Session curator and chat turn derive the memory AgentID differently: curator memory is unreachable, and single-identity deployments fail every pass #1333

Closed
opened 2026-10-27 13:39:58 +00:00 by sam · 0 comments
Owner

Found by auditing main after memory unification slices 2-5 merged (#886-#889). The epic is closed but this defect is live on main.

ROOT CAUSE: one AgentID concept, two derivations.

Turn path (slice 3) reads agent scope from the router turn-runner bot identity:
internal/gateway/turn_memory.go:121 Subject{AgentID: domainmemory.AgentID(r.BotUser)}
internal/app/archied/chat_setup.go:192 TurnRunnerConfig{... BotUser: cfg.BotUser ...}
cfg.BotUser is the top-level bot_user (defaulted "archie-bot" in setup.go:34) -> always non-empty.

Curator (slice 2) reads it from the session record, which stores the ROUTER IDENTITY NAME, not the bot user:
internal/infrastructure/sessioncurator/sessioncurator.go:195 Scope{Kind: ScopeAgentUser, Agent: domainmemory.AgentID(sess.AgentID), User: participant}
internal/infrastructure/sessioncurator/adapter.go:44 SessionSummary{AgentID: s.Source.BotUser}
internal/gateway/session_commands.go:300 and :549 SessionSource{... BotUser: r.Identity ...}
internal/app/archied/main.go:773 router.Identity = identity
internal/app/archied/main.go chatTaskProfiles: identity is "" when len(cfg.Identities)==0, else identities[0].Name

TWO LIVE CONSEQUENCES:

  1. Single-identity deployments (no identities -- deployments/single-forge-github.toml, the shipped default): AgentID is "" -> Scope.Validate rejects agent-user (contract.go:133 "agent and user both required") -> BuiltinEngine.Create returns an error -> reviewOne returns (nil, err) -> Pass aborts with "session %q: %w". So the curator writes NO memory and fails EVERY pass, permanently: the same session is re-derived on each pass, so it never gets past the first one. Acceptance criterion 4 (a curator pass writes a record a later turn reads) cannot hold there.

  2. Multi-identity deployments (identities present): the curator writes agent-user{Agent:"primary"} while the turn reads {agent:archie-bot, user:u, agent-user:archie-bot:u, global}. The write is never read. Criterion 4 fails SILENTLY there.

SAME CLASS, SAME FILE: any per-session engine refusal aborts the whole Pass and drops the Actions already collected (sessioncurator.go Pass loop returns PassResult{}, err on the first reviewOne error), so one unscannable fact starves every other session. PRD §6 says an unattributable session must "write nothing and record why", not kill the pass.

FIX DIRECTION (agreed with maintainer for the agent-id question: fail closed now, single source of truth):

  • One derivation for both paths. The turn path already answers it with cfg.BotUser; give the curator the same resolved value from the composition (the adapter currently reaches for Source.BotUser, which carries a different meaning).
  • An unaddressable session (empty agent id, zero/several participants) becomes ActionSkipped + continue, never a Pass error; keep the loud Pass error for real infrastructure failures (engine missing, store unreadable). That also makes the single-identity case visible instead of fatal.
  • Add a test that drives sessioncurator.New against the REAL infrastructure/memory.BuiltinEngine with SessionSummary.AgentID == "" and asserts a skip (today it fails with "memory scope agent-user: agent and user both required"), plus a test asserting the curator's AgentID equals the turn's Subject.AgentID for the same deployment. The lane test used a fake engine that never validates a Scope, which is why this passed review.

Close reason

Commit 1 landed: the curator addresses memory by the deployment's bot user (cfg.BotUser) and returns ActionSkipped, not a Pass error, for a session with no agent id. Commit 2 (oyna) is blocked by c1qx and was deliberately not attempted.


Imported from beads archie-core-ga6i · GitHub #904 · type bug · priority P1 · created 2026-09-19 · closed 2026-09-21

Found by auditing main after memory unification slices 2-5 merged (#886-#889). The epic is closed but this defect is live on main. ROOT CAUSE: one AgentID concept, two derivations. Turn path (slice 3) reads agent scope from the router turn-runner bot identity: internal/gateway/turn_memory.go:121 Subject{AgentID: domainmemory.AgentID(r.BotUser)} internal/app/archied/chat_setup.go:192 TurnRunnerConfig{... BotUser: cfg.BotUser ...} cfg.BotUser is the top-level bot_user (defaulted "archie-bot" in setup.go:34) -> always non-empty. Curator (slice 2) reads it from the session record, which stores the ROUTER IDENTITY NAME, not the bot user: internal/infrastructure/sessioncurator/sessioncurator.go:195 Scope{Kind: ScopeAgentUser, Agent: domainmemory.AgentID(sess.AgentID), User: participant} internal/infrastructure/sessioncurator/adapter.go:44 SessionSummary{AgentID: s.Source.BotUser} internal/gateway/session_commands.go:300 and :549 SessionSource{... BotUser: r.Identity ...} internal/app/archied/main.go:773 router.Identity = identity internal/app/archied/main.go chatTaskProfiles: identity is "" when len(cfg.Identities)==0, else identities[0].Name TWO LIVE CONSEQUENCES: 1. Single-identity deployments (no [[identities]] -- deployments/single-forge-github.toml, the shipped default): AgentID is "" -> Scope.Validate rejects agent-user (contract.go:133 "agent and user both required") -> BuiltinEngine.Create returns an error -> reviewOne returns (nil, err) -> Pass aborts with "session %q: %w". So the curator writes NO memory and fails EVERY pass, permanently: the same session is re-derived on each pass, so it never gets past the first one. Acceptance criterion 4 (a curator pass writes a record a later turn reads) cannot hold there. 2. Multi-identity deployments ([[identities]] present): the curator writes agent-user{Agent:"primary"} while the turn reads {agent:archie-bot, user:u, agent-user:archie-bot:u, global}. The write is never read. Criterion 4 fails SILENTLY there. SAME CLASS, SAME FILE: any per-session engine refusal aborts the whole Pass and drops the Actions already collected (sessioncurator.go Pass loop returns PassResult{}, err on the first reviewOne error), so one unscannable fact starves every other session. PRD §6 says an unattributable session must "write nothing and record why", not kill the pass. FIX DIRECTION (agreed with maintainer for the agent-id question: fail closed now, single source of truth): - One derivation for both paths. The turn path already answers it with cfg.BotUser; give the curator the same resolved value from the composition (the adapter currently reaches for Source.BotUser, which carries a different meaning). - An unaddressable session (empty agent id, zero/several participants) becomes ActionSkipped + continue, never a Pass error; keep the loud Pass error for real infrastructure failures (engine missing, store unreadable). That also makes the single-identity case visible instead of fatal. - Add a test that drives sessioncurator.New against the REAL infrastructure/memory.BuiltinEngine with SessionSummary.AgentID == "" and asserts a skip (today it fails with "memory scope agent-user: agent and user both required"), plus a test asserting the curator's AgentID equals the turn's Subject.AgentID for the same deployment. The lane test used a fake engine that never validates a Scope, which is why this passed review. ### Close reason Commit 1 landed: the curator addresses memory by the deployment's bot user (cfg.BotUser) and returns ActionSkipped, not a Pass error, for a session with no agent id. Commit 2 (oyna) is blocked by c1qx and was deliberately not attempted. --- _Imported from beads `archie-core-ga6i` · GitHub #904 · type bug · priority P1 · created 2026-09-19 · closed 2026-09-21_
sam added the highbug labels 2026-10-27 13:39:58 +00:00
sam self-assigned this 2026-10-27 13:39:58 +00:00
sam closed this issue 2026-10-27 13:39:58 +00:00
sam added a new dependency 2026-10-27 13:42:23 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Reference: sam/archie#1333