@critical-path/core 0.36.0 → 0.36.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 (185) hide show
  1. package/package.json +5 -1
  2. package/CHANGELOG.md +0 -593
  3. package/dist/deliverables.test.d.ts +0 -2
  4. package/dist/deliverables.test.d.ts.map +0 -1
  5. package/dist/deliverables.test.js +0 -232
  6. package/dist/deliverables.test.js.map +0 -1
  7. package/dist/domain/calendar.test.d.ts +0 -2
  8. package/dist/domain/calendar.test.d.ts.map +0 -1
  9. package/dist/domain/calendar.test.js +0 -181
  10. package/dist/domain/calendar.test.js.map +0 -1
  11. package/dist/domain/cpm.test.d.ts +0 -2
  12. package/dist/domain/cpm.test.d.ts.map +0 -1
  13. package/dist/domain/cpm.test.js +0 -166
  14. package/dist/domain/cpm.test.js.map +0 -1
  15. package/dist/domain/ddd.test.d.ts +0 -2
  16. package/dist/domain/ddd.test.d.ts.map +0 -1
  17. package/dist/domain/ddd.test.js +0 -349
  18. package/dist/domain/ddd.test.js.map +0 -1
  19. package/dist/domain/ladder.test.d.ts +0 -2
  20. package/dist/domain/ladder.test.d.ts.map +0 -1
  21. package/dist/domain/ladder.test.js +0 -213
  22. package/dist/domain/ladder.test.js.map +0 -1
  23. package/dist/domain/metrics.test.d.ts +0 -2
  24. package/dist/domain/metrics.test.d.ts.map +0 -1
  25. package/dist/domain/metrics.test.js +0 -252
  26. package/dist/domain/metrics.test.js.map +0 -1
  27. package/dist/domain/task-duration.test.d.ts +0 -2
  28. package/dist/domain/task-duration.test.d.ts.map +0 -1
  29. package/dist/domain/task-duration.test.js +0 -307
  30. package/dist/domain/task-duration.test.js.map +0 -1
  31. package/dist/domain/workload.test.d.ts +0 -2
  32. package/dist/domain/workload.test.d.ts.map +0 -1
  33. package/dist/domain/workload.test.js +0 -261
  34. package/dist/domain/workload.test.js.map +0 -1
  35. package/dist/engine/actor.test.d.ts +0 -2
  36. package/dist/engine/actor.test.d.ts.map +0 -1
  37. package/dist/engine/actor.test.js +0 -54
  38. package/dist/engine/actor.test.js.map +0 -1
  39. package/dist/engine/authorization.test.d.ts +0 -2
  40. package/dist/engine/authorization.test.d.ts.map +0 -1
  41. package/dist/engine/authorization.test.js +0 -154
  42. package/dist/engine/authorization.test.js.map +0 -1
  43. package/dist/engine/cascade.test.d.ts +0 -2
  44. package/dist/engine/cascade.test.d.ts.map +0 -1
  45. package/dist/engine/cascade.test.js +0 -99
  46. package/dist/engine/cascade.test.js.map +0 -1
  47. package/dist/engine/config.test.d.ts +0 -2
  48. package/dist/engine/config.test.d.ts.map +0 -1
  49. package/dist/engine/config.test.js +0 -46
  50. package/dist/engine/config.test.js.map +0 -1
  51. package/dist/engine/entity-events.test.d.ts +0 -2
  52. package/dist/engine/entity-events.test.d.ts.map +0 -1
  53. package/dist/engine/entity-events.test.js +0 -61
  54. package/dist/engine/entity-events.test.js.map +0 -1
  55. package/dist/index.test.d.ts +0 -2
  56. package/dist/index.test.d.ts.map +0 -1
  57. package/dist/index.test.js +0 -429
  58. package/dist/index.test.js.map +0 -1
  59. package/dist/plugins/plugins.test.d.ts +0 -2
  60. package/dist/plugins/plugins.test.d.ts.map +0 -1
  61. package/dist/plugins/plugins.test.js +0 -137
  62. package/dist/plugins/plugins.test.js.map +0 -1
  63. package/dist/schemas/schemas.test.d.ts +0 -2
  64. package/dist/schemas/schemas.test.d.ts.map +0 -1
  65. package/dist/schemas/schemas.test.js +0 -58
  66. package/dist/schemas/schemas.test.js.map +0 -1
  67. package/dist/status.test.d.ts +0 -2
  68. package/dist/status.test.d.ts.map +0 -1
  69. package/dist/status.test.js +0 -295
  70. package/dist/status.test.js.map +0 -1
  71. package/dist/storage/storage.test.d.ts +0 -2
  72. package/dist/storage/storage.test.d.ts.map +0 -1
  73. package/dist/storage/storage.test.js +0 -236
  74. package/dist/storage/storage.test.js.map +0 -1
  75. package/dist/storage/upload-limits.test.d.ts +0 -2
  76. package/dist/storage/upload-limits.test.d.ts.map +0 -1
  77. package/dist/storage/upload-limits.test.js +0 -31
  78. package/dist/storage/upload-limits.test.js.map +0 -1
  79. package/dist/store/conformance.test.d.ts +0 -2
  80. package/dist/store/conformance.test.d.ts.map +0 -1
  81. package/dist/store/conformance.test.js +0 -15
  82. package/dist/store/conformance.test.js.map +0 -1
  83. package/dist/store/firebase.test.d.ts +0 -2
  84. package/dist/store/firebase.test.d.ts.map +0 -1
  85. package/dist/store/firebase.test.js +0 -103
  86. package/dist/store/firebase.test.js.map +0 -1
  87. package/dist/store/query.test.d.ts +0 -2
  88. package/dist/store/query.test.d.ts.map +0 -1
  89. package/dist/store/query.test.js +0 -89
  90. package/dist/store/query.test.js.map +0 -1
  91. package/dist/store/sqlite.test.d.ts +0 -2
  92. package/dist/store/sqlite.test.d.ts.map +0 -1
  93. package/dist/store/sqlite.test.js +0 -177
  94. package/dist/store/sqlite.test.js.map +0 -1
  95. package/dist/task-state.test.d.ts +0 -2
  96. package/dist/task-state.test.d.ts.map +0 -1
  97. package/dist/task-state.test.js +0 -423
  98. package/dist/task-state.test.js.map +0 -1
  99. package/dist/use-case-validation.test.d.ts +0 -2
  100. package/dist/use-case-validation.test.d.ts.map +0 -1
  101. package/dist/use-case-validation.test.js +0 -281
  102. package/dist/use-case-validation.test.js.map +0 -1
  103. package/dist/utils/fractional-index.test.d.ts +0 -2
  104. package/dist/utils/fractional-index.test.d.ts.map +0 -1
  105. package/dist/utils/fractional-index.test.js +0 -182
  106. package/dist/utils/fractional-index.test.js.map +0 -1
  107. package/dist/utils/key.test.d.ts +0 -2
  108. package/dist/utils/key.test.d.ts.map +0 -1
  109. package/dist/utils/key.test.js +0 -65
  110. package/dist/utils/key.test.js.map +0 -1
  111. package/dist/utils/mentions.test.d.ts +0 -2
  112. package/dist/utils/mentions.test.d.ts.map +0 -1
  113. package/dist/utils/mentions.test.js +0 -114
  114. package/dist/utils/mentions.test.js.map +0 -1
  115. package/dist/webhooks/webhooks.test.d.ts +0 -2
  116. package/dist/webhooks/webhooks.test.d.ts.map +0 -1
  117. package/dist/webhooks/webhooks.test.js +0 -154
  118. package/dist/webhooks/webhooks.test.js.map +0 -1
  119. package/src/deliverables.test.ts +0 -284
  120. package/src/domain/authorization.ts +0 -82
  121. package/src/domain/calendar.test.ts +0 -216
  122. package/src/domain/calendar.ts +0 -502
  123. package/src/domain/cpm.test.ts +0 -189
  124. package/src/domain/cpm.ts +0 -258
  125. package/src/domain/custom-fields.ts +0 -172
  126. package/src/domain/ddd.test.ts +0 -442
  127. package/src/domain/entities.ts +0 -798
  128. package/src/domain/errors.ts +0 -38
  129. package/src/domain/events.ts +0 -369
  130. package/src/domain/graph.ts +0 -70
  131. package/src/domain/index.ts +0 -12
  132. package/src/domain/ladder.test.ts +0 -251
  133. package/src/domain/ladder.ts +0 -474
  134. package/src/domain/metrics.test.ts +0 -288
  135. package/src/domain/metrics.ts +0 -497
  136. package/src/domain/task-duration.test.ts +0 -354
  137. package/src/domain/workload.test.ts +0 -311
  138. package/src/domain/workload.ts +0 -457
  139. package/src/engine/actor.test.ts +0 -63
  140. package/src/engine/authorization.test.ts +0 -199
  141. package/src/engine/cascade.test.ts +0 -121
  142. package/src/engine/config.test.ts +0 -51
  143. package/src/engine/entity-events.test.ts +0 -67
  144. package/src/engine/index.ts +0 -2495
  145. package/src/index.test.ts +0 -514
  146. package/src/index.ts +0 -9
  147. package/src/plugins/index.ts +0 -103
  148. package/src/plugins/plugins.test.ts +0 -161
  149. package/src/schemas/index.ts +0 -402
  150. package/src/schemas/schemas.test.ts +0 -116
  151. package/src/status.test.ts +0 -354
  152. package/src/storage/file-storage.ts +0 -200
  153. package/src/storage/firebase-storage.ts +0 -209
  154. package/src/storage/index.ts +0 -3
  155. package/src/storage/s3.ts +0 -151
  156. package/src/storage/storage.test.ts +0 -274
  157. package/src/storage/upload-limits.test.ts +0 -41
  158. package/src/store/conformance.test.ts +0 -15
  159. package/src/store/firebase.test.ts +0 -131
  160. package/src/store/firebase.ts +0 -658
  161. package/src/store/index.ts +0 -623
  162. package/src/store/query.test.ts +0 -110
  163. package/src/store/query.ts +0 -113
  164. package/src/store/sqlite.test.ts +0 -218
  165. package/src/store/sqlite.ts +0 -1480
  166. package/src/task-state.test.ts +0 -506
  167. package/src/testing/conformance.ts +0 -319
  168. package/src/testing/index.ts +0 -1
  169. package/src/types/index.ts +0 -871
  170. package/src/use-case-validation.test.ts +0 -324
  171. package/src/utils/fractional-index.test.ts +0 -228
  172. package/src/utils/fractional-index.ts +0 -254
  173. package/src/utils/index.ts +0 -7
  174. package/src/utils/key.test.ts +0 -76
  175. package/src/utils/key.ts +0 -62
  176. package/src/utils/mentions.test.ts +0 -132
  177. package/src/utils/mentions.ts +0 -131
  178. package/src/utils/status.ts +0 -419
  179. package/src/utils/workflow.ts +0 -306
  180. package/src/webhooks/dispatcher.ts +0 -190
  181. package/src/webhooks/index.ts +0 -2
  182. package/src/webhooks/signature.ts +0 -57
  183. package/src/webhooks/webhooks.test.ts +0 -201
  184. package/tsconfig.json +0 -8
  185. package/tsconfig.tsbuildinfo +0 -1
@@ -1,288 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import type { Task, Activity, TimeEntry } from '../types/index.js';
3
- import {
4
- inferTaskProgress,
5
- calculateTaskEVM,
6
- reconstructTaskProgressHistory,
7
- calculateTaskMetrics
8
- } from './metrics.js';
9
- import { TaskEntity } from './entities.js';
10
- import { CriticalPathEngine } from '../engine/index.js';
11
- import { InMemoryStore } from '../store/index.js';
12
-
13
- describe('Task Metrics Domain', () => {
14
- const baseTask: Task = {
15
- id: 'task-1',
16
- projectId: 'proj-1',
17
- title: 'Design API Architecture',
18
- status: 'in_progress',
19
- semanticStatus: 'in_progress',
20
- priority: 'high',
21
- estimatedHours: 20,
22
- loggedHours: 10,
23
- actualStartDate: '2026-09-01T09:00:00Z',
24
- dueDate: '2026-09-10T17:00:00Z',
25
- createdAt: '2026-09-01T08:00:00Z',
26
- updatedAt: '2026-09-05T12:00:00Z'
27
- };
28
-
29
- describe('inferTaskProgress', () => {
30
- it('returns 100% progress for completed tasks', () => {
31
- const completedTask: Task = { ...baseTask, status: 'done', semanticStatus: 'completed' };
32
- const res = inferTaskProgress(completedTask);
33
- expect(res.progressPercentage).toBe(100);
34
- expect(res.breakdown.effortProgress).toBe(100);
35
- expect(res.breakdown.scheduleProgress).toBe(100);
36
- });
37
-
38
- it('uses explicit progress when provided', () => {
39
- const taskWithExplicit: Task = {
40
- ...baseTask,
41
- progress: 45,
42
- todos: [
43
- { id: 't1', title: 'Step 1', completed: true },
44
- { id: 't2', title: 'Step 2', completed: false }
45
- ]
46
- };
47
- const res = inferTaskProgress(taskWithExplicit);
48
- expect(res.isExplicit).toBe(true);
49
- expect(res.source).toBe('explicit');
50
- expect(res.progressPercentage).toBe(45);
51
- expect(res.breakdown.explicitProgress).toBe(45);
52
- expect(res.breakdown.todoProgress).toBe(50);
53
- });
54
-
55
- it('infers progress from todos when explicit progress is absent', () => {
56
- const taskWithTodos: Task = {
57
- ...baseTask,
58
- progress: undefined,
59
- todos: [
60
- { id: 't1', title: 'Step 1', completed: true },
61
- { id: 't2', title: 'Step 2', completed: true },
62
- { id: 't3', title: 'Step 3', completed: false },
63
- { id: 't4', title: 'Step 4', completed: false }
64
- ]
65
- };
66
- const res = inferTaskProgress(taskWithTodos);
67
- expect(res.isExplicit).toBe(false);
68
- expect(res.source).toBe('todos');
69
- expect(res.progressPercentage).toBe(50);
70
- expect(res.breakdown.todoProgress).toBe(50);
71
- });
72
-
73
- it('infers progress from effort (logged vs estimated) when todos and explicit are absent', () => {
74
- const taskWithEffort: Task = {
75
- ...baseTask,
76
- progress: undefined,
77
- todos: undefined,
78
- estimatedHours: 40,
79
- loggedHours: 10
80
- };
81
- const res = inferTaskProgress(taskWithEffort);
82
- expect(res.isExplicit).toBe(false);
83
- expect(res.source).toBe('time_effort');
84
- expect(res.progressPercentage).toBe(25);
85
- expect(res.breakdown.effortProgress).toBe(25);
86
- });
87
-
88
- it('infers progress from schedule elapsed time when no other metrics are present', () => {
89
- const taskWithSchedule: Task = {
90
- ...baseTask,
91
- progress: undefined,
92
- todos: undefined,
93
- estimatedHours: 0,
94
- loggedHours: 0,
95
- actualStartDate: '2026-09-01T00:00:00Z',
96
- dueDate: '2026-09-11T00:00:00Z'
97
- };
98
- const midDate = new Date('2026-09-06T00:00:00Z'); // 50% elapsed
99
- const res = inferTaskProgress(taskWithSchedule, { referenceDate: midDate });
100
- expect(res.source).toBe('schedule_elapsed');
101
- expect(res.progressPercentage).toBe(50);
102
- expect(res.breakdown.scheduleProgress).toBe(50);
103
- });
104
- });
105
-
106
- describe('calculateTaskEVM', () => {
107
- it('computes standard EVM values for on-track tasks', () => {
108
- const task: Task = {
109
- ...baseTask,
110
- estimatedHours: 20,
111
- loggedHours: 10,
112
- actualStartDate: '2026-09-01T00:00:00Z',
113
- dueDate: '2026-09-11T00:00:00Z',
114
- progress: 50
115
- };
116
- const midDate = new Date('2026-09-06T00:00:00Z'); // 50% expected
117
- const evm = calculateTaskEVM(task, { referenceDate: midDate });
118
-
119
- expect(evm.plannedValue).toBe(10); // 50% of 20h
120
- expect(evm.earnedValue).toBe(10); // 50% of 20h
121
- expect(evm.actualCost).toBe(10);
122
- expect(evm.costVariance).toBe(0);
123
- expect(evm.scheduleVariance).toBe(0);
124
- expect(evm.costPerformanceIndex).toBe(1.0);
125
- expect(evm.schedulePerformanceIndex).toBe(1.0);
126
- });
127
-
128
- it('detects cost overrun and schedule lag (CPI < 1, SPI < 1)', () => {
129
- const task: Task = {
130
- ...baseTask,
131
- estimatedHours: 20,
132
- loggedHours: 15, // Spent 15h
133
- progress: 25, // Only 25% complete (5h EV)
134
- actualStartDate: '2026-09-01T00:00:00Z',
135
- dueDate: '2026-09-11T00:00:00Z'
136
- };
137
- const midDate = new Date('2026-09-06T00:00:00Z'); // 50% expected (10h PV)
138
- const evm = calculateTaskEVM(task, { referenceDate: midDate });
139
-
140
- expect(evm.plannedValue).toBe(10);
141
- expect(evm.earnedValue).toBe(5);
142
- expect(evm.actualCost).toBe(15);
143
- expect(evm.costVariance).toBe(-10); // 5 - 15 = -10
144
- expect(evm.scheduleVariance).toBe(-5); // 5 - 10 = -5
145
- expect(evm.costPerformanceIndex).toBe(0.33); // 5 / 15
146
- expect(evm.schedulePerformanceIndex).toBe(0.5); // 5 / 10
147
- });
148
- });
149
-
150
- describe('reconstructTaskProgressHistory & Curve Profile', () => {
151
- const referenceDate = new Date('2026-09-09T12:00:00Z');
152
-
153
- it('detects linear progress', () => {
154
- const activities: Activity[] = [
155
- { id: 'a1', taskId: 'task-1', actorId: 'u1', action: 'task.updated', details: { progress: 25 }, createdAt: '2026-09-02T10:00:00Z' },
156
- { id: 'a2', taskId: 'task-1', actorId: 'u1', action: 'task.updated', details: { progress: 50 }, createdAt: '2026-09-04T10:00:00Z' },
157
- { id: 'a3', taskId: 'task-1', actorId: 'u1', action: 'task.updated', details: { progress: 75 }, createdAt: '2026-09-06T10:00:00Z' },
158
- { id: 'a4', taskId: 'task-1', actorId: 'u1', action: 'task.updated', details: { progress: 100 }, createdAt: '2026-09-08T10:00:00Z' }
159
- ];
160
- const task: Task = { ...baseTask, progress: 100, updatedAt: '2026-09-08T10:00:00Z' };
161
- const history = reconstructTaskProgressHistory(task, activities, { referenceDate });
162
-
163
- expect(history.points.length).toBeGreaterThanOrEqual(4);
164
- expect(history.curveProfile).toBe('linear');
165
- });
166
-
167
- it('detects S-Curve progress', () => {
168
- const activities: Activity[] = [
169
- { id: 'a1', taskId: 'task-1', actorId: 'u1', action: 'task.updated', details: { progress: 15 }, createdAt: '2026-09-02T10:00:00Z' },
170
- { id: 'a2', taskId: 'task-1', actorId: 'u1', action: 'task.updated', details: { progress: 45 }, createdAt: '2026-09-05T10:00:00Z' },
171
- { id: 'a3', taskId: 'task-1', actorId: 'u1', action: 'task.updated', details: { progress: 85 }, createdAt: '2026-09-07T10:00:00Z' },
172
- { id: 'a4', taskId: 'task-1', actorId: 'u1', action: 'task.updated', details: { progress: 95 }, createdAt: '2026-09-09T10:00:00Z' }
173
- ];
174
- const task: Task = { ...baseTask, progress: 95, updatedAt: '2026-09-09T10:00:00Z' };
175
- const history = reconstructTaskProgressHistory(task, activities, { referenceDate });
176
-
177
- expect(history.curveProfile).toBe('s_curve');
178
- });
179
-
180
- it('detects early surge progress', () => {
181
- const activities: Activity[] = [
182
- { id: 'a1', taskId: 'task-1', actorId: 'u1', action: 'task.updated', details: { progress: 75 }, createdAt: '2026-09-02T10:00:00Z' },
183
- { id: 'a2', taskId: 'task-1', actorId: 'u1', action: 'task.updated', details: { progress: 75 }, createdAt: '2026-09-05T10:00:00Z' },
184
- { id: 'a3', taskId: 'task-1', actorId: 'u1', action: 'task.updated', details: { progress: 78 }, createdAt: '2026-09-08T10:00:00Z' }
185
- ];
186
- const task: Task = { ...baseTask, progress: 78, updatedAt: '2026-09-08T10:00:00Z' };
187
- const history = reconstructTaskProgressHistory(task, activities, { referenceDate });
188
-
189
- expect(history.curveProfile).toBe('early_surge');
190
- });
191
-
192
- it('detects late rush progress', () => {
193
- const activities: Activity[] = [
194
- { id: 'a1', taskId: 'task-1', actorId: 'u1', action: 'task.updated', details: { progress: 10 }, createdAt: '2026-09-03T10:00:00Z' },
195
- { id: 'a2', taskId: 'task-1', actorId: 'u1', action: 'task.updated', details: { progress: 15 }, createdAt: '2026-09-06T10:00:00Z' },
196
- { id: 'a3', taskId: 'task-1', actorId: 'u1', action: 'task.updated', details: { progress: 90 }, createdAt: '2026-09-08T10:00:00Z' }
197
- ];
198
- const task: Task = { ...baseTask, progress: 90, updatedAt: '2026-09-08T10:00:00Z' };
199
- const history = reconstructTaskProgressHistory(task, activities, { referenceDate });
200
-
201
- expect(history.curveProfile).toBe('late_rush');
202
- });
203
- });
204
-
205
- describe('calculateTaskMetrics & Multi-dimensional Variance', () => {
206
- it('computes complete metrics with effort and schedule variances', () => {
207
- const task: Task = {
208
- ...baseTask,
209
- plannedStartDate: '2026-09-01T09:00:00Z',
210
- actualStartDate: '2026-09-01T09:00:00Z',
211
- dueDate: '2026-09-05T17:00:00Z',
212
- actualEndDate: '2026-09-07T17:00:00Z',
213
- status: 'done',
214
- semanticStatus: 'completed',
215
- estimatedHours: 20,
216
- loggedHours: 25
217
- };
218
-
219
- const metrics = calculateTaskMetrics(task);
220
- expect(metrics.taskId).toBe('task-1');
221
- expect(metrics.realityDelta.varianceHours).toBe(5);
222
- expect(metrics.realityDelta.effortVarianceHours).toBe(5);
223
- expect(metrics.realityDelta.accuracyRatio).toBe(1.25); // 25 / 20
224
- expect(metrics.realityDelta.scheduleVarianceDays).toBe(2); // Completed 2 days late
225
- expect(metrics.realityDelta.durationVarianceHours).toBe(48); // 2 days extra duration
226
- expect(metrics.inferredActuals.activeWorkingHours).toBeGreaterThan(0);
227
- expect(metrics.inferredActuals.isEndDateInferred).toBe(true);
228
- });
229
- });
230
-
231
- describe('Task Re-opening Timestamp Behavior', () => {
232
- it('resets actualEndDate when TaskEntity transitions from completed back to in_progress', () => {
233
- const entity = TaskEntity.create({
234
- projectId: 'proj-1',
235
- title: 'Bugfix',
236
- status: 'todo'
237
- });
238
-
239
- // Move to in_progress -> stamps actualStartDate
240
- entity.transitionTo('in_progress');
241
- expect(entity.actualStartDate).toBeDefined();
242
- expect(entity.actualEndDate).toBeUndefined();
243
-
244
- // Move to done -> stamps actualEndDate
245
- entity.transitionTo('done');
246
- expect(entity.actualEndDate).toBeDefined();
247
-
248
- // Re-open back to in_progress -> actualEndDate must be cleared
249
- entity.transitionTo('in_progress');
250
- expect(entity.actualEndDate).toBeUndefined();
251
- expect(entity.actualStartDate).toBeDefined();
252
- });
253
-
254
- it('integrates with CriticalPathEngine getTaskMetrics and getTaskProgressHistory', async () => {
255
- const store = new InMemoryStore();
256
- const engine = new CriticalPathEngine({ store });
257
-
258
- const project = await engine.createProject({ name: 'Engine Test' });
259
- const task = await engine.createTask({
260
- projectId: project.id,
261
- title: 'Implement Auth',
262
- estimatedHours: 16
263
- });
264
-
265
- // Move to in_progress
266
- await engine.updateTask(task.id, { status: 'in_progress' });
267
- await engine.logTime({ taskId: task.id, hours: 8, isBillable: true });
268
-
269
- const metrics = await engine.getTaskMetrics(task.id);
270
- expect(metrics).not.toBeNull();
271
- expect(metrics?.taskId).toBe(task.id);
272
- expect(metrics?.realityDelta.loggedHours).toBe(8);
273
- expect(metrics?.realityDelta.estimatedHours).toBe(16);
274
- expect(metrics?.progress.source).toBe('time_effort');
275
- expect(metrics?.progress.progressPercentage).toBe(50);
276
- expect(metrics?.evm.earnedValue).toBe(8);
277
-
278
- const history = await engine.getTaskProgressHistory(task.id);
279
- expect(history).not.toBeNull();
280
- expect(history?.points.length).toBeGreaterThanOrEqual(1);
281
-
282
- // Verify ladder view includes metrics
283
- const ladder = await engine.getTaskLadder(task.id);
284
- expect(ladder?.metrics).toBeDefined();
285
- expect(ladder?.metrics?.taskId).toBe(task.id);
286
- });
287
- });
288
- });