gcf-harness-aif-ext 0.21.2 → 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.
package/README.md CHANGED
@@ -43,10 +43,14 @@ ai-factory extension update gcf-harness-aif-ext
43
43
 
44
44
  Updating keeps the hook entry valid — it points into the extension's install directory, which an update refreshes in place.
45
45
 
46
+ 0.23.0 needs `gcf-aif-ext` 0.24: a main batch goes on past a card that left code, the next claim moving it to `work/<id>`. It still stops with `left` when no baseline stands or the shelve is refused. A returning card's first message says what came back and which conflicts to resolve first; `gate --each`'s `dirty` leaves out the paths of the card in the folder; a run's report names `shelved`, `returned` and `conflicts`.
47
+
46
48
  0.5.0 drives work items (`gcf/work/<id>.md`, schema 3) instead of cards and requires `gcf-aif-ext` 0.4.0 — update both together; against an older core the gate refuses with `gcf-aif-ext >= 0.4.0 is required`. A project still holding schema 2 cards in `gcf/cards/` re-creates them first (see the core's "Upgrading from 0.3.x"). What changes for you: `/gcf-run` takes ids of items in `ready`; it no longer stops at `built` but ends each item with `submit`, `close` or `block`; the plan is improved in passes until it converges; the WIP cap counts only items that end waiting for a verdict.
47
49
 
48
50
  0.5.1 is a fix release. During a run, `gcf/config.yml` is always readable, and a Grep inside `gcf/` reads only readset files. An import breaks a `depends:` cycle the pair checks closed and asks a D1 about it. It cuts a section longer than a segment at paragraphs, and lens and pair prompts carry a window around the quote. `/gcf-run` checks the plan against each pillar's invariant and asks each pillar's review question over the diff. Use it with core 0.4.1, which brings the parent feature into the readset.
49
51
 
52
+ 0.22.0 (bundled gcf-session 0.18.1, core up to 0.23): a subagent's lines in a run log read `subagent:`, `subagent tool:`, `subagent tool error:`. A main batch stops when a card ended with its work uncommitted and left new paths outside `gcf/`: the rest read `skipped`, and no card is built on top. Past the answer time a `--ask d1` question says block and picks no option, recommended or not; `--ask all` still takes the recommended one. gcf-run: an environment stop this machine's tools can clear is no question and no block; a `notes:` line against a slot wins, and the run rewrites that slot of its own card.
53
+
50
54
  0.21.2 changes no code: its peer range adds core 0.22.
51
55
 
52
56
  0.21.1: `/gcf-run` treats a `format:` line of `gcf plan check` (core 0.21: the plan's form against the plan profile) as polish its improve passes apply, never a block. It takes core 0.20 or 0.21 (the peer range of 0.21.0 left 0.21 out).
@@ -17,6 +17,7 @@ import {
17
17
  DEFAULT_AGENT,
18
18
  DEFAULT_TIMEOUT_MIN,
19
19
  MAIN_RUN,
20
+ loosePaths,
20
21
  queueOf,
21
22
  stopOf,
22
23
  } from './run.js';
@@ -49,20 +50,35 @@ function itemProblem(id, item, report) {
49
50
  return `${id}: its feature ${parent.id} awaits a decision — decide it first`;
50
51
  }
51
52
 
52
- // A dependency inside the same batch lands here too: the dependent waits for it.
53
- const open = report.open_depends.find((o) => o.id === id);
54
- if (open) {
55
- return (
56
- `${id} depends on unplayed ${open.depends.join(', ')} — playtest them first; ` +
57
- 'a killed one never plays: take it out of depends, or drop'
58
- );
59
- }
60
-
61
53
  // The tune limit is held by `verdict tune` itself: an item tuned up to the limit is still
62
54
  // built once more, and refusing that run would leave it stuck in ready.
63
55
  return null;
64
56
  }
65
57
 
58
+ const THEN = {
59
+ ready: 'run it first',
60
+ blocked: 'unblock it first',
61
+ 'awaiting-decision': 'decide it first',
62
+ };
63
+
64
+ /** What an item waits for, each dependency by what it takes: a card not built has no playtest. */
65
+ function waitWords(id, depends, byId) {
66
+ const each = depends.map((d) => {
67
+ const item = byId.get(d);
68
+ if (!item)
69
+ return (
70
+ `${d}, which has no work item: card it, or take it out of depends ` +
71
+ `(a killed one never plays: take it out, or drop ${id})`
72
+ );
73
+ if (item.type === 'feature') return `${d}, a feature: its children finish first`;
74
+ if (item.running) return `${d}, which is running: it ends first`;
75
+
76
+ return `${d}, which is ${item.status}: ${THEN[item.status] ?? 'it ends first'}`;
77
+ });
78
+
79
+ return `${id} waits for ${each.join('; ')}`;
80
+ }
81
+
66
82
  /**
67
83
  * Why the batch as a whole may not go, or null. `elsewhere` are the items other runs drive now:
68
84
  * a board starts one run per click, so each run sees the others only through their locks.
@@ -99,7 +115,11 @@ function batchProblem(items, wip, elsewhere = []) {
99
115
  return null;
100
116
  }
101
117
 
102
- const verdict = (reason) => ({ pass: !reason, reason: reason ?? '' });
118
+ const verdict = (reason, waits) => ({
119
+ pass: !reason,
120
+ reason: reason ?? '',
121
+ ...(waits && { waits }),
122
+ });
103
123
 
104
124
  const rank = (i) => i.priority ?? Number.MAX_SAFE_INTEGER;
105
125
 
@@ -214,6 +234,10 @@ export function gate(report, ids) {
214
234
  for (const id of ids) {
215
235
  const problem = itemProblem(id, byId.get(id), report);
216
236
  if (problem) return verdict(problem);
237
+ // A dependency inside the same batch lands here too: the dependent waits for it. `waits`: no
238
+ // failure, a queue keeps the item for when it is done.
239
+ const open = report.open_depends.find((o) => o.id === id);
240
+ if (open) return verdict(waitWords(id, open.depends, byId), { id, depends: open.depends });
217
241
  }
218
242
 
219
243
  return verdict(
@@ -446,30 +470,7 @@ export function gateEach(report, ids) {
446
470
  return { items: Object.fromEntries(named.map((id) => [id, gate(report, [id])])) };
447
471
  }
448
472
 
449
- /**
450
- * The checkout's uncommitted paths outside `gcf/` and `GLOSSARY.md`, untracked ones too (a new
451
- * folder as one): a main run's code lands among them, so the board warns before its click (Tails
452
- * "Первым" 6). The moves' own refusals guard `gcf/` and the glossary (core 0.21's gate scope).
453
- * Null outside a git checkout.
454
- */
455
- export function loosePaths(dir) {
456
- // No optional locks: a main run's agent may be committing in the same checkout.
457
- const args = [
458
- ...['--no-optional-locks', 'status', '--porcelain', '-z', '--', '.'],
459
- ...[':(exclude)gcf', ':(exclude)GLOSSARY.md'],
460
- ];
461
- const res = spawnSync('git', args, { cwd: dir, encoding: 'utf8' });
462
- if (res.status !== 0) return null;
463
- const parts = res.stdout.split('\0').filter(Boolean);
464
- const paths = [];
465
- // A rename or a copy gives its old path as the next part: the new one names it.
466
- for (let i = 0; i < parts.length; i++) {
467
- paths.push(parts[i].slice(3));
468
- if (/^(?:[RC].|.[RC])/.test(parts[i])) i++;
469
- }
470
-
471
- return paths;
472
- }
473
+ export { loosePaths };
473
474
 
474
475
  /**
475
476
  * `gate --each` as text: each item's answer, then the loose paths.
@@ -483,8 +484,12 @@ function printEach({ items, dirty }) {
483
484
 
484
485
  function runGate(ids, opts) {
485
486
  if (opts.each) {
486
- const dirty = loosePaths(process.cwd());
487
- const result = { ...gateEach(auditReport(), [...new Set(ids)]), ...(dirty && { dirty }) };
487
+ const report = auditReport();
488
+ // A card's work in the folder is no human's: the next claim shelves it (lib/shelf.js).
489
+ const own = report.main_work?.paths;
490
+ const loose = loosePaths(process.cwd(), { files: Boolean(own) });
491
+ const dirty = own ? loose?.filter((p) => !own.includes(p)) : loose;
492
+ const result = { ...gateEach(report, [...new Set(ids)]), ...(dirty && { dirty }) };
488
493
  if (opts.json) console.log(JSON.stringify(result));
489
494
  else printEach(result);
490
495
 
@@ -732,7 +737,13 @@ export function stopRun(projectDir, id, core = cliCore(projectDir)) {
732
737
  * lessons its sessions left in the inbox.
733
738
  */
734
739
  export const itemLine = (i) =>
735
- [`${i.id}: ${i.result}`, i.reason ?? i.conflict ?? i.error ?? i.skipped, i.process]
740
+ [
741
+ `${i.id}: ${i.result}`,
742
+ i.reason ?? i.conflict ?? i.error ?? i.skipped,
743
+ i.process,
744
+ i.shelved && `${i.shelved.id}'s work went to ${i.shelved.branch}`,
745
+ i.returned && `its work came back with ${i.conflicts?.length ?? 0} conflict(s)`,
746
+ ]
736
747
  .filter(Boolean)
737
748
  .join(' — ') + (i.lessons ? `, ${i.lessons} lesson${i.lessons > 1 ? 's' : ''}` : '');
738
749
 
package/commands/run.js CHANGED
@@ -41,10 +41,17 @@ import { milestones } from './milestones.js';
41
41
  import { readState } from '../hooks/implement-guard.js';
42
42
  import { logMetrics, metricsDir } from '../hooks/metrics.js';
43
43
 
44
- /** What the operator's silence says in a run's chat, past the answer timeout. */
44
+ /** What the operator's silence says in a run's chat, past the answer timeout (`ask: all`). */
45
45
  export const DEFAULT_ANSWER =
46
46
  'No answer came in time: take your safe default, or block the item with your question.';
47
47
 
48
+ /**
49
+ * Its words with `ask: d1`: such a question is the operator's alone, so silence picks no option,
50
+ * not even the one the agent recommended.
51
+ */
52
+ export const D1_ANSWER =
53
+ "No answer came in time: this question is the operator's to answer. Block the item with it and pick nothing.";
54
+
48
55
  /** The denial of a question card in a run that asks the operator nothing (`chat.ask: none`). */
49
56
  export const ASK_NONE =
50
57
  'answer it yourself and write your choice into the plan: this run asks the operator nothing';
@@ -142,12 +149,15 @@ export function json(res, what) {
142
149
  try {
143
150
  return JSON.parse(res.out);
144
151
  } catch (e) {
145
- // The core's refusal is the `Error: <message>` node prints over its stack, every line of it:
146
- // a git failure's first line is its progress, the cause comes after.
152
+ // Core 0.22.2's refusal is its words alone. An older core's is the `Error: <message>` node
153
+ // prints over its stack, every line of it: a git failure's first line is its progress.
147
154
  const text = res.err || res.out;
148
- const why =
149
- (text.match(/^\w*Error: ([\s\S]*?)\r?\n {4}at /m) ?? text.match(/^\w*Error: (.+)$/m))?.[1] ??
150
- text;
155
+ // Only a crash opens with its frame or its header: a later `Error: …` line is the words' own.
156
+ const crash = /^(.+:\d+|\w*Error: .*)\r?$/.test(text.trimStart().split('\n', 1)[0]);
157
+ const header = crash
158
+ ? (text.match(/^\w*Error: ([\s\S]*?)\r?\n {4}at /m) ?? text.match(/^\w*Error: (.+)$/m))
159
+ : null;
160
+ const why = header?.[1] ?? text;
151
161
  throw new Error(`ai-factory gcf ${what} gave no report: ${why.replace(/\r/g, '').trim()}`, {
152
162
  cause: e,
153
163
  });
@@ -472,16 +482,50 @@ const taskOf = (r, launch, after) => {
472
482
  * resume of the session its last run kept (the engine resumes it in the same directory, so the
473
483
  * agent finds it).
474
484
  */
475
- const promptOf = (r, launch) => (kind, caps, rec) => {
476
- const task = taskOf(r, launch, caps.after);
477
- if (kind === 'handoff') return `${task} --handoff`;
478
- if (kind !== 'resume') return task;
479
- // One plain line: the prompt goes into the shell command in double quotes.
480
- const ended = String(rec.ended).replace(/[^\w -]/g, '');
481
-
482
- return `Continue ${task}: the session was cut off (${ended}). Pick up where you stopped.`;
485
+ const promptOf = (r, launch) => {
486
+ // The first message only: a later session finds the files as this one left them.
487
+ let note = folderNote(r.folder);
488
+
489
+ return (kind, caps, rec) => {
490
+ const told = note;
491
+ note = '';
492
+ const task = taskOf(r, launch, caps.after);
493
+ if (kind === 'handoff') return `${task} --handoff${told}`;
494
+ if (kind !== 'resume') return `${task}${told}`;
495
+ // One plain line: the prompt goes into the shell command in double quotes.
496
+ const ended = String(rec.ended).replace(/[^\w -]/g, '');
497
+
498
+ const cut = `the session was cut off (${ended})`;
499
+
500
+ return `Continue ${task}: ${cut}. Pick up where you stopped.${told}`;
501
+ };
483
502
  };
484
503
 
504
+ /**
505
+ * What came back into the folder at the claim (`gcf claim --json`), for a session that may believe
506
+ * its files are as it left them; empty when nothing did. Plain words: see `promptOf`.
507
+ */
508
+ export function folderNote(folder) {
509
+ if (!folder?.returned) return '';
510
+ const names = (conflicts) =>
511
+ conflicts
512
+ .slice(0, 20)
513
+ .map((c) => c.path.replace(/[^\p{L}\p{N}_ ./-]/gu, ''))
514
+ .join(', ') + (conflicts.length > 20 ? ` and ${conflicts.length - 20} more` : '');
515
+ const marked = folder.conflicts.filter((c) => !c.kept_main);
516
+ const kept = folder.conflicts.filter((c) => c.kept_main);
517
+ const { id, files, copy, staged, branch_moved } = folder.returned;
518
+
519
+ return (
520
+ ` Your unfinished work came back into the folder: ${files} file(s), main moved ` +
521
+ `${folder.moved} commit(s) meanwhile.` +
522
+ (marked.length ? ` Conflict markers to resolve first, or block: ${names(marked)}.` : '') +
523
+ (kept.length ? ` Kept main's copy, yours is in commit ${copy}: ${names(kept)}.` : '') +
524
+ (staged ? ` What you had staged apart from the disk is in commit ${staged}.` : '') +
525
+ (branch_moved ? ` Branch work/${id} moved on and stays: its new commits are not here.` : '')
526
+ );
527
+ }
528
+
485
529
  /** The report note of an item whose session skipped gcf-run step 13. */
486
530
  export const OUTSIDE_IMPLEMENT = 'code written outside aif-implement';
487
531
  /** The report note of a main-mode item moved with `--unverified` (its commit says so). */
@@ -903,10 +947,13 @@ export function chatOf({ answerMin = null, graceMs }, config = {}) {
903
947
  const answerMs = (answerMin ?? config.answer_timeout_min ?? CHAT_TIMEOUT_MIN) * 60_000;
904
948
 
905
949
  // `graceMs`: the tests' shorter wait for a read echo (chat.js READ_GRACE_MS).
950
+ const ask = answerMs > 0 ? (config.ask ?? 'd1') : 'none';
951
+
906
952
  return {
907
953
  answerMs,
908
- ask: answerMs > 0 ? (config.ask ?? 'd1') : 'none',
909
- defaultAnswer: DEFAULT_ANSWER,
954
+ ask,
955
+ defaultAnswer: ask === 'd1' ? D1_ANSWER : DEFAULT_ANSWER,
956
+ silencePicks: ask !== 'd1',
910
957
  askNone: ASK_NONE,
911
958
  ...(graceMs && { graceMs }),
912
959
  };
@@ -979,16 +1026,29 @@ async function runMain(projectDir, ids, releaseMain, ctx) {
979
1026
  const items = [];
980
1027
  try {
981
1028
  for (const [n, id] of ids.entries()) {
1029
+ const loose = loosePaths(projectDir);
982
1030
  // Its mark holds it from its claim on: the queue lets it go then.
983
1031
  // Advisory only: a write refused (a file held by a scanner) leaves the item run as it is.
984
1032
  const dequeue = () => {
985
1033
  try {
986
1034
  writeAtomic(queueOf(logs), `${ids.slice(n + 1).join('\n')}\n`);
987
- } catch {}
1035
+ } catch {
1036
+ // Advisory, as above.
1037
+ }
988
1038
  };
989
1039
 
990
1040
  items.push(await mainItem(projectDir, id, { ...ctx, dequeue }));
991
- await postEnd(ctx, items.at(-1));
1041
+ if (!items.at(-1).shelve) await postEnd(ctx, items.at(-1));
1042
+ const left = items.at(-1).shelve
1043
+ ? refusedShelve(projectDir, items.at(-1))
1044
+ : leftBehind(projectDir, items.at(-1), loose);
1045
+ if (left) {
1046
+ items.at(-1).left = left.paths;
1047
+ items.push(
1048
+ ...ids.slice(n + 1).map((rest) => ({ id: rest, result: 'skipped', reason: left.reason })),
1049
+ );
1050
+ break;
1051
+ }
992
1052
  }
993
1053
  } finally {
994
1054
  await rm(queueOf(logs), { force: true });
@@ -998,6 +1058,78 @@ async function runMain(projectDir, ids, releaseMain, ctx) {
998
1058
  return items;
999
1059
  }
1000
1060
 
1061
+ /**
1062
+ * The checkout's uncommitted paths outside `gcf/` and `GLOSSARY.md`, untracked ones too (a new
1063
+ * folder as one): a main run's code lands among them, so the board warns before its click (Tails
1064
+ * "Первым" 6). The moves' own refusals guard `gcf/` and the glossary (core 0.21's gate scope).
1065
+ * Null outside a git checkout. `files`: a new folder as its files, to compare with a card's paths.
1066
+ */
1067
+ export function loosePaths(dir, { files = false } = {}) {
1068
+ // No optional locks: a main run's agent may be committing in the same checkout.
1069
+ const args = [
1070
+ ...['--no-optional-locks', 'status', '--porcelain', '-z', ...(files ? ['-uall'] : [])],
1071
+ ...['--', '.'],
1072
+ ...[':(exclude)gcf', ':(exclude)GLOSSARY.md'],
1073
+ ];
1074
+ const res = spawnSync('git', args, { cwd: dir, encoding: 'utf8' });
1075
+ if (res.status !== 0) return null;
1076
+ const parts = res.stdout.split('\0').filter(Boolean);
1077
+ const paths = [];
1078
+ // A rename or a copy gives its old path as the next part: the new one names it.
1079
+ for (let i = 0; i < parts.length; i++) {
1080
+ paths.push(parts[i].slice(3));
1081
+ if (/^(?:[RC].|.[RC])/.test(parts[i])) i++;
1082
+ }
1083
+
1084
+ return paths;
1085
+ }
1086
+
1087
+ // The results that mean an item's work is committed.
1088
+ const COMMITTED = ['submit', 'close', 'decide', 'deferred'];
1089
+
1090
+ /**
1091
+ * Why a main batch goes no further, or null: `item` ended with its work not committed and left
1092
+ * paths that were not loose before it (`loose`), and the next item would build on top of them. A
1093
+ * plan under `.ai-factory/` is no such work: a block at the plan's stage leaves one by design.
1094
+ * shortcut: a path already loose before it and changed again passes as a human's, as the status
1095
+ * alone cannot tell them apart; comparing hashes would. A card the folder's baseline names goes
1096
+ * further: the next claim shelves its work (docs/Shelve-Plan.md d9).
1097
+ */
1098
+ function leftBehind(dir, item, loose) {
1099
+ if (COMMITTED.includes(item.result) || !loose || folderHolds(dir, item.id)) return null;
1100
+ const fresh = (loosePaths(dir) ?? []).filter(
1101
+ (p) => !loose.includes(p) && !p.startsWith('.ai-factory/'),
1102
+ );
1103
+ if (!fresh.length) return null;
1104
+ const shown = `${fresh.slice(0, 3).join(', ')}${fresh.length > 3 ? '…' : ''}`;
1105
+
1106
+ return {
1107
+ paths: fresh,
1108
+ reason: `${item.id} left uncommitted work (${shown}): the rest of the batch waits for it`,
1109
+ };
1110
+ }
1111
+
1112
+ /** Whether the folder's baseline names card `id`: its loose work can be shelved. */
1113
+ function folderHolds(dir, id) {
1114
+ const r = spawnSync('git', ['log', '-1', '--format=%s', 'refs/gcf/main-work', '--'], {
1115
+ cwd: dir,
1116
+ encoding: 'utf8',
1117
+ });
1118
+
1119
+ return r.status === 0 && r.stdout.trim() === `gcf(main-work): ${id}`;
1120
+ }
1121
+
1122
+ /** The folder cannot change hands: this card and the rest wait, and a board's queue with them. */
1123
+ function refusedShelve(dir, item) {
1124
+ delete item.shelve;
1125
+ const paths = loosePaths(dir) ?? [];
1126
+
1127
+ return {
1128
+ paths: paths.length ? paths : [`work/${item.id}`],
1129
+ reason: `${item.id} did not start: ${item.reason}`,
1130
+ };
1131
+ }
1132
+
1001
1133
  /** The items a main run has yet to reach, one id a line. */
1002
1134
  export const queueOf = (logs) => path.join(logs, `${MAIN_RUN}.queue`);
1003
1135
 
@@ -1022,19 +1154,24 @@ async function mainItem(projectDir, id, ctx) {
1022
1154
  let r;
1023
1155
  let started = false;
1024
1156
  let marked = false;
1157
+ let folder = /** @type {any} */ (null);
1025
1158
  const head = headOf(projectDir);
1026
1159
  await rm(stopOf(logs, id), { force: true });
1027
1160
  // The checkout's lock names the item from now on: a stop before its session marks it.
1028
1161
  writeFileSync(path.join(logs, `${MAIN_RUN}.lock`), `${process.pid}\n${id}\n`);
1029
1162
  try {
1030
- const claimed = await core(['claim', id]);
1163
+ const claimed = await core(['claim', id, '--json']);
1031
1164
  if (!claimed.ok) {
1032
1165
  dequeue();
1033
- throw new Error((claimed.err || claimed.out).trim());
1166
+ const text = (claimed.err || claimed.out).trim();
1167
+ if (text.includes('gcf-refusal: {"code":"shelve"'))
1168
+ return { id, result: 'skipped', reason: text.split('\n')[0], shelve: true, started: false };
1169
+ throw new Error(text);
1034
1170
  }
1035
1171
 
1036
1172
  marked = true;
1037
1173
  dequeue();
1174
+ folder = json(claimed, 'claim');
1038
1175
  const none = async () => {};
1039
1176
 
1040
1177
  // The agent recorded the item's move: no fresh session takes it over.
@@ -1058,6 +1195,7 @@ async function mainItem(projectDir, id, ctx) {
1058
1195
  main: true,
1059
1196
  done,
1060
1197
  lessonsPrompt,
1198
+ folder,
1061
1199
  };
1062
1200
  started = true;
1063
1201
  r = await session(s, ctx);
@@ -1078,9 +1216,21 @@ async function mainItem(projectDir, id, ctx) {
1078
1216
  const note = started && movedUnverified(projectDir, id, head) ? UNVERIFIED_MOVE : null;
1079
1217
 
1080
1218
  // An item refused before its session spent nothing: the metrics keep it out of the share (§11).
1081
- return { ...item, ...r.cost, ...extras(r, note), ...(started ? {} : { started: false }) };
1219
+ return {
1220
+ ...item,
1221
+ ...r.cost,
1222
+ ...extras(r, note),
1223
+ ...(started ? {} : { started: false }),
1224
+ ...folderReport(folder),
1225
+ };
1082
1226
  }
1083
1227
 
1228
+ /** The report names what went where: a shelve must not read as lost work. */
1229
+ const folderReport = (folder) => ({
1230
+ ...(folder?.shelved ? { shelved: folder.shelved } : {}),
1231
+ ...(folder?.returned ? { returned: folder.returned, conflicts: folder.conflicts } : {}),
1232
+ });
1233
+
1084
1234
  /** The checkout's HEAD, or null before its first commit. */
1085
1235
  /** Whether main merged item `id`'s branch since `head`: the integrator's `gcf(integrate): <id>`. */
1086
1236
  function mergedSince(dir, id, head) {
@@ -1300,7 +1450,8 @@ const modeOf = (mode, board, item) => mode ?? item?.run_mode ?? board.run_mode ?
1300
1450
  * `run_mode`, else the project's. Items of two modes are two parts at once under one gate, one
1301
1451
  * report: the main part in the checkout, one item after another, the worktree part beside it;
1302
1452
  * a branch it verifies merges when the main part ends. `gate(ids)` answers `{pass, reason}`; a
1303
- * session past `timeoutMs` is stopped with all it started, and its item stays ready. `fresh` starts new sessions where kept ones would resume;
1453
+ * session past `timeoutMs` is stopped with all it started, and its item stays ready. `fresh` starts
1454
+ * new sessions where kept ones would resume;
1304
1455
  * `waitLimit` holds each session while the account's usage limit is known to reset ahead.
1305
1456
  * `chat` ({answerMs}) keeps each session open to the operator (docs/Chat-Plan.md).
1306
1457
  * The core's moves it and its agents make name the run as their maker (`GCF-By`); the variable
@@ -1404,6 +1555,7 @@ export function runEndOf(i, projectDir, launch = null) {
1404
1555
  } catch {
1405
1556
  // Archived with its item: nothing left.
1406
1557
  }
1558
+
1407
1559
  const steps = (launch?.events ?? []).filter((e) => e.type === 'step');
1408
1560
  const dod = steps.findLast((e) => e.step === 'dod');
1409
1561
  const review = steps.findLast((e) => e.step === 'review');
@@ -1439,6 +1591,7 @@ export function runEvents(file) {
1439
1591
  } catch {
1440
1592
  return [];
1441
1593
  }
1594
+
1442
1595
  const events = lines.flatMap((l) => {
1443
1596
  try {
1444
1597
  return l.trim() ? [JSON.parse(l)] : [];
@@ -1645,7 +1798,11 @@ async function runBatch(
1645
1798
 
1646
1799
  return { passed: verdict, claims: held };
1647
1800
  });
1648
- if (!passed.pass) return { orphans, gate: passed.reason, items: [] };
1801
+ if (!passed.pass) {
1802
+ const waits = passed.waits ? { waits: passed.waits } : {};
1803
+
1804
+ return { orphans, gate: passed.reason, ...waits, items: [] };
1805
+ }
1649
1806
 
1650
1807
  const { agentOf, agentFirst } = commandsOf(core, agent, board, override);
1651
1808
  const ctx = {
package/extension.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://raw.githubusercontent.com/lee-to/ai-factory/2.x/schemas/extension.schema.json",
3
3
  "name": "gcf-harness-aif-ext",
4
- "version": "0.21.2",
4
+ "version": "0.23.0",
5
5
  "description": "GCF orchestration harness for Claude Code: one-command card pipeline, readset guard",
6
6
  "skills": [
7
7
  "skills/gcf-run",
@@ -27,6 +27,7 @@ const whole = (text) => {
27
27
  ? `${line.slice(0, LOG_MAX)}… (${line.length - LOG_MAX} more characters)`
28
28
  : line;
29
29
  };
30
+
30
31
  const LOG_MAX = 8000;
31
32
 
32
33
  /** The first `n` non-empty lines of a text, trimmed, on one line. */
@@ -148,13 +149,16 @@ export function activity(line, now = new Date()) {
148
149
  function logged(e, now) {
149
150
  const at = `[${clock(now)}]`;
150
151
  const content = Array.isArray(e.message?.content) ? e.message.content : [];
152
+ // A subagent's lines say whose they are.
153
+ const sub = e.parent_tool_use_id != null;
151
154
  if (e.type === 'system') return system(e, at);
152
- if (e.type === 'assistant') return { ...said(content, at), ...contextOf(e) };
155
+ if (e.type === 'assistant') return { ...said(content, at, sub), ...contextOf(e) };
153
156
  if (e.type === 'user') {
154
157
  const errors = content.filter((b) => b.type === 'tool_result' && b.is_error);
158
+ const head = sub ? 'subagent tool error' : 'tool error';
155
159
 
156
160
  return {
157
- lines: errors.map((b) => `${at} tool error: ${whole(resultText(b.content))}`),
161
+ lines: errors.map((b) => `${at} ${head}: ${whole(resultText(b.content))}`),
158
162
  // A refused or failed call wrote nothing: its write does not count.
159
163
  ...(errors.length ? { failed: errors.map((b) => String(b.tool_use_id)) } : {}),
160
164
  };
@@ -415,16 +419,16 @@ function contextOf(e) {
415
419
  }
416
420
 
417
421
  /** An assistant turn: its tool calls and its text, which may be the usage-limit message. */
418
- function said(content, at) {
422
+ function said(content, at, sub) {
419
423
  const texts = content.filter((b) => b.type === 'text').map((b) => b.text);
420
424
 
421
425
  return {
422
426
  ...(texts.map((t) => limitIn(t)).find((l) => l.limit) ?? {}),
423
427
  lines: content.flatMap((b) => {
424
- if (b.type === 'tool_use') return [`${at} ${toolLine(b)}`];
428
+ if (b.type === 'tool_use') return [`${at} ${sub ? 'subagent ' : ''}${toolLine(b)}`];
425
429
  const text = b.type === 'text' ? cut(firstLines(b.text, 2), 300) : '';
426
430
 
427
- return text ? [`${at} agent: ${text}`] : [];
431
+ return text ? [`${at} ${sub ? 'subagent' : 'agent'}: ${text}`] : [];
428
432
  }),
429
433
  };
430
434
  }
@@ -198,11 +198,12 @@ function readRaw(file, from, to) {
198
198
 
199
199
  /**
200
200
  * A question card's answers past the timeout: each one's recommended option, or `fallback`.
201
+ * `picks: false`: `fallback` alone, for a question only the operator may answer.
201
202
  */
202
- export function defaultAnswers(questions = [], fallback = DEFAULT_ANSWER) {
203
+ export function defaultAnswers(questions = [], fallback = DEFAULT_ANSWER, { picks = true } = {}) {
203
204
  return Object.fromEntries(
204
205
  questions.map((q) => {
205
- const pick = (q.options ?? []).find((o) => RECOMMENDED.test(o.label ?? ''));
206
+ const pick = picks && (q.options ?? []).find((o) => RECOMMENDED.test(o.label ?? ''));
206
207
 
207
208
  return [q.question, pick ? pick.label.replace(RECOMMENDED, '') : fallback];
208
209
  }),
@@ -684,7 +685,13 @@ function waitCards(c) {
684
685
  waitFor(c, 'card', () => {
685
686
  for (const [rid, card] of [...c.cards])
686
687
  if (card.approval) void decided(c, rid, { allow: false, by: 'timeout' });
687
- else answer(c, rid, defaultAnswers(card.questions, c.defaultAnswer), 'timeout');
688
+ else
689
+ answer(
690
+ c,
691
+ rid,
692
+ defaultAnswers(card.questions, c.defaultAnswer, { picks: c.silencePicks }),
693
+ 'timeout',
694
+ );
688
695
  });
689
696
  }
690
697
 
@@ -756,12 +763,15 @@ export function taskGate(c, e, now, later) {
756
763
 
757
764
  return false;
758
765
  }
766
+
759
767
  c.taskAt.set(e.id, now);
760
768
  }
769
+
761
770
  if (held) {
762
771
  clearTimeout(held.timer);
763
772
  c.taskHeld.delete(e.id);
764
773
  }
774
+
765
775
  if (e.phase === 'end') c.taskAt.delete(e.id);
766
776
 
767
777
  return true;
@@ -845,6 +855,7 @@ const SEEN = {
845
855
  const last = flushed(c, e.id);
846
856
  if (!c.closed) SEEN.task(c, last);
847
857
  };
858
+
848
859
  if (!taskGate(c, e, Date.now(), later)) return;
849
860
  const prompt = e.phase === 'start' ? e.prompt : null;
850
861
  post(c, {
@@ -954,6 +965,8 @@ const CHAT_DEFAULTS = {
954
965
  graceMs: READ_GRACE_MS,
955
966
  steps: { see: () => [] },
956
967
  defaultAnswer: DEFAULT_ANSWER,
968
+ // Whether silence on a question takes its recommended option.
969
+ silencePicks: true,
957
970
  askNone: ASK_NONE,
958
971
  encode: claudeInput,
959
972
  approvals: false,
@@ -41,7 +41,8 @@ function absorb(seen, a) {
41
41
  * flags the session past its share or at a compaction (`handoff.flag`), and calls `stop` once it
42
42
  * works on past more. `windowOf(model)` is the window the share is taken of. A run's `fresh`
43
43
  * session (no resume) over the share at its first reading starts there: a fresh one after it,
44
- * on the same prompt, would too, so the share does not hand it over (a live run at 10%, 2026-11-03: three sessions of 19% each
44
+ * on the same prompt, would too, so the share does not hand it over (a live run at 10%, 2026-11-03:
45
+ * three sessions of 19% each
45
46
  * handed over before any work, and the item blocked); a compaction still does.
46
47
  */
47
48
  function handoffWatch(handoff, windowOf, write, { stop, onFlag, fresh = false }) {
@@ -84,6 +85,7 @@ function handoffWatch(handoff, windowOf, write, { stop, onFlag, fresh = false })
84
85
  `context_handoff_pct ${handoff.pct}: a fresh session would start there too; raise it`,
85
86
  ]);
86
87
  }
88
+
87
89
  if (!w.flagged && (compacted || (share >= handoff.pct && !w.under))) flag(win, pct, compacted);
88
90
  // A project chat hands over by its summary turn, which goes on past the flag (AD-42).
89
91
  if (handoff.soft) return;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gcf-session",
3
- "version": "0.18.0",
3
+ "version": "0.18.1",
4
4
  "private": true,
5
5
  "description": "The session engine of GCF: one agent session and a run as a chain of them, the chat protocol, the provider adapters. Bundled by gcf-harness-aif-ext and gcf-board, never published.",
6
6
  "type": "module",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gcf-harness-aif-ext",
3
- "version": "0.21.2",
3
+ "version": "0.23.0",
4
4
  "description": "GCF orchestration harness for Claude Code: one-command card pipeline, readset guard",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -28,7 +28,7 @@
28
28
  "prepack": "node -e \"const p=require('./package.json'),e=require('./extension.json');if(p.version!==e.version)throw new Error('version mismatch: package.json '+p.version+' vs extension.json '+e.version);require('node:fs').statSync('node_modules/gcf-session/lib/index.js')\""
29
29
  },
30
30
  "peerDependencies": {
31
- "gcf-aif-ext": ">=0.20.0 <0.23.0"
31
+ "gcf-aif-ext": ">=0.24.0 <0.25.0"
32
32
  },
33
33
  "dependencies": {
34
34
  "gcf-session": "file:../gcf-session"
@@ -11,6 +11,10 @@ purpose:
11
11
  - outside `--worktree`, mark each item running after its gate passes: `ai-factory gcf claim <id>`; a move clears the mark, and an item left without one gets `ai-factory gcf release <id>`
12
12
  - a claimed item takes only its session's moves: run `submit`, `close` and `block` on it with `--claimed`
13
13
  - a refused claim means another session works the item: report that item as taken and go on with the next; never `release` it, that is the human's call
14
+ - a claim refused with `gcf-refusal: {"code":"shelve",...}` means the folder cannot change hands: report the item as not started with its reason and stop the run; move no file by hand
15
+ - a claim moves files in the project folder: the unfinished work of the item that held it goes to branch `work/<other>`, and this item's own comes back
16
+ - a claim's `conflict <path>: resolve its markers` lines, or the words after the flags of the session's first message, come before everything else: resolve each marker and go on, or `block` and name the paths
17
+ - a claim's `conflict <path>: kept main's` line keeps main's file; the commit it names holds the item's copy, read it with `git show <commit>:<path>`
14
18
  - an item the audit lists `running_by: you` is held by this session or its harness run, and `unowned` by nobody: the claim passes; `session` or `run` is someone else's
15
19
 
16
20
  inputs:
@@ -58,7 +62,11 @@ forbidden_behaviors:
58
62
  - a ticked task whose code aif-implement's re-entry check finds missing stays pending and gets implemented, with no question to the human
59
63
  - at aif-implement's last question, verify or commit, pick neither: go on with step 13, which verifies, and steps 14-16, which review and commit
60
64
  - an aif-implement question none of these name: answer it by the same rule - the changes stay uncommitted and unstashed, the plan's tasks go on, and GCF commits and moves the item
61
- - do not leave a task ticked that the tune note or the answer reopens: untick it and add the note before step 13, or aif-implement's re-entry check ticks it again over the old code
65
+ - do not leave a task ticked that the tune note, the answer, an amend or a decision from the run's chat reopens: untick it and add the note before step 13, or aif-implement's re-entry check ticks it again over the old code
66
+ - a `notes:` line that contradicts a slot of the card is the human's word: build by it, ask nothing, and rewrite that slot of your own card by it in your commit, as only the slots reach the documents of the systems
67
+ - a decision from the run's chat that contradicts a slot goes the same way
68
+ - do not ask about or block on what stops your tools here and this machine's tools can clear: a held file, an application holding a lock, a stopped service
69
+ - clear such a stop within the deny rules, do the work, and put it back as it was; how comes from the project's rules
62
70
  - do not route a command the permission system refused through a script, a wrapper or another spelling or shell (a full exe path, `cmd /c`, `node`, `npm run`)
63
71
  - do not write a refused command into a DoD command or a config that `ai-factory gcf` runs
64
72
  - a dedicated tool doing the same job (Read, Grep, Glob, Edit) is no wrapper, nor is a refused pipe or `;` chain split into single allowed commands
@@ -79,14 +87,14 @@ workflow:
79
87
  2. for a unit still in `gcf/design/`: take it with the gcf-card skill first
80
88
  3. for a feature id: replace it with its `ready` children from the audit report's `items` (`parent` names the feature) that are not in `open_depends`; a feature in `awaiting-decision` starts none of them
81
89
  4. of those children, keep one per subsystem unless every child sharing it says `parallel: ok`; the rest wait for the next run; an empty list: report "nothing to run" and stop
82
- 5. gate: run `ai-factory gcf-harness gate <item-ids...>` over the whole batch; a non-zero exit is a failed gate, its stderr line is the reason
90
+ 5. gate: run `ai-factory gcf-harness gate <item-ids...>` over the whole batch; a non-zero exit is a failed gate, its stderr line is the reason; outside `--worktree`, then claim the item and take its conflict lines first
83
91
  6. readset: run `ai-factory gcf context <item-id> --json --readset`; it writes `.gcf-session/readset.json` for this session itself; `over_budget: true` stops the run with a D1 question naming the subsystem
84
- 7. plan: run aif-plan full for the item into its `plan:` path, by default `.ai-factory/plans/<id>.md`, reading only the readset files; an existing plan (the item came back after a tune, an unblock or a continue) is kept, not rewritten
92
+ 7. plan: run aif-plan full for the item into its `plan:` path, by default `.ai-factory/plans/<id>.md`, reading only the readset files; an existing plan (the item came back after a tune, an unblock, a continue or an amend) is kept, not rewritten
85
93
  8. improve the plan in passes, each pass a fresh subagent that reads only the plan and the readset and applies aif-improve without questions, writing each default it picks into the plan
86
94
  9. each pass also checks every task against the `invariant` of each pillar in `gcf/PILLARS.md`: the pass reworks a task that breaks one, and a conflict no rework removes is a pillar conflict of step 12
87
95
  10. after each pass run `ai-factory gcf plan check <id>`; a failure blocks the item with its reason; a pass with no blocking finding ends the loop - the plan converged, its polish applied
88
96
  11. passes <= `plan_passes` from `gcf/config.yml` (3 by default); a blocking finding left after the last pass: run `ai-factory gcf block <id> --reason "plan did not converge: <the finding>"` and stop
89
- 12. a question only the human can answer - a save format, a public API, a new dependency, a pillar conflict: run `ai-factory gcf block <id> --reason "<question>"` and stop
97
+ 12. a question only the human can answer - a save format, a public API, a new dependency, a pillar conflict, and no other: run `ai-factory gcf block <id> --reason "<question>"` and stop
90
98
  13. run the aif-implement skill on `@<plan path>`, write the item's `live:` delta, then run `ai-factory gcf verify <id>` and check the item's negative constraints; a non-zero exit is a red DoD; attempts <= `dod_attempts`, each with a diagnosis
91
99
  14. review the diff with a fresh subagent; fix what it finds before the commit; DoD still red after the attempts: commit no code, run `ai-factory gcf block <id> --reason "<diagnosis>"` - its commit carries the item file with its delta
92
100
  15. the reviewer also answers the `review_question` of each pillar in `gcf/PILLARS.md` over the diff: an answer that breaks the pillar is a finding
@@ -94,8 +102,8 @@ workflow:
94
102
  17. gate `verdict` or `decision`: run `ai-factory gcf submit <id>`; gate `auto`: `ai-factory gcf close <id>` - a soft unit closes unplayed; the core defers what the gates defer; never pass `--unverified`, the human's call
95
103
  18. a dependency still waiting for its verdict refuses the close: run `ai-factory gcf block <id> --reason "waits for <dep>"`
96
104
  19. close the run: delete `.gcf-session/readset.json`; report a row per plan pass: pass, blocking, polish, result; hand the human `ai-factory gcf playtest session` when the audit's `play_milestone` is set or an item waits for its verdict
97
- 20. after a tune verdict or an unblock, re-enter this pipeline at step 5: the gates re-run because the counters moved
98
- 21. with `--worktree`: skip the integrate of step 1, steps 2-4 and the playtest of step 19, and change no `gcf/` file but the item's `live:` and new inbox entries (`ai-factory gcf inbox add --category <c>`)
105
+ 20. after a tune verdict, an unblock or an amend, re-enter this pipeline at step 5: the gates re-run because the counters moved
106
+ 21. with `--worktree`: skip the integrate of step 1, steps 2-4 and the playtest of step 19, and change no `gcf/` file but the item's `live:`, a slot the human's word contradicts, and new inbox entries (`ai-factory gcf inbox add --category <c>`)
99
107
  22. with `--worktree`, every stop - a failed gate, an over budget readset, a failed plan check, a refused command, steps 11, 12, 14, 18 - writes `{"block": "<reason>"}` to `.gcf-session/outcome.json` and ends the session
100
108
  23. with `--worktree`, run no `ai-factory gcf block`, `submit` or `close`: the core refuses them on a `work/` branch, and the harness records the move on main
101
109
  24. with `--worktree`, step 17 is: commit everything but `gcf/.metrics`, then run `ai-factory gcf verify <id> --mark`; the harness merges the branch