@popovych.co/witness 0.28.1 → 0.28.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/dist/allowlist.js CHANGED
@@ -54,9 +54,13 @@ export function untrustedCmdsFor(root, doc) {
54
54
  // drive's report, the chat — renders it here: escaped, beside its source, and with the grant
55
55
  // that names it only when the verb would take it (printable ASCII, `witness trust`).
56
56
  export const shownCmd = (c) => `${visible(c.cmd)} (${visible(c.source)})`;
57
+ export const UNGRANTABLE = 'never granted here — rewrite it in printable ASCII where it is written';
57
58
  export const grantOf = (target, c) => hasControl(c.cmd)
58
- ? 'never granted here — rewrite it in printable ASCII where it is written'
59
+ ? UNGRANTABLE
59
60
  : `witness trust ${target} --cmd ${shellArg(c.cmd)}`;
61
+ // Row 205. The commands a grant leaves blocked for that reason, counted: the trust verb's summary
62
+ // and `decide --approve --trust-cmds` say it in these words.
63
+ export const unsafeLeft = (n) => `${n} carry characters outside printable ASCII — never granted here · rewrite where it is written`;
60
64
  // The filtered runner template, `ship.test`, `ship.lint`, each when set. Full-suite mode's
61
65
  // runner IS `ship.test`, and a command listed twice is listed once, under its first source.
62
66
  export function configCommands(cfg) {
@@ -131,6 +135,11 @@ export async function ensureTrusted(root, ctx, cmd) {
131
135
  const commands = load(root);
132
136
  if (commands.includes(cmd))
133
137
  return 'trusted';
138
+ // Row 237. The prompt is where a human reads the command, so a command they cannot read whole —
139
+ // one holding any character outside printable ASCII — is never offered, and so never granted
140
+ // here. Automation and the human's own list, above, still answer first.
141
+ if (hasControl(cmd))
142
+ return 'blocked';
134
143
  if (!ctx.isTTY)
135
144
  return 'blocked';
136
145
  const answer = await ctx.ask(`witness wants to run: ${cmd}\ntrust this command? saves to .witness/allow.json (gitignored) [y/N]`);
package/dist/needs.js CHANGED
@@ -1,5 +1,6 @@
1
- import { ensureTrusted } from './allowlist.js';
1
+ import { ensureTrusted, UNGRANTABLE } from './allowlist.js';
2
2
  import { execSync } from './spawn.js';
3
+ import { hasControl } from './toon.js';
3
4
  // Row 179. What a journaled satisfaction names a need by: its id, else its manual text.
4
5
  export function needKey(n) {
5
6
  return n.id ?? n.manual;
@@ -26,9 +27,12 @@ export async function evaluateNeeds(root, ctx, needs, doc) {
26
27
  else if (typeof n.cmd === 'string') {
27
28
  const trust = await ensureTrusted(root, ctx, n.cmd);
28
29
  if (trust !== 'trusted') {
30
+ // Row 237. No grant exists for a command outside printable ASCII, so its remedy says so
31
+ // rather than send the human to `witness next` for one.
32
+ const blocked = hasControl(n.cmd) ? UNGRANTABLE : 'untrusted on this machine — witness next names the grant to make';
29
33
  out.push({
30
34
  label: n.cmd, kind: 'cmd', status: trust,
31
- detail: trust === 'blocked' ? 'untrusted on this machine — witness next names the grant to make' : 'trust declined',
35
+ detail: trust === 'blocked' ? blocked : 'trust declined',
32
36
  });
33
37
  continue;
34
38
  }
package/dist/recommend.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { anchorRecurrence, boundReached, ladderSpent, lastGateRun, notePrefill, pendingDecision, repairsOnRegate, repairGranted, roundBudget, roundsSinceApprove, } from './rounds.js';
2
+ import { hasControl, visible } from './toon.js';
2
3
  // Commands are emitted raw (D120): `esc` would quote the `--note "…"` argument and the
3
4
  // line would paste into a shell as an empty note.
4
5
  export function renderDecision(d) {
@@ -42,13 +43,18 @@ const opt = (command, depth, rest = {}) => ({ command, depth, runnable: !PLACEHO
42
43
  // checks-failed · non-blocking-only · reserved-stop-clean · manual-stop
43
44
  // D154. Trust must never be the toll for approval. Where a plain `--approve` is offered
44
45
  // and the artifact carries untrusted `cmd:` criteria, the block renders BOTH forms — plain
45
- // first, so approving without granting stays the easy path — and names the commands
46
- // verbatim, because a grant the human cannot read is not one they made. Applied once, over
47
- // the finished option list, rather than at each of the five rules that offer an approve.
46
+ // first, so approving without granting stays the easy path — and names the commands, because
47
+ // a grant the human cannot read is not one they made. Applied once, over the finished option
48
+ // list, rather than at each of the five rules that offer an approve.
49
+ // Row 205. The twin grants what `witness trust` would and nothing else: a command holding a
50
+ // character outside printable ASCII is never granted. So the plain approve names every untrusted
51
+ // command, each spelled out (`visible`), since all of them stay blocked; the twin is offered only
52
+ // while one is grantable, and prices only those.
48
53
  function withTrustVariants(d, untrusted) {
49
54
  if (untrusted.length === 0)
50
55
  return d;
51
- const listed = untrusted.join(' · ');
56
+ const listed = untrusted.map(visible).join(' · ');
57
+ const grantable = untrusted.filter((c) => !hasControl(c));
52
58
  const options = [];
53
59
  for (const o of d.options) {
54
60
  options.push(o);
@@ -61,11 +67,13 @@ function withTrustVariants(d, untrusted) {
61
67
  tradeoff: [o.tradeoff, `the listed commands stay blocked at headless gates: ${listed}`]
62
68
  .filter(Boolean).join(' · '),
63
69
  };
70
+ if (grantable.length === 0)
71
+ continue;
64
72
  // The twin is the same stamp plus a grant, so it carries the stamp's depth: next to a
65
73
  // deferral approve (checks-failed) it is a deferral too, never a root fix.
66
74
  options.push(opt(`${o.command} --trust-cmds`, o.depth, {
67
75
  when: 'you have read these commands and accept them running unattended at every later gate',
68
- tradeoff: `grants them repo-wide in .witness/allow.json (machine-local): ${listed}`,
76
+ tradeoff: `grants them repo-wide in .witness/allow.json (machine-local): ${grantable.join(' · ')}`,
69
77
  note: 'a bare affirmation never grants trust — this form must be named (D143)',
70
78
  }));
71
79
  }
package/dist/runner.js CHANGED
@@ -1,11 +1,12 @@
1
1
  import { rmSync } from 'node:fs';
2
2
  import { join } from 'node:path';
3
- import { ensureTrusted } from './allowlist.js';
3
+ import { ensureTrusted, UNGRANTABLE } from './allowlist.js';
4
4
  import { mergeReports, reportFiles } from './junit.js';
5
5
  import { ok, refuse, v } from './refusal.js';
6
6
  import { contained, JOB_HOST_ENV, jobHost } from './contain.js';
7
7
  import { withRunnerTurn } from './runner-lock.js';
8
8
  import { execFileSync, execSync, system32 } from './spawn.js';
9
+ import { hasControl } from './toon.js';
9
10
  // The values' own shapes (a runner with {id}, a junit: report) are refused when the file loads
10
11
  // (row 193); what is left is what only a combination says, and what an older file never set.
11
12
  export function runnerConfig(cfg) {
@@ -87,17 +88,20 @@ export function untrustedOf(violations) {
87
88
  // Row 205. The runner knows no target, so it names the verb that does: `next` prints the grant
88
89
  // to make, and the human names the command in the chat. The env var is the automation route.
89
90
  const UNTRUSTED_WANT = 'a trusted command — witness next names the grant to make, or set WITNESS_TRUST_CMDS=1 for automation';
91
+ // Row 237. No grant exists for a command outside printable ASCII, so its refusal says so rather
92
+ // than send the human to `witness next` for one.
93
+ const blockedWant = (cmd) => hasControl(cmd) ? UNGRANTABLE : UNTRUSTED_WANT;
90
94
  export async function runFiltered(runRoot, ctx, template, specId, trustRoot = runRoot) {
91
95
  const trust = await ensureTrusted(trustRoot, ctx, template);
92
96
  if (trust !== 'trusted') {
93
- return refuse([v('criteria.runner', `untrusted-${trust}`, template, trust === 'blocked' ? UNTRUSTED_WANT : 'trust was declined')]);
97
+ return refuse([v('criteria.runner', `untrusted-${trust}`, template, trust === 'blocked' ? blockedWant(template) : 'trust was declined')]);
94
98
  }
95
99
  return ok(execCommand(runRoot, ctx, template.replaceAll('{id}', specId)));
96
100
  }
97
101
  export async function runFullSuite(runRoot, ctx, rc, trustRoot = runRoot) {
98
102
  const trust = await ensureTrusted(trustRoot, ctx, rc.suiteCmd);
99
103
  if (trust !== 'trusted') {
100
- return refuse([v('ship.test', `untrusted-${trust}`, rc.suiteCmd, trust === 'blocked' ? UNTRUSTED_WANT : 'trust was declined')]);
104
+ return refuse([v('ship.test', `untrusted-${trust}`, rc.suiteCmd, trust === 'blocked' ? blockedWant(rc.suiteCmd) : 'trust was declined')]);
101
105
  }
102
106
  for (const f of reportFiles(runRoot, rc.reportGlob))
103
107
  rmSync(join(runRoot, f));
@@ -1,6 +1,6 @@
1
1
  import { join } from 'node:path';
2
2
  import { EXIT } from '../cli.js';
3
- import { untrustedCmdsFor } from '../allowlist.js';
3
+ import { unsafeLeft, untrustedCmdsFor } from '../allowlist.js';
4
4
  import { loadConfig } from '../config.js';
5
5
  import { designUnseen } from '../design.js';
6
6
  import { dropDraft } from '../drafts.js';
@@ -21,7 +21,7 @@ import { newRunId } from '../drift.js';
21
21
  import { grantTrust } from './trust.js';
22
22
  import { ok, refuse, renderRefusal, v } from '../refusal.js';
23
23
  import { short } from '../sha.js';
24
- import { cmd, kv, rows } from '../toon.js';
24
+ import { cmd, hasControl, kv, rows } from '../toon.js';
25
25
  import { ROUND_BOUND, anchorRecurrence, boundReached, lastGateRun, openReopen, pendingDecision, repairGranted, roundsSinceApprove, } from '../rounds.js';
26
26
  import { prepareStamp, writeStamp } from '../stamp.js';
27
27
  import { handOverIfDue } from '../slice.js';
@@ -656,7 +656,12 @@ export async function applyDecision(ctx, act) {
656
656
  // and a grant it could not land is refused with its rows and the exit says so.
657
657
  let grantExit = EXIT.OK;
658
658
  if (trustCmds) {
659
- const granted = untrustedCmdsFor(root, criteriaOwner(canon, target));
659
+ // Row 205. The grant takes what `witness trust` would and nothing else: a command holding a
660
+ // character outside printable ASCII is never granted, so it stays blocked and is counted, and
661
+ // "nothing to grant" claims every criterion trusted only when none is left that way.
662
+ const untrusted = untrustedCmdsFor(root, criteriaOwner(canon, target));
663
+ const granted = untrusted.filter((c) => !hasControl(c));
664
+ const unsafe = untrusted.length - granted.length;
660
665
  if (granted.length > 0) {
661
666
  const res = grantTrust(ctx, root, target, granted, 'decide');
662
667
  if (res.ok)
@@ -668,8 +673,10 @@ export async function applyDecision(ctx, act) {
668
673
  }
669
674
  }
670
675
  else {
671
- ctx.out(kv('trusted', 'nothing to grant — every cmd: criterion was already trusted'));
676
+ ctx.out(kv('trusted', unsafe === 0 ? 'nothing to grant — every cmd: criterion was already trusted' : 'nothing to grant'));
672
677
  }
678
+ if (unsafe > 0)
679
+ ctx.out(kv('trust', unsafeLeft(unsafe)));
673
680
  }
674
681
  // Row 173: a decision nobody typed says so, with the rule it acted on.
675
682
  const by = act.selected === 'policy' || act.selected === 'arbiter'
@@ -1,6 +1,6 @@
1
1
  import { parseArgs } from 'node:util';
2
2
  import { EXIT } from '../cli.js';
3
- import { commandsRun, grantCommands, repoCommands, trustedCommands } from '../allowlist.js';
3
+ import { commandsRun, grantCommands, repoCommands, trustedCommands, unsafeLeft } from '../allowlist.js';
4
4
  import { loadConfig } from '../config.js';
5
5
  import { sessionMarker } from '../drive-presence.js';
6
6
  import { primaryRoot, stateCommit } from '../gitio.js';
@@ -84,7 +84,7 @@ export async function run(ctx, argv) {
84
84
  ctx.out(kv('trust', 'every command is already trusted'));
85
85
  return EXIT.OK;
86
86
  }
87
- ctx.out(kv('trust', `${unsafe} carry characters outside printable ASCII — never granted here · rewrite where it is written`));
87
+ ctx.out(kv('trust', unsafeLeft(unsafe)));
88
88
  return EXIT.FINDINGS;
89
89
  };
90
90
  if (id === undefined) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@popovych.co/witness",
3
- "version": "0.28.1",
3
+ "version": "0.28.2",
4
4
  "description": "Evidence-gated spec-driven development pipeline for AI coding agents: brainstorm to PR in six stages, where specs are state, plans are motion, and no transition passes without evidence. Drives from Claude Code or Pi.",
5
5
  "keywords": [
6
6
  "spec-driven-development",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "witness",
3
3
  "description": "Spec-driven development with evidence gates: brainstorm → PR through six stages and five gates. Skills author, the pinned witness CLI writes state and witnesses evidence; gates stop where judgment is owed.",
4
- "version": "0.28.1",
4
+ "version": "0.28.2",
5
5
  "author": {
6
6
  "name": "Kostiantyn Popovych"
7
7
  },
@@ -12,7 +12,7 @@ Any other words in `$ARGUMENTS` are the human's ask: run `$WITNESS ask "<those w
12
12
  Resolve the CLI once:
13
13
 
14
14
  ```bash
15
- WITNESS="${WITNESS_BIN:-npx -y @popovych.co/witness@0.28.1}"
15
+ WITNESS="${WITNESS_BIN:-npx -y @popovych.co/witness@0.28.2}"
16
16
  ```
17
17
 
18
18
  If the repo has no `witness.config.yaml`, run `$WITNESS init` first (one bootstrap commit), then proceed. If init or any verb refuses on a dirty tree, the human commits or cleans it — **never `git commit` yourself, anywhere, at any stage**: the CLI makes its own state commits, and the ship phase makes the sole code commit.
@@ -5,4 +5,4 @@
5
5
  [ -f witness.config.yaml ] || exit 0
6
6
  # row 217: a reviewer reads; it never runs witness
7
7
  [ -n "$WITNESS_REVIEWER" ] && exit 0
8
- ${WITNESS_BIN:-npx -y @popovych.co/witness@0.28.1} 2>/dev/null || true
8
+ ${WITNESS_BIN:-npx -y @popovych.co/witness@0.28.2} 2>/dev/null || true
@@ -16,7 +16,7 @@ recap, keeps a local draft, writes no document. See NOTICE.md. -->
16
16
  Resolve the CLI once per session:
17
17
 
18
18
  ```bash
19
- WITNESS="${WITNESS_BIN:-npx -y @popovych.co/witness@0.28.1}"
19
+ WITNESS="${WITNESS_BIN:-npx -y @popovych.co/witness@0.28.2}"
20
20
  ```
21
21
 
22
22
  - **Render the CLI's decision output verbatim and in full — every line, unmodified.** Never print a command set you remember; never recompose, reformat, summarise or reorder what the CLI emitted. Which decisions are live, how they rank, and what each costs are the CLI's answers, and they change with the round, the bound, the repair grant and the content sha — a remembered set is wrong in more states than it is right.
@@ -10,7 +10,7 @@ description: Slice a witness effort's confirmed recap into vertical spec slices,
10
10
  Resolve the CLI once per session:
11
11
 
12
12
  ```bash
13
- WITNESS="${WITNESS_BIN:-npx -y @popovych.co/witness@0.28.1}"
13
+ WITNESS="${WITNESS_BIN:-npx -y @popovych.co/witness@0.28.2}"
14
14
  ```
15
15
 
16
16
  - **Render the CLI's decision output verbatim and in full — every line, unmodified.** Never print a command set you remember; never recompose, reformat, summarise or reorder what the CLI emitted. Which decisions are live, how they rank, and what each costs are the CLI's answers, and they change with the round, the bound, the repair grant and the content sha — a remembered set is wrong in more states than it is right.
@@ -16,7 +16,7 @@ No text copied verbatim; the design-critic lens is new material. -->
16
16
  Resolve the CLI once per session:
17
17
 
18
18
  ```bash
19
- WITNESS="${WITNESS_BIN:-npx -y @popovych.co/witness@0.28.1}"
19
+ WITNESS="${WITNESS_BIN:-npx -y @popovych.co/witness@0.28.2}"
20
20
  ```
21
21
 
22
22
  - **Render the CLI's decision output verbatim and in full — every line, unmodified.** Never print a command set you remember; never recompose, reformat, summarise or reorder what the CLI emitted. Which decisions are live, how they rank, and what each costs are the CLI's answers, and they change with the round, the bound, the repair grant and the content sha — a remembered set is wrong in more states than it is right.
@@ -15,7 +15,7 @@ tests carry the parent spec's tag in their NAME. See NOTICE.md. -->
15
15
  Resolve the CLI once per session:
16
16
 
17
17
  ```bash
18
- WITNESS="${WITNESS_BIN:-npx -y @popovych.co/witness@0.28.1}"
18
+ WITNESS="${WITNESS_BIN:-npx -y @popovych.co/witness@0.28.2}"
19
19
  ```
20
20
 
21
21
  - **Render the CLI's decision output verbatim and in full — every line, unmodified.** Never print a command set you remember; never recompose, reformat, summarise or reorder what the CLI emitted. Which decisions are live, how they rank, and what each costs are the CLI's answers, and they change with the round, the bound, the repair grant and the content sha — a remembered set is wrong in more states than it is right.
@@ -15,7 +15,7 @@ parent's criteria. See NOTICE.md. -->
15
15
  Resolve the CLI once per session:
16
16
 
17
17
  ```bash
18
- WITNESS="${WITNESS_BIN:-npx -y @popovych.co/witness@0.28.1}"
18
+ WITNESS="${WITNESS_BIN:-npx -y @popovych.co/witness@0.28.2}"
19
19
  ```
20
20
 
21
21
  - **Render the CLI's decision output verbatim and in full — every line, unmodified.** Never print a command set you remember; never recompose, reformat, summarise or reorder what the CLI emitted. Which decisions are live, how they rank, and what each costs are the CLI's answers, and they change with the round, the bound, the repair grant and the content sha — a remembered set is wrong in more states than it is right.
@@ -15,7 +15,7 @@ model can. See NOTICE.md. -->
15
15
  Resolve the CLI once per session:
16
16
 
17
17
  ```bash
18
- WITNESS="${WITNESS_BIN:-npx -y @popovych.co/witness@0.28.1}"
18
+ WITNESS="${WITNESS_BIN:-npx -y @popovych.co/witness@0.28.2}"
19
19
  ```
20
20
 
21
21
  - **Render the CLI's decision output verbatim and in full — every line, unmodified.** Never print a command set you remember; never recompose, reformat, summarise or reorder what the CLI emitted. Which decisions are live, how they rank, and what each costs are the CLI's answers, and they change with the round, the bound, the repair grant and the content sha — a remembered set is wrong in more states than it is right.