Commit 1e29d11
fix(sdk): align WorkflowTrajectory writer with canonical layout + fields
The SDK's WorkflowTrajectory is a standalone writer that emits
trajectory JSON without using the `agent-trajectories` library. Its
output diverged from the canonical layout in two visible ways:
1. Completed files landed in a flat `completed/` root instead of
`completed/YYYY-MM/{id}.json`, forcing downstream readers to grow
legacy-layout fallbacks.
2. Top-level `commits`, `filesChanged`, and `tags` arrays were omitted,
even though the canonical schema declares them. Readers had to
default them at load time.
These are now aligned:
- `moveToCompleted()` computes a `YYYY-MM` bucket from
`completedAt` (falling back to `startedAt`) and writes into
`completed/<bucket>/{id}.json`.
- `TrajectoryFile` interface declares `commits: string[]`,
`filesChanged: string[]`, `tags: string[]`, and `start()` initializes
them to empty arrays.
Canonical output is defense-in-depth — `agent-trajectories` PR #22
(AgentWorkforce/trajectories#22) makes the reader tolerant of the prior
shapes, so this change is not urgent. It does let the reader shed those
fallbacks over time.
Test coverage:
- Existing `readCompletedTrajectoryFile` helper now walks completed/
recursively so tests don't hardcode the bucket name.
- New: asserts the completed file path has exactly one `YYYY-MM`
intermediate directory.
- New: asserts `commits`/`filesChanged`/`tags` are populated as [] on
`start()`.
All 29 tests in `workflow-trajectory.test.ts` pass. Diff scoped to
two files; unrelated full-suite failures (verification.test.ts,
step-executor, etc.) are pre-existing and out of scope.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent da4f2c4 commit 1e29d11
2 files changed
Lines changed: 80 additions & 20 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
40 | | - | |
41 | | - | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
42 | 56 | | |
43 | | - | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
44 | 61 | | |
45 | 62 | | |
46 | 63 | | |
| |||
135 | 152 | | |
136 | 153 | | |
137 | 154 | | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
138 | 183 | | |
139 | 184 | | |
140 | 185 | | |
| |||
143 | 188 | | |
144 | 189 | | |
145 | 190 | | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
| 191 | + | |
150 | 192 | | |
151 | 193 | | |
152 | 194 | | |
| |||
157 | 199 | | |
158 | 200 | | |
159 | 201 | | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
| 202 | + | |
165 | 203 | | |
166 | 204 | | |
167 | 205 | | |
| |||
175 | 213 | | |
176 | 214 | | |
177 | 215 | | |
178 | | - | |
| 216 | + | |
179 | 217 | | |
180 | 218 | | |
181 | 219 | | |
| |||
186 | 224 | | |
187 | 225 | | |
188 | 226 | | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
| 227 | + | |
193 | 228 | | |
194 | 229 | | |
195 | 230 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
69 | 78 | | |
70 | 79 | | |
71 | 80 | | |
| |||
191 | 200 | | |
192 | 201 | | |
193 | 202 | | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
194 | 206 | | |
195 | 207 | | |
196 | 208 | | |
| |||
765 | 777 | | |
766 | 778 | | |
767 | 779 | | |
768 | | - | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
769 | 794 | | |
770 | 795 | | |
771 | 796 | | |
| |||
0 commit comments