Repository navigation
Closed
Labels
pro-boundaryPro/core boundary: Pro code moves to nodespace-sync (ADR-081..085)
Description
Summary
Replace SqliteStore::get_multi_membership_edges with SqliteStore::member_of_edges(min_memberships, exclude_member_types), as ADR-083 §4 recommends (proposed; decision 5-B).
After the change, the query describes only the graph. The Pro membership sweep's policy moves to the caller: the threshold of 2 and the exclusion of person members.
Context
- The query lives in
packages/core/src/db/sqlite_store/relationships.rs: doc ~924-937, function ~938-963.- It returns
(member_id, collection_id)for everymember_ofedge whose member has more than onemember_ofedge and is not aperson. - Its doc talks about the "atomic cloud node insert", the "cloud-sync membership sweep" and "server-side RBAC".
- It returns
- Its only test is
get_multi_membership_edges_only_multi_membership_nodesinpackages/core/src/services/collection_service.rs(~1199-1245). Thepersonexclusion is untested. - Its only production caller is
nodespaced-pro/src/cloud_sync/orchestrator.rs~1941 (sync17f9557).- Sync cannot run the SQL itself, because
SqliteStore::read()ispub(crate). - The query stays in core because it reads core's tables.
- The change lands in core first. At its pin bump, sync calls
member_of_edges(2, &["person"]).
- Sync cannot run the SQL itself, because
Scope
relationships.rs: the method and its doc.collection_service.rs: the existing test and its doc, plus two new tests.
Out of scope
- The rest of the collection and membership API.
- Sync's sweep.
Steps
- Start up. Follow core
CLAUDE.md's startup sequence:EnterWorktree({name: "issue-<N>-member-of-edges"});bun install;- the
bun run testbaseline; gh:assign, thengh:status.
- Replace the method with
pub async fn member_of_edges(&self, min_memberships: usize, exclude_member_types: &[&str]) -> Result<Vec<(String, String)>>:- Keep the
GROUP BY in_node HAVING COUNT(*) >= ?1subquery, bound tomin_memberships.max(1). - When the slice is non-empty, add
AND n.node_type NOT IN (?2, …)with one placeholder per type. - Keep the error context neutral, e.g. "Failed to read member_of edges".
- Keep the
- Doc. "Every
member_ofedge, as(member_id, collection_id), whose member node has at leastmin_membershipsmember_ofedges and whosenode_typeis not inexclude_member_types. Amin_membershipsbelow 1 behaves as 1; an unknown type excludes nothing." Name no caller. - Tests in
collection_service.rs. Compare edges as sets, because the order is unspecified.- Rename the existing test to
member_of_edges_with_threshold_two_skips_single_memberships. Callmember_of_edges(2, &[]), and rewrite its doc in graph terms. - Add
member_of_edges_excludes_listed_member_types. Add the local person (get_local_person) to two collections:- with
(2, &[]), the person's edges appear; - with
(2, &["person"]), they are absent, while a content node's edges remain.
- with
- Add
member_of_edges_threshold_below_one_behaves_as_one.(0, &[])and(1, &[])return the same set, and it includes a single-membership node's edge.
- Rename the existing test to
- Grep.
git grep -n get_multi_membership_edges -- packagesprints nothing. - Ratchet. Run
bun run scripts/check-pro-boundary.ts, and setBASELINESto the printed counts.cloudSyncHooksdrops. - Finish:
- run
bun run test:changed, thenbun run quality:fix, then commit; - push to
issue-<N>-member-of-edges; - open the PR with
gh pr create --repo NodeSpaceAI/nodespace-core --base main --head issue-<N>-member-of-edges, then setgh:status "In Review"; - after approval, run
bun run merge <PR#>in the background.
- run
Acceptance criteria
- The step 4 grep prints nothing.
- No core doc or identifier here mentions cloud, push, a sweep or RBAC.
- All three tests pass.
-
member_of_edges(2, &["person"])returns the same result asget_multi_membership_edgesdid. -
bun run scripts/check-pro-boundary.tsexits 0, andBASELINESequals its printed counts. - Core builds, all tests pass, and the free app's collections are unchanged.
Tests and verification
bun run test:changed.tools/bin/cargo-nextest nextest run -p nodespace-core --lib member_of_edgescargo clippy -p nodespace-core --all-targets -- -D warnings -D clippy::unused-async- Mutation checks:
- drop the exclusion clause, and the exclusion test fails;
- hard-code
> 1, and the threshold test fails.
Dependencies
- NodeSpaceAI/nodespace-docs#92 (ADR-083) (ADR-083, proposed): decision 5-B.
- Add the Pro-boundary ratchet check and the CLAUDE.md Pro/sync placement rule #3299: the ratchet.
- No gate (ADR-083 §7 item 3).
- Sync note (not filed yet): sync switches its one call site at its next pin bump.
Risks and rollback
- Dynamic placeholders. A numbering error fails loudly in the tests.
- Rollback. Revert the PR.
Plan key: C7.7 (pro-boundary DAG).
🤖 Generated with Claude Code
Metadata
Metadata
Assignees
Labels
pro-boundaryPro/core boundary: Pro code moves to nodespace-sync (ADR-081..085)
Activity
mstomar125 commentedon Sep 30, 2026
Completed in #3383 (merged). Auto-close did not fire; closing manually.