Skip to content

Add a typed in-process write context and reserved client ids (refs #3435) - #3752

Merged
mstomar125 merged 3 commits into
mainfrom
issue-3435-trusted-write-context
Oct 12, 2026
Merged

mstomar125 merged 3 commits into
mainfrom
issue-3435-trusted-write-context

Conversation

@mstomar125

Copy link
Copy Markdown
Contributor

Refs #3435. Phase 1 of 2: additive. Phase 2 (a separate PR, held until Sync has moved to the typed context) deletes REPLICATED_APPLY_CLIENT_ID and is_replicated_apply; only then does #3435 close.

What changes

Core: a typed, in-process write context.

  • nodespace_core::WriteContext { skip_playbook_triggers: bool, skip_invariant_rules: bool } (also nodespace_core::db::WriteContext). It is named by what it does. The default is an ordinary write.
  • NodeService::with_write_context(ctx) -> NodeService is the only way to set it, alongside write_context(). with_client keeps the context and with_write_context keeps the client id. No request field or header reaches it.
  • The context travels with every event a write emits on every path: in-transaction writes, bulk writes, relationship writes, and the store's own notifications (unchecked and version-bump updates, every delete path, bulk delete). It goes to the playbook engine on a crate-private channel (subscribe_to_emitted_events) alongside the unchanged EventEnvelope. A transaction's or batch's buffer holds the event and its context together (EmittedEvent). Batch coalescing never merges writes with different contexts.
  • Playbook engine (ADR-073): no trigger evaluation for skip_playbook_triggers. Repair-and-log (ADR-060 §7) runs for skip_invariant_rules.
  • Invariant dispatch: with skip_invariant_rules, no rule runs at any of the three in-transaction points (create, update, declared relationship), single or bulk.
  • The superseded REPLICATED_APPLY_CLIENT_ID ("sync-service") still behaves exactly as today: it reads as both flags set. Its doc now says it is superseded and is removed in the next release. It is not #[deprecated] because CLAUDE.md bans the attribute, and it would need allow(deprecated) at the remaining uses.
  • Six SqliteStore write methods (update_node, update_node_with_version_check, delete_node, bulk_delete, delete_subtree_atomic, delete_with_version_check) take write_context: WriteContext after source. These are library API, not an extension point. Sync main calls none of them.

Daemon: reserved client ids.

  • DaemonExtensions::reserved_client_id(id) and reserved_client_ids(). The default is empty, so core reserves none.
  • A NodeService request whose x-ns-client-id is a reserved id gets PERMISSION_DENIED. This covers every unary RPC, through route(), and WatchNodes. client_id_header is now the daemon's single, validated source of a client id.
  • A reserved id that the header cannot carry stops startup with DaemonExtensionsError::InvalidReservedClientId. That error enum is non_exhaustive.
  • build_database_services wires the reservation into every database's node API. A host using build_shared_services needs nothing more.

Core behaviour is unchanged

  • Nothing in core sets a write context, and core reserves no client id. Every write therefore runs its triggers and invariant rules exactly as before.
  • source_client_id, echo suppression (set_excluded_event_origin, subscribe_to_events_excluding_origin, WatchNodes own-echo filtering) and EventMetadata / EventEnvelope are unchanged. The public event stream carries the same envelopes in the same order, and a test pins that.
  • Sync main (pinned at v0.3.5) still compiles against this. It builds EventMetadata / EventEnvelope literals in tests, which is why the context does not travel as a new EventMetadata field. It uses none of the changed store methods.
  • Not in v0.3.5: the release was already tagged at 2bf95fe. This lands in core main for the next release.

Tests

  • (a) Ordinary writes are unaffected. A write with a client id alone, or one that skips only playbook triggers, is still refused at all three invariant dispatch points. Reactive plays still fire. Over the wire, a request carrying a client id is still refused by an invariant (daemon) and still fires a play (fixture through build_shared_services).
  • (b) The old tests run against the typed context. The engine trigger gate (create_node, bulk_create), the invariant skips (create, update, relationship, bulk_create, bulk_update) and repair-and-log (create, update, chain depth, the two-device ping-pong) all pass under it. Copies run the superseded id until phase 2.
  • (c) A reserved id is refused (PERMISSION_DENIED) on writes and on WatchNodes, and writes nothing. Unreserved ids and no id are served as before. Core's daemon refuses nothing. An invalid reserved id stops startup.
  • (d) Phase 2 adds this test: the old value with no reservation no longer skips triggers or invariants. In this PR the header never sets a write context, and that has a test.
  • (e) Echo suppression keys on the client id alone, whatever the context.
  • Mutation testing on the final code: each mutation is killed by the tests expected to catch it. The mutations cover the gate (ignore the context, no trigger skip, repair keyed on the wrong flag, the superseded branch removed), each invariant guard and the flag it reads, a client id alone skipping, with_client resetting the context, the origin filter keying on the context, store/emit/merge/batch-key propagation and the engine channel, the header refusal (on, off, refusing everything), assembly wiring, the wire setting a context, and startup validation and dedupe. The list and its results are in the PR comments.

Docs (to commit to nodespace-docs main after this merges)

  • ADR-082 §5 table, two rows:
    • Write context: NodeService::with_write_context(WriteContext) (accessor; db/events.rs, services/node_service/mod.rs, playbook/engine.rs, services/node_service/invariants.rs). Default: every write runs triggers and invariant rules. Core's own tests set it in process.
    • Reserved client ids: DaemonExtensions::reserved_client_id (hook; extensions.rs, node_service.rs). Default: none, every id is served. A core fixture reserves one and is refused.
  • architecture/extension-points.md: the daemon API block gains reserved_client_id / reserved_client_ids. Two new subsections:
    • Reserved client ids: what is refused, the error, the startup check.
    • Write context: the two flags, that only in-process code sets it, that events reach the engine with it, repair-and-log, that it is separate from the client id, and what a writer applying already-validated data sets.

Open question for the architect

  1. ADR-073 (Decision, second bullet) and ADR-060 ("Remote-origin events are distinguishable") say the engine tells a sync apply from a local write by the event's origin client tag. After phase 2 that is false: it reads the writer's write context, and the client id is only an echo label. Should both ADRs be amended to say so, with phase 2 or now?
  2. Is the write context an ADR-082 §5 extension point (the row above), or core library API under §5's last paragraph? Core's own code never sets it, which argues for the row.

🤖 Generated with Claude Code

@mstomar125

Copy link
Copy Markdown
Contributor Author

API: the final shape for the Sync adaptation. Phase 2 only deletes the superseded "sync-service" path and changes none of these signatures.

// nodespace_core (also nodespace_core::db::WriteContext, nodespace_core::db::events::WriteContext)
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash)]
pub struct WriteContext {
    /// The playbook engine evaluates no event trigger against the write's events.
    pub skip_playbook_triggers: bool,
    /// No invariant rule runs in the write's transaction (create, update,
    /// declared relationship; single and bulk); the engine repairs a
    /// created/updated node after commit instead (ADR-060 §7 repair-and-log).
    pub skip_invariant_rules: bool,
}

impl NodeService {
    pub fn with_client(&self, client_id: impl Into<String>) -> Self;       // unchanged; keeps the write context
    pub fn with_write_context(&self, write_context: WriteContext) -> Self; // new; keeps the client id; in-process only
    pub fn write_context(&self) -> WriteContext;                             // new
}

// nodespace_daemon
impl DaemonExtensions {
    pub fn reserved_client_id(self, id: impl Into<String>) -> Self; // new; default: none reserved
    pub fn reserved_client_ids(&self) -> &[String];                  // new
}
// #[non_exhaustive] DaemonExtensionsError gains InvalidReservedClientId(String):
// a reserved id that is empty, not visible ASCII, or padded with spaces stops startup.
impl NodeServiceImpl {
    pub fn with_reserved_client_ids(self, ids: Vec<String>) -> Self; // build_database_services sets it from DaemonExtensions
}

The Sync daemon sets it like this:

// The apply service. This replaces with_client("sync-service") on every apply-side NodeService.
let apply = node_service
    .with_client(SYNC_SERVICE_CLIENT_ID)       // echo label, as today
    .with_write_context(WriteContext {
        skip_playbook_triggers: true,
        skip_invariant_rules: true,
    });

// Where nodespaced-sync builds DaemonExtensions:
let extensions = DaemonExtensions::none()
    /* .supported_extension(..), .behavior(..), .edge_fields(..) as today */
    .reserved_client_id(SYNC_SERVICE_CLIENT_ID);
  • Both flags set behaves exactly like with_client("sync-service") today: no trigger evaluation, no in-transaction invariants, and repair-and-log after commit. Events still carry source_client_id = SYNC_SERVICE_CLIENT_ID, so set_excluded_event_origin, EchoGuard and the L1 push skip behave the same.
  • With the id reserved, any NodeService gRPC call (WatchNodes included) that presents it as x-ns-client-id gets PERMISSION_DENIED. In-process writers are unaffected.
  • EventMetadata and EventEnvelope are unchanged. The context reaches the engine on a crate-private channel, so Sync's test literals keep compiling.
  • Changed SqliteStore signatures (Sync main calls none of them): update_node, update_node_with_version_check, delete_node, bulk_delete, delete_subtree_atomic, delete_with_version_check take write_context: WriteContext right after source.
  • Until phase 2 lands, with_client("sync-service") alone still skips, so Sync can switch call sites in any order. After phase 2 only the typed context skips.

🤖 Generated with Claude Code

@mstomar125

Copy link
Copy Markdown
Contributor Author

Test results for this PR at 7482ce1:

  • bun run test:changed passed: rust:test (the whole workspace under nextest) in 257s, test:scripts, and types:check.
  • Targeted runs: core lib + it 790 passed, daemon lib + it 66 passed.
  • Clippy (-D warnings -D clippy::unused-async) on nodespace-core, nodespace-daemon and nodespace-proto with --all-targets is clean, and fmt is clean.

Mutation testing on the final code: each mutation was applied on its own and the targeted tests were run. All 23 are killed, and each one by the tests expected to catch it.

# Mutation Killed by (among others)
M1 write_context_of ignores the write's context write_context_of_reads_the_writes_write_context, engine typed tests, repair tests
M2 no return for skip_playbook_triggers the engine typed and superseded-id trigger tests
M3 repair keyed on skip_playbook_triggers a_node_written_skipping_invariants_only_is_repaired, skipping_invariants_only_repairs_and_still_fires_reactive_rules
M4 superseded-id branch removed the_superseded_client_id_reads_as_skipping_both, the superseded-id engine and repair tests
M5 skips_invariant_rules ignores the context the invariant matrix, bulk create/update skip tests
M6 skips_invariant_rules reads the triggers flag skipping_playbook_triggers_alone_still_runs_invariant_rules
M7 relationship guard removed skipping_invariant_rules_skips_every_dispatch_point, the_superseded_client_id_skips_every_dispatch_point
M8 update guard removed the invariant matrix, bulk update skip tests
M9 any client id skips invariants a_client_id_alone_does_not_skip_invariant_rules
M13 with_client resets the context write_context_and_client_id_are_set_independently
M14b origin filter withholds by context origin_filter_excludes_by_client_id_whatever_the_write_context
N1 engine channel gets nothing the engine tests, every_event_of_a_write_carries_the_writers_write_context
N2 store notifier drops the context every_event_of_a_write_carries_the_writers_write_context
N3 emitted() drops the context the parity test, the batch tests, the engine typed tests
N4 batch merge drops the context a_batch_merge_keeps_the_write_context
N5 batch key ignores the context batch_keeps_writes_with_different_write_contexts_apart
D1 no reserved-id check a_reserved_client_id_is_refused_and_others_are_served, fixture a_reserved_client_id_is_refused_in_every_database
D2 assembly drops the reservations fixture a_reserved_client_id_is_refused_in_every_database
D3 the header sets a skip context a_client_id_header_never_sets_a_write_context, a_client_id_header_does_not_skip_invariant_rules, fixture a_client_id_never_skips_playbook_triggers
D4 startup check skips reserved ids check_rejects_the_first_reserved_client_id_a_header_cannot_carry, fixture an_invalid_reserved_client_id_stops_startup
D5 no dedupe reserving_a_client_id_twice_reserves_it_once
D6 refuse every id when none is reserved without_reservations_every_client_id_is_served, fixture core_reserves_no_client_id
D8 the header-form check accepts anything the two startup-check tests

An independent adversarial review is in progress.

🤖 Generated with Claude Code

@mstomar125

Copy link
Copy Markdown
Contributor Author

APPROVE

Independent review of head 7482ce1a4. I found no blocker or major issue. I tried to break the write context and the reservation on every route the brief lists and could not. The findings below are one test gap on a load-bearing line, one perf cost, and doc nits.

Findings

  1. minor: the reservation on the unrouted service set is load-bearing but no test covers it. packages/daemon/src/services/assembly.rs:611, read at packages/daemon/src/services/node_service.rs:258.
    route() checks self.reserved_client_ids on the impl that received the request, before route_or_self swaps in the target database's impl (node_service.rs:258-260). When the required-extensions guard refuses the default database, unrouted_services_if_default_refused returns the unrouted set and the server registers that set's NodeServiceImpl. From then on, every request for every database is checked against the unrouted impl's list only.
    Mutation: delete .with_reserved_client_ids(...) at assembly.rs:611. I ran nodespace-daemon --lib --test it filtered to reserved client_id unrouted required_extensions extension_points_fixture against it: 25 run, 25 passed.
    The code is correct today. The gap is that nothing would catch the line being lost. The fixture test also calls each database's impl directly, so the real flow is never exercised: a request reaching the registered impl and routed by x-ns-database-id to a second database. Suggested test: build the unrouted set with DaemonExtensions::none().reserved_client_id(..), put the Arc<DatabaseManager> in the request extensions, and send CreateNode with a reserved id and a database header for an open database. Expect PERMISSION_DENIED.

  2. minor (perf): every emitted event is now deep-cloned once more. packages/core/src/services/node_service/mod.rs:844-845.
    flush_events now sends event.envelope.clone() to tx and moves the event into emitted_tx. Before this change the envelope was moved into tx. A NodeUpdated carries the whole Node (content and properties), and bulk imports and deletes emit thousands of events. The extra clone also happens when nothing subscribes to the engine channel, for example the unrouted set or a bare NodeService. One cheap fix: skip the engine send when emitted_tx.receiver_count() == 0. Another: carry Arc<EventEnvelope> on the engine channel.

  3. nit: three store write methods take a caller-chosen source but hard-code WriteContext::default(). packages/core/src/db/sqlite_store/nodes.rs:479 (create_node), :665 (create_child_node_atomic) and :1281 (switch_node_type_atomic).
    The six methods this PR changed take write_context after source, but these three do not. A direct store caller can therefore tag a create with any client id, the superseded one included, yet cannot pass a write context. After phase 2, a store-level create made by an applying writer would fire triggers and run no repair. No non-test code calls them with a source today, so nothing breaks now. Either give them the same parameter, or say in their docs that they always write with the default context.

  4. nit: the docs say "visible ASCII", but the check accepts interior spaces. packages/daemon/src/services/extensions.rs:68 and :174 against is_header_client_id at :139.
    The doc comment and the error text both say "non-empty visible ASCII". "a b" is accepted, and check_rejects_the_first_reserved_client_id_a_header_cannot_carry asserts that it is. A space (0x20) is not visible ASCII. Reword the docs to match the behaviour (the API comment's wording, "not visible ASCII, or padded with spaces", is closer), or reject spaces.

  5. nit: one test comment overstates what it checks. packages/daemon/src/services/node_service.rs:7595-7597.
    a_client_id_header_never_sets_a_write_context says "the id is only the label its events carry", but its loop includes REPLICATED_APPLY_CLIENT_ID. In phase 1 that header still skips triggers and invariants through the superseded path. The assertion checks only write_context(), so the test is right and the comment is not. Say it is true for every id except the superseded one until phase 2.

  6. nit: two comments now describe the gate wrongly.

    • packages/core/src/playbook/engine.rs:618: "Trigger matching for non-lifecycle, locally-originated events". The gate is now the write context, not where the write came from.
    • packages/core/src/services/node_service/bulk.rs:275: "(via emit_event), which the ADR-073 local-origin gate depends on". That path uses emit_event_in_tx, and the gate reads the write context.
  7. nit: the PR body points to a comment that is not there. The body says the mutation list and its results "are in the PR comments". The only comment on the PR is the API comment.

What I checked (no issue found)

  • External routes to skipping rules. Outside tests, nothing calls with_write_context. Outside tests, with_client is called only in route(), which keeps the base service's default context.
    • The header that route reads is the only client-id source in the daemon. No proto field carries a client id or a source, and import, local-agent, agent-session, database and embeddings services never read the header.
    • The CLI, the Tauri app-lib and MCP reach the daemon only over gRPC. Agent code uses the daemon's own NodeService.
    • No cached or static NodeService handle exists. Clone, with_client and scoped_for_playbook all copy the context from the service they derive from, and the base service is never mutated.
  • Context propagation.
    • Every write site in NodeService that passes self.client_id also passes self.write_context: store update_node, update_node_with_version_check, delete_node, bulk_delete, delete_subtree_atomic and delete_with_version_check.
    • emit_event, emit_event_in_tx, the commit-publish path, the batch route/offer/merge path (the key includes the context, and a merge keeps it), BatchEmitGuard::drop and the store notifier all carry it.
    • The markdown spawn path clones the service, so it keeps the context.
    • The engine channel has the same capacity, the same per-sender order and the same Lagged handling (reload plays) as the public channel.
  • Ordinary writes are unchanged.
    • With the default context, skips_invariant_rules() is the old client-id comparison, at all three guards, the bulk paths and dry_run_update.
    • In handle_event, the lifecycle early returns still come first. A write with the default context gets neither repair nor a trigger skip.
    • With both flags set (or the superseded id), the behaviour is the old branch: repair, then return.
    • Invariant rules are still filtered out of the reactive queue, so skip_invariant_rules alone runs each invariant exactly once, as a repair.
  • Daemon refusal. The check is exact-match. It runs before database routing, so the routing header cannot bypass it. A second header value is never read, because get returns the first value on both paths. Non-ASCII is rejected by to_str. WatchNodes is covered. The only handlers that skip route() are get_daemon_version and get_daemon_memory, which are read-only.
  • Sync source compatibility (origin/main 95b5415, reference/ ignored).
    • Sync calls none of the six changed store methods. Its update_node, delete_node and delete_with_version_check calls are all on NodeService. It does not construct StoreChange and does not match on DaemonExtensionsError, which was already non_exhaustive.
    • Sync's EventMetadata and EventEnvelope literals are unaffected. It hosts through build_shared_services and get_or_open, so the reservation reaches it.
  • Core rules. scripts/check-sync-boundary.ts is clean. The diff adds no #[deprecated], no allow(...) and no issue numbers in comments.
  • Tests.
    • Baseline runs pass: core 44/44 targeted (lib and it), daemon 14/14 targeted.
    • Mutations I applied, each killed by the expected test:
      • store update_node notifies with the default context: killed by every_event_of_a_write_carries_the_writers_write_context.
      • delete_subtree_atomic notifies with the default context: killed by the same test.
      • BatchKey ignores the context: killed by batch_keeps_writes_with_different_write_contexts_apart.
      • Repair keyed on skip_playbook_triggers: killed by a_node_written_skipping_invariants_only_is_repaired and skipping_invariants_only_repairs_and_still_fires_reactive_rules.
      • The relationship guard reads only the client id: killed by skipping_invariant_rules_skips_every_dispatch_point.
    • The negative engine tests use a positive control on the same engine, and events are handled in order, so the 100-200 ms sleeps after a play is created do not make them flaky.

🤖 Generated with Claude Code

@mstomar125

Copy link
Copy Markdown
Contributor Author

APPROVE

Re-review at 36c70bec2. All seven findings from my previous review are resolved. Finding 7 was mine to withdraw: the mutation-results comment was already on the PR when I posted. I fetched the comments before it went up. One new nit is below, and it does not block the merge.

The receiver_count change (packages/core/src/services/node_service/mod.rs:846)

It cannot drop an event the engine would have received, and it cannot reorder events.

  • Nothing is lost. In tokio's broadcast, send with no receiver returns Err and stores nothing. A subscribe() that comes later starts at the current tail. An event skipped while receiver_count() == 0 is therefore one that no receiver, present or future, could have read. That is exactly what the old send did in that state.
  • The check-then-send gap adds no new kind of miss. The count is read under the tail lock, which is released before the send. If the engine subscribes in that gap, it misses the event. The old code missed the same event if the send landed just before the subscribe. The skip takes effect at the check, which comes before the subscribe.
    • start() already handles events from before its subscription. It subscribes first, then load_plays() reads the store.
    • flush_events runs only after the write has committed. So the store already holds anything the engine missed in that gap when load_plays() reads it.
    • A missed event fires no reactive rule, as before for any write made before the engine started.
  • Order is unchanged. Each event still goes to the filtered channel, then the main channel, then the engine channel, in the loop's order, and both branches keep that sequence. The count is read for each event, so an engine that subscribes partway through a flushed batch sees the tail end of it. That is also what the old code did.
  • Every handle shares one count. All clones, and the emitted_tx held by BatchEmitGuard, share the same channel, so the count covers every reader. A lagging receiver still counts. When the engine shuts down and drops its receiver, the copies stop.
  • A mutation confirms the engine depends on this guard. I changed the condition to > 1, so a single reader gets nothing. Three tests failed: play_fires_end_to_end_for_local_mutation, every_event_of_a_write_carries_the_writers_write_context and batch_keeps_writes_with_different_write_contexts_apart.

The new test (packages/daemon/tests/it/required_extensions_e2e.rs:281)

a_reserved_client_id_is_refused_by_the_unrouted_service_set covers what I asked for. A default database is refused, the unrouted set serves requests behind the real router with DbManagerLayer over TCP, and the request goes by x-ns-database-id to another database.

  • With .with_reserved_client_ids(...) removed from assembly.rs:611, it fails at :351: the refused request is served.
  • At the PR head it passes.

New nit

  • packages/core/src/db/sqlite_store/nodes.rs:419, :579 and :1250 say "Notifies with the default write context: every rule runs on the write's event." No invariant rule runs for these store writes:

    • A store-level write has no in-transaction invariant dispatch.
    • The default context asks the engine for no repair.
    • The engine filters invariant rules out of its reactive queue.

    Only reactive triggers are evaluated. Until phase 2, a source equal to the superseded id also skips those. Suggested wording: "the playbook engine evaluates its event triggers against the event; no invariant rule runs for a store-level write".

Runs at 36c70bec2 (through the machine slot)

  • Core, lib and it, targeted: 86 passed. The whole playbook_engine_integration_test, playbook_invariant_integration_test and bulk_invariant_dispatch_test modules: 88 passed.
  • Daemon, lib and it, targeted (reserved, client_id, required_extensions_e2e::, extension_points_fixture::): 20 passed.
  • scripts/check-sync-boundary.ts is clean.
  • The doc and comment fixes (printable ASCII with no leading or trailing space, the daemon test comment, engine.rs and bulk.rs) match the code.

🤖 Generated with Claude Code

@mstomar125

Copy link
Copy Markdown
Contributor Author

@malibio, a summary of this PR, which is phase 1 of #3435.

What changed. Core no longer needs a magic client id to recognise a write whose rules already ran elsewhere.

  • NodeService::with_write_context(WriteContext { skip_playbook_triggers, skip_invariant_rules }) marks such a write. It is a typed, in-process-only capability: no gRPC header or request field can set it.
  • The playbook engine reads it per event (trigger skip, plus ADR-060 §7 repair-and-log), and invariant dispatch reads it at create, update and declared-relationship time.
  • DaemonExtensions::reserved_client_id lets a build reserve its own writers' client ids. A request presenting a reserved x-ns-client-id is then refused with PERMISSION_DENIED.
  • Core reserves nothing and contains nothing named for Sync. Exact signatures are in the "API:" comment above.

Core behaviour is unchanged. Nothing in core sets a write context or reserves an id. Every ordinary write runs its triggers and invariants exactly as before. source_client_id echo suppression and the public event stream (EventMetadata/EventEnvelope) are untouched. Sync main still compiles against this, so the canary stays green.

Release. This is not in v0.3.5. That release was already tagged at 2bf95fe when the plan reached me, so this lands in core main for the next release. Phase 2 deletes REPLICATED_APPLY_CLIENT_ID / is_replicated_apply, which closes the hole where any local client sends x-ns-client-id: sync-service to switch rules off. It is prepared on a branch and waits until Sync has moved its apply services to with_write_context and reserves its id.

Open question for the architect (ADR text).

  1. ADR-073 ("the engine's subscriber checks the event's origin tag") and ADR-060 ("Remote-origin events are distinguishable … consults the same signal") both say the engine recognises a sync apply by its client tag. After phase 2 the engine reads the write context instead, and the client id is only an echo label. Should both ADRs be amended to say so, with phase 2 or now?
  2. I am adding ADR-082 §5 rows for the write context (as an accessor) and for reserved client ids (as a hook) when this merges. Should the write context instead count as plain core library API under §5's last paragraph?

🤖 Generated with Claude Code

mstomar125 and others added 3 commits October 12, 2026 09:24
)

WriteContext { skip_playbook_triggers, skip_invariant_rules } is set only
in process through NodeService::with_write_context. Each event a write
emits reaches the playbook engine beside it on a crate-private channel
(EmittedEvent, subscribe_to_emitted_events); transaction and batch buffers
hold the event and its context together, and batch coalescing keys on the
context. The engine skips trigger evaluation for skip_playbook_triggers and
runs repair-and-log for skip_invariant_rules; invariant dispatch at create,
update and declared-relationship time is skipped for skip_invariant_rules.
The six SqliteStore write methods that notify carry the writer's context.
EventMetadata and EventEnvelope are unchanged.

REPLICATED_APPLY_CLIENT_ID still reads as both flags set; its removal is a
separate change.

DaemonExtensions::reserved_client_id reserves client ids for a build's own
in-process writers: a NodeService request (WatchNodes included) presenting
one as x-ns-client-id is refused with PERMISSION_DENIED, and an id the
header cannot carry stops startup (InvalidReservedClientId). Core reserves
none.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ithout a reader, fix comments

Co-Authored-By: Claude Opus 5.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.

1 participant