Skip to content

feat(hooks): supply ATOMIC_SESSION_ID to shells for work-start binding - #14

Open
graywolf336 wants to merge 1 commit into
releasefrom
feat/work-start-binding
Open

graywolf336 wants to merge 1 commit into
releasefrom
feat/work-start-binding

Conversation

@graywolf336

Copy link
Copy Markdown
Contributor

Summary

atomic intent update <id> --status in_progress can bind the governing intent to the active session turn — the CLI persists the binding under .atomic/sessions/<id>/, and the turn's end-of-turn recording then carries the intent UID in plan_id, which is what atomic intent graph uses to attribute the turn's recorded changes to that intent. The CLI reads that session context from --session-id or the ATOMIC_SESSION_ID environment variable, but nothing ever supplied it — so every declaration issued from an agent session stayed a status-only update and the intent graph had no plan_id to read.

This plugin now supplies the context: shells launched from a tracked agent session carry ATOMIC_SESSION_ID, so the plain command the skills already teach binds the turn. No flags needed from the agent.

Changes

  • v1 shell.env: sets ATOMIC_SESSION_ID from input.sessionID (bash-tool events carry it; terminal/pty shells don't, which keeps the human status-only path).
  • v2 create.before: same, from event.sessionID when the host provides it.
  • Injection is gated on a new read-only isStarted tracker lookup — only sessions whose session-start hook has fired. A failed binding fails the whole update (the CLI binds before it updates status), and the CLI rejects declarations for unknown sessions, so unstarted and terminal shells keep the previous environment exactly.
  • Integration version 1.1.1 → 1.2.0 so atomic agent enable ships the updated package from storage.

Notes

  • Backward compatible: older CLIs ignore the environment variable, so nothing breaks — the binding simply activates once the CLI with session-binding support ships (atomic baseline PR #265). requires stays >=0.11.0 for that reason.
  • Pairs with the atomic-skills PR documenting the per-turn declaration.

Verification

bun test — 20 pass. New cases cover v1 started session (injected), unstarted session and terminal shell (not injected, and the lookup materializes no state), v2 started session (injected), and v2 foreign session (not injected).

The atomic CLI's session-binding flags on intent update (--session-id,
or the ATOMIC_SESSION_ID environment variable) let
`atomic intent update <id> --status in_progress` bind the governing
intent to the active session turn. Without session context the command
stays a status-only update and the intent graph never learns which
intent governs the turn's recorded changes.

Both plugin entrypoints now supply that context:

- v1 `shell.env` reads `input.sessionID` (bash tool events carry it;
  terminal/pty shells do not, keeping the human status-only path).
- v2 `create.before` reads `event.sessionID` when the host provides it.

Injection is gated on a new read-only `isStarted` tracker lookup: a
failed binding fails the whole update, so only sessions whose
session-start hook has fired get the variable — the CLI rejects a
declaration for an unknown session. Unstarted and terminal shells keep
the previous environment exactly.

Tests: v1 started/unstarted/terminal shell cases, v2 started/foreign
session cases (20 pass). Integration version 1.1.1 -> 1.2.0 so
`atomic agent enable` ships the updated package from storage.
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.

1 participant