@cleocode/core 2026.10.18 → 2026.10.19

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 (259) hide show
  1. package/dist/build-provenance.json +2 -2
  2. package/dist/check/pr-gate.js +1 -1
  3. package/dist/check/pr-gate.js.map +1 -1
  4. package/dist/cloud/nexus-vault.d.ts +4 -3
  5. package/dist/cloud/nexus-vault.d.ts.map +1 -1
  6. package/dist/cloud/nexus-vault.js +62 -22
  7. package/dist/cloud/nexus-vault.js.map +1 -1
  8. package/dist/config.d.ts.map +1 -1
  9. package/dist/config.js +11 -0
  10. package/dist/config.js.map +1 -1
  11. package/dist/docs/conduit-history-backfill.d.ts +210 -0
  12. package/dist/docs/conduit-history-backfill.d.ts.map +1 -0
  13. package/dist/docs/conduit-history-backfill.js +451 -0
  14. package/dist/docs/conduit-history-backfill.js.map +1 -0
  15. package/dist/docs/docs-ops.d.ts +33 -0
  16. package/dist/docs/docs-ops.d.ts.map +1 -1
  17. package/dist/docs/docs-ops.js +72 -0
  18. package/dist/docs/docs-ops.js.map +1 -1
  19. package/dist/docs/docs-update.d.ts.map +1 -1
  20. package/dist/docs/docs-update.js +71 -0
  21. package/dist/docs/docs-update.js.map +1 -1
  22. package/dist/docs/doctor.d.ts +18 -4
  23. package/dist/docs/doctor.d.ts.map +1 -1
  24. package/dist/docs/doctor.js +124 -3
  25. package/dist/docs/doctor.js.map +1 -1
  26. package/dist/docs/section-merge.d.ts +70 -9
  27. package/dist/docs/section-merge.d.ts.map +1 -1
  28. package/dist/docs/section-merge.js +167 -10
  29. package/dist/docs/section-merge.js.map +1 -1
  30. package/dist/docs/section-write-path.d.ts.map +1 -1
  31. package/dist/docs/section-write-path.js +23 -8
  32. package/dist/docs/section-write-path.js.map +1 -1
  33. package/dist/gateway-client/generated/types.gen.d.ts +4 -0
  34. package/dist/gateway-client/generated/types.gen.d.ts.map +1 -1
  35. package/dist/go/driver.d.ts +29 -145
  36. package/dist/go/driver.d.ts.map +1 -1
  37. package/dist/go/driver.js +75 -168
  38. package/dist/go/driver.js.map +1 -1
  39. package/dist/go/index.d.ts +1 -1
  40. package/dist/go/index.d.ts.map +1 -1
  41. package/dist/go/index.js +1 -1
  42. package/dist/go/index.js.map +1 -1
  43. package/dist/goal/close.d.ts +1 -1
  44. package/dist/goal/close.js +2 -2
  45. package/dist/goal/close.js.map +1 -1
  46. package/dist/goal/draft.d.ts +10 -3
  47. package/dist/goal/draft.d.ts.map +1 -1
  48. package/dist/goal/draft.js +14 -9
  49. package/dist/goal/draft.js.map +1 -1
  50. package/dist/goal/index.d.ts +9 -12
  51. package/dist/goal/index.d.ts.map +1 -1
  52. package/dist/goal/index.js +9 -12
  53. package/dist/goal/index.js.map +1 -1
  54. package/dist/goal/runtime.d.ts +126 -0
  55. package/dist/goal/runtime.d.ts.map +1 -0
  56. package/dist/goal/runtime.js +289 -0
  57. package/dist/goal/runtime.js.map +1 -0
  58. package/dist/goal/status.d.ts +39 -0
  59. package/dist/goal/status.d.ts.map +1 -0
  60. package/dist/goal/status.js +101 -0
  61. package/dist/goal/status.js.map +1 -0
  62. package/dist/hooks/project-runner.d.ts +8 -3
  63. package/dist/hooks/project-runner.d.ts.map +1 -1
  64. package/dist/hooks/project-runner.js +104 -14
  65. package/dist/hooks/project-runner.js.map +1 -1
  66. package/dist/hooks/project-state.js +1 -1
  67. package/dist/hooks/project-state.js.map +1 -1
  68. package/dist/internal.d.ts +7 -3
  69. package/dist/internal.d.ts.map +1 -1
  70. package/dist/internal.js +5 -3
  71. package/dist/internal.js.map +1 -1
  72. package/dist/lifecycle/engine-ops.d.ts.map +1 -1
  73. package/dist/lifecycle/engine-ops.js +9 -6
  74. package/dist/lifecycle/engine-ops.js.map +1 -1
  75. package/dist/memory/retrieval/observe.d.ts.map +1 -1
  76. package/dist/memory/retrieval/observe.js +4 -8
  77. package/dist/memory/retrieval/observe.js.map +1 -1
  78. package/dist/paths.d.ts.map +1 -1
  79. package/dist/paths.js +4 -1
  80. package/dist/paths.js.map +1 -1
  81. package/dist/playbooks/cantbook-profile.d.ts +3 -3
  82. package/dist/playbooks/cantbook-profile.js +3 -3
  83. package/dist/playbooks/pi-runner-wiring.d.ts +3 -3
  84. package/dist/playbooks/pi-runner-wiring.js +3 -3
  85. package/dist/release/ci-evidence.d.ts +28 -0
  86. package/dist/release/ci-evidence.d.ts.map +1 -1
  87. package/dist/release/ci-evidence.js +76 -20
  88. package/dist/release/ci-evidence.js.map +1 -1
  89. package/dist/release/open.d.ts +11 -0
  90. package/dist/release/open.d.ts.map +1 -1
  91. package/dist/release/open.js +49 -10
  92. package/dist/release/open.js.map +1 -1
  93. package/dist/release/preflight-skip.d.ts +50 -0
  94. package/dist/release/preflight-skip.d.ts.map +1 -1
  95. package/dist/release/preflight-skip.js +151 -34
  96. package/dist/release/preflight-skip.js.map +1 -1
  97. package/dist/release/reconcile.d.ts.map +1 -1
  98. package/dist/release/reconcile.js +6 -3
  99. package/dist/release/reconcile.js.map +1 -1
  100. package/dist/scaffold/ensure-config.d.ts +1 -1
  101. package/dist/scaffold/ensure-config.d.ts.map +1 -1
  102. package/dist/scaffold/ensure-config.js +2 -0
  103. package/dist/scaffold/ensure-config.js.map +1 -1
  104. package/dist/security/index.d.ts +1 -1
  105. package/dist/security/index.d.ts.map +1 -1
  106. package/dist/security/index.js +1 -1
  107. package/dist/security/index.js.map +1 -1
  108. package/dist/security/override-cap-setting.d.ts +180 -0
  109. package/dist/security/override-cap-setting.d.ts.map +1 -0
  110. package/dist/security/override-cap-setting.js +657 -0
  111. package/dist/security/override-cap-setting.js.map +1 -0
  112. package/dist/security/override-cap.d.ts +20 -29
  113. package/dist/security/override-cap.d.ts.map +1 -1
  114. package/dist/security/override-cap.js +47 -71
  115. package/dist/security/override-cap.js.map +1 -1
  116. package/dist/security/owner-override-auth.d.ts +58 -0
  117. package/dist/security/owner-override-auth.d.ts.map +1 -1
  118. package/dist/security/owner-override-auth.js +82 -1
  119. package/dist/security/owner-override-auth.js.map +1 -1
  120. package/dist/security/owner-override-authority.d.ts +67 -0
  121. package/dist/security/owner-override-authority.d.ts.map +1 -0
  122. package/dist/security/owner-override-authority.js +100 -0
  123. package/dist/security/owner-override-authority.js.map +1 -0
  124. package/dist/sessions/handoff.d.ts.map +1 -1
  125. package/dist/sessions/handoff.js +4 -5
  126. package/dist/sessions/handoff.js.map +1 -1
  127. package/dist/sessions/index.d.ts.map +1 -1
  128. package/dist/sessions/index.js +22 -25
  129. package/dist/sessions/index.js.map +1 -1
  130. package/dist/store/conduit-doc-history.d.ts +39 -7
  131. package/dist/store/conduit-doc-history.d.ts.map +1 -1
  132. package/dist/store/conduit-doc-history.js +62 -12
  133. package/dist/store/conduit-doc-history.js.map +1 -1
  134. package/dist/store/data-safety-central.d.ts.map +1 -1
  135. package/dist/store/data-safety-central.js +3 -2
  136. package/dist/store/data-safety-central.js.map +1 -1
  137. package/dist/store/json.d.ts.map +1 -1
  138. package/dist/store/json.js +7 -7
  139. package/dist/store/json.js.map +1 -1
  140. package/dist/store/portable-bundle-scan.d.ts +23 -1
  141. package/dist/store/portable-bundle-scan.d.ts.map +1 -1
  142. package/dist/store/portable-bundle-scan.js +85 -3
  143. package/dist/store/portable-bundle-scan.js.map +1 -1
  144. package/dist/store/portable-bundle.d.ts.map +1 -1
  145. package/dist/store/portable-bundle.js +6 -1
  146. package/dist/store/portable-bundle.js.map +1 -1
  147. package/dist/store/row-identity-registry.d.ts +5 -3
  148. package/dist/store/row-identity-registry.d.ts.map +1 -1
  149. package/dist/store/row-identity-registry.js +54 -38
  150. package/dist/store/row-identity-registry.js.map +1 -1
  151. package/dist/store/schema/cleo-project/conduit.d.ts.map +1 -1
  152. package/dist/store/schema/cleo-project/conduit.js +4 -3
  153. package/dist/store/schema/cleo-project/conduit.js.map +1 -1
  154. package/dist/store/schema/cleo-project/runtime.d.ts +32 -0
  155. package/dist/store/schema/cleo-project/runtime.d.ts.map +1 -1
  156. package/dist/store/schema/cleo-project/runtime.js +7 -3
  157. package/dist/store/schema/cleo-project/runtime.js.map +1 -1
  158. package/dist/store/session-store.d.ts +45 -0
  159. package/dist/store/session-store.d.ts.map +1 -1
  160. package/dist/store/session-store.js +96 -1
  161. package/dist/store/session-store.js.map +1 -1
  162. package/dist/store/sqlite.d.ts +2 -0
  163. package/dist/store/sqlite.d.ts.map +1 -1
  164. package/dist/store/sqlite.js +12 -0
  165. package/dist/store/sqlite.js.map +1 -1
  166. package/dist/store/sync/merge/rules.d.ts.map +1 -1
  167. package/dist/store/sync/merge/rules.js +0 -16
  168. package/dist/store/sync/merge/rules.js.map +1 -1
  169. package/dist/store/sync/sealer.d.ts.map +1 -1
  170. package/dist/store/sync/sealer.js +27 -1
  171. package/dist/store/sync/sealer.js.map +1 -1
  172. package/dist/store/sync/sequencing.d.ts +3 -1
  173. package/dist/store/sync/sequencing.d.ts.map +1 -1
  174. package/dist/store/sync/sequencing.js +5 -3
  175. package/dist/store/sync/sequencing.js.map +1 -1
  176. package/dist/store/sync/timestamp-canon.d.ts.map +1 -1
  177. package/dist/store/sync/timestamp-canon.js +4 -0
  178. package/dist/store/sync/timestamp-canon.js.map +1 -1
  179. package/dist/store/table-classification.d.ts.map +1 -1
  180. package/dist/store/table-classification.js +12 -8
  181. package/dist/store/table-classification.js.map +1 -1
  182. package/dist/store/twin-collapse.d.ts +21 -0
  183. package/dist/store/twin-collapse.d.ts.map +1 -1
  184. package/dist/store/twin-collapse.js +235 -18
  185. package/dist/store/twin-collapse.js.map +1 -1
  186. package/dist/system/health.d.ts +17 -0
  187. package/dist/system/health.d.ts.map +1 -1
  188. package/dist/system/health.js +96 -0
  189. package/dist/system/health.js.map +1 -1
  190. package/dist/tasks/affected-packages.d.ts +67 -2
  191. package/dist/tasks/affected-packages.d.ts.map +1 -1
  192. package/dist/tasks/affected-packages.js +149 -21
  193. package/dist/tasks/affected-packages.js.map +1 -1
  194. package/dist/tasks/affected-scope.d.ts.map +1 -1
  195. package/dist/tasks/affected-scope.js +91 -5
  196. package/dist/tasks/affected-scope.js.map +1 -1
  197. package/dist/tasks/changeset-plan.d.ts +33 -0
  198. package/dist/tasks/changeset-plan.d.ts.map +1 -0
  199. package/dist/tasks/changeset-plan.js +152 -0
  200. package/dist/tasks/changeset-plan.js.map +1 -0
  201. package/dist/tasks/complete.d.ts.map +1 -1
  202. package/dist/tasks/complete.js +9 -1
  203. package/dist/tasks/complete.js.map +1 -1
  204. package/dist/tasks/done-plan.d.ts.map +1 -1
  205. package/dist/tasks/done-plan.js +28 -14
  206. package/dist/tasks/done-plan.js.map +1 -1
  207. package/dist/tasks/done-record.d.ts.map +1 -1
  208. package/dist/tasks/done-record.js +5 -1
  209. package/dist/tasks/done-record.js.map +1 -1
  210. package/dist/tasks/evidence.d.ts.map +1 -1
  211. package/dist/tasks/evidence.js +149 -18
  212. package/dist/tasks/evidence.js.map +1 -1
  213. package/dist/tasks/gate-runner.d.ts.map +1 -1
  214. package/dist/tasks/gate-runner.js +76 -4
  215. package/dist/tasks/gate-runner.js.map +1 -1
  216. package/dist/tasks/qa-run-binding.d.ts +18 -0
  217. package/dist/tasks/qa-run-binding.d.ts.map +1 -1
  218. package/dist/tasks/qa-run-binding.js +41 -1
  219. package/dist/tasks/qa-run-binding.js.map +1 -1
  220. package/dist/tasks/test-run-binding.d.ts +62 -0
  221. package/dist/tasks/test-run-binding.d.ts.map +1 -1
  222. package/dist/tasks/test-run-binding.js +126 -21
  223. package/dist/tasks/test-run-binding.js.map +1 -1
  224. package/dist/tasks/tool-resolver.d.ts +7 -0
  225. package/dist/tasks/tool-resolver.d.ts.map +1 -1
  226. package/dist/tasks/tool-resolver.js +3 -1
  227. package/dist/tasks/tool-resolver.js.map +1 -1
  228. package/dist/validation/engine-ops.d.ts.map +1 -1
  229. package/dist/validation/engine-ops.js +24 -29
  230. package/dist/validation/engine-ops.js.map +1 -1
  231. package/migrations/drizzle-cleo-project/20261016120000_t12535-playbook-row-uids/migration.sql +24 -0
  232. package/package.json +13 -13
  233. package/schemas/project-context.schema.json +5 -0
  234. package/templates/CLEO-INJECTION.md +1 -1
  235. package/templates/CLEO-REFERENCE.md +42 -1
  236. package/templates/cleo-gitignore +3 -0
  237. package/templates/git-hooks/legacy-hashes.json +1 -0
  238. package/templates/git-hooks/pre-push +35 -7
  239. package/templates/workflows/release-prepare.yml.tmpl +82 -4
  240. package/dist/goal/advance-with-persist.d.ts +0 -80
  241. package/dist/goal/advance-with-persist.d.ts.map +0 -1
  242. package/dist/goal/advance-with-persist.js +0 -105
  243. package/dist/goal/advance-with-persist.js.map +0 -1
  244. package/dist/goal/arm.d.ts +0 -61
  245. package/dist/goal/arm.d.ts.map +0 -1
  246. package/dist/goal/arm.js +0 -65
  247. package/dist/goal/arm.js.map +0 -1
  248. package/dist/goal/continuation.d.ts +0 -66
  249. package/dist/goal/continuation.d.ts.map +0 -1
  250. package/dist/goal/continuation.js +0 -111
  251. package/dist/goal/continuation.js.map +0 -1
  252. package/dist/goal/judge.d.ts +0 -113
  253. package/dist/goal/judge.d.ts.map +0 -1
  254. package/dist/goal/judge.js +0 -193
  255. package/dist/goal/judge.js.map +0 -1
  256. package/dist/goal/loop.d.ts +0 -75
  257. package/dist/goal/loop.d.ts.map +0 -1
  258. package/dist/goal/loop.js +0 -132
  259. package/dist/goal/loop.js.map +0 -1
@@ -1,80 +0,0 @@
1
- /**
2
- * Goal advance-with-persist — load → advance → persist → continuation.
3
- *
4
- * This is the ORCHESTRATED entry point called by `cleo goal advance <goalId>`
5
- * (CLI) and by the Claude Code Stop-hook. It wraps the PURE
6
- * {@link advanceGoal} (no I/O) with the persistence and continuation steps
7
- * that complete the AC loop:
8
- *
9
- * ```
10
- * getGoalById(id)
11
- * → advanceGoal(goal, judgeGoal-closure) [pure, no I/O]
12
- * → updateGoal(id, { status, turnsUsed, lastVerdict })
13
- * → buildContinuation(updatedGoal, verdict) [null when terminal]
14
- * ```
15
- *
16
- * The injected `llmJudge` is only called for `fuzzy` goals — task-completion
17
- * goals use the ADR-051 evidence path (pure, offline). Tests pass
18
- * {@link StaticGoalJudge} to stay fully hermetic.
19
- *
20
- * ## Return shape
21
- *
22
- * The returned {@link AdvanceWithPersistResult} always carries the
23
- * `advanceResult` (verdict, nextStatus, turnsRemaining), the fully-updated
24
- * `goal` record (after the persistence write), and — critically — the
25
- * `continuation` nudge ({@link GoalContinuation}) or `null` when the goal
26
- * has reached a terminal state. The CLI formats this as a LAFS envelope; the
27
- * Stop-hook uses `continuation` to decide whether to emit a block decision.
28
- *
29
- * @module @cleocode/core/goal/advance-with-persist
30
- *
31
- * @epic T11290 EP-CLEO-GOAL-SYSTEM
32
- * @task T11496 E4-GOAL-LOOP
33
- * @saga T11283 SG-COGNITIVE-SUBSTRATE
34
- */
35
- import type { GoalAdvanceResult, GoalContinuation, GoalJudge, GoalRecord } from '@cleocode/contracts';
36
- /**
37
- * The combined result of one orchestrated advance turn.
38
- *
39
- * @task T11496
40
- */
41
- export interface AdvanceWithPersistResult {
42
- /**
43
- * The raw advance result from the pure `advanceGoal` engine (verdict,
44
- * nextStatus, turnsRemaining). This is what is persisted.
45
- */
46
- readonly advanceResult: GoalAdvanceResult;
47
- /**
48
- * The goal record AFTER the persistence write. Status and verdict are
49
- * already updated — callers render this, not the pre-advance snapshot.
50
- */
51
- readonly goal: GoalRecord;
52
- /**
53
- * The continuation nudge, or `null` when the goal is terminal.
54
- *
55
- * Non-null for `active` and `paused` goals — the Stop-hook emits this as a
56
- * `{ decision: 'block', reason: continuation.content }` response to keep
57
- * Claude working. Null for `satisfied`, `abandoned`, `impossible`.
58
- */
59
- readonly continuation: GoalContinuation | null;
60
- }
61
- /**
62
- * Advance a goal one turn and persist the result.
63
- *
64
- * Orchestrates the full load → advance (pure) → persist → continuation
65
- * pipeline in one call. Returns `null` when the goal id is not found.
66
- *
67
- * @param goalId - The goal to advance (idempotency key / primary key).
68
- * @param options - Optional overrides.
69
- * @param options.llmJudge - LLM judge for fuzzy goals (default: offline stub).
70
- * @param options.cwd - Project root override.
71
- * @returns The combined result, or `null` when the goal is absent.
72
- *
73
- * @task T11496
74
- * @adr ADR-051
75
- */
76
- export declare function advanceGoalWithPersist(goalId: string, options?: {
77
- readonly llmJudge?: GoalJudge;
78
- readonly cwd?: string;
79
- }): Promise<AdvanceWithPersistResult | null>;
80
- //# sourceMappingURL=advance-with-persist.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"advance-with-persist.d.ts","sourceRoot":"","sources":["../../src/goal/advance-with-persist.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,KAAK,EACV,iBAAiB,EACjB,gBAAgB,EAChB,SAAS,EACT,UAAU,EACX,MAAM,qBAAqB,CAAC;AA8B7B;;;;GAIG;AACH,MAAM,WAAW,wBAAwB;IACvC;;;OAGG;IACH,QAAQ,CAAC,aAAa,EAAE,iBAAiB,CAAC;IAC1C;;;OAGG;IACH,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B;;;;;;OAMG;IACH,QAAQ,CAAC,YAAY,EAAE,gBAAgB,GAAG,IAAI,CAAC;CAChD;AAMD;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,MAAM,EACd,OAAO,GAAE;IACP,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;CAClB,GACL,OAAO,CAAC,wBAAwB,GAAG,IAAI,CAAC,CA4C1C"}
@@ -1,105 +0,0 @@
1
- /**
2
- * Goal advance-with-persist — load → advance → persist → continuation.
3
- *
4
- * This is the ORCHESTRATED entry point called by `cleo goal advance <goalId>`
5
- * (CLI) and by the Claude Code Stop-hook. It wraps the PURE
6
- * {@link advanceGoal} (no I/O) with the persistence and continuation steps
7
- * that complete the AC loop:
8
- *
9
- * ```
10
- * getGoalById(id)
11
- * → advanceGoal(goal, judgeGoal-closure) [pure, no I/O]
12
- * → updateGoal(id, { status, turnsUsed, lastVerdict })
13
- * → buildContinuation(updatedGoal, verdict) [null when terminal]
14
- * ```
15
- *
16
- * The injected `llmJudge` is only called for `fuzzy` goals — task-completion
17
- * goals use the ADR-051 evidence path (pure, offline). Tests pass
18
- * {@link StaticGoalJudge} to stay fully hermetic.
19
- *
20
- * ## Return shape
21
- *
22
- * The returned {@link AdvanceWithPersistResult} always carries the
23
- * `advanceResult` (verdict, nextStatus, turnsRemaining), the fully-updated
24
- * `goal` record (after the persistence write), and — critically — the
25
- * `continuation` nudge ({@link GoalContinuation}) or `null` when the goal
26
- * has reached a terminal state. The CLI formats this as a LAFS envelope; the
27
- * Stop-hook uses `continuation` to decide whether to emit a block decision.
28
- *
29
- * @module @cleocode/core/goal/advance-with-persist
30
- *
31
- * @epic T11290 EP-CLEO-GOAL-SYSTEM
32
- * @task T11496 E4-GOAL-LOOP
33
- * @saga T11283 SG-COGNITIVE-SUBSTRATE
34
- */
35
- import { buildContinuation } from './continuation.js';
36
- import { judgeGoal, StaticGoalJudge } from './judge.js';
37
- import { advanceGoal } from './loop.js';
38
- import { getGoalById, updateGoal } from './store.js';
39
- // ---------------------------------------------------------------------------
40
- // Default offline-safe LLM judge
41
- // ---------------------------------------------------------------------------
42
- /**
43
- * The fallback judge used when no real LLM judge is provided.
44
- *
45
- * Always returns a non-satisfied, non-impossible verdict so the loop
46
- * continues (safe default). In production the caller should inject a
47
- * real LLM-backed {@link GoalJudge} for fuzzy goals.
48
- *
49
- * @internal
50
- */
51
- const DEFAULT_FALLBACK_JUDGE = new StaticGoalJudge({
52
- ok: false,
53
- impossible: false,
54
- reason: 'No LLM judge provided — fuzzy goal keeps running until explicitly resolved or budget exhausted.',
55
- });
56
- // ---------------------------------------------------------------------------
57
- // Public API
58
- // ---------------------------------------------------------------------------
59
- /**
60
- * Advance a goal one turn and persist the result.
61
- *
62
- * Orchestrates the full load → advance (pure) → persist → continuation
63
- * pipeline in one call. Returns `null` when the goal id is not found.
64
- *
65
- * @param goalId - The goal to advance (idempotency key / primary key).
66
- * @param options - Optional overrides.
67
- * @param options.llmJudge - LLM judge for fuzzy goals (default: offline stub).
68
- * @param options.cwd - Project root override.
69
- * @returns The combined result, or `null` when the goal is absent.
70
- *
71
- * @task T11496
72
- * @adr ADR-051
73
- */
74
- export async function advanceGoalWithPersist(goalId, options = {}) {
75
- const { llmJudge = DEFAULT_FALLBACK_JUDGE, cwd } = options;
76
- // 1. Load the current goal record.
77
- const goal = await getGoalById(goalId, cwd);
78
- if (!goal) {
79
- return null;
80
- }
81
- // 2. Build the injected judge closure over `judgeGoal` (the evidence-gate-
82
- // aware judge from judge.ts). This is what the AC says: "calling EXISTING
83
- // advanceGoal(goal, judgeGoal-closure)".
84
- const judgeFn = (g) => judgeGoal(g, llmJudge, cwd);
85
- // 3. Advance one turn (pure — no I/O, no side effects).
86
- const advanceResult = await advanceGoal(goal, judgeFn);
87
- // 4. Persist the updated status + turnsUsed + lastVerdict.
88
- const turnsConsumed = goal.turnsUsed + (goal.turnBudget - goal.turnsUsed - advanceResult.turnsRemaining);
89
- const updated = await updateGoal(goalId, {
90
- status: advanceResult.nextStatus,
91
- turnsUsed: Math.max(goal.turnsUsed, goal.turnBudget - advanceResult.turnsRemaining),
92
- lastVerdict: advanceResult.verdict,
93
- // Clear pausedReason when we successfully advanced (non-paused result).
94
- ...(advanceResult.nextStatus !== 'paused' ? { pausedReason: null } : {}),
95
- }, cwd);
96
- // `updated` can only be null if the row disappeared between load and update
97
- // (extremely unlikely — treat as present with the pre-update snapshot).
98
- const persisted = updated ?? { ...goal, status: advanceResult.nextStatus };
99
- // Suppress unused variable warning.
100
- void turnsConsumed;
101
- // 5. Build the continuation nudge for the updated goal + latest verdict.
102
- const continuation = buildContinuation(persisted, advanceResult.verdict);
103
- return { advanceResult, goal: persisted, continuation };
104
- }
105
- //# sourceMappingURL=advance-with-persist.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"advance-with-persist.js","sourceRoot":"","sources":["../../src/goal/advance-with-persist.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAQH,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAErD,8EAA8E;AAC9E,iCAAiC;AACjC,8EAA8E;AAE9E;;;;;;;;GAQG;AACH,MAAM,sBAAsB,GAAc,IAAI,eAAe,CAAC;IAC5D,EAAE,EAAE,KAAK;IACT,UAAU,EAAE,KAAK;IACjB,MAAM,EACJ,iGAAiG;CACpG,CAAC,CAAC;AAgCH,8EAA8E;AAC9E,aAAa;AACb,8EAA8E;AAE9E;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,MAAc,EACd,UAGI,EAAE;IAEN,MAAM,EAAE,QAAQ,GAAG,sBAAsB,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;IAE3D,mCAAmC;IACnC,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5C,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,IAAI,CAAC;IACd,CAAC;IAED,2EAA2E;IAC3E,6EAA6E;IAC7E,4CAA4C;IAC5C,MAAM,OAAO,GAAG,CAAC,CAAa,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAC;IAE/D,wDAAwD;IACxD,MAAM,aAAa,GAAG,MAAM,WAAW,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAEvD,2DAA2D;IAC3D,MAAM,aAAa,GACjB,IAAI,CAAC,SAAS,GAAG,CAAC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,SAAS,GAAG,aAAa,CAAC,cAAc,CAAC,CAAC;IAErF,MAAM,OAAO,GAAG,MAAM,UAAU,CAC9B,MAAM,EACN;QACE,MAAM,EAAE,aAAa,CAAC,UAAU;QAChC,SAAS,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,UAAU,GAAG,aAAa,CAAC,cAAc,CAAC;QACnF,WAAW,EAAE,aAAa,CAAC,OAAO;QAClC,wEAAwE;QACxE,GAAG,CAAC,aAAa,CAAC,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACzE,EACD,GAAG,CACJ,CAAC;IAEF,4EAA4E;IAC5E,wEAAwE;IACxE,MAAM,SAAS,GAAG,OAAO,IAAI,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,aAAa,CAAC,UAAU,EAAE,CAAC;IAE3E,oCAAoC;IACpC,KAAK,aAAa,CAAC;IAEnB,yEAAyE;IACzE,MAAM,YAAY,GAAG,iBAAiB,CAAC,SAAS,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;IAEzE,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;AAC1D,CAAC"}
@@ -1,61 +0,0 @@
1
- /**
2
- * Goal-loop arming — create + register the per-saga goal that `cleo go`
3
- * uses to drive the Stop-hook self-renudge cycle (AC3 of T11496).
4
- *
5
- * `armGoalLoop` is called by `cleoGo()` after it has selected the active saga.
6
- * It creates (or reuses via idempotency key) a `fuzzy` goal whose intent
7
- * describes the saga work. The Stop-hook then advances this goal each turn,
8
- * re-injecting the continuation nudge until `judgeGoal` signals
9
- * `satisfied` or `impossible`.
10
- *
11
- * ## Idempotency
12
- *
13
- * The idempotency key is `cleo-go:${sagaId}:${epochDay}`, ensuring one goal
14
- * per saga per calendar day. Re-runs of `cleo go` on the same day reuse the
15
- * existing goal (via `onConflictDoNothing` in the store) rather than
16
- * accumulating rows.
17
- *
18
- * ## Why fuzzy?
19
- *
20
- * Saga completion is orchestration-level progress — not a single task with
21
- * ADR-051 evidence gates. A `fuzzy` goal lets the loop keep nudging Claude
22
- * until the saga rollup shows the desired state; the injected nudge text
23
- * (from `buildContinuation`) reminds Claude of the intent each turn.
24
- *
25
- * @module @cleocode/core/goal/arm
26
- *
27
- * @task T11496 E4-GOAL-LOOP
28
- * @epic T11492 SG-AUTOPILOT
29
- * @saga T11283 SG-COGNITIVE-SUBSTRATE
30
- */
31
- import type { GoalRecord } from '@cleocode/contracts';
32
- /**
33
- * Parameters for {@link armGoalLoop}.
34
- *
35
- * @task T11496
36
- */
37
- export interface ArmGoalLoopParams {
38
- /** The saga being worked on (e.g. `'T11492'`). */
39
- readonly sagaId: string;
40
- /** Human-readable saga title for the goal intent. */
41
- readonly sagaTitle?: string;
42
- /** Override project root (useful in tests). */
43
- readonly cwd?: string;
44
- /**
45
- * Turn budget for the goal (default: {@link SAGA_GOAL_TURN_BUDGET}).
46
- */
47
- readonly turnBudget?: number;
48
- }
49
- /**
50
- * Create (or reuse) the per-saga goal that arms the Stop-hook self-renudge
51
- * loop for `cleo go`.
52
- *
53
- * Idempotent on `(sagaId, calendarDay)` — safe to call every `cleo go` turn.
54
- *
55
- * @param params - Arming parameters.
56
- * @returns The created (or pre-existing) {@link GoalRecord}.
57
- *
58
- * @task T11496
59
- */
60
- export declare function armGoalLoop(params: ArmGoalLoopParams): Promise<GoalRecord>;
61
- //# sourceMappingURL=arm.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"arm.d.ts","sourceRoot":"","sources":["../../src/goal/arm.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAMtD;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,kDAAkD;IAClD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,qDAAqD;IACrD,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,+CAA+C;IAC/C,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,WAAW,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,UAAU,CAAC,CA2BhF"}
package/dist/goal/arm.js DELETED
@@ -1,65 +0,0 @@
1
- /**
2
- * Goal-loop arming — create + register the per-saga goal that `cleo go`
3
- * uses to drive the Stop-hook self-renudge cycle (AC3 of T11496).
4
- *
5
- * `armGoalLoop` is called by `cleoGo()` after it has selected the active saga.
6
- * It creates (or reuses via idempotency key) a `fuzzy` goal whose intent
7
- * describes the saga work. The Stop-hook then advances this goal each turn,
8
- * re-injecting the continuation nudge until `judgeGoal` signals
9
- * `satisfied` or `impossible`.
10
- *
11
- * ## Idempotency
12
- *
13
- * The idempotency key is `cleo-go:${sagaId}:${epochDay}`, ensuring one goal
14
- * per saga per calendar day. Re-runs of `cleo go` on the same day reuse the
15
- * existing goal (via `onConflictDoNothing` in the store) rather than
16
- * accumulating rows.
17
- *
18
- * ## Why fuzzy?
19
- *
20
- * Saga completion is orchestration-level progress — not a single task with
21
- * ADR-051 evidence gates. A `fuzzy` goal lets the loop keep nudging Claude
22
- * until the saga rollup shows the desired state; the injected nudge text
23
- * (from `buildContinuation`) reminds Claude of the intent each turn.
24
- *
25
- * @module @cleocode/core/goal/arm
26
- *
27
- * @task T11496 E4-GOAL-LOOP
28
- * @epic T11492 SG-AUTOPILOT
29
- * @saga T11283 SG-COGNITIVE-SUBSTRATE
30
- */
31
- import { createGoal } from './store.js';
32
- /** Default turn budget for a saga-level goal (a full autopilot session). */
33
- const SAGA_GOAL_TURN_BUDGET = 20;
34
- /**
35
- * Create (or reuse) the per-saga goal that arms the Stop-hook self-renudge
36
- * loop for `cleo go`.
37
- *
38
- * Idempotent on `(sagaId, calendarDay)` — safe to call every `cleo go` turn.
39
- *
40
- * @param params - Arming parameters.
41
- * @returns The created (or pre-existing) {@link GoalRecord}.
42
- *
43
- * @task T11496
44
- */
45
- export async function armGoalLoop(params) {
46
- const { sagaId, sagaTitle, cwd, turnBudget = SAGA_GOAL_TURN_BUDGET } = params;
47
- // Idempotency key: one goal per saga per calendar day.
48
- const epochDay = Math.floor(Date.now() / (1000 * 60 * 60 * 24));
49
- const idempotencyKey = `cleo-go:${sagaId}:${epochDay}`;
50
- const intent = sagaTitle != null
51
- ? `Drive saga ${sagaId} (${sagaTitle}) forward — pick the next ready task and advance it until done.`
52
- : `Drive saga ${sagaId} forward — pick the next ready task and advance it until done.`;
53
- const criteria = [
54
- `All tasks in saga ${sagaId} reach 'done' status with ADR-051 evidence gates satisfied.`,
55
- 'Each turn: run `cleo go` to pick the next ready task and start IVTR.',
56
- ];
57
- return createGoal({
58
- goalKind: { kind: 'fuzzy' },
59
- intent,
60
- turnBudget,
61
- criteria,
62
- idempotencyKey,
63
- }, cwd);
64
- }
65
- //# sourceMappingURL=arm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"arm.js","sourceRoot":"","sources":["../../src/goal/arm.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,4EAA4E;AAC5E,MAAM,qBAAqB,GAAG,EAAE,CAAC;AAoBjC;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,MAAyB;IACzD,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,EAAE,UAAU,GAAG,qBAAqB,EAAE,GAAG,MAAM,CAAC;IAE9E,uDAAuD;IACvD,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;IAChE,MAAM,cAAc,GAAG,WAAW,MAAM,IAAI,QAAQ,EAAE,CAAC;IAEvD,MAAM,MAAM,GACV,SAAS,IAAI,IAAI;QACf,CAAC,CAAC,cAAc,MAAM,KAAK,SAAS,iEAAiE;QACrG,CAAC,CAAC,cAAc,MAAM,gEAAgE,CAAC;IAE3F,MAAM,QAAQ,GAAsB;QAClC,qBAAqB,MAAM,6DAA6D;QACxF,sEAAsE;KACvE,CAAC;IAEF,OAAO,UAAU,CACf;QACE,QAAQ,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE;QAC3B,MAAM;QACN,UAAU;QACV,QAAQ;QACR,cAAc;KACf,EACD,GAAG,CACJ,CAAC;AACJ,CAAC"}
@@ -1,66 +0,0 @@
1
- /**
2
- * Prompt-cache-safe goal continuation builder (Layer 4 of SG-COGNITIVE-SUBSTRATE).
3
- *
4
- * ## The prompt-cache-safety contract (why user-message, not system mutation)
5
- *
6
- * Prompt caching keys on a STABLE message prefix — most importantly the system
7
- * prompt. The harness assembles `[system, ...history]` once and caches the long
8
- * static prefix; every cache hit skips re-processing those tokens. If the goal
9
- * loop nudged the agent by REWRITING the system prompt each turn, it would
10
- * invalidate that cached prefix on every single turn — turning a cheap cache hit
11
- * into a full re-encode and defeating the entire point of caching.
12
- *
13
- * {@link buildContinuation} therefore emits the nudge as a `role: 'user'`
14
- * message that is APPENDED after the existing conversation. The system prompt is
15
- * never touched, so the cached prefix stays valid and only the new (short) user
16
- * message is processed. The builder is also byte-stable for identical
17
- * `(goal, verdict)` inputs — the same continuation text is produced every call —
18
- * which is required so a re-issued turn reuses the same cache prefix rather than
19
- * minting a fresh, cache-busting string.
20
- *
21
- * ## Harness boundary (AC4)
22
- *
23
- * The CLI/SDK side (this builder) guarantees the continuation is a user message
24
- * and never mutates the system prompt. The HARNESS owns final message-array
25
- * assembly (it decides where to splice this user message and how the system
26
- * prompt is cached). This module guarantees the CLI-side contract; the harness
27
- * guarantees its own. The two together deliver end-to-end cache safety.
28
- *
29
- * @module @cleocode/core/goal/continuation
30
- *
31
- * @epic T11290 EP-CLEO-GOAL-SYSTEM
32
- * @task T11380
33
- * @saga T11283 SG-COGNITIVE-SUBSTRATE
34
- */
35
- import type { GoalContinuation, GoalJudgeVerdict, GoalRecord } from '@cleocode/contracts';
36
- /**
37
- * Maximum byte length of a continuation's `content`. A continuation is a nudge,
38
- * not a document — keeping it small bounds the per-turn token cost and keeps the
39
- * appended user message cheap to (re)process. Criteria beyond what fits are
40
- * truncated with an explicit marker so the cap is never silently exceeded.
41
- *
42
- * @task T11380
43
- */
44
- export declare const CONTINUATION_MAX_BYTES = 1200;
45
- /**
46
- * Build the next-turn continuation nudge for a goal, or `null` when no nudge is
47
- * warranted.
48
- *
49
- * Returns `null` for a TERMINAL verdict/status — a `satisfied`, `abandoned`, or
50
- * `impossible` goal has nothing left to nudge toward, so no user message is
51
- * emitted. Only `active` and `paused` goals receive a continuation (`paused`
52
- * because it can be resumed). The presence of `verdict.ok` or
53
- * `verdict.impossible` ALSO short-circuits to `null` even if a stale status says
54
- * otherwise — the verdict is the freshest signal.
55
- *
56
- * The continuation embeds the goal intent, the outstanding criteria, and the
57
- * judge's reason (so the agent knows WHY it must continue), and is byte-stable
58
- * for identical inputs (deterministic — required for prompt-cache prefix reuse).
59
- *
60
- * @param goal - The current goal record.
61
- * @param verdict - The judge's latest verdict for this goal.
62
- * @returns A `{ role: 'user', content }` continuation, or `null` when terminal.
63
- * @task T11380
64
- */
65
- export declare function buildContinuation(goal: GoalRecord, verdict: GoalJudgeVerdict): GoalContinuation | null;
66
- //# sourceMappingURL=continuation.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"continuation.d.ts","sourceRoot":"","sources":["../../src/goal/continuation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAG1F;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB,OAAO,CAAC;AAE3C;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,UAAU,EAChB,OAAO,EAAE,gBAAgB,GACxB,gBAAgB,GAAG,IAAI,CA6BzB"}
@@ -1,111 +0,0 @@
1
- /**
2
- * Prompt-cache-safe goal continuation builder (Layer 4 of SG-COGNITIVE-SUBSTRATE).
3
- *
4
- * ## The prompt-cache-safety contract (why user-message, not system mutation)
5
- *
6
- * Prompt caching keys on a STABLE message prefix — most importantly the system
7
- * prompt. The harness assembles `[system, ...history]` once and caches the long
8
- * static prefix; every cache hit skips re-processing those tokens. If the goal
9
- * loop nudged the agent by REWRITING the system prompt each turn, it would
10
- * invalidate that cached prefix on every single turn — turning a cheap cache hit
11
- * into a full re-encode and defeating the entire point of caching.
12
- *
13
- * {@link buildContinuation} therefore emits the nudge as a `role: 'user'`
14
- * message that is APPENDED after the existing conversation. The system prompt is
15
- * never touched, so the cached prefix stays valid and only the new (short) user
16
- * message is processed. The builder is also byte-stable for identical
17
- * `(goal, verdict)` inputs — the same continuation text is produced every call —
18
- * which is required so a re-issued turn reuses the same cache prefix rather than
19
- * minting a fresh, cache-busting string.
20
- *
21
- * ## Harness boundary (AC4)
22
- *
23
- * The CLI/SDK side (this builder) guarantees the continuation is a user message
24
- * and never mutates the system prompt. The HARNESS owns final message-array
25
- * assembly (it decides where to splice this user message and how the system
26
- * prompt is cached). This module guarantees the CLI-side contract; the harness
27
- * guarantees its own. The two together deliver end-to-end cache safety.
28
- *
29
- * @module @cleocode/core/goal/continuation
30
- *
31
- * @epic T11290 EP-CLEO-GOAL-SYSTEM
32
- * @task T11380
33
- * @saga T11283 SG-COGNITIVE-SUBSTRATE
34
- */
35
- import { isTerminalGoalStatus } from '@cleocode/contracts/goal.js';
36
- /**
37
- * Maximum byte length of a continuation's `content`. A continuation is a nudge,
38
- * not a document — keeping it small bounds the per-turn token cost and keeps the
39
- * appended user message cheap to (re)process. Criteria beyond what fits are
40
- * truncated with an explicit marker so the cap is never silently exceeded.
41
- *
42
- * @task T11380
43
- */
44
- export const CONTINUATION_MAX_BYTES = 1200;
45
- /**
46
- * Build the next-turn continuation nudge for a goal, or `null` when no nudge is
47
- * warranted.
48
- *
49
- * Returns `null` for a TERMINAL verdict/status — a `satisfied`, `abandoned`, or
50
- * `impossible` goal has nothing left to nudge toward, so no user message is
51
- * emitted. Only `active` and `paused` goals receive a continuation (`paused`
52
- * because it can be resumed). The presence of `verdict.ok` or
53
- * `verdict.impossible` ALSO short-circuits to `null` even if a stale status says
54
- * otherwise — the verdict is the freshest signal.
55
- *
56
- * The continuation embeds the goal intent, the outstanding criteria, and the
57
- * judge's reason (so the agent knows WHY it must continue), and is byte-stable
58
- * for identical inputs (deterministic — required for prompt-cache prefix reuse).
59
- *
60
- * @param goal - The current goal record.
61
- * @param verdict - The judge's latest verdict for this goal.
62
- * @returns A `{ role: 'user', content }` continuation, or `null` when terminal.
63
- * @task T11380
64
- */
65
- export function buildContinuation(goal, verdict) {
66
- // The verdict is the freshest signal: a satisfied or impossible verdict means
67
- // there is nothing to nudge toward, regardless of the persisted status.
68
- if (verdict.ok || verdict.impossible) {
69
- return null;
70
- }
71
- // A terminal status (satisfied/abandoned/impossible) likewise yields no nudge.
72
- if (isTerminalGoalStatus(goal.status)) {
73
- return null;
74
- }
75
- const lines = [];
76
- lines.push(`[GOAL CONTINUATION] Your active goal is not yet satisfied.`);
77
- lines.push(`Intent: ${goal.intent}`);
78
- if (goal.criteria.length > 0) {
79
- lines.push(`Outstanding criteria:`);
80
- for (const criterion of goal.criteria) {
81
- lines.push(` - ${criterion}`);
82
- }
83
- }
84
- lines.push(`Why continue: ${verdict.reason}`);
85
- lines.push(`Turns: ${goal.turnsUsed}/${goal.turnBudget} used. Keep working until the goal's gates are evidence-backed.`);
86
- const content = clampToBytes(lines.join('\n'), CONTINUATION_MAX_BYTES);
87
- return { role: 'user', content };
88
- }
89
- /**
90
- * Clamp a string to at most `maxBytes` UTF-8 bytes, appending a truncation
91
- * marker when it overflows. Deterministic — identical input yields identical
92
- * output, preserving byte-stability for prompt-cache prefix reuse.
93
- *
94
- * @internal
95
- */
96
- function clampToBytes(text, maxBytes) {
97
- const encoder = new TextEncoder();
98
- if (encoder.encode(text).length <= maxBytes) {
99
- return text;
100
- }
101
- const marker = '\n… [truncated]';
102
- const budget = maxBytes - encoder.encode(marker).length;
103
- // Walk back from the byte budget to a safe character boundary so we never
104
- // split a multi-byte codepoint.
105
- let sliced = text;
106
- while (encoder.encode(sliced).length > budget && sliced.length > 0) {
107
- sliced = sliced.slice(0, -1);
108
- }
109
- return sliced + marker;
110
- }
111
- //# sourceMappingURL=continuation.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"continuation.js","sourceRoot":"","sources":["../../src/goal/continuation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAGH,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAEnE;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,CAAC;AAE3C;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,iBAAiB,CAC/B,IAAgB,EAChB,OAAyB;IAEzB,8EAA8E;IAC9E,wEAAwE;IACxE,IAAI,OAAO,CAAC,EAAE,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;QACrC,OAAO,IAAI,CAAC;IACd,CAAC;IACD,+EAA+E;IAC/E,IAAI,oBAAoB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QACtC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,CAAC,IAAI,CAAC,4DAA4D,CAAC,CAAC;IACzE,KAAK,CAAC,IAAI,CAAC,WAAW,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;IAErC,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC7B,KAAK,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;QACpC,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YACtC,KAAK,CAAC,IAAI,CAAC,OAAO,SAAS,EAAE,CAAC,CAAC;QACjC,CAAC;IACH,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,iBAAiB,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAC9C,KAAK,CAAC,IAAI,CACR,UAAU,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,UAAU,iEAAiE,CAC7G,CAAC;IAEF,MAAM,OAAO,GAAG,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,sBAAsB,CAAC,CAAC;IACvE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;AACnC,CAAC;AAED;;;;;;GAMG;AACH,SAAS,YAAY,CAAC,IAAY,EAAE,QAAgB;IAClD,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;IAClC,IAAI,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,IAAI,QAAQ,EAAE,CAAC;QAC5C,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,MAAM,GAAG,iBAAiB,CAAC;IACjC,MAAM,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC;IACxD,0EAA0E;IAC1E,gCAAgC;IAChC,IAAI,MAAM,GAAG,IAAI,CAAC;IAClB,OAAO,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,GAAG,MAAM,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACnE,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAC/B,CAAC;IACD,OAAO,MAAM,GAAG,MAAM,CAAC;AACzB,CAAC"}
@@ -1,113 +0,0 @@
1
- /**
2
- * Evidence-gate-aware goal judge (Layer 4 of SG-COGNITIVE-SUBSTRATE).
3
- *
4
- * This is CLEO's core differentiator over Claude-Code (transcript judge) and
5
- * Hermes (post-turn loop, still transcript-judged for fuzzy intent). For a
6
- * `task-completion` goal, the judge NEVER reads the transcript: it resolves the
7
- * target task's REAL status and re-uses the shipped ADR-051 evidence
8
- * infrastructure ({@link validateEvidenceForGate} +
9
- * {@link GATE_EVIDENCE_REQUIREMENTS} via `tasks/evidence.ts`). A goal is
10
- * satisfied ONLY when the task is `status === 'done'` AND every required gate
11
- * ({@link CRITICAL_GATES}) is backed by evidence atoms of the kinds ADR-051
12
- * mandates. Transcript text can never satisfy a task-completion goal.
13
- *
14
- * `fuzzy` goals — those with no machine-checkable artifact — delegate to an
15
- * INJECTABLE LLM judge ({@link GoalJudge}). The judge interface, not a concrete
16
- * model client, is the dependency, so vitest passes a deterministic mock and
17
- * stays fully offline/hermetic. The fuzzy path NEVER touches the evidence
18
- * infrastructure.
19
- *
20
- * @module @cleocode/core/goal/judge
21
- *
22
- * @epic T11290 EP-CLEO-GOAL-SYSTEM
23
- * @task T11378
24
- * @saga T11283 SG-COGNITIVE-SUBSTRATE
25
- * @adr ADR-051
26
- */
27
- import type { GoalJudge, GoalJudgeVerdict, GoalRecord, VerificationGate } from '@cleocode/contracts';
28
- /**
29
- * The gates a task-completion goal demands be evidence-backed before it is
30
- * judged satisfied. These are the ADR-051 critical gates that reject
31
- * override-only evidence (`implemented` + `testsPassed`) — the same two gates
32
- * `cleo complete` enforces hardest. A goal that says "complete T123" therefore
33
- * means exactly what CLEO means by complete: code landed (commit+files) AND
34
- * tests proven (test-run/tool/pr), with real, validated atoms.
35
- *
36
- * @task T11378
37
- * @adr ADR-051
38
- */
39
- export declare const CRITICAL_GATES: readonly VerificationGate[];
40
- /**
41
- * Judge a goal and return a uniform {@link GoalJudgeVerdict}.
42
- *
43
- * Routing:
44
- * - `task-completion` → {@link judgeTaskCompletion} (evidence path, no LLM).
45
- * - `fuzzy` → the injected {@link GoalJudge} (LLM fallback).
46
- *
47
- * The `llmJudge` is REQUIRED only for fuzzy goals; a task-completion goal never
48
- * calls it. Passing the judge by parameter (dependency injection) is what keeps
49
- * vitest hermetic.
50
- *
51
- * @param goal - The goal under evaluation.
52
- * @param llmJudge - The injectable LLM judge used for fuzzy goals.
53
- * @param cwd - Project root override for task lookup.
54
- * @returns The verdict (same shape for both paths).
55
- * @task T11378
56
- */
57
- export declare function judgeGoal(goal: GoalRecord, llmJudge: GoalJudge, cwd?: string): Promise<GoalJudgeVerdict>;
58
- /**
59
- * Evidence-gate-aware judgement for a single task-completion goal.
60
- *
61
- * Decision table (first match wins):
62
- * 1. Task not found → `impossible` (the goal references a task that no longer
63
- * exists).
64
- * 2. Task `cancelled` / `archived` → `impossible` (terminal non-done state —
65
- * it can never become `done`).
66
- * 3. Task not `done` → `ok: false` (still in flight; reason carries the real
67
- * status so the continuation tells the agent what remains).
68
- * 4. Task `done` but a critical gate lacks the ADR-051-required evidence atoms
69
- * → `ok: false` (done-without-proof is NOT satisfied — the whole point).
70
- * 5. Task `done` AND every critical gate is evidence-backed → `ok: true`.
71
- *
72
- * @param targetTaskId - The task the goal wants completed.
73
- * @param cwd - Project root override.
74
- * @returns The verdict, with `evidence[]` listing the atom kinds inspected.
75
- * @task T11378
76
- * @adr ADR-051
77
- */
78
- export declare function judgeTaskCompletion(targetTaskId: string, cwd?: string): Promise<GoalJudgeVerdict>;
79
- /**
80
- * A deterministic, offline {@link GoalJudge} that always returns a fixed
81
- * verdict. Wired in tests (and as a safe default in non-LLM contexts) so the
82
- * fuzzy path is fully exercised without a live model call.
83
- *
84
- * Production wires a real LLM-backed implementation of {@link GoalJudge}; this
85
- * stub exists so the goal loop has a hermetic fallback and so the gate
86
- * `GATE_EVIDENCE_REQUIREMENTS` import stays referenced for downstream tooling.
87
- *
88
- * @task T11378
89
- */
90
- export declare class StaticGoalJudge implements GoalJudge {
91
- private readonly verdict;
92
- /**
93
- * @param verdict - The verdict every {@link judge} call returns.
94
- */
95
- constructor(verdict: GoalJudgeVerdict);
96
- /**
97
- * Return the configured verdict, ignoring the goal entirely (deterministic).
98
- *
99
- * @param _goal - The goal under evaluation (unused — deterministic stub).
100
- * @returns The fixed verdict.
101
- */
102
- judge(_goal: GoalRecord): Promise<GoalJudgeVerdict>;
103
- }
104
- /**
105
- * The number of distinct critical gates the evidence judge inspects. Exposed so
106
- * callers/tests can assert the judge consulted the full {@link CRITICAL_GATES}
107
- * set without hard-coding the count, and to keep {@link GATE_EVIDENCE_REQUIREMENTS}
108
- * referenced as the SSoT the judge validates against.
109
- *
110
- * @task T11378
111
- */
112
- export declare const CRITICAL_GATE_COUNT: number;
113
- //# sourceMappingURL=judge.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"judge.d.ts","sourceRoot":"","sources":["../../src/goal/judge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,EACV,SAAS,EACT,gBAAgB,EAChB,UAAU,EACV,gBAAgB,EACjB,MAAM,qBAAqB,CAAC;AAY7B;;;;;;;;;;GAUG;AACH,eAAO,MAAM,cAAc,EAAE,SAAS,gBAAgB,EAGpD,CAAC;AAEH;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,SAAS,CAC7B,IAAI,EAAE,UAAU,EAChB,QAAQ,EAAE,SAAS,EACnB,GAAG,CAAC,EAAE,MAAM,GACX,OAAO,CAAC,gBAAgB,CAAC,CAM3B;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,mBAAmB,CACvC,YAAY,EAAE,MAAM,EACpB,GAAG,CAAC,EAAE,MAAM,GACX,OAAO,CAAC,gBAAgB,CAAC,CAkE3B;AAED;;;;;;;;;;GAUG;AACH,qBAAa,eAAgB,YAAW,SAAS;IAInC,OAAO,CAAC,QAAQ,CAAC,OAAO;IAHpC;;OAEG;gBAC0B,OAAO,EAAE,gBAAgB;IAEtD;;;;;OAKG;IACG,KAAK,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAG1D;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAE1B,CAAC"}