Skip to content

feat(core): key gateway trust and dm:send admission on user principals - #190

Merged
Mearman merged 5 commits into
mainfrom
feat/principal-keyed-gateway-trust
Sep 18, 2026
Merged

Mearman merged 5 commits into
mainfrom
feat/principal-keyed-gateway-trust

Conversation

@Mearman

@Mearman Mearman commented Sep 18, 2026

Copy link
Copy Markdown
Member

Closes #187

Extends GatewayTrust and admitAgentForDm to accept a user-principal device-id as the trusted/admitted party, not just a bare device-id, so a remote peer presenting a token whose delegation chain roots back to a trusted/admitted principal can pass, with the principal's own delegation depth allowed to sub-delegate to its own devices.

Work in progress: GatewayTrust's own principal allowlist lands first; admitAgentForDm's delegation-depth extension and the principal-to-own-device sub-delegation primitive follow as separate commits on this branch.

…device

Adds a second, parallel allowlist for principal device-ids alongside the
existing bare-device set: addPrincipal/removePrincipal/listPrincipals/
isTrustedPrincipal manage it, and isTrustedFor decides trust from a
caller-supplied, already chain-verified bearer and root-issuer pair,
accepting either a directly trusted device or a bearer rooted at a trusted
principal. hasAny now also reflects a trusted principal for the outbound
gossip gate. The existing isTrusted/add/remove/list bare-device path is
unchanged, so a peer with no principal at all behaves exactly as before.
admitAgentForDm now takes an optional delegationsRemaining argument,
defaulting to 0 so the existing non-delegable bare-device path is
unchanged. A positive value mints a dm:send grant naming a user principal
as bearer, with enough delegation depth for that principal to mint further
dm:send tokens to its own devices (agent-comms#187), the dm:send
counterpart to how #161's device-membership tokens already let a principal
admit its own devices. verifyDmSendToken needs no change: its chain-walk
already resolves rootIssuer through any number of hops.

wireTestTransport gains an optional userIdentityOptions parameter so a test
can control (and therefore know ahead of time) a MeshStore's own
user-principal identity, needed to construct a delegation whose scope
narrows the grant it chains from.
…own device

Adds delegateDmSendToDevice, the dm:send counterpart to device-membership.ts's
admitDevice: given a dm:send grant a user principal was itself admitted with
(delegationsRemaining > 0), mints a child token naming one of that
principal's own devices as bearer, keeping the original admitting
principal's own scope unchanged. mintCapabilityToken's own parent-narrowing
refuses the mint if the parent has no delegation depth left or if the
caller's identity is not the parent's own bearer. Records the delegated
token-id under the delegating principal's own issued-grant store, keyed by
device hex, mirroring how admitAgentForDm records its own root-level grants.

This is the first real use of mintCapabilityToken's parent-narrowing
machinery in this codebase; every existing grant is an independent
root-level token.
…d dm:send token

End-to-end integration test tying together the admitAgentForDm delegation
depth and delegateDmSendToDevice primitives: an admitting user trusts a
remote user principal rather than one bare device, that principal delegates
the resulting grant to one of its own devices out of band, and the device's
own requestDmAccess auto-admits over a real wire connection presenting only
the delegated token -- the "trust this whole person, not just one device"
flow agent-comms#187 describes.
@Mearman
Mearman force-pushed the feat/principal-keyed-gateway-trust branch from 5a26ada to 1d3b36a Compare September 18, 2026 08:26
@Mearman
Mearman marked this pull request as ready for review September 18, 2026 08:29
@Mearman
Mearman merged commit f45fca8 into main Sep 18, 2026
6 checks passed
@Mearman
Mearman deleted the feat/principal-keyed-gateway-trust branch September 18, 2026 08:29
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 18, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
🔒 Security Review Completed 2026-09-18T08:37:28.209285Z 1d3b36a Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 3.16.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Key gateway trust and dm:send admission on user principals, not bare device-ids

1 participant