Repository navigation
Conversation
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
2c10e82 to
71ebc3e
Compare
…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.
…-aware defaults for the measured winners (#5797) * docs(designs): System One v1 plan for Jev decision support, reviewed with /autoplan * docs(designs): System One v1 owner approval, on/off modes * feat(decide): System One decide core, storage migrations, S1/S3 search 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. * feat(decide): gbrain decide CLI, decide_health doctor check, config validation, 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. * test(decide): S1/S3 PGLite integration, core, runtime, CLI, doctor and 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. * fix(decide): bind receipt/spend unnest columns as text arrays (postgres.js), Postgres E2E + goldens, providers RERANK/DECIDE columns * chore(decide): TypeSafe keys in plugin manifests, snapshot cache keys, reviewed resolveAuth override, derived migration version in persistence test * test(goldens): regenerate doctor/export/upgrade-replay goldens for decide; upgrade replay accepts a strict-prefix fixture when branch migrations postdate it * test(e2e): map decide sources to the decide store E2E * decide: load write-path lane registrations before subcommands and help * docs(decide): TypeSafe provider doc and System One operator guide 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. * docs(decide): System One discovery links and agent upgrade note - 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. * decide(S6): recall_needed question, reducer, suppress_below policy binding 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). * search: decide.keywordOnly takes the keyword-only path for the S6 fire 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. * context(S6): wire recall_needed into serve's turn-context handler 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). * decide: unpacked logical decisions (one request per question, shared background lane) and calibrate support for unpacked, max-aggregated adapters * S7 triage: turn-window decide triage in runTriagePass and dream retriage; passesTriageGate reads decide verdicts * docs(decide): mark planned eval commands; regenerate llms-full.txt 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. * S8 grounding: decide claim support after the mechanical checks at both verifyDreamPage call sites, before persistence * bench: S6 turn-context latency load test (fixture Jev transport, measured delays) * S7/S8 operator surfaces: what-if reducers, cat35 and grounding-labels datasets with unpacked adapters, status cost units, dream --eval-run * System One write path: local llm: S7 test, module-size ceiling, decide contract and KEY_FILES entries for S7/S8 * System One write path: keep grown functions within their baselines, wire datasets explicitly, retarget unwired-slot tests to intent * feat(decide): S2 intent, S4 query answerability, S5 injection on the 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). * feat(think): S2 trajectory gating, S4 abstention, S5 framing; gather 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). * docs(decide): retrieval slots contract, Jev reranker egress_denied decision, KEY_FILES entries * decide(S9): conflict pair reducer, proposals store and sweep; extract_facts phase tail when the slot is not off * facts(S9): checked supersede for proposal accept/undo (unmanaged transaction + coordinator mutation decide_proposal) * decide(S9): gbrain decide sweep and proposals list/accept/reject/undo, conflict dataset adapter + facts-fixtures builder, wire the slot * test(S9): reducer/eligibility/watermark units, PGLite sweep + phase tail, proposals accept/undo (unmanaged + managed), CLI; goldens for sweep/proposals JSON and status (conflict wired) * docs(S9): decide contract proposals section, KEY_FILES entries, operator guide for sweep and proposals * S9: regenerate the CLI flag registry, classify proposal-supersede.ts in the canonical writer census and the valid_until allowlist * fix(reflex): retrieval-reflex heartbeat honors GBRAIN_HOME (gbrainPath) The reflex writer and the retrieval_reflex_health doctor reader joined os.homedir(), which Bun resolves once per process and which ignores GBRAIN_HOME. A heartbeat left in the real home by another test leaked into the hermetic doctor-early-stop goldens on the Ubicloud serial lane (reproduced on the foundation commit 45a5857). Both now use gbrainPath. * docs(key-files): fold duplicate decide bullets after lane merge * test(decide): unwired-slot gate coverage now that every slot is wired * evals(system-one): S7 triage dataset, generator, matched-pair runner and receipts * evals(S6): know-to-ask extension corpus and recall_needed datasets 132 synthetic BrainBench-schema fixtures (528 gold turns, labels by construction) built so the shipped reflex misses needed memory (fire opportunities) or fires when memory is not needed (suppress opportunities), plus fired-and-needed turns for suppression precision. Builder outputs for evals/brainbench, the extension and both combined. * evals(S9): labelled conflict fact pairs with cosine-rule baseline Repository test pairs (upstream-gold), probe-derived placeholder pairs and deterministic synthetic pairs: 786 pairs in 408 families (duplicate 159, supersede 179, independent 448), each with baseline_cosine and the decideSingleFact decision from text-embedding-3-large at 1536 dims. * evals(S8): LLM-judged grounding labels for Cat 35 dream-page units 567 claim units S8 would judge (verifyBody groundingUnits) labelled by claude-sonnet-5 against their transcripts, plus 183 judge-confirmed perturbation negatives; transcripts copied from gbrain-evals (MIT). * evals(system-one): dataset README, hash table and spend ledger * decide(S9): calibrate the proposal floor on supersede labels; eval runners for S2/S6/S8/S9 * decide(S6): raise recall_needed.suppress_below default 0.05 -> 0.10 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. * search: eval-only pool depth seam; S3 gate on the vector-failure fallback 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. * evals: --decide arms on eval longmemeval, brainbench and retrieval-quality 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. * decide: judge-agreement (eval-only Jev judge beside the LLM judge) 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. * docs(system-one): eval flags, judge-agreement, dataset sources, S6 default 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. * decide(S2): raise intent.wait_ms default 150 -> 250 from measured late rates * decide(S3): calibration co-packs S5 questions when injection rides the S3 request; LongMemEval builder dedupes repeated session ids; eval arm scripts * evals(system-one): LongMemEval arm summarizer, S6 BrainBench summary, protocol; brainbench --decide configures the gateway * evals(system-one): verdicts, receipts, reference calibrations for S7 and S9; enable --recommended pins the provider; quickstart shows the preset * decide(S9): calibrated proposal floor applies only with its own duplicate threshold; S7 no-calibration test uses an unreferenced model * fix(decide): the per-query decide budget starts at the first post-retrieval stage, so expansion no longer times out S1 * test(goldens): doctor JSON goldens for v186 + decide_health * test(goldens): Postgres doctor JSON golden for v186 + decide_health * chore(module-size): lower synthesize.ts ceiling to its merged size * v0.60.23.0 chore(release): System One v1 version stamps, changelog and 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. * feat(decide): key-aware defaults turn on the measured winners when a 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. * fix(evals): System One Ubicloud runner installs a pinned, checksum-verified Bun instead of curl | bash
|
Thank you @dsandrade. This adapter shipped in #5797 (v0.60.26.0) as part of System One, where it now runs on a shared We measured Jev reranking against Voyage on LongMemEval. It did not beat Voyage, so Voyage stays the default reranker, and |
What
Closes #5191.
Add TypeSafe Jev as an optional reranking provider through GBrain's existing recipe registry and AI gateway. Users select
typesafe:jev-1.13.0ortypesafe:jev-latestwithsearch.reranker.model, enable the existing reranker setting, and supplyTYPESAFE_API_KEYthrough the existing home.envor process environment. Setup and behavior.Each candidate receives an independent native System One Score question over shared query state. The adapter preflights estimated context and payload limits, packs candidates independently, executes batches with bounded concurrency under one deadline, validates complete scores, normalizes 0..3 to 0..1, and merges global indices with stable ties. It uses existing invocation authorization, cost admission/settlement and search failure reporting. The production Voyage recipe, standard rerank request/response/accounting path, configured defaults, search orchestration and downstream thresholds are preserved. The gateway adds a native dispatch and import, with blank-line removals outside reranking to retain its 4,914-line ceiling.
Why
GBrain has no registered native TypeSafe reranker. This supplies an explicit option for users with a Jev key, including internal parallel judgments and context-aware batch packing. It introduces no key-presence auto-selection or new configuration plane.
Measured evidence
Initial pilot and reproducible protocol and 100-document extension include frozen-input generators, unaltered receipts, capture source manifests, and all 85 HTTP requests from the two timing captures in individual tables/CSVs. Most added lines are raw JSON evidence. Each provider/profile has one execution on identical synthetic candidate text/order.
On 50 and 100 long documents, Jev had 78.7% and 86.81% lower active elapsed time in these observations, with approximately 0.53% higher nominal cost. Voyage was faster and cheaper on the two smaller profiles, and cheaper on every profile. Increasing the pool to 100 did not make Jev cheaper. Costs sum native reported input across all calls at list prices, excluding free credits; durations are measured individually and overlapping intervals are counted once for active elapsed time.
Free-account evaluation controls: Voyage
rerank-3was selected for its free allowance, with evaluation-only splitting, rolling 3 RPM / 10K TPM admission, concurrency up to three andtruncation:false. These controls do not modify the production Voyage adapter. Large-pool Voyage results measure complete account-constrained collector executions, not the untouched adapter receiving the entire pool in one request or paid-account capacity. Wall includes between-chunk quota gaps; active time excludes idle gaps but still includes client, batching, concurrency and network effects. Initial profile isolation is excluded from both.Jev uses the proposed production planner/executor, with query-only state and candidate-local structured questions. Conservative estimates do not prove minimum native request counts or optimal scheduling. In particular, the 50-short Voyage pool was split without probing its whole native request. All profiles use one synthetic query; short large pools repeat nine background texts. Both providers returned every candidate and ranked the expected policy first. This does not establish held-out quality equivalence, score-threshold calibration, maximum throughput, latency distributions or a universal winner.
The initial capture predates gateway lifecycle isolation and the upstream base update; the 100-document extension uses the current gateway on base
d13aa742f. Current code reproduces all captured Jev performance payload hashes and pool fingerprints offline. Separate selected-layout native cases retain twelve developer-labeled cases and required score pairs, including false premises, partial/multiple evidence and injected instructions; these are regression evidence rather than a Voyage quality comparison.Discrimination test
Reverted
src/core/ai/recipes/index.tsandsrc/core/ai/gateway.tstod13aa742fd68b71bfd6c98be3dda5813791f1d6cin an isolated worktree, rantest/ai/typesafe-reranker.test.ts: 14 pass / 15 executed failures. Restored: 29 pass / zero failures.Tests
No paid-tier throughput, independent accuracy improvement or lower-cost claim accompanies this contribution.