Skip to content

fix(watcher): bound parked-crew stale wakes, harden watcher identity, and clean up review-diff refs - #9

Closed
SchokoShake wants to merge 5 commits into
mainfrom
fm/upstream-pick-3-r7
Closed

SchokoShake wants to merge 5 commits into
mainfrom
fm/upstream-pick-3-r7

Conversation

@SchokoShake

@SchokoShake SchokoShake commented Jul 22, 2026 •

Copy link
Copy Markdown
Owner

Intent

Integrate three surgical upstream firstmate bug-fix commits (upstream PR kunchenguid#743 bound stale wakes for parked crew, kunchenguid#752 make watcher process identity immune to Linux wall-clock changes, kunchenguid#722 fetch current PR head for review diffs) into this fork as PR #9. This round is a review-response commit on top of the existing branch that addresses the captain's three inline review comments on that PR; it is not a new feature.

  1. bin/fm-review-diff.sh (the one behavioral fix): fetch_pull_head previously fetched refs/pull//head into a persistent private ref refs/fm-review/pull//head that nothing ever pruned, so a long-lived pooled clone accumulated one such ref per distinct PR number over time. The private ref only ever served as a clobber-proof fetch target; the resolved SHA is what the rest of the short-lived run actually uses. Fix: capture the SHA, then delete the private ref immediately (even on a parse failure). Diff-base selection and re-review correctness are deliberately unchanged; the only change is that no ref lingers. A new regression test asserts no refs/fm-review ref remains after a review.

  2. bin/fm-wake-lib.sh (documentation only, NO behavior change): two clarifying comments the captain asked to confirm. (a) The process-identity string shape changed from the ps-lstart form to the linux-starttime/cmdline-hex form; a watcher whose identity was recorded before the upgrade mismatches exactly once and is re-armed a single time, which is a benign, self-healing one-time re-arm, now documented in a comment. (b) I traced fm_pid_identity's lock-path callers and confirmed that an empty stored identity, or a failed live read (a partial /proc read such as a zombie's empty cmdline or a short stat line, where fm_pid_identity returns non-zero WITHOUT a ps fallback), deliberately resolves to no-match in fm_watcher_lock_matches_pid, which every caller (fm_watcher_healthy, and fm-watch-arm.sh's healthy and --restart paths) maps to "not healthy -> reclaim", never a hard error. That is correct fail-safe behavior, so it is documented with a comment and no code change. A new regression test proves a partial /proc read on a live watcher reads as reclaim, not a wrongly-kept holder.

  3. bin/fm-classify-lib.sh captain-held verb: DELIBERATELY KEPT with no change. The captain asked whether to ship the speculative forward-compat path now or hold it, and said no change is requested if the forward-compat is deliberate. It is deliberate and faithful to upstream fix(watcher): bound stale wakes for parked crew kunchenguid/firstmate#743 on this fork: this fleet surfaces captain-held state via the logbook/backlog hold rather than a status-file verb, so the FM_CLASSIFY_CAPTAIN_HELD_VERB branch is inert on this fleet today but is wired end-to-end for forward-compatibility. Do not flag it as dead code; keeping it is the captain's explicit decision.

Constraints: this repository has no GitHub CI, so "no CI checks reported" means review-ready, never "CI green". The commit uses the captain's own git identity and adds no agent co-author.

What Changed

  • Gated stale/pause classification in fm-watch.sh (with the keyed contract in fm-classify-lib.sh and fm-wake-lib.sh) on harness-agent liveness so a declared paused: crew surfaces once and then rides a bounded resurface cadence instead of waking on every idle poll; a live-agent declared pause now costs one extra surface, documented in docs/architecture.md and covered by the new triage tests.
  • Derived the watcher process-identity string from Linux /proc starttime/cmdline instead of the ps -lstart wall-clock form so a system clock change no longer invalidates the recorded watcher lock, and documented that a partial /proc read or a stale pre-upgrade identity resolves to reclaim (a single benign self-healing re-arm) rather than a wrongly-kept holder.
  • Reworked fm-review-diff.sh to fetch the current refs/pull/<n>/head as the diff base and delete the private fetch ref immediately after reading its SHA (even on parse failure), so a long-lived pooled clone no longer accumulates one lingering refs/fm-review ref per reviewed PR.

Risk Assessment

✅ Low: Three surgical, well-bounded bug fixes each backed by a targeted regression test, with the only behavioral shift (a live paused crew surfacing once) being explicitly documented and test-locked as intended.

Testing

Baseline suite already passed; on top of that I ran the three directly-relevant test files (fm-review-diff, fm-watcher-lock, fm-watch-triage), all green, then proved the sole behavioral fix at product level with a before/after CLI transcript showing the pre-fix code leaking one refs/fm-review ref per distinct PR reviewed into a long-lived pooled clone (3 accumulated) while the fixed code leaves zero and still resolves the correct PR-head diff each time; I also confirmed the deliberately-kept captain-held verb is wired end-to-end rather than dead code. No visual/UI artifact applies because this change is entirely a shell CLI/library fix with no rendered surface. Working tree left clean; transient scenario dirs removed, evidence preserved.

Evidence: Before/after end-to-end ref-leak demonstration (CLI transcript)

# BEFORE THE FIX (parent commit 2306cd2 — leaks one ref/PR) Simulating a long-lived pooled clone reviewing PRs #9, #42, #7 over time: review PR #9 -> diff shows: +fix-for-pr-9 | refs/fm-review count now: 1 review PR #42 -> diff shows: +fix-for-pr-42 | refs/fm-review count now: 2 review PR #7 -> diff shows: +fix-for-pr-7 | refs/fm-review count now: 3 Leftover private refs in the pooled clone after 3 reviews: refs/fm-review/pull/42/head -> 9456ab5 refs/fm-review/pull/7/head -> 213b9d8 refs/fm-review/pull/9/head -> 96c4771 # AFTER THE FIX (target commit 6025f7d — deletes the ref) Same scenario, same pooled clone reviewing PRs #9, #42, #7 over time: review PR #9 -> diff shows: +fix-for-pr-9 | refs/fm-review count now: 0 review PR #42 -> diff shows: +fix-for-pr-42 | refs/fm-review count now: 0 review PR #7 -> diff shows: +fix-for-pr-7 | refs/fm-review count now: 0 Leftover private refs in the pooled clone after 3 reviews: (none — refs/fm-review is empty; nothing leaked)

############################################################
# BEFORE THE FIX (parent commit 2306cd2 — leaks one ref/PR)
############################################################
warning: You appear to have cloned an empty repository.
Simulating a long-lived pooled clone reviewing PRs #9, #42, #7 over time:
  review PR #9   -> diff shows: +fix-for-pr-9        | refs/fm-review count now: 1
  review PR #42  -> diff shows: +fix-for-pr-42       | refs/fm-review count now: 2
  review PR #7   -> diff shows: +fix-for-pr-7        | refs/fm-review count now: 3
Leftover private refs in the pooled clone after 3 reviews:
  refs/fm-review/pull/42/head  ->  9456ab5
  refs/fm-review/pull/7/head  ->  213b9d8
  refs/fm-review/pull/9/head  ->  96c4771

############################################################
# AFTER THE FIX (target commit 6025f7d — deletes the ref)
############################################################
warning: You appear to have cloned an empty repository.
Same scenario, same pooled clone reviewing PRs #9, #42, #7 over time:
  review PR #9   -> diff shows: +fix-for-pr-9        | refs/fm-review count now: 0
  review PR #42  -> diff shows: +fix-for-pr-42       | refs/fm-review count now: 0
  review PR #7   -> diff shows: +fix-for-pr-7        | refs/fm-review count now: 0
Leftover private refs in the pooled clone after 3 reviews:
  (none — refs/fm-review is empty; nothing leaked)
Evidence: Reproducible demo script
#!/usr/bin/env bash
# End-to-end demonstration of the PR #9 review-response fix in fm-review-diff.sh:
# the private refs/fm-review/pull/<n>/head fetch target must NOT linger after a
# review, or a long-lived pooled clone leaks one ref per distinct PR reviewed.
set -eu

REPO=/home/metoo/.no-mistakes/worktrees/5f97ed91bec6/01KY6ZM5E1DCZH6XWCAMR0RXQB
NEW_BIN="$REPO/bin/fm-review-diff.sh"                                   # target commit (fixed)
OLD_BIN=/tmp/no-mistakes-evidence/01KY6ZM5E1DCZH6XWCAMR0RXQB/oldbin/fm-review-diff.sh  # parent commit (leaks)

export GIT_AUTHOR_NAME=demo GIT_AUTHOR_EMAIL=demo@demo GIT_COMMITTER_NAME=demo GIT_COMMITTER_EMAIL=demo@demo

# ---- Build a realistic long-lived pooled clone with a linked worktree --------
build_case() {
  local d=$1
  rm -rf "$d"; mkdir -p "$d/state"
  git init -q --bare "$d/origin.git"
  git -C "$d/origin.git" symbolic-ref HEAD refs/heads/main
  git clone -q "$d/origin.git" "$d/_seed"
  printf 'base\n' > "$d/_seed/feature.txt"
  git -C "$d/_seed" add feature.txt
  git -C "$d/_seed" commit -qm "origin baseline"
  git -C "$d/_seed" push -q origin main
  rm -rf "$d/_seed"
  git clone -q "$d/origin.git" "$d/project"          # the long-lived pooled clone
  git -C "$d/project" remote set-head origin main 2>/dev/null || true
  git -C "$d/project" worktree add -q -b fm/task-x1 "$d/wt" main
  touch "$d/state/.last-watcher-beat"
  # Distinct PR heads for three different PR numbers pushed to origin's pull refs
  local n
  for n in 9 42 7; do
    git -C "$d/wt" checkout -q -B "prtmp-$n" main
    printf 'fix-for-pr-%s\n' "$n" > "$d/wt/feature.txt"
    git -C "$d/wt" add feature.txt
    git -C "$d/wt" commit -qm "pipeline fix on PR #$n"
    git -C "$d/wt" push -q origin "prtmp-$n:refs/pull/$n/head"
  done
  git -C "$d/wt" checkout -q fm/task-x1
}

write_meta() {
  local d=$1 n=$2
  cat > "$d/state/task-x1.meta" <<META
window=fm-task-x1
worktree=$d/wt
project=$d/project
pr=https://github.com/example/repo/pull/$n
META
}

count_leaked_refs() {
  git -C "$1/wt" for-each-ref --format='%(refname)' | grep -c '^refs/fm-review/' || true
}

review_round() {
  local bin=$1 d=$2 n=$3
  write_meta "$d" "$n"
  local out
  out=$(FM_ROOT_OVERRIDE="$REPO" FM_STATE_OVERRIDE="$d/state" "$bin" task-x1 2>/dev/null)
  # Show the reviewer that the diff still resolves to THIS PR's fetched head
  local shown; shown=$(printf '%s\n' "$out" | grep -E '^\+fix-for-pr-' || echo '(none)')
  printf '  review PR #%-3s -> diff shows: %-20s | refs/fm-review count now: %s\n' \
    "$n" "$shown" "$(count_leaked_refs "$d")"
}

echo "############################################################"
echo "# BEFORE THE FIX (parent commit 2306cd2 — leaks one ref/PR)"
echo "############################################################"
D=/tmp/fm-refleak-old
build_case "$D"
echo "Simulating a long-lived pooled clone reviewing PRs #9, #42, #7 over time:"
for n in 9 42 7; do review_round "$OLD_BIN" "$D" "$n"; done
echo "Leftover private refs in the pooled clone after 3 reviews:"
git -C "$D/wt" for-each-ref --format='  %(refname)  ->  %(objectname:short)' refs/fm-review || true
echo

echo "############################################################"
echo "# AFTER THE FIX (target commit 6025f7d — deletes the ref)"
echo "############################################################"
D=/tmp/fm-refleak-new
build_case "$D"
echo "Same scenario, same pooled clone reviewing PRs #9, #42, #7 over time:"
for n in 9 42 7; do review_round "$NEW_BIN" "$D" "$n"; done
echo "Leftover private refs in the pooled clone after 3 reviews:"
leftover=$(git -C "$D/wt" for-each-ref --format='%(refname)' refs/fm-review || true)
if [ -z "$leftover" ]; then
  echo "  (none — refs/fm-review is empty; nothing leaked)"
else
  echo "$leftover" | sed 's/^/  LEAKED: /'
fi
Evidence: Combined regression-test transcript (both new tests)

ok - fm-review-diff deletes the private PR-head ref after reading its SHA ok - a partial /proc identity read resolves to reclaim, never a wrongly-kept live holder

# Regression tests for PR #9 review-response commit 6025f7d

## bin/fm-review-diff.sh — ref-leak cleanup (component 1, behavioral)
ok - fm-review-diff falls back to recorded pr_head when pull head cannot be fetched
ok - fm-review-diff fetches refs/pull/<n>/head when pr_head= is absent
ok - fm-review-diff deletes the private PR-head ref after reading its SHA
ok - fm-review-diff prefers freshly fetched PR head over a stale recorded pr_head=
ok - fm-review-diff without pr= keeps the worktree-branch diff
ok - fm-review-diff falls back to local branch with a warning when PR head is unreachable

## bin/fm-wake-lib.sh — partial /proc read biases to reclaim (component 2, doc + regression)
ok - simultaneous watcher starts leave exactly one live process
ok - fm_pid_identity is locale-invariant across LC_ALL/LC_TIME
ok - Linux process identity ignores simulated btime changes
ok - Linux process identity detects pid reuse
ok - a partial /proc identity read resolves to reclaim, never a wrongly-kept live holder
ok - killed watcher stale lock is reclaimed
ok - live watcher lock with stale heartbeat is actionable
ok - guard banner leads when down with pending wakes (re-arm-after-drain) and stays silent when fresh
ok - concurrent fm_lock_try_acquire yields exactly one winner
ok - dead-pid stale lock is reclaimed by a single acquirer
ok - concurrent stale-lock steal yields exactly one winner
ok - live steal mutex is not reclaimed
ok - live-held lock is not stolen
ok - empty mid-acquire lock keeps a minimum grace
ok - late original claimant cannot claim a recreated lock
ok - paused mid-acquire claimant backs off to active stealer
ok - watch restart refuses to signal a reused pid
ok - watch restart reports a healthy peer without attaching to it
ok - watcher self-evicts when the lock pid no longer names it
ok - arm attaches to a live fresh watcher and exits only when that cycle ends
ok - arm starts+confirms a fresh watcher on a clean lock and self-heals a dead-pid lock (never healthy off a dead pid)
ok - arm cleans child watcher and temp output on HUP
ok - arm propagates an immediate watcher wake before confirmation
ok - arm attaches to a peer watcher after child stands down and exits when peer dies
watcher: lock held by live pid 338348 but heartbeat is stale for 838113692s (>300s); inspect or stop that watcher before re-arming.
ok - arm reports FAILED and exits non-zero when no fresh watcher can be confirmed

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 1 info
  • ℹ️ bin/fm-watch.sh:383 - Behavioral change (intended, documented): as a side effect of the fix(watcher): bound stale wakes for parked crew kunchenguid/firstmate#743 agent-liveness gating in pause_state_class, an ordinary crew that declares paused: while its harness agent is still ALIVE (the common case — claude/grok/etc. stay running between turns, so fm_backend_tmux_agent_alive reports alive) is now classified none and surfaced once by surface_nonterminal_stale on the first stale poll, then absorbed onto the bounded PAUSE_RESURFACE_SECS cadence. Previously (crew_absorb_class returned paused) that first idle was absorbed silently with zero wakes. The existing test test_nonterminal_stale_paused_absorbed_then_resurfaced had to add FM_FAKE_TMUX_CURRENT_COMMAND=zsh (forcing a dead-agent read) to keep its silent-absorb assertion passing, which confirms the live-agent path now surfaces once. This is documented in docs/architecture.md ('Live or inconclusive liveness remains fail-open at that initial surface') and asserted by test_exited_declared_pause_is_bounded_but_live_gate_surfaces, so it is deliberate — flagged only so the captain confirms the one-extra-wake-per-declared-pause tradeoff is acceptable for the paused noise-reduction feature.
✅ **Test** - passed

✅ No issues found.

  • command -v tmux >/dev/null || { echo "tmux is required for e2e tests" >&2; exit 1; }; tmux -V; rc=0; for t in tests/*.test.sh; do echo "== $t =="; bash "$t" || rc=1; done; exit "$rc"
  • bash tests/fm-review-diff.test.sh — all 6 pass, incl. new fm-review-diff deletes the private PR-head ref after reading its SHA
  • bash tests/fm-watcher-lock.test.sh — all pass, incl. new a partial /proc identity read resolves to reclaim, never a wrongly-kept live holder
  • bash tests/fm-watch-triage.test.sh — all pass (covers the #743 bound-stale-wakes and captain-verb classification paths)
  • End-to-end before/after demo ref-leak-e2e.sh: reviewed PRs #9, #42, #7 in one pooled clone with the parent (leaking) vs target (fixed) fm-review-diff.sh; parent leaked 3 refs, target leaked 0 while each diff still showed the fetched PR head
  • grep FM_CLASSIFY_CAPTAIN_HELD_VERB bin/fm-classify-lib.sh — confirmed the verb constant is defined and consumed by status_is_paused_or_captain_held (wired, not dead)
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

kunchenguid and others added 4 commits July 22, 2026 11:57
* fix(watcher): bound stale wakes for exited paused crew

* no-mistakes(review): Gate pause suppression on confirmed agent death

* no-mistakes(test): Fixed stale pause cadence

* no-mistakes(document): Document dead-agent hold cadence
…anges (kunchenguid#752)

* fix(watcher): stabilize Linux process identity

* no-mistakes(document): document FM_PROC_ROOT_OVERRIDE and Linux starttime identity rationale
* fix: always fetch PR head for review diffs

Prefer a freshly fetched refs/pull/<n>/head over a reachable recorded
pr_head= so reviewers never hold a merge over a "missing" fix that already
landed on the remote PR. Recorded SHA is offline fallback only; local branch
is last resort with a warning. Store the tip under refs/fm-review/ so a later
base-branch fetch cannot clobber the compare tip via FETCH_HEAD.

* no-mistakes(test): Isolate session-start nudge tests from gate state

* no-mistakes(document): Correct review-diff documentation
… on this fork

The cherry-picked kunchenguid#743 (bound stale wakes for parked crew) reads
FM_CLASSIFY_CAPTAIN_HELD_VERB_DEFAULT, a constant upstream introduced in its
decision-hold work (kunchenguid#593) that this fork does not carry. Add only that one
constant ('captain-held', upstream's value) rather than importing the
subsystem. This fork surfaces captain-held state from the backlog hold via
logbook, not a status-file verb, so status_is_paused_or_captain_held's held
branch is inert today but forward-compatible; the dead-agent-gated pause fix
stays fully active.

Also align AGENTS.md's fm-review-diff description with the picked kunchenguid#722: the
helper now always fetches refs/pull/<n>/head fresh, with recorded pr_head= as
an offline-only fallback.

@SchokoShake SchokoShake left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed with Lookout.

Comment thread bin/fm-classify-lib.sh
# FM_CLASSIFY_CAPTAIN_HELD_VERB. This fleet surfaces captain-held state from the
# backlog hold via logbook rather than a status-file verb, so the check's
# captain-held branch is inert today but stays forward-compatible.
FM_CLASSIFY_CAPTAIN_HELD_VERB_DEFAULT='captain-held'

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

captain-held is wired end-to-end here (verb + classifier + watcher branch + tests), but per your own note nothing in this fleet actually writes a captain-held: status today — the branch is inert / forward-compatible. Flagging it for an explicit merge decision: ship the speculative path now, or hold it until the logbook→status-verb source exists? No change requested if the forward-compat is deliberate.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeping it as-is — this is deliberate forward-compat, per your "no change requested if the forward-compat is deliberate."

The captain-held verb is faithful to upstream kunchenguid#743 on this fork. This fleet surfaces captain-held state through the logbook/backlog hold rather than a status-file verb, so the status_is_paused_or_captain_held captain-held branch is inert today, but the verb + classifier + watcher branch + tests are wired end-to-end so a future logbook→status-verb source works without a follow-up change. No code change.

Comment thread bin/fm-wake-lib.sh
esac
cmdline_hex=$(od -An -v -tx1 "$proc_root/$pid/cmdline" 2>/dev/null | tr -d '[:space:]') || return 1
[ -n "$cmdline_hex" ] || return 1
printf 'linux-starttime=%s cmdline-hex=%s\n' "$starttime" "$cmdline_hex"

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two things worth confirming on the new identity format:

  • Upgrade transition: the string shape flips from the ps lstart form to linux-starttime=… cmdline-hex=…. A watcher that recorded its identity before this lands is re-read in the new form afterward, so it mismatches and is evicted/reclaimed once across the upgrade. Fine if a one-time re-arm is acceptable.
  • Partial /proc read: if stat/cmdline are readable but parsing fails (a zombie's empty cmdline, a short stat line), the function return 1s instead of falling back to ps. Confirm the lock-reclaim path treats an empty identity as 'reclaim', not 'error'.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both confirmed in 6025f7d — comments only, no behavior change.

Upgrade transition: correct as you describe. A watcher whose identity was recorded in the old ps lstart form mismatches exactly once when re-read in the new linux-starttime=… cmdline-hex=… form, so it is reclaimed and re-armed a single time across the upgrade — benign and self-healing. Documented at the top of fm_pid_identity.

Partial /proc read: traced the callers, and the failed read resolves to reclaim, not error, everywhere it matters. When stat/cmdline are readable but parsing fails (short stat line, zombie's empty cmdline), fm_pid_identity returns non-zero without a ps fallback — as you noted. Its lock-path caller fm_watcher_lock_matches_pid does current_identity=$(fm_pid_identity "$pid") || return 1, i.e. no match, and every consumer maps no-match to "not healthy → reclaim": fm_watcher_healthy returns non-zero, and fm-watch-arm.sh then re-arms (its arm path skips attach and starts a fresh watcher; its --restart path clears the lock via clear_stale_recorded_watcher_lock). None treats it as a hard error, so a failed identity read always biases toward reclaim — never toward wrongly keeping a live holder or retaining a dead one.

Since that is the intended fail-safe, I documented it in fm_watcher_lock_matches_pid (no code change) and added a regression test, test_partial_proc_identity_read_resolves_to_reclaim: it points FM_PROC_ROOT_OVERRIDE at a fake /proc with a too-short stat for a genuinely live pid, then asserts fm_pid_identity fails and both fm_watcher_lock_matches_pid and fm_watcher_healthy report reclaim (not healthy).

Comment thread bin/fm-review-diff.sh Outdated
# Fetch into a private ref so a later base-branch fetch cannot clobber the
# compare tip via FETCH_HEAD, and so we never review a stale local object.
git -C "$WT" fetch --quiet origin \
"+refs/pull/$n/head:refs/fm-review/pull/$n/head" >/dev/null 2>&1 || return 1

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR head is fetched into a persistent private ref refs/fm-review/pull/<n>/head that nothing ever prunes. In a long-lived pooled clone that reviews many PRs over time, these accumulate (one per distinct PR number). Functionally harmless — the + force-update keeps re-review correct — but consider deleting the ref after the rev-parse, or documenting a periodic cleanup, to avoid unbounded ref growth.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 6025f7d. fetch_pull_head now captures the resolved SHA and then deletes the private ref (git -C "$WT" update-ref -d refs/fm-review/pull/<n>/head) immediately after the rev-parse, including on a parse failure. Nothing lingers, so the one-ref-per-distinct-PR-number growth in a long-lived pooled clone is gone.

Behavior is otherwise identical: the resolved SHA keeps the fetched object reachable for the rest of the (short-lived) run — well inside any gc prune window — so the diff base and re-review correctness are unchanged. Added a regression test, test_pr_head_fetch_leaves_no_lingering_ref, which fetches a PR head and asserts the diff still resolves +pr-fixed with no remaining refs/fm-review/* ref.

Address PR #9 review.

fm-review-diff.sh: fetch_pull_head fetched refs/pull/<n>/head into a
persistent refs/fm-review/pull/<n>/head that nothing pruned, so a
long-lived pooled clone accumulated one ref per distinct PR number over
time. The ref was only ever a clobber-proof fetch target; capture the
resolved SHA (which keeps the fetched object reachable for the rest of
the short-lived run) and delete the ref immediately, even on a parse
failure. Diff base and re-review behavior are unchanged. Add a
regression test asserting no refs/fm-review ref lingers after a review.

fm-wake-lib.sh: document, with no behavior change, that (a) changing the
process-identity string shape re-arms a pre-upgrade watcher exactly once
(benign and self-healing), and (b) an empty or failed identity read
deliberately resolves to no-match -> reclaim in every caller, never a
hard error, so a partial /proc read biases toward reclaim. Add a
regression test proving a partial /proc read on a live watcher reads as
reclaim, not a wrongly-kept holder.
@SchokoShake SchokoShake changed the title fix(watcher): harden stale-wake handling, watcher identity, and review diffs fix(watcher): bound parked-crew stale wakes, harden watcher identity, and clean up review-diff refs Jul 23, 2026
@SchokoShake SchokoShake reopened this Jul 23, 2026
@SchokoShake

Copy link
Copy Markdown
Owner Author

Closing per captain decision.

Superseded by the logbook v2 de-fork plan (2026-08-05). P1 rebuilds fork main as upstream/main plus a small curated patch series, which brings upstream kunchenguid#743, kunchenguid#752 and kunchenguid#722 wholesale. Landing them as a surgical cherry-pick first only adds fork delta that the de-fork then has to unwind.

Not lost: these fixes arrive with the upstream merge at P1.

@SchokoShake SchokoShake closed this Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants