[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M757ZWRK0GSAJMV60A4HQ952":3,"skill-same:01M757ZWRK0GSAJMV60A4HQ952":73},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":44,"commitSha":45,"skillDirectory":46,"forksCount":47,"repositoryHtmlUrl":48,"repositoryHomepageUrl":49,"ownerHtmlUrl":50,"ownerBlogUrl":6,"ownerDescription":51,"updatedAt":52,"install":53,"resources":66},"01M757ZWRK0GSAJMV60A4HQ952","concurrent-session-isolation",null,"Use when two or more agent sessions share one host.","lukemcqueen\u002Fsteadfaste-fleet","lukemcqueen","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F405240?v=4","01M757MHPAGRXTJAT46SKZP98R","Luke McQueen","01M757MHPZ573KP8DT9GB8SBQ7",4,"MIT","https:\u002F\u002Fgithub.com\u002Flukemcqueen\u002Fsteadfaste-fleet\u002Fblob\u002Fmain\u002Fskills\u002Fdevops\u002Fconcurrent-session-isolation\u002FSKILL.md",[],[],"2026-11-12 13:55:43",false,"---\nname: concurrent-session-isolation\nversion: 1.0.0\ncategory: devops\ndescription: \"Use when two or more agent sessions share one host.\"\nauthor: Steadfaste Fleet curator\nlicense: MIT\nplatforms: [linux, macos]\nmetadata:\n  hermes:\n    tags: [governance, git, worktree, identity, concurrency, deploy]\n    related_skills: [governance-lock-lifecycle, governance-closeout, cross-agent-design, fleet-bus]\n---\n\n# Concurrent Sessions on One Host\n\n**Class of task:** two or more agent sessions alive on the SAME host — a second\ninteractive session, a background\u002Fdelegated session, a cron run — and everything\nthey collide over. Also the recovery when a collision has already happened.\n\nDiagnose first: sessions are easy to conflate.\n\n```bash\nls ~\u002F.steadfaste-fleet\u002Fstate\u002F.governance-*.json           # one lock per live session\ncat ~\u002F.steadfaste-fleet\u002Fagent.env                         # NOTE: one identity for the WHOLE host\n~\u002F.steadfaste-fleet\u002Fscripts\u002Floop-gov.py session_identity '{}'   # which source resolved THIS caller\ngit status --short                                        # uncommitted work may not be yours\ngit worktree list\n```\n\n**`check_repo_lock(repo_path)` answers \"is this repo covered by SOMEONE's lock\" — read it\nbefore deciding you are blocked.** A `covered: true` whose lock names a PEER's session id\nmeans the repo is BUSY, not that your own cycle is impossible: `begin_change` still creates\nYOUR OWN lock file (`.governance-\u003Cyour-session>.json`, distinct from theirs) and your writes\nproceed, because the write gate is satisfied by any live lock for that repo. Two\nconsequences to say out loud rather than assume: never release, purge, or repair the lock a\npeer's id names (that is theirs), and remember that working merely because THEIR lock exists\nis the hole pitfall 10 describes — with no `begin_change` of your own there is no session\nidentity, so the commit trailer credits your commits to them. Scope your writes to your own\npaths and leave their in-flight files (tracked and untracked) untouched.\n\n## What collides, and what to do\n\n| Shared resource | Failure it causes | Disposition |\n|---|---|---|\n| git index + working tree | a commit in one session sweeps the other's STAGED work under the wrong message | **scope** — one worktree per session; until then, forbid BARE commits (pitfall 11) |\n| git author identity | commits unattributable; author-scoped gates cannot tell sessions apart | **scope** — per-worktree identity |\n| commit ATTRIBUTION (a `FLEET-Session` trailer) | two live locks matching ONE repo ⇒ the hook stamps EVERY commit with the SAME id, so a session-scoped review filter cannot separate them | **scope** — one worktree AND one lock namespace per session; a trailer cannot distinguish sessions that share it |\n| governance lock file | a CLOSE is session-scoped (own file, own cycle rows) — but a purge sweep removes past-TTL locks for ANY session, so a peer's deploy can end an idle session's lock | scope (already correct) for close; **serialise\u002Fverify** the purge — see pitfall 9 |\n| loop-governance DB | writes serialise | scope (rows carry `session_id`) |\n| MCP server process | one session's blocking handler freezes the server for EVERY session sharing that parent — all calls time out at once | **keep handlers off-loop** — see \"A wedged shared MCP server\" below |\n| in-repo `.hermes-cortex\u002F.governance-lock` | ONE path per repo shared by all sessions, so a peer's `end_change` could unlink your marker while you still hold your lock | **fixed** — `_release_lock` removes it only when the marker's `session_id` is its own (or absent); the session-scoped `.governance-\u003Csession>.json` stays authoritative either way |\n| handoff state dirs | one session's stale marker appears in another's sweep | scope — session subdir |\n| `fleet-update.sh` deploy | interleaved unlock\u002Frelock; a killed run leaves enforcement files WRITABLE | **serialise** — one deploy per host |\n| immutable enforcement flags | come off during a deploy that dies | **serialise** (pitfall 4) |\n\n**The principle: scope what can be scoped, serialise what cannot.** There is\nexactly ONE deployed enforcement tree per host. Concurrency there must be\nexcluded by a lock, never \"scoped\" — scoping a shared resource only produces two\nsessions that each believe they own it.\n\n## A wedged shared MCP server (\"every call times out\")\n\nMCP servers are spawned per PARENT process, not per session: one gateway owns ONE\n`loop-gov-mcp.py` child, and every session that parent serves (interactive, cron,\ndelegated) shares it. A session blocked INSIDE a handler therefore blocks all of\nthem, and the symptom — every MCP call timing out at once — reads like a broken\nhost. It is not. Read the block state; never infer it:\n\n```bash\nps -eo pid,ppid,wchan:22,etime,pcpu,args --no-headers | grep loop-gov-mcp\n```\n\n| `wchan` | Meaning |\n|---|---|\n| `do_epoll_wait` | idle and healthy — waiting for work |\n| `poll_schedule_timeout` | BLOCKED in `subprocess.run(capture_output=True)` waiting on a child → that child's `ppid` is your culprit |\n| `futex_do_wait` | waiting on a lock or queue |\n\n```bash\nps -eo pid,ppid,etime,args --no-headers | grep -E '\u003Cserver pid>|\u003Creviewer name>'\n```\n\nThe mechanism: `loop-gov-mcp.py`'s `call_tool` is `async` but dispatches with a\nplain `return handler(args)`, and `end_change` runs the adversarial reviewer via\n`subprocess.run(timeout=900)` \u002F `urllib.urlopen(timeout=300)`. The MCP dispatcher\nDOES spawn a task per request (`mcp\u002Fshared\u002Fjsonrpc_dispatcher.py`, `tg.start_soon`),\nbut asyncio tasks are cooperative — a blocking sync call starves all of them.\nHermes' client ceiling is `_DEFAULT_TOOL_TIMEOUT = 300` s\n(`hermes-agent\u002Ftools\u002Fmcp_tool_common.py`), so a 900 s reviewer can never be waited\non: every queued call on that server hits the ceiling. Check BOTH numbers before\nblaming the network.\n\n**The rule for any handler in a shared server: never do blocking work on the loop.**\nDispatch through `await asyncio.to_thread(handler, args)`, guard the shared state\nmutations (purge sweeps, the in-repo marker) with one `threading.Lock`, and bound\nevery external call BELOW the client ceiling so one tenant cannot outlive the\ncaller's patience. The governance STATE layer is already per-session\n(session-scoped lock files; `begin_change`'s close-out gate filters\n`WHERE session_id = ?`) — the coupling is transport\u002Fprocess, so fix it there rather\nthan by weakening a lock.\n\n**Prove the dispatch is non-blocking from a SECOND thread or process — never from\nthe same event loop.** A loop starved by the handler cannot run your probe either,\nso a same-loop measurement reports ~0 s and passes vacuously: the first attempt at\nthis test measured `0.00 s` for a call that had in fact waited the whole block.\nDrive the server loop from a background thread, submit the slow call, wait on an\n`Event` the handler sets INSIDE its critical section, then time a cheap call from\nthe main thread. Keep a control that exercises the OLD dispatch shape and assert\nit still blocks — without that, a green test proves nothing.\n\n## The convention: one session = one worktree = one branch = one identity\n\n```bash\n# from the primary checkout\ngit worktree add ~\u002Ffleet-session-\u003Ctag> -b session\u002F\u003Ctag> origin\u002Fmain\ncd ~\u002Ffleet-session-\u003Ctag>\ngit config extensions.worktreeConfig true          # REQUIRED once — see pitfall 1\ngit config --worktree user.name  \"\u003Cagent>-\u003Ctag>\"\ngit config --worktree user.email \"\u003Cagent>+\u003Ctag>@\u003Cdomain>\"\n```\n\nBranch from `origin\u002Fmain`, never from a peer's dirty HEAD, or you inherit their\nuncommitted work. A plain numeric tag (`2`, `3`) distinguishes sessions.\nConfirm independence before trusting it:\n\n```bash\nprintf 'main -> %s\\n' \"$(git -C \u003Cprimary>  config user.email)\"\nprintf 'mine -> %s\\n' \"$(git -C \u003Cworktree> config user.email)\"   # must differ\ngit diff --cached --name-only                                     # only YOUR files\n```\n\n## Pitfalls\n\n1. **`git config` inside a worktree writes the SHARED config unless you ask otherwise.**\n   Without `extensions.worktreeConfig=true` + `git config --worktree …`, setting an\n   identity for one session silently changes EVERY worktree's — the primary checkout\n   picks up the session identity, which is the opposite of isolation. Set the\n   extension first, then read the identity back in BOTH trees.\n2. **Never session-append the BUS identity.** `AGENT_NAME` (agent.env) decides the\n   `inbox_\u003Cagent>` queue and the on-bus name; appending a session tag breaks routing.\n   Sessions differ in git AUTHORSHIP, a separate value. A helper that sets the\n   identity should re-read `AGENT_NAME` afterwards and abort if it changed.\n3. **Governance binds to the repo the SESSION was started in — a worktree is not it.**\n   A worktree isolates the index, not the gate: a commit on a worktree branch is\n   absent from the tree the close-gate diffs, so the review fails on material that\n   cannot contain the change (it reports the new files as missing). Run the session\n   FROM the worktree when the work lives there, or land the work in the session's own\n   tree before closing — `begin_change` cannot be re-pointed mid-cycle, so a\n   worktree-only change under a main-tree session is unclosable.\n4. **A deploy that exits non-zero can leave the enforcement files WRITABLE.**\n   `fleet-update.sh` unlocks the immutable targets early and relocks late, with no\n   `EXIT` trap: a run that dies in between (non-zero exit, timeout, killed detached\n   worker) leaves `chattr +i` off every target while the deploy merely looks failed.\n   Detect with `hermes-plugin-lock status` — protected entries read\n   `----i---------e-------`; `--------------e-------` means the flag is MISSING (the\n   doctor's `Immutable: \u003Cname>` checks report the same as FAIL). Restore with\n   `sudo -n hermes-plugin-lock lock`, which is NOPASSWD-granted. Re-check after ANY\n   failed deploy; \"ships unprotected\" is a governance regression, not cosmetic.\n5. **`sudo -n true` proves NOTHING about the command you need.** It tests `\u002Fbin\u002Ftrue`,\n   which no NOPASSWD rule grants, so it always answers *\"a password is required\"* —\n   even where the helper you need IS granted. Read the full `sudo -n -l` list and test\n   the SPECIFIC command (`sudo -n -l \u003Ccmd>` for policy, then `sudo -n \u003Ccmd>` for\n   execution). Never conclude a rule is absent from a TRUNCATED listing: the list runs\n   to dozens of grants and `head`\u002F`tail` hides the entry you want. Either mistake\n   invents a wrong root cause and a wrong \"needs the operator's password\" blocker.\n6. **Never assume uncommitted changes are yours.** With a session alive in the same\n   tree, `git status` is shared news. Investigate before you stash, revert, or commit,\n   and stage explicit paths rather than `git add -A`.\n7. **Do not race a peer's in-flight work.** If another session is mid-update on shared\n   state, `git pull --rebase` cannot pass its dirty tree (\"cannot pull with rebase: You\n   have unstaged changes\") and a deploy will fight it. Work in your own worktree, or\n   stand down until it finishes. Never resolve it by stashing, checking out or resetting\n   their tree: prove the overlap FIRST — their paths from `git status --short` against\n   the incoming paths from `git diff --name-only \u003Cold-head>..origin\u002Fmain` — and only then\n   `git merge --ff-only`, which is safe when the sets are disjoint and leaves their\n working tree untouched.\n\n **Operator-directed exception.** When the operator explicitly says to stash and land a\n peer's work, do it with a safety net and PROVE the round-trip — never on your own\n initiative. Backup first, then stash only their paths:\n\n ```bash\n BK=~\u002F.hermes\u002Fcache\u002Fscratch\u002Fpeer-stash-\u003Cdate>; mkdir -p \"$BK\"\n git ls-files -s -- \u003Cpaths> > \"$BK\u002Findex-snapshot.txt\"             # their index blobs\n git diff --cached --binary -- \u003Cpaths> > \"$BK\u002Fpeer-staged.patch\"   # binary-safe patch\n cp -a \u003Cpaths> \"$BK\"\u002F ; (cd \u003Cdir> && sha256sum \u003Cfiles>) > \"$BK\u002Fbefore.sha256\"\n TREE=$(git write-tree)                                            # their staged tree\n SAFE=$(git commit-tree \"$TREE\" -p HEAD -m \"safety: peer staged snapshot\")\n git tag -f peer-stash-safety \"$SAFE\"        # durable ref: a prune cannot lose it\n git stash push -m \"\u003Cwhat and why>\" -- \u003Cpaths>   # reset index AND worktree for those paths\n git merge origin\u002Fmain\n git stash pop && (cd \u003Cdir> && sha256sum -c \"$BK\u002Fbefore.sha256\")\n ```\n\n - Find the blocking set before stashing anything — the merge names it, and\n   `comm -12 \u003C(git diff --name-only HEAD origin\u002Fmain | sort) \u003C(git status --porcelain | sed 's\u002F^...\u002F\u002F' | sort)`\n   states it independently.\n - Use `git stash push -- \u003Cpaths>`, NOT `--staged`: `--staged` resets only the index and\n   leaves the worktree content behind, so the merge is refused exactly as before.\n - A file whose upstream side ALSO moved comes back from `git stash pop` as an UNSTAGED\n   3-way merge, which is correct but changes their index state — re-`git add` it so their\n   staged set is restored as it was. Only the file whose base moved can be affected.\n - Keep committing by PATHSPEC afterwards: their staged paths ride into any plain\n   `git commit`.\n - **Before assuming the peer will land its own work, check that it CAN.** A cron session\n   has no `skill_view` tool, so the pre-commit reflexion gate refuses EVERY commit it\n   attempts — its staged bundle is stranded by construction (its own DOCS-INDEX row said\n   so) and only an orchestrator can land it. That is the case in which the operator's\n   \"stash and close it out\" instruction is the only exit.\n - **Modifying a peer's artifact needs the OPERATOR, not the gate.** If the gate refuses\n   their file as-is (swallowed errors that can print a false PASS) and then refuses your\n   hardening as `scope-drift` against the description that promised it unchanged, stop\n   and present both findings: the gate can demand a change only the artifact's owner may\n   authorise, and self-authorising it is the same class of error as overriding a finding.\n   A cycle whose DESCRIPTION contradicts the diff cannot be talked out of it — see\n   `governance-closeout`.\n8. **A deploy+push races the peer's next commit.** The push gate compares HEAD with the\n   last-deploy commit, so any commit landing during the minutes-long deploy invalidates\n   it: a *successful* deploy is followed by \"Deploy sync — HEAD ahead of last deploy\".\n   Re-deploying in a loop is whack-a-mole and multiplies deploy windows on a shared tree\n   (each deploy also re-publishes whatever the peer has uncommitted there). The commits\n   are already local — `git status -sb` shows `ahead N` — so ANY push from that host,\n   theirs included, carries yours. Confirm what actually reached the remote with\n   `git fetch -q && git log --oneline -1 origin\u002Fmain` and coordinate rather than\n   thrashing deployments; if the peer is mid-cycle, their push is the one that lands it.\n\n9. **The deploy's sweep is the ONE shared step that can remove a PEER's lock — and it resolves no cycle.** Lock files are per session, so no session's close can touch another's; the collision lives entirely in the purge. Two things about it, both measured:\n   - **A purge is TTL-only.** The standalone purge script (run by the deploy and by a cron) ages a lock by `heartbeat_at` against its own `ttl_seconds` and stops there — it has NO commit-liveness rescue, unlike the MCP's staleness predicate. So a session that is alive but has made no governed call for an hour is judged dead by a peer's deploy. You cannot arm this from the victim side; keep the heartbeat fresh (any governed call refreshes it) or accept the release.\n   - **A purge removes lock FILES only; closing the cycles is a SEPARATE step.** The repair is `_resolve_orphaned_pending_cycles` (which `begin_change` invokes), not the purge. So a sweep that removes an abandoned session's lock leaves its cycle PENDING — and a PENDING cycle whose task has no non-terminal lock is a doctor FAIL that blocks EVERY agent's push on the host. The doctor only auto-resolves cycles older than 24h, so inside that window the leak sits with no owner left to clear it.\n\n   **Verify any claim about this class by planting sessions, never by reasoning about them.** Repoint the module's state dir and DB globals at a throwaway directory, plant locks for each role (a mid-deploy session, a session in another repo, one about to push, one past its TTL), then drive the shipped purge, release and repair functions and assert what each touched — including that live locks are BYTE-IDENTICAL (sha256) before and after. Recipe and the exact checks: `references\u002Flock-purge-and-ownership.md`.\n\n10. **The WRITE gate is per REPO, so a second session never takes its own lock — it rides yours.**\n   The enforcer's rule is \"this repo has an active lock\", satisfied by ANY session's lock for that\n   repo, so a peer session commits freely while yours is live and acquires nothing. The hook then\n   finds exactly ONE matching lock and stamps **your** id on the peer's commits. Locks are unique\n   per session BY FILE NAME (`_session_lock_path(session_id)`), but that uniqueness never gets\n   exercised: nothing forces the second session to call `begin_change`. So \"are locks unique per\n   session?\" is the wrong question — the holes are (a) ownership at the write gate, and (b)\n   attribution at commit time, and git gives the hook NO session identity to attribute with.\n\n   **Diagnose \"a peer's files are in my review\" in this order — do not guess:**\n\n   ```bash\n   git status --short                      # EMPTY ⇒ the files are COMMITTED, not dirty\n   git log --format='%h %s%n  trailer=%(trailers:key=FLEET-Session,valueonly)' -8\n   grep -H -e '\"session_id\"' -e '\"repo_path\"' ~\u002F.steadfaste-fleet\u002Fstate\u002F.governance-*.json\n   ```\n\n   - Empty `status` kills the working-tree\u002F`dirty_at_start` theory immediately: the offending files\n     are in the COMMITTED range, so stashing or reverting changes nothing and destroys real work.\n     Never run a peer's stash\u002Frevert on this evidence — the peer's work is committed and yours to\n     leave alone.\n   - **Every commit carrying the SAME trailer while only ONE lock exists for that repo** ⇒ the peer\n     rode your lock (pitfall above), not a two-lock ambiguity. A per-commit trailer cannot separate\n     two committers who share one id, in either direction.\n   - A stale commit trailer cannot be corrected after the fact; only a new commit gets a new one.\n\n   **Two scope bugs follow from the same root**, and both need fixing for N sessions:\n   a) the **per-blob review demand is the WHOLE UNPUSHED RANGE** (`push_base..HEAD`), regardless of\n      author or session — so whichever session closes first is judged on every unpushed file, its\n      peer's included. Scope it by the attributed session the way the diff already is, disclosing\n      peers by name instead of demanding verdicts for them.\n   b) the consumer must treat an **unattributed** commit as in-scope (fail closed, disclosed at\n      info) — never as \"mine by default\", which is what makes a wrong stamp silently harmful.\n\n   **Attribution is now session-scoped in code; the shared lock NAMESPACE is the part left to you.**\n   The hook stamps a commit only for the SINGLE claimant whose lock was refreshed recently (the server\n   rewrites the lock on every governed call, so its mtime IS that session's last activity) and writes\n   NO trailer when zero or several claimants are equally fresh — an absent trailer keeps the commit in\n   scope for everyone (fail-closed, visible), while a wrong one silently credits your files to a peer\n   and makes theirs yours to answer for. The per-blob DEMAND is scoped the same way: each path is\n   attributed to the commit that produced its CURRENT content (range walked newest-first) and a\n   peer-attributed path is disclosed rather than demanded — the receipt then covers only your own\n   blobs, so the push gate still refuses that range until its OWNER closes it. What no hook can fix is\n   that a session taking no lock of its own still commits under yours, so give each session its own\n   git worktree: separate `repo_path` ⇒ separate locks ⇒ the path match is unambiguous. Do that before\n   filing another scope bug.\n\n11. **The INDEX carries no provenance — a bare `git commit` sweeps whatever is staged, and a\n    pathspec commit structurally cannot.** The index is ONE shared mutable structure whose entries\n    record nothing about WHICH session staged them, so \"these staged files are not mine\" is not\n    answerable from the tree. The cheapest control needs no provenance at all: a PARTIAL commit uses\n    its own temporary index, so it can only ever include the paths you name. Measured as seen by a\n    `pre-commit` hook:\n\n    ```\n    bare commit      GIT_INDEX_FILE=[.git\u002Findex]\n    pathspec commit  GIT_INDEX_FILE=[…\u002F.git\u002Fnext-index-\u003Cpid>.lock]\n    # and after the pathspec commit the foreign entry is STILL staged\n    ```\n\n    So a hook CAN refuse a bare commit in the shared repo and require `git commit -- \u003Cpaths>`, which\n    kills the sweep class instead of merely discouraging it. Compare `$GIT_INDEX_FILE` against\n    `$(git rev-parse --git-dir)\u002Findex`; a difference means a partial commit. Prove the detection with\n    a self-test inside the hook (the way an identity guard is self-tested), and exempt a sanctioned\n    automated committer whose allowlist already proves every staged path is its own.\n\n    **The same shared index also blocks a MERGE**, and the refusal misleads: `git merge` stops with\n    *\"Your local changes to the following files would be overwritten by merge\"* while entries are\n    staged, listing paths the merge would not even touch. Determine WHOSE they are before deciding —\n    if they are your OWN earlier pass's leftovers (an evidence dump staged and never committed),\n    unstaging is legitimate: `git reset -q -- \u003Cpaths>` leaves the files on disk as untracked and\n    unblocks the merge. Never do that to a live peer's staged work; see pitfall 7. Note also that\n    `git ls-tree origin\u002Fmain -- \u003Cpath>` returning empty is the proof those files were never pushed —\n    do not infer from the merge's wording that the remote already has them.\n\n12. **A non-Hermes coding agent's governance id collapses to ONE per repo unless the\n    harness exports a per-session env value — and detecting the sharing is not fixing it.**\n    `get_session_id()` resolves: per-call injection (Hermes enforcer) → env\n    `FLEET_SESSION_KEY` then `PI_SESSION_ID` → per-repo persisted `state\u002F.session-\u003Cslug>.id`.\n    That fallback is ONE id per repo BY CONSTRUCTION (a restart-stability trade for bare\n    harnesses), so every env-less Pi\u002FClaude\u002FCodex session in the repo resolves the SAME id and\n    the SAME lock file: a new session \"picks up\" the existing session's lock, and a close can\n    release a peer's. Pitfall 10 is the Hermes write-gate half of this; this is the non-Hermes\n    resolver half, and it fires even when the second session correctly calls `begin_change`.\n\n    - **Uniqueness comes ONLY from the env step, and only if the harness actually puts the\n      value in the MCP child's environment — a variable can reach ONE subprocess class and be\n      absent from ANOTHER, so measure the seam for the exact consumer, never trust a documented\n      merge (cross-agent-design rule 6).** Two variants each dead-end the resolver's env read:\n      an MCP `env` block that REPLACES the child env (a harness passing `config.env` straight to\n      Node `spawn(env=…)` strips every inherited var, `FLEET_SESSION_KEY` included), and the\n      subtler one on Pi — Pi's stdio transport MERGES (`{...process.env, ...config.env}`), so the\n      block is fine, but Pi exports `PI_SESSION_ID` only into bash-tool commands and never onto\n      its own `process.env`, so the governor's MCP child inherits nothing regardless. Verify\n      which variant the host has by driving the harness's own launcher and reading the child's\n      survives — measured: `loop-gov.py session_identity '{}'` answers `per-repo, shared` on a\n      live Pi session.\n    - **The env-var NAME and its reach differ per harness — survey the exact one, never assume\n      a sibling's `*_SESSION_ID` is the other's.** Verified from each harness's own source (a\n      name documented as *set by the agent* does not mean it lands on the MCP child): Claude\n      Code injects `CLAUDE_CODE_SESSION_ID` (note `CODE`; `CLAUDE_SESSION_ID` is NOT set) into\n      stdio MCP children as of v2.1.154, so it needs no adapter; Codex sets `CODEX_SESSION_ID`\n      but forwards it only to shell commands, so an MCP child gets it only when pinned in\n      `[mcp_servers..env]` or by an upstream change. The resolver honours all of them\n      (`_ENV_SESSION_ID_SOURCES` in loop-gov-mcp.py) and falls back to the shared per-repo id\n      for a harness that supplies none — full matrix: `cross-agent-design` 'N heterogeneous\n      coding agents'.\n    - **Diagnose which source resolved with `loop-gov.py session_identity '{}'`.** A `per-repo`\n      answer on a live session proves no unique env id reached the child.\n    - **Fail-closed ownership (a `shared` id that is never claimable) converts silent theft\n      into visible blocking; it does NOT give sessions separate locks.** The fix lives at the\n      propagation seam — not in more resolver hardening. A static MCP `env` block CANNOT carry\n      a per-session value, so for Pi the working fix is the harness's lifecycle hook setting\n      `FLEET_SESSION_KEY` from its own session manager (`ctx.sessionManager.getSessionId()` in\n      `before_agent_start`, run BEFORE the MCP child spawns; only-if-unset so a gateway pin\n      wins) — proof at `ops\u002Finstall\u002Fharnesses\u002Fpi\u002Fextensions\u002Ffleet-context.ts`. The\n      fleet-gateway `command` backend already pins it per chat when a session runs through the\n      gateway; passing an explicit per-call `session_id` WITH `repo_path` remains the\n      CLI\u002FClaude-Code workaround.\n    - **Slug instability is the opposite failure of the same fallback:** when slug resolution\n      falls through to the child's cwd and that cwd is a temp dir, the slug is `tmp.\u003Crandom>` —\n      a fresh random id per spawn (unstable across an MCP-child restart, so locks orphan) and\n      orphaned `state\u002F.session-tmp.*.id` files accumulate.\n\n## What a shared-server fix must also preserve\n\n- **A shared fixed-path file is only removed by its owner.** The in-repo\n  `.hermes-cortex\u002F.governance-lock` marker is ONE path for the whole repo, so\n  `_release_lock` unlinks it only when the marker's `session_id` is its own (or\n  absent). Otherwise session A's close silently unmarks session B's live lock.\n\n**A lock's `repo_slug` is a HOST fact, not a session fact.** `_derive_slug()`\nprefers the canonical `~\u002Fsteadfaste-fleet`, so a session working in another repo\ngets a lock tagged with the canonical one — and the close gate then reviews a\ntree that cannot contain the work: permanent FINDINGS, an unclosable cycle, and\none full review re-run per retry. The enforcer injects the session's real repo\n(learned from the paths its own tool calls touch, since a `pre_tool_call` hook\nis never given a cwd), and the gate refuses loudly when the lock's repo shows no\ndiff and no commits in the window while another candidate repo gained commits.\n\n**`repo_slug` is a NAME, so carry the ABSOLUTE path too.** The slug resolves as\n`HOME\u002F\u003Cslug>` — a contract the git hooks share — which silently mis-resolves (or\nresolves to nothing) for a checkout nested below a HOME child, i.e. a dev host\nwith many project repos (`~\u002Fprojects\u002F\u003Corg>\u002F\u003Crepo>`), re-creating the wrong-repo\nreview on exactly the hosts a slug-only fix cannot reach. Carry BOTH: `repo_path`\n(absolute, observed per session and injected by the enforcer) decides which tree\nis parsed, while `repo_slug` (the basename) MUST stay, because the git hooks match\nlocks by name. Resolve in this order — recorded `repo_path`, then legacy\n`HOME\u002F\u003Cslug>`, then FAIL CLOSED; never guess a tree to review.\n\nThree consequences: a same-basename repo sitting at `HOME\u002F\u003Cslug>` must never win\nover the recorded path; the in-repo `.hermes-cortex\u002F.governance-lock` marker\nfollows the absolute path, so a nested repo gets its marker inside itself rather\nthan at `HOME\u002F\u003Cslug>`; and the wrong-repo guard's candidate scan must walk HOME a\nfew levels (skipping hidden dirs except `.hermes-cortex`, and treating a directory\nthat IS a repo as a leaf) or a nested repo's commits are invisible to the guard\nand it will happily review the canonical repo instead. Accept an injected path\nonly when it is a real git repo, so a bogus or stale value cannot aim a review at\nan arbitrary directory.\n\n**deploy is not load — and the two halves reload differently.** An MCP fix needs\nthe daemon restarted (kill the child; the parent respawns it on the next call —\nprobe and post-restart check in `governance-closeout`). An ENFORCER\u002Fplugin fix\nneeds a session reload an in-session agent CANNOT perform, and the deploy says so\nitself: grep its output for `Run \u002Freset to load the updated enforcer plugin`\nrather than inferring the reload happened. `kill` is an approval-gated\ndestructive command — if the approval does not arrive, do NOT retry it and do NOT\nroute around it (no alternate kill, no pkill variant): stand down, name which\nhalf is still unloaded, and close the cycle. Always state which half is loaded\nand which is pending; never report a fix as live because it deployed.\n\n**A timing window must be compared as an epoch, not with `git log --since=`**:\napproxidate returned 0 commits for a commit made seconds earlier when the bound\nwas a Z-suffixed UTC instant and the commit date carried a local offset. Use\n`git log --format=%ct` and compare integers.\n\n## Verification\n\n- `git worktree list` shows one tree per active session, each on its own branch.\n- Each tree's `config user.email` differs; `AGENT_NAME` is unchanged fleet-wide.\n- A commit in each tree is authored by that tree's identity\n  (`git log -1 --format='%h %an \u003C%ae>'`).\n- After any deploy: `hermes-plugin-lock status` shows `----i` on every target.\n\n## Related\n\n- `governance-closeout` — closing a cycle the gate refuses; the worktree\u002Frepo binding\n  pitfall is stated there from the close-out side.\n- `governance-lock-lifecycle`, `fleet-bus`, `fleet-commands`, `sudoers-audit` —\n  relevant but USER-OWNED: `hermes curator adopt \u003Cname>` before extending them.\n","# Concurrent Sessions on One Host\n\n**Class of task:** two or more agent sessions alive on the SAME host — a second\ninteractive session, a background\u002Fdelegated session, a cron run — and everything\nthey collide over. Also the recovery when a collision has already happened.\n\nDiagnose first: sessions are easy to conflate.\n\n```bash\nls ~\u002F.steadfaste-fleet\u002Fstate\u002F.governance-*.json           # one lock per live session\ncat ~\u002F.steadfaste-fleet\u002Fagent.env                         # NOTE: one identity for the WHOLE host\n~\u002F.steadfaste-fleet\u002Fscripts\u002Floop-gov.py session_identity '{}'   # which source resolved THIS caller\ngit status --short                                        # uncommitted work may not be yours\ngit worktree list\n```\n\n**`check_repo_lock(repo_path)` answers \"is this repo covered by SOMEONE's lock\" — read it\nbefore deciding you are blocked.** A `covered: true` whose lock names a PEER's session id\nmeans the repo is BUSY, not that your own cycle is impossible: `begin_change` still creates\nYOUR OWN lock file (`.governance-\u003Cyour-session>.json`, distinct from theirs) and your writes\nproceed, because the write gate is satisfied by any live lock for that repo. Two\nconsequences to say out loud rather than assume: never release, purge, or repair the lock a\npeer's id names (that is theirs), and remember that working merely because THEIR lock exists\nis the hole pitfall 10 describes — with no `begin_change` of your own there is no session\nidentity, so the commit trailer credits your commits to them. Scope your writes to your own\npaths and leave their in-flight files (tracked and untracked) untouched.\n\n## What collides, and what to do\n\n| Shared resource | Failure it causes | Disposition |\n|---|---|---|\n| git index + working tree | a commit in one session sweeps the other's STAGED work under the wrong message | **scope** — one worktree per session; until then, forbid BARE commits (pitfall 11) |\n| git author identity | commits unattributable; author-scoped gates cannot tell sessions apart | **scope** — per-worktree identity |\n| commit ATTRIBUTION (a `FLEET-Session` trailer) | two live locks matching ONE repo ⇒ the hook stamps EVERY commit with the SAME id, so a session-scoped review filter cannot separate them | **scope** — one worktree AND one lock namespace per session; a trailer cannot distinguish sessions that share it |\n| governance lock file | a CLOSE is session-scoped (own file, own cycle rows) — but a purge sweep removes past-TTL locks for ANY session, so a peer's deploy can end an idle session's lock | scope (already correct) for close; **serialise\u002Fverify** the purge — see pitfall 9 |\n| loop-governance DB | writes serialise | scope (rows carry `session_id`) |\n| MCP server process | one session's blocking handler freezes the server for EVERY session sharing that parent — all calls time out at once | **keep handlers off-loop** — see \"A wedged shared MCP server\" below |\n| in-repo `.hermes-cortex\u002F.governance-lock` | ONE path per repo shared by all sessions, so a peer's `end_change` could unlink your marker while you still hold your lock | **fixed** — `_release_lock` removes it only when the marker's `session_id` is its own (or absent); the session-scoped `.governance-\u003Csession>.json` stays authoritative either way |\n| handoff state dirs | one session's stale marker appears in another's sweep | scope — session subdir |\n| `fleet-update.sh` deploy | interleaved unlock\u002Frelock; a killed run leaves enforcement files WRITABLE | **serialise** — one deploy per host |\n| immutable enforcement flags | come off during a deploy that dies | **serialise** (pitfall 4) |\n\n**The principle: scope what can be scoped, serialise what cannot.** There is\nexactly ONE deployed enforcement tree per host. Concurrency there must be\nexcluded by a lock, never \"scoped\" — scoping a shared resource only produces two\nsessions that each believe they own it.\n\n## A wedged shared MCP server (\"every call times out\")\n\nMCP servers are spawned per PARENT process, not per session: one gateway owns ONE\n`loop-gov-mcp.py` child, and every session that parent serves (interactive, cron,\ndelegated) shares it. A session blocked INSIDE a handler therefore blocks all of\nthem, and the symptom — every MCP call timing out at once — reads like a broken\nhost. It is not. Read the block state; never infer it:\n\n```bash\nps -eo pid,ppid,wchan:22,etime,pcpu,args --no-headers | grep loop-gov-mcp\n```\n\n| `wchan` | Meaning |\n|---|---|\n| `do_epoll_wait` | idle and healthy — waiting for work |\n| `poll_schedule_timeout` | BLOCKED in `subprocess.run(capture_output=True)` waiting on a child → that child's `ppid` is your culprit |\n| `futex_do_wait` | waiting on a lock or queue |\n\n```bash\nps -eo pid,ppid,etime,args --no-headers | grep -E '\u003Cserver pid>|\u003Creviewer name>'\n```\n\nThe mechanism: `loop-gov-mcp.py`'s `call_tool` is `async` but dispatches with a\nplain `return handler(args)`, and `end_change` runs the adversarial reviewer via\n`subprocess.run(timeout=900)` \u002F `urllib.urlopen(timeout=300)`. The MCP dispatcher\nDOES spawn a task per request (`mcp\u002Fshared\u002Fjsonrpc_dispatcher.py`, `tg.start_soon`),\nbut asyncio tasks are cooperative — a blocking sync call starves all of them.\nHermes' client ceiling is `_DEFAULT_TOOL_TIMEOUT = 300` s\n(`hermes-agent\u002Ftools\u002Fmcp_tool_common.py`), so a 900 s reviewer can never be waited\non: every queued call on that server hits the ceiling. Check BOTH numbers before\nblaming the network.\n\n**The rule for any handler in a shared server: never do blocking work on the loop.**\nDispatch through `await asyncio.to_thread(handler, args)`, guard the shared state\nmutations (purge sweeps, the in-repo marker) with one `threading.Lock`, and bound\nevery external call BELOW the client ceiling so one tenant cannot outlive the\ncaller's patience. The governance STATE layer is already per-session\n(session-scoped lock files; `begin_change`'s close-out gate filters\n`WHERE session_id = ?`) — the coupling is transport\u002Fprocess, so fix it there rather\nthan by weakening a lock.\n\n**Prove the dispatch is non-blocking from a SECOND thread or process — never from\nthe same event loop.** A loop starved by the handler cannot run your probe either,\nso a same-loop measurement reports ~0 s and passes vacuously: the first attempt at\nthis test measured `0.00 s` for a call that had in fact waited the whole block.\nDrive the server loop from a background thread, submit the slow call, wait on an\n`Event` the handler sets INSIDE its critical section, then time a cheap call from\nthe main thread. Keep a control that exercises the OLD dispatch shape and assert\nit still blocks — without that, a green test proves nothing.\n\n## The convention: one session = one worktree = one branch = one identity\n\n```bash\n# from the primary checkout\ngit worktree add ~\u002Ffleet-session-\u003Ctag> -b session\u002F\u003Ctag> origin\u002Fmain\ncd ~\u002Ffleet-session-\u003Ctag>\ngit config extensions.worktreeConfig true          # REQUIRED once — see pitfall 1\ngit config --worktree user.name  \"\u003Cagent>-\u003Ctag>\"\ngit config --worktree user.email \"\u003Cagent>+\u003Ctag>@\u003Cdomain>\"\n```\n\nBranch from `origin\u002Fmain`, never from a peer's dirty HEAD, or you inherit their\nuncommitted work. A plain numeric tag (`2`, `3`) distinguishes sessions.\nConfirm independence before trusting it:\n\n```bash\nprintf 'main -> %s\\n' \"$(git -C \u003Cprimary>  config user.email)\"\nprintf 'mine -> %s\\n' \"$(git -C \u003Cworktree> config user.email)\"   # must differ\ngit diff --cached --name-only                                     # only YOUR files\n```\n\n## Pitfalls\n\n1. **`git config` inside a worktree writes the SHARED config unless you ask otherwise.**\n   Without `extensions.worktreeConfig=true` + `git config --worktree …`, setting an\n   identity for one session silently changes EVERY worktree's — the primary checkout\n   picks up the session identity, which is the opposite of isolation. Set the\n   extension first, then read the identity back in BOTH trees.\n2. **Never session-append the BUS identity.** `AGENT_NAME` (agent.env) decides the\n   `inbox_\u003Cagent>` queue and the on-bus name; appending a session tag breaks routing.\n   Sessions differ in git AUTHORSHIP, a separate value. A helper that sets the\n   identity should re-read `AGENT_NAME` afterwards and abort if it changed.\n3. **Governance binds to the repo the SESSION was started in — a worktree is not it.**\n   A worktree isolates the index, not the gate: a commit on a worktree branch is\n   absent from the tree the close-gate diffs, so the review fails on material that\n   cannot contain the change (it reports the new files as missing). Run the session\n   FROM the worktree when the work lives there, or land the work in the session's own\n   tree before closing — `begin_change` cannot be re-pointed mid-cycle, so a\n   worktree-only change under a main-tree session is unclosable.\n4. **A deploy that exits non-zero can leave the enforcement files WRITABLE.**\n   `fleet-update.sh` unlocks the immutable targets early and relocks late, with no\n   `EXIT` trap: a run that dies in between (non-zero exit, timeout, killed detached\n   worker) leaves `chattr +i` off every target while the deploy merely looks failed.\n   Detect with `hermes-plugin-lock status` — protected entries read\n   `----i---------e-------`; `--------------e-------` means the flag is MISSING (the\n   doctor's `Immutable: \u003Cname>` checks report the same as FAIL). Restore with\n   `sudo -n hermes-plugin-lock lock`, which is NOPASSWD-granted. Re-check after ANY\n   failed deploy; \"ships unprotected\" is a governance regression, not cosmetic.\n5. **`sudo -n true` proves NOTHING about the command you need.** It tests `\u002Fbin\u002Ftrue`,\n   which no NOPASSWD rule grants, so it always answers *\"a password is required\"* —\n   even where the helper you need IS granted. Read the full `sudo -n -l` list and test\n   the SPECIFIC command (`sudo -n -l \u003Ccmd>` for policy, then `sudo -n \u003Ccmd>` for\n   execution). Never conclude a rule is absent from a TRUNCATED listing: the list runs\n   to dozens of grants and `head`\u002F`tail` hides the entry you want. Either mistake\n   invents a wrong root cause and a wrong \"needs the operator's password\" blocker.\n6. **Never assume uncommitted changes are yours.** With a session alive in the same\n   tree, `git status` is shared news. Investigate before you stash, revert, or commit,\n   and stage explicit paths rather than `git add -A`.\n7. **Do not race a peer's in-flight work.** If another session is mid-update on shared\n   state, `git pull --rebase` cannot pass its dirty tree (\"cannot pull with rebase: You\n   have unstaged changes\") and a deploy will fight it. Work in your own worktree, or\n   stand down until it finishes. Never resolve it by stashing, checking out or resetting\n   their tree: prove the overlap FIRST — their paths from `git status --short` against\n   the incoming paths from `git diff --name-only \u003Cold-head>..origin\u002Fmain` — and only then\n   `git merge --ff-only`, which is safe when the sets are disjoint and leaves their\n working tree untouched.\n\n **Operator-directed exception.** When the operator explicitly says to stash and land a\n peer's work, do it with a safety net and PROVE the round-trip — never on your own\n initiative. Backup first, then stash only their paths:\n\n ```bash\n BK=~\u002F.hermes\u002Fcache\u002Fscratch\u002Fpeer-stash-\u003Cdate>; mkdir -p \"$BK\"\n git ls-files -s -- \u003Cpaths> > \"$BK\u002Findex-snapshot.txt\"             # their index blobs\n git diff --cached --binary -- \u003Cpaths> > \"$BK\u002Fpeer-staged.patch\"   # binary-safe patch\n cp -a \u003Cpaths> \"$BK\"\u002F ; (cd \u003Cdir> && sha256sum \u003Cfiles>) > \"$BK\u002Fbefore.sha256\"\n TREE=$(git write-tree)                                            # their staged tree\n SAFE=$(git commit-tree \"$TREE\" -p HEAD -m \"safety: peer staged snapshot\")\n git tag -f peer-stash-safety \"$SAFE\"        # durable ref: a prune cannot lose it\n git stash push -m \"\u003Cwhat and why>\" -- \u003Cpaths>   # reset index AND worktree for those paths\n git merge origin\u002Fmain\n git stash pop && (cd \u003Cdir> && sha256sum -c \"$BK\u002Fbefore.sha256\")\n ```\n\n - Find the blocking set before stashing anything — the merge names it, and\n   `comm -12 \u003C(git diff --name-only HEAD origin\u002Fmain | sort) \u003C(git status --porcelain | sed 's\u002F^...\u002F\u002F' | sort)`\n   states it independently.\n - Use `git stash push -- \u003Cpaths>`, NOT `--staged`: `--staged` resets only the index and\n   leaves the worktree content behind, so the merge is refused exactly as before.\n - A file whose upstream side ALSO moved comes back from `git stash pop` as an UNSTAGED\n   3-way merge, which is correct but changes their index state — re-`git add` it so their\n   staged set is restored as it was. Only the file whose base moved can be affected.\n - Keep committing by PATHSPEC afterwards: their staged paths ride into any plain\n   `git commit`.\n - **Before assuming the peer will land its own work, check that it CAN.** A cron session\n   has no `skill_view` tool, so the pre-commit reflexion gate refuses EVERY commit it\n   attempts — its staged bundle is stranded by construction (its own DOCS-INDEX row said\n   so) and only an orchestrator can land it. That is the case in which the operator's\n   \"stash and close it out\" instruction is the only exit.\n - **Modifying a peer's artifact needs the OPERATOR, not the gate.** If the gate refuses\n   their file as-is (swallowed errors that can print a false PASS) and then refuses your\n   hardening as `scope-drift` against the description that promised it unchanged, stop\n   and present both findings: the gate can demand a change only the artifact's owner may\n   authorise, and self-authorising it is the same class of error as overriding a finding.\n   A cycle whose DESCRIPTION contradicts the diff cannot be talked out of it — see\n   `governance-closeout`.\n8. **A deploy+push races the peer's next commit.** The push gate compares HEAD with the\n   last-deploy commit, so any commit landing during the minutes-long deploy invalidates\n   it: a *successful* deploy is followed by \"Deploy sync — HEAD ahead of last deploy\".\n   Re-deploying in a loop is whack-a-mole and multiplies deploy windows on a shared tree\n   (each deploy also re-publishes whatever the peer has uncommitted there). The commits\n   are already local — `git status -sb` shows `ahead N` — so ANY push from that host,\n   theirs included, carries yours. Confirm what actually reached the remote with\n   `git fetch -q && git log --oneline -1 origin\u002Fmain` and coordinate rather than\n   thrashing deployments; if the peer is mid-cycle, their push is the one that lands it.\n\n9. **The deploy's sweep is the ONE shared step that can remove a PEER's lock — and it resolves no cycle.** Lock files are per session, so no session's close can touch another's; the collision lives entirely in the purge. Two things about it, both measured:\n   - **A purge is TTL-only.** The standalone purge script (run by the deploy and by a cron) ages a lock by `heartbeat_at` against its own `ttl_seconds` and stops there — it has NO commit-liveness rescue, unlike the MCP's staleness predicate. So a session that is alive but has made no governed call for an hour is judged dead by a peer's deploy. You cannot arm this from the victim side; keep the heartbeat fresh (any governed call refreshes it) or accept the release.\n   - **A purge removes lock FILES only; closing the cycles is a SEPARATE step.** The repair is `_resolve_orphaned_pending_cycles` (which `begin_change` invokes), not the purge. So a sweep that removes an abandoned session's lock leaves its cycle PENDING — and a PENDING cycle whose task has no non-terminal lock is a doctor FAIL that blocks EVERY agent's push on the host. The doctor only auto-resolves cycles older than 24h, so inside that window the leak sits with no owner left to clear it.\n\n   **Verify any claim about this class by planting sessions, never by reasoning about them.** Repoint the module's state dir and DB globals at a throwaway directory, plant locks for each role (a mid-deploy session, a session in another repo, one about to push, one past its TTL), then drive the shipped purge, release and repair functions and assert what each touched — including that live locks are BYTE-IDENTICAL (sha256) before and after. Recipe and the exact checks: `references\u002Flock-purge-and-ownership.md`.\n\n10. **The WRITE gate is per REPO, so a second session never takes its own lock — it rides yours.**\n   The enforcer's rule is \"this repo has an active lock\", satisfied by ANY session's lock for that\n   repo, so a peer session commits freely while yours is live and acquires nothing. The hook then\n   finds exactly ONE matching lock and stamps **your** id on the peer's commits. Locks are unique\n   per session BY FILE NAME (`_session_lock_path(session_id)`), but that uniqueness never gets\n   exercised: nothing forces the second session to call `begin_change`. So \"are locks unique per\n   session?\" is the wrong question — the holes are (a) ownership at the write gate, and (b)\n   attribution at commit time, and git gives the hook NO session identity to attribute with.\n\n   **Diagnose \"a peer's files are in my review\" in this order — do not guess:**\n\n   ```bash\n   git status --short                      # EMPTY ⇒ the files are COMMITTED, not dirty\n   git log --format='%h %s%n  trailer=%(trailers:key=FLEET-Session,valueonly)' -8\n   grep -H -e '\"session_id\"' -e '\"repo_path\"' ~\u002F.steadfaste-fleet\u002Fstate\u002F.governance-*.json\n   ```\n\n   - Empty `status` kills the working-tree\u002F`dirty_at_start` theory immediately: the offending files\n     are in the COMMITTED range, so stashing or reverting changes nothing and destroys real work.\n     Never run a peer's stash\u002Frevert on this evidence — the peer's work is committed and yours to\n     leave alone.\n   - **Every commit carrying the SAME trailer while only ONE lock exists for that repo** ⇒ the peer\n     rode your lock (pitfall above), not a two-lock ambiguity. A per-commit trailer cannot separate\n     two committers who share one id, in either direction.\n   - A stale commit trailer cannot be corrected after the fact; only a new commit gets a new one.\n\n   **Two scope bugs follow from the same root**, and both need fixing for N sessions:\n   a) the **per-blob review demand is the WHOLE UNPUSHED RANGE** (`push_base..HEAD`), regardless of\n      author or session — so whichever session closes first is judged on every unpushed file, its\n      peer's included. Scope it by the attributed session the way the diff already is, disclosing\n      peers by name instead of demanding verdicts for them.\n   b) the consumer must treat an **unattributed** commit as in-scope (fail closed, disclosed at\n      info) — never as \"mine by default\", which is what makes a wrong stamp silently harmful.\n\n   **Attribution is now session-scoped in code; the shared lock NAMESPACE is the part left to you.**\n   The hook stamps a commit only for the SINGLE claimant whose lock was refreshed recently (the server\n   rewrites the lock on every governed call, so its mtime IS that session's last activity) and writes\n   NO trailer when zero or several claimants are equally fresh — an absent trailer keeps the commit in\n   scope for everyone (fail-closed, visible), while a wrong one silently credits your files to a peer\n   and makes theirs yours to answer for. The per-blob DEMAND is scoped the same way: each path is\n   attributed to the commit that produced its CURRENT content (range walked newest-first) and a\n   peer-attributed path is disclosed rather than demanded — the receipt then covers only your own\n   blobs, so the push gate still refuses that range until its OWNER closes it. What no hook can fix is\n   that a session taking no lock of its own still commits under yours, so give each session its own\n   git worktree: separate `repo_path` ⇒ separate locks ⇒ the path match is unambiguous. Do that before\n   filing another scope bug.\n\n11. **The INDEX carries no provenance — a bare `git commit` sweeps whatever is staged, and a\n    pathspec commit structurally cannot.** The index is ONE shared mutable structure whose entries\n    record nothing about WHICH session staged them, so \"these staged files are not mine\" is not\n    answerable from the tree. The cheapest control needs no provenance at all: a PARTIAL commit uses\n    its own temporary index, so it can only ever include the paths you name. Measured as seen by a\n    `pre-commit` hook:\n\n    ```\n    bare commit      GIT_INDEX_FILE=[.git\u002Findex]\n    pathspec commit  GIT_INDEX_FILE=[…\u002F.git\u002Fnext-index-\u003Cpid>.lock]\n    # and after the pathspec commit the foreign entry is STILL staged\n    ```\n\n    So a hook CAN refuse a bare commit in the shared repo and require `git commit -- \u003Cpaths>`, which\n    kills the sweep class instead of merely discouraging it. Compare `$GIT_INDEX_FILE` against\n    `$(git rev-parse --git-dir)\u002Findex`; a difference means a partial commit. Prove the detection with\n    a self-test inside the hook (the way an identity guard is self-tested), and exempt a sanctioned\n    automated committer whose allowlist already proves every staged path is its own.\n\n    **The same shared index also blocks a MERGE**, and the refusal misleads: `git merge` stops with\n    *\"Your local changes to the following files would be overwritten by merge\"* while entries are\n    staged, listing paths the merge would not even touch. Determine WHOSE they are before deciding —\n    if they are your OWN earlier pass's leftovers (an evidence dump staged and never committed),\n    unstaging is legitimate: `git reset -q -- \u003Cpaths>` leaves the files on disk as untracked and\n    unblocks the merge. Never do that to a live peer's staged work; see pitfall 7. Note also that\n    `git ls-tree origin\u002Fmain -- \u003Cpath>` returning empty is the proof those files were never pushed —\n    do not infer from the merge's wording that the remote already has them.\n\n12. **A non-Hermes coding agent's governance id collapses to ONE per repo unless the\n    harness exports a per-session env value — and detecting the sharing is not fixing it.**\n    `get_session_id()` resolves: per-call injection (Hermes enforcer) → env\n    `FLEET_SESSION_KEY` then `PI_SESSION_ID` → per-repo persisted `state\u002F.session-\u003Cslug>.id`.\n    That fallback is ONE id per repo BY CONSTRUCTION (a restart-stability trade for bare\n    harnesses), so every env-less Pi\u002FClaude\u002FCodex session in the repo resolves the SAME id and\n    the SAME lock file: a new session \"picks up\" the existing session's lock, and a close can\n    release a peer's. Pitfall 10 is the Hermes write-gate half of this; this is the non-Hermes\n    resolver half, and it fires even when the second session correctly calls `begin_change`.\n\n    - **Uniqueness comes ONLY from the env step, and only if the harness actually puts the\n      value in the MCP child's environment — a variable can reach ONE subprocess class and be\n      absent from ANOTHER, so measure the seam for the exact consumer, never trust a documented\n      merge (cross-agent-design rule 6).** Two variants each dead-end the resolver's env read:\n      an MCP `env` block that REPLACES the child env (a harness passing `config.env` straight to\n      Node `spawn(env=…)` strips every inherited var, `FLEET_SESSION_KEY` included), and the\n      subtler one on Pi — Pi's stdio transport MERGES (`{...process.env, ...config.env}`), so the\n      block is fine, but Pi exports `PI_SESSION_ID` only into bash-tool commands and never onto\n      its own `process.env`, so the governor's MCP child inherits nothing regardless. Verify\n      which variant the host has by driving the harness's own launcher and reading the child's\n      survives — measured: `loop-gov.py session_identity '{}'` answers `per-repo, shared` on a\n      live Pi session.\n    - **The env-var NAME and its reach differ per harness — survey the exact one, never assume\n      a sibling's `*_SESSION_ID` is the other's.** Verified from each harness's own source (a\n      name documented as *set by the agent* does not mean it lands on the MCP child): Claude\n      Code injects `CLAUDE_CODE_SESSION_ID` (note `CODE`; `CLAUDE_SESSION_ID` is NOT set) into\n      stdio MCP children as of v2.1.154, so it needs no adapter; Codex sets `CODEX_SESSION_ID`\n      but forwards it only to shell commands, so an MCP child gets it only when pinned in\n      `[mcp_servers..env]` or by an upstream change. The resolver honours all of them\n      (`_ENV_SESSION_ID_SOURCES` in loop-gov-mcp.py) and falls back to the shared per-repo id\n      for a harness that supplies none — full matrix: `cross-agent-design` 'N heterogeneous\n      coding agents'.\n    - **Diagnose which source resolved with `loop-gov.py session_identity '{}'`.** A `per-repo`\n      answer on a live session proves no unique env id reached the child.\n    - **Fail-closed ownership (a `shared` id that is never claimable) converts silent theft\n      into visible blocking; it does NOT give sessions separate locks.** The fix lives at the\n      propagation seam — not in more resolver hardening. A static MCP `env` block CANNOT carry\n      a per-session value, so for Pi the working fix is the harness's lifecycle hook setting\n      `FLEET_SESSION_KEY` from its own session manager (`ctx.sessionManager.getSessionId()` in\n      `before_agent_start`, run BEFORE the MCP child spawns; only-if-unset so a gateway pin\n      wins) — proof at `ops\u002Finstall\u002Fharnesses\u002Fpi\u002Fextensions\u002Ffleet-context.ts`. The\n      fleet-gateway `command` backend already pins it per chat when a session runs through the\n      gateway; passing an explicit per-call `session_id` WITH `repo_path` remains the\n      CLI\u002FClaude-Code workaround.\n    - **Slug instability is the opposite failure of the same fallback:** when slug resolution\n      falls through to the child's cwd and that cwd is a temp dir, the slug is `tmp.\u003Crandom>` —\n      a fresh random id per spawn (unstable across an MCP-child restart, so locks orphan) and\n      orphaned `state\u002F.session-tmp.*.id` files accumulate.\n\n## What a shared-server fix must also preserve\n\n- **A shared fixed-path file is only removed by its owner.** The in-repo\n  `.hermes-cortex\u002F.governance-lock` marker is ONE path for the whole repo, so\n  `_release_lock` unlinks it only when the marker's `session_id` is its own (or\n  absent). Otherwise session A's close silently unmarks session B's live lock.\n\n**A lock's `repo_slug` is a HOST fact, not a session fact.** `_derive_slug()`\nprefers the canonical `~\u002Fsteadfaste-fleet`, so a session working in another repo\ngets a lock tagged with the canonical one — and the close gate then reviews a\ntree that cannot contain the work: permanent FINDINGS, an unclosable cycle, and\none full review re-run per retry. The enforcer injects the session's real repo\n(learned from the paths its own tool calls touch, since a `pre_tool_call` hook\nis never given a cwd), and the gate refuses loudly when the lock's repo shows no\ndiff and no commits in the window while another candidate repo gained commits.\n\n**`repo_slug` is a NAME, so carry the ABSOLUTE path too.** The slug resolves as\n`HOME\u002F\u003Cslug>` — a contract the git hooks share — which silently mis-resolves (or\nresolves to nothing) for a checkout nested below a HOME child, i.e. a dev host\nwith many project repos (`~\u002Fprojects\u002F\u003Corg>\u002F\u003Crepo>`), re-creating the wrong-repo\nreview on exactly the hosts a slug-only fix cannot reach. Carry BOTH: `repo_path`\n(absolute, observed per session and injected by the enforcer) decides which tree\nis parsed, while `repo_slug` (the basename) MUST stay, because the git hooks match\nlocks by name. Resolve in this order — recorded `repo_path`, then legacy\n`HOME\u002F\u003Cslug>`, then FAIL CLOSED; never guess a tree to review.\n\nThree consequences: a same-basename repo sitting at `HOME\u002F\u003Cslug>` must never win\nover the recorded path; the in-repo `.hermes-cortex\u002F.governance-lock` marker\nfollows the absolute path, so a nested repo gets its marker inside itself rather\nthan at `HOME\u002F\u003Cslug>`; and the wrong-repo guard's candidate scan must walk HOME a\nfew levels (skipping hidden dirs except `.hermes-cortex`, and treating a directory\nthat IS a repo as a leaf) or a nested repo's commits are invisible to the guard\nand it will happily review the canonical repo instead. Accept an injected path\nonly when it is a real git repo, so a bogus or stale value cannot aim a review at\nan arbitrary directory.\n\n**deploy is not load — and the two halves reload differently.** An MCP fix needs\nthe daemon restarted (kill the child; the parent respawns it on the next call —\nprobe and post-restart check in `governance-closeout`). An ENFORCER\u002Fplugin fix\nneeds a session reload an in-session agent CANNOT perform, and the deploy says so\nitself: grep its output for `Run \u002Freset to load the updated enforcer plugin`\nrather than inferring the reload happened. `kill` is an approval-gated\ndestructive command — if the approval does not arrive, do NOT retry it and do NOT\nroute around it (no alternate kill, no pkill variant): stand down, name which\nhalf is still unloaded, and close the cycle. Always state which half is loaded\nand which is pending; never report a fix as live because it deployed.\n\n**A timing window must be compared as an epoch, not with `git log --since=`**:\napproxidate returned 0 commits for a commit made seconds earlier when the bound\nwas a Z-suffixed UTC instant and the commit date carried a local offset. Use\n`git log --format=%ct` and compare integers.\n\n## Verification\n\n- `git worktree list` shows one tree per active session, each on its own branch.\n- Each tree's `config user.email` differs; `AGENT_NAME` is unchanged fleet-wide.\n- A commit in each tree is authored by that tree's identity\n  (`git log -1 --format='%h %an \u003C%ae>'`).\n- After any deploy: `hermes-plugin-lock status` shows `----i` on every target.\n\n## Related\n\n- `governance-closeout` — closing a cycle the gate refuses; the worktree\u002Frepo binding\n  pitfall is stated there from the close-out side.\n- `governance-lock-lifecycle`, `fleet-bus`, `fleet-commands`, `sudoers-audit` —\n  relevant but USER-OWNED: `hermes curator adopt \u003Cname>` before extending them.\n",{"name":5,"author":24,"license":15,"version":25,"category":26,"metadata":27,"platforms":41,"description":7},"Steadfaste Fleet curator","1.0.0","devops",{"hermes":28},{"tags":29,"related_skills":36},[30,31,32,33,34,35],"governance","git","worktree","identity","concurrency","deploy",[37,38,39,40],"governance-lock-lifecycle","governance-closeout","cross-agent-design","fleet-bus",[42,43],"linux","macos","main","9dc0e92c5fa81d4db5292b205716e8ea0c00d10e","skills\u002Fdevops\u002Fconcurrent-session-isolation",1,"https:\u002F\u002Fgithub.com\u002Flukemcqueen\u002Fsteadfaste-fleet","steadfaste.com","https:\u002F\u002Fgithub.com\u002Flukemcqueen","AI Architect | Building Hermes Cortex: governed multi-agent AI for autonomous software engineering | Enterprise Tech Consultant","2026-11-14 22:33:34",{"source":8,"skillName":5,"commands":54,"prompt":64,"zipAvailable":65},[55,58,61],{"tool":56,"command":57},"npx","npx skills add lukemcqueen\u002Fsteadfaste-fleet --skill concurrent-session-isolation",{"tool":59,"command":60},"bunx","bunx skills add lukemcqueen\u002Fsteadfaste-fleet --skill concurrent-session-isolation",{"tool":62,"command":63},"pnpm","pnpm dlx skills add lukemcqueen\u002Fsteadfaste-fleet --skill concurrent-session-isolation","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Flukemcqueen\u002Fsteadfaste-fleet\u002Fblob\u002Fmain\u002Fskills\u002Fdevops\u002Fconcurrent-session-isolation\u002FSKILL.md",true,[67],{"path":68,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":71,"sourceHtmlUrl":72},"references\u002Flock-purge-and-ownership.md","REFERENCE","参考文档",4335,"https:\u002F\u002Fgithub.com\u002Flukemcqueen\u002Fsteadfaste-fleet\u002Fblob\u002Fmain\u002Fskills\u002Fdevops\u002Fconcurrent-session-isolation\u002Freferences\u002Flock-purge-and-ownership.md",[74,82,89,96,103,110],{"skillNo":75,"name":76,"nameZh":6,"description":77,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":78,"categories":79,"keywords":80,"publishedAt":81},"01M7DXY4G8NSVB59K8B6S2AQNP","macbook-linux-maintenance","Legacy MacBook Linux fixes: GPU wedge, reboot hang, thermal.","https:\u002F\u002Fgithub.com\u002Flukemcqueen\u002Fsteadfaste-fleet\u002Fblob\u002Fmain\u002Fskills\u002Fdevops\u002Fmacbook-linux-maintenance\u002FSKILL.md",[],[],"2026-11-15 14:19:17",{"skillNo":83,"name":84,"nameZh":6,"description":85,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":86,"categories":87,"keywords":88,"publishedAt":81},"01M7DXXYJCXFJ3TGB84ZQ8KFE6","governance-regression-triage","Triage a host's governance issues: what changed.","https:\u002F\u002Fgithub.com\u002Flukemcqueen\u002Fsteadfaste-fleet\u002Fblob\u002Fmain\u002Fskills\u002Fdevops\u002Fgovernance-regression-triage\u002FSKILL.md",[],[],{"skillNo":90,"name":91,"nameZh":6,"description":92,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":93,"categories":94,"keywords":95,"publishedAt":81},"01M7DXXSAP1G8FDRJAMXQGBBMK","enforcement-immutability","Use when enforcement files lose their immutable flag.","https:\u002F\u002Fgithub.com\u002Flukemcqueen\u002Fsteadfaste-fleet\u002Fblob\u002Fmain\u002Fskills\u002Fdevops\u002Fenforcement-immutability\u002FSKILL.md",[],[],{"skillNo":97,"name":98,"nameZh":6,"description":99,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":100,"categories":101,"keywords":102,"publishedAt":81},"01M78SSDQVRYX64Y16X32TC0NS","steadfaste-fleet-repo-deploy","Use when committing to the steadfaste-fleet repo.","https:\u002F\u002Fgithub.com\u002Flukemcqueen\u002Fsteadfaste-fleet\u002Fblob\u002Fmain\u002Fskills\u002Fdevops\u002Fsteadfaste-fleet-repo-deploy\u002FSKILL.md",[],[],{"skillNo":104,"name":105,"nameZh":6,"description":106,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":107,"categories":108,"keywords":109,"publishedAt":81},"01M78SS928F3R2RJAYVW4E30CE","steadfaste-fleet-maintenance","Maintain an installed Steadfaste Fleet instance — update both the upstream Hermes Agent and the fleet repo layer, merge diverged histories, sync skills safely, and troubleshoot common issues. Covers the dual-update workflow (hermes update + fleet-update.sh), encrypted brain data backup, mycortex import, and recovery techniques.","https:\u002F\u002Fgithub.com\u002Flukemcqueen\u002Fsteadfaste-fleet\u002Fblob\u002Fmain\u002Fskills\u002Fdevops\u002Fsteadfaste-fleet-maintenance\u002FSKILL.md",[],[],{"skillNo":111,"name":112,"nameZh":6,"description":113,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":114,"categories":115,"keywords":116,"publishedAt":81},"01M78SP1CHW0T0BWE5ZT6JBPX8","fleet-preflight","DEPRECATED alias — merged into survey-before-action (2026-08-20). Load survey-before-action instead; its \"Repo-Specific Pre-Flight\" section covers git search, Hermes boundary, and deployment verification.","https:\u002F\u002Fgithub.com\u002Flukemcqueen\u002Fsteadfaste-fleet\u002Fblob\u002Fmain\u002Fskills\u002Fdevops\u002Ffleet-preflight\u002FSKILL.md",[],[]]