@popovych.co/witness 0.29.0 → 0.30.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.
Files changed (65) hide show
  1. package/README.md +1 -1
  2. package/dist/arbiter.d.ts +1 -0
  3. package/dist/arbiter.js +20 -3
  4. package/dist/autonomy.js +8 -0
  5. package/dist/carry.d.ts +74 -0
  6. package/dist/carry.js +687 -0
  7. package/dist/clash.d.ts +23 -0
  8. package/dist/clash.js +225 -0
  9. package/dist/cli.js +1 -1
  10. package/dist/content-sha.d.ts +3 -0
  11. package/dist/content-sha.js +44 -0
  12. package/dist/decide-view.d.ts +10 -1
  13. package/dist/decide-view.js +55 -30
  14. package/dist/drift.js +5 -3
  15. package/dist/drive.d.ts +5 -4
  16. package/dist/drive.js +89 -47
  17. package/dist/evidence.js +319 -27
  18. package/dist/gate.d.ts +2 -0
  19. package/dist/gate.js +242 -56
  20. package/dist/gates/decompose.js +3 -2
  21. package/dist/gates/design.js +3 -5
  22. package/dist/gates/implement.js +4 -8
  23. package/dist/gates/plan.js +3 -4
  24. package/dist/gates/ship.js +4 -7
  25. package/dist/gitio.d.ts +1 -0
  26. package/dist/gitio.js +5 -0
  27. package/dist/harness.d.ts +1 -0
  28. package/dist/harness.js +3 -1
  29. package/dist/journal.d.ts +10 -1
  30. package/dist/progress.js +3 -0
  31. package/dist/recommend.d.ts +3 -0
  32. package/dist/recommend.js +148 -23
  33. package/dist/reviewer.d.ts +3 -3
  34. package/dist/reviewer.js +117 -55
  35. package/dist/rounds.d.ts +43 -4
  36. package/dist/rounds.js +419 -65
  37. package/dist/session-end.d.ts +14 -0
  38. package/dist/session-end.js +89 -0
  39. package/dist/settle.d.ts +1 -0
  40. package/dist/settle.js +24 -8
  41. package/dist/ship.d.ts +13 -1
  42. package/dist/ship.js +438 -82
  43. package/dist/slice.js +4 -2
  44. package/dist/stamp.js +11 -0
  45. package/dist/verbs/check.js +57 -6
  46. package/dist/verbs/dashboard.js +15 -14
  47. package/dist/verbs/decide.js +106 -84
  48. package/dist/verbs/evidence.js +12 -1
  49. package/dist/verbs/gate.js +5 -2
  50. package/dist/verbs/log.js +25 -9
  51. package/dist/verbs/next.d.ts +10 -1
  52. package/dist/verbs/next.js +365 -82
  53. package/dist/verbs/turn.js +13 -0
  54. package/dist/worker-stream.d.ts +7 -0
  55. package/dist/worker-stream.js +150 -5
  56. package/package.json +1 -1
  57. package/plugin/.claude-plugin/plugin.json +1 -1
  58. package/plugin/commands/witness.md +14 -2
  59. package/plugin/hooks/session-dashboard.sh +1 -1
  60. package/plugin/skills/witness-brainstorm/SKILL.md +2 -2
  61. package/plugin/skills/witness-decompose/SKILL.md +3 -3
  62. package/plugin/skills/witness-design/SKILL.md +3 -3
  63. package/plugin/skills/witness-implement/SKILL.md +5 -5
  64. package/plugin/skills/witness-plan/SKILL.md +3 -3
  65. package/plugin/skills/witness-ship/SKILL.md +40 -22
package/README.md CHANGED
@@ -306,7 +306,7 @@ the wrong file refuses. There are no `WITNESS_*` env vars for configuration.
306
306
  | `retry <target>` | ask drive to try a set-aside target again, after a fix that leaves no record of its own (code, a tool, an account); refused inside a session |
307
307
  | `wait [--since <token>]` | under autonomy, block until something new needs you, drive stops with work left, a merge lands on GitHub, or a newer chat takes over — the `/witness` chat runs it; journals nothing |
308
308
  | `log <id>` | render a journal stream |
309
- | `gate <decompose\|plan\|implement\|ship\|design> <id>` | run the reviewer gate; journals the round, stamps on pass |
309
+ | `gate <decompose\|plan\|implement\|ship\|design> <id> [--fresh] [--manual] [--unchanged]` | run the reviewer gate; journals the round, stamps on pass · `--unchanged` hands a revise back when the author judges it needs no change: where the gate would answer changed-nothing it journals the hand-back and the revise is decided again, and anywhere else it runs as the plain gate and says why nothing was handed back |
310
310
  | `decide <gate> <id> --approve\|--revise [--pin <policy>]` | record the human decision on a stopped gate; `--pin` adds a standing content policy |
311
311
  | `design <spec-id> --file <html>\|--open\|--reconfirm\|--preview <html>` | register/show a `ui` spec's approved look; `--preview` opens a page and records nothing |
312
312
  | `review design <spec-id> [--file <html>]` | the design gate's reviewers on a look — the registered one, or a page not yet registered — asking the gate's full-review question; journals nothing, decides nothing, and replays the gate's answer when the gate already judged the same bytes in full |
package/dist/arbiter.d.ts CHANGED
@@ -28,6 +28,7 @@ export declare function arbitrate(ctx: Ctx, root: string, cfg: Config, req: Arbi
28
28
  export declare function menuFor(block: Decision, run: GateRunEntry): Array<Option & {
29
29
  act: Act;
30
30
  }>;
31
+ export declare const HANDED_BACK_FACT = "the author handed this revise back with the content unchanged";
31
32
  export declare function decisionEvidence(root: string, canon: Canon, stop: {
32
33
  gate: string;
33
34
  target: string;
package/dist/arbiter.js CHANGED
@@ -9,7 +9,7 @@ import { SESSION_DEFAULT, stageModel, unansweredPin } from './model.js';
9
9
  import { ok, refuse, v } from './refusal.js';
10
10
  import { invokeReviewerAsync, parseVerdictText, promptsSha, resolvePrompt } from './reviewer.js';
11
11
  import { effortCanon, effortOf } from './reviewed.js';
12
- import { anchorRecurrence, gateRuns, roundBudget } from './rounds.js';
12
+ import { REVISE_HUMAN, anchorRecurrence, gateRuns, roundBudget } from './rounds.js';
13
13
  import { findById } from './scan.js';
14
14
  import { canonicalJson } from './sha.js';
15
15
  // How a later mode adds its own prompt without a second invoker.
@@ -98,19 +98,31 @@ export async function arbitrate(ctx, root, cfg, req) {
98
98
  // Row 239. Read off each option's act, never its printed line: an option the CLI built from no
99
99
  // act is not offered, a word is a flag only where the act holds it as one, and the one input the
100
100
  // arbiter may fill is the `<why>` slot (settle fills it through argv).
101
+ // Row 244 (design §4.2.6, §4.2.7; P38). The arbiter never revises a gate a revise already stands on:
102
+ // in the states where a plain revise is the human's alone (`REVISE_HUMAN`) every plain revise goes,
103
+ // the noted one included, while the send-upstream stays. A handed-back revise (`revise-returned`) is
104
+ // the one such state a settle brings to the arbiter, and there it matters twice over: hand-backs spend
105
+ // no rounds, so the bound would never stop a revise → hand-back loop.
101
106
  export function menuFor(block, run) {
102
107
  const failed = run.checks.filter((c) => !c.ok);
103
108
  const approveBarred = run.gate === 'design' || (failed.length > 0 && !failed.every((c) => c.name === 'amendment-ack'));
109
+ const reviseBarred = block.state !== undefined && REVISE_HUMAN.has(block.state);
110
+ const plainRevise = (argv) => argv.includes('--revise') && !argv.includes('--upstream') && !argv.includes('--repair');
104
111
  return block.options.filter((o) => o.act?.argv[0] === 'decide' &&
105
112
  !o.act.argv.includes('--trust-cmds') &&
106
113
  o.act.inputs.every((i) => i.name === 'why') &&
107
- !(approveBarred && o.act.argv.includes('--approve')));
114
+ !(approveBarred && o.act.argv.includes('--approve')) &&
115
+ !(reviseBarred && plainRevise(o.act.argv)));
108
116
  }
117
+ // Row 244 (design §4.2.6). A hand-back as the arbiter hears it: a journal fact in this fixed sentence,
118
+ // never a word the author wrote (anti-goal 1) — the entry carries none, and no field of it is read.
119
+ export const HANDED_BACK_FACT = 'the author handed this revise back with the content unchanged';
109
120
  const anchorText = (a) => (typeof a === 'string' ? a : `omission:${a.scope}`);
110
121
  const HISTORY_RUNS = 10;
111
122
  // The evidence the arbiter reads, composed by the CLI from the journal and canon. It never
112
123
  // carries a session transcript: none exists to carry, and the author's narration is
113
- // exactly what the arbiter must not hear (anti-goal 1).
124
+ // exactly what the arbiter must not hear (anti-goal 1). A hand-back reaches it as a fact the CLI
125
+ // states (`HANDED_BACK_FACT`), never as the author's account of why.
114
126
  export function decisionEvidence(root, canon, stop) {
115
127
  const { gate, target, entries, run, block } = stop;
116
128
  const findings = (run.verdicts ?? []).flatMap((rv) => rv.findings.map((f) => ({ reviewer: rv.reviewer, f })));
@@ -145,6 +157,11 @@ export function decisionEvidence(root, canon, stop) {
145
157
  for (const e of entries.slice(at + 1)) {
146
158
  if (e.t === 'gate-run' && e.gate === gate)
147
159
  break;
160
+ // Row 244 (design §4.2.6). The hand-back in its place among the gate's decisions, after the revise it answers.
161
+ if (e.t === 'revise-returned' && e.gate === gate) {
162
+ history.push(` - handed back · ${HANDED_BACK_FACT}`);
163
+ continue;
164
+ }
148
165
  if (e.t !== 'human-decision' || e.gate !== gate)
149
166
  continue;
150
167
  const d = e;
package/dist/autonomy.js CHANGED
@@ -80,6 +80,13 @@ export function policyFor(facts) {
80
80
  if (failed.some((c) => (c.untrusted?.length ?? 0) > 0) && !boundReached(entries, gate)) {
81
81
  return { kind: 'take', act: cliAct('gate', gate, target) };
82
82
  }
83
+ // Row 244 (design §4.2.6; the user's decision 2). A revise its author handed back unchanged is decided
84
+ // again, by the arbiter: neither the author nor a reviewer found a fix, so no rule has the right
85
+ // answer. It comes after the arms that belong elsewhere — the human's trust grant, the free re-runs
86
+ // (stale or malformed, fallen back, trust granted since) and the human's design look — and stays out
87
+ // of TAKEN, whose revise the author would only hand back again.
88
+ if (block.rule === 'revise-returned')
89
+ return { kind: 'arbiter' };
83
90
  if (block.rule === 'checks-failed') {
84
91
  // amendment-ack is the one check an approve clears, so approving is a judgment about the
85
92
  // amendment against the ask — the arbiter's, never the rule's (§11 call 10).
@@ -88,6 +95,7 @@ export function policyFor(facts) {
88
95
  if (TAKEN.has(block.rule) || block.rule.startsWith('anchor-recurrence-'))
89
96
  return first();
90
97
  // bound · bound-stale · ladder-spent · pin-contradiction · reserved-stop-clean · manual-stop
98
+ // (revise-returned has its own arm above)
91
99
  return { kind: 'arbiter' };
92
100
  }
93
101
  // Row 173. Who made a disposition, in one spelling for every surface that says so
@@ -0,0 +1,74 @@
1
+ import { type Result, type Violation } from './refusal.js';
2
+ import { type Platform } from './toon.js';
3
+ export declare const CARRY_ACTION = "witness-carry";
4
+ export declare function carryGit(wt: string, ...args: string[]): {
5
+ code: number | null;
6
+ stdout: string;
7
+ stderr: string;
8
+ };
9
+ export declare function carryRef(planId: string): string;
10
+ export declare function keptPrefix(planId: string): string;
11
+ export type OpInProgress = 'rebase-merge' | 'rebase-apply' | 'MERGE_HEAD' | 'CHERRY_PICK_HEAD' | 'REVERT_HEAD';
12
+ export declare function operationInProgress(wt: string): OpInProgress | undefined;
13
+ export interface UnmergedPath {
14
+ path: string;
15
+ stages: Partial<Record<1 | 2 | 3, string>>;
16
+ }
17
+ export declare function unmergedPaths(wt: string): UnmergedPath[];
18
+ export interface KeptRef {
19
+ ref: string;
20
+ sha: string;
21
+ files: string[];
22
+ }
23
+ export declare function keptRefs(wt: string, planId: string): KeptRef[];
24
+ export declare function keepCarry(wt: string, planId: string, carry: string, files: string[]): Result<string>;
25
+ export declare function carryPending(planId: string, got: string): Violation;
26
+ export declare function seeWork(ref: string): string;
27
+ export declare function carryGone(planId: string, wt: string): Violation;
28
+ export declare function offBranchPending(planId: string, head: string): Violation;
29
+ export declare function sessionUnmerged(planId: string, files: readonly UnmergedPath[]): Violation[];
30
+ export declare function restorePending(planId: string, got: string): Violation;
31
+ export declare function touchedRebasePending(planId: string, why: string): Violation;
32
+ export declare function heldLock(wt: string, out: string, locks?: readonly string[]): string | undefined;
33
+ export declare function lockedRow(planId: string, lock: string, carried: boolean, unfinished?: boolean): Violation;
34
+ export declare function headReflog(wt: string): string[];
35
+ export type RebaseOwner = 'witness' | 'session' | 'silent';
36
+ export declare function rebaseOwnerSince(wt: string, op: OpInProgress | undefined, out: string, before: readonly string[]): RebaseOwner;
37
+ export declare function witnessOwnRebase(wt: string, carry: string): RebaseOwner;
38
+ export type StopReading = {
39
+ fresh: true;
40
+ unmerged: UnmergedPath[];
41
+ } | {
42
+ fresh: false;
43
+ why: string;
44
+ };
45
+ export declare function freshStop(wt: string): StopReading;
46
+ export declare function keepStopped(wt: string, planId: string, files: readonly string[]): Result<string>;
47
+ export declare function gitAtLeast(versionLine: string, major: number, minor: number): boolean;
48
+ export declare function blobAt(wt: string, rev: string, path: string): string | undefined;
49
+ export declare function workAlreadyBack(wt: string, carry: string): {
50
+ back: boolean;
51
+ lock?: string;
52
+ };
53
+ export declare function operationRefusal(wt: string, planId: string, op: OpInProgress, silent?: boolean): Violation;
54
+ export declare function captureCarry(wt: string, planId: string): Result<string | undefined>;
55
+ export declare function cleanTree(wt: string, planId: string): Result<void>;
56
+ export type Reapplied = {
57
+ kind: 'clean';
58
+ kept?: string;
59
+ } | {
60
+ kind: 'clash';
61
+ kept: string;
62
+ files: UnmergedPath[];
63
+ } | {
64
+ kind: 'refused';
65
+ out: string;
66
+ } | {
67
+ kind: 'locked';
68
+ lock: string;
69
+ };
70
+ export declare function reapply(wt: string, planId: string, carry: string): Reapplied;
71
+ export declare function dropCarry(wt: string, planId: string, carry: string): Reapplied;
72
+ export declare function baseInTheWay(wt: string, planId: string, base: string): Result<void>;
73
+ export declare function untrackedInTheWay(wt: string, paths: readonly string[]): string[] | undefined;
74
+ export declare function remedyLine(argv: readonly string[], platform?: Platform): string;