Skip to content

chore: version packages - #457

Open
github-actions[bot] wants to merge 1 commit into
mainfrom
changeset-release/main
Open

chore: version packages#457
github-actions[bot] wants to merge 1 commit into
mainfrom
changeset-release/main

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

This PR was opened by the Changesets release GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated.

Releases

@herdctl/core@5.33.1

Patch Changes

  • #431 9b1e34a Thanks @edspencer! - Stop inferring a new CLI session's id — mint it and tell the CLI to use it (CLI runtime: resume:null session-id resolution steals a co-located agent's session id (shared cwd + concurrent stream) #357).

    waitForNewSessionFile worked out which transcript a freshly-spawned claude
    had created by looking at the session directory. Issue CLI runtime: resume:null session-id resolution steals a co-located agent's session id (shared cwd + concurrent stream) #357 fixed half of that:
    a snapshot taken before spawning identifies the new session by set difference, so
    a co-located agent appending to its own session can no longer be mistaken for
    ours. The other half was left as a guess:

    // Normally exactly one; if several appeared (e.g. multiple co-located
    // spawns raced), the newest is ours.

    The newest is not ours — it is whoever spawned last. When two agents share a
    working directory they share one ~/.claude/projects/<encoded-cwd>/, and two
    concurrent resume:null spawns produce two brand-new files that are
    indistinguishable by name or mtime. The two agents then trade session ids:
    each adopts the other's transcript, and each writes a job record claiming it.

    Claude Code accepts --session-id <uuid> and names the transcript after it (this
    also composes with --fork-session). So a turn that starts a new session now
    mints its own id and passes it, and the file is known by name — no snapshot, no
    mtime, no tie-break, nothing to get wrong. A plain resume already knows its id
    and is unchanged. Set HERDCTL_CLI_MINT_SESSION_ID=0 to restore the old
    inference.

    If the expected file never appears — a CLI too old to know the flag, or a test
    harness's fake that has not been taught it — herdctl logs a warning and falls
    back to the previous inference rather than failing the turn.

    While the CLI is still running, the inference paths stay disabled: "take
    whichever brand-new file shows up" is exactly the collision --session-id exists
    to remove, so a co-located agent's file cannot be claimed just because it landed
    first. But once the process has exited without writing the file we asked for,
    that is settled rather than merely unknown, so the fallback runs immediately
    instead of burning the full 60 s timeout. That distinction is what keeps this
    change survivable for every existing fake-CLI harness.

    Also make attribution of a doubly-claimed session id deterministic — CLI runtime: resume:null session-id resolution steals a co-located agent's session id (shared cwd + concurrent stream) #357's
    proposed "secondary hardening", which was never implemented.
    AttributionIndexBuilder filled its session→agent map in Promise.all
    completion order, so when two records claimed one session id the winner was
    whichever file's stat+parse finished last. That is decided by record size and
    machine load: with the same two records on disk, making one record larger flips
    the winner (measured 10/10 each way). Claims are now ordered explicitly — newest
    started_at wins, ties broken on job id — so the answer is a pure function of
    what is on disk. Newest-wins rather than first-owner-wins because adopting or
    promoting a session is a legitimate change of owner, and those write a newer
    record.

    Together these turn a failure that was arbitrary in both directions into one that
    cannot happen, and — where a collision is somehow still reached — into one that
    is at least consistent.

    Found via paddock#548, where a project's keeper and its post-turn sweeper share a
    cwd: a sweep is scheduled after every keeper turn, so the sweeper's spawn raced
    the next keeper turn and a user's chat could be bound to the curator's transcript
    — streaming the wrong reply, resuming the wrong history, and disappearing from
    the chat list depending on which record won attribution.

@github-actions
github-actions Bot requested a review from edspencer as a code owner August 16, 2026 17:25
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 16, 2026

Copy link
Copy Markdown

Deploying herdctl with  Cloudflare Pages  Cloudflare Pages

Latest commit: 82539bb
Status: ✅  Deploy successful!
Preview URL: https://c40806b6.herdctl.pages.dev
Branch Preview URL: https://changeset-release-main.herdctl.pages.dev

View logs

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.

0 participants