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
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DiagRouterRunner — PRI-468 Stage C intentTension additive passthrough tests.
|
|
3
|
+
*
|
|
4
|
+
* Verifies SPEC §18 requirements:
|
|
5
|
+
* 1. Stage A has intentTension → Stage C passes it through
|
|
6
|
+
* 2. Stage A has NO intentTension → Stage C does NOT generate one
|
|
7
|
+
* 3. Stage A has NO intentTension + LLM hallucinated one → Stage C strips it
|
|
8
|
+
* 4. Stage A has intentTension + LLM also produced one → Stage A wins (source of truth)
|
|
9
|
+
*
|
|
10
|
+
* ERR entries considered:
|
|
11
|
+
* - EP-01 / ERR-001: context.rootCauseOutput is schema-validated before reaching here
|
|
12
|
+
* - EP-01 / ERR-013: Object.hasOwn used for field presence check (not `in`)
|
|
13
|
+
* - EP-02 / ERR-009: fail-loud on missing required fields via schema validation
|
|
14
|
+
* - EP-03 / ERR-002: stripping hallucinated intentTension emits telemetry (observable)
|
|
15
|
+
*/
|
|
16
|
+
import { describe, it, expect, vi } from 'vitest';
|
|
17
|
+
import { DiagRouterRunner } from '../diag-router-runner.js';
|
|
18
|
+
import { MemoryPIArtifactStore } from '../pi-artifact-store.js';
|
|
19
|
+
import { createPITaskDiagnosticJson } from '../pitask-metadata.js';
|
|
20
|
+
import { MOCK_ROOT_CAUSE_OUTPUTS, MOCK_DISTILLER_OUTPUTS, MOCK_ROUTER_OUTPUTS } from './__fixtures__/split-pipeline-mock-outputs.js';
|
|
21
|
+
// ── Test fixtures ────────────────────────────────────────────────────────────
|
|
22
|
+
const ROUTER_TASK_ID = 'diag_router-001';
|
|
23
|
+
const ROOTCAUSE_TASK_ID = 'diag_rootcause-001';
|
|
24
|
+
const DISTILLER_TASK_ID = 'diag_distiller-001';
|
|
25
|
+
const RUN_ID = 'run-router-001';
|
|
26
|
+
const OWNER = 'test-router-intent-owner';
|
|
27
|
+
const RUNTIME_KIND = 'test-double';
|
|
28
|
+
const ROOTCAUSE_ARTIFACT_ID = 'pi-art-rc-001';
|
|
29
|
+
const DISTILLER_ARTIFACT_ID = 'pi-art-dist-001';
|
|
30
|
+
const VALID_INTENT_TENSION = {
|
|
31
|
+
source: 'action_drift',
|
|
32
|
+
evidenceStrength: 'moderate',
|
|
33
|
+
relatedIntentFields: ['current_strategic_focus', 'non_negotiables'],
|
|
34
|
+
evidence: [
|
|
35
|
+
'INTENT says current focus is validating the smallest Pain → Principle loop.',
|
|
36
|
+
'Agent designed a heavy dashboard.',
|
|
37
|
+
'Owner correction says the result increased review burden.',
|
|
38
|
+
],
|
|
39
|
+
explanation: 'The work may be useful later, but it optimized presentation completeness before validating the current learning loop.',
|
|
40
|
+
suggestedOwnerAction: 'confirm_drift',
|
|
41
|
+
intentDocHash: 'sha256:abc123',
|
|
42
|
+
};
|
|
43
|
+
function makeRootCauseTask(overrides = {}) {
|
|
44
|
+
return {
|
|
45
|
+
taskId: ROOTCAUSE_TASK_ID,
|
|
46
|
+
taskKind: 'diag_rootcause',
|
|
47
|
+
status: 'succeeded',
|
|
48
|
+
attemptCount: 1,
|
|
49
|
+
maxAttempts: 3,
|
|
50
|
+
resultRef: 'diag-rootcause://run-rc-001',
|
|
51
|
+
createdAt: new Date().toISOString(),
|
|
52
|
+
updatedAt: new Date().toISOString(),
|
|
53
|
+
diagnosticJson: '{}',
|
|
54
|
+
...overrides,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function makeDistillerTask(overrides = {}) {
|
|
58
|
+
return {
|
|
59
|
+
taskId: DISTILLER_TASK_ID,
|
|
60
|
+
taskKind: 'diag_distiller',
|
|
61
|
+
status: 'succeeded',
|
|
62
|
+
attemptCount: 1,
|
|
63
|
+
maxAttempts: 3,
|
|
64
|
+
resultRef: 'diag-distiller://run-dist-001',
|
|
65
|
+
createdAt: new Date().toISOString(),
|
|
66
|
+
updatedAt: new Date().toISOString(),
|
|
67
|
+
diagnosticJson: '{}',
|
|
68
|
+
...overrides,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function makeRouterTask(overrides = {}) {
|
|
72
|
+
return {
|
|
73
|
+
taskId: ROUTER_TASK_ID,
|
|
74
|
+
taskKind: 'diag_router',
|
|
75
|
+
status: 'pending',
|
|
76
|
+
attemptCount: 0,
|
|
77
|
+
maxAttempts: 3,
|
|
78
|
+
createdAt: new Date().toISOString(),
|
|
79
|
+
updatedAt: new Date().toISOString(),
|
|
80
|
+
diagnosticJson: createPITaskDiagnosticJson({
|
|
81
|
+
dependencyTaskIds: [ROOTCAUSE_TASK_ID, DISTILLER_TASK_ID],
|
|
82
|
+
channel: 'prompt',
|
|
83
|
+
timeoutMs: 300_000,
|
|
84
|
+
inputArtifactRefs: [],
|
|
85
|
+
outputArtifactRefs: [],
|
|
86
|
+
}),
|
|
87
|
+
...overrides,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
function makeRootCauseOutput(intentTension) {
|
|
91
|
+
const base = {
|
|
92
|
+
...MOCK_ROOT_CAUSE_OUTPUTS.R6,
|
|
93
|
+
diagnosisId: 'diag-001',
|
|
94
|
+
taskId: ROOTCAUSE_TASK_ID,
|
|
95
|
+
};
|
|
96
|
+
return intentTension ? { ...base, intentTension } : base;
|
|
97
|
+
}
|
|
98
|
+
function makeDistillerOutput() {
|
|
99
|
+
return {
|
|
100
|
+
...MOCK_DISTILLER_OUTPUTS.R6,
|
|
101
|
+
taskId: DISTILLER_TASK_ID,
|
|
102
|
+
sourceRootCauseArtifactId: ROOTCAUSE_ARTIFACT_ID,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
function makeRouterOutput(intentTension) {
|
|
106
|
+
const base = {
|
|
107
|
+
...MOCK_ROUTER_OUTPUTS.R6,
|
|
108
|
+
diagnosisId: 'diag-001',
|
|
109
|
+
};
|
|
110
|
+
if (intentTension !== undefined) {
|
|
111
|
+
return { ...base, intentTension: intentTension };
|
|
112
|
+
}
|
|
113
|
+
return base;
|
|
114
|
+
}
|
|
115
|
+
/** Pre-populate a MemoryPIArtifactStore with both predecessor artifacts. */
|
|
116
|
+
function populatePredecessorArtifacts(store, rootCauseOutput) {
|
|
117
|
+
store.upsertArtifact({
|
|
118
|
+
artifactId: ROOTCAUSE_ARTIFACT_ID,
|
|
119
|
+
artifactKind: 'principle',
|
|
120
|
+
sourceTaskId: ROOTCAUSE_TASK_ID,
|
|
121
|
+
lineageArtifactIds: [],
|
|
122
|
+
validationStatus: 'pending',
|
|
123
|
+
contentJson: JSON.stringify(rootCauseOutput),
|
|
124
|
+
createdAt: new Date().toISOString(),
|
|
125
|
+
updatedAt: new Date().toISOString(),
|
|
126
|
+
});
|
|
127
|
+
store.upsertArtifact({
|
|
128
|
+
artifactId: DISTILLER_ARTIFACT_ID,
|
|
129
|
+
artifactKind: 'principle',
|
|
130
|
+
sourceTaskId: DISTILLER_TASK_ID,
|
|
131
|
+
lineageArtifactIds: [ROOTCAUSE_ARTIFACT_ID],
|
|
132
|
+
validationStatus: 'pending',
|
|
133
|
+
contentJson: JSON.stringify(makeDistillerOutput()),
|
|
134
|
+
createdAt: new Date().toISOString(),
|
|
135
|
+
updatedAt: new Date().toISOString(),
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
// ── Mock factory ─────────────────────────────────────────────────────────────
|
|
139
|
+
function createMockDeps(rootCauseOutput, routerOutput, overrides = {}) {
|
|
140
|
+
const taskRecord = makeRouterTask();
|
|
141
|
+
const _stateManager = {
|
|
142
|
+
acquireLease: vi.fn().mockResolvedValue(taskRecord),
|
|
143
|
+
getTask: vi.fn().mockImplementation((id) => {
|
|
144
|
+
if (id === ROUTER_TASK_ID)
|
|
145
|
+
return Promise.resolve(taskRecord);
|
|
146
|
+
if (id === ROOTCAUSE_TASK_ID)
|
|
147
|
+
return Promise.resolve(makeRootCauseTask());
|
|
148
|
+
if (id === DISTILLER_TASK_ID)
|
|
149
|
+
return Promise.resolve(makeDistillerTask());
|
|
150
|
+
return Promise.resolve(undefined);
|
|
151
|
+
}),
|
|
152
|
+
getRunsByTask: vi.fn().mockResolvedValue([{ runId: RUN_ID, taskId: ROUTER_TASK_ID }]),
|
|
153
|
+
getValidRunsByTaskTolerant: vi.fn().mockResolvedValue({
|
|
154
|
+
runs: [{ runId: RUN_ID, taskId: ROUTER_TASK_ID }],
|
|
155
|
+
degradedRuns: [],
|
|
156
|
+
}),
|
|
157
|
+
updateRunOutput: vi.fn().mockResolvedValue(undefined),
|
|
158
|
+
markTaskSucceeded: vi.fn().mockResolvedValue(undefined),
|
|
159
|
+
markTaskFailed: vi.fn().mockResolvedValue(undefined),
|
|
160
|
+
markTaskRetryWait: vi.fn().mockResolvedValue(undefined),
|
|
161
|
+
getRetryPolicy: vi.fn().mockReturnValue({ shouldRetry: () => false }),
|
|
162
|
+
};
|
|
163
|
+
const runHandle = { runId: RUN_ID, runtimeKind: RUNTIME_KIND, startedAt: new Date().toISOString() };
|
|
164
|
+
const succeededStatus = { status: 'succeeded', runId: RUN_ID };
|
|
165
|
+
const _runtimeAdapter = {
|
|
166
|
+
kind: vi.fn().mockReturnValue(RUNTIME_KIND),
|
|
167
|
+
getCapabilities: vi.fn(),
|
|
168
|
+
healthCheck: vi.fn(),
|
|
169
|
+
startRun: vi.fn().mockResolvedValue(runHandle),
|
|
170
|
+
pollRun: vi.fn().mockResolvedValue(succeededStatus),
|
|
171
|
+
fetchOutput: vi.fn().mockResolvedValue({ payload: routerOutput }),
|
|
172
|
+
cancelRun: vi.fn().mockResolvedValue(undefined),
|
|
173
|
+
fetchArtifacts: vi.fn(),
|
|
174
|
+
};
|
|
175
|
+
const commitResult = {
|
|
176
|
+
commitId: 'commit-001',
|
|
177
|
+
artifactId: 'art-001',
|
|
178
|
+
candidateCount: 1,
|
|
179
|
+
};
|
|
180
|
+
const _committer = {
|
|
181
|
+
commit: vi.fn().mockResolvedValue(commitResult),
|
|
182
|
+
};
|
|
183
|
+
const _eventEmitter = {
|
|
184
|
+
emitTelemetry: vi.fn(),
|
|
185
|
+
on: vi.fn(),
|
|
186
|
+
emit: vi.fn(),
|
|
187
|
+
};
|
|
188
|
+
const artifactStore = new MemoryPIArtifactStore();
|
|
189
|
+
populatePredecessorArtifacts(artifactStore, rootCauseOutput);
|
|
190
|
+
return {
|
|
191
|
+
stateManager: _stateManager,
|
|
192
|
+
runtimeAdapter: _runtimeAdapter,
|
|
193
|
+
eventEmitter: _eventEmitter,
|
|
194
|
+
artifactStore,
|
|
195
|
+
committer: _committer,
|
|
196
|
+
_stateManager,
|
|
197
|
+
_runtimeAdapter,
|
|
198
|
+
_committer,
|
|
199
|
+
_eventEmitter,
|
|
200
|
+
...overrides,
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
function telemetryEventType(call) {
|
|
204
|
+
const event = call[0];
|
|
205
|
+
return event?.eventType;
|
|
206
|
+
}
|
|
207
|
+
function telemetryPayload(call) {
|
|
208
|
+
const event = call[0];
|
|
209
|
+
return event?.payload;
|
|
210
|
+
}
|
|
211
|
+
// ── Tests ────────────────────────────────────────────────────────────────────
|
|
212
|
+
describe('DiagRouterRunner — PRI-468 Stage C intentTension passthrough', () => {
|
|
213
|
+
it('Stage A has intentTension → Stage C passes it through', async () => {
|
|
214
|
+
const rootCause = makeRootCauseOutput(VALID_INTENT_TENSION);
|
|
215
|
+
const routerOut = makeRouterOutput(); // LLM did NOT produce intentTension
|
|
216
|
+
const deps = createMockDeps(rootCause, routerOut);
|
|
217
|
+
const runner = new DiagRouterRunner(deps, {
|
|
218
|
+
owner: OWNER,
|
|
219
|
+
runtimeKind: RUNTIME_KIND,
|
|
220
|
+
pollIntervalMs: 10,
|
|
221
|
+
timeoutMs: 1000,
|
|
222
|
+
});
|
|
223
|
+
const result = await runner.run(ROUTER_TASK_ID);
|
|
224
|
+
expect(result.status).toBe('succeeded');
|
|
225
|
+
// Verify the committed output has intentTension from Stage A
|
|
226
|
+
const commitMock = deps._committer.commit;
|
|
227
|
+
if (!commitMock)
|
|
228
|
+
throw new Error('commit mock not configured');
|
|
229
|
+
const [commitCall] = commitMock.mock.calls;
|
|
230
|
+
const committedOutput = commitCall?.[0]?.output;
|
|
231
|
+
expect(committedOutput.intentTension).toBeDefined();
|
|
232
|
+
expect(committedOutput.intentTension).toEqual(VALID_INTENT_TENSION);
|
|
233
|
+
});
|
|
234
|
+
it('Stage A has NO intentTension → Stage C does NOT generate one', async () => {
|
|
235
|
+
const rootCause = makeRootCauseOutput(); // No intentTension
|
|
236
|
+
const routerOut = makeRouterOutput(); // LLM also did not produce one
|
|
237
|
+
const deps = createMockDeps(rootCause, routerOut);
|
|
238
|
+
const runner = new DiagRouterRunner(deps, {
|
|
239
|
+
owner: OWNER,
|
|
240
|
+
runtimeKind: RUNTIME_KIND,
|
|
241
|
+
pollIntervalMs: 10,
|
|
242
|
+
timeoutMs: 1000,
|
|
243
|
+
});
|
|
244
|
+
const result = await runner.run(ROUTER_TASK_ID);
|
|
245
|
+
expect(result.status).toBe('succeeded');
|
|
246
|
+
// Verify the committed output does NOT have intentTension
|
|
247
|
+
const commitMock = deps._committer.commit;
|
|
248
|
+
if (!commitMock)
|
|
249
|
+
throw new Error('commit mock not configured');
|
|
250
|
+
const [commitCall] = commitMock.mock.calls;
|
|
251
|
+
const committedOutput = commitCall?.[0]?.output;
|
|
252
|
+
expect(committedOutput.intentTension).toBeUndefined();
|
|
253
|
+
});
|
|
254
|
+
it('Stage A has NO intentTension + LLM hallucinated one → Stage C strips it with telemetry', async () => {
|
|
255
|
+
const rootCause = makeRootCauseOutput(); // No intentTension
|
|
256
|
+
// LLM hallucinated an intentTension
|
|
257
|
+
const hallucinatedTension = {
|
|
258
|
+
source: 'healthy_tension',
|
|
259
|
+
evidenceStrength: 'weak',
|
|
260
|
+
relatedIntentFields: ['why'],
|
|
261
|
+
evidence: ['fake evidence'],
|
|
262
|
+
explanation: 'hallucinated',
|
|
263
|
+
suggestedOwnerAction: 'dismiss',
|
|
264
|
+
};
|
|
265
|
+
const routerOut = makeRouterOutput(hallucinatedTension);
|
|
266
|
+
const deps = createMockDeps(rootCause, routerOut);
|
|
267
|
+
const runner = new DiagRouterRunner(deps, {
|
|
268
|
+
owner: OWNER,
|
|
269
|
+
runtimeKind: RUNTIME_KIND,
|
|
270
|
+
pollIntervalMs: 10,
|
|
271
|
+
timeoutMs: 1000,
|
|
272
|
+
});
|
|
273
|
+
const result = await runner.run(ROUTER_TASK_ID);
|
|
274
|
+
expect(result.status).toBe('succeeded');
|
|
275
|
+
// Verify the committed output does NOT have intentTension (stripped)
|
|
276
|
+
const commitMock = deps._committer.commit;
|
|
277
|
+
if (!commitMock)
|
|
278
|
+
throw new Error('commit mock not configured');
|
|
279
|
+
const [commitCall] = commitMock.mock.calls;
|
|
280
|
+
const committedOutput = commitCall?.[0]?.output;
|
|
281
|
+
expect(committedOutput.intentTension).toBeUndefined();
|
|
282
|
+
// Verify telemetry was emitted for the strip (EP-03 / ERR-002: observable)
|
|
283
|
+
const telemetryCalls = deps._eventEmitter.emitTelemetry.mock.calls.filter((call) => telemetryEventType(call) === 'diag_router_invariant_override');
|
|
284
|
+
const intentTensionCall = telemetryCalls.find((call) => telemetryPayload(call)?.field === 'intentTension');
|
|
285
|
+
expect(intentTensionCall).toBeDefined();
|
|
286
|
+
if (!intentTensionCall)
|
|
287
|
+
return; // type narrowing after assertion
|
|
288
|
+
const payload = telemetryPayload(intentTensionCall);
|
|
289
|
+
expect(payload?.field).toBe('intentTension');
|
|
290
|
+
expect(payload?.reason).toContain('stripped');
|
|
291
|
+
});
|
|
292
|
+
it('Stage A has intentTension + LLM also produced one → Stage A wins (source of truth)', async () => {
|
|
293
|
+
const rootCause = makeRootCauseOutput(VALID_INTENT_TENSION);
|
|
294
|
+
// LLM produced a DIFFERENT intentTension
|
|
295
|
+
const llmTension = {
|
|
296
|
+
source: 'none',
|
|
297
|
+
evidenceStrength: 'weak',
|
|
298
|
+
relatedIntentFields: ['why'],
|
|
299
|
+
evidence: ['llm evidence'],
|
|
300
|
+
explanation: 'llm explanation',
|
|
301
|
+
suggestedOwnerAction: 'observe',
|
|
302
|
+
};
|
|
303
|
+
const routerOut = makeRouterOutput(llmTension);
|
|
304
|
+
const deps = createMockDeps(rootCause, routerOut);
|
|
305
|
+
const runner = new DiagRouterRunner(deps, {
|
|
306
|
+
owner: OWNER,
|
|
307
|
+
runtimeKind: RUNTIME_KIND,
|
|
308
|
+
pollIntervalMs: 10,
|
|
309
|
+
timeoutMs: 1000,
|
|
310
|
+
});
|
|
311
|
+
const result = await runner.run(ROUTER_TASK_ID);
|
|
312
|
+
expect(result.status).toBe('succeeded');
|
|
313
|
+
// Verify the committed output has Stage A's intentTension (not LLM's)
|
|
314
|
+
const commitMock = deps._committer.commit;
|
|
315
|
+
if (!commitMock)
|
|
316
|
+
throw new Error('commit mock not configured');
|
|
317
|
+
const [commitCall] = commitMock.mock.calls;
|
|
318
|
+
const committedOutput = commitCall?.[0]?.output;
|
|
319
|
+
expect(committedOutput.intentTension).toEqual(VALID_INTENT_TENSION);
|
|
320
|
+
expect(committedOutput.intentTension).not.toEqual(llmTension);
|
|
321
|
+
// Verify telemetry was emitted for the override (filter to intentTension field —
|
|
322
|
+
// `evidence` is always overridden in postFetchTransform, so find() would match it first)
|
|
323
|
+
const telemetryCalls = deps._eventEmitter.emitTelemetry.mock.calls.filter((call) => telemetryEventType(call) === 'diag_router_invariant_override');
|
|
324
|
+
const intentTensionCall = telemetryCalls.find((call) => telemetryPayload(call)?.field === 'intentTension');
|
|
325
|
+
expect(intentTensionCall).toBeDefined();
|
|
326
|
+
if (!intentTensionCall)
|
|
327
|
+
return; // type narrowing after assertion
|
|
328
|
+
const payload = telemetryPayload(intentTensionCall);
|
|
329
|
+
expect(payload?.field).toBe('intentTension');
|
|
330
|
+
expect(payload?.reason).toContain('overridden');
|
|
331
|
+
});
|
|
332
|
+
});
|
|
333
|
+
//# sourceMappingURL=diag-router-intent-tension.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diag-router-intent-tension.test.js","sourceRoot":"","sources":["../../../../src/runtime-v2/internalization/__tests__/diag-router-intent-tension.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,QAAQ,EAAE,E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Ae,CAChF,CAAC;QACF,MAAM,CAAC,iBAAiB,CAAC,CAAC,WAAW,EAAE,CAAC;QACxC,IAAI,CAAC,iBAAiB;YAAE,OAAO,CAAC,iCAAiC;QACjE,MAAM,OAAO,GAAG,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;QACpD,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QAC7C,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"intent-tension-cases.test.d.ts","sourceRoot":"","sources":["../../../../src/runtime-v2/internalization/__tests__/intent-tension-cases.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A/B Evaluation Cases fixtures test (SPEC §23.5–§23.8).
|
|
3
|
+
*
|
|
4
|
+
* Validates the offline evaluation dataset:
|
|
5
|
+
* - 10 total cases (4 positive + 4 negative + 2 intent_suspect)
|
|
6
|
+
* - Positive cases: source ∈ {action_drift, healthy_tension}, strength ≥ moderate
|
|
7
|
+
* - Negative cases: no intentTension expected (null)
|
|
8
|
+
* - intent_suspect cases: source = intent_suspect, action = revise_intent
|
|
9
|
+
* - All expected intentTension values pass the IntentTensionSchema
|
|
10
|
+
* - No case carries a `confidence` field (SPEC §16.3)
|
|
11
|
+
*
|
|
12
|
+
* ERR entries considered:
|
|
13
|
+
* - EP-01 / ERR-001: fixtures validated against TypeBox schema at runtime
|
|
14
|
+
* - EP-02 / ERR-009: composition counts asserted fail-loud
|
|
15
|
+
* - EP-03 / ERR-002: negative cases explicitly assert null (no silent skip)
|
|
16
|
+
*/
|
|
17
|
+
import { describe, it, expect } from 'vitest';
|
|
18
|
+
import { Value } from '@sinclair/typebox/value';
|
|
19
|
+
import { IntentTensionSchema } from '../../diagnostician/diag-rootcause-output.js';
|
|
20
|
+
import { INTENT_TENSION_CASES, INTENT_TENSION_CASE_COUNTS, } from './__fixtures__/intent-tension-cases.js';
|
|
21
|
+
describe('IntentTension A/B evaluation cases (SPEC §23.5)', () => {
|
|
22
|
+
it('has the required composition: 4 positive + 4 negative + 2 intent_suspect = 10', () => {
|
|
23
|
+
expect(INTENT_TENSION_CASE_COUNTS.total).toBe(10);
|
|
24
|
+
expect(INTENT_TENSION_CASE_COUNTS.positive).toBe(4);
|
|
25
|
+
expect(INTENT_TENSION_CASE_COUNTS.negative).toBe(4);
|
|
26
|
+
expect(INTENT_TENSION_CASE_COUNTS.intent_suspect).toBe(2);
|
|
27
|
+
});
|
|
28
|
+
it('every case id is unique', () => {
|
|
29
|
+
const ids = INTENT_TENSION_CASES.map((c) => c.id);
|
|
30
|
+
expect(new Set(ids).size).toBe(ids.length);
|
|
31
|
+
});
|
|
32
|
+
it('every flag-off diagnosis has intentTension === undefined (SPEC §3: no new output when flag off)', () => {
|
|
33
|
+
for (const c of INTENT_TENSION_CASES) {
|
|
34
|
+
expect(c.flagOffDiagnosis.intentTension).toBeUndefined();
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
describe('positive cases (§23.6)', () => {
|
|
38
|
+
const positives = INTENT_TENSION_CASES.filter((c) => c.category === 'positive');
|
|
39
|
+
it('all have expected intentTension (not null)', () => {
|
|
40
|
+
for (const c of positives) {
|
|
41
|
+
expect(c.flagOnExpectedIntentTension, `case ${c.id}`).not.toBeNull();
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
it('source is action_drift or healthy_tension', () => {
|
|
45
|
+
for (const c of positives) {
|
|
46
|
+
const src = c.flagOnExpectedIntentTension?.source;
|
|
47
|
+
expect(src, `case ${c.id}`).toMatch(/^(action_drift|healthy_tension)$/);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
it('evidenceStrength is at least moderate', () => {
|
|
51
|
+
for (const c of positives) {
|
|
52
|
+
const strength = c.flagOnExpectedIntentTension?.evidenceStrength;
|
|
53
|
+
expect(strength, `case ${c.id}`).toMatch(/^(moderate|strong)$/);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
it('all expected intentTension values pass IntentTensionSchema', () => {
|
|
57
|
+
for (const c of positives) {
|
|
58
|
+
const tension = c.flagOnExpectedIntentTension;
|
|
59
|
+
expect(tension, `case ${c.id}`).toBeDefined();
|
|
60
|
+
if (!tension)
|
|
61
|
+
continue; // type narrowing after assertion
|
|
62
|
+
expect(Value.Check(IntentTensionSchema, tension), `case ${c.id}`).toBe(true);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
describe('negative cases (§23.7)', () => {
|
|
67
|
+
const negatives = INTENT_TENSION_CASES.filter((c) => c.category === 'negative');
|
|
68
|
+
it('all expect NO intentTension even with flag on (null)', () => {
|
|
69
|
+
for (const c of negatives) {
|
|
70
|
+
expect(c.flagOnExpectedIntentTension, `case ${c.id}`).toBeNull();
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
describe('intent_suspect cases (§23.8)', () => {
|
|
75
|
+
const suspects = INTENT_TENSION_CASES.filter((c) => c.category === 'intent_suspect');
|
|
76
|
+
it('all have source = intent_suspect', () => {
|
|
77
|
+
for (const c of suspects) {
|
|
78
|
+
expect(c.flagOnExpectedIntentTension?.source, `case ${c.id}`).toBe('intent_suspect');
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
it('all suggest revise_intent', () => {
|
|
82
|
+
for (const c of suspects) {
|
|
83
|
+
expect(c.flagOnExpectedIntentTension?.suggestedOwnerAction, `case ${c.id}`).toBe('revise_intent');
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
it('all expected intentTension values pass IntentTensionSchema', () => {
|
|
87
|
+
for (const c of suspects) {
|
|
88
|
+
const tension = c.flagOnExpectedIntentTension;
|
|
89
|
+
expect(tension, `case ${c.id}`).toBeDefined();
|
|
90
|
+
if (!tension)
|
|
91
|
+
continue; // type narrowing after assertion
|
|
92
|
+
expect(Value.Check(IntentTensionSchema, tension), `case ${c.id}`).toBe(true);
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
it('no expected intentTension carries a `confidence` field (SPEC §16.3)', () => {
|
|
97
|
+
for (const c of INTENT_TENSION_CASES) {
|
|
98
|
+
const tension = c.flagOnExpectedIntentTension;
|
|
99
|
+
if (tension === null)
|
|
100
|
+
continue;
|
|
101
|
+
expect(Object.hasOwn(tension, 'confidence'), `case ${c.id} must not carry confidence`).toBe(false);
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
it('all non-null expected intentTension values pass the schema (cross-cut)', () => {
|
|
105
|
+
for (const c of INTENT_TENSION_CASES) {
|
|
106
|
+
const tension = c.flagOnExpectedIntentTension;
|
|
107
|
+
if (tension === null)
|
|
108
|
+
continue;
|
|
109
|
+
expect(Value.Check(IntentTensionSchema, tension), `case ${c.id}`).toBe(true);
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
//# sourceMappingURL=intent-tension-cases.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"intent-tension-cases.test.js","sourceRoot":"","sources":["../../../../src/runtime-v2/internalization/__tests__/intent-tension-cases.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,8CAA8C,CAAC;AACnF,OAAO,EACL,oBAAoB,EACpB,0BAA0B,GAC3B,MAAM,wCAAwC,CAAC;AAEhD,QAAQ,CAAC,iDAAiD,EAAE,GAAG,EAAE;IAC/D,EAAE,CAAC,+EAA+E,EAAE,GAAG,EAAE;QACvF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ruleContext reaches the rule during replay (ERR-024) ────
|
|
764
|
+
describe('PRI-481 Phase 2 — ruleContext reaches VM during replay (ERR-024)', () => {
|
|
765
|
+
const contextWithOneRead = {
|
|
766
|
+
version: 2,
|
|
767
|
+
history: {
|
|
768
|
+
status: 'available',
|
|
769
|
+
truncated: false,
|
|
770
|
+
calls: [
|
|
771
|
+
{
|
|
772
|
+
sequenceId: 1,
|
|
773
|
+
toolName: 'read',
|
|
774
|
+
canonicalKind: 'read',
|
|
775
|
+
normalizedPath: 'src/a.ts',
|
|
776
|
+
paramsSummary: {},
|
|
777
|
+
outcome: 'success',
|
|
778
|
+
},
|
|
779
|
+
],
|
|
780
|
+
},
|
|
781
|
+
facts: {
|
|
782
|
+
priorReadOfTarget: 'yes',
|
|
783
|
+
readCount: 1,
|
|
784
|
+
writeCount: 0,
|
|
785
|
+
uniqueWritePathCount: 0,
|
|
786
|
+
sameActionBlockCount: 0,
|
|
787
|
+
},
|
|
788
|
+
};
|
|
789
|
+
// A rule that genuinely reads input.context — NOT a helper test. It blocks
|
|
790
|
+
// when history shows prior reads, allows otherwise. Proving the rule's
|
|
791
|
+
// decision flips based on context proves context actually arrived.
|
|
792
|
+
const contextReadingRule = (input) => {
|
|
793
|
+
const calls = input.context?.history?.calls;
|
|
794
|
+
if (Array.isArray(calls) && calls.length > 0) {
|
|
795
|
+
return { decision: 'block', matched: true, reason: 'history shows prior reads' };
|
|
796
|
+
}
|
|
797
|
+
return { decision: 'allow', matched: false, reason: 'no context or no reads' };
|
|
798
|
+
};
|
|
799
|
+
it('replay delivers input.context to the rule when case carries ruleContext', () => {
|
|
800
|
+
const trace = {
|
|
801
|
+
traceId: 'trace-ctx',
|
|
802
|
+
createdAt: '2026-06-28T00:00:00.000Z',
|
|
803
|
+
version: 1,
|
|
804
|
+
cases: [
|
|
805
|
+
{
|
|
806
|
+
caseId: 'neg-with-ctx',
|
|
807
|
+
kind: 'negative',
|
|
808
|
+
toolName: 'write_file',
|
|
809
|
+
params: { path: 'src/a.ts', content: 'x' },
|
|
810
|
+
expectedDecision: 'block',
|
|
811
|
+
ruleContext: contextWithOneRead,
|
|
812
|
+
},
|
|
813
|
+
{
|
|
814
|
+
caseId: 'pos-with-ctx',
|
|
815
|
+
kind: 'positive',
|
|
816
|
+
toolName: 'write_file',
|
|
817
|
+
params: { path: 'src/other.ts', content: 'y' },
|
|
818
|
+
expectedDecision: 'allow',
|
|
819
|
+
ruleContext: contextWithOneRead,
|
|
820
|
+
},
|
|
821
|
+
],
|
|
822
|
+
};
|
|
823
|
+
// Positive case expects allow but the rule blocks because context arrives
|
|
824
|
+
// with prior reads — this FAILS the positive case, which is the proof that
|
|
825
|
+
// context reached the rule (otherwise the rule would allow it).
|
|
826
|
+
const result = evaluateInRefinerSandbox('reads-context', trace, {
|
|
827
|
+
evaluateCode: contextReadingRule,
|
|
828
|
+
});
|
|
829
|
+
expect(result.success).toBe(false);
|
|
830
|
+
expect(result.failedCases.some((c) => c.caseId === 'pos-with-ctx')).toBe(true);
|
|
831
|
+
});
|
|
832
|
+
it('v1 case without ruleContext — input.context is undefined, rule allows (zero behavior change)', () => {
|
|
833
|
+
const trace = {
|
|
834
|
+
traceId: 'trace-v1',
|
|
835
|
+
createdAt: '2026-06-28T00:00:00.000Z',
|
|
836
|
+
version: 1,
|
|
837
|
+
cases: [
|
|
838
|
+
{
|
|
839
|
+
caseId: 'neg-v1',
|
|
840
|
+
kind: 'negative',
|
|
841
|
+
toolName: 'write_file',
|
|
842
|
+
params: { path: '/etc/passwd', content: 'hacked' },
|
|
843
|
+
expectedDecision: 'block',
|
|
844
|
+
},
|
|
845
|
+
{
|
|
846
|
+
caseId: 'pos-v1',
|
|
847
|
+
kind: 'positive',
|
|
848
|
+
toolName: 'write_file',
|
|
849
|
+
params: { path: '/safe.txt', content: 'ok' },
|
|
850
|
+
expectedDecision: 'allow',
|
|
851
|
+
},
|
|
852
|
+
],
|
|
853
|
+
};
|
|
854
|
+
// The same context-reading rule, but with no context it falls to allow.
|
|
855
|
+
// Negative case expects block → fails; positive case expects allow → passes.
|
|
856
|
+
// This proves v1 cases have input.context === undefined.
|
|
857
|
+
const result = evaluateInRefinerSandbox('reads-context', trace, {
|
|
858
|
+
evaluateCode: contextReadingRule,
|
|
859
|
+
});
|
|
860
|
+
expect(result.success).toBe(false);
|
|
861
|
+
expect(result.failedCases.some((c) => c.caseId === 'neg-v1')).toBe(true);
|
|
862
|
+
expect(result.failedCases.some((c) => c.caseId === 'pos-v1')).toBe(false);
|
|
863
|
+
});
|
|
864
|
+
it('a rule keyed on context passes ALL cases when expectations align with context', () => {
|
|
865
|
+
// Definitive positive proof: both cases expect block, context carries reads,
|
|
866
|
+
// the rule blocks both → success=true. If context did NOT arrive, the rule
|
|
867
|
+
// would allow both and both negative cases would fail.
|
|
868
|
+
const trace = {
|
|
869
|
+
traceId: 'trace-ctx-aligned',
|
|
870
|
+
createdAt: '2026-06-28T00:00:00.000Z',
|
|
871
|
+
version: 1,
|
|
872
|
+
cases: [
|
|
873
|
+
{
|
|
874
|
+
caseId: 'neg-ctx-a',
|
|
875
|
+
kind: 'negative',
|
|
876
|
+
toolName: 'write_file',
|
|
877
|
+
params: { path: 'src/a.ts', content: 'x' },
|
|
878
|
+
expectedDecision: 'block',
|
|
879
|
+
ruleContext: contextWithOneRead,
|
|
880
|
+
},
|
|
881
|
+
{
|
|
882
|
+
caseId: 'neg-ctx-b',
|
|
883
|
+
kind: 'negative',
|
|
884
|
+
toolName: 'write_file',
|
|
885
|
+
params: { path: 'src/b.ts', content: 'z' },
|
|
886
|
+
expectedDecision: 'block',
|
|
887
|
+
ruleContext: contextWithOneRead,
|
|
888
|
+
},
|
|
889
|
+
],
|
|
890
|
+
};
|
|
891
|
+
const result = evaluateInRefinerSandbox('reads-context', trace, {
|
|
892
|
+
evaluateCode: contextReadingRule,
|
|
893
|
+
});
|
|
894
|
+
expect(result.success).toBe(true);
|
|
895
|
+
expect(result.failedCases).toEqual([]);
|
|
896
|
+
});
|
|
897
|
+
});
|
|
763
898
|
//# sourceMappingURL=refiner-sandbox-wrapper.test.js.map
|