Skip to content

Make six brittle tests derive their expectations from the source - #33

Merged
gitsad merged 9 commits into
mainfrom
chore/robust-brittle-tests
Nov 11, 2026
Merged

gitsad merged 9 commits into
mainfrom
chore/robust-brittle-tests

Conversation

@gitsad

@gitsad gitsad commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

What this changes

Six brittle tests now derive their expectations from the command registry, BUNDLE_SKILLS, model-floor.json and the real exported functions instead of literal lists, counted matches in main.ts or prose. A new test/helpers/source-blocks.ts locates a function body or IPC handler by bracket matching, so wiring tests check where a call sits.

Key files

  • test/editor-demand-wiring.test.ts — contract: the editor server is requested only from the need-editor and restart handlers, launchEditor only through the demand gate, keepWarm only in the scan. Fails if a request() is dropped from a handler or appears anywhere else, if launchEditor is called directly, or if keepWarm leaves runScan.
  • test/lantern-permissions-triggers.test.ts — contract: saving the skill linker or importing a list syncs the project's delegate rules afterwards, and a cancelled picker does not. Now calls the real registerExtensionsIpc with fakes; fails if either handler drops or reorders the sync, or main.ts stops passing syncPermissionsFor.
  • test/lantern-macro-load.test.ts — contract: lantern:macro is behind fromWorkspace, checks isRegisteredDir, and carries the language from renderer to reader. Literal 14 blocks / 58 edges removed (the view is compared to the fixture view). Fails if the wrapper, the registered check or the lang argument goes.
  • test/project-window.test.ts — contract: every registry command except on-demand ones is registered after boot. The 20-name list is now COMMANDS; fails if a registerCommand is removed.
  • test/install-skills.test.ts — contract: every bundled skill is installed. The 16-name list is BUNDLE_SKILLS, which must equal the skills/*/SKILL.md folders; fails if a skill is dropped from the bundle.
  • test/lantern-sync-selftest.test.ts — contract: the mapping model policy accepts the floor's families and exact ids, advises below the recommended version, rejects the rest. Driven by model-floor.json and the CLI; fails if the advisory or the allow check in lib.mjs breaks.

Before / after

Before: expect([...MAIN.matchAll(/editorDemand\.request\(\)/g)]).toHaveLength(2) and a hand-written command list. After: every editorDemand.request( lies inside the two handlers, and COMMANDS supplies the list.

Verified with pnpm install --frozen-lockfile, pnpm run typecheck, pnpm run lint, pnpm test, all green; each contract was also broken in source and the new test failed. Unreviewed fixes: none. Lantern: 7 files re-mapped.

Run cost

agent model effort calls cache-read cache-write+input
lantern-delegate-medium sonnet 5.5 medium 126 15744521 604059
└ reviewer ×5 opus 5.5 medium 69 4576023 359942
total 195 20320544 964001

@gitsad
gitsad merged commit 25627b1 into main Nov 11, 2026
14 checks passed
@gitsad
gitsad deleted the chore/robust-brittle-tests branch November 11, 2026 18:58
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