test: cover addLedgerFact errors, tool-name-aliases, hook E2E, CLI smoke (L7)#311
Merged
Conversation
…oke (L7) Closes the L7 test-audit gaps with four new test-only files (49 tests), home isolated via tmp dirs (never the real ~/.harness/): - ledger-add: addLedgerFact error paths (empty command, spawn ENOENT, timeout with verified child kill, server-exit stderr surfacing, JSON-RPC error, and an OK round-trip baseline) via fake MCP scripts under a tmp dir. - tool-name-aliases: expandToolNameAliases / expandCodexHookMatchPattern / extractShellCommand, incl. MCP name-variant edge cases, pinned exactly. - pack hook pre-tool-use: subprocess E2E spawning the real dist/cli/main.js with JSON on stdin, asserting the allow + fail-open paths. - CLI smoke: --help, --version (read dynamically from package.json), and unknown-command exit 64, via the real binary. Review fixes (reviewer subagent): pin HARNESS_HOME under the tmp dir in the hook E2E so machine/project override layers can't resolve against the real home; soften the server-exit stderr assertion to the stable "grounding-mcp exited:" invariant (the stderr tail rides a documented exit-vs-data race); assert the malformed-JSON loud-degradation stderr line. Deferred to follow-up 5839b59e: deny/ask-path E2E envelope coverage and switching addLedgerFact stderr capture to the 'close' event. Refs: task 56a834d2 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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
Closes the four L7 test-audit gaps (discovery 2026-06-10) with 49 new tests across 4 test-only files. No production
src/changed.tests/runtime/ledger-add.test.tstests/runtime/tool-name-aliases.test.tstests/cli/pack-hook-pre-tool-use-subprocess.test.tstests/cli/cli-subprocess-smoke.test.tsexpandToolNameAliases/expandCodexHookMatchPattern/extractShellCommandexactly, incl. MCP name-variant edge cases.dist/cli/main.js(the in-process path skips theHARNESS_ALLOW_REAL_GENERATED_DIRguard), home-isolated via tmp--config+HARNESS_HOME.--versionmatchespackage.jsondynamically and unknown-command exits 64.Home isolation (hard requirement)
No test touches the real
~/.harness/: pure units are filesystem-free; subprocess tests pin both--configandHARNESS_HOMEunder a per-test tmp dir.Review (reviewer subagent → REQUEST_CHANGES → fixed)
--config, leaving machine/project override layers resolving against the real home → now pinsHARNESS_HOMEunder tmp (fixed + comment corrected).grounding-mcp exited:invariant with a best-effort tail.Deferred to follow-up
5839b59e(reviewer-allowed): deny/ask-path E2E envelope coverage + switchingaddLedgerFactstderr capture to thecloseevent.Verification
npm run build,npm run typecheckclean; full suite2522 passed / 1 skipped; the 4 new files = 49 passing. Each group mutation-spot-checked (mutation → fail → revert).Refs: task 56a834d2