create-principles-disciple 1.150.4 → 1.151.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/README.md +5 -5
- package/_release/product-identity.json +1 -1
- package/codex-adapter/dist/ingestion/codex-version.d.ts +14 -12
- package/codex-adapter/dist/ingestion/codex-version.js +19 -20
- package/codex-adapter/dist/ingestion/ingestion.js +25 -4
- package/codex-adapter/dist/ingestion/transcript-decoder.d.ts +5 -3
- package/codex-adapter/dist/ingestion/transcript-decoder.js +61 -5
- package/codex-adapter/package.json +1 -1
- package/console/dist/server/bind-guard.d.ts +6 -13
- package/console/dist/server/bind-guard.js +8 -17
- package/console/dist/server/index.d.ts +9 -3
- package/console/dist/server/index.js +69 -55
- package/console/dist/server/models/ActivationsConsoleModel.js +5 -3
- package/console/dist/server/models/ApprovalsConsoleModel.js +2 -1
- package/console/dist/server/models/ApprovalsGroupedConsoleModel.js +2 -1
- package/console/dist/server/models/EvidenceChainConsoleModel.d.ts +46 -0
- package/console/dist/server/models/EvidenceChainConsoleModel.js +121 -2
- package/console/dist/server/models/GovernanceConsoleModel.js +3 -2
- package/console/dist/server/models/GovernanceExperienceCollector.js +2 -1
- package/console/dist/server/models/GovernanceProjectionCollector.js +2 -1
- package/console/dist/server/models/IngestionHealthModel.d.ts +34 -0
- package/console/dist/server/models/IngestionHealthModel.js +254 -0
- package/console/dist/server/models/IntentDecisionModel.js +2 -2
- package/console/dist/server/models/IntentPageModel.js +2 -1
- package/console/dist/server/models/OwnerDecisionConsoleModel.js +61 -22
- package/console/dist/server/models/OwnerDecisionViewModel.js +2 -2
- package/console/dist/server/models/PrincipleTrajectoryModel.js +2 -1
- package/console/dist/server/models/ReceiptsConsoleModel.js +2 -2
- package/console/dist/server/models/RuleCandidateBindingConsoleModel.js +3 -2
- package/console/dist/server/routes/activations.js +2 -2
- package/console/dist/server/routes/diagnostician.js +3 -2
- package/console/dist/server/routes/evidence-chain.d.ts +4 -0
- package/console/dist/server/routes/evidence-chain.js +22 -0
- package/console/dist/server/routes/evidence-outcomes.d.ts +3 -2
- package/console/dist/server/routes/evidence-outcomes.js +1 -1
- package/console/dist/server/routes/failed-tasks.js +79 -3
- package/console/dist/server/routes/governance.d.ts +9 -6
- package/console/dist/server/routes/governance.js +10 -6
- package/console/dist/server/routes/health.d.ts +8 -0
- package/console/dist/server/routes/health.js +72 -0
- package/console/dist/server/routes/owner-decisions.d.ts +3 -3
- package/console/dist/server/routes/owner-decisions.js +1 -1
- package/console/dist/server/routes/owner-identity.d.ts +10 -5
- package/console/dist/server/routes/owner-identity.js +11 -7
- package/console/dist/server/routes/principles.js +3 -3
- package/console/dist/server/routes/rule-candidate-bindings.js +1 -1
- package/console/dist/server/routes/update.js +24 -6
- package/console/dist/server/utils/request-guard.d.ts +35 -0
- package/console/dist/server/utils/request-guard.js +81 -0
- package/console/dist/server/utils/response.d.ts +0 -1
- package/console/dist/server/utils/response.js +0 -3
- package/console/dist/web/assets/app.css +98 -167
- package/console/dist/web/assets/app.js +34 -37
- package/core/dist/runtime/activation/activation-control-types.d.ts +3 -0
- package/core/dist/runtime/activation/activation-control-types.d.ts.map +1 -1
- package/core/dist/runtime/activation/adaptive-selection-output.d.ts +0 -21
- package/core/dist/runtime/activation/adaptive-selection-output.d.ts.map +1 -1
- package/core/dist/runtime/activation/adaptive-selection-output.js.map +1 -1
- package/core/dist/runtime/activation/index.d.ts +2 -6
- package/core/dist/runtime/activation/index.d.ts.map +1 -1
- package/core/dist/runtime/activation/index.js.map +1 -1
- package/core/dist/runtime/activation/production-gate-deps.d.ts +2 -1
- package/core/dist/runtime/activation/production-gate-deps.d.ts.map +1 -1
- package/core/dist/runtime/activation/prompt-activation-reader-contract.d.ts +2 -1
- package/core/dist/runtime/activation/prompt-activation-reader-contract.d.ts.map +1 -1
- package/core/dist/runtime/activation/rulecode-owner-decision-service.d.ts.map +1 -1
- package/core/dist/runtime/activation/rulecode-owner-decision-service.js +3 -2
- package/core/dist/runtime/activation/rulecode-owner-decision-service.js.map +1 -1
- package/core/dist/runtime/activation/sqlite-activation-safety-store.d.ts.map +1 -1
- package/core/dist/runtime/activation/sqlite-activation-safety-store.js +26 -13
- package/core/dist/runtime/activation/sqlite-activation-safety-store.js.map +1 -1
- package/core/dist/runtime/activation/writers/index.d.ts +0 -1
- package/core/dist/runtime/activation/writers/index.d.ts.map +1 -1
- package/core/dist/runtime/activation/writers/rule-host-writer.d.ts.map +1 -1
- package/core/dist/runtime/activation/writers/rule-host-writer.js +15 -6
- package/core/dist/runtime/activation/writers/rule-host-writer.js.map +1 -1
- package/core/dist/runtime/activation-compatibility-read-model.d.ts +3 -2
- package/core/dist/runtime/activation-compatibility-read-model.d.ts.map +1 -1
- package/core/dist/runtime/adapter/context-budget.d.ts +3 -14
- package/core/dist/runtime/adapter/context-budget.d.ts.map +1 -1
- package/core/dist/runtime/adapter/context-budget.js +2 -2
- package/core/dist/runtime/adapter/context-budget.js.map +1 -1
- package/core/dist/runtime/adapter/index.d.ts +1 -2
- package/core/dist/runtime/adapter/index.d.ts.map +1 -1
- package/core/dist/runtime/adapter/index.js +1 -1
- package/core/dist/runtime/adapter/index.js.map +1 -1
- package/core/dist/runtime/adapter/output-repair-contract.d.ts +18 -1
- package/core/dist/runtime/adapter/output-repair-contract.d.ts.map +1 -1
- package/core/dist/runtime/adapter/output-repair-contract.js +94 -0
- package/core/dist/runtime/adapter/output-repair-contract.js.map +1 -1
- package/core/dist/runtime/adapter/pi-ai-runtime-adapter.d.ts +2 -3
- package/core/dist/runtime/adapter/pi-ai-runtime-adapter.d.ts.map +1 -1
- package/core/dist/runtime/adapter/pi-ai-runtime-adapter.js +27 -10
- package/core/dist/runtime/adapter/pi-ai-runtime-adapter.js.map +1 -1
- package/core/dist/runtime/adapter/principle-tree-ledger-adapter.d.ts +1 -1
- package/core/dist/runtime/adapter/principle-tree-ledger-adapter.d.ts.map +1 -1
- package/core/dist/runtime/adapter/schema-prompt-adapter.d.ts +0 -1
- package/core/dist/runtime/adapter/schema-prompt-adapter.d.ts.map +1 -1
- package/core/dist/runtime/adapter/schema-prompt-adapter.js +43 -1
- package/core/dist/runtime/adapter/schema-prompt-adapter.js.map +1 -1
- package/core/dist/runtime/adapter/structured-output-repair.d.ts +17 -2
- package/core/dist/runtime/adapter/structured-output-repair.d.ts.map +1 -1
- package/core/dist/runtime/adapter/structured-output-repair.js +26 -5
- package/core/dist/runtime/adapter/structured-output-repair.js.map +1 -1
- package/core/dist/runtime/bridge-result-shaper.d.ts +1 -1
- package/core/dist/runtime/bridge-result-shaper.d.ts.map +1 -1
- package/core/dist/runtime/candidate-intake-service.d.ts +2 -1
- package/core/dist/runtime/candidate-intake-service.d.ts.map +1 -1
- package/core/dist/runtime/cli/diagnose.d.ts +4 -3
- package/core/dist/runtime/cli/diagnose.d.ts.map +1 -1
- package/core/dist/runtime/config/index.d.ts +2 -2
- package/core/dist/runtime/config/index.d.ts.map +1 -1
- package/core/dist/runtime/config/index.js +3 -3
- package/core/dist/runtime/config/index.js.map +1 -1
- package/core/dist/runtime/config/pd-config-defaults.d.ts +0 -2
- package/core/dist/runtime/config/pd-config-defaults.d.ts.map +1 -1
- package/core/dist/runtime/config/pd-config-defaults.js +2 -2
- package/core/dist/runtime/config/pd-config-defaults.js.map +1 -1
- package/core/dist/runtime/config/pd-config-types.d.ts +2 -0
- package/core/dist/runtime/config/pd-config-types.d.ts.map +1 -1
- package/core/dist/runtime/config/pd-config-types.js.map +1 -1
- package/core/dist/runtime/config/pd-config-validate.d.ts.map +1 -1
- package/core/dist/runtime/config/pd-config-validate.js +10 -1
- package/core/dist/runtime/config/pd-config-validate.js.map +1 -1
- package/core/dist/runtime/config/pd-profile-constants.d.ts +1 -7
- package/core/dist/runtime/config/pd-profile-constants.d.ts.map +1 -1
- package/core/dist/runtime/config/pd-profile-constants.js +5 -6
- package/core/dist/runtime/config/pd-profile-constants.js.map +1 -1
- package/core/dist/runtime/config/pd-validate-profile.d.ts +3 -2
- package/core/dist/runtime/config/pd-validate-profile.d.ts.map +1 -1
- package/core/dist/runtime/context-payload.d.ts +0 -7
- package/core/dist/runtime/context-payload.d.ts.map +1 -1
- package/core/dist/runtime/context-payload.js +1 -1
- package/core/dist/runtime/context-payload.js.map +1 -1
- package/core/dist/runtime/core-principles/index.d.ts +1 -1
- package/core/dist/runtime/core-principles/index.d.ts.map +1 -1
- package/core/dist/runtime/correction/correction-types.d.ts +0 -10
- package/core/dist/runtime/correction/correction-types.d.ts.map +1 -1
- package/core/dist/runtime/correction/correction-types.js.map +1 -1
- package/core/dist/runtime/diagnostician/diag-distiller-output.d.ts +0 -3
- package/core/dist/runtime/diagnostician/diag-distiller-output.d.ts.map +1 -1
- package/core/dist/runtime/diagnostician/diag-distiller-output.js +1 -1
- package/core/dist/runtime/diagnostician/diag-distiller-output.js.map +1 -1
- package/core/dist/runtime/diagnostician/diag-rootcause-output.d.ts +3 -11
- package/core/dist/runtime/diagnostician/diag-rootcause-output.d.ts.map +1 -1
- package/core/dist/runtime/diagnostician/diag-rootcause-output.js +3 -3
- package/core/dist/runtime/diagnostician/diag-rootcause-output.js.map +1 -1
- package/core/dist/runtime/diagnostician/distiller-prompt-builder.d.ts +5 -4
- package/core/dist/runtime/diagnostician/distiller-prompt-builder.d.ts.map +1 -1
- package/core/dist/runtime/diagnostician/evidence-ref-binding.d.ts +2 -1
- package/core/dist/runtime/diagnostician/evidence-ref-binding.d.ts.map +1 -1
- package/core/dist/runtime/diagnostician/rootcause-prompt-builder.d.ts +2 -1
- package/core/dist/runtime/diagnostician/rootcause-prompt-builder.d.ts.map +1 -1
- package/core/dist/runtime/diagnostician/router-prompt-builder.d.ts +22 -3
- package/core/dist/runtime/diagnostician/router-prompt-builder.d.ts.map +1 -1
- package/core/dist/runtime/diagnostician/router-prompt-builder.js +11 -1
- package/core/dist/runtime/diagnostician/router-prompt-builder.js.map +1 -1
- package/core/dist/runtime/diagnostician-association-shadow.d.ts +2 -2
- package/core/dist/runtime/diagnostician-association-shadow.d.ts.map +1 -1
- package/core/dist/runtime/diagnostician-association-validation.d.ts +3 -2
- package/core/dist/runtime/diagnostician-association-validation.d.ts.map +1 -1
- package/core/dist/runtime/diagnostician-output.d.ts +32 -5
- package/core/dist/runtime/diagnostician-output.d.ts.map +1 -1
- package/core/dist/runtime/diagnostician-output.js +47 -4
- package/core/dist/runtime/diagnostician-output.js.map +1 -1
- package/core/dist/runtime/diagnostician-prompt-builder.d.ts +2 -1
- package/core/dist/runtime/diagnostician-prompt-builder.d.ts.map +1 -1
- package/core/dist/runtime/error-categories.d.ts.map +1 -1
- package/core/dist/runtime/error-categories.js +10 -1
- package/core/dist/runtime/error-categories.js.map +1 -1
- package/core/dist/runtime/evidence-sanitizer.d.ts +8 -1
- package/core/dist/runtime/evidence-sanitizer.d.ts.map +1 -1
- package/core/dist/runtime/evidence-sanitizer.js +10 -3
- package/core/dist/runtime/evidence-sanitizer.js.map +1 -1
- package/core/dist/runtime/evolution/evolution-types.d.ts +0 -26
- package/core/dist/runtime/evolution/evolution-types.d.ts.map +1 -1
- package/core/dist/runtime/evolution/evolution-types.js.map +1 -1
- package/core/dist/runtime/feature-flags/index.d.ts +0 -1
- package/core/dist/runtime/feature-flags/index.d.ts.map +1 -1
- package/core/dist/runtime/feature-flags/index.js.map +1 -1
- package/core/dist/runtime/golden-trace.d.ts +9 -1
- package/core/dist/runtime/golden-trace.d.ts.map +1 -1
- package/core/dist/runtime/golden-trace.js +7 -0
- package/core/dist/runtime/golden-trace.js.map +1 -1
- package/core/dist/runtime/governance-experience-contract.d.ts +12 -12
- package/core/dist/runtime/governance-experience-contract.d.ts.map +1 -1
- package/core/dist/runtime/governance-experience-contract.js +0 -2
- package/core/dist/runtime/governance-experience-contract.js.map +1 -1
- package/core/dist/runtime/governance-experience.d.ts.map +1 -1
- package/core/dist/runtime/governance-experience.js +8 -16
- package/core/dist/runtime/governance-experience.js.map +1 -1
- package/core/dist/runtime/governance-projection-contract.d.ts +0 -6
- package/core/dist/runtime/governance-projection-contract.d.ts.map +1 -1
- package/core/dist/runtime/governance-projection-contract.js +3 -3
- package/core/dist/runtime/governance-projection-contract.js.map +1 -1
- package/core/dist/runtime/internalization/approved-rule-revision.d.ts.map +1 -1
- package/core/dist/runtime/internalization/approved-rule-revision.js +2 -1
- package/core/dist/runtime/internalization/approved-rule-revision.js.map +1 -1
- package/core/dist/runtime/internalization/artifact-summary.d.ts +5 -4
- package/core/dist/runtime/internalization/artifact-summary.d.ts.map +1 -1
- package/core/dist/runtime/internalization/artifact-summary.js +1 -1
- package/core/dist/runtime/internalization/artifact-summary.js.map +1 -1
- package/core/dist/runtime/internalization/artificer-intent-preflight.d.ts +1 -1
- package/core/dist/runtime/internalization/artificer-intent-preflight.d.ts.map +1 -1
- package/core/dist/runtime/internalization/artificer-output.d.ts +0 -2
- package/core/dist/runtime/internalization/artificer-output.d.ts.map +1 -1
- package/core/dist/runtime/internalization/artificer-output.js +17 -0
- package/core/dist/runtime/internalization/artificer-output.js.map +1 -1
- package/core/dist/runtime/internalization/artificer-prompt-builder.d.ts +14 -3
- package/core/dist/runtime/internalization/artificer-prompt-builder.d.ts.map +1 -1
- package/core/dist/runtime/internalization/artificer-prompt-builder.js +13 -1
- package/core/dist/runtime/internalization/artificer-prompt-builder.js.map +1 -1
- package/core/dist/runtime/internalization/artificer-run-correlation.d.ts +3 -2
- package/core/dist/runtime/internalization/artificer-run-correlation.d.ts.map +1 -1
- package/core/dist/runtime/internalization/consumer-evidence-preflight.d.ts +2 -1
- package/core/dist/runtime/internalization/consumer-evidence-preflight.d.ts.map +1 -1
- package/core/dist/runtime/internalization/diag-distiller-runner.d.ts +1 -1
- package/core/dist/runtime/internalization/diag-distiller-runner.d.ts.map +1 -1
- package/core/dist/runtime/internalization/diag-rootcause-runner.d.ts +1 -1
- package/core/dist/runtime/internalization/diag-rootcause-runner.d.ts.map +1 -1
- package/core/dist/runtime/internalization/diag-router-runner.d.ts +11 -1
- package/core/dist/runtime/internalization/diag-router-runner.d.ts.map +1 -1
- package/core/dist/runtime/internalization/diag-router-runner.js +105 -1
- package/core/dist/runtime/internalization/diag-router-runner.js.map +1 -1
- package/core/dist/runtime/internalization/dreamer-output.d.ts +0 -9
- package/core/dist/runtime/internalization/dreamer-output.d.ts.map +1 -1
- package/core/dist/runtime/internalization/dreamer-output.js +1 -1
- package/core/dist/runtime/internalization/dreamer-output.js.map +1 -1
- package/core/dist/runtime/internalization/dreamer-prompt-builder.d.ts +3 -2
- package/core/dist/runtime/internalization/dreamer-prompt-builder.d.ts.map +1 -1
- package/core/dist/runtime/internalization/dreamer-runner.d.ts +1 -1
- package/core/dist/runtime/internalization/dreamer-runner.d.ts.map +1 -1
- package/core/dist/runtime/internalization/evaluator-output.d.ts +7 -17
- package/core/dist/runtime/internalization/evaluator-output.d.ts.map +1 -1
- package/core/dist/runtime/internalization/evaluator-output.js +2 -2
- package/core/dist/runtime/internalization/evaluator-output.js.map +1 -1
- package/core/dist/runtime/internalization/evaluator-prompt-builder.d.ts +3 -9
- package/core/dist/runtime/internalization/evaluator-prompt-builder.d.ts.map +1 -1
- package/core/dist/runtime/internalization/evaluator-prompt-builder.js +1 -1
- package/core/dist/runtime/internalization/evaluator-prompt-builder.js.map +1 -1
- package/core/dist/runtime/internalization/formation-context.d.ts +4 -6
- package/core/dist/runtime/internalization/formation-context.d.ts.map +1 -1
- package/core/dist/runtime/internalization/formation-context.js +3 -3
- package/core/dist/runtime/internalization/formation-context.js.map +1 -1
- package/core/dist/runtime/internalization/index.d.ts +2 -4
- package/core/dist/runtime/internalization/index.d.ts.map +1 -1
- package/core/dist/runtime/internalization/index.js +8 -1
- package/core/dist/runtime/internalization/index.js.map +1 -1
- package/core/dist/runtime/internalization/intake-to-internalization-bridge.d.ts +2 -1
- package/core/dist/runtime/internalization/intake-to-internalization-bridge.d.ts.map +1 -1
- package/core/dist/runtime/internalization/intent-contract.d.ts +2 -1
- package/core/dist/runtime/internalization/intent-contract.d.ts.map +1 -1
- package/core/dist/runtime/internalization/internalization-job-graph.d.ts +1 -1
- package/core/dist/runtime/internalization/internalization-job-graph.d.ts.map +1 -1
- package/core/dist/runtime/internalization/internalization-route.d.ts +2 -1
- package/core/dist/runtime/internalization/internalization-route.d.ts.map +1 -1
- package/core/dist/runtime/internalization/owner-decision-review.d.ts +3 -2
- package/core/dist/runtime/internalization/owner-decision-review.d.ts.map +1 -1
- package/core/dist/runtime/internalization/owner-resolution-service.d.ts +2 -1
- package/core/dist/runtime/internalization/owner-resolution-service.d.ts.map +1 -1
- package/core/dist/runtime/internalization/owner-retry.d.ts +2 -1
- package/core/dist/runtime/internalization/owner-retry.d.ts.map +1 -1
- package/core/dist/runtime/internalization/owner-review.d.ts +2 -21
- package/core/dist/runtime/internalization/owner-review.d.ts.map +1 -1
- package/core/dist/runtime/internalization/owner-review.js +2 -2
- package/core/dist/runtime/internalization/owner-review.js.map +1 -1
- package/core/dist/runtime/internalization/peer-runner-contracts.d.ts +2 -5
- package/core/dist/runtime/internalization/peer-runner-contracts.d.ts.map +1 -1
- package/core/dist/runtime/internalization/peer-runner-contracts.js +1 -1
- package/core/dist/runtime/internalization/peer-runner-contracts.js.map +1 -1
- package/core/dist/runtime/internalization/philosopher-output.d.ts +0 -8
- package/core/dist/runtime/internalization/philosopher-output.d.ts.map +1 -1
- package/core/dist/runtime/internalization/philosopher-output.js +1 -1
- package/core/dist/runtime/internalization/philosopher-output.js.map +1 -1
- package/core/dist/runtime/internalization/philosopher-prompt-builder.d.ts +3 -2
- package/core/dist/runtime/internalization/philosopher-prompt-builder.d.ts.map +1 -1
- package/core/dist/runtime/internalization/pitask-metadata.d.ts +2 -2
- package/core/dist/runtime/internalization/pitask-metadata.d.ts.map +1 -1
- package/core/dist/runtime/internalization/repair-replay-resolver.d.ts +4 -3
- package/core/dist/runtime/internalization/repair-replay-resolver.d.ts.map +1 -1
- package/core/dist/runtime/internalization/rollout-reviewer-output.d.ts +2 -3
- package/core/dist/runtime/internalization/rollout-reviewer-output.d.ts.map +1 -1
- package/core/dist/runtime/internalization/rollout-reviewer-output.js.map +1 -1
- package/core/dist/runtime/internalization/rollout-reviewer-prompt-builder.d.ts +0 -1
- package/core/dist/runtime/internalization/rollout-reviewer-prompt-builder.d.ts.map +1 -1
- package/core/dist/runtime/internalization/rollout-reviewer-prompt-builder.js +1 -1
- package/core/dist/runtime/internalization/rollout-reviewer-prompt-builder.js.map +1 -1
- package/core/dist/runtime/internalization/router-context-reconstruction.d.ts +3 -3
- package/core/dist/runtime/internalization/router-context-reconstruction.d.ts.map +1 -1
- package/core/dist/runtime/internalization/rule-activation-contract.d.ts +3 -2
- package/core/dist/runtime/internalization/rule-activation-contract.d.ts.map +1 -1
- package/core/dist/runtime/internalization/rule-reliability-validation.d.ts +13 -18
- package/core/dist/runtime/internalization/rule-reliability-validation.d.ts.map +1 -1
- package/core/dist/runtime/internalization/rule-reliability-validation.js +43 -1
- package/core/dist/runtime/internalization/rule-reliability-validation.js.map +1 -1
- package/core/dist/runtime/internalization/scribe-output.d.ts +2 -15
- package/core/dist/runtime/internalization/scribe-output.d.ts.map +1 -1
- package/core/dist/runtime/internalization/scribe-output.js +2 -2
- package/core/dist/runtime/internalization/scribe-output.js.map +1 -1
- package/core/dist/runtime/internalization/scribe-prompt-builder.d.ts +3 -3
- package/core/dist/runtime/internalization/scribe-prompt-builder.d.ts.map +1 -1
- package/core/dist/runtime/internalization/scribe-prompt-builder.js +0 -1
- package/core/dist/runtime/internalization/scribe-prompt-builder.js.map +1 -1
- package/core/dist/runtime/internalization/split-diagnostician-runner.d.ts +17 -1
- package/core/dist/runtime/internalization/split-diagnostician-runner.d.ts.map +1 -1
- package/core/dist/runtime/internalization/split-diagnostician-runner.js +98 -3
- package/core/dist/runtime/internalization/split-diagnostician-runner.js.map +1 -1
- package/core/dist/runtime/internalization/textual-basis-anchor.d.ts +3 -6
- package/core/dist/runtime/internalization/textual-basis-anchor.d.ts.map +1 -1
- package/core/dist/runtime/internalization/textual-basis-anchor.js +2 -2
- package/core/dist/runtime/internalization/textual-basis-anchor.js.map +1 -1
- package/core/dist/runtime/language-directive.d.ts +2 -1
- package/core/dist/runtime/language-directive.d.ts.map +1 -1
- package/core/dist/runtime/owner-decision/owner-decision-view-contract.d.ts +3 -29
- package/core/dist/runtime/owner-decision/owner-decision-view-contract.d.ts.map +1 -1
- package/core/dist/runtime/owner-decision/owner-decision-view-contract.js +4 -5
- package/core/dist/runtime/owner-decision/owner-decision-view-contract.js.map +1 -1
- package/core/dist/runtime/owner-decision/owner-decision-view.d.ts +0 -49
- package/core/dist/runtime/owner-decision/owner-decision-view.d.ts.map +1 -1
- package/core/dist/runtime/owner-decision/owner-decision-view.js +5 -5
- package/core/dist/runtime/owner-decision/owner-decision-view.js.map +1 -1
- package/core/dist/runtime/owner-decision/semantic-selector.d.ts +3 -2
- package/core/dist/runtime/owner-decision/semantic-selector.d.ts.map +1 -1
- package/core/dist/runtime/owner-identity.d.ts +12 -1
- package/core/dist/runtime/owner-identity.d.ts.map +1 -1
- package/core/dist/runtime/owner-identity.js +19 -1
- package/core/dist/runtime/owner-identity.js.map +1 -1
- package/core/dist/runtime/pain-ingress-payload.d.ts +0 -39
- package/core/dist/runtime/pain-ingress-payload.d.ts.map +1 -1
- package/core/dist/runtime/pain-ingress-payload.js +4 -4
- package/core/dist/runtime/pain-ingress-payload.js.map +1 -1
- package/core/dist/runtime/pain-ingress.d.ts +1 -1
- package/core/dist/runtime/pain-ingress.d.ts.map +1 -1
- package/core/dist/runtime/pain-ingress.js.map +1 -1
- package/core/dist/runtime/pain-signal-bridge.d.ts +0 -2
- package/core/dist/runtime/pain-signal-bridge.d.ts.map +1 -1
- package/core/dist/runtime/pain-signal-bridge.js +1 -1
- package/core/dist/runtime/pain-signal-bridge.js.map +1 -1
- package/core/dist/runtime/pain-signal-runtime-factory.d.ts +3 -3
- package/core/dist/runtime/pain-signal-runtime-factory.d.ts.map +1 -1
- package/core/dist/runtime/pain-signal-runtime-factory.js +1 -1
- package/core/dist/runtime/pain-signal-runtime-factory.js.map +1 -1
- package/core/dist/runtime/principle-reuse/reuse-proposal.d.ts +3 -2
- package/core/dist/runtime/principle-reuse/reuse-proposal.d.ts.map +1 -1
- package/core/dist/runtime/principle-reuse/reuse-retrieval.d.ts +0 -10
- package/core/dist/runtime/principle-reuse/reuse-retrieval.d.ts.map +1 -1
- package/core/dist/runtime/principle-reuse/reuse-retrieval.js +1 -1
- package/core/dist/runtime/principle-reuse/reuse-retrieval.js.map +1 -1
- package/core/dist/runtime/principle-reuse/reuse-shortlist.d.ts +1 -8
- package/core/dist/runtime/principle-reuse/reuse-shortlist.d.ts.map +1 -1
- package/core/dist/runtime/principle-reuse/reuse-shortlist.js +1 -1
- package/core/dist/runtime/principle-reuse/reuse-shortlist.js.map +1 -1
- package/core/dist/runtime/product-telemetry/snapshot-contract.d.ts +3 -2
- package/core/dist/runtime/product-telemetry/snapshot-contract.d.ts.map +1 -1
- package/core/dist/runtime/recovery-sweep-service.d.ts +7 -0
- package/core/dist/runtime/recovery-sweep-service.d.ts.map +1 -1
- package/core/dist/runtime/recovery-sweep-service.js +1 -0
- package/core/dist/runtime/recovery-sweep-service.js.map +1 -1
- package/core/dist/runtime/runner/base-peer-runner.d.ts +32 -0
- package/core/dist/runtime/runner/base-peer-runner.d.ts.map +1 -1
- package/core/dist/runtime/runner/base-peer-runner.js +168 -16
- package/core/dist/runtime/runner/base-peer-runner.js.map +1 -1
- package/core/dist/runtime/runner/default-validator.d.ts +0 -1
- package/core/dist/runtime/runner/default-validator.d.ts.map +1 -1
- package/core/dist/runtime/runner/default-validator.js +11 -3
- package/core/dist/runtime/runner/default-validator.js.map +1 -1
- package/core/dist/runtime/runner/peer-runner-types.d.ts +11 -0
- package/core/dist/runtime/runner/peer-runner-types.d.ts.map +1 -1
- package/core/dist/runtime/storage-paths.d.ts +15 -0
- package/core/dist/runtime/storage-paths.d.ts.map +1 -0
- package/core/dist/runtime/storage-paths.js +15 -0
- package/core/dist/runtime/storage-paths.js.map +1 -0
- package/core/dist/runtime/store/artifact/index.d.ts +1 -1
- package/core/dist/runtime/store/artifact/index.d.ts.map +1 -1
- package/core/dist/runtime/store/candidate/admission-document.d.ts +4 -3
- package/core/dist/runtime/store/candidate/admission-document.d.ts.map +1 -1
- package/core/dist/runtime/store/commit/index.d.ts +0 -1
- package/core/dist/runtime/store/commit/index.d.ts.map +1 -1
- package/core/dist/runtime/store/commit/index.js.map +1 -1
- package/core/dist/runtime/store/context/promoted-evidence-reader.d.ts +59 -0
- package/core/dist/runtime/store/context/promoted-evidence-reader.d.ts.map +1 -0
- package/core/dist/runtime/store/context/promoted-evidence-reader.js +201 -0
- package/core/dist/runtime/store/context/promoted-evidence-reader.js.map +1 -0
- package/core/dist/runtime/store/context/sqlite-context-assembler.d.ts.map +1 -1
- package/core/dist/runtime/store/context/sqlite-context-assembler.js +43 -2
- package/core/dist/runtime/store/context/sqlite-context-assembler.js.map +1 -1
- package/core/dist/runtime/store/design-gate/sqlite-design-gate-store.d.ts +4 -3
- package/core/dist/runtime/store/design-gate/sqlite-design-gate-store.d.ts.map +1 -1
- package/core/dist/runtime/store/lifecycle/lease-manager.d.ts +2 -1
- package/core/dist/runtime/store/lifecycle/lease-manager.d.ts.map +1 -1
- package/core/dist/runtime/store/runtime-state-manager.d.ts +1 -2
- package/core/dist/runtime/store/runtime-state-manager.d.ts.map +1 -1
- package/core/dist/runtime/store/runtime-state-manager.js.map +1 -1
- package/core/dist/runtime/store/sqlite-connection.d.ts +2 -1
- package/core/dist/runtime/store/sqlite-connection.d.ts.map +1 -1
- package/core/dist/runtime/store/sqlite-connection.js +96 -37
- package/core/dist/runtime/store/sqlite-connection.js.map +1 -1
- package/core/dist/runtime/store/task/sqlite-family-reopen.d.ts +2 -1
- package/core/dist/runtime/store/task/sqlite-family-reopen.d.ts.map +1 -1
- package/core/dist/runtime/store/task/sqlite-task-store.d.ts +2 -1
- package/core/dist/runtime/store/task/sqlite-task-store.d.ts.map +1 -1
- package/core/dist/runtime/story-a-demo.d.ts.map +1 -1
- package/core/dist/runtime/story-a-demo.js +4 -1
- package/core/dist/runtime/story-a-demo.js.map +1 -1
- package/core/dist/runtime/tools/agent-tool-contract.d.ts +1 -2
- package/core/dist/runtime/tools/agent-tool-contract.d.ts.map +1 -1
- package/core/dist/runtime/tools/agent-tool-contract.js +0 -2
- package/core/dist/runtime/tools/agent-tool-contract.js.map +1 -1
- package/core/dist/runtime/tools/artificer-l2-tool-contract.d.ts +0 -2
- package/core/dist/runtime/tools/artificer-l2-tool-contract.d.ts.map +1 -1
- package/core/dist/runtime/tools/artificer-l2-tool-contract.js +0 -2
- package/core/dist/runtime/tools/artificer-l2-tool-contract.js.map +1 -1
- package/core/dist/runtime/types/event-payload.d.ts +0 -2
- package/core/dist/runtime/types/event-payload.d.ts.map +1 -1
- package/core/dist/runtime/types/event-payload.js.map +1 -1
- package/core/dist/runtime/types/evidence-chain-contract.d.ts +66 -2
- package/core/dist/runtime/types/evidence-chain-contract.d.ts.map +1 -1
- package/core/dist/runtime/types/evidence-chain-contract.js +69 -4
- package/core/dist/runtime/types/evidence-chain-contract.js.map +1 -1
- package/core/dist/runtime/types/hygiene-types.d.ts +0 -6
- package/core/dist/runtime/types/hygiene-types.d.ts.map +1 -1
- package/core/dist/runtime/types/hygiene-types.js.map +1 -1
- package/core/dist/runtime/types/index.d.ts +1 -1
- package/core/dist/runtime/types/index.d.ts.map +1 -1
- package/core/dist/runtime/types/index.js.map +1 -1
- package/core/dist/runtime/types/intervention-evidence-contract.d.ts +5 -5
- package/core/dist/runtime/types/intervention-evidence-contract.d.ts.map +1 -1
- package/core/dist/runtime/types/intervention-evidence-contract.js +0 -2
- package/core/dist/runtime/types/intervention-evidence-contract.js.map +1 -1
- package/core/dist/runtime/types/principle-dependency.d.ts +0 -2
- package/core/dist/runtime/types/principle-dependency.d.ts.map +1 -1
- package/core/dist/runtime/types/principle-dependency.js.map +1 -1
- package/core/dist/runtime/types/principle-lifecycle-event.d.ts +0 -2
- package/core/dist/runtime/types/principle-lifecycle-event.d.ts.map +1 -1
- package/core/dist/runtime/types/principle-lifecycle-event.js.map +1 -1
- package/core/dist/runtime/types/principle-schema.d.ts +0 -26
- package/core/dist/runtime/types/principle-schema.d.ts.map +1 -1
- package/core/dist/runtime/types/principle-schema.js +2 -2
- package/core/dist/runtime/types/principle-schema.js.map +1 -1
- package/core/dist/runtime/types/principle-tree-store.d.ts +0 -2
- package/core/dist/runtime/types/principle-tree-store.d.ts.map +1 -1
- package/core/dist/runtime/types/principle-tree-store.js.map +1 -1
- package/core/dist/runtime/types/principle-value-metrics.d.ts +0 -2
- package/core/dist/runtime/types/principle-value-metrics.d.ts.map +1 -1
- package/core/dist/runtime/types/principle-value-metrics.js.map +1 -1
- package/core/dist/runtime/types/rule-candidate-binding.d.ts +2 -1
- package/core/dist/runtime/types/rule-candidate-binding.d.ts.map +1 -1
- package/core/dist/telemetry-event.d.ts +2 -2
- package/core/dist/telemetry-event.d.ts.map +1 -1
- package/core/dist/telemetry-event.js +11 -0
- package/core/dist/telemetry-event.js.map +1 -1
- package/core/package.json +5 -1
- package/dist/installer.d.ts +14 -0
- package/dist/installer.d.ts.map +1 -1
- package/dist/installer.js +36 -77
- package/dist/installer.js.map +1 -1
- package/dist/installers/codex-host-installer.d.ts +9 -0
- package/dist/installers/codex-host-installer.d.ts.map +1 -1
- package/dist/installers/codex-host-installer.js +35 -1
- package/dist/installers/codex-host-installer.js.map +1 -1
- package/dist/mvp-config.js +1 -1
- package/dist/mvp-config.js.map +1 -1
- package/dist/update/data-compatibility.d.ts.map +1 -1
- package/dist/update/data-compatibility.js +3 -1
- package/dist/update/data-compatibility.js.map +1 -1
- package/dist/update/product-identity.d.ts.map +1 -1
- package/dist/update/product-identity.js +5 -1
- package/dist/update/product-identity.js.map +1 -1
- package/dist/update/release-manager.d.ts +5 -0
- package/dist/update/release-manager.d.ts.map +1 -1
- package/dist/update/release-manager.js +11 -1
- package/dist/update/release-manager.js.map +1 -1
- package/host-runtime/dist/active-principle-prompt.d.ts +7 -2
- package/host-runtime/dist/active-principle-prompt.js +80 -13
- package/host-runtime/dist/adaptive-decision-protocol.d.ts +36 -21
- package/host-runtime/dist/adaptive-decision-protocol.js +79 -34
- package/host-runtime/dist/adaptive-priority-provider.d.ts +2 -1
- package/host-runtime/dist/adaptive-priority-provider.js +6 -5
- package/host-runtime/dist/adaptive-selection.d.ts +4 -0
- package/host-runtime/dist/adaptive-selection.js +12 -4
- package/host-runtime/dist/cli-recovery-probe.d.ts +42 -1
- package/host-runtime/dist/cli-recovery-probe.js +16 -3
- package/host-runtime/dist/codex-disclosure.d.ts +12 -7
- package/host-runtime/dist/codex-disclosure.js +12 -7
- package/host-runtime/dist/conversation-ingestion/pipeline.d.ts +8 -29
- package/host-runtime/dist/conversation-ingestion/pipeline.js +45 -3
- package/host-runtime/dist/conversation-ingestion/text-policy.d.ts +3 -4
- package/host-runtime/dist/conversation-ingestion/text-policy.js +3 -4
- package/host-runtime/dist/governance-observation-store.d.ts +38 -5
- package/host-runtime/dist/governance-observation-store.js +63 -5
- package/host-runtime/dist/index.js +5 -2
- package/host-runtime/dist/production-rulehost-gate.d.ts +36 -1
- package/host-runtime/dist/production-rulehost-gate.js +91 -1
- package/host-runtime/package.json +1 -1
- package/package.json +2 -2
- package/pd-cli/dist/commands/candidate.d.ts.map +1 -1
- package/pd-cli/dist/commands/candidate.js +117 -3
- package/pd-cli/dist/commands/candidate.js.map +1 -1
- package/pd-cli/dist/commands/console.d.ts +0 -4
- package/pd-cli/dist/commands/console.d.ts.map +1 -1
- package/pd-cli/dist/commands/console.js +4 -67
- package/pd-cli/dist/commands/console.js.map +1 -1
- package/pd-cli/dist/commands/diagnose.js +1 -1
- package/pd-cli/dist/commands/diagnose.js.map +1 -1
- package/pd-cli/dist/commands/health-ingestion.d.ts +96 -0
- package/pd-cli/dist/commands/health-ingestion.d.ts.map +1 -0
- package/pd-cli/dist/commands/health-ingestion.js +473 -0
- package/pd-cli/dist/commands/health-ingestion.js.map +1 -0
- package/pd-cli/dist/commands/health.d.ts.map +1 -1
- package/pd-cli/dist/commands/health.js +10 -0
- package/pd-cli/dist/commands/health.js.map +1 -1
- package/pd-cli/dist/commands/runtime-activation.d.ts.map +1 -1
- package/pd-cli/dist/commands/runtime-activation.js +4 -8
- package/pd-cli/dist/commands/runtime-activation.js.map +1 -1
- package/pd-cli/dist/commands/runtime-recovery-failed-tasks.d.ts.map +1 -1
- package/pd-cli/dist/commands/runtime-recovery-failed-tasks.js +114 -63
- package/pd-cli/dist/commands/runtime-recovery-failed-tasks.js.map +1 -1
- package/pd-cli/dist/program.d.ts.map +1 -1
- package/pd-cli/dist/program.js +0 -8
- package/pd-cli/dist/program.js.map +1 -1
- package/pd-cli/dist/services/console-launcher.d.ts +1 -18
- package/pd-cli/dist/services/console-launcher.d.ts.map +1 -1
- package/pd-cli/dist/services/console-launcher.js +4 -92
- package/pd-cli/dist/services/console-launcher.js.map +1 -1
- package/pd-cli/dist/services/demo-story-a-runner.js +1 -1
- package/pd-cli/dist/services/demo-story-a-runner.js.map +1 -1
- package/pd-cli/dist/services/version-report.d.ts.map +1 -1
- package/pd-cli/dist/services/version-report.js +5 -1
- package/pd-cli/dist/services/version-report.js.map +1 -1
- package/pd-cli/package.json +1 -1
- package/plugin/dist/bundle.js +562 -534
- package/plugin/dist/core/experiment-workspace-guard.d.ts +25 -0
- package/plugin/dist/index.d.ts +1 -1
- package/plugin/dist/openclaw.plugin.json +1 -1
- package/plugin/openclaw.plugin.json +1 -1
- package/plugin/package.json +1 -1
- package/release-manager/dist/installer.js +36 -77
- package/release-manager/dist/installers/codex-host-installer.js +35 -1
- package/release-manager/dist/mvp-config.js +1 -1
- package/release-manager/dist/update/product-identity.js +5 -1
- package/release-manager/dist/update/release-manager.js +11 -1
- package/release-manager/package.json +1 -1
- package/workbuddy-adapter/dist/index.d.ts +1 -1
- package/workbuddy-adapter/dist/index.js +1 -1
- package/workbuddy-adapter/dist/ingestion/catch-up.d.ts +11 -0
- package/workbuddy-adapter/dist/ingestion/catch-up.js +7 -2
- package/workbuddy-adapter/dist/ingestion/index.d.ts +1 -1
- package/workbuddy-adapter/dist/ingestion/index.js +1 -1
- package/workbuddy-adapter/package.json +1 -1
- package/console/dist/server/config/AuthConfig.d.ts +0 -14
- package/console/dist/server/config/AuthConfig.js +0 -42
|
@@ -7,6 +7,7 @@ import path from 'node:path';
|
|
|
7
7
|
import { escapeXml } from '@principles/core/prompt-builder';
|
|
8
8
|
import { loadPdConfigForPlugin } from './pd-config.js';
|
|
9
9
|
import { readPromptActivationAuthority } from './prompt-activation-authority.js';
|
|
10
|
+
import { ADAPTIVE_DECISION_MAX_CANDIDATE_CHARS } from './adaptive-decision-protocol.js';
|
|
10
11
|
import { revalidateAdaptivePrinciple } from './adaptive-principle-revalidation.js';
|
|
11
12
|
/** PRI-904 SPEC §10: bounded diagnostic id lists (mirrors the core selector's cap of 16). */
|
|
12
13
|
export const MAX_SHARED_DIAGNOSTIC_IDS = 16;
|
|
@@ -345,17 +346,51 @@ export async function buildActivePrinciplePromptContext(input) {
|
|
|
345
346
|
};
|
|
346
347
|
const nativePacking = pack(nativeScanOrder);
|
|
347
348
|
const nativeResult = makeResult(nativePacking, principles);
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
349
|
+
let gapPriority;
|
|
350
|
+
const mandatoryIds = input.mandatoryPrincipleIds ?? [];
|
|
351
|
+
let feasible = [];
|
|
352
|
+
const replacements = new Map();
|
|
353
|
+
if (input.adaptivePriority === undefined && input.selectNativeGap && warnings.length === 0) {
|
|
354
|
+
const omitted = principles.filter((principle) => !nativeResult.principleIds.includes(principle.principleId));
|
|
355
|
+
const renderOptions = { escapeFn: escapeXml, selfReportInstruction: selfReportEnabled };
|
|
356
|
+
const nativeChars = nativePacking.additionalContext.length || sharedDirectiveBaseChars(renderOptions);
|
|
357
|
+
const remaining = budgetChars - nativeChars;
|
|
358
|
+
const config = loadPdConfigForPlugin(input.workspaceDir);
|
|
359
|
+
const replaceableIds = new Set(config.ok ? config.effective.config.adaptiveActivation?.replaceableActivationIds : undefined);
|
|
360
|
+
// Prefer the last explicitly replaceable Native directive that can cover
|
|
361
|
+
// the shortfall. Each question scores one concrete plan, never a free-form removal.
|
|
362
|
+
const replaceable = nativePacking.included.slice().reverse()
|
|
363
|
+
.filter((p) => replaceableIds.has(p.activationId) && p.authority === 'owner'
|
|
364
|
+
&& p.artifactContentSha256 && Array.isArray(mandatoryIds) && !mandatoryIds.includes(p.principleId)
|
|
365
|
+
&& principles.filter((candidate) => candidate.principleId === p.principleId).length === 1)
|
|
366
|
+
.map((principle) => ({ principle, chars: measureSharedDirectiveBlockChars(principle, renderOptions) }));
|
|
367
|
+
feasible = omitted.filter((principle) => {
|
|
368
|
+
const shortfall = measureSharedDirectiveBlockChars(principle, renderOptions) - remaining;
|
|
369
|
+
if (shortfall <= 0)
|
|
370
|
+
return true;
|
|
371
|
+
// Compare complete directives. A truncated excerpt cannot establish
|
|
372
|
+
// that removing a constraint is appropriate for this task.
|
|
373
|
+
if (principle.authority !== 'owner' || !principle.artifactContentSha256
|
|
374
|
+
|| principle.text.trim().length > ADAPTIVE_DECISION_MAX_CANDIDATE_CHARS)
|
|
375
|
+
return false;
|
|
376
|
+
const outgoing = replaceable.find(({ principle: p, chars }) => chars >= shortfall && p.text.trim().length <= ADAPTIVE_DECISION_MAX_CANDIDATE_CHARS);
|
|
377
|
+
if (!outgoing)
|
|
378
|
+
return false;
|
|
379
|
+
replacements.set(principle.activationId, outgoing.principle);
|
|
380
|
+
return true;
|
|
381
|
+
});
|
|
382
|
+
gapPriority = await input.selectNativeGap(feasible, {
|
|
383
|
+
excludedByBudget: feasible.length < omitted.length,
|
|
384
|
+
replacementByActivationId: replacements,
|
|
385
|
+
});
|
|
386
|
+
}
|
|
351
387
|
const priority = input.adaptivePriority ?? gapPriority;
|
|
352
388
|
if (priority === undefined)
|
|
353
389
|
return nativeResult;
|
|
354
390
|
const signal = gapPriority?.signal ?? input.signal ?? new AbortController().signal;
|
|
355
391
|
const deadlineAt = gapPriority?.deadlineAt ?? input.deadlineAt;
|
|
356
|
-
const
|
|
357
|
-
|
|
358
|
-
return nativeResult;
|
|
392
|
+
const outgoing = gapPriority ? replacements.get(priority.activationId) : undefined;
|
|
393
|
+
const additiveOnly = (gapPriority !== undefined && outgoing === undefined) || input.additiveOnly === true;
|
|
359
394
|
const report = (status, reason, displacedActivationIds = []) => ({
|
|
360
395
|
status,
|
|
361
396
|
...(gapPriority ? { source: 'native_gap' } : {}),
|
|
@@ -365,6 +400,9 @@ export async function buildActivePrinciplePromptContext(input) {
|
|
|
365
400
|
...(input.hookInvocationId ? { hookInvocationId: input.hookInvocationId } : {}),
|
|
366
401
|
displacedActivationIds,
|
|
367
402
|
});
|
|
403
|
+
if (gapPriority && (signal.aborted || (deadlineAt !== undefined && Date.now() >= deadlineAt))) {
|
|
404
|
+
return { ...nativeResult, adaptivePacking: report('unavailable', 'deadline') };
|
|
405
|
+
}
|
|
368
406
|
const nativeTargetMatches = principles.filter((principle) => principle.artifactId === priority.artifactId && principle.activationId === priority.activationId);
|
|
369
407
|
const [nativeTarget] = nativeTargetMatches;
|
|
370
408
|
const baselineHasTarget = nativePacking.included.some((principle) => principle.artifactId === priority.artifactId && principle.activationId === priority.activationId);
|
|
@@ -390,6 +428,9 @@ export async function buildActivePrinciplePromptContext(input) {
|
|
|
390
428
|
if (principles.filter((principle) => principle.principleId === nativeTarget.principleId).length !== 1) {
|
|
391
429
|
return { ...nativeResult, adaptivePacking: report('unavailable', 'target_ambiguous') };
|
|
392
430
|
}
|
|
431
|
+
if (gapPriority && !feasible.includes(nativeTarget)) {
|
|
432
|
+
return { ...nativeResult, adaptivePacking: report('unavailable', 'target_not_in_feasible_gap') };
|
|
433
|
+
}
|
|
393
434
|
const authorityRead = await readPromptActivationCandidates({ workspaceDir: input.workspaceDir, includeAuthority: true, noBusyWait: true });
|
|
394
435
|
const authorizedMatches = authorityRead.principles.filter((principle) => principle.artifactId === priority.artifactId && principle.activationId === priority.activationId);
|
|
395
436
|
const [authorizedTarget] = authorizedMatches;
|
|
@@ -415,6 +456,7 @@ export async function buildActivePrinciplePromptContext(input) {
|
|
|
415
456
|
const targetBody = targetRendered.slice(targetRendered.indexOf('<directive '), targetRendered.indexOf('</directive>') + '</directive>'.length);
|
|
416
457
|
const prepared = (status, displaced = []) => ({
|
|
417
458
|
...report(status, undefined, displaced), targetSnapshot: authorizedTarget, targetBody,
|
|
459
|
+
...(outgoing ? { displacedSnapshot: outgoing } : {}),
|
|
418
460
|
nativeBaseline: nativeResult, ...(deadlineAt !== undefined ? { deadlineAt } : {}),
|
|
419
461
|
});
|
|
420
462
|
if (baselineHasTarget) {
|
|
@@ -423,13 +465,21 @@ export async function buildActivePrinciplePromptContext(input) {
|
|
|
423
465
|
return withoutTarget('target_changed');
|
|
424
466
|
return { ...nativeResult, adaptivePacking: prepared('target_present') };
|
|
425
467
|
}
|
|
426
|
-
|
|
427
|
-
const
|
|
428
|
-
|
|
468
|
+
// Apply only the scored plan to the exact Native selection.
|
|
469
|
+
const prioritizedPacking = gapPriority
|
|
470
|
+
? {
|
|
471
|
+
...pack([...nativePacking.included.filter((p) => p !== outgoing), nativeTarget]),
|
|
472
|
+
truncated: nativePacking.truncated,
|
|
473
|
+
dropped: [
|
|
474
|
+
...(outgoing ? [outgoing.activationId] : []),
|
|
475
|
+
...nativePacking.dropped.filter((id) => id !== nativeTarget.activationId),
|
|
476
|
+
].slice(0, MAX_SHARED_DIAGNOSTIC_IDS),
|
|
477
|
+
oversized: nativePacking.oversized,
|
|
478
|
+
}
|
|
479
|
+
: pack([nativeTarget, ...nativeScanOrder.filter((principle) => principle.principleId !== nativeTarget.principleId)]);
|
|
429
480
|
if (!prioritizedPacking.included.some((principle) => principle.principleId === nativeTarget.principleId)) {
|
|
430
481
|
return { ...nativeResult, adaptivePacking: report('unavailable', 'target_does_not_fit') };
|
|
431
482
|
}
|
|
432
|
-
const mandatoryIds = input.mandatoryPrincipleIds ?? [];
|
|
433
483
|
if (!Array.isArray(mandatoryIds) || mandatoryIds.some((id) => typeof id !== 'string')
|
|
434
484
|
|| mandatoryIds.some((id) => !prioritizedPacking.included.some((principle) => principle.principleId === id))) {
|
|
435
485
|
return { ...nativeResult, adaptivePacking: report('unavailable', 'mandatory_constraint_displaced') };
|
|
@@ -438,6 +488,9 @@ export async function buildActivePrinciplePromptContext(input) {
|
|
|
438
488
|
const displacedActivationIds = nativePacking.included
|
|
439
489
|
.filter((principle) => !prioritizedActivationIds.has(principle.activationId))
|
|
440
490
|
.map((principle) => principle.activationId);
|
|
491
|
+
if (outgoing && (displacedActivationIds.length !== 1 || displacedActivationIds[0] !== outgoing.activationId)) {
|
|
492
|
+
return withoutTarget('unexpected_replacement');
|
|
493
|
+
}
|
|
441
494
|
// PRI-1140: an additive-only target may never squeeze out content the
|
|
442
495
|
// native baseline already assembled. Decided BEFORE the revalidation read so
|
|
443
496
|
// a refused placement costs no further I/O; the would-be displacement is the
|
|
@@ -448,11 +501,25 @@ export async function buildActivePrinciplePromptContext(input) {
|
|
|
448
501
|
adaptivePacking: report('unavailable', 'would_displace_native_assembly', displacedActivationIds.slice(0, MAX_SHARED_DIAGNOSTIC_IDS)),
|
|
449
502
|
};
|
|
450
503
|
}
|
|
451
|
-
const stillValid = await
|
|
504
|
+
const [stillValid, outgoingValid] = await Promise.all([
|
|
505
|
+
revalidateAdaptivePrinciple(input.workspaceDir, authorizedTarget, signal),
|
|
506
|
+
outgoing ? revalidateAdaptivePrinciple(input.workspaceDir, outgoing, signal) : true,
|
|
507
|
+
]);
|
|
508
|
+
if (gapPriority && (signal.aborted || (deadlineAt !== undefined && Date.now() >= deadlineAt))) {
|
|
509
|
+
return { ...nativeResult, adaptivePacking: report('unavailable', 'deadline') };
|
|
510
|
+
}
|
|
452
511
|
if (!stillValid)
|
|
453
512
|
return { ...nativeResult, adaptivePacking: report('unavailable', 'target_changed') };
|
|
454
|
-
if (
|
|
455
|
-
return
|
|
513
|
+
if (!outgoingValid)
|
|
514
|
+
return withoutTarget('replacement_changed');
|
|
515
|
+
if (outgoing) {
|
|
516
|
+
const config = loadPdConfigForPlugin(input.workspaceDir);
|
|
517
|
+
if (!config.ok || !config.effective.config.adaptiveActivation?.replaceableActivationIds?.includes(outgoing.activationId)) {
|
|
518
|
+
return withoutTarget('replacement_permission_changed');
|
|
519
|
+
}
|
|
520
|
+
if (signal.aborted || (deadlineAt !== undefined && Date.now() >= deadlineAt))
|
|
521
|
+
return withoutTarget('deadline');
|
|
522
|
+
}
|
|
456
523
|
const result = makeResult(prioritizedPacking, principles, prepared('prioritized', displacedActivationIds));
|
|
457
524
|
// Adaptive assembly is deliberately limited to the existing renderer's Native budget cap.
|
|
458
525
|
return result;
|
|
@@ -8,35 +8,31 @@
|
|
|
8
8
|
* The difference from the lab experiment is the QUESTION SET: the lab asked
|
|
9
9
|
* four task-level questions, while production asks one independent
|
|
10
10
|
* applicability condition per candidate plus one "insufficient context"
|
|
11
|
-
* condition.
|
|
12
|
-
*
|
|
13
|
-
*
|
|
11
|
+
* condition. A candidate that would replace an activation answers TWO
|
|
12
|
+
* independent conditions instead (incoming value, outgoing safety), because a
|
|
13
|
+
* single blended score cannot tell "this principle does not fit" apart from
|
|
14
|
+
* "dropping the other principle is unsafe". Each answer is an independent
|
|
15
|
+
* `noul` score in [0, 1] — not a distribution — so PD adjudicates locally
|
|
16
|
+
* instead of trusting the model to emit a decision.
|
|
14
17
|
*
|
|
15
18
|
* Everything here is pure: no I/O, no clock, no transport. The caller owns
|
|
16
19
|
* scheduling, cancellation and diagnostics.
|
|
17
20
|
*/
|
|
21
|
+
export declare const ADAPTIVE_DECISION_MAX_CANDIDATE_CHARS = 600;
|
|
18
22
|
export declare const ADAPTIVE_DECISION_INSUFFICIENT_QUESTION = "insufficient_context";
|
|
19
23
|
/**
|
|
20
|
-
*
|
|
24
|
+
* Preset applicability and context guards. Scores are model judgments, not
|
|
25
|
+
* calibrated probabilities.
|
|
21
26
|
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* replay-02 .9594 .9565 .0708 insufficient .1962 → uncertain (lead below margin)
|
|
27
|
-
* replay-03 .0496 .9958 .2068 insufficient .1375 → selected
|
|
28
|
-
* replay-04 .0624 .0340 .9888 insufficient .2668 → selected
|
|
29
|
-
*
|
|
30
|
-
* Do NOT tune these per failing turn, and do not tune them while a real
|
|
31
|
-
* batch is running: changing them is a product decision that requires a new
|
|
32
|
-
* version string and a new frozen batch.
|
|
27
|
+
* v3: a replaceable candidate is scored by TWO independent conditions
|
|
28
|
+
* (incoming value, outgoing safety). The append path keeps the single
|
|
29
|
+
* condition of v2 unchanged, which is why the version bump is required to
|
|
30
|
+
* tell the two evidence generations apart.
|
|
33
31
|
*/
|
|
34
32
|
export declare const ADAPTIVE_DECISION_CRITERIA: {
|
|
35
|
-
readonly version: '
|
|
36
|
-
/** A candidate must reach this
|
|
33
|
+
readonly version: 'v3-20261112';
|
|
34
|
+
/** A candidate (and, when it replaces something, its safety condition) must reach this score. */
|
|
37
35
|
readonly selectThreshold: 0.7;
|
|
38
|
-
/** The winner must lead the runner-up by this much, or the turn is ambiguous. */
|
|
39
|
-
readonly leadMargin: 0.25;
|
|
40
36
|
/** Above this "information is insufficient" score, PD refuses to select. */
|
|
41
37
|
readonly insufficientThreshold: 0.6;
|
|
42
38
|
};
|
|
@@ -68,6 +64,7 @@ export interface BuildDecisionRequestInput {
|
|
|
68
64
|
readonly ref: string;
|
|
69
65
|
readonly text: string;
|
|
70
66
|
readonly digest: string;
|
|
67
|
+
readonly replaces?: string;
|
|
71
68
|
}[];
|
|
72
69
|
/** Bounded by the caller; a request larger than this is refused locally. */
|
|
73
70
|
readonly maxPayloadChars: number;
|
|
@@ -81,14 +78,24 @@ export type BuildDecisionRequestResult = {
|
|
|
81
78
|
readonly reason: DecisionProtocolError;
|
|
82
79
|
};
|
|
83
80
|
export declare function candidateQuestionId(ref: string): string;
|
|
81
|
+
/** Replaceable candidates answer the incoming-value question under this id. */
|
|
82
|
+
export declare function candidateValueQuestionId(ref: string): string;
|
|
83
|
+
/** Replaceable candidates answer the outgoing-safety question under this id. */
|
|
84
|
+
export declare function candidateSafetyQuestionId(ref: string): string;
|
|
84
85
|
/**
|
|
85
86
|
* One question per candidate (its applicability condition) plus one
|
|
86
87
|
* "insufficient context" question. Instructions refer to the snapshot by ref;
|
|
87
88
|
* the candidate text itself travels once, in `state`.
|
|
89
|
+
*
|
|
90
|
+
* A candidate that would REPLACE an activation answers two independent
|
|
91
|
+
* conditions instead of one: whether the incoming principle helps the user's
|
|
92
|
+
* next required step, and whether this turn can afford to drop the outgoing
|
|
93
|
+
* principle. Both must clear the same threshold. The append path is untouched.
|
|
88
94
|
*/
|
|
89
95
|
export declare function buildDecisionQuestions(candidates: readonly {
|
|
90
96
|
readonly ref: string;
|
|
91
97
|
readonly text: string;
|
|
98
|
+
readonly replaces?: string;
|
|
92
99
|
}[]): DecisionQuestions;
|
|
93
100
|
export declare function buildDecisionRequest(input: BuildDecisionRequestInput): BuildDecisionRequestResult;
|
|
94
101
|
/**
|
|
@@ -129,14 +136,22 @@ export type DecisionOutcome = {
|
|
|
129
136
|
} | {
|
|
130
137
|
readonly status: 'none_applicable' | 'uncertain';
|
|
131
138
|
readonly ref: null;
|
|
132
|
-
readonly reason: 'below_selection_threshold'
|
|
139
|
+
readonly reason: 'below_selection_threshold'
|
|
140
|
+
/** The incoming candidate fits, but dropping the listed outgoing principle was not shown safe this turn. */
|
|
141
|
+
| 'replacement_unsafe' | 'candidate_tied' | 'information_insufficient';
|
|
133
142
|
readonly scores: Readonly<Record<string, number>>;
|
|
134
143
|
};
|
|
135
144
|
/**
|
|
136
145
|
* Local adjudication of the INDEPENDENT condition scores. Order matters:
|
|
137
146
|
* insufficient information first (it invalidates any candidate ranking), then
|
|
138
|
-
*
|
|
147
|
+
* eligibility, then the applicability ranking.
|
|
148
|
+
*
|
|
149
|
+
* A candidate that replaces something is eligible only when BOTH its value and
|
|
150
|
+
* its safety condition clear the threshold. PD never lets a high incoming
|
|
151
|
+
* score override an unsafe removal, and `replacement_unsafe` keeps that
|
|
152
|
+
* failure distinguishable from "the candidate itself did not fit".
|
|
139
153
|
*/
|
|
140
154
|
export declare function adjudicateDecision(scores: Readonly<Record<string, number>>, candidates: readonly {
|
|
141
155
|
readonly ref: string;
|
|
156
|
+
readonly replaces?: string;
|
|
142
157
|
}[], criteria?: typeof ADAPTIVE_DECISION_CRITERIA): DecisionOutcome;
|
|
@@ -8,54 +8,77 @@
|
|
|
8
8
|
* The difference from the lab experiment is the QUESTION SET: the lab asked
|
|
9
9
|
* four task-level questions, while production asks one independent
|
|
10
10
|
* applicability condition per candidate plus one "insufficient context"
|
|
11
|
-
* condition.
|
|
12
|
-
*
|
|
13
|
-
*
|
|
11
|
+
* condition. A candidate that would replace an activation answers TWO
|
|
12
|
+
* independent conditions instead (incoming value, outgoing safety), because a
|
|
13
|
+
* single blended score cannot tell "this principle does not fit" apart from
|
|
14
|
+
* "dropping the other principle is unsafe". Each answer is an independent
|
|
15
|
+
* `noul` score in [0, 1] — not a distribution — so PD adjudicates locally
|
|
16
|
+
* instead of trusting the model to emit a decision.
|
|
14
17
|
*
|
|
15
18
|
* Everything here is pure: no I/O, no clock, no transport. The caller owns
|
|
16
19
|
* scheduling, cancellation and diagnostics.
|
|
17
20
|
*/
|
|
21
|
+
export const ADAPTIVE_DECISION_MAX_CANDIDATE_CHARS = 600;
|
|
18
22
|
export const ADAPTIVE_DECISION_INSUFFICIENT_QUESTION = 'insufficient_context';
|
|
19
23
|
/**
|
|
20
|
-
*
|
|
24
|
+
* Preset applicability and context guards. Scores are model judgments, not
|
|
25
|
+
* calibrated probabilities.
|
|
21
26
|
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* replay-02 .9594 .9565 .0708 insufficient .1962 → uncertain (lead below margin)
|
|
27
|
-
* replay-03 .0496 .9958 .2068 insufficient .1375 → selected
|
|
28
|
-
* replay-04 .0624 .0340 .9888 insufficient .2668 → selected
|
|
29
|
-
*
|
|
30
|
-
* Do NOT tune these per failing turn, and do not tune them while a real
|
|
31
|
-
* batch is running: changing them is a product decision that requires a new
|
|
32
|
-
* version string and a new frozen batch.
|
|
27
|
+
* v3: a replaceable candidate is scored by TWO independent conditions
|
|
28
|
+
* (incoming value, outgoing safety). The append path keeps the single
|
|
29
|
+
* condition of v2 unchanged, which is why the version bump is required to
|
|
30
|
+
* tell the two evidence generations apart.
|
|
33
31
|
*/
|
|
34
32
|
export const ADAPTIVE_DECISION_CRITERIA = {
|
|
35
|
-
version: '
|
|
36
|
-
/** A candidate must reach this
|
|
33
|
+
version: 'v3-20261112',
|
|
34
|
+
/** A candidate (and, when it replaces something, its safety condition) must reach this score. */
|
|
37
35
|
selectThreshold: 0.7,
|
|
38
|
-
/** The winner must lead the runner-up by this much, or the turn is ambiguous. */
|
|
39
|
-
leadMargin: 0.25,
|
|
40
36
|
/** Above this "information is insufficient" score, PD refuses to select. */
|
|
41
37
|
insufficientThreshold: 0.6,
|
|
42
38
|
};
|
|
43
39
|
export function candidateQuestionId(ref) {
|
|
44
40
|
return `candidate_${ref}`;
|
|
45
41
|
}
|
|
42
|
+
/** Replaceable candidates answer the incoming-value question under this id. */
|
|
43
|
+
export function candidateValueQuestionId(ref) {
|
|
44
|
+
return `candidate_${ref}_value`;
|
|
45
|
+
}
|
|
46
|
+
/** Replaceable candidates answer the outgoing-safety question under this id. */
|
|
47
|
+
export function candidateSafetyQuestionId(ref) {
|
|
48
|
+
return `candidate_${ref}_safety`;
|
|
49
|
+
}
|
|
46
50
|
/**
|
|
47
51
|
* One question per candidate (its applicability condition) plus one
|
|
48
52
|
* "insufficient context" question. Instructions refer to the snapshot by ref;
|
|
49
53
|
* the candidate text itself travels once, in `state`.
|
|
54
|
+
*
|
|
55
|
+
* A candidate that would REPLACE an activation answers two independent
|
|
56
|
+
* conditions instead of one: whether the incoming principle helps the user's
|
|
57
|
+
* next required step, and whether this turn can afford to drop the outgoing
|
|
58
|
+
* principle. Both must clear the same threshold. The append path is untouched.
|
|
50
59
|
*/
|
|
51
60
|
export function buildDecisionQuestions(candidates) {
|
|
52
61
|
const questions = {};
|
|
53
62
|
for (const candidate of candidates) {
|
|
54
|
-
|
|
63
|
+
if (candidate.replaces === undefined) {
|
|
64
|
+
questions[candidateQuestionId(candidate.ref)] = {
|
|
65
|
+
type: 'noul',
|
|
66
|
+
instructions: `依据 currentInstruction 判断用户现在要做什么,并比较 state.candidates。候选 ${candidate.ref} 是否直接适用于这项任务,且最能改善下一步具体行动?`
|
|
67
|
+
+ '能避免当前任务的具体失误或补上关键步骤时给高分。仅主题相近、重复用户已明确的要求、或对下一步没有实质帮助时给低分。没有合适候选时全部给低分。',
|
|
68
|
+
};
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
questions[candidateValueQuestionId(candidate.ref)] = {
|
|
55
72
|
type: 'noul',
|
|
56
|
-
instructions:
|
|
57
|
-
+
|
|
58
|
-
+ '
|
|
73
|
+
instructions: `依据 currentInstruction 判断用户现在要求完成的下一步,并比较 state.candidates。候选 ${candidate.ref} 是否直接帮助完成这一步?`
|
|
74
|
+
+ '为完成这一步所需的核对、验证和证据整理也算直接帮助,即使用户没有逐字说出这些动作。'
|
|
75
|
+
+ '仅主题相近、重复用户已明确的要求、或对下一步没有实质帮助时给低分。没有合适候选时全部给低分。',
|
|
76
|
+
};
|
|
77
|
+
questions[candidateSafetyQuestionId(candidate.ref)] = {
|
|
78
|
+
type: 'noul',
|
|
79
|
+
instructions: `只判断本轮:state.candidates 中候选 ${candidate.ref} 的 replaces 记录了启用它将让位的原原则。`
|
|
80
|
+
+ '若启用该候选,本轮能否在保留任务所需约束的前提下省掉这条原原则?'
|
|
81
|
+
+ '原原则对本轮仍可能有用、或无法确认可以省掉时给低分;确认本轮不需要它时才给高分。只判断当前轮,不考虑以后。',
|
|
59
82
|
};
|
|
60
83
|
}
|
|
61
84
|
questions[ADAPTIVE_DECISION_INSUFFICIENT_QUESTION] = {
|
|
@@ -77,6 +100,7 @@ export function buildDecisionRequest(input) {
|
|
|
77
100
|
ref: candidate.ref,
|
|
78
101
|
text: candidate.text,
|
|
79
102
|
digest: candidate.digest,
|
|
103
|
+
...(candidate.replaces !== undefined ? { replaces: candidate.replaces } : {}),
|
|
80
104
|
})),
|
|
81
105
|
};
|
|
82
106
|
const body = {
|
|
@@ -166,25 +190,46 @@ export function validateDecisionResponse(value, expected) {
|
|
|
166
190
|
/**
|
|
167
191
|
* Local adjudication of the INDEPENDENT condition scores. Order matters:
|
|
168
192
|
* insufficient information first (it invalidates any candidate ranking), then
|
|
169
|
-
*
|
|
193
|
+
* eligibility, then the applicability ranking.
|
|
194
|
+
*
|
|
195
|
+
* A candidate that replaces something is eligible only when BOTH its value and
|
|
196
|
+
* its safety condition clear the threshold. PD never lets a high incoming
|
|
197
|
+
* score override an unsafe removal, and `replacement_unsafe` keeps that
|
|
198
|
+
* failure distinguishable from "the candidate itself did not fit".
|
|
170
199
|
*/
|
|
171
200
|
export function adjudicateDecision(scores, candidates, criteria = ADAPTIVE_DECISION_CRITERIA) {
|
|
172
201
|
const insufficient = scores[ADAPTIVE_DECISION_INSUFFICIENT_QUESTION];
|
|
173
202
|
if (insufficient !== undefined && insufficient >= criteria.insufficientThreshold) {
|
|
174
203
|
return { status: 'uncertain', ref: null, reason: 'information_insufficient', scores };
|
|
175
204
|
}
|
|
176
|
-
const
|
|
177
|
-
.
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
205
|
+
const evaluated = candidates.map((candidate) => {
|
|
206
|
+
const replaceable = candidate.replaces !== undefined;
|
|
207
|
+
const value = scores[replaceable
|
|
208
|
+
? candidateValueQuestionId(candidate.ref)
|
|
209
|
+
: candidateQuestionId(candidate.ref)] ?? 0;
|
|
210
|
+
const safety = replaceable ? scores[candidateSafetyQuestionId(candidate.ref)] ?? 0 : null;
|
|
211
|
+
return {
|
|
212
|
+
ref: candidate.ref,
|
|
213
|
+
value,
|
|
214
|
+
eligible: value >= criteria.selectThreshold
|
|
215
|
+
&& (safety === null || safety >= criteria.selectThreshold),
|
|
216
|
+
};
|
|
217
|
+
});
|
|
218
|
+
const ranked = evaluated
|
|
219
|
+
.filter((candidate) => candidate.eligible)
|
|
220
|
+
.sort((left, right) => right.value - left.value);
|
|
182
221
|
const [top, runnerUp] = ranked;
|
|
183
|
-
if (!top
|
|
184
|
-
|
|
222
|
+
if (!top) {
|
|
223
|
+
const applicable = evaluated.some((candidate) => candidate.value >= criteria.selectThreshold);
|
|
224
|
+
return {
|
|
225
|
+
status: 'none_applicable',
|
|
226
|
+
ref: null,
|
|
227
|
+
reason: applicable ? 'replacement_unsafe' : 'below_selection_threshold',
|
|
228
|
+
scores,
|
|
229
|
+
};
|
|
185
230
|
}
|
|
186
|
-
if (runnerUp && top.
|
|
187
|
-
return { status: 'uncertain', ref: null, reason: '
|
|
231
|
+
if (runnerUp && top.value === runnerUp.value) {
|
|
232
|
+
return { status: 'uncertain', ref: null, reason: 'candidate_tied', scores };
|
|
188
233
|
}
|
|
189
234
|
return { status: 'selected', ref: top.ref, reason: 'selected', scores };
|
|
190
235
|
}
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import type { HostEvent } from '@principles/core/host';
|
|
12
12
|
import type { ActivatedPrinciple, PdConfig } from '@principles/core/runtime';
|
|
13
|
+
import type { AdaptiveGapOptions } from './active-principle-prompt.js';
|
|
13
14
|
import { type AdaptiveSelectionModel } from './adaptive-selection.js';
|
|
14
15
|
/** Independent switch. `features.host.codex.enabled` remains the whole-hook gate. */
|
|
15
16
|
export declare const ADAPTIVE_ACTIVATION_FLAG = "host.codex.adaptive_activation";
|
|
@@ -26,7 +27,7 @@ export interface AdaptivePrioritySelection {
|
|
|
26
27
|
readonly deadlineAt?: number;
|
|
27
28
|
readonly signal?: AbortSignal;
|
|
28
29
|
}
|
|
29
|
-
export type AdaptivePriorityProvider = (event: HostEvent, candidates: readonly ActivatedPrinciple[]) => Promise<AdaptivePrioritySelection | undefined>;
|
|
30
|
+
export type AdaptivePriorityProvider = (event: HostEvent, candidates: readonly ActivatedPrinciple[], options: AdaptiveGapOptions) => Promise<AdaptivePrioritySelection | undefined>;
|
|
30
31
|
export interface AdaptiveActivationReadiness {
|
|
31
32
|
readonly readiness: 'ready' | 'disabled' | 'needs_setup';
|
|
32
33
|
readonly reason: string;
|
|
@@ -63,7 +63,7 @@ export function createAdaptivePriorityProvider(options) {
|
|
|
63
63
|
const now = options.now ?? Date.now;
|
|
64
64
|
const requestTimeoutMs = options.requestTimeoutMs ?? ADAPTIVE_SELECTION_LIMITS.requestTimeoutMs;
|
|
65
65
|
const outputReserveMs = options.outputReserveMs ?? ADAPTIVE_OUTPUT_RESERVE_MS;
|
|
66
|
-
return async (event, candidates) => {
|
|
66
|
+
return async (event, candidates, { excludedByBudget, replacementByActivationId }) => {
|
|
67
67
|
if (event.kind !== 'before_prompt_build')
|
|
68
68
|
return undefined;
|
|
69
69
|
const { sessionId, turnId, promptContent, workspaceDir } = event.context;
|
|
@@ -72,8 +72,8 @@ export function createAdaptivePriorityProvider(options) {
|
|
|
72
72
|
const hostDeadlineAt = options.outerDeadlineAt === undefined
|
|
73
73
|
? undefined
|
|
74
74
|
: options.outerDeadlineAt - outputReserveMs;
|
|
75
|
-
// PRI-1181: deterministic gate
|
|
76
|
-
//
|
|
75
|
+
// PRI-1181: the deterministic gate runs before any model request.
|
|
76
|
+
// Native has already been assembled, even when Adaptive skips.
|
|
77
77
|
const skip = decideAdaptiveSkip({
|
|
78
78
|
kind: event.kind,
|
|
79
79
|
sessionId,
|
|
@@ -84,10 +84,10 @@ export function createAdaptivePriorityProvider(options) {
|
|
|
84
84
|
? { minExecutableBudgetMs: options.minExecutableBudgetMs }
|
|
85
85
|
: {}),
|
|
86
86
|
});
|
|
87
|
-
if (skip.skip) {
|
|
87
|
+
if (skip.skip || (candidates.length === 0 && excludedByBudget)) {
|
|
88
88
|
options.onDiagnostic?.({
|
|
89
89
|
status: 'skipped',
|
|
90
|
-
reason: skip.reason,
|
|
90
|
+
reason: skip.skip ? skip.reason : 'no_appendable_gap',
|
|
91
91
|
stage: 'gate',
|
|
92
92
|
sends: 0,
|
|
93
93
|
requestSentAt: null,
|
|
@@ -112,6 +112,7 @@ export function createAdaptivePriorityProvider(options) {
|
|
|
112
112
|
workspaceDir: workspaceDir || options.workspaceDir,
|
|
113
113
|
currentPrompt: prompt,
|
|
114
114
|
candidates,
|
|
115
|
+
replacementByActivationId,
|
|
115
116
|
model: options.model,
|
|
116
117
|
requestTimeoutMs,
|
|
117
118
|
...(hostDeadlineAt !== undefined ? { outerDeadlineAt: hostDeadlineAt, signal } : {}),
|
|
@@ -32,6 +32,7 @@ export interface AdaptiveCandidate {
|
|
|
32
32
|
readonly ref: string;
|
|
33
33
|
readonly text: string;
|
|
34
34
|
readonly digest: string;
|
|
35
|
+
readonly replaces?: string;
|
|
35
36
|
readonly principle: AdaptiveCandidateSource;
|
|
36
37
|
}
|
|
37
38
|
export interface BoundedSelectionInput {
|
|
@@ -46,6 +47,7 @@ export interface BoundedSelectionInput {
|
|
|
46
47
|
readonly ref: string;
|
|
47
48
|
readonly text: string;
|
|
48
49
|
readonly digest: string;
|
|
50
|
+
readonly replaces?: string;
|
|
49
51
|
}[];
|
|
50
52
|
};
|
|
51
53
|
readonly entries: readonly AdaptiveCandidate[];
|
|
@@ -112,6 +114,7 @@ export declare function buildBoundedSelectionInput(input: {
|
|
|
112
114
|
readonly source?: string;
|
|
113
115
|
}[];
|
|
114
116
|
readonly candidates: readonly AdaptiveCandidateSource[];
|
|
117
|
+
readonly replacementByActivationId?: ReadonlyMap<string, ActivatedPrinciple> | undefined;
|
|
115
118
|
}): BuildBoundedInputResult;
|
|
116
119
|
export interface DecisionSelectorOptions {
|
|
117
120
|
readonly fetchImpl?: typeof fetch;
|
|
@@ -145,6 +148,7 @@ export interface RunAdaptiveSelectionOptions {
|
|
|
145
148
|
readonly workspaceDir: string;
|
|
146
149
|
readonly currentPrompt: string;
|
|
147
150
|
readonly candidates: readonly ActivatedPrinciple[];
|
|
151
|
+
readonly replacementByActivationId?: ReadonlyMap<string, ActivatedPrinciple> | undefined;
|
|
148
152
|
readonly model: AdaptiveSelectionModel;
|
|
149
153
|
readonly requestTimeoutMs?: number;
|
|
150
154
|
readonly signal?: AbortSignal;
|
|
@@ -22,10 +22,10 @@
|
|
|
22
22
|
*/
|
|
23
23
|
import crypto from 'node:crypto';
|
|
24
24
|
import { revalidateAdaptivePrinciple } from './adaptive-principle-revalidation.js';
|
|
25
|
-
import { adjudicateDecision, buildDecisionRequest, validateDecisionResponse, } from './adaptive-decision-protocol.js';
|
|
25
|
+
import { ADAPTIVE_DECISION_MAX_CANDIDATE_CHARS, adjudicateDecision, buildDecisionRequest, validateDecisionResponse, } from './adaptive-decision-protocol.js';
|
|
26
26
|
export const ADAPTIVE_SELECTION_LIMITS = {
|
|
27
27
|
maxCandidates: 12,
|
|
28
|
-
maxCandidateChars:
|
|
28
|
+
maxCandidateChars: ADAPTIVE_DECISION_MAX_CANDIDATE_CHARS,
|
|
29
29
|
maxPriorMessages: 4,
|
|
30
30
|
maxPriorMessageChars: 1200,
|
|
31
31
|
maxInputChars: 6000,
|
|
@@ -67,7 +67,9 @@ export function buildBoundedSelectionInput(input) {
|
|
|
67
67
|
if (!principle.text.trim())
|
|
68
68
|
continue;
|
|
69
69
|
const candidateText = boundText(principle.text, ADAPTIVE_SELECTION_LIMITS.maxCandidateChars);
|
|
70
|
+
const outgoing = input.replacementByActivationId?.get(principle.activationId);
|
|
70
71
|
entries.push({
|
|
72
|
+
...(outgoing ? { replaces: boundText(outgoing.text, ADAPTIVE_SELECTION_LIMITS.maxCandidateChars) } : {}),
|
|
71
73
|
ref: `c${entries.length + 1}`,
|
|
72
74
|
text: candidateText,
|
|
73
75
|
// The digest stays part of the frozen candidate snapshot even though the
|
|
@@ -87,7 +89,7 @@ export function buildBoundedSelectionInput(input) {
|
|
|
87
89
|
payload: {
|
|
88
90
|
currentInstruction,
|
|
89
91
|
priorMessages: boundedPrior,
|
|
90
|
-
candidates: entries.map((
|
|
92
|
+
candidates: entries.map(({ ref, text, digest, replaces }) => ({ ref, text, digest, ...(replaces !== undefined ? { replaces } : {}) })),
|
|
91
93
|
},
|
|
92
94
|
entries,
|
|
93
95
|
priorDropped: Math.max(0, priorMessages.length - selectedPrior.length),
|
|
@@ -335,6 +337,7 @@ export async function runAdaptiveSelection(options) {
|
|
|
335
337
|
const built = buildBoundedSelectionInput({
|
|
336
338
|
currentInput: options.currentPrompt,
|
|
337
339
|
candidates: options.candidates,
|
|
340
|
+
replacementByActivationId: options.replacementByActivationId,
|
|
338
341
|
});
|
|
339
342
|
if (!built.ok)
|
|
340
343
|
return unavailable(built.reason, 'idle');
|
|
@@ -383,7 +386,12 @@ export async function runAdaptiveSelection(options) {
|
|
|
383
386
|
return {
|
|
384
387
|
status: 'none',
|
|
385
388
|
target: null,
|
|
386
|
-
|
|
389
|
+
// Keep "the candidate fits but dropping the outgoing principle was not
|
|
390
|
+
// shown safe" separate from an ordinary no-gain abstention; the bounded
|
|
391
|
+
// diagnostics must be able to tell them apart (rc-9).
|
|
392
|
+
reason: decision.status === 'uncertain'
|
|
393
|
+
? 'uncertain'
|
|
394
|
+
: decision.reason === 'replacement_unsafe' ? 'replacement_unsafe' : 'no_increment',
|
|
387
395
|
sends,
|
|
388
396
|
diagnostics,
|
|
389
397
|
};
|
|
@@ -1,4 +1,40 @@
|
|
|
1
1
|
import type { RecoveryCapabilityEvidence } from '@principles/core/runtime';
|
|
2
|
+
/**
|
|
3
|
+
* SPEC-RULECODE-HOST-PROMOTION-001 review round 4 (P1): per-capability
|
|
4
|
+
* CLI-channel reachability probes, shared by the pd-cli readiness path and
|
|
5
|
+
* the pd-console readiness assembly (both packages depend on host-runtime).
|
|
6
|
+
*
|
|
7
|
+
* Every probe executes the REAL pd CLI as a bounded subprocess against the
|
|
8
|
+
* TARGET workspace — static command lists, no shell, output capped, timeout
|
|
9
|
+
* enforced. Evidence is produced fresh on every call; nothing is cached and
|
|
10
|
+
* nothing destructive runs:
|
|
11
|
+
* - `pd_status`: `pd activation list --json` (read-only status surface);
|
|
12
|
+
* - `rulecode_deactivate`: `pd activation deactivate --activation-id
|
|
13
|
+
* recovery-probe-nonexistent --dry-run --json` — the REAL deactivate entry
|
|
14
|
+
* through real parsing, workspace binding, and target-resolution
|
|
15
|
+
* preconditions, with the dry-run guard returning BEFORE any governance
|
|
16
|
+
* audit write or store mutation. A nonexistent probe id keeps the
|
|
17
|
+
* precondition honest without touching any real activation.
|
|
18
|
+
*
|
|
19
|
+
* Console-channel capabilities (`rulecode_global_pause`,
|
|
20
|
+
* `owner_review_access`) can never be verified from a CLI subprocess — the
|
|
21
|
+
* caller receives explicit NOT-VERIFIED entries for them instead of
|
|
22
|
+
* fabricated ok flags (fail closed; SPEC R4 §2.4.7).
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* PRI-1202 — single budget authority.
|
|
26
|
+
*
|
|
27
|
+
* The CLI recovery probes run INSIDE one Owner Console HTTP request. The
|
|
28
|
+
* console wrapper (`asyncHandler`) answers 504 once its request budget
|
|
29
|
+
* expires, so two independent literals (probe 15s, request 10s) let a single
|
|
30
|
+
* probe outlive the request it belongs to. The console request budget is the
|
|
31
|
+
* authority; the probe budget is DERIVED from it and must stay strictly
|
|
32
|
+
* smaller, leaving fixed headroom for the console to serialize the response.
|
|
33
|
+
*/
|
|
34
|
+
export declare const CONSOLE_REQUEST_BUDGET_MS = 10000;
|
|
35
|
+
/** Headroom reserved inside the console request budget for response assembly. */
|
|
36
|
+
export declare const CLI_RECOVERY_PROBE_HEADROOM_MS = 2000;
|
|
37
|
+
export declare const CLI_RECOVERY_PROBE_TIMEOUT_MS: number;
|
|
2
38
|
export declare const DEACTIVATE_DRY_RUN_PROBE_ACTIVATION_ID = "recovery-probe-nonexistent";
|
|
3
39
|
/**
|
|
4
40
|
* Resolve the built pd CLI entry for the CURRENT environment. Both layouts
|
|
@@ -14,7 +50,12 @@ export interface CliRecoveryProbeOptions {
|
|
|
14
50
|
workspaceDir: string;
|
|
15
51
|
/** When supplied, the status listing must include this activation (workspace-targeting proof). */
|
|
16
52
|
expectedActivationId?: string;
|
|
17
|
-
/**
|
|
53
|
+
/**
|
|
54
|
+
* Probe budget in ms (default `CLI_RECOVERY_PROBE_TIMEOUT_MS`, derived from
|
|
55
|
+
* the console request budget). A timeout fails the capability closed —
|
|
56
|
+
* tests on loaded machines may raise it, but the default must stay strictly
|
|
57
|
+
* inside one console request.
|
|
58
|
+
*/
|
|
18
59
|
timeoutMs?: number;
|
|
19
60
|
}
|
|
20
61
|
/** `pd activation list --json` — the pd_status status surface, read-only. */
|