Skip to content

Rename the origin-filtered event channel to subscribe_to_events_excluding_origin - #3394

Merged
mstomar125 merged 2 commits into
mainfrom
issue-3338-event-channel-names
Sep 30, 2026
Merged

mstomar125 merged 2 commits into
mainfrom
issue-3338-event-channel-names

Conversation

@mstomar125

Copy link
Copy Markdown
Contributor

Closes #3338

Part of the Pro/core boundary epic (#3298): renames the origin-filtered mirror of the domain-event channel for what it does, per ADR-083 §4 (proposed, decision 4-A). Behaviour is unchanged.

Renames

Old New
subscribe_for_push subscribe_to_events_excluding_origin
set_push_excluded_origin set_excluded_event_origin
NodeService.push_event_tx origin_filtered_event_tx
NodeService.push_excluded_origin, BatchEmitGuard.push_excluded_origin excluded_event_origin
BatchEmitGuard.push_tx filtered_tx
push_forward_allowed passes_origin_filter
flush_envelopes params push_tx / push_excluded_origin, local push_excluded_origin_ref filtered_tx / excluded_origin / excluded_origin_ref
tests push_channel_* origin_filtered_channel_*

The names occur only in packages/core/src/services/node_service/mod.rs and the is_sync_originated doc in packages/core/src/playbook/engine.rs. A repo-wide grep found no other caller; the only external one was the Pro daemon in nodespace-sync, which stops compiling until its next pin bump renames two call sites (accepted).

Docs and tests

  • Docs on everything in the table no longer name a consumer or say "push" / "cold pull". The create_node_streaming fixed-source caveat is kept, and now also appears on the public subscribe_to_events_excluding_origin doc.
  • Tests use a test-local const EXCLUDED_ORIGIN: &str = "bulk-apply" instead of the "sync-service" literal, in both the setter calls and with_client(..). Assertion messages, locals and the block header no longer say "push", "sync" or "UI".
  • Two test doc comments claimed the tests reach the "store-notifier path" and the "emit_event path". Mutation runs (below) show they reach neither, so those parentheticals were dropped rather than carried over.

Deviations from the issue text

Ratchet

bun run scripts/check-pro-boundary.ts exits 0. Counts are identical to origin/main (no count rises or falls from this change). cloudSyncHooks already sits at 0 against a baseline of 4 on main; left for #3371.

Verification

  • git grep -n -E 'subscribe_for_push|set_push_excluded_origin|push_event_tx|push_excluded_origin|push_forward_allowed|push_channel_' -- packages prints nothing.
  • cargo fmt -p nodespace-core --check: clean.
  • cargo clippy -p nodespace-core --all-targets -- -D warnings -D clippy::unused-async: clean.
  • nextest run -p nodespace-core --lib origin_filtered_channel create_parent_edge_reparent: the four origin_filtered_channel_* tests and create_parent_edge_reparent_emits_former_parent_delete pass.
  • bun run test:changed: passed (scripts tier and the full Rust workspace nextest run).

Mutation check

No test was added, but the renamed tests were mutation-checked so a rename cannot have quietly weakened them. Each mutation was applied to node_service/mod.rs, the five tests run, then the file restored:

Mutation Tests that fail
passes_origin_filter always true ..._node_events, ..._relationship_events, ..._batched_flush, create_parent_edge_reparent_emits_former_parent_delete
passes_origin_filter always false ..._mirrors_main_when_no_origin_excluded, ..._node_events
set_excluded_event_origin a no-op ..._node_events, ..._relationship_events, ..._batched_flush, create_parent_edge_reparent_emits_former_parent_delete
BatchEmitGuard::drop ignores the configured origin ..._batched_flush (only)
store-notifier flush in NodeService::new ignores the configured origin none
emit_event flush ignores the configured origin none

The last two are an existing coverage gap, not something this rename introduced: node and relationship writes in these tests publish through the transaction-commit flush, so the notifier and emit_event flush sites have no test that an excluded origin is withheld. The rename does not touch their logic (and the compiler checks their arguments, since the sender and lock types differ). Flagging it as a possible follow-up rather than growing a pure-rename PR.

🤖 Generated with Claude Code

@mstomar125

Copy link
Copy Markdown
Contributor Author

Automated pragmatic-code-review (initial review, medium): APPROVE

Code Review Summary

A clean, mechanical rename with accurate docs. I read every hunk of the two-file diff (packages/core/src/services/node_service/mod.rs, packages/core/src/playbook/engine.rs) against origin/main and found no behaviour change. There are 0 blocking issues, 1 non-blocking follow-up suggestion and 1 nit.

What I checked and how:

  • Completeness. git grep -n -i -E 'subscribe_for_push|push_excluded|push_event_tx|push_forward|push_channel|push_tx|push_rx|push_ids|set_push_excluded' over the whole tracked tree prints nothing. A plain grep -r over packages/, scripts/, .claude/agents, .claude/skills, README.md, CLAUDE.md and docs/ is also empty, so there are no untracked or non-Rust stragglers. The only remaining old-name callers anywhere are the two Pro daemon call sites in sync/nodespaced-pro/src/cloud_sync/orchestrator.rs (lines 107, 111 and 324), which is the accepted signal for its next pin bump. The remaining "push" and "sync" hits in mod.rs are unrelated: Vec::push, and the DOMAIN_EVENT_CHANNEL_CAPACITY and member_of test docs the brief marks as out of scope. In the seam's docs and tests (lines 655-700, 805-825, 1325-1350, 1514-1525, 2836-2875, 3005-3020, 8040-8320) the only remaining consumer-shaped word is the generic "a consumer whose buffer...", which is the wording the issue itself prescribes.
  • Behaviour unchanged.
    • The four flush_envelopes call sites keep the same argument order (tx, then the filtered sender, then the lock): BatchEmitGuard::drop (mod.rs:712-717), publish_committed (1016-1021), the store-notifier closure in NodeService::new (1589) and emit_event (3041-3047). tx and filtered_tx have the same type, so a swap would have compiled. I checked each one, and none is swapped.
    • The struct literals in NodeService::new (1608-1609), the Clone impl (1469-1470) and begin_batch_emit (3014-3015) map the old field to the matching new one.
    • Locals in the notifier block (filtered_tx, excluded_origin_ref, 1536-1537) do not shadow anything.
    • passes_origin_filter (671-680) has an identical body, flush_envelopes (813-826) an identical send order (filtered mirror first, then main), and the setter and subscriber bodies are identical apart from the identifiers.
    • SYNC_SERVICE_CLIENT_ID and is_sync_originated are untouched, which matches Give the replicated-apply origin constant and engine gate neutral names, value unchanged #3339's ownership.
  • Ratchet. bun run scripts/check-pro-boundary.ts exits 0 ("No count is above its baseline"). scripts/check-pro-boundary.ts is intentionally not in the diff, per the epic's standing decision not to touch BASELINES.

Findings

Critical Issues

None.

Suggested Improvements

  1. [Improvement, non-blocking, follow-up only] Coverage gap at two flush sites (pre-existing). The store-notifier flush in NodeService::new (mod.rs:1589) and the emit_event flush (3041-3047) have no test that an excluded origin is withheld. The author's mutation table shows this honestly. It does not block a pure rename: the sites are unchanged in logic, and the compiler checks their argument types. Node and relationship writes go through publish_committed, whose wiring the always-true, always-false and setter-no-op mutations do exercise. I would file a small follow-up issue (a test writing outside a transaction, e.g. via a store-level write, and one through emit_event) rather than grow this PR.

Nitpicks

  1. Nit: create_node_streaming is a SqliteStore method, not a NodeService one. The caveat is true. packages/core/src/db/sqlite_store/nodes.rs:3740 stamps source: Some("streaming_import".to_string()), and the notifier forwards change.source as source_client_id (mod.rs:1575). But the new public doc on subscribe_to_events_excluding_origin (mod.rs:2852-2855) says only create_node_streaming. A reader of the NodeService API cannot find it. SqliteStore::create_node_streaming would be unambiguous, in that doc and in the one at mod.rs:667-669. The method also has no callers in the workspace, so this is purely a readability point.

Doc accuracy (verified against the code)

  • "shared by every clone of this service" (2865): true. Clone (mod.rs:1470) clones the Arc<RwLock<..>>, and with_client clones through Clone. The Pro daemon's orchestrator.rs:107-111 relies on the same behaviour.
  • "With no origin set it behaves like subscribe_to_events" (2850): true. passes_origin_filter returns true when the lock holds None, so the mirror carries every event.
  • create_node_streaming fixed-source caveat: true, see nit 1.
  • Field docs (1330-1347) and the BatchEmitGuard field docs (694-697) are accurate. The "unset until configured via set_excluded_event_origin" comment (1518-1520) is accurate.

Test quality

  • The renamed tests still assert what their names and docs claim. Locals were renamed consistently (main_rx, filtered_rx, excluded_id, bulk). The test-local EXCLUDED_ORIGIN const is used in both the setter calls and with_client(..), so the "excluded origin" match the tests depend on is still exercised.
  • The two dropped parentheticals ("store-notifier path", "emit_event path") were inaccurate. Writes made through a NodeService with with_transaction publish via publish_committed. The mutation table in the PR body supports removing them, and the current doc comments are now accurate.
  • The mutation results in the PR body are consistent with my reading of the code paths.

Requirements Check (issue #3338)

  • Step 4 grep prints nothing (re-run over the whole tree).
  • Renamed tests keep the assertions: node, relationship and batched-flush events withheld, and the channel mirrors the main one when no origin is set. The author reports a passing nextest run.
  • No doc or identifier on this seam names a consumer, or says "push" or "sync".
  • check-pro-boundary.ts exits 0. The BASELINES edit is intentionally skipped, per the epic's standing decision.
  • Pure rename and no functional change. No dead-code allows, shims or aliases. No #NNNN references in comments. packages/agent untouched.
  • Names match ADR-083 section 4 (decision 4-A): subscribe_to_events_excluding_origin and set_excluded_event_origin. The ADR-082 catalog row and ADR-083 row 8 still show the old names, but both already say the rename is recommended, so no inconsistency arises from this PR.

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, GitHub blocks self-approval). Full findings in the review comment above.

@mstomar125

Copy link
Copy Markdown
Contributor Author

Address-review summary (round 1)

Review: APPROVE, 0 Critical, 1 Improvement, 1 Nit.

Addressed (1)

  • Nit: create_node_streaming is a SqliteStore method, not a NodeService one, so the unqualified name in the docs was ambiguous. Both mentions (the pre-existing caveat on passes_origin_filter and the sentence added on subscribe_to_events_excluding_origin) now read SqliteStore::create_node_streaming. Comment-only change, one line-wrap; no identifiers or logic touched. Commit: Qualify create_node_streaming as a SqliteStore method in the filter docs.

Skipped (1)

  • Improvement: no test that an excluded origin is withheld at the store-notifier flush in NodeService::new or the emit_event flush. Skipped as scope creep for a pure rename: the gap predates this PR, neither site's logic changes here, and the compiler checks their arguments (the sender and lock types differ, so an argument swap would not build). It is called out in the PR body's mutation table. Worth revisiting as a small follow-up that writes outside a transaction and goes through emit_event; not filed from here.

Checks after the fix: cargo fmt -p nodespace-core --check clean; bun run test:changed re-run on the final head 5397f8f0 and passed (scripts tier and the full Rust workspace nextest run).

Re-Review Decision

Decision: NO RE-REVIEW NEEDED

Rationale: the only change since the reviewed commit is a comment wording fix (two doc comments), with no code, identifier or test change. The reviewer's behaviour, completeness and doc-accuracy checks are unaffected.

mstomar125 and others added 2 commits September 30, 2026 14:01
subscribe_for_push becomes subscribe_to_events_excluding_origin and
set_push_excluded_origin becomes set_excluded_event_origin. The fields,
the batch-guard members, the filter predicate and the flush helper's
parameters follow (origin_filtered_event_tx, excluded_event_origin,
filtered_tx, passes_origin_filter). Behaviour is unchanged.

The docs on the renamed items no longer name a consumer or describe the
channel as "push". The tests use a test-local excluded origin instead of
the sync client id, and the playbook engine's reference to the filter
uses the new names.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
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.

Rename the origin-filtered event channel to subscribe_to_events_excluding_origin

1 participant