feat(substrate): whitepaper-fidelity gaps — M5 footprint, doom-loop, failing-test prediction (Tranche B)#18
Merged
CodeWithJuber merged 1 commit intoJul 6, 2026
Conversation
…ing-test prediction (Tranche B) Turns three "specified but barely-built" mechanisms from the paper into real, tested features. - M5 anti-over-engineering (src/lean.js, `forge lean`): a measured footprint check φ(y) − φ*(x) — new abstractions the task never named, a big diff for a short ask, files beyond the stated scope — replacing the three-keyword minimalityWarnings stub. Folded into `forge substrate` (minimality.footprint). - Doom-loop breaker (cortex_hook): captures a normalized signature of failing test output and fires detectDoomLoop when the SAME failure recurs past a threshold — the "different edits, same error" loop the shell guard can't see. Surfaced as a pre-edit "stop and find the root cause" advisory. - Consequence simulation, failing-tests class (Eq 4): substrate predicts the tests likely to break BEFORE an edit (impact.predictedTests) — impacted test files plus each impacted source file's sibling test. Assessed the 4th item (route recall.js through `val`) and deliberately did NOT: recall facts are user-authored pointers with no ground-truth outcome to validate against, so `val` correctly lives in lessons.js where it already ships. Forcing the metric where the data doesn't exist would be dishonest. 215 tests pass (+11), typecheck + Biome clean, zero new runtime deps. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HGZUYFdUb4EViXV5tRid19
CodeWithJuber
marked this pull request as ready for review
July 6, 2026 07:59
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
Tranche B of the review. Turns three mechanisms the paper specifies but the product barely
built into real, tested features — each grounded in inputs that already exist.
M5 — anti-over-engineering, measured (
src/lean.js,forge lean)The paper flags
φ(y) − φ*(x) > 0— the solution's footprint beyond the task's minimalsufficient footprint. The old
minimalityWarningswas three keyword regexes. Nowleanreads theworking diff and measures the real footprint:
referencedEntitiesfound in the task),Folded into
forge substrateasminimality.footprint, and available standalone:forge lean "<task>".Doom-loop breaker (self-correction)
The existing shell guard catches the same action repeated. This catches the subtler loop the
paper names — different edits that keep producing the same test failure.
cortex_hooknowcaptures a normalized signature of failing-test output (line numbers, timings, addresses, temp
paths factored out), and
detectDoomLoopfires when one signature recurs past a threshold. Thepre-edit hook surfaces a "stop and find the root cause" advisory (with the diagnosis), taking
precedence over lesson/risk notes.
Consequence simulation — failing-tests class (Eq 4)
forge substratenow predicts the tests likely to break before the edit(
impact.predictedTests): impacted files that are tests, plus each impacted source file'ssibling test (
foo.js → foo.test.js,foo.py → test_foo.py,__tests__/,test(s)/).Surfaced in the report and the ambient advisory so you run the narrowest affected tests first.
On the 4th item (recall
val) — deliberately not doneI assessed routing
recall.jsthrough thevalterm and chose not to: recall facts areuser-authored pointers with no ground-truth outcome to validate against, so
valcorrectlylives in
lessons.js(where it already ships). Forcing the metric where the data doesn't existwould be dishonest — flagging the decision rather than shipping a hollow version.
Checklist
npm testpasses (Node 18/20/22) — 215 tests (+11)npm run checkpasses (Biome lint + format)lean,detectDoomLoop,predictFailingTests)feat:)CHANGELOG.mdupdated under## [Unreleased]forge leancommand + substrate fields)Risk & rollback
fields;
leanis diff-based and quiet with no diff.Extra checks
npm run typecheckpassesVerification
Full suite + typecheck + Biome green. Manual:
forge leanon a synthetic 4-class diff flags theunrequested abstractions; doom-loop unit tests confirm normalization makes the same error match
across runs and that distinct/under-threshold failures stay quiet;
predictFailingTestsfinds thesibling test of an impacted source file.
Next: Tranche C (enforcement & stewardship — the mandatory gate).
🤖 Generated with Claude Code
https://claude.ai/code/session_01HGZUYFdUb4EViXV5tRid19
Generated by Claude Code