@blxzer/pactile 0.5.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/CHANGELOG.md +602 -0
- package/LICENSE +235 -0
- package/README.md +115 -0
- package/README.zh-CN.md +115 -0
- package/bin/compat-warning.js +11 -0
- package/bin/cstl.js +6 -0
- package/bin/pactile.js +3 -0
- package/bin/smart-search.js +38 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +362 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/commands/capability-smoke.d.ts +24 -0
- package/dist/commands/capability-smoke.d.ts.map +1 -0
- package/dist/commands/capability-smoke.js +83 -0
- package/dist/commands/capability-smoke.js.map +1 -0
- package/dist/commands/channel/adapters/claude.d.ts +29 -0
- package/dist/commands/channel/adapters/claude.d.ts.map +1 -0
- package/dist/commands/channel/adapters/claude.js +203 -0
- package/dist/commands/channel/adapters/claude.js.map +1 -0
- package/dist/commands/channel/adapters/codex.d.ts +85 -0
- package/dist/commands/channel/adapters/codex.d.ts.map +1 -0
- package/dist/commands/channel/adapters/codex.js +505 -0
- package/dist/commands/channel/adapters/codex.js.map +1 -0
- package/dist/commands/channel/adapters/index.d.ts +84 -0
- package/dist/commands/channel/adapters/index.d.ts.map +1 -0
- package/dist/commands/channel/adapters/index.js +115 -0
- package/dist/commands/channel/adapters/index.js.map +1 -0
- package/dist/commands/channel/adapters/types.d.ts +33 -0
- package/dist/commands/channel/adapters/types.d.ts.map +1 -0
- package/dist/commands/channel/adapters/types.js +2 -0
- package/dist/commands/channel/adapters/types.js.map +1 -0
- package/dist/commands/channel/agent-loader.d.ts +32 -0
- package/dist/commands/channel/agent-loader.d.ts.map +1 -0
- package/dist/commands/channel/agent-loader.js +154 -0
- package/dist/commands/channel/agent-loader.js.map +1 -0
- package/dist/commands/channel/context-loader.d.ts +26 -0
- package/dist/commands/channel/context-loader.d.ts.map +1 -0
- package/dist/commands/channel/context-loader.js +290 -0
- package/dist/commands/channel/context-loader.js.map +1 -0
- package/dist/commands/channel/context.d.ts +16 -0
- package/dist/commands/channel/context.d.ts.map +1 -0
- package/dist/commands/channel/context.js +83 -0
- package/dist/commands/channel/context.js.map +1 -0
- package/dist/commands/channel/create.d.ts +27 -0
- package/dist/commands/channel/create.d.ts.map +1 -0
- package/dist/commands/channel/create.js +39 -0
- package/dist/commands/channel/create.js.map +1 -0
- package/dist/commands/channel/dev-parse-trace.d.ts +14 -0
- package/dist/commands/channel/dev-parse-trace.d.ts.map +1 -0
- package/dist/commands/channel/dev-parse-trace.js +70 -0
- package/dist/commands/channel/dev-parse-trace.js.map +1 -0
- package/dist/commands/channel/guard.d.ts +150 -0
- package/dist/commands/channel/guard.d.ts.map +1 -0
- package/dist/commands/channel/guard.js +475 -0
- package/dist/commands/channel/guard.js.map +1 -0
- package/dist/commands/channel/index.d.ts +3 -0
- package/dist/commands/channel/index.d.ts.map +1 -0
- package/dist/commands/channel/index.js +531 -0
- package/dist/commands/channel/index.js.map +1 -0
- package/dist/commands/channel/interrupt.d.ts +10 -0
- package/dist/commands/channel/interrupt.d.ts.map +1 -0
- package/dist/commands/channel/interrupt.js +22 -0
- package/dist/commands/channel/interrupt.js.map +1 -0
- package/dist/commands/channel/kill.d.ts +7 -0
- package/dist/commands/channel/kill.d.ts.map +1 -0
- package/dist/commands/channel/kill.js +121 -0
- package/dist/commands/channel/kill.js.map +1 -0
- package/dist/commands/channel/list.d.ts +17 -0
- package/dist/commands/channel/list.d.ts.map +1 -0
- package/dist/commands/channel/list.js +233 -0
- package/dist/commands/channel/list.js.map +1 -0
- package/dist/commands/channel/messages.d.ts +15 -0
- package/dist/commands/channel/messages.d.ts.map +1 -0
- package/dist/commands/channel/messages.js +245 -0
- package/dist/commands/channel/messages.js.map +1 -0
- package/dist/commands/channel/rm.d.ts +27 -0
- package/dist/commands/channel/rm.d.ts.map +1 -0
- package/dist/commands/channel/rm.js +216 -0
- package/dist/commands/channel/rm.js.map +1 -0
- package/dist/commands/channel/run.d.ts +30 -0
- package/dist/commands/channel/run.d.ts.map +1 -0
- package/dist/commands/channel/run.js +130 -0
- package/dist/commands/channel/run.js.map +1 -0
- package/dist/commands/channel/send.d.ts +11 -0
- package/dist/commands/channel/send.d.ts.map +1 -0
- package/dist/commands/channel/send.js +24 -0
- package/dist/commands/channel/send.js.map +1 -0
- package/dist/commands/channel/spawn.d.ts +40 -0
- package/dist/commands/channel/spawn.d.ts.map +1 -0
- package/dist/commands/channel/spawn.js +242 -0
- package/dist/commands/channel/spawn.js.map +1 -0
- package/dist/commands/channel/store/events.d.ts +39 -0
- package/dist/commands/channel/store/events.d.ts.map +1 -0
- package/dist/commands/channel/store/events.js +87 -0
- package/dist/commands/channel/store/events.js.map +1 -0
- package/dist/commands/channel/store/filter.d.ts +3 -0
- package/dist/commands/channel/store/filter.d.ts.map +1 -0
- package/dist/commands/channel/store/filter.js +2 -0
- package/dist/commands/channel/store/filter.js.map +1 -0
- package/dist/commands/channel/store/lock.d.ts +23 -0
- package/dist/commands/channel/store/lock.d.ts.map +1 -0
- package/dist/commands/channel/store/lock.js +99 -0
- package/dist/commands/channel/store/lock.js.map +1 -0
- package/dist/commands/channel/store/paths.d.ts +63 -0
- package/dist/commands/channel/store/paths.d.ts.map +1 -0
- package/dist/commands/channel/store/paths.js +247 -0
- package/dist/commands/channel/store/paths.js.map +1 -0
- package/dist/commands/channel/store/schema.d.ts +27 -0
- package/dist/commands/channel/store/schema.d.ts.map +1 -0
- package/dist/commands/channel/store/schema.js +34 -0
- package/dist/commands/channel/store/schema.js.map +1 -0
- package/dist/commands/channel/store/thread-state.d.ts +5 -0
- package/dist/commands/channel/store/thread-state.d.ts.map +1 -0
- package/dist/commands/channel/store/thread-state.js +16 -0
- package/dist/commands/channel/store/thread-state.js.map +1 -0
- package/dist/commands/channel/store/watch.d.ts +19 -0
- package/dist/commands/channel/store/watch.d.ts.map +1 -0
- package/dist/commands/channel/store/watch.js +146 -0
- package/dist/commands/channel/store/watch.js.map +1 -0
- package/dist/commands/channel/supervisor/idle.d.ts +46 -0
- package/dist/commands/channel/supervisor/idle.d.ts.map +1 -0
- package/dist/commands/channel/supervisor/idle.js +72 -0
- package/dist/commands/channel/supervisor/idle.js.map +1 -0
- package/dist/commands/channel/supervisor/inbox.d.ts +30 -0
- package/dist/commands/channel/supervisor/inbox.d.ts.map +1 -0
- package/dist/commands/channel/supervisor/inbox.js +160 -0
- package/dist/commands/channel/supervisor/inbox.js.map +1 -0
- package/dist/commands/channel/supervisor/shutdown.d.ts +68 -0
- package/dist/commands/channel/supervisor/shutdown.d.ts.map +1 -0
- package/dist/commands/channel/supervisor/shutdown.js +146 -0
- package/dist/commands/channel/supervisor/shutdown.js.map +1 -0
- package/dist/commands/channel/supervisor/stdout.d.ts +51 -0
- package/dist/commands/channel/supervisor/stdout.d.ts.map +1 -0
- package/dist/commands/channel/supervisor/stdout.js +121 -0
- package/dist/commands/channel/supervisor/stdout.js.map +1 -0
- package/dist/commands/channel/supervisor/turns.d.ts +31 -0
- package/dist/commands/channel/supervisor/turns.d.ts.map +1 -0
- package/dist/commands/channel/supervisor/turns.js +45 -0
- package/dist/commands/channel/supervisor/turns.js.map +1 -0
- package/dist/commands/channel/supervisor/warning.d.ts +48 -0
- package/dist/commands/channel/supervisor/warning.d.ts.map +1 -0
- package/dist/commands/channel/supervisor/warning.js +77 -0
- package/dist/commands/channel/supervisor/warning.js.map +1 -0
- package/dist/commands/channel/supervisor.d.ts +59 -0
- package/dist/commands/channel/supervisor.d.ts.map +1 -0
- package/dist/commands/channel/supervisor.js +345 -0
- package/dist/commands/channel/supervisor.js.map +1 -0
- package/dist/commands/channel/text-body.d.ts +13 -0
- package/dist/commands/channel/text-body.d.ts.map +1 -0
- package/dist/commands/channel/text-body.js +47 -0
- package/dist/commands/channel/text-body.js.map +1 -0
- package/dist/commands/channel/threads.d.ts +39 -0
- package/dist/commands/channel/threads.d.ts.map +1 -0
- package/dist/commands/channel/threads.js +106 -0
- package/dist/commands/channel/threads.js.map +1 -0
- package/dist/commands/channel/title.d.ts +12 -0
- package/dist/commands/channel/title.d.ts.map +1 -0
- package/dist/commands/channel/title.js +24 -0
- package/dist/commands/channel/title.js.map +1 -0
- package/dist/commands/channel/wait.d.ts +17 -0
- package/dist/commands/channel/wait.d.ts.map +1 -0
- package/dist/commands/channel/wait.js +75 -0
- package/dist/commands/channel/wait.js.map +1 -0
- package/dist/commands/detach.d.ts +7 -0
- package/dist/commands/detach.d.ts.map +1 -0
- package/dist/commands/detach.js +31 -0
- package/dist/commands/detach.js.map +1 -0
- package/dist/commands/init.d.ts +51 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +1660 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/migrate.d.ts +10 -0
- package/dist/commands/migrate.d.ts.map +1 -0
- package/dist/commands/migrate.js +38 -0
- package/dist/commands/migrate.js.map +1 -0
- package/dist/commands/purge.d.ts +9 -0
- package/dist/commands/purge.d.ts.map +1 -0
- package/dist/commands/purge.js +29 -0
- package/dist/commands/purge.js.map +1 -0
- package/dist/commands/rollback.d.ts +7 -0
- package/dist/commands/rollback.d.ts.map +1 -0
- package/dist/commands/rollback.js +27 -0
- package/dist/commands/rollback.js.map +1 -0
- package/dist/commands/rollout.d.ts +34 -0
- package/dist/commands/rollout.d.ts.map +1 -0
- package/dist/commands/rollout.js +102 -0
- package/dist/commands/rollout.js.map +1 -0
- package/dist/commands/uninstall.d.ts +23 -0
- package/dist/commands/uninstall.d.ts.map +1 -0
- package/dist/commands/uninstall.js +68 -0
- package/dist/commands/uninstall.js.map +1 -0
- package/dist/commands/update.d.ts +139 -0
- package/dist/commands/update.d.ts.map +1 -0
- package/dist/commands/update.js +2459 -0
- package/dist/commands/update.js.map +1 -0
- package/dist/commands/upgrade.d.ts +28 -0
- package/dist/commands/upgrade.d.ts.map +1 -0
- package/dist/commands/upgrade.js +84 -0
- package/dist/commands/upgrade.js.map +1 -0
- package/dist/commands/validate-rules.d.ts +6 -0
- package/dist/commands/validate-rules.d.ts.map +1 -0
- package/dist/commands/validate-rules.js +33 -0
- package/dist/commands/validate-rules.js.map +1 -0
- package/dist/commands/workflow.d.ts +35 -0
- package/dist/commands/workflow.d.ts.map +1 -0
- package/dist/commands/workflow.js +220 -0
- package/dist/commands/workflow.js.map +1 -0
- package/dist/configurators/cursor.d.ts +21 -0
- package/dist/configurators/cursor.d.ts.map +1 -0
- package/dist/configurators/cursor.js +51 -0
- package/dist/configurators/cursor.js.map +1 -0
- package/dist/configurators/index.d.ts +68 -0
- package/dist/configurators/index.d.ts.map +1 -0
- package/dist/configurators/index.js +170 -0
- package/dist/configurators/index.js.map +1 -0
- package/dist/configurators/shared.d.ts +200 -0
- package/dist/configurators/shared.d.ts.map +1 -0
- package/dist/configurators/shared.js +602 -0
- package/dist/configurators/shared.js.map +1 -0
- package/dist/configurators/workflow.d.ts +45 -0
- package/dist/configurators/workflow.d.ts.map +1 -0
- package/dist/configurators/workflow.js +256 -0
- package/dist/configurators/workflow.js.map +1 -0
- package/dist/constants/paths.d.ts +93 -0
- package/dist/constants/paths.d.ts.map +1 -0
- package/dist/constants/paths.js +106 -0
- package/dist/constants/paths.js.map +1 -0
- package/dist/constants/version.d.ts +9 -0
- package/dist/constants/version.d.ts.map +1 -0
- package/dist/constants/version.js +15 -0
- package/dist/constants/version.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/migrations/index.d.ts +62 -0
- package/dist/migrations/index.d.ts.map +1 -0
- package/dist/migrations/index.js +187 -0
- package/dist/migrations/index.js.map +1 -0
- package/dist/migrations/manifests/0.1.0.json +9 -0
- package/dist/migrations/manifests/0.1.1.json +9 -0
- package/dist/migrations/manifests/0.1.2.json +9 -0
- package/dist/migrations/manifests/0.1.3.json +9 -0
- package/dist/migrations/manifests/0.1.4.json +9 -0
- package/dist/migrations/manifests/0.2.1.json +9 -0
- package/dist/migrations/manifests/0.2.10.json +374 -0
- package/dist/migrations/manifests/0.2.2.json +9 -0
- package/dist/migrations/manifests/0.2.3.json +9 -0
- package/dist/migrations/manifests/0.2.4.json +9 -0
- package/dist/migrations/manifests/0.2.5.json +9 -0
- package/dist/migrations/manifests/0.2.6.json +9 -0
- package/dist/migrations/manifests/0.2.7.json +9 -0
- package/dist/migrations/manifests/0.2.8.json +9 -0
- package/dist/migrations/manifests/0.2.9.json +9 -0
- package/dist/migrations/manifests/0.3.0.json +89 -0
- package/dist/migrations/manifests/0.3.1.json +32 -0
- package/dist/migrations/manifests/0.3.2.json +16 -0
- package/dist/migrations/manifests/0.3.3.json +9 -0
- package/dist/migrations/manifests/0.3.4.json +9 -0
- package/dist/migrations/manifests/0.3.5.json +9 -0
- package/dist/migrations/manifests/0.3.6.json +9 -0
- package/dist/migrations/manifests/0.4.0.json +9 -0
- package/dist/migrations/manifests/0.4.1.json +9 -0
- package/dist/migrations/manifests/0.4.2.json +9 -0
- package/dist/migrations/manifests/0.4.3.json +9 -0
- package/dist/migrations/manifests/0.5.0-beta.0.json +9 -0
- package/dist/migrations/manifests/0.5.0-beta.1.json +9 -0
- package/dist/migrations/manifests/0.5.0-beta.2.json +9 -0
- package/dist/migrations/manifests/0.5.0-beta.3.json +9 -0
- package/dist/migrations/manifests/0.5.0-beta.4.json +9 -0
- package/dist/migrations/manifests/0.5.0-beta.5.json +9 -0
- package/dist/pactile/adapters/codex/index.d.ts +75 -0
- package/dist/pactile/adapters/codex/index.d.ts.map +1 -0
- package/dist/pactile/adapters/codex/index.js +269 -0
- package/dist/pactile/adapters/codex/index.js.map +1 -0
- package/dist/pactile/adapters/cursor/index.d.ts +60 -0
- package/dist/pactile/adapters/cursor/index.d.ts.map +1 -0
- package/dist/pactile/adapters/cursor/index.js +186 -0
- package/dist/pactile/adapters/cursor/index.js.map +1 -0
- package/dist/pactile/adapters/index.d.ts +4 -0
- package/dist/pactile/adapters/index.d.ts.map +1 -0
- package/dist/pactile/adapters/index.js +4 -0
- package/dist/pactile/adapters/index.js.map +1 -0
- package/dist/pactile/adoption/bindings.d.ts +20 -0
- package/dist/pactile/adoption/bindings.d.ts.map +1 -0
- package/dist/pactile/adoption/bindings.js +99 -0
- package/dist/pactile/adoption/bindings.js.map +1 -0
- package/dist/pactile/adoption/discovery.d.ts +8 -0
- package/dist/pactile/adoption/discovery.d.ts.map +1 -0
- package/dist/pactile/adoption/discovery.js +159 -0
- package/dist/pactile/adoption/discovery.js.map +1 -0
- package/dist/pactile/adoption/inventory.d.ts +28 -0
- package/dist/pactile/adoption/inventory.d.ts.map +1 -0
- package/dist/pactile/adoption/inventory.js +261 -0
- package/dist/pactile/adoption/inventory.js.map +1 -0
- package/dist/pactile/adoption/safety.d.ts +19 -0
- package/dist/pactile/adoption/safety.d.ts.map +1 -0
- package/dist/pactile/adoption/safety.js +88 -0
- package/dist/pactile/adoption/safety.js.map +1 -0
- package/dist/pactile/adoption/workflow.d.ts +31 -0
- package/dist/pactile/adoption/workflow.d.ts.map +1 -0
- package/dist/pactile/adoption/workflow.js +259 -0
- package/dist/pactile/adoption/workflow.js.map +1 -0
- package/dist/pactile/compat/cli-options.d.ts +9 -0
- package/dist/pactile/compat/cli-options.d.ts.map +1 -0
- package/dist/pactile/compat/cli-options.js +9 -0
- package/dist/pactile/compat/cli-options.js.map +1 -0
- package/dist/pactile/compat/init-context.d.ts +16 -0
- package/dist/pactile/compat/init-context.d.ts.map +1 -0
- package/dist/pactile/compat/init-context.js +87 -0
- package/dist/pactile/compat/init-context.js.map +1 -0
- package/dist/pactile/compat/legacy-migrations.d.ts +8 -0
- package/dist/pactile/compat/legacy-migrations.d.ts.map +1 -0
- package/dist/pactile/compat/legacy-migrations.js +17 -0
- package/dist/pactile/compat/legacy-migrations.js.map +1 -0
- package/dist/pactile/compat/retired-alternate-client.d.ts +42 -0
- package/dist/pactile/compat/retired-alternate-client.d.ts.map +1 -0
- package/dist/pactile/compat/retired-alternate-client.js +153 -0
- package/dist/pactile/compat/retired-alternate-client.js.map +1 -0
- package/dist/pactile/compat/update-residue.d.ts +4 -0
- package/dist/pactile/compat/update-residue.d.ts.map +1 -0
- package/dist/pactile/compat/update-residue.js +55 -0
- package/dist/pactile/compat/update-residue.js.map +1 -0
- package/dist/pactile/exit/index.d.ts +3 -0
- package/dist/pactile/exit/index.d.ts.map +1 -0
- package/dist/pactile/exit/index.js +3 -0
- package/dist/pactile/exit/index.js.map +1 -0
- package/dist/pactile/exit/receipt.d.ts +23 -0
- package/dist/pactile/exit/receipt.d.ts.map +1 -0
- package/dist/pactile/exit/receipt.js +64 -0
- package/dist/pactile/exit/receipt.js.map +1 -0
- package/dist/pactile/exit/service.d.ts +107 -0
- package/dist/pactile/exit/service.d.ts.map +1 -0
- package/dist/pactile/exit/service.js +774 -0
- package/dist/pactile/exit/service.js.map +1 -0
- package/dist/pactile/index.d.ts +26 -0
- package/dist/pactile/index.d.ts.map +1 -0
- package/dist/pactile/index.js +22 -0
- package/dist/pactile/index.js.map +1 -0
- package/dist/pactile/lifecycle/command-runner.d.ts +26 -0
- package/dist/pactile/lifecycle/command-runner.d.ts.map +1 -0
- package/dist/pactile/lifecycle/command-runner.js +129 -0
- package/dist/pactile/lifecycle/command-runner.js.map +1 -0
- package/dist/pactile/lifecycle/default-adapters.d.ts +5 -0
- package/dist/pactile/lifecycle/default-adapters.d.ts.map +1 -0
- package/dist/pactile/lifecycle/default-adapters.js +136 -0
- package/dist/pactile/lifecycle/default-adapters.js.map +1 -0
- package/dist/pactile/lifecycle/index.d.ts +6 -0
- package/dist/pactile/lifecycle/index.d.ts.map +1 -0
- package/dist/pactile/lifecycle/index.js +6 -0
- package/dist/pactile/lifecycle/index.js.map +1 -0
- package/dist/pactile/lifecycle/legacy-import.d.ts +16 -0
- package/dist/pactile/lifecycle/legacy-import.d.ts.map +1 -0
- package/dist/pactile/lifecycle/legacy-import.js +228 -0
- package/dist/pactile/lifecycle/legacy-import.js.map +1 -0
- package/dist/pactile/lifecycle/orchestrator.d.ts +109 -0
- package/dist/pactile/lifecycle/orchestrator.d.ts.map +1 -0
- package/dist/pactile/lifecycle/orchestrator.js +1030 -0
- package/dist/pactile/lifecycle/orchestrator.js.map +1 -0
- package/dist/pactile/lifecycle/project-files.d.ts +28 -0
- package/dist/pactile/lifecycle/project-files.d.ts.map +1 -0
- package/dist/pactile/lifecycle/project-files.js +297 -0
- package/dist/pactile/lifecycle/project-files.js.map +1 -0
- package/dist/pactile/middleware/index.d.ts +3 -0
- package/dist/pactile/middleware/index.d.ts.map +1 -0
- package/dist/pactile/middleware/index.js +2 -0
- package/dist/pactile/middleware/index.js.map +1 -0
- package/dist/pactile/middleware/manifest-loader.d.ts +22 -0
- package/dist/pactile/middleware/manifest-loader.d.ts.map +1 -0
- package/dist/pactile/middleware/manifest-loader.js +228 -0
- package/dist/pactile/middleware/manifest-loader.js.map +1 -0
- package/dist/pactile/migration/index.d.ts +2 -0
- package/dist/pactile/migration/index.d.ts.map +1 -0
- package/dist/pactile/migration/index.js +2 -0
- package/dist/pactile/migration/index.js.map +1 -0
- package/dist/pactile/migration/transaction.d.ts +54 -0
- package/dist/pactile/migration/transaction.d.ts.map +1 -0
- package/dist/pactile/migration/transaction.js +445 -0
- package/dist/pactile/migration/transaction.js.map +1 -0
- package/dist/pactile/projection/managed-block.d.ts +32 -0
- package/dist/pactile/projection/managed-block.d.ts.map +1 -0
- package/dist/pactile/projection/managed-block.js +78 -0
- package/dist/pactile/projection/managed-block.js.map +1 -0
- package/dist/pactile/projection/planner.d.ts +65 -0
- package/dist/pactile/projection/planner.d.ts.map +1 -0
- package/dist/pactile/projection/planner.js +349 -0
- package/dist/pactile/projection/planner.js.map +1 -0
- package/dist/pactile/projection/shared/index.d.ts +38 -0
- package/dist/pactile/projection/shared/index.d.ts.map +1 -0
- package/dist/pactile/projection/shared/index.js +186 -0
- package/dist/pactile/projection/shared/index.js.map +1 -0
- package/dist/pactile/projection/store.d.ts +72 -0
- package/dist/pactile/projection/store.d.ts.map +1 -0
- package/dist/pactile/projection/store.js +669 -0
- package/dist/pactile/projection/store.js.map +1 -0
- package/dist/pactile/projection/structured-merge.d.ts +11 -0
- package/dist/pactile/projection/structured-merge.d.ts.map +1 -0
- package/dist/pactile/projection/structured-merge.js +347 -0
- package/dist/pactile/projection/structured-merge.js.map +1 -0
- package/dist/pactile/providers/index.d.ts +3 -0
- package/dist/pactile/providers/index.d.ts.map +1 -0
- package/dist/pactile/providers/index.js +3 -0
- package/dist/pactile/providers/index.js.map +1 -0
- package/dist/pactile/providers/probes.d.ts +55 -0
- package/dist/pactile/providers/probes.d.ts.map +1 -0
- package/dist/pactile/providers/probes.js +164 -0
- package/dist/pactile/providers/probes.js.map +1 -0
- package/dist/pactile/registry.d.ts +64 -0
- package/dist/pactile/registry.d.ts.map +1 -0
- package/dist/pactile/registry.js +196 -0
- package/dist/pactile/registry.js.map +1 -0
- package/dist/pactile/retrieval/boundary.d.ts +18 -0
- package/dist/pactile/retrieval/boundary.d.ts.map +1 -0
- package/dist/pactile/retrieval/boundary.js +113 -0
- package/dist/pactile/retrieval/boundary.js.map +1 -0
- package/dist/pactile/retrieval/evidence.d.ts +9 -0
- package/dist/pactile/retrieval/evidence.d.ts.map +1 -0
- package/dist/pactile/retrieval/evidence.js +327 -0
- package/dist/pactile/retrieval/evidence.js.map +1 -0
- package/dist/pactile/retrieval/index.d.ts +4 -0
- package/dist/pactile/retrieval/index.d.ts.map +1 -0
- package/dist/pactile/retrieval/index.js +4 -0
- package/dist/pactile/retrieval/index.js.map +1 -0
- package/dist/pactile/retrieval/planner.d.ts +23 -0
- package/dist/pactile/retrieval/planner.d.ts.map +1 -0
- package/dist/pactile/retrieval/planner.js +702 -0
- package/dist/pactile/retrieval/planner.js.map +1 -0
- package/dist/pactile/retrieval/types.d.ts +108 -0
- package/dist/pactile/retrieval/types.d.ts.map +1 -0
- package/dist/pactile/retrieval/types.js +36 -0
- package/dist/pactile/retrieval/types.js.map +1 -0
- package/dist/pactile/runtime/case-fold.d.ts +2 -0
- package/dist/pactile/runtime/case-fold.d.ts.map +1 -0
- package/dist/pactile/runtime/case-fold.js +31 -0
- package/dist/pactile/runtime/case-fold.js.map +1 -0
- package/dist/pactile/runtime/index.d.ts +8 -0
- package/dist/pactile/runtime/index.d.ts.map +1 -0
- package/dist/pactile/runtime/index.js +5 -0
- package/dist/pactile/runtime/index.js.map +1 -0
- package/dist/pactile/runtime/json-api.d.ts +15 -0
- package/dist/pactile/runtime/json-api.d.ts.map +1 -0
- package/dist/pactile/runtime/json-api.js +68 -0
- package/dist/pactile/runtime/json-api.js.map +1 -0
- package/dist/pactile/runtime/paths.d.ts +59 -0
- package/dist/pactile/runtime/paths.d.ts.map +1 -0
- package/dist/pactile/runtime/paths.js +201 -0
- package/dist/pactile/runtime/paths.js.map +1 -0
- package/dist/pactile/runtime/stores.d.ts +54 -0
- package/dist/pactile/runtime/stores.d.ts.map +1 -0
- package/dist/pactile/runtime/stores.js +375 -0
- package/dist/pactile/runtime/stores.js.map +1 -0
- package/dist/pactile/runtime/unicode-nfc-data.d.ts +12 -0
- package/dist/pactile/runtime/unicode-nfc-data.d.ts.map +1 -0
- package/dist/pactile/runtime/unicode-nfc-data.js +8 -0
- package/dist/pactile/runtime/unicode-nfc-data.js.map +1 -0
- package/dist/pactile/runtime/unicode-nfc.d.ts +3 -0
- package/dist/pactile/runtime/unicode-nfc.d.ts.map +1 -0
- package/dist/pactile/runtime/unicode-nfc.js +77 -0
- package/dist/pactile/runtime/unicode-nfc.js.map +1 -0
- package/dist/pactile/tiles/catalog.d.ts +35 -0
- package/dist/pactile/tiles/catalog.d.ts.map +1 -0
- package/dist/pactile/tiles/catalog.js +235 -0
- package/dist/pactile/tiles/catalog.js.map +1 -0
- package/dist/pactile/tiles/compiler.d.ts +54 -0
- package/dist/pactile/tiles/compiler.d.ts.map +1 -0
- package/dist/pactile/tiles/compiler.js +270 -0
- package/dist/pactile/tiles/compiler.js.map +1 -0
- package/dist/pactile/tiles/content/baseline/index.d.ts +5 -0
- package/dist/pactile/tiles/content/baseline/index.d.ts.map +1 -0
- package/dist/pactile/tiles/content/baseline/index.js +115 -0
- package/dist/pactile/tiles/content/baseline/index.js.map +1 -0
- package/dist/pactile/tiles/content/index.d.ts +4 -0
- package/dist/pactile/tiles/content/index.d.ts.map +1 -0
- package/dist/pactile/tiles/content/index.js +4 -0
- package/dist/pactile/tiles/content/index.js.map +1 -0
- package/dist/pactile/tiles/content/ondemand/index.d.ts +5 -0
- package/dist/pactile/tiles/content/ondemand/index.d.ts.map +1 -0
- package/dist/pactile/tiles/content/ondemand/index.js +184 -0
- package/dist/pactile/tiles/content/ondemand/index.js.map +1 -0
- package/dist/pactile/tiles/content/source.d.ts +29 -0
- package/dist/pactile/tiles/content/source.d.ts.map +1 -0
- package/dist/pactile/tiles/content/source.js +86 -0
- package/dist/pactile/tiles/content/source.js.map +1 -0
- package/dist/pactile/tiles/loader.d.ts +31 -0
- package/dist/pactile/tiles/loader.d.ts.map +1 -0
- package/dist/pactile/tiles/loader.js +139 -0
- package/dist/pactile/tiles/loader.js.map +1 -0
- package/dist/pactile/tiles/safe-yaml.d.ts +11 -0
- package/dist/pactile/tiles/safe-yaml.d.ts.map +1 -0
- package/dist/pactile/tiles/safe-yaml.js +212 -0
- package/dist/pactile/tiles/safe-yaml.js.map +1 -0
- package/dist/templates/common/bundled-skills/pactile-check/SKILL.md +161 -0
- package/dist/templates/common/bundled-skills/pactile-check/references/fowler-12-smells.md +28 -0
- package/dist/templates/common/bundled-skills/pactile-handoff/SKILL.md +117 -0
- package/dist/templates/common/bundled-skills/pactile-meta/SKILL.md +75 -0
- package/dist/templates/common/bundled-skills/pactile-meta/references/customize-local/add-project-local-conventions.md +83 -0
- package/dist/templates/common/bundled-skills/pactile-meta/references/customize-local/change-agents.md +47 -0
- package/dist/templates/common/bundled-skills/pactile-meta/references/customize-local/change-context-loading.md +84 -0
- package/dist/templates/common/bundled-skills/pactile-meta/references/customize-local/change-hooks.md +57 -0
- package/dist/templates/common/bundled-skills/pactile-meta/references/customize-local/change-skills-or-commands.md +77 -0
- package/dist/templates/common/bundled-skills/pactile-meta/references/customize-local/change-spec-structure.md +83 -0
- package/dist/templates/common/bundled-skills/pactile-meta/references/customize-local/change-task-lifecycle.md +88 -0
- package/dist/templates/common/bundled-skills/pactile-meta/references/customize-local/change-workflow.md +65 -0
- package/dist/templates/common/bundled-skills/pactile-meta/references/customize-local/overview.md +55 -0
- package/dist/templates/common/bundled-skills/pactile-meta/references/local-architecture/context-injection.md +68 -0
- package/dist/templates/common/bundled-skills/pactile-meta/references/local-architecture/generated-files.md +83 -0
- package/dist/templates/common/bundled-skills/pactile-meta/references/local-architecture/overview.md +51 -0
- package/dist/templates/common/bundled-skills/pactile-meta/references/local-architecture/spec-system.md +102 -0
- package/dist/templates/common/bundled-skills/pactile-meta/references/local-architecture/task-system.md +133 -0
- package/dist/templates/common/bundled-skills/pactile-meta/references/local-architecture/workflow.md +75 -0
- package/dist/templates/common/bundled-skills/pactile-meta/references/local-architecture/workspace-memory.md +71 -0
- package/dist/templates/common/bundled-skills/pactile-meta/references/platform-files/agents.md +69 -0
- package/dist/templates/common/bundled-skills/pactile-meta/references/platform-files/hooks-and-settings.md +59 -0
- package/dist/templates/common/bundled-skills/pactile-meta/references/platform-files/overview.md +45 -0
- package/dist/templates/common/bundled-skills/pactile-meta/references/platform-files/platform-map.md +45 -0
- package/dist/templates/common/bundled-skills/pactile-meta/references/platform-files/skills-and-commands.md +108 -0
- package/dist/templates/common/bundled-skills/pactile-micro-grill/SKILL.md +68 -0
- package/dist/templates/common/bundled-skills/pactile-skill-creator/SKILL.md +47 -0
- package/dist/templates/common/bundled-skills/pactile-skill-creator/references/authoring-rules.md +171 -0
- package/dist/templates/common/bundled-skills/pactile-skill-creator/references/general-authoring.md +189 -0
- package/dist/templates/common/bundled-skills/pactile-skill-creator/references/pactile-skill-locations.md +52 -0
- package/dist/templates/common/bundled-skills/pactile-skill-creator/references/review-checklist.md +52 -0
- package/dist/templates/common/bundled-skills/pactile-spec-bootstrap/SKILL.md +41 -0
- package/dist/templates/common/bundled-skills/pactile-spec-bootstrap/references/mcp-setup.md +90 -0
- package/dist/templates/common/bundled-skills/pactile-spec-bootstrap/references/repository-analysis.md +59 -0
- package/dist/templates/common/bundled-skills/pactile-spec-bootstrap/references/spec-task-planning.md +61 -0
- package/dist/templates/common/bundled-skills/pactile-spec-bootstrap/references/spec-writing.md +70 -0
- package/dist/templates/common/bundled-skills/smart-search-cli/SKILL.md +393 -0
- package/dist/templates/common/bundled-skills/smart-search-cli/agents/openai.yaml +3 -0
- package/dist/templates/common/bundled-skills/smart-search-cli/examples/batch-search.md +98 -0
- package/dist/templates/common/bundled-skills/smart-search-cli/examples/evidence-gathering.md +89 -0
- package/dist/templates/common/bundled-skills/smart-search-cli/references/cli-contract.md +323 -0
- package/dist/templates/common/commands/continue.md +62 -0
- package/dist/templates/common/commands/finish-work.md +82 -0
- package/dist/templates/common/commands/start.md +66 -0
- package/dist/templates/common/index.d.ts +68 -0
- package/dist/templates/common/index.d.ts.map +1 -0
- package/dist/templates/common/index.js +123 -0
- package/dist/templates/common/index.js.map +1 -0
- package/dist/templates/common/optional-skills/chrome-cdp/SKILL.md +179 -0
- package/dist/templates/common/optional-skills/chrome-cdp/examples/fetch-hook-api-capture.md +149 -0
- package/dist/templates/common/optional-skills/chrome-cdp/scripts/cdp.mjs +904 -0
- package/dist/templates/common/skills/before-dev.md +35 -0
- package/dist/templates/common/skills/brainstorm.md +204 -0
- package/dist/templates/common/skills/break-loop.md +125 -0
- package/dist/templates/common/skills/update-spec.md +364 -0
- package/dist/templates/cursor/agents/pactile-check.md +58 -0
- package/dist/templates/cursor/agents/pactile-implement.md +56 -0
- package/dist/templates/cursor/agents/pactile-research.md +51 -0
- package/dist/templates/cursor/commands/handoff.md +101 -0
- package/dist/templates/cursor/fixtures/expected-rules.d.ts +14 -0
- package/dist/templates/cursor/fixtures/expected-rules.d.ts.map +1 -0
- package/dist/templates/cursor/fixtures/expected-rules.js +20 -0
- package/dist/templates/cursor/fixtures/expected-rules.js.map +1 -0
- package/dist/templates/cursor/hooks.json +52 -0
- package/dist/templates/cursor/index.d.ts +19 -0
- package/dist/templates/cursor/index.d.ts.map +1 -0
- package/dist/templates/cursor/index.js +19 -0
- package/dist/templates/cursor/index.js.map +1 -0
- package/dist/templates/cursor/rules/pactile-bootstrap.mdc +18 -0
- package/dist/templates/cursor/worktrees.json +11 -0
- package/dist/templates/extract.d.ts +38 -0
- package/dist/templates/extract.d.ts.map +1 -0
- package/dist/templates/extract.js +120 -0
- package/dist/templates/extract.js.map +1 -0
- package/dist/templates/markdown/agents.md +14 -0
- package/dist/templates/markdown/framework/artifact-locale-guide.md.txt +93 -0
- package/dist/templates/markdown/framework/cursor-context-injection-guide.md.txt +85 -0
- package/dist/templates/markdown/framework/cursor-native-modes-guide.md.txt +239 -0
- package/dist/templates/markdown/framework/cursor-semantic-compliance.md.txt +41 -0
- package/dist/templates/markdown/framework/cursor-subagent-policy.md.txt +90 -0
- package/dist/templates/markdown/framework/dogfood-only-surfaces.md.txt +28 -0
- package/dist/templates/markdown/framework/execution-strategy.md.txt +45 -0
- package/dist/templates/markdown/framework/index.md.txt +31 -0
- package/dist/templates/markdown/framework/injection-budget-guide.md.txt +111 -0
- package/dist/templates/markdown/framework/internal-skills-cursor-reachability.md.txt +45 -0
- package/dist/templates/markdown/framework/middleware-protocol.md.txt +238 -0
- package/dist/templates/markdown/framework/parallel-first-execution.md.txt +116 -0
- package/dist/templates/markdown/framework/prd-grill-frontier.md.txt +105 -0
- package/dist/templates/markdown/framework/release-boundary.md.txt +30 -0
- package/dist/templates/markdown/framework/retrieval-daily-guide.md.txt +199 -0
- package/dist/templates/markdown/framework/upgrade.md.txt +15 -0
- package/dist/templates/markdown/framework/verification-strength-guide.md.txt +185 -0
- package/dist/templates/markdown/gitignore.txt +15 -0
- package/dist/templates/markdown/index.d.ts +59 -0
- package/dist/templates/markdown/index.d.ts.map +1 -0
- package/dist/templates/markdown/index.js +144 -0
- package/dist/templates/markdown/index.js.map +1 -0
- package/dist/templates/markdown/prompts/run-semantic-slice-12.md.txt +25 -0
- package/dist/templates/markdown/spec/backend/database-guidelines.md.txt +51 -0
- package/dist/templates/markdown/spec/backend/directory-structure.md.txt +54 -0
- package/dist/templates/markdown/spec/backend/error-handling.md.txt +51 -0
- package/dist/templates/markdown/spec/backend/index.md.txt +38 -0
- package/dist/templates/markdown/spec/backend/logging-guidelines.md.txt +51 -0
- package/dist/templates/markdown/spec/backend/quality-guidelines.md.txt +51 -0
- package/dist/templates/markdown/spec/frontend/component-guidelines.md.txt +59 -0
- package/dist/templates/markdown/spec/frontend/directory-structure.md.txt +54 -0
- package/dist/templates/markdown/spec/frontend/hook-guidelines.md.txt +51 -0
- package/dist/templates/markdown/spec/frontend/index.md.txt +39 -0
- package/dist/templates/markdown/spec/frontend/quality-guidelines.md.txt +51 -0
- package/dist/templates/markdown/spec/frontend/state-management.md.txt +51 -0
- package/dist/templates/markdown/spec/frontend/type-safety.md.txt +51 -0
- package/dist/templates/markdown/spec/guides/code-reuse-thinking-guide.md.txt +174 -0
- package/dist/templates/markdown/spec/guides/cross-layer-thinking-guide.md.txt +162 -0
- package/dist/templates/markdown/spec/guides/cross-platform-thinking-guide.md.txt +634 -0
- package/dist/templates/markdown/spec/guides/debug-loop-guide.md.txt +227 -0
- package/dist/templates/markdown/spec/guides/durable-learning-decision-guide.md.txt +76 -0
- package/dist/templates/markdown/spec/guides/e2e-walkthrough-guide.md.txt +93 -0
- package/dist/templates/markdown/spec/guides/index.md.txt +131 -0
- package/dist/templates/markdown/spec/guides/prototype-guide.md.txt +139 -0
- package/dist/templates/markdown/spec/guides/test-discipline-guide.md.txt +179 -0
- package/dist/templates/markdown/workspace-index.md +125 -0
- package/dist/templates/markdown/worktree.yaml.txt +58 -0
- package/dist/templates/pactile/CONTEXT.md +113 -0
- package/dist/templates/pactile/config/execution-strategy-rules.json +31 -0
- package/dist/templates/pactile/config.yaml +130 -0
- package/dist/templates/pactile/docs/adr/README.md +21 -0
- package/dist/templates/pactile/gitignore.txt +35 -0
- package/dist/templates/pactile/index.d.ts +134 -0
- package/dist/templates/pactile/index.d.ts.map +1 -0
- package/dist/templates/pactile/index.js +316 -0
- package/dist/templates/pactile/index.js.map +1 -0
- package/dist/templates/pactile/modules/approval-personal/contract.md +43 -0
- package/dist/templates/pactile/modules/candidate-pool/contract.md +37 -0
- package/dist/templates/pactile/modules/catalog.d.ts +32 -0
- package/dist/templates/pactile/modules/catalog.d.ts.map +1 -0
- package/dist/templates/pactile/modules/catalog.js +46 -0
- package/dist/templates/pactile/modules/catalog.js.map +1 -0
- package/dist/templates/pactile/modules/close-basic/contract.md +38 -0
- package/dist/templates/pactile/modules/context-progressive/contract.md +44 -0
- package/dist/templates/pactile/modules/debug-recovery/contract.md +44 -0
- package/dist/templates/pactile/modules/define-basic/contract.md +39 -0
- package/dist/templates/pactile/modules/define-extended/contract.md +45 -0
- package/dist/templates/pactile/modules/execute-agent/contract.md +38 -0
- package/dist/templates/pactile/modules/independent-check/contract.md +35 -0
- package/dist/templates/pactile/modules/index.json +133 -0
- package/dist/templates/pactile/modules/intake-basic/contract.md +34 -0
- package/dist/templates/pactile/modules/observability-local/contract.md +31 -0
- package/dist/templates/pactile/modules/parent-child/contract.md +45 -0
- package/dist/templates/pactile/modules/personal-memory/contract.md +56 -0
- package/dist/templates/pactile/modules/retention-storage/contract.md +43 -0
- package/dist/templates/pactile/modules/retrieval-extended/contract.md +77 -0
- package/dist/templates/pactile/modules/session-transfer/contract.md +41 -0
- package/dist/templates/pactile/modules/spec-learning/contract.md +50 -0
- package/dist/templates/pactile/modules/vcs-integration/contract.md +46 -0
- package/dist/templates/pactile/modules/verify-basic/contract.md +38 -0
- package/dist/templates/pactile/modules/worker-orchestration/contract.md +47 -0
- package/dist/templates/pactile/pool/README.md +149 -0
- package/dist/templates/pactile/pool/items/.gitkeep +0 -0
- package/dist/templates/pactile/pool/plan.md +50 -0
- package/dist/templates/pactile/scripts/__init__.py +5 -0
- package/dist/templates/pactile/scripts/add_session.py +547 -0
- package/dist/templates/pactile/scripts/build_context_pack.py +17 -0
- package/dist/templates/pactile/scripts/build_retrieval_pack.py +376 -0
- package/dist/templates/pactile/scripts/codegraph_session_smoke.py +76 -0
- package/dist/templates/pactile/scripts/common/__init__.py +103 -0
- package/dist/templates/pactile/scripts/common/active_task.py +576 -0
- package/dist/templates/pactile/scripts/common/adapter_middleware.py +1373 -0
- package/dist/templates/pactile/scripts/common/artifact_locale.py +303 -0
- package/dist/templates/pactile/scripts/common/artifact_search.py +587 -0
- package/dist/templates/pactile/scripts/common/cli_adapter.py +135 -0
- package/dist/templates/pactile/scripts/common/cli_environment.py +155 -0
- package/dist/templates/pactile/scripts/common/codebase_retrieval_router.py +1339 -0
- package/dist/templates/pactile/scripts/common/config.py +497 -0
- package/dist/templates/pactile/scripts/common/context_pack.py +371 -0
- package/dist/templates/pactile/scripts/common/cursor_retrieval_env.py +31 -0
- package/dist/templates/pactile/scripts/common/developer.py +190 -0
- package/dist/templates/pactile/scripts/common/execution_strategy.py +268 -0
- package/dist/templates/pactile/scripts/common/full_quality.py +237 -0
- package/dist/templates/pactile/scripts/common/git.py +37 -0
- package/dist/templates/pactile/scripts/common/git_context.py +198 -0
- package/dist/templates/pactile/scripts/common/injection_budget.py +317 -0
- package/dist/templates/pactile/scripts/common/io.py +37 -0
- package/dist/templates/pactile/scripts/common/kernel_command.py +369 -0
- package/dist/templates/pactile/scripts/common/lite_context.py +280 -0
- package/dist/templates/pactile/scripts/common/log.py +45 -0
- package/dist/templates/pactile/scripts/common/ondemand_topology.py +419 -0
- package/dist/templates/pactile/scripts/common/packages_context.py +239 -0
- package/dist/templates/pactile/scripts/common/pactile_config.py +131 -0
- package/dist/templates/pactile/scripts/common/parallel_declaration.py +369 -0
- package/dist/templates/pactile/scripts/common/parent_orchestration.py +1198 -0
- package/dist/templates/pactile/scripts/common/paths.py +756 -0
- package/dist/templates/pactile/scripts/common/pool_refs.py +119 -0
- package/dist/templates/pactile/scripts/common/pool_slice.py +269 -0
- package/dist/templates/pactile/scripts/common/pool_store.py +766 -0
- package/dist/templates/pactile/scripts/common/project_file_stats.py +91 -0
- package/dist/templates/pactile/scripts/common/retrieval_adapter_metadata.py +943 -0
- package/dist/templates/pactile/scripts/common/retrieval_agent_instructions.py +123 -0
- package/dist/templates/pactile/scripts/common/retrieval_evidence.py +915 -0
- package/dist/templates/pactile/scripts/common/retrieval_pack.py +422 -0
- package/dist/templates/pactile/scripts/common/retrieval_pack_context.py +122 -0
- package/dist/templates/pactile/scripts/common/retrieval_plan_gate.py +61 -0
- package/dist/templates/pactile/scripts/common/retrieval_result_ranking.py +104 -0
- package/dist/templates/pactile/scripts/common/retrieval_tool_classification.py +166 -0
- package/dist/templates/pactile/scripts/common/safe_commit.py +285 -0
- package/dist/templates/pactile/scripts/common/semantic_plan_gate.py +53 -0
- package/dist/templates/pactile/scripts/common/session_context.py +1213 -0
- package/dist/templates/pactile/scripts/common/session_memory.py +386 -0
- package/dist/templates/pactile/scripts/common/session_pack.py +886 -0
- package/dist/templates/pactile/scripts/common/smart_search_evidence.py +514 -0
- package/dist/templates/pactile/scripts/common/smart_search_resolve.py +150 -0
- package/dist/templates/pactile/scripts/common/subagent_dispatch.py +592 -0
- package/dist/templates/pactile/scripts/common/task_context.py +241 -0
- package/dist/templates/pactile/scripts/common/task_dashboard.py +286 -0
- package/dist/templates/pactile/scripts/common/task_dependencies.py +648 -0
- package/dist/templates/pactile/scripts/common/task_gates.py +2478 -0
- package/dist/templates/pactile/scripts/common/task_map.py +703 -0
- package/dist/templates/pactile/scripts/common/task_queue.py +188 -0
- package/dist/templates/pactile/scripts/common/task_store.py +2252 -0
- package/dist/templates/pactile/scripts/common/task_utils.py +274 -0
- package/dist/templates/pactile/scripts/common/tasks.py +231 -0
- package/dist/templates/pactile/scripts/common/test_adapter_middleware.py +199 -0
- package/dist/templates/pactile/scripts/common/test_depends_mode_block.py +509 -0
- package/dist/templates/pactile/scripts/common/test_full_quality.py +197 -0
- package/dist/templates/pactile/scripts/common/test_kernel_command.py +336 -0
- package/dist/templates/pactile/scripts/common/test_lite_path.py +190 -0
- package/dist/templates/pactile/scripts/common/test_observable_defaults.py +141 -0
- package/dist/templates/pactile/scripts/common/test_ondemand_topology.py +237 -0
- package/dist/templates/pactile/scripts/common/test_parallel_declaration.py +264 -0
- package/dist/templates/pactile/scripts/common/test_pool_slice.py +198 -0
- package/dist/templates/pactile/scripts/common/test_pool_store.py +452 -0
- package/dist/templates/pactile/scripts/common/test_retrieval_arbitration.py +331 -0
- package/dist/templates/pactile/scripts/common/test_task_dashboard.py +155 -0
- package/dist/templates/pactile/scripts/common/test_task_dependencies.py +329 -0
- package/dist/templates/pactile/scripts/common/test_task_store_kernel_patch.py +163 -0
- package/dist/templates/pactile/scripts/common/types.py +110 -0
- package/dist/templates/pactile/scripts/common/workflow_phase.py +194 -0
- package/dist/templates/pactile/scripts/compile_session_pack.py +15 -0
- package/dist/templates/pactile/scripts/cursor_retrieval_probe.py +64 -0
- package/dist/templates/pactile/scripts/cursor_retrieval_probe_prompt.md +33 -0
- package/dist/templates/pactile/scripts/generate_dispatch_prompt.py +182 -0
- package/dist/templates/pactile/scripts/get_context.py +19 -0
- package/dist/templates/pactile/scripts/get_developer.py +26 -0
- package/dist/templates/pactile/scripts/hooks/linear_sync.py +243 -0
- package/dist/templates/pactile/scripts/init_developer.py +51 -0
- package/dist/templates/pactile/scripts/injection_budget_probe.py +69 -0
- package/dist/templates/pactile/scripts/pool.py +237 -0
- package/dist/templates/pactile/scripts/rank_retrieval_candidates.py +98 -0
- package/dist/templates/pactile/scripts/retrieval_probe_matrix_template.json +43 -0
- package/dist/templates/pactile/scripts/route_codebase_retrieval.py +72 -0
- package/dist/templates/pactile/scripts/run_smart_search.py +12 -0
- package/dist/templates/pactile/scripts/score_evidence.py +131 -0
- package/dist/templates/pactile/scripts/search_artifacts.py +13 -0
- package/dist/templates/pactile/scripts/search_memory.py +12 -0
- package/dist/templates/pactile/scripts/spec_health_outcomes.py +160 -0
- package/dist/templates/pactile/scripts/task.py +1118 -0
- package/dist/templates/pactile/scripts/verify_evidence_probe.py +138 -0
- package/dist/templates/pactile/tasks/.gitkeep +0 -0
- package/dist/templates/pactile/tasks/locale/en/default-prd.md +27 -0
- package/dist/templates/pactile/tasks/locale/zh/default-prd.md +27 -0
- package/dist/templates/pactile/tasks/templates/release-execution/design.md +61 -0
- package/dist/templates/pactile/tasks/templates/release-execution/handoff-template.md +29 -0
- package/dist/templates/pactile/tasks/templates/release-execution/implement.md +29 -0
- package/dist/templates/pactile/tasks/templates/release-execution/prd.md +31 -0
- package/dist/templates/pactile/tasks/templates/release-readiness/design.md +50 -0
- package/dist/templates/pactile/tasks/templates/release-readiness/handoff-template.md +39 -0
- package/dist/templates/pactile/tasks/templates/release-readiness/implement.md +29 -0
- package/dist/templates/pactile/tasks/templates/release-readiness/prd.md +31 -0
- package/dist/templates/pactile/workflow.md +64 -0
- package/dist/templates/shared-hooks/event-bridge.py +121 -0
- package/dist/templates/shared-hooks/index.d.ts +50 -0
- package/dist/templates/shared-hooks/index.d.ts.map +1 -0
- package/dist/templates/shared-hooks/index.js +96 -0
- package/dist/templates/shared-hooks/index.js.map +1 -0
- package/dist/templates/shared-hooks/inject-retrieval-plan.py +217 -0
- package/dist/templates/shared-hooks/inject-shell-session-context.py +183 -0
- package/dist/templates/shared-hooks/inject-subagent-context.py +267 -0
- package/dist/templates/shared-hooks/inject-workflow-state.py +106 -0
- package/dist/templates/shared-hooks/rename-session-for-task.py +231 -0
- package/dist/templates/shared-hooks/research-end-retrieval-pack.py +345 -0
- package/dist/templates/shared-hooks/session-start.py +355 -0
- package/dist/templates/shared-hooks/spec-write-audit.py +173 -0
- package/dist/templates/template-utils.d.ts +28 -0
- package/dist/templates/template-utils.d.ts.map +1 -0
- package/dist/templates/template-utils.js +83 -0
- package/dist/templates/template-utils.js.map +1 -0
- package/dist/types/ai-tools.d.ts +102 -0
- package/dist/types/ai-tools.d.ts.map +1 -0
- package/dist/types/ai-tools.js +60 -0
- package/dist/types/ai-tools.js.map +1 -0
- package/dist/types/migration.d.ts +125 -0
- package/dist/types/migration.d.ts.map +1 -0
- package/dist/types/migration.js +8 -0
- package/dist/types/migration.js.map +1 -0
- package/dist/utils/agents-md.d.ts +27 -0
- package/dist/utils/agents-md.d.ts.map +1 -0
- package/dist/utils/agents-md.js +70 -0
- package/dist/utils/agents-md.js.map +1 -0
- package/dist/utils/codebase-retrieval-router.d.ts +31 -0
- package/dist/utils/codebase-retrieval-router.d.ts.map +1 -0
- package/dist/utils/codebase-retrieval-router.js +88 -0
- package/dist/utils/codebase-retrieval-router.js.map +1 -0
- package/dist/utils/compare-versions.d.ts +12 -0
- package/dist/utils/compare-versions.d.ts.map +1 -0
- package/dist/utils/compare-versions.js +86 -0
- package/dist/utils/compare-versions.js.map +1 -0
- package/dist/utils/cursor-retrieval-env.d.ts +17 -0
- package/dist/utils/cursor-retrieval-env.d.ts.map +1 -0
- package/dist/utils/cursor-retrieval-env.js +19 -0
- package/dist/utils/cursor-retrieval-env.js.map +1 -0
- package/dist/utils/cwd-guard.d.ts +38 -0
- package/dist/utils/cwd-guard.d.ts.map +1 -0
- package/dist/utils/cwd-guard.js +63 -0
- package/dist/utils/cwd-guard.js.map +1 -0
- package/dist/utils/file-writer.d.ts +36 -0
- package/dist/utils/file-writer.d.ts.map +1 -0
- package/dist/utils/file-writer.js +203 -0
- package/dist/utils/file-writer.js.map +1 -0
- package/dist/utils/manifest-prune.d.ts +59 -0
- package/dist/utils/manifest-prune.d.ts.map +1 -0
- package/dist/utils/manifest-prune.js +176 -0
- package/dist/utils/manifest-prune.js.map +1 -0
- package/dist/utils/mirror-check.d.ts +22 -0
- package/dist/utils/mirror-check.d.ts.map +1 -0
- package/dist/utils/mirror-check.js +90 -0
- package/dist/utils/mirror-check.js.map +1 -0
- package/dist/utils/normalize-text.d.ts +7 -0
- package/dist/utils/normalize-text.d.ts.map +1 -0
- package/dist/utils/normalize-text.js +16 -0
- package/dist/utils/normalize-text.js.map +1 -0
- package/dist/utils/p36-upgrade.d.ts +62 -0
- package/dist/utils/p36-upgrade.d.ts.map +1 -0
- package/dist/utils/p36-upgrade.js +165 -0
- package/dist/utils/p36-upgrade.js.map +1 -0
- package/dist/utils/posix.d.ts +13 -0
- package/dist/utils/posix.d.ts.map +1 -0
- package/dist/utils/posix.js +15 -0
- package/dist/utils/posix.js.map +1 -0
- package/dist/utils/post-update-smoke.d.ts +7 -0
- package/dist/utils/post-update-smoke.d.ts.map +1 -0
- package/dist/utils/post-update-smoke.js +40 -0
- package/dist/utils/post-update-smoke.js.map +1 -0
- package/dist/utils/project-capabilities.d.ts +82 -0
- package/dist/utils/project-capabilities.d.ts.map +1 -0
- package/dist/utils/project-capabilities.js +691 -0
- package/dist/utils/project-capabilities.js.map +1 -0
- package/dist/utils/project-detector.d.ts +46 -0
- package/dist/utils/project-detector.d.ts.map +1 -0
- package/dist/utils/project-detector.js +666 -0
- package/dist/utils/project-detector.js.map +1 -0
- package/dist/utils/proxy.d.ts +25 -0
- package/dist/utils/proxy.d.ts.map +1 -0
- package/dist/utils/proxy.js +60 -0
- package/dist/utils/proxy.js.map +1 -0
- package/dist/utils/readiness.d.ts +40 -0
- package/dist/utils/readiness.d.ts.map +1 -0
- package/dist/utils/readiness.js +491 -0
- package/dist/utils/readiness.js.map +1 -0
- package/dist/utils/retrieval-agent-instructions.d.ts +10 -0
- package/dist/utils/retrieval-agent-instructions.d.ts.map +1 -0
- package/dist/utils/retrieval-agent-instructions.js +97 -0
- package/dist/utils/retrieval-agent-instructions.js.map +1 -0
- package/dist/utils/retrieval-execution-telemetry.d.ts +53 -0
- package/dist/utils/retrieval-execution-telemetry.d.ts.map +1 -0
- package/dist/utils/retrieval-execution-telemetry.js +116 -0
- package/dist/utils/retrieval-execution-telemetry.js.map +1 -0
- package/dist/utils/retrieval-result-ranking.d.ts +34 -0
- package/dist/utils/retrieval-result-ranking.d.ts.map +1 -0
- package/dist/utils/retrieval-result-ranking.js +71 -0
- package/dist/utils/retrieval-result-ranking.js.map +1 -0
- package/dist/utils/retrieval-tool-classification.d.ts +18 -0
- package/dist/utils/retrieval-tool-classification.d.ts.map +1 -0
- package/dist/utils/retrieval-tool-classification.js +118 -0
- package/dist/utils/retrieval-tool-classification.js.map +1 -0
- package/dist/utils/semantic-plan-gate.d.ts +8 -0
- package/dist/utils/semantic-plan-gate.d.ts.map +1 -0
- package/dist/utils/semantic-plan-gate.js +24 -0
- package/dist/utils/semantic-plan-gate.js.map +1 -0
- package/dist/utils/task-json.d.ts +13 -0
- package/dist/utils/task-json.d.ts.map +1 -0
- package/dist/utils/task-json.js +12 -0
- package/dist/utils/task-json.js.map +1 -0
- package/dist/utils/template-fetcher.d.ts +150 -0
- package/dist/utils/template-fetcher.d.ts.map +1 -0
- package/dist/utils/template-fetcher.js +907 -0
- package/dist/utils/template-fetcher.js.map +1 -0
- package/dist/utils/template-hash.d.ts +123 -0
- package/dist/utils/template-hash.d.ts.map +1 -0
- package/dist/utils/template-hash.js +375 -0
- package/dist/utils/template-hash.js.map +1 -0
- package/dist/utils/uninstall-scrubbers.d.ts +30 -0
- package/dist/utils/uninstall-scrubbers.d.ts.map +1 -0
- package/dist/utils/uninstall-scrubbers.js +196 -0
- package/dist/utils/uninstall-scrubbers.js.map +1 -0
- package/dist/utils/update-rollout-report.d.ts +171 -0
- package/dist/utils/update-rollout-report.d.ts.map +1 -0
- package/dist/utils/update-rollout-report.js +126 -0
- package/dist/utils/update-rollout-report.js.map +1 -0
- package/dist/utils/validate-rules.d.ts +21 -0
- package/dist/utils/validate-rules.d.ts.map +1 -0
- package/dist/utils/validate-rules.js +88 -0
- package/dist/utils/validate-rules.js.map +1 -0
- package/dist/utils/workflow-dir.d.ts +15 -0
- package/dist/utils/workflow-dir.d.ts.map +1 -0
- package/dist/utils/workflow-dir.js +33 -0
- package/dist/utils/workflow-dir.js.map +1 -0
- package/dist/utils/workflow-resolver.d.ts +86 -0
- package/dist/utils/workflow-resolver.d.ts.map +1 -0
- package/dist/utils/workflow-resolver.js +265 -0
- package/dist/utils/workflow-resolver.js.map +1 -0
- package/package.json +117 -0
- package/scripts/postinstall.js +6 -0
|
@@ -0,0 +1,1030 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
4
|
+
import { canonicalizePactileJsonV1, fingerprintPactileContractV1, parseMigrationJournalV1, parseMigrationPlanV1, parseProjectionPlanV1, } from "@blxzer/pactile-core";
|
|
5
|
+
import { runMigrationTransaction, } from "../migration/transaction.js";
|
|
6
|
+
import { MAX_PROJECTION_BYTES, } from "../projection/planner.js";
|
|
7
|
+
import { ProjectionStore, } from "../projection/store.js";
|
|
8
|
+
import { GenerationStore, InstallStateStore, } from "../runtime/stores.js";
|
|
9
|
+
import { assertCanonicalWriteTarget, normalizeRuntimeRelativePath, resolveCanonicalPaths, } from "../runtime/paths.js";
|
|
10
|
+
const LOGICAL_ID = /^[a-z][a-z0-9]*(?:[._:-][a-z0-9]+)*$/;
|
|
11
|
+
const FINGERPRINT = /^sha256:[0-9a-f]{64}$/;
|
|
12
|
+
const SEMVER = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/;
|
|
13
|
+
function lexical(left, right) {
|
|
14
|
+
return left < right ? -1 : left > right ? 1 : 0;
|
|
15
|
+
}
|
|
16
|
+
function digest(bytes) {
|
|
17
|
+
return `sha256:${createHash("sha256").update(bytes).digest("hex")}`;
|
|
18
|
+
}
|
|
19
|
+
function normalizeGenerationFiles(files) {
|
|
20
|
+
try {
|
|
21
|
+
if (files.length === 0)
|
|
22
|
+
return null;
|
|
23
|
+
const normalized = files
|
|
24
|
+
.map((file) => {
|
|
25
|
+
const bytes = Buffer.from(file.bytes);
|
|
26
|
+
return {
|
|
27
|
+
path: normalizeRuntimeRelativePath(file.path),
|
|
28
|
+
bytes,
|
|
29
|
+
fingerprint: digest(bytes),
|
|
30
|
+
};
|
|
31
|
+
})
|
|
32
|
+
.sort((left, right) => lexical(left.path, right.path));
|
|
33
|
+
if (normalized.some((file) => file.bytes.byteLength > MAX_PROJECTION_BYTES) ||
|
|
34
|
+
new Set(normalized.map((file) => file.path.normalize("NFC").toLowerCase())).size !== normalized.length)
|
|
35
|
+
return null;
|
|
36
|
+
return normalized;
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function normalizeRequest(request) {
|
|
43
|
+
try {
|
|
44
|
+
if (!path.isAbsolute(request.projectRoot) ||
|
|
45
|
+
!fs.statSync(request.projectRoot).isDirectory() ||
|
|
46
|
+
!LOGICAL_ID.test(request.id) ||
|
|
47
|
+
!LOGICAL_ID.test(request.generationId) ||
|
|
48
|
+
!SEMVER.test(request.runtimeVersion) ||
|
|
49
|
+
(request.expectedInstallStateFingerprint !== null &&
|
|
50
|
+
!FINGERPRINT.test(request.expectedInstallStateFingerprint)) ||
|
|
51
|
+
Number.isNaN(Date.parse(request.occurredAt)))
|
|
52
|
+
return null;
|
|
53
|
+
const adapters = [...request.adapters].sort((left, right) => lexical(left.adapterId, right.adapterId));
|
|
54
|
+
if (new Set(adapters.map((adapter) => adapter.adapterId)).size !==
|
|
55
|
+
adapters.length ||
|
|
56
|
+
new Set(adapters.map((adapter) => adapter.projectionPlanId)).size !==
|
|
57
|
+
adapters.length ||
|
|
58
|
+
adapters.some((adapter) => !LOGICAL_ID.test(adapter.adapterId) ||
|
|
59
|
+
!LOGICAL_ID.test(adapter.projectionPlanId) ||
|
|
60
|
+
!SEMVER.test(adapter.adapterVersion) ||
|
|
61
|
+
typeof adapter.buildProjection !== "function"))
|
|
62
|
+
return null;
|
|
63
|
+
let source;
|
|
64
|
+
if (request.source.kind === "fresh") {
|
|
65
|
+
const files = normalizeGenerationFiles(request.source.files);
|
|
66
|
+
if (!files)
|
|
67
|
+
return null;
|
|
68
|
+
source = { kind: "fresh", files };
|
|
69
|
+
}
|
|
70
|
+
else if (request.source.kind === "canonical") {
|
|
71
|
+
const files = normalizeGenerationFiles(request.source.files);
|
|
72
|
+
if (!files ||
|
|
73
|
+
!LOGICAL_ID.test(request.source.generationId) ||
|
|
74
|
+
!SEMVER.test(request.source.runtimeVersion) ||
|
|
75
|
+
request.source.schemaVersion !== 1)
|
|
76
|
+
return null;
|
|
77
|
+
source = { ...request.source, files };
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
const files = normalizeGenerationFiles(request.source.files);
|
|
81
|
+
if (request.source.root !== ".cstl" ||
|
|
82
|
+
(request.source.runtimeVersion !== null &&
|
|
83
|
+
!SEMVER.test(request.source.runtimeVersion)) ||
|
|
84
|
+
(request.source.schemaVersion !== null &&
|
|
85
|
+
(!Number.isInteger(request.source.schemaVersion) ||
|
|
86
|
+
request.source.schemaVersion < 0)) ||
|
|
87
|
+
!files)
|
|
88
|
+
return null;
|
|
89
|
+
const byPath = new Map(files.map((file) => [file.path, file]));
|
|
90
|
+
const legacyFiles = request.source.files
|
|
91
|
+
.map((file) => {
|
|
92
|
+
const targetPath = normalizeRuntimeRelativePath(file.path);
|
|
93
|
+
const target = byPath.get(targetPath);
|
|
94
|
+
const sourceBytes = Buffer.from(file.sourceBytes);
|
|
95
|
+
if (!target ||
|
|
96
|
+
!file.sourceRef ||
|
|
97
|
+
file.sourceRef.length > 512 ||
|
|
98
|
+
/[\0\r\n]/.test(file.sourceRef) ||
|
|
99
|
+
!["active", "closed", "generated"].includes(file.classification) ||
|
|
100
|
+
!FINGERPRINT.test(file.expectedSourceFingerprint) ||
|
|
101
|
+
sourceBytes.byteLength > MAX_PROJECTION_BYTES ||
|
|
102
|
+
digest(sourceBytes) !== file.expectedSourceFingerprint ||
|
|
103
|
+
(file.classification === "closed" &&
|
|
104
|
+
!sourceBytes.equals(target.bytes)))
|
|
105
|
+
return null;
|
|
106
|
+
return {
|
|
107
|
+
...target,
|
|
108
|
+
sourceRef: file.sourceRef,
|
|
109
|
+
classification: file.classification,
|
|
110
|
+
sourceBytes,
|
|
111
|
+
expectedSourceFingerprint: file.expectedSourceFingerprint,
|
|
112
|
+
};
|
|
113
|
+
})
|
|
114
|
+
.sort((left, right) => left && right ? lexical(left.path, right.path) : left ? -1 : 1);
|
|
115
|
+
if (legacyFiles.some((file) => file === null) ||
|
|
116
|
+
new Set(legacyFiles.map((file) => file.sourceRef)).size !== legacyFiles.length)
|
|
117
|
+
return null;
|
|
118
|
+
source = {
|
|
119
|
+
...request.source,
|
|
120
|
+
files: legacyFiles,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
return { ...request, source, adapters };
|
|
124
|
+
}
|
|
125
|
+
catch {
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
function generationFiles(input) {
|
|
130
|
+
return input.source.files;
|
|
131
|
+
}
|
|
132
|
+
function sourceReference(source, file) {
|
|
133
|
+
// Two canonical targets may intentionally contain identical bytes (for
|
|
134
|
+
// example, per-package spec seeds in a monorepo). Migration preservation
|
|
135
|
+
// references are unique contract keys, so bind the byte fingerprint to the
|
|
136
|
+
// target identity without exposing the relative path itself.
|
|
137
|
+
if (source.kind === "fresh")
|
|
138
|
+
return `content://${digest(Buffer.from(`${file.path}\0${file.fingerprint}`, "utf8"))}`;
|
|
139
|
+
if (source.kind === "canonical")
|
|
140
|
+
return `generation://${source.generationId}/${file.path}#${file.fingerprint}`;
|
|
141
|
+
const legacy = source.files.find((candidate) => candidate.path === file.path);
|
|
142
|
+
if (!legacy)
|
|
143
|
+
throw new Error("legacy-file-mismatch");
|
|
144
|
+
return `${legacy.sourceRef}#${legacy.expectedSourceFingerprint}->${file.fingerprint}`;
|
|
145
|
+
}
|
|
146
|
+
function buildPlan(input) {
|
|
147
|
+
const detectId = `${input.id}.detect`;
|
|
148
|
+
const backupId = `${input.id}.backup`;
|
|
149
|
+
const validateId = `${input.id}.validate`;
|
|
150
|
+
const commitId = `${input.id}.commit`;
|
|
151
|
+
const doctorId = `${input.id}.doctor`;
|
|
152
|
+
const files = generationFiles(input);
|
|
153
|
+
const reconcileActions = input.adapters.map((adapter, index) => ({
|
|
154
|
+
id: `${input.id}.reconcile.${index + 1}`,
|
|
155
|
+
phase: "reconcile",
|
|
156
|
+
kind: "reconcile-projection",
|
|
157
|
+
domain: "projection",
|
|
158
|
+
sourceRef: `projection://${adapter.projectionPlanId}`,
|
|
159
|
+
targetRef: `adapter://${adapter.adapterId}`,
|
|
160
|
+
adapterId: adapter.adapterId,
|
|
161
|
+
reversible: true,
|
|
162
|
+
}));
|
|
163
|
+
const source = input.source.kind === "fresh"
|
|
164
|
+
? {
|
|
165
|
+
kind: "fresh",
|
|
166
|
+
root: null,
|
|
167
|
+
access: "none",
|
|
168
|
+
runtimeVersion: null,
|
|
169
|
+
schemaVersion: null,
|
|
170
|
+
}
|
|
171
|
+
: input.source.kind === "canonical"
|
|
172
|
+
? {
|
|
173
|
+
kind: "canonical",
|
|
174
|
+
root: ".pactile",
|
|
175
|
+
access: "read-write",
|
|
176
|
+
runtimeVersion: input.source.runtimeVersion,
|
|
177
|
+
schemaVersion: input.source.schemaVersion,
|
|
178
|
+
}
|
|
179
|
+
: {
|
|
180
|
+
kind: "legacy",
|
|
181
|
+
root: input.source.root,
|
|
182
|
+
access: "read-only",
|
|
183
|
+
runtimeVersion: input.source.runtimeVersion,
|
|
184
|
+
schemaVersion: input.source.schemaVersion,
|
|
185
|
+
};
|
|
186
|
+
const preservation = input.source.kind === "legacy"
|
|
187
|
+
? {
|
|
188
|
+
bytePreservedRefs: input.source.files
|
|
189
|
+
.filter((file) => file.classification === "closed")
|
|
190
|
+
.map((file) => file.sourceRef),
|
|
191
|
+
transformedRefs: input.source.files
|
|
192
|
+
.filter((file) => file.classification !== "closed")
|
|
193
|
+
.map((file) => file.sourceRef),
|
|
194
|
+
}
|
|
195
|
+
: {
|
|
196
|
+
bytePreservedRefs: [],
|
|
197
|
+
transformedRefs: files.map((file) => sourceReference(input.source, file)),
|
|
198
|
+
};
|
|
199
|
+
const candidate = {
|
|
200
|
+
schemaVersion: 1,
|
|
201
|
+
id: input.id,
|
|
202
|
+
source,
|
|
203
|
+
target: {
|
|
204
|
+
root: ".pactile",
|
|
205
|
+
runtimeVersion: input.runtimeVersion,
|
|
206
|
+
schemaVersion: 1,
|
|
207
|
+
generationId: input.generationId,
|
|
208
|
+
},
|
|
209
|
+
actions: [
|
|
210
|
+
{
|
|
211
|
+
id: detectId,
|
|
212
|
+
phase: "detect",
|
|
213
|
+
kind: "capture-facts",
|
|
214
|
+
domain: "canonical",
|
|
215
|
+
sourceRef: input.source.kind === "fresh"
|
|
216
|
+
? null
|
|
217
|
+
: input.source.kind === "canonical"
|
|
218
|
+
? `generation://${input.source.generationId}`
|
|
219
|
+
: "legacy://cstl",
|
|
220
|
+
targetRef: null,
|
|
221
|
+
adapterId: null,
|
|
222
|
+
reversible: true,
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
id: backupId,
|
|
226
|
+
phase: "backup",
|
|
227
|
+
kind: "snapshot",
|
|
228
|
+
domain: "canonical",
|
|
229
|
+
sourceRef: input.source.kind === "fresh"
|
|
230
|
+
? null
|
|
231
|
+
: input.source.kind === "canonical"
|
|
232
|
+
? `generation://${input.source.generationId}`
|
|
233
|
+
: "legacy://cstl",
|
|
234
|
+
targetRef: input.source.kind === "fresh"
|
|
235
|
+
? "backup://not-required"
|
|
236
|
+
: input.source.kind === "canonical"
|
|
237
|
+
? `generation://${input.source.generationId}`
|
|
238
|
+
: `migration://${input.id}.canonical`,
|
|
239
|
+
adapterId: null,
|
|
240
|
+
reversible: true,
|
|
241
|
+
},
|
|
242
|
+
...files.map((file, index) => ({
|
|
243
|
+
id: `${input.id}.stage.${index + 1}`,
|
|
244
|
+
phase: "stage",
|
|
245
|
+
kind: input.source.kind === "legacy"
|
|
246
|
+
? input.source.files[index]?.classification === "closed"
|
|
247
|
+
? "copy-byte-preserved"
|
|
248
|
+
: input.source.files[index]?.classification === "generated"
|
|
249
|
+
? "write-generation"
|
|
250
|
+
: "transform-schema"
|
|
251
|
+
: "write-generation",
|
|
252
|
+
domain: "canonical",
|
|
253
|
+
sourceRef: sourceReference(input.source, file),
|
|
254
|
+
targetRef: `generation://${input.generationId}/${file.path}`,
|
|
255
|
+
adapterId: null,
|
|
256
|
+
reversible: true,
|
|
257
|
+
})),
|
|
258
|
+
{
|
|
259
|
+
id: validateId,
|
|
260
|
+
phase: "validate",
|
|
261
|
+
kind: "validate-generation",
|
|
262
|
+
domain: "canonical",
|
|
263
|
+
sourceRef: `generation://${input.generationId}`,
|
|
264
|
+
targetRef: null,
|
|
265
|
+
adapterId: null,
|
|
266
|
+
reversible: true,
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
id: commitId,
|
|
270
|
+
phase: "commit",
|
|
271
|
+
kind: "activate-generation",
|
|
272
|
+
domain: "canonical",
|
|
273
|
+
sourceRef: `generation://${input.generationId}`,
|
|
274
|
+
targetRef: "install-state://active",
|
|
275
|
+
adapterId: null,
|
|
276
|
+
reversible: true,
|
|
277
|
+
},
|
|
278
|
+
...reconcileActions,
|
|
279
|
+
{
|
|
280
|
+
id: doctorId,
|
|
281
|
+
phase: "doctor",
|
|
282
|
+
kind: "doctor",
|
|
283
|
+
domain: "canonical",
|
|
284
|
+
sourceRef: `generation://${input.generationId}`,
|
|
285
|
+
targetRef: null,
|
|
286
|
+
adapterId: null,
|
|
287
|
+
reversible: true,
|
|
288
|
+
},
|
|
289
|
+
],
|
|
290
|
+
canonicalCommitPointActionId: commitId,
|
|
291
|
+
preservation,
|
|
292
|
+
recovery: {
|
|
293
|
+
backupRef: input.source.kind === "fresh"
|
|
294
|
+
? "backup://not-required"
|
|
295
|
+
: input.source.kind === "canonical"
|
|
296
|
+
? `generation://${input.source.generationId}`
|
|
297
|
+
: `migration://${input.id}.canonical`,
|
|
298
|
+
preserveNewerData: true,
|
|
299
|
+
},
|
|
300
|
+
projectionPlanIds: input.adapters.map((adapter) => adapter.projectionPlanId),
|
|
301
|
+
};
|
|
302
|
+
const parsed = parseMigrationPlanV1(candidate);
|
|
303
|
+
return parsed.success
|
|
304
|
+
? { plan: parsed.data, fingerprint: parsed.fingerprint }
|
|
305
|
+
: null;
|
|
306
|
+
}
|
|
307
|
+
class LifecycleJournalStore {
|
|
308
|
+
projectRoot;
|
|
309
|
+
directory;
|
|
310
|
+
constructor(projectRoot) {
|
|
311
|
+
this.projectRoot = projectRoot;
|
|
312
|
+
this.directory = resolveCanonicalPaths(projectRoot).migrationJournalsPath;
|
|
313
|
+
}
|
|
314
|
+
target(id) {
|
|
315
|
+
if (!LOGICAL_ID.test(id))
|
|
316
|
+
throw new Error("invalid-lifecycle-journal-id");
|
|
317
|
+
return assertCanonicalWriteTarget(this.projectRoot, path.join(this.directory, `${id}.json`));
|
|
318
|
+
}
|
|
319
|
+
read(id) {
|
|
320
|
+
try {
|
|
321
|
+
const value = JSON.parse(fs.readFileSync(this.target(id), "utf8"));
|
|
322
|
+
const parsed = parseMigrationJournalV1(value);
|
|
323
|
+
if (!parsed.success)
|
|
324
|
+
throw new Error("invalid-lifecycle-journal");
|
|
325
|
+
return { journal: parsed.data, fingerprint: parsed.fingerprint };
|
|
326
|
+
}
|
|
327
|
+
catch (error) {
|
|
328
|
+
if (error instanceof Error && "code" in error && error.code === "ENOENT")
|
|
329
|
+
return null;
|
|
330
|
+
throw new Error("lifecycle-journal-unavailable");
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
write(id, expectedFingerprint, journal) {
|
|
334
|
+
const parsed = parseMigrationJournalV1(journal);
|
|
335
|
+
if (!parsed.success)
|
|
336
|
+
throw new Error("invalid-lifecycle-journal");
|
|
337
|
+
fs.mkdirSync(assertCanonicalWriteTarget(this.projectRoot, this.directory), {
|
|
338
|
+
recursive: true,
|
|
339
|
+
});
|
|
340
|
+
const target = this.target(id);
|
|
341
|
+
const lock = assertCanonicalWriteTarget(this.projectRoot, `${target}.lock`);
|
|
342
|
+
const temporary = assertCanonicalWriteTarget(this.projectRoot, `${target}.tmp-${randomUUID()}`);
|
|
343
|
+
let descriptor = null;
|
|
344
|
+
let ownedLock = null;
|
|
345
|
+
try {
|
|
346
|
+
descriptor = fs.openSync(lock, "wx", 0o600);
|
|
347
|
+
const opened = fs.fstatSync(descriptor);
|
|
348
|
+
ownedLock = { dev: opened.dev, ino: opened.ino };
|
|
349
|
+
const current = this.read(id);
|
|
350
|
+
if ((current?.fingerprint ?? null) !== expectedFingerprint)
|
|
351
|
+
throw new Error("lifecycle-journal-cas-mismatch");
|
|
352
|
+
fs.writeFileSync(temporary, canonicalizePactileJsonV1(parsed.data), {
|
|
353
|
+
flag: "wx",
|
|
354
|
+
mode: 0o600,
|
|
355
|
+
});
|
|
356
|
+
fs.renameSync(temporary, target);
|
|
357
|
+
return { journal: parsed.data, fingerprint: parsed.fingerprint };
|
|
358
|
+
}
|
|
359
|
+
finally {
|
|
360
|
+
if (descriptor !== null)
|
|
361
|
+
fs.closeSync(descriptor);
|
|
362
|
+
if (ownedLock) {
|
|
363
|
+
try {
|
|
364
|
+
const visible = fs.lstatSync(lock);
|
|
365
|
+
if (visible.isFile() &&
|
|
366
|
+
!visible.isSymbolicLink() &&
|
|
367
|
+
visible.nlink === 1 &&
|
|
368
|
+
visible.dev === ownedLock.dev &&
|
|
369
|
+
visible.ino === ownedLock.ino)
|
|
370
|
+
fs.unlinkSync(lock);
|
|
371
|
+
}
|
|
372
|
+
catch {
|
|
373
|
+
/* A stale or replaced lock stays diagnosable. */
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
try {
|
|
377
|
+
fs.unlinkSync(temporary);
|
|
378
|
+
}
|
|
379
|
+
catch {
|
|
380
|
+
/* A successful rename consumes the temporary file. */
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
function journalEvent(journal, at, event, actionId, evidenceRefs, adapterId = null) {
|
|
386
|
+
return {
|
|
387
|
+
sequence: journal.events.length + 1,
|
|
388
|
+
at,
|
|
389
|
+
event,
|
|
390
|
+
actionId,
|
|
391
|
+
adapterId,
|
|
392
|
+
evidenceRefs,
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
function initialJournal(input, plan, planFingerprint) {
|
|
396
|
+
return {
|
|
397
|
+
schemaVersion: 1,
|
|
398
|
+
id: input.id,
|
|
399
|
+
planId: plan.id,
|
|
400
|
+
planFingerprint,
|
|
401
|
+
state: "planned",
|
|
402
|
+
canonicalCommit: {
|
|
403
|
+
status: "pending",
|
|
404
|
+
actionId: plan.canonicalCommitPointActionId,
|
|
405
|
+
generationId: null,
|
|
406
|
+
committedAt: null,
|
|
407
|
+
},
|
|
408
|
+
recovery: {
|
|
409
|
+
status: input.source.kind === "fresh" ? "not-required" : "available",
|
|
410
|
+
backupRef: plan.recovery.backupRef,
|
|
411
|
+
updatedAt: input.occurredAt,
|
|
412
|
+
error: null,
|
|
413
|
+
},
|
|
414
|
+
adapterReconciliations: input.adapters.map((adapter) => ({
|
|
415
|
+
adapterId: adapter.adapterId,
|
|
416
|
+
projectionPlanId: adapter.projectionPlanId,
|
|
417
|
+
status: "pending",
|
|
418
|
+
attempts: 0,
|
|
419
|
+
lastAttemptAt: null,
|
|
420
|
+
lastError: null,
|
|
421
|
+
})),
|
|
422
|
+
events: [
|
|
423
|
+
{
|
|
424
|
+
sequence: 1,
|
|
425
|
+
at: input.occurredAt,
|
|
426
|
+
event: "planned",
|
|
427
|
+
actionId: `${input.id}.detect`,
|
|
428
|
+
adapterId: null,
|
|
429
|
+
evidenceRefs: [planFingerprint],
|
|
430
|
+
},
|
|
431
|
+
],
|
|
432
|
+
};
|
|
433
|
+
}
|
|
434
|
+
function updateJournal(snapshot, store, id, patch) {
|
|
435
|
+
return store.write(id, snapshot.fingerprint, {
|
|
436
|
+
...snapshot.journal,
|
|
437
|
+
...patch,
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
function sealMatches(seal, files) {
|
|
441
|
+
return (canonicalizePactileJsonV1(seal.files) ===
|
|
442
|
+
canonicalizePactileJsonV1(files.map((file) => ({ path: file.path, fingerprint: file.fingerprint }))));
|
|
443
|
+
}
|
|
444
|
+
function ensureGeneration(generations, input) {
|
|
445
|
+
const files = generationFiles(input);
|
|
446
|
+
try {
|
|
447
|
+
const existing = generations.verify(input.generationId);
|
|
448
|
+
if (!sealMatches(existing, files))
|
|
449
|
+
throw new Error("generation-conflict");
|
|
450
|
+
return existing;
|
|
451
|
+
}
|
|
452
|
+
catch {
|
|
453
|
+
generations.stage(input.generationId);
|
|
454
|
+
}
|
|
455
|
+
const written = files.map((file) => generations.writeFile(input.generationId, file.path, file.bytes));
|
|
456
|
+
const seal = generations.seal(input.generationId, written);
|
|
457
|
+
if (!sealMatches(seal, files))
|
|
458
|
+
throw new Error("generation-conflict");
|
|
459
|
+
return seal;
|
|
460
|
+
}
|
|
461
|
+
async function validateGeneration(generations, input, options) {
|
|
462
|
+
const files = generationFiles(input);
|
|
463
|
+
const seal = generations.verify(input.generationId);
|
|
464
|
+
if (!sealMatches(seal, files))
|
|
465
|
+
return false;
|
|
466
|
+
const verifiedFiles = generations.readFiles(input.generationId, files.map((file) => file.path));
|
|
467
|
+
for (const file of files) {
|
|
468
|
+
const actual = verifiedFiles.get(file.path);
|
|
469
|
+
if (!actual?.equals(file.bytes))
|
|
470
|
+
return false;
|
|
471
|
+
}
|
|
472
|
+
return options.validateGeneration
|
|
473
|
+
? options.validateGeneration({
|
|
474
|
+
generationId: input.generationId,
|
|
475
|
+
files: seal.files,
|
|
476
|
+
readFile: (relativePath) => generations.readFile(input.generationId, relativePath),
|
|
477
|
+
})
|
|
478
|
+
: true;
|
|
479
|
+
}
|
|
480
|
+
function pendingInstallState(input, current) {
|
|
481
|
+
const adapters = new Map((current?.state.installedAdapters ?? []).map((adapter) => [
|
|
482
|
+
adapter.id,
|
|
483
|
+
adapter,
|
|
484
|
+
]));
|
|
485
|
+
for (const adapter of input.adapters) {
|
|
486
|
+
const previous = adapters.get(adapter.adapterId);
|
|
487
|
+
adapters.set(adapter.adapterId, {
|
|
488
|
+
id: adapter.adapterId,
|
|
489
|
+
version: adapter.adapterVersion,
|
|
490
|
+
status: "degraded",
|
|
491
|
+
lastProjectionFingerprint: previous?.lastProjectionFingerprint ?? null,
|
|
492
|
+
reconciledAt: previous?.reconciledAt ?? null,
|
|
493
|
+
});
|
|
494
|
+
}
|
|
495
|
+
const installedAdapters = [...adapters.values()].sort((left, right) => lexical(left.id, right.id));
|
|
496
|
+
return {
|
|
497
|
+
schemaVersion: 1,
|
|
498
|
+
product: "pactile",
|
|
499
|
+
canonicalRoot: ".pactile",
|
|
500
|
+
runtimeVersion: input.runtimeVersion,
|
|
501
|
+
contractVersion: 1,
|
|
502
|
+
generationId: input.generationId,
|
|
503
|
+
status: installedAdapters.some((adapter) => adapter.status === "degraded")
|
|
504
|
+
? "degraded"
|
|
505
|
+
: "active",
|
|
506
|
+
installedAdapters,
|
|
507
|
+
lastMigrationJournalId: input.id,
|
|
508
|
+
createdAt: current?.state.createdAt ?? input.occurredAt,
|
|
509
|
+
updatedAt: input.occurredAt,
|
|
510
|
+
};
|
|
511
|
+
}
|
|
512
|
+
function canonicalAlreadyCommitted(current, input) {
|
|
513
|
+
return (current?.state.generationId === input.generationId &&
|
|
514
|
+
current.state.lastMigrationJournalId === input.id);
|
|
515
|
+
}
|
|
516
|
+
function commitInstallState(installs, input) {
|
|
517
|
+
const current = installs.read();
|
|
518
|
+
if (canonicalAlreadyCommitted(current, input))
|
|
519
|
+
return current;
|
|
520
|
+
if (input.source.kind === "fresh") {
|
|
521
|
+
if (current !== null)
|
|
522
|
+
throw new Error("unexpected-existing-install-state");
|
|
523
|
+
}
|
|
524
|
+
else if (input.source.kind === "canonical") {
|
|
525
|
+
if (current?.state.generationId !== input.source.generationId)
|
|
526
|
+
throw new Error("canonical-source-generation-mismatch");
|
|
527
|
+
if (current.fingerprint !== input.expectedInstallStateFingerprint)
|
|
528
|
+
throw new Error("canonical-install-state-cas-mismatch");
|
|
529
|
+
}
|
|
530
|
+
else if (current?.state.generationId !== input.generationId) {
|
|
531
|
+
throw new Error("legacy-import-commit-missing");
|
|
532
|
+
}
|
|
533
|
+
const expected = input.source.kind === "legacy"
|
|
534
|
+
? (current?.fingerprint ?? null)
|
|
535
|
+
: input.expectedInstallStateFingerprint;
|
|
536
|
+
return installs.compareAndSwap(expected, pendingInstallState(input, current));
|
|
537
|
+
}
|
|
538
|
+
function migrationRequest(input) {
|
|
539
|
+
if (input.source.kind !== "legacy")
|
|
540
|
+
throw new Error("not-legacy-source");
|
|
541
|
+
return {
|
|
542
|
+
projectRoot: input.projectRoot,
|
|
543
|
+
id: `${input.id}.canonical`,
|
|
544
|
+
generationId: input.generationId,
|
|
545
|
+
sourceRoot: input.source.root,
|
|
546
|
+
sourceRuntimeVersion: input.source.runtimeVersion,
|
|
547
|
+
sourceSchemaVersion: input.source.schemaVersion,
|
|
548
|
+
runtimeVersion: input.runtimeVersion,
|
|
549
|
+
expectedInstallStateFingerprint: input.expectedInstallStateFingerprint,
|
|
550
|
+
occurredAt: input.occurredAt,
|
|
551
|
+
files: input.source.files.map((file) => ({
|
|
552
|
+
sourceRef: file.sourceRef,
|
|
553
|
+
targetPath: file.path,
|
|
554
|
+
classification: file.classification,
|
|
555
|
+
sourceBytes: file.sourceBytes,
|
|
556
|
+
targetBytes: file.bytes,
|
|
557
|
+
expectedSourceFingerprint: file.expectedSourceFingerprint,
|
|
558
|
+
})),
|
|
559
|
+
};
|
|
560
|
+
}
|
|
561
|
+
async function advanceCanonical(input, plan, store, snapshot, options) {
|
|
562
|
+
const generations = new GenerationStore(input.projectRoot);
|
|
563
|
+
const installs = new InstallStateStore(input.projectRoot);
|
|
564
|
+
let current = snapshot;
|
|
565
|
+
let seal;
|
|
566
|
+
if (input.source.kind === "legacy" && current.journal.state === "planned") {
|
|
567
|
+
const migration = await (options.migrationRunner ?? runMigrationTransaction)(migrationRequest(input), {
|
|
568
|
+
validateStaged: options.validateGeneration
|
|
569
|
+
? async (context) => options.validateGeneration?.({
|
|
570
|
+
generationId: context.generationId,
|
|
571
|
+
files: context.files.map((file) => ({
|
|
572
|
+
path: file.targetPath,
|
|
573
|
+
fingerprint: file.fingerprint,
|
|
574
|
+
})),
|
|
575
|
+
readFile: (relativePath) => generations.readFile(context.generationId, relativePath),
|
|
576
|
+
}) ?? true
|
|
577
|
+
: undefined,
|
|
578
|
+
});
|
|
579
|
+
if (migration.status !== "completed")
|
|
580
|
+
throw new Error(migration.reason === "migration-validation-failed"
|
|
581
|
+
? "generation-validation-failed"
|
|
582
|
+
: "legacy-migration-not-completed");
|
|
583
|
+
}
|
|
584
|
+
if (current.journal.state === "planned") {
|
|
585
|
+
const nextEvents = [
|
|
586
|
+
...current.journal.events,
|
|
587
|
+
journalEvent(current.journal, input.occurredAt, "backup-completed", `${input.id}.backup`, [plan.recovery.backupRef]),
|
|
588
|
+
];
|
|
589
|
+
current = updateJournal(current, store, input.id, {
|
|
590
|
+
state: "backed-up",
|
|
591
|
+
events: nextEvents,
|
|
592
|
+
});
|
|
593
|
+
}
|
|
594
|
+
if (current.journal.state === "backed-up") {
|
|
595
|
+
seal =
|
|
596
|
+
input.source.kind === "legacy"
|
|
597
|
+
? generations.verify(input.generationId)
|
|
598
|
+
: input.source.kind === "canonical" &&
|
|
599
|
+
input.source.generationId === input.generationId
|
|
600
|
+
? generations.verify(input.generationId)
|
|
601
|
+
: ensureGeneration(generations, input);
|
|
602
|
+
if (!sealMatches(seal, generationFiles(input)))
|
|
603
|
+
throw new Error("generation-conflict");
|
|
604
|
+
options.fault?.("after-stage");
|
|
605
|
+
current = updateJournal(current, store, input.id, {
|
|
606
|
+
state: "staged",
|
|
607
|
+
events: [
|
|
608
|
+
...current.journal.events,
|
|
609
|
+
journalEvent(current.journal, input.occurredAt, "stage-completed", `${input.id}.stage.1`, [seal.fingerprint]),
|
|
610
|
+
],
|
|
611
|
+
});
|
|
612
|
+
}
|
|
613
|
+
if (current.journal.state === "staged") {
|
|
614
|
+
if (!(await validateGeneration(generations, input, options)))
|
|
615
|
+
throw new Error("generation-validation-failed");
|
|
616
|
+
const validationFingerprint = fingerprintPactileContractV1(generationFiles(input).map((file) => ({
|
|
617
|
+
path: file.path,
|
|
618
|
+
fingerprint: file.fingerprint,
|
|
619
|
+
})));
|
|
620
|
+
current = updateJournal(current, store, input.id, {
|
|
621
|
+
state: "validated",
|
|
622
|
+
events: [
|
|
623
|
+
...current.journal.events,
|
|
624
|
+
journalEvent(current.journal, input.occurredAt, "validation-completed", `${input.id}.validate`, [validationFingerprint]),
|
|
625
|
+
],
|
|
626
|
+
});
|
|
627
|
+
}
|
|
628
|
+
if (current.journal.state === "validated") {
|
|
629
|
+
options.fault?.("before-canonical-commit");
|
|
630
|
+
const installed = commitInstallState(installs, input);
|
|
631
|
+
options.fault?.("after-canonical-commit");
|
|
632
|
+
current = updateJournal(current, store, input.id, {
|
|
633
|
+
state: "committed",
|
|
634
|
+
canonicalCommit: {
|
|
635
|
+
status: "committed",
|
|
636
|
+
actionId: plan.canonicalCommitPointActionId,
|
|
637
|
+
generationId: input.generationId,
|
|
638
|
+
committedAt: input.occurredAt,
|
|
639
|
+
},
|
|
640
|
+
events: [
|
|
641
|
+
...current.journal.events,
|
|
642
|
+
journalEvent(current.journal, input.occurredAt, "canonical-committed", plan.canonicalCommitPointActionId, [installed.fingerprint]),
|
|
643
|
+
],
|
|
644
|
+
});
|
|
645
|
+
}
|
|
646
|
+
seal = generations.verify(input.generationId);
|
|
647
|
+
const installState = installs.read();
|
|
648
|
+
if (current.journal.canonicalCommit.status !== "committed" ||
|
|
649
|
+
installState?.state.generationId !== input.generationId)
|
|
650
|
+
throw new Error("canonical-commit-not-completed");
|
|
651
|
+
return { snapshot: current, seal, installState };
|
|
652
|
+
}
|
|
653
|
+
function actionId(plan, adapterId) {
|
|
654
|
+
const action = plan.actions.find((candidate) => candidate.kind === "reconcile-projection" &&
|
|
655
|
+
candidate.adapterId === adapterId);
|
|
656
|
+
if (!action)
|
|
657
|
+
throw new Error("missing-adapter-action");
|
|
658
|
+
return action.id;
|
|
659
|
+
}
|
|
660
|
+
function failureRetryable(reason) {
|
|
661
|
+
return [
|
|
662
|
+
"projection-busy",
|
|
663
|
+
"projection-apply-not-completed",
|
|
664
|
+
"pending-projection-recovery",
|
|
665
|
+
"projection-cas-mismatch",
|
|
666
|
+
"ledger-cas-mismatch",
|
|
667
|
+
"target-cas-mismatch",
|
|
668
|
+
"applied-state-drift",
|
|
669
|
+
"interrupted-attempt-recovered",
|
|
670
|
+
].includes(reason);
|
|
671
|
+
}
|
|
672
|
+
function adaptersNeedingReconcile(input, journal, installState, options) {
|
|
673
|
+
const needed = new Set();
|
|
674
|
+
const canonicalCurrent = canonicalAlreadyCommitted(installState, input);
|
|
675
|
+
for (const adapter of input.adapters) {
|
|
676
|
+
const record = journal.adapterReconciliations.find((entry) => entry.adapterId === adapter.adapterId);
|
|
677
|
+
const installed = installState.state.installedAdapters.find((entry) => entry.id === adapter.adapterId);
|
|
678
|
+
if (!canonicalCurrent ||
|
|
679
|
+
record?.status !== "succeeded" ||
|
|
680
|
+
installed?.status !== "active" ||
|
|
681
|
+
installed.version !== adapter.adapterVersion) {
|
|
682
|
+
needed.add(adapter.adapterId);
|
|
683
|
+
continue;
|
|
684
|
+
}
|
|
685
|
+
const store = options.projectionStore?.(input.projectRoot, adapter.adapterId) ??
|
|
686
|
+
new ProjectionStore(input.projectRoot);
|
|
687
|
+
if (store.verifyAdapterState(adapter.adapterId, installed.lastProjectionFingerprint).status !== "applied")
|
|
688
|
+
needed.add(adapter.adapterId);
|
|
689
|
+
}
|
|
690
|
+
return needed;
|
|
691
|
+
}
|
|
692
|
+
async function inspectAdapterProjection(input, adapter, seal, projectionStore) {
|
|
693
|
+
const ledger = projectionStore.readLedger();
|
|
694
|
+
const projection = await adapter.buildProjection({
|
|
695
|
+
generationId: input.generationId,
|
|
696
|
+
canonicalFingerprint: seal.fingerprint,
|
|
697
|
+
ledger: ledger?.ledger ?? null,
|
|
698
|
+
ledgerFingerprint: ledger?.fingerprint ?? null,
|
|
699
|
+
occurredAt: input.occurredAt,
|
|
700
|
+
});
|
|
701
|
+
const parsed = parseProjectionPlanV1(projection.plan);
|
|
702
|
+
if (!parsed.success ||
|
|
703
|
+
parsed.data.id !== adapter.projectionPlanId ||
|
|
704
|
+
parsed.data.adapterId !== adapter.adapterId ||
|
|
705
|
+
parsed.data.generationId !== input.generationId ||
|
|
706
|
+
parsed.data.canonicalFingerprint !== seal.fingerprint ||
|
|
707
|
+
parsed.data.expectedLedgerFingerprint !== (ledger?.fingerprint ?? null) ||
|
|
708
|
+
projection.canonicalFingerprint !== seal.fingerprint)
|
|
709
|
+
return { status: "failed", reason: "invalid-adapter-projection" };
|
|
710
|
+
const preview = projectionStore.inspect({
|
|
711
|
+
plan: projection.plan,
|
|
712
|
+
canonicalFingerprint: projection.canonicalFingerprint,
|
|
713
|
+
updatedAt: projection.updatedAt,
|
|
714
|
+
resolveContent: projection.resolveContent,
|
|
715
|
+
externalClaims: projection.externalClaims,
|
|
716
|
+
});
|
|
717
|
+
return preview.status === "ready"
|
|
718
|
+
? { status: "ready", preview }
|
|
719
|
+
: { status: "failed", reason: preview.reason };
|
|
720
|
+
}
|
|
721
|
+
function adapterResults(journal) {
|
|
722
|
+
return journal.adapterReconciliations.map((adapter) => {
|
|
723
|
+
const succeeded = [...journal.events]
|
|
724
|
+
.reverse()
|
|
725
|
+
.find((event) => event.adapterId === adapter.adapterId &&
|
|
726
|
+
event.event === "adapter-reconcile-succeeded");
|
|
727
|
+
return {
|
|
728
|
+
adapterId: adapter.adapterId,
|
|
729
|
+
status: adapter.status === "succeeded"
|
|
730
|
+
? "succeeded"
|
|
731
|
+
: adapter.status === "pending"
|
|
732
|
+
? "pending"
|
|
733
|
+
: "failed",
|
|
734
|
+
attempts: adapter.attempts,
|
|
735
|
+
reason: adapter.lastError,
|
|
736
|
+
retryable: adapter.lastError
|
|
737
|
+
? failureRetryable(adapter.lastError)
|
|
738
|
+
: false,
|
|
739
|
+
projectionFingerprint: succeeded?.evidenceRefs[0] ?? null,
|
|
740
|
+
};
|
|
741
|
+
});
|
|
742
|
+
}
|
|
743
|
+
function updateAdapterRecord(journal, adapterId, patch) {
|
|
744
|
+
return journal.adapterReconciliations.map((entry) => entry.adapterId === adapterId ? { ...entry, ...patch } : entry);
|
|
745
|
+
}
|
|
746
|
+
function failAdapter(snapshot, store, input, plan, adapterId, occurredAt, reason) {
|
|
747
|
+
const adapter = snapshot.journal.adapterReconciliations.find((entry) => entry.adapterId === adapterId);
|
|
748
|
+
if (!adapter)
|
|
749
|
+
throw new Error("missing-adapter-journal");
|
|
750
|
+
return updateJournal(snapshot, store, input.id, {
|
|
751
|
+
state: "degraded",
|
|
752
|
+
adapterReconciliations: updateAdapterRecord(snapshot.journal, adapterId, {
|
|
753
|
+
status: "failed",
|
|
754
|
+
attempts: adapter.attempts,
|
|
755
|
+
lastAttemptAt: occurredAt,
|
|
756
|
+
lastError: reason,
|
|
757
|
+
}),
|
|
758
|
+
events: [
|
|
759
|
+
...snapshot.journal.events,
|
|
760
|
+
journalEvent(snapshot.journal, occurredAt, "adapter-reconcile-failed", actionId(plan, adapterId), [
|
|
761
|
+
fingerprintPactileContractV1({
|
|
762
|
+
reason,
|
|
763
|
+
retryable: failureRetryable(reason),
|
|
764
|
+
}),
|
|
765
|
+
], adapterId),
|
|
766
|
+
],
|
|
767
|
+
});
|
|
768
|
+
}
|
|
769
|
+
async function reconcileAdapters(input, plan, seal, store, snapshot, options, needed) {
|
|
770
|
+
let current = snapshot;
|
|
771
|
+
for (const adapter of input.adapters) {
|
|
772
|
+
let record = current.journal.adapterReconciliations.find((entry) => entry.adapterId === adapter.adapterId);
|
|
773
|
+
if (!record || !needed.has(adapter.adapterId))
|
|
774
|
+
continue;
|
|
775
|
+
if (record.status === "in-progress") {
|
|
776
|
+
current = failAdapter(current, store, input, plan, adapter.adapterId, input.occurredAt, "interrupted-attempt-recovered");
|
|
777
|
+
record = current.journal.adapterReconciliations.find((entry) => entry.adapterId === adapter.adapterId);
|
|
778
|
+
if (!record)
|
|
779
|
+
throw new Error("missing-adapter-journal");
|
|
780
|
+
}
|
|
781
|
+
const attemptedAt = input.occurredAt;
|
|
782
|
+
current = updateJournal(current, store, input.id, {
|
|
783
|
+
state: "reconciling",
|
|
784
|
+
adapterReconciliations: updateAdapterRecord(current.journal, adapter.adapterId, {
|
|
785
|
+
status: "in-progress",
|
|
786
|
+
attempts: record.attempts + 1,
|
|
787
|
+
lastAttemptAt: attemptedAt,
|
|
788
|
+
lastError: null,
|
|
789
|
+
}),
|
|
790
|
+
events: [
|
|
791
|
+
...current.journal.events,
|
|
792
|
+
journalEvent(current.journal, attemptedAt, "adapter-reconcile-started", actionId(plan, adapter.adapterId), [adapter.projectionPlanId], adapter.adapterId),
|
|
793
|
+
],
|
|
794
|
+
});
|
|
795
|
+
let failure = null;
|
|
796
|
+
let projectionFingerprint = null;
|
|
797
|
+
try {
|
|
798
|
+
options.fault?.("before-adapter", adapter.adapterId);
|
|
799
|
+
const projectionStore = options.projectionStore?.(input.projectRoot, adapter.adapterId) ??
|
|
800
|
+
new ProjectionStore(input.projectRoot);
|
|
801
|
+
const recovery = projectionStore.recover();
|
|
802
|
+
if (recovery.status === "busy")
|
|
803
|
+
failure = "projection-busy";
|
|
804
|
+
else if (recovery.status === "review")
|
|
805
|
+
failure = recovery.reason ?? "pending-projection-recovery";
|
|
806
|
+
if (!failure) {
|
|
807
|
+
const inspected = await inspectAdapterProjection(input, adapter, seal, projectionStore);
|
|
808
|
+
if (inspected.status === "failed")
|
|
809
|
+
failure = inspected.reason;
|
|
810
|
+
else {
|
|
811
|
+
const applied = projectionStore.apply(inspected.preview);
|
|
812
|
+
if (applied.status === "applied" ||
|
|
813
|
+
applied.status === "already-applied")
|
|
814
|
+
projectionFingerprint = applied.receipt.planFingerprint;
|
|
815
|
+
else
|
|
816
|
+
failure =
|
|
817
|
+
"reason" in applied
|
|
818
|
+
? applied.reason
|
|
819
|
+
: "projection-apply-not-completed";
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
options.fault?.("after-adapter", adapter.adapterId);
|
|
823
|
+
}
|
|
824
|
+
catch {
|
|
825
|
+
failure = "projection-apply-not-completed";
|
|
826
|
+
}
|
|
827
|
+
if (failure) {
|
|
828
|
+
current = failAdapter(current, store, input, plan, adapter.adapterId, attemptedAt, failure);
|
|
829
|
+
continue;
|
|
830
|
+
}
|
|
831
|
+
if (!projectionFingerprint)
|
|
832
|
+
throw new Error("missing-projection-fingerprint");
|
|
833
|
+
current = updateJournal(current, store, input.id, {
|
|
834
|
+
state: current.journal.adapterReconciliations.some((entry) => entry.adapterId !== adapter.adapterId && entry.status === "failed")
|
|
835
|
+
? "degraded"
|
|
836
|
+
: "committed",
|
|
837
|
+
adapterReconciliations: updateAdapterRecord(current.journal, adapter.adapterId, {
|
|
838
|
+
status: "succeeded",
|
|
839
|
+
lastAttemptAt: attemptedAt,
|
|
840
|
+
lastError: null,
|
|
841
|
+
}),
|
|
842
|
+
events: [
|
|
843
|
+
...current.journal.events,
|
|
844
|
+
journalEvent(current.journal, attemptedAt, "adapter-reconcile-succeeded", actionId(plan, adapter.adapterId), [projectionFingerprint], adapter.adapterId),
|
|
845
|
+
],
|
|
846
|
+
});
|
|
847
|
+
}
|
|
848
|
+
return current;
|
|
849
|
+
}
|
|
850
|
+
function finalizeInstallState(installs, input, journal) {
|
|
851
|
+
const current = installs.read();
|
|
852
|
+
if (current?.state.generationId !== input.generationId ||
|
|
853
|
+
current.state.lastMigrationJournalId !== input.id)
|
|
854
|
+
throw new Error("canonical-install-state-missing");
|
|
855
|
+
const adapters = new Map(current.state.installedAdapters.map((adapter) => [adapter.id, adapter]));
|
|
856
|
+
for (const requested of input.adapters) {
|
|
857
|
+
const reconciliation = journal.adapterReconciliations.find((entry) => entry.adapterId === requested.adapterId);
|
|
858
|
+
if (!reconciliation)
|
|
859
|
+
throw new Error("missing-adapter-journal");
|
|
860
|
+
const previous = adapters.get(requested.adapterId);
|
|
861
|
+
const successEvent = [...journal.events]
|
|
862
|
+
.reverse()
|
|
863
|
+
.find((event) => event.adapterId === requested.adapterId &&
|
|
864
|
+
event.event === "adapter-reconcile-succeeded");
|
|
865
|
+
adapters.set(requested.adapterId, {
|
|
866
|
+
id: requested.adapterId,
|
|
867
|
+
version: requested.adapterVersion,
|
|
868
|
+
status: reconciliation.status === "succeeded" ? "active" : "degraded",
|
|
869
|
+
lastProjectionFingerprint: successEvent?.evidenceRefs[0] ??
|
|
870
|
+
previous?.lastProjectionFingerprint ??
|
|
871
|
+
null,
|
|
872
|
+
reconciledAt: successEvent?.at ?? previous?.reconciledAt ?? null,
|
|
873
|
+
});
|
|
874
|
+
}
|
|
875
|
+
const installedAdapters = [...adapters.values()].sort((left, right) => lexical(left.id, right.id));
|
|
876
|
+
const next = {
|
|
877
|
+
...current.state,
|
|
878
|
+
runtimeVersion: input.runtimeVersion,
|
|
879
|
+
status: installedAdapters.some((adapter) => adapter.status === "degraded")
|
|
880
|
+
? "degraded"
|
|
881
|
+
: "active",
|
|
882
|
+
installedAdapters,
|
|
883
|
+
updatedAt: input.occurredAt,
|
|
884
|
+
};
|
|
885
|
+
if (canonicalizePactileJsonV1(next) === canonicalizePactileJsonV1(current.state))
|
|
886
|
+
return current;
|
|
887
|
+
return installs.compareAndSwap(current.fingerprint, next);
|
|
888
|
+
}
|
|
889
|
+
function failureResult(status, reason, resumed, plan, snapshot, generationFingerprint, installState) {
|
|
890
|
+
return {
|
|
891
|
+
status,
|
|
892
|
+
resumed,
|
|
893
|
+
reason,
|
|
894
|
+
plan: plan?.plan ?? null,
|
|
895
|
+
planFingerprint: plan?.fingerprint ?? null,
|
|
896
|
+
generationFingerprint,
|
|
897
|
+
journal: snapshot?.journal ?? null,
|
|
898
|
+
installState,
|
|
899
|
+
adapters: snapshot ? adapterResults(snapshot.journal) : [],
|
|
900
|
+
};
|
|
901
|
+
}
|
|
902
|
+
/**
|
|
903
|
+
* Durable Batch 3 lifecycle seam. Canonical generation activation is complete
|
|
904
|
+
* before any Adapter factory or ProjectionStore write is allowed to run.
|
|
905
|
+
*/
|
|
906
|
+
export async function runLifecycleTransaction(request, options = {}) {
|
|
907
|
+
const input = normalizeRequest(request);
|
|
908
|
+
const planned = input ? buildPlan(input) : null;
|
|
909
|
+
if (!input || !planned)
|
|
910
|
+
return failureResult("review", "invalid-lifecycle-request", false, null, null, null, null);
|
|
911
|
+
const journals = new LifecycleJournalStore(input.projectRoot);
|
|
912
|
+
let snapshot = null;
|
|
913
|
+
let resumed = false;
|
|
914
|
+
let generationFingerprint = null;
|
|
915
|
+
let installState = null;
|
|
916
|
+
let neededAdapters = null;
|
|
917
|
+
try {
|
|
918
|
+
snapshot = journals.read(input.id);
|
|
919
|
+
if (snapshot) {
|
|
920
|
+
resumed = true;
|
|
921
|
+
if (snapshot.journal.planId !== planned.plan.id ||
|
|
922
|
+
snapshot.journal.planFingerprint !== planned.fingerprint)
|
|
923
|
+
return failureResult("review", "lifecycle-plan-conflict", true, planned, snapshot, null, new InstallStateStore(input.projectRoot).read());
|
|
924
|
+
}
|
|
925
|
+
else {
|
|
926
|
+
snapshot = journals.write(input.id, null, initialJournal(input, planned.plan, planned.fingerprint));
|
|
927
|
+
}
|
|
928
|
+
if (snapshot.journal.state === "completed") {
|
|
929
|
+
const seal = new GenerationStore(input.projectRoot).verify(input.generationId);
|
|
930
|
+
const installed = new InstallStateStore(input.projectRoot).read();
|
|
931
|
+
if (!installed)
|
|
932
|
+
throw new Error("canonical-install-state-missing");
|
|
933
|
+
generationFingerprint = seal.fingerprint;
|
|
934
|
+
installState = installed;
|
|
935
|
+
neededAdapters = adaptersNeedingReconcile(input, snapshot.journal, installed, options);
|
|
936
|
+
if (canonicalAlreadyCommitted(installed, input) &&
|
|
937
|
+
neededAdapters.size === 0) {
|
|
938
|
+
if (input.materializeCanonical) {
|
|
939
|
+
const generations = new GenerationStore(input.projectRoot);
|
|
940
|
+
await input.materializeCanonical({
|
|
941
|
+
generationId: input.generationId,
|
|
942
|
+
files: seal.files,
|
|
943
|
+
readFile: (relativePath) => generations.readFile(input.generationId, relativePath),
|
|
944
|
+
readFiles: (relativePaths) => generations.readFiles(input.generationId, relativePaths),
|
|
945
|
+
});
|
|
946
|
+
}
|
|
947
|
+
return {
|
|
948
|
+
status: "completed",
|
|
949
|
+
resumed,
|
|
950
|
+
reason: null,
|
|
951
|
+
plan: planned.plan,
|
|
952
|
+
planFingerprint: planned.fingerprint,
|
|
953
|
+
generationFingerprint: seal.fingerprint,
|
|
954
|
+
journal: snapshot.journal,
|
|
955
|
+
installState: installed,
|
|
956
|
+
adapters: adapterResults(snapshot.journal),
|
|
957
|
+
};
|
|
958
|
+
}
|
|
959
|
+
installState = commitInstallState(new InstallStateStore(input.projectRoot), input);
|
|
960
|
+
snapshot = updateJournal(snapshot, journals, input.id, {
|
|
961
|
+
state: "committed",
|
|
962
|
+
});
|
|
963
|
+
}
|
|
964
|
+
if (["planned", "backed-up", "staged", "validated"].includes(snapshot.journal.state)) {
|
|
965
|
+
const advanced = await advanceCanonical(input, planned.plan, journals, snapshot, options);
|
|
966
|
+
snapshot = advanced.snapshot;
|
|
967
|
+
generationFingerprint = advanced.seal.fingerprint;
|
|
968
|
+
installState = advanced.installState;
|
|
969
|
+
}
|
|
970
|
+
else {
|
|
971
|
+
const seal = new GenerationStore(input.projectRoot).verify(input.generationId);
|
|
972
|
+
generationFingerprint = seal.fingerprint;
|
|
973
|
+
installState = new InstallStateStore(input.projectRoot).read();
|
|
974
|
+
}
|
|
975
|
+
if (!generationFingerprint || !installState)
|
|
976
|
+
throw new Error("canonical-commit-not-completed");
|
|
977
|
+
if (input.materializeCanonical) {
|
|
978
|
+
const generations = new GenerationStore(input.projectRoot);
|
|
979
|
+
const seal = generations.verify(input.generationId);
|
|
980
|
+
await input.materializeCanonical({
|
|
981
|
+
generationId: input.generationId,
|
|
982
|
+
files: seal.files,
|
|
983
|
+
readFile: (relativePath) => generations.readFile(input.generationId, relativePath),
|
|
984
|
+
readFiles: (relativePaths) => generations.readFiles(input.generationId, relativePaths),
|
|
985
|
+
});
|
|
986
|
+
}
|
|
987
|
+
neededAdapters ??= adaptersNeedingReconcile(input, snapshot.journal, installState, options);
|
|
988
|
+
snapshot = await reconcileAdapters(input, planned.plan, { ...new GenerationStore(input.projectRoot).verify(input.generationId) }, journals, snapshot, options, neededAdapters);
|
|
989
|
+
installState = finalizeInstallState(new InstallStateStore(input.projectRoot), input, snapshot.journal);
|
|
990
|
+
const failed = snapshot.journal.adapterReconciliations.some((adapter) => adapter.status !== "succeeded");
|
|
991
|
+
if (!failed) {
|
|
992
|
+
snapshot = updateJournal(snapshot, journals, input.id, {
|
|
993
|
+
state: "completed",
|
|
994
|
+
events: [
|
|
995
|
+
...snapshot.journal.events,
|
|
996
|
+
journalEvent(snapshot.journal, input.occurredAt, "doctor-completed", `${input.id}.doctor`, [installState.fingerprint]),
|
|
997
|
+
],
|
|
998
|
+
});
|
|
999
|
+
}
|
|
1000
|
+
return {
|
|
1001
|
+
status: failed ? "degraded" : "completed",
|
|
1002
|
+
resumed,
|
|
1003
|
+
reason: null,
|
|
1004
|
+
plan: planned.plan,
|
|
1005
|
+
planFingerprint: planned.fingerprint,
|
|
1006
|
+
generationFingerprint,
|
|
1007
|
+
journal: snapshot.journal,
|
|
1008
|
+
installState,
|
|
1009
|
+
adapters: adapterResults(snapshot.journal),
|
|
1010
|
+
};
|
|
1011
|
+
}
|
|
1012
|
+
catch (error) {
|
|
1013
|
+
let latest = snapshot;
|
|
1014
|
+
try {
|
|
1015
|
+
latest = journals.read(input.id) ?? snapshot;
|
|
1016
|
+
}
|
|
1017
|
+
catch {
|
|
1018
|
+
return failureResult("review", "lifecycle-journal-unavailable", resumed, planned, snapshot, generationFingerprint, installState);
|
|
1019
|
+
}
|
|
1020
|
+
const validationFailed = error instanceof Error &&
|
|
1021
|
+
error.message === "generation-validation-failed";
|
|
1022
|
+
return failureResult(validationFailed ? "review" : "interrupted", validationFailed
|
|
1023
|
+
? "generation-validation-failed"
|
|
1024
|
+
: "canonical-commit-not-completed", resumed, planned, latest, generationFingerprint, new InstallStateStore(input.projectRoot).read());
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
export function createProjectionStore(projectRoot, options = {}) {
|
|
1028
|
+
return new ProjectionStore(projectRoot, options);
|
|
1029
|
+
}
|
|
1030
|
+
//# sourceMappingURL=orchestrator.js.map
|