Skip to content

test: cover addLedgerFact errors, tool-name-aliases, hook E2E, CLI smoke (L7)#311

Merged
LanNguyenSi merged 1 commit into
masterfrom
test/harness-test-gaps-l7
Jun 26, 2026
Merged

test: cover addLedgerFact errors, tool-name-aliases, hook E2E, CLI smoke (L7)#311
LanNguyenSi merged 1 commit into
masterfrom
test/harness-test-gaps-l7

Conversation

@LanNguyenSi

Copy link
Copy Markdown
Owner

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.

Group File Tests
addLedgerFact error paths tests/runtime/ledger-add.test.ts 6
tool-name-aliases tests/runtime/tool-name-aliases.test.ts 31
hook pre-tool-use E2E (real binary) tests/cli/pack-hook-pre-tool-use-subprocess.test.ts 3
CLI smoke (real binary) tests/cli/cli-subprocess-smoke.test.ts 9
  • Error paths drive empty command, spawn ENOENT, timeout (with verified child kill via elapsed-time bound), server-exit stderr surfacing, and JSON-RPC error, using fake MCP scripts under a tmp dir.
  • Aliases pin expandToolNameAliases / expandCodexHookMatchPattern / extractShellCommand exactly, incl. MCP name-variant edge cases.
  • Subprocess E2E spawn the real dist/cli/main.js (the in-process path skips the HARNESS_ALLOW_REAL_GENERATED_DIR guard), home-isolated via tmp --config + HARNESS_HOME.
  • CLI smoke asserts --version matches package.json dynamically and unknown-command exits 64.

Home isolation (hard requirement)

No test touches the real ~/.harness/: pure units are filesystem-free; subprocess tests pin both --config and HARNESS_HOME under a per-test tmp dir.

Review (reviewer subagent → REQUEST_CHANGES → fixed)

  • [MAJOR] Hook E2E only passed --config, leaving machine/project override layers resolving against the real home → now pins HARNESS_HOME under tmp (fixed + comment corrected).
  • [MINOR] Server-exit stderr assertion rode the documented exit-vs-data race → softened to the stable grounding-mcp exited: invariant with a best-effort tail.
  • [NIT] Added the malformed-JSON loud-degradation stderr assertion.

Deferred to follow-up 5839b59e (reviewer-allowed): deny/ask-path E2E envelope coverage + switching addLedgerFact stderr capture to the close event.

Verification

  • npm run build, npm run typecheck clean; full suite 2522 passed / 1 skipped; the 4 new files = 49 passing. Each group mutation-spot-checked (mutation → fail → revert).

Refs: task 56a834d2

…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>
@LanNguyenSi LanNguyenSi merged commit b961220 into master Jun 26, 2026
1 check 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.

2 participants