Repository navigation
feat(sweep): stale-claim reclaim sweep with capacity holds and held-row exclusion - #4225
RooseveltAdvisors wants to merge 164 commits into
Conversation
…firstmate-main-with-12-or-f1 # Conflicts: # .github/workflows/ci.yml # bin/fm-spawn.sh # bin/fm-test-run.sh # docs/architecture.md # tests/fm-bearings-board-render.test.sh
…unchenguid#3458) Upstream: kunchenguid#3458 State: open Slug: herdr-task-labels Upstream PR kunchenguid#3458 (open). Title-based Herdr task labels + duplicate guards. Spawn label wiring ships with kunchenguid#4225 (shared bin/fm-spawn.sh). House tracking: one commit ↔ one upstream PR. When this PR merges to origin/main, drop this commit from house main (rebase onto new origin/main or reset residue without this feature).
…id#4225) Upstream: kunchenguid#4225 State: open Slug: stale-sweep-capacity Upstream PR kunchenguid#4225 (open); supersedes closed kunchenguid#3720. Also sibling kunchenguid#4224. Includes bin/fm-spawn.sh and bin/fm-captain-hold.sh full house delta (capacity + kunchenguid#3712 actor bits + kunchenguid#3458 label bits) and bin/fm-teardown.sh full house delta (capacity release + kunchenguid#3657 retire-secondmate authority), because those files are not cleanly separable at tip. House tracking: one commit ↔ one upstream PR. When this PR merges to origin/main, drop this commit from house main (rebase onto new origin/main or reset residue without this feature).
…unchenguid#3657) Upstream: kunchenguid#3657 State: open Slug: retire-secondmate-authority Upstream PR kunchenguid#3657 (open); duplicate tracker kunchenguid#4219. Teardown --retire-secondmate implementation lives in the kunchenguid#4225 commit (shared bin/fm-teardown.sh); this commit carries the rest of the authority surface (fleet-view, remote control, docs, safety tests). House tracking: one commit ↔ one upstream PR. When this PR merges to origin/main, drop this commit from house main (rebase onto new origin/main or reset residue without this feature).
…d make two live-fixture tests hermetic under main's stricter semantics - fm-spawn: the launch brief now leads with the worker-role contract (main's ordering, pinned by its first-line assertions), so the short herdr title is read from the original source brief the overlay was built from; kinds that never enter the overlay still fall back to $BRIEF. - fm-beads-actor: bd's audit sidecar (.beads/interactions.jsonl) is opt-in per database; enable it in the fixture so actor attribution is recorded on every host regardless of the operator's global bd config. - fm-control-relaunch: the recorded relaunch case now seeds its recorded pane so the endpoint reads agent-free-but-present under main's stricter stub; a structurally-gone pane correctly takes the rebind path and mints a fresh tab.
…es PR's per-target authority flag The authority gate (kind=secondmate requires --retire-secondmate) runs before the liveness-lock check, so this main-only case must name its target to reach the retry path it asserts.
|
| set -eu | ||
| env -u CI npm install -g @beads/bd |
There was a problem hiding this comment.
Mutable Package Executes In CI
This step installs an unpinned @beads/bd release and explicitly enables its lifecycle and binary-download behavior. A newly published or compromised release could alter serial test results and generated artifacts, even though this job has only read-only repository permissions and no referenced secrets. Pin and verify the required release so CI does not execute mutable registry code on every run.
How this was verified: The workflow installs an unversioned package with lifecycle execution enabled before running the serial test suite.
… scan; drop duplicate stubs
…ed for the executor. (1) Stock macOS Bash snapshot compatibility: this PR adds a 19th test to tests/fm-fleet-snapshot-view.test.sh (test_view_renders_kind_labeled_cleanup_candidates, from commit 3039060), but .github/workflows/ci.yml still expected 18. Changed the check and its error message to 19. Verified: the suite prints 19 ok lines locally. (2) Lint 1 and Lint 2: the merge with main left two definitions of make_herdr_stub in tests/fm-control-relaunch.test.sh. Bash keeps the later one (from main), so the PR's earlier copy never ran and ShellCheck flagged it (SC2329). Deleted the unused copy. The herdr-label test already works with main's stub, because merge-adaptation commit 679e922 seeds herdr-pane for it. Verified: the full suite passes (74 ok, rc=0), fm-lint on the changed files is clean, and actionlint reports 3 workflow files valid. (3) Behavior portable serial 4: tests/fm-beads-actor.test.sh used to skip in CI only because bd wasn't installed. This PR now installs bd, but the npm tasks-axi only supports markdown, so the suite reached its spawn step and failed with 'Unsupported backend "beads"'. Added a one-time check at the top: it creates a scratch beads home, runs bd init and tasks-axi list, and skips the whole suite with an explicit reason if that fails. This is the same check tests/fm-stale-sweep.test.sh uses. Verified: with the local beads-capable tasks-axi 0.2.6, all 3 tests run and pass; with a stand-in tasks-axi that only supports markdown, the suite prints 'ok - skipped (the installed tasks-axi cannot operate the beads backend)' and exits 0. Side effect: CI installs the npm tasks-axi, so these actor-attribution tests will be skipped there, as they were before this PR. That is the open Greptile finding ci-7, which still awaits a decision. Nothing else changed
…n bin/fm-teardown.sh (exit 251, reason=memory, about 8.4 GB RSS under CI's 12 GiB address-space cap per lint process). Every other file in the partition passed. This PR caused it. I reproduced it locally with `ulimit -v 12582912`: the base commit's teardown passes under the cap and this PR's version fails. Two PR changes push it over. The PR adds the fm-capacity-lib source, and it grows fm-backlog-transition-lib.sh, which ShellCheck expands twice for teardown: once from teardown's own directive and once through fm-public-followup-lib -> fm-x-lib. fm-tasks-axi-lib is also expanded more than once. Invariant: each library should be expanded only once in a lint root's ShellCheck source graph, following the earlier fix in commit 72b63ee (kunchenguid#5753). I checked every source directive this PR added that reaches teardown (fm-capacity-lib -> fm-tasks-axi-lib). The duplicates were the teardown-level directives for fm-tasks-axi-lib.sh and fm-backlog-transition-lib.sh. Fix: in bin/fm-teardown.sh only, I changed those two directives to `# shellcheck source=/dev/null`, the repo's existing idiom for a source that ShellCheck should not follow, and added a comment explaining why. ShellCheck still sees both libraries once, through fm-x-lib's directed expansion. The runtime `.` lines are byte-identical, so behavior does not change. Checks: `ulimit -v 12582912; FM_LINT_REQUIRE_BOUNDS=1 FM_LINT_JOBS=1 bin/fm-lint.sh bin/fm-teardown.sh` now exits 0 with no findings at about 7.7 GB peak RSS, down from an out-of-memory failure (rc=251). `bash -n` passes
…es are uncommitted, for the executor to commit. Expect one CI consequence of your ci-3 choice: CI's required lane installs the npm tasks-axi, which only supports markdown, so tests/fm-stale-sweep.test.sh will now fail there until that lane installs a tasks-axi that can operate the beads backend. **ci-1: relative [beads] path** (bin/fm-stale-sweep.sh, fm_stale_read_beads_config). Rule: a relative graph path is resolved against FM_HOME, never against the caller's working directory. The sweep now prefixes "$FM_HOME/" to a relative `[beads] path`, the same way the owning-home check fm_stale_home_beads_path already resolves it against the home, so the sweep's graph path and the owning-home graph paths still compare equal. - New test test_relative_beads_path_resolves_against_the_home sets `path = "../fm/.beads"` and runs the sweep from a directory two levels below an unrelated one. It expects exit 0 and the dead row listed. - It failed before the fix ("beads graph path ../fm/.beads is not a directory") and passes after it. My first version ran from a directory at the same depth as the home, so it passed even without the fix; I moved it one level deeper. **ci-2: capacity hold/release backlog path** (bin/fm-capacity-lib.sh, fm_capacity_axi). Rule: capacity holds and releases use the same configured markdown backlog file as every other transition. The hardcoded `$data/backlog.md` is replaced with fm_backlog_markdown_file, the configured-path resolver in fm-backlog-transition-lib.sh. Both callers (fm-spawn.sh and fm-teardown.sh) already source that library, and capacity-lib does not source it itself, which keeps the ShellCheck expansion of teardown unchanged. - tests/fm-capacity-hold.test.sh has a new end-to-end test, test_configured_backlog_holds_and_releases_in_the_same_file. The home's .tasks.toml sets `[markdown] path = "data/queue.md"`. A real fm-spawn pool-full refusal records the hold in queue.md, then a real fm-teardown releases it from queue.md. No data/backlog.md is ever created, and the newer same-pool hold stays held. - It failed before the fix ("spawn did not record the hold in the configured backlog") and passes after it. - Small fixture changes to support it: make_spawn_fakebin takes an optional pool, make_teardown_case takes an optional backlog path, and held_field takes an optional backlog path. **ci-3: tests no longer pass when the beads backend is missing** (tests/fm-stale-sweep.test.sh, require_tasks_axi_beads). A tasks-axi that cannot operate the beads backend is now a hard `fail`. It is only skipped under FM_LIVE=0, the explicit local opt-out tests/lib.sh already defines. This guard covers the apply, held-row scan, blocked/pinned scan and scan-to-apply hold race tests. **Not changed:** fm_stale_axi in fm-stale-sweep.sh still names `$home/data/backlog.md` in its markdown branch. I left it because the sweep only acts on rows whose owning home uses the same beads graph, so that branch can't run, and you said nothing else should change. **Checks run:** - tests/fm-stale-sweep.test.sh: all passed, using the local tasks-axi that can operate the beads backend. - tests/fm-capacity-hold.test.sh: 5/5 passed. - tests/fm-gotmp.test.sh: passed. - fm-lint on the four changed files: exit 0
…tasks-axi that can operate the beads backend. The change is in .github/workflows/ci.yml and is uncommitted, for the executor to commit. The ci-3 hard-failure check in tests/fm-stale-sweep.test.sh is unchanged. **The PR #53 branch itself fails one test, so I pinned a later commit from the same fork.** I built the head of RooseveltAdvisors:fm/tasks-axi-beads-backend (90f8c96, version 0.2.5) and ran tests/fm-stale-sweep.test.sh against it. It failed `not ok - a pinned blocker must not set tasks-axi's blocked bit (missing: 'blocked: no')`, because that branch doesn't yet ignore pinned blockers. The fork's main branch has PR #53's beads backend merged (as fork PR #1), plus later beads fixes, pinned-blocker handling and the upstream 0.2.6 release. That matches the local fork build, which reports 0.2.6 and handles pinned blockers. So I pinned fork main at 8c6f96eb58924fd094053eb1a57dd57c64655bbd. **Change:** in the `tests-portable-serial` job (all 9 shards), the step `npm install -g tasks-axi` is replaced by a step that: - fetches only that commit, with the repo and SHA set in the step's `env`; - checks that HEAD equals the pinned SHA; - runs `npm install --ignore-scripts`, then `npm pack` (its prepack runs `tsc`); - runs `npm install -g` on the tarball, then prints `tasks-axi --version`. **Side effect:** shard 4's tests/fm-beads-actor.test.sh also stops skipping in CI and now runs for real (it passes, as below). Other lanes still install the npm tasks-axi. **Local checks:** - I ran the step's exact commands against a temporary prefix. It built and installed tasks-axi 0.2.6. - With that binary on PATH, tests/fm-stale-sweep.test.sh exited 0 with 15/15 ok, and nothing skipped or failed. - tests/fm-beads-actor.test.sh exited 0 with 3/3 ok, nothing skipped. - actionlint on ci.yml was clean. I could not run the GitHub job itself here, so "Behavior portable serial 2" passing is expected from these local results but not yet confirmed
Intent
Take ownership of the Beads task
fm-stale-sweep-held-row-filter-20260909and update the Firstmate stale-claim sweep so held rows are not counted as reclaimable. The reported incident found 36 dead-endpoint rows presented as reclaimable, but only 4 were validly reclaimed and 32 were correctly refused because they were held. Preserve the 4 valid reclaims and every existing held row. Preserve the scan-to-apply race refusal. Add focused coverage for a row already held during scan and a row that becomes held between scan and apply. Run the normal no-mistakes delivery path with the authorized yolo posture, contribute upstream without force-push, and leave merge decisions to the supervisor.What Changed
bin/fm-stale-sweep.sh: a dry-run-by-default sweep that reclaims stalein_progressBeads claims past the staleness threshold after positively proving the owning home's endpoint is dead. Held rows (thetasks-axi-heldlabel) are excluded before endpoint classification so check/dry-run output can never present a held row as reclaimable, and the apply path re-proves the row is still in flight and unheld under the owning home's per-task record lock, so a row already held at scan time or held between scan and apply is refused rather than raced; check/arm/disarm modes compose with the watcher under bounded budget and timeout knobs (FM_STALE_SWEEP_BD_TIMEOUT,FM_STALE_SWEEP_BUDGET_SECS,FM_STALE_SWEEP_INTERVAL).bin/fm-capacity-lib.shcapacity holds: when the dispatch pool is full, dispatches hold instead of dropping, with fallback-identity holds released via the canonical project-root identity..tasks.tomlrenamed to.tasks.toml.example, and new or extended suites (stale-sweep, capacity-hold, backlog atomicity/row-probe, beads-actor, teardown, bootstrap, lint).Risk Assessment
✅ Low: The change is a minimal, well-understood scan filter whose external contract was empirically verified, whose race backstop already existed at apply time, and whose two new tests are behavioral rather than source-grep; only a one-line documentation gap remains.
Testing
Ran the targeted stale-sweep suite at the fix commit (all pass, including the two new held-row tests), confirmed the new tests fail against the pre-fix sweep (regression reproduced), and captured the sweep's real dry-run and --apply CLI tables showing held rows excluded from the scan and the scan-to-apply hold race refused while the 4-style valid reclaims still proceed; worktree left clean with no source modifications.
Evidence: Sweep dry-run table: captain-held dead row excluded from stale candidates
Source: Sweep dry-run table: captain-held dead row excluded from stale candidates
Evidence: Sweep --apply table: row held between scan and apply refused, valid dead row still reclaimed
Source: Sweep --apply table: row held between scan and apply refused, valid dead row still reclaimed
Evidence: Pre-fix regression check: held-row scan test fails before the fix, passes after
Source: Pre-fix regression check: held-row scan test fails before the fix, passes after
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
bin/fm-backlog-transition-lib.sh- merge conflict rebasing onto origin/maindocs/configuration.md:547- The 'Stale-claim sweep' section documents that the apply path re-proves a row is 'still in flight and unheld', but not the new scan-level contract that held rows (the tasks-axi-held label) are excluded from the candidate scan entirely, so check mode and dry runs no longer surface them at all. This is a user-visible change to the check-mode contract introduced by bin/fm-stale-sweep.sh:549; one clause in this paragraph would keep the operator-facing contract accurate. No code concern: the filter is correct (verified empirically that tasks-axi hold sets exactly label 'tasks-axi-held' on beads rows for all hold kinds, keeps status in_progress, and that unhold removes the label so unheld rows return to the scan), and the apply-time race refusal is intact.✅ **Test** - passed
✅ No issues found.
bash tests/fm-stale-sweep.test.shat 576b5c0 — full stale-sweep suite passes, including the two new focused teststest_held_row_is_excluded_from_scan(row already held during scan) andtest_apply_refuses_row_held_after_scan(row becomes held between scan and apply, refused with hold and in_progress state preserved, other valid dead row still reclaimed)Regression check: revertedbin/fm-stale-sweep.shto parent 576b5c0^ and re-ran the suite — the held-row scan test fails with 'a row already held during scan must be excluded from stale candidates (unexpected: fm-dead-row)', proving the new coverage detects the reported incident behavior; fix restored afterward (worktree clean, HEAD = 576b5c0)Product-level CLI transcript: captured the sweep's actual dry-run table on a fixture with a captain-held dead row — the held row is absent from candidates and the count excludes it (6 stale candidates: 1 dead), artifactheld-row-scan-dry-run.txtProduct-level CLI transcript: captured--applyoutput where the row becomes held after the scan — verdict 'reclaim failed: row changed under the sweep (state=in_flight held=yes blocked=no)', row not reopened, no reclaim note, and the valid dead row still shows 'reclaimed 1', artifactheld-race-apply-refusal.txt✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.