@cleocode/core 2026.5.134 → 2026.6.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/binaries/README.md +49 -27
- package/dist/agents/{agent-registry.d.ts → agent-capacity-tracker.d.ts} +2 -2
- package/dist/agents/agent-capacity-tracker.d.ts.map +1 -0
- package/dist/agents/{agent-registry.js → agent-capacity-tracker.js} +2 -2
- package/dist/agents/agent-capacity-tracker.js.map +1 -0
- package/dist/agents/index.d.ts +1 -1
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/index.js +4 -2
- package/dist/agents/index.js.map +1 -1
- package/dist/agents/seed-install.d.ts +1 -1
- package/dist/agents/seed-install.d.ts.map +1 -1
- package/dist/agents/seed-install.js +42 -36
- package/dist/agents/seed-install.js.map +1 -1
- package/dist/caamp-export.d.ts +18 -0
- package/dist/caamp-export.d.ts.map +1 -0
- package/dist/caamp-export.js +18 -0
- package/dist/caamp-export.js.map +1 -0
- package/dist/conduit/local-transport.d.ts +1 -1
- package/dist/conduit/local-transport.d.ts.map +1 -1
- package/dist/conduit/local-transport.js +69 -43
- package/dist/conduit/local-transport.js.map +1 -1
- package/dist/dispatch/mutate-projection.d.ts.map +1 -1
- package/dist/dispatch/mutate-projection.js +11 -0
- package/dist/dispatch/mutate-projection.js.map +1 -1
- package/dist/docs/docs-read-model.d.ts +7 -0
- package/dist/docs/docs-read-model.d.ts.map +1 -1
- package/dist/docs/docs-read-model.js +5 -0
- package/dist/docs/docs-read-model.js.map +1 -1
- package/dist/docs/supersede.d.ts.map +1 -1
- package/dist/docs/supersede.js +12 -7
- package/dist/docs/supersede.js.map +1 -1
- package/dist/doctor/db-substrate.d.ts.map +1 -1
- package/dist/doctor/db-substrate.js +10 -9
- package/dist/doctor/db-substrate.js.map +1 -1
- package/dist/git-shim-export.d.ts +18 -0
- package/dist/git-shim-export.d.ts.map +1 -0
- package/dist/git-shim-export.js +18 -0
- package/dist/git-shim-export.js.map +1 -0
- package/dist/hooks/payload-schemas.d.ts +2 -2
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +39 -32
- package/dist/init.js.map +1 -1
- package/dist/internal.d.ts +11 -3
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +14 -5
- package/dist/internal.js.map +1 -1
- package/dist/lafs-export.d.ts +18 -0
- package/dist/lafs-export.d.ts.map +1 -0
- package/dist/lafs-export.js +18 -0
- package/dist/lafs-export.js.map +1 -0
- package/dist/lifecycle/effective-stage.js +1 -1
- package/dist/lifecycle/index.js +1 -1
- package/dist/lifecycle/index.js.map +1 -1
- package/dist/lifecycle/rollup.js +1 -1
- package/dist/llm/credential-pool.d.ts +17 -0
- package/dist/llm/credential-pool.d.ts.map +1 -1
- package/dist/llm/credential-pool.js +40 -1
- package/dist/llm/credential-pool.js.map +1 -1
- package/dist/llm/plugin-facade.d.ts.map +1 -1
- package/dist/llm/plugin-facade.js +11 -19
- package/dist/llm/plugin-facade.js.map +1 -1
- package/dist/llm/role-executor.d.ts +8 -0
- package/dist/llm/role-executor.d.ts.map +1 -1
- package/dist/llm/role-executor.js +96 -4
- package/dist/llm/role-executor.js.map +1 -1
- package/dist/llm/role-resolver.d.ts.map +1 -1
- package/dist/llm/role-resolver.js +56 -1
- package/dist/llm/role-resolver.js.map +1 -1
- package/dist/llm/transports/codex-oauth-headers.d.ts +51 -0
- package/dist/llm/transports/codex-oauth-headers.d.ts.map +1 -0
- package/dist/llm/transports/codex-oauth-headers.js +89 -0
- package/dist/llm/transports/codex-oauth-headers.js.map +1 -0
- package/dist/memory/claude-mem-migration.d.ts.map +1 -1
- package/dist/memory/claude-mem-migration.js +1 -3
- package/dist/memory/claude-mem-migration.js.map +1 -1
- package/dist/memory/decisions.d.ts.map +1 -1
- package/dist/memory/decisions.js +77 -23
- package/dist/memory/decisions.js.map +1 -1
- package/dist/memory/graph-memory-bridge.d.ts.map +1 -1
- package/dist/memory/graph-memory-bridge.js +12 -6
- package/dist/memory/graph-memory-bridge.js.map +1 -1
- package/dist/memory/learnings.d.ts +2 -2
- package/dist/memory/nexus-plasticity.d.ts +21 -9
- package/dist/memory/nexus-plasticity.d.ts.map +1 -1
- package/dist/memory/nexus-plasticity.js +44 -22
- package/dist/memory/nexus-plasticity.js.map +1 -1
- package/dist/memory/patterns.d.ts +2 -2
- package/dist/memory/redaction.d.ts +19 -3
- package/dist/memory/redaction.d.ts.map +1 -1
- package/dist/memory/redaction.js +22 -94
- package/dist/memory/redaction.js.map +1 -1
- package/dist/metrics/token-service.d.ts +8 -2
- package/dist/metrics/token-service.d.ts.map +1 -1
- package/dist/metrics/token-service.js +1 -1
- package/dist/metrics/token-service.js.map +1 -1
- package/dist/nexus/analyze-orchestrator.d.ts.map +1 -1
- package/dist/nexus/analyze-orchestrator.js +6 -8
- package/dist/nexus/analyze-orchestrator.js.map +1 -1
- package/dist/nexus/api-extractors/http-extractor.d.ts.map +1 -1
- package/dist/nexus/api-extractors/http-extractor.js +3 -3
- package/dist/nexus/api-extractors/http-extractor.js.map +1 -1
- package/dist/nexus/clusters.d.ts.map +1 -1
- package/dist/nexus/clusters.js +3 -2
- package/dist/nexus/clusters.js.map +1 -1
- package/dist/nexus/context.d.ts.map +1 -1
- package/dist/nexus/context.js +10 -16
- package/dist/nexus/context.js.map +1 -1
- package/dist/nexus/diff.d.ts.map +1 -1
- package/dist/nexus/diff.js +6 -4
- package/dist/nexus/diff.js.map +1 -1
- package/dist/nexus/export.d.ts.map +1 -1
- package/dist/nexus/export.js +7 -4
- package/dist/nexus/export.js.map +1 -1
- package/dist/nexus/flows.d.ts.map +1 -1
- package/dist/nexus/flows.js +3 -1
- package/dist/nexus/flows.js.map +1 -1
- package/dist/nexus/impact.d.ts +1 -1
- package/dist/nexus/impact.d.ts.map +1 -1
- package/dist/nexus/impact.js +31 -17
- package/dist/nexus/impact.js.map +1 -1
- package/dist/nexus/living-brain.d.ts.map +1 -1
- package/dist/nexus/living-brain.js +27 -15
- package/dist/nexus/living-brain.js.map +1 -1
- package/dist/nexus/nexus-bridge.d.ts.map +1 -1
- package/dist/nexus/nexus-bridge.js +28 -29
- package/dist/nexus/nexus-bridge.js.map +1 -1
- package/dist/nexus/plasticity-queries.d.ts +4 -2
- package/dist/nexus/plasticity-queries.d.ts.map +1 -1
- package/dist/nexus/plasticity-queries.js +27 -15
- package/dist/nexus/plasticity-queries.js.map +1 -1
- package/dist/nexus/query.d.ts.map +1 -1
- package/dist/nexus/query.js +6 -2
- package/dist/nexus/query.js.map +1 -1
- package/dist/nexus/registry.d.ts.map +1 -1
- package/dist/nexus/registry.js +65 -30
- package/dist/nexus/registry.js.map +1 -1
- package/dist/nexus/route-analysis.d.ts +3 -2
- package/dist/nexus/route-analysis.d.ts.map +1 -1
- package/dist/nexus/route-analysis.js +11 -10
- package/dist/nexus/route-analysis.js.map +1 -1
- package/dist/nexus/sigil.d.ts.map +1 -1
- package/dist/nexus/sigil.js +60 -13
- package/dist/nexus/sigil.js.map +1 -1
- package/dist/nexus/user-profile.d.ts +2 -1
- package/dist/nexus/user-profile.d.ts.map +1 -1
- package/dist/nexus/user-profile.js +8 -4
- package/dist/nexus/user-profile.js.map +1 -1
- package/dist/orchestrate/index.d.ts +1 -1
- package/dist/orchestrate/index.d.ts.map +1 -1
- package/dist/orchestrate/index.js +1 -1
- package/dist/orchestrate/index.js.map +1 -1
- package/dist/orchestrate/plan.d.ts +3 -3
- package/dist/orchestrate/plan.d.ts.map +1 -1
- package/dist/orchestrate/plan.js +7 -7
- package/dist/orchestrate/plan.js.map +1 -1
- package/dist/orchestrate/spawn-ops.js +2 -2
- package/dist/orchestrate/spawn-ops.js.map +1 -1
- package/dist/orchestration/classify.d.ts +2 -2
- package/dist/orchestration/classify.js +3 -3
- package/dist/orchestration/classify.js.map +1 -1
- package/dist/orchestration/validate-spawn.d.ts.map +1 -1
- package/dist/orchestration/validate-spawn.js +5 -5
- package/dist/orchestration/validate-spawn.js.map +1 -1
- package/dist/paths-export.d.ts +18 -0
- package/dist/paths-export.d.ts.map +1 -0
- package/dist/paths-export.js +18 -0
- package/dist/paths-export.js.map +1 -0
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +24 -11
- package/dist/paths.js.map +1 -1
- package/dist/playbooks/index.d.ts +1 -0
- package/dist/playbooks/index.d.ts.map +1 -1
- package/dist/playbooks/index.js +4 -0
- package/dist/playbooks/index.js.map +1 -1
- package/dist/playbooks/skill-node-executor.d.ts +155 -0
- package/dist/playbooks/skill-node-executor.d.ts.map +1 -0
- package/dist/playbooks/skill-node-executor.js +156 -0
- package/dist/playbooks/skill-node-executor.js.map +1 -0
- package/dist/repair.d.ts +3 -7
- package/dist/repair.d.ts.map +1 -1
- package/dist/repair.js +5 -43
- package/dist/repair.js.map +1 -1
- package/dist/sagas/migrate-containment.js +7 -7
- package/dist/sagas/migrate-containment.js.map +1 -1
- package/dist/scaffold/ensure-dirs.d.ts +8 -2
- package/dist/scaffold/ensure-dirs.d.ts.map +1 -1
- package/dist/scaffold/ensure-dirs.js +24 -11
- package/dist/scaffold/ensure-dirs.js.map +1 -1
- package/dist/scaffold/project-detection.d.ts +5 -1
- package/dist/scaffold/project-detection.d.ts.map +1 -1
- package/dist/scaffold/project-detection.js +9 -5
- package/dist/scaffold/project-detection.js.map +1 -1
- package/dist/sentient/hygiene-scan.js +6 -6
- package/dist/sentient/hygiene-scan.js.map +1 -1
- package/dist/sentient/proposal-dedup.js +2 -2
- package/dist/sentient/proposal-rate-limiter.js +1 -1
- package/dist/sentient/propose-tick.js +5 -5
- package/dist/sentient/propose-tick.js.map +1 -1
- package/dist/sentient/stage-drift-tick.js +3 -3
- package/dist/sentient/stage-drift-tick.js.map +1 -1
- package/dist/sequence/index.d.ts.map +1 -1
- package/dist/sequence/index.js +6 -2
- package/dist/sequence/index.js.map +1 -1
- package/dist/setup/sections/verification.js +2 -2
- package/dist/setup/sections/verification.js.map +1 -1
- package/dist/shutdown.d.ts +81 -0
- package/dist/shutdown.d.ts.map +1 -0
- package/dist/shutdown.js +105 -0
- package/dist/shutdown.js.map +1 -0
- package/dist/skills/index.d.ts +2 -0
- package/dist/skills/index.d.ts.map +1 -1
- package/dist/skills/index.js +1 -0
- package/dist/skills/index.js.map +1 -1
- package/dist/skills/skill-executor-adapter.d.ts +136 -0
- package/dist/skills/skill-executor-adapter.d.ts.map +1 -0
- package/dist/skills/skill-executor-adapter.js +137 -0
- package/dist/skills/skill-executor-adapter.js.map +1 -0
- package/dist/skills/usage-recorder.d.ts.map +1 -1
- package/dist/skills/usage-recorder.js +30 -0
- package/dist/skills/usage-recorder.js.map +1 -1
- package/dist/skills-export.d.ts +23 -0
- package/dist/skills-export.d.ts.map +1 -0
- package/dist/skills-export.js +23 -0
- package/dist/skills-export.js.map +1 -0
- package/dist/stats/index.d.ts.map +1 -1
- package/dist/stats/index.js +8 -3
- package/dist/stats/index.js.map +1 -1
- package/dist/store/agent-doctor.d.ts +3 -3
- package/dist/store/agent-doctor.d.ts.map +1 -1
- package/dist/store/agent-doctor.js +18 -13
- package/dist/store/agent-doctor.js.map +1 -1
- package/dist/store/agent-install.d.ts +6 -5
- package/dist/store/agent-install.d.ts.map +1 -1
- package/dist/store/agent-install.js +20 -16
- package/dist/store/agent-install.js.map +1 -1
- package/dist/store/agent-registry-accessor.d.ts +66 -28
- package/dist/store/agent-registry-accessor.d.ts.map +1 -1
- package/dist/store/agent-registry-accessor.js +248 -167
- package/dist/store/agent-registry-accessor.js.map +1 -1
- package/dist/store/agent-registry-store.d.ts +242 -0
- package/dist/store/agent-registry-store.d.ts.map +1 -0
- package/dist/store/agent-registry-store.js +501 -0
- package/dist/store/agent-registry-store.js.map +1 -0
- package/dist/store/agent-resolver.d.ts +8 -8
- package/dist/store/agent-resolver.d.ts.map +1 -1
- package/dist/store/agent-resolver.js +19 -17
- package/dist/store/agent-resolver.js.map +1 -1
- package/dist/store/backup-pack.d.ts.map +1 -1
- package/dist/store/backup-pack.js +24 -8
- package/dist/store/backup-pack.js.map +1 -1
- package/dist/store/conduit-sqlite.d.ts +181 -74
- package/dist/store/conduit-sqlite.d.ts.map +1 -1
- package/dist/store/conduit-sqlite.js +307 -528
- package/dist/store/conduit-sqlite.js.map +1 -1
- package/dist/store/cross-db-cleanup.d.ts +5 -5
- package/dist/store/cross-db-cleanup.d.ts.map +1 -1
- package/dist/store/cross-db-cleanup.js +12 -10
- package/dist/store/cross-db-cleanup.js.map +1 -1
- package/dist/store/data-accessor.d.ts +4 -4
- package/dist/store/data-accessor.js +5 -5
- package/dist/store/data-accessor.js.map +1 -1
- package/dist/store/data-safety-central.d.ts +83 -1
- package/dist/store/data-safety-central.d.ts.map +1 -1
- package/dist/store/data-safety-central.js +257 -0
- package/dist/store/data-safety-central.js.map +1 -1
- package/dist/store/db-helpers.d.ts +8 -2
- package/dist/store/db-helpers.d.ts.map +1 -1
- package/dist/store/db-helpers.js +6 -2
- package/dist/store/db-helpers.js.map +1 -1
- package/dist/store/dual-scope-db.d.ts +46 -4
- package/dist/store/dual-scope-db.d.ts.map +1 -1
- package/dist/store/dual-scope-db.js +103 -9
- package/dist/store/dual-scope-db.js.map +1 -1
- package/dist/store/exodus/__fixtures__/representative-fixture.d.ts +116 -0
- package/dist/store/exodus/__fixtures__/representative-fixture.d.ts.map +1 -0
- package/dist/store/exodus/__fixtures__/representative-fixture.js +274 -0
- package/dist/store/exodus/__fixtures__/representative-fixture.js.map +1 -0
- package/dist/store/exodus/index.d.ts +3 -1
- package/dist/store/exodus/index.d.ts.map +1 -1
- package/dist/store/exodus/index.js +3 -1
- package/dist/store/exodus/index.js.map +1 -1
- package/dist/store/exodus/migrate.d.ts +120 -1
- package/dist/store/exodus/migrate.d.ts.map +1 -1
- package/dist/store/exodus/migrate.js +923 -119
- package/dist/store/exodus/migrate.js.map +1 -1
- package/dist/store/exodus/on-open.d.ts +189 -0
- package/dist/store/exodus/on-open.d.ts.map +1 -0
- package/dist/store/exodus/on-open.js +464 -0
- package/dist/store/exodus/on-open.js.map +1 -0
- package/dist/store/exodus/table-name-map.d.ts +173 -0
- package/dist/store/exodus/table-name-map.d.ts.map +1 -0
- package/dist/store/exodus/table-name-map.js +660 -0
- package/dist/store/exodus/table-name-map.js.map +1 -0
- package/dist/store/exodus/verify-migration.d.ts +72 -0
- package/dist/store/exodus/verify-migration.d.ts.map +1 -0
- package/dist/store/exodus/verify-migration.js +678 -0
- package/dist/store/exodus/verify-migration.js.map +1 -0
- package/dist/store/exodus/verify.d.ts +32 -8
- package/dist/store/exodus/verify.d.ts.map +1 -1
- package/dist/store/exodus/verify.js +48 -142
- package/dist/store/exodus/verify.js.map +1 -1
- package/dist/store/index.d.ts +2 -3
- package/dist/store/index.d.ts.map +1 -1
- package/dist/store/index.js +2 -3
- package/dist/store/index.js.map +1 -1
- package/dist/store/memory-accessor.d.ts +31 -0
- package/dist/store/memory-accessor.d.ts.map +1 -1
- package/dist/store/memory-accessor.js +38 -0
- package/dist/store/memory-accessor.js.map +1 -1
- package/dist/store/memory-sqlite.d.ts +86 -13
- package/dist/store/memory-sqlite.d.ts.map +1 -1
- package/dist/store/memory-sqlite.js +326 -528
- package/dist/store/memory-sqlite.js.map +1 -1
- package/dist/store/migrate-signaldock-to-conduit.d.ts +1 -1
- package/dist/store/migrate-signaldock-to-conduit.d.ts.map +1 -1
- package/dist/store/migrate-signaldock-to-conduit.js +126 -35
- package/dist/store/migrate-signaldock-to-conduit.js.map +1 -1
- package/dist/store/migration-manager.d.ts +49 -0
- package/dist/store/migration-manager.d.ts.map +1 -1
- package/dist/store/migration-manager.js +167 -67
- package/dist/store/migration-manager.js.map +1 -1
- package/dist/store/migration-sqlite.d.ts +1 -1
- package/dist/store/migration-sqlite.d.ts.map +1 -1
- package/dist/store/migration-sqlite.js +32 -3
- package/dist/store/migration-sqlite.js.map +1 -1
- package/dist/store/nexus-sqlite.d.ts +152 -29
- package/dist/store/nexus-sqlite.d.ts.map +1 -1
- package/dist/store/nexus-sqlite.js +496 -177
- package/dist/store/nexus-sqlite.js.map +1 -1
- package/dist/store/nexus-validation-schemas.d.ts +32 -32
- package/dist/store/open-cleo-db.d.ts +37 -40
- package/dist/store/open-cleo-db.d.ts.map +1 -1
- package/dist/store/open-cleo-db.js +76 -153
- package/dist/store/open-cleo-db.js.map +1 -1
- package/dist/store/role-accessors-impl.d.ts +4 -4
- package/dist/store/role-accessors-impl.d.ts.map +1 -1
- package/dist/store/role-accessors-impl.js +18 -15
- package/dist/store/role-accessors-impl.js.map +1 -1
- package/dist/store/schema/{signaldock-schema.d.ts → agent-registry-schema.d.ts} +15 -5
- package/dist/store/schema/agent-registry-schema.d.ts.map +1 -0
- package/dist/store/schema/{signaldock-schema.js → agent-registry-schema.js} +15 -5
- package/dist/store/schema/agent-registry-schema.js.map +1 -0
- package/dist/store/schema/agent-schema.d.ts +1 -1
- package/dist/store/schema/agent-schema.js +4 -4
- package/dist/store/schema/agent-schema.js.map +1 -1
- package/dist/store/schema/attachments.d.ts +1 -1
- package/dist/store/schema/audit.d.ts +15 -5
- package/dist/store/schema/audit.d.ts.map +1 -1
- package/dist/store/schema/audit.js +12 -2
- package/dist/store/schema/audit.js.map +1 -1
- package/dist/store/schema/background-jobs.d.ts +1 -1
- package/dist/store/schema/cleo-global/{signaldock.d.ts → agent-registry.d.ts} +277 -271
- package/dist/store/schema/cleo-global/agent-registry.d.ts.map +1 -0
- package/dist/store/schema/cleo-global/{signaldock.js → agent-registry.js} +136 -125
- package/dist/store/schema/cleo-global/agent-registry.js.map +1 -0
- package/dist/store/schema/cleo-global/index.d.ts +29 -22
- package/dist/store/schema/cleo-global/index.d.ts.map +1 -1
- package/dist/store/schema/cleo-global/index.js +29 -22
- package/dist/store/schema/cleo-global/index.js.map +1 -1
- package/dist/store/schema/cleo-global/nexus.d.ts +36 -1034
- package/dist/store/schema/cleo-global/nexus.d.ts.map +1 -1
- package/dist/store/schema/cleo-global/nexus.js +32 -337
- package/dist/store/schema/cleo-global/nexus.js.map +1 -1
- package/dist/store/schema/cleo-global/skills.d.ts +16 -0
- package/dist/store/schema/cleo-global/skills.d.ts.map +1 -1
- package/dist/store/schema/cleo-global/skills.js +11 -0
- package/dist/store/schema/cleo-global/skills.js.map +1 -1
- package/dist/store/schema/{cleo-project → cleo-global}/telemetry.d.ts +33 -17
- package/dist/store/schema/cleo-global/telemetry.d.ts.map +1 -0
- package/dist/store/schema/{cleo-project → cleo-global}/telemetry.js +30 -18
- package/dist/store/schema/cleo-global/telemetry.js.map +1 -0
- package/dist/store/schema/cleo-project/audit.d.ts +8 -8
- package/dist/store/schema/cleo-project/audit.d.ts.map +1 -1
- package/dist/store/schema/cleo-project/audit.js +2 -6
- package/dist/store/schema/cleo-project/audit.js.map +1 -1
- package/dist/store/schema/cleo-project/docs.d.ts +1 -1
- package/dist/store/schema/cleo-project/index.d.ts +29 -12
- package/dist/store/schema/cleo-project/index.d.ts.map +1 -1
- package/dist/store/schema/cleo-project/index.js +29 -12
- package/dist/store/schema/cleo-project/index.js.map +1 -1
- package/dist/store/schema/cleo-project/lifecycle.d.ts +2 -2
- package/dist/store/schema/cleo-project/nexus-graph.d.ts +1067 -0
- package/dist/store/schema/cleo-project/nexus-graph.d.ts.map +1 -0
- package/dist/store/schema/cleo-project/nexus-graph.js +407 -0
- package/dist/store/schema/cleo-project/nexus-graph.js.map +1 -0
- package/dist/store/schema/cleo-project/provenance-orphans.d.ts +385 -0
- package/dist/store/schema/cleo-project/provenance-orphans.d.ts.map +1 -0
- package/dist/store/schema/cleo-project/provenance-orphans.js +142 -0
- package/dist/store/schema/cleo-project/provenance-orphans.js.map +1 -0
- package/dist/store/schema/cleo-project/provenance-rest.d.ts +1 -1
- package/dist/store/schema/cleo-project/runtime.d.ts +1 -1
- package/dist/store/schema/cleo-project/tasks-core-batch2.d.ts +1 -1
- package/dist/store/schema/cleo-project/tasks-core.d.ts +3 -3
- package/dist/store/schema/cleo-shared/brain.d.ts +711 -494
- package/dist/store/schema/cleo-shared/brain.d.ts.map +1 -1
- package/dist/store/schema/cleo-shared/brain.js +215 -134
- package/dist/store/schema/cleo-shared/brain.js.map +1 -1
- package/dist/store/schema/conduit-schema.d.ts +63 -51
- package/dist/store/schema/conduit-schema.d.ts.map +1 -1
- package/dist/store/schema/conduit-schema.js +23 -11
- package/dist/store/schema/conduit-schema.js.map +1 -1
- package/dist/store/schema/goal.d.ts +3 -2
- package/dist/store/schema/goal.d.ts.map +1 -1
- package/dist/store/schema/goal.js +3 -2
- package/dist/store/schema/goal.js.map +1 -1
- package/dist/store/schema/index.d.ts +1 -0
- package/dist/store/schema/index.d.ts.map +1 -1
- package/dist/store/schema/index.js +1 -0
- package/dist/store/schema/index.js.map +1 -1
- package/dist/store/schema/lifecycle.d.ts +2 -2
- package/dist/store/schema/memory-schema.d.ts +2 -2
- package/dist/store/schema/nexus-schema.d.ts +174 -115
- package/dist/store/schema/nexus-schema.d.ts.map +1 -1
- package/dist/store/schema/nexus-schema.js +175 -55
- package/dist/store/schema/nexus-schema.js.map +1 -1
- package/dist/store/schema/provenance/releases.d.ts +1 -1
- package/dist/store/schema/schema-utils.d.ts +78 -0
- package/dist/store/schema/schema-utils.d.ts.map +1 -0
- package/dist/store/schema/schema-utils.js +49 -0
- package/dist/store/schema/schema-utils.js.map +1 -0
- package/dist/store/schema/skills-schema.d.ts +81 -44
- package/dist/store/schema/skills-schema.d.ts.map +1 -1
- package/dist/store/schema/skills-schema.js +49 -16
- package/dist/store/schema/skills-schema.js.map +1 -1
- package/dist/store/schema/tasks.d.ts +3 -3
- package/dist/store/skills-db.d.ts +90 -50
- package/dist/store/skills-db.d.ts.map +1 -1
- package/dist/store/skills-db.js +132 -146
- package/dist/store/skills-db.js.map +1 -1
- package/dist/store/sqlite-backup.d.ts +2 -2
- package/dist/store/sqlite-backup.d.ts.map +1 -1
- package/dist/store/sqlite-backup.js +11 -10
- package/dist/store/sqlite-backup.js.map +1 -1
- package/dist/store/sqlite-data-accessor.d.ts.map +1 -1
- package/dist/store/sqlite-data-accessor.js +25 -18
- package/dist/store/sqlite-data-accessor.js.map +1 -1
- package/dist/store/sqlite.d.ts +72 -12
- package/dist/store/sqlite.d.ts.map +1 -1
- package/dist/store/sqlite.js +153 -89
- package/dist/store/sqlite.js.map +1 -1
- package/dist/store/tasks-schema.d.ts +4 -0
- package/dist/store/tasks-schema.d.ts.map +1 -1
- package/dist/store/tasks-schema.js +60 -0
- package/dist/store/tasks-schema.js.map +1 -1
- package/dist/store/tasks-sqlite.d.ts +2 -2
- package/dist/store/tasks-sqlite.d.ts.map +1 -1
- package/dist/store/tasks-sqlite.js +10 -5
- package/dist/store/tasks-sqlite.js.map +1 -1
- package/dist/store/umbrella-data-accessor.d.ts +17 -6
- package/dist/store/umbrella-data-accessor.d.ts.map +1 -1
- package/dist/store/umbrella-data-accessor.js +8 -8
- package/dist/store/umbrella-data-accessor.js.map +1 -1
- package/dist/store/validation-schemas.d.ts +241 -208
- package/dist/store/validation-schemas.d.ts.map +1 -1
- package/dist/system/health.d.ts.map +1 -1
- package/dist/system/health.js +11 -6
- package/dist/system/health.js.map +1 -1
- package/dist/system/project-health.d.ts.map +1 -1
- package/dist/system/project-health.js +58 -12
- package/dist/system/project-health.js.map +1 -1
- package/dist/tasks/add.d.ts +8 -0
- package/dist/tasks/add.d.ts.map +1 -1
- package/dist/tasks/add.js +101 -0
- package/dist/tasks/add.js.map +1 -1
- package/dist/tasks/cancelled-child-waiver-audit.d.ts +47 -0
- package/dist/tasks/cancelled-child-waiver-audit.d.ts.map +1 -0
- package/dist/tasks/cancelled-child-waiver-audit.js +34 -0
- package/dist/tasks/cancelled-child-waiver-audit.js.map +1 -0
- package/dist/tasks/complete.d.ts +22 -2
- package/dist/tasks/complete.d.ts.map +1 -1
- package/dist/tasks/complete.js +71 -6
- package/dist/tasks/complete.js.map +1 -1
- package/dist/tasks/compute-task-view.js +1 -1
- package/dist/tasks/session-scope.d.ts +5 -0
- package/dist/tasks/session-scope.d.ts.map +1 -1
- package/dist/tasks/session-scope.js +4 -0
- package/dist/tasks/session-scope.js.map +1 -1
- package/dist/tools/guard.d.ts +71 -1
- package/dist/tools/guard.d.ts.map +1 -1
- package/dist/tools/guard.js +73 -1
- package/dist/tools/guard.js.map +1 -1
- package/dist/tools/index.d.ts +21 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +25 -0
- package/dist/tools/index.js.map +1 -1
- package/dist/upgrade.d.ts.map +1 -1
- package/dist/upgrade.js +22 -13
- package/dist/upgrade.js.map +1 -1
- package/dist/workgraph/containment.js +18 -18
- package/dist/workgraph/relations.js +2 -2
- package/dist/worktree/list.d.ts +1 -1
- package/dist/worktree/list.d.ts.map +1 -1
- package/dist/worktree/list.js +19 -21
- package/dist/worktree/list.js.map +1 -1
- package/dist/worktree-export.d.ts +18 -0
- package/dist/worktree-export.d.ts.map +1 -0
- package/dist/worktree-export.js +18 -0
- package/dist/worktree-export.js.map +1 -0
- package/migrations/drizzle-agent-registry/20260412000000_initial-global-agent-registry/migration.sql +29 -0
- package/migrations/drizzle-brain/20260601000001_t11522-brain-task-observations/migration.sql +28 -0
- package/migrations/drizzle-brain/20260601000002_t11522-inline-only-brain-tables/migration.sql +75 -0
- package/migrations/drizzle-cleo-global/20260531000001_t11363-consolidation-cleo-global/migration.sql +49 -144
- package/migrations/drizzle-cleo-global/20260531000001_t11363-consolidation-cleo-global/snapshot.json +8 -8
- package/migrations/drizzle-cleo-global/20260531000002_t11546-brain-usage-log/migration.sql +16 -0
- package/migrations/drizzle-cleo-global/20260601000001_t11544-skills-usage-project-id/migration.sql +12 -0
- package/migrations/drizzle-cleo-global/20260602000001_t11622-agent-registry-rename/migration.sql +80 -0
- package/migrations/drizzle-cleo-project/20260531000001_t11363-consolidation-cleo-project/migration.sql +26 -167
- package/migrations/drizzle-cleo-project/20260531000001_t11363-consolidation-cleo-project/snapshot.json +8 -8
- package/migrations/drizzle-cleo-project/20260531000002_t11546-brain-usage-log/migration.sql +21 -0
- package/migrations/drizzle-cleo-project/20260601000001_t11549-agent-credentials-brain-release-links/migration.sql +49 -0
- package/migrations/drizzle-cleo-project/20260601000002_t11538-project-nexus-graph/migration.sql +140 -0
- package/migrations/drizzle-cleo-project/20260602000002_t11649-token-usage-transport-mcp/migration.sql +146 -0
- package/migrations/drizzle-conduit/20260601000003_t11523-conduit-inline-schema/migration.sql +82 -0
- package/migrations/drizzle-nexus/20260421200001_t1165-baseline-reset/migration.sql +26 -8
- package/migrations/drizzle-nexus/20260601000001_t11545-nexus-relation-weights-partition/migration.sql +97 -0
- package/package.json +44 -12
- package/scripts/install-supervisor-binary.mjs +50 -201
- package/scripts/napi-binary-picker.mjs +267 -0
- package/dist/agents/agent-registry.d.ts.map +0 -1
- package/dist/agents/agent-registry.js.map +0 -1
- package/dist/store/data-safety.d.ts +0 -92
- package/dist/store/data-safety.d.ts.map +0 -1
- package/dist/store/data-safety.js +0 -274
- package/dist/store/data-safety.js.map +0 -1
- package/dist/store/schema/cleo-global/signaldock.d.ts.map +0 -1
- package/dist/store/schema/cleo-global/signaldock.js.map +0 -1
- package/dist/store/schema/cleo-project/telemetry.d.ts.map +0 -1
- package/dist/store/schema/cleo-project/telemetry.js.map +0 -1
- package/dist/store/schema/signaldock-schema.d.ts.map +0 -1
- package/dist/store/schema/signaldock-schema.js.map +0 -1
- package/dist/store/signaldock-sqlite.d.ts +0 -173
- package/dist/store/signaldock-sqlite.d.ts.map +0 -1
- package/dist/store/signaldock-sqlite.js +0 -445
- package/dist/store/signaldock-sqlite.js.map +0 -1
- package/migrations/drizzle-nexus/20260318205558_initial/migration.sql +0 -46
- package/migrations/drizzle-nexus/20260412000001_t529-nexus-graph-tables/migration.sql +0 -49
- package/migrations/drizzle-nexus/20260415000001_t622-project-registry-paths/migration.sql +0 -12
- package/migrations/drizzle-nexus/20260419000001_t998-nexus-plasticity/migration.sql +0 -13
- package/migrations/drizzle-nexus/20260423052640_t1077-add-user-profile-table/migration.sql +0 -16
- package/migrations/drizzle-nexus/20260423052640_t1077-add-user-profile-table/snapshot.json +0 -1531
- package/migrations/drizzle-nexus/20260424140538_t1148-add-sigils-table/migration.sql +0 -13
- package/migrations/drizzle-nexus/20260424140538_t1148-add-sigils-table/snapshot.json +0 -1652
- package/migrations/drizzle-nexus/20260504000001_t1839-fts5-nexus-symbols/migration.sql +0 -68
- package/migrations/drizzle-nexus/20260507135519_t9163-nexus-is-external/migration.sql +0 -20
- package/migrations/drizzle-nexus/20260507135519_t9163-nexus-is-external/snapshot.json +0 -1652
- package/migrations/drizzle-nexus/20260526222449_t11025-project-id-aliases/migration.sql +0 -16
- package/migrations/drizzle-signaldock/20260412000000_initial-global-signaldock/migration.sql +0 -209
- package/migrations/drizzle-signaldock/20260412000000_initial-global-signaldock/snapshot.json +0 -2060
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SCHEMA-REAL representative migration fixture (T11551 · DHQ-045 · AC3).
|
|
3
|
+
*
|
|
4
|
+
* The exodus zero-loss campaign happened because the original unit fixtures
|
|
5
|
+
* used MATCHING NAMES + canonical enums (`CREATE TABLE x (id, val)`), so they
|
|
6
|
+
* missed every real-schema failure: epoch-INTEGER timestamps in a `text`+GLOB
|
|
7
|
+
* column, legacy enum aliases failing a CHECK, and unprefixed→prefixed table
|
|
8
|
+
* names. This module builds a fixture that reproduces those exact hazards so
|
|
9
|
+
* the migration is exercised against representative data — NOT a name-matched
|
|
10
|
+
* toy.
|
|
11
|
+
*
|
|
12
|
+
* The fixture builds two legacy source DBs (`tasks.db`, `brain.db`) whose
|
|
13
|
+
* tables carry:
|
|
14
|
+
*
|
|
15
|
+
* - **Unprefixed names** that must map to domain-prefixed targets
|
|
16
|
+
* (`tasks` → `tasks_tasks`, `architecture_decisions` →
|
|
17
|
+
* `tasks_architecture_decisions`).
|
|
18
|
+
* - **Epoch-INTEGER timestamps** (seconds AND milliseconds) destined for a
|
|
19
|
+
* TASKS-domain target `text` column with an ISO-8601 GLOB CHECK constraint.
|
|
20
|
+
* - **Legacy enum aliases** (`'Accepted'`) that fail the TASKS-domain target
|
|
21
|
+
* CHECK unless the migration normalises them, AND the real value `'mcp'`
|
|
22
|
+
* (transport) which the consolidated CHECK now ACCEPTS verbatim — proving
|
|
23
|
+
* exodus preserves it without coercion (T11649). (Brain enum values are no
|
|
24
|
+
* longer CHECK-constrained at all — see the Brain-domain note below, T11647.)
|
|
25
|
+
* - **A self-referential FK** (`tasks.parent_id → tasks.id`) copied
|
|
26
|
+
* child-before-parent to exercise the FK-defer path.
|
|
27
|
+
*
|
|
28
|
+
* The matching consolidated TASKS-domain target schemas are built with the REAL
|
|
29
|
+
* CHECK and GLOB constraints the production schema declares, so a regression in
|
|
30
|
+
* the coercion/normalisation layer surfaces as a row deficit caught by
|
|
31
|
+
* {@link verifyMigration}.
|
|
32
|
+
*
|
|
33
|
+
* **Brain domain (T11647):** the consolidated `brain_*` target now matches the
|
|
34
|
+
* LEGACY RUNTIME shape — INTEGER epoch-ms timestamps and NO SQL CHECK
|
|
35
|
+
* constraints. So the fixture's `brain_observations` target carries no `type`
|
|
36
|
+
* CHECK and an INTEGER `created_at`: every legacy `type` value (`'observation'`,
|
|
37
|
+
* `'proposal'`, `'pattern'`) and the raw epoch-ms timestamp copy through VERBATIM
|
|
38
|
+
* — zero coercion, zero deficit. This is what proves the brain data-loss /
|
|
39
|
+
* corruption fix end-to-end against representative data.
|
|
40
|
+
*
|
|
41
|
+
* @task T11551 (DHQ-045 — exodus zero-loss durable guard · AC3)
|
|
42
|
+
* @epic T10878
|
|
43
|
+
* @saga T11242
|
|
44
|
+
*/
|
|
45
|
+
import { createRequire } from 'node:module';
|
|
46
|
+
const _require = createRequire(import.meta.url);
|
|
47
|
+
const { DatabaseSync } = _require('node:sqlite');
|
|
48
|
+
/** ISO-8601 GLOB pattern the production CHECK constraints use (T11363). */
|
|
49
|
+
const ISO_GLOB = "'[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]*'";
|
|
50
|
+
/**
|
|
51
|
+
* The number of base-table rows the fixture seeds per (source) table.
|
|
52
|
+
* Exposed so the CI runner can assert an exact post-migration row count.
|
|
53
|
+
*
|
|
54
|
+
* @public
|
|
55
|
+
*/
|
|
56
|
+
export const FIXTURE_EXPECTED_ROWS = {
|
|
57
|
+
tasks_tasks: 30,
|
|
58
|
+
tasks_architecture_decisions: 12,
|
|
59
|
+
tasks_token_usage: 25,
|
|
60
|
+
brain_observations: 40,
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Base-table rows for the optional hazard tables (only seeded when the matching
|
|
64
|
+
* {@link RepresentativeFixtureOptions} flag is set). Exposed so a test that
|
|
65
|
+
* enables the hazards can assert exact parity on them too.
|
|
66
|
+
*
|
|
67
|
+
* @public
|
|
68
|
+
*/
|
|
69
|
+
export const FIXTURE_HAZARD_EXPECTED_ROWS = {
|
|
70
|
+
/** brain_decisions base rows (content table behind the FTS5 index). */
|
|
71
|
+
brain_decisions: 20,
|
|
72
|
+
/** task_relations rows: 4 clean + 2 pre-existing orphans = 6. */
|
|
73
|
+
tasks_task_relations: 6,
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Build the legacy `tasks.db` source fixture with representative drift.
|
|
77
|
+
*
|
|
78
|
+
* @param path - Absolute path for the legacy tasks source DB.
|
|
79
|
+
* @param opts - Optional hazard injection (T11572).
|
|
80
|
+
*/
|
|
81
|
+
function buildTasksSource(path, opts = {}) {
|
|
82
|
+
const db = new DatabaseSync(path);
|
|
83
|
+
try {
|
|
84
|
+
// --- tasks (unprefixed → tasks_tasks) with a self-referential FK + epoch ms ---
|
|
85
|
+
db.exec(`CREATE TABLE "tasks" (
|
|
86
|
+
id TEXT PRIMARY KEY,
|
|
87
|
+
title TEXT NOT NULL,
|
|
88
|
+
parent_id TEXT,
|
|
89
|
+
created_at INTEGER
|
|
90
|
+
)`);
|
|
91
|
+
// Insert child rows BEFORE parents to exercise the FK-defer path.
|
|
92
|
+
for (let i = FIXTURE_EXPECTED_ROWS.tasks_tasks; i >= 1; i--) {
|
|
93
|
+
const parent = i > 1 ? `'T${i - 1}'` : 'NULL';
|
|
94
|
+
// created_at in epoch MILLISECONDS (e.g. 1_717_200_000_000)
|
|
95
|
+
const ms = 1_717_200_000_000 + i * 1000;
|
|
96
|
+
db.exec(`INSERT INTO "tasks" VALUES ('T${i}', 'task ${i}', ${parent}, ${ms})`);
|
|
97
|
+
}
|
|
98
|
+
// --- architecture_decisions with legacy enum aliases for status ---
|
|
99
|
+
db.exec(`CREATE TABLE "architecture_decisions" (id INTEGER PRIMARY KEY, status TEXT, decided_at INTEGER)`);
|
|
100
|
+
const statuses = ['accepted', 'Accepted', 'ACCEPTED', 'approved', 'proposed', 'superseded'];
|
|
101
|
+
for (let i = 1; i <= FIXTURE_EXPECTED_ROWS.tasks_architecture_decisions; i++) {
|
|
102
|
+
const s = statuses[i % statuses.length];
|
|
103
|
+
// decided_at in epoch SECONDS (e.g. 1_717_200_000)
|
|
104
|
+
const sec = 1_717_200_000 + i;
|
|
105
|
+
db.exec(`INSERT INTO "architecture_decisions" VALUES (${i}, '${s}', ${sec})`);
|
|
106
|
+
}
|
|
107
|
+
// --- token_usage with legacy 'mcp' transport alias ---
|
|
108
|
+
db.exec(`CREATE TABLE "token_usage" (id INTEGER PRIMARY KEY, transport TEXT)`);
|
|
109
|
+
const transports = ['cli', 'api', 'agent', 'mcp', 'unknown'];
|
|
110
|
+
for (let i = 1; i <= FIXTURE_EXPECTED_ROWS.tasks_token_usage; i++) {
|
|
111
|
+
db.exec(`INSERT INTO "token_usage" VALUES (${i}, '${transports[i % transports.length]}')`);
|
|
112
|
+
}
|
|
113
|
+
// --- task_relations with a PRE-EXISTING source FK orphan (T11572 BLOCKER 2) ---
|
|
114
|
+
// Mirrors the real `tasks_task_relations` rows that reference deleted tasks.
|
|
115
|
+
// 4 clean rows (parent + child both real) + 2 orphan rows (to_id is a task id
|
|
116
|
+
// that was never inserted). FK enforcement is OFF so the orphans can be
|
|
117
|
+
// seeded; the orphan travels with the row on copy (zero loss).
|
|
118
|
+
if (opts.withPreExistingSourceOrphan) {
|
|
119
|
+
db.exec(`PRAGMA foreign_keys = OFF`);
|
|
120
|
+
db.exec(`CREATE TABLE "task_relations" (
|
|
121
|
+
id INTEGER PRIMARY KEY,
|
|
122
|
+
from_id TEXT REFERENCES "tasks"(id),
|
|
123
|
+
to_id TEXT REFERENCES "tasks"(id),
|
|
124
|
+
kind TEXT
|
|
125
|
+
)`);
|
|
126
|
+
// 4 clean rows referencing real tasks T1..T5.
|
|
127
|
+
for (let i = 1; i <= 4; i++) {
|
|
128
|
+
db.exec(`INSERT INTO "task_relations" VALUES (${i}, 'T${i}', 'T${i + 1}', 'related')`);
|
|
129
|
+
}
|
|
130
|
+
// 2 PRE-EXISTING orphans: to_id points at tasks that do NOT exist.
|
|
131
|
+
db.exec(`INSERT INTO "task_relations" VALUES (5, 'T1', 'T-RECONCILE-FOLLOWUP-v2026.5.38-2', 'related')`);
|
|
132
|
+
db.exec(`INSERT INTO "task_relations" VALUES (6, 'T2', 'T-RECONCILE-FOLLOWUP-v2026.5.38-3', 'related')`);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
finally {
|
|
136
|
+
db.close();
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Build the legacy `brain.db` source fixture with representative drift.
|
|
141
|
+
*
|
|
142
|
+
* @param path - Absolute path for the legacy brain source DB.
|
|
143
|
+
* @param opts - Optional hazard injection (T11572).
|
|
144
|
+
*/
|
|
145
|
+
function buildBrainSource(path, opts = {}) {
|
|
146
|
+
const db = new DatabaseSync(path);
|
|
147
|
+
try {
|
|
148
|
+
// brain_observations already domain-prefixed (identity map) with legacy
|
|
149
|
+
// 'observation' type alias and epoch-ms created_at.
|
|
150
|
+
db.exec(`CREATE TABLE "brain_observations" (id INTEGER PRIMARY KEY, type TEXT, created_at INTEGER)`);
|
|
151
|
+
const types = ['discovery', 'observation', 'decision', 'proposal', 'refactor', 'pattern'];
|
|
152
|
+
for (let i = 1; i <= FIXTURE_EXPECTED_ROWS.brain_observations; i++) {
|
|
153
|
+
const ms = 1_717_200_000_000 + i * 1000;
|
|
154
|
+
db.exec(`INSERT INTO "brain_observations" VALUES (${i}, '${types[i % types.length]}', ${ms})`);
|
|
155
|
+
}
|
|
156
|
+
// --- DERIVED (FTS5) + INTERNAL (conduit meta) tables (T11572 BLOCKER 1) ---
|
|
157
|
+
// These have NO consolidated counterpart; a correct migration SKIPS them
|
|
158
|
+
// rather than counting them as an N→0 deficit.
|
|
159
|
+
if (opts.withDerivedAndInternalTables) {
|
|
160
|
+
// brain_decisions: the FTS5 content table (real base data).
|
|
161
|
+
db.exec(`CREATE TABLE "brain_decisions" (id INTEGER PRIMARY KEY, decision TEXT, rationale TEXT)`);
|
|
162
|
+
for (let i = 1; i <= FIXTURE_HAZARD_EXPECTED_ROWS.brain_decisions; i++) {
|
|
163
|
+
db.exec(`INSERT INTO "brain_decisions" VALUES (${i}, 'decision-${i}', 'rationale-${i}')`);
|
|
164
|
+
}
|
|
165
|
+
// Real FTS5 index → materialises brain_decisions_fts + _data/_idx/_docsize/
|
|
166
|
+
// _config shadow tables (rows that do NOT map 1:1 to base rows).
|
|
167
|
+
db.exec(`CREATE VIRTUAL TABLE "brain_decisions_fts" USING fts5(decision, rationale, content="brain_decisions", content_rowid="id")`);
|
|
168
|
+
db.exec(`INSERT INTO "brain_decisions_fts"("brain_decisions_fts") VALUES('rebuild')`);
|
|
169
|
+
// Internal bookkeeping tables (conduit-sqlite's schema-version + ledger).
|
|
170
|
+
db.exec(`CREATE TABLE "_conduit_meta" (key TEXT PRIMARY KEY, value TEXT)`);
|
|
171
|
+
db.exec(`INSERT INTO "_conduit_meta" VALUES ('schema_version', '7')`);
|
|
172
|
+
db.exec(`CREATE TABLE "_conduit_migrations" (id INTEGER PRIMARY KEY, name TEXT, applied_at TEXT)`);
|
|
173
|
+
db.exec(`INSERT INTO "_conduit_migrations" VALUES (1, 'init', '2026-01-01T00:00:00Z')`);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
finally {
|
|
177
|
+
db.close();
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Build the consolidated TARGET schema with the REAL CHECK + GLOB constraints
|
|
182
|
+
* the production dual-scope schema declares for the fixture's tables.
|
|
183
|
+
*
|
|
184
|
+
* Only the project-scope DB receives tables here (the fixture's brain source is
|
|
185
|
+
* project-scoped in this representative set). The global DB is created empty.
|
|
186
|
+
*
|
|
187
|
+
* @param projectPath - Absolute path for the consolidated project cleo.db.
|
|
188
|
+
* @param globalPath - Absolute path for the consolidated global cleo.db.
|
|
189
|
+
* @param opts - Optional hazard injection (T11572) — adds the matching
|
|
190
|
+
* target tables (`tasks_task_relations`, `brain_decisions`) so the hazard
|
|
191
|
+
* source data has a consolidated home to copy INTO.
|
|
192
|
+
*/
|
|
193
|
+
function buildTargetSchema(projectPath, globalPath, opts = {}) {
|
|
194
|
+
const db = new DatabaseSync(projectPath);
|
|
195
|
+
try {
|
|
196
|
+
// tasks_tasks: created_at is text + ISO GLOB; self-FK on parent_id.
|
|
197
|
+
db.exec(`CREATE TABLE "tasks_tasks" (
|
|
198
|
+
id TEXT PRIMARY KEY,
|
|
199
|
+
title TEXT NOT NULL,
|
|
200
|
+
parent_id TEXT REFERENCES "tasks_tasks"(id),
|
|
201
|
+
created_at TEXT CHECK ("created_at" IS NULL OR "created_at" GLOB ${ISO_GLOB})
|
|
202
|
+
)`);
|
|
203
|
+
// tasks_architecture_decisions: status CHECK enum + decided_at ISO GLOB.
|
|
204
|
+
db.exec(`CREATE TABLE "tasks_architecture_decisions" (
|
|
205
|
+
id INTEGER PRIMARY KEY,
|
|
206
|
+
status TEXT CHECK ("status" IN ('accepted', 'proposed', 'superseded', 'deprecated')),
|
|
207
|
+
decided_at TEXT CHECK ("decided_at" IS NULL OR "decided_at" GLOB ${ISO_GLOB})
|
|
208
|
+
)`);
|
|
209
|
+
// tasks_token_usage: transport CHECK enum — WIDENED to include 'mcp' (T11649).
|
|
210
|
+
// 'mcp' is a first-class transport origin; the consolidated CHECK accepts it
|
|
211
|
+
// so exodus stores the real value verbatim (no coercion to 'agent').
|
|
212
|
+
db.exec(`CREATE TABLE "tasks_token_usage" (
|
|
213
|
+
id INTEGER PRIMARY KEY,
|
|
214
|
+
transport TEXT CHECK ("transport" IN ('cli', 'api', 'agent', 'mcp', 'unknown'))
|
|
215
|
+
)`);
|
|
216
|
+
// brain_observations: LEGACY RUNTIME shape (T11647) — NO CHECK on `type`,
|
|
217
|
+
// INTEGER epoch-ms `created_at`. The consolidated brain target equals the
|
|
218
|
+
// runtime shape (no SQL CHECKs), so every legacy `type` value and the raw
|
|
219
|
+
// epoch-ms timestamp copy through VERBATIM (zero coercion, zero deficit).
|
|
220
|
+
db.exec(`CREATE TABLE "brain_observations" (
|
|
221
|
+
id INTEGER PRIMARY KEY,
|
|
222
|
+
type TEXT,
|
|
223
|
+
created_at INTEGER
|
|
224
|
+
)`);
|
|
225
|
+
// tasks_task_relations: self-FK to tasks_tasks via from_id/to_id. The
|
|
226
|
+
// pre-existing source orphan (to_id pointing at a missing task) copies
|
|
227
|
+
// through and surfaces under PRAGMA foreign_key_check — but is tolerated
|
|
228
|
+
// because the SOURCE already had it (T11572 BLOCKER 2).
|
|
229
|
+
if (opts.withPreExistingSourceOrphan) {
|
|
230
|
+
db.exec(`CREATE TABLE "tasks_task_relations" (
|
|
231
|
+
id INTEGER PRIMARY KEY,
|
|
232
|
+
from_id TEXT REFERENCES "tasks_tasks"(id),
|
|
233
|
+
to_id TEXT REFERENCES "tasks_tasks"(id),
|
|
234
|
+
kind TEXT
|
|
235
|
+
)`);
|
|
236
|
+
}
|
|
237
|
+
// brain_decisions: consolidated home for the FTS5 content table. The derived
|
|
238
|
+
// FTS shadow tables + _conduit_meta have NO target — they are skipped, not
|
|
239
|
+
// migrated (T11572 BLOCKER 1).
|
|
240
|
+
if (opts.withDerivedAndInternalTables) {
|
|
241
|
+
db.exec(`CREATE TABLE "brain_decisions" (id INTEGER PRIMARY KEY, decision TEXT, rationale TEXT)`);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
finally {
|
|
245
|
+
db.close();
|
|
246
|
+
}
|
|
247
|
+
// Empty global DB (the representative set keeps everything project-scoped).
|
|
248
|
+
new DatabaseSync(globalPath).close();
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Materialise the full representative fixture: two legacy source DBs and the
|
|
252
|
+
* consolidated target DBs with production-grade CHECK/GLOB/FK constraints.
|
|
253
|
+
*
|
|
254
|
+
* @param dir - Directory the fixture files are written into. Must already exist.
|
|
255
|
+
* @param opts - Optional T11572 hazard injection (FTS5/meta derived tables +
|
|
256
|
+
* pre-existing source FK orphan). Omitting it preserves the original
|
|
257
|
+
* zero-loss base fixture exactly.
|
|
258
|
+
* @returns Absolute paths of every fixture artifact.
|
|
259
|
+
*
|
|
260
|
+
* @task T11551 (DHQ-045 · AC3)
|
|
261
|
+
* @task T11572 (parity-gate hazards — FTS5/meta exclusion + source-orphan tolerance)
|
|
262
|
+
*/
|
|
263
|
+
export function buildRepresentativeFixture(dir, opts = {}) {
|
|
264
|
+
const { join } = _require('node:path');
|
|
265
|
+
const tasksDbPath = join(dir, 'tasks.db');
|
|
266
|
+
const brainDbPath = join(dir, 'brain.db');
|
|
267
|
+
const projectDbPath = join(dir, 'cleo-project.db');
|
|
268
|
+
const globalDbPath = join(dir, 'cleo-global.db');
|
|
269
|
+
buildTasksSource(tasksDbPath, opts);
|
|
270
|
+
buildBrainSource(brainDbPath, opts);
|
|
271
|
+
buildTargetSchema(projectDbPath, globalDbPath, opts);
|
|
272
|
+
return { tasksDbPath, brainDbPath, projectDbPath, globalDbPath };
|
|
273
|
+
}
|
|
274
|
+
//# sourceMappingURL=representative-fixture.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"representative-fixture.js","sourceRoot":"","sources":["../../../../src/store/exodus/__fixtures__/representative-fixture.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;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CAAC;QACD,6EAA6E;QAC7E,2EAA2E;QAC3E,+BAA+B;QAC/B,IAAI,IAAI,CAAC,4BAA4B,EAAE,CAAC;YACtC,EAAE,CAAC,IAAI,CACL,wFAAwF,CACzF,CAAC;QACJ,CAAC;IACH,CAAC;YAAS,CAAC;QACT,EAAE,CAAC,KAAK,EAAE,CAAC;IACb,CAAC;IACD,4EAA4E;IAC5E,IAAI,YAAY,CAAC,UAAU,CAAC,CAAC,KAAK,EAAE,CAAC;AACvC,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,0BAA0B,CACxC,GAAW,EACX,OAAqC,EAAE;IAOvC,MAAM,EAAE,IAAI,EAAE,GAAG,QAAQ,CAAC,WAAW,CAA+B,CAAC;IACrE,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;IAC1C,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;IAC1C,MAAM,aAAa,GAAG,IAAI,CAAC,GAAG,EAAE,iBAAiB,CAAC,CAAC;IACnD,MAAM,YAAY,GAAG,IAAI,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;IAEjD,gBAAgB,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;IACpC,gBAAgB,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;IACpC,iBAAiB,CAAC,aAAa,EAAE,YAAY,EAAE,IAAI,CAAC,CAAC;IAErD,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,YAAY,EAAE,CAAC;AACnE,CAAC"}
|
|
@@ -8,9 +8,11 @@
|
|
|
8
8
|
* @task T11248 (E5 · SG-DB-SUBSTRATE-V2)
|
|
9
9
|
* @saga T11242
|
|
10
10
|
*/
|
|
11
|
-
export { runExodusMigrate } from './migrate.js';
|
|
11
|
+
export { clearExodusJournal, runExodusMigrate } from './migrate.js';
|
|
12
12
|
export { buildExodusPlan, deriveStagingDirName, sourcesPresent } from './plan.js';
|
|
13
13
|
export { runExodusStatus } from './status.js';
|
|
14
|
+
export { isDerivedOrInternalTable, resolveConsolidatedTableName, reverseLookup, type TableNameResolution, } from './table-name-map.js';
|
|
14
15
|
export { EXODUS_TARGET_SCHEMA_VERSION, type ExodusJournal, type ExodusMigrateResult, type ExodusPlan, type ExodusScope, type ExodusStatusResult, type ExodusVerifyResult, type JournalTableEntry, type LegacyDbDescriptor, type TableCopyResult, type TableMigrationStatus, type VerifyTableResult, } from './types.js';
|
|
15
16
|
export { runExodusVerify } from './verify.js';
|
|
17
|
+
export { verifyMigration } from './verify-migration.js';
|
|
16
18
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/store/exodus/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/store/exodus/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAClF,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EACL,wBAAwB,EACxB,4BAA4B,EAC5B,aAAa,EACb,KAAK,mBAAmB,GACzB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,4BAA4B,EAC5B,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,GACvB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -8,9 +8,11 @@
|
|
|
8
8
|
* @task T11248 (E5 · SG-DB-SUBSTRATE-V2)
|
|
9
9
|
* @saga T11242
|
|
10
10
|
*/
|
|
11
|
-
export { runExodusMigrate } from './migrate.js';
|
|
11
|
+
export { clearExodusJournal, runExodusMigrate } from './migrate.js';
|
|
12
12
|
export { buildExodusPlan, deriveStagingDirName, sourcesPresent } from './plan.js';
|
|
13
13
|
export { runExodusStatus } from './status.js';
|
|
14
|
+
export { isDerivedOrInternalTable, resolveConsolidatedTableName, reverseLookup, } from './table-name-map.js';
|
|
14
15
|
export { EXODUS_TARGET_SCHEMA_VERSION, } from './types.js';
|
|
15
16
|
export { runExodusVerify } from './verify.js';
|
|
17
|
+
export { verifyMigration } from './verify-migration.js';
|
|
16
18
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/store/exodus/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/store/exodus/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAClF,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EACL,wBAAwB,EACxB,4BAA4B,EAC5B,aAAa,GAEd,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,4BAA4B,GAY7B,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -6,13 +6,92 @@
|
|
|
6
6
|
*
|
|
7
7
|
* - Source DBs are opened **read-only** via `openCleoDbSnapshot` (AC4).
|
|
8
8
|
* - Source files are backed up to the staging dir before any writes (AC5).
|
|
9
|
-
* - Import is wrapped in `BEGIN … COMMIT` per
|
|
9
|
+
* - Import is wrapped in `BEGIN … COMMIT` per source; partial failure leaves
|
|
10
10
|
* the target DB untouched (AC6).
|
|
11
11
|
* - Idempotency keys are propagated where the source row has them; generated
|
|
12
12
|
* where it does not (AC7).
|
|
13
13
|
* - The staging journal is written atomically before each table copy so a
|
|
14
14
|
* crash can be resumed (AC5).
|
|
15
15
|
*
|
|
16
|
+
* ## Type coercion — epoch INTEGER → ISO-8601 TEXT (ROOT CAUSE 1 fix — T11546)
|
|
17
|
+
*
|
|
18
|
+
* Many legacy tables store timestamps as INTEGER epoch values (seconds or
|
|
19
|
+
* milliseconds). The consolidated schema declares these columns as `text` with
|
|
20
|
+
* a CHECK constraint: `CHECK ("col" IS NULL OR "col" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]*')`.
|
|
21
|
+
*
|
|
22
|
+
* When a source INTEGER value is inserted into a target TEXT+GLOB column, SQLite
|
|
23
|
+
* coerces the integer to its decimal string representation (e.g. `"1717200000"`),
|
|
24
|
+
* which fails the GLOB check. `INSERT OR IGNORE` then SILENTLY DROPS the entire
|
|
25
|
+
* row. Result: all conduit_messages, brain_observations, etc. → 0 rows copied
|
|
26
|
+
* while migrate reports `success: true, rowsCopied: 0`.
|
|
27
|
+
*
|
|
28
|
+
* Fix (two parts):
|
|
29
|
+
* (a) Per-column value transform: `detectEpochToIsoColumns()` reads the target
|
|
30
|
+
* table DDL from `sqlite_master` to identify columns with an ISO GLOB
|
|
31
|
+
* CHECK constraint. For those columns, if the source type affinity is
|
|
32
|
+
* INTEGER, the SELECT expression applies `strftime('%Y-%m-%dT%H:%M:%fZ',
|
|
33
|
+
* col, 'unixepoch')` (seconds) or the `/1000.0` ms variant depending on
|
|
34
|
+
* the per-source/table heuristic.
|
|
35
|
+
* (b) No-swallow assertion: after the bulk INSERT OR IGNORE, the actual
|
|
36
|
+
* `changes` count is compared against the source row count. Any shortfall
|
|
37
|
+
* is surfaced as a hard table-level error (not a silent success).
|
|
38
|
+
* PK/UNIQUE conflicts on resume are tolerated (they are expected and safe
|
|
39
|
+
* to ignore); unexpected shortfalls are flagged with a detailed error.
|
|
40
|
+
*
|
|
41
|
+
* ## ATTACH-once-per-source design (P0 fix — T11531)
|
|
42
|
+
*
|
|
43
|
+
* Each legacy source DB is ATTACHed to the target handle ONCE using a unique
|
|
44
|
+
* per-source alias, all tables from that source are copied under the single
|
|
45
|
+
* attachment, and then the alias is DETACHed. The ATTACH and DETACH are
|
|
46
|
+
* performed **outside** the BEGIN/COMMIT transaction block because SQLite
|
|
47
|
+
* forbids DETACH inside an active multi-statement transaction. The INSERT
|
|
48
|
+
* statements themselves are issued inside the transaction for atomicity (AC6).
|
|
49
|
+
*
|
|
50
|
+
* Prior implementation called ATTACH/DETACH per-table inside an open
|
|
51
|
+
* transaction — DETACH silently failed (SQLite restriction), the alias stayed
|
|
52
|
+
* attached, and every subsequent table for the same source threw
|
|
53
|
+
* "database _exodus_src_ is already in use", causing ~80 % data loss.
|
|
54
|
+
*
|
|
55
|
+
* ## FK-defer bulk copy (ROOT CAUSE 1 fix — T11533)
|
|
56
|
+
*
|
|
57
|
+
* Legacy tasks.db has self-referential FKs (`tasks.parent_id → tasks.id`),
|
|
58
|
+
* cross-table FKs, and ~18 tables with FK relationships. When FK enforcement
|
|
59
|
+
* is ON and tables are copied in arbitrary order (children before parents),
|
|
60
|
+
* each child INSERT fails with FOREIGN KEY constraint error (SQLite errcode 787)
|
|
61
|
+
* and the table is silently skipped — causing ~114K rows of data loss.
|
|
62
|
+
*
|
|
63
|
+
* Fix: set `PRAGMA foreign_keys = OFF` on the target connection before any
|
|
64
|
+
* bulk INSERT, then after all tables are committed run `PRAGMA foreign_key_check`
|
|
65
|
+
* to validate referential integrity. Genuine orphan rows surface as verify
|
|
66
|
+
* failures; child-before-parent ordering artifacts are NOT dropped.
|
|
67
|
+
* `PRAGMA foreign_keys = ON` is restored after the check.
|
|
68
|
+
*
|
|
69
|
+
* ## Name-mapping (ROOT CAUSE 1 fix — T11532)
|
|
70
|
+
*
|
|
71
|
+
* Legacy source DBs use UNPREFIXED table names (`tasks`, `messages`, `skills`,
|
|
72
|
+
* …) while the consolidated `cleo.db` uses DOMAIN-PREFIXED names
|
|
73
|
+
* (`tasks_tasks`, `conduit_messages`, `skills_skills`, …). The
|
|
74
|
+
* `resolveConsolidatedTableName()` function from `table-name-map.ts` performs
|
|
75
|
+
* the deterministic legacy→consolidated mapping before every copy. Tables with
|
|
76
|
+
* no consolidated home emit an explicit WARN journal entry rather than being
|
|
77
|
+
* silently discarded.
|
|
78
|
+
*
|
|
79
|
+
* ## Column-drift tolerance (ROOT CAUSE 2 fix — T11532, hardened T11533)
|
|
80
|
+
*
|
|
81
|
+
* When the source and target schemas differ (consolidated schema added/changed
|
|
82
|
+
* columns vs legacy), the copy uses the INTERSECTION of source and target
|
|
83
|
+
* column names. New target-only columns take their schema defaults; old
|
|
84
|
+
* source-only columns are dropped. This is implemented by introspecting both
|
|
85
|
+
* schemas via `PRAGMA table_info` and building an explicit column list.
|
|
86
|
+
*
|
|
87
|
+
* **NOT NULL / no-default hazard (T11533)**: target-only NOT NULL columns
|
|
88
|
+
* WITHOUT a schema default caused `INSERT OR IGNORE` to silently drop rows
|
|
89
|
+
* whose source value was NULL for that column (constraint violation → IGNORE).
|
|
90
|
+
* The fix: for each intersection column that is NOT NULL in the target AND
|
|
91
|
+
* has no `dflt_value`, the SELECT clause wraps the source reference in
|
|
92
|
+
* `COALESCE(src_col, type_default)` so no row is silently dropped.
|
|
93
|
+
* A type_default of `''` is used for TEXT affinity and `0` for numeric.
|
|
94
|
+
*
|
|
16
95
|
* ## Advisory file lock (AC4)
|
|
17
96
|
*
|
|
18
97
|
* The source DB files are opened read-only via `openCleoDbSnapshot` which
|
|
@@ -23,9 +102,48 @@
|
|
|
23
102
|
* an in-progress exodus and refuse to write.
|
|
24
103
|
*
|
|
25
104
|
* @task T11248 (E5 · SG-DB-SUBSTRATE-V2)
|
|
105
|
+
* @task T11531 (P0 attach-leak fix)
|
|
106
|
+
* @task T11532 (P0 name-mapping + column-drift + verify-rowid fix)
|
|
107
|
+
* @task T11533 (P0 FK-defer + NOT NULL coalesce + signaldock-global map + nexus hash fix)
|
|
108
|
+
* @task T11547 (P0 enum normalization — 7,421 rows recovered)
|
|
109
|
+
* @task T11548 (P0 final enum coverage — 285 remaining rows zero-loss)
|
|
110
|
+
* @task T11549 (P0 zero-loss final mile — brain_decisions enums + seconds-epoch coercion +
|
|
111
|
+
* agent_credentials/brain_release_links tables)
|
|
26
112
|
* @saga T11242
|
|
27
113
|
*/
|
|
28
114
|
import type { ExodusMigrateResult, ExodusPlan } from './types.js';
|
|
115
|
+
/**
|
|
116
|
+
* Invalidate the migrate journal after an aborted/rolled-back migration so a
|
|
117
|
+
* post-abort retry RE-COPIES every table from scratch (T11572).
|
|
118
|
+
*
|
|
119
|
+
* ## Why this is required for retry correctness
|
|
120
|
+
*
|
|
121
|
+
* `runExodusMigrate` is resumable (AC5): after each table copy it writes a
|
|
122
|
+
* journal entry with `status: 'done'`, and a subsequent run SKIPS any table
|
|
123
|
+
* already marked `done`. That resume optimisation is correct only while the
|
|
124
|
+
* consolidated rows it copied still EXIST. When the parity gate aborts, the
|
|
125
|
+
* exodus-on-open hook truncates the consolidated tables back to EMPTY
|
|
126
|
+
* (`rollbackConsolidatedToEmpty`) — but the on-disk journal still says every
|
|
127
|
+
* table is `done`. The next open therefore re-triggers (consolidated empty),
|
|
128
|
+
* runs `runExodusMigrate` again, finds every table `done` in the journal, copies
|
|
129
|
+
* NOTHING, re-verifies the still-empty target, and re-aborts — a permanent loop
|
|
130
|
+
* that pays the full migrate+verify cost on every open.
|
|
131
|
+
*
|
|
132
|
+
* Deleting the journal file forces `runExodusMigrate` to `initJournal()` afresh,
|
|
133
|
+
* so the retry actually re-copies. Idempotent and best-effort: a missing journal
|
|
134
|
+
* (or a missing staging dir) is a no-op. The staging backups are intentionally
|
|
135
|
+
* LEFT in place (they are the legacy source-of-truth snapshots — harmless to
|
|
136
|
+
* keep, valuable for forensics); only the progress journal is cleared.
|
|
137
|
+
*
|
|
138
|
+
* @param stagingDir - The staging directory whose `exodus-journal.json` to clear.
|
|
139
|
+
* @returns `true` if a journal file was removed, `false` if there was nothing to
|
|
140
|
+
* remove.
|
|
141
|
+
*
|
|
142
|
+
* @task T11572 (abort/rollback must invalidate journal so retry re-copies)
|
|
143
|
+
* @epic T11249 (E6)
|
|
144
|
+
* @saga T11242
|
|
145
|
+
*/
|
|
146
|
+
export declare function clearExodusJournal(stagingDir: string): boolean;
|
|
29
147
|
/**
|
|
30
148
|
* Run the exodus migration.
|
|
31
149
|
*
|
|
@@ -36,6 +154,7 @@ import type { ExodusMigrateResult, ExodusPlan } from './types.js';
|
|
|
36
154
|
* @returns {@link ExodusMigrateResult}
|
|
37
155
|
*
|
|
38
156
|
* @task T11248 (AC4, AC5, AC6, AC7, AC9)
|
|
157
|
+
* @task T11531 (P0 attach-leak fix)
|
|
39
158
|
*/
|
|
40
159
|
export declare function runExodusMigrate(plan: ExodusPlan, forceCrossVersion?: boolean, onProgress?: (msg: string) => void): Promise<ExodusMigrateResult>;
|
|
41
160
|
//# sourceMappingURL=migrate.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../../../src/store/exodus/migrate.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../../../src/store/exodus/migrate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgHG;AAkBH,OAAO,KAAK,EAEV,mBAAmB,EACnB,UAAU,EAMX,MAAM,YAAY,CAAC;AAiEpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAiB9D;AAs3BD;;;;;;;;;;;GAWG;AACH,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,UAAU,EAChB,iBAAiB,UAAQ,EACzB,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,GACjC,OAAO,CAAC,mBAAmB,CAAC,CA0I9B"}
|