@cleocode/contracts 2026.5.95 → 2026.5.97

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 (121) hide show
  1. package/dist/__tests__/enums.test.d.ts +14 -0
  2. package/dist/__tests__/enums.test.d.ts.map +1 -0
  3. package/dist/__tests__/enums.test.js +75 -0
  4. package/dist/__tests__/enums.test.js.map +1 -0
  5. package/dist/__tests__/jobs.test.d.ts +11 -0
  6. package/dist/__tests__/jobs.test.d.ts.map +1 -0
  7. package/dist/__tests__/jobs.test.js +48 -0
  8. package/dist/__tests__/jobs.test.js.map +1 -0
  9. package/dist/__tests__/memory-wire-shapes.test.d.ts +19 -0
  10. package/dist/__tests__/memory-wire-shapes.test.d.ts.map +1 -0
  11. package/dist/__tests__/memory-wire-shapes.test.js +119 -0
  12. package/dist/__tests__/memory-wire-shapes.test.js.map +1 -0
  13. package/dist/__tests__/operation-def.test.d.ts +20 -0
  14. package/dist/__tests__/operation-def.test.d.ts.map +1 -0
  15. package/dist/__tests__/operation-def.test.js +111 -0
  16. package/dist/__tests__/operation-def.test.js.map +1 -0
  17. package/dist/__tests__/provenance.test.d.ts +18 -0
  18. package/dist/__tests__/provenance.test.d.ts.map +1 -0
  19. package/dist/__tests__/provenance.test.js +142 -0
  20. package/dist/__tests__/provenance.test.js.map +1 -0
  21. package/dist/__tests__/scaffold-diagnostics.test.d.ts +19 -0
  22. package/dist/__tests__/scaffold-diagnostics.test.d.ts.map +1 -0
  23. package/dist/__tests__/scaffold-diagnostics.test.js +70 -0
  24. package/dist/__tests__/scaffold-diagnostics.test.js.map +1 -0
  25. package/dist/dispatch/identity.d.ts +72 -0
  26. package/dist/dispatch/identity.d.ts.map +1 -0
  27. package/dist/dispatch/identity.js +72 -0
  28. package/dist/dispatch/identity.js.map +1 -0
  29. package/dist/dispatch/operation-def.d.ts +92 -0
  30. package/dist/dispatch/operation-def.d.ts.map +1 -0
  31. package/dist/dispatch/operation-def.js +31 -0
  32. package/dist/dispatch/operation-def.js.map +1 -0
  33. package/dist/doctor.d.ts +52 -0
  34. package/dist/doctor.d.ts.map +1 -1
  35. package/dist/doctor.js +7 -0
  36. package/dist/doctor.js.map +1 -1
  37. package/dist/enums.d.ts +123 -0
  38. package/dist/enums.d.ts.map +1 -0
  39. package/dist/enums.js +139 -0
  40. package/dist/enums.js.map +1 -0
  41. package/dist/index.d.ts +16 -3
  42. package/dist/index.d.ts.map +1 -1
  43. package/dist/index.js +4 -0
  44. package/dist/index.js.map +1 -1
  45. package/dist/jobs.d.ts +39 -0
  46. package/dist/jobs.d.ts.map +1 -0
  47. package/dist/jobs.js +19 -0
  48. package/dist/jobs.js.map +1 -0
  49. package/dist/memory/budgeted.d.ts +67 -0
  50. package/dist/memory/budgeted.d.ts.map +1 -0
  51. package/dist/memory/budgeted.js +17 -0
  52. package/dist/memory/budgeted.js.map +1 -0
  53. package/dist/memory/fetch.d.ts +58 -0
  54. package/dist/memory/fetch.d.ts.map +1 -0
  55. package/dist/memory/fetch.js +19 -0
  56. package/dist/memory/fetch.js.map +1 -0
  57. package/dist/memory/observe.d.ts +158 -0
  58. package/dist/memory/observe.d.ts.map +1 -0
  59. package/dist/memory/observe.js +46 -0
  60. package/dist/memory/observe.js.map +1 -0
  61. package/dist/memory/search.d.ts +137 -0
  62. package/dist/memory/search.d.ts.map +1 -0
  63. package/dist/memory/search.js +22 -0
  64. package/dist/memory/search.js.map +1 -0
  65. package/dist/memory/timeline.d.ts +89 -0
  66. package/dist/memory/timeline.d.ts.map +1 -0
  67. package/dist/memory/timeline.js +22 -0
  68. package/dist/memory/timeline.js.map +1 -0
  69. package/dist/operations/focus.d.ts +199 -0
  70. package/dist/operations/focus.d.ts.map +1 -0
  71. package/dist/operations/focus.js +15 -0
  72. package/dist/operations/focus.js.map +1 -0
  73. package/dist/operations/index.d.ts +1 -0
  74. package/dist/operations/index.d.ts.map +1 -1
  75. package/dist/operations/index.js +1 -0
  76. package/dist/operations/index.js.map +1 -1
  77. package/dist/operations/session.d.ts +54 -0
  78. package/dist/operations/session.d.ts.map +1 -1
  79. package/dist/operations/tasks.d.ts +38 -0
  80. package/dist/operations/tasks.d.ts.map +1 -1
  81. package/dist/operations/worktree.d.ts +138 -1
  82. package/dist/operations/worktree.d.ts.map +1 -1
  83. package/dist/provenance.d.ts +257 -0
  84. package/dist/provenance.d.ts.map +1 -0
  85. package/dist/provenance.js +42 -0
  86. package/dist/provenance.js.map +1 -0
  87. package/dist/release/plan.d.ts +7 -7
  88. package/dist/scaffold-diagnostics.d.ts +110 -0
  89. package/dist/scaffold-diagnostics.d.ts.map +1 -0
  90. package/dist/scaffold-diagnostics.js +28 -0
  91. package/dist/scaffold-diagnostics.js.map +1 -0
  92. package/dist/session.d.ts +37 -0
  93. package/dist/session.d.ts.map +1 -1
  94. package/dist/session.js.map +1 -1
  95. package/dist/tasks/archive.d.ts +3 -3
  96. package/package.json +42 -2
  97. package/src/__tests__/enums.test.ts +114 -0
  98. package/src/__tests__/jobs.test.ts +76 -0
  99. package/src/__tests__/memory-wire-shapes.test.ts +371 -0
  100. package/src/__tests__/operation-def.test.ts +185 -0
  101. package/src/__tests__/provenance.test.ts +259 -0
  102. package/src/__tests__/scaffold-diagnostics.test.ts +137 -0
  103. package/src/dispatch/identity.ts +109 -0
  104. package/src/dispatch/operation-def.ts +102 -0
  105. package/src/doctor.ts +62 -0
  106. package/src/enums.ts +144 -0
  107. package/src/index.ts +89 -2
  108. package/src/jobs.ts +45 -0
  109. package/src/memory/budgeted.ts +75 -0
  110. package/src/memory/fetch.ts +66 -0
  111. package/src/memory/observe.ts +176 -0
  112. package/src/memory/search.ts +145 -0
  113. package/src/memory/timeline.ts +100 -0
  114. package/src/operations/focus.ts +226 -0
  115. package/src/operations/index.ts +1 -0
  116. package/src/operations/session.ts +56 -0
  117. package/src/operations/tasks.ts +40 -0
  118. package/src/operations/worktree.ts +149 -1
  119. package/src/provenance.ts +335 -0
  120. package/src/scaffold-diagnostics.ts +119 -0
  121. package/src/session.ts +37 -0
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Structural-equivalence + value-set tests for the task-axis enum
3
+ * constants promoted in Phase 0c (T9955).
4
+ *
5
+ * These tests pin the runtime value sets of the 6 `as const` arrays
6
+ * (`TASK_KINDS`, `TASK_SCOPES`, `TASK_SEVERITIES`, `TASK_SIZES`,
7
+ * `ARCHIVE_REASONS`, `TASK_RELATION_TYPES`) so that:
8
+ * - The Drizzle row-type narrowing in `tasks-schema.ts` stays byte-identical.
9
+ * - The DB CHECK constraints they back keep their canonical value list.
10
+ *
11
+ * @since SG-ARCH-SOLID Saga T9831 · E-CONTRACTS-FOUNDATION T9832 · T9955 (Phase 0c)
12
+ */
13
+ export {};
14
+ //# sourceMappingURL=enums.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enums.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/enums.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG"}
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Structural-equivalence + value-set tests for the task-axis enum
3
+ * constants promoted in Phase 0c (T9955).
4
+ *
5
+ * These tests pin the runtime value sets of the 6 `as const` arrays
6
+ * (`TASK_KINDS`, `TASK_SCOPES`, `TASK_SEVERITIES`, `TASK_SIZES`,
7
+ * `ARCHIVE_REASONS`, `TASK_RELATION_TYPES`) so that:
8
+ * - The Drizzle row-type narrowing in `tasks-schema.ts` stays byte-identical.
9
+ * - The DB CHECK constraints they back keep their canonical value list.
10
+ *
11
+ * @since SG-ARCH-SOLID Saga T9831 · E-CONTRACTS-FOUNDATION T9832 · T9955 (Phase 0c)
12
+ */
13
+ import { describe, expect, it } from 'vitest';
14
+ import { ARCHIVE_REASONS, TASK_KINDS, TASK_RELATION_TYPES, TASK_SCOPES, TASK_SEVERITIES, TASK_SIZES, } from '../enums.js';
15
+ // ─── Runtime value-set assertions ───────────────────────────────────
16
+ describe('task-axis enum constants', () => {
17
+ it('TASK_KINDS holds the 6 canonical task kinds', () => {
18
+ expect(TASK_KINDS).toEqual(['work', 'research', 'experiment', 'bug', 'spike', 'release']);
19
+ });
20
+ it('TASK_SCOPES holds project / feature / unit (in canonical order)', () => {
21
+ expect(TASK_SCOPES).toEqual(['project', 'feature', 'unit']);
22
+ });
23
+ it('TASK_SEVERITIES holds P0 through P3 in increasing severity order', () => {
24
+ expect(TASK_SEVERITIES).toEqual(['P0', 'P1', 'P2', 'P3']);
25
+ });
26
+ it('TASK_SIZES holds small / medium / large (CLEO avoids time estimates)', () => {
27
+ expect(TASK_SIZES).toEqual(['small', 'medium', 'large']);
28
+ });
29
+ it('ARCHIVE_REASONS holds exactly the 6 truth-grade closure reasons', () => {
30
+ expect(ARCHIVE_REASONS).toEqual([
31
+ 'verified',
32
+ 'reconciled',
33
+ 'superseded',
34
+ 'shadowed',
35
+ 'cancelled',
36
+ 'completed-unverified',
37
+ ]);
38
+ });
39
+ it('TASK_RELATION_TYPES includes "groups" (ADR-073 Saga membership)', () => {
40
+ expect(TASK_RELATION_TYPES).toContain('groups');
41
+ expect(TASK_RELATION_TYPES).toEqual([
42
+ 'related',
43
+ 'blocks',
44
+ 'duplicates',
45
+ 'absorbs',
46
+ 'fixes',
47
+ 'extends',
48
+ 'supersedes',
49
+ 'groups',
50
+ ]);
51
+ });
52
+ it('All enum arrays are non-empty readonly tuples', () => {
53
+ expect(TASK_KINDS.length).toBeGreaterThan(0);
54
+ expect(TASK_SCOPES.length).toBeGreaterThan(0);
55
+ expect(TASK_SEVERITIES.length).toBeGreaterThan(0);
56
+ expect(TASK_SIZES.length).toBeGreaterThan(0);
57
+ expect(ARCHIVE_REASONS.length).toBeGreaterThan(0);
58
+ expect(TASK_RELATION_TYPES.length).toBeGreaterThan(0);
59
+ });
60
+ // The six `_Pin…` aliases above will fail compilation if any const
61
+ // array is accidentally widened to `string[]`. The reference below
62
+ // prevents unused-locals diagnostics from removing them.
63
+ it('compile-time readonly-tuple pins are wired (no-op at runtime)', () => {
64
+ const pinned = [
65
+ TASK_KINDS,
66
+ TASK_SCOPES,
67
+ TASK_SEVERITIES,
68
+ TASK_SIZES,
69
+ ARCHIVE_REASONS,
70
+ TASK_RELATION_TYPES,
71
+ ];
72
+ expect(pinned).toHaveLength(6);
73
+ });
74
+ });
75
+ //# sourceMappingURL=enums.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enums.test.js","sourceRoot":"","sources":["../../src/__tests__/enums.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EACL,eAAe,EACf,UAAU,EACV,mBAAmB,EACnB,WAAW,EACX,eAAe,EACf,UAAU,GACX,MAAM,aAAa,CAAC;AAkBrB,uEAAuE;AAEvE,QAAQ,CAAC,0BAA0B,EAAE,GAAG,EAAE;IACxC,EAAE,CAAC,6CAA6C,EAAE,GAAG,EAAE;QACrD,MAAM,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC;IAC5F,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iEAAiE,EAAE,GAAG,EAAE;QACzE,MAAM,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC;IAC9D,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,kEAAkE,EAAE,GAAG,EAAE;QAC1E,MAAM,CAAC,eAAe,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;IAC5D,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,sEAAsE,EAAE,GAAG,EAAE;QAC9E,MAAM,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC,OAAO,EA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AU;YACV,WAAW;YACX,eAAe;YACf,UAAU;YACV,eAAe;YACf,mBAAmB;SACpB,CAAC;QACF,MAAM,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IACjC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Structural-equivalence tests for the background-job contracts.
3
+ *
4
+ * Pins the literal shape of {@link BackgroundJobStatus} promoted in
5
+ * Phase 0c (T9955) so accidental narrowing or widening triggers a
6
+ * compile-time failure during `tsc -b` in the CI gate.
7
+ *
8
+ * @since SG-ARCH-SOLID Saga T9831 · E-CONTRACTS-FOUNDATION T9832 · T9955 (Phase 0c)
9
+ */
10
+ export {};
11
+ //# sourceMappingURL=jobs.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jobs.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/jobs.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Structural-equivalence tests for the background-job contracts.
3
+ *
4
+ * Pins the literal shape of {@link BackgroundJobStatus} promoted in
5
+ * Phase 0c (T9955) so accidental narrowing or widening triggers a
6
+ * compile-time failure during `tsc -b` in the CI gate.
7
+ *
8
+ * @since SG-ARCH-SOLID Saga T9831 · E-CONTRACTS-FOUNDATION T9832 · T9955 (Phase 0c)
9
+ */
10
+ import { describe, expect, it } from 'vitest';
11
+ // ─── Runtime constructibility smoke ─────────────────────────────────
12
+ describe('jobs contracts', () => {
13
+ it('BackgroundJobStatus enumerates the 6 documented lifecycle states', () => {
14
+ const all = [
15
+ 'pending',
16
+ 'running',
17
+ 'complete',
18
+ 'failed',
19
+ 'cancelled',
20
+ 'orphaned',
21
+ ];
22
+ expect(all).toHaveLength(6);
23
+ });
24
+ it('BackgroundJobStatus distinguishes terminal from in-flight states', () => {
25
+ const terminal = ['complete', 'failed', 'cancelled', 'orphaned'];
26
+ const inFlight = ['pending', 'running'];
27
+ expect(terminal).toHaveLength(4);
28
+ expect(inFlight).toHaveLength(2);
29
+ });
30
+ it('Every BackgroundJobStatus is a non-empty string literal', () => {
31
+ const statuses = [
32
+ 'pending',
33
+ 'running',
34
+ 'complete',
35
+ 'failed',
36
+ 'cancelled',
37
+ 'orphaned',
38
+ ];
39
+ for (const s of statuses) {
40
+ expect(s.length).toBeGreaterThan(0);
41
+ }
42
+ });
43
+ it('compile-time pin is wired (no-op at runtime)', () => {
44
+ const pinned = 1;
45
+ expect(pinned).toBe(1);
46
+ });
47
+ });
48
+ //# sourceMappingURL=jobs.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jobs.test.js","sourceRoot":"","sources":["../../src/__tests__/jobs.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAyB9C,uEAAuE;AAEvE,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC9B,EAAE,CAAC,kEAAkE,EAAE,GAAG,EAAE;QAC1E,MAAM,GAAG,GAA0B;YACjC,SAAS;YACT,SAAS;YACT,UAAU;YACV,QAAQ;YACR,WAAW;YACX,UAAU;SACX,CAAC;QACF,MAAM,CAAC,GAAG,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAC9B,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,kEAAkE,EAAE,GAAG,EAAE;QAC1E,MAAM,QAAQ,GAA0B,CAAC,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC;QACxF,MAAM,QAAQ,GAA0B,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QAC/D,MAAM,CAAC,QAAQ,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;QACjC,MAAM,CAAC,QAAQ,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,yDAAyD,EAAE,GAAG,EAAE;QACjE,MAAM,QAAQ,GAA0B;YACtC,SAAS;YACT,SAAS;YACT,UAAU;YACV,QAAQ;YACR,WAAW;YACX,UAAU;SACX,CAAC;QACF,KAAK,MAAM,CAAC,IAAI,QAAQ,EAAE,CAAC;YACzB,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;QACtC,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,8CAA8C,EAAE,GAAG,EAAE;QACtD,MAAM,MAAM,GAAqC,CAAC,CAAC;QACnD,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACzB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Structural-equivalence tests for the BRAIN memory wire-shape contracts.
3
+ *
4
+ * These tests pin the field shapes of the 15 types promoted from
5
+ * `packages/core/src/memory/brain-retrieval.ts` in Phase 0e of
6
+ * SG-ARCH-SOLID (E-CONTRACTS-FOUNDATION). Accidental narrowing or
7
+ * widening triggers a compile-time failure during `tsc -b` in the CI gate.
8
+ *
9
+ * The compile-time assertions use the conditional-equality trick
10
+ * (`Equals<A, B>`) so any structural drift produces a TS2322 or TS2344
11
+ * at build time. The runtime `expect` smoke verifies that constructible
12
+ * literals satisfy each interface — these are pure type contracts with
13
+ * no runtime, so this is a thin satisfies check rather than a behavior
14
+ * test.
15
+ *
16
+ * @since SG-ARCH-SOLID Saga T9831 · E-CONTRACTS-FOUNDATION T9832 · T9956 (Phase 0e)
17
+ */
18
+ export {};
19
+ //# sourceMappingURL=memory-wire-shapes.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory-wire-shapes.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/memory-wire-shapes.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG"}
@@ -0,0 +1,119 @@
1
+ /**
2
+ * Structural-equivalence tests for the BRAIN memory wire-shape contracts.
3
+ *
4
+ * These tests pin the field shapes of the 15 types promoted from
5
+ * `packages/core/src/memory/brain-retrieval.ts` in Phase 0e of
6
+ * SG-ARCH-SOLID (E-CONTRACTS-FOUNDATION). Accidental narrowing or
7
+ * widening triggers a compile-time failure during `tsc -b` in the CI gate.
8
+ *
9
+ * The compile-time assertions use the conditional-equality trick
10
+ * (`Equals<A, B>`) so any structural drift produces a TS2322 or TS2344
11
+ * at build time. The runtime `expect` smoke verifies that constructible
12
+ * literals satisfy each interface — these are pure type contracts with
13
+ * no runtime, so this is a thin satisfies check rather than a behavior
14
+ * test.
15
+ *
16
+ * @since SG-ARCH-SOLID Saga T9831 · E-CONTRACTS-FOUNDATION T9832 · T9956 (Phase 0e)
17
+ */
18
+ import { describe, expect, it } from 'vitest';
19
+ import { BRAIN_OBSERVATION_SOURCE_TYPES, } from '../memory/observe.js';
20
+ // ─── Runtime constructibility smoke ─────────────────────────────────
21
+ describe('memory wire-shape contracts (T9956)', () => {
22
+ it('BrainCompactHit is constructible with the canonical shape', () => {
23
+ const hit = {
24
+ id: 'O-abc123',
25
+ type: 'observation',
26
+ title: 'sample',
27
+ date: '2026-05-21T00:00:00Z',
28
+ };
29
+ expect(hit.id).toBe('O-abc123');
30
+ expect(hit.type).toBe('observation');
31
+ });
32
+ it('SearchBrainCompactResult composes BrainCompactHit and token accounting', () => {
33
+ const result = {
34
+ results: [{ id: 'O-1', type: 'observation', title: 't', date: '2026-05-21' }],
35
+ total: 1,
36
+ tokensEstimated: 50,
37
+ };
38
+ expect(result.results).toHaveLength(1);
39
+ expect(result.tokensEstimated).toBe(50);
40
+ });
41
+ it('BrainAnchor and TimelineBrainResult compose correctly', () => {
42
+ const anchor = { id: 'O-anchor', type: 'observation', data: { x: 1 } };
43
+ const result = {
44
+ anchor,
45
+ before: [{ id: 'O-prev', type: 'observation', date: '2026-05-20' }],
46
+ after: [{ id: 'O-next', type: 'observation', date: '2026-05-22' }],
47
+ };
48
+ expect(result.anchor?.id).toBe('O-anchor');
49
+ expect(result.before).toHaveLength(1);
50
+ expect(result.after).toHaveLength(1);
51
+ });
52
+ it('TimelineBrainResult accepts null anchor for unresolved IDs', () => {
53
+ const result = { anchor: null, before: [], after: [] };
54
+ expect(result.anchor).toBeNull();
55
+ });
56
+ it('FetchBrainEntriesResult tracks notFound IDs alongside resolved entries', () => {
57
+ const result = {
58
+ results: [{ id: 'O-1', type: 'observation', data: null }],
59
+ notFound: ['O-missing'],
60
+ tokensEstimated: 100,
61
+ };
62
+ expect(result.results).toHaveLength(1);
63
+ expect(result.notFound).toContain('O-missing');
64
+ });
65
+ it('BRAIN_OBSERVATION_SOURCE_TYPES is the runtime tuple backing BrainObservationSourceType', () => {
66
+ expect(BRAIN_OBSERVATION_SOURCE_TYPES).toEqual([
67
+ 'agent',
68
+ 'session-debrief',
69
+ 'claude-mem',
70
+ 'manual',
71
+ ]);
72
+ // The derived type must include every const member.
73
+ const sample = [...BRAIN_OBSERVATION_SOURCE_TYPES];
74
+ expect(sample).toHaveLength(4);
75
+ });
76
+ it('ObserveBrainParams accepts the minimal required shape (text only)', () => {
77
+ const params = { text: 'hello world' };
78
+ expect(params.text).toBe('hello world');
79
+ });
80
+ it('ObserveBrainResult mirrors the persisted row identity tuple', () => {
81
+ const result = {
82
+ id: 'O-new',
83
+ type: 'observation',
84
+ createdAt: '2026-05-21T12:00:00Z',
85
+ };
86
+ expect(result.id).toBe('O-new');
87
+ expect(result.type).toBe('observation');
88
+ });
89
+ it('BudgetedRetrievalOptions composes all three optional filter axes', () => {
90
+ const opts = {
91
+ types: ['semantic', 'procedural'],
92
+ tiers: ['medium', 'long'],
93
+ verified: true,
94
+ };
95
+ expect(opts.types).toHaveLength(2);
96
+ expect(opts.tiers).toHaveLength(2);
97
+ expect(opts.verified).toBe(true);
98
+ });
99
+ it('BudgetedResult tracks token usage, remaining budget, and exclusion count', () => {
100
+ const result = {
101
+ entries: [
102
+ {
103
+ id: 'L-1',
104
+ type: 'learning',
105
+ title: 'insight',
106
+ text: 'body',
107
+ score: 0.42,
108
+ tokensEstimated: 32,
109
+ },
110
+ ],
111
+ tokensUsed: 32,
112
+ tokensRemaining: 468,
113
+ excluded: 0,
114
+ };
115
+ expect(result.entries).toHaveLength(1);
116
+ expect(result.tokensUsed + result.tokensRemaining).toBe(500);
117
+ });
118
+ });
119
+ //# sourceMappingURL=memory-wire-shapes.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory-wire-shapes.test.js","sourceRoot":"","sources":["../../src/__tests__/memory-wire-shapes.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAa9C,OAAO,EACL,8BAA8B,GAI/B,MAAM,sBAAsB,CAAC;AAkO9B,uEAAuE;AAEvE,QAAQ,CAAC,qCAAqC,EAAE,GAAG,EAAE;IACnD,EAAE,CAAC,2DAA2D,EAAE,GAAG,EAAE;QACnE,MAAM,GAAG,GAAoB;YAC3B,EAAE,EAAE,UAAU;YACd,IAAI,EAAE,aAAa;YACnB,KAAK,EAAE,QAAQ;YACf,IAAI,EAAE,sBAAsB;SAC7B,CAAC;QACF,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAChC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,wEAAwE,EAAE,GAAG,EAAE;QAChF,MAAM,MAAM,GAA6B;YACvC,OAAO,EAAE,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;YAC7E,KAAK,EAAE,CAAC;YACR,eA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CAAC,CAAC;IAEH,EAAE,CAAC,kEAAkE,EAAE,GAAG,EAAE;QAC1E,MAAM,IAAI,GAA6B;YACrC,KAAK,EAAE,CAAC,UAAU,EAAE,YAAY,CAAC;YACjC,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC;YACzB,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;QACnC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;QACnC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,0EAA0E,EAAE,GAAG,EAAE;QAClF,MAAM,MAAM,GAAmB;YAC7B,OAAO,EAAE;gBACP;oBACE,EAAE,EAAE,KAAK;oBACT,IAAI,EAAE,UAAU;oBAChB,KAAK,EAAE,SAAS;oBAChB,IAAI,EAAE,MAAM;oBACZ,KAAK,EAAE,IAAI;oBACX,eAAe,EAAE,EAAE;iBACpB;aACF;YACD,UAAU,EAAE,EAAE;YACd,eAAe,EAAE,GAAG;YACpB,QAAQ,EAAE,CAAC;SACZ,CAAC;QACF,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;QACvC,MAAM,CAAC,MAAM,CAAC,UAAU,GAAG,MAAM,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC/D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Structural-equivalence tests for the dispatch operation-def contracts.
3
+ *
4
+ * These tests pin the field shapes of {@link OperationDef} and
5
+ * {@link Resolution} (and the underlying identity types {@link Gateway},
6
+ * {@link Tier}, {@link CanonicalDomain}) so accidental narrowing or
7
+ * widening triggers a compile-time failure during `tsc -b` in the CI
8
+ * gate.
9
+ *
10
+ * The compile-time assertions use the conditional-equality trick
11
+ * (`Equals<A, B>`) so any structural drift produces a TS2322 or TS2344
12
+ * at build time. The runtime `expect` shape sanity check below is a
13
+ * thin smoke verification that constructible literals satisfy each
14
+ * interface — it does NOT exercise behavior (these are pure type
15
+ * contracts with no runtime).
16
+ *
17
+ * @since SG-ARCH-SOLID Saga T9831 · E-CONTRACTS-FOUNDATION T9832 · T9954 (Phase 0b)
18
+ */
19
+ export {};
20
+ //# sourceMappingURL=operation-def.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operation-def.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/operation-def.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG"}
@@ -0,0 +1,111 @@
1
+ /**
2
+ * Structural-equivalence tests for the dispatch operation-def contracts.
3
+ *
4
+ * These tests pin the field shapes of {@link OperationDef} and
5
+ * {@link Resolution} (and the underlying identity types {@link Gateway},
6
+ * {@link Tier}, {@link CanonicalDomain}) so accidental narrowing or
7
+ * widening triggers a compile-time failure during `tsc -b` in the CI
8
+ * gate.
9
+ *
10
+ * The compile-time assertions use the conditional-equality trick
11
+ * (`Equals<A, B>`) so any structural drift produces a TS2322 or TS2344
12
+ * at build time. The runtime `expect` shape sanity check below is a
13
+ * thin smoke verification that constructible literals satisfy each
14
+ * interface — it does NOT exercise behavior (these are pure type
15
+ * contracts with no runtime).
16
+ *
17
+ * @since SG-ARCH-SOLID Saga T9831 · E-CONTRACTS-FOUNDATION T9832 · T9954 (Phase 0b)
18
+ */
19
+ import { describe, expect, it } from 'vitest';
20
+ import { CANONICAL_DOMAINS } from '../dispatch/identity.js';
21
+ // ─── Runtime constructibility smoke ─────────────────────────────────
22
+ describe('dispatch/operation-def contracts', () => {
23
+ it('Gateway union covers exactly the 2 documented values', () => {
24
+ const values = ['query', 'mutate'];
25
+ expect(values).toHaveLength(2);
26
+ });
27
+ it('Tier union covers exactly the 3 documented values', () => {
28
+ const tiers = [0, 1, 2];
29
+ expect(tiers).toHaveLength(3);
30
+ });
31
+ it('CANONICAL_DOMAINS is a non-empty readonly tuple', () => {
32
+ expect(CANONICAL_DOMAINS.length).toBeGreaterThan(0);
33
+ // T9954 — snapshot the current count so accidental additions/removals
34
+ // trip this test and force an explicit human review.
35
+ expect(CANONICAL_DOMAINS.length).toBe(22);
36
+ });
37
+ it('CANONICAL_DOMAINS contains the four sentinel newly-promoted domains', () => {
38
+ // Spot-check the canonical surface: T964 conduit, T1726 sentient/release,
39
+ // T9528 provenance, T9536 upgrade. Catches the most common drift where
40
+ // someone deletes one and breaks SDK consumers downstream.
41
+ expect(CANONICAL_DOMAINS).toContain('conduit');
42
+ expect(CANONICAL_DOMAINS).toContain('sentient');
43
+ expect(CANONICAL_DOMAINS).toContain('release');
44
+ expect(CANONICAL_DOMAINS).toContain('provenance');
45
+ expect(CANONICAL_DOMAINS).toContain('upgrade');
46
+ });
47
+ it('OperationDef is constructible with the canonical shape (no params field)', () => {
48
+ const def = {
49
+ gateway: 'query',
50
+ domain: 'tasks',
51
+ operation: 'show',
52
+ description: 'tasks.show (query)',
53
+ tier: 0,
54
+ idempotent: true,
55
+ sessionRequired: false,
56
+ requiredParams: ['taskId'],
57
+ };
58
+ expect(def.gateway).toBe('query');
59
+ expect(def.domain).toBe('tasks');
60
+ expect(def.params).toBeUndefined();
61
+ });
62
+ it('OperationDef is constructible with the optional params field populated', () => {
63
+ const def = {
64
+ gateway: 'mutate',
65
+ domain: 'tasks',
66
+ operation: 'add',
67
+ description: 'tasks.add (mutate)',
68
+ tier: 0,
69
+ idempotent: false,
70
+ sessionRequired: false,
71
+ requiredParams: ['title'],
72
+ params: [
73
+ {
74
+ name: 'title',
75
+ type: 'string',
76
+ required: true,
77
+ description: 'Title of the task',
78
+ },
79
+ ],
80
+ };
81
+ expect(def.params).toHaveLength(1);
82
+ expect(def.params?.[0].name).toBe('title');
83
+ });
84
+ it('Resolution wraps a domain + operation + def triple', () => {
85
+ const def = {
86
+ gateway: 'query',
87
+ domain: 'session',
88
+ operation: 'status',
89
+ description: 'session.status (query)',
90
+ tier: 0,
91
+ idempotent: true,
92
+ sessionRequired: false,
93
+ requiredParams: [],
94
+ };
95
+ const r = {
96
+ domain: 'session',
97
+ operation: 'status',
98
+ def,
99
+ };
100
+ expect(r.domain).toBe('session');
101
+ expect(r.def).toBe(def);
102
+ });
103
+ // The five `_Assert…Pinned` aliases above will fail compilation if
104
+ // any shape drifts. The following references prevent unused-locals
105
+ // diagnostics from removing them.
106
+ it('compile-time pins are wired (no-op at runtime)', () => {
107
+ const pinned = [1, 1, 1, 1, 1];
108
+ expect(pinned).toEqual([1, 1, 1, 1, 1]);
109
+ });
110
+ });
111
+ //# sourceMappingURL=operation-def.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operation-def.test.js","sourceRoot":"","sources":["../../src/__tests__/operation-def.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAE9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AA4D5D,uEAAuE;AAEvE,QAAQ,CAAC,kCAAkC,EAAE,GAAG,EAAE;IAChD,EAAE,CAAC,sDAAsD,EAAE,GAAG,EAAE;QAC9D,MAAM,MAAM,GAAc,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QAC9C,MAAM,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IACjC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,mDAAmD,EAAE,GAAG,EAAE;QAC3D,MAAM,KAAK,GAAW,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QAChC,MAAM,CAAC,KAAK,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAChC,CAAC,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EH,mEAAmE;IACnE,mEAAmE;IACnE,kCAAkC;IAClC,EAAE,CAAC,gDAAgD,EAAE,GAAG,EAAE;QACxD,MAAM,MAAM,GAMR,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QACpB,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Structural-equivalence tests for the provenance graph contracts.
3
+ *
4
+ * These tests pin the literal shapes of the 16 provenance/release/BRAIN
5
+ * unions promoted in Phase 0c (T9955) so that accidental narrowing or
6
+ * widening produces a compile-time failure during `tsc -b` in the CI gate.
7
+ *
8
+ * The compile-time assertions use the conditional-equality trick
9
+ * (`Equals<A, B>`) so any structural drift produces a TS2322 or TS2344 at
10
+ * build time. The runtime `expect` shape sanity check below is a thin
11
+ * smoke verification that representative literals satisfy each union — it
12
+ * does NOT exercise behavior (these are pure type contracts with no
13
+ * runtime).
14
+ *
15
+ * @since SG-ARCH-SOLID Saga T9831 · E-CONTRACTS-FOUNDATION T9832 · T9955 (Phase 0c)
16
+ */
17
+ export {};
18
+ //# sourceMappingURL=provenance.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provenance.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/provenance.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG"}
@@ -0,0 +1,142 @@
1
+ /**
2
+ * Structural-equivalence tests for the provenance graph contracts.
3
+ *
4
+ * These tests pin the literal shapes of the 16 provenance/release/BRAIN
5
+ * unions promoted in Phase 0c (T9955) so that accidental narrowing or
6
+ * widening produces a compile-time failure during `tsc -b` in the CI gate.
7
+ *
8
+ * The compile-time assertions use the conditional-equality trick
9
+ * (`Equals<A, B>`) so any structural drift produces a TS2322 or TS2344 at
10
+ * build time. The runtime `expect` shape sanity check below is a thin
11
+ * smoke verification that representative literals satisfy each union — it
12
+ * does NOT exercise behavior (these are pure type contracts with no
13
+ * runtime).
14
+ *
15
+ * @since SG-ARCH-SOLID Saga T9831 · E-CONTRACTS-FOUNDATION T9832 · T9955 (Phase 0c)
16
+ */
17
+ import { describe, expect, it } from 'vitest';
18
+ // ─── Runtime constructibility smoke ─────────────────────────────────
19
+ describe('provenance contracts', () => {
20
+ it('PrState union covers exactly the 3 GitHub PR states', () => {
21
+ const all = ['open', 'closed', 'merged'];
22
+ expect(all).toHaveLength(3);
23
+ });
24
+ it('PrLinkSource enumerates all 5 discovery sources', () => {
25
+ const all = ['pr-title', 'pr-body', 'branch-name', 'commit-trailer', 'manual'];
26
+ expect(all).toHaveLength(5);
27
+ });
28
+ it('PrLinkKind extends CommitLinkKind with the "tracks" addition', () => {
29
+ const commit = 'implements';
30
+ const pr = commit; // every commit-link-kind is a valid pr-link-kind
31
+ expect(pr).toBe('implements');
32
+ const tracks = 'tracks';
33
+ expect(tracks).toBe('tracks');
34
+ });
35
+ it('CommitConventionalType enumerates the canonical CC prefixes plus "breaking"', () => {
36
+ const ccs = [
37
+ 'feat',
38
+ 'fix',
39
+ 'chore',
40
+ 'docs',
41
+ 'refactor',
42
+ 'test',
43
+ 'build',
44
+ 'ci',
45
+ 'perf',
46
+ 'revert',
47
+ 'breaking',
48
+ ];
49
+ expect(ccs).toHaveLength(11);
50
+ expect(ccs).toContain('breaking');
51
+ });
52
+ it('CommitLinkSource and CommitLinkKind are independent unions', () => {
53
+ const src = 'commit-trailer';
54
+ const kind = 'implements';
55
+ expect(src).toBe('commit-trailer');
56
+ expect(kind).toBe('implements');
57
+ });
58
+ it('CommitFileChangeType matches the git status letter codes', () => {
59
+ const codes = ['A', 'M', 'D', 'R', 'C'];
60
+ expect(codes).toHaveLength(5);
61
+ });
62
+ it('ReleaseScheme enumerates calver/semver/calver-suffix', () => {
63
+ const schemes = ['calver', 'semver', 'calver-suffix'];
64
+ expect(schemes).toHaveLength(3);
65
+ });
66
+ it('ReleaseChannel enumerates the provenance-layer channels', () => {
67
+ const channels = ['latest', 'beta', 'dev', 'hotfix'];
68
+ expect(channels).toHaveLength(4);
69
+ });
70
+ it('ReleaseKind enumerates regular/hotfix/prerelease', () => {
71
+ const kinds = ['regular', 'hotfix', 'prerelease'];
72
+ expect(kinds).toHaveLength(3);
73
+ });
74
+ it('ReleaseStatus admits BOTH new-pipeline and legacy-pipeline statuses', () => {
75
+ const newPipeline = [
76
+ 'planned',
77
+ 'pr-opened',
78
+ 'pr-merged',
79
+ 'published',
80
+ 'reconciled',
81
+ ];
82
+ const legacyPipeline = ['prepared', 'committed', 'tagged', 'pushed'];
83
+ const terminals = ['rolled_back', 'failed', 'cancelled'];
84
+ expect(newPipeline).toHaveLength(5);
85
+ expect(legacyPipeline).toHaveLength(4);
86
+ expect(terminals).toHaveLength(3);
87
+ });
88
+ it('ReleaseChangeType enumerates the 12 CLEO change types', () => {
89
+ const types = [
90
+ 'feature',
91
+ 'enhancement',
92
+ 'bug',
93
+ 'hotfix',
94
+ 'security',
95
+ 'breaking',
96
+ 'refactor',
97
+ 'docs',
98
+ 'chore',
99
+ 'revert',
100
+ 'deprecation',
101
+ 'infrastructure',
102
+ ];
103
+ expect(types).toHaveLength(12);
104
+ });
105
+ it('ReleaseImpact enumerates the 4 semver-bump assessments', () => {
106
+ const impacts = ['major', 'minor', 'patch', 'none'];
107
+ expect(impacts).toHaveLength(4);
108
+ });
109
+ it('ReleaseClassifiedBy enumerates auto/manual/approved provenance', () => {
110
+ const provenance = ['auto', 'manual', 'approved'];
111
+ expect(provenance).toHaveLength(3);
112
+ });
113
+ it('ReleaseArtifactType enumerates the 7 supported artifact archetypes', () => {
114
+ const types = [
115
+ 'npm',
116
+ 'cargo',
117
+ 'docker',
118
+ 'pypi',
119
+ 'github-release',
120
+ 'binary',
121
+ 'github-tag',
122
+ ];
123
+ expect(types).toHaveLength(7);
124
+ });
125
+ it('BrainReleaseLinkType enumerates the 4 BRAIN↔release semantics', () => {
126
+ const links = [
127
+ 'approved-by',
128
+ 'documented-in',
129
+ 'derived-from',
130
+ 'observed-in',
131
+ ];
132
+ expect(links).toHaveLength(4);
133
+ });
134
+ // The five `_Assert…Pinned` aliases above will fail compilation if any
135
+ // shape drifts. The following references prevent unused-locals
136
+ // diagnostics from removing them.
137
+ it('compile-time pins are wired (no-op at runtime)', () => {
138
+ const pinned = [1, 1, 1, 1, 1, 1];
139
+ expect(pinned).toEqual([1, 1, 1, 1, 1, 1]);
140
+ });
141
+ });
142
+ //# sourceMappingURL=provenance.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provenance.test.js","sourceRoot":"","sources":["../../src/__tests__/provenance.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AA+F9C,uEAAuE;AAEvE,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;IACpC,EAAE,CAAC,qDAAqD,EAAE,GAAG,EAAE;QAC7D,MAAM,GAAG,GAAc,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;QACpD,MAAM,CAAC,GAAG,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAC9B,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iDAAiD,EAAE,GAAG,EAAE;QACzD,MAAM,GAAG,GAAmB,CAAC,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,gBAAgB,EAAE,QAAQ,CAAC,CAAC;QAC/F,MAAM,CAAC,GAAG,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAC9B,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,8DAA8D,EAAE,GAAG,EAAE;QACtE,MAAM,MAAM,GAAmB,YAAY,CAAC;QAC5C,MAAM,EAA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