create-principles-disciple 1.94.0 → 1.96.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/WorkspaceConfigStore.js +2 -1
- package/console/dist/server/config/pd-config-store.d.ts +33 -0
- package/console/dist/server/config/pd-config-store.js +196 -0
- package/console/dist/server/index.js +19 -4
- package/console/dist/server/models/EvidenceChainConsoleModel.d.ts +0 -2
- package/console/dist/server/models/EvidenceChainConsoleModel.js +36 -2
- package/console/dist/server/models/HealthCheckModel.js +5 -3
- package/console/dist/server/models/IntentDecisionModel.d.ts +66 -0
- package/console/dist/server/models/IntentDecisionModel.js +207 -0
- package/console/dist/server/models/IntentPageModel.d.ts +52 -0
- package/console/dist/server/models/IntentPageModel.js +292 -0
- package/console/dist/server/models/PrinciplesConsoleModel.d.ts +2 -0
- package/console/dist/server/models/PrinciplesConsoleModel.js +37 -1
- package/console/dist/server/models/WorkspaceService.d.ts +0 -28
- package/console/dist/server/models/WorkspaceService.js +0 -115
- package/console/dist/server/routes/config.js +55 -1
- package/console/dist/server/routes/intent-decisions.d.ts +33 -0
- package/console/dist/server/routes/intent-decisions.js +499 -0
- package/console/dist/server/routes/intent.d.ts +7 -0
- package/console/dist/server/routes/intent.js +223 -0
- package/console/dist/server/routes/principles.js +67 -1
- package/console/dist/server/routes/update.d.ts +0 -1
- package/console/dist/server/routes/update.js +14 -11
- package/console/dist/types.d.ts +1 -0
- package/console/dist/ui/App.js +2 -60
- package/console/dist/ui/api.d.ts +58 -18
- package/console/dist/ui/api.js +78 -6
- package/console/dist/ui/components/layout/app-sidebar.js +13 -12
- package/console/dist/ui/components/ui/badge.d.ts +1 -1
- package/console/dist/ui/components/ui/button.d.ts +1 -1
- package/console/dist/ui/components/ui/shiny-text.d.ts +28 -0
- package/console/dist/ui/components/ui/shiny-text.js +46 -0
- package/console/dist/ui/i18n/en.json +306 -3
- package/console/dist/ui/i18n/zh-CN.json +306 -3
- package/console/dist/ui/pages/activation/ActivationPage.js +2 -1
- package/console/dist/ui/pages/control-center/AgentCard.d.ts +31 -0
- package/console/dist/ui/pages/control-center/AgentCard.js +156 -0
- package/console/dist/ui/pages/control-center/AgentGroup.d.ts +26 -0
- package/console/dist/ui/pages/control-center/AgentGroup.js +38 -0
- package/console/dist/ui/pages/control-center/ControlCenterPage.js +103 -41
- package/console/dist/ui/pages/control-center/EmpathyObserverCostHint.d.ts +28 -0
- package/console/dist/ui/pages/control-center/EmpathyObserverCostHint.js +38 -0
- package/console/dist/ui/pages/control-center/WorkflowDiagram.d.ts +17 -0
- package/console/dist/ui/pages/control-center/WorkflowDiagram.js +55 -0
- package/console/dist/ui/pages/debt/DebtPage.js +219 -2
- package/console/dist/ui/pages/focus/FocusPage.js +2 -1
- package/console/dist/ui/pages/intent/IntentOnboarding.d.ts +67 -0
- package/console/dist/ui/pages/intent/IntentOnboarding.js +289 -0
- package/console/dist/ui/pages/intent/IntentPage.d.ts +1 -0
- package/console/dist/ui/pages/intent/IntentPage.js +258 -0
- package/console/dist/ui/pages/pain/PainPage.js +234 -4
- package/console/dist/ui/pages/pain/pain-card-helpers.d.ts +75 -0
- package/console/dist/ui/pages/pain/pain-card-helpers.js +78 -0
- package/console/dist/ui/pages/principles/PrinciplesPage.js +2 -1
- package/console/dist/ui/utils/agent-metadata.d.ts +58 -0
- package/console/dist/ui/utils/agent-metadata.js +275 -0
- package/console/dist/ui/utils/control-center-helpers.d.ts +19 -0
- package/console/dist/ui/utils/control-center-helpers.js +37 -0
- package/console/dist/ui/utils/validators.d.ts +200 -0
- package/console/dist/ui/utils/validators.js +563 -0
- package/console/dist/web/assets/app.css +498 -3
- package/console/dist/web/assets/app.js +5063 -1418
- package/console/package.json +3 -0
- package/core/dist/principle-tree-ledger.d.ts +55 -4
- package/core/dist/principle-tree-ledger.d.ts.map +1 -1
- package/core/dist/principle-tree-ledger.js +472 -13
- package/core/dist/principle-tree-ledger.js.map +1 -1
- package/core/dist/prompt-builder/__tests__/prompt-builder-core.test.js +58 -0
- package/core/dist/prompt-builder/__tests__/prompt-builder-core.test.js.map +1 -1
- package/core/dist/prompt-builder/empathy-keyword-matching.d.ts.map +1 -1
- package/core/dist/prompt-builder/empathy-keyword-matching.js +9 -6
- package/core/dist/prompt-builder/empathy-keyword-matching.js.map +1 -1
- package/core/dist/prompt-builder/size-guard.d.ts +1 -0
- package/core/dist/prompt-builder/size-guard.d.ts.map +1 -1
- package/core/dist/prompt-builder/size-guard.js +21 -0
- package/core/dist/prompt-builder/size-guard.js.map +1 -1
- package/core/dist/prompt-builder/types.d.ts +2 -0
- package/core/dist/prompt-builder/types.d.ts.map +1 -1
- package/core/dist/runtime-v2/__tests__/architecture-regression.test.js +143 -65
- package/core/dist/runtime-v2/__tests__/architecture-regression.test.js.map +1 -1
- package/core/dist/runtime-v2/__tests__/evaluator-runner-vslice-v2.test.js +85 -7
- package/core/dist/runtime-v2/__tests__/evaluator-runner-vslice-v2.test.js.map +1 -1
- package/core/dist/runtime-v2/__tests__/evidence-chain-intent-tension.test.d.ts +2 -0
- package/core/dist/runtime-v2/__tests__/evidence-chain-intent-tension.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/__tests__/evidence-chain-intent-tension.test.js +284 -0
- package/core/dist/runtime-v2/__tests__/evidence-chain-intent-tension.test.js.map +1 -0
- package/core/dist/runtime-v2/__tests__/golden-trace-replay-validator.test.js +70 -0
- package/core/dist/runtime-v2/__tests__/golden-trace-replay-validator.test.js.map +1 -1
- package/core/dist/runtime-v2/__tests__/golden-trace.test.js +136 -1
- package/core/dist/runtime-v2/__tests__/golden-trace.test.js.map +1 -1
- package/core/dist/runtime-v2/__tests__/pain-signal-bridge-result-shaping.test.js +105 -0
- package/core/dist/runtime-v2/__tests__/pain-signal-bridge-result-shaping.test.js.map +1 -1
- package/core/dist/runtime-v2/__tests__/pain-signal-observability.test.js +7 -5
- package/core/dist/runtime-v2/__tests__/pain-signal-observability.test.js.map +1 -1
- package/core/dist/runtime-v2/__tests__/pi-artifact-store.test.js +11 -0
- package/core/dist/runtime-v2/__tests__/pi-artifact-store.test.js.map +1 -1
- package/core/dist/runtime-v2/__tests__/proven-channel-baseline.test.js +15 -2
- package/core/dist/runtime-v2/__tests__/proven-channel-baseline.test.js.map +1 -1
- package/core/dist/runtime-v2/__tests__/schema-float-precision.test.d.ts +2 -0
- package/core/dist/runtime-v2/__tests__/schema-float-precision.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/__tests__/schema-float-precision.test.js +290 -0
- package/core/dist/runtime-v2/__tests__/schema-float-precision.test.js.map +1 -0
- package/core/dist/runtime-v2/__tests__/schema-orphan-detection.test.d.ts +2 -0
- package/core/dist/runtime-v2/__tests__/schema-orphan-detection.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/__tests__/schema-orphan-detection.test.js +158 -0
- package/core/dist/runtime-v2/__tests__/schema-orphan-detection.test.js.map +1 -0
- package/core/dist/runtime-v2/__tests__/v2-adversarial-cases.test.d.ts +2 -0
- package/core/dist/runtime-v2/__tests__/v2-adversarial-cases.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/__tests__/v2-adversarial-cases.test.js +211 -0
- package/core/dist/runtime-v2/__tests__/v2-adversarial-cases.test.js.map +1 -0
- package/core/dist/runtime-v2/activation/__tests__/approval-store-extended.test.js +15 -1
- package/core/dist/runtime-v2/activation/__tests__/approval-store-extended.test.js.map +1 -1
- package/core/dist/runtime-v2/activation/__tests__/sqlite-activation-state-store-fk.test.d.ts +2 -0
- package/core/dist/runtime-v2/activation/__tests__/sqlite-activation-state-store-fk.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/activation/__tests__/sqlite-activation-state-store-fk.test.js +62 -0
- package/core/dist/runtime-v2/activation/__tests__/sqlite-activation-state-store-fk.test.js.map +1 -0
- package/core/dist/runtime-v2/activation/__tests__/sqlite-activation-state-store.test.js +12 -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-fk.test.d.ts +2 -0
- package/core/dist/runtime-v2/activation/__tests__/sqlite-approval-store-fk.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/activation/__tests__/sqlite-approval-store-fk.test.js +56 -0
- package/core/dist/runtime-v2/activation/__tests__/sqlite-approval-store-fk.test.js.map +1 -0
- package/core/dist/runtime-v2/activation/__tests__/sqlite-approval-store.test.js +8 -0
- package/core/dist/runtime-v2/activation/__tests__/sqlite-approval-store.test.js.map +1 -1
- package/core/dist/runtime-v2/activation/__tests__/story-a-acceptance.test.js +20 -0
- package/core/dist/runtime-v2/activation/__tests__/story-a-acceptance.test.js.map +1 -1
- 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 +6 -0
- 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.map +1 -1
- package/core/dist/runtime-v2/activation/sqlite-approval-store.js +86 -32
- package/core/dist/runtime-v2/activation/sqlite-approval-store.js.map +1 -1
- package/core/dist/runtime-v2/activation/writers/__tests__/rule-host-writer.test.js +158 -1
- package/core/dist/runtime-v2/activation/writers/__tests__/rule-host-writer.test.js.map +1 -1
- package/core/dist/runtime-v2/activation/writers/rule-host-writer.d.ts +11 -0
- package/core/dist/runtime-v2/activation/writers/rule-host-writer.d.ts.map +1 -1
- package/core/dist/runtime-v2/activation/writers/rule-host-writer.js +55 -11
- package/core/dist/runtime-v2/activation/writers/rule-host-writer.js.map +1 -1
- package/core/dist/runtime-v2/diagnostician/__tests__/diag-rootcause-output.test.js +134 -15
- package/core/dist/runtime-v2/diagnostician/__tests__/diag-rootcause-output.test.js.map +1 -1
- package/core/dist/runtime-v2/diagnostician/__tests__/intent-tension-schema.test.d.ts +18 -0
- package/core/dist/runtime-v2/diagnostician/__tests__/intent-tension-schema.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/diagnostician/__tests__/intent-tension-schema.test.js +251 -0
- package/core/dist/runtime-v2/diagnostician/__tests__/intent-tension-schema.test.js.map +1 -0
- package/core/dist/runtime-v2/diagnostician/__tests__/rootcause-prompt-builder.test.js +73 -0
- package/core/dist/runtime-v2/diagnostician/__tests__/rootcause-prompt-builder.test.js.map +1 -1
- package/core/dist/runtime-v2/diagnostician/diag-rootcause-output.d.ts +98 -0
- package/core/dist/runtime-v2/diagnostician/diag-rootcause-output.d.ts.map +1 -1
- package/core/dist/runtime-v2/diagnostician/diag-rootcause-output.js +131 -0
- package/core/dist/runtime-v2/diagnostician/diag-rootcause-output.js.map +1 -1
- package/core/dist/runtime-v2/diagnostician/rootcause-prompt-builder.d.ts +8 -0
- package/core/dist/runtime-v2/diagnostician/rootcause-prompt-builder.d.ts.map +1 -1
- package/core/dist/runtime-v2/diagnostician/rootcause-prompt-builder.js +66 -3
- package/core/dist/runtime-v2/diagnostician/rootcause-prompt-builder.js.map +1 -1
- package/core/dist/runtime-v2/diagnostician-output.d.ts +23 -0
- package/core/dist/runtime-v2/diagnostician-output.d.ts.map +1 -1
- package/core/dist/runtime-v2/diagnostician-output.js +16 -0
- package/core/dist/runtime-v2/diagnostician-output.js.map +1 -1
- package/core/dist/runtime-v2/diagnostician-prompt-builder.d.ts +32 -0
- package/core/dist/runtime-v2/diagnostician-prompt-builder.d.ts.map +1 -1
- package/core/dist/runtime-v2/diagnostician-prompt-builder.js.map +1 -1
- package/core/dist/runtime-v2/evidence-triage/source-descriptors.d.ts +1 -1
- package/core/dist/runtime-v2/evidence-triage/source-descriptors.js +1 -1
- package/core/dist/runtime-v2/feature-flags/__tests__/feature-flag-contract.test.js +23 -0
- package/core/dist/runtime-v2/feature-flags/__tests__/feature-flag-contract.test.js.map +1 -1
- package/core/dist/runtime-v2/feature-flags/__tests__/intent-engineering-flag.test.d.ts +2 -0
- package/core/dist/runtime-v2/feature-flags/__tests__/intent-engineering-flag.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/feature-flags/__tests__/intent-engineering-flag.test.js +30 -0
- package/core/dist/runtime-v2/feature-flags/__tests__/intent-engineering-flag.test.js.map +1 -0
- package/core/dist/runtime-v2/feature-flags/__tests__/rulecode-context-v2-flag.test.d.ts +2 -0
- package/core/dist/runtime-v2/feature-flags/__tests__/rulecode-context-v2-flag.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/feature-flags/__tests__/rulecode-context-v2-flag.test.js +74 -0
- package/core/dist/runtime-v2/feature-flags/__tests__/rulecode-context-v2-flag.test.js.map +1 -0
- package/core/dist/runtime-v2/feature-flags/__tests__/surface-guard-policy.test.d.ts +2 -0
- package/core/dist/runtime-v2/feature-flags/__tests__/surface-guard-policy.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/feature-flags/__tests__/surface-guard-policy.test.js +246 -0
- package/core/dist/runtime-v2/feature-flags/__tests__/surface-guard-policy.test.js.map +1 -0
- 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 +9 -0
- package/core/dist/runtime-v2/feature-flags/feature-flag-contract.js.map +1 -1
- package/core/dist/runtime-v2/feature-flags/index.d.ts +2 -0
- package/core/dist/runtime-v2/feature-flags/index.d.ts.map +1 -1
- package/core/dist/runtime-v2/feature-flags/index.js +2 -0
- package/core/dist/runtime-v2/feature-flags/index.js.map +1 -1
- package/core/dist/runtime-v2/feature-flags/plugin-surface-registry.d.ts.map +1 -1
- package/core/dist/runtime-v2/feature-flags/plugin-surface-registry.js +0 -9
- package/core/dist/runtime-v2/feature-flags/plugin-surface-registry.js.map +1 -1
- package/{plugin/dist/core/surface-guard.d.ts → core/dist/runtime-v2/feature-flags/surface-guard-policy.d.ts} +15 -5
- package/core/dist/runtime-v2/feature-flags/surface-guard-policy.d.ts.map +1 -0
- package/{plugin/dist/core/surface-guard.js → core/dist/runtime-v2/feature-flags/surface-guard-policy.js} +14 -2
- package/core/dist/runtime-v2/feature-flags/surface-guard-policy.js.map +1 -0
- package/core/dist/runtime-v2/golden-trace-replay-validator.js +1 -1
- package/core/dist/runtime-v2/golden-trace-replay-validator.js.map +1 -1
- package/core/dist/runtime-v2/golden-trace.d.ts +19 -3
- package/core/dist/runtime-v2/golden-trace.d.ts.map +1 -1
- package/core/dist/runtime-v2/golden-trace.js +2 -0
- package/core/dist/runtime-v2/golden-trace.js.map +1 -1
- package/core/dist/runtime-v2/index.d.ts +21 -4
- package/core/dist/runtime-v2/index.d.ts.map +1 -1
- package/core/dist/runtime-v2/index.js +21 -3
- package/core/dist/runtime-v2/index.js.map +1 -1
- package/core/dist/runtime-v2/intent/__tests__/intent-decision-record.test.d.ts +2 -0
- package/core/dist/runtime-v2/intent/__tests__/intent-decision-record.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/intent/__tests__/intent-decision-record.test.js +185 -0
- package/core/dist/runtime-v2/intent/__tests__/intent-decision-record.test.js.map +1 -0
- package/core/dist/runtime-v2/intent/__tests__/intent-doc-version.test.d.ts +2 -0
- package/core/dist/runtime-v2/intent/__tests__/intent-doc-version.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/intent/__tests__/intent-doc-version.test.js +88 -0
- package/core/dist/runtime-v2/intent/__tests__/intent-doc-version.test.js.map +1 -0
- package/core/dist/runtime-v2/intent/__tests__/intent-doc.test.d.ts +2 -0
- package/core/dist/runtime-v2/intent/__tests__/intent-doc.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/intent/__tests__/intent-doc.test.js +181 -0
- package/core/dist/runtime-v2/intent/__tests__/intent-doc.test.js.map +1 -0
- package/core/dist/runtime-v2/intent/__tests__/intent-friction-block.test.d.ts +2 -0
- package/core/dist/runtime-v2/intent/__tests__/intent-friction-block.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/intent/__tests__/intent-friction-block.test.js +168 -0
- package/core/dist/runtime-v2/intent/__tests__/intent-friction-block.test.js.map +1 -0
- package/core/dist/runtime-v2/intent/__tests__/intent-patch-proposal.test.d.ts +2 -0
- package/core/dist/runtime-v2/intent/__tests__/intent-patch-proposal.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/intent/__tests__/intent-patch-proposal.test.js +121 -0
- package/core/dist/runtime-v2/intent/__tests__/intent-patch-proposal.test.js.map +1 -0
- package/core/dist/runtime-v2/intent/index.d.ts +8 -0
- package/core/dist/runtime-v2/intent/index.d.ts.map +1 -0
- package/core/dist/runtime-v2/intent/index.js +8 -0
- package/core/dist/runtime-v2/intent/index.js.map +1 -0
- package/core/dist/runtime-v2/intent/intent-browser.d.ts +23 -0
- package/core/dist/runtime-v2/intent/intent-browser.d.ts.map +1 -0
- package/core/dist/runtime-v2/intent/intent-browser.js +21 -0
- package/core/dist/runtime-v2/intent/intent-browser.js.map +1 -0
- package/core/dist/runtime-v2/intent/intent-decision-record.d.ts +125 -0
- package/core/dist/runtime-v2/intent/intent-decision-record.d.ts.map +1 -0
- package/core/dist/runtime-v2/intent/intent-decision-record.js +21 -0
- package/core/dist/runtime-v2/intent/intent-decision-record.js.map +1 -0
- package/core/dist/runtime-v2/intent/intent-doc-reader-port.d.ts +95 -0
- package/core/dist/runtime-v2/intent/intent-doc-reader-port.d.ts.map +1 -0
- package/core/dist/runtime-v2/intent/intent-doc-reader-port.js +43 -0
- package/core/dist/runtime-v2/intent/intent-doc-reader-port.js.map +1 -0
- package/core/dist/runtime-v2/intent/intent-doc-version.d.ts +28 -0
- package/core/dist/runtime-v2/intent/intent-doc-version.d.ts.map +1 -0
- package/core/dist/runtime-v2/intent/intent-doc-version.js +21 -0
- package/core/dist/runtime-v2/intent/intent-doc-version.js.map +1 -0
- package/core/dist/runtime-v2/intent/intent-doc.d.ts +35 -0
- package/core/dist/runtime-v2/intent/intent-doc.d.ts.map +1 -0
- package/core/dist/runtime-v2/intent/intent-doc.js +158 -0
- package/core/dist/runtime-v2/intent/intent-doc.js.map +1 -0
- package/core/dist/runtime-v2/intent/intent-friction-block.d.ts +63 -0
- package/core/dist/runtime-v2/intent/intent-friction-block.d.ts.map +1 -0
- package/core/dist/runtime-v2/intent/intent-friction-block.js +129 -0
- package/core/dist/runtime-v2/intent/intent-friction-block.js.map +1 -0
- package/core/dist/runtime-v2/intent/intent-hash.d.ts +2 -0
- package/core/dist/runtime-v2/intent/intent-hash.d.ts.map +1 -0
- package/core/dist/runtime-v2/intent/intent-hash.js +10 -0
- package/core/dist/runtime-v2/intent/intent-hash.js.map +1 -0
- package/core/dist/runtime-v2/intent/intent-patch-proposal.d.ts +42 -0
- package/core/dist/runtime-v2/intent/intent-patch-proposal.d.ts.map +1 -0
- package/core/dist/runtime-v2/intent/intent-patch-proposal.js +81 -0
- package/core/dist/runtime-v2/intent/intent-patch-proposal.js.map +1 -0
- package/core/dist/runtime-v2/internalization/__tests__/__fixtures__/intent-tension-cases.d.ts +54 -0
- package/core/dist/runtime-v2/internalization/__tests__/__fixtures__/intent-tension-cases.d.ts.map +1 -0
- package/core/dist/runtime-v2/internalization/__tests__/__fixtures__/intent-tension-cases.js +219 -0
- package/core/dist/runtime-v2/internalization/__tests__/__fixtures__/intent-tension-cases.js.map +1 -0
- package/core/dist/runtime-v2/internalization/__tests__/artificer-prompt-builder.test.js +41 -1
- package/core/dist/runtime-v2/internalization/__tests__/artificer-prompt-builder.test.js.map +1 -1
- package/core/dist/runtime-v2/internalization/__tests__/artificer-rule-output.test.js +130 -2
- package/core/dist/runtime-v2/internalization/__tests__/artificer-rule-output.test.js.map +1 -1
- package/core/dist/runtime-v2/internalization/__tests__/behavior-example-pack.test.d.ts +2 -0
- package/core/dist/runtime-v2/internalization/__tests__/behavior-example-pack.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/internalization/__tests__/behavior-example-pack.test.js +228 -0
- package/core/dist/runtime-v2/internalization/__tests__/behavior-example-pack.test.js.map +1 -0
- package/core/dist/runtime-v2/internalization/__tests__/diag-chain-e2e.test.js +41 -11
- package/core/dist/runtime-v2/internalization/__tests__/diag-chain-e2e.test.js.map +1 -1
- package/core/dist/runtime-v2/internalization/__tests__/diag-rootcause-intent-tension.test.d.ts +2 -0
- package/core/dist/runtime-v2/internalization/__tests__/diag-rootcause-intent-tension.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/internalization/__tests__/diag-rootcause-intent-tension.test.js +360 -0
- package/core/dist/runtime-v2/internalization/__tests__/diag-rootcause-intent-tension.test.js.map +1 -0
- package/core/dist/runtime-v2/internalization/__tests__/diag-router-intent-tension.test.d.ts +2 -0
- package/core/dist/runtime-v2/internalization/__tests__/diag-router-intent-tension.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/internalization/__tests__/diag-router-intent-tension.test.js +333 -0
- package/core/dist/runtime-v2/internalization/__tests__/diag-router-intent-tension.test.js.map +1 -0
- package/core/dist/runtime-v2/internalization/__tests__/intent-tension-cases.test.d.ts +2 -0
- package/core/dist/runtime-v2/internalization/__tests__/intent-tension-cases.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/internalization/__tests__/intent-tension-cases.test.js +113 -0
- package/core/dist/runtime-v2/internalization/__tests__/intent-tension-cases.test.js.map +1 -0
- package/core/dist/runtime-v2/internalization/__tests__/refiner-sandbox-wrapper.test.js +135 -0
- package/core/dist/runtime-v2/internalization/__tests__/refiner-sandbox-wrapper.test.js.map +1 -1
- package/core/dist/runtime-v2/internalization/__tests__/rule-context-v2.test.d.ts +2 -0
- package/core/dist/runtime-v2/internalization/__tests__/rule-context-v2.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/internalization/__tests__/rule-context-v2.test.js +449 -0
- package/core/dist/runtime-v2/internalization/__tests__/rule-context-v2.test.js.map +1 -0
- package/core/dist/runtime-v2/internalization/adversarial-case.d.ts.map +1 -1
- package/core/dist/runtime-v2/internalization/adversarial-case.js +24 -0
- package/core/dist/runtime-v2/internalization/adversarial-case.js.map +1 -1
- package/core/dist/runtime-v2/internalization/artificer-output.d.ts +10 -0
- package/core/dist/runtime-v2/internalization/artificer-output.d.ts.map +1 -1
- package/core/dist/runtime-v2/internalization/artificer-output.js +45 -0
- package/core/dist/runtime-v2/internalization/artificer-output.js.map +1 -1
- package/core/dist/runtime-v2/internalization/artificer-prompt-builder.d.ts +2 -2
- package/core/dist/runtime-v2/internalization/artificer-prompt-builder.d.ts.map +1 -1
- package/core/dist/runtime-v2/internalization/artificer-prompt-builder.js +7 -2
- package/core/dist/runtime-v2/internalization/artificer-prompt-builder.js.map +1 -1
- package/core/dist/runtime-v2/internalization/behavior-example-pack.d.ts +66 -0
- package/core/dist/runtime-v2/internalization/behavior-example-pack.d.ts.map +1 -0
- package/core/dist/runtime-v2/internalization/behavior-example-pack.js +183 -0
- package/core/dist/runtime-v2/internalization/behavior-example-pack.js.map +1 -0
- package/core/dist/runtime-v2/internalization/diag-rootcause-runner.d.ts +13 -0
- package/core/dist/runtime-v2/internalization/diag-rootcause-runner.d.ts.map +1 -1
- package/core/dist/runtime-v2/internalization/diag-rootcause-runner.js +42 -0
- package/core/dist/runtime-v2/internalization/diag-rootcause-runner.js.map +1 -1
- package/core/dist/runtime-v2/internalization/diag-router-runner.d.ts.map +1 -1
- package/core/dist/runtime-v2/internalization/diag-router-runner.js +27 -0
- package/core/dist/runtime-v2/internalization/diag-router-runner.js.map +1 -1
- package/core/dist/runtime-v2/internalization/evaluator-output.d.ts +8 -0
- package/core/dist/runtime-v2/internalization/evaluator-output.d.ts.map +1 -1
- package/core/dist/runtime-v2/internalization/evaluator-output.js +10 -0
- package/core/dist/runtime-v2/internalization/evaluator-output.js.map +1 -1
- package/core/dist/runtime-v2/internalization/evaluator-runner.d.ts +17 -0
- package/core/dist/runtime-v2/internalization/evaluator-runner.d.ts.map +1 -1
- package/core/dist/runtime-v2/internalization/evaluator-runner.js +118 -24
- package/core/dist/runtime-v2/internalization/evaluator-runner.js.map +1 -1
- package/core/dist/runtime-v2/internalization/refiner-sandbox-wrapper.d.ts.map +1 -1
- package/core/dist/runtime-v2/internalization/refiner-sandbox-wrapper.js +1 -1
- package/core/dist/runtime-v2/internalization/refiner-sandbox-wrapper.js.map +1 -1
- package/core/dist/runtime-v2/internalization/rule-context-v2.d.ts +61 -0
- package/core/dist/runtime-v2/internalization/rule-context-v2.d.ts.map +1 -0
- package/core/dist/runtime-v2/internalization/rule-context-v2.js +301 -0
- package/core/dist/runtime-v2/internalization/rule-context-v2.js.map +1 -0
- package/core/dist/runtime-v2/internalization/rule-host-contracts.d.ts +9 -0
- package/core/dist/runtime-v2/internalization/rule-host-contracts.d.ts.map +1 -1
- package/core/dist/runtime-v2/internalization/v2-adversarial-cases.d.ts +55 -0
- package/core/dist/runtime-v2/internalization/v2-adversarial-cases.d.ts.map +1 -0
- package/core/dist/runtime-v2/internalization/v2-adversarial-cases.js +131 -0
- package/core/dist/runtime-v2/internalization/v2-adversarial-cases.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 +280 -56
- package/core/dist/runtime-v2/pain-signal-observability.js.map +1 -1
- package/core/dist/runtime-v2/pain-signal-runtime-factory.d.ts +12 -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 +1 -1
- package/core/dist/runtime-v2/pain-signal-runtime-factory.js.map +1 -1
- package/core/dist/runtime-v2/pain-to-principle-service.d.ts +6 -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/principle-tree/ledger-codec.js.map +1 -1
- package/core/dist/runtime-v2/proven-channel-baseline.js +1 -1
- package/core/dist/runtime-v2/proven-channel-baseline.js.map +1 -1
- package/core/dist/runtime-v2/risk/__tests__/risk-calculator-policy.test.d.ts +2 -0
- package/core/dist/runtime-v2/risk/__tests__/risk-calculator-policy.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/risk/__tests__/risk-calculator-policy.test.js +95 -0
- package/core/dist/runtime-v2/risk/__tests__/risk-calculator-policy.test.js.map +1 -0
- package/core/dist/runtime-v2/risk/index.d.ts +7 -0
- package/core/dist/runtime-v2/risk/index.d.ts.map +1 -0
- package/core/dist/runtime-v2/risk/index.js +6 -0
- package/core/dist/runtime-v2/risk/index.js.map +1 -0
- package/core/dist/runtime-v2/risk/risk-calculator-policy.d.ts +18 -0
- package/core/dist/runtime-v2/risk/risk-calculator-policy.d.ts.map +1 -0
- package/core/dist/runtime-v2/risk/risk-calculator-policy.js +47 -0
- package/core/dist/runtime-v2/risk/risk-calculator-policy.js.map +1 -0
- package/core/dist/runtime-v2/store/artifact/__tests__/sqlite-pi-artifact-store-fk.test.d.ts +2 -0
- package/core/dist/runtime-v2/store/artifact/__tests__/sqlite-pi-artifact-store-fk.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/store/artifact/__tests__/sqlite-pi-artifact-store-fk.test.js +55 -0
- package/core/dist/runtime-v2/store/artifact/__tests__/sqlite-pi-artifact-store-fk.test.js.map +1 -0
- package/core/dist/runtime-v2/store/artifact/sqlite-pi-artifact-store.d.ts.map +1 -1
- package/core/dist/runtime-v2/store/artifact/sqlite-pi-artifact-store.js +6 -0
- package/core/dist/runtime-v2/store/artifact/sqlite-pi-artifact-store.js.map +1 -1
- package/core/dist/runtime-v2/store/intent/__tests__/sqlite-intent-decision-store.test.d.ts +2 -0
- package/core/dist/runtime-v2/store/intent/__tests__/sqlite-intent-decision-store.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/store/intent/__tests__/sqlite-intent-decision-store.test.js +272 -0
- package/core/dist/runtime-v2/store/intent/__tests__/sqlite-intent-decision-store.test.js.map +1 -0
- package/core/dist/runtime-v2/store/intent/__tests__/sqlite-intent-doc-version-store.test.d.ts +2 -0
- package/core/dist/runtime-v2/store/intent/__tests__/sqlite-intent-doc-version-store.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/store/intent/__tests__/sqlite-intent-doc-version-store.test.js +83 -0
- package/core/dist/runtime-v2/store/intent/__tests__/sqlite-intent-doc-version-store.test.js.map +1 -0
- package/core/dist/runtime-v2/store/intent/index.d.ts +7 -0
- package/core/dist/runtime-v2/store/intent/index.d.ts.map +1 -0
- package/core/dist/runtime-v2/store/intent/index.js +6 -0
- package/core/dist/runtime-v2/store/intent/index.js.map +1 -0
- package/core/dist/runtime-v2/store/intent/sqlite-intent-decision-store.d.ts +51 -0
- package/core/dist/runtime-v2/store/intent/sqlite-intent-decision-store.d.ts.map +1 -0
- package/core/dist/runtime-v2/store/intent/sqlite-intent-decision-store.js +306 -0
- package/core/dist/runtime-v2/store/intent/sqlite-intent-decision-store.js.map +1 -0
- package/core/dist/runtime-v2/store/intent/sqlite-intent-doc-version-store.d.ts +28 -0
- package/core/dist/runtime-v2/store/intent/sqlite-intent-doc-version-store.d.ts.map +1 -0
- package/core/dist/runtime-v2/store/intent/sqlite-intent-doc-version-store.js +88 -0
- package/core/dist/runtime-v2/store/intent/sqlite-intent-doc-version-store.js.map +1 -0
- package/core/dist/runtime-v2/store/sqlite-connection-pragma.test.js +14 -3
- package/core/dist/runtime-v2/store/sqlite-connection-pragma.test.js.map +1 -1
- package/core/dist/runtime-v2/store/sqlite-connection-schema-version.test.d.ts +2 -0
- package/core/dist/runtime-v2/store/sqlite-connection-schema-version.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/store/sqlite-connection-schema-version.test.js +72 -0
- package/core/dist/runtime-v2/store/sqlite-connection-schema-version.test.js.map +1 -0
- package/core/dist/runtime-v2/store/sqlite-connection.d.ts +27 -0
- package/core/dist/runtime-v2/store/sqlite-connection.d.ts.map +1 -1
- package/core/dist/runtime-v2/store/sqlite-connection.js +138 -12
- package/core/dist/runtime-v2/store/sqlite-connection.js.map +1 -1
- package/core/dist/runtime-v2/thinking-models/__tests__/thinking-models-policy.test.d.ts +2 -0
- package/core/dist/runtime-v2/thinking-models/__tests__/thinking-models-policy.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/thinking-models/__tests__/thinking-models-policy.test.js +149 -0
- package/core/dist/runtime-v2/thinking-models/__tests__/thinking-models-policy.test.js.map +1 -0
- package/core/dist/runtime-v2/thinking-models/index.d.ts +3 -0
- package/core/dist/runtime-v2/thinking-models/index.d.ts.map +1 -0
- package/core/dist/runtime-v2/thinking-models/index.js +3 -0
- package/core/dist/runtime-v2/thinking-models/index.js.map +1 -0
- package/core/dist/runtime-v2/thinking-models/thinking-models-policy.d.ts +73 -0
- package/core/dist/runtime-v2/thinking-models/thinking-models-policy.d.ts.map +1 -0
- package/core/dist/runtime-v2/thinking-models/thinking-models-policy.js +227 -0
- package/core/dist/runtime-v2/thinking-models/thinking-models-policy.js.map +1 -0
- package/core/dist/runtime-v2/tools/__tests__/artificer-l2-tool-contract.test.js +40 -1
- package/core/dist/runtime-v2/tools/__tests__/artificer-l2-tool-contract.test.js.map +1 -1
- package/core/dist/runtime-v2/tools/artificer-l2-tool-contract.d.ts.map +1 -1
- package/core/dist/runtime-v2/tools/artificer-l2-tool-contract.js +28 -1
- package/core/dist/runtime-v2/tools/artificer-l2-tool-contract.js.map +1 -1
- package/core/dist/runtime-v2/tools/artificer-output-typebox.d.ts +3 -0
- package/core/dist/runtime-v2/tools/artificer-output-typebox.d.ts.map +1 -1
- package/core/dist/runtime-v2/tools/artificer-output-typebox.js +3 -0
- package/core/dist/runtime-v2/tools/artificer-output-typebox.js.map +1 -1
- package/core/dist/runtime-v2/types/event-payload.d.ts +1 -20
- package/core/dist/runtime-v2/types/event-payload.d.ts.map +1 -1
- package/core/dist/runtime-v2/types/event-payload.js +0 -12
- package/core/dist/runtime-v2/types/event-payload.js.map +1 -1
- package/core/dist/runtime-v2/types/event-types.d.ts +5 -34
- package/core/dist/runtime-v2/types/event-types.d.ts.map +1 -1
- package/core/dist/runtime-v2/types/event-types.js +0 -19
- package/core/dist/runtime-v2/types/event-types.js.map +1 -1
- package/core/dist/runtime-v2/types/evidence-chain-contract.d.ts +63 -0
- package/core/dist/runtime-v2/types/evidence-chain-contract.d.ts.map +1 -1
- package/core/dist/runtime-v2/types/evidence-chain-contract.js +234 -9
- package/core/dist/runtime-v2/types/evidence-chain-contract.js.map +1 -1
- package/core/dist/runtime-v2/types/index.d.ts +5 -5
- package/core/dist/runtime-v2/types/index.d.ts.map +1 -1
- package/core/dist/runtime-v2/types/index.js +5 -3
- package/core/dist/runtime-v2/types/index.js.map +1 -1
- package/core/dist/runtime-v2/types/ledger-store.d.ts +30 -30
- package/core/dist/runtime-v2/types/ledger-store.d.ts.map +1 -1
- package/core/dist/runtime-v2/types/ledger-store.js +10 -5
- package/core/dist/runtime-v2/types/ledger-store.js.map +1 -1
- package/core/dist/workflow-funnel-loader.d.ts +2 -2
- package/core/dist/workflow-funnel-loader.d.ts.map +1 -1
- package/core/package.json +4 -0
- package/dist/installer.d.ts.map +1 -1
- package/dist/installer.js +16 -0
- package/dist/installer.js.map +1 -1
- package/package.json +1 -1
- package/pd-cli/dist/commands/__tests__/intent-flag-wiring.test.d.ts +9 -0
- package/pd-cli/dist/commands/__tests__/intent-flag-wiring.test.d.ts.map +1 -0
- package/pd-cli/dist/commands/__tests__/intent-flag-wiring.test.js +237 -0
- package/pd-cli/dist/commands/__tests__/intent-flag-wiring.test.js.map +1 -0
- package/pd-cli/dist/commands/intent.d.ts +76 -0
- package/pd-cli/dist/commands/intent.d.ts.map +1 -0
- package/pd-cli/dist/commands/intent.js +411 -0
- package/pd-cli/dist/commands/intent.js.map +1 -0
- package/pd-cli/dist/commands/runtime-init.d.ts +43 -0
- package/pd-cli/dist/commands/runtime-init.d.ts.map +1 -0
- package/pd-cli/dist/commands/runtime-init.js +264 -0
- package/pd-cli/dist/commands/runtime-init.js.map +1 -0
- package/pd-cli/dist/index.js +25 -0
- package/pd-cli/dist/index.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 +6 -0
- package/pd-cli/dist/services/demo-story-a-runner.js.map +1 -1
- package/pd-cli/package.json +1 -0
- package/plugin/dist/commands/pain.js +2 -0
- package/plugin/dist/core/behavior-example-pack-assembler.d.ts +43 -0
- package/plugin/dist/core/behavior-example-pack-assembler.js +247 -0
- package/plugin/dist/core/control-ui-db.d.ts +11 -0
- package/plugin/dist/core/control-ui-db.js +40 -16
- package/plugin/dist/core/event-log.js +0 -5
- package/plugin/dist/core/intent-doc-reader-adapter.d.ts +36 -0
- package/plugin/dist/core/intent-doc-reader-adapter.js +76 -0
- package/plugin/dist/core/intent-doc-reader.d.ts +89 -0
- package/plugin/dist/core/intent-doc-reader.js +210 -0
- package/plugin/dist/core/principle-tree-ledger.d.ts +27 -79
- package/plugin/dist/core/principle-tree-ledger.js +39 -524
- package/plugin/dist/core/reflection/reflection-context.d.ts +2 -2
- package/plugin/dist/core/rule-context-assembler.d.ts +45 -0
- package/plugin/dist/core/rule-context-assembler.js +148 -0
- package/plugin/dist/core/thinking-models.d.ts +12 -57
- package/plugin/dist/core/thinking-models.js +18 -224
- package/plugin/dist/core/trajectory-types.d.ts +18 -0
- package/plugin/dist/core/trajectory.d.ts +50 -2
- package/plugin/dist/core/trajectory.js +435 -254
- package/plugin/dist/core/workspace-context.d.ts +2 -3
- package/plugin/dist/hooks/gate.js +59 -2
- package/plugin/dist/hooks/pain.js +5 -0
- package/plugin/dist/hooks/prompt-helpers.d.ts +19 -1
- package/plugin/dist/hooks/prompt-helpers.js +39 -2
- package/plugin/dist/hooks/prompt-types.d.ts +8 -0
- package/plugin/dist/hooks/prompt.js +81 -21
- package/plugin/dist/index.d.ts +3 -1
- package/plugin/dist/index.js +10 -6
- package/plugin/dist/service/runtime-summary-service.js +1 -1
- package/plugin/dist/service/subagent-workflow/workflow-store.d.ts +14 -0
- package/plugin/dist/service/subagent-workflow/workflow-store.js +91 -2
- package/plugin/dist/types/event-types.d.ts +1 -1
- package/plugin/package.json +6 -3
- package/plugin/scripts/acceptance-test.mjs +3 -3
- package/plugin/dist/core/evolution-migration.d.ts +0 -5
- package/plugin/dist/core/evolution-migration.js +0 -65
- package/plugin/dist/core/principle-tree-ledger-adapter.d.ts +0 -32
- package/plugin/dist/core/principle-tree-ledger-adapter.js +0 -125
- package/plugin/dist/core/risk-calculator.d.ts +0 -22
- package/plugin/dist/core/risk-calculator.js +0 -88
- package/plugin/dist/core/rule-host-helpers.d.ts +0 -8
- package/plugin/dist/core/rule-host-helpers.js +0 -7
- package/plugin/dist/core/rule-host-types.d.ts +0 -7
- package/plugin/dist/core/rule-host-types.js +0 -7
- package/plugin/dist/core/schema/db-types.d.ts +0 -11
- package/plugin/dist/core/schema/db-types.js +0 -5
- package/plugin/dist/core/schema/index.d.ts +0 -17
- package/plugin/dist/core/schema/index.js +0 -15
- package/plugin/dist/core/schema/migration-runner.d.ts +0 -53
- package/plugin/dist/core/schema/migration-runner.js +0 -170
- package/plugin/dist/core/schema/migrations/001-init-trajectory.d.ts +0 -6
- package/plugin/dist/core/schema/migrations/001-init-trajectory.js +0 -190
- package/plugin/dist/core/schema/migrations/002-init-central.d.ts +0 -5
- package/plugin/dist/core/schema/migrations/002-init-central.js +0 -108
- package/plugin/dist/core/schema/migrations/003-init-workflow.d.ts +0 -5
- package/plugin/dist/core/schema/migrations/003-init-workflow.js +0 -50
- package/plugin/dist/core/schema/migrations/004-add-thinking-and-gfi.d.ts +0 -8
- package/plugin/dist/core/schema/migrations/004-add-thinking-and-gfi.js +0 -66
- package/plugin/dist/core/schema/migrations/index.d.ts +0 -16
- package/plugin/dist/core/schema/migrations/index.js +0 -27
- package/plugin/dist/core/schema/schema-definitions.d.ts +0 -46
- package/plugin/dist/core/schema/schema-definitions.js +0 -599
- package/plugin/dist/service/central-database.d.ts +0 -138
- package/plugin/dist/service/central-database.js +0 -731
- package/plugin/dist/service/central-sync-service.d.ts +0 -8
- package/plugin/dist/service/central-sync-service.js +0 -71
- package/plugin/scripts/db-migrate.mjs +0 -170
- package/plugin/scripts/validate-live-path.ts +0 -462
|
@@ -6,12 +6,11 @@ import { HygieneTracker } from './hygiene/tracker.js';
|
|
|
6
6
|
import { EvolutionReducerImpl } from './evolution-reducer.js';
|
|
7
7
|
import type { TrajectoryDatabase } from './trajectory.js';
|
|
8
8
|
import { PrincipleLifecycleService } from './principle-internalization/principle-lifecycle-service.js';
|
|
9
|
-
import { type PrincipleSubtree } from './principle-tree-ledger.js';
|
|
10
|
-
import type { Principle, PrincipleValueMetrics } from '../types/principle-tree-schema.js';
|
|
9
|
+
import { type PrincipleSubtree, type LedgerPrinciple, type PrincipleValueMetrics } from './principle-tree-ledger.js';
|
|
11
10
|
import type { Principle as ActivePrinciple } from './evolution-types.js';
|
|
12
11
|
interface PrincipleTreeLedgerAccessor {
|
|
13
12
|
getPrincipleSubtree(_principleId: string): PrincipleSubtree | undefined;
|
|
14
|
-
updatePrinciple(_principleId: string, updates: Partial<
|
|
13
|
+
updatePrinciple(_principleId: string, updates: Partial<LedgerPrinciple>): LedgerPrinciple;
|
|
15
14
|
updatePrincipleValueMetrics(principleId: string, _metrics: PrincipleValueMetrics): PrincipleValueMetrics;
|
|
16
15
|
}
|
|
17
16
|
/**
|
|
@@ -12,12 +12,14 @@ import { normalizePath } from '../utils/io.js';
|
|
|
12
12
|
import { WorkspaceContext } from '../core/workspace-context.js';
|
|
13
13
|
import { recordGateBlockAndReturn } from './gate-block-helper.js';
|
|
14
14
|
import { RuleHost } from '../core/rule-host.js';
|
|
15
|
-
import { validateCorrectionProposal, validateProposedPathBounds } from '@principles/core/runtime-v2';
|
|
15
|
+
import { validateCorrectionProposal, validateProposedPathBounds, computeFeatureFlagsFromConfig, UNAVAILABLE_RULE_CONTEXT } from '@principles/core/runtime-v2';
|
|
16
16
|
import { AGENT_TOOLS, BASH_TOOLS_SET, WRITE_TOOLS } from '../constants/tools.js';
|
|
17
17
|
import { getSession, hasRecentThinking } from '../core/session-tracker.js';
|
|
18
18
|
import { getEvolutionEngine } from '../core/evolution-engine.js';
|
|
19
19
|
import { EventLogService } from '../core/event-log.js';
|
|
20
|
-
import { estimateLineChanges } from '
|
|
20
|
+
import { estimateLineChanges } from '@principles/core/runtime-v2';
|
|
21
|
+
import { loadPdConfigForPlugin } from '../core/pd-config-loader.js';
|
|
22
|
+
import { buildProductionRuleContext } from '../core/rule-context-assembler.js';
|
|
21
23
|
export function handleBeforeToolCall(event, ctx) {
|
|
22
24
|
const logger = ctx.logger || console;
|
|
23
25
|
// 1. Identify tool type
|
|
@@ -53,6 +55,10 @@ export function handleBeforeToolCall(event, ctx) {
|
|
|
53
55
|
// 3. Rule Host Evaluation — sole gate
|
|
54
56
|
try {
|
|
55
57
|
const ruleHost = new RuleHost(wctx.stateDir, logger, { workspaceDir: ctx.workspaceDir });
|
|
58
|
+
// PRI-483 Phase 4: assemble RuleContextV2 when `rulecode_context_v2` flag is ON.
|
|
59
|
+
// flag OFF → undefined (v1 zero-change, no trajectory access).
|
|
60
|
+
// flag ON → RuleContextV2 (available or unavailable). Never throws (ERR-024).
|
|
61
|
+
const ruleContext = _buildRuleContextIfEnabled(wctx, relPath, ctx.sessionId, logger);
|
|
56
62
|
const hostInput = {
|
|
57
63
|
action: {
|
|
58
64
|
toolName: event.toolName,
|
|
@@ -80,6 +86,7 @@ export function handleBeforeToolCall(event, ctx) {
|
|
|
80
86
|
estimatedLineChanges: estimateLineChanges({ toolName: event.toolName, params: event.params ?? {} }),
|
|
81
87
|
bashRisk: _getBashRisk(event),
|
|
82
88
|
},
|
|
89
|
+
context: ruleContext,
|
|
83
90
|
};
|
|
84
91
|
const hostResult = ruleHost.evaluate(hostInput);
|
|
85
92
|
// Always emit rulehost_evaluated
|
|
@@ -379,3 +386,53 @@ function _getBashRisk(event) {
|
|
|
379
386
|
return 'unknown';
|
|
380
387
|
}
|
|
381
388
|
}
|
|
389
|
+
/**
|
|
390
|
+
* PRI-483 Phase 4 — Build RuleContextV2 for RuleHost.evaluate when the
|
|
391
|
+
* `rulecode_context_v2` feature flag is ON. Returns `undefined` when the flag
|
|
392
|
+
* is OFF (v1 zero-change — does NOT touch trajectory) or when config loading
|
|
393
|
+
* fails (conservative fail-soft: can't determine flag state → v1-style).
|
|
394
|
+
*
|
|
395
|
+
* ERR-024 prevention: context assembly failures never skip RuleHost.evaluate.
|
|
396
|
+
* - loadPdConfigForPlugin throws → return undefined (v1-style)
|
|
397
|
+
* - buildProductionRuleContext throws → return UNAVAILABLE_RULE_CONTEXT
|
|
398
|
+
* (structured unavailable so v2 rules see "context unavailable" and allow)
|
|
399
|
+
*
|
|
400
|
+
* Spec: docs/superpowers/specs/2026-06-27-rulecode-context-vision-design.md §5.3
|
|
401
|
+
*/
|
|
402
|
+
function _buildRuleContextIfEnabled(wctx, targetPath, sessionId, logger) {
|
|
403
|
+
// Step 1: load PD config (flag-gated). If this throws, we can't safely
|
|
404
|
+
// determine whether v2 context is required — fall back to v1 (undefined).
|
|
405
|
+
let configResult;
|
|
406
|
+
try {
|
|
407
|
+
configResult = loadPdConfigForPlugin(wctx.workspaceDir);
|
|
408
|
+
}
|
|
409
|
+
catch (err) {
|
|
410
|
+
logger?.warn?.(`[PD_GATE] RuleContext v2: config load failed, skipping context assembly: ${String(err)}`);
|
|
411
|
+
return undefined;
|
|
412
|
+
}
|
|
413
|
+
// Step 2: compute effective flags and check rulecode_context_v2.
|
|
414
|
+
// Explicit ok:false guard (rc-9-no-silent-fallback): when config is malformed,
|
|
415
|
+
// do NOT silently fall through to flag computation on defaults — log and
|
|
416
|
+
// return v1-style undefined so config issues surface to the operator.
|
|
417
|
+
if (!configResult.ok) {
|
|
418
|
+
const reasons = configResult.errors.map(e => e.reason).join('; ');
|
|
419
|
+
logger?.warn?.(`[PD_GATE] RuleContext v2: config load returned malformed result, skipping context assembly: ${reasons}`);
|
|
420
|
+
return undefined;
|
|
421
|
+
}
|
|
422
|
+
const flagsResult = computeFeatureFlagsFromConfig(configResult.effective);
|
|
423
|
+
const v2Flag = flagsResult.flags.rulecode_context_v2;
|
|
424
|
+
if (!v2Flag?.enabled) {
|
|
425
|
+
// Flag OFF → v1 zero-change. Do NOT access trajectory (spec §10.1).
|
|
426
|
+
return undefined;
|
|
427
|
+
}
|
|
428
|
+
// Step 3: flag ON → assemble context via production data source.
|
|
429
|
+
// buildProductionRuleContext is fail-soft internally (returns unavailable),
|
|
430
|
+
// but wrap in try/catch as defense-in-depth (ERR-024).
|
|
431
|
+
try {
|
|
432
|
+
return buildProductionRuleContext(sessionId, targetPath, wctx.trajectory, wctx.workspaceDir);
|
|
433
|
+
}
|
|
434
|
+
catch (err) {
|
|
435
|
+
logger?.warn?.(`[PD_GATE] RuleContext v2: buildProductionRuleContext threw unexpectedly, using unavailable context: ${String(err)}`);
|
|
436
|
+
return UNAVAILABLE_RULE_CONTEXT;
|
|
437
|
+
}
|
|
438
|
+
}
|
|
@@ -25,6 +25,7 @@ import { resolveWorkspaceDirForRuntimeV2 } from '../utils/workspace-resolver.js'
|
|
|
25
25
|
import { PainToPrincipleService, PrincipleTreeLedgerAdapter } from '@principles/core/runtime-v2';
|
|
26
26
|
import { evaluatePainDiagnosticGate } from '../core/pain-diagnostic-gate.js';
|
|
27
27
|
import { loadPdConfigForPlugin, loadFeatureFlagFromConfig } from '../core/pd-config-loader.js';
|
|
28
|
+
import { createIntentDocReader, resolveIntentLang } from '../core/intent-doc-reader-adapter.js';
|
|
28
29
|
import { evaluateTriggerController } from '@principles/core/runtime-v2';
|
|
29
30
|
import { isSharedCooldownActive, markSharedEpisodeAsDiagnosed } from './trigger-cooldown-tracker.js';
|
|
30
31
|
import { buildManualPainObservation, resolveSourceKind } from './raw-observation-adapter.js';
|
|
@@ -44,6 +45,10 @@ function createPainToPrincipleService(wctx) {
|
|
|
44
45
|
autoIntakeEnabled: true,
|
|
45
46
|
effectiveConfig: configResult.effective,
|
|
46
47
|
getEnvVar: (name) => process.env[name],
|
|
48
|
+
// PRI-468: wire INTENT.md reader so Stage A can produce intentTension
|
|
49
|
+
// when intent_engineering flag is on. Adapter performs no I/O beyond
|
|
50
|
+
// delegating to safeReadIntentDoc (which owns the flag-first check).
|
|
51
|
+
intentDocReader: createIntentDocReader(wctx.workspaceDir, resolveIntentLang(wctx.workspaceDir)),
|
|
47
52
|
});
|
|
48
53
|
}
|
|
49
54
|
// buildTrajectoryEvidence is in ./trajectory-evidence.ts (re-exported above)
|
|
@@ -76,12 +76,30 @@ export declare function formatEvolutionPrinciples(active: EvolutionPrincipleEntr
|
|
|
76
76
|
* Assemble appendSystemContext from ordered parts.
|
|
77
77
|
*
|
|
78
78
|
* Content order (most important last):
|
|
79
|
-
* behavioral_constraints → project_context → working_memory →
|
|
79
|
+
* behavioral_constraints → project_context → intent_block → working_memory →
|
|
80
80
|
* thinking_os → evolution_principles → core_principles
|
|
81
81
|
*
|
|
82
|
+
* PRI-467: intent_block (INTENT.md reference) sits after project_context
|
|
83
|
+
* (stable reference data, lower priority than principles) and before
|
|
84
|
+
* working_memory (volatile per-session state).
|
|
85
|
+
*
|
|
82
86
|
* Pure logic — string assembly only, no I/O.
|
|
83
87
|
*
|
|
84
88
|
* @param parts Ordered content parts (empty/undefined parts are skipped)
|
|
85
89
|
* @returns Assembled appendSystemContext (empty string if no parts)
|
|
86
90
|
*/
|
|
87
91
|
export declare function assembleAppendSystemContext(parts: AppendSystemContextParts): string;
|
|
92
|
+
/**
|
|
93
|
+
* Extracts short, distinct keyword phrases from an EmpathyObserver reason string.
|
|
94
|
+
*
|
|
95
|
+
* Used to feed newly detected expressions back into the keyword store, so the
|
|
96
|
+
* keyword-based fast path can catch them on future turns without re-running
|
|
97
|
+
* the more expensive observer.
|
|
98
|
+
*
|
|
99
|
+
* Pure function — no I/O, no side effects. Fully unit-testable.
|
|
100
|
+
*
|
|
101
|
+
* @param reason - observer's reason string (e.g., "用户表达了强烈的挫败感,提到反复尝试失败")
|
|
102
|
+
* @param lang - UI locale for minimum length threshold (zh=2 chars, en=3 chars)
|
|
103
|
+
* @returns deduplicated array of up to 3 candidate phrases
|
|
104
|
+
*/
|
|
105
|
+
export declare function extractPhrasesFromReason(reason: string, lang: 'zh' | 'en'): string[];
|
|
@@ -187,9 +187,13 @@ export function formatEvolutionPrinciples(active, probation) {
|
|
|
187
187
|
* Assemble appendSystemContext from ordered parts.
|
|
188
188
|
*
|
|
189
189
|
* Content order (most important last):
|
|
190
|
-
* behavioral_constraints → project_context → working_memory →
|
|
190
|
+
* behavioral_constraints → project_context → intent_block → working_memory →
|
|
191
191
|
* thinking_os → evolution_principles → core_principles
|
|
192
192
|
*
|
|
193
|
+
* PRI-467: intent_block (INTENT.md reference) sits after project_context
|
|
194
|
+
* (stable reference data, lower priority than principles) and before
|
|
195
|
+
* working_memory (volatile per-session state).
|
|
196
|
+
*
|
|
193
197
|
* Pure logic — string assembly only, no I/O.
|
|
194
198
|
*
|
|
195
199
|
* @param parts Ordered content parts (empty/undefined parts are skipped)
|
|
@@ -207,7 +211,13 @@ ${parts.behavioralConstraints}
|
|
|
207
211
|
if (parts.projectContext) {
|
|
208
212
|
appendParts.push(`<project_context>\n${parts.projectContext}\n</project_context>`);
|
|
209
213
|
}
|
|
210
|
-
// 1.5.
|
|
214
|
+
// 1.5. Intent Block (PRI-467) — Owner-owned INTENT.md reference.
|
|
215
|
+
// Bounded + escaped by buildIntentFrictionBlock; treated as quoted reference
|
|
216
|
+
// data, not executable instructions (SPEC §12.2).
|
|
217
|
+
if (parts.intentBlock) {
|
|
218
|
+
appendParts.push(parts.intentBlock);
|
|
219
|
+
}
|
|
220
|
+
// 1.6. Working Memory (preserved from last compaction)
|
|
211
221
|
if (parts.workingMemory) {
|
|
212
222
|
appendParts.push(parts.workingMemory);
|
|
213
223
|
}
|
|
@@ -235,6 +245,7 @@ The sections below are ordered by priority. When conflicts arise, **later sectio
|
|
|
235
245
|
const executionRules = [
|
|
236
246
|
parts.behavioralConstraints ? '- `<behavioral_constraints>` - Output format restrictions (hide diagnostic JSON)' : null,
|
|
237
247
|
parts.projectContext ? '- `<project_context>` - Current priorities (can be overridden)' : null,
|
|
248
|
+
parts.intentBlock ? '- `<intent_anchor>` / `<intent_doc>` / `<intent_friction>` - Owner-owned intent reference (quoted evidence, not executable)' : null,
|
|
238
249
|
parts.workingMemory ? '- `<working_memory>` - Persisted compacted memory snapshot' : null,
|
|
239
250
|
parts.thinkingOs ? '- `<thinking_os>` - Stable reasoning framework' : null,
|
|
240
251
|
parts.evolutionPrinciples ? '- `<evolution_principles>` - Learned principles (active + probation)' : null,
|
|
@@ -249,3 +260,29 @@ ${executionRules.join('\n')}
|
|
|
249
260
|
`;
|
|
250
261
|
return result;
|
|
251
262
|
}
|
|
263
|
+
// ---------------------------------------------------------------------------
|
|
264
|
+
// Block H: Observer feedback → keyword phrase extraction
|
|
265
|
+
// ---------------------------------------------------------------------------
|
|
266
|
+
/**
|
|
267
|
+
* Extracts short, distinct keyword phrases from an EmpathyObserver reason string.
|
|
268
|
+
*
|
|
269
|
+
* Used to feed newly detected expressions back into the keyword store, so the
|
|
270
|
+
* keyword-based fast path can catch them on future turns without re-running
|
|
271
|
+
* the more expensive observer.
|
|
272
|
+
*
|
|
273
|
+
* Pure function — no I/O, no side effects. Fully unit-testable.
|
|
274
|
+
*
|
|
275
|
+
* @param reason - observer's reason string (e.g., "用户表达了强烈的挫败感,提到反复尝试失败")
|
|
276
|
+
* @param lang - UI locale for minimum length threshold (zh=2 chars, en=3 chars)
|
|
277
|
+
* @returns deduplicated array of up to 3 candidate phrases
|
|
278
|
+
*/
|
|
279
|
+
export function extractPhrasesFromReason(reason, lang) {
|
|
280
|
+
const MAX_PHRASES = 3;
|
|
281
|
+
const MIN_LENGTH = lang === 'zh' ? 2 : 3;
|
|
282
|
+
const MAX_LENGTH = 20;
|
|
283
|
+
const segments = reason
|
|
284
|
+
.split(/[,,。.!!??、\n;;]/)
|
|
285
|
+
.map(s => s.trim())
|
|
286
|
+
.filter(s => s.length >= MIN_LENGTH && s.length <= MAX_LENGTH);
|
|
287
|
+
return [...new Set(segments)].slice(0, MAX_PHRASES);
|
|
288
|
+
}
|
|
@@ -55,6 +55,14 @@ export interface EvolutionPrincipleEntry extends CorePrincipleEntry {
|
|
|
55
55
|
export interface AppendSystemContextParts {
|
|
56
56
|
behavioralConstraints?: string;
|
|
57
57
|
projectContext?: string;
|
|
58
|
+
/**
|
|
59
|
+
* PRI-467: Intent Engineering friction block. Bounded + escaped INTENT.md
|
|
60
|
+
* reference. Positioned after projectContext (stable reference data, lower
|
|
61
|
+
* priority than principles) and before workingMemory (volatile per-session
|
|
62
|
+
* state). Only populated when intent_engineering flag is on and INTENT.md
|
|
63
|
+
* is valid.
|
|
64
|
+
*/
|
|
65
|
+
intentBlock?: string;
|
|
58
66
|
workingMemory?: string;
|
|
59
67
|
thinkingOs?: string;
|
|
60
68
|
evolutionPrinciples?: string;
|
|
@@ -11,7 +11,7 @@ import { selectPrinciplesForInjection, DEFAULT_PRINCIPLE_BUDGET } from '../core/
|
|
|
11
11
|
import { getCachedMaskedPrincipleSet, WorkflowFunnelLoader, PiAiRuntimeAdapter, EmpathyObserver, AgentScheduler, RUNTIME_V2_PRINCIPLE_BUDGET, trimToBudget, renderPrinciplesToDirectives } from '@principles/core/runtime-v2';
|
|
12
12
|
import { truncateInjectionToBudget } from '@principles/core/prompt-builder';
|
|
13
13
|
import { PromptActivationReader } from '../core/runtime-v2-prompt-activation-reader.js';
|
|
14
|
-
import { matchEmpathyKeywords, loadKeywordStore, saveKeywordStore, getKeywordStoreSummary, } from '../core/empathy-keyword-matcher.js';
|
|
14
|
+
import { matchEmpathyKeywords, loadKeywordStore, saveKeywordStore, applyKeywordUpdates, getKeywordStoreSummary, } from '../core/empathy-keyword-matcher.js';
|
|
15
15
|
import { severityToPenalty, DEFAULT_EMPATHY_KEYWORD_CONFIG } from '../core/empathy-types.js';
|
|
16
16
|
import { evaluatePainDiagnosticGate } from '../core/pain-diagnostic-gate.js';
|
|
17
17
|
import { emitPainDetectedEvent, buildTrajectoryEvidence } from './pain.js';
|
|
@@ -20,10 +20,13 @@ import { isSharedCooldownActive, markSharedEpisodeAsDiagnosed } from './trigger-
|
|
|
20
20
|
import { buildEmpathyObservation, resolveSourceKind } from './raw-observation-adapter.js';
|
|
21
21
|
import { evaluateEvidenceTriage } from './triage-adapter.js';
|
|
22
22
|
import { loadFeatureFlagFromConfig } from '../core/pd-config-loader.js';
|
|
23
|
+
import { safeReadIntentDoc, resetIntentDocCacheForTest } from '../core/intent-doc-reader.js';
|
|
24
|
+
import { resolveIntentLang } from '../core/intent-doc-reader-adapter.js';
|
|
25
|
+
import { buildIntentFrictionBlock } from '@principles/core/runtime-v2';
|
|
23
26
|
import { CorrectionCueLearner } from '../core/correction-cue-learner.js';
|
|
24
27
|
import { detectCorrectionCue as coreDetectCorrectionCue, escapeXml, extractMessageContent, isMinimalTrigger, } from '@principles/core/prompt-builder';
|
|
25
28
|
import { sanitizeForEvidence } from './message-sanitize.js';
|
|
26
|
-
import { buildAgentIdentity, buildEmpathySilenceConstraint, extractUserMessageFromPrompt, assembleHeartbeatChecklist, formatCorePrinciples, formatEvolutionPrinciples, assembleAppendSystemContext, } from './prompt-helpers.js';
|
|
29
|
+
import { buildAgentIdentity, buildEmpathySilenceConstraint, extractUserMessageFromPrompt, assembleHeartbeatChecklist, formatCorePrinciples, formatEvolutionPrinciples, assembleAppendSystemContext, extractPhrasesFromReason, } from './prompt-helpers.js';
|
|
27
30
|
// ---------------------------------------------------------------------------
|
|
28
31
|
// Static file cache — avoids re-reading rarely-changing files every message
|
|
29
32
|
// ---------------------------------------------------------------------------
|
|
@@ -103,10 +106,12 @@ export function resetPromptStateForTest(workspaceDir) {
|
|
|
103
106
|
if (workspaceDir) {
|
|
104
107
|
_staticFileCache.delete(workspaceDir);
|
|
105
108
|
_empathyState.delete(workspaceDir);
|
|
109
|
+
resetIntentDocCacheForTest(workspaceDir);
|
|
106
110
|
}
|
|
107
111
|
else {
|
|
108
112
|
_staticFileCache.clear();
|
|
109
113
|
_empathyState.clear();
|
|
114
|
+
resetIntentDocCacheForTest();
|
|
110
115
|
}
|
|
111
116
|
}
|
|
112
117
|
function parseContextInjectionConfig(value) {
|
|
@@ -301,6 +306,8 @@ export async function handleBeforePromptBuild(event, ctx) {
|
|
|
301
306
|
// Increment turn counter (Finding #3: session.turnCount doesn't exist)
|
|
302
307
|
empathyState.turnCounter++;
|
|
303
308
|
const turnCount = empathyState.turnCounter;
|
|
309
|
+
const painTrigger = wctx.config.get('thresholds.pain_trigger') || 40;
|
|
310
|
+
const highGfiThreshold = Math.max(wctx.config.get('severity_thresholds.high') || 70, painTrigger + 30);
|
|
304
311
|
if (matchResult.matched) {
|
|
305
312
|
const penalty = severityToPenalty(matchResult.severity, DEFAULT_EMPATHY_KEYWORD_CONFIG);
|
|
306
313
|
// trackFriction signature: (sessionId, deltaF: number, hash: string, workspaceDir?, options?)
|
|
@@ -310,8 +317,6 @@ export async function handleBeforePromptBuild(event, ctx) {
|
|
|
310
317
|
logger?.info?.(`[PD:Empathy] MATCH: "${matchResult.matchedTerms.join(', ')}" → severity=${matchResult.severity}, score=${matchResult.score.toFixed(2)}, penalty=${penalty}`);
|
|
311
318
|
const currentSession = getSession(sessionId);
|
|
312
319
|
const currentGfi = currentSession?.currentGfi ?? 0;
|
|
313
|
-
const painTrigger = wctx.config.get('thresholds.pain_trigger') || 40;
|
|
314
|
-
const highGfiThreshold = Math.max(wctx.config.get('severity_thresholds.high') || 70, painTrigger + 30);
|
|
315
320
|
if (currentGfi >= highGfiThreshold) {
|
|
316
321
|
const gfiPainScore = Math.min(Math.round(currentGfi), 60);
|
|
317
322
|
logger?.info?.(`[PD:Empathy] GFI-TRIGGERED: currentGfi=${currentGfi.toFixed(1)} >= highGfi=${highGfiThreshold}, emitting pain signal (score=${gfiPainScore})`);
|
|
@@ -447,7 +452,9 @@ export async function handleBeforePromptBuild(event, ctx) {
|
|
|
447
452
|
}
|
|
448
453
|
}
|
|
449
454
|
}
|
|
450
|
-
|
|
455
|
+
}
|
|
456
|
+
else {
|
|
457
|
+
// ── Pipeline: Observer only runs when keyword matcher misses ──
|
|
451
458
|
const observer = resolveEmpathyObserver(wctx, logger);
|
|
452
459
|
if (observer) {
|
|
453
460
|
const scheduler = new AgentScheduler();
|
|
@@ -456,14 +463,40 @@ export async function handleBeforePromptBuild(event, ctx) {
|
|
|
456
463
|
mode: 'realtime',
|
|
457
464
|
runner: observer,
|
|
458
465
|
});
|
|
459
|
-
logger?.info?.(`[PD:Empathy] Triggering background Empathy Observer
|
|
466
|
+
logger?.info?.(`[PD:Empathy] Pipeline: Triggering background Empathy Observer for unmatched message: "${msgPreview}"`);
|
|
460
467
|
void scheduler.dispatch('empathy-observer', { userMessage: latestUserMessage })
|
|
461
468
|
.then(async (result) => {
|
|
462
469
|
if (result.damageDetected) {
|
|
463
|
-
logger?.info?.(`[PD:Empathy] Background Empathy Observer detected damage. Severity: ${result.severity}, Reason: ${result.reason}`);
|
|
470
|
+
logger?.info?.(`[PD:Empathy] Pipeline: Background Empathy Observer detected damage. Severity: ${result.severity}, Reason: ${result.reason}`);
|
|
464
471
|
// ── Persistence Contract ──
|
|
465
472
|
const painScore = scoreFromSeverityForSpec(result.severity, wctx);
|
|
466
473
|
trackFriction(sessionId, painScore, `observer_empathy_${result.severity}`, workspaceDir, { source: 'user_empathy' });
|
|
474
|
+
// ── Pipeline: feed back newly detected expressions into keyword store ──
|
|
475
|
+
if (result.reason) {
|
|
476
|
+
const rawLang = wctx.config.get('language');
|
|
477
|
+
const lang = rawLang === 'en' ? 'en' : 'zh';
|
|
478
|
+
const phrases = extractPhrasesFromReason(result.reason, lang);
|
|
479
|
+
if (phrases.length > 0) {
|
|
480
|
+
const updates = {};
|
|
481
|
+
for (const phrase of phrases) {
|
|
482
|
+
if (!Object.hasOwn(keywordStore.terms, phrase)) {
|
|
483
|
+
updates[phrase] = {
|
|
484
|
+
action: 'add',
|
|
485
|
+
weight: 0.4,
|
|
486
|
+
falsePositiveRate: 0.3,
|
|
487
|
+
reasoning: `Discovered by empathy observer: ${result.reason.substring(0, 100)}`,
|
|
488
|
+
};
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
if (Object.keys(updates).length > 0) {
|
|
492
|
+
const { added } = applyKeywordUpdates(keywordStore, updates);
|
|
493
|
+
if (added > 0) {
|
|
494
|
+
saveKeywordStore(wctx.stateDir, keywordStore);
|
|
495
|
+
logger?.info?.(`[PD:Empathy] Pipeline: added ${added} new terms from observer feedback`);
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
}
|
|
467
500
|
const eventId = `emp_obs_${Date.now()}_${Math.random().toString(36).substring(2, 8)}`;
|
|
468
501
|
wctx.eventLog.recordPainSignal(sessionId, {
|
|
469
502
|
score: painScore,
|
|
@@ -520,7 +553,7 @@ export async function handleBeforePromptBuild(event, ctx) {
|
|
|
520
553
|
const sourceKind = resolveSourceKind(rawObs);
|
|
521
554
|
const triage = evaluateEvidenceTriage(sourceKind, freshGfiPainScore);
|
|
522
555
|
if (triage.decision !== 'admit') {
|
|
523
|
-
logger?.info?.(`[PD:Empathy]
|
|
556
|
+
logger?.info?.(`[PD:Empathy] Pipeline observer triage ${triage.decision}: ${triage.reason}`);
|
|
524
557
|
}
|
|
525
558
|
else {
|
|
526
559
|
const cooldownActive = isSharedCooldownActive(sourceKind, sessionId, 'empathy_gfi_observer');
|
|
@@ -534,7 +567,7 @@ export async function handleBeforePromptBuild(event, ctx) {
|
|
|
534
567
|
});
|
|
535
568
|
if (triggerDecision.shouldCreateDiagnosticTask) {
|
|
536
569
|
markSharedEpisodeAsDiagnosed(sourceKind, sessionId, 'empathy_gfi_observer');
|
|
537
|
-
logger?.info?.(`[PD:Empathy] Gate B approved (observer), calling emitPainDetectedEvent...`);
|
|
570
|
+
logger?.info?.(`[PD:Empathy] Pipeline Gate B approved (observer), calling emitPainDetectedEvent...`);
|
|
538
571
|
try {
|
|
539
572
|
const evidence = buildTrajectoryEvidence(wctx, sessionId);
|
|
540
573
|
// PRI-453: Reuse observerPainId for lineage consistency —
|
|
@@ -558,11 +591,11 @@ export async function handleBeforePromptBuild(event, ctx) {
|
|
|
558
591
|
}, { recordObservability: false });
|
|
559
592
|
}
|
|
560
593
|
catch (emitErr) {
|
|
561
|
-
logger?.error?.(`[PD:Empathy] FAILED to emit observer-triggered pain event: ${String(emitErr)}`);
|
|
594
|
+
logger?.error?.(`[PD:Empathy] Pipeline FAILED to emit observer-triggered pain event: ${String(emitErr)}`);
|
|
562
595
|
}
|
|
563
596
|
}
|
|
564
597
|
else {
|
|
565
|
-
logger?.info?.(`[PD:Empathy] Gate B skipped (observer): ${triggerDecision.reason}`);
|
|
598
|
+
logger?.info?.(`[PD:Empathy] Pipeline Gate B skipped (observer): ${triggerDecision.reason}`);
|
|
566
599
|
}
|
|
567
600
|
}
|
|
568
601
|
}
|
|
@@ -582,7 +615,7 @@ export async function handleBeforePromptBuild(event, ctx) {
|
|
|
582
615
|
},
|
|
583
616
|
});
|
|
584
617
|
if (gate.shouldDiagnose) {
|
|
585
|
-
logger?.info?.(`[PD:Empathy] GFI threshold crossed after background observer. Emitting pain signal...`);
|
|
618
|
+
logger?.info?.(`[PD:Empathy] Pipeline GFI threshold crossed after background observer. Emitting pain signal...`);
|
|
586
619
|
try {
|
|
587
620
|
const evidence = buildTrajectoryEvidence(wctx, sessionId);
|
|
588
621
|
// PRI-453: Reuse observerPainId for lineage consistency —
|
|
@@ -606,22 +639,20 @@ export async function handleBeforePromptBuild(event, ctx) {
|
|
|
606
639
|
}, { recordObservability: false });
|
|
607
640
|
}
|
|
608
641
|
catch (emitErr) {
|
|
609
|
-
logger?.error?.(`[PD:Empathy] FAILED to emit observer-triggered pain event: ${String(emitErr)}`);
|
|
642
|
+
logger?.error?.(`[PD:Empathy] Pipeline FAILED to emit observer-triggered pain event: ${String(emitErr)}`);
|
|
610
643
|
}
|
|
611
644
|
}
|
|
612
645
|
}
|
|
613
646
|
}
|
|
614
647
|
}
|
|
615
648
|
else {
|
|
616
|
-
logger?.info?.(`[PD:Empathy] Background Empathy Observer did not detect any damage.`);
|
|
649
|
+
logger?.info?.(`[PD:Empathy] Pipeline: Background Empathy Observer did not detect any damage.`);
|
|
617
650
|
}
|
|
618
651
|
})
|
|
619
652
|
.catch((err) => {
|
|
620
|
-
logger?.warn?.(`[PD:Empathy] Background analysis failed or rejected: ${String(err)}`);
|
|
653
|
+
logger?.warn?.(`[PD:Empathy] Pipeline: Background analysis failed or rejected: ${String(err)}`);
|
|
621
654
|
});
|
|
622
655
|
}
|
|
623
|
-
}
|
|
624
|
-
else {
|
|
625
656
|
// Log unmatched messages periodically for coverage analysis
|
|
626
657
|
if (turnCount > 0 && turnCount % 50 === 0) {
|
|
627
658
|
const sampleMsg = latestUserMessage.substring(0, 80).replace(/\n/g, ' ');
|
|
@@ -871,11 +902,38 @@ export async function handleBeforePromptBuild(event, ctx) {
|
|
|
871
902
|
catch (e) {
|
|
872
903
|
logger?.warn?.(`[PD:RuntimeV2] Failed to read Runtime V2 prompt activations: ${String(e)}`);
|
|
873
904
|
}
|
|
905
|
+
// ── PRI-467: Intent Engineering — INTENT.md friction block injection ──
|
|
906
|
+
// SPEC §5: flag off → no fs access, no cache access, no injection, no telemetry.
|
|
907
|
+
// SPEC §13.1: inject only when flag on + INTENT.md exists + safeReadIntentDoc ok=true.
|
|
908
|
+
// SPEC §14.1 Mode A: prompt-only — no output-hook capture, no check_emitted counter.
|
|
909
|
+
let intentBlockContent;
|
|
910
|
+
try {
|
|
911
|
+
const intentFlag = loadFeatureFlagFromConfig(workspaceDir, 'intent_engineering', logger);
|
|
912
|
+
if (intentFlag.enabled) {
|
|
913
|
+
const intentResult = safeReadIntentDoc(workspaceDir, resolveIntentLang(workspaceDir), { logger });
|
|
914
|
+
if (intentResult.ok && intentResult.doc) {
|
|
915
|
+
const block = buildIntentFrictionBlock({ rawIntentMd: intentResult.doc.raw });
|
|
916
|
+
if (block.length > 0) {
|
|
917
|
+
intentBlockContent = block;
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
else if (!intentResult.ok && intentResult.reason !== 'not_found') {
|
|
921
|
+
// SPEC §13.1: missing file is silent (no debug noise). Other degraded
|
|
922
|
+
// paths (oversized, read_error, flag_disabled) log a debug reason.
|
|
923
|
+
logger?.debug?.(`[PD:Intent] INTENT.md injection skipped: reason=${intentResult.reason ?? 'unknown'}, nextAction=${intentResult.nextAction ?? 'none'}`);
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
catch (intentErr) {
|
|
928
|
+
// ERR-002 — fail-open: never let INTENT injection break the prompt hook.
|
|
929
|
+
logger?.warn?.(`[PD:Intent] INTENT injection failed, skipping: ${String(intentErr)}`);
|
|
930
|
+
}
|
|
874
931
|
// Build appendSystemContext with recency effect
|
|
875
|
-
// Content order (most important last): behavioral_constraints -> project_context -> working_memory -> reflection_log -> thinking_os -> principles
|
|
932
|
+
// Content order (most important last): behavioral_constraints -> project_context -> intent_block -> working_memory -> reflection_log -> thinking_os -> principles
|
|
876
933
|
appendSystemContext = assembleAppendSystemContext({
|
|
877
934
|
behavioralConstraints: shouldInjectBehavioralConstraints ? empathySilenceConstraint : undefined,
|
|
878
935
|
projectContext: projectContextContent || undefined,
|
|
936
|
+
intentBlock: intentBlockContent,
|
|
879
937
|
workingMemory: workingMemoryContent || undefined,
|
|
880
938
|
thinkingOs: thinkingOsContent || undefined,
|
|
881
939
|
evolutionPrinciples: evolutionPrinciplesContent || undefined,
|
|
@@ -892,10 +950,12 @@ export async function handleBeforePromptBuild(event, ctx) {
|
|
|
892
950
|
// routing helpers deleted per PRI-448. No routing-related content is injected.
|
|
893
951
|
// ──── 8. SIZE GUARD ────
|
|
894
952
|
// Delegates to @principles/core/prompt-builder/truncateInjectionToBudget
|
|
895
|
-
// which handles priority stripping: project_context →
|
|
896
|
-
// evolution_principles → reflection_log → reason: truncation → fallback.
|
|
953
|
+
// which handles priority stripping: project_context → intent_block →
|
|
954
|
+
// thinking_os → evolution_principles → reflection_log → reason: truncation → fallback.
|
|
955
|
+
// PRI-467: intentBlockContent is passed so the guard can strip INTENT by
|
|
956
|
+
// exact match before falling back to the nuclear option.
|
|
897
957
|
const result = truncateInjectionToBudget(prependSystemContext, prependContext, appendSystemContext, {
|
|
898
|
-
blocks: { projectContextContent, thinkingOsContent, evolutionPrinciplesContent },
|
|
958
|
+
blocks: { projectContextContent, intentBlockContent, thinkingOsContent, evolutionPrinciplesContent },
|
|
899
959
|
});
|
|
900
960
|
prependSystemContext = result.prependSystemContext;
|
|
901
961
|
prependContext = result.prependContext;
|
package/plugin/dist/index.d.ts
CHANGED
|
@@ -45,6 +45,8 @@ declare const plugin: {
|
|
|
45
45
|
description: string;
|
|
46
46
|
register(api: OpenClawPluginApi): void;
|
|
47
47
|
};
|
|
48
|
-
export { PrincipleTreeLedgerAdapter } from '
|
|
48
|
+
export { PrincipleTreeLedgerAdapter } from '@principles/core/runtime-v2';
|
|
49
49
|
export { loadFeatureFlagFromWorkspace, isRecord };
|
|
50
|
+
export { initTrajectorySchema } from './core/trajectory.js';
|
|
51
|
+
export { initWorkflowSchema } from './service/subagent-workflow/workflow-store.js';
|
|
50
52
|
export default plugin;
|
package/plugin/dist/index.js
CHANGED
|
@@ -31,7 +31,6 @@ import { CorrectionObserverService } from './service/correction-observer-service
|
|
|
31
31
|
import { InternalizationAutoConsumerService } from './service/internalization-auto-consumer-service.js';
|
|
32
32
|
import { TrajectoryService } from './service/trajectory-service.js';
|
|
33
33
|
import { PDTaskService } from './core/pd-task-service.js';
|
|
34
|
-
import { CentralSyncService } from './service/central-sync-service.js';
|
|
35
34
|
import { ensureWorkspaceTemplates } from './core/init.js';
|
|
36
35
|
import { migrateDirectoryStructure } from './core/migration.js';
|
|
37
36
|
import { migrateStaleWorkspaceGuidance } from './core/workspace-guidance-migrator.js';
|
|
@@ -39,7 +38,7 @@ import { SystemLogger } from './core/system-logger.js';
|
|
|
39
38
|
import { PathResolver } from './core/path-resolver.js';
|
|
40
39
|
import { resolveCommandWorkspaceDir, resolveToolHookWorkspaceDirSafe, resolveHookWorkspaceDir } from './utils/workspace-resolver.js';
|
|
41
40
|
import { validateWorkspaceDir } from './core/workspace-dir-validation.js';
|
|
42
|
-
import { checkSurfaceGuard, guardHook, guardService } from '
|
|
41
|
+
import { checkSurfaceGuard, guardHook, guardService } from '@principles/core/runtime-v2';
|
|
43
42
|
// Track started workspaces — one-time init + evolution worker per workspace
|
|
44
43
|
const startedWorkspaces = new Set();
|
|
45
44
|
// ── Conversation Access Health Check (PRI-343) ────────────────────────────
|
|
@@ -408,9 +407,6 @@ const plugin = {
|
|
|
408
407
|
const guardedPdTask = guardService('service:pd-task', PDTaskService, api.logger);
|
|
409
408
|
if (guardedPdTask)
|
|
410
409
|
api.registerService(guardedPdTask);
|
|
411
|
-
const guardedCentralSync = guardService('service:central-sync', CentralSyncService, api.logger);
|
|
412
|
-
if (guardedCentralSync)
|
|
413
|
-
api.registerService(guardedCentralSync);
|
|
414
410
|
const guardedAutoConsumer = guardService('service:internalization-auto-consumer', InternalizationAutoConsumerService, api.logger);
|
|
415
411
|
if (guardedAutoConsumer)
|
|
416
412
|
api.registerService(guardedAutoConsumer);
|
|
@@ -745,7 +741,15 @@ const plugin = {
|
|
|
745
741
|
});
|
|
746
742
|
}
|
|
747
743
|
};
|
|
748
|
-
|
|
744
|
+
// PrincipleTreeLedgerAdapter is exported from @principles/core/runtime-v2 (canonical,
|
|
745
|
+
// consolidated in PRI-459). The plugin-local duplicate was removed; re-export the core
|
|
746
|
+
// symbol so any external consumer importing from the plugin still resolves it.
|
|
747
|
+
export { PrincipleTreeLedgerAdapter } from '@principles/core/runtime-v2';
|
|
749
748
|
/* istanbul ignore next — test exports for evolution worker gate */
|
|
750
749
|
export { loadFeatureFlagFromWorkspace, isRecord };
|
|
750
|
+
// Schema initialization exports for `pd runtime init` (unified DB init).
|
|
751
|
+
// These functions open the DB in write mode, apply the full schema, and close the DB.
|
|
752
|
+
// They do NOT run runtime side-effects (importLegacyArtifacts, pruneUnreferencedBlobs).
|
|
753
|
+
export { initTrajectorySchema } from './core/trajectory.js';
|
|
754
|
+
export { initWorkflowSchema } from './service/subagent-workflow/workflow-store.js';
|
|
751
755
|
export default plugin;
|
|
@@ -16,7 +16,7 @@ function pushWarning(warnings, message) {
|
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
|
-
* YAML-SSOT-03: resolve a dot-path (e.g. 'evolution.
|
|
19
|
+
* YAML-SSOT-03: resolve a dot-path (e.g. 'evolution.rulehostEvaluated') from dailyStats.
|
|
20
20
|
* Returns { count, resolvable } to distinguish "field not found / non-numeric" from "legitimate zero".
|
|
21
21
|
*/
|
|
22
22
|
function resolveStatsField(stats, dotPath) {
|
|
@@ -28,3 +28,17 @@ export declare class WorkflowStore {
|
|
|
28
28
|
recordDuration(workflowId: string, durationMs: number): void;
|
|
29
29
|
getCompletionDurations(workflowType: string, limit?: number): number[];
|
|
30
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Initialize subagent_workflows.db schema at the given workspace directory.
|
|
33
|
+
*
|
|
34
|
+
* Opens the DB in write mode, applies the full schema (tables + indexes + migrations),
|
|
35
|
+
* then closes the DB. Used by `pd runtime init` for unified DB initialization.
|
|
36
|
+
*
|
|
37
|
+
* Idempotent: safe to call on an existing DB; all CREATE statements use IF NOT EXISTS.
|
|
38
|
+
*
|
|
39
|
+
* @returns list of created/verified table names and any warnings
|
|
40
|
+
*/
|
|
41
|
+
export declare function initWorkflowSchema(workspaceDir: string): {
|
|
42
|
+
tables: string[];
|
|
43
|
+
warnings: string[];
|
|
44
|
+
};
|