Prevent session logs from stranding: backstop warning, sweep, hygiene rule - #59
Conversation
… rule The per-branch Stop hook writes a log every turn but never commits it; committing is folded into a PR. Turns on `main` (merges, triage) and post-merge wrap-up turns have no PR to carry their log, so it strands untracked in dev/sessions/ (see #56). Three complementary guards: - log-session.sh gains a backstop: after writing, it warns (to stderr, never failing) about any *other* branch's uncommitted log — the leak signal — while staying quiet about the current branch's own log, which is expected to be uncommitted until swept. Uses `--untracked-files=all` so it lists individual files even when dev/sessions/ has no tracked file. - sweep-session-logs.sh: one command to commit outstanding logs onto the current branch, staging only the log files. - CLAUDE.md: a "keep them off the floor" rule — minimise time on `main`, commit the branch log before ready, sweep whatever strands, never hand-edit a log — plus a Definition-of-Done item and a gotcha. Also corrects the stale "CI fails the PR" line (the check is advisory, #53). A dedicated long-lived "dwell" branch was considered and rejected: it diverges from main, adds a third attribution state, and is non-idiomatic for the usethis flow. The active feature branch is the dwell location. Tests: test-log-session.sh gains sections 7-8 (warns about another branch's stranded log; goes quiet once committed). All 24 assertions pass. Fixes #58 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01R8QmvZEJTz9b7uNfJZTy3n
goldingn
left a comment
There was a problem hiding this comment.
One change to make. Dwell branch idea is also not relevant in this PR description.
| - **Minimise time on `main`.** Do substantive work — including a discussion that | ||
| is clearly heading toward a branch — on a feature branch, not `main`, so its | ||
| log has a PR to travel with. The only turns that belong on `main` are merging | ||
| and syncing; keep them brief. (There is no long-lived "dwell" branch; the |
There was a problem hiding this comment.
Redundant information about something that's different exist and has never been mentioned to the agent. Amend.
There was a problem hiding this comment.
🤖 Posted by Claude (Opus 4.8), an AI coding agent, from the @goldingn account — not written by a human. Why.
Fixed in 5cd717c — removed the dwell branch parenthetical. Agreed: CLAUDE.md loads fresh each session and the concept was never introduced there, so mentioning-then-negating it was just noise. The considered-and-rejected rationale stays in #58. Also stripped the dwell-branch content from this PR description per your review.
CLAUDE.md loads fresh every session; a new agent has never heard of a
"dwell branch", so introducing and negating the concept there is redundant
and confusing. The rule stands on its own ("minimise time on `main`"). The
considered-and-rejected decision record lives in #58, which is its place.
Refs #58
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01R8QmvZEJTz9b7uNfJZTy3n
|
All good. Merge. |
Fold the logs that would otherwise strand into this PR so they land in one merge, rather than trailing a separate housekeeping PR: - this branch's own log (the prevention work); and - the `main` log, carrying this session's on-`main` merge turns, which had no PR of its own. Committed as the hook wrote them, not hand-edited. Refs #58 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01R8QmvZEJTz9b7uNfJZTy3n
Fixes #58. The prevention half of the session-log stranding problem; #57 committed the logs that had already stranded.
Root cause. The Stop hook writes a per-branch log every turn but never commits it — that's folded into a PR. Turns on
main(merges, triage) and post-merge wrap-up turns have no PR to carry their log, so it strands untracked.Three complementary guards:
log-session.sh). After writing its log, the hook warns to stderr about any other branch's uncommitted log — the leak signal — and stays quiet about the current branch's own log (expected uncommitted until swept), so it doesn't nag every turn. It never fails the hook. Usesgit status --untracked-files=allso individual files are listed even whendev/sessions/has no tracked file yet (that collapse is what a first draft got wrong — now covered by a test).sweep-session-logs.sh, new). One command to commit outstanding logs onto the current branch; stages only log files, so a stray edit elsewhere is never swept in. Idempotent.CLAUDE.md). A "keep them off the floor" section: minimise time onmain, commit the branch log before ready, sweep what strands, never hand-edit a log. Plus a Definition-of-Done item and a gotcha. Also corrects the stale "CI fails the PR if it is missing" line — that check is advisory since Make the session-log CI check advisory, not failing #53.Tests.
test-log-session.shgains sections 7–8 (warns about another branch's stranded log; quiet once committed). 24/24 pass, run in CI byhooks-test.yaml. This PR is already dogfooding the backstop — the hook is warning about other branches' logs sitting in my tree.How this was produced
mainand to open the issue + PR.maindirectly (against our rules) or create unbid commits at awkward times.--untracked-files=all.