@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.
- package/LICENSE +1 -1
- package/README.md +107 -70
- package/package.json +10 -20
- package/src/bin.ts +64 -5
- package/src/cache/archive.ts +279 -28
- package/src/cache/cache.ts +952 -1584
- package/src/cache/chained-cache.ts +14 -10
- package/src/cache/config-evals.ts +112 -0
- package/src/cache/file-hashes.ts +290 -0
- package/src/cache/git-inputs.ts +966 -0
- package/src/cache/index.ts +23 -7
- package/src/cache/inputs.ts +553 -739
- package/src/cache/key-fold.ts +232 -0
- package/src/cache/layer.ts +674 -0
- package/src/cache/layered-cache.ts +211 -49
- package/src/cache/output-index.ts +323 -0
- package/src/cache/policy.ts +84 -0
- package/src/cache/run-history.ts +152 -0
- package/src/cache/zstd.ts +183 -0
- package/src/cli/cache.ts +88 -30
- package/src/cli/completions.ts +104 -0
- package/src/cli/core-alias.ts +25 -0
- package/src/cli/format.ts +4 -15
- package/src/cli/help.ts +76 -38
- package/src/cli/index.ts +82 -17
- package/src/cli/info.ts +162 -91
- package/src/cli/init.ts +87 -0
- package/src/cli/last.ts +130 -23
- package/src/cli/lock.ts +36 -18
- package/src/cli/plan-format.ts +18 -7
- package/src/cli/plugin-commands.ts +34 -12
- package/src/cli/run.ts +138 -313
- package/src/cli/select.ts +342 -0
- package/src/cli/show.ts +151 -71
- package/src/cli/upgrade.ts +136 -15
- package/src/cli/watch.ts +1175 -116
- package/src/cli/why.ts +51 -29
- package/src/cli/workspace-config.ts +138 -0
- package/src/config.ts +183 -126
- package/src/exec/env.ts +11 -0
- package/src/exec/executor.ts +62 -31
- package/src/exec/index.ts +16 -2
- package/src/exec/kill-tree.ts +281 -0
- package/src/exec/local-executor.ts +41 -0
- package/src/exec/runner.ts +361 -77
- package/src/exec/sandbox-binds.ts +211 -0
- package/src/exec/sandbox-paths.ts +70 -0
- package/src/exec/sandbox-runtime.ts +1152 -415
- package/src/exec/sandbox-violations.ts +293 -0
- package/src/graph/dependency-spec.ts +14 -14
- package/src/graph/index.ts +6 -4
- package/src/graph/priorities.ts +130 -0
- package/src/graph/scheduler.ts +332 -329
- package/src/graph/task-graph.ts +552 -188
- package/src/index.ts +111 -102
- package/src/orchestrator/admission.ts +161 -0
- package/src/orchestrator/colors.ts +8 -3
- package/src/orchestrator/deferred-outputs.ts +25 -7
- package/src/orchestrator/doctor.ts +363 -0
- package/src/orchestrator/events.ts +111 -8
- package/src/orchestrator/excluded-keys.ts +155 -0
- package/src/orchestrator/execute-task.ts +450 -565
- package/src/orchestrator/failure-mode.ts +169 -28
- package/src/orchestrator/failure-recap.ts +121 -0
- package/src/orchestrator/fingerprint-watch.ts +89 -0
- package/src/orchestrator/framed-output.ts +121 -49
- package/src/orchestrator/history.ts +123 -104
- package/src/orchestrator/hit-restore.ts +285 -0
- package/src/orchestrator/index.ts +42 -5
- package/src/orchestrator/keyed-projects.ts +89 -0
- package/src/orchestrator/local-shortcircuit.ts +83 -23
- package/src/orchestrator/lockfile-claim.ts +401 -0
- package/src/orchestrator/logger.ts +128 -41
- package/src/orchestrator/metrics.ts +201 -72
- package/src/orchestrator/miss-save.ts +232 -0
- package/src/orchestrator/options.ts +63 -34
- package/src/orchestrator/persistent.ts +99 -0
- package/src/orchestrator/placement.ts +212 -0
- package/src/orchestrator/plan.ts +24 -11
- package/src/orchestrator/plugin-host.ts +200 -49
- package/src/orchestrator/plugin.ts +190 -14
- package/src/orchestrator/prepare.ts +168 -137
- package/src/orchestrator/projects.ts +270 -0
- package/src/orchestrator/remote-prefetch.ts +22 -2
- package/src/orchestrator/run-artifacts.ts +34 -3
- package/src/orchestrator/run-context.ts +20 -5
- package/src/orchestrator/run-lock.ts +349 -0
- package/src/orchestrator/run-records.ts +132 -0
- package/src/orchestrator/run-report.ts +6 -4
- package/src/orchestrator/run.ts +467 -611
- package/src/orchestrator/sandbox-request.ts +569 -0
- package/src/orchestrator/save-lane.ts +44 -0
- package/src/orchestrator/shell-verdict.ts +117 -0
- package/src/orchestrator/signals.ts +167 -0
- package/src/orchestrator/stable-keys.ts +259 -10
- package/src/orchestrator/status-line.ts +35 -2
- package/src/orchestrator/summary.ts +115 -25
- package/src/orchestrator/task-hash.ts +103 -21
- package/src/orchestrator/task-log-buffer.ts +15 -18
- package/src/orchestrator/telemetry-host.ts +27 -8
- package/src/orchestrator/telemetry.ts +71 -44
- package/src/orchestrator/upstream.ts +91 -45
- package/src/util/bun-version.ts +43 -0
- package/src/util/cgroup.ts +160 -0
- package/src/util/edit-distance.ts +49 -0
- package/src/util/errors.ts +86 -0
- package/src/util/hash.ts +10 -1
- package/src/util/index.ts +42 -5
- package/src/util/paths.ts +168 -5
- package/src/util/procfs.ts +20 -0
- package/src/util/settle.ts +23 -2
- package/src/util/size.ts +33 -0
- package/src/util/task-id.ts +20 -0
- package/src/util/timing.ts +11 -1
- package/src/util/verbs.ts +39 -0
- package/src/util/which.ts +48 -0
- package/src/workspace/affected.ts +368 -60
- package/src/workspace/config-cache.ts +271 -32
- package/src/workspace/config-eval.ts +60 -16
- package/src/workspace/config-imports.ts +131 -9
- package/src/workspace/config-schema.ts +1033 -0
- package/src/workspace/filter.ts +69 -17
- package/src/workspace/fingerprint.ts +59 -7
- package/src/workspace/index.ts +37 -3
- package/src/workspace/json-data.ts +90 -0
- package/src/workspace/load-reads.ts +32 -0
- package/src/workspace/lockfile.ts +41 -14
- package/src/workspace/migrate-scripts.ts +187 -0
- package/src/workspace/migration.ts +353 -0
- package/src/workspace/package-graph.ts +239 -31
- package/src/workspace/project-loader.ts +295 -815
- package/src/workspace/workspace.ts +266 -31
- package/plugins/local-cache/index.ts +0 -2
- package/plugins/local-executor/index.ts +0 -2
- package/plugins/schedule-history/index.ts +0 -2
- package/src/cache/cas-backend.ts +0 -115
- package/src/cache/digest.ts +0 -32
- package/src/cli/migrate-emit.ts +0 -21
- package/src/cli/migrate-nx.ts +0 -473
- package/src/cli/migrate-scripts.ts +0 -127
- package/src/cli/migrate-turbo.ts +0 -401
- package/src/cli/migrate.ts +0 -305
- package/src/cli/prune.ts +0 -291
- package/src/orchestrator/missing-plugin.ts +0 -9
- package/src/orchestrator/resources.ts +0 -45
- package/src/orchestrator/verify.ts +0 -174
- package/src/plugins/local-cache/index.ts +0 -11
- package/src/plugins/local-executor/index.ts +0 -45
- 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
|
-
}
|