Commit 49fd9be
authored
* fix(tracing): reliability follow-ups from the v0.8.4 review (#901, #902, #903)
Three follow-ups filed during the v0.8.4 release review of the trace-data-loss
fix (#895):
#901 — reconstructed spans no longer masquerade as failures. When
`rehydrateFromFile` force-closes an in-flight generation span (worker restart /
cache eviction), the span kept `status: "error"`, so the viewer painted it red
and counted it in the session error total — a false alarm on a postmortem
surface. Spans now also carry `interrupted: true`; the viewer renders them with
an amber "⚠" affordance and an "Interrupted" detail label instead of red, and
the session error count (`errSpans`) excludes them. `status: "error"` is kept so
the boundary stays visible, so existing rehydrate tests are unaffected.
#902 — `getOrCreateTrace` can no longer resurrect a Trace into a cleared cache.
The async rehydrate added an await point where a concurrent `startEventStream`
(e.g. `setWorkspace`) can abort the stream and `sessionTraces.clear()` while
we're suspended. On resume the old code inserted the freshly built Trace into
the just-cleared map — an orphan writer under a dead stream. We now capture the
owning stream before the await and, if it was replaced, discard the Trace
(`endTrace`) and defer to the live stream instead of inserting.
#903 — long-lived traces no longer grow `ses_<id>.json` without bound.
`snapshot()` rewrites the entire spans array on every event, so an unbounded
session paid O(n) per write (O(n^2) overall) and grew the file forever.
`capSpansForSerialization` bounds the on-disk projection to `MAX_SERIALIZED_SPANS`
(default 5000, override via `ALTIMATE_TRACE_MAX_SPANS`) by keeping the head
(prompt + first tools) and tail (recent activity) and eliding the middle with a
single marker span. In-memory spans are untouched; summary counters are separate
counters, so totals are unaffected.
Tests: `test/altimate/tracing-followups.test.ts` — interrupted flag is set on
rehydrate; viewer carries the amber/`!sp.interrupted` contract and the flag in
embedded data; `capSpansForSerialization` head/tail/marker behavior, no-op under
cap, and no-benefit guard; plus a scope-bounded source contract for the #902
guard ordering (await → guard → insert).
`worker.ts` edits are wrapped in `altimate_change` markers (upstream-shared).
tracing.ts / viewer.ts are altimate-owned.
Closes #901
Closes #902
Closes #903
* fix(tracing): harden follow-ups per multi-model review (#901, #902, #903)
Addresses findings from the GPT-5.4 + Kimi-K2.5 review panel:
#902 (MAJOR) — key the orphan-writer guard on a monotonic `streamGeneration`
counter bumped in startEventStream, not on AbortController object identity. The
identity check was correct only while startEventStream always allocates a fresh
controller; the counter makes ownership explicit and removes that hidden
dependency. The check and the cache insert run in one synchronous turn (no await
between), so the insert can't race a later startEventStream.
#903 (MAJOR) — capSpansForSerialization now explicitly guarantees the structural
root (session) span survives the cut even if it isn't in the head slice, instead
of relying on "root happens to be index 0". Rehydrate and the viewer tree both
require the root, and the elision marker is parented to it. Added table-driven
tests: root-not-at-index-0, tiny caps (1–5) with marker-parent validity, the
exact head+tail+1===length boundary, and elided-count accuracy.
#901 (Kimi blockers) — interrupted spans now render amber (not red) on EVERY
viewer surface, not just the preview/detail: waterfall row + icon class, tree-view
meta ("interrupted" in orange), and log-view row (⚠ amber). errSpans already
excluded them; this makes the visual treatment consistent so a reconstructed
trace never looks like a failed one anywhere.
Known minor (deferred, noted on PR): a trace containing ONLY interrupted spans
no longer contributes to the summary error count (correct) but also shows no
"incomplete" hint in the summary; a dedicated interrupted/incomplete banner is a
small follow-up.
1 parent db81d41 commit 49fd9be
4 files changed
Lines changed: 350 additions & 10 deletions
File tree
- packages/opencode
- src
- altimate/observability
- cli/cmd/tui
- test/altimate
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
50 | 58 | | |
51 | 59 | | |
52 | 60 | | |
| |||
349 | 357 | | |
350 | 358 | | |
351 | 359 | | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
352 | 416 | | |
353 | 417 | | |
354 | 418 | | |
| |||
592 | 656 | | |
593 | 657 | | |
594 | 658 | | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
595 | 662 | | |
596 | 663 | | |
597 | 664 | | |
| |||
927 | 994 | | |
928 | 995 | | |
929 | 996 | | |
| 997 | + | |
| 998 | + | |
930 | 999 | | |
931 | 1000 | | |
932 | 1001 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
196 | 196 | | |
197 | 197 | | |
198 | 198 | | |
| 199 | + | |
199 | 200 | | |
200 | 201 | | |
201 | 202 | | |
| |||
222 | 223 | | |
223 | 224 | | |
224 | 225 | | |
| 226 | + | |
225 | 227 | | |
226 | 228 | | |
227 | 229 | | |
| |||
443 | 445 | | |
444 | 446 | | |
445 | 447 | | |
446 | | - | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
447 | 451 | | |
448 | 452 | | |
449 | 453 | | |
| |||
467 | 471 | | |
468 | 472 | | |
469 | 473 | | |
470 | | - | |
| 474 | + | |
471 | 475 | | |
472 | 476 | | |
473 | 477 | | |
| |||
487 | 491 | | |
488 | 492 | | |
489 | 493 | | |
490 | | - | |
491 | | - | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
492 | 497 | | |
493 | 498 | | |
494 | 499 | | |
| |||
565 | 570 | | |
566 | 571 | | |
567 | 572 | | |
568 | | - | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
569 | 577 | | |
570 | 578 | | |
571 | 579 | | |
| |||
1239 | 1247 | | |
1240 | 1248 | | |
1241 | 1249 | | |
1242 | | - | |
| 1250 | + | |
1243 | 1251 | | |
1244 | 1252 | | |
1245 | 1253 | | |
1246 | 1254 | | |
1247 | | - | |
| 1255 | + | |
1248 | 1256 | | |
1249 | 1257 | | |
1250 | 1258 | | |
| |||
1278 | 1286 | | |
1279 | 1287 | | |
1280 | 1288 | | |
1281 | | - | |
| 1289 | + | |
| 1290 | + | |
1282 | 1291 | | |
1283 | 1292 | | |
1284 | 1293 | | |
| |||
1390 | 1399 | | |
1391 | 1400 | | |
1392 | 1401 | | |
1393 | | - | |
| 1402 | + | |
1394 | 1403 | | |
1395 | 1404 | | |
1396 | 1405 | | |
| |||
1400 | 1409 | | |
1401 | 1410 | | |
1402 | 1411 | | |
1403 | | - | |
| 1412 | + | |
| 1413 | + | |
1404 | 1414 | | |
1405 | 1415 | | |
1406 | 1416 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
50 | 58 | | |
51 | 59 | | |
52 | 60 | | |
| |||
83 | 91 | | |
84 | 92 | | |
85 | 93 | | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
86 | 101 | | |
87 | 102 | | |
88 | 103 | | |
| |||
106 | 121 | | |
107 | 122 | | |
108 | 123 | | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
109 | 135 | | |
110 | 136 | | |
111 | 137 | | |
| 138 | + | |
112 | 139 | | |
113 | 140 | | |
114 | 141 | | |
| |||
117 | 144 | | |
118 | 145 | | |
119 | 146 | | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
120 | 151 | | |
121 | 152 | | |
122 | 153 | | |
| |||
0 commit comments