Garry's Opinionated OpenClaw/Hermes Agent Brain
Key files: Core Decide (System One)
Subsystem index. Read only the entries relevant to your change.
Current behavior and load-bearing invariants; history belongs in Git and CHANGELOG.
The capability contract (API, providers, egress, extension points) is docs/architecture/decide.md.
src/core/ai/decide/types.ts— The request/answer contract:DECIDE_SLOTS,DecideMode(off/on, advancedshadow),EvidenceItem(text + class + provenance), the question union (noul,choicewithoptions,scorewithlevels), answers mirroring the wire,DecideRequest/DecideResult,DecideErrorwith a catalogued reason, andthresholdValue(noul p, the chosen label's probability, normalized score).src/core/ai/decide/outcomes.ts— The ONE vocabulary: per-slot receipt outcomes (pluserror/skippedeverywhere),SKIP_REASONS,REFUSAL_CATALOG(problem, cause, exact fix, docs anchor) and plain slot names.recordReceiptsthrows on an unknown outcome; the database has no CHECK constraint.test/decide/docs-sync.test.tspins the table indocs/architecture/decide.md.src/core/ai/decide/slots.ts—SLOT_SPECS: lane, question kind, harmful direction (needs the action-precision gate), thresholded, call sites, egress classes, defaultmin_keep, shadow sample, what-if reproducibility, question version, fail direction andwired(the delivery gate: unwired slots are refused withslot_unavailable).src/core/ai/decide/config.ts— Everydecide.*key with its validator (validateDecideConfigValue, called bygbrain config set), andreadDecideConfig(snapshot)(invalid stored values fall back to defaults; all default off).pickDecideConfiggives search the decide subset of the one config snapshot so all-off does no work.enableDecideEvalOverrideis the only door forGBRAIN_DECIDE_SLOTS.isValidProvideracceptsnone,llm:<provider:model>and anytypesafe:<id>of[a-z0-9._@/-]starting alphanumeric (#5980: gateway-published ids such astypesafe:oc/jev-1.13-free; no whitespace, no second colon); the snapshot'spricing.overridesis parsed intoDecideConfig.pricingOverridesso the runner can price an id gbrain ships no tariff for.src/core/ai/decide/pack.ts— Planner (64k per request, 32k state + longest question, 2x estimate with a digit floor, split before send, never truncate, rank-then-id order),packShape, andrunBatches(≤16 in flight, one deadline, a 429 retry only whenretry-afterfits, background lanes drop to one worker after a 429, first failure stops queueing while started requests settle).src/core/ai/decide/providers/typesafe.ts— Pure System One wire adapter:buildTypeSafeRequest,parseTypeSafeResponse(every requested id, numeric and in range, and a resolvedmodel, or the batch failsmalformed_response),classifyTypeSafeHttpError(status only;Unknown model→pinned_model_unavailable).src/core/ai/decide/providers/llm-structured.ts—llm:<provider:model>: prompt + JSON schema throughchat(), same parser,llmCapability(structuredonly for openai-compatible recipes that declare structured outputs), model identity from the provider snapshot or an endpoint fingerprint.src/core/ai/decide/index.ts—runDecide(req, ctx)(alsogateway.decide): provider selection, egress gate, egress fallback as its own sub-decision, daily cap and remote share before sending,BudgetTrackerreserve/record (kinddecide, orrerankfor S1 on), bounded batches, mixed-model rejection, onedecide_spendrow per request (failed and timed-out requests charged their estimate). [R18]: before the daily-cap check, an id whose price resolves to nothing (usageCostUsd(..., cfg.pricingOverrides)null: no shipped tariff, nopricing.overridesentry) is refusedunpriced_modelwith nothing sent and no spend row, so the ledger never records $0 for an unknown cost and no outerBudgetTrackeris needed to protect the daily and remote-share budgets.provider_base_urls.typesafe(gatewaybase_urls) is the request origin,/systemoneappended. Pinned bytest/decide/provider-ids-5980.test.ts.src/core/ai/decide/egress.ts—checkEgress: consent per data class (or the reranker selection for S1 on), denied sources on every provider, private pages by one batchedprivatePagesFilterFragmentquery (with the #5525 derived-origin rule), facts by visibility (default private), conversation text private, missing provenance refused.src/core/ai/decide/policy.ts—resolveSlotPolicy: requested vs effective mode with a catalogued inactive cause, threshold precedence (override > adopted > newest local > reference), alias lookup via the last resolved model, marginmax(floor, 2*max(retest_sd, repack_sd)),min_keepprecedence, the action-precision gate andforce_on,policyFingerprint;driftReasonafter a response;readinessstrings.src/core/ai/decide/protection.ts— The canonical protection predicate for slots that remove or demote results (alias hit, exact lookup, exact title match, relational pin). Autocut keeps its own narrower preserve predicate so all-off output is unchanged.src/core/ai/decide/evidence.ts— S3's question and its one reducer (reduceEvidence, shared by production, qualify and what-if): protected and unjudged stay, below-threshold prune, the margin band holds, best-ranked pruned items return untilmin_keep; never reorders.whatIfEvidencereplays receipts.src/core/ai/decide/rerank-adapter.ts— S1 transport forsearch.reranker.model typesafe:*(#5178 contract on the decide core): four-level score questions, normalized scores, stable ties, topN after all batches, status-onlyRerankErrors, reported usage settled even when validation fails, mixed resolved models fail the call,onMetareports the resolved model and rubric semantics.src/core/ai/decide/store.ts—executeRawstorage (no engine method): buffered receipts and spend rows with a background-work drainer (500 ms exit bound),decide_state(internal keys: receipt salt, S1 ownership),receiptSalt(insert-if-absent) +hmacRef, the 60 s cached daily spend, calibrations CRUD, aggregate receipt reads, retention pruning for the purge phase.src/core/ai/decide/receipts.ts—buildReceiptRows/writeReceipts: one row per question with HMAC hashes only, the thresholded value, outcome, reason, policy fingerprint, calibration ref and replay fields; fire-and-forget. An error row with noresulttakespartial(DecideError.partial: the answers settled batches returned before the decision failed,model_resolvednull when they disagree), sooutcome: errorwithanswer_valueset means returned but never applied; replay and calibration read only acted outcomes.src/core/ai/decide/runtime.ts— Per-query decide budget (createQueryBudget,stageDeadlineMs), shadow sampling, and detached shadow work under its ownBudgetTrackerwith a bounded queue and a drainer.src/core/ai/decide/recall-needed.ts— S6 know-to-ask: the question (state = the user prompt, head-capped at 6,000 characters, plus the previous turn, tail-capped at 2,000, both conversation class),recallReflex(reflex fired; alias or exact-title identity hit) and the ONE reducerreduceRecallNeeded(fire only when the reflex was silent and p ≥ threshold; suppress only belowsuppress_belowminus the margin and never over an identity hit; the band belowsuppress_belowholds), plus the dataset adapter (harmful action = suppress) and the lazyknow-to-askbuilder registration.suppress_belowjoins the policy fingerprint.src/core/ai/decide/unpacked.ts—runDecideUnpacked: one logical decision whose questions each go in their own request (S7 windows, S8 claim units), one decision id and deadline, a process-wide background-lane semaphore atdecide.background_concurrency(one per decision after a 429), per-questionfailedreasons instead of throwing (so slots can tell complete from partial coverage;stopOnFailurestops early), mixed resolved models fail every answer. Calibrate uses it for adapters that declareunpacked.src/core/ai/decide/calibrate.ts,dataset.ts,reference-calibrations.ts(REFERENCE_CALIBRATIONS,recommendedSlots, andnewerReference(policy, refs): thedecide statushintnewer_reference, #6497: the newest row matching the policy's slot, call site, provider and resolved model that differs from the calibration in use, else null;gbrain decide calibrations adopt ref:<id>stores a matching shipped id verbatim indecide.slots.<slot>.calibration;test/decide/newer-ref-hint-6497.serial.test.ts),schema.ts— Threshold search, reliability/ECE, retest/repack sd, Wilson bound,requiredN, family-levelqualifyActions; the dataset JSONL schema, frozen family split andsplit_hash, per-slot adapters (choice slots addpositive(item, answer)for the calibration label; items withstate.call_sitebelong to that call site only, filtered by--call-site) and--frombuilders (S3:longmemeval,jsonl; S2/S4/S5 in their slot modules; S6:know-to-ask, registered fromrecall-needed.ts; S7/S8/S9:cat35,grounding-labels,facts-fixtures); adapters may override the thresholded value (calibrationValue) and calibrate extra knobs into the row's notes (calibrateExtra; S9's proposal floor on supersede labels, read back bypolicy.tsnotesProposalFloorand the sweep); shipped reference rows (S7 triage and S9 conflict for jev-1.13.0, the only slots with a recorded win, docs/eval/system-one/README.md); the canonical DDL used by migrations 184-186 and the fresh-install fragment.src/core/search/decide-stage.ts— The search side of S1/S3 (and the S3-shaped request S5 rides, with or without S3 on):resolveDecideSearchContext(undefined when every slot is off),applyEvidenceGate(insidesizeReturnPooland the keyword-only path),recordRerankReceipts,startRerankShadow(Jev beside a non-Jev reranker, rank agreement),decideKnobsPart(search cache key), the S5 co-pack registry and the meta block (meta.decide).resolveAndLaunchDecideresolves the context and launches S2 at hybridSearch entry; S4 on thequeryop starts insideapplyEvidenceGate, concurrent with the S3/S5 request.calibrationState(60 s cached calibrations and last resolved models) is shared with think and S6.src/core/ai/decide/intent.ts— S2: the search (QueryIntent) and think (temporal | knowledge_update | other) choice questions andreduceIntent(override only above threshold, on a known label that differs from the regex label and does not tie it; regex is the default and tie source), the intent dataset adapter (items carrystate.call_site, never sent) and thelongmemeval(question_type) andbrainbench(relational) builders.src/core/ai/decide/answerable.ts— S4: one probability question over the top-k evidence (answerableK: k = min(10, n), shrunk to fit 32k, 0 = fail open),reduceAnswerable(pass, incomplete coverage, margin_hold, deterministic identity/strong-grade signal → pass, else abstain), the dataset adapter/harmful-action reducer and thelongmemevalabstention builder.src/core/ai/decide/injection.ts— S5: the per-candidate question,reduceInjection(flag at threshold, never protected or unjudged) anddemoteFlagged(flagged below clean items of the same evidence class, topcutand the rest reordered separately, nothing dropped), the co-packed dataset adapter and theinjection-fixturesbuilder (#5178 known cases intest/fixtures/decide/injection-cases.jsonl).src/core/search/decide-retrieval.ts— Search-path wiring for S2 (launchSearchIntent/applySearchIntent: wait bounddecide.slots.intent.wait_ms, late answers keep the regex label and land aslatereceipts;askIntent/settleIntentshared with think), S4 on the query op (startQueryAnswerability,meta.answerability), the S5 co-pack handler,candidateItem, andrerankEgressDenied(the Jev reranker skips a query with a candidate fromdecide.egress.deny_sources). Imports decide-stage for types only.src/core/think/decide.ts— Think wiring:startThinkDecide(undefined when S2 and S4 are off) launches the S2 think and search questions before gather;trajectoryIntentawaits the think answer at mostwait_msafter gather;answerabilityasks S4 over final pages and sendable takes (private takes and trajectory make coverage incomplete) and returns an abstention only onabstain;thinkAbstainResultlists the nearest pages and skips synthesis.src/core/cycle/decide-slot.ts—resolveCycleDecideSlot(engine, 'triage' | 'grounding'): undefined when the slot is off (all-off cycles do no decide work); otherwise the slot policy (unpacked pack shape, calibrations, last resolved models, key presence).src/core/cycle/triage-decide.ts— S7:splitTurnWindows(whole turns from speaker anchors,[role]lines or role headings, else paragraphs; ~1,500 chars; a turn over 24,000 chars splits at paragraphs, marked), onenoulper window throughrunDecideUnpacked, transcript score = max window p,reduceTriage(pass / margin_hold / reject; null = incomplete) shared with qualify andwhatIfTriage. Complete pass/reject verdicts are cached with modeldecide:<provider>@<resolved>#<fingerprint8>(the S7-only cache identity;TRIAGE_VERSIONunchanged), segments = top windows' first 300 chars cut at a turn boundary, entities fromextractEntities, content type from one extrachoicerequest; margin_hold and every incomplete decision return no verdict sorunTriagePassruns today's LLM triage (no judge → pass). #7307: before any request, a scored row at the currentTRIAGE_VERSION(and not older thanstaleBefore) from either judge (the decide identity, orllmModel, today's triage model thatrunTriagePasspasses) is a cache hit; a margin hold writes a marker row (score NULL, content_typedecide_margin_hold, never over an LLM backoff marker) that keeps the transcript off the provider forDECIDE_MARGIN_HOLD_TTL_MS(24 h), and an active LLM backoff also holds it (both counted instats.held). Shadow/inactive: receipts only, observed only for transcripts today's triage judged this pass (never a cache hit).estimateTriageDecideUsdprices retriage.src/core/cycle/grounding-decide.ts— S8:GroundingPassfor both verify call sites; per unit up to three source windows (selectSourceWindows: normalized 4-gram substring hits, best keyword overlap, nearest embedding when an embedding provider is configured), coverage weak when no window reaches the 0.25 keyword floor; onenoulper unit;reduceGrounding(pass / margin_hold / insufficient_context on weak coverage / quarantine) shared with qualify andwhatIfGrounding(receiptprotected= weak coverage). Only quarantines when on; timeout (30 s per page, 10 min per phase), 429, 5xx, budget, egress and drift keep the mechanical result. Coverage is judged over the distinct content words of the selected windows together (a substring window still counts), against the same 25% floor.src/core/cycle/decide-datasets.ts— S7/S8 dataset adapters (unpacked; S7 aggregates windows by max; harmful actions = reject / quarantine) and builderscat35(gold/*.jsonexpected_triage+ transcripts-txt) andgrounding-labels(JSONL claim units; stores the production window selection and weak-coverage protection).src/commands/decide/eval-lane.ts+src/commands/decide/judge-agreement.ts+src/core/ai/decide/judge-agreement.ts— the eval-only judge harness:gbrain decide judge-agreement --suite <longmemeval|grounding> --input <file> [--limit N] [--provider <id>] [--threshold 0.5] [--dry-run] [--json] [--out FILE](registered byloadDecideLanes();src/cli/commands/decide.tsdispatches it without opening a brain). One Jev probability question per item on the background lane (LongMemEval--judgerows: hypothesis vs question and reference answer, judge errors/budget skips/unjudged skipped; grounding labels: S8's production question, transcripts through the production window selection), consent implied as for calibrate, no runtime substitution. The pure module holds the 2x2 confusion matrix, raw agreement, Cohen's kappa with the large-sample 95% CI (null when undefined), per-slice results and nearest-rank percentiles. Reference labels are LLM verdicts (label_sourcecounted in the report). Tests:test/decide/judge-agreement.test.ts,test/decide/judge-agreement-cli.serial.test.ts.src/eval/decide-eval-flags.ts— the--decide <slot>=<off|on|shadow>/--decide-provider/--decide-calibration <file|ref:id>/--decide-threshold <slot>=<x>/--decide-force-on <slot>/--decide-dataset <jsonl>plumbing shared byeval longmemeval,eval brainbenchandeval retrieval-quality:prepareDecideEvalmerges flags over an inheritedGBRAIN_DECIDE_SLOTS(flags win), sets it and callsenableDecideEvalOverride(), imports calibrations (decide calibrate --json/calibrations list --jsonoutput orREFERENCE_CALIBRATIONSids) and refuses asplit_hashdiffering from the frozen dataset orcalibrate_onlyfalse (DecideEvalRefusal,split_mismatch); null when no slot is on or shadow (all-off byte-identical).configureDecideBrainwrites provider, consent,decide.egress.private allow, awaited shadow, thresholds,force_oninto throwaway benchmark brains and inserts/qualifies/adopts the calibrations;operatorBrainRefusalguards connected brains (never written);decideRowReceipt/summarizeDecideReceiptsbuild per-row receipts fromDecideSlotMetaplus the brain'sdecide_spenddelta (S2late, S1 rerank tokens). Tests:test/decide/eval-flags.serial.test.ts,test/eval-longmemeval-decide.serial.test.ts,test/eval-brainbench-decide.serial.test.ts,test/eval-retrieval-quality-decide.serial.test.ts.src/commands/decide/writepath.ts— write-path lane registrations (what-if reducers for triage and grounding, dataset adapters; S9 subcommands), loaded byloadDecideLanes()insrc/commands/decide.tsbefore any subcommand or help.src/core/ai/decide/conflict.ts— S9's question (duplicate | supersede | independent, state = the new fact, one choice per candidate), the ONE pair reducerreduceConflict(chosen duplicate at or above threshold → duplicate; else P(supersede) at or abovedecide.slots.conflict.proposal_floor→ proposal; else independent), candidate eligibility (thedecideSingleFactguards, self-exclusion, cosine ≥ 0.80), unordered pair keys, proposal direction, chronology (isOlderFact: valid_from, then created_at, then id;datedConflictState/datedConflictQuestionaddfact_time/candidate_timeevidence for a reordered pair) andsweepWindow(stops at the first fact younger than 60 s).src/core/ai/decide/sweep.ts(+proposals-store.ts) —runConflictSweep: per-source watermark indecide_state(first run records the max fact id unlesssince), 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 oneexecuteRawquery, 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, pendingdecide_proposalsrows inonmode only; never supersedes.conflictSweepTailis theextract_factsphase tail: undefined when the slot is off.proposals-store.tsholds the watermark, deferred, dedup and proposal SQL, andenqueueRelinked(engine, sourceId, factIds)(thegbrain facts relinkhandoff: attempts 0, due now, reasonrelinked,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. Whendecide.slots.conflict.review_withdrawis on, each swept fact re-queues up to two withdrawn claims it may restate (requeueWithdrawnAnchorsNear), andconflictSweepTailrunsrunReviewLanesafter the sweep (output keyreview).src/core/ai/decide/review-lane.ts(+src/core/facts/proposal-review.ts) — the ambiguous-band review lane on theconflictslot's provider, egress and spend. Kindswithdraw(active facts close to a withdrawn fact; conflict question unchanged,duplicate= same claim),duplicate_pageandduplicate_entity(page pairs other subsystems queue withenqueueReviewCandidate;same | differentquestion, candidates class). Each kind has a switch (decide.slots.conflict.review_<kind>, off by default), a call site (review_<kind>, listed inSLOT_SPECS.conflict.callSites) and its own calibration;reviewGatelets 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 indecide_review_queue(written in the event's own transaction:recordFactWithdrawalfor withdraws; no timestamp cursor), at mostREVIEW_BUDGET_PER_RUN(50) per kind per run, with attempt/backoff deferral and permanent-failure clearing. Pair subjectsreview:<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 unlessdecide.egress.privateisallow. Proposals go todecide_review_proposals(unique per kind/source/a/b/subject; separate table so older binaries never read them).proposalReviewRatesfeedsgbrain 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 anacceptingrow 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 theforgetoperation with a proposal-derived request id andsemantic_review: false(finishing an interrupted accept when the fact already carries the(review r<id>)marker); a changed candidate goesstale; undo refuses withwithdrawal_is_durableand a fix; duplicate kinds run the (idempotent) handler registered withregisterReviewAcceptHandler, elseaccepted_no_action. CLI incommands/decide/proposals.ts:r<id>ids,--yesrequired to accept a withdraw,--all-fromexcludes withdraws unless--include-withdrawals. Pinned bytest/decide/review-withdraw.serial.test.tsandtest/decide/review-duplicate-kinds.serial.test.ts.src/core/ai/decide/datasets-conflict.ts—registerConflictDatasets()(called bysrc/commands/decide/writepath.ts): the conflict dataset adapter (production request shape, no harmful-action reducer) and thefacts-fixturesbuilder (labelled fact-pair JSONL; labeltrueexactly forduplicate, the calibrated threshold). Calibration thresholds the reducer-consistentduplicateValue(P(chosen) only when duplicate is chosen) andcalibrateProposalFloorpicks the F1-best P(supersede) floor on the choice label kept inslice(≥ 10 supersede labels), stored in the row's notes. Tests:test/decide/conflict-calibration.test.ts.src/core/facts/proposal-supersede.ts— S9 accept/undo as a CHECKED supersede: old factexpired_at/valid_until/superseded_by, the struck## Factsrow (file and DB body) and the proposal status apply as one unit with before/after state; a failed fence write leaves the proposal pending. Unmanaged brains: source-filesystem + page lock, one transaction that publishes the file last and restores it on a failed commit. Managed brains: coordinator mutationdecide_proposal(dispatched bypersistence/service.ts). Stale pairs are markedstale; undo refuses when either fact or the fence row changed. Tests:test/decide/conflict-proposals.serial.test.ts,conflict-proposals-managed.test.ts. #8060: the manageddecide_proposalpreparer reads the fact page throughwholeBodySnapshot, so a segmented page within PAGE_MAX_BYTES is accepted or undone like an inline one (test/trust-supersede-segmented-8060.test.ts).src/commands/decide/proposals.ts(registered insrc/commands/decide/writepath.ts) —gbrain decide sweep --slot conflict [--since] [--source] [--json]andgbrain decide proposals list|accept|reject|undo(--all-from <sweep id>for accept/reject,--jsoneverywhere); list shows both facts' text locally.src/core/context/recall-needed.ts— S6 at the turn-context call site:startRecallNeededruns concurrently with the reflex arms (config, policy, one decide call under an absolute 250 ms deadline from turn start; null when off, so all-off does one config read and nothing else);applyRecallNeededruns after the reflex block is rendered and waits only until that deadline; on mode fires one keyword-onlyhybridSearch(limit 3, decide off, world-only safe chunks, the hook's source) only with ≥150 ms ofTURN_CONTEXT_SERVER_BUDGET_MSleft and must finish 40 ms before it, adding hits asrecall-arm pointers, or suppresses the reflex window (hot facts stay). Every failure leaves the reflex result unchanged; receipts hash the session ref, never prompt text.GBRAIN_DEBUG=1prints the per-turn explain line. Tests:test/decide/recall-needed.test.ts,test/decide/turn-context-s6.serial.test.ts.src/eval/brainbench/know-to-ask-dataset.ts—gbrain decide dataset --slot recall_needed --from know-to-ask <dir>(fixtures/+gold/): one item per gold user turn, labelshould_retrieve, the reflex state replayed through the shipped path on a seeded in-memory brain (slicereflex:fired/silent,protected= identity hit), split by fixture, holdouts skipped.src/commands/decide.ts(+src/commands/decide/{calibrate,receipts,probe-query}.ts, dispatchsrc/cli/commands/decide.ts) —gbrain decidestatus/probe/enable/disable/calibrate/qualify/calibrations/dataset/receipts; status carries the conflict slot's 7-day share ofno_entityskip receipts (no_entity_7d, fromconflictNoEntityShareinstore.ts) and, when non-zero, agbrain facts relink --dry-runhint line (test/decide/status-no-entity.serial.test.ts); help and the key-only probe run without a brain;enablerefuses unless the effective mode would be the requested one, writes the pinned id and consent, and owns S1's reranker keys sodisablerestores only what it still owns;registerDecideSubcommandfor slot lanes;enable --recommendedpins the default provider on a brain with none, and calibrate/qualify send the production request (productionRequest: S3 co-packs S5's questions when injection rides the S3 request, so the recordedpack_shapeis the one sent;test/decide/evidence-copack-calibration.serial.test.ts). Tests:test/decide/cli.serial.test.ts; the operator guide's quickstart (docs/guides/system-one.md) is executed against a fixture transport bytest/decide/quickstart-doc.serial.test.ts, andtest/decide/docs-sync.test.tspins its troubleshooting anchors toREFUSAL_CATALOG.src/commands/doctor/checks/decide.ts—decide_health: key, alias, inactive slots with cause and fix, drift, alias rollouts, 24 h error rate over 5%, exhausted budget, retired pinned model,force_on. Tests:test/doctor-decide-health.test.ts.