create-principles-disciple 1.82.0 → 1.83.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/console/dist/server/config/pd-config-store.d.ts +135 -0
- package/console/dist/server/config/pd-config-store.js +660 -0
- package/console/dist/server/index.js +40 -389
- package/console/dist/server/models/ActivationsConsoleModel.d.ts +33 -0
- package/console/dist/server/models/ActivationsConsoleModel.js +112 -0
- package/console/dist/server/models/ApprovalsConsoleModel.d.ts +5 -0
- package/console/dist/server/models/ApprovalsConsoleModel.js +14 -0
- package/console/dist/server/models/ApprovalsGroupedConsoleModel.d.ts +25 -0
- package/console/dist/server/models/ApprovalsGroupedConsoleModel.js +126 -0
- package/console/dist/server/models/ConsoleLifecycleDatasource.d.ts +13 -0
- package/console/dist/server/models/ConsoleLifecycleDatasource.js +73 -0
- package/console/dist/server/models/EvidenceChainConsoleModel.d.ts +58 -0
- package/console/dist/server/models/EvidenceChainConsoleModel.js +493 -0
- package/console/dist/server/models/GovernanceConsoleModel.d.ts +74 -0
- package/console/dist/server/models/GovernanceConsoleModel.js +246 -0
- package/console/dist/server/models/HealthCheckModel.d.ts +0 -4
- package/console/dist/server/models/HealthCheckModel.js +49 -80
- package/console/dist/server/models/LifecycleConsoleModel.d.ts +19 -0
- package/console/dist/server/models/LifecycleConsoleModel.js +55 -0
- package/console/dist/server/models/PrincipleClassifier.d.ts +41 -0
- package/console/dist/server/models/PrincipleClassifier.js +100 -0
- package/console/dist/server/models/PrinciplesConsoleModel.d.ts +12 -1
- package/console/dist/server/models/PrinciplesConsoleModel.js +53 -6
- package/console/dist/server/models/WorkspaceService.d.ts +2 -1
- package/console/dist/server/models/WorkspaceService.js +51 -23
- package/console/dist/server/routes/activations.d.ts +3 -0
- package/console/dist/server/routes/activations.js +111 -0
- package/console/dist/server/routes/approvals-grouped.d.ts +3 -0
- package/console/dist/server/routes/approvals-grouped.js +32 -0
- package/console/dist/server/routes/approvals.js +28 -4
- package/console/dist/server/routes/config.d.ts +27 -0
- package/console/dist/server/routes/config.js +213 -0
- package/console/dist/server/routes/evidence-chain.d.ts +9 -0
- package/console/dist/server/routes/evidence-chain.js +32 -0
- package/console/dist/server/routes/governance.d.ts +3 -0
- package/console/dist/server/routes/governance.js +32 -0
- package/console/dist/server/routes/{evolution.d.ts → lifecycle.d.ts} +2 -2
- package/console/dist/server/routes/lifecycle.js +48 -0
- package/console/dist/server/routes/principles.js +74 -1
- package/console/dist/server/routes/workspaces.js +8 -1
- package/console/dist/server/utils/response.d.ts +1 -1
- package/console/dist/server/utils/response.js +6 -2
- package/console/dist/types.d.ts +1 -0
- package/console/dist/ui/App.js +116 -40
- package/console/dist/ui/api.d.ts +88 -501
- package/console/dist/ui/api.js +139 -162
- package/console/dist/ui/components/approval-card.js +1 -1
- package/console/dist/ui/components/approval-detail-dialog.js +1 -1
- package/console/dist/ui/components/auth/login-form.d.ts +3 -0
- package/console/dist/ui/components/auth/login-form.js +36 -0
- package/console/dist/ui/components/auth/splash-screen.d.ts +8 -0
- package/console/dist/ui/components/auth/splash-screen.js +22 -0
- package/console/dist/ui/components/layout/app-sidebar.d.ts +1 -0
- package/console/dist/ui/components/layout/app-sidebar.js +56 -0
- package/console/dist/ui/components/layout/page-shell.d.ts +11 -0
- package/console/dist/ui/components/layout/page-shell.js +10 -0
- package/console/dist/ui/components/layout/section-title.d.ts +10 -0
- package/console/dist/ui/components/layout/section-title.js +9 -0
- package/console/dist/ui/components/theme-provider.d.ts +1 -1
- package/console/dist/ui/components/theme-provider.js +13 -8
- package/console/dist/ui/components/theme-toggle.js +2 -21
- package/console/dist/ui/components/ui/badge.d.ts +1 -1
- package/console/dist/ui/components/ui/badge.js +7 -5
- package/console/dist/ui/components/ui/button.d.ts +2 -2
- package/console/dist/ui/components/ui/button.js +12 -11
- package/console/dist/ui/components/ui/card.js +6 -6
- package/console/dist/ui/components/ui/sheet.d.ts +1 -1
- package/console/dist/ui/i18n/en.json +401 -343
- package/console/dist/ui/i18n/index.js +2 -2
- package/console/dist/ui/i18n/zh-CN.json +406 -348
- package/console/dist/ui/main.d.ts +1 -1
- package/console/dist/ui/main.js +1 -0
- package/console/dist/ui/pages/activation/ActivationPage.d.ts +1 -0
- package/console/dist/ui/pages/activation/ActivationPage.js +150 -0
- package/console/dist/ui/pages/activation/ActivationValidators.d.ts +20 -0
- package/console/dist/ui/pages/activation/ActivationValidators.js +156 -0
- package/console/dist/ui/pages/control-center/ControlCenterPage.d.ts +1 -0
- package/console/dist/ui/pages/control-center/ControlCenterPage.js +447 -0
- package/console/dist/ui/pages/debt/DebtPage.d.ts +1 -0
- package/console/dist/ui/pages/debt/DebtPage.js +5 -0
- package/console/dist/ui/pages/design-system/DesignSystemPage.d.ts +1 -0
- package/console/dist/ui/pages/design-system/DesignSystemPage.js +30 -0
- package/console/dist/ui/pages/focus/FocusPage.d.ts +1 -0
- package/console/dist/ui/pages/focus/FocusPage.js +265 -0
- package/console/dist/ui/pages/pain/PainEvidenceValidators.d.ts +59 -0
- package/console/dist/ui/pages/pain/PainEvidenceValidators.js +125 -0
- package/console/dist/ui/pages/pain/PainPage.js +136 -0
- package/console/dist/ui/pages/principles/PrincipleDetailPage.js +264 -0
- package/console/dist/ui/pages/principles/PrinciplesPage.js +244 -0
- package/console/dist/ui/pages/report-problem/ReportProblemPage.js +245 -0
- package/console/dist/ui/pages/settings/SettingsPage.d.ts +4 -0
- package/console/dist/ui/pages/settings/SettingsPage.js +202 -0
- package/console/dist/ui/pages/settings/UpdatePage.d.ts +5 -0
- package/console/dist/ui/pages/settings/UpdatePage.js +168 -0
- package/console/dist/ui/utils/control-center-helpers.d.ts +58 -0
- package/console/dist/ui/utils/control-center-helpers.js +152 -0
- package/console/dist/ui/utils/validators.d.ts +350 -0
- package/console/dist/ui/utils/validators.js +995 -0
- package/console/dist/web/assets/app.css +672 -902
- package/console/dist/web/assets/app.js +6404 -15347
- package/console/dist/web/assets/jetbrains-mono-cyrillic-400-normal-C5JECUCT.woff2 +0 -0
- package/console/dist/web/assets/jetbrains-mono-cyrillic-400-normal-FGCZYWMY.woff +0 -0
- package/console/dist/web/assets/jetbrains-mono-cyrillic-ext-400-normal-C7IFWGF6.woff2 +0 -0
- package/console/dist/web/assets/jetbrains-mono-cyrillic-ext-400-normal-PWXUA557.woff +0 -0
- package/console/dist/web/assets/jetbrains-mono-greek-400-normal-JJNQZMPZ.woff +0 -0
- package/console/dist/web/assets/jetbrains-mono-greek-400-normal-O7JTTR3P.woff2 +0 -0
- package/console/dist/web/assets/jetbrains-mono-latin-400-normal-3OOWLGQ2.woff2 +0 -0
- package/console/dist/web/assets/jetbrains-mono-latin-400-normal-WDD34GPP.woff +0 -0
- package/console/dist/web/assets/jetbrains-mono-latin-ext-400-normal-55RNMRQS.woff +0 -0
- package/console/dist/web/assets/jetbrains-mono-latin-ext-400-normal-JVR3IR4Z.woff2 +0 -0
- package/console/dist/web/assets/jetbrains-mono-vietnamese-400-normal-7ULXAK72.woff +0 -0
- package/console/dist/web/assets/jetbrains-mono-vietnamese-400-normal-KU7YLUPA.woff2 +0 -0
- package/console/package.json +2 -1
- package/core/dist/runtime-v2/__tests__/admission-gate.test.js +49 -0
- package/core/dist/runtime-v2/__tests__/admission-gate.test.js.map +1 -1
- package/core/dist/runtime-v2/__tests__/architecture-regression.test.js +16 -1
- package/core/dist/runtime-v2/__tests__/architecture-regression.test.js.map +1 -1
- package/core/dist/runtime-v2/__tests__/evidence-sanitizer.test.d.ts +21 -0
- package/core/dist/runtime-v2/__tests__/evidence-sanitizer.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/__tests__/evidence-sanitizer.test.js +354 -0
- package/core/dist/runtime-v2/__tests__/evidence-sanitizer.test.js.map +1 -0
- package/core/dist/runtime-v2/__tests__/language-directive.test.d.ts +12 -0
- package/core/dist/runtime-v2/__tests__/language-directive.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/__tests__/language-directive.test.js +162 -0
- package/core/dist/runtime-v2/__tests__/language-directive.test.js.map +1 -0
- package/core/dist/runtime-v2/__tests__/pain-signal-observability.test.js +23 -1
- package/core/dist/runtime-v2/__tests__/pain-signal-observability.test.js.map +1 -1
- package/core/dist/runtime-v2/__tests__/pain-to-principle-service.test.js +48 -3
- package/core/dist/runtime-v2/__tests__/pain-to-principle-service.test.js.map +1 -1
- package/core/dist/runtime-v2/__tests__/proven-channel-baseline.test.js +13 -1
- package/core/dist/runtime-v2/__tests__/proven-channel-baseline.test.js.map +1 -1
- package/core/dist/runtime-v2/__tests__/resolve-runtime-config-from-pd-config.test.d.ts +12 -0
- package/core/dist/runtime-v2/__tests__/resolve-runtime-config-from-pd-config.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/__tests__/resolve-runtime-config-from-pd-config.test.js +194 -0
- package/core/dist/runtime-v2/__tests__/resolve-runtime-config-from-pd-config.test.js.map +1 -0
- package/core/dist/runtime-v2/__tests__/runtime-config-boundary.test.js +5 -3
- package/core/dist/runtime-v2/__tests__/runtime-config-boundary.test.js.map +1 -1
- package/core/dist/runtime-v2/activation/__tests__/activation-dispatcher.test.js +1 -0
- package/core/dist/runtime-v2/activation/__tests__/activation-dispatcher.test.js.map +1 -1
- package/core/dist/runtime-v2/activation/__tests__/approval-queue.test.js +54 -0
- package/core/dist/runtime-v2/activation/__tests__/approval-queue.test.js.map +1 -1
- package/core/dist/runtime-v2/activation/__tests__/memory-activation-state-store.test.js +15 -2
- package/core/dist/runtime-v2/activation/__tests__/memory-activation-state-store.test.js.map +1 -1
- package/core/dist/runtime-v2/activation/__tests__/prompt-activation-reader-contract.test.js +10 -0
- package/core/dist/runtime-v2/activation/__tests__/prompt-activation-reader-contract.test.js.map +1 -1
- package/core/dist/runtime-v2/activation/__tests__/sqlite-activation-state-store.test.js +17 -2
- package/core/dist/runtime-v2/activation/__tests__/sqlite-activation-state-store.test.js.map +1 -1
- package/core/dist/runtime-v2/activation/__tests__/sqlite-approval-store.test.js +36 -0
- package/core/dist/runtime-v2/activation/__tests__/sqlite-approval-store.test.js.map +1 -1
- package/core/dist/runtime-v2/activation/activation-dispatcher.d.ts.map +1 -1
- package/core/dist/runtime-v2/activation/activation-dispatcher.js +1 -1
- package/core/dist/runtime-v2/activation/activation-dispatcher.js.map +1 -1
- package/core/dist/runtime-v2/activation/activation-types.d.ts +10 -0
- package/core/dist/runtime-v2/activation/activation-types.d.ts.map +1 -1
- package/core/dist/runtime-v2/activation/activation-types.js.map +1 -1
- package/core/dist/runtime-v2/activation/approval-queue.d.ts +6 -0
- package/core/dist/runtime-v2/activation/approval-queue.d.ts.map +1 -1
- package/core/dist/runtime-v2/activation/approval-queue.js +3 -0
- package/core/dist/runtime-v2/activation/approval-queue.js.map +1 -1
- package/core/dist/runtime-v2/activation/memory-activation-state-store.d.ts +2 -0
- package/core/dist/runtime-v2/activation/memory-activation-state-store.d.ts.map +1 -1
- package/core/dist/runtime-v2/activation/memory-activation-state-store.js +17 -1
- package/core/dist/runtime-v2/activation/memory-activation-state-store.js.map +1 -1
- package/core/dist/runtime-v2/activation/memory-approval-store.d.ts +6 -0
- package/core/dist/runtime-v2/activation/memory-approval-store.d.ts.map +1 -1
- package/core/dist/runtime-v2/activation/memory-approval-store.js +16 -0
- package/core/dist/runtime-v2/activation/memory-approval-store.js.map +1 -1
- package/core/dist/runtime-v2/activation/prompt-activation-reader-contract.js +1 -1
- package/core/dist/runtime-v2/activation/prompt-activation-reader-contract.js.map +1 -1
- package/core/dist/runtime-v2/activation/sqlite-activation-state-store.d.ts +2 -0
- package/core/dist/runtime-v2/activation/sqlite-activation-state-store.d.ts.map +1 -1
- package/core/dist/runtime-v2/activation/sqlite-activation-state-store.js +34 -6
- package/core/dist/runtime-v2/activation/sqlite-activation-state-store.js.map +1 -1
- package/core/dist/runtime-v2/activation/sqlite-approval-store.d.ts +6 -0
- package/core/dist/runtime-v2/activation/sqlite-approval-store.d.ts.map +1 -1
- package/core/dist/runtime-v2/activation/sqlite-approval-store.js +10 -0
- package/core/dist/runtime-v2/activation/sqlite-approval-store.js.map +1 -1
- package/core/dist/runtime-v2/adapter/__tests__/json-extractor.test.js +51 -1
- package/core/dist/runtime-v2/adapter/__tests__/json-extractor.test.js.map +1 -1
- package/core/dist/runtime-v2/adapter/__tests__/openclaw-cli-runtime-adapter.test.js +145 -0
- package/core/dist/runtime-v2/adapter/__tests__/openclaw-cli-runtime-adapter.test.js.map +1 -1
- package/core/dist/runtime-v2/adapter/json-extractor.d.ts +13 -0
- package/core/dist/runtime-v2/adapter/json-extractor.d.ts.map +1 -1
- package/core/dist/runtime-v2/adapter/json-extractor.js +103 -0
- package/core/dist/runtime-v2/adapter/json-extractor.js.map +1 -1
- package/core/dist/runtime-v2/adapter/openclaw-cli-runtime-adapter.d.ts +4 -2
- package/core/dist/runtime-v2/adapter/openclaw-cli-runtime-adapter.d.ts.map +1 -1
- package/core/dist/runtime-v2/adapter/openclaw-cli-runtime-adapter.js +57 -5
- package/core/dist/runtime-v2/adapter/openclaw-cli-runtime-adapter.js.map +1 -1
- package/core/dist/runtime-v2/config/__tests__/pd-config-agent-binding.test.d.ts +18 -0
- package/core/dist/runtime-v2/config/__tests__/pd-config-agent-binding.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/config/__tests__/pd-config-agent-binding.test.js +633 -0
- package/core/dist/runtime-v2/config/__tests__/pd-config-agent-binding.test.js.map +1 -0
- package/core/dist/runtime-v2/config/__tests__/pd-config-validation-edge-cases.test.js +92 -0
- package/core/dist/runtime-v2/config/__tests__/pd-config-validation-edge-cases.test.js.map +1 -1
- package/core/dist/runtime-v2/config/index.d.ts +3 -1
- package/core/dist/runtime-v2/config/index.d.ts.map +1 -1
- package/core/dist/runtime-v2/config/index.js +1 -0
- package/core/dist/runtime-v2/config/index.js.map +1 -1
- package/core/dist/runtime-v2/config/pd-config-agent-binding.d.ts +93 -0
- package/core/dist/runtime-v2/config/pd-config-agent-binding.d.ts.map +1 -0
- package/core/dist/runtime-v2/config/pd-config-agent-binding.js +184 -0
- package/core/dist/runtime-v2/config/pd-config-agent-binding.js.map +1 -0
- package/core/dist/runtime-v2/config/pd-config-defaults.d.ts.map +1 -1
- package/core/dist/runtime-v2/config/pd-config-defaults.js +2 -0
- package/core/dist/runtime-v2/config/pd-config-defaults.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 +3 -0
- package/core/dist/runtime-v2/config/pd-config-effective.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.map +1 -1
- package/core/dist/runtime-v2/diagnostician/__tests__/diagnostician-prompt-language.test.d.ts +13 -0
- package/core/dist/runtime-v2/diagnostician/__tests__/diagnostician-prompt-language.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/diagnostician/__tests__/diagnostician-prompt-language.test.js +97 -0
- package/core/dist/runtime-v2/diagnostician/__tests__/diagnostician-prompt-language.test.js.map +1 -0
- package/core/dist/runtime-v2/diagnostician-prompt-builder.d.ts +3 -2
- package/core/dist/runtime-v2/diagnostician-prompt-builder.d.ts.map +1 -1
- package/core/dist/runtime-v2/diagnostician-prompt-builder.js +6 -4
- package/core/dist/runtime-v2/diagnostician-prompt-builder.js.map +1 -1
- package/core/dist/runtime-v2/evidence-sanitizer.d.ts +57 -0
- package/core/dist/runtime-v2/evidence-sanitizer.d.ts.map +1 -0
- package/core/dist/runtime-v2/evidence-sanitizer.js +213 -0
- package/core/dist/runtime-v2/evidence-sanitizer.js.map +1 -0
- package/core/dist/runtime-v2/evidence-triage/__tests__/admission-events.test.d.ts +7 -0
- package/core/dist/runtime-v2/evidence-triage/__tests__/admission-events.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/evidence-triage/__tests__/admission-events.test.js +170 -0
- package/core/dist/runtime-v2/evidence-triage/__tests__/admission-events.test.js.map +1 -0
- package/core/dist/runtime-v2/evidence-triage/__tests__/source-descriptors.test.d.ts +18 -0
- package/core/dist/runtime-v2/evidence-triage/__tests__/source-descriptors.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/evidence-triage/__tests__/source-descriptors.test.js +277 -0
- package/core/dist/runtime-v2/evidence-triage/__tests__/source-descriptors.test.js.map +1 -0
- package/core/dist/runtime-v2/evidence-triage/__tests__/triage-policy.test.d.ts +13 -0
- package/core/dist/runtime-v2/evidence-triage/__tests__/triage-policy.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/evidence-triage/__tests__/triage-policy.test.js +264 -0
- package/core/dist/runtime-v2/evidence-triage/__tests__/triage-policy.test.js.map +1 -0
- package/core/dist/runtime-v2/evidence-triage/__tests__/trigger-controller.test.d.ts +16 -0
- package/core/dist/runtime-v2/evidence-triage/__tests__/trigger-controller.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/evidence-triage/__tests__/trigger-controller.test.js +316 -0
- package/core/dist/runtime-v2/evidence-triage/__tests__/trigger-controller.test.js.map +1 -0
- package/core/dist/runtime-v2/evidence-triage/admission-events.d.ts +126 -0
- package/core/dist/runtime-v2/evidence-triage/admission-events.d.ts.map +1 -0
- package/core/dist/runtime-v2/evidence-triage/admission-events.js +159 -0
- package/core/dist/runtime-v2/evidence-triage/admission-events.js.map +1 -0
- package/core/dist/runtime-v2/evidence-triage/index.d.ts +16 -0
- package/core/dist/runtime-v2/evidence-triage/index.d.ts.map +1 -0
- package/core/dist/runtime-v2/evidence-triage/index.js +13 -0
- package/core/dist/runtime-v2/evidence-triage/index.js.map +1 -0
- package/core/dist/runtime-v2/evidence-triage/source-descriptors.d.ts +48 -0
- package/core/dist/runtime-v2/evidence-triage/source-descriptors.d.ts.map +1 -0
- package/core/dist/runtime-v2/evidence-triage/source-descriptors.js +131 -0
- package/core/dist/runtime-v2/evidence-triage/source-descriptors.js.map +1 -0
- package/core/dist/runtime-v2/evidence-triage/triage-policy.d.ts +32 -0
- package/core/dist/runtime-v2/evidence-triage/triage-policy.d.ts.map +1 -0
- package/core/dist/runtime-v2/evidence-triage/triage-policy.js +95 -0
- package/core/dist/runtime-v2/evidence-triage/triage-policy.js.map +1 -0
- package/core/dist/runtime-v2/evidence-triage/trigger-controller.d.ts +116 -0
- package/core/dist/runtime-v2/evidence-triage/trigger-controller.d.ts.map +1 -0
- package/core/dist/runtime-v2/evidence-triage/trigger-controller.js +218 -0
- package/core/dist/runtime-v2/evidence-triage/trigger-controller.js.map +1 -0
- package/core/dist/runtime-v2/evidence-triage/types.d.ts +65 -0
- package/core/dist/runtime-v2/evidence-triage/types.d.ts.map +1 -0
- package/core/dist/runtime-v2/evidence-triage/types.js +38 -0
- package/core/dist/runtime-v2/evidence-triage/types.js.map +1 -0
- package/core/dist/runtime-v2/feature-flags/__tests__/feature-flag-contract.test.js +10 -0
- package/core/dist/runtime-v2/feature-flags/__tests__/feature-flag-contract.test.js.map +1 -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 +1 -0
- package/core/dist/runtime-v2/feature-flags/feature-flag-contract.js.map +1 -1
- package/core/dist/runtime-v2/index.d.ts +8 -1
- package/core/dist/runtime-v2/index.d.ts.map +1 -1
- package/core/dist/runtime-v2/index.js +7 -1
- package/core/dist/runtime-v2/index.js.map +1 -1
- package/core/dist/runtime-v2/internalization/__tests__/scribe-prompt-language.test.d.ts +12 -0
- package/core/dist/runtime-v2/internalization/__tests__/scribe-prompt-language.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/internalization/__tests__/scribe-prompt-language.test.js +83 -0
- package/core/dist/runtime-v2/internalization/__tests__/scribe-prompt-language.test.js.map +1 -0
- package/core/dist/runtime-v2/internalization/scribe-prompt-builder.d.ts +10 -0
- package/core/dist/runtime-v2/internalization/scribe-prompt-builder.d.ts.map +1 -1
- package/core/dist/runtime-v2/internalization/scribe-prompt-builder.js +13 -1
- package/core/dist/runtime-v2/internalization/scribe-prompt-builder.js.map +1 -1
- package/core/dist/runtime-v2/internalization/scribe-runner.d.ts +3 -0
- package/core/dist/runtime-v2/internalization/scribe-runner.d.ts.map +1 -1
- package/core/dist/runtime-v2/internalization/scribe-runner.js +2 -0
- package/core/dist/runtime-v2/internalization/scribe-runner.js.map +1 -1
- package/core/dist/runtime-v2/internalization-chain-integrity-read-model.js +1 -1
- package/core/dist/runtime-v2/internalization-chain-integrity-read-model.js.map +1 -1
- package/core/dist/runtime-v2/language-directive.d.ts +80 -0
- package/core/dist/runtime-v2/language-directive.d.ts.map +1 -0
- package/core/dist/runtime-v2/language-directive.js +108 -0
- package/core/dist/runtime-v2/language-directive.js.map +1 -0
- package/core/dist/runtime-v2/pain-signal-observability.d.ts.map +1 -1
- package/core/dist/runtime-v2/pain-signal-observability.js +24 -11
- package/core/dist/runtime-v2/pain-signal-observability.js.map +1 -1
- package/core/dist/runtime-v2/pain-signal-runtime-factory.d.ts +16 -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 +97 -6
- package/core/dist/runtime-v2/pain-signal-runtime-factory.js.map +1 -1
- package/core/dist/runtime-v2/pain-to-principle-service.d.ts +7 -0
- package/core/dist/runtime-v2/pain-to-principle-service.d.ts.map +1 -1
- package/core/dist/runtime-v2/pain-to-principle-service.js +2 -0
- package/core/dist/runtime-v2/pain-to-principle-service.js.map +1 -1
- package/core/dist/runtime-v2/proven-channel-baseline.d.ts.map +1 -1
- package/core/dist/runtime-v2/proven-channel-baseline.js +14 -0
- package/core/dist/runtime-v2/proven-channel-baseline.js.map +1 -1
- package/core/dist/runtime-v2/runner/__tests__/diagnostician-runner.test.js +40 -0
- package/core/dist/runtime-v2/runner/__tests__/diagnostician-runner.test.js.map +1 -1
- package/core/dist/runtime-v2/runner/base-peer-runner.d.ts.map +1 -1
- package/core/dist/runtime-v2/runner/base-peer-runner.js +1 -0
- package/core/dist/runtime-v2/runner/base-peer-runner.js.map +1 -1
- package/core/dist/runtime-v2/runner/diagnostician-runner-options.d.ts +10 -0
- package/core/dist/runtime-v2/runner/diagnostician-runner-options.d.ts.map +1 -1
- package/core/dist/runtime-v2/runner/diagnostician-runner-options.js +1 -0
- package/core/dist/runtime-v2/runner/diagnostician-runner-options.js.map +1 -1
- package/core/dist/runtime-v2/runner/diagnostician-runner.d.ts.map +1 -1
- package/core/dist/runtime-v2/runner/diagnostician-runner.js +28 -4
- package/core/dist/runtime-v2/runner/diagnostician-runner.js.map +1 -1
- package/core/dist/runtime-v2/runner/peer-runner-types.d.ts +9 -0
- package/core/dist/runtime-v2/runner/peer-runner-types.d.ts.map +1 -1
- package/core/dist/runtime-v2/store/runtime-state-manager.d.ts.map +1 -1
- package/core/dist/runtime-v2/store/runtime-state-manager.integration.test.js +34 -1
- package/core/dist/runtime-v2/store/runtime-state-manager.integration.test.js.map +1 -1
- package/core/dist/runtime-v2/store/runtime-state-manager.js +1 -0
- package/core/dist/runtime-v2/store/runtime-state-manager.js.map +1 -1
- package/core/dist/runtime-v2/store/sqlite-connection.d.ts.map +1 -1
- package/core/dist/runtime-v2/store/sqlite-connection.js +9 -1
- package/core/dist/runtime-v2/store/sqlite-connection.js.map +1 -1
- package/core/dist/runtime-v2/store/task/sqlite-task-store.js +1 -1
- package/core/dist/runtime-v2/store/task/sqlite-task-store.js.map +1 -1
- package/core/dist/runtime-v2/task-status.d.ts +4 -4
- package/core/dist/runtime-v2/task-status.d.ts.map +1 -1
- package/core/dist/runtime-v2/task-status.js +2 -2
- package/core/dist/runtime-v2/task-status.js.map +1 -1
- package/core/package.json +1 -1
- package/package.json +2 -2
- package/pd-cli/dist/commands/console.d.ts +2 -0
- package/pd-cli/dist/commands/console.d.ts.map +1 -1
- package/pd-cli/dist/commands/console.js +6 -1
- package/pd-cli/dist/commands/console.js.map +1 -1
- package/pd-cli/dist/commands/diagnose.d.ts.map +1 -1
- package/pd-cli/dist/commands/diagnose.js +18 -1
- package/pd-cli/dist/commands/diagnose.js.map +1 -1
- package/pd-cli/dist/commands/pain-evidence.d.ts +41 -0
- package/pd-cli/dist/commands/pain-evidence.d.ts.map +1 -0
- package/pd-cli/dist/commands/pain-evidence.js +177 -0
- package/pd-cli/dist/commands/pain-evidence.js.map +1 -0
- package/pd-cli/dist/commands/pain-record.d.ts.map +1 -1
- package/pd-cli/dist/commands/pain-record.js +24 -9
- package/pd-cli/dist/commands/pain-record.js.map +1 -1
- package/pd-cli/dist/commands/pain-retry.d.ts +19 -0
- package/pd-cli/dist/commands/pain-retry.d.ts.map +1 -0
- package/pd-cli/dist/commands/pain-retry.js +485 -0
- package/pd-cli/dist/commands/pain-retry.js.map +1 -0
- package/pd-cli/dist/commands/runtime-internalization-run-once.d.ts.map +1 -1
- package/pd-cli/dist/commands/runtime-internalization-run-once.js +59 -9
- package/pd-cli/dist/commands/runtime-internalization-run-once.js.map +1 -1
- package/pd-cli/dist/commands/runtime-uat.d.ts +1 -0
- package/pd-cli/dist/commands/runtime-uat.d.ts.map +1 -1
- package/pd-cli/dist/commands/runtime-uat.guard.test.d.ts +2 -0
- package/pd-cli/dist/commands/runtime-uat.guard.test.d.ts.map +1 -0
- package/pd-cli/dist/commands/runtime-uat.guard.test.js +155 -0
- package/pd-cli/dist/commands/runtime-uat.guard.test.js.map +1 -0
- package/pd-cli/dist/commands/runtime-uat.js +29 -3
- package/pd-cli/dist/commands/runtime-uat.js.map +1 -1
- package/pd-cli/dist/config-reader.d.ts +25 -0
- package/pd-cli/dist/config-reader.d.ts.map +1 -0
- package/pd-cli/dist/config-reader.js +109 -0
- package/pd-cli/dist/config-reader.js.map +1 -0
- package/pd-cli/dist/index.js +40 -5
- package/pd-cli/dist/index.js.map +1 -1
- package/pd-cli/dist/services/console-launcher.d.ts.map +1 -1
- package/pd-cli/dist/services/console-launcher.js +29 -15
- package/pd-cli/dist/services/console-launcher.js.map +1 -1
- package/pd-cli/dist/services/demo-story-a-runner.d.ts.map +1 -1
- package/pd-cli/dist/services/demo-story-a-runner.js +1 -0
- package/pd-cli/dist/services/demo-story-a-runner.js.map +1 -1
- package/pd-cli/dist/utils/production-workspace-guard.d.ts +77 -0
- package/pd-cli/dist/utils/production-workspace-guard.d.ts.map +1 -0
- package/pd-cli/dist/utils/production-workspace-guard.js +170 -0
- package/pd-cli/dist/utils/production-workspace-guard.js.map +1 -0
- package/pd-cli/dist/utils/production-workspace-guard.test.d.ts +2 -0
- package/pd-cli/dist/utils/production-workspace-guard.test.d.ts.map +1 -0
- package/pd-cli/dist/utils/production-workspace-guard.test.js +95 -0
- package/pd-cli/dist/utils/production-workspace-guard.test.js.map +1 -0
- package/pd-cli/package.json +1 -1
- package/plugin/dist/commands/pain.js +27 -2
- package/plugin/dist/core/pain-diagnostic-gate.d.ts +6 -0
- package/plugin/dist/core/pain-diagnostic-gate.js +9 -0
- package/plugin/dist/hooks/after-tool-call-helpers.d.ts +90 -0
- package/plugin/dist/hooks/after-tool-call-helpers.js +486 -0
- package/plugin/dist/hooks/after-tool-call-types.d.ts +92 -0
- package/plugin/dist/hooks/after-tool-call-types.js +13 -0
- package/plugin/dist/hooks/gate-block-helper.js +73 -29
- package/plugin/dist/hooks/llm.js +49 -29
- package/plugin/dist/hooks/message-sanitize.d.ts +21 -0
- package/plugin/dist/hooks/message-sanitize.js +30 -0
- package/plugin/dist/hooks/pain.d.ts +26 -3
- package/plugin/dist/hooks/pain.js +165 -425
- package/plugin/dist/hooks/prompt.js +3 -2
- package/plugin/dist/hooks/trajectory-evidence.d.ts +11 -0
- package/plugin/dist/hooks/trajectory-evidence.js +65 -0
- package/plugin/dist/hooks/triage-adapter.d.ts +82 -0
- package/plugin/dist/hooks/triage-adapter.js +121 -0
- package/console/dist/server/models/EventLogReadModel.d.ts +0 -33
- package/console/dist/server/models/EventLogReadModel.js +0 -218
- package/console/dist/server/models/EvolutionConsoleModel.d.ts +0 -79
- package/console/dist/server/models/EvolutionConsoleModel.js +0 -179
- package/console/dist/server/models/FeedbackConsoleModel.d.ts +0 -38
- package/console/dist/server/models/FeedbackConsoleModel.js +0 -129
- package/console/dist/server/models/GateConsoleModel.d.ts +0 -50
- package/console/dist/server/models/GateConsoleModel.js +0 -151
- package/console/dist/server/models/OverviewConsoleModel.d.ts +0 -22
- package/console/dist/server/models/OverviewConsoleModel.js +0 -202
- package/console/dist/server/models/PipelineStatsModel.d.ts +0 -35
- package/console/dist/server/models/PipelineStatsModel.js +0 -129
- package/console/dist/server/models/SampleConsoleModel.d.ts +0 -21
- package/console/dist/server/models/SampleConsoleModel.js +0 -188
- package/console/dist/server/models/ThinkingModelsConsoleModel.d.ts +0 -22
- package/console/dist/server/models/ThinkingModelsConsoleModel.js +0 -75
- package/console/dist/server/routes/agents.d.ts +0 -3
- package/console/dist/server/routes/agents.js +0 -442
- package/console/dist/server/routes/central.d.ts +0 -5
- package/console/dist/server/routes/central.js +0 -31
- package/console/dist/server/routes/events.d.ts +0 -10
- package/console/dist/server/routes/events.js +0 -99
- package/console/dist/server/routes/evolution.js +0 -73
- package/console/dist/server/routes/feedback.d.ts +0 -3
- package/console/dist/server/routes/feedback.js +0 -65
- package/console/dist/server/routes/gates.d.ts +0 -3
- package/console/dist/server/routes/gates.js +0 -52
- package/console/dist/server/routes/overview.d.ts +0 -3
- package/console/dist/server/routes/overview.js +0 -49
- package/console/dist/server/routes/pipeline.d.ts +0 -3
- package/console/dist/server/routes/pipeline.js +0 -33
- package/console/dist/server/routes/samples.d.ts +0 -3
- package/console/dist/server/routes/samples.js +0 -101
- package/console/dist/server/routes/thinking-models.d.ts +0 -3
- package/console/dist/server/routes/thinking-models.js +0 -54
- package/console/dist/ui/components/app-sidebar.d.ts +0 -7
- package/console/dist/ui/components/app-sidebar.js +0 -75
- package/console/dist/ui/components/compare-view.d.ts +0 -7
- package/console/dist/ui/components/compare-view.js +0 -32
- package/console/dist/ui/components/data-freshness-indicator.d.ts +0 -10
- package/console/dist/ui/components/data-freshness-indicator.js +0 -63
- package/console/dist/ui/components/health-diagnostic-card.d.ts +0 -15
- package/console/dist/ui/components/health-diagnostic-card.js +0 -42
- package/console/dist/ui/components/page-header.d.ts +0 -10
- package/console/dist/ui/components/page-header.js +0 -37
- package/console/dist/ui/hooks/useAutoRefresh.d.ts +0 -13
- package/console/dist/ui/hooks/useAutoRefresh.js +0 -64
- package/console/dist/ui/hooks/useBookmarks.d.ts +0 -6
- package/console/dist/ui/hooks/useBookmarks.js +0 -43
- package/console/dist/ui/hooks/useDebounce.d.ts +0 -2
- package/console/dist/ui/hooks/useDebounce.js +0 -32
- package/console/dist/ui/hooks/useKeyboardNavigation.d.ts +0 -14
- package/console/dist/ui/hooks/useKeyboardNavigation.js +0 -75
- package/console/dist/ui/pages/AgentsPage.d.ts +0 -1
- package/console/dist/ui/pages/AgentsPage.js +0 -167
- package/console/dist/ui/pages/ApprovalsPage.d.ts +0 -1
- package/console/dist/ui/pages/ApprovalsPage.js +0 -123
- package/console/dist/ui/pages/CentralPage.d.ts +0 -1
- package/console/dist/ui/pages/CentralPage.js +0 -57
- package/console/dist/ui/pages/DataFlowPage.d.ts +0 -1
- package/console/dist/ui/pages/DataFlowPage.js +0 -158
- package/console/dist/ui/pages/EventLogPage.d.ts +0 -1
- package/console/dist/ui/pages/EventLogPage.js +0 -176
- package/console/dist/ui/pages/EvolutionPage.d.ts +0 -1
- package/console/dist/ui/pages/EvolutionPage.js +0 -118
- package/console/dist/ui/pages/FeedbackPage.d.ts +0 -1
- package/console/dist/ui/pages/FeedbackPage.js +0 -46
- package/console/dist/ui/pages/GatesPage.d.ts +0 -1
- package/console/dist/ui/pages/GatesPage.js +0 -31
- package/console/dist/ui/pages/LoginPage.d.ts +0 -5
- package/console/dist/ui/pages/LoginPage.js +0 -39
- package/console/dist/ui/pages/OverviewPage.d.ts +0 -1
- package/console/dist/ui/pages/OverviewPage.js +0 -50
- package/console/dist/ui/pages/PainPage.js +0 -50
- package/console/dist/ui/pages/PrincipleDetailPage.js +0 -145
- package/console/dist/ui/pages/PrinciplesPage.js +0 -322
- package/console/dist/ui/pages/ReportProblemPage.js +0 -186
- package/console/dist/ui/pages/SamplesPage.d.ts +0 -1
- package/console/dist/ui/pages/SamplesPage.js +0 -105
- package/console/dist/ui/pages/SettingsPage.d.ts +0 -1
- package/console/dist/ui/pages/SettingsPage.js +0 -86
- package/console/dist/ui/pages/TasksPage.d.ts +0 -1
- package/console/dist/ui/pages/TasksPage.js +0 -373
- package/console/dist/ui/pages/ThinkingModelsPage.d.ts +0 -1
- package/console/dist/ui/pages/ThinkingModelsPage.js +0 -32
- package/console/dist/ui/pages/UpdatePage.d.ts +0 -1
- package/console/dist/ui/pages/UpdatePage.js +0 -142
- /package/console/dist/ui/pages/{PainPage.d.ts → pain/PainPage.d.ts} +0 -0
- /package/console/dist/ui/pages/{PrincipleDetailPage.d.ts → principles/PrincipleDetailPage.d.ts} +0 -0
- /package/console/dist/ui/pages/{PrinciplesPage.d.ts → principles/PrinciplesPage.d.ts} +0 -0
- /package/console/dist/ui/pages/{ReportProblemPage.d.ts → report-problem/ReportProblemPage.d.ts} +0 -0
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import { SqliteConnection, SqliteApprovalQueueStore, SqlitePIArtifactStore, ApprovalQueue, } from '@principles/core/runtime-v2';
|
|
2
|
+
import * as fs from 'node:fs';
|
|
3
|
+
import * as path from 'node:path';
|
|
4
|
+
function isMissingTableError(err) {
|
|
5
|
+
if (!(err instanceof Error))
|
|
6
|
+
return false;
|
|
7
|
+
return err.message.includes('no such table');
|
|
8
|
+
}
|
|
9
|
+
export class GovernanceConsoleModel {
|
|
10
|
+
readConnection = null;
|
|
11
|
+
workspaceDir;
|
|
12
|
+
constructor(workspaceDir) {
|
|
13
|
+
this.workspaceDir = workspaceDir;
|
|
14
|
+
}
|
|
15
|
+
getReadConnection() {
|
|
16
|
+
if (!this.readConnection) {
|
|
17
|
+
this.readConnection = new SqliteConnection({ workspaceDir: this.workspaceDir, readonly: true });
|
|
18
|
+
}
|
|
19
|
+
return this.readConnection;
|
|
20
|
+
}
|
|
21
|
+
async getGovernanceQueue() {
|
|
22
|
+
const stateDbPath = path.join(this.workspaceDir, '.pd', 'state.db');
|
|
23
|
+
if (!fs.existsSync(stateDbPath)) {
|
|
24
|
+
return {
|
|
25
|
+
pendingReviewCount: 0,
|
|
26
|
+
behaviorDeviationCount: 0,
|
|
27
|
+
stagnationSignals: [],
|
|
28
|
+
governanceState: 'none',
|
|
29
|
+
stateReasonCode: 'state_db_missing',
|
|
30
|
+
nextActionCode: 'run_config_doctor',
|
|
31
|
+
stateReason: 'State database not initialized. PD has not run in this workspace.',
|
|
32
|
+
nextAction: 'Ensure the OpenClaw plugin is enabled, or run pd config doctor.',
|
|
33
|
+
generatedAt: new Date().toISOString(),
|
|
34
|
+
note: 'state.db not found — workspace may not be initialized',
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
const conn = this.getReadConnection();
|
|
38
|
+
const store = new SqliteApprovalQueueStore(conn);
|
|
39
|
+
const queue = new ApprovalQueue(store);
|
|
40
|
+
const artifactStore = new SqlitePIArtifactStore(conn);
|
|
41
|
+
const db = conn.getDb();
|
|
42
|
+
// ── Gather signals from multiple data sources ───────────────────────
|
|
43
|
+
// 1. Pending approvals
|
|
44
|
+
let pendingApprovals;
|
|
45
|
+
let missingApprovalTable = false;
|
|
46
|
+
try {
|
|
47
|
+
pendingApprovals = await queue.listPending();
|
|
48
|
+
}
|
|
49
|
+
catch (err) {
|
|
50
|
+
if (isMissingTableError(err)) {
|
|
51
|
+
pendingApprovals = [];
|
|
52
|
+
missingApprovalTable = true;
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
throw err;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const pendingReviewCount = pendingApprovals.length;
|
|
59
|
+
const behaviorDeviationCount = pendingApprovals.filter((a) => a.riskLevel === 'high' || a.riskLevel === 'critical').length;
|
|
60
|
+
// Build artifactId → sourcePrincipleId map for stagnation signals
|
|
61
|
+
const artifactPrincipleMap = new Map();
|
|
62
|
+
for (const approval of pendingApprovals) {
|
|
63
|
+
if (!artifactPrincipleMap.has(approval.artifactId)) {
|
|
64
|
+
try {
|
|
65
|
+
const artifact = await artifactStore.getArtifactById(approval.artifactId);
|
|
66
|
+
artifactPrincipleMap.set(approval.artifactId, artifact?.sourcePrincipleId ?? null);
|
|
67
|
+
}
|
|
68
|
+
catch (err) {
|
|
69
|
+
if (isMissingTableError(err)) {
|
|
70
|
+
artifactPrincipleMap.set(approval.artifactId, null);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
throw err;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
const sevenDaysAgo = Date.now() - 7 * 24 * 60 * 60 * 1000;
|
|
79
|
+
const stagnationSignals = pendingApprovals
|
|
80
|
+
.filter((a) => {
|
|
81
|
+
const requestedAt = new Date(a.requestedAt).getTime();
|
|
82
|
+
return !Number.isNaN(requestedAt) && requestedAt < sevenDaysAgo;
|
|
83
|
+
})
|
|
84
|
+
.map((a) => {
|
|
85
|
+
const requestedAt = new Date(a.requestedAt).getTime();
|
|
86
|
+
const daysSince = Math.floor((Date.now() - requestedAt) / (24 * 60 * 60 * 1000));
|
|
87
|
+
const principleId = artifactPrincipleMap.get(a.artifactId) ?? 'unlinked';
|
|
88
|
+
return {
|
|
89
|
+
type: 'never_activated',
|
|
90
|
+
principleId,
|
|
91
|
+
daysSince,
|
|
92
|
+
};
|
|
93
|
+
});
|
|
94
|
+
// 2. Check internalization pipeline activity (tasks)
|
|
95
|
+
let hasInternalizationTasks = false;
|
|
96
|
+
let hasRetryWaitTasks = false;
|
|
97
|
+
let hasFailedTasks = false;
|
|
98
|
+
const retryWaitReasons = [];
|
|
99
|
+
const failedReasons = [];
|
|
100
|
+
try {
|
|
101
|
+
const tasks = db.prepare(`SELECT task_kind, status, last_error FROM tasks WHERE task_kind IN ('dreamer', 'philosopher', 'scribe', 'artificer', 'evaluator')`).all();
|
|
102
|
+
hasInternalizationTasks = tasks.length > 0;
|
|
103
|
+
for (const task of tasks) {
|
|
104
|
+
if (task.status === 'retry_wait') {
|
|
105
|
+
hasRetryWaitTasks = true;
|
|
106
|
+
const errText = task.last_error ? task.last_error.substring(0, 120) : 'unknown error';
|
|
107
|
+
retryWaitReasons.push(`${task.task_kind}: ${errText}`);
|
|
108
|
+
}
|
|
109
|
+
if (task.status === 'failed') {
|
|
110
|
+
hasFailedTasks = true;
|
|
111
|
+
const errText = task.last_error ? task.last_error.substring(0, 120) : 'unknown error';
|
|
112
|
+
failedReasons.push(`${task.task_kind}: ${errText}`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
catch (err) {
|
|
117
|
+
if (!isMissingTableError(err))
|
|
118
|
+
throw err;
|
|
119
|
+
}
|
|
120
|
+
// 3. Check candidates table for pipeline activity
|
|
121
|
+
let hasConsumedCandidates = false;
|
|
122
|
+
let hasPendingCandidates = false;
|
|
123
|
+
try {
|
|
124
|
+
const candidateRow = db.prepare(`SELECT status, COUNT(*) as c FROM principle_candidates GROUP BY status`).all();
|
|
125
|
+
for (const row of candidateRow) {
|
|
126
|
+
if (row.status === 'consumed')
|
|
127
|
+
hasConsumedCandidates = true;
|
|
128
|
+
if (row.status === 'pending' || row.status === 'new')
|
|
129
|
+
hasPendingCandidates = true;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
catch (err) {
|
|
133
|
+
if (!isMissingTableError(err))
|
|
134
|
+
throw err;
|
|
135
|
+
}
|
|
136
|
+
// 4. Degraded signals
|
|
137
|
+
const degradedSignals = [];
|
|
138
|
+
if (hasRetryWaitTasks) {
|
|
139
|
+
degradedSignals.push({
|
|
140
|
+
reasonCode: 'task_retry_wait',
|
|
141
|
+
nextActionCode: 'check_task_status',
|
|
142
|
+
reason: `Internalization task waiting for retry: ${retryWaitReasons.join('; ')}`,
|
|
143
|
+
nextAction: 'Check internalization pipeline status, or wait for automatic retry.',
|
|
144
|
+
source: 'internalization_task',
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
if (hasFailedTasks) {
|
|
148
|
+
degradedSignals.push({
|
|
149
|
+
reasonCode: 'task_failed',
|
|
150
|
+
nextActionCode: 'fix_and_retry',
|
|
151
|
+
reason: `Internalization task failed: ${failedReasons.join('; ')}`,
|
|
152
|
+
nextAction: 'Check failure details, fix the issue and retry.',
|
|
153
|
+
source: 'internalization_task',
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
if (missingApprovalTable) {
|
|
157
|
+
degradedSignals.push({
|
|
158
|
+
reasonCode: 'approval_table_missing',
|
|
159
|
+
nextActionCode: 'run_integrity_check',
|
|
160
|
+
reason: 'Approval table does not exist. This may be an old workspace.',
|
|
161
|
+
nextAction: 'Run pd runtime internalization integrity to check and repair table structure.',
|
|
162
|
+
source: 'source_unavailable',
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
// ── Determine governance state ──────────────────────────────────────
|
|
166
|
+
// P1-2: Only pendingReviewCount determines owner_review_ready.
|
|
167
|
+
// Validated artifacts are NOT sufficient — they may be demo/smoke/historical.
|
|
168
|
+
// The owner-actionable queue read model (PRI-330) will refine this.
|
|
169
|
+
const hasOwnerReadyItems = pendingReviewCount > 0;
|
|
170
|
+
const hasPipelineActivity = hasInternalizationTasks || hasConsumedCandidates || hasPendingCandidates;
|
|
171
|
+
const hasDegradation = degradedSignals.length > 0;
|
|
172
|
+
let governanceState;
|
|
173
|
+
let stateReasonCode;
|
|
174
|
+
let nextActionCode;
|
|
175
|
+
let stateReason;
|
|
176
|
+
let nextAction;
|
|
177
|
+
let inProgressSummary;
|
|
178
|
+
if (hasOwnerReadyItems) {
|
|
179
|
+
governanceState = 'owner_review_ready';
|
|
180
|
+
stateReasonCode = 'pending_approvals';
|
|
181
|
+
nextActionCode = 'review_approvals';
|
|
182
|
+
stateReason = `${pendingReviewCount} principle(s) pending your review and decision.`;
|
|
183
|
+
nextAction = 'Review pending principles and approve, reject, or park.';
|
|
184
|
+
}
|
|
185
|
+
else if (hasDegradation) {
|
|
186
|
+
governanceState = 'degraded';
|
|
187
|
+
stateReasonCode = 'degraded_state';
|
|
188
|
+
nextActionCode = 'check_degraded_signals';
|
|
189
|
+
stateReason = 'Part of the governance pipeline or data source is degraded.';
|
|
190
|
+
nextAction = 'Check degraded signal details and follow suggested actions.';
|
|
191
|
+
}
|
|
192
|
+
else if (hasPipelineActivity) {
|
|
193
|
+
governanceState = 'in_progress';
|
|
194
|
+
if (hasInternalizationTasks) {
|
|
195
|
+
stateReasonCode = 'pipeline_active';
|
|
196
|
+
nextActionCode = 'check_pipeline_status';
|
|
197
|
+
inProgressSummary = 'PD is processing the internalization pipeline: diagnostics, principle candidates, or internalization task activity recorded, but no owner-reviewable decision items yet.';
|
|
198
|
+
stateReason = 'Pipeline has activity, but candidate principles are not ready for review.';
|
|
199
|
+
nextAction = 'Wait for internalization tasks to complete. If no change for a long time, check pipeline status.';
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
stateReasonCode = 'consumed_candidates';
|
|
203
|
+
nextActionCode = 'wait_for_pipeline';
|
|
204
|
+
inProgressSummary = 'PD has recorded governance chain activity (candidates generated), but candidates are not yet ready for review.';
|
|
205
|
+
stateReason = 'Candidate records exist, but have not entered the review stage.';
|
|
206
|
+
nextAction = 'Wait for the internalization pipeline to convert candidates into reviewable principles.';
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
governanceState = 'none';
|
|
211
|
+
stateReasonCode = 'no_pipeline_activity';
|
|
212
|
+
nextActionCode = 'wait_for_pipeline';
|
|
213
|
+
stateReason = 'No governance chain activity recorded yet.';
|
|
214
|
+
nextAction = 'PD will surface principle candidates here once behavior deviations are captured and reviewable artifacts are generated.';
|
|
215
|
+
}
|
|
216
|
+
const response = {
|
|
217
|
+
pendingReviewCount,
|
|
218
|
+
behaviorDeviationCount,
|
|
219
|
+
stagnationSignals,
|
|
220
|
+
governanceState,
|
|
221
|
+
stateReasonCode,
|
|
222
|
+
nextActionCode,
|
|
223
|
+
stateReason,
|
|
224
|
+
nextAction,
|
|
225
|
+
generatedAt: new Date().toISOString(),
|
|
226
|
+
};
|
|
227
|
+
if (inProgressSummary) {
|
|
228
|
+
response.inProgressSummary = inProgressSummary;
|
|
229
|
+
}
|
|
230
|
+
if (degradedSignals.length > 0) {
|
|
231
|
+
response.degradedSignals = degradedSignals;
|
|
232
|
+
}
|
|
233
|
+
return response;
|
|
234
|
+
}
|
|
235
|
+
dispose() {
|
|
236
|
+
if (this.readConnection) {
|
|
237
|
+
try {
|
|
238
|
+
this.readConnection.close();
|
|
239
|
+
}
|
|
240
|
+
catch (err) {
|
|
241
|
+
console.warn('GovernanceConsoleModel.dispose: failed to close connection:', err instanceof Error ? err.message : String(err));
|
|
242
|
+
}
|
|
243
|
+
this.readConnection = null;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
@@ -19,22 +19,18 @@ export interface SystemHealthStatus {
|
|
|
19
19
|
}
|
|
20
20
|
export declare class HealthCheckModel {
|
|
21
21
|
private readonly workspaceDir;
|
|
22
|
-
private readonly stateDir;
|
|
23
22
|
private operatorHealth;
|
|
24
23
|
private painChain;
|
|
25
24
|
private pruning;
|
|
26
25
|
private runtime;
|
|
27
|
-
private eventLog;
|
|
28
26
|
constructor(workspaceDir: string);
|
|
29
27
|
checkSystemHealth(): Promise<SystemHealthStatus>;
|
|
30
|
-
private checkEventLog;
|
|
31
28
|
private checkSqlite;
|
|
32
29
|
private checkPainChainFlow;
|
|
33
30
|
private checkTaskQueue;
|
|
34
31
|
private checkPrincipleTree;
|
|
35
32
|
private checkGfiHealth;
|
|
36
33
|
private getPipelineTimestamps;
|
|
37
|
-
private getEventLogReadModel;
|
|
38
34
|
private getRuntime;
|
|
39
35
|
private getPainChain;
|
|
40
36
|
private getPruning;
|
|
@@ -1,22 +1,16 @@
|
|
|
1
|
-
import * as path from 'path';
|
|
2
1
|
import { OperatorHealthReadModel, PainChainReadModel, PruningReadModel, RuntimeStateManager, } from '@principles/core/runtime-v2';
|
|
3
|
-
import { EventLogReadModel } from './EventLogReadModel.js';
|
|
4
2
|
const noop = () => { };
|
|
5
3
|
export class HealthCheckModel {
|
|
6
4
|
workspaceDir;
|
|
7
|
-
stateDir;
|
|
8
5
|
operatorHealth = null;
|
|
9
6
|
painChain = null;
|
|
10
7
|
pruning = null;
|
|
11
8
|
runtime = null;
|
|
12
|
-
eventLog = null;
|
|
13
9
|
constructor(workspaceDir) {
|
|
14
10
|
this.workspaceDir = workspaceDir;
|
|
15
|
-
this.stateDir = path.join(workspaceDir, '.state');
|
|
16
11
|
}
|
|
17
12
|
async checkSystemHealth() {
|
|
18
13
|
const checks = [];
|
|
19
|
-
checks.push(await this.checkEventLog());
|
|
20
14
|
checks.push(await this.checkSqlite());
|
|
21
15
|
checks.push(await this.checkPainChainFlow());
|
|
22
16
|
checks.push(await this.checkTaskQueue());
|
|
@@ -32,53 +26,9 @@ export class HealthCheckModel {
|
|
|
32
26
|
generatedAt: new Date().toISOString(),
|
|
33
27
|
};
|
|
34
28
|
}
|
|
35
|
-
async checkEventLog() {
|
|
36
|
-
try {
|
|
37
|
-
const eventLog = this.getEventLogReadModel();
|
|
38
|
-
const recentEvents = await eventLog.getEventsByTypes([], 1);
|
|
39
|
-
const now = new Date();
|
|
40
|
-
if (recentEvents.length === 0) {
|
|
41
|
-
return {
|
|
42
|
-
id: 'event_log',
|
|
43
|
-
name: '事件日志',
|
|
44
|
-
status: 'warning',
|
|
45
|
-
message: '暂无事件记录',
|
|
46
|
-
lastCheck: now.toISOString(),
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
const [lastEvent] = recentEvents;
|
|
50
|
-
const eventTime = new Date(lastEvent.ts);
|
|
51
|
-
const diffMinutes = (now.getTime() - eventTime.getTime()) / (1000 * 60);
|
|
52
|
-
if (diffMinutes > 60) {
|
|
53
|
-
return {
|
|
54
|
-
id: 'event_log',
|
|
55
|
-
name: '事件日志',
|
|
56
|
-
status: 'warning',
|
|
57
|
-
message: `最后事件超过 ${Math.floor(diffMinutes)} 分钟前`,
|
|
58
|
-
lastCheck: now.toISOString(),
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
return {
|
|
62
|
-
id: 'event_log',
|
|
63
|
-
name: '事件日志',
|
|
64
|
-
status: 'healthy',
|
|
65
|
-
message: `正常记录中,最后事件 ${Math.floor(diffMinutes)} 分钟前`,
|
|
66
|
-
lastCheck: now.toISOString(),
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
catch (e) {
|
|
70
|
-
return {
|
|
71
|
-
id: 'event_log',
|
|
72
|
-
name: '事件日志',
|
|
73
|
-
status: 'error',
|
|
74
|
-
message: `读取失败: ${e.message}`,
|
|
75
|
-
lastCheck: new Date().toISOString(),
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
29
|
async checkSqlite() {
|
|
80
30
|
try {
|
|
81
|
-
const runtime = this.getRuntime();
|
|
31
|
+
const runtime = await this.getRuntime();
|
|
82
32
|
await runtime.listTasks({ limit: 1 });
|
|
83
33
|
return {
|
|
84
34
|
id: 'sqlite',
|
|
@@ -143,7 +93,7 @@ export class HealthCheckModel {
|
|
|
143
93
|
}
|
|
144
94
|
async checkTaskQueue() {
|
|
145
95
|
try {
|
|
146
|
-
const runtime = this.getRuntime();
|
|
96
|
+
const runtime = await this.getRuntime();
|
|
147
97
|
const pendingTasks = await runtime.listTasks({ status: 'pending', limit: 100 });
|
|
148
98
|
const leasedTasks = await runtime.listTasks({ status: 'leased', limit: 100 });
|
|
149
99
|
const failedTasks = await runtime.listTasks({ status: 'failed', limit: 100 });
|
|
@@ -217,7 +167,7 @@ export class HealthCheckModel {
|
|
|
217
167
|
}
|
|
218
168
|
async checkGfiHealth() {
|
|
219
169
|
try {
|
|
220
|
-
const health = this.getOperatorHealth();
|
|
170
|
+
const health = await this.getOperatorHealth();
|
|
221
171
|
const snapshot = await health.getSnapshot();
|
|
222
172
|
const { gfi } = snapshot;
|
|
223
173
|
const { active } = gfi;
|
|
@@ -269,37 +219,59 @@ export class HealthCheckModel {
|
|
|
269
219
|
}
|
|
270
220
|
}
|
|
271
221
|
async getPipelineTimestamps() {
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
222
|
+
try {
|
|
223
|
+
const runtime = await this.getRuntime();
|
|
224
|
+
const [painTasks, diagTasks, candidates] = await Promise.all([
|
|
225
|
+
runtime.listTasks({ taskKind: 'pain_collector', limit: 1 }),
|
|
226
|
+
runtime.listTasks({ taskKind: 'diagnostician', limit: 1 }),
|
|
227
|
+
runtime.listTasks({ status: 'succeeded', limit: 1 }),
|
|
228
|
+
]);
|
|
229
|
+
const lastPainSignal = painTasks[0]?.updatedAt ?? null;
|
|
230
|
+
const lastTaskCreated = diagTasks[0]?.createdAt ?? null;
|
|
231
|
+
const lastCandidateGenerated = candidates[0]?.updatedAt ?? null;
|
|
232
|
+
let lastPrincipleAdded = null;
|
|
233
|
+
try {
|
|
234
|
+
const pruning = this.getPruning();
|
|
235
|
+
const summary = pruning.getHealthSummary();
|
|
236
|
+
const { byStatus } = summary;
|
|
237
|
+
if ((byStatus.active ?? 0) > 0) {
|
|
238
|
+
const signals = pruning.getPrincipleSignals();
|
|
239
|
+
const latestSignal = signals.length > 0 ? signals[0] : null;
|
|
240
|
+
lastPrincipleAdded = latestSignal?.updatedAt ?? null;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
catch {
|
|
244
|
+
// Pruning not available — leave as null
|
|
245
|
+
}
|
|
246
|
+
return {
|
|
247
|
+
lastPainSignal,
|
|
248
|
+
lastTaskCreated,
|
|
249
|
+
lastCandidateGenerated,
|
|
250
|
+
lastPrincipleAdded,
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
catch {
|
|
254
|
+
return {
|
|
255
|
+
lastPainSignal: null,
|
|
256
|
+
lastTaskCreated: null,
|
|
257
|
+
lastCandidateGenerated: null,
|
|
258
|
+
lastPrincipleAdded: null,
|
|
259
|
+
};
|
|
289
260
|
}
|
|
290
|
-
return this.eventLog;
|
|
291
261
|
}
|
|
292
|
-
getRuntime() {
|
|
262
|
+
async getRuntime() {
|
|
293
263
|
if (!this.runtime) {
|
|
294
264
|
this.runtime = new RuntimeStateManager({ workspaceDir: this.workspaceDir });
|
|
265
|
+
await this.runtime.initialize();
|
|
295
266
|
}
|
|
296
267
|
return this.runtime;
|
|
297
268
|
}
|
|
298
|
-
getPainChain() {
|
|
269
|
+
async getPainChain() {
|
|
299
270
|
if (!this.painChain) {
|
|
271
|
+
const runtime = await this.getRuntime();
|
|
300
272
|
this.painChain = new PainChainReadModel({
|
|
301
273
|
workspaceDir: this.workspaceDir,
|
|
302
|
-
stateManager:
|
|
274
|
+
stateManager: runtime,
|
|
303
275
|
});
|
|
304
276
|
}
|
|
305
277
|
return this.painChain;
|
|
@@ -310,11 +282,12 @@ export class HealthCheckModel {
|
|
|
310
282
|
}
|
|
311
283
|
return this.pruning;
|
|
312
284
|
}
|
|
313
|
-
getOperatorHealth() {
|
|
285
|
+
async getOperatorHealth() {
|
|
314
286
|
if (!this.operatorHealth) {
|
|
287
|
+
const painChain = await this.getPainChain();
|
|
315
288
|
this.operatorHealth = new OperatorHealthReadModel({
|
|
316
289
|
workspaceDir: this.workspaceDir,
|
|
317
|
-
painChainReadModel:
|
|
290
|
+
painChainReadModel: painChain,
|
|
318
291
|
pruningReadModel: this.getPruning(),
|
|
319
292
|
});
|
|
320
293
|
}
|
|
@@ -333,9 +306,5 @@ export class HealthCheckModel {
|
|
|
333
306
|
this.runtime.close().catch(noop);
|
|
334
307
|
this.runtime = null;
|
|
335
308
|
}
|
|
336
|
-
if (this.eventLog) {
|
|
337
|
-
this.eventLog.dispose();
|
|
338
|
-
this.eventLog = null;
|
|
339
|
-
}
|
|
340
309
|
}
|
|
341
310
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface LifecycleMetricsResponse {
|
|
2
|
+
principleId: string;
|
|
3
|
+
adherence: {
|
|
4
|
+
insufficientData: boolean;
|
|
5
|
+
rate: number | null;
|
|
6
|
+
note: string;
|
|
7
|
+
};
|
|
8
|
+
ruleMetrics: {
|
|
9
|
+
ruleId: string;
|
|
10
|
+
triggered: number;
|
|
11
|
+
lastTriggeredAt: string | null;
|
|
12
|
+
}[];
|
|
13
|
+
}
|
|
14
|
+
export declare class LifecycleConsoleModel {
|
|
15
|
+
private readonly workspaceDir;
|
|
16
|
+
private readonly stateDir;
|
|
17
|
+
constructor(workspaceDir: string);
|
|
18
|
+
getLifecycleMetrics(principleId: string): LifecycleMetricsResponse | null;
|
|
19
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { buildLifecycleReadModel, computePrincipleAdherence, computeRuleMetrics, } from '@principles/core/runtime-v2';
|
|
2
|
+
import { ConsoleLifecycleDatasource } from './ConsoleLifecycleDatasource.js';
|
|
3
|
+
export class LifecycleConsoleModel {
|
|
4
|
+
workspaceDir;
|
|
5
|
+
stateDir;
|
|
6
|
+
constructor(workspaceDir) {
|
|
7
|
+
this.workspaceDir = workspaceDir;
|
|
8
|
+
this.stateDir = `${workspaceDir}/.state`;
|
|
9
|
+
}
|
|
10
|
+
getLifecycleMetrics(principleId) {
|
|
11
|
+
const datasource = new ConsoleLifecycleDatasource(this.workspaceDir, this.stateDir);
|
|
12
|
+
const readModel = buildLifecycleReadModel(datasource);
|
|
13
|
+
const principle = readModel.principles.find((p) => p.principle.id === principleId);
|
|
14
|
+
if (!principle)
|
|
15
|
+
return null;
|
|
16
|
+
const ruleMetricsMap = {};
|
|
17
|
+
for (const rule of principle.rules) {
|
|
18
|
+
ruleMetricsMap[rule.rule.id] = computeRuleMetrics(rule);
|
|
19
|
+
}
|
|
20
|
+
const adherence = computePrincipleAdherence(principle, ruleMetricsMap);
|
|
21
|
+
// Build ruleMetrics array from lifecycle evidence
|
|
22
|
+
const ruleMetrics = principle.rules.map((rule) => {
|
|
23
|
+
const triggered = rule.replayEvidence.reportCount;
|
|
24
|
+
const latestReport = rule.replayEvidence.latestReports.length > 0
|
|
25
|
+
? rule.replayEvidence.latestReports[0]
|
|
26
|
+
: null;
|
|
27
|
+
const lastTriggeredAt = latestReport?.generatedAt ?? null;
|
|
28
|
+
return {
|
|
29
|
+
ruleId: rule.rule.id,
|
|
30
|
+
triggered,
|
|
31
|
+
lastTriggeredAt,
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
if (adherence.insufficientData) {
|
|
35
|
+
return {
|
|
36
|
+
principleId,
|
|
37
|
+
adherence: {
|
|
38
|
+
insufficientData: true,
|
|
39
|
+
rate: null,
|
|
40
|
+
note: '该原则尚无规则,无法计算依从率',
|
|
41
|
+
},
|
|
42
|
+
ruleMetrics,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
principleId,
|
|
47
|
+
adherence: {
|
|
48
|
+
insufficientData: false,
|
|
49
|
+
rate: adherence.adherenceRate,
|
|
50
|
+
note: '',
|
|
51
|
+
},
|
|
52
|
+
ruleMetrics,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PrincipleClassifier — Read model that classifies principles into
|
|
3
|
+
* owner-actionable vs noise categories.
|
|
4
|
+
*
|
|
5
|
+
* Categories:
|
|
6
|
+
* - owner_actionable: Needs a real governance decision (pending, probation, candidate)
|
|
7
|
+
* - demo: Demo / example principles planted by the framework
|
|
8
|
+
* - smoke: Smoke-test principles for CI validation
|
|
9
|
+
* - historical: Archived or deprecated principles (already decided long ago)
|
|
10
|
+
* - builtin: Core Thinking OS axioms (T-01..T-10) — not governance targets
|
|
11
|
+
* - already_decided: Approved / rejected via approval queue
|
|
12
|
+
*
|
|
13
|
+
* Classification is purely read-side; it does NOT mutate any data.
|
|
14
|
+
*/
|
|
15
|
+
import type { PrincipleListItem } from './PrinciplesConsoleModel.js';
|
|
16
|
+
export type PrincipleCategory = 'owner_actionable' | 'demo' | 'smoke' | 'historical' | 'builtin' | 'already_decided';
|
|
17
|
+
export interface ClassifiedPrinciple {
|
|
18
|
+
principle: PrincipleListItem;
|
|
19
|
+
category: PrincipleCategory;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Classify a single principle. Order matters — earlier checks win.
|
|
23
|
+
*
|
|
24
|
+
* @param p - The principle to classify
|
|
25
|
+
* @param decidedPrincipleIds - Set of principle IDs that have been decided
|
|
26
|
+
* via the approval queue (approved or rejected). These should be classified
|
|
27
|
+
* as already_decided regardless of their ledger status.
|
|
28
|
+
*/
|
|
29
|
+
export declare function classifyPrinciple(p: PrincipleListItem, decidedPrincipleIds?: Set<string>): PrincipleCategory;
|
|
30
|
+
/**
|
|
31
|
+
* Classify a batch of principles. Returns the classified array.
|
|
32
|
+
*
|
|
33
|
+
* @param principles - The principles to classify
|
|
34
|
+
* @param decidedPrincipleIds - Set of principle IDs that have been decided
|
|
35
|
+
* via the approval queue (approved or rejected).
|
|
36
|
+
*/
|
|
37
|
+
export declare function classifyPrinciples(principles: PrincipleListItem[], decidedPrincipleIds?: Set<string>): ClassifiedPrinciple[];
|
|
38
|
+
/**
|
|
39
|
+
* Filter to only owner-actionable principles.
|
|
40
|
+
*/
|
|
41
|
+
export declare function filterOwnerActionable(classified: ClassifiedPrinciple[]): ClassifiedPrinciple[];
|