@bluenyang/reins 0.2.0 → 0.3.0-rc.2
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 +50 -203
- package/cli/dist/commands/config-models.js +206 -127
- package/cli/dist/commands/config.js +104 -16
- package/cli/dist/commands/configure.js +166 -134
- package/cli/dist/commands/install.js +161 -217
- package/cli/dist/commands/migrate.js +23 -48
- package/cli/dist/commands/update.js +203 -30
- package/cli/dist/lib/agents-md.js +111 -0
- package/cli/dist/lib/bindings.js +227 -386
- package/cli/dist/lib/detect.js +7 -2
- package/cli/dist/lib/generate.js +56 -75
- package/cli/dist/lib/harness.js +0 -3
- package/cli/dist/lib/migrate-plan.js +3 -3
- package/cli/dist/lib/prompter.js +4 -4
- package/cli/dist/lib/reader.js +20 -0
- package/cli/dist/lib/upstream.js +0 -17
- package/cli/dist/lib/vendor-write.js +9 -56
- package/cli/dist/reins.js +59 -270
- package/docs/README.ko.md +31 -204
- package/harness/CHANGELOG.md +8 -3
- package/harness/VERSION +1 -1
- package/harness/models.yaml +8 -0
- package/harness/policy/common-red-lines.yaml +4 -4
- package/harness/roles/advisor.md +10 -14
- package/harness/roles/auditor.md +17 -0
- package/harness/roles/executor.md +32 -0
- package/harness/roles/implementer.md +23 -21
- package/harness/roles/pl.md +44 -21
- package/harness/roles/planner.md +17 -19
- package/harness/roles/pm.md +16 -21
- package/harness/schemas/bindings.schema.json +55 -0
- package/harness/schemas/install.schema.json +1 -2
- package/harness/schemas/intent.schema.json +1 -13
- package/harness/templates/agents-md-blocks.md +52 -17
- package/harness/templates/audit.md +25 -0
- package/harness/templates/history.md +14 -0
- package/harness/templates/intent.md +5 -0
- package/harness/templates/spec.md +4 -2
- package/package.json +1 -2
- package/skills/audit/SKILL.md +28 -0
- package/skills/implement/SKILL.md +30 -0
- package/skills/intent/SKILL.md +28 -0
- package/skills/merge/SKILL.md +26 -0
- package/skills/onboard/SKILL.md +31 -0
- package/skills/reins-setup/SKILL.md +16 -25
- package/skills/release/SKILL.md +26 -0
- package/skills/retro/SKILL.md +30 -0
- package/skills/review/SKILL.md +27 -0
- package/skills/roadmap/SKILL.md +29 -0
- package/skills/spec/SKILL.md +27 -0
- package/skills/test/SKILL.md +26 -0
- package/cli/dist/commands/check.js +0 -379
- package/cli/dist/commands/gate.js +0 -136
- package/cli/dist/commands/knowledge.js +0 -111
- package/cli/dist/commands/metrics.js +0 -138
- package/cli/dist/commands/new.js +0 -190
- package/cli/dist/commands/retro.js +0 -7
- package/cli/dist/commands/stages.js +0 -562
- package/cli/dist/commands/status.js +0 -281
- package/cli/dist/lib/enforcement.js +0 -125
- package/cli/dist/lib/memory.js +0 -96
- package/cli/dist/lib/metrics.js +0 -223
- package/cli/dist/lib/retro.js +0 -179
- package/cli/dist/lib/verdict.js +0 -15
- package/cli/dist/lib/work.js +0 -106
- package/cli/dist/scripts/enforcement.js +0 -24
- package/harness/policy/budget.yaml +0 -13
- package/harness/policy/enforcement.yaml +0 -98
- package/harness/policy/stops.yaml +0 -29
- package/harness/policy/transitions.yaml +0 -13
- package/harness/roles/code-review.md +0 -27
- package/harness/roles/deploy.md +0 -50
- package/harness/roles/docs.md +0 -19
- package/harness/roles/lookup.md +0 -22
- package/harness/roles/qa-design.md +0 -22
- package/harness/roles/qa-run.md +0 -19
- package/harness/roles/verify-tool.md +0 -21
- package/harness/schemas/bindings-local.schema.json +0 -21
- package/harness/schemas/bus-request.schema.json +0 -17
- package/harness/schemas/bus-response.schema.json +0 -14
- package/harness/schemas/enforcement.schema.json +0 -22
- package/harness/schemas/plan.schema.json +0 -10
- package/harness/schemas/ticket.schema.json +0 -15
- package/harness/templates/bus/request.yaml +0 -20
- package/harness/templates/bus/response.yaml +0 -10
- package/harness/templates/plan.md +0 -23
- package/harness/templates/ticket.md +0 -29
- package/skills/reins-implement/SKILL.md +0 -20
- package/skills/reins-intent/SKILL.md +0 -26
- package/skills/reins-loop/SKILL.md +0 -26
- package/skills/reins-loop/references/vendor-cli.md +0 -41
- package/skills/reins-release/SKILL.md +0 -18
- package/skills/reins-retro/SKILL.md +0 -20
- package/skills/reins-review/SKILL.md +0 -23
- package/skills/reins-roadmap/SKILL.md +0 -17
- package/skills/reins-spec/SKILL.md +0 -22
- package/skills/reins-test/SKILL.md +0 -18
|
@@ -1,562 +0,0 @@
|
|
|
1
|
-
import { existsSync, readFileSync, readdirSync } from 'node:fs';
|
|
2
|
-
import { isAbsolute, join, relative, sep } from 'node:path';
|
|
3
|
-
import { roleStates } from '../lib/bindings.js';
|
|
4
|
-
import { isWithin, realPath } from '../lib/fsx.js';
|
|
5
|
-
import { harnessDir, readYaml } from '../lib/harness.js';
|
|
6
|
-
import { checkDoc, dispatchLines, readRelease, readReleaseDocs } from '../lib/release.js';
|
|
7
|
-
import { loadSchemas, validateFile } from '../lib/schema.js';
|
|
8
|
-
import { compound } from './gate.js';
|
|
9
|
-
import { approvedBy, busFor, historyPages, intentFile, intentIds, openTickets, recordedDecisions, ticketFile, } from '../lib/work.js';
|
|
10
|
-
const str = (v) => (typeof v === 'string' ? v : '');
|
|
11
|
-
const list = (v) => (Array.isArray(v) ? v.map(String) : []);
|
|
12
|
-
const mentions = (text, id) => new RegExp(`(?<![\\w-])${id.replace(/[-]/g, '\\-')}(?![\\w-])`).test(text);
|
|
13
|
-
/** Words of a phrase, for matching an ask against recorded decisions. */
|
|
14
|
-
function words(s) {
|
|
15
|
-
return new Set(s
|
|
16
|
-
.toLowerCase()
|
|
17
|
-
.split(/[^\p{L}\p{N}]+/u)
|
|
18
|
-
.filter((w) => w.length >= 3 || /\p{Script=Hangul}/u.test(w)));
|
|
19
|
-
}
|
|
20
|
-
/** A recorded decision whose every word appears in the ask — the question was probably answered before. */
|
|
21
|
-
function answeredBefore(root, ask) {
|
|
22
|
-
const a = words(ask);
|
|
23
|
-
return recordedDecisions(root).filter(({ decision }) => {
|
|
24
|
-
const d = [...words(decision)];
|
|
25
|
-
return d.length > 0 && d.every((w) => a.has(w));
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
/** The intent → spec → plan chain a ticket stands on (design §4: approved ∧ accepted ∧ reviewed). */
|
|
29
|
-
function approvalChain(root, intent, ticket) {
|
|
30
|
-
const out = [];
|
|
31
|
-
const i = intentFile(root, intent, 'intent');
|
|
32
|
-
if (!i)
|
|
33
|
-
return [
|
|
34
|
-
{
|
|
35
|
-
reason: 'B3',
|
|
36
|
-
verdict: 'HOLD',
|
|
37
|
-
message: `ticket ${ticket} belongs to intent ${intent}, which has no intent.md`,
|
|
38
|
-
resume: 'write the intent with the user (reins-intent) or move the ticket to its intent',
|
|
39
|
-
},
|
|
40
|
-
];
|
|
41
|
-
if (i.data['status'] !== 'approved')
|
|
42
|
-
out.push({
|
|
43
|
-
reason: 'B3',
|
|
44
|
-
verdict: 'HOLD',
|
|
45
|
-
path: i.path,
|
|
46
|
-
message: `intent ${intent} is ${str(i.data['status']) || 'without a status'} — only the user approves an intent`,
|
|
47
|
-
resume: 'show the intent to the user; on approval set status: approved, add approvals: [{role: user, at}] and commit with an Approved-by: trailer',
|
|
48
|
-
});
|
|
49
|
-
else {
|
|
50
|
-
if (!hasUser(i.data['approvals']))
|
|
51
|
-
out.push({
|
|
52
|
-
reason: 'B3',
|
|
53
|
-
verdict: 'HOLD',
|
|
54
|
-
path: i.path,
|
|
55
|
-
message: 'intent approvals: has no user entry',
|
|
56
|
-
resume: 'record the user approval: approvals: [{role: user, at: <date>}]',
|
|
57
|
-
});
|
|
58
|
-
if (approvedBy(root, i.path).length === 0)
|
|
59
|
-
out.push({
|
|
60
|
-
reason: 'B3',
|
|
61
|
-
verdict: 'HOLD',
|
|
62
|
-
path: i.path,
|
|
63
|
-
message: 'the approval is not recorded in git (no commit with an Approved-by: trailer)',
|
|
64
|
-
resume: 'commit the status change with the trailer "Approved-by: <user>"',
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
const s = intentFile(root, intent, 'spec');
|
|
68
|
-
if (s?.data['status'] !== 'accepted')
|
|
69
|
-
out.push({
|
|
70
|
-
reason: 'B3',
|
|
71
|
-
verdict: 'HOLD',
|
|
72
|
-
path: s?.path,
|
|
73
|
-
message: s
|
|
74
|
-
? `spec of intent ${intent} is ${str(s.data['status'])}, not accepted`
|
|
75
|
-
: `intent ${intent} has no spec.md`,
|
|
76
|
-
resume: 'planner writes spec.md → pm and qa-design review → the user sees summary_for_user and does not veto (R64)',
|
|
77
|
-
});
|
|
78
|
-
const p = intentFile(root, intent, 'plan');
|
|
79
|
-
if (!p || !['reviewed', 'active'].includes(str(p.data['status'])))
|
|
80
|
-
out.push({
|
|
81
|
-
reason: 'F2',
|
|
82
|
-
verdict: 'STOP',
|
|
83
|
-
path: p?.path,
|
|
84
|
-
message: p
|
|
85
|
-
? `plan of intent ${intent} is ${str(p.data['status'])}, not reviewed`
|
|
86
|
-
: `intent ${intent} has no plan.md`,
|
|
87
|
-
resume: 'pl writes plan.md, qa-design reviews it lightly, then status: reviewed',
|
|
88
|
-
});
|
|
89
|
-
else if (!list(p.data['tickets']).includes(ticket))
|
|
90
|
-
out.push({
|
|
91
|
-
reason: 'P2',
|
|
92
|
-
verdict: 'STOP',
|
|
93
|
-
path: p.path,
|
|
94
|
-
message: `ticket ${ticket} is not in the plan's tickets:`,
|
|
95
|
-
resume: 'add it to plan.md (order of work + tickets:) in the same commit, or drop the ticket',
|
|
96
|
-
});
|
|
97
|
-
return out;
|
|
98
|
-
}
|
|
99
|
-
function hasUser(approvals) {
|
|
100
|
-
return (Array.isArray(approvals) &&
|
|
101
|
-
approvals.some((a) => a?.['role'] === 'user'));
|
|
102
|
-
}
|
|
103
|
-
/** T1 — before a ticket starts. */
|
|
104
|
-
export function ticketStart(root, id) {
|
|
105
|
-
const t = ticketFile(root, id);
|
|
106
|
-
if (!t)
|
|
107
|
-
return [
|
|
108
|
-
{
|
|
109
|
-
reason: 'F2',
|
|
110
|
-
verdict: 'STOP',
|
|
111
|
-
message: `no ticket ${id} in .loctx/ticket/`,
|
|
112
|
-
resume: 'pl creates it from plan.md (one order-of-work item = one ticket)',
|
|
113
|
-
},
|
|
114
|
-
];
|
|
115
|
-
const findings = [];
|
|
116
|
-
const dir = harnessDir(root);
|
|
117
|
-
const v = dir ? loadSchemas(dir).get('ticket') : undefined;
|
|
118
|
-
if (v)
|
|
119
|
-
for (const i of validateFile(v, join(root, t.path)))
|
|
120
|
-
findings.push({
|
|
121
|
-
reason: 'F2',
|
|
122
|
-
verdict: 'STOP',
|
|
123
|
-
path: t.path,
|
|
124
|
-
message: `ticket: ${i.message}`,
|
|
125
|
-
resume: 'fix the frontmatter to match ticket.schema.json',
|
|
126
|
-
});
|
|
127
|
-
findings.push(...approvalChain(root, str(t.data['intent']), id));
|
|
128
|
-
for (const ask of list(t.data['asks'])) {
|
|
129
|
-
const prior = answeredBefore(root, ask);
|
|
130
|
-
findings.push({
|
|
131
|
-
reason: 'B1',
|
|
132
|
-
verdict: 'HOLD',
|
|
133
|
-
path: t.path,
|
|
134
|
-
message: prior.length
|
|
135
|
-
? `open ask "${ask}" — possibly answered already: ${prior.map((p) => `${p.decision} (${p.path})`).join('; ')}`
|
|
136
|
-
: `open ask "${ask}"`,
|
|
137
|
-
resume: prior.length
|
|
138
|
-
? "read the recorded decision; if it answers the ask, move it to the ticket's decisions section and clear asks:"
|
|
139
|
-
: "ask the user; record the answer in the ticket's decisions section and clear asks:",
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
const history = historyPages(root);
|
|
143
|
-
for (const dep of list(t.data['depends'])) {
|
|
144
|
-
const d = ticketFile(root, dep);
|
|
145
|
-
if (d && d.data['status'] !== 'done')
|
|
146
|
-
findings.push({
|
|
147
|
-
reason: 'F2',
|
|
148
|
-
verdict: 'STOP',
|
|
149
|
-
path: t.path,
|
|
150
|
-
message: `depends on ${dep}, which is ${str(d.data['status'])}`,
|
|
151
|
-
resume: `finish ${dep} first`,
|
|
152
|
-
});
|
|
153
|
-
else if (!d && !history.some((h) => mentions(h.text, dep)))
|
|
154
|
-
findings.push({
|
|
155
|
-
reason: 'F2',
|
|
156
|
-
verdict: 'STOP',
|
|
157
|
-
path: t.path,
|
|
158
|
-
message: `depends on ${dep}, which is neither open nor recorded as done in history`,
|
|
159
|
-
resume: `check the id; a finished ticket has a line in .loctx/history/`,
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
const role = str(t.data['role']);
|
|
163
|
-
if (dir) {
|
|
164
|
-
const roleFile = join(dir, 'roles', `${role}.md`);
|
|
165
|
-
const bindingsPath = join(dir, 'bindings.yaml');
|
|
166
|
-
const bound = existsSync(bindingsPath)
|
|
167
|
-
? (readYaml(bindingsPath).roles ?? {})
|
|
168
|
-
: null;
|
|
169
|
-
if (!existsSync(roleFile))
|
|
170
|
-
findings.push({
|
|
171
|
-
reason: 'F2',
|
|
172
|
-
verdict: 'STOP',
|
|
173
|
-
path: t.path,
|
|
174
|
-
message: `role "${role}" does not exist (roles: ${readdirSync(join(dir, 'roles'))
|
|
175
|
-
.map((f) => f.replace(/\.md$/, ''))
|
|
176
|
-
.join(', ')})`,
|
|
177
|
-
resume: 'set role: to one of the harness roles',
|
|
178
|
-
});
|
|
179
|
-
else if (bound && !(role in bound))
|
|
180
|
-
findings.push({
|
|
181
|
-
reason: 'F2',
|
|
182
|
-
verdict: 'STOP',
|
|
183
|
-
path: '.agents/harness/bindings.yaml',
|
|
184
|
-
message: `role "${role}" has no binding`,
|
|
185
|
-
resume: `reins configure bindings --set ${role}=<model>`,
|
|
186
|
-
});
|
|
187
|
-
else {
|
|
188
|
-
// an off role is not refused yet (the loop's stage cutting is 0.2); the covering role does the work.
|
|
189
|
-
// F2: a check without its own stop id reports as F2 (design §3)
|
|
190
|
-
const st = roleStates(root).states.get(role);
|
|
191
|
-
if (st && !st.enabled)
|
|
192
|
-
findings.push({
|
|
193
|
-
reason: 'F2',
|
|
194
|
-
verdict: 'WARN',
|
|
195
|
-
path: t.path,
|
|
196
|
-
message: `role ${role} is off — covered by ${st.covered_by ?? 'the next role in the chain'}`,
|
|
197
|
-
resume: `reins configure bindings --enable ${role} [--local], or let ${st.covered_by ?? 'the next role'} do it`,
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
return findings;
|
|
202
|
-
}
|
|
203
|
-
/** What a raw evidence text says: the command line (`$ cmd`) and the exit code (`exit N`). */
|
|
204
|
-
export function readEvidence(root, evidence) {
|
|
205
|
-
const tokens = evidence.split(/\s+/).filter(Boolean);
|
|
206
|
-
// an absolute path inside the repository reads like a relative one; outside it is refused
|
|
207
|
-
// macOS: tmpdir() is /var/... while git reports /private/var/...; Windows: RUNNER~1 vs the long name
|
|
208
|
-
const real = realPath;
|
|
209
|
-
const inside = (t) => isWithin(real(root), real(t));
|
|
210
|
-
const outside = tokens.filter((t) => isAbsolute(t) && !inside(t));
|
|
211
|
-
const resolve = (t) => (isAbsolute(t) ? t : join(root, t));
|
|
212
|
-
const files = tokens.length > 0 && tokens.every((t) => existsSync(resolve(t)));
|
|
213
|
-
const pieces = outside.length > 0
|
|
214
|
-
? outside.map((t) => ({ source: t, text: '', outside: true }))
|
|
215
|
-
: files
|
|
216
|
-
? tokens.map((t) => ({
|
|
217
|
-
source: isAbsolute(t) ? relative(real(root), real(t)).split(sep).join('/') : t,
|
|
218
|
-
text: readFileSync(resolve(t), 'utf8'),
|
|
219
|
-
}))
|
|
220
|
-
: [{ source: 'inline', text: evidence }];
|
|
221
|
-
return pieces.map((p) => {
|
|
222
|
-
const empty = !p.outside &&
|
|
223
|
-
p.text
|
|
224
|
-
.split(/\r?\n/)
|
|
225
|
-
.filter((l) => !l.startsWith('$ ') && !/^exit[: =]?\s*-?\d+\s*$/i.test(l))
|
|
226
|
-
.join('')
|
|
227
|
-
.trim() === '';
|
|
228
|
-
const code = /^exit[: =]?\s*(-?\d+)\s*$/im.exec(p.text)?.[1];
|
|
229
|
-
return {
|
|
230
|
-
...p,
|
|
231
|
-
empty,
|
|
232
|
-
cmd: /^\$ (.+)$/m.exec(p.text)?.[1]?.trim(),
|
|
233
|
-
exit: code === undefined ? undefined : Number(code),
|
|
234
|
-
};
|
|
235
|
-
});
|
|
236
|
-
}
|
|
237
|
-
/** T3 — at a gate or test verdict: the latest verification of a ticket must be a real pass. */
|
|
238
|
-
export function verdictCheck(root, id) {
|
|
239
|
-
const bus = busFor(root, id);
|
|
240
|
-
const unreadable = bus.flatMap((b) => b.broken);
|
|
241
|
-
if (unreadable.length > 0)
|
|
242
|
-
return unreadable.map((u) => ({
|
|
243
|
-
reason: 'F2',
|
|
244
|
-
verdict: 'STOP',
|
|
245
|
-
path: u.path,
|
|
246
|
-
message: `bus file is not valid YAML: ${u.message}`,
|
|
247
|
-
resume: 'quote values containing ": " or " #" in double quotes, then re-run the check',
|
|
248
|
-
}));
|
|
249
|
-
const verifies = bus.filter((b) => b.request?.['kind'] === 'verify');
|
|
250
|
-
if (verifies.length === 0)
|
|
251
|
-
return [
|
|
252
|
-
{
|
|
253
|
-
reason: 'D5',
|
|
254
|
-
verdict: 'STOP',
|
|
255
|
-
message: `ticket ${id} has no verification exchange in .loctx/bus/`,
|
|
256
|
-
resume: 'pl sends a verify request; verify-tool runs the gates and answers with raw evidence',
|
|
257
|
-
},
|
|
258
|
-
];
|
|
259
|
-
const findings = [];
|
|
260
|
-
const last = verifies.at(-1);
|
|
261
|
-
const dir = harnessDir(root);
|
|
262
|
-
const schemas = dir ? loadSchemas(dir) : undefined;
|
|
263
|
-
const bad = [];
|
|
264
|
-
for (const [kind, name] of [
|
|
265
|
-
['request', 'bus-request'],
|
|
266
|
-
['response', 'bus-response'],
|
|
267
|
-
]) {
|
|
268
|
-
const v = schemas?.get(name);
|
|
269
|
-
const rel = `.loctx/bus/${last.id}.${kind}.yaml`;
|
|
270
|
-
if (v && last[kind])
|
|
271
|
-
for (const i of validateFile(v, join(root, rel), true))
|
|
272
|
-
bad.push({
|
|
273
|
-
reason: 'F2',
|
|
274
|
-
verdict: 'STOP',
|
|
275
|
-
path: rel,
|
|
276
|
-
message: `${name}: ${i.message}`,
|
|
277
|
-
resume: 'fix the bus file against its schema, then re-run the check',
|
|
278
|
-
});
|
|
279
|
-
}
|
|
280
|
-
if (bad.length > 0)
|
|
281
|
-
return bad;
|
|
282
|
-
if (!last.response)
|
|
283
|
-
return [
|
|
284
|
-
{
|
|
285
|
-
reason: 'D5',
|
|
286
|
-
verdict: 'STOP',
|
|
287
|
-
path: `.loctx/bus/${last.id}.request.yaml`,
|
|
288
|
-
message: 'verification requested but not answered',
|
|
289
|
-
resume: 'verify-tool answers it with a response file',
|
|
290
|
-
},
|
|
291
|
-
];
|
|
292
|
-
// D1: consecutive failed rounds at the tail; a pass resets the counter
|
|
293
|
-
let fails = 0;
|
|
294
|
-
for (const b of verifies.toReversed()) {
|
|
295
|
-
if (b.response?.['verdict'] !== 'fail')
|
|
296
|
-
break;
|
|
297
|
-
fails++;
|
|
298
|
-
}
|
|
299
|
-
if (fails >= 2)
|
|
300
|
-
findings.push({
|
|
301
|
-
reason: 'D1',
|
|
302
|
-
verdict: 'ESCALATE',
|
|
303
|
-
message: `${fails} failed verification rounds in a row for ${id}`,
|
|
304
|
-
resume: 'the next role in the chain (pl → pm → advisor → user) finds the root cause',
|
|
305
|
-
});
|
|
306
|
-
else if (fails === 1)
|
|
307
|
-
findings.push({
|
|
308
|
-
reason: 'D1',
|
|
309
|
-
verdict: 'WARN',
|
|
310
|
-
path: `.loctx/bus/${last.id}.response.yaml`,
|
|
311
|
-
message: 'the latest verification failed (round 1 of 2)',
|
|
312
|
-
resume: 'fix and verify again; a second failure escalates',
|
|
313
|
-
});
|
|
314
|
-
if (last.response['verdict'] !== 'pass')
|
|
315
|
-
return findings;
|
|
316
|
-
const at = `.loctx/bus/${last.id}.response.yaml`;
|
|
317
|
-
const ev = str(last.response['evidence']);
|
|
318
|
-
if (!ev.trim())
|
|
319
|
-
findings.push({
|
|
320
|
-
reason: 'D5',
|
|
321
|
-
verdict: 'STOP',
|
|
322
|
-
path: at,
|
|
323
|
-
message: 'pass without evidence',
|
|
324
|
-
resume: 'attach the raw gate output (a .loctx/reports/ path or the text itself)',
|
|
325
|
-
});
|
|
326
|
-
else
|
|
327
|
-
for (const e of readEvidence(root, ev)) {
|
|
328
|
-
const at2 = e.source === 'inline' ? at : `${at} → ${e.source}`;
|
|
329
|
-
if (e.outside) {
|
|
330
|
-
findings.push({
|
|
331
|
-
reason: 'D5',
|
|
332
|
-
verdict: 'STOP',
|
|
333
|
-
path: at2,
|
|
334
|
-
message: 'evidence path outside the repository',
|
|
335
|
-
resume: 'copy the gate output under .loctx/reports/ and cite that path',
|
|
336
|
-
});
|
|
337
|
-
continue;
|
|
338
|
-
}
|
|
339
|
-
if (e.empty)
|
|
340
|
-
findings.push({
|
|
341
|
-
reason: 'D4',
|
|
342
|
-
verdict: 'WARN',
|
|
343
|
-
path: at2,
|
|
344
|
-
message: 'gate output is empty',
|
|
345
|
-
resume: 'check that the gate produced output; attach it unabridged',
|
|
346
|
-
});
|
|
347
|
-
if (e.exit === undefined)
|
|
348
|
-
findings.push({
|
|
349
|
-
reason: 'D4',
|
|
350
|
-
verdict: 'STOP',
|
|
351
|
-
path: at2,
|
|
352
|
-
message: 'evidence has no exit code line ("exit N")',
|
|
353
|
-
resume: 're-run the gate unmodified and keep its exit code',
|
|
354
|
-
});
|
|
355
|
-
else if (e.exit !== 0)
|
|
356
|
-
findings.push({
|
|
357
|
-
reason: 'D4',
|
|
358
|
-
verdict: 'STOP',
|
|
359
|
-
path: at2,
|
|
360
|
-
message: `reported as pass, but the evidence exits ${e.exit}`,
|
|
361
|
-
resume: 'a non-zero exit is a failure; answer fail',
|
|
362
|
-
});
|
|
363
|
-
if (!e.cmd)
|
|
364
|
-
findings.push({
|
|
365
|
-
reason: 'D4',
|
|
366
|
-
verdict: 'STOP',
|
|
367
|
-
path: at2,
|
|
368
|
-
message: 'evidence does not show the command that ran ("$ <cmd>")',
|
|
369
|
-
resume: 're-run the gate from gates.yaml and keep the command line',
|
|
370
|
-
});
|
|
371
|
-
else if (compound(e.cmd))
|
|
372
|
-
findings.push({
|
|
373
|
-
reason: 'D4',
|
|
374
|
-
verdict: 'STOP',
|
|
375
|
-
path: at2,
|
|
376
|
-
message: `the gate did not run as a single command: ${e.cmd}`,
|
|
377
|
-
resume: 'run the gate exactly as gates.yaml declares it (C5)',
|
|
378
|
-
});
|
|
379
|
-
}
|
|
380
|
-
return findings;
|
|
381
|
-
}
|
|
382
|
-
/** T5 — an rc closes: every planned ticket of the release's intents is done and recorded. */
|
|
383
|
-
export function rcClose(root, release, stable = false) {
|
|
384
|
-
if (!release)
|
|
385
|
-
return [
|
|
386
|
-
{
|
|
387
|
-
reason: 'F2',
|
|
388
|
-
verdict: 'STOP',
|
|
389
|
-
message: 'rc-close needs the release version (--release <version>)',
|
|
390
|
-
},
|
|
391
|
-
];
|
|
392
|
-
const intents = intentIds(root).filter((id) => {
|
|
393
|
-
const i = intentFile(root, id, 'intent');
|
|
394
|
-
return i?.data['status'] === 'approved' && String(i.data['version']) === release;
|
|
395
|
-
});
|
|
396
|
-
if (intents.length === 0)
|
|
397
|
-
return [
|
|
398
|
-
{
|
|
399
|
-
reason: 'F2',
|
|
400
|
-
verdict: 'STOP',
|
|
401
|
-
message: `no approved intent has version ${release}`,
|
|
402
|
-
resume: 'check the version, or set version: in the intents this release bundles',
|
|
403
|
-
},
|
|
404
|
-
];
|
|
405
|
-
const findings = [];
|
|
406
|
-
const history = historyPages(root);
|
|
407
|
-
const open = openTickets(root);
|
|
408
|
-
for (const id of intents) {
|
|
409
|
-
const p = intentFile(root, id, 'plan');
|
|
410
|
-
const planned = list(p?.data['tickets']);
|
|
411
|
-
if (!p || planned.length === 0) {
|
|
412
|
-
findings.push({
|
|
413
|
-
reason: 'F2',
|
|
414
|
-
verdict: 'STOP',
|
|
415
|
-
path: p?.path,
|
|
416
|
-
message: `intent ${id} has no planned tickets`,
|
|
417
|
-
resume: 'plan.md tickets: lists one id per order-of-work item',
|
|
418
|
-
});
|
|
419
|
-
continue;
|
|
420
|
-
}
|
|
421
|
-
for (const t of planned) {
|
|
422
|
-
const f = open.find((o) => o.data['id'] === t);
|
|
423
|
-
if (f)
|
|
424
|
-
findings.push({
|
|
425
|
-
reason: 'F2',
|
|
426
|
-
verdict: 'STOP',
|
|
427
|
-
path: f.path,
|
|
428
|
-
message: `ticket ${t} is still open (${str(f.data['status'])})`,
|
|
429
|
-
resume: 'finish it, write its history line, then delete the ticket file',
|
|
430
|
-
});
|
|
431
|
-
else if (!history.some((h) => mentions(h.text, t)))
|
|
432
|
-
findings.push({
|
|
433
|
-
reason: 'F2',
|
|
434
|
-
verdict: 'STOP',
|
|
435
|
-
message: `ticket ${t} is gone but no history page mentions it`,
|
|
436
|
-
resume: 'write what was done in .loctx/history/',
|
|
437
|
-
});
|
|
438
|
-
}
|
|
439
|
-
for (const o of open)
|
|
440
|
-
if (o.data['intent'] === id && !planned.includes(str(o.data['id'])))
|
|
441
|
-
findings.push({
|
|
442
|
-
reason: 'P2',
|
|
443
|
-
verdict: 'STOP',
|
|
444
|
-
path: o.path,
|
|
445
|
-
message: `ticket ${str(o.data['id'])} is not in the plan of intent ${id}`,
|
|
446
|
-
resume: 'add it to plan.md (departure log) or close it',
|
|
447
|
-
});
|
|
448
|
-
}
|
|
449
|
-
if (findings.length === 0)
|
|
450
|
-
findings.push(...(stable ? noRcRecorded(root, release) : nextRc(root, release)));
|
|
451
|
-
if (findings.every((f) => f.verdict === 'WARN'))
|
|
452
|
-
findings.push(...(stable ? stableFindings(root, release) : dispatchFindings(root, findings)));
|
|
453
|
-
findings.push(...docsFindings(root, release, stable ? 'stable' : 'rc'));
|
|
454
|
-
return findings;
|
|
455
|
-
}
|
|
456
|
-
/** One F2 WARN per `release.docs` file that still describes the previous state (S-7); never a STOP. */
|
|
457
|
-
export function docsFindings(root, release, stage) {
|
|
458
|
-
const out = [];
|
|
459
|
-
for (const d of readReleaseDocs(root)) {
|
|
460
|
-
let text = null;
|
|
461
|
-
try {
|
|
462
|
-
text = readFileSync(join(root, d.file), 'utf8');
|
|
463
|
-
}
|
|
464
|
-
catch {
|
|
465
|
-
// missing, a directory or unreadable: the same advisory warning, and the other documents are still checked
|
|
466
|
-
}
|
|
467
|
-
if (text !== null && checkDoc(text, d.check, release, stage))
|
|
468
|
-
continue;
|
|
469
|
-
out.push({
|
|
470
|
-
reason: 'F2',
|
|
471
|
-
verdict: 'WARN',
|
|
472
|
-
path: d.file,
|
|
473
|
-
message: `docs: ${d.file} still describes the previous state (${d.check})`,
|
|
474
|
-
});
|
|
475
|
-
}
|
|
476
|
-
return out;
|
|
477
|
-
}
|
|
478
|
-
/** The rc dispatch lines (S-3) from install.yaml `release:`; the rc number comes from the ledger finding. */
|
|
479
|
-
function dispatchFindings(root, found) {
|
|
480
|
-
const rc = found.map((f) => /^next rc: (\S+)$/.exec(f.message)?.[1]).find(Boolean);
|
|
481
|
-
const ws = readRelease(root);
|
|
482
|
-
if (!rc || !ws)
|
|
483
|
-
return [
|
|
484
|
-
{
|
|
485
|
-
reason: 'F2',
|
|
486
|
-
verdict: 'WARN',
|
|
487
|
-
message: 'no release settings (install.yaml has no release:) — merge only',
|
|
488
|
-
},
|
|
489
|
-
];
|
|
490
|
-
const lines = dispatchLines(ws, 'rc', rc);
|
|
491
|
-
if (lines.length === 0)
|
|
492
|
-
return [
|
|
493
|
-
{ reason: 'F2', verdict: 'WARN', message: 'no release workflow is set for the rc stage' },
|
|
494
|
-
];
|
|
495
|
-
return [
|
|
496
|
-
...lines.map((l) => ({ reason: 'F2', verdict: 'WARN', message: `dispatch: ${l}` })),
|
|
497
|
-
{
|
|
498
|
-
reason: 'F2',
|
|
499
|
-
verdict: 'WARN',
|
|
500
|
-
message: "stable: rerun with --stable on the user's instruction",
|
|
501
|
-
},
|
|
502
|
-
];
|
|
503
|
-
}
|
|
504
|
-
/** The stable dispatch lines (S-9): printed only under --stable, labelled so an agent does not run them unasked. */
|
|
505
|
-
function stableFindings(root, release) {
|
|
506
|
-
const ws = readRelease(root);
|
|
507
|
-
if (!ws)
|
|
508
|
-
return [
|
|
509
|
-
{
|
|
510
|
-
reason: 'F2',
|
|
511
|
-
verdict: 'WARN',
|
|
512
|
-
message: 'no release settings (install.yaml has no release:) — merge only',
|
|
513
|
-
},
|
|
514
|
-
];
|
|
515
|
-
const lines = dispatchLines(ws, 'stable', release);
|
|
516
|
-
if (lines.length === 0)
|
|
517
|
-
return [
|
|
518
|
-
{ reason: 'F2', verdict: 'WARN', message: 'no release workflow is set for the stable stage' },
|
|
519
|
-
];
|
|
520
|
-
return lines.map((l) => ({
|
|
521
|
-
reason: 'F2',
|
|
522
|
-
verdict: 'WARN',
|
|
523
|
-
message: `dispatch (stable — user's instruction only, A2): ${l}`,
|
|
524
|
-
}));
|
|
525
|
-
}
|
|
526
|
-
/** A stable normally follows an rc: WARN when the ledger records none. */
|
|
527
|
-
function noRcRecorded(root, release) {
|
|
528
|
-
const path = join(root, '.loctx', 'release', `${release}.md`);
|
|
529
|
-
const has = existsSync(path) && /^\s*[-*]\s*rc\.\d+\b/m.test(readFileSync(path, 'utf8'));
|
|
530
|
-
return has
|
|
531
|
-
? []
|
|
532
|
-
: [{ reason: 'F2', verdict: 'WARN', path, message: `no rc recorded for ${release}` }];
|
|
533
|
-
}
|
|
534
|
-
/**
|
|
535
|
-
* The next rc number from the local ledger `.loctx/release/<V>.md` (one `- rc.N …` line per rc):
|
|
536
|
-
* rc.1 when there is no ledger, else the last recorded rc + 1. A number already recorded is F2.
|
|
537
|
-
*/
|
|
538
|
-
function nextRc(root, release) {
|
|
539
|
-
const path = join(root, '.loctx', 'release', `${release}.md`);
|
|
540
|
-
const recorded = existsSync(path)
|
|
541
|
-
? [...readFileSync(path, 'utf8').matchAll(/^\s*[-*]\s*rc\.(\d+)\b/gm)].map((m) => Number(m[1]))
|
|
542
|
-
: [];
|
|
543
|
-
const next = (recorded.at(-1) ?? 0) + 1;
|
|
544
|
-
if (recorded.includes(next))
|
|
545
|
-
return [
|
|
546
|
-
{
|
|
547
|
-
reason: 'F2',
|
|
548
|
-
verdict: 'STOP',
|
|
549
|
-
path,
|
|
550
|
-
message: `${release}-rc.${next} is already recorded`,
|
|
551
|
-
resume: 'a version number is never reused; fix the ledger order or record the later rc last',
|
|
552
|
-
},
|
|
553
|
-
];
|
|
554
|
-
return [
|
|
555
|
-
{
|
|
556
|
-
reason: 'F2',
|
|
557
|
-
verdict: 'WARN',
|
|
558
|
-
path: existsSync(path) ? path : undefined,
|
|
559
|
-
message: `next rc: ${release}-rc.${next}`,
|
|
560
|
-
},
|
|
561
|
-
];
|
|
562
|
-
}
|