devcontour-harness 0.1.0-alpha.44 → 0.1.0-alpha.45
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 +11 -2
- package/docs/contracts.md +107 -1
- package/docs/release-notes/0.1.0-alpha.45.md +77 -0
- package/docs/upgrade.md +60 -18
- package/lib/contracts/cli.d.ts +67 -0
- package/lib/contracts/cli.js +6 -1
- package/lib/contracts/events.d.ts +5 -0
- package/lib/contracts/events.js +2 -0
- package/lib/contracts/execution.d.ts +39 -0
- package/lib/contracts/execution.js +15 -2
- package/lib/contracts/policy.d.ts +39 -0
- package/lib/contracts/policy.js +64 -0
- package/lib/contracts/profiles.d.ts +6 -0
- package/lib/contracts/published.d.ts +69 -0
- package/lib/contracts/result.d.ts +91 -0
- package/lib/contracts/result.js +31 -1
- package/lib/contracts/review.d.ts +1 -1
- package/lib/control/harness.d.ts +24 -2
- package/lib/engine/engine.d.ts +18 -3
- package/lib/engine/engine.js +74 -8
- package/lib/engine/result.js +7 -3
- package/lib/engine/runner.d.ts +8 -0
- package/lib/engine/runner.js +91 -3
- package/lib/environment/git-trust.js +3 -0
- package/lib/environment/process.d.ts +2 -0
- package/lib/environment/process.js +7 -1
- package/lib/explain/state.js +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/integrations/connector/history.js +1 -1
- package/lib/integrations/connector/summary.js +2 -1
- package/lib/profiles/resolve.d.ts +6 -0
- package/lib/projections/attempt.d.ts +4 -2
- package/lib/projections/attempt.js +14 -1
- package/lib/report/compute.js +4 -3
- package/lib/storage/document.d.ts +26 -2
- package/lib/verification/acceptance.d.ts +12 -0
- package/lib/verification/acceptance.js +62 -7
- package/lib/verification/applicability.d.ts +134 -0
- package/lib/verification/applicability.js +373 -0
- package/lib/verification/gates.d.ts +6 -0
- package/lib/verification/proof.d.ts +18 -4
- package/lib/verification/proof.js +52 -9
- package/package.json +1 -1
- package/schemas/execution-document.schema.json +73 -1
- package/schemas/execution-policy.schema.json +38 -0
- package/schemas/result-envelope.schema.json +138 -2
- package/schemas/run-event.schema.json +4 -0
- package/schemas/run-result.schema.json +138 -2
package/lib/engine/runner.d.ts
CHANGED
|
@@ -302,6 +302,14 @@ export declare class Runner {
|
|
|
302
302
|
* прошёл, `confirmed` — провал подтвердился и засчитывается как прежде).
|
|
303
303
|
*/
|
|
304
304
|
private integrationGate;
|
|
305
|
+
/**
|
|
306
|
+
* Gates фазы, которые исполняются; для остальных (gate с `when.paths`, чей
|
|
307
|
+
* путь diff фазы не задел, — `gateDecisions`) записывается `not-applicable`.
|
|
308
|
+
* Diff — из Git: кандидат — `base..candidate`; интеграция — ещё и
|
|
309
|
+
* `base..integration` (то, что принесло слияние с target). Попытка без
|
|
310
|
+
* изменений исполняет всё: её приёмка опирается на прохождение gates.
|
|
311
|
+
*/
|
|
312
|
+
private applicableGates;
|
|
305
313
|
private runOneGate;
|
|
306
314
|
/**
|
|
307
315
|
* Ожидаемая проверка генеративного gate. Проверка потребителя исполняет
|
package/lib/engine/runner.js
CHANGED
|
@@ -21,6 +21,7 @@ import { GateTimeout, prepareWriterDependencies, draftTouchesInstall, runGate, w
|
|
|
21
21
|
import { ActivityScope, activityScope } from "../environment/activity.js";
|
|
22
22
|
import { StallSweep, StalledError, stallMessage, livenessPayload, } from "./stall-sweep.js";
|
|
23
23
|
import { orderedScope } from "../verification/gate-scope.js";
|
|
24
|
+
import { changedPaths, gateBasis, gateDecisions, proofGates, } from "../verification/applicability.js";
|
|
24
25
|
import { alreadySatisfiedVerdict, contractCheckGates, withinWriteScope, } from "../verification/already-satisfied.js";
|
|
25
26
|
import { assertDependencies, dependencyFreshness, removeSnapshots, snapshotDependencies, } from "../verification/dependencies.js";
|
|
26
27
|
import { CleanupFailure, cleanupEnvironment } from "../environment/lifecycle.js";
|
|
@@ -1193,7 +1194,8 @@ export class Runner {
|
|
|
1193
1194
|
rearm();
|
|
1194
1195
|
this.engine.phase(attempt.id, attempt.token, 'verifying', { candidateSha: sha });
|
|
1195
1196
|
const recheck = { recheck: true };
|
|
1196
|
-
|
|
1197
|
+
const applicable = await this.applicableGates(attempt, work, repo, gates, 'candidate', cwd, sha, base);
|
|
1198
|
+
for (const gate of applicable)
|
|
1197
1199
|
await this.candidateGate(attempt, cwd, sha, gate, artifacts, signal, execution, recheck).catch((error) => {
|
|
1198
1200
|
// Без изменений непрошедший gate значит одно: работа не
|
|
1199
1201
|
// сделана, — это пустой результат, а не дефект кода.
|
|
@@ -1722,14 +1724,97 @@ export class Runner {
|
|
|
1722
1724
|
await this.gate(attempt, cwd, sha, 'integration', gate, artifacts, signal, execution, undefined, failed.id);
|
|
1723
1725
|
}
|
|
1724
1726
|
}
|
|
1727
|
+
/**
|
|
1728
|
+
* Gates фазы, которые исполняются; для остальных (gate с `when.paths`, чей
|
|
1729
|
+
* путь diff фазы не задел, — `gateDecisions`) записывается `not-applicable`.
|
|
1730
|
+
* Diff — из Git: кандидат — `base..candidate`; интеграция — ещё и
|
|
1731
|
+
* `base..integration` (то, что принесло слияние с target). Попытка без
|
|
1732
|
+
* изменений исполняет всё: её приёмка опирается на прохождение gates.
|
|
1733
|
+
*/
|
|
1734
|
+
async applicableGates(attempt, work, repo, gates, phase, cwd, sha, base) {
|
|
1735
|
+
if (!gates.some((g) => g.when))
|
|
1736
|
+
return gates;
|
|
1737
|
+
const candidate = phase === 'candidate' ? sha : attempt.candidateSha;
|
|
1738
|
+
if (candidate === base)
|
|
1739
|
+
return gates;
|
|
1740
|
+
const proof = this.engine.read((v) => proofGates(work.order, contractDocuments(work.order, v)));
|
|
1741
|
+
// Последний зелёный SHA условного gate: integration принятой попытки
|
|
1742
|
+
// этого репозитория, где gate прошёл под тем же основанием (`gateBasis`),
|
|
1743
|
+
// и предок базы попытки. Diff фазы — от него: всё, что попало в target
|
|
1744
|
+
// после (в том числе мимо harness или в задачах с суженной областью),
|
|
1745
|
+
// входит в решение. Нет такого SHA — gate исполняется.
|
|
1746
|
+
const greens = this.engine.read((v) => v
|
|
1747
|
+
.attempts()
|
|
1748
|
+
.filter((x) => x.status === 'succeeded' && x.repositoryId === repo.id && x.integrationSha)
|
|
1749
|
+
.sort((x, y) => (y.finishedAt ?? '').localeCompare(x.finishedAt ?? '')));
|
|
1750
|
+
const diffs = new Map();
|
|
1751
|
+
const changed = new Map();
|
|
1752
|
+
for (const gate of gates) {
|
|
1753
|
+
if (!gate.when || proof.has(gate.id))
|
|
1754
|
+
continue;
|
|
1755
|
+
const basis = gateBasis(this.policy, repo, gate, this.engine.version);
|
|
1756
|
+
const shas = [
|
|
1757
|
+
...new Set(greens
|
|
1758
|
+
.filter((x) => x.evidence.some((e) => e.kind === 'test' &&
|
|
1759
|
+
e.phase === 'integration' &&
|
|
1760
|
+
e.sha === x.integrationSha &&
|
|
1761
|
+
e.gate === gate.id &&
|
|
1762
|
+
e.consumer === undefined &&
|
|
1763
|
+
e.passed &&
|
|
1764
|
+
e.gateBasis === basis))
|
|
1765
|
+
.map((x) => x.integrationSha)),
|
|
1766
|
+
].slice(0, 50);
|
|
1767
|
+
let anchor;
|
|
1768
|
+
for (const green of shas)
|
|
1769
|
+
if (await git(cwd, 'merge-base', '--is-ancestor', green, base).then(() => true, () => false)) {
|
|
1770
|
+
anchor = green;
|
|
1771
|
+
break;
|
|
1772
|
+
}
|
|
1773
|
+
if (!anchor)
|
|
1774
|
+
continue;
|
|
1775
|
+
if (!diffs.has(anchor))
|
|
1776
|
+
diffs.set(anchor, await changedPaths(cwd, [
|
|
1777
|
+
{ from: anchor, to: candidate },
|
|
1778
|
+
...(phase === 'integration' ? [{ from: anchor, to: sha }] : []),
|
|
1779
|
+
]));
|
|
1780
|
+
changed.set(gate.id, diffs.get(anchor));
|
|
1781
|
+
}
|
|
1782
|
+
const decisions = gateDecisions({
|
|
1783
|
+
repo,
|
|
1784
|
+
scope: gates,
|
|
1785
|
+
proof,
|
|
1786
|
+
changedFor: (gate) => changed.get(gate.id),
|
|
1787
|
+
});
|
|
1788
|
+
for (const d of decisions)
|
|
1789
|
+
if (!d.run && d.record)
|
|
1790
|
+
this.engine.evidence(attempt.id, attempt.token, {
|
|
1791
|
+
kind: 'not-applicable',
|
|
1792
|
+
phase,
|
|
1793
|
+
sha,
|
|
1794
|
+
gate: d.gate.id,
|
|
1795
|
+
passed: false,
|
|
1796
|
+
command: [],
|
|
1797
|
+
exitCode: -1,
|
|
1798
|
+
log: '',
|
|
1799
|
+
digest: digestOf(d.record),
|
|
1800
|
+
summary: `Не применим: diff фазы (${d.record.count} путей) не задел when.paths и неявные входы gate`,
|
|
1801
|
+
notApplicable: d.record,
|
|
1802
|
+
});
|
|
1803
|
+
return decisions.filter((d) => d.run).map((d) => d.gate);
|
|
1804
|
+
}
|
|
1725
1805
|
async runOneGate(attempt, cwd, sha, phase, gate, artifacts, signal, execution, consumer, recheck) {
|
|
1726
1806
|
// Генеративный gate — всегда; gate эталонных наборов — когда манифест
|
|
1727
1807
|
// поручения ждёт от него отчёта (без договора — прежний уровень).
|
|
1728
1808
|
const run = this.propertyRun(attempt, gate, consumer);
|
|
1729
1809
|
const property = gate.property || expectsReference(run.expected) ? run : undefined;
|
|
1810
|
+
const basis = gate.when && !consumer
|
|
1811
|
+
? {
|
|
1812
|
+
gateBasis: gateBasis(this.policy, this.repo(attempt.repositoryId), gate, this.engine.version),
|
|
1813
|
+
}
|
|
1814
|
+
: {};
|
|
1730
1815
|
await runGate({
|
|
1731
1816
|
policy: this.policy,
|
|
1732
|
-
record: (e) => this.engine.evidence(attempt.id, attempt.token, e),
|
|
1817
|
+
record: (e) => this.engine.evidence(attempt.id, attempt.token, { ...e, ...basis }),
|
|
1733
1818
|
cwd,
|
|
1734
1819
|
sha,
|
|
1735
1820
|
phase,
|
|
@@ -2496,6 +2581,8 @@ export class Runner {
|
|
|
2496
2581
|
passed: e.passed,
|
|
2497
2582
|
summary: e.summary,
|
|
2498
2583
|
...(e.consumer ? { consumer: e.consumer } : {}),
|
|
2584
|
+
// Gate не исполнялся по when.paths: не провал и не PASS.
|
|
2585
|
+
...(e.kind === 'not-applicable' ? { notApplicable: true } : {}),
|
|
2499
2586
|
}))), 'Where a requirement names a testId, open that test. Reject it when the test does not exercise the stated scenario, or when it would still pass if the behaviour it claims to prove were broken. A matching name is not proof.');
|
|
2500
2587
|
}
|
|
2501
2588
|
const r = v.work(attempt.workId)?.recovery;
|
|
@@ -2650,7 +2737,8 @@ export class Runner {
|
|
|
2650
2737
|
await runSteps(repo.prepare, cwd, join(artifacts, 'integration', 'prepare'), execution, signal, attempt.baseSha);
|
|
2651
2738
|
prepared(execution);
|
|
2652
2739
|
const budget = { recheck: true };
|
|
2653
|
-
|
|
2740
|
+
const applicable = await this.applicableGates(attempt, work, repo, gates, 'integration', cwd, sha, attempt.baseSha);
|
|
2741
|
+
for (const gate of applicable)
|
|
2654
2742
|
await this.integrationGate(attempt, cwd, sha, gate, artifacts, signal, execution, budget);
|
|
2655
2743
|
await this.consumers(attempt, cwd, sha, artifacts, signal);
|
|
2656
2744
|
this.requirements(attempt, work, repoPath, cwd, sha, 'integration');
|
|
@@ -19,6 +19,9 @@ import { basename, dirname, join, resolve, sep } from 'node:path';
|
|
|
19
19
|
* исполняемые настройки, которые git читает сам.
|
|
20
20
|
*/
|
|
21
21
|
export const gitHardening = [
|
|
22
|
+
// Объекты замены (`refs/replace/*`) пишет любой, кто пишет в репозиторий:
|
|
23
|
+
// git хоста читает только настоящие объекты (diff, требования, области).
|
|
24
|
+
'--no-replace-objects',
|
|
22
25
|
'-c',
|
|
23
26
|
// Older Git treats 'false' as a hook executable; empty disables the hook
|
|
24
27
|
// there and is false for versions supporting the built-in fsmonitor.
|
|
@@ -59,6 +59,8 @@ export declare function hostGitArgs(cwd: string, args: string[]): string[];
|
|
|
59
59
|
* содержимого файла, которое разбирают, усечение незаметно и опасно.
|
|
60
60
|
*/
|
|
61
61
|
export declare function gitOutput(cwd: string, ...args: string[]): Promise<string>;
|
|
62
|
+
/** Вывод git целиком и без обрезки пробелов: для `-z`-списков путей. */
|
|
63
|
+
export declare function gitRawOutput(cwd: string, ...args: string[]): Promise<string>;
|
|
62
64
|
/**
|
|
63
65
|
* Содержимое объектов git одним `cat-file --batch`: байты, без усечения и
|
|
64
66
|
* без процесса на объект. Отсутствующий объект — отказ.
|
|
@@ -264,6 +264,8 @@ export function hostGitArgs(cwd, args) {
|
|
|
264
264
|
const gitEnv = () => ({
|
|
265
265
|
...process.env,
|
|
266
266
|
GIT_TERMINAL_PROMPT: '0',
|
|
267
|
+
// Дублирует `--no-replace-objects` из `gitHardening` для дочерних git.
|
|
268
|
+
GIT_NO_REPLACE_OBJECTS: '1',
|
|
267
269
|
GIT_AUTHOR_NAME: 'devcontour-harness',
|
|
268
270
|
GIT_AUTHOR_EMAIL: 'harness@localhost',
|
|
269
271
|
GIT_COMMITTER_NAME: 'devcontour-harness',
|
|
@@ -274,6 +276,10 @@ const gitEnv = () => ({
|
|
|
274
276
|
* содержимого файла, которое разбирают, усечение незаметно и опасно.
|
|
275
277
|
*/
|
|
276
278
|
export async function gitOutput(cwd, ...args) {
|
|
279
|
+
return (await gitRawOutput(cwd, ...args)).trim();
|
|
280
|
+
}
|
|
281
|
+
/** Вывод git целиком и без обрезки пробелов: для `-z`-списков путей. */
|
|
282
|
+
export async function gitRawOutput(cwd, ...args) {
|
|
277
283
|
let text = '';
|
|
278
284
|
const result = await command(['git', ...hostGitArgs(cwd, args)], cwd, {
|
|
279
285
|
env: gitEnv(),
|
|
@@ -283,7 +289,7 @@ export async function gitOutput(cwd, ...args) {
|
|
|
283
289
|
});
|
|
284
290
|
if (result.code !== 0)
|
|
285
291
|
throw new Error(`git ${args[0]}: ${result.stderr.trim()}`);
|
|
286
|
-
return text
|
|
292
|
+
return text;
|
|
287
293
|
}
|
|
288
294
|
/**
|
|
289
295
|
* Содержимое объектов git одним `cat-file --batch`: байты, без усечения и
|
package/lib/explain/state.js
CHANGED
|
@@ -322,7 +322,7 @@ export function stopInputsOf(h, options) {
|
|
|
322
322
|
? [
|
|
323
323
|
{ kind: 'attempt', id: last.id },
|
|
324
324
|
...last.evidence
|
|
325
|
-
.filter((e) => !e.passed)
|
|
325
|
+
.filter((e) => !e.passed && e.kind !== 'not-applicable')
|
|
326
326
|
.map((e) => ({ kind: 'evidence', id: e.id, sha: e.sha })),
|
|
327
327
|
]
|
|
328
328
|
: [];
|
package/lib/index.d.ts
CHANGED
|
@@ -69,6 +69,7 @@ export { runGatesAt, type GatesAtContext, type GatesAtInput, type GatesAtResult,
|
|
|
69
69
|
export { dependencyStoreRoot, materializeStore, type StoreContext, type StoreReceipt, } from './verification/dependency-store.ts';
|
|
70
70
|
export { explicitPrerequisites, gatePrerequisites, orderedScope, standaloneScope, } from './verification/gate-scope.ts';
|
|
71
71
|
export { requirementProof, uncoveredGates, unprovenReason } from './verification/proof.ts';
|
|
72
|
+
export { changedPaths, coverageChanges, gateBasis, gateDecisions, gatePathRegExp, matchingPaths, notApplicableProblem, pathApplicability, proofGates, type ChangedPaths, type GateDecision, type PathDecision, } from './verification/applicability.ts';
|
|
72
73
|
export { ReviewProbes, probeLimits, observeReproductions } from './agents/review-probe.ts';
|
|
73
74
|
export { composeRedactors, outputRedactor,
|
|
74
75
|
/**
|
package/lib/index.js
CHANGED
|
@@ -69,6 +69,7 @@ export { runGatesAt, } from "./verification/gates-at.js";
|
|
|
69
69
|
export { dependencyStoreRoot, materializeStore, } from "./verification/dependency-store.js";
|
|
70
70
|
export { explicitPrerequisites, gatePrerequisites, orderedScope, standaloneScope, } from "./verification/gate-scope.js";
|
|
71
71
|
export { requirementProof, uncoveredGates, unprovenReason } from "./verification/proof.js";
|
|
72
|
+
export { changedPaths, coverageChanges, gateBasis, gateDecisions, gatePathRegExp, matchingPaths, notApplicableProblem, pathApplicability, proofGates, } from "./verification/applicability.js";
|
|
72
73
|
export { ReviewProbes, probeLimits, observeReproductions } from "./agents/review-probe.js";
|
|
73
74
|
export { composeRedactors, outputRedactor,
|
|
74
75
|
/**
|
|
@@ -466,7 +466,7 @@ export class HistoryRecorder {
|
|
|
466
466
|
return { status: 'none' };
|
|
467
467
|
const gates = result.evidence
|
|
468
468
|
.filter((e) => e.kind !== 'review')
|
|
469
|
-
.map((e) => `${e.gate} [${e.phase}] ${e.passed ? 'passed' : 'failed'} @ ${e.sha.slice(0, 12)}`)
|
|
469
|
+
.map((e) => `${e.gate} [${e.phase}] ${e.kind === 'not-applicable' ? 'not applicable' : e.passed ? 'passed' : 'failed'} @ ${e.sha.slice(0, 12)}`)
|
|
470
470
|
.join('\n');
|
|
471
471
|
const accepted = result.outcome === 'accepted';
|
|
472
472
|
const body = accepted
|
|
@@ -12,7 +12,8 @@ export function summaryText(input) {
|
|
|
12
12
|
const tests = e.tests
|
|
13
13
|
? ` (${e.tests.filter((t) => t.status === 'passed').length}/${e.tests.length} тестов)`
|
|
14
14
|
: '';
|
|
15
|
-
|
|
15
|
+
const outcome = e.kind === 'not-applicable' ? 'not applicable' : e.passed ? 'passed' : 'failed';
|
|
16
|
+
return `- ${e.gate} [${e.phase}]: ${outcome}${tests} @ ${shortSha(e.sha)}`;
|
|
16
17
|
});
|
|
17
18
|
const reviews = r.evidence.filter((e) => e.kind === 'review');
|
|
18
19
|
const lines = [
|
|
@@ -126,6 +126,9 @@ export declare function repositoryFromProfile(profile: ResolvedProfile, own: Pic
|
|
|
126
126
|
command: string[];
|
|
127
127
|
timeoutMs: number;
|
|
128
128
|
artifacts?: string[] | undefined;
|
|
129
|
+
when?: {
|
|
130
|
+
paths: string[];
|
|
131
|
+
} | undefined;
|
|
129
132
|
property?: {
|
|
130
133
|
path?: string | undefined;
|
|
131
134
|
} | undefined;
|
|
@@ -142,6 +145,9 @@ export declare function repositoryFromProfile(profile: ResolvedProfile, own: Pic
|
|
|
142
145
|
path: string;
|
|
143
146
|
} | undefined;
|
|
144
147
|
artifacts?: string[] | undefined;
|
|
148
|
+
when?: {
|
|
149
|
+
paths: string[];
|
|
150
|
+
} | undefined;
|
|
145
151
|
property?: {
|
|
146
152
|
path?: string | undefined;
|
|
147
153
|
} | undefined;
|
|
@@ -24,7 +24,7 @@ export interface AttemptViewInput {
|
|
|
24
24
|
candidateSha?: string;
|
|
25
25
|
integrationSha?: string;
|
|
26
26
|
evidence: readonly {
|
|
27
|
-
kind: 'test' | 'review';
|
|
27
|
+
kind: 'test' | 'review' | 'not-applicable';
|
|
28
28
|
phase: 'candidate' | 'integration';
|
|
29
29
|
sha: string;
|
|
30
30
|
gate: string;
|
|
@@ -94,7 +94,7 @@ export interface AttemptView {
|
|
|
94
94
|
* Обязательные gates текущей фазы (интеграции — в `integrating`, иначе
|
|
95
95
|
* кандидата) по последней записи каждого gate на текущем SHA фазы, без
|
|
96
96
|
* проверок потребителей: прошли, не прошли, ещё без записи. Записи других
|
|
97
|
-
* gates и других SHA не считаются: `passed + failed + remaining = required`.
|
|
97
|
+
* gates и других SHA не считаются: `passed + failed + remaining (+ notApplicable) = required`.
|
|
98
98
|
*/
|
|
99
99
|
gates: {
|
|
100
100
|
phase: 'candidate' | 'integration';
|
|
@@ -102,6 +102,8 @@ export interface AttemptView {
|
|
|
102
102
|
passed: number;
|
|
103
103
|
failed: number;
|
|
104
104
|
remaining: number;
|
|
105
|
+
/** Не исполнены по `when.paths` (нет поля — таких нет); входят в `required`. */
|
|
106
|
+
notApplicable?: number;
|
|
105
107
|
};
|
|
106
108
|
/**
|
|
107
109
|
* Живость по последнему переходу обхода controller: `quiet` и `stalled`
|
|
@@ -15,6 +15,16 @@ export function attemptView(input, options) {
|
|
|
15
15
|
const sha = phase === 'integration' ? input.integrationSha : input.candidateSha;
|
|
16
16
|
const required = [...new Set(input.requiredGates ?? options.repositoryGates ?? [])];
|
|
17
17
|
const latest = new Map();
|
|
18
|
+
// Gate, не исполненный по `when.paths`: ни PASS, ни провал, но и не ждёт.
|
|
19
|
+
const notApplicable = new Set();
|
|
20
|
+
for (const e of input.evidence)
|
|
21
|
+
if (e.kind === 'not-applicable' &&
|
|
22
|
+
e.phase === phase &&
|
|
23
|
+
!e.consumer &&
|
|
24
|
+
sha !== undefined &&
|
|
25
|
+
e.sha === sha &&
|
|
26
|
+
required.includes(e.gate))
|
|
27
|
+
notApplicable.add(e.gate);
|
|
18
28
|
for (const e of input.evidence)
|
|
19
29
|
if (e.kind === 'test' &&
|
|
20
30
|
e.phase === phase &&
|
|
@@ -58,7 +68,10 @@ export function attemptView(input, options) {
|
|
|
58
68
|
required: required.length,
|
|
59
69
|
passed,
|
|
60
70
|
failed: latest.size - passed,
|
|
61
|
-
remaining: required.filter((g) => !latest.has(g)).length,
|
|
71
|
+
remaining: required.filter((g) => !latest.has(g) && !notApplicable.has(g)).length,
|
|
72
|
+
...(notApplicable.size
|
|
73
|
+
? { notApplicable: [...notApplicable].filter((g) => !latest.has(g)).length }
|
|
74
|
+
: {}),
|
|
62
75
|
},
|
|
63
76
|
...(input.liveness
|
|
64
77
|
? {
|
package/lib/report/compute.js
CHANGED
|
@@ -401,7 +401,8 @@ export function valueReport(input, options = {}) {
|
|
|
401
401
|
const defectAttempts = windowAttempts.filter((a) => failureBucketOf(a) === 'defect');
|
|
402
402
|
const failingOf = (a) => {
|
|
403
403
|
const kind = a.failureKind === 'gate' ? 'test' : a.failureKind === 'review' ? 'review' : null;
|
|
404
|
-
|
|
404
|
+
// Неприменимый gate (`when.paths`) не исполнялся и провалом не считается.
|
|
405
|
+
return a.evidence.filter((e) => !e.passed && e.kind !== 'not-applicable' && (kind === null || e.kind === kind));
|
|
405
406
|
};
|
|
406
407
|
const byKind = { gate: 0, review: 0, 'scope-violation': 0 };
|
|
407
408
|
const byPhase = { candidate: 0, integration: 0, unknown: 0 };
|
|
@@ -444,12 +445,12 @@ export function valueReport(input, options = {}) {
|
|
|
444
445
|
for (const e of a.evidence) {
|
|
445
446
|
if (e.kind !== 'review' || e.phase !== 'candidate')
|
|
446
447
|
continue;
|
|
447
|
-
|
|
448
|
+
// Неприменимый gate (`when.paths`) зелёного состава не нарушает.
|
|
449
|
+
const allGreen = required.every((g) => a.evidence.some((x) => (x.kind === 'not-applicable' || (x.kind === 'test' && x.passed)) &&
|
|
448
450
|
x.phase === 'candidate' &&
|
|
449
451
|
!x.consumer &&
|
|
450
452
|
x.gate === g &&
|
|
451
453
|
x.sha === e.sha &&
|
|
452
|
-
x.passed &&
|
|
453
454
|
(x.checks === undefined || e.checks === undefined || x.checks === e.checks)));
|
|
454
455
|
if (!allGreen)
|
|
455
456
|
continue;
|
|
@@ -478,7 +478,7 @@ export declare class DocumentView {
|
|
|
478
478
|
evidence: {
|
|
479
479
|
id: string;
|
|
480
480
|
runId: string;
|
|
481
|
-
kind: "review" | "test";
|
|
481
|
+
kind: "review" | "test" | "not-applicable";
|
|
482
482
|
phase: "candidate" | "integration";
|
|
483
483
|
sha: string;
|
|
484
484
|
gate: string;
|
|
@@ -634,6 +634,18 @@ export declare class DocumentView {
|
|
|
634
634
|
skippedMore?: number | undefined;
|
|
635
635
|
} | undefined;
|
|
636
636
|
checks?: string | undefined;
|
|
637
|
+
gateBasis?: string | undefined;
|
|
638
|
+
notApplicable?: {
|
|
639
|
+
gateDigest: string;
|
|
640
|
+
patterns: string[];
|
|
641
|
+
ranges: {
|
|
642
|
+
from: string;
|
|
643
|
+
to: string;
|
|
644
|
+
}[];
|
|
645
|
+
count: number;
|
|
646
|
+
files: string[];
|
|
647
|
+
pathsDigest: string;
|
|
648
|
+
} | undefined;
|
|
637
649
|
alreadySatisfied?: {
|
|
638
650
|
gates: string[];
|
|
639
651
|
evidence: string;
|
|
@@ -838,7 +850,7 @@ export declare class DocumentView {
|
|
|
838
850
|
evidence: {
|
|
839
851
|
id: string;
|
|
840
852
|
runId: string;
|
|
841
|
-
kind: "review" | "test";
|
|
853
|
+
kind: "review" | "test" | "not-applicable";
|
|
842
854
|
phase: "candidate" | "integration";
|
|
843
855
|
sha: string;
|
|
844
856
|
gate: string;
|
|
@@ -994,6 +1006,18 @@ export declare class DocumentView {
|
|
|
994
1006
|
skippedMore?: number | undefined;
|
|
995
1007
|
} | undefined;
|
|
996
1008
|
checks?: string | undefined;
|
|
1009
|
+
gateBasis?: string | undefined;
|
|
1010
|
+
notApplicable?: {
|
|
1011
|
+
gateDigest: string;
|
|
1012
|
+
patterns: string[];
|
|
1013
|
+
ranges: {
|
|
1014
|
+
from: string;
|
|
1015
|
+
to: string;
|
|
1016
|
+
}[];
|
|
1017
|
+
count: number;
|
|
1018
|
+
files: string[];
|
|
1019
|
+
pathsDigest: string;
|
|
1020
|
+
} | undefined;
|
|
997
1021
|
alreadySatisfied?: {
|
|
998
1022
|
gates: string[];
|
|
999
1023
|
evidence: string;
|
|
@@ -210,6 +210,18 @@ export declare const receiptTrust: {
|
|
|
210
210
|
readonly 'evidence[].summary': readonly ["informative", "описание записи"];
|
|
211
211
|
readonly 'evidence[].consumer': readonly ["expected", "объявленный потребитель"];
|
|
212
212
|
readonly 'evidence[].checks': readonly ["expected", "версия проверок, вычисленная получателем, у каждой записи"];
|
|
213
|
+
readonly 'evidence[].notApplicable': readonly ["consistency", "только у записи not-applicable: обычный gate с when, не доказательство и не предпосылка исполненного"];
|
|
214
|
+
readonly 'evidence[].notApplicable.gateDigest': readonly ["expected", "digest определения gate у получателя"];
|
|
215
|
+
readonly 'evidence[].notApplicable.patterns': readonly ["informative", "пути when; их задаёт определение gate"];
|
|
216
|
+
readonly 'evidence[].notApplicable.patterns[]': readonly ["informative", "пути when; их задаёт определение gate"];
|
|
217
|
+
readonly 'evidence[].notApplicable.ranges': readonly ["informative", "diff фазы — наблюдение Git исполнителя"];
|
|
218
|
+
readonly 'evidence[].notApplicable.ranges[]': readonly ["informative", "diff фазы — наблюдение Git исполнителя"];
|
|
219
|
+
readonly 'evidence[].notApplicable.ranges[].from': readonly ["informative", "diff фазы — наблюдение Git исполнителя"];
|
|
220
|
+
readonly 'evidence[].notApplicable.ranges[].to': readonly ["informative", "diff фазы — наблюдение Git исполнителя"];
|
|
221
|
+
readonly 'evidence[].notApplicable.count': readonly ["informative", "diff фазы — наблюдение Git исполнителя"];
|
|
222
|
+
readonly 'evidence[].notApplicable.files': readonly ["informative", "diff фазы — наблюдение Git исполнителя"];
|
|
223
|
+
readonly 'evidence[].notApplicable.files[]': readonly ["informative", "diff фазы — наблюдение Git исполнителя"];
|
|
224
|
+
readonly 'evidence[].notApplicable.pathsDigest': readonly ["informative", "diff фазы — наблюдение Git исполнителя"];
|
|
213
225
|
readonly 'evidence[].tests': readonly ["expected", "доказательство названного testcase решающей записью"];
|
|
214
226
|
readonly 'evidence[].tests[]': readonly ["expected", "элемент названного testcase; прочие элементы — сведения"];
|
|
215
227
|
readonly 'evidence[].tests[].id': readonly ["expected", "ID названного testcase"];
|
|
@@ -3,6 +3,7 @@ import { corpusBindingHolds, effectiveChecks, obligationOf, orderCheckManifest,
|
|
|
3
3
|
import { manifestDigest } from "./property.js";
|
|
4
4
|
import { unprovenReason } from "./proof.js";
|
|
5
5
|
import { REQUIREMENT_GATE } from "./requirements.js";
|
|
6
|
+
import { notApplicableProblem, proofGates } from "./applicability.js";
|
|
6
7
|
/** Решающая запись gate на фазе: последняя запись этой фазы, SHA и версии. */
|
|
7
8
|
function decisive(input, phase, gate) {
|
|
8
9
|
const sha = phase === 'candidate' ? input.candidateSha : input.resultSha;
|
|
@@ -236,6 +237,24 @@ export const receiptTrust = {
|
|
|
236
237
|
'evidence[].summary': ['informative', 'описание записи'],
|
|
237
238
|
'evidence[].consumer': ['expected', 'объявленный потребитель'],
|
|
238
239
|
'evidence[].checks': ['expected', 'версия проверок, вычисленная получателем, у каждой записи'],
|
|
240
|
+
'evidence[].notApplicable': [
|
|
241
|
+
'consistency',
|
|
242
|
+
'только у записи not-applicable: обычный gate с when, не доказательство и не предпосылка исполненного',
|
|
243
|
+
],
|
|
244
|
+
'evidence[].notApplicable.gateDigest': ['expected', 'digest определения gate у получателя'],
|
|
245
|
+
'evidence[].notApplicable.patterns': ['informative', 'пути when; их задаёт определение gate'],
|
|
246
|
+
'evidence[].notApplicable.patterns[]': ['informative', 'пути when; их задаёт определение gate'],
|
|
247
|
+
'evidence[].notApplicable.ranges': ['informative', 'diff фазы — наблюдение Git исполнителя'],
|
|
248
|
+
'evidence[].notApplicable.ranges[]': ['informative', 'diff фазы — наблюдение Git исполнителя'],
|
|
249
|
+
'evidence[].notApplicable.ranges[].from': [
|
|
250
|
+
'informative',
|
|
251
|
+
'diff фазы — наблюдение Git исполнителя',
|
|
252
|
+
],
|
|
253
|
+
'evidence[].notApplicable.ranges[].to': ['informative', 'diff фазы — наблюдение Git исполнителя'],
|
|
254
|
+
'evidence[].notApplicable.count': ['informative', 'diff фазы — наблюдение Git исполнителя'],
|
|
255
|
+
'evidence[].notApplicable.files': ['informative', 'diff фазы — наблюдение Git исполнителя'],
|
|
256
|
+
'evidence[].notApplicable.files[]': ['informative', 'diff фазы — наблюдение Git исполнителя'],
|
|
257
|
+
'evidence[].notApplicable.pathsDigest': ['informative', 'diff фазы — наблюдение Git исполнителя'],
|
|
239
258
|
'evidence[].tests': ['expected', 'доказательство названного testcase решающей записью'],
|
|
240
259
|
'evidence[].tests[]': ['expected', 'элемент названного testcase; прочие элементы — сведения'],
|
|
241
260
|
'evidence[].tests[].id': ['expected', 'ID названного testcase'],
|
|
@@ -415,13 +434,25 @@ export function resultProblems(result, context) {
|
|
|
415
434
|
integrity.push(`запись ${e.id}: сведения о свойствах недопустимы у записи вида ${e.kind}`);
|
|
416
435
|
if ((e.reviewer !== undefined) !== (e.kind === 'review'))
|
|
417
436
|
integrity.push(`запись ${e.id}: сведения о reviewer не согласованы с видом записи`);
|
|
437
|
+
if ((e.notApplicable !== undefined) !== (e.kind === 'not-applicable'))
|
|
438
|
+
integrity.push(`запись ${e.id}: сведения о неприменимости не согласованы с видом записи`);
|
|
439
|
+
if (e.kind === 'not-applicable' && (e.passed || e.consumer !== undefined))
|
|
440
|
+
integrity.push(`запись ${e.id}: неприменимый gate не бывает PASS или проверкой потребителя`);
|
|
418
441
|
}
|
|
419
442
|
if (integrity.length)
|
|
420
443
|
return integrity;
|
|
421
444
|
const evidence = result.evidence
|
|
422
|
-
.filter((e) => e.kind === 'test' ||
|
|
445
|
+
.filter((e) => e.kind === 'test' ||
|
|
446
|
+
e.kind === 'review' ||
|
|
447
|
+
e.kind === 'consumer' ||
|
|
448
|
+
e.kind === 'not-applicable')
|
|
423
449
|
.map((e) => ({
|
|
424
|
-
kind: e.kind === 'review'
|
|
450
|
+
kind: e.kind === 'review'
|
|
451
|
+
? 'review'
|
|
452
|
+
: e.kind === 'not-applicable'
|
|
453
|
+
? 'not-applicable'
|
|
454
|
+
: 'test',
|
|
455
|
+
...(e.notApplicable ? { notApplicable: e.notApplicable } : {}),
|
|
425
456
|
phase: e.phase,
|
|
426
457
|
gate: e.gate,
|
|
427
458
|
sha: e.sha,
|
|
@@ -432,7 +463,7 @@ export function resultProblems(result, context) {
|
|
|
432
463
|
tests: e.tests,
|
|
433
464
|
testsTruncated: e.testsTruncated,
|
|
434
465
|
}));
|
|
435
|
-
const last = (kind, phase, gate, consumer) => evidence.findLast((e) => e.kind === kind &&
|
|
466
|
+
const last = (kind, phase, gate, consumer) => evidence.findLast((e) => (typeof kind === 'string' ? e.kind === kind : kind.includes(e.kind)) &&
|
|
436
467
|
e.phase === phase &&
|
|
437
468
|
e.gate === gate &&
|
|
438
469
|
e.sha === sha(phase) &&
|
|
@@ -457,13 +488,37 @@ export function resultProblems(result, context) {
|
|
|
457
488
|
if (declared && !sameSet(declared, own))
|
|
458
489
|
problems.push(`область результата [${declared.join(', ')}] — ожидалась ровно [${own.join(', ')}]`);
|
|
459
490
|
const required = [...new Set([...own, ...(gates.byGate?.keys() ?? [])])];
|
|
491
|
+
// Обычный gate с `when` закрывается и записью неприменимости
|
|
492
|
+
// (`notApplicableProblem` по политике получателя); доказательства
|
|
493
|
+
// требований и договоров — только PASS.
|
|
494
|
+
const named = proofGates(order, context.contracts);
|
|
460
495
|
const decisiveAll = ['candidate', 'integration'].flatMap((phase) => [
|
|
461
|
-
...required.map((gate) => ({
|
|
496
|
+
...required.map((gate) => ({
|
|
497
|
+
phase,
|
|
498
|
+
gate,
|
|
499
|
+
// Исход исполнения решает всегда; неприменимость — только без него.
|
|
500
|
+
check: last('test', phase, gate) ??
|
|
501
|
+
(named.has(gate) ? undefined : last(['not-applicable'], phase, gate)),
|
|
502
|
+
})),
|
|
462
503
|
{ phase, gate: 'independent-review', check: last('review', phase, 'independent-review') },
|
|
463
504
|
]);
|
|
464
|
-
for (const { phase, gate, check } of decisiveAll)
|
|
465
|
-
if (
|
|
466
|
-
|
|
505
|
+
for (const { phase, gate, check } of decisiveAll) {
|
|
506
|
+
if (check?.passed)
|
|
507
|
+
continue;
|
|
508
|
+
const problem = check?.kind === 'not-applicable'
|
|
509
|
+
? notApplicableProblem({
|
|
510
|
+
gates: repo.gates,
|
|
511
|
+
gate,
|
|
512
|
+
record: check,
|
|
513
|
+
proof: named,
|
|
514
|
+
ran: decisiveAll
|
|
515
|
+
.filter((d) => d.phase === phase && d.check?.kind === 'test')
|
|
516
|
+
.map((d) => d.gate),
|
|
517
|
+
})
|
|
518
|
+
: 'нет записи';
|
|
519
|
+
if (problem)
|
|
520
|
+
problems.push(`Нет PASS: ${phase}/${gate}` + (check?.kind === 'not-applicable' ? ': ' + problem : ''));
|
|
521
|
+
}
|
|
467
522
|
// Ревью: writer — роли поручения в политике получателя; reviewer решающих
|
|
468
523
|
// записей обеих фаз — тот, кого политика назначает этому writer, и правило
|
|
469
524
|
// вендора соблюдено (тот же вендор — только явным разрешением). Для
|