@cleocode/core 2026.6.12 → 2026.6.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/conduit/local-transport.d.ts +12 -0
- package/dist/conduit/local-transport.d.ts.map +1 -1
- package/dist/conduit/local-transport.js +53 -23
- package/dist/conduit/local-transport.js.map +1 -1
- package/dist/crypto/credentials.d.ts +37 -0
- package/dist/crypto/credentials.d.ts.map +1 -1
- package/dist/crypto/credentials.js +110 -0
- package/dist/crypto/credentials.js.map +1 -1
- package/dist/dispatch/contracts/derive-output-contract.d.ts +86 -0
- package/dist/dispatch/contracts/derive-output-contract.d.ts.map +1 -0
- package/dist/dispatch/contracts/derive-output-contract.js +347 -0
- package/dist/dispatch/contracts/derive-output-contract.js.map +1 -0
- package/dist/dispatch/contracts/ensures-schema.d.ts +77 -0
- package/dist/dispatch/contracts/ensures-schema.d.ts.map +1 -0
- package/dist/dispatch/contracts/ensures-schema.js +91 -0
- package/dist/dispatch/contracts/ensures-schema.js.map +1 -0
- package/dist/dispatch/contracts/output-contracts.d.ts +27 -5
- package/dist/dispatch/contracts/output-contracts.d.ts.map +1 -1
- package/dist/dispatch/contracts/output-contracts.js +29 -6
- package/dist/dispatch/contracts/output-contracts.js.map +1 -1
- package/dist/docs/export-document.js +2294 -1250
- package/dist/docs/export-document.js.map +3 -3
- package/dist/go/driver.d.ts +132 -7
- package/dist/go/driver.d.ts.map +1 -1
- package/dist/go/driver.js +135 -10
- package/dist/go/driver.js.map +1 -1
- package/dist/go/index.d.ts +1 -1
- package/dist/go/index.d.ts.map +1 -1
- package/dist/go/index.js +1 -1
- package/dist/go/index.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +13 -10
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +11 -11
- package/dist/internal.js.map +1 -1
- package/dist/lifecycle/engine-ops.d.ts.map +1 -1
- package/dist/lifecycle/engine-ops.js +7 -4
- package/dist/lifecycle/engine-ops.js.map +1 -1
- package/dist/lifecycle/ivtr-loop.d.ts +108 -183
- package/dist/lifecycle/ivtr-loop.d.ts.map +1 -1
- package/dist/lifecycle/ivtr-loop.js +207 -522
- package/dist/lifecycle/ivtr-loop.js.map +1 -1
- package/dist/llm/auxiliary-fallback.js +1 -1
- package/dist/llm/auxiliary-fallback.js.map +1 -1
- package/dist/llm/cli-ops.d.ts +14 -1
- package/dist/llm/cli-ops.d.ts.map +1 -1
- package/dist/llm/cli-ops.js +41 -12
- package/dist/llm/cli-ops.js.map +1 -1
- package/dist/llm/concrete-session.d.ts.map +1 -1
- package/dist/llm/concrete-session.js +4 -0
- package/dist/llm/concrete-session.js.map +1 -1
- package/dist/llm/credentials.d.ts +35 -0
- package/dist/llm/credentials.d.ts.map +1 -1
- package/dist/llm/credentials.js +49 -0
- package/dist/llm/credentials.js.map +1 -1
- package/dist/llm/index.d.ts +4 -0
- package/dist/llm/index.d.ts.map +1 -1
- package/dist/llm/index.js +4 -0
- package/dist/llm/index.js.map +1 -1
- package/dist/llm/pi/gondolin-loader.d.ts +241 -0
- package/dist/llm/pi/gondolin-loader.d.ts.map +1 -0
- package/dist/llm/pi/gondolin-loader.js +195 -0
- package/dist/llm/pi/gondolin-loader.js.map +1 -0
- package/dist/llm/pi/index.d.ts +28 -0
- package/dist/llm/pi/index.d.ts.map +1 -0
- package/dist/llm/pi/index.js +27 -0
- package/dist/llm/pi/index.js.map +1 -0
- package/dist/llm/pi/pi-agent-adapter.d.ts +135 -0
- package/dist/llm/pi/pi-agent-adapter.d.ts.map +1 -0
- package/dist/llm/pi/pi-agent-adapter.js +329 -0
- package/dist/llm/pi/pi-agent-adapter.js.map +1 -0
- package/dist/llm/pi/pi-errors.d.ts +161 -0
- package/dist/llm/pi/pi-errors.d.ts.map +1 -0
- package/dist/llm/pi/pi-errors.js +296 -0
- package/dist/llm/pi/pi-errors.js.map +1 -0
- package/dist/llm/pi/pi-execution-env.d.ts +286 -0
- package/dist/llm/pi/pi-execution-env.d.ts.map +1 -0
- package/dist/llm/pi/pi-execution-env.js +406 -0
- package/dist/llm/pi/pi-execution-env.js.map +1 -0
- package/dist/llm/pi/pi-gondolin-env.d.ts +227 -0
- package/dist/llm/pi/pi-gondolin-env.d.ts.map +1 -0
- package/dist/llm/pi/pi-gondolin-env.js +541 -0
- package/dist/llm/pi/pi-gondolin-env.js.map +1 -0
- package/dist/llm/pi/pi-session-storage.d.ts +154 -0
- package/dist/llm/pi/pi-session-storage.d.ts.map +1 -0
- package/dist/llm/pi/pi-session-storage.js +314 -0
- package/dist/llm/pi/pi-session-storage.js.map +1 -0
- package/dist/llm/pi/pi-stream-fn.d.ts +124 -0
- package/dist/llm/pi/pi-stream-fn.d.ts.map +1 -0
- package/dist/llm/pi/pi-stream-fn.js +504 -0
- package/dist/llm/pi/pi-stream-fn.js.map +1 -0
- package/dist/llm/pi/pi-tool-bridge.d.ts +99 -0
- package/dist/llm/pi/pi-tool-bridge.d.ts.map +1 -0
- package/dist/llm/pi/pi-tool-bridge.js +117 -0
- package/dist/llm/pi/pi-tool-bridge.js.map +1 -0
- package/dist/llm/pi/pi-types.d.ts +56 -0
- package/dist/llm/pi/pi-types.d.ts.map +1 -0
- package/dist/llm/pi/pi-types.js +16 -0
- package/dist/llm/pi/pi-types.js.map +1 -0
- package/dist/llm/pi/resolve-execution-env.d.ts +194 -0
- package/dist/llm/pi/resolve-execution-env.d.ts.map +1 -0
- package/dist/llm/pi/resolve-execution-env.js +132 -0
- package/dist/llm/pi/resolve-execution-env.js.map +1 -0
- package/dist/llm/plugin-facade.js +2253 -1151
- package/dist/llm/plugin-facade.js.map +3 -3
- package/dist/llm/role-executor.d.ts.map +1 -1
- package/dist/llm/role-executor.js +8 -5
- package/dist/llm/role-executor.js.map +1 -1
- package/dist/llm/role-resolver.d.ts +46 -14
- package/dist/llm/role-resolver.d.ts.map +1 -1
- package/dist/llm/role-resolver.js +178 -20
- package/dist/llm/role-resolver.js.map +1 -1
- package/dist/llm/sealed-credential.d.ts +125 -0
- package/dist/llm/sealed-credential.d.ts.map +1 -0
- package/dist/llm/sealed-credential.js +133 -0
- package/dist/llm/sealed-credential.js.map +1 -0
- package/dist/llm/session-factory.d.ts.map +1 -1
- package/dist/llm/session-factory.js +6 -2
- package/dist/llm/session-factory.js.map +1 -1
- package/dist/llm/system-key.d.ts +67 -0
- package/dist/llm/system-key.d.ts.map +1 -0
- package/dist/llm/system-key.js +87 -0
- package/dist/llm/system-key.js.map +1 -0
- package/dist/llm/system-of-use-registry.d.ts +119 -0
- package/dist/llm/system-of-use-registry.d.ts.map +1 -0
- package/dist/llm/system-of-use-registry.js +200 -0
- package/dist/llm/system-of-use-registry.js.map +1 -0
- package/dist/llm/system-resolver.d.ts +32 -10
- package/dist/llm/system-resolver.d.ts.map +1 -1
- package/dist/llm/system-resolver.js +70 -18
- package/dist/llm/system-resolver.js.map +1 -1
- package/dist/memory/brain-writer-thread.d.ts.map +1 -1
- package/dist/memory/brain-writer-thread.js +116 -11
- package/dist/memory/brain-writer-thread.js.map +1 -1
- package/dist/memory/claude-mem-migration.d.ts.map +1 -1
- package/dist/memory/claude-mem-migration.js +21 -0
- package/dist/memory/claude-mem-migration.js.map +1 -1
- package/dist/memory/graph-memory-bridge.d.ts.map +1 -1
- package/dist/memory/graph-memory-bridge.js +32 -25
- package/dist/memory/graph-memory-bridge.js.map +1 -1
- package/dist/memory/llm-backend-resolver.js +23 -5
- package/dist/memory/llm-backend-resolver.js.map +1 -1
- package/dist/nexus/migrations/M-split-graph.d.ts.map +1 -1
- package/dist/nexus/migrations/M-split-graph.js +60 -53
- package/dist/nexus/migrations/M-split-graph.js.map +1 -1
- package/dist/orchestrate/pivot.d.ts.map +1 -1
- package/dist/orchestrate/pivot.js +20 -2
- package/dist/orchestrate/pivot.js.map +1 -1
- package/dist/release/engine-ops.js +2 -2
- package/dist/release/engine-ops.js.map +1 -1
- package/dist/routing/capability-matrix.d.ts.map +1 -1
- package/dist/routing/capability-matrix.js +0 -57
- package/dist/routing/capability-matrix.js.map +1 -1
- package/dist/selfimprove/budget.d.ts +206 -0
- package/dist/selfimprove/budget.d.ts.map +1 -0
- package/dist/selfimprove/budget.js +203 -0
- package/dist/selfimprove/budget.js.map +1 -0
- package/dist/selfimprove/dhq-adapter.d.ts +105 -0
- package/dist/selfimprove/dhq-adapter.d.ts.map +1 -0
- package/dist/selfimprove/dhq-adapter.js +95 -0
- package/dist/selfimprove/dhq-adapter.js.map +1 -0
- package/dist/selfimprove/draft-pr.d.ts +129 -0
- package/dist/selfimprove/draft-pr.d.ts.map +1 -0
- package/dist/selfimprove/draft-pr.js +158 -0
- package/dist/selfimprove/draft-pr.js.map +1 -0
- package/dist/selfimprove/envelope-diff.d.ts +162 -0
- package/dist/selfimprove/envelope-diff.d.ts.map +1 -0
- package/dist/selfimprove/envelope-diff.js +321 -0
- package/dist/selfimprove/envelope-diff.js.map +1 -0
- package/dist/selfimprove/replay.d.ts +121 -0
- package/dist/selfimprove/replay.d.ts.map +1 -0
- package/dist/selfimprove/replay.js +109 -0
- package/dist/selfimprove/replay.js.map +1 -0
- package/dist/selfimprove/run-loop.d.ts +148 -0
- package/dist/selfimprove/run-loop.d.ts.map +1 -0
- package/dist/selfimprove/run-loop.js +240 -0
- package/dist/selfimprove/run-loop.js.map +1 -0
- package/dist/selfimprove/scenario.d.ts +145 -0
- package/dist/selfimprove/scenario.d.ts.map +1 -0
- package/dist/selfimprove/scenario.js +243 -0
- package/dist/selfimprove/scenario.js.map +1 -0
- package/dist/sentient/daemon-entry.js +5 -0
- package/dist/sentient/daemon-entry.js.map +1 -1
- package/dist/sentient/daemon.d.ts.map +1 -1
- package/dist/sentient/daemon.js +19 -0
- package/dist/sentient/daemon.js.map +1 -1
- package/dist/sentient/hygiene-scan.d.ts.map +1 -1
- package/dist/sentient/hygiene-scan.js +14 -6
- package/dist/sentient/hygiene-scan.js.map +1 -1
- package/dist/sessions/briefing.d.ts.map +1 -1
- package/dist/sessions/briefing.js +13 -9
- package/dist/sessions/briefing.js.map +1 -1
- package/dist/sessions/connection-session-handle.d.ts +161 -0
- package/dist/sessions/connection-session-handle.d.ts.map +1 -0
- package/dist/sessions/connection-session-handle.js +168 -0
- package/dist/sessions/connection-session-handle.js.map +1 -0
- package/dist/sessions/handoff.d.ts.map +1 -1
- package/dist/sessions/handoff.js +9 -0
- package/dist/sessions/handoff.js.map +1 -1
- package/dist/sessions/index.d.ts +4 -1
- package/dist/sessions/index.d.ts.map +1 -1
- package/dist/sessions/index.js +31 -1
- package/dist/sessions/index.js.map +1 -1
- package/dist/sessions/session-id.d.ts +34 -0
- package/dist/sessions/session-id.d.ts.map +1 -1
- package/dist/sessions/session-id.js +37 -0
- package/dist/sessions/session-id.js.map +1 -1
- package/dist/sessions/session-manifest-mirror.d.ts +115 -0
- package/dist/sessions/session-manifest-mirror.d.ts.map +1 -0
- package/dist/sessions/session-manifest-mirror.js +250 -0
- package/dist/sessions/session-manifest-mirror.js.map +1 -0
- package/dist/sessions/session-switch.d.ts.map +1 -1
- package/dist/sessions/session-switch.js +5 -2
- package/dist/sessions/session-switch.js.map +1 -1
- package/dist/store/converters.d.ts.map +1 -1
- package/dist/store/converters.js +2 -0
- package/dist/store/converters.js.map +1 -1
- package/dist/store/db-helpers.d.ts.map +1 -1
- package/dist/store/db-helpers.js +2 -0
- package/dist/store/db-helpers.js.map +1 -1
- package/dist/store/dual-scope-db.d.ts.map +1 -1
- package/dist/store/dual-scope-db.js +87 -47
- package/dist/store/dual-scope-db.js.map +1 -1
- package/dist/store/pi-session-store.d.ts +151 -0
- package/dist/store/pi-session-store.d.ts.map +1 -0
- package/dist/store/pi-session-store.js +166 -0
- package/dist/store/pi-session-store.js.map +1 -0
- package/dist/store/safety-data-accessor.d.ts +1 -0
- package/dist/store/safety-data-accessor.d.ts.map +1 -1
- package/dist/store/safety-data-accessor.js +5 -0
- package/dist/store/safety-data-accessor.js.map +1 -1
- package/dist/store/schema/cleo-global/accounts.d.ts +357 -0
- package/dist/store/schema/cleo-global/accounts.d.ts.map +1 -0
- package/dist/store/schema/cleo-global/accounts.js +136 -0
- package/dist/store/schema/cleo-global/accounts.js.map +1 -0
- package/dist/store/schema/cleo-global/index.d.ts +2 -0
- package/dist/store/schema/cleo-global/index.d.ts.map +1 -1
- package/dist/store/schema/cleo-global/index.js +2 -0
- package/dist/store/schema/cleo-global/index.js.map +1 -1
- package/dist/store/schema/cleo-global/session-manifest.d.ts +217 -0
- package/dist/store/schema/cleo-global/session-manifest.d.ts.map +1 -0
- package/dist/store/schema/cleo-global/session-manifest.js +99 -0
- package/dist/store/schema/cleo-global/session-manifest.js.map +1 -0
- package/dist/store/schema/cleo-project/tasks-core.d.ts +16 -0
- package/dist/store/schema/cleo-project/tasks-core.d.ts.map +1 -1
- package/dist/store/schema/cleo-project/tasks-core.js +14 -0
- package/dist/store/schema/cleo-project/tasks-core.js.map +1 -1
- package/dist/store/schema/tasks.d.ts +16 -0
- package/dist/store/schema/tasks.d.ts.map +1 -1
- package/dist/store/schema/tasks.js +10 -0
- package/dist/store/schema/tasks.js.map +1 -1
- package/dist/store/selfimprove-dhq-schema.d.ts +284 -0
- package/dist/store/selfimprove-dhq-schema.d.ts.map +1 -0
- package/dist/store/selfimprove-dhq-schema.js +128 -0
- package/dist/store/selfimprove-dhq-schema.js.map +1 -0
- package/dist/store/selfimprove-dhq-store.d.ts +175 -0
- package/dist/store/selfimprove-dhq-store.d.ts.map +1 -0
- package/dist/store/selfimprove-dhq-store.js +182 -0
- package/dist/store/selfimprove-dhq-store.js.map +1 -0
- package/dist/store/session-store.d.ts +52 -13
- package/dist/store/session-store.d.ts.map +1 -1
- package/dist/store/session-store.js +71 -13
- package/dist/store/session-store.js.map +1 -1
- package/dist/store/sqlite-data-accessor.d.ts.map +1 -1
- package/dist/store/sqlite-data-accessor.js +7 -0
- package/dist/store/sqlite-data-accessor.js.map +1 -1
- package/dist/store/umbrella-data-accessor.d.ts +1 -0
- package/dist/store/umbrella-data-accessor.d.ts.map +1 -1
- package/dist/store/umbrella-data-accessor.js +5 -0
- package/dist/store/umbrella-data-accessor.js.map +1 -1
- package/dist/store/validation-schemas.d.ts +32 -0
- package/dist/store/validation-schemas.d.ts.map +1 -1
- package/dist/store/writer-lease-schema.d.ts +392 -0
- package/dist/store/writer-lease-schema.d.ts.map +1 -0
- package/dist/store/writer-lease-schema.js +142 -0
- package/dist/store/writer-lease-schema.js.map +1 -0
- package/dist/store/writer-lease.d.ts +368 -0
- package/dist/store/writer-lease.d.ts.map +1 -0
- package/dist/store/writer-lease.js +1002 -0
- package/dist/store/writer-lease.js.map +1 -0
- package/dist/tasks/backfill-child-projections.d.ts.map +1 -1
- package/dist/tasks/backfill-child-projections.js +14 -9
- package/dist/tasks/backfill-child-projections.js.map +1 -1
- package/dist/tasks/complete.d.ts.map +1 -1
- package/dist/tasks/complete.js +7 -10
- package/dist/tasks/complete.js.map +1 -1
- package/dist/tasks/duplicate-detector.d.ts.map +1 -1
- package/dist/tasks/duplicate-detector.js +14 -7
- package/dist/tasks/duplicate-detector.js.map +1 -1
- package/dist/telemetry/index.d.ts.map +1 -1
- package/dist/telemetry/index.js +10 -4
- package/dist/telemetry/index.js.map +1 -1
- package/dist/tools/agent-registry.d.ts +250 -0
- package/dist/tools/agent-registry.d.ts.map +1 -0
- package/dist/tools/agent-registry.js +292 -0
- package/dist/tools/agent-registry.js.map +1 -0
- package/dist/tools/agent-tool-families.d.ts +107 -0
- package/dist/tools/agent-tool-families.d.ts.map +1 -0
- package/dist/tools/agent-tool-families.js +527 -0
- package/dist/tools/agent-tool-families.js.map +1 -0
- package/dist/tools/browser-driver.d.ts +183 -0
- package/dist/tools/browser-driver.d.ts.map +1 -0
- package/dist/tools/browser-driver.js +242 -0
- package/dist/tools/browser-driver.js.map +1 -0
- package/dist/tools/builtin-agent-tools.d.ts +36 -0
- package/dist/tools/builtin-agent-tools.d.ts.map +1 -0
- package/dist/tools/builtin-agent-tools.js +150 -0
- package/dist/tools/builtin-agent-tools.js.map +1 -0
- package/dist/tools/dispatch.d.ts +370 -0
- package/dist/tools/dispatch.d.ts.map +1 -0
- package/dist/tools/dispatch.js +505 -0
- package/dist/tools/dispatch.js.map +1 -0
- package/dist/tools/env-scrub.d.ts +93 -0
- package/dist/tools/env-scrub.d.ts.map +1 -0
- package/dist/tools/env-scrub.js +176 -0
- package/dist/tools/env-scrub.js.map +1 -0
- package/dist/tools/fs.d.ts +30 -0
- package/dist/tools/fs.d.ts.map +1 -1
- package/dist/tools/fs.js +55 -2
- package/dist/tools/fs.js.map +1 -1
- package/dist/tools/guard.d.ts +15 -0
- package/dist/tools/guard.d.ts.map +1 -1
- package/dist/tools/guard.js +49 -12
- package/dist/tools/guard.js.map +1 -1
- package/dist/tools/index.d.ts +10 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +37 -0
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/pty.d.ts +45 -0
- package/dist/tools/pty.d.ts.map +1 -0
- package/dist/tools/pty.js +166 -0
- package/dist/tools/pty.js.map +1 -0
- package/dist/tools/schema-gen.d.ts +57 -0
- package/dist/tools/schema-gen.d.ts.map +1 -0
- package/dist/tools/schema-gen.js +52 -0
- package/dist/tools/schema-gen.js.map +1 -0
- package/dist/tools/shell.d.ts +12 -0
- package/dist/tools/shell.d.ts.map +1 -1
- package/dist/tools/shell.js +14 -1
- package/dist/tools/shell.js.map +1 -1
- package/dist/tools/web-agent-tools.d.ts +72 -0
- package/dist/tools/web-agent-tools.d.ts.map +1 -0
- package/dist/tools/web-agent-tools.js +393 -0
- package/dist/tools/web-agent-tools.js.map +1 -0
- package/dist/tools/web-search-backends.d.ts +156 -0
- package/dist/tools/web-search-backends.d.ts.map +1 -0
- package/dist/tools/web-search-backends.js +290 -0
- package/dist/tools/web-search-backends.js.map +1 -0
- package/dist/validation/ops.d.ts +1 -15
- package/dist/validation/ops.d.ts.map +1 -1
- package/dist/validation/ops.js +0 -20
- package/dist/validation/ops.js.map +1 -1
- package/migrations/drizzle-cleo-global/20260607000000_t11891-writer-leases/migration.sql +55 -0
- package/migrations/drizzle-cleo-global/20260607010000_t11639-session-manifest/migration.sql +43 -0
- package/migrations/drizzle-cleo-global/20260608000000_t11899-pi-session-tree/migration.sql +52 -0
- package/migrations/drizzle-cleo-global/20260608010000_t11709-accounts-credential-pool/migration.sql +72 -0
- package/migrations/drizzle-cleo-global/20260608020000_t11889-selfimprove-dhq/migration.sql +64 -0
- package/migrations/drizzle-cleo-project/20260607000000_t11891-writer-leases/migration.sql +55 -0
- package/migrations/drizzle-cleo-project/20260607010000_t11639-session-parent/migration.sql +22 -0
- package/migrations/drizzle-cleo-project/20260608000000_t11899-pi-session-tree/migration.sql +52 -0
- package/migrations/drizzle-cleo-project/20260608020000_t11889-selfimprove-dhq/migration.sql +64 -0
- package/package.json +15 -13
- package/dist/lifecycle/chain-composition.d.ts +0 -30
- package/dist/lifecycle/chain-composition.d.ts.map +0 -1
- package/dist/lifecycle/chain-composition.js +0 -152
- package/dist/lifecycle/chain-composition.js.map +0 -1
- package/dist/lifecycle/chain-store.d.ts +0 -70
- package/dist/lifecycle/chain-store.d.ts.map +0 -1
- package/dist/lifecycle/chain-store.js +0 -246
- package/dist/lifecycle/chain-store.js.map +0 -1
- package/dist/lifecycle/default-chain.d.ts +0 -39
- package/dist/lifecycle/default-chain.d.ts.map +0 -1
- package/dist/lifecycle/default-chain.js +0 -176
- package/dist/lifecycle/default-chain.js.map +0 -1
- package/dist/lifecycle/tessera-engine.d.ts +0 -48
- package/dist/lifecycle/tessera-engine.d.ts.map +0 -1
- package/dist/lifecycle/tessera-engine.js +0 -249
- package/dist/lifecycle/tessera-engine.js.map +0 -1
- package/dist/validation/chain-validation.d.ts +0 -43
- package/dist/validation/chain-validation.d.ts.map +0 -1
- package/dist/validation/chain-validation.js +0 -146
- package/dist/validation/chain-validation.js.map +0 -1
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Budget caps + circuit-breaker state machine for the self-improvement loop
|
|
3
|
+
* (T11889 · T11889-C).
|
|
4
|
+
*
|
|
5
|
+
* The loop is an AUTONOMOUS dogfooding engine — it boots a sandbox, replays a
|
|
6
|
+
* scenario, and on a regression it WRITES a leased DHQ row and opens a draft PR.
|
|
7
|
+
* Two guardrails bound that autonomy:
|
|
8
|
+
*
|
|
9
|
+
* 1. {@link SelfImproveBudget} — HARD, in-code caps (`maxTokens`, `maxUsd`,
|
|
10
|
+
* `maxPrs = 1`, `maxWorktrees = 1`). These are REAL, not advisory: the engine
|
|
11
|
+
* asks {@link CircuitBreaker.assertWithinBudget} BEFORE each costed step, so a
|
|
12
|
+
* cap is enforced as a PRE-FLIGHT check (never merely observed after the fact).
|
|
13
|
+
* `MemoryMax=32G` is NOT an in-code cap — a CORE function cannot portably
|
|
14
|
+
* self-confine to a cgroup (`systemd-run` is Linux-only) — it is an OPERATIONAL
|
|
15
|
+
* launch-wrapper documented on {@link MEMORY_MAX_LAUNCH_WRAPPER}; the in-process
|
|
16
|
+
* complement is the gondolin VM's own `memory` option.
|
|
17
|
+
* 2. {@link CircuitBreaker} — a one-way latch that HALTS the run (no further ops,
|
|
18
|
+
* no DHQ write, no PR) the moment any of these trip:
|
|
19
|
+
* - an architectural gate goes RED (`gateRed`);
|
|
20
|
+
* - the writer lease throws {@link "../store/writer-lease.js".LeaseUnavailableError}
|
|
21
|
+
* (a `require`-mode acquisition FAILURE — `leaseUnavailable`);
|
|
22
|
+
* - a budget cap would be exceeded (`budgetOverrun`);
|
|
23
|
+
* - a DB error escapes the leased section (`dbError`).
|
|
24
|
+
* It does NOT trip on "daemon OFF": the default lease mode is `local` (no
|
|
25
|
+
* daemon), so daemon-off is the NORMAL operating state — tripping on it would
|
|
26
|
+
* block EVERY write in the default config (P5 spec §B.7 correction).
|
|
27
|
+
*
|
|
28
|
+
* This module is PURE — no DB, no native handle, no `cleo` mutation, no I/O.
|
|
29
|
+
* Import-time side-effect-free.
|
|
30
|
+
*
|
|
31
|
+
* @module @cleocode/core/selfimprove/budget
|
|
32
|
+
* @epic T11889
|
|
33
|
+
* @task T11913
|
|
34
|
+
*/
|
|
35
|
+
/**
|
|
36
|
+
* The default budget for a self-improvement run. `maxPrs` / `maxWorktrees` are
|
|
37
|
+
* `1` by contract; `maxTokens` / `maxUsd` are conservative defaults overridable
|
|
38
|
+
* via {@link resolveBudget} (env) or an explicit partial.
|
|
39
|
+
*/
|
|
40
|
+
export const DEFAULT_BUDGET = {
|
|
41
|
+
maxTokens: 200_000,
|
|
42
|
+
maxUsd: 5,
|
|
43
|
+
maxPrs: 1,
|
|
44
|
+
maxWorktrees: 1,
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* The launch-boundary memory cap — an OPERATIONAL wrapper, NOT an in-code cap.
|
|
48
|
+
*
|
|
49
|
+
* A CORE function cannot portably self-confine to a cgroup (`systemd-run` is
|
|
50
|
+
* Linux-only; re-exec'ing under it from inside the engine is fragile), so the
|
|
51
|
+
* 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
|
+
*/
|
|
55
|
+
export const MEMORY_MAX_LAUNCH_WRAPPER = 'systemd-run --user --scope -p MemoryMax=32G -p MemorySwapMax=0';
|
|
56
|
+
/** A fresh, zeroed {@link BudgetSpend}. */
|
|
57
|
+
export function emptySpend() {
|
|
58
|
+
return { tokens: 0, usd: 0, prs: 0, worktrees: 0 };
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Thrown by {@link CircuitBreaker.assertWithinBudget} when a step's charge would
|
|
62
|
+
* push the accumulated spend past a cap. Carries the offending dimension so the
|
|
63
|
+
* engine can trip the breaker with `reason: 'budgetOverrun'` and surface WHICH cap.
|
|
64
|
+
*/
|
|
65
|
+
export class BudgetExceededError extends Error {
|
|
66
|
+
/** Stable machine-readable code. */
|
|
67
|
+
code = 'E_SELFIMPROVE_BUDGET_EXCEEDED';
|
|
68
|
+
/** Which cap was exceeded. */
|
|
69
|
+
dimension;
|
|
70
|
+
/**
|
|
71
|
+
* @param dimension - The exceeded cap dimension.
|
|
72
|
+
* @param attempted - The accumulated value the step would have reached.
|
|
73
|
+
* @param cap - The cap that bounds it.
|
|
74
|
+
*/
|
|
75
|
+
constructor(dimension, attempted, cap) {
|
|
76
|
+
super(`self-improve budget exceeded: ${dimension} would reach ${attempted}, cap is ${cap}`);
|
|
77
|
+
this.name = 'BudgetExceededError';
|
|
78
|
+
this.dimension = dimension;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* A one-way circuit-breaker latch + pre-flight budget gate for ONE run.
|
|
83
|
+
*
|
|
84
|
+
* Once {@link trip} is called the breaker stays OPEN for the run's lifetime —
|
|
85
|
+
* there is no reset (a run is single-use; the next run constructs a fresh
|
|
86
|
+
* breaker). {@link assertOpen} short-circuits B.4-B.5 to a no-op the moment the
|
|
87
|
+
* latch is set, and {@link assertWithinBudget} is the PRE-FLIGHT check the engine
|
|
88
|
+
* runs before each costed step.
|
|
89
|
+
*
|
|
90
|
+
* PURE — holds only in-memory counters; no I/O.
|
|
91
|
+
*/
|
|
92
|
+
export class CircuitBreaker {
|
|
93
|
+
#budget;
|
|
94
|
+
#spend;
|
|
95
|
+
#open = false;
|
|
96
|
+
#reason = null;
|
|
97
|
+
#detail = null;
|
|
98
|
+
/**
|
|
99
|
+
* @param budget - The caps for this run (defaults to {@link DEFAULT_BUDGET}).
|
|
100
|
+
* @param spend - The starting spend (defaults to a zeroed accumulator).
|
|
101
|
+
*/
|
|
102
|
+
constructor(budget = DEFAULT_BUDGET, spend = emptySpend()) {
|
|
103
|
+
this.#budget = budget;
|
|
104
|
+
this.#spend = spend;
|
|
105
|
+
}
|
|
106
|
+
/** Whether the breaker has latched OPEN. */
|
|
107
|
+
get isOpen() {
|
|
108
|
+
return this.#open;
|
|
109
|
+
}
|
|
110
|
+
/** The current latch state (open flag + reason + detail). */
|
|
111
|
+
get state() {
|
|
112
|
+
return { open: this.#open, reason: this.#reason, detail: this.#detail };
|
|
113
|
+
}
|
|
114
|
+
/** The accumulated spend so far (a live read of the internal counters). */
|
|
115
|
+
get spend() {
|
|
116
|
+
return { ...this.#spend };
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Latch the breaker OPEN. Idempotent: the FIRST trip wins — a later trip does
|
|
120
|
+
* not overwrite the original reason (the first fault is the relevant one).
|
|
121
|
+
*
|
|
122
|
+
* @param reason - The trip reason.
|
|
123
|
+
* @param detail - A human-readable detail for logs / the run report.
|
|
124
|
+
*/
|
|
125
|
+
trip(reason, detail) {
|
|
126
|
+
if (this.#open)
|
|
127
|
+
return;
|
|
128
|
+
this.#open = true;
|
|
129
|
+
this.#reason = reason;
|
|
130
|
+
this.#detail = detail;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Throw if the breaker is OPEN — the engine calls this at the top of each
|
|
134
|
+
* phase so a tripped breaker short-circuits the rest of the run.
|
|
135
|
+
*
|
|
136
|
+
* @throws {Error} `E_SELFIMPROVE_CIRCUIT_OPEN` when the breaker is latched.
|
|
137
|
+
*/
|
|
138
|
+
assertClosed() {
|
|
139
|
+
if (this.#open) {
|
|
140
|
+
const err = new Error(`self-improve circuit-breaker OPEN (${this.#reason}): ${this.#detail}`);
|
|
141
|
+
err.code = 'E_SELFIMPROVE_CIRCUIT_OPEN';
|
|
142
|
+
throw err;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* PRE-FLIGHT budget check for a costed step. Computes the spend the step WOULD
|
|
147
|
+
* reach and — if any dimension would exceed its cap — TRIPS the breaker with
|
|
148
|
+
* `reason: 'budgetOverrun'` and throws {@link BudgetExceededError} BEFORE the
|
|
149
|
+
* step runs. On success it COMMITS the charge to the accumulator.
|
|
150
|
+
*
|
|
151
|
+
* @param charge - The increment the step would add.
|
|
152
|
+
* @throws {BudgetExceededError} When a cap would be exceeded (and trips the breaker).
|
|
153
|
+
*/
|
|
154
|
+
chargeOrTrip(charge) {
|
|
155
|
+
const next = {
|
|
156
|
+
tokens: this.#spend.tokens + (charge.tokens ?? 0),
|
|
157
|
+
usd: this.#spend.usd + (charge.usd ?? 0),
|
|
158
|
+
prs: this.#spend.prs + (charge.prs ?? 0),
|
|
159
|
+
worktrees: this.#spend.worktrees + (charge.worktrees ?? 0),
|
|
160
|
+
};
|
|
161
|
+
const checks = [
|
|
162
|
+
['maxTokens', next.tokens, this.#budget.maxTokens],
|
|
163
|
+
['maxUsd', next.usd, this.#budget.maxUsd],
|
|
164
|
+
['maxPrs', next.prs, this.#budget.maxPrs],
|
|
165
|
+
['maxWorktrees', next.worktrees, this.#budget.maxWorktrees],
|
|
166
|
+
];
|
|
167
|
+
for (const [dimension, attempted, cap] of checks) {
|
|
168
|
+
if (attempted > cap) {
|
|
169
|
+
const err = new BudgetExceededError(dimension, attempted, cap);
|
|
170
|
+
this.trip('budgetOverrun', err.message);
|
|
171
|
+
throw err;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
this.#spend.tokens = next.tokens;
|
|
175
|
+
this.#spend.usd = next.usd;
|
|
176
|
+
this.#spend.prs = next.prs;
|
|
177
|
+
this.#spend.worktrees = next.worktrees;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Resolve the effective {@link SelfImproveBudget}, layering env overrides over an
|
|
182
|
+
* explicit partial over {@link DEFAULT_BUDGET}. `maxPrs` / `maxWorktrees` are
|
|
183
|
+
* ALWAYS clamped to at most `1` regardless of override — the one-PR / one-sandbox
|
|
184
|
+
* ceiling is a hard invariant, not a tunable.
|
|
185
|
+
*
|
|
186
|
+
* Env overrides (numeric): `CLEO_SELFIMPROVE_MAX_TOKENS`, `CLEO_SELFIMPROVE_MAX_USD`.
|
|
187
|
+
*
|
|
188
|
+
* @param overrides - Optional explicit partial caps (test / caller injection).
|
|
189
|
+
* @param env - The environment to read overrides from (defaults to `process.env`).
|
|
190
|
+
* @returns The resolved, invariant-clamped budget.
|
|
191
|
+
*/
|
|
192
|
+
export function resolveBudget(overrides = {}, env = process.env) {
|
|
193
|
+
const envTokens = Number(env.CLEO_SELFIMPROVE_MAX_TOKENS);
|
|
194
|
+
const envUsd = Number(env.CLEO_SELFIMPROVE_MAX_USD);
|
|
195
|
+
const maxTokens = overrides.maxTokens ??
|
|
196
|
+
(Number.isFinite(envTokens) && envTokens > 0 ? envTokens : DEFAULT_BUDGET.maxTokens);
|
|
197
|
+
const maxUsd = overrides.maxUsd ?? (Number.isFinite(envUsd) && envUsd > 0 ? envUsd : DEFAULT_BUDGET.maxUsd);
|
|
198
|
+
// The one-PR / one-sandbox ceiling is invariant — clamp to at most 1.
|
|
199
|
+
const maxPrs = Math.min(1, overrides.maxPrs ?? DEFAULT_BUDGET.maxPrs);
|
|
200
|
+
const maxWorktrees = Math.min(1, overrides.maxWorktrees ?? DEFAULT_BUDGET.maxWorktrees);
|
|
201
|
+
return { maxTokens, maxUsd, maxPrs, maxWorktrees };
|
|
202
|
+
}
|
|
203
|
+
//# sourceMappingURL=budget.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"budget.js","sourceRoot":"","sources":["../../src/selfimprove/budget.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAwCH;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAsB;IAC/C,SAAS,EAAE,OAAO;IAClB,MAAM,EAAE,CAAC;IACT,MAAM,EAAE,CAAC;IACT,YAAY,EAAE,CAAC;CAChB,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,yBAAyB,GACpC,gEAAyE,CAAC;AAiB5E,2CAA2C;AAC3C,MAAM,UAAU,UAAU;IACxB,OAAO,EAAE,MAA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CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;IAE/F,sEAAsE;IACtE,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,SAAS,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,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Durable DHQ adapter for the self-improvement loop (T11889 · T11889-C).
|
|
3
|
+
*
|
|
4
|
+
* This adapter sits OUTSIDE the store chokepoint (it is in `selfimprove/`, not
|
|
5
|
+
* `store/`), so it MUST NOT open a raw native handle (Gate-3). It is the lease
|
|
6
|
+
* boundary: EVERY write it performs is wrapped in
|
|
7
|
+
* {@link "../store/writer-lease.js".withWriterLease}`('project', 'bulk', …)`, which
|
|
8
|
+
* serializes the write against any other writer on the `(project, bulk)` lane. It
|
|
9
|
+
* then calls the Gate-3 accessors in
|
|
10
|
+
* {@link "../store/selfimprove-dhq-store.js"} (the ONLY native-handle toucher) —
|
|
11
|
+
* whose prepared statements target ONLY `selfimprove_dhq`.
|
|
12
|
+
*
|
|
13
|
+
* Two invariants the rest of the loop relies on:
|
|
14
|
+
*
|
|
15
|
+
* 1. **No raw / unleased write.** Reads go straight through the accessor (the
|
|
16
|
+
* shared handle, no lease); every WRITE goes through {@link upsertOpenDhq} /
|
|
17
|
+
* {@link recordPrUrl}, both of which acquire the lease first. There is no
|
|
18
|
+
* code path here that mutates `cleo.db` without the lease.
|
|
19
|
+
* 2. **`selfimprove_dhq` ONLY — never a prod `tasks`/`brain` row.** The lease
|
|
20
|
+
* SERIALIZES the write; it does NOT confine it to a table. The
|
|
21
|
+
* table-confinement is ENTIRELY this adapter's discipline: it calls only the
|
|
22
|
+
* `selfimprove_dhq` accessors, whose SQL references no other table. A unit
|
|
23
|
+
* test asserts the accessor SQL targets `selfimprove_dhq` and nothing else.
|
|
24
|
+
*
|
|
25
|
+
* Lease-mode note (P5 spec §B.7): the default mode is `local` (no daemon), where a
|
|
26
|
+
* contended lease DEGRADES under `busy_timeout` rather than throwing. To get a hard
|
|
27
|
+
* denial signal for the circuit-breaker, the process runs in `require` mode
|
|
28
|
+
* (`CLEO_WRITER_LEASE_MODE=require`), where an unacquirable lease THROWS
|
|
29
|
+
* {@link "../store/writer-lease.js".LeaseUnavailableError}. This adapter does NOT
|
|
30
|
+
* swallow that throw — it propagates so {@link runSelfImprove} trips the breaker.
|
|
31
|
+
*
|
|
32
|
+
* This module is import-time side-effect-free.
|
|
33
|
+
*
|
|
34
|
+
* @module @cleocode/core/selfimprove/dhq-adapter
|
|
35
|
+
* @epic T11889
|
|
36
|
+
* @task T11913
|
|
37
|
+
*/
|
|
38
|
+
import { type SelfimproveDhqRow } from '../store/selfimprove-dhq-store.js';
|
|
39
|
+
/**
|
|
40
|
+
* The fields the engine supplies to {@link upsertOpenDhq}. `now` and the fixed
|
|
41
|
+
* `status: 'open'` are stamped by the accessor; `dhqId` / `severity` carry through.
|
|
42
|
+
*/
|
|
43
|
+
export interface UpsertDhqInput {
|
|
44
|
+
/** Stable `'DHQ-###'` handle (used only on first insert for a hash). */
|
|
45
|
+
readonly dhqId: string;
|
|
46
|
+
/** The scenario name replayed. */
|
|
47
|
+
readonly scenario: string;
|
|
48
|
+
/** sha256 of the normalized regression signature — the idempotency key. */
|
|
49
|
+
readonly questionHash: string;
|
|
50
|
+
/** Human-readable DHQ title. */
|
|
51
|
+
readonly title: string;
|
|
52
|
+
/** The envelope-diff payload (the evidence) as serialized JSON. */
|
|
53
|
+
readonly regressionJson: string;
|
|
54
|
+
/** Severity classification, or `null` until triaged. */
|
|
55
|
+
readonly severity: string | null;
|
|
56
|
+
/** Ties the row to ONE loop run. */
|
|
57
|
+
readonly runId: string;
|
|
58
|
+
}
|
|
59
|
+
/** The durable DHQ adapter — the lease boundary for the self-improvement loop. */
|
|
60
|
+
export interface DhqAdapter {
|
|
61
|
+
/**
|
|
62
|
+
* Read the open DHQ row for a `question_hash` (lease-free — readers share the
|
|
63
|
+
* handle). Returns `null` when no open row exists.
|
|
64
|
+
*/
|
|
65
|
+
readOpen(questionHash: string): Promise<SelfimproveDhqRow | null>;
|
|
66
|
+
/**
|
|
67
|
+
* UPSERT exactly ONE open DHQ row for a `question_hash`, under the
|
|
68
|
+
* `(project, bulk)` writer lease. Idempotent via the partial-UNIQUE index: a
|
|
69
|
+
* repeated open regression refreshes the existing row.
|
|
70
|
+
*/
|
|
71
|
+
upsertOpenDhq(input: UpsertDhqInput): Promise<void>;
|
|
72
|
+
/**
|
|
73
|
+
* Record the draft PR URL on the open DHQ row for a `question_hash`, under the
|
|
74
|
+
* `(project, bulk)` writer lease.
|
|
75
|
+
*
|
|
76
|
+
* @returns The number of rows updated (0 when no open row exists).
|
|
77
|
+
*/
|
|
78
|
+
recordPrUrl(questionHash: string, prUrl: string): Promise<number>;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Construct the durable DHQ adapter bound to a project working directory.
|
|
82
|
+
*
|
|
83
|
+
* Every WRITE method acquires the `(project, bulk)` writer lease via
|
|
84
|
+
* {@link "../store/writer-lease.js".withWriterLease} before delegating to the
|
|
85
|
+
* Gate-3 accessor. The native handle is resolved per call through
|
|
86
|
+
* {@link "../store/selfimprove-dhq-store.js".getSelfimproveDhqNativeDb} (the
|
|
87
|
+
* chokepoint singleton — no raw open). The clock is injectable for deterministic
|
|
88
|
+
* tests; production uses `Date.now`.
|
|
89
|
+
*
|
|
90
|
+
* @param opts - Adapter options.
|
|
91
|
+
* @param opts.cwd - Project working directory for scope resolution (defaults to `cwd`).
|
|
92
|
+
* @param opts.now - Injectable clock (defaults to {@link Date.now}).
|
|
93
|
+
* @returns A {@link DhqAdapter}.
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ```ts
|
|
97
|
+
* const adapter = createDhqAdapter({ cwd: projectRoot });
|
|
98
|
+
* await adapter.upsertOpenDhq({ dhqId: 'DHQ-001', … }); // leased UPSERT
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
export declare function createDhqAdapter(opts?: {
|
|
102
|
+
cwd?: string;
|
|
103
|
+
now?: () => number;
|
|
104
|
+
}): DhqAdapter;
|
|
105
|
+
//# sourceMappingURL=dhq-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dhq-adapter.d.ts","sourceRoot":"","sources":["../../src/selfimprove/dhq-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,OAAO,EAGL,KAAK,iBAAiB,EAIvB,MAAM,mCAAmC,CAAC;AAG3C;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,wEAAwE;IACxE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,kCAAkC;IAClC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,2EAA2E;IAC3E,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,gCAAgC;IAChC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,mEAAmE;IACnE,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,wDAAwD;IACxD,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,oCAAoC;IACpC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED,kFAAkF;AAClF,MAAM,WAAW,UAAU;IACzB;;;OAGG;IACH,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAAC;IAClE;;;;OAIG;IACH,aAAa,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpD;;;;;OAKG;IACH,WAAW,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACnE;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,GAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAA;CAAO,GAAG,UAAU,CAoC5F"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Durable DHQ adapter for the self-improvement loop (T11889 · T11889-C).
|
|
3
|
+
*
|
|
4
|
+
* This adapter sits OUTSIDE the store chokepoint (it is in `selfimprove/`, not
|
|
5
|
+
* `store/`), so it MUST NOT open a raw native handle (Gate-3). It is the lease
|
|
6
|
+
* boundary: EVERY write it performs is wrapped in
|
|
7
|
+
* {@link "../store/writer-lease.js".withWriterLease}`('project', 'bulk', …)`, which
|
|
8
|
+
* serializes the write against any other writer on the `(project, bulk)` lane. It
|
|
9
|
+
* then calls the Gate-3 accessors in
|
|
10
|
+
* {@link "../store/selfimprove-dhq-store.js"} (the ONLY native-handle toucher) —
|
|
11
|
+
* whose prepared statements target ONLY `selfimprove_dhq`.
|
|
12
|
+
*
|
|
13
|
+
* Two invariants the rest of the loop relies on:
|
|
14
|
+
*
|
|
15
|
+
* 1. **No raw / unleased write.** Reads go straight through the accessor (the
|
|
16
|
+
* shared handle, no lease); every WRITE goes through {@link upsertOpenDhq} /
|
|
17
|
+
* {@link recordPrUrl}, both of which acquire the lease first. There is no
|
|
18
|
+
* code path here that mutates `cleo.db` without the lease.
|
|
19
|
+
* 2. **`selfimprove_dhq` ONLY — never a prod `tasks`/`brain` row.** The lease
|
|
20
|
+
* SERIALIZES the write; it does NOT confine it to a table. The
|
|
21
|
+
* table-confinement is ENTIRELY this adapter's discipline: it calls only the
|
|
22
|
+
* `selfimprove_dhq` accessors, whose SQL references no other table. A unit
|
|
23
|
+
* test asserts the accessor SQL targets `selfimprove_dhq` and nothing else.
|
|
24
|
+
*
|
|
25
|
+
* Lease-mode note (P5 spec §B.7): the default mode is `local` (no daemon), where a
|
|
26
|
+
* contended lease DEGRADES under `busy_timeout` rather than throwing. To get a hard
|
|
27
|
+
* denial signal for the circuit-breaker, the process runs in `require` mode
|
|
28
|
+
* (`CLEO_WRITER_LEASE_MODE=require`), where an unacquirable lease THROWS
|
|
29
|
+
* {@link "../store/writer-lease.js".LeaseUnavailableError}. This adapter does NOT
|
|
30
|
+
* swallow that throw — it propagates so {@link runSelfImprove} trips the breaker.
|
|
31
|
+
*
|
|
32
|
+
* This module is import-time side-effect-free.
|
|
33
|
+
*
|
|
34
|
+
* @module @cleocode/core/selfimprove/dhq-adapter
|
|
35
|
+
* @epic T11889
|
|
36
|
+
* @task T11913
|
|
37
|
+
*/
|
|
38
|
+
import { getSelfimproveDhqNativeDb, readOpenSelfimproveDhq, setSelfimproveDhqPrUrl, upsertOpenSelfimproveDhq, } from '../store/selfimprove-dhq-store.js';
|
|
39
|
+
import { withWriterLease } from '../store/writer-lease.js';
|
|
40
|
+
/**
|
|
41
|
+
* Construct the durable DHQ adapter bound to a project working directory.
|
|
42
|
+
*
|
|
43
|
+
* Every WRITE method acquires the `(project, bulk)` writer lease via
|
|
44
|
+
* {@link "../store/writer-lease.js".withWriterLease} before delegating to the
|
|
45
|
+
* Gate-3 accessor. The native handle is resolved per call through
|
|
46
|
+
* {@link "../store/selfimprove-dhq-store.js".getSelfimproveDhqNativeDb} (the
|
|
47
|
+
* chokepoint singleton — no raw open). The clock is injectable for deterministic
|
|
48
|
+
* tests; production uses `Date.now`.
|
|
49
|
+
*
|
|
50
|
+
* @param opts - Adapter options.
|
|
51
|
+
* @param opts.cwd - Project working directory for scope resolution (defaults to `cwd`).
|
|
52
|
+
* @param opts.now - Injectable clock (defaults to {@link Date.now}).
|
|
53
|
+
* @returns A {@link DhqAdapter}.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```ts
|
|
57
|
+
* const adapter = createDhqAdapter({ cwd: projectRoot });
|
|
58
|
+
* await adapter.upsertOpenDhq({ dhqId: 'DHQ-001', … }); // leased UPSERT
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export function createDhqAdapter(opts = {}) {
|
|
62
|
+
const cwd = opts.cwd;
|
|
63
|
+
const now = opts.now ?? (() => Date.now());
|
|
64
|
+
return {
|
|
65
|
+
async readOpen(questionHash) {
|
|
66
|
+
const native = await getSelfimproveDhqNativeDb(cwd);
|
|
67
|
+
return readOpenSelfimproveDhq(native, questionHash);
|
|
68
|
+
},
|
|
69
|
+
async upsertOpenDhq(input) {
|
|
70
|
+
// EVERY write is leased — never raw / unleased. The lease serializes against
|
|
71
|
+
// other writers on (project, bulk); the table-confinement is the accessor's.
|
|
72
|
+
await withWriterLease('project', 'bulk', async () => {
|
|
73
|
+
const native = await getSelfimproveDhqNativeDb(cwd);
|
|
74
|
+
const row = {
|
|
75
|
+
dhqId: input.dhqId,
|
|
76
|
+
scenario: input.scenario,
|
|
77
|
+
questionHash: input.questionHash,
|
|
78
|
+
title: input.title,
|
|
79
|
+
regressionJson: input.regressionJson,
|
|
80
|
+
severity: input.severity,
|
|
81
|
+
runId: input.runId,
|
|
82
|
+
now: now(),
|
|
83
|
+
};
|
|
84
|
+
upsertOpenSelfimproveDhq(native, row);
|
|
85
|
+
});
|
|
86
|
+
},
|
|
87
|
+
async recordPrUrl(questionHash, prUrl) {
|
|
88
|
+
return withWriterLease('project', 'bulk', async () => {
|
|
89
|
+
const native = await getSelfimproveDhqNativeDb(cwd);
|
|
90
|
+
return setSelfimproveDhqPrUrl(native, questionHash, prUrl, now());
|
|
91
|
+
});
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=dhq-adapter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AAK;oBAClB,GAAG,EAAE,GAAG,EAAE;iBACX,CAAC;gBACF,wBAAwB,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;YACxC,CAAC,CAAC,CAAC;QACL,CAAC;QAED,KAAK,CAAC,WAAW,CAAC,YAAoB,EAAE,KAAa;YACnD,OAAO,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,IAAI,EAAE;gBACnD,MAAM,MAAM,GAAG,MAAM,yBAAyB,CAAC,GAAG,CAAC,CAAC;gBACpD,OAAO,sBAAsB,CAAC,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;YACpE,CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Draft-PR egress for the self-improvement loop (T11889 · T11889-C).
|
|
3
|
+
*
|
|
4
|
+
* On a detected regression the loop's ONLY outbound action is to open ONE DRAFT
|
|
5
|
+
* PR against the cleocode repo (ADR-065 — PRs target `main` via the Merge Queue;
|
|
6
|
+
* NEVER a direct push to `main`, NEVER an auto-merge, NEVER a publish). This module
|
|
7
|
+
* is the egress primitive, modeled on `propose-patch.ts` (the closest "agent
|
|
8
|
+
* proposes a fix PR" exemplar) with three self-dogfooding hardenings:
|
|
9
|
+
*
|
|
10
|
+
* 1. **`--draft` is ALWAYS appended** to `gh pr create` — the PR is never
|
|
11
|
+
* ready-for-merge; a human reviews and undrafts it.
|
|
12
|
+
* 2. **Dry-run is the DEFAULT.** `openDraftPr` returns the planned `steps[]`
|
|
13
|
+
* WITHOUT invoking git/gh unless `execute: true` is passed. So the loop is
|
|
14
|
+
* side-effect-free at egress by default.
|
|
15
|
+
* 3. **Branch `feat/T11889-selfimprove-<scenario>-<ts>`** — a feature branch
|
|
16
|
+
* (ADR-065); no main mutation path exists in this module.
|
|
17
|
+
*
|
|
18
|
+
* The live path wraps the git/gh shell-out in
|
|
19
|
+
* {@link "../sentient/skill-provenance.js".withProvenance}`('pr-generator', …)`
|
|
20
|
+
* (the established legal PR-cutting origin — the `SkillWriteOrigin` union is
|
|
21
|
+
* closed) and returns the `gh`-emitted PR URL so the caller can record it back
|
|
22
|
+
* into `selfimprove_dhq.pr_url` via the leased adapter.
|
|
23
|
+
*
|
|
24
|
+
* This module is import-time side-effect-free.
|
|
25
|
+
*
|
|
26
|
+
* @module @cleocode/core/selfimprove/draft-pr
|
|
27
|
+
* @epic T11889
|
|
28
|
+
* @task T11913
|
|
29
|
+
*/
|
|
30
|
+
/**
|
|
31
|
+
* Pluggable command runner. Returns stdout as UTF-8 text or throws on non-zero
|
|
32
|
+
* exit. Production default wraps `child_process.execFileSync` with piped stdio.
|
|
33
|
+
*/
|
|
34
|
+
export type CommandRunner = (file: string, args: readonly string[]) => string;
|
|
35
|
+
/** Failure codes from {@link openDraftPr}. */
|
|
36
|
+
export type DraftPrErrorCode =
|
|
37
|
+
/** Patch file does not exist on disk. */
|
|
38
|
+
'E_NOT_FOUND'
|
|
39
|
+
/** Patch file exists but is empty. */
|
|
40
|
+
| 'E_PATCH_EMPTY'
|
|
41
|
+
/** `gh` CLI missing / not authenticated. */
|
|
42
|
+
| 'E_GH_UNAVAILABLE'
|
|
43
|
+
/** Shell-out failure during the live PR cut. */
|
|
44
|
+
| 'E_DRAFT_PR_FAILED';
|
|
45
|
+
/** Args for {@link openDraftPr}. */
|
|
46
|
+
export interface OpenDraftPrArgs {
|
|
47
|
+
/** The scenario name whose regression this PR addresses (branch slug). */
|
|
48
|
+
readonly scenario: string;
|
|
49
|
+
/** Path to a unified-diff file with the proposed fix. Resolved against {@link cwd}. */
|
|
50
|
+
readonly diffPath: string;
|
|
51
|
+
/** PR title. */
|
|
52
|
+
readonly title: string;
|
|
53
|
+
/** PR body markdown (the trailer is appended automatically). */
|
|
54
|
+
readonly body: string;
|
|
55
|
+
/**
|
|
56
|
+
* When `true`, actually cut the branch + open the draft PR. DEFAULT `false`
|
|
57
|
+
* (dry-run) — the loop is side-effect-free at egress unless `--execute` flows
|
|
58
|
+
* through to here.
|
|
59
|
+
*
|
|
60
|
+
* @defaultValue false
|
|
61
|
+
*/
|
|
62
|
+
readonly execute?: boolean;
|
|
63
|
+
/** Working directory for path resolution + git ops. Defaults to {@link process.cwd}. */
|
|
64
|
+
readonly cwd?: string;
|
|
65
|
+
/** Injectable command runner (tests capture the shell-out). Defaults to {@link execFileSync}. */
|
|
66
|
+
readonly run?: CommandRunner;
|
|
67
|
+
/** Injectable timestamp source for the branch suffix (tests pin it). Defaults to now. */
|
|
68
|
+
readonly timestamp?: () => string;
|
|
69
|
+
}
|
|
70
|
+
/** Dry-run result — the planned steps, no side effects. */
|
|
71
|
+
export interface DraftPrDryRun {
|
|
72
|
+
readonly kind: 'dry-run';
|
|
73
|
+
readonly scenario: string;
|
|
74
|
+
readonly branchName: string;
|
|
75
|
+
/** The planned shell steps; the `gh pr create` step includes `--draft`. */
|
|
76
|
+
readonly steps: readonly string[];
|
|
77
|
+
}
|
|
78
|
+
/** Live result — the opened draft PR. */
|
|
79
|
+
export interface DraftPrOk {
|
|
80
|
+
readonly kind: 'ok';
|
|
81
|
+
readonly scenario: string;
|
|
82
|
+
readonly branchName: string;
|
|
83
|
+
/** The draft PR URL emitted by `gh pr create --draft`. */
|
|
84
|
+
readonly prUrl: string;
|
|
85
|
+
}
|
|
86
|
+
/** Failure result. */
|
|
87
|
+
export interface DraftPrFailure {
|
|
88
|
+
readonly kind: 'error';
|
|
89
|
+
readonly code: DraftPrErrorCode;
|
|
90
|
+
readonly message: string;
|
|
91
|
+
}
|
|
92
|
+
/** Discriminated-union result of {@link openDraftPr}. */
|
|
93
|
+
export type DraftPrResult = DraftPrDryRun | DraftPrOk | DraftPrFailure;
|
|
94
|
+
/**
|
|
95
|
+
* Compute the feature branch name for a scenario's draft PR (ADR-065 feature
|
|
96
|
+
* branch — `feat/T11889-selfimprove-<scenario>-<ts>`). The timestamp is
|
|
97
|
+
* colon/dot-sanitized so it is a valid git ref.
|
|
98
|
+
*
|
|
99
|
+
* @param scenario - The scenario name.
|
|
100
|
+
* @param ts - The ISO timestamp string.
|
|
101
|
+
* @returns The branch name.
|
|
102
|
+
*/
|
|
103
|
+
export declare function draftPrBranchName(scenario: string, ts: string): string;
|
|
104
|
+
/**
|
|
105
|
+
* Open ONE DRAFT PR carrying a proposed self-improvement fix.
|
|
106
|
+
*
|
|
107
|
+
* DRY-RUN by default ({@link OpenDraftPrArgs.execute} falsey): returns the planned
|
|
108
|
+
* `steps[]` (the `gh pr create` step ALWAYS carries `--draft`) WITHOUT touching
|
|
109
|
+
* git/gh — so the loop is egress-side-effect-free unless `--execute` is threaded
|
|
110
|
+
* through. The live path (`execute: true`) cuts the feature branch, applies the
|
|
111
|
+
* diff, commits, pushes the FEATURE branch (NEVER `main`), and runs
|
|
112
|
+
* `gh pr create --base main --head <branch> --draft`, returning the PR URL.
|
|
113
|
+
*
|
|
114
|
+
* NEVER pushes `main`, NEVER auto-merges, NEVER publishes — the only egress is a
|
|
115
|
+
* draft PR against a feature branch.
|
|
116
|
+
*
|
|
117
|
+
* @param args - See {@link OpenDraftPrArgs}.
|
|
118
|
+
* @returns A {@link DraftPrResult} describing the outcome.
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* ```ts
|
|
122
|
+
* // dry-run (default): no side effects, steps include `--draft`
|
|
123
|
+
* const plan = await openDraftPr({ scenario: 'x', diffPath: 'fix.patch', title, body });
|
|
124
|
+
* // live: cuts branch + opens draft PR
|
|
125
|
+
* const res = await openDraftPr({ scenario: 'x', diffPath: 'fix.patch', title, body, execute: true });
|
|
126
|
+
* ```
|
|
127
|
+
*/
|
|
128
|
+
export declare function openDraftPr(args: OpenDraftPrArgs): Promise<DraftPrResult>;
|
|
129
|
+
//# sourceMappingURL=draft-pr.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"draft-pr.d.ts","sourceRoot":"","sources":["../../src/selfimprove/draft-pr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