@vzn/vx 0.0.333 → 0.0.335
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.
|
|
3
|
+
"version": "0.0.335",
|
|
4
4
|
"description": "A fast, correct 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.
|
|
25
|
-
"@vzn/vx-linux-arm64": "0.0.
|
|
26
|
-
"@vzn/vx-darwin-x64": "0.0.
|
|
27
|
-
"@vzn/vx-darwin-arm64": "0.0.
|
|
24
|
+
"@vzn/vx-linux-x64": "0.0.335",
|
|
25
|
+
"@vzn/vx-linux-arm64": "0.0.335",
|
|
26
|
+
"@vzn/vx-darwin-x64": "0.0.335",
|
|
27
|
+
"@vzn/vx-darwin-arm64": "0.0.335"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@anthropic-ai/sandbox-runtime": "^0.0.76"
|
|
@@ -737,6 +737,30 @@ function canonicalBaselines(
|
|
|
737
737
|
}
|
|
738
738
|
}
|
|
739
739
|
|
|
740
|
+
/**
|
|
741
|
+
* Linux: does some mount hold the task's cwd? bwrap enters the old cwd
|
|
742
|
+
* only if it exists in the new root, and otherwise `$HOME`, with no word:
|
|
743
|
+
* a project granted no read ran in the home directory, where `cat x.txt`
|
|
744
|
+
* read `~/x.txt`. A grant at or above the cwd holds it, and so does an
|
|
745
|
+
* existing one below (bwrap builds the path to a bind), and so does a
|
|
746
|
+
* deny that IS the cwd (a single-package workspace's anchor). When none does,
|
|
747
|
+
* the cwd is denied instead: an empty directory the task enters, whose
|
|
748
|
+
* reads are refused and reported as the anchor's are.
|
|
749
|
+
*/
|
|
750
|
+
function cwdMounted(
|
|
751
|
+
cwd: string,
|
|
752
|
+
fs: {
|
|
753
|
+
allowRead?: readonly string[] | undefined
|
|
754
|
+
allowWrite?: readonly string[] | undefined
|
|
755
|
+
denyRead?: readonly string[] | undefined
|
|
756
|
+
},
|
|
757
|
+
): boolean {
|
|
758
|
+
if (fs.denyRead?.includes(cwd) === true) return true
|
|
759
|
+
return [...(fs.allowRead ?? []), ...(fs.allowWrite ?? [])].some(
|
|
760
|
+
(p) => atOrUnder(cwd, p) || (atOrUnder(p, cwd) && existsSync(p)),
|
|
761
|
+
)
|
|
762
|
+
}
|
|
763
|
+
|
|
740
764
|
/**
|
|
741
765
|
* A write grant that names a path in the project must BIND one there. The
|
|
742
766
|
* grant was realpath'd, so `out.txt -> ../b/src/x` (committed, or planted
|
|
@@ -958,6 +982,9 @@ export async function wrapSandboxedCommand(
|
|
|
958
982
|
const customConfig = buildCustomConfig(args, baselines)
|
|
959
983
|
const scratch = pendingWriteGrants(args.config, customConfig!.filesystem!, baselines.denyRead)
|
|
960
984
|
customConfig!.filesystem!.denyRead!.push(toRealPath(taskTmpRoot()))
|
|
985
|
+
if (process.platform === 'linux' && !cwdMounted(baselines.cwd, customConfig!.filesystem!)) {
|
|
986
|
+
customConfig!.filesystem!.denyRead!.push(baselines.cwd)
|
|
987
|
+
}
|
|
961
988
|
customConfig!.filesystem!.allowWrite!.push(toRealPath(tmp))
|
|
962
989
|
if (scopedDenyScan) {
|
|
963
990
|
customConfig!.filesystem!.denyWrite!.push(
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import path from 'node:path'
|
|
8
8
|
import type { ProjectConfig } from '../config.js'
|
|
9
9
|
import {
|
|
10
|
-
|
|
10
|
+
frozenProjectConfigs,
|
|
11
11
|
loadProjectConfigs,
|
|
12
12
|
validateProjectConfig,
|
|
13
13
|
type LoadProjectConfigOptions,
|
|
@@ -216,7 +216,7 @@ export async function loadProjects(args: LoadProjectsArgs): Promise<LoadedProjec
|
|
|
216
216
|
typeof m.configPath === 'string' && args.staged?.get(m.name) === undefined,
|
|
217
217
|
)
|
|
218
218
|
const loaded = lock
|
|
219
|
-
? await
|
|
219
|
+
? await frozenProjectConfigs(lock, withFile, workspaceRoot, args.evalCache?.store)
|
|
220
220
|
: await loadProjectConfigs(
|
|
221
221
|
withFile.map((m) => m.configPath),
|
|
222
222
|
args.evalCache !== undefined ? { evalCache: args.evalCache } : {},
|
package/src/workspace/index.ts
CHANGED
|
@@ -18,7 +18,7 @@ export {
|
|
|
18
18
|
export { computeNestedProjectDirs } from './nested-dirs.js'
|
|
19
19
|
export { buildPackageGraph, type PackageGraph } from './package-graph.js'
|
|
20
20
|
export {
|
|
21
|
-
|
|
21
|
+
frozenProjectConfigs,
|
|
22
22
|
LOCKFILE_NAME,
|
|
23
23
|
LOCKFILE_VERSION,
|
|
24
24
|
lockfilePath,
|
|
@@ -16,7 +16,9 @@
|
|
|
16
16
|
import { rename, rm } from 'node:fs/promises'
|
|
17
17
|
import path from 'node:path'
|
|
18
18
|
import type { ProjectConfig } from '../config.js'
|
|
19
|
-
import { relPosix, UserError } from '../util/index.js'
|
|
19
|
+
import { relPosix, UserError, xxh3 } from '../util/index.js'
|
|
20
|
+
import { VERSION } from '../version.js'
|
|
21
|
+
import { CONFIG_EVAL_VERSION, type ConfigEvalStore } from './config-cache.js'
|
|
20
22
|
import { validateProjectConfig } from './config-schema.js'
|
|
21
23
|
|
|
22
24
|
export const LOCKFILE_NAME = 'vx-lock.json'
|
|
@@ -54,8 +56,10 @@ export async function readLockfile(root: string): Promise<Lockfile | null> {
|
|
|
54
56
|
const file = Bun.file(lockfilePath(root))
|
|
55
57
|
if (!(await file.exists())) return null
|
|
56
58
|
let parsed: unknown
|
|
59
|
+
let text: string
|
|
57
60
|
try {
|
|
58
|
-
|
|
61
|
+
text = await file.text()
|
|
62
|
+
parsed = JSON.parse(text)
|
|
59
63
|
} catch {
|
|
60
64
|
throw new UserError(`${LOCKFILE_NAME} is not valid JSON — re-run \`vx lock\` or delete it`)
|
|
61
65
|
}
|
|
@@ -95,9 +99,13 @@ export async function readLockfile(root: string): Promise<Lockfile | null> {
|
|
|
95
99
|
throw new UserError(`${LOCKFILE_NAME}: entry for "${name}" is malformed — re-run \`vx lock\``)
|
|
96
100
|
}
|
|
97
101
|
}
|
|
102
|
+
lockDigests.set(parsed, xxh3(text).toString(16))
|
|
98
103
|
return parsed as Lockfile
|
|
99
104
|
}
|
|
100
105
|
|
|
106
|
+
/** The digest of the bytes each lock `readLockfile` returned was parsed from. */
|
|
107
|
+
const lockDigests = new WeakMap<object, string>()
|
|
108
|
+
|
|
101
109
|
export async function writeLockfile(root: string, lock: Lockfile): Promise<void> {
|
|
102
110
|
// Written beside its name and renamed over it: `Bun.write` truncates in
|
|
103
111
|
// place, so a `--frozen` run, or `vx watch --frozen` woken by the write
|
|
@@ -123,26 +131,36 @@ export async function writeLockfile(root: string, lock: Lockfile): Promise<void>
|
|
|
123
131
|
|
|
124
132
|
/**
|
|
125
133
|
* Run-time config load from the lock: return the FROZEN resolved config
|
|
126
|
-
* for
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
134
|
+
* for each project, in order. No evaluation happens — this is the fast,
|
|
135
|
+
* eval-free trust path — and no staleness check either (see below): the
|
|
136
|
+
* lock's contract is "what runs is what was locked", so a config file
|
|
137
|
+
* edited since `vx lock` still runs as locked until `vx lock --check`
|
|
138
|
+
* says otherwise. An unlocked project is a hard error; silently falling
|
|
139
|
+
* back to evaluation would break frozen-env semantics.
|
|
140
|
+
*
|
|
141
|
+
* `store` remembers which entries of which lock bytes this validator
|
|
142
|
+
* accepted, beside the config evaluations and keyed like them (vx's and
|
|
143
|
+
* Bun's versions): validating 1,000 entries was ~30 ms of every warm
|
|
144
|
+
* `--frozen` run, for a verdict that cannot change until the bytes or vx
|
|
145
|
+
* do.
|
|
132
146
|
*/
|
|
133
|
-
export async function
|
|
147
|
+
export async function frozenProjectConfigs(
|
|
134
148
|
lock: Lockfile,
|
|
135
|
-
|
|
149
|
+
metas: ReadonlyArray<{ name: string; configPath: string }>,
|
|
136
150
|
root: string,
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
151
|
+
store?: ConfigEvalStore,
|
|
152
|
+
): Promise<ProjectConfig[]> {
|
|
153
|
+
const entries = metas.map((meta) => {
|
|
154
|
+
const rel = relPosix(root, meta.configPath)
|
|
155
|
+
const entry = lock.projects[meta.name]
|
|
156
|
+
if (!entry || entry.configPath !== rel) {
|
|
157
|
+
throw new UserError(
|
|
158
|
+
`${LOCKFILE_NAME} has no entry for "${meta.name}" (${rel}) — ` +
|
|
159
|
+
`run \`vx lock\` to refresh, or delete ${LOCKFILE_NAME}`,
|
|
160
|
+
)
|
|
161
|
+
}
|
|
162
|
+
return entry
|
|
163
|
+
})
|
|
146
164
|
// No staleness checks here, deliberately: --frozen runs after
|
|
147
165
|
// `vx lock --check` in any sane pipeline, and that audit re-
|
|
148
166
|
// evaluates everything — a per-file byte-hash re-check would be
|
|
@@ -151,6 +169,30 @@ export async function frozenProjectConfig(
|
|
|
151
169
|
// in the file solely for --check's fast file-changed reporting.
|
|
152
170
|
// The lock is hand-editable; the stored config crosses the same
|
|
153
171
|
// boundary a freshly evaluated one does.
|
|
154
|
-
|
|
155
|
-
|
|
172
|
+
const digest = store === undefined ? undefined : lockDigests.get(lock)
|
|
173
|
+
const keys =
|
|
174
|
+
digest === undefined
|
|
175
|
+
? undefined
|
|
176
|
+
: metas.map(
|
|
177
|
+
(m) =>
|
|
178
|
+
`vx-lock-valid-v${CONFIG_EVAL_VERSION}\0${VERSION}\0${Bun.version}\0${digest}\0${m.name}`,
|
|
179
|
+
)
|
|
180
|
+
const known =
|
|
181
|
+
keys === undefined || store === undefined
|
|
182
|
+
? new Map<string, string>()
|
|
183
|
+
: store.getConfigEvals !== undefined
|
|
184
|
+
? store.getConfigEvals(keys)
|
|
185
|
+
: new Map(keys.flatMap((k) => (store.getConfigEval(k) === null ? [] : [[k, '1'] as const])))
|
|
186
|
+
const accepted: Array<readonly [string, string]> = []
|
|
187
|
+
for (let i = 0; i < entries.length; i++) {
|
|
188
|
+
const key = keys?.[i]
|
|
189
|
+
if (key !== undefined && known.has(key)) continue
|
|
190
|
+
validateProjectConfig(entries[i]!.config, `${LOCKFILE_NAME} (${metas[i]!.name})`)
|
|
191
|
+
if (key !== undefined) accepted.push([key, '1'])
|
|
192
|
+
}
|
|
193
|
+
if (store !== undefined && accepted.length > 0) {
|
|
194
|
+
if (store.putConfigEvals !== undefined) store.putConfigEvals(accepted)
|
|
195
|
+
else for (const [k, v] of accepted) store.putConfigEval(k, v)
|
|
196
|
+
}
|
|
197
|
+
return entries.map((e) => e.config)
|
|
156
198
|
}
|