Skip to content

feat: permission runtime, lodge adapter, MCP plugin and stdio MCP - #4

Merged
bketelsen merged 6 commits into
mainfrom
irulan/t4-authz-mcp
Nov 16, 2026
Merged

bketelsen merged 6 commits into
mainfrom
irulan/t4-authz-mcp

Conversation

@frostyard-machines

@frostyard-machines frostyard-machines commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Phase 2 of the roadmap (frostyard/core ADR-0085): the permission runtime, the permission plugin, the lodge adapter, the MCP plugin and the stdio MCP server.

  • authz/: a grant of items (a capability, and a path for each selector), the path rules (NFC; no empty, . or .. segment; no trailing /; a grant on /Chan does not cover /Chani), the union check, an absent selector value as the root, the caller and the app's transaction in the context. The denial text is permission denied: needs <cap> on <selector>=<path>.
  • cmd/protoc-gen-hearth-authz: 1 check per RPC; an Authorize<Rpc> hook for each RPC on an object id (a singular non-message field named id or *_id); a wrapper that takes the handler together with its hooks, so a handler without its hook does not build (TestMissingHookFailsBuild). The hook and the RPC run in 1 transaction of the app.
  • lodge/: the lodge socket closes a connection whose peer uid is not lodge's before it reads it; Lodge-Principal and Lodge-Grant (base64url of the grant JSON) are read only on that socket; the private socket deletes every Lodge-* header and acts as the local user.
  • cmd/protoc-gen-hearth-mcp and mcpserver/: tools for EXPOSE_AGENT RPCs only, snake_case names, the proto3 JSON schema (internal/protoschema), the hints of each effect, the denial as a tool error; ServeStdio needs no token and acts as the local user (Go MCP SDK v1.8.0).
  • internal/e2e: the demo app's generated code, its hooks on an in-memory store, and the tests (refusal text, hook refusal, a move checked at both ends, the stdio tools driven by the SDK client). The demo proto adds MoveNote and exposes PublishNote to agents: a compatible manifest change.
  • Docs: ADR-0006, ADR-0007, specs/permissions.md, specs/mcp-tools.md, the options spec (Go plugin parameters, object-id rule), the design overview, the roadmap, AGENTS.md and 2 new site guides.
  • The Connect route of an app and the Connect client that satisfies the generated agent interface move to phase 3, with the example app; the generated tools take a plain Go interface.

Risk tier

Risk tier: 3 — the PR touches L1 and L2 paths of .github/risk-paths.json.

Matched paths at the base, and why each change is safe:

  • authz/** (L1): new package. It fails closed: a context without a caller, the zero grant, an unknown capability and an invalid path all refuse. Tests cover each path rule.
  • lodge/** (L1): new package. The peer uid check runs in Accept, before any byte is read; the handler refuses unless the connection carries the lodge listener's mark; the private socket never reads Lodge-*. Tests: forged headers on the private socket, wrong peer uid, missing and bad headers, a handler without the mark.
  • cmd/protoc-gen-hearth-authz/** (L1): new plugin; golden and failure tests; the demo's generated code is checked by make gen-check and exercised by internal/e2e.
  • internal/model/** (L1): adds Operation.ObjectIDs, BuildGo and ParseGoParams. Build and the manifest plugin's strict parameters are unchanged (tested); no manifest member changes.
  • go.mod, go.sum (L1): adds github.com/modelcontextprotocol/go-sdk v1.8.0, golang.org/x/sys, and golang.org/x/text as a direct dependency. The import boundary test passes.
  • Makefile (L2): gen-check also compares internal/e2e/gen, in the same fail-closed form.
  • .github/risk-paths.json (L2): adds cmd/protoc-gen-hearth-mcp/** (L2) and mcpserver/** (L1), and updates the why of authz/**. Nothing is removed or lowered.

Docs housekeeping

  • New docs started from their category's TEMPLATE.md
  • Every new doc indexed in docs/README.md
  • Cross-links added in both directions (ADR ↔ design ↔ spec ↔ plan)
  • New significant decision recorded as an ADR first, in this PR
  • New or edited ADRs are fact-only: context, decision and consequences
  • Conformance aliases and canonical symlinks are unchanged; canonical targets are edited instead

Verification

  • make ci green locally before the first push (verify gen-check race cross corrections-base).
  • Revert test (new behavior): in a scratch worktree at the PR head, 1 mutation at a time, the targeted test fails on its assertion:
    • covers without the / boundary → TestCoverSiblingPrefix fails
    • no peer uid check in Accept → TestWrongPeerUIDRefused fails (it got a 403 response, not a closed stream)
    • private socket reads Lodge-Principal → TestForgedHeadersOnPrivateSocket fails
    • no AuthorizeGetNote call in the generated wrapper → TestDeniedGetNoteByHook fails
    • no NFC normalization → TestNFC fails
    • wrong outward destructive hint → TestAnnotationsOutward fails
  • Workflows: unchanged.

Cross-review

Reviewer openai/gpt-6.1-sol; coder deepseek/deepseek-flash (with edits by anthropic/claude-opus-5-5). Base 38eaf52e60ad186f41836c8c3d9052cad0b860cf.

  • Initial review at 56e7590 (3 batches, all substantive paths; excluded as generated: demo.pb.go, go.sum, the demo manifest.json): Not ready, 6 blocking. Fixed in 8a7acdc: the MCP guide's caller text, "sel": null in a grant, non-object roots of a tool, NullValue, canonical groups in the demo list, invalid demo examples.
  • Re-review 1 at 8a7acdc: 2 blocking (the Struct root schema; the guard of the caller fix). Fixed in 1e0c256 (TestStructRoot, TestEmptyRoot, the AGENTS.md invariant "1 MCP server has 1 caller").
  • Re-review 2 at 1e0c256: 1 blocking (a message named Empty with no package was mapped as a well-known type). Fixed in 8ea4fbf (TestUnqualifiedNamesAreOrdinary).
  • Re-review 3 at 8ea4fbf: Ready, Blocking: none.

Each blocking fix has a guard test (or the AGENTS.md rule for the docs-only point) and 1 record in .memory/corrections/2026-11-15-pr-4-*.json (7 records). Each guard test fails with its fix reverted.

Phase 2 of the roadmap (docs/plans/0001-roadmap.md), on frostyard/core
ADR-0085.

- authz/: a grant of items (a capability on a path for each selector),
  the path rules (NFC, no empty, . or .. segment, no trailing /, a grant
  covers its path and the paths below it), the union check, the caller
  and the app's transaction in the context.
- cmd/protoc-gen-hearth-authz: 1 check per RPC, an Authorize<Rpc> hook
  for each RPC on an object id, and a wrapper that takes the handler
  with its hooks, so a handler without a hook does not build; the hook
  and the RPC run in 1 transaction of the app.
- lodge/: the peer uid check of the lodge socket before any read, the
  Lodge-Principal and Lodge-Grant headers only there, and the local
  user on the private socket.
- cmd/protoc-gen-hearth-mcp and mcpserver/: tools for the agent RPCs
  only, with snake_case names, the proto3 JSON schema, the hints of the
  effect and the denial text as a tool error; a stdio server that needs
  no token and acts as the local user (Go MCP SDK v1.8.0).
- internal/e2e: the demo app, its generated code, its hooks and the
  tests of the refusal, the move at both ends and the stdio tools.

ADR-0006 and ADR-0007 record the decisions; docs/specs/permissions.md
and docs/specs/mcp-tools.md are the contracts.
@github-actions github-actions Bot added level:L1 Read every line risk:high Touches a path in .github/risk-paths.json labels Nov 16, 2026
…ap NullValue; canonical demo groups

- authz: ParseGrant refuses a "sel" that is not a JSON object, so
  "sel": null no longer reads as the root path.
- protoc-gen-hearth-mcp: refuses an agent RPC whose request or response
  has no JSON object form, and an example that does not fit the tool's
  input schema.
- internal/protoschema: google.protobuf.NullValue maps to type null.
- internal/e2e: the demo stores and compares groups in canonical form;
  its examples use absolute paths and JSON names.
- docs: NewServer fixes 1 caller for every call; never share a
  local-user server with lodge callers.

Each fix has a guard test and a record in .memory/corrections/.
…ixed MCP caller in AGENTS.md

A Struct root now validates real Struct JSON. Rule 6 of the options spec
still keeps Struct out of an agent RPC, and the MCP tools spec says so.
AGENTS.md records that mcpserver.NewServer fixes 1 caller for every call.
An ordinary message named Empty, Struct or Timestamp in a file with no
package keeps its own fields.
@frostyard-machines frostyard-machines added the ready-for-human Reviewed, CI green: ready for Brian to review and merge label Nov 16, 2026
@bketelsen
bketelsen merged commit 859e17e into main Nov 16, 2026
7 checks passed
@frostyard-machines
frostyard-machines deleted the irulan/t4-authz-mcp branch November 16, 2026 07:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

level:L1 Read every line ready-for-human Reviewed, CI green: ready for Brian to review and merge risk:high Touches a path in .github/risk-paths.json

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants