Skip to content

feat(engine): embed cluster node id into worker-scoped ids - #2421

Merged
jfallows merged 4 commits into
developfrom
claude/cluster-wide-worker-ids-847
Aug 24, 2026
Merged

feat(engine): embed cluster node id into worker-scoped ids#2421
jfallows merged 4 commits into
developfrom
claude/cluster-wide-worker-ids-847

Conversation

@jfallows

Copy link
Copy Markdown
Contributor

Description

EngineWorker mints initialId, promiseId, traceId, budgetId, authorizedId, and its own affinityId counter from one shared initial/mask pair that previously encoded only this node's local worker index (top byte, bits 56-63). Every such id was therefore unique only within one engine instance — a traceId minted on one node's worker 2 can numerically collide with one minted on a different node's worker 2.

That matters once a RouterContext implementation fans work out across physical nodes (the SPI already supports this — RouteableContext#attachComposite/supplyStore, RouterContext#resolveRoutedId) rather than only across local workers: any consumer of traceId/budgetId/etc. for cross-node trace or log correlation (zilla dump output included, once a stream has been forwarded to a different node and back) can't disambiguate two ids that happen to share the same local worker index on different nodes.

This folds EngineConfiguration's own node.id byte into the same initial value, immediately below the existing worker-index byte (bits 48-55, previously always zero) — forming one contiguous 16-bit (node, worker) pair. Every id derived from initial/mask becomes cluster-wide unique as a result, with:

  • no change to the existing per-worker counter width (still 31 bits via the unchanged RESERVED_SIZE)
  • no change to indexOfId's existing local-dispatch semantics (guard verifier/identifier/attributor routing, BudgetId#ownerIndex resolution) — both still read only the unmoved worker-index byte
  • a new nodeOfId alongside the existing indexOfId, for symmetry

node.id defaults to 0, so this is a no-op for every single-node deployment — verified via the full runtime/engine unit + integration test suite (438 tests, 0 failures) and checkstyle:check (0 violations), both green before and after this change.

Test plan

  • ./mvnw checkstyle:check -pl runtime/engine — 0 violations
  • ./mvnw clean install -pl runtime/engine -am -DskipTests=false — full unit + IT suite green (228 unit tests, 210 integration tests, 0 failures/errors)

Generated by Claude Code

claude added 2 commits August 23, 2026 16:25
EngineWorker mints initialId, promiseId, traceId, budgetId, authorizedId,
and its own affinityId counter from one shared `initial`/`mask` pair that
previously encoded only this node's local worker index (top byte, bits
56-63). Every such id was therefore unique only within one engine
instance -- a traceId minted on one cluster node's worker 2 could collide
numerically with one minted on a different node's worker 2, defeating
cross-node trace/log correlation for any router that fans work out across
physical nodes (see RouterContext).

Folds EngineConfiguration's own node.id byte into the same `initial` value,
immediately below the existing worker-index byte (bits 48-55, previously
always zero) -- forming one contiguous 16-bit (node, worker) pair. Every id
derived from `initial`/`mask` becomes cluster-wide unique as a result, with
no change to the existing per-worker counter width or to indexOfId's local
dispatch semantics (guard verifier/identifier/attributor routing, budget
ownership resolution). Adds nodeOfId alongside the existing indexOfId for
symmetry.

node.id defaults to 0, so this is a no-op for every single-node deployment.
…sector

Follow-up to the previous commit: zilla.lua showed trace_id as one opaque
64-bit hex value, with no visibility into the (node, worker) pair now
embedded in it. Adds trace_id.node and trace_id.worker as child fields
under a new Trace ID subtree, extracted from the same byte range as
plain single-byte slices (bytes 6 and 7 of the little-endian trace_id
field) rather than a 64-bit bitmask, avoiding any precision concerns.

Also drops an explanatory comment on NODE_SHIFT_SIZE from the prior
commit that wasn't earning its place.

@jfallows jfallows 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.

LGTM

claude added 2 commits August 23, 2026 17:30
The Trace ID field in zilla dump output is now a subtree with nested
Node and Worker fields; regenerate the 25 golden fixtures used by the
tshark-based command-dump integration tests to match.

@jfallows jfallows 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.

LGTM

@jfallows
jfallows merged commit 1e9449c into develop Aug 24, 2026
42 checks passed
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.

2 participants