Skip to content

Peer gateway as a gateway principal kind: the granting side (slice H of #252, part 1) - #725

Merged
Varuas37 merged 10 commits into
mainfrom
claude/project-thread-q3nib0-h-peer-gateways
Oct 10, 2026
Merged

Varuas37 merged 10 commits into
mainfrom
claude/project-thread-q3nib0-h-peer-gateways

Conversation

@Varuas37

Copy link
Copy Markdown
Contributor

Part of #705 (slice H of #252). Design, state table and limits: docs/design/auth/peer-gateways.md.

Before: pairing could only enroll a device, and every credential it issued acted as the owner (the owner's principal, conversation.read). Another gateway had no identity of its own, so there was no way to let one gateway trust another.

After: an owner can invite a peer gateway with pairing.create {enrollee: "gateway"}. The peer enrolls through the same OPAQUE flow on the same listener. It receives a credential naming a new gateway principal, gateway:<key hex>, derived from the key pinned at pairing and bound to that key. That principal is a member of the owner's organization and can hold only conversation.read, never the conversation authority's actions (conversation.write, credential.manage). For now a paired peer can authenticate and nothing more: every read is refused, and the owner cannot share a conversation with it yet. Revoking it refuses its next connection. A gateway that pairs no peer behaves exactly as before.

How

  • The consent's class is the owner's choice. It is public, bound into the PAKE transcript, and stored with the pairing. A pairing with no class reads as a device, so existing registries and device client files are unchanged. A device client given a peer code (or the reverse) refuses with OtherEnrollee before the PAKE starts: no attempt is charged and nothing is saved.
  • One authority for what a peer may hold. PrincipalKind::may_hold refuses the conversation-authority actions, which are listed once in CONVERSATION_AUTHORITY_ACTIONS, and allows only conversation.read. Slice I will widen this to environment grants, never to authority actions.
  • The registry enforces it on open and before every write:
    • A gateway principal must be pairing-bound, must not be an admin, and must hold no other grant.
    • The gateway: id prefix belongs exactly to the Gateway kind.
    • A pairing-bound credential names a gateway exactly when its pairing's class is a peer's.
    • credential.issue refuses a gateway principal or prefix, so there is no second way in.
  • Reads stay closed until part 2. A peer's receiver binding names the owner as the grantor. Every read path refuses a binding whose owner is not the session principal: passive-read admission on the native channel, and reader_of on the socket. conversation.share refuses a peer's credential with share_target_not_paired. Part 2 lifts both together, with every peer read path behind slice G's grant filter.
sequenceDiagram
    participant Owner
    participant GW as Gateway (pairing + registry)
    participant Peer as Peer gateway
    Owner->>GW: pairing.create {enrollee: gateway}
    GW-->>Owner: code, class peer-gateway-conversation-read
    Peer->>GW: Hello (same listener)
    GW-->>Peer: PublicIntent(class PeerRead)
    Peer->>Peer: class matches, else OtherEnrollee
    Peer->>GW: OPAQUE Begin/Confirm (class in transcript)
    Owner->>GW: pairing.approve(exact key)
    GW->>GW: credential -> gateway:<hex>, kind gateway, conversation.read, key-bound
    Peer->>GW: authenticate -> principal gateway:<hex>
    Peer->>GW: catalogueHead / records / watches -> wrong_owner
    Owner->>GW: conversation.share(peer credential) -> share_target_not_paired
    Owner->>GW: credential.revoke
    Peer->>GW: next connection -> refused
Loading

Tests

Rows H1–H8 in peer-gateways.md each have a test. Highlights:

  • nessa-auth:
    • a_peer_enrollment_issues_a_gateway_principal_bound_to_its_key
    • a_relabelled_enrollment_class_does_not_complete_the_pake
    • the_kind_alone_refuses_a_gateway_any_conversation_authority
    • a_pairing_bound_credential_names_a_gateway_exactly_when_its_class_is_a_peers
    • the_gateway_id_prefix_belongs_to_gateway_principals_alone
  • nessa-server native_enrollment:
    • a_peer_gateway_pairs_as_its_own_principal_and_reads_nothing_ungranted
    • a_revoked_peer_gateway_is_refused_its_next_connection
    • a_client_refuses_an_invitation_for_another_kind_of_party
    • a_peer_cannot_be_shared_with_and_reads_nothing_even_if_granted
  • Socket: a_binding_owned_by_another_principal_reads_nothing_on_the_socket.
  • Each registry clause and each owner check was removed in turn, and the test covering it then failed.

Checks

  • cargo fmt --check: clean.
  • cargo clippy --workspace --exclude nessa-app --all-targets -D warnings: clean. nessa-app needs GTK, which this container lacks.
  • Windows cross-check over the CI crate list: clean.
  • nessa-auth, nessa-protocol and nessa-client-core tests: all pass.
  • nessa-server lib: all pass except the 2 tests that also fail on main in this container, which runs as root. native_enrollment: 85 pass.
  • pnpm protocol:check, typecheck, lint, format:check: pass. Vitest: 3962 pass.

Review

  • Two independent read-only review rounds, plus a design consult on how to read "never both authorities" in the ADR. Neither round found a blocker.
  • Round 1:
    • The may_hold registry clause had no test that reached it.
    • The gateway: prefix and the class were not tied to the kind.
    • Descriptions were stale.
    • A peer's binding names the owner. That is kept as the grantor, with a written precondition for part 2.
  • Round 2:
    • Sharing with a peer is now refused until its reads are grant-scoped, so no grant can wait to start disclosing.
    • The socket test's claims were narrowed.
    • The invariant label was fixed.

Not in this part

  • Part 2, the peer side: a gateway enrolling into another, keeping its credential and pin, and reading what it is granted. The enrollment client moves into nessa-auth.
  • Discovery and "last addresses". These belong to slice I.
  • Known limits:
    • Desktop Linked devices lists a peer's credential, and a claimed peer invitation, as a device.
    • The issuance audit cause is still DevicePairing; the class is in the pairing record.

The ADR implementation plan also ticks A, B and E here, which merged as #714, #721 and #715.

Scripted gateway checks

Not run. pnpm test:e2e:scripted drives the desktop in a browser, and this change has no desktop UI. The pairing and socket paths are covered by the native-enrollment and socket suites above.

🤖 Generated with Claude Code

https://claude.ai/code/session_016B5gDzmXSTaSA3TRsR6MsJ


Generated by Claude Code

#252, part 1)

A gateway can now invite another gateway with the same one-use device
enrollment, on the same native listener. The owner picks who an
invitation enrolls (pairing.create {enrollee: "gateway"}); that choice is
the consent's class, public and bound into the PAKE transcript. A peer's
credential names a principal of the new `gateway` kind, identified by the
key pinned at pairing, instead of the owner.

- auth domain: PrincipalKind::Gateway and PrincipalKind::may_hold, which
  lets a gateway hold conversation.read only, never the conversation
  authority's conversation.write or credential.manage; ConsentClass and
  ConsentClass::credential_principal as the one owner of which principal a
  pairing credential names; PublicIntent and ConsentIntent carry the class.
- registry: publication mints the peer principal and a member membership;
  validate_registry refuses a gateway principal that is not pairing-bound,
  is an admin, or holds a grant its kind cannot; credential.issue refuses a
  gateway principal. The class is stored with the pairing (absent = device,
  so existing registries read unchanged).
- client private state: a peer's record has its own magics; a device's
  file is byte-for-byte as before. The enrollment client refuses an
  invitation for the other kind of party before any attempt is charged
  (NativeClientError::OtherEnrollee).
- protocol: PairingCreateParams {enrollee?}, PairingEnrollee, and
  PrincipalKind "gateway"; TS PairingApi.create(params?).
- A paired peer authenticates and reads nothing: its binding reads for the
  owner and its principal is not the owner, so reads are wrong_owner until
  per-conversation grants (slice G) name it. Revoking it refuses its next
  connection.

Design: docs/design/auth/peer-gateways.md (rows H1-H7, each with a test).
The ADR plan ticks A (#714), B (#721) and E (#715).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016B5gDzmXSTaSA3TRsR6MsJ
PrincipalKind::may_hold and the pairing read grant now share one constant
for conversation.read, and the owner status's class field lists the two
values a consent can carry.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016B5gDzmXSTaSA3TRsR6MsJ
…ld alone

The registry now requires a pairing-bound credential to name a gateway
principal exactly when its pairing's class is a peer's, and a principal's
id to carry the gateway: prefix exactly when its kind is a gateway.
credential.issue refuses the prefix whatever kind a request claims. The
prefix is one constant shared with peer_principal.

The conversation authority's actions are listed once in
CONVERSATION_AUTHORITY_ACTIONS; may_hold refuses them before it consults
the peer allowlist that slice I will widen.

ReceiverBinding::owner_id is documented as the grantor, never the reader.

New tests call validate_principal_kind directly so the may_hold clause and
the class/kind clause are each the only check that refuses; each was shown
to fail with its clause removed.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016B5gDzmXSTaSA3TRsR6MsJ
peer-gateways.md names binding.owner_id as the grantor, states that the
owner check may be replaced by a credential comparison only in the change
that puts every peer read path behind slice G's grant filter, and that a
peer's reads are recorded under the session principal. It notes slice I's
allowlist widening, the registry's prefix and class rules, and that Linked
devices shows a claimed peer invitation as an ordinary device awaiting
approval. ProductPrincipal and the session principal descriptions now
include paired peer gateways.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016B5gDzmXSTaSA3TRsR6MsJ
Slice G's conversation.share accepts a peer's credential, because the
peer's receiver binding names the owner as its grantor. Two tests pin that
the grant is not yet a way in:

- On the native channel, a peer's catalogue and record heads and both
  watches are refused wrong_owner by AdmitPassiveRead::binding, while a
  device granted the same conversation passes that admission.
- On the socket, a binding whose owner is not the session principal is
  refused by reader_of before any grant: conversation.read, .list,
  .observe and both subscriptions answer conversation_not_found, and
  conversation.shares is forbidden by policy.

Each test fails with its owner check removed. peer-gateways.md names the
two checks, adds row H8 and the share step to the sequence, and notes a
share to a peer is accepted and unused until the next part. read_grants.rs
points at the precondition.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016B5gDzmXSTaSA3TRsR6MsJ
conversation.share now refuses a target credential whose principal is a
peer gateway's, with share_target_not_paired, and writes no grant. A peer's
reads are not yet narrowed by grant, so a grant stored now would start
disclosing when they are, without a fresh decision by the owner; the change
that narrows them lifts this refusal. unshare is unchanged. The target's
principal is read through the access port; is_peer_principal, beside the
reserved prefix, answers the kind from the id, which the registry keeps
equivalent.

The native H8 test now asserts the refusal (it fails without it) and that a
grant already on a peer's receiver still discloses nothing. The socket test
is renamed and described as what it exercises, a binding whose owner is not
the session principal, and no longer asserts the fixture's policy refusal of
conversation.shares.

A principal whose id and kind disagree is reported as the new
RegistryInvariant::PrincipalKind rather than DuplicateIdentity.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016B5gDzmXSTaSA3TRsR6MsJ

Copy link
Copy Markdown
Contributor Author

@codex review


Generated by Claude Code

@coderabbitai

coderabbitai Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Review in Change Stack →Review in Change Stack →

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f8567a53-bb34-40f5-bb21-fd1ad4bd7af3

📥 Commits

Reviewing files that changed from the base of the PR and between 52328db and fe38c09.


⛔ Files ignored due to path filters (1)
  • packages/nessa-client/src/generated/product.ts is excluded by !**/generated/**

📒 Files selected for processing (57)
  • crates/nessa-auth/src/adapters/local/registry.rs
  • crates/nessa-auth/src/adapters/local/registry/pairing/enrollment.rs
  • crates/nessa-auth/src/adapters/local/registry/pairing/projection.rs
  • crates/nessa-auth/src/adapters/local/registry/pairing/tests.rs
  • crates/nessa-auth/src/adapters/pairing/context.rs
  • crates/nessa-auth/src/adapters/pairing/private_state.rs
  • crates/nessa-auth/src/adapters/pairing/private_state/tests.rs
  • crates/nessa-auth/src/adapters/pairing/tests.rs
  • crates/nessa-auth/src/application/credential_registry.rs
  • crates/nessa-auth/src/application/dto.rs
  • crates/nessa-auth/src/application/mapping.rs
  • crates/nessa-auth/src/domain/mod.rs
  • crates/nessa-auth/src/domain/models.rs
  • crates/nessa-auth/src/domain/pairing/aggregates/invitation.rs
  • crates/nessa-auth/src/domain/pairing/mod.rs
  • crates/nessa-auth/src/domain/pairing/value_objects/disclosed_consent.rs
  • crates/nessa-auth/src/domain/pairing/value_objects/mod.rs
  • crates/nessa-auth/src/domain/pairing/value_objects/public_intent.rs
  • crates/nessa-auth/src/domain/pairing/value_objects/values.rs
  • crates/nessa-auth/tests/domain/pairing/disclosure.rs
  • crates/nessa-auth/tests/domain/pairing/invitation.rs
  • crates/nessa-auth/tests/domain/pairing/peer.rs
  • crates/nessa-auth/tests/pairing_domain.rs
  • crates/nessa-client-core/src/composition/device.rs
  • crates/nessa-client-core/src/pairing/client.rs
  • crates/nessa-client-core/tests/read_only_sync/application/device.rs
  • crates/nessa-protocol/src/pairing/wire/dto.rs
  • crates/nessa-protocol/src/product/generated.rs
  • crates/nessa-protocol/tests/pairing/wire.rs
  • crates/nessa-server/src/conversation/application/read_grants.rs
  • crates/nessa-server/src/conversation/domain/receiver.rs
  • crates/nessa-server/src/device_pairing/application/owner.rs
  • crates/nessa-server/src/device_pairing/infrastructure/owner_commands.rs
  • crates/nessa-server/src/device_pairing/infrastructure/runtime.rs
  • crates/nessa-server/src/product/pairing.rs
  • crates/nessa-server/src/product/read_access.rs
  • crates/nessa-server/src/product/socket.rs
  • crates/nessa-server/tests/composition/native_pairing.rs
  • crates/nessa-server/tests/composition/read_only_online/fixtures/gateway.rs
  • crates/nessa-server/tests/device_pairing/infrastructure/activation.rs
  • crates/nessa-server/tests/device_pairing/infrastructure/enrollment.rs
  • crates/nessa-server/tests/device_pairing/infrastructure/lifecycle.rs
  • crates/nessa-server/tests/device_pairing/infrastructure/listener.rs
  • crates/nessa-server/tests/device_pairing/infrastructure/protected.rs
  • crates/nessa-server/tests/device_pairing/owner_routes.rs
  • crates/nessa-server/tests/product/socket/subscriptions.rs
  • docs/adr/todo/252-runtime-roles-and-execution-leases.md
  • docs/codebase-structure.md
  • docs/design/auth/README.md
  • docs/design/auth/device-pairing.md
  • docs/design/auth/peer-gateways.md
  • docs/design/read-grants.md
  • docs/design/runtime-architecture.md
  • packages/nessa-client/src/presentation/pairing-api.test.ts
  • packages/nessa-client/src/presentation/pairing-api.ts
  • protocol/product/manifest.json
  • protocol/product/v1.json

 _______________________________________
< Goodbye, 3-hour code review sessions. >
 ---------------------------------------
  \
   \   (\__/)
       (•ㅅ•)
       /   づ
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR

🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 10, 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-10T05:33:00.720031Z fe38c09 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.

@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: a8580ba64c

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

Share classified its target by the principal of whatever snapshot the
access reader returned. A reader answering about another credential could
pass a peer as a device and store a grant that would disclose once peer
reads are enabled. The snapshot must now name the credential asked for.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016B5gDzmXSTaSA3TRsR6MsJ

Copy link
Copy Markdown
Contributor Author

@codex review

The snapshot-belongs-to-target finding is fixed in d9934d2, and main (with #723) is merged in at 9cdf8f4.


Generated by Claude Code

@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: 9cdf8f4169

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

The snapshot read for a share target must name the credential asked
for, in the binding's organization, with a membership of the same
principal and organization, before the peer check runs. The socket
tests' fake access reader now answers about the credential asked for.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016B5gDzmXSTaSA3TRsR6MsJ
@Varuas37
Varuas37 marked this pull request as ready for review October 10, 2026 05:27
@Varuas37
Varuas37 merged commit 14314fe into main Oct 10, 2026
11 checks passed
@Varuas37
Varuas37 deleted the claude/project-thread-q3nib0-h-peer-gateways branch October 10, 2026 05:28

@greptile-apps greptile-apps 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.

Your trial has ended. Reactivate Greptile to resume code reviews.

@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: fe38c09404

ℹ️ 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 +235 to +237
|| named.principal_id() != target.membership.principal_id()
|| named.organization_id() != target.membership.organization_id()
|| is_peer_principal(named.principal_id())

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Compare the snapshot principal with the binding owner

When a hosted/custom AccessReader returns the requested peer credential ID but substitutes both the credential and membership principals with the same non-gateway identity in the binding's organization, these checks pass because they compare those principals only with each other, never with binding.owner_id. grants.change then records the latent peer grant that H8 is intended to prevent. Fresh evidence after fe38c09 is that the current check closes the mismatched-membership case but still accepts this coherent substituted pair; compare the snapshot principal with the binding owner before the effect and cover that case.

AGENTS.md reference: AGENTS.md:L87-L88

Useful? React with 👍 / 👎.

Varuas37 added a commit that referenced this pull request Oct 10, 2026
…2a) (#728)

Part 2a of #705 (slice H of ADR 252). Builds on #725, which added peer
gateways but only on the granting side.

**Before:** admission only accepted a session whose principal was the
owner its receiver binding named. A paired peer gateway is its own
principal, so it read nothing, and `conversation.share` refused to share
with one. A paired device's catalogue head was also the owner's whole
head, so it moved with owner work the device was never granted.

**After:** a paired peer reads exactly what the owner shared with it,
and nothing else.
- Admission matches a binding to its session by credential and
organization. The binding's `owner_id` is the grantor whose
conversations are read, never the reader.
- Every read path a peer can reach is narrowed by the receiver's grants:
record head and pages, records watch, catalogue manifest and resolve.
- `conversation.share` accepts a peer's credential. Before writing
anything it checks that the access answer is about that credential, in
the binding's organization, and that the credential and membership name
the same principal.
- A paired reader's catalogue head is computed over what it was granted:
the latest revision among its granted rows and its applied grant
changes. A grant, a revoke, or a change to a granted row moves it; other
owner work does not. This applies to devices too, which closes G's known
limit.
- A manifest pass from a paired reader is bounded by that reader's own
head, so it cannot probe for the owner's head.
- `watchCatalogue` is refused (`forbidden`) to a peer, because its
notices would reveal the timing of the owner's ungranted work. A peer
polls its head instead. Devices keep the watch.

```mermaid
sequenceDiagram
    participant O as Owner
    participant G as Owner's gateway
    participant P as Peer gateway
    O->>G: conversation.share(A, peer credential)
    G->>G: access answer is about this credential, same org, credential and membership agree
    G->>G: write grant on the peer's receiver for A
    P->>G: catalogueHead (paired peer)
    G-->>P: head over granted rows only
    P->>G: catalogueManifest(boundary <= its head)
    G-->>P: A only
    P->>G: recordsHead(B, not granted)
    G-->>P: wrong_owner
    P->>G: watchCatalogue
    G-->>P: forbidden
```

## How

- `AdmitPassiveRead::binding` and `reader_of` drop the
owner-equals-principal check. The credential and organization check that
was already there becomes the identity check.
- The read paths were already narrowed by receiver through G's filter.
This change pins each one with a test.
- `ConversationCatalogue::head` takes a `Reader`. `granted_head` reads
the max over granted rows and `read_grant_changes` in one transaction.
`page()` checks a paired reader's boundary against that head.
- The socket's read methods need `conversation.write`, which a gateway
principal can never hold, so Cedar refuses a peer before admission.
Admission still narrows by grant behind that.

## Known limits (in docs/design/auth/peer-gateways.md)

- **One catalogue reset for existing devices.** Devices paired under G
saved progress against the owner's head. Their next pass sees a lower
head and gets `ResetRequired`, which the client does not handle on its
own, so each needs one explicit catalogue reset. Changing the scope
would hit the same refusal.
- **The head still counts other owner work.** Head values are owner-wide
revisions, so the gap between two values counts the owner's other
changes. Numbering revisions per reader is not built.
- **Grantor liveness rests on a registry invariant.** It holds because
no runtime path disables or demotes a membership and only active admins
can pair. The change that adds either must add a grantor-liveness check
at admission in the same change.

## What was tested

- `a_peer_reads_only_what_it_was_granted` (native, real registry)
covers:
  - the share applies;
- the granted record head is admitted, while the ungranted head, watch
and page are refused `wrong_owner`;
  - an ungranted resolve is answered like a missing id;
  - the manifest lists only the granted conversation;
  - a boundary past the peer's head is refused;
  - `watchCatalogue` is forbidden to the peer but admitted for a device;
- owner work does not move the peer's head, and unshare moves it
forward.
- `a_binding_owned_by_another_principal_reads_only_what_it_was_granted`
(socket), `a_paired_readers_head_moves_only_with_what_it_was_granted`
(store), and
`a_registry_whose_owner_is_not_an_active_admin_does_not_open`
(nessa-auth).
- Each test fails under its mutation. The mutations were:
  - skip `admit_read`;
  - drop the SQL narrowing;
  - use the owner head for a paired reader;
  - drop the journal term;
  - treat ungranted as ok;
  - drop the peer watch refusal;
  - drop the owner Active check;
  - use the owner head for the manifest boundary.
- Local gate:
  - `cargo fmt --check`: clean.
  - Clippy `-D warnings` on nessa-server and nessa-auth: clean.
  - nessa-auth tests: pass.
  - `native_enrollment`: 85 pass.
- nessa-server lib: 2157 pass. The 2 tests that fail only when run as
root also fail on main in this container.
  - `pnpm protocol:check` and `format:check`: clean.
- An independent adversarial review found one major issue: a peer could
find the owner's head by probing the manifest boundary. It also found
four minor ones. All are fixed in da57e42.

## Scripted gateway checks

Not run: no desktop or UI surface changes. The protocol change is a
description string only.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_016B5gDzmXSTaSA3TRsR6MsJ

---
_Generated by [Claude
Code](https://claude.ai/code/session_016B5gDzmXSTaSA3TRsR6MsJ)_

---------

Co-authored-by: Claude <noreply@anthropic.com>
Varuas37 added a commit that referenced this pull request Oct 11, 2026
## Motivation

Complete the unblocked work from [audit tracker
#691](#691), following
the user's request to pause issues labelled `blocked-by-restructure`.
The earlier combined local branch is preserved; #678, #680, #681, #682,
#683, #686 and #696 are deferred until their runtime-architecture slices
are ready. This PR does not close the tracker.

#692 and #694 already fixed #679 and #687; #715 covered #684 and
superseded closed, unmerged #677. This PR completes #677's remaining
mounted panel Messages-list goal as #722 through the current
subscription contract.

## Solution

1. Keep SDK approval-change ownership through provider acknowledgment,
caller loss and close (#685; `15cfad98f`, `4ef66c8ff`).
2. Accept safely owned shared service directories, reconcile exact
installed commands and changed environment, and retain one
directory-publication transaction through physical settlement and audit
failure (#688–#690; `9460a266f`, `4baa5c5da`, `5c949fc22`, `68f53229d`).
3. Refuse a retained OAuth refresh secret from another authorization
generation before making the token request (#711; `78d8a4958`).
4. Correlate metadata targets and newly Created receipts with the
original proposal before effects; retain owned mode intent/application
through terminal faults; and publish current views through the
projection and existing retirement owners (#712/#726/#727; `adf20f3dd`,
`43e171c9d`). This uses existing current-read and LiveOnly paths without
the deferred history API.
5. Keep one mounted active/archived Messages-list pair, reject late
callbacks and one-shot replies, retain each half’s stale evidence, and
release late opens on cleanup (#722; `e27825680`). Its target budget of
two is generated from the existing schema owner; separate list frames
are not claimed as an atomic snapshot.
6. Move ResizeObserver effects onto cancellable frames; retire queued
focus settlement with its mounted effect, including both overview-return
frames; and measure existing browser readiness before sampling or
clicking (#693/#730; `69135f63d`, `5ed886807`, `19d11a3dd`,
`90eb7bcda`). The original layout setup and timing budgets are
unchanged. Live mode/list verification uses the shared dev-only fixture
classification (`2b57adac3`, `a413aee6b`).

The branch was assembled from main `965797a9f`, retaining #715
subscriptions, #714/#721 execution leases, #720 read grants and
#725/#728/#729 peer admission and client feature wiring. It adds no
deferred passive-history API or desktop history renderer changes.

7. Refuse a bound unavailable view through the existing draft decision
before create/send/steer; retain the draft and project the same failure
into the existing approval control until valid recovery (#712;
`9c1c672f2`). The unchanged headed Chromium/WebKit mode fixture proves
both consumers, and a fresh independent delta review reports zero
findings.

Current source head is `fb8d62152d2c26c9ae6e659b7b02d7f5cadfff38`
(native test-gate correction and compact final evidence). Upstream
subsequently advanced to `2d2a7a714e053d25b7371d86ff53b8b77952a363`
(#732, SDK MCP writer-panic cleanup); a read-only merge preflight is
clean. The measured main performance baseline below remains the actual
`88f34e4da` source, and is not relabelled as the later main. The new CI
workflow checkout is independently verified as merge
`db98edc8718f52b8328880358feea5d1cd8d3678`, parents current main2d2a and
PRfb8. All 10 checks on that actual current-main merge now pass,
including all three supported-platform jobs and the required aggregate.

8. Keep the native settings fault counter compatible with the declared
Rust 1.85 minimum and current CI warnings: use its existing checked
decrement with a compare/exchange loop inside the test fixture
(`31e0ff4ee`). Production code and warning policy are unchanged.
9. Consume the existing complete-list, recorded ghost and resize-frame
publications before verification measures them (`2040a42b3`); refuse an
unavailable complete-list observation through the existing `CannotRun`
result (`a327700ec`). Original product assertions, seeds, selectors,
geometry and budgets are unchanged. The readiness review’s P2 is fixed
and its fresh second round reports zero findings.

10. Make the existing two-caller native tests consume both receipt
waiters before releasing their held effect (`7f9ef1807`). The retained
publication introduced in `68f53229dd` makes its first caller a waiter
too; the old nonzero test gate could release before the second caller
joined. Three existing gates are corrected, the sole-caller gate stays
unchanged, and production code is unchanged. Controlled
before/fixed/removal/restored witnesses distinguish the original failure
from valid late admission through typed outcomes, directory state and
native attempt counts.

### Native settings settlement

Previously, losing a caller could restore the old directory while a
detached native change still installed the new command. One publication
transaction now retains the desired settings through the actual native
receipt. A failed audit preserves its confirmed physical result.

```mermaid
sequenceDiagram
    participant Caller
    participant Owner as ClaudePublication transaction
    participant Settings
    participant Native as Native reconciliation
    participant Result as Retained result
    Caller->>Owner: Claim requested directory
    Owner->>Settings: Save desired directory
    Owner->>Native: Reconcile exact owned command
    Caller->>Owner: Drop waiting caller
    Note over Owner: Keep transaction and prior values
    Native-->>Owner: Physical result and audit receipt
    alt Confirmed physical success
        Owner->>Settings: Keep desired directory
    else Native refusal before effects
        Owner->>Settings: Restore known prior values
    else Native effect is unconfirmed
        Owner->>Settings: Restore known local priors and retain failure
        Note over Owner,Native: No daemon rollback is claimed
    end
    Owner->>Result: Settle retained receipt and release ownership
```

### Messages-list lifetime

The list previously refreshed only on opening, reconnection or local
changes. Its mounted owner now receives external catalogue changes
through the current subscription API and stops both targets when it
leaves.

```mermaid
sequenceDiagram
    participant Messages as Mounted Messages owner
    participant Client as Client subscription gate
    participant Gateway
    participant Other as Other window
    Messages->>Client: Follow active and archived lists
    Client->>Gateway: Subscribe both bounded targets
    Gateway-->>Messages: Initial frame for each half
    Messages->>Messages: Publish roster after both answer
    Other->>Gateway: Create or archive conversation
    Gateway-->>Messages: Replace changed half
    Messages->>Messages: Preserve other half and its stale evidence
    Messages->>Client: Leave and stop both registrations
    Client->>Gateway: Retire targets including late opens
```

### Focus cleanup

Queued settlement could start a new focus attempt after its subscription
had been cleaned up. The mounted effect now owns those outer frames as
well as its current attempt. The browser regression replaces the real
layout while a movement is queued, delivers the retired callbacks, and
checks zero new frame work and a usable replacement composer.

```mermaid
sequenceDiagram
    participant Store
    participant Owner as Mounted focus effect
    participant Frame as Animation-frame queue
    participant Next as Replacement layout
    Store->>Owner: Move focused pane
    Owner->>Frame: Queue owned settlement
    Next->>Owner: Cleanup old layout
    Owner->>Frame: Cancel tracked settlement
    Owner->>Owner: Retire effect and stop current attempt
    Frame-->>Owner: Deliver cancelled callback late
    Owner->>Owner: Refuse work from retired effect
    Next->>Next: Keep current composer usable
```

### Mode and metadata agreement

A mode-only commit previously reused the old publication revision, and
substituted metadata could replace the request or audit origin. The
service now keeps its original intent and observed application until a
correlated terminal result. Unknown settlement retires the attachment
through its existing owner; retained physical uncertainty refuses a
clean current replacement. Explicit pending recovery evidence remains
marked and read-only.

```mermaid
sequenceDiagram
    participant Service as ConversationService
    participant Metadata
    participant Backend
    participant Audit
    participant Projection
    Service->>Metadata: Begin original immutable mode intent
    Metadata-->>Service: Pending evidence
    Service->>Service: Validate evidence before effects
    Service->>Backend: Apply original requested mode
    Backend-->>Service: Observed application
    Service->>Audit: Record original intent and observed effect
    Service->>Metadata: Settle original request with contained faults
    alt Confirmed matching terminal result
        Service->>Projection: Replace selection through revision owner
    else Terminal result cannot be confirmed
        Service->>Service: Retire through existing attachment owner
        Note over Service,Projection: Retained uncertainty refuses clean current publication
    end
```

Loaded and acknowledged metadata must name the requested conversation
before access, audit or provider effects. A newly Created receipt must
also equal the complete admitted proposal; historical Existing evidence
remains legitimate.

```mermaid
sequenceDiagram
    participant Service as ConversationService
    participant Metadata
    participant Audit
    Service->>Metadata: Create admitted immutable proposal
    Metadata-->>Service: Created or historical Existing
    Service->>Service: Validate target and access
    alt Created contradicts original proposal
        Service->>Service: Refuse typed Metadata before effects
    else Correlated Created or legitimate Existing
        Service->>Audit: Reconcile validated original evidence
    end
```

## Validation and remaining merge blockers

**Draft, blocked from merge by the 50 ms overview-answer performance
gate. All 10 current-head CI checks pass, including Linux/macOS/Windows
and the required aggregate. Full browser verification passes 990/990 at
actual checked `05bc3c6c3`, with unchanged browser executable source at
pushed `fb8d62152`.** The checked production cut is
`9c1c672f2f20e39f63ff9745a32d6467259d328d`. The initial evidence-only
commit preserves its production/verification bytes. Later commits change
only the native `cfg(test)` fault-counter fixture, three verification
readiness consumers, three native test sampling gates, their existing
owning tables and evidence. [Committed evidence and exact source
identities](https://github.com/nessalabs/nessa-agent/blob/5c1c2257c630a3f5d5dc83ba422c882ecc598fbd/verification/desktop/evidence/unblocked-audit/README.md)
separate each run and review head.

- Full frontend passes **3,998 tests / 307 files**, plus formatting,
lint/rules, scripts, desktop helpers, architecture, protocol generators,
client documentation, client/root types and production build at this
source.
- All **twelve Rust verification stages** pass at `bd8ef0763`: exact
six-package CI test selection, all-targets Clippy with warnings denied,
client-without-CLI/server feature checks, formatting/runtime
dependencies, SDK/strict documentation, desktop, all-feature storage,
release host and fresh gateway. Rust/native/SDK/OAuth/schema regions are
byte-identical at the final consumer cut; reuse is recorded precisely.
At the latest pushed head, the native `cfg(test)` fault fixture and
existing three test gates differ from that regional Rust result; their
fresh complete host verification is recorded below.
- Fresh desktop and native/SDK/OAuth reviews report zero findings at
`4fea9814`, with their assigned regions unchanged. API round 1's
panic-payload destructor escape was fixed through one terminal owner at
`43e171c9d`; its eight public cases and three guard-removal probes hold.
Fresh API round 2 reports zero findings at `bd8ef0763`. The final
five-file consumer delta has a separate fresh zero-finding review at
`9c1c672f2` (94 scoped tests and two independent ordering probes).
- Unchanged mode-publication check passes in **headed bundled Chromium
and WebKit**, dev mode: both consumer rows plus console row hold in one
run. Ask → Auto → Ask revisions are `[1,2,2,3]`, transcript messages 0;
unavailable dispatch delta 0, `view-unavailable` decline, retained draft
and disabled controls; confirmed recovery restores Auto. Both added
source rules independently fail on removal and pass after restoration.

![Unavailable view retains draft and disables approval in
Chromium](https://github.com/nessalabs/nessa-agent/blob/5c1c2257c630a3f5d5dc83ba422c882ecc598fbd/verification/desktop/evidence/unblocked-audit/mode-publication/unavailable-chromium.png?raw=true)
![Unavailable view retains draft and disables approval in
WebKit](https://github.com/nessalabs/nessa-agent/blob/5c1c2257c630a3f5d5dc83ba422c882ecc598fbd/verification/desktop/evidence/unblocked-audit/mode-publication/unavailable-webkit.png?raw=true)

Fresh mandatory scripted on final production source `9c1c672f2`:
**Verdict: pass, 37/37** — MCP Apps 16/16, gateway-window 13/13,
scripted scenarios 8/8, Chromium and WebKit/default Claude/dev mode;
49.4 seconds. The earlier `bd8ef0763` checkpoint remains separately
committed. The fresh delegate mode run also passes both engine consumer
rows (2/2); it is separate from the author run's two consumer rows plus
console row, and these are not additive repeated-trial counts.

| Check | Chromium | WebKit |
| --- | --- | --- |
| mcp-apps-gateway | pass | pass |
| gateway-window | pass | pass |
| scripted-scenarios | pass | pass |

Relevant recorded line: `console chromium: requestfailed:
http://127.0.0.1:58906/browser/check net::ERR_ABORTED (aborted after a
204 response, #485) (harmless)` — the known harmless abort after a 204
response (#485). Raw gateway/ACP/session-capability diagnostics are kept
private. The checked source inventory excludes evidence-only files and
matches the final production cut; Initial GitHub head
`5c1c2257c630a3f5d5dc83ba422c882ecc598fbd` added only committed
evidence. The later readiness changes do not change the scripted-run
executable/helper/fixture regions; this 37/37 result remains attributed
to its exact `9c1c672f2` source.

**Measured performance is failed, not waived:** production/headed
bundled Chromium, three runs, 4× throttle, calibrated 120 ms frame
measured 120.4 ms (ratio 3.2), **32/35 held** at `bd8ef0763`. Against 50
ms: columns drag-drop max/median 73.6/41.9 ms (one slow frame); columns
overview-answer 78.6/74.9 ms (three); sidebar overview-answer 76.7/76.6
ms (three). Answer LoAFs report 55–63 ms script and 37–40 ms forced
layout through React’s delegated root keydown dispatcher; drag's LoAF
has no script attribution. No source cause or outside-scope disposition
is inferred. The measured main88 baseline and failed production9c1
performance are recorded below. Final whole verification passes 990/990
with the corrected readiness consumers; separate retained-app checks
passed 4/4 on identical executable source. Deferred cursor-owned #710 is
not imported or used to excuse these failures.

Quiet actual-main baseline at `88f34e4dabdeca46486dfbd5294e0a2a00a0a5fa`
is now measured: production/headed bundled Chromium, five runs, 4×
throttle, calibration 120 ms → 120.5 ms (ratio 4.12). Overview-answer
fails 5/5 in both layouts: columns max/median 87.9/76.5 ms, sidebar
75.6/73.8 ms; all ten slow frames identify React’s delegated root
keydown dispatcher with script 55–68 ms / forced layout 36–45 ms. Drag
passes 5/5: columns 42.6/41.8 ms, sidebar 44.4/40.4 ms. This establishes
an existing answer-budget failure at the measured main88 source; it
neither identifies a source cause nor waives the final gate or equates
it with #710. The final-cut full performance run has finished at exact
production source `9c1c672f2`: **33/35 held, failed**. Production/headed
bundled Chromium, three runs, 4× throttle, calibration 120 ms → 120.5 ms
(ratio 2.94). Only overview-answer fails 3/3 in each layout: columns
max/median 76.8/73.3 ms, sidebar 72.7/65.5 ms. All other 31 interaction
rows, including both drag rows, pass; the earlier bd8 drag outlier
remains a failed historical result, not a claimed fixed defect. Six slow
answer LoAFs report script 56–58 ms / forced layout 37–39 ms through
React’s delegated dispatcher. The 50 ms gate remains failed.

The complete frozen functional run on production `9c1c672f2` has now
ended **failed, 20/23 groups held** (51m55s), dev mode, Chromium/WebKit,
all default layouts/sizes, no quick or omitted functional selection.
Drag held 171/172 with a WebKit/sidebar/1000×700 compact-card setup
error; columns held 81/84 with three Chromium rail-fold setup errors;
command-order held 0/8, missing the expected named overview rows in both
engines/layouts. The first failures remain unchanged. Live mode and
mounted Messages-list checks pass inside this complete run; widgets,
subagents, MCP Apps and production message-sync pass (14/14 for the
latter). Its four retained-app dev-only rows are run separately and are
not counted as passed here. Separate retained-app checks subsequently
passed 4/4 (dev, 7.9 s). Focused probes proved the three verification
readiness defects: command rows were read before complete-list
publication, compact-card DOM visibility preceded the recorder’s current
frame, and rail inputs were sampled before resize publication. The
tracked corrections consume existing publications; their original
assertions still fail on individual source removals. The initial
whole-run failures remain failures.

Read-only tracing identifies the real request-row → overview
answer/focus → store command → scenario source → settling/reflow path,
with six named source files byte-identical between actual main88 and
final production9c1. These are ranked profiling suspects, not causal
proof. Historical #642 overview-answer measurements had passed, so
neither its older exceptions nor deferred #669/#710 are used to excuse
this new measured failure. No deferred performance source is patched.
The failed initial whole run is recorded above. The final whole run at
exact `05bc3c6c3` passes **23/23 groups, 990/990**, exit 0 in 3,112.5
seconds (51m52.5s): Chromium and WebKit, every default layout/size, no
quick selection. Drag 172/172, rail/layout 84/84 and command-order 8/8
include the previously failing observations. Internal production
message-sync passes 14/14 with three delivery runs per engine/layout:
maximum measured delivery frame 34 ms, zero over 50 ms. Chromium is
calibrated at 4× throttle; WebKit is unthrottled. The four retained-app
dev-only cases remain excluded from that production fixture and
separately pass 4/4 on byte-identical executable source. All owned
browser/dev/gateway/caffeinate processes ended; **this PR stays blocked
from merge even if CI passes until the required frame-budget gate is
properly resolved**.

CodeRabbit explicitly skipped this draft. A fresh independent
evidence-only review at pushed
`5c1c2257c630a3f5d5dc83ba422c882ecc598fbd` reports no new actionable
findings, independently verifying all 25 evidence-only additions and
exact unchanged source regions. It preserves prior review heads rather
than claiming a new whole-code approval. One historical focus probe's
preserved-mtime wording is qualified: that probe is not fresh-mtime
proof; independent hashes and later exact-source checks establish
restored source separately.

The first combined Rust run's generated limits-document mismatch at
`adf20f3dd` remains historical failure evidence; the owner meaning was
corrected and regenerated at `bd8ef0763`, and the exact generator
test/full Rust rerun pass. Historical whole-batch reports apply only to
their original source.

Initial supported-platform CI at `5c1c2257c` failed on all three systems
because stable Clippy denied deprecated `AtomicUsize::fetch_update` in
the native settings test fixture; the required aggregate failed too. Its
macOS SDK/server suites had passed (1,099 SDK and 2,220 server tests).
The correction in `31e0ff4ee` preserves the existing checked decrement
and exactly-one-fault semantics with Rust-1.85-compatible atomics. Fresh
full host verification passes: 705 host tests (one existing ignored),
six signed-manifest and nine release-key tests, 279 tooling tests,
formatting and all-target Clippy with warnings denied. A source-asserted
counter removal fails the public rollback witness; restored fixtures
pass 8/8. Independent source review reports zero findings. [Native CI
correction
evidence](https://github.com/nessalabs/nessa-agent/tree/05bc3c6c3b1ab1a9148bfc45f7cb133cc6f855fe/verification/desktop/evidence/unblocked-audit/native-ci-compatibility).

The four-file readiness delta passes 28 affected browser rows (command
8/8, compact drag 8/8, rail 12/12), with 164 shared helper tests, lint
and format checks. Individual asserted removals fail their canonical
checks and restored source passes. Its round-1 P2—ignoring the
complete-list observer's false result—was corrected; the fresh
independent round-2 review finds no unresolved priority and
independently proves evaluator failure is refused while valid
publications remain accepted. [Readiness evidence and exact reviewed
heads](https://github.com/nessalabs/nessa-agent/tree/05bc3c6c3b1ab1a9148bfc45f7cb133cc6f855fe/verification/desktop/evidence/unblocked-audit/browser-readiness).
Targeted checks do not replace the final whole run.

Previous-head CI at `05bc3c6c3` completed: eight jobs passed, including
Linux/macOS and SDK coverage; Windows failed one native concurrency
witness (427 passed, one failed), and the required aggregate failed. The
failing assertion is `second.join().unwrap().is_err()` in
`an_identical_in_flight_directory_change_waits_for_that_attempt`,
`src-tauri/tests/gateway/application.rs:2467`. The former atomic
deprecation is no longer the failure. The waiter gate correction is now
pushed at `fb8d62152`; its controlled public witness reproduces the old
assertion failure after compilation, passes with the fix, fails after
actual sole-gate removal and passes after fresh restoration. The same
scheduling scaffold preserves typed Gateway failures, authoritative host
directory restoration and one native attempt under the fixed gate; the
broken gate admits a legitimate later Ok request with two attempts. No
flaky-test waiver is used. Fresh complete combined host verification at
clean source `7f9ef1807` passes 705 tests/one existing ignore, 279
tooling tests, six signed-manifest and nine release-key tests,
format/all-target Clippy-Dwarnings in28.2s; fresh independent review is
zero. The latest evidence commit changes no executable source. [Current
native gate correction and
review](https://github.com/nessalabs/nessa-agent/tree/fb8d62152d2c26c9ae6e659b7b02d7f5cadfff38/verification/desktop/evidence/unblocked-audit/native-publication-waiters).
[Actual final whole990/990 report and
identity](https://github.com/nessalabs/nessa-agent/tree/fb8d62152d2c26c9ae6e659b7b02d7f5cadfff38/verification/desktop/evidence/unblocked-audit/final-browser-05bc).

Fresh current-head CI at `fb8d62152` is **PASS: all 10 owned checks**,
including Linux, macOS, Windows, frontend, gateway contract, release
desktop compilation, SDK domain coverage, workflow validation,
classifier and the required aggregate. [Actual
run38078915630](https://github.com/nessalabs/nessa-agent/actions/runs/38078915630)
tests merge `db98edc8718f52b8328880358feea5d1cd8d3678` with current
main2d2a. Backend Windows logs explicitly show the formerly failing
identical-caller test passing and **428/428 native tests**, plus six
manifest and nine release-key tests. The Windows log is truncated; check
conclusions and the untruncated required aggregate independently confirm
success. Existing platform-specific Unix-only omissions retain their
real platform limitations and are not counted as newly passed cases.
These actual CI results replace the pending status; local checks were
not used as a substitute. Results will be read from this head's backend
checks, not inferred from local checks. CodeRabbit continues to decline
the draft, which is not an automated approval. The [independent05bc
assembly replacement
report](#739 (comment))
retains its exact source. The new two-file gate correction has a fresh
[independent review
at7f9](https://github.com/nessalabs/nessa-agent/blob/fb8d62152d2c26c9ae6e659b7b02d7f5cadfff38/verification/desktop/evidence/unblocked-audit/native-publication-waiters/independent-review.md);
a [fresh independent currentfb8 assembly/evidence replacement
review](#739 (comment))
reports zero unresolved findings at every priority in its stated scope.
Completed production reviews retain their actual regions and heads. The
draft cannot merge while performance or any other required gate fails.

Verification limits: local macOS injected-adapter and Playwright
Chromium/WebKit checks do not establish actual Linux service
installation, native WKWebView, signed packaged application, live
providers or an external peer deployment. Supported-platform CI is
reported separately.

Refs #691
Closes #685
Closes #688
Closes #689
Closes #690
Closes #693
Closes #711
Closes #712
Closes #722
Closes #726
Closes #727
Closes #730
Varuas37 added a commit that referenced this pull request Oct 15, 2026
…886)

<!-- CURSOR_AGENT_PR_BODY_BEGIN -->
## Gap check

Same-user and different-user gateways use one path. Each gateway
bootstraps its own owner and organization. Pairing does not record that
the two owners are the same person. A peer is a `gateway:<key>` member
of the **grantor's** organization. Reading the other way is a second
enrollment. Nothing merges the two stores.

### (a) Two gateways owned by the same user, on different devices

| Gap | Issue |
| --- | --- |
| Pair, and read chats the other has shared, over a direct connection |
None. On main: #725, #728, #729, #731, #738. This issue, #705. |
| The same read when the address does not answer, through the relay |
None. #266 (closed), including `peer.enroll` / `peer.relay` and the
poller race. |
| A shared person identity, so the two gateways are one user rather than
two owners who paired | **None exists.** #797 is owner-issued targets
inside one gateway. #811 is a first-party phone on one gateway and says
not to widen `PeerRead`. |
| Comment or Drive on a chat the other gateway shared | **None exists.**
Cedar `paired.peer_gateway` forbids `conversation.comment` and
`conversation.drive` when the session is not signed in as the grantor.
The policy calls forwarding a peer's people's commands a later slice.
#707 does Comment and Drive for a paired **device** that signs in as the
grantor, and leaves the peer forbid in place. #707 is still open for the
share dialog (nessa_ui#128) and for the environment enforcing the
tool-policy snapshot. |
| A follow rule: which granted chats to keep, and how much | **None
exists.** #704 asked for follow rules beside grants. #720 shipped grants
only, and #704 is closed. The poller replicates every granted
conversation. #257 and #262 are the linked-device read path and mobile
scheduling, not a follow table. |
| Local discovery on the LAN | **None exists.** The mesh leaves "whether
to announce, and what it reveals" unresolved. #706 says discovery is its
own issue. The dialing record keeps the enroll address and an optional
relay. |
| The reading gateway's owner opening the replica as a local
conversation | **None exists.** `peer.list` reports sync state and a
count. No product method returns the cached transcript. The design
defers the desktop control. |
| A live catalogue watch for the peer | **None exists.** Cedar
`grant.catalogue_watch` admits a device signed in as the grantor and
refuses a peer. The peer polls. #719 is the shared watch-pool allowance,
not a peer watch. |

### (b) Gateways owned by different users

The pairing, share grants, Cedar caller, direct read, and relay read are
the same as (a). There is no second flow.

| Gap | Issue |
| --- | --- |
| The friend's own people commenting or driving the shared chat | **None
exists.** Same `paired.peer_gateway` forbid. The peer principal is not
the friend. |
| A shared organization or any cross-organization membership beyond that
gateway principal | **None exists.**
`docs/design/auth/identity-tenancy-and-cloud.md` says cross-organization
collaboration needs a future explicit design. Peer pairing is the narrow
path that exists. |
| Follow rules, local discovery, opening the replica locally, live watch
| Same as (a). **None exists** for each. |
| Environment lease relay | Not a chat gap. `nessa env dial --relay`
landed with #266. #706 is still open; its body still says the relay is
blocked on #266. |

Cedar is already the authority for these reads. The session principal is
the gateway principal (`signedInAs`). The grantor is `bindingOwner`, and
it is not compared with the session principal. Share grants from #704
are the rows Cedar consults. A gateway credential cannot hold
`conversation.write` or `credential.manage` (`hold.peer`).

## What this change does

No new pairing protocol. Adding one would be a second flow beside the
one #705's gate forbids.

The implementation plan still said the peer side "follows", and the
architecture table still said a peer's writes were refused for every
role and that gateway-to-gateway pairing was proposed. This records
slice G (#720) and slice H (#725, #728, #729, #731, #738, relay #266) as
met, and leaves local discovery unresolved under slice I.

```mermaid
sequenceDiagram
    participant Owner as Grantor surface
    participant A as Gateway A
    participant B as Gateway B
    Owner->>A: pairing.create {enrollee: gateway}
    B->>A: peer.enroll {address, code} (own native key, OPAQUE)
    Owner->>A: pairing.approve
    A-->>B: credential gateway:key, conversation.read only
    Owner->>A: conversation.share {credentialId, role}
    A->>A: Cedar conversation.read for that receiver
    B->>A: catalogue and records, direct or relay
    B->>B: retained cache of the granted chats
    B->>A: conversation.comment or conversation.drive
    A-->>B: forbidden (paired.peer_gateway)
```

Closes #705

## Scripted gateway checks

Not applicable. No gateway, UI, ACP, or MCP behavior changes.

Re-ran the existing two-gateway tests on this tree:

| Test | Result |
| --- | --- |
| `a_peer_reads_only_what_it_is_granted_and_stops_at_revocation` | pass
(4.24s) |
| `a_peer_whose_address_stops_answering_is_read_through_its_relay` |
pass (0.53s) |
| `a_composed_gateway_enrolls_into_another_with_its_own_key` | pass
(0.72s) |

<!-- CURSOR_AGENT_PR_BODY_END -->

<div><a
href="https://cursor.com/agents/bc-a6b4a05e-cc7d-5b60-af94-4dc82349dca6?cursor_ref=pr_footer&cursor_cta=open_in_web"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/assets/images/open-in-web-light.png"><img
alt="Open in Web" width="114" height="28"
src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a>&nbsp;<a
href="https://cursor.com/background-agent?bcId=bc-a6b4a05e-cc7d-5b60-af94-4dc82349dca6&cursor_ref=pr_footer&cursor_cta=open_in_cursor"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img
alt="Open in Cursor" width="131" height="28"
src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a>&nbsp;</div>

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
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.

2 participants