@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,1373 @@
|
|
|
1
|
+
"""Stage 6 Event Bridge + Middleware Provider projection.
|
|
2
|
+
|
|
3
|
+
Kernel extras remain authoritative. This module mirrors the contract for
|
|
4
|
+
hooks and tests. It does not write a second store or invent Command ops.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import hashlib
|
|
10
|
+
import json
|
|
11
|
+
import math
|
|
12
|
+
import re
|
|
13
|
+
from datetime import datetime
|
|
14
|
+
from typing import Any
|
|
15
|
+
|
|
16
|
+
STAGE6_SOURCE = "stage6-adapter-middleware"
|
|
17
|
+
STAGE6_SCHEMA_VERSION = 1
|
|
18
|
+
SMART_SEARCH_PROVIDER = "legacy.external"
|
|
19
|
+
EXTERNAL_KNOWLEDGE_CAPABILITY = "external-knowledge"
|
|
20
|
+
RETRIEVAL_INTENTS = ("exact", "semantic", "structural", "external")
|
|
21
|
+
OPTIONAL_CODE_INTEL_PROVIDERS: tuple[str, ...] = ()
|
|
22
|
+
SHIPPED_MIDDLEWARE_PROVIDERS: tuple[str, ...] = ()
|
|
23
|
+
DEFAULT_REQUIRED_MIDDLEWARE_PROVIDERS: tuple[str, ...] = ()
|
|
24
|
+
SHIPPED_PROVIDER_CAPABILITY: dict[str, str] = {}
|
|
25
|
+
SHIPPED_PROVIDER_PROBE: dict[str, str] = {}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class AdapterMiddlewareError(RuntimeError):
|
|
29
|
+
"""Event Bridge / Middleware contract rejected a request."""
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
PROFILE_BASELINE_MODULES = (
|
|
33
|
+
"intake-basic",
|
|
34
|
+
"define-basic",
|
|
35
|
+
"approval-personal",
|
|
36
|
+
"execute-agent",
|
|
37
|
+
"verify-basic",
|
|
38
|
+
"close-basic",
|
|
39
|
+
"context-progressive",
|
|
40
|
+
"observability-local",
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
# Hook subscriptions filled/cleared with Profile activation. Unsubscribed
|
|
44
|
+
# hooks stay no-op and must not crash.
|
|
45
|
+
MODULE_HOOK_SUBSCRIPTIONS: dict[str, tuple[dict[str, str], ...]] = {
|
|
46
|
+
"context-progressive": (
|
|
47
|
+
{
|
|
48
|
+
"event": "sessionStart",
|
|
49
|
+
"module": "context-progressive",
|
|
50
|
+
"hook": "session-start.py",
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"event": "beforeShellExecution",
|
|
54
|
+
"module": "context-progressive",
|
|
55
|
+
"hook": "inject-shell-session-context.py",
|
|
56
|
+
},
|
|
57
|
+
),
|
|
58
|
+
"worker-orchestration": (
|
|
59
|
+
{
|
|
60
|
+
"event": "preToolUse",
|
|
61
|
+
"module": "worker-orchestration",
|
|
62
|
+
"hook": "inject-subagent-context.py",
|
|
63
|
+
},
|
|
64
|
+
),
|
|
65
|
+
"retrieval-extended": (
|
|
66
|
+
{
|
|
67
|
+
"event": "beforeSubmitPrompt",
|
|
68
|
+
"module": "retrieval-extended",
|
|
69
|
+
"hook": "inject-retrieval-plan.py",
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"event": "stop",
|
|
73
|
+
"module": "retrieval-extended",
|
|
74
|
+
"hook": "research-end-retrieval-pack.py",
|
|
75
|
+
},
|
|
76
|
+
),
|
|
77
|
+
"spec-learning": (
|
|
78
|
+
{
|
|
79
|
+
"event": "preToolUse",
|
|
80
|
+
"module": "spec-learning",
|
|
81
|
+
"hook": "spec-write-audit.py",
|
|
82
|
+
},
|
|
83
|
+
),
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def default_event_bridge() -> dict[str, Any]:
|
|
88
|
+
return {
|
|
89
|
+
"schema_version": STAGE6_SCHEMA_VERSION,
|
|
90
|
+
"source": STAGE6_SOURCE,
|
|
91
|
+
"subscriptions": [],
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def _unique_ids(values: list[Any]) -> list[str]:
|
|
96
|
+
out: list[str] = []
|
|
97
|
+
for value in values:
|
|
98
|
+
if not isinstance(value, str):
|
|
99
|
+
continue
|
|
100
|
+
item = value.strip()
|
|
101
|
+
if item and item not in out:
|
|
102
|
+
out.append(item)
|
|
103
|
+
return out
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def _baseline_active_ids(extras: dict[str, Any]) -> list[str]:
|
|
107
|
+
block = extras.get("baseline_modules")
|
|
108
|
+
if not isinstance(block, dict) or "active" not in block:
|
|
109
|
+
return list(PROFILE_BASELINE_MODULES)
|
|
110
|
+
raw = block.get("active")
|
|
111
|
+
if not isinstance(raw, list):
|
|
112
|
+
return []
|
|
113
|
+
allowed = set(PROFILE_BASELINE_MODULES)
|
|
114
|
+
return _unique_ids([item for item in raw if isinstance(item, str) and item in allowed])
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def _ondemand_active_ids(extras: dict[str, Any]) -> list[str]:
|
|
118
|
+
block = extras.get("ondemand_modules")
|
|
119
|
+
if not isinstance(block, dict):
|
|
120
|
+
return []
|
|
121
|
+
raw = block.get("active") or []
|
|
122
|
+
if not isinstance(raw, list):
|
|
123
|
+
return []
|
|
124
|
+
return _unique_ids([item for item in raw if isinstance(item, str)])
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
def subscriptions_for_active_modules(
|
|
128
|
+
*,
|
|
129
|
+
baseline_active: list[str] | None = None,
|
|
130
|
+
ondemand_active: list[str] | None = None,
|
|
131
|
+
) -> list[dict[str, str]]:
|
|
132
|
+
ids = _unique_ids(list(baseline_active or []) + list(ondemand_active or []))
|
|
133
|
+
seen: set[tuple[str, str]] = set()
|
|
134
|
+
out: list[dict[str, str]] = []
|
|
135
|
+
for module_id in ids:
|
|
136
|
+
for item in MODULE_HOOK_SUBSCRIPTIONS.get(module_id, ()):
|
|
137
|
+
key = (item.get("event", ""), item.get("module", ""))
|
|
138
|
+
if key in seen:
|
|
139
|
+
continue
|
|
140
|
+
seen.add(key)
|
|
141
|
+
out.append(dict(item))
|
|
142
|
+
return out
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
def sync_event_bridge_subscriptions(extras: dict[str, Any]) -> dict[str, Any]:
|
|
146
|
+
"""Fill or clear `event_bridge.subscriptions` from still-active modules."""
|
|
147
|
+
bridge = extras.get("event_bridge")
|
|
148
|
+
if not isinstance(bridge, dict):
|
|
149
|
+
bridge = default_event_bridge()
|
|
150
|
+
extras["event_bridge"] = bridge
|
|
151
|
+
bridge["subscriptions"] = subscriptions_for_active_modules(
|
|
152
|
+
baseline_active=_baseline_active_ids(extras),
|
|
153
|
+
ondemand_active=_ondemand_active_ids(extras),
|
|
154
|
+
)
|
|
155
|
+
return extras
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
def event_bridge_for_dispatch(extras: dict[str, Any] | None) -> dict[str, Any]:
|
|
159
|
+
"""Hook-safe view: missing extras still default Baseline eight on."""
|
|
160
|
+
payload: dict[str, Any] = dict(extras or {})
|
|
161
|
+
sync_event_bridge_subscriptions(payload)
|
|
162
|
+
bridge = payload.get("event_bridge")
|
|
163
|
+
return bridge if isinstance(bridge, dict) else default_event_bridge()
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
def _default_readiness() -> dict[str, Any]:
|
|
167
|
+
return {
|
|
168
|
+
provider_id: {
|
|
169
|
+
"status": "unknown",
|
|
170
|
+
"capability": SHIPPED_PROVIDER_CAPABILITY[provider_id],
|
|
171
|
+
"evidence": None,
|
|
172
|
+
}
|
|
173
|
+
for provider_id in SHIPPED_MIDDLEWARE_PROVIDERS
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
def default_middleware_providers() -> dict[str, Any]:
|
|
178
|
+
return {
|
|
179
|
+
"schema_version": STAGE6_SCHEMA_VERSION,
|
|
180
|
+
"source": STAGE6_SOURCE,
|
|
181
|
+
"registered": list(SHIPPED_MIDDLEWARE_PROVIDERS),
|
|
182
|
+
"required": list(DEFAULT_REQUIRED_MIDDLEWARE_PROVIDERS),
|
|
183
|
+
"active": [],
|
|
184
|
+
"degraded": [],
|
|
185
|
+
"readiness": _default_readiness(),
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
def default_capability_router() -> dict[str, Any]:
|
|
190
|
+
return {
|
|
191
|
+
"schema_version": STAGE6_SCHEMA_VERSION,
|
|
192
|
+
"source": STAGE6_SOURCE,
|
|
193
|
+
"exact": True,
|
|
194
|
+
"semantic": True,
|
|
195
|
+
"structural": True,
|
|
196
|
+
"external": True,
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
def dispatch_hook_event(
|
|
201
|
+
event_bridge: dict[str, Any],
|
|
202
|
+
event: str,
|
|
203
|
+
*,
|
|
204
|
+
source: str = "host-hooks",
|
|
205
|
+
at: str | None = None,
|
|
206
|
+
) -> dict[str, Any]:
|
|
207
|
+
name = (event or "").strip()
|
|
208
|
+
if not name:
|
|
209
|
+
raise AdapterMiddlewareError("event_bridge.last_event.event must be a non-empty string")
|
|
210
|
+
delivered: list[str] = []
|
|
211
|
+
skipped: list[str] = []
|
|
212
|
+
for item in event_bridge.get("subscriptions") or []:
|
|
213
|
+
if not isinstance(item, dict):
|
|
214
|
+
continue
|
|
215
|
+
module = str(item.get("module") or "").strip()
|
|
216
|
+
if not module:
|
|
217
|
+
continue
|
|
218
|
+
if item.get("event") == name:
|
|
219
|
+
if module not in delivered:
|
|
220
|
+
delivered.append(module)
|
|
221
|
+
else:
|
|
222
|
+
skipped.append(module)
|
|
223
|
+
return {
|
|
224
|
+
"event": name,
|
|
225
|
+
"at": at or "",
|
|
226
|
+
"source": source,
|
|
227
|
+
"delivered": delivered,
|
|
228
|
+
"skipped": skipped,
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
def classify_transport_probe(
|
|
233
|
+
*,
|
|
234
|
+
present: bool | None = None,
|
|
235
|
+
reachable: bool | None = None,
|
|
236
|
+
available: bool | None = None,
|
|
237
|
+
status: str | None = None,
|
|
238
|
+
evidence: str | None = None,
|
|
239
|
+
) -> dict[str, Any]:
|
|
240
|
+
safe_evidence = evidence if _valid_evidence_reference(evidence) else None
|
|
241
|
+
if status in {"ready", "missing", "failed", "unknown"}:
|
|
242
|
+
return {"status": status, "evidence": safe_evidence}
|
|
243
|
+
resolved_present = present if present is not None else available
|
|
244
|
+
if resolved_present is False:
|
|
245
|
+
return {"status": "missing", "evidence": safe_evidence}
|
|
246
|
+
if resolved_present is True and reachable is False:
|
|
247
|
+
return {"status": "failed", "evidence": safe_evidence}
|
|
248
|
+
if resolved_present is True:
|
|
249
|
+
return {"status": "ready", "evidence": safe_evidence}
|
|
250
|
+
return {"status": "unknown", "evidence": safe_evidence}
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
def mcp_server_ids_from_config(raw: Any) -> list[str]:
|
|
254
|
+
if not isinstance(raw, dict):
|
|
255
|
+
return []
|
|
256
|
+
servers = raw.get("mcpServers")
|
|
257
|
+
if not isinstance(servers, dict):
|
|
258
|
+
return []
|
|
259
|
+
return [str(name) for name in servers.keys()]
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
def select_registered_mcp_servers(
|
|
263
|
+
configured: list[str] | tuple[str, ...],
|
|
264
|
+
registered: list[str] | tuple[str, ...] | None = None,
|
|
265
|
+
) -> list[str]:
|
|
266
|
+
allow = list(registered if registered is not None else SHIPPED_MIDDLEWARE_PROVIDERS)
|
|
267
|
+
out: list[str] = []
|
|
268
|
+
for name in configured:
|
|
269
|
+
if name in allow and name not in out:
|
|
270
|
+
out.append(name)
|
|
271
|
+
return out
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
def probe_shipped_provider_readiness(
|
|
275
|
+
provider_id: str,
|
|
276
|
+
*,
|
|
277
|
+
present: bool | None = None,
|
|
278
|
+
reachable: bool | None = None,
|
|
279
|
+
available: bool | None = None,
|
|
280
|
+
status: str | None = None,
|
|
281
|
+
evidence: str | None = None,
|
|
282
|
+
capability: str | None = None,
|
|
283
|
+
) -> dict[str, Any]:
|
|
284
|
+
classified = classify_transport_probe(
|
|
285
|
+
present=present,
|
|
286
|
+
reachable=reachable,
|
|
287
|
+
available=available,
|
|
288
|
+
status=status,
|
|
289
|
+
evidence=evidence,
|
|
290
|
+
)
|
|
291
|
+
return {
|
|
292
|
+
"status": classified["status"],
|
|
293
|
+
"capability": capability or SHIPPED_PROVIDER_CAPABILITY.get(
|
|
294
|
+
provider_id,
|
|
295
|
+
EXTERNAL_KNOWLEDGE_CAPABILITY if provider_id == SMART_SEARCH_PROVIDER else "unknown",
|
|
296
|
+
),
|
|
297
|
+
"evidence": classified["evidence"] if _valid_evidence_reference(classified["evidence"]) else None,
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
def apply_middleware_probes(
|
|
302
|
+
providers: dict[str, Any],
|
|
303
|
+
probes: dict[str, Any],
|
|
304
|
+
) -> dict[str, Any]:
|
|
305
|
+
registered = providers.get("registered") or []
|
|
306
|
+
readiness = dict(providers.get("readiness") or {})
|
|
307
|
+
if not isinstance(probes, dict):
|
|
308
|
+
return providers
|
|
309
|
+
for provider_id, value in probes.items():
|
|
310
|
+
if provider_id not in registered or not isinstance(value, dict):
|
|
311
|
+
continue
|
|
312
|
+
readiness[provider_id] = probe_shipped_provider_readiness(
|
|
313
|
+
provider_id,
|
|
314
|
+
present=value.get("present"),
|
|
315
|
+
reachable=value.get("reachable"),
|
|
316
|
+
available=value.get("available"),
|
|
317
|
+
status=value.get("status"),
|
|
318
|
+
evidence=value.get("evidence") if isinstance(value.get("evidence"), str) else None,
|
|
319
|
+
capability=value.get("capability") if isinstance(value.get("capability"), str) else None,
|
|
320
|
+
)
|
|
321
|
+
next_providers = {**providers, "readiness": readiness}
|
|
322
|
+
return next_providers
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
def probe_smart_search_readiness(*, available: bool | None = None, status: str | None = None) -> dict[str, Any]:
|
|
326
|
+
return probe_shipped_provider_readiness(
|
|
327
|
+
SMART_SEARCH_PROVIDER,
|
|
328
|
+
available=available,
|
|
329
|
+
status=status,
|
|
330
|
+
)
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
def normalize_capability_router(raw: Any) -> dict[str, Any]:
|
|
334
|
+
if raw is None:
|
|
335
|
+
return default_capability_router()
|
|
336
|
+
if not isinstance(raw, dict):
|
|
337
|
+
raise AdapterMiddlewareError("capability_router must be a JSON object")
|
|
338
|
+
allowed = {"schema_version", "source", *RETRIEVAL_INTENTS}
|
|
339
|
+
for key in list(raw.keys()):
|
|
340
|
+
if key not in allowed:
|
|
341
|
+
raise AdapterMiddlewareError(
|
|
342
|
+
"capability_router must contain only retrieval intent keys"
|
|
343
|
+
)
|
|
344
|
+
next_router = default_capability_router()
|
|
345
|
+
for intent in RETRIEVAL_INTENTS:
|
|
346
|
+
if raw.get(intent) is False:
|
|
347
|
+
next_router.pop(intent, None)
|
|
348
|
+
else:
|
|
349
|
+
next_router[intent] = True
|
|
350
|
+
return next_router
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
def required_capabilities(extras: dict[str, Any]) -> list[str]:
|
|
354
|
+
raw = extras.get("required_capabilities") or []
|
|
355
|
+
if not isinstance(raw, list):
|
|
356
|
+
return []
|
|
357
|
+
out: list[str] = []
|
|
358
|
+
for item in raw:
|
|
359
|
+
if isinstance(item, str) and item.strip() and item not in out:
|
|
360
|
+
out.append(item.strip())
|
|
361
|
+
return out
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
def assert_external_knowledge(
|
|
365
|
+
extras: dict[str, Any],
|
|
366
|
+
readiness: dict[str, Any],
|
|
367
|
+
*,
|
|
368
|
+
phase: str,
|
|
369
|
+
) -> None:
|
|
370
|
+
if phase in {"create", "patch"}:
|
|
371
|
+
return
|
|
372
|
+
if EXTERNAL_KNOWLEDGE_CAPABILITY not in required_capabilities(extras):
|
|
373
|
+
return
|
|
374
|
+
if readiness.get("status") == "ready":
|
|
375
|
+
return
|
|
376
|
+
if extras.get("external_knowledge_policy") == "degrade":
|
|
377
|
+
extras["profile_health"] = "degraded"
|
|
378
|
+
return
|
|
379
|
+
raise AdapterMiddlewareError(
|
|
380
|
+
"required external capability has no ready authorized Provider"
|
|
381
|
+
)
|
|
382
|
+
|
|
383
|
+
|
|
384
|
+
# Pactile Provider Resolver v1 -------------------------------------------------
|
|
385
|
+
#
|
|
386
|
+
# This is the shipped Python mirror of the host-neutral TypeScript resolver.
|
|
387
|
+
# It consumes caller-supplied facts only: no clock, filesystem, process,
|
|
388
|
+
# network, environment, credential, host config, or probe is read here.
|
|
389
|
+
|
|
390
|
+
PROVIDER_RESOLUTION_REASON_CODES_V1 = (
|
|
391
|
+
"provider-selected",
|
|
392
|
+
"provider-unsupported",
|
|
393
|
+
"provider-input-invalid",
|
|
394
|
+
"provider-manifest-invalid",
|
|
395
|
+
"provider-manifest-duplicate",
|
|
396
|
+
"provider-runtime-fact-duplicate",
|
|
397
|
+
"provider-binding-duplicate",
|
|
398
|
+
"provider-not-authorized",
|
|
399
|
+
"provider-intent-mismatch",
|
|
400
|
+
"provider-capability-mismatch",
|
|
401
|
+
"provider-policy-filesystem-exceeded",
|
|
402
|
+
"provider-policy-process-exceeded",
|
|
403
|
+
"provider-policy-network-exceeded",
|
|
404
|
+
"provider-policy-credentials-exceeded",
|
|
405
|
+
"provider-policy-privacy-exceeded",
|
|
406
|
+
"provider-policy-egress-exceeded",
|
|
407
|
+
"provider-policy-telemetry-exceeded",
|
|
408
|
+
"provider-policy-cost-exceeded",
|
|
409
|
+
"provider-policy-exceeded",
|
|
410
|
+
"provider-binding-missing",
|
|
411
|
+
"provider-binding-capability-mismatch",
|
|
412
|
+
"provider-binding-intent-mismatch",
|
|
413
|
+
"provider-binding-readiness-unknown",
|
|
414
|
+
"provider-binding-unavailable",
|
|
415
|
+
"provider-runtime-fact-missing",
|
|
416
|
+
"provider-runtime-version-mismatch",
|
|
417
|
+
"provider-readiness-unknown",
|
|
418
|
+
"provider-readiness-unavailable",
|
|
419
|
+
"provider-probe-unexpected",
|
|
420
|
+
"provider-probe-not-run",
|
|
421
|
+
"provider-probe-failed",
|
|
422
|
+
"provider-probe-time-invalid",
|
|
423
|
+
"provider-probe-from-future",
|
|
424
|
+
"provider-probe-expired",
|
|
425
|
+
"provider-freshness-unknown",
|
|
426
|
+
"provider-freshness-stale",
|
|
427
|
+
"provider-assurance-exceeds-manifest",
|
|
428
|
+
"provider-assurance-insufficient",
|
|
429
|
+
"provider-evidence-missing",
|
|
430
|
+
"provider-degraded-without-evidence",
|
|
431
|
+
"provider-active-missing",
|
|
432
|
+
"provider-fallback-disabled",
|
|
433
|
+
"provider-not-preferred",
|
|
434
|
+
"provider-not-selected",
|
|
435
|
+
"provider-eligible",
|
|
436
|
+
"provider-selected-active",
|
|
437
|
+
"provider-selected-fallback",
|
|
438
|
+
"provider-selected-stable",
|
|
439
|
+
)
|
|
440
|
+
|
|
441
|
+
_ASSURANCE_LEVELS = ("best-effort", "evidence-backed", "verified")
|
|
442
|
+
_INTENTS = ("exact", "semantic", "structural", "external")
|
|
443
|
+
_ORIGINS = ("native", "provider", "heuristic")
|
|
444
|
+
_READINESS = ("ready", "degraded", "unavailable")
|
|
445
|
+
_FRESHNESS = ("fresh", "stale", "unknown", "not-applicable")
|
|
446
|
+
_PROBE_RESULTS = ("passed", "failed", "not-run")
|
|
447
|
+
_FILESYSTEM = ("none", "read", "write")
|
|
448
|
+
_PROCESS = ("none", "execute")
|
|
449
|
+
_NETWORK = ("forbidden", "project-authorized")
|
|
450
|
+
_CREDENTIALS = ("forbidden", "project-authorized")
|
|
451
|
+
_PRIVACY = ("local-only", "project-approved-egress", "external")
|
|
452
|
+
_TELEMETRY = ("forbidden", "local-only", "project-authorized")
|
|
453
|
+
_COST = ("none", "free", "low", "medium", "high")
|
|
454
|
+
_LOGICAL_ID = re.compile(r"^[a-z][a-z0-9]*(?:[._:-][a-z0-9]+)*$")
|
|
455
|
+
_SEMVER = re.compile(
|
|
456
|
+
r"^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)"
|
|
457
|
+
r"(?:-[0-9A-Za-z]+(?:\.[0-9A-Za-z]+)*)?"
|
|
458
|
+
r"(?:\+[0-9A-Za-z]+(?:\.[0-9A-Za-z]+)*)?$"
|
|
459
|
+
)
|
|
460
|
+
_EVIDENCE_REFERENCE = re.compile(
|
|
461
|
+
r"^evidence://[a-z0-9]+(?:[._-][a-z0-9]+)*"
|
|
462
|
+
r"(?:/[a-z0-9]+(?:[._-][a-z0-9]+)*)*$"
|
|
463
|
+
)
|
|
464
|
+
_POLICY_DESTINATION = re.compile(
|
|
465
|
+
r"^[a-z0-9]+(?:[._-][a-z0-9]+)*(?::[0-9]+)?$"
|
|
466
|
+
)
|
|
467
|
+
_OPAQUE_REFERENCE = re.compile(
|
|
468
|
+
r"^([a-z][a-z0-9-]{0,31})://"
|
|
469
|
+
r"([a-z0-9]+(?:[._-][a-z0-9]+)*(?:/[a-z0-9]+(?:[._-][a-z0-9]+)*)*)$"
|
|
470
|
+
)
|
|
471
|
+
_FINGERPRINT = re.compile(r"^sha256:[0-9a-f]{64}$")
|
|
472
|
+
_RFC3339 = re.compile(
|
|
473
|
+
r"^(?P<year>[0-9]{4})-(?P<month>[0-9]{2})-(?P<day>[0-9]{2})"
|
|
474
|
+
r"T(?P<hour>[0-9]{2}):(?P<minute>[0-9]{2}):(?P<second>[0-9]{2})"
|
|
475
|
+
r"(?:\.(?P<fraction>[0-9]{1,9}))?"
|
|
476
|
+
r"(?:Z|(?P<offset_sign>[+-])(?P<offset_hour>[0-9]{2}):(?P<offset_minute>[0-9]{2}))$"
|
|
477
|
+
)
|
|
478
|
+
_SENSITIVE_REFERENCE_TERMS = {
|
|
479
|
+
"credential",
|
|
480
|
+
"credentials",
|
|
481
|
+
"passwd",
|
|
482
|
+
"password",
|
|
483
|
+
"secret",
|
|
484
|
+
"token",
|
|
485
|
+
}
|
|
486
|
+
_POLICY_KEYS = {
|
|
487
|
+
"filesystem",
|
|
488
|
+
"process",
|
|
489
|
+
"network",
|
|
490
|
+
"credentials",
|
|
491
|
+
"privacy",
|
|
492
|
+
"egressDestinations",
|
|
493
|
+
"telemetry",
|
|
494
|
+
"cost",
|
|
495
|
+
}
|
|
496
|
+
_INVALID_JSON_VALUE = object()
|
|
497
|
+
_FORBIDDEN_JSON_RECORD_KEYS = {"__proto__", "constructor", "prototype"}
|
|
498
|
+
|
|
499
|
+
|
|
500
|
+
def _snapshot_plain_json_value(value: Any, seen: set[int] | None = None) -> Any:
|
|
501
|
+
if value is None or type(value) in {bool, int, str}:
|
|
502
|
+
return value
|
|
503
|
+
if type(value) is float:
|
|
504
|
+
return value if math.isfinite(value) else _INVALID_JSON_VALUE
|
|
505
|
+
if type(value) not in {dict, list}:
|
|
506
|
+
return _INVALID_JSON_VALUE
|
|
507
|
+
|
|
508
|
+
if seen is None:
|
|
509
|
+
seen = set()
|
|
510
|
+
identity = id(value)
|
|
511
|
+
if identity in seen:
|
|
512
|
+
return _INVALID_JSON_VALUE
|
|
513
|
+
seen.add(identity)
|
|
514
|
+
|
|
515
|
+
if type(value) is list:
|
|
516
|
+
result = []
|
|
517
|
+
for item in value:
|
|
518
|
+
snapshot = _snapshot_plain_json_value(item, seen)
|
|
519
|
+
if snapshot is _INVALID_JSON_VALUE:
|
|
520
|
+
seen.remove(identity)
|
|
521
|
+
return _INVALID_JSON_VALUE
|
|
522
|
+
result.append(snapshot)
|
|
523
|
+
seen.remove(identity)
|
|
524
|
+
return result
|
|
525
|
+
|
|
526
|
+
result = {}
|
|
527
|
+
for key, item in value.items():
|
|
528
|
+
if type(key) is not str or key in _FORBIDDEN_JSON_RECORD_KEYS:
|
|
529
|
+
seen.remove(identity)
|
|
530
|
+
return _INVALID_JSON_VALUE
|
|
531
|
+
snapshot = _snapshot_plain_json_value(item, seen)
|
|
532
|
+
if snapshot is _INVALID_JSON_VALUE:
|
|
533
|
+
seen.remove(identity)
|
|
534
|
+
return _INVALID_JSON_VALUE
|
|
535
|
+
result[key] = snapshot
|
|
536
|
+
seen.remove(identity)
|
|
537
|
+
return result
|
|
538
|
+
|
|
539
|
+
|
|
540
|
+
def _is_leap_year(year: int) -> bool:
|
|
541
|
+
return year % 4 == 0 and (year % 100 != 0 or year % 400 == 0)
|
|
542
|
+
|
|
543
|
+
|
|
544
|
+
def _parse_timestamp_ms(value: Any) -> int | None:
|
|
545
|
+
if not isinstance(value, str):
|
|
546
|
+
return None
|
|
547
|
+
match = _RFC3339.fullmatch(value)
|
|
548
|
+
if match is None:
|
|
549
|
+
return None
|
|
550
|
+
year = int(match.group("year"))
|
|
551
|
+
month = int(match.group("month"))
|
|
552
|
+
day = int(match.group("day"))
|
|
553
|
+
hour = int(match.group("hour"))
|
|
554
|
+
minute = int(match.group("minute"))
|
|
555
|
+
second = int(match.group("second"))
|
|
556
|
+
offset_hour = int(match.group("offset_hour") or 0)
|
|
557
|
+
offset_minute = int(match.group("offset_minute") or 0)
|
|
558
|
+
days_in_month = (
|
|
559
|
+
31,
|
|
560
|
+
29 if _is_leap_year(year) else 28,
|
|
561
|
+
31,
|
|
562
|
+
30,
|
|
563
|
+
31,
|
|
564
|
+
30,
|
|
565
|
+
31,
|
|
566
|
+
31,
|
|
567
|
+
30,
|
|
568
|
+
31,
|
|
569
|
+
30,
|
|
570
|
+
31,
|
|
571
|
+
)
|
|
572
|
+
if (
|
|
573
|
+
year == 0
|
|
574
|
+
or month < 1
|
|
575
|
+
or month > 12
|
|
576
|
+
or day < 1
|
|
577
|
+
or day > days_in_month[month - 1]
|
|
578
|
+
or hour > 23
|
|
579
|
+
or minute > 59
|
|
580
|
+
or second > 59
|
|
581
|
+
or offset_hour > 23
|
|
582
|
+
or offset_minute > 59
|
|
583
|
+
):
|
|
584
|
+
return None
|
|
585
|
+
|
|
586
|
+
local = datetime(year, month, day, hour, minute, second)
|
|
587
|
+
epoch = datetime(1970, 1, 1)
|
|
588
|
+
delta = local - epoch
|
|
589
|
+
fraction_ms = int(((match.group("fraction") or "") + "000")[:3])
|
|
590
|
+
offset_minutes = offset_hour * 60 + offset_minute
|
|
591
|
+
if match.group("offset_sign") == "-":
|
|
592
|
+
offset_minutes = -offset_minutes
|
|
593
|
+
return (
|
|
594
|
+
(delta.days * 86_400 + delta.seconds) * 1_000
|
|
595
|
+
+ fraction_ms
|
|
596
|
+
- offset_minutes * 60_000
|
|
597
|
+
)
|
|
598
|
+
|
|
599
|
+
|
|
600
|
+
def _valid_timestamp(value: Any) -> bool:
|
|
601
|
+
return _parse_timestamp_ms(value) is not None
|
|
602
|
+
|
|
603
|
+
|
|
604
|
+
def _timestamp_ms(value: str) -> int:
|
|
605
|
+
parsed = _parse_timestamp_ms(value)
|
|
606
|
+
if parsed is None:
|
|
607
|
+
raise ValueError("invalid RFC3339 timestamp")
|
|
608
|
+
return parsed
|
|
609
|
+
|
|
610
|
+
|
|
611
|
+
def _valid_evidence_reference(value: Any) -> bool:
|
|
612
|
+
if (
|
|
613
|
+
not isinstance(value, str)
|
|
614
|
+
or len(value) > 256
|
|
615
|
+
or _EVIDENCE_REFERENCE.fullmatch(value) is None
|
|
616
|
+
):
|
|
617
|
+
return False
|
|
618
|
+
payload = value[len("evidence://") :].replace("/", ".")
|
|
619
|
+
return not any(
|
|
620
|
+
term in _SENSITIVE_REFERENCE_TERMS for term in re.split(r"[_.-]", payload)
|
|
621
|
+
)
|
|
622
|
+
|
|
623
|
+
|
|
624
|
+
def _valid_policy_destination(value: Any) -> bool:
|
|
625
|
+
if (
|
|
626
|
+
not isinstance(value, str)
|
|
627
|
+
or len(value) > 253
|
|
628
|
+
or _POLICY_DESTINATION.fullmatch(value) is None
|
|
629
|
+
):
|
|
630
|
+
return False
|
|
631
|
+
return not any(
|
|
632
|
+
term in _SENSITIVE_REFERENCE_TERMS
|
|
633
|
+
for term in re.split(r"[_.:-]", value)
|
|
634
|
+
)
|
|
635
|
+
|
|
636
|
+
|
|
637
|
+
def _valid_opaque_reference(value: Any, allowed_schemes: set[str]) -> bool:
|
|
638
|
+
if not isinstance(value, str) or len(value) > 256:
|
|
639
|
+
return False
|
|
640
|
+
match = _OPAQUE_REFERENCE.fullmatch(value)
|
|
641
|
+
if match is None or match.group(1) not in allowed_schemes:
|
|
642
|
+
return False
|
|
643
|
+
return not any(
|
|
644
|
+
term in _SENSITIVE_REFERENCE_TERMS
|
|
645
|
+
for term in re.split(r"[_.\-/]", match.group(2))
|
|
646
|
+
)
|
|
647
|
+
|
|
648
|
+
|
|
649
|
+
def _normalize_install_hint(value: Any) -> dict[str, Any] | None:
|
|
650
|
+
keys = {
|
|
651
|
+
"schemaVersion",
|
|
652
|
+
"mechanism",
|
|
653
|
+
"label",
|
|
654
|
+
"reference",
|
|
655
|
+
"requiresAuthentication",
|
|
656
|
+
}
|
|
657
|
+
if not isinstance(value, dict) or set(value) != keys or value.get("schemaVersion") != 1:
|
|
658
|
+
return None
|
|
659
|
+
label = value.get("label")
|
|
660
|
+
reference = value.get("reference")
|
|
661
|
+
if (
|
|
662
|
+
value.get("mechanism") not in {"host-native", "package-manager", "manual"}
|
|
663
|
+
or not isinstance(label, str)
|
|
664
|
+
or len(label) > 128
|
|
665
|
+
or _LOGICAL_ID.fullmatch(label) is None
|
|
666
|
+
or not (
|
|
667
|
+
reference is None
|
|
668
|
+
or _valid_opaque_reference(
|
|
669
|
+
reference, {"docs", "host-native", "package-manager"}
|
|
670
|
+
)
|
|
671
|
+
)
|
|
672
|
+
or not isinstance(value.get("requiresAuthentication"), bool)
|
|
673
|
+
):
|
|
674
|
+
return None
|
|
675
|
+
return dict(value)
|
|
676
|
+
|
|
677
|
+
|
|
678
|
+
def _sorted_unique_strings(value: Any, *, logical_ids: bool = False) -> list[str] | None:
|
|
679
|
+
if not isinstance(value, list) or not all(isinstance(item, str) for item in value):
|
|
680
|
+
return None
|
|
681
|
+
if logical_ids and not all(_LOGICAL_ID.fullmatch(item) for item in value):
|
|
682
|
+
return None
|
|
683
|
+
return sorted(set(value))
|
|
684
|
+
|
|
685
|
+
|
|
686
|
+
def _normalize_policy(value: Any) -> dict[str, Any] | None:
|
|
687
|
+
if not isinstance(value, dict) or set(value) != _POLICY_KEYS:
|
|
688
|
+
return None
|
|
689
|
+
destinations = value.get("egressDestinations")
|
|
690
|
+
if (
|
|
691
|
+
not isinstance(destinations, list)
|
|
692
|
+
or not all(_valid_policy_destination(item) for item in destinations)
|
|
693
|
+
or len(set(destinations)) != len(destinations)
|
|
694
|
+
or value.get("filesystem") not in _FILESYSTEM
|
|
695
|
+
or value.get("process") not in _PROCESS
|
|
696
|
+
or value.get("network") not in _NETWORK
|
|
697
|
+
or value.get("credentials") not in _CREDENTIALS
|
|
698
|
+
or value.get("privacy") not in _PRIVACY
|
|
699
|
+
or value.get("telemetry") not in _TELEMETRY
|
|
700
|
+
or value.get("cost") not in _COST
|
|
701
|
+
):
|
|
702
|
+
return None
|
|
703
|
+
if value["network"] == "forbidden" and (
|
|
704
|
+
value["privacy"] != "local-only" or destinations
|
|
705
|
+
):
|
|
706
|
+
return None
|
|
707
|
+
if (
|
|
708
|
+
value["network"] == "project-authorized"
|
|
709
|
+
and value["privacy"] != "local-only"
|
|
710
|
+
and not destinations
|
|
711
|
+
):
|
|
712
|
+
return None
|
|
713
|
+
if value["network"] == "forbidden" and value["telemetry"] == "project-authorized":
|
|
714
|
+
return None
|
|
715
|
+
return {
|
|
716
|
+
"filesystem": value["filesystem"],
|
|
717
|
+
"process": value["process"],
|
|
718
|
+
"network": value["network"],
|
|
719
|
+
"credentials": value["credentials"],
|
|
720
|
+
"privacy": value["privacy"],
|
|
721
|
+
"egressDestinations": sorted(destinations),
|
|
722
|
+
"telemetry": value["telemetry"],
|
|
723
|
+
"cost": value["cost"],
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
|
|
727
|
+
def _normalize_manifest(value: Any) -> dict[str, Any] | None:
|
|
728
|
+
keys = {
|
|
729
|
+
"schemaVersion",
|
|
730
|
+
"id",
|
|
731
|
+
"version",
|
|
732
|
+
"origin",
|
|
733
|
+
"intents",
|
|
734
|
+
"capabilityIds",
|
|
735
|
+
"maximumAssurance",
|
|
736
|
+
"policyCeiling",
|
|
737
|
+
"evidenceKinds",
|
|
738
|
+
"probe",
|
|
739
|
+
}
|
|
740
|
+
if not isinstance(value, dict) or set(value) != keys or value.get("schemaVersion") != 1:
|
|
741
|
+
return None
|
|
742
|
+
intents = _sorted_unique_strings(value.get("intents"))
|
|
743
|
+
capability_ids = _sorted_unique_strings(value.get("capabilityIds"))
|
|
744
|
+
evidence_kinds = _sorted_unique_strings(value.get("evidenceKinds"))
|
|
745
|
+
policy = _normalize_policy(value.get("policyCeiling"))
|
|
746
|
+
probe = value.get("probe")
|
|
747
|
+
if (
|
|
748
|
+
not isinstance(value.get("id"), str)
|
|
749
|
+
or _LOGICAL_ID.fullmatch(value["id"]) is None
|
|
750
|
+
or not isinstance(value.get("version"), str)
|
|
751
|
+
or _SEMVER.fullmatch(value["version"]) is None
|
|
752
|
+
or value.get("origin") not in _ORIGINS
|
|
753
|
+
or intents is None
|
|
754
|
+
or not intents
|
|
755
|
+
or len(intents) != len(value["intents"])
|
|
756
|
+
or not all(intent in _INTENTS for intent in intents)
|
|
757
|
+
or capability_ids is None
|
|
758
|
+
or len(capability_ids) != len(value["capabilityIds"])
|
|
759
|
+
or not all(_LOGICAL_ID.fullmatch(item) for item in capability_ids)
|
|
760
|
+
or value.get("maximumAssurance") not in _ASSURANCE_LEVELS
|
|
761
|
+
or policy is None
|
|
762
|
+
or evidence_kinds is None
|
|
763
|
+
or len(evidence_kinds) != len(value["evidenceKinds"])
|
|
764
|
+
or not all(evidence_kinds)
|
|
765
|
+
or not isinstance(probe, dict)
|
|
766
|
+
or set(probe) != {"supported", "maxAgeSeconds"}
|
|
767
|
+
or not isinstance(probe.get("supported"), bool)
|
|
768
|
+
):
|
|
769
|
+
return None
|
|
770
|
+
max_age = probe.get("maxAgeSeconds")
|
|
771
|
+
if probe["supported"]:
|
|
772
|
+
if not isinstance(max_age, int) or isinstance(max_age, bool) or max_age < 1:
|
|
773
|
+
return None
|
|
774
|
+
elif max_age is not None:
|
|
775
|
+
return None
|
|
776
|
+
if value["maximumAssurance"] in {"evidence-backed", "verified"} and not evidence_kinds:
|
|
777
|
+
return None
|
|
778
|
+
if value["maximumAssurance"] == "verified" and not probe["supported"]:
|
|
779
|
+
return None
|
|
780
|
+
return {
|
|
781
|
+
"schemaVersion": 1,
|
|
782
|
+
"id": value["id"],
|
|
783
|
+
"version": value["version"],
|
|
784
|
+
"origin": value["origin"],
|
|
785
|
+
"intents": intents,
|
|
786
|
+
"capabilityIds": capability_ids,
|
|
787
|
+
"maximumAssurance": value["maximumAssurance"],
|
|
788
|
+
"policyCeiling": policy,
|
|
789
|
+
"evidenceKinds": evidence_kinds,
|
|
790
|
+
"probe": {"supported": probe["supported"], "maxAgeSeconds": max_age},
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
|
|
794
|
+
def _normalize_binding(value: Any) -> dict[str, Any] | None:
|
|
795
|
+
keys = {
|
|
796
|
+
"schemaVersion",
|
|
797
|
+
"id",
|
|
798
|
+
"capabilityId",
|
|
799
|
+
"mode",
|
|
800
|
+
"control",
|
|
801
|
+
"deleteBoundary",
|
|
802
|
+
"asset",
|
|
803
|
+
"intents",
|
|
804
|
+
"providerId",
|
|
805
|
+
}
|
|
806
|
+
if not isinstance(value, dict) or set(value) != keys or value.get("schemaVersion") != 1:
|
|
807
|
+
return None
|
|
808
|
+
asset = value.get("asset")
|
|
809
|
+
owner = asset.get("owner") if isinstance(asset, dict) else None
|
|
810
|
+
asset_keys = {
|
|
811
|
+
"schemaVersion",
|
|
812
|
+
"id",
|
|
813
|
+
"kind",
|
|
814
|
+
"source",
|
|
815
|
+
"scope",
|
|
816
|
+
"owner",
|
|
817
|
+
"locator",
|
|
818
|
+
"fingerprint",
|
|
819
|
+
"readiness",
|
|
820
|
+
"installHint",
|
|
821
|
+
}
|
|
822
|
+
if (
|
|
823
|
+
not isinstance(value.get("id"), str)
|
|
824
|
+
or _LOGICAL_ID.fullmatch(value["id"]) is None
|
|
825
|
+
or not isinstance(value.get("capabilityId"), str)
|
|
826
|
+
or _LOGICAL_ID.fullmatch(value["capabilityId"]) is None
|
|
827
|
+
or value.get("mode") not in {"native", "adopted", "composed"}
|
|
828
|
+
or value.get("control") not in {"borrowed", "pactile-owned"}
|
|
829
|
+
or value.get("deleteBoundary") not in {"preserve", "remove-when-unclaimed"}
|
|
830
|
+
or not isinstance(asset, dict)
|
|
831
|
+
or set(asset) != asset_keys
|
|
832
|
+
or asset.get("schemaVersion") != 1
|
|
833
|
+
or not isinstance(asset.get("id"), str)
|
|
834
|
+
or _LOGICAL_ID.fullmatch(asset["id"]) is None
|
|
835
|
+
or asset.get("kind") not in {"skill", "mcp", "plugin", "executable", "service"}
|
|
836
|
+
or asset.get("source") not in {
|
|
837
|
+
"host-native",
|
|
838
|
+
"user-installed",
|
|
839
|
+
"pactile-bundled",
|
|
840
|
+
"project-vendored",
|
|
841
|
+
}
|
|
842
|
+
or asset.get("scope") not in {"project", "user", "host"}
|
|
843
|
+
or not isinstance(owner, dict)
|
|
844
|
+
or set(owner) != {"kind", "id"}
|
|
845
|
+
or owner.get("kind") not in {"user", "host", "pactile", "third-party"}
|
|
846
|
+
or asset.get("readiness") not in {"ready", "degraded", "missing", "unknown"}
|
|
847
|
+
):
|
|
848
|
+
return None
|
|
849
|
+
owner_id = owner.get("id")
|
|
850
|
+
fingerprint = asset.get("fingerprint")
|
|
851
|
+
hint_value = asset.get("installHint")
|
|
852
|
+
hint = None if hint_value is None else _normalize_install_hint(hint_value)
|
|
853
|
+
if (
|
|
854
|
+
not (owner_id is None or isinstance(owner_id, str) and bool(owner_id))
|
|
855
|
+
or owner["kind"] in {"pactile", "third-party"} and owner_id is None
|
|
856
|
+
or asset["source"] == "pactile-bundled" and owner["kind"] != "pactile"
|
|
857
|
+
or asset["source"] == "host-native" and owner["kind"] != "host"
|
|
858
|
+
or not _valid_opaque_reference(asset.get("locator"), {asset["source"]})
|
|
859
|
+
or not (
|
|
860
|
+
fingerprint is None
|
|
861
|
+
or isinstance(fingerprint, str) and _FINGERPRINT.fullmatch(fingerprint)
|
|
862
|
+
)
|
|
863
|
+
or hint_value is not None and hint is None
|
|
864
|
+
or asset["readiness"] == "missing" and hint is None
|
|
865
|
+
):
|
|
866
|
+
return None
|
|
867
|
+
intents = _sorted_unique_strings(value.get("intents"))
|
|
868
|
+
provider_id = value.get("providerId")
|
|
869
|
+
if (
|
|
870
|
+
intents is None
|
|
871
|
+
or len(intents) != len(value["intents"])
|
|
872
|
+
or not all(intent in _INTENTS for intent in intents)
|
|
873
|
+
or not (
|
|
874
|
+
provider_id is None
|
|
875
|
+
or isinstance(provider_id, str) and _LOGICAL_ID.fullmatch(provider_id)
|
|
876
|
+
)
|
|
877
|
+
or asset["kind"] == "mcp" and provider_id is None
|
|
878
|
+
or value["control"] == "borrowed" and value["deleteBoundary"] != "preserve"
|
|
879
|
+
or value["mode"] in {"native", "adopted"} and value["control"] != "borrowed"
|
|
880
|
+
or value["mode"] == "native"
|
|
881
|
+
and asset["source"] not in {"host-native", "user-installed"}
|
|
882
|
+
or value["mode"] == "adopted" and asset["source"] == "pactile-bundled"
|
|
883
|
+
or value["control"] == "pactile-owned"
|
|
884
|
+
and (
|
|
885
|
+
owner["kind"] != "pactile"
|
|
886
|
+
or value["deleteBoundary"] != "remove-when-unclaimed"
|
|
887
|
+
or value["mode"] != "composed"
|
|
888
|
+
or asset["source"] not in {"pactile-bundled", "project-vendored"}
|
|
889
|
+
)
|
|
890
|
+
):
|
|
891
|
+
return None
|
|
892
|
+
normalized = dict(value)
|
|
893
|
+
normalized["asset"] = {
|
|
894
|
+
**asset,
|
|
895
|
+
"owner": dict(owner),
|
|
896
|
+
"installHint": hint,
|
|
897
|
+
}
|
|
898
|
+
normalized["intents"] = intents
|
|
899
|
+
return normalized
|
|
900
|
+
|
|
901
|
+
|
|
902
|
+
def _normalize_runtime_fact(value: Any) -> dict[str, Any] | None:
|
|
903
|
+
keys = {
|
|
904
|
+
"providerId",
|
|
905
|
+
"providerVersion",
|
|
906
|
+
"readiness",
|
|
907
|
+
"assurance",
|
|
908
|
+
"freshness",
|
|
909
|
+
"probedAt",
|
|
910
|
+
"probeResult",
|
|
911
|
+
"evidenceRefs",
|
|
912
|
+
}
|
|
913
|
+
if not isinstance(value, dict) or set(value) != keys:
|
|
914
|
+
return None
|
|
915
|
+
refs = value.get("evidenceRefs")
|
|
916
|
+
probed_at = value.get("probedAt")
|
|
917
|
+
if (
|
|
918
|
+
not isinstance(value.get("providerId"), str)
|
|
919
|
+
or _LOGICAL_ID.fullmatch(value["providerId"]) is None
|
|
920
|
+
or not isinstance(value.get("providerVersion"), str)
|
|
921
|
+
or _SEMVER.fullmatch(value["providerVersion"]) is None
|
|
922
|
+
or value.get("readiness") not in {*_READINESS, "unknown"}
|
|
923
|
+
or value.get("assurance") not in {*_ASSURANCE_LEVELS, None}
|
|
924
|
+
or value.get("freshness") not in _FRESHNESS
|
|
925
|
+
or value.get("probeResult") not in _PROBE_RESULTS
|
|
926
|
+
or not isinstance(refs, list)
|
|
927
|
+
or not all(_valid_evidence_reference(ref) for ref in refs)
|
|
928
|
+
or not (probed_at is None or _valid_timestamp(probed_at))
|
|
929
|
+
or value["probeResult"] == "not-run" and probed_at is not None
|
|
930
|
+
or value["probeResult"] != "not-run" and probed_at is None
|
|
931
|
+
):
|
|
932
|
+
return None
|
|
933
|
+
normalized = dict(value)
|
|
934
|
+
normalized["evidenceRefs"] = sorted(set(refs))
|
|
935
|
+
return normalized
|
|
936
|
+
|
|
937
|
+
|
|
938
|
+
def _invalid_resolution(reason: str) -> dict[str, Any]:
|
|
939
|
+
return {
|
|
940
|
+
"schemaVersion": 1,
|
|
941
|
+
"status": "invalid",
|
|
942
|
+
"resolution": None,
|
|
943
|
+
"fingerprint": None,
|
|
944
|
+
"explain": {
|
|
945
|
+
"schemaVersion": 1,
|
|
946
|
+
"decision": "invalid",
|
|
947
|
+
"reasonCode": reason,
|
|
948
|
+
"selectedProviderId": None,
|
|
949
|
+
"fallbackFromProviderId": None,
|
|
950
|
+
"effectivePolicy": None,
|
|
951
|
+
"evidenceRefs": [],
|
|
952
|
+
"candidates": [],
|
|
953
|
+
},
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
|
|
957
|
+
def _normalize_resolver_input(value: Any) -> tuple[dict[str, Any] | None, str | None]:
|
|
958
|
+
keys = {
|
|
959
|
+
"schemaVersion",
|
|
960
|
+
"intent",
|
|
961
|
+
"capabilityId",
|
|
962
|
+
"minimumAssurance",
|
|
963
|
+
"requestedPolicy",
|
|
964
|
+
"authorizedProviderIds",
|
|
965
|
+
"activeProviderIds",
|
|
966
|
+
"standbyProviderIds",
|
|
967
|
+
"fallbackAllowed",
|
|
968
|
+
"manifests",
|
|
969
|
+
"bindings",
|
|
970
|
+
"runtimeFacts",
|
|
971
|
+
"now",
|
|
972
|
+
}
|
|
973
|
+
if (
|
|
974
|
+
not isinstance(value, dict)
|
|
975
|
+
or set(value) != keys
|
|
976
|
+
or value.get("schemaVersion") != 1
|
|
977
|
+
):
|
|
978
|
+
return None, "provider-input-invalid"
|
|
979
|
+
policy = _normalize_policy(value.get("requestedPolicy"))
|
|
980
|
+
authorized = _sorted_unique_strings(value.get("authorizedProviderIds"), logical_ids=True)
|
|
981
|
+
active = _sorted_unique_strings(value.get("activeProviderIds"), logical_ids=True)
|
|
982
|
+
standby = _sorted_unique_strings(value.get("standbyProviderIds"), logical_ids=True)
|
|
983
|
+
capability_id = value.get("capabilityId")
|
|
984
|
+
if (
|
|
985
|
+
policy is None
|
|
986
|
+
or authorized is None
|
|
987
|
+
or active is None
|
|
988
|
+
or standby is None
|
|
989
|
+
or any(item in standby for item in active)
|
|
990
|
+
or not isinstance(value.get("fallbackAllowed"), bool)
|
|
991
|
+
or value.get("intent") not in _INTENTS
|
|
992
|
+
or value.get("minimumAssurance") not in _ASSURANCE_LEVELS
|
|
993
|
+
or not (
|
|
994
|
+
capability_id is None
|
|
995
|
+
or isinstance(capability_id, str) and _LOGICAL_ID.fullmatch(capability_id)
|
|
996
|
+
)
|
|
997
|
+
or not _valid_timestamp(value.get("now"))
|
|
998
|
+
or not isinstance(value.get("manifests"), list)
|
|
999
|
+
or not isinstance(value.get("bindings"), list)
|
|
1000
|
+
or not isinstance(value.get("runtimeFacts"), list)
|
|
1001
|
+
):
|
|
1002
|
+
return None, "provider-input-invalid"
|
|
1003
|
+
|
|
1004
|
+
manifests: list[dict[str, Any]] = []
|
|
1005
|
+
for item in value["manifests"]:
|
|
1006
|
+
manifest = _normalize_manifest(item)
|
|
1007
|
+
if manifest is None:
|
|
1008
|
+
return None, "provider-manifest-invalid"
|
|
1009
|
+
manifests.append(manifest)
|
|
1010
|
+
manifests.sort(key=lambda item: (item["id"], item["version"]))
|
|
1011
|
+
identities = [(item["id"], item["version"]) for item in manifests]
|
|
1012
|
+
if len(set(identities)) != len(identities):
|
|
1013
|
+
return None, "provider-manifest-duplicate"
|
|
1014
|
+
|
|
1015
|
+
bindings: list[dict[str, Any]] = []
|
|
1016
|
+
for item in value["bindings"]:
|
|
1017
|
+
binding = _normalize_binding(item)
|
|
1018
|
+
if binding is None:
|
|
1019
|
+
return None, "provider-input-invalid"
|
|
1020
|
+
bindings.append(binding)
|
|
1021
|
+
bindings.sort(key=lambda item: item["id"])
|
|
1022
|
+
if len({item["id"] for item in bindings}) != len(bindings):
|
|
1023
|
+
return None, "provider-binding-duplicate"
|
|
1024
|
+
|
|
1025
|
+
runtime_facts: list[dict[str, Any]] = []
|
|
1026
|
+
for item in value["runtimeFacts"]:
|
|
1027
|
+
fact = _normalize_runtime_fact(item)
|
|
1028
|
+
if fact is None:
|
|
1029
|
+
return None, "provider-input-invalid"
|
|
1030
|
+
runtime_facts.append(fact)
|
|
1031
|
+
runtime_facts.sort(key=lambda item: (item["providerId"], item["providerVersion"]))
|
|
1032
|
+
fact_ids = [(item["providerId"], item["providerVersion"]) for item in runtime_facts]
|
|
1033
|
+
if len(set(fact_ids)) != len(fact_ids):
|
|
1034
|
+
return None, "provider-runtime-fact-duplicate"
|
|
1035
|
+
|
|
1036
|
+
return {
|
|
1037
|
+
"schemaVersion": 1,
|
|
1038
|
+
"intent": value["intent"],
|
|
1039
|
+
"capabilityId": capability_id,
|
|
1040
|
+
"minimumAssurance": value["minimumAssurance"],
|
|
1041
|
+
"requestedPolicy": policy,
|
|
1042
|
+
"authorizedProviderIds": authorized,
|
|
1043
|
+
"activeProviderIds": active,
|
|
1044
|
+
"standbyProviderIds": standby,
|
|
1045
|
+
"fallbackAllowed": value["fallbackAllowed"],
|
|
1046
|
+
"manifests": manifests,
|
|
1047
|
+
"bindings": bindings,
|
|
1048
|
+
"runtimeFacts": runtime_facts,
|
|
1049
|
+
"nowEpochMs": _timestamp_ms(value["now"]),
|
|
1050
|
+
}, None
|
|
1051
|
+
|
|
1052
|
+
|
|
1053
|
+
def _policy_rejection(requested: dict[str, Any], ceiling: dict[str, Any]) -> str | None:
|
|
1054
|
+
ordered = (
|
|
1055
|
+
("filesystem", _FILESYSTEM, "provider-policy-filesystem-exceeded"),
|
|
1056
|
+
("process", _PROCESS, "provider-policy-process-exceeded"),
|
|
1057
|
+
("network", _NETWORK, "provider-policy-network-exceeded"),
|
|
1058
|
+
("credentials", _CREDENTIALS, "provider-policy-credentials-exceeded"),
|
|
1059
|
+
("privacy", _PRIVACY, "provider-policy-privacy-exceeded"),
|
|
1060
|
+
)
|
|
1061
|
+
for field, levels, reason in ordered:
|
|
1062
|
+
if levels.index(requested[field]) > levels.index(ceiling[field]):
|
|
1063
|
+
return reason
|
|
1064
|
+
if any(item not in ceiling["egressDestinations"] for item in requested["egressDestinations"]):
|
|
1065
|
+
return "provider-policy-egress-exceeded"
|
|
1066
|
+
if _TELEMETRY.index(requested["telemetry"]) > _TELEMETRY.index(ceiling["telemetry"]):
|
|
1067
|
+
return "provider-policy-telemetry-exceeded"
|
|
1068
|
+
if _COST.index(requested["cost"]) > _COST.index(ceiling["cost"]):
|
|
1069
|
+
return "provider-policy-cost-exceeded"
|
|
1070
|
+
return None
|
|
1071
|
+
|
|
1072
|
+
|
|
1073
|
+
def _candidate_role(provider_id: str, value: dict[str, Any]) -> str:
|
|
1074
|
+
if provider_id in value["activeProviderIds"]:
|
|
1075
|
+
return "active"
|
|
1076
|
+
if provider_id in value["standbyProviderIds"]:
|
|
1077
|
+
return "standby"
|
|
1078
|
+
return "default"
|
|
1079
|
+
|
|
1080
|
+
|
|
1081
|
+
def _evaluate_candidate(manifest: dict[str, Any], value: dict[str, Any]) -> dict[str, Any]:
|
|
1082
|
+
role = _candidate_role(manifest["id"], value)
|
|
1083
|
+
|
|
1084
|
+
def rejected(reason: str, fact: dict[str, Any] | None = None) -> dict[str, Any]:
|
|
1085
|
+
return {"manifest": manifest, "fact": fact, "role": role, "rejection": reason}
|
|
1086
|
+
|
|
1087
|
+
if manifest["id"] not in value["authorizedProviderIds"]:
|
|
1088
|
+
return rejected("provider-not-authorized")
|
|
1089
|
+
if value["intent"] not in manifest["intents"]:
|
|
1090
|
+
return rejected("provider-intent-mismatch")
|
|
1091
|
+
if value["capabilityId"] is not None and value["capabilityId"] not in manifest["capabilityIds"]:
|
|
1092
|
+
return rejected("provider-capability-mismatch")
|
|
1093
|
+
policy_reason = _policy_rejection(value["requestedPolicy"], manifest["policyCeiling"])
|
|
1094
|
+
if policy_reason is not None:
|
|
1095
|
+
return rejected(policy_reason)
|
|
1096
|
+
|
|
1097
|
+
provider_bindings = [
|
|
1098
|
+
item for item in value["bindings"] if item["providerId"] == manifest["id"]
|
|
1099
|
+
]
|
|
1100
|
+
if not provider_bindings:
|
|
1101
|
+
return rejected("provider-binding-missing")
|
|
1102
|
+
capability_bindings = [
|
|
1103
|
+
item
|
|
1104
|
+
for item in provider_bindings
|
|
1105
|
+
if (
|
|
1106
|
+
item["capabilityId"] in manifest["capabilityIds"]
|
|
1107
|
+
if value["capabilityId"] is None
|
|
1108
|
+
else item["capabilityId"] == value["capabilityId"]
|
|
1109
|
+
)
|
|
1110
|
+
]
|
|
1111
|
+
if not capability_bindings:
|
|
1112
|
+
return rejected("provider-binding-capability-mismatch")
|
|
1113
|
+
intent_bindings = [
|
|
1114
|
+
item for item in capability_bindings if value["intent"] in item["intents"]
|
|
1115
|
+
]
|
|
1116
|
+
if not intent_bindings:
|
|
1117
|
+
return rejected("provider-binding-intent-mismatch")
|
|
1118
|
+
ready_bindings = [
|
|
1119
|
+
item for item in intent_bindings if item["asset"]["readiness"] in {"ready", "degraded"}
|
|
1120
|
+
]
|
|
1121
|
+
if not ready_bindings:
|
|
1122
|
+
reason = (
|
|
1123
|
+
"provider-binding-readiness-unknown"
|
|
1124
|
+
if any(item["asset"]["readiness"] == "unknown" for item in intent_bindings)
|
|
1125
|
+
else "provider-binding-unavailable"
|
|
1126
|
+
)
|
|
1127
|
+
return rejected(reason)
|
|
1128
|
+
|
|
1129
|
+
fact = next(
|
|
1130
|
+
(
|
|
1131
|
+
item
|
|
1132
|
+
for item in value["runtimeFacts"]
|
|
1133
|
+
if item["providerId"] == manifest["id"]
|
|
1134
|
+
and item["providerVersion"] == manifest["version"]
|
|
1135
|
+
),
|
|
1136
|
+
None,
|
|
1137
|
+
)
|
|
1138
|
+
if fact is None:
|
|
1139
|
+
reason = (
|
|
1140
|
+
"provider-runtime-version-mismatch"
|
|
1141
|
+
if any(item["providerId"] == manifest["id"] for item in value["runtimeFacts"])
|
|
1142
|
+
else "provider-runtime-fact-missing"
|
|
1143
|
+
)
|
|
1144
|
+
return rejected(reason)
|
|
1145
|
+
if fact["readiness"] == "unknown":
|
|
1146
|
+
return rejected("provider-readiness-unknown", fact)
|
|
1147
|
+
if fact["readiness"] == "unavailable":
|
|
1148
|
+
return rejected("provider-readiness-unavailable", fact)
|
|
1149
|
+
|
|
1150
|
+
if manifest["probe"]["supported"]:
|
|
1151
|
+
if fact["probeResult"] == "not-run":
|
|
1152
|
+
return rejected("provider-probe-not-run", fact)
|
|
1153
|
+
if fact["probeResult"] == "failed":
|
|
1154
|
+
return rejected("provider-probe-failed", fact)
|
|
1155
|
+
if fact["freshness"] in {"unknown", "not-applicable"}:
|
|
1156
|
+
return rejected("provider-freshness-unknown", fact)
|
|
1157
|
+
if fact["freshness"] == "stale":
|
|
1158
|
+
return rejected("provider-freshness-stale", fact)
|
|
1159
|
+
if fact["probedAt"] is None or manifest["probe"]["maxAgeSeconds"] is None:
|
|
1160
|
+
return rejected("provider-probe-time-invalid", fact)
|
|
1161
|
+
probed_at_ms = _timestamp_ms(fact["probedAt"])
|
|
1162
|
+
if probed_at_ms > value["nowEpochMs"]:
|
|
1163
|
+
return rejected("provider-probe-from-future", fact)
|
|
1164
|
+
if value["nowEpochMs"] - probed_at_ms > manifest["probe"]["maxAgeSeconds"] * 1000:
|
|
1165
|
+
return rejected("provider-probe-expired", fact)
|
|
1166
|
+
elif (
|
|
1167
|
+
fact["probeResult"] != "not-run"
|
|
1168
|
+
or fact["probedAt"] is not None
|
|
1169
|
+
or fact["freshness"] not in {"unknown", "not-applicable"}
|
|
1170
|
+
):
|
|
1171
|
+
return rejected("provider-probe-unexpected", fact)
|
|
1172
|
+
|
|
1173
|
+
assurance = fact["assurance"]
|
|
1174
|
+
if assurance is None:
|
|
1175
|
+
return rejected("provider-assurance-insufficient", fact)
|
|
1176
|
+
if _ASSURANCE_LEVELS.index(assurance) > _ASSURANCE_LEVELS.index(manifest["maximumAssurance"]):
|
|
1177
|
+
return rejected("provider-assurance-exceeds-manifest", fact)
|
|
1178
|
+
if _ASSURANCE_LEVELS.index(assurance) < _ASSURANCE_LEVELS.index(value["minimumAssurance"]):
|
|
1179
|
+
return rejected("provider-assurance-insufficient", fact)
|
|
1180
|
+
if _ASSURANCE_LEVELS.index(assurance) >= 1 and not fact["evidenceRefs"]:
|
|
1181
|
+
return rejected("provider-evidence-missing", fact)
|
|
1182
|
+
if (
|
|
1183
|
+
fact["readiness"] == "degraded"
|
|
1184
|
+
or all(item["asset"]["readiness"] == "degraded" for item in ready_bindings)
|
|
1185
|
+
) and (_ASSURANCE_LEVELS.index(assurance) < 1 or not fact["evidenceRefs"]):
|
|
1186
|
+
return rejected("provider-degraded-without-evidence", fact)
|
|
1187
|
+
return {"manifest": manifest, "fact": fact, "role": role, "rejection": None}
|
|
1188
|
+
|
|
1189
|
+
|
|
1190
|
+
def _resolver_fingerprint(value: dict[str, Any]) -> str:
|
|
1191
|
+
payload = {
|
|
1192
|
+
"schemaVersion": value["schemaVersion"],
|
|
1193
|
+
"intent": value["intent"],
|
|
1194
|
+
"capabilityId": value["capabilityId"],
|
|
1195
|
+
"minimumAssurance": value["minimumAssurance"],
|
|
1196
|
+
"requestedPolicy": value["requestedPolicy"],
|
|
1197
|
+
"authorizedProviderIds": value["authorizedProviderIds"],
|
|
1198
|
+
"activeProviderIds": value["activeProviderIds"],
|
|
1199
|
+
"standbyProviderIds": value["standbyProviderIds"],
|
|
1200
|
+
"fallbackAllowed": value["fallbackAllowed"],
|
|
1201
|
+
"manifests": value["manifests"],
|
|
1202
|
+
"bindings": value["bindings"],
|
|
1203
|
+
"runtimeFacts": value["runtimeFacts"],
|
|
1204
|
+
}
|
|
1205
|
+
canonical = json.dumps(payload, ensure_ascii=False, sort_keys=True, separators=(",", ":"))
|
|
1206
|
+
return "sha256:" + hashlib.sha256(canonical.encode("utf-8")).hexdigest()
|
|
1207
|
+
|
|
1208
|
+
|
|
1209
|
+
def _unsupported_resolution(value: dict[str, Any]) -> dict[str, Any]:
|
|
1210
|
+
return {
|
|
1211
|
+
"schemaVersion": 1,
|
|
1212
|
+
"intent": value["intent"],
|
|
1213
|
+
"minimumAssurance": value["minimumAssurance"],
|
|
1214
|
+
"origin": "unsupported",
|
|
1215
|
+
"providerId": None,
|
|
1216
|
+
"providerVersion": None,
|
|
1217
|
+
"assurance": None,
|
|
1218
|
+
"readiness": "unavailable",
|
|
1219
|
+
"requestedPolicy": value["requestedPolicy"],
|
|
1220
|
+
"effectivePolicy": None,
|
|
1221
|
+
"evidenceRefs": [],
|
|
1222
|
+
"freshness": "not-applicable",
|
|
1223
|
+
"probedAt": None,
|
|
1224
|
+
"probeResult": "not-run",
|
|
1225
|
+
"fallbackFromProviderId": None,
|
|
1226
|
+
}
|
|
1227
|
+
|
|
1228
|
+
|
|
1229
|
+
def _resolve_plain_provider_v1(raw: Any) -> dict[str, Any]:
|
|
1230
|
+
value, invalid_reason = _normalize_resolver_input(raw)
|
|
1231
|
+
if value is None:
|
|
1232
|
+
return _invalid_resolution(invalid_reason or "provider-input-invalid")
|
|
1233
|
+
fingerprint = _resolver_fingerprint(value)
|
|
1234
|
+
evaluated = [_evaluate_candidate(manifest, value) for manifest in value["manifests"]]
|
|
1235
|
+
eligible = [item for item in evaluated if item["rejection"] is None]
|
|
1236
|
+
|
|
1237
|
+
selected: dict[str, Any] | None = None
|
|
1238
|
+
fallback_from: str | None = None
|
|
1239
|
+
if value["activeProviderIds"]:
|
|
1240
|
+
selected = next((item for item in eligible if item["role"] == "active"), None)
|
|
1241
|
+
if selected is None and value["fallbackAllowed"]:
|
|
1242
|
+
selected = next((item for item in eligible if item["role"] == "standby"), None)
|
|
1243
|
+
if selected is not None:
|
|
1244
|
+
fallback_from = value["activeProviderIds"][0]
|
|
1245
|
+
elif not value["standbyProviderIds"]:
|
|
1246
|
+
selected = eligible[0] if eligible else None
|
|
1247
|
+
|
|
1248
|
+
candidates: list[dict[str, Any]] = []
|
|
1249
|
+
for item in evaluated:
|
|
1250
|
+
if item["rejection"] is not None:
|
|
1251
|
+
candidates.append(
|
|
1252
|
+
{
|
|
1253
|
+
"providerId": item["manifest"]["id"],
|
|
1254
|
+
"providerVersion": item["manifest"]["version"],
|
|
1255
|
+
"role": item["role"],
|
|
1256
|
+
"accepted": False,
|
|
1257
|
+
"selected": False,
|
|
1258
|
+
"reasonCodes": [item["rejection"]],
|
|
1259
|
+
"effectivePolicy": None,
|
|
1260
|
+
"evidenceRefs": [],
|
|
1261
|
+
}
|
|
1262
|
+
)
|
|
1263
|
+
continue
|
|
1264
|
+
if item is selected:
|
|
1265
|
+
selected_reason = {
|
|
1266
|
+
"active": "provider-selected-active",
|
|
1267
|
+
"standby": "provider-selected-fallback",
|
|
1268
|
+
"default": "provider-selected-stable",
|
|
1269
|
+
}[item["role"]]
|
|
1270
|
+
candidates.append(
|
|
1271
|
+
{
|
|
1272
|
+
"providerId": item["manifest"]["id"],
|
|
1273
|
+
"providerVersion": item["manifest"]["version"],
|
|
1274
|
+
"role": item["role"],
|
|
1275
|
+
"accepted": True,
|
|
1276
|
+
"selected": True,
|
|
1277
|
+
"reasonCodes": [selected_reason],
|
|
1278
|
+
"effectivePolicy": value["requestedPolicy"],
|
|
1279
|
+
"evidenceRefs": item["fact"]["evidenceRefs"],
|
|
1280
|
+
}
|
|
1281
|
+
)
|
|
1282
|
+
continue
|
|
1283
|
+
if item["role"] == "standby" and not value["fallbackAllowed"]:
|
|
1284
|
+
reason = "provider-fallback-disabled"
|
|
1285
|
+
elif value["activeProviderIds"] and item["role"] == "default":
|
|
1286
|
+
reason = "provider-not-preferred"
|
|
1287
|
+
else:
|
|
1288
|
+
reason = "provider-not-selected"
|
|
1289
|
+
candidates.append(
|
|
1290
|
+
{
|
|
1291
|
+
"providerId": item["manifest"]["id"],
|
|
1292
|
+
"providerVersion": item["manifest"]["version"],
|
|
1293
|
+
"role": item["role"],
|
|
1294
|
+
"accepted": False,
|
|
1295
|
+
"selected": False,
|
|
1296
|
+
"reasonCodes": [reason],
|
|
1297
|
+
"effectivePolicy": None,
|
|
1298
|
+
"evidenceRefs": [],
|
|
1299
|
+
}
|
|
1300
|
+
)
|
|
1301
|
+
|
|
1302
|
+
if selected is None or selected["fact"] is None:
|
|
1303
|
+
if not value["activeProviderIds"] and value["standbyProviderIds"]:
|
|
1304
|
+
reason = "provider-active-missing"
|
|
1305
|
+
elif value["activeProviderIds"] and not value["fallbackAllowed"]:
|
|
1306
|
+
reason = "provider-fallback-disabled"
|
|
1307
|
+
elif candidates:
|
|
1308
|
+
reason = candidates[0]["reasonCodes"][0]
|
|
1309
|
+
else:
|
|
1310
|
+
reason = "provider-unsupported"
|
|
1311
|
+
return {
|
|
1312
|
+
"schemaVersion": 1,
|
|
1313
|
+
"status": "unsupported",
|
|
1314
|
+
"resolution": _unsupported_resolution(value),
|
|
1315
|
+
"fingerprint": fingerprint,
|
|
1316
|
+
"explain": {
|
|
1317
|
+
"schemaVersion": 1,
|
|
1318
|
+
"decision": "unsupported",
|
|
1319
|
+
"reasonCode": reason,
|
|
1320
|
+
"selectedProviderId": None,
|
|
1321
|
+
"fallbackFromProviderId": None,
|
|
1322
|
+
"effectivePolicy": None,
|
|
1323
|
+
"evidenceRefs": [],
|
|
1324
|
+
"candidates": candidates,
|
|
1325
|
+
},
|
|
1326
|
+
}
|
|
1327
|
+
|
|
1328
|
+
fact = selected["fact"]
|
|
1329
|
+
manifest = selected["manifest"]
|
|
1330
|
+
resolution = {
|
|
1331
|
+
"schemaVersion": 1,
|
|
1332
|
+
"intent": value["intent"],
|
|
1333
|
+
"minimumAssurance": value["minimumAssurance"],
|
|
1334
|
+
"origin": manifest["origin"],
|
|
1335
|
+
"providerId": manifest["id"],
|
|
1336
|
+
"providerVersion": manifest["version"],
|
|
1337
|
+
"assurance": fact["assurance"],
|
|
1338
|
+
"readiness": fact["readiness"],
|
|
1339
|
+
"requestedPolicy": value["requestedPolicy"],
|
|
1340
|
+
"effectivePolicy": value["requestedPolicy"],
|
|
1341
|
+
"evidenceRefs": fact["evidenceRefs"],
|
|
1342
|
+
"freshness": fact["freshness"],
|
|
1343
|
+
"probedAt": fact["probedAt"],
|
|
1344
|
+
"probeResult": fact["probeResult"],
|
|
1345
|
+
"fallbackFromProviderId": fallback_from,
|
|
1346
|
+
}
|
|
1347
|
+
return {
|
|
1348
|
+
"schemaVersion": 1,
|
|
1349
|
+
"status": "supported",
|
|
1350
|
+
"resolution": resolution,
|
|
1351
|
+
"fingerprint": fingerprint,
|
|
1352
|
+
"explain": {
|
|
1353
|
+
"schemaVersion": 1,
|
|
1354
|
+
"decision": "supported",
|
|
1355
|
+
"reasonCode": "provider-selected",
|
|
1356
|
+
"selectedProviderId": manifest["id"],
|
|
1357
|
+
"fallbackFromProviderId": fallback_from,
|
|
1358
|
+
"effectivePolicy": value["requestedPolicy"],
|
|
1359
|
+
"evidenceRefs": fact["evidenceRefs"],
|
|
1360
|
+
"candidates": candidates,
|
|
1361
|
+
},
|
|
1362
|
+
}
|
|
1363
|
+
|
|
1364
|
+
|
|
1365
|
+
def resolve_provider_v1(raw: Any) -> dict[str, Any]:
|
|
1366
|
+
"""Resolve plain JSON Provider facts with the redacted TypeScript ABI."""
|
|
1367
|
+
try:
|
|
1368
|
+
snapshot = _snapshot_plain_json_value(raw)
|
|
1369
|
+
if snapshot is _INVALID_JSON_VALUE or type(snapshot) is not dict:
|
|
1370
|
+
return _invalid_resolution("provider-input-invalid")
|
|
1371
|
+
return _resolve_plain_provider_v1(snapshot)
|
|
1372
|
+
except Exception:
|
|
1373
|
+
return _invalid_resolution("provider-input-invalid")
|