Only `apply` had a handler for AdoptionError, which was true when the error
type was introduced. `plan` has since gained two ways to refuse: it validates
the managed block of an existing CLAUDE.md to test idempotence, and it now
decides the knowledge entrypoint by content. Both reached the top-level safety
net in main, which prints a bare line to stderr and exits -- so `--output json`
answered a caller with no envelope at all, breaking the machine-readable
contract precisely when something went wrong and the caller needed the code.
The mapping from finding code to exit code now lives in one place rather than
being spelled out per branch.
- add _adoption_failure and use it from both plan and apply
- cover a refused plan end to end, envelope shape and exit code included
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
- tests-universal/ drives repoctl only as a subprocess CLI, asserting
directly against docs/specification.md (envelope, exit codes 0-5,
validation rules MVP, security invariants) so the same suite can judge
any conforming implementation, including the sibling codex/repoctl-l1
branch built independently from the same baseline.
- Running it surfaced two real bugs, both fixed:
- `context --strict` only checked budget truncation, never stale or
missing referenced documents, despite specification.md 19.2 defining
exit 4 as "stale or incomplete context" (not just truncation).
- `paths.confined_path` crashed with an unhandled WinError2 when a
referenced path's parent directory also didn't exist, because it
resolved a single non-existent parent with strict=True instead of
walking up to the nearest existing ancestor.