You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 36b1798
Browse filesBrowse the repository at this point in the historyBrowse files
fix(agents): close project input guard faults in the target inspector (#379)
Follow-up to #346 for HACK-1332 (target inspector contract, HACK-1144 / WU31).
## What changed
`hack project target` (and the `hack.project.target` MCP tool) could still return a detail-less
error envelope when a shared project input guard refused. The MCP adapter turned that into
`data: null`. This PR maps every input-guard fault to a closed, value-free refusal.
1. **Guard refusals (cherry-picked rework 077825fe).** The inspector maps the shared guards'
refusals wherever they are raised, including inside config reads: - native or conflicting
inputs become `project_inputs_unsupported` - an unparseable, interrupted or uncheckable
legacy adoption state (for example an unsearchable `.hack` or `.hack/.internal`) becomes the new
provisional `adoption_state_unsafe` - a `.hack` file becomes `input_unreadable`
`LegacyComposeAdoptionSelectionError` now carries its `kind`. 2. **Uncheckable input presence
(new).** `inputPresent()` in `src/lib/project-input-selection.ts` treats only `ENOENT` as
absence. Any other fault threw a plain `Error`, so a `.dev` file, or a mode-000 `.dev`
directory, beside a valid `.hack` still produced `E_UNEXPECTED` with no detail. The guard now
throws a typed `ProjectInputAccessError`. It is value-free: no OS message, path or `cause`. It
classifies the fault as `permission` (`EACCES`/`EPERM`) or `unreadable`. The inspector maps
these to `input_permission_denied` and `input_unreadable`.
**Side effect on other commands:** the same fault now reports `E_CONFIG_INVALID` instead of
`E_UNEXPECTED`. The message text is unchanged except for a trailing "Values omitted.", which
matches the adoption guard's input-access refusal.
The contract doc (`docs/reference/ax-target-result-contract.md`) and its proof table are
updated.
## Validation
- Before the fix, the new paired CLI/MCP fixtures returned the off-contract envelope
`{"code":"E_UNEXPECTED","message":"Cannot inspect Hack project inputs. …"}`. After the fix,
they return the closed refusal, and the envelope contains neither the fixture path nor the
errno.
- Each new test failed under a mutation:
- always classifying as `unreadable` failed the permission domain test and the paired test
- restoring the plain `Error` failed both domain tests
- disabling the inspector mapping failed both paired tests
- Local checks: `packages/cli` typecheck passed. `packages/cli` check reported 0 errors (pre-
existing warnings only). Biome on the changed files passed. `privacy:check` passed. gitleaks
over `origin/next..HEAD` found no leaks. `tests/project-target-inspect.test.ts` and
`tests/project-input-selection.test.ts` gave 52 pass, 0 fail.
- Full suite on the M3 at the exact head `85c8ec23`: 7579 pass, 126 skip, 2 fail, across 7707
tests. The mode-000 cases are skipped when running as root.
- Both failures are in `tests/native-authored-project-recovery.test.ts`: "new no-host death
uses real read-only quiescence facts…" and "new no-host recovery retains original bindings on
last-await".
- Both also fail on the untouched `next` base `f2278c79` in the same M3 environment (16 pass,
2 fail). The error is "Native process census expired". The real host process census keeps
refusing its sessions phase while concurrent suites change the process table, so the 3 s
budget expires.
- These failures predate this PR and do not touch project inputs. They are reported
separately, not fixed here.
## Not changed (noted)
`readProjectsRegistry` still treats an unreadable registry as empty. That is pending a product
decision (HACK-1332 item 1) and is intentionally left alone here.
Refs HACK-1332, HACK-1144.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
@@ -163,6 +164,16 @@ read permission, or a directory where a config file belongs) is reported as
163
164
filesystem error). The OS message is never surfaced, because it contains the
164
165
absolute path.
165
166
167
+
The shared project input guards that every project command runs are mapped
168
+
too. Native or conflicting project files are `project_inputs_unsupported`. A
169
+
legacy adoption state that is unparseable, interrupted, or cannot be checked
170
+
(for example a project directory the caller cannot search) is
171
+
`adoption_state_unsafe`. A non-directory where the project directory belongs is
172
+
`input_unreadable`. When the guard cannot check whether a project input exists
173
+
(for example a `.dev` file, or a `.dev` directory the caller cannot search,
174
+
beside a valid `.hack`), the refusal is `input_permission_denied` (`EACCES`,
175
+
`EPERM`) or `input_unreadable` (any other fault), like a read fault.
176
+
166
177
`retry` is advice for the caller. Like suggested actions and application logs,
167
178
it carries no execution authority.
168
179
@@ -208,6 +219,8 @@ WU21). The inspector itself only produces snapshots.
208
219
| Two registrations owning one checkout |`ambiguous_project`| same | paired fixture |
209
220
| Malformed Hack config or Compose file, oversized input |`config_parse_failed`, `compose_parse_failed`, `generation_input_too_large`| same | paired fixture |
210
221
| Unreadable input (directory in place of a file, no read permission) |`input_unreadable`, `input_permission_denied`| same | paired fixture (permission case skipped as root) |
222
+
| Input guard refusals (native/legacy conflict, unsafe adoption state, unsearchable or non-directory project dir) |`project_inputs_unsupported`, `adoption_state_unsafe`, `input_unreadable`| same | paired fixture (unsearchable case skipped as root) |
223
+
| Uncheckable input presence (`.dev` file or unsearchable `.dev` beside a valid `.hack`) |`input_unreadable`, `input_permission_denied`| same | paired fixture and domain test (unsearchable case skipped as root) |
211
224
| Detached linked worktree, no project, missing path | closed refusals | same | paired fixture |
212
225
| Unknown service |`service_not_found`| same | paired fixture |
213
226
| Config changed during read |`generation_changed_during_read`| same code path | domain test |
0 commit comments