@blxzer/pactile 0.6.0-beta.2 → 0.6.0-beta.4
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/README.md +93 -84
- package/README.zh-CN.md +90 -81
- package/dist/bin/compat-warning.d.ts +2 -0
- package/dist/bin/compat-warning.d.ts.map +1 -0
- package/dist/bin/compat-warning.js +8 -0
- package/dist/bin/compat-warning.js.map +1 -0
- package/dist/bin/cstl.d.ts +3 -0
- package/dist/bin/cstl.d.ts.map +1 -0
- package/{bin → dist/bin}/cstl.js +2 -3
- package/dist/bin/cstl.js.map +1 -0
- package/dist/bin/pactile.d.ts +3 -0
- package/dist/bin/pactile.d.ts.map +1 -0
- package/dist/bin/pactile.js +4 -0
- package/dist/bin/pactile.js.map +1 -0
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +77 -17
- package/dist/cli/index.js.map +1 -1
- package/dist/commands/capability.d.ts +3 -0
- package/dist/commands/capability.d.ts.map +1 -0
- package/dist/commands/capability.js +129 -0
- package/dist/commands/capability.js.map +1 -0
- package/dist/commands/codex.d.ts.map +1 -1
- package/dist/commands/codex.js +54 -6
- package/dist/commands/codex.js.map +1 -1
- package/dist/commands/context.d.ts +2 -0
- package/dist/commands/context.d.ts.map +1 -1
- package/dist/commands/context.js +367 -41
- package/dist/commands/context.js.map +1 -1
- package/dist/commands/detach.d.ts.map +1 -1
- package/dist/commands/detach.js +5 -4
- package/dist/commands/detach.js.map +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +615 -259
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/legacy-task.d.ts +3 -0
- package/dist/commands/legacy-task.d.ts.map +1 -0
- package/dist/commands/legacy-task.js +295 -0
- package/dist/commands/legacy-task.js.map +1 -0
- package/dist/commands/pi.d.ts +3 -2
- package/dist/commands/pi.d.ts.map +1 -1
- package/dist/commands/pi.js +333 -10
- package/dist/commands/pi.js.map +1 -1
- package/dist/commands/session.d.ts.map +1 -1
- package/dist/commands/session.js +148 -24
- package/dist/commands/session.js.map +1 -1
- package/dist/commands/task-schedule.d.ts +17 -0
- package/dist/commands/task-schedule.d.ts.map +1 -0
- package/dist/commands/task-schedule.js +395 -0
- package/dist/commands/task-schedule.js.map +1 -0
- package/dist/commands/task-verify-plan.d.ts +3 -0
- package/dist/commands/task-verify-plan.d.ts.map +1 -0
- package/dist/commands/task-verify-plan.js +503 -0
- package/dist/commands/task-verify-plan.js.map +1 -0
- package/dist/commands/task-worktree-close.d.ts +4 -0
- package/dist/commands/task-worktree-close.d.ts.map +1 -0
- package/dist/commands/task-worktree-close.js +81 -0
- package/dist/commands/task-worktree-close.js.map +1 -0
- package/dist/commands/task.d.ts +3 -0
- package/dist/commands/task.d.ts.map +1 -1
- package/dist/commands/task.js +1373 -184
- package/dist/commands/task.js.map +1 -1
- package/dist/commands/tile-selection.d.ts +3 -0
- package/dist/commands/tile-selection.d.ts.map +1 -0
- package/dist/commands/tile-selection.js +174 -0
- package/dist/commands/tile-selection.js.map +1 -0
- package/dist/commands/update.d.ts +1 -1
- package/dist/commands/update.d.ts.map +1 -1
- package/dist/commands/update.js +80 -55
- package/dist/commands/update.js.map +1 -1
- package/dist/commands/worktree.d.ts +4 -0
- package/dist/commands/worktree.d.ts.map +1 -0
- package/dist/commands/worktree.js +198 -0
- package/dist/commands/worktree.js.map +1 -0
- package/dist/configurators/shared.js +1 -1
- package/dist/configurators/shared.js.map +1 -1
- package/dist/core/compat/environment.d.ts +0 -1
- package/dist/core/compat/environment.d.ts.map +1 -1
- package/dist/core/compat/environment.js +1 -9
- package/dist/core/compat/environment.js.map +1 -1
- package/dist/core/pactile/bounded-capabilities.d.ts +127 -0
- package/dist/core/pactile/bounded-capabilities.d.ts.map +1 -0
- package/dist/core/pactile/bounded-capabilities.js +188 -0
- package/dist/core/pactile/bounded-capabilities.js.map +1 -0
- package/dist/core/pactile/index.d.ts +1 -0
- package/dist/core/pactile/index.d.ts.map +1 -1
- package/dist/core/pactile/index.js +1 -0
- package/dist/core/pactile/index.js.map +1 -1
- package/dist/core/task/index.d.ts +4 -2
- package/dist/core/task/index.d.ts.map +1 -1
- package/dist/core/task/index.js +2 -1
- package/dist/core/task/index.js.map +1 -1
- package/dist/core/task/kernel-cli.d.ts +14 -1
- package/dist/core/task/kernel-cli.d.ts.map +1 -1
- package/dist/core/task/kernel-cli.js +128 -0
- package/dist/core/task/kernel-cli.js.map +1 -1
- package/dist/core/task/kernel-contract.d.ts +6 -3
- package/dist/core/task/kernel-contract.d.ts.map +1 -1
- package/dist/core/task/kernel-contract.js +71 -23
- package/dist/core/task/kernel-contract.js.map +1 -1
- package/dist/core/task/kernel-store.d.ts +6 -0
- package/dist/core/task/kernel-store.d.ts.map +1 -1
- package/dist/core/task/kernel-store.js +54 -2
- package/dist/core/task/kernel-store.js.map +1 -1
- package/dist/core/task/legacy-task-migration-reader.d.ts +137 -0
- package/dist/core/task/legacy-task-migration-reader.d.ts.map +1 -0
- package/dist/core/task/legacy-task-migration-reader.js +512 -0
- package/dist/core/task/legacy-task-migration-reader.js.map +1 -0
- package/dist/core/task/legacy-task-migration.d.ts +105 -0
- package/dist/core/task/legacy-task-migration.d.ts.map +1 -0
- package/dist/core/task/legacy-task-migration.js +562 -0
- package/dist/core/task/legacy-task-migration.js.map +1 -0
- package/dist/core/task/legacy-task-overlay-durable-io.d.ts +18 -0
- package/dist/core/task/legacy-task-overlay-durable-io.d.ts.map +1 -0
- package/dist/core/task/legacy-task-overlay-durable-io.js +66 -0
- package/dist/core/task/legacy-task-overlay-durable-io.js.map +1 -0
- package/dist/core/task/legacy-task-reconciliation-reader.d.ts +26 -0
- package/dist/core/task/legacy-task-reconciliation-reader.d.ts.map +1 -0
- package/dist/core/task/legacy-task-reconciliation-reader.js +324 -0
- package/dist/core/task/legacy-task-reconciliation-reader.js.map +1 -0
- package/dist/core/task/legacy-task-v2-import.d.ts +67 -0
- package/dist/core/task/legacy-task-v2-import.d.ts.map +1 -0
- package/dist/core/task/legacy-task-v2-import.js +1046 -0
- package/dist/core/task/legacy-task-v2-import.js.map +1 -0
- package/dist/core/task/project-file-observer.d.ts +46 -0
- package/dist/core/task/project-file-observer.d.ts.map +1 -0
- package/dist/core/task/project-file-observer.js +618 -0
- package/dist/core/task/project-file-observer.js.map +1 -0
- package/dist/core/task/start-authority.d.ts +14 -0
- package/dist/core/task/start-authority.d.ts.map +1 -0
- package/dist/core/task/start-authority.js +146 -0
- package/dist/core/task/start-authority.js.map +1 -0
- package/dist/core/task/strategy.d.ts +24 -0
- package/dist/core/task/strategy.d.ts.map +1 -0
- package/dist/core/task/strategy.js +136 -0
- package/dist/core/task/strategy.js.map +1 -0
- package/dist/core/task/task-candidate-observer.d.ts +111 -0
- package/dist/core/task/task-candidate-observer.d.ts.map +1 -0
- package/dist/core/task/task-candidate-observer.js +762 -0
- package/dist/core/task/task-candidate-observer.js.map +1 -0
- package/dist/core/task/task-kernel-close.d.ts +5 -0
- package/dist/core/task/task-kernel-close.d.ts.map +1 -0
- package/dist/core/task/task-kernel-close.js +367 -0
- package/dist/core/task/task-kernel-close.js.map +1 -0
- package/dist/core/task/task-kernel-dependencies.d.ts +3 -0
- package/dist/core/task/task-kernel-dependencies.d.ts.map +1 -0
- package/dist/core/task/task-kernel-dependencies.js +24 -0
- package/dist/core/task/task-kernel-dependencies.js.map +1 -0
- package/dist/core/task/task-kernel-host.d.ts +5 -0
- package/dist/core/task/task-kernel-host.d.ts.map +1 -0
- package/dist/core/task/task-kernel-host.js +136 -0
- package/dist/core/task/task-kernel-host.js.map +1 -0
- package/dist/core/task/task-kernel-paths.d.ts +19 -0
- package/dist/core/task/task-kernel-paths.d.ts.map +1 -0
- package/dist/core/task/task-kernel-paths.js +237 -0
- package/dist/core/task/task-kernel-paths.js.map +1 -0
- package/dist/core/task/task-kernel-reviews.d.ts +3 -0
- package/dist/core/task/task-kernel-reviews.d.ts.map +1 -0
- package/dist/core/task/task-kernel-reviews.js +100 -0
- package/dist/core/task/task-kernel-reviews.js.map +1 -0
- package/dist/core/task/task-kernel-runs.d.ts +5 -0
- package/dist/core/task/task-kernel-runs.d.ts.map +1 -0
- package/dist/core/task/task-kernel-runs.js +196 -0
- package/dist/core/task/task-kernel-runs.js.map +1 -0
- package/dist/core/task/task-kernel-schema.d.ts +29 -0
- package/dist/core/task/task-kernel-schema.d.ts.map +1 -0
- package/dist/core/task/task-kernel-schema.js +1169 -0
- package/dist/core/task/task-kernel-schema.js.map +1 -0
- package/dist/core/task/task-kernel-store-v2.d.ts +33 -0
- package/dist/core/task/task-kernel-store-v2.d.ts.map +1 -0
- package/dist/core/task/task-kernel-store-v2.js +574 -0
- package/dist/core/task/task-kernel-store-v2.js.map +1 -0
- package/dist/core/task/task-kernel-types.d.ts +585 -0
- package/dist/core/task/task-kernel-types.d.ts.map +1 -0
- package/dist/core/task/task-kernel-types.js +31 -0
- package/dist/core/task/task-kernel-types.js.map +1 -0
- package/dist/core/task/task-kernel-workspaces.d.ts +10 -0
- package/dist/core/task/task-kernel-workspaces.d.ts.map +1 -0
- package/dist/core/task/task-kernel-workspaces.js +250 -0
- package/dist/core/task/task-kernel-workspaces.js.map +1 -0
- package/dist/core/task/task-kernel-write-set.d.ts +3 -0
- package/dist/core/task/task-kernel-write-set.d.ts.map +1 -0
- package/dist/core/task/task-kernel-write-set.js +12 -0
- package/dist/core/task/task-kernel-write-set.js.map +1 -0
- package/dist/core/task/task-kernel.d.ts +19 -0
- package/dist/core/task/task-kernel.d.ts.map +1 -0
- package/dist/core/task/task-kernel.js +17 -0
- package/dist/core/task/task-kernel.js.map +1 -0
- package/dist/core/task/task-pull-request-observer.d.ts +25 -0
- package/dist/core/task/task-pull-request-observer.d.ts.map +1 -0
- package/dist/core/task/task-pull-request-observer.js +187 -0
- package/dist/core/task/task-pull-request-observer.js.map +1 -0
- package/dist/core/task/task-review-evidence.d.ts +27 -0
- package/dist/core/task/task-review-evidence.d.ts.map +1 -0
- package/dist/core/task/task-review-evidence.js +383 -0
- package/dist/core/task/task-review-evidence.js.map +1 -0
- package/dist/migrations/index.d.ts +1 -1
- package/dist/migrations/index.d.ts.map +1 -1
- package/dist/migrations/index.js +5 -3
- package/dist/migrations/index.js.map +1 -1
- package/dist/migrations/manifests/0.6.0-beta.3.json +9 -0
- package/dist/migrations/manifests/0.6.0-beta.4.json +9 -0
- package/dist/pactile/artifacts/documents.d.ts +72 -0
- package/dist/pactile/artifacts/documents.d.ts.map +1 -0
- package/dist/pactile/artifacts/documents.js +406 -0
- package/dist/pactile/artifacts/documents.js.map +1 -0
- package/dist/pactile/artifacts/index.d.ts +6 -0
- package/dist/pactile/artifacts/index.d.ts.map +1 -0
- package/dist/pactile/artifacts/index.js +6 -0
- package/dist/pactile/artifacts/index.js.map +1 -0
- package/dist/pactile/artifacts/projection.d.ts +50 -0
- package/dist/pactile/artifacts/projection.d.ts.map +1 -0
- package/dist/pactile/artifacts/projection.js +139 -0
- package/dist/pactile/artifacts/projection.js.map +1 -0
- package/dist/pactile/artifacts/reader.d.ts +20 -0
- package/dist/pactile/artifacts/reader.d.ts.map +1 -0
- package/dist/pactile/artifacts/reader.js +559 -0
- package/dist/pactile/artifacts/reader.js.map +1 -0
- package/dist/pactile/artifacts/schema.d.ts +4 -0
- package/dist/pactile/artifacts/schema.d.ts.map +1 -0
- package/dist/pactile/artifacts/schema.js +217 -0
- package/dist/pactile/artifacts/schema.js.map +1 -0
- package/dist/pactile/artifacts/types.d.ts +66 -0
- package/dist/pactile/artifacts/types.d.ts.map +1 -0
- package/dist/pactile/artifacts/types.js +45 -0
- package/dist/pactile/artifacts/types.js.map +1 -0
- package/dist/pactile/capabilities/claim.d.ts +3 -0
- package/dist/pactile/capabilities/claim.d.ts.map +1 -0
- package/dist/pactile/capabilities/claim.js +97 -0
- package/dist/pactile/capabilities/claim.js.map +1 -0
- package/dist/pactile/capabilities/command.d.ts +6 -0
- package/dist/pactile/capabilities/command.d.ts.map +1 -0
- package/dist/pactile/capabilities/command.js +253 -0
- package/dist/pactile/capabilities/command.js.map +1 -0
- package/dist/pactile/capabilities/discover.d.ts +6 -0
- package/dist/pactile/capabilities/discover.d.ts.map +1 -0
- package/dist/pactile/capabilities/discover.js +48 -0
- package/dist/pactile/capabilities/discover.js.map +1 -0
- package/dist/pactile/capabilities/node.d.ts +15 -0
- package/dist/pactile/capabilities/node.d.ts.map +1 -0
- package/dist/pactile/capabilities/node.js +292 -0
- package/dist/pactile/capabilities/node.js.map +1 -0
- package/dist/pactile/capabilities/read.d.ts +6 -0
- package/dist/pactile/capabilities/read.d.ts.map +1 -0
- package/dist/pactile/capabilities/read.js +100 -0
- package/dist/pactile/capabilities/read.js.map +1 -0
- package/dist/pactile/capabilities/receipts.d.ts +17 -0
- package/dist/pactile/capabilities/receipts.d.ts.map +1 -0
- package/dist/pactile/capabilities/receipts.js +90 -0
- package/dist/pactile/capabilities/receipts.js.map +1 -0
- package/dist/pactile/capabilities/search.d.ts +6 -0
- package/dist/pactile/capabilities/search.d.ts.map +1 -0
- package/dist/pactile/capabilities/search.js +181 -0
- package/dist/pactile/capabilities/search.js.map +1 -0
- package/dist/pactile/capabilities/shared.d.ts +29 -0
- package/dist/pactile/capabilities/shared.d.ts.map +1 -0
- package/dist/pactile/capabilities/shared.js +134 -0
- package/dist/pactile/capabilities/shared.js.map +1 -0
- package/dist/pactile/capabilities/workspace.d.ts +19 -0
- package/dist/pactile/capabilities/workspace.d.ts.map +1 -0
- package/dist/pactile/capabilities/workspace.js +273 -0
- package/dist/pactile/capabilities/workspace.js.map +1 -0
- package/dist/pactile/codex/bridge.d.ts +105 -2
- package/dist/pactile/codex/bridge.d.ts.map +1 -1
- package/dist/pactile/codex/bridge.js +1266 -92
- package/dist/pactile/codex/bridge.js.map +1 -1
- package/dist/pactile/codex/dispatch-stop-proof.d.ts +43 -0
- package/dist/pactile/codex/dispatch-stop-proof.d.ts.map +1 -0
- package/dist/pactile/codex/dispatch-stop-proof.js +177 -0
- package/dist/pactile/codex/dispatch-stop-proof.js.map +1 -0
- package/dist/pactile/codex/host-stop.d.ts +47 -0
- package/dist/pactile/codex/host-stop.d.ts.map +1 -0
- package/dist/pactile/codex/host-stop.js +344 -0
- package/dist/pactile/codex/host-stop.js.map +1 -0
- package/dist/pactile/coordination/index.d.ts +4 -0
- package/dist/pactile/coordination/index.d.ts.map +1 -0
- package/dist/pactile/coordination/index.js +4 -0
- package/dist/pactile/coordination/index.js.map +1 -0
- package/dist/pactile/coordination/journal.d.ts +10 -0
- package/dist/pactile/coordination/journal.d.ts.map +1 -0
- package/dist/pactile/coordination/journal.js +255 -0
- package/dist/pactile/coordination/journal.js.map +1 -0
- package/dist/pactile/coordination/kernel-resume.d.ts +8 -0
- package/dist/pactile/coordination/kernel-resume.d.ts.map +1 -0
- package/dist/pactile/coordination/kernel-resume.js +87 -0
- package/dist/pactile/coordination/kernel-resume.js.map +1 -0
- package/dist/pactile/coordination/model.d.ts +553 -0
- package/dist/pactile/coordination/model.d.ts.map +1 -0
- package/dist/pactile/coordination/model.js +239 -0
- package/dist/pactile/coordination/model.js.map +1 -0
- package/dist/pactile/coordination/state.d.ts +46 -0
- package/dist/pactile/coordination/state.d.ts.map +1 -0
- package/dist/pactile/coordination/state.js +301 -0
- package/dist/pactile/coordination/state.js.map +1 -0
- package/dist/pactile/coordination/store.d.ts +94 -0
- package/dist/pactile/coordination/store.d.ts.map +1 -0
- package/dist/pactile/coordination/store.js +396 -0
- package/dist/pactile/coordination/store.js.map +1 -0
- package/dist/pactile/index.d.ts +7 -1
- package/dist/pactile/index.d.ts.map +1 -1
- package/dist/pactile/index.js +7 -1
- package/dist/pactile/index.js.map +1 -1
- package/dist/pactile/jev/contracts.d.ts +104 -0
- package/dist/pactile/jev/contracts.d.ts.map +1 -0
- package/dist/pactile/jev/contracts.js +53 -0
- package/dist/pactile/jev/contracts.js.map +1 -0
- package/dist/pactile/jev/decision.d.ts +58 -0
- package/dist/pactile/jev/decision.d.ts.map +1 -0
- package/dist/pactile/jev/decision.js +149 -0
- package/dist/pactile/jev/decision.js.map +1 -0
- package/dist/pactile/jev/http.d.ts +25 -0
- package/dist/pactile/jev/http.d.ts.map +1 -0
- package/dist/pactile/jev/http.js +234 -0
- package/dist/pactile/jev/http.js.map +1 -0
- package/dist/pactile/jev/index.d.ts +8 -0
- package/dist/pactile/jev/index.d.ts.map +1 -0
- package/dist/pactile/jev/index.js +4 -0
- package/dist/pactile/jev/index.js.map +1 -0
- package/dist/pactile/jev/outbound.d.ts +15 -0
- package/dist/pactile/jev/outbound.d.ts.map +1 -0
- package/dist/pactile/jev/outbound.js +264 -0
- package/dist/pactile/jev/outbound.js.map +1 -0
- package/dist/pactile/jev/project-policy.d.ts +10 -0
- package/dist/pactile/jev/project-policy.d.ts.map +1 -0
- package/dist/pactile/jev/project-policy.js +53 -0
- package/dist/pactile/jev/project-policy.js.map +1 -0
- package/dist/pactile/jev/response.d.ts +17 -0
- package/dist/pactile/jev/response.d.ts.map +1 -0
- package/dist/pactile/jev/response.js +280 -0
- package/dist/pactile/jev/response.js.map +1 -0
- package/dist/pactile/jev/scheduler-advice.d.ts +92 -0
- package/dist/pactile/jev/scheduler-advice.d.ts.map +1 -0
- package/dist/pactile/jev/scheduler-advice.js +323 -0
- package/dist/pactile/jev/scheduler-advice.js.map +1 -0
- package/dist/pactile/jev/transport.d.ts +6 -0
- package/dist/pactile/jev/transport.d.ts.map +1 -0
- package/dist/pactile/jev/transport.js +87 -0
- package/dist/pactile/jev/transport.js.map +1 -0
- package/dist/pactile/lifecycle/deferred-live.d.ts +17 -0
- package/dist/pactile/lifecycle/deferred-live.d.ts.map +1 -0
- package/dist/pactile/lifecycle/deferred-live.js +173 -0
- package/dist/pactile/lifecycle/deferred-live.js.map +1 -0
- package/dist/pactile/lifecycle/legacy-import.d.ts +1 -1
- package/dist/pactile/lifecycle/legacy-import.js +3 -3
- package/dist/pactile/lifecycle/legacy-import.js.map +1 -1
- package/dist/pactile/lifecycle/project-files.d.ts.map +1 -1
- package/dist/pactile/lifecycle/project-files.js +1 -0
- package/dist/pactile/lifecycle/project-files.js.map +1 -1
- package/dist/pactile/migration/legacy-task-batch-generation.d.ts +23 -0
- package/dist/pactile/migration/legacy-task-batch-generation.d.ts.map +1 -0
- package/dist/pactile/migration/legacy-task-batch-generation.js +102 -0
- package/dist/pactile/migration/legacy-task-batch-generation.js.map +1 -0
- package/dist/pactile/migration/legacy-task-batch-io.d.ts +9 -0
- package/dist/pactile/migration/legacy-task-batch-io.d.ts.map +1 -0
- package/dist/pactile/migration/legacy-task-batch-io.js +208 -0
- package/dist/pactile/migration/legacy-task-batch-io.js.map +1 -0
- package/dist/pactile/migration/legacy-task-batch-journal.d.ts +6 -0
- package/dist/pactile/migration/legacy-task-batch-journal.d.ts.map +1 -0
- package/dist/pactile/migration/legacy-task-batch-journal.js +121 -0
- package/dist/pactile/migration/legacy-task-batch-journal.js.map +1 -0
- package/dist/pactile/migration/legacy-task-batch-orchestrator.d.ts +18 -0
- package/dist/pactile/migration/legacy-task-batch-orchestrator.d.ts.map +1 -0
- package/dist/pactile/migration/legacy-task-batch-orchestrator.js +634 -0
- package/dist/pactile/migration/legacy-task-batch-orchestrator.js.map +1 -0
- package/dist/pactile/migration/legacy-task-batch-source.d.ts +8 -0
- package/dist/pactile/migration/legacy-task-batch-source.d.ts.map +1 -0
- package/dist/pactile/migration/legacy-task-batch-source.js +158 -0
- package/dist/pactile/migration/legacy-task-batch-source.js.map +1 -0
- package/dist/pactile/migration/legacy-task-batch-types.d.ts +127 -0
- package/dist/pactile/migration/legacy-task-batch-types.d.ts.map +1 -0
- package/dist/pactile/migration/legacy-task-batch-types.js +127 -0
- package/dist/pactile/migration/legacy-task-batch-types.js.map +1 -0
- package/dist/pactile/migration/legacy-task-batch.d.ts +3 -0
- package/dist/pactile/migration/legacy-task-batch.d.ts.map +1 -0
- package/dist/pactile/migration/legacy-task-batch.js +2 -0
- package/dist/pactile/migration/legacy-task-batch.js.map +1 -0
- package/dist/pactile/migration/legacy-task-held-source-reader.d.ts +27 -0
- package/dist/pactile/migration/legacy-task-held-source-reader.d.ts.map +1 -0
- package/dist/pactile/migration/legacy-task-held-source-reader.js +261 -0
- package/dist/pactile/migration/legacy-task-held-source-reader.js.map +1 -0
- package/dist/pactile/migration/legacy-task-reconciliation.d.ts +46 -0
- package/dist/pactile/migration/legacy-task-reconciliation.d.ts.map +1 -0
- package/dist/pactile/migration/legacy-task-reconciliation.js +589 -0
- package/dist/pactile/migration/legacy-task-reconciliation.js.map +1 -0
- package/dist/pactile/migration/legacy-task-update.d.ts +19 -0
- package/dist/pactile/migration/legacy-task-update.d.ts.map +1 -0
- package/dist/pactile/migration/legacy-task-update.js +164 -0
- package/dist/pactile/migration/legacy-task-update.js.map +1 -0
- package/dist/pactile/parallel/batch.d.ts +21 -2
- package/dist/pactile/parallel/batch.d.ts.map +1 -1
- package/dist/pactile/parallel/batch.js +271 -50
- package/dist/pactile/parallel/batch.js.map +1 -1
- package/dist/pactile/parallel/policy.d.ts +1 -1
- package/dist/pactile/parallel/policy.d.ts.map +1 -1
- package/dist/pactile/parallel/policy.js +130 -102
- package/dist/pactile/parallel/policy.js.map +1 -1
- package/dist/pactile/pi/bridge.d.ts +139 -2
- package/dist/pactile/pi/bridge.d.ts.map +1 -1
- package/dist/pactile/pi/bridge.js +1317 -106
- package/dist/pactile/pi/bridge.js.map +1 -1
- package/dist/pactile/pi/rpc.d.ts +23 -4
- package/dist/pactile/pi/rpc.d.ts.map +1 -1
- package/dist/pactile/pi/rpc.js +243 -42
- package/dist/pactile/pi/rpc.js.map +1 -1
- package/dist/pactile/pi/v2-dispatch.d.ts +113 -0
- package/dist/pactile/pi/v2-dispatch.d.ts.map +1 -0
- package/dist/pactile/pi/v2-dispatch.js +919 -0
- package/dist/pactile/pi/v2-dispatch.js.map +1 -0
- package/dist/pactile/projection/planner.js +1 -1
- package/dist/pactile/projection/planner.js.map +1 -1
- package/dist/pactile/registry.d.ts +63 -1
- package/dist/pactile/registry.d.ts.map +1 -1
- package/dist/pactile/registry.js +633 -4
- package/dist/pactile/registry.js.map +1 -1
- package/dist/pactile/retrieval/index.d.ts +1 -0
- package/dist/pactile/retrieval/index.d.ts.map +1 -1
- package/dist/pactile/retrieval/index.js +1 -0
- package/dist/pactile/retrieval/index.js.map +1 -1
- package/dist/pactile/retrieval/jev-planning.d.ts +28 -0
- package/dist/pactile/retrieval/jev-planning.d.ts.map +1 -0
- package/dist/pactile/retrieval/jev-planning.js +96 -0
- package/dist/pactile/retrieval/jev-planning.js.map +1 -0
- package/dist/pactile/review/contract.d.ts +232 -0
- package/dist/pactile/review/contract.d.ts.map +1 -0
- package/dist/pactile/review/contract.js +695 -0
- package/dist/pactile/review/contract.js.map +1 -0
- package/dist/pactile/review/escalation-artifacts.d.ts +41 -0
- package/dist/pactile/review/escalation-artifacts.d.ts.map +1 -0
- package/dist/pactile/review/escalation-artifacts.js +415 -0
- package/dist/pactile/review/escalation-artifacts.js.map +1 -0
- package/dist/pactile/review/escalation-contract.d.ts +115 -0
- package/dist/pactile/review/escalation-contract.d.ts.map +1 -0
- package/dist/pactile/review/escalation-contract.js +151 -0
- package/dist/pactile/review/escalation-contract.js.map +1 -0
- package/dist/pactile/review/escalation-finalize.d.ts +14 -0
- package/dist/pactile/review/escalation-finalize.d.ts.map +1 -0
- package/dist/pactile/review/escalation-finalize.js +319 -0
- package/dist/pactile/review/escalation-finalize.js.map +1 -0
- package/dist/pactile/review/escalation-reply.d.ts +10 -0
- package/dist/pactile/review/escalation-reply.d.ts.map +1 -0
- package/dist/pactile/review/escalation-reply.js +61 -0
- package/dist/pactile/review/escalation-reply.js.map +1 -0
- package/dist/pactile/review/escalation-transport.d.ts +32 -0
- package/dist/pactile/review/escalation-transport.d.ts.map +1 -0
- package/dist/pactile/review/escalation-transport.js +216 -0
- package/dist/pactile/review/escalation-transport.js.map +1 -0
- package/dist/pactile/review/escalation.d.ts +7 -0
- package/dist/pactile/review/escalation.d.ts.map +1 -0
- package/dist/pactile/review/escalation.js +6 -0
- package/dist/pactile/review/escalation.js.map +1 -0
- package/dist/pactile/review/evidence.d.ts +25 -0
- package/dist/pactile/review/evidence.d.ts.map +1 -0
- package/dist/pactile/review/evidence.js +58 -0
- package/dist/pactile/review/evidence.js.map +1 -0
- package/dist/pactile/review/jev-escalation-advice.d.ts +77 -0
- package/dist/pactile/review/jev-escalation-advice.d.ts.map +1 -0
- package/dist/pactile/review/jev-escalation-advice.js +358 -0
- package/dist/pactile/review/jev-escalation-advice.js.map +1 -0
- package/dist/pactile/scheduler/index.d.ts +6 -0
- package/dist/pactile/scheduler/index.d.ts.map +1 -0
- package/dist/pactile/scheduler/index.js +5 -0
- package/dist/pactile/scheduler/index.js.map +1 -0
- package/dist/pactile/scheduler/project-lease-store.d.ts +35 -0
- package/dist/pactile/scheduler/project-lease-store.d.ts.map +1 -0
- package/dist/pactile/scheduler/project-lease-store.js +189 -0
- package/dist/pactile/scheduler/project-lease-store.js.map +1 -0
- package/dist/pactile/scheduler/scheduler.d.ts +91 -0
- package/dist/pactile/scheduler/scheduler.d.ts.map +1 -0
- package/dist/pactile/scheduler/scheduler.js +589 -0
- package/dist/pactile/scheduler/scheduler.js.map +1 -0
- package/dist/pactile/scheduler/task-kernel-admission.d.ts +173 -0
- package/dist/pactile/scheduler/task-kernel-admission.d.ts.map +1 -0
- package/dist/pactile/scheduler/task-kernel-admission.js +1560 -0
- package/dist/pactile/scheduler/task-kernel-admission.js.map +1 -0
- package/dist/pactile/scheduler/task-kernel-wave-dispatch.d.ts +184 -0
- package/dist/pactile/scheduler/task-kernel-wave-dispatch.d.ts.map +1 -0
- package/dist/pactile/scheduler/task-kernel-wave-dispatch.js +952 -0
- package/dist/pactile/scheduler/task-kernel-wave-dispatch.js.map +1 -0
- package/dist/pactile/scheduler/task-map-scheduler.d.ts +116 -0
- package/dist/pactile/scheduler/task-map-scheduler.d.ts.map +1 -0
- package/dist/pactile/scheduler/task-map-scheduler.js +1448 -0
- package/dist/pactile/scheduler/task-map-scheduler.js.map +1 -0
- package/dist/pactile/scheduler/task-run-dispatch-state.d.ts +7 -0
- package/dist/pactile/scheduler/task-run-dispatch-state.d.ts.map +1 -0
- package/dist/pactile/scheduler/task-run-dispatch-state.js +69 -0
- package/dist/pactile/scheduler/task-run-dispatch-state.js.map +1 -0
- package/dist/pactile/task/authorization.d.ts +3 -0
- package/dist/pactile/task/authorization.d.ts.map +1 -0
- package/dist/pactile/task/authorization.js +43 -0
- package/dist/pactile/task/authorization.js.map +1 -0
- package/dist/pactile/task/creation.d.ts +22 -0
- package/dist/pactile/task/creation.d.ts.map +1 -0
- package/dist/pactile/task/creation.js +95 -0
- package/dist/pactile/task/creation.js.map +1 -0
- package/dist/pactile/task/guards.d.ts +1 -4
- package/dist/pactile/task/guards.d.ts.map +1 -1
- package/dist/pactile/task/guards.js +5 -57
- package/dist/pactile/task/guards.js.map +1 -1
- package/dist/pactile/task/session-jev-receipt.d.ts +58 -0
- package/dist/pactile/task/session-jev-receipt.d.ts.map +1 -0
- package/dist/pactile/task/session-jev-receipt.js +375 -0
- package/dist/pactile/task/session-jev-receipt.js.map +1 -0
- package/dist/pactile/task/session-jev.d.ts +7 -0
- package/dist/pactile/task/session-jev.d.ts.map +1 -0
- package/dist/pactile/task/session-jev.js +217 -0
- package/dist/pactile/task/session-jev.js.map +1 -0
- package/dist/pactile/task/session-pack.d.ts.map +1 -1
- package/dist/pactile/task/session-pack.js +155 -16
- package/dist/pactile/task/session-pack.js.map +1 -1
- package/dist/pactile/task/session-retrieval-jev-receipt.d.ts +49 -0
- package/dist/pactile/task/session-retrieval-jev-receipt.d.ts.map +1 -0
- package/dist/pactile/task/session-retrieval-jev-receipt.js +97 -0
- package/dist/pactile/task/session-retrieval-jev-receipt.js.map +1 -0
- package/dist/pactile/task/session-retrieval-jev.d.ts +8 -0
- package/dist/pactile/task/session-retrieval-jev.d.ts.map +1 -0
- package/dist/pactile/task/session-retrieval-jev.js +352 -0
- package/dist/pactile/task/session-retrieval-jev.js.map +1 -0
- package/dist/pactile/task/strategy.d.ts +1 -23
- package/dist/pactile/task/strategy.d.ts.map +1 -1
- package/dist/pactile/task/strategy.js +2 -135
- package/dist/pactile/task/strategy.js.map +1 -1
- package/dist/pactile/tiles/jev-selection.d.ts +44 -0
- package/dist/pactile/tiles/jev-selection.d.ts.map +1 -0
- package/dist/pactile/tiles/jev-selection.js +210 -0
- package/dist/pactile/tiles/jev-selection.js.map +1 -0
- package/dist/pactile/tiles/safe-yaml.d.ts +5 -1
- package/dist/pactile/tiles/safe-yaml.d.ts.map +1 -1
- package/dist/pactile/tiles/safe-yaml.js +8 -8
- package/dist/pactile/tiles/safe-yaml.js.map +1 -1
- package/dist/pactile/tiles/selection-receipts.d.ts +71 -0
- package/dist/pactile/tiles/selection-receipts.d.ts.map +1 -0
- package/dist/pactile/tiles/selection-receipts.js +319 -0
- package/dist/pactile/tiles/selection-receipts.js.map +1 -0
- package/dist/pactile/tiles/selection.d.ts +185 -0
- package/dist/pactile/tiles/selection.d.ts.map +1 -0
- package/dist/pactile/tiles/selection.js +985 -0
- package/dist/pactile/tiles/selection.js.map +1 -0
- package/dist/pactile/verification/git-observer.d.ts +3 -0
- package/dist/pactile/verification/git-observer.d.ts.map +1 -0
- package/dist/pactile/verification/git-observer.js +3 -0
- package/dist/pactile/verification/git-observer.js.map +1 -0
- package/dist/pactile/verification/index.d.ts +11 -0
- package/dist/pactile/verification/index.d.ts.map +1 -0
- package/dist/pactile/verification/index.js +6 -0
- package/dist/pactile/verification/index.js.map +1 -0
- package/dist/pactile/verification/jev-advice.d.ts +78 -0
- package/dist/pactile/verification/jev-advice.d.ts.map +1 -0
- package/dist/pactile/verification/jev-advice.js +397 -0
- package/dist/pactile/verification/jev-advice.js.map +1 -0
- package/dist/pactile/verification/planner.d.ts +15 -0
- package/dist/pactile/verification/planner.d.ts.map +1 -0
- package/dist/pactile/verification/planner.js +412 -0
- package/dist/pactile/verification/planner.js.map +1 -0
- package/dist/pactile/verification/receipt.d.ts +101 -0
- package/dist/pactile/verification/receipt.d.ts.map +1 -0
- package/dist/pactile/verification/receipt.js +400 -0
- package/dist/pactile/verification/receipt.js.map +1 -0
- package/dist/pactile/verification/types.d.ts +72 -0
- package/dist/pactile/verification/types.d.ts.map +1 -0
- package/dist/pactile/verification/types.js +21 -0
- package/dist/pactile/verification/types.js.map +1 -0
- package/dist/pactile/worktree/git-probe.d.ts +32 -0
- package/dist/pactile/worktree/git-probe.d.ts.map +1 -0
- package/dist/pactile/worktree/git-probe.js +336 -0
- package/dist/pactile/worktree/git-probe.js.map +1 -0
- package/dist/pactile/worktree/git-removal.d.ts +3 -0
- package/dist/pactile/worktree/git-removal.d.ts.map +1 -0
- package/dist/pactile/worktree/git-removal.js +11 -0
- package/dist/pactile/worktree/git-removal.js.map +1 -0
- package/dist/pactile/worktree/index.d.ts +2 -0
- package/dist/pactile/worktree/index.d.ts.map +1 -0
- package/dist/pactile/worktree/index.js +2 -0
- package/dist/pactile/worktree/index.js.map +1 -0
- package/dist/pactile/worktree/integration-evidence.d.ts +80 -0
- package/dist/pactile/worktree/integration-evidence.d.ts.map +1 -0
- package/dist/pactile/worktree/integration-evidence.js +166 -0
- package/dist/pactile/worktree/integration-evidence.js.map +1 -0
- package/dist/pactile/worktree/manager-core.d.ts +50 -0
- package/dist/pactile/worktree/manager-core.d.ts.map +1 -0
- package/dist/pactile/worktree/manager-core.js +359 -0
- package/dist/pactile/worktree/manager-core.js.map +1 -0
- package/dist/pactile/worktree/manager-provenance.d.ts +32 -0
- package/dist/pactile/worktree/manager-provenance.d.ts.map +1 -0
- package/dist/pactile/worktree/manager-provenance.js +409 -0
- package/dist/pactile/worktree/manager-provenance.js.map +1 -0
- package/dist/pactile/worktree/manager-types.d.ts +84 -0
- package/dist/pactile/worktree/manager-types.d.ts.map +1 -0
- package/dist/pactile/worktree/manager-types.js +11 -0
- package/dist/pactile/worktree/manager-types.js.map +1 -0
- package/dist/pactile/worktree/manager.d.ts +10 -0
- package/dist/pactile/worktree/manager.d.ts.map +1 -0
- package/dist/pactile/worktree/manager.js +6 -0
- package/dist/pactile/worktree/manager.js.map +1 -0
- package/dist/pactile/worktree/run-workspace-cleanup.d.ts +10 -0
- package/dist/pactile/worktree/run-workspace-cleanup.d.ts.map +1 -0
- package/dist/pactile/worktree/run-workspace-cleanup.js +695 -0
- package/dist/pactile/worktree/run-workspace-cleanup.js.map +1 -0
- package/dist/pactile/worktree/run-workspace-lifecycle.d.ts +65 -0
- package/dist/pactile/worktree/run-workspace-lifecycle.d.ts.map +1 -0
- package/dist/pactile/worktree/run-workspace-lifecycle.js +276 -0
- package/dist/pactile/worktree/run-workspace-lifecycle.js.map +1 -0
- package/dist/templates/common/bundled-skills/pactile-meta/references/customize-local/change-hooks.md +1 -1
- package/dist/templates/common/bundled-skills/pactile-meta/references/local-architecture/generated-files.md +1 -1
- package/dist/templates/common/bundled-skills/pactile-meta/references/platform-files/hooks-and-settings.md +1 -1
- package/dist/templates/common/bundled-skills/pactile-meta/references/platform-files/overview.md +1 -1
- package/dist/templates/common/bundled-skills/pactile-meta/references/platform-files/platform-map.md +1 -1
- package/dist/templates/common/bundled-skills/smart-search-cli/SKILL.md +2 -0
- package/dist/templates/common/skills/brainstorm.md +19 -13
- package/dist/templates/markdown/agents.md +2 -2
- package/dist/templates/markdown/framework/execution-strategy.md.txt +1 -1
- package/dist/templates/markdown/framework/index.md.txt +1 -1
- package/dist/templates/markdown/framework/parallel-first-execution.md.txt +17 -105
- package/dist/templates/markdown/framework/prd-grill-frontier.md.txt +3 -3
- package/dist/templates/markdown/framework/release-boundary.md.txt +9 -10
- package/dist/templates/markdown/framework/retrieval-daily-guide.md.txt +1 -1
- package/dist/templates/pactile/CONTEXT.md +48 -36
- package/dist/templates/pactile/modules/approval-personal/contract.md +12 -24
- package/dist/templates/pactile/modules/close-basic/contract.md +15 -18
- package/dist/templates/pactile/modules/debug-recovery/contract.md +4 -4
- package/dist/templates/pactile/modules/define-basic/contract.md +15 -19
- package/dist/templates/pactile/modules/define-extended/contract.md +3 -3
- package/dist/templates/pactile/modules/execute-agent/contract.md +11 -19
- package/dist/templates/pactile/modules/intake-basic/contract.md +16 -13
- package/dist/templates/pactile/modules/verify-basic/contract.md +11 -20
- package/dist/templates/pactile/tasks/templates/release-execution/design.md +5 -5
- package/dist/templates/pactile/tasks/templates/release-readiness/design.md +6 -6
- package/dist/templates/pactile/tasks/templates/release-readiness/handoff-template.md +8 -2
- package/dist/templates/pactile/workflow.md +37 -41
- package/dist/templates/template-utils.d.ts +1 -2
- package/dist/templates/template-utils.d.ts.map +1 -1
- package/dist/templates/template-utils.js +2 -13
- package/dist/templates/template-utils.js.map +1 -1
- package/dist/types/ai-tools.d.ts +1 -1
- package/dist/types/ai-tools.js +1 -1
- package/dist/utils/manifest-prune.js +1 -1
- package/dist/utils/manifest-prune.js.map +1 -1
- package/dist/utils/p36-upgrade.d.ts +2 -2
- package/dist/utils/p36-upgrade.d.ts.map +1 -1
- package/dist/utils/p36-upgrade.js +2 -10
- package/dist/utils/p36-upgrade.js.map +1 -1
- package/dist/utils/post-update-smoke.js +1 -1
- package/dist/utils/post-update-smoke.js.map +1 -1
- package/dist/utils/readiness.d.ts +2 -2
- package/dist/utils/readiness.js +2 -2
- package/dist/utils/uninstall-scrubbers.js +1 -1
- package/dist/utils/workflow-dir.d.ts +1 -1
- package/dist/utils/workflow-dir.d.ts.map +1 -1
- package/dist/utils/workflow-dir.js +1 -1
- package/dist/utils/workflow-dir.js.map +1 -1
- package/package.json +42 -37
- package/CHANGELOG.md +0 -651
- package/bin/compat-warning.js +0 -11
- package/bin/pactile.js +0 -3
- package/bin/smart-search.js +0 -38
- package/dist/migrations/manifests/0.1.0.json +0 -9
- package/dist/migrations/manifests/0.1.1.json +0 -9
- package/dist/migrations/manifests/0.1.2.json +0 -9
- package/dist/migrations/manifests/0.1.3.json +0 -9
- package/dist/migrations/manifests/0.1.4.json +0 -9
- package/dist/migrations/manifests/0.2.1.json +0 -9
- package/dist/migrations/manifests/0.2.10.json +0 -374
- package/dist/migrations/manifests/0.2.2.json +0 -9
- package/dist/migrations/manifests/0.2.3.json +0 -9
- package/dist/migrations/manifests/0.2.4.json +0 -9
- package/dist/migrations/manifests/0.2.5.json +0 -9
- package/dist/migrations/manifests/0.2.6.json +0 -9
- package/dist/migrations/manifests/0.2.7.json +0 -9
- package/dist/migrations/manifests/0.2.8.json +0 -9
- package/dist/migrations/manifests/0.2.9.json +0 -9
- package/dist/migrations/manifests/0.3.0.json +0 -89
- package/dist/migrations/manifests/0.3.1.json +0 -32
- package/dist/migrations/manifests/0.3.2.json +0 -16
- package/dist/migrations/manifests/0.3.3.json +0 -9
- package/dist/migrations/manifests/0.3.4.json +0 -9
- package/dist/migrations/manifests/0.3.5.json +0 -9
- package/dist/migrations/manifests/0.3.6.json +0 -9
- package/dist/migrations/manifests/0.4.0.json +0 -9
- package/dist/migrations/manifests/0.4.1.json +0 -9
- package/dist/migrations/manifests/0.4.2.json +0 -9
- package/dist/migrations/manifests/0.4.3.json +0 -9
- package/dist/migrations/manifests/0.5.0-beta.0.json +0 -9
- package/dist/migrations/manifests/0.5.0-beta.1.json +0 -9
- package/dist/migrations/manifests/0.5.0-beta.2.json +0 -9
- package/dist/migrations/manifests/0.5.0-beta.3.json +0 -9
- package/dist/migrations/manifests/0.5.0-beta.4.json +0 -9
- package/dist/migrations/manifests/0.5.0-beta.5.json +0 -9
- package/dist/migrations/manifests/0.5.0.json +0 -9
- package/dist/pactile/compat/retired-alternate-client.d.ts +0 -42
- package/dist/pactile/compat/retired-alternate-client.d.ts.map +0 -1
- package/dist/pactile/compat/retired-alternate-client.js +0 -153
- package/dist/pactile/compat/retired-alternate-client.js.map +0 -1
- package/dist/pactile/compat/update-residue.d.ts +0 -4
- package/dist/pactile/compat/update-residue.d.ts.map +0 -1
- package/dist/pactile/compat/update-residue.js +0 -55
- package/dist/pactile/compat/update-residue.js.map +0 -1
- package/dist/utils/cursor-retrieval-env.d.ts +0 -17
- package/dist/utils/cursor-retrieval-env.d.ts.map +0 -1
- package/dist/utils/cursor-retrieval-env.js +0 -19
- package/dist/utils/cursor-retrieval-env.js.map +0 -1
- package/dist/utils/proxy.d.ts +0 -25
- package/dist/utils/proxy.d.ts.map +0 -1
- package/dist/utils/proxy.js +0 -60
- package/dist/utils/proxy.js.map +0 -1
- package/scripts/postinstall.js +0 -6
|
@@ -0,0 +1,634 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { scanLegacyTaskMigration, } from "../../core/task/legacy-task-migration.js";
|
|
4
|
+
import { assertUniqueTaskIdForLegacyBatchTarget } from "../../core/task/task-kernel-paths.js";
|
|
5
|
+
import { parseTaskKernelSnapshotV2 } from "../../core/task/task-kernel-schema.js";
|
|
6
|
+
import { assertLegacyTaskMigrationAuthorityOrCleanStore } from "../../core/task/legacy-task-migration-reader.js";
|
|
7
|
+
import { digest, jsonBytes, normalizeRequest, STORAGE_RELATIVE, } from "./legacy-task-batch-types.js";
|
|
8
|
+
import { assertSourceUnchanged, validatePlanAtRoot, verifySourceBackup, writeSourceBackup, } from "./legacy-task-batch-source.js";
|
|
9
|
+
import { stageTargets, verifyGeneration, } from "./legacy-task-batch-generation.js";
|
|
10
|
+
import { readAuthoritySnapshot, readJournal, writeAuthority, writeJournal, } from "./legacy-task-batch-journal.js";
|
|
11
|
+
import { ensureDirectory, storagePath, withAsyncLock, } from "./legacy-task-batch-io.js";
|
|
12
|
+
export function legacyTaskBatchTaskIdConflict(projectRoot, targets) {
|
|
13
|
+
const root = path.resolve(projectRoot);
|
|
14
|
+
const kernels = [];
|
|
15
|
+
try {
|
|
16
|
+
for (const target of targets) {
|
|
17
|
+
if (!target.path.endsWith("/kernel.json"))
|
|
18
|
+
continue;
|
|
19
|
+
const taskDirPath = target.path.slice(0, -"/kernel.json".length);
|
|
20
|
+
if (!taskDirPath.startsWith(".pactile/tasks/") || taskDirPath.split("/").some((part) => part.toLowerCase() === "archive"))
|
|
21
|
+
continue;
|
|
22
|
+
const kernel = parseTaskKernelSnapshotV2(JSON.parse(Buffer.from(target.bytes).toString("utf8")));
|
|
23
|
+
kernels.push({ path: target.path, taskDir: path.join(root, ...taskDirPath.split("/")), taskId: kernel.identity.taskId });
|
|
24
|
+
}
|
|
25
|
+
const ids = new Set();
|
|
26
|
+
for (const kernel of kernels) {
|
|
27
|
+
if (ids.has(kernel.taskId))
|
|
28
|
+
return `legacy-task-migration-task-id-duplicate:${kernel.taskId}`;
|
|
29
|
+
ids.add(kernel.taskId);
|
|
30
|
+
const existingPath = path.join(kernel.taskDir, "kernel.json");
|
|
31
|
+
try {
|
|
32
|
+
const stat = fs.lstatSync(existingPath);
|
|
33
|
+
if (stat.isFile() && !stat.isSymbolicLink()) {
|
|
34
|
+
let existing;
|
|
35
|
+
try {
|
|
36
|
+
existing = JSON.parse(fs.readFileSync(existingPath, "utf8"));
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
existing = null;
|
|
40
|
+
}
|
|
41
|
+
if (existing && typeof existing === "object" && !Array.isArray(existing) && existing.schemaVersion === 2)
|
|
42
|
+
return "legacy-task-migration-target-kernel-occupied";
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
if (error.code !== "ENOENT")
|
|
47
|
+
throw error;
|
|
48
|
+
}
|
|
49
|
+
assertUniqueTaskIdForLegacyBatchTarget(root, kernel.taskId, kernel.taskDir);
|
|
50
|
+
}
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
return error instanceof Error ? error.message : "legacy-task-migration-task-id-check-failed";
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function initialJournal(request, expectedAuthorityFingerprint, at) {
|
|
58
|
+
return {
|
|
59
|
+
schemaVersion: 1,
|
|
60
|
+
batchId: request.batchId,
|
|
61
|
+
generationId: request.generationId,
|
|
62
|
+
state: "planned",
|
|
63
|
+
sourceFingerprint: request.sourceFingerprint,
|
|
64
|
+
targetFingerprint: request.targetFingerprint,
|
|
65
|
+
planFingerprint: request.planFingerprint,
|
|
66
|
+
expectedAuthorityFingerprint,
|
|
67
|
+
createdAt: at,
|
|
68
|
+
updatedAt: at,
|
|
69
|
+
reason: null,
|
|
70
|
+
events: [
|
|
71
|
+
{
|
|
72
|
+
sequence: 1,
|
|
73
|
+
at,
|
|
74
|
+
event: "planned",
|
|
75
|
+
evidenceFingerprint: request.planFingerprint,
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
function nextJournal(journal, state, event, evidenceFingerprint, at, reason = null) {
|
|
81
|
+
return {
|
|
82
|
+
...journal,
|
|
83
|
+
state,
|
|
84
|
+
updatedAt: at,
|
|
85
|
+
reason,
|
|
86
|
+
events: [
|
|
87
|
+
...journal.events,
|
|
88
|
+
{
|
|
89
|
+
sequence: journal.events.length + 1,
|
|
90
|
+
at,
|
|
91
|
+
event,
|
|
92
|
+
evidenceFingerprint,
|
|
93
|
+
},
|
|
94
|
+
],
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
function commitJournal(projectRoot, snapshot, journal) {
|
|
98
|
+
return writeJournal(projectRoot, journal.batchId, snapshot.fingerprint, journal);
|
|
99
|
+
}
|
|
100
|
+
function makeResult(status, reason, request, wrote, journal) {
|
|
101
|
+
return {
|
|
102
|
+
status,
|
|
103
|
+
reason,
|
|
104
|
+
batchId: request?.batchId ?? null,
|
|
105
|
+
generationId: request?.generationId ?? null,
|
|
106
|
+
sourceFingerprint: request?.sourceFingerprint ?? null,
|
|
107
|
+
targetFingerprint: request?.targetFingerprint ?? null,
|
|
108
|
+
wrote,
|
|
109
|
+
journal,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
function completedResult(request, journal, resumed, wrote) {
|
|
113
|
+
return {
|
|
114
|
+
status: "completed",
|
|
115
|
+
resumed,
|
|
116
|
+
batchId: request.batchId,
|
|
117
|
+
generationId: request.generationId,
|
|
118
|
+
sourceFingerprint: request.sourceFingerprint,
|
|
119
|
+
targetFingerprint: request.targetFingerprint,
|
|
120
|
+
wrote,
|
|
121
|
+
journal,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
async function checkpoint(options, phase) {
|
|
125
|
+
await options.onPhase?.(phase);
|
|
126
|
+
}
|
|
127
|
+
/** Read the one committed-batch pointer and verify its source and staged bytes. */
|
|
128
|
+
export function readPreparedLegacyTaskBatch(projectRoot) {
|
|
129
|
+
const root = path.resolve(projectRoot);
|
|
130
|
+
return readAuthoritySnapshot(root)?.authority ?? null;
|
|
131
|
+
}
|
|
132
|
+
function hasOnlyExpectedJournalLock(projectRoot, batchId) {
|
|
133
|
+
const store = path.join(projectRoot, ".pactile", "runtime", "legacy-task-migrations");
|
|
134
|
+
const journalDirectory = path.join(store, "journals");
|
|
135
|
+
const lockPath = path.join(journalDirectory, `${batchId}.json.lock`);
|
|
136
|
+
try {
|
|
137
|
+
const storeEntries = fs.readdirSync(store);
|
|
138
|
+
const journalDirectoryStat = fs.lstatSync(journalDirectory);
|
|
139
|
+
const journalEntries = fs.readdirSync(journalDirectory);
|
|
140
|
+
const lockStat = fs.lstatSync(lockPath);
|
|
141
|
+
return (storeEntries.length === 1 &&
|
|
142
|
+
storeEntries[0] === "journals" &&
|
|
143
|
+
journalDirectoryStat.isDirectory() &&
|
|
144
|
+
!journalDirectoryStat.isSymbolicLink() &&
|
|
145
|
+
journalEntries.length === 1 &&
|
|
146
|
+
journalEntries[0] === `${batchId}.json.lock` &&
|
|
147
|
+
lockStat.isFile() &&
|
|
148
|
+
!lockStat.isSymbolicLink() &&
|
|
149
|
+
lockStat.nlink === 1);
|
|
150
|
+
}
|
|
151
|
+
catch {
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* A missing pointer may be retried only for a matching, pre-commit journal
|
|
157
|
+
* whose backup/staged generation verifies and which has no post-commit overlay.
|
|
158
|
+
* A lone lock for this exact batch may also reach `withLock`, which only reclaims
|
|
159
|
+
* it after confirming that its recorded process is dead.
|
|
160
|
+
*/
|
|
161
|
+
export function canResumeLegacyTaskBatchWithoutAuthority(request) {
|
|
162
|
+
const normalized = normalizeRequest(request);
|
|
163
|
+
if (!normalized ||
|
|
164
|
+
!validatePlanAtRoot(normalized.projectRoot, normalized.plan))
|
|
165
|
+
return false;
|
|
166
|
+
if (legacyTaskBatchTaskIdConflict(normalized.projectRoot, normalized.targets))
|
|
167
|
+
return false;
|
|
168
|
+
try {
|
|
169
|
+
if (readAuthoritySnapshot(normalized.projectRoot))
|
|
170
|
+
return false;
|
|
171
|
+
const snapshot = readJournal(normalized.projectRoot, normalized.batchId);
|
|
172
|
+
if (!snapshot)
|
|
173
|
+
return hasOnlyExpectedJournalLock(normalized.projectRoot, normalized.batchId);
|
|
174
|
+
const journal = snapshot.journal;
|
|
175
|
+
if (journal.batchId !== normalized.batchId ||
|
|
176
|
+
journal.generationId !== normalized.generationId ||
|
|
177
|
+
journal.sourceFingerprint !== normalized.sourceFingerprint ||
|
|
178
|
+
journal.targetFingerprint !== normalized.targetFingerprint ||
|
|
179
|
+
journal.planFingerprint !== normalized.planFingerprint ||
|
|
180
|
+
journal.expectedAuthorityFingerprint !== null)
|
|
181
|
+
return false;
|
|
182
|
+
return readRecoverablePrecommitJournals(request) !== null;
|
|
183
|
+
}
|
|
184
|
+
catch {
|
|
185
|
+
return false;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
function directoryEntries(directory) {
|
|
189
|
+
try {
|
|
190
|
+
const stat = fs.lstatSync(directory);
|
|
191
|
+
if (!stat.isDirectory() || stat.isSymbolicLink())
|
|
192
|
+
return null;
|
|
193
|
+
return fs.readdirSync(directory).sort();
|
|
194
|
+
}
|
|
195
|
+
catch (error) {
|
|
196
|
+
if (error.code === "ENOENT")
|
|
197
|
+
return [];
|
|
198
|
+
return null;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
function directoryExistsSafely(directory) {
|
|
202
|
+
try {
|
|
203
|
+
const stat = fs.lstatSync(directory);
|
|
204
|
+
return stat.isDirectory() && !stat.isSymbolicLink();
|
|
205
|
+
}
|
|
206
|
+
catch (error) {
|
|
207
|
+
if (error.code === "ENOENT")
|
|
208
|
+
return false;
|
|
209
|
+
return null;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
function journalLifecycleEvents(journal) {
|
|
213
|
+
const events = [{ event: "planned", evidenceFingerprint: journal.planFingerprint }];
|
|
214
|
+
if (journal.state === "backed-up" || journal.state === "staged" || journal.state === "validated")
|
|
215
|
+
events.push({ event: "source-backed-up", evidenceFingerprint: journal.sourceFingerprint });
|
|
216
|
+
if (journal.state === "staged" || journal.state === "validated")
|
|
217
|
+
events.push({ event: "targets-staged", evidenceFingerprint: journal.targetFingerprint });
|
|
218
|
+
if (journal.state === "validated")
|
|
219
|
+
events.push({ event: "targets-validated", evidenceFingerprint: journal.targetFingerprint });
|
|
220
|
+
if (![
|
|
221
|
+
"planned",
|
|
222
|
+
"backed-up",
|
|
223
|
+
"staged",
|
|
224
|
+
"validated",
|
|
225
|
+
].includes(journal.state))
|
|
226
|
+
return null;
|
|
227
|
+
return events;
|
|
228
|
+
}
|
|
229
|
+
function journalMatchesPrecommitEvidence(projectRoot, journal, requiredSources, requiredGenerations) {
|
|
230
|
+
const expectedEvents = journalLifecycleEvents(journal);
|
|
231
|
+
const lifecycleEvents = journal.events.filter((event) => event.event !== "source-change-reconciled");
|
|
232
|
+
const markerEvents = journal.events.filter((event) => event.event === "source-change-reconciled");
|
|
233
|
+
if (expectedEvents?.length !== lifecycleEvents.length ||
|
|
234
|
+
lifecycleEvents.some((event, index) => event.event !== expectedEvents?.[index]?.event ||
|
|
235
|
+
event.evidenceFingerprint !== expectedEvents?.[index]?.evidenceFingerprint) ||
|
|
236
|
+
markerEvents.some((event) => journal.events.indexOf(event) < expectedEvents.length) ||
|
|
237
|
+
journal.expectedAuthorityFingerprint !== null ||
|
|
238
|
+
journal.reason !== null ||
|
|
239
|
+
journal.batchId !== `legacy-${journal.planFingerprint.slice("sha256:".length)}` ||
|
|
240
|
+
journal.generationId !== journal.batchId ||
|
|
241
|
+
journal.planFingerprint !==
|
|
242
|
+
digest(jsonBytes({
|
|
243
|
+
sourceFingerprint: journal.sourceFingerprint,
|
|
244
|
+
targetFingerprint: journal.targetFingerprint,
|
|
245
|
+
})))
|
|
246
|
+
return false;
|
|
247
|
+
const markerKeys = new Set();
|
|
248
|
+
for (const event of markerEvents) {
|
|
249
|
+
const markerKey = `${event.relatedBatchId}\0${event.relatedSourceFingerprint}\0${event.relatedPlanFingerprint}`;
|
|
250
|
+
if (event.relatedBatchId !==
|
|
251
|
+
`legacy-${event.relatedPlanFingerprint?.slice("sha256:".length)}` ||
|
|
252
|
+
event.evidenceFingerprint !== event.relatedPlanFingerprint ||
|
|
253
|
+
event.relatedSourceFingerprint === journal.sourceFingerprint ||
|
|
254
|
+
markerKeys.has(markerKey))
|
|
255
|
+
return false;
|
|
256
|
+
markerKeys.add(markerKey);
|
|
257
|
+
}
|
|
258
|
+
const sourceDirectory = storagePath(projectRoot, "sources", journal.sourceFingerprint.slice("sha256:".length));
|
|
259
|
+
const sourceBackupExists = directoryExistsSafely(sourceDirectory);
|
|
260
|
+
if (sourceBackupExists === null)
|
|
261
|
+
return false;
|
|
262
|
+
if (sourceBackupExists) {
|
|
263
|
+
verifySourceBackup(projectRoot, journal.sourceFingerprint);
|
|
264
|
+
requiredSources.add(journal.sourceFingerprint.slice("sha256:".length));
|
|
265
|
+
}
|
|
266
|
+
else if (journal.state !== "planned") {
|
|
267
|
+
return false;
|
|
268
|
+
}
|
|
269
|
+
const generationDirectory = storagePath(projectRoot, "generations", journal.generationId);
|
|
270
|
+
const generationExists = directoryExistsSafely(generationDirectory);
|
|
271
|
+
if (generationExists === null)
|
|
272
|
+
return false;
|
|
273
|
+
if (generationExists) {
|
|
274
|
+
verifyGeneration(projectRoot, journal.generationId, {
|
|
275
|
+
batchId: journal.batchId,
|
|
276
|
+
sourceFingerprint: journal.sourceFingerprint,
|
|
277
|
+
targetFingerprint: journal.targetFingerprint,
|
|
278
|
+
});
|
|
279
|
+
requiredGenerations.add(journal.generationId);
|
|
280
|
+
}
|
|
281
|
+
else if (journal.state === "staged" || journal.state === "validated") {
|
|
282
|
+
return false;
|
|
283
|
+
}
|
|
284
|
+
if (journal.state === "planned" && generationExists)
|
|
285
|
+
return false;
|
|
286
|
+
return true;
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Validate all authority-less P36 artifacts before offering an approved
|
|
290
|
+
* replacement batch. Only intact pre-commit journals with intact snapshots can
|
|
291
|
+
* be superseded; malformed, committed, overlay, or unreferenced artifacts
|
|
292
|
+
* remain fail-closed.
|
|
293
|
+
*/
|
|
294
|
+
function readRecoverablePrecommitJournals(request) {
|
|
295
|
+
const normalized = normalizeRequest(request);
|
|
296
|
+
if (!normalized ||
|
|
297
|
+
!validatePlanAtRoot(normalized.projectRoot, normalized.plan) ||
|
|
298
|
+
legacyTaskBatchTaskIdConflict(normalized.projectRoot, normalized.targets))
|
|
299
|
+
return null;
|
|
300
|
+
try {
|
|
301
|
+
if (readAuthoritySnapshot(normalized.projectRoot))
|
|
302
|
+
return null;
|
|
303
|
+
const store = path.join(normalized.projectRoot, STORAGE_RELATIVE);
|
|
304
|
+
const storeEntries = directoryEntries(store);
|
|
305
|
+
if (!storeEntries?.includes("journals") ||
|
|
306
|
+
storeEntries.some((entry) => !["journals", "sources", "generations"].includes(entry)))
|
|
307
|
+
return null;
|
|
308
|
+
for (const name of ["sources", "generations"]) {
|
|
309
|
+
if (storeEntries.includes(name) && directoryEntries(path.join(store, name)) === null)
|
|
310
|
+
return null;
|
|
311
|
+
}
|
|
312
|
+
const journalDirectory = path.join(store, "journals");
|
|
313
|
+
const journalNames = directoryEntries(journalDirectory);
|
|
314
|
+
if (!journalNames?.length)
|
|
315
|
+
return null;
|
|
316
|
+
const journals = [];
|
|
317
|
+
const journalIds = new Set();
|
|
318
|
+
const requiredSources = new Set();
|
|
319
|
+
const requiredGenerations = new Set();
|
|
320
|
+
let hasCurrentBatch = false;
|
|
321
|
+
for (const name of journalNames) {
|
|
322
|
+
const match = /^(legacy-[a-f0-9]{64})\.json$/.exec(name);
|
|
323
|
+
const batchId = match?.[1];
|
|
324
|
+
if (!batchId)
|
|
325
|
+
return null;
|
|
326
|
+
const snapshot = readJournal(normalized.projectRoot, batchId);
|
|
327
|
+
if (!snapshot?.journal)
|
|
328
|
+
return null;
|
|
329
|
+
const journal = snapshot.journal;
|
|
330
|
+
if (journal.batchId !== batchId ||
|
|
331
|
+
journalIds.has(batchId) ||
|
|
332
|
+
!journalMatchesPrecommitEvidence(normalized.projectRoot, journal, requiredSources, requiredGenerations))
|
|
333
|
+
return null;
|
|
334
|
+
journalIds.add(batchId);
|
|
335
|
+
const isCurrent = journal.batchId === normalized.batchId;
|
|
336
|
+
if (isCurrent) {
|
|
337
|
+
if (journal.sourceFingerprint !== normalized.sourceFingerprint ||
|
|
338
|
+
journal.targetFingerprint !== normalized.targetFingerprint ||
|
|
339
|
+
journal.planFingerprint !== normalized.planFingerprint)
|
|
340
|
+
return null;
|
|
341
|
+
hasCurrentBatch = true;
|
|
342
|
+
}
|
|
343
|
+
else if (journal.sourceFingerprint === normalized.sourceFingerprint) {
|
|
344
|
+
// Same-source competing plans need explicit reconciliation semantics.
|
|
345
|
+
return null;
|
|
346
|
+
}
|
|
347
|
+
journals.push(snapshot);
|
|
348
|
+
}
|
|
349
|
+
const actualSources = storeEntries.includes("sources")
|
|
350
|
+
? directoryEntries(path.join(store, "sources"))
|
|
351
|
+
: [];
|
|
352
|
+
const actualGenerations = storeEntries.includes("generations")
|
|
353
|
+
? directoryEntries(path.join(store, "generations"))
|
|
354
|
+
: [];
|
|
355
|
+
if (!actualSources ||
|
|
356
|
+
!actualGenerations ||
|
|
357
|
+
actualSources.some((name) => !/^[a-f0-9]{64}$/.test(name) || !requiredSources.has(name)) ||
|
|
358
|
+
actualSources.length !== requiredSources.size ||
|
|
359
|
+
actualGenerations.some((name) => !requiredGenerations.has(name)) ||
|
|
360
|
+
actualGenerations.length !== requiredGenerations.size)
|
|
361
|
+
return null;
|
|
362
|
+
// A changed-source retry can have no journal for the new batch yet. A
|
|
363
|
+
// same-batch retry is also accepted here after validating every artifact.
|
|
364
|
+
return hasCurrentBatch || journals.some(({ journal }) => journal.sourceFingerprint !== normalized.sourceFingerprint) ? journals : null;
|
|
365
|
+
}
|
|
366
|
+
catch {
|
|
367
|
+
return null;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
/** Pure preflight for explicitly approved recovery from source-change residue. */
|
|
371
|
+
export function canReconcileLegacyTaskBatchSourceChangeWithoutAuthority(request) {
|
|
372
|
+
return readRecoverablePrecommitJournals(request) !== null;
|
|
373
|
+
}
|
|
374
|
+
function reconcilePrecommitJournals(request, occurredAt, onWrite) {
|
|
375
|
+
const normalized = normalizeRequest(request);
|
|
376
|
+
if (!normalized)
|
|
377
|
+
throw new Error("invalid-or-blocked-source-plan");
|
|
378
|
+
const snapshots = readRecoverablePrecommitJournals(request);
|
|
379
|
+
if (!snapshots)
|
|
380
|
+
throw new Error("legacy-task-migration-authority-missing-with-residual-state");
|
|
381
|
+
assertSourceUnchanged(normalized);
|
|
382
|
+
for (const snapshot of snapshots) {
|
|
383
|
+
const old = snapshot.journal;
|
|
384
|
+
if (old.batchId === normalized.batchId)
|
|
385
|
+
continue;
|
|
386
|
+
const alreadyRecorded = old.events.some((event) => event.event === "source-change-reconciled" &&
|
|
387
|
+
event.relatedBatchId === normalized.batchId &&
|
|
388
|
+
event.relatedSourceFingerprint === normalized.sourceFingerprint &&
|
|
389
|
+
event.relatedPlanFingerprint === normalized.planFingerprint);
|
|
390
|
+
if (alreadyRecorded)
|
|
391
|
+
continue;
|
|
392
|
+
const reconciled = {
|
|
393
|
+
...old,
|
|
394
|
+
updatedAt: occurredAt,
|
|
395
|
+
events: [
|
|
396
|
+
...old.events,
|
|
397
|
+
{
|
|
398
|
+
sequence: old.events.length + 1,
|
|
399
|
+
at: occurredAt,
|
|
400
|
+
event: "source-change-reconciled",
|
|
401
|
+
evidenceFingerprint: normalized.planFingerprint,
|
|
402
|
+
relatedBatchId: normalized.batchId,
|
|
403
|
+
relatedSourceFingerprint: normalized.sourceFingerprint,
|
|
404
|
+
relatedPlanFingerprint: normalized.planFingerprint,
|
|
405
|
+
},
|
|
406
|
+
],
|
|
407
|
+
};
|
|
408
|
+
writeJournal(normalized.projectRoot, old.batchId, snapshot.fingerprint, reconciled);
|
|
409
|
+
onWrite();
|
|
410
|
+
}
|
|
411
|
+
assertSourceUnchanged(normalized);
|
|
412
|
+
}
|
|
413
|
+
/**
|
|
414
|
+
* Prepare a complete source-preserving migration batch outside `.pactile/tasks`.
|
|
415
|
+
* The original files are never rewritten. The entire Task/needs-reconciliation
|
|
416
|
+
* generation becomes visible to the Kernel through one atomic pointer CAS.
|
|
417
|
+
*/
|
|
418
|
+
async function runLegacyTaskBatchUnlocked(request, options = {}) {
|
|
419
|
+
const normalized = normalizeRequest(request);
|
|
420
|
+
if (!normalized ||
|
|
421
|
+
!validatePlanAtRoot(path.resolve(request.projectRoot), request.plan))
|
|
422
|
+
return makeResult("blocked", "invalid-or-blocked-source-plan", null, false, null);
|
|
423
|
+
const taskIdConflict = legacyTaskBatchTaskIdConflict(normalized.projectRoot, normalized.targets);
|
|
424
|
+
if (taskIdConflict)
|
|
425
|
+
return makeResult("blocked", taskIdConflict, normalized, false, null);
|
|
426
|
+
let currentPlan;
|
|
427
|
+
try {
|
|
428
|
+
currentPlan = scanLegacyTaskMigration({
|
|
429
|
+
projectRoot: normalized.projectRoot,
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
catch {
|
|
433
|
+
return makeResult("blocked", "source-preflight-unavailable", normalized, false, null);
|
|
434
|
+
}
|
|
435
|
+
if (currentPlan.preflight.status !== "clear-to-review" ||
|
|
436
|
+
currentPlan.sourceFingerprint !== normalized.sourceFingerprint)
|
|
437
|
+
return makeResult("blocked", "migration-source-changed", normalized, false, null);
|
|
438
|
+
let authorityAtStart;
|
|
439
|
+
try {
|
|
440
|
+
authorityAtStart = readAuthoritySnapshot(normalized.projectRoot);
|
|
441
|
+
}
|
|
442
|
+
catch {
|
|
443
|
+
return makeResult("review", "migration-authority-invalid", normalized, false, null);
|
|
444
|
+
}
|
|
445
|
+
if (authorityAtStart) {
|
|
446
|
+
if (authorityAtStart.authority.sourceFingerprint !==
|
|
447
|
+
normalized.sourceFingerprint) {
|
|
448
|
+
return makeResult("review", "migration-authority-source-changed-after-commit", normalized, false, null);
|
|
449
|
+
}
|
|
450
|
+
if (authorityAtStart.authority.batchId !== normalized.batchId) {
|
|
451
|
+
return makeResult("review", "migration-authority-already-committed", normalized, false, null);
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
if (options.dryRun) {
|
|
455
|
+
return {
|
|
456
|
+
status: "dry-run",
|
|
457
|
+
batchId: normalized.batchId,
|
|
458
|
+
generationId: normalized.generationId,
|
|
459
|
+
sourceFingerprint: normalized.sourceFingerprint,
|
|
460
|
+
targetFingerprint: normalized.targetFingerprint,
|
|
461
|
+
wrote: false,
|
|
462
|
+
journal: null,
|
|
463
|
+
};
|
|
464
|
+
}
|
|
465
|
+
if (options.approved !== true) {
|
|
466
|
+
return {
|
|
467
|
+
status: "cancelled",
|
|
468
|
+
batchId: normalized.batchId,
|
|
469
|
+
generationId: normalized.generationId,
|
|
470
|
+
sourceFingerprint: normalized.sourceFingerprint,
|
|
471
|
+
targetFingerprint: normalized.targetFingerprint,
|
|
472
|
+
wrote: false,
|
|
473
|
+
journal: null,
|
|
474
|
+
};
|
|
475
|
+
}
|
|
476
|
+
let reconcileResidualState = false;
|
|
477
|
+
if (!authorityAtStart) {
|
|
478
|
+
try {
|
|
479
|
+
assertLegacyTaskMigrationAuthorityOrCleanStore(normalized.projectRoot);
|
|
480
|
+
}
|
|
481
|
+
catch (error) {
|
|
482
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
483
|
+
const changedSourceCanReconcile = canReconcileLegacyTaskBatchSourceChangeWithoutAuthority(request);
|
|
484
|
+
const recoverableMissingAuthority = reason ===
|
|
485
|
+
"legacy-task-migration-authority-missing-with-residual-state" &&
|
|
486
|
+
(changedSourceCanReconcile ||
|
|
487
|
+
hasOnlyExpectedJournalLock(normalized.projectRoot, normalized.batchId));
|
|
488
|
+
if (!recoverableMissingAuthority) {
|
|
489
|
+
return makeResult("review", reason, normalized, false, null);
|
|
490
|
+
}
|
|
491
|
+
reconcileResidualState = changedSourceCanReconcile;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
const occurredAt = options.occurredAt ?? new Date().toISOString();
|
|
495
|
+
if (Number.isNaN(Date.parse(occurredAt)))
|
|
496
|
+
return makeResult("blocked", "invalid-event-time", normalized, false, null);
|
|
497
|
+
let snapshot = null;
|
|
498
|
+
let wrote = false;
|
|
499
|
+
let resumed = false;
|
|
500
|
+
try {
|
|
501
|
+
if (reconcileResidualState)
|
|
502
|
+
reconcilePrecommitJournals(request, occurredAt, () => { wrote = true; });
|
|
503
|
+
snapshot = readJournal(normalized.projectRoot, normalized.batchId);
|
|
504
|
+
if (snapshot) {
|
|
505
|
+
resumed = true;
|
|
506
|
+
if (snapshot.journal.planFingerprint !== normalized.planFingerprint ||
|
|
507
|
+
snapshot.journal.sourceFingerprint !== normalized.sourceFingerprint ||
|
|
508
|
+
snapshot.journal.targetFingerprint !== normalized.targetFingerprint)
|
|
509
|
+
return makeResult("review", "migration-plan-conflict", normalized, false, snapshot.journal);
|
|
510
|
+
if (snapshot.journal.state === "review")
|
|
511
|
+
return makeResult("review", snapshot.journal.reason ?? "migration-needs-review", normalized, false, snapshot.journal);
|
|
512
|
+
if (snapshot.journal.state === "committed")
|
|
513
|
+
return completedResult(normalized, snapshot.journal, true, false);
|
|
514
|
+
}
|
|
515
|
+
else {
|
|
516
|
+
const journal = initialJournal(normalized, authorityAtStart?.fingerprint ?? null, occurredAt);
|
|
517
|
+
snapshot = writeJournal(normalized.projectRoot, normalized.batchId, null, journal);
|
|
518
|
+
wrote = true;
|
|
519
|
+
}
|
|
520
|
+
if (snapshot.journal.state === "planned") {
|
|
521
|
+
assertSourceUnchanged(normalized);
|
|
522
|
+
writeSourceBackup(normalized);
|
|
523
|
+
wrote = true;
|
|
524
|
+
const next = nextJournal(snapshot.journal, "backed-up", "source-backed-up", normalized.sourceFingerprint, occurredAt);
|
|
525
|
+
snapshot = commitJournal(normalized.projectRoot, snapshot, next);
|
|
526
|
+
await checkpoint(options, "source-backed-up");
|
|
527
|
+
}
|
|
528
|
+
if (snapshot.journal.state === "backed-up") {
|
|
529
|
+
assertSourceUnchanged(normalized);
|
|
530
|
+
stageTargets(normalized, snapshot.journal.createdAt);
|
|
531
|
+
wrote = true;
|
|
532
|
+
const next = nextJournal(snapshot.journal, "staged", "targets-staged", normalized.targetFingerprint, occurredAt);
|
|
533
|
+
snapshot = commitJournal(normalized.projectRoot, snapshot, next);
|
|
534
|
+
await checkpoint(options, "targets-staged");
|
|
535
|
+
}
|
|
536
|
+
if (snapshot.journal.state === "staged") {
|
|
537
|
+
const manifest = verifyGeneration(normalized.projectRoot, normalized.generationId, {
|
|
538
|
+
batchId: normalized.batchId,
|
|
539
|
+
sourceFingerprint: normalized.sourceFingerprint,
|
|
540
|
+
targetFingerprint: normalized.targetFingerprint,
|
|
541
|
+
});
|
|
542
|
+
const context = {
|
|
543
|
+
batchId: normalized.batchId,
|
|
544
|
+
generationId: normalized.generationId,
|
|
545
|
+
sourceFingerprint: normalized.sourceFingerprint,
|
|
546
|
+
targetFingerprint: normalized.targetFingerprint,
|
|
547
|
+
targets: manifest.files,
|
|
548
|
+
};
|
|
549
|
+
if (options.validateStaged && !(await options.validateStaged(context))) {
|
|
550
|
+
const review = nextJournal(snapshot.journal, "review", "needs-review", normalized.targetFingerprint, occurredAt, "migration-validation-failed");
|
|
551
|
+
snapshot = commitJournal(normalized.projectRoot, snapshot, review);
|
|
552
|
+
return makeResult("review", "migration-validation-failed", normalized, wrote, snapshot.journal);
|
|
553
|
+
}
|
|
554
|
+
assertSourceUnchanged(normalized);
|
|
555
|
+
const next = nextJournal(snapshot.journal, "validated", "targets-validated", normalized.targetFingerprint, occurredAt);
|
|
556
|
+
snapshot = commitJournal(normalized.projectRoot, snapshot, next);
|
|
557
|
+
await checkpoint(options, "targets-validated");
|
|
558
|
+
}
|
|
559
|
+
if (snapshot.journal.state === "validated") {
|
|
560
|
+
assertSourceUnchanged(normalized);
|
|
561
|
+
const current = readAuthoritySnapshot(normalized.projectRoot);
|
|
562
|
+
if (current?.authority.batchId === normalized.batchId &&
|
|
563
|
+
current.authority.generationId === normalized.generationId) {
|
|
564
|
+
// The process may have stopped after the atomic pointer replace.
|
|
565
|
+
}
|
|
566
|
+
else if ((current?.fingerprint ?? null) !==
|
|
567
|
+
snapshot.journal.expectedAuthorityFingerprint) {
|
|
568
|
+
const review = nextJournal(snapshot.journal, "review", "needs-review", current?.fingerprint ?? digest("no-authority"), occurredAt, "migration-authority-cas-mismatch");
|
|
569
|
+
snapshot = commitJournal(normalized.projectRoot, snapshot, review);
|
|
570
|
+
return makeResult("review", "migration-authority-cas-mismatch", normalized, wrote, snapshot.journal);
|
|
571
|
+
}
|
|
572
|
+
else {
|
|
573
|
+
const taskIdConflict = legacyTaskBatchTaskIdConflict(normalized.projectRoot, normalized.targets);
|
|
574
|
+
if (taskIdConflict) {
|
|
575
|
+
const review = nextJournal(snapshot.journal, "review", "needs-review", normalized.targetFingerprint, occurredAt, taskIdConflict);
|
|
576
|
+
snapshot = commitJournal(normalized.projectRoot, snapshot, review);
|
|
577
|
+
return makeResult("review", taskIdConflict, normalized, wrote, snapshot.journal);
|
|
578
|
+
}
|
|
579
|
+
const authority = {
|
|
580
|
+
schemaVersion: 1,
|
|
581
|
+
kind: "prepared-legacy-task-batch",
|
|
582
|
+
visibility: "active-v2",
|
|
583
|
+
batchId: normalized.batchId,
|
|
584
|
+
generationId: normalized.generationId,
|
|
585
|
+
sourceFingerprint: normalized.sourceFingerprint,
|
|
586
|
+
targetFingerprint: normalized.targetFingerprint,
|
|
587
|
+
committedAt: occurredAt,
|
|
588
|
+
};
|
|
589
|
+
writeAuthority(normalized.projectRoot, snapshot.journal.expectedAuthorityFingerprint, authority);
|
|
590
|
+
wrote = true;
|
|
591
|
+
}
|
|
592
|
+
await checkpoint(options, "authority-committed");
|
|
593
|
+
const committed = nextJournal(snapshot.journal, "committed", "authority-committed", normalized.planFingerprint, occurredAt);
|
|
594
|
+
snapshot = commitJournal(normalized.projectRoot, snapshot, committed);
|
|
595
|
+
}
|
|
596
|
+
return completedResult(normalized, snapshot.journal, resumed, wrote);
|
|
597
|
+
}
|
|
598
|
+
catch (error) {
|
|
599
|
+
const reason = error instanceof Error ? error.message : "migration-interrupted";
|
|
600
|
+
try {
|
|
601
|
+
snapshot ??= readJournal(normalized.projectRoot, normalized.batchId);
|
|
602
|
+
}
|
|
603
|
+
catch {
|
|
604
|
+
/* Report interruption even when the persisted journal is unreadable. */
|
|
605
|
+
}
|
|
606
|
+
return makeResult(reason === "migration-source-changed" ? "blocked" : "interrupted", reason, normalized, wrote, snapshot?.journal ?? null);
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
export async function runLegacyTaskBatch(request, options = {}) {
|
|
610
|
+
const normalized = normalizeRequest(request);
|
|
611
|
+
if (!normalized || options.approved !== true || options.dryRun)
|
|
612
|
+
return runLegacyTaskBatchUnlocked(request, options);
|
|
613
|
+
const lockPath = path.join(normalized.projectRoot, ".pactile", "runtime", "legacy-task-migration-batch.lock");
|
|
614
|
+
try {
|
|
615
|
+
ensureDirectory(normalized.projectRoot, path.dirname(lockPath));
|
|
616
|
+
return await withAsyncLock(normalized.projectRoot, lockPath, () => runLegacyTaskBatchUnlocked(request, options));
|
|
617
|
+
}
|
|
618
|
+
catch (error) {
|
|
619
|
+
const reason = error instanceof Error ? error.message : "migration-interrupted";
|
|
620
|
+
if (reason === "migration-lock-unavailable") {
|
|
621
|
+
try {
|
|
622
|
+
assertLegacyTaskMigrationAuthorityOrCleanStore(normalized.projectRoot);
|
|
623
|
+
}
|
|
624
|
+
catch (storeError) {
|
|
625
|
+
const storeReason = storeError instanceof Error ? storeError.message : String(storeError);
|
|
626
|
+
if (storeReason === "legacy-task-migration-authority-missing-with-residual-state" &&
|
|
627
|
+
!canResumeLegacyTaskBatchWithoutAuthority(request))
|
|
628
|
+
return makeResult("review", storeReason, normalized, false, null);
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
return makeResult("interrupted", reason, normalized, false, null);
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
//# sourceMappingURL=legacy-task-batch-orchestrator.js.map
|