Skip to content

fix(bin): suppress inactivity alerts for captain-held work - #4171

Open
black0rpheus wants to merge 10 commits into
kunchenguid:mainfrom
black0rpheus:fm/hold-for-captain-suppression
Open

black0rpheus wants to merge 10 commits into
kunchenguid:mainfrom
black0rpheus:fm/hold-for-captain-suppression

Conversation

@black0rpheus

Copy link
Copy Markdown

Intent

Prevent completed work awaiting a captain decision from generating repeated inactivity alerts while preserving its evidence and local work unchanged.

What Changed

  • Skip inactive terminal reconciliation for tasks with an open captain hold before endpoint or current-state inspection, preserving task records and local work unchanged.
  • Document the suppression behavior and add coverage for dirty preserved work, clean local-only branches, repeated scans, and recent-task lookup ordering.

Risk Assessment

✅ Low: The change is narrowly scoped, uses the authoritative captain-hold predicate after cheap eligibility checks, preserves held-task evidence, and includes behavioral regressions without introducing unrelated components.

Testing

The focused regression suite passed, and isolated live CLI scenarios proved suppression and preservation for dirty and clean captain-held work, reproduced the old alert on the base implementation, and confirmed non-held or unreadable-hold cases still alert normally.

  • Live validation: ✅ go - 4 of 4 scenarios driven live against the product
Scenario Result Live Evidence
Repeated inactivity scans of dirty completed work awaiting the captain emit no alert and preserve all evidence and local changes ✅ pass live HOLD_FOR_CAPTAIN live product validation transcript: Scenario 1 shows three scans with zero wakes/outcomes and unchanged metadata, status, backlog, HEAD, and dirty worktree.
An absent worker with a clean completed local-only branch awaiting landing approval remains held and unchanged ✅ pass live HOLD_FOR_CAPTAIN live product validation transcript: Scenario 2 shows zero inactivity wakes, a clean worktree, and unchanged metadata, status, backlog, and HEAD.
Completed work without an open captain hold still generates the normal inactivity alert ✅ pass live HOLD_FOR_CAPTAIN live product validation transcript: Scenario 3 records real current state as done and one queued inactivity alert.
A captain-hold lookup failure cannot silently suppress an eligible terminal alert ✅ pass live HOLD_FOR_CAPTAIN live product validation transcript: Scenario 4 records predicate exit 2 and one queued fail-safe inactivity alert.
Evidence: HOLD_FOR_CAPTAIN live product validation transcript

Source: HOLD_FOR_CAPTAIN live product validation transcript

LIVE PRODUCT VALIDATION: HOLD_FOR_CAPTAIN inactivity suppression

Scenario 1: dirty completed work with absent endpoint remains held and unchanged across repeated startup scans
captain hold predicate:
OPEN (exit 0)
scan 1: inactive wakes=0, pending outcomes=0
scan 2: inactive wakes=0, pending outcomes=0
scan 3: inactive wakes=0, pending outcomes=0
meta unchanged: yes
status evidence unchanged: yes
captain-held backlog unchanged: yes
branch HEAD unchanged: yes
dirty work unchanged: yes
preserved dirty entry: ?? preserved-unlanded.txt

Scenario 2: clean completed local-only work with absent endpoint remains held and unchanged
inactive wakes after clean scan: 0
clean worktree remains clean: yes
clean metadata/status/backlog/HEAD unchanged: yes/yes/yes/yes

Scenario 3 (adversarial boundary): equivalent completed work without a captain hold still emits one inactivity alert
real current-state read:
state: done · source: status-log · completed but not held for captain
actionable: inactive terminal outcome awaiting captain presentation: child=completed-not-held state=done pr=https://example.test/live/control/1
queued inactivity records:
1789067715	1	check	inactive-outcome:36aa8326e5f34f273e5b27b3e2244c99	inactive terminal outcome awaiting captain presentation: child=completed-not-held state=done pr=https://example.test/live/control/1
control alert count: 1

Regression counterfactual: same real held task on base vs target executable
target commit scan:
target inactive alert count: 0
base commit scan:
actionable: inactive terminal outcome awaiting captain presentation: child=held-counterfactual state=done pr=https://example.test/live/counterfactual/1
base inactive alert count: 1
1789067755	1	check	inactive-outcome:c15a0068a426c21fe38a1945e20c12de	inactive terminal outcome awaiting captain presentation: child=held-counterfactual state=done pr=https://example.test/live/counterfactual/1

Scenario 4 (fail-safe): unreadable captain-hold source does not suppress an eligible terminal alert
captain hold predicate exit: 2 (2 means unreadable/cannot establish)
actionable: inactive terminal outcome awaiting captain presentation: child=unreadable-hold state=done pr=https://example.test/live/failsafe/1
queued inactivity record:
1789067789	1	check	inactive-outcome:e41fa8d20a5909eaa54f4c9201bffce9	inactive terminal outcome awaiting captain presentation: child=unreadable-hold state=done pr=https://example.test/live/failsafe/1
fail-safe alert count: 1

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

🔧 **Review** - 2 issues found → auto-fixed (3) ✅
  • ⚠️ bin/fm-inactive-reconcile.sh:496 - The intent is limited to “completed work awaiting a captain decision,” but this early return suppresses reconciliation for every captain-held task before determining its current state. A held in-flight task whose run silently transitions to failed will produce no inactive failure alert. Narrow suppression to tasks with authoritative completion evidence; broader suppression requires user approval.
  • ⚠️ bin/fm-spawn.sh:3042 - The cross-home worktree-slot collision scanner, retry loop, retry configuration, documentation, and associated test suite are unrelated to suppressing inactivity alerts for captain-held completed work. No stated intent requirement needs this component; remove the spawn feature and its supporting changes from this branch.

🔧 Fix applied.
1 warning still open:

  • ⚠️ bin/fm-inactive-reconcile.sh:470 - The predicate only needs the open command's exit status, but --identity forces a second tasks-axi show after the first already established an open captain hold. If that redundant read fails or times out while crew state reports done, the hold is misclassified as absent and an inactivity alert is queued. Remove --identity and the output check; use the successful exit status of open "$id".

🔧 Fix applied.
1 warning still open:

  • ⚠️ bin/fm-inactive-reconcile.sh:494 - The hold lookup runs before the cheap terminal-ledger and inactivity-age exclusions, so every recently active task triggers a new captain-hold process and repeated tasks-axi compatibility/show probes. A sufficiently populated fleet can exhaust the 10-second scan budget before reaching an actually inactive failed task, delaying its alert by another reconciliation interval. Move the ledger and age checks ahead of this predicate while retaining the hold check before current-state inspection for eligible inactive tasks.

🔧 Fix applied.
✅ Re-checked - no issues remain.

✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 4 of 4 scenarios driven live against the product
Scenario Result Live Evidence
Repeated inactivity scans of dirty completed work awaiting the captain emit no alert and preserve all evidence and local changes ✅ pass live HOLD_FOR_CAPTAIN live product validation transcript: Scenario 1 shows three scans with zero wakes/outcomes and unchanged metadata, status, backlog, HEAD, and dirty worktree.
An absent worker with a clean completed local-only branch awaiting landing approval remains held and unchanged ✅ pass live HOLD_FOR_CAPTAIN live product validation transcript: Scenario 2 shows zero inactivity wakes, a clean worktree, and unchanged metadata, status, backlog, and HEAD.
Completed work without an open captain hold still generates the normal inactivity alert ✅ pass live HOLD_FOR_CAPTAIN live product validation transcript: Scenario 3 records real current state as done and one queued inactivity alert.
A captain-hold lookup failure cannot silently suppress an eligible terminal alert ✅ pass live HOLD_FOR_CAPTAIN live product validation transcript: Scenario 4 records predicate exit 2 and one queued fail-safe inactivity alert.
  • bash tests/fm-inactive-reconcile.test.sh
  • Isolated live CLI workflow using real tasks-axi, bin/fm-captain-hold.sh hold/open, and three bin/fm-inactive-reconcile.sh scan --startup invocations for dirty held work
  • Isolated live CLI workflow for clean local-only held work with an absent endpoint
  • Live adversarial scan of completed non-held work using real bin/fm-crew-state.sh and a tmux endpoint
  • Live base-versus-target counterfactual using the base fm-inactive-reconcile.sh executable against the same open captain-held task
  • Live fail-safe scan with an unreadable captain-hold source
✅ **Document** - passed

✅ No issues found.

⚠️ **Lint** - 1 warning
  • ⚠️ linter found issues (exit code 1)

🔧 Fix applied.
1 warning still open:

  • ⚠️ linter found issues (exit code 1)
✅ **Push** - passed

✅ No issues found.

rico369 and others added 10 commits September 10, 2026 13:48
…claims

Closes the spawn-side half of the worktree-pool-collision guard pair:
bin/fm-teardown.sh's require_exclusive_worktree_slot_record (already shipped
in kunchenguid#3837) refuses to return a slot another live task's state/*.meta claims,
but nothing on the spawn side stopped treehouse from handing a fresh spawn
the same slot in the first place. spawn_worktree_slot_conflict_task scans
every locally registered Firstmate home's state/*.meta for the candidate
worktree before accepting it; a collision sends 'treehouse get' again into
the same pane (bounded by FM_SPAWN_SLOT_CONFLICT_RETRIES, default 3) rather
than adopting a contested slot, and exhausting every attempt refuses the
launch and names the task already holding it.

Fixes two pre-existing test fixtures that happened to reuse one fake pane
path across sequential spawns within a single test (fm-spawn-dispatch-profile
batch tests, fm-spawn-pool-base-freshen's submodule-pin seed helper) - real
treehouse never hands a second call the slot an earlier call's still-running
task occupies, so those fixtures needed a second, genuinely distinct slot or
an explicit teardown between reused spawns to match reality.

Fixes kunchenguid#2754, Fixes kunchenguid#3075
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-10T19:30:22.953055Z 0524ef7 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@black0rpheus

Copy link
Copy Markdown
Author

The two required workflow runs are currently marked action_required because this is the fork's first contribution. A maintainer needs to approve them before CI can run.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0524ef7591

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +474 to +475
FM_HOME="$FM_HOME" FM_STATE_OVERRIDE="$STATE" \
"$CAPTAIN_HOLD_BIN" open "$id" >/dev/null 2>&1

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Budget the hold probe before advancing the scan

When the supported FM_INACTIVE_RECONCILE_BUDGET_SECS=1 is used, this new synchronous subprocess consumes part of the per-child budget, but the subsequent state read still receives the original timeout. In test_stalled_state_read_is_bounded_and_scan_progresses, after child a times out and terminal child b is visited, the outer backstop consistently kills reconciliation after creating b's pending receipt but before writing .wake-queue; the cursor is already advanced to b, so later scans can stall on a again without surfacing b. Account for this probe in the remaining timeout or recompute the deadline before the state read and publication so detected outcomes still reach the durable wake queue.

AGENTS.md reference: AGENTS.md:L175-L175

Useful? React with 👍 / 👎.

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.

2 participants