@vzn/vx 0.0.515 → 0.0.516

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vzn/vx",
3
- "version": "0.0.515",
3
+ "version": "0.0.516",
4
4
  "description": "The fastest task runner and build cache for JavaScript monorepos.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -21,10 +21,10 @@
21
21
  "node": ">=18"
22
22
  },
23
23
  "optionalDependencies": {
24
- "@vzn/vx-linux-x64": "0.0.515",
25
- "@vzn/vx-linux-arm64": "0.0.515",
26
- "@vzn/vx-darwin-x64": "0.0.515",
27
- "@vzn/vx-darwin-arm64": "0.0.515"
24
+ "@vzn/vx-linux-x64": "0.0.516",
25
+ "@vzn/vx-linux-arm64": "0.0.516",
26
+ "@vzn/vx-darwin-x64": "0.0.516",
27
+ "@vzn/vx-darwin-arm64": "0.0.516"
28
28
  },
29
29
  "dependencies": {
30
30
  "@anthropic-ai/sandbox-runtime": "^0.0.76"
@@ -139,6 +139,11 @@ export interface TaskOutcome {
139
139
  * flaky detection reads it off the outcome stream.
140
140
  */
141
141
  attempts?: number
142
+ /**
143
+ * Set when this run proved the task flaky: its key holds both outcomes on
144
+ * record (this run's included) or it needed a retry. Its row carries it.
145
+ */
146
+ flaky?: { passes: number; failures: number }
142
147
  /**
143
148
  * Count of sandbox violations captured during this task's exec (a task
144
149
  * declaring `exec.sandbox`). Non-zero means the task touched something
@@ -291,8 +291,7 @@ export function outcomeLabel(
291
291
 
292
292
  /**
293
293
  * Why a task was skipped, one copy for every surface: `blocked by lib#build`
294
- * (the failed or aborted task at the root of the block, what the footer's
295
- * Skipped section groups by), or '' for fail-fast's skip — the run stopped,
294
+ * (the failed or aborted task at the root of the block), or '' for fail-fast's skip — the run stopped,
296
295
  * nothing blocked it, and a label claiming an upstream failure would lie.
297
296
  */
298
297
  export function skippedReason(blockedBy: string | undefined): string {
@@ -344,22 +344,42 @@ function formatOutcomeRow(
344
344
  ): string {
345
345
  const st = statusOf(o)
346
346
  const ca = cacheOf(o)
347
- return formatTaskRow(
348
- taskGlyph(o, colors),
349
- ms,
350
- st.word,
351
- st.color,
352
- ca.word,
353
- ca.color,
354
- paintedId,
355
- colors,
347
+ return (
348
+ formatTaskRow(
349
+ taskGlyph(o, colors),
350
+ ms,
351
+ st.word,
352
+ st.color,
353
+ ca.word,
354
+ ca.color,
355
+ paintedId,
356
+ colors,
357
+ ) + flakyNote(o, colors)
356
358
  )
357
359
  }
358
360
 
361
+ /**
362
+ * The dim note a flaky task's row and frame carry (`flaky - failed 1×
363
+ * before`): nothing prints below the footer, so the task's own line is
364
+ * where the reader learns it. '' when the run did not prove it flaky.
365
+ */
366
+ export function flakyNote(o: TaskOutcome, colors: ColorSupport = NO_COLOR): string {
367
+ if (o.flaky === undefined) return ''
368
+ const said: string[] = []
369
+ if (o.status === 'failed' && o.flaky.passes > 0)
370
+ said.push(`passed ${o.flaky.passes}\u00d7 before`)
371
+ if (o.status !== 'failed' && o.flaky.failures > 0) {
372
+ said.push(`failed ${o.flaky.failures}\u00d7 before`)
373
+ }
374
+ if ((o.attempts ?? 1) > 1) said.push(`${o.attempts} attempts`)
375
+ const text = said.length === 0 ? 'flaky' : `flaky - ${said.join(' \u00b7 ')}`
376
+ return ` ${paint('', text, colors, { dim: true })}`
377
+ }
378
+
359
379
  /**
360
380
  * Compact one-liner for a skipped task — it never ran (blank time). The
361
- * blocker rides the row (`• blocked by lib#build`): the footer's Skipped
362
- * section groups the same fact, but the row is where the reader's eye is.
381
+ * blocker rides the row (`• blocked by lib#build`): nothing prints below
382
+ * the footer, so the row is where the reader learns what blocked it.
363
383
  */
364
384
  export function formatTaskSkippedLine(
365
385
  node: TaskNode,
@@ -564,7 +584,7 @@ function formatBlockFooter(o: TaskOutcome, colors: ColorSupport): string {
564
584
  // formatStatusTag.
565
585
  const dur = paint('', `(${formatDuration(o.durationMs)})`, colors, { dim: true })
566
586
  const tag = formatStatusTag(o, colors)
567
- return ` ${dur} ${tag}`
587
+ return ` ${dur} ${tag}${flakyNote(o, colors)}`
568
588
  }
569
589
 
570
590
  function formatStatusTag(o: TaskOutcome, colors: ColorSupport): string {
@@ -8,6 +8,7 @@ import {
8
8
  formatTaskAbortedLine,
9
9
  formatTaskBlock,
10
10
  formatTaskExecutedLine,
11
+ flakyNote,
11
12
  formatTaskHitLine,
12
13
  formatTaskSkippedLine,
13
14
  } from './framed-output.js'
@@ -431,6 +432,10 @@ export function defaultLogger(
431
432
  (framesTerminal && holdsTerminal(node)) ||
432
433
  (view.mode === 'focused' && isPrimary(node) && !isGroupTask(node) && requestedCount <= 1)
433
434
 
435
+ const failureRow = (node: TaskNode, outcome: TaskOutcome): string =>
436
+ formatFailureLine(node.id, outcome.durationMs, colors, cacheWordOf(node)) +
437
+ flakyNote(outcome, colors)
438
+
434
439
  return {
435
440
  settle() {
436
441
  // The bus delivers one `run:end`, so the CLI's last word reaches here.
@@ -697,25 +702,31 @@ export function defaultLogger(
697
702
  return
698
703
  }
699
704
  case 'errors-only':
705
+ if (outcome.status === 'skipped') {
706
+ emitLine(formatTaskSkippedLine(node, colors, outcome.blockedBy))
707
+ return
708
+ }
700
709
  if (outcome.status !== 'failed') return
701
- emitLine(formatFailureLine(node.id, outcome.durationMs, colors, cacheWordOf(node)))
710
+ emitLine(failureRow(node, outcome))
702
711
  deferredFailures.push(
703
712
  formatTaskBlock(node, outcome, { stdout, stderr, ...dropped }, colors),
704
713
  )
705
714
  return
706
715
  case 'broad':
707
- // News only: executed work gets a one-liner, failures get
708
- // the full frame. Hits (including up-to-date) are silent —
716
+ // News only: executed work and skips get a one-liner, failures
717
+ // get the full frame. Hits (including up-to-date) are silent —
709
718
  // their replay buffers are deliberately dropped; the counts
710
719
  // surface in the end-of-run summary.
711
720
  if (outcome.status === 'failed') {
712
721
  // ◼ row now; the full frame replays at runEnd.
713
- emitLine(formatFailureLine(node.id, outcome.durationMs, colors, cacheWordOf(node)))
722
+ emitLine(failureRow(node, outcome))
714
723
  deferredFailures.push(
715
724
  formatTaskBlock(node, outcome, { stdout, stderr, ...dropped }, colors),
716
725
  )
717
726
  } else if (outcome.status === 'success') {
718
727
  emitLine(formatTaskExecutedLine(node, outcome, colors))
728
+ } else if (outcome.status === 'skipped') {
729
+ emitLine(formatTaskSkippedLine(node, colors, outcome.blockedBy))
719
730
  }
720
731
  return
721
732
  case 'focused':
@@ -745,7 +756,7 @@ export function defaultLogger(
745
756
  // to runEnd like everywhere else; everything else emits
746
757
  // ONE atomic block from the buffered output.
747
758
  if (outcome.status === 'failed') {
748
- emitLine(formatFailureLine(node.id, outcome.durationMs, colors, cacheWordOf(node)))
759
+ emitLine(failureRow(node, outcome))
749
760
  deferredFailures.push(
750
761
  formatTaskBlock(node, outcome, { stdout, stderr, ...dropped }, colors),
751
762
  )
@@ -756,10 +767,12 @@ export function defaultLogger(
756
767
  emitBlock(formatTaskBlock(node, outcome, { stdout, stderr, ...dropped }, colors, true))
757
768
  return
758
769
  }
759
- // Dependency-pulled nodes: silent on success; failures get
760
- // the ◼ row now and their frame replayed at runEnd.
761
- if (outcome.status === 'failed') {
762
- emitLine(formatFailureLine(node.id, outcome.durationMs, colors, cacheWordOf(node)))
770
+ // Dependency-pulled nodes: silent on success; a skip gets its
771
+ // row, failures the ◼ row now and their frame replayed at runEnd.
772
+ if (outcome.status === 'skipped') {
773
+ emitLine(formatTaskSkippedLine(node, colors, outcome.blockedBy))
774
+ } else if (outcome.status === 'failed') {
775
+ emitLine(failureRow(node, outcome))
763
776
  deferredFailures.push(
764
777
  formatTaskBlock(node, outcome, { stdout, stderr, ...dropped }, colors),
765
778
  )
@@ -33,7 +33,7 @@ export interface SummarizeArgs {
33
33
  /** The process's exit code where it is not `ok ? 0 : 1`: a stopping signal's. */
34
34
  exitCode?: number
35
35
  outcomes: readonly TaskOutcome[]
36
- /** What `detectFlaky` found this run; the footer's Flaky section, typed. */
36
+ /** What `detectFlaky` found this run; each row's flaky note, typed. */
37
37
  flaky?: readonly FlakyFinding[]
38
38
  }
39
39
 
@@ -90,8 +90,8 @@ import { assembleRunRecords } from './run-records.js'
90
90
  import { hasEnded, selectKeepAlive, shutdownPersistent } from './persistent.js'
91
91
  import { writeRunProfile, writeRunSummary } from './run-artifacts.js'
92
92
  import { createSaveLane } from './save-lane.js'
93
- import { formatFlakySection, formatRunSummary, formatSkippedSection } from './summary.js'
94
- import { detectFlaky, type FlakyCandidate } from './failure-mode.js'
93
+ import { formatRunSummary } from './summary.js'
94
+ import { detectFlaky, type FlakyCandidate, type FlakyFinding } from './failure-mode.js'
95
95
  import type { RunOptions, RunSummary } from './options.js'
96
96
 
97
97
  // Per run, never shared: a `vx watch` process runs many, and a shared map
@@ -973,6 +973,24 @@ async function runOnBus(
973
973
  })
974
974
 
975
975
  mark('classify + probe')
976
+ // Judged as each task finishes, against the history BEFORE this run's
977
+ // rows land, so the row that prints next carries the verdict: nothing
978
+ // prints below the footer. A hit or a skip asks nothing; a green miss
979
+ // is one probe of the failed-row index.
980
+ const flaky: FlakyFinding[] = []
981
+ const historyDb = prepared.localCache.dbHandle()
982
+ const judgeFlaky = (o: TaskOutcome): void => {
983
+ const candidates = flakyCandidates([o])
984
+ if (candidates.length === 0) return
985
+ try {
986
+ const found = detectFlaky(historyDb, candidates)[0]
987
+ if (found === undefined) return
988
+ flaky.push(found)
989
+ o.flaky = { passes: found.passes, failures: found.failures }
990
+ } catch {
991
+ // History is observability: an unreadable one judges nothing.
992
+ }
993
+ }
976
994
  const outcomes = await runGraph({
977
995
  nodes,
978
996
  concurrency,
@@ -988,6 +1006,7 @@ async function runOnBus(
988
1006
  },
989
1007
  onFinish: (o) => {
990
1008
  taint.settled(o)
1009
+ judgeFlaky(o)
991
1010
  log.taskComplete(o.node, o)
992
1011
  narrowDemand(o.node.id)
993
1012
  },
@@ -1069,9 +1088,8 @@ async function runOnBus(
1069
1088
  if (stillUp.length > 0) {
1070
1089
  for (const line of formatPersistentList(stillUp, colors)) log.status(line)
1071
1090
  }
1072
- for (const line of formatRunSummary(list, totalMs, colors, runContext)) log.status(line)
1073
1091
  // A dependency-only server that died before the end of the graph
1074
- // stopped it: the footer counts it failed, this says why.
1092
+ // stopped it: the footer below counts it failed, this says why.
1075
1093
  // A signal death is named as its exit code, as the keep-alive wait
1076
1094
  // names it: `code SIGTERM` read beside `code 143` for one event (item
1077
1095
  // 1102).
@@ -1079,20 +1097,11 @@ async function runOnBus(
1079
1097
  const code = typeof c.code === 'number' ? c.code : signalExitCode(c.code)
1080
1098
  log.status(`vx: ${c.id} exited with code ${code} before the run stopped it`)
1081
1099
  }
1082
- // The footer's "N skipped" names no task; this names each under the
1083
- // failure that blocked it.
1084
- for (const line of formatSkippedSection(list)) log.status(line)
1085
- // Judged against the history BEFORE this run's rows land, so the query
1086
- // is one scan over the executed tasks' keys and nothing at all on a run
1087
- // that executed none (every hit, every skip).
1088
- const flaky = detectFlaky(prepared.localCache.dbHandle(), flakyCandidates(list))
1089
- for (const line of formatFlakySection(flaky)) log.status(line)
1090
1100
  // Outputs that never came home are not an error, but a silent `dist/`
1091
1101
  // that is empty-or-stale would be: name every task whose bytes are
1092
1102
  // still remote.
1093
1103
  const stillDeferred = deferredOutputs.pending()
1094
1104
  if (stillDeferred.length > 0) {
1095
- log.status('')
1096
1105
  log.status(
1097
1106
  ` Deferred: ${stillDeferred.length} task(s) left outputs remote (--download=none): ${stillDeferred.join(', ')}`,
1098
1107
  )
@@ -1104,6 +1113,9 @@ async function runOnBus(
1104
1113
  // Ctrl-C there is the process's exit, and the first write said ok.
1105
1114
  const summarize = async (runOk: boolean, final = list): Promise<void> => {
1106
1115
  if (options.summarize === undefined) return
1116
+ // The rewrite after the keep-alive wait says nothing: the footer is
1117
+ // the run's last word.
1118
+ const quiet = final !== list
1107
1119
  try {
1108
1120
  const wrote = await writeRunSummary({
1109
1121
  target: options.summarize,
@@ -1118,7 +1130,7 @@ async function runOnBus(
1118
1130
  outcomes: final,
1119
1131
  flaky,
1120
1132
  })
1121
- log.status(`vx: summary written to ${wrote}`)
1133
+ if (!quiet) log.status(`vx: summary written to ${wrote}`)
1122
1134
  } catch (err) {
1123
1135
  const msg = err instanceof Error ? err.message : String(err)
1124
1136
  log.status(`vx: failed to write summary: ${msg}`)
@@ -1138,6 +1150,9 @@ async function runOnBus(
1138
1150
  log.status(`vx: failed to write profile: ${msg}`)
1139
1151
  }
1140
1152
  }
1153
+ // The footer is the run's last word: every line above, nothing below
1154
+ // (owner, 2026-10-06). A task's own facts (flaky, blocked) ride its row.
1155
+ for (const line of formatRunSummary(list, totalMs, colors, runContext)) log.status(line)
1141
1156
 
1142
1157
  // Record each task to the run history in a single SQLite transaction
1143
1158
  // (one fsync instead of N), with the invocation header row alongside,
@@ -4,7 +4,6 @@
4
4
  // aren't real work and would inflate "N total" misleadingly.
5
5
 
6
6
  import type { TaskOutcome } from '../graph/index.js'
7
- import type { FlakyFinding } from './failure-mode.js'
8
7
  import { paint, type ColorSupport } from './colors.js'
9
8
  import { tallyOutcomes } from './tally.js'
10
9
  import { isGroupTask } from '../graph/index.js'
@@ -386,84 +385,6 @@ export function neverStarted(o: TaskOutcome): boolean {
386
385
  return o.status === 'aborted' && o.wallclockStartNs === undefined
387
386
  }
388
387
 
389
- /**
390
- * Post-summary section naming the tasks that never started, under the
391
- * failure that blocked them. The footer's "1 skipped" says a task was
392
- * blocked and nothing about which task or by what; the broad flow prints
393
- * no row for a skipped task on purpose (a wide red run would drown in
394
- * them), so this is where the reader learns what the failure cost
395
- * (item 266). The scheduler records the root of each block on the outcome
396
- * (`blockedBy`, item 267); a skip without one is fail-fast's. Empty when
397
- * nothing was skipped.
398
- */
399
- export function formatSkippedSection(outcomes: readonly TaskOutcome[]): string[] {
400
- // A group (no `exec`) never starts by definition and is not a task the
401
- // tally counts; listing a blocked one here named three "tasks" the legend
402
- // beside it counted as none (item 281). Its members' rows say enough.
403
- const skipped = outcomes.filter((o) => o.status === 'skipped' && !isGroupTask(o.node))
404
- if (skipped.length === 0) return []
405
- const byId = new Map(outcomes.map((o) => [o.node.id, o]))
406
- const causeOf = (o: TaskOutcome): string => {
407
- if (o.blockedBy === undefined) return 'after the run stopped (fail-fast)'
408
- const root = byId.get(o.blockedBy)
409
- return root?.status === 'aborted'
410
- ? `after ${o.blockedBy} was aborted`
411
- : `after ${o.blockedBy} failed`
412
- }
413
- const groups = new Map<string, string[]>()
414
- for (const o of skipped) {
415
- const cause = causeOf(o)
416
- const list = groups.get(cause) ?? []
417
- list.push(o.node.id)
418
- groups.set(cause, list)
419
- }
420
- // "Blocked upstream" only when every skip was: a fail-fast skip had no
421
- // blocker, and the header claimed one over its own cause line (C-55).
422
- const blocked = skipped.every((o) => o.blockedBy !== undefined) ? ' \u2014 blocked upstream' : ''
423
- const lines = [
424
- '',
425
- ` Skipped: ${skipped.length} task${skipped.length === 1 ? '' : 's'} never started${blocked}`,
426
- ]
427
- const NAMES = 8
428
- for (const [cause, ids] of [...groups].sort((a, b) => b[1].length - a[1].length)) {
429
- ids.sort()
430
- const shown = ids.slice(0, NAMES).join(', ')
431
- const more = ids.length > NAMES ? ` \u2026 +${ids.length - NAMES} more` : ''
432
- lines.push(` \u2298 ${cause}: ${shown}${more}`)
433
- }
434
- return lines
435
- }
436
-
437
- /**
438
- * Post-summary section naming the tasks this run proved flaky: identical
439
- * inputs, both outcomes on record (or a retry within the run). A red run
440
- * whose failure has passed on these exact inputs before is not a break to
441
- * bisect, and a green run that only passed on the second attempt is not
442
- * green — either way the footer's counts alone would say nothing. Empty
443
- * when nothing was.
444
- */
445
- export function formatFlakySection(findings: readonly FlakyFinding[]): string[] {
446
- if (findings.length === 0) return []
447
- const lines = [
448
- '',
449
- ` Flaky: ${findings.length} task${findings.length === 1 ? '' : 's'} with the same inputs both passing and failing on record`,
450
- ]
451
- for (const f of findings) {
452
- const times = (n: number): string => `${n}\u00d7`
453
- const history =
454
- f.status === 'failed'
455
- ? `failed on inputs that passed ${times(f.passes)} before`
456
- : f.failures > 0
457
- ? `passed on inputs that failed ${times(f.failures)} before`
458
- : 'passed'
459
- const retried = f.attempts > 1 ? ` \u00b7 ${f.attempts} attempts this run` : ''
460
- lines.push(
461
- ` ${f.status === 'failed' ? '\u2717' : '\u2713'} ${f.taskId} \u2014 ${history}${retried}`,
462
- )
463
- }
464
- return lines
465
- }
466
-
467
388
  export function formatDuration(ms: number): string {
468
389
  return formatElapsed(ms)
469
390
  }