@cleocode/core 2026.6.14 → 2026.6.17

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 (152) hide show
  1. package/dist/check/pr-gate.d.ts +6 -2
  2. package/dist/check/pr-gate.d.ts.map +1 -1
  3. package/dist/check/pr-gate.js +14 -32
  4. package/dist/check/pr-gate.js.map +1 -1
  5. package/dist/config/config-repair.d.ts +70 -0
  6. package/dist/config/config-repair.d.ts.map +1 -0
  7. package/dist/config/config-repair.js +248 -0
  8. package/dist/config/config-repair.js.map +1 -0
  9. package/dist/config/registry.d.ts.map +1 -1
  10. package/dist/config/registry.js +4 -4
  11. package/dist/config/registry.js.map +1 -1
  12. package/dist/config.d.ts.map +1 -1
  13. package/dist/config.js +11 -10
  14. package/dist/config.js.map +1 -1
  15. package/dist/docs/export-document.js +58 -16
  16. package/dist/docs/export-document.js.map +2 -2
  17. package/dist/gc/cleanup.d.ts +23 -8
  18. package/dist/gc/cleanup.d.ts.map +1 -1
  19. package/dist/gc/cleanup.js +287 -22
  20. package/dist/gc/cleanup.js.map +1 -1
  21. package/dist/gc/janitor.d.ts +149 -0
  22. package/dist/gc/janitor.d.ts.map +1 -0
  23. package/dist/gc/janitor.js +760 -0
  24. package/dist/gc/janitor.js.map +1 -0
  25. package/dist/internal.d.ts +1 -0
  26. package/dist/internal.d.ts.map +1 -1
  27. package/dist/internal.js +3 -0
  28. package/dist/internal.js.map +1 -1
  29. package/dist/llm/cli-ops.d.ts +31 -4
  30. package/dist/llm/cli-ops.d.ts.map +1 -1
  31. package/dist/llm/cli-ops.js +110 -26
  32. package/dist/llm/cli-ops.js.map +1 -1
  33. package/dist/llm/credential-pool.d.ts +62 -0
  34. package/dist/llm/credential-pool.d.ts.map +1 -1
  35. package/dist/llm/credential-pool.js +161 -0
  36. package/dist/llm/credential-pool.js.map +1 -1
  37. package/dist/llm/cross-provider-selector.d.ts +254 -0
  38. package/dist/llm/cross-provider-selector.d.ts.map +1 -0
  39. package/dist/llm/cross-provider-selector.js +635 -0
  40. package/dist/llm/cross-provider-selector.js.map +1 -0
  41. package/dist/llm/index.d.ts +2 -0
  42. package/dist/llm/index.d.ts.map +1 -1
  43. package/dist/llm/index.js +1 -0
  44. package/dist/llm/index.js.map +1 -1
  45. package/dist/llm/local-model-fit.d.ts +260 -0
  46. package/dist/llm/local-model-fit.d.ts.map +1 -0
  47. package/dist/llm/local-model-fit.js +563 -0
  48. package/dist/llm/local-model-fit.js.map +1 -0
  49. package/dist/llm/plugin-facade.js +883 -231
  50. package/dist/llm/plugin-facade.js.map +3 -3
  51. package/dist/llm/provider-registry/builtin/ollama.d.ts +18 -0
  52. package/dist/llm/provider-registry/builtin/ollama.d.ts.map +1 -1
  53. package/dist/llm/provider-registry/builtin/ollama.js +20 -2
  54. package/dist/llm/provider-registry/builtin/ollama.js.map +1 -1
  55. package/dist/llm/role-resolver.d.ts.map +1 -1
  56. package/dist/llm/role-resolver.js +45 -10
  57. package/dist/llm/role-resolver.js.map +1 -1
  58. package/dist/llm/transports/codex-responses.d.ts +111 -88
  59. package/dist/llm/transports/codex-responses.d.ts.map +1 -1
  60. package/dist/llm/transports/codex-responses.js +456 -258
  61. package/dist/llm/transports/codex-responses.js.map +1 -1
  62. package/dist/release/index.d.ts +2 -2
  63. package/dist/release/index.d.ts.map +1 -1
  64. package/dist/release/index.js +1 -1
  65. package/dist/release/index.js.map +1 -1
  66. package/dist/release/reconcile.d.ts +97 -0
  67. package/dist/release/reconcile.d.ts.map +1 -1
  68. package/dist/release/reconcile.js +412 -5
  69. package/dist/release/reconcile.js.map +1 -1
  70. package/dist/resources/backend.d.ts +155 -0
  71. package/dist/resources/backend.d.ts.map +1 -0
  72. package/dist/resources/backend.js +23 -0
  73. package/dist/resources/backend.js.map +1 -0
  74. package/dist/resources/linux-backend.d.ts +167 -0
  75. package/dist/resources/linux-backend.d.ts.map +1 -0
  76. package/dist/resources/linux-backend.js +259 -0
  77. package/dist/resources/linux-backend.js.map +1 -0
  78. package/dist/resources/monitor.d.ts +230 -0
  79. package/dist/resources/monitor.d.ts.map +1 -0
  80. package/dist/resources/monitor.js +255 -0
  81. package/dist/resources/monitor.js.map +1 -0
  82. package/dist/resources/spawn-wrapper.d.ts +265 -0
  83. package/dist/resources/spawn-wrapper.d.ts.map +1 -0
  84. package/dist/resources/spawn-wrapper.js +304 -0
  85. package/dist/resources/spawn-wrapper.js.map +1 -0
  86. package/dist/selfimprove/budget.d.ts +11 -2
  87. package/dist/selfimprove/budget.d.ts.map +1 -1
  88. package/dist/selfimprove/budget.js +11 -2
  89. package/dist/selfimprove/budget.js.map +1 -1
  90. package/dist/selfimprove/fix-gen-context.d.ts +172 -0
  91. package/dist/selfimprove/fix-gen-context.d.ts.map +1 -0
  92. package/dist/selfimprove/fix-gen-context.js +218 -0
  93. package/dist/selfimprove/fix-gen-context.js.map +1 -0
  94. package/dist/selfimprove/fix-gen.d.ts +285 -0
  95. package/dist/selfimprove/fix-gen.d.ts.map +1 -0
  96. package/dist/selfimprove/fix-gen.js +346 -0
  97. package/dist/selfimprove/fix-gen.js.map +1 -0
  98. package/dist/selfimprove/op-source-map.d.ts +92 -0
  99. package/dist/selfimprove/op-source-map.d.ts.map +1 -0
  100. package/dist/selfimprove/op-source-map.js +187 -0
  101. package/dist/selfimprove/op-source-map.js.map +1 -0
  102. package/dist/selfimprove/probe-helper.d.ts +61 -0
  103. package/dist/selfimprove/probe-helper.d.ts.map +1 -0
  104. package/dist/selfimprove/probe-helper.js +64 -0
  105. package/dist/selfimprove/probe-helper.js.map +1 -0
  106. package/dist/selfimprove/run-loop.d.ts +44 -4
  107. package/dist/selfimprove/run-loop.d.ts.map +1 -1
  108. package/dist/selfimprove/run-loop.js +73 -6
  109. package/dist/selfimprove/run-loop.js.map +1 -1
  110. package/dist/selfimprove/scenarios/seeded-code-regression/golden.json +18 -0
  111. package/dist/selfimprove/scenarios/seeded-code-regression/scenario.json +12 -0
  112. package/dist/sentient/cross-project-hygiene.d.ts +11 -2
  113. package/dist/sentient/cross-project-hygiene.d.ts.map +1 -1
  114. package/dist/sentient/cross-project-hygiene.js +73 -10
  115. package/dist/sentient/cross-project-hygiene.js.map +1 -1
  116. package/dist/sentient/daemon.d.ts.map +1 -1
  117. package/dist/sentient/daemon.js +7 -2
  118. package/dist/sentient/daemon.js.map +1 -1
  119. package/dist/sentient/worktree-dispatch.d.ts.map +1 -1
  120. package/dist/sentient/worktree-dispatch.js +8 -1
  121. package/dist/sentient/worktree-dispatch.js.map +1 -1
  122. package/dist/setup/index.d.ts +1 -0
  123. package/dist/setup/index.d.ts.map +1 -1
  124. package/dist/setup/index.js +1 -0
  125. package/dist/setup/index.js.map +1 -1
  126. package/dist/setup/sections/models-roles.d.ts +32 -1
  127. package/dist/setup/sections/models-roles.d.ts.map +1 -1
  128. package/dist/setup/sections/models-roles.js +118 -19
  129. package/dist/setup/sections/models-roles.js.map +1 -1
  130. package/dist/setup/whoami-summary.d.ts +34 -0
  131. package/dist/setup/whoami-summary.d.ts.map +1 -0
  132. package/dist/setup/whoami-summary.js +106 -0
  133. package/dist/setup/whoami-summary.js.map +1 -0
  134. package/dist/spawn/branch-lock.d.ts.map +1 -1
  135. package/dist/spawn/branch-lock.js +7 -1
  136. package/dist/spawn/branch-lock.js.map +1 -1
  137. package/dist/store/attachment-repair.d.ts +110 -0
  138. package/dist/store/attachment-repair.d.ts.map +1 -0
  139. package/dist/store/attachment-repair.js +326 -0
  140. package/dist/store/attachment-repair.js.map +1 -0
  141. package/dist/store/attachment-store.d.ts.map +1 -1
  142. package/dist/store/attachment-store.js +24 -7
  143. package/dist/store/attachment-store.js.map +1 -1
  144. package/dist/tasks/evidence.d.ts +34 -2
  145. package/dist/tasks/evidence.d.ts.map +1 -1
  146. package/dist/tasks/evidence.js +293 -35
  147. package/dist/tasks/evidence.js.map +1 -1
  148. package/dist/verification/verify-tools.d.ts.map +1 -1
  149. package/dist/verification/verify-tools.js +5 -6
  150. package/dist/verification/verify-tools.js.map +1 -1
  151. package/package.json +22 -12
  152. package/templates/workflows/release-prepare.yml.tmpl +48 -2
@@ -0,0 +1,304 @@
1
+ /**
2
+ * Slice-aware launch-wrapper SSoT (T11993 · Epic T11992).
3
+ *
4
+ * This module is the ONLY constructor of `systemd-run` argv for cleo children.
5
+ * Every consumer that needs to launch a cleo child in a memory-capped cgroup
6
+ * MUST call {@link buildSpawnArgs} or {@link spawnWrapped} here instead of
7
+ * constructing `systemd-run` arguments ad-hoc.
8
+ *
9
+ * ## Design
10
+ *
11
+ * Children are placed inside `cleo.slice` when systemd is available:
12
+ *
13
+ * ```
14
+ * cleo.slice
15
+ * ├── cleo-daemon.service (managed by the daemon service unit)
16
+ * └── cleo-<scopeClass>-<n>.scope (transient scopes for child spawns)
17
+ * ```
18
+ *
19
+ * The slice applies MemoryHigh (primary soft throttle) and MemoryMax (hard
20
+ * safety net) at the slice level, shared across all members. Child scopes
21
+ * inherit these limits and may override them downward.
22
+ *
23
+ * ## Staged P1 budget (IMPORTANT — read before tuning)
24
+ *
25
+ * P1 ships MemoryHigh within 5 % of MemoryMax (80 % / 85 % of a reference
26
+ * host total) so that reclaim stalls under the soft limit NEVER block the
27
+ * SQLite WAL write-transaction held by a slice member. A stalled scope
28
+ * holding a WAL write-txn for > 30 s (busy_timeout) cascades SQLITE_BUSY to
29
+ * every other slice member.
30
+ *
31
+ * **P1 installed values (safe defaults):**
32
+ * - `MemoryHigh = undefined` (disabled — no throttle in P1)
33
+ * - `MemoryMax = 32G` (hard cap, benign cgroup kill)
34
+ *
35
+ * The 60 % / 85 % target shape is documented here and in `DEFAULT_SLICE_CONFIG`
36
+ * as the P2 goal once the stall-escalator (T11994) is in place.
37
+ *
38
+ * **With `MemorySwapMax=0`:** reclaim has only page-cache to chew against
39
+ * `MemoryHigh` on anonymous heaps — admission (P2) becomes the primary
40
+ * control, throttling is not load-bearing in P1.
41
+ *
42
+ * ## oomd-avoid (selective)
43
+ *
44
+ * `ManagedOOMPreference=avoid` is applied ONLY to daemon/db-heavy scope
45
+ * classes (`'daemon'`, `'db'`). Bulk agent/test scopes do NOT get `avoid`
46
+ * because Fedora oomd monitors `user@1000.service` at 80 %/20 s and ranks
47
+ * avoid-marked candidates last — blanket avoid redirects oomd kills onto
48
+ * innocent user apps.
49
+ *
50
+ * ## Fallback
51
+ *
52
+ * On hosts without systemd-run (macOS, CI containers, minimal installs)
53
+ * the wrapper degrades log-once to plain `spawn` in a new process-group
54
+ * with NODE_OPTIONS heap cap inherited from the caller. This is mirrored
55
+ * from the writer-lease `pgid-demotion` pattern.
56
+ *
57
+ * ## Return value — ownership handle (T11998 / T11995)
58
+ *
59
+ * {@link SpawnWrappedResult} carries `{ unitName?, pid, mode }` so the
60
+ * suite-containment epic (T11998) and the janitor (T11995) can look up or
61
+ * clean up the transient scope by unit name.
62
+ *
63
+ * @module @cleocode/core/resources/spawn-wrapper
64
+ * @epic T11992
65
+ * @task T11993
66
+ */
67
+ import { spawn, spawnSync } from 'node:child_process';
68
+ import { readFileSync } from 'node:fs';
69
+ // ---------------------------------------------------------------------------
70
+ // Constants
71
+ // ---------------------------------------------------------------------------
72
+ /**
73
+ * The systemd user slice that all cleo child scopes are placed under.
74
+ *
75
+ * The slice unit (`~/.config/systemd/user/cleo.slice`) must be installed
76
+ * by the doctor/install flow before this is effective. Placing an orphan
77
+ * scope under a non-existent slice degrades silently to the default slice —
78
+ * so the slice install is best-effort and the wrapper is always safe to call.
79
+ */
80
+ export const CLEO_SLICE = 'cleo.slice';
81
+ /**
82
+ * Default per-scope memory resource config (P1 staged values).
83
+ *
84
+ * P1: MemoryHigh disabled, MemoryMax=32G.
85
+ * P2 target (after T11994 stall-escalator lands): memoryHigh=0.60, memoryMax=0.85.
86
+ */
87
+ export const DEFAULT_SCOPE_RESOURCES = {
88
+ memoryHigh: 'infinity', // P1: disabled — no throttle (safe until P2 stall-escalator)
89
+ memoryMax: '32G', // P1: hard cap (benign cgroup kill; coredumps suppressed via ulimit -c 0)
90
+ };
91
+ /**
92
+ * Scope classes that receive `ManagedOOMPreference=avoid`.
93
+ *
94
+ * Only write-transaction holders (daemon, db) are marked `avoid` to prevent
95
+ * mid-txn oomd kills. See module-level TSDoc for the Fedora oomd rationale.
96
+ */
97
+ const OOM_AVOID_CLASSES = new Set(['daemon', 'db']);
98
+ // ---------------------------------------------------------------------------
99
+ // Internal helpers
100
+ // ---------------------------------------------------------------------------
101
+ /**
102
+ * Is `systemd-run` available on this host? Probed once and cached.
103
+ * Mirrors the probe in `packages/core/src/check/pr-gate.ts`.
104
+ */
105
+ let _systemdRunAvailable;
106
+ /**
107
+ * Check whether `systemd-run --user` is usable on this host.
108
+ *
109
+ * Returns `false` on non-Linux, when systemd-run is not on PATH, or when
110
+ * DBUS_SESSION_BUS_ADDRESS / XDG_RUNTIME_DIR are absent (CI containers,
111
+ * ssh sessions without a user bus).
112
+ */
113
+ export function hasSystemdRun() {
114
+ if (_systemdRunAvailable !== undefined)
115
+ return _systemdRunAvailable;
116
+ if (process.platform !== 'linux') {
117
+ _systemdRunAvailable = false;
118
+ return false;
119
+ }
120
+ // Quick binary availability check — does NOT test user-bus connectivity.
121
+ const probe = spawnSync('systemd-run', ['--version'], { stdio: 'ignore' });
122
+ _systemdRunAvailable = probe.status === 0;
123
+ return _systemdRunAvailable;
124
+ }
125
+ /**
126
+ * Force-override the cached systemd-run availability.
127
+ *
128
+ * Exposed for unit tests that need to exercise the pgid-fallback or
129
+ * systemd paths without the real binary.
130
+ *
131
+ * @param available - `true` = force systemd path, `false` = force pgid path.
132
+ */
133
+ export function _forceSystemdRunAvailable(available) {
134
+ _systemdRunAvailable = available;
135
+ }
136
+ /** Whether we have already emitted the pgid-demotion log line for this process. */
137
+ let _pgidDemotionLogged = false;
138
+ /**
139
+ * Resolve a memory value to a systemd property string.
140
+ *
141
+ * Numbers in (0, 1] are treated as fractions of a `totalBytes` reference.
142
+ * Strings are passed through verbatim. `undefined` / `'infinity'` resolves
143
+ * to `'infinity'` (disabled).
144
+ */
145
+ function resolveMemoryValue(val, totalBytes) {
146
+ if (val === undefined || val === 'infinity')
147
+ return 'infinity';
148
+ if (typeof val === 'string')
149
+ return val;
150
+ // Fraction: multiply by total and round to nearest mebibyte boundary.
151
+ const bytes = Math.round(val * totalBytes);
152
+ const mib = Math.round(bytes / (1024 * 1024));
153
+ return `${mib}M`;
154
+ }
155
+ /**
156
+ * Read /proc/meminfo MemTotal in bytes. Returns 32 GiB as a safe fallback
157
+ * when unavailable (non-Linux, CI, permission denied).
158
+ */
159
+ function readMemTotalBytes() {
160
+ if (process.platform !== 'linux')
161
+ return 32 * 1024 * 1024 * 1024;
162
+ try {
163
+ const raw = readFileSync('/proc/meminfo', 'utf8');
164
+ const m = raw.match(/^MemTotal:\s+(\d+)\s+kB/m);
165
+ if (m?.[1])
166
+ return parseInt(m[1], 10) * 1024;
167
+ }
168
+ catch {
169
+ // ignore
170
+ }
171
+ return 32 * 1024 * 1024 * 1024;
172
+ }
173
+ /** Counter for generating unique scope discriminators within a process. */
174
+ let _scopeCounter = 0;
175
+ // ---------------------------------------------------------------------------
176
+ // Core API
177
+ // ---------------------------------------------------------------------------
178
+ /**
179
+ * Build the argv for a cleo child spawn.
180
+ *
181
+ * When `systemd-run` is available, the result is:
182
+ *
183
+ * ```
184
+ * ['systemd-run', '--user', '--scope', '--slice=cleo.slice',
185
+ * '--unit=cleo-<class>-<id>.scope',
186
+ * '-p', 'MemoryHigh=<high>', '-p', 'MemoryMax=<max>',
187
+ * '-p', 'MemorySwapMax=0',
188
+ * ['-p', 'ManagedOOMPreference=avoid'], // daemon/db only
189
+ * '--',
190
+ * // when noCoreFile=true (default):
191
+ * 'sh', '-c', 'ulimit -c 0; exec "$@"', 'sh', command, ...args
192
+ * // when noCoreFile=false:
193
+ * command, ...args]
194
+ * ```
195
+ *
196
+ * `LimitCORE` is intentionally NOT used — it is a service-unit EXEC property
197
+ * and is rejected by `systemd-run --scope` with "Unknown assignment: LimitCORE".
198
+ * Core-dump suppression is applied at the process level instead via
199
+ * `ulimit -c 0` (POSIX sh, works in both systemd and pgid-fallback paths).
200
+ *
201
+ * When `systemd-run` is NOT available, the result is `[command, ...args]`
202
+ * (or the sh/ulimit-wrapped form when noCoreFile=true) and `mode` is `'pgid'`.
203
+ *
204
+ * @param command - The executable to run (e.g. `'node'`).
205
+ * @param args - Arguments to pass to the executable.
206
+ * @param opts - Wrapper options (scope class, resources, etc.).
207
+ * @returns Build result with final command, args, mode, and unit name.
208
+ */
209
+ export function buildSpawnArgs(command, args, opts = {}) {
210
+ const { scopeClass = 'agent', scopeId, resources = {}, noCoreFile = true } = opts;
211
+ if (!hasSystemdRun()) {
212
+ if (!_pgidDemotionLogged) {
213
+ _pgidDemotionLogged = true;
214
+ process.stderr.write('[cleo:spawn-wrapper] systemd-run unavailable — falling back to plain pgid spawn ' +
215
+ '(no cgroup containment; set NODE_OPTIONS=--max-old-space-size=<mb> externally)\n');
216
+ }
217
+ if (noCoreFile) {
218
+ // Apply ulimit -c 0 in the pgid path as well so core suppression is
219
+ // consistent regardless of whether systemd is available.
220
+ return {
221
+ command: 'sh',
222
+ args: ['-c', 'ulimit -c 0; exec "$@"', 'sh', command, ...args],
223
+ mode: 'pgid',
224
+ };
225
+ }
226
+ return { command, args: [...args], mode: 'pgid' };
227
+ }
228
+ const totalBytes = readMemTotalBytes();
229
+ const merged = {
230
+ memoryHigh: resources.memoryHigh ?? DEFAULT_SCOPE_RESOURCES.memoryHigh,
231
+ memoryMax: resources.memoryMax ?? DEFAULT_SCOPE_RESOURCES.memoryMax,
232
+ };
233
+ const highStr = resolveMemoryValue(merged.memoryHigh, totalBytes);
234
+ const maxStr = resolveMemoryValue(merged.memoryMax, totalBytes);
235
+ // Build a deterministic, unique unit name.
236
+ const counter = ++_scopeCounter;
237
+ const discriminator = scopeId ? scopeId.replace(/[^a-zA-Z0-9-]/g, '-') : String(counter);
238
+ const unitName = `cleo-${scopeClass}-${discriminator}.scope`;
239
+ const wrapArgs = [
240
+ '--user',
241
+ '--scope',
242
+ `--slice=${CLEO_SLICE}`,
243
+ `--unit=${unitName}`,
244
+ '-p',
245
+ `MemoryMax=${maxStr}`,
246
+ '-p',
247
+ 'MemorySwapMax=0',
248
+ ];
249
+ // MemoryHigh: only emit the directive when it is a real limit (not infinity).
250
+ if (highStr !== 'infinity') {
251
+ wrapArgs.push('-p', `MemoryHigh=${highStr}`);
252
+ }
253
+ // Selective oomd-avoid: only for write-txn holder classes.
254
+ if (OOM_AVOID_CLASSES.has(scopeClass)) {
255
+ wrapArgs.push('-p', 'ManagedOOMPreference=avoid');
256
+ }
257
+ if (noCoreFile) {
258
+ // LimitCORE is a service-unit EXEC property — it is NOT valid on scope
259
+ // units and causes systemd-run to reject the argv with:
260
+ // "Unknown assignment: LimitCORE=0"
261
+ // Suppress coredumps at the process level instead: wrap the inner command
262
+ // in a tiny sh fragment that sets `ulimit -c 0` then execs the real binary.
263
+ // This is equivalent to LimitCORE for our purposes and works on both
264
+ // Fedora and Ubuntu CI runners.
265
+ wrapArgs.push('--', 'sh', '-c', 'ulimit -c 0; exec "$@"', 'sh', command, ...args);
266
+ }
267
+ else {
268
+ wrapArgs.push('--', command, ...args);
269
+ }
270
+ return {
271
+ command: 'systemd-run',
272
+ args: wrapArgs,
273
+ mode: 'systemd',
274
+ unitName,
275
+ };
276
+ }
277
+ /**
278
+ * Spawn a command wrapped in a cleo.slice transient cgroup scope.
279
+ *
280
+ * This is a thin convenience wrapper over {@link buildSpawnArgs} +
281
+ * Node.js `child_process.spawn`. All cleo child spawns SHOULD route through
282
+ * this function instead of constructing `systemd-run` arguments inline.
283
+ *
284
+ * The returned {@link SpawnWrappedResult} carries `unitName` — the systemd
285
+ * transient scope unit name — as the ownership/cleanup handle for
286
+ * T11998 (suite containment) and T11995 (janitor).
287
+ *
288
+ * @param command - The executable to run.
289
+ * @param args - Arguments to pass to the executable.
290
+ * @param spawnOpts - Options forwarded to `child_process.spawn`.
291
+ * @param wrapOpts - Wrapper options (scope class, resources, etc.).
292
+ * @returns Wrapped spawn result.
293
+ */
294
+ export function spawnWrapped(command, args, spawnOpts = {}, wrapOpts = {}) {
295
+ const built = buildSpawnArgs(command, args, wrapOpts);
296
+ const child = spawn(built.command, built.args, spawnOpts);
297
+ return {
298
+ child,
299
+ pid: child.pid,
300
+ mode: built.mode,
301
+ unitName: built.unitName,
302
+ };
303
+ }
304
+ //# sourceMappingURL=spawn-wrapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spawn-wrapper.js","sourceRoot":"","sources":["../../src/resources/spawn-wrapper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiEG;AAEH,OAAO,EAAqB,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAkIvC,8EAA8E;AAC9E,YAAY;AACZ,8EAA8E;AAE9E;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,YAAqB,CAAC;AAEhD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAkC;IACpE,UAAU,EAAE,UAAU,EAAE,6DAA6D;IACrF,SAAS,EAAE,KAAK,EAAE,0EAA0E;CAC7F,CAAC;AAEF;;;;;GAKG;AACH,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAa,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC;AAEhE,8EAA8E;AAC9E,mBAAmB;AACnB,8EAA8E;AAE9E;;;GAGG;AACH,IAAI,oBAAyC,CAAC;AAE9C;;;;;;GAMG;AACH,MAAM,UAAU,aAAa;IAC3B,IAAI,oBAAoB,KAAK,SAAS;QAAE,OAAO,oBAAoB,CAAC;IACpE,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;QACjC,oBAAoB,GAAG,KAAK,CAAC;QAC7B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,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AE,GAAG,IAAI,CAAC,CAAC;IACxC,CAAC;IAED,OAAO;QACL,OAAO,EAAE,aAAa;QACtB,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,SAAS;QACf,QAAQ;KACT,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,YAAY,CAC1B,OAAe,EACf,IAAuB,EACvB,YAAyC,EAAE,EAC3C,WAAkC,EAAE;IAEpC,MAAM,KAAK,GAAG,cAAc,CAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;IACtD,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAC1D,OAAO;QACL,KAAK;QACL,GAAG,EAAE,KAAK,CAAC,GAAG;QACd,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,QAAQ,EAAE,KAAK,CAAC,QAAQ;KACzB,CAAC;AACJ,CAAC"}
@@ -75,13 +75,22 @@ export interface SelfImproveBudget {
75
75
  */
76
76
  export declare const DEFAULT_BUDGET: SelfImproveBudget;
77
77
  /**
78
+ * @deprecated Use {@link "../resources/spawn-wrapper.js".buildSpawnArgs} instead.
79
+ *
78
80
  * The launch-boundary memory cap — an OPERATIONAL wrapper, NOT an in-code cap.
79
81
  *
80
82
  * A CORE function cannot portably self-confine to a cgroup (`systemd-run` is
81
83
  * Linux-only; re-exec'ing under it from inside the engine is fragile), so the
82
84
  * runbook / spawn wrapper that invokes `cleo selfimprove run` wraps it on Linux.
83
- * On macOS the gondolin VM's own `memory` option bounds the guest. Exported as a
84
- * documented constant so the spawn wrapper and the runbook share one SSoT string.
85
+ * On macOS the gondolin VM's own `memory` option bounds the guest.
86
+ *
87
+ * **Retired (T11993)**: callers should use
88
+ * `buildSpawnArgs('cleo', ['selfimprove', 'run', ...], {}, { scopeClass: 'agent' })`
89
+ * from `@cleocode/core/resources/spawn-wrapper` instead. This constant remains
90
+ * exported only for backward compatibility until all doc references are updated.
91
+ *
92
+ * The new SSoT places children under `cleo.slice` with coredumps suppressed
93
+ * via `ulimit -c 0` and staged memory budgets (see spawn-wrapper module TSDoc).
85
94
  */
86
95
  export declare const MEMORY_MAX_LAUNCH_WRAPPER: "systemd-run --user --scope -p MemoryMax=32G -p MemorySwapMax=0";
87
96
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"budget.d.ts","sourceRoot":"","sources":["../../src/selfimprove/budget.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH;;;;;GAKG;AACH,MAAM,MAAM,oBAAoB;AAC9B,mEAAmE;AACjE,SAAS;AACX,+EAA+E;GAC7E,kBAAkB;AACpB,+DAA+D;GAC7D,eAAe;AACjB,6CAA6C;GAC3C,SAAS,CAAC;AAEd;;;;;;;;;;GAUG;AACH,MAAM,WAAW,iBAAiB;IAChC,uDAAuD;IACvD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,8CAA8C;IAC9C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,2DAA2D;IAC3D,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,8DAA8D;IAC9D,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;CAC/B;AAED;;;;GAIG;AACH,eAAO,MAAM,cAAc,EAAE,iBAK5B,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,yBAAyB,EACpC,gEAAyE,CAAC;AAE5E;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,2BAA2B;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,wBAAwB;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,+BAA+B;IAC/B,GAAG,EAAE,MAAM,CAAC;IACZ,kCAAkC;IAClC,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,2CAA2C;AAC3C,wBAAgB,UAAU,IAAI,WAAW,CAExC;AAED;;;GAGG;AACH,M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,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI;CA2BzC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAC3B,SAAS,GAAE,OAAO,CAAC,iBAAiB,CAAM,EAC1C,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC,iBAAiB,CAenB"}
@@ -44,13 +44,22 @@ export const DEFAULT_BUDGET = {
44
44
  maxWorktrees: 1,
45
45
  };
46
46
  /**
47
+ * @deprecated Use {@link "../resources/spawn-wrapper.js".buildSpawnArgs} instead.
48
+ *
47
49
  * The launch-boundary memory cap — an OPERATIONAL wrapper, NOT an in-code cap.
48
50
  *
49
51
  * A CORE function cannot portably self-confine to a cgroup (`systemd-run` is
50
52
  * Linux-only; re-exec'ing under it from inside the engine is fragile), so the
51
53
  * runbook / spawn wrapper that invokes `cleo selfimprove run` wraps it on Linux.
52
- * On macOS the gondolin VM's own `memory` option bounds the guest. Exported as a
53
- * documented constant so the spawn wrapper and the runbook share one SSoT string.
54
+ * On macOS the gondolin VM's own `memory` option bounds the guest.
55
+ *
56
+ * **Retired (T11993)**: callers should use
57
+ * `buildSpawnArgs('cleo', ['selfimprove', 'run', ...], {}, { scopeClass: 'agent' })`
58
+ * from `@cleocode/core/resources/spawn-wrapper` instead. This constant remains
59
+ * exported only for backward compatibility until all doc references are updated.
60
+ *
61
+ * The new SSoT places children under `cleo.slice` with coredumps suppressed
62
+ * via `ulimit -c 0` and staged memory budgets (see spawn-wrapper module TSDoc).
54
63
  */
55
64
  export const MEMORY_MAX_LAUNCH_WRAPPER = 'systemd-run --user --scope -p MemoryMax=32G -p MemorySwapMax=0';
56
65
  /** A fresh, zeroed {@link BudgetSpend}. */
@@ -1 +1 @@
1
- {"version":3,"file":"budget.js","sourceRoot":"","sources":["../../src/selfimprove/budget.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAwCH;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAA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AS,CAAC,MAAM,IAAI,cAAc,CAAC,MAAM,CAAC,CAAC;IACtE,MAAM,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,SAAS,CAAC,YAAY,IAAI,cAAc,CAAC,YAAY,CAAC,CAAC;IAExF,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC;AACrD,CAAC"}
@@ -0,0 +1,172 @@
1
+ /**
2
+ * Bounded file-content loader for the fix-gen stage (T11988).
3
+ *
4
+ * The self-improvement fix-gen stage builds a prompt for the LLM
5
+ * ({@link "./fix-gen.js".buildFixGenPrompt}). Without file context the model
6
+ * can only see the regression diff entries (e.g.
7
+ * `op tasks.show (#0) at data/task/status: actual="pending" expected="active"`)
8
+ * and rationally responds `NO_PATCH` because it cannot locate the responsible code.
9
+ *
10
+ * This module resolves the relevant source files for each regressing op-coordinate
11
+ * via the static map ({@link "./op-source-map.js"}) and reads their content with a
12
+ * **hard context budget** so the prompt stays bounded regardless of file size.
13
+ *
14
+ * ## Budget model
15
+ *
16
+ * Two independent byte-level caps:
17
+ *
18
+ * - `perFileBudget` (default {@link DEFAULT_PER_FILE_BUDGET}): the maximum bytes
19
+ * read from any single file. Files larger than this are truncated at a
20
+ * newline boundary and a `<… TRUNCATED …>` marker is appended.
21
+ * - `totalBudget` (default {@link DEFAULT_TOTAL_BUDGET}): the maximum total bytes
22
+ * across ALL included files. Files are added in order (handler files first, then
23
+ * core files); once the total would be exceeded the remaining files are
24
+ * summarised as a path-only `<file listed but not loaded — budget exhausted>` stub.
25
+ *
26
+ * The caller embeds the resolved {@link LoadedFileContext} into the prompt. The LLM
27
+ * prompt builder ({@link "./fix-gen.js".buildFixGenPrompt}) inserts the file blocks
28
+ * between the regression description and the "produce the diff" instruction, giving
29
+ * the model concrete code to work from.
30
+ *
31
+ * Import-time side-effect-free: no logger init, no native handles.
32
+ *
33
+ * @module @cleocode/core/selfimprove/fix-gen-context
34
+ * @epic T11889
35
+ * @task T11988
36
+ */
37
+ /**
38
+ * Per-file byte cap (default): any single file is truncated to at most 24 KB
39
+ * before being included in the prompt. Chosen to comfortably fit a large-ish
40
+ * handler or core module without overwhelming the model context.
41
+ */
42
+ export declare const DEFAULT_PER_FILE_BUDGET = 24576;
43
+ /**
44
+ * Total byte cap (default): the combined content of all included files must not
45
+ * exceed 65 KB. Keeps the combined code context section to a model-digestible
46
+ * slice of the context window even when multiple files are included.
47
+ */
48
+ export declare const DEFAULT_TOTAL_BUDGET = 65536;
49
+ /** Options for {@link loadFileContext}. */
50
+ export interface LoadFileContextOptions {
51
+ /**
52
+ * Absolute project root. Source files are resolved relative to this path.
53
+ * Must be set to the actual repo root for the paths from the op-source-map
54
+ * to resolve correctly.
55
+ */
56
+ readonly projectRoot: string;
57
+ /**
58
+ * The op-coordinates whose source files should be loaded (e.g. `['tasks.show']`).
59
+ * Resolved via {@link collectOpSourceFiles}.
60
+ */
61
+ readonly opCoords: readonly string[];
62
+ /**
63
+ * Per-file byte budget (defaults to {@link DEFAULT_PER_FILE_BUDGET}).
64
+ * Files exceeding this are truncated with a `<… TRUNCATED …>` marker.
65
+ */
66
+ readonly perFileBudget?: number;
67
+ /**
68
+ * Total byte budget for all files combined
69
+ * (defaults to {@link DEFAULT_TOTAL_BUDGET}).
70
+ * Files whose content would push the total over budget are listed but not
71
+ * loaded (their path is emitted as a stub).
72
+ */
73
+ readonly totalBudget?: number;
74
+ }
75
+ /** A single file included in the context (content loaded or stubbed). */
76
+ export interface FileContextEntry {
77
+ /** Repo-relative path (as returned by the op-source-map). */
78
+ readonly repoRelativePath: string;
79
+ /**
80
+ * File content (possibly truncated if `truncated` is `true`). `null` when the
81
+ * file was skipped due to the total budget being exhausted or a read error.
82
+ */
83
+ readonly content: string | null;
84
+ /**
85
+ * `true` when the file was truncated at the per-file budget; the loaded
86
+ * `content` ends with a `<… TRUNCATED …>` marker.
87
+ */
88
+ readonly truncated: boolean;
89
+ /**
90
+ * `true` when the total budget was exhausted before this file was loaded. The
91
+ * file appears in the context list but its `content` is `null`.
92
+ */
93
+ readonly budgetExhausted: boolean;
94
+ /**
95
+ * `true` when the file could not be read (missing, permission error, etc.).
96
+ * The file appears in the context list with `content: null`.
97
+ */
98
+ readonly readError: boolean;
99
+ }
100
+ /** Resolved file context for a set of op-coordinates. */
101
+ export interface LoadedFileContext {
102
+ /** The resolved file entries (handler files first, then core files). */
103
+ readonly entries: readonly FileContextEntry[];
104
+ /** Total bytes of loaded content (across all non-skipped entries). */
105
+ readonly totalBytes: number;
106
+ /** Number of files that were truncated due to the per-file budget. */
107
+ readonly truncatedCount: number;
108
+ /** Number of files that were skipped due to the total budget. */
109
+ readonly budgetSkippedCount: number;
110
+ /** Number of files that could not be read. */
111
+ readonly errorCount: number;
112
+ }
113
+ /**
114
+ * Truncate `content` to at most `maxBytes` bytes, cutting at a newline boundary
115
+ * wherever possible, and appending a marker.
116
+ *
117
+ * Operates on raw bytes via `Buffer` so multi-byte characters don't produce
118
+ * partial surrogate pairs in the truncated output.
119
+ *
120
+ * @param content - The full file content string.
121
+ * @param maxBytes - The per-file byte cap.
122
+ * @returns `{ text, truncated }` — the (possibly shortened) string and a flag.
123
+ * @internal
124
+ */
125
+ export declare function truncateToByteLimit(content: string, maxBytes: number): {
126
+ text: string;
127
+ truncated: boolean;
128
+ };
129
+ /**
130
+ * Load bounded file content for the op-coordinates in a fix-gen request.
131
+ *
132
+ * Resolves the handler + core files for each `opCoord` via
133
+ * {@link collectOpSourceFiles}, reads them against `projectRoot`, applies the
134
+ * per-file and total byte budgets, and returns a structured
135
+ * {@link LoadedFileContext} describing every entry (loaded, truncated, skipped, or
136
+ * errored). NEVER throws — read errors produce `{ content: null, readError: true }`.
137
+ *
138
+ * @param opts - See {@link LoadFileContextOptions}.
139
+ * @returns The resolved {@link LoadedFileContext}.
140
+ *
141
+ * @example
142
+ * ```ts
143
+ * const ctx = loadFileContext({
144
+ * projectRoot: '/repo',
145
+ * opCoords: ['tasks.show'],
146
+ * });
147
+ * // ctx.entries[0].repoRelativePath === 'packages/cleo/src/dispatch/domains/tasks.ts'
148
+ * // ctx.entries[1].repoRelativePath === 'packages/core/src/tasks/show.ts'
149
+ * // ctx.totalBytes <= DEFAULT_TOTAL_BUDGET
150
+ * ```
151
+ */
152
+ export declare function loadFileContext(opts: LoadFileContextOptions): LoadedFileContext;
153
+ /**
154
+ * Render a {@link LoadedFileContext} as the file-context section of a fix-gen
155
+ * prompt.
156
+ *
157
+ * Produces a human-readable block listing each file with its content (or a stub
158
+ * explaining why the content was omitted). Suitable for direct embedding in the
159
+ * LLM user-turn after the regression description.
160
+ *
161
+ * @param ctx - The loaded file context.
162
+ * @returns A string ready for embedding in the prompt (empty string when no files).
163
+ *
164
+ * @example
165
+ * ```ts
166
+ * const section = renderFileContextSection(ctx);
167
+ * // --- packages/core/src/tasks/show.ts ---
168
+ * // <content or stub>
169
+ * ```
170
+ */
171
+ export declare function renderFileContextSection(ctx: LoadedFileContext): string;
172
+ //# sourceMappingURL=fix-gen-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fix-gen-context.d.ts","sourceRoot":"","sources":["../../src/selfimprove/fix-gen-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAQH;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,QAAS,CAAC;AAE9C;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,QAAS,CAAC;AAI3C,2CAA2C;AAC3C,MAAM,WAAW,sBAAsB;IACrC;;;;OAIG;IACH,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC;;;OAGG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC;;;;;OAKG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED,yEAAyE;AACzE,M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