Project output avoids Home resolution
Traceability
- Spec ID: project-output-home-resolution
- Status: Implemented
Intent
Allow record-fix-output to record verified Project-scoped output even when the current process Home directory is unavailable or cannot be canonicalized. This keeps Project output validation independent of unrelated Global-scope state.
Acceptance Scenarios
- AC-1: A result whose
actualOutputentries are allscope: "Project"is accepted when every referenced file exists within the canonical workspace, even ifHOMEandUSERPROFILEpoint to a non-existent directory. - AC-2: A
scope: "Global"output resolves and canonicalizes the process Home on demand, accepts an existing~/...file within that canonical Home, and fails without writing the report when Home is unavailable. - AC-3: Project output continues to require an existing file and rejects a canonical target that escapes the workspace.
Non-goals
- Change output schemas, CLI arguments, or result consumption behavior.
- Relax existing-file,
realpath, or scope-containment validation. - Add test-only production API parameters or alter host environment state.
Plan and Tasks
- Add a deterministic CLI regression test that invokes
record-fix-outputwith only Project output in a child process whoseHOMEandUSERPROFILErefer to a non-existent directory. - Confirm the regression fails against the current eager Home resolution.
- Make Home canonicalization lazy in
assertOutputTargets, retaining the existing workspace canonicalization and Global validation behavior. - Run focused, task-loop, documentation-link, packaging, and practical full test gates; record any environment limitation.
Test and Review Evidence
- AC-1:
node --test test/task-loop-report.test.mjsexercises the isolated child-process regression and verifies a successful JSON CLI result. - AC-2:
node --test test/task-loop-report.test.mjsruns isolated Global success and unavailable-Home failure cases; the latter verifies the JSON error envelope and that findings bytes are unchanged. - AC-3: existing
record-fix-outputcases retain automated Project existing-file rejection. Focused source review confirms the canonicalrealpathcontainment check and its validation order are unchanged. - Documentation: regenerate
docs/better-harness-doc-links.mmdand runnode --test test/doc-link-graph.test.mjsafter adding this spec. - Packaging: run
npm run pack:verify; runnpm testwhen the local runtime can complete the full suite. - Risk:
os.homedir()stays intentionally reachable for Global output only; a regression could weaken containment only if lazy initialization is applied to the wrong scope, which focused scope tests mitigate.
Observed Evidence (2026-07-30)
- Pre-fix regression: temporarily restoring eager Home resolution made the new Project-only child-process test fail with exit code 1.
- Focused gate:
node --test --test-name-pattern="record-fix-output" test/task-loop-report.test.mjspassed 10/10. - Task-loop gate:
node --test test/task-loop-report.test.mjspassed 76/76. - Documentation gate: the routing graph had no semantic diff and
node --test test/doc-link-graph.test.mjspassed 6/6. - Full regression:
npm testexited 0; the suite retained its existing Windows symlink-permission skip. - Package gate:
npm run pack:verifypassed using an isolated temporary npm cache, which was removed afterward. - Environment limitation: Node
v22.17.0and npm10.9.2are below the repository minimums of Node22.20.0and npm10.9.3.