@nodii/dev 0.6.221 → 0.6.223
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 +9 -1
- package/dist/core.js +1 -1
- package/dist/landed-check.js +487 -0
- package/dist/landed-report.js +97 -0
- package/dist/lanes.js +9 -0
- package/dist/surface.js +18 -1
- package/dist/upload.js +5 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -820,7 +820,13 @@ nodii-dev lane done-check KEY --evidence TEXT|URL
|
|
|
820
820
|
# run that exits after it ends finished, not orphaned; on a
|
|
821
821
|
# lane already on_dev (land → verify first) it is a no-op
|
|
822
822
|
# refused with FIGMA_AFTER_IMAGES_MISSING while an open change
|
|
823
|
-
# set the lane holds has a changed node with no after image
|
|
823
|
+
# set the lane holds has a changed node with no after image.
|
|
824
|
+
# O21 (DEV-PROCESS-12): both this and lane finish fetch origin in
|
|
825
|
+
# each repository the lane changes, run the landed check, and send
|
|
826
|
+
# Dev that machine report; Dev compares its refs with GitHub's and
|
|
827
|
+
# refuses LANE_BRANCH_NOT_LANDED (proposed) while a commit's change
|
|
828
|
+
# is not on main (patches, so a squash counts) or anything is
|
|
829
|
+
# uncommitted, untracked or stashed, one line per commit or path
|
|
824
830
|
nodii-dev lane finish KEY --reason TEXT --evidence TEXT|URL
|
|
825
831
|
# the lane's own agent marks the lane finished (MW1-28.2):
|
|
826
832
|
# why, and what it delivered and where its branch and
|
|
@@ -1023,6 +1029,8 @@ nodii-dev docs upload PATH... --class ruling|conformance|editorial
|
|
|
1023
1029
|
[--base CODE=VERSION ...] [--decision DECISION.json]
|
|
1024
1030
|
[--conformance-ref PR|REPO@SHA] [--meaning-unchanged REASON]
|
|
1025
1031
|
[--wait [--wait-minutes N]]
|
|
1032
|
+
# a ruling's DECISION.json: title, context, options, ruling, consequences,
|
|
1033
|
+
# provenance, ruledBy ("operator", the only value; P-22, DEV-DOC-9), amends
|
|
1026
1034
|
nodii-dev docs ratify --domain KEY [--domain KEY ...] --decision DECISION.json [--wait]
|
|
1027
1035
|
nodii-dev docs parked [CODE] [--status pending|acknowledged]
|
|
1028
1036
|
|
package/dist/core.js
CHANGED
|
@@ -4,7 +4,7 @@ import { chmod, lstat, mkdir, readFile, rename, rm, writeFile } from "node:fs/pr
|
|
|
4
4
|
import { homedir, platform } from "node:os";
|
|
5
5
|
import { basename, dirname, join } from "node:path";
|
|
6
6
|
|
|
7
|
-
export const VERSION = "0.6.
|
|
7
|
+
export const VERSION = "0.6.223";
|
|
8
8
|
export const configPath = () =>
|
|
9
9
|
process.env.NODII_DEV_CONFIG_PATH ??
|
|
10
10
|
join(homedir(), ".config/nodii-dev/config.json");
|
|
@@ -0,0 +1,487 @@
|
|
|
1
|
+
// DEV-PROCESS-12 / O21: a lane is done only when every commit's change on its branch is on main and its
|
|
2
|
+
// tree is clean. This is the Node port of the frozen drill oracle (evidence/o21/oracle.sh, which is never
|
|
3
|
+
// shipped here): same semantics, same line format, for ONE repo. A lane over several repos combines the
|
|
4
|
+
// per-repo answers with combineLandedChecks().
|
|
5
|
+
//
|
|
6
|
+
// The check never fetches: it judges the refs already present (refs/remotes/origin/main, the local branch
|
|
7
|
+
// and origin/<branch>). The caller fetches first with its own credentials. Git runs isolated from the
|
|
8
|
+
// caller's global and system config (only the caller's core.excludesFile is carried over), and never once
|
|
9
|
+
// per commit: patch-ids, file writes and trees come from a few batched streams.
|
|
10
|
+
//
|
|
11
|
+
// Output lines (as the oracle prints them):
|
|
12
|
+
// VERDICT LANDED|NOT-LANDED|ERROR
|
|
13
|
+
// REASON commit <sha> <subject>
|
|
14
|
+
// FILE +<add> -<del> <path>
|
|
15
|
+
// REASON stash <stash@{n}> <sha>
|
|
16
|
+
// REASON uncommitted <path>
|
|
17
|
+
// REASON untracked <path>
|
|
18
|
+
// REASON worktree on <other> not <branch>
|
|
19
|
+
// REASON branch not found
|
|
20
|
+
// REASON error <what>
|
|
21
|
+
// LANDED-BY content on main (merge-tree)
|
|
22
|
+
// INFO <text>
|
|
23
|
+
import { spawn } from "node:child_process";
|
|
24
|
+
import { stat } from "node:fs/promises";
|
|
25
|
+
import { basename } from "node:path";
|
|
26
|
+
|
|
27
|
+
const MAIN = "refs/remotes/origin/main";
|
|
28
|
+
|
|
29
|
+
class CheckError extends Error {}
|
|
30
|
+
const die = (what) => {
|
|
31
|
+
throw new CheckError(what);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
async function isDir(path) {
|
|
35
|
+
try {
|
|
36
|
+
return (await stat(path)).isDirectory();
|
|
37
|
+
} catch {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
async function isFile(path) {
|
|
42
|
+
try {
|
|
43
|
+
return (await stat(path)).isFile();
|
|
44
|
+
} catch {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
async function exists(path) {
|
|
49
|
+
try {
|
|
50
|
+
await stat(path);
|
|
51
|
+
return true;
|
|
52
|
+
} catch {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** Run one command; resolves { code, stdout } (never rejects on exit code; rejects on spawn failure). */
|
|
58
|
+
function run(cmd, args, { env, input, signal } = {}) {
|
|
59
|
+
return new Promise((resolve, reject) => {
|
|
60
|
+
const child = spawn(cmd, args, { env, stdio: ["pipe", "pipe", "ignore"], signal });
|
|
61
|
+
const out = [];
|
|
62
|
+
child.stdout.on("data", (d) => out.push(d));
|
|
63
|
+
child.on("error", reject);
|
|
64
|
+
child.on("close", (code, sig) => resolve({ code: code ?? (sig ? 128 : 1), stdout: Buffer.concat(out).toString("utf8") }));
|
|
65
|
+
child.stdin.on("error", () => {});
|
|
66
|
+
child.stdin.end(input ?? "");
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** Run `a | b` with pipefail semantics; resolves { code, stdout } of b, code = first non-zero. */
|
|
71
|
+
function runPipe(cmdA, argsA, cmdB, argsB, { env, signal } = {}) {
|
|
72
|
+
return new Promise((resolve, reject) => {
|
|
73
|
+
const a = spawn(cmdA, argsA, { env, stdio: ["ignore", "pipe", "ignore"], signal });
|
|
74
|
+
const b = spawn(cmdB, argsB, { env, stdio: ["pipe", "pipe", "ignore"], signal });
|
|
75
|
+
const out = [];
|
|
76
|
+
let codeA, codeB, failed = false;
|
|
77
|
+
const done = () => {
|
|
78
|
+
if (codeA === undefined || codeB === undefined) return;
|
|
79
|
+
resolve({ code: codeA || codeB, stdout: Buffer.concat(out).toString("utf8") });
|
|
80
|
+
};
|
|
81
|
+
const fail = (e) => {
|
|
82
|
+
if (failed) return;
|
|
83
|
+
failed = true;
|
|
84
|
+
try { a.kill(); } catch {}
|
|
85
|
+
try { b.kill(); } catch {}
|
|
86
|
+
reject(e);
|
|
87
|
+
};
|
|
88
|
+
a.on("error", fail);
|
|
89
|
+
b.on("error", fail);
|
|
90
|
+
b.stdin.on("error", () => {});
|
|
91
|
+
a.stdout.pipe(b.stdin);
|
|
92
|
+
b.stdout.on("data", (d) => out.push(d));
|
|
93
|
+
a.on("close", (code, sig) => { codeA = code ?? (sig ? 128 : 1); done(); });
|
|
94
|
+
b.on("close", (code, sig) => { codeB = code ?? (sig ? 128 : 1); done(); });
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const lines = (s) => {
|
|
99
|
+
const l = s.split("\n");
|
|
100
|
+
if (l.length && l[l.length - 1] === "") l.pop();
|
|
101
|
+
return l;
|
|
102
|
+
};
|
|
103
|
+
const firstLine = (s) => s.split("\n")[0];
|
|
104
|
+
|
|
105
|
+
/** Parse raw diff output (with commit-id lines) into [commit, "mode:blob"|"DEL", path] triples. */
|
|
106
|
+
function rawPairs(text) {
|
|
107
|
+
const res = [];
|
|
108
|
+
let c = "";
|
|
109
|
+
for (const l of lines(text)) {
|
|
110
|
+
let m;
|
|
111
|
+
if (/^[0-9a-f]+$/.test(l)) { c = l; continue; }
|
|
112
|
+
if ((m = /^C ([0-9a-f]+)$/.exec(l))) { c = m[1]; continue; }
|
|
113
|
+
if (l.startsWith(":")) {
|
|
114
|
+
const i = l.indexOf("\t");
|
|
115
|
+
const f = l.slice(0, i === -1 ? l.length : i).split(/[ \t]+/).filter(Boolean);
|
|
116
|
+
const b = /^0+$/.test(f[3] ?? "") ? "DEL" : `${f[1]}:${f[3]}`;
|
|
117
|
+
res.push([c, b, i === -1 ? "" : l.slice(i + 1)]);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return res;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const byteSortUnique = (arr) => {
|
|
124
|
+
const s = [...new Set(arr)];
|
|
125
|
+
return s.sort((x, y) => Buffer.compare(Buffer.from(x), Buffer.from(y)));
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Judge one repo for one lane branch.
|
|
130
|
+
* @param {object} o
|
|
131
|
+
* @param {string} o.worktree the lane's worktree path (may no longer exist)
|
|
132
|
+
* @param {string} o.branch the lane branch, e.g. "lane/s2"
|
|
133
|
+
* @param {string} [o.repo] where the refs live when the worktree is gone (default: the worktree)
|
|
134
|
+
* @param {object} [o.env] the caller's environment (default process.env); its core.excludesFile is honoured
|
|
135
|
+
* @param {AbortSignal} [o.signal] aborts the run (answers ERROR)
|
|
136
|
+
* @returns {Promise<{verdict: "LANDED"|"NOT-LANDED"|"ERROR", exitCode: 0|1|2, lines: string[],
|
|
137
|
+
* reasons: string[], landedBy: string|null, info: string[]}>}
|
|
138
|
+
* lines: the oracle's stdout lines exactly (VERDICT first); reasons: the REASON and FILE lines in order;
|
|
139
|
+
* info: the INFO lines (without "INFO ").
|
|
140
|
+
*/
|
|
141
|
+
export async function landedCheck({ worktree, branch, repo, env, signal } = {}) {
|
|
142
|
+
let out;
|
|
143
|
+
try {
|
|
144
|
+
out = await check({ worktree, branch, repo, env: env ?? process.env, signal });
|
|
145
|
+
} catch (e) {
|
|
146
|
+
let what;
|
|
147
|
+
if (e instanceof CheckError) what = e.message;
|
|
148
|
+
else if (e?.name === "AbortError") what = "aborted (timeout?)";
|
|
149
|
+
else what = `unexpected: ${e?.message ?? String(e)}`;
|
|
150
|
+
out = ["VERDICT ERROR", `REASON error ${what}`];
|
|
151
|
+
}
|
|
152
|
+
return shape(out);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function shape(out) {
|
|
156
|
+
const verdict = out[0].slice("VERDICT ".length);
|
|
157
|
+
return {
|
|
158
|
+
verdict,
|
|
159
|
+
exitCode: verdict === "LANDED" ? 0 : verdict === "NOT-LANDED" ? 1 : 2,
|
|
160
|
+
lines: out,
|
|
161
|
+
reasons: out.filter((l) => l.startsWith("REASON ") || l.startsWith(" FILE ")),
|
|
162
|
+
landedBy: out.find((l) => l.startsWith("LANDED-BY "))?.slice("LANDED-BY ".length) ?? null,
|
|
163
|
+
info: out.filter((l) => l.startsWith("INFO ")).map((l) => l.slice(5)),
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Combine per-repo answers for a lane over several repos, as the O21 drill does: one repo is its own
|
|
169
|
+
* answer; otherwise every repo that is not LANDED adds "REASON repo <name>" and its lines (VERDICT
|
|
170
|
+
* dropped). The verdict is ERROR if any repo errored (the drill would read it as NOT-LANDED), else
|
|
171
|
+
* NOT-LANDED if any repo is, else LANDED.
|
|
172
|
+
* @param {{repo: string, result: Awaited<ReturnType<typeof landedCheck>>}[]} parts
|
|
173
|
+
*/
|
|
174
|
+
export function combineLandedChecks(parts) {
|
|
175
|
+
if (parts.length === 1) return parts[0].result;
|
|
176
|
+
const body = [];
|
|
177
|
+
let anyErr = false, anyNot = false;
|
|
178
|
+
for (const { repo, result } of parts) {
|
|
179
|
+
if (result.exitCode === 0) continue;
|
|
180
|
+
if (result.verdict === "ERROR") anyErr = true;
|
|
181
|
+
else anyNot = true;
|
|
182
|
+
body.push(`REASON repo ${basename(repo)}`, ...result.lines.filter((l) => !l.startsWith("VERDICT ")));
|
|
183
|
+
}
|
|
184
|
+
return shape([`VERDICT ${anyErr ? "ERROR" : anyNot ? "NOT-LANDED" : "LANDED"}`, ...body]);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
async function check({ worktree, branch, repo, env: callerEnv, signal }) {
|
|
188
|
+
if (typeof worktree !== "string" || !worktree || typeof branch !== "string" || !branch || (repo != null && typeof repo !== "string")) {
|
|
189
|
+
die("usage: landedCheck({ worktree, branch[, repo] })");
|
|
190
|
+
}
|
|
191
|
+
const WT = worktree, BRANCH = branch, REPO = repo || worktree;
|
|
192
|
+
let CLONE, WT_PRESENT;
|
|
193
|
+
if (await isDir(WT)) { CLONE = WT; WT_PRESENT = true; }
|
|
194
|
+
else if (await isDir(REPO)) { CLONE = REPO; WT_PRESENT = false; }
|
|
195
|
+
else die(`neither worktree ${WT} nor repo ${REPO} exists`);
|
|
196
|
+
|
|
197
|
+
const baseEnv = { ...callerEnv };
|
|
198
|
+
delete baseEnv.GIT_DIR; delete baseEnv.GIT_WORK_TREE; delete baseEnv.GIT_INDEX_FILE;
|
|
199
|
+
|
|
200
|
+
let ver;
|
|
201
|
+
try {
|
|
202
|
+
ver = (await run("git", ["version"], { env: baseEnv, signal })).stdout.split(/\s+/)[2] ?? "";
|
|
203
|
+
} catch (e) {
|
|
204
|
+
if (e?.name === "AbortError") throw e;
|
|
205
|
+
die(`cannot run git: ${e?.message ?? e}`);
|
|
206
|
+
}
|
|
207
|
+
const [maj, min] = ver.split(".").map((n) => parseInt(n, 10));
|
|
208
|
+
if (!(maj > 2 || (maj === 2 && min >= 43))) die(`git ${ver} is older than 2.43 (merge-tree --merge-base, show-ref --exists)`);
|
|
209
|
+
|
|
210
|
+
const bareDir = !(await exists(`${CLONE}/.git`)) && (await isFile(`${CLONE}/HEAD`)) && (await isDir(`${CLONE}/objects`));
|
|
211
|
+
const GLOC = bareDir ? [`--git-dir=${CLONE}`] : ["-C", CLONE];
|
|
212
|
+
|
|
213
|
+
// The caller's core.excludesFile, before isolating from the global config.
|
|
214
|
+
const XF = lines((await run("git", [...GLOC, "config", "--type=path", "--get", "core.excludesFile"], { env: baseEnv, signal })).stdout)[0] ?? "";
|
|
215
|
+
|
|
216
|
+
const env = { ...baseEnv, GIT_CONFIG_NOSYSTEM: "1", GIT_CONFIG_GLOBAL: "/dev/null", GIT_TERMINAL_PROMPT: "0", LC_ALL: "C" };
|
|
217
|
+
const G = [...GLOC, "-c", "core.hooksPath=/dev/null", "-c", "diff.noprefix=false", "-c", "core.quotePath=false"];
|
|
218
|
+
const g = (args, input) => run("git", [...G, ...args], { env, input, signal });
|
|
219
|
+
/** g that must succeed; returns stdout. */
|
|
220
|
+
const gok = async (args, what, input) => {
|
|
221
|
+
const r = await g(args, input);
|
|
222
|
+
if (r.code !== 0) die(`${what ?? `git ${args[0]}`} failed (exit ${r.code})`);
|
|
223
|
+
return r.stdout;
|
|
224
|
+
};
|
|
225
|
+
const DIFFOPTS = ["--no-color", "--no-ext-diff", "--no-textconv", "--no-renames", "--full-index", "--binary"];
|
|
226
|
+
const pidStream = async (revs) => { // [[commit, patch-id]] per non-merge commit with a non-empty diff
|
|
227
|
+
const r = await runPipe("git", [...G, "log", "--no-merges", "-p", ...DIFFOPTS, "--format=commit %H", ...revs],
|
|
228
|
+
"git", [...GLOC, "patch-id", "--verbatim"], { env, signal });
|
|
229
|
+
if (r.code !== 0) die(`patch-id stream for ${revs.join(" ")} failed (exit ${r.code})`);
|
|
230
|
+
return lines(r.stdout).map((l) => { const [p, c] = l.split(" "); return [c, p]; });
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
if ((await g(["rev-parse", "--git-dir"])).code !== 0) die(`not a git repository: ${CLONE}`);
|
|
234
|
+
if ((await g(["rev-parse", "--verify", "--quiet", `${MAIN}^{commit}`])).code !== 0) die(`no origin/main in ${CLONE}`);
|
|
235
|
+
const mainTree = firstLine(await gok(["rev-parse", `${MAIN}^{tree}`]));
|
|
236
|
+
|
|
237
|
+
const reasons = [], info = [], named = new Set(), landedSingle = new Set(), mergeBaseOf = new Map();
|
|
238
|
+
if (!WT_PRESENT) info.push("INFO worktree missing");
|
|
239
|
+
const refs = [];
|
|
240
|
+
for (const r of [`refs/heads/${BRANCH}`, `refs/remotes/origin/${BRANCH}`]) {
|
|
241
|
+
const rc = (await g(["show-ref", "--exists", r])).code;
|
|
242
|
+
if (rc === 2) continue;
|
|
243
|
+
if (rc !== 0) die(`cannot check whether ${r} exists (git show-ref exit ${rc})`);
|
|
244
|
+
if ((await g(["rev-parse", "--verify", "--quiet", `${r}^{commit}`])).code !== 0) die(`cannot read ${r} (ref exists, its commit does not)`);
|
|
245
|
+
if ((await g(["cat-file", "-e", `${r}^{tree}`])).code !== 0) die(`cannot read the tree of ${r}`);
|
|
246
|
+
refs.push(r);
|
|
247
|
+
}
|
|
248
|
+
if (refs.length === 0) return ["VERDICT NOT-LANDED", "REASON branch not found", ...info];
|
|
249
|
+
if (refs.length === 1) info.push(`INFO only ${refs[0]} exists`);
|
|
250
|
+
else if (firstLine(await gok(["rev-parse", refs[0]])) !== firstLine(await gok(["rev-parse", refs[1]]))) {
|
|
251
|
+
info.push(`INFO local and origin ${BRANCH} differ; checking both`);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
let landedByTree = false;
|
|
255
|
+
for (const ref of refs) {
|
|
256
|
+
const first = lines(await gok(["rev-list", "--first-parent", "--reverse", ref, "--not", MAIN], "git rev-list"))[0];
|
|
257
|
+
if (!first) continue; // every commit of the ref is reachable from main
|
|
258
|
+
const forkR = await g(["rev-parse", "--verify", "--quiet", `${first}^`]);
|
|
259
|
+
const fork = forkR.code === 0 ? firstLine(forkR.stdout) : "";
|
|
260
|
+
if (!fork) die(`${ref} has no fork point with main (its history shares no commit with origin/main)`);
|
|
261
|
+
|
|
262
|
+
const [mainPidList, mainPairsText, brPidList, walkText, treesText, forkTreeText, forkTreeId] = await Promise.all([
|
|
263
|
+
pidStream([MAIN, "--not", fork]),
|
|
264
|
+
gok(["log", "--no-merges", "--raw", "--no-abbrev", "--no-renames", "--format=C %H", MAIN, "--not", fork], "git log --raw"),
|
|
265
|
+
pidStream([ref, "--not", MAIN]),
|
|
266
|
+
gok(["rev-list", "--reverse", "--topo-order", "--parents", ref, "--not", MAIN], "git rev-list"),
|
|
267
|
+
gok(["log", "--format=%H %T", ref, "--not", MAIN], "git log"),
|
|
268
|
+
gok(["ls-tree", "-r", "--full-tree", fork], "git ls-tree"),
|
|
269
|
+
gok(["rev-parse", `${fork}^{tree}`]),
|
|
270
|
+
]);
|
|
271
|
+
const mp = new Set(mainPidList.map(([, p]) => p));
|
|
272
|
+
const pid = new Map(brPidList);
|
|
273
|
+
const walk = lines(walkText).map((l) => l.split(" ").filter(Boolean));
|
|
274
|
+
const tr = new Map(lines(treesText).map((l) => l.split(" ")));
|
|
275
|
+
const stepInput = walk.map((w, i) => `${w[0]} ${i === 0 ? fork : walk[i - 1][0]}\n`).join("");
|
|
276
|
+
const stepsText = await gok(["diff-tree", "--stdin", "-r", "--raw", "--no-renames", "--no-abbrev"], "git diff-tree", stepInput);
|
|
277
|
+
const steps = new Map();
|
|
278
|
+
for (const [c, b, p] of rawPairs(stepsText)) {
|
|
279
|
+
if (!steps.has(c)) steps.set(c, []);
|
|
280
|
+
steps.get(c).push([p, b]);
|
|
281
|
+
}
|
|
282
|
+
const fk = new Map();
|
|
283
|
+
for (const l of lines(forkTreeText)) {
|
|
284
|
+
const i = l.indexOf("\t");
|
|
285
|
+
const f = l.slice(0, i).split(" ");
|
|
286
|
+
fk.set(l.slice(i + 1), `${f[0]}:${f[2]}`);
|
|
287
|
+
}
|
|
288
|
+
// Merges: clean (tree equals the automatic merge of its two parents) or with their own change.
|
|
289
|
+
const mg = new Map(), mfrom = new Map();
|
|
290
|
+
for (const [c, ...ps] of walk) {
|
|
291
|
+
if (ps.length < 2) continue;
|
|
292
|
+
if (ps.length === 2) {
|
|
293
|
+
const r = await g(["merge-tree", "--write-tree", ps[0], ps[1]]);
|
|
294
|
+
if (r.code > 1) die(`git merge-tree failed (exit ${r.code}) on merge ${c}`);
|
|
295
|
+
const auto = firstLine(r.stdout);
|
|
296
|
+
if (r.code === 0 && auto === tr.get(c)) { mg.set(c, "clean"); mfrom.set(c, "-"); }
|
|
297
|
+
else if (r.code === 0) { mg.set(c, "own"); mfrom.set(c, auto); }
|
|
298
|
+
else { mg.set(c, "own"); mfrom.set(c, ps[0]); }
|
|
299
|
+
} else { mg.set(c, "own"); mfrom.set(c, ps[0]); }
|
|
300
|
+
}
|
|
301
|
+
// What each main commit writes since the fork (first write of a path per commit wins).
|
|
302
|
+
const want = new Map(), need = new Map(), wl = new Map(), dsat = new Map(), full = new Map();
|
|
303
|
+
for (const [m, b, p] of rawPairs(mainPairsText)) {
|
|
304
|
+
if (!want.has(m)) want.set(m, new Map());
|
|
305
|
+
const wm = want.get(m);
|
|
306
|
+
if (wm.has(p)) continue;
|
|
307
|
+
wm.set(p, b);
|
|
308
|
+
need.set(m, (need.get(m) ?? 0) + 1);
|
|
309
|
+
if (!wl.has(p)) wl.set(p, []);
|
|
310
|
+
wl.get(p).push(m);
|
|
311
|
+
}
|
|
312
|
+
for (const m of need.keys()) dsat.set(m, 0);
|
|
313
|
+
|
|
314
|
+
// The walk (oldest first), keeping the branch's exact file state against the last landed point.
|
|
315
|
+
const cur = new Map(), bst = new Map();
|
|
316
|
+
let chg = new Set();
|
|
317
|
+
let base = fork, btree = firstLine(forkTreeId), pend = [], ndiff = 0;
|
|
318
|
+
const fst = (p) => fk.get(p) ?? "DEL";
|
|
319
|
+
const curv = (p) => (cur.has(p) ? cur.get(p) : fst(p));
|
|
320
|
+
const bv = (p) => (bst.has(p) ? bst.get(p) : fst(p));
|
|
321
|
+
const setd = (m, d) => {
|
|
322
|
+
const n = need.get(m);
|
|
323
|
+
if (dsat.get(m) === n) full.set(n, (full.get(n) ?? 0) - 1);
|
|
324
|
+
dsat.set(m, dsat.get(m) + d);
|
|
325
|
+
if (dsat.get(m) === n) full.set(n, (full.get(n) ?? 0) + 1);
|
|
326
|
+
};
|
|
327
|
+
const write = (p, b) => {
|
|
328
|
+
const old = curv(p);
|
|
329
|
+
if (old === b) return;
|
|
330
|
+
const bs = bv(p);
|
|
331
|
+
for (const m of wl.get(p) ?? []) {
|
|
332
|
+
const w = want.get(m).get(p);
|
|
333
|
+
const oc = old === w && old !== bs ? 1 : 0, nc = b === w && b !== bs ? 1 : 0;
|
|
334
|
+
if (oc !== nc) setd(m, nc - oc);
|
|
335
|
+
}
|
|
336
|
+
if (old !== bs && b === bs) ndiff--;
|
|
337
|
+
else if (old === bs && b !== bs) ndiff++;
|
|
338
|
+
chg.add(p);
|
|
339
|
+
cur.set(p, b);
|
|
340
|
+
};
|
|
341
|
+
const movebase = (c) => {
|
|
342
|
+
for (const p of chg) {
|
|
343
|
+
const cv = curv(p), bs = bv(p);
|
|
344
|
+
for (const m of wl.get(p) ?? []) if (cv === want.get(m).get(p) && cv !== bs) setd(m, -1);
|
|
345
|
+
bst.set(p, cv);
|
|
346
|
+
}
|
|
347
|
+
chg = new Set(); ndiff = 0; base = c; btree = tr.get(c);
|
|
348
|
+
};
|
|
349
|
+
const rangepid = async (a, b) => {
|
|
350
|
+
const r = await runPipe("git", [...G, "diff", ...DIFFOPTS, a, b], "git", [...GLOC, "patch-id", "--verbatim"], { env, signal });
|
|
351
|
+
if (r.code !== 0) die(`walk failed for ${ref}: ERROR range diff ${a}..${b} failed`);
|
|
352
|
+
return (lines(r.stdout)[0] ?? "").split(" ")[0];
|
|
353
|
+
};
|
|
354
|
+
for (const [c, ...ps] of walk) {
|
|
355
|
+
const p1 = ps[0] ?? "";
|
|
356
|
+
for (const [p, b] of steps.get(c) ?? []) write(p, b);
|
|
357
|
+
if (ps.length >= 2) {
|
|
358
|
+
if (mg.get(c) === "clean") {
|
|
359
|
+
info.push(`INFO ${c} is a clean merge on ${ref}; carries no change of its own`);
|
|
360
|
+
if (pend.length === 0) movebase(c);
|
|
361
|
+
continue;
|
|
362
|
+
}
|
|
363
|
+
if (!mergeBaseOf.has(c)) mergeBaseOf.set(c, mfrom.get(c));
|
|
364
|
+
info.push(`INFO ${c} is a merge with its own change on ${ref}`);
|
|
365
|
+
pend.push(c);
|
|
366
|
+
} else {
|
|
367
|
+
const st = !pid.has(c) ? "E" : mp.has(pid.get(c)) ? "M" : "N";
|
|
368
|
+
if (st !== "N") {
|
|
369
|
+
if (pend.length === 0) { movebase(c); continue; }
|
|
370
|
+
landedSingle.add(c);
|
|
371
|
+
}
|
|
372
|
+
pend.push(c);
|
|
373
|
+
if (pend.length === 1 && base === p1) continue;
|
|
374
|
+
}
|
|
375
|
+
if (tr.get(c) === btree) { pend = []; movebase(c); continue; }
|
|
376
|
+
if (ndiff > 0 && (full.get(ndiff) ?? 0) > 0) {
|
|
377
|
+
const r = await rangepid(base, c);
|
|
378
|
+
if (r !== "" && mp.has(r)) { pend = []; movebase(c); }
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
if (pend.length === 0) continue;
|
|
382
|
+
|
|
383
|
+
// Fallback: content check from the walk's last landed point.
|
|
384
|
+
const mt = await g(["merge-tree", "--write-tree", `--merge-base=${base}`, MAIN, ref]);
|
|
385
|
+
if (mt.code > 1) die(`git merge-tree failed (exit ${mt.code}) for ${ref} from ${base}`);
|
|
386
|
+
if (mt.code === 0 && firstLine(mt.stdout) === mainTree) { landedByTree = true; continue; }
|
|
387
|
+
|
|
388
|
+
// Name what is left, in walk order: non-merge commits in batches (one git log), merges one by one.
|
|
389
|
+
const toName = [];
|
|
390
|
+
for (const c of pend) if (!landedSingle.has(c) && !named.has(c) && !toName.includes(c)) toName.push(c);
|
|
391
|
+
for (const c of toName) named.add(c);
|
|
392
|
+
let batch = [];
|
|
393
|
+
const flush = async () => {
|
|
394
|
+
if (batch.length === 0) return;
|
|
395
|
+
const text = await gok(["log", "--no-walk=unsorted", "--stdin", "--numstat", "--no-renames", "--format=REASON commit %H %s"],
|
|
396
|
+
"git log --numstat", batch.map((c) => `${c}\n`).join(""));
|
|
397
|
+
for (const l of lines(text)) {
|
|
398
|
+
if (l.startsWith("REASON commit ")) { reasons.push(l); continue; }
|
|
399
|
+
const f = l.split("\t");
|
|
400
|
+
if (f.length === 3) reasons.push(` FILE +${f[0]} -${f[1]} ${f[2]}`);
|
|
401
|
+
}
|
|
402
|
+
batch = [];
|
|
403
|
+
};
|
|
404
|
+
for (const c of toName) {
|
|
405
|
+
const from = mergeBaseOf.get(c);
|
|
406
|
+
if (!from) { batch.push(c); continue; }
|
|
407
|
+
await flush();
|
|
408
|
+
const subj = (await gok(["log", "-1", "--format=%s", c], "git log -1")).replace(/\n+$/, "");
|
|
409
|
+
reasons.push(`REASON commit ${c} ${subj}`);
|
|
410
|
+
for (const l of lines(await gok(["diff", "--numstat", "--no-renames", from, c], "git diff --numstat"))) {
|
|
411
|
+
const i = l.indexOf("\t"), j = l.indexOf("\t", i + 1);
|
|
412
|
+
if (i === -1 || j === -1) continue;
|
|
413
|
+
reasons.push(` FILE +${l.slice(0, i)} -${l.slice(i + 1, j)} ${l.slice(j + 1)}`);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
await flush();
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
// Stash: only the lane's entries (refs/stash is shared by every worktree of a repo).
|
|
420
|
+
const isAnc = async (a, b) => (await g(["merge-base", "--is-ancestor", a, b])).code === 0;
|
|
421
|
+
const stashReasons = [];
|
|
422
|
+
if ((await g(["rev-parse", "--verify", "--quiet", "refs/stash"])).code === 0) {
|
|
423
|
+
const entries = lines(await gok(["log", "-g", "--format=%H %gs", "refs/stash"], "git log -g refs/stash"));
|
|
424
|
+
for (let n = 0; n < entries.length; n++) {
|
|
425
|
+
const sref = `stash@{${n}}`;
|
|
426
|
+
const m = /^[ \t]*(\S*)[ \t]*(.*?)[ \t]*$/.exec(entries[n]);
|
|
427
|
+
const sha = m[1], subj = m[2];
|
|
428
|
+
let mine = subj.startsWith(`On ${BRANCH}: `) || subj === `On ${BRANCH}:` || subj.startsWith(`WIP on ${BRANCH}: `) || subj === `WIP on ${BRANCH}:`;
|
|
429
|
+
if (!mine) {
|
|
430
|
+
const sb = await g(["rev-parse", "--verify", "--quiet", `${sha}^1`]);
|
|
431
|
+
const sbase = sb.code === 0 ? firstLine(sb.stdout) : "";
|
|
432
|
+
if (sbase) {
|
|
433
|
+
let onLane = false;
|
|
434
|
+
for (const r of refs) if (await isAnc(sbase, r)) { onLane = true; break; }
|
|
435
|
+
if (onLane && !(await isAnc(sbase, MAIN))) mine = true;
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
if (mine) stashReasons.push(`REASON stash ${sref} ${sha}`);
|
|
439
|
+
else info.push(`INFO stash ${sref} is not this lane's (${subj})`);
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
reasons.push(...byteSortUnique(stashReasons));
|
|
443
|
+
|
|
444
|
+
// Worktree: uncommitted, untracked (ignored excluded) and hidden-flag files.
|
|
445
|
+
if (WT_PRESENT && firstLine(await gok(["rev-parse", "--is-bare-repository"])) === "true") {
|
|
446
|
+
info.push("INFO no work tree");
|
|
447
|
+
} else if (WT_PRESENT) {
|
|
448
|
+
const hb = await g(["symbolic-ref", "--quiet", "--short", "HEAD"]);
|
|
449
|
+
const headBranch = hb.code === 0 ? firstLine(hb.stdout) : "(detached)";
|
|
450
|
+
if (headBranch !== BRANCH) {
|
|
451
|
+
reasons.push(`REASON worktree on ${headBranch} not ${BRANCH}`);
|
|
452
|
+
} else {
|
|
453
|
+
const sp = await g(["config", "--bool", "--get", "core.sparseCheckout"]);
|
|
454
|
+
const sparse = sp.code === 0 ? firstLine(sp.stdout) : "false";
|
|
455
|
+
const wtReasons = [];
|
|
456
|
+
const xargs = XF ? ["-c", `core.excludesFile=${XF}`] : [];
|
|
457
|
+
const status = await gok([...xargs, "status", "--porcelain=v1", "-z", "--untracked-files=all", "--no-renames"], "git status");
|
|
458
|
+
for (const line of status.split(/[\0\n]/)) {
|
|
459
|
+
if (!line) continue;
|
|
460
|
+
const xy = line.slice(0, 2), path = line.slice(3);
|
|
461
|
+
wtReasons.push(xy === "??" ? `REASON untracked ${path}` : `REASON uncommitted ${path}`);
|
|
462
|
+
}
|
|
463
|
+
const top = firstLine(await gok(["rev-parse", "--show-toplevel"]));
|
|
464
|
+
const flagged = await gok(["ls-files", "-v", "-z"], "git ls-files");
|
|
465
|
+
for (const line of flagged.split(/[\0\n]/)) {
|
|
466
|
+
if (!line) continue;
|
|
467
|
+
const tag = line[0], path = line.slice(2);
|
|
468
|
+
if (!(tag === "S" || (tag >= "a" && tag <= "z"))) continue;
|
|
469
|
+
const hr = await g(["rev-parse", "--verify", "--quiet", `HEAD:${path}`]);
|
|
470
|
+
const headBlob = hr.code === 0 ? firstLine(hr.stdout) : "";
|
|
471
|
+
if (!(await exists(`${top}/${path}`))) {
|
|
472
|
+
if (tag === "S" && sparse === "true") continue;
|
|
473
|
+
if (headBlob) wtReasons.push(`REASON uncommitted ${path}`);
|
|
474
|
+
continue;
|
|
475
|
+
}
|
|
476
|
+
const wtBlob = firstLine(await gok(["hash-object", `--path=${path}`, "--", `${top}/${path}`], "git hash-object"));
|
|
477
|
+
if (headBlob !== wtBlob) wtReasons.push(`REASON uncommitted ${path}`);
|
|
478
|
+
}
|
|
479
|
+
reasons.push(...byteSortUnique(wtReasons));
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
const res = [reasons.length ? "VERDICT NOT-LANDED" : "VERDICT LANDED", ...reasons];
|
|
484
|
+
if (landedByTree && named.size === 0) res.push("LANDED-BY content on main (merge-tree)");
|
|
485
|
+
res.push(...info);
|
|
486
|
+
return res;
|
|
487
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// DEV-PROCESS-12 / O21: the report `lane done-check` and `lane finish` send Dev. The CLI collects it
|
|
2
|
+
// mechanically on the lane's machine, for every repository the lane changes (its Dev record, never the
|
|
3
|
+
// lane's own text): it fetches origin with the machine's credentials, runs the landed check, and names
|
|
4
|
+
// the refs it judged so Dev can compare them with its own read of GitHub. Dev decides; this only reports.
|
|
5
|
+
import { execFile } from "node:child_process";
|
|
6
|
+
import { stat } from "node:fs/promises";
|
|
7
|
+
import { promisify } from "node:util";
|
|
8
|
+
import { VERSION } from "./core.js";
|
|
9
|
+
import { landedCheck } from "./landed-check.js";
|
|
10
|
+
|
|
11
|
+
const run = promisify(execFile);
|
|
12
|
+
const FETCH_TIMEOUT_MS = 120_000;
|
|
13
|
+
/** Dev's name for a lane judged on its own branch (lane_landed.ts OWN_BRANCH_REPO). */
|
|
14
|
+
export const OWN_BRANCH_REPO = "lane";
|
|
15
|
+
|
|
16
|
+
const isDir = async (path) => {
|
|
17
|
+
try {
|
|
18
|
+
return (await stat(path)).isDirectory();
|
|
19
|
+
} catch {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Where the repository's refs live when the lane's worktree is gone (S17): a lane worktree sits at
|
|
26
|
+
* <repo>/.claude/worktrees/<key>, so the repository is the path before that.
|
|
27
|
+
*/
|
|
28
|
+
export const repoOfWorktree = (worktree) => {
|
|
29
|
+
const at = worktree.indexOf("/.claude/worktrees/");
|
|
30
|
+
return at > 0 ? worktree.slice(0, at) : worktree;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const git = (dir, args, env) =>
|
|
34
|
+
run("git", ["-C", dir, ...args], { env: { ...env, GIT_TERMINAL_PROMPT: "0" }, timeout: FETCH_TIMEOUT_MS, maxBuffer: 1 << 20 });
|
|
35
|
+
|
|
36
|
+
const refSha = async (dir, ref, env) => {
|
|
37
|
+
try {
|
|
38
|
+
const { stdout } = await git(dir, ["rev-parse", "--verify", "--quiet", `${ref}^{commit}`], env);
|
|
39
|
+
return stdout.trim() || null;
|
|
40
|
+
} catch {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* One repository's report entry. A failed fetch is an ERROR: judging stale refs could land a lane
|
|
47
|
+
* whose pushed branch moved.
|
|
48
|
+
*/
|
|
49
|
+
export async function collectRepo({ repo, branch, worktree }, { env = process.env, check = landedCheck } = {}) {
|
|
50
|
+
const dir = (await isDir(worktree)) ? worktree : repoOfWorktree(worktree);
|
|
51
|
+
const base = { repo, branch, originMain: null, originBranch: null, localBranch: null };
|
|
52
|
+
if (!(await isDir(dir))) return { ...base, verdict: "ERROR", lines: [`REASON error neither worktree ${worktree} nor its repository exists`] };
|
|
53
|
+
try {
|
|
54
|
+
await git(dir, ["fetch", "--quiet", "--prune", "origin"], env);
|
|
55
|
+
} catch (error) {
|
|
56
|
+
const why = String(error?.stderr || error?.message || error).trim().split("\n").pop();
|
|
57
|
+
return { ...base, verdict: "ERROR", lines: [`REASON error git fetch origin failed: ${why}`.slice(0, 2_000)] };
|
|
58
|
+
}
|
|
59
|
+
const result = await check({ worktree, branch, repo: dir, env });
|
|
60
|
+
const [originMain, originBranch, localBranch] = await Promise.all([
|
|
61
|
+
refSha(dir, "refs/remotes/origin/main", env),
|
|
62
|
+
refSha(dir, `refs/remotes/origin/${branch}`, env),
|
|
63
|
+
refSha(dir, `refs/heads/${branch}`, env),
|
|
64
|
+
]);
|
|
65
|
+
return {
|
|
66
|
+
...base,
|
|
67
|
+
verdict: result.verdict,
|
|
68
|
+
lines: result.lines.filter((line) => !line.startsWith("VERDICT ")).map((line) => line.slice(0, 2_000)),
|
|
69
|
+
originMain,
|
|
70
|
+
originBranch,
|
|
71
|
+
localBranch,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* The report for a lane record from Dev (`GET /lanes/:id`): every repository but read-only ones, in
|
|
77
|
+
* order. Null when the lane changes no repository, so Dev has nothing to judge.
|
|
78
|
+
*/
|
|
79
|
+
export async function collectLandedReport(lane, options = {}) {
|
|
80
|
+
// Dev fills in one entry for a lane with no repository rows (repos[0], the lane's own branch and
|
|
81
|
+
// worktree); a stub lane names no repository, so it goes under the name Dev expects for it. A lane
|
|
82
|
+
// with no branch or worktree (a steward) has nothing to judge.
|
|
83
|
+
const repos = (lane?.repositories ?? [])
|
|
84
|
+
.filter((r) => !r.readOnly && r.branch && r.worktree)
|
|
85
|
+
.map((r) => ({ ...r, repo: r.repo || OWN_BRANCH_REPO }));
|
|
86
|
+
if (!repos.length) return null;
|
|
87
|
+
const entries = [];
|
|
88
|
+
// One at a time: each fetch and check is git-heavy, and the lane waits on the slowest anyway.
|
|
89
|
+
for (const r of repos) entries.push(await collectRepo(r, options));
|
|
90
|
+
return { collector: `nodii-dev@${VERSION}`, collectedAt: new Date().toISOString(), repos: entries };
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** The refusal lines a human reads when the CLI already sees the lane is not landed. */
|
|
94
|
+
export const reportProblems = (report) =>
|
|
95
|
+
(report?.repos ?? [])
|
|
96
|
+
.filter((r) => r.verdict !== "LANDED")
|
|
97
|
+
.flatMap((r) => [...(report.repos.length > 1 ? [`repo ${r.repo}`] : []), ...r.lines.filter((l) => /^\s*(REASON|FILE) /.test(l)).map((l) => l.replace(/^REASON /, ""))]);
|
package/dist/lanes.js
CHANGED
|
@@ -21,6 +21,7 @@ import { SWAP_BOUNDARIES, componentsForScope, guidelineLookup, laneFigmaScope, l
|
|
|
21
21
|
import { designCheck } from "./design.js";
|
|
22
22
|
import { LANE_ENV_FIX, laneConfigName, laneEnvProblem, laneEnvReport } from "./lane-env.js";
|
|
23
23
|
import { closeoutLane } from "./closeout.js";
|
|
24
|
+
import { collectLandedReport } from "./landed-report.js";
|
|
24
25
|
import { assertLaneOnThisMachine, endLane } from "./lane-pause.js";
|
|
25
26
|
import { isProcessAlive, readWatchedRuns } from "./watchdog.js";
|
|
26
27
|
import { GATES_RECEIPT, REVIEW_FILE, REVIEW_LAST, REVIEW_LOOP, checkLines, checkReviewChecks, citationText, diffDigest, findingId, laneDiff, privateStore, repoGeneratedPaths, reviewGates, runBody, runLaneCheck, runOutcome, treatChecks, treatable, worktreeCommitted } from "./review.js";
|
|
@@ -1047,6 +1048,11 @@ export async function laneCommand(action, args, flags, deps = {}) {
|
|
|
1047
1048
|
// A lane whose done check already counts has nothing more to record, so it is not held.
|
|
1048
1049
|
const current = (await request("GET", `/api/v1/lanes/${encode(id)}`)).data;
|
|
1049
1050
|
if (!doneCheckRecorded(current)) await assertLaneAfterImages(ref, current, { request });
|
|
1051
|
+
// DEV-PROCESS-12 (O21): Dev refuses unless every commit's change is on main and nothing is
|
|
1052
|
+
// uncommitted, judged from this machine report, never from the evidence text.
|
|
1053
|
+
// Always: a later done check is judged afresh, so work added after the first one counts.
|
|
1054
|
+
const landed = await collectLandedReport(current);
|
|
1055
|
+
if (landed) body.landed = landed;
|
|
1050
1056
|
let payload;
|
|
1051
1057
|
try {
|
|
1052
1058
|
payload = await request("POST", `/api/v1/lanes/${encode(id)}/evidence`, body);
|
|
@@ -1078,6 +1084,9 @@ export async function laneCommand(action, args, flags, deps = {}) {
|
|
|
1078
1084
|
evidence: text("evidence", 8_000, "TEXT|URL: what the lane delivered and where its branch and commits went."),
|
|
1079
1085
|
...via,
|
|
1080
1086
|
};
|
|
1087
|
+
// DEV-PROCESS-12 (O21): the same machine report as done-check; Dev refuses while work is left.
|
|
1088
|
+
const landed = await collectLandedReport((await request("GET", `/api/v1/lanes/${encode(id)}`)).data);
|
|
1089
|
+
if (landed) body.landed = landed;
|
|
1081
1090
|
const payload = await request("POST", `/api/v1/lanes/${encode(id)}/finish`, body);
|
|
1082
1091
|
return { payload, human: `${ref}: recorded finished. Its coordinator can close it with nodii-dev lane close ${ref} --reason TEXT.` };
|
|
1083
1092
|
}
|
package/dist/surface.js
CHANGED
|
@@ -34,7 +34,8 @@ import { MIN_FIGMA_INTERVAL_MS, figmaRest } from "./figma-rest.js";
|
|
|
34
34
|
import { createRenderer } from "./vendor/render-templates.mjs";
|
|
35
35
|
|
|
36
36
|
/** Bumped whenever the emitted code changes shape for the same inputs. */
|
|
37
|
-
|
|
37
|
+
// 67 (NODII-DEV-CLI-322): a Table Rich Cell whose text differs across rows reads it from the row (text={row.<column>Text}).
|
|
38
|
+
export const GENERATOR_FORMAT = 67;
|
|
38
39
|
/**
|
|
39
40
|
* DS parts that are an item of their parent's own list or grid, so they take no sizing
|
|
40
41
|
* wrapper: a Detail Section / Row's facts are the section grid's cells, a Right Pane / Row
|
|
@@ -4400,6 +4401,22 @@ function tableOf(node, ctx) {
|
|
|
4400
4401
|
secondaryKeys.add(secondary);
|
|
4401
4402
|
open = open.replace(new RegExp(`\\bsecondary=(${LITERAL})`), `secondary={row.${secondary}}`);
|
|
4402
4403
|
}
|
|
4404
|
+
// A Rich Cell's text is row data when the rows draw different texts; one
|
|
4405
|
+
// text on every row is the frame's own copy (NODII-DEV-CLI-322).
|
|
4406
|
+
const textAttr = new RegExp(`\\btext=(${LITERAL})`);
|
|
4407
|
+
if (/^<TableCell\b/.test(open) && textAttr.test(open)) {
|
|
4408
|
+
const texts = new Set(dataRows.map((p) => {
|
|
4409
|
+
const own = p.cells[i]?.code ?? "";
|
|
4410
|
+
return textAttr.exec(own.slice(0, openTagEnd(own) + 1))?.[1] ?? null;
|
|
4411
|
+
}));
|
|
4412
|
+
if (texts.size > 1) {
|
|
4413
|
+
const base = `${keys[i]}Text`;
|
|
4414
|
+
let field = base;
|
|
4415
|
+
for (let n = 2; secondaryKeys.has(field); n++) field = `${base}${n}`;
|
|
4416
|
+
secondaryKeys.add(field);
|
|
4417
|
+
open = open.replace(textAttr, `text={row.${field}}`);
|
|
4418
|
+
}
|
|
4419
|
+
}
|
|
4403
4420
|
if (invalidPii.has(i)) return indent(`${open}${comment(`unmapped: ${invalidPii.get(i)}`)}${close}`, depth + 4);
|
|
4404
4421
|
if (piiColumn[i]) {
|
|
4405
4422
|
const nullable = nullablePii.get(i);
|
package/dist/upload.js
CHANGED
|
@@ -201,9 +201,13 @@ export async function docsCommand(action, args, flags, { request = devRequest, l
|
|
|
201
201
|
if (flags["no-embed"] !== undefined && action !== "upload")
|
|
202
202
|
throw new CliError("USAGE", "--no-embed is valid only with docs upload.", 2);
|
|
203
203
|
const decision = await readJsonFile(flags.decision, "decision");
|
|
204
|
-
if (cls === "ruling" && !decision) throw new CliError("RULING_NEEDS_DECISION", "A ruling write needs its decision: --decision DECISION.json (title, context, options, ruling, consequences, provenance, amends).", 2);
|
|
204
|
+
if (cls === "ruling" && !decision) throw new CliError("RULING_NEEDS_DECISION", "A ruling write needs its decision: --decision DECISION.json (title, context, options, ruling, consequences, provenance, ruledBy, amends).", 2);
|
|
205
205
|
if (cls !== "ruling" && decision) throw new CliError("DECISION_NEEDS_RULING", "--decision goes with --class ruling only.", 2);
|
|
206
206
|
if (decision && !decision.amends?.length) throw new CliError("AMENDS_EMPTY", "A decision whose amends list is empty is refused (M05-13).", 2);
|
|
207
|
+
// NODII-DEV-CLI-315 (P-22): Dev reads who ruled from this field, never the provenance text.
|
|
208
|
+
if (decision && !decision.ruledBy) throw new CliError("DECISION_RULED_BY_REQUIRED", 'A ruling names who ruled it: "ruledBy": "operator" in DECISION.json, the operator, whose statement the provenance quotes (P-22, DEV-DOC-9). Only an operator ruling settles a review finding (P-21).', 2);
|
|
209
|
+
// Review f-fa5afdb6 (DEV-DOC-9): only the operator rules, so a ruling is recorded only from an operator statement.
|
|
210
|
+
if (decision && decision.ruledBy !== "operator") throw new CliError("DECISION_RULED_BY_NOT_OPERATOR", `"ruledBy": ${JSON.stringify(decision.ruledBy)} in DECISION.json: only the operator rules, so a ruling is recorded only from an operator statement (P-22, DEV-DOC-9, MW4-27). A lane, steward or coordinator's own call is not a ruling; take the question to the operator.`, 2);
|
|
207
211
|
if (cls === "editorial" && flags["meaning-unchanged"] === true) throw new CliError("USAGE", "--meaning-unchanged needs a reason.", 2);
|
|
208
212
|
if (flags["conformance-ref"] === true) throw new CliError("USAGE", "--conformance-ref needs a value: a PR or REPO@SHA.", 2);
|
|
209
213
|
const docs = await checkDocuments(args, cwd);
|