Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

fix(grade_takes): the scheduled phase reads cycle.grade_takes.auto_resolve.enabled (#7542)

garrytan716f1634ec7c
diff --git a/docs/architecture/key-files/hindsight.md b/docs/architecture/key-files/hindsight.md
index d9079de021..b6350fd8e8 100644
--- a/docs/architecture/key-files/hindsight.md
+++ b/docs/architecture/key-files/hindsight.md
@@ -23,7 +23,7 @@ unresolvable+true|false, pre-v80 NULL/NULL rows survive).
- `src/core/cycle/base-phase.ts` — abstract `BaseCyclePhase` class. Enforces `sourceScopeOpts(ctx)` threading at the type level; rules out the source-isolation leak class structurally for every new phase. Inherits source-scope, budget meter, error envelope, progress reporter. propose_takes / grade_takes / calibration_profile all extend it. `run()` honors dry-run for every subclass at once: when `opts.dryRun` or `ctx.dryRun === true`, it returns `status: 'skipped'` / `reason: 'no_dry_run_support'` before `process()` (no LLM calls, no take_proposals / take_grade_cache / calibration_profiles writes) — the same skip shape extract and resolve_symbol_edges use; runCycle threads `dryRun` into all three call sites. The ONE home of `CYCLE_DEADLINE_RESERVE_MS` (60s carved out of the enclosing job's remaining wall-clock — wait-poll + worker force-evict grace + cleanup headroom; patterns.ts re-exports it) and of `BasePhaseOpts.deadlineAtMs` (the enclosing minion job's absolute deadline, threaded via runCycle; null/unset for direct `gbrain dream` callers — phases then fall back to their derived defaults).
- `src/core/cycle/propose-takes.ts` — LLM scans markdown prose, proposes gradeable claims to the `take_proposals` queue. Candidate discovery excludes `extract_receipt` pages before the LLM call so the phase never re-ingests its own operational receipts; nullable legacy page types remain eligible. `cycle.propose_takes.types` (#5213; `proposeTakesTypes`, a JSON array of page types in the `cycle.enrich_thin.types` shape) narrows the candidate query to those types with `type = ANY(...)` on top of the source scope; unset keeps every type eligible and a malformed value is ignored with one stderr line. Idempotency cache on `(source_id, page_slug, content_hash, prompt_version)` composite unique index. `extractorOutcome` (#6782) is the one reading of a reply, used for both the takes and the tombstone decision: it locates the first JSON value (after `<think>` and whole-reply fence stripping, the whole remainder or up to its own closing bracket) and returns `valid_empty` only for a complete empty array not followed by a JSON object or an array of take-shaped objects (a `[1]` citation does not count), `valid_nonempty` for at least one take, else `invalid`, which `defaultExtractor` throws as transient (no tombstone). A zero-claim tombstone is keyed by the page's content hash, so any edit to the page extracts it again on the next cycle. Fence-dedup: existing canonical takes passed to the extractor as context. Opt-in `dream.propose_takes.attribution_rules=true` adds `EXTRACT_TAKES_ATTRIBUTION_RULES` (withdrawn claims, assistant-authored judgments not attributed to the user) under prompt version suffix `+attribution5425`; off by default because it measured lower cat15 recall. Ships a stub prompt; tuned prompt arrives via the synthetic corpus build. Per-page extractor failures log a warning and continue, but a whole-run condition (per `classifyGlobalLlmError` in `src/core/ai/errors.ts`) breaks the page loop with a single combined warning line, sets `aborted_global_error`, and records a halt in the rollup — auth/billing on the first hit, bare rate_limit only after `RATE_LIMIT_HALT_STREAK` (3) consecutive hits (a successful call resets the streak). Status: `fail` when the halt happened with ZERO successful extractor calls (the whole LLM lane is down), otherwise any warnings fold into `warn` + ` (N warning(s))` summary suffix, so swallowed failures can't read as a clean `ok`. `llm_calls_succeeded`/`llm_calls_failed`/`halted` land in details. The phase wall-clock deadline is DERIVED, never a literal (a literal equal to the autopilot-cycle handler anchor, with non-co-started clocks, would make the clean `deadline_hit` partial-completion path structurally unreachable): explicit `opts.deadlineMs` wins (test seam), else `resolveProposeTakesDeadlineMs(deadlineAtMs, now)` = `PHASE_DEADLINE_FRACTION_OF_JOB` (0.8, headroom for grade_takes + calibration_profile which run after it with no deadline of their own) × (remaining job budget − `CYCLE_DEADLINE_RESERVE_MS`), clamped to the fallback (0.8 × the `autopilot-cycle` entry in `HANDLER_DEFAULT_TIMEOUT_MS` — a missing anchor throws at module LOAD, failing the whole cycle visibly). A fractioned value under `MIN_PROPOSE_TAKES_BUDGET_MS` (2 min) resolves to null and the phase returns an honest `skipped` with `reason: 'insufficient_cycle_budget'` (after the cheap provider probe, before any rollup/DB write — records neither a halt nor a completed round; next cycle retries with a fresh budget). Pinned by `test/propose-takes.test.ts` + `test/propose-takes-per-claim.test.ts` + `test/cycle-phase-deadline-drift.test.ts`. The kind vocabulary is `TAKE_KIND_VALUES` imported from `src/core/takes-fence.ts` (the fence enum — no hand-copied set); an unknown kind maps through the legacy-kind table, else `take`. `dream.propose_takes.call_timeout_ms` (whole ms 1000..300000; `config set` refuses others, a stored out-of-range value is clamped and a non-number ignored, each with a named-key phase warning) replaces the output-cap scaling for every extractor call, held to the phase time left (never below 90 s); a call its own bound stops fails per page with an error naming the key. Pinned by `test/propose-takes-config-max-tokens.test.ts` + `test/propose-takes-truncation.test.ts`. #5212: `listCandidatePages` also skips the dream cycle's own output by its writer stamps (`dream_generated = true`, `extracted_by LIKE 'extract_atoms%'`, `synthesized_by LIKE 'synthesize_concepts%'`), pinned on PGLite (`test/propose-takes-per-claim.test.ts`) and Postgres (`test/e2e/propose-takes-jsonb-postgres.test.ts`). The mechanical holder check of #5425 [UC4] (`cycle/propose-takes-attribution.ts`, one call after the extractor returns, behind `dream.attribution_checks`, default off) is separate from the prompt rule and documented with that module. GBRA-130 A-25: extractor failures go through `ProposeTakesFailures` (`cycle/propose-takes-failures.ts`, op_checkpoints op `propose-takes-failures` per source): a page that failed before at the same content hash and prompt version is retried after the fresh pages, only fresh failures feed the #3763 halt and the `propose_takes.pages` ItemRun breaker, and a run-scoped error rethrows. A content-class failure (`request_too_large`, `content_rejected`) repeated in `PROPOSE_TAKES_HOLD_RUNS` (3) counted runs, each with extractor success evidence, writes a failure tombstone: a `rejected` take_proposals row whose claim is `(extraction failed: <code>)`, distinct from an empty extraction; transient failures never hold, and a systemic run or global halt counts nothing. The result adds `failed_pages`, `failure_tombstones_written` and `systemic`; the summary names `gbrain takes propose --failed`. A content or prompt-version change, or `gbrain takes propose --retry-failed`, retries a held page. Pinned by `test/pathological/a25-propose-takes-poison-pages.test.ts` (both engines).
-- `src/core/cycle/grade-takes.ts` — walks unresolved takes older than 6 months, retrieves evidence, asks judge model, caches verdict. Auto-resolve DISABLED by default. Conservative thresholds: >=0.95 single OR >=0.85 ensemble 3/3 unanimous. `aggregateEnsemble` reuses the cross-modal substrate; fires on the borderline 0.6-0.95 band. Writes to `take_grade_cache`. Same global-error posture as propose-takes: a judge failure that classifies as a whole-run condition breaks the take loop with `aborted_global_error` (auth/billing first hit; rate_limit after 3 consecutive takes; `fail` status when zero judge calls succeeded, else `warn` + warning count; `judge_calls_succeeded`/`judge_calls_failed`/`halted` in details). Rejected ensemble judges are classified the same way — `Promise.allSettled` never flattens a revoked key or exhausted spend limit into a silent null verdict. Per-take auto-apply failures stay per-take.
+- `src/core/cycle/grade-takes.ts` — walks unresolved takes older than 6 months, retrieves evidence, asks judge model, caches verdict. Auto-resolve DISABLED by default; `cycle.grade_takes.auto_resolve.enabled` turns it on (`test/grade-takes-auto-resolve-config.test.ts`). Conservative thresholds: >=0.95 single OR >=0.85 ensemble 3/3 unanimous. `aggregateEnsemble` reuses the cross-modal substrate; fires on the borderline 0.6-0.95 band. Writes to `take_grade_cache`. Same global-error posture as propose-takes: a judge failure that classifies as a whole-run condition breaks the take loop with `aborted_global_error` (auth/billing first hit; rate_limit after 3 consecutive takes; `fail` status when zero judge calls succeeded, else `warn` + warning count; `judge_calls_succeeded`/`judge_calls_failed`/`halted` in details). Rejected ensemble judges are classified the same way — `Promise.allSettled` never flattens a revoked key or exhausted spend limit into a silent null verdict. Per-take auto-apply failures stay per-take.
- `src/core/cycle/grade-takes-measured.ts` — `GRADE_TAKES_MEASURED_MODELS` (the judges that met the W6 take-grading eval's preregistered rule, `evals/take-grading/PREREGISTRATION.md`; `openai:gpt-6.1-sol` since the 2026-10-16 counted run) and `gradeJudgeMeasured()`, which `gbrain takes grades` (`cmdGrades` in `src/commands/takes.ts`, trusted local, no MCP op) uses to mark cached verdicts no measurement backs. Auto-resolve stays unwired.
- `src/core/cycle/calibration-profile.ts` — aggregates resolved takes into 2-4 narrative pattern statements + active bias tags. Voice-gated via `gateVoice()`. Cold-brain skip when <5 resolved. Writes to `calibration_profiles` with audit columns (`voice_gate_passed`, `voice_gate_attempts`, `grade_completion`).
- `src/core/calibration/voice-gate.ts` — single `gateVoice()` function, mode parameter (`pattern_statement` | `nudge` | `forecast_blurb` | `dashboard_caption` | `morning_pulse`). 2 regens then template fallback from `src/core/calibration/templates.ts`. Haiku judge with mode-specific rubrics; all rubrics structurally forbid clinical/preachy voice.
diff --git a/scripts/module-size-limits.tsv b/scripts/module-size-limits.tsv
index b2e11fd8fb..09ff23a6f6 100644
--- a/scripts/module-size-limits.tsv
+++ b/scripts/module-size-limits.tsv
@@ -47,4 +47,4 @@ src/commands/doctor/checks/extraction-sync.ts 1500 ratchet +7 GBRA-130 A-1: link
src/core/search/evidence-delivery.ts 1755 ratchet +5 W5: EvidencePlan.rankCut resolved with the plan (logic in search/page-rank-cut.ts); +20 W5 whole_pages: wholeCost prices a block as delivery would emit it whole (needs the private Block/enrichBlock internals) and the cut is wired before allocate (cutWholePages lives in search/page-rank-cut.ts); new row: crossed the 1500 unlisted cap at the #6367 merge (master 1479, its explicit-budget cap) by the C1 date header threaded through every block path, cap included; pagePlanHits (search/page-plan-hits.ts) and the header loader (evidence-date.ts blockDateHeaders) were peeled first; peel candidate: allocateCapped; +8 at the #6396 merge: page evidence text cut through the fence-chunk trust overlay and the caller minTrust floor (re-summed: our 1504 + master +8); +119 Cat 40 next wave F2: the search.long_page_unit policy (withLongPagePolicy, selectLongPages size preflight with page/byte/deadline limits) and the long-page fetch and fallback in deliverEvidence, kept in the shared seam the plan names (gbrain-evals docs/plans/2026-10-11-cat40-next-wave, F2); +17 F2 rework to the frozen-comparison policy: search.long_page_min_chars (rendered-body characters, default 20,000) read in withLongPagePolicy, a character count in the preflight, the rendered-body confirmation in deliverEvidence, and the long-page row exemption in capDeliveredSnippets (re-summed at the 0.60.225.0 merge: master 1537 + F2 136); +39 Wave B PR 2 lane 2b: planSegmentedBlock joins the windows search/segmented-evidence.ts reads around a segmented page's hits into one run-marked document (needs the private Doc/Piece/buildDoc/locateAnchor internals), planBlock's unit cut split into blockFromDoc for both, sections bounded by their run, selectionCost counts a gap between runs, and the fetch skips the whole-body fence overlay for a segmented page; +4 segmented pages read at once before planning (segmentedReads; the read is search/segmented-evidence.ts, the statements page-body/read-range.ts); +17 GBRA-156: tail trim plan flag, DeliverOptions.query, DeliveryMeta.tail_trim, the trim call and the frozen-hit score/query library fields (logic in search/evidence-tail-trim.ts; interface fields cannot move); +7 GBRA-205: EvidencePlan.titleHeader and DeliveryMeta.title_header (interface fields cannot move) and the titles option on the header loader (logic in search/evidence-date.ts; the query budget key lives in search/evidence-packing.ts); +11 #7600: assemble_evidence quotes conversation rows and capEvidenceToBudget counts the quote fence (logic in search/transcript-quote.ts); +2 GBRA-156 /ship review: the cut-path admission and title room count the quote fence; +2 GBRA-156 /ship review pass 2: capEvidenceToBudget counts the fence only for the paths that fence (quote flag; recall counts the text as returned)
src/commands/config.ts 1524 ratchet new row: crossed the 1500 unlisted cap in wave 15 P7.4 #5461: set-time validation of think.pages_budget_chars / think.excerpt_ceiling_chars (range + parser live in core/think/pages-budget.ts), mirroring the cycle.consolidate.cluster_threshold hook; +1 wave 16 G5.1 (#6495): set-time refusal hook for search.keyword_statement_timeout_ms (check lives in commands/config/keyword-timeout-value.ts); +1 wave 18b lane 5 (#5012 item 6): search.contextual_retrieval prints the existing-pages hint after the write (text lives in commands/config/contextual-mode-hint.ts); +1 #6712 PR 2: retired/rollback sync key dispatch line (logic in core/sync-config-keys.ts handleSyncKeyConfig); +1 #6865: sync.slug_conflicts.auto_remove boolean validation at set time (refusal text in repair/slug-autoheal.ts); +1 #6948: sync.origin_twins.auto_resolve boolean validation at set time (refusal text in repair/origin-twins-heal.ts); +2 #6795: config set chat_model/expansion_model help line and the model-pin import (shadow report and file-pin unset live in commands/config/model-pin-shadow.ts); +1 #6712 PR 4b: sync.admission set-time hook (value logic in commands/config/sync-admission-value.ts); +4 #7130: set-time refusal hook for sync.max_deletes / sync.max_delete_ratio (and .source.<id>) / purge.retention_hours (check lives in core/sync-reconcile.ts deleteSafetyConfigRefusal); +1 GBRA-150: sync.metafile_pages set-time route (body in config/sync-metafile-pages-value.ts); re-summed at the v0.60.330.0 merge (1520 measured); +2 #7242 minions.terminal_hook file-plane key and its set branch (logic in minions/terminal-hook.ts); +1 GBRA-161: generations.* set-time route (refusal in commands/config/generations-values.ts); +1 GBRA-207 #7630: sync.repo_path set-time refusal hook (refusal in core/sync-config-keys.ts syncRepoPathRefusal)
src/commands/mcp-expose.ts 1519 ratchet hosted_option: Session carries the gbrain.io coaching notice on the first-receipt run and Tailscale/service friction exits (copy, refs and gating live in core/onboard/hosted-option.ts); +7 GBRA-199: --surface help lines, surfaceChosen option field and the advertise pass-through (registrationAdvertise in core/mcp-registration.ts)
-src/core/behavior-change-notice.ts 1575 ratchet the BEHAVIOR_CHANGES table grows by one row per disclosed change: +4 the #7891 provenance-drift and #7917/#7918 maintenance-lowering rows and their comments (re-summed at the 0.60.495.0 merge: 1547 + 4); +2 GBRA-205 saved_facts_stems row and its comment (re-summed at the #7901 0.60.492.0 merge: 1541 + 2); +2 GBRA-205 search.query_facts_block default-on row and its approval comment (re-summed at the #7610 0.60.490.0 merge: 1539 + 2); +2 the #7900 content checkpoint host-move row (since TBD until the merge slot), +2 the #7897 private-hold sweep row (since TBD until the merge slot), +2 the #7880 ingest_capture and company-brain private-hold row (since TBD until the merge slot), +5 the frozen-source wave comment and four rows (#7868, #7850, #7869/#7870, #7871), +2 the #7848 visibility_noncanonical hold row (since TBD until the merge slot), +2 the #7846 extract_atoms session-source row (re-summed at the 0.60.481.0 merge: master 1524 + 2), +2 the #7805 synthesize session-source and #7841 visibility_not_applied rows (re-summed at the 0.60.480.0 merge: master 1522 + 2), +2 strict door planned-state row (#7705, re-summed at the 0.60.470.0 merge: master 1514 + 2), +2 Bun floor 1.4.4 row (#7644), the GBRA-95 RLS backfill row (+2), +3 rows for #7596 pass_interrupted, #7599 read-only serve and the --access=read-only ceiling, +1 G5 lane C trust_release row, +1 #7619 cli_flag_equals, +3 GBRA-207 #7630 relative-anchor and stalled-write rows, +2 the #7632 function search_path disclosure row and +2 the #7679 orphaned worktree refresh row (re-summed at the 0.60.471.0 merge: master 1516 + 2), +2 the #7814 retired v0.13.1 grandfather row, +2 the #7618 conversion withhold/progress/push row (master 1520 + 2); the behavior-change table split (#7607) retires this row; +4 GBRA-188 #7489: the wave comment and three rows (brain-first instructions, starter surface default, per-turn rule); +1 GBRA-188 plugin_turn_hook_gbra188 row; +1 GBRA-242 provider_key_rules_7959 row (#7959), +2 the GBRA-199 registration_lists_verbs row (since TBD until the merge slot); +2 GBRA-133 #7652: the #7611 pass_abandoned reader row and the lean read-only serve socket row (re-summed at the 0.60.503.0 merge: master 1555 + 2); +1 GBRA-243: the per-turn hook disclosure row (rows are data and cannot move); +4 GBRA-156 #7598 harness wave comment and rows (remote page cap, sources_not_readable refusal, sources add next step); +4 GBRA-156 #7601 search_quotes_transcript_rows comment and row; +1 GBRA-175 #7475 autopilot_restarts_serve_7475 row (re-summed at the #8012 merge: 1566 + 1); +3 #7997/#8014/#8015 rows (redaction markers, company db_only keep, ignored supabase_only scope); +1 GBRA-250 #8071 rows_behind_checkpoint_8071 row (since TBD until the merge slot); +1 GBRA-250 #8073 derived_write_through_commits_8073 row (since TBD until the merge slot); +2 GBRA-250 #8072 rows (oversize hold left unread, refresh sync budget; since TBD until the merge slot); +1 GBRA-156 #7593: private_pages_granted_sources row (re-summed at the 0.60.527.0 merge: 1574 + 1)
+src/core/behavior-change-notice.ts 1576 ratchet the BEHAVIOR_CHANGES table grows by one row per disclosed change: +4 the #7891 provenance-drift and #7917/#7918 maintenance-lowering rows and their comments (re-summed at the 0.60.495.0 merge: 1547 + 4); +2 GBRA-205 saved_facts_stems row and its comment (re-summed at the #7901 0.60.492.0 merge: 1541 + 2); +2 GBRA-205 search.query_facts_block default-on row and its approval comment (re-summed at the #7610 0.60.490.0 merge: 1539 + 2); +2 the #7900 content checkpoint host-move row (since TBD until the merge slot), +2 the #7897 private-hold sweep row (since TBD until the merge slot), +2 the #7880 ingest_capture and company-brain private-hold row (since TBD until the merge slot), +5 the frozen-source wave comment and four rows (#7868, #7850, #7869/#7870, #7871), +2 the #7848 visibility_noncanonical hold row (since TBD until the merge slot), +2 the #7846 extract_atoms session-source row (re-summed at the 0.60.481.0 merge: master 1524 + 2), +2 the #7805 synthesize session-source and #7841 visibility_not_applied rows (re-summed at the 0.60.480.0 merge: master 1522 + 2), +2 strict door planned-state row (#7705, re-summed at the 0.60.470.0 merge: master 1514 + 2), +2 Bun floor 1.4.4 row (#7644), the GBRA-95 RLS backfill row (+2), +3 rows for #7596 pass_interrupted, #7599 read-only serve and the --access=read-only ceiling, +1 G5 lane C trust_release row, +1 #7619 cli_flag_equals, +3 GBRA-207 #7630 relative-anchor and stalled-write rows, +2 the #7632 function search_path disclosure row and +2 the #7679 orphaned worktree refresh row (re-summed at the 0.60.471.0 merge: master 1516 + 2), +2 the #7814 retired v0.13.1 grandfather row, +2 the #7618 conversion withhold/progress/push row (master 1520 + 2); the behavior-change table split (#7607) retires this row; +4 GBRA-188 #7489: the wave comment and three rows (brain-first instructions, starter surface default, per-turn rule); +1 GBRA-188 plugin_turn_hook_gbra188 row; +1 GBRA-242 provider_key_rules_7959 row (#7959), +2 the GBRA-199 registration_lists_verbs row (since TBD until the merge slot); +2 GBRA-133 #7652: the #7611 pass_abandoned reader row and the lean read-only serve socket row (re-summed at the 0.60.503.0 merge: master 1555 + 2); +1 GBRA-243: the per-turn hook disclosure row (rows are data and cannot move); +4 GBRA-156 #7598 harness wave comment and rows (remote page cap, sources_not_readable refusal, sources add next step); +4 GBRA-156 #7601 search_quotes_transcript_rows comment and row; +1 GBRA-175 #7475 autopilot_restarts_serve_7475 row (re-summed at the #8012 merge: 1566 + 1); +3 #7997/#8014/#8015 rows (redaction markers, company db_only keep, ignored supabase_only scope); +1 GBRA-250 #8071 rows_behind_checkpoint_8071 row (since TBD until the merge slot); +1 GBRA-250 #8073 derived_write_through_commits_8073 row (since TBD until the merge slot); +2 GBRA-250 #8072 rows (oversize hold left unread, refresh sync budget; since TBD until the merge slot); +1 GBRA-156 #7593: private_pages_granted_sources row (re-summed at the 0.60.527.0 merge: 1574 + 1); +1 #7542 grade_takes_auto_resolve_7542 row (since TBD until the merge slot)
diff --git a/src/core/behavior-change-notice.ts b/src/core/behavior-change-notice.ts
index d2bcaa71a8..a8feb69337 100644
--- a/src/core/behavior-change-notice.ts
+++ b/src/core/behavior-change-notice.ts
@@ -1376,6 +1376,7 @@ export const BEHAVIOR_CHANGES: ReadonlyArray<{ since: string; text: ChangeText;
{ since: '0.60.525.0', id: 'rows_behind_checkpoint_8071', text: 'New doctor check `sync_rows_behind_checkpoint` and explicit-only repair kind `gbrain repair rows-behind --source <id>` (#8071): on each managed source\'s owner host, doctor compares every live Markdown page with its file read from Git at the sync checkpoint (`sources.last_commit`) and warns about rows that hold an older version with no hold, which no later sync re-imports because the import record names the current file. The repair previews each row with its path, checkpoint blob and action and writes nothing; `--apply --expect <hash>` re-imports the committed file through the managed import (no file is written), or opens the hold sync would have opened when that import is refused or the file is over the read bound. Rows with no import record join only with `--include-ambiguous`. Bounded by `GBRAIN_DOCTOR_ROWS_BEHIND_TIMEOUT_MS` (default 10 s); not applicable on repo-less brains and off the owner host. It never runs on upgrade or automatically.' },
{ since: '0.60.525.0', id: 'derived_write_through_commits_8073', text: 'Files the dream cycle writes into a source that is a Git checkout are now committed: atom and concept files (with `cycle.extract_atoms.write_through` or `cycle.synthesize_concepts.write_through` on) and the reverse-written synthesis, patterns and cycle-summary pages and their removals. Each batch (an item\'s atoms plus the files of the atoms it retired, the backfill, one concept, or one phase\'s reverse-written pages) is one local commit naming only those files, made through the checkout\'s commit lock (a hardened checkout\'s post-commit hook pushes it; a checkout with a canonical owner marker gets a named-paths-only commit). They used to stay untracked or modified, which made the scheduled sync skip every run. A commit the checkout refuses rolls back the files it wrote and reports `write_through_failed` with a warn status; atoms and concepts are written again on the next run. Each written file is also recorded in the pending write-through ledger, so files a crash left uncommitted go into the next commit gbrain makes in that checkout. Files left uncommitted by earlier versions are not touched; commit them with `gbrain git commit-push -m <msg> -- <paths>`.' },
{ since: '0.60.525.0', id: 'oversize_hold_unread_8072', text: 'A Markdown file over 24 MiB that sync had to read whole to refuse (segmented storage on, held `file_too_large`, for example for a facts fence) is no longer read again by every sync: it stays held, unread, until it changes, gbrain is upgraded, or `gbrain sources retry-held <source>` schedules it. After changing a setting the hold message names, run `gbrain sources retry-held <source>`. A file held from its size alone still re-checks on every sync.' },
+ { since: 'TBD', id: 'grade_takes_auto_resolve_7542', text: '`gbrain config set cycle.grade_takes.auto_resolve.enabled true` now does what it documents (#7542): the dream cycle\'s `grade_takes` phase applies a verdict with confidence 0.95 or higher (3/3 at 0.85 or higher on the ensemble path) to the take. Before, the key was ignored and every verdict stayed review-only. Unset or false is unchanged: verdicts wait for review in `gbrain takes grades`.' },
{ since: '0.60.525.0', id: 'refresh_sync_budget_8072', text: 'The member syncs of one `gbrain sources refresh` run stop starting work after `sources.refresh_sync_budget_ms` (default 5 minutes; `GBRAIN_REFRESH_SYNC_BUDGET_MS`). Each member gets an equal share of what is left. A run past it reports `sync_deferred` with the members it left `deferred` and still completes the refresh, so writes to the checkout are admitted again and the next `gbrain sources refresh <source>` continues them; a member that committed nothing in its share is reported `refresh_sync_timeout` in `sync_blocked`. A stalled sync no longer holds the refresh lock across scheduled runs or starves the other members.' },
];
diff --git a/src/core/config-runtime-keys.ts b/src/core/config-runtime-keys.ts
index 8d5f12ffd2..5f73774c63 100644
--- a/src/core/config-runtime-keys.ts
+++ b/src/core/config-runtime-keys.ts
@@ -11,6 +11,7 @@ export const RUNTIME_READER_CONFIG_KEYS: readonly string[] = [
'embed.content_drift.pass_interval_hours', // content-drift-sweep.ts: hours between completed content-drift passes, default 24 (0 = every run)
'facts.absorb_warn_threshold', // doctor facts_extraction_health absorb-refusal warn threshold, default 10 per 24 h
'think.trajectory_enabled', // think/index.ts: trajectory substrate on temporal intents, default on
+ 'cycle.grade_takes.auto_resolve.enabled', // cycle/grade-takes.ts: apply verdicts at or above the 0.95 confidence threshold, default off (#7542)
'embedding_image_ocr_max_images', 'embedding_image_ocr_max_usd', // import-file.ts image-OCR per-run caps, default 200 images / $1
'agent.search_snippet_chars', // ops/search.ts subagent snippet cap, default 300 (0 = full text)
'skillopt.allowed_skills', // JSON array of skills remote callers may optimize (ops/skillopt.ts, shared-skills/optimizer.ts); default deny-all
diff --git a/src/core/cycle/grade-takes.ts b/src/core/cycle/grade-takes.ts
index 443ca746c1..847badc38b 100644
--- a/src/core/cycle/grade-takes.ts
+++ b/src/core/cycle/grade-takes.ts
@@ -51,6 +51,7 @@ import { parseTakesFence } from '../takes-fence.ts';
import { submitPageMutation } from '../persistence/page-mutations.ts';
import { maintenanceTransaction } from '../persistence/attribution.ts';
import { utcDate } from './cycle-date.ts';
+import { isConfigTruthy } from '../config.ts';
/**
* Bump when the judge prompt or the JSON output shape changes. Old verdicts
@@ -206,7 +207,8 @@ export interface GradeTakesOpts extends BasePhaseOpts {
/** Judge model id; defaults to the configured chat model. */
model?: string;
/**
- * Auto-resolve verdicts above the confidence threshold. D17 default: false.
+ * Auto-resolve verdicts above the confidence threshold. Unset: the
+ * `cycle.grade_takes.auto_resolve.enabled` config key (D17 default: false).
* When false, every verdict lands in take_grade_cache with applied=false
* (review-queue posture). When true, verdicts with confidence >= the
* configured threshold get applied via engine.resolveTake.
@@ -571,7 +573,8 @@ class GradeTakesPhase extends BaseCyclePhase {
const promptVersion = opts.promptVersion ?? GRADE_TAKES_PROMPT_VERSION;
const minAgeMonths = opts.minAgeMonths ?? 6;
const takeLimit = opts.takeLimit ?? 50;
- const autoResolve = opts.autoResolve ?? false; // D17 default OFF
+ const autoResolve = opts.autoResolve // D17 default OFF; an unreadable key stays off
+ ?? isConfigTruthy(await Promise.resolve(engine.getConfig?.('cycle.grade_takes.auto_resolve.enabled')).catch(() => null));
const autoResolveThreshold = opts.autoResolveThreshold ?? GRADE_TAKES_AUTO_RESOLVE_THRESHOLD;
const resolvedByLabel = opts.resolvedByLabel ?? 'gbrain:grade_takes';
// One resolved string drives the judge call, the verdict-cache key, and
diff --git a/test/grade-takes-auto-resolve-config.test.ts b/test/grade-takes-auto-resolve-config.test.ts
new file mode 100644
index 0000000000..5526e94ed5
--- /dev/null
+++ b/test/grade-takes-auto-resolve-config.test.ts
@@ -0,0 +1,90 @@
+/**
+ * #7542: `cycle.grade_takes.auto_resolve.enabled` is the operator opt-in the
+ * grade_takes phase documents (src/core/cycle/grade-takes.ts,
+ * skills/conventions/calibration.md).
+ *
+ * Protects: with the key on, the scheduled phase applies a verdict at or above
+ * the 0.95 confidence threshold to the take; unset (the default) or off, every
+ * verdict stays review-only; the threshold is unchanged.
+ * Fails when: the phase or the cycle ignores the key, so the documented opt-in
+ * never resolves a take.
+ * Why new: grade-takes tests pass `autoResolve` directly, so nothing ran the
+ * config path the cycle uses.
+ */
+import { afterAll, beforeAll, beforeEach, describe, expect, test } from 'bun:test';
+import { PGLiteEngine } from '../src/core/pglite-engine.ts';
+import type { OperationContext } from '../src/core/operations.ts';
+import { runCycle } from '../src/core/cycle.ts';
+import { runPhaseGradeTakes, type EvidenceRetrieverFn, type JudgeFn } from '../src/core/cycle/grade-takes.ts';
+
+const KEY = 'cycle.grade_takes.auto_resolve.enabled';
+let engine: PGLiteEngine;
+let n = 0;
+
+beforeAll(async () => {
+ engine = new PGLiteEngine();
+ await engine.connect({});
+ await engine.initSchema();
+}, 120_000);
+afterAll(async () => { await engine.disconnect(); });
+beforeEach(async () => {
+ await engine.executeRaw('DELETE FROM take_grade_cache');
+ await engine.executeRaw('DELETE FROM takes');
+ await engine.executeRaw('DELETE FROM config WHERE key = $1', [KEY]);
+});
+
+const seedTake = async () => {
+ const page = await engine.putPage(`notes/auto-resolve-${++n}`, { type: 'note', title: 'Auto resolve', compiled_truth: 'Seed page.', timeline: '' });
+ await engine.addTakesBatch([{ page_id: page.id, row_num: 1, claim: 'acme-example ships by 2020', kind: 'bet' as const, holder: 'alice-example', weight: 0.6, since_date: '2019-01-01' }]);
+};
+const ctx = (): OperationContext => ({ engine, config: {} as never, logger: { info() {}, warn() {}, error() {} } as never, dryRun: false, remote: false, sourceId: 'default' });
+const grade = async (confidence: number) => {
+ const judge: JudgeFn = async () => ({ verdict: 'correct', confidence, reasoning: 'stub' });
+ const evidenceRetriever: EvidenceRetrieverFn = async () => 'evidence';
+ const result = await runPhaseGradeTakes(ctx(), { judge, evidenceRetriever, model: 'anthropic:claude-sonnet-4-6' });
+ const [take] = await engine.executeRaw<{ resolved_quality: string | null }>('SELECT resolved_quality FROM takes');
+ return { details: result.details as Record<string, unknown>, quality: take!.resolved_quality };
+};
+
+describe('grade_takes reads cycle.grade_takes.auto_resolve.enabled (#7542)', () => {
+ test('unset: the verdict is review-only and the take stays unresolved', async () => {
+ await seedTake();
+ const { details, quality } = await grade(0.99);
+ expect(details.auto_resolve).toBe(false);
+ expect(details.auto_applied).toBe(0);
+ expect(quality).toBeNull();
+ });
+
+ test('false: the verdict is review-only', async () => {
+ await engine.setConfig(KEY, 'false');
+ await seedTake();
+ const { details, quality } = await grade(0.99);
+ expect(details.auto_applied).toBe(0);
+ expect(quality).toBeNull();
+ });
+
+ test('true: a verdict at or above 0.95 resolves the take', async () => {
+ await engine.setConfig(KEY, 'true');
+ await seedTake();
+ const { details, quality } = await grade(0.97);
+ expect(details.auto_resolve).toBe(true);
+ expect(details.auto_resolve_threshold).toBe(0.95);
+ expect(details.auto_applied).toBe(1);
+ expect(quality).toBe('correct');
+ });
+
+ test('true: a verdict below 0.95 stays review-only', async () => {
+ await engine.setConfig(KEY, 'true');
+ await seedTake();
+ const { details, quality } = await grade(0.9);
+ expect(details.auto_applied).toBe(0);
+ expect(quality).toBeNull();
+ });
+
+ test('the scheduled cycle carries the key into the phase', async () => {
+ const phase = async () => (await runCycle(engine, { brainDir: null, phases: ['grade_takes'] } as never)).phases.find(p => p.phase === 'grade_takes')!;
+ expect((await phase()).details).toMatchObject({ auto_resolve: false });
+ await engine.setConfig(KEY, 'true');
+ expect((await phase()).details).toMatchObject({ auto_resolve: true, auto_resolve_threshold: 0.95 });
+ });
+});