Repository navigation
Conversation
The broker now records runs and delegations per broker session and applies design step (6) checks 4 and 5 to every AuthorizeCall: - ReportDelegation records a delegation from a run of one agent to a new run of another, with the design's six checks in order. An unseen delegating run is recorded as a root run of a root instance. - A call's run must be bound to the acting agent and act under the delegation it names; a new run naming no delegation needs a root instance. The reported run owner must equal the run's owner and the grant's owner, in one function a later membership check can replace. - A first call's run is recorded only once both checks pass. - The grant records its user, and the ID-JAG record carries the delegation, run owner, and grant user. mecak8s reports the runs it already knows: - Every server run entry puts the session's run ID and owner on the engine context; a RunTeam call mints its own run of the root's main agent, owned by the root's owner. - Each helper registration and resume reports a new delegation from its parent agent's current run and keeps it with the helper's credential. - A gateway call names the main agent's run, or the helper's delegated run, and is refused when there is none, replacing the run serial stand-in. - After a broker session reopens, every held delegation is reported again in its original order. Part of #2554. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… none Review follow-ups: - A helper resumed by a parent with no run no longer keeps acting in its earlier run; its gateway calls fail closed, as documented. - Tests pin that one delegation starts one run, that a resume with no run holds no delegation, and that rootedRunContext carries the session's run or masks the caller's. - Shortcut notes name #2805 for runs across replicas; delegations are described as kept until the root is dropped, since the design gives them no end. - The design's delegation report lists the refusal of a receiving run that is already recorded; Service and Core docs cover the delegated run a call can record and another workload's delegation report. - Delegation IDs use rand.Text, as the broker's own IDs do. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ecks A parallel branch, a Team tool member, a member of a team the API creates and runs, and a subagent resumed after its root's broker session reopened each call the gateway through mecak8s's startup, the real AS-1 and AS-2, and the embedded vMCP. A helper is not a root instance, so each completed call proves mecak8s reported the delegation that started its run and the broker accepted it. Skipping the report fails all four. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Once a session's run and delegation records reach their cap, a delegated run whose record was forgotten is recorded again from its delegation, for the delegation's receiving agent only, and a run whose own delegation was forgotten can no longer delegate. Both refusals were reachable only after forgetting, so no test failed when either was removed. The credential holder's list of delegations to report again forgets its oldest entry at its cap while each helper keeps its current delegation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- One deniedError helper for credential, run and delegation refusals. - Name the run owner shortcut where the server reads the session owner at each run entry (removed by #2569), and cite the run-owner draft by its full path. - startTeamRootRun says that it starts the RunTeam run, not only opens the root's broker session. - Tests: a shared createSession helper, sync.OnceValues for the late-loading mock script, and slices.Repeat for its padding. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ChrisJBurns
left a comment
There was a problem hiding this comment.
Review against the agent identity design and #2557. This lists only issues, gaps, and questions. Nothing here blocks the PR, and none of the correctness items is an authorization bypass; they all fail closed. Please address each one or reply with your reasoning.
Design changed or contradicted without sign-off
- Run owner for interactive runs (major).
run-owner.mdand #2557 say mecak8s records the run owner when the run starts, from that request's AS-1sub_id. The code readssess.Owneragain at every run entry (internal/adapter/server/service.go:10085). The shortcut says #2569 removes this, but #2569 covers only scheduled runs. Nothing tracks the interactive case. Please file an issue for it, or get sign-off on decision 5. - Grants keyed by (session, user) (major). This is a listed #2557 requirement and is still
run-owner.mditem 3. Decision 6 replaces it with a singleownerfield (internal/identitybroker/sessionopen.go:285) without amending the ticket or the design. Either amend both, or implement the requirement. - Re-reporting after a reopen sends the whole history, not the open delegations (major).
credentials-and-lifecycle.mdstep (3) says to report the open delegations again. Decision 2 re-reports every delegation ever made, so ended helper runs come back in the new broker session. The design never says when a delegation ends (the comment atinternal/agentcredential/runs.go:66says so), so "open" is undefined. The PR and the design disagree, and neither was changed. - Decision 4 adds a refusal to the design (question). "The receiving run must have no record" is a new refusal, filed under check 6's repeat rule.
implementation.md"Run owner checks" andaudit.md"Lineage consistency" weren't updated to match. This needs sign-off. - The
RunTeamdecision isn't agreed (question). The only comment on #2557 is your own proposal, with no reply, yet the PR writes it intoagent-definitions.md. The code also differs from that proposal: the proposal makes the caller the run's owner, butidentity_broker.go:505uses the root session's owner. The two differ whenOwnershipEnforcedis off. - The 4096-record cap isn't in the design (minor). The design keeps delegation records for the whole session. #2563 covers making them durable, not forgetting them. Either the design should mention the cap, or a ticket should own removing it.
Correctness
-
ReportDelegationdoesn't check the owner of an unseen root run (major). Atinternal/identitybroker/runs.go:113-118,ReportDelegationstoresreq.Ownerwithout comparing it to the grant's owner. This is the normal order whenever a helper starts before the main agent's first gateway call. One inconsistent report fixes the wrong owner on the root run. After that, every call in that run, and in every run delegated from it, fails check 5. Please applycheckRunOwnerin the!knownbranch and add a conformance case. -
Nested helpers break after eviction (major). Each report can add two runs but only one delegation, so run records are forgotten before their delegations.
AuthorizeCallrebuilds a forgotten delegated run from its kept delegation (runs.go:175);ReportDelegationdoesn't, and refuses with "not a root instance". In a long session, a helper can still make calls but cannot start sub-helpers, andreportHelperDelegationturns that into a failed helper start. Fix: in the!knownbranch, look up a kept delegation whose receiving run and agent match the delegating run and agent.TestRunRecordsForgottenAtTheCapcovers only the case where the delegation itself was forgotten. -
Helpers moved lazily are never re-reported (major).
reportDelegationsAgainskips helpers thatMoveHelpersdidn't move (identity_broker.go:638). When such a helper moves later throughCredential→renew(internal/agentcredential/holder.go:282), nothing reports its delegation again. Its calls are refused ("delegation was not reported") until it's resumed, which may never happen for a background helper. -
A window during a reopen (major). Between
MoveHelperspublishing a helper's new broker session andreportDelegationsAgainfinishing (identity_broker.go:335), two things go wrong:- An in-flight helper call is refused with
PERMISSION_DENIED. It's recorded as a denial and looks permanent to the model, though it's transient. - A running parent helper can't start a child, because its run is unseen and it isn't a root.
No test covers either case.
- An in-flight helper call is refused with
-
The re-report runs on every renewal (minor). It runs on every renewal of the main agent's credential, not only after a reopen, because it sits under
if registeredatidentity_broker.go:335. That can mean up to 4096 synchronousReportDelegationcalls while holdingrunEntryMu. Already-forgotten delegations come back asPERMISSION_DENIED("receiving run already recorded"), which only adds warning noise. -
A report can land in the closing session (minor).
Held(key)is read before the report andSetDelegationruns after it (identity_broker_helpers.go:171-196). A report that lands in the old session just before the root reopens can miss thereportDelegationsAgainsnapshot. -
The holder's cap can drop an ancestor (minor). When the holder forgets its oldest entry (
agentcredential/runs.go:77), it can drop an ancestor that a kept delegation depends on. Re-reporting that delegation then fails, and the failure is only logged. Re-reporting only current delegations and their ancestor chains would avoid this and the history problem in point 3. -
Gaps in the receiving-run checks (minor) (
runs.go:120-160):- Check 4 doesn't require the receiving agent to be a child of the delegating agent.
- "Receiving run already recorded" looks only at run records. Once a run is forgotten, a second delegation can name it.
- A root instance can reuse a forgotten delegated run's ID.
Only the trusted harness can trigger these, but they're weaker than the documented checks.
-
A call with no run leaves no record (minor). It's refused inside mecak8s (
internal/adapter/mcpbroker/gateway_call.go:123), so the broker records no denial, and theidentity_unavailablemessage doesn't say a missing run or delegation is the cause. -
Audit attribution (minor).
- A helper's call names its current delegation, so after a resume, a call still in flight from the earlier run is attributed to the new run (
gateway_call.go:46). - A background helper that outlives its delegating run keeps naming the old run in later root runs.
- The
RunTeamrun ID exists only on the context, so audit can't trace a member back to the API request (audit.md"Lineage").
- A helper's call names its current delegation, so after a resume, a call still in flight from the earlier run is attributed to the new run (
-
Nits.
- A session close that races a call returns
ReasonNoGrantinstead of the closing reason. - A refused
ReportDelegationstill creates an emptysessionRunsthroughforLocked(runs.go:101), which contradicts "a refused call leaves nothing behind".
- A session close that races a call returns
Missing tests
- A helper's gateway call succeeding after a reopen. The reopen test only compares report requests.
- A lazy helper move, and a failed
MoveHelpers. - A nested report after only the delegating run's record (not its delegation) was forgotten.
ReportDelegationrefusing an owner that differs from the grant's.- A delegation reported in session A being refused by
AuthorizeCallin session B.
A helper that moved to its root's reopened broker session lazily, after the reopen's own move failed, had no delegation reported there, so its gateway calls were refused until it was resumed. The credential holder now reports a helper's current delegation into each broker session it moves to, after the delegations its delegating run descends from, before the move is stored, so a failed report leaves the helper to move again. A delegation set while a move is in flight is reported to the new session too. The reopen no longer re-reports the whole delegation history. The broker also: - checks the owner of a delegating root run it has not seen against the session's owner, so one inconsistent report cannot fix the wrong owner; - rebuilds a delegating run whose record was forgotten at the cap from its kept delegation, as AuthorizeCall does. The design defines the open delegations a reopen reports, and the in-memory record cap is marked as a shortcut. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
main now refuses the identity broker with a workspace on the process's filesystem (#2875), so the delegation tests run file-less. Parallel branches and API-created teams need a workspace, which the broker then gets only through Kubernetes execution, so their end-to-end cases are dropped; they report delegations through the same path the remaining tests drive. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks, this was thorough. Point by point; the fixes are in 82f6618, 5744a42, and the commit that points the run-owner shortcut at #2947. One fact changes how much several of these matter. Today a helper can't start helpers of its own: every child's tools drop Design changed or contradicted without sign-off
Correctness
Missing tests
Also changed sinceMerging |
Closes #2557. Part of #2554.
Every gateway call now names its run, the run's owner, and the delegation it acts under, and the identity broker checks all three. Before this, the broker accepted whatever mecak8s sent: the run serial as the run ID, the registration owner as the run owner, and no delegation.
What changes
Identity broker (
internal/identitybroker)ReportDelegation, a new call onServiceandCore, records "run R41 of agent A handed work to new run R42 of agent B". It applies the design's delegation report checks in order. A delegating run the broker hasn't seen is recorded as a root run, which needs a root instance.AuthorizeCall:checkRunOwner, so a later membership check for shared sessions replaces only its body.run-owner.mdasks.mecak8s
rootedRunContext. No engine change: tool calls and helper runs, background ones included, inherit context values.RunTeam. Each call mints its own run of the root's main agent, owned by the root's owner, as decided on Runs, delegations, and the run owner #2557. Members' runs are delegated from it.MoveHelpersor on its next call, and the credential holder reports its current delegation there first, after the delegations its delegating run descends from. A move whose report fails isn't stored, so the helper moves and reports again on its next lookup.Decisions to review
agentcredential.Holder. The plan had a separate registry. The holder already has the right key (per root), the same writer and reader (server and MCP broker), and the same drop sites, so a separate registry would need its ownDropat four places.SetDelegationrefuses when no credential is held.credentials-and-lifecycle.md.credentials-and-lifecycle.md).ownerfield; it is not a map keyed by (session, user). The behavior matches "one entry per session for now", and with state in memory there is nothing to migrate. The durable schema's keying moved to Durable broker state and recovery #2563.AuthorizeCalldoes.Sign-off on decisions 4 and 5, the
RunTeamowner, and decision 2's definition of open delegations is requested on #2557.Shortcuts
API compatibility
Assessment: no wire change. No proto, gRPC, or HTTP surface changes.
ReportDelegationis added to the in-processidentitybroker.ServiceandCoreinterfaces only. #2559 (broker over gRPC) has not landed, so no RPC is needed yet.Behavior: with the identity broker on, a gateway call whose run, owner, or delegation does not check out is refused. mecak8s always reports consistently, so no client sees a difference. With the broker off, nothing changes.
No major bump, no feature identifier, no approval needed. There are no upgrade implications.
Testing
Broker (
runs_test.go,conformance/delegations.go):ReportDelegationcheck and outcome: an idempotent repeat,ALREADY_EXISTS, recording a delegating root run, an unregistered receiver, a child delegating run, an owner change, a closed session, and another workload;mecak8s:
RunTeammember's delegation, the report after a reopen, a helper whose move failed reporting when it later moves, androotedRunContext;cmd/mecak8send to end: a helper's gateway call passes the real broker's run and owner checks. This test failed before the delegation reporting was wired up.cmd/mecak8send to end: a Team tool member, and a subagent resumed after its root's broker session reopened. Each makes a gateway call through the real AS-1, AS-2, and the embedded vMCP, and the call passes the run checks under its reported delegation. Both fail when the delegation report is skipped. Parallel branches and API-created teams had end-to-end cases too. Since feat(identitybroker): start the broker from operator configuration and keys #2875 the broker refuses a workspace on the process's filesystem, so those two helper kinds run only under Kubernetes execution, and the cases were dropped; they report through the same path.Gates:
task lintpasses.task docspasses.task test:racepasses, apart from three load-related timeouts in untouched packages (environment/microvm,cmd/mecatui,internal/adapter/microvmmanager). All three pass when rerun alone.go test -race -count=1.task check:prpasses, except two steps:sdk:e2edidn't run becausebunisn't installed locally;docs:server-cli:checkreports a line-wrap difference that comes from the local checkout path (no flags changed).Real use, local (before merging #2875): I ran mecak8s with the broker on and offline sign-in. Each helper kind reported its delegation with no broker failures:
RunTeamrun)Panel review (spec, standards, tests, security, architecture, duplication, reuse) found no blockers. I fixed:
After review
The review's findings and my answers are in the review reply. Two agents also checked each finding against the design independently. The main change: a helper moved to a reopened broker session after the reopen's own move failed had no delegation reported there, so its calls were refused until it was resumed. The credential holder now reports on every move.
🤖 Generated with Claude Code