Repository navigation
feat(impact-ledger): credit a page a person approved in an agent run to that run (00480) - #2137
Merged
Merged
Conversation
…0480)
A page a person sends or publishes from a card in an agent run's chat
("agent run, you approved", CHAT-22 §2 item 2, mockup #f-impact) named no
run, so the impact ledger never counted it for the agent.
Migration 00480 adds content_draft_deliveries.via_agent_run_id (FK to
chat_agent_runs, on delete set null, partial index), with a check that a
send names at most one run: agent_run_id keeps meaning "sent on its own"
(the Library's wording is unchanged). POST /api/content-drafts/send and
/publish-cms take an optional viaAgentRunId (a guid); sendContentPages
keeps it on the deliveries before they go, only once it is the
workspace's run on that brand (the click comes through a server action
any member's session can call), never beside an agent's own run. A run
that doesn't check out is logged and the page still goes.
schema.sql and the web's Supabase types follow; the schema test reads
the migration.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
…to that run agentOrigin (ship.js) now reads via_agent_run_id (00480) as well as an agent's own send: the ship event names the agent, the agent run and the run's Chat run (its chat's newest, as the web's chatRunOf reads it), while shipped_by stays the person and execution_mode stays assisted. A run of another workspace names none. An agent's own send is unchanged. A ship event written after its agent run ended (a CMS draft published there later, a confirmation filled in by the nightly job) now marks that run Pending at once, never over an outcome already read, so it doesn't show "—" until day 7; a run still going says Pending as it ends (markShipped). syncAgentRuns then gives it its verdict through the same agent_run_id, which a job test now covers end to end. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
…its chat push_cms_draft, publish_cms and trigger_content_webhook pass the run the chat is (ctx.chat.agentRunId) to sendDraftToCms, publishDraftToCms and sendDraftToWebhook, which send it to the API as viaAgentRunId. A row's run is always the person's click here (an agent going live on its own goes through the engine's own route), so this is "agent run, you approved"; a person's own chat, the Content Editor and the Library send none. Help: Agent Center's article says what a run's outcome counts, and that a page published later from the Content Editor or the Library is the person's; approved-articles.json follows. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
closeTakenDown stores the reason taken_down, which Reports › What Ansvisor did for you read as "It can't be measured.". It now says "The page was taken down from your site.". Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
…in a person's chat The engine test's Admin click in a person's own chat now expects no run (null), and the owner's click on an agent run's held go-live card expects that run: "agent run, you approved" (00480), end to end through the engine. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
cihan-gyk
pushed a commit
to cihan-gyk/ansvisor
that referenced
this pull request
Nov 5, 2026
Brings in Onboarding & Help (ansvisor#2136, /setup as the 22nd skill), ansvisor#2134, ansvisor#2135 and ansvisor#2137. Conflicts kept both: /setup then /fanout in SKILL_ORDER and everywhere the library is listed (23 skills), Fan-out Gap Filler and Onboarding & Help both ready (20 ready presets, 19 Soon). The tests that used Fan-out Gap Filler as their Soon example now use Localization. Help: skills.md gives Fan-out gaps a section of its own, so The Ansvisor skills stays within 150 words. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
cihan-gyk
pushed a commit
to cihan-gyk/ansvisor
that referenced
this pull request
Nov 5, 2026
…t-card Brings in ansvisor#2134, ansvisor#2135, ansvisor#2136 (the Onboarding & Help agent) and ansvisor#2137 (impact-ledger ship credit, 00480). Conflict in help/chat/agents.md: both sides added a section after "An agent's page". Kept both, "What this agent did" (this branch) then "What a run's outcome means" (ansvisor#2137), in the page's order; each stays under 150 words. impact-report.tsx merged cleanly: ansvisor#2137's taken_down reason in REASONS beside this branch's move of the pills, outcome words and signed numbers to impact-parts.ts. approved-articles.json regenerated. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
cihan-gyk
pushed a commit
to cihan-gyk/ansvisor
that referenced
this pull request
Nov 5, 2026
…ites
A person's click on a card in an agent run's chat now ships with the
agent and its run (00480, ship.js agentOrigin), execution_mode assisted
and shipped_by the person; the agent's own send stays automated. The card
already reads automated as "on its own" and the rest by who sent it, so
nothing changes in the read: the tests now use that data. Each change in
the credit test names its run, a page sent later from the Content Editor
or the Library (no agent) isn't listed, and the agent's own change reads
"on its own" to every viewer. The card's fixtures ship "you approved" and
"by {name}" rows as assisted, and a page taken down shows ansvisor#2137's reason.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
cihan-gyk
pushed a commit
to cihan-gyk/ansvisor
that referenced
this pull request
Nov 5, 2026
Main brought ansvisor#2137 (00480) and ansvisor#2143. schema.sql is rebuilt with build-schema.sh (00480 then 00481). help/chat/agents.md's front matter keeps both keyword and synonym lists (Agent work's and Onboarding's). approved-articles.json regenerated. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
gkhngyk
pushed a commit
that referenced
this pull request
Nov 5, 2026
…n its page (#2148) * refactor(reports): share the impact ledger's pills, outcome words and ship-row read Reports' outcome pill colors, "Pending · early signal" label and signed numbers move to components/reports/impact-parts.ts, and the ship_events embed (action number, measurement) and measurementOf to lib/impact/report.ts, so the agent page's "What this agent did" shows a change exactly as Reports does. Reports reads and renders as before. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9 * feat(chat): read what an agent's runs took live in the last 30 days GET /api/chat/agents/{id}/impact answers the agent's ship events of the last 30 days (agent_id) with their measurements, read by Reports' own impactRow and impactSummary (Improved counts Medium and High verdicts only), on the brands the person may see as the ledger's policy (00424) has it. Each change says how it went live (on its own, the reader approved it, or a teammate) and its run's number among the agent's runs the person sees, with the run's chat when they may open it. It also counts the drafts the agent's runs of the last 30 days made that no ship event names, found through the draft's chat: content_drafts.conversation_id -> chat_conversations.agent_run_id -> chat_agent_runs.agent_id. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9 * feat(chat): show "What this agent did" on the agent page Between Triggers and Run history, as the owner approved it: the last 30 days, with no period to pick. Changes shipped, Improved X of Y (Medium and High verdicts only, "—" before any) and Pending; each change with how it went live ("run #31, on its own", "you approved", "by Sam Lee"), its outcome in Reports' words and its next checkpoint; how many drafts aren't live yet; the method line and Open in Reports, as Reports has no link to one change. Three states: with results, the first week, and nothing live yet. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9 * docs(help): what an agent's page says it did in the last 30 days Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9 * test(chat): read "you approved" from the ship events #2137 writes A person's click on a card in an agent run's chat now ships with the agent and its run (00480, ship.js agentOrigin), execution_mode assisted and shipped_by the person; the agent's own send stays automated. The card already reads automated as "on its own" and the rest by who sent it, so nothing changes in the read: the tests now use that data. Each change in the credit test names its run, a page sent later from the Content Editor or the Library (no agent) isn't listed, and the agent's own change reads "on its own" to every viewer. The card's fixtures ship "you approved" and "by {name}" rows as assisted, and a page taken down shows #2137's reason. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9 * docs(help): find "What this agent did" by its words, and say how a change went live Agent Center's article gets keywords and synonyms for the agent page's card (what this agent did, agent impact, what did my agent do), now that #2136's Onboarding & Help keywords are on main, and its section says the three ways a change went live: on its own, you approved on a card in the run's chat (00480), or by a teammate. Sources name agent-impact.ts. approved-articles.json follows. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9 --------- Co-authored-by: Claude <[email protected]>
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
AGENTS-plan §2 rule 1 and §7 step 2 say every agent closes its loop with a measured result, and its page shows "what it did and what it moved". This PR lays the groundwork for the per-agent "What this agent did" card. The owner has approved the card's mockup, and the card is being built in a separate PR on top of this one.
The gap on main
content_draft_deliveries.agent_run_id),CHAT_AUTO_GO_LIVE, the Admins' switch and Full auto.What changes
content_draft_deliveries.via_agent_run_id:chat_agent_runs,on delete set null, with a partial index;agent_run_idkeeps its meaning, "sent on its own", so the Library's "Sent by {agent} · on its own" is unchanged.push_cms_draft,publish_cmsandtrigger_content_webhookpass the chat's agent run (ctx.chat.agentRunId) tosendDraftToCms,publishDraftToCmsandsendDraftToWebhook. Those send it to the API asviaAgentRunId.runhere is always a person's click, because an agent that goes live on its own goes through the engine's internal route.POST /api/content-drafts/sendandPOST /api/content-drafts/publish-cmstake an optionalviaAgentRunId, which must be a guid.sendContentPagesstores it on the deliveries before they go, but only after checking that it is a run of the same workspace and brand. Any member's session can call the server action, so the id is never trusted as given.ship.js,agentOrigin)via_agent_run_idtoo. The ship event then names the agent, the agent run, and the run's Chat run (the newest one in its chat, the same rule as the web'schatRunOf).shipped_bystays the person andexecution_modestaysassisted.markShipped).syncAgentRunsthen gives the verdict through the sameagent_run_id. A job test covers this end to end.taken_downread "It can't be measured." It now reads "The page was taken down from your site."help/chat/agents.mdgets a new section, "What a run's outcome means". It says which pages count for a run, and that a page published later from the Content Editor or the Library counts as yours.approved-articles.jsonis regenerated.Open questions
markShipped's follow-up checks (openAgentFollowUps) still don't open for it. That was already true on main for an agent's own late publishes, and this PR leaves it alone.Related issue
None. AGENTS-plan §7 step 2 (W2-20 per-agent impact); the owner chose option A1 on 2026-11-05.
Type of change
feat— New featurefix— Bug fix (thetaken_downwording only)chore— Maintenance / dependenciesdocs— Documentation onlyrefactor— Code change that neither fixes a bug nor adds a featuretest— Adding or updating testsHow to test
Apply migration 00480 (
needs-migration) before deploying the server. The server reads the new column, so until 00480 is applied, ship events for CMS confirmations fail and are logged. Once it is applied, the nightly job fills in any missed ones from the last 30 days.In an agent's run that waits on a Send to CMS or Publish card, approve the card. The send's row has
via_agent_run_idset to the run, andagent_run_idstays null.Once the CMS confirms the page is live, check the ship event:
agent_id,agent_run_idandrun_idare the agent's;execution_mode = 'assisted';shipped_byis you.The run's Outcome in Agent Center › the agent › Run history shows Pending, then the day-14 verdict.
Send the same kind of page from the Content Editor, the Library or your own chat. No run is named.
Tests:
cd server && npx vitest run src/lib/impact-ledger src/lib/content-delivery.test.js src/lib/cms-publish.test.js src/routes/content-drafts-send.test.js src/routes/content-drafts-publish-cms.test.jscd web && npx vitest run src/lib/chat/schema.test.ts src/lib/chat/registry/tools.test.ts src/lib/chat/write.test.ts src/lib/chat/engine.test.ts src/lib/actions/chat-content.test.ts src/components/reports/impact-report.test.tsx src/lib/helpengine.test.tscovers the click end to end: when the owner approves an agent run's held go-live card, the send names that run; when an Admin clicks in their own chat, it names none.There are no screenshots, because the only on-screen changes are the Help article and the one Reports reason line.
Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromweb/)yarn typecheckpasses (run fromweb/)yarn format:checkpasses (run fromweb/)taken_downwording fix found on the way)help/(or no user-visible change) — see help/README.mdChecks run locally on 4389fc9. The branch still merges cleanly into current
main.build-schema.shleavesschema.sqlunchanged.format:check, lint and typecheck pass. Lint has 0 errors; its 7 warnings were already on main, in files this PR doesn't touch. All tests pass (987 files, 10,590 passed, 1 skipped), andyarn buildpasses with CI's placeholder env.format:checkpass. All tests pass (419 files, 5,781 passed, 4 skipped).Merge note: open PR #1894 also edits
assertSenderand the/sendroute inserver/src/routes/content-drafts.js, next to this PR's lines. Whichever merges second gets a small conflict there.Generated by Claude Code