Skip to content

Remove Pro-owned state from core's data model and the sync-only conflict kinds (ADR-083) - #3424

Merged
mstomar125 merged 2 commits into
mainfrom
issue-3412-strip-pro-data-model
Oct 1, 2026
Merged

mstomar125 merged 2 commits into
mainfrom
issue-3412-strip-pro-data-model

Conversation

@mstomar125

@mstomar125 mstomar125 commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Part of #3412

Slice S2 of the one-pass strip: ADR-083's data model in packages/core and the conflict-kind UI. Core keeps the settings singleton, its owner has_role edge and get_local_person; it loses the settings accessors, collection restriction, the AI-chat privacy machinery, the dead node/embedding columns and the two sync-only conflict kinds. Several items reverse work merged under the earlier draft ADRs (#3378, #3382, #3389, #3400); that work is deleted, not adapted.

Acceptance (from the slice plan)

    • Settings node. The database-settings schema declares no sync fields; required_extensions is added by the step-3 issue. DatabaseSettingsNodeBehavior loses its sync checks and default_metadata keys, and seeding writes no sync values. The generic settings accessor (database_settings / merge_database_settings) and any remaining typed sync accessors are deleted. The singleton id stays database-settings-singleton.
    • Restriction. restrictedToMembers is removed from the collection schema, and nothing in core reads or writes it or a member_of permission. embedding_roots.rs treats a non-person descendant holding a member_of edge as the ADR-059 §7 defect without reading restriction, with a test.
    • AI-chat privacy machinery. seed_personal_ai_chat_collection_if_needed, set_ai_chat_personal_collection_default, the personal_collection_id field, the play-core-ai-chat-privacy Play and AI_CHAT_PRIVACY_PLAY_ID are deleted. A test shows a new chat has no member_of edge and can be moved under a page.
    • Dead columns. embedding.origin, idx_emb_modified and node.sync_seq are dropped from db/schema.rs, and row_to_node positions and the embedding write path are updated. Database reset.
    • Conflict kinds. ConflictKind::SupersededEdit and DuplicateReactiveCreate are deleted, with their UI handling.
    • ADR (Replace DatabaseSettingsNode Pro fields and accessors with a generic settings accessor #3378 reversal): delete the following. NodeService::database_settings, merge_database_settings and merge_database_settings_rejecting (node_service/mod.rs ~2126-2183) and their tests (~9191, ~10248-10280). packages/core/tests/it/database_settings_extension_keys_test.rs and its line in tests/it/main.rs. behaviors::database_settings_accepts_namespaced_extension_keys (~5634). The ADR-063 'namespaced keys' comment on the database-settings schema (core_schemas.rs ~1572-1576). The 'tenant role' and merge_database_settings lines in DatabaseSettingsNodeBehavior's doc (behaviors/mod.rs ~2318-2324).
    • ADR (Rewrite the restrictedToMembers and member_of permission comments as storage contracts #3389 reversal): remove the restriction storage-contract comments (core_schemas.rs ~525-543) and every member_of permission write and read, including node_service/mod.rs ~1752-1888 and tests/it/collection_membership_test.rs:451-526. Those tests keep proving that non-order edge data survives, but use a neutral key such as 'note' and a neutral fixture path instead of 'admins-only'.
    • ADR: per ADR-085 §8, KEEP refuse_ai_chat_target and the refusal to retype a node into ai-chat. Reword their docs (crud.rs:45-55, relationship.rs:74-84) and ai_chat_reference_test.rs:157 to cite only the no-reference invariant: no personal collection, privacy Play or privacy membership.
    • ADR: in your files, name no multi-role RBAC, signed-in user, Recovered Items, Pro gating, nodespace-sync, Supabase, RLS or tenant. That covers the get_local_person comments (node_service/mod.rs ~2015-2045); the conflicts UI comments (conflicts-pane.svelte:5, conflicts.svelte.ts:53, conflict-indicator-badge.svelte:9-10); conflicts.test.ts:1-6; playbook_engine_integration_test.rs ~397 and ~443 ('nodespaced-pro' catch-up comments: describe a bulk_create batch generically); playbook_invariant_integration_test.rs (Supabase/RLS comment); nodespace-types/src/schema.rs:13 and :571 (switch the derive_friendly_name example to another camelCase field).

What changed

  • Schema DDL (db/schema.rs): node.sync_seq and embedding.origin dropped; idx_emb_modified was already gone from the DDL. row_to_node reads created_at/modified_at at 7/8. The embedding INSERTs already listed their columns without origin, so the write path needed no further change.
  • Files outside the slice's ownership list. Each edit is forced by this PR's own changes:
    • db/sqlite_store/relationships.rs, get_related_nodes_with_edges: it reads r.properties after n.* by position, so dropping a node column moves it from index 10 to 9. One-line index fix plus its doc (item 4).
    • services/mod.rs (NodeAccessor::access_boundaries_under doc) and models/embedding.rs (module doc): doc-only. Both described the removed "access differs" rule, so after item 2 they contradicted the code (review finding).
  • Settings node: accessors, their helper first_core_declared_key and their tests deleted. Behaviour and schema docs now name only the owner edge.
  • Restriction / embedding roots: the collection schema declares no fields. embedding_roots.rs no longer walks restriction (access_boundary, restricted_among and restricted_collection_sql are gone). Any topmost non-person descendant holding a member_of edge is the defect: it is excluded from its root's aggregate and is its own embedding root. embedding_root_id resolves to the nearest such node at or above the node. Public names (access_boundaries_under, embedding_root_id) are unchanged, so no caller outside the slice changes.
  • AI-chat privacy machinery: the seeding call and both functions, the Play, its id and all its tests are deleted. The refuse_ai_chat_target and retype docs now cite ADR-061 §8 only.
  • Conflict kinds: ConflictKind is UniqueFieldCollision | CollectionNameCollision. The reconcile match arm, the doc table, the proto comment, the TS union and the pane's label map are updated. The pane's merge/adopt guard only existed to exclude the two retired kinds, so it is now just nodeIds.length === 2.
  • Wording (item 11): get_local_person comments, conflicts UI comments, store test header, both catch-up comments, and the derive_friendly_name example (estimatedHours). playbook_invariant_integration_test.rs has no Supabase/RLS comment on current main; its one nodespace-sync mention is reworded instead.

Two tests kept but retargeted, so a real guarantee keeps its coverage:

  • scalar_field_type_validation_test::core_schema_scalar_fields_are_enforced now uses task.due_date, since the collection schema has no scalar field left.
  • core_plays::tests::integration::re_seeding_keeps_an_existing_plays_edits now uses the parent-task Play. "Seeding never overwrites a user's edits to a core Play" was only tested through the privacy Play.

No daemon or CLI integration test asserted the old seeded-collection or Play counts, so none changed.

New and changed tests, with mutation checks

Each mutation was applied alone, the named tests run, and the file reverted. Every one fails the test.

Test Mutation Result
(1) schema_test::a_fresh_database_has_no_unused_node_or_embedding_columns (needles built from fragments) re-add the node sequence column / re-add the embedding provenance column / re-add the provenance index killed ×3
(1) sqlite_store::tests::test_row_to_node_round_trips_every_node_column re-add the node sequence column without moving positions / swap the created_at and modified_at reads killed ×2
(2) node_service::tests::test_a_new_ai_chat_has_no_member_of_edge_and_moves_under_a_page (activates every seeded Play, as the app does) restore the deleted privacy seeding + Play from origin/main (fails on the member_of assertion: the chat lands in "AI Chats") / make move_node refuse an ai-chat gaining a parent killed ×2
(3) access_boundary_descendant_is_excluded_and_rerooted_adr059, access_boundary_shapes_agree_across_exclusion_and_rerooting_adr059 drop the person exclusion / re-introduce a restriction read on the collection / resolve to the topmost filed ancestor instead of the nearest killed ×3
(3) shape (d'): a filed node below a filed person (added in review) the subtree walk's stop predicate ignores the person exemption killed
(4) test_seed_database_settings_singleton_with_owner_edge (singleton stores {"database-settings": {}}; get_local_person resolves the seeded owner) seed a sync value onto the singleton / get_local_person returns None killed ×2
(5) conflicts.test.ts › conflict kinds (pane renders one record of each kind) narrow merge/adopt back to one kind / show Rename for every kind / drop the collection-name label killed ×3
(5) conflicts.test.ts › ConflictKind is exactly the two kinds (expectTypeOf, enforced by svelte-check) add a third kind to the union svelte-check error
conflict::tests::conflict_kind_parses_only_locally_detected_kinds (fragment needles) map a retired wire name back to a kind killed
core_schemas::tests::test_simple_schemas_have_no_fields (+collection) give collection a field again killed
Seeded counts: resolve_path_is_idempotent_no_duplicate_collections, test_get_all_collections_with_counts_returns_parent_ids, reopening_a_database_does_not_duplicate_the_play the restored privacy machinery (row 3) killed
re_seeding_keeps_an_existing_plays_edits seeding overwrites an existing Play's properties killed
core_schema_scalar_fields_are_enforced disable the date type check killed
test_add_to_collection_preserves_non_order_edge_data, test_add_to_collection_computed_order_overwrites_caller_order (neutral note key) add_to_collection drops the caller's non-order keys killed ×2

Pro-boundary ratchet

bun run scripts/check-pro-boundary.ts passes. --changed reports 0 for every marker in every changed file.

Before is origin/main at 4ca90c2; after is this branch rebased on it.

marker before after
proSyncModule 367 366
editionBranching 6 4
cloudWording 13 12
tenantWording 232 229
proWording 137 136
all others unchanged unchanged

BASELINES is not edited.

Database reset: REQUIRED

The table shape changes (node.sync_seq and embedding.origin are dropped), so every dev database must be reset after this merges. The shape check refuses an existing one until it is. No migration.

Left for later slices

  • add-synced-database-dialog.svelte and its test still write restrictedToMembers (S4 deletes them).
  • required_extensions on database-settings (S6). test_database_settings_schema_declares_no_fields will need its expectation updated then.
  • "Grantee"/"grant" wording on the person exemption in db/sqlite_store/nodes.rs ~2833-2836 and db/sqlite_store/relationships.rs ~505-506 (ADR-037's access model is Pro's under ADR-083 §5).
  • A possible rename of access_boundaries_under and the *_adr059 test names to "filed descendants". This touches services/mod.rs, embedding_service.rs and behaviors/mod.rs across slices.
  • "Chats are private" wording in files outside this slice: db/sqlite_store/relationships.rs ~1526/1576 (bulk mention skip), db/sqlite_store/search.rs:16, schema/mod.rs:398/413 (including the user-visible error text) and schema/schema_test.rs:2771. The refusals themselves stand under ADR-061 §8; only the rationale wording names privacy.

🤖 Generated with Claude Code

@mstomar125

Copy link
Copy Markdown
Contributor Author

Automated pragmatic-code-review (medium depth): APPROVE

Review Type: Initial Review. Head 2b859adb, read-only review against ADR-083 §2–§7, ADR-085 §6/§8, ADR-059 §2/§7, ADR-061 §8 and core CLAUDE.md.

Requirements Check

  1. ✅ Settings node. The database-settings schema has no fields, validate is a no-op and seeding writes {}. The accessors and first_core_declared_key are deleted with no remaining callers. The id database-settings-singleton is kept.
  2. ✅ Restriction. The collection schema has fields: vec![]. No "permission" read or write remains. embedding_roots.rs treats any non-person member_of holder as the defect, with tests.
  3. ✅ AI-chat privacy machinery. Both functions, the Play, AI_CHAT_PRIVACY_PLAY_ID and personal_collection_id are gone. The new test activates every seeded Play, then checks no member_of edge and a move under a page.
  4. ✅ Dead columns. sync_seq and origin are dropped. idx_emb_modified was already absent. row_to_node reads 7/8, and the embedding INSERT/SELECT list columns explicitly. The DB-reset note is present.
  5. ✅ Conflict kinds. Removed from the enum, as_str/FromStr, the reconcile arm, the doc table, the proto comment, the TS union and the pane labels.
  6. ✅ Replace DatabaseSettingsNode Pro fields and accessors with a generic settings accessor #3378 reversal. Complete.
  7. ✅ Delete the dead embedding push/pull seam; keep embedding.origin for existing databases #3382 reversal. Complete. A fragment-built absence test also pins the exact node column order.
  8. ✅ Rewrite the restrictedToMembers and member_of permission comments as storage contracts #3389 reversal. Complete. The edge-data tests use note/kept and the fixture path annotated.
  9. ✅ Reword the AI-chat privacy Play text without tenant wording #3400 reversal. Complete. The counts are exact.
  10. ✅ The ai-chat refusals are kept, and their docs cite only ADR-061 §8.
  11. ✅ The slice grep returns 0 hits, and git grep -nwP origin on schema.rs returns 0.

Column-position audit. All 24 row_to_node call sites use SELECT * or SELECT n.* with no trailing columns. The only exception is get_related_nodes_with_edges, fixed here (index 9). There is no node-row SQL in daemon, cli, agent or app-lib. Nothing was missed.

embedding_roots consistency. access_boundaries_under and embedding_root_id share one predicate. The first returns the topmost filed descendants, the second resolves to the nearest filed node at or above a node. So an excluded node always resolves to a root whose vector includes it, and nested boundaries chain correctly. The person exemption matches assert_may_gain_parent.

Findings

🟡 Important: contract docs still describe the removed "access differs" rule
📁 packages/core/src/services/node_service/embedding.rs:21-23, packages/core/src/services/mod.rs:62-64 (NodeAccessor::access_boundaries_under), packages/core/src/models/embedding.rs:10-11

All three say the exception is "a descendant whose access differs from its root's". The code no longer compares access, and a descendant filed into its root's own collection is now a boundary. These are the contract docs callers read, so they now contradict the implementation. Reword them to "a non-person descendant holding a member_of edge (ADR-059 §7, ADR-083 §5)".

🟢 Suggestion: test gap, filed node beneath a filed person
📁 packages/core/src/services/node_service/mod.rs shape (d)

The walk continues through a person only because the stop predicate also exempts persons, and no test covers that. Simplifying stop to a plain member_of EXISTS would survive every current test, while letting a filed node's text into its root's vector. Add a filed text under the filed person, and assert boundaries(r) == {n} and root_of(n) == n.

🟢 Suggestion: grant/grantee wording on the person exemption
📁 packages/core/src/db/sqlite_store/mod.rs:1590 (also nodes.rs:2833-2836 and relationships.rs:505-506, outside the slice)

ADR-083 §5 makes ADR-037's access model Pro's. Word it the way embedding_roots.rs does.

🟢 Nit: access_boundaries_under and the *_adr059 test names keep "access boundary" naming. A rename to filed_descendants_under is a follow-up, since it touches other slices' files.

🟢 Nit: embedding_roots.rs:5-6 should say "every non-person node".

🟢 Nit: relationships.rs:1893-1909 reads the trailing column at a fixed index after n.*. The exact-column-list test guards this indirectly; reading the last column or listing the node columns explicitly would harden it.

Branch freshness: one commit behind origin/main (#3423), with no common files. Rebase before merge.

Recommendation: APPROVE. Make the 🟡 doc fix and add the person-chain test before merge. The change clearly improves code health.

@mstomar125 mstomar125 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated pragmatic-code-review: APPROVE (posted as a comment, since GitHub blocks self-approval). Full findings are in the review comment above.

@mstomar125
mstomar125 force-pushed the issue-3412-strip-pro-data-model branch from 2b859ad to 9087494 Compare October 1, 2026 10:33
@mstomar125

Copy link
Copy Markdown
Contributor Author

Address-review

Commit 9087494f. The branch is also rebased onto origin/main at 4ca90c2 (#3423 and #3422 landed), with no conflicts.

✅ Addressed (4)

  • 🟡 Contract docs still described "access differs". All three are reworded to "a non-person descendant holding a member_of edge (ADR-059 §7, ADR-083 §5)": services/node_service/embedding.rs (in the slice), and services/mod.rs (NodeAccessor::access_boundaries_under) and models/embedding.rs (outside the slice, doc-only, now named in the PR body).
  • 🟢 Person-chain test gap. Shape (d') adds a filed text below the filed person. It asserts boundaries(r) == {note}, root_of(note) == note and root_of(person) == r. Mutation check: making the walk's stop predicate a plain member_of EXISTS (ignoring the person exemption) fails access_boundary_shapes_agree_across_exclusion_and_rerooting_adr059.
  • 🟢 Grantee wording in sqlite_store/mod.rs is reworded to match embedding_roots.rs.
  • 🟢 Nit: embedding_roots.rs module doc now says "every non-person node".

⏭️ Skipped (2)

  • Rename of access_boundaries_under and the *_adr059 tests. It touches services/mod.rs, embedding_service.rs and behaviors/mod.rs across slices for a name-only gain; it is listed under "Left for later slices".
  • Reading the trailing column dynamically in get_related_nodes_with_edges. schema_test::a_fresh_database_has_no_unused_node_or_embedding_columns pins the exact node column list and order, so a column change fails that test before it can misplace this read. A further edit to relationships.rs is out of the slice's scope.

Noted for later slices: the grant wording in nodes.rs ~2833-2836 and relationships.rs ~505-506 (in the PR body).

Checks after the changes and the rebase

  • cargo fmt; the ADR-059 tests pass (4/4).
  • bun run quality:fix is clean: clippy -D warnings across the workspace, and svelte-check reports 0 errors in 2475 files.
  • bun run test:changed passes: frontend, scripts, Chromium and the Rust workspace.
  • The slice verification grep returns 0, and check-pro-boundary.ts passes.

Re-Review Decision

Decision: NO RE-REVIEW NEEDED

Rationale: the changes are doc comments plus one added test case. No product logic changed. The added case is mutation-checked.

mstomar125 and others added 2 commits October 1, 2026 12:39
…ict kinds

Drop the node sequence and embedding provenance columns from the DDL and
shift row_to_node and the related-nodes-with-edges read to the new
positions. Delete the database-settings accessors, the AI-chat personal
collection seeding, its schema-default stamping and its Play. Remove the
collection restriction field; embedding roots now split on any non-person
descendant holding a member_of edge. Delete ConflictKind::SupersededEdit
and DuplicateReactiveCreate and their handling in the Conflicts view.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… node under a filed person

Reword the embedding-root contract docs that still described an access
comparison, drop the grant wording on the person exemption, and extend the
boundary-shapes test with a filed node below a filed person.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@mstomar125
mstomar125 force-pushed the issue-3412-strip-pro-data-model branch from 9087494 to e722ef4 Compare October 1, 2026 10:39
@mstomar125
mstomar125 merged commit 7f321ee into main Oct 1, 2026
@mstomar125
mstomar125 deleted the issue-3412-strip-pro-data-model branch October 1, 2026 10:39
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.

1 participant