Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
#5575 memory trust: claim and legacy-scan fixes are the user's to run (tell_user_to_run)
garrytan756fc024d5fc
diff --git a/docs/architecture/key-files/security.md b/docs/architecture/key-files/security.mdindex 219e5b23e1..b0ecc6743c 100644--- a/docs/architecture/key-files/security.md+++ b/docs/architecture/key-files/security.md@@ -28,7 +28,7 @@ Current behavior and load-bearing invariants; history belongs in Git and CHANGEL- `src/core/ssrf-validate.ts` — DNS-rebinding-defended URL validation. `validateAndResolveUrl(url)` resolves the hostname via `dns.lookup({all: true, family: 0})`, checks EVERY A and AAAA record against the internal-IP deny list, and returns the resolved IP so callers fetch by IP (validation IP === fetch IP defeats DNS rebinding). `fetchWithSSRFGuard(url, opts)` does redirect-aware fetching with per-hop re-validation (max 3 hops by default). Reusable across all URL-fetching features. Test seam `__setDnsLookupForTests` for hermetic tests.-- `src/core/trust/claim.ts` + `claim-state.ts` + `claim-notice.ts`, `src/commands/trust-claim.ts`: #5575 legacy content. `gbrain trust claim-sources` (local CLI; typed source id on a TTY, `--yes` never counts, non-TTY refuses `confirmation_required` with an ask_user fix) records a claim in `sources.config` (`trust_tier: operator_curated`, `trust_claimed_at`, `trust_claim_lifted_at`) and lifts the source's legacy `unknown` rows (ids at or below `write_gate.scan_baseline`) through `trust/backfill.ts` scoped to the claimed sources (own cursor, `write_origin.channel` `trust_claim`), lowered by `frontmatterTrustCapsSql` (channel.ts, pinned to `frontmatterTrustCaps`) and every backfill signal, never above operator_curated; connector sources refuse. Doctor `trust_sources_unclaimed`, `gbrain post-upgrade` and the behavior-change notice ask (ask_user); doctor `trust_scan` asks before scanning; the scan refuses while a lift is pending; explain and review show pending rows as owner tier. Guide: `docs/guides/memory-trust.md`. Tests: `test/trust-claim.test.ts`.+- `src/core/trust/claim.ts` + `claim-state.ts` + `claim-notice.ts`, `src/commands/trust-claim.ts`: #5575 legacy content. `gbrain trust claim-sources` (local CLI; typed source id on a TTY, `--yes` never counts, non-TTY refuses `confirmation_required` with a tell_user_to_run fix) records a claim in `sources.config` (`trust_tier: operator_curated`, `trust_claimed_at`, `trust_claim_lifted_at`) and lifts the source's legacy `unknown` rows (ids at or below `write_gate.scan_baseline`) through `trust/backfill.ts` scoped to the claimed sources (own cursor, `write_origin.channel` `trust_claim`), lowered by `frontmatterTrustCapsSql` (channel.ts, pinned to `frontmatterTrustCaps`) and every backfill signal, never above operator_curated; connector sources refuse. Doctor `trust_sources_unclaimed`, `gbrain post-upgrade` and the behavior-change notice name the claim (`actor: user`, tell_user_to_run); doctor `trust_scan`'s fix is the user's to run; the scan refuses while a lift is pending; explain and review show pending rows as owner tier. Guide: `docs/guides/memory-trust.md`. Tests: `test/trust-claim.test.ts`.- `src/core/write-gate.ts` + `src/core/write-gate-patterns.ts` — the #5575 blocking write gate, separate from observe-only `guardrails.ts` (never imported). Deterministic and model-free (P8): `WRITE_GATE_PATTERNS` (bounded clones of the detection-grade `think/sanitize.ts` `INJECTION_DETECTION_PATTERNS`, the exported transcript `IMPERATIVE_RES`, plus standing-instruction (incl. agent-addressed rules with long run-ups, concealment and act-without-asking clauses), exfiltration (incl. passive "must be emailed to <address>" rules and direct cc/bcc) and credential patterns; families `override`, `standing_instruction`, `exfiltration`, `credential`). `detectInstructionLike` decodes tag characters, strips invisibles and NFKC-folds compatibility forms only when present, finds anchor words in one allocation-light hash pass (one tight loop per word), then runs each pattern only on 4 KB windows (overlap `MAX_MATCH_CHARS` + `MAX_PRECEDING_CHARS`) holding its anchors, tracked as sliding per-window anchor counts, and inside a window only within the pattern's longest match (`write-gate-regex.ts`, the analysis the regex lint uses) of its own anchor words, except `WHOLE_WINDOW_PATTERNS`; `preceded` regexes check context before a rare-token match, a `neg` group rejects negated matches. `assessPageForGate` (title, body minus managed fence table rows, frontmatter strings), `assessFactForGate` (fact, context, value, provenance, pre-sanitized `source_text`), `assessTakeForGate` and `assessTimelineForGate` scan every attacker-controllable field plus origin strings. Verdicts by tier: owner tiers never assessed; `external_untrusted` -> `write_gate.external_mode` (`quarantine` default, `flag`, `reject`, `off`), detector error -> quarantine; `agent_written`/`unknown` -> `flag` (`write_gate.agent_mode=off`), detector error -> allow. `writeGateOutcome` is the DX-1 `gate` shape; `writeHeldError` / `writeGateRejectedError` build the `write_held` / `write_gate_rejected` refusals (families only, no pattern names). `scripts/check-write-gate-regex.ts` (in verify) proves every pattern bounded. Tests: `test/write-gate.test.ts`, `test/write-gate-perf.slow.test.ts`, `test/write-gate-anchor-ranges.test.ts` (sampled matches of every narrowed pattern hold an anchor word within its longest match), and `test/write-gate-detector-differential.test.ts` (identical hits to the pre-optimization detector v2 kept as `test/helpers/write-gate-detector-reference.ts`, over the detector corpora, BrainBench fixtures, docs/skills and a seeded random corpus).- `src/core/write-gate-store.ts` + `src/core/write-gate-schema.ts` — `write_gate_receipts` (flag/quarantine verdicts per persisted target, unique on target, content hash and detector version; pattern names only) and `write_gate_holds` (quarantined facts/takes kept out of `facts`/`takes`, unique on source, slug, fingerprint and detector version; re-arrival re-opens a decided hold). Writers record inside their publication transaction: `recordPageGateReceipt` resolves the live page row, `recordWriteGateReceipt`, `recordWriteGateHold`; `decideFactWrite` / `decideTakeWrite` return insert/hold/reject per row and `recordFlaggedRow` receipts an inserted flagged row. Owner review: `listWriteGateHolds`, `getWriteGateHold`, `releaseWriteGateHold` (returns the payload for the confirm path; authorization is the caller's), `dropWriteGateHold`; `pruneWriteGateReceipts` drops receipts unseen for 365 days except a pending hold's. Tests: `test/write-gate-store.test.ts` (+ Postgres arm `test/e2e/write-gate-store-postgres.test.ts`).diff --git a/docs/guides/memory-trust.md b/docs/guides/memory-trust.mdindex dbb966db0c..9644a6e1a6 100644--- a/docs/guides/memory-trust.md+++ b/docs/guides/memory-trust.md@@ -37,8 +37,8 @@ recall and `get_page`. Proactive surfaces (hook context, the context engine,sources and agree to the scan.** Older rows have no provenance, so they readas "unverified origin". On a long-lived brain that is most rows, includingyour own notes and synced code repositories. gbrain never scans them on its-own. Doctor, `gbrain post-upgrade` and the behavior-change notice ask you-first.+own. Doctor, `gbrain post-upgrade` and the behavior-change notice tell you+the commands to run.## Claim your sources (once, after upgrading)@@ -65,8 +65,8 @@ Typing a source's id claims it as your own notes:comes from other people.Claiming needs you at a terminal on the brain host. Without one (an agent,-piped input) the command changes nothing. It exits 3 with an `ask_user` fix,-whose `user_message` explains claiming.+piped input) the command changes nothing. It exits 3 with a fix whose+`next` is `tell_user_to_run`; its `user_message` explains claiming.The lift runs in bounded batches. If it is interrupted,`gbrain trust claim-sources --resume` finishes it without asking again. Until@@ -89,16 +89,17 @@ The scan runs the write gate's deterministic detector over older rows at"written by an agent" or below. It records a receipt for each instruction-likerow. It never deletes, moves or rewrites anything, but flagged rows stopreaching proactive context until you confirm them. Doctor's `trust_scan`-check therefore asks you before an agent runs it (`fix.next: ask_user`).+check therefore leaves it to you (`fix.next: tell_user_to_run`): no agent+starts it.Claim your own sources first, so your notes are not treated as unverified.## Doctor checks- `trust_sources_unclaimed` warns while unclaimed, non-connector sources hold- rows from before trust tiers, with `fix.next: ask_user` naming+ rows from before trust tiers, with `fix.next: tell_user_to_run` naming`gbrain trust claim-sources`. It also warns, with the resume command, whilea claim's lift has not finished. A fresh or empty brain is ok.- `trust_scan` warns while older rows at "written by an agent" or below have- not been scanned. Its fix asks you first.+ not been scanned. Its fix is yours to run (`tell_user_to_run`).- `trust_tiers` reports the tier mix and recommends `gbrain trust backfill`.The backfill classifies older rows from deterministic signals only.diff --git a/src/commands/doctor/checks/trust-scan.ts b/src/commands/doctor/checks/trust-scan.tsindex cb21fe7d5b..9b3e5be2ca 100644--- a/src/commands/doctor/checks/trust-scan.ts+++ b/src/commands/doctor/checks/trust-scan.ts@@ -2,11 +2,12 @@* trust_scan (#5575, DX-6 / ENG-8): rows at `agent_written` or lower that* the write gate's current detector has not scanned. Activation control* (CEO-20) only covers scanned rows, so unscanned legacy rows can still be- * injected by proactive surfaces. The fix is `fix.next: ask_user`: `gbrain- * trust scan` records flag receipts in bounded, resumable batches and changes- * no row, but a flagged row stops reaching proactive context, so the scan of- * legacy content runs only after the user agrees (and ideally after they- * claimed their own sources: trust_sources_unclaimed).+ * injected by proactive surfaces. The fix is `actor: 'user'` (`fix.next:+ * tell_user_to_run`): `gbrain trust scan` records flag receipts in bounded,+ * resumable batches and changes no row, but a flagged row stops reaching+ * proactive context, so no agent starts the legacy scan; the user runs it+ * after reading user_message (ideally after claiming their own sources:+ * trust_sources_unclaimed).* A brain before the trust or write-gate migrations is ok. Read-only.*/import type { Check } from '../../doctor.ts';@@ -18,7 +19,7 @@ import { isUndefinedColumnError, isUndefinedTableError } from '../../../core/uticonst SCAN_USER_MESSAGE = 'gbrain can check your memory written before its write gate for text that reads like instructions to an AI '+ '(for example "from now on always say..."). Anything it flags stays in your brain and in search, but agents stop getting it automatically '+ 'until you confirm it in gbrain trust review. If some sources are your own notes, claim them first (gbrain trust claim-sources) so the check '- + 'treats them as yours. Run the check now?';+ + 'treats them as yours. To run the check, run gbrain trust scan on the brain host.';async function runTrustScan(ctx: DoctorContext): Promise<Check[]> {const engine = connectedEngine(ctx);@@ -33,10 +34,10 @@ async function runTrustScan(ctx: DoctorContext): Promise<Check[]> {}checks.push({ name: 'trust_scan', status: 'warn', details,message: `${state.total_unscanned} agent-written or lower row(s) have not been scanned by the write-gate detector (v${state.detector_version}), `- + 'so proactive surfaces do not withhold instruction-like ones yet. Ask the user before running gbrain trust scan: it records receipts in resumable batches and changes no row, '+ + 'so proactive surfaces do not withhold instruction-like ones yet. Tell the user about gbrain trust scan; they run it if they want it: it records receipts in resumable batches and changes no row, '+ 'but flagged rows (their own older notes included, unless they claimed those sources first with gbrain trust claim-sources) stop reaching proactive context until confirmed.',- fix: { argv: ['gbrain', 'trust', 'scan'], consent: ['destructive'], actor: 'agent', requires_exclusive: false, verify: doctorVerify('trust_scan'),- why: 'Scans legacy agent-written and unverified rows with the deterministic detector and records flag receipts; it moves, deletes or rewrites nothing, but flagged rows stop reaching proactive context until the owner confirms them, so it runs only after the user agrees.',+ fix: { argv: ['gbrain', 'trust', 'scan'], consent: [], actor: 'user', requires_exclusive: false, verify: doctorVerify('trust_scan'),+ why: 'Scans legacy agent-written and unverified rows with the deterministic detector and records flag receipts; it moves, deletes or rewrites nothing, but flagged rows stop reaching proactive context until the owner confirms them, so the user runs it after reading user_message; no agent starts it.',user_message: SCAN_USER_MESSAGE } });} catch (err) {if (isUndefinedColumnError(err, 'trust_tier') || isUndefinedTableError(err)) {diff --git a/src/commands/doctor/checks/trust-sources-unclaimed.ts b/src/commands/doctor/checks/trust-sources-unclaimed.tsindex 7a29d26dc7..2139b06d85 100644--- a/src/commands/doctor/checks/trust-sources-unclaimed.ts+++ b/src/commands/doctor/checks/trust-sources-unclaimed.ts@@ -2,8 +2,8 @@* trust_sources_unclaimed (#5575, legacy content): warns while live,* non-connector sources the owner has not claimed hold rows still at* `unknown` (written before trust tiers, so they have no provenance), and- * while a claim's lift has not finished. The fix is `fix.next: ask_user`:- * relay what claiming means; only the owner can claim, at a terminal+ * while a claim's lift has not finished. The fix is `fix.next:+ * tell_user_to_run`: relay what claiming means; only the owner can claim, at a terminal* (`gbrain trust claim-sources`, trust/claim.ts). A fresh or empty brain, or a* brain before the trust migration, is ok. Read-only.*/@@ -33,7 +33,7 @@ async function runTrustSourcesUnclaimed(ctx: DoctorContext): Promise<Check[]> {} else {checks.push({ name: 'trust_sources_unclaimed', status: 'warn', details,message: `${rows} row(s) from before trust tiers in ${unclaimed.length} unclaimed source(s) (${unclaimed.map(s => s.id).join(', ')}) read as "unverified origin". `- + 'Ask the user whether these are their own notes; if so they run gbrain trust claim-sources in a terminal on the brain host (gbrain trust claim-sources --dry-run --json previews it).',+ + 'Tell the user: if these are their own notes, they run gbrain trust claim-sources in a terminal on the brain host (gbrain trust claim-sources --dry-run --json previews it).',fix: claimSourcesFix('trust_sources_unclaimed') });}} catch (err) {diff --git a/src/commands/trust-claim.ts b/src/commands/trust-claim.tsindex a4f3b8b2c3..a98209530f 100644--- a/src/commands/trust-claim.ts+++ b/src/commands/trust-claim.ts@@ -106,7 +106,7 @@ export async function runTrustClaimSources(engine: BrainEngine, args: string[],});if (answer === 'non_interactive') {throw opError('confirmation_required', 'Claiming sources needs the owner at a terminal; nothing was changed.',- 'Relay user_message to the user and stop. Only they can claim, by running the command in a terminal on the brain host.',+ 'Relay user_message to the user and stop. Only they can claim, by running the command in fix in a terminal on the brain host.',{ why: 'Claiming raises legacy rows to "your notes"; that is the owner\'s decision, so it needs a person typing each source id. Piped input, agents and --yes cannot claim.', fix: claimSourcesFix() });}if (answer === 'confirmed') claimed.push(s.id);diff --git a/src/core/behavior-change-notice.ts b/src/core/behavior-change-notice.tsindex 9555aa7da7..5a1e0df9d1 100644--- a/src/core/behavior-change-notice.ts+++ b/src/core/behavior-change-notice.ts@@ -313,7 +313,7 @@ export const BEHAVIOR_CHANGES: ReadonlyArray<{ since: string; text: ChangeText }{ since: '0.60.108.0', text: 'A job error during worker shutdown now records `worker_shutdown: <handler error>` instead of bare `worker_shutdown`, and an `UnrecoverableError` thrown then dead-letters at once instead of running again.' },{ since: '0.60.108.0', text: '`gbrain jobs supervisor stop` can now report `unverified` (exit 1) and `stale_pid_file` (exit 0, nothing signaled), and on Linux the supervisor PID file has a second line with the process start time; read only its first line.' },{ since: '0.60.108.0', text: '`thinking: off` calls on native Google and OpenAI routes (eval judges, the synthesize triage judge, fence repair\'s model tier) now send the model\'s thinking switch (`thinkingBudget: 0`, `reasoningEffort: none`) and, where reasoning cannot be turned off (Gemini 2.5 Pro and 3.x, gpt-5/-mini/-nano, o-series), a 32,000-token reply cap; `eval takes-quality --budget-usd` and `eval cross-modal --max-usd` price that cap, so a budget that passed before can refuse earlier.' },- { since: '0.60.110.0', text: 'Memory trust: new agent-written content that reads as instructions to an agent is held back from proactive context until you confirm it (`gbrain trust review`). Content written before this release is held back only after you claim your own sources (`gbrain trust claim-sources`, in a terminal) and agree to `gbrain trust scan`; neither runs on its own.' },+ { since: '0.60.110.0', text: 'Memory trust: new agent-written content that reads as instructions to an agent is held back from proactive context until you confirm it (`gbrain trust review`). Content written before this release is held back only after you claim your own sources (`gbrain trust claim-sources`, in a terminal) and run `gbrain trust scan` yourself; no agent starts either.' },];/** The newest disclosed change's release: the notice id moves only when a release adds rows. */@@ -351,7 +351,7 @@ export function behaviorChangesNotice(chain: ChainDisclosure | null, opts: { rem/*** #5575 legacy content: while unclaimed sources hold rows from before trust- * tiers, the notice's fix becomes the claim ask (`fix.next: ask_user`, the+ * tiers, the notice's fix becomes the claim (`fix.next: tell_user_to_run`, the* user_message explains claiming), unless it already carries the chat* fallback removal. Best-effort: any fault keeps the notice as built.*/diff --git a/src/core/trust/claim-notice.ts b/src/core/trust/claim-notice.tsindex 53735998e8..ec3b9d87d7 100644--- a/src/core/trust/claim-notice.ts+++ b/src/core/trust/claim-notice.ts@@ -1,7 +1,7 @@/*** `gbrain post-upgrade` (#5575, legacy content): while unclaimed sources hold- * rows from before trust tiers, an [AGENT] ask_user block asks the agent to- * relay what claiming means; only the owner claims, at a terminal+ * rows from before trust tiers, an [AGENT] tell_user_to_run block asks the agent+ * to relay what claiming means; only the owner claims, at a terminal* (`gbrain trust claim-sources`, trust/claim.ts). It repeats on every* post-upgrade until nothing is left to claim. A claim whose lift did not* finish gets the resume command instead. Never runs the claim or the scan.@@ -24,12 +24,11 @@ export async function trustClaimUpgradeNotice(engine: Pick<BrainEngine, 'executeif (!unclaimed.length) return null;const rows = unclaimed.reduce((n, s) => n + s.legacy_unknown, 0);return ['', ...agentBlock({- ask: `Are ${unclaimed.map(s => s.id).join(', ')} the user's own notes? If so, the user claims them in a terminal.`,why: `${rows} row(s) written before trust tiers in ${unclaimed.length} unclaimed source(s) read as "unverified origin". New agent-written content is already held back `- + 'when it reads as instructions; older content is covered only after the user claims their sources and agrees to gbrain trust scan, which nothing runs on its own.',- actor: 'user', next: `ask_user: ${TRUST_CLAIM_COMMAND.join(' ')}`,- if_yes: `Tell the user to run ${TRUST_CLAIM_COMMAND.join(' ')} in a terminal on the brain host; it asks them to type each source id (--yes never claims). Preview: gbrain trust claim-sources --dry-run --json.`,- if_no: 'Run nothing; those rows stay "unverified origin" and nothing is withheld unless the user later agrees to gbrain trust scan.',+ + 'when it reads as instructions; older content is covered only after the user claims their sources and runs gbrain trust scan, which no agent starts.',+ actor: 'user', next: `tell_user_to_run: ${TRUST_CLAIM_COMMAND.join(' ')}`,+ if_yes: `The user runs ${TRUST_CLAIM_COMMAND.join(' ')} in a terminal on the brain host; it asks them to type each source id (--yes never claims). Preview: gbrain trust claim-sources --dry-run --json.`,+ if_no: 'Run nothing; those rows stay "unverified origin" and nothing is withheld unless the user later runs gbrain trust scan.',verify,}, { showUser: CLAIM_USER_MESSAGE }).trimEnd().split('\n'), ''];}diff --git a/src/core/trust/claim.ts b/src/core/trust/claim.tsindex a7d85697a5..23fcc831f3 100644--- a/src/core/trust/claim.ts+++ b/src/core/trust/claim.ts@@ -16,7 +16,7 @@* Connector sources (google, github) cannot be claimed: their text is third* party. Claiming needs the owner at a terminal typing each source id* (trust/confirm.ts; `--yes` never counts); without one the command refuses- * with an ask_user fix. The lift is bounded (keyset batches), resumable+ * with a tell_user_to_run fix. The lift is bounded (keyset batches), resumable* (`--resume`, its own cursor) and receipted (each lifted row's* `write_origin.channel` is `trust_claim`; the source records when it was* claimed and when its lift finished). `--dry-run` is read-only.@@ -212,12 +212,14 @@ export const CLAIM_USER_MESSAGE = 'Your older notes were saved before gbrain tra+ 'To claim, run `gbrain trust claim-sources` in a terminal on the brain host; it shows each source and asks you to type its id.';/**- * The ask for an unclaimed brain: relay `user_message`; only the user can- * claim (the command needs them at a terminal typing each source id).+ * The fix for an unclaimed brain: `actor: 'user'`, so `fix.next` is+ * tell_user_to_run (DX-3: every tier-raising fix is the user's to run, and the+ * command needs them at a terminal typing each source id). The agent relays+ * `user_message`, which explains the decision.*/export function claimSourcesFix(verifyCheck = 'trust_sources_unclaimed'): Action {return {- argv: [...TRUST_CLAIM_COMMAND], consent: ['destructive'], actor: 'agent', requires_exclusive: false,+ argv: [...TRUST_CLAIM_COMMAND], consent: [], actor: 'user', requires_exclusive: false,why: 'Claiming raises legacy rows of the sources the owner confirms from "unverified origin" to "your notes" (never to "confirmed by you"); it is the owner\'s decision and needs them at a terminal.',user_message: CLAIM_USER_MESSAGE,preview_argv: [...TRUST_CLAIM_COMMAND, '--dry-run', '--json'],diff --git a/test/trust-claim.test.ts b/test/trust-claim.test.tsindex a121a87fc3..e2e7b8e679 100644--- a/test/trust-claim.test.ts+++ b/test/trust-claim.test.ts@@ -3,7 +3,7 @@** Protects: the owner claims a source only by typing its id on a terminal* (--yes never counts; without a terminal the command refuses with an- * ask_user fix and changes nothing); a claim sets the per-source default+ * tell_user_to_run fix and changes nothing); a claim sets the per-source default* operator_curated and lifts the source's legacy unknown rows through the* backfill, never above operator_curated, while rows with a lowering signal* (mcp:* and capture stamps, transcript imports, clipped pages, connector@@ -11,9 +11,10 @@* tier; connector sources cannot be claimed; an interrupted lift resumes, and* until it does the scan refuses and explain shows the rows as owner tier;* `--dry-run` writes nothing; `sources set-trust` to a lower tier ends a- * claim. Doctor `trust_sources_unclaimed` warns with ask_user while unclaimed- * legacy rows exist and never on a fresh brain; doctor `trust_scan` asks- * before scanning; post-upgrade and the behavior-change notice carry the ask.+ * claim. Doctor `trust_sources_unclaimed` warns with tell_user_to_run while unclaimed+ * legacy rows exist and never on a fresh brain; doctor `trust_scan` leaves the+ * scan to the user; post-upgrade and the behavior-change notice name the claim.+ * None of these fixes carries consent effects (nothing is destructive).* Also pins the SQL frontmatter caps to `frontmatterTrustCaps`.*/import { afterAll, afterEach, beforeAll, describe, expect, test } from 'bun:test';@@ -163,7 +164,7 @@ describe('trust claim-sources', () => {expect(out).toContain('github connector: cannot be claimed');});- test('without a terminal it refuses with an ask_user fix and changes nothing', async () => {+ test('without a terminal it refuses with a tell_user_to_run fix and changes nothing', async () => {const s = await seed();const before = await snapshot(s.src);nonTty();@@ -171,7 +172,8 @@ describe('trust claim-sources', () => {expect(err).toContain('confirmation_required');expect(await snapshot(s.src)).toBe(before);const fix = render(claimSourcesFix());- expect(fix.next).toBe('ask_user');+ expect(fix.next).toBe('tell_user_to_run');+ expect(fix.consent).toEqual([]);expect(fix.argv).toEqual(['gbrain', 'trust', 'claim-sources']);expect(fix.user_message).toContain('gbrain trust claim-sources');expect(fix.user_message).toContain('your notes');@@ -260,7 +262,7 @@ describe('trust claim-sources', () => {});describe('the asks around claiming', () => {- test('doctor trust_sources_unclaimed: ok on a fresh brain, ask_user while unclaimed legacy rows exist', async () => {+ test('doctor trust_sources_unclaimed: ok on a fresh brain, tell_user_to_run while unclaimed legacy rows exist', async () => {expect((await doctor(trustSourcesUnclaimedEntry, fresh)).status).toBe('ok');expect(await trustClaimUpgradeNotice(fresh)).toBeNull();expect(await withTrustClaimAsk(fresh, { code: 'behavior_changes', kind: 'safety', why: 'w', fix: { argv: ['gbrain', 'doctor', '--only', 'behavior_changes', '--json'], consent: [], actor: 'agent', requires_exclusive: false, why: 'x' } }))@@ -271,7 +273,8 @@ describe('the asks around claiming', () => {expect(check.message).toContain(s.src);expect(check.message).not.toContain(s.gh);const fix = render(check.fix);- expect(fix.next).toBe('ask_user');+ expect(fix.next).toBe('tell_user_to_run');+ expect(fix.consent).toEqual([]);expect(fix.argv).toEqual(['gbrain', 'trust', 'claim-sources']);});@@ -284,27 +287,28 @@ describe('the asks around claiming', () => {expect((await fresh.executeRaw<{ t: string }>('SELECT trust_tier AS t FROM pages WHERE id=$1', [page!.id]))[0]!.t).toBe('unknown');});- test('doctor trust_scan asks before scanning legacy content', async () => {+ test('doctor trust_scan leaves the legacy scan to the user', async () => {await seed();// These rows stand in for content from before the write gate: no scan baseline bounds them.await engine.executeRaw('DELETE FROM config WHERE key = $1', [WRITE_GATE_SCAN_BASELINE_KEY]);const check = await doctor(trustScanEntry);expect(check.status).toBe('warn');const fix = render(check.fix);- expect(fix.next).toBe('ask_user');+ expect(fix.next).toBe('tell_user_to_run');+ expect(fix.consent).toEqual([]);expect(fix.argv).toEqual(['gbrain', 'trust', 'scan']);expect(fix.user_message).toContain('claim');});- test('post-upgrade and the behavior-change notice carry the ask_user block', async () => {+ test('post-upgrade and the behavior-change notice carry the tell_user_to_run block', async () => {await seed();const lines = (await trustClaimUpgradeNotice(engine))!.join('\n');expect(lines).toContain('[AGENT]');- expect(lines).toContain('next: ask_user: gbrain trust claim-sources');+ expect(lines).toContain('next: tell_user_to_run: gbrain trust claim-sources');expect(lines).toContain('[SHOW USER]');expect(lines).not.toContain('gbrain trust scan --');const notice = await withTrustClaimAsk(engine, { code: 'behavior_changes', kind: 'safety', why: 'w', fix: { argv: ['gbrain', 'doctor', '--only', 'behavior_changes', '--json'], consent: [], actor: 'agent', requires_exclusive: false, why: 'x' } });- expect(render(notice!.fix).next).toBe('ask_user');+ expect(render(notice!.fix)).toMatchObject({ next: 'tell_user_to_run', consent: [] });expect(notice!.user_message).toContain('gbrain trust claim-sources');});});