feat: automate stow on session re-emits and heartbeats - #2947
Open
bingb0t5 wants to merge 9 commits into
Open
Conversation
…ss gates Adds the two triggers from data/fm-auto-stow/report.md so the captain no longer has to type /stow to keep memory current, without a new daemon, watcher, or cascade: - bin/fm-session-start.sh prepends a STOW DUE line to a compact/clear session-start re-emit when state/.last-stow is missing or older than FM_AUTO_STOW_INTERVAL_SECS (default ~24h), silent when current. - AGENTS.md section 8 rule 4 now also checks that same marker on a heartbeat wake, using the same larger-than-heartbeat interval, so a pass runs at most once per interval rather than on every wake. - The stow skill touches state/.last-stow only at the end of a pass it can call reset-safe, mirroring state/.last-heartbeat's bare-mtime marker. Away-mode heartbeats stay bash-only and unaffected: they never reach an LLM turn to run /stow in, per the existing away-daemon design.
Promote the last-stow marker contract out of the cascade heading so a secondmate home still throttles automatic /stow. Pin the stale re-emit age assertion to a 9xxxx band instead of the prefix 900. Document that default Pi branch supervision does not run heartbeat /stow, and leave that wiring as follow-up (kunchenguid#2944) rather than editing fm-branch-prompt.sh.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Reviews (4): Last reviewed commit: "no-mistakes: apply CI fixes" | Re-trigger Greptile |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
Implement automatic /stow so the captain does not have to type it.
Two triggers, no new daemon, watcher, or second cascade:
(1) On session-start compact/clear re-emit, prepend a STOW DUE instruction to the digest when state/.last-stow-attempt is missing or older than FM_AUTO_STOW_INTERVAL_SECS (default ~24h); stay silent when current or when the session could not verify fleet-lock ownership.
(2) On heartbeat wake handling (AGENTS.md section 8 rule 4), add one staleness-gated /stow instruction using that same larger interval so a pass runs at most once per interval rather than on every heartbeat wake.
Touch state/.last-stow only at the end of a reset-safe /stow pass. Touch state/.last-stow-attempt at the end of every /stow pass, reset-safe or not, so a sticky exception still throttles automatic retriggering. Away-mode heartbeats stay bash-only.
Executable tests cover the digest line's staleness gate by exercising fm-session-start.sh's real output, never by grepping source.
Accepted decision C: skip wiring heartbeat /stow into the Pi supervision branch; do not edit fm-branch-prompt.sh. Document that gap and file follow-up #2944. Compact/clear re-emit remains the automatic path on default Pi.
Also applied remaining review auto-fixes: promote the marker-touch instructions out of the cascade heading so secondmate homes still throttle, and pin the stale-marker age assertion to a 9xxxx band instead of the prefix 900.
This PR targets https://github.com/bingb0t5/firstmate; the captain cannot merge upstream themselves.
What Changed
STOW DUEinstruction to lock-owning compact/clear session re-emits, with a configurable 24-hour default interval./stowduring eligible heartbeat handling and track both attempted and reset-safe passes so unresolved exceptions remain throttled.Risk Assessment
✅ Low: The change is well-bounded, satisfies the automatic stow intent and prior fixes, and introduces no substantiated merge-blocking source risk.
Testing
The focused session-start suite passed, including lock ownership, default and custom staleness intervals, attempt-marker throttling, read-only silence, and ordinary-startup exclusion; a reviewer-visible CLI transcript demonstrates the real missing, fresh, and stale marker behavior. No screenshot was captured because this is a CLI digest change with no rendered UI.
Evidence: Automatic stow session-start transcript
Source: Automatic stow session-start transcript
Missing and stale markers emit STOW DUE before BOOTSTRAP; a fresh marker emits zero STOW DUE lines.Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 1 issue found → auto-fixed ✅
bin/fm-session-start.sh:364- FM_AUTO_STOW_INTERVAL_SECS accepts any nonzero digit string, but[cannot compare values outside the shell's integer range. For example, with a stale marker andFM_AUTO_STOW_INTERVAL_SECS=999999999999999999999, the comparison errors and|| return 0silently suppressesSTOW DUE. Validate the configured value against a supported upper bound before using it.🔧 Fix: Cap automatic stow interval safely
✅ Re-checked - no issues remain.
✅ **Test** - passed
✅ No issues found.
bash tests/fm-session-start.test.shRealbin/fm-session-start.sh --reemitchecks for missing, fresh, and 90000-second-oldstate/.last-stow-attemptmarkers using the session-start test harness; transcript captured withteegit status --shortafter testing to confirm no transient worktree artifacts remained✅ **Document** - passed
✅ No issues found.
🔧 **Lint** - 1 issue found → auto-fixed ✅
🔧 Fix: Fix numeric stow interval lint comparison
✅ Re-checked - no issues remain.
✅ **Push** - passed
✅ No issues found.