amicus 4.3.0 → 4.4.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 (53) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +32 -0
  3. package/README.md +4 -3
  4. package/electron/ipc-workspace.js +283 -0
  5. package/electron/main.js +27 -0
  6. package/electron/preload-workspace.js +40 -0
  7. package/electron/workspace-shell.js +85 -0
  8. package/electron/workspace-ui/index.html +111 -0
  9. package/electron/workspace-ui/live-model.js +101 -0
  10. package/electron/workspace-ui/md-lite.js +119 -0
  11. package/electron/workspace-ui/workspace-app.js +240 -0
  12. package/electron/workspace-ui/workspace-matrix.js +212 -0
  13. package/electron/workspace-ui/workspace-panels.js +226 -0
  14. package/electron/workspace-ui/workspace-render.js +271 -0
  15. package/electron/workspace-ui/workspace-verbs.js +247 -0
  16. package/electron/workspace-ui/workspace.css +172 -0
  17. package/package.json +1 -1
  18. package/schemas/council-run-live.schema.json +25 -1
  19. package/schemas/council-run.schema.json +14 -0
  20. package/schemas/progress.schema.json +14 -1
  21. package/skills/second-opinion/MODEL-NOTES.md +53 -5
  22. package/src/cli-handlers-council-run.js +25 -3
  23. package/src/cli-handlers-spend.js +32 -5
  24. package/src/cli-handlers-watch.js +37 -10
  25. package/src/council/briefings.js +35 -2
  26. package/src/council/run-budget.js +224 -0
  27. package/src/council/run-launch.js +44 -6
  28. package/src/council/run-stages.js +17 -3
  29. package/src/council/run.js +12 -11
  30. package/src/headless.js +347 -14
  31. package/src/mcp-council-awareness.js +53 -3
  32. package/src/observe/council-legs.js +183 -0
  33. package/src/observe/live-doc.js +21 -3
  34. package/src/observe/watch-render.js +19 -0
  35. package/src/opencode-client.js +15 -3
  36. package/src/sidecar/child-sessions.js +198 -0
  37. package/src/sidecar/conversation-mirror.js +111 -37
  38. package/src/sidecar/fanout-budget.js +71 -0
  39. package/src/sidecar/fanout-leg.js +23 -1
  40. package/src/sidecar/fanout.js +4 -11
  41. package/src/sidecar/tool-part.js +196 -0
  42. package/src/sidecar/workspace-window.js +62 -0
  43. package/src/spend-query.js +21 -6
  44. package/src/utils/env-num.js +42 -0
  45. package/src/utils/path-fence.js +82 -0
  46. package/src/utils/pricing.js +98 -9
  47. package/src/workspace/artifact-guard.js +187 -0
  48. package/src/workspace/blind-mode.js +32 -0
  49. package/src/workspace/fold-format.js +95 -0
  50. package/src/workspace/live-normalize.js +156 -0
  51. package/src/workspace/matrix-model.js +94 -0
  52. package/src/workspace/run-detail.js +223 -0
  53. package/src/workspace/run-scan.js +148 -0
@@ -0,0 +1,172 @@
1
+ /* Council Workspace styles — every color/font/space from src/design/tokens.css. */
2
+
3
+ * { box-sizing: border-box; }
4
+ /* ⚠️ DE-ROT (F33): REQUIRED — do not drop. `.dialog-backdrop { display: flex }` below is an
5
+ AUTHOR rule, and author origin beats the UA's `[hidden] { display: none }` regardless of
6
+ specificity — so `#dialog-abort` (and `#run-view`, also `hidden`-attribute-gated) would be
7
+ visible from first paint and Task 16's `$('dialog-abort').hidden = true` would never hide it.
8
+ Nothing under electron/ or src/ defines a `[hidden]` reset today; this line is the only guard. */
9
+ [hidden] { display: none !important; }
10
+ html, body { height: 100%; margin: 0; }
11
+ body {
12
+ background: var(--bg);
13
+ color: var(--text-1);
14
+ font-family: var(--font-sans);
15
+ font-size: var(--fs-13);
16
+ line-height: var(--lh-body);
17
+ }
18
+ .mono { font-family: var(--font-mono); }
19
+
20
+ #app { display: flex; height: 100vh; }
21
+
22
+ /* ---- left rail -------------------------------------------------------- */
23
+ #rail {
24
+ width: 280px; min-width: 220px; flex: none;
25
+ border-right: var(--bd); background: var(--surface-1);
26
+ display: flex; flex-direction: column;
27
+ }
28
+ .rail-head {
29
+ padding: var(--pad-card); border-bottom: var(--bd);
30
+ display: flex; flex-direction: column; gap: var(--space-2);
31
+ }
32
+ .rail-title { font-weight: var(--w-semibold); letter-spacing: var(--ls-label); }
33
+ .rail-project { color: var(--text-3); font-size: var(--fs-10); overflow: hidden; text-overflow: ellipsis; }
34
+ #run-list { list-style: none; margin: 0; padding: var(--space-2); overflow-y: auto; flex: 1; }
35
+ #run-list li {
36
+ padding: var(--space-4) var(--space-6); border-radius: var(--r-6);
37
+ cursor: pointer; border: 1px solid transparent;
38
+ }
39
+ #run-list li:hover { background: var(--surface-2); }
40
+ #run-list li.selected { background: var(--surface-sel); border-color: var(--accent-line); }
41
+ #run-list li.error-row { color: var(--text-3); cursor: default; }
42
+ #run-list li:focus-visible, .btn:focus-visible, #blind-toggle:focus-visible, summary:focus-visible {
43
+ outline: 2px solid var(--focus-ring); outline-offset: 1px;
44
+ }
45
+ .run-row-top { display: flex; justify-content: space-between; gap: var(--space-4); }
46
+ .run-row-sub { color: var(--text-3); font-size: var(--fs-11); display: flex; gap: var(--space-4); flex-wrap: wrap; }
47
+
48
+ /* ---- chips / status --------------------------------------------------- */
49
+ .chips { display: flex; gap: var(--space-3); flex-wrap: wrap; align-items: center; }
50
+ .chip {
51
+ padding: var(--pad-pill); border-radius: var(--r-full); font-size: var(--fs-10);
52
+ border: var(--bd-strong); color: var(--text-2); background: var(--surface-2);
53
+ }
54
+ .chip.running { color: var(--running); border-color: var(--running); }
55
+ .chip.running::before {
56
+ content: ''; display: inline-block; width: 6px; height: 6px; margin-right: var(--space-2);
57
+ border-radius: var(--r-full); background: var(--running); animation: ws-pulse 1.2s ease-in-out infinite;
58
+ }
59
+ .chip.complete { color: var(--ok); }
60
+ .chip.partial { color: var(--warn); }
61
+ .chip.error { color: var(--danger); }
62
+ .chip.aborted { color: var(--text-3); }
63
+ @keyframes ws-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }
64
+ @media (prefers-reduced-motion: reduce) { .chip.running::before { animation: none; } }
65
+
66
+ /* ---- detail ----------------------------------------------------------- */
67
+ #detail { flex: 1; overflow-y: auto; padding: var(--space-8); }
68
+ .empty-state { color: var(--text-3); padding: var(--space-24); text-align: center; }
69
+ #run-header { display: flex; flex-direction: column; gap: var(--space-4); margin-bottom: var(--space-6); }
70
+ .run-head-row { display: flex; align-items: center; gap: var(--space-8); flex-wrap: wrap; }
71
+ #run-title { font-size: var(--fs-18); margin: 0; }
72
+
73
+ .banner {
74
+ padding: var(--pad-card); border-radius: var(--r-6); margin-bottom: var(--space-6);
75
+ border: 1px solid var(--danger); color: var(--danger); background: var(--surface-1);
76
+ }
77
+ .banner.warn { border-color: var(--warn); color: var(--warn); }
78
+ .banner.info { border-color: var(--border-strong); color: var(--text-2); }
79
+
80
+ .stage-rail { display: flex; gap: var(--space-4); flex-wrap: wrap; margin-bottom: var(--space-8); }
81
+ .stage {
82
+ display: flex; align-items: center; gap: var(--space-3);
83
+ padding: var(--pad-pill); border-radius: var(--r-6); border: var(--bd);
84
+ color: var(--text-2); font-size: var(--fs-11);
85
+ }
86
+ .stage.complete { color: var(--ok); }
87
+ .stage.running { color: var(--running); border-color: var(--running); }
88
+ .stage.error { color: var(--danger); }
89
+ .stage.partial { color: var(--warn); }
90
+ .stage.skipped { color: var(--text-3); }
91
+
92
+ .panel { margin-bottom: var(--space-10); border: var(--bd); border-radius: var(--r-8); background: var(--surface-1); padding: var(--pad-card); }
93
+ .panel-title { font-size: var(--fs-13); font-weight: var(--w-semibold); margin: 0 0 var(--space-4) 0; cursor: default; }
94
+ details.panel > summary { cursor: pointer; }
95
+ .prose-host { color: var(--text-2); }
96
+ .prose-host h3, .prose-host h4, .prose-host h5, .prose-host h6 { color: var(--text-1); margin: var(--space-6) 0 var(--space-2); }
97
+ .prose-host pre {
98
+ background: var(--surface-3); border: var(--bd); border-radius: var(--r-6);
99
+ padding: var(--pad-card); overflow-x: auto; font-family: var(--font-mono); font-size: var(--fs-11);
100
+ }
101
+ .prose-host code { font-family: var(--font-mono); background: var(--surface-3); border-radius: var(--r-3); padding: 0 var(--space-2); }
102
+ .prose-section { border-top: var(--bd); padding-top: var(--space-4); margin-top: var(--space-4); }
103
+ .prose-section:first-child { border-top: none; margin-top: 0; padding-top: 0; }
104
+ mark { background: var(--gold-soft); color: var(--gold-400); border-radius: var(--r-2); }
105
+
106
+ /* ---- tables ------------------------------------------------------------ */
107
+ .table { width: 100%; border-collapse: collapse; font-size: var(--fs-12); }
108
+ .table th {
109
+ text-align: left; color: var(--text-3); font-weight: var(--w-medium);
110
+ border-bottom: var(--bd-strong); padding: var(--space-3) var(--space-4);
111
+ }
112
+ .table td { border-bottom: var(--bd); padding: var(--space-3) var(--space-4); }
113
+ .table td.num, .table th.num { text-align: right; font-family: var(--font-mono); }
114
+ .stalled-flag { color: var(--warn); }
115
+
116
+ /* ---- matrix tier rows (report-html light-ground pairs, as token vars) -- */
117
+ .matrix-wrap { overflow-x: auto; }
118
+ tr.tier-Confirmed td { background: var(--tier-confirmed); color: var(--tier-confirmed-ink); }
119
+ tr.tier-Contested td { background: var(--tier-contested); color: var(--tier-contested-ink); }
120
+ tr.tier-Disputed td { background: var(--tier-disputed); color: var(--tier-disputed-ink); }
121
+ tr.tier-Singleton td { background: var(--tier-singleton); color: var(--tier-singleton-ink); }
122
+ td.vote-cell { text-align: center; font-family: var(--font-mono); }
123
+ td.vote-cell.dispute { cursor: pointer; text-decoration: underline dotted; }
124
+ .thin-badge, .override-badge, .debate-badge {
125
+ font-size: var(--fs-9); border-radius: var(--r-full); padding: 0 var(--space-3);
126
+ border: 1px solid currentColor; margin-left: var(--space-2);
127
+ }
128
+
129
+ /* ---- gauge -------------------------------------------------------------- */
130
+ .gauge {
131
+ position: relative; flex: 1; min-width: 160px; max-width: 360px; height: 18px;
132
+ border: var(--bd-strong); border-radius: var(--r-full); background: var(--surface-2); overflow: hidden;
133
+ }
134
+ .gauge-fill { height: 100%; width: 0; background: var(--accent-soft); border-right: 2px solid var(--accent); }
135
+ .gauge.over .gauge-fill { background: var(--danger); border-right-color: var(--danger); }
136
+ /* v4.4 §8: `unknown` = at least one seat reported no usage, so the filled
137
+ fraction is a LOWER BOUND, not a measurement. Hatch the whole track (not just
138
+ the fill) so the empty remainder reads "indeterminate" rather than "headroom",
139
+ and dash the leading edge so it is visibly not a hard boundary. Paired with the
140
+ `≥` prefix renderGauge writes into .gauge-text. */
141
+ .gauge.unknown {
142
+ background-image: repeating-linear-gradient(135deg,
143
+ transparent 0 4px, var(--surface-3, var(--surface-2)) 4px 8px);
144
+ }
145
+ .gauge.unknown .gauge-fill { border-right-style: dashed; }
146
+ .gauge-text { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: var(--fs-10); color: var(--text-2); }
147
+
148
+ /* ---- buttons / dialog ---------------------------------------------------- */
149
+ .btn {
150
+ font-family: var(--font-sans); font-size: var(--fs-12); padding: var(--pad-btn-sm);
151
+ border-radius: var(--r-6); border: var(--bd-strong); background: var(--surface-2);
152
+ color: var(--text-1); cursor: pointer;
153
+ }
154
+ .btn:hover { background: var(--surface-3); }
155
+ .btn.danger { border-color: var(--danger); color: var(--danger); }
156
+ .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
157
+ .btn[disabled] { opacity: 0.5; cursor: default; }
158
+ .blind-label { display: flex; align-items: center; gap: var(--space-3); color: var(--text-2); font-size: var(--fs-12); }
159
+
160
+ .dialog-backdrop {
161
+ position: fixed; inset: 0; background: var(--accent-glow);
162
+ backdrop-filter: blur(2px); display: flex; align-items: center; justify-content: center; z-index: 10;
163
+ }
164
+ .dialog {
165
+ background: var(--surface-2); border: var(--bd-strong); border-radius: var(--r-10);
166
+ box-shadow: var(--shadow-pop); padding: var(--space-12); max-width: 420px;
167
+ }
168
+ .dialog h2 { margin-top: 0; font-size: var(--fs-15); }
169
+ .dialog-actions { display: flex; justify-content: flex-end; gap: var(--space-4); margin-top: var(--space-8); }
170
+
171
+ .empty-note { color: var(--text-3); font-size: var(--fs-12); }
172
+ .truncate-note { color: var(--warn); font-size: var(--fs-11); margin-top: var(--space-3); }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "amicus",
3
- "version": "4.3.0",
3
+ "version": "4.4.0",
4
4
  "mcpName": "io.github.BourbonDog/amicus",
5
5
  "description": "Multi-model LLM Council + parallel AI window for Claude Code. Run structured council reviews across Gemini, GPT, DeepSeek and more — or fork a conversation to any model and fold the results back.",
6
6
  "keywords": [
@@ -27,7 +27,31 @@
27
27
  "legsComplete": { "type": ["number", "null"] },
28
28
  "elapsed": { "type": "string" },
29
29
  "exitCode": { "type": ["number", "null"] },
30
- "usage": { "type": "object" }
30
+ "usage": { "type": "object" },
31
+ "legs": {
32
+ "description": "One row per active-stage leg id (DE-ROT Task 0.5 / F01), present unconditionally — a just-started leg with no usage flushed yet still gets a row.",
33
+ "type": "array",
34
+ "items": {
35
+ "type": "object",
36
+ "required": ["taskId", "model", "status"],
37
+ "properties": {
38
+ "taskId": { "type": "string" },
39
+ "model": { "type": ["string", "null"], "description": "Resolved executable id (metadata.model)." },
40
+ "modelInput": { "type": ["string", "null"], "description": "Council alias (run.json bench/chair/critic/lenses are keyed on this, not `model`); null when the leg's metadata.json has not been patched with it yet (F36)." },
41
+ "role": { "type": ["string", "null"], "description": "'seat' | 'critic' | 'lens:<slug>' | 'chair', derived via roleFor keyed on modelInput (chair via the owning stage's name instead, F34); null when modelInput is unknown." },
42
+ "status": { "type": "string" },
43
+ "messages": { "type": "number" },
44
+ "stage": { "type": "string" },
45
+ "latestPreview": { "type": ["string", "null"] },
46
+ "lastActivityAt": { "type": ["string", "null"] },
47
+ "stalled": { "type": "boolean" },
48
+ "usage": { "type": "object" },
49
+ "usageError": { "type": "string", "description": "Council review C3: set when enrichLegUsage (pricing resolution) throws for this leg's progress usage, so the failure is distinguishable from a leg that simply has not billed yet (no `usage` key, no `usageError` key either). Additive; absent on every leg that priced cleanly or has no usage yet." }
50
+ }
51
+ }
52
+ },
53
+ "stalled": { "type": "boolean" },
54
+ "stalledForSeconds": { "type": "number" }
31
55
  },
32
56
  "additionalProperties": true
33
57
  }
@@ -34,6 +34,20 @@
34
34
  "options": { "type": "object" },
35
35
  "usage": { "type": "object" },
36
36
  "exitCode": { "type": ["number", "null"] },
37
+ "budgetRefusals": {
38
+ "description": "Waves the --max-cost ceiling refused at pre-flight (v4.4). Present only once at least one wave was refused. The run CONTINUES with a partial bench and exits degraded (2) — it is never rolled back and never aborted.",
39
+ "type": "array",
40
+ "items": {
41
+ "type": "object",
42
+ "required": ["waveId", "models"],
43
+ "properties": {
44
+ "waveId": { "type": ["string", "null"] },
45
+ "models": { "type": "array", "items": { "type": "string" } },
46
+ "reason": { "type": "string" },
47
+ "at": { "type": "string" }
48
+ }
49
+ }
50
+ },
37
51
  "debate": {
38
52
  "type": "object",
39
53
  "properties": {
@@ -16,7 +16,20 @@
16
16
  "type": "object",
17
17
  "properties": {
18
18
  "tokens": { "type": "object" },
19
- "costReported": { "type": "number" }
19
+ "costReported": { "type": "number" },
20
+ "subtree": {
21
+ "description": "v4.4.1 CA-1. Spend of the CHILD (subagent) OpenCode sessions this leg spawned, which OpenCode bills separately and does NOT roll into the parent session's cost. Attributed to this leg by the terminal walk in src/headless.js; resolved into usage.subtree by src/observe/live-doc.js enrichLegUsage so the live GUI and run.json agree. Absent when the leg spawned none.",
22
+ "type": "object",
23
+ "properties": {
24
+ "sessions": { "type": "number" },
25
+ "tokens": { "type": "object" },
26
+ "costReported": { "type": "number" }
27
+ }
28
+ },
29
+ "subtreeUnknown": {
30
+ "description": "The leg's own cost is stated, but there is positive evidence of a subagent subtree whose spend the walk could not account for. The total is a floor, not the bill. Present only when true.",
31
+ "const": true
32
+ }
20
33
  }
21
34
  }
22
35
  },
@@ -4,8 +4,8 @@ This file is the `second-opinion` skill's evolving memory of **how to actually d
4
4
  well**. Read it before Stage 0 (council selection and launch); update it, with the user's
5
5
  approval, at the end of each run (Stage 6). Keep it tight — merge and prune rather than append.
6
6
 
7
- _Last updated: 2026-07-14 (v2.2.0 fold-back: v3.1 optional council elements verified live;
8
- claim-class dedup adjudication limit; minimax and qwen-coder debut notes; see changelog)._
7
+ _Last updated: 2026-07-26 (v4.4.0 fold-back: alias-resolution hygiene, `council run --run-id`,
8
+ debate defense/re-vote waves now exercised, haiku and glm notes; see changelog)._
9
9
 
10
10
  ## Global operating rules (all models)
11
11
  - **Fast path:** `council run` applies `--agent Plan` / `--no-context` / `--summary-length
@@ -58,6 +58,20 @@ claim-class dedup adjudication limit; minimax and qwen-coder debut notes; see ch
58
58
  including ones outside a judge's focus. A council reviewing this contract flagged the asymmetry
59
59
  unanimously. Weigh a lone `Confirmed` tier accordingly, and prefer `Contested` evidence over
60
60
  vote counts when a finding matters.
61
+ - **`council run` prints nothing until the run is terminal.** The run id is generated internally and
62
+ the only stdout write happens after the run resolves, so a backgrounded `council run` gives you no
63
+ id to watch. **Pin it up front with `--run-id <id>`** and point `amicus watch <id>` at it directly.
64
+ - **Resolve every alias before you spend.** Two failure shapes, both cheap to pre-empt:
65
+ - **An alias that does not exist aborts the run before any spend** — `resolveModel` throws
66
+ `Unknown model alias '<x>'`. `deepseek-r1` is a recurring guess and is **not** shipped; the real
67
+ alias is `deepseek`. Check the alias table (`amicus models`) rather than inferring a name from a
68
+ model's marketing string.
69
+ - **A local alias override can silently upgrade a "cheap" seat to a frontier model.** Aliases in
70
+ `~/.config/amicus/config.json` take precedence over the shipped routes, so a bench you picked for
71
+ price can resolve to a Pro/preview tier and trip a low `--max-cost` (exit 1) — or quietly cost
72
+ 5-10× what you budgeted. Confirm what each seat actually resolves to before a budget bench.
73
+ - **The chair cannot also hold a bench seat**, so a bench built from budget aliases cannot chair
74
+ itself with one of them — pick the chair from *outside* the bench list.
61
75
  - **Stage-6 approvals:** write the proposed MODEL-NOTES diff to a run-folder file and put that path
62
76
  in the approval prompt — chat-text diffs can be hidden behind the approval dialog.
63
77
 
@@ -85,9 +99,13 @@ claim-class dedup adjudication limit; minimax and qwen-coder debut notes; see ch
85
99
  - **Optional council elements (v2.2.0) verified live:** critic seat (solo-alongside-fanout;
86
100
  `role: "critic"` passes through `council tally` untouched), debate mode's nothing-to-debate path
87
101
  (provisional `--no-ledger` tally → skip rebuttals → final ledger-recorded tally), and the chair
88
- verdict scale (parseable `VERDICT:` line + hard questions) all behaved per SEAT-BRIEFS. **Debate
89
- mode's defense/re-vote waves remain unexercised** an all-Confirmed consensus run has no
90
- rebuttal surface; exercise them on a contentious artifact before trusting that path blind.
102
+ verdict scale (parseable `VERDICT:` line + hard questions) all behaved per SEAT-BRIEFS.
103
+ - **Debate's defense/re-vote waves have now been exercised** (an ideation council, where severity
104
+ means impact rather than correctness): they parse and tally cleanly, and the round behaves as a
105
+ **rescope** mechanism rather than a defense — raisers overwhelmingly AMEND (downgrade an
106
+ overstated severity, narrow a scope) rather than DEFEND, and amendments are re-confirmed on the
107
+ re-vote. Expect high-amend / low-defend; the idea usually survives, the severity claim often does
108
+ not.
91
109
 
92
110
  ## Per-model notes
93
111
 
@@ -136,6 +154,26 @@ claim-class dedup adjudication limit; minimax and qwen-coder debut notes; see ch
136
154
  ### Claude (in-council, when toggle on)
137
155
  - Consistently the most *calibrated* reviewer (no severity inflation; findings overwhelmingly Confirmed; bench-best street-cred in recent runs) but sometimes the least *original* — it can miss the boldest single catch. Treat as a reliability floor, not a discovery engine.
138
156
 
157
+ ### haiku (`--model haiku`) — **verify before using; it has been hard-404ing**
158
+ - The direct-Anthropic route (`anthropic/claude-haiku-4-5-20251001`) returned a hard `Not Found`
159
+ on **every** invocation of a recent paid corpus — 3 of 3 legs across two separate runs, both as
160
+ **chair** (twice, incl. the fallback retry) and as a **bench seat** — in ~2 s with zero tokens.
161
+ - Both runs degraded *around* it silently rather than failing: one fell back to another chair, the
162
+ other collapsed its bench from 3 seats to 2 and exited 2. **A dead alias does not stop a council;
163
+ it shrinks it.** In the bench-seat case every finding came out `confidence: "thin"` with a single
164
+ peer corroborator, purely because the bench had halved — and nothing in `verdict.json` said so.
165
+ - Resolve the alias against the catalog (`amicus models --check`) before putting it on a paid
166
+ bench, and re-check the bench roster in `run.json` against what you asked for afterwards.
167
+
168
+ ### GLM (`--model glm` → z-ai via OpenRouter)
169
+ - Cheap and fast, and ranked best-by-peers on a clean debut — but a later run produced **35 KB of
170
+ prose with `conformance: unstructured` and 0 parsed findings**, twice. Its structured-output
171
+ reliability is **not** established; treat the debut as low-N.
172
+ - Useful behavioural note: when its structured output failed it **refused to fabricate** on the
173
+ repair attempts. Honest — but an honest refusal still costs you the seat, so a bench that leans
174
+ on `glm` for quorum can silently adjudicate a seat short while still paying for its tokens.
175
+ Watch `conformance` per seat, not just the finding count.
176
+
139
177
  ### minimax (`--model minimax` → via OpenRouter)
140
178
  - Fast (~2 min review legs), cheap, `clean` findings-JSON conformance on debut.
141
179
  - Took the **critic seat** brief exceptionally well: unanimously ranked #1 by its bench, full
@@ -209,6 +247,16 @@ This section keeps only per-model **qualitative quirks** and **structural-confor
209
247
  GUI-hangs-on-this-machine rule (resolved 2026-06-10; headless stays the council default by
210
248
  design). Config path updated to `~/.config/amicus/.env`.
211
249
  - **2026-07-02** — Folded back field lessons from runs 4-7 (AV-receiver, pork-shoulder, resume, novel ×2 councils): PowerShell `--models` quoting; current-date injection; long-read model selection; judge no-tools preamble; severity-inflation-justifies-dispute; five-keys tally schema; new Grok/Kimi/Mistral/Claude-in-council sections. Quantitative history stays in the ledger (`amicus council stats`).
250
+ - **2026-07-26 (v4.4.0)** — Fold-back from six paid councils (workspace/renderer review ×4, a
251
+ frontier cost-pipeline council, and an ideation council). Operating lessons: alias-resolution
252
+ hygiene before spending (a non-existent alias aborts the run; a local `config.json` override can
253
+ silently upgrade a "cheap" seat to a Pro tier and trip `--max-cost`); the chair may not also hold
254
+ a bench seat; `council run` prints nothing until terminal, so pin `--run-id` when backgrounding.
255
+ Debate's defense/re-vote waves exercised for the first time — they work, and behave as a rescope
256
+ (amend-heavy) rather than a defense. New per-model notes: **haiku** hard-404ed 3/3 legs across two
257
+ runs and both councils silently degraded around it; **glm** returned `unstructured` conformance
258
+ with 0 findings twice after a clean debut, and honestly refused to fabricate on repair — which
259
+ still costs the seat.
212
260
  - **2026-07-14 (v2.2.0)** — Optional council elements shipped and verified on a planted-flaw
213
261
  ground-truth council (critic seat, debate mode nothing-to-debate path, chair verdict scale;
214
262
  expert lenses defined but not yet field-run). New lessons: claim-class dedup glosses
@@ -82,8 +82,30 @@ function renderRunHuman(run) {
82
82
  ` bench: ${(run.bench || []).join(', ')} chair: ${run.chair}`,
83
83
  ` dir: ${run.options && run.options.outDir}`,
84
84
  ];
85
- if (run.usage && run.usage.cost && typeof run.usage.cost.amount === 'number') {
86
- lines.push(` cost: $${run.usage.cost.amount.toFixed(4)} (${run.usage.cost.source})`);
85
+ // v4.4: a cost line that omits unpriced legs reads as the whole bill. The
86
+ // diagnosis measured council-wsgate02 printing $0.3720 for a run that really
87
+ // spent $0.9859. Say what we know, then say what we cannot know — and print
88
+ // the line even when NOTHING resolved (the old `typeof amount === 'number'`
89
+ // guard silently dropped it, so a fully unpriced run looked free).
90
+ const u = run.usage || null;
91
+ const unknownLegs = u && typeof u.unknownLegs === 'number'
92
+ ? u.unknownLegs
93
+ : (u && u.cost && u.cost.unpricedLegs) || 0;
94
+ // v4.4 Task 2: a fully-priced run can still be short. `council-wsgate01`
95
+ // printed an unqualified $0.2821 for a run that really spent $0.3036 — every
96
+ // leg `reported`, and 100% of the gap one unattributed `explore` child session.
97
+ const subtreeLegs = u && typeof u.subtreeUnknownLegs === 'number'
98
+ ? u.subtreeUnknownLegs
99
+ : (u && u.cost && u.cost.subtreeUnknownLegs) || 0;
100
+ if (u && u.cost && (typeof u.cost.amount === 'number' || unknownLegs > 0 || subtreeLegs > 0)) {
101
+ const known = typeof u.cost.amount === 'number' ? `$${u.cost.amount.toFixed(4)}` : '$0.0000';
102
+ const gaps = [];
103
+ if (unknownLegs > 0) { gaps.push(`${unknownLegs} leg(s) unknown`); }
104
+ if (subtreeLegs > 0) { gaps.push(`${subtreeLegs} leg(s) with unattributed subagent child-session spend`); }
105
+ const tail = gaps.length > 0
106
+ ? ` + ${gaps.join(' + ')} — real spend is at least this much`
107
+ : '';
108
+ lines.push(` cost: ${known} (${u.cost.source})${tail}`);
87
109
  }
88
110
  if (run.error) { lines.push(` error: ${run.error.code}: ${run.error.message}`); }
89
111
  return lines.join('\n') + '\n';
@@ -230,4 +252,4 @@ async function handleCouncilRun(args) {
230
252
  return exitCode;
231
253
  }
232
254
 
233
- module.exports = { handleCouncilRun, CHAIR_DEFAULT };
255
+ module.exports = { handleCouncilRun, renderRunHuman, CHAIR_DEFAULT };
@@ -43,22 +43,31 @@ function parseSinceDays(since) {
43
43
  * A row with a null cost.amount contributes 0 to totals but is still counted
44
44
  * in `runs` and its source bucket — visibility into "how many runs are
45
45
  * unpriced" matters as much as the dollar figure.
46
+ *
47
+ * v4.4: `unpricedRows` is the count of rows that contributed NOTHING to
48
+ * `amount` (no numeric cost). `sourceMix.unknown` is adjacent but not the same
49
+ * question — it buckets by the row's declared source, whereas this counts what
50
+ * the arithmetic actually saw. It exists so the renderers can say "$X plus N
51
+ * unknown" instead of coercing null→0 and printing a measured-looking $0.0000
52
+ * (diagnosis §8, final paragraph).
46
53
  * @param {Array<object>} rows
47
54
  */
48
55
  function aggregateSpend(rows) {
49
- const total = { amount: 0, tokens: emptyTokens(), runs: rows.length, sourceMix: { reported: 0, estimated: 0, unknown: 0 } };
56
+ const total = { amount: 0, tokens: emptyTokens(), runs: rows.length, unpricedRows: 0, sourceMix: { reported: 0, estimated: 0, unknown: 0 } };
50
57
  const byModelMap = new Map();
51
58
  for (const r of rows) {
52
59
  const model = r.model || 'unknown';
53
60
  if (!byModelMap.has(model)) {
54
- byModelMap.set(model, { model, amount: 0, tokens: emptyTokens(), runs: 0, sourceMix: { reported: 0, estimated: 0, unknown: 0 } });
61
+ byModelMap.set(model, { model, amount: 0, tokens: emptyTokens(), runs: 0, unpricedRows: 0, sourceMix: { reported: 0, estimated: 0, unknown: 0 } });
55
62
  }
56
63
  const bucket = byModelMap.get(model);
57
64
  bucket.runs += 1;
58
65
  addTokens(bucket.tokens, r.tokens);
59
66
  addTokens(total.tokens, r.tokens);
60
67
  const cost = r.cost || {};
61
- const amount = typeof cost.amount === 'number' ? cost.amount : 0;
68
+ const priced = typeof cost.amount === 'number';
69
+ const amount = priced ? cost.amount : 0;
70
+ if (!priced) { bucket.unpricedRows += 1; total.unpricedRows += 1; }
62
71
  bucket.amount += amount;
63
72
  total.amount += amount;
64
73
  // Any source string outside {reported,estimated} buckets as unknown —
@@ -139,6 +148,18 @@ async function fetchCreditFooter(deps) {
139
148
  return res || null;
140
149
  }
141
150
 
151
+ /**
152
+ * Cost cell for one rollup bucket. v4.4: a bucket in which NO row carried a
153
+ * numeric amount has no dollar figure to show — it renders formatCost's `?`
154
+ * rather than `$0.0000`, which previously read as a measured zero and was the
155
+ * only thing contradicting the (correct but easily missed) `u` count.
156
+ */
157
+ function bucketCost(bucket) {
158
+ const unpriced = bucket.unpricedRows || 0;
159
+ const hasKnown = (bucket.runs || 0) > unpriced;
160
+ return formatCost({ amount: hasKnown ? bucket.amount : null, source: dominantSource(bucket.sourceMix) });
161
+ }
162
+
142
163
  function renderHuman({ total, byModel, windowDays, credit, wasted }) {
143
164
  if (total.runs === 0) { return 'No spend recorded yet.\n'; }
144
165
  let out = windowDays ? `amicus spend (last ${windowDays}d)\n\n` : 'amicus spend (all time)\n\n';
@@ -148,9 +169,15 @@ function renderHuman({ total, byModel, windowDays, credit, wasted }) {
148
169
  const tokCol = `${m.tokens.input}/${m.tokens.output}`;
149
170
  out += `${String(m.model).slice(0, 48).padEnd(48)} ${String(m.runs).padStart(4)} ` +
150
171
  `${tokCol.padStart(15)} ` +
151
- `${formatCost({ amount: m.amount, source: dominantSource(m.sourceMix) }).padStart(9)} ${mix}\n`;
172
+ `${bucketCost(m).padStart(9)} ${mix}\n`;
173
+ }
174
+ out += `\nTotal: ${bucketCost(total)} across ${total.runs} run(s)\n`;
175
+ // v4.4: the total is a FLOOR whenever any row is unpriced. Stated on its own
176
+ // line rather than squeezed into the fixed-width cost column.
177
+ if (total.unpricedRows > 0) {
178
+ out += `${total.unpricedRows} unpriced row(s) — cost unknown and NOT in the total; `
179
+ + 'real spend is at least this much.\n';
152
180
  }
153
- out += `\nTotal: ${formatCost({ amount: total.amount, source: dominantSource(total.sourceMix) })} across ${total.runs} run(s)\n`;
154
181
  if (wasted && wasted.runs > 0) {
155
182
  out += `Wasted (failed runs): ${formatCost({ amount: wasted.amount, source: 'mixed' })} across ${wasted.runs} rows — see amicus spend --failed\n`;
156
183
  }
@@ -29,8 +29,21 @@ function resolveWatchTarget(id, project) {
29
29
  const clean = String(id).replace(/^council-/, '');
30
30
 
31
31
  const { readPointer } = require('./council/run-state');
32
+ const { containsOnDisk } = require('./utils/path-fence');
32
33
  const ptr = readPointer(project, clean);
33
- if (ptr) { return { kind: 'council', id: clean, runDir: ptr.runDir }; }
34
+ // readPointer validates `council-<id>.json`'s {runId, runDir} only for
35
+ // truthiness (run-state.js:133-139), so a tampered or stale pointer can point
36
+ // runDir anywhere on disk — and this resolver's runDir is what
37
+ // observe/watch-render.js opens events.jsonl from. Same realpath-containment
38
+ // fence the v4.4 workspace reads use (src/utils/path-fence.js); a real
39
+ // runDir is always nested inside project (src/mcp-council-run.js:109 enforces
40
+ // it at creation time), so nothing legitimate is refused. An escaping pointer
41
+ // falls through to the session lookup and then 'unknown' — the same outcome a
42
+ // missing pointer already produces, so handleWatch's BAD_SESSION contract is
43
+ // unchanged.
44
+ if (ptr && containsOnDisk(project, ptr.runDir)) {
45
+ return { kind: 'council', id: clean, runDir: ptr.runDir };
46
+ }
34
47
 
35
48
  // getSessionDir THROWS on a path-traversal id ('..' / separators) — this
36
49
  // resolver is exported and docblocked "pure over disk", so it must be
@@ -50,11 +63,33 @@ function resolveWatchTarget(id, project) {
50
63
  }
51
64
 
52
65
  /**
53
- * `amicus watch <id> [--json|--plain] [--interval <sec>] [--project <p>] [--ui]`
66
+ * `amicus watch [--ui] <id> [--json|--plain] [--interval <sec>] [--project <p>]`
54
67
  * @param {object} args parsed CLI args
55
68
  * @returns {Promise<number>} exit code (render loop: Task 12)
56
69
  */
57
70
  async function handleWatch(args) {
71
+ // v4.4: `amicus watch [--ui] [runId]` — GUI watch is the same verb (spec
72
+ // §4.4), not a separate command. Handled at the very top, above id
73
+ // resolution: unlike the machine-readable path, `--ui` alone (no runId)
74
+ // is valid and opens the Council Workspace run-list landing, so this
75
+ // branch must run BEFORE the "id is required" gate below.
76
+ if (args.ui) {
77
+ if (args.json) {
78
+ process.stderr.write('Error: --ui is interactive-only (no --json). Use amicus watch <id> --json for machine output.\n');
79
+ return 1;
80
+ }
81
+ // --project wins over --cwd (same precedence as the non-UI path below) —
82
+ // DE-ROT F46: `--project` is the documented first-priority option for
83
+ // `watch`; resolving from --cwd only would silently point the workspace
84
+ // at the wrong directory when a run was launched elsewhere.
85
+ const project = args.project || args.cwd || process.cwd();
86
+ const runId = args._[1] ? String(args._[1]) : '';
87
+ const { launchWorkspaceWindow } = require('./sidecar/workspace-window');
88
+ const res = await launchWorkspaceWindow({ project, runId });
89
+ if (res.error) { process.stderr.write(`${res.error}\n`); }
90
+ return res.code;
91
+ }
92
+
58
93
  const { failJson, ERROR_CODES } = require('./utils/error-doc');
59
94
  const id = args._[1];
60
95
  if (!id || id === true) {
@@ -64,14 +99,6 @@ async function handleWatch(args) {
64
99
  const check = validateTaskId(String(id));
65
100
  if (!check.valid) { process.stderr.write(`${check.error}\n`); return 1; }
66
101
 
67
- // --ui is registered as the v4.4 Council Workspace seam only; this rev
68
- // (v4.3) registers the flag + this fail-fast, the GUI itself is out of
69
- // scope. --ui alone is accepted and falls through to the loop.
70
- if (args.ui && args.json) {
71
- process.stderr.write('Error: --ui is interactive-only and cannot be combined with --json\n');
72
- return 1;
73
- }
74
-
75
102
  const project = args.project || args.cwd || process.cwd();
76
103
  const target = resolveWatchTarget(String(id), project);
77
104
  if (target.kind === 'unknown') {
@@ -121,13 +121,46 @@ function buildLensBriefing({ lens, briefing, date }) {
121
121
  * repair loop). References ONLY the json-shape fragment — never the
122
122
  * "prose review THEN json" framing — so a headless model isn't handed license
123
123
  * to write a whole new prose review on a tight repair turn.
124
+ *
125
+ * ⚠️ LC-6. This used to carry the validation ERRORS without the REVIEW they
126
+ * were errors about, and a repair solo is a FRESH session with no memory of
127
+ * the review turn. Three of five paid councils burned a seat on it:
128
+ * - wsgate02 `qwen` — refused twice: "I don't have a previous review to correct"
129
+ * - wsgate04 `glm` — refused twice: "the previous review's content was
130
+ * excluded by the caller… I will not fabricate findings"
131
+ * - costgate01 `grok` — COMPLIED, by inventing a self-referential finding
132
+ * about its own empty output, which then entered
133
+ * tally.json, the street-cred table and the chair
134
+ * synthesis as C1 and reached a human's decision.
135
+ * Honest models lose the seat (a 4-model bench silently adjudicating on 3,
136
+ * still paying for the fourth); compliant ones poison the record.
137
+ *
138
+ * `review` is the text that ACTUALLY failed — the original review on the first
139
+ * attempt, the previous repair's output on the second — so the errors and the
140
+ * artifact they describe are always the same thing. It is embedded verbatim and
141
+ * uncapped: the largest real case was 35 KB, and a silent truncation would
142
+ * recreate this defect in a subtler form (repairing a review the model can only
143
+ * half see).
144
+ * @param {{errors?: Array<{code: string, detail: string}>, review?: string}} args
124
145
  */
125
- function buildFindingsRepairPrompt({ errors }) {
146
+ function buildFindingsRepairPrompt({ errors, review }) {
126
147
  const lines = (errors || []).map(e => `- ${e.code}: ${e.detail}`).join('\n');
148
+ const text = typeof review === 'string' ? review.trim() : '';
149
+ // The absent case is stated, never papered over with an empty block: a model
150
+ // asked to repair nothing must be told to report nothing rather than left to
151
+ // guess, which is precisely what produced grok's invented finding.
152
+ const prior = text
153
+ ? ['--- YOUR PREVIOUS REVIEW (verbatim — this is the text to correct) ---',
154
+ text,
155
+ '--- END OF YOUR PREVIOUS REVIEW ---'].join('\n')
156
+ : 'Your previous response was empty — there is no prior review text to correct. ' +
157
+ 'Do not invent findings to satisfy the schema: emit an empty "findings" array ' +
158
+ 'and say so in "overall".';
127
159
  return [
128
160
  'Do NOT use any tools or read any files; everything is in this message; begin ' +
129
161
  'immediately with the JSON block.',
130
- 'Your previous review\'s trailing findings JSON failed validation with these errors:',
162
+ prior,
163
+ 'That review\'s trailing findings JSON failed validation with these errors:',
131
164
  lines,
132
165
  'Re-emit ONLY the corrected findings JSON block (the same findings, fixed — do not ' +
133
166
  'add or remove findings), as a single fenced ```json block:',