@humwick/server 0.0.0-stage → 0.130.0
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/CLA.md +66 -0
- package/CONTRIBUTING.md +144 -0
- package/LICENSE +167 -0
- package/README.md +511 -2
- package/SECURITY.md +67 -0
- package/THIRD_PARTY_NOTICES.md +144 -0
- package/bundled/prompts/README.md +10 -0
- package/bundled/prompts/context.advisory.compact.md +1 -0
- package/bundled/prompts/context.advisory.warn.md +1 -0
- package/bundled/prompts/continuation.envelope.md +18 -0
- package/bundled/prompts/manifest.json +838 -0
- package/bundled/prompts/memory.capture.boundary.post.md +1 -0
- package/bundled/prompts/memory.capture.boundary.pre.md +1 -0
- package/bundled/prompts/memory.charter.md +3 -0
- package/bundled/prompts/memory.native-off.md +0 -0
- package/bundled/prompts/notify.agent.exited.md +1 -0
- package/bundled/prompts/notify.agent.never-ready.md +1 -0
- package/bundled/prompts/notify.agent.ready.md +1 -0
- package/bundled/prompts/notify.automation.budget-warning.md +1 -0
- package/bundled/prompts/notify.land.failure.md +1 -0
- package/bundled/prompts/notify.land.steward-taken.coordinator.md +1 -0
- package/bundled/prompts/notify.land.steward-taken.md +1 -0
- package/bundled/prompts/notify.land.success.md +1 -0
- package/bundled/prompts/notify.routing.policy-changed.md +2 -0
- package/bundled/prompts/notify.spawn.failed.md +1 -0
- package/bundled/prompts/notify.spawn.queued.md +1 -0
- package/bundled/prompts/notify.spawn.recovered.md +1 -0
- package/bundled/prompts/notify.spawn.unconfirmed.md +1 -0
- package/bundled/prompts/profile.coordinator.charter.md +17 -0
- package/bundled/prompts/profile.debugger.system.md +12 -0
- package/bundled/prompts/profile.device-qa.system.md +10 -0
- package/bundled/prompts/profile.image-gen.append.0.md +2 -0
- package/bundled/prompts/profile.image-gen.system.md +4 -0
- package/bundled/prompts/profile.ops-assistant.brief.md +4 -0
- package/bundled/prompts/profile.probe.system.md +5 -0
- package/bundled/prompts/profile.qa.system.md +10 -0
- package/bundled/prompts/profile.sec-ops.system.md +14 -0
- package/bundled/prompts/profile.social-media.system.md +7 -0
- package/bundled/prompts/profile.software-design.system.md +26 -0
- package/bundled/prompts/profile.sub-coordinator.charter.md +2 -0
- package/bundled/prompts/profile.worker-gui.system.md +7 -0
- package/bundled/prompts/profile.worker.system.md +2 -0
- package/bundled/prompts/relay.agent-core.delivery.md +13 -0
- package/bundled/prompts/relay.agent-core.engineering.md +13 -0
- package/bundled/prompts/relay.agent-core.md +22 -0
- package/bundled/prompts/relay.context.claude.md +1 -0
- package/bundled/prompts/relay.context.claude.readonly.md +3 -0
- package/bundled/prompts/relay.context.codex.md +1 -0
- package/bundled/prompts/relay.context.opencode.md +1 -0
- package/bundled/prompts/relay.manual.claude.md +8 -0
- package/bundled/prompts/relay.search.fff.md +1 -0
- package/bundled/prompts/relay.temp-dir.md +1 -0
- package/bundled/prompts/relay.web.brave.md +1 -0
- package/bundled/prompts/relay.web.fetch.md +1 -0
- package/bundled/prompts/skill.device-lane.md +20 -0
- package/bundled/prompts/skill.security-code-review.md +10 -0
- package/bundled/prompts/skill.security-hardening.md +10 -0
- package/bundled/prompts/skill.security-host-audit.md +11 -0
- package/bundled/prompts/spawn.primer.md +6 -0
- package/bundled/prompts/spawn.reportup.child.md +3 -0
- package/bundled/prompts/spawn.reportup.coordinator.md +2 -0
- package/bundled/prompts/spawn.reportup.workflow-step.md +4 -0
- package/bundled/prompts/spawn.validation.delivery.md +1 -0
- package/bundled/prompts/spawn.validation.iterate.generic.md +1 -0
- package/bundled/prompts/spawn.validation.iterate.imperative.md +1 -0
- package/bundled/prompts/spawn.validation.landgates.header.md +1 -0
- package/bundled/prompts/steward.merge-stall.md +1 -0
- package/bundled/prompts/steward.prompt.md +20 -0
- package/bundled/prompts/steward.wake.md +1 -0
- package/bundled/prompts/task.claim.instruction.md +1 -0
- package/bundled/prompts/task.hydration.md +23 -0
- package/bundled/prompts/user.response.brief.md +1 -0
- package/bundled/prompts/user.response.normal.md +1 -0
- package/bundled/prompts/user.style.neutral.md +1 -0
- package/bundled/prompts/user.style.warm.md +1 -0
- package/bundled/prompts/workspace.deps.command.md +1 -0
- package/bundled/prompts/workspace.deps.none.md +1 -0
- package/bundled/prompts/workspace.deps.symlink.md +1 -0
- package/bundled/prompts/workspace.lifecycle.md +4 -0
- package/bundled/prompts/workspace.mcp.instructions.md +7 -0
- package/bundled/prompts/workspace.phase.abandoned.headline.md +1 -0
- package/bundled/prompts/workspace.phase.abandoned.hint.md +1 -0
- package/bundled/prompts/workspace.phase.active.headline.md +1 -0
- package/bundled/prompts/workspace.phase.active.hint.md +1 -0
- package/bundled/prompts/workspace.phase.conflict.headline.md +1 -0
- package/bundled/prompts/workspace.phase.conflict.hint.md +1 -0
- package/bundled/prompts/workspace.phase.merge-planned.headline.md +1 -0
- package/bundled/prompts/workspace.phase.merge-planned.hint.md +1 -0
- package/bundled/prompts/workspace.phase.merged.headline.md +1 -0
- package/bundled/prompts/workspace.phase.merged.hint.md +1 -0
- package/bundled/prompts/workspace.phase.ready.headline.md +1 -0
- package/bundled/prompts/workspace.phase.ready.hint.md +1 -0
- package/bundled/prompts/workspace.ready.contract.md +6 -0
- package/bundled/prompts/workspace.symlinks.md +1 -0
- package/bundled/roles/builder.md +18 -0
- package/bundled/roles/design-reviewer.md +13 -0
- package/bundled/roles/designer.md +11 -0
- package/bundled/roles/plan-auditor.md +29 -0
- package/bundled/roles/reviewer.md +36 -0
- package/bundled/roles/slice-qa.md +13 -0
- package/bundled/roles/verifier.md +13 -0
- package/bundled/skills/agent-browser/SKILL.md +72 -0
- package/bundled/skills/test-audit/SKILL.md +75 -0
- package/bundled/workflows/build-review.yaml +8 -0
- package/bundled/workflows/design-review.yaml +60 -0
- package/bundled/workflows/plan-conformance.yaml +5 -0
- package/bundled/workflows/slice-proof.yaml +85 -0
- package/bundled/workflows/verify-deployed.yaml +140 -0
- package/docs/guides/sub-coordinators.md +114 -0
- package/docs/guides/tools-administration.md +83 -0
- package/docs/guides/tools-agents.md +137 -0
- package/docs/guides/tools-coordination.md +228 -0
- package/docs/guides/tools-execution.md +48 -0
- package/docs/guides/tools-issues.md +69 -0
- package/docs/guides/tools-memory.md +150 -0
- package/docs/guides/tools-messages.md +192 -0
- package/docs/guides/tools-operations.md +133 -0
- package/docs/guides/tools-tasks.md +235 -0
- package/docs/guides/workflows.md +324 -0
- package/docs/license-faq.md +37 -0
- package/docs/openapi.json +18531 -0
- package/examples/integrations/github-issue.ts +48 -0
- package/examples/integrations/ops-alert.sh +27 -0
- package/examples/integrations/prometheus-alertmanager.ts +55 -0
- package/examples/integrations/support-ticket.sh +28 -0
- package/node_modules/@humwick/kernel/LICENSE +167 -0
- package/node_modules/@humwick/kernel/async-entity-persistence.ts +344 -0
- package/node_modules/@humwick/kernel/async-event-log.ts +107 -0
- package/node_modules/@humwick/kernel/automations.pilot.ts +147 -0
- package/node_modules/@humwick/kernel/config.ts +111 -0
- package/node_modules/@humwick/kernel/contract.ts +572 -0
- package/node_modules/@humwick/kernel/control-authz.ts +281 -0
- package/node_modules/@humwick/kernel/control.ts +645 -0
- package/node_modules/@humwick/kernel/effects.ts +493 -0
- package/node_modules/@humwick/kernel/event-log.ts +319 -0
- package/node_modules/@humwick/kernel/http-transport.ts +384 -0
- package/node_modules/@humwick/kernel/identity-grammar.ts +20 -0
- package/node_modules/@humwick/kernel/identity.ts +248 -0
- package/node_modules/@humwick/kernel/index.ts +28 -0
- package/node_modules/@humwick/kernel/kernel-persistence.ts +181 -0
- package/node_modules/@humwick/kernel/landing-incident.ts +306 -0
- package/node_modules/@humwick/kernel/landing.ts +953 -0
- package/node_modules/@humwick/kernel/manifest-validation.ts +460 -0
- package/node_modules/@humwick/kernel/mcp-transport.ts +109 -0
- package/node_modules/@humwick/kernel/message-authority-chaos-worker.ts +200 -0
- package/node_modules/@humwick/kernel/message-authority.ts +281 -0
- package/node_modules/@humwick/kernel/module-host.ts +722 -0
- package/node_modules/@humwick/kernel/openapi-init.ts +14 -0
- package/node_modules/@humwick/kernel/package.json +47 -0
- package/node_modules/@humwick/kernel/persistence-schema.ts +248 -0
- package/node_modules/@humwick/kernel/persistence.ts +510 -0
- package/node_modules/@humwick/kernel/registry.ts +60 -0
- package/node_modules/@humwick/kernel/sqlite-kernel-persistence.ts +499 -0
- package/node_modules/@humwick/kernel/sqlite-module-host.ts +87 -0
- package/node_modules/@humwick/kernel/timers-chaos-worker.ts +186 -0
- package/node_modules/@humwick/kernel/timers.pilot.ts +1411 -0
- package/node_modules/@humwick/kernel/workflow-activation.ts +25 -0
- package/node_modules/@humwick/kernel/workflow-backstop.ts +40 -0
- package/node_modules/@humwick/kernel/workflow-cancel-tree.ts +20 -0
- package/node_modules/@humwick/kernel/workflow-chaos-worker.ts +213 -0
- package/node_modules/@humwick/kernel/workflow-composition.ts +231 -0
- package/node_modules/@humwick/kernel/workflow-container.ts +72 -0
- package/node_modules/@humwick/kernel/workflow-control.test-fixture.ts +42 -0
- package/node_modules/@humwick/kernel/workflow-control.ts +178 -0
- package/node_modules/@humwick/kernel/workflow-definition.ts +507 -0
- package/node_modules/@humwick/kernel/workflow-dispatch.ts +60 -0
- package/node_modules/@humwick/kernel/workflow-foreach.ts +167 -0
- package/node_modules/@humwick/kernel/workflow-journal-codec.ts +339 -0
- package/node_modules/@humwick/kernel/workflow-journal.ts +922 -0
- package/node_modules/@humwick/kernel/workflow-lane.ts +48 -0
- package/node_modules/@humwick/kernel/workflow-lease-owner.ts +60 -0
- package/node_modules/@humwick/kernel/workflow-recovery.test-fixture.ts +19 -0
- package/node_modules/@humwick/kernel/workflow-runtime.ts +938 -0
- package/node_modules/@humwick/kernel/workflow-script.ts +11 -0
- package/node_modules/@humwick/kernel/workflow-state.ts +299 -0
- package/node_modules/@humwick/kernel/workflow-step-commit.ts +195 -0
- package/node_modules/@humwick/kernel/workflow-transitions.ts +317 -0
- package/node_modules/@humwick/kernel/workflow-values.ts +153 -0
- package/node_modules/@humwick/kernel/workflow.pilot.ts +376 -0
- package/node_modules/@humwick/offload/LICENSE +167 -0
- package/node_modules/@humwick/offload/README.md +57 -0
- package/node_modules/@humwick/offload/dist/async-runner.d.ts +18 -0
- package/node_modules/@humwick/offload/dist/async-runner.d.ts.map +1 -0
- package/node_modules/@humwick/offload/dist/async-runner.js +158 -0
- package/node_modules/@humwick/offload/dist/async-runner.js.map +1 -0
- package/node_modules/@humwick/offload/dist/envelope.d.ts +25 -0
- package/node_modules/@humwick/offload/dist/envelope.d.ts.map +1 -0
- package/node_modules/@humwick/offload/dist/envelope.js +80 -0
- package/node_modules/@humwick/offload/dist/envelope.js.map +1 -0
- package/node_modules/@humwick/offload/dist/fixtures/worker-task.d.ts +10 -0
- package/node_modules/@humwick/offload/dist/fixtures/worker-task.d.ts.map +1 -0
- package/node_modules/@humwick/offload/dist/fixtures/worker-task.js +59 -0
- package/node_modules/@humwick/offload/dist/fixtures/worker-task.js.map +1 -0
- package/node_modules/@humwick/offload/dist/index.d.ts +5 -0
- package/node_modules/@humwick/offload/dist/index.d.ts.map +1 -0
- package/node_modules/@humwick/offload/dist/index.js +5 -0
- package/node_modules/@humwick/offload/dist/index.js.map +1 -0
- package/node_modules/@humwick/offload/dist/subprocess-runner.d.ts +62 -0
- package/node_modules/@humwick/offload/dist/subprocess-runner.d.ts.map +1 -0
- package/node_modules/@humwick/offload/dist/subprocess-runner.js +295 -0
- package/node_modules/@humwick/offload/dist/subprocess-runner.js.map +1 -0
- package/node_modules/@humwick/offload/dist/types.d.ts +111 -0
- package/node_modules/@humwick/offload/dist/types.d.ts.map +1 -0
- package/node_modules/@humwick/offload/dist/types.js +176 -0
- package/node_modules/@humwick/offload/dist/types.js.map +1 -0
- package/node_modules/@humwick/offload/dist/worker-pool.d.ts +23 -0
- package/node_modules/@humwick/offload/dist/worker-pool.d.ts.map +1 -0
- package/node_modules/@humwick/offload/dist/worker-pool.js +435 -0
- package/node_modules/@humwick/offload/dist/worker-pool.js.map +1 -0
- package/node_modules/@humwick/offload/dist/worker-runtime.d.ts +2 -0
- package/node_modules/@humwick/offload/dist/worker-runtime.d.ts.map +1 -0
- package/node_modules/@humwick/offload/dist/worker-runtime.js +27 -0
- package/node_modules/@humwick/offload/dist/worker-runtime.js.map +1 -0
- package/node_modules/@humwick/offload/dist/worker.d.ts +5 -0
- package/node_modules/@humwick/offload/dist/worker.d.ts.map +1 -0
- package/node_modules/@humwick/offload/dist/worker.js +1 -0
- package/node_modules/@humwick/offload/dist/worker.js.map +1 -0
- package/node_modules/@humwick/offload/package.json +46 -0
- package/node_modules/@humwick/offload/src/async-runner.ts +170 -0
- package/node_modules/@humwick/offload/src/envelope.ts +92 -0
- package/node_modules/@humwick/offload/src/fixtures/worker-task.ts +49 -0
- package/node_modules/@humwick/offload/src/index.ts +4 -0
- package/node_modules/@humwick/offload/src/subprocess-runner.ts +334 -0
- package/node_modules/@humwick/offload/src/types.ts +235 -0
- package/node_modules/@humwick/offload/src/worker-pool.ts +463 -0
- package/node_modules/@humwick/offload/src/worker-runtime.ts +32 -0
- package/node_modules/@humwick/offload/src/worker.ts +5 -0
- package/package.json +229 -4
- package/public/assets/MessageBubble-BWpoBjl4.js +4 -0
- package/public/assets/PlanGraphPanel-C0auck3n.js +2 -0
- package/public/assets/TraceView-DBnOx7AQ.js +5 -0
- package/public/assets/VaultDecisionCard-0kp2oNBC.js +2 -0
- package/public/assets/activity-TMzFOdh2.js +2 -0
- package/public/assets/activity-yLztXEBt.js +2 -0
- package/public/assets/agent-lineage-BbJDR1dW.js +2 -0
- package/public/assets/agent-liveness-DyqxfB-t.js +2 -0
- package/public/assets/agent-name-CTZBrSD9.js +2 -0
- package/public/assets/agent-profiles-BpI_jTxq.js +2 -0
- package/public/assets/agent-project-badge-9TqzUUYE.js +2 -0
- package/public/assets/agent-tools-D4n40pn8.js +2 -0
- package/public/assets/agent-type-icon-D6FUarOf.js +2 -0
- package/public/assets/agents-BYDslkJc.js +2 -0
- package/public/assets/analytics-B-XSbEMC.js +910 -0
- package/public/assets/andromeeda-vGVdxbeo.js +2 -0
- package/public/assets/angular-html-BVBpGdXr.js +2 -0
- package/public/assets/angular-ts-BfdufMKP.js +2 -0
- package/public/assets/api-CIIVBtAV.js +10 -0
- package/public/assets/archive-CIuPSvmx.js +2 -0
- package/public/assets/arrow-right-vFsRqG8V.js +2 -0
- package/public/assets/arrow-up-a-z-CKC2RCjD.js +2 -0
- package/public/assets/artifact-viewer-DdWIfV6M.js +2 -0
- package/public/assets/artifacts-DPN1q4pA.js +2 -0
- package/public/assets/artifacts-oBOqks-2.js +2 -0
- package/public/assets/astro-JKRPP03v.js +2 -0
- package/public/assets/aurora-x-CDeNXAV0.js +2 -0
- package/public/assets/automation-4KcRFXEu.js +2 -0
- package/public/assets/ayu-dark-DluEY0Gj.js +2 -0
- package/public/assets/ayu-light-C3h-C4tm.js +2 -0
- package/public/assets/ayu-mirage-Bqwy1Gya.js +2 -0
- package/public/assets/backlog-Cw9xPTCF.js +2 -0
- package/public/assets/badge-DqJRtj_p.js +2 -0
- package/public/assets/bell-_Yzbxxrt.js +2 -0
- package/public/assets/blade-DA8yMPsw.js +2 -0
- package/public/assets/bot-B0NpDNhr.js +2 -0
- package/public/assets/boxes-Cv7Wq3h4.js +2 -0
- package/public/assets/braces-BOks9SsY.js +2 -0
- package/public/assets/brain-CagXMEKE.js +2 -0
- package/public/assets/brain-circuit-CpQeSmp3.js +2 -0
- package/public/assets/bundle-web-ifbJd0t-.js +14 -0
- package/public/assets/busy-health-CTu32MZt.js +2 -0
- package/public/assets/button-Do6Z3vvn.js +2 -0
- package/public/assets/c-Wt1voDr2.js +2 -0
- package/public/assets/calendar-QJjoZ1JU.js +2 -0
- package/public/assets/calendar-clock-CDG_KBhx.js +2 -0
- package/public/assets/card-C4QJ4hCW.js +2 -0
- package/public/assets/catppuccin-frappe-3VR1Za6u.js +2 -0
- package/public/assets/catppuccin-latte-DwIHMF0Q.js +2 -0
- package/public/assets/catppuccin-macchiato-DYnBP6_5.js +2 -0
- package/public/assets/catppuccin-mocha-DYhrFGRu.js +2 -0
- package/public/assets/channels-BiXzg1G9.js +2 -0
- package/public/assets/chart-column-S02ZGfTR.js +2 -0
- package/public/assets/chat-Ctk2qwvA.js +6 -0
- package/public/assets/check-B3M9Ug1P.js +2 -0
- package/public/assets/chevron-down-BoG3JCZn.js +2 -0
- package/public/assets/chevron-right-iljytE0x.js +2 -0
- package/public/assets/chevron-up-Bv3yC5ma.js +2 -0
- package/public/assets/circle-UESLMi2-.js +2 -0
- package/public/assets/circle-alert-CryagaZd.js +2 -0
- package/public/assets/circle-arrow-up-B432r0Kk.js +2 -0
- package/public/assets/circle-check-CkUkN96J.js +2 -0
- package/public/assets/circle-x-CZ0erS7Q.js +2 -0
- package/public/assets/clipboard-list-W2YeUsxT.js +2 -0
- package/public/assets/clock-3-BH47318N.js +2 -0
- package/public/assets/clock-BWPPBh1_.js +2 -0
- package/public/assets/code-preview-Bm1wWqAp.js +3 -0
- package/public/assets/coffee-CThvmt4R.js +2 -0
- package/public/assets/connectors-C36ax4Vw.js +2 -0
- package/public/assets/copy-DFxhHRtV.js +2 -0
- package/public/assets/copy-button-CjOj4HEf.js +2 -0
- package/public/assets/cosmos-Dn8XrlnS.css +1 -0
- package/public/assets/cosmos-Jj9LK2Wf.js +3993 -0
- package/public/assets/cpp-C5WNSHb9.js +2 -0
- package/public/assets/cpu-Dndy84IU.js +2 -0
- package/public/assets/crate-agent-H6S7-B9T.js +2 -0
- package/public/assets/css-DJp_X0uY.js +2 -0
- package/public/assets/csv-Dx-8-gkx.js +2 -0
- package/public/assets/dark-plus-Cs2F2srj.js +2 -0
- package/public/assets/dependency-graph-Cd1E23wa.js +2 -0
- package/public/assets/deploys-Bwfq146q.js +2 -0
- package/public/assets/dialog-uuJ9_geR.js +6 -0
- package/public/assets/display-CfO7rTuF.js +3 -0
- package/public/assets/dist-B2h2GeWt.js +2 -0
- package/public/assets/dist-BeVYU67E.js +2 -0
- package/public/assets/dist-Bmm-RKub.js +2 -0
- package/public/assets/dist-C1xmD7qJ.js +2 -0
- package/public/assets/dist-C2J943E6.js +2 -0
- package/public/assets/dist-C6lpJDoA.js +2 -0
- package/public/assets/dist-CoWL6B0c.js +2 -0
- package/public/assets/dist-D93SmTNC.js +2 -0
- package/public/assets/dist-Da7HrHNA.js +2 -0
- package/public/assets/dist-DeW2Y1R5.js +2 -0
- package/public/assets/dist-DwBdqQ6H.js +2 -0
- package/public/assets/dist-Dz182zaW.js +2 -0
- package/public/assets/dist-H3DLHJ0C.js +2 -0
- package/public/assets/dist-RrY9C4SI.js +2 -0
- package/public/assets/download-KgtpDbt5.js +2 -0
- package/public/assets/dracula-BHWKrbxM.js +2 -0
- package/public/assets/dracula-soft-5eyTD99u.js +2 -0
- package/public/assets/dropdown-menu-BXiNephE.js +2 -0
- package/public/assets/es2015-DMmZ8vbD.js +42 -0
- package/public/assets/esm-ZSuD7QuY.js +2 -0
- package/public/assets/everforest-dark-sB-x3p7T.js +2 -0
- package/public/assets/everforest-light-Df2xbC6M.js +2 -0
- package/public/assets/external-link-BRfu-fHG.js +2 -0
- package/public/assets/eye-BAP6fHrX.js +2 -0
- package/public/assets/file-code-corner-CXhIR1vB.js +2 -0
- package/public/assets/file-pen-Crunre5f.js +2 -0
- package/public/assets/file-text-CKuoMR2U.js +2 -0
- package/public/assets/files-DhhZI2Ih.js +3 -0
- package/public/assets/flag-CnEG9PH-.js +2 -0
- package/public/assets/flame-CxBuz46L.js +2 -0
- package/public/assets/fleet-BL4UXS_k.js +2 -0
- package/public/assets/fleet-metrics-BkHP-P3R.js +2 -0
- package/public/assets/folder-git-2-CJOmTT06.js +2 -0
- package/public/assets/folder-open-CBUCMSlu.js +2 -0
- package/public/assets/folder-tree-BG3Y9nqH.js +2 -0
- package/public/assets/formatted-body-Cm1RrzmN.js +3 -0
- package/public/assets/formatted-body-impl-DQiOuOD1.js +3 -0
- package/public/assets/gauge-BIODY-BQ.js +2 -0
- package/public/assets/geist-cyrillic-wght-normal-CHSlOQsW.woff2 +0 -0
- package/public/assets/geist-latin-ext-wght-normal-DMtmJ5ZE.woff2 +0 -0
- package/public/assets/geist-latin-wght-normal-Dm3htQBi.woff2 +0 -0
- package/public/assets/git-branch-yxhV0m8E.js +2 -0
- package/public/assets/git-commit-horizontal-DS1pJ_SS.js +2 -0
- package/public/assets/git-merge-C7eIG425.js +2 -0
- package/public/assets/github-dark-C-LZuMrd.js +2 -0
- package/public/assets/github-dark-default-DXG-b-1a.js +2 -0
- package/public/assets/github-dark-dimmed-Bx1FflLF.js +2 -0
- package/public/assets/github-dark-high-contrast-B_tTalzw.js +2 -0
- package/public/assets/github-light-EUqPIrTm.js +2 -0
- package/public/assets/github-light-default-BXViO-2h.js +2 -0
- package/public/assets/github-light-high-contrast-B68TUdTA.js +2 -0
- package/public/assets/globe-Cl5fXtqs.js +2 -0
- package/public/assets/glsl-Dv5r7kPw.js +2 -0
- package/public/assets/graphql-CcFwQwm0.js +2 -0
- package/public/assets/gruvbox-dark-hard-C820rvS2.js +2 -0
- package/public/assets/gruvbox-dark-medium-BPjhmG05.js +2 -0
- package/public/assets/gruvbox-dark-soft-MrdJrrXF.js +2 -0
- package/public/assets/gruvbox-light-hard-BC_s9l72.js +2 -0
- package/public/assets/gruvbox-light-medium-BAWPOn9u.js +2 -0
- package/public/assets/gruvbox-light-soft-BSMLrYjP.js +2 -0
- package/public/assets/haml-Bg4I2hiD.js +2 -0
- package/public/assets/handlebars-DnwbnL5R.js +2 -0
- package/public/assets/hash-CbtKih3g.js +2 -0
- package/public/assets/horizon-CE9ld1lL.js +2 -0
- package/public/assets/horizon-bright-DSNQnXHK.js +2 -0
- package/public/assets/host-mTgRw7xh.js +2 -0
- package/public/assets/host-providers-dialog-CHqwXTov.js +2 -0
- package/public/assets/hourglass-txu4ax6n.js +2 -0
- package/public/assets/houston-CsvMBhTu.js +2 -0
- package/public/assets/html-C8UlPnhE.js +2 -0
- package/public/assets/html-derivative-CY6NRz-J.js +2 -0
- package/public/assets/http-CoW620Fi.js +2 -0
- package/public/assets/humwick-lockup-on-dark-Ds44Y7BK.svg +19 -0
- package/public/assets/humwick-lockup-on-light-ClALZAHt.svg +19 -0
- package/public/assets/hurl-CSSETujw.js +2 -0
- package/public/assets/imba-DsUTQ-LC.js +2 -0
- package/public/assets/inbox-Dfwk3Gt8.js +2 -0
- package/public/assets/index-B7ZerHLY.css +2 -0
- package/public/assets/index-BK0WV6hF.js +15 -0
- package/public/assets/input-CsTB6jIx.js +2 -0
- package/public/assets/insights-fH1EL-qZ.js +2 -0
- package/public/assets/integrations-C5Oix6ng.js +2 -0
- package/public/assets/issue-ref-chip-ODyondIa.js +3 -0
- package/public/assets/java-CGc3VwQr.js +2 -0
- package/public/assets/javascript-CUt1pgmJ.js +2 -0
- package/public/assets/jinja-CD-Z-FLd.js +2 -0
- package/public/assets/jison-imPNup1l.js +2 -0
- package/public/assets/json-qhed-kSA.js +2 -0
- package/public/assets/json5-BR5RXkoi.js +2 -0
- package/public/assets/jsonc-CYpm1nAK.js +2 -0
- package/public/assets/jsonl-CmCQp5Yx.js +2 -0
- package/public/assets/jsx-CY6oMTks.js +2 -0
- package/public/assets/julia-CjffhBEM.js +2 -0
- package/public/assets/kanagawa-dragon-CXtmUGW6.js +2 -0
- package/public/assets/kanagawa-lotus-BN08jTvb.js +2 -0
- package/public/assets/kanagawa-wave-CTweb8Dz.js +2 -0
- package/public/assets/kernel-Bqr0CZGv.js +2 -0
- package/public/assets/key-round-CcSxl5qr.js +2 -0
- package/public/assets/keyboard-DcmEulph.js +2 -0
- package/public/assets/label-BPBzm9FJ.js +2 -0
- package/public/assets/laserwave-C_8bwKvT.js +2 -0
- package/public/assets/layers-DEfClY-v.js +2 -0
- package/public/assets/legacy-storage-carry-C-tBSxRA.js +2 -0
- package/public/assets/less-DVTAwKKz.js +2 -0
- package/public/assets/lib-D7DTGM1F.js +2 -0
- package/public/assets/lib-G-25QXXf.js +30 -0
- package/public/assets/light-plus-DVQuIRkW.js +2 -0
- package/public/assets/lightbulb-RDhZ4p-D.js +2 -0
- package/public/assets/link-2-off-DfRF9Hwb.js +2 -0
- package/public/assets/link-6RR7Hy3-.js +2 -0
- package/public/assets/list-checks-CwnS3hly.js +2 -0
- package/public/assets/list-ordered-D8nCM7rT.js +2 -0
- package/public/assets/list-todo-9qT0fgxZ.js +2 -0
- package/public/assets/loader-circle-BfPd4kOD.js +2 -0
- package/public/assets/lock-BW8MPKw_.js +2 -0
- package/public/assets/log-viewer-Cvfy6PW7.js +4 -0
- package/public/assets/mail-DyaDmwfY.js +2 -0
- package/public/assets/maintenance-D8CDH5wZ.js +2 -0
- package/public/assets/managed-agents-egllbpij.js +4 -0
- package/public/assets/markdown-BYOwaDjH.js +2 -0
- package/public/assets/markdown-preview-CYSFgVgK.js +3 -0
- package/public/assets/markdown-preview-impl-BteVIjX4.js +2 -0
- package/public/assets/marko-DvhNOisQ.js +2 -0
- package/public/assets/material-theme-Bm3Qr25_.js +2 -0
- package/public/assets/material-theme-darker-2IIEA8gg.js +2 -0
- package/public/assets/material-theme-lighter-uhdI0v04.js +2 -0
- package/public/assets/material-theme-ocean-CHQ94UKr.js +2 -0
- package/public/assets/material-theme-palenight-B5W6OYN7.js +2 -0
- package/public/assets/mdc-CazklSAj.js +2 -0
- package/public/assets/mdx-DQZ5AkYe.js +2 -0
- package/public/assets/memory-C8WmXsyr.js +2 -0
- package/public/assets/message-circle-wjztgHBe.js +2 -0
- package/public/assets/message-square-C-1G8dMM.js +2 -0
- package/public/assets/message-square-reply-B9Z4cbQx.js +2 -0
- package/public/assets/messages-BzQdqlO6.js +2 -0
- package/public/assets/messages-square-DVM1ZtcI.js +2 -0
- package/public/assets/min-dark-BSWPekZh.js +2 -0
- package/public/assets/min-light-DDpmG2fV.js +2 -0
- package/public/assets/minimize-2-BkK6XoMP.js +2 -0
- package/public/assets/monokai-CdkpiU2Y.js +2 -0
- package/public/assets/night-owl-DhmEMT88.js +2 -0
- package/public/assets/night-owl-light-eJ-hLW7d.js +2 -0
- package/public/assets/nord-Cb4Vim4T.js +2 -0
- package/public/assets/octagon-x-B5lnUY-8.js +2 -0
- package/public/assets/one-dark-pro-CLwyXe_n.js +2 -0
- package/public/assets/one-light-D7Lr4KcI.js +2 -0
- package/public/assets/orchestrators-B1HxzkNw.js +2 -0
- package/public/assets/overview-DCUnI4Z7.js +2 -0
- package/public/assets/package-open-ckPgcjpv.js +2 -0
- package/public/assets/package-plus-C1AKMjsl.js +2 -0
- package/public/assets/pairs-ftCd2XcD.js +2 -0
- package/public/assets/paperclip-CNpKZKum.js +2 -0
- package/public/assets/pause-DttnHD4c.js +2 -0
- package/public/assets/pencil-B1Hf2V_J.js +2 -0
- package/public/assets/php-CBqsN0ai.js +2 -0
- package/public/assets/pin-DcsKeXxr.js +2 -0
- package/public/assets/plastic-DQwYfKfQ.js +2 -0
- package/public/assets/play-BbT8m7A0.js +2 -0
- package/public/assets/plug-vIyO9_P8.js +2 -0
- package/public/assets/plug-zap-V0wMDJ-G.js +2 -0
- package/public/assets/plus-D5Ek4e2S.js +2 -0
- package/public/assets/poimandres-DRFjx7u4.js +2 -0
- package/public/assets/popover-8w1TWKMG.js +2 -0
- package/public/assets/postcss-BXeXVLqQ.js +2 -0
- package/public/assets/power-6tZOhYPg.js +2 -0
- package/public/assets/preload-helper-HclGiUj8.js +1 -0
- package/public/assets/profile-icon-B2zH8DMH.js +2 -0
- package/public/assets/projects-B_lmcqfO.js +2 -0
- package/public/assets/prompt-settings-Bftq9czX.js +2 -0
- package/public/assets/provider-brand-icon-_67JR7Zh.js +2 -0
- package/public/assets/provider-display-DbLWpP3j.js +2 -0
- package/public/assets/pug-C5hz5LQ7.js +2 -0
- package/public/assets/python-gzcpVVnB.js +2 -0
- package/public/assets/r-Dzep-lPg.js +2 -0
- package/public/assets/radio-Bn0_qc0G.js +2 -0
- package/public/assets/react-dom-DSFxiC7T.js +2 -0
- package/public/assets/red-CJ3rzSJv.js +2 -0
- package/public/assets/refresh-cw-CfpvQcUn.js +2 -0
- package/public/assets/regexp-Omp9DhTb.js +2 -0
- package/public/assets/registry-DWCU5c8q.js +4 -0
- package/public/assets/repeat-hl4p_Klo.js +2 -0
- package/public/assets/rocket-BmO1qSu-.js +2 -0
- package/public/assets/rolldown-runtime-QTnfLwEv.js +1 -0
- package/public/assets/rose-pine-BthvhNj6.js +2 -0
- package/public/assets/rose-pine-dawn-Dg85fqjY.js +2 -0
- package/public/assets/rose-pine-moon-hon4tzzS.js +2 -0
- package/public/assets/rotate-ccw-CtD77qkX.js +2 -0
- package/public/assets/rotate-cw-FPtkDewA.js +2 -0
- package/public/assets/run-card-CO_bguQf.js +2 -0
- package/public/assets/sass-DXrisJhu.js +2 -0
- package/public/assets/save-B_PGqSm4.js +2 -0
- package/public/assets/scroll-area-CIN4KQse.js +2 -0
- package/public/assets/scss-DdSxiZKl.js +2 -0
- package/public/assets/search-DjzbnTbf.js +2 -0
- package/public/assets/secrets-C7GIUATz.js +2 -0
- package/public/assets/security-BUFau5-N.js +3 -0
- package/public/assets/select-DTQMP4Dk.js +2 -0
- package/public/assets/separator-t1cLZErD.js +2 -0
- package/public/assets/server-CZIRjFyY.js +2 -0
- package/public/assets/service-access-settings-C3aujqTG.js +2 -0
- package/public/assets/settings-C6sZ9eBa.js +6 -0
- package/public/assets/shellscript-CLZ0U2zV.js +2 -0
- package/public/assets/shield-CtXNUA0i.js +2 -0
- package/public/assets/shield-alert-B9jCWcKW.js +2 -0
- package/public/assets/shipping-Bu8p1gEw.js +2 -0
- package/public/assets/shipping-stats-BiMTsA4A.js +2 -0
- package/public/assets/slack-dark-DnToyrRv.js +2 -0
- package/public/assets/slack-ochin-B2OO5cIa.js +2 -0
- package/public/assets/smile-plus-q6EQBXHZ.js +2 -0
- package/public/assets/snazzy-light-4G7pJPwS.js +2 -0
- package/public/assets/solarized-dark-DV17i1UV.js +2 -0
- package/public/assets/solarized-light-DSh2HLQt.js +2 -0
- package/public/assets/sparkles-CzwR10ZU.js +2 -0
- package/public/assets/sql-DNssxck8.js +2 -0
- package/public/assets/square-Bqly37YM.js +2 -0
- package/public/assets/stats-V9Z-GxUd.js +2 -0
- package/public/assets/status-dot-CVv0iGHL.js +2 -0
- package/public/assets/stethoscope-SCBrnQQ8.js +2 -0
- package/public/assets/store-BvtFdlGX.js +9 -0
- package/public/assets/stylus-B6D30XZt.js +2 -0
- package/public/assets/svelte-DOdLCIlh.js +2 -0
- package/public/assets/switch-DuCA7mrB.js +2 -0
- package/public/assets/synthwave-84-nFMaYfgc.js +2 -0
- package/public/assets/tabs-jZgNvNHr.js +2 -0
- package/public/assets/task-chip-CYj0mpoL.js +2 -0
- package/public/assets/tasks-BIyeAaPC.js +2 -0
- package/public/assets/tasks-CXU75HRF.js +11 -0
- package/public/assets/teams-BPf976zb.js +2 -0
- package/public/assets/terminal-Bl2u7KxT.js +2 -0
- package/public/assets/terminal-viewer-DE9BOe-8.js +3 -0
- package/public/assets/terminal-viewer-impl-BrP-ENHg.css +1 -0
- package/public/assets/terminal-viewer-impl-D04pjmGh.js +143 -0
- package/public/assets/textarea-hs6Mpyfl.js +2 -0
- package/public/assets/themes-G5j9m1Ji.js +2 -0
- package/public/assets/tokyo-night-oM2G3aXe.js +2 -0
- package/public/assets/trash-2-FbcSq927.js +2 -0
- package/public/assets/triangle-alert-BBNhfgMi.js +2 -0
- package/public/assets/ts-tags-Ca73dJJY.js +2 -0
- package/public/assets/tsx-5Eka4NBX.js +2 -0
- package/public/assets/typescript-DOu2WMV5.js +2 -0
- package/public/assets/use-agent-terminal-B1yR456R.js +2 -0
- package/public/assets/use-decisions-D-S4tpDf.js +2 -0
- package/public/assets/use-project-list-B-T2Bnnn.js +2 -0
- package/public/assets/use-selectors-CnrAk2YP.js +6 -0
- package/public/assets/user-avatar-nBFIcR4M.js +2 -0
- package/public/assets/user-cog-CKcouW1J.js +2 -0
- package/public/assets/user-plus-D9749q73.js +2 -0
- package/public/assets/users-C7B3u9jv.js +2 -0
- package/public/assets/versioned-prompt-editor-Diu8BIaM.js +8 -0
- package/public/assets/vesper-DdrHHSXu.js +2 -0
- package/public/assets/vitesse-black-fwtXNY1n.js +2 -0
- package/public/assets/vitesse-dark-BZCL-v6S.js +2 -0
- package/public/assets/vitesse-light-VbXTXTou.js +2 -0
- package/public/assets/volume-2-XrcRKD9Z.js +2 -0
- package/public/assets/vue-Bfx0ffIq.js +2 -0
- package/public/assets/vue-html-BeluIYX0.js +2 -0
- package/public/assets/vue-vine-DGUAbOCX.js +2 -0
- package/public/assets/warehouse-BanzOanY.js +2 -0
- package/public/assets/wasm-BnjxR4X6.js +2 -0
- package/public/assets/wasm-ByWQv1Qj.js +2 -0
- package/public/assets/waypoints-CIzINtLT.js +2 -0
- package/public/assets/wgsl-BsKzXJz4.js +2 -0
- package/public/assets/wit-DdvCle-K.js +2 -0
- package/public/assets/work-queue-TCjJxeT-.js +2 -0
- package/public/assets/workflow-marker-Cf3Hf2fN.js +2 -0
- package/public/assets/workflows-CXQX20Qj.js +6 -0
- package/public/assets/workspaces-qSYzKYMA.js +3 -0
- package/public/assets/wrench-C7-4CgnY.js +2 -0
- package/public/assets/x-Bge17hWJ.js +2 -0
- package/public/assets/xml-DIqSwXR3.js +2 -0
- package/public/assets/yaml-rwi0_p6S.js +2 -0
- package/public/assets/zap-DGuDTw4w.js +2 -0
- package/public/assets/zoom-in-Bs8Qv8VL.js +2 -0
- package/public/assets/zoomable-image-B3Og53nj.js +2 -0
- package/public/cosmos/audio/README.md +50 -0
- package/public/cosmos/audio/alert.mp3 +0 -0
- package/public/cosmos/audio/ambient-bed.mp3 +0 -0
- package/public/cosmos/audio/comet.mp3 +0 -0
- package/public/cosmos/audio/cross-galaxy.mp3 +0 -0
- package/public/cosmos/audio/deploy.mp3 +0 -0
- package/public/cosmos/audio/galaxy-dissipate.mp3 +0 -0
- package/public/cosmos/audio/galaxy-form.mp3 +0 -0
- package/public/cosmos/audio/land.mp3 +0 -0
- package/public/cosmos/audio/reap.mp3 +0 -0
- package/public/cosmos/audio/spawn.mp3 +0 -0
- package/public/cosmos.html +34 -0
- package/public/favicon.ico +0 -0
- package/public/favicon.svg +10 -0
- package/public/icons/apple-touch-icon.png +0 -0
- package/public/icons/humwick-192.png +0 -0
- package/public/icons/humwick-512.png +0 -0
- package/public/icons/humwick.svg +19 -0
- package/public/index.html +188 -0
- package/public/manifest.webmanifest +45 -0
- package/public/sw.js +160 -0
- package/recipes/code-review.yaml +26 -0
- package/recipes/debug.yaml +20 -0
- package/recipes/feature.yaml +26 -0
- package/recipes/refactor.yaml +20 -0
- package/recipes/test.yaml +20 -0
- package/runner/LICENSE +167 -0
- package/runner/agent-bin/agent-relay-browser +10 -0
- package/runner/agent-bin/humwick +10 -0
- package/runner/hooks/fff-search-redirect/fff-search-redirect.cjs +161 -0
- package/runner/hooks/fff-search-redirect/hooks.json +13 -0
- package/runner/hooks/rg-r-guard/hooks.json +18 -0
- package/runner/hooks/rg-r-guard/rg-r-guard.cjs +144 -0
- package/runner/hooks/web-tools-redirect/hooks.json +13 -0
- package/runner/hooks/web-tools-redirect/web-tools-redirect.cjs +84 -0
- package/runner/plugins/browser/skills/playwright-cli/SKILL.md +53 -0
- package/runner/plugins/claude/.claude-plugin/plugin.json +8 -0
- package/runner/plugins/claude/claude-statusline-probe.cjs +144 -0
- package/runner/plugins/claude/hooks/gate-run-guard.provisioned.mjs +914 -0
- package/runner/plugins/claude/hooks/gate-run-guard.sh +9 -0
- package/runner/plugins/claude/hooks/gate-run-guard.ts +237 -0
- package/runner/plugins/claude/hooks/hooks.json +158 -0
- package/runner/plugins/claude/hooks/kill-guard.provisioned.mjs +7027 -0
- package/runner/plugins/claude/hooks/kill-guard.sh +341 -0
- package/runner/plugins/claude/hooks/kill-guard.ts +337 -0
- package/runner/plugins/claude/hooks/permission-request.sh +22 -0
- package/runner/plugins/claude/hooks/post-compact.sh +10 -0
- package/runner/plugins/claude/hooks/post-tool-use.sh +8 -0
- package/runner/plugins/claude/hooks/pre-compact.sh +12 -0
- package/runner/plugins/claude/hooks/read-only-bash-guard.sh +587 -0
- package/runner/plugins/claude/hooks/relay-status.sh +373 -0
- package/runner/plugins/claude/hooks/session-end.sh +26 -0
- package/runner/plugins/claude/hooks/session-start.sh +31 -0
- package/runner/plugins/claude/hooks/shell-trust.ts +28 -0
- package/runner/plugins/claude/hooks/stop-failure.sh +47 -0
- package/runner/plugins/claude/hooks/stop.sh +48 -0
- package/runner/plugins/claude/hooks/subagent-guard.cjs +26 -0
- package/runner/plugins/claude/hooks/subagent-skill-policy.cjs +160 -0
- package/runner/plugins/claude/hooks/subagent-start.sh +13 -0
- package/runner/plugins/claude/hooks/subagent-stop.sh +19 -0
- package/runner/plugins/claude/hooks/user-prompt-submit.sh +18 -0
- package/runner/plugins/claude/hooks/wait-loop-guard.ts +120 -0
- package/runner/plugins/claude/monitors/monitors.json +7 -0
- package/runner/plugins/claude/monitors/relay-monitor.provisioned.mjs +786 -0
- package/runner/plugins/claude/monitors/relay-monitor.ts +58 -0
- package/runner/plugins/claude/skills/disconnect/SKILL.md +16 -0
- package/runner/plugins/claude/skills/label/SKILL.md +23 -0
- package/runner/plugins/claude/skills/message/SKILL.md +40 -0
- package/runner/plugins/claude/skills/pair/SKILL.md +30 -0
- package/runner/plugins/claude/skills/react/SKILL.md +18 -0
- package/runner/plugins/claude/skills/read-message/SKILL.md +24 -0
- package/runner/plugins/claude/skills/reply/SKILL.md +44 -0
- package/runner/plugins/claude/skills/send-claimable/SKILL.md +39 -0
- package/runner/plugins/claude/skills/slice-first/SKILL.md +32 -0
- package/runner/plugins/claude/skills/slice-first/references/plan-recipe.md +46 -0
- package/runner/plugins/claude/skills/status/SKILL.md +16 -0
- package/runner/plugins/claude/skills/tags/SKILL.md +25 -0
- package/runner/plugins/claude/skills/task/SKILL.md +28 -0
- package/runner/plugins/claude-output-style/.claude-plugin/plugin.json +5 -0
- package/runner/plugins/claude-output-style/output-styles/agent-relay.md +5 -0
- package/runner/plugins/codex/skills/disconnect/SKILL.md +15 -0
- package/runner/plugins/codex/skills/guide/SKILL.md +15 -0
- package/runner/plugins/codex/skills/label/SKILL.md +22 -0
- package/runner/plugins/codex/skills/message/SKILL.md +40 -0
- package/runner/plugins/codex/skills/pair/SKILL.md +29 -0
- package/runner/plugins/codex/skills/react/SKILL.md +17 -0
- package/runner/plugins/codex/skills/read-message/SKILL.md +23 -0
- package/runner/plugins/codex/skills/reply/SKILL.md +44 -0
- package/runner/plugins/codex/skills/send-claimable/SKILL.md +39 -0
- package/runner/plugins/codex/skills/slice-first/SKILL.md +32 -0
- package/runner/plugins/codex/skills/slice-first/references/plan-recipe.md +46 -0
- package/runner/plugins/codex/skills/status/SKILL.md +15 -0
- package/runner/plugins/codex/skills/tags/SKILL.md +24 -0
- package/runner/plugins/codex/skills/task/SKILL.md +28 -0
- package/runner/src/adapter.ts +1061 -0
- package/runner/src/adapters/__fixtures__/codex-app-server.ts +47 -0
- package/runner/src/adapters/claude-api.ts +243 -0
- package/runner/src/adapters/claude-context-command.ts +16 -0
- package/runner/src/adapters/claude-credentials.ts +22 -0
- package/runner/src/adapters/claude-delivery-lanes.ts +28 -0
- package/runner/src/adapters/claude-delivery.ts +166 -0
- package/runner/src/adapters/claude-effort.ts +94 -0
- package/runner/src/adapters/claude-exit.ts +290 -0
- package/runner/src/adapters/claude-headless-mirror.ts +88 -0
- package/runner/src/adapters/claude-headless-refusal.ts +51 -0
- package/runner/src/adapters/claude-headless.ts +617 -0
- package/runner/src/adapters/claude-monitor-delivery-plan.ts +317 -0
- package/runner/src/adapters/claude-permission.ts +243 -0
- package/runner/src/adapters/claude-prompt-gates.ts +269 -0
- package/runner/src/adapters/claude-prompt-hook.ts +145 -0
- package/runner/src/adapters/claude-session-capture.ts +293 -0
- package/runner/src/adapters/claude-session-probe.ts +414 -0
- package/runner/src/adapters/claude-shutdown.ts +190 -0
- package/runner/src/adapters/claude-status-detectors.ts +426 -0
- package/runner/src/adapters/claude-subagents.ts +93 -0
- package/runner/src/adapters/claude-submit-confirmation.ts +287 -0
- package/runner/src/adapters/claude-tmux.ts +548 -0
- package/runner/src/adapters/claude-token-usage-capture.ts +253 -0
- package/runner/src/adapters/claude-tool-policy.ts +165 -0
- package/runner/src/adapters/claude-transcript-tail.ts +193 -0
- package/runner/src/adapters/claude-transcript.ts +812 -0
- package/runner/src/adapters/claude.ts +1097 -0
- package/runner/src/adapters/codex-agent-message-capture.ts +189 -0
- package/runner/src/adapters/codex-app-server.ts +70 -0
- package/runner/src/adapters/codex-client.ts +362 -0
- package/runner/src/adapters/codex-effective-config.ts +87 -0
- package/runner/src/adapters/codex-launch-config.ts +153 -0
- package/runner/src/adapters/codex-rollout-context.ts +272 -0
- package/runner/src/adapters/codex-skill-discovery.ts +18 -0
- package/runner/src/adapters/codex-token-usage-capture.ts +163 -0
- package/runner/src/adapters/codex-tool-output.ts +53 -0
- package/runner/src/adapters/codex-turn-outcome.ts +27 -0
- package/runner/src/adapters/codex-version.ts +64 -0
- package/runner/src/adapters/codex.ts +1442 -0
- package/runner/src/adapters/incremental-file.ts +110 -0
- package/runner/src/adapters/opencode-api.ts +71 -0
- package/runner/src/adapters/opencode-context.ts +277 -0
- package/runner/src/adapters/opencode-model-registry.ts +126 -0
- package/runner/src/adapters/opencode-provider.ts +169 -0
- package/runner/src/adapters/opencode-server-retry.ts +50 -0
- package/runner/src/adapters/opencode-soft-steer.ts +302 -0
- package/runner/src/adapters/opencode-spawn.ts +145 -0
- package/runner/src/adapters/opencode-subscribe.ts +62 -0
- package/runner/src/adapters/opencode-token-usage-capture.ts +187 -0
- package/runner/src/adapters/opencode-tool-events.ts +302 -0
- package/runner/src/adapters/opencode-tools-config.ts +17 -0
- package/runner/src/adapters/opencode.ts +2264 -0
- package/runner/src/adapters/project-shell.ts +80 -0
- package/runner/src/adapters/provider-launch-config.ts +21 -0
- package/runner/src/adapters/provider-quota-harvest.ts +127 -0
- package/runner/src/adapters/service-access.ts +153 -0
- package/runner/src/adapters/tmux-offload.ts +207 -0
- package/runner/src/adapters/tool-summary.ts +214 -0
- package/runner/src/agent-redact.ts +75 -0
- package/runner/src/agent-runner/commands/dispatch.ts +185 -0
- package/runner/src/agent-runner/commands/lifecycle.ts +84 -0
- package/runner/src/agent-runner/commands/prompt.ts +284 -0
- package/runner/src/agent-runner/credentials.ts +208 -0
- package/runner/src/agent-runner/http-liveness.ts +85 -0
- package/runner/src/agent-runner/lifecycle-milestones.ts +207 -0
- package/runner/src/agent-runner/lifecycle-phase.ts +80 -0
- package/runner/src/agent-runner/registration.ts +163 -0
- package/runner/src/agent-runner/runner-context.ts +158 -0
- package/runner/src/agent-runner/session-mirror.ts +278 -0
- package/runner/src/agent-runner/task-claims.ts +116 -0
- package/runner/src/agent-runner/token-usage-coverage.ts +54 -0
- package/runner/src/agent-runner/turn-report.ts +269 -0
- package/runner/src/api-budget-accounting.ts +91 -0
- package/runner/src/area-memory.ts +255 -0
- package/runner/src/artifact-path-materialize.ts +52 -0
- package/runner/src/async-guard.ts +35 -0
- package/runner/src/attachment-cache-sweep.ts +31 -0
- package/runner/src/attachment-cache.ts +195 -0
- package/runner/src/background-script-reconcile.ts +106 -0
- package/runner/src/bounded-log.ts +59 -0
- package/runner/src/bounded-spawn-sync.ts +18 -0
- package/runner/src/busy-reconciler.ts +282 -0
- package/runner/src/claim-tracker.ts +140 -0
- package/runner/src/claude-settings.ts +167 -0
- package/runner/src/claude-workspace-trust.ts +289 -0
- package/runner/src/config.ts +547 -0
- package/runner/src/context-boundary.ts +101 -0
- package/runner/src/context-command.ts +151 -0
- package/runner/src/context-probe-state.ts +6 -0
- package/runner/src/continuation-archive.ts +179 -0
- package/runner/src/control-server.ts +730 -0
- package/runner/src/delivery-policy.ts +9 -0
- package/runner/src/delivery-result.ts +24 -0
- package/runner/src/effort-command.ts +125 -0
- package/runner/src/empty-turn.ts +816 -0
- package/runner/src/free-port.ts +25 -0
- package/runner/src/fs-offload.ts +26 -0
- package/runner/src/gate-run-config.ts +35 -0
- package/runner/src/gate-run-lease-probe.ts +38 -0
- package/runner/src/host-asset-plan.ts +450 -0
- package/runner/src/host-claude-config-worker.ts +34 -0
- package/runner/src/host-sources.ts +40 -0
- package/runner/src/inbox-carrier.ts +7 -0
- package/runner/src/index.ts +386 -0
- package/runner/src/launch-assembly.ts +955 -0
- package/runner/src/liveness.ts +105 -0
- package/runner/src/logger.ts +108 -0
- package/runner/src/mcp-outbox.ts +204 -0
- package/runner/src/mcp-preflight.ts +86 -0
- package/runner/src/mcp-source-selection.ts +54 -0
- package/runner/src/mcp-tool-deferral.ts +35 -0
- package/runner/src/mcp-vault-env.ts +25 -0
- package/runner/src/message-body-config/config.ts +16 -0
- package/runner/src/message-body-config.ts +1 -0
- package/runner/src/mid-turn-delivery.ts +43 -0
- package/runner/src/native-memory-lever.ts +329 -0
- package/runner/src/native-self-resume.ts +244 -0
- package/runner/src/outbox.ts +453 -0
- package/runner/src/park-post.ts +17 -0
- package/runner/src/pending-permission-store.ts +148 -0
- package/runner/src/process-meta.ts +9 -0
- package/runner/src/profile-home.ts +419 -0
- package/runner/src/profile-projection.ts +411 -0
- package/runner/src/project-hooks.ts +65 -0
- package/runner/src/project-instructions.ts +119 -0
- package/runner/src/provider-double.ts +59 -0
- package/runner/src/provider-hold.ts +228 -0
- package/runner/src/provider-home-marker.ts +3 -0
- package/runner/src/provider-home-tombstone.ts +4 -0
- package/runner/src/provider-input-queue.ts +134 -0
- package/runner/src/provider-integration.ts +93 -0
- package/runner/src/provider-processes.ts +17 -0
- package/runner/src/provider-submit-failure.ts +15 -0
- package/runner/src/providers.ts +35 -0
- package/runner/src/provisioning.ts +703 -0
- package/runner/src/question-decision.ts +18 -0
- package/runner/src/quota.ts +22 -0
- package/runner/src/rate-limit.ts +351 -0
- package/runner/src/refused-prompt-store.ts +36 -0
- package/runner/src/relay-injection-events.ts +161 -0
- package/runner/src/relay-instructions.ts +107 -0
- package/runner/src/relay-mcp-proxy.long-turn-e2e.ts +183 -0
- package/runner/src/relay-mcp-proxy.ts +704 -0
- package/runner/src/relay-mcp.ts +583 -0
- package/runner/src/reply-obligation-cache.ts +211 -0
- package/runner/src/response-capture-report.ts +111 -0
- package/runner/src/response-routing.ts +6 -0
- package/runner/src/runner-core.ts +2955 -0
- package/runner/src/runner-exit.ts +12 -0
- package/runner/src/runner-helpers.ts +582 -0
- package/runner/src/runner-insights.ts +105 -0
- package/runner/src/runner-mcp-proxy.ts +46 -0
- package/runner/src/runner-spawn-config.ts +68 -0
- package/runner/src/runner-stale-scratch-sweep.ts +21 -0
- package/runner/src/runner.ts +9 -0
- package/runner/src/runtime-token-file.ts +45 -0
- package/runner/src/runtime-token-remint.ts +56 -0
- package/runner/src/service-access.ts +88 -0
- package/runner/src/session-destroy.ts +27 -0
- package/runner/src/session-insights.ts +118 -0
- package/runner/src/session-scratch.ts +296 -0
- package/runner/src/spawn-input.ts +147 -0
- package/runner/src/startup-config-fetch.ts +48 -0
- package/runner/src/subreaper.ts +113 -0
- package/runner/src/template-resolver.ts +29 -0
- package/runner/src/test-run-dedup.ts +435 -0
- package/runner/src/transcript-context.ts +99 -0
- package/runner/src/transport-errors.ts +48 -0
- package/runner/src/turn-opener.ts +55 -0
- package/runner/src/turn-reconcile-event.ts +88 -0
- package/runner/src/vault-proxy-hop.ts +99 -0
- package/runner/src/version.ts +44 -0
- package/runner/src/web-tool-call-proxy.ts +128 -0
- package/runner/src/web-tools.ts +59 -0
- package/runner/test-support/codex-web-config-proof.ts +149 -0
- package/runner/test-support/effective-launch.ts +189 -0
- package/runner/test-support/native-context-sources.ts +77 -0
- package/runner/test-support/provisioning-context.ts +55 -0
- package/runner/test-support/recorder-double.ts +130 -0
- package/runner/test-support/recording-provider.ts +242 -0
- package/runner/test-support/runner-harness.ts +249 -0
- package/runner/test-support/service-access-fixture.ts +12 -0
- package/scripts/agent-vault/bootstrap.py +87 -0
- package/scripts/agent-vault/install.py +200 -0
- package/scripts/agent-vault/install_refresh.py +98 -0
- package/scripts/agent-vault/refresh.py +116 -0
- package/scripts/agent-vault/refresh_provision.py +109 -0
- package/scripts/agent-vault/refresh_store.py +54 -0
- package/scripts/agent-vault/runtime.py +253 -0
- package/scripts/agent-vault/sec-ops-activation.json +23 -0
- package/scripts/artifact-checkout-gc.ts +51 -0
- package/scripts/cd-config.ts +224 -0
- package/scripts/cd-deploy-debounce.ts +94 -0
- package/scripts/cd-deploy-worktree-gc.ts +235 -0
- package/scripts/cd-fleet-membership.ts +48 -0
- package/scripts/cd-host-epochs.ts +101 -0
- package/scripts/cd-hub-wake.ts +40 -0
- package/scripts/cd-land-boundary.ts +49 -0
- package/scripts/cd-watcher.ts +985 -0
- package/scripts/dashboard-build-marker.ts +71 -0
- package/scripts/fleet-sha-coverage.ts +66 -0
- package/scripts/gate-run-lease.ts +329 -0
- package/scripts/gate-slot +9 -0
- package/scripts/gate-slot-fleet-health.ts +60 -0
- package/scripts/gate.sh +6 -0
- package/scripts/install-bin-shim.cjs +149 -0
- package/scripts/orchestrator-spawn-smoke.ts +398 -0
- package/scripts/provisioning-matrix.ts +72 -0
- package/scripts/release-cd-stamp.ts +146 -0
- package/scripts/release-health.ts +133 -0
- package/scripts/release-report.ts +102 -0
- package/scripts/release-upgrade.ts +1296 -0
- package/scripts/steward-policy-cleanup.ts +73 -0
- package/scripts/wait-for-deploy.ts +43 -0
- package/src/agent-authz.ts +219 -0
- package/src/agent-branch-state.ts +45 -0
- package/src/agent-busy-health.ts +158 -0
- package/src/agent-card-projection.ts +86 -0
- package/src/agent-channel-binding.ts +49 -0
- package/src/agent-command-activity.ts +39 -0
- package/src/agent-core.ts +29 -0
- package/src/agent-death-diagnosis.ts +314 -0
- package/src/agent-drive-arbiter.ts +112 -0
- package/src/agent-exit-alarm.ts +10 -0
- package/src/agent-exit-cleanup-async.ts +69 -0
- package/src/agent-exit-cleanup.ts +99 -0
- package/src/agent-exit-report.ts +28 -0
- package/src/agent-issue-repo.ts +53 -0
- package/src/agent-launch-shape-redaction.ts +72 -0
- package/src/agent-lifecycle-events.ts +428 -0
- package/src/agent-principal.ts +14 -0
- package/src/agent-profile-catalog.ts +188 -0
- package/src/agent-ref.ts +340 -0
- package/src/agent-spawn.ts +45 -0
- package/src/agent-status-events.ts +41 -0
- package/src/agent-system-tags.ts +38 -0
- package/src/artifact-media.ts +34 -0
- package/src/artifact-storage.ts +245 -0
- package/src/artifact-text.ts +31 -0
- package/src/async-deadline.ts +59 -0
- package/src/auth/admin-routes.ts +36 -0
- package/src/auth/index.ts +23 -0
- package/src/auth/login-rate-limiter.ts +153 -0
- package/src/auth/password.ts +142 -0
- package/src/auth/provider.ts +60 -0
- package/src/auth/role-scopes.ts +15 -0
- package/src/auth/session-cookie.ts +35 -0
- package/src/auth/session-refresh.ts +61 -0
- package/src/auth/session.test-fixture.ts +10 -0
- package/src/auth/session.ts +107 -0
- package/src/authority-audit.ts +56 -0
- package/src/authz-meta-keys.ts +64 -0
- package/src/auto-spawn-dispatch.ts +154 -0
- package/src/automations/constants.ts +14 -0
- package/src/automations/cron.ts +129 -0
- package/src/automations/crud.ts +129 -0
- package/src/automations/dispatch.ts +299 -0
- package/src/automations/index.ts +5 -0
- package/src/automations/precheck.ts +124 -0
- package/src/automations/reconcile.ts +314 -0
- package/src/automations/storage.ts +200 -0
- package/src/automations/types.ts +16 -0
- package/src/automations/validation.ts +216 -0
- package/src/automations.ts +1 -0
- package/src/branch-landed.ts +761 -0
- package/src/browser-authz.ts +18 -0
- package/src/browser-config.ts +31 -0
- package/src/bundled-workflows.ts +48 -0
- package/src/bus-outbox-async.ts +16 -0
- package/src/bus-outbox.ts +265 -0
- package/src/bus-resume-commands.ts +18 -0
- package/src/bus.ts +792 -0
- package/src/canonical-repo-root.ts +131 -0
- package/src/cd-deploy-notify.ts +59 -0
- package/src/cd-host-deferrals.ts +23 -0
- package/src/cd-host-lag-notify.ts +36 -0
- package/src/cd-repository.ts +49 -0
- package/src/channel-output-control.ts +43 -0
- package/src/channel-output-validation.ts +11 -0
- package/src/channel-policy-health.ts +20 -0
- package/src/channel-target.ts +40 -0
- package/src/channels-host-service.ts +219 -0
- package/src/ci/bun-test-log.ts +41 -0
- package/src/ci/failed-test-files.ts +52 -0
- package/src/ci/gate-history.ts +66 -0
- package/src/ci/github-actions.ts +145 -0
- package/src/ci/incidents.ts +175 -0
- package/src/ci/index.ts +6 -0
- package/src/ci/job-verdict.ts +27 -0
- package/src/ci/land-boundary-ci.ts +104 -0
- package/src/ci/monitor.ts +528 -0
- package/src/ci/not-triggered.ts +116 -0
- package/src/ci/notifications.ts +234 -0
- package/src/ci/provider.ts +87 -0
- package/src/ci/root-missing.ts +35 -0
- package/src/ci/transition-notify.ts +279 -0
- package/src/ci-monitor.ts +7 -0
- package/src/claude-api-budget-async.ts +11 -0
- package/src/claude-api-budget-config.ts +23 -0
- package/src/claude-api-expiry.ts +70 -0
- package/src/claude-api-overflow.ts +146 -0
- package/src/claude-app/config.ts +13 -0
- package/src/claude-app/oauth-http.ts +127 -0
- package/src/claude-app/oauth-provider.ts +136 -0
- package/src/claude-app/passphrase.ts +14 -0
- package/src/claude-app-auth.ts +65 -0
- package/src/claude-app-gateway.ts +68 -0
- package/src/cli/_shared.ts +136 -0
- package/src/cli/agent-detect.ts +175 -0
- package/src/cli/agent-guide.ts +152 -0
- package/src/cli/agent-keep.ts +37 -0
- package/src/cli/agent-meta.ts +111 -0
- package/src/cli/artifact.ts +154 -0
- package/src/cli/browser.ts +56 -0
- package/src/cli/channel-output.ts +17 -0
- package/src/cli/channels-host.ts +13 -0
- package/src/cli/channels.ts +16 -0
- package/src/cli/claude-api-budget.ts +41 -0
- package/src/cli/context-probe.ts +90 -0
- package/src/cli/credentials.ts +1 -0
- package/src/cli/daemon.ts +125 -0
- package/src/cli/dev.ts +185 -0
- package/src/cli/ephemeral.ts +159 -0
- package/src/cli/hosts.ts +41 -0
- package/src/cli/index.ts +442 -0
- package/src/cli/introspect.ts +74 -0
- package/src/cli/maintenance.ts +24 -0
- package/src/cli/merges.ts +78 -0
- package/src/cli/message.ts +229 -0
- package/src/cli/orchestrator.ts +384 -0
- package/src/cli/pair.ts +135 -0
- package/src/cli/profile.ts +35 -0
- package/src/cli/project.ts +52 -0
- package/src/cli/prompts.ts +23 -0
- package/src/cli/provider-enablement.ts +42 -0
- package/src/cli/provider.ts +230 -0
- package/src/cli/recipe.ts +110 -0
- package/src/cli/reply.ts +130 -0
- package/src/cli/roles.ts +60 -0
- package/src/cli/routing-policy.ts +20 -0
- package/src/cli/run.ts +96 -0
- package/src/cli/secrets-backup.ts +85 -0
- package/src/cli/secrets.ts +55 -0
- package/src/cli/service-access.ts +23 -0
- package/src/cli/setup.ts +57 -0
- package/src/cli/shutdown.ts +16 -0
- package/src/cli/spawn.ts +31 -0
- package/src/cli/state.ts +73 -0
- package/src/cli/steward.ts +58 -0
- package/src/cli/task.ts +151 -0
- package/src/cli/team.ts +18 -0
- package/src/cli/timers.ts +53 -0
- package/src/cli/token.ts +72 -0
- package/src/cli/upgrade.ts +200 -0
- package/src/cli/web-tool-calls.ts +17 -0
- package/src/cli/workflow.ts +46 -0
- package/src/cli/workspace.ts +544 -0
- package/src/cli.ts +4 -0
- package/src/codex-reset-consume.ts +274 -0
- package/src/codex-wham-quota.ts +177 -0
- package/src/command-events.ts +69 -0
- package/src/command-secrets.ts +198 -0
- package/src/command-ttl.ts +63 -0
- package/src/commands-db.ts +1196 -0
- package/src/commands-landing-async.ts +166 -0
- package/src/commands-write.ts +160 -0
- package/src/comment-blocks.ts +84 -0
- package/src/compaction-watch.ts +259 -0
- package/src/config-model-selection.ts +14 -0
- package/src/config-store-write.ts +39 -0
- package/src/config-store.ts +1253 -0
- package/src/config.ts +939 -0
- package/src/connector-boot-health.ts +27 -0
- package/src/connector-paths.ts +47 -0
- package/src/connectors.ts +547 -0
- package/src/content-security.ts +12 -0
- package/src/context-advisory.ts +279 -0
- package/src/context-block-rendered-at.ts +33 -0
- package/src/context-injection-channel.ts +49 -0
- package/src/context-router.ts +121 -0
- package/src/context-threshold-config.ts +52 -0
- package/src/continuation-replay-edge.ts +30 -0
- package/src/continuity-working-state.ts +107 -0
- package/src/contracts.ts +109 -0
- package/src/coordinator-authority.ts +100 -0
- package/src/coordinator-digest-config.ts +20 -0
- package/src/cosmos-events.ts +164 -0
- package/src/daemon.ts +570 -0
- package/src/dashboard-notifications.ts +169 -0
- package/src/dashboard-presence.ts +86 -0
- package/src/db/activity-async.ts +58 -0
- package/src/db/activity-read-ops.ts +42 -0
- package/src/db/activity-write-ops.ts +43 -0
- package/src/db/activity.ts +454 -0
- package/src/db/agent-card-read.ts +98 -0
- package/src/db/agent-effort-state.ts +146 -0
- package/src/db/agent-exit-cleanup.ts +94 -0
- package/src/db/agent-exit-report.ts +33 -0
- package/src/db/agent-gate-runs-write-ops.ts +7 -0
- package/src/db/agent-gate-runs.ts +96 -0
- package/src/db/agent-identity-archive.test-fixture.ts +12 -0
- package/src/db/agent-identity-archive.ts +75 -0
- package/src/db/agent-keep.ts +21 -0
- package/src/db/agent-lifecycle-write-ops.ts +92 -0
- package/src/db/agent-meta.ts +74 -0
- package/src/db/agent-outstanding-work.ts +154 -0
- package/src/db/agent-ownership-async.ts +45 -0
- package/src/db/agent-ownership-read-ops.ts +12 -0
- package/src/db/agent-ownership-write-ops.ts +50 -0
- package/src/db/agent-ownership.ts +200 -0
- package/src/db/agent-predicates.ts +64 -0
- package/src/db/agent-read.ts +39 -0
- package/src/db/agent-search-async.ts +21 -0
- package/src/db/agent-search-read-ops.ts +8 -0
- package/src/db/agent-search.ts +162 -0
- package/src/db/agent-shutdown-in-flight.ts +21 -0
- package/src/db/agents-async.ts +333 -0
- package/src/db/agents-prune-write-op.ts +37 -0
- package/src/db/agents-read-ops.ts +33 -0
- package/src/db/agents-write-ops.ts +174 -0
- package/src/db/agents.ts +1284 -0
- package/src/db/api-budget-schema.ts +144 -0
- package/src/db/api-budget-usage-migration.ts +31 -0
- package/src/db/api-budget-usage.ts +40 -0
- package/src/db/artifact-browse.ts +145 -0
- package/src/db/artifact-retention.ts +115 -0
- package/src/db/artifacts-async.ts +81 -0
- package/src/db/artifacts-read-ops.ts +24 -0
- package/src/db/artifacts-write-ops.ts +46 -0
- package/src/db/artifacts.ts +307 -0
- package/src/db/auth-identities.ts +128 -0
- package/src/db/backlog.ts +172 -0
- package/src/db/blackboard.ts +171 -0
- package/src/db/broadcast-scope.ts +63 -0
- package/src/db/broker-memory-migration.ts +71 -0
- package/src/db/browser-sessions.ts +89 -0
- package/src/db/budget-lineage.ts +26 -0
- package/src/db/bus-outbox-read-ops.ts +29 -0
- package/src/db/bus-outbox-write-ops.ts +57 -0
- package/src/db/bus-prune-async.ts +16 -0
- package/src/db/busy-regression.worker.ts +48 -0
- package/src/db/caller-lifecycle.ts +24 -0
- package/src/db/carry-pending-marker.ts +129 -0
- package/src/db/carry-pending.ts +145 -0
- package/src/db/channel-binding-delete.ts +15 -0
- package/src/db/channel-egress-allowlist.ts +200 -0
- package/src/db/channel-identity.ts +38 -0
- package/src/db/channel-runtime.ts +19 -0
- package/src/db/channels-async.ts +55 -0
- package/src/db/channels-read-ops.ts +13 -0
- package/src/db/channels-session-fence.ts +18 -0
- package/src/db/channels-write-ops.ts +42 -0
- package/src/db/channels.ts +654 -0
- package/src/db/checkout-refresh.ts +36 -0
- package/src/db/ci-gate-runs.ts +92 -0
- package/src/db/ci-incidents-async.ts +76 -0
- package/src/db/ci-incidents-read-ops.ts +15 -0
- package/src/db/ci-incidents-write-ops.ts +57 -0
- package/src/db/ci-incidents.ts +667 -0
- package/src/db/ci-sha-observations-schema.ts +33 -0
- package/src/db/claim-sql.ts +44 -0
- package/src/db/claude-api-budget-ops.ts +15 -0
- package/src/db/claude-api-budget-reconcile.ts +39 -0
- package/src/db/claude-api-budget.ts +198 -0
- package/src/db/claude-app-oauth.ts +74 -0
- package/src/db/claude-catalog-reconcile.ts +27 -0
- package/src/db/codex-reset-consumes-async.ts +9 -0
- package/src/db/codex-reset-consumes-read-ops.ts +5 -0
- package/src/db/codex-reset-consumes-write-ops.ts +19 -0
- package/src/db/codex-reset-consumes.ts +122 -0
- package/src/db/command-agent-profiles.ts +58 -0
- package/src/db/command-row.ts +88 -0
- package/src/db/command-terminal-status.ts +33 -0
- package/src/db/command-vault-pruning.ts +30 -0
- package/src/db/commands-cancel-write.ts +45 -0
- package/src/db/commands-claim-admission.ts +144 -0
- package/src/db/commands-effort-read.ts +58 -0
- package/src/db/commands-host-land-admission.ts +106 -0
- package/src/db/commands-kernel-landing.ts +268 -0
- package/src/db/commands-land-occupancy.ts +40 -0
- package/src/db/commands-land-wait.ts +38 -0
- package/src/db/commands-landing-completeness.ts +66 -0
- package/src/db/commands-landing-tuples.ts +22 -0
- package/src/db/commands-landing.ts +1046 -0
- package/src/db/commands-leaseless-sweep.ts +72 -0
- package/src/db/commands-list-query.ts +47 -0
- package/src/db/commands-planner-stats.test-fixture.ts +97 -0
- package/src/db/commands-read-ops.ts +49 -0
- package/src/db/commands-scheduler-recovery.ts +71 -0
- package/src/db/commands-spawn-read.ts +33 -0
- package/src/db/commands-write-ops.ts +286 -0
- package/src/db/config-store-write-ops.ts +58 -0
- package/src/db/connection-instrumentation.ts +76 -0
- package/src/db/connection.ts +532 -0
- package/src/db/context-reset-carry.ts +144 -0
- package/src/db/continuation-archive-purge.ts +48 -0
- package/src/db/continuation-archive-search.ts +249 -0
- package/src/db/continuation-archives-async.ts +59 -0
- package/src/db/continuation-archives-read-ops.ts +10 -0
- package/src/db/continuation-archives-write-ops.ts +15 -0
- package/src/db/continuation-archives.ts +158 -0
- package/src/db/continuations.ts +201 -0
- package/src/db/coordinator-delivery.ts +10 -0
- package/src/db/coordinator-digest-async.ts +13 -0
- package/src/db/coordinator-digest-flush.ts +6 -0
- package/src/db/coordinator-digest.ts +145 -0
- package/src/db/coordinator-seat.ts +130 -0
- package/src/db/crash-reports.ts +115 -0
- package/src/db/db-error-registry.ts +290 -0
- package/src/db/db-reader-worker.ts +91 -0
- package/src/db/db-writer-worker.ts +66 -0
- package/src/db/deferred-lineage-report-queries.ts +28 -0
- package/src/db/deferred-lineage-reports.ts +44 -0
- package/src/db/delivery-async.ts +102 -0
- package/src/db/delivery-expiration-health.ts +97 -0
- package/src/db/delivery-expiration.ts +52 -0
- package/src/db/delivery-quality-async.ts +23 -0
- package/src/db/delivery-quality.ts +116 -0
- package/src/db/delivery-read-ops.ts +26 -0
- package/src/db/delivery-report-echo.ts +53 -0
- package/src/db/delivery-write-ops.ts +72 -0
- package/src/db/delivery.ts +545 -0
- package/src/db/deploy-events-async.ts +66 -0
- package/src/db/deploy-events-read-ops.ts +25 -0
- package/src/db/deploy-events-write-ops.ts +81 -0
- package/src/db/deploy-events.ts +554 -0
- package/src/db/deploy-task-completion.ts +48 -0
- package/src/db/drive-leases.ts +165 -0
- package/src/db/durable-payloads.ts +92 -0
- package/src/db/fixtures/writer-shutdown.ts +28 -0
- package/src/db/fts-query.ts +8 -0
- package/src/db/gate-policy.ts +27 -0
- package/src/db/gate-runs.ts +181 -0
- package/src/db/gateway.ts +513 -0
- package/src/db/generation-launch.ts +82 -0
- package/src/db/guides-search.ts +18 -0
- package/src/db/history-delivery-settle.ts +57 -0
- package/src/db/hosts-async.ts +150 -0
- package/src/db/hosts-backfill.ts +91 -0
- package/src/db/hosts-read-ops.ts +21 -0
- package/src/db/hosts-registration.ts +452 -0
- package/src/db/hosts-views.ts +259 -0
- package/src/db/hosts-write-ops.ts +94 -0
- package/src/db/hosts.ts +251 -0
- package/src/db/human-address.ts +6 -0
- package/src/db/idle-digest.ts +54 -0
- package/src/db/idle-self-care.ts +100 -0
- package/src/db/inbox-async.ts +29 -0
- package/src/db/inbox-read-ops.ts +8 -0
- package/src/db/inbox-write-ops.ts +25 -0
- package/src/db/inbox.ts +197 -0
- package/src/db/index.ts +147 -0
- package/src/db/injection-attempts.ts +41 -0
- package/src/db/insights-read-ops.ts +12 -0
- package/src/db/insights-write-ops.ts +15 -0
- package/src/db/integrations.ts +297 -0
- package/src/db/issue-associations.ts +136 -0
- package/src/db/issue-lifecycle.ts +199 -0
- package/src/db/issue-refs.ts +312 -0
- package/src/db/kernel-event-log-schema.ts +14 -0
- package/src/db/kernel-landing-admission.ts +15 -0
- package/src/db/kernel-landing-command-authority.ts +222 -0
- package/src/db/kernel-persistence-async.ts +48 -0
- package/src/db/kernel-persistence-read-ops.ts +24 -0
- package/src/db/kernel-persistence-write-ops.ts +43 -0
- package/src/db/land-boundaries.ts +138 -0
- package/src/db/land-executing.ts +147 -0
- package/src/db/land-gate-attestations.ts +161 -0
- package/src/db/land-incident-eligibility.ts +44 -0
- package/src/db/land-queue-trace.ts +28 -0
- package/src/db/land-stack.ts +80 -0
- package/src/db/land-telemetry-schema.ts +50 -0
- package/src/db/land-telemetry-write-ops.ts +16 -0
- package/src/db/land-telemetry.ts +114 -0
- package/src/db/land-withdrawal-state.ts +26 -0
- package/src/db/landed-merge-evidence.ts +72 -0
- package/src/db/landed-task-attribution.ts +23 -0
- package/src/db/landing-audit.ts +18 -0
- package/src/db/landing-controllers.ts +67 -0
- package/src/db/landing-ingress-async.ts +102 -0
- package/src/db/landing-ingress-read-ops.ts +8 -0
- package/src/db/landing-ingress-write-ops.ts +42 -0
- package/src/db/landing-ingress.ts +380 -0
- package/src/db/landing-read-ops.ts +18 -0
- package/src/db/landing-receipts.ts +206 -0
- package/src/db/landing-schema.ts +479 -0
- package/src/db/launch-facts.ts +60 -0
- package/src/db/legacy-landing-publication.ts +103 -0
- package/src/db/legacy-message-backfill.ts +90 -0
- package/src/db/lifecycle-seq.ts +127 -0
- package/src/db/lifecycle-write-window.ts +216 -0
- package/src/db/lineage-pair-dedupe-sql.ts +80 -0
- package/src/db/lineage-startup-captures.ts +43 -0
- package/src/db/long-running-work-async.ts +12 -0
- package/src/db/long-running-work-write-ops.ts +8 -0
- package/src/db/long-running-work.ts +78 -0
- package/src/db/macos-privacy.ts +72 -0
- package/src/db/main-connection-writes.ts +44 -0
- package/src/db/main-thread-state.ts +38 -0
- package/src/db/maintenance-health.ts +560 -0
- package/src/db/maintenance-indexes.ts +37 -0
- package/src/db/maintenance-job-runs-async.ts +15 -0
- package/src/db/maintenance-job-runs.ts +62 -0
- package/src/db/maintenance-job-write-ops.ts +10 -0
- package/src/db/maintenance-pauses.ts +224 -0
- package/src/db/maintenance-worker.ts +111 -0
- package/src/db/mappers.ts +422 -0
- package/src/db/memory-preamble-read.ts +13 -0
- package/src/db/memory-resolve.ts +209 -0
- package/src/db/memory-retirement-plan.ts +31 -0
- package/src/db/memory-retirement.ts +15 -0
- package/src/db/merge-drain-async.ts +8 -0
- package/src/db/merge-lease.ts +225 -0
- package/src/db/message-claims.ts +16 -0
- package/src/db/message-queries.ts +16 -0
- package/src/db/message-read-mark.ts +32 -0
- package/src/db/message-reads-async.ts +46 -0
- package/src/db/message-reads-read-ops.ts +35 -0
- package/src/db/message-reads-write-ops.ts +24 -0
- package/src/db/message-reads.ts +553 -0
- package/src/db/message-send-suppression.ts +58 -0
- package/src/db/message-send.ts +76 -0
- package/src/db/message-thread.ts +15 -0
- package/src/db/message-write-ops.ts +96 -0
- package/src/db/messages-async.ts +31 -0
- package/src/db/messages-read-ops.ts +14 -0
- package/src/db/messages.ts +1201 -0
- package/src/db/migration-marker.ts +13 -0
- package/src/db/migrations.ts +1761 -0
- package/src/db/notification-subscriptions.ts +282 -0
- package/src/db/on-loop-write-transaction.ts +34 -0
- package/src/db/operator-actions-schema.ts +10 -0
- package/src/db/operator-decisions.ts +180 -0
- package/src/db/orchestrators-async.ts +57 -0
- package/src/db/orchestrators-read-ops.ts +7 -0
- package/src/db/orchestrators-write-ops.ts +52 -0
- package/src/db/orchestrators.ts +485 -0
- package/src/db/outbox-codec.ts +16 -0
- package/src/db/pair-maintenance.ts +9 -0
- package/src/db/pairs-async.ts +10 -0
- package/src/db/pairs-write-ops.ts +8 -0
- package/src/db/pairs.ts +264 -0
- package/src/db/pending-relay-runs.ts +73 -0
- package/src/db/plan-blurb-migration.ts +158 -0
- package/src/db/plan-ci-blocks.ts +28 -0
- package/src/db/plan-completion.ts +55 -0
- package/src/db/plan-conformance.ts +104 -0
- package/src/db/plan-dispatch-schema.ts +17 -0
- package/src/db/plan-dispatch-store.ts +112 -0
- package/src/db/plan-external.ts +79 -0
- package/src/db/plan-graph-async.ts +23 -0
- package/src/db/plan-graph-read-ops.ts +16 -0
- package/src/db/plan-graph-write-ops.ts +37 -0
- package/src/db/plan-graph.ts +403 -0
- package/src/db/plan-import-schema.ts +19 -0
- package/src/db/plan-import.ts +211 -0
- package/src/db/plan-task-create.ts +44 -0
- package/src/db/planner-stats.ts +123 -0
- package/src/db/plans-async.ts +22 -0
- package/src/db/plans-read-ops.ts +11 -0
- package/src/db/plans-write-ops.ts +9 -0
- package/src/db/plans.ts +385 -0
- package/src/db/policy-runtime.ts +14 -0
- package/src/db/presence-buffer.ts +111 -0
- package/src/db/presence-loop.ts +58 -0
- package/src/db/presence-write-ops.ts +28 -0
- package/src/db/presence-write.ts +38 -0
- package/src/db/profile-artifact-backfill-migration.ts +32 -0
- package/src/db/profile-host-sources-migration.ts +150 -0
- package/src/db/profile-legacy-project-instructions-migration.ts +41 -0
- package/src/db/profile-name-case-migration.ts +46 -0
- package/src/db/profile-override-migration.ts +200 -0
- package/src/db/profile-project-ack-migration.ts +55 -0
- package/src/db/profile-slim-migration.ts +125 -0
- package/src/db/profile-slim-plan.ts +190 -0
- package/src/db/project-entries-async.ts +18 -0
- package/src/db/project-entries-read-ops.ts +28 -0
- package/src/db/project-entries.ts +514 -0
- package/src/db/project-entry-search.ts +63 -0
- package/src/db/project-identity.ts +16 -0
- package/src/db/project-journal.ts +256 -0
- package/src/db/project-lifecycle.ts +80 -0
- package/src/db/project-memory-group-migration.ts +76 -0
- package/src/db/project-phantom-merge.ts +228 -0
- package/src/db/project-root-schema.ts +30 -0
- package/src/db/project-trust-approvals.ts +98 -0
- package/src/db/projects-async.ts +50 -0
- package/src/db/projects-read-ops.ts +59 -0
- package/src/db/projects-write-ops.ts +74 -0
- package/src/db/projects.ts +629 -0
- package/src/db/prompt-templates-schema.ts +23 -0
- package/src/db/prompt-templates.ts +138 -0
- package/src/db/prompt-version-migration.ts +115 -0
- package/src/db/prompt-versions-ops.ts +16 -0
- package/src/db/prompt-versions.ts +167 -0
- package/src/db/provider-catalog-async.ts +31 -0
- package/src/db/provider-catalog-read-ops.ts +8 -0
- package/src/db/provider-catalog-write-ops.ts +16 -0
- package/src/db/provider-config-history.ts +49 -0
- package/src/db/provider-config-secrets.ts +117 -0
- package/src/db/provider-flap-messages-async.ts +6 -0
- package/src/db/provider-flap-messages-write-ops.ts +12 -0
- package/src/db/provider-flap-messages.ts +19 -0
- package/src/db/provider-quota-advisory-types.ts +39 -0
- package/src/db/provider-quota-burn.ts +322 -0
- package/src/db/provider-quota-effect-occurrences.ts +13 -0
- package/src/db/provider-quota-lease-write-ops.ts +23 -0
- package/src/db/provider-quota-leases-async.ts +35 -0
- package/src/db/provider-quota-leases.ts +174 -0
- package/src/db/provider-quota-matrix-cache.ts +85 -0
- package/src/db/provider-quota-matrix-fetch.ts +85 -0
- package/src/db/provider-quota-merge.ts +90 -0
- package/src/db/provider-quota-notification-write.ts +98 -0
- package/src/db/provider-quota-prune.ts +35 -0
- package/src/db/provider-quota-read-async.ts +77 -0
- package/src/db/provider-quota-read-ops.ts +56 -0
- package/src/db/provider-quota-recipients.ts +38 -0
- package/src/db/provider-quota-state.ts +139 -0
- package/src/db/provider-quota-visibility.ts +22 -0
- package/src/db/provider-quota-write-ops.ts +69 -0
- package/src/db/provider-quotas.ts +726 -0
- package/src/db/provider-secret-scrub.ts +64 -0
- package/src/db/provisioning-assets-migration.ts +85 -0
- package/src/db/provisioning-async.ts +116 -0
- package/src/db/provisioning-callmux.ts +184 -0
- package/src/db/provisioning-github-api.ts +16 -0
- package/src/db/provisioning-github-import-target.ts +29 -0
- package/src/db/provisioning-mcp-validation.ts +103 -0
- package/src/db/provisioning-read-ops.ts +23 -0
- package/src/db/provisioning-registry.ts +1122 -0
- package/src/db/provisioning-resolve.ts +321 -0
- package/src/db/provisioning-write-ops.ts +43 -0
- package/src/db/qa-skill-seed.ts +27 -0
- package/src/db/quota-lease-busy.worker.ts +62 -0
- package/src/db/read-op-marshaling-fixtures.ts +724 -0
- package/src/db/read-ops.ts +266 -0
- package/src/db/reader-pool.ts +252 -0
- package/src/db/recipe-read-ops.ts +15 -0
- package/src/db/recipe-write-ops.ts +68 -0
- package/src/db/reply-obligations.ts +265 -0
- package/src/db/report-suppression.ts +126 -0
- package/src/db/restart-epoch-admin-async.ts +14 -0
- package/src/db/restart-epoch-admin.ts +67 -0
- package/src/db/restart-epoch-admission.ts +114 -0
- package/src/db/restart-epoch-async.ts +80 -0
- package/src/db/restart-epoch-begin.ts +177 -0
- package/src/db/restart-epoch-read-ops.ts +40 -0
- package/src/db/restart-epoch-release.ts +248 -0
- package/src/db/restart-epoch-write-ops.ts +117 -0
- package/src/db/restart-epoch.test-fixture.ts +37 -0
- package/src/db/restart-epoch.ts +623 -0
- package/src/db/restart-sensitive.ts +81 -0
- package/src/db/retention.ts +423 -0
- package/src/db/review-ref-cleanups.ts +306 -0
- package/src/db/routing-policy.ts +64 -0
- package/src/db/scheduled-timer-projection.ts +123 -0
- package/src/db/scheduled-timer-quota-chaos-worker.ts +84 -0
- package/src/db/scheduled-timers.ts +521 -0
- package/src/db/schema.ts +1472 -0
- package/src/db/scoped-message-reads.ts +31 -0
- package/src/db/secrets-broker-async.ts +31 -0
- package/src/db/secrets-broker-read-ops.ts +8 -0
- package/src/db/secrets-broker-write-ops.ts +23 -0
- package/src/db/secrets-broker.ts +221 -0
- package/src/db/secrets-vault-import.ts +37 -0
- package/src/db/secrets-vault-key-lifecycle.ts +64 -0
- package/src/db/secrets-vault-metadata.ts +37 -0
- package/src/db/secrets-vault-migration.ts +53 -0
- package/src/db/secrets-vault-write.ts +97 -0
- package/src/db/secrets-vault.ts +69 -0
- package/src/db/self-effort-permissions.ts +50 -0
- package/src/db/service-access-read-ops.ts +10 -0
- package/src/db/services-async.ts +29 -0
- package/src/db/services-read-ops.ts +134 -0
- package/src/db/services-write-ops.ts +71 -0
- package/src/db/shared.ts +7 -0
- package/src/db/shipping-board-async.ts +6 -0
- package/src/db/shipping-board.ts +319 -0
- package/src/db/shipping-stats-async.ts +24 -0
- package/src/db/shipping-stats-histogram.ts +45 -0
- package/src/db/shipping-stats-schema.ts +8 -0
- package/src/db/shipping-stats.ts +265 -0
- package/src/db/snapshot-ledger-prune.ts +53 -0
- package/src/db/spawn-budget.ts +145 -0
- package/src/db/spawn-command-busy.worker.ts +71 -0
- package/src/db/spawn-delegation-state.ts +124 -0
- package/src/db/spawn-delegation.ts +114 -0
- package/src/db/spawn-host-cap.ts +29 -0
- package/src/db/spawn-in-flight-count.ts +37 -0
- package/src/db/spawn-in-flight.ts +15 -0
- package/src/db/spawn-process-evidence.ts +68 -0
- package/src/db/spawn-project-target.ts +57 -0
- package/src/db/spawn-registration-confirmed-backfill.ts +71 -0
- package/src/db/spawn-request-id-migration.ts +36 -0
- package/src/db/spawn-request-id.ts +35 -0
- package/src/db/spawn-request-reuse.ts +28 -0
- package/src/db/spawn-tree-cleanup.ts +89 -0
- package/src/db/spawn-tree.ts +29 -0
- package/src/db/sql-audit-indexes.ts +77 -0
- package/src/db/stalled-message-delivery.ts +52 -0
- package/src/db/startup-write-lock.ts +36 -0
- package/src/db/stats-async.ts +235 -0
- package/src/db/stats-health-read-model.ts +225 -0
- package/src/db/stats-read-ops.ts +25 -0
- package/src/db/stats.ts +633 -0
- package/src/db/target-host.ts +25 -0
- package/src/db/task-async.ts +165 -0
- package/src/db/task-comment-through-async.ts +14 -0
- package/src/db/task-comment-through-read-ops.ts +4 -0
- package/src/db/task-comment-through-write-ops.ts +7 -0
- package/src/db/task-comment-through.ts +123 -0
- package/src/db/task-core.ts +44 -0
- package/src/db/task-deliverables-async.ts +60 -0
- package/src/db/task-deliverables-read-ops.ts +4 -0
- package/src/db/task-deliverables-write-ops.ts +37 -0
- package/src/db/task-deliverables.ts +387 -0
- package/src/db/task-dependency-cycle.worker.ts +43 -0
- package/src/db/task-detail-projection.ts +91 -0
- package/src/db/task-entity-async.ts +252 -0
- package/src/db/task-entity-read-ops.ts +51 -0
- package/src/db/task-entity-write-ops.ts +197 -0
- package/src/db/task-entity.ts +1143 -0
- package/src/db/task-execution.ts +20 -0
- package/src/db/task-issue-relation.ts +23 -0
- package/src/db/task-issue-source.ts +46 -0
- package/src/db/task-land-withdraw-async.ts +10 -0
- package/src/db/task-land-withdraw-read-ops.ts +13 -0
- package/src/db/task-land-withdraw-read.ts +47 -0
- package/src/db/task-land-withdraw-write-ops.ts +31 -0
- package/src/db/task-land-withdraw.ts +423 -0
- package/src/db/task-list.ts +113 -0
- package/src/db/task-maintenance.ts +25 -0
- package/src/db/task-memory-async.ts +19 -0
- package/src/db/task-memory-read-ops.ts +9 -0
- package/src/db/task-memory-write-ops.ts +23 -0
- package/src/db/task-memory.ts +170 -0
- package/src/db/task-owner.ts +126 -0
- package/src/db/task-read-ops.ts +44 -0
- package/src/db/task-review-hold-async.ts +20 -0
- package/src/db/task-review-hold-delivery.ts +58 -0
- package/src/db/task-review-hold-write-ops.ts +26 -0
- package/src/db/task-review-hold.ts +615 -0
- package/src/db/task-state-reconcile-async.ts +12 -0
- package/src/db/task-state-reconcile.ts +163 -0
- package/src/db/task-validation.ts +71 -0
- package/src/db/task-write-ops.ts +145 -0
- package/src/db/tasks.ts +528 -0
- package/src/db/team-epics.ts +37 -0
- package/src/db/team-idle.ts +35 -0
- package/src/db/team-project.ts +69 -0
- package/src/db/team-spawn-delegation-read.ts +36 -0
- package/src/db/team-spawn-delegation.ts +49 -0
- package/src/db/teams-async.ts +58 -0
- package/src/db/teams-read-ops.ts +27 -0
- package/src/db/teams-write-ops.ts +17 -0
- package/src/db/teams.ts +504 -0
- package/src/db/terminal-events.ts +113 -0
- package/src/db/timer-async.ts +523 -0
- package/src/db/timer-cutover-core.ts +545 -0
- package/src/db/timer-cutover-report-read-ops.ts +211 -0
- package/src/db/timer-cutover-write-ops.ts +275 -0
- package/src/db/timer-ingress-payload.ts +160 -0
- package/src/db/timer-ingress-read-ops.ts +39 -0
- package/src/db/timer-ingress-request-keys.ts +282 -0
- package/src/db/timer-ingress-write-ops.ts +145 -0
- package/src/db/timer-ingress.ts +515 -0
- package/src/db/timer-message-cutover.ts +322 -0
- package/src/db/timer-message-fire-deadletter.ts +136 -0
- package/src/db/timer-message-fire.ts +209 -0
- package/src/db/timer-message-flip-chaos-worker.ts +89 -0
- package/src/db/timer-message-flip-consistency.ts +147 -0
- package/src/db/timer-message-flip.ts +676 -0
- package/src/db/timer-message-participant.ts +138 -0
- package/src/db/timer-migrate-input.ts +92 -0
- package/src/db/timer-operator-async.ts +177 -0
- package/src/db/timer-operator-read-ops.ts +21 -0
- package/src/db/timer-operator-stage10.ts +119 -0
- package/src/db/timer-operator-write-ops.ts +102 -0
- package/src/db/timer-operator.ts +393 -0
- package/src/db/timer-read-ops.ts +147 -0
- package/src/db/timer-transfer-errors.ts +10 -0
- package/src/db/timer-transfer-write-ops.ts +39 -0
- package/src/db/timer-verifier-schema.ts +29 -0
- package/src/db/timer-verifier.ts +379 -0
- package/src/db/timer-write-ops.ts +277 -0
- package/src/db/token-db-write-ops.ts +92 -0
- package/src/db/token-standing.ts +84 -0
- package/src/db/token-usage-read-ops.ts +8 -0
- package/src/db/token-usage-write-ops.ts +35 -0
- package/src/db/token-usage.ts +338 -0
- package/src/db/tool-groups-empty-migration.ts +59 -0
- package/src/db/urgent-intake.ts +30 -0
- package/src/db/user-invites.ts +107 -0
- package/src/db/user-settings-read-ops.ts +19 -0
- package/src/db/user-settings-write-ops.ts +42 -0
- package/src/db/users.ts +173 -0
- package/src/db/vault-backup.ts +59 -0
- package/src/db/vault-expiry.ts +71 -0
- package/src/db/vault-health.ts +99 -0
- package/src/db/vault-token-launch.ts +77 -0
- package/src/db/vault-token-ops.ts +14 -0
- package/src/db/vault-tokens.ts +101 -0
- package/src/db/viewer-scope.ts +117 -0
- package/src/db/wal-checkpointer-worker.ts +48 -0
- package/src/db/wal-checkpointer.ts +107 -0
- package/src/db/wal-index.ts +53 -0
- package/src/db/wal-live-log.ts +68 -0
- package/src/db/wal-reclaim-async.ts +45 -0
- package/src/db/wal-reclaim.ts +140 -0
- package/src/db/web-tool-call-ops.ts +15 -0
- package/src/db/web-tool-calls.ts +87 -0
- package/src/db/withdraw-land-error.ts +18 -0
- package/src/db/work-evidence.ts +43 -0
- package/src/db/workflow-budget.ts +44 -0
- package/src/db/workflow-contact.ts +173 -0
- package/src/db/workflow-execution.ts +10 -0
- package/src/db/workflow-journal-async.ts +64 -0
- package/src/db/workflow-journal-prune.ts +71 -0
- package/src/db/workflow-journal-read-ops.ts +21 -0
- package/src/db/workflow-journal-schema.ts +9 -0
- package/src/db/workflow-journal-write-ops.ts +33 -0
- package/src/db/workflow-journal.ts +324 -0
- package/src/db/workflow-spawn-quota.ts +57 -0
- package/src/db/workflow-stats-read-ops.ts +177 -0
- package/src/db/workflow-step-tasks.ts +74 -0
- package/src/db/workflow-task-read-ops.ts +187 -0
- package/src/db/workspace-land-state.ts +65 -0
- package/src/db/workspace-merge-hold.ts +28 -0
- package/src/db/workspace-persistence.ts +77 -0
- package/src/db/workspace-rekey-write-ops.ts +11 -0
- package/src/db/workspace-rekey.ts +148 -0
- package/src/db/workspace-steward-cancel.ts +85 -0
- package/src/db/workspace-steward-fence.ts +30 -0
- package/src/db/workspace-write-ops.ts +26 -0
- package/src/db/workspace-writes-async.ts +46 -0
- package/src/db/workspace-writes.ts +196 -0
- package/src/db/workspaces.ts +617 -0
- package/src/db/write-ops.ts +594 -0
- package/src/db/writer-drain.ts +27 -0
- package/src/db/writer-fault-seam.ts +101 -0
- package/src/db/writer-gateway.ts +840 -0
- package/src/db/writer-ledger.ts +56 -0
- package/src/db.ts +4 -0
- package/src/deploy-executor.ts +139 -0
- package/src/dev.ts +541 -0
- package/src/dispatch-availability.ts +55 -0
- package/src/dispatch-match.ts +21 -0
- package/src/ephemeral/host-landing-slots-proof-worker.ts +45 -0
- package/src/ephemeral/index.ts +58 -0
- package/src/ephemeral/instance.ts +832 -0
- package/src/ephemeral/landing-ingress-proof-worker.ts +30 -0
- package/src/ephemeral/ports.ts +40 -0
- package/src/ephemeral/profile.ts +323 -0
- package/src/ephemeral/rehearsal-stamps.ts +149 -0
- package/src/ephemeral/rehearsal.ts +213 -0
- package/src/ephemeral/snapshot-kernel.ts +41 -0
- package/src/ephemeral/snapshot.ts +753 -0
- package/src/ephemeral/sweep.ts +40 -0
- package/src/event-loop-lag.ts +584 -0
- package/src/event-loop-yield.ts +27 -0
- package/src/events.ts +140 -0
- package/src/execution-mode.ts +63 -0
- package/src/fleet-convergence.ts +123 -0
- package/src/gate-resolver.ts +151 -0
- package/src/gate-run-capture.ts +71 -0
- package/src/git-sha.ts +58 -0
- package/src/guides.ts +73 -0
- package/src/host/capacity.ts +79 -0
- package/src/host/gate-capacity-alert.ts +90 -0
- package/src/host/identity.ts +128 -0
- package/src/host/presentation.ts +234 -0
- package/src/host/pressure-details.ts +89 -0
- package/src/host/pressure.ts +216 -0
- package/src/host/state.ts +132 -0
- package/src/host/utilization-buffer.ts +71 -0
- package/src/host-awareness.ts +57 -0
- package/src/host-identity.ts +39 -0
- package/src/host-provider-enablement.ts +75 -0
- package/src/host-provider-store.ts +102 -0
- package/src/host-tools.ts +39 -0
- package/src/http-body.ts +49 -0
- package/src/http-compression.ts +16 -0
- package/src/hub-metrics-report.ts +67 -0
- package/src/hub-metrics.ts +166 -0
- package/src/idle-digest-config.ts +40 -0
- package/src/idle-self-care.ts +58 -0
- package/src/index.ts +35 -0
- package/src/injection-sweep-pacing.ts +24 -0
- package/src/insights-async.ts +16 -0
- package/src/insights-db.ts +188 -0
- package/src/internal-spawn-model.ts +18 -0
- package/src/invite-link.ts +11 -0
- package/src/issue-tracker/adapter.ts +58 -0
- package/src/issue-tracker/github.ts +342 -0
- package/src/issue-tracker/index.ts +12 -0
- package/src/issue-tracker/registry.ts +26 -0
- package/src/journal-preamble.ts +350 -0
- package/src/kernel-correlation.ts +28 -0
- package/src/land-authorization.ts +73 -0
- package/src/land-block.ts +59 -0
- package/src/land-failure-event-key.ts +8 -0
- package/src/land-gate-failure-routing.ts +69 -0
- package/src/land-gate-notifications.ts +173 -0
- package/src/land-gate-queue-progress.ts +54 -0
- package/src/land-gates-source.ts +126 -0
- package/src/land-gates.ts +29 -0
- package/src/land-lifecycle-drives.ts +15 -0
- package/src/land-settle-dispatch.ts +134 -0
- package/src/land-stack-depth.ts +11 -0
- package/src/land-telemetry.ts +40 -0
- package/src/landing-base-ref.ts +3 -0
- package/src/landing-host-safety.ts +38 -0
- package/src/landing-lane-key.ts +74 -0
- package/src/launch-mode-support.ts +11 -0
- package/src/launch-mode.ts +58 -0
- package/src/legacy-landing.test-fixture.ts +56 -0
- package/src/lifecycle-context-pressure.ts +134 -0
- package/src/lifecycle-manager.ts +831 -0
- package/src/lifecycle-signal-registry.ts +87 -0
- package/src/live-runs-section.ts +38 -0
- package/src/loop-block-attribution.ts +442 -0
- package/src/loop-block-regression-alarm.ts +156 -0
- package/src/loop-task-stamps.ts +62 -0
- package/src/main-thread-clock.ts +95 -0
- package/src/maintenance/agent-identity-archive-job.ts +15 -0
- package/src/maintenance/artifact-checkout-gc-job.ts +14 -0
- package/src/maintenance/artifact-checkout-gc.ts +33 -0
- package/src/maintenance/artifact-sweep.ts +23 -0
- package/src/maintenance/breaker.ts +200 -0
- package/src/maintenance/cd-watcher.ts +176 -0
- package/src/maintenance/checkout-refresh.ts +83 -0
- package/src/maintenance/ci-monitor.ts +14 -0
- package/src/maintenance/claude-api-budget-job.ts +16 -0
- package/src/maintenance/constants.ts +134 -0
- package/src/maintenance/continuation-archive-search-job.ts +27 -0
- package/src/maintenance/critical-job-watchdog.ts +252 -0
- package/src/maintenance/db-planner-stats-job.ts +19 -0
- package/src/maintenance/db-wal-reclaim-job.ts +82 -0
- package/src/maintenance/events.ts +28 -0
- package/src/maintenance/gate-capacity-sample-job.ts +16 -0
- package/src/maintenance/index.ts +10 -0
- package/src/maintenance/jobs.ts +857 -0
- package/src/maintenance/long-running-work.ts +41 -0
- package/src/maintenance/orphaned-sessions.ts +126 -0
- package/src/maintenance/pauses.ts +174 -0
- package/src/maintenance/provider-secret-scrub-job.ts +16 -0
- package/src/maintenance/queued-message-expiration.ts +23 -0
- package/src/maintenance/red-main-controller-job.ts +22 -0
- package/src/maintenance/reply-obligation-parity-job.ts +27 -0
- package/src/maintenance/restart-epoch-hold-health.ts +62 -0
- package/src/maintenance/run-registry.ts +194 -0
- package/src/maintenance/scheduler.ts +778 -0
- package/src/maintenance/service-access-job.ts +31 -0
- package/src/maintenance/shipping-stats-rollup-job.ts +23 -0
- package/src/maintenance/snapshot-ledger-prune-job.ts +17 -0
- package/src/maintenance/stalled-delivery-pager.ts +125 -0
- package/src/maintenance/steward-handback.ts +11 -0
- package/src/maintenance/task-state-reconcile-job.ts +22 -0
- package/src/maintenance/teams.ts +426 -0
- package/src/maintenance/types.ts +124 -0
- package/src/maintenance/vault-backup-job.ts +34 -0
- package/src/maintenance/vault-expiry-job.ts +29 -0
- package/src/maintenance/web-tool-call-prune-job.ts +13 -0
- package/src/maintenance/workflow-backstop-job.ts +12 -0
- package/src/maintenance/workflow-journal-prune-job.ts +29 -0
- package/src/maintenance/workspaces.ts +784 -0
- package/src/maintenance.ts +1 -0
- package/src/managed-policy-escalation.ts +123 -0
- package/src/managed-policy.ts +236 -0
- package/src/managed-provider-gate.ts +27 -0
- package/src/managed-spawn-reservation.ts +23 -0
- package/src/markdown-frontmatter.ts +14 -0
- package/src/mcp/activity-output.ts +57 -0
- package/src/mcp/artifact-upload.ts +53 -0
- package/src/mcp/context-output.ts +73 -0
- package/src/mcp/dispatch-shape-schema.ts +13 -0
- package/src/mcp/guides.ts +33 -0
- package/src/mcp/http.ts +27 -0
- package/src/mcp/identity-projection.ts +121 -0
- package/src/mcp/identity.ts +235 -0
- package/src/mcp/index.ts +355 -0
- package/src/mcp/issue-selector-schema.ts +12 -0
- package/src/mcp/message-read.ts +87 -0
- package/src/mcp/output-descriptions.ts +72 -0
- package/src/mcp/output-levels.ts +71 -0
- package/src/mcp/output-projection.ts +88 -0
- package/src/mcp/plan-presentation.ts +166 -0
- package/src/mcp/presentation-values.ts +11 -0
- package/src/mcp/presentation.ts +653 -0
- package/src/mcp/project-entry-search-schema.ts +7 -0
- package/src/mcp/prompts.ts +36 -0
- package/src/mcp/runtime-output.ts +84 -0
- package/src/mcp/schema-budget.ts +28 -0
- package/src/mcp/self-care-visibility.ts +23 -0
- package/src/mcp/service-access.ts +18 -0
- package/src/mcp/spawn-targets-matrix.ts +68 -0
- package/src/mcp/spawn-targets.test-fixture.ts +21 -0
- package/src/mcp/task-validation-presentation.ts +19 -0
- package/src/mcp/tool-generation.ts +8 -0
- package/src/mcp/tool-groups.ts +136 -0
- package/src/mcp/tools-artifacts.ts +82 -0
- package/src/mcp/tools-messaging.ts +541 -0
- package/src/mcp/tools-permission.ts +88 -0
- package/src/mcp/tools-run.ts +73 -0
- package/src/mcp/tools-scheduler.ts +156 -0
- package/src/mcp/tools-spawn.ts +418 -0
- package/src/mcp/tools-web-tool-calls.ts +28 -0
- package/src/mcp/tools-workspace.ts +260 -0
- package/src/mcp/types.ts +68 -0
- package/src/mcp/validation.ts +66 -0
- package/src/mcp-agent-action.ts +96 -0
- package/src/mcp-agent-keep.ts +37 -0
- package/src/mcp-backlog-tools.ts +137 -0
- package/src/mcp-blackboard-tools.ts +131 -0
- package/src/mcp-channel-binding-tools.ts +27 -0
- package/src/mcp-claude-api-budget.ts +35 -0
- package/src/mcp-codex-reset.ts +43 -0
- package/src/mcp-decision-tools.ts +96 -0
- package/src/mcp-dispatch-tools.ts +142 -0
- package/src/mcp-egress-tools.ts +168 -0
- package/src/mcp-errors.ts +7 -0
- package/src/mcp-host-tools.ts +61 -0
- package/src/mcp-interrupt-agent.ts +47 -0
- package/src/mcp-issue-activity-tools.ts +114 -0
- package/src/mcp-issue-association-tools.ts +103 -0
- package/src/mcp-issue-lifecycle-tools.ts +49 -0
- package/src/mcp-issue-ref-tools.ts +214 -0
- package/src/mcp-maintenance-tools.ts +113 -0
- package/src/mcp-merge-tools.ts +66 -0
- package/src/mcp-notification-subscription-tools.ts +297 -0
- package/src/mcp-output-levels.test-fixture.ts +95 -0
- package/src/mcp-plan-tools.ts +347 -0
- package/src/mcp-profile-trust-tools.ts +47 -0
- package/src/mcp-project-journal-tools.ts +160 -0
- package/src/mcp-project-tools.ts +420 -0
- package/src/mcp-provider-catalog.ts +9 -0
- package/src/mcp-release-tools.ts +33 -0
- package/src/mcp-routing-policy-tools.ts +35 -0
- package/src/mcp-secrets-tools.ts +87 -0
- package/src/mcp-task-deliver-tools.ts +166 -0
- package/src/mcp-task-land-withdraw-tools.ts +49 -0
- package/src/mcp-task-memory-tools.ts +119 -0
- package/src/mcp-task-review-hold-tools.ts +57 -0
- package/src/mcp-task-tools.ts +342 -0
- package/src/mcp-task-validation-tools.ts +30 -0
- package/src/mcp-task-weave-tools.ts +63 -0
- package/src/mcp-team-template-tools.ts +141 -0
- package/src/mcp-team-tools.ts +197 -0
- package/src/mcp-tool-allowlist.ts +88 -0
- package/src/mcp-workflow-tools.ts +158 -0
- package/src/mcp.ts +1 -0
- package/src/memory-admission-rank.ts +55 -0
- package/src/memory-area-injection.ts +216 -0
- package/src/memory-boundary-capture.ts +206 -0
- package/src/memory-entry-safety.ts +28 -0
- package/src/memory-inject-filter.ts +190 -0
- package/src/memory-injection.ts +954 -0
- package/src/memory-preamble-admission.ts +158 -0
- package/src/memory-preamble-async.ts +13 -0
- package/src/memory-preamble.ts +1142 -0
- package/src/memory-retirement.ts +11 -0
- package/src/memory-seam.ts +273 -0
- package/src/memory-tokens.ts +91 -0
- package/src/merge-drain.ts +101 -0
- package/src/merge-pause-maintenance.ts +19 -0
- package/src/message-visibility.ts +50 -0
- package/src/messaging-policy.ts +94 -0
- package/src/native-memory.ts +59 -0
- package/src/notification-prefs.ts +25 -0
- package/src/notification-role-policy.ts +14 -0
- package/src/notification-router.ts +329 -0
- package/src/notification-rules.ts +390 -0
- package/src/notification-settings-store.ts +47 -0
- package/src/notification-settings.ts +166 -0
- package/src/notification-subscription-rules.ts +11 -0
- package/src/notification-types.ts +312 -0
- package/src/notify.ts +55 -0
- package/src/observed-reset-boundary.ts +23 -0
- package/src/observed-reset-refresh.ts +21 -0
- package/src/operator-alarm.ts +41 -0
- package/src/operator-decisions-section.ts +29 -0
- package/src/orchestrator-lookup.ts +29 -0
- package/src/orchestrator-self-report-authz.ts +34 -0
- package/src/package-pack.ts +246 -0
- package/src/post-bind-startup.ts +58 -0
- package/src/process-guard.ts +31 -0
- package/src/profile-cells.ts +305 -0
- package/src/profile-effective-survey.ts +121 -0
- package/src/profile-host-sources.ts +73 -0
- package/src/profile-instruction-blocks.ts +11 -0
- package/src/profile-project-validation.ts +23 -0
- package/src/profile-provider-options.ts +59 -0
- package/src/profile-role-templates.ts +26 -0
- package/src/profile-workflow-policy.ts +14 -0
- package/src/project-claudemd-sweep.ts +176 -0
- package/src/project-file-source.ts +54 -0
- package/src/project-ingest.ts +195 -0
- package/src/project-instructions.ts +700 -0
- package/src/project-mcp.ts +18 -0
- package/src/project-role-assets.ts +109 -0
- package/src/project-roles-validate.ts +53 -0
- package/src/project-roles.ts +364 -0
- package/src/project-settings.ts +5 -0
- package/src/project-skills.ts +5 -0
- package/src/project-toolchain.ts +58 -0
- package/src/project-trust-fingerprint.ts +174 -0
- package/src/project-trust.ts +262 -0
- package/src/project-workflows.ts +185 -0
- package/src/prompt-resolver.ts +697 -0
- package/src/prompt-template-fallback.ts +15 -0
- package/src/prompt-version-errors.ts +13 -0
- package/src/provider-catalog-store.ts +393 -0
- package/src/provider-config-store.ts +308 -0
- package/src/provider-enablement.ts +36 -0
- package/src/provider-home-gc.ts +58 -0
- package/src/provider-model-seed.ts +18 -0
- package/src/provider-quota-async.ts +152 -0
- package/src/provider-quota-config-store.ts +60 -0
- package/src/provider-secrets.test-fixture.ts +34 -0
- package/src/provider-state.ts +93 -0
- package/src/provider-timeline-event.ts +76 -0
- package/src/quota-advisory.ts +359 -0
- package/src/quota-band-delivery.ts +13 -0
- package/src/quota-band-projection.ts +149 -0
- package/src/quota-band-transition.ts +316 -0
- package/src/quota-pacing.ts +46 -0
- package/src/quota-threshold-config.ts +46 -0
- package/src/quota.ts +61 -0
- package/src/ratchet-files.ts +202 -0
- package/src/recipe-async.ts +50 -0
- package/src/recipe-db.ts +260 -0
- package/src/recipe-loader.ts +132 -0
- package/src/recipe-runner.ts +259 -0
- package/src/recipe-validator.ts +107 -0
- package/src/relay-event-drain.ts +39 -0
- package/src/relay-host-locality.ts +20 -0
- package/src/relay-run-lease.ts +17 -0
- package/src/repo-config-source.ts +209 -0
- package/src/report-verbosity.ts +5 -0
- package/src/restart-epoch-deploy-hold.ts +221 -0
- package/src/retention-config-store.ts +32 -0
- package/src/retention-config.ts +70 -0
- package/src/reviewer-pipeline.ts +238 -0
- package/src/routes/_route.ts +70 -0
- package/src/routes/_shared.ts +513 -0
- package/src/routes/activity.ts +70 -0
- package/src/routes/agent-effort.ts +69 -0
- package/src/routes/agent-keep.ts +27 -0
- package/src/routes/agent-profiles.ts +169 -0
- package/src/routes/agent-reporting.ts +19 -0
- package/src/routes/agent-self-effort.ts +51 -0
- package/src/routes/agent-sessions.ts +650 -0
- package/src/routes/agent-sharing.ts +23 -0
- package/src/routes/agents-spawn.ts +258 -0
- package/src/routes/agents.ts +452 -0
- package/src/routes/artifacts.ts +340 -0
- package/src/routes/auth.ts +123 -0
- package/src/routes/authority-audit.ts +14 -0
- package/src/routes/automations.ts +83 -0
- package/src/routes/backlog.ts +112 -0
- package/src/routes/blackboard.ts +54 -0
- package/src/routes/browser.ts +73 -0
- package/src/routes/channel-binding-delete.ts +21 -0
- package/src/routes/channel-output.ts +17 -0
- package/src/routes/claude-api-budget.ts +65 -0
- package/src/routes/commands-listing.ts +50 -0
- package/src/routes/commands.ts +586 -0
- package/src/routes/config.ts +75 -0
- package/src/routes/connectors.ts +108 -0
- package/src/routes/context-resets.ts +35 -0
- package/src/routes/continuation-archives.ts +37 -0
- package/src/routes/coordinator-teams.ts +14 -0
- package/src/routes/decisions.ts +82 -0
- package/src/routes/deploys.ts +15 -0
- package/src/routes/fleet-convergence.ts +5 -0
- package/src/routes/guides.ts +13 -0
- package/src/routes/host-providers.ts +73 -0
- package/src/routes/host-resource-control.ts +45 -0
- package/src/routes/host-secret-files.ts +38 -0
- package/src/routes/hosts.ts +240 -0
- package/src/routes/inbox.ts +151 -0
- package/src/routes/index.ts +614 -0
- package/src/routes/insights.ts +86 -0
- package/src/routes/integrations.ts +636 -0
- package/src/routes/issue-activity.ts +78 -0
- package/src/routes/issue-associations.ts +76 -0
- package/src/routes/issue-lifecycle.ts +34 -0
- package/src/routes/issue-refs.ts +163 -0
- package/src/routes/kernel-timers-operator.ts +57 -0
- package/src/routes/memory.ts +25 -0
- package/src/routes/merges.ts +109 -0
- package/src/routes/message-viewer.ts +4 -0
- package/src/routes/messages.ts +621 -0
- package/src/routes/notifications.ts +36 -0
- package/src/routes/orchestrator-bootstrap.ts +101 -0
- package/src/routes/orchestrator-host-registration.ts +125 -0
- package/src/routes/orchestrator-host-utilization.ts +255 -0
- package/src/routes/orchestrator-proxy.ts +174 -0
- package/src/routes/orchestrator.ts +699 -0
- package/src/routes/pairs.ts +214 -0
- package/src/routes/plans.ts +98 -0
- package/src/routes/project-onboarding.ts +56 -0
- package/src/routes/project-trust.ts +73 -0
- package/src/routes/projects.ts +296 -0
- package/src/routes/prompt-templates.ts +106 -0
- package/src/routes/provider-config.ts +232 -0
- package/src/routes/provider-quota-config.ts +48 -0
- package/src/routes/provider-quotas.ts +312 -0
- package/src/routes/provisioning-registry.ts +192 -0
- package/src/routes/recipes.ts +129 -0
- package/src/routes/restart-epochs.ts +98 -0
- package/src/routes/routing-policy.ts +30 -0
- package/src/routes/run-command.ts +25 -0
- package/src/routes/secrets-backup.ts +53 -0
- package/src/routes/secrets-import.ts +32 -0
- package/src/routes/secrets-page.ts +98 -0
- package/src/routes/secrets-vault.ts +121 -0
- package/src/routes/secrets.ts +165 -0
- package/src/routes/service-access.ts +57 -0
- package/src/routes/settings.ts +191 -0
- package/src/routes/shipping.ts +56 -0
- package/src/routes/spawn-policy.ts +299 -0
- package/src/routes/spec.ts +58 -0
- package/src/routes/sse.ts +18 -0
- package/src/routes/stats.ts +159 -0
- package/src/routes/steward.ts +49 -0
- package/src/routes/task-graph.ts +30 -0
- package/src/routes/task-http.ts +27 -0
- package/src/routes/task-issues.ts +81 -0
- package/src/routes/task-reads.ts +139 -0
- package/src/routes/task-validation.ts +22 -0
- package/src/routes/tasks.ts +553 -0
- package/src/routes/team-templates.ts +65 -0
- package/src/routes/teams-config.ts +15 -0
- package/src/routes/teams.ts +141 -0
- package/src/routes/token-usage.ts +167 -0
- package/src/routes/tokens.ts +393 -0
- package/src/routes/users.ts +248 -0
- package/src/routes/viewer-read.ts +27 -0
- package/src/routes/web-tool-calls.ts +38 -0
- package/src/routes/workflows.ts +142 -0
- package/src/routes/workspaces.ts +642 -0
- package/src/routes.ts +3 -0
- package/src/routing-eligibility.ts +42 -0
- package/src/routing-model-aliases.ts +21 -0
- package/src/routing-policy-normalize.ts +412 -0
- package/src/routing-policy-push.ts +154 -0
- package/src/routing-policy-service.ts +19 -0
- package/src/routing-policy-store.ts +16 -0
- package/src/routing-preferences.ts +82 -0
- package/src/routing-step-defaults.ts +31 -0
- package/src/runtime-grant.ts +164 -0
- package/src/runtime-prefix.ts +8 -0
- package/src/runtime-tokens.ts +395 -0
- package/src/search-query.ts +10 -0
- package/src/secret-keys.ts +24 -0
- package/src/secrets-broker/config.ts +53 -0
- package/src/secrets-broker/error.ts +8 -0
- package/src/secrets-broker/infisical.ts +259 -0
- package/src/secrets-broker/reader-infisical.ts +41 -0
- package/src/secrets-broker/reader.ts +101 -0
- package/src/secrets-broker/service.ts +242 -0
- package/src/secrets-broker/tool-credentials.ts +9 -0
- package/src/secrets-vault/backend-conformance.ts +26 -0
- package/src/secrets-vault/backend.ts +102 -0
- package/src/secrets-vault/backup.ts +103 -0
- package/src/secrets-vault/config.ts +7 -0
- package/src/secrets-vault/expiry.ts +10 -0
- package/src/secrets-vault/identity.ts +27 -0
- package/src/secrets-vault/import.ts +90 -0
- package/src/secrets-vault/key-files.ts +91 -0
- package/src/secrets-vault/keys.ts +79 -0
- package/src/secrets-vault/metadata.ts +51 -0
- package/src/secrets-vault/provider-env.ts +25 -0
- package/src/secrets-vault/resolve.ts +101 -0
- package/src/secrets-vault/restore.ts +57 -0
- package/src/secrets-vault/scope.ts +25 -0
- package/src/secrets-vault/service.ts +192 -0
- package/src/secrets-vault/shared.ts +10 -0
- package/src/security.ts +772 -0
- package/src/self-effort-rule.ts +36 -0
- package/src/self-resume-carry.ts +131 -0
- package/src/self-resume-command.ts +24 -0
- package/src/self-resume-config.ts +54 -0
- package/src/self-resume-identity.ts +40 -0
- package/src/self-resume-supersede.ts +19 -0
- package/src/self-resume.ts +884 -0
- package/src/server-background.ts +24 -0
- package/src/server.ts +726 -0
- package/src/service-access/config.ts +3 -0
- package/src/service-access/health.ts +151 -0
- package/src/service-access/host-health.ts +62 -0
- package/src/service-access/host.ts +63 -0
- package/src/service-access/operations.ts +21 -0
- package/src/service-access/policy.ts +30 -0
- package/src/service-access/probe.ts +62 -0
- package/src/service-access/request-logs.ts +93 -0
- package/src/service-access/scope.ts +7 -0
- package/src/service-access/service.ts +185 -0
- package/src/service-access/tokens.ts +174 -0
- package/src/service-access/validation.ts +75 -0
- package/src/service-access/vault.ts +59 -0
- package/src/services/agent-action.ts +238 -0
- package/src/services/agent-control-host.ts +74 -0
- package/src/services/agent-effort.ts +60 -0
- package/src/services/agent-hang-watchdog-job.ts +513 -0
- package/src/services/agent-hang-watchdog-wiring.ts +487 -0
- package/src/services/agent-hang-watchdog.ts +395 -0
- package/src/services/agent-keep.ts +72 -0
- package/src/services/agent-message-fanout.ts +91 -0
- package/src/services/agent-outstanding-work.ts +66 -0
- package/src/services/agent-reporting.ts +27 -0
- package/src/services/artifact-access.ts +39 -0
- package/src/services/artifact-multipart.ts +70 -0
- package/src/services/artifact-path-host.ts +55 -0
- package/src/services/artifact-read.ts +88 -0
- package/src/services/artifact-write.ts +25 -0
- package/src/services/auth-context.ts +117 -0
- package/src/services/automatic-disposal.ts +33 -0
- package/src/services/backlog.ts +149 -0
- package/src/services/browser-inventory.ts +52 -0
- package/src/services/browser-session-state.ts +41 -0
- package/src/services/browser-session.ts +167 -0
- package/src/services/bus-command-update.ts +84 -0
- package/src/services/bus-expiration-death.ts +57 -0
- package/src/services/canonical-root.ts +284 -0
- package/src/services/captured-delivery-gate.ts +12 -0
- package/src/services/carry-pending.ts +5 -0
- package/src/services/channel-binding-delete.ts +20 -0
- package/src/services/channel-suppression-receipt.ts +28 -0
- package/src/services/checkout-refresh-state.ts +18 -0
- package/src/services/checkout-refresh.test-fixture.ts +12 -0
- package/src/services/child-work-evidence.ts +77 -0
- package/src/services/claude-app.ts +91 -0
- package/src/services/command-claim-rejection.ts +23 -0
- package/src/services/command-host.ts +42 -0
- package/src/services/coordinator-digest.ts +30 -0
- package/src/services/decision-audience.ts +26 -0
- package/src/services/delivery-gate-policy.ts +98 -0
- package/src/services/delivery-tip.test-fixture.ts +25 -0
- package/src/services/diff-gate.ts +110 -0
- package/src/services/dispatch-command.ts +388 -0
- package/src/services/effective-launch-driver.ts +240 -0
- package/src/services/effective-launch-harness.ts +257 -0
- package/src/services/errors.ts +31 -0
- package/src/services/git-process.ts +176 -0
- package/src/services/git-remote.ts +100 -0
- package/src/services/harness-subagents.ts +12 -0
- package/src/services/host-changed-paths.test-fixture.ts +134 -0
- package/src/services/host-landing-placement.ts +65 -0
- package/src/services/host-project-readiness.ts +49 -0
- package/src/services/host-providers.ts +114 -0
- package/src/services/host-utilization.ts +70 -0
- package/src/services/idle-agent-digest.ts +318 -0
- package/src/services/idle-epics.ts +105 -0
- package/src/services/idle-self-care.ts +47 -0
- package/src/services/interrupt-agent.ts +146 -0
- package/src/services/isolated-workspace-placement.ts +258 -0
- package/src/services/issue-activity.ts +23 -0
- package/src/services/issue-associations.ts +72 -0
- package/src/services/issue-completion-drain.ts +24 -0
- package/src/services/issue-completion.ts +24 -0
- package/src/services/issue-lifecycle-comments.ts +12 -0
- package/src/services/issue-lifecycle.ts +620 -0
- package/src/services/issue-refs.ts +65 -0
- package/src/services/kernel-command-bridge.ts +219 -0
- package/src/services/kernel-control-host.ts +78 -0
- package/src/services/kernel-control-http.ts +119 -0
- package/src/services/kernel-control-mcp.ts +193 -0
- package/src/services/kernel-landing-command.ts +28 -0
- package/src/services/kernel-landing-ingress.ts +65 -0
- package/src/services/kernel-timers-authoritative-ingress.ts +48 -0
- package/src/services/kernel-timers-authz.ts +229 -0
- package/src/services/kernel-timers-command.ts +182 -0
- package/src/services/kernel-timers-cutover-chaos-worker.ts +209 -0
- package/src/services/kernel-timers-cutover.ts +39 -0
- package/src/services/kernel-timers-ingress-apply.ts +39 -0
- package/src/services/kernel-timers-ingress-chaos-worker.ts +312 -0
- package/src/services/kernel-timers-ingress.ts +702 -0
- package/src/services/kernel-timers-message-authority-chaos-worker.ts +97 -0
- package/src/services/kernel-timers-migrate.ts +158 -0
- package/src/services/kernel-timers-operator-chaos-worker.ts +259 -0
- package/src/services/kernel-timers-operator-preflight.ts +18 -0
- package/src/services/kernel-timers-operator.ts +424 -0
- package/src/services/kernel-timers-outbox.ts +138 -0
- package/src/services/kernel-timers-request-key-migration-chaos-worker.ts +77 -0
- package/src/services/kernel-timers-stage10-operator.ts +210 -0
- package/src/services/kernel-timers-stage10.ts +85 -0
- package/src/services/kernel-timers-stage9.ts +57 -0
- package/src/services/kernel-timers-transfer-chaos-worker.ts +118 -0
- package/src/services/kernel-timers-transfer.ts +525 -0
- package/src/services/kernel-timers-verifier.ts +39 -0
- package/src/services/kernel-timers.ts +247 -0
- package/src/services/land-boundary-settle.ts +32 -0
- package/src/services/land-gate-placement.ts +60 -0
- package/src/services/land-issue-relations.ts +46 -0
- package/src/services/land-restart-retry.ts +77 -0
- package/src/services/landed-ancestry.ts +417 -0
- package/src/services/landed-task-attribution.ts +14 -0
- package/src/services/landing-terminal-report.ts +119 -0
- package/src/services/legacy-landing-backfill.ts +159 -0
- package/src/services/legacy-landing-host.ts +291 -0
- package/src/services/legacy-landing-publication.ts +35 -0
- package/src/services/legacy-landing-recovery.ts +111 -0
- package/src/services/macos-privacy.ts +34 -0
- package/src/services/managed-running.ts +189 -0
- package/src/services/memory-areas.ts +172 -0
- package/src/services/memory-identity.ts +162 -0
- package/src/services/merge-pause.ts +37 -0
- package/src/services/message-delivery-actions.ts +11 -0
- package/src/services/operator-decisions.ts +260 -0
- package/src/services/orchestrator-landing-recovery.ts +55 -0
- package/src/services/orchestrator-registration-recovery.ts +12 -0
- package/src/services/orchestrator-upgrade.ts +83 -0
- package/src/services/parity-harness.ts +141 -0
- package/src/services/permission-decision.ts +129 -0
- package/src/services/plan-ci-recovery.ts +76 -0
- package/src/services/plan-conformance.ts +105 -0
- package/src/services/plan-dispatch-policy.ts +79 -0
- package/src/services/plan-dispatch.ts +372 -0
- package/src/services/plan-external-view.ts +7 -0
- package/src/services/plan-frontier.ts +34 -0
- package/src/services/plan-graph.ts +703 -0
- package/src/services/plan-import.ts +66 -0
- package/src/services/plan-live-bindings.ts +139 -0
- package/src/services/plan-task-create.ts +80 -0
- package/src/services/plan-terminal-refs.ts +83 -0
- package/src/services/plan-wake-digest.ts +88 -0
- package/src/services/plan-wake-policy.ts +12 -0
- package/src/services/profile-trust.ts +54 -0
- package/src/services/project-checkout-binding.ts +65 -0
- package/src/services/project-checkout-enrollment.ts +27 -0
- package/src/services/project-cwd.ts +41 -0
- package/src/services/project-onboarding.ts +165 -0
- package/src/services/project-repo-create.ts +27 -0
- package/src/services/project-role.test-fixture.ts +74 -0
- package/src/services/project.ts +191 -0
- package/src/services/prompt-templates.ts +46 -0
- package/src/services/prompt-version-writer.ts +42 -0
- package/src/services/provider-catalog.ts +7 -0
- package/src/services/provider-hold-flap.ts +130 -0
- package/src/services/provider-hold-nudge.ts +191 -0
- package/src/services/provider-hold-record.ts +137 -0
- package/src/services/provider-state-audit.ts +214 -0
- package/src/services/provisioning-harness/analyze.ts +285 -0
- package/src/services/provisioning-harness/budget-baseline.json +391 -0
- package/src/services/provisioning-harness/capture.ts +197 -0
- package/src/services/provisioning-harness/config.ts +55 -0
- package/src/services/provisioning-harness/context-sources.ts +85 -0
- package/src/services/provisioning-harness/driver.ts +156 -0
- package/src/services/provisioning-harness/expect.ts +81 -0
- package/src/services/provisioning-harness/fixture-matrix.ts +38 -0
- package/src/services/provisioning-harness/fixtures/project/.agent-relay/land-gates.json +1 -0
- package/src/services/provisioning-harness/fixtures/project/.claude/skills/harness-skill/SKILL.md +6 -0
- package/src/services/provisioning-harness/fixtures/project/.mcp.json +1 -0
- package/src/services/provisioning-harness/fixtures/project/AGENTS.md +1 -0
- package/src/services/provisioning-harness/fixtures/project/CLAUDE.md +1 -0
- package/src/services/provisioning-harness/fixtures/project/mcp-server.ts +33 -0
- package/src/services/provisioning-harness/fixtures/provider-home/AGENTS.md +1 -0
- package/src/services/provisioning-harness/fixtures/provider-home/CLAUDE.md +1 -0
- package/src/services/provisioning-harness/host-fixtures.ts +25 -0
- package/src/services/provisioning-harness/index.ts +4 -0
- package/src/services/provisioning-harness/inventory-types.ts +8 -0
- package/src/services/provisioning-harness/inventory.ts +33 -0
- package/src/services/provisioning-harness/lifecycle.ts +193 -0
- package/src/services/provisioning-harness/live.ts +61 -0
- package/src/services/provisioning-harness/manifests.ts +118 -0
- package/src/services/provisioning-harness/prepare.ts +113 -0
- package/src/services/provisioning-harness/redundancy-report.ts +32 -0
- package/src/services/provisioning-harness/redundancy.ts +137 -0
- package/src/services/provisioning-harness/report.ts +129 -0
- package/src/services/provisioning-harness/types.ts +174 -0
- package/src/services/provisioning-registry.ts +15 -0
- package/src/services/rate-limit-resume.ts +220 -0
- package/src/services/reap-verdict.ts +52 -0
- package/src/services/red-main-auto-revert.ts +103 -0
- package/src/services/red-main-controller-deps.ts +80 -0
- package/src/services/red-main-controller.ts +262 -0
- package/src/services/red-main-incident.ts +44 -0
- package/src/services/red-main-quarantine.ts +92 -0
- package/src/services/register-agent.ts +447 -0
- package/src/services/release-readiness.ts +219 -0
- package/src/services/reported-exit-death.ts +29 -0
- package/src/services/response-report-admission.ts +17 -0
- package/src/services/restart-epoch-driver.ts +290 -0
- package/src/services/restart-epoch-reconciler.ts +326 -0
- package/src/services/restart-epoch-stale-command-recovery.ts +133 -0
- package/src/services/restart-instructions.ts +86 -0
- package/src/services/restart-project-role.ts +74 -0
- package/src/services/restart-secret-refs.ts +14 -0
- package/src/services/restart-spawn.ts +510 -0
- package/src/services/review-publish.ts +76 -0
- package/src/services/review-ref-reconcile.ts +337 -0
- package/src/services/run-command-input.ts +22 -0
- package/src/services/run-command.ts +510 -0
- package/src/services/run-completion-message.ts +70 -0
- package/src/services/run-log.ts +212 -0
- package/src/services/run-queue.ts +63 -0
- package/src/services/scheduler-command-cancel.ts +49 -0
- package/src/services/scheduler-command.ts +590 -0
- package/src/services/scheduler-create.ts +25 -0
- package/src/services/scheduler-plan.ts +202 -0
- package/src/services/scheduler-recovery.ts +31 -0
- package/src/services/scheduler.ts +406 -0
- package/src/services/self-care-state.ts +10 -0
- package/src/services/self-effort-grant.ts +93 -0
- package/src/services/self-effort.ts +152 -0
- package/src/services/send-message.ts +548 -0
- package/src/services/server-credentials.ts +53 -0
- package/src/services/shipping-board.ts +111 -0
- package/src/services/shipping-project-config.ts +86 -0
- package/src/services/shipping-stats.ts +86 -0
- package/src/services/shutdown-agent.ts +463 -0
- package/src/services/shutdown-watchdog.ts +119 -0
- package/src/services/spawn-agent.ts +967 -0
- package/src/services/spawn-approval.ts +26 -0
- package/src/services/spawn-brief.ts +39 -0
- package/src/services/spawn-chain-inspector.ts +286 -0
- package/src/services/spawn-cwd-placement.ts +250 -0
- package/src/services/spawn-identity.ts +127 -0
- package/src/services/spawn-instruction-inputs.ts +114 -0
- package/src/services/spawn-issue-activity.ts +102 -0
- package/src/services/spawn-launch-decision.ts +32 -0
- package/src/services/spawn-launch.ts +116 -0
- package/src/services/spawn-loss-escalation.ts +253 -0
- package/src/services/spawn-placement.test-fixture.ts +30 -0
- package/src/services/spawn-project-role.ts +133 -0
- package/src/services/spawn-registration-watchdog.ts +352 -0
- package/src/services/spawn-replay.ts +61 -0
- package/src/services/spawn-repo-probe.ts +118 -0
- package/src/services/spawn-tree-cleanup.ts +37 -0
- package/src/services/spawn-warnings.ts +13 -0
- package/src/services/steward-reaper.ts +244 -0
- package/src/services/task-context-hydration.ts +413 -0
- package/src/services/task-delivery-close.ts +26 -0
- package/src/services/task-delivery-event.ts +11 -0
- package/src/services/task-delivery-land-policy.ts +35 -0
- package/src/services/task-delivery-summary.ts +38 -0
- package/src/services/task-delivery.ts +762 -0
- package/src/services/task-dependency-graph.ts +116 -0
- package/src/services/task-dispatch.ts +178 -0
- package/src/services/task-done-when.ts +45 -0
- package/src/services/task-entity.ts +758 -0
- package/src/services/task-from-issue.ts +80 -0
- package/src/services/task-issue-digest.ts +45 -0
- package/src/services/task-issue-link.ts +158 -0
- package/src/services/task-issue-weave.ts +570 -0
- package/src/services/task-land-withdraw.ts +462 -0
- package/src/services/task-lifecycle.ts +668 -0
- package/src/services/task-nothing-to-land.ts +37 -0
- package/src/services/task-plan-view.ts +172 -0
- package/src/services/task-review-hold.ts +244 -0
- package/src/services/task-semantic-events.ts +396 -0
- package/src/services/task-stage-wake.ts +15 -0
- package/src/services/task-state-reconcile.ts +169 -0
- package/src/services/task-validation.ts +42 -0
- package/src/services/team-claim-race.worker.ts +72 -0
- package/src/services/team-spawn-delegation.ts +30 -0
- package/src/services/team-templates.ts +172 -0
- package/src/services/team.ts +320 -0
- package/src/services/terminal-provider-exit.ts +57 -0
- package/src/services/timer-message-fire-chaos-worker.ts +29 -0
- package/src/services/timer-message-fire-outbox.ts +184 -0
- package/src/services/transient-agent-reaper.ts +412 -0
- package/src/services/turn-reconcile-audit.ts +236 -0
- package/src/services/user-onboarding.ts +98 -0
- package/src/services/user-profile.ts +57 -0
- package/src/services/web-search.ts +83 -0
- package/src/services/web-tool-calls.ts +65 -0
- package/src/services/withdraw-steward.ts +57 -0
- package/src/services/work-finality.ts +34 -0
- package/src/services/workflow-agent-obligation.ts +35 -0
- package/src/services/workflow-auto-start.ts +126 -0
- package/src/services/workflow-backstop.ts +38 -0
- package/src/services/workflow-budget.test-fixture.ts +10 -0
- package/src/services/workflow-caller.ts +32 -0
- package/src/services/workflow-catalog.ts +43 -0
- package/src/services/workflow-child-proof-worker.ts +76 -0
- package/src/services/workflow-child.test-fixture.ts +51 -0
- package/src/services/workflow-ci-main.ts +93 -0
- package/src/services/workflow-control-proof-worker.ts +149 -0
- package/src/services/workflow-coordinator-decision-proof-worker.ts +123 -0
- package/src/services/workflow-coordinator.ts +8 -0
- package/src/services/workflow-decision-answer.ts +18 -0
- package/src/services/workflow-decision-proof-worker.ts +92 -0
- package/src/services/workflow-decision.test-fixture.ts +58 -0
- package/src/services/workflow-decisions.ts +107 -0
- package/src/services/workflow-deferred-cleanup.ts +40 -0
- package/src/services/workflow-dispatch-result.ts +20 -0
- package/src/services/workflow-effect-driver.ts +165 -0
- package/src/services/workflow-effects.ts +544 -0
- package/src/services/workflow-foreach-proof-worker.ts +209 -0
- package/src/services/workflow-land-notice.ts +18 -0
- package/src/services/workflow-land.ts +105 -0
- package/src/services/workflow-notice.ts +32 -0
- package/src/services/workflow-overdue-notice.ts +19 -0
- package/src/services/workflow-pins.ts +162 -0
- package/src/services/workflow-reconcile.ts +210 -0
- package/src/services/workflow-resume-pins.ts +30 -0
- package/src/services/workflow-run-chaos-worker.ts +67 -0
- package/src/services/workflow-run-view.ts +71 -0
- package/src/services/workflow-run.test-fixture.ts +165 -0
- package/src/services/workflow-runs.ts +370 -0
- package/src/services/workflow-scripts.ts +100 -0
- package/src/services/workflow-slice-proof.ts +14 -0
- package/src/services/workflow-stats.ts +208 -0
- package/src/services/workflow-supervisor-state.ts +117 -0
- package/src/services/workflow-supervisor.ts +122 -0
- package/src/services/workflow-verification.ts +68 -0
- package/src/services/workspace-recovery.ts +168 -0
- package/src/services/workspace-task-binding.ts +22 -0
- package/src/settings/modules.ts +149 -0
- package/src/settings/registry.ts +629 -0
- package/src/settings/user-settings.ts +81 -0
- package/src/setup.ts +199 -0
- package/src/shared-mcp.ts +87 -0
- package/src/shutdown.ts +33 -0
- package/src/spawn-admission.ts +48 -0
- package/src/spawn-budget.ts +18 -0
- package/src/spawn-command.ts +373 -0
- package/src/spawn-env.ts +27 -0
- package/src/spawn-intent.ts +17 -0
- package/src/spawn-lease.ts +41 -0
- package/src/spawn-models.ts +22 -0
- package/src/spawn-placement.ts +348 -0
- package/src/spawn-profile-errors.ts +9 -0
- package/src/spawn-quota.ts +15 -0
- package/src/spawn-targets.ts +679 -0
- package/src/sse-agent-status.ts +35 -0
- package/src/sse-outbox-cursor.ts +28 -0
- package/src/sse-visibility.ts +36 -0
- package/src/sse.ts +684 -0
- package/src/startup-context-injection.ts +518 -0
- package/src/startup-timing.ts +30 -0
- package/src/state-adoption/artifacts.ts +27 -0
- package/src/state-adoption/cd-cutover.ts +125 -0
- package/src/state-adoption/files.ts +31 -0
- package/src/state-adoption/index.ts +166 -0
- package/src/state-adoption/linux-plan.ts +67 -0
- package/src/state-adoption/linux.ts +104 -0
- package/src/state-adoption/macos-plan.ts +58 -0
- package/src/state-adoption/macos.ts +112 -0
- package/src/steward-claim-release.ts +38 -0
- package/src/steward-handoff.ts +28 -0
- package/src/steward-identity.ts +54 -0
- package/src/steward-policy-cleanup.ts +222 -0
- package/src/steward-policy-model-reconcile.ts +33 -0
- package/src/steward-policy-name.ts +13 -0
- package/src/steward-provenance.ts +59 -0
- package/src/steward-queue.ts +85 -0
- package/src/steward-slot-recovery.ts +34 -0
- package/src/steward-spawn-guard.ts +344 -0
- package/src/steward.test-fixture.ts +11 -0
- package/src/steward.ts +199 -0
- package/src/stream-proxy.ts +84 -0
- package/src/task-authz.ts +40 -0
- package/src/task-completion.ts +39 -0
- package/src/task-dispatch-live.ts +70 -0
- package/src/task-dispatcher-ranking.ts +136 -0
- package/src/task-dispatcher.ts +841 -0
- package/src/task-owner-notices.ts +35 -0
- package/src/task-owner.ts +63 -0
- package/src/task-plan-status.ts +21 -0
- package/src/task-verification.ts +35 -0
- package/src/team-idle-tracker.ts +39 -0
- package/src/team-template-config.ts +100 -0
- package/src/teams-config-store.ts +22 -0
- package/src/terminal-authz.ts +49 -0
- package/src/token-db-write.ts +44 -0
- package/src/token-db.ts +487 -0
- package/src/token-usage-async.ts +40 -0
- package/src/transport-subscriptions.ts +57 -0
- package/src/types.ts +1 -0
- package/src/upgrade-install-verify.ts +179 -0
- package/src/upgrade-local-id.ts +3 -0
- package/src/upgrade-services.ts +125 -0
- package/src/upgrade.ts +1006 -0
- package/src/user-awaiting-reply.ts +42 -0
- package/src/user-path.ts +246 -0
- package/src/user-settings-async.ts +33 -0
- package/src/user-settings-store.ts +106 -0
- package/src/user-style.ts +83 -0
- package/src/utils.ts +42 -0
- package/src/validation.ts +324 -0
- package/src/vault-backup-config.ts +28 -0
- package/src/vault-expiry-config.ts +12 -0
- package/src/versioned-prompts.ts +57 -0
- package/src/workflow-capabilities.ts +10 -0
- package/src/workflow-prompt-templates.ts +20 -0
- package/src/workspace-action-audit.ts +42 -0
- package/src/workspace-actions.ts +689 -0
- package/src/workspace-auto-merge.ts +1055 -0
- package/src/workspace-changed-paths-client.ts +97 -0
- package/src/workspace-claim.ts +45 -0
- package/src/workspace-cleanup-settle.ts +51 -0
- package/src/workspace-cleanup-stale.ts +231 -0
- package/src/workspace-command-settle.ts +589 -0
- package/src/workspace-config.ts +7 -0
- package/src/workspace-conflict-resolver.ts +182 -0
- package/src/workspace-dead-owner-recovery.ts +19 -0
- package/src/workspace-delivery-tip.ts +51 -0
- package/src/workspace-escalation.ts +107 -0
- package/src/workspace-git-state-client.ts +42 -0
- package/src/workspace-host-client.ts +86 -0
- package/src/workspace-host-target.ts +5 -0
- package/src/workspace-host.ts +61 -0
- package/src/workspace-human-escalation.ts +70 -0
- package/src/workspace-land-gate-watchdog.ts +76 -0
- package/src/workspace-land-gate.ts +99 -0
- package/src/workspace-land-result.ts +12 -0
- package/src/workspace-land-retry.ts +82 -0
- package/src/workspace-land-stopped.ts +57 -0
- package/src/workspace-merge-dispatch.ts +27 -0
- package/src/workspace-merge-progress.ts +369 -0
- package/src/workspace-merge-retry-policy.ts +59 -0
- package/src/workspace-merge.ts +614 -0
- package/src/workspace-nothing-to-land-notice.ts +27 -0
- package/src/workspace-orphans.ts +927 -0
- package/src/workspace-phase.ts +507 -0
- package/src/workspace-pr-completion.ts +285 -0
- package/src/workspace-probe.ts +212 -0
- package/src/workspace-recorded-land.ts +47 -0
- package/src/workspace-recovery-authz.ts +88 -0
- package/src/workspace-rekey.ts +106 -0
- package/src/workspace-steward-authority.ts +16 -0
- package/src/workspace-steward-failure.ts +42 -0
- package/src/workspace-steward-wake.ts +150 -0
- package/src/workspace-steward-watchdog.ts +240 -0
|
@@ -0,0 +1,1761 @@
|
|
|
1
|
+
import { PLAN_DISPATCH_SCHEMA_SQL } from "./plan-dispatch-schema";
|
|
2
|
+
import { PLAN_IMPORT_SCHEMA_SQL } from "./plan-import-schema";
|
|
3
|
+
import { ensureDurablePayloadSchema } from "./durable-payloads"; import { redactProviderConfigHistory } from "./provider-config-history"; import { retireMemoryStorage } from "./memory-retirement";
|
|
4
|
+
import { migrateProjectRootHosts } from "./project-root-schema";
|
|
5
|
+
import { migrateBrokerMemories } from "./broker-memory-migration";
|
|
6
|
+
import { installProjectEntrySearch } from "./project-entry-search";
|
|
7
|
+
import { LONG_RUNNING_WORK_SCHEMA } from "./long-running-work";
|
|
8
|
+
import { CI_GATE_BACKFILL_SCHEMA, repairRerunGateTimings } from "./ci-gate-runs.ts";
|
|
9
|
+
import { ensureCiShaObservationsSchema } from "./ci-sha-observations-schema.ts";
|
|
10
|
+
import { AGENT_GATE_RUNS_SCHEMA, ensureAgentGateCommandSchema } from "./agent-gate-runs.ts";
|
|
11
|
+
import { ensureSpawnTreeStopSchema } from "./spawn-delegation-state";
|
|
12
|
+
import { CLAUDE_APP_OAUTH_SCHEMA } from "./claude-app-oauth";
|
|
13
|
+
import { ensureVaultTokensSchema } from "./vault-tokens";
|
|
14
|
+
import { ensureVaultHealthSchema } from "./vault-health";
|
|
15
|
+
import { ensureWebToolCallsSchema } from "./web-tool-calls";
|
|
16
|
+
import { ensureArtifactRetentionSchema } from "./artifact-retention";
|
|
17
|
+
import { installAgentIdentityArchive } from "./agent-identity-archive";
|
|
18
|
+
import { ensureIssueAssociationRelationSchema } from "./task-issue-relation";
|
|
19
|
+
import { CLAUDE_API_BUDGET_SCHEMA } from "./claude-api-budget";
|
|
20
|
+
import { backfillLegacyMessages } from "./legacy-message-backfill";
|
|
21
|
+
import { installHistoryDeliverySettlement } from "./history-delivery-settle";
|
|
22
|
+
import { installReplyObligations } from "./reply-obligations";
|
|
23
|
+
import { beginStartupPhase, timeStartupPhase } from "../startup-timing";
|
|
24
|
+
import { Database } from "bun:sqlite";
|
|
25
|
+
import { AGENT_EXIT_REPORT_SCHEMA } from "./agent-exit-report";
|
|
26
|
+
import { CONTEXT_RESET_SCHEMA } from "./context-reset-carry";
|
|
27
|
+
import { TASK_TOKEN_TOTALS_SCHEMA } from "./token-usage";
|
|
28
|
+
import { SHIPPING_STATS_SCHEMA } from "./shipping-stats-schema";
|
|
29
|
+
import { migrateOperatorActionsSchema } from "./operator-actions-schema";
|
|
30
|
+
import { SELF_EFFORT_PERMISSIONS_SCHEMA } from "./self-effort-permissions";
|
|
31
|
+
import { AGENT_EFFORT_STATE_SCHEMA, importLegacyEffortCommands } from "./agent-effort-state";
|
|
32
|
+
import { randomUUID } from "node:crypto";
|
|
33
|
+
import { isRecord, stringValue, isMechanicalMessageKind } from "@humwick/sdk";
|
|
34
|
+
import { ORCHESTRATOR_PROTOCOL_VERSION, VERSION } from "../config.ts";
|
|
35
|
+
import { parseJson } from "../utils";
|
|
36
|
+
import { isLiveIsolatedWorkspace } from "../workspace-phase";
|
|
37
|
+
import {
|
|
38
|
+
CONTRACT_REQUIREMENTS,
|
|
39
|
+
contractCompatibility,
|
|
40
|
+
parseRuntimeCapabilities,
|
|
41
|
+
parseRuntimeContracts,
|
|
42
|
+
parseRuntimePackage,
|
|
43
|
+
type RuntimeContracts,
|
|
44
|
+
} from "../contracts";
|
|
45
|
+
import { STALE_TTL_MS, DAY_MS, CLAIM_LEASE_MS, POOL_CLAIM_LEASE_MS, WORKSPACE_MERGE_LEASE_MS } from "../config";
|
|
46
|
+
import { matchAgents } from "../agent-ref";
|
|
47
|
+
import { COORDINATOR_PROFILE_NAMES } from "../agent-system-tags";
|
|
48
|
+
import { getDb } from "./connection.ts";
|
|
49
|
+
import { normalizeExistingAgentSpawnRequestIds } from "./spawn-request-id-migration.ts";
|
|
50
|
+
import { ensureUsersSchema, seedDefaultUser } from "./users.ts";
|
|
51
|
+
import { ensureAuthIdentitiesSchema } from "./auth-identities.ts";
|
|
52
|
+
import { ensureUserInvitesSchema } from "./user-invites.ts";
|
|
53
|
+
import { ensureAgentOwnershipSchema, seedDefaultAgentOwnership } from "./agent-ownership.ts";
|
|
54
|
+
import { ensureDriveLeaseSchema } from "./drive-leases.ts";
|
|
55
|
+
import { convertManualJobDisablesToPauses, ensureMaintenanceJobPauseSchema } from "./maintenance-pauses.ts";
|
|
56
|
+
import { dropLegacyContinuationArchiveIndex } from "./continuation-archive-search.ts";
|
|
57
|
+
import { ensureCrashReportsSchema } from "./crash-reports.ts";
|
|
58
|
+
import { migrateVaultSchema } from "./secrets-vault-migration";
|
|
59
|
+
import { ensureBudgetLineageSchema } from "./budget-lineage";
|
|
60
|
+
import { ensureLaunchFactsSchema } from "./launch-facts.ts";
|
|
61
|
+
import { ensureTerminalEventsSchema } from "./terminal-events.ts";
|
|
62
|
+
import { seedBundledProvisioningAssets } from "./provisioning-registry.ts";
|
|
63
|
+
import { seedQaSkills } from "./qa-skill-seed.ts";
|
|
64
|
+
import { seedSharedCallmuxProvisioningAssets } from "./provisioning-callmux.ts";
|
|
65
|
+
import { provisioningAssetsColumnNames, provisioningAssetsNeedsRebuild, rebuildProvisioningAssetsTable } from "./provisioning-assets-migration.ts";
|
|
66
|
+
import { ensureWorkflowJournalSchema } from "./workflow-journal-schema.ts";
|
|
67
|
+
import { ensureKernelEventLogSchema } from "./kernel-event-log-schema.ts";
|
|
68
|
+
import { ensureReviewRefCleanupsSchema } from "./review-ref-cleanups.ts";
|
|
69
|
+
import { installTimerMessageFlipSchema } from "./timer-message-flip.ts";
|
|
70
|
+
import { ensureTimerMessageFireDeadLetterSchema } from "./timer-message-fire-deadletter.ts";
|
|
71
|
+
import { ensureIngestedMemoryIndex, ensureSqlAuditIndexes } from "./sql-audit-indexes.ts";
|
|
72
|
+
import { ensureMaintenanceIndexes } from "./maintenance-indexes.ts";
|
|
73
|
+
import { ensureProviderFlapMessagesIndex } from "./provider-flap-messages.ts";
|
|
74
|
+
import { normalizeReactionEmoji } from "./mappers.ts";
|
|
75
|
+
import { normalizeProviderQuotaAccountKeys } from "./provider-quotas.ts";
|
|
76
|
+
import { projectRootsMissingIssueRepo, projectRootsMissingRemoteUrl, setProjectIssueRepo, setProjectRootRemoteUrl } from "./projects.ts";
|
|
77
|
+
import { mergePhantomWorktreeProjectsAtStartup } from "./project-phantom-merge.ts";
|
|
78
|
+
import { migrateTeamProjectSeats } from "./team-project.ts";
|
|
79
|
+
import { ensureArtifactCreatorAgentColumn } from "./artifacts.ts";
|
|
80
|
+
import { rewriteEmptyToolGroupsToAbsent } from "./tool-groups-empty-migration.ts";
|
|
81
|
+
import { backfillProjectMemoryToolGroup } from "./project-memory-group-migration.ts";
|
|
82
|
+
import { removeLegacyProfileProjectInstructions } from "./profile-legacy-project-instructions-migration.ts";
|
|
83
|
+
import { migrateProfileHostSources } from "./profile-host-sources-migration.ts";
|
|
84
|
+
import { migrateProfileProjectAcks } from "./profile-project-ack-migration.ts";
|
|
85
|
+
import { backfillCustomProfileArtifacts } from "./profile-artifact-backfill-migration.ts";
|
|
86
|
+
import { migrateAgentProfileOverridesToV2 } from "./profile-override-migration.ts";
|
|
87
|
+
import { migrateProfileSlimOnStartup } from "./profile-slim-migration.ts";
|
|
88
|
+
import { ensureProfileNameCaseIndex } from "./profile-name-case-migration.ts";
|
|
89
|
+
import { backfillSpawnRegistrationConfirmedOnce } from "./spawn-registration-confirmed-backfill.ts";
|
|
90
|
+
import { auditHostAliases, backfillHostsFromOrchestrators } from "./hosts-backfill.ts";
|
|
91
|
+
import { remoteUrlFromGitRemote, repoFromGitRemote } from "../services/git-remote.ts";
|
|
92
|
+
import { migrateBlockedTaskBacklog, migrateDeployedTaskBacklog } from "./task-validation.ts";
|
|
93
|
+
import { backfillTaskOwners } from "./task-owner.ts";
|
|
94
|
+
import { migratePlanBlurbsOnStartup } from "./plan-blurb-migration.ts";
|
|
95
|
+
import { ensureLandingPhaseOneSchema } from "./landing-schema.ts";
|
|
96
|
+
import { ensureCommandAgentProfileSchema } from "./command-agent-profiles.ts";
|
|
97
|
+
|
|
98
|
+
// One-time normalization of legacy reaction rows, run on every open (idempotent).
|
|
99
|
+
function normalizeExistingMessageReactions(): void {
|
|
100
|
+
const rows = getDb().query("SELECT message_id, actor_id, emoji, created_at, updated_at FROM message_reactions").all() as Array<{
|
|
101
|
+
message_id: number;
|
|
102
|
+
actor_id: string;
|
|
103
|
+
emoji: string;
|
|
104
|
+
created_at: number;
|
|
105
|
+
updated_at: number;
|
|
106
|
+
}>;
|
|
107
|
+
const migrate = getDb().transaction((items: typeof rows) => {
|
|
108
|
+
const upsert = getDb().query(`
|
|
109
|
+
INSERT INTO message_reactions (message_id, actor_id, emoji, created_at, updated_at)
|
|
110
|
+
VALUES (?, ?, ?, ?, ?)
|
|
111
|
+
ON CONFLICT(message_id, actor_id, emoji) DO UPDATE SET
|
|
112
|
+
created_at = min(message_reactions.created_at, excluded.created_at),
|
|
113
|
+
updated_at = max(message_reactions.updated_at, excluded.updated_at)
|
|
114
|
+
`);
|
|
115
|
+
const remove = getDb().query("DELETE FROM message_reactions WHERE message_id = ? AND actor_id = ? AND emoji = ?");
|
|
116
|
+
for (const row of items) {
|
|
117
|
+
const normalized = normalizeReactionEmoji(row.emoji);
|
|
118
|
+
if (normalized === row.emoji) continue;
|
|
119
|
+
upsert.run(row.message_id, row.actor_id, normalized, row.created_at, row.updated_at);
|
|
120
|
+
remove.run(row.message_id, row.actor_id, row.emoji);
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
migrate(rows);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function backfillProjectIssueRepos(): void {
|
|
127
|
+
const repaired = new Set<string>();
|
|
128
|
+
for (const row of projectRootsMissingIssueRepo()) {
|
|
129
|
+
if (repaired.has(row.projectId)) continue;
|
|
130
|
+
try {
|
|
131
|
+
const repo = repoFromGitRemote(row.rootPath);
|
|
132
|
+
if (!repo) continue;
|
|
133
|
+
setProjectIssueRepo(row.projectId, repo, { onlyIfNull: true });
|
|
134
|
+
repaired.add(row.projectId);
|
|
135
|
+
} catch {
|
|
136
|
+
// Best-effort startup repair: a missing root or unavailable git must not block Relay.
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function backfillProjectRootRemoteUrls(): void {
|
|
142
|
+
for (const row of projectRootsMissingRemoteUrl()) {
|
|
143
|
+
try {
|
|
144
|
+
const remoteUrl = remoteUrlFromGitRemote(row.rootPath);
|
|
145
|
+
if (remoteUrl) setProjectRootRemoteUrl(row.projectId, row.rootPath, remoteUrl, { onlyIfNull: true });
|
|
146
|
+
} catch {
|
|
147
|
+
// Best-effort startup repair: a missing root or unavailable git must not block Relay.
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// Incremental schema migrations + one-shot backfills, applied after the base DDL
|
|
153
|
+
// in initDb(). Ordering matters: each block guards on the current column/table
|
|
154
|
+
// shape, so they must run in historical order. Built-in agent seeding and the
|
|
155
|
+
// read_by backfill live here too — both run unconditionally and idempotently.
|
|
156
|
+
export function applyMigrations(): void {
|
|
157
|
+
getDb().run(PLAN_IMPORT_SCHEMA_SQL);
|
|
158
|
+
ensureVaultTokensSchema();
|
|
159
|
+
ensureVaultHealthSchema();
|
|
160
|
+
const finishSchema = beginStartupPhase("db.migrations.schema-and-seeds");
|
|
161
|
+
ensureLandingPhaseOneSchema();
|
|
162
|
+
ensureCommandAgentProfileSchema(); // #3606 — spawn agentProfile stored once by content hash
|
|
163
|
+
timeStartupPhase("db.backfill.reactions", normalizeExistingMessageReactions);
|
|
164
|
+
timeStartupPhase("db.backfill.spawn-request-ids", normalizeExistingAgentSpawnRequestIds);
|
|
165
|
+
|
|
166
|
+
// Migrations
|
|
167
|
+
getDb().run(`
|
|
168
|
+
CREATE TABLE IF NOT EXISTS issue_refs (
|
|
169
|
+
id TEXT PRIMARY KEY,
|
|
170
|
+
provider TEXT NOT NULL,
|
|
171
|
+
repo TEXT NOT NULL,
|
|
172
|
+
external_key TEXT NOT NULL,
|
|
173
|
+
url TEXT NOT NULL,
|
|
174
|
+
title TEXT,
|
|
175
|
+
status TEXT NOT NULL DEFAULT 'unknown',
|
|
176
|
+
close_reason TEXT,
|
|
177
|
+
status_synced_at INTEGER,
|
|
178
|
+
created_at INTEGER NOT NULL,
|
|
179
|
+
updated_at INTEGER NOT NULL,
|
|
180
|
+
UNIQUE(provider, repo, external_key)
|
|
181
|
+
)
|
|
182
|
+
`);
|
|
183
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_issue_refs_external ON issue_refs(provider, repo, external_key)");
|
|
184
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_issue_refs_updated ON issue_refs(updated_at DESC)");
|
|
185
|
+
// #2520 — the GitHub close classification (completed|not_planned) cached beside the status so
|
|
186
|
+
// plan-node terminal propagation can tell a completed close from a not-planned one. The guarded
|
|
187
|
+
// ALTER converges databases created before the column existed with the CREATE above.
|
|
188
|
+
const issueRefCols = getDb().query("PRAGMA table_info(issue_refs)").all() as any[];
|
|
189
|
+
const issueRefColNames = issueRefCols.map((c: any) => c.name);
|
|
190
|
+
if (!issueRefColNames.includes("close_reason")) {
|
|
191
|
+
getDb().run("ALTER TABLE issue_refs ADD COLUMN close_reason TEXT");
|
|
192
|
+
}
|
|
193
|
+
getDb().run(`
|
|
194
|
+
CREATE TABLE IF NOT EXISTS issue_associations (
|
|
195
|
+
issue_ref_id TEXT NOT NULL REFERENCES issue_refs(id) ON DELETE CASCADE,
|
|
196
|
+
entity_type TEXT NOT NULL CHECK (entity_type IN ('team', 'plan-node', 'epic', 'task')),
|
|
197
|
+
entity_id TEXT NOT NULL,
|
|
198
|
+
created_at INTEGER NOT NULL,
|
|
199
|
+
PRIMARY KEY (issue_ref_id, entity_type, entity_id)
|
|
200
|
+
)
|
|
201
|
+
`);
|
|
202
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_issue_associations_entity ON issue_associations(entity_type, entity_id, created_at DESC)");
|
|
203
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_issue_associations_issue ON issue_associations(issue_ref_id, created_at DESC)");
|
|
204
|
+
getDb().run(`CREATE TABLE IF NOT EXISTS issue_lifecycle_actions (
|
|
205
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT, issue_ref_id TEXT NOT NULL REFERENCES issue_refs(id) ON DELETE CASCADE,
|
|
206
|
+
action TEXT NOT NULL CHECK (action IN ('close', 'reopen')), land_key TEXT NOT NULL, workspace_id TEXT, branch TEXT, base_ref TEXT, commit_sha TEXT, commit_subject TEXT,
|
|
207
|
+
agent_id TEXT, source TEXT, comment TEXT, status TEXT NOT NULL CHECK (status IN ('succeeded', 'failed')),
|
|
208
|
+
error TEXT, created_at INTEGER NOT NULL, updated_at INTEGER NOT NULL, UNIQUE(issue_ref_id, action, land_key))`);
|
|
209
|
+
getDb().run(LONG_RUNNING_WORK_SCHEMA);
|
|
210
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_issue_lifecycle_commit ON issue_lifecycle_actions(commit_sha, action, status)");
|
|
211
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_issue_lifecycle_subject ON issue_lifecycle_actions(commit_subject, action, status)");
|
|
212
|
+
|
|
213
|
+
const activityCols = getDb().query("PRAGMA table_info(activity_events)").all() as any[];
|
|
214
|
+
const activityColNames = activityCols.map((c: any) => c.name);
|
|
215
|
+
if (!activityColNames.includes("issue_ref_id")) {
|
|
216
|
+
getDb().run("ALTER TABLE activity_events ADD COLUMN issue_ref_id TEXT");
|
|
217
|
+
}
|
|
218
|
+
if (!activityColNames.includes("issue_action")) {
|
|
219
|
+
getDb().run("ALTER TABLE activity_events ADD COLUMN issue_action TEXT");
|
|
220
|
+
}
|
|
221
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_activity_issue ON activity_events(issue_ref_id, created_at)");
|
|
222
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_activity_agent_issue ON activity_events(agent_id, issue_ref_id, created_at)"); getDb().run("CREATE INDEX IF NOT EXISTS idx_activity_policy_created ON activity_events(json_extract(metadata, '$.policyName'), created_at DESC, id DESC)");
|
|
223
|
+
|
|
224
|
+
getDb().run(`
|
|
225
|
+
CREATE TABLE IF NOT EXISTS workspace_merge_pauses (
|
|
226
|
+
id TEXT PRIMARY KEY,
|
|
227
|
+
repo_root TEXT NOT NULL,
|
|
228
|
+
base_ref TEXT NOT NULL,
|
|
229
|
+
holder TEXT NOT NULL,
|
|
230
|
+
reason TEXT,
|
|
231
|
+
created_at INTEGER NOT NULL,
|
|
232
|
+
updated_at INTEGER NOT NULL,
|
|
233
|
+
expires_at INTEGER NOT NULL,
|
|
234
|
+
UNIQUE(repo_root, base_ref)
|
|
235
|
+
)
|
|
236
|
+
`);
|
|
237
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_workspace_merge_pauses_expires ON workspace_merge_pauses(expires_at)");
|
|
238
|
+
|
|
239
|
+
const workspaceCols = getDb().query("PRAGMA table_info(workspaces)").all() as any[];
|
|
240
|
+
const workspaceColNames = workspaceCols.map((c: any) => c.name);
|
|
241
|
+
if (!workspaceColNames.includes("orchestrator_id")) {
|
|
242
|
+
getDb().run("ALTER TABLE workspaces ADD COLUMN orchestrator_id TEXT");
|
|
243
|
+
}
|
|
244
|
+
if (!workspaceColNames.includes("landed_at")) {
|
|
245
|
+
getDb().run("ALTER TABLE workspaces ADD COLUMN landed_at INTEGER");
|
|
246
|
+
}
|
|
247
|
+
if (!workspaceColNames.includes("landed_sha")) {
|
|
248
|
+
getDb().run("ALTER TABLE workspaces ADD COLUMN landed_sha TEXT");
|
|
249
|
+
}
|
|
250
|
+
if (!workspaceColNames.includes("land_state")) {
|
|
251
|
+
getDb().run("ALTER TABLE workspaces ADD COLUMN land_state TEXT NOT NULL DEFAULT 'no-changes'");
|
|
252
|
+
getDb().run(`UPDATE workspaces SET land_state = CASE status
|
|
253
|
+
WHEN 'ready' THEN 'delivery:complete'
|
|
254
|
+
WHEN 'review_requested' THEN 'delivery:needs-review'
|
|
255
|
+
WHEN 'merge_planned' THEN 'gate-running'
|
|
256
|
+
WHEN 'gate_running' THEN 'gate-running'
|
|
257
|
+
WHEN 'gate_failed' THEN 'gate-failed'
|
|
258
|
+
WHEN 'conflict' THEN 'steward-requested'
|
|
259
|
+
WHEN 'merging' THEN 'merging'
|
|
260
|
+
WHEN 'landed' THEN 'landed'
|
|
261
|
+
WHEN 'merged' THEN 'landed'
|
|
262
|
+
WHEN 'active' THEN CASE WHEN coalesce(json_extract(metadata, '$.gitDirtyCount'), 0) > 0 THEN 'changes' WHEN coalesce(json_extract(metadata, '$.gitAhead'), 0) > 0 THEN 'committed' ELSE 'no-changes' END
|
|
263
|
+
ELSE 'no-changes' END`);
|
|
264
|
+
}
|
|
265
|
+
if (!workspaceColNames.includes("land_state_at")) {
|
|
266
|
+
getDb().run("ALTER TABLE workspaces ADD COLUMN land_state_at INTEGER");
|
|
267
|
+
getDb().run(`UPDATE workspaces SET land_state_at = coalesce(updated_at, created_at) WHERE land_state_at IS NULL`);
|
|
268
|
+
}
|
|
269
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_workspaces_orchestrator ON workspaces(orchestrator_id)");
|
|
270
|
+
getDb().run(`CREATE INDEX IF NOT EXISTS idx_workspaces_steward_cancellation ON workspaces(
|
|
271
|
+
json_extract(metadata, '$.stewardCancellation.agentId'), json_extract(metadata, '$.stewardCancellation.spawnRequestId'))`);
|
|
272
|
+
getDb().run(`CREATE INDEX IF NOT EXISTS idx_workspaces_steward_handback_status ON workspaces(
|
|
273
|
+
json_extract(metadata, '$.stewardCancellation.status'))`);
|
|
274
|
+
getDb().run(`
|
|
275
|
+
CREATE TABLE IF NOT EXISTS workspace_orphan_alerts (
|
|
276
|
+
orphan_key TEXT PRIMARY KEY,
|
|
277
|
+
fingerprint TEXT NOT NULL,
|
|
278
|
+
alerted_at INTEGER NOT NULL,
|
|
279
|
+
updated_at INTEGER NOT NULL
|
|
280
|
+
)
|
|
281
|
+
`);
|
|
282
|
+
// #1525 — durable human-escalation dedupe, independent of the liveness-pruned
|
|
283
|
+
// workspace_orphan_alerts table (see schema.ts for why).
|
|
284
|
+
getDb().run(`
|
|
285
|
+
CREATE TABLE IF NOT EXISTS workspace_human_escalation_alerts (
|
|
286
|
+
alert_key TEXT PRIMARY KEY,
|
|
287
|
+
alerted_at INTEGER NOT NULL
|
|
288
|
+
)
|
|
289
|
+
`);
|
|
290
|
+
|
|
291
|
+
const cols = getDb().query("PRAGMA table_info(messages)").all() as any[];
|
|
292
|
+
const colNames = cols.map((c: any) => c.name);
|
|
293
|
+
if (!colNames.includes("thread_id")) {
|
|
294
|
+
getDb().run("ALTER TABLE messages ADD COLUMN thread_id INTEGER");
|
|
295
|
+
}
|
|
296
|
+
if (!colNames.includes("reply_to")) {
|
|
297
|
+
getDb().run("ALTER TABLE messages ADD COLUMN reply_to INTEGER REFERENCES messages(id)");
|
|
298
|
+
}
|
|
299
|
+
if (!colNames.includes("reply_expected")) {
|
|
300
|
+
getDb().run("ALTER TABLE messages ADD COLUMN reply_expected INTEGER NOT NULL DEFAULT 1");
|
|
301
|
+
}
|
|
302
|
+
// #2017 — server-owned urgent request facts. These are columns, never payload/meta fields.
|
|
303
|
+
if (!colNames.includes("urgent_requested")) getDb().run("ALTER TABLE messages ADD COLUMN urgent_requested INTEGER NOT NULL DEFAULT 0");
|
|
304
|
+
if (!colNames.includes("urgent_throttled")) getDb().run("ALTER TABLE messages ADD COLUMN urgent_throttled INTEGER NOT NULL DEFAULT 0");
|
|
305
|
+
getDb().run(`
|
|
306
|
+
CREATE TABLE IF NOT EXISTS urgent_message_budgets (
|
|
307
|
+
sender_agent TEXT NOT NULL,
|
|
308
|
+
recipient_target TEXT NOT NULL,
|
|
309
|
+
tokens REAL NOT NULL,
|
|
310
|
+
updated_at INTEGER NOT NULL,
|
|
311
|
+
PRIMARY KEY (sender_agent, recipient_target)
|
|
312
|
+
)
|
|
313
|
+
`);
|
|
314
|
+
if (!colNames.includes("claimable")) {
|
|
315
|
+
getDb().run("ALTER TABLE messages ADD COLUMN claimable INTEGER NOT NULL DEFAULT 0");
|
|
316
|
+
getDb().run("ALTER TABLE messages ADD COLUMN claimed_by TEXT");
|
|
317
|
+
getDb().run("ALTER TABLE messages ADD COLUMN claimed_at INTEGER");
|
|
318
|
+
}
|
|
319
|
+
if (!colNames.includes("claim_expires_at")) {
|
|
320
|
+
getDb().run("ALTER TABLE messages ADD COLUMN claim_expires_at INTEGER");
|
|
321
|
+
}
|
|
322
|
+
if (!colNames.includes("idempotency_key")) {
|
|
323
|
+
getDb().run("ALTER TABLE messages ADD COLUMN idempotency_key TEXT");
|
|
324
|
+
}
|
|
325
|
+
if (!colNames.includes("delivery_status")) {
|
|
326
|
+
getDb().run("ALTER TABLE messages ADD COLUMN delivery_status TEXT NOT NULL DEFAULT 'pending'");
|
|
327
|
+
}
|
|
328
|
+
if (!colNames.includes("delivery_attempts")) {
|
|
329
|
+
getDb().run("ALTER TABLE messages ADD COLUMN delivery_attempts INTEGER NOT NULL DEFAULT 0");
|
|
330
|
+
}
|
|
331
|
+
if (!colNames.includes("delivery_last_error")) {
|
|
332
|
+
getDb().run("ALTER TABLE messages ADD COLUMN delivery_last_error TEXT");
|
|
333
|
+
}
|
|
334
|
+
if (!colNames.includes("delivery_next_retry_at")) {
|
|
335
|
+
getDb().run("ALTER TABLE messages ADD COLUMN delivery_next_retry_at INTEGER");
|
|
336
|
+
}
|
|
337
|
+
if (!colNames.includes("delivery_poison_reason")) {
|
|
338
|
+
getDb().run("ALTER TABLE messages ADD COLUMN delivery_poison_reason TEXT");
|
|
339
|
+
}
|
|
340
|
+
if (!colNames.includes("delivery_updated_at")) {
|
|
341
|
+
getDb().run("ALTER TABLE messages ADD COLUMN delivery_updated_at INTEGER");
|
|
342
|
+
}
|
|
343
|
+
if (!colNames.includes("queued_at")) {
|
|
344
|
+
getDb().run("ALTER TABLE messages ADD COLUMN queued_at INTEGER");
|
|
345
|
+
}
|
|
346
|
+
if (!colNames.includes("max_age_seconds")) {
|
|
347
|
+
getDb().run("ALTER TABLE messages ADD COLUMN max_age_seconds INTEGER");
|
|
348
|
+
}
|
|
349
|
+
if (!colNames.includes("resolved_to_agent")) {
|
|
350
|
+
getDb().run("ALTER TABLE messages ADD COLUMN resolved_to_agent TEXT");
|
|
351
|
+
}
|
|
352
|
+
// #1935 — nullable, server-owned final-turn lineage; old rows use the legacy predicate.
|
|
353
|
+
if (!colNames.includes("message_type")) getDb().run("ALTER TABLE messages ADD COLUMN message_type TEXT"); if (!colNames.includes("source_message_id")) getDb().run("ALTER TABLE messages ADD COLUMN source_message_id INTEGER"); getDb().run("CREATE UNIQUE INDEX IF NOT EXISTS idx_msg_final_turn_source ON messages(source_message_id) WHERE message_type = 'final-turn'");
|
|
354
|
+
// Event time (#196): when a Runner queues a message in its durable outbox during an
|
|
355
|
+
// outage, occurred_at preserves when it really happened vs. the later receive time.
|
|
356
|
+
if (!colNames.includes("occurred_at")) {
|
|
357
|
+
getDb().run("ALTER TABLE messages ADD COLUMN occurred_at INTEGER");
|
|
358
|
+
}
|
|
359
|
+
if (!colNames.includes("seq")) getDb().run("ALTER TABLE messages ADD COLUMN seq INTEGER");
|
|
360
|
+
getDb().query(
|
|
361
|
+
"UPDATE messages SET claim_expires_at = coalesce(claimed_at, ?) + ? WHERE claimed_by IS NOT NULL AND claim_expires_at IS NULL",
|
|
362
|
+
).run(Date.now(), CLAIM_LEASE_MS);
|
|
363
|
+
// #3054 — keyed "a later response from this agent in this thread" probes; a superset of the old thread_id index.
|
|
364
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_msg_thread_from_id ON messages(thread_id, from_agent, id)");
|
|
365
|
+
getDb().run("DROP INDEX IF EXISTS idx_msg_thread");
|
|
366
|
+
// (reply_to, from_agent) powers the reply-obligation NOT EXISTS subquery in
|
|
367
|
+
// listPendingReplyObligations. It must stay migration-owned because reply_to is
|
|
368
|
+
// an ALTER-added column on legacy DBs (#963).
|
|
369
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_msg_reply_to ON messages(reply_to, from_agent)");
|
|
370
|
+
// The kernel-timers authority flip depends on this request-key guard remaining UNIQUE.
|
|
371
|
+
// It also backs retry-dedup and session-step upsert lookups.
|
|
372
|
+
getDb().run("CREATE UNIQUE INDEX IF NOT EXISTS idx_msg_idempotency ON messages(from_agent, idempotency_key) WHERE idempotency_key IS NOT NULL");
|
|
373
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_msg_delivery_status ON messages(delivery_status)");
|
|
374
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_msg_claimed_expires ON messages(claimed_by, claim_expires_at, id) WHERE claimed_by IS NOT NULL");
|
|
375
|
+
getDb().run("CREATE UNIQUE INDEX IF NOT EXISTS idx_msg_from_seq ON messages(from_agent, seq) WHERE seq IS NOT NULL");
|
|
376
|
+
// (#846) composite replaces the old single-column idx_msg_resolved_to_agent; created
|
|
377
|
+
// here — AFTER the resolved_to_agent ALTER above — so existing DBs without the column
|
|
378
|
+
// don't crash (same hazard as idx_msg_from_kind_id / #483/#559).
|
|
379
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_msg_resolved_to_id ON messages(resolved_to_agent, id)");
|
|
380
|
+
|
|
381
|
+
getDb().run(`
|
|
382
|
+
CREATE TABLE IF NOT EXISTS agent_continuations (
|
|
383
|
+
agent_id TEXT PRIMARY KEY REFERENCES agents(id) ON DELETE CASCADE,
|
|
384
|
+
objective TEXT NOT NULL, objective_epoch INTEGER NOT NULL,
|
|
385
|
+
generation INTEGER NOT NULL DEFAULT 0,
|
|
386
|
+
ledger TEXT NOT NULL DEFAULT '[]',
|
|
387
|
+
working_state TEXT NOT NULL DEFAULT '',
|
|
388
|
+
archive_refs TEXT NOT NULL DEFAULT '[]',
|
|
389
|
+
budget TEXT NOT NULL,
|
|
390
|
+
created_at INTEGER NOT NULL,
|
|
391
|
+
updated_at INTEGER NOT NULL
|
|
392
|
+
)
|
|
393
|
+
`); if (!(getDb().query("PRAGMA table_info(agent_continuations)").all() as Array<{ name: string }>).some((column) => column.name === "objective_epoch")) { getDb().run("ALTER TABLE agent_continuations ADD COLUMN objective_epoch INTEGER NOT NULL DEFAULT 0"); getDb().run("UPDATE agent_continuations SET objective_epoch = created_at WHERE objective_epoch = 0"); }
|
|
394
|
+
getDb().run(`
|
|
395
|
+
CREATE TABLE IF NOT EXISTS continuation_archives (
|
|
396
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
397
|
+
agent_id TEXT NOT NULL REFERENCES agents(id) ON DELETE CASCADE,
|
|
398
|
+
generation INTEGER NOT NULL,
|
|
399
|
+
segment TEXT NOT NULL,
|
|
400
|
+
created_at INTEGER NOT NULL
|
|
401
|
+
)
|
|
402
|
+
`);
|
|
403
|
+
getDb().run(`
|
|
404
|
+
CREATE INDEX IF NOT EXISTS idx_continuation_archives_agent_generation
|
|
405
|
+
ON continuation_archives(agent_id, generation, created_at DESC)
|
|
406
|
+
`);
|
|
407
|
+
dropLegacyContinuationArchiveIndex();
|
|
408
|
+
getDb().run(`
|
|
409
|
+
CREATE TABLE IF NOT EXISTS task_memories (
|
|
410
|
+
task_id INTEGER PRIMARY KEY REFERENCES tasks(id) ON DELETE CASCADE,
|
|
411
|
+
objective TEXT NOT NULL,
|
|
412
|
+
generation INTEGER NOT NULL DEFAULT 0,
|
|
413
|
+
ledger TEXT NOT NULL DEFAULT '[]',
|
|
414
|
+
decisions TEXT NOT NULL DEFAULT '[]',
|
|
415
|
+
working_state TEXT NOT NULL DEFAULT '',
|
|
416
|
+
archive_refs TEXT NOT NULL DEFAULT '[]',
|
|
417
|
+
budget TEXT NOT NULL,
|
|
418
|
+
created_at INTEGER NOT NULL,
|
|
419
|
+
updated_at INTEGER NOT NULL
|
|
420
|
+
)
|
|
421
|
+
`);
|
|
422
|
+
|
|
423
|
+
const tokenCols = getDb().query("PRAGMA table_info(tokens)").all() as any[];
|
|
424
|
+
const tokenColNames = tokenCols.map((c: any) => c.name);
|
|
425
|
+
if (!tokenColNames.includes("constraints")) {
|
|
426
|
+
getDb().run("ALTER TABLE tokens ADD COLUMN constraints TEXT");
|
|
427
|
+
}
|
|
428
|
+
if (!tokenColNames.includes("profile_id")) {
|
|
429
|
+
getDb().run("ALTER TABLE tokens ADD COLUMN profile_id TEXT");
|
|
430
|
+
}
|
|
431
|
+
// #484: revocation reason distinguishes a stale-on-restart revocation (recoverable via
|
|
432
|
+
// orchestrator re-mint for a still-live process) from a hard kill (admin/rotation). A NULL
|
|
433
|
+
// reason on a legacy revoked token is treated as a hard kill — never re-mintable.
|
|
434
|
+
if (!tokenColNames.includes("revoked_reason")) {
|
|
435
|
+
getDb().run("ALTER TABLE tokens ADD COLUMN revoked_reason TEXT");
|
|
436
|
+
}
|
|
437
|
+
// #1245: handoff links between a token and its successor (token-db.ts handoffTokenInternal); the index serves
|
|
438
|
+
// the lineage walk of a revocation (token-standing.ts revokeTokenLineage).
|
|
439
|
+
for (const col of ["successor_jti", "predecessor_jti"]) if (!tokenColNames.includes(col)) getDb().run(`ALTER TABLE tokens ADD COLUMN ${col} TEXT`);
|
|
440
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_tokens_predecessor_jti ON tokens(predecessor_jti) WHERE predecessor_jti IS NOT NULL");
|
|
441
|
+
|
|
442
|
+
getDb().run(`
|
|
443
|
+
CREATE TABLE IF NOT EXISTS message_delivery_attempts (
|
|
444
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
445
|
+
message_id INTEGER NOT NULL REFERENCES messages(id) ON DELETE CASCADE,
|
|
446
|
+
agent_id TEXT,
|
|
447
|
+
action TEXT NOT NULL DEFAULT 'attempt',
|
|
448
|
+
status TEXT NOT NULL,
|
|
449
|
+
error TEXT,
|
|
450
|
+
next_retry_at INTEGER,
|
|
451
|
+
poison_reason TEXT,
|
|
452
|
+
created_at INTEGER NOT NULL
|
|
453
|
+
)
|
|
454
|
+
`);
|
|
455
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_mda_message ON message_delivery_attempts(message_id, created_at DESC)"); getDb().run("CREATE INDEX IF NOT EXISTS idx_mda_agent_created ON message_delivery_attempts(agent_id, created_at DESC)");
|
|
456
|
+
getDb().run("CREATE TABLE IF NOT EXISTS channel_delivery_releases (message_id INTEGER PRIMARY KEY REFERENCES messages(id) ON DELETE CASCADE)");
|
|
457
|
+
|
|
458
|
+
const channelBindingsSql = getDb().query("SELECT sql FROM sqlite_master WHERE type = 'table' AND name = 'channel_bindings'").get() as { sql?: string } | undefined;
|
|
459
|
+
if (channelBindingsSql?.sql?.includes("UNIQUE(channel_id, conversation_key)")) {
|
|
460
|
+
getDb().transaction(() => {
|
|
461
|
+
getDb().run("ALTER TABLE channel_bindings RENAME TO channel_bindings_old");
|
|
462
|
+
getDb().run(`
|
|
463
|
+
CREATE TABLE channel_bindings (
|
|
464
|
+
id TEXT PRIMARY KEY,
|
|
465
|
+
channel_id TEXT NOT NULL REFERENCES channels(id) ON DELETE CASCADE,
|
|
466
|
+
conversation_key TEXT NOT NULL DEFAULT '',
|
|
467
|
+
conversation_id TEXT,
|
|
468
|
+
target_type TEXT NOT NULL,
|
|
469
|
+
target_id TEXT NOT NULL,
|
|
470
|
+
mode TEXT NOT NULL DEFAULT 'exclusive',
|
|
471
|
+
priority INTEGER NOT NULL DEFAULT 0,
|
|
472
|
+
created_at INTEGER NOT NULL,
|
|
473
|
+
updated_at INTEGER NOT NULL
|
|
474
|
+
)
|
|
475
|
+
`);
|
|
476
|
+
getDb().run(`
|
|
477
|
+
INSERT INTO channel_bindings (id, channel_id, conversation_key, conversation_id, target_type, target_id, mode, priority, created_at, updated_at)
|
|
478
|
+
SELECT id, channel_id, conversation_key, conversation_id, target_type, target_id, mode, priority, created_at, updated_at
|
|
479
|
+
FROM channel_bindings_old
|
|
480
|
+
`);
|
|
481
|
+
getDb().run("DROP TABLE channel_bindings_old");
|
|
482
|
+
})();
|
|
483
|
+
}
|
|
484
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_channel_bindings_channel ON channel_bindings(channel_id, priority)");
|
|
485
|
+
getDb().run("CREATE UNIQUE INDEX IF NOT EXISTS idx_channel_bindings_target ON channel_bindings(channel_id, conversation_key, target_type, target_id)");
|
|
486
|
+
|
|
487
|
+
const bindingColNames = (getDb().query("PRAGMA table_info(channel_bindings)").all() as any[]).map((c: any) => c.name);
|
|
488
|
+
if (!bindingColNames.includes("pool_selector")) {
|
|
489
|
+
getDb().run("ALTER TABLE channel_bindings ADD COLUMN pool_selector TEXT");
|
|
490
|
+
getDb().run("ALTER TABLE channel_bindings ADD COLUMN pool_agent_id TEXT");
|
|
491
|
+
getDb().run("ALTER TABLE channel_bindings ADD COLUMN pool_agent_epoch INTEGER");
|
|
492
|
+
getDb().run("ALTER TABLE channel_bindings ADD COLUMN pool_claim_expires_at INTEGER");
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
if (!colNames.includes("kind")) {
|
|
496
|
+
getDb().run("ALTER TABLE messages ADD COLUMN kind TEXT NOT NULL DEFAULT 'chat'");
|
|
497
|
+
}
|
|
498
|
+
if (!colNames.includes("payload")) {
|
|
499
|
+
getDb().run("ALTER TABLE messages ADD COLUMN payload TEXT NOT NULL DEFAULT '{}'");
|
|
500
|
+
}
|
|
501
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_msg_kind ON messages(kind)");
|
|
502
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_msg_from_id ON messages(from_agent, id)");
|
|
503
|
+
// #3644 idx_msg_pair_chat: child→parent chat dedupe reads (db/lineage-pair-dedupe-sql.ts) seek the
|
|
504
|
+
// pair, not the parent's whole inbox. One-time build before bind on an existing DB (~1 s per GB warm).
|
|
505
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_msg_from_kind_id ON messages(from_agent, kind, id)"); getDb().run("CREATE INDEX IF NOT EXISTS idx_msg_pair_chat ON messages(from_agent, to_target, created_at) WHERE kind = 'chat'"); getDb().run("CREATE INDEX IF NOT EXISTS idx_msg_analytics_created ON messages(created_at, kind, from_agent, claimable, reply_to)"); getDb().run("CREATE INDEX IF NOT EXISTS idx_msg_session_analytics ON messages(kind, created_at, json_extract(payload, '$.session.type'), json_extract(payload, '$.session.label'), json_extract(payload, '$.session.turnId'))");
|
|
506
|
+
getDb().run(`
|
|
507
|
+
CREATE TABLE IF NOT EXISTS teams (
|
|
508
|
+
id TEXT PRIMARY KEY,
|
|
509
|
+
coordinator_id TEXT,
|
|
510
|
+
root_coordinator_id TEXT,
|
|
511
|
+
title TEXT,
|
|
512
|
+
brief TEXT,
|
|
513
|
+
definition_of_done TEXT,
|
|
514
|
+
status TEXT NOT NULL DEFAULT 'active',
|
|
515
|
+
outcome_status TEXT,
|
|
516
|
+
outcome_summary TEXT,
|
|
517
|
+
composition TEXT,
|
|
518
|
+
cost_tokens INTEGER,
|
|
519
|
+
cost_usd REAL,
|
|
520
|
+
wall_clock_ms INTEGER,
|
|
521
|
+
lands_clean INTEGER,
|
|
522
|
+
zero_members_since INTEGER,
|
|
523
|
+
created_at INTEGER NOT NULL,
|
|
524
|
+
updated_at INTEGER NOT NULL,
|
|
525
|
+
dissolved_at INTEGER
|
|
526
|
+
)
|
|
527
|
+
`);
|
|
528
|
+
const teamColNames = (getDb().query("PRAGMA table_info(teams)").all() as any[]).map((c: any) => c.name);
|
|
529
|
+
if (!teamColNames.includes("zero_members_since")) {
|
|
530
|
+
getDb().run("ALTER TABLE teams ADD COLUMN zero_members_since INTEGER");
|
|
531
|
+
}
|
|
532
|
+
if (!teamColNames.includes("idle_since")) getDb().run("ALTER TABLE teams ADD COLUMN idle_since INTEGER");
|
|
533
|
+
if (!teamColNames.includes("idle_pinged")) getDb().run("ALTER TABLE teams ADD COLUMN idle_pinged INTEGER");
|
|
534
|
+
// #2862 — JSON array of agents a claim displaced from the seat (see db/coordinator-seat.ts).
|
|
535
|
+
if (!teamColNames.includes("parent_team_id")) getDb().run("ALTER TABLE teams ADD COLUMN parent_team_id TEXT");
|
|
536
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_teams_parent ON teams(parent_team_id) WHERE parent_team_id IS NOT NULL");
|
|
537
|
+
if (!teamColNames.includes("former_coordinator_ids")) getDb().run("ALTER TABLE teams ADD COLUMN former_coordinator_ids TEXT");
|
|
538
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_teams_coordinator ON teams(coordinator_id)");
|
|
539
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_teams_status ON teams(status)");
|
|
540
|
+
getDb().run(`
|
|
541
|
+
CREATE TABLE IF NOT EXISTS blackboard_entries (
|
|
542
|
+
id TEXT PRIMARY KEY,
|
|
543
|
+
team_id TEXT NOT NULL,
|
|
544
|
+
kind TEXT NOT NULL,
|
|
545
|
+
title TEXT NOT NULL,
|
|
546
|
+
body TEXT,
|
|
547
|
+
status TEXT NOT NULL DEFAULT 'active',
|
|
548
|
+
supersedes TEXT,
|
|
549
|
+
tags TEXT,
|
|
550
|
+
author_id TEXT NOT NULL,
|
|
551
|
+
created_at INTEGER NOT NULL,
|
|
552
|
+
updated_at INTEGER NOT NULL
|
|
553
|
+
)
|
|
554
|
+
`);
|
|
555
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_blackboard_team ON blackboard_entries(team_id)");
|
|
556
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_blackboard_team_kind ON blackboard_entries(team_id, kind)");
|
|
557
|
+
getDb().run(`
|
|
558
|
+
CREATE TABLE IF NOT EXISTS plans (
|
|
559
|
+
id TEXT PRIMARY KEY, thread_id INTEGER NOT NULL, team_id TEXT, channel TEXT, version INTEGER NOT NULL DEFAULT 1,
|
|
560
|
+
title TEXT, objective TEXT, nodes TEXT NOT NULL DEFAULT '[]', edges TEXT NOT NULL DEFAULT '[]',
|
|
561
|
+
created_by TEXT NOT NULL, created_at INTEGER NOT NULL, updated_at INTEGER NOT NULL
|
|
562
|
+
)
|
|
563
|
+
`);
|
|
564
|
+
const planColNames = (getDb().query("PRAGMA table_info(plans)").all() as any[]).map((c: any) => c.name);
|
|
565
|
+
if (!planColNames.includes("team_id")) {
|
|
566
|
+
getDb().run("ALTER TABLE plans ADD COLUMN team_id TEXT");
|
|
567
|
+
}
|
|
568
|
+
if (!planColNames.includes("archived")) getDb().run("ALTER TABLE plans ADD COLUMN archived INTEGER NOT NULL DEFAULT 0");
|
|
569
|
+
// #2932 plan-level acceptance: nullable, so legacy plans keep no completion state.
|
|
570
|
+
for (const col of ["acceptance", "conformance", "completion"]) if (!planColNames.includes(col)) getDb().run(`ALTER TABLE plans ADD COLUMN ${col} TEXT`);
|
|
571
|
+
getDb().run("CREATE UNIQUE INDEX IF NOT EXISTS idx_plans_thread_channel ON plans(thread_id, coalesce(channel, ''))");
|
|
572
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_plans_updated ON plans(updated_at)");
|
|
573
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_plans_team ON plans(team_id)");
|
|
574
|
+
getDb().run(`
|
|
575
|
+
CREATE TABLE IF NOT EXISTS plan_versions (
|
|
576
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT, plan_id TEXT NOT NULL,
|
|
577
|
+
version INTEGER NOT NULL, title TEXT, objective TEXT, nodes TEXT NOT NULL, edges TEXT NOT NULL,
|
|
578
|
+
changed_by TEXT, changed_at INTEGER NOT NULL
|
|
579
|
+
)
|
|
580
|
+
`);
|
|
581
|
+
const planVersionFks = getDb().query("PRAGMA foreign_key_list(plan_versions)").all() as any[];
|
|
582
|
+
if (planVersionFks.some((fk) => fk.table === "plans" && String(fk.on_delete).toUpperCase() === "CASCADE")) {
|
|
583
|
+
getDb().transaction(() => {
|
|
584
|
+
getDb().run("ALTER TABLE plan_versions RENAME TO plan_versions_old");
|
|
585
|
+
getDb().run(`
|
|
586
|
+
CREATE TABLE plan_versions (
|
|
587
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT, plan_id TEXT NOT NULL,
|
|
588
|
+
version INTEGER NOT NULL, title TEXT, objective TEXT, nodes TEXT NOT NULL, edges TEXT NOT NULL,
|
|
589
|
+
changed_by TEXT, changed_at INTEGER NOT NULL
|
|
590
|
+
)
|
|
591
|
+
`);
|
|
592
|
+
getDb().run(`
|
|
593
|
+
INSERT INTO plan_versions (id, plan_id, version, title, objective, nodes, edges, changed_by, changed_at)
|
|
594
|
+
SELECT id, plan_id, version, title, objective, nodes, edges, changed_by, changed_at
|
|
595
|
+
FROM plan_versions_old
|
|
596
|
+
`);
|
|
597
|
+
getDb().run("DROP TABLE plan_versions_old");
|
|
598
|
+
})();
|
|
599
|
+
}
|
|
600
|
+
const planVersionCols = (getDb().query("PRAGMA table_info(plan_versions)").all() as any[]).map((c: any) => c.name);
|
|
601
|
+
for (const col of ["acceptance", "conformance"]) if (!planVersionCols.includes(col)) getDb().run(`ALTER TABLE plan_versions ADD COLUMN ${col} TEXT`);
|
|
602
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_plan_versions_plan ON plan_versions(plan_id, version DESC)");
|
|
603
|
+
|
|
604
|
+
// Backfill thread_id for pre-migration rows (self-threaded).
|
|
605
|
+
getDb().run("UPDATE messages SET thread_id = id WHERE thread_id IS NULL");
|
|
606
|
+
|
|
607
|
+
const taskCols = getDb().query("PRAGMA table_info(tasks)").all() as any[];
|
|
608
|
+
const taskColNames = taskCols.map((c: any) => c.name);
|
|
609
|
+
if (!taskColNames.includes("claim_expires_at")) {
|
|
610
|
+
getDb().run("ALTER TABLE tasks ADD COLUMN claim_expires_at INTEGER");
|
|
611
|
+
}
|
|
612
|
+
getDb().query(
|
|
613
|
+
"UPDATE tasks SET claim_expires_at = coalesce(claimed_at, ?) + ? WHERE claimed_by IS NOT NULL AND claim_expires_at IS NULL",
|
|
614
|
+
).run(Date.now(), CLAIM_LEASE_MS);
|
|
615
|
+
|
|
616
|
+
const providerModelOverrideCols = getDb().query("PRAGMA table_info(provider_model_overrides)").all() as any[];
|
|
617
|
+
const providerModelOverrideColNames = providerModelOverrideCols.map((c: any) => c.name);
|
|
618
|
+
if (!providerModelOverrideColNames.includes("disabled")) {
|
|
619
|
+
getDb().run("ALTER TABLE provider_model_overrides ADD COLUMN disabled INTEGER NOT NULL DEFAULT 0");
|
|
620
|
+
}
|
|
621
|
+
getDb().run(`CREATE TABLE IF NOT EXISTS provider_model_defaults (
|
|
622
|
+
provider TEXT PRIMARY KEY, alias TEXT NOT NULL, updated_at INTEGER NOT NULL, updated_by TEXT
|
|
623
|
+
)`);
|
|
624
|
+
|
|
625
|
+
// Migration: projects.issue_repo (#533) — per-project `owner/repo` for #NNN linkify/land-close.
|
|
626
|
+
const projectCols = (getDb().query("PRAGMA table_info(projects)").all() as any[]).map((c: any) => c.name);
|
|
627
|
+
if (!projectCols.includes("issue_repo")) {
|
|
628
|
+
getDb().run("ALTER TABLE projects ADD COLUMN issue_repo TEXT");
|
|
629
|
+
}
|
|
630
|
+
// Migration: projects.scope/anchor_key (#559) — the {project|profile|user} anchor axis.
|
|
631
|
+
// ADD COLUMN with a DEFAULT is safe on a populated table; existing rows become scope='project'.
|
|
632
|
+
if (!projectCols.includes("scope")) {
|
|
633
|
+
getDb().run("ALTER TABLE projects ADD COLUMN scope TEXT NOT NULL DEFAULT 'project'");
|
|
634
|
+
}
|
|
635
|
+
if (!projectCols.includes("anchor_key")) {
|
|
636
|
+
getDb().run("ALTER TABLE projects ADD COLUMN anchor_key TEXT");
|
|
637
|
+
}
|
|
638
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_projects_scope_anchor ON projects(scope, anchor_key)");
|
|
639
|
+
// Migration: project_roots.remote_url/ref (#410) — clone/sync manifest metadata.
|
|
640
|
+
const projectRootCols = (getDb().query("PRAGMA table_info(project_roots)").all() as any[]).map((c: any) => c.name);
|
|
641
|
+
if (!projectRootCols.includes("remote_url")) {
|
|
642
|
+
getDb().run("ALTER TABLE project_roots ADD COLUMN remote_url TEXT");
|
|
643
|
+
}
|
|
644
|
+
if (!projectRootCols.includes("ref")) {
|
|
645
|
+
getDb().run("ALTER TABLE project_roots ADD COLUMN ref TEXT");
|
|
646
|
+
}
|
|
647
|
+
if (!projectRootCols.includes("orchestrator_id")) {
|
|
648
|
+
getDb().run("ALTER TABLE project_roots ADD COLUMN orchestrator_id TEXT");
|
|
649
|
+
}
|
|
650
|
+
migrateProjectRootHosts();
|
|
651
|
+
// Migration: project_entries audience/inject/expires_at/sensitivity (#1565 P2) — the
|
|
652
|
+
// unified-memory scope+audience model. Every default is behavior-preserving: an existing row
|
|
653
|
+
// becomes `audience:'all'`, `sensitivity:'normal'`, no TTL, and its kind-derived inject tier,
|
|
654
|
+
// which is exactly how the current composer already treats it (nothing reads these yet).
|
|
655
|
+
const projectEntryCols = (getDb().query("PRAGMA table_info(project_entries)").all() as any[]).map((c: any) => c.name);
|
|
656
|
+
if (!projectEntryCols.includes("audience")) {
|
|
657
|
+
getDb().run("ALTER TABLE project_entries ADD COLUMN audience TEXT NOT NULL DEFAULT 'all'");
|
|
658
|
+
}
|
|
659
|
+
if (!projectEntryCols.includes("inject")) {
|
|
660
|
+
getDb().run("ALTER TABLE project_entries ADD COLUMN inject TEXT NOT NULL DEFAULT 'indexed'");
|
|
661
|
+
// Backfill the kind-derived tier ONCE, at the ALTER (§4.3(1) — a directive that isn't in
|
|
662
|
+
// context doesn't bind). Guarded by the ALTER so a later hand-edit is never clobbered.
|
|
663
|
+
getDb().run("UPDATE project_entries SET inject = 'pinned' WHERE kind = 'rule'");
|
|
664
|
+
}
|
|
665
|
+
if (!projectEntryCols.includes("expires_at")) {
|
|
666
|
+
getDb().run("ALTER TABLE project_entries ADD COLUMN expires_at INTEGER");
|
|
667
|
+
}
|
|
668
|
+
if (!projectEntryCols.includes("sensitivity")) {
|
|
669
|
+
getDb().run("ALTER TABLE project_entries ADD COLUMN sensitivity TEXT NOT NULL DEFAULT 'normal'");
|
|
670
|
+
}
|
|
671
|
+
// #3408 — the memory's areas (JSON array). Existing rows stay NULL: legacy/untagged.
|
|
672
|
+
if (!projectEntryCols.includes("areas")) {
|
|
673
|
+
getDb().run("ALTER TABLE project_entries ADD COLUMN areas TEXT");
|
|
674
|
+
}
|
|
675
|
+
timeStartupPhase("db.backfill.project-issue-repos", backfillProjectIssueRepos);
|
|
676
|
+
timeStartupPhase("db.backfill.project-remote-urls", backfillProjectRootRemoteUrls);
|
|
677
|
+
timeStartupPhase("db.backfill.phantom-projects", mergePhantomWorktreeProjectsAtStartup);
|
|
678
|
+
ensureIngestedMemoryIndex();
|
|
679
|
+
rewriteEmptyToolGroupsToAbsent(); // #1963 N2 — persisted relay.tools.groups:[] meant ALL; honoring [] as NONE requires rewriting existing [] → absent first
|
|
680
|
+
backfillProjectMemoryToolGroup(); // #2154 follow-up — stored/overridden profiles do not pick up the built-in `project-memory` group on their own
|
|
681
|
+
removeLegacyProfileProjectInstructions(); // #2133 — remove retired profile policy fields before profile override migration reads legacy rows
|
|
682
|
+
backfillCustomProfileArtifacts(); // #3171 — Artifact is off by default now; keep the approved custom brainstorm exception
|
|
683
|
+
migrateAgentProfileOverridesToV2(); // #1963 N10 — back up + migrate persisted override rows to the v2 matrix (D-T=off; G6/G7 leave-untouched-and-report; flag-gated rollback)
|
|
684
|
+
migrateProfileSlimOnStartup(); // #2982 — marker-gated: promote 4 custom rows to built-in overrides, retire merged/removed presets, canonicalize memory audiences
|
|
685
|
+
migrateProfileHostSources((line) => console.log(`[profile-host-sources] ${line}`)); // #3387 — stamp Host asset classes whose omission now inherits differently; logs the per-class diff
|
|
686
|
+
migrateProfileProjectAcks((line) => console.log(`[profile-project-ack] ${line}`)); // #3636 — acks stopped hashing trust.review; re-stamp the ones valid under the old hash
|
|
687
|
+
ensureProfileNameCaseIndex(); // #2791 — case-insensitive uniqueness for agent-profile keys; throws naming collisions instead of merging them
|
|
688
|
+
|
|
689
|
+
// Migration: orchestrators.api_url
|
|
690
|
+
const orchCols = getDb().query("PRAGMA table_info(orchestrators)").all() as any[];
|
|
691
|
+
const orchColNames = orchCols.map((c: any) => c.name);
|
|
692
|
+
if (!orchColNames.includes("api_url")) {
|
|
693
|
+
getDb().run("ALTER TABLE orchestrators ADD COLUMN api_url TEXT");
|
|
694
|
+
}
|
|
695
|
+
// Migration: orchestrators.queued_spawns (#1513) — spawns held back by the host headroom admission
|
|
696
|
+
// gate, surfaced to the dashboard. Defaults to an empty JSON array for pre-existing rows.
|
|
697
|
+
if (!orchColNames.includes("queued_spawns")) {
|
|
698
|
+
getDb().run("ALTER TABLE orchestrators ADD COLUMN queued_spawns TEXT NOT NULL DEFAULT '[]'");
|
|
699
|
+
}
|
|
700
|
+
// ADR 0002 (#1925) H2 — orchestrators.host_id, the 1:N link to its Host row (§3.3). The fresh-DB
|
|
701
|
+
// schema.ts DDL already carries this column; an existing DB gains it here.
|
|
702
|
+
if (!orchColNames.includes("host_id")) {
|
|
703
|
+
getDb().run("ALTER TABLE orchestrators ADD COLUMN host_id TEXT REFERENCES hosts(id)");
|
|
704
|
+
}
|
|
705
|
+
// ADR 0002 §4.3.1 (#895 U3) — orchestrators.utilization, the per-generation half of the
|
|
706
|
+
// utilization sample. Nullable: a generation that has never reported (or a pre-upgrade daemon)
|
|
707
|
+
// has no sample, and the band reads that as "not reporting", never as "idle".
|
|
708
|
+
if (!orchColNames.includes("utilization")) {
|
|
709
|
+
getDb().run("ALTER TABLE orchestrators ADD COLUMN utilization TEXT");
|
|
710
|
+
}
|
|
711
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_orchestrators_host ON orchestrators(host_id)");
|
|
712
|
+
|
|
713
|
+
// #1977 — retain the latest real report separately from the accepted, first-seen fingerprint.
|
|
714
|
+
// Existing rows have no pending report, so their accepted fingerprint is the only truthful
|
|
715
|
+
// baseline until the next registration supplies a newer report.
|
|
716
|
+
const hostColNames = (getDb().query("PRAGMA table_info(hosts)").all() as any[]).map((c: any) => c.name);
|
|
717
|
+
if (!hostColNames.includes("reported_hardware")) {
|
|
718
|
+
getDb().run("ALTER TABLE hosts ADD COLUMN reported_hardware TEXT");
|
|
719
|
+
getDb().run("UPDATE hosts SET reported_hardware = hardware WHERE reported_hardware IS NULL");
|
|
720
|
+
}
|
|
721
|
+
// §3.3.2 backfill: one Host row per distinct hostname, keyed on normalizeHostToken(hostname),
|
|
722
|
+
// with {hostname, id} claimed as aliases and host_id linked — idempotent (skips already-linked
|
|
723
|
+
// rows). Then the §3.8 alias audit (RC-6), which must see the just-built alias table.
|
|
724
|
+
backfillHostsFromOrchestrators(Date.now());
|
|
725
|
+
auditHostAliases(Date.now());
|
|
726
|
+
|
|
727
|
+
const managedStateCols = getDb().query("PRAGMA table_info(managed_agent_state)").all() as any[];
|
|
728
|
+
const managedStateColNames = managedStateCols.map((c: any) => c.name);
|
|
729
|
+
if (!managedStateColNames.includes("workspace_id")) {
|
|
730
|
+
getDb().run("ALTER TABLE managed_agent_state ADD COLUMN workspace_id TEXT");
|
|
731
|
+
getDb().run("ALTER TABLE managed_agent_state ADD COLUMN workspace_path TEXT");
|
|
732
|
+
getDb().run("ALTER TABLE managed_agent_state ADD COLUMN workspace_branch TEXT");
|
|
733
|
+
}
|
|
734
|
+
// #1623 — retained last-known agent_id for steward provenance across the steward's own stop.
|
|
735
|
+
// Backfilled from the current agent_id so a steward RUNNING at migration time keeps its binding.
|
|
736
|
+
if (!managedStateColNames.includes("last_agent_id")) {
|
|
737
|
+
getDb().run("ALTER TABLE managed_agent_state ADD COLUMN last_agent_id TEXT");
|
|
738
|
+
getDb().run("UPDATE managed_agent_state SET last_agent_id = agent_id WHERE agent_id IS NOT NULL");
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
// message_reads: relational replacement for the read_by JSON array.
|
|
742
|
+
getDb().run(`
|
|
743
|
+
CREATE TABLE IF NOT EXISTS message_reads (
|
|
744
|
+
message_id INTEGER NOT NULL REFERENCES messages(id) ON DELETE CASCADE,
|
|
745
|
+
agent_id TEXT NOT NULL,
|
|
746
|
+
read_at INTEGER NOT NULL,
|
|
747
|
+
PRIMARY KEY (message_id, agent_id)
|
|
748
|
+
);
|
|
749
|
+
CREATE INDEX IF NOT EXISTS idx_mr_agent ON message_reads(agent_id);
|
|
750
|
+
`);
|
|
751
|
+
|
|
752
|
+
// Migration: agents.label
|
|
753
|
+
const agentCols = getDb().query("PRAGMA table_info(agents)").all() as any[];
|
|
754
|
+
const agentColNames = agentCols.map((c: any) => c.name);
|
|
755
|
+
if (!agentColNames.includes("label")) {
|
|
756
|
+
getDb().run("ALTER TABLE agents ADD COLUMN label TEXT");
|
|
757
|
+
}
|
|
758
|
+
if (!agentColNames.includes("ready")) {
|
|
759
|
+
getDb().run("ALTER TABLE agents ADD COLUMN ready INTEGER NOT NULL DEFAULT 0");
|
|
760
|
+
}
|
|
761
|
+
if (!agentColNames.includes("instance_id")) {
|
|
762
|
+
getDb().run("ALTER TABLE agents ADD COLUMN instance_id TEXT");
|
|
763
|
+
}
|
|
764
|
+
if (!agentColNames.includes("epoch")) {
|
|
765
|
+
getDb().run("ALTER TABLE agents ADD COLUMN epoch INTEGER NOT NULL DEFAULT 0");
|
|
766
|
+
}
|
|
767
|
+
if (!agentColNames.includes("kind")) {
|
|
768
|
+
getDb().run("ALTER TABLE agents ADD COLUMN kind TEXT NOT NULL DEFAULT 'provider'");
|
|
769
|
+
getDb().run(`
|
|
770
|
+
UPDATE agents
|
|
771
|
+
SET kind = CASE
|
|
772
|
+
WHEN id = 'user' THEN 'user'
|
|
773
|
+
WHEN id = 'system' THEN 'system'
|
|
774
|
+
WHEN json_extract(meta, '$.kind') = 'channel' THEN 'channel'
|
|
775
|
+
WHEN EXISTS (SELECT 1 FROM json_each(tags) WHERE value = 'channel') THEN 'channel'
|
|
776
|
+
ELSE 'provider'
|
|
777
|
+
END
|
|
778
|
+
`);
|
|
779
|
+
}
|
|
780
|
+
if (!agentColNames.includes("provider_capabilities")) {
|
|
781
|
+
getDb().run("ALTER TABLE agents ADD COLUMN provider_capabilities TEXT");
|
|
782
|
+
}
|
|
783
|
+
if (!agentColNames.includes("context_state")) {
|
|
784
|
+
getDb().run("ALTER TABLE agents ADD COLUMN context_state TEXT");
|
|
785
|
+
}
|
|
786
|
+
if (!agentColNames.includes("quota_state")) {
|
|
787
|
+
getDb().run("ALTER TABLE agents ADD COLUMN quota_state TEXT");
|
|
788
|
+
}
|
|
789
|
+
// #2367 — launch projection is large and immutable. Move it out of the hot meta JSON so status
|
|
790
|
+
// frames update only runtime fields. The mapper reattaches it at the AgentCard read boundary.
|
|
791
|
+
if (!agentColNames.includes("profile_projection")) {
|
|
792
|
+
getDb().run("ALTER TABLE agents ADD COLUMN profile_projection TEXT");
|
|
793
|
+
getDb().run(`
|
|
794
|
+
UPDATE agents
|
|
795
|
+
SET profile_projection = json_extract(meta, '$.agentProfile.projection'),
|
|
796
|
+
meta = json_remove(meta, '$.agentProfile.projection')
|
|
797
|
+
WHERE json_type(meta, '$.agentProfile.projection') IS NOT NULL
|
|
798
|
+
`);
|
|
799
|
+
}
|
|
800
|
+
if (!agentColNames.includes("lifecycle")) getDb().run("ALTER TABLE agents ADD COLUMN lifecycle TEXT NOT NULL DEFAULT 'persistent'");
|
|
801
|
+
// #2111 — the per-column lifecycle submission-ordinal fence. Existing rows start at 0, which is
|
|
802
|
+
// below every ordinal this process will issue (the counter is seeded from the stored high-water
|
|
803
|
+
// mark), so an upgraded DB is immediately writable rather than fenced out.
|
|
804
|
+
if (!agentColNames.includes("status_seq")) getDb().run("ALTER TABLE agents ADD COLUMN status_seq INTEGER NOT NULL DEFAULT 0");
|
|
805
|
+
if (!agentColNames.includes("ready_seq")) getDb().run("ALTER TABLE agents ADD COLUMN ready_seq INTEGER NOT NULL DEFAULT 0");
|
|
806
|
+
if (!agentColNames.includes("keep_state")) getDb().run("ALTER TABLE agents ADD COLUMN keep_state TEXT"); // #3428
|
|
807
|
+
if (!agentColNames.includes("system_tags")) { getDb().run("ALTER TABLE agents ADD COLUMN system_tags TEXT NOT NULL DEFAULT '[]'"); getDb().query(`UPDATE agents SET system_tags = CASE WHEN json_extract(meta, '$.profile') IN (${COORDINATOR_PROFILE_NAMES.map(() => "?").join(",")}) THEN '[\"coordinator\"]' WHEN json_extract(meta, '$.profile') = 'memory-steward' THEN '[\"memory-steward\"]' WHEN EXISTS (SELECT 1 FROM json_each(agents.tags) WHERE value = 'steward') THEN '[\"merge-steward\"]' ELSE system_tags END WHERE system_tags = '[]'`).run(...COORDINATOR_PROFILE_NAMES); }
|
|
808
|
+
|
|
809
|
+
// Relay-owned provisioning registry (#554/#555/#556/#694) — see schema.ts for
|
|
810
|
+
// canonical DDL; mirrored here so existing DBs gain the registry on upgrade.
|
|
811
|
+
getDb().run(`
|
|
812
|
+
CREATE TABLE IF NOT EXISTS provisioning_capabilities (
|
|
813
|
+
id TEXT PRIMARY KEY,
|
|
814
|
+
slug TEXT NOT NULL,
|
|
815
|
+
kind TEXT NOT NULL,
|
|
816
|
+
title TEXT,
|
|
817
|
+
description TEXT,
|
|
818
|
+
status TEXT NOT NULL DEFAULT 'active',
|
|
819
|
+
tenant_id TEXT,
|
|
820
|
+
created_at INTEGER NOT NULL,
|
|
821
|
+
updated_at INTEGER NOT NULL,
|
|
822
|
+
UNIQUE(kind, slug)
|
|
823
|
+
)
|
|
824
|
+
`);
|
|
825
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_provisioning_capabilities_kind ON provisioning_capabilities(kind, status)");
|
|
826
|
+
getDb().run(`
|
|
827
|
+
CREATE TABLE IF NOT EXISTS provisioning_assets (
|
|
828
|
+
id TEXT PRIMARY KEY,
|
|
829
|
+
kind TEXT NOT NULL,
|
|
830
|
+
name TEXT NOT NULL,
|
|
831
|
+
provider TEXT NOT NULL DEFAULT 'any',
|
|
832
|
+
definition TEXT NOT NULL,
|
|
833
|
+
enabled INTEGER NOT NULL DEFAULT 1,
|
|
834
|
+
created_at INTEGER NOT NULL,
|
|
835
|
+
updated_at INTEGER NOT NULL,
|
|
836
|
+
UNIQUE(kind, name, provider)
|
|
837
|
+
)
|
|
838
|
+
`);
|
|
839
|
+
let provisioningAssetColNames = provisioningAssetsColumnNames();
|
|
840
|
+
const provisioningAssetAddColumns = [
|
|
841
|
+
["capability_id", "capability_id TEXT"],
|
|
842
|
+
["source_type", "source_type TEXT"],
|
|
843
|
+
["source_url", "source_url TEXT"],
|
|
844
|
+
["source_ref", "source_ref TEXT"],
|
|
845
|
+
["resolved_ref", "resolved_ref TEXT"],
|
|
846
|
+
["source_subpath", "source_subpath TEXT"],
|
|
847
|
+
["version_constraint", "version_constraint TEXT"],
|
|
848
|
+
["approval_status", "approval_status TEXT NOT NULL DEFAULT 'approved'"],
|
|
849
|
+
["validation_status", "validation_status TEXT NOT NULL DEFAULT 'valid'"],
|
|
850
|
+
["validation_errors", "validation_errors TEXT NOT NULL DEFAULT '[]'"],
|
|
851
|
+
["provenance", "provenance TEXT NOT NULL DEFAULT '{}'"],
|
|
852
|
+
["imported_at", "imported_at INTEGER"],
|
|
853
|
+
] as const;
|
|
854
|
+
for (const [name, ddl] of provisioningAssetAddColumns) {
|
|
855
|
+
if (!provisioningAssetColNames.includes(name)) getDb().run(`ALTER TABLE provisioning_assets ADD COLUMN ${ddl}`);
|
|
856
|
+
}
|
|
857
|
+
const existingCapabilities = getDb()
|
|
858
|
+
.query("SELECT kind, name, min(created_at) AS created_at, max(updated_at) AS updated_at FROM provisioning_assets GROUP BY kind, name")
|
|
859
|
+
.all() as Array<{ kind: string; name: string; created_at: number; updated_at: number }>;
|
|
860
|
+
const insertCapability = getDb().query(`
|
|
861
|
+
INSERT INTO provisioning_capabilities (id, slug, kind, title, status, tenant_id, created_at, updated_at)
|
|
862
|
+
VALUES (?, ?, ?, ?, 'active', NULL, ?, ?)
|
|
863
|
+
ON CONFLICT(kind, slug) DO UPDATE SET
|
|
864
|
+
updated_at = max(provisioning_capabilities.updated_at, excluded.updated_at)
|
|
865
|
+
`);
|
|
866
|
+
const backfillCapabilities = getDb().transaction((rows: typeof existingCapabilities) => {
|
|
867
|
+
for (const row of rows) {
|
|
868
|
+
insertCapability.run(`pc_${randomUUID().replace(/-/g, "").slice(0, 16)}`, row.name, row.kind, row.name, row.created_at, row.updated_at);
|
|
869
|
+
}
|
|
870
|
+
getDb().run(`
|
|
871
|
+
UPDATE provisioning_assets
|
|
872
|
+
SET capability_id = (
|
|
873
|
+
SELECT id FROM provisioning_capabilities
|
|
874
|
+
WHERE provisioning_capabilities.kind = provisioning_assets.kind
|
|
875
|
+
AND provisioning_capabilities.slug = provisioning_assets.name
|
|
876
|
+
)
|
|
877
|
+
WHERE capability_id IS NULL
|
|
878
|
+
`);
|
|
879
|
+
getDb().run("UPDATE provisioning_assets SET imported_at = coalesce(imported_at, created_at)");
|
|
880
|
+
});
|
|
881
|
+
backfillCapabilities(existingCapabilities);
|
|
882
|
+
if (provisioningAssetsNeedsRebuild()) rebuildProvisioningAssetsTable();
|
|
883
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_provisioning_assets_kind ON provisioning_assets(kind, enabled)");
|
|
884
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_provisioning_assets_capability ON provisioning_assets(capability_id, provider, enabled)");
|
|
885
|
+
getDb().run(`
|
|
886
|
+
CREATE UNIQUE INDEX IF NOT EXISTS idx_provisioning_assets_capability_provider
|
|
887
|
+
ON provisioning_assets(capability_id, provider)
|
|
888
|
+
`);
|
|
889
|
+
seedBundledProvisioningAssets();
|
|
890
|
+
seedQaSkills();
|
|
891
|
+
seedSharedCallmuxProvisioningAssets();
|
|
892
|
+
if (!agentColNames.includes("spawned_by")) {
|
|
893
|
+
getDb().run("ALTER TABLE agents ADD COLUMN spawned_by TEXT");
|
|
894
|
+
}
|
|
895
|
+
if (!agentColNames.includes("team_id")) {
|
|
896
|
+
getDb().run("ALTER TABLE agents ADD COLUMN team_id TEXT");
|
|
897
|
+
}
|
|
898
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_agents_team ON agents(team_id)");
|
|
899
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_agents_spawn_request ON agents(json_extract(meta, '$.spawnRequestId'))");
|
|
900
|
+
getDb().run(`
|
|
901
|
+
CREATE TABLE IF NOT EXISTS notification_subscriptions (
|
|
902
|
+
id TEXT PRIMARY KEY,
|
|
903
|
+
agent_id TEXT NOT NULL REFERENCES agents(id) ON DELETE CASCADE,
|
|
904
|
+
type TEXT NOT NULL,
|
|
905
|
+
mode TEXT NOT NULL CHECK (mode IN ('opt_in', 'opt_out', 'mute')),
|
|
906
|
+
scope_match TEXT,
|
|
907
|
+
created_at INTEGER NOT NULL
|
|
908
|
+
)
|
|
909
|
+
`);
|
|
910
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_notification_subscriptions_agent ON notification_subscriptions(agent_id, type)");
|
|
911
|
+
getDb().run(`
|
|
912
|
+
CREATE UNIQUE INDEX IF NOT EXISTS idx_notification_subscriptions_unique
|
|
913
|
+
ON notification_subscriptions(agent_id, type, mode, coalesce(scope_match, ''))
|
|
914
|
+
`);
|
|
915
|
+
getDb().run(`
|
|
916
|
+
CREATE TABLE IF NOT EXISTS context_snapshots (
|
|
917
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
918
|
+
agent_id TEXT NOT NULL REFERENCES agents(id) ON DELETE CASCADE,
|
|
919
|
+
utilization REAL NOT NULL,
|
|
920
|
+
lifecycle_state TEXT NOT NULL,
|
|
921
|
+
tokens_used INTEGER,
|
|
922
|
+
tokens_max INTEGER,
|
|
923
|
+
source TEXT NOT NULL,
|
|
924
|
+
confidence TEXT NOT NULL,
|
|
925
|
+
context_state TEXT NOT NULL,
|
|
926
|
+
captured_at INTEGER NOT NULL
|
|
927
|
+
)
|
|
928
|
+
`);
|
|
929
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_context_snapshots_agent_time ON context_snapshots(agent_id, captured_at DESC)");
|
|
930
|
+
getDb().run(`
|
|
931
|
+
CREATE TABLE IF NOT EXISTS quota_snapshots (
|
|
932
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
933
|
+
provider TEXT NOT NULL,
|
|
934
|
+
account_key TEXT NOT NULL,
|
|
935
|
+
agent_id TEXT REFERENCES agents(id) ON DELETE SET NULL,
|
|
936
|
+
windows TEXT NOT NULL,
|
|
937
|
+
source TEXT NOT NULL,
|
|
938
|
+
quota_state TEXT NOT NULL,
|
|
939
|
+
captured_at INTEGER NOT NULL
|
|
940
|
+
)
|
|
941
|
+
`);
|
|
942
|
+
const quotaSnapshotCols = (getDb().query("PRAGMA table_info(quota_snapshots)").all() as Array<{ name: string }>).map((col) => col.name);
|
|
943
|
+
if (!quotaSnapshotCols.includes("provider") || !quotaSnapshotCols.includes("account_key")) {
|
|
944
|
+
getDb().run("ALTER TABLE quota_snapshots RENAME TO quota_snapshots_legacy_agent");
|
|
945
|
+
getDb().run(`
|
|
946
|
+
CREATE TABLE quota_snapshots (
|
|
947
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
948
|
+
provider TEXT NOT NULL,
|
|
949
|
+
account_key TEXT NOT NULL,
|
|
950
|
+
agent_id TEXT REFERENCES agents(id) ON DELETE SET NULL,
|
|
951
|
+
windows TEXT NOT NULL,
|
|
952
|
+
source TEXT NOT NULL,
|
|
953
|
+
quota_state TEXT NOT NULL,
|
|
954
|
+
captured_at INTEGER NOT NULL
|
|
955
|
+
)
|
|
956
|
+
`);
|
|
957
|
+
getDb().run(`
|
|
958
|
+
INSERT INTO quota_snapshots (id, provider, account_key, agent_id, windows, source, quota_state, captured_at)
|
|
959
|
+
SELECT
|
|
960
|
+
qs.id,
|
|
961
|
+
CASE
|
|
962
|
+
WHEN json_extract(a.meta, '$.provider') IS NOT NULL THEN lower(json_extract(a.meta, '$.provider'))
|
|
963
|
+
WHEN a.tags LIKE '%"codex"%' OR lower(a.id) LIKE '%codex%' OR lower(a.name) LIKE '%codex%' THEN 'codex'
|
|
964
|
+
ELSE 'claude'
|
|
965
|
+
END,
|
|
966
|
+
coalesce(
|
|
967
|
+
nullif(json_extract(a.meta, '$.accountKey'), ''),
|
|
968
|
+
nullif(json_extract(a.meta, '$.accountId'), ''),
|
|
969
|
+
nullif(json_extract(a.meta, '$.orgId'), ''),
|
|
970
|
+
'host:' || coalesce(a.machine, a.rig, 'unknown')
|
|
971
|
+
),
|
|
972
|
+
qs.agent_id,
|
|
973
|
+
qs.windows,
|
|
974
|
+
qs.source,
|
|
975
|
+
qs.quota_state,
|
|
976
|
+
qs.captured_at
|
|
977
|
+
FROM quota_snapshots_legacy_agent qs
|
|
978
|
+
LEFT JOIN agents a ON a.id = qs.agent_id
|
|
979
|
+
`);
|
|
980
|
+
getDb().run("DROP TABLE quota_snapshots_legacy_agent");
|
|
981
|
+
}
|
|
982
|
+
// #609 — durable 30-day quota history needs explicit "couldn't collect" markers so gaps are
|
|
983
|
+
// first-class, not silent absences. An unavailable row carries no quota: `unavailable=1` plus the
|
|
984
|
+
// skip reason in `last_error` (the NOT NULL windows/source/quota_state columns get inert placeholders
|
|
985
|
+
// that `rowToSnapshot` never reads when `unavailable=1`).
|
|
986
|
+
const quotaSnapshotColsNow = (getDb().query("PRAGMA table_info(quota_snapshots)").all() as Array<{ name: string }>).map((col) => col.name);
|
|
987
|
+
if (!quotaSnapshotColsNow.includes("unavailable")) {
|
|
988
|
+
getDb().run("ALTER TABLE quota_snapshots ADD COLUMN unavailable INTEGER NOT NULL DEFAULT 0");
|
|
989
|
+
}
|
|
990
|
+
if (!quotaSnapshotColsNow.includes("last_error")) {
|
|
991
|
+
getDb().run("ALTER TABLE quota_snapshots ADD COLUMN last_error TEXT");
|
|
992
|
+
}
|
|
993
|
+
getDb().run(`
|
|
994
|
+
CREATE TABLE IF NOT EXISTS provider_quotas (
|
|
995
|
+
provider TEXT NOT NULL,
|
|
996
|
+
account_key TEXT NOT NULL,
|
|
997
|
+
quota_state TEXT,
|
|
998
|
+
source_agent_ids TEXT NOT NULL DEFAULT '[]',
|
|
999
|
+
quota_advisory_state TEXT NOT NULL DEFAULT '{}',
|
|
1000
|
+
last_updated_at INTEGER,
|
|
1001
|
+
last_attempt_at INTEGER NOT NULL,
|
|
1002
|
+
last_error TEXT,
|
|
1003
|
+
updated_at INTEGER NOT NULL,
|
|
1004
|
+
created_at INTEGER NOT NULL,
|
|
1005
|
+
PRIMARY KEY (provider, account_key)
|
|
1006
|
+
)
|
|
1007
|
+
`);
|
|
1008
|
+
const providerQuotaCols = (getDb().query("PRAGMA table_info(provider_quotas)").all() as Array<{ name: string }>).map((col) => col.name);
|
|
1009
|
+
if (!providerQuotaCols.includes("codex_reset_credits")) getDb().run("ALTER TABLE provider_quotas ADD COLUMN codex_reset_credits TEXT");
|
|
1010
|
+
if (!providerQuotaCols.includes("quota_advisory_state")) getDb().run("ALTER TABLE provider_quotas ADD COLUMN quota_advisory_state TEXT NOT NULL DEFAULT '{}'");
|
|
1011
|
+
// #1074 — persist quota-band hysteresis state so a relay restart doesn't re-fire already-sent
|
|
1012
|
+
// band-degradation notifications to the whole fleet.
|
|
1013
|
+
if (!providerQuotaCols.includes("quota_band_state")) getDb().run("ALTER TABLE provider_quotas ADD COLUMN quota_band_state TEXT NOT NULL DEFAULT '{}'");
|
|
1014
|
+
getDb().run("CREATE TABLE IF NOT EXISTS provider_quota_effect_occurrences (id INTEGER PRIMARY KEY AUTOINCREMENT, provider TEXT NOT NULL, account_key TEXT NOT NULL, event_type TEXT NOT NULL, subject TEXT NOT NULL, created_at INTEGER NOT NULL)");
|
|
1015
|
+
getDb().run(`
|
|
1016
|
+
INSERT INTO provider_quotas (
|
|
1017
|
+
provider, account_key, quota_state, source_agent_ids, last_updated_at,
|
|
1018
|
+
last_attempt_at, last_error, updated_at, created_at
|
|
1019
|
+
)
|
|
1020
|
+
SELECT
|
|
1021
|
+
CASE
|
|
1022
|
+
WHEN json_extract(meta, '$.provider') IS NOT NULL THEN lower(json_extract(meta, '$.provider'))
|
|
1023
|
+
WHEN tags LIKE '%"codex"%' OR lower(id) LIKE '%codex%' OR lower(name) LIKE '%codex%' THEN 'codex'
|
|
1024
|
+
ELSE 'claude'
|
|
1025
|
+
END AS provider,
|
|
1026
|
+
coalesce(
|
|
1027
|
+
nullif(json_extract(meta, '$.accountKey'), ''),
|
|
1028
|
+
nullif(json_extract(meta, '$.accountId'), ''),
|
|
1029
|
+
nullif(json_extract(meta, '$.orgId'), ''),
|
|
1030
|
+
'host:' || coalesce(machine, rig, 'unknown')
|
|
1031
|
+
) AS account_key,
|
|
1032
|
+
quota_state,
|
|
1033
|
+
json_array(id),
|
|
1034
|
+
coalesce(json_extract(quota_state, '$.updatedAt'), last_seen),
|
|
1035
|
+
coalesce(json_extract(quota_state, '$.updatedAt'), last_seen),
|
|
1036
|
+
NULL,
|
|
1037
|
+
last_seen,
|
|
1038
|
+
created_at
|
|
1039
|
+
FROM agents
|
|
1040
|
+
WHERE quota_state IS NOT NULL
|
|
1041
|
+
ON CONFLICT(provider, account_key) DO UPDATE SET
|
|
1042
|
+
quota_state = excluded.quota_state,
|
|
1043
|
+
source_agent_ids = excluded.source_agent_ids,
|
|
1044
|
+
last_updated_at = max(coalesce(provider_quotas.last_updated_at, 0), coalesce(excluded.last_updated_at, 0)),
|
|
1045
|
+
last_attempt_at = max(provider_quotas.last_attempt_at, excluded.last_attempt_at),
|
|
1046
|
+
updated_at = max(provider_quotas.updated_at, excluded.updated_at)
|
|
1047
|
+
`);
|
|
1048
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_quota_snapshots_account_time ON quota_snapshots(provider, account_key, captured_at DESC)");
|
|
1049
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_quota_snapshots_agent_time ON quota_snapshots(agent_id, captured_at DESC)");
|
|
1050
|
+
normalizeProviderQuotaAccountKeys();
|
|
1051
|
+
|
|
1052
|
+
getDb().run(`
|
|
1053
|
+
CREATE TABLE IF NOT EXISTS provider_quota_leases (
|
|
1054
|
+
provider TEXT NOT NULL,
|
|
1055
|
+
account_key TEXT NOT NULL,
|
|
1056
|
+
orchestrator_id TEXT NOT NULL,
|
|
1057
|
+
lease_token TEXT NOT NULL,
|
|
1058
|
+
expires_at INTEGER NOT NULL,
|
|
1059
|
+
updated_at INTEGER NOT NULL,
|
|
1060
|
+
created_at INTEGER NOT NULL,
|
|
1061
|
+
PRIMARY KEY (provider, account_key)
|
|
1062
|
+
)
|
|
1063
|
+
`);
|
|
1064
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_provider_quota_leases_expires ON provider_quota_leases(expires_at)");
|
|
1065
|
+
|
|
1066
|
+
// #1425 finding 2 — durable dedupe for the manual Codex banked-reset trigger. Keyed by the
|
|
1067
|
+
// STABLE idempotency key derived per logical owner action (not a fresh UUID per call): a
|
|
1068
|
+
// lost-response retry of the same logical request is recognized here and returns the original
|
|
1069
|
+
// outcome instead of burning a second scarce reset. A row is written in-flight BEFORE firing
|
|
1070
|
+
// and completed after; the codex-side idempotency (same key) is the backstop for the window
|
|
1071
|
+
// where the fire happened but our recording of it didn't.
|
|
1072
|
+
getDb().run(`
|
|
1073
|
+
CREATE TABLE IF NOT EXISTS codex_reset_consumes (
|
|
1074
|
+
idempotency_key TEXT PRIMARY KEY,
|
|
1075
|
+
provider TEXT NOT NULL,
|
|
1076
|
+
account_key TEXT,
|
|
1077
|
+
status TEXT NOT NULL,
|
|
1078
|
+
outcome TEXT,
|
|
1079
|
+
burned INTEGER,
|
|
1080
|
+
available_count INTEGER,
|
|
1081
|
+
orchestrator_id TEXT,
|
|
1082
|
+
created_at INTEGER NOT NULL,
|
|
1083
|
+
updated_at INTEGER NOT NULL
|
|
1084
|
+
)
|
|
1085
|
+
`);
|
|
1086
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_codex_reset_consumes_created ON codex_reset_consumes(created_at)");
|
|
1087
|
+
|
|
1088
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_agents_label ON agents(label)");
|
|
1089
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_agents_kind ON agents(kind)");
|
|
1090
|
+
getDb().run(`
|
|
1091
|
+
CREATE INDEX IF NOT EXISTS idx_activity_registered_spawn_request
|
|
1092
|
+
ON activity_events(json_extract(metadata, '$.spawnRequestId'))
|
|
1093
|
+
WHERE kind = 'state' AND title = 'Agent registered'
|
|
1094
|
+
`);
|
|
1095
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_commands_spawn_watchdog ON commands(type, status, updated_at)");
|
|
1096
|
+
// #1858 — runs AFTER the commands/agents/activity_events tables and the two spawnRequestId indexes
|
|
1097
|
+
// above exist, so the backfill's registration lookups are indexed point lookups. #3707: once per DB;
|
|
1098
|
+
// registration stamps new spawns, and rescanning every spawn's params took 43 s on a hub restart.
|
|
1099
|
+
timeStartupPhase("db.backfill.spawn-registration", backfillSpawnRegistrationConfirmedOnce);
|
|
1100
|
+
|
|
1101
|
+
getDb().run(`
|
|
1102
|
+
CREATE TABLE IF NOT EXISTS integration_registry (
|
|
1103
|
+
name TEXT PRIMARY KEY,
|
|
1104
|
+
display_name TEXT,
|
|
1105
|
+
description TEXT,
|
|
1106
|
+
enabled INTEGER NOT NULL DEFAULT 1,
|
|
1107
|
+
scopes TEXT NOT NULL DEFAULT '[]',
|
|
1108
|
+
targets TEXT NOT NULL DEFAULT '[]',
|
|
1109
|
+
channels TEXT NOT NULL DEFAULT '[]',
|
|
1110
|
+
type TEXT,
|
|
1111
|
+
icon TEXT,
|
|
1112
|
+
accent_color TEXT,
|
|
1113
|
+
tags TEXT NOT NULL DEFAULT '[]',
|
|
1114
|
+
homepage_url TEXT,
|
|
1115
|
+
repository_url TEXT,
|
|
1116
|
+
docs_url TEXT,
|
|
1117
|
+
manifest TEXT NOT NULL DEFAULT '{}',
|
|
1118
|
+
source TEXT NOT NULL DEFAULT 'api',
|
|
1119
|
+
created_at INTEGER NOT NULL,
|
|
1120
|
+
updated_at INTEGER NOT NULL,
|
|
1121
|
+
last_event_at INTEGER,
|
|
1122
|
+
last_task_at INTEGER,
|
|
1123
|
+
last_auth_success_at INTEGER,
|
|
1124
|
+
last_auth_failure_at INTEGER
|
|
1125
|
+
)
|
|
1126
|
+
`);
|
|
1127
|
+
|
|
1128
|
+
// #636 — persisted crash post-mortems. Own table, no FK to agents, so a death verdict outlives
|
|
1129
|
+
// the offline-prune/reaper and stays retrievable by agentId.
|
|
1130
|
+
ensureCrashReportsSchema();
|
|
1131
|
+
migrateVaultSchema();
|
|
1132
|
+
ensureLaunchFactsSchema();
|
|
1133
|
+
ensureBudgetLineageSchema();
|
|
1134
|
+
ensureSpawnTreeStopSchema();
|
|
1135
|
+
|
|
1136
|
+
// #645 — clean terminal markers (sibling of crash_reports). Own table, no FK, so an EXPECTED
|
|
1137
|
+
// terminus (transient reap after land, graceful shutdown) outlives the reaper and lets the #634
|
|
1138
|
+
// watchdog tell a benign completion from a silent death. Idempotent CREATE IF NOT EXISTS.
|
|
1139
|
+
ensureTerminalEventsSchema();
|
|
1140
|
+
ensureWebToolCallsSchema();
|
|
1141
|
+
|
|
1142
|
+
// First-class human users (#388 keystone #393): ensure the table (single DDL home in users.ts)
|
|
1143
|
+
// and seed the admin-level default user mapped to the existing single human. P0 + idempotent —
|
|
1144
|
+
// bare 'user' == user:default resolve to users.id='default' via the SDK resolver; no bytes move.
|
|
1145
|
+
ensureUsersSchema();
|
|
1146
|
+
seedDefaultUser();
|
|
1147
|
+
|
|
1148
|
+
// Pluggable login identities (#389): the (provider, provider_subject) → users.id map behind real
|
|
1149
|
+
// login + sessions. Ensured right after the user seed (FK → users) and idempotent — an old
|
|
1150
|
+
// single-user DB gains it empty, and the god-token break-glass keeps working with zero rows.
|
|
1151
|
+
ensureAuthIdentitiesSchema();
|
|
1152
|
+
// Single-use invites (#3567): additive, empty until an admin turns invites on.
|
|
1153
|
+
ensureUserInvitesSchema();
|
|
1154
|
+
|
|
1155
|
+
// Agent ownership/visibility table (#392). FK-references both agents and users, so it ensures
|
|
1156
|
+
// AFTER both exist. The backfill (seedDefaultAgentOwnership) runs below, once the built-in
|
|
1157
|
+
// agents are in, so they can be excluded from ownership.
|
|
1158
|
+
ensureAgentOwnershipSchema();
|
|
1159
|
+
|
|
1160
|
+
// Per-agent drive lease — the "X is driving this agent" soft-lock (#394). FK-references agents,
|
|
1161
|
+
// so it ensures after the agents table exists. Empty in a single-user world (the arbiter never
|
|
1162
|
+
// writes it), so it adds nothing to the legacy flow.
|
|
1163
|
+
ensureDriveLeaseSchema();
|
|
1164
|
+
|
|
1165
|
+
// #652 — epoch column on terminal_events: a stale event from a prior epoch must NOT suppress the
|
|
1166
|
+
// heartbeat-gap alert for a genuine silent death in a later epoch (agent_id reuse across epochs).
|
|
1167
|
+
// Default 0 preserves the suppression behaviour for all existing rows written before this migration.
|
|
1168
|
+
const terminalEventCols = (getDb().query("PRAGMA table_info(terminal_events)").all() as any[]).map((c: any) => c.name);
|
|
1169
|
+
if (!terminalEventCols.includes("epoch")) {
|
|
1170
|
+
getDb().run("ALTER TABLE terminal_events ADD COLUMN epoch INTEGER NOT NULL DEFAULT 0");
|
|
1171
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_terminal_events_agent ON terminal_events(agent_id, epoch, created_at DESC)");
|
|
1172
|
+
}
|
|
1173
|
+
|
|
1174
|
+
// Built-in agents — registered unconditionally so sends from these ids
|
|
1175
|
+
// pass the sendMessage validation. The reaper exempts these by checking
|
|
1176
|
+
// meta.builtin (or by id for "user").
|
|
1177
|
+
const now = Date.now();
|
|
1178
|
+
const builtinStmt = getDb().query(`
|
|
1179
|
+
INSERT INTO agents (id, name, kind, tags, machine, rig, capabilities, ready, status, meta, lifecycle, last_seen, created_at)
|
|
1180
|
+
VALUES (?, ?, ?, ?, NULL, NULL, '[]', 1, 'online', '{"builtin":true}', 'persistent', ?, ?)
|
|
1181
|
+
ON CONFLICT(id) DO UPDATE SET status = 'online', ready = 1, last_seen = excluded.last_seen
|
|
1182
|
+
`);
|
|
1183
|
+
builtinStmt.run("user", "User", "user", '["human"]', now, now);
|
|
1184
|
+
builtinStmt.run("system", "System", "system", '["system"]', now, now);
|
|
1185
|
+
|
|
1186
|
+
// #3567 H7: legacy agents stay visible to admins; sharing with other users is explicit.
|
|
1187
|
+
seedDefaultAgentOwnership();
|
|
1188
|
+
|
|
1189
|
+
// #652 follow-up — the epoch migration above used CREATE INDEX IF NOT EXISTS, but existing prod
|
|
1190
|
+
// DBs already had idx_terminal_events_agent under the old (agent_id, created_at DESC) shape from
|
|
1191
|
+
// #645; that made the new three-column definition a silent no-op. Drop-and-recreate forces the
|
|
1192
|
+
// correct shape on all DB vintages; fresh DBs already carry the right shape and are unaffected.
|
|
1193
|
+
getDb().run("DROP INDEX IF EXISTS idx_terminal_events_agent");
|
|
1194
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_terminal_events_agent ON terminal_events(agent_id, epoch, created_at DESC)");
|
|
1195
|
+
|
|
1196
|
+
// #361 — persistent Relay scheduler. Keep this append-only at the end: older DBs may
|
|
1197
|
+
// have reached this point through many schema vintages, and the table references messages.
|
|
1198
|
+
getDb().run(`
|
|
1199
|
+
CREATE TABLE IF NOT EXISTS scheduled_timers (
|
|
1200
|
+
id TEXT PRIMARY KEY,
|
|
1201
|
+
target TEXT NOT NULL,
|
|
1202
|
+
created_by TEXT NOT NULL,
|
|
1203
|
+
created_by_kind TEXT NOT NULL,
|
|
1204
|
+
created_by_scopes TEXT NOT NULL DEFAULT '[]',
|
|
1205
|
+
created_by_constraints TEXT,
|
|
1206
|
+
delivery_from TEXT NOT NULL,
|
|
1207
|
+
created_at INTEGER NOT NULL,
|
|
1208
|
+
next_run_at INTEGER NOT NULL,
|
|
1209
|
+
schedule_kind TEXT NOT NULL,
|
|
1210
|
+
schedule_def TEXT NOT NULL,
|
|
1211
|
+
message_kind TEXT,
|
|
1212
|
+
channel TEXT,
|
|
1213
|
+
subject TEXT,
|
|
1214
|
+
body TEXT NOT NULL,
|
|
1215
|
+
claimable INTEGER NOT NULL DEFAULT 0,
|
|
1216
|
+
payload TEXT NOT NULL DEFAULT '{}',
|
|
1217
|
+
meta TEXT NOT NULL DEFAULT '{}',
|
|
1218
|
+
enabled INTEGER NOT NULL DEFAULT 1,
|
|
1219
|
+
run_count INTEGER NOT NULL DEFAULT 0,
|
|
1220
|
+
max_runs INTEGER,
|
|
1221
|
+
expires_at INTEGER,
|
|
1222
|
+
last_run_at INTEGER,
|
|
1223
|
+
last_error TEXT,
|
|
1224
|
+
consecutive_failures INTEGER NOT NULL DEFAULT 0,
|
|
1225
|
+
idempotency_key TEXT,
|
|
1226
|
+
correlation_id TEXT NOT NULL,
|
|
1227
|
+
last_message_id INTEGER REFERENCES messages(id),
|
|
1228
|
+
claimed_by TEXT,
|
|
1229
|
+
claim_expires_at INTEGER,
|
|
1230
|
+
command TEXT,
|
|
1231
|
+
message_authority_frozen INTEGER NOT NULL DEFAULT 0
|
|
1232
|
+
CHECK (message_authority_frozen IN (0, 1) AND (command IS NULL OR message_authority_frozen = 0))
|
|
1233
|
+
)
|
|
1234
|
+
`);
|
|
1235
|
+
const scheduledTimerCols = (getDb().query("PRAGMA table_info(scheduled_timers)").all() as any[]).map((c: any) => c.name);
|
|
1236
|
+
if (!scheduledTimerCols.includes("message_kind")) {
|
|
1237
|
+
getDb().run("ALTER TABLE scheduled_timers ADD COLUMN message_kind TEXT");
|
|
1238
|
+
}
|
|
1239
|
+
if (!scheduledTimerCols.includes("channel")) {
|
|
1240
|
+
getDb().run("ALTER TABLE scheduled_timers ADD COLUMN channel TEXT");
|
|
1241
|
+
}
|
|
1242
|
+
if (!scheduledTimerCols.includes("claimable")) {
|
|
1243
|
+
getDb().run("ALTER TABLE scheduled_timers ADD COLUMN claimable INTEGER NOT NULL DEFAULT 0");
|
|
1244
|
+
}
|
|
1245
|
+
if (!scheduledTimerCols.includes("meta")) {
|
|
1246
|
+
getDb().run("ALTER TABLE scheduled_timers ADD COLUMN meta TEXT NOT NULL DEFAULT '{}'");
|
|
1247
|
+
}
|
|
1248
|
+
if (!scheduledTimerCols.includes("command")) {
|
|
1249
|
+
getDb().run("ALTER TABLE scheduled_timers ADD COLUMN command TEXT");
|
|
1250
|
+
}
|
|
1251
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_scheduled_timers_due ON scheduled_timers(enabled, next_run_at, claim_expires_at)");
|
|
1252
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_scheduled_timers_creator ON scheduled_timers(created_by, enabled, next_run_at)");
|
|
1253
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_scheduled_timers_correlation ON scheduled_timers(correlation_id)");
|
|
1254
|
+
|
|
1255
|
+
// #834 — grow `tasks` into the durable Task entity. Additive, kind-fenced columns:
|
|
1256
|
+
// existing rows default to kind='claim'/deliverable_stage='none', so every legacy
|
|
1257
|
+
// claim path is byte-for-byte unaffected. The claim-lease machinery filters kind='claim'.
|
|
1258
|
+
const durableTaskCols = (getDb().query("PRAGMA table_info(tasks)").all() as any[]).map((c: any) => c.name);
|
|
1259
|
+
const addTaskCol = (name: string, ddl: string) => {
|
|
1260
|
+
if (!durableTaskCols.includes(name)) getDb().run(`ALTER TABLE tasks ADD COLUMN ${ddl}`);
|
|
1261
|
+
};
|
|
1262
|
+
addTaskCol("kind", "kind TEXT NOT NULL DEFAULT 'claim'");
|
|
1263
|
+
addTaskCol("intent", "intent TEXT");
|
|
1264
|
+
addTaskCol("complexity", "complexity TEXT");
|
|
1265
|
+
addTaskCol("context", "context TEXT");
|
|
1266
|
+
addTaskCol("latest_steer", "latest_steer TEXT");
|
|
1267
|
+
addTaskCol("deliverable_stage", "deliverable_stage TEXT NOT NULL DEFAULT 'none'");
|
|
1268
|
+
addTaskCol("blocked_by", "blocked_by TEXT");
|
|
1269
|
+
addTaskCol("branch", "branch TEXT");
|
|
1270
|
+
addTaskCol("commits", "commits TEXT");
|
|
1271
|
+
addTaskCol("done_when", "done_when TEXT");
|
|
1272
|
+
addTaskCol("team_id", "team_id TEXT");
|
|
1273
|
+
addTaskCol("project_id", "project_id TEXT");
|
|
1274
|
+
addTaskCol("repo", "repo TEXT");
|
|
1275
|
+
addTaskCol("created_by", "created_by TEXT");
|
|
1276
|
+
addTaskCol("owner_agent_id", "owner_agent_id TEXT");
|
|
1277
|
+
addTaskCol("owner_agent_label", "owner_agent_label TEXT");
|
|
1278
|
+
addTaskCol("dispatch", "dispatch TEXT");
|
|
1279
|
+
addTaskCol("reaped_at", "reaped_at INTEGER");
|
|
1280
|
+
// #1535 WS2 — tags[] (JSON array of strings) + priority. Additive/idempotent, same
|
|
1281
|
+
// addTaskCol guard as the rest of the #834 batch: existing rows read back as absent.
|
|
1282
|
+
addTaskCol("tags", "tags TEXT");
|
|
1283
|
+
addTaskCol("priority", "priority TEXT");
|
|
1284
|
+
// #1535 WS1 — parent/epic tree edge. Self-referential FK via ALTER TABLE ADD COLUMN is
|
|
1285
|
+
// proven safe in this codebase already (messages.reply_to above); cycle-guarding lives
|
|
1286
|
+
// in application code (task-entity.ts), not a DB constraint.
|
|
1287
|
+
addTaskCol("parent_task_id", "parent_task_id INTEGER REFERENCES tasks(id) ON DELETE SET NULL");
|
|
1288
|
+
// #1535 WS3 — backlog lifecycle axis (backlog|promoted). Additive/idempotent, same guard as
|
|
1289
|
+
// the tags/priority/parent batch above; existing rows read back as NULL (not backlog-managed).
|
|
1290
|
+
addTaskCol("backlog_state", "backlog_state TEXT");
|
|
1291
|
+
// #2518 — coordinator review-hold (temporary landBlocked). Additive/idempotent; the
|
|
1292
|
+
// NOT NULL DEFAULT 0 migration preserves every pre-existing Task as UNHELD, so no legacy
|
|
1293
|
+
// delivery behavior changes until a coordinator explicitly sets the hold.
|
|
1294
|
+
addTaskCol("review_hold", "review_hold INTEGER NOT NULL DEFAULT 0 CHECK (review_hold IN (0, 1))");
|
|
1295
|
+
addTaskCol("validation_items", "validation_items TEXT");
|
|
1296
|
+
addTaskCol("terminal_stage", "terminal_stage TEXT");
|
|
1297
|
+
addTaskCol("completed_at", "completed_at INTEGER");
|
|
1298
|
+
addTaskCol("owner", "owner TEXT"); // #2862 — backfilled by backfillTaskOwners below
|
|
1299
|
+
migratePlanBlurbsOnStartup(); // #2082 S5 — fold legacy bound-node blurbs before stripping them
|
|
1300
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_tasks_message_status ON tasks(message_id, status) WHERE message_id IS NOT NULL");
|
|
1301
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_tasks_kind ON tasks(kind, status, updated_at)");
|
|
1302
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_tasks_branch ON tasks(branch) WHERE branch IS NOT NULL");
|
|
1303
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_tasks_team ON tasks(team_id) WHERE team_id IS NOT NULL");
|
|
1304
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_tasks_owner ON tasks(owner) WHERE owner IS NOT NULL");
|
|
1305
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_tasks_assignee ON tasks(owner_agent_id, updated_at) WHERE owner_agent_id IS NOT NULL");
|
|
1306
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_tasks_project ON tasks(project_id, status, updated_at) WHERE project_id IS NOT NULL");
|
|
1307
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_tasks_repo ON tasks(repo, status, updated_at) WHERE repo IS NOT NULL");
|
|
1308
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_tasks_priority ON tasks(priority, status, updated_at) WHERE priority IS NOT NULL");
|
|
1309
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_tasks_parent ON tasks(parent_task_id) WHERE parent_task_id IS NOT NULL");
|
|
1310
|
+
// #1535 WS3 — the per-project prioritized backlog query filters on backlog_state and orders by
|
|
1311
|
+
// priority,updated: a partial index over the backlog-managed rows keyed to that access path.
|
|
1312
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_tasks_backlog ON tasks(backlog_state, project_id, priority, updated_at) WHERE backlog_state IS NOT NULL");
|
|
1313
|
+
// #1355 — permanent land attribution must outlive ephemeral worker/workspace rows.
|
|
1314
|
+
// No foreign keys by design: retention may delete those source rows at any time.
|
|
1315
|
+
getDb().run(`
|
|
1316
|
+
CREATE TABLE IF NOT EXISTS landing_receipts (
|
|
1317
|
+
id TEXT PRIMARY KEY,
|
|
1318
|
+
project_id TEXT,
|
|
1319
|
+
repo TEXT NOT NULL,
|
|
1320
|
+
ref TEXT NOT NULL,
|
|
1321
|
+
branch TEXT,
|
|
1322
|
+
base_sha TEXT,
|
|
1323
|
+
tip_sha TEXT,
|
|
1324
|
+
commit_shas TEXT NOT NULL CHECK (json_valid(commit_shas) AND json_type(commit_shas) = 'array'),
|
|
1325
|
+
workspace_id TEXT NOT NULL,
|
|
1326
|
+
task_id INTEGER,
|
|
1327
|
+
worker_agent_id TEXT,
|
|
1328
|
+
coordinator_agent_id TEXT,
|
|
1329
|
+
team_id TEXT,
|
|
1330
|
+
orchestrator_id TEXT,
|
|
1331
|
+
host TEXT,
|
|
1332
|
+
landed_at INTEGER NOT NULL
|
|
1333
|
+
)
|
|
1334
|
+
`);
|
|
1335
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_landing_receipts_repo_tip ON landing_receipts(repo, tip_sha)");
|
|
1336
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_landing_receipts_repo_landed ON landing_receipts(repo, landed_at)");
|
|
1337
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_landing_receipts_task ON landing_receipts(task_id) WHERE task_id IS NOT NULL");
|
|
1338
|
+
|
|
1339
|
+
// #1355 U3 — existing relay databases need the CI incident core too. Additive
|
|
1340
|
+
// and independently idempotent, same shape as the fresh-DB bootstrap in
|
|
1341
|
+
// schema.ts. The two partial unique indexes are the durable lease: SQLite
|
|
1342
|
+
// itself rejects a second non-resolved row for the same watch (or the same
|
|
1343
|
+
// watch+fingerprint pair).
|
|
1344
|
+
getDb().run(`
|
|
1345
|
+
CREATE TABLE IF NOT EXISTS ci_watch_state (
|
|
1346
|
+
watch_key TEXT PRIMARY KEY,
|
|
1347
|
+
provider TEXT NOT NULL,
|
|
1348
|
+
repository TEXT NOT NULL,
|
|
1349
|
+
branch TEXT NOT NULL,
|
|
1350
|
+
workflow TEXT NOT NULL,
|
|
1351
|
+
status TEXT NOT NULL CHECK (status IN ('green', 'failing', 'cancelled', 'pending', 'missing')),
|
|
1352
|
+
head_sha TEXT NOT NULL,
|
|
1353
|
+
observed_at INTEGER NOT NULL,
|
|
1354
|
+
updated_at INTEGER NOT NULL
|
|
1355
|
+
)
|
|
1356
|
+
`);
|
|
1357
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_ci_watch_state_repo ON ci_watch_state(repository, branch, workflow)");
|
|
1358
|
+
|
|
1359
|
+
// #1609 — never-matched watch visibility, additive to existing ci_watch_state rows.
|
|
1360
|
+
const ciWatchStateCols = getDb().query("PRAGMA table_info(ci_watch_state)").all() as any[];
|
|
1361
|
+
const ciWatchStateColNames = ciWatchStateCols.map((c: any) => c.name);
|
|
1362
|
+
if (!ciWatchStateColNames.includes("first_seen_at")) {
|
|
1363
|
+
getDb().run("ALTER TABLE ci_watch_state ADD COLUMN first_seen_at INTEGER NOT NULL DEFAULT 0");
|
|
1364
|
+
// Backfill: treat every pre-existing row as already seen at its last observation, so an
|
|
1365
|
+
// upgrade never retroactively starts a fresh never-matched grace window for a watch that
|
|
1366
|
+
// already has real history.
|
|
1367
|
+
getDb().run("UPDATE ci_watch_state SET first_seen_at = observed_at WHERE first_seen_at = 0");
|
|
1368
|
+
}
|
|
1369
|
+
const hadHasMatched = ciWatchStateColNames.includes("has_matched");
|
|
1370
|
+
if (!hadHasMatched) {
|
|
1371
|
+
getDb().run("ALTER TABLE ci_watch_state ADD COLUMN has_matched INTEGER NOT NULL DEFAULT 0");
|
|
1372
|
+
}
|
|
1373
|
+
if (!ciWatchStateColNames.includes("never_matched_notified_at")) {
|
|
1374
|
+
getDb().run("ALTER TABLE ci_watch_state ADD COLUMN never_matched_notified_at INTEGER");
|
|
1375
|
+
}
|
|
1376
|
+
if (!ciWatchStateColNames.includes("config_mismatch_notified_at")) {
|
|
1377
|
+
getDb().run("ALTER TABLE ci_watch_state ADD COLUMN config_mismatch_notified_at INTEGER");
|
|
1378
|
+
}
|
|
1379
|
+
if (!ciWatchStateColNames.includes("root_missing_notified_at")) {
|
|
1380
|
+
getDb().run("ALTER TABLE ci_watch_state ADD COLUMN root_missing_notified_at INTEGER");
|
|
1381
|
+
}
|
|
1382
|
+
if (!hadHasMatched) {
|
|
1383
|
+
getDb().run("UPDATE ci_watch_state SET has_matched = 1 WHERE status != 'missing'");
|
|
1384
|
+
}
|
|
1385
|
+
// #1682 — #1616 originally put this inside the `has_matched` ALTER branch, leaving rows on a
|
|
1386
|
+
// database that had already received #1609 with a null fire-once guard. Those rows false-page
|
|
1387
|
+
// on the first post-deploy poll, so seed every still-unseeded pre-existing missing row here.
|
|
1388
|
+
getDb().run("UPDATE ci_watch_state SET never_matched_notified_at = updated_at WHERE has_matched = 0 AND never_matched_notified_at IS NULL");
|
|
1389
|
+
|
|
1390
|
+
getDb().run(`
|
|
1391
|
+
CREATE TABLE IF NOT EXISTS ci_incidents (
|
|
1392
|
+
id TEXT PRIMARY KEY,
|
|
1393
|
+
watch_key TEXT NOT NULL,
|
|
1394
|
+
provider TEXT NOT NULL,
|
|
1395
|
+
repository TEXT NOT NULL,
|
|
1396
|
+
branch TEXT NOT NULL,
|
|
1397
|
+
workflow TEXT NOT NULL,
|
|
1398
|
+
fingerprint TEXT NOT NULL,
|
|
1399
|
+
state TEXT NOT NULL CHECK (state IN ('detected', 'attributed', 'notified', 'steward_attempting', 'escalated', 'resolved')),
|
|
1400
|
+
attempt INTEGER NOT NULL DEFAULT 0 CHECK (attempt >= 0),
|
|
1401
|
+
opened_at INTEGER NOT NULL,
|
|
1402
|
+
opened_head_sha TEXT NOT NULL,
|
|
1403
|
+
opened_conclusion TEXT,
|
|
1404
|
+
coordinator_agent_id TEXT,
|
|
1405
|
+
escalated_at INTEGER,
|
|
1406
|
+
escalation_reason TEXT,
|
|
1407
|
+
resolved_at INTEGER,
|
|
1408
|
+
resolved_head_sha TEXT,
|
|
1409
|
+
resolution TEXT,
|
|
1410
|
+
lease_owner TEXT,
|
|
1411
|
+
lease_token TEXT,
|
|
1412
|
+
lease_acquired_at INTEGER,
|
|
1413
|
+
lease_expires_at INTEGER,
|
|
1414
|
+
created_at INTEGER NOT NULL,
|
|
1415
|
+
updated_at INTEGER NOT NULL,
|
|
1416
|
+
CHECK ((state = 'resolved') = (resolved_at IS NOT NULL)),
|
|
1417
|
+
CHECK (
|
|
1418
|
+
(lease_owner IS NULL AND lease_token IS NULL AND lease_acquired_at IS NULL AND lease_expires_at IS NULL)
|
|
1419
|
+
OR
|
|
1420
|
+
(lease_owner IS NOT NULL AND lease_token IS NOT NULL AND lease_acquired_at IS NOT NULL AND lease_expires_at > lease_acquired_at)
|
|
1421
|
+
)
|
|
1422
|
+
)
|
|
1423
|
+
`);
|
|
1424
|
+
getDb().run("CREATE UNIQUE INDEX IF NOT EXISTS idx_ci_incidents_active_watch ON ci_incidents(watch_key) WHERE state != 'resolved'");
|
|
1425
|
+
getDb().run("CREATE UNIQUE INDEX IF NOT EXISTS idx_ci_incidents_active_fingerprint ON ci_incidents(watch_key, fingerprint) WHERE state != 'resolved'");
|
|
1426
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_ci_incidents_repo ON ci_incidents(repository, branch, workflow, state)");
|
|
1427
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_ci_incidents_lease ON ci_incidents(state, lease_expires_at) WHERE lease_owner IS NOT NULL");
|
|
1428
|
+
|
|
1429
|
+
getDb().run(`
|
|
1430
|
+
UPDATE tasks
|
|
1431
|
+
SET repo = (
|
|
1432
|
+
SELECT ir.repo
|
|
1433
|
+
FROM issue_associations ia
|
|
1434
|
+
JOIN issue_refs ir ON ir.id = ia.issue_ref_id
|
|
1435
|
+
WHERE ia.entity_type = 'task' AND ia.entity_id = CAST(tasks.id AS TEXT)
|
|
1436
|
+
ORDER BY ia.created_at ASC, ir.id ASC
|
|
1437
|
+
LIMIT 1
|
|
1438
|
+
)
|
|
1439
|
+
WHERE kind = 'deliverable'
|
|
1440
|
+
AND (repo IS NULL OR trim(repo) = '')
|
|
1441
|
+
AND EXISTS (
|
|
1442
|
+
SELECT 1 FROM issue_associations ia
|
|
1443
|
+
JOIN issue_refs ir ON ir.id = ia.issue_ref_id
|
|
1444
|
+
WHERE ia.entity_type = 'task' AND ia.entity_id = CAST(tasks.id AS TEXT)
|
|
1445
|
+
)
|
|
1446
|
+
`);
|
|
1447
|
+
getDb().run(`
|
|
1448
|
+
UPDATE tasks
|
|
1449
|
+
SET project_id = (
|
|
1450
|
+
SELECT p.id
|
|
1451
|
+
FROM projects p
|
|
1452
|
+
WHERE p.scope = 'project' AND p.issue_repo = tasks.repo
|
|
1453
|
+
ORDER BY p.created_at ASC, p.id ASC
|
|
1454
|
+
LIMIT 1
|
|
1455
|
+
)
|
|
1456
|
+
WHERE kind = 'deliverable'
|
|
1457
|
+
AND (project_id IS NULL OR trim(project_id) = '')
|
|
1458
|
+
AND repo IS NOT NULL AND trim(repo) <> ''
|
|
1459
|
+
AND EXISTS (
|
|
1460
|
+
SELECT 1 FROM projects p
|
|
1461
|
+
WHERE p.scope = 'project' AND p.issue_repo = tasks.repo
|
|
1462
|
+
)
|
|
1463
|
+
`);
|
|
1464
|
+
|
|
1465
|
+
getDb().run(`
|
|
1466
|
+
CREATE TABLE IF NOT EXISTS task_dependencies (
|
|
1467
|
+
task_id INTEGER NOT NULL REFERENCES tasks(id) ON DELETE CASCADE,
|
|
1468
|
+
depends_on_task_id INTEGER NOT NULL REFERENCES tasks(id) ON DELETE CASCADE,
|
|
1469
|
+
created_at INTEGER NOT NULL,
|
|
1470
|
+
PRIMARY KEY (task_id, depends_on_task_id)
|
|
1471
|
+
)
|
|
1472
|
+
`);
|
|
1473
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_task_dependencies_depended ON task_dependencies(depends_on_task_id)");
|
|
1474
|
+
// #3692 — per-edge required stage; NULL keeps the original meaning (landed-on-main).
|
|
1475
|
+
if (!(getDb().query("PRAGMA table_info(task_dependencies)").all() as Array<{ name: string }>).some((c) => c.name === "required_stage")) getDb().run("ALTER TABLE task_dependencies ADD COLUMN required_stage TEXT CHECK (required_stage IN ('landed-on-main','deployed'))");
|
|
1476
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_task_events_task_type ON task_events(task_id, type, id DESC)");
|
|
1477
|
+
|
|
1478
|
+
// #1275 — existing relay databases need the fleet deploy ledger too. Keep this
|
|
1479
|
+
// additive and independently idempotent: a failed/partial deploy must survive
|
|
1480
|
+
// restarts instead of being inferred from ephemeral orchestrator activity.
|
|
1481
|
+
getDb().run(`
|
|
1482
|
+
CREATE TABLE IF NOT EXISTS deploy_events (
|
|
1483
|
+
id TEXT PRIMARY KEY,
|
|
1484
|
+
commit_sha TEXT NOT NULL,
|
|
1485
|
+
version TEXT,
|
|
1486
|
+
hosts TEXT NOT NULL,
|
|
1487
|
+
status TEXT NOT NULL CHECK (status IN ('pending', 'succeeded', 'failed', 'rolled-back')),
|
|
1488
|
+
initiated_by TEXT NOT NULL,
|
|
1489
|
+
started_at INTEGER NOT NULL,
|
|
1490
|
+
finished_at INTEGER
|
|
1491
|
+
)
|
|
1492
|
+
`);
|
|
1493
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_deploy_events_commit ON deploy_events(commit_sha, started_at DESC)");
|
|
1494
|
+
// #1744 / Phase -1 F1 — existing relay databases need the tree-keyed land-gate attestation store
|
|
1495
|
+
// that lets cd-watcher deploy a landed tree without waiting for main's redundant ci.yml re-run.
|
|
1496
|
+
// Purely additive: with the table empty (or absent on an older binary) every deploy decision falls
|
|
1497
|
+
// back to the pre-existing green-ci.yml path, which is the fail-closed default.
|
|
1498
|
+
getDb().run(`
|
|
1499
|
+
CREATE TABLE IF NOT EXISTS land_gate_attestations (
|
|
1500
|
+
repo TEXT NOT NULL,
|
|
1501
|
+
tree_sha TEXT NOT NULL,
|
|
1502
|
+
commit_sha TEXT NOT NULL,
|
|
1503
|
+
base_ref TEXT NOT NULL,
|
|
1504
|
+
level TEXT NOT NULL CHECK (level IN ('full')),
|
|
1505
|
+
gates_digest TEXT NOT NULL,
|
|
1506
|
+
gate_names TEXT NOT NULL CHECK (json_valid(gate_names) AND json_type(gate_names) = 'array'),
|
|
1507
|
+
gates_ran INTEGER NOT NULL,
|
|
1508
|
+
workspace_id TEXT,
|
|
1509
|
+
attested_at INTEGER NOT NULL,
|
|
1510
|
+
PRIMARY KEY (repo, tree_sha)
|
|
1511
|
+
)
|
|
1512
|
+
`);
|
|
1513
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_land_gate_attestations_attested ON land_gate_attestations(attested_at)");
|
|
1514
|
+
// #3362 — NULL is a pre-S1 attestation, which only a full land gate produced.
|
|
1515
|
+
if (!(getDb().query("PRAGMA table_info(land_gate_attestations)").all() as Array<{ name: string }>).some((col) => col.name === "suite_coverage")) {
|
|
1516
|
+
getDb().run("ALTER TABLE land_gate_attestations ADD COLUMN suite_coverage TEXT CHECK (suite_coverage IN ('full', 'partial'))");
|
|
1517
|
+
}
|
|
1518
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_land_gate_attestations_partial_commit ON land_gate_attestations(repo, commit_sha) WHERE suite_coverage = 'partial'");
|
|
1519
|
+
// #1281 — repair historical duplicate pending rows before imposing the
|
|
1520
|
+
// fleet-wide deploy lease invariant.
|
|
1521
|
+
getDb().run(`UPDATE deploy_events SET status = 'failed', finished_at = COALESCE(finished_at, started_at)
|
|
1522
|
+
WHERE status = 'pending' AND id NOT IN (
|
|
1523
|
+
SELECT id FROM deploy_events WHERE status = 'pending' ORDER BY started_at DESC LIMIT 1
|
|
1524
|
+
)`);
|
|
1525
|
+
getDb().run("CREATE UNIQUE INDEX IF NOT EXISTS idx_deploy_events_single_pending ON deploy_events(status) WHERE status = 'pending'");
|
|
1526
|
+
// #1327 — additive column for existing DBs; deploy history reconstructs "what changed" from it.
|
|
1527
|
+
const deployEventsColNames = (getDb().query("PRAGMA table_info(deploy_events)").all() as any[]).map((c: any) => c.name);
|
|
1528
|
+
if (!deployEventsColNames.includes("previous_sha")) {
|
|
1529
|
+
getDb().run("ALTER TABLE deploy_events ADD COLUMN previous_sha TEXT");
|
|
1530
|
+
}
|
|
1531
|
+
// #1799 — durable, range-keyed deploy attribution. Existing successful rows are
|
|
1532
|
+
// deliberately left NULL for the detached cd-watcher's bounded backfill.
|
|
1533
|
+
if (!deployEventsColNames.includes("changes_summary")) {
|
|
1534
|
+
getDb().run("ALTER TABLE deploy_events ADD COLUMN changes_summary TEXT");
|
|
1535
|
+
}
|
|
1536
|
+
// #2105 — the deploy driver's process identity, so a stranded `pending` row can be reclaimed on
|
|
1537
|
+
// EXECUTOR LIVENESS instead of waiting out the 2h lease. Nullable and additive: rows written by an
|
|
1538
|
+
// older driver (and the window before the driver records itself) simply have no executor, and the
|
|
1539
|
+
// reconcile degrades to the pre-existing lease-TTL backstop.
|
|
1540
|
+
if (!deployEventsColNames.includes("executor")) getDb().run("ALTER TABLE deploy_events ADD COLUMN executor TEXT");
|
|
1541
|
+
// #2359 — `started_at` is immutable audit history. Older code reused it as the renewable lease
|
|
1542
|
+
// clock, hiding five minutes from every long deploy shown in the dashboard.
|
|
1543
|
+
if (!deployEventsColNames.includes("lease_renewed_at")) getDb().run("ALTER TABLE deploy_events ADD COLUMN lease_renewed_at INTEGER");
|
|
1544
|
+
|
|
1545
|
+
// #833 — comment-through idempotency outbox (reserve→post→finalize). Existing DBs gain
|
|
1546
|
+
// the table here; the UNIQUE claim is what makes the write-through concurrency/crash-safe.
|
|
1547
|
+
getDb().run(`
|
|
1548
|
+
CREATE TABLE IF NOT EXISTS task_comment_throughs (
|
|
1549
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
1550
|
+
task_id INTEGER NOT NULL REFERENCES tasks(id) ON DELETE CASCADE,
|
|
1551
|
+
kind TEXT NOT NULL,
|
|
1552
|
+
idempotency_key TEXT NOT NULL,
|
|
1553
|
+
status TEXT NOT NULL,
|
|
1554
|
+
event_id INTEGER,
|
|
1555
|
+
created_at INTEGER NOT NULL,
|
|
1556
|
+
updated_at INTEGER NOT NULL,
|
|
1557
|
+
UNIQUE (task_id, kind, idempotency_key)
|
|
1558
|
+
)
|
|
1559
|
+
`);
|
|
1560
|
+
|
|
1561
|
+
// #1452 round-4/round-5 — durable review-ref lifecycle ledger. Schema + its round-5 id-keyed
|
|
1562
|
+
// migration live in the domain module (per epic #291), next to its accessors.
|
|
1563
|
+
ensureReviewRefCleanupsSchema();
|
|
1564
|
+
|
|
1565
|
+
// #834 — issue_associations.entity_type gained 'task'. The CHECK constraint is baked into
|
|
1566
|
+
// the table SQL, so a TS-only enum change would fail at runtime; rebuild the table (SQLite
|
|
1567
|
+
// can't ALTER a CHECK). Guarded on the absence of 'task' in the stored DDL so it runs once.
|
|
1568
|
+
const issueAssocSql = (getDb().query("SELECT sql FROM sqlite_master WHERE type = 'table' AND name = 'issue_associations'").get() as { sql?: string } | undefined)?.sql;
|
|
1569
|
+
if (issueAssocSql && !issueAssocSql.includes("'task'")) {
|
|
1570
|
+
getDb().transaction(() => {
|
|
1571
|
+
getDb().run("ALTER TABLE issue_associations RENAME TO issue_associations_old");
|
|
1572
|
+
getDb().run(`
|
|
1573
|
+
CREATE TABLE issue_associations (
|
|
1574
|
+
issue_ref_id TEXT NOT NULL REFERENCES issue_refs(id) ON DELETE CASCADE,
|
|
1575
|
+
entity_type TEXT NOT NULL CHECK (entity_type IN ('team', 'plan-node', 'epic', 'task')),
|
|
1576
|
+
entity_id TEXT NOT NULL,
|
|
1577
|
+
created_at INTEGER NOT NULL,
|
|
1578
|
+
PRIMARY KEY (issue_ref_id, entity_type, entity_id)
|
|
1579
|
+
)
|
|
1580
|
+
`);
|
|
1581
|
+
getDb().run(`
|
|
1582
|
+
INSERT INTO issue_associations (issue_ref_id, entity_type, entity_id, created_at)
|
|
1583
|
+
SELECT issue_ref_id, entity_type, entity_id, created_at FROM issue_associations_old
|
|
1584
|
+
`);
|
|
1585
|
+
getDb().run("DROP TABLE issue_associations_old");
|
|
1586
|
+
})();
|
|
1587
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_issue_associations_entity ON issue_associations(entity_type, entity_id, created_at DESC)");
|
|
1588
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_issue_associations_issue ON issue_associations(issue_ref_id, created_at DESC)");
|
|
1589
|
+
}
|
|
1590
|
+
|
|
1591
|
+
ensureIssueAssociationRelationSchema();
|
|
1592
|
+
// #846 — drop the superseded single-column indexes so the planner is forced to
|
|
1593
|
+
// choose the composite replacements (idx_msg_to_id / idx_msg_resolved_to_id).
|
|
1594
|
+
// When both old and new exist the planner may prefer the old single-column index,
|
|
1595
|
+
// silently defeating the ORDER BY id optimisation. DROP INDEX IF EXISTS is
|
|
1596
|
+
// idempotent and safe on any populated DB. Guard ANALYZE on the presence of the
|
|
1597
|
+
// old idx_msg_to: it exists on pre-#846 DBs and is absent once this block has run,
|
|
1598
|
+
// so ANALYZE executes exactly once per DB (on first boot with the new code).
|
|
1599
|
+
// Fresh DBs never create idx_msg_to (removed from base schema), so the guard is
|
|
1600
|
+
// false and ANALYZE is skipped (the first-boot `if (!hasStats)` path in initDb
|
|
1601
|
+
// covers fresh DBs instead).
|
|
1602
|
+
const hasOldToIdx = !!getDb()
|
|
1603
|
+
.query("SELECT 1 FROM sqlite_master WHERE type='index' AND name='idx_msg_to'")
|
|
1604
|
+
.get();
|
|
1605
|
+
getDb().run("DROP INDEX IF EXISTS idx_msg_to");
|
|
1606
|
+
getDb().run("DROP INDEX IF EXISTS idx_msg_resolved_to_agent"); getDb().run("CREATE INDEX IF NOT EXISTS idx_commands_target_updated ON commands(target, updated_at DESC, created_at DESC)"); const commandColNames = (getDb().query("PRAGMA table_info(commands)").all() as Array<{ name: string }>).map((col) => col.name); if (!commandColNames.includes("claim_owner_token")) getDb().run("ALTER TABLE commands ADD COLUMN claim_owner_token TEXT"); getDb().run("CREATE INDEX IF NOT EXISTS idx_commands_claim_recovery ON commands(target, status, claim_owner_token)"); // #1811 ambiguous-claim recovery
|
|
1607
|
+
// T4060 (#2289) — partial index for the scheduler-restart reconcile's awaiting-wake scan
|
|
1608
|
+
// (target + error over failed scheduler.commands only). Idempotent; existing DBs (incl. the
|
|
1609
|
+
// 4.5GB prod hub) build it once at startup. Base schema covers fresh DBs (schema.ts).
|
|
1610
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_commands_scheduler_recovery ON commands(target, error) WHERE type = 'scheduler.command' AND status = 'failed'");
|
|
1611
|
+
// Build once, pre-bind on fresh and upgraded DBs, with the actual build timed (#3063).
|
|
1612
|
+
timeStartupPhase("db.index.commands-target-type", () => getDb().run("CREATE INDEX IF NOT EXISTS idx_commands_target_type_created ON commands(target, type, created_at DESC, id DESC)"));
|
|
1613
|
+
timeStartupPhase("db.index.spawn-request", () => getDb().run("CREATE INDEX IF NOT EXISTS idx_commands_spawn_request ON commands(json_extract(params, '$.spawnRequestId')) WHERE type = 'agent.spawn' AND json_valid(params)"));
|
|
1614
|
+
timeStartupPhase("db.index.spawn-resume-branch", () => getDb().run("CREATE INDEX IF NOT EXISTS idx_commands_spawn_resume_branch ON commands(json_extract(params, '$.resumeWorkspace.branch')) WHERE type = 'agent.spawn' AND json_valid(params) AND json_extract(params, '$.resumeWorkspace.branch') IS NOT NULL")); // #3011 reviewer-by-branch link
|
|
1615
|
+
timeStartupPhase("db.index.restart-spawn-request", () => getDb().run("CREATE INDEX IF NOT EXISTS idx_commands_restart_spawn_request ON commands(json_extract(params, '$.restartSpawn.spawnRequestId')) WHERE type IN ('agent.restart', 'agent.resume') AND json_valid(params)")); // #2950 H3
|
|
1616
|
+
timeStartupPhase("db.index.relaunch-agent", () => getDb().run("CREATE INDEX IF NOT EXISTS idx_commands_relaunch_agent ON commands(json_extract(params, '$.agentId')) WHERE type IN ('agent.restart', 'agent.resume') AND json_valid(params)")); // #2712 launch lookup by agent
|
|
1617
|
+
// T4060 (#2289) — composite index serving the project-entries active-only display
|
|
1618
|
+
// ORDER BY from the index, so the sort never visits a cell's ~95% retracted rows.
|
|
1619
|
+
// Idempotent; existing DBs build it once at startup. Base schema covers fresh DBs.
|
|
1620
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_project_entries_active_order ON project_entries(project_id, status, updated_at DESC, created_at DESC, id DESC)");
|
|
1621
|
+
installProjectEntrySearch(getDb());
|
|
1622
|
+
migrateBrokerMemories(getDb());
|
|
1623
|
+
if (hasOldToIdx) getDb().run("ANALYZE messages");
|
|
1624
|
+
|
|
1625
|
+
// #1645 — maintenance-job pause storage, and the one-time conversion of any pre-existing
|
|
1626
|
+
// hand-written `UPDATE maintenance_jobs SET enabled=0` into an explicit indefinite pause row.
|
|
1627
|
+
//
|
|
1628
|
+
// ORDER IS LOAD-BEARING. `ensureMaintenanceJobs()` (src/maintenance/scheduler.ts) now re-asserts
|
|
1629
|
+
// `enabled` from `definitions` on every reconcile, which is what makes a manual disable
|
|
1630
|
+
// recoverable instead of permanent. That reconcile runs when the scheduler starts — after
|
|
1631
|
+
// migrations — so this conversion MUST happen here, before it. Landing the upsert change without
|
|
1632
|
+
// this conversion would silently re-enable a job an operator had deliberately stopped.
|
|
1633
|
+
const maintenanceJobCols = (getDb().query("PRAGMA table_info(maintenance_jobs)").all() as Array<{ name: string }>).map((c) => c.name);
|
|
1634
|
+
if (!maintenanceJobCols.includes("critical")) {
|
|
1635
|
+
getDb().run("ALTER TABLE maintenance_jobs ADD COLUMN critical INTEGER NOT NULL DEFAULT 0");
|
|
1636
|
+
}
|
|
1637
|
+
// #1725 P1 — measured per-run synchronous block time (loop occupancy), distinct from the
|
|
1638
|
+
// wall-clock last_duration_ms. Additive/idempotent; existing rows read back NULL until they run.
|
|
1639
|
+
if (!maintenanceJobCols.includes("last_block_ms")) {
|
|
1640
|
+
getDb().run("ALTER TABLE maintenance_jobs ADD COLUMN last_block_ms INTEGER");
|
|
1641
|
+
}
|
|
1642
|
+
// #2317 — deliberately leave existing rows NULL: an upgraded process cannot honestly infer
|
|
1643
|
+
// whether a pre-upgrade run is still making progress, and recovery must fail toward retaining it.
|
|
1644
|
+
if (!maintenanceJobCols.includes("run_token")) {
|
|
1645
|
+
getDb().run("ALTER TABLE maintenance_jobs ADD COLUMN run_token TEXT");
|
|
1646
|
+
}
|
|
1647
|
+
if (!maintenanceJobCols.includes("last_progress_at")) {
|
|
1648
|
+
getDb().run("ALTER TABLE maintenance_jobs ADD COLUMN last_progress_at INTEGER");
|
|
1649
|
+
}
|
|
1650
|
+
ensureMaintenanceJobPauseSchema(); convertManualJobDisablesToPauses();
|
|
1651
|
+
|
|
1652
|
+
// RFC 0001 / S4 §6 — dedicated durable-workflow replay storage. This is
|
|
1653
|
+
// intentionally not bus_outbox: message-bus pruning must never erase an open
|
|
1654
|
+
// instance's execution history. The ensure also rebuilds the original cascading
|
|
1655
|
+
// journal FK so direct parent deletes cannot erase an open replay history.
|
|
1656
|
+
getDb().run(PLAN_DISPATCH_SCHEMA_SQL);
|
|
1657
|
+
ensureWorkflowJournalSchema();
|
|
1658
|
+
|
|
1659
|
+
// KAPI-1 W4c fix 3b — the kernel event log (`kernel_events` / `kernel_event_scope_seq`) is
|
|
1660
|
+
// created at STARTUP alongside the workflow journal, so a lazily-built control host (the
|
|
1661
|
+
// `/api/kernel` mount + the `relay_kernel_*` MCP binding) never runs request-time DDL on an
|
|
1662
|
+
// unauthorized first call. Idempotent against the shared prod schema.
|
|
1663
|
+
ensureKernelEventLogSchema();
|
|
1664
|
+
|
|
1665
|
+
// Kernel timers MESSAGE-authority flip catalog (through Stage 8): dormant until an audited action.
|
|
1666
|
+
installTimerMessageFlipSchema(); ensureProviderFlapMessagesIndex();
|
|
1667
|
+
|
|
1668
|
+
// #1538 — send-layer dead-letter ledger for the fire-outbox. Created alongside (but OUTSIDE) the
|
|
1669
|
+
// flip catalog: it tracks per-fire send attempts so a permanently un-sendable fire dead-letters
|
|
1670
|
+
// and leaves `listPending`, instead of re-failing every drain tick and flooding the logs.
|
|
1671
|
+
ensureTimerMessageFireDeadLetterSchema();
|
|
1672
|
+
ensureSqlAuditIndexes(); ensureMaintenanceIndexes(); ensureDurablePayloadSchema(); // #1725 indexes; ADR 0001 §3.7.1 dedup ledger (#3704 hour-slot layout)
|
|
1673
|
+
|
|
1674
|
+
retireMemoryStorage(getDb());
|
|
1675
|
+
|
|
1676
|
+
// #2591 — the structured project journal tables, installed for upgraded databases.
|
|
1677
|
+
// Byte-identical to the fresh-DB catalog DDL in src/db/schema.ts (schema-parity asserted
|
|
1678
|
+
// by migrations.test).
|
|
1679
|
+
getDb().run(`
|
|
1680
|
+
CREATE TABLE IF NOT EXISTS project_journal (
|
|
1681
|
+
id TEXT PRIMARY KEY,
|
|
1682
|
+
project_id TEXT NOT NULL,
|
|
1683
|
+
profile TEXT NOT NULL,
|
|
1684
|
+
field TEXT NOT NULL,
|
|
1685
|
+
value TEXT NOT NULL,
|
|
1686
|
+
updated_at INTEGER NOT NULL,
|
|
1687
|
+
updated_by TEXT NOT NULL,
|
|
1688
|
+
UNIQUE(project_id, profile, field)
|
|
1689
|
+
)
|
|
1690
|
+
`);
|
|
1691
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_project_journal_scope ON project_journal(project_id, profile)");
|
|
1692
|
+
getDb().run(`
|
|
1693
|
+
CREATE TABLE IF NOT EXISTS project_journal_history (
|
|
1694
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
1695
|
+
project_id TEXT NOT NULL,
|
|
1696
|
+
profile TEXT NOT NULL,
|
|
1697
|
+
field TEXT NOT NULL,
|
|
1698
|
+
old_value TEXT,
|
|
1699
|
+
new_value TEXT,
|
|
1700
|
+
action TEXT NOT NULL,
|
|
1701
|
+
changed_at INTEGER NOT NULL,
|
|
1702
|
+
changed_by TEXT NOT NULL
|
|
1703
|
+
)
|
|
1704
|
+
`);
|
|
1705
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_project_journal_history_scope ON project_journal_history(project_id, profile, field)");
|
|
1706
|
+
|
|
1707
|
+
// #2485 — the durable token-usage ledger, installed for upgraded databases. Byte-identical to
|
|
1708
|
+
// the fresh-DB catalog DDL in src/db/schema.ts (schema-parity asserted by migrations.test).
|
|
1709
|
+
getDb().run(`
|
|
1710
|
+
CREATE TABLE IF NOT EXISTS session_token_usage (
|
|
1711
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
1712
|
+
agent_id TEXT NOT NULL,
|
|
1713
|
+
session_id TEXT NOT NULL,
|
|
1714
|
+
turn_id TEXT,
|
|
1715
|
+
provider TEXT NOT NULL,
|
|
1716
|
+
model TEXT NOT NULL,
|
|
1717
|
+
input_tokens INTEGER NOT NULL DEFAULT 0,
|
|
1718
|
+
output_tokens INTEGER NOT NULL DEFAULT 0,
|
|
1719
|
+
cache_read_tokens INTEGER NOT NULL DEFAULT 0,
|
|
1720
|
+
cache_write_tokens INTEGER NOT NULL DEFAULT 0,
|
|
1721
|
+
reasoning_output_tokens INTEGER,
|
|
1722
|
+
created_at INTEGER NOT NULL,
|
|
1723
|
+
dedupe_key TEXT NOT NULL
|
|
1724
|
+
)
|
|
1725
|
+
`);
|
|
1726
|
+
if (!(getDb().query("PRAGMA table_info(session_token_usage)").all() as Array<{ name: string }>).some((c) => c.name === "task_id")) {
|
|
1727
|
+
getDb().run("ALTER TABLE session_token_usage ADD COLUMN task_id INTEGER"); // #3011
|
|
1728
|
+
}
|
|
1729
|
+
if (!(getDb().query("PRAGMA table_info(session_token_usage)").all() as Array<{ name: string }>).some((c) => c.name === "subagent_id")) {
|
|
1730
|
+
getDb().run("ALTER TABLE session_token_usage ADD COLUMN subagent_id TEXT"); // #3241
|
|
1731
|
+
}
|
|
1732
|
+
if (!(getDb().query("PRAGMA table_info(session_token_usage)").all() as Array<{ name: string }>).some((c) => c.name === "usage_status")) {
|
|
1733
|
+
getDb().run("ALTER TABLE session_token_usage ADD COLUMN usage_status TEXT"); // #3351
|
|
1734
|
+
}
|
|
1735
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_session_token_usage_created ON session_token_usage(created_at)");
|
|
1736
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_session_token_usage_provider_time ON session_token_usage(provider, created_at)");
|
|
1737
|
+
getDb().run("CREATE UNIQUE INDEX IF NOT EXISTS idx_session_token_usage_dedupe ON session_token_usage(dedupe_key)");
|
|
1738
|
+
getDb().run("CREATE INDEX IF NOT EXISTS idx_session_token_usage_agent ON session_token_usage(agent_id)");
|
|
1739
|
+
getDb().run(CLAUDE_API_BUDGET_SCHEMA);
|
|
1740
|
+
getDb().run(CLAUDE_APP_OAUTH_SCHEMA);
|
|
1741
|
+
getDb().run(AGENT_EXIT_REPORT_SCHEMA);
|
|
1742
|
+
getDb().run(CONTEXT_RESET_SCHEMA); // #3398
|
|
1743
|
+
getDb().run(TASK_TOKEN_TOTALS_SCHEMA);
|
|
1744
|
+
getDb().run(SHIPPING_STATS_SCHEMA);
|
|
1745
|
+
getDb().run(CI_GATE_BACKFILL_SCHEMA); getDb().run(AGENT_GATE_RUNS_SCHEMA); ensureAgentGateCommandSchema(); repairRerunGateTimings(); ensureCiShaObservationsSchema();
|
|
1746
|
+
migrateOperatorActionsSchema();
|
|
1747
|
+
getDb().run(SELF_EFFORT_PERMISSIONS_SCHEMA);
|
|
1748
|
+
getDb().run(AGENT_EFFORT_STATE_SCHEMA);
|
|
1749
|
+
importLegacyEffortCommands();
|
|
1750
|
+
ensureArtifactCreatorAgentColumn(); // #2952
|
|
1751
|
+
ensureArtifactRetentionSchema();
|
|
1752
|
+
installAgentIdentityArchive();
|
|
1753
|
+
redactProviderConfigHistory(); finishSchema(); // #3540 — discard plaintext provider credentials from prior revisions
|
|
1754
|
+
timeStartupPhase("db.backfill.task-autoclose", migrateDeployedTaskBacklog);
|
|
1755
|
+
timeStartupPhase("db.backfill.task-shipped-blocked", migrateBlockedTaskBacklog);
|
|
1756
|
+
timeStartupPhase("db.backfill.task-owner", backfillTaskOwners);
|
|
1757
|
+
timeStartupPhase("db.backfill.team-project-seats", migrateTeamProjectSeats); // #3107
|
|
1758
|
+
timeStartupPhase("db.backfill.legacy-messages", backfillLegacyMessages);
|
|
1759
|
+
timeStartupPhase("db.backfill.history-delivery", () => installHistoryDeliverySettlement());
|
|
1760
|
+
timeStartupPhase("db.projection.reply-obligations", () => installReplyObligations());
|
|
1761
|
+
}
|