@vzn/vx 0.0.152 → 0.0.154

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.152",
3
+ "version": "0.0.154",
4
4
  "description": "A fast, correct task runner and build cache for JavaScript monorepos.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -17,10 +17,10 @@
17
17
  "node": ">=18"
18
18
  },
19
19
  "optionalDependencies": {
20
- "@vzn/vx-linux-x64": "0.0.152",
21
- "@vzn/vx-linux-arm64": "0.0.152",
22
- "@vzn/vx-darwin-x64": "0.0.152",
23
- "@vzn/vx-darwin-arm64": "0.0.152"
20
+ "@vzn/vx-linux-x64": "0.0.154",
21
+ "@vzn/vx-linux-arm64": "0.0.154",
22
+ "@vzn/vx-darwin-x64": "0.0.154",
23
+ "@vzn/vx-darwin-arm64": "0.0.154"
24
24
  },
25
25
  "dependencies": {
26
26
  "@anthropic-ai/sandbox-runtime": "^0.0.76"
@@ -11,6 +11,7 @@ import { lstatSync, readlinkSync } from 'node:fs'
11
11
  import path from 'node:path'
12
12
  import { fileIdentity, repoFacts } from './git-inputs.js'
13
13
  import { FILE_HASH_RACY_MS, isIndexFull, racyWindowMs } from './layer.js'
14
+ import { isPermissionError, UserError } from '../util/index.js'
14
15
 
15
16
  const FILE_HASHES_SWEPT_AT = 'file_hashes_swept_at'
16
17
  const DAY_MS = 24 * 60 * 60 * 1000
@@ -301,7 +302,19 @@ export class FileHashStore {
301
302
  * spawn per file.
302
303
  */
303
304
  private async hashFileFromDisk(filePath: string): Promise<string> {
304
- return this.hashBytes(await Bun.file(filePath).bytes(), filePath)
305
+ let bytes: Uint8Array
306
+ try {
307
+ bytes = await Bun.file(filePath).bytes()
308
+ } catch (err) {
309
+ // Left raw, the scheduler added the write hint to an input vx only
310
+ // reads: "a path vx must write is not writable by this user".
311
+ if (!isPermissionError(err)) throw err
312
+ throw new UserError(
313
+ `${filePath} is not readable by this user (${err.code}), and vx reads it to derive a ` +
314
+ 'cache key. Make it readable, or, for a task input, take it out of cache.inputs.files.',
315
+ )
316
+ }
317
+ return this.hashBytes(bytes, filePath)
305
318
  }
306
319
 
307
320
  /**
@@ -3,7 +3,7 @@
3
3
  // ownership moves to the run's registry, and this is the one place that
4
4
  // decides which of them outlive the graph and how the rest go down.
5
5
 
6
- import type { TaskNode } from '../graph/index.js'
6
+ import { isGroupTask, type TaskNode } from '../graph/index.js'
7
7
  import { killGraceMs } from '../util/index.js'
8
8
  import { holdGroups, killTree, untilGroupsGone } from '../exec/index.js'
9
9
 
@@ -25,9 +25,12 @@ export interface KeepAlive {
25
25
  /**
26
26
  * A persistent task the user REQUESTED (or one surfaced for display) is the
27
27
  * run's whole purpose — it is left running and blocked on at the very end,
28
- * after the summary. Only in the real CLI foreground: a custom logger or
29
- * `handleSignals: false` (watch mode, embedders) expects `run()` to return,
30
- * not to sit on a server.
28
+ * after the summary. So is every persistent task a kept one depends on,
29
+ * directly or through groups: `vx run dev --filter app` stopped the api#dev
30
+ * its app#dev was started against (C-46). A one-shot's persistent deps are
31
+ * not kept on its account; it has finished with them. Only in the real CLI
32
+ * foreground: a custom logger or `handleSignals: false` (watch mode,
33
+ * embedders) expects `run()` to return, not to sit on a server.
31
34
  */
32
35
  export function selectKeepAlive(
33
36
  registry: ReadonlyMap<string, Child>,
@@ -36,13 +39,25 @@ export function selectKeepAlive(
36
39
  ): KeepAlive {
37
40
  const out: KeepAlive = { nodes: [], children: [] }
38
41
  if (!foreground) return out
39
- for (const [id, child] of registry) {
42
+ const stack = [...registry.keys()].filter((id) => {
40
43
  const n = nodes.get(id)
41
- if (n !== undefined && (n.requested || n.surfaced === true)) {
42
- out.nodes.push(n)
43
- out.children.push(child)
44
+ return n !== undefined && (n.requested || n.surfaced === true)
45
+ })
46
+ const reached = new Set<string>()
47
+ while (stack.length > 0) {
48
+ const id = stack.pop()!
49
+ if (reached.has(id)) continue
50
+ reached.add(id)
51
+ for (const dep of nodes.get(id)?.deps ?? []) {
52
+ const d = nodes.get(dep)
53
+ if (d !== undefined && (registry.has(dep) || isGroupTask(d))) stack.push(dep)
44
54
  }
45
55
  }
56
+ for (const [id, child] of registry) {
57
+ if (!reached.has(id)) continue
58
+ out.nodes.push(nodes.get(id)!)
59
+ out.children.push(child)
60
+ }
46
61
  return out
47
62
  }
48
63