@williacj/rigger 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +370 -2
- package/package.json +56 -4
- package/scripts/doc-reference-check.mjs +59 -0
- package/scripts/gate-check.mjs +249 -0
- package/scripts/lib/pack-result.mjs +9 -0
- package/scripts/record-commit.mjs +67 -0
- package/src/cli/doctor.mjs +1021 -0
- package/src/cli/init.mjs +384 -0
- package/src/cli/once.mjs +489 -0
- package/src/cli/pause.mjs +56 -0
- package/src/cli/plan.mjs +106 -0
- package/src/cli/recording.mjs +52 -0
- package/src/cli/report.mjs +242 -0
- package/src/cli/resume.mjs +96 -0
- package/src/cli/rigger.mjs +12 -0
- package/src/cli/run.mjs +10 -0
- package/src/cli/setup-board.mjs +108 -0
- package/src/cli/verbs.mjs +82 -0
- package/src/cli/verdict.mjs +180 -0
- package/src/config/validate.mjs +960 -0
- package/src/execution/groups.mjs +185 -0
- package/src/execution/kept-output.mjs +21 -0
- package/src/execution/role.mjs +171 -0
- package/src/execution/run.mjs +490 -0
- package/src/execution/step.mjs +26 -0
- package/src/execution/workspace.mjs +866 -0
- package/src/observation/push.mjs +103 -0
- package/src/observation/report.mjs +415 -0
- package/src/observation/sink.mjs +271 -0
- package/src/package-commit.json +1 -0
- package/src/scheduling/admission.mjs +390 -0
- package/src/scheduling/clock.mjs +98 -0
- package/src/scheduling/lane.mjs +160 -0
- package/src/scheduling/loop.mjs +1738 -0
- package/src/scheduling/pull-order.mjs +46 -0
- package/src/substrate/data-ref.mjs +147 -0
- package/src/substrate/forge/assets.mjs +5 -0
- package/src/substrate/forge/graphql.mjs +258 -0
- package/src/substrate/forge/item-write.mjs +74 -0
- package/src/substrate/forge/read.mjs +998 -0
- package/src/substrate/forge/repository-write.mjs +152 -0
- package/src/substrate/forge/runners.mjs +510 -0
- package/src/substrate/forge/schema-write.mjs +70 -0
- package/src/substrate/forge/write-made.mjs +40 -0
- package/src/substrate/git-environment.mjs +54 -0
- package/src/substrate/host.mjs +23 -0
- package/src/substrate/launchd.mjs +23 -0
- package/src/substrate/process-table.sh +48 -0
- package/src/substrate/process.mjs +2474 -0
- package/src/substrate/providers/adapters.mjs +8 -0
- package/src/substrate/providers/claude.mjs +427 -0
- package/src/substrate/providers/codex.mjs +349 -0
- package/src/substrate/standard-error.mjs +134 -0
- package/src/substrate/worktrees.mjs +517 -0
- package/src/workflow/clock-mark.mjs +40 -0
- package/src/workflow/escalation.mjs +110 -0
- package/src/workflow/facts.mjs +92 -0
- package/src/workflow/first-above.mjs +17 -0
- package/src/workflow/form-check.mjs +88 -0
- package/src/workflow/gate.mjs +62 -0
- package/src/workflow/judges.mjs +695 -0
- package/src/workflow/marker.mjs +265 -0
- package/src/workflow/next-action.mjs +456 -0
- package/src/workflow/status-issue.mjs +268 -0
- package/src/workflow/transitions.mjs +588 -0
- package/templates/claude/agents/architect.md +116 -0
- package/templates/claude/agents/engineer.md +57 -0
- package/templates/claude/agents/pm.md +114 -0
- package/templates/claude/agents/reviewer.md +37 -0
- package/templates/claude/agents/spike-engineer.md +80 -0
- package/templates/claude/hooks/refuse-reserved-git-commands.mjs +909 -0
- package/templates/claude/settings.json +50 -0
- package/templates/claude/skills/acceptance/SKILL.md +275 -0
- package/templates/claude/skills/agent-style/SKILL.md +78 -0
- package/templates/claude/skills/code-review/SKILL.md +242 -0
- package/templates/claude/skills/proposal/SKILL.md +175 -0
- package/templates/claude/skills/spec-style/SKILL.md +112 -0
- package/templates/claude/skills/tdd/SKILL.md +230 -0
- package/templates/codex/config.toml +19 -0
- package/templates/doc-reference-check.md +25 -0
- package/templates/githooks/pre-push +24 -0
- package/templates/github/workflows/rigger-gate.yml +209 -0
- package/templates/launchd/com.williacj.rigger.plist +31 -0
- package/templates/rigger.config.mjs +78 -0
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
// ABOUTME: L2's status issue: the title, body and comment a hold's notice writes, the hold's id
|
|
2
|
+
// parsed back from them, and the notice function, phased so that L3 makes every rename it answers,
|
|
3
|
+
// which also follows the notice on an issue a closer names and closes the status issues for `resume`.
|
|
4
|
+
|
|
5
|
+
import { FIXED_LABELS } from '../config/validate.mjs';
|
|
6
|
+
|
|
7
|
+
import { WRITERS } from './marker.mjs';
|
|
8
|
+
import { firstAbove } from './first-above.mjs';
|
|
9
|
+
|
|
10
|
+
/** The status issue's title (`R-SCHED-20`). */
|
|
11
|
+
export const TITLE = 'Rigger closed admission';
|
|
12
|
+
|
|
13
|
+
/** The line naming a hold's id, which `holdOf` parses back. */
|
|
14
|
+
const holdLine = (id) => `Hold: \`${id}\``;
|
|
15
|
+
|
|
16
|
+
/** What failed in an attempt, as L2's failure names it: a step, the maker, the workspace or the judge. */
|
|
17
|
+
const failedPart = (failure) => (failure.step !== undefined ? `step \`${failure.step}\``
|
|
18
|
+
: failure.maker !== undefined ? `maker \`${failure.maker}\`` : failure.judge !== undefined ? `judge \`${failure.judge}\`` : failure.workspace !== undefined ? 'workspace' : 'dispatch');
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The status issue's body for hold `id`: its closer's `reason` and `run`, and, where it is opened at
|
|
22
|
+
* the hold, from L2's `hold` answer, the failing card, each attempt's class and what failed, the
|
|
23
|
+
* dispatch ids of the attempts that recorded one, and `admission`, the admission directory's path.
|
|
24
|
+
*/
|
|
25
|
+
export function holdBody({ id, reason, run, hold, admission }) {
|
|
26
|
+
const attempts = hold === undefined ? [] : [hold.firstFailure, hold.failure];
|
|
27
|
+
const dispatches = attempts.map((failure) => failure?.dispatch).filter((dispatch) => dispatch !== undefined);
|
|
28
|
+
const lines = [
|
|
29
|
+
...(hold === undefined ? [] : [`- Card: #${hold.card}`]),
|
|
30
|
+
...attempts.map((failure, at) => `- Attempt ${at + 1}: ${failure.class}, ${failedPart(failure)}`),
|
|
31
|
+
...(dispatches.length === 0 ? [] : [`- Dispatch ids: ${dispatches.join(', ')}`]),
|
|
32
|
+
`- Run: ${run}`,
|
|
33
|
+
...(admission === undefined ? [] : [`- Admission record: ${admission}`]),
|
|
34
|
+
];
|
|
35
|
+
return `${TITLE}: ${reason}\n\n${lines.join('\n')}\n\n${holdLine(id)}\n`;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* The comment for hold `id` on a status issue already open (`R-SCHED-25`): its closer's `reason`,
|
|
40
|
+
* and the failing `card` where the hold names one.
|
|
41
|
+
*/
|
|
42
|
+
export const holdComment = ({ id, reason, card }) => `Rigger closed admission again: ${reason}\n\n${card === undefined ? '' : `- Card: #${card}\n\n`}${holdLine(id)}\n`;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* One printable line saying what `thrown` was, whatever value was thrown, and never itself a
|
|
46
|
+
* throw: an Error's message, a string, a Symbol's description, `null` or `undefined` as written,
|
|
47
|
+
* and otherwise the value's own string. Reading an Error's message, or converting the value, runs
|
|
48
|
+
* code its thrower supplied, which can throw in turn; then the line says only what kind of value
|
|
49
|
+
* was thrown.
|
|
50
|
+
*/
|
|
51
|
+
export function causeOf(thrown) {
|
|
52
|
+
try {
|
|
53
|
+
const held = thrown instanceof Error ? thrown.message : thrown;
|
|
54
|
+
const said = typeof held === 'string' ? held : typeof held === 'symbol' ? held.toString() : String(held);
|
|
55
|
+
if (said !== '') return said;
|
|
56
|
+
} catch {
|
|
57
|
+
// The value refused to be read or converted; its kind is all that is left to say.
|
|
58
|
+
}
|
|
59
|
+
return `a thrown ${typeof thrown}`;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** `failure`'s `made` mark, or undefined where it has none or reading it throws. */
|
|
63
|
+
const madeOf = (failure) => {
|
|
64
|
+
try {
|
|
65
|
+
return failure?.made;
|
|
66
|
+
} catch {
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/** The hold's id the body or comment `text` names, or null where it names none. */
|
|
72
|
+
export const holdOf = (text) => /^Hold: `([0-9a-z]+)`$/m.exec(String(text ?? ''))?.[1] ?? null;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Where hold `id`'s notice stands on an issue L2 read: `closed` where the timeline shows a close
|
|
76
|
+
* after the notice reached it, made while the issue carried the status label `status`; otherwise
|
|
77
|
+
* `reached` where the opening or a comment names the hold's id. `opened` is whether the issue's
|
|
78
|
+
* opening names it, by an account with write access. A comment counts only where an account with
|
|
79
|
+
* write access wrote it and it was never edited. The timeline's order is the order that counts, so
|
|
80
|
+
* a close and a reopen between two reads still count, and a label applied at the opening is carried
|
|
81
|
+
* from it.
|
|
82
|
+
*/
|
|
83
|
+
function noticeIn(id, status, opened, timeline) {
|
|
84
|
+
let reached = opened;
|
|
85
|
+
let labelled = false;
|
|
86
|
+
for (const entry of timeline) {
|
|
87
|
+
if (entry.label === status) labelled = entry.kind === 'labeled';
|
|
88
|
+
if (entry.kind === 'comment' && holdOf(entry.body) === id && WRITERS.includes(entry.permission) && !entry.edited) reached = true;
|
|
89
|
+
if (entry.kind === 'closed' && reached && labelled) return { closed: true, reached };
|
|
90
|
+
}
|
|
91
|
+
return { closed: false, reached };
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* L2's notice function, over the forge adapter's `reads`, repository `writes`, `board` reads and
|
|
96
|
+
* item writes `items`, placing by `columns` and recording through `sink`. It answers, for one hold's
|
|
97
|
+
* `closer` as L3 listed it, an async generator L3 drives (the architect's placement ruling on
|
|
98
|
+
* #1016): each value it yields is the rename the closer is to take, `{ rename: 'after' | 'issue',
|
|
99
|
+
* number }`, which L3 makes through `admission.mjs` and hands back unread, as `next(outcome)`, before
|
|
100
|
+
* L2 writes again. L2 holds no admission handle and no callback. Where a rename found its closer
|
|
101
|
+
* gone, L3 ends the call, and L2 writes nothing more. It returns `{ issue }`, the status issue, or
|
|
102
|
+
* `{ failed }`, naming the step it stopped at and the cause, and, where the forge made that step's
|
|
103
|
+
* write, its `made` mark, and any `unrecorded` events where the sink refused them.
|
|
104
|
+
*
|
|
105
|
+
* For a closer naming an issue, L3 hands over `state`, the issue's state as it read it, and L2
|
|
106
|
+
* follows the notice there, as `ARCHITECTURE.md`, "Failure model", says: it answers `{ issue,
|
|
107
|
+
* closed: true }` where the notice closed for that hold, for L3 to remove its closer; places the
|
|
108
|
+
* issue in Owner where it is still the notice, first commenting where the notice never reached it;
|
|
109
|
+
* and otherwise finds or opens another, as the hold's steps 2 to 6 do.
|
|
110
|
+
*
|
|
111
|
+
* The function also carries `close`, `rigger resume`'s third step.
|
|
112
|
+
*/
|
|
113
|
+
export function statusNotice({ reads, writes, board, items, columns, sink }) {
|
|
114
|
+
const status = FIXED_LABELS.status;
|
|
115
|
+
/** Whether `issue`, as `readIssue` answers it, is open and carries the status label. */
|
|
116
|
+
const isStatus = (issue) => issue !== null && issue.state === 'open' && issue.labels.includes(status);
|
|
117
|
+
async function* notice({ closer, others = [], hold, admission, state }) {
|
|
118
|
+
let at;
|
|
119
|
+
/** Answers `act`'s answer as the step `named`, so that a failure names that step. */
|
|
120
|
+
const step = (named, act) => {
|
|
121
|
+
at = named;
|
|
122
|
+
return act();
|
|
123
|
+
};
|
|
124
|
+
/** Answers the rename to `rename` `number`, for L3 to make; the outcome L3 hands back failing it fails the call. */
|
|
125
|
+
async function* renamed(rename, number) {
|
|
126
|
+
const outcome = yield { rename, number };
|
|
127
|
+
at = 'rename the closer';
|
|
128
|
+
if (outcome?.status === 'rejected') throw outcome.reason;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* The number of the issue above the after-name's `k` and up to the newest whose body names the
|
|
132
|
+
* hold's id, written by an account with write access, or undefined where none is.
|
|
133
|
+
*/
|
|
134
|
+
const scanned = async () => (await firstAbove(Number(closer.after), {
|
|
135
|
+
readNewestNumber: () => step('read the newest number', () => reads.readNewestNumber()),
|
|
136
|
+
readIssue: (number) => step(`read issue #${number}`, () => reads.readIssue(number)),
|
|
137
|
+
readPermission: (author) => step(`read ${author}'s permission`, () => reads.readPermission(author)),
|
|
138
|
+
}, (issue) => holdOf(issue.body) === closer.id))?.number;
|
|
139
|
+
/**
|
|
140
|
+
* How the notice stands on the issue the closer names: `closed`, `notice` once L2 has commented
|
|
141
|
+
* where the notice never reached the open labelled issue, or `gone` where it is no longer the
|
|
142
|
+
* hold's notice.
|
|
143
|
+
*/
|
|
144
|
+
const followed = async (number) => {
|
|
145
|
+
if (state === 'none') return 'gone';
|
|
146
|
+
const issue = await step(`read issue #${number}`, () => reads.readIssue(number));
|
|
147
|
+
if (issue === null) return 'gone';
|
|
148
|
+
const timeline = await step(`read issue #${number}'s timeline`, () => reads.readIssueTimeline(number));
|
|
149
|
+
const opened = holdOf(issue.body) === closer.id && issue.author !== null
|
|
150
|
+
&& WRITERS.includes(await step(`read ${issue.author}'s permission`, () => reads.readPermission(issue.author)));
|
|
151
|
+
const { closed, reached } = noticeIn(closer.id, status, opened, timeline);
|
|
152
|
+
if (closed) return 'closed';
|
|
153
|
+
if (!isStatus(issue)) return 'gone';
|
|
154
|
+
if (!reached) await step(`comment on issue #${number}`, () => writes.postIssueComment(number, holdComment({ id: closer.id, reason: closer.reason, card: hold?.card })));
|
|
155
|
+
return 'notice';
|
|
156
|
+
};
|
|
157
|
+
try {
|
|
158
|
+
let number = closer.after === undefined ? undefined : await scanned();
|
|
159
|
+
const named = closer.issue === undefined ? undefined : Number(closer.issue);
|
|
160
|
+
const follows = named === undefined ? undefined : await followed(named);
|
|
161
|
+
if (follows === 'closed') return { issue: named, closed: true };
|
|
162
|
+
if (follows === 'notice') number = named;
|
|
163
|
+
else if (number !== undefined) yield* renamed('issue', number);
|
|
164
|
+
else number = yield* written();
|
|
165
|
+
const item = (await step('read the board', () => board.readItems())).find((each) => each.number === number);
|
|
166
|
+
if (item?.column !== columns.owner) {
|
|
167
|
+
const id = item?.id ?? await step(`add issue #${number} to the board`, () => items.addIssue(number));
|
|
168
|
+
await step(`move issue #${number} to Owner`, () => items.moveItem(id, columns.owner));
|
|
169
|
+
}
|
|
170
|
+
return { issue: number };
|
|
171
|
+
} catch (failure) {
|
|
172
|
+
// L2 returns a made write with its mark and any refused events rather than recording it
|
|
173
|
+
// as an undone step. The verb names the side's refusal and only events actually refused.
|
|
174
|
+
const made = madeOf(failure);
|
|
175
|
+
if (made !== undefined) {
|
|
176
|
+
let unrecorded;
|
|
177
|
+
try {
|
|
178
|
+
({ unrecorded } = failure);
|
|
179
|
+
} catch {
|
|
180
|
+
unrecorded = [{ event: 'events it could not name' }];
|
|
181
|
+
}
|
|
182
|
+
return { failed: { step: at, cause: causeOf(failure), made, ...(unrecorded === undefined ? {} : { unrecorded }) } };
|
|
183
|
+
}
|
|
184
|
+
const failed = { step: at, cause: causeOf(failure) };
|
|
185
|
+
try {
|
|
186
|
+
sink.emitter({ layer: 'L2' }).emit('notice.failed', { hold: closer.id, ...failed });
|
|
187
|
+
} catch (refusal) {
|
|
188
|
+
// The failure stays the answer, whatever it says was made, and the refused record of it is
|
|
189
|
+
// added to its cause, so neither is lost to the caller.
|
|
190
|
+
return { failed: { ...failed, cause: `${failed.cause}; and the sink refused its notice.failed event: ${causeOf(refusal)}` } };
|
|
191
|
+
}
|
|
192
|
+
return { failed };
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/** The hold's steps 2 to 5: picks an issue and comments on it, or opens one, answering its number. */
|
|
196
|
+
async function* written() {
|
|
197
|
+
let number;
|
|
198
|
+
for (const other of others) {
|
|
199
|
+
if (isStatus(await step(`read issue #${other}`, () => reads.readIssue(other)))) {
|
|
200
|
+
number = other;
|
|
201
|
+
break;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
number ??= (await step(`read the open issues labelled ${status}`, () => reads.readLabelledIssues(status)))[0];
|
|
205
|
+
if (number !== undefined) {
|
|
206
|
+
yield* renamed('issue', number);
|
|
207
|
+
await step(`comment on issue #${number}`, () => writes.postIssueComment(number, holdComment({ id: closer.id, reason: closer.reason, card: hold?.card })));
|
|
208
|
+
} else {
|
|
209
|
+
yield* renamed('after', await step('read the newest number', () => reads.readNewestNumber()));
|
|
210
|
+
number = await step('open the status issue', () => writes.openIssue(TITLE, holdBody({ id: closer.id, reason: closer.reason, run: closer.run, hold, admission }), status));
|
|
211
|
+
yield* renamed('issue', number);
|
|
212
|
+
}
|
|
213
|
+
return number;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* `rigger resume`'s third step, once it has removed the closers it read: closes each issue in
|
|
219
|
+
* `named`, the numbers the closers' file names gave, and every other open issue carrying the
|
|
220
|
+
* status label. For each, it removes the label where the issue carries it, then closes it. An
|
|
221
|
+
* issue the repository no longer holds, or already closed, takes no write. A read or write refused
|
|
222
|
+
* for one issue leaves it open, and L2 goes on to the next; where its label was already removed,
|
|
223
|
+
* the issue left open says so, since no later read by label finds it. A write the forge made whose record
|
|
224
|
+
* the sink refused, a failure the write side marks `made`, is a write made: L2 goes on as it
|
|
225
|
+
* would had it been recorded, and keeps the failure. Answers `{ closed, left, unrecorded, unread }`:
|
|
226
|
+
* the numbers it closed, each issue left open as `{ issue, why }`, each write made and left
|
|
227
|
+
* unrecorded as `{ issue, write, why }`, `write` being `label` or `close`, and, where the read of
|
|
228
|
+
* the labelled issues was refused, why, in which case only the issues `named` gave were closed.
|
|
229
|
+
*/
|
|
230
|
+
notice.close = async (named) => {
|
|
231
|
+
let labelled = [];
|
|
232
|
+
let unread;
|
|
233
|
+
try {
|
|
234
|
+
labelled = await reads.readLabelledIssues(status);
|
|
235
|
+
} catch (failure) {
|
|
236
|
+
unread = causeOf(failure);
|
|
237
|
+
}
|
|
238
|
+
const closed = [];
|
|
239
|
+
const left = [];
|
|
240
|
+
const unrecorded = [];
|
|
241
|
+
/** Awaits `write`, the write named `kind` for issue `number`, keeping a made write's refused record. */
|
|
242
|
+
const made = async (number, kind, write) => {
|
|
243
|
+
try {
|
|
244
|
+
await write();
|
|
245
|
+
} catch (failure) {
|
|
246
|
+
if (madeOf(failure) === undefined) throw failure;
|
|
247
|
+
unrecorded.push({ issue: number, write: kind, why: causeOf(failure) });
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
for (const number of [...new Set([...named, ...labelled])]) {
|
|
251
|
+
let unlabelled = false;
|
|
252
|
+
try {
|
|
253
|
+
const issue = await reads.readIssue(number);
|
|
254
|
+
if (issue === null || issue.state === 'closed') continue;
|
|
255
|
+
if (issue.labels.includes(status)) {
|
|
256
|
+
await made(number, 'label', () => writes.removeIssueLabel(number, status));
|
|
257
|
+
unlabelled = true;
|
|
258
|
+
}
|
|
259
|
+
await made(number, 'close', () => writes.closeIssue(number));
|
|
260
|
+
closed.push(number);
|
|
261
|
+
} catch (failure) {
|
|
262
|
+
left.push({ issue: number, why: causeOf(failure), ...(unlabelled && { unlabelled }) });
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
return { closed, left, unrecorded, ...(unread === undefined ? {} : { unread }) };
|
|
266
|
+
};
|
|
267
|
+
return notice;
|
|
268
|
+
}
|