Skip to content

The | <branch> identity slot collapses under concurrent sessions in one project — REMEMBER_BRANCH is launch-time env, and save-session.sh already holds the session id #481

Closed

Description

@TensusDS

What happens

remember 0.20.0, Linux, one project, several Claude Code sessions running at the same time.

Every entry written today carries the same identity slot:

## 13:55 | main
## 13:57 | main
## 14:03 | main

Measured in this project on 2026-08-30: 51 entries (42 in .remember/today-2026-08-30.md,
9 in .remember/now.md), one distinct slot value across all of them, with 7 sessions live in
the project
at the time of the count. They are different sessions doing different work — the log
cannot say which is which.

This is the failure the slot exists to prevent, arriving through the other branch of the same
expression. The CHANGELOG entry that introduced REMEMBER_BRANCH names it exactly — an unusable
slot "makes log entries indistinguishable across instances" — but it reaches that state via the
unknown fallback in a non-git directory. Here the repo is a real git repo, the git fallback
succeeds, and the slot is filled with a value that is correct and identical for everybody.

Why

scripts/save-session.sh:324

BRANCH="${REMEMBER_BRANCH:-$(cd "$PROJECT_DIR" && git branch --show-current 2>/dev/null || echo "unknown")}"

Sessions of one project share $PROJECT_DIR, so the git fallback returns the same branch for all of
them. Sessions that later cut their own worktrees still have $PROJECT_DIR pointing at the root they
were launched from, so the value does not diverge there either.

Concurrent sessions in one project are not hypothetical for this file: #212 established the case, and
post-tool-hook.sh says so in its own header — "with two sessions live in one project those are
different answers"
.

Why REMEMBER_BRANCH does not cover this shape

It is process environment: read at save time, but inherited at launch.

  • One value per launched process, so distinguishing N sessions means remembering, at N launches, to
    give each its own tag.
  • A session renamed after start (Claude Code /rename) cannot update it. Hooks inherit the launch
    environment and there is no in-session way to change it — so the identity a peer session would
    recognise is not knowable at the moment the value has to be set.
  • A hooks.d/before_save listener cannot supply it either: dispatch() runs listeners as child
    processes, and a child cannot set a variable in the parent, which computes BRANCH 116 lines
    later (dispatch at save-session.sh:208, BRANCH at :324).

So for this shape of use there is no reachable per-session value for the slot.

The distinguishing value is already in scope

scripts/post-tool-hook.sh:371 launches the save with the session id as its first argument:

nohup "$SAVE_SCRIPT" "$SESSION_ID" > "$REMEMBER_DIR/logs/autonomous/save-$(_remember_date +%H%M%S).log" 2>&1 &

and save-session.sh:118-130 parses it into $SESSION_ID (falling back to the newest transcript
when the argument is absent). At line 324 the script therefore already holds a value that is
different for every writer — it just isn't asked.

Suggested shape — a hint, not a spec

A command-valued override, evaluated at save time and handed the session id:

REMEMBER_BRANCH_CMD=/path/to/resolve-identity   # invoked as: $REMEMBER_BRANCH_CMD "$SESSION_ID"

resolved after REMEMBER_BRANCH and before the git fallback, with a non-zero exit or empty stdout
falling through to the existing chain.

The reason to prefer a command over a new built-in default: what a session id should map to is
site-specific. Here it would resolve against a local registry of named sessions, so the buffer reads
## 14:03 | minor-24 and a line can be matched to the session that wrote it; elsewhere
${SESSION_ID:0:8} would already be enough. Keeping that outside the plugin also avoids putting a
second meaning on a slot whose default meaning ("the branch") is right for the single-session case.

Happy to send a PR if the shape is right — but per the README, the design is yours to make from the
code, and a refusal is a fine outcome.

Environment

  • remember 0.20.0 (from .claude-plugin/plugin.json, not the cache directory name)
  • Claude Code 2.1.251
  • Linux 7.0.0-28-generic
  • project is a git repository; all sessions launched from its root; REMEMBER_BRANCH unset

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions