gcf-aif-ext 0.18.9 → 0.19.1

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
@@ -50,6 +50,22 @@ Updating preserves `gcf/`, `cnlp.config.json` and the pre-commit hook. Run `ai-f
50
50
 
51
51
  On Windows, run `extension add` and `extension update` from PowerShell or cmd, not Git Bash: the installer unpacks with `tar`, and Git Bash's GNU tar reads `C:\…` as a remote host (`Cannot connect to C: resolve failed`). The Windows `tar.exe` handles it.
52
52
 
53
+ ### 0.19.1
54
+
55
+ - `verdict <milestone> keep --milestone` that fails, its commit too, puts the pack's items back with the index as the operator left it: a staged compress edit stays staged.
56
+ - The deny group `git-history` also holds `git push <remote> :<branch>`, which deletes the remote branch.
57
+
58
+ ### 0.19.0
59
+
60
+ Autonomy (docs/Autonomy-Plan.md): the agent works by itself, the operator plays the milestones.
61
+ - The core holds the operator's moves: `verdict`, `decide` (but under the gates), `drop` of a work item, `unblock`, `question answer`, `config set`, `permissions`, `phase next`, `pillar`, `hooks-install` and `item gates` refuse a harness run and a board thread (`GCF-By: thread`). A console session and the operator pass.
62
+ - `gates:` in `gcf/config.yml`: `milestone` wait|go, `verdict` wait|defer (a mechanic's or resource's submit closes it unplayed), `decision` wait|agent (a run decides go or no of its own spike, with `--reason`), `question` wait|assume. A card's `skip_gates`: `ai-factory gcf item gates <id> --to skip|wait|project`. `config set --pair key=value …` sets several keys in one commit.
63
+ - A soft unit whose delta modifies or removes a capability no longer refuses its close: it waits for a verdict, `gate_why: modifies <capability>`.
64
+ - `--assume "<question> = <value>"` on `submit`, `close`, `decide` files a D2 in the move's commit; `ai-factory gcf question add --class D1|D2 …` files one alone. `decide`'s reason goes into its commit.
65
+ - The integrator reads a worktree plan's `## Outcome` (`decide:`, `reason:`, `assume:`) and records it in the item's move, one commit.
66
+ - Milestones: `take --milestone <name>`; a mechanic or resource with a milestone is gate auto; a feature needs one while `game.md` lists them; `verdict <milestone> keep --milestone` keeps all of it that waits for play; `verdict keep --played-on "<line>"`. `gcf audit --json` and `gcf board --json` give `milestones`, `build_milestone`, `play_milestone`, `milestone_order`, and each item's `gates`; the playtest sheet goes by milestone; phases count every milestone up to theirs.
67
+ - The deny group `git-destroy` is `git-history` and `git-discard` (`stash list` and `show` are free); the old id names both.
68
+
53
69
  ### 0.18.9
54
70
 
55
71
  - `gcf design import --commit` that applied some parts and refused others exits 0: it committed what it applied, and the refused parts stay in its report. Before, it exited 1 and gcf-board showed the move as failed. A plain import and an import that applied nothing still exit 1.
@@ -207,7 +223,7 @@ Update together with gcf-harness-aif-ext 0.12.0 and gcf-board 0.6.0 (docs/Sessio
207
223
 
208
224
  ### 0.7.6
209
225
 
210
- - `ai-factory gcf permissions [--on <group>] [--off <group>] [--deny <rule>] [--undeny <rule>]` — what agent runs may not do: deny groups and the human's own rules in the `agent:` section of `gcf/config.yml`, one `gcf(permissions)` commit; with no change it lists them. On by default: `git-destroy`, `mass-delete`, `publish`, `human-moves`, `guards`; off: `secrets`, `outside`, `processes`. `agent.groups` keeps only the human's choices (`secrets: true`): a group it does not name keeps its default, so one a later version adds comes on. `git push` is in none. `gcf board --json` carries `agent` (`groups`, `deny_extra`, the resolved `deny`, `allow`).
226
+ - `ai-factory gcf permissions [--on <group>] [--off <group>] [--deny <rule>] [--undeny <rule>]` — what agent runs may not do: deny groups and the human's own rules in the `agent:` section of `gcf/config.yml`, one `gcf(permissions)` commit; with no change it lists them. On by default: `git-history` (force push, `branch -D`, stash entries dropped), `git-discard` (`reset --hard`, `clean`, stash; `stash list` and `show` are free; the old `git-destroy` names both), `mass-delete`, `publish`, `human-moves`, `guards`; off: `secrets`, `outside`, `processes`. `agent.groups` keeps only the human's choices (`secrets: true`): a group it does not name keeps its default, so one a later version adds comes on. `git push` is in none. `gcf board --json` carries `agent` (`groups`, `deny_extra`, the resolved `deny`, `allow`).
211
227
  - New `config.yml` keys for harness runs: `context_handoff_pct` (60; 0 turns the handoff off), `context_window` (0: the model's) and `auto_compact_pct` (0: the agent's default; at least the handoff share + 15). `gcf board --json` carries them as `context`; a kept session that handed over reads `resume: {ended: 'handoff', handoffs}`.
212
228
  - The AGENTS.md block tells the agent that the permissions are the human's.
213
229
 
package/commands/gcf.js CHANGED
@@ -25,6 +25,7 @@ const verifiedMove = (o) => ({
25
25
  requireVerify: true,
26
26
  unverified: o.unverified === undefined ? undefined : reasonOf(o.unverified),
27
27
  unticked: o.unticked === undefined ? undefined : reasonOf(o.unticked),
28
+ assume: o.assume,
28
29
  });
29
30
 
30
31
  /** The reason of `--unverified`, one line in the commit's subject; an empty one is no reason. */
@@ -45,6 +46,36 @@ const claimedBy = (o, id) => {
45
46
  if (o.claimed) process.env.GCF_RUN_ITEM = id;
46
47
  };
47
48
 
49
+ /** Refuse the operator's move from a harness run or a board thread (lib/git.js needOperator). */
50
+ const operatorOnly = async (move) => (await lib('git')).needOperator(move);
51
+
52
+ /**
53
+ * decide: the operator's, or a run's under the gates' policy (lib/gates.js agentDecideProblem);
54
+ * a board thread proposes it.
55
+ */
56
+ async function deciderMay(id, choice, reason) {
57
+ const by = (await lib('git')).moveBy();
58
+ if (by === 'thread') return operatorOnly('decide');
59
+ if (by !== 'run') return;
60
+ // Its own item only: a run's session decides the spike it drives, not another one.
61
+ const own = process.env.GCF_RUN_ITEM;
62
+ if (own && own !== id)
63
+ throw new Error(
64
+ `decide is the operator's here: ${id} is not the item this run drives (${own})`,
65
+ );
66
+ const item = (await (await lib('ledger')).buildLedger(process.cwd())).item(id);
67
+ if (!item) return;
68
+ const { gcfRoot, readConfig } = await lib('gcf-paths');
69
+ const config = await readConfig(gcfRoot());
70
+ const problem = (await lib('gates')).agentDecideProblem(config, item.data, choice, reason);
71
+ if (problem) throw new Error(problem);
72
+ }
73
+
74
+ const ASSUME =
75
+ "an assumption you took instead of asking: a D2 record in the move's commit, " +
76
+ '"<question> = <value>" (repeatable)';
77
+ const repeated = (v, p) => [...p, v];
78
+
48
79
  /** A session's own command on its item keeps the item's running mark fresh. */
49
80
  const touchSession = async (id) => (await lib('session-mark')).touchSession(process.cwd(), id);
50
81
 
@@ -328,7 +359,7 @@ function sessionHead(s) {
328
359
  }
329
360
 
330
361
  /** The session sheet: the build, then per item what to check and how to get there. */
331
- function sessionText(s) {
362
+ export function sessionText(s) {
332
363
  const lines = sessionHead(s);
333
364
  const decide = s.decisions.length
334
365
  ? [
@@ -341,8 +372,21 @@ function sessionText(s) {
341
372
  : [];
342
373
  if (!s.items.length) return [...lines, 'nothing waits for a playtest', ...decide].join('\n');
343
374
  let group = null;
344
- // Items come sorted by their first subsystem: one header each, so play goes system by system.
375
+ let slice;
376
+ const known = new Map((s.milestones ?? []).map((m) => [m.name, m]));
377
+ // Items come sorted by milestone, then first subsystem: a milestone is played as one slice,
378
+ // its question first, then system by system.
345
379
  for (const c of s.items) {
380
+ const m = known.get(c.milestone) ?? null;
381
+ if (slice === undefined || (m?.name ?? null) !== slice) {
382
+ lines.push('', m ? `# ${m.name}${m.goal ? `: ${m.goal}` : ''}` : '# no milestone');
383
+ if (m?.play) lines.push(`play: ${m.play}`);
384
+ if (m && (m.building || m.blocked))
385
+ lines.push(`still building ${m.building}, blocked ${m.blocked}`);
386
+ slice = m?.name ?? null;
387
+ group = null;
388
+ }
389
+
346
390
  const system = c.system[0] ?? '(no subsystem)';
347
391
  if (system !== group) lines.push('', `## ${system}`);
348
392
  group = system;
@@ -351,6 +395,7 @@ function sessionText(s) {
351
395
  `[ ] ${c.id} (${c.status}) [${c.system.join(',')}] ${c.title ?? c.intent ?? ''}`,
352
396
  );
353
397
  lines.push(` check: ${c.question}`);
398
+ if (c.play_on?.length) lines.push(` play on: ${c.play_on.join('; ')}`);
354
399
  for (const r of c.reach) lines.push(` try: ${r}`);
355
400
  for (const f of c.feel) lines.push(` feel: ${f}`);
356
401
  }
@@ -418,14 +463,39 @@ function registerVerdict(gcf) {
418
463
  [],
419
464
  ),
420
465
  )
466
+ .option(
467
+ '--played-on <line>',
468
+ 'where you played it, a line of platforms in game.md (repeatable; a note, not a must)',
469
+ repeated,
470
+ [],
471
+ )
472
+ .option(
473
+ '--milestone',
474
+ 'the first argument names a milestone: keep all of it that waits for play, one commit',
475
+ )
421
476
  .option('--no-commit', 'skip the verdict commit (tests only)')
422
477
  .action(async (itemId, verdict, opts) => {
423
- const { verdictItem } = await lib('work-ops');
478
+ await operatorOnly('verdict');
479
+ const { keepMilestone, verdictItem } = await lib('work-ops');
480
+ if (opts.milestone) {
481
+ if (verdict !== 'keep')
482
+ throw new Error('a milestone takes keep only: tune or kill per item');
483
+ const r = await keepMilestone(process.cwd(), itemId, {
484
+ note: opts.note ?? '',
485
+ playedOn: opts.playedOn,
486
+ commit: opts.commit,
487
+ });
488
+ console.log(`keep ${r.milestone} → ${r.ids.join(', ')}${shortHash(r.hash)}`);
489
+
490
+ return;
491
+ }
492
+
424
493
  const res = await verdictItem(process.cwd(), itemId, verdict, {
425
494
  note: opts.note ?? '',
426
495
  tags: splitList(opts.tags),
427
496
  remove: opts.remove,
428
497
  constraints: opts.constraint,
498
+ playedOn: opts.playedOn,
429
499
  commit: opts.commit,
430
500
  });
431
501
  console.log(
@@ -726,8 +796,14 @@ function registerMoves(gcf) {
726
796
  .command('take <ids...>')
727
797
  .description('Move ready units from gcf/design/ into work items gcf/work/<id>.md (no commit)')
728
798
  .option('--feature <id>', 'group them under this feature item, new or live')
799
+ .option('--milestone <name>', 'the milestone of game.md a unit without its own is played with')
729
800
  .action(async (ids, o) => {
730
- const r = await (await ops()).takeUnits(process.cwd(), ids, { feature: o.feature ?? null });
801
+ const r = await (
802
+ await ops()
803
+ ).takeUnits(process.cwd(), ids, {
804
+ feature: o.feature ?? null,
805
+ milestone: o.milestone ?? null,
806
+ });
731
807
  console.log(r.items.join('\n'));
732
808
  });
733
809
  gcf
@@ -760,6 +836,8 @@ function registerMoves(gcf) {
760
836
  const tags = splitList(o.tags);
761
837
  const { buildLedger } = await lib('ledger');
762
838
  const isItem = (await buildLedger(process.cwd())).item(id);
839
+ // A unit's drop stays the agent's: gcf-card drops one that already ships on the human's yes.
840
+ if (isItem) await operatorOnly('drop of a work item');
763
841
  const r = isItem
764
842
  ? await (
765
843
  await lib('work-ops')
@@ -904,6 +982,25 @@ function registerAgent(item) {
904
982
  ).setRunMode(process.cwd(), id, { run: o.run, commit: o.commit });
905
983
  console.log(`${id} runs in ${r.run_mode ?? "the project's run_mode"}${shortHash(r.hash)}`);
906
984
  });
985
+ item
986
+ .command('gates <id>')
987
+ .description(
988
+ "The operator's choice of an item's stops: skip (verdict defer, decision agent, question " +
989
+ "assume), wait, or the project's gates: (commit)",
990
+ )
991
+ .requiredOption(
992
+ '--to <choice>',
993
+ "skip (the agent goes on), wait (they wait for you), project (the project's gates: hold)",
994
+ )
995
+ .option('--no-commit', 'skip the commit (tests only)')
996
+ .action(async (id, o) => {
997
+ await operatorOnly('item gates');
998
+ const r = await (
999
+ await lib('work-ops')
1000
+ ).setGates(process.cwd(), id, { gates: o.to, commit: o.commit });
1001
+ const now = { true: 'skip', false: 'wait', null: "the project's" }[String(r.skip_gates)];
1002
+ console.log(`${id} gates: ${now}${shortHash(r.hash)}`);
1003
+ });
907
1004
  }
908
1005
 
909
1006
  function registerAttach(item) {
@@ -960,17 +1057,51 @@ function registerItemMoves(gcf) {
960
1057
  .requiredOption('--text <text>', 'the answer, one line')
961
1058
  .option('--no-commit', 'skip the commit (tests only)')
962
1059
  .action(async (qid, o) => {
1060
+ await operatorOnly('question answer');
963
1061
  const r = await (
964
1062
  await lib('questions')
965
1063
  ).answerQuestion(process.cwd(), qid, o.text, { commit: o.commit });
966
1064
  console.log(`answered ${r.id}${shortHash(r.hash)}`);
967
1065
  });
1066
+ question
1067
+ .command('add')
1068
+ .description(
1069
+ 'File a question only the human answers (D1, --blocks the units it holds) or your ' +
1070
+ 'assumption (D2, --assumed the value you took): commit gcf(question)',
1071
+ )
1072
+ .requiredOption('--class <class>', 'D1 or D2')
1073
+ .requiredOption('--question <text>', 'the question, one line')
1074
+ .option('--proposed <text>', 'your proposed answer (D1)')
1075
+ .option('--assumed <text>', 'the value you took (D2)')
1076
+ .option('--blocks <ids>', 'the units or items a D1 holds, comma-separated')
1077
+ .option('--until <trigger>', 'when a D2 comes back: verdict(<id>), retune(<sys>), manual(...)')
1078
+ .option('--sys <list>', 'the subsystems it is about, comma-separated')
1079
+ .option('--no-commit', 'skip the commit (tests only)')
1080
+ .action(async (o) => {
1081
+ const r = await (
1082
+ await lib('questions')
1083
+ ).addQuestion(
1084
+ process.cwd(),
1085
+ {
1086
+ class: o.class,
1087
+ question: o.question,
1088
+ proposed: o.proposed,
1089
+ assumed: o.assumed,
1090
+ blocks: o.blocks,
1091
+ until: o.until,
1092
+ sys: o.sys,
1093
+ },
1094
+ { commit: o.commit },
1095
+ );
1096
+ console.log(`${r.id}${shortHash(r.hash)}`);
1097
+ });
968
1098
  gcf
969
1099
  .command('submit <id>')
970
1100
  .description('ready → awaiting-verdict / awaiting-decision (commit gcf(submit))')
971
1101
  .option('--claimed', CLAIMED)
972
1102
  .option('--unverified <why>', UNVERIFIED)
973
1103
  .option('--unticked <why>', UNTICKED)
1104
+ .option('--assume <line>', ASSUME, repeated, [])
974
1105
  .option('--no-commit', 'skip the commit (tests only)')
975
1106
  .action(async (id, o) => {
976
1107
  claimedBy(o, id);
@@ -989,6 +1120,7 @@ function registerItemMoves(gcf) {
989
1120
  .option('--claimed', CLAIMED)
990
1121
  .option('--unverified <why>', UNVERIFIED)
991
1122
  .option('--unticked <why>', UNTICKED)
1123
+ .option('--assume <line>', ASSUME, repeated, [])
992
1124
  .option('--no-commit', 'skip the commit (tests only)')
993
1125
  .action(async (id, o) => {
994
1126
  claimedBy(o, id);
@@ -1005,15 +1137,18 @@ function registerDecide(gcf) {
1005
1137
  gcf
1006
1138
  .command('decide <id> <choice>')
1007
1139
  .description('go | no | wontfix | known | close | continue | kill (Methodology §4.1)')
1008
- .option('--reason <text>', 'why: the graveyard keeps it'),
1140
+ .option('--reason <text>', 'why: the graveyard and the commit keep it'),
1009
1141
  )
1142
+ .option('--assume <line>', ASSUME, repeated, [])
1010
1143
  .option('--no-commit', 'skip the commit (tests only)')
1011
1144
  .action(async (id, choice, o) => {
1145
+ await deciderMay(id, choice, o.reason);
1012
1146
  const r = await (
1013
1147
  await ops()
1014
1148
  ).decideItem(process.cwd(), id, choice, {
1015
1149
  reason: o.reason ?? '',
1016
1150
  remove: o.remove,
1151
+ assume: o.assume,
1017
1152
  commit: o.commit,
1018
1153
  });
1019
1154
  console.log(`${r.choice} ${r.id}${shortHash(r.hash)}${removalLine(r)}`);
@@ -1037,6 +1172,7 @@ function registerDecide(gcf) {
1037
1172
  .option('--note <text>', 'the answer, or "file: <path>" for an asset')
1038
1173
  .option('--no-commit', 'skip the commit (tests only)')
1039
1174
  .action(async (id, o) => {
1175
+ await operatorOnly('unblock');
1040
1176
  const r = await (
1041
1177
  await ops()
1042
1178
  ).unblockItem(process.cwd(), id, { note: o.note ?? '', commit: o.commit });
@@ -1458,14 +1594,45 @@ function registerSettings(gcf) {
1458
1594
  );
1459
1595
  });
1460
1596
  config
1461
- .command('set <key>')
1462
- .description('Set one key; an empty --value= takes a number back to its default, a word off')
1597
+ .command('set [key]')
1598
+ .description(
1599
+ 'Set one key; an empty --value= takes a number back to its default, a word off; or ' +
1600
+ 'several keys of gcf/config.yml in one commit with --pair key=value (a preset)',
1601
+ )
1463
1602
  // The value only through --value: `set plan_passes 7` must not read as a reset. A value
1464
1603
  // may start with a hyphen (a command's flag); as `--value=<text>` it stays one value.
1465
1604
  .allowExcessArguments(false)
1466
- .requiredOption('--value <value>', 'the new value; empty (--value=) for the default')
1605
+ .option('--value <value>', 'the new value; empty (--value=) for the default')
1606
+ .option(
1607
+ '--pair <key=value>',
1608
+ 'a key and its value, repeatable: one commit for all',
1609
+ repeated,
1610
+ [],
1611
+ )
1467
1612
  .option('--no-commit', 'skip the commit (tests only)')
1468
1613
  .action(async (key, o) => {
1614
+ await operatorOnly('config set');
1615
+ if (o.pair.length) {
1616
+ if (key !== undefined || o.value !== undefined)
1617
+ throw new Error('give a key with --value, or --pair key=value, not both');
1618
+ const pairs = o.pair.map((p) => {
1619
+ const at = p.indexOf('=');
1620
+ if (at < 1) throw new Error(`--pair is key=value, not ${p}`);
1621
+
1622
+ return [p.slice(0, at), p.slice(at + 1)];
1623
+ });
1624
+ const r = await (
1625
+ await lib('config-set')
1626
+ ).setConfigs(process.cwd(), pairs, {
1627
+ commit: o.commit,
1628
+ });
1629
+ console.log(`${r.keys.join(', ')}${r.unchanged ? ' (unchanged)' : shortHash(r.hash)}`);
1630
+
1631
+ return;
1632
+ }
1633
+
1634
+ if (key === undefined || o.value === undefined)
1635
+ throw new Error('give a key and --value <value>, or --pair key=value');
1469
1636
  const r = await (
1470
1637
  await lib('config-set')
1471
1638
  ).setConfig(process.cwd(), key, o.value, {
@@ -1501,6 +1668,7 @@ function registerPermissions(gcf) {
1501
1668
  const perms = await lib('agent-permissions');
1502
1669
  const { gcfRoot, readConfig } = await lib('gcf-paths');
1503
1670
  const change = [o.on, o.off, o.deny, o.undeny].some(Boolean);
1671
+ if (change) await operatorOnly('permissions');
1504
1672
  const r = change
1505
1673
  ? await perms.setPermissions(process.cwd(), o, { commit: o.commit })
1506
1674
  : perms.agentOf(await readConfig(gcfRoot()));
@@ -1560,6 +1728,7 @@ function registerPhase(gcf) {
1560
1728
  .option('--reason <text>', 'why, when an exit criterion is not met')
1561
1729
  .option('--no-commit', 'skip the commit (tests only)')
1562
1730
  .action(async (o) => {
1731
+ await operatorOnly('phase next');
1563
1732
  const r = await (
1564
1733
  await lib('phase')
1565
1734
  ).nextPhase(process.cwd(), { reason: o.reason ?? '', commit: o.commit });
@@ -1575,6 +1744,7 @@ function registerHooksInstall(gcf) {
1575
1744
  .command('hooks-install')
1576
1745
  .description('Install the gcf pre-commit gate into the repository hooks dir (idempotent)')
1577
1746
  .action(async () => {
1747
+ await operatorOnly('hooks-install');
1578
1748
  const { writeFile } = await import('node:fs/promises');
1579
1749
  // --git-path resolves the hooks dir for a plain repo, a worktree and a submodule alike,
1580
1750
  // where a bare existsSync('.git') passes on a worktree and then fails with ENOTDIR.
@@ -1627,6 +1797,7 @@ function registerPillar(gcf) {
1627
1797
  .option('--to <id>', 'the new id, for a caller that passes options only (a board)')
1628
1798
  .option('--no-commit', 'skip the commit (tests only)')
1629
1799
  .action(async (from, arg, o) => {
1800
+ await operatorOnly('pillar rename');
1630
1801
  if ((arg === undefined) === (o.to === undefined))
1631
1802
  throw new Error('give the new id once: as the argument or --to <id>');
1632
1803
  const to = arg ?? o.to;
@@ -1639,6 +1810,7 @@ function registerPillar(gcf) {
1639
1810
  .requiredOption('--reason <text>', 'why the game no longer holds it')
1640
1811
  .option('--no-commit', 'skip the commit (tests only)')
1641
1812
  .action(async (id, o) => {
1813
+ await operatorOnly('pillar retire');
1642
1814
  const r = await (await lib('pillars')).retirePillar(process.cwd(), id, o);
1643
1815
  console.log(`retired ${id}${shortHash(r.hash)}`);
1644
1816
  if (r.bare.length)
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-aif-ext",
4
- "version": "0.18.9",
4
+ "version": "0.19.1",
5
5
  "description": "Game Context Framework for AI Factory",
6
6
  "skills": [
7
7
  "skills/gcf-init",
@@ -105,13 +105,10 @@ const files = (kind, ...globs) => globs.map((pattern) => ({ kind, pattern }));
105
105
  /** @type {{ id: string, label: string, on: boolean, rules: Rule[] }[]} */
106
106
  export const DENY_GROUPS = [
107
107
  {
108
- id: 'git-destroy',
109
- label: 'git history and uncommitted work: reset --hard, clean, stash, force push',
108
+ id: 'git-history',
109
+ label: 'git history: force push, branch -D, a ref deleted, stash entries dropped',
110
110
  on: true,
111
111
  rules: shell(
112
- 'git reset --hard*',
113
- 'git clean*',
114
- 'git stash*',
115
112
  'git branch -D*',
116
113
  'git filter-branch*',
117
114
  'git update-ref -d*',
@@ -123,10 +120,32 @@ export const DENY_GROUPS = [
123
120
  'git push *+*',
124
121
  'git push*--mirror*',
125
122
  'git push*--delete*',
123
+ // A refspec with no source deletes the remote branch: git push origin :old.
124
+ 'git push * :*',
125
+ 'git stash drop*',
126
+ 'git stash clear*',
127
+ ),
128
+ },
129
+ {
130
+ // The stash stack is the checkout's and every worktree's: a pop may take the operator's.
131
+ id: 'git-discard',
132
+ label:
133
+ 'uncommitted work: reset --hard, clean, checkout or restore of all, stash (list and show are free)',
134
+ on: true,
135
+ rules: shell(
136
+ 'git reset --hard*',
137
+ 'git clean*',
126
138
  'git checkout .',
127
139
  'git checkout -- .',
128
140
  'git restore .',
129
141
  'git restore -- .',
142
+ 'git stash',
143
+ 'git stash -*',
144
+ 'git stash push*',
145
+ 'git stash save*',
146
+ 'git stash pop*',
147
+ 'git stash apply*',
148
+ 'git stash branch*',
130
149
  ),
131
150
  },
132
151
  {
@@ -160,14 +179,14 @@ export const DENY_GROUPS = [
160
179
  {
161
180
  id: 'human-moves',
162
181
  label:
163
- "the human's GCF moves: verdict, decide, answer, unblock, phase, pillars, settings, " +
164
- 'permissions, setup',
182
+ "the human's GCF moves: verdict, answer, unblock, a card's gates, phase, pillars, " +
183
+ 'settings, permissions, setup (decide the core holds by the gates)',
165
184
  on: true,
166
185
  rules: shell(
167
186
  'ai-factory gcf verdict*',
168
- 'ai-factory gcf decide*',
169
187
  'ai-factory gcf question answer*',
170
188
  'ai-factory gcf unblock*',
189
+ 'ai-factory gcf item gates*',
171
190
  'ai-factory gcf phase next*',
172
191
  'ai-factory gcf pillar*',
173
192
  'ai-factory gcf permissions*',
@@ -175,6 +194,8 @@ export const DENY_GROUPS = [
175
194
  'ai-factory gcf hooks-install*',
176
195
  'ai-factory gcf-harness init*',
177
196
  'ai-factory gcf-harness run*',
197
+ // The autopilot's card session: an agent starts none.
198
+ 'ai-factory gcf-harness card*',
178
199
  'ai-factory gcf-harness stop*',
179
200
  // The operator's chat input: an agent answering its own question would be no answer.
180
201
  'ai-factory gcf-harness chat*',
@@ -231,7 +252,10 @@ export const DENY_GROUPS = [
231
252
  ];
232
253
 
233
254
  const GROUP_IDS = DENY_GROUPS.map((g) => g.id);
234
- const known = (x) => GROUP_IDS.includes(x);
255
+ // A group a later version split: its old id still names all of its parts.
256
+ const ALIASES = { 'git-destroy': ['git-history', 'git-discard'] };
257
+ const known = (x) => GROUP_IDS.includes(x) || x in ALIASES;
258
+ const partsOf = (id) => ALIASES[id] ?? [id];
235
259
  const rule = (x) => parseRule(x) !== null;
236
260
 
237
261
  function rules(agent, key) {
@@ -260,8 +284,12 @@ function choices(agent) {
260
284
  `gcf/config.yml: agent.groups.${id} must be true or false, ` +
261
285
  `for one of ${GROUP_IDS.join(' | ')}`,
262
286
  );
287
+ // An old id holds each part it split into, unless the file names that part itself.
288
+ const parts = Object.entries(g)
289
+ .filter(([id]) => id in ALIASES)
290
+ .flatMap(([id, on]) => ALIASES[id].filter((p) => !(p in g)).map((p) => [p, on]));
263
291
 
264
- return g;
292
+ return { ...Object.fromEntries(parts), ...g };
265
293
  }
266
294
 
267
295
  /**
@@ -284,7 +312,8 @@ function picksOf(agent) {
284
312
  /**
285
313
  * The `agent:` section resolved: the project's model and effort, each group on or off, the deny
286
314
  * rules the run gets, the extra allow rules (for an agent run without bypass). No section: the
287
- * default groups. `rules` holds them neutral (AD-4), `deny` and `allow` as claude rules for a
315
+ * default groups. `rules` holds them neutral (AD-4), a group's deny rule with its `group` (the
316
+ * operator's own have none), `deny` and `allow` as claude rules for a
288
317
  * harness before 0.12; `deny_extra` is the operator's own deny lines as written, `extra` the
289
318
  * same neutral.
290
319
  */
@@ -296,8 +325,11 @@ export function agentOf(config) {
296
325
  const extra = rules(agent, 'deny');
297
326
  const allowed = rules(agent, 'allow').map(parseRule);
298
327
  const groups = DENY_GROUPS.map((g) => ({ id: g.id, label: g.label, on: chosen[g.id] ?? g.on }));
328
+ // A group's rule names its group: a refusal in a chat says which group to turn off.
299
329
  const denied = [
300
- ...DENY_GROUPS.filter((g, i) => groups[i].on).flatMap((g) => g.rules),
330
+ ...DENY_GROUPS.filter((g, i) => groups[i].on).flatMap((g) =>
331
+ g.rules.map((r) => ({ ...r, group: g.id })),
332
+ ),
301
333
  ...extra.map(parseRule),
302
334
  ].filter((r, i, all) => all.findIndex((x) => sameRule(x, r)) === i);
303
335
 
@@ -346,8 +378,19 @@ export async function setPermissions(projectDir, change, { commit = true } = {})
346
378
  ensureMap(doc, ['agent', 'groups'], GROUPS_SHAPE);
347
379
  const current = agentOf({ agent: doc.toJS().agent });
348
380
  checkChange(change, current);
349
- for (const id of change.on ?? []) doc.setIn(['agent', 'groups', id], true);
350
- for (const id of change.off ?? []) doc.setIn(['agent', 'groups', id], false);
381
+ // An old id goes to its parts; the old key leaves the file once they are written.
382
+ for (const id of change.on ?? [])
383
+ for (const p of partsOf(id)) doc.setIn(['agent', 'groups', p], true);
384
+ for (const id of change.off ?? [])
385
+ for (const p of partsOf(id)) doc.setIn(['agent', 'groups', p], false);
386
+ for (const old of Object.keys(ALIASES))
387
+ if (doc.hasIn(['agent', 'groups', old])) {
388
+ for (const p of ALIASES[old])
389
+ if (!doc.hasIn(['agent', 'groups', p]))
390
+ doc.setIn(['agent', 'groups', p], doc.getIn(['agent', 'groups', old]));
391
+ doc.deleteIn(['agent', 'groups', old]);
392
+ }
393
+
351
394
  const deny = [...new Set([...current.deny_extra, ...(change.deny ?? [])])].filter(
352
395
  (r) => !change.undeny?.some((u) => sameRule(parseRule(u), parseRule(r))),
353
396
  );
package/lib/audit-core.js CHANGED
@@ -5,7 +5,7 @@ import { spawnSync } from 'node:child_process';
5
5
  import { listItems, listSystems, readConfig, tokensEst, legacyCards } from './gcf-paths.js';
6
6
  import { lint } from './linter.js';
7
7
  import { drifted } from './index-gen.js';
8
- import { designCheck, recordsIn } from './design-check.js';
8
+ import { designCheck, gameMilestones, recordsIn } from './design-check.js';
9
9
  import { PILLARS_MAX } from './design.js';
10
10
  import { buildLedger } from './ledger.js';
11
11
  import { STORED } from './transitions.js';
@@ -15,6 +15,8 @@ import { markOwner, ownerOf, sessionActive } from './session-mark.js';
15
15
  import { fieldOf } from './question-fields.js';
16
16
  import { inboxProblems } from './inbox.js';
17
17
  import { inboxVocabulary } from './domain.js';
18
+ import { gatePolicy, verdictDeferred } from './gates.js';
19
+ import { milestoneState } from './milestone-state.js';
18
20
 
19
21
  function git(args, cwd) {
20
22
  // A blame of a long file overflows the 1 MiB default, and an overflow reads as a git failure.
@@ -86,7 +88,12 @@ export async function audit(projectDir) {
86
88
  const items = await listItems(root);
87
89
  const systems = await listSystems(root);
88
90
  const ledger = await buildLedger(projectDir);
89
- const unplayed = items.filter((c) => c.data.status === 'unplayed').length;
91
+ // An unplayed item of a milestone waits for that milestone's play by design: only the ones
92
+ // with none (or one game.md no longer has) pile up unasked (docs/Autonomy-Plan.md, C).
93
+ const named = new Set(((await gameMilestones(root)) ?? []).map((m) => m.name));
94
+ const unplayed = items.filter(
95
+ (c) => c.data.status === 'unplayed' && !named.has(c.data.milestone),
96
+ ).length;
90
97
  /** @type {AuditReport} */
91
98
  const report = {
92
99
  first_line: '',
@@ -116,6 +123,7 @@ export async function audit(projectDir) {
116
123
  };
117
124
  // The harness gate reads everything from this one report — it never parses gcf/ itself.
118
125
  report.schema = config.schema;
126
+ report.gates = config.gates;
119
127
  report.items = items.map((c) => ({
120
128
  id: c.data.id,
121
129
  type: c.data.type,
@@ -127,6 +135,12 @@ export async function audit(projectDir) {
127
135
  tune_count: c.data.tune_count ?? 0,
128
136
  parallel: c.data.parallel ?? 'serial',
129
137
  priority: c.data.priority ?? null,
138
+ milestone: c.data.milestone ?? null,
139
+ // Where its run goes: its own run_mode, else the project's (an autopilot batches by it).
140
+ run_mode: c.data.run_mode ?? config.run_mode,
141
+ // The gates in force (docs/Autonomy-Plan.md, B); `deferred`: its submit closes unplayed.
142
+ gates: gatePolicy(config, c.data),
143
+ deferred: verdictDeferred(config, c.data),
130
144
  ...runningOf(projectDir, String(c.data.id)),
131
145
  }));
132
146
  const design = await designCheck(projectDir);
@@ -136,6 +150,8 @@ export async function audit(projectDir) {
136
150
  units: design.units.length,
137
151
  ready: design.units.filter((u) => u.ready).length,
138
152
  };
153
+ // Where each milestone stands, and what the autopilot builds and stops to play (Plan, D).
154
+ Object.assign(report, await milestoneState(projectDir, ledger, design.units));
139
155
  lintSystems(report, systems);
140
156
  report.first_line = firstLine(report);
141
157