Skip to content

refactor: separate inspection, safety policy, unlock execution, and test fixtures #16

Closed

Description

@abruption

Problem

src/doctor.ts currently combines evidence collection, safety policy, signaling, and post-signal verification. The test suite keeps its owner fixture and all four tests in one file. This makes the security work in #9 through #13 harder to review and independently test.

Required changes

After the behavioral fixes are established:

  • separate evidence inspection, authorization policy, and unlock execution into focused modules
  • keep signaling behind a narrow function that requires fully revalidated evidence
  • move reusable advisory-lock owner setup into test helpers
  • organize tests by lock, process, transcript, doctor/policy, and CLI behavior
  • add CLI JSON and exit-code contract coverage
  • continue using real advisory locks for safety-critical integration cases

Avoid a behavior-changing rewrite. Preserve schemaVersion 1 and existing command behavior unless a linked issue explicitly changes them.

Acceptance criteria

  • policy tests can supply deterministic evidence without spawning a process
  • integration tests still prove real advisory-lock behavior
  • signaling tests prove that refusal paths never send SIGTERM
  • package and CLI smoke tests remain green on macOS and Linux

Activity

  1. added
    enhancement
    on Sep 20, 2026
  2. abruption commented on Sep 22, 2026

    @abruption
    OwnerAuthor

    Development order: this refactor is blocked by #31, which defines and tests the supported CLI/JSON boundary required to prove behavior preservation. Start the isolated #16 worktree from main only after #31 merges.

  3. abruption commented on Sep 22, 2026

    @abruption
    OwnerAuthor

    Development gate update: PR #35 closes #24 and the newly discovered concurrent-unlock security issue #34. Start #16 from current main only after #35 merges so the refactor preserves the operation-lease and deterministic race matrix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions