Skip to content

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

Closed

Description

@mstomar125

Summary

Rename two identifiers so they say what they do:

  • SYNC_SERVICE_CLIENT_ID becomes REPLICATED_APPLY_CLIENT_ID. It is the reserved source_client_id for replicated writes.
  • is_sync_originated becomes is_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_originated and its doc (~1512-1526).
  • packages/core/src/services/node_service/invariants.rs: ~87, ~157, ~215.
  • packages/daemon/src/services/assembly.rs: a comment that names is_sync_originated (~404-410).
  • packages/core/src/playbook/tests.rs: the three is_sync_originated_* tests (~1787-1856).
  • packages/core/src/services/node_service/mod.rs: batch_keeps_writes_from_different_origins_apart and batch_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_id for 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 debug message "Skipping trigger evaluation for sync-originated event" becomes "... for replicated-apply event".
  • Test names: is_sync_originated_* becomes is_replicated_apply_*.

Out of scope

Steps

  1. Start up. Follow core CLAUDE.md's startup sequence:
    • EnterWorktree({name: "issue-<N>-replicated-origin-name"});
    • bun install;
    • the bun run test baseline;
    • gh:assign, then gh:status.
  2. Rename the constant and the function, and update every reference listed under Context.
  3. Rewrite the two docs, the debug message and the assembly.rs comment.
  4. Grep:
    • git grep -n -E 'SYNC_SERVICE_CLIENT_ID|is_sync_originated' -- packages prints nothing;
    • git grep -n 'REPLICATED_APPLY_CLIENT_ID: &str' -- packages/core/src/db/events.rs shows the value "sync-service".
  5. Ratchet. Run bun run scripts/check-pro-boundary.ts and set BASELINES to the printed counts.
  6. Finish:
    • bun run test:changed, then bun 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, then gh: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_stable to the db/events.rs tests: it asserts REPLICATED_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.ts exits 0, and BASELINES equals 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

Risks and rollback


Plan key: C7.3a (pro-boundary DAG).

🤖 Generated with Claude Code

Activity

  1. self-assigned this
    on Sep 30, 2026
  2. added
    pro-boundary
    on Sep 30, 2026
  3. added a commit that references this issue on Sep 30, 2026
    679cd66
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

pro-boundary

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions