@warpgogol/forge 9.4.0 → 9.5.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/CHANGELOG.md +30 -0
- package/README.md +4 -2
- package/README.uk.md +10 -8
- package/bin/cli.ts +152 -11
- package/dist/bin/cli.js +125 -5
- package/dist/bin/cli.js.map +1 -1
- package/dist/os/flow/dirty-classify.d.ts +11 -1
- package/dist/os/flow/dirty-classify.d.ts.map +1 -1
- package/dist/os/flow/dirty-classify.js +13 -0
- package/dist/os/flow/dirty-classify.js.map +1 -1
- package/dist/os/flow/flow.module.d.ts.map +1 -1
- package/dist/os/flow/flow.module.js +29 -3
- package/dist/os/flow/flow.module.js.map +1 -1
- package/dist/os/flow/handlers/flow-check.d.ts.map +1 -1
- package/dist/os/flow/handlers/flow-check.js +9 -9
- package/dist/os/flow/handlers/flow-check.js.map +1 -1
- package/dist/os/flow/handlers/flow-cut.d.ts.map +1 -1
- package/dist/os/flow/handlers/flow-cut.js +22 -8
- package/dist/os/flow/handlers/flow-cut.js.map +1 -1
- package/dist/os/flow/handlers/flow-integrate.d.ts +6 -0
- package/dist/os/flow/handlers/flow-integrate.d.ts.map +1 -1
- package/dist/os/flow/handlers/flow-integrate.js +155 -44
- package/dist/os/flow/handlers/flow-integrate.js.map +1 -1
- package/dist/os/flow/handlers/flow-open.d.ts.map +1 -1
- package/dist/os/flow/handlers/flow-open.js +14 -19
- package/dist/os/flow/handlers/flow-open.js.map +1 -1
- package/dist/os/flow/handlers/flow-peers.d.ts +24 -0
- package/dist/os/flow/handlers/flow-peers.d.ts.map +1 -0
- package/dist/os/flow/handlers/flow-peers.js +99 -0
- package/dist/os/flow/handlers/flow-peers.js.map +1 -0
- package/dist/os/flow/index.d.ts +3 -0
- package/dist/os/flow/index.d.ts.map +1 -1
- package/dist/os/flow/index.js +9 -4
- package/dist/os/flow/index.js.map +1 -1
- package/dist/os/flow/ops-registry.d.ts +33 -0
- package/dist/os/flow/ops-registry.d.ts.map +1 -0
- package/dist/os/flow/ops-registry.js +177 -0
- package/dist/os/flow/ops-registry.js.map +1 -0
- package/dist/os/flow/preflight.d.ts +70 -3
- package/dist/os/flow/preflight.d.ts.map +1 -1
- package/dist/os/flow/preflight.js +545 -49
- package/dist/os/flow/preflight.js.map +1 -1
- package/dist/os/flow/registry.d.ts +2 -2
- package/dist/os/flow/standalone-invoke.d.ts +11 -0
- package/dist/os/flow/standalone-invoke.d.ts.map +1 -0
- package/dist/os/flow/standalone-invoke.js +75 -0
- package/dist/os/flow/standalone-invoke.js.map +1 -0
- package/dist/os/gate-run/detach.d.ts +27 -0
- package/dist/os/gate-run/detach.d.ts.map +1 -0
- package/dist/os/gate-run/detach.js +85 -0
- package/dist/os/gate-run/detach.js.map +1 -0
- package/dist/os/gate-run/gate-run.module.d.ts +3 -0
- package/dist/os/gate-run/gate-run.module.d.ts.map +1 -0
- package/dist/os/gate-run/gate-run.module.js +23 -0
- package/dist/os/gate-run/gate-run.module.js.map +1 -0
- package/dist/os/gate-run/index.d.ts +7 -0
- package/dist/os/gate-run/index.d.ts.map +1 -0
- package/dist/os/gate-run/index.js +5 -0
- package/dist/os/gate-run/index.js.map +1 -0
- package/dist/os/gate-run/record.d.ts +47 -0
- package/dist/os/gate-run/record.d.ts.map +1 -0
- package/dist/os/gate-run/record.js +157 -0
- package/dist/os/gate-run/record.js.map +1 -0
- package/dist/os/gate-run/status.d.ts +41 -0
- package/dist/os/gate-run/status.d.ts.map +1 -0
- package/dist/os/gate-run/status.js +142 -0
- package/dist/os/gate-run/status.js.map +1 -0
- package/dist/os/gate-run/types.d.ts +47 -0
- package/dist/os/gate-run/types.d.ts.map +1 -0
- package/dist/os/gate-run/types.js +24 -0
- package/dist/os/gate-run/types.js.map +1 -0
- package/dist/os/mission/handlers/archive.d.ts.map +1 -1
- package/dist/os/mission/handlers/archive.js +12 -8
- package/dist/os/mission/handlers/archive.js.map +1 -1
- package/dist/os/mission/importer-block.d.ts +19 -0
- package/dist/os/mission/importer-block.d.ts.map +1 -0
- package/dist/os/mission/importer-block.js +124 -0
- package/dist/os/mission/importer-block.js.map +1 -0
- package/dist/os/mission/lockfile.d.ts +17 -0
- package/dist/os/mission/lockfile.d.ts.map +1 -1
- package/dist/os/mission/lockfile.js +38 -0
- package/dist/os/mission/lockfile.js.map +1 -1
- package/dist/os/rfc/evidence-annotation.d.ts +26 -0
- package/dist/os/rfc/evidence-annotation.d.ts.map +1 -0
- package/dist/os/rfc/evidence-annotation.js +52 -0
- package/dist/os/rfc/evidence-annotation.js.map +1 -0
- package/dist/os/rfc/handlers/fixed-inputs.d.ts.map +1 -1
- package/dist/os/rfc/handlers/fixed-inputs.js +7 -1
- package/dist/os/rfc/handlers/fixed-inputs.js.map +1 -1
- package/dist/os/rfc/handlers/implement-stamp.d.ts.map +1 -1
- package/dist/os/rfc/handlers/implement-stamp.js +21 -28
- package/dist/os/rfc/handlers/implement-stamp.js.map +1 -1
- package/dist/os/rfc/handlers/list-create.d.ts.map +1 -1
- package/dist/os/rfc/handlers/list-create.js +25 -3
- package/dist/os/rfc/handlers/list-create.js.map +1 -1
- package/dist/os/rfc/handlers/validate-rules.d.ts.map +1 -1
- package/dist/os/rfc/handlers/validate-rules.js +127 -7
- package/dist/os/rfc/handlers/validate-rules.js.map +1 -1
- package/dist/os/rfc/rfc.module.d.ts.map +1 -1
- package/dist/os/rfc/rfc.module.js +3 -2
- package/dist/os/rfc/rfc.module.js.map +1 -1
- package/dist/os/rfc/types.d.ts +9 -2
- package/dist/os/rfc/types.d.ts.map +1 -1
- package/dist/os/rfc/types.js +2 -2
- package/dist/os/rfc/types.js.map +1 -1
- package/dist/os/system/handlers/system-task-collect.d.ts.map +1 -1
- package/dist/os/system/handlers/system-task-collect.js +11 -5
- package/dist/os/system/handlers/system-task-collect.js.map +1 -1
- package/dist/src/cli-flags.d.ts.map +1 -1
- package/dist/src/cli-flags.js +6 -0
- package/dist/src/cli-flags.js.map +1 -1
- package/dist/src/onboarding/prettierignore.d.ts.map +1 -1
- package/dist/src/onboarding/prettierignore.js +2 -0
- package/dist/src/onboarding/prettierignore.js.map +1 -1
- package/dist/src/types.d.ts +7 -0
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js +2 -8
- package/dist/src/types.js.map +1 -1
- package/os/flow/dirty-classify.ts +21 -0
- package/os/flow/flow.module.ts +31 -3
- package/os/flow/handlers/flow-check.ts +17 -18
- package/os/flow/handlers/flow-cut.ts +28 -11
- package/os/flow/handlers/flow-integrate.ts +229 -62
- package/os/flow/handlers/flow-open.ts +24 -31
- package/os/flow/handlers/flow-peers.ts +142 -0
- package/os/flow/index.ts +10 -8
- package/os/flow/ops-registry.ts +194 -0
- package/os/flow/preflight.ts +608 -55
- package/os/flow/standalone-invoke.ts +85 -0
- package/os/flow/tests/dirty-classify.test.ts +139 -4
- package/os/flow/tests/flow-cut.test.ts +21 -0
- package/os/flow/tests/flow-integrate.preflight.test.ts +34 -9
- package/os/flow/tests/flow-integrate.test.ts +433 -17
- package/os/flow/tests/lockfile-induced.test.ts +328 -0
- package/os/flow/tests/ops-registry.test.ts +136 -0
- package/os/gate-run/detach.ts +106 -0
- package/os/gate-run/gate-run.module.ts +25 -0
- package/os/gate-run/index.ts +16 -0
- package/os/gate-run/record.ts +194 -0
- package/os/gate-run/status.ts +168 -0
- package/os/gate-run/tests/gate-run-detach.test.ts +144 -0
- package/os/gate-run/tests/gate-run-record.test.ts +200 -0
- package/os/gate-run/types.ts +73 -0
- package/os/mission/handlers/archive.ts +22 -14
- package/os/mission/importer-block.ts +119 -0
- package/os/mission/lockfile.ts +41 -0
- package/os/rfc/evidence-annotation.ts +61 -0
- package/os/rfc/handlers/fixed-inputs.test.ts +70 -0
- package/os/rfc/handlers/fixed-inputs.ts +11 -1
- package/os/rfc/handlers/implement-stamp.ts +25 -28
- package/os/rfc/handlers/list-create.test.ts +58 -5
- package/os/rfc/handlers/list-create.ts +30 -3
- package/os/rfc/handlers/validate-evidence-shape.test.ts +218 -0
- package/os/rfc/handlers/validate-probe-meta.test.ts +71 -0
- package/os/rfc/handlers/validate-rules.ts +169 -17
- package/os/rfc/handlers/validate-transient-probes.test.ts +222 -0
- package/os/rfc/rfc-0000-template.md +10 -10
- package/os/rfc/rfc.module.ts +3 -2
- package/os/rfc/types.ts +5 -2
- package/os/system/handlers/system-task-collect.ts +11 -5
- package/os/system/tests/system-task-collect.test.ts +16 -0
- package/package.json +17 -1
- package/skills/fo/fo-session-retro/SKILL.md +12 -4
- package/src/cli-flags.ts +7 -0
- package/src/onboarding/prettierignore.ts +2 -0
- package/src/tests/prettierignore-manage.test.ts +11 -0
- package/src/types.ts +9 -8
|
@@ -14,29 +14,32 @@ closed by the RFC: adding a check requires an amendment.</purpose>
|
|
|
14
14
|
</non-goals>
|
|
15
15
|
</MODULE_CONTRACT>
|
|
16
16
|
<CHANGE_SUMMARY>
|
|
17
|
-
<item>RFC-
|
|
18
|
-
<item>RFC-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
<item>RFC-
|
|
22
|
-
<
|
|
23
|
-
<item>RFC-1538: revalidate integration preconditions post-lock and reuse the session engine</item>
|
|
24
|
-
<item>RFC-1531: shared DirtyClass enum via dirty-classify.ts (Q-4), classified FLOW-INT-01/03 data.entries, classifyDirtyEntries for the remediation flags</item>
|
|
17
|
+
<item>RFC-1543: attribute shared-checkout dirt to live ops and expose peers (RFC-1543)</item>
|
|
18
|
+
<item>RFC-1544: attribute mission lockfile churn to owning checkout and auto-resolve foreign importer diffs (RFC-1544)</item>
|
|
19
|
+
<item>ADR-0130: induced-change lockfile classifiers — BFS reachability for optional-flag removals, collapse pairs, induced packages/snapshots additions</item>
|
|
20
|
+
<item>ADR-0129: F-0186/F-0187 — FLOW-INT-03 names paths + three-way remedy, FLOW-OPEN-01 same hint, forge CLI kernel-command hint</item>
|
|
21
|
+
<item>RFC-0000: skip rfc-0000 template in integrate preflight id extraction; regen ecosystem manifest; file F-0207</item>
|
|
22
|
+
<history>RFC-1528, RFC-1531, RFC-1537, RFC-1538, RFC-1545, RFC-1546</history>
|
|
25
23
|
</CHANGE_SUMMARY>
|
|
26
24
|
*/
|
|
27
25
|
import { basename, dirname, join } from "node:path";
|
|
26
|
+
import { parse as parseYaml } from "yaml";
|
|
28
27
|
import { loadLiveCommandInventory } from "../../src/utils/command-inventory.js";
|
|
29
|
-
import { isGeneratedContent, isGeneratedPathName, REGEN_FLAGS
|
|
28
|
+
import { isGeneratedContent, isGeneratedPathName, REGEN_FLAGS } from "../core/archive-regen.js";
|
|
30
29
|
import { openMissionsIn } from "../mission/open-missions.js";
|
|
31
|
-
import { classifyDirtyPath, summarizeClasses, } from "./dirty-classify.js";
|
|
32
|
-
import { currentBranch, git, statusTracked } from "./git.js";
|
|
30
|
+
import { classifyDirtyPath, FOREIGN_PRIMARY_DIRT_HINT, summarizeClasses, } from "./dirty-classify.js";
|
|
31
|
+
import { currentBranch, git, statusTracked, worktreeList } from "./git.js";
|
|
32
|
+
import { canonicalRepoDir } from "../../src/utils/repo-path.js";
|
|
33
|
+
import { claimCoversPath, liveClaims } from "./ops-registry.js";
|
|
33
34
|
/**
|
|
34
35
|
* Strict match for the pnpm-prune shape: ONLY removed lines, every one either
|
|
35
36
|
* a `missions/<id>/workpiece:` importer key or a deeper-indented member of
|
|
36
|
-
* such a key's block.
|
|
37
|
-
*
|
|
37
|
+
* such a key's block. Returns the sorted pruned mission ids on match, null
|
|
38
|
+
* otherwise — any added line, any other removed line, or a diff with no
|
|
39
|
+
* removals is ambiguous and stays an ordinary refusal.
|
|
38
40
|
*/
|
|
39
|
-
export function
|
|
41
|
+
export function classifyLockfilePruneIds(diffText) {
|
|
42
|
+
const ids = new Set();
|
|
40
43
|
let sawImporterKey = false;
|
|
41
44
|
let openBlockIndent = null;
|
|
42
45
|
for (const raw of diffText.split("\n")) {
|
|
@@ -51,7 +54,7 @@ export function classifyLockfileDiff(diffText) {
|
|
|
51
54
|
continue;
|
|
52
55
|
}
|
|
53
56
|
if (raw.startsWith("+"))
|
|
54
|
-
return
|
|
57
|
+
return null;
|
|
55
58
|
const line = raw.slice(1);
|
|
56
59
|
if (raw[0] === " ") {
|
|
57
60
|
const indent = line.length - line.trimStart().length;
|
|
@@ -65,20 +68,25 @@ export function classifyLockfileDiff(diffText) {
|
|
|
65
68
|
if (line.trim().length === 0) {
|
|
66
69
|
// A blank removed line only tolerates inside an open importer block.
|
|
67
70
|
if (openBlockIndent === null)
|
|
68
|
-
return
|
|
71
|
+
return null;
|
|
69
72
|
continue;
|
|
70
73
|
}
|
|
71
74
|
const indent = line.length - line.trimStart().length;
|
|
72
|
-
|
|
75
|
+
const key = /^\s*missions\/([^\s/]+)\/workpiece:\s*$/.exec(line);
|
|
76
|
+
if (key) {
|
|
73
77
|
sawImporterKey = true;
|
|
78
|
+
ids.add(key[1]);
|
|
74
79
|
openBlockIndent = indent;
|
|
75
80
|
continue;
|
|
76
81
|
}
|
|
77
82
|
if (openBlockIndent !== null && indent > openBlockIndent)
|
|
78
83
|
continue;
|
|
79
|
-
return
|
|
84
|
+
return null;
|
|
80
85
|
}
|
|
81
|
-
return sawImporterKey ?
|
|
86
|
+
return sawImporterKey ? [...ids].sort() : null;
|
|
87
|
+
}
|
|
88
|
+
export function classifyLockfileDiff(diffText) {
|
|
89
|
+
return classifyLockfilePruneIds(diffText) !== null ? "importer-prune-only" : "other";
|
|
82
90
|
}
|
|
83
91
|
/**
|
|
84
92
|
* Mirror of the prune shape for materialization (RFC-1537): ONLY added lines,
|
|
@@ -133,6 +141,303 @@ export function classifyLockfileMaterialize(diffText) {
|
|
|
133
141
|
}
|
|
134
142
|
return sawImporterKey ? [...ids].sort() : null;
|
|
135
143
|
}
|
|
144
|
+
// ---------------------------------------------------------------------------
|
|
145
|
+
// ADR-0130 (F-0201): induced-change lockfile shapes
|
|
146
|
+
//
|
|
147
|
+
// A `pnpm install` against a lockfile whose `importers:` list includes open
|
|
148
|
+
// mission workpieces produces diffs that are never pure block additions or
|
|
149
|
+
// removals — the dependency-graph write also adds/drops `optional: true`
|
|
150
|
+
// flags, collapses `key:\n optional: true` pairs to `key: {}`, and adds or
|
|
151
|
+
// removes `packages:`/`snapshots:` members. The strict one-shape classifiers
|
|
152
|
+
// above see the extra hunks and degrade to `work`, which is the ping-pong the
|
|
153
|
+
// ADR stops. These extended classifiers accept the strict shape first and
|
|
154
|
+
// then the induced shape, bounded by where each hunk anchors in the HEAD
|
|
155
|
+
// lockfile.
|
|
156
|
+
// ---------------------------------------------------------------------------
|
|
157
|
+
const DIFF_HEADER = /^(diff |index |--- |\+\+\+ |@@ )/;
|
|
158
|
+
const TOP_LEVEL_KEY = /^(\S[^:]*):\s*$/;
|
|
159
|
+
const IMPORTER_KEY = /^\s*missions\/([^\s/]+)\/workpiece:\s*$/;
|
|
160
|
+
const OPTIONAL_TRUE = /^\s*optional: true\s*$/;
|
|
161
|
+
/** Parse `git diff` output into positioned lines (single-file diffs only). */
|
|
162
|
+
function parseDiffLines(diffText) {
|
|
163
|
+
const lines = [];
|
|
164
|
+
let oldCursor = 0;
|
|
165
|
+
for (const raw of diffText.split("\n")) {
|
|
166
|
+
const hunk = /^@@ -(\d+)(?:,\d+)? \+\d+(?:,\d+)? @@/.exec(raw);
|
|
167
|
+
if (hunk) {
|
|
168
|
+
oldCursor = Number(hunk[1]);
|
|
169
|
+
lines.push({ kind: "hunk", text: raw, oldLine: oldCursor });
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
if (DIFF_HEADER.test(raw) || raw === "")
|
|
173
|
+
continue;
|
|
174
|
+
if (raw.startsWith("+")) {
|
|
175
|
+
lines.push({ kind: "add", text: raw.slice(1), oldLine: oldCursor });
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
if (raw.startsWith("-")) {
|
|
179
|
+
lines.push({ kind: "del", text: raw.slice(1), oldLine: oldCursor });
|
|
180
|
+
oldCursor += 1;
|
|
181
|
+
continue;
|
|
182
|
+
}
|
|
183
|
+
lines.push({ kind: "ctx", text: raw.slice(1), oldLine: oldCursor });
|
|
184
|
+
oldCursor += 1;
|
|
185
|
+
}
|
|
186
|
+
return lines;
|
|
187
|
+
}
|
|
188
|
+
/** Top-level (`key:`) section containing old-file line `n` (1-based). */
|
|
189
|
+
function topLevelSectionAt(headLines, n) {
|
|
190
|
+
let section = null;
|
|
191
|
+
for (let i = 0; i < Math.min(n, headLines.length); i++) {
|
|
192
|
+
const m = TOP_LEVEL_KEY.exec(headLines[i]);
|
|
193
|
+
if (m)
|
|
194
|
+
section = m[1];
|
|
195
|
+
}
|
|
196
|
+
return section;
|
|
197
|
+
}
|
|
198
|
+
/** Second-level `key:` (one-indent) enclosing old-file line `n` inside `section`. */
|
|
199
|
+
function secondLevelKeyAt(headLines, n, section) {
|
|
200
|
+
let inSection = false;
|
|
201
|
+
let key = null;
|
|
202
|
+
for (let i = 0; i < Math.min(n, headLines.length); i++) {
|
|
203
|
+
const line = headLines[i];
|
|
204
|
+
const top = TOP_LEVEL_KEY.exec(line);
|
|
205
|
+
if (top) {
|
|
206
|
+
inSection = top[1] === section;
|
|
207
|
+
key = null;
|
|
208
|
+
continue;
|
|
209
|
+
}
|
|
210
|
+
if (!inSection || line.trim() === "")
|
|
211
|
+
continue;
|
|
212
|
+
const m = /^ {2}('?[^:]*'?):\s*(?:\{\})?\s*$/.exec(line);
|
|
213
|
+
if (m)
|
|
214
|
+
key = m[1].replace(/^'|'$/g, "");
|
|
215
|
+
}
|
|
216
|
+
return key;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Snapshot keys reachable from `missionIds` in the working lockfile — BFS
|
|
220
|
+
* from each `missions/<id>/workpiece` importer through `dependencies`,
|
|
221
|
+
* `devDependencies` and `optionalDependencies` version specifiers, then
|
|
222
|
+
* through each reached snapshot's own dependency maps. Specifiers that are
|
|
223
|
+
* not registry resolutions (`link:`, `workspace:`, `file:`) have no snapshot
|
|
224
|
+
* entry and are ignored.
|
|
225
|
+
*/
|
|
226
|
+
export function reachableSnapshotKeys(lockText, missionIds) {
|
|
227
|
+
const reachable = new Set();
|
|
228
|
+
let parsed;
|
|
229
|
+
try {
|
|
230
|
+
parsed = parseYaml(lockText);
|
|
231
|
+
}
|
|
232
|
+
catch {
|
|
233
|
+
return reachable;
|
|
234
|
+
}
|
|
235
|
+
const root = parsed;
|
|
236
|
+
const importers = (root?.importers ?? {});
|
|
237
|
+
const snapshots = (root?.snapshots ?? {});
|
|
238
|
+
const depMaps = (entry) => {
|
|
239
|
+
const out = [];
|
|
240
|
+
for (const field of ["dependencies", "devDependencies", "optionalDependencies"]) {
|
|
241
|
+
const deps = entry[field];
|
|
242
|
+
if (!deps)
|
|
243
|
+
continue;
|
|
244
|
+
for (const [name, spec] of Object.entries(deps)) {
|
|
245
|
+
const version = typeof spec === "string" ? spec : spec?.version;
|
|
246
|
+
if (typeof version !== "string")
|
|
247
|
+
continue;
|
|
248
|
+
if (/^(link|workspace|file):/.test(version))
|
|
249
|
+
continue;
|
|
250
|
+
// pnpm strips the name for plain resolutions inside importers
|
|
251
|
+
// (version only) but snapshot keys carry `name@version`.
|
|
252
|
+
out.push(version.startsWith(`${name}@`) ? version : `${name}@${version}`);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
return out;
|
|
256
|
+
};
|
|
257
|
+
const queue = [];
|
|
258
|
+
for (const id of missionIds) {
|
|
259
|
+
const entry = importers[`missions/${id}/workpiece`];
|
|
260
|
+
if (entry)
|
|
261
|
+
queue.push(...depMaps(entry));
|
|
262
|
+
}
|
|
263
|
+
while (queue.length > 0) {
|
|
264
|
+
const key = queue.shift();
|
|
265
|
+
if (reachable.has(key))
|
|
266
|
+
continue;
|
|
267
|
+
reachable.add(key);
|
|
268
|
+
const snap = snapshots[key];
|
|
269
|
+
if (snap)
|
|
270
|
+
queue.push(...depMaps(snap));
|
|
271
|
+
}
|
|
272
|
+
return reachable;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* ADR-0130 criterion (b)+(c): materialize shape extended with induced
|
|
276
|
+
* changes. Removed lines must be `optional: true` on snapshots reachable
|
|
277
|
+
* from the added mission importers, or `key:` lines paired with an added
|
|
278
|
+
* `key: {}` collapse. Added lines outside mission importer blocks must
|
|
279
|
+
* anchor under `packages:` or `snapshots:` in the HEAD file.
|
|
280
|
+
*/
|
|
281
|
+
export function classifyLockfileMaterializeExtended(diffText, headText, workText) {
|
|
282
|
+
const strict = classifyLockfileMaterialize(diffText);
|
|
283
|
+
if (strict !== null)
|
|
284
|
+
return strict;
|
|
285
|
+
const headLines = headText.split("\n");
|
|
286
|
+
const lines = parseDiffLines(diffText);
|
|
287
|
+
const missionIds = new Set();
|
|
288
|
+
const collapsedKeys = new Set();
|
|
289
|
+
const optionalRemovedOn = new Set();
|
|
290
|
+
let importerBlockIndent = null;
|
|
291
|
+
let sawDiff = false;
|
|
292
|
+
for (const line of lines) {
|
|
293
|
+
if (line.kind === "hunk") {
|
|
294
|
+
importerBlockIndent = null;
|
|
295
|
+
continue;
|
|
296
|
+
}
|
|
297
|
+
if (line.kind === "ctx") {
|
|
298
|
+
const indent = line.text.length - line.text.trimStart().length;
|
|
299
|
+
if (line.text.trim().length > 0 &&
|
|
300
|
+
importerBlockIndent !== null &&
|
|
301
|
+
indent <= importerBlockIndent) {
|
|
302
|
+
importerBlockIndent = null;
|
|
303
|
+
}
|
|
304
|
+
continue;
|
|
305
|
+
}
|
|
306
|
+
sawDiff = true;
|
|
307
|
+
if (line.kind === "add") {
|
|
308
|
+
const text = line.text;
|
|
309
|
+
const indent = text.length - text.trimStart().length;
|
|
310
|
+
const key = IMPORTER_KEY.exec(text);
|
|
311
|
+
if (key) {
|
|
312
|
+
missionIds.add(key[1]);
|
|
313
|
+
importerBlockIndent = indent;
|
|
314
|
+
continue;
|
|
315
|
+
}
|
|
316
|
+
if (importerBlockIndent !== null && (indent > importerBlockIndent || text.trim() === "")) {
|
|
317
|
+
continue; // member of an open importer block
|
|
318
|
+
}
|
|
319
|
+
if (indent <= (importerBlockIndent ?? indent))
|
|
320
|
+
importerBlockIndent = null;
|
|
321
|
+
// Non-importer additions must anchor inside the dependency-graph
|
|
322
|
+
// sections — the induced write never touches anything else.
|
|
323
|
+
const section = topLevelSectionAt(headLines, line.oldLine);
|
|
324
|
+
if (section === "packages" || section === "snapshots")
|
|
325
|
+
continue;
|
|
326
|
+
return null;
|
|
327
|
+
}
|
|
328
|
+
// removed line
|
|
329
|
+
const text = line.text;
|
|
330
|
+
if (OPTIONAL_TRUE.test(text)) {
|
|
331
|
+
const owner = secondLevelKeyAt(headLines, line.oldLine, "snapshots");
|
|
332
|
+
if (owner === null)
|
|
333
|
+
return null;
|
|
334
|
+
optionalRemovedOn.add(owner);
|
|
335
|
+
continue;
|
|
336
|
+
}
|
|
337
|
+
const removedKey = /^(\s*'?[^:]*'?):\s*$/.exec(text);
|
|
338
|
+
if (removedKey) {
|
|
339
|
+
// allowed only as the `key:` → `key: {}` collapse — an added
|
|
340
|
+
// `key: {}` must appear somewhere in the diff.
|
|
341
|
+
collapsedKeys.add(removedKey[1].trim());
|
|
342
|
+
const owner = removedKey[1].trim().replace(/^'|'$/g, "");
|
|
343
|
+
const section = topLevelSectionAt(headLines, line.oldLine);
|
|
344
|
+
if (section !== "snapshots")
|
|
345
|
+
return null;
|
|
346
|
+
optionalRemovedOn.add(owner);
|
|
347
|
+
continue;
|
|
348
|
+
}
|
|
349
|
+
return null;
|
|
350
|
+
}
|
|
351
|
+
if (!sawDiff || missionIds.size === 0)
|
|
352
|
+
return null;
|
|
353
|
+
// every removed `key:` must be matched by an added `key: {}` — an
|
|
354
|
+
// unmatched one is a real snapshot removal, not a collapse.
|
|
355
|
+
for (const key of collapsedKeys) {
|
|
356
|
+
const hasPair = lines.some((l) => l.kind === "add" && l.text.trim() === `${key}: {}`);
|
|
357
|
+
if (!hasPair)
|
|
358
|
+
return null;
|
|
359
|
+
}
|
|
360
|
+
const reachable = reachableSnapshotKeys(workText, [...missionIds]);
|
|
361
|
+
for (const owner of optionalRemovedOn) {
|
|
362
|
+
if (!reachable.has(owner))
|
|
363
|
+
return null;
|
|
364
|
+
}
|
|
365
|
+
return [...missionIds].sort();
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* ADR-0130 prune direction: removed lines must still be importer-block
|
|
369
|
+
* members (strict rule); added lines are tolerated only when they anchor
|
|
370
|
+
* inside `packages:`/`snapshots:` — the inverse induced write (`optional:
|
|
371
|
+
* true` re-additions, `transitivePeerDependencies`, snapshot entries).
|
|
372
|
+
*/
|
|
373
|
+
export function classifyLockfilePruneIdsExtended(diffText, headText) {
|
|
374
|
+
const strict = classifyLockfilePruneIds(diffText);
|
|
375
|
+
if (strict !== null)
|
|
376
|
+
return strict;
|
|
377
|
+
const headLines = headText.split("\n");
|
|
378
|
+
const lines = parseDiffLines(diffText);
|
|
379
|
+
const ids = new Set();
|
|
380
|
+
const expandedKeys = new Set();
|
|
381
|
+
let sawImporterKey = false;
|
|
382
|
+
let openBlockIndent = null;
|
|
383
|
+
for (const line of lines) {
|
|
384
|
+
if (line.kind === "hunk") {
|
|
385
|
+
openBlockIndent = null;
|
|
386
|
+
continue;
|
|
387
|
+
}
|
|
388
|
+
if (line.kind === "ctx") {
|
|
389
|
+
const indent = line.text.length - line.text.trimStart().length;
|
|
390
|
+
if (line.text.trim().length > 0 && openBlockIndent !== null && indent <= openBlockIndent) {
|
|
391
|
+
openBlockIndent = null;
|
|
392
|
+
}
|
|
393
|
+
continue;
|
|
394
|
+
}
|
|
395
|
+
if (line.kind === "add") {
|
|
396
|
+
const section = topLevelSectionAt(headLines, line.oldLine);
|
|
397
|
+
if (section === "packages" || section === "snapshots")
|
|
398
|
+
continue;
|
|
399
|
+
return null;
|
|
400
|
+
}
|
|
401
|
+
const text = line.text;
|
|
402
|
+
if (text.trim().length === 0) {
|
|
403
|
+
if (openBlockIndent === null)
|
|
404
|
+
return null;
|
|
405
|
+
continue;
|
|
406
|
+
}
|
|
407
|
+
// inverse of the materialize collapse — the prune re-expands
|
|
408
|
+
// `key: {}` into `key:` + `optional: true` children.
|
|
409
|
+
const emptyEntry = /^(\s*'?[^:]*'?):\s*\{\}\s*$/.exec(text);
|
|
410
|
+
if (emptyEntry) {
|
|
411
|
+
const section = topLevelSectionAt(headLines, line.oldLine);
|
|
412
|
+
if (section === "snapshots" || section === "packages") {
|
|
413
|
+
expandedKeys.add(emptyEntry[1].trim());
|
|
414
|
+
continue;
|
|
415
|
+
}
|
|
416
|
+
return null;
|
|
417
|
+
}
|
|
418
|
+
const indent = text.length - text.trimStart().length;
|
|
419
|
+
const key = IMPORTER_KEY.exec(text);
|
|
420
|
+
if (key) {
|
|
421
|
+
sawImporterKey = true;
|
|
422
|
+
ids.add(key[1]);
|
|
423
|
+
openBlockIndent = indent;
|
|
424
|
+
continue;
|
|
425
|
+
}
|
|
426
|
+
if (openBlockIndent !== null && indent > openBlockIndent)
|
|
427
|
+
continue;
|
|
428
|
+
return null;
|
|
429
|
+
}
|
|
430
|
+
if (!sawImporterKey)
|
|
431
|
+
return null;
|
|
432
|
+
// every removed `key: {}` must pair with an added `key:` — an unmatched
|
|
433
|
+
// one is a real snapshot removal, not a re-expansion.
|
|
434
|
+
for (const key of expandedKeys) {
|
|
435
|
+
const hasPair = lines.some((l) => l.kind === "add" && l.text.trim() === `${key}:`);
|
|
436
|
+
if (!hasPair)
|
|
437
|
+
return null;
|
|
438
|
+
}
|
|
439
|
+
return [...ids].sort();
|
|
440
|
+
}
|
|
136
441
|
/** Classify the pnpm-lock.yaml diff of `repo` when the lockfile is dirty. */
|
|
137
442
|
async function classifyDirtyLockfile(repo, io, dirtyEntries, runGit) {
|
|
138
443
|
const lockfileDirty = dirtyEntries.some((entry) => entry.slice(3).trim() === "pnpm-lock.yaml");
|
|
@@ -141,6 +446,47 @@ async function classifyDirtyLockfile(repo, io, dirtyEntries, runGit) {
|
|
|
141
446
|
const diff = await runGit(repo, io, ["diff", "HEAD", "--", "pnpm-lock.yaml"]);
|
|
142
447
|
return classifyLockfileDiff(diff.stdout);
|
|
143
448
|
}
|
|
449
|
+
/**
|
|
450
|
+
* Default referent resolver — `git worktree list` for the checkout set and
|
|
451
|
+
* `openMissionsIn` per checkout for mission state (the same enumeration
|
|
452
|
+
* `flow.status` performs; never cwd-relative guesses).
|
|
453
|
+
*/
|
|
454
|
+
export async function resolveImporterReferents(repo, io, missionIds) {
|
|
455
|
+
const worktrees = await worktreeList(repo, io);
|
|
456
|
+
const here = canonicalRepoDir(repo);
|
|
457
|
+
const others = worktrees.filter((w) => w.path !== here).map((w) => w.path);
|
|
458
|
+
const openCache = new Map();
|
|
459
|
+
const openIn = async (dir) => {
|
|
460
|
+
let set = openCache.get(dir);
|
|
461
|
+
if (set === undefined) {
|
|
462
|
+
try {
|
|
463
|
+
set = new Set(await openMissionsIn(dir, io));
|
|
464
|
+
}
|
|
465
|
+
catch {
|
|
466
|
+
set = new Set();
|
|
467
|
+
}
|
|
468
|
+
openCache.set(dir, set);
|
|
469
|
+
}
|
|
470
|
+
return set;
|
|
471
|
+
};
|
|
472
|
+
const out = [];
|
|
473
|
+
for (const missionId of missionIds) {
|
|
474
|
+
const rel = join("missions", missionId, "workpiece");
|
|
475
|
+
const existsHere = await io.exists(join(repo, rel));
|
|
476
|
+
const existsInCheckout = [];
|
|
477
|
+
for (const dir of others) {
|
|
478
|
+
if (await io.exists(join(dir, rel)))
|
|
479
|
+
existsInCheckout.push(dir);
|
|
480
|
+
}
|
|
481
|
+
let missionOpen = (await openIn(repo)).has(missionId);
|
|
482
|
+
for (const dir of others) {
|
|
483
|
+
if (!missionOpen && (await openIn(dir)).has(missionId))
|
|
484
|
+
missionOpen = true;
|
|
485
|
+
}
|
|
486
|
+
out.push({ missionId, existsHere, existsInCheckout: existsInCheckout.sort(), missionOpen });
|
|
487
|
+
}
|
|
488
|
+
return out;
|
|
489
|
+
}
|
|
144
490
|
const TWIN_ROOT = ".agents/skills/";
|
|
145
491
|
/** Canonical candidates for a `.agents/skills/<dir>/<rel>` twin path. */
|
|
146
492
|
function twinCanonicalCandidates(dir, rel) {
|
|
@@ -188,9 +534,10 @@ function prettierignoreTwinOnly(diffText) {
|
|
|
188
534
|
* The shapes are closed by RFC-1537: ambiguity always degrades to
|
|
189
535
|
* unattributed, never to tolerance.
|
|
190
536
|
*/
|
|
191
|
-
export async function classifyDirt(repo, io, entries, deps = { runGit: git }) {
|
|
537
|
+
export async function classifyDirt(repo, io, entries, deps = { runGit: git }, claims = [], resolveReferents) {
|
|
192
538
|
const tolerated = [];
|
|
193
539
|
const unattributed = [];
|
|
540
|
+
const foreignInFlight = [];
|
|
194
541
|
const byPath = new Map();
|
|
195
542
|
for (const line of entries) {
|
|
196
543
|
const p = line.slice(3).trim();
|
|
@@ -206,11 +553,71 @@ export async function classifyDirt(repo, io, entries, deps = { runGit: git }) {
|
|
|
206
553
|
outer: for (const [path, lines] of byPath) {
|
|
207
554
|
if (path === "pnpm-lock.yaml") {
|
|
208
555
|
const diff = await deps.runGit(repo, io, ["diff", "HEAD", "--", "pnpm-lock.yaml"]);
|
|
209
|
-
|
|
210
|
-
|
|
556
|
+
// ADR-0130: the induced-change shapes need the HEAD and working
|
|
557
|
+
// contents — fetched lazily, only when the strict shapes miss.
|
|
558
|
+
let headLock = null;
|
|
559
|
+
let workLock = null;
|
|
560
|
+
const lockContents = async () => {
|
|
561
|
+
if (headLock === null || workLock === null) {
|
|
562
|
+
const head = await deps.runGit(repo, io, ["show", "HEAD:pnpm-lock.yaml"]);
|
|
563
|
+
if (head.exitCode !== 0)
|
|
564
|
+
return null;
|
|
565
|
+
let work;
|
|
566
|
+
try {
|
|
567
|
+
work = await io.readFile(join(repo, "pnpm-lock.yaml"));
|
|
568
|
+
}
|
|
569
|
+
catch {
|
|
570
|
+
return null; // reduced io — degrade to the strict-shape verdict
|
|
571
|
+
}
|
|
572
|
+
headLock = head.stdout;
|
|
573
|
+
workLock = work;
|
|
574
|
+
}
|
|
575
|
+
return { head: headLock, work: workLock };
|
|
576
|
+
};
|
|
577
|
+
let pruneIds = classifyLockfilePruneIds(diff.stdout);
|
|
578
|
+
if (pruneIds === null) {
|
|
579
|
+
const contents = await lockContents();
|
|
580
|
+
if (contents !== null) {
|
|
581
|
+
pruneIds = classifyLockfilePruneIdsExtended(diff.stdout, contents.head);
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
if (pruneIds !== null) {
|
|
585
|
+
// RFC-1544: the pruned importer's referent decides the class — a
|
|
586
|
+
// foreign checkout's open mission (foreign-open-mission, auto-
|
|
587
|
+
// restored by flow.integrate), dead residue (importer-prune-stale,
|
|
588
|
+
// accepted cleanup), or anything else (importer-prune, unchanged).
|
|
589
|
+
// An unresolvable referent set (no exec/ io capability) degrades to
|
|
590
|
+
// the inert importer-prune — "couldn't resolve" is not "resolved to
|
|
591
|
+
// nothing".
|
|
592
|
+
let referents;
|
|
593
|
+
if (resolveReferents !== undefined) {
|
|
594
|
+
try {
|
|
595
|
+
referents = await resolveReferents(pruneIds);
|
|
596
|
+
}
|
|
597
|
+
catch {
|
|
598
|
+
referents = undefined;
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
if (referents !== undefined &&
|
|
602
|
+
referents.every((r) => !r.existsHere && r.missionOpen && r.existsInCheckout.length > 0)) {
|
|
603
|
+
tolerated.push({ path, class: "foreign-open-mission", missionIds: pruneIds });
|
|
604
|
+
}
|
|
605
|
+
else if (referents !== undefined &&
|
|
606
|
+
referents.every((r) => !r.existsHere && r.existsInCheckout.length === 0 && !r.missionOpen)) {
|
|
607
|
+
tolerated.push({ path, class: "importer-prune-stale", missionIds: pruneIds });
|
|
608
|
+
}
|
|
609
|
+
else {
|
|
610
|
+
tolerated.push({ path, class: "importer-prune", missionIds: pruneIds });
|
|
611
|
+
}
|
|
211
612
|
continue;
|
|
212
613
|
}
|
|
213
|
-
|
|
614
|
+
let ids = classifyLockfileMaterialize(diff.stdout);
|
|
615
|
+
if (ids === null) {
|
|
616
|
+
const contents = await lockContents();
|
|
617
|
+
if (contents !== null) {
|
|
618
|
+
ids = classifyLockfileMaterializeExtended(diff.stdout, contents.head, contents.work);
|
|
619
|
+
}
|
|
620
|
+
}
|
|
214
621
|
if (ids !== null) {
|
|
215
622
|
const open = await openMissionIds();
|
|
216
623
|
if (ids.every((id) => open.has(id))) {
|
|
@@ -302,7 +709,22 @@ export async function classifyDirt(repo, io, entries, deps = { runGit: git }) {
|
|
|
302
709
|
}
|
|
303
710
|
unattributed.push(...lines);
|
|
304
711
|
}
|
|
305
|
-
|
|
712
|
+
// RFC-1543 AC-3: unattributed paths covered by a live claim reclassify as
|
|
713
|
+
// in-flight-foreign — every other unattributed path stays work-class.
|
|
714
|
+
if (claims.length > 0) {
|
|
715
|
+
const stillUnattributed = [];
|
|
716
|
+
for (const line of unattributed) {
|
|
717
|
+
const path = line.slice(3).trim();
|
|
718
|
+
const holder = claims.find((c) => claimCoversPath(c, path));
|
|
719
|
+
if (holder !== undefined)
|
|
720
|
+
foreignInFlight.push({ path, holder });
|
|
721
|
+
else
|
|
722
|
+
stillUnattributed.push(line);
|
|
723
|
+
}
|
|
724
|
+
unattributed.length = 0;
|
|
725
|
+
unattributed.push(...stillUnattributed);
|
|
726
|
+
}
|
|
727
|
+
return { tolerated, unattributed, foreignInFlight };
|
|
306
728
|
}
|
|
307
729
|
/**
|
|
308
730
|
* RFC-1531 AC-6: classify EVERY dirty entry — tolerated-family classes come
|
|
@@ -317,6 +739,9 @@ export async function classifyDirtyEntries(repo, io, entries, deps = { runGit: g
|
|
|
317
739
|
path: t.path,
|
|
318
740
|
class: t.class,
|
|
319
741
|
}));
|
|
742
|
+
for (const f of verdict.foreignInFlight) {
|
|
743
|
+
out.push({ path: f.path, class: "in-flight-foreign" });
|
|
744
|
+
}
|
|
320
745
|
for (const line of verdict.unattributed) {
|
|
321
746
|
const path = line.slice(3).trim();
|
|
322
747
|
out.push({ path, class: classifyDirtyPath(path) });
|
|
@@ -371,7 +796,7 @@ export async function runIntegratePreflight(opts, deps = { runGit: git, runStatu
|
|
|
371
796
|
if (opts.worktreeDirty.entries.length > 0) {
|
|
372
797
|
const verdict = await classifyDirt(opts.branchWorktree, io, opts.worktreeDirty.entries, {
|
|
373
798
|
runGit: deps.runGit,
|
|
374
|
-
});
|
|
799
|
+
}, [], (ids) => resolveImporterReferents(opts.branchWorktree, io, ids));
|
|
375
800
|
tolerated.push(...verdict.tolerated);
|
|
376
801
|
if (verdict.unattributed.length > 0) {
|
|
377
802
|
const lockfile = await classifyDirtyLockfile(opts.branchWorktree, io, verdict.unattributed, deps.runGit);
|
|
@@ -415,14 +840,36 @@ export async function runIntegratePreflight(opts, deps = { runGit: git, runStatu
|
|
|
415
840
|
// classification; the post-gate check stays (primary can dirty mid-gate).
|
|
416
841
|
checked.push("primary-dirty");
|
|
417
842
|
const primaryBranch = await deps.runCurrentBranch(opts.primary, io);
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
843
|
+
// RFC-1543 AC-4: primary-side foreign claims get a bounded wait — the poll
|
|
844
|
+
// re-reads both dirt and claims (≤30s cadence) until they clear or the
|
|
845
|
+
// budget expires; unattributed work refuses instantly as before.
|
|
846
|
+
const waitForeignMs = Math.max(0, (opts.waitForeignSeconds ?? 600) * 1000);
|
|
847
|
+
const foreignDeadline = Date.now() + waitForeignMs;
|
|
848
|
+
let primaryClean = false;
|
|
849
|
+
for (;;) {
|
|
850
|
+
const primaryDirty = await deps.runStatusTracked(opts.primary, io);
|
|
851
|
+
if (primaryDirty.entries.length === 0) {
|
|
852
|
+
primaryClean = true;
|
|
853
|
+
break;
|
|
854
|
+
}
|
|
855
|
+
const verdict = await classifyDirt(opts.primary, io, primaryDirty.entries, { runGit: deps.runGit }, await liveClaims(opts.primary, io), (ids) => resolveImporterReferents(opts.primary, io, ids));
|
|
423
856
|
tolerated.push(...verdict.tolerated);
|
|
424
|
-
|
|
857
|
+
const foreignOnly = verdict.unattributed.length === 0 &&
|
|
858
|
+
verdict.foreignInFlight.length > 0 &&
|
|
859
|
+
primaryBranch === "develop";
|
|
860
|
+
if (foreignOnly && Date.now() < foreignDeadline) {
|
|
861
|
+
const holders = verdict.foreignInFlight.map((f) => `${f.holder.command} ${f.holder.opId} (pid ${f.holder.pid}, started ${f.holder.startedAt})`);
|
|
862
|
+
opts.onProgress?.(`primary held by foreign op(s): ${holders.join("; ")} — waiting up to ${Math.ceil((foreignDeadline - Date.now()) / 1000)}s`);
|
|
863
|
+
await new Promise((r) => setTimeout(r, Math.min(30_000, foreignDeadline - Date.now())));
|
|
864
|
+
continue;
|
|
865
|
+
}
|
|
866
|
+
if (primaryBranch !== "develop" ||
|
|
867
|
+
verdict.unattributed.length > 0 ||
|
|
868
|
+
verdict.foreignInFlight.length > 0) {
|
|
425
869
|
const lockfile = await classifyDirtyLockfile(opts.primary, io, verdict.unattributed, deps.runGit);
|
|
870
|
+
const holderNote = verdict.foreignInFlight.length > 0
|
|
871
|
+
? ` — in-flight holder(s): ${verdict.foreignInFlight.map((f) => `${f.holder.command} ${f.holder.opId} (pid ${f.holder.pid})`).join("; ")}`
|
|
872
|
+
: "";
|
|
426
873
|
return {
|
|
427
874
|
ok: false,
|
|
428
875
|
checked,
|
|
@@ -432,25 +879,48 @@ export async function runIntegratePreflight(opts, deps = { runGit: git, runStatu
|
|
|
432
879
|
ruleId: "FLOW-INT-03",
|
|
433
880
|
message: (primaryBranch !== "develop"
|
|
434
881
|
? `primary worktree is on ${primaryBranch ?? "detached HEAD"}, not develop`
|
|
435
|
-
:
|
|
882
|
+
: verdict.unattributed.length > 0
|
|
883
|
+
? // ADR-0129 (F-0186): name the paths — the remedy differs by
|
|
884
|
+
// whose work each one is.
|
|
885
|
+
`primary worktree has ${verdict.unattributed.length} uncommitted change(s): ${verdict.unattributed
|
|
886
|
+
.slice(0, 20)
|
|
887
|
+
.map((line) => line.slice(3).trim())
|
|
888
|
+
.join(", ")}` +
|
|
889
|
+
(verdict.unattributed.length > 20
|
|
890
|
+
? ` (+${verdict.unattributed.length - 20} more)`
|
|
891
|
+
: "")
|
|
892
|
+
: `primary worktree held by ${verdict.foreignInFlight.length} in-flight foreign op(s)`) +
|
|
893
|
+
holderNote +
|
|
436
894
|
(verdict.tolerated.length > 0
|
|
437
895
|
? ` — tolerated regenerable state: ${verdict.tolerated.map((t) => `${t.path} (${t.class})`).join(", ")}`
|
|
438
896
|
: "") +
|
|
439
897
|
(lockfile === "importer-prune-only" ? ` — pnpm-lock.yaml${LOCKFILE_PRUNE_HINT}` : ""),
|
|
440
|
-
fixHint:
|
|
898
|
+
fixHint: primaryBranch !== "develop"
|
|
899
|
+
? "switch the primary to develop and commit or revert its tracked changes, then re-run — the branch stays rebased"
|
|
900
|
+
: `${FOREIGN_PRIMARY_DIRT_HINT}, then re-run`,
|
|
441
901
|
data: {
|
|
902
|
+
unattributed: verdict.unattributed.map((line) => line.slice(3).trim()),
|
|
442
903
|
entries: verdict.unattributed.map((line) => {
|
|
443
904
|
const path = line.slice(3).trim();
|
|
444
905
|
return { path, class: classifyDirtyPath(path) };
|
|
445
906
|
}),
|
|
907
|
+
foreignHolders: verdict.foreignInFlight.map((f) => ({
|
|
908
|
+
path: f.path,
|
|
909
|
+
opId: f.holder.opId,
|
|
910
|
+
command: f.holder.command,
|
|
911
|
+
pid: f.holder.pid,
|
|
912
|
+
startedAt: f.holder.startedAt,
|
|
913
|
+
})),
|
|
446
914
|
toleratedDirt: verdict.tolerated,
|
|
447
915
|
...(lockfile !== null ? { lockfileClassification: lockfile } : {}),
|
|
448
916
|
},
|
|
449
917
|
},
|
|
450
918
|
};
|
|
451
919
|
}
|
|
920
|
+
primaryClean = true;
|
|
921
|
+
break;
|
|
452
922
|
}
|
|
453
|
-
|
|
923
|
+
if (!primaryClean && primaryBranch !== "develop") {
|
|
454
924
|
return {
|
|
455
925
|
ok: false,
|
|
456
926
|
checked,
|
|
@@ -463,23 +933,17 @@ export async function runIntegratePreflight(opts, deps = { runGit: git, runStatu
|
|
|
463
933
|
},
|
|
464
934
|
};
|
|
465
935
|
}
|
|
466
|
-
// (3) ecosystem.manifest.validate — stale generated manifest
|
|
936
|
+
// (3) ecosystem.manifest.validate — stale generated manifest is a
|
|
937
|
+
// recoverable violation (RFC-1546): the failure is recorded and the
|
|
938
|
+
// remaining checks still run. Only when the drift is the SOLE violation
|
|
939
|
+
// does the owner command regenerate in place and the validator re-run —
|
|
940
|
+
// a coexisting refusal below must skip the regeneration entirely.
|
|
941
|
+
let manifestDrift;
|
|
467
942
|
if (resolvable("ecosystem.manifest.validate")) {
|
|
468
943
|
checked.push("ecosystem.manifest.validate");
|
|
469
944
|
const result = await opts.invoke("ecosystem.manifest.validate", {});
|
|
470
945
|
if (result.ok === false || (result.exitCode !== undefined && result.exitCode !== 0)) {
|
|
471
|
-
|
|
472
|
-
ok: false,
|
|
473
|
-
checked,
|
|
474
|
-
skipped,
|
|
475
|
-
tolerated,
|
|
476
|
-
refuse: {
|
|
477
|
-
ruleId: "FLOW-INT-12",
|
|
478
|
-
message: `preflight: ecosystem.manifest.validate refused — ${result.summary ?? `exit ${result.exitCode}`}`,
|
|
479
|
-
fixHint: "regenerate the manifest via `pnpm exec werkstatt run ecosystem.manifest.generate`, commit, then re-run flow.integrate",
|
|
480
|
-
data: { command: "ecosystem.manifest.validate", summary: result.summary },
|
|
481
|
-
},
|
|
482
|
-
};
|
|
946
|
+
manifestDrift = { summary: result.summary, exitCode: result.exitCode };
|
|
483
947
|
}
|
|
484
948
|
}
|
|
485
949
|
else {
|
|
@@ -501,7 +965,9 @@ export async function runIntegratePreflight(opts, deps = { runGit: git, runStatu
|
|
|
501
965
|
...new Set(diff.stdout
|
|
502
966
|
.split("\n")
|
|
503
967
|
.map((l) => /^docs\/rfcs\/(?:archive\/(?:implemented|rejected|superseded)\/)?rfc-(\d+)-[^/]*\.md$/.exec(l.trim())?.[1])
|
|
504
|
-
.
|
|
968
|
+
// rfc-0000-template.md is corpus-excluded (listRfcFiles) — it is a
|
|
969
|
+
// template, not a validateable RFC.
|
|
970
|
+
.filter((m) => m !== undefined && m !== "0000")
|
|
505
971
|
.map((n) => `RFC-${n.padStart(4, "0")}`)),
|
|
506
972
|
];
|
|
507
973
|
if (changedRfcIds.length > 0) {
|
|
@@ -557,10 +1023,40 @@ export async function runIntegratePreflight(opts, deps = { runGit: git, runStatu
|
|
|
557
1023
|
reason: opts.invoke === undefined ? "no-invoke" : "unresolvable",
|
|
558
1024
|
});
|
|
559
1025
|
}
|
|
1026
|
+
// RFC-1546: every other check passed — the manifest drift is the sole
|
|
1027
|
+
// violation, so the owner command regenerates in place and the validator
|
|
1028
|
+
// re-runs. A coexisting violation already refused above without ever
|
|
1029
|
+
// reaching the regeneration.
|
|
1030
|
+
if (manifestDrift !== undefined) {
|
|
1031
|
+
if (resolvable("ecosystem.manifest.generate")) {
|
|
1032
|
+
const regen = await opts.invoke("ecosystem.manifest.generate", REGEN_FLAGS["ecosystem.manifest.generate"] ?? {});
|
|
1033
|
+
if (regen.ok !== false && (regen.exitCode === undefined || regen.exitCode === 0)) {
|
|
1034
|
+
checked.push("ecosystem.manifest.generate", "ecosystem.manifest.validate");
|
|
1035
|
+
const result = await opts.invoke("ecosystem.manifest.validate", {});
|
|
1036
|
+
if (result.ok !== false && (result.exitCode === undefined || result.exitCode === 0)) {
|
|
1037
|
+
manifestDrift = undefined;
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
if (manifestDrift !== undefined) {
|
|
1042
|
+
return {
|
|
1043
|
+
ok: false,
|
|
1044
|
+
checked,
|
|
1045
|
+
skipped,
|
|
1046
|
+
tolerated,
|
|
1047
|
+
refuse: {
|
|
1048
|
+
ruleId: "FLOW-INT-12",
|
|
1049
|
+
message: `preflight: ecosystem.manifest.validate refused — ${manifestDrift.summary ?? `exit ${manifestDrift.exitCode}`}`,
|
|
1050
|
+
fixHint: "regenerate the manifest via `pnpm exec werkstatt run ecosystem.manifest.generate`, commit, then re-run flow.integrate",
|
|
1051
|
+
data: { command: "ecosystem.manifest.validate", summary: manifestDrift.summary },
|
|
1052
|
+
},
|
|
1053
|
+
};
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
560
1056
|
return { ok: true, checked, skipped, tolerated };
|
|
561
1057
|
}
|
|
562
1058
|
/** `.generated.` basenames whose owner command is fixed by convention. */
|
|
563
|
-
const GENERATED_BASENAME_OWNERS = {
|
|
1059
|
+
export const GENERATED_BASENAME_OWNERS = {
|
|
564
1060
|
"ecosystem.generated.yaml": "ecosystem.manifest.generate",
|
|
565
1061
|
"command-manifest.generated.yaml": "command.manifest.generate",
|
|
566
1062
|
};
|