Skip to content

Prevent session logs from stranding: backstop warning, sweep, hygiene rule - #59

Merged
goldingn merged 4 commits into
mainfrom
prevent-orphan-session-logs
Jul 24, 2026
Merged

Prevent session logs from stranding: backstop warning, sweep, hygiene rule#59
goldingn merged 4 commits into
mainfrom
prevent-orphan-session-logs

Conversation

@goldingn

@goldingn goldingn commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

🤖 Posted by Claude (Opus 4.8), an AI coding agent, from the @goldingn account — not written by a human. Why.

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:

  1. Backstop warning (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. Uses git status --untracked-files=all so individual files are listed even when dev/sessions/ has no tracked file yet (that collapse is what a first draft got wrong — now covered by a test).
  2. Sweep helper (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.
  3. Hygiene rule (CLAUDE.md). A "keep them off the floor" section: minimise time on main, 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.sh gains sections 7–8 (warns about another branch's stranded log; quiet once committed). 24/24 pass, run in CI by hooks-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

… 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 goldingn left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

One change to make. Dwell branch idea is also not relevant in this PR description.

Comment thread CLAUDE.md Outdated
- **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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Redundant information about something that's different exist and has never been mentioned to the agent. Amend.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

🤖 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
@goldingn

Copy link
Copy Markdown
Contributor Author

All good. Merge.

goldingn and others added 2 commits July 24, 2026 13:25
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
@goldingn
goldingn marked this pull request as ready for review July 24, 2026 05:25
@goldingn
goldingn merged commit 1ea7a99 into main Jul 24, 2026
@goldingn
goldingn deleted the prevent-orphan-session-logs branch July 24, 2026 05:25
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.

Prevent session logs from stranding (main-branch and post-merge turns)

1 participant