Repository navigation
Description
Every session and schedule records who owns it. A deployment with no verifier wired behaves exactly as today, to the byte.
mecatl. First — nothing else in this set starts without it.
Today mecatl has no user identity at all: one shared static token, the credential discarded at the interceptor, the mTLS certificate never read. This epic adds the principal and the owner field; enforcement is the next epic.
Hazards
Facts that were expensive to find and that nobody re-derives on the way to implementing. Each is verified against code.
SecurityConfig.authEnabled()is the wrong disable predicate. It means "a static shared token is configured", which is wrong in both directions: a shared-token deployment has one credential and zero subjects, an OIDC deployment may have subjects and no static token. Reusing it is a latent fail-open. The identity-disable switch needs its own predicate, derived from whether the verifier is wired.- The module boundary does not protect the ctx accessor. It stops
engine/; the risk is intra-package, where ~60Servicemethods already takectxfirst. An unexported accessor buys nothing against a futureServicemethod reading ctx instead of its parameter, and depguard is package-granular so it cannot express the rule. A source-level test is the cheapest thing that works. ScheduleSpec.OriginSessionIDoutlives the session it names.childgcsweeps top-level sessions on retention, so a cron schedule that outlives its origin would derive an owner from a session that no longer exists — the exact failure this epic exists to prevent. Capture the owner where the origin session is already loaded at create time.- The durable owner lives inside the opaque snapshot payload, which a remote
grpcdriverstore cannot
see. That is fine as scoped here, because the edge writes it and harness-side paths read it. It
becomes a protocol question the first time a driver must key or filter on owner server-side, for
example a per-principal List that does not ship the whole inventory over the wire — at which point
owner needs promoting to a top-level proto field alongsidesession_id, not a metadata header. - A fork must inherit the source's owner. Stamping the forking caller's own owner makes fork an ownership-laundering path.
- Anonymous means a nil caller and a zero owner, never a fabricated one. For reference on what not to do: ToolHive's
AnonymousMiddlewaremintssub: "anonymous"with forgedexp/iat/nbf, so a policy inspecting token freshness sees a valid 24-hour token no IdP issued, and that string then appears in audit records and an external webhook payload looking like a real user. Worth copying from it: its Cedar authorizer fails closed on a missing principal rather than choosing one.
Acceptance criteria
- Exactly one place parses an inbound credential, and one credential-free type crosses into the service layer. Nothing downstream re-parses a token.
- The owner survives every persistence and rehydration path: the snapshot, the event-sourced fold, and the fast list path. A path that misses it yields a silent zero, so all three are enumerated.
- Identity is either derived from a verified credential or absent. There is no third state, and the server never invents a principal to fill the gap.
- No credential, expiry or refresh token is persisted, logged, or placed on a durable type.
- With no verifier configured, behaviour and stored bytes are unchanged from today.
- An object created before this shipped has one defined answer, applied identically everywhere.
Proof
The same properties, adversarially, with an actor and an ordering. A property-level criterion can go green while being false; these are what stop that.
- Alice creates a session; the store, the event log and the list row all name her, and still do after reopen, interrupt, recover, a pod migration and a fork.
- A 3am schedule fires naming its creator, across a restart and a leadership change.
- A developer runs mecatui locally with no token: no principal is invented, and the log says unauthenticated rather than naming a user who does not exist.
- A session persisted before this shipped is refused, not adopted by whoever touches it first.
Slices
Decomposition is the implementer's job; these are the natural seams, not a mandate.
- Verify an inbound token and derive a principal.
- The identity type and how it travels: one hop of ctx at the wire, explicit parameter thereafter.
- The schedule owner, captured at create.
Reasoning
The design this comes from, both on main:
- docs/agent-identity-model.md — the inbound side: who is acting, and how mecatl would identify them.
- docs/agent-identity-outbound.md — the outbound boundary: acting for a user against an external system.
Every hazard above is stated in full here rather than linked, so this issue stands on its own.
Follow-up
Driver-side enforcement is tracked in #452. It is the B-lite continuation of this spike's ownership model, depends on #368, and covers authenticated principal-claim propagation, driver-side ownership enforcement, and the private ownership registry.
Activity
[-]EP1: a caller has an identity, and objects have owners[/-][+]A caller has an identity, and objects have owners[/+]JAORMX commentedon Aug 5, 2026
(mecatl comment, posted on Juan's behalf — color from the #377 open-questions discussion.)
The "one hop of ctx at the wire, explicit parameter thereafter" slice already matches what the Q3 discussion converged on, so recording the reasoning where implementers will see it: gRPC metadata → server interceptor → handler
context.Contextis the idiomatic boundary mechanism (it's how the bearer token rides today), but below the adapter the principal should be a typed, constructor-injected or parameter-passed value. The hazard about the ctx accessor is the same concern from the other side: ctx is invisible at the call site, so anything policy-relevant that travels in it needs the source-level test this issue already calls for, because nothing else can express the rule.One adjacent note from that discussion: the durable owner label will live inside the opaque sessnap payload, which a remote grpcdriver store cannot see. That's fine for #367 as scoped (the edge writes it, harness-side paths read it). It only becomes a protocol question if a driver ever needs to key or filter on owner server-side (e.g. a per-principal List that doesn't ship the whole inventory over the wire) — at that point the owner needs promoting to a top-level proto field alongside
session_id, not just a metadata header. Worth having on the radar here since this epic is what puts the owner into the snapshot.jhrozek commentedon Aug 5, 2026
Agreed on the ctx boundary as described, and the source-level test is already the criterion here — nothing else can express a rule about which parameter a method reads.
Added the driver-visibility point as a hazard rather than acting on it, since as scoped this epic is fine: the edge writes the owner and harness-side paths read it. Recording the trigger so it is not rediscovered later — the first time a driver needs to key or filter on owner server-side, for instance a per-principal List that does not ship the whole inventory over the wire, the owner needs promoting to a top-level proto field alongside
session_idrather than riding in a metadata header.feat(agent): surface the routing-miss reason on the delegation wire (#…
jhrozek commentedon Aug 10, 2026
The verifier slice now has an off-the-shelf answer, and two upstream issues to depend on.
The first slice here is "verify an inbound token and derive a principal", and the hazard above says the identity-disable switch must derive from whether the verifier is wired. Until now that phrase had no referent — mecatl's edge authentication is a constant-time compare against one static shared bearer token (
internal/adapter/server/authn.go), which is exactly the wrong-predicate problem the hazard describes.toolhive-coreis getting the verifier:KeyProviderseam for embedded issuersnetworkingsubstrate it is stacked on: hardened HTTP client, SSRF-safe fetch, port/listener helpersBoth exist as unmerged branches with the hardening already applied — default-deny SSRF on discovery and JWKS fetches, an RSA strength floor, a JWKS staleness bound, a
typgate, credentials kept out of logs. That is the class of detail a hand-rolled verifier gets quietly wrong, which is the argument for consuming rather than writing one.Cost is a go.mod promotion, not a new dependency. mecatl already carries
github.com/stacklok/toolhive-core v0.0.26as an indirect dependency (go.mod:226), pulled in viagithub.com/stacklok/toolhive v0.31.0.Layering constraint. It lands in
internal/adapter/, next to theauthn.goit replaces, and never inengine/. The engine module's dependency closure is doublestar, robfig/cron, yaml, x/sync and goleak; an engine-side import breaks theGOWORK=offstandalone build. Edge authentication is composition's job in any case.Sequencing. Both upstream issues are unmerged branches, and mecatl consumes toolhive-core by version tag, so each is done only when merged and released. Worth knowing before this epic is scheduled, since it is the only unblocked one in the set and everything else waits on its owner field.
Scope note. This covers inbound verification only. The outbound side — the token-exchange client and SVID handling for #372 — is not in either issue and stays ours.
fix: reconcile post-rebase API drift against origin/main
fix: reconcile post-rebase API drift against origin/main
fix: reconcile post-rebase API drift against origin/main
Caller separation: enforce owner-scoped access across sessions, sched…