Skip to content

feat(identitybroker): register each helper agent under its parent - #2913

Merged
rdimitrov merged 8 commits into
feat/per-agent-registrationfrom
feat/helper-registration
Nov 20, 2026
Merged

rdimitrov merged 8 commits into
feat/per-agent-registrationfrom
feat/helper-registration

Conversation

@rdimitrov

@rdimitrov rdimitrov commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Summary

Stacked on #2912 (which is stacked on #2883). The base is feat/helper-create-seam. The new commits here are feat(identitybroker): register each helper agent under its parent, its review fix, feat(identitybroker): register helpers again when the broker session reopens, and fix(identitybroker): admit resumed helpers, per panel review.

Helper agents (subagents, parallel branches, and team members) were never registered with the identity broker. Each one now gets its own agent identity when the engine first publishes its session, before it runs, registered under the agent that created it. A refused registration stops the helper.

  • When and where. mecak8s wraps the stores the engine publishes child sessions to (internal/adapter/childstore, using feat(engine): let a child store admit each child it publishes #2912's seam). Service.RegisterHelper then registers the helper in its root session's broker session. Its parent is the agent of its parent session, or the root's main agent for a member of a team created over the API, whose session records no parent. Registration runs after the child is persisted, as the design orders it.
  • Definitions.
    • A named helper registers with its loaded global/<name> definition, or by name only if the broker did not load one, in which case it is refused, as main sessions are in feat(identitybroker): give each agent its own identity, checked against loaded definitions #2883.
    • A helper with no named definition registers with a built-in: system/explorer (an existing built-in), or the new system/branch and system/member.
    • A team member registers with the definition its factory actually built it from, so an unknown agent type still falls back to a generic member.
  • D5, the decision proposed on Helper agents: their own registered identity and broker MCP tools #2555. A child registration reports its parent's host session (RegisterAgentRequest.ParentHostSessionID). The broker refuses a child whose reported value is not the parent's recorded host session. This ties each child to its parent and, through it, to the root host session that check 4 pins.
  • Reopened broker sessions. When the root's main agent registers into a reopened broker session at run entry, the tree's held helpers register there too, parents first, keeping their ag_ identities, as the design's "Session end" requires. A helper's credential lookup also moves it if that eager move failed.
  • Resumed helpers. A resumed subagent is admitted again through feat(engine): let a child store admit each child it publishes #2912's ChildSessionResumer. A helper whose credential is still held keeps it. One with none, as after a refused registration or a dropped credential, registers as a new one does, so a helper that cannot register is not resumed. A resumed subagent runs the default explorer, so it registers as system/explorer, and the broker refuses that for an agent it recorded with another definition.
  • Helpers outside a registered tree. A helper whose root has no registered main agent is not registered: for example, a root with no owner, or a team with no source session, per the decision on Helper agents: their own registered identity and broker MCP tools #2555. It runs, and its gateway calls fail closed, as they do today.
  • Docs. The three decisions are recorded in the design: D5 in step (4) and "Registering instances", the built-ins in "Loading definitions", and teams with no source session in "Relationships and lifetimes". They were proposed on Helper agents: their own registered identity and broker MCP tools #2555 and still need the design author's review. The operator docs' identityBroker.enabled row covers helpers.

Helpers still have no broker MCP tools; #2914, next in the stack, adds them and closes #2555.

Issue relationship

Part of #2555. Part of #2554.

Type of change

  • Bug fix
  • New feature
  • Refactoring (no behavior change)
  • Dependency update
  • Documentation
  • Other (describe):

Test plan

Baseline checks

  • Linting (task lint)
  • Pre-review race suite (task test:race), plus a focused race rerun of the touched packages after the review fixes
  • Offline PR checks (task check:pr)
  • Markdown changed: docs generation/link checks (task docs)
  • User docs/user-facing behavior changed: site build (task site:build)
  • Guarded engine API affected: compatibility check (task api:check): engine unchanged in this PR
  • Intentional engine API change: not applicable

Contract tests (internal/identitybroker/conformance)

  • A child must report its parent's host session. Another host session, its own, a sibling's, or the root's for a grandchild are each refused with PERMISSION_DENIED, with a positive control.
  • A child moves to a reopened broker session only after its parent, keeping its identity.
  • A child changing its parent is still refused by check 7. The new parent host session matches the new parent, so only check 7 can refuse it.
  • Validation: a parent without a parent host session, and a parent host session without a parent.
  • The conformance definition set includes the helper built-ins.

Other tests

  • Credential holder: after the main agent moves, MoveHelpers moves every held helper, parents first, keeping their identities; it visits the grandchild first, so only the parent-first move passes. A grandchild's lookup after its root moved registers the child and then itself in the new broker session, keeping both identities. A helper that cannot move gets the error, not its old credential. A lookup made after the move doesn't join an in-place renewal started before it.
  • Server (RegisterHelper):
    • Each kind registers with its definition, parent, ParentHostSessionID, broker session, owner, and incarnation.
    • A helper of a helper names its parent's host session.
    • Helpers with no root, a default-placement team, or a root without a main agent are skipped, with a positive control.
    • Refusals: an unregistered parent, an unloaded definition (sent by name only, no credential held), another owner's helper, and a retryable unavailable broker.
  • Reopened broker session (server): after the root's broker session closes, the root's next run registers the main agent and then the helper into the new broker session, keeping the helper's identity, with no gateway call (checked by mutation).
  • API team run: the member registers as system/member under the root's main agent. A member registration with the broker down returns ErrIdentityBrokerUnavailable, not an invalid argument (checked by mutation).
  • Member factory: an unknown agent type reports no definition; a known one reports its name.
  • Resumed helper (server): a held credential is kept with no new registration; a helper with none registers as system/explorer under the main agent; a refusal stops the resume.
  • Real wiring for branches and team members (internal/app): a parallel branch and a Team-tool member each register under the main agent, as system/branch and system/member. Passing the unwrapped store to the Parallel or Team tool fails these cases.
  • Real wiring (internal/app): a default subagent and a subagent naming an --agents-dir definition each register under the main agent with system/explorer or global/code-reviewer, and the broker holds the registration. Removing the store wrapper fails this test.
  • childstore: persists before admitting, reports the wrapped store's create support, and admits a resumed child without publishing it.

Real use

I ran the real mecak8s locally with the broker on, OIDC sign-in, and HTTP sessions, driven by a mock model:

  • A default subagent registered as system/explorer under the main agent and ran its tool calls.
  • A subagent naming an --agents-dir agent registered as global/reviewer and ran.
  • A subagent naming a user-level agent was refused (PERMISSION_DENIED) before it started. The parent got the error "durable child session could not be created: server: internal error: identity broker call failed".
  • A parallel branch registered as system/branch under the main agent and ran.
  • A Team-tool team's lead registered as system/member and its reviewer as global/reviewer, both under the main agent.
  • A team created over the API (POST /v1/teams, then run) registered its lead as system/member and its reviewer as global/reviewer. A member whose agent type does not exist fell back to system/member instead of blocking the team. All three were registered under the root session's main agent.

Changes

File Change
internal/identitybroker/service.go, agents.go ParentHostSessionID and the D5 check
internal/identitybroker/definition.go, adapter/definitionloader/loader.go system/branch, system/member
internal/identitybroker/conformance/* Helper built-ins, D5 and reopen cases
internal/agentcredential/holder.go Helpers move after their root, parents first
internal/adapter/childstore Child store wrapper
internal/adapter/server/identity_broker_helpers.go, identity_broker.go, team.go, classification.go RegisterHelper, definition lookup, API team members, error classes
internal/app/helper_registrar.go, catalog.go, build.go Wrap the child stores; bind RegisterHelper; member factory reports its definition
docs/drafts/agent-identity/* The three #2555 decisions
user-docs/operating/mecak8s/identity-and-client-access.md identityBroker.enabled row
*_test.go Tests above

API compatibility

  • Assessment. No gRPC or HTTP message, route, or field changes. With --enable-identity-broker on, these client-observable behaviors change:
    • A subagent or team member naming an agent outside the --agents-dir directories, or any named helper under an operator harness_context policy, no longer starts. The parent gets the existing creation-failure tool result. This is the same rule feat(identitybroker): give each agent its own identity, checked against loaded definitions #2883 applies to sessions.
    • Helpers with no named definition (the default explorer, parallel branches, generic members) start as before.
    • An API team whose member cannot register fails RunTeam with the registration's class (unavailable or internal).
    • Gateway records will name helper identities once the next PR gives helpers broker tools.
  • Rationale for no major bump. Same as feat(identitybroker): give each agent its own identity, checked against loaded definitions #2883: the broker is experimental and off by default, which definitions may run is the operator's policy, and no client change could make a refused helper correct.
  • Major/feature changes: none.
  • Stored data: none; broker state is in memory (Durable broker state and recovery #2563).
  • Upgrade implications. Operators using the experimental broker with named helpers must put those definitions in an --agents-dir directory.

Special notes for reviewers

🤖 Generated with Claude Code

rdimitrov and others added 8 commits November 20, 2026 15:34
Add port.ChildSessionCreator, an optional SessionStore capability. When
the engine first publishes a subagent, parallel-branch, or team-member
session, it calls CreateChild instead of Create, passing the definition
the child runs. An error stops the child before its first turn, like a
failed Create. Stores without the capability behave as before.

mecak8s uses this to register each helper agent with the identity
broker before it runs (#2555).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A member's factory falls back to a generic member when the roster's
agent type is unknown, so the agent type is not always what runs.
MemberBuild.DefinitionName reports the definition the factory adopted,
and the supervisor passes it to CreateChild instead of the agent type.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A resumed subagent was never published again, so a host could not
admit it: a child whose admission was refused, or whose admission was
lost, could be resumed and run. port.ChildSessionResumer gives the
host ResumeChild before a resumed subagent runs again; an error stops
the resume.

The child-store decorator rule is narrowed to what the engine uses on
child stores, and the background refusal test now waits for the child
to end before checking that its model was not called.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Subagents, parallel branches, and team members now get their own agent
identity when the engine first publishes their session, before they
run. Each registers in its root session's broker session with the agent
that created it as parent, and a refused registration stops the helper.

- D5: a child reports its parent's host session, and the broker refuses
  one that is not the parent's recorded host session.
- Built-ins system/branch and system/member join system/explorer for
  helpers that run no named definition.
- The credential holder moves a helper into its root's new broker
  session, after its parent, keeping its identity.
- A helper whose root has no registered main agent, such as a member of
  a team with no source session, runs unregistered; its gateway calls
  fail closed.

Part of #2555.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- A team member registers with the definition its factory built it
  from, so an unknown agent type falls back to a generic member as
  before instead of being refused.
- An API team keeps the class of a member's registration failure, so an
  unavailable broker stays retryable rather than an invalid argument.
- A failed lookup of a helper's parent maps like a registration failure
  instead of always as retryable.
- A helper lookup made after its root moved no longer joins an in-place
  renewal started before the move.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…reopens

When a root's main agent registers into a reopened broker session at
run entry, the tree's held helpers now register there too, parents
first, keeping their identities, as the design's session end requires.
Before, a helper moved only at its next gateway call.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- A resumed subagent is admitted again before it runs: a held
  credential is kept, and a helper with none registers as a new one
  does, so a helper whose registration failed or was lost is not
  resumed.
- The child-store wrapper documents that it forwards only what the
  engine uses on a child store.
- Parallel branches and Team-tool members are tested through the real
  wiring, not only subagents.
- MoveHelpers visits helpers in a fixed order, so its test exercises
  the parent-first move every run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- A resumed subagent runs the default explorer today, so the design no
  longer says it keeps its original definition; #2548 does that.
- Members of a team created over the API register with the root's main
  agent as a stand-in creation parent; the design now says so.
- system/member covers any member that runs no named definition.
- The failure table, the walkthrough, and the test list cover the
  definition in check 7 and the parent host session (D5).
- Shortcut notes for registration lineage records (#2541) and resuming
  a named subagent (#2548).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@rdimitrov
rdimitrov force-pushed the feat/helper-create-seam branch from 2656979 to 3977775 Compare November 20, 2026 13:38
@rdimitrov
rdimitrov force-pushed the feat/helper-registration branch from f37c302 to fbe979f Compare November 20, 2026 13:38
Base automatically changed from feat/helper-create-seam to feat/per-agent-registration November 20, 2026 14:30
@rdimitrov
rdimitrov merged commit 44d2ea1 into feat/per-agent-registration Nov 20, 2026
77 of 115 checks passed
@rdimitrov
rdimitrov deleted the feat/helper-registration branch November 20, 2026 14:30
rdimitrov added a commit that referenced this pull request Nov 20, 2026
#2912 and #2913 were squash-merged into the base. Their trees match the
commits this branch was built on, so every conflict resolves to this
branch's side and the merged tree is unchanged.

Co-Authored-By: Claude Opus 5.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