Skip to content

refactor: retire legacy PR-check migration machinery - #3299

Merged
kunchenguid merged 4 commits into
mainfrom
fm/fm-retire-legacy-check-migration-s1
Aug 29, 2026
Merged

kunchenguid merged 4 commits into
mainfrom
fm/fm-retire-legacy-check-migration-s1

Conversation

@kunchenguid

Copy link
Copy Markdown
Owner

Intent

Retire the ALREADY-COMPLETED legacy PR-check migration machinery from Firstmate after proving it is safe to delete. The deletion is authorized only because every registered home (main plus every secondmate in data/secondmates.md) already carried both completion markers state/.pr-check-migration-scan-v1 and state/.pr-check-migration-v1, and no installer or live check-creation path still produces pre-migration checks. Remove bin/fm-pr-check-migrate.sh, its migration-path test coverage in tests/fm-pr-check-security.test.sh (keep every still-live PR-check security/trust test), the quarantine/log/marker machinery and bootstrap migration sweep, and dangling AGENTS.md/docs/state-layout references. Keep the executable-custom-check trust architecture (fm-check-register.sh, .check-trust, PR-poll sidecar) intact. One concept per PR: this is migration-machinery retirement only. The decision-hold-lifecycle stub was left in place because the collapse has no numbered release boundary proving "one release after." Prove behavior through real interfaces, not by asserting deleted source text is gone. Session start must still work with the sweep removed. Do not merge.

What Changed

  • Remove the completed PR-check migration script and its hooks from bootstrap, watcher startup, and check arming.
  • Delete legacy quarantine, marker, teardown, and compatibility handling while preserving current PR-poll and custom-check trust paths.
  • Refocus security coverage and documentation on live v2 registration and the remaining five bootstrap sweeps.

Risk Assessment

✅ Low: The retirement is well-bounded, preserves live trust and PR-poll paths, and the previously removed live security coverage is restored without retaining migration-only machinery.

Testing

The focused PR-check security and session-start behavior suites passed; manual CLI checks demonstrated that live custom-check trust boundaries remain enforced and a real session start completes and persists its completion record without the retired sweep. This is CLI-only behavior, so reviewer-visible transcript artifacts were captured instead of visual screenshots.

Evidence: Custom-check trust architecture end-to-end transcript

Source: Custom-check trust architecture end-to-end transcript

1) Hard-linked executable source is refused:
exit=1 output=error: custom check is unavailable trust_created=no
2) Private single-link executable registers through the real CLI:
exit=0 output=registered: state/demo.check.sh trust_mode=600
3) Hard-linked trust destination is refused and external alias survives:
exit=1 output=error: custom check trust path is unavailable alias_survives=yes
Evidence: Session-start completion transcript

Source: Session-start completion transcript

command: FM_HOME=<evidence>/session-home FM_ROOT_OVERRIDE=<worktree> FM_BACKEND=orca bin/fm-session-start.sh
exit: 0
SESSION START - ~/.no-mistakes/evidence/01M17JMAY6EF3MS9RHW8S6NRKM/session-home
lock acquired: harness pid 91892
(no queued wakes)
READ-ONCE CONTRACT
FLEET STATE
CONTEXT
NEXT STEP
The digest above is complete for this session start. The READ-ONCE CONTRACT
persisted completion owner pid: 91892

deferred network stage after the digest:
completed off the startup path in 1s: GitHub authentication, dead-secondmate relaunch, secondmate convergence, pending handoff delivery, and project clone refresh with its drift reporting.
(silent - no problems found)
Evidence: Complete real session-start output

Source: Complete real session-start output


================================================================================
SESSION START - ~/.no-mistakes/evidence/01M17JMAY6EF3MS9RHW8S6NRKM/session-home
================================================================================

LOCK
--------------------------------------------------------------------------------
lock acquired: harness pid 91892

BOOTSTRAP
--------------------------------------------------------------------------------
MISSING: orca (install: brew install orca  # or the platform's package manager)

WAKE QUEUE
--------------------------------------------------------------------------------
(no queued wakes)
PI_WATCH_EXTENSION: not loaded - approve Pi project trust once per clone, then restart plain pi so ~/.no-mistakes/worktrees/016d88035d58/01M17JMAY6EF3MS9RHW8S6NRKM/.pi/extensions/fm-primary-turnend-guard.ts and ~/.no-mistakes/worktrees/016d88035d58/01M17JMAY6EF3MS9RHW8S6NRKM/.pi/extensions/fm-primary-pi-watch.ts auto-load for turn-end guard and background wake coverage; use -e ~/.no-mistakes/worktrees/016d88035d58/01M17JMAY6EF3MS9RHW8S6NRKM/.pi/extensions/fm-primary-turnend-guard.ts -e ~/.no-mistakes/worktrees/016d88035d58/01M17JMAY6EF3MS9RHW8S6NRKM/.pi/extensions/fm-primary-pi-watch.ts only if project hooks are not trusted
================================================================================
SUPERVISION OPERATING INSTRUCTIONS - primary harness: pi
================================================================================
Current state:
- Lock: held by this session; this session owns normal supervision unless away mode says otherwise.
- Away mode: inactive.
- X mode: inactive; use the default watcher cadence.
- Ordinary wake: the Pi extension already owns watcher continuity; do not arm another cycle.

Mode: Pi extension background wake.

When this session owns supervision and away mode is not active:
1. Drain first with `bin/fm-wake-drain.sh`.
   After handling all emitted wakes and reconciling open decisions and unread status lines, run the exact `--ack-through` command printed as `WAKE_ACK_REQUIRED`; until then the work remains durable for idempotent re-handling after interruption.
2. Confirm the Pi primary auto-loaded both project extensions (plain `pi` or `pi-signed`, after approving project trust once per clone); if not, restart the selected executable with `-e ~/.no-mistakes/worktrees/016d88035d58/01M17JMAY6EF3MS9RHW8S6NRKM/.pi/extensions/fm-primary-turnend-guard.ts -e ~/.no-mistakes/worktrees/016d88035d58/01M17JMAY6EF3MS9RHW8S6NRKM/.pi/extensions/fm-primary-pi-watch.ts` as a trust-free fallback.
3. First cycle only: make the one required `fm_watch_arm_pi` call.
   Use `/fm-watch-arm-pi` only as a human-entered fallback.
   Never run `bin/fm-watch-arm.sh` through Pi's bash tool because that foreground arm can wedge the agent and bypasses extension-owned cleanup.
4. If the extension says no live session holds the lock, run `bin/fm-session-start.sh` to reclaim the session lock, then call `fm_watch_arm_pi` again.
5. The extension starts `bin/fm-watch-arm.sh --restart`, keeps the child attached to the live Pi process, and owns every later successor launch.
6. Ordinary same-process session replacement (`/new`, `/resume`, `/fork`, reload) retires only the prior generation; call `fm_watch_arm_pi` once for the first cycle of the replacement session without restarting Pi.
   The generation-owner contract lives in `.pi/extensions/fm-primary-pi-watch.ts`.
7. After an actionable child close, the extension rechecks session-lock ownership and verifies one successor before it delivers the follow-up wake; its bounded fallback is defined in `docs/watcher-continuity.md`.
8. Ordinary work, turn completion, and ordinary signal, stale, check, heartbeat, or other wake handling: do not call `fm_watch_arm_pi` again because continuity is extension-owned rather than model-memory-owned.
9. An unexpected child close enters bounded exponential retry, and an exhausted retry or lost session lock is surfaced as a watcher failure instead of disappearing.
10. Missing, failed, or unhealthy cycle only: if a later notification explicitly reports one of those repair conditions, drain queued wakes, inspect the failure text, call `fm_watch_arm_pi`, and restart the selected Pi-family executable with both extensions loaded if needed.
   A redundant call while the extension owns an arm child or scheduled retry is an ownership-based `watcher: unchanged` no-op, not an independent health claim.
11. Never use shell `&` for watcher supervision.
   The arm mechanism above is extension-owned, not a model tool call, but a manual recovery probe that backgrounds, pipes, or bundles the arm is denied automatically by the PreToolUse seatbelt (`bin/fm-arm-pretool-check.sh`, wired into the turn-end guard extension at `~/.no-mistakes/worktrees/016d88035d58/01M17JMAY6EF3MS9RHW8S6NRKM/.pi/extensions/fm-primary-turnend-guard.ts`).

The supervision branch is default-on (docs/pi-supervision-branch.md): whenever this session owns the fleet lock and away mode is not active, the watcher extension hands eligible task-local rows from ordinary actionable wakes, plus selected fleet-wide heartbeat reviews, to the persistent in-process supervision branch while main-only rows remain queued for this conversation.
A no-change heartbeat outcome explicitly reported with `task=fleet` and `silent=true` is delivered silently with no rendered note, while every other routine outcome returns as an appended, rendered note that leads with ⛵ then the dim outcome text.
A captain-facing outcome instead opens exactly one follow-up turn on this conversation - MAIN must produce its captain-visible response in that turn, and no separate note is printed here.
Before MAIN steers, controls lifecycle, or cleans up a task, claim its lease with `bin/fm-lease.sh claim <task>` and release it afterwards; a refused claim means the branch is acting on that task right now.
This conversation still receives every other fleet-wide or unresolvable wake, the branch's wakes when it is unavailable or away mode is active, and every watcher-failure alarm regardless, so the arm and repair contract above is unchanged.
Treat the merged fleet event as already handled for fleet operations: MAIN must not re-drain, re-run, or acknowledge it.
Separately, MAIN applies judgment about whether and how to surface, summarize, reference, or incorporate a merged sailboat outcome in the captain conversation; event ownership does not decide the conversational treatment.
Read the durable outcome store with the fm_branch_outcomes tool when the captain asks what happened.

The turn-end guard extension lives at `~/.no-mistakes/worktrees/016d88035d58/01M17JMAY6EF3MS9RHW8S6NRKM/.pi/extensions/fm-primary-turnend-guard.ts`.
The watcher extension lives at `~/.no-mistakes/worktrees/016d88035d58/01M17JMAY6EF3MS9RHW8S6NRKM/.pi/extensions/fm-primary-pi-watch.ts`.
Both are tracked, project-local `.pi/extensions/*.ts` files that Pi auto-discovers once the project is trusted; `bin/fm-session-start.sh` reports when the running Pi session has not loaded both required extensions.


================================================================================
READ-ONCE CONTRACT
================================================================================
Everything below is printed in full for this session start: every state/*.meta,
a compact data/backlog.md listing, a bounded tail of every state/*.status,
data/projects.md, data/secondmates.md, data/captain.md, data/captain-shared.md,
and data/learnings.md.
Do NOT re-read any of them after reading this digest, and do NOT bulk-read
data/backlog.md or state/*.status: re-reading everything defeats the entire
point of this command.

Go to a source directly only when:
  - this digest flagged it ABSENT (then rebuild or create it per AGENTS.md),
  - its contents looked unparseable or corrupt,
  - an individual full status log is needed for older wake-event history, or a
    status line was capped and its tail matters (each task's full log path is
    printed with its tail),
  - a full task body is needed (tasks-axi show <id> --full, or data/backlog.md),
  - the backlog listing disclosed omitted queued items and this turn needs them,
  - the NETWORK CHECKS section reported its checks still IN PROGRESS and this
    turn needs their verdict (bin/fm-startup-network.sh report),
  - or a STARTUP TRUNCATED banner named the stage that would have printed it, in
    which case that stage's sources were never emitted and must be reconciled.

================================================================================
FLEET STATE
================================================================================

data/backlog.md
--------------------------------------------------------------------------------
(present, empty)

Work under way (state/*.meta)
--------------------------------------------------------------------------------
(none)

Orphan status logs (state/*.status without matching .meta)
--------------------------------------------------------------------------------
(none)

AFK
--------------------------------------------------------------------------------
absent

================================================================================
NETWORK CHECKS
================================================================================
IN PROGRESS - the deferred network checks have not finished yet.
NOT yet confirmed: GitHub authentication, dead-secondmate relaunch, secondmate convergence, pending handoff delivery, and project clone refresh with its drift reporting.
Started 1s ago, bounded at 120s.
Only a FAILED or otherwise actionable result arrives as a `check: startup-network` wake; a clean success stays silent.
The durable result is readable on demand with ~/.no-mistakes/worktrees/016d88035d58/01M17JMAY6EF3MS9RHW8S6NRKM/bin/fm-startup-network.sh report; until it finishes, treat none of it as confirmed.

================================================================================
CONTEXT
================================================================================

data/projects.md
--------------------------------------------------------------------------------
(present, empty)

data/secondmates.md
--------------------------------------------------------------------------------
(present, empty)

data/captain.md
--------------------------------------------------------------------------------
(present, empty)

data/captain-shared.md (shared, main-authoritative, read-only in secondmate homes)
--------------------------------------------------------------------------------
(present, empty)

data/learnings.md
--------------------------------------------------------------------------------
(present, empty)

================================================================================
NEXT STEP
================================================================================
Follow the supervision operating instructions block above for harness 'pi'.
This script never starts supervision itself.

The digest above is complete for this session start. The READ-ONCE CONTRACT
section near the top of it governs what may still be read from disk.

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

🔧 **Review** - 1 issue found → auto-fixed ✅
  • 🚨 tests/fm-pr-check-security.test.sh:793 - Contradicts the required criterion “keep every still-live PR-check security/trust test.” The diff deletes all of test_private_artifact_paths_refuse_symlinks_and_directories, including live fm_pr_poll_publish_prepared refusal cases for pre-existing symlink/directory destinations, and all of test_complete_single_link_validation, including live PR-poll hard-link validation plus custom-check source/trust hard-link and private-mode checks. Existing tests only verify normal single-link publication and post-rename corruption, not these boundaries. Split out and retain the non-migration cases rather than deleting the mixed tests wholesale.

🔧 Fix: Restore live PR-check security coverage
✅ Re-checked - no issues remain.

✅ **Test** - passed

✅ No issues found.

  • bin/fm-test-run.sh tests/fm-pr-check-security.test.sh
  • bin/fm-test-run.sh tests/fm-session-start.test.sh
  • Manual FM_HOME=&lt;evidence&gt;/custom-check-home bin/fm-check-register.sh demo checks for hard-linked source refusal, successful private registration, and hard-linked trust refusal
  • Manual FM_HOME=&lt;evidence&gt;/session-home FM_ROOT_OVERRIDE=&lt;worktree&gt; FM_BACKEND=orca bin/fm-session-start.sh end-to-end session start, completion-record persistence, and deferred network-stage reporting
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

@greptile-apps

greptile-apps Bot commented Aug 29, 2026 •

Copy link
Copy Markdown

Confidence Score: 5/5

The PR appears safe to merge because no blocking failure remains.

No blocking failure remains.

Reviews (3): Last reviewed commit: "no-mistakes(ci): Fixed both failing CI c..." | Re-trigger Greptile

Every registered home already carried both completion markers, and no
installer still creates pre-migration checks. Remove the one-time migrate
script, its bootstrap/watch/teardown/docs surface, and migration-path tests
without weakening live check-trust or PR-poll authentication.
…cile setup to use the public status-marking interface, preventing false watcher exits. Made remote-job shutdown deterministic by stopping the complete worker tree before tampering. Verified both affected test suites, repeated inactive reconciliation, shell syntax, and git diff checks