Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
P8: Postgres E2E for review accept and remember.replaces races; CI goldens
garrytan850e8ef3dfad
diff --git a/docs/architecture/canonical-writers.tsv b/docs/architecture/canonical-writers.tsvindex 764f72e6d3..e1786e24ac 100644--- a/docs/architecture/canonical-writers.tsv+++ b/docs/architecture/canonical-writers.tsv@@ -43,7 +43,7 @@ src/core/cycle/extract-facts.ts 7 coordinator Managed and unmanaged reconciliatisrc/core/cycle/extract-atoms-page-state.ts 1 engine_guard Atom completion updates and cardinality checks share one transaction; managed canonical SQL remains fenced and scan/failure bookkeeping is stored separately.src/core/cycle/extract-takes.ts 5 coordinator On a managed brain the DB-source walk publishes each fenced page's takes inside a withCoordinatedWrite transaction for the page's own source under the page lock, re-reading the page there and writing the canonical projection's superseded_by while leaving resolution columns untouched; the file walk and unmanaged brains keep direct SQL, which the trigger refuses on managed brains. Stale-row pruning deletes only takes whose rows left a cleanly parsed fence on a live page in the same source.src/core/cycle/grade-takes.ts 1 coordinator A managed brain applies auto-resolutions through the coordinated takes_resolve page mutation; the unmanaged resolveTake stays behind the canonical table trigger.-src/core/cycle/patterns.ts 0 coordinator Managed local patterns use admitted page operations and validate canonical outputs; the legacy reverse-file path runs only unmanaged.+src/core/cycle/patterns.ts 1 coordinator Managed local patterns use admitted page operations and validate canonical outputs; the legacy reverse-file path runs only unmanaged. Quote grounding writes verified pattern pages back through publishMaintenancePage (revision-checked) on a managed brain; the unmanaged importFromContent write-back stays behind the canonical table trigger.src/core/cycle/phantom-redirect.ts 3 coordinator Managed brains route the redirect to phantom-redirect-managed.ts (canonical merge and phantom delete as coordinated maintenance requests whose publication moves the rows); the legacy file-first path runs only unmanaged and its canonical SQL stays trigger-guarded.src/core/cycle/phases/consolidate.ts 5 coordinator Managed local consolidation publishes a take, semantic contributing facts and file in one guarded receipt transaction; legacy writes remain SQL-guarded.src/core/cycle/dream-provenance.ts 1 engine_guard The unmanaged dream-provenance stamp (synthesize and patterns) updates pages frontmatter directly; managed brains stamp through stampMaintenancePage or the synthesis postprocess maintenance write instead, and the canonical table trigger refuses this path there.diff --git a/docs/architecture/key-files/core-decide.md b/docs/architecture/key-files/core-decide.mdindex 2be5a81cf6..70c401a74e 100644--- a/docs/architecture/key-files/core-decide.md+++ b/docs/architecture/key-files/core-decide.md@@ -70,7 +70,7 @@ The capability contract (API, providers, egress, extension points) is `docs/arch- `src/core/ai/decide/conflict.ts` — S9's question (`duplicate | supersede | independent`, state = the new fact, one choice per candidate), the ONE pair reducer `reduceConflict` (chosen duplicate at or above threshold → duplicate; else P(supersede) at or above `decide.slots.conflict.proposal_floor` → proposal; else independent), candidate eligibility (the `decideSingleFact` guards, self-exclusion, cosine ≥ 0.80), unordered pair keys, proposal direction, chronology (`isOlderFact`: valid_from, then created_at, then id; `datedConflictState`/`datedConflictQuestion` add `fact_time`/`candidate_time` evidence for a reordered pair) and `sweepWindow` (stops at the first fact younger than 60 s).- `src/core/ai/decide/sweep.ts` (+ `proposals-store.ts`) — `runConflictSweep`: per-source watermark in `decide_state` (first run records the max fact id unless `since`), deferred retries first (attempt cap 5, oldest due first so a relinked backlog never starves a transient retry), neighbours filtered BEFORE the k=5 limit by one `executeRaw` query, pairs deduped within the sweep and across sweeps (answered receipts by hashed pair subject, existing proposals), one background-lane request per fact for its older neighbours plus one per neighbour newer than the fact (that neighbour is presented as the new claim with both timestamps, so a proposal always retires the older fact), drift and inactive policy run with off behavior, pending `decide_proposals` rows in `on` mode only; never supersedes. `conflictSweepTail` is the `extract_facts` phase tail: undefined when the slot is off. `proposals-store.ts` holds the watermark, deferred, dedup and proposal SQL, and `enqueueRelinked(engine, sourceId, factIds)` (the `gbrain facts relink` handoff: attempts 0, due now, reason `relinked`, `ON CONFLICT DO NOTHING`, run on the caller's transaction engine). Tests: `test/decide/conflict-sweep.serial.test.ts`, `test/decide/conflict-relink-handoff.serial.test.ts`. When `decide.slots.conflict.review_withdraw` is on, each swept fact re-queues up to two withdrawn claims it may restate (`requeueWithdrawnAnchorsNear`), and `conflictSweepTail` runs `runReviewLanes` after the sweep (output key `review`).-- `src/core/ai/decide/review-lane.ts` (+ `src/core/facts/proposal-review.ts`) — the ambiguous-band review lane on the `conflict` slot's provider, egress and spend. Kinds `withdraw` (active facts close to a withdrawn fact; conflict question unchanged, `duplicate` = same claim), `duplicate_page` and `duplicate_entity` (page pairs other subsystems queue with `enqueueReviewCandidate`; `same | different` question, candidates class). Each kind has a switch (`decide.slots.conflict.review_<kind>`, off by default), a call site (`review_<kind>`, listed in `SLOT_SPECS.conflict.callSites`) and its own calibration; `reviewGate` lets a kind propose only with a calibration qualified for action precision (`action_precision_lb >= min_action_precision`, fingerprint match; an operator threshold override never qualifies) and otherwise skips the provider entirely; shadow mode writes receipts only. Work lives in `decide_review_queue` (written in the event's own transaction: `recordFactWithdrawal` for withdraws; no timestamp cursor), at most `REVIEW_BUDGET_PER_RUN` (50) per kind per run, with attempt/backoff deferral and permanent-failure clearing. Pair subjects `review:<kind>:<source>:<a>:<b>` are hashed into receipts, so supersede receipts never suppress a review judgment and judged pairs are not re-asked. A forgotten private fact is skipped unless `decide.egress.private` is `allow`. Proposals go to `decide_review_proposals` (unique per kind/source/a/b/subject; separate table so older binaries never read them). `proposalReviewRates` feeds `gbrain decide status` (pending, oldest pending age, 30-day accepted/rejected per kind). Owner actions (`proposal-review.ts`): withdraw accept re-checks anchor still withdrawn and candidate active with unchanged text (`candidate_hash`), then calls the `forget` operation with a proposal-derived request id and `semantic_review: false` (finishing an interrupted accept when the fact already carries the `(review r<id>)` marker); a changed candidate goes `stale`; undo refuses with `withdrawal_is_durable` and a fix; duplicate kinds run the handler registered with `registerReviewAcceptHandler`, else `accepted_no_action`. CLI in `commands/decide/proposals.ts`: `r<id>` ids, `--yes` required to accept a withdraw, `--all-from` excludes withdraws unless `--include-withdrawals`. Pinned by `test/decide/review-withdraw.serial.test.ts` and `test/decide/review-duplicate-kinds.serial.test.ts`.+- `src/core/ai/decide/review-lane.ts` (+ `src/core/facts/proposal-review.ts`) — the ambiguous-band review lane on the `conflict` slot's provider, egress and spend. Kinds `withdraw` (active facts close to a withdrawn fact; conflict question unchanged, `duplicate` = same claim), `duplicate_page` and `duplicate_entity` (page pairs other subsystems queue with `enqueueReviewCandidate`; `same | different` question, candidates class). Each kind has a switch (`decide.slots.conflict.review_<kind>`, off by default), a call site (`review_<kind>`, listed in `SLOT_SPECS.conflict.callSites`) and its own calibration; `reviewGate` lets a kind propose only with a calibration qualified for action precision (`action_precision_lb >= min_action_precision`, fingerprint match; an operator threshold override never qualifies) and otherwise skips the provider entirely; shadow mode writes receipts only. Work lives in `decide_review_queue` (written in the event's own transaction: `recordFactWithdrawal` for withdraws; no timestamp cursor), at most `REVIEW_BUDGET_PER_RUN` (50) per kind per run, with attempt/backoff deferral and permanent-failure clearing. Pair subjects `review:<kind>:<source>:<a>:<b>` are hashed into receipts, so supersede receipts never suppress a review judgment and judged pairs are not re-asked. A forgotten private fact is skipped unless `decide.egress.private` is `allow`. Proposals go to `decide_review_proposals` (unique per kind/source/a/b/subject; separate table so older binaries never read them). `proposalReviewRates` feeds `gbrain decide status` (pending, oldest pending age, 30-day accepted/rejected per kind). Owner actions (`proposal-review.ts`): withdraw accept first claims the proposal (`pending` -> `accepting`, so a concurrent reject refuses and an `accepting` row from a concurrent or crashed accept resumes; one accept records the outcome), re-checks anchor still withdrawn and candidate active with unchanged text (`candidate_hash`), then calls the `forget` operation with a proposal-derived request id and `semantic_review: false` (finishing an interrupted accept when the fact already carries the `(review r<id>)` marker); a changed candidate goes `stale`; undo refuses with `withdrawal_is_durable` and a fix; duplicate kinds run the (idempotent) handler registered with `registerReviewAcceptHandler`, else `accepted_no_action`. CLI in `commands/decide/proposals.ts`: `r<id>` ids, `--yes` required to accept a withdraw, `--all-from` excludes withdraws unless `--include-withdrawals`. Pinned by `test/decide/review-withdraw.serial.test.ts` and `test/decide/review-duplicate-kinds.serial.test.ts`.- `src/core/ai/decide/datasets-conflict.ts` — `registerConflictDatasets()` (called by `src/commands/decide/writepath.ts`): the conflict dataset adapter (production request shape, no harmful-action reducer) and the `facts-fixtures` builder (labelled fact-pair JSONL; label `true` exactly for `duplicate`, the calibrated threshold). Calibration thresholds the reducer-consistent `duplicateValue` (P(chosen) only when duplicate is chosen) and `calibrateProposalFloor` picks the F1-best P(supersede) floor on the choice label kept in `slice` (≥ 10 supersede labels), stored in the row's notes. Tests: `test/decide/conflict-calibration.test.ts`.diff --git a/llms-full.txt b/llms-full.txtindex 57bab91e74..8e1a571b90 100644--- a/llms-full.txt+++ b/llms-full.txt@@ -7778,6 +7778,21 @@ No server, no tunnel, no token needed. Works on both PGLite and Postgres engines`--surface starter` sits between (~27 ops: the verbs plus the daily-driver set);omit the flag (default `full`) for every operation.+`--surface` is the callable ceiling. To keep every operation callable while+listing fewer tools to the agent, set `mcp.advertised_surface`:++```bash+gbrain config set mcp.advertised_surface verbs # list the 7 verbs; everything else stays callable+```++`tools/list` then shows the advertised surface, and the initialize+instructions tell the agent how many more tools are callable. On stdio,+`request_tools` with `tools: [names]` returns their schemas and adds them to+that session's list (the server sends `tools/list_changed`). On the OAuth HTTP+server, a client that set its own surface (`request_tools` with `surface`, or+`gbrain auth rescope-client`) has that surface listed in full. Unset+advertises the whole callable set.+#### Stdio source bindingDo not inherit `GBRAIN_SOURCE=__all__` from a trusted CLI session into a@@ -8770,6 +8785,25 @@ near-duplicates may insert; dedup and supersession ride embedding similarity).supersedes the old ("X at acme-example" → "X left acme-example").- Omitted optional inputs echo as `null`, never absent.+#### remember replaces (additive)++`replaces` (string): the `fact_id` of the fact this new fact replaces. It is a+caller-directed replacement: it says the old fact is no longer the current one,+not that the two texts mean the same. Zero model calls; the cosine rule does+not apply. The target must be an active fact in the same source, with the same+visibility (world only for remote callers, else `not_found`) and the same+entity, on the same entity page. Refusals come back as `invalid_params` with a+code prefix and a `suggestion`: `target_withdrawn` (forgotten facts are not+replaceable; remember without `replaces`), `target_superseded` (names the fact+that replaced it), `target_expired`, `replaces_entity_mismatch`,+`replaces_cross_page` (forget the old fact, then remember), and+`replaces_duplicate` (another active fact already states the new claim). New+text equal to the target is `status: duplicate` and changes nothing. On success+`status` is `superseded`, `superseded_fact_id` names the replaced fact and+`replaced_by_caller` is `true`; the replaced fact is expired with+`superseded_by` and its `## Facts` row is struck with `superseded by #N` in+the same publication. Every `superseded` response carries `superseded_fact_id`.+#### remember entity attribution fields (additive)Optional response fields; clients must ignore any they do not know.@@ -8847,6 +8881,17 @@ output_tokens, usd_estimate}, protocol_version }`.- No LLM configured ⇒ the protocol error `unavailable` with a fix — never afake answer.+#### synthesize quote check (additive)++Every quoted span in a synthesized `answer` is grounded against the evidence+the answer was composed from (the same page excerpts, takes and graph lines,+no refetch). An exact match stays; a normalized or near match is replaced with+the evidence's own words; a quote found in no evidence loses its quotation+marks and gains `[unverified]`, and the response warns `QUOTE_NOT_IN_EVIDENCE`.+When the answer contained quotes, the response adds `answer_raw` (as written),+`quote_check: { grounded, repaired, unverified }` and `unverified_quotes:+[{ text, reason }]`. Present `answer`, not `answer_raw`, to the user.+#### synthesize compose status (additive)Every response additionally carries four ADDITIVE-FOREVER fields (optional;@@ -8888,6 +8933,23 @@ already-expired fact returns `expired: false` (success); unknown id ⇒Response: `{ id, expired, reason, protocol_version }`.+#### forget similar_active and semantic_review (additive)++`semantic_review` (boolean, default `true`): `false` keeps this claim out of+the overnight rewording review, so its text is never sent to a decision+provider for comparison.++The response carries `similar_active`: `{ state, candidates, semantic_review,+next }`. `state` is `checked`, `not_checked_no_embedding` or+`not_checked_pending`. `candidates` lists up to five other active facts about+the same entity, with the same visibility (world only for remote callers),+whose embedding is at cosine 0.80 or higher to the withdrawn claim, as+`{ fact_id, similarity }` (no stored text; zero model calls). `semantic_review`+is `scheduled`, `off`, `unavailable` or `opted_out`; `next` tells the agent+what to do. Similarity is not sameness: show the candidates to the user and+forget one only when the user confirms it restates the withdrawn claim. An+empty list means no close match was found, not that every rewording is gone.+#### Durable write receipts (additive)Write receipts distinguish accepted work from committed memory. Their publicdiff --git a/src/core/ai/decide/review-lane.ts b/src/core/ai/decide/review-lane.tsindex 2d672efc82..3ca2f4104f 100644--- a/src/core/ai/decide/review-lane.ts+++ b/src/core/ai/decide/review-lane.ts@@ -117,7 +117,7 @@ export interface ReviewProposalRow {receipt: string | null;}-/** What accepting a duplicate-kind proposal does; registered by the subsystem that owns the merge or link. */+/** What accepting a duplicate-kind proposal does; registered by the subsystem that owns the merge or link. Must be idempotent: a crashed accept resumes by calling it again. */export type ReviewAcceptHandler = (engine: BrainEngine, proposal: ReviewProposalRow) => Promise<{ status: 'accepted' | 'stale'; detail?: string }>;const acceptHandlers = new Map<ReviewKind, ReviewAcceptHandler>();export function registerReviewAcceptHandler(kind: Exclude<ReviewKind, 'withdraw'>, handler: ReviewAcceptHandler): void {@@ -364,7 +364,7 @@ export async function runReviewLanes(engine: BrainEngine, sourceId: string, sign// Proposals store// ----------------------------------------------------------------------------export const REVIEW_PROPOSAL_STATUSES = ['pending', 'accepted', 'rejected', 'stale', 'accepted_no_action'] as const;+export const REVIEW_PROPOSAL_STATUSES = ['pending', 'accepting', 'accepted', 'rejected', 'stale', 'accepted_no_action'] as const;export async function listReviewProposals(engine: BrainEngine, filter: { status?: string | 'all' } = {}): Promise<ReviewProposalRow[]> {const status = filter.status ?? 'pending';diff --git a/src/core/cli-flag-registry.generated.ts b/src/core/cli-flag-registry.generated.tsindex 9127ae4368..5a3f77d86a 100644--- a/src/core/cli-flag-registry.generated.ts+++ b/src/core/cli-flag-registry.generated.ts@@ -45,7 +45,7 @@ export const CLI_FLAG_REGISTRY: Record<string, readonly string[]> = {'conversation-parser': ['--brain', '--help', '--json', '--source'],'creds': ['--allow-create-db', '--allow-docker', '--brain', '--chat-model', '--content-root', '--db-only', '--embedding-dimensions', '--embedding-model', '--expansion-model', '--force', '--git', '--grant-types', '--help', '--http', '--ids', '--issuer-url', '--json', '--key', '--local-postgres', '--mcp-only', '--mcp-url', '--migrate-only', '--model', '--no-embedding', '--no-git', '--non-interactive', '--oauth-client-id', '--oauth-client-secret', '--out', '--passphrase-env', '--path', '--pglite', '--prefer-postgres', '--provenance', '--provider', '--query', '--schema-pack', '--scopes', '--skip-embed-check', '--source', '--status', '--supabase', '--to', '--url', '--version'],'db-repair': ['--accept-pending', '--apply', '--apply-rewrites', '--background', '--brain', '--break-lock', '--db-url', '--dry-run', '--explain', '--filter', '--follow', '--force', '--force-retry', '--format', '--help', '--http', '--json', '--locks', '--name', '--no-accept-pending', '--path', '--prefer-postgres', '--probe', '--progress-interval', '--progress-json', '--quiet', '--remediate', '--restart', '--skip-verify', '--source', '--supabase', '--timeout', '--undo-last-rewrite', '--url', '--version', '--wait', '--yes'],- 'decide': ['--all', '--all-from', '--brain', '--call-site', '--dataset', '--dry-run', '--egress', '--embedding-dimensions', '--embedding-model', '--from', '--help', '--include-withdrawals', '--input', '--json', '--limit', '--min', '--out', '--provenance', '--provider', '--query', '--recommended', '--shadow', '--since', '--slot', '--source', '--status', '--suite', '--target', '--threshold', '--what-if-threshold', '--yes'],+ 'decide': ['--all', '--all-from', '--apply', '--brain', '--call-site', '--dataset', '--dry-run', '--egress', '--embedding-dimensions', '--embedding-model', '--expect', '--from', '--help', '--include-withdrawals', '--input', '--json', '--limit', '--max-cost', '--max-usd', '--min', '--non-interactive', '--out', '--provenance', '--provider', '--query', '--recommended', '--shadow', '--since', '--slot', '--source', '--status', '--suite', '--target', '--threshold', '--trust', '--what-if-threshold', '--yes'],'doctor': ['--abandon', '--abbrev-ref', '--abort', '--accept-pending', '--admin-intent', '--adopt-columns', '--adopt-permissions', '--all', '--all-from', '--allow-old-serve', '--allow-shell-jobs', '--allow-unverified-remote', '--apply', '--apply-rewrites', '--auto', '--auto-fix', '--background', '--brain', '--branch', '--break-lock', '--by-mention', '--cached', '--call-site', '--catch-up', '--check', '--client', '--concurrency', '--confidence', '--confirm', '--content-audit', '--count', '--dataset', '--db-url', '--delete-brain', '--detach', '--diff-filter', '--dim', '--dir', '--drain', '--dry-run', '--egress', '--embedding-dimensions', '--embedding-model', '--env', '--exclude', '--exclude-standard', '--exit-code', '--expect', '--expected-epoch', '--expected-state', '--explain', '--facts', '--fast', '--federated-read', '--fetch-timeout-ms', '--ff-only', '--file', '--fix', '--follow', '--force', '--force-rechunk', '--force-retry', '--force-schema', '--format', '--fresh', '--from', '--from-pages', '--full', '--gbrain-bin', '--get', '--get-url', '--git-common-dir', '--git-dir', '--git-path', '--hard', '--harness', '--help', '--home', '--http', '--id', '--ignore-env-override', '--include-ambiguous', '--include-flagged', '--include-gitignored', '--include-hidden', '--include-pseudo', '--include-repairs', '--include-withdrawals', '--index-audit', '--init', '--input', '--install', '--is-ancestor', '--is-inside-work-tree', '--job-isolation', '--jq', '--json', '--lang', '--limit', '--link-source', '--link-type', '--local', '--locks', '--log-noop', '--manifest', '--markdown', '--max-cost', '--max-cost-usd', '--max-jobs', '--max-rss', '--max-usd', '--max-waiting', '--mcp-only', '--migrate-legacy', '--migrate-only', '--min', '--mode', '--multimodal', '--name', '--name-only', '--nice', '--no-accept-pending', '--no-autopilot-install', '--no-capture', '--no-cron', '--no-edit', '--no-embed', '--no-embedding', '--no-extract', '--no-hooks', '--no-migrate', '--no-pull', '--no-renames', '--no-schema-pack', '--no-tags', '--no-verify', '--no-write-fetch-head', '--non-interactive', '--older-than', '--once', '--only', '--operations', '--others', '--out', '--output', '--overwrite', '--parallel', '--params', '--pat-file', '--path', '--path-format', '--pglite', '--phase', '--pid-file', '--porcelain', '--port', '--prefer-postgres', '--preset', '--preview', '--probe', '--probe-pglite', '--progress-interval', '--progress-json', '--project', '--provider', '--prune-orphans', '--pure', '--push', '--push-only', '--query', '--queue', '--quiet', '--rate', '--reauth', '--rebase', '--recommended', '--refresh', '--refresh-operations', '--refresh-skills', '--regenerate', '--reissue', '--remediate', '--remediation-plan', '--remove', '--repo', '--request-id', '--reranker', '--reset', '--reset-checkpoint', '--restore-only', '--resume', '--retry-failed', '--review-lower', '--scope', '--scopes', '--select', '--self-transfer', '--session', '--set', '--set-upstream-to', '--shadow', '--short', '--show-current', '--show-token', '--show-toplevel', '--since', '--skills', '--skills-dir', '--skip', '--skip-bare-tweet', '--skip-failed', '--skip-urls', '--skip-verify', '--slot', '--slugs', '--source', '--source-id', '--sources', '--src-subpath', '--staged', '--stale', '--status', '--strategy', '--strict', '--suite', '--supabase', '--surface', '--symbol-kind', '--symbolic-full-name', '--takes-holders', '--target', '--target-score', '--threshold', '--timeout', '--to', '--token', '--token-name', '--token-ttl', '--top-k', '--trust', '--type', '--uninstall', '--unsafe-bypass-dream-guard', '--unset-all', '--untracked-files', '--url', '--user', '--vectors', '--verbose', '--verify', '--version', '--wait', '--wait-drain', '--what-if-threshold', '--window', '--workers', '--working-tree', '--yes'],'dream': ['--audit-rejects', '--brain', '--cancel-unmatched', '--date', '--dir', '--drain', '--dry-run', '--eval-run', '--force', '--force-retry', '--from', '--help', '--input', '--install', '--json', '--limit', '--list', '--max-usd', '--once', '--path', '--phase', '--pull', '--reconcile-queue', '--since', '--source', '--source-id', '--threshold', '--to', '--unsafe-bypass-dream-guard', '--window', '--yes'],'edges-backfill': ['--all-sources', '--brain', '--concurrency', '--help', '--json', '--max-chunks', '--source', '--workers'],@@ -69,7 +69,7 @@ export const CLI_FLAG_REGISTRY: Record<string, readonly string[]> = {'graph-query': ['--brain', '--depth', '--direction', '--help', '--include-foreign', '--json', '--mcp-only', '--source', '--type'],'hook': ['--allow-unverified-remote', '--auto', '--brain', '--branch', '--cached', '--count', '--diff-filter', '--end-of-options', '--env', '--get', '--harness', '--help', '--jq', '--json', '--name-only', '--others', '--path', '--porcelain', '--pure', '--quiet', '--seat', '--session', '--show-current', '--show-toplevel', '--source'],'import': ['--accept-pending', '--allow-empty', '--allow-noncanonical-root', '--apply', '--background', '--brain', '--cached', '--diff-filter', '--dim', '--embedding-dimensions', '--embedding-model', '--empty', '--exclude', '--exclude-standard', '--explain', '--follow', '--force', '--force-rechunk', '--format', '--fresh', '--help', '--include-gitignored', '--is-shallow-repository', '--json', '--log-noop', '--name-only', '--no-accept-pending', '--no-embed', '--no-embedding', '--no-gpg-sign', '--no-pull', '--no-renames', '--no-verify', '--only', '--others', '--path', '--probe', '--progress-interval', '--progress-json', '--quiet', '--show-toplevel', '--skip-failed', '--slugs', '--source', '--source-id', '--stale', '--status', '--supabase', '--timeout', '--to', '--url', '--verify', '--wait', '--workers'],- 'init': ['--allow-create-db', '--allow-docker', '--brain', '--break-lock', '--chat-model', '--check', '--content-root', '--db-only', '--dim', '--embedding-dimensions', '--embedding-model', '--expansion-model', '--force', '--git', '--grant-types', '--help', '--http', '--issuer-url', '--json', '--key', '--local-postgres', '--mcp-only', '--mcp-url', '--migrate-only', '--model', '--no-autopilot-install', '--no-embedding', '--no-expand', '--no-git', '--non-interactive', '--oauth-client-id', '--oauth-client-secret', '--only', '--path', '--pglite', '--prefer-postgres', '--probe', '--provenance', '--query', '--quiet', '--save', '--schema-pack', '--scopes', '--show-toplevel', '--skip-embed-check', '--source', '--stale', '--status', '--supabase', '--to', '--touchpoint', '--url', '--version', '--yes'],+ 'init': ['--access', '--allow-create-db', '--allow-docker', '--brain', '--break-lock', '--chat-model', '--check', '--content-root', '--db-only', '--dim', '--embedding-dimensions', '--embedding-model', '--expansion-model', '--force', '--git', '--grant-types', '--help', '--http', '--issuer-url', '--json', '--key', '--local-postgres', '--mcp-only', '--mcp-url', '--migrate-only', '--model', '--no-autopilot-install', '--no-embedding', '--no-expand', '--no-git', '--non-interactive', '--oauth-client-id', '--oauth-client-secret', '--only', '--path', '--pglite', '--prefer-postgres', '--probe', '--provenance', '--query', '--quiet', '--save', '--schema-pack', '--scopes', '--show-toplevel', '--skip-embed-check', '--source', '--stale', '--status', '--supabase', '--surface', '--to', '--touchpoint', '--url', '--version', '--yes'],'integrations': ['--auto', '--brain', '--dry-run', '--help', '--json', '--overwrite', '--refresh', '--source', '--target'],'integrity': ['--accept-pending', '--auto', '--backend', '--background', '--brain', '--confidence', '--cost', '--dry-run', '--explain', '--follow', '--fresh', '--help', '--json', '--limit', '--no-accept-pending', '--probe', '--progress-interval', '--progress-json', '--quiet', '--review-lower', '--skip-bare-tweet', '--skip-urls', '--source', '--supabase', '--timeout', '--type', '--url', '--wait'],'jobs': ['--abbrev-ref', '--access', '--add', '--aliases', '--all', '--allow-empty', '--allow-shell-jobs', '--allowed-operations', '--apply', '--asof', '--auto', '--background', '--backoff-delay', '--backoff-jitter', '--backoff-type', '--batch-size', '--bound-slug-prefixes', '--brain', '--break-lock', '--by-mention', '--cached', '--catch-up', '--cli-path', '--client', '--cluster-errors', '--concurrency', '--confidence', '--confirm-destructive', '--cost-estimate', '--date', '--dated-since', '--days', '--delay', '--detach', '--diff-filter', '--dir', '--drain', '--dry-run', '--embedding-dimensions', '--embedding-model', '--empty', '--entities', '--exclude', '--exclude-standard', '--expect', '--explain', '--facts', '--federated-read', '--filters', '--fix', '--follow', '--force', '--force-break-lock', '--force-retry', '--format', '--fresh', '--from-meetings', '--full', '--full-history', '--fuzzy', '--hard-deadline', '--health-interval', '--help', '--http', '--id', '--idempotency-key', '--ids', '--images', '--include-deleted', '--include-frontmatter', '--include-gitignored', '--include-hidden', '--include-null-signature', '--infer-dates', '--inject-bootstrap', '--inline', '--input', '--install', '--interval', '--is-ancestor', '--is-shallow-repository', '--job-id', '--job-isolation', '--json', '--kind', '--limit', '--lock-duration-ms', '--log-noop', '--markdown', '--max-age', '--max-attempts', '--max-cost', '--max-cost-usd', '--max-crashes', '--max-rss', '--max-sources', '--max-stalled', '--max-usd', '--max-waiting', '--mcp-only', '--min-context', '--missing-path', '--model', '--multimodal', '--name-only', '--ner', '--nice', '--no-auto-embed', '--no-autopilot-install', '--no-bulk', '--no-delegate', '--no-embed', '--no-extract', '--no-gpg-sign', '--no-hard-deadline', '--no-inject', '--no-pull', '--no-renames', '--no-schema-pack', '--no-verify', '--no-worker', '--non-interactive', '--now', '--older-than', '--once', '--only', '--order', '--others', '--output', '--override-disabled', '--pace', '--pace-max-concurrency', '--pack', '--page', '--parallel', '--params', '--path', '--pause', '--phase', '--pid-file', '--priority', '--probe', '--prune-orphans', '--queue', '--queue-only', '--quiet', '--reason', '--rebuild', '--recent', '--redact-secrets', '--reenrich-after', '--refresh-ms', '--refresh-operations', '--replace', '--repo', '--reset-checkpoint', '--resume', '--retry-failed', '--retry-held', '--review-lower', '--scopes', '--segment-limit', '--select', '--serial', '--session', '--show-toplevel', '--sigkill-rescue', '--since', '--skip-bare-tweet', '--skip-failed', '--skip-urls', '--sleep', '--slug', '--slugs', '--source', '--source-id', '--sources', '--src-subpath', '--stale', '--status', '--strategy', '--surface', '--swap-only', '--target', '--thin', '--thin-threshold', '--timeout', '--timeout-ms', '--to', '--trust', '--type', '--types', '--uninstall', '--url', '--user', '--vectors', '--verbose', '--verify', '--watch', '--wedge-rescue', '--workers', '--working-tree', '--yes'],diff --git a/src/core/facts/proposal-review.ts b/src/core/facts/proposal-review.tsindex 3ac4b1a558..3a34c905ca 100644--- a/src/core/facts/proposal-review.ts+++ b/src/core/facts/proposal-review.ts@@ -9,6 +9,9 @@* same withdrawal instead of making a second one. The withdrawal ledger is* durable, so there is no undo. duplicate kinds: accepting runs the handler the* owning subsystem registered, or records the owner's verdict when none is.+ * Accept claims the proposal (`pending` -> `accepting`) before acting, so a+ * concurrent reject refuses; an `accepting` proposal (a concurrent or crashed+ * accept) resumes, and only one accept records the outcome.*/import { createHash } from 'node:crypto';import type { BrainEngine } from '../engine.ts';@@ -51,31 +54,31 @@ async function staleReason(engine: BrainEngine, p: ReviewProposalRow): Promise<sexport async function acceptReviewProposal(engine: BrainEngine, id: number): Promise<ReviewActionResult> {const ref = `r${id}`;- const p = await getReviewProposal(engine, id);+ let p = await getReviewProposal(engine, id);if (!p) return { id: ref, action: 'accept', status: 'not_found' };- if (p.status !== 'pending') return { id: ref, action: 'accept', status: 'refused', reason: `proposal is ${p.status}` };+ // Claim first so a concurrent reject loses cleanly; an 'accepting' row (a concurrent or crashed accept) resumes.+ if (p.status === 'pending' && !(await transitionReviewProposal(engine, id, 'pending', 'accepting'))) p = (await getReviewProposal(engine, id))!;+ else if (p.status === 'pending') p = { ...p, status: 'accepting' };+ if (p.status !== 'accepting') return { id: ref, action: 'accept', status: 'refused', reason: `proposal is ${p.status}` };+ const finish = async (status: 'accepted' | 'accepted_no_action' | 'stale', reason?: string): Promise<ReviewActionResult> => {+ if (!(await transitionReviewProposal(engine, id, 'accepting', status))) {+ const now = await getReviewProposal(engine, id);+ return { id: ref, action: 'accept', status: 'refused', reason: `proposal is ${now?.status ?? 'gone'}` };+ }+ return { id: ref, action: 'accept', status, ...(reason ? { reason } : {}) };+ };if (p.kind !== 'withdraw') {const handler = reviewAcceptHandler(p.kind);- if (!handler) {- await transitionReviewProposal(engine, id, 'pending', 'accepted_no_action');- return { id: ref, action: 'accept', status: 'accepted_no_action', reason: 'verdict recorded; no merge or link handler is registered in this build' };- }+ if (!handler) return finish('accepted_no_action', 'verdict recorded; no merge or link handler is registered in this build');const out = await handler(engine, p);- await transitionReviewProposal(engine, id, 'pending', out.status);- return { id: ref, action: 'accept', status: out.status, ...(out.detail ? { reason: out.detail } : {}) };+ return finish(out.status, out.detail);}// A previous accept that withdrew the fact but stopped before the status change: finish it.const [done] = await engine.executeRaw<{ id: number }>(`SELECT id FROM facts WHERE id = $1 AND source_id = $2 AND expired_at IS NOT NULLAND strpos(COALESCE(context, ''), $3) > 0`, [Number(p.b_ref), p.source_id, `(review r${id})`]);- if (done) {- await transitionReviewProposal(engine, id, 'pending', 'accepted');- return { id: ref, action: 'accept', status: 'accepted' };- }+ if (done) return finish('accepted');const stale = await staleReason(engine, p);- if (stale) {- await transitionReviewProposal(engine, id, 'pending', 'stale');- return { id: ref, action: 'accept', status: 'stale', reason: stale };- }+ if (stale) return finish('stale', stale);const { submitForgetMutation } = await import('../persistence/memory-mutations.ts');const { runMemoryWrite } = await import('../persistence/verb-errors.ts');await runMemoryWrite(() => submitForgetMutation({@@ -83,8 +86,7 @@ export async function acceptReviewProposal(engine: BrainEngine, id: number): Prologger: { info: () => {}, warn: () => {}, error: () => {} },} as never, 'forget', { id: p.b_ref, request_id: reviewRequestId(id), semantic_review: false,reason: `paraphrase of withdrawn fact #${p.a_ref} (review r${id})` }));- await transitionReviewProposal(engine, id, 'pending', 'accepted');- return { id: ref, action: 'accept', status: 'accepted' };+ return finish('accepted');}export async function rejectReviewProposal(engine: BrainEngine, id: number): Promise<ReviewActionResult> {diff --git a/src/core/persistence/verb-errors.ts b/src/core/persistence/verb-errors.tsindex e584e40a08..317f5158a4 100644--- a/src/core/persistence/verb-errors.ts+++ b/src/core/persistence/verb-errors.ts@@ -85,10 +85,23 @@ export function writeFailureDiagnostic(code: string, message?: string | null): {suggestion: 'Correct the frontmatter in the file and commit the change.' };if (code === 'invalid_params' && isFrontmatterHoldMessage(message)) return { reason: code, message: message!,suggestion: 'Correct the named frontmatter line in the file (one line per key, the whole value quoted) and commit the change.' };+ const replaces = code === 'invalid_params' ? REPLACES_REFUSAL.exec(message ?? '') : null;+ if (replaces) return { reason: code, message: message!, suggestion: REPLACES_SUGGESTION[replaces[1]!]! };return { reason: isWriteErrorCode(code) ? code : 'storage_error', message: 'The write did not commit. Inspect its durable request on the source host.',suggestion: 'Resolve the reported write failure before starting a corrected attempt.' };}+/** `remember.replaces` refusals decided under the target row lock keep their code and next step. */+const REPLACES_REFUSAL = /^(target_superseded|target_withdrawn|target_expired|replaces_entity_mismatch|replaces_cross_page|replaces_duplicate): /;+const REPLACES_SUGGESTION: Record<string, string> = {+ target_superseded: 'Recall the entity to check the current fact, then pass replaces with the fact id named here if the new claim replaces that one.',+ target_withdrawn: 'Remember the new claim without replaces; the forgotten claim stays withdrawn.',+ target_expired: 'Remember the new claim without replaces.',+ replaces_entity_mismatch: 'Pass the same entity as the fact being replaced, or forget the old fact and remember the new one separately.',+ replaces_cross_page: 'Forget the old fact, then remember the new one.',+ replaces_duplicate: 'Forget the replaced fact if it is no longer true; the existing fact named here already says the new claim.',+};+/** Apply the frozen contract at the verb boundary for CLI and every transport. */export async function runMemoryWrite<T>(run: () => Promise<T>): Promise<T> {try { return await run(); } catch (error) {diff --git a/test/e2e/p8-memory-writes-postgres.test.ts b/test/e2e/p8-memory-writes-postgres.test.tsnew file mode 100644index 0000000000..2ff8591f10--- /dev/null+++ b/test/e2e/p8-memory-writes-postgres.test.ts@@ -0,0 +1,155 @@+/**+ * P8 memory writes on Postgres: withdrawal review queueing commits with the+ * withdrawal, the review lane proposes and an accept withdraws exactly once+ * under concurrency, and `remember.replaces` holds the target row lock so two+ * concurrent replacements (or a replacement racing a forget) leave one+ * consistent outcome. Zero model calls: fixture embed and decide transports.+ */+import { afterAll, beforeAll, beforeEach, describe, expect, test } from 'bun:test';+import { hasDatabase, setupLegacyEmbeddingDB, teardownDB } from './helpers.ts';+import type { PostgresEngine } from '../../src/core/postgres-engine.ts';+import { importFromContent } from '../../src/core/import-file.ts';+import { writeSingleFact } from '../../src/core/facts/write-single.ts';+import { configureGateway, resetGateway, __setDecideTransportForTests, __setEmbedTransportForTests } from '../../src/core/ai/gateway.ts';+import { insertCalibration, __resetDecideStoreForTests } from '../../src/core/ai/decide/store.ts';+import { packShape } from '../../src/core/ai/decide/pack.ts';+import { listReviewProposals, runReviewLane } from '../../src/core/ai/decide/review-lane.ts';+import { acceptReviewProposal, rejectReviewProposal } from '../../src/core/facts/proposal-review.ts';+import { dispatchToolCall } from '../../src/mcp/dispatch.ts';+import { operationsByName } from '../../src/core/operations.ts';+import { disposePersistenceConsumer } from '../../src/core/persistence/service.ts';+import { LEGACY_EMBEDDING_CONFIG } from '../helpers/legacy-embedding-config.ts';++const RUN = hasDatabase();+const d = RUN ? describe : describe.skip;+const SLUG = 'people/alice-example';+const DIM = LEGACY_EMBEDDING_CONFIG.embedding_dimensions;+let engine: PostgresEngine;++function embed(text: string): number[] {+ const v = new Array(DIM).fill(0);+ const g = /\[g(\d+)\]/.exec(text);+ const m = /\[v(\d+)\]/.exec(text);+ if (!g) { v[1000 + ([...text].reduce((n, c) => n + c.charCodeAt(0), 0) % 400)] = 1; return v; }+ v[Number(g[1]) * 20] = 1;+ if (m) v[Number(g[1]) * 20 + 1 + Number(m[1])] = 0.4;+ return v;+}++function gateway() {+ configureGateway({ ...LEGACY_EMBEDDING_CONFIG, env: { OPENAI_API_KEY: 'sk-test', TYPESAFE_API_KEY: 'sk-test-typesafe' } });+ __setEmbedTransportForTests((async (opts: { values: string[] }) => ({ embeddings: opts.values.map(embed) })) as never);+ __setDecideTransportForTests(async (_url, init) => {+ const body = JSON.parse(init.body as string);+ const answers = Object.fromEntries(Object.entries(body.questions).map(([id, q]: [string, any]) => {+ const same = String(q.instructions.candidate).includes('[same]');+ const probabilities = same ? { duplicate: 0.97, supersede: 0.02, independent: 0.01 } : { duplicate: 0.05, supersede: 0.1, independent: 0.85 };+ const choice = same ? 'duplicate' : 'independent';+ return [id, { type: 'choice', choice, confidence: probabilities[choice], probabilities }];+ }));+ return new Response(JSON.stringify({ model: 'jev-1.13.0', answers, usage: { input_tokens: 50, output_tokens: 5 } }));+ });+}++async function remember(fact: string): Promise<number> {+ const r = await writeSingleFact(engine, 'default', { fact, provenance: 'test', entity: SLUG, kind: 'fact', visibility: 'world' });+ expect(r.status).toBe('inserted');+ return r.id;+}+async function forget(id: number): Promise<Record<string, any>> {+ return await operationsByName.forget!.handler({ engine, config: { engine: 'postgres' }, remote: false, dryRun: false, sourceId: 'default',+ logger: { info: () => {}, warn: () => {}, error: () => {} } } as never, { id: String(id) }) as Record<string, any>;+}+async function replace(fact: string, target: number) {+ const res = await dispatchToolCall(engine, 'remember', { fact, provenance: 'test', entity: SLUG, replaces: String(target) }, { remote: false });+ return { isError: res.isError === true, body: JSON.parse(res.content[0]!.text!) as Record<string, any> };+}+async function factRow(id: number) {+ const [r] = await engine.executeRaw<{ expired: boolean; superseded_by: number | null }>(+ 'SELECT expired_at IS NOT NULL AS expired, superseded_by::int AS superseded_by FROM facts WHERE id = $1', [id]);+ return r!;+}++beforeAll(async () => {+ if (!RUN) return;+ engine = await setupLegacyEmbeddingDB();+});+afterAll(async () => {+ if (!RUN) return;+ __setDecideTransportForTests(null);+ __setEmbedTransportForTests(null);+ resetGateway();+ await disposePersistenceConsumer(engine);+ await teardownDB();+});+beforeEach(async () => {+ if (!RUN) return;+ __resetDecideStoreForTests();+ gateway();+ await engine.executeRaw('DELETE FROM decide_review_proposals');+ await engine.executeRaw('DELETE FROM decide_review_queue');+ await engine.executeRaw('DELETE FROM decide_calibrations');+ await engine.executeRaw("DELETE FROM facts WHERE entity_slug = $1", [SLUG]);+ await importFromContent(engine, SLUG, '---\ntitle: Alice Example\ntype: person\n---\n# Alice Example\n\nA person.\n', { noEmbed: true, sourceId: 'default' });+ for (const [k, v] of Object.entries({+ 'decide.provider': 'typesafe:jev-1.13.0', 'decide.slots.conflict.mode': 'on',+ 'decide.egress.typesafe.facts': 'allow', 'decide.slots.conflict.review_withdraw': 'true',+ })) await engine.setConfig(k, v);+});++d('P8 withdrawal review on Postgres', () => {+ test('the queue row commits with the withdrawal; concurrent accepts and a reject record one outcome', async () => {+ const anchor = await remember('[g5] Alice Example works at acme-example.');+ const restated = await remember('[g5][v1] Alice Example is employed by acme-example. [same]');+ const res = await forget(anchor);+ expect(res.similar_active.candidates.map((c: any) => c.fact_id)).toEqual([String(restated)]);+ expect(await engine.executeRaw('SELECT kind, a_ref FROM decide_review_queue')).toEqual([{ kind: 'withdraw', a_ref: String(anchor) }]);++ const id = await insertCalibration(engine, {+ slot: 'conflict', call_site: 'review_withdraw', provider: 'typesafe:jev-1.13.0', model_resolved: 'jev-1.13.0', threshold: 0.9, min_keep: null,+ metric: 'precision', metric_value: 0.97, ece: 0.03, retest_sd: 0.01, repack_sd: 0.01, n: 200, dataset_hash: 'd', split_hash: 's',+ calibrate_ids_hash: 'c', calibrate_only: false, pack_shape: packShape('conflict'), notes: null,+ });+ await engine.executeRaw('UPDATE decide_calibrations SET action_precision_lb = 0.95 WHERE id = $1', [id]);+ const lane = await runReviewLane(engine, { kind: 'withdraw' });+ expect(lane).toMatchObject({ effective: 'on', proposals: 1 });+ const [proposal] = await listReviewProposals(engine);+ expect(proposal!.b_ref).toBe(String(restated));++ const results = await Promise.all([acceptReviewProposal(engine, proposal!.id), acceptReviewProposal(engine, proposal!.id), rejectReviewProposal(engine, proposal!.id)]);+ const winners = results.filter(r => r.status === 'accepted' || r.status === 'rejected');+ expect(winners).toHaveLength(1);+ expect((await factRow(restated)).expired).toBe(winners[0]!.status === 'accepted');+ expect(await engine.executeRaw('SELECT kind FROM decide_review_queue')).toEqual([]);+ });+});++d('P8 remember.replaces on Postgres', () => {+ test('two concurrent replacements of one fact: one supersedes, the other is refused naming the chain head', async () => {+ const old = await remember('Alice Example lives in Lisbon.');+ const [a, b] = await Promise.all([replace('Alice Example lives in Porto.', old), replace('Alice Example lives in Madrid.', old)]);+ const won = [a, b].filter(r => !r.isError);+ const lost = [a, b].filter(r => r.isError);+ expect(won).toHaveLength(1);+ expect(won[0]!.body.status).toBe('superseded');+ expect(lost).toHaveLength(1);+ expect(JSON.stringify(lost[0]!.body)).toContain('target_superseded');+ expect(await factRow(old)).toEqual({ expired: true, superseded_by: Number(won[0]!.body.id) });+ const active = await engine.executeRaw<{ n: number }>('SELECT count(*)::int AS n FROM facts WHERE entity_slug = $1 AND expired_at IS NULL', [SLUG]);+ expect(active[0]!.n).toBe(1);+ });++ test('a replacement racing a forget leaves one consistent outcome', async () => {+ const old = await remember('Alice Example plays chess.');+ const [rep] = await Promise.all([replace('Alice Example plays go.', old), forget(old)]);+ const row = await factRow(old);+ expect(row.expired).toBe(true);+ if (rep.isError) {+ expect(JSON.stringify(rep.body)).toContain('target_withdrawn');+ expect(row.superseded_by).toBeNull();+ } else {+ expect(rep.body.status).toBe('superseded');+ expect(row.superseded_by).toBe(Number(rep.body.id));+ }+ });+});diff --git a/test/fixtures/goldens/catalog/postgres-db-initschema.json b/test/fixtures/goldens/catalog/postgres-db-initschema.jsonindex 49158bae10..3ba828f6cb 100644--- a/test/fixtures/goldens/catalog/postgres-db-initschema.json+++ b/test/fixtures/goldens/catalog/postgres-db-initschema.json@@ -29,6 +29,9 @@"decide_calibrations.decide_calibrations_pkey": "p PRIMARY KEY (id)","decide_proposals.decide_proposals_pkey": "p PRIMARY KEY (id)","decide_proposals.decide_proposals_sweep_id_pair_index_key": "u UNIQUE (sweep_id, pair_index)",+ "decide_review_proposals.decide_review_proposals_kind_source_id_a_ref_b_ref_subject_key": "u UNIQUE (kind, source_id, a_ref, b_ref, subject)",+ "decide_review_proposals.decide_review_proposals_pkey": "p PRIMARY KEY (id)",+ "decide_review_queue.decide_review_queue_pkey": "p PRIMARY KEY (kind, source_id, a_ref, b_ref)","decide_spend.decide_spend_pkey": "p PRIMARY KEY (request_id)","decide_state.decide_state_pkey": "p PRIMARY KEY (key)","decide_sweep_deferred.decide_sweep_deferred_pkey": "p PRIMARY KEY (slot, source_id, fact_id)",@@ -301,6 +304,12 @@"decide_proposals": ["<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"],+ "decide_review_proposals": [+ "<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"+ ],+ "decide_review_queue": [+ "<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"+ ],"decide_spend": ["<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"],@@ -543,6 +552,10 @@"decide_proposals_pkey": "CREATE UNIQUE INDEX decide_proposals_pkey ON public.decide_proposals USING btree (id)","decide_proposals_status_created_idx": "CREATE INDEX decide_proposals_status_created_idx ON public.decide_proposals USING btree (status, created_at)","decide_proposals_sweep_id_pair_index_key": "CREATE UNIQUE INDEX decide_proposals_sweep_id_pair_index_key ON public.decide_proposals USING btree (sweep_id, pair_index)",+ "decide_review_proposals_kind_source_id_a_ref_b_ref_subject_key": "CREATE UNIQUE INDEX decide_review_proposals_kind_source_id_a_ref_b_ref_subject_key ON public.decide_review_proposals USING btree (kind, source_id, a_ref, b_ref, subject)",+ "decide_review_proposals_pkey": "CREATE UNIQUE INDEX decide_review_proposals_pkey ON public.decide_review_proposals USING btree (id)",+ "decide_review_proposals_status_idx": "CREATE INDEX decide_review_proposals_status_idx ON public.decide_review_proposals USING btree (status, created_at)",+ "decide_review_queue_pkey": "CREATE UNIQUE INDEX decide_review_queue_pkey ON public.decide_review_queue USING btree (kind, source_id, a_ref, b_ref)","decide_spend_created_idx": "CREATE INDEX decide_spend_created_idx ON public.decide_spend USING btree (created_at)","decide_spend_pkey": "CREATE UNIQUE INDEX decide_spend_pkey ON public.decide_spend USING btree (request_id)","decide_state_pkey": "CREATE UNIQUE INDEX decide_state_pkey ON public.decide_state USING btree (key)",@@ -769,6 +782,7 @@"context_volunteer_events_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=context_volunteer_events.id","decide_calibrations_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=decide_calibrations.id","decide_proposals_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=decide_proposals.id",+ "decide_review_proposals_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=decide_review_proposals.id","decision_receipts_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=decision_receipts.id","eval_candidates_id_seq": "integer start=1 min=1 max=2147483647 increment=1 cycle=false cache=1 owned_by=eval_candidates.id","eval_capture_failures_id_seq": "integer start=1 min=1 max=2147483647 increment=1 cycle=false cache=1 owned_by=eval_capture_failures.id",@@ -1015,6 +1029,41 @@],"flags": "relkind=r rls=true force_rls=false"},+ "decide_review_proposals": {+ "columns": [+ "1 id bigint/int8 NOT NULL DEFAULT nextval('decide_review_proposals_id_seq'::regclass)",+ "2 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",+ "3 kind text/text NOT NULL",+ "4 source_id text/text NOT NULL",+ "5 sweep_id text/text NOT NULL",+ "6 a_ref text/text NOT NULL",+ "7 b_ref text/text NOT NULL",+ "8 subject text/text NOT NULL DEFAULT '*'::text",+ "9 visibility text/text NULL",+ "10 p_action real/float4 NOT NULL",+ "11 threshold real/float4 NULL",+ "12 model_resolved text/text NULL",+ "13 question_version text/text NULL",+ "14 status text/text NOT NULL DEFAULT 'pending'::text",+ "15 decided_at timestamp with time zone/timestamptz NULL",+ "16 receipt text/text NULL"+ ],+ "flags": "relkind=r rls=true force_rls=false"+ },+ "decide_review_queue": {+ "columns": [+ "1 kind text/text NOT NULL",+ "2 source_id text/text NOT NULL",+ "3 a_ref text/text NOT NULL",+ "4 b_ref text/text NOT NULL DEFAULT '*'::text",+ "5 evidence text/text NULL",+ "6 reason text/text NOT NULL DEFAULT 'queued'::text",+ "7 attempts integer/int4 NOT NULL DEFAULT 0",+ "8 next_attempt_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",+ "9 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"+ ],+ "flags": "relkind=r rls=true force_rls=false"+ },"decide_spend": {"columns": ["1 request_id text/text NOT NULL",diff --git a/test/fixtures/goldens/catalog/postgres-engine-init-default.json b/test/fixtures/goldens/catalog/postgres-engine-init-default.jsonindex 65013754c1..d676a2ba07 100644--- a/test/fixtures/goldens/catalog/postgres-engine-init-default.json+++ b/test/fixtures/goldens/catalog/postgres-engine-init-default.json@@ -35,6 +35,9 @@"decide_calibrations.decide_calibrations_pkey": "p PRIMARY KEY (id)","decide_proposals.decide_proposals_pkey": "p PRIMARY KEY (id)","decide_proposals.decide_proposals_sweep_id_pair_index_key": "u UNIQUE (sweep_id, pair_index)",+ "decide_review_proposals.decide_review_proposals_kind_source_id_a_ref_b_ref_subject_key": "u UNIQUE (kind, source_id, a_ref, b_ref, subject)",+ "decide_review_proposals.decide_review_proposals_pkey": "p PRIMARY KEY (id)",+ "decide_review_queue.decide_review_queue_pkey": "p PRIMARY KEY (kind, source_id, a_ref, b_ref)","decide_spend.decide_spend_pkey": "p PRIMARY KEY (request_id)","decide_state.decide_state_pkey": "p PRIMARY KEY (key)","decide_sweep_deferred.decide_sweep_deferred_pkey": "p PRIMARY KEY (slot, source_id, fact_id)",@@ -379,6 +382,12 @@"decide_proposals": ["<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"],+ "decide_review_proposals": [+ "<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"+ ],+ "decide_review_queue": [+ "<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"+ ],"decide_spend": ["<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"],@@ -678,6 +687,10 @@"decide_proposals_pkey": "CREATE UNIQUE INDEX decide_proposals_pkey ON public.decide_proposals USING btree (id)","decide_proposals_status_created_idx": "CREATE INDEX decide_proposals_status_created_idx ON public.decide_proposals USING btree (status, created_at)","decide_proposals_sweep_id_pair_index_key": "CREATE UNIQUE INDEX decide_proposals_sweep_id_pair_index_key ON public.decide_proposals USING btree (sweep_id, pair_index)",+ "decide_review_proposals_kind_source_id_a_ref_b_ref_subject_key": "CREATE UNIQUE INDEX decide_review_proposals_kind_source_id_a_ref_b_ref_subject_key ON public.decide_review_proposals USING btree (kind, source_id, a_ref, b_ref, subject)",+ "decide_review_proposals_pkey": "CREATE UNIQUE INDEX decide_review_proposals_pkey ON public.decide_review_proposals USING btree (id)",+ "decide_review_proposals_status_idx": "CREATE INDEX decide_review_proposals_status_idx ON public.decide_review_proposals USING btree (status, created_at)",+ "decide_review_queue_pkey": "CREATE UNIQUE INDEX decide_review_queue_pkey ON public.decide_review_queue USING btree (kind, source_id, a_ref, b_ref)","decide_spend_created_idx": "CREATE INDEX decide_spend_created_idx ON public.decide_spend USING btree (created_at)","decide_spend_pkey": "CREATE UNIQUE INDEX decide_spend_pkey ON public.decide_spend USING btree (request_id)","decide_state_pkey": "CREATE UNIQUE INDEX decide_state_pkey ON public.decide_state USING btree (key)",@@ -993,6 +1006,7 @@"context_volunteer_events_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=context_volunteer_events.id","decide_calibrations_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=decide_calibrations.id","decide_proposals_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=decide_proposals.id",+ "decide_review_proposals_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=decide_review_proposals.id","decision_receipts_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=decision_receipts.id","drift_decisions_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=drift_decisions.id","entity_identities_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=entity_identities.id",@@ -1307,6 +1321,41 @@],"flags": "relkind=r rls=true force_rls=false"},+ "decide_review_proposals": {+ "columns": [+ "1 id bigint/int8 NOT NULL DEFAULT nextval('decide_review_proposals_id_seq'::regclass)",+ "2 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",+ "3 kind text/text NOT NULL",+ "4 source_id text/text NOT NULL",+ "5 sweep_id text/text NOT NULL",+ "6 a_ref text/text NOT NULL",+ "7 b_ref text/text NOT NULL",+ "8 subject text/text NOT NULL DEFAULT '*'::text",+ "9 visibility text/text NULL",+ "10 p_action real/float4 NOT NULL",+ "11 threshold real/float4 NULL",+ "12 model_resolved text/text NULL",+ "13 question_version text/text NULL",+ "14 status text/text NOT NULL DEFAULT 'pending'::text",+ "15 decided_at timestamp with time zone/timestamptz NULL",+ "16 receipt text/text NULL"+ ],+ "flags": "relkind=r rls=true force_rls=false"+ },+ "decide_review_queue": {+ "columns": [+ "1 kind text/text NOT NULL",+ "2 source_id text/text NOT NULL",+ "3 a_ref text/text NOT NULL",+ "4 b_ref text/text NOT NULL DEFAULT '*'::text",+ "5 evidence text/text NULL",+ "6 reason text/text NOT NULL DEFAULT 'queued'::text",+ "7 attempts integer/int4 NOT NULL DEFAULT 0",+ "8 next_attempt_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",+ "9 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"+ ],+ "flags": "relkind=r rls=true force_rls=false"+ },"decide_spend": {"columns": ["1 request_id text/text NOT NULL",diff --git a/test/fixtures/goldens/catalog/postgres-engine-init-fts-portuguese.json b/test/fixtures/goldens/catalog/postgres-engine-init-fts-portuguese.jsonindex ecdff86800..b68cb35cc1 100644--- a/test/fixtures/goldens/catalog/postgres-engine-init-fts-portuguese.json+++ b/test/fixtures/goldens/catalog/postgres-engine-init-fts-portuguese.json@@ -35,6 +35,9 @@"decide_calibrations.decide_calibrations_pkey": "p PRIMARY KEY (id)","decide_proposals.decide_proposals_pkey": "p PRIMARY KEY (id)","decide_proposals.decide_proposals_sweep_id_pair_index_key": "u UNIQUE (sweep_id, pair_index)",+ "decide_review_proposals.decide_review_proposals_kind_source_id_a_ref_b_ref_subject_key": "u UNIQUE (kind, source_id, a_ref, b_ref, subject)",+ "decide_review_proposals.decide_review_proposals_pkey": "p PRIMARY KEY (id)",+ "decide_review_queue.decide_review_queue_pkey": "p PRIMARY KEY (kind, source_id, a_ref, b_ref)","decide_spend.decide_spend_pkey": "p PRIMARY KEY (request_id)","decide_state.decide_state_pkey": "p PRIMARY KEY (key)","decide_sweep_deferred.decide_sweep_deferred_pkey": "p PRIMARY KEY (slot, source_id, fact_id)",@@ -379,6 +382,12 @@"decide_proposals": ["<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"],+ "decide_review_proposals": [+ "<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"+ ],+ "decide_review_queue": [+ "<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"+ ],"decide_spend": ["<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"],@@ -678,6 +687,10 @@"decide_proposals_pkey": "CREATE UNIQUE INDEX decide_proposals_pkey ON public.decide_proposals USING btree (id)","decide_proposals_status_created_idx": "CREATE INDEX decide_proposals_status_created_idx ON public.decide_proposals USING btree (status, created_at)","decide_proposals_sweep_id_pair_index_key": "CREATE UNIQUE INDEX decide_proposals_sweep_id_pair_index_key ON public.decide_proposals USING btree (sweep_id, pair_index)",+ "decide_review_proposals_kind_source_id_a_ref_b_ref_subject_key": "CREATE UNIQUE INDEX decide_review_proposals_kind_source_id_a_ref_b_ref_subject_key ON public.decide_review_proposals USING btree (kind, source_id, a_ref, b_ref, subject)",+ "decide_review_proposals_pkey": "CREATE UNIQUE INDEX decide_review_proposals_pkey ON public.decide_review_proposals USING btree (id)",+ "decide_review_proposals_status_idx": "CREATE INDEX decide_review_proposals_status_idx ON public.decide_review_proposals USING btree (status, created_at)",+ "decide_review_queue_pkey": "CREATE UNIQUE INDEX decide_review_queue_pkey ON public.decide_review_queue USING btree (kind, source_id, a_ref, b_ref)","decide_spend_created_idx": "CREATE INDEX decide_spend_created_idx ON public.decide_spend USING btree (created_at)","decide_spend_pkey": "CREATE UNIQUE INDEX decide_spend_pkey ON public.decide_spend USING btree (request_id)","decide_state_pkey": "CREATE UNIQUE INDEX decide_state_pkey ON public.decide_state USING btree (key)",@@ -993,6 +1006,7 @@"context_volunteer_events_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=context_volunteer_events.id","decide_calibrations_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=decide_calibrations.id","decide_proposals_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=decide_proposals.id",+ "decide_review_proposals_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=decide_review_proposals.id","decision_receipts_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=decision_receipts.id","drift_decisions_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=drift_decisions.id","entity_identities_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=entity_identities.id",@@ -1307,6 +1321,41 @@],"flags": "relkind=r rls=true force_rls=false"},+ "decide_review_proposals": {+ "columns": [+ "1 id bigint/int8 NOT NULL DEFAULT nextval('decide_review_proposals_id_seq'::regclass)",+ "2 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",+ "3 kind text/text NOT NULL",+ "4 source_id text/text NOT NULL",+ "5 sweep_id text/text NOT NULL",+ "6 a_ref text/text NOT NULL",+ "7 b_ref text/text NOT NULL",+ "8 subject text/text NOT NULL DEFAULT '*'::text",+ "9 visibility text/text NULL",+ "10 p_action real/float4 NOT NULL",+ "11 threshold real/float4 NULL",+ "12 model_resolved text/text NULL",+ "13 question_version text/text NULL",+ "14 status text/text NOT NULL DEFAULT 'pending'::text",+ "15 decided_at timestamp with time zone/timestamptz NULL",+ "16 receipt text/text NULL"+ ],+ "flags": "relkind=r rls=true force_rls=false"+ },+ "decide_review_queue": {+ "columns": [+ "1 kind text/text NOT NULL",+ "2 source_id text/text NOT NULL",+ "3 a_ref text/text NOT NULL",+ "4 b_ref text/text NOT NULL DEFAULT '*'::text",+ "5 evidence text/text NULL",+ "6 reason text/text NOT NULL DEFAULT 'queued'::text",+ "7 attempts integer/int4 NOT NULL DEFAULT 0",+ "8 next_attempt_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",+ "9 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"+ ],+ "flags": "relkind=r rls=true force_rls=false"+ },"decide_spend": {"columns": ["1 request_id text/text NOT NULL",diff --git a/test/fixtures/goldens/catalog/postgres-engine-init-high-dims.json b/test/fixtures/goldens/catalog/postgres-engine-init-high-dims.jsonindex a815cd1c99..c992871526 100644--- a/test/fixtures/goldens/catalog/postgres-engine-init-high-dims.json+++ b/test/fixtures/goldens/catalog/postgres-engine-init-high-dims.json@@ -35,6 +35,9 @@"decide_calibrations.decide_calibrations_pkey": "p PRIMARY KEY (id)","decide_proposals.decide_proposals_pkey": "p PRIMARY KEY (id)","decide_proposals.decide_proposals_sweep_id_pair_index_key": "u UNIQUE (sweep_id, pair_index)",+ "decide_review_proposals.decide_review_proposals_kind_source_id_a_ref_b_ref_subject_key": "u UNIQUE (kind, source_id, a_ref, b_ref, subject)",+ "decide_review_proposals.decide_review_proposals_pkey": "p PRIMARY KEY (id)",+ "decide_review_queue.decide_review_queue_pkey": "p PRIMARY KEY (kind, source_id, a_ref, b_ref)","decide_spend.decide_spend_pkey": "p PRIMARY KEY (request_id)","decide_state.decide_state_pkey": "p PRIMARY KEY (key)","decide_sweep_deferred.decide_sweep_deferred_pkey": "p PRIMARY KEY (slot, source_id, fact_id)",@@ -379,6 +382,12 @@"decide_proposals": ["<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"],+ "decide_review_proposals": [+ "<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"+ ],+ "decide_review_queue": [+ "<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"+ ],"decide_spend": ["<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"],@@ -678,6 +687,10 @@"decide_proposals_pkey": "CREATE UNIQUE INDEX decide_proposals_pkey ON public.decide_proposals USING btree (id)","decide_proposals_status_created_idx": "CREATE INDEX decide_proposals_status_created_idx ON public.decide_proposals USING btree (status, created_at)","decide_proposals_sweep_id_pair_index_key": "CREATE UNIQUE INDEX decide_proposals_sweep_id_pair_index_key ON public.decide_proposals USING btree (sweep_id, pair_index)",+ "decide_review_proposals_kind_source_id_a_ref_b_ref_subject_key": "CREATE UNIQUE INDEX decide_review_proposals_kind_source_id_a_ref_b_ref_subject_key ON public.decide_review_proposals USING btree (kind, source_id, a_ref, b_ref, subject)",+ "decide_review_proposals_pkey": "CREATE UNIQUE INDEX decide_review_proposals_pkey ON public.decide_review_proposals USING btree (id)",+ "decide_review_proposals_status_idx": "CREATE INDEX decide_review_proposals_status_idx ON public.decide_review_proposals USING btree (status, created_at)",+ "decide_review_queue_pkey": "CREATE UNIQUE INDEX decide_review_queue_pkey ON public.decide_review_queue USING btree (kind, source_id, a_ref, b_ref)","decide_spend_created_idx": "CREATE INDEX decide_spend_created_idx ON public.decide_spend USING btree (created_at)","decide_spend_pkey": "CREATE UNIQUE INDEX decide_spend_pkey ON public.decide_spend USING btree (request_id)","decide_state_pkey": "CREATE UNIQUE INDEX decide_state_pkey ON public.decide_state USING btree (key)",@@ -989,6 +1002,7 @@"context_volunteer_events_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=context_volunteer_events.id","decide_calibrations_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=decide_calibrations.id","decide_proposals_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=decide_proposals.id",+ "decide_review_proposals_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=decide_review_proposals.id","decision_receipts_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=decision_receipts.id","drift_decisions_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=drift_decisions.id","entity_identities_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=entity_identities.id",@@ -1303,6 +1317,41 @@],"flags": "relkind=r rls=true force_rls=false"},+ "decide_review_proposals": {+ "columns": [+ "1 id bigint/int8 NOT NULL DEFAULT nextval('decide_review_proposals_id_seq'::regclass)",+ "2 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",+ "3 kind text/text NOT NULL",+ "4 source_id text/text NOT NULL",+ "5 sweep_id text/text NOT NULL",+ "6 a_ref text/text NOT NULL",+ "7 b_ref text/text NOT NULL",+ "8 subject text/text NOT NULL DEFAULT '*'::text",+ "9 visibility text/text NULL",+ "10 p_action real/float4 NOT NULL",+ "11 threshold real/float4 NULL",+ "12 model_resolved text/text NULL",+ "13 question_version text/text NULL",+ "14 status text/text NOT NULL DEFAULT 'pending'::text",+ "15 decided_at timestamp with time zone/timestamptz NULL",+ "16 receipt text/text NULL"+ ],+ "flags": "relkind=r rls=true force_rls=false"+ },+ "decide_review_queue": {+ "columns": [+ "1 kind text/text NOT NULL",+ "2 source_id text/text NOT NULL",+ "3 a_ref text/text NOT NULL",+ "4 b_ref text/text NOT NULL DEFAULT '*'::text",+ "5 evidence text/text NULL",+ "6 reason text/text NOT NULL DEFAULT 'queued'::text",+ "7 attempts integer/int4 NOT NULL DEFAULT 0",+ "8 next_attempt_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",+ "9 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"+ ],+ "flags": "relkind=r rls=true force_rls=false"+ },"decide_spend": {"columns": ["1 request_id text/text NOT NULL",diff --git a/test/fixtures/goldens/doctor/json-pglite-degraded.json b/test/fixtures/goldens/doctor/json-pglite-degraded.jsonindex 22c4a12451..a7377f67a7 100644--- a/test/fixtures/goldens/doctor/json-pglite-degraded.json+++ b/test/fixtures/goldens/doctor/json-pglite-degraded.json@@ -507,13 +507,13 @@},{"category": "meta",- "message": "Version 200 (latest: 200)",+ "message": "Version 201 (latest: 201)","name": "schema_version","status": "ok"},{"category": "meta",- "message": "853 column(s) verified against live schema",+ "message": "878 column(s) verified against live schema","name": "schema_columns","status": "ok"},diff --git a/test/fixtures/goldens/doctor/json-pglite-fresh.json b/test/fixtures/goldens/doctor/json-pglite-fresh.jsonindex 153d996111..edc50ca91b 100644--- a/test/fixtures/goldens/doctor/json-pglite-fresh.json+++ b/test/fixtures/goldens/doctor/json-pglite-fresh.json@@ -510,13 +510,13 @@},{"category": "meta",- "message": "Version 200 (latest: 200)",+ "message": "Version 201 (latest: 201)","name": "schema_version","status": "ok"},{"category": "meta",- "message": "853 column(s) verified against live schema",+ "message": "878 column(s) verified against live schema","name": "schema_columns","status": "ok"},diff --git a/test/fixtures/goldens/doctor/json-postgres-fresh.json b/test/fixtures/goldens/doctor/json-postgres-fresh.jsonindex 9ebd3e303b..c0d4d9b224 100644--- a/test/fixtures/goldens/doctor/json-postgres-fresh.json+++ b/test/fixtures/goldens/doctor/json-postgres-fresh.json@@ -497,19 +497,19 @@},{"category": "ops",- "message": "RLS enabled on 103/103 public tables",+ "message": "RLS enabled on 105/105 public tables","name": "rls","status": "ok"},{"category": "meta",- "message": "Version 200 (latest: 200)",+ "message": "Version 201 (latest: 201)","name": "schema_version","status": "ok"},{"category": "meta",- "message": "859 column(s) verified against live schema",+ "message": "884 column(s) verified against live schema","name": "schema_columns","status": "ok"},diff --git a/test/fixtures/goldens/exports/runtime.json b/test/fixtures/goldens/exports/runtime.jsonindex 829c615c1b..0f73524704 100644--- a/test/fixtures/goldens/exports/runtime.json+++ b/test/fixtures/goldens/exports/runtime.json@@ -470,11 +470,16 @@"withBudgetTracker"],"./ai/invocation-guard": [+ "aiInvocationObserverFailures",+ "currentAIAttribution","hasAIInvocationGuard",+ "hasAIInvocationObservers","invokeAI","isAIInvocationPolicyError",+ "observeAIInvocations","responseInvocationUsage","sdkInvocationUsage",+ "withAIAttribution","withAIInvocationGuard","withAIInvocationPreflight"],diff --git a/test/fixtures/goldens/exports/types.json b/test/fixtures/goldens/exports/types.jsonindex fb4aa5732c..b5834d91f6 100644--- a/test/fixtures/goldens/exports/types.json+++ b/test/fixtures/goldens/exports/types.json@@ -2257,11 +2257,22 @@}],"./ai/invocation-guard": [+ {+ "kind": "interface",+ "members": [+ "effect?: string | undefined",+ "job_id?: string | number | undefined",+ "job_name?: string | undefined",+ "phase?: string | undefined",+ "request_id?: string | undefined"+ ],+ "name": "AIAttribution"+ },{"kind": "interface","members": ["cacheWriteTtl?: \"5m\" | \"1h\" | undefined",- "kind: \"embedding\" | \"rerank\" | \"chat\" | \"multimodal\" | \"decide\"",+ "kind: \"embedding\" | \"rerank\" | \"chat\" | \"transcription\" | \"multimodal\" | \"decide\"","maxInputTokens?: number | undefined","maxOutputTokens?: number | undefined","model: string",@@ -2269,6 +2280,18 @@],"name": "AIInvocation"},+ {+ "kind": "interface",+ "members": [+ "attribution: AIAttribution | null",+ "call: AIInvocation",+ "ms: number",+ "outcome: \"error\" | \"ok\" | \"refused\"",+ "startedAt: number",+ "usage: AIInvocationUsage | null"+ ],+ "name": "AIInvocationEvent"+ },{"kind": "type","name": "AIInvocationGuard",@@ -2276,6 +2299,13 @@"(call: AIInvocation) => Promise<AIInvocationPermit>"]},+ {+ "kind": "type",+ "name": "AIInvocationObserver",+ "signature": [+ "(event: AIInvocationEvent) => void"+ ]+ },{"kind": "interface","members": [@@ -2293,6 +2323,20 @@],"name": "AIInvocationUsage"},+ {+ "kind": "function",+ "name": "aiInvocationObserverFailures",+ "signature": [+ "() => number"+ ]+ },+ {+ "kind": "function",+ "name": "currentAIAttribution",+ "signature": [+ "() => AIAttribution | null"+ ]+ },{"kind": "function","name": "hasAIInvocationGuard",@@ -2300,6 +2344,13 @@"() => boolean"]},+ {+ "kind": "function",+ "name": "hasAIInvocationObservers",+ "signature": [+ "() => boolean"+ ]+ },{"kind": "function","name": "invokeAI",@@ -2314,6 +2365,13 @@"(error: unknown) => boolean"]},+ {+ "kind": "function",+ "name": "observeAIInvocations",+ "signature": [+ "(observer: AIInvocationObserver) => () => void"+ ]+ },{"kind": "function","name": "responseInvocationUsage",@@ -2328,6 +2386,13 @@"(result: unknown) => AIInvocationUsage | null"]},+ {+ "kind": "function",+ "name": "withAIAttribution",+ "signature": [+ "<T>(patch: AIAttribution, fn: () => T) => T"+ ]+ },{"kind": "function","name": "withAIInvocationGuard",@@ -2470,7 +2535,7 @@"hooks?: { stop_push_debounce_min?: number | string; } | undefined","integrations?: { memorable?: { enabled?: boolean; }; } | undefined","litellm_api_key?: string | undefined",- "mcp?: { instructions?: string; publish_skills?: boolean; publish_advisor?: boolean; skills_dir?: string; strict_params?: \"warn\" | \"reject\"; default_surface_dcr?: \"verbs\" | \"starter\" | \"full\"; result_rows?: \"lean\" | \"full\"; } | undefined",+ "mcp?: { instructions?: string; publish_skills?: boolean; publish_advisor?: boolean; skills_dir?: string; strict_params?: \"warn\" | \"reject\"; default_surface_dcr?: \"verbs\" | \"starter\" | \"full\"; advertised_surface?: \"verbs\" | \"starter\" | \"full\"; result_rows?: \"lean\" | \"full\"; } | undefined","mcp_surface?: \"verbs\" | \"starter\" | \"full\" | undefined","memory?: { auto_writeback?: string; auto_writeback_transient_ttl?: string; visibility_posture?: string; } | undefined","openai_api_key?: string | undefined",@@ -5587,7 +5652,8 @@"publishGateKey?: \"mcp.publish_skills\" | \"mcp.publish_advisor\" | undefined","requiredScopes?: readonly string[] | undefined","scope?: \"agent\" | \"read\" | \"write\" | \"admin\" | \"sources_admin\" | \"users_admin\" | undefined",- "verb?: boolean | undefined"+ "verb?: boolean | undefined",+ "writeInference?: WriteInference | undefined"],"name": "Operation"},@@ -5611,6 +5677,7 @@"logger: Logger","remote: boolean","resultRows?: \"full\" | \"lean\" | undefined",+ "revealTools?: ((names: string[]) => void) | undefined","sessionId?: string | undefined","sourceId: string","subagentId?: number | undefined",@@ -7139,6 +7206,7 @@"members": ["abstained?: ThinkAbstention | undefined","answer: string",+ "answer_raw?: string | undefined","citations: ParsedCitation[]","cost_usd?: number | undefined","diagnostics: { pagesFromHybrid: number; takesFromKeyword: number; takesFromVector: number; graphHits: number; }",@@ -7148,12 +7216,15 @@"graphHits: number","modelUsed: string","pagesGathered: number",+ "persist?: { answer: string; unverified_claims: Array<{ text: string; reason: string; detail: string; }>; } | undefined","question: string",+ "quote_check?: { grounded: number; repaired: number; unverified: number; } | undefined","rounds: number","savedSlug?: string | undefined","synthesisOk?: boolean | undefined","synthesis_status?: ThinkSynthesisStatus | undefined","takesGathered: number",+ "unverified_quotes?: { text: string; reason: string; }[] | undefined","usage?: { input_tokens: number; output_tokens: number; } | null | undefined","warnings: string[]"],diff --git a/test/fixtures/goldens/pglite-upgrade-replay/catalog-after-boot.json b/test/fixtures/goldens/pglite-upgrade-replay/catalog-after-boot.jsonindex 40df5ecbfd..54365e05df 100644--- a/test/fixtures/goldens/pglite-upgrade-replay/catalog-after-boot.json+++ b/test/fixtures/goldens/pglite-upgrade-replay/catalog-after-boot.json@@ -35,6 +35,9 @@"decide_calibrations.decide_calibrations_pkey": "p PRIMARY KEY (id)","decide_proposals.decide_proposals_pkey": "p PRIMARY KEY (id)","decide_proposals.decide_proposals_sweep_id_pair_index_key": "u UNIQUE (sweep_id, pair_index)",+ "decide_review_proposals.decide_review_proposals_kind_source_id_a_ref_b_ref_subject_key": "u UNIQUE (kind, source_id, a_ref, b_ref, subject)",+ "decide_review_proposals.decide_review_proposals_pkey": "p PRIMARY KEY (id)",+ "decide_review_queue.decide_review_queue_pkey": "p PRIMARY KEY (kind, source_id, a_ref, b_ref)","decide_spend.decide_spend_pkey": "p PRIMARY KEY (request_id)","decide_state.decide_state_pkey": "p PRIMARY KEY (key)","decide_sweep_deferred.decide_sweep_deferred_pkey": "p PRIMARY KEY (slot, source_id, fact_id)",@@ -375,6 +378,12 @@"decide_proposals": ["<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"],+ "decide_review_proposals": [+ "<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"+ ],+ "decide_review_queue": [+ "<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"+ ],"decide_spend": ["<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"],@@ -677,6 +686,10 @@"decide_proposals_pkey": "CREATE UNIQUE INDEX decide_proposals_pkey ON public.decide_proposals USING btree (id)","decide_proposals_status_created_idx": "CREATE INDEX decide_proposals_status_created_idx ON public.decide_proposals USING btree (status, created_at)","decide_proposals_sweep_id_pair_index_key": "CREATE UNIQUE INDEX decide_proposals_sweep_id_pair_index_key ON public.decide_proposals USING btree (sweep_id, pair_index)",+ "decide_review_proposals_kind_source_id_a_ref_b_ref_subject_key": "CREATE UNIQUE INDEX decide_review_proposals_kind_source_id_a_ref_b_ref_subject_key ON public.decide_review_proposals USING btree (kind, source_id, a_ref, b_ref, subject)",+ "decide_review_proposals_pkey": "CREATE UNIQUE INDEX decide_review_proposals_pkey ON public.decide_review_proposals USING btree (id)",+ "decide_review_proposals_status_idx": "CREATE INDEX decide_review_proposals_status_idx ON public.decide_review_proposals USING btree (status, created_at)",+ "decide_review_queue_pkey": "CREATE UNIQUE INDEX decide_review_queue_pkey ON public.decide_review_queue USING btree (kind, source_id, a_ref, b_ref)","decide_spend_created_idx": "CREATE INDEX decide_spend_created_idx ON public.decide_spend USING btree (created_at)","decide_spend_pkey": "CREATE UNIQUE INDEX decide_spend_pkey ON public.decide_spend USING btree (request_id)","decide_state_pkey": "CREATE UNIQUE INDEX decide_state_pkey ON public.decide_state USING btree (key)",@@ -991,6 +1004,7 @@"context_volunteer_events_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=context_volunteer_events.id","decide_calibrations_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=decide_calibrations.id","decide_proposals_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=decide_proposals.id",+ "decide_review_proposals_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=decide_review_proposals.id","decision_receipts_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=decision_receipts.id","drift_decisions_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=drift_decisions.id","entity_identities_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=entity_identities.id",@@ -1306,6 +1320,41 @@],"flags": "relkind=r rls=true force_rls=false"},+ "decide_review_proposals": {+ "columns": [+ "1 id bigint/int8 NOT NULL DEFAULT nextval('decide_review_proposals_id_seq'::regclass)",+ "2 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",+ "3 kind text/text NOT NULL",+ "4 source_id text/text NOT NULL",+ "5 sweep_id text/text NOT NULL",+ "6 a_ref text/text NOT NULL",+ "7 b_ref text/text NOT NULL",+ "8 subject text/text NOT NULL DEFAULT '*'::text",+ "9 visibility text/text NULL",+ "10 p_action real/float4 NOT NULL",+ "11 threshold real/float4 NULL",+ "12 model_resolved text/text NULL",+ "13 question_version text/text NULL",+ "14 status text/text NOT NULL DEFAULT 'pending'::text",+ "15 decided_at timestamp with time zone/timestamptz NULL",+ "16 receipt text/text NULL"+ ],+ "flags": "relkind=r rls=true force_rls=false"+ },+ "decide_review_queue": {+ "columns": [+ "1 kind text/text NOT NULL",+ "2 source_id text/text NOT NULL",+ "3 a_ref text/text NOT NULL",+ "4 b_ref text/text NOT NULL DEFAULT '*'::text",+ "5 evidence text/text NULL",+ "6 reason text/text NOT NULL DEFAULT 'queued'::text",+ "7 attempts integer/int4 NOT NULL DEFAULT 0",+ "8 next_attempt_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",+ "9 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"+ ],+ "flags": "relkind=r rls=true force_rls=false"+ },"decide_spend": {"columns": ["1 request_id text/text NOT NULL",