Skip to content

feat: TypeSafe System One (Jev) typed proposers + hermetic test suite - #146

Merged
CodeWithJuber merged 4 commits into
masterfrom
fix/hermetic-test-suite
Sep 20, 2026
Merged

CodeWithJuber merged 4 commits into
masterfrom
fix/hermetic-test-suite

Conversation

@CodeWithJuber

Copy link
Copy Markdown
Owner

What & why

Two changes, rebased onto latest master:

1. fix(test): the test suite is hermetic. It inherited the developer's environment — green in CI, red on any machine where forge was installed and enabled. A new test/_setup.js (preloaded via --import) scrubs FORGE_*/provider env by prefix, sandboxes $HOME, and forces the keyless HTTP runner: 0 failures in ~40s (was 593s with two failures). test/hermetic.test.js pins the scrub list against envVarsRead() so the two cannot drift.

2. feat: TypeSafe System One (Jev) as the fast typed proposer. Where the LLM layer asked a text model for a judgment that is really a classification or a yes/no — route's complexity band and preflight's assumption gate — forge now asks TypeSafe's Jev instead: typed choice/noul answers with probability distributions and confidence in ~150ms (batched into one call for the gate's four dimensions), versus seconds of text generation plus JSON parsing.

The new src/jev.js client keeps the existing proposer contract exactly:

  • Opt-inFORGE_LLM=1 and TYPESAFE_API_KEY; without the key, behavior is byte-identical
  • Fail-safe — any error → null → text-LLM fallback → deterministic rubric; a null never changes a verdict. BAND_FLOOR and the ±band assumption reconcile are untouched
  • Zero-dependency — one raw HTTPS POST via the spawned-child pattern; key travels via child env (_FORGE_JEV_KEY), never argv, never logged; hasSecret refuses secret-shaped state
  • Validated — a choice naming an option we never offered is garble and fails safe

forge route --json now reports llm.provider (jev/text) with Jev's confidence; preflight records assumption.provenance.provider. Clarifying free-text questions stay with the deterministic rubric — a System One model judges, it does not author prose.

Docs updated everywhere the proposer layer is documented: CHANGELOG.md, docs/GUIDE.md (section + env table), ARCHITECTURE.md, mintlify/concepts/model-routing.mdx, mintlify/concepts/pre-action-gate.mdx. forge docs check passes, with TYPESAFE_* covered in both directions and _FORGE_JEV_KEY registered as internal plumbing.

Checklist

  • npm test passes (1145 tests, 0 failures — 11 new for Jev)
  • npm run check passes (Biome lint + format)
  • New public functions have a test (test/jev.test.js, injected transport, no network)
  • Conventional commit messages (fix(test) + feat)
  • CHANGELOG.md updated under ## [Unreleased]
  • No new runtime dependency (raw HTTPS, zero-dep rule kept)
  • Substrate/docs updated (router/gate changed — GUIDE, ARCHITECTURE, mintlify, env contract)

Risk & rollback

  • Risk level: low — off by default; every Jev path fails safe to the pre-existing behavior
  • Rollback plan: revert the feat commit; the hermetic fix(test) commit stands alone either way

Extra checks (tick if applicable)

  • npm run typecheck passes
  • Input validated at boundaries; errors handled (answer validation per question type; all transports fail closed to null)
  • Logs contain no secrets/PII (key in child env only; state screened by hasSecret; metrics log no prompt text)
  • If AI-assisted: I understand it, verified the package APIs (read https://docs.typesafe.ai/api.md directly), and it has tests

Note: no API keys are committed anywhere in this PR. Live smoke test for a keyed machine:

FORGE_LLM=1 TYPESAFE_API_KEY=… node src/cli.js route "fix the race condition in the worker pool" --json
# expect: llm.provider === "jev", premium band with confidence

CodeWithJuber and others added 4 commits September 20, 2026 10:22
The suite inherited the developer's environment, so it was green in CI and
red on any machine where forge was actually installed and enabled -- the two
things a maintainer does.

An exported FORGE_LLM=1 both flipped the "llm off by default" assertion in
test/substrate.test.js and made the faculties fire real model calls; a real
~/.forge reached doctor()'s machine-scoped install check through
test/doctor.test.js. 593s wall, two failures.

test/_setup.js is preloaded via --import into every test process (all three
invocation sites, including the Windows job that bypasses `npm test`). It
scrubs FORGE_*/provider env by prefix denylist, sandboxes $HOME to a
throwaway tmpdir, and sets FORGE_LLM_HTTP=1 to force the keyless HTTP runner
rather than shelling out to a real `claude` binary. 0 failures in ~40s.

test/hermetic.test.js pins the scrub list against envVarsRead() so the two
cannot drift, and fails if anyone drops the --import wiring.

Two assertions were wrong rather than merely leaky:
- doctor asserted a global `failed === 0` to prove a local property about
  `na` rows, making it depend on unrelated machine state.
- a substrate comment claimed no runner reaches the real CLI -- the opposite
  of the truth, and why that file spent 85s on live calls.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Where the LLM layer asked a text model for a judgment that is really a
classification or a yes/no — route's complexity band and preflight's
assumption gate — forge can now ask TypeSafe's Jev instead: typed
choice/noul answers with probabilities and confidence in ~150ms, batched
into one call, versus seconds of text generation plus JSON parsing.

- src/jev.js: zero-dep client on the adjudicate contract — opt-in
  (FORGE_LLM=1 + TYPESAFE_API_KEY), fail-safe (null never moves a
  verdict), key via child env, secret-refusing on outgoing state,
  answers validated against the questions asked
- route: Jev choice proposer preferred, text-LLM fallback, BAND_FLOOR
  reconcile untouched; --json gains llm.provider + confidence
- preflight: all four rubric dimensions scored as one batched noul
  call; clarifying questions stay with the deterministic rubric
- hermetic boundary: test/_setup.js scrubs TYPESAFE_*; docs check
  covers the new env surface both directions; 11 new tests
Windows CI caught it: a plain absolute path (D:\…) handed to --import
parses as the URL scheme "d:" and dies with ERR_UNSUPPORTED_ESM_URL_SCHEME
before the canary process can run. --import resolves module specifiers,
so give it the URL href — valid on every platform.
@CodeWithJuber
CodeWithJuber merged commit 5eeade5 into master Sep 20, 2026
7 of 12 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.

1 participant