Repository navigation
Description
Summary
Rename two identifiers so they say what they do:
SYNC_SERVICE_CLIENT_IDbecomesREPLICATED_APPLY_CLIENT_ID. It is the reservedsource_client_idfor replicated writes.is_sync_originatedbecomesis_replicated_apply. It is the engine gate that reads that constant.
The constant's value stays "sync-service", byte for byte. There is no gate.
Context
What the constant does. pub const SYNC_SERVICE_CLIENT_ID: &str = "sync-service" lives in packages/core/src/db/events.rs (~276-285). Two consumers compare against it, so that a write applied from another device never fires local rules:
- the playbook engine's local-origin gate (ADR-073);
- invariant dispatch.
Why the value stays. nodespace-sync never imports core's constant. It tags replicated writes with its own nodespace_sync::echo::SYNC_SERVICE_CLIENT_ID (src/echo.rs) and with about 25 with_client("sync-service") literals.
- Renaming the identifier is invisible to sync.
- Changing the value would silently re-enable plays and invariants on replicated writes after sync's next pin bump, with no compile error.
- The value is the analogue of a stored name, and ADR-083 rule 5 keeps names that are already in use.
Why rename at all. ADR-083 rule 2 (proposed) says core's hooks are named for what they do, not for who calls them. The draft ADR's inventory does not list this constant yet. Either the ADR-083 PR adds a row ("identifier renamed, value kept"), or this issue is closed as not planned and #3367 rewords the docs instead.
References at af8ddb61:
packages/core/src/playbook/engine.rs:- the gate comment (~455-472);
- the call and its debug message (~473-477);
is_sync_originatedand its doc (~1512-1526).
packages/core/src/services/node_service/invariants.rs: ~87, ~157, ~215.packages/daemon/src/services/assembly.rs: a comment that namesis_sync_originated(~404-410).packages/core/src/playbook/tests.rs: the threeis_sync_originated_*tests (~1787-1856).packages/core/src/services/node_service/mod.rs:batch_keeps_writes_from_different_origins_apartandbatch_flushes_the_newest_write_last_across_origins(~8920-8975).packages/core/tests/it/bulk_invariant_dispatch_test.rs: 12, 377, 825.packages/core/tests/it/playbook_engine_integration_test.rs: 28, 297, 301, 340, 403, 446, 491.packages/core/tests/it/playbook_invariant_integration_test.rs: 18, 25, 419, 448, 507, 564, 2638, 2706, 2757, 2771, 3343, 3556.
Scope
- Every reference above: identifiers, imports, and any prose that names either identifier.
- Two rewritten docs:
- The constant. "Reserved
source_client_idfor writes applied from another device, per ADR-027's origin-tagging convention. Consumers that must not treat such a write as a fresh local mutation (the playbook engine's local-origin gate, ADR-073, and invariant dispatch) compare against this constant. The value is a stable tag that writers outside core set as a literal. Changing it would make those writes fire local rules again." is_replicated_apply. Keep the denylist rationale. If Rename the origin-filtered event channel to subscribe_to_events_excluding_origin #3338 has merged, use its names (passes_origin_filter,excluded_event_origin); otherwise keep the current ones.
- The constant. "Reserved
- The debug message "Skipping trigger evaluation for sync-originated event" becomes "... for replicated-apply event".
- Test names:
is_sync_originated_*becomesis_replicated_apply_*.
Out of scope
- The value
"sync-service". - Product and repository names in the surrounding prose, such as "
nodespace-sync's real apply path" or "nodespaced-pro's catch-up path" in the integration-test comments. Sweep the Pro and sync wording C7 leaves around replicated writes and AI-chat privacy #3367 owns those. "Sync" may stay as the ADR-060/ADR-073 term for a write from another device. remote-update-policy.tsand its test (Sweep the Pro and sync wording C7 leaves around replicated writes and AI-chat privacy #3367).
Steps
- Start up. Follow core
CLAUDE.md's startup sequence:EnterWorktree({name: "issue-<N>-replicated-origin-name"});bun install;- the
bun run testbaseline; gh:assign, thengh:status.
- Rename the constant and the function, and update every reference listed under Context.
- Rewrite the two docs, the debug message and the
assembly.rscomment. - Grep:
git grep -n -E 'SYNC_SERVICE_CLIENT_ID|is_sync_originated' -- packagesprints nothing;git grep -n 'REPLICATED_APPLY_CLIENT_ID: &str' -- packages/core/src/db/events.rsshows the value"sync-service".
- Ratchet. Run
bun run scripts/check-pro-boundary.tsand setBASELINESto the printed counts. - Finish:
bun run test:changed, thenbun run quality:fix, then commit;- push to
issue-<N>-replicated-origin-name; gh pr create --repo NodeSpaceAI/nodespace-core --base main --head issue-<N>-replicated-origin-name, thengh:status "In Review";- after approval, run
bun run merge <PR#>in the background.
Acceptance criteria
- Both step 3 greps give the expected output.
- The value is unchanged. Add
replicated_apply_client_id_value_is_stableto thedb/events.rstests: it assertsREPLICATED_APPLY_CLIENT_ID == "sync-service", with a comment that writers outside core tag this literal. - Replicated-apply writes still skip reactive and invariant rules. The renamed ADR-073 gate tests pass, including the test that the match is exact rather than a substring match.
-
bun run scripts/check-pro-boundary.tsexits 0, andBASELINESequals its printed counts. - Core builds, all tests pass, and plays in the free app still fire on local edits.
Tests and verification
bun run test:changed.tools/bin/cargo-nextest nextest run -p nodespace-core --lib playbook::tests.tools/bin/cargo-nextest nextest run -p nodespace-core --lib batch_.tools/bin/cargo-nextest nextest run -p nodespace-core --test it playbook_invariant_integration_test::.tools/bin/cargo-nextest nextest run -p nodespace-core --test it playbook_engine_integration_test::.tools/bin/cargo-nextest nextest run -p nodespace-core --test it bulk_invariant_dispatch_test::cargo clippy -p nodespace-core -p nodespace-daemon --all-targets -- -D warnings -D clippy::unused-async
Dependencies
- NodeSpaceAI/nodespace-docs#92 (ADR-083) (ADR-083, proposed): rule 2, and ideally an inventory row for this constant.
- Add the Pro-boundary ratchet check and the CLAUDE.md Pro/sync placement rule #3299: the ratchet.
- No gate: sync never names core's constant, and the value does not change.
Risks and rollback
- Changing the value would be the dangerous part, and it is out of scope. If it is ever wanted, it first needs a real sync-first gate: sync must tag every replicated write with core's exported constant instead of literals. Sync can do that against its current pin, because the constant exists at
680c35d8. - Conflict with Rename the origin-filtered event channel to subscribe_to_events_excluding_origin #3338 on the
is_sync_originateddoc: rebase, and keep Rename the origin-filtered event channel to subscribe_to_events_excluding_origin #3338's names. - Rollback: revert the PR.
Plan key: C7.3a (pro-boundary DAG).
🤖 Generated with Claude Code
Activity
Rename the replicated-apply origin constant and engine gate to neutra…