create-principles-disciple 1.121.7 → 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 +4 -2
- 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 +4 -5
- 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 +7 -2
- 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 +3 -2
- package/plugin/dist/bundle.js +870 -932
- 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,305 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Governance Experience Snapshot collector — PRI-585 (SPEC v1.5.1).
|
|
3
|
+
*
|
|
4
|
+
* Batch source reader for the read-only governance experience layer:
|
|
5
|
+
* Batch Source Reader (4 queries + 1 ledger read + 1 config read, once)
|
|
6
|
+
* → group facts in memory per principle (GovernanceProjectionCollector.buildFacts)
|
|
7
|
+
* → deriveOwnerGovernanceView() per principle (existing projection, zero duplication)
|
|
8
|
+
* → deriveGovernanceExperienceSnapshot() aggregate (principles-core pure function)
|
|
9
|
+
*
|
|
10
|
+
* Forbidden by SPEC and absent here: `for (principle) { collect() }` — the four
|
|
11
|
+
* table reads happen exactly once per snapshot regardless of principle count.
|
|
12
|
+
* The snapshot explains; it never authorizes (ERR-102).
|
|
13
|
+
*/
|
|
14
|
+
import * as fs from 'node:fs';
|
|
15
|
+
import * as path from 'node:path';
|
|
16
|
+
import { createHash } from 'node:crypto';
|
|
17
|
+
import { deriveGovernanceExperienceSnapshot, deriveOwnerGovernanceView, } from '@principles/core/runtime-v2';
|
|
18
|
+
import { GovernanceProjectionCollector, isRecord, readOwnString, } from './GovernanceProjectionCollector.js';
|
|
19
|
+
import { loadPdConfig } from '../config/pd-config-store.js';
|
|
20
|
+
const EMPTY_TABLES = { artifactRows: [], taskRows: [], approvalRows: [], activationRows: [] };
|
|
21
|
+
const UNLINKED_SAMPLE_LIMIT = 10;
|
|
22
|
+
/**
|
|
23
|
+
* Stable, path-safe workspace hash for snapshotId (SPEC §13): never exposes the
|
|
24
|
+
* raw path and is never persisted. Windows normalization: backslashes become
|
|
25
|
+
* forward slashes and the drive letter is case-folded, so `D:\a\b`, `d:/a/b/`
|
|
26
|
+
* and `D:/a/b` hash identically. POSIX path case is intentionally preserved.
|
|
27
|
+
*/
|
|
28
|
+
export function hashWorkspacePath(workspaceDir) {
|
|
29
|
+
const resolved = path.resolve(workspaceDir).replace(/\\/g, '/').replace(/\/+$/, '');
|
|
30
|
+
const normalized = resolved.replace(/([A-Za-z]):/, (match, _drive) => match.toUpperCase());
|
|
31
|
+
return createHash('sha256').update(normalized).digest('hex').slice(0, 16);
|
|
32
|
+
}
|
|
33
|
+
export class GovernanceExperienceCollector {
|
|
34
|
+
workspaceDir;
|
|
35
|
+
constructor(workspaceDir) {
|
|
36
|
+
this.workspaceDir = workspaceDir;
|
|
37
|
+
}
|
|
38
|
+
collectSnapshot(options) {
|
|
39
|
+
return deriveGovernanceExperienceSnapshot(this.buildInputs(options));
|
|
40
|
+
}
|
|
41
|
+
buildInputs(options) {
|
|
42
|
+
const asOf = options.asOf ?? new Date().toISOString();
|
|
43
|
+
const sourceAvailability = [];
|
|
44
|
+
const dataQualityInputs = [];
|
|
45
|
+
// ── Principle ledger: read once, validate every entry ────────────────────
|
|
46
|
+
const ledger = this.scanLedger();
|
|
47
|
+
sourceAvailability.push({
|
|
48
|
+
sourceId: 'principle_ledger',
|
|
49
|
+
available: ledger.available,
|
|
50
|
+
...(ledger.reasonCode !== undefined ? { reasonCode: ledger.reasonCode } : {}),
|
|
51
|
+
});
|
|
52
|
+
if (ledger.invalidPrincipleRefs.length > 0) {
|
|
53
|
+
dataQualityInputs.push({
|
|
54
|
+
source: 'principle',
|
|
55
|
+
reasonCode: 'principle_ledger_entry_invalid',
|
|
56
|
+
count: ledger.invalidPrincipleRefs.length,
|
|
57
|
+
sampleRefs: ledger.invalidPrincipleRefs.slice(0, UNLINKED_SAMPLE_LIMIT),
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
// ── state.db: existence check + one batched table read ───────────────────
|
|
61
|
+
const dbPath = path.join(this.workspaceDir, '.pd', 'state.db');
|
|
62
|
+
let tables = EMPTY_TABLES;
|
|
63
|
+
let stateDbAvailable = true;
|
|
64
|
+
let stateDbReasonCode;
|
|
65
|
+
if (!fs.existsSync(dbPath)) {
|
|
66
|
+
stateDbAvailable = false;
|
|
67
|
+
stateDbReasonCode = 'state_db_missing';
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
try {
|
|
71
|
+
tables = (options.tableReader ?? GovernanceProjectionCollector.readTables)(this.workspaceDir);
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
stateDbAvailable = false;
|
|
75
|
+
stateDbReasonCode = 'state_db_read_failed';
|
|
76
|
+
tables = EMPTY_TABLES;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
sourceAvailability.push({
|
|
80
|
+
sourceId: 'state_db',
|
|
81
|
+
available: stateDbAvailable,
|
|
82
|
+
...(stateDbReasonCode !== undefined ? { reasonCode: stateDbReasonCode } : {}),
|
|
83
|
+
});
|
|
84
|
+
// ── Views: reuse the existing projection per principle, in memory ────────
|
|
85
|
+
const views = [];
|
|
86
|
+
const claimedTaskIds = new Set();
|
|
87
|
+
const principleIds = [...ledger.facts.keys()].sort();
|
|
88
|
+
for (const principleId of principleIds) {
|
|
89
|
+
const principle = ledger.facts.get(principleId);
|
|
90
|
+
if (principle === undefined)
|
|
91
|
+
continue;
|
|
92
|
+
const issues = [...(ledger.issuesByPrinciple.get(principleId) ?? [])];
|
|
93
|
+
try {
|
|
94
|
+
// state.db unavailable mirrors collect()'s degraded facts shape exactly
|
|
95
|
+
const facts = stateDbAvailable
|
|
96
|
+
? GovernanceProjectionCollector.buildFacts({ principleId, asOf, principle, tables, collectionIssues: issues })
|
|
97
|
+
: GovernanceProjectionCollector.factsForUnavailableSource({ principleId, asOf, principle, collectionIssues: issues });
|
|
98
|
+
for (const task of facts.tasks) {
|
|
99
|
+
if (task.taskId !== undefined)
|
|
100
|
+
claimedTaskIds.add(task.taskId);
|
|
101
|
+
}
|
|
102
|
+
views.push({ view: deriveOwnerGovernanceView(facts), lineageConfidence: facts.lineage.confidence });
|
|
103
|
+
}
|
|
104
|
+
catch {
|
|
105
|
+
// A principle whose facts/view fail validation never blocks the snapshot;
|
|
106
|
+
// it surfaces as a bounded data-quality group (fail loud, keep going).
|
|
107
|
+
dataQualityInputs.push({
|
|
108
|
+
source: 'principle',
|
|
109
|
+
reasonCode: 'projection_derivation_failed',
|
|
110
|
+
count: 1,
|
|
111
|
+
sampleRefs: [{ type: 'principle', id: principleId }],
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
// ── Linkage indexes + evidence + unlinked records (same batched rows) ────
|
|
116
|
+
const parsedTasks = [];
|
|
117
|
+
const parseIssues = []; // malformed rows are attributed per-principle by buildFacts; not double-counted here
|
|
118
|
+
if (stateDbAvailable) {
|
|
119
|
+
for (const row of tables.taskRows) {
|
|
120
|
+
const parsed = GovernanceProjectionCollector.parseTaskRow(row, parseIssues);
|
|
121
|
+
if (parsed !== null)
|
|
122
|
+
parsedTasks.push(parsed);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
// SPEC §9: unlinked records never enter activity classification. Evidence
|
|
126
|
+
// counts require an established relationship: a task must have produced an
|
|
127
|
+
// artifact row (task↔artifact), a RuleCode decision's artifact must exist
|
|
128
|
+
// AND belong to a principle present in the ledger (artifact↔principle).
|
|
129
|
+
const artifactIds = new Set();
|
|
130
|
+
const taskIdsWithArtifact = new Set();
|
|
131
|
+
const artifactOwnerKnown = new Map();
|
|
132
|
+
if (stateDbAvailable) {
|
|
133
|
+
for (const row of tables.artifactRows) {
|
|
134
|
+
if (!isRecord(row))
|
|
135
|
+
continue;
|
|
136
|
+
const artifactId = readOwnString(row, 'artifact_id');
|
|
137
|
+
if (artifactId === undefined)
|
|
138
|
+
continue;
|
|
139
|
+
artifactIds.add(artifactId);
|
|
140
|
+
const sourceTaskId = readOwnString(row, 'source_task_id');
|
|
141
|
+
if (sourceTaskId !== undefined)
|
|
142
|
+
taskIdsWithArtifact.add(sourceTaskId);
|
|
143
|
+
const sourcePrincipleId = readOwnString(row, 'source_principle_id');
|
|
144
|
+
artifactOwnerKnown.set(artifactId, sourcePrincipleId !== undefined && ledger.available && ledger.presentPrincipleIds.has(sourcePrincipleId));
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
const activeTasks = stateDbAvailable
|
|
148
|
+
? parsedTasks.filter(task => task.status !== 'succeeded' && taskIdsWithArtifact.has(task.taskId))
|
|
149
|
+
: [];
|
|
150
|
+
// RuleCode owner decisions awaiting action (SPEC §8.3 source): non-deactivated
|
|
151
|
+
// shadow activations with verified linkage; unlinked ones degrade to data
|
|
152
|
+
// quality instead of inflating the decision count.
|
|
153
|
+
const rulecodePendingRefs = [];
|
|
154
|
+
let rulecodePendingCount = 0;
|
|
155
|
+
const unlinkedRulecodeRefs = [];
|
|
156
|
+
let unlinkedRulecodeCount = 0;
|
|
157
|
+
if (stateDbAvailable) {
|
|
158
|
+
for (const row of tables.activationRows) {
|
|
159
|
+
if (!isRecord(row))
|
|
160
|
+
continue;
|
|
161
|
+
const action = readOwnString(row, 'action');
|
|
162
|
+
const deactivatedAt = readOwnString(row, 'deactivated_at');
|
|
163
|
+
if (action !== 'code_tool_hook_shadow_activate' || deactivatedAt !== undefined)
|
|
164
|
+
continue;
|
|
165
|
+
const artifactId = readOwnString(row, 'artifact_id');
|
|
166
|
+
const activationId = readOwnString(row, 'activation_id');
|
|
167
|
+
const ref = activationId === undefined ? undefined : { type: 'activation', id: activationId };
|
|
168
|
+
if (artifactId !== undefined && artifactOwnerKnown.get(artifactId) === true) {
|
|
169
|
+
rulecodePendingCount += 1;
|
|
170
|
+
if (ref !== undefined && rulecodePendingRefs.length < UNLINKED_SAMPLE_LIMIT)
|
|
171
|
+
rulecodePendingRefs.push(ref);
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
unlinkedRulecodeCount += 1;
|
|
175
|
+
if (ref !== undefined && unlinkedRulecodeRefs.length < UNLINKED_SAMPLE_LIMIT)
|
|
176
|
+
unlinkedRulecodeRefs.push(ref);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
if (unlinkedRulecodeCount > 0) {
|
|
181
|
+
dataQualityInputs.push({ source: 'activation', reasonCode: 'unlinked_record', count: unlinkedRulecodeCount, sampleRefs: unlinkedRulecodeRefs });
|
|
182
|
+
}
|
|
183
|
+
if (stateDbAvailable) {
|
|
184
|
+
const unlinkedApprovalRefs = [];
|
|
185
|
+
let unlinkedApprovalCount = 0;
|
|
186
|
+
for (const row of tables.approvalRows) {
|
|
187
|
+
if (!isRecord(row))
|
|
188
|
+
continue;
|
|
189
|
+
const artifactId = readOwnString(row, 'artifact_id');
|
|
190
|
+
const approvalId = readOwnString(row, 'approval_id');
|
|
191
|
+
if (artifactId !== undefined && !artifactIds.has(artifactId)) {
|
|
192
|
+
unlinkedApprovalCount += 1;
|
|
193
|
+
if (approvalId !== undefined && unlinkedApprovalRefs.length < UNLINKED_SAMPLE_LIMIT) {
|
|
194
|
+
unlinkedApprovalRefs.push({ type: 'approval', id: approvalId });
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
if (unlinkedApprovalCount > 0) {
|
|
199
|
+
dataQualityInputs.push({ source: 'approval', reasonCode: 'unlinked_record', count: unlinkedApprovalCount, sampleRefs: unlinkedApprovalRefs });
|
|
200
|
+
}
|
|
201
|
+
if (ledger.available) {
|
|
202
|
+
const unlinkedArtifactRefs = [];
|
|
203
|
+
let unlinkedArtifactCount = 0;
|
|
204
|
+
for (const row of tables.artifactRows) {
|
|
205
|
+
if (!isRecord(row))
|
|
206
|
+
continue;
|
|
207
|
+
const sourcePrincipleId = readOwnString(row, 'source_principle_id');
|
|
208
|
+
const artifactId = readOwnString(row, 'artifact_id');
|
|
209
|
+
if (sourcePrincipleId !== undefined && !ledger.presentPrincipleIds.has(sourcePrincipleId)) {
|
|
210
|
+
unlinkedArtifactCount += 1;
|
|
211
|
+
if (artifactId !== undefined && unlinkedArtifactRefs.length < UNLINKED_SAMPLE_LIMIT) {
|
|
212
|
+
unlinkedArtifactRefs.push({ type: 'artifact', id: artifactId });
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
if (unlinkedArtifactCount > 0) {
|
|
217
|
+
dataQualityInputs.push({ source: 'artifact', reasonCode: 'unlinked_record', count: unlinkedArtifactCount, sampleRefs: unlinkedArtifactRefs });
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
const unlinkedTaskRefs = [];
|
|
221
|
+
let unlinkedTaskCount = 0;
|
|
222
|
+
for (const task of parsedTasks) {
|
|
223
|
+
if (claimedTaskIds.has(task.taskId))
|
|
224
|
+
continue;
|
|
225
|
+
unlinkedTaskCount += 1;
|
|
226
|
+
if (unlinkedTaskRefs.length < UNLINKED_SAMPLE_LIMIT)
|
|
227
|
+
unlinkedTaskRefs.push({ type: 'task', id: task.taskId });
|
|
228
|
+
}
|
|
229
|
+
if (unlinkedTaskCount > 0) {
|
|
230
|
+
dataQualityInputs.push({ source: 'task', reasonCode: 'unlinked_record', count: unlinkedTaskCount, sampleRefs: unlinkedTaskRefs });
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
// ── Workspace config environment (PRI-587) via the unified validator ─────
|
|
234
|
+
const configResult = loadPdConfig(this.workspaceDir);
|
|
235
|
+
const environment = configResult.ok ? configResult.effective.config.workspace?.environment : undefined;
|
|
236
|
+
const environmentContext = configResult.ok
|
|
237
|
+
? environment !== undefined
|
|
238
|
+
? { environment, source: 'workspace_config' }
|
|
239
|
+
: { environment: 'unknown', source: 'missing' }
|
|
240
|
+
: { environment: 'unknown', source: 'missing', configIssue: 'config_invalid' };
|
|
241
|
+
return {
|
|
242
|
+
schemaVersion: '1',
|
|
243
|
+
asOf,
|
|
244
|
+
workspaceHash: hashWorkspacePath(this.workspaceDir),
|
|
245
|
+
governanceViews: views,
|
|
246
|
+
ownerConfigSnapshot: options.ownerConfig,
|
|
247
|
+
environmentContext,
|
|
248
|
+
sourceAvailability,
|
|
249
|
+
dataQualityInputs,
|
|
250
|
+
...(stateDbAvailable
|
|
251
|
+
? {
|
|
252
|
+
frontierEvidence: { sourceId: 'state_db', activeTaskCount: activeTasks.length, sampleRefs: activeTasks.slice(0, UNLINKED_SAMPLE_LIMIT).map(task => ({ type: 'task', id: task.taskId })) },
|
|
253
|
+
rulecodeDecisionEvidence: { pendingCount: rulecodePendingCount, sampleRefs: rulecodePendingRefs },
|
|
254
|
+
}
|
|
255
|
+
: {}),
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Reads the principle ledger once and validates every entry. A readable file
|
|
260
|
+
* with a malformed tree counts as an unavailable ledger source (no views can
|
|
261
|
+
* be built); individual invalid entries degrade to data-quality groups.
|
|
262
|
+
*/
|
|
263
|
+
scanLedger() {
|
|
264
|
+
const scan = {
|
|
265
|
+
available: true,
|
|
266
|
+
presentPrincipleIds: new Set(),
|
|
267
|
+
facts: new Map(),
|
|
268
|
+
issuesByPrinciple: new Map(),
|
|
269
|
+
invalidPrincipleRefs: [],
|
|
270
|
+
};
|
|
271
|
+
let parsed;
|
|
272
|
+
try {
|
|
273
|
+
parsed = GovernanceProjectionCollector.parsePrincipleLedgerFile(this.workspaceDir);
|
|
274
|
+
}
|
|
275
|
+
catch {
|
|
276
|
+
scan.available = false;
|
|
277
|
+
scan.reasonCode = 'ledger_unreadable';
|
|
278
|
+
return scan;
|
|
279
|
+
}
|
|
280
|
+
if (!isRecord(parsed)) {
|
|
281
|
+
scan.available = false;
|
|
282
|
+
scan.reasonCode = 'ledger_tree_malformed';
|
|
283
|
+
return scan;
|
|
284
|
+
}
|
|
285
|
+
const principlesTree = GovernanceProjectionCollector.principleTreeFromLedger(parsed);
|
|
286
|
+
if (principlesTree === null) {
|
|
287
|
+
scan.available = false;
|
|
288
|
+
scan.reasonCode = 'ledger_tree_malformed';
|
|
289
|
+
return scan;
|
|
290
|
+
}
|
|
291
|
+
for (const principleId of Object.keys(principlesTree).sort()) {
|
|
292
|
+
scan.presentPrincipleIds.add(principleId);
|
|
293
|
+
const issues = [];
|
|
294
|
+
try {
|
|
295
|
+
const fact = GovernanceProjectionCollector.principleFactFromLedger(parsed, principleId, issues);
|
|
296
|
+
scan.facts.set(principleId, fact);
|
|
297
|
+
scan.issuesByPrinciple.set(principleId, issues);
|
|
298
|
+
}
|
|
299
|
+
catch {
|
|
300
|
+
scan.invalidPrincipleRefs.push({ type: 'principle', id: principleId });
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
return scan;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
@@ -1,16 +1,74 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type Database from 'better-sqlite3';
|
|
2
|
+
import type { DataQualityIssue, GovernanceFacts, GovernanceChannel, RevisionIdentity, RunnerVerdictFact, TaskFact } from '@principles/core/runtime-v2';
|
|
3
|
+
export declare const GOVERNANCE_TASK_KINDS: Set<string>;
|
|
4
|
+
export declare const GOVERNANCE_TASK_STATUSES: Set<string>;
|
|
5
|
+
export declare function isRecord(value: unknown): value is Record<string, unknown>;
|
|
6
|
+
export declare function readOwnString(record: Record<string, unknown>, key: string): string | undefined;
|
|
2
7
|
export declare class GovernanceProjectionCollectionError extends Error {
|
|
3
8
|
readonly reasonCode: 'principle_not_found' | 'governance_projection_error';
|
|
4
9
|
readonly nextActionCode: string;
|
|
5
10
|
constructor(reasonCode: 'principle_not_found' | 'governance_projection_error', nextActionCode: string);
|
|
6
11
|
}
|
|
12
|
+
export interface ValidTaskRow {
|
|
13
|
+
taskId: string;
|
|
14
|
+
taskKind: TaskFact['taskKind'];
|
|
15
|
+
status: TaskFact['status'];
|
|
16
|
+
createdAt: string;
|
|
17
|
+
updatedAt: string;
|
|
18
|
+
leaseExpiresAt?: string;
|
|
19
|
+
attemptCount: number;
|
|
20
|
+
maxAttempts: number;
|
|
21
|
+
lastErrorCategory?: TaskFact['lastErrorCategory'];
|
|
22
|
+
channel: GovernanceChannel;
|
|
23
|
+
dependencyTaskIds: string[];
|
|
24
|
+
revisionIdentity?: RevisionIdentity;
|
|
25
|
+
completionIntent?: TaskFact['completionIntent'];
|
|
26
|
+
runnerDecision?: RunnerVerdictFact['outcome'];
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Raw rows for the four tables the projection reads. Populated once per
|
|
30
|
+
* workspace by `readTables` and grouped per principle in memory by
|
|
31
|
+
* `buildFacts` — the batch experience collector (PRI-585) reuses the same
|
|
32
|
+
* rows so a workspace snapshot costs 4 queries total, not 4 per principle.
|
|
33
|
+
*/
|
|
34
|
+
export interface GovernanceProjectionTables {
|
|
35
|
+
artifactRows: unknown[];
|
|
36
|
+
taskRows: unknown[];
|
|
37
|
+
approvalRows: unknown[];
|
|
38
|
+
activationRows: unknown[];
|
|
39
|
+
}
|
|
7
40
|
export declare class GovernanceProjectionCollector {
|
|
8
41
|
private readonly workspaceDir;
|
|
9
42
|
constructor(workspaceDir: string);
|
|
10
43
|
collect(principleId: string, asOf: string): Promise<GovernanceFacts>;
|
|
44
|
+
/** Degraded facts shape used when state.db is unavailable (shared by single + batch collectors). */
|
|
45
|
+
static factsForUnavailableSource(input: {
|
|
46
|
+
principleId: string;
|
|
47
|
+
asOf: string;
|
|
48
|
+
principle: GovernanceFacts['principle'];
|
|
49
|
+
collectionIssues: DataQualityIssue[];
|
|
50
|
+
}): GovernanceFacts;
|
|
51
|
+
/** Reads the four projection tables once. Closes its own connection unless one is injected (caller then owns closing). */
|
|
52
|
+
static readTables(workspaceDir: string, injected?: {
|
|
53
|
+
getDb(): Database.Database;
|
|
54
|
+
}): GovernanceProjectionTables;
|
|
55
|
+
/** Groups pre-fetched raw rows into GovernanceFacts for ONE principle. Pure in-memory. */
|
|
56
|
+
static buildFacts(input: {
|
|
57
|
+
principleId: string;
|
|
58
|
+
asOf: string;
|
|
59
|
+
principle: GovernanceFacts['principle'];
|
|
60
|
+
tables: GovernanceProjectionTables;
|
|
61
|
+
collectionIssues: DataQualityIssue[];
|
|
62
|
+
}): GovernanceFacts;
|
|
11
63
|
private readPrinciple;
|
|
64
|
+
/** Reads and JSON-parses the principle ledger file (shared by single + batch collectors). */
|
|
65
|
+
static parsePrincipleLedgerFile(workspaceDir: string): unknown;
|
|
66
|
+
/** Extracts the principles record from a parsed ledger; null when the tree is absent/malformed. */
|
|
67
|
+
static principleTreeFromLedger(parsed: unknown): Record<string, unknown> | null;
|
|
68
|
+
/** Validates one principle entry from an already-parsed ledger (shared by single + batch collectors). */
|
|
69
|
+
static principleFactFromLedger(parsed: unknown, principleId: string, issues: DataQualityIssue[]): GovernanceFacts['principle'];
|
|
12
70
|
private static parseStringArrayJson;
|
|
13
|
-
|
|
71
|
+
static parseTaskRow(row: unknown, issues: DataQualityIssue[]): ValidTaskRow | null;
|
|
14
72
|
private static connectedTaskIds;
|
|
15
73
|
private static finish;
|
|
16
74
|
}
|