Skip to content

feat(identitybroker): add validated startup foundation for the agent identity broker - #2442

Merged
ChrisJBurns merged 1 commit into
mainfrom
feat/identitybroker-startup
Oct 20, 2026
Merged

ChrisJBurns merged 1 commit into
mainfrom
feat/identitybroker-startup

Conversation

@ChrisJBurns

@ChrisJBurns ChrisJBurns commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Adds internal/identitybroker, the in-process core of the agent identity broker from the agent identity design. This is the startup foundation every later identity change builds on: the broker's configuration, signing key, and known agent definitions, validated before anything registers.
  • identitybroker.New(config, definitions, signer) validates and keeps independent copies of:
    • configuration: SPIFFE trust domain, the single audience (the broker's), and a credential lifetime of at most one hour;
    • an ES256 (ECDSA P-256) crypto.Signer;
    • definition records: source, name, revision, and provenance with SHA-256 source and definition digests.
  • Identical duplicate records collapse; conflicting ones are rejected. DefinitionRecord.Validate lets the future definition loader skip bad records. Definition(ref) returns a copy.
  • A new internal-identitybroker depguard rule keeps the package standard-library only and denies os, net, log, syscall, crypto/tls, and plugin.

Nothing calls the package yet. For now, the signer and definition records come only from tests; mecak8s startup and the definition loader supply them in later changes.

Closes #2445

Issue relationship

Relates to #2121

Type of change

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

Test plan

Baseline checks

  • Linting (task lint): root module clean, including internal/identitybroker and the new depguard rule. The run stops at a pre-existing gosec G703 finding in environment/microvm/launch_ownership_darwin.go:754, which is darwin-only and untouched here.
  • Fast offline test suite (task test): covered by the race suite below.
  • Pre-review race suite (task test:race): internal/identitybroker passes. Failures in cmd/mecated, cmd/mecatui, and environment/microvm/gitexec reproduce on unmodified main (8ae7d901b) on the same macOS machine and are unrelated to this change. One environment/microvm timing test failed once and passed on rerun.
  • Offline demo (go run ./cmd/mecademo): tool call, permission ask and approval, and result shown.
  • Markdown changed: docs generation/link checks (task docs): no Markdown changes.
  • User docs/user-facing behavior changed: site build (task site:build)
  • Guarded engine API affected: compatibility check (task api:check)
  • Intentional engine API change: task api:update + engine/CHANGELOG.md

Changes

File Change
internal/identitybroker/broker.go New, Broker, Definition, signer checks, the definition snapshot, and error sentinels
internal/identitybroker/config.go Config and its validation
internal/identitybroker/definition.go DefinitionRef, Digest, Provenance, DefinitionRecord, and Validate
internal/identitybroker/broker_test.go Validation, duplicate, lookup, and copy-isolation tests
.golangci.yml internal-identitybroker depguard rule

User-facing change

None.

Special notes for reviewers

Decisions the design leaves open or doesn't spell out:

  • New is strict. One invalid record rejects the whole set. The design says the broker serves the definitions that loaded and skips the ones that fail; that filtering is the loader's job, through DefinitionRecord.Validate.
  • The one-hour lifetime cap is interim. The design doesn't set a value.
  • The snapshot holds only global and system definitions. Repository definitions never enter it; mecak8s reports them at registration.
  • Several revisions per definition are accepted. Whether the loader should keep older revisions after a restart is still open and is tracked with the full definition loader work.
  • ES256 only. JWT-SVID permits only RSA and ECDSA, which rules out Ed25519; P-256 is the smallest permitted key. A raw *ecdsa.PrivateKey is copied; any other crypto.Signer, such as a KMS handle, is kept as supplied.

API compatibility: no remote-observable change. The package is internal, not wired into any server, and adds no protobuf, gRPC, HTTP, or engine API surface. No major or feature-identifier change.

…identity broker

Add internal/identitybroker, the in-process core of the agent identity
broker from the agent identity design (docs/drafts/agent-identity).
New(config, definitions, signer) validates and keeps independently
owned copies of:

- configuration: SPIFFE trust domain, the single audience (the
  broker's), and a credential lifetime of at most one hour, an interim
  cap the design does not set;
- an ECDSA P-256 (ES256) crypto.Signer, the smallest algorithm JWT-SVID
  permits;
- already-loaded definition records: source, name, revision, and
  provenance with SHA-256 source and definition digests.

Identical duplicate records collapse; conflicting ones are rejected.
New rejects the whole set on any invalid record; DefinitionRecord.Validate
lets the definition loader skip bad records first, as the design
requires. Definition(ref) returns a copy. Errors wrap one of four
sentinels. Signer and records come only from tests until mecak8s
startup and the definition loader exist.

The package imports only the standard library, enforced by a new
depguard rule that also denies os, net, log, syscall, crypto/tls, and
plugin, so file, network, and logging access stay in adapters.

Co-authored-by: Mecatl <[email protected]>
@ChrisJBurns
ChrisJBurns merged commit ea10187 into main Oct 20, 2026
40 of 42 checks passed
@ChrisJBurns
ChrisJBurns deleted the feat/identitybroker-startup branch October 20, 2026 18:39
@toolhive-release-app toolhive-release-app Bot mentioned this pull request Oct 23, 2026
2 tasks
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.

Identity broker startup foundation

2 participants