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
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
import * as fs from 'node:fs';
|
|
2
2
|
import * as path from 'node:path';
|
|
3
3
|
import { Value } from '@sinclair/typebox/value';
|
|
4
|
-
import { GovernanceFactsSchema, SqliteConnection, isPDErrorCategory, parsePITaskMetadata, } from '@principles/core/runtime-v2';
|
|
5
|
-
const GOVERNANCE_TASK_KINDS = new Set([
|
|
4
|
+
import { GovernanceFactsSchema, SqliteConnection, isPDErrorCategory, parsePITaskMetadata, PD_TASK_STATUSES, PRINCIPLE_STATUSES, isPDTaskStatus, } from '@principles/core/runtime-v2';
|
|
5
|
+
export const GOVERNANCE_TASK_KINDS = new Set([
|
|
6
6
|
'dreamer', 'philosopher', 'scribe', 'artificer', 'evaluator', 'rollout_reviewer',
|
|
7
7
|
]);
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const PRINCIPLE_STATES = new Set(['candidate', 'active', 'archived', 'deprecated', 'probation']);
|
|
8
|
+
// PRI-612: both status sets derive from the canonical core authorities.
|
|
9
|
+
export const GOVERNANCE_TASK_STATUSES = new Set(PD_TASK_STATUSES);
|
|
10
|
+
const PRINCIPLE_STATES = new Set(PRINCIPLE_STATUSES);
|
|
12
11
|
const ISO_UTC = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{3})?Z$/;
|
|
13
12
|
const MAX_LINEAGE_NODES = 500;
|
|
14
|
-
function isRecord(value) {
|
|
13
|
+
export function isRecord(value) {
|
|
15
14
|
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
16
15
|
}
|
|
17
|
-
function readOwnString(record, key) {
|
|
16
|
+
export function readOwnString(record, key) {
|
|
18
17
|
if (!Object.hasOwn(record, key))
|
|
19
18
|
return undefined;
|
|
20
19
|
const value = record[key];
|
|
@@ -57,317 +56,356 @@ export class GovernanceProjectionCollector {
|
|
|
57
56
|
const principle = this.readPrinciple(principleId, collectionIssues);
|
|
58
57
|
const dbPath = path.join(this.workspaceDir, '.pd', 'state.db');
|
|
59
58
|
if (!fs.existsSync(dbPath)) {
|
|
60
|
-
|
|
61
|
-
return GovernanceProjectionCollector.finish({ principleId, asOf, principle, collectionIssues });
|
|
59
|
+
return GovernanceProjectionCollector.factsForUnavailableSource({ principleId, asOf, principle, collectionIssues });
|
|
62
60
|
}
|
|
63
|
-
const connection = new SqliteConnection({ workspaceDir: this.workspaceDir, readonly: true });
|
|
64
61
|
try {
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
62
|
+
const tables = GovernanceProjectionCollector.readTables(this.workspaceDir);
|
|
63
|
+
return GovernanceProjectionCollector.buildFacts({ principleId, asOf, principle, tables, collectionIssues });
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
if (error instanceof GovernanceProjectionCollectionError)
|
|
67
|
+
throw error;
|
|
68
|
+
throw new GovernanceProjectionCollectionError('governance_projection_error', 'inspect_runtime_state');
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/** Degraded facts shape used when state.db is unavailable (shared by single + batch collectors). */
|
|
72
|
+
static factsForUnavailableSource(input) {
|
|
73
|
+
const { principleId, asOf, principle, collectionIssues } = input;
|
|
74
|
+
collectionIssues.push(issue({ source: 'lineage', reasonCode: 'source_unavailable', nextActionCode: 'initialize_runtime_state' }));
|
|
75
|
+
return GovernanceProjectionCollector.finish({ principleId, asOf, principle, collectionIssues });
|
|
76
|
+
}
|
|
77
|
+
/** Reads the four projection tables once. Closes its own connection unless one is injected (caller then owns closing). */
|
|
78
|
+
static readTables(workspaceDir, injected) {
|
|
79
|
+
const own = injected === undefined ? new SqliteConnection({ workspaceDir, readonly: true }) : null;
|
|
80
|
+
try {
|
|
81
|
+
const db = (injected ?? own)?.getDb();
|
|
82
|
+
if (db === undefined)
|
|
83
|
+
throw new Error('readTables: no database handle');
|
|
84
|
+
return {
|
|
85
|
+
artifactRows: db.prepare(`
|
|
86
|
+
SELECT artifact_id, source_task_id, source_principle_id, lineage_artifact_ids, updated_at
|
|
87
|
+
FROM pi_artifacts ORDER BY artifact_id ASC
|
|
88
|
+
`).all(),
|
|
89
|
+
taskRows: db.prepare('SELECT * FROM tasks ORDER BY task_id ASC').all(),
|
|
90
|
+
approvalRows: db.prepare('SELECT * FROM approvals ORDER BY approval_id ASC').all(),
|
|
91
|
+
activationRows: db.prepare('SELECT * FROM activations ORDER BY activated_at ASC, activation_id ASC').all(),
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
finally {
|
|
95
|
+
own?.close();
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/** Groups pre-fetched raw rows into GovernanceFacts for ONE principle. Pure in-memory. */
|
|
99
|
+
static buildFacts(input) {
|
|
100
|
+
const { principleId, asOf, principle, tables, collectionIssues } = input;
|
|
101
|
+
const artifactIds = [];
|
|
102
|
+
const rootTaskIds = [];
|
|
103
|
+
const sourceRefs = [{ type: 'principle', id: principleId }];
|
|
104
|
+
const { artifactRows } = tables;
|
|
105
|
+
const validArtifacts = new Map();
|
|
106
|
+
for (const row of artifactRows) {
|
|
107
|
+
if (!isRecord(row)) {
|
|
108
|
+
collectionIssues.push(issue({ source: 'artifact', reasonCode: 'metadata_malformed', nextActionCode: 'repair_artifact_metadata' }));
|
|
109
|
+
continue;
|
|
99
110
|
}
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
111
|
+
const artifactId = readOwnString(row, 'artifact_id');
|
|
112
|
+
const sourceTaskId = readOwnString(row, 'source_task_id');
|
|
113
|
+
const sourcePrincipleId = readOwnString(row, 'source_principle_id');
|
|
114
|
+
const updatedAt = readOwnString(row, 'updated_at');
|
|
115
|
+
const lineageJson = readOwnString(row, 'lineage_artifact_ids');
|
|
116
|
+
const lineageArtifactIds = GovernanceProjectionCollector.parseStringArrayJson(lineageJson);
|
|
117
|
+
const artifactRef = artifactId === undefined ? undefined : { type: 'artifact', id: artifactId };
|
|
118
|
+
if (artifactId === undefined || sourceTaskId === undefined || !isTimestamp(updatedAt)
|
|
119
|
+
|| lineageArtifactIds === null) {
|
|
120
|
+
if (sourcePrincipleId === principleId) {
|
|
121
|
+
collectionIssues.push(issue(artifactRef === undefined
|
|
122
|
+
? { source: 'artifact', reasonCode: 'metadata_malformed', nextActionCode: 'repair_artifact_metadata' }
|
|
123
|
+
: { source: 'artifact', reasonCode: 'metadata_malformed', nextActionCode: 'repair_artifact_metadata', sourceRef: artifactRef }));
|
|
109
124
|
}
|
|
125
|
+
continue;
|
|
110
126
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
127
|
+
validArtifacts.set(artifactId, {
|
|
128
|
+
artifactId, sourceTaskId, lineageArtifactIds,
|
|
129
|
+
...(sourcePrincipleId === undefined ? {} : { sourcePrincipleId }),
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
const strongArtifactIds = new Set([...validArtifacts.values()].filter(row => row.sourcePrincipleId === principleId).map(row => row.artifactId));
|
|
133
|
+
let addedArtifact = true;
|
|
134
|
+
while (addedArtifact) {
|
|
135
|
+
addedArtifact = false;
|
|
136
|
+
for (const row of validArtifacts.values()) {
|
|
137
|
+
if (!strongArtifactIds.has(row.artifactId) && row.lineageArtifactIds.some(id => strongArtifactIds.has(id))) {
|
|
138
|
+
strongArtifactIds.add(row.artifactId);
|
|
139
|
+
addedArtifact = true;
|
|
140
|
+
}
|
|
122
141
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
142
|
+
}
|
|
143
|
+
for (const artifactId of [...strongArtifactIds].sort()) {
|
|
144
|
+
const artifact = validArtifacts.get(artifactId);
|
|
145
|
+
if (artifact === undefined)
|
|
146
|
+
continue;
|
|
147
|
+
artifactIds.push(artifactId);
|
|
148
|
+
rootTaskIds.push(artifact.sourceTaskId);
|
|
149
|
+
sourceRefs.push({ type: 'artifact', id: artifactId });
|
|
150
|
+
}
|
|
151
|
+
if (artifactIds.length === 0) {
|
|
152
|
+
collectionIssues.push(issue({ source: 'lineage', reasonCode: 'lineage_not_available', nextActionCode: 'wait_for_durable_lineage' }));
|
|
153
|
+
return GovernanceProjectionCollector.finish({ principleId, asOf, principle, collectionIssues });
|
|
154
|
+
}
|
|
155
|
+
const validTasks = new Map();
|
|
156
|
+
const taskRowIssues = [];
|
|
157
|
+
const { taskRows } = tables;
|
|
158
|
+
for (const row of taskRows) {
|
|
159
|
+
const parsed = GovernanceProjectionCollector.parseTaskRow(row, taskRowIssues);
|
|
160
|
+
if (parsed !== null)
|
|
161
|
+
validTasks.set(parsed.taskId, parsed);
|
|
162
|
+
}
|
|
163
|
+
const connected = GovernanceProjectionCollector.connectedTaskIds(rootTaskIds, validTasks, collectionIssues);
|
|
164
|
+
const taskLineageConfidence = collectionIssues.some(item => item.reasonCode === 'lineage_cycle' || item.reasonCode === 'lineage_limit_exceeded') ? 'weak' : 'strong';
|
|
165
|
+
for (const taskIssue of taskRowIssues) {
|
|
166
|
+
if (taskIssue.sourceRef?.type === 'task' && connected.has(taskIssue.sourceRef.id)) {
|
|
167
|
+
collectionIssues.push(taskIssue);
|
|
130
168
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
169
|
+
}
|
|
170
|
+
const tasks = [];
|
|
171
|
+
const runnerVerdicts = [];
|
|
172
|
+
const derivedRelations = [];
|
|
173
|
+
const revisionIdentities = [];
|
|
174
|
+
const timelineEvents = [];
|
|
175
|
+
const materializedRevisionSources = new Set();
|
|
176
|
+
for (const taskId of connected) {
|
|
177
|
+
const task = validTasks.get(taskId);
|
|
178
|
+
if (task === undefined) {
|
|
179
|
+
collectionIssues.push(issue({ source: 'task', reasonCode: 'metadata_malformed', nextActionCode: 'repair_task_metadata', sourceRef: { type: 'task', id: taskId } }));
|
|
180
|
+
continue;
|
|
137
181
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
if (
|
|
147
|
-
|
|
182
|
+
if (task.revisionIdentity !== undefined) {
|
|
183
|
+
const identity = task.revisionIdentity;
|
|
184
|
+
const sourceTaskId = identity.kind === 'evaluator_repair'
|
|
185
|
+
? identity.sourceEvaluatorTaskId
|
|
186
|
+
: identity.kind === 'rollout_reopen' ? identity.sourceRolloutTaskId : undefined;
|
|
187
|
+
const sourceArtifactId = identity.kind === 'evaluator_repair'
|
|
188
|
+
? identity.sourceArtificerArtifactId
|
|
189
|
+
: identity.kind === 'rollout_reopen' ? identity.sourceArtifactId : undefined;
|
|
190
|
+
if (sourceTaskId === undefined || sourceArtifactId === undefined
|
|
191
|
+
|| !connected.has(sourceTaskId) || !strongArtifactIds.has(sourceArtifactId)) {
|
|
192
|
+
collectionIssues.push(issue({
|
|
193
|
+
source: 'lineage', reasonCode: 'lineage_conflict', nextActionCode: 'repair_revision_lineage',
|
|
194
|
+
sourceRef: { type: 'task', id: task.taskId },
|
|
195
|
+
}));
|
|
148
196
|
continue;
|
|
149
197
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
: identity.kind === 'rollout_reopen' ? identity.sourceRolloutTaskId : undefined;
|
|
155
|
-
const sourceArtifactId = identity.kind === 'evaluator_repair'
|
|
156
|
-
? identity.sourceArtificerArtifactId
|
|
157
|
-
: identity.kind === 'rollout_reopen' ? identity.sourceArtifactId : undefined;
|
|
158
|
-
if (sourceTaskId === undefined || sourceArtifactId === undefined
|
|
159
|
-
|| !connected.has(sourceTaskId) || !strongArtifactIds.has(sourceArtifactId)) {
|
|
160
|
-
collectionIssues.push(issue({
|
|
161
|
-
source: 'lineage', reasonCode: 'lineage_conflict', nextActionCode: 'repair_revision_lineage',
|
|
162
|
-
sourceRef: { type: 'task', id: task.taskId },
|
|
163
|
-
}));
|
|
164
|
-
continue;
|
|
165
|
-
}
|
|
166
|
-
revisionIdentities.push(identity);
|
|
167
|
-
materializedRevisionSources.add(sourceTaskId);
|
|
168
|
-
derivedRelations.push({
|
|
169
|
-
schemaVersion: '1', family: 'derived_relation', sourceRef: { type: 'task', id: task.taskId }, principleId,
|
|
170
|
-
taskId: task.taskId, lineageConfidence: taskLineageConfidence, recordedAt: task.updatedAt,
|
|
171
|
-
revisionIdentity: identity, relation: 'revision_materialized',
|
|
172
|
-
evidenceRefs: [
|
|
173
|
-
{ type: 'task', id: sourceTaskId },
|
|
174
|
-
{ type: 'artifact', id: sourceArtifactId },
|
|
175
|
-
{ type: 'task', id: task.taskId },
|
|
176
|
-
],
|
|
177
|
-
});
|
|
178
|
-
timelineEvents.push({
|
|
179
|
-
code: 'revision_reopened', occurredAt: task.createdAt, recordedAt: task.updatedAt,
|
|
180
|
-
summaryCode: 'governance.timeline.revision_reopened', sourceRef: { type: 'task', id: task.taskId },
|
|
181
|
-
lineageConfidence: taskLineageConfidence,
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
const fact = {
|
|
185
|
-
schemaVersion: '1', family: 'task', sourceRef: { type: 'task', id: task.taskId }, principleId,
|
|
198
|
+
revisionIdentities.push(identity);
|
|
199
|
+
materializedRevisionSources.add(sourceTaskId);
|
|
200
|
+
derivedRelations.push({
|
|
201
|
+
schemaVersion: '1', family: 'derived_relation', sourceRef: { type: 'task', id: task.taskId }, principleId,
|
|
186
202
|
taskId: task.taskId, lineageConfidence: taskLineageConfidence, recordedAt: task.updatedAt,
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
203
|
+
revisionIdentity: identity, relation: 'revision_materialized',
|
|
204
|
+
evidenceRefs: [
|
|
205
|
+
{ type: 'task', id: sourceTaskId },
|
|
206
|
+
{ type: 'artifact', id: sourceArtifactId },
|
|
207
|
+
{ type: 'task', id: task.taskId },
|
|
208
|
+
],
|
|
209
|
+
});
|
|
210
|
+
timelineEvents.push({
|
|
211
|
+
code: 'revision_reopened', occurredAt: task.createdAt, recordedAt: task.updatedAt,
|
|
212
|
+
summaryCode: 'governance.timeline.revision_reopened', sourceRef: { type: 'task', id: task.taskId },
|
|
213
|
+
lineageConfidence: taskLineageConfidence,
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
const fact = {
|
|
217
|
+
schemaVersion: '1', family: 'task', sourceRef: { type: 'task', id: task.taskId }, principleId,
|
|
218
|
+
taskId: task.taskId, lineageConfidence: taskLineageConfidence, recordedAt: task.updatedAt,
|
|
219
|
+
occurredAt: task.createdAt, taskKind: task.taskKind, channel: task.channel, status: task.status,
|
|
220
|
+
attemptCount: task.attemptCount, maxAttempts: task.maxAttempts,
|
|
221
|
+
};
|
|
222
|
+
if (task.leaseExpiresAt !== undefined)
|
|
223
|
+
fact.leaseExpiresAt = task.leaseExpiresAt;
|
|
224
|
+
if (task.lastErrorCategory !== undefined)
|
|
225
|
+
fact.lastErrorCategory = task.lastErrorCategory;
|
|
226
|
+
if (task.revisionIdentity !== undefined) {
|
|
227
|
+
fact.revisionIdentity = task.revisionIdentity;
|
|
228
|
+
}
|
|
229
|
+
if (task.completionIntent !== undefined)
|
|
230
|
+
fact.completionIntent = task.completionIntent;
|
|
231
|
+
tasks.push(fact);
|
|
232
|
+
sourceRefs.push(fact.sourceRef);
|
|
233
|
+
if ((task.taskKind === 'evaluator' || task.taskKind === 'rollout_reviewer') && task.runnerDecision !== undefined) {
|
|
234
|
+
runnerVerdicts.push({
|
|
235
|
+
schemaVersion: '1', family: 'runner_verdict', sourceRef: fact.sourceRef, principleId,
|
|
236
|
+
taskId: task.taskId, lineageConfidence: taskLineageConfidence, recordedAt: task.updatedAt,
|
|
237
|
+
runnerKind: task.taskKind, outcome: task.runnerDecision,
|
|
238
|
+
});
|
|
239
|
+
timelineEvents.push({
|
|
240
|
+
code: 'review_started', occurredAt: task.createdAt, recordedAt: task.updatedAt,
|
|
241
|
+
summaryCode: 'governance.timeline.review_started', sourceRef: fact.sourceRef, lineageConfidence: taskLineageConfidence,
|
|
242
|
+
});
|
|
243
|
+
if (task.runnerDecision === 'needs_revision') {
|
|
227
244
|
timelineEvents.push({
|
|
228
|
-
code, occurredAt: task.updatedAt, recordedAt: task.updatedAt,
|
|
229
|
-
summaryCode:
|
|
245
|
+
code: 'revision_requested', occurredAt: task.updatedAt, recordedAt: task.updatedAt,
|
|
246
|
+
summaryCode: 'governance.timeline.revision_requested', sourceRef: fact.sourceRef, lineageConfidence: taskLineageConfidence,
|
|
230
247
|
});
|
|
231
248
|
}
|
|
232
249
|
}
|
|
233
|
-
|
|
234
|
-
const strongTaskIds = new Set(tasks.filter(task => task.lineageConfidence === 'strong').map(task => task.taskId).filter((taskId) => taskId !== undefined));
|
|
235
|
-
for (const task of tasks) {
|
|
236
|
-
const { taskId } = task;
|
|
237
|
-
if (taskId === undefined || task.completionIntent?.status !== 'pending' || materializedRevisionSources.has(taskId))
|
|
238
|
-
continue;
|
|
250
|
+
else if ((task.taskKind === 'evaluator' || task.taskKind === 'rollout_reviewer') && task.status === 'succeeded') {
|
|
239
251
|
derivedRelations.push({
|
|
240
|
-
schemaVersion: '1', family: 'derived_relation', sourceRef:
|
|
241
|
-
taskId, lineageConfidence:
|
|
242
|
-
relation: '
|
|
252
|
+
schemaVersion: '1', family: 'derived_relation', sourceRef: fact.sourceRef, principleId,
|
|
253
|
+
taskId: task.taskId, lineageConfidence: taskLineageConfidence, recordedAt: task.updatedAt,
|
|
254
|
+
relation: 'verdict_missing', evidenceRefs: [fact.sourceRef],
|
|
243
255
|
});
|
|
244
256
|
}
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
derivedRelations.push({
|
|
252
|
-
schemaVersion: '1', family: 'derived_relation', sourceRef: { type: 'task', id: dependencyTaskId }, principleId,
|
|
253
|
-
taskId: dependencyTaskId, lineageConfidence: 'strong', recordedAt: successor.updatedAt,
|
|
254
|
-
relation: 'successor_present',
|
|
255
|
-
evidenceRefs: [{ type: 'task', id: dependencyTaskId }, { type: 'task', id: successor.taskId }],
|
|
256
|
-
});
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
const approvals = [];
|
|
260
|
-
const activations = [];
|
|
261
|
-
for (const row of db.prepare('SELECT * FROM approvals ORDER BY approval_id ASC').all()) {
|
|
262
|
-
if (!isRecord(row))
|
|
263
|
-
continue;
|
|
264
|
-
const artifactId = readOwnString(row, 'artifact_id');
|
|
265
|
-
if (artifactId === undefined || !strongArtifactIds.has(artifactId))
|
|
266
|
-
continue;
|
|
267
|
-
const approvalId = readOwnString(row, 'approval_id');
|
|
268
|
-
const channel = readOwnString(row, 'channel');
|
|
269
|
-
const outcome = readOwnString(row, 'status');
|
|
270
|
-
const requestedAt = readOwnString(row, 'requested_at');
|
|
271
|
-
const decidedAt = readOwnString(row, 'decided_at');
|
|
272
|
-
const approvalRef = approvalId === undefined ? undefined : { type: 'approval', id: approvalId };
|
|
273
|
-
if (approvalId === undefined || !isGovernanceChannel(channel) || !isTimestamp(requestedAt)
|
|
274
|
-
|| (outcome !== 'pending' && outcome !== 'approved' && outcome !== 'rejected' && outcome !== 'cancelled')
|
|
275
|
-
|| (decidedAt !== undefined && !isTimestamp(decidedAt))) {
|
|
276
|
-
collectionIssues.push(issue(approvalRef === undefined
|
|
277
|
-
? { source: 'approval', reasonCode: 'metadata_malformed', nextActionCode: 'repair_approval_record' }
|
|
278
|
-
: { source: 'approval', reasonCode: 'metadata_malformed', nextActionCode: 'repair_approval_record', sourceRef: approvalRef }));
|
|
279
|
-
continue;
|
|
280
|
-
}
|
|
281
|
-
const strongApprovalRef = { type: 'approval', id: approvalId };
|
|
282
|
-
const fact = {
|
|
283
|
-
schemaVersion: '1', family: 'approval', sourceRef: strongApprovalRef, principleId, artifactId,
|
|
284
|
-
approvalId, channel, outcome, lineageConfidence: 'strong', recordedAt: decidedAt ?? requestedAt,
|
|
285
|
-
};
|
|
286
|
-
if (decidedAt !== undefined)
|
|
287
|
-
fact.occurredAt = decidedAt;
|
|
288
|
-
approvals.push(fact);
|
|
289
|
-
sourceRefs.push(strongApprovalRef);
|
|
290
|
-
if (outcome === 'approved' || outcome === 'rejected') {
|
|
291
|
-
timelineEvents.push({
|
|
292
|
-
code: outcome, occurredAt: decidedAt ?? requestedAt, recordedAt: decidedAt ?? requestedAt,
|
|
293
|
-
summaryCode: `governance.timeline.${outcome}`, sourceRef: strongApprovalRef, lineageConfidence: 'strong',
|
|
294
|
-
});
|
|
295
|
-
}
|
|
257
|
+
if (task.status === 'failed' || task.status === 'needs_human_review') {
|
|
258
|
+
const code = task.status === 'failed' ? 'failed' : 'human_review';
|
|
259
|
+
timelineEvents.push({
|
|
260
|
+
code, occurredAt: task.updatedAt, recordedAt: task.updatedAt,
|
|
261
|
+
summaryCode: `governance.timeline.${code}`, sourceRef: fact.sourceRef, lineageConfidence: taskLineageConfidence,
|
|
262
|
+
});
|
|
296
263
|
}
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
264
|
+
}
|
|
265
|
+
tasks.sort((left, right) => (left.taskId ?? '').localeCompare(right.taskId ?? ''));
|
|
266
|
+
const strongTaskIds = new Set(tasks.filter(task => task.lineageConfidence === 'strong').map(task => task.taskId).filter((taskId) => taskId !== undefined));
|
|
267
|
+
for (const task of tasks) {
|
|
268
|
+
const { taskId } = task;
|
|
269
|
+
if (taskId === undefined || task.completionIntent?.status !== 'pending' || materializedRevisionSources.has(taskId))
|
|
270
|
+
continue;
|
|
271
|
+
derivedRelations.push({
|
|
272
|
+
schemaVersion: '1', family: 'derived_relation', sourceRef: task.sourceRef, principleId,
|
|
273
|
+
taskId, lineageConfidence: 'strong', recordedAt: task.recordedAt,
|
|
274
|
+
relation: 'revision_pending', evidenceRefs: [task.sourceRef],
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
for (const successor of [...validTasks.values()].sort((left, right) => left.taskId.localeCompare(right.taskId))) {
|
|
278
|
+
if (!strongTaskIds.has(successor.taskId))
|
|
279
|
+
continue;
|
|
280
|
+
for (const dependencyTaskId of [...successor.dependencyTaskIds].sort()) {
|
|
281
|
+
if (!strongTaskIds.has(dependencyTaskId))
|
|
313
282
|
continue;
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
};
|
|
321
|
-
if (deactivatedAt !== undefined)
|
|
322
|
-
fact.deactivatedAt = deactivatedAt;
|
|
323
|
-
activations.push(fact);
|
|
324
|
-
sourceRefs.push(strongActivationRef);
|
|
325
|
-
timelineEvents.push({ code: 'activated', occurredAt: activatedAt, recordedAt: activatedAt, summaryCode: 'governance.timeline.activated', sourceRef: strongActivationRef, lineageConfidence: 'strong' });
|
|
326
|
-
if (deactivatedAt !== undefined) {
|
|
327
|
-
timelineEvents.push({ code: 'deactivated', occurredAt: deactivatedAt, recordedAt: deactivatedAt, summaryCode: 'governance.timeline.deactivated', sourceRef: strongActivationRef, lineageConfidence: 'strong' });
|
|
328
|
-
}
|
|
283
|
+
derivedRelations.push({
|
|
284
|
+
schemaVersion: '1', family: 'derived_relation', sourceRef: { type: 'task', id: dependencyTaskId }, principleId,
|
|
285
|
+
taskId: dependencyTaskId, lineageConfidence: 'strong', recordedAt: successor.updatedAt,
|
|
286
|
+
relation: 'successor_present',
|
|
287
|
+
evidenceRefs: [{ type: 'task', id: dependencyTaskId }, { type: 'task', id: successor.taskId }],
|
|
288
|
+
});
|
|
329
289
|
}
|
|
330
|
-
timelineEvents.sort((left, right) => {
|
|
331
|
-
const timeOrder = (left.occurredAt ?? left.recordedAt).localeCompare(right.occurredAt ?? right.recordedAt);
|
|
332
|
-
if (timeOrder !== 0)
|
|
333
|
-
return timeOrder;
|
|
334
|
-
const typeOrder = left.sourceRef.type.localeCompare(right.sourceRef.type);
|
|
335
|
-
if (typeOrder !== 0)
|
|
336
|
-
return typeOrder;
|
|
337
|
-
const idOrder = left.sourceRef.id.localeCompare(right.sourceRef.id);
|
|
338
|
-
return idOrder !== 0 ? idOrder : left.code.localeCompare(right.code);
|
|
339
|
-
});
|
|
340
|
-
return GovernanceProjectionCollector.finish({
|
|
341
|
-
principleId, asOf, principle, collectionIssues, artifactIds,
|
|
342
|
-
taskIds: tasks.map(task => task.taskId).filter((taskId) => taskId !== undefined).sort(), tasks, revisionIdentities, sourceRefs,
|
|
343
|
-
runnerVerdicts, derivedRelations, approvals, activations, timelineEvents,
|
|
344
|
-
});
|
|
345
290
|
}
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
291
|
+
const approvals = [];
|
|
292
|
+
const activations = [];
|
|
293
|
+
for (const row of tables.approvalRows) {
|
|
294
|
+
if (!isRecord(row))
|
|
295
|
+
continue;
|
|
296
|
+
const artifactId = readOwnString(row, 'artifact_id');
|
|
297
|
+
if (artifactId === undefined || !strongArtifactIds.has(artifactId))
|
|
298
|
+
continue;
|
|
299
|
+
const approvalId = readOwnString(row, 'approval_id');
|
|
300
|
+
const channel = readOwnString(row, 'channel');
|
|
301
|
+
const outcome = readOwnString(row, 'status');
|
|
302
|
+
const requestedAt = readOwnString(row, 'requested_at');
|
|
303
|
+
const decidedAt = readOwnString(row, 'decided_at');
|
|
304
|
+
const approvalRef = approvalId === undefined ? undefined : { type: 'approval', id: approvalId };
|
|
305
|
+
if (approvalId === undefined || !isGovernanceChannel(channel) || !isTimestamp(requestedAt)
|
|
306
|
+
|| (outcome !== 'pending' && outcome !== 'approved' && outcome !== 'rejected' && outcome !== 'cancelled')
|
|
307
|
+
|| (decidedAt !== undefined && !isTimestamp(decidedAt))) {
|
|
308
|
+
collectionIssues.push(issue(approvalRef === undefined
|
|
309
|
+
? { source: 'approval', reasonCode: 'metadata_malformed', nextActionCode: 'repair_approval_record' }
|
|
310
|
+
: { source: 'approval', reasonCode: 'metadata_malformed', nextActionCode: 'repair_approval_record', sourceRef: approvalRef }));
|
|
311
|
+
continue;
|
|
312
|
+
}
|
|
313
|
+
const strongApprovalRef = { type: 'approval', id: approvalId };
|
|
314
|
+
const fact = {
|
|
315
|
+
schemaVersion: '1', family: 'approval', sourceRef: strongApprovalRef, principleId, artifactId,
|
|
316
|
+
approvalId, channel, outcome, lineageConfidence: 'strong', recordedAt: decidedAt ?? requestedAt,
|
|
317
|
+
};
|
|
318
|
+
if (decidedAt !== undefined)
|
|
319
|
+
fact.occurredAt = decidedAt;
|
|
320
|
+
approvals.push(fact);
|
|
321
|
+
sourceRefs.push(strongApprovalRef);
|
|
322
|
+
if (outcome === 'approved' || outcome === 'rejected') {
|
|
323
|
+
timelineEvents.push({
|
|
324
|
+
code: outcome, occurredAt: decidedAt ?? requestedAt, recordedAt: decidedAt ?? requestedAt,
|
|
325
|
+
summaryCode: `governance.timeline.${outcome}`, sourceRef: strongApprovalRef, lineageConfidence: 'strong',
|
|
326
|
+
});
|
|
327
|
+
}
|
|
350
328
|
}
|
|
351
|
-
|
|
352
|
-
|
|
329
|
+
for (const row of tables.activationRows) {
|
|
330
|
+
if (!isRecord(row))
|
|
331
|
+
continue;
|
|
332
|
+
const artifactId = readOwnString(row, 'artifact_id');
|
|
333
|
+
if (artifactId === undefined || !strongArtifactIds.has(artifactId))
|
|
334
|
+
continue;
|
|
335
|
+
const activationId = readOwnString(row, 'activation_id');
|
|
336
|
+
const channel = readOwnString(row, 'channel');
|
|
337
|
+
const activatedAt = readOwnString(row, 'activated_at');
|
|
338
|
+
const deactivatedAt = readOwnString(row, 'deactivated_at');
|
|
339
|
+
const activationRef = activationId === undefined ? undefined : { type: 'activation', id: activationId };
|
|
340
|
+
if (activationId === undefined || !isGovernanceChannel(channel) || !isTimestamp(activatedAt)
|
|
341
|
+
|| (deactivatedAt !== undefined && !isTimestamp(deactivatedAt))) {
|
|
342
|
+
collectionIssues.push(issue(activationRef === undefined
|
|
343
|
+
? { source: 'activation', reasonCode: 'metadata_malformed', nextActionCode: 'repair_activation_record' }
|
|
344
|
+
: { source: 'activation', reasonCode: 'metadata_malformed', nextActionCode: 'repair_activation_record', sourceRef: activationRef }));
|
|
345
|
+
continue;
|
|
346
|
+
}
|
|
347
|
+
const strongActivationRef = { type: 'activation', id: activationId };
|
|
348
|
+
const fact = {
|
|
349
|
+
schemaVersion: '1', family: 'activation', sourceRef: strongActivationRef, principleId, artifactId,
|
|
350
|
+
activationId, channel, outcome: deactivatedAt === undefined ? 'active' : 'deactivated',
|
|
351
|
+
activatedAt, lineageConfidence: 'strong', recordedAt: deactivatedAt ?? activatedAt,
|
|
352
|
+
};
|
|
353
|
+
if (deactivatedAt !== undefined)
|
|
354
|
+
fact.deactivatedAt = deactivatedAt;
|
|
355
|
+
activations.push(fact);
|
|
356
|
+
sourceRefs.push(strongActivationRef);
|
|
357
|
+
timelineEvents.push({ code: 'activated', occurredAt: activatedAt, recordedAt: activatedAt, summaryCode: 'governance.timeline.activated', sourceRef: strongActivationRef, lineageConfidence: 'strong' });
|
|
358
|
+
if (deactivatedAt !== undefined) {
|
|
359
|
+
timelineEvents.push({ code: 'deactivated', occurredAt: deactivatedAt, recordedAt: deactivatedAt, summaryCode: 'governance.timeline.deactivated', sourceRef: strongActivationRef, lineageConfidence: 'strong' });
|
|
360
|
+
}
|
|
353
361
|
}
|
|
362
|
+
timelineEvents.sort((left, right) => {
|
|
363
|
+
const timeOrder = (left.occurredAt ?? left.recordedAt).localeCompare(right.occurredAt ?? right.recordedAt);
|
|
364
|
+
if (timeOrder !== 0)
|
|
365
|
+
return timeOrder;
|
|
366
|
+
const typeOrder = left.sourceRef.type.localeCompare(right.sourceRef.type);
|
|
367
|
+
if (typeOrder !== 0)
|
|
368
|
+
return typeOrder;
|
|
369
|
+
const idOrder = left.sourceRef.id.localeCompare(right.sourceRef.id);
|
|
370
|
+
return idOrder !== 0 ? idOrder : left.code.localeCompare(right.code);
|
|
371
|
+
});
|
|
372
|
+
return GovernanceProjectionCollector.finish({
|
|
373
|
+
principleId, asOf, principle, collectionIssues, artifactIds,
|
|
374
|
+
taskIds: tasks.map(task => task.taskId).filter((taskId) => taskId !== undefined).sort(), tasks, revisionIdentities, sourceRefs,
|
|
375
|
+
runnerVerdicts, derivedRelations, approvals, activations, timelineEvents,
|
|
376
|
+
});
|
|
354
377
|
}
|
|
355
378
|
readPrinciple(principleId, issues) {
|
|
356
|
-
|
|
357
|
-
|
|
379
|
+
return GovernanceProjectionCollector.principleFactFromLedger(GovernanceProjectionCollector.parsePrincipleLedgerFile(this.workspaceDir), principleId, issues);
|
|
380
|
+
}
|
|
381
|
+
/** Reads and JSON-parses the principle ledger file (shared by single + batch collectors). */
|
|
382
|
+
static parsePrincipleLedgerFile(workspaceDir) {
|
|
383
|
+
const ledgerPath = path.join(workspaceDir, '.state', 'principle_training_state.json');
|
|
358
384
|
try {
|
|
359
|
-
|
|
385
|
+
return JSON.parse(fs.readFileSync(ledgerPath, 'utf8'));
|
|
360
386
|
}
|
|
361
387
|
catch {
|
|
362
388
|
throw new GovernanceProjectionCollectionError('principle_not_found', 'check_principle_ledger');
|
|
363
389
|
}
|
|
390
|
+
}
|
|
391
|
+
/** Extracts the principles record from a parsed ledger; null when the tree is absent/malformed. */
|
|
392
|
+
static principleTreeFromLedger(parsed) {
|
|
364
393
|
if (!isRecord(parsed))
|
|
365
|
-
|
|
394
|
+
return null;
|
|
366
395
|
const tree = Object.hasOwn(parsed, '_tree') ? parsed._tree : parsed.tree;
|
|
367
|
-
if (!isRecord(tree) || !isRecord(tree.principles)
|
|
396
|
+
if (!isRecord(tree) || !isRecord(tree.principles))
|
|
397
|
+
return null;
|
|
398
|
+
return tree.principles;
|
|
399
|
+
}
|
|
400
|
+
/** Validates one principle entry from an already-parsed ledger (shared by single + batch collectors). */
|
|
401
|
+
static principleFactFromLedger(parsed, principleId, issues) {
|
|
402
|
+
if (!isRecord(parsed))
|
|
403
|
+
throw new GovernanceProjectionCollectionError('principle_not_found', 'check_principle_ledger');
|
|
404
|
+
const principles = GovernanceProjectionCollector.principleTreeFromLedger(parsed);
|
|
405
|
+
if (principles === null || !Object.hasOwn(principles, principleId)) {
|
|
368
406
|
throw new GovernanceProjectionCollectionError('principle_not_found', 'check_principle_id');
|
|
369
407
|
}
|
|
370
|
-
const raw =
|
|
408
|
+
const raw = principles[principleId];
|
|
371
409
|
if (!isRecord(raw))
|
|
372
410
|
throw new GovernanceProjectionCollectionError('principle_not_found', 'repair_principle_ledger');
|
|
373
411
|
const state = readOwnString(raw, 'status');
|
|
@@ -428,7 +466,7 @@ export class GovernanceProjectionCollector {
|
|
|
428
466
|
}
|
|
429
467
|
if (taskKind !== 'dreamer' && taskKind !== 'philosopher' && taskKind !== 'scribe' && taskKind !== 'artificer' && taskKind !== 'evaluator' && taskKind !== 'rollout_reviewer')
|
|
430
468
|
return null;
|
|
431
|
-
if (status
|
|
469
|
+
if (!isPDTaskStatus(status))
|
|
432
470
|
return null;
|
|
433
471
|
const result = { taskId, taskKind, status, createdAt, updatedAt, attemptCount, maxAttempts, channel, dependencyTaskIds: metadata.dependencyTaskIds };
|
|
434
472
|
const leaseExpiresAt = readOwnString(row, 'lease_expires_at');
|