Skip to content

v0.60.26.0 feat(decide): System One v1, Jev decision support with key-aware defaults for the measured winners (#5178) - #5797

Merged
capy-ai[bot] merged 69 commits into
masterfrom
feat/system-one-v1
Oct 1, 2026
Merged

capy-ai[bot] merged 69 commits into
masterfrom
feat/system-one-v1

Conversation

@garrytan

@garrytan garrytan commented Oct 1, 2026 •

Copy link
Copy Markdown
Owner

What ships

System One: typed decisions from TypeSafe's Jev (or any configured chat model via llm:<provider:model>) at nine slots in search, think, the hook user-prompt path, dream and the fact sweep. GBrain code owns every threshold, floor and fallback; every slot fails toward today's behavior and writes a hash-only receipt.

  • gbrain decide CLI: probe (key check, sends nothing from the brain), probe --query (today's order beside Jev's, asks first, changes nothing), enable <slot> / enable --recommended, disable <slot>|--all, status [--egress] [--json], calibrate, qualify, calibrations list|adopt|retire|restore, dataset, receipts [--what-if-threshold], sweep, proposals list|accept|reject|undo, judge-agreement (eval only).
  • Slots: rerank, intent, evidence, answerable, injection, recall_needed, triage, grounding, conflict.
  • Reference calibrations for jev-1.13.0: S7 triage (threshold 0.77, qualified lb 0.910) and S9 conflict (dup 0.52, proposal floor 0.65).
  • Jev search reranker on the decide core (search.reranker.model typesafe:jev-1.13.0); Voyage stays the default.
  • --decide* flags on gbrain eval longmemeval, brainbench, retrieval-quality.

Defaults and safety

  • No TypeSafe key: every slot off, output byte-identical to a brain without System One.
  • Key present (owner decision 2026-10-01): S7 triage and S9 conflict default on with typesafe:jev-1.13.0 and their reference calibrations; the other seven stay off. The set comes from recommendedSlots(), the same function enable --recommended uses. For those two slots the key is the egress opt-in for their own data (conversation text, fact text); nothing is written to config; pages, derived pages and deny_sources keep their rules.
  • Explicit settings win: slot mode/provider, decide.provider none, decide.egress.private deny, a consent deny, decide disable. Eval runs never use the defaults.
  • status and doctor decide_health show on (default: Jev key present) plus the opt-out.
  • Consent per data class, private-content gate, denied sources, egress fallback, $1/day soft budget with a remote share, mixed-model and drift protection, action-precision gate (0.90) for slots that can remove content.

Measured verdicts (eval half, typesafe:jev-1.13.0, no human hand labels)

Slot Verdict Headline
S7 triage win, costs more buried-signal misses 10/18 → 0/18; preset E2E 10/10 vs 3/10 synthesized, dream spend $1.50 → $2.60
S9 conflict win supersedes found 0/97 → 94/97; wrong 10 → 1
S1 rerank regression recall_all@5 94.8% (Voyage) vs 94.0/91.4/92.7% (Jev 30/50/100)
S2 intent no measurable change routing accuracy up, retrieval unchanged; wait_ms default 250
S3 evidence regression forced 0.08: recall_all@5 94.8% → 91.4%
S4 answerable regression abstention precision ≤ 34%
S6 recall_needed mixed failures 71.3% → 11.3% on reflex-miss corpus; 8.5% false fires on sealed BrainBench
S8 grounding inconclusive insufficient_n
S5 injection inconclusive 12 fixtures

Full tables, datasets, receipts and runners: docs/eval/system-one/. Total eval spend $24.95.

Migrations

v184 decision_receipts (+ decide_spend, decide_state), v185 decide_calibrations, v186 decide_proposals (+ decide_sweep_deferred). Empty tables, no backfill. Agent upgrade note: skills/migrations/v0.60.26.0.md.

Docs

docs/guides/system-one.md (operator guide, CI-checked quickstart, new "Defaults" section), docs/ai-providers/typesafe.md, docs/architecture/decide.md (contract and extension points), docs/architecture/key-files/core-decide.md, docs/designs/SYSTEM_ONE_JEV_V1.md (plan with dated owner decisions), docs/eval/system-one/.

Fixes along the way

  • Retrieval-reflex heartbeat and its doctor check honor GBRAIN_HOME.
  • The per-query decide budget starts at the first post-retrieval stage, so query expansion no longer starves reranking.

Credits

The native Jev reranker adapter, its context-aware packing and cost accounting come from #5178 by @dsandrade.

Test evidence

  • bun run verify: 66/66 checks green.
  • bun run ci:ubicloud on af1c285 (before merging master v0.60.23.0–v0.60.25.0; verify, typecheck and the 331 decide tests re-run green after): gitleaks 1, unit 2174, serial 373, slow 26, e2e 342, verify 1; 0 failed (7m13s).
  • bun run wave-security-scan origin/master..HEAD: gitleaks 0 (allowlist stripped), no admin/dist change; the 46 obfuscation hits are all the word "eval" in identifiers and prose; the only dependency change is the version stamp; new outbound hosts in src/ are *.typesafe.ai only.

Closes #5191. Supersedes #5178 (to be closed after this merges).

Open in Capy

…h wiring

Adds src/core/ai/decide/ (typed questions and answers, canonical outcome and
refusal catalogs, slot specs, config registry, 64k/32k pack planner with a
bounded deadline-aware batch runner, TypeSafe System One and llm: structured
providers, typed-provenance egress gate, slot policy with threshold
precedence, drift and policy fingerprints, receipts and spend ledger via
executeRaw with background drain, calibration math), the TypeSafe recipe,
migrations for decision_receipts/decide_spend/decide_state,
decide_calibrations and decide_proposals, and the S1 rerank and S3 evidence
stages behind all-off defaults.
…alidation, receipt retention

gbrain decide status/probe/enable/disable/calibrate/qualify/calibrations/
dataset/receipts (engine-free help and key-only probe), decide.* config
validation with the effective-mode post-set line, decide_health, receipt
pruning in the purge phase, decide/rerank meta through the query op,
module-size ceilings raised for delegation lines.
…d live tests; decide contract doc

Ports the #5178 reranker contract tests onto the decide core (credit:
dsandrade), adds unit tests for the planner, runner, parsers, policy,
calibration math and vocabulary, PGLite tests for egress, spend, receipts,
salt and the S1/S3 search stages (all-off byte-identical), the CLI and
decide_health, the opt-in keyed live test, docs/architecture/decide.md with a
docs-sync test, KEY_FILES entries, and regenerated goldens.
…es.js), Postgres E2E + goldens, providers RERANK/DECIDE columns
…, reviewed resolveAuth override, derived migration version in persistence test
…cide; upgrade replay accepts a strict-prefix fixture when branch migrations postdate it
# Conflicts:
#	src/core/cli-flag-registry.generated.ts
docs/ai-providers/typesafe.md: key setup (TYPESAFE_API_KEY, JEV_TYPESAFE_API_KEY
alias), pinned vs alias models, the #5178 reranker setup (credit dsandrade),
pricing, limits, data handling and what never leaves the machine.

docs/guides/system-one.md: operator guide with an executed quickstart, each slot
in plain words, off -> on, calibration and qualification, fail directions,
egress, status/doctor reading, receipts, budget, say-to-your-agent prompts,
troubleshooting keyed by REFUSAL_CATALOG, and shadow only under Advanced
diagnostics.

Tests: quickstart-doc.serial.test.ts runs the quickstart block against a seeded
PGLite brain with a fixture transport and asserts every documented line;
docs-sync.test.ts pins the guide's anchors and slot rows and keeps shadow out of
the main path.
- skills/migrations/v0.60.NEXT.md: agent upgrade note (placeholder name, renamed
  at ship): nothing changes until the user opts in; quickstart; refusals;
  upgrades never move an enabled slot; kill switch.
- AGENTS.md Common tasks bullet, skills/RESOLVER.md route, search-modes.md
  pointer, llms-config entries (index only, not inlined).
- Regenerated llms.txt, llms-full.txt and skills/skills.lock.json.
- core-decide.md: test path fix (cli.serial.test.ts) and the guide's tests.
…nding and know-to-ask dataset

One shared S6 reducer (fire only when the reflex was silent; suppress only
below suppress_below minus the margin and never over an alias/exact-title
hit), the state builder (prompt + previous turn, conversation class), the
dataset adapter (harmful action = suppress) and the BrainBench know-to-ask
builder that replays the shipped reflex path per gold turn. suppress_below
is read into the slot config and bound into the policy fingerprint (other
slots' fingerprints are unchanged).
…e retrieval

HybridSearchOpts.decide.keywordOnly routes to searchWithoutEmbeddings (no
embedding call) without the vector-unavailable degraded marker or warning.
calibrationState is exported so S6 shares the 60 s calibration cache.
startRecallNeeded runs concurrently with the reflex arms under an absolute
250 ms deadline; the reflex block is rendered first and S6 only replaces
its pointer/volunteer window when it finishes in time: on mode fires one
keyword-only search (limit 3, decide off, world-only safe chunks, the
hook's source) when the reflex was silent and >=150 ms of the 400 ms server
budget remain, adding recall-arm pointers, or suppresses a non-identity
window below suppress_below. Every failure leaves the reflex result
unchanged; receipts hash the session ref only; result.decide.recall_needed
and GBRAIN_DEBUG carry the explain line; status costs S6 per 1,000 turns.
Flips SLOT_SPECS.recall_needed.wired.

Golden: decide/status-keyless-all-off.json (recall_needed wired: true,
cost unit turns).
…background lane) and calibrate support for unpacked, max-aggregated adapters
docs-cli-commands flagged dream --eval-run and decide judge-agreement --suite,
which are not on this branch yet; the guide now names them as planned with a
reconcile marker. llms-full.txt regenerated against the committed README.
…h verifyDreamPage call sites, before persistence
… datasets with unpacked adapters, status cost units, dream --eval-run
…ire datasets explicitly, retarget unwired-slot tests to intent
…search path

- S2: the search intent question launches at hybridSearch entry beside the
  regex classifier and is awaited at most decide.slots.intent.wait_ms; an
  above-threshold label that differs from (and does not tie) the regex label
  replaces the QueryIntent before weights, detail and options are derived.
  Late, below-threshold, failing, drifting or egress-refused answers keep the
  regex label.
- S4 (query op): its own request over the pre-S3 top-k (k = min(10, n),
  shrunk to fit 32k), concurrent with the S3/S5 request; diagnostic only
  (meta.answerability), results never change.
- S5: co-pack handler registered with registerEvidenceCoPack; stamps
  injection_p, moves flagged results below clean results of the same
  evidence class without crossing the S3 min_keep cut, never drops content.
  Always rides the S3-shaped request (one pack_shape), also when S3 is off.
- Jev reranker with a candidate from decide.egress.deny_sources skips
  reranking for the query (fused order), reason egress_denied.
- Dataset adapters/builders: intent (longmemeval question_type, brainbench
  relational), answerable (longmemeval abstention), injection
  (injection-fixtures, #5178 known cases); calibrate filters items by
  --call-site and uses positive(item, answer) for choice slots.
- Goldens: decide status (S2/S4/S5 wired), export surface (new fields and
  the egress_denied degraded reason).
…runs S3 under call site think

- think/decide.ts (no work when S2 and S4 are off): the S2 think question
  (temporal | knowledge_update | other) replaces classifyIntent as the
  trajectory gate, regex as fallback and tie source, awaited at most wait_ms
  after gather; the S2 search question is asked once and handed to gather.
- S4: one separate call over the final gathered pages and sendable takes,
  after gather and before synthesis; abstains only on an abstain verdict
  (complete coverage, no identity hit, no strong CRAG grade without S3),
  lists the nearest pages and skips the synthesis call (ThinkResult.abstained,
  DECIDE_ABSTAINED, synthesisOk false). Private takes and trajectory make
  coverage incomplete; provider failures answer normally.
- gather passes decide { remote, callSite: 'think' } so S3/S5 run and key
  calibrations correctly inside think; a page flagged by S5 carries an
  injection_suspected line inside its untrusted wrapper.
- runThink stays within its function-size baseline (two warning branches
  folded to one line each).
…saction + coordinator mutation decide_proposal)
…, conflict dataset adapter + facts-fixtures builder, wire the slot
With the 0.05 margin floor, a 0.05 boundary could never suppress (every p
below it fell in the margin_hold band). Also export parseEvalSlots for the
eval flag plumbing.
…back

src/core/search/eval-pool-depth.ts: setEvalPoolDepth(N) (N <= 300, eval only)
raises the per-arm cap both engines clamp to and makes every arm fetch N.
Unset (production), the cap stays MAX_SEARCH_LIMIT (100) and the per-arm pool
is unchanged (test/eval-pool-depth.test.ts). Engine ceilings +1 (import).

searchVectorFallback (every vector arm empty or failed) skipped the S3
evidence gate, so decide receipts and meta vanished on embed failures; it now
gates at the same position as the fused and no-provider paths.
…ality

Shared plumbing in src/eval/decide-eval-flags.ts: --decide <slot>=<mode>
(merged over an inherited GBRAIN_DECIDE_SLOTS, flags win, set + opted in),
--decide-provider, --decide-calibration <file|ref:id>, --decide-threshold,
--decide-force-on (loud, recorded) and --decide-dataset (split holdout:
split_mismatch refusal, LongMemEval eval-half restriction). Throwaway brains
get provider, consent, private egress, awaited shadow, thresholds and adopted
calibrations; retrieval-quality never writes the operator brain and refuses
with the catalogued line. Per-row/per-turn/per-query receipts (S2 late, S4
answerability + harness-reader abstention, S1 rerank latency/tokens, decide
spend delta) and run-level decide blocks; all-off output unchanged.
LongMemEval: --eval-pool-depth N and pool_recall at fused 30/50/100/300 in
--capture-pool rows; a --decide arm refuses trajectory routing.
gbrain decide judge-agreement --suite <longmemeval|grounding> --input <file>
[--limit N] [--provider <id>] [--threshold 0.5] [--dry-run] [--json] [--out FILE]:
one probability question per item on the background lane; n, raw agreement,
Cohen's kappa with a 95% CI, confusion matrix, per question_type slices, Jev
cost and latency p50/p95. Brain-free dispatch; reference labels are LLM
verdicts (label_source reported). Kappa math is pure and unit-tested.
Regenerated the CLI flag registry.
…fault

Guide: exact --decide / --eval-pool-depth / judge-agreement syntax replaces the
planned note; sweep/proposals and dataset --from sources restored from the CLI
usage (reconcile comments removed); suppress_below 0.10. eval-bench flag table
and System One arms section; decide.md fixed-vs-configurable + extension
points; KEY_FILES entries; dated note in the plan's config block.
…e S3 request; LongMemEval builder dedupes repeated session ids; eval arm scripts
… protocol; brainbench --decide configures the gateway
…and S9; enable --recommended pins the provider; quickstart shows the preset
…cate threshold; S7 no-calibration test uses an unreferenced model
…rieval stage, so expansion no longer times out S1
…d migration note

Bump VERSION and every version location to 0.60.23.0, regenerate the
plugin and template trees, rename the System One agent migration note to
skills/migrations/v0.60.23.0.md and refresh skills/skills.lock.json.
…TypeSafe key is present

With TYPESAFE_API_KEY or JEV_TYPESAFE_API_KEY present and no explicit
setting, dream triage (S7) and contradiction proposals (S9) default on with
typesafe:jev-1.13.0 and their shipped reference calibrations. The set comes
from recommendedSlots(), the same function enable --recommended uses. The
key is those slots' egress opt-in for their own data class; pages, derived
pages and deny_sources keep their rules. Explicit settings win (slot mode or
provider, decide.provider none, decide.egress.private deny, a consent deny,
decide disable). Without a key everything is off and byte-identical. Eval
runs never use the defaults.

status and doctor show 'on (default: Jev key present)' with the opt-out;
enable on a default slot says it is already on and writes nothing. Docs,
quickstart, plan owner note and the agent upgrade note explain the default.
@trunk-io

trunk-io Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

😎 This pull request was merged.

capy-ai Bot pushed a commit that referenced this pull request Oct 1, 2026
…it hangs) (#5798)

* fix(watchdog): write worker log lines straight to fd 2 so they survive a starved parent on Bun 1.4

* test(db): fake Postgres endpoint ends each refused socket once (Bun 1.4 emits write-after-end)

* ci: move the primary Bun version from 1.3.13 to 1.4.2; keep 1.3.11 as the compatibility lane

* v0.60.24.0 ci: run CI on Bun 1.4.2 (fixes the Bun 1.3.x lost child-exit-event hangs)

* v0.60.25.0 ci: re-bump past #5797's v0.60.24.0 claim
@capy-ai capy-ai Bot changed the title v0.60.24.0 feat(decide): System One v1, Jev decision support with key-aware defaults for the measured winners (#5178) v0.60.26.0 feat(decide): System One v1, Jev decision support with key-aware defaults for the measured winners (#5178) Oct 1, 2026
@capy-ai
capy-ai Bot merged commit 3a284ae into master Oct 1, 2026
65 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(search): add optional TypeSafe Jev reranking

1 participant