devcontour-harness 0.1.0-alpha.26 → 0.1.0-alpha.28
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/README.md +15 -2
- package/docs/architecture.md +59 -0
- package/docs/compatibility.md +25 -12
- package/docs/connectors.md +5 -2
- package/docs/contracts.md +80 -25
- package/docs/release-notes/0.1.0-alpha.27.md +36 -0
- package/docs/release-notes/0.1.0-alpha.28.md +37 -0
- package/docs/review-protocol.md +10 -4
- package/docs/toolchains.md +83 -0
- package/docs/upgrade.md +22 -0
- package/lib/cli.js +13 -0
- package/lib/contracts/cli.d.ts +147 -19
- package/lib/contracts/cli.js +66 -0
- package/lib/contracts/diagnosis.d.ts +1 -1
- package/lib/contracts/events.d.ts +6 -6
- package/lib/contracts/execution.d.ts +268 -16
- package/lib/contracts/execution.js +3 -1
- package/lib/contracts/policy.d.ts +37 -5
- package/lib/contracts/policy.js +42 -2
- package/lib/contracts/profiles.d.ts +2 -0
- package/lib/contracts/published.d.ts +226 -20
- package/lib/contracts/result.d.ts +268 -12
- package/lib/contracts/result.js +66 -0
- package/lib/control/harness.d.ts +64 -7
- package/lib/control/harness.js +4 -0
- package/lib/control/recovery.d.ts +1 -1
- package/lib/control/review.js +6 -1
- package/lib/engine/engine.d.ts +117 -12
- package/lib/engine/joint-runner.d.ts +96 -6
- package/lib/engine/joint-runner.js +47 -1
- package/lib/engine/runner.d.ts +29 -0
- package/lib/engine/runner.js +200 -2
- package/lib/engine/worktree-cleanup.d.ts +131 -0
- package/lib/engine/worktree-cleanup.js +520 -0
- package/lib/environment/isolation.d.ts +1 -0
- package/lib/environment/isolation.js +2 -1
- package/lib/environment/os-tools.d.ts +4 -2
- package/lib/environment/os-tools.js +4 -2
- package/lib/environment/process.d.ts +5 -0
- package/lib/environment/process.js +40 -17
- package/lib/environment/resources.d.ts +9 -0
- package/lib/environment/resources.js +24 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/integrations/connector/commands.d.ts +2 -1
- package/lib/integrations/connector/commands.js +10 -2
- package/lib/integrations/connector/store.d.ts +1 -1
- package/lib/integrations/connector/store.js +11 -6
- package/lib/profiles/resolve.d.ts +8 -0
- package/lib/storage/document.d.ts +132 -12
- package/lib/toolchains/inspect.d.ts +1 -1
- package/lib/toolchains/inspect.js +29 -1
- package/lib/toolchains/probe.d.ts +16 -0
- package/lib/toolchains/probe.js +20 -0
- package/lib/verification/confirm.d.ts +3 -1
- package/lib/verification/confirm.js +16 -2
- package/lib/verification/dependencies.d.ts +3 -0
- package/lib/verification/dependencies.js +11 -0
- package/lib/verification/dependency-store.d.ts +117 -0
- package/lib/verification/dependency-store.js +811 -0
- package/lib/verification/gate-artifacts.d.ts +34 -0
- package/lib/verification/gate-artifacts.js +303 -0
- package/lib/verification/gates-at.js +18 -0
- package/lib/verification/gates.js +15 -0
- package/lib/verification/joint.d.ts +48 -3
- package/package.json +1 -1
- package/schemas/execution-document.schema.json +372 -0
- package/schemas/execution-policy.schema.json +56 -0
- package/schemas/joint-verification.schema.json +279 -0
|
@@ -245,22 +245,37 @@ export function hostGitArgs(cwd, args) {
|
|
|
245
245
|
assertTrustedCheckout(cwd);
|
|
246
246
|
return [...gitHardening, ...args];
|
|
247
247
|
}
|
|
248
|
+
const gitEnv = () => ({
|
|
249
|
+
...process.env,
|
|
250
|
+
GIT_TERMINAL_PROMPT: '0',
|
|
251
|
+
GIT_AUTHOR_NAME: 'devcontour-harness',
|
|
252
|
+
GIT_AUTHOR_EMAIL: 'harness@localhost',
|
|
253
|
+
GIT_COMMITTER_NAME: 'devcontour-harness',
|
|
254
|
+
GIT_COMMITTER_EMAIL: 'harness@localhost',
|
|
255
|
+
});
|
|
256
|
+
/**
|
|
257
|
+
* Вывод git целиком. `git` хранит только хвост вывода (предел `command`): для
|
|
258
|
+
* содержимого файла, которое разбирают, усечение незаметно и опасно.
|
|
259
|
+
*/
|
|
260
|
+
export async function gitOutput(cwd, ...args) {
|
|
261
|
+
let text = '';
|
|
262
|
+
const result = await command(['git', ...hostGitArgs(cwd, args)], cwd, {
|
|
263
|
+
env: gitEnv(),
|
|
264
|
+
onRawStdout: (chunk) => {
|
|
265
|
+
text += chunk;
|
|
266
|
+
},
|
|
267
|
+
});
|
|
268
|
+
if (result.code !== 0)
|
|
269
|
+
throw new Error(`git ${args[0]}: ${result.stderr.trim()}`);
|
|
270
|
+
return text.trim();
|
|
271
|
+
}
|
|
248
272
|
export async function git(cwd, ...args) {
|
|
249
273
|
const added = worktreeAddPath(args);
|
|
250
274
|
// Путь убираемого дерева — до удаления: потом настоящий путь уже не узнать.
|
|
251
275
|
const removed = args[0] === 'worktree' && args[1] === 'remove'
|
|
252
276
|
? worktreeKey(resolve(cwd, args.at(-1)))
|
|
253
277
|
: undefined;
|
|
254
|
-
const result = await command(['git', ...hostGitArgs(cwd, args)], cwd, {
|
|
255
|
-
env: {
|
|
256
|
-
...process.env,
|
|
257
|
-
GIT_TERMINAL_PROMPT: '0',
|
|
258
|
-
GIT_AUTHOR_NAME: 'devcontour-harness',
|
|
259
|
-
GIT_AUTHOR_EMAIL: 'harness@localhost',
|
|
260
|
-
GIT_COMMITTER_NAME: 'devcontour-harness',
|
|
261
|
-
GIT_COMMITTER_EMAIL: 'harness@localhost',
|
|
262
|
-
},
|
|
263
|
-
});
|
|
278
|
+
const result = await command(['git', ...hostGitArgs(cwd, args)], cwd, { env: gitEnv() });
|
|
264
279
|
if (result.code !== 0)
|
|
265
280
|
throw new Error(`git ${args[0]}: ${result.stderr.trim() || result.stdout.trim()}`);
|
|
266
281
|
if (added)
|
|
@@ -273,9 +288,11 @@ export async function git(cwd, ...args) {
|
|
|
273
288
|
* Вывод системной утилиты или null, если она не выполнилась. Не блокирует
|
|
274
289
|
* event loop. Локаль фиксирована (`osToolEnv`): вывод разбирается.
|
|
275
290
|
*/
|
|
276
|
-
function output(command, args, timeout
|
|
291
|
+
function output(command, args, timeout,
|
|
292
|
+
/** Код выхода, при котором вывод остаётся верным (lsof: часть процессов уже завершилась). */
|
|
293
|
+
partial) {
|
|
277
294
|
return new Promise((resolve) => {
|
|
278
|
-
execFile(command, args, { encoding: 'utf8', env: osToolEnv(), timeout, maxBuffer: 64_000_000 }, (error, stdout) => resolve(error ? null : stdout));
|
|
295
|
+
execFile(command, args, { encoding: 'utf8', env: osToolEnv(), timeout, maxBuffer: 64_000_000 }, (error, stdout) => resolve(error && (!partial || error.code !== partial) ? null : stdout));
|
|
279
296
|
});
|
|
280
297
|
}
|
|
281
298
|
/** Процессы пользователя, в окружении которых есть метка. */
|
|
@@ -334,7 +351,7 @@ async function descendants(root, known) {
|
|
|
334
351
|
* одного из её каталогов. Время старта отсекает процессы пользователя —
|
|
335
352
|
* например, терминал, открытый в worktree раньше.
|
|
336
353
|
*/
|
|
337
|
-
async function inside(dirs, since) {
|
|
354
|
+
async function inside(dirs, since, table) {
|
|
338
355
|
if (!dirs.length)
|
|
339
356
|
return [];
|
|
340
357
|
// lsof и /proc сообщают настоящие пути; временный каталог macOS — за symlink.
|
|
@@ -346,7 +363,7 @@ async function inside(dirs, since) {
|
|
|
346
363
|
return d;
|
|
347
364
|
}
|
|
348
365
|
});
|
|
349
|
-
const started = new Map(
|
|
366
|
+
const started = new Map(table.map((r) => [r.pid, Date.parse(r.start)]));
|
|
350
367
|
// Нечитаемое время старта — не повод оставить процесс: каталоги принадлежат
|
|
351
368
|
// только этой команде, и утечка её потомка хуже ошибочной остановки.
|
|
352
369
|
// Отсекается только процесс, о котором точно известно, что он старше
|
|
@@ -373,7 +390,12 @@ async function inside(dirs, since) {
|
|
|
373
390
|
return [];
|
|
374
391
|
}
|
|
375
392
|
});
|
|
376
|
-
|
|
393
|
+
// Только процессы моложе команды: обход всех процессов пользователя занимает
|
|
394
|
+
// сотни миллисекунд на каждую команду. Код 1 — часть из них уже завершилась.
|
|
395
|
+
const candidates = [...started.keys()].filter((pid) => pid !== process.pid && fresh(pid));
|
|
396
|
+
if (!candidates.length)
|
|
397
|
+
return [];
|
|
398
|
+
const stdout = await output(osTool('lsof'), ['-a', '-d', 'cwd', '-Fpn', '-u', String(process.getuid?.()), '-p', candidates.join(',')], 15000, 1);
|
|
377
399
|
const pids = [];
|
|
378
400
|
let pid = 0;
|
|
379
401
|
for (const line of (stdout ?? '').split('\n')) {
|
|
@@ -392,14 +414,15 @@ async function sweep(mark, seen, dirs, since) {
|
|
|
392
414
|
let left = [];
|
|
393
415
|
for (let attempt = 0; attempt < 20; attempt++) {
|
|
394
416
|
try {
|
|
395
|
-
const
|
|
417
|
+
const rows = await processTable();
|
|
418
|
+
const table = new Map(rows.map((r) => [r.pid, r.start]));
|
|
396
419
|
left = [
|
|
397
420
|
...new Set([
|
|
398
421
|
...(await marked(mark)),
|
|
399
422
|
// Замеченный опросом потомок — только если это тот же процесс, а
|
|
400
423
|
// не новый, получивший освободившийся PID.
|
|
401
424
|
...[...seen].filter(([pid, start]) => table.get(pid) === start).map(([pid]) => pid),
|
|
402
|
-
...(await inside(dirs, since)),
|
|
425
|
+
...(await inside(dirs, since, rows)),
|
|
403
426
|
]),
|
|
404
427
|
];
|
|
405
428
|
}
|
|
@@ -23,6 +23,15 @@ export declare class ResourcePool {
|
|
|
23
23
|
heartbeat(token: string, count: number, ttl: number): void;
|
|
24
24
|
release(token: string): void;
|
|
25
25
|
clearAbandoned(key: string, token: string): void;
|
|
26
|
+
/**
|
|
27
|
+
* Digest манифеста seed зависимостей (`verification/dependency-store.ts`).
|
|
28
|
+
* Лежит здесь, а не рядом с seed: подмена seed вместе с его манифестом не
|
|
29
|
+
* совпадёт с записью, а песочнице база на запись закрыта. От кода с правами
|
|
30
|
+
* хоста (`prepare`, `lifecycle`) закрепление не защищает.
|
|
31
|
+
*/
|
|
32
|
+
seedPin(root: string, key: string): string | undefined;
|
|
33
|
+
setSeedPin(root: string, key: string, digest: string | undefined): void;
|
|
34
|
+
private seedPins;
|
|
26
35
|
close(): void;
|
|
27
36
|
}
|
|
28
37
|
export declare function withResources<T>(config: Pick<ExecutionPolicy, 'resources' | 'leaseMs'> & {
|
|
@@ -71,6 +71,30 @@ export class ResourcePool {
|
|
|
71
71
|
throw new Error('Владелец ресурса ещё работает');
|
|
72
72
|
this.db.prepare('DELETE FROM leases WHERE key=? AND token=?').run(key, token);
|
|
73
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* Digest манифеста seed зависимостей (`verification/dependency-store.ts`).
|
|
76
|
+
* Лежит здесь, а не рядом с seed: подмена seed вместе с его манифестом не
|
|
77
|
+
* совпадёт с записью, а песочнице база на запись закрыта. От кода с правами
|
|
78
|
+
* хоста (`prepare`, `lifecycle`) закрепление не защищает.
|
|
79
|
+
*/
|
|
80
|
+
seedPin(root, key) {
|
|
81
|
+
this.seedPins();
|
|
82
|
+
const row = this.db
|
|
83
|
+
.prepare('SELECT digest FROM seed_pins WHERE root=? AND key=?')
|
|
84
|
+
.get(root, key);
|
|
85
|
+
return row?.digest;
|
|
86
|
+
}
|
|
87
|
+
setSeedPin(root, key, digest) {
|
|
88
|
+
this.seedPins();
|
|
89
|
+
if (digest === undefined)
|
|
90
|
+
this.db.prepare('DELETE FROM seed_pins WHERE root=? AND key=?').run(root, key);
|
|
91
|
+
else
|
|
92
|
+
this.db.prepare('INSERT OR REPLACE INTO seed_pins VALUES (?,?,?)').run(root, key, digest);
|
|
93
|
+
}
|
|
94
|
+
// Таблица создаётся при первом обращении: база установок без хранилища не меняется.
|
|
95
|
+
seedPins() {
|
|
96
|
+
this.db.exec('CREATE TABLE IF NOT EXISTS seed_pins (root TEXT NOT NULL, key TEXT NOT NULL, digest TEXT NOT NULL, PRIMARY KEY (root, key))');
|
|
97
|
+
}
|
|
74
98
|
close() {
|
|
75
99
|
this.db.close();
|
|
76
100
|
}
|
package/lib/index.d.ts
CHANGED
|
@@ -57,6 +57,7 @@ export { JointRunner, type JointRunnerOptions } from './engine/joint-runner.ts';
|
|
|
57
57
|
export { moveBase, fencedRefMove, type BaseMoved, type RefMove } from './control/base-move.ts';
|
|
58
58
|
export { junitSummary, prepareReportPath, runCheck, runGate, sandboxBlockedHosts, type GateRun, } from './verification/gates.ts';
|
|
59
59
|
export { runGatesAt, type GatesAtContext, type GatesAtInput, type GatesAtResult, } from './verification/gates-at.ts';
|
|
60
|
+
export { dependencyStoreRoot, materializeStore, type StoreContext, type StoreReceipt, } from './verification/dependency-store.ts';
|
|
60
61
|
export { explicitPrerequisites, gatePrerequisites, orderedScope, standaloneScope, } from './verification/gate-scope.ts';
|
|
61
62
|
export { requirementProof, uncoveredGates, unprovenReason } from './verification/proof.ts';
|
|
62
63
|
export { ReviewProbes, probeLimits, observeReproductions } from './agents/review-probe.ts';
|
package/lib/index.js
CHANGED
|
@@ -57,6 +57,7 @@ export { JointRunner } from "./engine/joint-runner.js";
|
|
|
57
57
|
export { moveBase, fencedRefMove } from "./control/base-move.js";
|
|
58
58
|
export { junitSummary, prepareReportPath, runCheck, runGate, sandboxBlockedHosts, } from "./verification/gates.js";
|
|
59
59
|
export { runGatesAt, } from "./verification/gates-at.js";
|
|
60
|
+
export { dependencyStoreRoot, materializeStore, } from "./verification/dependency-store.js";
|
|
60
61
|
export { explicitPrerequisites, gatePrerequisites, orderedScope, standaloneScope, } from "./verification/gate-scope.js";
|
|
61
62
|
export { requirementProof, uncoveredGates, unprovenReason } from "./verification/proof.js";
|
|
62
63
|
export { ReviewProbes, probeLimits, observeReproductions } from "./agents/review-probe.js";
|
|
@@ -207,7 +207,8 @@ export declare class Connector {
|
|
|
207
207
|
/**
|
|
208
208
|
* Прочитать и предпросмотреть снимок; записать graph/context/manifest для
|
|
209
209
|
* `review-plan`/`approve`. Снимок закрепляется в состоянии коннектора по
|
|
210
|
-
* semantic digest: повтор неизменной постановки ничего не
|
|
210
|
+
* semantic digest: повтор неизменной постановки ничего не меняет, а возврат
|
|
211
|
+
* к прежней редакции снова закрепляет её запись (`created: false`).
|
|
211
212
|
*/
|
|
212
213
|
snapshot(outDir?: string): Promise<{
|
|
213
214
|
tasks: {
|
|
@@ -109,7 +109,14 @@ export class Connector {
|
|
|
109
109
|
const file = this.loaded.file;
|
|
110
110
|
if (!this.config.baseline || !file)
|
|
111
111
|
return undefined;
|
|
112
|
-
|
|
112
|
+
let real;
|
|
113
|
+
try {
|
|
114
|
+
real = realpathSync(file);
|
|
115
|
+
}
|
|
116
|
+
catch {
|
|
117
|
+
// Защиту файла, которого уже нет, не проверить: отказ, а не внутренняя ошибка.
|
|
118
|
+
return `Конфигурация коннектора с baseline недоступна после загрузки (${file}): восстановите файл и повторите команду`;
|
|
119
|
+
}
|
|
113
120
|
for (const repo of policy.repositories) {
|
|
114
121
|
const root = resolveFrom(baseDir, repo.path);
|
|
115
122
|
if (!existsSync(root))
|
|
@@ -220,7 +227,8 @@ export class Connector {
|
|
|
220
227
|
/**
|
|
221
228
|
* Прочитать и предпросмотреть снимок; записать graph/context/manifest для
|
|
222
229
|
* `review-plan`/`approve`. Снимок закрепляется в состоянии коннектора по
|
|
223
|
-
* semantic digest: повтор неизменной постановки ничего не
|
|
230
|
+
* semantic digest: повтор неизменной постановки ничего не меняет, а возврат
|
|
231
|
+
* к прежней редакции снова закрепляет её запись (`created: false`).
|
|
224
232
|
*/
|
|
225
233
|
async snapshot(outDir) {
|
|
226
234
|
const snapshot = await this.source.snapshot();
|
|
@@ -99,7 +99,7 @@ export declare class ConnectorStore {
|
|
|
99
99
|
created: boolean;
|
|
100
100
|
};
|
|
101
101
|
snapshot(revision: string): SnapshotRecord | undefined;
|
|
102
|
-
/** Последний снимок
|
|
102
|
+
/** Последний закреплённый снимок графа: порядок записи, а не время создания редакции. */
|
|
103
103
|
latestSnapshot(graphId: string): SnapshotRecord | undefined;
|
|
104
104
|
/** Последний закреплённый снимок любого графа этого коннектора. */
|
|
105
105
|
latestSnapshotAny(): SnapshotRecord | undefined;
|
|
@@ -94,8 +94,15 @@ export class ConnectorStore {
|
|
|
94
94
|
return this.tx(() => {
|
|
95
95
|
const prior = this.snapshot(record.revision);
|
|
96
96
|
// Повтор той же редакции не меняет записанный снимок (и время его создания).
|
|
97
|
-
|
|
97
|
+
// Возврат к прежней редакции снова делает её последней: иначе снимок,
|
|
98
|
+
// совпавший со свежим чтением, не закрепить ничем, кроме новой правки.
|
|
99
|
+
if (prior) {
|
|
100
|
+
this.db
|
|
101
|
+
.prepare(`UPDATE snapshots SET rowid=(SELECT max(rowid) + 1 FROM snapshots)
|
|
102
|
+
WHERE revision=? AND rowid<(SELECT max(rowid) FROM snapshots)`)
|
|
103
|
+
.run(record.revision);
|
|
98
104
|
return { record: prior, created: false };
|
|
105
|
+
}
|
|
99
106
|
const full = { ...record, createdAt: now() };
|
|
100
107
|
this.db
|
|
101
108
|
.prepare('INSERT INTO snapshots VALUES(?, ?, ?, ?)')
|
|
@@ -107,18 +114,16 @@ export class ConnectorStore {
|
|
|
107
114
|
const row = this.db.prepare('SELECT data FROM snapshots WHERE revision=?').get(revision);
|
|
108
115
|
return row ? JSON.parse(row.data) : undefined;
|
|
109
116
|
}
|
|
110
|
-
/** Последний снимок
|
|
117
|
+
/** Последний закреплённый снимок графа: порядок записи, а не время создания редакции. */
|
|
111
118
|
latestSnapshot(graphId) {
|
|
112
119
|
const row = this.db
|
|
113
|
-
.prepare('SELECT data FROM snapshots WHERE graph_id=? ORDER BY
|
|
120
|
+
.prepare('SELECT data FROM snapshots WHERE graph_id=? ORDER BY rowid DESC LIMIT 1')
|
|
114
121
|
.get(graphId);
|
|
115
122
|
return row ? JSON.parse(row.data) : undefined;
|
|
116
123
|
}
|
|
117
124
|
/** Последний закреплённый снимок любого графа этого коннектора. */
|
|
118
125
|
latestSnapshotAny() {
|
|
119
|
-
const row = this.db
|
|
120
|
-
.prepare('SELECT data FROM snapshots ORDER BY created_at DESC, rowid DESC LIMIT 1')
|
|
121
|
-
.get();
|
|
126
|
+
const row = this.db.prepare('SELECT data FROM snapshots ORDER BY rowid DESC LIMIT 1').get();
|
|
122
127
|
return row ? JSON.parse(row.data) : undefined;
|
|
123
128
|
}
|
|
124
129
|
/* ---------------------------------------------------------------- */
|
|
@@ -125,6 +125,7 @@ export declare function repositoryFromProfile(profile: ResolvedProfile, own: Pic
|
|
|
125
125
|
id: string;
|
|
126
126
|
command: string[];
|
|
127
127
|
timeoutMs: number;
|
|
128
|
+
artifacts?: string[] | undefined;
|
|
128
129
|
property?: {
|
|
129
130
|
path?: string | undefined;
|
|
130
131
|
} | undefined;
|
|
@@ -140,6 +141,7 @@ export declare function repositoryFromProfile(profile: ResolvedProfile, own: Pic
|
|
|
140
141
|
type: "junit";
|
|
141
142
|
path: string;
|
|
142
143
|
} | undefined;
|
|
144
|
+
artifacts?: string[] | undefined;
|
|
143
145
|
property?: {
|
|
144
146
|
path?: string | undefined;
|
|
145
147
|
} | undefined;
|
|
@@ -228,6 +230,12 @@ export declare function repositoryFromProfile(profile: ResolvedProfile, own: Pic
|
|
|
228
230
|
timeoutMs: number;
|
|
229
231
|
}[];
|
|
230
232
|
} | undefined;
|
|
233
|
+
dependencyStore?: {
|
|
234
|
+
manager: "pnpm";
|
|
235
|
+
lockfile: string;
|
|
236
|
+
maxBytes: number;
|
|
237
|
+
timeoutMs: number;
|
|
238
|
+
} | undefined;
|
|
231
239
|
toolchain?: {
|
|
232
240
|
tools: Record<string, string>;
|
|
233
241
|
packageManagers: Record<string, "npm" | "pnpm">;
|
|
@@ -211,7 +211,7 @@ export declare class DocumentView {
|
|
|
211
211
|
activeRunId?: string | undefined;
|
|
212
212
|
resultSha?: string | undefined;
|
|
213
213
|
failure?: string | undefined;
|
|
214
|
-
failureKind?: "gate" | "unknown" | "review" | "
|
|
214
|
+
failureKind?: "gate" | "unknown" | "review" | "cancelled" | "environment" | "timeout" | "provider-auth" | "stale-base" | "empty-result" | "unfinished" | "scope-violation" | "review-protocol" | "merge" | "budget" | "needs-lead" | undefined;
|
|
215
215
|
failureFingerprint?: string | undefined;
|
|
216
216
|
approvedAt?: string | undefined;
|
|
217
217
|
approvedDigest?: string | undefined;
|
|
@@ -359,7 +359,7 @@ export declare class DocumentView {
|
|
|
359
359
|
activeRunId?: string | undefined;
|
|
360
360
|
resultSha?: string | undefined;
|
|
361
361
|
failure?: string | undefined;
|
|
362
|
-
failureKind?: "gate" | "unknown" | "review" | "
|
|
362
|
+
failureKind?: "gate" | "unknown" | "review" | "cancelled" | "environment" | "timeout" | "provider-auth" | "stale-base" | "empty-result" | "unfinished" | "scope-violation" | "review-protocol" | "merge" | "budget" | "needs-lead" | undefined;
|
|
363
363
|
failureFingerprint?: string | undefined;
|
|
364
364
|
approvedAt?: string | undefined;
|
|
365
365
|
approvedDigest?: string | undefined;
|
|
@@ -618,6 +618,21 @@ export declare class DocumentView {
|
|
|
618
618
|
} | undefined;
|
|
619
619
|
coverage?: string[] | undefined;
|
|
620
620
|
} | undefined;
|
|
621
|
+
artifactFiles?: {
|
|
622
|
+
dir: string;
|
|
623
|
+
files: {
|
|
624
|
+
path: string;
|
|
625
|
+
sha256: string;
|
|
626
|
+
bytes: number;
|
|
627
|
+
redacted?: true | undefined;
|
|
628
|
+
}[];
|
|
629
|
+
skipped: {
|
|
630
|
+
path: string;
|
|
631
|
+
reason: "missing" | "symlink" | "outside" | "not-regular" | "hardlink" | "secret" | "extension" | "file-limit" | "total-limit" | "count-limit" | "scan-limit" | "copy-failed";
|
|
632
|
+
detail?: string | undefined;
|
|
633
|
+
}[];
|
|
634
|
+
skippedMore?: number | undefined;
|
|
635
|
+
} | undefined;
|
|
621
636
|
checks?: string | undefined;
|
|
622
637
|
alreadySatisfied?: {
|
|
623
638
|
gates: string[];
|
|
@@ -644,7 +659,7 @@ export declare class DocumentView {
|
|
|
644
659
|
integrationSha?: string | undefined;
|
|
645
660
|
error?: string | undefined;
|
|
646
661
|
blocked?: boolean | undefined;
|
|
647
|
-
failureKind?: "gate" | "unknown" | "review" | "
|
|
662
|
+
failureKind?: "gate" | "unknown" | "review" | "cancelled" | "environment" | "timeout" | "provider-auth" | "stale-base" | "empty-result" | "unfinished" | "scope-violation" | "review-protocol" | "merge" | "budget" | "needs-lead" | undefined;
|
|
648
663
|
failureFingerprint?: string | undefined;
|
|
649
664
|
requiredGates?: string[] | undefined;
|
|
650
665
|
consumers?: {
|
|
@@ -734,7 +749,7 @@ export declare class DocumentView {
|
|
|
734
749
|
kind: "candidate" | "unfinished";
|
|
735
750
|
applied: boolean;
|
|
736
751
|
files: string[];
|
|
737
|
-
reason?: "gate" | "unknown" | "review" | "
|
|
752
|
+
reason?: "gate" | "unknown" | "review" | "cancelled" | "environment" | "timeout" | "provider-auth" | "stale-base" | "empty-result" | "unfinished" | "scope-violation" | "review-protocol" | "merge" | "budget" | "needs-lead" | undefined;
|
|
738
753
|
respecified?: boolean | undefined;
|
|
739
754
|
} | undefined;
|
|
740
755
|
callsRecorded?: true | undefined;
|
|
@@ -932,6 +947,21 @@ export declare class DocumentView {
|
|
|
932
947
|
} | undefined;
|
|
933
948
|
coverage?: string[] | undefined;
|
|
934
949
|
} | undefined;
|
|
950
|
+
artifactFiles?: {
|
|
951
|
+
dir: string;
|
|
952
|
+
files: {
|
|
953
|
+
path: string;
|
|
954
|
+
sha256: string;
|
|
955
|
+
bytes: number;
|
|
956
|
+
redacted?: true | undefined;
|
|
957
|
+
}[];
|
|
958
|
+
skipped: {
|
|
959
|
+
path: string;
|
|
960
|
+
reason: "missing" | "symlink" | "outside" | "not-regular" | "hardlink" | "secret" | "extension" | "file-limit" | "total-limit" | "count-limit" | "scan-limit" | "copy-failed";
|
|
961
|
+
detail?: string | undefined;
|
|
962
|
+
}[];
|
|
963
|
+
skippedMore?: number | undefined;
|
|
964
|
+
} | undefined;
|
|
935
965
|
checks?: string | undefined;
|
|
936
966
|
alreadySatisfied?: {
|
|
937
967
|
gates: string[];
|
|
@@ -958,7 +988,7 @@ export declare class DocumentView {
|
|
|
958
988
|
integrationSha?: string | undefined;
|
|
959
989
|
error?: string | undefined;
|
|
960
990
|
blocked?: boolean | undefined;
|
|
961
|
-
failureKind?: "gate" | "unknown" | "review" | "
|
|
991
|
+
failureKind?: "gate" | "unknown" | "review" | "cancelled" | "environment" | "timeout" | "provider-auth" | "stale-base" | "empty-result" | "unfinished" | "scope-violation" | "review-protocol" | "merge" | "budget" | "needs-lead" | undefined;
|
|
962
992
|
failureFingerprint?: string | undefined;
|
|
963
993
|
requiredGates?: string[] | undefined;
|
|
964
994
|
consumers?: {
|
|
@@ -1048,7 +1078,7 @@ export declare class DocumentView {
|
|
|
1048
1078
|
kind: "candidate" | "unfinished";
|
|
1049
1079
|
applied: boolean;
|
|
1050
1080
|
files: string[];
|
|
1051
|
-
reason?: "gate" | "unknown" | "review" | "
|
|
1081
|
+
reason?: "gate" | "unknown" | "review" | "cancelled" | "environment" | "timeout" | "provider-auth" | "stale-base" | "empty-result" | "unfinished" | "scope-violation" | "review-protocol" | "merge" | "budget" | "needs-lead" | undefined;
|
|
1052
1082
|
respecified?: boolean | undefined;
|
|
1053
1083
|
} | undefined;
|
|
1054
1084
|
callsRecorded?: true | undefined;
|
|
@@ -1109,6 +1139,21 @@ export declare class DocumentView {
|
|
|
1109
1139
|
path: string;
|
|
1110
1140
|
digest: string;
|
|
1111
1141
|
}[];
|
|
1142
|
+
artifactFiles?: {
|
|
1143
|
+
dir: string;
|
|
1144
|
+
files: {
|
|
1145
|
+
path: string;
|
|
1146
|
+
sha256: string;
|
|
1147
|
+
bytes: number;
|
|
1148
|
+
redacted?: true | undefined;
|
|
1149
|
+
}[];
|
|
1150
|
+
skipped: {
|
|
1151
|
+
path: string;
|
|
1152
|
+
reason: "missing" | "symlink" | "outside" | "not-regular" | "hardlink" | "secret" | "extension" | "file-limit" | "total-limit" | "count-limit" | "scan-limit" | "copy-failed";
|
|
1153
|
+
detail?: string | undefined;
|
|
1154
|
+
}[];
|
|
1155
|
+
skippedMore?: number | undefined;
|
|
1156
|
+
} | undefined;
|
|
1112
1157
|
durationMs?: number | undefined;
|
|
1113
1158
|
}[];
|
|
1114
1159
|
token: string;
|
|
@@ -1122,7 +1167,7 @@ export declare class DocumentView {
|
|
|
1122
1167
|
changed: string[];
|
|
1123
1168
|
affected: string[];
|
|
1124
1169
|
gateIds: string[];
|
|
1125
|
-
mode: "
|
|
1170
|
+
mode: "affected" | "all";
|
|
1126
1171
|
reason: string;
|
|
1127
1172
|
baseline?: string | undefined;
|
|
1128
1173
|
} | undefined;
|
|
@@ -1149,6 +1194,21 @@ export declare class DocumentView {
|
|
|
1149
1194
|
path: string;
|
|
1150
1195
|
digest: string;
|
|
1151
1196
|
}[];
|
|
1197
|
+
artifactFiles?: {
|
|
1198
|
+
dir: string;
|
|
1199
|
+
files: {
|
|
1200
|
+
path: string;
|
|
1201
|
+
sha256: string;
|
|
1202
|
+
bytes: number;
|
|
1203
|
+
redacted?: true | undefined;
|
|
1204
|
+
}[];
|
|
1205
|
+
skipped: {
|
|
1206
|
+
path: string;
|
|
1207
|
+
reason: "missing" | "symlink" | "outside" | "not-regular" | "hardlink" | "secret" | "extension" | "file-limit" | "total-limit" | "count-limit" | "scan-limit" | "copy-failed";
|
|
1208
|
+
detail?: string | undefined;
|
|
1209
|
+
}[];
|
|
1210
|
+
skippedMore?: number | undefined;
|
|
1211
|
+
} | undefined;
|
|
1152
1212
|
durationMs?: number | undefined;
|
|
1153
1213
|
}[];
|
|
1154
1214
|
token: string;
|
|
@@ -1162,7 +1222,7 @@ export declare class DocumentView {
|
|
|
1162
1222
|
changed: string[];
|
|
1163
1223
|
affected: string[];
|
|
1164
1224
|
gateIds: string[];
|
|
1165
|
-
mode: "
|
|
1225
|
+
mode: "affected" | "all";
|
|
1166
1226
|
reason: string;
|
|
1167
1227
|
baseline?: string | undefined;
|
|
1168
1228
|
} | undefined;
|
|
@@ -1193,6 +1253,21 @@ export declare class DocumentView {
|
|
|
1193
1253
|
path: string;
|
|
1194
1254
|
digest: string;
|
|
1195
1255
|
}[];
|
|
1256
|
+
artifactFiles?: {
|
|
1257
|
+
dir: string;
|
|
1258
|
+
files: {
|
|
1259
|
+
path: string;
|
|
1260
|
+
sha256: string;
|
|
1261
|
+
bytes: number;
|
|
1262
|
+
redacted?: true | undefined;
|
|
1263
|
+
}[];
|
|
1264
|
+
skipped: {
|
|
1265
|
+
path: string;
|
|
1266
|
+
reason: "missing" | "symlink" | "outside" | "not-regular" | "hardlink" | "secret" | "extension" | "file-limit" | "total-limit" | "count-limit" | "scan-limit" | "copy-failed";
|
|
1267
|
+
detail?: string | undefined;
|
|
1268
|
+
}[];
|
|
1269
|
+
skippedMore?: number | undefined;
|
|
1270
|
+
} | undefined;
|
|
1196
1271
|
durationMs?: number | undefined;
|
|
1197
1272
|
}[];
|
|
1198
1273
|
token: string;
|
|
@@ -1201,7 +1276,7 @@ export declare class DocumentView {
|
|
|
1201
1276
|
changed: string[];
|
|
1202
1277
|
affected: string[];
|
|
1203
1278
|
gateIds: string[];
|
|
1204
|
-
mode: "
|
|
1279
|
+
mode: "affected" | "all";
|
|
1205
1280
|
reason: string;
|
|
1206
1281
|
baseline?: string | undefined;
|
|
1207
1282
|
} | undefined;
|
|
@@ -1227,6 +1302,21 @@ export declare class DocumentView {
|
|
|
1227
1302
|
path: string;
|
|
1228
1303
|
digest: string;
|
|
1229
1304
|
}[];
|
|
1305
|
+
artifactFiles?: {
|
|
1306
|
+
dir: string;
|
|
1307
|
+
files: {
|
|
1308
|
+
path: string;
|
|
1309
|
+
sha256: string;
|
|
1310
|
+
bytes: number;
|
|
1311
|
+
redacted?: true | undefined;
|
|
1312
|
+
}[];
|
|
1313
|
+
skipped: {
|
|
1314
|
+
path: string;
|
|
1315
|
+
reason: "missing" | "symlink" | "outside" | "not-regular" | "hardlink" | "secret" | "extension" | "file-limit" | "total-limit" | "count-limit" | "scan-limit" | "copy-failed";
|
|
1316
|
+
detail?: string | undefined;
|
|
1317
|
+
}[];
|
|
1318
|
+
skippedMore?: number | undefined;
|
|
1319
|
+
} | undefined;
|
|
1230
1320
|
durationMs?: number | undefined;
|
|
1231
1321
|
}[];
|
|
1232
1322
|
token: string;
|
|
@@ -1240,7 +1330,7 @@ export declare class DocumentView {
|
|
|
1240
1330
|
changed: string[];
|
|
1241
1331
|
affected: string[];
|
|
1242
1332
|
gateIds: string[];
|
|
1243
|
-
mode: "
|
|
1333
|
+
mode: "affected" | "all";
|
|
1244
1334
|
reason: string;
|
|
1245
1335
|
baseline?: string | undefined;
|
|
1246
1336
|
} | undefined;
|
|
@@ -1267,6 +1357,21 @@ export declare class DocumentView {
|
|
|
1267
1357
|
path: string;
|
|
1268
1358
|
digest: string;
|
|
1269
1359
|
}[];
|
|
1360
|
+
artifactFiles?: {
|
|
1361
|
+
dir: string;
|
|
1362
|
+
files: {
|
|
1363
|
+
path: string;
|
|
1364
|
+
sha256: string;
|
|
1365
|
+
bytes: number;
|
|
1366
|
+
redacted?: true | undefined;
|
|
1367
|
+
}[];
|
|
1368
|
+
skipped: {
|
|
1369
|
+
path: string;
|
|
1370
|
+
reason: "missing" | "symlink" | "outside" | "not-regular" | "hardlink" | "secret" | "extension" | "file-limit" | "total-limit" | "count-limit" | "scan-limit" | "copy-failed";
|
|
1371
|
+
detail?: string | undefined;
|
|
1372
|
+
}[];
|
|
1373
|
+
skippedMore?: number | undefined;
|
|
1374
|
+
} | undefined;
|
|
1270
1375
|
durationMs?: number | undefined;
|
|
1271
1376
|
}[];
|
|
1272
1377
|
token: string;
|
|
@@ -1280,7 +1385,7 @@ export declare class DocumentView {
|
|
|
1280
1385
|
changed: string[];
|
|
1281
1386
|
affected: string[];
|
|
1282
1387
|
gateIds: string[];
|
|
1283
|
-
mode: "
|
|
1388
|
+
mode: "affected" | "all";
|
|
1284
1389
|
reason: string;
|
|
1285
1390
|
baseline?: string | undefined;
|
|
1286
1391
|
} | undefined;
|
|
@@ -1311,6 +1416,21 @@ export declare class DocumentView {
|
|
|
1311
1416
|
path: string;
|
|
1312
1417
|
digest: string;
|
|
1313
1418
|
}[];
|
|
1419
|
+
artifactFiles?: {
|
|
1420
|
+
dir: string;
|
|
1421
|
+
files: {
|
|
1422
|
+
path: string;
|
|
1423
|
+
sha256: string;
|
|
1424
|
+
bytes: number;
|
|
1425
|
+
redacted?: true | undefined;
|
|
1426
|
+
}[];
|
|
1427
|
+
skipped: {
|
|
1428
|
+
path: string;
|
|
1429
|
+
reason: "missing" | "symlink" | "outside" | "not-regular" | "hardlink" | "secret" | "extension" | "file-limit" | "total-limit" | "count-limit" | "scan-limit" | "copy-failed";
|
|
1430
|
+
detail?: string | undefined;
|
|
1431
|
+
}[];
|
|
1432
|
+
skippedMore?: number | undefined;
|
|
1433
|
+
} | undefined;
|
|
1314
1434
|
durationMs?: number | undefined;
|
|
1315
1435
|
}[];
|
|
1316
1436
|
token: string;
|
|
@@ -1319,7 +1439,7 @@ export declare class DocumentView {
|
|
|
1319
1439
|
changed: string[];
|
|
1320
1440
|
affected: string[];
|
|
1321
1441
|
gateIds: string[];
|
|
1322
|
-
mode: "
|
|
1442
|
+
mode: "affected" | "all";
|
|
1323
1443
|
reason: string;
|
|
1324
1444
|
baseline?: string | undefined;
|
|
1325
1445
|
} | undefined;
|
|
@@ -7,7 +7,7 @@ type Field = (string | number)[];
|
|
|
7
7
|
* Коды проблем диагностики toolchain. Каждая проблема называет поле
|
|
8
8
|
* конфигурации (`field`) и, когда причина в файле проекта, — путь (`path`).
|
|
9
9
|
*/
|
|
10
|
-
export declare const toolchainProblemCodes: readonly ["REPOSITORY_MISSING", "CWD_MISSING", "TOOL_MISSING", "TOOL_VERSION", "TOOL_VERSION_UNKNOWN", "TOOL_NOT_LOCKED", "MANIFEST_MISSING", "LOCKFILE_MISSING", "LOCKFILE_AMBIGUOUS", "SCRIPT_UNKNOWN", "TASK_UNKNOWN", "FILTER_UNKNOWN", "INSTALL_UNLOCKED", "UNPINNED", "IF_PRESENT", "CACHE_REPLAY", "REPORT_MISMATCH", "COMPOSITION_CONFLICT", "PROJECT_FILE_MISSING", "SCRIPT_UNRESOLVED", "TOOL_IN_PROJECT"];
|
|
10
|
+
export declare const toolchainProblemCodes: readonly ["REPOSITORY_MISSING", "CWD_MISSING", "TOOL_MISSING", "TOOL_VERSION", "TOOL_VERSION_UNKNOWN", "TOOL_NOT_LOCKED", "MANIFEST_MISSING", "LOCKFILE_MISSING", "LOCKFILE_AMBIGUOUS", "SCRIPT_UNKNOWN", "TASK_UNKNOWN", "FILTER_UNKNOWN", "INSTALL_UNLOCKED", "UNPINNED", "IF_PRESENT", "CACHE_REPLAY", "REPORT_MISMATCH", "COMPOSITION_CONFLICT", "PROJECT_FILE_MISSING", "SCRIPT_UNRESOLVED", "TOOL_IN_PROJECT", "DEPENDENCY_STORE"];
|
|
11
11
|
export type ToolchainProblemCode = (typeof toolchainProblemCodes)[number];
|
|
12
12
|
export interface ToolchainProblem {
|
|
13
13
|
code: ToolchainProblemCode;
|
|
@@ -2,7 +2,7 @@ import { existsSync, realpathSync } from 'node:fs';
|
|
|
2
2
|
import { basename, isAbsolute, posix, resolve, sep } from 'node:path';
|
|
3
3
|
import { HarnessError, } from "../contracts/index.js";
|
|
4
4
|
import { Manifests, goModule, join2, lockedVersion, lockfiles, packageManagerField, scriptsOf, turboTasks, uvLocked, workspacePackages, } from "./manifests.js";
|
|
5
|
-
import { PROBE_TIMEOUT_MS, defaultProbe, moduleVersionOf, resolveExecutable, satisfies, versionOf, } from "./probe.js";
|
|
5
|
+
import { PROBE_TIMEOUT_MS, defaultProbe, dependencyStoreSupports, dependencyStoreVersions, moduleVersionOf, resolveExecutable, satisfies, versionOf, } from "./probe.js";
|
|
6
6
|
/**
|
|
7
7
|
* Коды проблем диагностики toolchain. Каждая проблема называет поле
|
|
8
8
|
* конфигурации (`field`) и, когда причина в файле проекта, — путь (`path`).
|
|
@@ -29,6 +29,7 @@ export const toolchainProblemCodes = [
|
|
|
29
29
|
'PROJECT_FILE_MISSING',
|
|
30
30
|
'SCRIPT_UNRESOLVED',
|
|
31
31
|
'TOOL_IN_PROJECT',
|
|
32
|
+
'DEPENDENCY_STORE',
|
|
32
33
|
];
|
|
33
34
|
/**
|
|
34
35
|
* Исполняемый файл под контролем проекта: его канонический путь (после всех
|
|
@@ -638,6 +639,33 @@ export async function inspectRepository(repo, root, field, options = {}) {
|
|
|
638
639
|
steps('prepare', repo.prepare, [...field, 'prepare']);
|
|
639
640
|
steps('dependencyBuild', repo.dependencyBuild, [...field, 'dependencyBuild']);
|
|
640
641
|
steps('preflight', repo.preflight, [...field, 'preflight']);
|
|
642
|
+
// Хранилище зависимостей — ускорение: что мешает ему, остаётся предупреждением,
|
|
643
|
+
// и работа идёт с обычной установкой.
|
|
644
|
+
if (repo.dependencyStore) {
|
|
645
|
+
const store = repo.dependencyStore;
|
|
646
|
+
const storeField = [...field, 'dependencyStore'];
|
|
647
|
+
if (!m.isFile(store.lockfile))
|
|
648
|
+
warning('LOCKFILE_MISSING', [...storeField, 'lockfile'], 'Хранилищу зависимостей нужен lockfile: ' + store.lockfile);
|
|
649
|
+
const { from, below } = dependencyStoreVersions[store.manager];
|
|
650
|
+
const executable = resolveExecutable(store.manager, PATH);
|
|
651
|
+
if (!executable)
|
|
652
|
+
warning('TOOL_MISSING', [...storeField, 'manager'], `Не найден ${store.manager}`);
|
|
653
|
+
else {
|
|
654
|
+
const found = await probe([store.manager, '--version'], {
|
|
655
|
+
timeoutMs,
|
|
656
|
+
env: { ...env, PATH },
|
|
657
|
+
}).catch(() => undefined);
|
|
658
|
+
const version = versionOf(found?.stdout ?? '');
|
|
659
|
+
if (!version)
|
|
660
|
+
warning('DEPENDENCY_STORE', [...storeField, 'manager'], `Версия ${store.manager} не определена: хранилище не действует, установка обычная`);
|
|
661
|
+
const declared = packageManagerField(m, '.');
|
|
662
|
+
for (const v of [version, declared?.name === store.manager ? declared.version : undefined])
|
|
663
|
+
if (v && !dependencyStoreSupports(store.manager, v))
|
|
664
|
+
warning('DEPENDENCY_STORE', [...storeField, 'manager'], `${store.manager} ${v} вне проверенных версий ${from} … <${below}: хранилище не действует, установка обычная`);
|
|
665
|
+
}
|
|
666
|
+
if (repo.prepare.length)
|
|
667
|
+
warning('DEPENDENCY_STORE', [...storeField], 'prepare идёт на хосте, на integration — над слитым деревом: если шаг исполняет код кандидата, он может изменить seed');
|
|
668
|
+
}
|
|
641
669
|
const lifecycle = repo.lifecycle ?? options.lifecycle;
|
|
642
670
|
const lifecycleField = repo.lifecycle ? [...field, 'lifecycle'] : ['lifecycle'];
|
|
643
671
|
if (lifecycle)
|