Skip to content

Wire the blob membership gate into id serve (#173) — crate-split port of #7181 - #9734

Closed
dezren39 wants to merge 8 commits into
mainfrom
queue/13492-173-blob-gate-port
Closed

dezren39 wants to merge 8 commits into
mainfrom
queue/13492-173-blob-gate-port

Conversation

@dezren39

@dezren39 dezren39 commented Nov 14, 2026 •

Copy link
Copy Markdown
Member

What

The crate-split port of PR #7181 (task 13492, lane any-a). PR #7181 carried the blob membership gate wiring for #173 but was authored against the pre-split pkgs/id layout; the pkgs/id crate split (#4407/#4408) then moved every file it touches, leaving it CONFLICTING with no rebase path. This PR cherry-picks #7181's five commits and relocates their changes onto current main at the post-split homes:

  • id-groups::blob_gate: decide_with_local (local-reader trust), build_reference_index, hashseq_children; blob_events/blob_events_with_blocks take the local_readers set and compose local trust ahead of membership/block verdicts.
  • id-worlds::blob_gate: FoldedWorlds gains the group-projection membership mode (world_key, fold_group_events, group_projection_member) and RefreshingWorlds.
  • id-cli serve: build_blob_gate (group-log fold + the store's document references, with the bounded HashSeq expansion from the Wire the blob membership gate into id serve (#173) #7181 review), the gated BlobsProtocol wiring with node key + client key as local readers, and the refresh task; LocalNode::set_blob_gate for embedders.
  • id-events: EventStore::document_references + the LocalEvents wrapper.
  • Facade: the new names are re-exported at the historical id::blob_gate paths.

Closes #173. Supersedes #7181 (closed with a salvage note; every file in its diff has a counterpart here — see the file mapping in the closing comment there).

Codex findings from #7181 — disposition

All three findings were fixed in #7181's head fa56e7e7d1 and are carried into this port, re-verified by tests at the ported head:

  • P1 local reads locked out when the gate is enabled → decide_with_local + local readers in serve/LocalNode; covered by a_local_reader_fetches_an_unreferenced_blob_but_a_stranger_cannot and the peer-level tests in tests/blob_gate.rs.
  • P1 design record required before activating authorization wiring → doc/2026-11-13T09-00-00Z_design_blob_gate_authorization_wiring.md, included unchanged.
  • P2 unbounded HashSeq reference-index reads → expansion only for group-referenced blobs, read only when the store status reports a positive multiple-of-32 size ≤ MAX_HASHSEQ_BYTES (1 MiB), in build_blob_gate.

Tests (laptop, this head)

  • cargo check -p id-groups -p id-worlds -p id-events -p id-cli -p id --all-features — pass.
  • cargo test -p id-groups --lib — 118 passed. -p id-worlds --lib — 637 passed. -p id-events --lib — 289 passed. -p id-cli --lib — 671 passed.
  • cargo test -p id --test blob_gate — 16 passed; --test documents — 10 passed; --test content_removal — 12 passed.
  • The three Codex fix behaviors are covered at the ported head: local client-key fetch of an unreferenced blob admitted, remote non-member refused, reference-index build does not read ungrouped blobs (bounded expansion in build_blob_gate + hashseq_children/build_reference_index unit tests).

One note: an early combined test run showed 6 failures in unrelated suites from stale pooled-target binaries (code#8392 pattern); a clean re-run of the identical command was fully green, as were the per-package runs.


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

dezren39 and others added 8 commits November 13, 2026 22:34
The blob gate (blob_gate::decide/blob_events) decided fetches and observes
from a reference index that had no producer, so it was never wired into a
serving path and blobs were served to any peer.

- blob_gate: build_reference_index (with transitive HashSeq children),
  hashseq_children, fold_group_events (group log -> Worlds, world key =
  group create-hash hex), RefreshingWorlds (producer-swappable fold).
- event_store: EventStore::document_references — applied, unremoved
  document.put events as (blob hash, group) pairs; LocalEvents exposes it.
- serve: when the event store is open (web UI), BlobsProtocol runs the
  gate handler (push still decided by the AccessPolicy); a refresh task
  re-folds on the group-warning cadence so removals revoke fetch. Without
  the store, serve keeps push-only handling and warns the gate is inactive.
- local: LocalNode::set_blob_gate lets an embedder supply the gate to
  serve(); default behavior unchanged.
- groups::worlds::Worlds::empty for fail-closed fallbacks.

Tests: blob_gate producer tests (index + HashSeq attribution, group-log
fold gating, refresh revoking a removed member); existing suites pass.
fold_group_events partitioned the group log by world, but
GroupLog::record names the log's global heads as after, so any second
group's events name dependencies living in another partition. fold::index
rejects those partitions with MissingDependency and build_blob_gate
failed the whole gate closed, denying even authorized members.

Keep only intra-partition after edges: ordering inside a world is
preserved and membership reads each world's own projection, so no
authority is lost.

Adds a regression test with two groups where the second create names
the first group's events, as a real group log would.
… design record (#173)

P1 (serve wiring): the gate now trusts the node's own key and the data
directory client key as local readers (decide_with_local), mirroring
build_access_policy — the local CLI/REPL keep reading locally published
(group: None) and uploaded blobs with the gate on; remote peers still
need world membership for every hash.

P2 (reference index build): HashSeq expansion only considers
group-referenced blobs and reads a blob only when the store status
reports it complete with a positive multiple-of-32 size no larger than
MAX_HASHSEQ_BYTES (1 MiB), so index building no longer loads whole
documents into memory to guess at collections.

P1 (docs): dated design record for the authorization wiring —
reference source, HashSeq inference, refresh/revocation timing, local
trust, and the ungated non-web behavior — per pkgs/id AGENTS.md.

Tests: blob_gate lib 19 passed (new decide_with_local unit test),
blob_gate integration 11 passed (new peer-level local-reader test:
local reader fetches an unreferenced blob, stranger refused),
documents 7 passed, content_removal 5 passed; cargo check --features
web passes.
The five shepherd commits were authored against the pre-split pkgs/id
layout. This commit relocates their changes onto current main:

- id-groups::blob_gate: decide_with_local, build_reference_index,
  hashseq_children; blob_events/blob_events_with_blocks take the
  local_readers set and compose local trust ahead of membership.
- id-worlds::blob_gate: FoldedWorlds gains the group-projection
  membership mode (world_key, fold_group_events,
  group_projection_member) and RefreshingWorlds.
- id-cli serve: build_blob_gate + gated BlobsProtocol wiring and the
  refresh task, at the post-split paths; LocalNode::set_blob_gate.
- id-events LocalEvents::document_references wrapper.
- Facade re-exports the new names at the historical id::blob_gate
  paths; the resurrected pre-split serve.rs/local_events.rs are
  removed again.
…e-abuse MetaProtocol construction, pass the resolved groups log path to build_blob_gate
@dezren39
dezren39 requested a review from a team as a code owner November 14, 2026 05:04
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

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

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-14T05:05:02.018734Z
We couldn’t complete this review. Comment @codex review to try again.
af6e057 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

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Nov 14, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 34 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 35f3a966-5526-42aa-b98b-172b248b5019
Commits

Reviewing files that changed from the base of the PR and between 65876ae and af6e057.

Files selected for processing: 12

  • doc/2026-11-13T09-00-00Z_design_blob_gate_authorization_wiring.md
  • pkgs/id/crates/id-cli/src/commands/serve.rs
  • pkgs/id/crates/id-cli/src/local.rs
  • pkgs/id/crates/id-events/src/event_store/documents.rs
  • pkgs/id/crates/id-events/src/local_events.rs
  • pkgs/id/crates/id-groups/src/blob_gate.rs
  • pkgs/id/crates/id-worlds/src/blob_gate.rs
  • pkgs/id/crates/id-worlds/src/groups/worlds.rs
  • pkgs/id/src/blob_gate.rs
  • pkgs/id/tests/blob_gate.rs
  • pkgs/id/tests/content_removal.rs
  • pkgs/id/tests/documents.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@dezren39

Copy link
Copy Markdown
Member Author

🤖 Agent note · task 13492 — closing as superseded by PR #9723 (merged)

While this port was in verification, the parallel shepherd task 5874 lane (repo-worker-tmp-code-b) merged PR #9723, "Port blob gate wiring from #7181 onto the pkgs/id crate split (#173)" — the same port, independently built. Salvage check before closing: every behavior in this PR is present on main via #9723 — decide_with_local, build_reference_index, hashseq_children, fold_group_events, world_key, RefreshingWorlds, LocalNode::set_blob_gate, the bounded MAX_HASHSEQ_BYTES HashSeq expansion, EventStore::document_references, the design record, and the local-reader tests in both the unit and tests/blob_gate.rs suites (all verified by fresh git grep + file mapping against origin/main). The remaining tree differences are presentational (which crate hosts which test, a lib.rs shim vs facade imports). Nothing unique is lost by closing this PR.

This PR's own verification (all green at its head): cargo check --all-features for the five crates; lib suites id-groups 118, id-worlds 637, id-events 289, id-cli 671; integration blob_gate 16, documents 10, content_removal 12.

Codex: the review on this PR failed on Codex usage limits and produced no findings; the three #7181 findings were dispositioned on #7181 and are test-covered on main.

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.

Phase 3: blob gate is not wired into serve, so blobs are still served to any peer

1 participant