@bonesofspring/ai-rules 0.2.38 → 0.2.39

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 (110) hide show
  1. package/CHANGELOG.md +249 -6
  2. package/package.json +1 -1
  3. package/presets/_shared/ai-local/scripts/derive-gate-signals.mjs +4 -6
  4. package/presets/_shared/ai-local/scripts/efficacy-oracle.mjs +5 -0
  5. package/presets/_shared/ai-local/scripts/lock.mjs +101 -73
  6. package/presets/_shared/ai-local/scripts/rule-improver.mjs +1 -1
  7. package/presets/_shared/ai-local/scripts/run.mjs +13 -4
  8. package/presets/_shared/ai-local/scripts/signals.mjs +38 -8
  9. package/presets/_shared/hooks/chain-team-phases.sh.tmpl +4 -5
  10. package/presets/_shared/hooks/check-preset-update.mjs +1 -1
  11. package/presets/claude/android-kotlin/hooks/chain-team-phases.sh +4 -5
  12. package/presets/claude/android-kotlin/hooks/check-preset-update.mjs +1 -1
  13. package/presets/claude/go/hooks/chain-team-phases.sh +4 -5
  14. package/presets/claude/go/hooks/check-preset-update.mjs +1 -1
  15. package/presets/claude/ios-swift/hooks/chain-team-phases.sh +4 -5
  16. package/presets/claude/ios-swift/hooks/check-preset-update.mjs +1 -1
  17. package/presets/claude/java/hooks/chain-team-phases.sh +4 -5
  18. package/presets/claude/java/hooks/check-preset-update.mjs +1 -1
  19. package/presets/claude/mcp-ts/hooks/chain-team-phases.sh +4 -5
  20. package/presets/claude/mcp-ts/hooks/check-preset-update.mjs +1 -1
  21. package/presets/claude/next/hooks/chain-team-phases.sh +4 -5
  22. package/presets/claude/next/hooks/check-preset-update.mjs +1 -1
  23. package/presets/claude/nuxt/hooks/chain-team-phases.sh +4 -5
  24. package/presets/claude/nuxt/hooks/check-preset-update.mjs +1 -1
  25. package/presets/claude/php-hexagonal/hooks/chain-team-phases.sh +4 -5
  26. package/presets/claude/php-hexagonal/hooks/check-preset-update.mjs +1 -1
  27. package/presets/claude/php-laravel/hooks/chain-team-phases.sh +4 -5
  28. package/presets/claude/php-laravel/hooks/check-preset-update.mjs +1 -1
  29. package/presets/claude/svelte/hooks/chain-team-phases.sh +4 -5
  30. package/presets/claude/svelte/hooks/check-preset-update.mjs +1 -1
  31. package/presets/cursor/android-kotlin/hooks/chain-team-phases.sh +4 -5
  32. package/presets/cursor/android-kotlin/hooks/check-preset-update.mjs +1 -1
  33. package/presets/cursor/go/hooks/chain-team-phases.sh +4 -5
  34. package/presets/cursor/go/hooks/check-preset-update.mjs +1 -1
  35. package/presets/cursor/ios-swift/hooks/chain-team-phases.sh +4 -5
  36. package/presets/cursor/ios-swift/hooks/check-preset-update.mjs +1 -1
  37. package/presets/cursor/java/hooks/chain-team-phases.sh +4 -5
  38. package/presets/cursor/java/hooks/check-preset-update.mjs +1 -1
  39. package/presets/cursor/mcp-ts/hooks/chain-team-phases.sh +4 -5
  40. package/presets/cursor/mcp-ts/hooks/check-preset-update.mjs +1 -1
  41. package/presets/cursor/next/hooks/chain-team-phases.sh +4 -5
  42. package/presets/cursor/next/hooks/check-preset-update.mjs +1 -1
  43. package/presets/cursor/nuxt/hooks/chain-team-phases.sh +4 -5
  44. package/presets/cursor/nuxt/hooks/check-preset-update.mjs +1 -1
  45. package/presets/cursor/php-hexagonal/hooks/chain-team-phases.sh +4 -5
  46. package/presets/cursor/php-hexagonal/hooks/check-preset-update.mjs +1 -1
  47. package/presets/cursor/php-laravel/hooks/chain-team-phases.sh +4 -5
  48. package/presets/cursor/php-laravel/hooks/check-preset-update.mjs +1 -1
  49. package/presets/cursor/svelte/hooks/chain-team-phases.sh +4 -5
  50. package/presets/cursor/svelte/hooks/check-preset-update.mjs +1 -1
  51. package/presets/mavis/android-kotlin/adapter-map.json +1 -1
  52. package/presets/mavis/android-kotlin/hooks/chain-team-phases.sh +4 -5
  53. package/presets/mavis/android-kotlin/hooks/check-preset-update.mjs +1 -1
  54. package/presets/mavis/go/adapter-map.json +1 -1
  55. package/presets/mavis/go/hooks/chain-team-phases.sh +4 -5
  56. package/presets/mavis/go/hooks/check-preset-update.mjs +1 -1
  57. package/presets/mavis/ios-swift/adapter-map.json +1 -1
  58. package/presets/mavis/ios-swift/hooks/chain-team-phases.sh +4 -5
  59. package/presets/mavis/ios-swift/hooks/check-preset-update.mjs +1 -1
  60. package/presets/mavis/java/adapter-map.json +1 -1
  61. package/presets/mavis/java/hooks/chain-team-phases.sh +4 -5
  62. package/presets/mavis/java/hooks/check-preset-update.mjs +1 -1
  63. package/presets/mavis/mcp-ts/adapter-map.json +1 -1
  64. package/presets/mavis/mcp-ts/hooks/chain-team-phases.sh +4 -5
  65. package/presets/mavis/mcp-ts/hooks/check-preset-update.mjs +1 -1
  66. package/presets/mavis/next/adapter-map.json +1 -1
  67. package/presets/mavis/next/hooks/chain-team-phases.sh +4 -5
  68. package/presets/mavis/next/hooks/check-preset-update.mjs +1 -1
  69. package/presets/mavis/nuxt/adapter-map.json +1 -1
  70. package/presets/mavis/nuxt/hooks/chain-team-phases.sh +4 -5
  71. package/presets/mavis/nuxt/hooks/check-preset-update.mjs +1 -1
  72. package/presets/mavis/php-hexagonal/adapter-map.json +1 -1
  73. package/presets/mavis/php-hexagonal/hooks/chain-team-phases.sh +4 -5
  74. package/presets/mavis/php-hexagonal/hooks/check-preset-update.mjs +1 -1
  75. package/presets/mavis/php-laravel/adapter-map.json +1 -1
  76. package/presets/mavis/php-laravel/hooks/chain-team-phases.sh +4 -5
  77. package/presets/mavis/php-laravel/hooks/check-preset-update.mjs +1 -1
  78. package/presets/mavis/svelte/adapter-map.json +1 -1
  79. package/presets/mavis/svelte/hooks/chain-team-phases.sh +4 -5
  80. package/presets/mavis/svelte/hooks/check-preset-update.mjs +1 -1
  81. package/presets/opencode/android-kotlin/adapter-map.json +1 -1
  82. package/presets/opencode/android-kotlin/hooks/chain-team-phases.sh +4 -5
  83. package/presets/opencode/android-kotlin/hooks/check-preset-update.mjs +1 -1
  84. package/presets/opencode/go/adapter-map.json +1 -1
  85. package/presets/opencode/go/hooks/chain-team-phases.sh +4 -5
  86. package/presets/opencode/go/hooks/check-preset-update.mjs +1 -1
  87. package/presets/opencode/ios-swift/adapter-map.json +1 -1
  88. package/presets/opencode/ios-swift/hooks/chain-team-phases.sh +4 -5
  89. package/presets/opencode/ios-swift/hooks/check-preset-update.mjs +1 -1
  90. package/presets/opencode/java/adapter-map.json +1 -1
  91. package/presets/opencode/java/hooks/chain-team-phases.sh +4 -5
  92. package/presets/opencode/java/hooks/check-preset-update.mjs +1 -1
  93. package/presets/opencode/mcp-ts/adapter-map.json +1 -1
  94. package/presets/opencode/mcp-ts/hooks/chain-team-phases.sh +4 -5
  95. package/presets/opencode/mcp-ts/hooks/check-preset-update.mjs +1 -1
  96. package/presets/opencode/next/adapter-map.json +1 -1
  97. package/presets/opencode/next/hooks/chain-team-phases.sh +4 -5
  98. package/presets/opencode/next/hooks/check-preset-update.mjs +1 -1
  99. package/presets/opencode/nuxt/adapter-map.json +1 -1
  100. package/presets/opencode/nuxt/hooks/chain-team-phases.sh +4 -5
  101. package/presets/opencode/nuxt/hooks/check-preset-update.mjs +1 -1
  102. package/presets/opencode/php-hexagonal/adapter-map.json +1 -1
  103. package/presets/opencode/php-hexagonal/hooks/chain-team-phases.sh +4 -5
  104. package/presets/opencode/php-hexagonal/hooks/check-preset-update.mjs +1 -1
  105. package/presets/opencode/php-laravel/adapter-map.json +1 -1
  106. package/presets/opencode/php-laravel/hooks/chain-team-phases.sh +4 -5
  107. package/presets/opencode/php-laravel/hooks/check-preset-update.mjs +1 -1
  108. package/presets/opencode/svelte/adapter-map.json +1 -1
  109. package/presets/opencode/svelte/hooks/chain-team-phases.sh +4 -5
  110. package/presets/opencode/svelte/hooks/check-preset-update.mjs +1 -1
@@ -6,10 +6,10 @@
6
6
  * (>=2 distinct tasks → edit; >=3 → new rule). See
7
7
  * `.ai.local/team/tasks/self-learning-agents/architecture.md` §1.
8
8
  *
9
- * Concurrency: writes to `.ai.local/signals.jsonl` go through the shared
10
- * ownership-token advisory lock (`.ai.local/scripts/lock.mjs`) and a
11
- * temp-file + atomic rename, mirroring `waitForMetricsLock` in
12
- * `.opencode/hooks/chain-team-phases.sh`. The store is never partially written.
9
+ * Concurrency: writes to `.ai.local/signals.jsonl` go through the exclusive
10
+ * lock (`.ai.local/scripts/lock.mjs`) and a temp-file + atomic rename. The
11
+ * store is never partially written. Derived rows re-check `(slug, id, kind)`
12
+ * under that lock (`appendSignal` `dedup`).
13
13
  */
14
14
 
15
15
  import fs from 'node:fs';
@@ -41,6 +41,29 @@ export const SIGNATURE_RE = new RegExp(`^(?:${KINDS.join('|')}):(?=[a-z0-9-]{2,6
41
41
  const KEBAB_RE = ISSUE_BODY_RE;
42
42
  const SIGNAL_KEYS = ['id', 'at', 'slug', 'agent', 'kind', 'severity', 'confidence', 'signature', 'target', 'stem', 'source', 'status'];
43
43
 
44
+ /** A parsed journal line that can be field-accessed. `JSON.parse('null')` is not one. */
45
+ export function isSignalRecord(value) {
46
+ return value !== null && typeof value === 'object' && !Array.isArray(value);
47
+ }
48
+
49
+ /** Identity used to dedup a derived gate signal: one row per slug + attempt + kind. */
50
+ export function signalIdentityKey(signal) {
51
+ return `${signal.slug}\u0000${signal.id}\u0000${signal.kind}`;
52
+ }
53
+
54
+ function journalHasIdentity(raw, key) {
55
+ for (const line of raw.split('\n')) {
56
+ const trimmed = line.trim();
57
+ if (trimmed === '') continue;
58
+ let value;
59
+ try { value = JSON.parse(trimmed); } catch { continue; }
60
+ if (!isSignalRecord(value)) continue;
61
+ if (typeof value.slug !== 'string' || typeof value.id !== 'string' || typeof value.kind !== 'string') continue;
62
+ if (signalIdentityKey(value) === key) return true;
63
+ }
64
+ return false;
65
+ }
66
+
44
67
  function requireString(signal, key) {
45
68
  if (typeof signal[key] !== 'string' || signal[key].length === 0) {
46
69
  throw new Error(`"${key}" must be a non-empty string`);
@@ -86,10 +109,13 @@ export function validateSignal(signal) {
86
109
  }
87
110
 
88
111
  /**
89
- * Append one validated signal to the JSON-Lines store under the advisory lock.
90
- * Returns `{ path, signal }`; throws on an invalid signal or lock timeout.
112
+ * Append one validated signal to the JSON-Lines store under the exclusive lock.
113
+ * Returns `{ path, signal, appended }`. `appended` is false only when `dedup`
114
+ * is set and the journal already contains the same `(slug, id, kind)` — that
115
+ * check runs after the lock is held, so two overlapping derivations cannot
116
+ * both append. Throws on an invalid signal or lock timeout.
91
117
  */
92
- export function appendSignal(signal, { signalsPath = DEFAULT_SIGNALS_PATH } = {}) {
118
+ export function appendSignal(signal, { signalsPath = DEFAULT_SIGNALS_PATH, dedup = false } = {}) {
93
119
  validateSignal(signal);
94
120
  const lockPath = `${signalsPath}.lock`;
95
121
  const token = acquireLock(lockPath);
@@ -100,6 +126,9 @@ export function appendSignal(signal, { signalsPath = DEFAULT_SIGNALS_PATH } = {}
100
126
  } catch (error) {
101
127
  if (!error || error.code !== 'ENOENT') throw error;
102
128
  }
129
+ if (dedup && journalHasIdentity(existing, signalIdentityKey(signal))) {
130
+ return { path: signalsPath, signal, appended: false };
131
+ }
103
132
  const temporary = `${signalsPath}.${process.pid}.${Date.now()}.tmp`;
104
133
  const fd = fs.openSync(temporary, 'w');
105
134
  try {
@@ -109,7 +138,7 @@ export function appendSignal(signal, { signalsPath = DEFAULT_SIGNALS_PATH } = {}
109
138
  fs.closeSync(fd);
110
139
  }
111
140
  fs.renameSync(temporary, signalsPath);
112
- return { path: signalsPath, signal };
141
+ return { path: signalsPath, signal, appended: true };
113
142
  } finally {
114
143
  releaseLock(lockPath, token);
115
144
  }
@@ -138,6 +167,7 @@ export function markSignalsApplied(signature, { signalsPath = DEFAULT_SIGNALS_PA
138
167
  if (line.trim() === '') return line;
139
168
  let signal;
140
169
  try { signal = JSON.parse(line); } catch { return line; }
170
+ if (!isSignalRecord(signal)) return line;
141
171
  if (
142
172
  signal.signature === signature
143
173
  && (signal.status === 'proposed' || signal.status === 'staged')
@@ -420,6 +420,10 @@ function completePipeline(statusPatch) {
420
420
  out(`Pipeline blocked for "${slug}": .ai.local/pipeline-gates.json requireArtifacts missing completed receipt(s): ${missing.join(', ')}.`);
421
421
  process.exit(0);
422
422
  }
423
+ // task_completed is written only on this branch. A missing receipt blocks
424
+ // above and must not be counted as a finished task.
425
+ status.state = 'completed';
426
+ completeTaskMetrics();
423
427
  writeStatus(statusPatch);
424
428
  out(`Pipeline complete for "${slug}". Run /technical-retro ${slug}.`);
425
429
  process.exit(0);
@@ -813,7 +817,6 @@ if (hookInput.action === 'end_human_gate') {
813
817
  if (dispatchReadyWave()) process.exit(0);
814
818
  if (pendingStepIndexes().length === 0) {
815
819
  status.state = 'completed';
816
- completeTaskMetrics();
817
820
  completePipeline({ pipelineIndex: resumeSteps.length, phase: 'done', state: 'completed', currentAgent: null, awaitingHumanGate: false });
818
821
  }
819
822
  out(noProgressNotice());
@@ -839,7 +842,6 @@ if (hookInput.action === 'end_human_gate') {
839
842
  // Gate on the final step: no executable step remains. Complete the
840
843
  // pipeline instead of leaving it in_progress forever.
841
844
  status.state = 'completed';
842
- completeTaskMetrics();
843
845
  completePipeline({
844
846
  pipelineIndex: resumeSteps.length,
845
847
  phase: 'done',
@@ -1150,7 +1152,6 @@ if (waveIndexes) {
1150
1152
  process.exit(0);
1151
1153
  }
1152
1154
  if (pendingStepIndexes().length === 0) {
1153
- completeTaskMetrics();
1154
1155
  completePipeline({ pipelineIndex: steps.length, phase: 'done', state: 'completed', currentAgent: null, awaitingHumanGate: false });
1155
1156
  }
1156
1157
  out(noProgressNotice());
@@ -1264,7 +1265,6 @@ if (isGraphMode()) {
1264
1265
  }
1265
1266
  if (dispatchReadyWave()) process.exit(0);
1266
1267
  if (pendingStepIndexes().length === 0) {
1267
- completeTaskMetrics();
1268
1268
  completePipeline({ pipelineIndex: steps.length, phase: 'done', state: 'completed', currentAgent: null, awaitingHumanGate: false });
1269
1269
  }
1270
1270
  out(noProgressNotice());
@@ -1273,7 +1273,6 @@ if (isGraphMode()) {
1273
1273
 
1274
1274
  const next = findNextExecutableStep(steps, idx + 1, taskDir);
1275
1275
  if (!next) {
1276
- completeTaskMetrics();
1277
1276
  completePipeline({
1278
1277
  pipelineIndex: steps.length,
1279
1278
  phase: 'done',
@@ -9,7 +9,7 @@ import { fileURLToPath } from 'node:url';
9
9
 
10
10
  export const PACKAGE_NAME = '@bonesofspring/ai-rules';
11
11
  export const REGISTRY_URL = 'https://registry.npmjs.org/@bonesofspring/ai-rules/latest';
12
- export const CACHE_TTL_MS = 12 * 60 * 60 * 1000;
12
+ export const CACHE_TTL_MS = 60 * 60 * 1000;
13
13
  export const TOOL_ROOTS = ['.cursor', '.claude', '.mavis', '.opencode'];
14
14
 
15
15
  const RELEASE_VERSION = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/;
@@ -457,6 +457,10 @@ function completePipeline(statusPatch) {
457
457
  out(`Pipeline blocked for "${slug}": .ai.local/pipeline-gates.json requireArtifacts missing completed receipt(s): ${missing.join(', ')}.`);
458
458
  process.exit(0);
459
459
  }
460
+ // task_completed is written only on this branch. A missing receipt blocks
461
+ // above and must not be counted as a finished task.
462
+ status.state = 'completed';
463
+ completeTaskMetrics();
460
464
  writeStatus(statusPatch);
461
465
  out(`Pipeline complete for "${slug}". Run /technical-retro ${slug}.`);
462
466
  process.exit(0);
@@ -972,7 +976,6 @@ if (hookInput.action === 'end_human_gate') {
972
976
  if (dispatchReadyWave()) process.exit(0);
973
977
  if (pendingStepIndexes().length === 0) {
974
978
  status.state = 'completed';
975
- completeTaskMetrics();
976
979
  completePipeline({ pipelineIndex: resumeSteps.length, phase: 'done', state: 'completed', currentAgent: null, awaitingHumanGate: false });
977
980
  }
978
981
  out(noProgressNotice());
@@ -998,7 +1001,6 @@ if (hookInput.action === 'end_human_gate') {
998
1001
  // Gate on the final step: no executable step remains. Complete the
999
1002
  // pipeline instead of leaving it in_progress forever.
1000
1003
  status.state = 'completed';
1001
- completeTaskMetrics();
1002
1004
  completePipeline({
1003
1005
  pipelineIndex: resumeSteps.length,
1004
1006
  phase: 'done',
@@ -1309,7 +1311,6 @@ if (waveIndexes) {
1309
1311
  process.exit(0);
1310
1312
  }
1311
1313
  if (pendingStepIndexes().length === 0) {
1312
- completeTaskMetrics();
1313
1314
  completePipeline({ pipelineIndex: steps.length, phase: 'done', state: 'completed', currentAgent: null, awaitingHumanGate: false });
1314
1315
  }
1315
1316
  out(noProgressNotice());
@@ -1423,7 +1424,6 @@ if (isGraphMode()) {
1423
1424
  }
1424
1425
  if (dispatchReadyWave()) process.exit(0);
1425
1426
  if (pendingStepIndexes().length === 0) {
1426
- completeTaskMetrics();
1427
1427
  completePipeline({ pipelineIndex: steps.length, phase: 'done', state: 'completed', currentAgent: null, awaitingHumanGate: false });
1428
1428
  }
1429
1429
  out(noProgressNotice());
@@ -1432,7 +1432,6 @@ if (isGraphMode()) {
1432
1432
 
1433
1433
  const next = findNextExecutableStep(steps, idx + 1, taskDir);
1434
1434
  if (!next) {
1435
- completeTaskMetrics();
1436
1435
  completePipeline({
1437
1436
  pipelineIndex: steps.length,
1438
1437
  phase: 'done',
@@ -9,7 +9,7 @@ import { fileURLToPath } from 'node:url';
9
9
 
10
10
  export const PACKAGE_NAME = '@bonesofspring/ai-rules';
11
11
  export const REGISTRY_URL = 'https://registry.npmjs.org/@bonesofspring/ai-rules/latest';
12
- export const CACHE_TTL_MS = 12 * 60 * 60 * 1000;
12
+ export const CACHE_TTL_MS = 60 * 60 * 1000;
13
13
  export const TOOL_ROOTS = ['.cursor', '.claude', '.mavis', '.opencode'];
14
14
 
15
15
  const RELEASE_VERSION = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/;
@@ -456,6 +456,10 @@ function completePipeline(statusPatch) {
456
456
  out(`Pipeline blocked for "${slug}": .ai.local/pipeline-gates.json requireArtifacts missing completed receipt(s): ${missing.join(', ')}.`);
457
457
  process.exit(0);
458
458
  }
459
+ // task_completed is written only on this branch. A missing receipt blocks
460
+ // above and must not be counted as a finished task.
461
+ status.state = 'completed';
462
+ completeTaskMetrics();
459
463
  writeStatus(statusPatch);
460
464
  out(`Pipeline complete for "${slug}". Run /technical-retro ${slug}.`);
461
465
  process.exit(0);
@@ -967,7 +971,6 @@ if (hookInput.action === 'end_human_gate') {
967
971
  if (dispatchReadyWave()) process.exit(0);
968
972
  if (pendingStepIndexes().length === 0) {
969
973
  status.state = 'completed';
970
- completeTaskMetrics();
971
974
  completePipeline({ pipelineIndex: resumeSteps.length, phase: 'done', state: 'completed', currentAgent: null, awaitingHumanGate: false });
972
975
  }
973
976
  out(noProgressNotice());
@@ -993,7 +996,6 @@ if (hookInput.action === 'end_human_gate') {
993
996
  // Gate on the final step: no executable step remains. Complete the
994
997
  // pipeline instead of leaving it in_progress forever.
995
998
  status.state = 'completed';
996
- completeTaskMetrics();
997
999
  completePipeline({
998
1000
  pipelineIndex: resumeSteps.length,
999
1001
  phase: 'done',
@@ -1304,7 +1306,6 @@ if (waveIndexes) {
1304
1306
  process.exit(0);
1305
1307
  }
1306
1308
  if (pendingStepIndexes().length === 0) {
1307
- completeTaskMetrics();
1308
1309
  completePipeline({ pipelineIndex: steps.length, phase: 'done', state: 'completed', currentAgent: null, awaitingHumanGate: false });
1309
1310
  }
1310
1311
  out(noProgressNotice());
@@ -1418,7 +1419,6 @@ if (isGraphMode()) {
1418
1419
  }
1419
1420
  if (dispatchReadyWave()) process.exit(0);
1420
1421
  if (pendingStepIndexes().length === 0) {
1421
- completeTaskMetrics();
1422
1422
  completePipeline({ pipelineIndex: steps.length, phase: 'done', state: 'completed', currentAgent: null, awaitingHumanGate: false });
1423
1423
  }
1424
1424
  out(noProgressNotice());
@@ -1427,7 +1427,6 @@ if (isGraphMode()) {
1427
1427
 
1428
1428
  const next = findNextExecutableStep(steps, idx + 1, taskDir);
1429
1429
  if (!next) {
1430
- completeTaskMetrics();
1431
1430
  completePipeline({
1432
1431
  pipelineIndex: steps.length,
1433
1432
  phase: 'done',
@@ -9,7 +9,7 @@ import { fileURLToPath } from 'node:url';
9
9
 
10
10
  export const PACKAGE_NAME = '@bonesofspring/ai-rules';
11
11
  export const REGISTRY_URL = 'https://registry.npmjs.org/@bonesofspring/ai-rules/latest';
12
- export const CACHE_TTL_MS = 12 * 60 * 60 * 1000;
12
+ export const CACHE_TTL_MS = 60 * 60 * 1000;
13
13
  export const TOOL_ROOTS = ['.cursor', '.claude', '.mavis', '.opencode'];
14
14
 
15
15
  const RELEASE_VERSION = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/;
@@ -457,6 +457,10 @@ function completePipeline(statusPatch) {
457
457
  out(`Pipeline blocked for "${slug}": .ai.local/pipeline-gates.json requireArtifacts missing completed receipt(s): ${missing.join(', ')}.`);
458
458
  process.exit(0);
459
459
  }
460
+ // task_completed is written only on this branch. A missing receipt blocks
461
+ // above and must not be counted as a finished task.
462
+ status.state = 'completed';
463
+ completeTaskMetrics();
460
464
  writeStatus(statusPatch);
461
465
  out(`Pipeline complete for "${slug}". Run /technical-retro ${slug}.`);
462
466
  process.exit(0);
@@ -972,7 +976,6 @@ if (hookInput.action === 'end_human_gate') {
972
976
  if (dispatchReadyWave()) process.exit(0);
973
977
  if (pendingStepIndexes().length === 0) {
974
978
  status.state = 'completed';
975
- completeTaskMetrics();
976
979
  completePipeline({ pipelineIndex: resumeSteps.length, phase: 'done', state: 'completed', currentAgent: null, awaitingHumanGate: false });
977
980
  }
978
981
  out(noProgressNotice());
@@ -998,7 +1001,6 @@ if (hookInput.action === 'end_human_gate') {
998
1001
  // Gate on the final step: no executable step remains. Complete the
999
1002
  // pipeline instead of leaving it in_progress forever.
1000
1003
  status.state = 'completed';
1001
- completeTaskMetrics();
1002
1004
  completePipeline({
1003
1005
  pipelineIndex: resumeSteps.length,
1004
1006
  phase: 'done',
@@ -1309,7 +1311,6 @@ if (waveIndexes) {
1309
1311
  process.exit(0);
1310
1312
  }
1311
1313
  if (pendingStepIndexes().length === 0) {
1312
- completeTaskMetrics();
1313
1314
  completePipeline({ pipelineIndex: steps.length, phase: 'done', state: 'completed', currentAgent: null, awaitingHumanGate: false });
1314
1315
  }
1315
1316
  out(noProgressNotice());
@@ -1423,7 +1424,6 @@ if (isGraphMode()) {
1423
1424
  }
1424
1425
  if (dispatchReadyWave()) process.exit(0);
1425
1426
  if (pendingStepIndexes().length === 0) {
1426
- completeTaskMetrics();
1427
1427
  completePipeline({ pipelineIndex: steps.length, phase: 'done', state: 'completed', currentAgent: null, awaitingHumanGate: false });
1428
1428
  }
1429
1429
  out(noProgressNotice());
@@ -1432,7 +1432,6 @@ if (isGraphMode()) {
1432
1432
 
1433
1433
  const next = findNextExecutableStep(steps, idx + 1, taskDir);
1434
1434
  if (!next) {
1435
- completeTaskMetrics();
1436
1435
  completePipeline({
1437
1436
  pipelineIndex: steps.length,
1438
1437
  phase: 'done',
@@ -9,7 +9,7 @@ import { fileURLToPath } from 'node:url';
9
9
 
10
10
  export const PACKAGE_NAME = '@bonesofspring/ai-rules';
11
11
  export const REGISTRY_URL = 'https://registry.npmjs.org/@bonesofspring/ai-rules/latest';
12
- export const CACHE_TTL_MS = 12 * 60 * 60 * 1000;
12
+ export const CACHE_TTL_MS = 60 * 60 * 1000;
13
13
  export const TOOL_ROOTS = ['.cursor', '.claude', '.mavis', '.opencode'];
14
14
 
15
15
  const RELEASE_VERSION = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/;
@@ -456,6 +456,10 @@ function completePipeline(statusPatch) {
456
456
  out(`Pipeline blocked for "${slug}": .ai.local/pipeline-gates.json requireArtifacts missing completed receipt(s): ${missing.join(', ')}.`);
457
457
  process.exit(0);
458
458
  }
459
+ // task_completed is written only on this branch. A missing receipt blocks
460
+ // above and must not be counted as a finished task.
461
+ status.state = 'completed';
462
+ completeTaskMetrics();
459
463
  writeStatus(statusPatch);
460
464
  out(`Pipeline complete for "${slug}". Run /technical-retro ${slug}.`);
461
465
  process.exit(0);
@@ -967,7 +971,6 @@ if (hookInput.action === 'end_human_gate') {
967
971
  if (dispatchReadyWave()) process.exit(0);
968
972
  if (pendingStepIndexes().length === 0) {
969
973
  status.state = 'completed';
970
- completeTaskMetrics();
971
974
  completePipeline({ pipelineIndex: resumeSteps.length, phase: 'done', state: 'completed', currentAgent: null, awaitingHumanGate: false });
972
975
  }
973
976
  out(noProgressNotice());
@@ -993,7 +996,6 @@ if (hookInput.action === 'end_human_gate') {
993
996
  // Gate on the final step: no executable step remains. Complete the
994
997
  // pipeline instead of leaving it in_progress forever.
995
998
  status.state = 'completed';
996
- completeTaskMetrics();
997
999
  completePipeline({
998
1000
  pipelineIndex: resumeSteps.length,
999
1001
  phase: 'done',
@@ -1304,7 +1306,6 @@ if (waveIndexes) {
1304
1306
  process.exit(0);
1305
1307
  }
1306
1308
  if (pendingStepIndexes().length === 0) {
1307
- completeTaskMetrics();
1308
1309
  completePipeline({ pipelineIndex: steps.length, phase: 'done', state: 'completed', currentAgent: null, awaitingHumanGate: false });
1309
1310
  }
1310
1311
  out(noProgressNotice());
@@ -1418,7 +1419,6 @@ if (isGraphMode()) {
1418
1419
  }
1419
1420
  if (dispatchReadyWave()) process.exit(0);
1420
1421
  if (pendingStepIndexes().length === 0) {
1421
- completeTaskMetrics();
1422
1422
  completePipeline({ pipelineIndex: steps.length, phase: 'done', state: 'completed', currentAgent: null, awaitingHumanGate: false });
1423
1423
  }
1424
1424
  out(noProgressNotice());
@@ -1427,7 +1427,6 @@ if (isGraphMode()) {
1427
1427
 
1428
1428
  const next = findNextExecutableStep(steps, idx + 1, taskDir);
1429
1429
  if (!next) {
1430
- completeTaskMetrics();
1431
1430
  completePipeline({
1432
1431
  pipelineIndex: steps.length,
1433
1432
  phase: 'done',
@@ -9,7 +9,7 @@ import { fileURLToPath } from 'node:url';
9
9
 
10
10
  export const PACKAGE_NAME = '@bonesofspring/ai-rules';
11
11
  export const REGISTRY_URL = 'https://registry.npmjs.org/@bonesofspring/ai-rules/latest';
12
- export const CACHE_TTL_MS = 12 * 60 * 60 * 1000;
12
+ export const CACHE_TTL_MS = 60 * 60 * 1000;
13
13
  export const TOOL_ROOTS = ['.cursor', '.claude', '.mavis', '.opencode'];
14
14
 
15
15
  const RELEASE_VERSION = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/;
@@ -444,6 +444,10 @@ function completePipeline(statusPatch) {
444
444
  out(`Pipeline blocked for "${slug}": .ai.local/pipeline-gates.json requireArtifacts missing completed receipt(s): ${missing.join(', ')}.`);
445
445
  process.exit(0);
446
446
  }
447
+ // task_completed is written only on this branch. A missing receipt blocks
448
+ // above and must not be counted as a finished task.
449
+ status.state = 'completed';
450
+ completeTaskMetrics();
447
451
  writeStatus(statusPatch);
448
452
  out(`Pipeline complete for "${slug}". Run /technical-retro ${slug}.`);
449
453
  process.exit(0);
@@ -914,7 +918,6 @@ if (hookInput.action === 'end_human_gate') {
914
918
  if (dispatchReadyWave()) process.exit(0);
915
919
  if (pendingStepIndexes().length === 0) {
916
920
  status.state = 'completed';
917
- completeTaskMetrics();
918
921
  completePipeline({ pipelineIndex: resumeSteps.length, phase: 'done', state: 'completed', currentAgent: null, awaitingHumanGate: false });
919
922
  }
920
923
  out(noProgressNotice());
@@ -940,7 +943,6 @@ if (hookInput.action === 'end_human_gate') {
940
943
  // Gate on the final step: no executable step remains. Complete the
941
944
  // pipeline instead of leaving it in_progress forever.
942
945
  status.state = 'completed';
943
- completeTaskMetrics();
944
946
  completePipeline({
945
947
  pipelineIndex: resumeSteps.length,
946
948
  phase: 'done',
@@ -1251,7 +1253,6 @@ if (waveIndexes) {
1251
1253
  process.exit(0);
1252
1254
  }
1253
1255
  if (pendingStepIndexes().length === 0) {
1254
- completeTaskMetrics();
1255
1256
  completePipeline({ pipelineIndex: steps.length, phase: 'done', state: 'completed', currentAgent: null, awaitingHumanGate: false });
1256
1257
  }
1257
1258
  out(noProgressNotice());
@@ -1365,7 +1366,6 @@ if (isGraphMode()) {
1365
1366
  }
1366
1367
  if (dispatchReadyWave()) process.exit(0);
1367
1368
  if (pendingStepIndexes().length === 0) {
1368
- completeTaskMetrics();
1369
1369
  completePipeline({ pipelineIndex: steps.length, phase: 'done', state: 'completed', currentAgent: null, awaitingHumanGate: false });
1370
1370
  }
1371
1371
  out(noProgressNotice());
@@ -1374,7 +1374,6 @@ if (isGraphMode()) {
1374
1374
 
1375
1375
  const next = findNextExecutableStep(steps, idx + 1, taskDir);
1376
1376
  if (!next) {
1377
- completeTaskMetrics();
1378
1377
  completePipeline({
1379
1378
  pipelineIndex: steps.length,
1380
1379
  phase: 'done',
@@ -9,7 +9,7 @@ import { fileURLToPath } from 'node:url';
9
9
 
10
10
  export const PACKAGE_NAME = '@bonesofspring/ai-rules';
11
11
  export const REGISTRY_URL = 'https://registry.npmjs.org/@bonesofspring/ai-rules/latest';
12
- export const CACHE_TTL_MS = 12 * 60 * 60 * 1000;
12
+ export const CACHE_TTL_MS = 60 * 60 * 1000;
13
13
  export const TOOL_ROOTS = ['.cursor', '.claude', '.mavis', '.opencode'];
14
14
 
15
15
  const RELEASE_VERSION = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/;
@@ -457,6 +457,10 @@ function completePipeline(statusPatch) {
457
457
  out(`Pipeline blocked for "${slug}": .ai.local/pipeline-gates.json requireArtifacts missing completed receipt(s): ${missing.join(', ')}.`);
458
458
  process.exit(0);
459
459
  }
460
+ // task_completed is written only on this branch. A missing receipt blocks
461
+ // above and must not be counted as a finished task.
462
+ status.state = 'completed';
463
+ completeTaskMetrics();
460
464
  writeStatus(statusPatch);
461
465
  out(`Pipeline complete for "${slug}". Run /technical-retro ${slug}.`);
462
466
  process.exit(0);
@@ -970,7 +974,6 @@ if (hookInput.action === 'end_human_gate') {
970
974
  if (dispatchReadyWave()) process.exit(0);
971
975
  if (pendingStepIndexes().length === 0) {
972
976
  status.state = 'completed';
973
- completeTaskMetrics();
974
977
  completePipeline({ pipelineIndex: resumeSteps.length, phase: 'done', state: 'completed', currentAgent: null, awaitingHumanGate: false });
975
978
  }
976
979
  out(noProgressNotice());
@@ -996,7 +999,6 @@ if (hookInput.action === 'end_human_gate') {
996
999
  // Gate on the final step: no executable step remains. Complete the
997
1000
  // pipeline instead of leaving it in_progress forever.
998
1001
  status.state = 'completed';
999
- completeTaskMetrics();
1000
1002
  completePipeline({
1001
1003
  pipelineIndex: resumeSteps.length,
1002
1004
  phase: 'done',
@@ -1307,7 +1309,6 @@ if (waveIndexes) {
1307
1309
  process.exit(0);
1308
1310
  }
1309
1311
  if (pendingStepIndexes().length === 0) {
1310
- completeTaskMetrics();
1311
1312
  completePipeline({ pipelineIndex: steps.length, phase: 'done', state: 'completed', currentAgent: null, awaitingHumanGate: false });
1312
1313
  }
1313
1314
  out(noProgressNotice());
@@ -1421,7 +1422,6 @@ if (isGraphMode()) {
1421
1422
  }
1422
1423
  if (dispatchReadyWave()) process.exit(0);
1423
1424
  if (pendingStepIndexes().length === 0) {
1424
- completeTaskMetrics();
1425
1425
  completePipeline({ pipelineIndex: steps.length, phase: 'done', state: 'completed', currentAgent: null, awaitingHumanGate: false });
1426
1426
  }
1427
1427
  out(noProgressNotice());
@@ -1430,7 +1430,6 @@ if (isGraphMode()) {
1430
1430
 
1431
1431
  const next = findNextExecutableStep(steps, idx + 1, taskDir);
1432
1432
  if (!next) {
1433
- completeTaskMetrics();
1434
1433
  completePipeline({
1435
1434
  pipelineIndex: steps.length,
1436
1435
  phase: 'done',
@@ -9,7 +9,7 @@ import { fileURLToPath } from 'node:url';
9
9
 
10
10
  export const PACKAGE_NAME = '@bonesofspring/ai-rules';
11
11
  export const REGISTRY_URL = 'https://registry.npmjs.org/@bonesofspring/ai-rules/latest';
12
- export const CACHE_TTL_MS = 12 * 60 * 60 * 1000;
12
+ export const CACHE_TTL_MS = 60 * 60 * 1000;
13
13
  export const TOOL_ROOTS = ['.cursor', '.claude', '.mavis', '.opencode'];
14
14
 
15
15
  const RELEASE_VERSION = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/;
@@ -457,6 +457,10 @@ function completePipeline(statusPatch) {
457
457
  out(`Pipeline blocked for "${slug}": .ai.local/pipeline-gates.json requireArtifacts missing completed receipt(s): ${missing.join(', ')}.`);
458
458
  process.exit(0);
459
459
  }
460
+ // task_completed is written only on this branch. A missing receipt blocks
461
+ // above and must not be counted as a finished task.
462
+ status.state = 'completed';
463
+ completeTaskMetrics();
460
464
  writeStatus(statusPatch);
461
465
  out(`Pipeline complete for "${slug}". Run /technical-retro ${slug}.`);
462
466
  process.exit(0);
@@ -970,7 +974,6 @@ if (hookInput.action === 'end_human_gate') {
970
974
  if (dispatchReadyWave()) process.exit(0);
971
975
  if (pendingStepIndexes().length === 0) {
972
976
  status.state = 'completed';
973
- completeTaskMetrics();
974
977
  completePipeline({ pipelineIndex: resumeSteps.length, phase: 'done', state: 'completed', currentAgent: null, awaitingHumanGate: false });
975
978
  }
976
979
  out(noProgressNotice());
@@ -996,7 +999,6 @@ if (hookInput.action === 'end_human_gate') {
996
999
  // Gate on the final step: no executable step remains. Complete the
997
1000
  // pipeline instead of leaving it in_progress forever.
998
1001
  status.state = 'completed';
999
- completeTaskMetrics();
1000
1002
  completePipeline({
1001
1003
  pipelineIndex: resumeSteps.length,
1002
1004
  phase: 'done',
@@ -1307,7 +1309,6 @@ if (waveIndexes) {
1307
1309
  process.exit(0);
1308
1310
  }
1309
1311
  if (pendingStepIndexes().length === 0) {
1310
- completeTaskMetrics();
1311
1312
  completePipeline({ pipelineIndex: steps.length, phase: 'done', state: 'completed', currentAgent: null, awaitingHumanGate: false });
1312
1313
  }
1313
1314
  out(noProgressNotice());
@@ -1421,7 +1422,6 @@ if (isGraphMode()) {
1421
1422
  }
1422
1423
  if (dispatchReadyWave()) process.exit(0);
1423
1424
  if (pendingStepIndexes().length === 0) {
1424
- completeTaskMetrics();
1425
1425
  completePipeline({ pipelineIndex: steps.length, phase: 'done', state: 'completed', currentAgent: null, awaitingHumanGate: false });
1426
1426
  }
1427
1427
  out(noProgressNotice());
@@ -1430,7 +1430,6 @@ if (isGraphMode()) {
1430
1430
 
1431
1431
  const next = findNextExecutableStep(steps, idx + 1, taskDir);
1432
1432
  if (!next) {
1433
- completeTaskMetrics();
1434
1433
  completePipeline({
1435
1434
  pipelineIndex: steps.length,
1436
1435
  phase: 'done',
@@ -9,7 +9,7 @@ import { fileURLToPath } from 'node:url';
9
9
 
10
10
  export const PACKAGE_NAME = '@bonesofspring/ai-rules';
11
11
  export const REGISTRY_URL = 'https://registry.npmjs.org/@bonesofspring/ai-rules/latest';
12
- export const CACHE_TTL_MS = 12 * 60 * 60 * 1000;
12
+ export const CACHE_TTL_MS = 60 * 60 * 1000;
13
13
  export const TOOL_ROOTS = ['.cursor', '.claude', '.mavis', '.opencode'];
14
14
 
15
15
  const RELEASE_VERSION = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/;
@@ -457,6 +457,10 @@ function completePipeline(statusPatch) {
457
457
  out(`Pipeline blocked for "${slug}": .ai.local/pipeline-gates.json requireArtifacts missing completed receipt(s): ${missing.join(', ')}.`);
458
458
  process.exit(0);
459
459
  }
460
+ // task_completed is written only on this branch. A missing receipt blocks
461
+ // above and must not be counted as a finished task.
462
+ status.state = 'completed';
463
+ completeTaskMetrics();
460
464
  writeStatus(statusPatch);
461
465
  out(`Pipeline complete for "${slug}". Run /technical-retro ${slug}.`);
462
466
  process.exit(0);
@@ -968,7 +972,6 @@ if (hookInput.action === 'end_human_gate') {
968
972
  if (dispatchReadyWave()) process.exit(0);
969
973
  if (pendingStepIndexes().length === 0) {
970
974
  status.state = 'completed';
971
- completeTaskMetrics();
972
975
  completePipeline({ pipelineIndex: resumeSteps.length, phase: 'done', state: 'completed', currentAgent: null, awaitingHumanGate: false });
973
976
  }
974
977
  out(noProgressNotice());
@@ -994,7 +997,6 @@ if (hookInput.action === 'end_human_gate') {
994
997
  // Gate on the final step: no executable step remains. Complete the
995
998
  // pipeline instead of leaving it in_progress forever.
996
999
  status.state = 'completed';
997
- completeTaskMetrics();
998
1000
  completePipeline({
999
1001
  pipelineIndex: resumeSteps.length,
1000
1002
  phase: 'done',
@@ -1305,7 +1307,6 @@ if (waveIndexes) {
1305
1307
  process.exit(0);
1306
1308
  }
1307
1309
  if (pendingStepIndexes().length === 0) {
1308
- completeTaskMetrics();
1309
1310
  completePipeline({ pipelineIndex: steps.length, phase: 'done', state: 'completed', currentAgent: null, awaitingHumanGate: false });
1310
1311
  }
1311
1312
  out(noProgressNotice());
@@ -1419,7 +1420,6 @@ if (isGraphMode()) {
1419
1420
  }
1420
1421
  if (dispatchReadyWave()) process.exit(0);
1421
1422
  if (pendingStepIndexes().length === 0) {
1422
- completeTaskMetrics();
1423
1423
  completePipeline({ pipelineIndex: steps.length, phase: 'done', state: 'completed', currentAgent: null, awaitingHumanGate: false });
1424
1424
  }
1425
1425
  out(noProgressNotice());
@@ -1428,7 +1428,6 @@ if (isGraphMode()) {
1428
1428
 
1429
1429
  const next = findNextExecutableStep(steps, idx + 1, taskDir);
1430
1430
  if (!next) {
1431
- completeTaskMetrics();
1432
1431
  completePipeline({
1433
1432
  pipelineIndex: steps.length,
1434
1433
  phase: 'done',
@@ -9,7 +9,7 @@ import { fileURLToPath } from 'node:url';
9
9
 
10
10
  export const PACKAGE_NAME = '@bonesofspring/ai-rules';
11
11
  export const REGISTRY_URL = 'https://registry.npmjs.org/@bonesofspring/ai-rules/latest';
12
- export const CACHE_TTL_MS = 12 * 60 * 60 * 1000;
12
+ export const CACHE_TTL_MS = 60 * 60 * 1000;
13
13
  export const TOOL_ROOTS = ['.cursor', '.claude', '.mavis', '.opencode'];
14
14
 
15
15
  const RELEASE_VERSION = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/;