Repository navigation
feat(chat): let an allowed agent send CMS drafts on its own (00445) - #1982
Merged
gkhngyk merged 17 commits intoNov 2, 2026
Merged
Conversation
…permission AUTONOMOUS-GO-LIVE PR 1 (migration 00443), with nothing reading it yet: chat_settings gains the workspace switch (auto_go_live_groups, who turned it on, when, under which terms); chat_agent_go_live keeps an agent's permission for the version it was given on, with its daily limit (1-20, 5 unless set); chat_agent_go_live_events keeps each step an agent takes live on its own, read by brand access. reserve_agent_go_live and finish_agent_go_live (service role) hold the daily limit under a lock per agent, once per (draft, target); a failed step frees its slot. Types, schema.sql, and the brand-access and demo coverage lists follow. Co-Authored-By: Claude Opus 5.5 <[email protected]>
AUTONOMOUS-GO-LIVE PR 3 (owner's Q1 answer B): pure checks on the page as it would go out, for a later PR's go-live step. go-live-checks.ts holds a page with text aimed at AI (in its text or its structured data), hidden text, 30 words in a row copied from an untrusted read of the run, or a link to a site that isn't the brand's, a source the draft lists, or a page a read listed (page-sites linksToSites, sitesOfPages). An agent run now keeps its untrusted reads as 64-bit hashes of 12-word runs in its progress, 32 KB at most; past that the check holds the page. A person's own chat keeps none. Nothing calls the checks yet. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…er session AUTONOMOUS-GO-LIVE PR 4 (migration 00444). POST /api/internal/chat/go-live/send (CRON_SECRET) is how the web's engine will send an agent's page on its own: it checks everything again from the database (Chat on, Full auto's plan, the Admins' switch, the run running as the person, the agent's permission for the run's version, the person's role and the Managers' publishing switch, brand access, not the demo brand, and the step's own reservation), then sends as a person's Send to CMS does, with the agent run kept on the delivery (content_draft_deliveries.agent_run_id). The step is finished done, or failed with why, which frees its slot; a refusal frees only this step's own slot. Never retried. v1 takes CMS drafts only. Nothing calls it yet. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… test's model steps out of a hook-named helper Co-Authored-By: Claude Opus 5.5 <[email protected]>
…function AUTONOMOUS-GO-LIVE PR 2a. lib/content/quality-inputs.ts qualityState() computes E-E-A-T, Trust and Readability and what the editor shows beside them from the reads the editor holds, so PR 2b's server gate for an agent going live on its own computes them exactly as the editor does. The editor's two dozen memos become one call after its reads; nothing on screen changes. quality-inputs.test.ts keeps the editor's code from before the move and shows both give the same values for four page types in each phase, for every read still pending, and with Quality off. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ate, on the run's budget AUTONOMOUS-GO-LIVE PR 2b-1 (the owner's 2026-11-02 decision). POST /api/internal/chat/go-live/quality-reads (CRON_SECRET) reads the draft as saved for the web's gate: its links, and with Quality's phase 2 its claims, its page read and the kinds of the sites the gate's rules can't place. A kept read costs nothing; a new one is the agent run's own step (chat-budget agentRunReserve: feature agent, within the run's cap and the month's budget), not the workspace's Quality budget. Each read answers on its own (run_cap, ai_budget, off, failed), so the gate can hold the page on the one it lacks. The three reads take an optional meter; the page read's brand context moves to content-page-context.js for both callers. Nothing calls the endpoint yet. Co-Authored-By: Claude Opus 5.5 <[email protected]>
AUTONOMOUS-GO-LIVE PR 6. Settings › Chat gets "Agents that publish on their own", under what Managers may take live: an Admin's switch, off by default, locked below Growth and while Content Quality is off, read-only for everyone else. Turning it on asks the Admin to accept the responsibility text first (its version kept with who and when, 00443); turning it off needs no dialog. Hidden unless staff turn on CHAT_AUTO_GO_LIVE for the workspace (autoGoLiveEnabled). Where it shows, the page's "EXECUTE needs a click" lines say an Admin may let an agent go live on its own. Help: a new Settings › Chat article, and the "nothing is published without your click" lines name the exception. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…trust with the draft's reads Co-Authored-By: Claude Opus 5.5 <[email protected]>
…mo guard leaves Co-Authored-By: Claude Opus 5.5 <[email protected]>
…-reads Co-Authored-By: Claude Opus 5.5 <[email protected]>
…efore an agent takes it live AUTONOMOUS-GO-LIVE PR 2b-2. lib/content/go-live-gate.ts goLiveGate() gathers, with no one's session, every read the Content Editor's scores take (the draft, its authors, inputs, sources, rules, confirmations, own images and catalog product; its links, claims, page read, sources' kinds, brand facts and site trust from the server's go-live reads, made on the agent run's budget when none is kept) and scores the page with the editor's own qualityState. It holds the page for a click, with why: with Content Quality off, placeholders or fields a CMS won't take, suggestions waiting, a read that couldn't be made, a fact that differs from an approved one or one stated with none approved, a score under 60 or an average under 75. A score with nothing to judge is left out, as the editor's average leaves it. To read the page as the editor does on the server: the catalog match takes a client (catalog-match.ts), the editor's StarterKit options and the HTML block's node schema move to lib (the editor uses the same), and textRanges and openSpotPlaces move to lib/content/doc-text.ts with pageDoc(), which parses a page into the editor's document. Nothing calls the gate yet. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…check the plan themselves Co-Authored-By: Claude Opus 5.5 <[email protected]>
…-go-live-agent-drafts
…live-agent-drafts
AUTONOMOUS-GO-LIVE PR 5. Step 4b of the precedence: for an agent run in Full auto whose agent an Admin allowed for the run's version, on a workspace whose Admins let agents take publishing live, on Growth and up and behind CHAT_AUTO_GO_LIVE, the Send to CMS click is lifted once the guards pass (injection and untrusted start, the page as Send to CMS makes it, its text and links, a live page, the quality gate, the daily limit). The engine reserves the agent's slot, sends the checked page through the API's internal route as the run's person, and logs it as go_live (00445). A guard that fails, a full limit or a failed send keeps the click card and says why. Interactive Chat and MCP keep the click; nothing can turn it on until the Settings switch and the agent's box ship. Co-Authored-By: Claude Opus 5.5 <[email protected]>
8 of 13 tasks
# Conflicts: # server/src/lib/brand-access-policies.test.js # server/src/middleware/demo-brand.test.js # supabase/schema.sql # web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_draft-editor.tsx # web/src/lib/chat/engine.test.ts # web/src/lib/chat/engine.ts # web/src/lib/chat/precedence.ts # web/src/lib/chat/registry/define-tool.ts # web/src/lib/chat/write.ts # web/src/lib/content/quality-inputs.test.ts # web/src/lib/content/quality-inputs.ts
8 of 13 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
AUTONOMOUS-GO-LIVE PR 5: an agent an Admin allowed can send a Library draft to the brand's CMS without a click, once its guards pass (§5, §6). Behind
CHAT_AUTO_GO_LIVE. Nothing can turn it on yet: the per-agent permission is set by PR 7's box. Interactive Chat and MCP keep the click.Stacked on #1979 (the quality gate), #1978 (the server's reads, with #1970's internal send and #1967's tables), #1968 (text and link checks) and #1977 (
autoGoLiveEnabled). Migration 00445;schema.sqlregenerated.The precedence: step 4b (
lib/chat/precedence.ts)It is the one exception to hard rule 1. It is evaluated last for an EXECUTE, and only turns a
clickintorun/go_live. It never lifts a denial or a card: read-only, the demo brand, an Admin's Never, the role and "publishing off for Managers" still decide first.goLiveCandidate(tool, ctx), all of these:{}matches today);goLive.goLiveHold(ctx, facts): the guards in order, and the first that fails keeps the click with a held reason:A missing fact gives
unchecked, the closed side.policyChoices,allowedToolsandlistingDenialare unchanged. WRITE taint is unchanged.The registry
defineToolgetsgoLive(input)(kind, draft, target), which setsflags.goLiveOnOwn.push_cms_drafthas it.The facts (
lib/chat/go-live-facts.ts, new)getContentDraftPackageFor, as Send to CMS makes it. That same page is what gets sent, so what was checked is what goes out.reserve_agent_go_livedoes. The page's own pair takes no new slot;nextAtis when the first slot frees.The send (
lib/chat/go-live-send.ts, new; the engine;write.ts)reserve_agent_go_live). A full limit, or a slot that can't be reserved, opens the click card with why.runLoggedWriteallows an EXECUTE withauto/go_liveonly for an agent run with its run id, its slot and page, on a row withgoLive. Anything else still throws./api/internal/chat/go-live/send(CRON_SECRET), which checks everything again from the database. Answers are mapped assendDraftToCmsanswers them.askWithoutSessionleavesgo_livealone: this path exists for runs with no session.{step}:go_live), so the person's later click runs the person's own send anew instead of replaying the failure.keepReadSitesalso keeps a read's structured sites in agent runs, so a page may link to cited and competitor pages a read listed.Words and Activity
noteline: "Held for your click: {reason}" (chatEngine.held.*, §7.3's words). It is shown the same way as the no-session note today. No new component.auto/go_livewith the agent and its run;logActivityrefusesgo_liveoutside an agent run's EXECUTE.chat_activity_log.auto_viaacceptsgo_live, and a check keeps it to an EXECUTE with anagent_run_id.42P01,PGRST205,42703andPGRST204.Not in this PR (later PRs of the spec): the Inbox notice (PR 8), publish and Take down (PRs 9, 10), webhook (PR 11), the agent's box (PR 7).
Related issue
None. AUTONOMOUS-GO-LIVE spec, PR 5.
Type of change
feat— New featurefix— Bug fixchore— Maintenance / dependenciesdocs— Documentation onlyrefactor— Code change that neither fixes a bug nor adds a featuretest— Adding or updating testsHow to test
Unit tests:
precedence.test.ts, step 4b's matrix:goLive) gives a plain click;unchecked;execute_off, and read-only, demo, Never and an Analyst are denied before 4b;precedence-context.test.ts:go-live-facts.test.ts:write.test.ts:sendDraftToCms, loggedauto/go_livewith the agent;goLive, for a WRITE, and for Full auto;engine.test.ts, an agent run with no session:tools.test.ts:goLiveonly on an EXECUTE with no free-text target; onlypush_cms_drafthas it.activity-view.test.ts: the label and the CSV.No reachable UI change: the held line and the Activity label show only once an Admin allows an agent (PR 7). So no Help article in this PR; PR 7 updates
agents.mdwith the held card. Migration 00445 must be applied to the dev database before PR 7's manual test.Checklist
yarn lintpassesyarn typecheckpassesyarn format:checkpasseshelp/(or no user-visible change)CI passed on this branch (4f9d788), run on the fork (https://github.com/cihan-gyk/ansvisor/actions/runs/41365960030): schema is up to date; web
format:check, lint, typecheck, all tests andyarn buildpass; server lint,format:checkand all tests pass.🤖 Generated with Claude Code