aboutsummaryrefslogtreecommitdiff
path: root/.ai/protocols.org
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-30 21:48:13 -0500
committerCraig Jennings <c@cjennings.net>2026-05-30 21:48:13 -0500
commit143feda0644d2289954b694f3ce4cee2fc74b808 (patch)
tree539452f3e7a47b24b2e9a0dd9a98e1e9c67f30a3 /.ai/protocols.org
parent9a1bea9bfc066312bf9743dc23c88f191a36cc16 (diff)
downloadrulesets-143feda0644d2289954b694f3ce4cee2fc74b808.tar.gz
rulesets-143feda0644d2289954b694f3ce4cee2fc74b808.zip
feat(session-context): resolve the active path per AI_AGENT_ID
A single .ai/session-context.org races when two agents share a project: each agent's writes clobber the other's session log. I added .ai/scripts/session-context-path, which resolves the active path from AI_AGENT_ID: unset gives the legacy .ai/session-context.org singleton (so every existing one-agent session is unchanged), set gives .ai/session-context.d/<id>.org with the id sanitized to filename-safe characters. This is Codex's Phase 1 slice from the runtime-neutral spec: the race fix on its own, no broader refactor. startup.org's existence check and wrap-it-up.org's rename now resolve through the helper, each with a singleton fallback so older checkouts that haven't synced the script still work. Wrap folds the agent id into the archive name so two agents wrapping in the same minute don't collide. protocols.org documents the rule. Verified with 5 bats cases and a two-agent simulation showing distinct paths per id.
Diffstat (limited to '.ai/protocols.org')
-rw-r--r--.ai/protocols.org9
1 files changed, 9 insertions, 0 deletions
diff --git a/.ai/protocols.org b/.ai/protocols.org
index 6e415e3..d5290aa 100644
--- a/.ai/protocols.org
+++ b/.ai/protocols.org
@@ -84,6 +84,15 @@ Mechanics live in =startup.org= Phase A.0. The rule lives here because it govern
Location during session: =.ai/session-context.org=
Location after wrap-up: =.ai/sessions/YYYY-MM-DD-HH-MM-description.org=
+*** Agent-scoped path (=AI_AGENT_ID=)
+
+When two agents share one project at the same time, a single =session-context.org= is a race — each agent's writes clobber the other's. The active path is therefore resolved per agent:
+
+- =AI_AGENT_ID= unset or empty (the normal one-agent-per-project case): =.ai/session-context.org=, exactly as before.
+- =AI_AGENT_ID= set: =.ai/session-context.d/<id>.org= (id sanitized to filename-safe chars). Archived at wrap-up to =.ai/sessions/YYYY-MM-DD-HH-MM-<id>-<description>.org= so concurrent agents don't collide on the archive name either.
+
+Resolve the path with =.ai/scripts/session-context-path= rather than hardcoding =.ai/session-context.org=; it prints the right path for the current =AI_AGENT_ID=. Fall back to =.ai/session-context.org= if the script isn't present (older checkouts mid-sync). Everything below — the record/recovery purpose, the update triggers, the startup existence check, the wrap-up rename — operates on that resolved path. The prose says "session-context.org" as the default name; read it as "the resolved active path" when =AI_AGENT_ID= is set.
+
This file serves two purposes with one mechanism:
1. *Crash recovery* — if the session dies mid-work, the live file is all that's left. On 2026-01-22 a session crashed during a 20-minute design discussion and all context was lost because this file wasn't being updated.
2. *Session archive* — at wrap-up the file is renamed into =.ai/sessions/=, becoming the permanent record. No transcription to notes.org; the file IS the record.