Skip to content

Give the replicated-apply origin constant and engine gate neutral names, value unchanged - #3396

Merged
mstomar125 merged 2 commits into
mainfrom
issue-3339-replicated-origin-name
Sep 30, 2026
Merged

mstomar125 merged 2 commits into
mainfrom
issue-3339-replicated-origin-name

Conversation

@mstomar125

Copy link
Copy Markdown
Contributor

Closes #3339

Summary

Gives the replicated-apply origin constant and its engine gate names that say what they do, per ADR-083 rule 2 (proposed):

  • SYNC_SERVICE_CLIENT_ID becomes REPLICATED_APPLY_CLIENT_ID.
  • is_sync_originated becomes is_replicated_apply.

The constant's value stays "sync-service", byte for byte. Writers outside core tag replicated writes with that literal, so changing it would silently re-enable plays and invariants on replicated writes with no compile error. A new test pins it.

Part of the Pro/core boundary epic (#3298). Implemented ahead of the ADR-083 PR, as authorized.

Changes

  • db/events.rs: rename the constant and rewrite its doc as a storage contract (stable tag, set as a literal by writers outside core, changing it makes replicated writes fire local rules again). New test replicated_apply_client_id_value_is_stable.
  • playbook/engine.rs: rename the gate, rewrite its doc (denylist rationale kept, built on the names Rename the origin-filtered event channel to subscribe_to_events_excluding_origin #3394 introduced), gate comment, and the skip debug message ("... for replicated-apply event").
  • node_service/invariants.rs (3 gates), node_service/mod.rs (2 batch tests), the three integration test files, and the assembly.rs comment: identifier renames only.
  • playbook/tests.rs: the three is_sync_originated_* tests become is_replicated_apply_*. The first drops the now-misleading sync_client_id from its name (..._true_for_reserved_client_id).

Not touched (out of scope per the issue): the value, product and repository names in prose such as "nodespace-sync's real apply path", and the integration tests' own function names (sync_originated_*), which are not the renamed identifiers.

Callers

git grep -n -E 'SYNC_SERVICE_CLIENT_ID|is_sync_originated' -- packages now prints nothing, and REPLICATED_APPLY_CLIENT_ID: &str in db/events.rs still shows "sync-service".

External callers: none found. I checked nodespace-sync at origin/main and on every remote branch, plus nodespace-cloud, nodespace-website, homebrew-nodespace and nodespace-docs. nodespace-sync never imports core's constant or gate. It defines its own nodespace_sync::echo::SYNC_SERVICE_CLIENT_ID = "sync-service" and about 25 "sync-service" literals, and pins core at 680c35d8. So the rename is invisible to it, and it does not break at its next pin bump. No other open PR or local branch adds a use of the old names.

Ratchet

bun run scripts/check-pro-boundary.ts exits 0. The printed counts are identical before and after this change (neither identifier matches a marker), so the delta is 0 for every marker. BASELINES is untouched, per the standing instruction not to lower ceilings in parallel PRs. This deviates from the issue's step 4 ("set BASELINES to the printed counts"), which the instruction supersedes. No Pro lines are added.

Tests and mutation checks

Every test in the issue's verification list passes on the rebased tree, and cargo clippy -p nodespace-core -p nodespace-daemon --all-targets -- -D warnings -D clippy::unused-async is clean. bun run test:changed passed (scripts tier and the Rust workspace nextest run).

Each mutation was applied to product code, the targeted tests were run, and the change was reverted:

Mutation Result
Constant value changed to "replicated-apply" only replicated_apply_client_id_value_is_stable fails; the gate tests and the integration tests still pass because they use the constant on both sides
Gate uses contains() instead of an exact match is_replicated_apply_is_an_exact_match_not_a_substring_check fails
Gate always false is_replicated_apply_true_for_reserved_client_id fails
Gate always true is_replicated_apply_false_for_local_client_ids_and_none and the exact-match test fail

Risks

Only the identifier changes, so the wire and stored value is unchanged. Rollback is a revert.

🤖 Generated with Claude Code

@mstomar125

Copy link
Copy Markdown
Contributor Author

Review Type: Initial Review

Requirements Check (core#3339, verified against commit a19e04d by reading the diff and grepping the branch; I did not run builds or tests, per instructions)

  • [PASS] Step 3 grep 1: git grep -n -i -E 'SYNC_SERVICE_CLIENT_ID|is_sync_originated' on the branch returns nothing, across all file types (Rust, TS, scripts, proto, md). The only case-insensitive near-misses are unrelated CloudSyncService/browserSyncService names.
  • [PASS] Step 3 grep 2 / value unchanged: packages/core/src/db/events.rs:285 is pub const REPLICATED_APPLY_CLIENT_ID: &str = "sync-service";. The literal "sync-service" appears in core code exactly once (the constant), plus the pinning test. There is no duplicate or shadow definition. The other two textual hits are prose in remote-update-policy.ts and its test, which are out of scope (owned by a separate issue).
  • [PASS] replicated_apply_client_id_value_is_stable (events.rs:401-406) exists, is assert_eq!(REPLICATED_APPLY_CLIENT_ID, "sync-service") against a literal (not tautological, so it fails on any value change), and carries the required comment that writers outside core tag this literal.
  • [PASS] Gate behavior is unchanged. is_replicated_apply (engine.rs:1524) is still an exact == Some(...) comparison (only rustfmt re-wrapped). All three invariant early-returns (invariants.rs:87, 157, 215) compare against the renamed constant with no other change. The debug message is the only string change (engine.rs:476); nothing in the repo matches on the old text. The three is_replicated_apply_* tests are renamed, including the exact-match-not-substring test.
  • [PASS] The rewritten constant doc matches the wording the issue prescribes word for word (only line wrapping differs). The gate doc keeps the denylist rationale and refers to passes_origin_filter / excluded_event_origin. Both names exist in node_service/mod.rs (lines 671, 697, 1347), so the reference is accurate.
  • [PASS] No #NNNN issue numbers or issues/ links in any added line. No Pro, tenant, Supabase, or nodespaced wording added. The literal "sync"/"sync-service" only appears as the stable tag and ADR term, which is acceptable.
  • [PASS, deviation accepted] BASELINES not edited. I checked independently that no removed or added line matches any MARKERS pattern in scripts/check-pro-boundary.ts (union grep over both sides of the diff returns nothing), so the ratchet delta is genuinely 0 and there is nothing to tighten. Current core CLAUDE.md also says baselines are ceilings and that parallel removal PRs never have to edit them, so the standing instruction is consistent with the repo's rules. The issue's step 4 was written for an older model of the ratchet. I accept this deviation. The acceptance line "BASELINES equals its printed counts" is a property of main's state, not something this PR can worsen.
  • [PASS, by author evidence] Core builds and plays still fire on local edits. I did not re-run anything. The author's runs (clippy with -D warnings -D clippy::unused-async, test:changed, nextest for playbook::tests, batch_, and the three it modules) cover the criterion, and the four reported mutations map to real tests. play_fires_end_to_end_for_local_mutation is in the passing 12. Note: gh pr checks reports no CI checks on the branch, so the only test evidence is the author's local runs.

Cross-repo caller check (claim 3): confirmed. In nodespace-sync at origin/main, SYNC_SERVICE_CLIENT_ID appears only as nodespace_sync::echo::SYNC_SERVICE_CLIENT_ID (src/echo.rs:59 and its users). Nothing imports nodespace_core::db::events::SYNC_SERVICE_CLIENT_ID, and nothing references is_sync_originated. I scanned every remote branch of sync for nodespace_core::playbook, is_sync_originated, or a core-events import of the constant and found no hit. It pins core at 680c35d8, which predates this rename, so it is unaffected. nodespace-cloud, nodespace-website, docs and homebrew-nodespace have no references.

Deliberate decisions:

  1. BASELINES untouched: sound (above).
  2. Integration-test function names and prose left alone: sound. The issue puts product and repo names in that prose out of scope and allows "sync" as the ADR-060/073 term for a write from another device.
  3. Author's "no external caller" claim: verified independently (above).
  4. The mutation table is credible. The value-mutation row correctly notes that the gate and integration tests still pass because they use the constant on both sides, which is exactly why the pin test is needed.

Also checked: origin/main is one commit ahead of this branch's base (9d93d24, settings extension points). It shares no files with this diff, so no conflict is expected.

Code Review Findings

Critical / Blocker: None

Improvements: None

Nits (optional polish, none block merge):

  • Nit: packages/core/src/playbook/engine.rs:611 reads "event is the just-applied replicated-apply event". "Replicated-apply event" is the wording the issue prescribes for the debug message, but as a noun phrase in prose it is clumsy. "just-applied replicated write" or "replicated event" would read better.
  • Nit: packages/core/src/playbook/engine.rs:462-472 (gate comment) now says "replicated-apply path" and then a few lines later "sync backlog" / "sync-replayed event". This is permitted (sync is the ADR term), just mixed vocabulary within one comment block.
  • Nit: packages/core/tests/it/playbook_engine_integration_test.rs:403-404 now reads "is_replicated_apply (correctly) does NOT treat as sync-originated", which mixes old and new terms in one sentence. It is out of scope per the issue and the author left it deliberately, so this is only a note for the later prose pass.
  • Nit: the PR description says "on the rebased tree", but the branch base is one commit behind current origin/main (no overlapping files, so harmless). A final rebase before bun run merge will pick it up.

Recommendation: APPROVE

The change is a faithful identifier-only rename. The value is byte-identical and pinned by a non-tautological test. All old-identifier references are gone across all file types. Gate semantics are unchanged (exact match, all three invariant early-returns updated). The docs match the issue's prescribed wording. The description's claims hold up: I verified the callers, grep, and ratchet-delta claims directly and found no overclaim. The BASELINES deviation is justified and accepted.

@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 verdict: APPROVE, 0 critical, 0 improvements, 4 nits.

Addressed (1 of 4)

  • Nit, packages/core/src/playbook/engine.rs:611: "the just-applied replicated-apply event" read clumsily as prose. Reworded to "the event of a just-applied replicated write". Commit 49ac254. Doc comment only: the commit changes zero non-comment lines; cargo fmt --check, cargo clippy -p nodespace-core --lib -- -D warnings -D clippy::unused-async, and the Pro-boundary ratchet are clean.

Skipped (3 of 4), with reasons

  • Mixed "replicated-apply" / "sync backlog" / "sync-replayed" wording in the gate comment (engine.rs:462-472): the issue explicitly keeps "sync" as the ADR-060/ADR-073 term for a write from another device, and "sync backlog" / "sync-replayed" describe what the sync path actually does. Rewording further would grow the diff past the identifier rename. Revisit in the separate prose pass.
  • playbook_engine_integration_test.rs:403-404 still says "sync-originated" next to is_replicated_apply: integration-test prose is out of scope per the issue (owned by the separate prose/docs issue). Revisit there.
  • Branch is one commit behind origin/main: that commit touches none of this PR's files (checked), and bun run merge stacks the PR onto current main before its gate. Not rebased here, to avoid a force-push that would invalidate the verification already run on this tree.

Tests are unchanged by this round (no code change), so the earlier results stand: test:changed passed, the five verification commands from the issue pass (playbook::tests 65, batch_ 18, the three it modules 45 / 12 / 14), clippy is clean for nodespace-core and nodespace-daemon, and all four mutations were caught by the intended test.

Re-Review Decision

Decision: NO RE-REVIEW NEEDED

Rationale: The only change since the review is one reworded doc-comment line (zero non-comment lines changed, no logic, no test, no rename touched). The reviewer approved with no blocking or improvement findings.

🤖 Generated with Claude Code

mstomar125 and others added 2 commits September 30, 2026 14:25
…l names (closes #3339)

SYNC_SERVICE_CLIENT_ID becomes REPLICATED_APPLY_CLIENT_ID and
is_sync_originated becomes is_replicated_apply, so the names say what they
do (a write applied from another device) instead of who calls them.

The constant's value stays "sync-service": writers outside core tag
replicated writes with that literal, so changing it would silently
re-enable plays and invariants on replicated writes. A new test in
db/events.rs pins the value.

Also renames the three is_sync_originated_* unit tests, rewords the
constant's and the gate's docs and the skip debug message, and updates
every caller in core's src, its integration tests and the daemon's
assembly comment.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Reads better as prose than "replicated-apply event"; doc comment only.

The other review nits are left as is: "sync" stays as the ADR-060/073
term for a write from another device, and the integration tests' prose
belongs to the separate prose pass.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@mstomar125
mstomar125 force-pushed the issue-3339-replicated-origin-name branch from 49ac254 to fdcfbb5 Compare September 30, 2026 12:25
@mstomar125
mstomar125 merged commit ea4bfd8 into main Sep 30, 2026
@mstomar125
mstomar125 deleted the issue-3339-replicated-origin-name branch September 30, 2026 12:25
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.

Give the replicated-apply origin constant and engine gate neutral names, value unchanged

1 participant