Repository navigation
feat(dir): apply the policy gate to the peer RPC - #2238
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This was referenced Sep 30, 2026
muscariello
force-pushed
the
feat/policy-peer-gate
branch
from
September 30, 2026 18:09
4dfaeb8 to
4775812
Compare
This was referenced Sep 30, 2026
muscariello
force-pushed
the
feat/policy-peer-gate
branch
from
October 1, 2026 11:20
4775812 to
82ee3ec
Compare
muscariello
force-pushed
the
feat/policy-peer-gate
branch
from
October 1, 2026 15:12
59bac10 to
03c9d6a
Compare
muscariello
force-pushed
the
feat/policy-peer-gate
branch
from
October 1, 2026 15:52
03c9d6a to
991ec80
Compare
muscariello
force-pushed
the
feat/policy-peer-gate
branch
from
October 1, 2026 17:51
991ec80 to
d7eae19
Compare
This was referenced Oct 2, 2026
muscariello
force-pushed
the
feat/policy-peer-gate
branch
from
October 2, 2026 07:34
d7eae19 to
9ff5780
Compare
csirmazbendeguz
previously approved these changes
Oct 2, 2026
muscariello
dismissed
csirmazbendeguz’s stale review
October 2, 2026 12:05
The merge-base changed after approval.
muscariello
force-pushed
the
feat/policy-peer-gate
branch
from
October 2, 2026 12:05
9ff5780 to
8440580
Compare
muscariello
force-pushed
the
feat/policy-peer-gate
branch
from
October 2, 2026 12:33
8440580 to
04c9910
Compare
The libp2p RPC serves Lookup, Pull, ListReferrers and PullReferrer to remote peers straight from the store, with no database access, so a peer could still fetch a record the policy gate excludes. Each handler now checks the record first. As on the API, an excluded record is refused with PermissionDenied (the record is not available under this node's content policy), with no policy name and no reason. The gate answers from the index, so a record this node does not hold is refused the same way. A gate error fails closed. The gate is a required argument of rpc.New, routing.New and newRemote, so the peer RPC cannot be built without it; the server passes its database. types.RecordServabilityAPI names the check, and the store controller's copy of it goes. Closes #2208. Refs #2205 Signed-off-by: Luca Muscariello <[email protected]>
muscariello
force-pushed
the
feat/policy-peer-gate
branch
from
October 2, 2026 12:59
04c9910 to
883442b
Compare
csirmazbendeguz
approved these changes
Oct 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2208 (third and last PR). Part of #2205. Stacked on #2237:
main← #2226 ← #2229 ← #2235 ← #2237 ← this. Based onfeat/policy-pull-gate; retargets as the PRs below it merge.What this adds
The peer RPC (
routing/rpc) servesLookup,Pull,ListReferrersandPullReferrerto remote peers over libp2p, straight from the store and with no database access, so a peer could still fetch a record the policy gate excludes. Each handler now checks the record first.PermissionDenied, the sametypes.RecordExcludedErrorthe API uses, through each handler's existing error wrapping, with no policy name and no reason. The gate answers from the index, so a record this node doesn't hold is refused the same way.Internaland nothing is read from the store.rpc.New,newRemoteandrouting.New;rpc.Newrejects nil. The server passes its database. The routing package's test server passes a gate with no policy enforced.types.RecordServabilityAPInames the check; the store controller's private copy of that interface goes.LookupandPulllog the local peer through the nil-safelocalPeerID(), as the referrer handlers already did.#2208, all together
GetRecords,GetRecordCIDs,CountRecords, catalog entries and count)handleFilterOptionsdistinctColumn,distinctAuthorsStoreServicePull,Lookup,PullReferrer;AIFinderService.ExportAgentIsRecordServableLookup,Pull,ListReferrers,PullReferrerStill outside #2208:
RoutingService.Publishwith an explicit CID announces a record without the gate (announcement, not content; query-based publication is gated),IdentityService.GetIdentityStatusby CID (gated in #2241), and direct registry access, which bypasses the API entirely.Testing
routing/rpchad no tests; it has four now, each over all four handlers: an excluded record is refused withPermissionDenied, where a record the gate lets through but the store lacks still getsNotFound(same CID, excluded vs not in the store), without reading the store for the excluded one; a servable record is served; a gate error fails closed without reading the store;Newrefuses a nil gate.NotFoundagain, failing open, and a nil gate accepted byNeweach make a test fail.server,reconciler,cliandtestsvet clean. Theroutingpackage's own tests (which buildnewTestServer) andserverlink only in CI here — they compile, but can't be linked on this macOS toolchain.