@vzn/vx 0.0.18 → 0.0.22

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 (149) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +107 -70
  3. package/package.json +10 -20
  4. package/src/bin.ts +64 -5
  5. package/src/cache/archive.ts +279 -28
  6. package/src/cache/cache.ts +952 -1584
  7. package/src/cache/chained-cache.ts +14 -10
  8. package/src/cache/config-evals.ts +112 -0
  9. package/src/cache/file-hashes.ts +290 -0
  10. package/src/cache/git-inputs.ts +966 -0
  11. package/src/cache/index.ts +23 -7
  12. package/src/cache/inputs.ts +553 -739
  13. package/src/cache/key-fold.ts +232 -0
  14. package/src/cache/layer.ts +674 -0
  15. package/src/cache/layered-cache.ts +211 -49
  16. package/src/cache/output-index.ts +323 -0
  17. package/src/cache/policy.ts +84 -0
  18. package/src/cache/run-history.ts +152 -0
  19. package/src/cache/zstd.ts +183 -0
  20. package/src/cli/cache.ts +88 -30
  21. package/src/cli/completions.ts +104 -0
  22. package/src/cli/core-alias.ts +25 -0
  23. package/src/cli/format.ts +4 -15
  24. package/src/cli/help.ts +76 -38
  25. package/src/cli/index.ts +82 -17
  26. package/src/cli/info.ts +162 -91
  27. package/src/cli/init.ts +87 -0
  28. package/src/cli/last.ts +130 -23
  29. package/src/cli/lock.ts +36 -18
  30. package/src/cli/plan-format.ts +18 -7
  31. package/src/cli/plugin-commands.ts +34 -12
  32. package/src/cli/run.ts +138 -313
  33. package/src/cli/select.ts +342 -0
  34. package/src/cli/show.ts +151 -71
  35. package/src/cli/upgrade.ts +136 -15
  36. package/src/cli/watch.ts +1175 -116
  37. package/src/cli/why.ts +51 -29
  38. package/src/cli/workspace-config.ts +138 -0
  39. package/src/config.ts +183 -126
  40. package/src/exec/env.ts +11 -0
  41. package/src/exec/executor.ts +62 -31
  42. package/src/exec/index.ts +16 -2
  43. package/src/exec/kill-tree.ts +281 -0
  44. package/src/exec/local-executor.ts +41 -0
  45. package/src/exec/runner.ts +361 -77
  46. package/src/exec/sandbox-binds.ts +211 -0
  47. package/src/exec/sandbox-paths.ts +70 -0
  48. package/src/exec/sandbox-runtime.ts +1152 -415
  49. package/src/exec/sandbox-violations.ts +293 -0
  50. package/src/graph/dependency-spec.ts +14 -14
  51. package/src/graph/index.ts +6 -4
  52. package/src/graph/priorities.ts +130 -0
  53. package/src/graph/scheduler.ts +332 -329
  54. package/src/graph/task-graph.ts +552 -188
  55. package/src/index.ts +111 -102
  56. package/src/orchestrator/admission.ts +161 -0
  57. package/src/orchestrator/colors.ts +8 -3
  58. package/src/orchestrator/deferred-outputs.ts +25 -7
  59. package/src/orchestrator/doctor.ts +363 -0
  60. package/src/orchestrator/events.ts +111 -8
  61. package/src/orchestrator/excluded-keys.ts +155 -0
  62. package/src/orchestrator/execute-task.ts +450 -565
  63. package/src/orchestrator/failure-mode.ts +169 -28
  64. package/src/orchestrator/failure-recap.ts +121 -0
  65. package/src/orchestrator/fingerprint-watch.ts +89 -0
  66. package/src/orchestrator/framed-output.ts +121 -49
  67. package/src/orchestrator/history.ts +123 -104
  68. package/src/orchestrator/hit-restore.ts +285 -0
  69. package/src/orchestrator/index.ts +42 -5
  70. package/src/orchestrator/keyed-projects.ts +89 -0
  71. package/src/orchestrator/local-shortcircuit.ts +83 -23
  72. package/src/orchestrator/lockfile-claim.ts +401 -0
  73. package/src/orchestrator/logger.ts +128 -41
  74. package/src/orchestrator/metrics.ts +201 -72
  75. package/src/orchestrator/miss-save.ts +232 -0
  76. package/src/orchestrator/options.ts +63 -34
  77. package/src/orchestrator/persistent.ts +99 -0
  78. package/src/orchestrator/placement.ts +212 -0
  79. package/src/orchestrator/plan.ts +24 -11
  80. package/src/orchestrator/plugin-host.ts +200 -49
  81. package/src/orchestrator/plugin.ts +190 -14
  82. package/src/orchestrator/prepare.ts +168 -137
  83. package/src/orchestrator/projects.ts +270 -0
  84. package/src/orchestrator/remote-prefetch.ts +22 -2
  85. package/src/orchestrator/run-artifacts.ts +34 -3
  86. package/src/orchestrator/run-context.ts +20 -5
  87. package/src/orchestrator/run-lock.ts +349 -0
  88. package/src/orchestrator/run-records.ts +132 -0
  89. package/src/orchestrator/run-report.ts +6 -4
  90. package/src/orchestrator/run.ts +467 -611
  91. package/src/orchestrator/sandbox-request.ts +569 -0
  92. package/src/orchestrator/save-lane.ts +44 -0
  93. package/src/orchestrator/shell-verdict.ts +117 -0
  94. package/src/orchestrator/signals.ts +167 -0
  95. package/src/orchestrator/stable-keys.ts +259 -10
  96. package/src/orchestrator/status-line.ts +35 -2
  97. package/src/orchestrator/summary.ts +115 -25
  98. package/src/orchestrator/task-hash.ts +103 -21
  99. package/src/orchestrator/task-log-buffer.ts +15 -18
  100. package/src/orchestrator/telemetry-host.ts +27 -8
  101. package/src/orchestrator/telemetry.ts +71 -44
  102. package/src/orchestrator/upstream.ts +91 -45
  103. package/src/util/bun-version.ts +43 -0
  104. package/src/util/cgroup.ts +160 -0
  105. package/src/util/edit-distance.ts +49 -0
  106. package/src/util/errors.ts +86 -0
  107. package/src/util/hash.ts +10 -1
  108. package/src/util/index.ts +42 -5
  109. package/src/util/paths.ts +168 -5
  110. package/src/util/procfs.ts +20 -0
  111. package/src/util/settle.ts +23 -2
  112. package/src/util/size.ts +33 -0
  113. package/src/util/task-id.ts +20 -0
  114. package/src/util/timing.ts +11 -1
  115. package/src/util/verbs.ts +39 -0
  116. package/src/util/which.ts +48 -0
  117. package/src/workspace/affected.ts +368 -60
  118. package/src/workspace/config-cache.ts +271 -32
  119. package/src/workspace/config-eval.ts +60 -16
  120. package/src/workspace/config-imports.ts +131 -9
  121. package/src/workspace/config-schema.ts +1033 -0
  122. package/src/workspace/filter.ts +69 -17
  123. package/src/workspace/fingerprint.ts +59 -7
  124. package/src/workspace/index.ts +37 -3
  125. package/src/workspace/json-data.ts +90 -0
  126. package/src/workspace/load-reads.ts +32 -0
  127. package/src/workspace/lockfile.ts +41 -14
  128. package/src/workspace/migrate-scripts.ts +187 -0
  129. package/src/workspace/migration.ts +353 -0
  130. package/src/workspace/package-graph.ts +239 -31
  131. package/src/workspace/project-loader.ts +295 -815
  132. package/src/workspace/workspace.ts +266 -31
  133. package/plugins/local-cache/index.ts +0 -2
  134. package/plugins/local-executor/index.ts +0 -2
  135. package/plugins/schedule-history/index.ts +0 -2
  136. package/src/cache/cas-backend.ts +0 -115
  137. package/src/cache/digest.ts +0 -32
  138. package/src/cli/migrate-emit.ts +0 -21
  139. package/src/cli/migrate-nx.ts +0 -473
  140. package/src/cli/migrate-scripts.ts +0 -127
  141. package/src/cli/migrate-turbo.ts +0 -401
  142. package/src/cli/migrate.ts +0 -305
  143. package/src/cli/prune.ts +0 -291
  144. package/src/orchestrator/missing-plugin.ts +0 -9
  145. package/src/orchestrator/resources.ts +0 -45
  146. package/src/orchestrator/verify.ts +0 -174
  147. package/src/plugins/local-cache/index.ts +0 -11
  148. package/src/plugins/local-executor/index.ts +0 -45
  149. package/src/plugins/schedule-history/index.ts +0 -109
@@ -1,109 +0,0 @@
1
- // History-based scheduling as a plugin: order ready tasks by their expected
2
- // REMAINING critical-path duration (own p50 + the longest chain of
3
- // dependents), learned from the local run history. This was core's opt-in
4
- // `predictive` mode until 2026-09-02; it is the reference `schedule` plugin
5
- // now — declared like any other, and paying its history read only in
6
- // workspaces that ask for it.
7
- //
8
- // Cache hits are NOT modelled as zero-cost: predicting cache state needs
9
- // the key and a probe, which the scheduler handles at run time (a confirmed
10
- // hit is backfill, never a critical-path task). The estimate here is "what
11
- // if everything ran", which is exactly the case where order matters.
12
-
13
- import { LocalHistoryProvider, type HistoryTable, type TaskNode, type VxPlugin } from '@vzn/vx'
14
-
15
- const SCHEDULE_HISTORY_PLUGIN = 'vx/schedule-history'
16
-
17
- /** Default duration when neither task history nor a workspace median exists. */
18
- const DEFAULT_DURATION_MS = 1000
19
-
20
- export interface ScheduleHistoryOptions {
21
- /** How many recent runs per task to learn from. Default 20. */
22
- readonly window?: number
23
- }
24
-
25
- export function scheduleHistoryPlugin(options: ScheduleHistoryOptions = {}): VxPlugin {
26
- return {
27
- name: SCHEDULE_HISTORY_PLUGIN,
28
- async schedule(nodes, ctx) {
29
- const provider =
30
- options.window === undefined
31
- ? new LocalHistoryProvider(ctx.localCache.dbHandle())
32
- : new LocalHistoryProvider(ctx.localCache.dbHandle(), options.window)
33
- let table: HistoryTable
34
- try {
35
- table = await provider.loadFor([...nodes.keys()])
36
- } catch (err) {
37
- // Failing open: a broken history read costs the ordering, never the run.
38
- ctx.warn(
39
- `[vx] schedule-history: falling back to the baseline order: ${err instanceof Error ? err.message : String(err)}`,
40
- )
41
- return undefined
42
- }
43
- return criticalPathPriorities([...nodes.values()], table)
44
- },
45
- }
46
- }
47
-
48
- /**
49
- * For each node, the expected remaining critical-path duration: its own p50
50
- * plus the maximum over its dependents. A node with no history takes the
51
- * workspace median; an empty history takes a flat default.
52
- */
53
- export function criticalPathPriorities(
54
- nodes: readonly TaskNode[],
55
- history: HistoryTable,
56
- ): ReadonlyMap<string, number> {
57
- const p50s: number[] = []
58
- for (const h of history.values()) {
59
- if (h.p50DurationMs !== undefined) p50s.push(h.p50DurationMs)
60
- }
61
- p50s.sort((a, b) => a - b)
62
- const workspaceMedian =
63
- p50s.length > 0
64
- ? (p50s[Math.floor(p50s.length / 2)] ?? DEFAULT_DURATION_MS)
65
- : DEFAULT_DURATION_MS
66
-
67
- const dependentsOf = new Map<string, string[]>()
68
- for (const n of nodes) {
69
- for (const upstreamId of n.deps) {
70
- const list = dependentsOf.get(upstreamId)
71
- if (list) list.push(n.id)
72
- else dependentsOf.set(upstreamId, [n.id])
73
- }
74
- }
75
- const ownDuration = (n: TaskNode): number => history.get(n.id)?.p50DurationMs ?? workspaceMedian
76
-
77
- // Reverse-topological pass: a node's value is final once every dependent's
78
- // is, so start from the sinks (no dependents) and release each upstream
79
- // when its last dependent has been scored.
80
- const memo = new Map<string, number>()
81
- const nodeById = new Map<string, TaskNode>(nodes.map((n) => [n.id, n]))
82
- const pending = new Map<string, number>()
83
- const queue: TaskNode[] = []
84
- for (const n of nodes) {
85
- const count = dependentsOf.get(n.id)?.length ?? 0
86
- pending.set(n.id, count)
87
- if (count === 0) queue.push(n)
88
- }
89
- let head = 0
90
- while (head < queue.length) {
91
- const n = queue[head++]!
92
- let downstream = 0
93
- for (const dep of dependentsOf.get(n.id) ?? []) {
94
- const d = memo.get(dep) ?? 0
95
- if (d > downstream) downstream = d
96
- }
97
- memo.set(n.id, ownDuration(n) + downstream)
98
- for (const up of n.deps) {
99
- const left = (pending.get(up) ?? 0) - 1
100
- pending.set(up, left)
101
- if (left === 0) {
102
- const upNode = nodeById.get(up)
103
- if (upNode) queue.push(upNode)
104
- }
105
- }
106
- }
107
- for (const n of nodes) if (!memo.has(n.id)) memo.set(n.id, ownDuration(n))
108
- return memo
109
- }