feat(hermit): daily midnight auto-close + narrow auto-archive skip#133
Merged
Conversation
Daemons stay in_progress for days when operators chat continuously, so the existing 12h-inactivity close never trips and reflect/weekly-review/brain silently degrade. Adds a midnight daily-auto-close routine with a 10-min lull queue/drain: routine queues state/pending-close.json if the operator is active, heartbeat-precheck drains the flag on the next tick where the lull appears (bypasses active-hours/tick gates). The closed_via:auto skip in reflect-precheck and weekly-review's autonomy calc is narrowed to only-empty archives (operator_turns:0); daily-lull closes with real operator content now reach the evidence surfaces. Also clears pending-close.json on operator-invoked /session-close so a queued flag can't fire AUTO_CLOSE against the next session.
…chive predicate Addresses review feedback on the daily-auto-close bridge (PR #133): - Move the pending-close drain above the HEARTBEAT.md SKIP gates so it fires at tick cadence even when HEARTBEAT.md is absent or has no checklist items. - Guard the missing-last-op fail-open on queued_at being within 24h, so a stale flag from a crashed prior session can't auto-close a fresh session whose last-op clock has not yet been seeded. - Extract the duplicated `closed_via:auto && operator_turns:0` predicate into a shared isEmptyAutoArchive helper consumed by reflect-precheck and weekly-review. - Fix the session-close doc seam (auto-close path now references step 8 explicitly instead of duplicating the cleanup prose) and hoist the duplicated HERMIT_NOW resolution to module scope. 5 new drain tests cover the moved gate, the staleness guard, and the unaffected lull-check path.
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.
Summary
Verification
bash plugins/claude-code-hermit/tests/run-all.sh, 341 passed, 0 failed at HEAD311b7e1.Notes
Long-running daemon sessions never archived because the existing 12h-inactivity auto-close in
heartbeat-precheck.jsnever trips when operators chat continuously. With no archives, cross-session learning (reflect,weekly-review,hermit-brain) silently degrades. This PR adds a daily midnightdaily-auto-closeroutine with a 10-min lull check: the routine queuesstate/pending-close.jsonif the operator is currently active, then the heartbeat-precheck drains the flag on the next tick where the lull arrives (bypasses active-hours / tick-count / micro-proposal gates).The
closed_via: autoskip inreflect-precheck.jsandweekly-review.js's autonomy calc was narrowed from "all auto archives" to "only-empty (operator_turns: 0)" — chatty-daemon midnight closes carry real operator content and now reach the evidence surfaces, while truly empty 12h-inactivity archives still get excluded.Followups baked in by code-review iteration:
heartbeat-precheckdrain fail-opens whenlast-operator-action.jsonis absent or malformed (treats as "idle indefinitely" per the skill spec)./session-closenow also clearspending-close.jsonafter archive success (was previously only on--auto), so a queued flag can't fireAUTO_CLOSEagainst the next session.tests/test-auto-close.shcover the drain paths, the empty-12h exclusion, and the routine-prompt prefix invariant.