@lumenflow/core 4.11.0 → 4.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/dist/arg-parser.d.ts.map +1 -1
  2. package/dist/arg-parser.js +18 -0
  3. package/dist/arg-parser.js.map +1 -1
  4. package/dist/backlog-generator.d.ts +6 -0
  5. package/dist/backlog-generator.d.ts.map +1 -1
  6. package/dist/backlog-generator.js +12 -0
  7. package/dist/backlog-generator.js.map +1 -1
  8. package/dist/lumenflow-config-schema.d.ts +10 -0
  9. package/dist/lumenflow-config-schema.d.ts.map +1 -1
  10. package/dist/lumenflow-config-schema.js +3 -1
  11. package/dist/lumenflow-config-schema.js.map +1 -1
  12. package/dist/ports/wu-state.ports.d.ts +12 -0
  13. package/dist/ports/wu-state.ports.d.ts.map +1 -1
  14. package/dist/schemas/wu-config.d.ts +17 -0
  15. package/dist/schemas/wu-config.d.ts.map +1 -1
  16. package/dist/schemas/wu-config.js +31 -0
  17. package/dist/schemas/wu-config.js.map +1 -1
  18. package/dist/wu-id-format.d.ts +139 -0
  19. package/dist/wu-id-format.d.ts.map +1 -0
  20. package/dist/wu-id-format.js +252 -0
  21. package/dist/wu-id-format.js.map +1 -0
  22. package/dist/wu-rename-projection.d.ts +62 -0
  23. package/dist/wu-rename-projection.d.ts.map +1 -0
  24. package/dist/wu-rename-projection.js +66 -0
  25. package/dist/wu-rename-projection.js.map +1 -0
  26. package/dist/wu-state-indexer.d.ts +23 -0
  27. package/dist/wu-state-indexer.d.ts.map +1 -1
  28. package/dist/wu-state-indexer.js +70 -2
  29. package/dist/wu-state-indexer.js.map +1 -1
  30. package/dist/wu-state-schema.d.ts +40 -1
  31. package/dist/wu-state-schema.d.ts.map +1 -1
  32. package/dist/wu-state-schema.js +27 -0
  33. package/dist/wu-state-schema.js.map +1 -1
  34. package/dist/wu-state-store.d.ts +12 -0
  35. package/dist/wu-state-store.d.ts.map +1 -1
  36. package/dist/wu-state-store.js +23 -0
  37. package/dist/wu-state-store.js.map +1 -1
  38. package/package.json +4 -2
@@ -0,0 +1,252 @@
1
+ // Copyright (c) 2026 Hellmai Ltd
2
+ // SPDX-License-Identifier: AGPL-3.0-only
3
+ /**
4
+ * WU ID Format Primitives (WU-2552)
5
+ *
6
+ * Canonical zero-padded WU ID primitives. All ID formatting, parsing,
7
+ * and regex construction flows through this module so that width, strict
8
+ * mode, and prefix can be centrally configured via workspace.yaml
9
+ * `software_delivery.wu_id.{width,strict,prefix}`.
10
+ *
11
+ * Design principles:
12
+ * - Pure functions, no I/O, no config reads (caller supplies config).
13
+ * - Hardcoded choices: separator '-', lowercase digits, padding char '0',
14
+ * starting number 1, gap-fill policy 'never reuse'.
15
+ * - `wuIdRegex` is intentionally permissive (matches both padded and unpadded
16
+ * digit counts) so that consumers scanning files for legacy + canonical
17
+ * IDs stay backward compatible during the transition. Strict canonical
18
+ * form is enforced separately via `isCanonicalWuId`.
19
+ *
20
+ * @module wu-id-format
21
+ */
22
+ import { existsSync, readdirSync, readFileSync } from 'node:fs';
23
+ import { createError, ErrorCodes } from './error-handler.js';
24
+ import { getConfig } from './lumenflow-config.js';
25
+ /** Minimum allowed zero-padding width. */
26
+ export const WU_ID_WIDTH_MIN = 1;
27
+ /** Maximum allowed zero-padding width. */
28
+ export const WU_ID_WIDTH_MAX = 6;
29
+ /**
30
+ * Prefix validation pattern: uppercase letter start, followed by 1-9 more
31
+ * uppercase-alphanumeric characters, terminated by a dash. Matches 'WU-',
32
+ * 'TASK-', 'STORY-', 'TICKET-', 'JIRA123-'. Rejects lowercase, missing dash,
33
+ * single-char prefixes, and over-long prefixes.
34
+ */
35
+ export const WU_ID_PREFIX_PATTERN = /^[A-Z][A-Z0-9]{1,9}-$/;
36
+ /** Default WU ID configuration. */
37
+ export const WU_ID_DEFAULTS = Object.freeze({
38
+ width: 4,
39
+ strict: true,
40
+ prefix: 'WU-',
41
+ });
42
+ /**
43
+ * Validate and resolve a partial WU ID config against the defaults.
44
+ *
45
+ * @throws {Error} If width is not an integer in [1, 6] or prefix does not
46
+ * match {@link WU_ID_PREFIX_PATTERN}.
47
+ */
48
+ export function validateWuIdConfig(partial = {}) {
49
+ const width = partial.width ?? WU_ID_DEFAULTS.width;
50
+ const strict = partial.strict ?? WU_ID_DEFAULTS.strict;
51
+ const prefix = partial.prefix ?? WU_ID_DEFAULTS.prefix;
52
+ if (!Number.isInteger(width) || width < WU_ID_WIDTH_MIN || width > WU_ID_WIDTH_MAX) {
53
+ throw createError(ErrorCodes.VALIDATION_ERROR, `Invalid wu_id.width: ${String(width)}. Must be an integer between ${WU_ID_WIDTH_MIN} and ${WU_ID_WIDTH_MAX}.`);
54
+ }
55
+ if (typeof prefix !== 'string' || !WU_ID_PREFIX_PATTERN.test(prefix)) {
56
+ throw createError(ErrorCodes.VALIDATION_ERROR, `Invalid wu_id.prefix: "${String(prefix)}". Must match ${WU_ID_PREFIX_PATTERN} (e.g., 'WU-', 'TASK-', 'STORY-').`);
57
+ }
58
+ return { width, strict, prefix };
59
+ }
60
+ /**
61
+ * Format an integer as a canonical WU ID.
62
+ *
63
+ * Zero-pads to the configured width. If the integer exceeds 10^width, the
64
+ * result is wider than width (overflow is preserved, never truncated).
65
+ *
66
+ * @throws {Error} If n is not a positive integer.
67
+ */
68
+ export function formatWuId(n, config = {}) {
69
+ if (!Number.isInteger(n) || n < 1) {
70
+ throw createError(ErrorCodes.VALIDATION_ERROR, `Invalid WU number: ${String(n)}. Must be a positive integer.`);
71
+ }
72
+ const { width, prefix } = validateWuIdConfig(config);
73
+ return `${prefix}${String(n).padStart(width, '0')}`;
74
+ }
75
+ /**
76
+ * Parse a WU ID (or YAML/stamp filename) into its prefix and numeric parts.
77
+ *
78
+ * Returns null for any input that does not match the configured prefix or
79
+ * does not carry a positive integer body. Accepts both canonical padded and
80
+ * legacy unpadded forms.
81
+ *
82
+ * Strips `.yaml` and `.done` extensions before parsing.
83
+ */
84
+ export function parseWuId(id, config = {}) {
85
+ if (typeof id !== 'string' || id.length === 0) {
86
+ return null;
87
+ }
88
+ const { prefix } = validateWuIdConfig(config);
89
+ const stripped = id.replace(/\.(yaml|done)$/, '');
90
+ if (!stripped.startsWith(prefix)) {
91
+ return null;
92
+ }
93
+ const body = stripped.slice(prefix.length);
94
+ if (!/^\d+$/.test(body)) {
95
+ return null;
96
+ }
97
+ const num = parseInt(body, 10);
98
+ if (!Number.isFinite(num) || num < 1) {
99
+ return null;
100
+ }
101
+ return { prefix, num };
102
+ }
103
+ /**
104
+ * Build an anchored regex that matches WU IDs (both padded and unpadded
105
+ * digit counts) for the configured prefix. Intended for file scans and
106
+ * consumers that previously hardcoded `/^WU-\d+$/`.
107
+ *
108
+ * Strict canonical-form enforcement lives in {@link isCanonicalWuId}, not here.
109
+ */
110
+ export function wuIdRegex(config = {}) {
111
+ // eslint-disable-next-line security/detect-non-literal-regexp -- prefix escaped
112
+ return new RegExp(`^${wuIdBodyPattern(config)}$`);
113
+ }
114
+ /**
115
+ * Return an unanchored pattern string (for embedding in longer regexes)
116
+ * that matches the WU id body — the configured prefix followed by one
117
+ * or more digits. Consumers that previously hardcoded `WU-\\d+` inside
118
+ * a larger regex should use this helper so prefix configuration
119
+ * (`software_delivery.wu_id.prefix`) is honored.
120
+ *
121
+ * The pattern does NOT include anchors; callers decide whether to
122
+ * anchor with `^`/`$` or embed in a path/substring match.
123
+ */
124
+ export function wuIdBodyPattern(config = {}) {
125
+ const { prefix } = validateWuIdConfig(config);
126
+ const escaped = prefix.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
127
+ return `${escaped}\\d+`;
128
+ }
129
+ /**
130
+ * Return true if the given string is a canonical WU ID for the configured
131
+ * width and prefix. Canonical means:
132
+ * - Prefix matches.
133
+ * - Digit body is at least `width` characters long.
134
+ * - The digit body is not shorter than width (no unpadded legacy).
135
+ * - Overflow (body wider than width) is allowed so the sequence never truncates.
136
+ */
137
+ export function isCanonicalWuId(id, config = {}) {
138
+ const { width, prefix } = validateWuIdConfig(config);
139
+ if (typeof id !== 'string' || !id.startsWith(prefix)) {
140
+ return false;
141
+ }
142
+ const body = id.slice(prefix.length);
143
+ if (!/^\d+$/.test(body)) {
144
+ return false;
145
+ }
146
+ return body.length >= width;
147
+ }
148
+ /**
149
+ * Canonicalize a (possibly legacy) WU ID to the canonical form for the
150
+ * configured width. Returns null for unparseable input or prefix mismatch.
151
+ *
152
+ * Already-canonical IDs are returned unchanged. Overflow IDs (wider than
153
+ * width) are preserved.
154
+ */
155
+ export function canonicalizeWuId(id, config = {}) {
156
+ const parsed = parseWuId(id, config);
157
+ if (!parsed) {
158
+ return null;
159
+ }
160
+ return formatWuId(parsed.num, config);
161
+ }
162
+ /**
163
+ * Load the canonical WU id config from workspace.yaml
164
+ * `software_delivery.wu_id.{width,strict,prefix}`.
165
+ *
166
+ * Falls back to {@link WU_ID_DEFAULTS} when the block is absent, so
167
+ * existing repos without any wu_id config continue to see WU- prefixed
168
+ * ids (backward compatible) with the only visible change being
169
+ * zero-padding on newly-generated ids.
170
+ *
171
+ * @param options.projectRoot - Optional override for the project root.
172
+ */
173
+ export function loadWuIdConfig(options = {}) {
174
+ const config = getConfig(options.projectRoot ? { projectRoot: options.projectRoot } : {});
175
+ const wuIdBlock = config.wuId;
176
+ return validateWuIdConfig(wuIdBlock ?? {});
177
+ }
178
+ /**
179
+ * Scan every existing WU id integer across the yaml directory, stamps
180
+ * directory, and event log. Used by wu:create for integer-level
181
+ * collision detection so `WU-14` and `WU-0014` can never coexist.
182
+ *
183
+ * Results are deduplicated across sources. Entries whose prefix does
184
+ * not match the configured prefix are ignored. Extension suffixes
185
+ * (`.yaml`, `.done`) are stripped before parsing.
186
+ */
187
+ export function scanExistingWuNumbers(input, config = {}) {
188
+ const result = new Set();
189
+ const addFromEntries = (entries) => {
190
+ for (const entry of entries) {
191
+ const parsed = parseWuId(entry, config);
192
+ if (parsed) {
193
+ result.add(parsed.num);
194
+ }
195
+ }
196
+ };
197
+ if (existsSync(input.wuDir)) {
198
+ addFromEntries(readdirSync(input.wuDir));
199
+ }
200
+ if (existsSync(input.stampsDir)) {
201
+ addFromEntries(readdirSync(input.stampsDir));
202
+ }
203
+ if (existsSync(input.eventsPath)) {
204
+ try {
205
+ const content = readFileSync(input.eventsPath, { encoding: 'utf-8' });
206
+ for (const line of content.split('\n')) {
207
+ const trimmed = line.trim();
208
+ if (trimmed.length === 0)
209
+ continue;
210
+ try {
211
+ const event = JSON.parse(trimmed);
212
+ for (const candidate of [event.wuId, event.from, event.to]) {
213
+ if (typeof candidate === 'string') {
214
+ const parsed = parseWuId(candidate, config);
215
+ if (parsed) {
216
+ result.add(parsed.num);
217
+ }
218
+ }
219
+ }
220
+ }
221
+ catch {
222
+ // Ignore malformed lines; the events file is allowed to have gaps.
223
+ }
224
+ }
225
+ }
226
+ catch {
227
+ // Read errors fall through; caller treats this as "no known ids".
228
+ }
229
+ }
230
+ return result;
231
+ }
232
+ /**
233
+ * Returns true when `num` is already present in the given set.
234
+ * Thin wrapper for call-site readability at the wu:create integration point.
235
+ */
236
+ export function integerCollides(existing, num) {
237
+ return existing.has(num);
238
+ }
239
+ /**
240
+ * Returns true when the given WU number is within the width-exhaustion
241
+ * warning band (>= 90% of 10^width) but still below the width ceiling.
242
+ *
243
+ * Numbers that already exceed the width capacity return false so the
244
+ * warning only fires once, not on every subsequent overflow id.
245
+ */
246
+ export function isWidthExhaustionWarning(num, config = {}) {
247
+ const { width } = validateWuIdConfig(config);
248
+ const capacity = Math.pow(10, width);
249
+ const threshold = capacity * 0.9;
250
+ return num >= threshold && num < capacity;
251
+ }
252
+ //# sourceMappingURL=wu-id-format.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wu-id-format.js","sourceRoot":"","sources":["../src/wu-id-format.ts"],"names":[],"mappings":"AAAA,iCAAiC;AACjC,yCAAyC;AAEzC;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,C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;IACpF,MAAM,EAAE,KAAK,EAAE,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC;IAC7C,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;IACrC,MAAM,SAAS,GAAG,QAAQ,GAAG,GAAG,CAAC;IACjC,OAAO,GAAG,IAAI,SAAS,IAAI,GAAG,GAAG,QAAQ,CAAC;AAC5C,CAAC"}
@@ -0,0 +1,62 @@
1
+ /// <reference path="./types.d.ts" />
2
+ /**
3
+ * WU Rename Projection (WU-2552)
4
+ *
5
+ * Read-side helper that walks a wu-events log and returns a function
6
+ * resolving any original WU id to its current canonical id after zero
7
+ * or more `wu_renamed` events.
8
+ *
9
+ * Event sourcing discipline:
10
+ * - History is append-only. Historical events keep their original wuId.
11
+ * - This projection is the read-side resolution view, not a rewrite.
12
+ * - Rename chains are transitive: A -> B -> C means resolve(A) === 'C'.
13
+ *
14
+ * Consumers:
15
+ * - {@link ./wu-state-indexer.ts} applies events in rename-resolved order.
16
+ * - {@link ./backlog-generator.ts} displays current canonical ids only.
17
+ *
18
+ * @module wu-rename-projection
19
+ */
20
+ import type { WUEvent } from './wu-state-schema.js';
21
+ /** A single rename link recorded in the event log. */
22
+ export interface RenameLink {
23
+ /** Original WU id (what it was called before the rename). */
24
+ from: string;
25
+ /** New WU id (what it is called after the rename). */
26
+ to: string;
27
+ /** Optional human reason supplied at wu:rename time. */
28
+ reason?: string;
29
+ /** ISO-8601 timestamp of the rename event. */
30
+ timestamp: string;
31
+ }
32
+ /** Result of building a rename projection from an event log. */
33
+ export interface RenameProjection {
34
+ /**
35
+ * Resolve an original (possibly stale) WU id to its current canonical id.
36
+ * If the id is not part of any rename chain, it is returned unchanged.
37
+ */
38
+ resolve(wuId: string): string;
39
+ /** List every rename link discovered, in event-log order. */
40
+ getAllRenames(): RenameLink[];
41
+ }
42
+ /**
43
+ * Walk the event log and return a {@link RenameProjection}.
44
+ *
45
+ * Algorithm:
46
+ * 1. Iterate events in order. For each `wu_renamed` event, compose the link
47
+ * into the transitive map. If an earlier rename produced `from`, update
48
+ * its target to `to` so the chain collapses on lookup.
49
+ * 2. Store all raw rename links for audit/debugging via getAllRenames().
50
+ *
51
+ * The returned projection is pure; callers may retain it or throw it away.
52
+ */
53
+ export declare function buildRenameProjection(events: readonly WUEvent[]): RenameProjection;
54
+ /**
55
+ * Convenience wrapper: build a projection and resolve a single id.
56
+ *
57
+ * Use this when you only need one lookup. For multiple lookups against the
58
+ * same event log, call {@link buildRenameProjection} once and keep the
59
+ * projection.
60
+ */
61
+ export declare function resolveRenamedWuId(events: readonly WUEvent[], wuId: string): string;
62
+ //# sourceMappingURL=wu-rename-projection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wu-rename-projection.d.ts","sourceRoot":"","sources":["../src/wu-rename-projection.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAkB,MAAM,sBAAsB,CAAC;AAGpE,sDAAsD;AACtD,MAAM,WAAW,UAAU;IACzB,6DAA6D;IAC7D,IAAI,EAAE,MAAM,CAAC;IACb,sDAAsD;IACtD,EAAE,EAAE,MAAM,CAAC;IACX,wDAAwD;IACxD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,8CAA8C;IAC9C,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,gEAAgE;AAChE,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAC9B,6DAA6D;IAC7D,aAAa,IAAI,UAAU,EAAE,CAAC;CAC/B;AAMD;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,SAAS,OAAO,EAAE,GAAG,gBAAgB,CAwClF;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAEnF"}
@@ -0,0 +1,66 @@
1
+ // Copyright (c) 2026 Hellmai Ltd
2
+ // SPDX-License-Identifier: AGPL-3.0-only
3
+ import { WU_EVENT_TYPE } from './wu-state-schema.js';
4
+ function isRenameEvent(event) {
5
+ return event.type === WU_EVENT_TYPE.WU_RENAMED;
6
+ }
7
+ /**
8
+ * Walk the event log and return a {@link RenameProjection}.
9
+ *
10
+ * Algorithm:
11
+ * 1. Iterate events in order. For each `wu_renamed` event, compose the link
12
+ * into the transitive map. If an earlier rename produced `from`, update
13
+ * its target to `to` so the chain collapses on lookup.
14
+ * 2. Store all raw rename links for audit/debugging via getAllRenames().
15
+ *
16
+ * The returned projection is pure; callers may retain it or throw it away.
17
+ */
18
+ export function buildRenameProjection(events) {
19
+ // Direct map: original id -> current id after all observed renames.
20
+ const forward = new Map();
21
+ // Raw rename links in order.
22
+ const links = [];
23
+ for (const event of events) {
24
+ if (!isRenameEvent(event)) {
25
+ continue;
26
+ }
27
+ const { from, to } = event;
28
+ const link = {
29
+ from,
30
+ to,
31
+ timestamp: event.timestamp,
32
+ ...(typeof event.reason === 'string' && event.reason.length > 0
33
+ ? { reason: event.reason }
34
+ : {}),
35
+ };
36
+ links.push(link);
37
+ // Compose: any prior entry whose target equals `from` now targets `to`.
38
+ // This keeps resolve() O(1) without recursive lookup at query time.
39
+ for (const [key, value] of forward) {
40
+ if (value === from) {
41
+ forward.set(key, to);
42
+ }
43
+ }
44
+ // Record the link itself; if already present, the final target wins.
45
+ forward.set(from, to);
46
+ }
47
+ return {
48
+ resolve(wuId) {
49
+ return forward.get(wuId) ?? wuId;
50
+ },
51
+ getAllRenames() {
52
+ return [...links];
53
+ },
54
+ };
55
+ }
56
+ /**
57
+ * Convenience wrapper: build a projection and resolve a single id.
58
+ *
59
+ * Use this when you only need one lookup. For multiple lookups against the
60
+ * same event log, call {@link buildRenameProjection} once and keep the
61
+ * projection.
62
+ */
63
+ export function resolveRenamedWuId(events, wuId) {
64
+ return buildRenameProjection(events).resolve(wuId);
65
+ }
66
+ //# sourceMappingURL=wu-rename-projection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wu-rename-projection.js","sourceRoot":"","sources":["../src/wu-rename-projection.ts"],"names":[],"mappings":"AAAA,iCAAiC;AACjC,yCAAyC;AAsBzC,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAyBrD,SAAS,aAAa,CAAC,KAAc;IACnC,OAAO,KAAK,CAAC,IAAI,KAAK,aAAa,CAAC,UAAU,CAAC;AACjD,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,qBAAqB,CAAC,MAA0B;IAC9D,oEAAoE;IACpE,MAAM,OAAO,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC1C,6BAA6B;IAC7B,MAAM,KAAK,GAAiB,EAAE,CAAC;IAE/B,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;YAC1B,SAAS;QACX,CAAC;QACD,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,KAAK,CAAC;QAC3B,MAAM,IAAI,GAAe;YACvB,IAAI;YACJ,EAAE;YACF,SAAS,EAAE,KAAK,CAAC,SAAS;YAC1B,GAAG,CAAC,OAAO,KAAK,CAAC,MAAM,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC;gBAC7D,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE;gBAC1B,CAAC,CAAC,EAAE,CAAC;SACR,CAAC;QACF,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEjB,wEAAwE;QACxE,oEAAoE;QACpE,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,OAAO,EAAE,CAAC;YACnC,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;gBACnB,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;YACvB,CAAC;QACH,CAAC;QACD,qEAAqE;QACrE,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IACxB,CAAC;IAED,OAAO;QACL,OAAO,CAAC,IAAY;YAClB,OAAO,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC;QACnC,CAAC;QACD,aAAa;YACX,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC;QACpB,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAA0B,EAAE,IAAY;IACzE,OAAO,qBAAqB,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AACrD,CAAC"}
@@ -13,15 +13,38 @@ export declare class WUStateIndexer {
13
13
  private byStatus;
14
14
  private byLane;
15
15
  private byParent;
16
+ /**
17
+ * Live rename map (WU-2552): original id -> current id after renames.
18
+ * Populated incrementally as wu_renamed events are applied.
19
+ * Used to route subsequent events referencing stale ids to their
20
+ * current canonical target.
21
+ */
22
+ private renameMap;
16
23
  constructor();
17
24
  /**
18
25
  * Clear all in-memory state and indexes.
19
26
  */
20
27
  clear(): void;
28
+ /**
29
+ * Resolve a (possibly stale) WU id to its current canonical id after
30
+ * any applied renames. Returns the input id unchanged when no rename
31
+ * chain maps it.
32
+ */
33
+ resolveRenamedWuId(wuId: string): string;
21
34
  /**
22
35
  * Apply an event to the in-memory state.
23
36
  */
24
37
  applyEvent(event: WUEvent): void;
38
+ /**
39
+ * Move WU state from an old id to a new id and record the rename link.
40
+ *
41
+ * - If no state exists under `from`, only the rename link is recorded
42
+ * (handles the replay-only case where the CLI command appended an
43
+ * event without having had an in-memory slot to move).
44
+ * - Any prior rename target that resolved to `from` is collapsed to `to`
45
+ * so the live map stays flat.
46
+ */
47
+ private _applyRename;
25
48
  /**
26
49
  * Get current in-memory state for a WU.
27
50
  */
@@ -1 +1 @@
1
- {"version":3,"file":"wu-state-indexer.d.ts","sourceRoot":"","sources":["../src/wu-state-indexer.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAiB,KAAK,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAGjF,YAAY,EAAE,YAAY,EAAE,iBAAiB,EAAE,CAAC;AAEhD;;;;;GAKG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,OAAO,CAA4B;IAC3C,OAAO,CAAC,QAAQ,CAA2B;IAC3C,OAAO,CAAC,MAAM,CAA2B;IACzC,OAAO,CAAC,QAAQ,CAA2B;;IAS3C;;OAEG;IACH,KAAK,IAAI,IAAI;IAOb;;OAEG;IACH,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAuDhC;;OAEG;IACH,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;IAIlD;;OAEG;IACH,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC;IAIxC;;OAEG;IACH,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC;IAIpC;;OAEG;IACH,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC;IAI5C;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAO3B;;OAEG;IACH,OAAO,CAAC,SAAS;CA+BlB"}
1
+ {"version":3,"file":"wu-state-indexer.d.ts","sourceRoot":"","sources":["../src/wu-state-indexer.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAiB,KAAK,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAGjF,YAAY,EAAE,YAAY,EAAE,iBAAiB,EAAE,CAAC;AAEhD;;;;;GAKG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,OAAO,CAA4B;IAC3C,OAAO,CAAC,QAAQ,CAA2B;IAC3C,OAAO,CAAC,MAAM,CAA2B;IACzC,OAAO,CAAC,QAAQ,CAA2B;IAC3C;;;;;OAKG;IACH,OAAO,CAAC,SAAS,CAAsB;;IAUvC;;OAEG;IACH,KAAK,IAAI,IAAI;IAQb;;;;OAIG;IACH,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAIxC;;OAEG;IACH,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAoEhC;;;;;;;;OAQG;IACH,OAAO,CAAC,YAAY;IAmCpB;;OAEG;IACH,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;IAIlD;;OAEG;IACH,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC;IAIxC;;OAEG;IACH,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC;IAIpC;;OAEG;IACH,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC;IAI5C;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAO3B;;OAEG;IACH,OAAO,CAAC,SAAS;CA+BlB"}
@@ -24,11 +24,19 @@ export class WUStateIndexer {
24
24
  byStatus;
25
25
  byLane;
26
26
  byParent;
27
+ /**
28
+ * Live rename map (WU-2552): original id -> current id after renames.
29
+ * Populated incrementally as wu_renamed events are applied.
30
+ * Used to route subsequent events referencing stale ids to their
31
+ * current canonical target.
32
+ */
33
+ renameMap;
27
34
  constructor() {
28
35
  this.wuState = new Map();
29
36
  this.byStatus = new Map();
30
37
  this.byLane = new Map();
31
38
  this.byParent = new Map();
39
+ this.renameMap = new Map();
32
40
  }
33
41
  /**
34
42
  * Clear all in-memory state and indexes.
@@ -38,12 +46,25 @@ export class WUStateIndexer {
38
46
  this.byStatus.clear();
39
47
  this.byLane.clear();
40
48
  this.byParent.clear();
49
+ this.renameMap.clear();
50
+ }
51
+ /**
52
+ * Resolve a (possibly stale) WU id to its current canonical id after
53
+ * any applied renames. Returns the input id unchanged when no rename
54
+ * chain maps it.
55
+ */
56
+ resolveRenamedWuId(wuId) {
57
+ return this.renameMap.get(wuId) ?? wuId;
41
58
  }
42
59
  /**
43
60
  * Apply an event to the in-memory state.
44
61
  */
45
62
  applyEvent(event) {
46
- const { wuId, type } = event;
63
+ const { type } = event;
64
+ // WU-2552: Route every event's wuId through the live rename map so that
65
+ // historical events referencing ids that were later renamed land on the
66
+ // correct current-state slot.
67
+ const wuId = this.resolveRenamedWuId(event.wuId);
47
68
  if (type === WU_EVENT_TYPE.CREATE || type === WU_EVENT_TYPE.CLAIM) {
48
69
  // Discriminated union narrows to CreateEvent | ClaimEvent (both have lane/title)
49
70
  this._setState(wuId, WU_STATUS.IN_PROGRESS, event.lane, event.title);
@@ -77,7 +98,7 @@ export class WUStateIndexer {
77
98
  }
78
99
  if (type === WU_EVENT_TYPE.DELEGATION) {
79
100
  // Discriminated union narrows to DelegationEvent (has parentWuId)
80
- const { parentWuId } = event;
101
+ const parentWuId = this.resolveRenamedWuId(event.parentWuId);
81
102
  if (!this.byParent.has(parentWuId)) {
82
103
  this.byParent.set(parentWuId, new Set());
83
104
  }
@@ -87,6 +108,53 @@ export class WUStateIndexer {
87
108
  // WU-1080: Handle release event - transitions from in_progress to ready
88
109
  if (type === WU_EVENT_TYPE.RELEASE) {
89
110
  this._transitionToStatus(wuId, WU_STATUS.READY);
111
+ return;
112
+ }
113
+ // WU-2552: Handle wu_renamed event - move any existing state from
114
+ // `from` to `to` and record the rename in the live map so subsequent
115
+ // events referencing `from` land on `to`.
116
+ if (type === WU_EVENT_TYPE.WU_RENAMED) {
117
+ this._applyRename(event.from, event.to);
118
+ }
119
+ }
120
+ /**
121
+ * Move WU state from an old id to a new id and record the rename link.
122
+ *
123
+ * - If no state exists under `from`, only the rename link is recorded
124
+ * (handles the replay-only case where the CLI command appended an
125
+ * event without having had an in-memory slot to move).
126
+ * - Any prior rename target that resolved to `from` is collapsed to `to`
127
+ * so the live map stays flat.
128
+ */
129
+ _applyRename(from, to) {
130
+ // Collapse prior chains: anything that targeted `from` now targets `to`.
131
+ for (const [key, value] of this.renameMap) {
132
+ if (value === from) {
133
+ this.renameMap.set(key, to);
134
+ }
135
+ }
136
+ this.renameMap.set(from, to);
137
+ const existing = this.wuState.get(from);
138
+ if (!existing) {
139
+ // Nothing to move; the live map update alone is sufficient.
140
+ return;
141
+ }
142
+ // Move the state entry and update indexes.
143
+ this.wuState.delete(from);
144
+ const statusSet = this.byStatus.get(existing.status);
145
+ statusSet?.delete(from);
146
+ const laneSet = this.byLane.get(existing.lane);
147
+ laneSet?.delete(from);
148
+ this._setState(to, existing.status, existing.lane, existing.title);
149
+ const moved = this.wuState.get(to);
150
+ if (moved && existing.completedAt) {
151
+ moved.completedAt = existing.completedAt;
152
+ }
153
+ if (moved && existing.lastCheckpoint) {
154
+ moved.lastCheckpoint = existing.lastCheckpoint;
155
+ }
156
+ if (moved && existing.lastCheckpointNote) {
157
+ moved.lastCheckpointNote = existing.lastCheckpointNote;
90
158
  }
91
159
  }
92
160
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"wu-state-indexer.js","sourceRoot":"","sources":["../src/wu-state-indexer.ts"],"names":[],"mappings":"AAAA,iCAAiC;AACjC,yCAAyC;AAEzC;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAgB,MAAM,sBAAsB,CAAC;AAMnE;;;;;GAKG;AACH,MAAM,OAAO,cAAc;IACjB,OAAO,CAA4B;IACnC,QAAQ,CAA2B;IACnC,MAAM,CAA2B;IACjC,QAAQ,CAA2B;IAE3C;QACE,IAAI,CAAC,OAAO,GAAG,IAAI,GAAG,EAAE,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,IAAI,GAAG,EAAE,CAAC;QAC1B,IAAI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C,GAAG,CAAC,IAAI,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC;QACnC,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC;CACF"}
@@ -19,8 +19,9 @@ import { z } from 'zod';
19
19
  * - checkpoint: Progress checkpoint (WU-1748: cross-agent visibility)
20
20
  * - delegation: WU delegated from parent (WU-1947: parent-child relationships)
21
21
  * - release: WU released (WU-1080: transitions from in_progress to ready for orphan recovery)
22
+ * - wu_renamed: WU id canonicalized or normalized (WU-2552: append-only rename, never rewrites history)
22
23
  */
23
- export declare const WU_EVENT_TYPES: readonly ["create", "claim", "block", "unblock", "complete", "checkpoint", "delegation", "release"];
24
+ export declare const WU_EVENT_TYPES: readonly ["create", "claim", "block", "unblock", "complete", "checkpoint", "delegation", "release", "wu_renamed"];
24
25
  /** Type for WU event types */
25
26
  export type WUEventType = (typeof WU_EVENT_TYPES)[number];
26
27
  /**
@@ -38,6 +39,7 @@ export declare const WU_EVENT_TYPE: Readonly<{
38
39
  CHECKPOINT: "checkpoint";
39
40
  DELEGATION: "delegation";
40
41
  RELEASE: "release";
42
+ WU_RENAMED: "wu_renamed";
41
43
  }>;
42
44
  /**
43
45
  * WU status values (matches LumenFlow state machine)
@@ -132,6 +134,28 @@ export declare const ReleaseEventSchema: z.ZodObject<{
132
134
  type: z.ZodLiteral<"release">;
133
135
  reason: z.ZodString;
134
136
  }, z.core.$strip>;
137
+ /**
138
+ * WU renamed event schema (WU-2552: canonical WU IDs)
139
+ *
140
+ * Records a WU id change without rewriting history. Historical events
141
+ * before the rename keep their original wuId field (audit trail intact).
142
+ * Projections use {@link buildRenameProjection} to resolve an original id
143
+ * to its current canonical id.
144
+ *
145
+ * Invariants:
146
+ * - `wuId` field mirrors `from` so filter-by-wuId still returns this event
147
+ * for queries about the original id.
148
+ * - `from` and `to` accept any WU ID matching WU_PATTERNS.WU_ID, which is
149
+ * intentionally permissive (matches both padded and unpadded legacy IDs).
150
+ */
151
+ export declare const WURenamedEventSchema: z.ZodObject<{
152
+ wuId: z.ZodString;
153
+ timestamp: z.ZodString;
154
+ type: z.ZodLiteral<"wu_renamed">;
155
+ from: z.ZodString;
156
+ to: z.ZodString;
157
+ reason: z.ZodOptional<z.ZodString>;
158
+ }, z.core.$strip>;
135
159
  /**
136
160
  * Union schema for all event types
137
161
  */
@@ -179,6 +203,13 @@ export declare const WUEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
179
203
  timestamp: z.ZodString;
180
204
  type: z.ZodLiteral<"release">;
181
205
  reason: z.ZodString;
206
+ }, z.core.$strip>, z.ZodObject<{
207
+ wuId: z.ZodString;
208
+ timestamp: z.ZodString;
209
+ type: z.ZodLiteral<"wu_renamed">;
210
+ from: z.ZodString;
211
+ to: z.ZodString;
212
+ reason: z.ZodOptional<z.ZodString>;
182
213
  }, z.core.$strip>], "type">;
183
214
  /**
184
215
  * TypeScript types inferred from schemas
@@ -191,6 +222,7 @@ export type CompleteEvent = z.infer<typeof CompleteEventSchema>;
191
222
  export type CheckpointEvent = z.infer<typeof CheckpointEventSchema>;
192
223
  export type DelegationEvent = z.infer<typeof DelegationEventSchema>;
193
224
  export type ReleaseEvent = z.infer<typeof ReleaseEventSchema>;
225
+ export type WURenamedEvent = z.infer<typeof WURenamedEventSchema>;
194
226
  export type WUEvent = z.infer<typeof WUEventSchema>;
195
227
  /**
196
228
  * Validates WU event data against schema
@@ -250,5 +282,12 @@ export declare function validateWUEvent(data: unknown): z.ZodSafeParseResult<{
250
282
  timestamp: string;
251
283
  type: "release";
252
284
  reason: string;
285
+ } | {
286
+ wuId: string;
287
+ timestamp: string;
288
+ type: "wu_renamed";
289
+ from: string;
290
+ to: string;
291
+ reason?: string | undefined;
253
292
  }>;
254
293
  //# sourceMappingURL=wu-state-schema.d.ts.map