Skip to content

docs: describe agent authority, broker trust boundaries, and implementation gaps - #2121

Merged
jhrozek merged 51 commits into
mainfrom
docs/agent-authority
Oct 19, 2026
Merged

jhrozek merged 51 commits into
mainfrom
docs/agent-authority

Conversation

@jhrozek

@jhrozek jhrozek commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Document the intended agent-identity and external-broker design, separating the
reader-facing explanation from implementation evidence and remaining work.

Design narrative

docs/agent-authority.md covers:

  • User, logical-agent and workload identities, including the limits of trusting
    a shared Mecatl process to identify its agents.
  • The A–D progression from Kubernetes ServiceAccount authentication to
    logical-agent credentials and SPIFFE workload authentication.
  • Interactive execution: broker admission for an exact call, followed by
    ToolHive token exchange using the existing user access token and a separate
    logical-agent credential.
  • Credential custody, account association, denial behavior and unknown outcomes.

Implementation companion

docs/agent-authority-implementation.md records inspected implementation
snapshots, gaps and follow-up decisions. It distinguishes existing functionality
from proposed integration rather than presenting the design as already shipped.

Scope

Documentation only. No runtime behavior changes.

The design retains the existing broker, browser authorization, token refresh and
provider credential custody. It does not introduce a new consent or mandate system.
Provider-credential linkage is an OAuth/ToolHive concern, separate from SPIFFE
workload authentication.

Review focus

  • Are the trust placed in Mecatl and the broker’s independent checks clear?
  • Are user, agent and workload identities kept distinct throughout the flow?
  • Does the intended design preserve exact-call authorization independently of
    OAuth token claims?
  • Does the companion accurately identify what remains unresolved?

Validation

  • Staged whitespace checks passed.
  • task docs ran but did not pass link validation.
  • The companion references a document absent from the branch and two ToolHive
    follow-up briefs not included in this commit; those links need resolution
    before merge.

@jhrozek
jhrozek force-pushed the docs/agent-authority branch from bca7cf8 to 8c6f099 Compare October 5, 2026 22:28
Comment thread docs/agent-authority.md Resolved
@jhrozek
jhrozek force-pushed the docs/agent-authority branch from 8c6f099 to 70e62b9 Compare October 6, 2026 10:12
Comment thread docs/agent-authority.md Resolved

@JAORMX JAORMX 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.

Jakub, my main concern here is keeping the agent/subagent hierarchy from the existing identity model:

https://github.com/stacklok/mecatl/blob/main/docs/agent-identity-model.md#the-three-tier-model

I'm fine with code-reviewer being a stable logical identity that we can use in policy. But we also need to know which instance of that reviewer we're talking about and where it sits in the delegation tree:

Alice
└── main
    └── code-reviewer
        └── security-reviewer
            └── another specialist

Each child inherits restrictions from its parent, all the way down. If the main agent was restricted to reviewing PR 42, spawning a specialist with a broader definition must not give it access to other repositories or permission to merge.

The document does say children only narrow authority. What I'm missing is how we carry and enforce that hierarchy through issuance, broker admission and recovery. The credential identifies the definition, and then we have separate run and call bindings, but where is the binding to the actual parent and the authority delegated to this particular child?

I'm not asking for a private key per subagent or claiming this isolates goroutines from a compromised Mecatl process. I want us to preserve the delegation tree as something we enforce, rather than something we only reconstruct from logs.

Can we make that relationship explicit before settling the credential model? I'd like the broker flow to implement the definition/instance/run model, rather than leave the instance hierarchy behind.

Comment thread docs/agent-authority.md Resolved
Comment thread docs/agent-authority.md Resolved
Comment thread docs/agent-authority.md Resolved
@JAORMX

JAORMX commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

One clarification on my earlier comments: I’m thinking of this in two phases. First, identities and cryptographically verifiable attribution across the agent/subagent tree, so we can audit which instance did what and beneath whom. Then, policy enforcement where each child’s authority stays within what its parent may delegate.

I see this PR as helping with that first foundation. I’m not asking us to settle the policy language or containment mechanism here, or make the complete enforcement model a prerequisite for attribution. I want us to preserve the hierarchy now so enforcement can build on the same model later.

@JAORMX

JAORMX commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Jakub, one more thing I'd like us to account for is agent definition provenance. This expands the scope a bit, so I'm not asking us to implement every source adapter or settle a wire format in this PR. But I think we should capture the requirement on both the Mecatl side and the identity broker side.

For attribution, I'd like to answer: which agent definition revision did this particular agent instance actually use, and where did it come from?

With local files, that could mean repository, path, commit and content digest. But Mecatl's AgentDefSource is deliberately storage-independent. An agent definition could also come from a Kubernetes custom resource or a service backed by Postgres. The provenance contract should support those sources without making Git or Kubernetes concepts part of the core interface.

Could we leave room for an agent definition provenance envelope with extensible metadata and versioned profiles? Something like this, just to illustrate the shape:

agent_definition_provenance:
  profile: mecatl.agent-definition-provenance.git/v1
  metadata:
    repository: https://github.com/example/agents
    path: agents/reviewer.md
    commit: "<full commit ID>"
    source_content_digest:
      algorithm: sha256
      value: "<digest of the source content>"
    accepted_definition_digest:
      algorithm: sha256
      value: "<digest of the normalized agent definition>"

A Kubernetes profile could describe the source cluster, custom-resource object UID, observed revision and relevant-content digest. A service-backed profile could use a service/tenant namespace, object identifier and revision. Those are source details; the workload running the agent has its own identity and runtime metadata.

I'm fine with the metadata being a map, provided each profile has a strict contract: required fields, schemas, hashing rules and defined revision semantics. The operator should be able to require particular evidence, and the source shouldn't be able to weaken those requirements by selecting a more permissive profile.

The distinction between source content and the accepted agent definition matters here. Mecatl parses and normalizes agent definitions, so the bytes read aren't necessarily the exact representation used to construct the agent. Having a commit and a digest also doesn't establish that the loaded content belongs to that commit. A locally modified file is an obvious example.

The flow I have in mind is:

Source adapter/service
  → agent definition + source evidence
Mecatl's trusted resolver
  → accepted definition snapshot + validated provenance
Mecatl's instance lifecycle
  → bind that snapshot to the instance and its parent
Identity broker
  → validate required evidence and establish a verifiable binding
Invocation/audit records
  → retain the link to that instance and provenance

This information should come from source resolution and trusted execution state, not from the model. The agent definition and its provenance need to describe the same snapshot. We shouldn't reconstruct provenance afterward by looking at whatever happens to be current in Git, Kubernetes or the service.

On the broker side, we should distinguish what it verifies independently from what it accepts as Mecatl's attestation. “Mecatl reports loading these bytes from commit X” is different from “the broker verified these bytes against commit X.” We don't need the broker to access every backend, but its signature shouldn't obscure that trust distinction.

I also don't think the full provenance record needs to be a claim in every token. We could embed it or use an integrity-protected reference to retained evidence. If the logical-agent credential is reusable across instances, the binding needs to live in instance-specific evidence or an authenticated broker record instead. Otherwise, one credential could end up describing several different agent definition revisions ambiguously.

This fits the observability-first phase: establish which agent definition each instance used and preserve that evidence alongside the delegation hierarchy. It doesn't grant permissions by itself. Later, enforcement could require approved revisions or particular source authorities.

Can we capture this in the proposal and track the Mecatl interface and broker work separately? I'd like us to preserve enough information now that verifiable attribution doesn't stop at the agent definition's name and admission tier.

@jhrozek
jhrozek force-pushed the docs/agent-authority branch 2 times, most recently from 8c1f133 to 1b69f1a Compare October 12, 2026 11:59
@JAORMX

JAORMX commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

So, I think we're mixing two threat models here. With native execution enabled, mecak8s already keeps workspace filesystem operations and Shell in separate executor Pods, behind the execution provider. A prompt-injected agent running a command doesn't automatically get access to the mecak8s process or its credentials. The proposal acknowledges that existing boundary, but I'd like that distinction to drive the rationale throughout.

I'm in favor of brokerage, and I want the real provider credentials kept away from mecak8s. I also want to keep the agent loop minimal. Owning OAuth enrollment, account association, refresh, credential selection, and mediated provider calls is plenty of responsibility for a broker already!

I don't have a strong opinion about whether that needs its own deployment. A separate deployment is fine for operational ownership, independent lifecycle, or sharing the service across instances. But I wouldn't make process separation the main security argument for the identity design. Keeping credentials outside mecak8s can reduce exposure if that process is compromised, provided its storage and deployment permissions are actually separated. That's a useful property, but it's a different threat from hostile code running in an executor.

And moving the signer doesn't make the identity reports independently trustworthy. If we trust mecak8s to report the user, agent instance, and delegation context, that trust remains. A compromised process holding multiple agent credentials can still substitute one for another. The docs already acknowledge this, and I think we should make it part of the starting assumptions rather than something readers discover after the architecture.

I'd frame this around the responsibilities first: the loop runs agents, the existing execution boundary handles workspace code, and the broker owns provider connections and protected external calls. Identity issuance can be a module in that design without implying another service or per-agent process isolation.

The part I'd like us to discuss separately is broker ownership of run admission and agent lifecycle. Establishing bounded access to external tools makes sense. Becoming another authority over whether agents can start or runs can execute is a much larger decision. Can we clarify which one we mean, and keep the attribution work from depending on the broader execution-control design?

@jhrozek
jhrozek force-pushed the docs/agent-authority branch 3 times, most recently from c3f3fa7 to f75b378 Compare October 12, 2026 17:35
@jhrozek

jhrozek commented Oct 13, 2026

Copy link
Copy Markdown
Contributor Author

Replies to the review summary and the first two issue comments, as of fbf9e8d.

Review summary (delegation hierarchy through issuance, admission and recovery). The hierarchy is now enforced at the broker, not only reconstructed from logs. Each instance is registered under its parent. The broker stores an effective ceiling equal to the child's definition ceiling intersected with the parent's, evaluates it on every call, and reloads it unchanged on renewal and recovery. Details are in Delegated authority and the thread replies above.

Two phases (attribution, then enforcement). Phase 1 maps onto the audit evidence table and the illustrative authorization record. They attribute each call to its instance, incarnation, definition revision, creation parent, run, delegation and user, and mark which facts are verified and which are reported. Server/tool enforcement against the parent's ceiling landed in v1 as well. Still deferred: task-specific bounds, resource/argument policy, and a verified per-operation binding for the reported run and delegation fields.

Agent definition provenance. Captured in a new Definition provenance section:

  • a versioned profile with profile-specific metadata (Git, Kubernetes CR, or service-backed), keeping AgentDefSource storage-independent;
  • strict per-profile contracts, with operator-required evidence that a source can't downgrade;
  • separate source-content and accepted-definition digests, with the locally-modified-file caveat;
  • provenance from the trusted resolver, never reconstructed later;
  • broker-verified facts kept distinct from mecak8s-asserted ones;
  • provenance stored in the per-instance registration record rather than in tokens.

Mecatl and broker work are tracked separately in implementation.md. No wire format is chosen.

The 2026-10-12 comment on threat models and broker scope is still under discussion.

@JAORMX JAORMX 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.

Jakub, I'd like us to strengthen the audit sections around a practical outcome: we can establish who did what, when and where, and follow the full delegation chain behind the action. We already have toolhive-core/audit, so let's build on that rather than introduce a separate event format.

I'm not asking this PR to implement every NIST control or make a blanket compliance claim. NIST's Audit and Accountability controls are a useful guide for choosing the record structure and identifying what Mecatl, ToolHive, and the deployment each need to provide. I filed the reusable enhancements in toolhive-core and linked them in the inline comments. The request here is to make those requirements and dependencies explicit in the proposal and its verification companion.

Comment thread docs/drafts/agent-identity/audit.md Outdated

## Illustrative authorization evidence

The following readable fields illustrate a proposed broker authorization event for the reviewer's call in the [interactive walkthrough](credentials-and-lifecycle.md#interactive-execution). They are an audit shape to guide implementation, not an immutable event API or a Cedar policy representation.

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.

Can we make this a documented profile of toolhive-core/audit.AuditEvent, rather than leave it as an independent illustrative shape? The shared package already gives us the type, source, component, subjects, target, outcome, event ID, and UTC logging timestamp.

I'd like the chapter to map these fields onto that structure and say which evidence we require: who acted and on whose behalf, what operation and target, when it occurred/was observed, where it originated and was recorded, and the decision or observed outcome. Operation and attempt IDs should connect the records without confusing a retry with another event for the same attempt. Keep the verified-versus-reported distinction and the retained policy/definition references.

I filed the generic correlation, provenance, timestamp, and unknown-outcome conventions here: stacklok/toolhive-core#341

This is the useful direction from NIST AU-3 and AU-8, not a request to satisfy the whole control catalog: https://csrc.nist.gov/pubs/sp/800/53/r5/upd1/final. Could we also carry the field mapping and round-trip checks into the implementation companion?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in 1a56af2. The illustrative table is replaced by an AuditEvent profile. We ran the mapping past ToolHive, OAuth, identity, and audit-standards reviews first. The profile now covers:

  • Each field. The table says what Mecatl puts in each AuditEvent field, and uses toolhive-core's existing conventions so records join with vMCP's:
  • Who acted, and for whom. Subjects holds issuer-qualified keys for the user, the company owner, the workload, and the acting instance. A mecatl.provenance map marks each fact as verified, record:<AuditID>, reported:<component>, or unavailable, and an unverified identity never appears as user_id.
  • Correlation. Operation, attempt, and event IDs work like this:
    • A retry is a new attempt.
    • A re-send keeps its AuditID and LoggedAt.
    • A late result after unknown is a new event that references the earlier one.
    • The broker passes the operation and attempt IDs to AS-1 and the vMCP.
  • When. Occurrence time and its clock are recorded next to LoggedAt.
  • The outcome. Each event type (decision, dispatch, observed outcome) has a fixed set of outcomes.
  • References. Credentials are recorded as (iss, jti) or record references, never values.
  • Lineage. DelegationChain holds only an act chain the recorder validated. Creation ancestry and delegation are kept separately, in Data.lineage.
  • Scope. The profile lists the event families the identity work needs. Cedar evaluation fields are marked as authority work.

Interim mecatl. keys stand in until #341 and #342 land. The implementation companion now has the field mapping as round-trip checks: JSON and slog projections, re-emission, missing and reported identities, unknown then retry then late result, per-type outcome sets, key allowlists, and secret exclusion.

One related change: AS-1 now sets act.iss. Otherwise an agent: identifier looks like AS-2's once AS-2 copies act into V.

Comment thread docs/drafts/agent-identity/audit.md Outdated
| Field group | Illustrative values or required evidence |
| --- | --- |
| Event and call references | Event `authz-42`, operation `op-pr42-001`, attempt `attempt-1`, recording component, and observation time. Distinguish another attempt from another event for the same attempt. |
| Actor and context | Verified reviewer subject from its registered instance; verified workload with trust qualifier; host session `S42`; reviewer's agent-instance incarnation; run `R42`; creation-parent reference; reported delegation `D42` from `R41`; API-reported Alice with issuer/subject and request reference. Preserve the provenance above. |

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.

Can we explicitly require the full delegation chain to be part of the retained audit evidence, not just the immediate parent and delegation references? Starting with a specialist's tool call, we should be able to follow Alice -> main -> reviewer -> specialist, identifying each instance, the relevant execution/delegation, and which component established or reported each relationship. Two instances with the same definition must not become indistinguishable.

toolhive-core/audit already records RFC 8693 actor chains, including malformed/truncated markers. Let's reuse that where it applies, but keep OAuth actor history, creation ancestry, and the delegation for the current execution distinct. They aren't necessarily the same chain.

We don't need to duplicate an unbounded ancestry list in every event. Parent-linked lineage records in the audit dataset can work, provided references are integrity-protected, remain resolvable for the audit-retention period, and don't depend on live session state. Missing or truncated evidence must remain visibly incomplete, never presented as the full chain.

I've tracked the reusable support here: stacklok/toolhive-core#342. Could the investigation example and verification companion demonstrate reconstructing a multi-level chain after restart or transient session cleanup? This is about preserving attribution; it doesn't require completing task-specific authorization first.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in 905f9e9. The full chain is now retained evidence. See Lineage.

  • Two lineage events. Registration records each instance and a reference to its creation parent's registration. Delegation records each delegation (the delegating run and instance, and the receiving run and instance) and a reference to the delegation the delegating run was itself under. References are AuditIDs. Both events are marked as reported by mecak8s, because only mecak8s observes those relationships.
  • Three chains, kept apart. DelegationChain holds only a validated act chain. Execution delegation and creation ancestry come from the lineage events. Nothing is derived from the SPIFFE path.
  • Retention. Lineage events follow the audit retention period, not the session's lifetime. Session cleanup doesn't delete them.
  • Incomplete chains. An unresolved reference makes the reconstruction report the chain as incomplete, with where and why it stopped. It never shows a shorter chain as complete.
  • Example. The investigation section now walks a security-reviewer specialist's call back through the reviewer and main to Alice's session, and notes which links are reported and which come from AS-1.
  • Checks. The implementation companion now covers rebuilding a three-level chain after a broker restart and after session cleanup, keeping two instances of the same definition apart, and reporting incomplete chains.

This needs one new piece of plumbing: mecak8s reports each delegation to the broker when it happens. Integrity protection for the store itself goes with your delivery-contract comment, which I'm taking next.

Comment thread docs/drafts/agent-identity/audit.md Outdated

The broker records its authorization decision, whether it attempted dispatch, and the outcome it observed as separate facts. An allow is not a dispatch; a dispatch attempt is not proof of receipt or success. A denial dispatches no backend operation. If completion is missing after possible dispatch, the outcome is unknown, not evidence of nonexecution. Credential recovery cannot justify automatic replay of an unknown operation.

Decision, dispatch, and observed-outcome evidence must be durable and survive broker restart. The storage mechanism, write ordering relative to dispatch, failure handling when evidence cannot be persisted, and cross-service delivery and authenticated correlation remain explicitly unresolved implementation requirements. This design does not select a transactional ledger or claim atomicity between an audit write and an external effect.

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.

Can we add a small delivery and operational contract here, even if the backend remains an implementation choice? Correctly shaped events aren't enough if we can't tell that they were lost.

There's already audit-sink work in stacklok/toolhive-core#326. I filed the complementary failure-observability work at stacklok/toolhive-core#343: returning an error from a writer doesn't make it visible through AuditEvent.LogTo and slog. We should distinguish an emission attempt, receiver acknowledgment, and durable storage, and make failures observable through a usable reporting channel.

For this proposal, I'd like us to identify the required event families and their producers, the write/dispatch and failure semantics we depend on, and the deployment's responsibilities for protected storage, retention, and investigation. Include relevant registration/delegation, authorization, connection, and policy changes, not only successful calls. Audit and referenced lineage/policy evidence must not disappear with ordinary session cleanup before their configured retention expires. Be explicit about audit coverage outside broker-mediated MCP.

AU-2/5/6/9/11/12 are useful pointers here, not a requirement to implement every control, choose a SIEM, mandate WORM, or universally stop execution on logging failure. Let's select and document the guarantees we need, then verify actual destination delivery, failure reporting, secret exclusion, and reconstruction of the delegation chain. The separation of decision, dispatch, and unknown outcome in the preceding paragraph should stay.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in 3557e50. The new section is Delivery, protection, and reconciliation. Before writing it, we had an audit reviewer walk a specialist's call backwards through every record and check each step against AU-3, AU-6, AU-8, AU-9, AU-11, and AU-12.

  • Emission and destination. Every component records through the toolhive-core audit logger, and the sink work in toolhive-core#326 lets each deployment choose the destination. ToolHive's authorization server records nothing today. That's in the ToolHive ledger, now including sign-in and token issuance at AS-1.
  • Protection. The deployment points sinks at a store mecak8s can't write or delete, and investigators get read-only access. That helps even while the broker runs inside mecak8s: records delivered before a compromise survive.
  • Producers. A table lists which component records which event families. It now includes AS-1 sign-in and token issuance, and mecak8s request and ownership checks, so the user's identity anchors to the company IdP's independent log.
  • Write order and failure.
    • The broker mints attempt IDs.
    • The sink must accept a decision record before the broker dispatches; if it can't deliver the record, the broker refuses to dispatch. That's the broker's choice, not a library default.
    • "Accepted by the sink" is kept distinct from durable storage, which is the destination's job.
    • Delivery failures go to a separate channel, per Telemetry for the headless binaries (mecatequi, mecak8s) #343.
  • Gap detection. Each component, replica, and process start gets a contiguous sequence, with start and stop events, plus a synchronized time source.
  • Reconciliation. These checks run across stores and flag mismatches:
    • an AS-2 redemption with no AS-1 issuance;
    • a vMCP call with no broker dispatch, and the reverse;
    • a session-open conversion with no AS-1 issuance and sign-in.
  • Lineage consistency. The broker checks that a reported delegation's instances share a session tree and that the parent links line up. This catches mistakes, not a compromised mecak8s.
  • Retention. Lineage is kept as long as anything references it. Each deployment names an owner and a duration, and agrees retention with an external gateway operator.
  • Coverage. Filesystem tools, Shell, and spawning are covered only by harness logs.
  • Later. Hash chains with signed checkpoints after the broker is a separate service, and signed records for non-repudiation.

The implementation companion's checks now cover refuse-on-delivery-failure, sequence gaps, each reconciliation flag, and the lineage consistency check.

@ChrisJBurns

Copy link
Copy Markdown
Contributor

Documenting our earlier conversation here for visibility: Should we split this into phases and focus first on the identity broker and the plumbing/audit of agent identities? We can tackle policy enforcement once that foundation is in place. This will keep us from making early assumptions that might require rework down the road.

Comment thread docs/drafts/agent-identity/README.md Resolved
- the presenter is the authenticated client `mecatl`;
- the request asks for no wider scope than the original grant.

Accepting a token whose `aud` is mecak8s from a different client is an explicit, narrow AS-1 policy for client `mecatl`, not a general audience bypass. AS-1 issues a broker refresh token and creates its record: client `mecatl`, AS-1 `sub`, broker session reference, host session and incarnation, source token `jti`, issue time and hard expiry, and rotation chain. The broker supplies the session reference. Rotation inherits the record and does not extend the hard expiry. Session close revokes the token and deletes the record. In v1 the refresh token is not tied to the user's AS-1 login session.

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.

Could we clarify the expected behaviour when a user logs out while an agent is still working? My understanding is that the agent can continue making authorised tool calls because its broker session remains active. If that’s intentional, what explicit user action ends that access? It would help to make the distinction between signing out and stopping the agent’s access clear.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good question. Your reading was right: before this change, signing out didn't stop a running agent, because its authority is a broker-held refresh token, not the client's tokens. 5aec36d makes the two actions explicit in Sign-out and revocation:

  • Sign out in the TUI or Studio revokes only that client's tokens. Running agents and schedules continue.

  • Sign out everywhere is the explicit action that stops every agent acting for the user. It ends:

    • live runs;
    • tool calls parked waiting for authorization, and tool calls in flight;
    • the broker sessions and their refresh tokens;
    • the authority of every schedule.

    The transcripts stay. A schedule stays configured, and its next run ends with "needs owner action" until the user renews it.

  • If the company IdP disables the account, the same happens without the user doing anything. When AS-1 issues an ID-JAG, it re-checks the company-IdP refresh token behind the grant, at most once per interval. If the IdP refuses, AS-1 revokes all of the user's grants. That works with any IdP that issues refresh tokens, with no IdP-specific events.

Faster IdP signals are listed as later work. Those are back-channel logout from Keycloak and event hooks from Okta; Entra and Google Workspace don't send either to third-party apps. Binding the broker's token to the AS-1 login session, so that signing out at AS-1 itself stops agents, is later work too.

@jhrozek

jhrozek commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor Author

Following up on @ChrisJBurns's phasing comment, and on @JAORMX's earlier two-phase comment: yes, we're sequencing the work that way. The identity work comes first, with no broker authority work in it. The authority work follows. The README now has an Order of work section listing both.

Identity work:

  • the broker modules: definition loader, agent issuer, AS-1, and broker core;
  • definitions with provenance;
  • instance registration, including the definition reference and the creation parent;
  • agent credentials;
  • the credential flow, from AS-1 sign-in to per-user credentials at the gateway;
  • the broker's identity checks;
  • audit.

Authority work:

  • ceiling resolution and effective ceilings;
  • Cedar generation and per-call checks;
  • delegation, user, resource, and argument policy.

Until the authority work is in place, the harness's existing delegation restrictions are the only ceiling checks. Registration already records the definition reference and the creation parent, so the authority work adds computation, not a migration.

The three audit comments from 13 October are still open. Those are part of the identity work, and I'm working through them next.

@jhrozek

jhrozek commented Oct 15, 2026

Copy link
Copy Markdown
Contributor Author

@JAORMX, replying to your threat-model comment.

Thanks, this was the right push. Here's where it landed.

Run admission. This is now a non-goal, as you suggested (81eae38). The broker governs protected tool calls. It does not decide whether agents start or runs execute, and registering an instance grants no permission to run. The work is also sequenced so that the identity work comes first and carries no broker authority at all (eede8bd). So the attribution work doesn't depend on any execution-control design.

Deployment. The broker starts as modules inside mecak8s (broker core, AS-1, the agent issuer, and the definition loader). Later those modules move together into one separate service. Identity issuance stays a module of the broker in both cases. The new Deployment and threats section (adae397) starts from your framing.

1. Executor code and a compromised mecak8s are separate threats. Agreed. Executor Pods handle hostile workspace code in both deployments. Where the broker runs only matters against code execution in the mecak8s process.

2. Process separation is a custody argument, and only if storage and permissions are really separate. Agreed. The section has a table of what each deployment closes against a compromised mecak8s, and the conditions the split needs to be real: separate storage, KMS permissions, RBAC, and configuration. While the broker runs inside mecak8s, it gives no protection against that attacker. The docs say so, and the claims that assumed a separate broker are qualified.

3. Moving the signer doesn't make mecak8s's reports trustworthy. Agreed, with one change since you wrote this: the user is no longer a mecak8s report.

  • The user signs in at AS-1. mecak8s passes on the AS-1-signed token once.
  • AS-1 converts each token at most once, and every ID-JAG names the user from AS-1's record.
  • So no mecak8s code path can name a user who didn't sign in. Only an attacker inside the process that holds AS-1's keys could, which is mecak8s until the broker moves out.

These stay mecak8s's word in both deployments, and audit marks them as reported:

  • which agent instance made a call;
  • which loaded definition a session uses as its root;
  • which instance created which child;
  • run and delegation context;
  • which open session a call belongs to.

The broker now loads global definitions itself, so mecak8s can't supply their content or ceilings (d9fb3c0). We found ways the later authority work could narrow the rest (an envelope around the root ceiling, and tool-call grants scoped to a run the user started), but they're not settled.

The modulith constraints list what we keep fixed now so the later move is a deployment change. Examples: AS-1's final issuer URL from the start, because external consent links are keyed on it; the same RPC contract in-process; separate broker storage; and one key per signing role.

@JAORMX

JAORMX commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

Heads up: #2003 adds named agent definitions as interactive session roots, with a persisted authority ceiling that later grants and fork/clear successors cannot widen. I left some thoughts on how the two efforts should fit together here: #2003 (comment)

I think that gives us a useful starting point for this proposal, without making 2003 depend on the broker work. The distinction I’d keep is that agent_definition_name selects a definition inside Mecatl; it doesn’t establish an externally trusted identity.

For the integration, I’d like us to spell out how trusted definition resolution produces an admitted source/revision reference, and how a particular durable instance gets registered against that reference and associated with its owner/session. The broker should establish the MCP ceiling from admitted records, rather than accepting a name or tool list supplied by the client or model. Knowing a definition exists also shouldn’t implicitly grant a caller permission to instantiate it.

There’s a lifecycle detail worth reconciling explicitly: 2003 rebuilds fork/clear successors using the current definition catalog while retaining inherited authority, whereas this proposal pins a definition revision to an instance. My suggestion is to distinguish a successor with a new instance identity from restoration of an existing instance. Neither should widen inherited authority, and current restrictions or revocation still need to apply. Direct execution resume after restart is intentionally refused in 2003’s first version, so safe continuation remains follow-up work.

Could we reference 2003 here and capture those integration rules? That would keep the session-binding work and the broker design aligned without pulling credentials, registration, or restart recovery into the first PR.

@jhrozek

jhrozek commented Oct 15, 2026

Copy link
Copy Markdown
Contributor Author

This round of review comments is answered, and each thread has a reply linking the commit. I've left the threads open so you can resolve them, or push back if a reply doesn't settle it.

Answers to review comments

  • Sequencing (@ChrisJBurns, @JAORMX). The identity work comes first and has no broker authority in it; the authority work follows. "v1" is gone from the drafts (eede8bd).
  • Deployment and threats (@JAORMX, 10-12). The broker starts as modules inside mecak8s and later becomes a separate service. A new section says what each deployment closes against a compromised mecak8s, and what stays mecak8s's word in both. Run admission is now an explicit non-goal (adae397, 81eae38).
  • Relationships diagram (@ChrisJBurns). Folded in from docs: clarify agent definitions, instances, sessions, and runs #2347. Also: the glossary now separates host sessions from broker sessions (c872f08, d830782).
  • Logout (@ChrisJBurns). "Sign out" ends one client's tokens. "Sign out everywhere" stops every agent and schedule. AS-1 re-checks the company-IdP grant, so a disabled account stops acting (5aec36d).
  • Audit (@JAORMX). This covers three changes:
    • an AuditEvent profile, which also has AS-1 set act.iss (1a56af2);
    • delegation lineage kept as retained audit events (905f9e9);
    • delivery, protection, and reconciliation, with the sink being the toolhive-core audit logger pointed at a store mecak8s can't write (3557e50).

Other changes, not asked for in review, worth a look

  • AS-1 ID-JAG flow (e2e684a). The credential flow was reworked around a sign-in at AS-1, a session-bound broker refresh token, and an ID-JAG per call. Its decision record is now folded into the chapters and deleted (f7c5f58).
  • Definition loader (d9fb3c0). It's a broker module again. It loads global definitions at startup, and mecak8s names definitions by reference.
  • ID-JAG §9.3 (ca5d9c1). It's now quoted correctly: the section is about trust domains. Embedded mode is outside its cross-domain scope and reuses the format for one protocol path.
  • Session binding (467060b). At session open, AS-1 now checks that the token's user owns the session, which catches mistakes. Session-bound tokens via RFC 9396 are recorded as later work.
  • Containing a compromised mecak8s (27a5065). The later authority work does this with loader-set ceilings, operator-listed root-eligible definitions, and grants per run.
  • ToolHive ledger. The ToolHive work list in implementation.md is now the ledger of the ToolHive changes this design needs. None is filed as an issue yet.

@JAORMX JAORMX 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.

shipit

jhrozek and others added 4 commits October 19, 2026 09:31
Fix what the final review round found:

- A closed session returns its recorded reason with that reason's
  status everywhere; a replaced refresh token returns superseded; a
  lease waiter re-reads its grant before answering.
- Re-registering a SPIFFE ID must match its earlier host session,
  owner, definition revision, and parent; the undefined
  "deregistered" check is dropped.
- Delegation records are kept per session and re-reported parents
  first; an unrecorded delegating run becomes a root run only for a
  root instance.
- Schedule setup keeps the schedule's owner after revocation, renewal
  moves a live grant's horizon, the scheduled-run open refuses a
  closed session and has its own failure table, deleting a schedule
  has its own reason, and scheduled runs map every revocation to
  "needs owner action".
- Sign out everywhere also ends AS-1 login sessions, the revocation
  time compares iat strictly, and issued access tokens are stated to
  keep working for the API until they expire.
- The error_description character set, the README key-sharing and
  instance sentences, the registration list in agent-definitions, and
  stale tests in implementation.md.

Co-Authored-By: mecatl <[email protected]>
Make credentials-and-lifecycle the single home of the end-to-end token
flow and reorder it for implementers:

- One credentials table with custody, then the walkthrough with a new
  step (0) for broker startup, the failure matrix, and error reasons.
- Scheduled runs follow the interactive flow; lifetimes and renewal
  become one table; vMCP sessions move here from the gateway chapter.
- A Later work section collects the unselected options; the workload
  and instance-identity material moves under Reference.
- The User identity, custody, actor-history, provider-selection, and
  sender-binding sections are folded into the steps they belong to.

mcp-gateway-modes keeps only what differs between embedded and
external gateways and links to the flow. implementation.md keeps the
grant record, open items, tests, and ledger, and links to the chapter
instead of restating it. Step numbers are unchanged so existing links
still resolve.

Co-Authored-By: mecatl <[email protected]>
From the pass-3 review:

- Restore the credential record's compare-and-swap refresh, the run
  ID's path to the vMCP, renewal-failure behavior, Mecatl revoking the
  consent link, the broker-side SVID limit, the custody disclaimer,
  RFC 8707 at the vMCP, and the open item on correlation-record order.
- vMCP sessions belong to the instance and user, so they survive a
  replacement broker session and end when the instance ends or the
  user's grants are revoked.
- The delegation report now precedes step (6), which depends on it;
  the failure matrix and error reasons follow scheduled runs, whose
  rows they include; step (0) is marked as a startup prerequisite.
- The embedded-vs-external resolution table lives only in the gateway
  chapter; "provider credential" and "broker refresh token" replace
  the ambiguous "upstream credential" and "session refresh token".
- The chapter points to the tests and the threat model; links to run
  grants and session-bound tokens go to Later work; implementation's
  section is renamed Grant record.
- README: the identity-work checks include the run and its owner, and
  the post-split attacker limit names new sessions and schedule grants.

Co-Authored-By: mecatl <[email protected]>
Replace the "Where trust lives" diagram with one that draws
administrative domains as boxes and the four trust boundaries as
numbered edges: user entry, credential custody between mecak8s and the
broker, gateway entry, and provider egress, each labelled with what
crosses and who checks. It shows the intended deployment, a separate
broker and an external gateway, and a note says what differs today.

The agent trust domain is shown as a naming label on the agents, not a
boundary, since agents share the mecak8s process and their SVIDs are
asserted. AS-1 touches both user entry and gateway entry.

Co-Authored-By: mecatl <[email protected]>
@jhrozek
jhrozek force-pushed the docs/agent-authority branch from de4303c to 1fc17d5 Compare October 19, 2026 07:34
@jhrozek
jhrozek merged commit d5532e9 into main Oct 19, 2026
34 checks passed
@jhrozek
jhrozek deleted the docs/agent-authority branch October 19, 2026 08:35
@toolhive-release-app toolhive-release-app Bot mentioned this pull request Oct 20, 2026
2 tasks
ChrisJBurns added a commit that referenced this pull request Oct 20, 2026
…identity broker

Add internal/identitybroker, the in-process core of the agent-instance
issuer proposed in #2121. New(config, definitions, signer) validates the
identity configuration (SPIFFE trust domain, unique audiences, credential
lifetime capped at one hour), an ECDSA P-256 (ES256) crypto.Signer, and
already-loaded definition records (source, name, revision, provenance
with SHA-256 digests), then retains independently owned copies.
Identical duplicate records collapse; conflicting records for the same
reference are rejected. Errors wrap one of four sentinels for later
transport mapping.

ES256 is required because agent credentials are planned as JWT-SVIDs,
which do not permit EdDSA. The package imports only the standard
library, enforced by a new depguard rule that also denies file,
process, network, syscall, TLS, plugin, and logging packages.

Add a contributor design record in docs/drafts covering scope, package
ownership, validation and snapshot semantics, and future work.

Co-authored-by: Mecatl <[email protected]>
ChrisJBurns added a commit that referenced this pull request Oct 20, 2026
 design

Follow the updated agent identity design (#2121 head de4303c):

- Config carries a single Audience, the broker's, because every agent
  JWT-SVID names exactly one audience and the broker's verifiers reject
  more.
- Cap definition source and name at 63 bytes (MaxSegmentBytes), the
  proposed SPIFFE path segment limit.
- Export DefinitionRecord.Validate so the definition loader can skip
  bad definitions, as the design requires, while New stays strict.
- Use global/ and system/ examples: the broker loads only operator and
  built-in definitions; repository definitions are mecak8s reports.

Update the design record: per-instance definition records settle
restoration after a source change, the snapshot scope, the single
audience, the segment cap, the signing key ID, the registration checks
for the next step, and the open question of two sources sharing a
category.

Co-authored-by: Mecatl <[email protected]>
ChrisJBurns added a commit that referenced this pull request Oct 20, 2026
…undation

Drop registration, adapter, restoration, and roadmap material that belongs
to later agent identity tickets, and point at the merged design in
docs/drafts/agent-identity instead of PR #2121.

Co-authored-by: Mecatl <[email protected]>

This branch was successfully deployed

1 active deployment
Preview — 938691cd Deployed Oct 19, 2026 by vercel[bot]
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.

4 participants