@giamme/forge 0.22.0 → 0.23.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 (153) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/README.md +19 -12
  3. package/SKILL.md +137 -216
  4. package/VERSION +1 -1
  5. package/docs/README.md +2 -3
  6. package/docs/add-ons.md +5 -3
  7. package/docs/artifacts.md +17 -2
  8. package/docs/commands.md +85 -63
  9. package/docs/decomposed-runs.md +195 -21
  10. package/docs/development.md +11 -9
  11. package/docs/forge-ui.md +33 -4
  12. package/docs/install.md +37 -5
  13. package/docs/memory.md +6 -1
  14. package/docs/models.md +36 -10
  15. package/docs/reviews.md +44 -25
  16. package/docs/safety.md +27 -2
  17. package/docs/troubleshooting.md +7 -10
  18. package/forge +25 -4
  19. package/package.json +2 -1
  20. package/references/dataset.md +10 -9
  21. package/references/decompose-integration.md +337 -0
  22. package/references/decompose-opt-in.md +527 -0
  23. package/references/decompose-recovery.md +569 -0
  24. package/references/decompose-review.md +256 -0
  25. package/references/decompose.md +99 -1606
  26. package/references/findings.md +68 -0
  27. package/references/harnesses.md +7 -12
  28. package/references/memory.md +13 -2
  29. package/references/planning.md +48 -18
  30. package/references/ripwire.md +38 -13
  31. package/references/runtime.md +22 -33
  32. package/references/setup.md +90 -0
  33. package/references/solo.md +13 -42
  34. package/references/ui.md +12 -5
  35. package/registry.tsv +40 -22
  36. package/scripts/forge-artifact.sh +143 -12
  37. package/scripts/forge-compare.py +5 -15
  38. package/scripts/forge-config.py +14 -1
  39. package/scripts/forge-contract.py +216 -53
  40. package/scripts/forge-control.py +777 -54
  41. package/scripts/forge-dispatch.sh +95 -12
  42. package/scripts/forge-du.py +13 -3
  43. package/scripts/forge-handoff.py +221 -39
  44. package/scripts/forge-install-ripwire.sh +100 -24
  45. package/scripts/forge-install.sh +18 -32
  46. package/scripts/forge-issues.py +6 -4
  47. package/scripts/forge-jev-options.sh +3 -5
  48. package/scripts/forge-lib-adopt.sh +169 -5
  49. package/scripts/forge-lib-attribute.sh +10 -3
  50. package/scripts/forge-lib-decompose.sh +454 -0
  51. package/scripts/forge-lib-env.sh +21 -0
  52. package/scripts/forge-lib-group.sh +4 -1
  53. package/scripts/forge-lib-plans.sh +30 -18
  54. package/scripts/forge-lib-review.sh +28 -8
  55. package/scripts/forge-lib-task.sh +225 -56
  56. package/scripts/forge-lib-verify.sh +59 -10
  57. package/scripts/forge-memory.sh +81 -4
  58. package/scripts/forge-metrics.sh +4 -2
  59. package/scripts/forge-parallel-options.sh +23 -4
  60. package/scripts/forge-parallel.sh +447 -175
  61. package/scripts/forge-plan-check.py +71 -8
  62. package/scripts/forge-planner.py +303 -17
  63. package/scripts/forge-pr.py +9 -1
  64. package/scripts/forge-prompt.py +2 -2
  65. package/scripts/forge-review-links.py +248 -0
  66. package/scripts/forge-ripwire.py +234 -16
  67. package/scripts/forge-route.py +19 -27
  68. package/scripts/forge-runs-rm.py +92 -21
  69. package/scripts/forge-runs.py +46 -5
  70. package/scripts/forge-runtime.py +37 -12
  71. package/scripts/forge-schedule.py +124 -33
  72. package/scripts/forge-setup-stale.py +236 -0
  73. package/scripts/forge-setup.py +804 -0
  74. package/scripts/forge-shadow.py +2 -20
  75. package/scripts/forge-solo-lock.py +46 -0
  76. package/scripts/forge-solo.sh +33 -56
  77. package/scripts/forge-sweep.py +2 -1
  78. package/scripts/forge-ui.py +8 -1
  79. package/scripts/forge-update.sh +2 -2
  80. package/scripts/forge-verify.py +16 -1
  81. package/scripts/forge-version.py +13 -1
  82. package/scripts/forge-watch.py +7 -2
  83. package/scripts/forge_dataset/__init__.py +1 -1
  84. package/scripts/forge_dataset/capture.py +0 -34
  85. package/scripts/forge_dataset/checks.py +0 -1
  86. package/scripts/forge_dataset/cli.py +5 -1
  87. package/scripts/forge_dataset/export.py +28 -6
  88. package/scripts/forge_dataset/facts.py +1 -2
  89. package/scripts/forge_dataset/forecast.py +1 -1
  90. package/scripts/forge_dataset/harvest.py +107 -7
  91. package/scripts/forge_dataset/importer.py +3 -2
  92. package/scripts/forge_dataset/pairs.py +3 -3
  93. package/scripts/forge_dataset/reviewers.py +4 -3
  94. package/scripts/forge_dataset/routing.py +6 -3
  95. package/scripts/forge_dataset/tiers.py +1 -1
  96. package/scripts/forge_decide/__init__.py +1 -1
  97. package/scripts/forge_decide/profiles.py +11 -14
  98. package/scripts/forge_decompose.py +987 -0
  99. package/scripts/forge_groups/review.py +6 -1
  100. package/scripts/forge_jev/__init__.py +1 -1
  101. package/scripts/forge_jev/cli.py +10 -1
  102. package/scripts/forge_jev/gates.py +10 -1
  103. package/scripts/forge_jev/verify.py +10 -2
  104. package/scripts/forge_legacy.py +86 -0
  105. package/scripts/forge_memory_home.py +57 -0
  106. package/scripts/forge_models.py +151 -0
  107. package/scripts/forge_prefs.py +138 -0
  108. package/scripts/forge_side/__init__.py +10 -0
  109. package/scripts/forge_storage.py +28 -15
  110. package/ui/README.md +22 -10
  111. package/ui/docs/api.md +121 -99
  112. package/ui/forge_ui/control.py +46 -14
  113. package/ui/forge_ui/export.py +0 -10
  114. package/ui/forge_ui/models.py +15 -2
  115. package/ui/forge_ui/projects.py +4 -1
  116. package/ui/forge_ui/reader.py +456 -59
  117. package/ui/forge_ui/server.py +0 -10
  118. package/ui/forge_ui/static/app.js +28 -9
  119. package/ui/forge_ui/static/checksview.js +12 -3
  120. package/ui/forge_ui/static/controls.js +147 -11
  121. package/ui/forge_ui/static/convo.js +5 -2
  122. package/ui/forge_ui/static/diffview.js +4 -5
  123. package/ui/forge_ui/static/panel.js +180 -77
  124. package/ui/forge_ui/static/projectsview.js +16 -2
  125. package/ui/forge_ui/static/runmodel.js +18 -4
  126. package/ui/forge_ui/static/scene3d.js +29 -29
  127. package/ui/forge_ui/static/settings.js +1 -1
  128. package/ui/forge_ui/static/storageview.js +2 -2
  129. package/ui/forge_ui/static/style.css +23 -6
  130. package/ui/forge_ui/static/worktreesview.js +8 -4
  131. package/ui/forge_ui/transcripts.py +6 -0
  132. package/ui/forge_ui/worktrees.py +13 -1
  133. package/docs/fractal.md +0 -181
  134. package/references/fractal-dashboard.md +0 -21
  135. package/references/fractal.md +0 -307
  136. package/scripts/forge-fractal-dispatch.sh +0 -4
  137. package/scripts/forge-fractal-options.sh +0 -54
  138. package/scripts/forge-fractal.py +0 -6
  139. package/scripts/forge-install-fractal.sh +0 -4
  140. package/scripts/forge_fractal/__init__.py +0 -88
  141. package/scripts/forge_fractal/bridge.py +0 -46
  142. package/scripts/forge_fractal/cli.py +0 -224
  143. package/scripts/forge_fractal/dashboard.css +0 -138
  144. package/scripts/forge_fractal/dashboard.html +0 -41
  145. package/scripts/forge_fractal/dashboard.js +0 -687
  146. package/scripts/forge_fractal/decomposition.py +0 -262
  147. package/scripts/forge_fractal/execution.py +0 -659
  148. package/scripts/forge_fractal/inspection.py +0 -261
  149. package/scripts/forge_fractal/install.py +0 -158
  150. package/scripts/forge_fractal/invocation.py +0 -95
  151. package/scripts/forge_fractal/pipeline.py +0 -125
  152. package/scripts/forge_fractal/selection.py +0 -180
  153. package/ui/forge_ui/fractal.py +0 -582
@@ -52,7 +52,6 @@ _ADOPTION_DIFF_PATH = re.compile(_ADOPTION_PATH.pattern + '/diff')
52
52
  _FILES_PATH = re.compile(r'/api/runs/([0-9a-f]{12})/files')
53
53
  _FINDINGS_PATH = re.compile(r'/api/runs/([0-9a-f]{12})/findings')
54
54
  _EXPORT_PATH = re.compile(r'/api/runs/([0-9a-f]{12})/export')
55
- _FRACTAL_PATH = re.compile(_TASK_PATH.pattern + r'/fractal(?:/nodes/([A-Za-z0-9][A-Za-z0-9_-]{0,100})(/diff)?)?')
56
55
  _VERIFY_LOG_PATH = re.compile(r'/api/runs/([0-9a-f]{12})/verification(?:/(retry)|/lanes/([^/]+)(?:/runs/([^/]+))?)?/log'
57
56
  r'(?:/lines/([^/]+))?')
58
57
  _STATIC_PATH = re.compile(r'/([A-Za-z0-9_.-]+\.(?:html|js|css|svg|woff2))')
@@ -183,15 +182,6 @@ def api_get(catalog, path):
183
182
  if k is False or first is False:
184
183
  return None
185
184
  return catalog.verification_log(key, lane, k, first, retry=bool(retry))
186
- match = _FRACTAL_PATH.fullmatch(path)
187
- if match:
188
- key, task_id, node, diff = match.group(1), _task_id(match.group(2)), match.group(3), match.group(4)
189
- if task_id is None:
190
- return None
191
- if node is None:
192
- return catalog.fractal(key, task_id)
193
- read = catalog.fractal_node_diff if diff else catalog.fractal_node
194
- return read(key, task_id, node)
195
185
  return NO_ROUTE
196
186
 
197
187
 
@@ -55,17 +55,14 @@ window.ForgeApp = (() => {
55
55
  if (sel.kind === 'adoption') return `${base}/adoptions/${e(sel.name)}`;
56
56
  if (sel.kind === 'verification') return `${base}/verification`;
57
57
  if (sel.kind === 'integration') return `${base}/integration`;
58
- if (sel.kind === 'fractal') return `${base}/tasks/${e(sel.task)}/fractal/${e(sel.node)}`;
59
58
  return base;
60
59
  }
61
- // a diff: {kind: 'task', task, source, file} | {kind: 'final', name, file} | {kind: 'adoption', name, file}
62
- // | {kind: 'fractal', task, node, file},
60
+ // a diff: {kind: 'task', task, source, file} | {kind: 'final', name, file} | {kind: 'adoption', name, file},
63
61
  // opened at a file, or at one finding (its id from /findings)
64
62
  function diffHash(key, spec) {
65
63
  const e = encodeURIComponent, base = '#/runs/' + e(key), file = spec.finding ? '/finding/' + e(spec.finding) : spec.file ? '/file/' + e(spec.file) : '';
66
64
  if (spec.kind === 'final') return `${base}/final-review/${e(spec.name)}/diff${file}`;
67
65
  if (spec.kind === 'adoption') return `${base}/adoptions/${e(spec.name)}/diff${file}`;
68
- if (spec.kind === 'fractal') return `${base}/tasks/${e(spec.task)}/fractal/${e(spec.node)}/diff${file}`;
69
66
  return `${base}/tasks/${e(spec.task)}/diff${spec.source && spec.source !== 'current' ? '/' + e(spec.source) : ''}${file}`;
70
67
  }
71
68
  // an execution's conversation, in the stage's place like a diff; opened at one of its events when given
@@ -91,7 +88,6 @@ window.ForgeApp = (() => {
91
88
  let sel = null, r;
92
89
  if ((r = rest.match(/^\/group\/([^/]+)\/?$/))) return { key: d(m[1]), sel: null, group: d(r[1]) };
93
90
  if ((r = rest.match(/^\/tasks\/([^/]+)\/diff(?:\/(?!file\/|finding\/)([^/]+))?(?:\/finding\/([^/]+))?(?:\/file\/(.+?))?\/?$/))) return { key: d(m[1]), sel: { kind: 'task', id: d(r[1]) }, diff: { kind: 'task', task: d(r[1]), source: r[2] ? d(r[2]) : 'current', finding: r[3] ? d(r[3]) : null, file: r[4] ? d(r[4]) : null } };
94
- if ((r = rest.match(/^\/tasks\/([^/]+)\/fractal\/([^/]+)\/diff(?:\/file\/(.+?))?\/?$/))) return { key: d(m[1]), sel: { kind: 'task', id: d(r[1]) }, diff: { kind: 'fractal', task: d(r[1]), node: d(r[2]), file: r[3] ? d(r[3]) : null } };
95
91
  if ((r = rest.match(/^\/final-review\/([^/]+)\/diff(?:\/finding\/([^/]+))?(?:\/file\/(.+?))?\/?$/))) return { key: d(m[1]), sel: { kind: 'final', name: d(r[1]) }, diff: { kind: 'final', name: d(r[1]), finding: r[2] ? d(r[2]) : null, file: r[3] ? d(r[3]) : null } };
96
92
  if ((r = rest.match(/^\/adoptions\/([^/]+)\/diff(?:\/finding\/([^/]+))?(?:\/file\/(.+?))?\/?$/))) return { key: d(m[1]), sel: { kind: 'adoption', name: d(r[1]) }, diff: { kind: 'adoption', name: d(r[1]), finding: r[2] ? d(r[2]) : null, file: r[3] ? d(r[3]) : null } };
97
93
  if ((r = rest.match(/^\/(?:tasks\/([^/]+)\/)?executions\/([^/]+)\/conversation(?:\/event\/(\d{1,7}))?\/?$/))) {
@@ -111,7 +107,6 @@ window.ForgeApp = (() => {
111
107
  else if ((r = rest.match(/^\/adoptions\/([^/]+)\/?$/))) sel = { kind: 'adoption', name: d(r[1]) };
112
108
  else if (/^\/verification\/?$/.test(rest)) sel = { kind: 'verification' };
113
109
  else if (/^\/integration\/?$/.test(rest)) sel = { kind: 'integration' };
114
- else if ((r = rest.match(/^\/tasks\/([^/]+)\/fractal\/([^/]+)\/?$/))) sel = { kind: 'fractal', task: d(r[1]), node: d(r[2]) };
115
110
  return { key: d(m[1]), sel };
116
111
  }
117
112
  const select = sel => { location.hash = hashFor(state.key, sel); };
@@ -317,6 +312,7 @@ window.ForgeApp = (() => {
317
312
  window.ForgeMap3D.load().then(mod => mod.createStage(stageHost, {
318
313
  onSelect: sel => select(sel),
319
314
  onOpenRun: key => { location.hash = hashFor(key, null); },
315
+ onOpenNode: n => { location.hash = hashFor(n.run, { kind: 'task', id: n.task }); }, // a subtask, in its sub-plan's run
320
316
  onBack: () => { location.hash = '#/'; },
321
317
  onMode: mode => setMode(mode),
322
318
  onLayers: L => { state.layers = L; store.set('layers', L); syncLayerKeys(); }, // the stage's I key
@@ -936,13 +932,34 @@ window.ForgeApp = (() => {
936
932
  value => window.ForgePanel.changeSummaries(host.querySelector('.sum-msgs'), null, key, { input: value }, () => loadRun(key)),
937
933
  'Summaries for this run'));
938
934
  } else kids.push(el('span', undefined, 'sum-state'));
939
- kids.push(el('span', undefined, 'sum-model'), el('div', undefined, 'sum-msgs'));
935
+ kids.push(el('span', undefined, 'sum-model'));
936
+ // The model they use (#163): a planned run never reads `forge config set summaries.model` again, so this sets
937
+ // the run's own (`forge control set summaries-model`); the CLI refuses `on` while the run has none.
938
+ if (summaryWritable) kids.push(summaryModelForm(host, key));
939
+ kids.push(el('div', undefined, 'sum-msgs'));
940
940
  host.replaceChildren(...kids);
941
941
  }
942
942
  for (const b of host.querySelectorAll('.sum-bank button')) b.setAttribute('aria-pressed', String(b.dataset.value === mode));
943
943
  const word = host.querySelector('.sum-state');
944
944
  if (word) word.textContent = mode;
945
- host.querySelector('.sum-model').replaceChildren(...(mode === 'on' && run.summaries.model ? [window.ForgeIcons.modelPlate(run.summaries.model)] : []));
945
+ const model = run.summaries && run.summaries.model;
946
+ host.querySelector('.sum-model').replaceChildren(...(model ? [window.ForgeIcons.modelPlate(model)]
947
+ : mode === 'on' ? [] : [el('span', 'no model set', 'muted')]));
948
+ const field = host.querySelector('.sum-model-form input');
949
+ if (field && document.activeElement !== field) field.placeholder = model ? 'change model' : 'model, e.g. haiku:low';
950
+ }
951
+ function summaryModelForm(host, key) {
952
+ const form = el('form', undefined, 'sum-model-form');
953
+ const field = el('input'); field.type = 'text'; field.spellcheck = false; field.autocomplete = 'off';
954
+ field.setAttribute('aria-label', 'Summaries model for this run (a model spec)');
955
+ const go = el('button', 'Set model'); go.type = 'submit';
956
+ form.append(field, go);
957
+ form.addEventListener('submit', e => {
958
+ e.preventDefault();
959
+ window.ForgePanel.changeSummaries(host.querySelector('.sum-msgs'), null, key, { key: 'summaries-model', input: field.value },
960
+ res => { if (res && res.ok) field.value = ''; loadRun(key); });
961
+ });
962
+ return form;
946
963
  }
947
964
  function renderInspector(run) {
948
965
  const host = $('inspector'); if (!host || !window.ForgePanel) return;
@@ -955,7 +972,9 @@ window.ForgeApp = (() => {
955
972
  refresh: () => loadRun(run.key), // a change made here shows at once, not at the next poll
956
973
  hash: s => hashFor(run.key, s), onSelect: s => select(s), diffHash: spec => diffHash(run.key, spec),
957
974
  convoHash: (s, event) => convoHash(run.key, s, event),
958
- onFractal: (id, data) => { if (state.stage && state.stage.setFractal) state.stage.setFractal(id, data); },
975
+ // a split task's subtasks, drawn over it on the map; a node opens its own task in the sub-plan's run
976
+ onSubtasks: (id, nodes) => { if (state.stage && state.stage.setSubtasks) state.stage.setSubtasks(id, nodes); },
977
+ nodeHash: n => hashFor(n.run, { kind: 'task', id: n.task }),
959
978
  });
960
979
  scoped(host, run.key + ':');
961
980
  });
@@ -88,6 +88,8 @@
88
88
  return { ...out, text: asked.length ? `waits for your answer to ${asked.join(', ')}` : 'waits for its brief questions to be written' };
89
89
  }
90
90
  if (w.kind === 'next') return { ...out, text: "starts at the scheduler's next turn" };
91
+ // #229: left RUNNING by a forge process that is gone
92
+ if (w.kind === 'stale') return { ...out, text: `stopped: no live scheduler${w.command ? ' · ' + w.command : ''}`, command: w.command || null };
91
93
  if (w.kind === 'infra') {
92
94
  const cause = RM.causeLabel(w.class);
93
95
  const needs = w.needs_you === true ? (typeof w.hint === 'string' && w.hint ? `needs you: ${w.hint}` : 'needs you') : null;
@@ -102,7 +104,7 @@
102
104
  return null;
103
105
  }
104
106
  // The Now column's order: running, then what starts soonest, then what waits on others, then what is held
105
- const RANK = { running: 0, next: 1, slot: 2, overlap: 2, brief: 2, deps: 3, infra: 4, drained: 5, stopping: 5, escalation: 6 };
107
+ const RANK = { running: 0, next: 1, slot: 2, overlap: 2, brief: 2, deps: 3, infra: 4, drained: 5, stopping: 5, escalation: 6, stale: 6 };
106
108
  function nowRank(task) {
107
109
  if (task && task.now) return RANK.running;
108
110
  const w = task && task.waiting;
@@ -140,9 +142,16 @@
140
142
  }
141
143
  // The environment problems that several tasks met, for the run header's banner
142
144
  const bannerProblems = (env, least = 2) => list(env && env.problems).filter(p => p && list(p.tasks).length >= least);
143
- // The run inspector's scheduler fields: [[label, text]], or null when no scheduler runs the plan
145
+ // The run inspector's scheduler fields: [[label, text]], or null when no scheduler runs the plan and none
146
+ // left a task RUNNING behind it (#229: then the scheduler reads as stopped, with those tasks and the way back)
144
147
  function schedulerModel(run) {
145
148
  const s = run && run.scheduler;
149
+ const stale = list(s && s.stale).map(String);
150
+ if (s && s.live !== true && stale.length) {
151
+ const w = list(run.tasks).map(t => t.waiting).find(x => x && x.kind === 'stale' && x.command);
152
+ return [['Scheduler', 'stopped: no live scheduler'], ['Left running', stale.join(', ')]]
153
+ .concat(w ? [['Resume with', w.command]] : []);
154
+ }
146
155
  if (!s || s.live !== true) return null;
147
156
  const tasks = list(run.tasks), count = kind => tasks.filter(t => t.waiting && t.waiting.kind === kind).length;
148
157
  const state = s.stopping ? (s.stopping === 'now' ? 'stopping now' : 'stopping once its running tasks end') : s.drained ? 'drained: nothing new starts' : 'dispatching';
@@ -404,7 +413,7 @@
404
413
  const rows = schedulerModel(run);
405
414
  if (!rows) return;
406
415
  const dl = el('dl', undefined, 'fields');
407
- for (const [label, value] of rows) { dl.append(el('dt', label), el('dd', value)); }
416
+ for (const [label, value] of rows) { dl.append(el('dt', label), el('dd', value, label === 'Resume with' ? 'mono' : undefined)); }
408
417
  for (const p of list(run.scheduler.pauses)) {
409
418
  const w = waitingModel({ ...p, kind: 'infra' }, now);
410
419
  const dd = el('dd', w.text);
@@ -30,6 +30,8 @@
30
30
  'infra-backoff': { label: 'Infra backoff', run: 'at the next infrastructure wait', planOnly: true },
31
31
  'escalate-effort': { label: 'Effort step', run: 'at the next retry decision', planOnly: true },
32
32
  'summaries': { label: 'Summaries', run: "at each task's next change", task: 'at its next change' },
33
+ 'summaries-model': { label: 'Summaries model', run: "at each task's next change", planOnly: true },
34
+ 'brief-model': { label: 'Brief model', run: 'at the next brief change proposal', planOnly: true },
33
35
  };
34
36
  const BACKOFF_FORMS = 'exp:<base>[,<cap>], linear:<start>,<step>[,<cap>] or list:<a>,<b>,… (seconds)';
35
37
  // A task status after which "Retry now" applies (or the policy stopped it).
@@ -64,6 +66,47 @@
64
66
  return { ok: true, spec };
65
67
  }
66
68
 
69
+ // What a spec runs (#169, #187): {model, harness, known} from the registry `forge control show` carries
70
+ // ({alias: [[harness, model], ...]}, the first row the default), resolved as forge-dispatch.sh does; an unknown
71
+ // alias with a harness is a literal model id; null when it cannot be resolved (or is a pool).
72
+ function resolveSpec(registry, spec) {
73
+ const text = String(spec === undefined || spec === null ? '' : spec).trim();
74
+ if (!text || text.includes(',') || text === 'script' || text === '-') return null;
75
+ const parts = text.split(':'), alias = parts[0], harness = parts.slice(2).join(':');
76
+ const rows = Array.isArray(obj(registry)[alias]) ? registry[alias] : [];
77
+ const row = rows.find(r => Array.isArray(r) && (!harness || r[0] === harness));
78
+ if (row) return { model: String(row[1]), harness: String(row[0]), known: true };
79
+ return harness ? { model: alias, harness, known: false } : null;
80
+ }
81
+ // "gpt-6.2-sol on codex" for a spec: the label the CLI gave (controls.models), else resolved from the registry.
82
+ function modelLabel(controls, spec) {
83
+ const c = obj(controls), given = obj(c.models)[spec];
84
+ if (typeof given === 'string' && given) return given;
85
+ const r = resolveSpec(c.registry, spec);
86
+ if (!r) return 'not a known model';
87
+ return `${r.model} on ${r.harness}${r.known ? '' : ' (literal id, not in the registry)'}`;
88
+ }
89
+ // One spec or a comma-separated pool, as `forge control models` takes it: {ok, specs, text} or {ok: false, error}.
90
+ function poolOf(input) {
91
+ const text = String(input === undefined || input === null ? '' : input).trim();
92
+ if (!text) return { ok: true, specs: [], text: '' };
93
+ const specs = text.split(',').map(x => x.trim());
94
+ if (specs.some(x => !x)) return bad('a pool is specs separated by commas, such as haiku:xhigh,sonnet');
95
+ for (const x of specs) {
96
+ if (/[\s\u0000-\u001f\u007f]/.test(x)) return bad('a spec cannot hold spaces');
97
+ if (x.startsWith('-')) return bad('a spec cannot start with "-"');
98
+ }
99
+ const joined = specs.join(',');
100
+ return joined.length > MAX_FIELD ? bad(`the specs are longer than ${MAX_FIELD} characters`) : { ok: true, specs, text: joined };
101
+ }
102
+ const TIERS = ['low', 'medium', 'high'];
103
+ // The tiers block of `forge control show` for one tier: {tasks, pending, dwarf: [specs], qa: [specs]}.
104
+ function tierValues(controls, tier) {
105
+ const t = obj(obj(obj(controls).tiers)[tier]);
106
+ const list = v => Array.isArray(v) ? v.filter(x => typeof x === 'string' && x) : [];
107
+ return { tier, tasks: num(t.tasks) || 0, pending: num(t.pending) || 0, dwarf: list(t.dwarf), qa: list(t.qa) };
108
+ }
109
+
67
110
  // A count the CLI takes: 1 to 9 digits (control.py `_int`).
68
111
  function countOf(text) {
69
112
  const t = String(text === undefined || text === null ? '' : text).trim();
@@ -99,6 +142,11 @@
99
142
  return text === 'on' || text === 'off' || (task && text === 'inherit') ? { ok: true, value: text }
100
143
  : bad(task ? 'on, off or inherit' : 'on or off');
101
144
  }
145
+ if (key === 'summaries-model' || key === 'brief-model') {
146
+ // One spec as forge-control.py `_summaries_model` takes it (the doctor checks the rest), or default.
147
+ return text && !/[\s,\u0000-\u001f\u007f]/.test(text) && !text.startsWith('-') && text.length <= MAX_FIELD
148
+ ? { ok: true, value: text } : bad('one model spec such as haiku:low, or default');
149
+ }
102
150
  if (key === 'escalate-effort') return text === 'on' || text === 'off' ? { ok: true, value: text } : bad('on or off');
103
151
  if (key === 'infra-backoff') {
104
152
  // The shape itself is the CLI's to check; here only what can never be one. "default" drops the setting.
@@ -118,6 +166,12 @@
118
166
  }
119
167
  if (action === 'pin') return { action: 'pin', task: a.task, spec: a.spec };
120
168
  if (action === 'unpin') return { action: 'unpin', task: a.task };
169
+ if (action === 'models') {
170
+ const body = { action: 'models', tier: a.tier };
171
+ if (a.dwarf) body.dwarf = a.dwarf;
172
+ if (a.qa) body.qa = a.qa;
173
+ return body;
174
+ }
121
175
  if (action === 'drain' || action === 'resume') return { action };
122
176
  if (action === 'stop') return a && a.now ? { action: 'stop', now: true } : { action: 'stop' };
123
177
  if (action === 'retry') return a.dwarf ? { action: 'retry', task: a.task, dwarf: a.dwarf } : { action: 'retry', task: a.task };
@@ -127,7 +181,8 @@
127
181
  const shown = (key, value, task) => key === 'timeout' ? `${minutesOf(Number(value))} min`
128
182
  : key === 'qa-threshold' && value === 'none' ? (task ? 'P3 for this task' : 'P3 (nothing tolerated)')
129
183
  : key === 'qa-threshold' && value === 'default' ? 'the default (P2)'
130
- : key === 'infra-backoff' && value === 'none' ? 'the default (exp:60)' : value;
184
+ : key === 'infra-backoff' && value === 'none' ? 'the default (exp:60)'
185
+ : (key === 'summaries-model' || key === 'brief-model') && value === 'default' ? 'the default (the plan drops its own)' : value;
131
186
  const inTask = task => task ? ` for task \`${task}\`` : '';
132
187
 
133
188
  // A draft change → {ok, body, confirm} or {ok: false, error}. change: {kind: 'set', key, input, task?} |
@@ -145,12 +200,24 @@
145
200
  if (!c.task) return bad('no task');
146
201
  const s = specOf(c);
147
202
  return s.ok ? { ok: true, body: bodyFor('pin', { task: c.task, spec: s.spec }),
148
- confirm: `Pin task \`${c.task}\`'s next retry to \`${s.spec}\`? Takes effect ${PIN_APPLIES}` } : s;
203
+ confirm: `Pin task \`${c.task}\`'s next retry to \`${s.spec}\`${c.controls ? ` (${modelLabel(c.controls, s.spec)})` : ''}? Takes effect ${PIN_APPLIES}` } : s;
149
204
  }
150
205
  if (c.kind === 'unpin') {
151
206
  return c.task ? { ok: true, body: bodyFor('unpin', { task: c.task }),
152
207
  confirm: `Remove the pin on task \`${c.task}\`? Its next retry goes back to the escalation policy` } : bad('no task');
153
208
  }
209
+ if (c.kind === 'models') {
210
+ if (!TIERS.includes(c.tier)) return bad('the tier is low, medium or high');
211
+ const d = poolOf(c.dwarf), q = poolOf(c.qa);
212
+ if (!d.ok) return bad('implementer: ' + d.error);
213
+ if (!q.ok) return bad('reviewer: ' + q.error);
214
+ if (!d.text && !q.text) return bad('name an implementer, a reviewer or both');
215
+ const said = p => p.specs.map(x => `\`${x}\` (${modelLabel(c.controls, x)})`).join(', ');
216
+ const n = num(c.pending), tasks = n === null ? `the ${c.tier} tasks` : `the ${n} ${c.tier} task${n === 1 ? '' : 's'}`;
217
+ const roles = [d.text ? `implementer ${said(d)}` : null, q.text ? `reviewer ${said(q)}` : null].filter(Boolean).join(' and ');
218
+ return { ok: true, body: bodyFor('models', { tier: c.tier, dwarf: d.text, qa: q.text }),
219
+ confirm: `Use ${roles} for ${tasks} that ${n === 1 ? 'has' : 'have'} not started? ${d.specs.length > 1 || q.specs.length > 1 ? 'A pool is handed out in task order. ' : ''}Takes effect when each task starts; started tasks keep their model` };
220
+ }
154
221
  if (c.kind === 'drain') return { ok: true, body: bodyFor('drain'), confirm: 'Drain the run? Running tasks finish; nothing new starts until you resume' };
155
222
  if (c.kind === 'resume') return { ok: true, body: bodyFor('resume'), confirm: 'Resume the run? The scheduler starts tasks again' };
156
223
  if (c.kind === 'stop') {
@@ -182,7 +249,7 @@
182
249
  // The run's controls as they stand (`forge control show`'s `run`): what each shows.
183
250
  function runValues(controls) {
184
251
  const c = obj(controls), run = obj(c.run);
185
- return { live: c.live === true, fractal: c.fractal === true,
252
+ return { live: c.live === true,
186
253
  qa: LEVELS.includes(run.qa_threshold) ? run.qa_threshold : run.qa_threshold === 'none' ? 'P3' : DEFAULT_LEVEL,
187
254
  qaSource: run.qa_threshold_source === 'set' ? 'set' : 'default',
188
255
  qaText: `${LEVELS.includes(run.qa_threshold) ? run.qa_threshold : run.qa_threshold === 'none' ? 'P3' : DEFAULT_LEVEL} (${run.qa_threshold_source === 'set' ? 'set' : 'default'})`,
@@ -245,11 +312,10 @@
245
312
  const effective = (controls, id) => id === undefined ? runValues(controls) : taskValues(controls, id);
246
313
 
247
314
  // Whether a control can be changed now: {enabled, why, hidden}. Retry and infra budgets only while a scheduler is
248
- // live; a merged task has nothing left to change; Fractal plans never apply pins (the control is hidden).
315
+ // live; a merged task has nothing left to change.
249
316
  function canEdit(controls, key, id) {
250
317
  const c = obj(controls), info = KEYS[key];
251
318
  if (key === 'pin') {
252
- if (c.fractal === true) return { enabled: false, hidden: true, why: 'Fractal plans never apply pins' };
253
319
  if (id !== undefined && taskValues(c, id).status === 'MERGED') return { enabled: false, hidden: false, why: 'merged: nothing left to change' };
254
320
  return { enabled: true, hidden: false, why: null };
255
321
  }
@@ -262,7 +328,8 @@
262
328
  // One line of the change log (`control.log`): who, what, previous → new, when.
263
329
  function logLine(entry) {
264
330
  const e = obj(entry), key = typeof e.key === 'string' ? e.key : '';
265
- const label = e.action === 'pin' || e.action === 'unpin' || key === 'pin' ? 'Pin' : KEYS[key] ? KEYS[key].label : key || String(e.action || '?');
331
+ const label = e.action === 'pin' || e.action === 'unpin' || key === 'pin' ? 'Pin' : e.action === 'models' ? `Models · ${key}`
332
+ : KEYS[key] ? KEYS[key].label : key || String(e.action || '?');
266
333
  const empty = key === 'pin' ? 'no pin' : 'unset';
267
334
  const show = v => v === null || v === undefined || v === '' ? empty : key === 'timeout' && minutesOf(Number(v)) !== null ? `${minutesOf(Number(v))} min` : String(v);
268
335
  return { who: String(e.actor || '?'), what: e.task ? `${label} · ${e.task}` : label, from: show(e.previous), to: show(e.value), at: num(e.at) };
@@ -530,6 +597,65 @@
530
597
  return r.box;
531
598
  }
532
599
 
600
+ // A spec with what it runs: its plate and, muted, the model id and harness.
601
+ function specWithModel(c, spec) {
602
+ const u = ui(), box = u.el('span', undefined, 'ctl-spec');
603
+ box.append(plateOf(spec), u.el('span', modelLabel(c, spec), 'muted ctl-model'));
604
+ return box;
605
+ }
606
+ // What a typed spec (or pool) runs, redrawn as it is typed.
607
+ function resolvedLine(c, text) {
608
+ const p = poolOf(text);
609
+ if (!p.ok) return p.error;
610
+ return p.specs.map(x => `${x} → ${modelLabel(c, x)}`).join('; ');
611
+ }
612
+
613
+ // Models per difficulty (#169): the implementer and reviewer of the tier's tasks that have not started yet.
614
+ function tierRow(view, c, tier) {
615
+ const u = ui(), t = tierValues(c, tier), r = shell(view, 'tier-' + tier, tier, false);
616
+ const line = u.el('div', undefined, 'ctl-tier-now');
617
+ line.append(u.el('span', `${t.pending} of ${t.tasks} not started`, t.pending ? 'tag' : 'muted'));
618
+ for (const [role, specs] of [['dwarf', t.dwarf], ['qa', t.qa]]) {
619
+ if (!specs.length) continue;
620
+ line.append(u.el('span', role, 'ctl-role'));
621
+ for (const x of specs) line.append(specWithModel(c, x));
622
+ }
623
+ r.status.append(line);
624
+ if (!t.pending) { help(r, t.tasks ? 'Every task of this tier has started: a pin or a retry changes its model.' : 'No task of this tier.'); return r.box; }
625
+ const form = u.el('form', undefined, 'ctl-pin ctl-tier');
626
+ form.noValidate = true;
627
+ const input = (name, caption, placeholder) => {
628
+ const i = u.el('input'); i.type = 'text'; i.autocomplete = 'off'; i.spellcheck = false; i.placeholder = placeholder;
629
+ const key = `tier.${tier}.${name}`;
630
+ i.value = field(view, key, '');
631
+ i.addEventListener('input', () => { touch(view, key, i.value); paint(); clearOutcome(view, r); });
632
+ const l = u.el('label', undefined, 'filter ctl-alias'); l.append(u.el('span', caption), i);
633
+ return { i, l, key };
634
+ };
635
+ const d = input('dwarf', 'Implementer', t.dwarf.join(',') || 'e.g. haiku:xhigh'), q = input('qa', 'Reviewer', t.qa.join(',') || 'e.g. opus');
636
+ const hint = u.el('p', undefined, 'ctl-help ctl-resolved');
637
+ const paint = () => {
638
+ const lines = [d.i.value.trim() ? 'implementer: ' + resolvedLine(c, d.i.value) : null, q.i.value.trim() ? 'reviewer: ' + resolvedLine(c, q.i.value) : null].filter(Boolean);
639
+ hint.textContent = lines.length ? lines.join(' · ') : 'One spec, or a pool separated by commas.';
640
+ };
641
+ paint();
642
+ const go = u.el('button', 'Apply', 'primary'); go.type = 'submit';
643
+ form.append(d.l, q.l, go);
644
+ form.addEventListener('submit', e => {
645
+ e.preventDefault();
646
+ commit(view, r, { kind: 'models', tier, dwarf: d.i.value, qa: q.i.value, pending: t.pending, controls: c }, [d.key, q.key], go);
647
+ });
648
+ r.control.append(form, hint);
649
+ return r.box;
650
+ }
651
+ function tierBox(view, c) {
652
+ const u = ui(), box = u.el('div', undefined, 'ctl-tiers');
653
+ box.append(u.el('span', 'Models per difficulty', 'ctl-label'));
654
+ box.append(u.el('p', 'The implementer and reviewer of the tasks that have not started yet, by difficulty.', 'ctl-help'));
655
+ for (const tier of TIERS) box.append(tierRow(view, c, tier));
656
+ return box;
657
+ }
658
+
533
659
  function changeLog(c) {
534
660
  const u = ui(), log = Array.isArray(c.log) ? c.log : [];
535
661
  const box = u.el('div', undefined, 'ctl-log');
@@ -575,6 +701,7 @@
575
701
  body.append(switchRow(view, c, { key: 'escalate-effort', label: 'Effort step', current: v.escalateEffort, perm: perm('escalate-effort'),
576
702
  help: v.escalateEffort === 'on' ? 'On: at the top tier, a task is retried once more at the next effort its model accepts before it stops.'
577
703
  : 'Off: at the top tier, a task that used up its escalation stops with a split suggestion.' }));
704
+ body.append(tierBox(view, c));
578
705
  body.append(changeLog(c));
579
706
  return body;
580
707
  }
@@ -661,12 +788,12 @@
661
788
  const un = u.el('button', 'Unpin'); un.type = 'button';
662
789
  un.title = 'Drop the pin: the next retry goes back to the escalation policy';
663
790
  un.addEventListener('click', () => commit(view, r, { kind: 'unpin', task: id }, ['pin.alias', 'pin.effort', 'pin.harness'], un));
664
- now.append(u.el('span', 'pinned', 'tag'), plateOf(v.pin), un);
791
+ now.append(u.el('span', 'pinned', 'tag'), specWithModel(c, v.pin), un);
665
792
  } else now.append(u.el('span', 'no pin', 'muted'));
666
793
  r.status.append(now);
667
794
  if (v.next) {
668
795
  const next = u.el('p', undefined, 'ctl-help');
669
- next.append(textNode('the policy picked '), plateOf(v.next), textNode(' for the next retry'));
796
+ next.append(textNode('the policy picked '), specWithModel(c, v.next), textNode(' for the next retry'));
670
797
  r.status.append(next);
671
798
  }
672
799
  if (v.stop) {
@@ -682,9 +809,18 @@
682
809
  form.append(...picker.nodes, go);
683
810
  form.addEventListener('submit', e => {
684
811
  e.preventDefault();
685
- commit(view, r, Object.assign({ kind: 'pin', task: id }, picker.read()), picker.fields, go);
812
+ commit(view, r, Object.assign({ kind: 'pin', task: id, controls: c }, picker.read()), picker.fields, go);
686
813
  });
687
- r.control.append(form);
814
+ // What the typed spec runs, before it is applied: a pin never changes the model generation silently (#180).
815
+ const hint = u.el('p', undefined, 'ctl-help ctl-resolved');
816
+ const paint = () => {
817
+ const s = specOf(picker.read());
818
+ hint.textContent = s.ok ? `${s.spec} runs ${modelLabel(c, s.spec)}` : '';
819
+ };
820
+ form.addEventListener('input', paint);
821
+ form.addEventListener('click', () => setTimeout(paint, 0));
822
+ paint();
823
+ r.control.append(form, hint);
688
824
  help(r, 'Applies at the next full retry, not a QA-only resume.');
689
825
  return r.box;
690
826
  }
@@ -812,7 +948,7 @@
812
948
  } };
813
949
  }
814
950
 
815
- return { LEVELS, EFFORTS, KEYS, specOf, countOf, secondsOf, minutesOf, valueFor, bodyFor, prepare, savedText, effective, canEdit, logLine, agoText,
951
+ return { LEVELS, EFFORTS, KEYS, TIERS, resolveSpec, modelLabel, poolOf, tierValues, specOf, countOf, secondsOf, minutesOf, valueFor, bodyFor, prepare, savedText, effective, canEdit, logLine, agoText,
816
952
  aliasesOf, scopeOf, typing, isEditing, keepEditing, redrawDue, countdown, pauseLines, requestState, requestText, canRetry,
817
953
  mountRun, mountTask, hold };
818
954
  });
@@ -22,9 +22,9 @@ window.ForgeConvo = (() => {
22
22
  const icon = name => window.ForgeIcons ? window.ForgeIcons.icon(name) : el('span');
23
23
  const chip = (text, st) => el('span', text, 'chip st-' + st);
24
24
  const num = v => Number.isFinite(Number(v)) && v !== null ? Number(v).toLocaleString() : '—';
25
- const ICON = { prompt: 'flag', message: 'chat', reasoning: 'thought', command: 'terminal', edit: 'pencil', tool: 'tool', result: 'check', error: 'cross', text: 'keyboard', gap: 'chevron-down' };
25
+ const ICON = { prompt: 'flag', steer: 'chat', message: 'chat', reasoning: 'thought', command: 'terminal', edit: 'pencil', tool: 'tool', result: 'check', error: 'cross', text: 'keyboard', gap: 'chevron-down' };
26
26
  // which kinds each filter key shows
27
- const SHOW = [['all', 'All', null], ['said', 'Said', ['prompt', 'message', 'reasoning', 'result', 'error']], ['ran', 'Ran', ['command', 'tool', 'error']],
27
+ const SHOW = [['all', 'All', null], ['said', 'Said', ['prompt', 'steer', 'message', 'reasoning', 'result', 'error']], ['ran', 'Ran', ['command', 'tool', 'error']],
28
28
  ['changed', 'Changed', ['edit']]];
29
29
  const urlFor = (run, spec) => `/api/runs/${enc(run.key)}/executions/${enc(spec.exec)}/transcript`;
30
30
 
@@ -164,6 +164,9 @@ window.ForgeConvo = (() => {
164
164
  } else if (kind === 'message') {
165
165
  head.append(el('span', D.role === 'qa' ? 'Reviewer' : 'Dwarf', 'ev-label')); if (when) head.append(when);
166
166
  body.append(head, el('div', ev.text, 'ev-text'));
167
+ } else if (kind === 'steer') { // a message the user sent while it ran (#252)
168
+ head.append(el('span', 'Your message', 'ev-label'), el('span', 'sent live', 'tag steered')); if (when) head.append(when);
169
+ body.append(head, el('div', ev.text, 'ev-text'));
167
170
  } else if (kind === 'command') {
168
171
  const st = ev.running ? 'running' : ev.error ? 'fail' : ev.exit === 0 || ev.error === false ? 'pass' : ev.exit != null ? 'fail' : 'none';
169
172
  const line = el('span', undefined, 'ev-cmdline'); line.append(el('i', undefined, 'lamp st-' + st), el('code', ev.command || '(no command)', 'ev-cmd'));
@@ -1,7 +1,7 @@
1
1
  /* forge-ui diff viewer: a task's diff (current, previous, committed, or exactly what one reviewer read), a final
2
- review's combined diff, an adopted range or a Fractal node's candidate, with each review finding shown under the line it points
2
+ review's combined diff or an adopted range, with each review finding shown under the line it points
3
3
  at. Defines window.ForgeDiff.render(host, ctx). All API values enter the DOM as text.
4
- ctx = { run, spec: {kind: 'task'|'final'|'adoption'|'fractal', task, source, file, name, node, finding}, fetchJSON(path),
4
+ ctx = { run, spec: {kind: 'task'|'final'|'adoption', task, source, file, name, finding}, fetchJSON(path),
5
5
  rerender(), href(spec) → hash, closeHref }. */
6
6
  window.ForgeDiff = (() => {
7
7
  'use strict';
@@ -24,7 +24,6 @@ window.ForgeDiff = (() => {
24
24
  const base = `/api/runs/${enc(run.key)}`;
25
25
  if (spec.kind === 'final') return `${base}/final-reviews/${enc(spec.name)}/diff`;
26
26
  if (spec.kind === 'adoption') return `${base}/adoptions/${enc(spec.name)}/diff`;
27
- if (spec.kind === 'fractal') return `${base}/tasks/${enc(spec.task)}/fractal/nodes/${enc(spec.node)}/diff`;
28
27
  const src = spec.source || 'current';
29
28
  if (TASK_FILES.has(src)) return `${base}/tasks/${enc(spec.task)}/diff${src === 'current' ? '' : '/' + src}`;
30
29
  return `${base}/executions/${enc(src)}/diff`;
@@ -132,7 +131,7 @@ window.ForgeDiff = (() => {
132
131
  host.replaceChildren();
133
132
  const D = entry.data;
134
133
  const top = el('div', undefined, 'diff-top');
135
- const what = spec.kind === 'final' ? 'Final review' : spec.kind === 'adoption' ? `Adopted range · ${spec.name}` : spec.kind === 'fractal' ? `${spec.task} · Fractal node ${spec.node}` : spec.task === 'solo' && run.kind === 'solo' ? 'Solo run' : `Task ${spec.task}`;
134
+ const what = spec.kind === 'final' ? 'Final review' : spec.kind === 'adoption' ? `Adopted range · ${spec.name}` : spec.task === 'solo' && run.kind === 'solo' ? 'Solo run' : `Task ${spec.task}`;
136
135
  const title = el('h2'); title.append(el('span', 'Diff · ', 'muted'), document.createTextNode(what)); top.append(title);
137
136
  const close = el('a', undefined, 'diff-close button'); close.href = ctx.closeHref;
138
137
  if (window.ForgeIcons) close.append(window.ForgeIcons.icon('close'));
@@ -147,7 +146,7 @@ window.ForgeDiff = (() => {
147
146
  const sources = list(D.sources);
148
147
  if (sources.length > 1) {
149
148
  const bar = el('div', undefined, 'diff-sources'); bar.setAttribute('role', 'group'); bar.setAttribute('aria-label', 'Which diff');
150
- const cur = spec.kind === 'final' ? spec.name : spec.kind === 'fractal' ? 'candidate' : spec.source || 'current';
149
+ const cur = spec.kind === 'final' ? spec.name : spec.source || 'current';
151
150
  for (const s of sources) {
152
151
  const a = el('a', s.label || s.id, 'diff-source'); a.setAttribute('aria-current', String(s.id === cur));
153
152
  a.href = spec.kind === 'final' ? ctx.href({ kind: 'final', name: s.id }) : ctx.href({ ...spec, source: s.id, file: null, finding: null });