@sentropic/track 0.98.10 → 0.98.11-rc.5

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 (80) hide show
  1. package/README.md +17 -6
  2. package/dist/cli/index.d.ts.map +1 -1
  3. package/dist/cli/index.js +136 -5
  4. package/dist/cli/index.js.map +1 -1
  5. package/dist/cli/resolve.d.ts.map +1 -1
  6. package/dist/cli/resolve.js +9 -0
  7. package/dist/cli/resolve.js.map +1 -1
  8. package/dist/events/types.d.ts +1 -1
  9. package/dist/events/types.d.ts.map +1 -1
  10. package/dist/events/types.js +5 -0
  11. package/dist/events/types.js.map +1 -1
  12. package/dist/focus-vendor/cli/index.d.ts +1 -1
  13. package/dist/graph-export.d.ts +19 -0
  14. package/dist/graph-export.d.ts.map +1 -1
  15. package/dist/graph-export.js +53 -0
  16. package/dist/graph-export.js.map +1 -1
  17. package/dist/model/blocker.d.ts +2 -0
  18. package/dist/model/blocker.d.ts.map +1 -1
  19. package/dist/model/blocker.js.map +1 -1
  20. package/dist/model/decision.d.ts +4 -0
  21. package/dist/model/decision.d.ts.map +1 -1
  22. package/dist/model/decision.js.map +1 -1
  23. package/dist/model/demand.d.ts +15 -0
  24. package/dist/model/demand.d.ts.map +1 -1
  25. package/dist/model/demand.js.map +1 -1
  26. package/dist/model/item.d.ts +3 -1
  27. package/dist/model/item.d.ts.map +1 -1
  28. package/dist/model/item.js.map +1 -1
  29. package/dist/model/report-status.d.ts +124 -21
  30. package/dist/model/report-status.d.ts.map +1 -1
  31. package/dist/model/report-status.js +372 -38
  32. package/dist/model/report-status.js.map +1 -1
  33. package/dist/read/commands.d.ts +6 -0
  34. package/dist/read/commands.d.ts.map +1 -1
  35. package/dist/read/commands.js +19 -0
  36. package/dist/read/commands.js.map +1 -1
  37. package/dist/read/contract.d.ts +8 -0
  38. package/dist/read/contract.d.ts.map +1 -1
  39. package/dist/read/contract.js +21 -0
  40. package/dist/read/contract.js.map +1 -1
  41. package/dist/read/index.d.ts +2 -2
  42. package/dist/read/index.d.ts.map +1 -1
  43. package/dist/read/index.js +1 -1
  44. package/dist/read/index.js.map +1 -1
  45. package/dist/report/audit.d.ts +2 -19
  46. package/dist/report/audit.d.ts.map +1 -1
  47. package/dist/report/audit.js +9 -26
  48. package/dist/report/audit.js.map +1 -1
  49. package/dist/report/index.d.ts +2 -0
  50. package/dist/report/index.d.ts.map +1 -1
  51. package/dist/report/index.js +2 -0
  52. package/dist/report/index.js.map +1 -1
  53. package/dist/report/owner-table.d.ts +142 -0
  54. package/dist/report/owner-table.d.ts.map +1 -0
  55. package/dist/report/owner-table.js +1586 -0
  56. package/dist/report/owner-table.js.map +1 -0
  57. package/dist/report/stage-status-lexicon.d.ts.map +1 -1
  58. package/dist/report/stage-status-lexicon.js +61 -37
  59. package/dist/report/stage-status-lexicon.js.map +1 -1
  60. package/dist/report/stage-status.d.ts +20 -9
  61. package/dist/report/stage-status.d.ts.map +1 -1
  62. package/dist/report/stage-status.js +211 -85
  63. package/dist/report/stage-status.js.map +1 -1
  64. package/dist/report/velocity-eta.d.ts +81 -0
  65. package/dist/report/velocity-eta.d.ts.map +1 -0
  66. package/dist/report/velocity-eta.js +217 -0
  67. package/dist/report/velocity-eta.js.map +1 -0
  68. package/dist/state/fold.d.ts +11 -0
  69. package/dist/state/fold.d.ts.map +1 -1
  70. package/dist/state/fold.js +437 -7
  71. package/dist/state/fold.js.map +1 -1
  72. package/dist/track.d.ts +53 -1
  73. package/dist/track.d.ts.map +1 -1
  74. package/dist/track.js +297 -4
  75. package/dist/track.js.map +1 -1
  76. package/dist/workspace-id.d.ts.map +1 -1
  77. package/dist/workspace-id.js +5 -0
  78. package/dist/workspace-id.js.map +1 -1
  79. package/package.json +1 -1
  80. package/registry/entries.v1.json +1 -1
@@ -1,30 +1,111 @@
1
1
  /**
2
- * Neutral stage codes (D2) — the identity carried by JSON, never localised
3
- * words. B1 (Lot L1) adds `review` and `published` as READERS first: the write
4
- * grammar stays `WRITABLE_REPORT_STAGES` until Lot L5 opens the writers. The
5
- * 2026-10-17 French values (`mergé`/`déployé`) and `PR` are legacy aliases:
6
- * normalised on read (`normalizeReportStage`, fold-time), rejected on new
7
- * writes (`assertItemReportStatus`). Historical events are never rewritten.
2
+ * Neutral stage codes (D2, D5) — the 12 ordered workflow stages carried by JSON,
3
+ * never localised words. Historical 2026-10-17 French values (`mergé`/`déployé`),
4
+ * `PR`, and bare `deployed` are legacy aliases: normalised on read
5
+ * (`normalizeReportStage`, fold-time), rejected on new writes
6
+ * (`assertItemReportStatus`). Historical events are never rewritten.
8
7
  */
9
- export declare const REPORT_STAGES: readonly ["spec", "dev", "pr", "review", "merged", "published", "deployed"];
8
+ export declare const REPORT_STAGES: readonly ["brainstorm", "spec", "plan", "dev", "test", "pr", "review", "merged", "published", "preprod", "prod", "done"];
10
9
  export type ReportStage = typeof REPORT_STAGES[number];
11
- /** Stages accepted on NEW writes (B1 Lot L1): the `review`/`published` writers open in Lot L5. */
12
- export declare const WRITABLE_REPORT_STAGES: readonly ["spec", "dev", "pr", "merged", "deployed"];
13
- export declare const REPORT_STATUSES: readonly ["progressing", "unforeseen", "blocked", "decision-awaited", "not-qualified", "withdrawn"];
10
+ /**
11
+ * Only the 10 pre-production stages can be asserted via `item.report.stage` on writes;
12
+ * `prod` and `done` require recorded delivery and acceptance links (`deployed-prod` +
13
+ * `prod-accepted` / `uat-accepted`).
14
+ */
15
+ export declare const WRITABLE_REPORT_STAGES: readonly ["brainstorm", "spec", "plan", "dev", "test", "pr", "review", "merged", "published", "preprod"];
16
+ /**
17
+ * Neutral status codes (D2, D6, Owner Decision 14/11):
18
+ * - `withdrawn` -> ⚫ retiré
19
+ * - `blocked` -> 🔴 bloqué
20
+ * - `unforeseen` -> 🟠 dérive
21
+ * - `waiting` -> 🟡 en attente
22
+ * - `done` -> ✅ fait
23
+ * - `on-track` -> 🔵 sur la voie
24
+ * - `not-started` -> ⚪ pas commencé / en pause
25
+ * - `not-qualified` -> — sans témoin
26
+ * Note: `decision-awaited` is no longer a status (blocking decisions make the row `blocked`).
27
+ */
28
+ export declare const REPORT_STATUSES: readonly ["withdrawn", "blocked", "unforeseen", "waiting", "done", "on-track", "not-started", "not-qualified"];
14
29
  export type ReportStatus = typeof REPORT_STATUSES[number];
15
30
  /**
16
31
  * Map a stored stage value to its neutral code. Returns `undefined` for an
17
32
  * unknown value (the caller then ignores the stored stage rather than
18
- * inventing one). Neutral codes map to themselves.
33
+ * inventing one). Neutral codes map to themselves. An old `deployed` / `déployé`
34
+ * with no environment (or a non-prod locator) maps to `preprod`.
19
35
  */
20
- export declare function normalizeReportStage(value: unknown): ReportStage | undefined;
36
+ export declare function normalizeReportStage(value: unknown, evidence?: unknown): ReportStage | undefined;
37
+ /**
38
+ * Map a stored status value to its neutral code. Returns `undefined` for
39
+ * `decision-awaited` (no longer a status) or unknown values.
40
+ */
41
+ export declare function normalizeReportStatus(value: unknown): ReportStatus | undefined;
42
+ export type ReportEtaSource = 'measured' | 'committed' | 'unknown';
43
+ export interface MeasuredVelocityProvenance {
44
+ predictedAt: string;
45
+ evidenceCutoff: string;
46
+ p80Seconds: number;
47
+ sampleCount: number;
48
+ support: 'descriptive';
49
+ lockedDigest: string;
50
+ currentDigest: string;
51
+ }
52
+ export interface EtaSlipRecord {
53
+ fromWhen: string;
54
+ toWhen: string;
55
+ at: string;
56
+ reason?: string;
57
+ rebaselineDecisionId?: string;
58
+ }
59
+ export interface ReportEtaEntry {
60
+ targetStage: ReportStage;
61
+ /** Target stage label qualification (e.g. `MEP` for `prod (MEP)`). */
62
+ targetLabel?: string;
63
+ /** ISO-8601 date token (`YYYY-MM-DD`) or `—` when unknown. */
64
+ when: string;
65
+ source: ReportEtaSource;
66
+ /** Required when `source === 'committed'`. */
67
+ by?: string;
68
+ /** Optional slip annotation when the initial ETA was missed or moved. */
69
+ slip?: {
70
+ initialWhen: string;
71
+ reason?: string;
72
+ };
73
+ /** Required when `source === 'measured'`: provenance from `qualifyVelocityEta` (#376). */
74
+ measured?: MeasuredVelocityProvenance;
75
+ }
76
+ export interface EtaJournalEntry extends ReportEtaEntry {
77
+ /** First non-blank `when` recorded for `targetStage` (or re-anchored by a settled `go` decision). */
78
+ initialWhen: string;
79
+ /** ISO-8601 timestamp of the latest `eta-set` event on this slot. */
80
+ updatedAt: string;
81
+ /** Monotonic stream index of the latest `eta-set` event on this slot. */
82
+ updatedOrder?: number;
83
+ /** Append-only slip history for this `targetStage` slot. */
84
+ slips: EtaSlipRecord[];
85
+ /** Optional settled `'go'` decision that re-baselined `initialWhen` on the latest event. */
86
+ rebaselineDecisionId?: string;
87
+ /** All settled `'go'` decision IDs ever consumed to rebaseline this slot (each `'go'` decision rebaselines once). */
88
+ rebaselineDecisionIds?: string[];
89
+ /** True when explicitly acknowledged as delivered on time (extinguishes a demand-level ETA without cross-lot reads). */
90
+ delivered?: boolean;
91
+ }
92
+ export interface SetEtaInput {
93
+ targetStage: ReportStage;
94
+ targetLabel?: string;
95
+ when?: string;
96
+ source?: ReportEtaSource;
97
+ by?: string;
98
+ reason?: string;
99
+ rebaselineDecisionId?: string;
100
+ measured?: MeasuredVelocityProvenance;
101
+ delivered?: boolean;
102
+ }
21
103
  /**
22
104
  * Read-path tolerance for a stored report assertion (fold + derivation).
23
- * Historical 2026-10-17 French stage values read as neutral codes; the
24
- * events themselves are never rewritten. Unknown stage values are dropped
25
- * (the caller ignores the stored stage rather than inventing one). This is
26
- * the READ path — new writes still go through `assertItemReportStatus`, which
27
- * rejects the legacy values.
105
+ * Historical stage/status values read as neutral codes; the events themselves
106
+ * are never rewritten. Unknown stage values and retired `decision-awaited`
107
+ * statuses are dropped on read. New writes still go through
108
+ * `assertItemReportStatus`, which rejects legacy values.
28
109
  */
29
110
  export declare function normalizeStoredReport(value: unknown): ItemReportStatus;
30
111
  export interface DecisionExpectations {
@@ -40,6 +121,9 @@ export interface DecisionExpectations {
40
121
  /** Full replacement, display-only record. Does not mutate realization, acceptance or decisions. */
41
122
  export interface ItemReportStatus {
42
123
  ownerRequest?: string;
124
+ ownerNumber?: number;
125
+ ownerSummary?: string;
126
+ requestedStage?: ReportStage;
43
127
  stage?: {
44
128
  value: ReportStage;
45
129
  evidence?: string;
@@ -51,13 +135,32 @@ export interface ItemReportStatus {
51
135
  nextAction?: string;
52
136
  waitingOn?: string;
53
137
  suspended?: string;
138
+ pausedByOwner?: boolean;
139
+ pauseDecisionId?: string;
140
+ etas?: ReportEtaEntry[];
141
+ decisionRefs?: string[];
142
+ decisionBlocking?: boolean;
143
+ archived?: {
144
+ decisionId: string;
145
+ reason: string;
146
+ };
54
147
  }
148
+ export declare function isValidIsoDateToken(value: string): boolean;
55
149
  export declare function assertDecisionExpectations(value: unknown): asserts value is DecisionExpectations;
150
+ export declare function isValidMeasuredVelocityProvenance(value: unknown): value is MeasuredVelocityProvenance;
151
+ export declare function assertReportEtaEntry(value: unknown, grammar?: 'read' | 'write'): asserts value is ReportEtaEntry;
152
+ export declare function assertSetEtaInput(value: unknown, options?: {
153
+ allowMeasured?: boolean;
154
+ }): SetEtaInput & {
155
+ when: string;
156
+ source: ReportEtaSource;
157
+ };
158
+ /** High stages that always require a recorded evidence locator. */
159
+ export declare const EVIDENCE_REQUIRED_STAGES: readonly ReportStage[];
56
160
  /**
57
- * Validate a report assertion. The default `'write'` grammar accepts only
58
- * `WRITABLE_REPORT_STAGES` (B1 Lot L1: the `review`/`published` writers open
59
- * in Lot L5); `'read'` accepts the full `REPORT_STAGES` grammar, so a stored
60
- * review/published assertion still asserts on the fold/derivation path.
161
+ * Validate a report assertion. `'read'` accepts all 12 neutral stages in `REPORT_STAGES`;
162
+ * `'write'` accepts the 10 pre-prod stages in `WRITABLE_REPORT_STAGES` (`prod` and `done`
163
+ * require recorded links) and the 8 neutral statuses in `REPORT_STATUSES`.
61
164
  */
62
165
  export declare function assertItemReportStatus(value: unknown, grammar?: 'read' | 'write'): asserts value is ItemReportStatus;
63
166
  //# sourceMappingURL=report-status.d.ts.map
@@ -1 +1 @@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CAc1D;AAED,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,KAAK,IAAI,oBAAoB,CAehG;AAID,wBAAgB,iCAAiC,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,0BAA0B,CA8BrG;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,GAAE,MAAM,GAAG,OAAiB,GAAG,OAAO,CAAC,KAAK,IAAI,cAAc,CAoCzH;AAED,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,OAAO,EACd,OAAO,GAAE;IAAE,aAAa,CAAC,EAAE,OAAO,CAAA;CAAO,GACxC,WAAW,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,eAAe,CAAA;CAAE,CAiFzD;AAED,mEAAmE;AACnE,eAAO,MAAM,wBAAwB,EAAE,SAAS,WAAW,EAQjD,CAAA;AAEV;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,GAAE,MAAM,GAAG,OAAiB,GAAG,OAAO,CAAC,KAAK,IAAI,gBAAgB,CAyE7H"}
@@ -1,59 +1,156 @@
1
1
  import { DomainError } from './item.js';
2
2
  /**
3
- * Neutral stage codes (D2) — the identity carried by JSON, never localised
4
- * words. B1 (Lot L1) adds `review` and `published` as READERS first: the write
5
- * grammar stays `WRITABLE_REPORT_STAGES` until Lot L5 opens the writers. The
6
- * 2026-10-17 French values (`mergé`/`déployé`) and `PR` are legacy aliases:
7
- * normalised on read (`normalizeReportStage`, fold-time), rejected on new
8
- * writes (`assertItemReportStatus`). Historical events are never rewritten.
3
+ * Neutral stage codes (D2, D5) — the 12 ordered workflow stages carried by JSON,
4
+ * never localised words. Historical 2026-10-17 French values (`mergé`/`déployé`),
5
+ * `PR`, and bare `deployed` are legacy aliases: normalised on read
6
+ * (`normalizeReportStage`, fold-time), rejected on new writes
7
+ * (`assertItemReportStatus`). Historical events are never rewritten.
9
8
  */
10
- export const REPORT_STAGES = ['spec', 'dev', 'pr', 'review', 'merged', 'published', 'deployed'];
11
- /** Stages accepted on NEW writes (B1 Lot L1): the `review`/`published` writers open in Lot L5. */
12
- export const WRITABLE_REPORT_STAGES = ['spec', 'dev', 'pr', 'merged', 'deployed'];
13
- export const REPORT_STATUSES = ['progressing', 'unforeseen', 'blocked', 'decision-awaited', 'not-qualified', 'withdrawn'];
9
+ export const REPORT_STAGES = [
10
+ 'brainstorm',
11
+ 'spec',
12
+ 'plan',
13
+ 'dev',
14
+ 'test',
15
+ 'pr',
16
+ 'review',
17
+ 'merged',
18
+ 'published',
19
+ 'preprod',
20
+ 'prod',
21
+ 'done',
22
+ ];
23
+ /**
24
+ * Only the 10 pre-production stages can be asserted via `item.report.stage` on writes;
25
+ * `prod` and `done` require recorded delivery and acceptance links (`deployed-prod` +
26
+ * `prod-accepted` / `uat-accepted`).
27
+ */
28
+ export const WRITABLE_REPORT_STAGES = [
29
+ 'brainstorm',
30
+ 'spec',
31
+ 'plan',
32
+ 'dev',
33
+ 'test',
34
+ 'pr',
35
+ 'review',
36
+ 'merged',
37
+ 'published',
38
+ 'preprod',
39
+ ];
40
+ /**
41
+ * Neutral status codes (D2, D6, Owner Decision 14/11):
42
+ * - `withdrawn` -> ⚫ retiré
43
+ * - `blocked` -> 🔴 bloqué
44
+ * - `unforeseen` -> 🟠 dérive
45
+ * - `waiting` -> 🟡 en attente
46
+ * - `done` -> ✅ fait
47
+ * - `on-track` -> 🔵 sur la voie
48
+ * - `not-started` -> ⚪ pas commencé / en pause
49
+ * - `not-qualified` -> — sans témoin
50
+ * Note: `decision-awaited` is no longer a status (blocking decisions make the row `blocked`).
51
+ */
52
+ export const REPORT_STATUSES = [
53
+ 'withdrawn',
54
+ 'blocked',
55
+ 'unforeseen',
56
+ 'waiting',
57
+ 'done',
58
+ 'on-track',
59
+ 'not-started',
60
+ 'not-qualified',
61
+ ];
14
62
  /** Legacy stored stage values mapped to their neutral code (read path only). */
15
63
  const LEGACY_STAGE_ALIASES = {
16
64
  PR: 'pr',
17
65
  'mergé': 'merged',
18
- 'déployé': 'deployed',
66
+ 'préprod': 'preprod',
19
67
  'revue': 'review',
20
68
  'en revue': 'review',
21
69
  'publié': 'published',
22
70
  'publication': 'published',
71
+ bench: 'brainstorm',
72
+ benchmark: 'brainstorm',
73
+ cadrage: 'brainstorm',
74
+ 'dév': 'dev',
23
75
  };
76
+ /** Legacy stored status values mapped to their neutral code (read path only). */
77
+ const LEGACY_STATUS_ALIASES = {
78
+ progressing: 'on-track',
79
+ ontrack: 'on-track',
80
+ drift: 'unforeseen',
81
+ idle: 'not-started',
82
+ nowitness: 'not-qualified',
83
+ };
84
+ function isProdEvidenceLocator(evidence) {
85
+ if (typeof evidence !== 'string')
86
+ return false;
87
+ const trimmed = evidence.trim();
88
+ if (!/^prod:/iu.test(trimmed))
89
+ return false;
90
+ return !/(?:-rc\.|staging|preprod|canary)/iu.test(trimmed);
91
+ }
24
92
  /**
25
93
  * Map a stored stage value to its neutral code. Returns `undefined` for an
26
94
  * unknown value (the caller then ignores the stored stage rather than
27
- * inventing one). Neutral codes map to themselves.
95
+ * inventing one). Neutral codes map to themselves. An old `deployed` / `déployé`
96
+ * with no environment (or a non-prod locator) maps to `preprod`.
28
97
  */
29
- export function normalizeReportStage(value) {
98
+ export function normalizeReportStage(value, evidence) {
30
99
  if (typeof value !== 'string')
31
100
  return undefined;
32
101
  if (REPORT_STAGES.includes(value))
33
102
  return value;
103
+ if (value === 'deployed' || value === 'déployé') {
104
+ return isProdEvidenceLocator(evidence) ? 'prod' : 'preprod';
105
+ }
34
106
  return LEGACY_STAGE_ALIASES[value];
35
107
  }
108
+ /**
109
+ * Map a stored status value to its neutral code. Returns `undefined` for
110
+ * `decision-awaited` (no longer a status) or unknown values.
111
+ */
112
+ export function normalizeReportStatus(value) {
113
+ if (typeof value !== 'string')
114
+ return undefined;
115
+ if (REPORT_STATUSES.includes(value))
116
+ return value;
117
+ return LEGACY_STATUS_ALIASES[value];
118
+ }
36
119
  /**
37
120
  * Read-path tolerance for a stored report assertion (fold + derivation).
38
- * Historical 2026-10-17 French stage values read as neutral codes; the
39
- * events themselves are never rewritten. Unknown stage values are dropped
40
- * (the caller ignores the stored stage rather than inventing one). This is
41
- * the READ path — new writes still go through `assertItemReportStatus`, which
42
- * rejects the legacy values.
121
+ * Historical stage/status values read as neutral codes; the events themselves
122
+ * are never rewritten. Unknown stage values and retired `decision-awaited`
123
+ * statuses are dropped on read. New writes still go through
124
+ * `assertItemReportStatus`, which rejects legacy values.
43
125
  */
44
126
  export function normalizeStoredReport(value) {
127
+ if (!value || typeof value !== 'object' || Array.isArray(value)) {
128
+ return value;
129
+ }
45
130
  const source = value;
46
- const stored = source.stage;
47
- if (stored === undefined || typeof stored !== 'object' || stored === null) {
48
- return { ...value };
131
+ const copy = { ...value };
132
+ const storedStage = source.stage;
133
+ if (storedStage !== undefined && typeof storedStage === 'object' && storedStage !== null) {
134
+ const normalizedStage = normalizeReportStage(storedStage.value, storedStage.evidence);
135
+ if (normalizedStage === undefined) {
136
+ delete copy['stage'];
137
+ }
138
+ else {
139
+ copy['stage'] = { ...storedStage, value: normalizedStage };
140
+ }
49
141
  }
50
- const normalized = normalizeReportStage(stored.value);
51
- if (normalized === undefined) {
52
- const { stage: _dropped, ...rest } = value;
53
- void _dropped;
54
- return { ...rest };
142
+ if (source.status !== undefined) {
143
+ if (source.status === 'decision-awaited') {
144
+ delete copy['status'];
145
+ }
146
+ else {
147
+ const normalizedStatus = normalizeReportStatus(source.status);
148
+ if (normalizedStatus !== undefined) {
149
+ copy['status'] = normalizedStatus;
150
+ }
151
+ }
55
152
  }
56
- return { ...value, stage: { ...stored, value: normalized } };
153
+ return copy;
57
154
  }
58
155
  const object = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
59
156
  const text = (v) => typeof v === 'string' && v.trim().length > 0;
@@ -62,6 +159,21 @@ function keys(v, allowed) {
62
159
  if (Object.keys(v).some(k => !allowed.includes(k)))
63
160
  fail('unknown field');
64
161
  }
162
+ export function isValidIsoDateToken(value) {
163
+ const trimmed = value.trim();
164
+ const match = /^(\d{4})-(\d{2})-(\d{2})(?:T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2}))?$/u.exec(trimmed);
165
+ if (!match)
166
+ return false;
167
+ const year = Number(match[1]);
168
+ const month = Number(match[2]);
169
+ const day = Number(match[3]);
170
+ if (month < 1 || month > 12 || day < 1 || day > 31)
171
+ return false;
172
+ const probe = new Date(Date.UTC(year, month - 1, day));
173
+ return (probe.getUTCFullYear() === year &&
174
+ probe.getUTCMonth() === month - 1 &&
175
+ probe.getUTCDate() === day);
176
+ }
65
177
  export function assertDecisionExpectations(value) {
66
178
  if (!object(value))
67
179
  fail('decisionExpectations must be an object');
@@ -86,20 +198,244 @@ export function assertDecisionExpectations(value) {
86
198
  if (words > 400)
87
199
  fail('decision summary exceeds 400 words (two minutes)');
88
200
  }
201
+ const UNMEASURED_EARLY_STAGES = new Set(['brainstorm', 'spec', 'plan']);
202
+ export function isValidMeasuredVelocityProvenance(value) {
203
+ if (!object(value))
204
+ return false;
205
+ const allowed = [
206
+ 'predictedAt',
207
+ 'evidenceCutoff',
208
+ 'p80Seconds',
209
+ 'sampleCount',
210
+ 'support',
211
+ 'lockedDigest',
212
+ 'currentDigest',
213
+ ];
214
+ if (Object.keys(value).some((k) => !allowed.includes(k)))
215
+ return false;
216
+ if (value['support'] !== 'descriptive')
217
+ return false;
218
+ if (typeof value['p80Seconds'] !== 'number' || !Number.isFinite(value['p80Seconds']) || value['p80Seconds'] <= 0) {
219
+ return false;
220
+ }
221
+ if (typeof value['sampleCount'] !== 'number' ||
222
+ !Number.isInteger(value['sampleCount']) ||
223
+ value['sampleCount'] <= 0) {
224
+ return false;
225
+ }
226
+ if (!text(value['predictedAt']) || !text(value['evidenceCutoff']))
227
+ return false;
228
+ const predictedMs = Date.parse(value['predictedAt']);
229
+ const cutoffMs = Date.parse(value['evidenceCutoff']);
230
+ if (Number.isNaN(predictedMs) || Number.isNaN(cutoffMs) || cutoffMs > predictedMs)
231
+ return false;
232
+ if (!text(value['lockedDigest']) || !text(value['currentDigest']))
233
+ return false;
234
+ if (value['lockedDigest'].trim() !== value['currentDigest'].trim())
235
+ return false;
236
+ return true;
237
+ }
238
+ export function assertReportEtaEntry(value, grammar = 'write') {
239
+ if (!object(value))
240
+ fail('eta entry must be an object');
241
+ keys(value, ['targetStage', 'targetLabel', 'when', 'source', 'by', 'slip', 'measured']);
242
+ if (!REPORT_STAGES.includes(value['targetStage']))
243
+ fail('eta targetStage must be a valid stage');
244
+ if (value['targetLabel'] !== undefined && !text(value['targetLabel']))
245
+ fail('eta targetLabel must be non-empty');
246
+ if (!text(value['when']))
247
+ fail('eta when is required');
248
+ if (value['source'] !== 'measured' && value['source'] !== 'committed' && value['source'] !== 'unknown') {
249
+ fail('eta source must be measured, committed or unknown');
250
+ }
251
+ if (value['measured'] !== undefined && !isValidMeasuredVelocityProvenance(value['measured'])) {
252
+ fail('eta measured provenance is invalid');
253
+ }
254
+ if (grammar === 'write' &&
255
+ value['source'] === 'measured' &&
256
+ (!isValidMeasuredVelocityProvenance(value['measured']) ||
257
+ UNMEASURED_EARLY_STAGES.has(value['targetStage']))) {
258
+ fail('measured eta requires qualified velocity estimator provenance');
259
+ }
260
+ if (value['source'] === 'unknown' && String(value['when']).trim() !== '—') {
261
+ fail('unknown eta must have when === "—"');
262
+ }
263
+ if (grammar === 'write' && value['source'] !== 'unknown' && !isValidIsoDateToken(String(value['when']))) {
264
+ fail('eta when must be an ISO date (YYYY-MM-DD)');
265
+ }
266
+ if (value['source'] === 'committed' && !text(value['by'])) {
267
+ fail('committed eta requires by');
268
+ }
269
+ if (value['by'] !== undefined && !text(value['by']))
270
+ fail('eta by must be non-empty');
271
+ if (value['slip'] !== undefined) {
272
+ if (!object(value['slip']))
273
+ fail('eta slip must be an object');
274
+ keys(value['slip'], ['initialWhen', 'reason']);
275
+ if (!text(value['slip']['initialWhen']))
276
+ fail('eta slip initialWhen is required');
277
+ if (value['slip']['reason'] !== undefined && !text(value['slip']['reason']))
278
+ fail('eta slip reason must be non-empty');
279
+ }
280
+ }
281
+ export function assertSetEtaInput(value, options = {}) {
282
+ if (!object(value))
283
+ throw new DomainError('eta-set: input must be an object');
284
+ const allowed = [
285
+ 'targetStage',
286
+ 'targetLabel',
287
+ 'when',
288
+ 'source',
289
+ 'by',
290
+ 'reason',
291
+ 'rebaselineDecisionId',
292
+ 'measured',
293
+ 'delivered',
294
+ ];
295
+ if (Object.keys(value).some((k) => !allowed.includes(k))) {
296
+ throw new DomainError('eta-set: unknown field');
297
+ }
298
+ if (!REPORT_STAGES.includes(value['targetStage'])) {
299
+ throw new DomainError('eta-set: targetStage must be a valid stage');
300
+ }
301
+ const targetStage = value['targetStage'];
302
+ if (value['targetLabel'] !== undefined && !text(value['targetLabel'])) {
303
+ throw new DomainError('eta-set: targetLabel must be non-empty');
304
+ }
305
+ if (value['delivered'] !== undefined && typeof value['delivered'] !== 'boolean') {
306
+ throw new DomainError('eta-set: delivered must be a boolean');
307
+ }
308
+ const delivered = value['delivered'] === true;
309
+ const rawWhenVal = delivered && value['when'] === undefined ? '—' : value['when'];
310
+ const rawSourceVal = delivered && value['source'] === undefined ? 'unknown' : value['source'];
311
+ if (!text(rawWhenVal)) {
312
+ throw new DomainError('eta-set: when is required');
313
+ }
314
+ const when = rawWhenVal.trim();
315
+ const source = rawSourceVal;
316
+ if (source !== 'measured' && source !== 'committed' && source !== 'unknown') {
317
+ throw new DomainError('eta-set: source must be measured, committed or unknown');
318
+ }
319
+ if (source === 'measured') {
320
+ if (options.allowMeasured !== true ||
321
+ !isValidMeasuredVelocityProvenance(value['measured']) ||
322
+ UNMEASURED_EARLY_STAGES.has(targetStage)) {
323
+ throw new DomainError('eta-set: source "measured" requires qualified velocity estimator inputs via qualifyVelocityEta');
324
+ }
325
+ }
326
+ if (source === 'unknown' && when !== '—') {
327
+ throw new DomainError('eta-set: unknown eta must have when === "—"');
328
+ }
329
+ if (source !== 'unknown' && !isValidIsoDateToken(when)) {
330
+ throw new DomainError('eta-set: when must be an ISO date (YYYY-MM-DD)');
331
+ }
332
+ if (source === 'committed' && !text(value['by'])) {
333
+ throw new DomainError('eta-set: committed eta requires by');
334
+ }
335
+ if (value['by'] !== undefined && !text(value['by'])) {
336
+ throw new DomainError('eta-set: by must be non-empty');
337
+ }
338
+ if (value['reason'] !== undefined && !text(value['reason'])) {
339
+ throw new DomainError('eta-set: reason must be non-empty');
340
+ }
341
+ if (value['rebaselineDecisionId'] !== undefined && !text(value['rebaselineDecisionId'])) {
342
+ throw new DomainError('eta-set: rebaselineDecisionId must be non-empty');
343
+ }
344
+ return {
345
+ targetStage,
346
+ when,
347
+ source,
348
+ ...(value['targetLabel'] !== undefined ? { targetLabel: value['targetLabel'].trim() } : {}),
349
+ ...(value['by'] !== undefined ? { by: value['by'].trim() } : {}),
350
+ ...(value['reason'] !== undefined ? { reason: value['reason'].trim() } : {}),
351
+ ...(value['rebaselineDecisionId'] !== undefined
352
+ ? { rebaselineDecisionId: value['rebaselineDecisionId'].trim() }
353
+ : {}),
354
+ ...(source === 'measured' && isValidMeasuredVelocityProvenance(value['measured'])
355
+ ? { measured: value['measured'] }
356
+ : {}),
357
+ ...(delivered ? { delivered: true } : {}),
358
+ };
359
+ }
360
+ /** High stages that always require a recorded evidence locator. */
361
+ export const EVIDENCE_REQUIRED_STAGES = [
362
+ 'pr',
363
+ 'review',
364
+ 'merged',
365
+ 'published',
366
+ 'preprod',
367
+ 'prod',
368
+ 'done',
369
+ ];
89
370
  /**
90
- * Validate a report assertion. The default `'write'` grammar accepts only
91
- * `WRITABLE_REPORT_STAGES` (B1 Lot L1: the `review`/`published` writers open
92
- * in Lot L5); `'read'` accepts the full `REPORT_STAGES` grammar, so a stored
93
- * review/published assertion still asserts on the fold/derivation path.
371
+ * Validate a report assertion. `'read'` accepts all 12 neutral stages in `REPORT_STAGES`;
372
+ * `'write'` accepts the 10 pre-prod stages in `WRITABLE_REPORT_STAGES` (`prod` and `done`
373
+ * require recorded links) and the 8 neutral statuses in `REPORT_STATUSES`.
94
374
  */
95
375
  export function assertItemReportStatus(value, grammar = 'write') {
96
376
  if (!object(value))
97
377
  fail('report must be an object');
98
- keys(value, ['ownerRequest', 'stage', 'status', 'proposal', 'decisionExpectations', 'facts', 'nextAction', 'waitingOn', 'suspended']);
99
- for (const key of ['ownerRequest', 'proposal', 'facts', 'nextAction', 'waitingOn', 'suspended']) {
378
+ keys(value, [
379
+ 'ownerRequest',
380
+ 'ownerNumber',
381
+ 'ownerSummary',
382
+ 'requestedStage',
383
+ 'stage',
384
+ 'status',
385
+ 'proposal',
386
+ 'decisionExpectations',
387
+ 'facts',
388
+ 'nextAction',
389
+ 'waitingOn',
390
+ 'suspended',
391
+ 'pausedByOwner',
392
+ 'pauseDecisionId',
393
+ 'etas',
394
+ 'decisionRefs',
395
+ 'decisionBlocking',
396
+ 'archived',
397
+ ]);
398
+ for (const key of ['ownerRequest', 'ownerSummary', 'proposal', 'facts', 'nextAction', 'waitingOn', 'suspended', 'pauseDecisionId']) {
100
399
  if (value[key] !== undefined && !text(value[key]))
101
400
  fail(`${key} must be a non-empty string`);
102
401
  }
402
+ if (value['ownerNumber'] !== undefined) {
403
+ if (typeof value['ownerNumber'] !== 'number' || !Number.isInteger(value['ownerNumber']) || value['ownerNumber'] < 1) {
404
+ fail('ownerNumber must be a positive integer');
405
+ }
406
+ }
407
+ if (value['requestedStage'] !== undefined && !REPORT_STAGES.includes(value['requestedStage'])) {
408
+ fail('invalid requestedStage');
409
+ }
410
+ if (value['pausedByOwner'] !== undefined && typeof value['pausedByOwner'] !== 'boolean') {
411
+ fail('pausedByOwner must be a boolean');
412
+ }
413
+ if (grammar === 'write' && value['pausedByOwner'] === true && !text(value['pauseDecisionId'])) {
414
+ fail('pausedByOwner requires pauseDecisionId');
415
+ }
416
+ if (value['decisionBlocking'] !== undefined && typeof value['decisionBlocking'] !== 'boolean') {
417
+ fail('decisionBlocking must be a boolean');
418
+ }
419
+ if (value['decisionRefs'] !== undefined) {
420
+ if (!Array.isArray(value['decisionRefs']) || value['decisionRefs'].some(ref => !text(ref))) {
421
+ fail('decisionRefs must be an array of non-empty strings');
422
+ }
423
+ }
424
+ if (value['etas'] !== undefined) {
425
+ if (!Array.isArray(value['etas']) || value['etas'].length > 2) {
426
+ fail('etas must be an array of at most 2 entries');
427
+ }
428
+ for (const entry of value['etas'])
429
+ assertReportEtaEntry(entry, grammar);
430
+ }
431
+ if (value['archived'] !== undefined) {
432
+ if (!object(value['archived']))
433
+ fail('archived must be an object');
434
+ keys(value['archived'], ['decisionId', 'reason']);
435
+ if (!text(value['archived']['decisionId']) || !text(value['archived']['reason'])) {
436
+ fail('archived requires decisionId and reason');
437
+ }
438
+ }
103
439
  if (value["status"] !== undefined && !REPORT_STATUSES.includes(value["status"]))
104
440
  fail('invalid status');
105
441
  if (value["stage"] !== undefined) {
@@ -111,14 +447,12 @@ export function assertItemReportStatus(value, grammar = 'write') {
111
447
  fail('invalid stage');
112
448
  if (value["stage"]["evidence"] !== undefined && !text(value["stage"]["evidence"]))
113
449
  fail('stage evidence must be non-empty');
114
- const evidenceStages = grammar === 'read'
115
- ? ['pr', 'review', 'merged', 'published', 'deployed']
116
- : ['pr', 'merged', 'deployed'];
117
- if (evidenceStages.includes(String(value["stage"]["value"])) && !text(value["stage"]["evidence"]))
450
+ const evidenceStages = EVIDENCE_REQUIRED_STAGES;
451
+ if (evidenceStages.includes(String(value["stage"]["value"])) && !text(value["stage"]["evidence"])) {
118
452
  fail(`${evidenceStages.join('/')} requires evidence`);
453
+ }
119
454
  }
120
455
  if (value["decisionExpectations"] !== undefined)
121
456
  assertDecisionExpectations(value["decisionExpectations"]);
122
- // Incomplete red/blue declarations are retained so the renderer can flag and route their repair.
123
457
  }
124
458
  //# sourceMappingURL=report-status.js.map