create-principles-disciple 1.121.8 → 1.121.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -1
- package/console/dist/server/config/pd-config-store.d.ts +1 -3
- package/console/dist/server/config/pd-config-store.js +4 -4
- package/console/dist/server/feedback/channels.d.ts +2 -8
- package/console/dist/server/feedback/channels.js +0 -11
- package/console/dist/server/index.js +34 -5
- package/console/dist/server/models/ActivationsConsoleModel.d.ts +28 -1
- package/console/dist/server/models/ActivationsConsoleModel.js +72 -30
- package/console/dist/server/models/GovernanceExperienceCollector.d.ts +28 -0
- package/console/dist/server/models/GovernanceExperienceCollector.js +305 -0
- package/console/dist/server/models/GovernanceProjectionCollector.d.ts +60 -2
- package/console/dist/server/models/GovernanceProjectionCollector.js +323 -285
- package/console/dist/server/models/PrincipleClassifier.d.ts +1 -1
- package/console/dist/server/models/PrincipleClassifier.js +7 -4
- package/console/dist/server/models/PrinciplesConsoleModel.d.ts +2 -1
- package/console/dist/server/models/ReceiptsConsoleModel.d.ts +5 -0
- package/console/dist/server/models/ReceiptsConsoleModel.js +140 -13
- package/console/dist/server/routes/activations.js +1 -1
- package/console/dist/server/routes/failed-tasks.js +28 -11
- package/console/dist/server/routes/governance.d.ts +26 -0
- package/console/dist/server/routes/governance.js +51 -0
- package/console/dist/server/routes/owner-identity.d.ts +31 -0
- package/console/dist/server/routes/owner-identity.js +76 -0
- package/console/dist/server/routes/update-history.d.ts +5 -0
- package/console/dist/server/routes/update-history.js +50 -4
- package/console/dist/server/routes/update.js +186 -32
- package/console/dist/shared/feedback-channel-ids.d.ts +13 -0
- package/console/dist/shared/feedback-channel-ids.js +12 -0
- package/console/dist/shared/feedback-contract.d.ts +46 -0
- package/console/dist/shared/feedback-contract.js +45 -0
- package/console/dist/ui/App.js +1 -1
- package/console/dist/ui/api.d.ts +22 -3
- package/console/dist/ui/api.js +63 -3
- package/console/dist/ui/components/receipts/ReceiptCoverageDisclosure.d.ts +6 -0
- package/console/dist/ui/components/receipts/ReceiptCoverageDisclosure.js +66 -0
- package/console/dist/ui/i18n/en.json +198 -2
- package/console/dist/ui/i18n/zh-CN.json +196 -0
- package/console/dist/ui/pages/activation/ActivationPage.js +14 -2
- package/console/dist/ui/pages/failed-tasks/FailedTasksPage.js +25 -5
- package/console/dist/ui/pages/focus/FocusPage.d.ts +28 -1
- package/console/dist/ui/pages/focus/FocusPage.js +128 -15
- package/console/dist/ui/pages/principles/PrincipleDetailPage.d.ts +30 -0
- package/console/dist/ui/pages/principles/PrincipleDetailPage.js +49 -6
- package/console/dist/ui/pages/settings/SettingsPage.js +67 -2
- package/console/dist/ui/pages/settings/UpdatePage.js +7 -7
- package/console/dist/ui/utils/enum-labels.js +0 -1
- package/console/dist/ui/utils/validators.d.ts +53 -21
- package/console/dist/ui/utils/validators.js +248 -21
- package/console/dist/web/assets/app.css +6 -0
- package/console/dist/web/assets/app.js +2721 -1664
- package/console/package.json +3 -1
- package/core/dist/host/host-adapter.d.ts +1 -1
- package/core/dist/host/host-adapter.d.ts.map +1 -1
- package/core/dist/host/host-adapter.js +1 -0
- package/core/dist/host/host-adapter.js.map +1 -1
- package/core/dist/runtime-v2/__tests__/architecture-regression.test.js +12 -2
- package/core/dist/runtime-v2/__tests__/architecture-regression.test.js.map +1 -1
- package/core/dist/runtime-v2/__tests__/attack-e2e-pipeline-smoke.test.js +1 -1
- package/core/dist/runtime-v2/__tests__/attack-e2e-pipeline-smoke.test.js.map +1 -1
- package/core/dist/runtime-v2/__tests__/governance-experience.test.d.ts +2 -0
- package/core/dist/runtime-v2/__tests__/governance-experience.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/__tests__/governance-experience.test.js +300 -0
- package/core/dist/runtime-v2/__tests__/governance-experience.test.js.map +1 -0
- package/core/dist/runtime-v2/__tests__/owner-identity.test.d.ts +2 -0
- package/core/dist/runtime-v2/__tests__/owner-identity.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/__tests__/owner-identity.test.js +147 -0
- package/core/dist/runtime-v2/__tests__/owner-identity.test.js.map +1 -0
- package/core/dist/runtime-v2/__tests__/product-telemetry-contract.test.d.ts +18 -0
- package/core/dist/runtime-v2/__tests__/product-telemetry-contract.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/__tests__/product-telemetry-contract.test.js +303 -0
- package/core/dist/runtime-v2/__tests__/product-telemetry-contract.test.js.map +1 -0
- package/core/dist/runtime-v2/__tests__/recovery-actions-log.test.js +40 -0
- package/core/dist/runtime-v2/__tests__/recovery-actions-log.test.js.map +1 -1
- package/core/dist/runtime-v2/__tests__/status-contract.test.d.ts +2 -0
- package/core/dist/runtime-v2/__tests__/status-contract.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/__tests__/status-contract.test.js +107 -0
- package/core/dist/runtime-v2/__tests__/status-contract.test.js.map +1 -0
- package/core/dist/runtime-v2/activation/__tests__/promotion-evidence-snapshot.test.d.ts +2 -0
- package/core/dist/runtime-v2/activation/__tests__/promotion-evidence-snapshot.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/activation/__tests__/promotion-evidence-snapshot.test.js +104 -0
- package/core/dist/runtime-v2/activation/__tests__/promotion-evidence-snapshot.test.js.map +1 -0
- package/core/dist/runtime-v2/activation/__tests__/promotion-readiness-evaluator.test.js +19 -0
- package/core/dist/runtime-v2/activation/__tests__/promotion-readiness-evaluator.test.js.map +1 -1
- package/core/dist/runtime-v2/activation/__tests__/rulecode-owner-decision-service.test.js +20 -0
- package/core/dist/runtime-v2/activation/__tests__/rulecode-owner-decision-service.test.js.map +1 -1
- package/core/dist/runtime-v2/activation/__tests__/sqlite-activation-safety-store.test.js +40 -0
- package/core/dist/runtime-v2/activation/__tests__/sqlite-activation-safety-store.test.js.map +1 -1
- package/core/dist/runtime-v2/activation/index.d.ts +2 -0
- package/core/dist/runtime-v2/activation/index.d.ts.map +1 -1
- package/core/dist/runtime-v2/activation/index.js +1 -0
- package/core/dist/runtime-v2/activation/index.js.map +1 -1
- package/core/dist/runtime-v2/activation/promotion-evidence-snapshot.d.ts +30 -0
- package/core/dist/runtime-v2/activation/promotion-evidence-snapshot.d.ts.map +1 -0
- package/core/dist/runtime-v2/activation/promotion-evidence-snapshot.js +87 -0
- package/core/dist/runtime-v2/activation/promotion-evidence-snapshot.js.map +1 -0
- package/core/dist/runtime-v2/activation/promotion-readiness-evaluator.d.ts.map +1 -1
- package/core/dist/runtime-v2/activation/promotion-readiness-evaluator.js +3 -0
- package/core/dist/runtime-v2/activation/promotion-readiness-evaluator.js.map +1 -1
- package/core/dist/runtime-v2/activation/promotion-readiness-reader.d.ts +1 -1
- package/core/dist/runtime-v2/activation/promotion-readiness-reader.d.ts.map +1 -1
- package/core/dist/runtime-v2/activation/promotion-readiness-reader.js +2 -2
- package/core/dist/runtime-v2/activation/promotion-readiness-reader.js.map +1 -1
- package/core/dist/runtime-v2/activation/rulecode-owner-decision-service.d.ts.map +1 -1
- package/core/dist/runtime-v2/activation/rulecode-owner-decision-service.js +18 -9
- package/core/dist/runtime-v2/activation/rulecode-owner-decision-service.js.map +1 -1
- package/core/dist/runtime-v2/adapter/__tests__/chaos-json-repair.test.js +1 -1
- package/core/dist/runtime-v2/adapter/__tests__/chaos-json-repair.test.js.map +1 -1
- package/core/dist/runtime-v2/adapter/__tests__/json-extractor.test.js +91 -1
- package/core/dist/runtime-v2/adapter/__tests__/json-extractor.test.js.map +1 -1
- package/core/dist/runtime-v2/adapter/__tests__/pi-ai-runtime-adapter.test.js +59 -12
- package/core/dist/runtime-v2/adapter/__tests__/pi-ai-runtime-adapter.test.js.map +1 -1
- package/core/dist/runtime-v2/adapter/__tests__/runtime-config-contract.test.js +10 -9
- package/core/dist/runtime-v2/adapter/__tests__/runtime-config-contract.test.js.map +1 -1
- package/core/dist/runtime-v2/adapter/__tests__/structured-output-repair.test.js +42 -1
- package/core/dist/runtime-v2/adapter/__tests__/structured-output-repair.test.js.map +1 -1
- package/core/dist/runtime-v2/adapter/json-extractor.d.ts +25 -0
- package/core/dist/runtime-v2/adapter/json-extractor.d.ts.map +1 -1
- package/core/dist/runtime-v2/adapter/json-extractor.js +126 -0
- package/core/dist/runtime-v2/adapter/json-extractor.js.map +1 -1
- package/core/dist/runtime-v2/adapter/l2-agent-loop-adapter.d.ts +9 -4
- package/core/dist/runtime-v2/adapter/l2-agent-loop-adapter.d.ts.map +1 -1
- package/core/dist/runtime-v2/adapter/l2-agent-loop-adapter.js +9 -4
- package/core/dist/runtime-v2/adapter/l2-agent-loop-adapter.js.map +1 -1
- package/core/dist/runtime-v2/adapter/output-repair-contract.d.ts +5 -1
- package/core/dist/runtime-v2/adapter/output-repair-contract.d.ts.map +1 -1
- package/core/dist/runtime-v2/adapter/output-repair-contract.js +4 -1
- package/core/dist/runtime-v2/adapter/output-repair-contract.js.map +1 -1
- package/core/dist/runtime-v2/adapter/pi-ai-catalog.d.ts +7 -0
- package/core/dist/runtime-v2/adapter/pi-ai-catalog.d.ts.map +1 -0
- package/core/dist/runtime-v2/adapter/pi-ai-catalog.js +19 -0
- package/core/dist/runtime-v2/adapter/pi-ai-catalog.js.map +1 -0
- package/core/dist/runtime-v2/adapter/pi-ai-runtime-adapter.d.ts +13 -15
- package/core/dist/runtime-v2/adapter/pi-ai-runtime-adapter.d.ts.map +1 -1
- package/core/dist/runtime-v2/adapter/pi-ai-runtime-adapter.js +104 -37
- package/core/dist/runtime-v2/adapter/pi-ai-runtime-adapter.js.map +1 -1
- package/core/dist/runtime-v2/adapter/structured-output-repair.d.ts +16 -1
- package/core/dist/runtime-v2/adapter/structured-output-repair.d.ts.map +1 -1
- package/core/dist/runtime-v2/adapter/structured-output-repair.js +38 -6
- package/core/dist/runtime-v2/adapter/structured-output-repair.js.map +1 -1
- package/core/dist/runtime-v2/adapter/tools/diagnostician-tool.d.ts +1 -1
- package/core/dist/runtime-v2/adapter/tools/diagnostician-tool.d.ts.map +1 -1
- package/core/dist/runtime-v2/config/__tests__/pd-config-agent-binding.test.js +8 -9
- package/core/dist/runtime-v2/config/__tests__/pd-config-agent-binding.test.js.map +1 -1
- package/core/dist/runtime-v2/config/__tests__/pd-config-contract.test.js +27 -3
- package/core/dist/runtime-v2/config/__tests__/pd-config-contract.test.js.map +1 -1
- package/core/dist/runtime-v2/config/__tests__/pd-config-principles.test.d.ts +11 -0
- package/core/dist/runtime-v2/config/__tests__/pd-config-principles.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/config/__tests__/pd-config-principles.test.js +93 -0
- package/core/dist/runtime-v2/config/__tests__/pd-config-principles.test.js.map +1 -0
- package/core/dist/runtime-v2/config/__tests__/pd-config-workspace.test.js +41 -0
- package/core/dist/runtime-v2/config/__tests__/pd-config-workspace.test.js.map +1 -1
- package/core/dist/runtime-v2/config/index.d.ts +2 -2
- package/core/dist/runtime-v2/config/index.d.ts.map +1 -1
- package/core/dist/runtime-v2/config/index.js +2 -0
- package/core/dist/runtime-v2/config/index.js.map +1 -1
- package/core/dist/runtime-v2/config/pd-config-agent-binding.d.ts.map +1 -1
- package/core/dist/runtime-v2/config/pd-config-agent-binding.js +4 -13
- package/core/dist/runtime-v2/config/pd-config-agent-binding.js.map +1 -1
- package/core/dist/runtime-v2/config/pd-config-effective.d.ts.map +1 -1
- package/core/dist/runtime-v2/config/pd-config-effective.js +14 -7
- package/core/dist/runtime-v2/config/pd-config-effective.js.map +1 -1
- package/core/dist/runtime-v2/config/pd-config-feature-flags.d.ts.map +1 -1
- package/core/dist/runtime-v2/config/pd-config-feature-flags.js +5 -12
- package/core/dist/runtime-v2/config/pd-config-feature-flags.js.map +1 -1
- package/core/dist/runtime-v2/config/pd-config-types.d.ts +8 -0
- package/core/dist/runtime-v2/config/pd-config-types.d.ts.map +1 -1
- package/core/dist/runtime-v2/config/pd-config-types.js +2 -0
- package/core/dist/runtime-v2/config/pd-config-types.js.map +1 -1
- package/core/dist/runtime-v2/config/pd-config-validate.d.ts.map +1 -1
- package/core/dist/runtime-v2/config/pd-config-validate.js +48 -3
- package/core/dist/runtime-v2/config/pd-config-validate.js.map +1 -1
- package/core/dist/runtime-v2/core-principles/__tests__/core-axiom-block.test.js +36 -8
- package/core/dist/runtime-v2/core-principles/__tests__/core-axiom-block.test.js.map +1 -1
- package/core/dist/runtime-v2/core-principles/__tests__/core-principle-registry.test.js +36 -12
- package/core/dist/runtime-v2/core-principles/__tests__/core-principle-registry.test.js.map +1 -1
- package/core/dist/runtime-v2/core-principles/core-axiom-block.d.ts +22 -8
- package/core/dist/runtime-v2/core-principles/core-axiom-block.d.ts.map +1 -1
- package/core/dist/runtime-v2/core-principles/core-axiom-block.js +28 -13
- package/core/dist/runtime-v2/core-principles/core-axiom-block.js.map +1 -1
- package/core/dist/runtime-v2/core-principles/core-principle-registry.d.ts +29 -4
- package/core/dist/runtime-v2/core-principles/core-principle-registry.d.ts.map +1 -1
- package/core/dist/runtime-v2/core-principles/core-principle-registry.js +68 -33
- package/core/dist/runtime-v2/core-principles/core-principle-registry.js.map +1 -1
- package/core/dist/runtime-v2/core-principles/index.d.ts +3 -3
- package/core/dist/runtime-v2/core-principles/index.d.ts.map +1 -1
- package/core/dist/runtime-v2/core-principles/index.js +1 -1
- package/core/dist/runtime-v2/core-principles/index.js.map +1 -1
- package/core/dist/runtime-v2/evolution/evolution-types.d.ts +2 -1
- package/core/dist/runtime-v2/evolution/evolution-types.d.ts.map +1 -1
- package/core/dist/runtime-v2/evolution/evolution-types.js.map +1 -1
- package/core/dist/runtime-v2/feature-flags/__tests__/anonymous-product-telemetry-flag.test.d.ts +2 -0
- package/core/dist/runtime-v2/feature-flags/__tests__/anonymous-product-telemetry-flag.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/feature-flags/__tests__/anonymous-product-telemetry-flag.test.js +48 -0
- package/core/dist/runtime-v2/feature-flags/__tests__/anonymous-product-telemetry-flag.test.js.map +1 -0
- package/core/dist/runtime-v2/feature-flags/__tests__/codex-conversation-ingestion-flag.test.d.ts +2 -0
- package/core/dist/runtime-v2/feature-flags/__tests__/codex-conversation-ingestion-flag.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/feature-flags/__tests__/codex-conversation-ingestion-flag.test.js +46 -0
- package/core/dist/runtime-v2/feature-flags/__tests__/codex-conversation-ingestion-flag.test.js.map +1 -0
- package/core/dist/runtime-v2/feature-flags/__tests__/feature-flag-contract.test.js +86 -31
- package/core/dist/runtime-v2/feature-flags/__tests__/feature-flag-contract.test.js.map +1 -1
- package/core/dist/runtime-v2/feature-flags/__tests__/feature-flag-lifecycle.test.d.ts +2 -0
- package/core/dist/runtime-v2/feature-flags/__tests__/feature-flag-lifecycle.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/feature-flags/__tests__/feature-flag-lifecycle.test.js +83 -0
- package/core/dist/runtime-v2/feature-flags/__tests__/feature-flag-lifecycle.test.js.map +1 -0
- package/core/dist/runtime-v2/feature-flags/feature-flag-contract.d.ts +19 -1
- package/core/dist/runtime-v2/feature-flags/feature-flag-contract.d.ts.map +1 -1
- package/core/dist/runtime-v2/feature-flags/feature-flag-contract.js +128 -10
- package/core/dist/runtime-v2/feature-flags/feature-flag-contract.js.map +1 -1
- package/core/dist/runtime-v2/feature-flags/feature-flag-lifecycle.d.ts +37 -0
- package/core/dist/runtime-v2/feature-flags/feature-flag-lifecycle.d.ts.map +1 -0
- package/core/dist/runtime-v2/feature-flags/feature-flag-lifecycle.js +304 -0
- package/core/dist/runtime-v2/feature-flags/feature-flag-lifecycle.js.map +1 -0
- package/core/dist/runtime-v2/feature-flags/index.d.ts +4 -2
- package/core/dist/runtime-v2/feature-flags/index.d.ts.map +1 -1
- package/core/dist/runtime-v2/feature-flags/index.js +3 -1
- package/core/dist/runtime-v2/feature-flags/index.js.map +1 -1
- package/core/dist/runtime-v2/governance-experience-contract.d.ts +468 -0
- package/core/dist/runtime-v2/governance-experience-contract.d.ts.map +1 -0
- package/core/dist/runtime-v2/governance-experience-contract.js +208 -0
- package/core/dist/runtime-v2/governance-experience-contract.js.map +1 -0
- package/core/dist/runtime-v2/governance-experience.d.ts +11 -0
- package/core/dist/runtime-v2/governance-experience.d.ts.map +1 -0
- package/core/dist/runtime-v2/governance-experience.js +276 -0
- package/core/dist/runtime-v2/governance-experience.js.map +1 -0
- package/core/dist/runtime-v2/index.d.ts +20 -8
- package/core/dist/runtime-v2/index.d.ts.map +1 -1
- package/core/dist/runtime-v2/index.js +20 -6
- package/core/dist/runtime-v2/index.js.map +1 -1
- package/core/dist/runtime-v2/internalization/__tests__/artificer-output-retry-flag.test.js +29 -10
- package/core/dist/runtime-v2/internalization/__tests__/artificer-output-retry-flag.test.js.map +1 -1
- package/core/dist/runtime-v2/owner-identity.d.ts +69 -0
- package/core/dist/runtime-v2/owner-identity.d.ts.map +1 -0
- package/core/dist/runtime-v2/owner-identity.js +179 -0
- package/core/dist/runtime-v2/owner-identity.js.map +1 -0
- package/core/dist/runtime-v2/pain-signal-runtime-factory.d.ts.map +1 -1
- package/core/dist/runtime-v2/pain-signal-runtime-factory.js +2 -3
- package/core/dist/runtime-v2/pain-signal-runtime-factory.js.map +1 -1
- package/core/dist/runtime-v2/product-telemetry/daily-identity.d.ts +70 -0
- package/core/dist/runtime-v2/product-telemetry/daily-identity.d.ts.map +1 -0
- package/core/dist/runtime-v2/product-telemetry/daily-identity.js +89 -0
- package/core/dist/runtime-v2/product-telemetry/daily-identity.js.map +1 -0
- package/core/dist/runtime-v2/product-telemetry/snapshot-contract.d.ts +110 -0
- package/core/dist/runtime-v2/product-telemetry/snapshot-contract.d.ts.map +1 -0
- package/core/dist/runtime-v2/product-telemetry/snapshot-contract.js +250 -0
- package/core/dist/runtime-v2/product-telemetry/snapshot-contract.js.map +1 -0
- package/core/dist/runtime-v2/pruning-read-model.d.ts +2 -1
- package/core/dist/runtime-v2/pruning-read-model.d.ts.map +1 -1
- package/core/dist/runtime-v2/pruning-read-model.js.map +1 -1
- package/core/dist/runtime-v2/receipt-coverage.d.ts +63 -0
- package/core/dist/runtime-v2/receipt-coverage.d.ts.map +1 -0
- package/core/dist/runtime-v2/receipt-coverage.js +19 -0
- package/core/dist/runtime-v2/receipt-coverage.js.map +1 -0
- package/core/dist/runtime-v2/recovery-actions-log.d.ts +7 -0
- package/core/dist/runtime-v2/recovery-actions-log.d.ts.map +1 -1
- package/core/dist/runtime-v2/recovery-actions-log.js +6 -0
- package/core/dist/runtime-v2/recovery-actions-log.js.map +1 -1
- package/core/dist/runtime-v2/runtime-protocol.js +1 -1
- package/core/dist/runtime-v2/runtime-protocol.js.map +1 -1
- package/core/dist/runtime-v2/store/task/__tests__/sqlite-task-store.failed-tasks.test.js +17 -1
- package/core/dist/runtime-v2/store/task/__tests__/sqlite-task-store.failed-tasks.test.js.map +1 -1
- package/core/dist/runtime-v2/store/task/sqlite-task-store.d.ts.map +1 -1
- package/core/dist/runtime-v2/store/task/sqlite-task-store.js +10 -0
- package/core/dist/runtime-v2/store/task/sqlite-task-store.js.map +1 -1
- package/core/dist/runtime-v2/store/task/task-types.d.ts +2 -0
- package/core/dist/runtime-v2/store/task/task-types.d.ts.map +1 -1
- package/core/dist/runtime-v2/task-status.d.ts +9 -5
- package/core/dist/runtime-v2/task-status.d.ts.map +1 -1
- package/core/dist/runtime-v2/task-status.js +15 -7
- package/core/dist/runtime-v2/task-status.js.map +1 -1
- package/core/dist/runtime-v2/types/event-types.d.ts +4 -0
- package/core/dist/runtime-v2/types/event-types.d.ts.map +1 -1
- package/core/dist/runtime-v2/types/event-types.js.map +1 -1
- package/core/dist/runtime-v2/types/index.d.ts +1 -1
- package/core/dist/runtime-v2/types/index.d.ts.map +1 -1
- package/core/dist/runtime-v2/types/index.js +1 -1
- package/core/dist/runtime-v2/types/index.js.map +1 -1
- package/core/dist/runtime-v2/types/principle-enums.d.ts +3 -2
- package/core/dist/runtime-v2/types/principle-enums.d.ts.map +1 -1
- package/core/dist/runtime-v2/types/principle-enums.js +11 -5
- package/core/dist/runtime-v2/types/principle-enums.js.map +1 -1
- package/core/dist/runtime-v2/types/principle-schema.d.ts +1 -1
- package/core/dist/runtime-v2/types/principle-tree-store.d.ts +1 -1
- package/core/dist/runtime-v2/utils/cli-process-runner.d.ts.map +1 -1
- package/core/dist/runtime-v2/utils/cli-process-runner.js +3 -2
- package/core/dist/runtime-v2/utils/cli-process-runner.js.map +1 -1
- package/core/package.json +2 -3
- package/dist/i18n.d.ts.map +1 -1
- package/dist/i18n.js +4 -2
- package/dist/i18n.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +47 -11
- package/dist/index.js.map +1 -1
- package/dist/installer.d.ts +31 -5
- package/dist/installer.d.ts.map +1 -1
- package/dist/installer.js +472 -161
- package/dist/installer.js.map +1 -1
- package/dist/installers/codex-host-installer.d.ts.map +1 -1
- package/dist/installers/codex-host-installer.js +4 -0
- package/dist/installers/codex-host-installer.js.map +1 -1
- package/dist/mvp-config.d.ts +10 -0
- package/dist/mvp-config.d.ts.map +1 -1
- package/dist/mvp-config.js +30 -3
- package/dist/mvp-config.js.map +1 -1
- package/dist/uninstaller.d.ts +9 -1
- package/dist/uninstaller.d.ts.map +1 -1
- package/dist/uninstaller.js +103 -23
- package/dist/uninstaller.js.map +1 -1
- package/dist/update/atomic-file.d.ts +35 -0
- package/dist/update/atomic-file.d.ts.map +1 -0
- package/dist/update/atomic-file.js +120 -0
- package/dist/update/atomic-file.js.map +1 -0
- package/dist/update/bootstrap-protocol.d.ts +55 -0
- package/dist/update/bootstrap-protocol.d.ts.map +1 -0
- package/dist/update/bootstrap-protocol.js +132 -0
- package/dist/update/bootstrap-protocol.js.map +1 -0
- package/dist/update/channel-metadata.d.ts +28 -0
- package/dist/update/channel-metadata.d.ts.map +1 -0
- package/dist/update/channel-metadata.js +90 -0
- package/dist/update/channel-metadata.js.map +1 -0
- package/dist/update/channel-promotion.d.ts +39 -0
- package/dist/update/channel-promotion.d.ts.map +1 -0
- package/dist/update/channel-promotion.js +55 -0
- package/dist/update/channel-promotion.js.map +1 -0
- package/dist/update/data-compatibility.d.ts +35 -0
- package/dist/update/data-compatibility.d.ts.map +1 -0
- package/dist/update/data-compatibility.js +45 -0
- package/dist/update/data-compatibility.js.map +1 -0
- package/dist/update/install-layout.d.ts +59 -0
- package/dist/update/install-layout.d.ts.map +1 -0
- package/dist/update/install-layout.js +127 -0
- package/dist/update/install-layout.js.map +1 -0
- package/dist/update/legacy-migration.d.ts +56 -0
- package/dist/update/legacy-migration.d.ts.map +1 -0
- package/dist/update/legacy-migration.js +254 -0
- package/dist/update/legacy-migration.js.map +1 -0
- package/dist/update/product-identity.d.ts +50 -0
- package/dist/update/product-identity.d.ts.map +1 -0
- package/dist/update/product-identity.js +63 -0
- package/dist/update/product-identity.js.map +1 -0
- package/dist/update/release-asset-manifest.d.ts +31 -0
- package/dist/update/release-asset-manifest.d.ts.map +1 -0
- package/dist/update/release-asset-manifest.js +161 -0
- package/dist/update/release-asset-manifest.js.map +1 -0
- package/dist/update/release-identity.d.ts +33 -0
- package/dist/update/release-identity.d.ts.map +1 -0
- package/dist/update/release-identity.js +108 -0
- package/dist/update/release-identity.js.map +1 -0
- package/dist/update/release-manager.d.ts +96 -0
- package/dist/update/release-manager.d.ts.map +1 -0
- package/dist/update/release-manager.js +253 -0
- package/dist/update/release-manager.js.map +1 -0
- package/dist/update/release-metadata.d.ts +57 -0
- package/dist/update/release-metadata.d.ts.map +1 -0
- package/dist/update/release-metadata.js +200 -0
- package/dist/update/release-metadata.js.map +1 -0
- package/dist/update/release-policy.d.ts +51 -0
- package/dist/update/release-policy.d.ts.map +1 -0
- package/dist/update/release-policy.js +103 -0
- package/dist/update/release-policy.js.map +1 -0
- package/dist/update/rollback-policy.d.ts +56 -0
- package/dist/update/rollback-policy.d.ts.map +1 -0
- package/dist/update/rollback-policy.js +61 -0
- package/dist/update/rollback-policy.js.map +1 -0
- package/dist/update/transaction-journal.d.ts +121 -0
- package/dist/update/transaction-journal.d.ts.map +1 -0
- package/dist/update/transaction-journal.js +333 -0
- package/dist/update/transaction-journal.js.map +1 -0
- package/dist/update/trust-metadata.d.ts +55 -0
- package/dist/update/trust-metadata.d.ts.map +1 -0
- package/dist/update/trust-metadata.js +170 -0
- package/dist/update/trust-metadata.js.map +1 -0
- package/dist/update/update-history.d.ts +46 -0
- package/dist/update/update-history.d.ts.map +1 -0
- package/dist/update/update-history.js +123 -0
- package/dist/update/update-history.js.map +1 -0
- package/dist/utils/env.d.ts +7 -0
- package/dist/utils/env.d.ts.map +1 -1
- package/dist/utils/env.js +134 -44
- package/dist/utils/env.js.map +1 -1
- package/host-runtime/dist/governance-observation-store.d.ts +172 -0
- package/host-runtime/dist/governance-observation-store.js +649 -0
- package/host-runtime/dist/index.d.ts +6 -0
- package/host-runtime/dist/index.js +8 -0
- package/host-runtime/dist/product-telemetry/consent-store.d.ts +107 -0
- package/host-runtime/dist/product-telemetry/consent-store.js +329 -0
- package/host-runtime/dist/product-telemetry/eligibility.d.ts +53 -0
- package/host-runtime/dist/product-telemetry/eligibility.js +69 -0
- package/host-runtime/dist/product-telemetry/exporter.d.ts +46 -0
- package/host-runtime/dist/product-telemetry/exporter.js +71 -0
- package/host-runtime/dist/product-telemetry/milestone-readers.d.ts +61 -0
- package/host-runtime/dist/product-telemetry/milestone-readers.js +234 -0
- package/host-runtime/dist/product-telemetry/service.d.ts +142 -0
- package/host-runtime/dist/product-telemetry/service.js +532 -0
- package/host-runtime/dist/product-telemetry/workspace-scope.d.ts +38 -0
- package/host-runtime/dist/product-telemetry/workspace-scope.js +64 -0
- package/host-runtime/package.json +6 -1
- package/install-layout/dist/index.d.ts +48 -0
- package/install-layout/dist/index.js +81 -0
- package/install-layout/dist/index.test.d.ts +1 -0
- package/install-layout/dist/index.test.js +34 -0
- package/install-layout/package.json +33 -0
- package/package.json +16 -6
- package/pd-cli/dist/commands/__tests__/telemetry-flag-wiring.test.d.ts +9 -0
- package/pd-cli/dist/commands/__tests__/telemetry-flag-wiring.test.d.ts.map +1 -0
- package/pd-cli/dist/commands/__tests__/telemetry-flag-wiring.test.js +76 -0
- package/pd-cli/dist/commands/__tests__/telemetry-flag-wiring.test.js.map +1 -0
- package/pd-cli/dist/commands/__tests__/version.test.d.ts +2 -0
- package/pd-cli/dist/commands/__tests__/version.test.d.ts.map +1 -0
- package/pd-cli/dist/commands/__tests__/version.test.js +134 -0
- package/pd-cli/dist/commands/__tests__/version.test.js.map +1 -0
- package/pd-cli/dist/commands/console.d.ts.map +1 -1
- package/pd-cli/dist/commands/console.js +29 -10
- package/pd-cli/dist/commands/console.js.map +1 -1
- package/pd-cli/dist/commands/pain-record.d.ts.map +1 -1
- package/pd-cli/dist/commands/pain-record.js +6 -15
- package/pd-cli/dist/commands/pain-record.js.map +1 -1
- package/pd-cli/dist/commands/runtime-activation.d.ts +29 -0
- package/pd-cli/dist/commands/runtime-activation.d.ts.map +1 -1
- package/pd-cli/dist/commands/runtime-activation.js +70 -31
- package/pd-cli/dist/commands/runtime-activation.js.map +1 -1
- package/pd-cli/dist/commands/runtime-internalization-enqueue-successors.d.ts.map +1 -1
- package/pd-cli/dist/commands/runtime-internalization-enqueue-successors.js +2 -2
- package/pd-cli/dist/commands/runtime-internalization-enqueue-successors.js.map +1 -1
- package/pd-cli/dist/commands/telemetry.d.ts +82 -0
- package/pd-cli/dist/commands/telemetry.d.ts.map +1 -0
- package/pd-cli/dist/commands/telemetry.js +268 -0
- package/pd-cli/dist/commands/telemetry.js.map +1 -0
- package/pd-cli/dist/commands/version.d.ts +11 -0
- package/pd-cli/dist/commands/version.d.ts.map +1 -0
- package/pd-cli/dist/commands/version.js +48 -0
- package/pd-cli/dist/commands/version.js.map +1 -0
- package/pd-cli/dist/index.js +35 -2
- package/pd-cli/dist/index.js.map +1 -1
- package/pd-cli/dist/services/version-report.d.ts +44 -0
- package/pd-cli/dist/services/version-report.d.ts.map +1 -0
- package/pd-cli/dist/services/version-report.js +152 -0
- package/pd-cli/dist/services/version-report.js.map +1 -0
- package/pd-cli/package.json +2 -1
- package/plugin/dist/bundle.js +868 -936
- package/plugin/dist/core/init.d.ts +2 -1
- package/plugin/dist/core/principle-application-ledger.d.ts +10 -0
- package/plugin/dist/core/product-telemetry-trigger.d.ts +14 -0
- package/plugin/dist/core/thinking-os-parser.d.ts +5 -2
- package/plugin/dist/governance-audit.js +386 -0
- package/plugin/dist/hooks/gate-block-helper.d.ts +25 -1
- package/plugin/dist/hooks/gate.d.ts +22 -0
- package/plugin/dist/openclaw.plugin.json +1 -1
- package/plugin/dist/rulehost-evidence.js +832 -0
- package/plugin/dist/templates/langs/en/principles/THINKING_OS.md +53 -45
- package/plugin/dist/templates/langs/en/skills/pd-mentor/SKILL.md +1 -1
- package/plugin/dist/templates/langs/zh/principles/THINKING_OS.md +62 -46
- package/plugin/dist/templates/langs/zh/skills/pd-mentor/SKILL.md +1 -1
- package/plugin/dist/templates/workspace/.principles/THINKING_OS.md +66 -38
- package/plugin/openclaw.plugin.json +1 -1
- package/plugin/package.json +1 -1
- package/plugin/templates/langs/en/principles/THINKING_OS.md +53 -45
- package/plugin/templates/langs/en/skills/pd-mentor/SKILL.md +1 -1
- package/plugin/templates/langs/zh/principles/THINKING_OS.md +62 -46
- package/plugin/templates/langs/zh/skills/pd-mentor/SKILL.md +1 -1
- package/plugin/templates/workspace/.principles/THINKING_OS.md +66 -38
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transaction journal and recovery (SPEC §8, §14.3).
|
|
3
|
+
*
|
|
4
|
+
* An update follows a persisted state machine:
|
|
5
|
+
*
|
|
6
|
+
* planned -> downloaded -> verified -> staged -> probed
|
|
7
|
+
* -> activated -> host_verified -> confirmed
|
|
8
|
+
* -> rolled_back | refused | failed
|
|
9
|
+
*
|
|
10
|
+
* EVERY transition is appended (and fsynced) to the transaction journal
|
|
11
|
+
* BEFORE the side effect it describes. On restart, recovery reconciles any
|
|
12
|
+
* unfinished transaction: the outcome is always old-confirmed, new-confirmed,
|
|
13
|
+
* or an explicit safe refusal — never a hybrid.
|
|
14
|
+
*/
|
|
15
|
+
import { appendFileSync, closeSync, existsSync, fsyncSync, mkdirSync, openSync, readFileSync } from 'node:fs';
|
|
16
|
+
import { dirname } from 'node:path';
|
|
17
|
+
import { writeRecordAtomically } from './atomic-file.js';
|
|
18
|
+
export const TRANSACTION_STATES = [
|
|
19
|
+
'planned',
|
|
20
|
+
'downloaded',
|
|
21
|
+
'verified',
|
|
22
|
+
'staged',
|
|
23
|
+
'probed',
|
|
24
|
+
'activated',
|
|
25
|
+
'host_verified',
|
|
26
|
+
'confirmed',
|
|
27
|
+
'rolled_back',
|
|
28
|
+
'refused',
|
|
29
|
+
'failed',
|
|
30
|
+
];
|
|
31
|
+
export class TransactionJournalError extends Error {
|
|
32
|
+
code;
|
|
33
|
+
constructor(code, message) {
|
|
34
|
+
super(message);
|
|
35
|
+
this.name = 'TransactionJournalError';
|
|
36
|
+
this.code = code;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const VALID_STATES = new Set(TRANSACTION_STATES);
|
|
40
|
+
const TERMINAL_STATES = new Set(['confirmed', 'rolled_back', 'refused', 'failed']);
|
|
41
|
+
const ACTIVATION_OR_LATER = new Set(['activated', 'host_verified', 'confirmed']);
|
|
42
|
+
function isPlainObject(value) {
|
|
43
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
44
|
+
}
|
|
45
|
+
function parseTransition(line, lineNumber) {
|
|
46
|
+
let parsed;
|
|
47
|
+
try {
|
|
48
|
+
parsed = JSON.parse(line);
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
throw new TransactionJournalError('journal_line_invalid', `Journal line ${lineNumber} is not valid JSON.`);
|
|
52
|
+
}
|
|
53
|
+
if (!isPlainObject(parsed)) {
|
|
54
|
+
throw new TransactionJournalError('journal_line_invalid', `Journal line ${lineNumber} is not an object.`);
|
|
55
|
+
}
|
|
56
|
+
const required = [
|
|
57
|
+
['at', 'string'], ['to', 'string'], ['transactionId', 'string'],
|
|
58
|
+
['releaseId', 'string'], ['productVersion', 'string'],
|
|
59
|
+
['releaseMetadataDigest', 'string'], ['generation', 'number'],
|
|
60
|
+
];
|
|
61
|
+
for (const [field, kind] of required) {
|
|
62
|
+
const value = Object.hasOwn(parsed, field) ? parsed[field] : undefined;
|
|
63
|
+
if (kind === 'string' && (typeof value !== 'string' || value.length === 0)) {
|
|
64
|
+
throw new TransactionJournalError('journal_field_invalid', `Journal line ${lineNumber}: field "${field}" must be a non-empty string.`);
|
|
65
|
+
}
|
|
66
|
+
if (kind === 'number' && (typeof value !== 'number' || !Number.isSafeInteger(value) || value < 1)) {
|
|
67
|
+
throw new TransactionJournalError('journal_field_invalid', `Journal line ${lineNumber}: field "${field}" must be a positive integer.`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const { to } = parsed;
|
|
71
|
+
if (typeof to !== 'string' || !VALID_STATES.has(to)) {
|
|
72
|
+
throw new TransactionJournalError('journal_state_invalid', `Journal line ${lineNumber}: unknown state ${JSON.stringify(to)}.`);
|
|
73
|
+
}
|
|
74
|
+
const fromValue = parsed.from;
|
|
75
|
+
if (fromValue !== null && (typeof fromValue !== 'string' || !VALID_STATES.has(fromValue))) {
|
|
76
|
+
throw new TransactionJournalError('journal_state_invalid', `Journal line ${lineNumber}: invalid from-state ${JSON.stringify(fromValue)}.`);
|
|
77
|
+
}
|
|
78
|
+
if (typeof parsed.releaseMetadataDigest !== 'string' || !/^[a-f0-9]{64}$/.test(parsed.releaseMetadataDigest)) {
|
|
79
|
+
throw new TransactionJournalError('journal_field_invalid', `Journal line ${lineNumber}: releaseMetadataDigest must be 64-char hex.`);
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
at: parsed.at,
|
|
83
|
+
from: fromValue,
|
|
84
|
+
to: to,
|
|
85
|
+
transactionId: parsed.transactionId,
|
|
86
|
+
releaseId: parsed.releaseId,
|
|
87
|
+
productVersion: parsed.productVersion,
|
|
88
|
+
releaseMetadataDigest: parsed.releaseMetadataDigest,
|
|
89
|
+
generation: parsed.generation,
|
|
90
|
+
detail: typeof parsed.detail === 'string' ? parsed.detail : undefined,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
function readJournalLines(journalPath, options) {
|
|
94
|
+
if (!existsSync(journalPath))
|
|
95
|
+
return { transitions: [], tornTailDetected: false };
|
|
96
|
+
const raw = readFileSync(journalPath, 'utf8');
|
|
97
|
+
const segments = raw.split('\n');
|
|
98
|
+
// A trailing '\n' makes split() yield a final empty segment; every other
|
|
99
|
+
// segment is a newline-terminated (complete) physical record.
|
|
100
|
+
const terminated = raw.endsWith('\n');
|
|
101
|
+
const completeLines = segments.slice(0, -1);
|
|
102
|
+
const trailingSegment = terminated ? '' : (segments[segments.length - 1] ?? '');
|
|
103
|
+
const transitions = [];
|
|
104
|
+
let lineNumber = 0;
|
|
105
|
+
for (const line of completeLines) {
|
|
106
|
+
lineNumber += 1;
|
|
107
|
+
if (line.trim().length === 0)
|
|
108
|
+
continue;
|
|
109
|
+
transitions.push(parseTransition(line, lineNumber));
|
|
110
|
+
}
|
|
111
|
+
let tornTailDetected = false;
|
|
112
|
+
if (trailingSegment.trim().length > 0) {
|
|
113
|
+
lineNumber += 1;
|
|
114
|
+
if (options.recoveryAware) {
|
|
115
|
+
try {
|
|
116
|
+
transitions.push(parseTransition(trailingSegment, lineNumber));
|
|
117
|
+
}
|
|
118
|
+
catch {
|
|
119
|
+
// Torn tail: unparseable, unterminated final record. Its transition
|
|
120
|
+
// never durably committed — drop it and flag for the recovery caller.
|
|
121
|
+
tornTailDetected = true;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
transitions.push(parseTransition(trailingSegment, lineNumber));
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
for (let index = 1; index < transitions.length; index += 1) {
|
|
129
|
+
const previous = transitions[index - 1];
|
|
130
|
+
const current = transitions[index];
|
|
131
|
+
if (!previous || !current)
|
|
132
|
+
continue;
|
|
133
|
+
if (previous.to !== current.from) {
|
|
134
|
+
throw new TransactionJournalError('journal_sequence_broken', `Journal transition ${index + 1} claims from=${JSON.stringify(current.from)} but the previous transition ended at ${JSON.stringify(previous.to)}.`);
|
|
135
|
+
}
|
|
136
|
+
if (TERMINAL_STATES.has(previous.to)) {
|
|
137
|
+
throw new TransactionJournalError('journal_terminal_continued', `Journal continues after the terminal state ${previous.to} at transition ${index + 1}.`);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return { transitions, tornTailDetected };
|
|
141
|
+
}
|
|
142
|
+
/** Reads and strictly validates the whole journal (fail loud on any tear). */
|
|
143
|
+
export function readTransactionJournal(journalPath) {
|
|
144
|
+
return readJournalLines(journalPath, { recoveryAware: false }).transitions;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Recovery-aware journal reader (crash contract, SPEC §8).
|
|
148
|
+
*
|
|
149
|
+
* The writer appends `JSON + '\n'` and fsyncs. A crash mid-append can leave a
|
|
150
|
+
* TORN final record: unparseable JSON without a trailing newline. Such a
|
|
151
|
+
* record never durably committed, so recovery drops it. Everything else is
|
|
152
|
+
* strict: a malformed line anywhere else (including a complete-but-invalid
|
|
153
|
+
* final line that DOES end with a newline) fails loud, because a complete
|
|
154
|
+
* write with bad content is corruption, not a torn write.
|
|
155
|
+
*/
|
|
156
|
+
export function readTransactionJournalForRecovery(journalPath) {
|
|
157
|
+
return readJournalLines(journalPath, { recoveryAware: true });
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Appends one transition durably (append + fsync) BEFORE the caller performs
|
|
161
|
+
* the side effect the transition describes. Journal-first ordering is what
|
|
162
|
+
* makes crash recovery sound.
|
|
163
|
+
*/
|
|
164
|
+
export function appendJournalTransition(journalPath, transition) {
|
|
165
|
+
const line = `${JSON.stringify(transition)}\n`;
|
|
166
|
+
const directory = dirname(journalPath);
|
|
167
|
+
mkdirSync(directory, { recursive: true });
|
|
168
|
+
let descriptor;
|
|
169
|
+
try {
|
|
170
|
+
descriptor = openSync(journalPath, 'a');
|
|
171
|
+
appendFileSync(descriptor, line);
|
|
172
|
+
fsyncSync(descriptor);
|
|
173
|
+
}
|
|
174
|
+
finally {
|
|
175
|
+
if (descriptor !== undefined)
|
|
176
|
+
closeSync(descriptor);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
/** Serializes + atomically replaces active.json (see atomic-file adapter). */
|
|
180
|
+
export function writeActiveRecord(recordPath, write) {
|
|
181
|
+
const record = { schemaVersion: 1, ...write };
|
|
182
|
+
writeRecordAtomically(recordPath, `${JSON.stringify(record, null, 2)}\n`);
|
|
183
|
+
}
|
|
184
|
+
/** Strict active.json reader; returns null when absent. */
|
|
185
|
+
export function readActiveRecord(recordPath) {
|
|
186
|
+
if (!existsSync(recordPath))
|
|
187
|
+
return null;
|
|
188
|
+
let text;
|
|
189
|
+
try {
|
|
190
|
+
text = readFileSync(recordPath, 'utf8');
|
|
191
|
+
}
|
|
192
|
+
catch (error) {
|
|
193
|
+
throw new TransactionJournalError('active_record_corrupt', `active.json could not be read (${recordPath}): ${error instanceof Error ? error.message : String(error)}`);
|
|
194
|
+
}
|
|
195
|
+
let value;
|
|
196
|
+
try {
|
|
197
|
+
value = JSON.parse(text);
|
|
198
|
+
}
|
|
199
|
+
catch (error) {
|
|
200
|
+
// A bare SyntaxError here would escape every ReleaseManager reason
|
|
201
|
+
// contract; corrupt active state maps to its own stable code (rc-3/rc-9).
|
|
202
|
+
throw new TransactionJournalError('active_record_corrupt', `active.json is not valid JSON (${recordPath}): ${error instanceof Error ? error.message : String(error)}. Recovery must consult the transaction journal, never guess from a partial file.`);
|
|
203
|
+
}
|
|
204
|
+
if (!isPlainObject(value)) {
|
|
205
|
+
throw new TransactionJournalError('active_record_corrupt', `active.json is not an object: ${recordPath}`);
|
|
206
|
+
}
|
|
207
|
+
if (value.schemaVersion !== 1) {
|
|
208
|
+
throw new TransactionJournalError('active_record_corrupt', `active.json has unsupported schemaVersion: ${JSON.stringify(value.schemaVersion)}`);
|
|
209
|
+
}
|
|
210
|
+
const { generation } = value;
|
|
211
|
+
const { releaseId } = value;
|
|
212
|
+
const digest = value.releaseMetadataDigest;
|
|
213
|
+
const { previousReleaseId } = value;
|
|
214
|
+
const { transactionId } = value;
|
|
215
|
+
const { productVersion } = value;
|
|
216
|
+
if (typeof generation !== 'number' || !Number.isSafeInteger(generation) || generation < 1
|
|
217
|
+
|| typeof releaseId !== 'string' || releaseId.length === 0
|
|
218
|
+
|| typeof digest !== 'string' || !/^[a-f0-9]{64}$/.test(digest)
|
|
219
|
+
|| (previousReleaseId !== null && (typeof previousReleaseId !== 'string' || previousReleaseId.length === 0))
|
|
220
|
+
|| typeof transactionId !== 'string' || transactionId.length === 0
|
|
221
|
+
|| typeof productVersion !== 'string' || productVersion.length === 0) {
|
|
222
|
+
throw new TransactionJournalError('active_record_corrupt', `active.json has malformed fields: ${recordPath}`);
|
|
223
|
+
}
|
|
224
|
+
return {
|
|
225
|
+
schemaVersion: 1,
|
|
226
|
+
generation,
|
|
227
|
+
releaseId,
|
|
228
|
+
releaseMetadataDigest: digest,
|
|
229
|
+
previousReleaseId,
|
|
230
|
+
transactionId,
|
|
231
|
+
productVersion,
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Reconciles ONE transaction against the active record after a crash. The
|
|
236
|
+
* invariant: the result is old-confirmed, new-confirmed, or an explicit
|
|
237
|
+
* refusal — never a hybrid release (SPEC §18-4).
|
|
238
|
+
*
|
|
239
|
+
* Rules:
|
|
240
|
+
* - No journal activity for this transaction → nothing to reconcile.
|
|
241
|
+
* - Journal reached `confirmed` → new release stands.
|
|
242
|
+
* - Journal never reached `activated` → old release stands (nothing was
|
|
243
|
+
* swapped); staging residue is cleaned up by the caller.
|
|
244
|
+
* - Journal reached `activated` (or later, unconfirmed) but active.json does
|
|
245
|
+
* not carry this transaction's generation → the crash interrupted the
|
|
246
|
+
* active-record write. The journal-confirmed PREVIOUS generation wins:
|
|
247
|
+
* recovery re-points to it; a hybrid (new code, old pointer) is never
|
|
248
|
+
* activated. If there is no previous pointer to fall back to, refuse
|
|
249
|
+
* explicitly and demand the official installer.
|
|
250
|
+
*/
|
|
251
|
+
export function recoverUnfinishedTransaction(input) {
|
|
252
|
+
const { transitions, activeRecord, previousRecord, transactionId } = input;
|
|
253
|
+
const mine = transitions.filter((transition) => transition.transactionId === transactionId);
|
|
254
|
+
if (mine.length === 0) {
|
|
255
|
+
return { kind: 'old_confirmed', releaseId: null, generation: null, reason: 'no journal activity for this transaction' };
|
|
256
|
+
}
|
|
257
|
+
const last = mine[mine.length - 1];
|
|
258
|
+
if (last.to === 'confirmed') {
|
|
259
|
+
return {
|
|
260
|
+
kind: 'new_confirmed',
|
|
261
|
+
releaseId: last.releaseId,
|
|
262
|
+
generation: last.generation,
|
|
263
|
+
reason: 'journal already confirmed the new release',
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
if (last.to === 'rolled_back' || last.to === 'refused' || last.to === 'failed') {
|
|
267
|
+
return {
|
|
268
|
+
kind: 'old_confirmed',
|
|
269
|
+
releaseId: previousRecord?.releaseId ?? activeRecord?.releaseId ?? null,
|
|
270
|
+
generation: previousRecord?.generation ?? activeRecord?.generation ?? null,
|
|
271
|
+
reason: `transaction ended in ${last.to}; the previously confirmed release remains active`,
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
const reachedActivation = mine.some((transition) => ACTIVATION_OR_LATER.has(transition.to));
|
|
275
|
+
if (!reachedActivation) {
|
|
276
|
+
return {
|
|
277
|
+
kind: 'old_confirmed',
|
|
278
|
+
releaseId: previousRecord?.releaseId ?? activeRecord?.releaseId ?? null,
|
|
279
|
+
generation: previousRecord?.generation ?? activeRecord?.generation ?? null,
|
|
280
|
+
reason: 'activation was never journaled; no swap happened and staging can be discarded',
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
// Activation started. The active record decides which side of the swap
|
|
284
|
+
// actually landed, and its generation must match a journal transition.
|
|
285
|
+
const activeMatchesNew = activeRecord !== null
|
|
286
|
+
&& activeRecord.transactionId === transactionId
|
|
287
|
+
&& activeRecord.generation === last.generation
|
|
288
|
+
&& activeRecord.releaseId === last.releaseId;
|
|
289
|
+
if (activeMatchesNew && last.to !== 'activated') {
|
|
290
|
+
// host_verified was journaled but confirmation didn't land — the active
|
|
291
|
+
// pointer plus the journal's activation lineage still close on the new
|
|
292
|
+
// generation; confirm it.
|
|
293
|
+
return {
|
|
294
|
+
kind: 'new_confirmed',
|
|
295
|
+
releaseId: activeRecord.releaseId,
|
|
296
|
+
generation: activeRecord.generation,
|
|
297
|
+
reason: 'active record matches the journaled activation lineage; completing confirmation',
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
if (activeMatchesNew && last.to === 'activated') {
|
|
301
|
+
// Pointer landed but host verification never ran: NOT confirmed. The
|
|
302
|
+
// previous confirmed generation is the safe answer when it exists.
|
|
303
|
+
if (previousRecord !== null) {
|
|
304
|
+
return {
|
|
305
|
+
kind: 'old_confirmed',
|
|
306
|
+
releaseId: previousRecord.releaseId,
|
|
307
|
+
generation: previousRecord.generation,
|
|
308
|
+
reason: 'activation pointer landed but the release was never host-verified; falling back to the previous confirmed generation',
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
return {
|
|
312
|
+
kind: 'explicit_refusal',
|
|
313
|
+
reason: 'activation_interrupted_without_previous',
|
|
314
|
+
nextAction: 'The first-ever activation was interrupted before host verification and there is no previously confirmed release to fall back to. Re-run the official installer to install a complete release.',
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
// Active record does not carry this transaction — the swap never landed.
|
|
318
|
+
const fallback = previousRecord ?? activeRecord;
|
|
319
|
+
if (fallback !== null) {
|
|
320
|
+
return {
|
|
321
|
+
kind: 'old_confirmed',
|
|
322
|
+
releaseId: fallback.releaseId,
|
|
323
|
+
generation: fallback.generation,
|
|
324
|
+
reason: 'the active record never took this transaction\'s generation; the previously confirmed release stands',
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
return {
|
|
328
|
+
kind: 'explicit_refusal',
|
|
329
|
+
reason: 'activation_interrupted_without_previous',
|
|
330
|
+
nextAction: 'Activation was interrupted before any confirmed generation existed. Re-run the official installer to install a complete release.',
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
//# sourceMappingURL=transaction-journal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction-journal.js","sourceRoot":"","sources":["../../src/update/transaction-journal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC9G,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,SAAS;IACT,YAAY;IACZ,UAAU;IACV,QAAQ;IACR,QAAQ;IACR,WAAW;IACX,eAAe;IACf,WAAW;IACX,aAAa;IACb,SAAS;IACT,QAAQ;CACA,CAAC;AA4BX,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IACvC,IAAI,CAAS;IAEtB,YAAY,IAAY,EAAE,OAAe;QACvC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;QACtC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAED,MAAM,YAAY,GAAG,IAAI,GAAG,CAAS,kBAAkB,CAAC,CAAC;AACzD,MAAM,eAAe,GAAG,IAAI,GAAG,CAAS,CAAC,WAAW,EAAE,aAAa,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC;AAC3F,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAmB,CAAC,WAAW,EAAE,eAAe,EAAE,WAAW,CAAC,CAAC,CAAC;AAEnG,SAAS,aAAa,CAAC,KAAc;I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,CAAC;QACtB,OAAO;YACL,IAAI,EAAE,eAAe;YACrB,SAAS,EAAE,QAAQ,CAAC,SAAS;YAC7B,UAAU,EAAE,QAAQ,CAAC,UAAU;YAC/B,MAAM,EAAE,sGAAsG;SAC/G,CAAC;IACJ,CAAC;IACD,OAAO;QACL,IAAI,EAAE,kBAAkB;QACxB,MAAM,EAAE,yCAAyC;QACjD,UAAU,EAAE,kIAAkI;KAC/I,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { type Fetcher } from 'tuf-js';
|
|
2
|
+
export type ReleaseTrustErrorCode = 'invalid_request' | 'metadata_refresh_failed' | 'target_not_found' | 'target_identity_mismatch' | 'target_integrity_missing';
|
|
3
|
+
interface ReleaseTrustErrorOptions {
|
|
4
|
+
code: ReleaseTrustErrorCode;
|
|
5
|
+
message: string;
|
|
6
|
+
nextAction: string;
|
|
7
|
+
cause?: unknown;
|
|
8
|
+
}
|
|
9
|
+
export declare class ReleaseTrustError extends Error {
|
|
10
|
+
readonly code: ReleaseTrustErrorCode;
|
|
11
|
+
readonly nextAction: string;
|
|
12
|
+
constructor(options: ReleaseTrustErrorOptions);
|
|
13
|
+
}
|
|
14
|
+
export interface ResolveTrustedReleaseTargetOptions {
|
|
15
|
+
metadataDir: string;
|
|
16
|
+
metadataBaseUrl: string;
|
|
17
|
+
targetPath: string;
|
|
18
|
+
expectedChannel: string;
|
|
19
|
+
expectedPlatform: string;
|
|
20
|
+
fetcher?: Fetcher;
|
|
21
|
+
}
|
|
22
|
+
export interface TrustedReleaseTarget {
|
|
23
|
+
artifactSha256: string;
|
|
24
|
+
artifactSize: number;
|
|
25
|
+
channel: string;
|
|
26
|
+
platform: string;
|
|
27
|
+
releaseId: string;
|
|
28
|
+
targetPath: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Resolves a release target only after the official TUF client verifies the
|
|
32
|
+
* trusted-root → timestamp → snapshot → targets metadata chain.
|
|
33
|
+
*
|
|
34
|
+
* This module deliberately does not download or install the target. Phase 1
|
|
35
|
+
* uses it as an independently testable trust boundary before update execution
|
|
36
|
+
* is wired to the new release system.
|
|
37
|
+
*/
|
|
38
|
+
export declare function resolveTrustedReleaseTarget(options: ResolveTrustedReleaseTargetOptions): Promise<TrustedReleaseTarget>;
|
|
39
|
+
export interface DownloadTrustedReleasePayloadOptions {
|
|
40
|
+
metadataDir: string;
|
|
41
|
+
metadataBaseUrl: string;
|
|
42
|
+
targetPath: string;
|
|
43
|
+
destinationPath: string;
|
|
44
|
+
fetcher?: Fetcher;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Downloads a trusted target to an exact destination path. The TUF client
|
|
48
|
+
* verifies length + digest DURING the download; a mismatch aborts and the
|
|
49
|
+
* partial file never reaches the destination. The destination is replaced
|
|
50
|
+
* atomically only after verification (temp file + rename in the same
|
|
51
|
+
* directory).
|
|
52
|
+
*/
|
|
53
|
+
export declare function downloadTrustedReleasePayload(options: DownloadTrustedReleasePayloadOptions): Promise<void>;
|
|
54
|
+
export {};
|
|
55
|
+
//# sourceMappingURL=trust-metadata.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trust-metadata.d.ts","sourceRoot":"","sources":["../../src/update/trust-metadata.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAW,MAAM,QAAQ,CAAC;AAE/C,MAAM,MAAM,qBAAqB,GAC7B,iBAAiB,GACjB,yBAAyB,GACzB,kBAAkB,GAClB,0BAA0B,GAC1B,0BAA0B,CAAC;AAE/B,UAAU,wBAAwB;IAChC,IAAI,EAAE,qBAAqB,CAAC;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,qBAAa,iBAAkB,SAAQ,KAAK;IAC1C,QAAQ,CAAC,IAAI,EAAE,qBAAqB,CAAC;IACrC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAE5B,YAAY,OAAO,EAAE,wBAAwB,EAK5C;CACF;AAED,MAAM,WAAW,kCAAkC;IACjD,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;IACzB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,oBAAoB;IACnC,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACpB;AA4CD;;;;;;;GAOG;AACH,wBAAsB,2BAA2B,CAC/C,OAAO,EAAE,kCAAkC,GAC1C,OAAO,CAAC,oBAAoB,CAAC,CAoD/B;AAOD,MAAM,WAAW,oCAAoC;IACnD,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;GAMG;AACH,wBAAsB,6BAA6B,CACjD,OAAO,EAAE,oCAAoC,GAC5C,OAAO,CAAC,IAAI,CAAC,CAoDf"}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { Updater } from 'tuf-js';
|
|
2
|
+
export class ReleaseTrustError extends Error {
|
|
3
|
+
code;
|
|
4
|
+
nextAction;
|
|
5
|
+
constructor(options) {
|
|
6
|
+
super(options.message, { cause: options.cause });
|
|
7
|
+
this.name = 'ReleaseTrustError';
|
|
8
|
+
this.code = options.code;
|
|
9
|
+
this.nextAction = options.nextAction;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function isNonEmptyString(value) {
|
|
13
|
+
return typeof value === 'string' && value.trim().length > 0;
|
|
14
|
+
}
|
|
15
|
+
function hasRequiredOptions(options) {
|
|
16
|
+
return isNonEmptyString(options.metadataDir)
|
|
17
|
+
&& isNonEmptyString(options.metadataBaseUrl)
|
|
18
|
+
&& isNonEmptyString(options.targetPath)
|
|
19
|
+
&& isNonEmptyString(options.expectedChannel)
|
|
20
|
+
&& isNonEmptyString(options.expectedPlatform);
|
|
21
|
+
}
|
|
22
|
+
function readSignedIdentity(custom) {
|
|
23
|
+
const releaseId = Object.hasOwn(custom, 'releaseId') ? custom.releaseId : undefined;
|
|
24
|
+
const channel = Object.hasOwn(custom, 'channel') ? custom.channel : undefined;
|
|
25
|
+
const platform = Object.hasOwn(custom, 'platform') ? custom.platform : undefined;
|
|
26
|
+
if (!isNonEmptyString(releaseId) || !isNonEmptyString(channel) || !isNonEmptyString(platform)) {
|
|
27
|
+
throw new ReleaseTrustError({
|
|
28
|
+
code: 'target_identity_mismatch',
|
|
29
|
+
message: 'The signed target is missing a release ID, channel, or platform identity.',
|
|
30
|
+
nextAction: 'Do not install this release. Publish complete signed target metadata and retry.',
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
return { releaseId, channel, platform };
|
|
34
|
+
}
|
|
35
|
+
function readArtifactSha256(hashes) {
|
|
36
|
+
const sha256 = Object.hasOwn(hashes, 'sha256') ? hashes.sha256 : undefined;
|
|
37
|
+
if (typeof sha256 !== 'string' || !/^[a-f0-9]{64}$/i.test(sha256)) {
|
|
38
|
+
throw new ReleaseTrustError({
|
|
39
|
+
code: 'target_integrity_missing',
|
|
40
|
+
message: 'The signed target does not contain a valid SHA-256 artifact hash.',
|
|
41
|
+
nextAction: 'Do not install this release. Publish signed target metadata with a SHA-256 hash and retry.',
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
return sha256.toLowerCase();
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Resolves a release target only after the official TUF client verifies the
|
|
48
|
+
* trusted-root → timestamp → snapshot → targets metadata chain.
|
|
49
|
+
*
|
|
50
|
+
* This module deliberately does not download or install the target. Phase 1
|
|
51
|
+
* uses it as an independently testable trust boundary before update execution
|
|
52
|
+
* is wired to the new release system.
|
|
53
|
+
*/
|
|
54
|
+
export async function resolveTrustedReleaseTarget(options) {
|
|
55
|
+
if (!hasRequiredOptions(options)) {
|
|
56
|
+
throw new ReleaseTrustError({
|
|
57
|
+
code: 'invalid_request',
|
|
58
|
+
message: 'Trusted release verification requires metadata storage, a repository URL, target path, channel, and platform.',
|
|
59
|
+
nextAction: 'Correct the release verification request before retrying.',
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
let target;
|
|
63
|
+
try {
|
|
64
|
+
const updater = new Updater({
|
|
65
|
+
metadataDir: options.metadataDir,
|
|
66
|
+
metadataBaseUrl: options.metadataBaseUrl,
|
|
67
|
+
fetcher: options.fetcher,
|
|
68
|
+
});
|
|
69
|
+
await updater.refresh();
|
|
70
|
+
target = await updater.getTargetInfo(options.targetPath);
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
throw new ReleaseTrustError({
|
|
74
|
+
code: 'metadata_refresh_failed',
|
|
75
|
+
message: 'Release metadata could not be verified against the trusted root.',
|
|
76
|
+
nextAction: 'Do not install this release. Check the signed release repository and retry after the metadata issue is resolved.',
|
|
77
|
+
cause: error,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
if (!target) {
|
|
81
|
+
throw new ReleaseTrustError({
|
|
82
|
+
code: 'target_not_found',
|
|
83
|
+
message: `No signed target exists for ${options.targetPath}.`,
|
|
84
|
+
nextAction: 'Do not install this release. Publish the target in signed metadata or select a supported channel and platform.',
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
const identity = readSignedIdentity(target.custom);
|
|
88
|
+
if (identity.channel !== options.expectedChannel || identity.platform !== options.expectedPlatform) {
|
|
89
|
+
throw new ReleaseTrustError({
|
|
90
|
+
code: 'target_identity_mismatch',
|
|
91
|
+
message: `The signed target identity (${identity.channel}/${identity.platform}) does not match the requested channel and platform (${options.expectedChannel}/${options.expectedPlatform}).`,
|
|
92
|
+
nextAction: 'Do not install this release. Select the matching signed channel and platform target.',
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
return {
|
|
96
|
+
artifactSha256: readArtifactSha256(target.hashes),
|
|
97
|
+
artifactSize: target.length,
|
|
98
|
+
channel: identity.channel,
|
|
99
|
+
platform: identity.platform,
|
|
100
|
+
releaseId: identity.releaseId,
|
|
101
|
+
targetPath: target.path,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
function destinationDirOf(destinationPath) {
|
|
105
|
+
const lastSeparator = Math.max(destinationPath.lastIndexOf('/'), destinationPath.lastIndexOf('\\'));
|
|
106
|
+
return lastSeparator === -1 ? '.' : destinationPath.slice(0, lastSeparator);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Downloads a trusted target to an exact destination path. The TUF client
|
|
110
|
+
* verifies length + digest DURING the download; a mismatch aborts and the
|
|
111
|
+
* partial file never reaches the destination. The destination is replaced
|
|
112
|
+
* atomically only after verification (temp file + rename in the same
|
|
113
|
+
* directory).
|
|
114
|
+
*/
|
|
115
|
+
export async function downloadTrustedReleasePayload(options) {
|
|
116
|
+
for (const field of ['metadataDir', 'metadataBaseUrl', 'targetPath', 'destinationPath']) {
|
|
117
|
+
if (typeof options[field] !== 'string' || options[field].trim().length === 0) {
|
|
118
|
+
throw new ReleaseTrustError({
|
|
119
|
+
code: 'invalid_request',
|
|
120
|
+
message: `Trusted payload download requires ${field}.`,
|
|
121
|
+
nextAction: 'Correct the download request before retrying.',
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
let downloaded;
|
|
126
|
+
try {
|
|
127
|
+
const updater = new Updater({
|
|
128
|
+
metadataDir: options.metadataDir,
|
|
129
|
+
metadataBaseUrl: options.metadataBaseUrl,
|
|
130
|
+
targetBaseUrl: `${options.metadataBaseUrl.replace(/\/+$/, '')}/targets`,
|
|
131
|
+
fetcher: options.fetcher,
|
|
132
|
+
});
|
|
133
|
+
await updater.refresh();
|
|
134
|
+
const target = await updater.getTargetInfo(options.targetPath);
|
|
135
|
+
if (!target) {
|
|
136
|
+
throw new Error(`target not found: ${options.targetPath}`);
|
|
137
|
+
}
|
|
138
|
+
const destinationDirectory = destinationDirOf(options.destinationPath);
|
|
139
|
+
const { mkdirSync, renameSync, existsSync } = await import('node:fs');
|
|
140
|
+
const { join } = await import('node:path');
|
|
141
|
+
const { randomUUID } = await import('node:crypto');
|
|
142
|
+
mkdirSync(destinationDirectory, { recursive: true });
|
|
143
|
+
// UUID-named staging path: pid+timestamp collides when two downloads
|
|
144
|
+
// land in the same millisecond and the verifier would overwrite a
|
|
145
|
+
// concurrent verified payload.
|
|
146
|
+
const stagingPath = join(destinationDirectory, `.pd-payload-download-${randomUUID()}`);
|
|
147
|
+
downloaded = await updater.downloadTarget(target, stagingPath);
|
|
148
|
+
if (!existsSync(downloaded)) {
|
|
149
|
+
throw new Error(`verified download did not materialize: ${downloaded}`);
|
|
150
|
+
}
|
|
151
|
+
renameSync(downloaded, options.destinationPath);
|
|
152
|
+
downloaded = undefined;
|
|
153
|
+
}
|
|
154
|
+
catch (error) {
|
|
155
|
+
const causeMessage = error instanceof Error ? error.message : String(error);
|
|
156
|
+
throw new ReleaseTrustError({
|
|
157
|
+
code: 'metadata_refresh_failed',
|
|
158
|
+
message: `The trusted release payload could not be downloaded and verified (${options.targetPath}): ${causeMessage}`,
|
|
159
|
+
nextAction: 'Do not use this payload. Check the signed release repository and retry.',
|
|
160
|
+
cause: error,
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
finally {
|
|
164
|
+
if (downloaded !== undefined) {
|
|
165
|
+
const { rmSync } = await import('node:fs');
|
|
166
|
+
rmSync(downloaded, { force: true });
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
//# sourceMappingURL=trust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KAAK,EAAE,CAAC;QACf,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC5E,MAAM,IAAI,iBAAiB,CAAC;YAC1B,IAAI,EAAE,yBAAyB;YAC/B,OAAO,EAAE,qEAAqE,OAAO,CAAC,UAAU,MAAM,YAAY,EAAE;YACpH,UAAU,EAAE,yEAAyE;YACrF,KAAK,EAAE,KAAK;SACb,CAAC,CAAC;IACL,CAAC;YAAS,CAAC;QACT,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;YAC7B,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,CAAC;YAC3C,MAAM,CAAC,UAAU,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Update history semantics (SPEC §12).
|
|
3
|
+
*
|
|
4
|
+
* History events use explicit kinds: update, reinstall, channel_promotion,
|
|
5
|
+
* legacy_migration, rollback, refusal, and recovery. Direction is DERIVED
|
|
6
|
+
* from canonical release identity and metadata sequence — never from
|
|
7
|
+
* package.json values found in a checkout. Every failed or refused event
|
|
8
|
+
* states what happened, whether the previous release remains active, and
|
|
9
|
+
* the safest next action.
|
|
10
|
+
*/
|
|
11
|
+
export type HistoryKind = 'update' | 'reinstall' | 'channel_promotion' | 'legacy_migration' | 'rollback' | 'refusal' | 'recovery';
|
|
12
|
+
export type HistoryDirection = 'forward' | 'backward' | 'none';
|
|
13
|
+
export type HistoryOutcome = 'succeeded' | 'refused' | 'failed' | 'recovered';
|
|
14
|
+
export interface UpdateHistoryEvent {
|
|
15
|
+
readonly at: string;
|
|
16
|
+
readonly kind: HistoryKind;
|
|
17
|
+
readonly direction: HistoryDirection;
|
|
18
|
+
readonly outcome: HistoryOutcome;
|
|
19
|
+
readonly productVersion: string | null;
|
|
20
|
+
readonly releaseId: string | null;
|
|
21
|
+
readonly previousReleaseId: string | null;
|
|
22
|
+
/** True when the previously confirmed release is still the active one. */
|
|
23
|
+
readonly previousRemainsActive: boolean;
|
|
24
|
+
readonly reason: string | null;
|
|
25
|
+
readonly nextAction: string | null;
|
|
26
|
+
readonly transactionId: string | null;
|
|
27
|
+
}
|
|
28
|
+
export declare class UpdateHistoryError extends Error {
|
|
29
|
+
readonly field: string;
|
|
30
|
+
constructor(field: string, message: string);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Direction is derived from canonical publication sequences: forward when the
|
|
34
|
+
* event's release is newer than the previous one, backward when older,
|
|
35
|
+
* none for reinstall/refusal/unknown.
|
|
36
|
+
*/
|
|
37
|
+
export declare function classifyDirection(input: {
|
|
38
|
+
kind: HistoryKind;
|
|
39
|
+
releasePublicationSequence: number | null;
|
|
40
|
+
previousPublicationSequence: number | null;
|
|
41
|
+
}): HistoryDirection;
|
|
42
|
+
/** Appends one durable history event to `<pdHome>/logs/history.jsonl`. */
|
|
43
|
+
export declare function appendHistoryEvent(historyFilePath: string, event: UpdateHistoryEvent): void;
|
|
44
|
+
/** Strict reader for tests and the Console history surface. */
|
|
45
|
+
export declare function readHistoryEvents(historyFilePath: string): UpdateHistoryEvent[];
|
|
46
|
+
//# sourceMappingURL=update-history.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-history.d.ts","sourceRoot":"","sources":["../../src/update/update-history.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,MAAM,MAAM,WAAW,GACnB,QAAQ,GACR,WAAW,GACX,mBAAmB,GACnB,kBAAkB,GAClB,UAAU,GACV,SAAS,GACT,UAAU,CAAC;AAEf,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,UAAU,GAAG,MAAM,CAAC;AAE/D,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG,SAA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