@juicesharp/rpiv-pi 2.9.0 → 2.10.0
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/extensions/rpiv-core/artifact-collector.ts +30 -7
- package/extensions/rpiv-core/built-in-workflows.ts +222 -70
- package/extensions/rpiv-core/built-ins/citations.ts +9 -0
- package/extensions/rpiv-core/built-ins/design.ts +64 -0
- package/extensions/rpiv-core/built-ins/elaboration.ts +53 -0
- package/extensions/rpiv-core/built-ins/gates.ts +282 -12
- package/extensions/rpiv-core/built-ins/grade-panel.ts +54 -26
- package/extensions/rpiv-core/built-ins/index.ts +20 -1
- package/extensions/rpiv-core/built-ins/markdown-fence.ts +26 -1
- package/extensions/rpiv-core/built-ins/plan-phases.ts +8 -0
- package/extensions/rpiv-core/built-ins/priors.ts +9 -2
- package/extensions/rpiv-core/built-ins/remediation.ts +60 -7
- package/extensions/rpiv-core/built-ins/scope-checks.ts +74 -11
- package/extensions/rpiv-core/built-ins/shared.ts +5 -3
- package/extensions/rpiv-core/built-ins/slice-checks.ts +164 -28
- package/extensions/rpiv-core/built-ins/slices.ts +44 -13
- package/extensions/rpiv-core/built-ins/verdict-collector.ts +207 -0
- package/extensions/rpiv-core/built-ins/verdict-outcome.ts +36 -0
- package/extensions/rpiv-core/lane-list.ts +10 -1
- package/extensions/rpiv-core/lane-progress.ts +1 -1
- package/extensions/rpiv-core/lane-usage.ts +1 -1
- package/extensions/rpiv-core/models-picker.ts +4 -3
- package/extensions/rpiv-core/run-lane-registry.ts +1 -2
- package/extensions/rpiv-core/sdk-workflow-host.ts +20 -4
- package/extensions/rpiv-core/session-hooks.ts +1 -1
- package/package.json +4 -3
- package/skills/_shared/stitch-elaborations.mjs +282 -21
- package/skills/acceptance/SKILL.md +3 -2
- package/skills/amend/SKILL.md +5 -5
- package/skills/design-slice/SKILL.md +5 -0
- package/skills/elaborate/SKILL.md +10 -3
- package/skills/grade/SKILL.md +13 -10
- package/skills/validate/SKILL.md +14 -0
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
* re-export targets a `.js` specifier (Node16 ESM, source stays `.ts`).
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
export { designOutcome, designParser, designStructure } from "./design.js";
|
|
8
|
+
export { elaborationOutcome, elaborationParser, elaborationStructure } from "./elaboration.js";
|
|
7
9
|
export {
|
|
8
10
|
allDimensionsPass,
|
|
9
11
|
anchorNitsOnly,
|
|
@@ -13,13 +15,23 @@ export {
|
|
|
13
15
|
latestArtifactPath,
|
|
14
16
|
latestVerdictPerDimension,
|
|
15
17
|
PLAN_DIMENSIONS,
|
|
18
|
+
panelProgress,
|
|
16
19
|
planAuthoredRisks,
|
|
17
20
|
planGatePasses,
|
|
21
|
+
progressFromRoundCounts,
|
|
18
22
|
rulingEffectivePass,
|
|
23
|
+
type SeedOnlyVerdict,
|
|
19
24
|
SHIP_DIMENSIONS,
|
|
25
|
+
SLICE_DIMENSIONS,
|
|
26
|
+
seedLiftStuck,
|
|
27
|
+
seedOnlyCiteFail,
|
|
28
|
+
seedOnlyFindings,
|
|
20
29
|
shipGatePasses,
|
|
21
30
|
sliceGatePasses,
|
|
22
31
|
subplanGatePasses,
|
|
32
|
+
unitFailedDimensions,
|
|
33
|
+
type VerdictRecord,
|
|
34
|
+
verdictBlocks,
|
|
23
35
|
verdictRiskRulings,
|
|
24
36
|
} from "./gates.js";
|
|
25
37
|
export {
|
|
@@ -31,10 +43,14 @@ export {
|
|
|
31
43
|
export {
|
|
32
44
|
CODE_CONFIRM_FANOUT,
|
|
33
45
|
CODE_DIMENSION_FANOUT,
|
|
46
|
+
CODE_PANEL_PROGRESS,
|
|
34
47
|
PLAN_CONFIRM_FANOUT,
|
|
35
48
|
PLAN_DIMENSION_FANOUT,
|
|
49
|
+
PLAN_PANEL_PROGRESS,
|
|
36
50
|
SHIP_DIMENSION_FANOUT,
|
|
51
|
+
SHIP_PANEL_PROGRESS,
|
|
37
52
|
SLICE_DIMENSION_FANOUT,
|
|
53
|
+
SLICE_PANEL_PROGRESS,
|
|
38
54
|
shipVerdictOutcome,
|
|
39
55
|
} from "./grade-panel.js";
|
|
40
56
|
export {
|
|
@@ -43,9 +59,11 @@ export {
|
|
|
43
59
|
FENCE_LINE_RE,
|
|
44
60
|
fencedSpans,
|
|
45
61
|
forEachLineOutsideFences,
|
|
62
|
+
openFenceLine,
|
|
46
63
|
} from "./markdown-fence.js";
|
|
47
64
|
export { planCitationCheck } from "./plan-cite.js";
|
|
48
65
|
export {
|
|
66
|
+
ELABORATE_PHASE_FANOUT,
|
|
49
67
|
FRONTMATTER_PHASE_FANOUT,
|
|
50
68
|
IMPLEMENT_DAG_FANOUT,
|
|
51
69
|
IMPLEMENT_PLANS_FANOUT,
|
|
@@ -71,5 +89,6 @@ export {
|
|
|
71
89
|
VERDICT_PASS_SCORE,
|
|
72
90
|
writeStructureVerdict,
|
|
73
91
|
} from "./shared.js";
|
|
74
|
-
export { sliceStructureCheck, subplanCoverageCheck } from "./slice-checks.js";
|
|
92
|
+
export { sliceSeedLift, sliceStructureCheck, subplanCoverageCheck } from "./slice-checks.js";
|
|
75
93
|
export { SLICE_DESIGN_FANOUT, SYNTH_CLUSTER_FANOUT } from "./slices.js";
|
|
94
|
+
export { verdictOutcome } from "./verdict-outcome.js";
|
|
@@ -105,4 +105,29 @@ const fencedSpans = (content: string): [number, number][] => {
|
|
|
105
105
|
return spans;
|
|
106
106
|
};
|
|
107
107
|
|
|
108
|
-
|
|
108
|
+
/**
|
|
109
|
+
* 1-based line of a fence opener that never closes, or `undefined` when every
|
|
110
|
+
* fence is balanced. Same walk as `fencedSpans`, reported as the one number an
|
|
111
|
+
* author needs to fix the leak.
|
|
112
|
+
*/
|
|
113
|
+
const openFenceLine = (content: string): number | undefined => {
|
|
114
|
+
let inFence = false;
|
|
115
|
+
let fenceLen = 0;
|
|
116
|
+
let fenceChar = "";
|
|
117
|
+
let opened = 0;
|
|
118
|
+
content.split("\n").forEach((line, index) => {
|
|
119
|
+
const fence = FENCE_LINE_RE.exec(line);
|
|
120
|
+
if (!fence) return;
|
|
121
|
+
if (!inFence) {
|
|
122
|
+
inFence = true;
|
|
123
|
+
fenceLen = fence[1].length;
|
|
124
|
+
fenceChar = fence[1][0];
|
|
125
|
+
opened = index + 1;
|
|
126
|
+
} else if (closesFence(line, fence, fenceChar, fenceLen)) {
|
|
127
|
+
inFence = false;
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
return inFence ? opened : undefined;
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
export { closesFence, countHeadingsOutsideFences, FENCE_LINE_RE, fencedSpans, forEachLineOutsideFences, openFenceLine };
|
|
@@ -138,6 +138,13 @@ const FRONTMATTER_PHASE_FANOUT = fanout({
|
|
|
138
138
|
},
|
|
139
139
|
});
|
|
140
140
|
|
|
141
|
+
/**
|
|
142
|
+
* The elaborate fanout: `FRONTMATTER_PHASE_FANOUT` with one re-dispatch for a
|
|
143
|
+
* unit whose output failed its contract after the in-session retries — a
|
|
144
|
+
* malformed section is re-produced with the failure memo, not stitched.
|
|
145
|
+
*/
|
|
146
|
+
const ELABORATE_PHASE_FANOUT = { ...FRONTMATTER_PHASE_FANOUT, retryHaltedUnits: 1 };
|
|
147
|
+
|
|
141
148
|
/**
|
|
142
149
|
* Derive the directed `deps` edges for ONE implement phase under the dep-gated
|
|
143
150
|
* DAG fanout (`IMPLEMENT_DAG_FANOUT`). Edges point strictly downward (toward
|
|
@@ -412,6 +419,7 @@ const PLANS_PHASE_FANOUT = fanout({
|
|
|
412
419
|
const IMPLEMENT_PLANS_FANOUT = { ...PLANS_PHASE_FANOUT, concurrency: 1 };
|
|
413
420
|
|
|
414
421
|
export {
|
|
422
|
+
ELABORATE_PHASE_FANOUT,
|
|
415
423
|
FRONTMATTER_PHASE_FANOUT,
|
|
416
424
|
IMPLEMENT_DAG_FANOUT,
|
|
417
425
|
IMPLEMENT_PLANS_FANOUT,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* surgical-fix guard, and the risk-duty demotion stamp.
|
|
4
4
|
*/
|
|
5
5
|
import { copyFileSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
6
|
-
import { basename, isAbsolute, join } from "node:path";
|
|
6
|
+
import { basename, extname, isAbsolute, join } from "node:path";
|
|
7
7
|
import {
|
|
8
8
|
type Artifact,
|
|
9
9
|
handleToString,
|
|
@@ -47,9 +47,16 @@ const snapshotLatestPlan =
|
|
|
47
47
|
);
|
|
48
48
|
}
|
|
49
49
|
const src = isAbsolute(latest.handle.path) ? latest.handle.path : join(cwd, latest.handle.path);
|
|
50
|
-
|
|
50
|
+
// One file per round, so a resume replaying an earlier round reads that
|
|
51
|
+
// round's bytes, not the newest copy. The basename-keyed file is still
|
|
52
|
+
// written for readers that key on it.
|
|
53
|
+
const round = (state.named[who]?.length ?? 0) + 1;
|
|
54
|
+
const base = basename(latest.handle.path);
|
|
55
|
+
const ext = extname(base);
|
|
56
|
+
const priorRel = join(PRIOR_DIR, `${base.slice(0, base.length - ext.length)}.r${round}${ext}`);
|
|
51
57
|
mkdirSync(join(cwd, PRIOR_DIR), { recursive: true });
|
|
52
58
|
copyFileSync(src, join(cwd, priorRel));
|
|
59
|
+
copyFileSync(src, join(cwd, PRIOR_DIR, base));
|
|
53
60
|
return {
|
|
54
61
|
kind: "artifact-md",
|
|
55
62
|
artifacts: [{ handle: { kind: "fs", path: priorRel }, role: "prior" }],
|
|
@@ -12,12 +12,20 @@
|
|
|
12
12
|
* recompute after, and publish `{ changed }` on the `remediation` channel for
|
|
13
13
|
* the `validate-fix` route to fold.
|
|
14
14
|
*
|
|
15
|
-
* Git-only (status --porcelain + diff HEAD
|
|
16
|
-
* `computeWorktreeDigest`, which also hashes
|
|
17
|
-
* contractually forbidden from writing
|
|
18
|
-
* timestamped report every lap, so the
|
|
19
|
-
* verdict on churn that is not a code
|
|
20
|
-
* the same staged-content reason the
|
|
15
|
+
* Git-only (status --porcelain + diff HEAD + untracked content) —
|
|
16
|
+
* deliberately NOT the runner's `computeWorktreeDigest`, which also hashes
|
|
17
|
+
* `.rpiv/artifacts/`: remediate is contractually forbidden from writing
|
|
18
|
+
* artifacts, and validate writes a new timestamped report every lap, so the
|
|
19
|
+
* artifacts component would flip the verdict on churn that is not a code
|
|
20
|
+
* fix. `diff HEAD` (not bare `diff`) for the same staged-content reason the
|
|
21
|
+
* runner's digest documents. The third component hashes every untracked,
|
|
22
|
+
* non-ignored file's content: status porcelain lists a NEW untracked path
|
|
23
|
+
* but never a byte mutation inside an already-untracked file, so a repair
|
|
24
|
+
* confined to files that were already untracked would read as a no-op and
|
|
25
|
+
* re-enter the identical-lap loop. Untracked content under `.rpiv/` is
|
|
26
|
+
* excluded from that component deterministically — a whole-prefix filter,
|
|
27
|
+
* never a gitignore trust: that tree root is engine-owned pipeline
|
|
28
|
+
* bookkeeping (reports, run trails, scratch), never the code under repair.
|
|
21
29
|
*
|
|
22
30
|
* Degrade posture mirrors worktree-digest.ts: an `undefined` digest on either
|
|
23
31
|
* side (non-repo / git missing / timeout) reports `changed: true` — a missing
|
|
@@ -26,6 +34,8 @@
|
|
|
26
34
|
|
|
27
35
|
import { execFileSync } from "node:child_process";
|
|
28
36
|
import { createHash } from "node:crypto";
|
|
37
|
+
import { readFileSync } from "node:fs";
|
|
38
|
+
import { join } from "node:path";
|
|
29
39
|
import {
|
|
30
40
|
type Artifact,
|
|
31
41
|
type CollectContext,
|
|
@@ -39,6 +49,42 @@ import {
|
|
|
39
49
|
* on expiry the throw degrades to `undefined` (proceed). */
|
|
40
50
|
const GIT_DIGEST_TIMEOUT_MS = 10_000;
|
|
41
51
|
|
|
52
|
+
/** Engine-owned tree root — everything under `.rpiv/` is pipeline bookkeeping
|
|
53
|
+
* (validation reports, run trails, scratch), never the code under repair.
|
|
54
|
+
* Excluded from the untracked component deterministically via this
|
|
55
|
+
* whole-prefix filter, NOT via gitignore trust: a repo's ignore file is user
|
|
56
|
+
* state the digest must never depend on. */
|
|
57
|
+
const UNTRACKED_EXCLUDED_PREFIX = ".rpiv/";
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Content hash over the untracked, non-ignored, non-excluded tree. `rawZ` is
|
|
61
|
+
* `git ls-files --others --exclude-standard -z` output: NUL-separated
|
|
62
|
+
* repo-relative forward-slash paths. Surviving paths are sorted (JS code-unit
|
|
63
|
+
* sort, mirroring the artifacts walker) so enumeration order never feeds the
|
|
64
|
+
* hash, and each path is hashed verbatim in git's repo-relative form — never
|
|
65
|
+
* `join()`-reconstructed. An unreadable file (raced delete) hashes the stable
|
|
66
|
+
* `"<unreadable>"` token; the helper never throws. An empty surviving set
|
|
67
|
+
* hashes to the sha256 of nothing — a stable constant.
|
|
68
|
+
*/
|
|
69
|
+
const hashUntrackedTree = (cwd: string, rawZ: string): string => {
|
|
70
|
+
const hash = createHash("sha256");
|
|
71
|
+
const paths = rawZ
|
|
72
|
+
.split("\0")
|
|
73
|
+
.filter((p) => p !== "" && !p.startsWith(UNTRACKED_EXCLUDED_PREFIX))
|
|
74
|
+
.sort();
|
|
75
|
+
for (const path of paths) {
|
|
76
|
+
hash.update(path);
|
|
77
|
+
hash.update("\0");
|
|
78
|
+
try {
|
|
79
|
+
hash.update(readFileSync(join(cwd, path)));
|
|
80
|
+
} catch {
|
|
81
|
+
hash.update("<unreadable>");
|
|
82
|
+
}
|
|
83
|
+
hash.update("\0");
|
|
84
|
+
}
|
|
85
|
+
return hash.digest("hex");
|
|
86
|
+
};
|
|
87
|
+
|
|
42
88
|
/**
|
|
43
89
|
* Git-only content fingerprint of `cwd`'s working tree. Returns `undefined`
|
|
44
90
|
* on ANY failure so callers degrade to "proceed", never "stop".
|
|
@@ -53,7 +99,14 @@ export const gitTreeDigest = (cwd: string): string | undefined => {
|
|
|
53
99
|
};
|
|
54
100
|
const status = execFileSync("git", ["status", "--porcelain"], opts);
|
|
55
101
|
const diff = execFileSync("git", ["diff", "HEAD"], opts);
|
|
56
|
-
|
|
102
|
+
const untracked = execFileSync("git", ["ls-files", "--others", "--exclude-standard", "-z"], opts);
|
|
103
|
+
return createHash("sha256")
|
|
104
|
+
.update(status)
|
|
105
|
+
.update("\0")
|
|
106
|
+
.update(diff)
|
|
107
|
+
.update("\0")
|
|
108
|
+
.update(hashUntrackedTree(cwd, untracked))
|
|
109
|
+
.digest("hex");
|
|
57
110
|
} catch {
|
|
58
111
|
return undefined;
|
|
59
112
|
}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The lane scope floors: build's latest-plan variant and vet's full-history
|
|
3
3
|
* union variant, sharing one scope-verdict envelope — plus the deterministic
|
|
4
|
-
* `scope-quarantine` remedy arm the untracked-only verdict routes to.
|
|
4
|
+
* `scope-quarantine` remedy arm the untracked-only verdict routes to. Build
|
|
5
|
+
* and ship's variant additionally accepts validate-report-named writes on a
|
|
6
|
+
* validate-fix re-entry (vet's graph has no remediation writer to
|
|
7
|
+
* discriminate, so its union twin carries no acceptance arm).
|
|
5
8
|
*/
|
|
6
9
|
import { mkdirSync, renameSync, writeFileSync } from "node:fs";
|
|
7
10
|
import { basename, dirname, join } from "node:path";
|
|
8
|
-
import { handleToString, type Output, type ScriptContext } from "@juicesharp/rpiv-workflow/registration";
|
|
11
|
+
import { handleToString, type Output, type RunView, type ScriptContext } from "@juicesharp/rpiv-workflow/registration";
|
|
9
12
|
import { gitDirtyEntries, goalBaselinePath, readGoalBaseline, scopeExcess } from "./goal-baseline.js";
|
|
10
13
|
import { phaseFiles, planPhaseRecords, withTestTwins } from "./plan-phases.js";
|
|
11
14
|
import {
|
|
@@ -96,26 +99,35 @@ type ScopeVerdict = "pass" | "untracked-only" | "excess";
|
|
|
96
99
|
* NOT round-stamped (unlike grade's timestamped slug): each fix-loop round
|
|
97
100
|
* overwrites the file — the route reads the accumulating channel, and on disk
|
|
98
101
|
* only the latest round's scope verdict matters; round-stamp here if a consumer
|
|
99
|
-
* ever needs the history. Severity mirrors the tier ("
|
|
100
|
-
* "high" tracked excess) for TRAIL LEGIBILITY ONLY —
|
|
101
|
-
* routing reads `verdict`, and validate's adjudication
|
|
102
|
+
* ever needs the history. Severity mirrors the tier ("low" all-advisory,
|
|
103
|
+
* "medium" untracked-only, "high" tracked excess) for TRAIL LEGIBILITY ONLY —
|
|
104
|
+
* no consumer folds it: routing reads `verdict`, and validate's adjudication
|
|
105
|
+
* reads `findings`. The advisory tier is DORMANT at this writer's call sites
|
|
106
|
+
* (`scopeFinding` emits no `advisory` key) — the contract is encoded for the
|
|
107
|
+
* day one is. The optional `acceptance` param stamps `declaredBy`/`accepted`
|
|
108
|
+
* onto the envelope ONLY when a validate-report acceptance declared them
|
|
109
|
+
* (key-omission idiom — every uninformed emission omits both, so the persisted
|
|
110
|
+
* JSON stays byte-identical to the pre-widening shape).
|
|
102
111
|
*/
|
|
103
112
|
const writeScopeVerdict = (
|
|
104
113
|
artifact: FsArtifact,
|
|
105
|
-
findings: { detail: string; where: string }[],
|
|
114
|
+
findings: { detail: string; where: string; advisory?: true }[],
|
|
106
115
|
verdict: ScopeVerdict,
|
|
107
116
|
cwd: string,
|
|
117
|
+
acceptance?: { declaredBy: string | null; accepted: string[] },
|
|
108
118
|
): Omit<Output, "meta"> => {
|
|
109
119
|
const pass = verdict === "pass";
|
|
120
|
+
const advisoryOnly = findings.length > 0 && findings.every((f) => f.advisory === true);
|
|
110
121
|
const data = {
|
|
111
122
|
dimension: "scope",
|
|
112
123
|
pass,
|
|
113
124
|
verdict,
|
|
114
|
-
score: pass ? VERDICT_PASS_SCORE : VERDICT_FAIL_SCORE,
|
|
115
|
-
severity: pass ? "none" : verdict === "untracked-only" ? "medium" : "high",
|
|
125
|
+
score: pass ? VERDICT_PASS_SCORE : advisoryOnly ? null : VERDICT_FAIL_SCORE,
|
|
126
|
+
severity: pass ? "none" : advisoryOnly ? "low" : verdict === "untracked-only" ? "medium" : "high",
|
|
116
127
|
artifact: handleToString(artifact.handle),
|
|
117
128
|
findings,
|
|
118
129
|
feedback: pass ? "" : findings.map((f) => f.detail).join(" "),
|
|
130
|
+
...(acceptance?.declaredBy ? { declaredBy: acceptance.declaredBy, accepted: acceptance.accepted } : {}),
|
|
119
131
|
};
|
|
120
132
|
const rel = join(VERDICT_DIR, `implement-scope-check__${basename(artifact.handle.path, ".md")}.json`);
|
|
121
133
|
mkdirSync(join(cwd, VERDICT_DIR), { recursive: true });
|
|
@@ -152,6 +164,45 @@ const scopeFinding = (path: string, untracked: boolean): { detail: string; where
|
|
|
152
164
|
where: path,
|
|
153
165
|
});
|
|
154
166
|
|
|
167
|
+
/**
|
|
168
|
+
* Validate-report scope acceptance: the `file:` paths the latest validation
|
|
169
|
+
* report's structured `blockers:` entries name, credited ONLY on a
|
|
170
|
+
* validate-fix re-entry — the latest `remediation` digest row must EXIST and
|
|
171
|
+
* STRICTLY postdate the failing report (`meta.ts` strings compare
|
|
172
|
+
* lexicographically, the ISO-8601 idiom), and the report's `data.blockers`
|
|
173
|
+
* must be an array. Remediate is the one tree writer a plan cannot declare
|
|
174
|
+
* (the plan predates the report), so on exactly that hop the floor accepts
|
|
175
|
+
* the blocker-named writes as declared scope.
|
|
176
|
+
*
|
|
177
|
+
* Fail-closed by construction — the first entry (no remediation row), a
|
|
178
|
+
* quarantine re-entry (no postdating remediation), and a re-validation
|
|
179
|
+
* report NEWER than the remediation all
|
|
180
|
+
* refuse. Blocker entries are read literally, never coerced (a non-string
|
|
181
|
+
* `file` contributes nothing), and accepted paths are repo-relative
|
|
182
|
+
* forward-slash strings matched VERBATIM against the dirty set — no twin
|
|
183
|
+
* expansion, no recursion: the engine accepts exactly the strings the report
|
|
184
|
+
* names, and a drifted spelling simply fails to accept (the path stays a
|
|
185
|
+
* finding for validate to adjudicate exactly as before). Reads defensively
|
|
186
|
+
* off `state.named` — the stage's `reads` deliberately omits these channels
|
|
187
|
+
* (a declared read would halt the first, pre-validate entry).
|
|
188
|
+
*/
|
|
189
|
+
const validateReportAcceptance = (state: RunView): { declaredBy: "validate-report" | null; accepted: string[] } => {
|
|
190
|
+
const remediationTs = state.named.remediation?.at(-1)?.meta?.ts;
|
|
191
|
+
const validation = state.named.validation?.at(-1);
|
|
192
|
+
const validationTs = validation?.meta?.ts;
|
|
193
|
+
if (typeof remediationTs !== "string" || typeof validationTs !== "string" || remediationTs <= validationTs) {
|
|
194
|
+
return { declaredBy: null, accepted: [] };
|
|
195
|
+
}
|
|
196
|
+
const blockers = (validation?.data as { blockers?: unknown } | undefined)?.blockers;
|
|
197
|
+
if (!Array.isArray(blockers)) return { declaredBy: null, accepted: [] };
|
|
198
|
+
const files = new Set<string>();
|
|
199
|
+
for (const blocker of blockers) {
|
|
200
|
+
const file = (blocker as { file?: unknown } | null)?.file;
|
|
201
|
+
if (typeof file === "string") files.add(file);
|
|
202
|
+
}
|
|
203
|
+
return { declaredBy: "validate-report", accepted: [...files].sort() };
|
|
204
|
+
};
|
|
205
|
+
|
|
155
206
|
/**
|
|
156
207
|
* Deterministic lane-level scope floor — the structural backstop beneath the
|
|
157
208
|
* LLM quality gates. After build's `implement` lane runs (now dep-gated and, as
|
|
@@ -189,6 +240,14 @@ const scopeFinding = (path: string, untracked: boolean): { detail: string; where
|
|
|
189
240
|
* never inferred from severity. `readsData: false` (the route consults the
|
|
190
241
|
* channel, not the projected output), so no schema is declared on the script
|
|
191
242
|
* stage (matching `slice-check`/`plan-cite-check`).
|
|
243
|
+
*
|
|
244
|
+
* On a validate-fix re-entry the floor additionally ACCEPTS dirty paths the
|
|
245
|
+
* latest validation report's `blockers:` entries name (see
|
|
246
|
+
* `validateReportAcceptance`): remediate is the one tree writer a plan
|
|
247
|
+
* cannot declare (the plan predates the report), and its digest row
|
|
248
|
+
* postdating the report witnesses the targeted fix. The accepted paths fold
|
|
249
|
+
* into `scopeExcess`'s declared argument — a blocker-named dirty path
|
|
250
|
+
* generates no finding and never rides `--scope` into validate.
|
|
192
251
|
*/
|
|
193
252
|
const implementScopeCheck = ({ state, cwd }: ScriptContext): Omit<Output, "meta"> => {
|
|
194
253
|
const latest = latestFsArtifact(state, "plans");
|
|
@@ -212,14 +271,18 @@ const implementScopeCheck = ({ state, cwd }: ScriptContext): Omit<Output, "meta"
|
|
|
212
271
|
const baseline = readGoalBaseline(goalBaselinePath(state), cwd);
|
|
213
272
|
const entries = gitDirtyEntries(cwd);
|
|
214
273
|
|
|
274
|
+
// Validate-report acceptance (fail-closed): on the validate-fix re-entry
|
|
275
|
+
// the report's blocker-named paths join the declared set; refused ⇒
|
|
276
|
+
// `accepted` is `[]` ⇒ the union is `declared` verbatim (inert).
|
|
277
|
+
const acceptance = validateReportAcceptance(state);
|
|
215
278
|
const excess = scopeExcess(
|
|
216
279
|
entries.map((e) => e.path),
|
|
217
280
|
baseline,
|
|
218
|
-
declared,
|
|
281
|
+
[...declared, ...acceptance.accepted],
|
|
219
282
|
);
|
|
220
283
|
const untracked = new Set(entries.filter((e) => e.xy === "??").map((e) => e.path));
|
|
221
284
|
const findings = excess.map((path) => scopeFinding(path, untracked.has(path)));
|
|
222
|
-
return writeScopeVerdict(latest as FsArtifact, findings, foldScopeVerdict(excess, untracked), cwd);
|
|
285
|
+
return writeScopeVerdict(latest as FsArtifact, findings, foldScopeVerdict(excess, untracked), cwd, acceptance);
|
|
223
286
|
};
|
|
224
287
|
|
|
225
288
|
/**
|
|
@@ -375,4 +438,4 @@ const scopeQuarantine = ({ state, cwd }: ScriptContext): Omit<Output, "meta"> =>
|
|
|
375
438
|
};
|
|
376
439
|
|
|
377
440
|
export type { ScopeVerdict };
|
|
378
|
-
export { implementScopeCheck, implementScopeCheckVet, scopeQuarantine };
|
|
441
|
+
export { implementScopeCheck, implementScopeCheckVet, scopeQuarantine, writeScopeVerdict };
|
|
@@ -103,8 +103,10 @@ type FsHandle = { kind: "fs"; path: string };
|
|
|
103
103
|
* whose findings are ALL `advisory` rates `low` — honest (`pass: false`, the
|
|
104
104
|
* findings persist on the trail and downstream readers see them) but
|
|
105
105
|
* deliberately below the gate floor, so a resolver limitation never terminates
|
|
106
|
-
* a loop-less preset. The `score`
|
|
107
|
-
* 0 =
|
|
106
|
+
* a loop-less preset. The `score` mirrors that tier (100 = clean,
|
|
107
|
+
* 0 = at least one BLOCKING finding, `null` = an all-advisory non-pass — an
|
|
108
|
+
* honest null, never a fake zero; the gate keys off `severity`, never this
|
|
109
|
+
* number).
|
|
108
110
|
*
|
|
109
111
|
* `extra` lets a caller stamp additional gate-readable fields onto the verdict
|
|
110
112
|
* data (and the persisted JSON, so the trail records them) — currently only
|
|
@@ -122,7 +124,7 @@ const writeStructureVerdict = (
|
|
|
122
124
|
const data = {
|
|
123
125
|
dimension: "structure",
|
|
124
126
|
pass,
|
|
125
|
-
score: pass ? VERDICT_PASS_SCORE : VERDICT_FAIL_SCORE,
|
|
127
|
+
score: pass ? VERDICT_PASS_SCORE : blocking ? VERDICT_FAIL_SCORE : null,
|
|
126
128
|
severity: pass ? "none" : blocking ? "high" : "low",
|
|
127
129
|
artifact: handleToString(handle),
|
|
128
130
|
findings,
|