Open-source SEO, GEO, and marketing skills for AI agents.
chore(guardrails): drop unused autonomy guardrails feature
Yuting Zhong8257b78bb0d8
diff --git a/src/app/(app)/[project]/settings/page.tsx b/src/app/(app)/[project]/settings/page.tsxindex e76101b4..dfc09769 100644--- a/src/app/(app)/[project]/settings/page.tsx+++ b/src/app/(app)/[project]/settings/page.tsx@@ -1,11 +1,5 @@import { notFound } from "next/navigation";-import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";-import { Input } from "@/components/ui/input";-import { Label } from "@/components/ui/label";-import { Button } from "@/components/ui/button";import { getProject } from "@/server/db/projects";-import { getGuardrails } from "@/server/db/guardrails";-import { updateGuardrailsAction } from "@/server/actions/guardrails";import { DangerZone } from "@/components/danger-zone";import { ProjectRenameCard } from "@/components/project-rename-card";@@ -17,80 +11,16 @@ export default async function SettingsPage({const { project: slug } = await params;const project = getProject(slug);if (!project || project.archived_at) notFound();- const g = getGuardrails(project.slug);- const submit = updateGuardrailsAction.bind(null, project.slug);return (<div className="mx-auto max-w-2xl space-y-6"><header><h1 className="text-2xl font-semibold tracking-tight">Settings</h1><p className="text-sm text-muted-foreground">- Project <span className="font-mono">{project.slug}</span> · Autonomy guardrails+ Project <span className="font-mono">{project.slug}</span></p></header>- <Card>- <CardHeader>- <CardTitle>Autonomy</CardTitle>- <CardDescription>- Defaults are conservative. Loosen as you build trust with the CMO.- </CardDescription>- </CardHeader>- <CardContent>- <form action={submit} className="space-y-5">- <div className="grid gap-4 sm:grid-cols-2">- <Field- id="max_daily_spend_usd"- label="Max daily spend (USD)"- value={g.max_daily_spend_usd}- help="Hard cap. Halts all autonomous spending at this limit."- />- <Field- id="max_concurrent_experiments"- label="Max concurrent experiments"- value={g.max_concurrent_experiments}- help="CMO won't launch more than this many at once."- />- <Field- id="spend_per_action_usd"- label="Approval needed above (USD/action)"- value={g.require_approval_above.spend_per_action_usd}- help="Single actions above this go to approval inbox."- />- <Field- id="bid_changes_percent"- label="Approval needed for bid change ≥ (%)"- value={g.require_approval_above.bid_changes_percent}- help="Big bid swings get human approval."- />- </div>-- <fieldset className="space-y-3 rounded-md border p-4">- <legend className="px-1 text-xs uppercase text-muted-foreground">- Always require approval for:- </legend>- <Toggle- id="new_channel_first_action"- label="First action in a new channel"- checked={g.require_approval_above.new_channel_first_action}- />- <Toggle- id="content_publishing"- label="Content publishing (Reddit post, X tweet, email send)"- checked={g.require_approval_above.content_publishing}- />- <Toggle- id="audience_change"- label="Audience / targeting changes"- checked={g.require_approval_above.audience_change}- />- </fieldset>-- <Button type="submit">Save guardrails</Button>- </form>- </CardContent>- </Card>-<ProjectRenameCardcurrentSlug={project.slug}currentDisplayName={project.display_name}@@ -105,32 +35,3 @@ export default async function SettingsPage({</div>);}--function Field({- id,- label,- value,- help,-}: {- id: string;- label: string;- value: number;- help: string;-}) {- return (- <div className="space-y-1.5">- <Label htmlFor={id}>{label}</Label>- <Input id={id} name={id} type="number" defaultValue={value} step="any" min={0} />- <p className="text-[11px] text-muted-foreground">{help}</p>- </div>- );-}--function Toggle({ id, label, checked }: { id: string; label: string; checked: boolean }) {- return (- <label htmlFor={id} className="flex cursor-pointer items-center gap-2 text-sm">- <input id={id} name={id} type="checkbox" defaultChecked={checked} className="size-4" />- <span>{label}</span>- </label>- );-}diff --git a/src/server/actions/guardrails.ts b/src/server/actions/guardrails.tsdeleted file mode 100644index 0a4b3c00..00000000--- a/src/server/actions/guardrails.ts+++ /dev/null@@ -1,45 +0,0 @@-"use server";--import { revalidatePath } from "next/cache";-import { setGuardrails, getGuardrails } from "@/server/db/guardrails";--export async function updateGuardrailsAction(- project_slug: string,- formData: FormData,-): Promise<void> {- const current = getGuardrails(project_slug);- const max_daily_spend_usd = num(formData.get("max_daily_spend_usd"), current.max_daily_spend_usd);- const max_concurrent_experiments = num(- formData.get("max_concurrent_experiments"),- current.max_concurrent_experiments,- );- const spend_per_action_usd = num(- formData.get("spend_per_action_usd"),- current.require_approval_above.spend_per_action_usd,- );- const bid_changes_percent = num(- formData.get("bid_changes_percent"),- current.require_approval_above.bid_changes_percent,- );-- setGuardrails({- project_slug,- max_daily_spend_usd,- max_concurrent_experiments,- require_approval_above: {- spend_per_action_usd,- new_channel_first_action: formData.get("new_channel_first_action") === "on",- content_publishing: formData.get("content_publishing") === "on",- bid_changes_percent,- audience_change: formData.get("audience_change") === "on",- },- });-- revalidatePath("/", "layout");-}--function num(v: FormDataEntryValue | null, fallback: number): number {- if (typeof v !== "string") return fallback;- const n = Number(v);- return Number.isFinite(n) ? n : fallback;-}diff --git a/src/server/agent-templates.ts b/src/server/agent-templates.tsindex 32a7d68d..1ee7d8ab 100644--- a/src/server/agent-templates.ts+++ b/src/server/agent-templates.ts@@ -391,7 +391,7 @@ Style:description: "Runs Google Ads campaigns, keywords, bids, budgets, search terms, negatives.",capabilities: ["Audit account health + identify wasted spend",- "Propose + apply bid changes within guardrails",+ "Propose + apply bid changes","Manage keywords, ad groups, negative lists","Pull performance metrics + surface anomalies","Schedule recurring bid/metric jobs",diff --git a/src/server/db/guardrails.ts b/src/server/db/guardrails.tsdeleted file mode 100644index 6cf2286a..00000000--- a/src/server/db/guardrails.ts+++ /dev/null@@ -1,39 +0,0 @@-import { getDb } from "./db";-import type { Guardrails } from "@/types";--export const DEFAULT_GUARDRAILS: Omit<Guardrails, "project_slug"> = {- max_daily_spend_usd: 200,- max_concurrent_experiments: 3,- require_approval_above: {- spend_per_action_usd: 50,- new_channel_first_action: true,- content_publishing: true,- bid_changes_percent: 25,- audience_change: true,- },-};--export function getGuardrails(project_slug: string): Guardrails {- const db = getDb();- const row = db- .prepare("SELECT config_json FROM guardrails WHERE project_slug = ?")- .get(project_slug) as { config_json: string } | undefined;- if (!row) return { project_slug, ...DEFAULT_GUARDRAILS };- try {- const parsed = JSON.parse(row.config_json) as Omit<Guardrails, "project_slug">;- return { project_slug, ...parsed };- } catch {- return { project_slug, ...DEFAULT_GUARDRAILS };- }-}--export function setGuardrails(g: Guardrails): void {- const db = getDb();- const { project_slug, ...config } = g;- const config_json = JSON.stringify(config);- const now = new Date().toISOString();- db.prepare(- `INSERT INTO guardrails (project_slug, config_json, updated_at) VALUES (?, ?, ?)- ON CONFLICT(project_slug) DO UPDATE SET config_json = excluded.config_json, updated_at = excluded.updated_at`,- ).run(project_slug, config_json, now);-}diff --git a/src/server/db/migrations.ts b/src/server/db/migrations.tsindex fcfe226f..da736e5d 100644--- a/src/server/db/migrations.ts+++ b/src/server/db/migrations.ts@@ -175,6 +175,15 @@ FROM numberedWHERE tasks.id = numbered.id;CREATE UNIQUE INDEX IF NOT EXISTS idx_tasks_display_id ON tasks(display_id);+`,+ },+ {+ name: "005_drop_guardrails.sql",+ sql: `+-- Remove the guardrails autonomy feature. The Settings page no longer+-- exposes per-project autonomy knobs and no runtime code reads/writes+-- this table, so drop it to keep the schema honest.+DROP TABLE IF EXISTS guardrails;`,},];diff --git a/src/server/db/migrations/005_drop_guardrails.sql b/src/server/db/migrations/005_drop_guardrails.sqlnew file mode 100644index 00000000..e7e30a24--- /dev/null+++ b/src/server/db/migrations/005_drop_guardrails.sql@@ -0,0 +1,4 @@+-- Remove the guardrails autonomy feature. The Settings page no longer+-- exposes per-project autonomy knobs and no runtime code reads/writes+-- this table, so drop it to keep the schema honest.+DROP TABLE IF EXISTS guardrails;diff --git a/src/server/db/projects.ts b/src/server/db/projects.tsindex ac1a40f8..b4deb052 100644--- a/src/server/db/projects.ts+++ b/src/server/db/projects.ts@@ -114,7 +114,6 @@ export function changeProjectSlug("approvals","cost_events","oauth_tokens",- "guardrails","agent_actions","sequence_runs",];@@ -188,7 +187,6 @@ export function deleteProjectRow(slug: string): void {"approvals","cost_events","oauth_tokens",- "guardrails","agent_actions","sequence_runs",];diff --git a/src/types/index.ts b/src/types/index.tsindex c91ab71e..e6ced44c 100644--- a/src/types/index.ts+++ b/src/types/index.ts@@ -24,7 +24,7 @@ export type TaskStatus =| "failed"| "cancelled";-// ┌──────────┐ approve(within guardrails) ┌──────────┐ agent picks up ┌─────────┐+// ┌──────────┐ user approves ┌──────────┐ agent picks up ┌─────────┐// │ proposed │ ─────────────────────────────▶│ approved │ ────────────────▶│ running │// └──────────┘ needs_approval └──────────┘ └────┬────┘// │ ▲ │@@ -121,19 +121,6 @@ export type OAuthToken = {updated_at: string;};-export type Guardrails = {- project_slug: string;- max_daily_spend_usd: number;- max_concurrent_experiments: number;- require_approval_above: {- spend_per_action_usd: number;- new_channel_first_action: boolean;- content_publishing: boolean;- bid_changes_percent: number;- audience_change: boolean;- };-};-export type ToolErrorEnvelope = {ok: false;error_code: string;