Skip to content

feat(contract): role watch and capability cmd.exchange - #1623

Merged
frahlg merged 2 commits into
masterfrom
feat/watch-registry
Oct 14, 2026
Merged

frahlg merged 2 commits into
masterfrom
feat/watch-registry

Conversation

@frahlg

@frahlg frahlg commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

Step 2 of ADR 0009. contract/registry.yaml is copied byte for byte from srcfl/ftw-webapp#84, and go generate ./internal/... adds RoleWatch, its scopes and CapCmdExchange:

  • Role watch: ftw.live.read, ftw.plan.read, ftw.events.read and ftw.dispatch.write.
  • Capability cmd.exchange: the box opens the relay's exchange socket and mints watch codes.

The box claims neither name yet.

  • DefaultCaps() lists its capabilities by hand, so cmd.exchange stays unsaid until step 5.
  • knownRole reads the generated RoleScopes. With watch in that table, the LAN page could mint a watch code or change a phone into a watch: a watch with no phone above it. appLinkRoleAllowed now refuses watch at both doors with 403. Step 3 replaces that refusal with decision 4: over a session, from an owner, with step-up, bound to the calling phone.

TestNoDoorHandsOutAWatchYet runs against the real appenroll.Identity. Without the guard, a scanned watch code from the LAN answers 200 with "role":"watch".

Contract-pair: srcfl/ftw-webapp@feat/watch-registry

Paired pull requests. All three carry the same file, byte for byte.

Merge this one and srcfl/ftw-webapp#84 together: while both are open, each CI compares against the other's branch.

Tests

make verify                                       verify: vet + test + build clean
go test ./internal/api/ -run TestNoDoorHandsOutAWatchYet
  without the guard: FAIL, "a scanned watch code from the LAN answered 200"
  with it:           ok
cmp contract/registry.yaml against the ftw-webapp and ftw-app branches   identical

🤖 Generated with Claude Code

ADR 0009 step 2: the shared registry copied byte for byte from
srcfl/ftw-webapp, and the Go constants generated from it.

The box claims neither name yet. DefaultCaps lists its capabilities by
hand, so cmd.exchange stays unsaid until step 5. The role needs a
guard: knownRole reads the generated table, so with watch in it the LAN
page could mint a watch code, or change a phone into a watch, with no
phone above it. appLinkRoleAllowed now refuses watch at both doors.
Step 3 replaces that refusal with the real rule: over a session, from
an owner, with step-up.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 14, 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
📝 Code Review ✅ Completed 2026-10-14T08:19:13.631214Z 498f26c PR opened
ℹ️ 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 498f26c7f1

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +36 to +40
RoleWatch: {
"ftw.live.read",
"ftw.plan.read",
"ftw.events.read",
"ftw.dispatch.write",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Reject persisted watches until parent authorization exists

After a site enrolls a watch on a later milestone and then uses ftw rollback with the current data, appenroll.load preserves the watch row and appuplink admits its key because the role is now known. ScopesForRole then grants the watch unconditional ftw.dispatch.write, without the parent intersection or cascading revocation required by ADR 0009, so a watch can continue controlling energy even after its phone is demoted or removed. Keep this role inadmissible at session construction until parent-aware authorization ships, not merely blocked at the pairing API.

Useful? React with 👍 / 👎.

@frahlg
frahlg merged commit 00d791c into master Oct 14, 2026
17 checks passed
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.

1 participant