Repository navigation
AI chats private by default: seeded personal collection + invariant membership rule - #3158
Conversation
Code Review: PR #3158 — AI chats private by default (closes #1740)Recommendation: COMMENT (would be APPROVE if not self-authored — see note below) This is a self-authored PR (author Requirements Checklist (issue #1740)
ADR-061 §4 and §6/§7 "already shipped" claim: independently verified. FindingsCritical IssuesNone. The core mechanism is architecturally sound and correctly validated against the real eligibility checker, not just its own comments. Suggested Improvements1. [ Every piece of this mechanism is unit-tested in isolation:
But nothing creates a real This matters because the binding mechanism — Recommendation: add one test that creates an 2. [ A crash or error between steps leaves a partially-seeded state. This is explicitly by design and follows the established precedent of
3. [
Nitpicks
Deferral Evaluations (explicit)a. Pro tenant-schema insert-rejection constraint (#3154): Legitimate. Verified NodeSpaceAI/nodespace-cloud#183 exists, is unassigned (correct per backlog convention), and is well-scoped: concrete constraint pattern cited ( b. ADR-061 §8 source_chat_node marker (#3155): Legitimate, and stronger than a typical deferral — it's an architectural improvement (prevention over graceful degradation) that correctly identifies the ADR text describes an unbuilt mechanism. Verified via c. "Teammate cannot read" / sharing (#1735 coverage claim): Legitimate. This is not really a deferral so much as a correct scope boundary: per ADR-037's own Tier Boundary table, RLS enforcement (nearest-boundary walk, break-inheritance, person-only) is explicitly a Pro/cloud concern with no free-tier equivalent, and the walk ( SummaryThe riskiest part of this PR — stamping a random collection id onto a schema field default so an invariant rule's same-graph-scope binding can reach it — is implemented correctly and checked directly against the real The one substantive gap is Improvement #1: no test exercises the mechanism end-to-end against a real, fully-seeded |
malibio
left a comment
There was a problem hiding this comment.
Self-authored PR (author malibio matches the reviewing git identity), so GitHub blocks --approve/--request-changes on this PR. Stating the real verdict explicitly: this is a net positive I would APPROVE. The core mechanism (schema-default-as-binding-target for the invariant Play) is implemented correctly and verified directly against packages/core/src/playbook/validation.rs's real eligibility checks, not just its own doc comments. All three claimed deferrals (#3154, #3155, and the #1735 RLS-coverage claim) check out as legitimate against the actual codebase/ADR text. Test-count adjustments are legitimate, not loosened. One real gap found: no test creates a real ai-chat node end-to-end and asserts the member_of edge actually lands (see full report in the separate PR comment) — recommended as a fast-follow, not a blocker.
…'s non-atomicity Adds two tests that were missing: creating a real ai-chat node actually produces the member_of edge (not just the schema-default property value, which was already covered), and a failed invariant action rolls back the whole chat creation (fail-closed). Both require wiring a PlaybookEngine lifecycle manager and activating the already- seeded privacy play against it — create_test_service alone never activates any play, so invariant dispatch is a no-op without this, which is why the first draft of the positive test silently asserted against an inert path. Also documents the one unrecoverable edge case in seed_personal_ai_chat_collection_if_needed's non-transactional writes: a crash between creating the collection node and writing either the admin edge or the schema default leaves an inert orphan neither repair path can find. Addresses reviewer recommendations from PR #3158's pragmatic-code-review (#3158 (comment)). Skipped: multi-process concurrent first-launch seeding defense (narrow, first-launch-only race; this is a single-process-per-database desktop app) and the i18n nitpick (consistent with existing codebase patterns). Co-Authored-By: Claude Sonnet 5 <[email protected]>
Address-review summaryAddressed the one real gap from the pragmatic-code-review (#3158 (comment)): ✅ Addressed: Missing end-to-end test of the seeded invariant Play's actual effect. Added two tests to
Writing these caught a real bug in my own test setup, not the implementation: ✅ Addressed: Doc acknowledgment of the seed's non-atomicity edge case, added to ⏭️ Skipped: Multi-process concurrent first-launch seeding defense — narrow, first-launch-only race; this is a single-process-per-database desktop app, not a deployment topology where two processes open the same fresh DB concurrently. ⏭️ Skipped: i18n nitpick on the "AI Chats" collection title — consistent with existing codebase patterns (no i18n infrastructure exists yet for any seeded content). Tests: Re-Review DecisionDecision: NO RE-REVIEW NEEDED Rationale: The only change was adding two new tests (135 lines, one file) that exercise an already-implemented code path — no production code changed, no new functionality, no architectural changes. The original review's verdict was already effectively APPROVE with no critical issues; this closes the one identified test-coverage gap using a pattern lifted directly from existing, reviewed test code in the same codebase. Low-risk, additive, straightforward. |
…'s non-atomicity Adds two tests that were missing: creating a real ai-chat node actually produces the member_of edge (not just the schema-default property value, which was already covered), and a failed invariant action rolls back the whole chat creation (fail-closed). Both require wiring a PlaybookEngine lifecycle manager and activating the already- seeded privacy play against it — create_test_service alone never activates any play, so invariant dispatch is a no-op without this, which is why the first draft of the positive test silently asserted against an inert path. Also documents the one unrecoverable edge case in seed_personal_ai_chat_collection_if_needed's non-transactional writes: a crash between creating the collection node and writing either the admin edge or the schema default leaves an inert orphan neither repair path can find. Addresses reviewer recommendations from PR #3158's pragmatic-code-review (#3158 (comment)). Skipped: multi-process concurrent first-launch seeding defense (narrow, first-launch-only race; this is a single-process-per-database desktop app) and the i18n nitpick (consistent with existing codebase patterns). Co-Authored-By: Claude Sonnet 5 <[email protected]>
e0c93c5 to
b89927c
Compare
…'s non-atomicity Adds two tests that were missing: creating a real ai-chat node actually produces the member_of edge (not just the schema-default property value, which was already covered), and a failed invariant action rolls back the whole chat creation (fail-closed). Both require wiring a PlaybookEngine lifecycle manager and activating the already- seeded privacy play against it — create_test_service alone never activates any play, so invariant dispatch is a no-op without this, which is why the first draft of the positive test silently asserted against an inert path. Also documents the one unrecoverable edge case in seed_personal_ai_chat_collection_if_needed's non-transactional writes: a crash between creating the collection node and writing either the admin edge or the schema default leaves an inert orphan neither repair path can find. Addresses reviewer recommendations from PR #3158's pragmatic-code-review (#3158 (comment)). Skipped: multi-process concurrent first-launch seeding defense (narrow, first-launch-only race; this is a single-process-per-database desktop app) and the i18n nitpick (consistent with existing codebase patterns). Co-Authored-By: Claude Sonnet 5 <[email protected]>
b89927c to
9347307
Compare
…'s non-atomicity Adds two tests that were missing: creating a real ai-chat node actually produces the member_of edge (not just the schema-default property value, which was already covered), and a failed invariant action rolls back the whole chat creation (fail-closed). Both require wiring a PlaybookEngine lifecycle manager and activating the already- seeded privacy play against it — create_test_service alone never activates any play, so invariant dispatch is a no-op without this, which is why the first draft of the positive test silently asserted against an inert path. Also documents the one unrecoverable edge case in seed_personal_ai_chat_collection_if_needed's non-transactional writes: a crash between creating the collection node and writing either the admin edge or the schema default leaves an inert orphan neither repair path can find. Addresses reviewer recommendations from PR #3158's pragmatic-code-review (#3158 (comment)). Skipped: multi-process concurrent first-launch seeding defense (narrow, first-launch-only race; this is a single-process-per-database desktop app) and the i18n nitpick (consistent with existing codebase patterns). Co-Authored-By: Claude Sonnet 5 <[email protected]>
9347307 to
86f565a
Compare
…embership rule (closes #1740) Every install now seeds one restricted personal AI-chat collection (random id, admin member_of edge to the local PersonNode), mirroring ADR-037 §6's auto-admin bootstrap pattern. A new seeded invariant Play gives every ai-chat node a member_of edge into that collection in the same transaction that creates it, so a chat is never observable unrestricted (ADR-060, ADR-061 §1/§3). The invariant rule's add_relationship target binds to {trigger.node.personal_collection_id} rather than a literal id, since same-graph-scope eligibility validation rejects literal targets and the collection's id is random per install. The seed step stamps that id onto the ai-chat schema's field default directly (bypassing the user-facing update_schema path), which ordinary schema-default stamping then carries onto every new ai-chat node. ADR-061 §4 (never embed ai-chat) and §6/§7 (localOnly classification, capture.sync removal) were already shipped before this issue; verified rather than re-implemented. §8 (known-but-inaccessible source_chat_node marker) and the Pro tenant-schema insert constraint are out of scope for this repo/PR — tracked in #3155 and #3154 respectively. Co-Authored-By: Claude Sonnet 5 <[email protected]>
Existing collection-listing and core-Play-count assertions were exact counts that predate this change; every fresh install now also seeds one "AI Chats" personal collection and one privacy Play (ADR-061), so those counts grow by one. Also allowlists the new set_ai_chat_personal_collection_default's own-declarations-only .fields mutation in the schema_chain_blindness_guard_test — same shape as handle_update_schema's existing allowlisted entries, not the extends-chain-blindness bug the guard watches for. Co-Authored-By: Claude Sonnet 5 <[email protected]>
…'s non-atomicity Adds two tests that were missing: creating a real ai-chat node actually produces the member_of edge (not just the schema-default property value, which was already covered), and a failed invariant action rolls back the whole chat creation (fail-closed). Both require wiring a PlaybookEngine lifecycle manager and activating the already- seeded privacy play against it — create_test_service alone never activates any play, so invariant dispatch is a no-op without this, which is why the first draft of the positive test silently asserted against an inert path. Also documents the one unrecoverable edge case in seed_personal_ai_chat_collection_if_needed's non-transactional writes: a crash between creating the collection node and writing either the admin edge or the schema default leaves an inert orphan neither repair path can find. Addresses reviewer recommendations from PR #3158's pragmatic-code-review (#3158 (comment)). Skipped: multi-process concurrent first-launch seeding defense (narrow, first-launch-only race; this is a single-process-per-database desktop app) and the i18n nitpick (consistent with existing codebase patterns). Co-Authored-By: Claude Sonnet 5 <[email protected]>
86f565a to
d66257d
Compare
Summary
Implements issue #1740 / ADR-061 §1–§3: every AI chat is private by default, achieved entirely within ADR-037's existing restricted-collection access model.
restrictedToMembers = true, random node id, oneadminmember_ofedge to the local PersonNode) — mirrors ADR-037 §6's auto-admin bootstrap pattern.ai-chatnode amember_ofedge into that collection in the same transaction that creates it (ADR-060), so a chat is never observable unrestricted.add_relationshiptarget binds to{trigger.node.personal_collection_id}rather than a literal collection id — same-graph-scope eligibility validation rejects literal targets, and the collection's id is random per install. The seed step stamps that id onto theai-chatschema's own field default directly (bypassing the user-facingupdate_schemapath, following the same "mutate this schema's own declaration list" pattern already allowlisted forhandle_update_schema).Already shipped before this issue, verified rather than re-implemented:
AiChatNodeBehavior::get_embeddable_content()returnsNoneunconditionally, no ai-chat rows enter the vector index)localOnlyschema classification, PTY capture fields,capture.syncremoval)Out of scope for this repo/PR:
nodespace-cloudrepo, not checked out alongsidenodespace-core. Tracked in NodeSpaceAI/nodespace-cloud#183.source_chat_nodemarker — investigation foundsource_chat_nodedoesn't exist anywhere in the codebase yet (no schema field, no writer, no reader). Rather than build speculative UI with no real call site, the agreed direction is to prevent ai-chat nodes from being reference targets at all (mentions, wikilinks, and any futuresource_chat_node), which supersedes §8 outright. Tracked in Prevent ai-chat nodes from being referenced (mentions, wikilinks, source_chat_node) #3155.user_can_access_node), which applies to anyrestrictedToMemberscollection regardless of node type. No new enforcement needed here; not independently re-tested in this PR since the enforcement mechanism itself isn't in this repo.Test plan
bun run rust:test:lib— 1823/1823 passedbun run rust:test:workspace— 3748/3748 passed (0 unexpected failures; 63 skipped are pre-existing)bun run test(frontend) — 281 files / 5444 tests passed, matches baseline exactly (no frontend changes in this PR)bun run quality:fix— clean, no lint/format changes neededcollection_membership_test.rs×3,parent_task_completion_play_test.rs,services/collection_service.rs)schema_chain_blindness_guard_test.rs/pragmatic-code-review+/address-review— not yet runRelated
🤖 Generated with Claude Code