@vzn/vx 0.0.424 → 0.0.425

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.424",
3
+ "version": "0.0.425",
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.424",
25
- "@vzn/vx-linux-arm64": "0.0.424",
26
- "@vzn/vx-darwin-x64": "0.0.424",
27
- "@vzn/vx-darwin-arm64": "0.0.424"
24
+ "@vzn/vx-linux-x64": "0.0.425",
25
+ "@vzn/vx-linux-arm64": "0.0.425",
26
+ "@vzn/vx-darwin-x64": "0.0.425",
27
+ "@vzn/vx-darwin-arm64": "0.0.425"
28
28
  },
29
29
  "dependencies": {
30
30
  "@anthropic-ai/sandbox-runtime": "^0.0.76"
@@ -160,6 +160,12 @@ export interface ExecuteArgs {
160
160
  * Absent → probe lazily, exactly as today (unstable / unclassified).
161
161
  */
162
162
  preProbed?: { hash: string; hit: CacheEntry | null }
163
+ /**
164
+ * An uncached task's key as the up-front pass derived it, present only
165
+ * when no upstream can change it (`deriveStableKeys`' `uncachedKeys`):
166
+ * used verbatim instead of deriving the same key again.
167
+ */
168
+ upfrontKey?: string
163
169
  /**
164
170
  * Start the sandbox runtime, on the first task that executes inside one
165
171
  * (run.ts, `prepareSandbox`). Absent when no task in the run declares a
@@ -274,7 +280,8 @@ async function executePersistentTask(args: ExecuteArgs): Promise<TaskOutcome> {
274
280
  const hash =
275
281
  args.noDependants === true
276
282
  ? undefined
277
- : await computeTaskHash({
283
+ : (args.upfrontKey ??
284
+ (await computeTaskHash({
278
285
  node,
279
286
  upstream: args.upstream,
280
287
  workspaceRoot: args.workspaceRoot,
@@ -284,7 +291,7 @@ async function executePersistentTask(args: ExecuteArgs): Promise<TaskOutcome> {
284
291
  nestedProjectDirs: args.nestedProjectDirs,
285
292
  ...(args.gitFilesCache !== undefined ? { gitFilesCache: args.gitFilesCache } : {}),
286
293
  ...(args.hashCache !== undefined ? { hashCache: args.hashCache } : {}),
287
- })
294
+ })))
288
295
 
289
296
  // The args after `--` reach a server as they reach any task. A readyWhen
290
297
  // server once got none — "so the matcher sees the unmodified output",
@@ -658,19 +665,19 @@ async function executeCachedTask(args: ExecuteArgs): Promise<TaskOutcome> {
658
665
  // authoritative stable key) and skip the probe below.
659
666
  const preProbed = args.preProbed
660
667
  const hash =
661
- preProbed !== undefined
662
- ? preProbed.hash
663
- : await computeTaskHash({
664
- node,
665
- upstream,
666
- workspaceRoot: args.workspaceRoot,
667
- workspaceFingerprint: args.workspaceFingerprint,
668
- cache,
669
- forwardArgs: args.forwardArgs,
670
- nestedProjectDirs: args.nestedProjectDirs,
671
- ...(args.gitFilesCache !== undefined ? { gitFilesCache: args.gitFilesCache } : {}),
672
- ...(args.hashCache !== undefined ? { hashCache: args.hashCache } : {}),
673
- })
668
+ preProbed?.hash ??
669
+ args.upfrontKey ??
670
+ (await computeTaskHash({
671
+ node,
672
+ upstream,
673
+ workspaceRoot: args.workspaceRoot,
674
+ workspaceFingerprint: args.workspaceFingerprint,
675
+ cache,
676
+ forwardArgs: args.forwardArgs,
677
+ nestedProjectDirs: args.nestedProjectDirs,
678
+ ...(args.gitFilesCache !== undefined ? { gitFilesCache: args.gitFilesCache } : {}),
679
+ ...(args.hashCache !== undefined ? { hashCache: args.hashCache } : {}),
680
+ }))
674
681
 
675
682
  // The local no-op half of `exec.remote: 'only'`: no remote executor took
676
683
  // the task, so it succeeds without running. The hash was still computed —
@@ -84,10 +84,14 @@ export interface ShortCircuit {
84
84
  * with a non-null hit, minus the workspace-outputs exclusion).
85
85
  */
86
86
  restoreTier: Set<string>
87
+ /**
88
+ * Uncached task id → its up-front key, for the tasks whose key no
89
+ * upstream can change: execute-task reuses it instead of deriving it
90
+ * again (`deriveStableKeys`' `uncachedKeys`).
91
+ */
92
+ uncachedKeys: Map<string, string>
87
93
  }
88
94
 
89
- const EMPTY: ShortCircuit = { preProbed: new Map(), restoreTier: new Set() }
90
-
91
95
  /**
92
96
  * Classify the graph's stable tasks: derive keys + probe local ONCE,
93
97
  * returning the `preProbed` map (probe reuse) and the `restoreTier` set
@@ -99,11 +103,12 @@ const EMPTY: ShortCircuit = { preProbed: new Map(), restoreTier: new Set() }
99
103
  */
100
104
  export async function startLocalShortCircuit(args: ShortCircuitArgs): Promise<ShortCircuit> {
101
105
  let stableKeys
106
+ const uncachedKeys = new Map<string, string>()
102
107
  const endKeys = span('stable keys')
103
108
  try {
104
- stableKeys = await deriveStableKeys(args)
109
+ stableKeys = await deriveStableKeys({ ...args, uncachedKeys })
105
110
  } catch {
106
- return EMPTY
111
+ return { preProbed: new Map(), restoreTier: new Set(), uncachedKeys: new Map() }
107
112
  } finally {
108
113
  endKeys()
109
114
  }
@@ -111,12 +116,17 @@ export async function startLocalShortCircuit(args: ShortCircuitArgs): Promise<Sh
111
116
  // `cacheEnabled && !unstable` (item 640 deleted a second filter here and
112
117
  // nothing reddened).
113
118
  const candidates = stableKeys
114
- if (candidates.length === 0) return EMPTY
115
-
116
- const keptOut = restoreTierExclusions(args.nodes, args.workspaceRoot)
117
-
118
119
  const preProbed = new Map<string, ProbedEntry>()
119
120
  const restoreTier = new Set<string>()
121
+ if (candidates.length === 0 && uncachedKeys.size === 0) {
122
+ return { preProbed, restoreTier, uncachedKeys }
123
+ }
124
+
125
+ const keptOut = restoreTierExclusions(args.nodes, args.workspaceRoot)
126
+ // A root-anchored output may land in a project no edge leads from, so an
127
+ // uncached key there is derived again once the writer may have run.
128
+ for (const id of keptOut) uncachedKeys.delete(id)
129
+ if (candidates.length === 0) return { preProbed, restoreTier, uncachedKeys }
120
130
 
121
131
  // Bounded pool over the stable candidates: probe local ONCE each. A
122
132
  // confirmed hit becomes restore-tier (unless workspace outputs disable
@@ -135,7 +145,7 @@ export async function startLocalShortCircuit(args: ShortCircuitArgs): Promise<Sh
135
145
  preProbed.set(node.id, { hash, hit })
136
146
  if (hit !== null && !keptOut.has(node.id)) restoreTier.add(node.id)
137
147
  }
138
- return { preProbed, restoreTier }
148
+ return { preProbed, restoreTier, uncachedKeys }
139
149
  } catch {
140
150
  // Fall through to the per-hash pool, which isolates a failing probe
141
151
  // to its own task.
@@ -159,7 +169,7 @@ export async function startLocalShortCircuit(args: ShortCircuitArgs): Promise<Sh
159
169
  }
160
170
  await Promise.all(Array.from({ length: workers }, () => pump()))
161
171
 
162
- return { preProbed, restoreTier }
172
+ return { preProbed, restoreTier, uncachedKeys }
163
173
  }
164
174
 
165
175
  /**
@@ -103,7 +103,11 @@ import type { RunOptions, RunSummary } from './options.js'
103
103
 
104
104
  // Per run, never shared: a `vx watch` process runs many, and a shared map
105
105
  // is one `preProbed.set` away from leaking a hit across cycles.
106
- const emptyShortCircuit = (): ShortCircuit => ({ preProbed: new Map(), restoreTier: new Set() })
106
+ const emptyShortCircuit = (): ShortCircuit => ({
107
+ preProbed: new Map(),
108
+ restoreTier: new Set(),
109
+ uncachedKeys: new Map(),
110
+ })
107
111
 
108
112
  /**
109
113
  * Parse the `VX_TASK_TIMEOUT` env var (ms) — the "global" run-level task
@@ -891,6 +895,7 @@ async function runOnBus(
891
895
 
892
896
  const buildExecuteArgs = (node: TaskNode, upstream: TaskOutcome[], reuseProbe = true) => {
893
897
  const probe = reuseProbe ? shortCircuit.preProbed.get(node.id) : undefined
898
+ const upfrontKey = shortCircuit.uncachedKeys.get(node.id)
894
899
  if (
895
900
  options.continueMode === 'always' &&
896
901
  node.deps.some((d) => deadServerBehind(nodes, serverDied, d) !== undefined)
@@ -921,6 +926,7 @@ async function runOnBus(
921
926
  gitFilesCache,
922
927
  hashCache,
923
928
  ...(probe !== undefined ? { preProbed: probe } : {}),
929
+ ...(upfrontKey !== undefined ? { upfrontKey } : {}),
924
930
  ...(tainted ? { taintedUpstream: true } : {}),
925
931
  ...(dependedOn.has(node.id) ? {} : { noDependants: true as const }),
926
932
  fingerprintWatch,
@@ -27,6 +27,11 @@ export interface DeriveStableKeysArgs {
27
27
  nestedDirsByProject: Map<string, string[]>
28
28
  gitFilesCache: GitFilesCache
29
29
  hashCache: HashCache
30
+ /**
31
+ * Filled with each uncached task's key when no upstream can write where
32
+ * that key reads, so execute-task need not derive it a second time.
33
+ */
34
+ uncachedKeys?: Map<string, string>
30
35
  }
31
36
 
32
37
  export interface StableKey {
@@ -237,6 +242,18 @@ export async function deriveStableKeys(args: DeriveStableKeysArgs): Promise<Stab
237
242
 
238
243
  const cacheEnabled = node.config.cache !== undefined
239
244
  if (cacheEnabled && !unstable) stableKeys.push({ hash, node })
245
+ // An uncached key reads its whole project, so `dependsOnSiblingOutputs`
246
+ // (which answers false for it) is not the gate: any upstream that may
247
+ // write into this project, or anywhere, leaves the key preliminary.
248
+ else if (
249
+ !cacheEnabled &&
250
+ !unstable &&
251
+ !outputProjects.has(node.projectName) &&
252
+ unfolded?.has(node.projectName) !== true &&
253
+ !wsOutputUpstream &&
254
+ !wsUnfoldedHere
255
+ )
256
+ args.uncachedKeys?.set(id, hash)
240
257
  }
241
258
  return stableKeys
242
259
  }