What to build
Roll out Cluster-safe key naming across every key factory method in Constants.java. Two independent things happen under REDIS_KEY_SCHEMA_VERSION=v2:
- Every key gains a
byai_gateway:v2: prefix (v1 stays unprefixed, unchanged, and remains the default).
- Keys belonging to the same logical entity (session, worker, task_group, trace, agent_type, service-discovery name) get a Redis Cluster hash tag around the shared ID, so multi-key operations against the same entity land on the same slot. Single-key methods, global-index keys (SETs shared across entities), and the small set of keys that are read together but never written together atomically do NOT get a tag.
The prefix + tag logic must be centralized in one formatting function that every key factory method calls — no per-method judgment calls about whether to add the prefix.
Same-entity groups requiring a shared tag: session (data_stream / consumer checkpoint / registry), worker (ctrl stream / lock / online-lease / status / executions / active_executions / active_execution_index / active_snapshots / history_snapshots / admin / declared_agent_types), task_group (main + results), agent_type (members + denied — this one is mandatory, not optional: WorkerRegistry.java's denyWorkerForType already writes both keys together and must keep working), service-discovery (active instances + instance details), trace (meta + spans).
Global-index keys (known-workers set, admin-workers set, service-discovery services set) do NOT get a tag.
Separately, trace keys get a bigger change: today Java's trace keys use a by_framework:trace:* namespace (byte-for-byte identical to Python's current format), while TS uses a different byai_gateway:trace:{id}:meta/spans namespace. This is the SDK-wide decision to unify onto one v2 format used by all three languages: byai_gateway:v2:trace:{trace_id} for meta, byai_gateway:v2:trace:spans:{trace_id} for spans (type-then-id ordering, consistent with the rest of the key matrix). trace_meta/trace_spans share the trace_id hash tag. trace_index_session/worker/agent keep their existing path structure, only the prefix changes — they do NOT get a tag (splitting them out of the shared write pipeline is a separate, later issue).
Also add this SDK's contribution to a cross-language "golden key" test: given a fixed set of IDs (e.g. session_id="sess-abc123", worker_id="worker-01", trace_id="trace-xyz", etc.), Java's key factory must produce exact key strings matching a shared fixture (JSON/YAML) that Python has already populated and TS will populate in its own equivalent issue. Under v1, trace keys are expected to still differ from what TS produces (pre-existing inconsistency) — only assert full cross-language equality for trace keys under v2.
Acceptance criteria
Blocked by
#8
What to build
Roll out Cluster-safe key naming across every key factory method in
Constants.java. Two independent things happen underREDIS_KEY_SCHEMA_VERSION=v2:byai_gateway:v2:prefix (v1 stays unprefixed, unchanged, and remains the default).The prefix + tag logic must be centralized in one formatting function that every key factory method calls — no per-method judgment calls about whether to add the prefix.
Same-entity groups requiring a shared tag: session (data_stream / consumer checkpoint / registry), worker (ctrl stream / lock / online-lease / status / executions / active_executions / active_execution_index / active_snapshots / history_snapshots / admin / declared_agent_types), task_group (main + results), agent_type (members + denied — this one is mandatory, not optional:
WorkerRegistry.java'sdenyWorkerForTypealready writes both keys together and must keep working), service-discovery (active instances + instance details), trace (meta + spans).Global-index keys (known-workers set, admin-workers set, service-discovery services set) do NOT get a tag.
Separately, trace keys get a bigger change: today Java's trace keys use a
by_framework:trace:*namespace (byte-for-byte identical to Python's current format), while TS uses a differentbyai_gateway:trace:{id}:meta/spansnamespace. This is the SDK-wide decision to unify onto one v2 format used by all three languages:byai_gateway:v2:trace:{trace_id}for meta,byai_gateway:v2:trace:spans:{trace_id}for spans (type-then-id ordering, consistent with the rest of the key matrix).trace_meta/trace_spansshare the trace_id hash tag.trace_index_session/worker/agentkeep their existing path structure, only the prefix changes — they do NOT get a tag (splitting them out of the shared write pipeline is a separate, later issue).Also add this SDK's contribution to a cross-language "golden key" test: given a fixed set of IDs (e.g.
session_id="sess-abc123",worker_id="worker-01",trace_id="trace-xyz", etc.), Java's key factory must produce exact key strings matching a shared fixture (JSON/YAML) that Python has already populated and TS will populate in its own equivalent issue. Underv1, trace keys are expected to still differ from what TS produces (pre-existing inconsistency) — only assert full cross-language equality for trace keys underv2.Acceptance criteria
v2prefixagentTypeMembers/agentTypeDenied(or equivalent) share a mandatory tag (not marked optional)traceMeta/traceSpansmove to the unifiedbyai_gateway:v2:trace:{trace_id}/byai_gateway:v2:trace:spans:{trace_id}format;trace_index_*keeps its path structure, only the prefix changesv2; underv1, trace keys are exempted from cross-language equality assertionsv1behavior/output is completely unchangedBlocked by
#8