Agents Builders

Scope span invariant per agent

Archived
scope-span-invariant-per-agent

Created

Jul 03, 12:27

Started

Jul 03, 12:27

Completed

Jul 03, 21:53

DevOps handoff

Type

Bug

Shape

backend

Worktree Slug

scope-span-invariant-per-agent

Repositories

mcritchie-studio

Release Slug

Branch

feat/scope-span-invariant-per-agent

Local URL

QA URL

Production URL

tooling

Acceptance Criteria

  • Parallel soul narrations do not close each others spans
  • Each agent close targets its own open span
  • Session end still closes every open span lane

Expected Test Plan

  • [unit] AtomicEvent.normalize_agent_value lane-key coercion
  • [integration] per-agent span lanes: concurrent souls don't collide; close targets own lane; nil lane independent; close_all closes all; CLI end sends agent (explicit+sticky); API close scopes by agent

Checks Run

  • [unit] normalize_agent_value maps souls / coerces unknown+blank+nil to the nil lane
  • [integration] model: concurrent soul spans stay open, boundary+close scope to one lane, orchestrator nil lane independent, close_all_open closes every lane, unknown close-agent -> nil lane
  • [integration] API close scopes by agent (carl close leaves shannon open); CLI end sends explicit --agent and falls back to the sticky heartbeat soul
  • [full-suite@3a07d74c81e408f7c001d9712da4cd136d88f6ba] bin/rails test green
  • [rubocop@3a07d74c81e408f7c001d9712da4cd136d88f6ba] bin/rubocop clean

Agent Context

Audit 2026-07-02 high finding #4. AtomicEvent enforces ONE open span per session_id: open_event! runs for_session(sid).open.update_all(close) closing ANY open span; close_event! closes for_session(sid).open.order(:seq).last. But pr-review-sop + qa-release spawn parallel soul reviewers that each narrate bin/atomic-event start --agent <soul> in the SHARED parent session (subagents inherit CLAUDE_CODE_SESSION_ID) — so LIGHT's start silently closes PRIMARY's in-flight span (NULL outcome), PRIMARY's end finds no open span (204, CLI prints success on a DROPPED verdict), corrupting the exact trajectories Alex grades. Fix = per-agent lanes: scope the single-open invariant per (session_id, agent). open_event!(agent: X) closes only X's open lane; close_event!(agent: X) closes X's lane; close_all_open! STILL closes every lane (session-end teardown). CLI: end/next resolve the effective agent (explicit --agent OR the #335 sticky heartbeat agent) and send it on close so it targets the right lane. Controller close action + close_params accept :agent. Normalize the agent the SAME way for the WHERE scope as the before_validation coercion (unknown->nil) so lane keys match. KNOWN LIMIT (document, do not claim fixed): raw AtomicAction attribution stays best-effort last-open-span — actions carry no agent and the subagent hook posts under the parent session id (harness-level). This fixes the SPAN/verdict collision (the graded signal), not per-agent action attribution. Regression-test-first: two agents' concurrent spans don't close each other; each end closes its own lane; nil (orchestrator) lane independent of soul lanes; close_all closes all.

Stage Timeline

Who handled each stage, the time it took (measured), and the model / tokens / cost reported (best-effort) — plus who's on it right now. means the agent didn't report that metric.

Sizing Avi · PO SMALL Dev SMALL Actual XL ≠ forecast
  1. Created Designed
    A Arbok
    Arbok
    Model
    Duration
    Tokens
    Cost
    Completed Jul 03, 12:27 · 5 days ago
    api
  2. Designed Building
    A Arbok
    Arbok
    Model
    claude-opus-4-8
    Duration
    under a minute
    Tokens
    1,880,613
    Cost
    ~$1.26
    Started Jul 03, 12:27
    Completed Jul 03, 12:27 · 5 days ago
    cli
  3. Building Submitted
    A Arbok
    Arbok
    Model
    claude-opus-4-8
    Duration
    11 minutes
    Tokens
    33,998,039
    Cost
    ~$18.62
    Started Jul 03, 12:27
    Completed Jul 03, 12:38 · 5 days ago
    cli
  4. Submitted Reviewed Review Activity
    C Carl
    Carl primary
    J Jasper
    Jasper light
    Model
    claude-opus-4-8
    Duration
    about 1 hour
    Tokens
    2,083,382
    Cost
    ~$2.32
    Started Jul 03, 12:38
    Completed Jul 03, 13:46 · 5 days ago
    cli
  5. Reviewed Assembled
    S Steffon
    Steffon
    Model
    claude-opus-4-8
    Duration
    14 minutes
    Tokens
    2,572,485
    Cost
    ~$2.32
    Started Jul 03, 13:46
    Completed Jul 03, 14:00 · 5 days ago
  6. Assembled Shipped
    A Avi
    Avi
    Model
    claude-opus-4-8
    Duration
    about 8 hours
    Tokens
    633,012,664
    Cost
    ~$388.13
    Started Jul 03, 14:00
    Completed Jul 03, 21:53 · 5 days ago
  7. Shipped Archived
    Model
    Duration
    about 10 hours
    Tokens
    Cost
    Started Jul 03, 21:53
    Completed Jul 04, 07:34 · 4 days ago

Conversation

QA review feedback, agent handoffs, and follow-up notes for this task.

No task feedback has been recorded yet.

Sealed-bid sizing

Edit →

Alex (PM)

Avi (PO)

SMALL

Dev

SMALL

Actual

XL