Skip to content

plan: session-scoped agent identity (Plan / Interface) - #1815

Merged
kantord merged 7 commits into
mainfrom
plan/session-scoped-agent-identity
Sep 29, 2026
Merged

kantord merged 7 commits into
mainfrom
plan/session-scoped-agent-identity

Conversation

@kantord

@kantord kantord commented Sep 23, 2026

Copy link
Copy Markdown
Member

Summary

Stage: Plan / Interface. Durable behavioral and interface contract for ADR 0353 (Session-scoped agent identity, merged in #1783). This does not implement anything — it is the plan/interface review checkpoint before autonomous TDD implementation.

  • Architectural work classification, decision record: ADR 0353.
  • 3 scenarios, 25 acceptance criteria, all with verify: lines.
  • 7 open Human decisions — the plan stays draft until a reviewer resolves them. Each carries a recommendation.

Relates to #1053.

Review already performed

Per /to-acceptance-plan, this draft already went through one devils-advocate pass and two specialist spot-checks before this PR opened, all folded in:

  • devils-advocate: caught a real contradiction — AC2.5 originally claimed behavior that the ADR's own text asserts but the actual code (resolveAgentMemoryHead) doesn't support — plus a hidden Limits zero-value decision, a task-shaped (non-observable) AC, and missing profile:"no-fs" composition coverage. All fixed.
  • software-architect: confirmed the buildAgentDefEngine split and the new AgentDefSessionEngineFactory's shape are sound; flagged a 15-argument positional-prefix duplication risk between the two engine-builder functions and a provider/model-resolver delegation opportunity, both now implementation guidance in "Deferred decisions."
  • secure-code-reviewer: found a CRITICAL, code-verified guardrail bypass — a definition hook's mutated PreToolUse payload is never re-inspected by the guardrail checker today (modelhook.Runner.check reads the stale pre-mutation event) — and a HIGH-severity mistargeted fail-closed guard (the real shared choke point is needsRehydration()/engineAndEnvironmentFor, not rehydrateSession; RetryFailedRun/CompactSession/resumeFromAwaiting share the same exposure and weren't originally named). Both are now explicit ACs (AC1.7/AC1.8, AC3.2) and open Human decisions.

What needs a decision before this can move to proposed

The 7 open Human decisions, in short:

  1. PermissionMode clamp ordinal — local table now vs. block on PR plan(permissions): one named permission-mode vocabulary and two admission gates #1730.
  2. Should AgentDefSessionEngineFactory ever accept a tool-widening parameter? (Recommended: never.)
  3. Fail closed on restart/MCP-resume for v1, or pull in the full authority-persistence fix (Session-scoped agent identity: persist and enforce authority across all engine-rebuild paths #1796)? (Recommended: fail closed now.)
  4. memory: project — thread the session's own placement in, or keep today's process-wide behavior? (Recommended: thread it in — it's real work, but it's also what the ADR already claims is true.)
  5. Limits zero-value semantics on an agent-bound session — inherit vs. explicit-unlimited? (Recommended: inherit.)
  6. Fix the guardrail-mutation-inspection gap in this plan's scope, or narrow the AC and file it separately? (Recommended: fix here — a false security claim is worse than a wider diff.)
  7. Widen the tool base set for explicit opt-in (matching the ADR's stated intent), or correct the ADR text instead? (Recommended: correct the ADR text for v1.)

Test plan

  • bash .claude/skills/to-acceptance-plan/scripts/check-acceptance-plan.sh docs/acceptance/session-scoped-agent-identity.md — passed with warnings (advisory only: no TestADR_NNNN_*/TestInvariant_* names, which is expected — this plan's ACs use the Test<Plan>_Scenario<N>_* convention instead)
  • bash .claude/skills/to-acceptance-plan/scripts/check-acceptance-plan-test.sh — fixture regression suite passed
  • task docs — matlatl strict check: 0 broken links/anchors/orphans across 450 documents

Fully or partially written by an AI agent.

🤖 Generated with Claude Code

@kantord
kantord requested a review from samuv September 23, 2026 17:59

@jhrozek jhrozek left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Traced the plan against the actual code it cites (agentdefs.go, root_authority.go, service.go, modelhook, project_ingestion.go, engine/session, engine/agent/dispatch.go) rather than reviewing the prose in isolation. Most of the plan holds up well and several claims are verified accurate (proto field numbers, mintRootAuthority vs the RootAuthority closure, the modelhook Pre-phase gap). The comments below are the places where the plan's text and the code it's built on currently disagree, plus one substantive design finding on Scenario 3's enforcement strategy. Posting as COMMENT, not a merge-gate verdict — these are inputs for plan/interface review, not blockers I'm asserting unilaterally.

Comment thread docs/acceptance/README.md Resolved
@kantord
kantord force-pushed the plan/session-scoped-agent-identity branch from 329e60d to 8233526 Compare September 28, 2026 10:20
kantord and others added 5 commits September 28, 2026 15:24
Durable behavioral and interface contract for ADR 0353 (Session-scoped
agent identity, merged as #1783). Architectural work classification;
3 scenarios, 25 acceptance criteria, 7 open human decisions (keeps the
plan draft).

Drafted via /to-acceptance-plan, reviewed by one devils-advocate pass
and two specialist spot-checks (secure-code-reviewer, software-architect),
all folded in:
- devils-advocate: fixed a contradiction between AC2.5's original
  claim and the ADR's own text vs. actual code (memory:project
  placement), surfaced a hidden Limits zero-value decision, removed a
  task-shaped AC, added missing no-fs composition coverage.
- software-architect: confirmed the buildAgentDefEngine split and the
  new AgentDefSessionEngineFactory's shape, flagged a 15-argument
  positional-prefix duplication risk and a provider/model resolver
  delegation opportunity for the eventual implementation.
- secure-code-reviewer: found a CRITICAL, code-verified guardrail
  bypass (a definition hook's mutated payload is never re-inspected
  by the guardrail checker today) and a HIGH-severity mistargeted
  fail-closed guard (the real choke point is
  needsRehydration()/engineAndEnvironmentFor, not rehydrateSession,
  and RetryFailedRun/CompactSession/resumeFromAwaiting share the same
  exposure) - both now explicit ACs and human decisions.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Directing human resolved every open decision:
- PermissionMode ordinal: local table now.
- AgentDefSessionEngineFactory: never accepts a widening parameter.
- Restart/MCP-resume: fail closed for v1, keep #1796 separate.
- memory:project: implement placement-aware resolution (real new
  work; the exploratory Slice A branch doesn't do this yet).
- Limits zero-value: means "inherit" for agent-bound sessions only,
  narrow carve-out, pre-existing convention elsewhere untouched.
- Guardrail-mutation-inspection gap: fix in scope (a false security
  claim is worse than a wider diff).
- Explicit tools: widening: correct the ADR wording instead of
  widening code, for v1.

Ready for plan/interface review and merge.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Intermediate commit before rebasing onto main (which moved ~55 commits
since this branch diverged) to re-verify Scenario 3 claims against
current code, notably GrantToolAuthority (landed via #1673/ADR 0355
after this branch's merge-base - not visible in the stale checkout
this commit's Scenario 3 text was verified against).

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Rebased onto main (55+ commits since branch diverged) and re-verified
every code claim against current state, not the stale checkout the
first review pass was drafted against. This surfaced a real gap in
the previous fold-in: GrantToolAuthority (engine/session/principal.go)
landed on main via #1673/ADR 0355 after this branch's merge-base, so
it was invisible to earlier verification - it is a second, real,
currently-unguarded authority-widening method alongside
CompleteWorkspaceEnrollment, and both are now covered by the
Ceiling requirement (AC3.1/AC3.2).

Also folds the rest of jhrozek's round-1 review:
- Fixed real factual errors: ADR 0352->0353 typo and stale
  draft/proposed status in docs/acceptance/README.md's index entry.
- Corrected ADR 0353's stale "lists them explicitly" sentence to
  match actual code (an explicit tools: entry outside the base set
  is silently dropped, not granted) - done in this PR per review
  recommendation rather than deferred.
- Fixed AC1.11's "if and only if" overstatement (no-fs profile still
  removes mutation tools even when the def allows them).
- Expanded AC1.14 to name all 5 cases of the provider/model
  resolution algorithm, not just 2 of 5.
- Corrected the Limits human-decision's premise (server code already
  treats zero as "unset", not "unlimited" - the .proto doc comment
  was the stale one, not the reverse).
- Extended AC1.7/AC1.8's guardrail-mutation-inspection fix to cover
  PostToolUse (result mutation), not just PreToolUse (args mutation).
- Extended AC2.5's memory:project placement fix to require the
  root-aware trust admission check (projectIngestionAdmittedForRoot),
  not the bare global-flag check resolveAgentMemoryHead calls today.
- Noted #1741/#1809's parallel, in-flight redesign of
  CompleteWorkspaceEnrollment's internals as a coordination point,
  written so this plan's Ceiling requirement composes with either
  landing order rather than redesigning that work here.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Round-3 PR #1815 review (high severity, verified not a hallucination):
modelhook.Runner no longer exists on main - ADR 0363 replaced
hook-decorator guardrails with dispatch-level contextual review
(reviewAction/prepareInboundAssessment, engine/agent/dispatch.go).
Re-verified directly: both already inspect the effective/post-mutation
payload (pre.effective for PreToolUse, the post-postHook result for
PostToolUse), closing the exact gap AC1.7/AC1.8 were drafted against.

AC1.7/AC1.8 are now pinning regression tests against the real current
mechanism (confirming an agent-bound session inherits it via ordinary
main-session Deps, AC1.6) rather than a fix targeting removed code.
Retired Human decision 6's premise accordingly.

Also fixed the moderate finding: AC1.12 now states the zero-value
clause Human decision 5 resolved, so it's traceable to a verify: line.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@kantord
kantord force-pushed the plan/session-scoped-agent-identity branch from 8233526 to c7559c9 Compare September 28, 2026 13:25
kantord and others added 2 commits September 28, 2026 15:48
code-review (Standards + Spec) caught real self-inflicted staleness:
- Human decision 7's "tracked below in Deferred decisions" pointed to
  a section that doesn't contain it - the ADR fix was already done in
  this branch's own diff, not deferred. Same bug repeated in AC1.16's
  parenthetical ("separate documentation follow-up, not this AC").
- The Deferred-decisions bullet still called AC1.7/AC1.8 an open
  conditional ("if the corresponding Human decision keeps it in
  scope") after that decision was already resolved to "retired" in
  the previous commit. Dropped them from the bullet per review
  recommendation.

Also fixed the judgment calls:
- Trimmed the GrantToolAuthority/CompleteWorkspaceEnrollment
  mechanism description duplicated near-verbatim between the
  Interface contract and Scenario 3 - Scenario 3 now references the
  Interface contract instead of restating it.
- Added a proper AGENTS.md markdown link for the "mutate Session
  through aggregate methods" citation, matching this doc's own
  citation convention everywhere else.
- Removed a stray double blank line in docs/acceptance/README.md.
- Added AC1.17 for the "no special-casing by discovery mechanism"
  claim, which previously had prose but no verify: line.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Systematic pass per the directing human's request: extracted every
internal cross-reference (all 29 AC mentions, all Human-decision
pointers, every numeric enumeration) and verified each against its
actual target, plus re-verified external PR/issue status.

Found and fixed:
- "either of the two extra grant channels" (opening summary) -
  undercounted; now names all four (RootAuthority, MCPBroker,
  GrantToolAuthority, CompleteWorkspaceEnrollment).
- "beyond the four originally named" (Scenario 3 intro + Interface
  contract, same bug in two places) - the real original count was six
  (SetMode, LoadSessionWithMCP, StartRunContent, RetryFailedRun,
  CompactSession, resumeFromAwaiting), not four. Both now say six and
  name them.
- Scenario 1's "three channels this exploration found" - stale from
  the very first draft, before rounds 2/3 found more channels; now
  scoped correctly to what Scenario 1 itself proves, pointing to
  Scenario 3 for the rest.
- "Deferred decisions" bullet 1 was missing the Ceiling/
  GrantToolAuthority/CompleteWorkspaceEnrollment mechanism entirely -
  the biggest thing ADR 0353's text doesn't name yet, discovered in
  the latest review round, never folded back into this earlier bullet.
- External state drift: PR #1741 (workspace-enrollment-authority)
  MERGED 2026-09-24 - was still described as "proposed, not yet
  approved" in two places (Scenario 3 + Interface contract, same
  stale phrase in both). Re-verified CompleteWorkspaceEnrollment's
  actual code is still unimplemented (naive full-replace) despite the
  approved contract, so this plan's technical claims still hold.
- PR #1730 already renumbered itself again (0351->0365) - fixed two
  "still-unnumbered"/"pending renumbering" mentions.

All AC cross-references (29 ACs), all Human-decision pointers, and
all remaining enumerated counts verified correct on this pass.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@kantord
kantord merged commit a9dfd84 into main Sep 29, 2026
33 checks passed
@kantord
kantord deleted the plan/session-scoped-agent-identity branch September 29, 2026 11:38
@toolhive-release-app toolhive-release-app Bot mentioned this pull request Sep 30, 2026
2 tasks
kantord added a commit that referenced this pull request Sep 30, 2026
… (ADR 0353, Task C)

Implements ADR 0353's 5-case provider/model pair resolution
(resolveAgentDefRootProviderModel) and tighten-only Limits/PermissionMode
clamps (tightenLimits, clampPermissionMode) for an agent-bound session,
wired into agentDefSessionEngineFactory in place of the placeholder
resolveChildProvider call (whose def-wins-over-parent, silent-fallback
contract is wrong for case 5 — an unavailable def-pinned provider must
fail session creation, never silently fall back).

Case 1 delegates to the existing resolveProviderModel for its base-pair
computation, per the plan's own implementation guidance; cases 2-5 are
fresh logic against the request's own ProviderSelector.

Pins AC1.12 (TestSessionScopedAgentIdentity_Scenario1_LimitsTightenOnly),
AC1.13 (TestSessionScopedAgentIdentity_Scenario1_PermissionModeClampedNotRaised),
AC1.14 (TestSessionScopedAgentIdentity_Scenario1_ProviderModelPairResolution).

Plan / Interface PR: #1815 (merged, a9dfd84)

Co-Authored-By: Claude Sonnet 5 <[email protected]>
kantord added a commit that referenced this pull request Oct 8, 2026
Adds the CreateSessionRequest.agent_definition_name / CreateSessionResponse
.resolved_agent_definition_name wire fields, a write-once AgentDefinitionName
label on session.Session and sessnap.Snapshot, and verbatim echo on the
response. Plumbing only: no catalog restriction, provider/model/limits/
permission-mode resolution, or validation is wired from this field yet — that
is later work in docs/acceptance/session-scoped-agent-identity.md.

Pins AC2.1 (TestSessionScopedAgentIdentity_Scenario2_PersistsAcrossSnapshotRoundTrip)
and AC2.2 (TestSessionScopedAgentIdentity_Scenario2_ResponseEchoesBoundName).

Plan / Interface PR: #1815 (merged, a9dfd84)

Co-Authored-By: Claude Sonnet 5 <[email protected]>
kantord added a commit that referenced this pull request Oct 8, 2026
… (ADR 0353, Task C)

Implements ADR 0353's 5-case provider/model pair resolution
(resolveAgentDefRootProviderModel) and tighten-only Limits/PermissionMode
clamps (tightenLimits, clampPermissionMode) for an agent-bound session,
wired into agentDefSessionEngineFactory in place of the placeholder
resolveChildProvider call (whose def-wins-over-parent, silent-fallback
contract is wrong for case 5 — an unavailable def-pinned provider must
fail session creation, never silently fall back).

Case 1 delegates to the existing resolveProviderModel for its base-pair
computation, per the plan's own implementation guidance; cases 2-5 are
fresh logic against the request's own ProviderSelector.

Pins AC1.12 (TestSessionScopedAgentIdentity_Scenario1_LimitsTightenOnly),
AC1.13 (TestSessionScopedAgentIdentity_Scenario1_PermissionModeClampedNotRaised),
AC1.14 (TestSessionScopedAgentIdentity_Scenario1_ProviderModelPairResolution).

Plan / Interface PR: #1815 (merged, a9dfd84)

Co-Authored-By: Claude Sonnet 5 <[email protected]>
kantord added a commit that referenced this pull request Oct 13, 2026
Adds the CreateSessionRequest.agent_definition_name / CreateSessionResponse
.resolved_agent_definition_name wire fields, a write-once AgentDefinitionName
label on session.Session and sessnap.Snapshot, and verbatim echo on the
response. Plumbing only: no catalog restriction, provider/model/limits/
permission-mode resolution, or validation is wired from this field yet — that
is later work in docs/acceptance/session-scoped-agent-identity.md.

Pins AC2.1 (TestSessionScopedAgentIdentity_Scenario2_PersistsAcrossSnapshotRoundTrip)
and AC2.2 (TestSessionScopedAgentIdentity_Scenario2_ResponseEchoesBoundName).

Plan / Interface PR: #1815 (merged, a9dfd84)

Co-Authored-By: Claude Sonnet 5 <[email protected]>
kantord added a commit that referenced this pull request Oct 13, 2026
… (ADR 0353, Task C)

Implements ADR 0353's 5-case provider/model pair resolution
(resolveAgentDefRootProviderModel) and tighten-only Limits/PermissionMode
clamps (tightenLimits, clampPermissionMode) for an agent-bound session,
wired into agentDefSessionEngineFactory in place of the placeholder
resolveChildProvider call (whose def-wins-over-parent, silent-fallback
contract is wrong for case 5 — an unavailable def-pinned provider must
fail session creation, never silently fall back).

Case 1 delegates to the existing resolveProviderModel for its base-pair
computation, per the plan's own implementation guidance; cases 2-5 are
fresh logic against the request's own ProviderSelector.

Pins AC1.12 (TestSessionScopedAgentIdentity_Scenario1_LimitsTightenOnly),
AC1.13 (TestSessionScopedAgentIdentity_Scenario1_PermissionModeClampedNotRaised),
AC1.14 (TestSessionScopedAgentIdentity_Scenario1_ProviderModelPairResolution).

Plan / Interface PR: #1815 (merged, a9dfd84)

Co-Authored-By: Claude Sonnet 5 <[email protected]>
kantord added a commit that referenced this pull request Oct 13, 2026
Adds the CreateSessionRequest.agent_definition_name / CreateSessionResponse
.resolved_agent_definition_name wire fields, a write-once AgentDefinitionName
label on session.Session and sessnap.Snapshot, and verbatim echo on the
response. Plumbing only: no catalog restriction, provider/model/limits/
permission-mode resolution, or validation is wired from this field yet — that
is later work in docs/acceptance/session-scoped-agent-identity.md.

Pins AC2.1 (TestSessionScopedAgentIdentity_Scenario2_PersistsAcrossSnapshotRoundTrip)
and AC2.2 (TestSessionScopedAgentIdentity_Scenario2_ResponseEchoesBoundName).

Plan / Interface PR: #1815 (merged, a9dfd84)

Co-Authored-By: Claude Sonnet 5 <[email protected]>
kantord added a commit that referenced this pull request Oct 13, 2026
… (ADR 0353, Task C)

Implements ADR 0353's 5-case provider/model pair resolution
(resolveAgentDefRootProviderModel) and tighten-only Limits/PermissionMode
clamps (tightenLimits, clampPermissionMode) for an agent-bound session,
wired into agentDefSessionEngineFactory in place of the placeholder
resolveChildProvider call (whose def-wins-over-parent, silent-fallback
contract is wrong for case 5 — an unavailable def-pinned provider must
fail session creation, never silently fall back).

Case 1 delegates to the existing resolveProviderModel for its base-pair
computation, per the plan's own implementation guidance; cases 2-5 are
fresh logic against the request's own ProviderSelector.

Pins AC1.12 (TestSessionScopedAgentIdentity_Scenario1_LimitsTightenOnly),
AC1.13 (TestSessionScopedAgentIdentity_Scenario1_PermissionModeClampedNotRaised),
AC1.14 (TestSessionScopedAgentIdentity_Scenario1_ProviderModelPairResolution).

Plan / Interface PR: #1815 (merged, a9dfd84)

Co-Authored-By: Claude Sonnet 5 <[email protected]>
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.

2 participants