Skip to content

fix(auth): bind outbound ops to validated capability snapshots - #191

Draft
marcus-pousette wants to merge 2 commits into
refactor/sync-protocol-helpersfrom
fix/auth-outbound-read-guard
Draft

marcus-pousette wants to merge 2 commits into
refactor/sync-protocol-helpersfrom
fix/auth-outbound-read-guard

Conversation

@marcus-pousette

@marcus-pousette marcus-pousette commented Jul 11, 2026 •

Copy link
Copy Markdown
Collaborator

Roadmap: Source material for #244 and #243.
Status: Legacy capability-snapshot design, not a merge candidate. Port only the useful exchange correlation, outbound fencing, and tests into the possession-bound session model.

Problem

A peer's capabilities can change while backend reads, filtering, signing, or transport sends are awaiting. Outbound work must not be selected under one authority snapshot and be sent after that snapshot is replaced.

The original draft also had no way to correlate HelloAck with a specific Hello, which forced transport-wide waiter queues and handshake serialization.

What changes

  • Treat Hello/HelloAck capabilities as validated replacement snapshots.
  • Give outbound work a generation/fingerprint lease and recheck it before sending.
  • Require a non-empty Hello.exchangeId; HelloAck echoes it exactly.
  • Allow SyncError.exchangeId to reject only the failed exchange.
  • Track pending Acks by (transport, exchangeId).
  • Ignore unknown, duplicate, or wrong-transport Acks.
  • Fence queued/in-flight work after transport termination.
  • Keep direct-negotiation capabilities out of auth hooks.

Clean-slate choice

This is a wire reset. There is no parser or state-machine fallback for Hello/Ack messages without exchange IDs. The direct correlation removes the global waiter, refresh queue, Hello serialization tail, capability-handler tail, inbound-Hello generation, and crossed-Hello fallback.

Fast paths left

  • Tiny-scope direct send remains.
  • Empty-receiver direct send remains.
  • Normal RIBLT reconciliation remains.
  • Capability-free peers retain the empty generation-zero path.
  • Stable snapshots use cheap fingerprint/generation checks.
  • An all-denied filter still avoids signing and sending.

Verification

  • Sync protocol build and full test suite pass.
  • Auth build and full test suite pass on the final stack.
  • Generated protobuf code was regenerated from the schema.

The rewrite removes 258 net lines from the previous PR head, including 101 net production lines from sync.ts.

Stack

Stacked on #201. #181 provides transport ownership and terminal-error foundations.

@marcus-pousette
marcus-pousette force-pushed the fix/auth-outbound-read-guard branch from d7baa47 to be3fafc Compare July 11, 2026 22:56
@marcus-pousette
marcus-pousette force-pushed the fix/auth-safe-oplog-projection branch from 9b37f32 to 54181f6 Compare July 11, 2026 23:01
@marcus-pousette
marcus-pousette force-pushed the fix/auth-outbound-read-guard branch from be3fafc to 7e254df Compare July 11, 2026 23:01
@marcus-pousette marcus-pousette added bug Something isn't working area:auth Authorization, capabilities, proofs, signatures, crypto, and privacy area:sync Sync protocol, reconciliation, transport, discovery, and sync servers labels Jul 12, 2026
@marcus-pousette
marcus-pousette force-pushed the fix/auth-safe-oplog-projection branch from 54181f6 to 3c84eae Compare July 12, 2026 12:18
@marcus-pousette
marcus-pousette force-pushed the fix/auth-outbound-read-guard branch from 7e254df to fde4928 Compare July 12, 2026 12:32
@marcus-pousette marcus-pousette changed the title fix(auth): gate every outbound operation path fix(auth): bind outbound ops to validated capability snapshots Jul 12, 2026
@marcus-pousette
marcus-pousette changed the base branch from fix/auth-safe-oplog-projection to refactor/sync-protocol-helpers July 12, 2026 12:32
@marcus-pousette
marcus-pousette force-pushed the refactor/sync-protocol-helpers branch from 89efe4d to 48660f0 Compare July 13, 2026 14:07
@marcus-pousette
marcus-pousette force-pushed the fix/auth-outbound-read-guard branch 3 times, most recently from 72cf530 to 7ac402b Compare July 13, 2026 15:06
@marcus-pousette
marcus-pousette force-pushed the refactor/sync-protocol-helpers branch 2 times, most recently from 160a171 to 7268598 Compare July 13, 2026 15:50
@marcus-pousette
marcus-pousette force-pushed the fix/auth-outbound-read-guard branch from 7ac402b to dbc37dc Compare July 13, 2026 15:50
@marcus-pousette
marcus-pousette force-pushed the fix/auth-outbound-read-guard branch from dbc37dc to f019796 Compare August 19, 2026 08:52
@marcus-pousette
marcus-pousette force-pushed the refactor/sync-protocol-helpers branch from 7268598 to 6221d9b Compare August 19, 2026 08:52
@marcus-pousette
marcus-pousette marked this pull request as draft August 31, 2026 13:38

This branch has not been deployed

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

Labels

area:auth Authorization, capabilities, proofs, signatures, crypto, and privacy area:sync Sync protocol, reconciliation, transport, discovery, and sync servers bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant