@popovych.co/witness 0.28.2 → 0.28.3
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 +1 -1
- package/dist/abandon.d.ts +67 -0
- package/dist/act.d.ts +16 -0
- package/dist/act.js +61 -0
- package/dist/adopt.d.ts +21 -0
- package/dist/allowlist.d.ts +48 -0
- package/dist/allowlist.js +79 -5
- package/dist/arbiter.d.ts +37 -0
- package/dist/arbiter.js +7 -5
- package/dist/ask.d.ts +29 -0
- package/dist/ask.js +11 -5
- package/dist/autonomy.d.ts +46 -0
- package/dist/autonomy.js +24 -12
- package/dist/awake.d.ts +15 -0
- package/dist/basis.d.ts +9 -0
- package/dist/battery.d.ts +23 -0
- package/dist/bin.d.ts +2 -0
- package/dist/caps.d.ts +20 -0
- package/dist/cli.d.ts +18 -0
- package/dist/config-file.d.ts +12 -0
- package/dist/config.d.ts +96 -0
- package/dist/config.js +2 -1
- package/dist/contain.d.ts +16 -0
- package/dist/context.d.ts +25 -0
- package/dist/criteria.d.ts +27 -0
- package/dist/criteria.js +2 -1
- package/dist/decide-view.d.ts +46 -0
- package/dist/decide-view.js +137 -0
- package/dist/decisions.d.ts +23 -0
- package/dist/deferral.d.ts +26 -0
- package/dist/delta.d.ts +58 -0
- package/dist/departure.d.ts +66 -0
- package/dist/design.d.ts +34 -0
- package/dist/drafts.d.ts +31 -0
- package/dist/drafts.js +5 -3
- package/dist/drift.d.ts +23 -0
- package/dist/drive-presence.d.ts +27 -0
- package/dist/drive-presence.js +15 -4
- package/dist/drive-report.d.ts +24 -0
- package/dist/drive-report.js +4 -4
- package/dist/drive.d.ts +97 -0
- package/dist/drive.js +68 -71
- package/dist/dsl.d.ts +23 -0
- package/dist/dsl.js +8 -3
- package/dist/evidence.d.ts +65 -0
- package/dist/floor.d.ts +6 -0
- package/dist/fm.d.ts +9 -0
- package/dist/gate-run-view.d.ts +57 -0
- package/dist/gate-run-view.js +100 -0
- package/dist/gate.d.ts +91 -0
- package/dist/gate.js +14 -67
- package/dist/gates/decompose.d.ts +1 -0
- package/dist/gates/decompose.js +3 -1
- package/dist/gates/design.d.ts +1 -0
- package/dist/gates/design.js +6 -2
- package/dist/gates/implement.d.ts +1 -0
- package/dist/gates/implement.js +9 -2
- package/dist/gates/index.d.ts +5 -0
- package/dist/gates/plan.d.ts +1 -0
- package/dist/gates/plan.js +10 -4
- package/dist/gates/ship.d.ts +1 -0
- package/dist/gates/ship.js +4 -2
- package/dist/gitio.d.ts +30 -0
- package/dist/gitio.js +4 -1
- package/dist/glob.d.ts +2 -0
- package/dist/harness.d.ts +73 -0
- package/dist/harness.js +36 -15
- package/dist/history.d.ts +10 -0
- package/dist/idlists.d.ts +2 -0
- package/dist/install.d.ts +29 -0
- package/dist/journal.d.ts +74 -0
- package/dist/journal.js +5 -1
- package/dist/junit.d.ts +9 -0
- package/dist/live.d.ts +24 -0
- package/dist/lock.d.ts +9 -0
- package/dist/matcher.d.ts +8 -0
- package/dist/migration.d.ts +25 -0
- package/dist/model.d.ts +8 -0
- package/dist/models.d.ts +9 -0
- package/dist/models.js +10 -0
- package/dist/needs-you.d.ts +75 -0
- package/dist/needs-you.js +104 -40
- package/dist/needs.d.ts +44 -0
- package/dist/needs.js +37 -7
- package/dist/notify.d.ts +12 -0
- package/dist/opener.d.ts +15 -0
- package/dist/pin.d.ts +12 -0
- package/dist/pin.js +9 -2
- package/dist/principles.d.ts +3 -0
- package/dist/probe.d.ts +1 -0
- package/dist/progress.d.ts +3 -0
- package/dist/recommend.d.ts +31 -0
- package/dist/recommend.js +51 -42
- package/dist/refusal.d.ts +20 -0
- package/dist/refusal.js +12 -4
- package/dist/registry.d.ts +1 -0
- package/dist/released-comments.d.ts +1 -0
- package/dist/review.d.ts +27 -0
- package/dist/reviewed.d.ts +23 -0
- package/dist/reviewer.d.ts +47 -0
- package/dist/rounds.d.ts +135 -0
- package/dist/rounds.js +38 -21
- package/dist/runner-lock.d.ts +5 -0
- package/dist/runner.d.ts +30 -0
- package/dist/scan.d.ts +27 -0
- package/dist/schemas.d.ts +11 -0
- package/dist/schemas.js +7 -3
- package/dist/session-clock.d.ts +16 -0
- package/dist/settings.d.ts +73 -0
- package/dist/settings.js +12 -2
- package/dist/settle.d.ts +39 -0
- package/dist/settle.js +59 -30
- package/dist/sha.d.ts +5 -0
- package/dist/ship.d.ts +20 -0
- package/dist/ship.js +21 -12
- package/dist/slice.d.ts +45 -0
- package/dist/slice.js +2 -2
- package/dist/snapshot.d.ts +10 -0
- package/dist/spawn.d.ts +22 -0
- package/dist/stamp.d.ts +27 -0
- package/dist/stamp.js +3 -1
- package/dist/steps.d.ts +30 -0
- package/dist/steps.js +8 -3
- package/dist/toon.d.ts +17 -0
- package/dist/toon.js +150 -14
- package/dist/txn.d.ts +28 -0
- package/dist/usage.d.ts +25 -0
- package/dist/verbs/abandon.d.ts +2 -0
- package/dist/verbs/adopt.d.ts +2 -0
- package/dist/verbs/adopt.js +9 -4
- package/dist/verbs/ask.d.ts +2 -0
- package/dist/verbs/check.d.ts +2 -0
- package/dist/verbs/check.js +29 -10
- package/dist/verbs/clean.d.ts +2 -0
- package/dist/verbs/dashboard.d.ts +59 -0
- package/dist/verbs/dashboard.js +4 -2
- package/dist/verbs/decide.d.ts +34 -0
- package/dist/verbs/decide.js +95 -130
- package/dist/verbs/design.d.ts +2 -0
- package/dist/verbs/design.js +8 -5
- package/dist/verbs/diff.d.ts +2 -0
- package/dist/verbs/diff.js +4 -2
- package/dist/verbs/dismiss.d.ts +2 -0
- package/dist/verbs/dispatch.d.ts +2 -0
- package/dist/verbs/dispatch.js +2 -2
- package/dist/verbs/draft.d.ts +2 -0
- package/dist/verbs/draft.js +6 -3
- package/dist/verbs/drive.d.ts +2 -0
- package/dist/verbs/evidence.d.ts +5 -0
- package/dist/verbs/floor.d.ts +2 -0
- package/dist/verbs/gate.d.ts +3 -0
- package/dist/verbs/index-verb.d.ts +2 -0
- package/dist/verbs/init.d.ts +2 -0
- package/dist/verbs/log.d.ts +9 -0
- package/dist/verbs/migrate.d.ts +13 -0
- package/dist/verbs/next.d.ts +61 -0
- package/dist/verbs/next.js +112 -84
- package/dist/verbs/read.d.ts +2 -0
- package/dist/verbs/read.js +3 -1
- package/dist/verbs/recap.d.ts +28 -0
- package/dist/verbs/recap.js +3 -3
- package/dist/verbs/recover.d.ts +5 -0
- package/dist/verbs/recover.js +14 -9
- package/dist/verbs/rename.d.ts +2 -0
- package/dist/verbs/rename.js +1 -1
- package/dist/verbs/retry.d.ts +2 -0
- package/dist/verbs/review.d.ts +2 -0
- package/dist/verbs/review.js +1 -1
- package/dist/verbs/satisfy.d.ts +2 -0
- package/dist/verbs/ship.d.ts +3 -0
- package/dist/verbs/start.d.ts +2 -0
- package/dist/verbs/start.js +12 -7
- package/dist/verbs/step-close.d.ts +2 -0
- package/dist/verbs/sync.d.ts +15 -0
- package/dist/verbs/trust.d.ts +4 -0
- package/dist/verbs/trust.js +34 -32
- package/dist/verbs/turn.d.ts +2 -0
- package/dist/verbs/wait.d.ts +9 -0
- package/dist/verbs/wait.js +3 -3
- package/dist/verbs/write.d.ts +18 -0
- package/dist/verbs/write.js +11 -5
- package/dist/verdict.d.ts +60 -0
- package/dist/version.d.ts +4 -0
- package/dist/worker-stream.d.ts +22 -0
- package/dist/worktree.d.ts +22 -0
- package/dist/worktree.js +1 -1
- package/package.json +7 -1
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/commands/witness.md +10 -10
- package/plugin/hooks/canon-guard.mjs +71 -10
- package/plugin/hooks/session-dashboard.sh +1 -1
- package/plugin/skills/witness-brainstorm/SKILL.md +3 -3
- package/plugin/skills/witness-decompose/SKILL.md +3 -3
- package/plugin/skills/witness-design/SKILL.md +2 -2
- package/plugin/skills/witness-implement/SKILL.md +2 -2
- package/plugin/skills/witness-plan/SKILL.md +2 -2
- package/plugin/skills/witness-ship/SKILL.md +2 -2
package/dist/rounds.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { cliAct, exitsLine } from './act.js';
|
|
1
2
|
const isRun = (e, gate) => e !== undefined && e.t === 'gate-run' && e.gate === gate;
|
|
2
3
|
const isDecision = (e, gate) => e !== undefined && e.t === 'human-decision' && e.gate === gate;
|
|
3
4
|
export function keyOf(run) {
|
|
@@ -136,12 +137,13 @@ export function ladderSpent(entries, gate, anchor) {
|
|
|
136
137
|
}
|
|
137
138
|
const PREFILL_MAX = 120;
|
|
138
139
|
const PREFILL_ANCHORS = 3;
|
|
139
|
-
// What
|
|
140
|
-
// the author already receives the whole verdict in `decide`'s
|
|
141
|
-
//
|
|
142
|
-
//
|
|
143
|
-
//
|
|
144
|
-
//
|
|
140
|
+
// Row 239. What `decide` journals as the note of a bare `--revise`. An index of the anchoring
|
|
141
|
+
// run, never a judgment: the author already receives the whole verdict in `decide`'s
|
|
142
|
+
// revise-context. It no longer rides a command. As `--note "…"` (D129) it carried a
|
|
143
|
+
// reviewer's anchor onto a line a human pastes, so the revise is offered bare and `decide`
|
|
144
|
+
// derives the note from the same journal. `<why>` means the run holds no facts — a clean
|
|
145
|
+
// standing stop, where the reason is the human's and the CLI has none — and there the revise
|
|
146
|
+
// keeps its `<why>` slot (`reviseAct`), and a bare one journals no note.
|
|
145
147
|
export function notePrefill(entries, gate) {
|
|
146
148
|
const last = lastGateRun(entries, gate);
|
|
147
149
|
if (!last)
|
|
@@ -162,6 +164,14 @@ export function notePrefill(entries, gate) {
|
|
|
162
164
|
shown.join(', ') + (more > 0 ? ` +${more} more` : '');
|
|
163
165
|
return text.slice(0, PREFILL_MAX);
|
|
164
166
|
}
|
|
167
|
+
// Row 239. The revise an exits line or a block offers, carrying no text from a reviewer. Where
|
|
168
|
+
// the run holds facts it is a bare `--revise`, and `decide` journals the prefill itself; where
|
|
169
|
+
// it holds none it keeps the `<why>` slot the human fills, printed as it always was.
|
|
170
|
+
export function reviseAct(gate, target, entries) {
|
|
171
|
+
return notePrefill(entries, gate) !== '<why>'
|
|
172
|
+
? cliAct('decide', gate, target, '--revise')
|
|
173
|
+
: cliAct('decide', gate, target, '--revise', '--note', '<why>');
|
|
174
|
+
}
|
|
165
175
|
// Which decisions are legal RIGHT NOW is a pure function of journal state, so it lives
|
|
166
176
|
// where the state is — it was in `gate.ts`, which `next.ts` cannot import back (gate.ts
|
|
167
177
|
// already imports next.ts), and that one-way edge is precisely why `next` grew three
|
|
@@ -173,10 +183,10 @@ export function notePrefill(entries, gate) {
|
|
|
173
183
|
// which shipped an unrunnable command on every screen (D129). `undefined` means no
|
|
174
184
|
// upstream exists — `decide` refuses that with `unknown-owner`, so the option is not legal
|
|
175
185
|
// and is omitted rather than printed as a placeholder.
|
|
176
|
-
export function
|
|
177
|
-
const d =
|
|
178
|
-
const up = upstream === undefined ? [] : [
|
|
179
|
-
const note =
|
|
186
|
+
export function exitActs(gate, target, entries, stale, upstream) {
|
|
187
|
+
const d = (...rest) => cliAct('decide', gate, target, ...rest);
|
|
188
|
+
const up = upstream === undefined ? [] : [d('--revise', '--upstream', upstream)];
|
|
189
|
+
const note = reviseAct(gate, target, entries);
|
|
180
190
|
// The bound outranks staleness: at the bound the gate short-circuits and will not run
|
|
181
191
|
// again (gate.ts), so "re-gate" is the D67 lie whatever the sha says. Stale content only
|
|
182
192
|
// removes APPROVE from the endgame — a human cannot honestly stamp bytes no battery
|
|
@@ -190,10 +200,9 @@ export function liveExits(gate, target, entries, stale, upstream) {
|
|
|
190
200
|
// printed it (`help: or discard the plan`) and nothing else offers it — and under D124
|
|
191
201
|
// `--stop` becomes *park*, which would otherwise leave the bound screen with no
|
|
192
202
|
// discarding act at all.
|
|
193
|
-
const repair = repairGranted(entries, gate) ? [] : ['--revise --repair'];
|
|
194
|
-
const approve = stale ? [] : ['--approve --override'];
|
|
195
|
-
return [
|
|
196
|
-
`witness abandon ${target}`].join(' | ');
|
|
203
|
+
const repair = repairGranted(entries, gate) ? [] : [d('--revise', '--repair')];
|
|
204
|
+
const approve = stale ? [] : [d('--approve', '--override')];
|
|
205
|
+
return [...approve, ...up, ...repair, d('--stop'), cliAct('abandon', target)];
|
|
197
206
|
}
|
|
198
207
|
// Stale removes --approve and nothing else: `decide` refuses that one with `stale-verdict`
|
|
199
208
|
// because a stamp asserts about current content, while a stop or a revise judges the work.
|
|
@@ -201,19 +210,27 @@ export function liveExits(gate, target, entries, stale, upstream) {
|
|
|
201
210
|
// reopened and revised screens, where no anchor resolves and every decide verb refuses.
|
|
202
211
|
if (stale) {
|
|
203
212
|
if (pendingDecision(entries, gate) === undefined)
|
|
204
|
-
return
|
|
205
|
-
return [
|
|
213
|
+
return [cliAct('gate', gate, target)];
|
|
214
|
+
return [cliAct('gate', gate, target), note, ...up, d('--stop')];
|
|
206
215
|
}
|
|
207
|
-
return
|
|
216
|
+
return [d('--approve'), note, ...up, d('--stop')];
|
|
217
|
+
}
|
|
218
|
+
// Rows 139/203. The exits line: `exitActs` rendered in one line.
|
|
219
|
+
export function liveExits(gate, target, entries, stale, upstream) {
|
|
220
|
+
return exitsLine(exitActs(gate, target, entries, stale, upstream));
|
|
208
221
|
}
|
|
209
222
|
// What un-parks a gate stopped under D124. Below the bound a fresh run is the act — the
|
|
210
223
|
// content is unchanged, so a plain re-gate would answer `changed-nothing`. At the bound
|
|
211
224
|
// the gate short-circuits before invoking anything, so `--fresh` is the D67 lie: the only
|
|
212
|
-
// live acts there are the endgame set, which
|
|
213
|
-
export function
|
|
225
|
+
// live acts there are the endgame set, which exitActs already knows.
|
|
226
|
+
export function reopenActs(gate, target, entries, upstream) {
|
|
214
227
|
return boundReached(entries, gate)
|
|
215
|
-
?
|
|
216
|
-
:
|
|
228
|
+
? exitActs(gate, target, entries, false, upstream)
|
|
229
|
+
: [cliAct('gate', gate, target, '--fresh')];
|
|
230
|
+
}
|
|
231
|
+
// Rows 139/203. The reopen as one line: `reopenActs` rendered.
|
|
232
|
+
export function reopenCommand(gate, target, entries, upstream) {
|
|
233
|
+
return exitsLine(reopenActs(gate, target, entries, upstream));
|
|
217
234
|
}
|
|
218
235
|
export function pendingDecision(entries, gate) {
|
|
219
236
|
for (let i = entries.length - 1; i >= 0; i--) {
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Ctx } from './cli.js';
|
|
2
|
+
export declare const runnerLockPath: (root: string) => string;
|
|
3
|
+
export declare const RUNNER_TURN_ENV = "WITNESS_RUNNER_TURN";
|
|
4
|
+
export declare function releaseDeadTurn(root: string): boolean;
|
|
5
|
+
export declare function withRunnerTurn<T>(runRoot: string, ctx: Ctx, label: string, fn: (env: Ctx['env']) => T): T;
|
package/dist/runner.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Ctx } from './cli.js';
|
|
2
|
+
import type { Config } from './config.js';
|
|
3
|
+
import { type TestOutcome } from './junit.js';
|
|
4
|
+
import { type Result, type Violation } from './refusal.js';
|
|
5
|
+
import { type JobHost } from './contain.js';
|
|
6
|
+
export type RunnerConfig = {
|
|
7
|
+
mode: 'filtered';
|
|
8
|
+
template: string;
|
|
9
|
+
reportGlob?: string;
|
|
10
|
+
} | {
|
|
11
|
+
mode: 'full-suite';
|
|
12
|
+
reportGlob: string;
|
|
13
|
+
suiteCmd: string;
|
|
14
|
+
};
|
|
15
|
+
export declare function runnerConfig(cfg: Config): Result<RunnerConfig>;
|
|
16
|
+
export declare function criteriaExcludes(cfg: Config): string[];
|
|
17
|
+
export interface RunOutcome {
|
|
18
|
+
exitZero: boolean;
|
|
19
|
+
output: string;
|
|
20
|
+
}
|
|
21
|
+
export declare function execCommand(runRoot: string, ctx: Ctx, cmd: string): RunOutcome;
|
|
22
|
+
export declare function sayNoJob(ctx: Ctx, host: JobHost): void;
|
|
23
|
+
export declare function untrustedOf(violations: readonly Violation[]): string | undefined;
|
|
24
|
+
export declare function runFiltered(runRoot: string, ctx: Ctx, template: string, specId: string, trustRoot?: string): Promise<Result<RunOutcome>>;
|
|
25
|
+
export declare function runFullSuite(runRoot: string, ctx: Ctx, rc: Extract<RunnerConfig, {
|
|
26
|
+
mode: 'full-suite';
|
|
27
|
+
}>, trustRoot?: string): Promise<Result<{
|
|
28
|
+
run: RunOutcome;
|
|
29
|
+
tests: TestOutcome[];
|
|
30
|
+
}>>;
|
package/dist/scan.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type CanonPaths } from './config.js';
|
|
2
|
+
import { type Violation } from './refusal.js';
|
|
3
|
+
export interface CanonDoc {
|
|
4
|
+
rel: string;
|
|
5
|
+
meta: Record<string, unknown>;
|
|
6
|
+
body: string;
|
|
7
|
+
violations: Violation[];
|
|
8
|
+
satisfiedNeeds: readonly string[];
|
|
9
|
+
}
|
|
10
|
+
export interface Canon {
|
|
11
|
+
docs: CanonDoc[];
|
|
12
|
+
errors: Violation[];
|
|
13
|
+
paths: CanonPaths;
|
|
14
|
+
}
|
|
15
|
+
export declare function loadCanon(root: string): Canon;
|
|
16
|
+
export declare function criteriaOwner(canon: Canon, id: string): CanonDoc | undefined;
|
|
17
|
+
export declare function findById(canon: Canon, id: string): CanonDoc | undefined;
|
|
18
|
+
export declare function plannableParent(doc: CanonDoc): boolean;
|
|
19
|
+
export declare function planFinished(doc: CanonDoc): boolean;
|
|
20
|
+
export declare function plansOn(canon: Canon, specId: string, opts?: {
|
|
21
|
+
exclude?: Set<string>;
|
|
22
|
+
pin?: string;
|
|
23
|
+
}): CanonDoc[];
|
|
24
|
+
export declare function findCycle(canon: Canon, extra?: {
|
|
25
|
+
id: string;
|
|
26
|
+
depends: string[];
|
|
27
|
+
}): string[] | undefined;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type Violation } from './refusal.js';
|
|
2
|
+
export declare const SPEC_STATUS: readonly ["draft", "approved", "live"];
|
|
3
|
+
export declare const PLAN_STATUS: readonly ["draft", "approved", "in-progress", "done", "abandoned"];
|
|
4
|
+
export declare const PRINCIPLES_STATUS: readonly ["draft", "approved"];
|
|
5
|
+
export interface Step {
|
|
6
|
+
id: string;
|
|
7
|
+
title: string;
|
|
8
|
+
criteria?: string[];
|
|
9
|
+
scaffolding?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare function validateDoc(meta: Record<string, unknown>, body: string): Violation[];
|
package/dist/schemas.js
CHANGED
|
@@ -7,7 +7,7 @@ export function validateDoc(meta, body) {
|
|
|
7
7
|
const out = [];
|
|
8
8
|
const id = meta.id;
|
|
9
9
|
if (typeof id !== 'string' || !ID_RE.test(id)) {
|
|
10
|
-
out.push(v('id', 'id-charset', String(id ?? 'absent'), '[a-z0-9-]
|
|
10
|
+
out.push(v('id', 'id-charset', String(id ?? 'absent'), '[a-z0-9][a-z0-9-]*'));
|
|
11
11
|
}
|
|
12
12
|
const type = meta.type;
|
|
13
13
|
if (type !== 'spec' && type !== 'plan' && type !== 'principles') {
|
|
@@ -25,7 +25,7 @@ export function validateDoc(meta, body) {
|
|
|
25
25
|
}
|
|
26
26
|
const depends = meta.depends ?? [];
|
|
27
27
|
if (!Array.isArray(depends) || depends.some((d) => typeof d !== 'string' || !ID_RE.test(d))) {
|
|
28
|
-
out.push(v('depends', 'shape', JSON.stringify(meta.depends), 'list of ids matching [a-z0-9-]
|
|
28
|
+
out.push(v('depends', 'shape', JSON.stringify(meta.depends), 'list of ids matching [a-z0-9][a-z0-9-]*'));
|
|
29
29
|
}
|
|
30
30
|
out.push(...validateNeeds(meta.needs));
|
|
31
31
|
out.push(...validateHolds(meta));
|
|
@@ -76,6 +76,10 @@ export function validateDoc(meta, body) {
|
|
|
76
76
|
if (meta['decisions-from'] !== undefined && (typeof meta['decisions-from'] !== 'string' || !/^[0-9a-f]{64}$/.test(String(meta['decisions-from'])))) {
|
|
77
77
|
out.push(v('decisions-from', 'shape', String(meta['decisions-from']), '64-hex carried-decisions sha'));
|
|
78
78
|
}
|
|
79
|
+
// Row 239. Ship stamps the PR's number (`stampPr`), and the merge a human is offered names it.
|
|
80
|
+
if (meta.pr !== undefined && !(typeof meta.pr === 'number' && Number.isInteger(meta.pr) && meta.pr > 0)) {
|
|
81
|
+
out.push(v('pr', 'shape', String(meta.pr), 'a positive integer — the PR number ship stamps'));
|
|
82
|
+
}
|
|
79
83
|
out.push(...validateSteps(meta.steps, body));
|
|
80
84
|
}
|
|
81
85
|
if (type === 'principles' && meta.criteria !== undefined) {
|
|
@@ -93,7 +97,7 @@ function validateSteps(raw, body) {
|
|
|
93
97
|
const at = `steps[${i}]`;
|
|
94
98
|
const e = (typeof s === 'object' && s !== null ? s : {});
|
|
95
99
|
if (typeof e.id !== 'string' || !ID_RE.test(e.id)) {
|
|
96
|
-
out.push(v(`${at}.id`, 'id-charset', String(e.id ?? 'absent'), '[a-z0-9-]
|
|
100
|
+
out.push(v(`${at}.id`, 'id-charset', String(e.id ?? 'absent'), '[a-z0-9][a-z0-9-]*'));
|
|
97
101
|
}
|
|
98
102
|
else if (ids.has(e.id)) {
|
|
99
103
|
out.push(v(`${at}.id`, 'id-unique', e.id, 'unique per plan'));
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const SESSION_TICK_MS = 1000;
|
|
2
|
+
export declare const SUSPEND_GAP_MS = 30000;
|
|
3
|
+
export interface Ticker {
|
|
4
|
+
now(): number;
|
|
5
|
+
after(ms: number, fn: () => void): () => void;
|
|
6
|
+
}
|
|
7
|
+
export declare const monotonicTicker: Ticker;
|
|
8
|
+
export interface SessionClock {
|
|
9
|
+
awakeMs(): number;
|
|
10
|
+
stop(): void;
|
|
11
|
+
}
|
|
12
|
+
export declare function sessionClock(limitMs: number, ticker: Ticker, on: {
|
|
13
|
+
expire(): void;
|
|
14
|
+
slept(ms: number): void;
|
|
15
|
+
tick?(awakeMs: number): void;
|
|
16
|
+
}): SessionClock;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
export declare const GATE_NAMES: readonly ["decompose", "plan", "design", "implement", "ship"];
|
|
2
|
+
export type GateName = (typeof GATE_NAMES)[number];
|
|
3
|
+
export declare const CHANGE_CLASSES: readonly ["feature", "fix", "chore"];
|
|
4
|
+
export type ChangeClass = (typeof CHANGE_CLASSES)[number];
|
|
5
|
+
export type Battery = string[] | Record<ChangeClass, string[]>;
|
|
6
|
+
export declare const DEFAULT_MODEL = "claude-opus-5-5";
|
|
7
|
+
export declare const DEFAULT_BATTERIES: Record<GateName, Battery>;
|
|
8
|
+
export type Shape = {
|
|
9
|
+
kind: 'int';
|
|
10
|
+
min: number;
|
|
11
|
+
max?: number;
|
|
12
|
+
} | {
|
|
13
|
+
kind: 'bool';
|
|
14
|
+
} | {
|
|
15
|
+
kind: 'enum';
|
|
16
|
+
values: readonly string[];
|
|
17
|
+
} | {
|
|
18
|
+
kind: 'text';
|
|
19
|
+
} | {
|
|
20
|
+
kind: 'dir';
|
|
21
|
+
} | {
|
|
22
|
+
kind: 'files';
|
|
23
|
+
} | {
|
|
24
|
+
kind: 'globs';
|
|
25
|
+
} | {
|
|
26
|
+
kind: 'runner';
|
|
27
|
+
} | {
|
|
28
|
+
kind: 'report';
|
|
29
|
+
} | {
|
|
30
|
+
kind: 'pin';
|
|
31
|
+
} | {
|
|
32
|
+
kind: 'battery';
|
|
33
|
+
};
|
|
34
|
+
export type Group = 'setup' | 'behavior' | 'tuning';
|
|
35
|
+
export interface Setting {
|
|
36
|
+
path: string;
|
|
37
|
+
shape: Shape;
|
|
38
|
+
since: number;
|
|
39
|
+
defaults: Readonly<Record<number, unknown>>;
|
|
40
|
+
ambient?: true;
|
|
41
|
+
hookRead?: true;
|
|
42
|
+
pattern?: RegExp;
|
|
43
|
+
group: Group;
|
|
44
|
+
comment: string;
|
|
45
|
+
want: string;
|
|
46
|
+
}
|
|
47
|
+
export declare const BRANCH_RE: RegExp;
|
|
48
|
+
export interface Retired {
|
|
49
|
+
path: string;
|
|
50
|
+
until: number;
|
|
51
|
+
shape: Shape;
|
|
52
|
+
instead: string;
|
|
53
|
+
}
|
|
54
|
+
export declare const SETTINGS: readonly Setting[];
|
|
55
|
+
export declare const RETIRED: readonly Retired[];
|
|
56
|
+
export declare const SECTION_ORDER: readonly string[];
|
|
57
|
+
export declare const FIRST_LINE = "# witness.config.yaml \u2014 every setting witness reads. Change a value in place; `witness migrate` keeps the file current.";
|
|
58
|
+
export declare const SCHEMA_COMMENT = "format version \u00B7 witness migrate raises it; never edit by hand";
|
|
59
|
+
export declare const GROUP_HEADINGS: Record<Group, string>;
|
|
60
|
+
export declare function settingAt(path: string, list?: readonly Setting[]): Setting | undefined;
|
|
61
|
+
export declare function defaultAt(s: Setting, schema: number): unknown;
|
|
62
|
+
export declare function knownAt(schema: number, list?: readonly Setting[]): Set<string>;
|
|
63
|
+
export declare function getIn(raw: Record<string, unknown>, path: string): unknown;
|
|
64
|
+
export declare function nest(path: string, value: unknown): Record<string, unknown>;
|
|
65
|
+
export declare function withValues(base: Record<string, unknown>, patch: Record<string, unknown>): Record<string, unknown>;
|
|
66
|
+
export declare function defaultValues(opts?: {
|
|
67
|
+
harness?: string;
|
|
68
|
+
schema?: number;
|
|
69
|
+
}): Record<string, unknown>;
|
|
70
|
+
export declare function fingerprint(schema: number, list?: readonly Setting[]): string;
|
|
71
|
+
export declare const SCHEMA_FINGERPRINTS: Readonly<Record<number, string>>;
|
|
72
|
+
export declare function inlineValue(val: unknown): string;
|
|
73
|
+
export declare function settingsTable(): string;
|
package/dist/settings.js
CHANGED
|
@@ -21,6 +21,11 @@ export const DEFAULT_BATTERIES = {
|
|
|
21
21
|
ship: ['drift-reviewer', 'code-reviewer'],
|
|
22
22
|
design: ['design-critic'],
|
|
23
23
|
};
|
|
24
|
+
// Row 239 (the plan's B14). The ship branch is printed into the git commands a refusal offers. Its
|
|
25
|
+
// characters are letters, digits and `. _ / + -`, under git's ref rules for them: no `..`, `//` or
|
|
26
|
+
// `/.`, and no `.lock`, `.` or `/` at the end. It starts with a letter or a digit, so it is never
|
|
27
|
+
// read as a flag, and every name it admits prints bare on every platform.
|
|
28
|
+
export const BRANCH_RE = /^(?!.*\.\.)(?!.*\/\/)(?!.*\/\.)(?!.*\.lock$)[A-Za-z0-9][A-Za-z0-9._\/+-]*(?<![./])$/;
|
|
24
29
|
const INT1 = { kind: 'int', min: 1 };
|
|
25
30
|
const PIN = { kind: 'pin' };
|
|
26
31
|
const PIN_WANT = '[provider/]model[:thinking]';
|
|
@@ -95,7 +100,11 @@ export const SETTINGS = [
|
|
|
95
100
|
path: 'ship.lint', shape: { kind: 'text' }, since: 1, defaults: { 1: 'npm run lint' }, ambient: true, group: 'setup',
|
|
96
101
|
comment: 'the lint command ship runs', want: 'a shell command',
|
|
97
102
|
},
|
|
98
|
-
{
|
|
103
|
+
{
|
|
104
|
+
path: 'ship.branch', shape: { kind: 'text' }, pattern: BRANCH_RE, since: 1, defaults: { 1: 'main' }, group: 'setup',
|
|
105
|
+
comment: 'the branch witness ships into',
|
|
106
|
+
want: 'a branch name: letters, digits and . _ / + -, as git allows them — it is printed into git commands',
|
|
107
|
+
},
|
|
99
108
|
{
|
|
100
109
|
path: 'ship.merge', shape: { kind: 'enum', values: ['merge', 'squash', 'rebase'] }, since: 1, defaults: { 1: 'merge' }, group: 'setup',
|
|
101
110
|
comment: 'how ship merges its own PR under autonomy · merge | squash | rebase', want: 'merge | squash | rebase',
|
|
@@ -238,7 +247,8 @@ export function defaultValues(opts = {}) {
|
|
|
238
247
|
}
|
|
239
248
|
// What a schema promises a file means: every path, shape, `since` and default in force at
|
|
240
249
|
// that schema. Comments, wants and groups are left out, so rewording one needs no schema step:
|
|
241
|
-
// `migrate` refreshes witness's comments on every run (§4.1).
|
|
250
|
+
// `migrate` refreshes witness's comments on every run (§4.1). Row 239: so is a `pattern`, which
|
|
251
|
+
// refuses only values no shell-safe line can carry.
|
|
242
252
|
export function fingerprint(schema, list = SETTINGS) {
|
|
243
253
|
const live = list.filter((s) => s.since <= schema)
|
|
244
254
|
.map((s) => [s.path, s.shape, s.since, defaultAt(s, schema) ?? null]);
|
package/dist/settle.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type Act } from './act.js';
|
|
2
|
+
import { type KeptStop } from './autonomy.js';
|
|
3
|
+
import { type Ctx } from './cli.js';
|
|
4
|
+
import type { Config } from './config.js';
|
|
5
|
+
import type { DecisionEntry, GateRunEntry } from './rounds.js';
|
|
6
|
+
export type Settled = {
|
|
7
|
+
kind: 'none';
|
|
8
|
+
} | {
|
|
9
|
+
kind: 'decided';
|
|
10
|
+
by: 'policy' | 'arbiter';
|
|
11
|
+
decision: DecisionEntry['decision'];
|
|
12
|
+
rule: string;
|
|
13
|
+
} | {
|
|
14
|
+
kind: 'routed';
|
|
15
|
+
act: Act;
|
|
16
|
+
line: string;
|
|
17
|
+
} | {
|
|
18
|
+
kind: 'kept';
|
|
19
|
+
stop: KeptStop;
|
|
20
|
+
line: string;
|
|
21
|
+
untrusted?: string[];
|
|
22
|
+
} | {
|
|
23
|
+
kind: 'left';
|
|
24
|
+
why: string;
|
|
25
|
+
code: number;
|
|
26
|
+
limit?: string;
|
|
27
|
+
};
|
|
28
|
+
export declare function stillUntrusted(root: string, env: Ctx['env'], run: GateRunEntry): string[];
|
|
29
|
+
export declare function settleStop(ctx: Ctx, root: string, cfg: Config, gate: string, target: string): Promise<Settled>;
|
|
30
|
+
export declare function settledCode(code: number, s: Settled): number;
|
|
31
|
+
export interface SettleReport {
|
|
32
|
+
gate: string;
|
|
33
|
+
target: string;
|
|
34
|
+
settled: Settled;
|
|
35
|
+
}
|
|
36
|
+
export declare function settleOwed(ctx: Ctx, root: string, cfg: Config, opts?: {
|
|
37
|
+
scope?: (target: string) => boolean;
|
|
38
|
+
}): Promise<SettleReport[]>;
|
|
39
|
+
export declare function settledLine(r: SettleReport): string | undefined;
|
package/dist/settle.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { cliAct } from './act.js';
|
|
2
|
+
import { grantRows, shownCmd, sourced, trustedCommands, untrustedCmdsFor } from './allowlist.js';
|
|
2
3
|
import { arbitrate, decisionEvidence, menuFor } from './arbiter.js';
|
|
3
4
|
import { keptStopLine, policyFor } from './autonomy.js';
|
|
4
5
|
import { EXIT } from './cli.js';
|
|
@@ -9,7 +10,7 @@ import { recommend, renderDecision } from './recommend.js';
|
|
|
9
10
|
import { renderRefusal } from './refusal.js';
|
|
10
11
|
import { criteriaOwner, loadCanon } from './scan.js';
|
|
11
12
|
import { cmd, kv } from './toon.js';
|
|
12
|
-
import {
|
|
13
|
+
import { applyDecision, decisionAct } from './verbs/decide.js';
|
|
13
14
|
import { owedDecisions, owedRun } from './verbs/next.js';
|
|
14
15
|
import { pendingTxn } from './txn.js';
|
|
15
16
|
// The commands a failed check of `run` names that the repo STILL does not trust. A grant
|
|
@@ -26,7 +27,8 @@ function refusedRule(lines) {
|
|
|
26
27
|
const at = lines.findIndex((l) => /^refused\[\d+\]\{/.test(l));
|
|
27
28
|
return at >= 0 ? lines[at + 1]?.trim().split(',')[1] : undefined;
|
|
28
29
|
}
|
|
29
|
-
|
|
30
|
+
// Row 239. The command it names is an act's line, as every command witness prints.
|
|
31
|
+
const leftLine = (gate, target, why) => cmd('autonomy', `left for a human — ${why} · ${cliAct('decide', gate, target, '--show').line}`);
|
|
30
32
|
export async function settleStop(ctx, root, cfg, gate, target) {
|
|
31
33
|
const spec = gateSpec(gate);
|
|
32
34
|
if (!spec)
|
|
@@ -59,12 +61,8 @@ export async function settleStop(ctx, root, cfg, gate, target) {
|
|
|
59
61
|
// same model call to reach the same refusal (F4). It parks instead — once, reversibly,
|
|
60
62
|
// as the policy's act — exactly as a second malformed answer does. A lock or a pending
|
|
61
63
|
// transaction is transient (exit 3), so that stop is left to be tried again.
|
|
62
|
-
if (by === 'arbiter' && code === EXIT.REFUSED)
|
|
63
|
-
return
|
|
64
|
-
gate, target, decision: 'stop', selected: 'policy', runId: owed.run_id,
|
|
65
|
-
note: `parked by the policy — the arbiter's choice was refused (${rule ?? 'refused'})`,
|
|
66
|
-
}, 'policy');
|
|
67
|
-
}
|
|
64
|
+
if (by === 'arbiter' && code === EXIT.REFUSED)
|
|
65
|
+
return parkRefused(rule);
|
|
68
66
|
const why = `the ${by} decision was refused (${rule ?? `exit ${code}`})`;
|
|
69
67
|
ctx.out(leftLine(gate, target, why));
|
|
70
68
|
return { kind: 'left', why, code };
|
|
@@ -74,27 +72,56 @@ export async function settleStop(ctx, root, cfg, gate, target) {
|
|
|
74
72
|
decision: act.decision === 'revise' && act.upstream !== undefined ? 'revise-upstream' : act.decision,
|
|
75
73
|
};
|
|
76
74
|
};
|
|
75
|
+
const parkRefused = (rule) => settle({
|
|
76
|
+
gate, target, decision: 'stop', selected: 'policy', runId: owed.run_id,
|
|
77
|
+
note: `parked by the policy — the arbiter's choice was refused (${rule ?? 'refused'})`,
|
|
78
|
+
}, 'policy');
|
|
79
|
+
// Row 239. A decide act runs as its argv, through the parse the verb gives it, which prints its
|
|
80
|
+
// refusal. A shape the parse refuses is no decision the CLI can take: the policy's stop is left
|
|
81
|
+
// for a human, and the arbiter's parks (F4).
|
|
82
|
+
const parsed = (argv) => {
|
|
83
|
+
const actR = decisionAct(argv.slice(1));
|
|
84
|
+
if (!actR.ok)
|
|
85
|
+
renderRefusal(actR.violations).forEach((l) => ctx.err(l));
|
|
86
|
+
return actR;
|
|
87
|
+
};
|
|
77
88
|
if (policy.kind === 'human') {
|
|
78
89
|
// Row 194: the gate ran only on a look the human opened, so approving is their one act.
|
|
79
|
-
// Row 205 (final review): a trust grant is one
|
|
80
|
-
// the grant that names it — as `next`'s pre-flight prints it, so the chat shows the source.
|
|
90
|
+
// Row 205 (final review): a trust grant is one kept stop per command — escaped, with its source
|
|
91
|
+
// and the grant that names it — as `next`'s pre-flight prints it, so the chat shows the source.
|
|
92
|
+
// Row 239 (B12): the grant on a `run:` row of its own under the command, which is the repo's text.
|
|
81
93
|
const line = policy.stop === 'design-look'
|
|
82
|
-
? keptStopLine(policy.stop, `the human approves the screen or sends a note —
|
|
83
|
-
: sourced(cfg, canon, target, untrusted).
|
|
94
|
+
? keptStopLine(policy.stop, `the human approves the screen or sends a note — ${cliAct('decide', 'design', target, '--show').line}`)
|
|
95
|
+
: sourced(cfg, canon, target, untrusted).flatMap((c) => [keptStopLine('trust-grant', shownCmd(c)), ...grantRows(target, c)]).join('\n');
|
|
84
96
|
renderDecision(block).forEach((l) => ctx.out(l));
|
|
85
97
|
ctx.out(line);
|
|
86
98
|
return { kind: 'kept', stop: policy.stop, line, ...(policy.stop === 'trust-grant' ? { untrusted } : {}) };
|
|
87
99
|
}
|
|
88
100
|
if (policy.kind === 'take') {
|
|
89
|
-
const
|
|
90
|
-
if (
|
|
101
|
+
const { act } = policy;
|
|
102
|
+
if (act.argv[0] !== 'decide') {
|
|
91
103
|
// Not a decision: a re-run the CLI names and never executes — the stage owns it.
|
|
92
|
-
const line = cmd('autonomy', `re-run owed — ${
|
|
104
|
+
const line = cmd('autonomy', `re-run owed — ${act.line}`);
|
|
93
105
|
ctx.out(line);
|
|
94
|
-
return { kind: 'routed', line };
|
|
106
|
+
return { kind: 'routed', act, line };
|
|
107
|
+
}
|
|
108
|
+
const actR = parsed(act.argv);
|
|
109
|
+
if (!actR.ok) {
|
|
110
|
+
const why = 'the policy chose an option the CLI could not read';
|
|
111
|
+
ctx.out(leftLine(gate, target, why));
|
|
112
|
+
return { kind: 'left', why, code: EXIT.REFUSED };
|
|
95
113
|
}
|
|
96
114
|
return settle({ ...actR.value, selected: 'policy', runId: owed.run_id }, 'policy');
|
|
97
115
|
}
|
|
116
|
+
// Row 239. A `pick` answers a choose block, whose options name specs, not commands: no gate stop
|
|
117
|
+
// yields one. Should one reach here, it is no decision the CLI can take at a gate, and it fails
|
|
118
|
+
// closed — left for a human, never handed on to the arbiter, which the arms below would otherwise
|
|
119
|
+
// pay a model call for, to judge a stop the policy claimed to have answered.
|
|
120
|
+
if (policy.kind === 'pick') {
|
|
121
|
+
const why = 'the policy picked a spec, which a gate stop never takes';
|
|
122
|
+
ctx.out(leftLine(gate, target, why));
|
|
123
|
+
return { kind: 'left', why, code: EXIT.REFUSED };
|
|
124
|
+
}
|
|
98
125
|
ctx.out(cmd('arbiter', `judging ${gate} ${target} · ${block.rule}`));
|
|
99
126
|
const menu = menuFor(block, owed);
|
|
100
127
|
const ruling = await arbitrate(ctx, root, cfg, {
|
|
@@ -125,20 +152,22 @@ export async function settleStop(ctx, root, cfg, gate, target) {
|
|
|
125
152
|
const limited = ruling.violations.find((x) => x.rule === 'usage-limit');
|
|
126
153
|
return { kind: 'left', why, code: EXIT.REFUSED, ...(limited ? { limit: limited.got } : {}) };
|
|
127
154
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
155
|
+
// The one placeholder the arbiter may fill (A3): `<why>`, with its note or its reason. Row 239:
|
|
156
|
+
// filled in a copy of the chosen act's argv, as the value of its `--note`, which `decisionAct`
|
|
157
|
+
// reads as the note whatever words it holds and never as a flag. A note that is the bare `<why>`
|
|
158
|
+
// leaves the slot unfilled, which the door refuses, and the flow parks (F4). An option with no
|
|
159
|
+
// slot carries no note: a bare revise journals the prefill `decide` derives, and the reason is
|
|
160
|
+
// journaled beside either.
|
|
161
|
+
const chosen = menu[ruling.value.choice - 1].act;
|
|
162
|
+
const argv = [...chosen.argv];
|
|
163
|
+
for (const i of chosen.inputs)
|
|
164
|
+
if (i.name === 'why')
|
|
165
|
+
argv[i.at] = ruling.value.note ?? ruling.value.reason;
|
|
166
|
+
const actR = parsed(argv);
|
|
167
|
+
if (!actR.ok)
|
|
168
|
+
return parkRefused(actR.violations[0]?.rule);
|
|
139
169
|
return settle({
|
|
140
|
-
...actR.value,
|
|
141
|
-
selected: 'arbiter', reason: ruling.value.reason,
|
|
170
|
+
...actR.value, selected: 'arbiter', reason: ruling.value.reason,
|
|
142
171
|
arbiter: { model: ruling.value.model, prompts_sha: ruling.value.prompts_sha },
|
|
143
172
|
runId: owed.run_id,
|
|
144
173
|
}, 'arbiter');
|
package/dist/sha.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const VOLATILE_FIELDS: readonly ["status", "drift", "pr", "design"];
|
|
2
|
+
export declare function canonicalJson(value: unknown): string;
|
|
3
|
+
export declare function canonicalSha(meta: Record<string, unknown>, body: string): string;
|
|
4
|
+
export declare function planContentSha(meta: Record<string, unknown>, body: string): string;
|
|
5
|
+
export declare function short(sha: string): string;
|
package/dist/ship.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type Ctx } from './cli.js';
|
|
2
|
+
import { type Config } from './config.js';
|
|
3
|
+
import { type Entry } from './journal.js';
|
|
4
|
+
import { type HeldRow } from './needs.js';
|
|
5
|
+
import { type CanonDoc } from './scan.js';
|
|
6
|
+
import { type Result } from './refusal.js';
|
|
7
|
+
export type ShipPhase = 'gate' | 'awaiting-decision' | 'pr' | 'watch';
|
|
8
|
+
export declare function shipPhase(plan: CanonDoc, entries: Entry[], treeSha?: string, baseMoved?: boolean, holdLifted?: boolean): ShipPhase;
|
|
9
|
+
export declare function existingPr(ctx: Ctx, root: string, branch: string): number | undefined;
|
|
10
|
+
export declare function prBody(plan: CanonDoc, held: HeldRow[]): string;
|
|
11
|
+
export declare function createPr(ctx: Ctx, wt: string, root: string, plan: CanonDoc, parentSummary: string, held?: HeldRow[]): Result<number>;
|
|
12
|
+
export declare function stampPr(ctx: Ctx, root: string, planId: string, pr: number): Result<{
|
|
13
|
+
sha: string;
|
|
14
|
+
}>;
|
|
15
|
+
export declare function baseMoved(wt: string, root: string, shipBranch: string, remote?: string): boolean;
|
|
16
|
+
export declare function rebaseIfMoved(wt: string, root: string, shipBranch: string, remote?: string): Result<'clean' | 'rebased'>;
|
|
17
|
+
export declare function mergeOwnPr(ctx: Ctx, root: string, cfg: Config, planId: string, pr: number, pushed?: string): number;
|
|
18
|
+
export declare function runShip(ctx: Ctx, planId: string, opts?: {
|
|
19
|
+
manual?: boolean;
|
|
20
|
+
}): Promise<number>;
|