Skip to content

Caller separation: enforce owner-scoped access across sessions, schedules, and delegation (#368) - #501

Merged
jhrozek merged 52 commits into
mainfrom
acc/caller-separation
Aug 13, 2026
Merged

jhrozek merged 52 commits into
mainfrom
acc/caller-separation

Conversation

@jhrozek

@jhrozek jhrozek commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Implements ADR 0102's caller-ownership enforcement (issue #368): every
persisted/live resource a caller can reach — sessions, schedules/fires,
subagent/team-member transcripts, memory stores, live event subscriptions —
is now scoped to the (Issuer, Subject) principal that created it, with
deny-by-default, absence-shaped denials (a foreign caller sees "not found",
never "exists but not yours").

Landed as a stacked acceptance-plan run (docs/plan/) per AGENTS.md's
capability-scale exception, on this single accumulator branch:

  • Ownership core: caller binding on resource creation (internal/adapter/server/ownership.go's ownsResource), the syscaller system principal for internal/background work (never a universal bypass).
  • Persisted + live resource enforcement: sessions, memory stores (partitioned by caller), live subscriptions, schedules (owner-namespaced physical keys vs. caller-visible literal names via server.LiteralScheduleName), subagent/team transcript inspection (InspectSubagent/InspectMember) and Subagent resume — all gated behind a deployment OwnershipEnforced flag, legacy behavior preserved when unset.
  • Classification guard: a reflection-checked table (internal/adapter/server/classification.go) asserting every access path is explicitly classified as owned/shared-infrastructure/system.
  • Session-origin race fix: replaced an atomic-pointer origin binder with a context.Context-scoped WithSessionOrigin, documented in new ADR 0104 (schedule-origin-run-context), superseding ADR 0075's binder mechanism.
  • Not-found leak fix: schedule/fire not-found errors no longer leak the internal owner-namespaced physical store key to the caller.
  • e2e: caller-separation journeys derived from the live k8s-cluster probe (task e2e:k8s, run and green).

Security findings addressed

A multi-agent (Opus) adversarial security audit was run against the caller-
separation surface partway through this work, on top of the schedule-key-leak
fix already landed. Every finding below was personally re-traced against the
code before being treated as real; MEDIUM/LOW findings additionally carry
independent adversarial-verify confirmation. Fixed in this PR:

  1. CRITICAL — Schedule/ScheduleQuery chat tools bypassed ownership filtering entirely. The model-facing tools read the raw scheduleManager directly instead of the ownership-filtered Service, so any caller listing their schedules via chat saw every tenant's rows (name, cron, next-fire, owner digest). Fixed by moving the filter into scheduleManager.ListSchedules itself, so REST, gRPC, and the chat tool share one choke point.
  2. HIGH — GetFire ownership check bypassable via a crafted decoy schedule. GetFire "authorized" a foreign fire by re-deriving a schedule lookup from the fire's already-owner-namespaced name; a caller who created a same-owner-prefixed decoy schedule could make that check pass and read another tenant's fire record. A same-code-path not-found leak (echoing the victim's physical key) was fixed alongside it. Fixed by authorizing against the fire's real owner directly, never a re-derived lookup.
  3. HIGH — cross-tenant schedule/prompt misattribution via one shared session-origin pointer. SessionOriginScheduleManager tracked "the current session" in a single process-wide atomic.Pointer, despite the shared engine serving many concurrent sessions — ordinary concurrent load (no malice needed) could stamp one tenant's run as the owner of another tenant's schedule. Fixed by deriving the origin from the request context.Context instead of shared mutable state (ADR 0104).
  4. HIGH — scheduled fires never ran at all once OIDC was on. The scheduler's tick/fire loop ran entirely under the syscaller system principal, so StartRunContent's authorization check (system principal vs. the fire session's real owner) always failed — silently, forever, with the at-most-once claim already consumed. Two related bugs folded into the same fix: the fire-timeout watchdog's Cancel used context.Background() (losing the principal, so per-fire deadlines silently stopped being enforced), and newFireID minted fire/session IDs from the owner-namespaced physical schedule name (an unsalted fingerprinting oracle baked into caller-visible IDs and delivery notes). Fixed via schedulerOwnerContext, which layers the schedule's real owner over the system-principal context only for the specific authorization-sensitive calls (StartRunContent, Cancel), and by resolving the literal name before minting IDs / rendering delivery notes.
  5. LOW — Subagent resume in-flight guard leaked existence/liveness pre-ownership-check. The process-wide in-flight child-id guard was consulted before the ownership check, so a resume attempt against another tenant's currently running background child returned a distinguishable "already running" message instead of an absence-shaped denial (no content crossed; the resume itself was still denied — an oracle only). Fixed by running the ownership check first.
  6. LOW, docs-only — stale/false rationale in the classification guard. classification.go's memory-consolidation rationale claimed per-caller scoping that the code doesn't actually do (consolidation simply doesn't run under enforcement, so not currently exploitable, but a landmine for a future change). Rationale corrected to match the code.

Not in this PR (tracked separately): a MEDIUM finding — the team registry's global creation cap (Config.MaxTeams) has no per-owner accounting, so one caller can exhaust it for every tenant — is unrelated to caller separation per se (a DoS/fairness issue, not a data leak) and is handed off as its own fix in a dedicated origin/main worktree/PR. A separate unsynchronized-channel-close-vs-send panic in Service.Subscribe/PublishSessionEvent (HIGH, any tenant's disconnect timing could crash the process) was found by the same audit but was already being fixed independently upstream on main; this branch only absorbed that signature change during rebase.

Verification

  • task lint — 0 issues (root + engine + authn/oidc + provider/* modules).
  • task test — green, except one test (TestBuildOperatorContextWindowsFeedEchoListAndPerSessionFactory) confirmed pre-existing and reproducible on plain, unmodified origin/main — unrelated to this branch, root-caused and handed off separately (a test-isolation bug: PermissionsConventional: true tests leak the real developer's ~/.config/mecatl/settings.yaml).
  • task api:check — clean.
  • go run ./cmd/mecademo — full offline session.
  • task e2e:k8s — green (314s).
  • Every commit reviewed via multi-agent panel review (Spec/Standards/Domain axes) before landing; all confirmed/cross-confirmed findings fixed, judgement calls resolved with the branch owner.

Test plan

  • task lint
  • task test (one pre-existing, unrelated, machine-local failure — see above)
  • task api:check
  • go run ./cmd/mecademo
  • task e2e:k8s

🤖 Generated with Claude Code

@jhrozek
jhrozek force-pushed the acc/caller-separation branch 2 times, most recently from a38d8eb to 14b586e Compare August 13, 2026 11:57
jhrozek and others added 27 commits August 13, 2026 22:40
Distinguish the scheduler's system actor from the schedule's caller-owned
resource, deny system principals any operation outside their classified
shared-infrastructure scope, and keep posture changes from ever touching
ownership enforcement. Skip ownerless schedules under OIDC composition so
background workers neither adopt nor retry stranded pre-cutover records,
and pin the raw-driver deployment boundary with a NetworkPolicy scoping
ingress to the mecak8s agent only.

Co-Authored-By: mecatl <[email protected]>
Add a source-level classification guard (ADR 0102 decision 2) over the
designated application-facade, in-memory-registry, event-relay, cache/index,
and model-tool access boundaries: every exported *Service and
memory.CallerStore method, every registered internal/syscaller.Root, and the
model-facing memory/child-observability/team tool family resolve to exactly
one caller-owned, derived, shared-infrastructure, or exempt table entry.
Shared-infrastructure/exempt entries must carry a concrete, reviewable
rationale, so an exemption can never quietly become a caller-owned bypass.
Classifying the table surfaced a real gap — CleanupTeam ignored its ctx and
was the one team verb with no ownership check — fixed in the same change.

Co-Authored-By: mecatl <[email protected]>
A live-cluster probe against a real kind deployment found that CreateSchedule's
collision guard leaks cross-tenant existence and rests on an accidental
fail-closed guard against a latent same-name clobber, because schedule names
are a caller-chosen key that never got memory's owner-namespacing treatment.
An architectural review confirmed the fix is scoped to the create path and
requires no port/backend change.

Co-Authored-By: mecatl <[email protected]>
CreateSchedule's collision guard checked the globally-keyed schedule Name
before the create-time owner was resolved, so a name already used by a
DIFFERENT owner was rejected with a distinguishing "already exists" error
(an existence leak) instead of ADR-0102 decision 1's absence-style
behavior — and both storage backends' unconditional upsert-by-name made
that rejection the only thing preventing a same-named create from a
different owner from clobbering the original.

The schedule manager now computes an owner-namespaced physical store key
(mirroring memory.CallerStore's owner-digest scheme) for every name-keyed
verb (Create/Get/List/Update/Delete/Pause/Resume/GetFire/ListFires/
FireNow), translating back to the caller's literal name on every returned
value. port.ScheduleStore's interface and both backends are unchanged;
only the manager decides which physical string is the key. Two different
owners may now use the identical schedule name without collision or
leak; a same-owner reuse is still rejected. With no verifier wired the
key stays byte-identical to today (a single flat namespace).

Also wire cmd/mecak8s's OwnershipEnforced (mirroring cmd/mecated): the k8s
binary attributed schedule/session/team ownership correctly but never
enforced it, the same class of "enforcement silently not applied" bug.

Co-Authored-By: mecatl <[email protected]>
An adversarial pass over this plan found the process-wide preserved-fork
LRU is unpartitioned by caller (availability/DoS only, no confidentiality
break). Recorded as a deferred, non-blocking follow-up rather than folded
into this plan's scope.

Co-Authored-By: mecatl <[email protected]>
An adversarial pass found Service.Subscribe took no context and made no
ownership decision at all; its sole caller is the untrusted gRPC
StreamSessionLive handler, not the trusted in-process embed its stale doc
comment claimed. A go-architect review confirmed the fix (mirror
StreamSessionEvents, reclassify the guard's Subscribe row) and the test
shape (a new Scenario 3 AC, reusing the existing live-subscription harness).

Co-Authored-By: mecatl <[email protected]>
Service.Subscribe made no ownership decision at all: it took no
context.Context and registered a live event channel keyed purely on the
raw wire-supplied session ID, so any OIDC-authenticated caller who knew
another caller's session ID could stream that session's live events
indefinitely (StreamSessionLive is an untrusted gRPC boundary, not the
trusted in-process caller its stale doc comment claimed).

Subscribe now takes a ctx and returns an error, gating a GetSession
ownership check on OwnershipEnforced (mirroring StreamSessionEvents
exactly); the gRPC StreamSessionLive handler passes stream.Context() and
maps a refusal via the existing toStatus (ErrNotFound covers both
absence and owner mismatch by design, so the RPC stays a non-oracle).
Reclassifies Subscribe from KindDerived (false rationale) to
KindCallerOwned, and strengthens the classification guard to fail when a
KindCallerOwned entry's method has no leading context.Context parameter
-- exactly the shape that let this bug ship unnoticed.

Co-Authored-By: mecatl <[email protected]>
jhrozek and others added 25 commits August 13, 2026 22:44
An adversarial pass found AC3.3 was implemented at half strength:
InspectSubagent/InspectMember correctly authorized inspection, but the
Subagent tool's resume: <agentId> argument loaded a persisted child
session by id with no ownership check at all -- worse than a read leak,
since resume replays the ENTIRE foreign transcript into the resuming
caller's model and persists the resuming caller's turns back onto the
foreign owner's stored session. A go-architect review confirmed the fix
(reuse teaminspect.go's existing callerOwnsTranscript helper, fall into
the existing not-found branch) and the test shape.

Co-Authored-By: mecatl <[email protected]>
engine/agent/subagent.go's resolveResumeSession (the load path for the
Subagent tool's `resume: <agentId>` argument) made NO ownership check: it
loaded a persisted child session from t.store purely by id and never
compared its Owner against the calling principal. AC3.3 ("a model given
another caller's subagent or team handle cannot inspect its transcript or
act on it") was implemented at half strength -- InspectSubagentTool/
InspectMemberTool correctly authorize inspection of the same store by the
same kind of id, but resume, the "act on it" half, did not.

This is worse than a read leak: InspectSubagent returns a bounded (40
messages/1000 runes/8000 total) transcript in one ToolResult, while resume
replays the foreign owner's ENTIRE conversation into a child engine the
resuming caller's own model-authored prompt then drives, with no clamp.
Worse still, resume MUTATES the foreign owner's persisted record --
issue #38's resume-start persist re-saves the loaded snapshot BEFORE the
child drives, so the resuming caller's turns get appended to the foreign
owner's stored session even when the child drive itself later fails.

Fix: reuse teaminspect.go's existing callerOwnsTranscript(ctx, sess)
verbatim, checked immediately after the Load and before the resume-start
persist, falling a foreign-owned load into the EXISTING not-found branch
(never a second, distinguishing error message -- that would itself be the
leak this closes). Both call sites (foreground prepareChildSession,
background startBackground) funnel through this one function, so one
fix covers both.

Also fixes internal/adapter/server/classification.go: adds the missing
"Subagent" row to ModelToolBoundaries/modelToolAccessTable, and corrects
InspectSubagent's rationale, which wrongly said "resumes" (that verb
belongs to Subagent; InspectSubagent only reads).

Two follow-ups noted, not fixed here: a ctx-vs-session-owner divergence on
the scheduler fire path (documented in docs/acceptance/caller-separation.md's
Deferred decisions section), and a doc-comment note on inheritOwner that
its "resumed child already carries this owner" assumption is now an
enforced invariant.

verify: TestCallerSeparation_Scenario3_SubagentResumeIsOwnerChecked

Co-Authored-By: mecatl <[email protected]>
Written after hand-driving the equivalent curl journeys against a real
kind cluster (real Dex tokens, real mecak8s pods built from this
accumulator) and observing the actual responses -- the two real gaps
found that way (cmd/mecak8s never wiring OwnershipEnforced, and the
schedule collision guard leaking cross-tenant existence) are both fixed
upstream of this commit and exercised here.

Flip caller_identity_test.go's Story 3/4, per their own inline "when
#368 lands, FLIP this" instructions: a caller's session list is now
scoped to their own rows, and a foreign prompt is refused absence-shaped
instead of permitted. New caller_separation_test.go covers the surfaces
those stories don't: two owners sharing a schedule name without
collision or leak (AC6.1/6.3), same-owner reuse still rejected (AC6.2),
a foreign schedule load/delete staying absence-shaped and non-mutating
(AC2.4), and a foreign session fork/carryover source being refused
without disturbing the source (AC1.6).

Co-Authored-By: mecatl <[email protected]>
Issue #368 shipped application-level ownership enforcement for
mecak8s-oidc; this doc previously described the overlay as
attribution-only ("records who acted, refuses nothing", "Isolation:
None"), which is no longer true and would actively mislead an operator
deciding whether this meets their tenancy needs. Update the caller-
identity section, the raw-driver NetworkPolicy note, the actor-vs-owner
example (a foreign prompt is now refused, so the scheduler's own
system-principal fire is the illustrative case instead), and the
"what this does not give you" table's isolation row.

Co-Authored-By: mecatl <[email protected]>
An operator reading deployment docs doesn't need internal issue
numbers or a note about what an earlier revision of this doc used to
say -- keep the ADR links (this doc's existing convention for citing
the why) and drop the rest.

Co-Authored-By: mecatl <[email protected]>
…e name

GetSchedule/UpdateSchedule/PauseSchedule/ResumeSchedule/ListFires/FireNow
were returning the raw store error verbatim on a miss, which for a
redisstore-backed schedule store embeds the owner-namespaced physical key
(the SHA-256 owner digest) in the error text instead of the literal name
the caller supplied — an absence-shaped-error violation and an
internal-implementation-detail leak. scheduleNotFoundErr normalizes every
such error to name only the caller-visible literal identifier.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Rebased acc/caller-separation's #368-specific commits onto origin/main
(dropping the 5 stale #367/spike-authn-wiring commits this branch had
carried since it forked from an earlier snapshot of that work, now
superseded by the merged, submodule-extracted version). The rebase
itself was clean save for a handful of additive conflicts; these are
the follow-up fixes needed because origin/main independently evolved
some of the same call surfaces after the fork point:

- Engine.Run's signature moved from a bare (ctx, sess, ws, string) to
  (ctx, sess, ws, RunRequest{Text: ...}) upstream; two call sites
  (engine/agent/subagent_resume_owner_test.go, added by this branch's
  own subagent-resume-owner-check task) still used the old shape.
- Service.Subscribe gained a third (error) return value here (the
  ownership-check task); four pre-existing calls in
  subscription_test.go still used the old two-value shape.
- Service.Subscribe's early-return path (a subscriptionsClosed guard
  added independently upstream — origin/main already fixed the
  same close-vs-send race this branch's own security audit flagged as
  a separate finding) was missing the new third return value.
- classification.go's reflection-checked systemAccessTable didn't yet
  know about syscaller.RootModelCatalogRefresh, a new internal root
  origin/main added for the startup live-model-catalog refresh;
  classified it KindSharedInfrastructure (a one-shot, caller-free,
  process-wide catalog fetch, same shape as RootJWKSRefresh).

task lint && task test are green on both modules; go run ./cmd/mecademo
still produces a clean offline session.

Note: docs/adr/README.md and engine/CHANGELOG.md carry a flagged ADR
number collision (this branch's 0102/0103 vs origin/main's own 0102/0103)
inherited from the merge — needs a renumbering pass before this ships,
noted inline where the collision was resolved.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
GetFire's rationale still described the pre-e81e4b24 GetSchedule-delegating
path; the manager now loads the fire's parent schedule directly by its
stored physical key and compares owners. The model-facing Schedule tool's
rationale borrowed GetFire's new wording even though the tool never calls
GetFire (that's a separate gRPC/REST-only boundary) — restate it in terms
of the verbs the tool actually drives.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Scheduler bookkeeping (Claim/RecordFire*/diagnostics/event-attribution)
keeps the syscaller system context; only the run-entry-adjacent calls
(StartRunContent, the fire-timeout watchdog's Cancel, the delivery
driver's GetSession/StartRunContent/fireFinalText) receive a context
carrying the schedule's own already-captured owner via the new
schedulerOwnerContext helper, so ownsResource resolves against the real
owner instead of denying every fire once OwnershipEnforced is on.
Ownerless schedules correctly stay on the system context and fail
closed. server.LiteralScheduleName keeps the owner-namespaced physical
key out of minted fire/session IDs and lifecycle-event/metric payloads.

Amended to close a gap the review found: fireFailed's create-time
failure fallback (reached when CreateSessionWithProfile itself fails,
before a session exists) still minted its fire id from the raw physical
schedule name -- LiteralScheduleName's fix only covered the success
path. Also folded in two related cleanups the same review surfaced:
LiteralScheduleName is a total, self-guarding function (identity on any
non-namespaced key), so gating its use on an ownershipEnforced bool was
dead weight inconsistent with the delivery driver's own unconditional
call -- dropped the parameter (and the matching build.go gate around
SetPresentScheduleName) so there is one policy, not three copies of it.
LiteralScheduleName's hex-digit validation now uses encoding/hex.DecodeString
instead of a hand-rolled per-rune loop.

Co-Authored-By: mecatl <[email protected]>
Co-Authored-By: Claude Sonnet 5 <[email protected]>
InspectSubagentTool/InspectMemberTool shared callerOwnsTranscript, which
treated an absent principal in the tool's OWN ctx as proof that ownership
enforcement is off deployment-wide -- a category error: a nil caller
means "no verified principal reached this call," not "this deployment
has no verifier." Any path where the tool's ctx lacked a principal would
let it return ANY persisted child/member transcript to ANY caller, in an
enforced deployment. Fixed by threading the deployment's actual
cfg.OwnershipEnforced flag into both tools at construction (new
NewInspectSubagentToolWithOwnership/NewInspectMemberToolWithOwnership,
wired in internal/app/catalog.go; old constructors kept, defaulting to
unenforced for existing embedders) and gating on it explicitly via the
new callerOwnsTranscriptWhenEnforced, rather than inferring the
deployment's posture from context state.

Amended to close a gap the review found: callerOwnsTranscriptWhenEnforced's
disabled branch returned true unconditionally, which is MORE permissive
than the callerOwnsTranscript it's meant to stay backward-compatible
with -- the old predicate still denied a present-but-foreign VERIFIED
caller regardless of any flag. An identity-recorded-but-not-enforced
deployment would have silently lost that check. The disabled branch now
falls back to callerOwnsTranscript instead of blanket-allowing, and the
"legacy compatibility" test was corrected to distinguish a genuinely
absent principal (still permissive, as intended) from a verified foreign
caller under an unenforced-constructed tool (now denied, matching the
predicate it replaces).

The identical category-error shape still exists, unfixed, in
resolveResumeSession (engine/agent/subagent.go)'s use of the untouched
callerOwnsTranscript for the Subagent{resume:...} path -- confirmed not
currently exploitable (SubagentTool is never registered on team-member
or forked-child catalogs, and every production ctx is stamped with a
real principal), but left as a structural landmine with no explicit
enforcement flag to catch a future drift. Tracked as a follow-up, not
fixed here.

Co-Authored-By: mecatl <[email protected]>
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Authorize persisted subagent resumes before consulting the shared
in-flight registry, and require a verified matching caller when
ownership enforcement is enabled.

Amended to close two gaps the review found:

- A confirmed task lint failure: the new pre-guard check pushed
  (*SubagentTool).run's cyclomatic complexity to 21 (threshold 20).
  Fixed by moving the "if resuming" branch inside
  authorizeResumeLookup itself (a no-op when not resuming), so run()
  carries one branch here instead of two nested ones.

- Cross-confirmed duplication: the load-then-ownership-fold-then-
  error-branch block was now written out a second time, verbatim,
  inside authorizeResumeLookup and resolveResumeSession. Extracted
  the shared read-only fold into loadOwnedResumeSession, called by
  both. Each caller still performs its OWN fresh Load at its OWN
  point in time -- the pre-guard Load (no exclusion, before
  tryAcquireChildID claims the id) is never threaded into
  resolveResumeSession's later, authoritative Load (which runs only
  after a successful claim, under that id's exclusion, on a session
  about to be Reopen/Interrupt/Recover'd and re-persisted, and on
  the background path resolved later on a detached goroutine) --
  doing so would turn a benign snapshot read into a stale write
  input. Threading the loaded session forward was considered and
  rejected for exactly this reason; the fix shares the CHECK LOGIC
  only, never the loaded data, and the new doc comment says so
  inline.

Also corrected callerOwnsTranscriptWhenEnforced's doc comment, still
describing itself as "the persisted-inspection predicate" from when
only the two Inspect tools consumed it -- it now gates a third,
non-inspection caller (Subagent's resume path) too.

Co-Authored-By: mecatl <[email protected]>
Co-Authored-By: Claude Sonnet 5 <[email protected]>

# Conflicts:
#	engine/CHANGELOG.md
Rebasing acc/caller-separation onto the latest origin/main (which
independently added two more ADRs both numbered 0104, on top of this
branch's own 0104-schedule-origin-run-context.md) left the ADR
README's index listing only one of the three same-numbered entries --
a rebase merge artifact, not data loss; all three files were intact
on disk. Added the two missing index entries with the collision
flagged inline, matching this repo's existing tolerated-duplicate-
number convention (0100/0101/0103 already have precedent).

go.work.sum gained the checksum entries go build/test naturally
produces for the module-graph shift from origin/main's dependency
bumps; a pure-additive sync, nothing removed or changed.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
matlatl's strict docs gate caught a broken relative link introduced in this
branch's very first plan commit: docs/acceptance/README.md pointed at
caller-identity-e2e.md, a companion e2e-verification plan doc that was
referenced but never written — its intended scope (real IdP, real cluster,
owner-survives-failover) ended up covered directly inside
caller-separation.md's live-cluster-probe section instead. Regenerate llms.txt
to match.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
CreateSchedule was check-then-upsert: a Load followed by a separate Save,
racing across two store calls. Two concurrent same-owner creates could both
observe absence and one would silently overwrite the other.

Add the OPTIONAL port.ScheduleCreator seam (mirroring the existing
ScheduleOneShotReArmer type-assertion pattern) with an atomic Create that
returns ErrScheduleAlreadyExists on collision. memschedulestore, jsonlstore,
and redisstore all implement it under their existing single-lock/single-EVAL
discipline; the manager routes through it when available and falls back to
the pre-existing check-then-Save otherwise (documented residual TOCTOU on
that path only). Adds conformance coverage (concurrent-create-one-winner) run
against every backend, plus manager-level tests for both the atomic and
fallback paths.

Review finding 5 (docs/acceptance/caller-separation.md, ADR 0102).

Co-Authored-By: Claude Sonnet 5 <[email protected]>
ownerScheduleNamespace mapped a missing principal to a shared
"schedule/none\x00" bucket instead of rejecting, so under ownership
enforcement any call path lacking a verified principal could create or
operate on shared ownerless schedules alongside every other unauthenticated
caller.

Add requireCaller, checked first by every public ScheduleManager verb
(Create/Get/List/Update/Delete/Pause/Resume/FireNow/GetFire/ListFires): it is
a no-op when enforcement is disabled, and rejects fail-closed when
enforcement is enabled and ctx carries no principal. Read/mutate verbs on an
existing name get the same absence-shaped not-found a genuinely-missing
schedule produces; Create gets a generic refusal; Delete stays an idempotent
no-op. The shared-bucket fallback inside ownerScheduleNamespace is now
unreachable from any of the guarded verbs (the tick/fire path never calls
them — it drives the raw ScheduleStore directly) and stays only as an
internal fail-safe.

Review finding 4 (docs/acceptance/caller-separation.md, ADR 0102).

Co-Authored-By: Claude Sonnet 5 <[email protected]>
…rcement

validateScheduleOrigin loaded OriginSessionID and returned its owner without
comparing it to the verified caller. Create/Update adopted that owner
verbatim, so a caller who merely knew another caller's session id could name
it as a schedule's origin — every fire's delivery path (deliverFireResult /
deliverFireStarted) then trusted spec.Owner to enqueue content into that
foreign session.

Under ownership enforcement, require the origin session's owner to match the
verified caller (an ownerless origin also fails — it is invisible to every
caller, the same rule GetSession already applies). Both the missing-session
and the existing-but-foreign-owner cases now produce the byte-identical
"origin_session_id %q must reference an existing session" message via one
constructor, so the error can't be used as an existence/ownership oracle.
Non-enforced deployments are unaffected (ADR 0100's origin-wins-over-caller
attribution is unchanged there). The check runs at validation time, before
anything is saved, so a rejected create never reaches the delivery path.

Review finding 1 (docs/acceptance/caller-separation.md, ADR 0102).

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Subagent/Parallel/Team all derived their durable child session id from ONLY
the provider tool-call id, a value the LLM API supplies and does not
guarantee unique across independent conversations, let alone across owners.
Two different top-level sessions issuing equal or adversarially-chosen call
ids would derive the identical child SessionID and silently overwrite each
other's persisted transcript before any inspect/resume authorization ever ran.

parentCaps now carries the parent session's own id (already collision-safe
across owners via the existing atomic session-creation enforcement) alongside
its owner; SubagentTool.childSessionID, ParallelTool.childSessionID, and
TeamTool.run's teamID derivation all thread it in as a namespace segment
("subagent-<parentID>-<callID>", "parallel-<parentID>-<callID>-<i>",
"<parentID>-<callID>" for MemberSessionID). A caps-less drive (plain
Execute/ExecuteObserved, no parent session threaded) keeps the pre-fix
call-id-only id — unaffected outside real dispatch. Every prefix-only
consumer (resume parsing, InspectSubagent/InspectMember, the childgc prefix
list) is unaffected; only assertions of the exact derived id needed updating
across the test suite.

Adds equal-call-id collision tests across two different parent sessions for
all three delegation families.

Review finding 2 (docs/acceptance/caller-separation.md, ADR 0102).

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Two more places assumed a delegation id was derived from the call id alone
(review finding 2, issue #368): mecademo's background-subagent demo scripts
the SubagentStatus collection call against a pre-computed child id, and the
gRPC Converse per-member-cancel e2e asserted a hardcoded MemberSessionID.
Both now compute the expected namespaced id (parent session id + call id).

Also picks up a gofmt fix on schedule_manager_create_test.go flagged by
`task lint` (gci import grouping).

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Rebasing onto origin/main pulled in SessionStale/LeaseSweepDisabled/
SettleIfStale (#475's crash-orphan sweep), added independently of the
classification guard this branch introduces. All three are composition-
owned process-wide maintenance, never a caller-facing verb.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Rebasing onto origin/main pulled in the execution-environments refactor
(issue #503), which changed Tool.Execute's third parameter from
tool.Workspace to the new tool.Environment struct and renamed
Service.SetSessionWorkspace to SetSessionEnvironment. Update every test
call site this branch's own commits added, and reclassify the renamed
method.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@jhrozek
jhrozek force-pushed the acc/caller-separation branch from 14b586e to 2d90477 Compare August 13, 2026 21:01
@jhrozek
jhrozek merged commit f25a494 into main Aug 13, 2026
16 checks passed
@jhrozek
jhrozek deleted the acc/caller-separation branch August 13, 2026 21:20
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