Skip to content

Patch-restore cleanup batch: centralize latch preconditions, one path normalizer, test-fixture dedup #91

Description

@pbean

Non-bug cleanups from the PR #86 final review, batched:

  • Centralize the restore-latch preconditions in runs.rearm_escalation (single seam): the worktree/containment checks live in cli._resolve_restore_patch while the sentinel + spec-less rejections live in rearm_escalation — any future caller of rearm_escalation (TUI restore parity, programmatic) bypasses the CLI half. The CLI's pre-session fail-fast can call the same shared validator.
  • One restore-path normalizer: the maybe-relative→absolute normalization of task.restore_patch exists in three copies resolving against two different bases (engine._restore_patchworkspace.root; verify.verify_dev_exclude_relpathspaths.project; cli._resolve_restore_patchproject). The CLI always latches an absolute resolved path today, so the relative branches are dead — either delete them and document the latch as absolute-only (model.py currently documents 'repo-relative-or-absolute'), or extract one named helper.
  • Vacuous phase guard in engine._restore_patch: at its sole call site the task is always DEV_RUNNING, so if task.phase == Phase.DEV_RUNNING is always true — and the comment's PENDING case wouldn't survive _escalate anyway (PENDING→ESCALATED is not a legal transition). Replace with an unconditional advance + call-site-invariant comment.
  • T4 altitude: verify_dev_exclude_relpaths's restore_patch param is threaded through three call sites above _verify_shared_gates — the anti-drift seam that already receives task. Deriving the exclusion inside the shared gate removes the default-None foot-gun for a future fourth mode.
  • Test dedup: third _escalated_run fixture copy (test_runs / test_resolve / test_cli — promote a parameterized builder to conftest); E2E scaffolds hand-roll the skill list three times (loop over install.DEV_BASE_SKILLS like tests/test_install.py does); tests/test_engine.py::_restoring_dev_effect re-builds the result_json envelope that conftest's dev_effect factory owns.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions