Skip to content

Describe batch-write, event and collision docs without naming the sync daemon - #3408

Merged
mstomar125 merged 2 commits into
mainfrom
issue-3364-batch-api-docs
Oct 1, 2026
Merged

mstomar125 merged 2 commits into
mainfrom
issue-3364-batch-api-docs

Conversation

@mstomar125

Copy link
Copy Markdown
Contributor

Summary

Rewords core's batch-write, event-emission and collection-collision docs so they describe the contract instead of the sync code that happens to call them (ADR-081). Comments and docs only, plus one test-function rename and one assertion message. No behaviour, signature or public-name change.

Event emission

  • DOMAIN_EVENT_CHANNEL_CAPACITY (node_service/mod.rs): a subscriber doing slow per-event work (for example, forwarding each member_of edge over the network) lags and drops edges when a burst exceeds the buffer. The 128 → 4096 sizing history is kept.
  • bulk_add_to_collections_notify (relationship.rs): the raw store insert emits nothing, so without this no subscriber learns of the edges (other windows, CLI watchers, a host that mirrors changes). Its chunk-yield comment said the channel was "bounded (128 slots)"; it is bounded by DOMAIN_EVENT_CHANNEL_CAPACITY (4096).
  • The NodeService.event_tx field doc said "128 subscriber capacity"; it now says the channel buffers DOMAIN_EVENT_CHANNEL_CAPACITY events.
  • The import-service call site (import_service.rs) says the event reaches every subscriber, not "PUSHES to cloud".
  • Test bulk_add_to_collections_notify_emits_push_events is renamed to bulk_add_to_collections_notify_emits_relationship_events; its doc, assertion message ("so it pushes to cloud" dropped) and "no spurious re-emit" comment follow. The burst test's doc says "drop edges for a lagging subscriber".

Batch-write APIs and bulk store paths

  • bulk_create_has_child_edges (hierarchy.rs), bulk_create_has_child, assert_root_only_membership (sqlite_store/relationships.rs), assert_may_gain_parent (sqlite_store/nodes.rs), the bulk-path parity test comments (sqlite_store/mod.rs), the has_child writer list (schema.rs, the Rust comment outside SCHEMA_SQL), the two bulk.rs title comments and the bulk_create / bulk_update title test docs (node_service/mod.rs) now say "the bulk path", "a batched caller applying writes made elsewhere" or "a from-scratch batch".
  • Misplaced doc moved. The bulk_add_to_collections doc sat on top of collection_typed_ids, where rustdoc merged it into that function's doc. It now sits directly above pub async fn bulk_add_to_collections, reworded: it emits no events, and callers whose writes must reach event subscribers use NodeService::bulk_add_to_collections_notify.
  • scheduler_grants_immediately_when_no_active_database (embedding_processor.rs): "the single-database path is unaffected".
  • reverse_relationship_name_test.rs: "The bulk attach path (bulk_create_has_child_edges)."

Local-first collision rule (ADR-065, ADR-068)

  • create_node's collision comment (sqlite_store/nodes.rs) states the rule itself: two offline devices can each validly create the same name, and a hard rejection would propagate out of any caller applying another device's writes through create_node, stalling it permanently on a benign duplicate. The marker-write comment drops the mark_possible_duplicate provenance.
  • collection_membership_test.rs, collection_name_convergence_test.rs and person_duplicate_convergence_test.rs restate the same rule ("replicated apply", "a replicated rename — an apply whose node already exists locally") without naming a sync function, repository or cursor contract.

Leftovers from #3363's sweep that fall under event docs (included at the coordinator's direction)

  • event-types.ts (NodeEventData.databaseId) and database.svelte.ts (isActiveDatabaseEvent, which said "single-database / Pro daemon"): the empty database_id now reads "the serving impl was not opened through the registry", matching the NodeEvent.database_id comment in node_service.proto that Describe core's access gate and daemon seams without naming the Pro daemon #3363 settled.
  • tauri-sync-listener.ts and its test header named a DomainEventForwarder that no longer exists. They now describe the real path: the desktop watcher (app-lib/src/watcher.rs) opens the daemon's WatchNodes stream and forwards each event as a Tauri event.

Deviations from the issue

  • BASELINES is not lowered, per the coordinator's standing rule for the Pro-boundary epic (parallel PRs collide on those lines; Drive every Pro-boundary ratchet count to zero and make the check a hard ban #3371 tightens everything). The ratchet exits 0 with no count raised. This overrides the issue's acceptance criterion about lowering it.
  • The issue's expected leftovers from the vocabulary grep (the get_multi_membership_edges doc, the embedding test in sqlite_store/mod.rs, the SQL comments in schema.rs, the push-channel docs and subtree_access_gate in node_service/mod.rs) are already gone on main through sibling PRs, so the grep now prints nothing.
  • bulk_create_has_child's "safe for a from-scratch sweep" became "from-scratch batch", to match the reworded bulk_create_has_child_edges doc.
  • The NodeService.event_tx field doc ("128 subscriber capacity") wasn't listed in the issue, but the acceptance criterion forbids any other comment saying the event channel holds 128, so it's fixed here.
  • Describe core's access gate and daemon seams without naming the Pro daemon #3363 (Describe the access gate and daemon seams without naming the Pro daemon #3401) had already merged when this branched, so the node_service/mod.rs edits sit on top of its wording. crud.rs needed no change for this issue.

Ratchet delta

bun run scripts/check-pro-boundary.ts, origin/main (066fac4) vs this branch (tenantWording and every other marker unchanged):

marker before after
cloudWording 50 41 (-9)
editionBranching 96 95 (-1)
proWording 243 242 (-1)

No count rises, so no baseline edit is needed and none of the three CLAUDE.md "may add Pro lines" classes applies.

Verification

  • Vocabulary grep from the issue, over every listed file: prints nothing.
  • Comment-only: git diff -U0 origin/main...HEAD | grep '^[+-]' | grep -v '^[+-][+-]' | grep -vE '^[+-]\s*(//|\*|/\*\*|\*/)' prints only the test-function rename and the assertion message string.
  • No stale 128: no comment says the domain-event channel holds 128, apart from the DOMAIN_EVENT_CHANNEL_CAPACITY sizing history and the 128 → 4096 burst test. The store module's own private DOMAIN_EVENT_CHANNEL_CAPACITY = 128 constant (sqlite_store/mod.rs) is code, so it's out of scope here.
  • Moved doc: rustdoc renders SqliteStore::bulk_add_to_collections with the new doc, and its link resolves to NodeService#method.bulk_add_to_collections_notify. In the source, collection_typed_ids carries only its own three lines.
  • rustdoc: the issue's RUSTDOCFLAGS='-D rustdoc::broken_intra_doc_links' cargo doc -p nodespace-core --no-deps --no-default-features fails to compile on main: ops/context_ops.rs imports NodeEmbeddingService, which that feature set configures out. Run with default features, -D rustdoc::broken_intra_doc_links reports pre-existing broken links on main in files this PR doesn't touch (schema_node.rs, rel_ops.rs, playbook/validation.rs, extends_chain.rs, schema/mod.rs, query_service/mod.rs, markdown/mod.rs, connections.rs). None is on a changed line, and no diagnostic mentions the moved doc's link.
  • cargo fmt -p nodespace-core -p nodespace-daemon --check: clean.
  • cargo clippy -p nodespace-core -p nodespace-daemon --all-targets -- -D warnings -D clippy::unused-async: clean.
  • bun run --cwd packages/desktop-app quality:fix: 0 errors, 0 warnings, no file changes.
  • bun run scripts/check-code-references.ts: 71 / 71 issue references, 0 doc-path references (unchanged).
  • bun run test:changed: frontend, scripts, browser and Rust tiers pass. Nextest ran 4147 tests with 4147 passing, including bulk_add_to_collections_notify_emits_relationship_events, bulk_membership_burst_does_not_overflow_the_event_channel, test_bulk_root_only_membership_is_enforced, the collection-name and person-duplicate convergence tests, and no_write_path_leaves_the_reverse_name_unpopulated.
  • No test is added. The only test change is a rename, so there is nothing to mutation-test.
  • Describe core's person, AI-chat and access-walk docs without Pro, tenant or cloud wording #3407 (Reword core data-model and identity docs that cite Pro, Supabase, RLS or tenants #3365) also edits node_service/mod.rs, but its hunks (around lines 1644, 1991 and 9675) don't overlap this PR's, so either merge order applies cleanly.

Closes #3364

🤖 Generated with Claude Code

@mstomar125

Copy link
Copy Markdown
Contributor Author

Pragmatic code review (medium)

Review Type: Initial Review. Run on the branch's first commit before the PR was opened (now c9c098ef after the rebase onto 066fac40).

Requirements Check (core#3364)

  • ✅ The issue's vocabulary grep prints nothing on this branch. The Move Pro-owned data out of core's data model (ADR-083) #3345-owned leftovers it expected are already gone on main.
  • ✅ bulk_add_to_collections has its own doc, directly above pub async fn bulk_add_to_collections. collection_typed_ids carries only its own doc.
  • ✅ No comment says the domain-event channel holds 128, apart from the sizing-history sentence and the 128 → 4096 burst test. The event_tx field doc ("128 subscriber capacity") is fixed too.
  • ✅ Comment-only: the only non-comment changes are the test rename and the assertion message string.
  • ✅ No #NNNN references and no product or repository names added.
  • ✅ The old test name emits_push_events is referenced nowhere.
  • ⚠️ BASELINES is not lowered, by the coordinator's override. That's safe: check-pro-boundary.ts only prints a notice when a count is below its ceiling.

Accuracy checks against the code (all confirmed)

  • create_relationship emits DomainEvent::RelationshipCreated on its member_of and has_child paths, so "the exact same event path" holds.
  • DOMAIN_EVENT_CHANNEL_CAPACITY (node_service) is 4096 and sizes both event_tx and origin_filtered_event_tx. EMIT_CHUNK = 50 stays well under it.
  • crate::services::NodeService is re-exported, so the moved doc's intra-doc link resolves.
  • The frontend database_id wording matches the NodeEvent.database_id comment in node_service.proto and watcher.rs.
  • watcher.rs opens WatchNodes and forwards each event via emit_routed. DomainEventForwarder exists nowhere.

Code Review Findings: no Critical or Important issues.

  • 🟢 Nit: 📁 packages/core/src/services/node_service/relationship.rs:1980-1982. "far more member_of edges than that" now refers to a 4096-event buffer, which overstates a realistic burst. "more than the buffer holds" reads more honestly. Principle: comments stay proportionate to the code they describe.
  • 🟢 Nit: 📁 packages/core/src/db/sqlite_store/mod.rs:30 (outside the diff). The store has its own private DOMAIN_EVENT_CHANNEL_CAPACITY = 128 for a vestigial event_tx, so a grep for the name finds both. Module scoping resolves each comment to the node_service constant. Out of scope for a docs PR.
  • 🟢 Nit: 📁 collection_name_convergence_test.rs:129-133, person_duplicate_convergence_test.rs:132-136. The new "(replicated apply)" headings sit next to the existing generic "sync pull" wording. That's the allowed ADR-060 term, so this is optional.
  • 🟢 Nit: 📁 packages/core/src/services/node_service/bulk.rs:~180. One reflowed comment line runs long.
  • 🟢 Nit: 📁 packages/core/src/services/node_service/hierarchy.rs:1047-1056. "genuinely-unparented" appears twice; the second is the pre-existing sentence the issue said to keep.

Recommendation: APPROVE

@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). The full findings are in the review comment above: no Critical or Important issues, 5 nits.

@mstomar125

Copy link
Copy Markdown
Contributor Author

Address review

Commit 4ec84bbf (comment-only).

✅ Addressed (2)

  • relationship.rs: "far more member_of edges than that" becomes "more member_of edges than the buffer holds".
  • bulk.rs: reflowed the long comment line.

⏭️ Skipped (3)

  • The store's private DOMAIN_EVENT_CHANNEL_CAPACITY = 128 constant: renaming or removing it is a code change, and this issue is comment-only. The comments that name the constant sit in node_service, where it resolves to the 4096 one. A follow-up could revisit it when the store's vestigial event_tx is cleaned up.
  • The generic "sync pull" / "sync-pulled" wording in the convergence tests: this is the ADR-060 term the epic's wording guide allows, and those lines aren't in the issue's scope.
  • The repeated "genuinely-unparented" in the bulk_create_has_child_edges doc: the second occurrence is the pre-existing sentence the issue said to keep.

Tests: bun run test:changed passes on the final tree: frontend, scripts, browser and Rust tiers, with nextest at 4147/4147. Clippy and fmt are clean for nodespace-core and nodespace-daemon.

Re-Review Decision

Decision: NO RE-REVIEW NEEDED

Rationale: The review had no Critical or Important findings. The two changes are comment wording and a reflow, with no logic, signature or test change.

mstomar125 and others added 2 commits October 1, 2026 09:29
…c daemon

Reword the docs of bulk_add_to_collections_notify, DOMAIN_EVENT_CHANNEL_CAPACITY,
bulk_create_has_child_edges, the store's bulk member_of/has_child paths and
their guards, and the local-first collection-collision rule so they state the
contract (every event subscriber must see each new membership; any caller
applying another device's writes through create_node must not stall on a
benign duplicate) instead of naming one sync implementation's functions.

Move the bulk_add_to_collections doc off collection_typed_ids, where rustdoc
merged the two, onto the function it documents. Replace the stale "128 slots"
and "128 subscriber capacity" channel comments with
DOMAIN_EVENT_CHANNEL_CAPACITY. Rename the notify test to
bulk_add_to_collections_notify_emits_relationship_events.

Align the frontend's empty database_id event docs with the proto convention,
and point the Tauri sync listener's header at the watcher's WatchNodes stream
instead of the removed DomainEventForwarder.

Comments, docs and one test-function name only; no behaviour change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- relationship.rs: "far more edges than that" overstated the burst against a
  4096-event buffer; say "more edges than the buffer holds".
- bulk.rs: reflow a long comment line.

Skipped: renaming the store's own private DOMAIN_EVENT_CHANNEL_CAPACITY (128)
constant is a code change outside this comment-only issue; the generic "sync
pull" wording is the allowed ADR-060 term; the hierarchy doc's repeated
"genuinely-unparented" is the pre-existing sentence the issue said to keep.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@mstomar125
mstomar125 force-pushed the issue-3364-batch-api-docs branch from 4ec84bb to 2e8bf08 Compare October 1, 2026 07:30
@mstomar125
mstomar125 merged commit cb778ae into main Oct 1, 2026
@mstomar125
mstomar125 deleted the issue-3364-batch-api-docs branch October 1, 2026 07:30
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.

Reword core's batch-write, event and collision docs without naming the sync daemon

1 participant