create-principles-disciple 1.152.2 → 1.152.4
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/_release/product-identity.json +1 -1
- package/codex-adapter/dist/pd-hook.js +34 -4
- package/codex-adapter/package.json +1 -1
- package/console/dist/server/config/pd-config-store.d.ts +48 -0
- package/console/dist/server/config/pd-config-store.js +273 -93
- package/console/dist/server/index.js +16 -1
- package/console/dist/server/models/ActivationsConsoleModel.d.ts +72 -1
- package/console/dist/server/models/ActivationsConsoleModel.js +92 -14
- package/console/dist/server/models/AdaptiveActivationConsoleModel.d.ts +79 -0
- package/console/dist/server/models/AdaptiveActivationConsoleModel.js +151 -0
- package/console/dist/server/models/ApprovalsConsoleModel.d.ts +28 -0
- package/console/dist/server/models/ApprovalsConsoleModel.js +118 -3
- package/console/dist/server/models/ApprovalsGroupedConsoleModel.d.ts +38 -0
- package/console/dist/server/models/ApprovalsGroupedConsoleModel.js +158 -26
- package/console/dist/server/models/IntentDecisionModel.d.ts +6 -1
- package/console/dist/server/models/IntentDecisionModel.js +17 -9
- package/console/dist/server/models/pipeline-health-metrics.d.ts +128 -0
- package/console/dist/server/models/pipeline-health-metrics.js +225 -0
- package/console/dist/server/routes/approvals.js +14 -0
- package/console/dist/server/routes/config.js +212 -1
- package/console/dist/server/routes/diagnostician.js +13 -2
- package/console/dist/server/routes/intent-decisions.js +19 -1
- package/console/dist/server/routes/pipeline-health.d.ts +9 -0
- package/console/dist/server/routes/pipeline-health.js +124 -0
- package/console/dist/web/assets/app.css +484 -67
- package/console/dist/web/assets/app.js +36 -31
- package/console/dist/web/assets/evidence-art-1.webp +0 -0
- package/console/dist/web/assets/evidence-art-2.webp +0 -0
- package/console/dist/web/assets/evidence-art-3.webp +0 -0
- package/console/dist/web/assets/evidence-art-4.webp +0 -0
- package/console/dist/web/assets/principle-grove.jpg +0 -0
- package/console/dist/web/assets/principle-stone-steps.jpg +0 -0
- package/console/dist/web/assets/principles-art-1.webp +0 -0
- package/console/dist/web/assets/principles-art-2.webp +0 -0
- package/console/dist/web/assets/principles-art-3.webp +0 -0
- package/console/dist/web/assets/principles-art-4.webp +0 -0
- package/console/dist/web/assets/today-art-1.webp +0 -0
- package/console/dist/web/assets/today-art-2.webp +0 -0
- package/console/dist/web/assets/today-art-3.webp +0 -0
- package/console/dist/web/assets/today-art-4.webp +0 -0
- package/core/dist/runtime/activation/activation-types.d.ts +6 -0
- package/core/dist/runtime/activation/activation-types.d.ts.map +1 -1
- package/core/dist/runtime/activation/activation-types.js.map +1 -1
- package/core/dist/runtime/activation/index.d.ts +2 -1
- package/core/dist/runtime/activation/index.d.ts.map +1 -1
- package/core/dist/runtime/activation/index.js +1 -1
- package/core/dist/runtime/activation/index.js.map +1 -1
- package/core/dist/runtime/activation/ledger-identity.d.ts +8 -0
- package/core/dist/runtime/activation/ledger-identity.d.ts.map +1 -1
- package/core/dist/runtime/activation/ledger-identity.js +20 -1
- package/core/dist/runtime/activation/ledger-identity.js.map +1 -1
- package/core/dist/runtime/activation/sqlite-approval-store.d.ts +18 -0
- package/core/dist/runtime/activation/sqlite-approval-store.d.ts.map +1 -1
- package/core/dist/runtime/activation/sqlite-approval-store.js +146 -20
- package/core/dist/runtime/activation/sqlite-approval-store.js.map +1 -1
- package/core/dist/runtime/adapter/artificer-l2-adapter.d.ts.map +1 -1
- package/core/dist/runtime/adapter/artificer-l2-adapter.js +11 -4
- package/core/dist/runtime/adapter/artificer-l2-adapter.js.map +1 -1
- package/core/dist/runtime/adapter/l2-agent-loop-adapter.d.ts.map +1 -1
- package/core/dist/runtime/adapter/l2-agent-loop-adapter.js +11 -4
- package/core/dist/runtime/adapter/l2-agent-loop-adapter.js.map +1 -1
- package/core/dist/runtime/adapter/output-repair-contract.d.ts +21 -1
- package/core/dist/runtime/adapter/output-repair-contract.d.ts.map +1 -1
- package/core/dist/runtime/adapter/output-repair-contract.js.map +1 -1
- package/core/dist/runtime/adapter/pi-ai-catalog.d.ts +42 -0
- package/core/dist/runtime/adapter/pi-ai-catalog.d.ts.map +1 -1
- package/core/dist/runtime/adapter/pi-ai-catalog.js +68 -0
- package/core/dist/runtime/adapter/pi-ai-catalog.js.map +1 -1
- package/core/dist/runtime/adapter/pi-ai-connection-probe.d.ts +45 -0
- package/core/dist/runtime/adapter/pi-ai-connection-probe.d.ts.map +1 -0
- package/core/dist/runtime/adapter/pi-ai-connection-probe.js +321 -0
- package/core/dist/runtime/adapter/pi-ai-connection-probe.js.map +1 -0
- package/core/dist/runtime/adapter/pi-ai-runtime-adapter.d.ts +27 -2
- package/core/dist/runtime/adapter/pi-ai-runtime-adapter.d.ts.map +1 -1
- package/core/dist/runtime/adapter/pi-ai-runtime-adapter.js +71 -10
- package/core/dist/runtime/adapter/pi-ai-runtime-adapter.js.map +1 -1
- package/core/dist/runtime/adapter/schema-prompt-adapter.d.ts.map +1 -1
- package/core/dist/runtime/adapter/schema-prompt-adapter.js +39 -6
- package/core/dist/runtime/adapter/schema-prompt-adapter.js.map +1 -1
- package/core/dist/runtime/adapter/structured-output-repair.d.ts +26 -0
- package/core/dist/runtime/adapter/structured-output-repair.d.ts.map +1 -1
- package/core/dist/runtime/adapter/structured-output-repair.js +140 -2
- package/core/dist/runtime/adapter/structured-output-repair.js.map +1 -1
- package/core/dist/runtime/config/execution-timing.d.ts +56 -0
- package/core/dist/runtime/config/execution-timing.d.ts.map +1 -0
- package/core/dist/runtime/config/execution-timing.js +76 -0
- package/core/dist/runtime/config/execution-timing.js.map +1 -0
- package/core/dist/runtime/config/index.d.ts +4 -0
- package/core/dist/runtime/config/index.d.ts.map +1 -1
- package/core/dist/runtime/config/index.js +2 -0
- package/core/dist/runtime/config/index.js.map +1 -1
- package/core/dist/runtime/config/pd-config-redaction.d.ts.map +1 -1
- package/core/dist/runtime/config/pd-config-redaction.js +4 -0
- package/core/dist/runtime/config/pd-config-redaction.js.map +1 -1
- package/core/dist/runtime/config/pd-config-types.d.ts +5 -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-credentials.d.ts +105 -0
- package/core/dist/runtime/config/pd-credentials.d.ts.map +1 -0
- package/core/dist/runtime/config/pd-credentials.js +409 -0
- package/core/dist/runtime/config/pd-credentials.js.map +1 -0
- package/core/dist/runtime/diagnostician/diag-rootcause-output.d.ts +13 -2
- package/core/dist/runtime/diagnostician/diag-rootcause-output.d.ts.map +1 -1
- package/core/dist/runtime/diagnostician/diag-rootcause-output.js.map +1 -1
- package/core/dist/runtime/diagnostician/diagnostic-context-budget.d.ts +45 -0
- package/core/dist/runtime/diagnostician/diagnostic-context-budget.d.ts.map +1 -0
- package/core/dist/runtime/diagnostician/diagnostic-context-budget.js +74 -0
- package/core/dist/runtime/diagnostician/diagnostic-context-budget.js.map +1 -0
- package/core/dist/runtime/diagnostician/prompt-projection.d.ts +51 -0
- package/core/dist/runtime/diagnostician/prompt-projection.d.ts.map +1 -0
- package/core/dist/runtime/diagnostician/prompt-projection.js +192 -0
- package/core/dist/runtime/diagnostician/prompt-projection.js.map +1 -0
- package/core/dist/runtime/diagnostician-output.d.ts +1 -1
- package/core/dist/runtime/diagnostician-output.d.ts.map +1 -1
- package/core/dist/runtime/diagnostician-output.js +2 -2
- package/core/dist/runtime/diagnostician-output.js.map +1 -1
- package/core/dist/runtime/index.d.ts +5 -2
- package/core/dist/runtime/index.d.ts.map +1 -1
- package/core/dist/runtime/index.js +11 -1
- package/core/dist/runtime/index.js.map +1 -1
- package/core/dist/runtime/intent/index.d.ts +2 -0
- package/core/dist/runtime/intent/index.d.ts.map +1 -1
- package/core/dist/runtime/intent/index.js +2 -0
- package/core/dist/runtime/intent/index.js.map +1 -1
- package/core/dist/runtime/intent/intent-decision-record.d.ts +51 -3
- package/core/dist/runtime/intent/intent-decision-record.d.ts.map +1 -1
- package/core/dist/runtime/intent/intent-snapshot.d.ts +104 -0
- package/core/dist/runtime/intent/intent-snapshot.d.ts.map +1 -0
- package/core/dist/runtime/intent/intent-snapshot.js +164 -0
- package/core/dist/runtime/intent/intent-snapshot.js.map +1 -0
- package/core/dist/runtime/intent/strategic-conflict-gate.d.ts +70 -0
- package/core/dist/runtime/intent/strategic-conflict-gate.d.ts.map +1 -0
- package/core/dist/runtime/intent/strategic-conflict-gate.js +148 -0
- package/core/dist/runtime/intent/strategic-conflict-gate.js.map +1 -0
- package/core/dist/runtime/internalization/artificer-runner.js +1 -1
- package/core/dist/runtime/internalization/artificer-runner.js.map +1 -1
- package/core/dist/runtime/internalization/diag-distiller-runner.d.ts +6 -0
- package/core/dist/runtime/internalization/diag-distiller-runner.d.ts.map +1 -1
- package/core/dist/runtime/internalization/diag-distiller-runner.js +62 -5
- package/core/dist/runtime/internalization/diag-distiller-runner.js.map +1 -1
- package/core/dist/runtime/internalization/diag-rootcause-runner.d.ts +41 -1
- package/core/dist/runtime/internalization/diag-rootcause-runner.d.ts.map +1 -1
- package/core/dist/runtime/internalization/diag-rootcause-runner.js +190 -43
- package/core/dist/runtime/internalization/diag-rootcause-runner.js.map +1 -1
- package/core/dist/runtime/internalization/diag-router-runner.d.ts +6 -0
- package/core/dist/runtime/internalization/diag-router-runner.d.ts.map +1 -1
- package/core/dist/runtime/internalization/diag-router-runner.js +114 -69
- package/core/dist/runtime/internalization/diag-router-runner.js.map +1 -1
- package/core/dist/runtime/internalization/dreamer-prompt-builder.d.ts.map +1 -1
- package/core/dist/runtime/internalization/dreamer-prompt-builder.js +3 -0
- package/core/dist/runtime/internalization/dreamer-prompt-builder.js.map +1 -1
- package/core/dist/runtime/internalization/dreamer-runner.js +1 -1
- package/core/dist/runtime/internalization/dreamer-runner.js.map +1 -1
- package/core/dist/runtime/internalization/evaluator-runner.js +4 -4
- package/core/dist/runtime/internalization/evaluator-runner.js.map +1 -1
- package/core/dist/runtime/internalization/formation-context.d.ts +54 -0
- package/core/dist/runtime/internalization/formation-context.d.ts.map +1 -1
- package/core/dist/runtime/internalization/formation-context.js +135 -3
- package/core/dist/runtime/internalization/formation-context.js.map +1 -1
- package/core/dist/runtime/internalization/index.d.ts +2 -2
- package/core/dist/runtime/internalization/index.d.ts.map +1 -1
- package/core/dist/runtime/internalization/index.js +1 -1
- package/core/dist/runtime/internalization/index.js.map +1 -1
- package/core/dist/runtime/internalization/intent-contract.d.ts +107 -0
- package/core/dist/runtime/internalization/intent-contract.d.ts.map +1 -1
- package/core/dist/runtime/internalization/intent-contract.js +315 -4
- package/core/dist/runtime/internalization/intent-contract.js.map +1 -1
- package/core/dist/runtime/internalization/peer-runner-contracts.d.ts +8 -0
- package/core/dist/runtime/internalization/peer-runner-contracts.d.ts.map +1 -1
- package/core/dist/runtime/internalization/peer-runner-contracts.js.map +1 -1
- package/core/dist/runtime/internalization/philosopher-prompt-builder.d.ts +22 -1
- package/core/dist/runtime/internalization/philosopher-prompt-builder.d.ts.map +1 -1
- package/core/dist/runtime/internalization/philosopher-prompt-builder.js +22 -3
- package/core/dist/runtime/internalization/philosopher-prompt-builder.js.map +1 -1
- package/core/dist/runtime/internalization/philosopher-runner.d.ts +15 -0
- package/core/dist/runtime/internalization/philosopher-runner.d.ts.map +1 -1
- package/core/dist/runtime/internalization/philosopher-runner.js +74 -2
- package/core/dist/runtime/internalization/philosopher-runner.js.map +1 -1
- package/core/dist/runtime/internalization/pitask-metadata.d.ts +32 -0
- package/core/dist/runtime/internalization/pitask-metadata.d.ts.map +1 -1
- package/core/dist/runtime/internalization/pitask-metadata.js +44 -0
- package/core/dist/runtime/internalization/pitask-metadata.js.map +1 -1
- package/core/dist/runtime/internalization/rollout-reviewer-runner.d.ts +6 -1
- package/core/dist/runtime/internalization/rollout-reviewer-runner.d.ts.map +1 -1
- package/core/dist/runtime/internalization/rollout-reviewer-runner.js +31 -15
- package/core/dist/runtime/internalization/rollout-reviewer-runner.js.map +1 -1
- package/core/dist/runtime/internalization/scribe-output.d.ts +21 -0
- package/core/dist/runtime/internalization/scribe-output.d.ts.map +1 -1
- package/core/dist/runtime/internalization/scribe-output.js +125 -2
- package/core/dist/runtime/internalization/scribe-output.js.map +1 -1
- package/core/dist/runtime/internalization/scribe-prompt-builder.d.ts +26 -1
- package/core/dist/runtime/internalization/scribe-prompt-builder.d.ts.map +1 -1
- package/core/dist/runtime/internalization/scribe-prompt-builder.js +33 -3
- package/core/dist/runtime/internalization/scribe-prompt-builder.js.map +1 -1
- package/core/dist/runtime/internalization/scribe-runner.d.ts +32 -2
- package/core/dist/runtime/internalization/scribe-runner.d.ts.map +1 -1
- package/core/dist/runtime/internalization/scribe-runner.js +106 -8
- package/core/dist/runtime/internalization/scribe-runner.js.map +1 -1
- package/core/dist/runtime/internalization/split-diagnostician-runner.d.ts +46 -0
- package/core/dist/runtime/internalization/split-diagnostician-runner.d.ts.map +1 -1
- package/core/dist/runtime/internalization/split-diagnostician-runner.js +220 -20
- package/core/dist/runtime/internalization/split-diagnostician-runner.js.map +1 -1
- package/core/dist/runtime/internalization-integrity-remediation.d.ts +7 -0
- package/core/dist/runtime/internalization-integrity-remediation.d.ts.map +1 -1
- package/core/dist/runtime/internalization-integrity-remediation.js +44 -12
- package/core/dist/runtime/internalization-integrity-remediation.js.map +1 -1
- package/core/dist/runtime/pain-signal-runtime-factory.d.ts.map +1 -1
- package/core/dist/runtime/pain-signal-runtime-factory.js +25 -4
- package/core/dist/runtime/pain-signal-runtime-factory.js.map +1 -1
- package/core/dist/runtime/pain-submit-capability.js +5 -5
- package/core/dist/runtime/pain-submit-capability.js.map +1 -1
- package/core/dist/runtime/runner/base-peer-runner.d.ts +90 -2
- package/core/dist/runtime/runner/base-peer-runner.d.ts.map +1 -1
- package/core/dist/runtime/runner/base-peer-runner.js +463 -170
- package/core/dist/runtime/runner/base-peer-runner.js.map +1 -1
- package/core/dist/runtime/runner/peer-runner-types.d.ts +19 -0
- package/core/dist/runtime/runner/peer-runner-types.d.ts.map +1 -1
- package/core/dist/runtime/runtime-protocol.d.ts +19 -0
- package/core/dist/runtime/runtime-protocol.d.ts.map +1 -1
- package/core/dist/runtime/signal-collector/llm-stage.d.ts +5 -0
- package/core/dist/runtime/signal-collector/llm-stage.d.ts.map +1 -1
- package/core/dist/runtime/signal-collector/llm-stage.js.map +1 -1
- package/core/dist/runtime/store/artifact/sqlite-pi-artifact-store.d.ts +14 -0
- package/core/dist/runtime/store/artifact/sqlite-pi-artifact-store.d.ts.map +1 -1
- package/core/dist/runtime/store/artifact/sqlite-pi-artifact-store.js +16 -1
- package/core/dist/runtime/store/artifact/sqlite-pi-artifact-store.js.map +1 -1
- package/core/dist/runtime/store/commit/diagnostician-committer.d.ts +19 -0
- package/core/dist/runtime/store/commit/diagnostician-committer.d.ts.map +1 -1
- package/core/dist/runtime/store/commit/diagnostician-committer.js +11 -0
- package/core/dist/runtime/store/commit/diagnostician-committer.js.map +1 -1
- package/core/dist/runtime/store/intent/sqlite-intent-decision-store.d.ts +2 -2
- package/core/dist/runtime/store/intent/sqlite-intent-decision-store.d.ts.map +1 -1
- package/core/dist/runtime/store/intent/sqlite-intent-decision-store.js +285 -35
- package/core/dist/runtime/store/intent/sqlite-intent-decision-store.js.map +1 -1
- package/core/dist/runtime/store/lifecycle/fenced-task-writer.d.ts +64 -0
- package/core/dist/runtime/store/lifecycle/fenced-task-writer.d.ts.map +1 -0
- package/core/dist/runtime/store/lifecycle/fenced-task-writer.js +231 -0
- package/core/dist/runtime/store/lifecycle/fenced-task-writer.js.map +1 -0
- package/core/dist/runtime/store/lifecycle/index.d.ts +2 -0
- package/core/dist/runtime/store/lifecycle/index.d.ts.map +1 -1
- package/core/dist/runtime/store/lifecycle/index.js +1 -0
- package/core/dist/runtime/store/lifecycle/index.js.map +1 -1
- package/core/dist/runtime/store/lifecycle/lease-fence.d.ts +80 -0
- package/core/dist/runtime/store/lifecycle/lease-fence.d.ts.map +1 -0
- package/core/dist/runtime/store/lifecycle/lease-fence.js +79 -0
- package/core/dist/runtime/store/lifecycle/lease-fence.js.map +1 -0
- package/core/dist/runtime/store/lifecycle/lease-heartbeat.d.ts +118 -0
- package/core/dist/runtime/store/lifecycle/lease-heartbeat.d.ts.map +1 -0
- package/core/dist/runtime/store/lifecycle/lease-heartbeat.js +187 -0
- package/core/dist/runtime/store/lifecycle/lease-heartbeat.js.map +1 -0
- package/core/dist/runtime/store/lifecycle/lease-manager.d.ts +30 -20
- package/core/dist/runtime/store/lifecycle/lease-manager.d.ts.map +1 -1
- package/core/dist/runtime/store/lifecycle/lease-manager.js +94 -53
- package/core/dist/runtime/store/lifecycle/lease-manager.js.map +1 -1
- package/core/dist/runtime/store/lifecycle/recovery-sweep.d.ts.map +1 -1
- package/core/dist/runtime/store/lifecycle/recovery-sweep.js +32 -15
- package/core/dist/runtime/store/lifecycle/recovery-sweep.js.map +1 -1
- package/core/dist/runtime/store/run/sqlite-run-store.d.ts +29 -0
- package/core/dist/runtime/store/run/sqlite-run-store.d.ts.map +1 -1
- package/core/dist/runtime/store/run/sqlite-run-store.js +40 -0
- package/core/dist/runtime/store/run/sqlite-run-store.js.map +1 -1
- package/core/dist/runtime/store/runtime-state-manager.d.ts +64 -10
- package/core/dist/runtime/store/runtime-state-manager.d.ts.map +1 -1
- package/core/dist/runtime/store/runtime-state-manager.js +154 -89
- package/core/dist/runtime/store/runtime-state-manager.js.map +1 -1
- package/core/dist/runtime/store/sqlite-connection.d.ts.map +1 -1
- package/core/dist/runtime/store/sqlite-connection.js +73 -4
- package/core/dist/runtime/store/sqlite-connection.js.map +1 -1
- package/core/dist/runtime/store/task/sqlite-task-store.d.ts.map +1 -1
- package/core/dist/runtime/store/task/sqlite-task-store.js +6 -3
- package/core/dist/runtime/store/task/sqlite-task-store.js.map +1 -1
- package/core/dist/runtime/task-status.d.ts +16 -0
- package/core/dist/runtime/task-status.d.ts.map +1 -1
- package/core/dist/runtime/task-status.js +8 -0
- package/core/dist/runtime/task-status.js.map +1 -1
- package/core/dist/runtime/trajectory-schema.d.ts.map +1 -1
- package/core/dist/runtime/trajectory-schema.js +20 -1
- package/core/dist/runtime/trajectory-schema.js.map +1 -1
- package/core/dist/runtime/types/event-types.d.ts +20 -0
- package/core/dist/runtime/types/event-types.d.ts.map +1 -1
- package/core/dist/runtime/types/event-types.js +7 -0
- package/core/dist/runtime/types/event-types.js.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 +27 -2
- package/core/dist/telemetry-event.js.map +1 -1
- package/core/dist/trajectory-types.d.ts +33 -0
- package/core/dist/trajectory-types.d.ts.map +1 -1
- package/core/package.json +1 -1
- package/dist/installer.d.ts.map +1 -1
- package/dist/installer.js +12 -5
- package/dist/installer.js.map +1 -1
- package/dist/installers/codex-host-installer.d.ts.map +1 -1
- package/dist/installers/codex-host-installer.js +9 -12
- package/dist/installers/codex-host-installer.js.map +1 -1
- package/host-runtime/dist/adaptive-consumer-schedule.d.ts +103 -0
- package/host-runtime/dist/adaptive-consumer-schedule.js +145 -0
- package/host-runtime/dist/adaptive-priority-provider.d.ts +7 -1
- package/host-runtime/dist/adaptive-priority-provider.js +6 -3
- package/host-runtime/dist/adaptive-selection.d.ts +1 -1
- package/host-runtime/dist/adaptive-selection.js +2 -1
- package/host-runtime/dist/degraded-enforcement-marker.d.ts +35 -0
- package/host-runtime/dist/degraded-enforcement-marker.js +79 -0
- package/host-runtime/dist/index.d.ts +2 -0
- package/host-runtime/dist/index.js +8 -0
- package/host-runtime/dist/internalization-consumer-cycle.d.ts +35 -0
- package/host-runtime/dist/internalization-consumer-cycle.js +51 -17
- package/host-runtime/dist/prompt-activation-deliverability.d.ts +10 -0
- package/host-runtime/dist/prompt-activation-deliverability.js +5 -2
- package/host-runtime/dist/prompt-injection-event-evidence.d.ts +34 -0
- package/host-runtime/dist/prompt-injection-event-evidence.js +96 -0
- package/host-runtime/dist/signal-classifier.js +4 -4
- package/host-runtime/package.json +1 -1
- package/install-layout/dist/mcp-binding-contract.js +4 -15
- package/install-layout/package.json +1 -1
- package/package.json +3 -3
- package/pd-cli/dist/commands/health-codex.d.ts.map +1 -1
- package/pd-cli/dist/commands/health-codex.js +26 -1
- package/pd-cli/dist/commands/health-codex.js.map +1 -1
- package/pd-cli/dist/commands/health.d.ts.map +1 -1
- package/pd-cli/dist/commands/health.js +32 -2
- package/pd-cli/dist/commands/health.js.map +1 -1
- package/pd-cli/dist/commands/pain-retry.d.ts.map +1 -1
- package/pd-cli/dist/commands/pain-retry.js +6 -4
- package/pd-cli/dist/commands/pain-retry.js.map +1 -1
- package/pd-cli/dist/commands/runtime-init.d.ts.map +1 -1
- package/pd-cli/dist/commands/runtime-init.js +29 -1
- package/pd-cli/dist/commands/runtime-init.js.map +1 -1
- package/pd-cli/dist/commands/runtime-internalization-run-once.d.ts.map +1 -1
- package/pd-cli/dist/commands/runtime-internalization-run-once.js +9 -14
- package/pd-cli/dist/commands/runtime-internalization-run-once.js.map +1 -1
- package/pd-cli/dist/commands/runtime-internalization-run-rulehost.d.ts.map +1 -1
- package/pd-cli/dist/commands/runtime-internalization-run-rulehost.js +5 -5
- package/pd-cli/dist/commands/runtime-internalization-run-rulehost.js.map +1 -1
- package/pd-cli/dist/commands/runtime-usage.d.ts +62 -0
- package/pd-cli/dist/commands/runtime-usage.d.ts.map +1 -0
- package/pd-cli/dist/commands/runtime-usage.js +315 -0
- package/pd-cli/dist/commands/runtime-usage.js.map +1 -0
- package/pd-cli/dist/commands/runtime.js +6 -6
- package/pd-cli/dist/commands/runtime.js.map +1 -1
- package/pd-cli/dist/index.d.ts.map +1 -1
- package/pd-cli/dist/index.js +51 -17
- package/pd-cli/dist/index.js.map +1 -1
- package/pd-cli/dist/program.d.ts.map +1 -1
- package/pd-cli/dist/program.js +4 -0
- package/pd-cli/dist/program.js.map +1 -1
- package/pd-cli/dist/services/cli-invocation-log.d.ts +66 -0
- package/pd-cli/dist/services/cli-invocation-log.d.ts.map +1 -0
- package/pd-cli/dist/services/cli-invocation-log.js +139 -0
- package/pd-cli/dist/services/cli-invocation-log.js.map +1 -0
- package/pd-cli/dist/services/config-doctor.d.ts.map +1 -1
- package/pd-cli/dist/services/config-doctor.js +5 -4
- package/pd-cli/dist/services/config-doctor.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 -2
- package/pd-cli/dist/services/demo-story-a-runner.js.map +1 -1
- package/pd-cli/dist/services/pd-config-loader.d.ts +3 -1
- package/pd-cli/dist/services/pd-config-loader.d.ts.map +1 -1
- package/pd-cli/dist/services/pd-config-loader.js +20 -8
- package/pd-cli/dist/services/pd-config-loader.js.map +1 -1
- package/pd-cli/dist/services/runtime-adapter-resolver.d.ts.map +1 -1
- package/pd-cli/dist/services/runtime-adapter-resolver.js +5 -5
- package/pd-cli/dist/services/runtime-adapter-resolver.js.map +1 -1
- package/pd-cli/package.json +1 -1
- package/plugin/dist/bundle.js +632 -536
- package/plugin/dist/core/signal-collector-host.d.ts +5 -0
- package/plugin/dist/governance-audit.js +2 -2
- package/plugin/dist/openclaw.plugin.json +1 -1
- package/plugin/dist/rulehost-evidence.js +13 -10
- package/plugin/dist/service/internalization-auto-consumer-service.d.ts +2 -1
- package/plugin/dist/templates/langs/en/skills/pd-pain-signal/SKILL.md +1 -1
- package/plugin/dist/templates/langs/zh/skills/pd-pain-signal/SKILL.md +1 -1
- package/plugin/openclaw.plugin.json +1 -1
- package/plugin/package.json +1 -1
- package/plugin/templates/langs/en/skills/pd-pain-signal/SKILL.md +1 -1
- package/plugin/templates/langs/zh/skills/pd-pain-signal/SKILL.md +1 -1
- package/release-manager/dist/installer.js +12 -5
- package/release-manager/dist/installers/codex-host-installer.js +9 -12
- package/release-manager/package.json +1 -1
- package/workbuddy-adapter/package.json +1 -1
- package/workbuddy-adapter/plugin/skills/pd-pain-signal/SKILL.md +1 -1
- package/dist/installers/mcp-binding-shape-mirror.d.ts +0 -27
- package/dist/installers/mcp-binding-shape-mirror.d.ts.map +0 -1
- package/dist/installers/mcp-binding-shape-mirror.js +0 -105
- package/dist/installers/mcp-binding-shape-mirror.js.map +0 -1
- package/release-manager/dist/installers/mcp-binding-shape-mirror.js +0 -105
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pipeline health metrics (SPEC-PD-PIPELINE-RELIABILITY-AND-EFFICIENCY-001 §3).
|
|
3
|
+
*
|
|
4
|
+
* Lives in the Console server model layer on purpose: it is a presentation read
|
|
5
|
+
* model over core's persisted facts, not a domain capability. Keeping it here
|
|
6
|
+
* means the core public surface does not grow for a single host consumer
|
|
7
|
+
* (see the core export-surface admission rule).
|
|
8
|
+
*
|
|
9
|
+
* Read-model ONLY. Every number is derived from the facts the runtime already
|
|
10
|
+
* persists (`tasks`, `runs`) — nothing here writes state, creates a second
|
|
11
|
+
* source of truth, or estimates a value it cannot observe.
|
|
12
|
+
*
|
|
13
|
+
* Honesty rules (rc-9, SPEC §3.4):
|
|
14
|
+
* - a metric whose data is not persisted is reported `available: false` with
|
|
15
|
+
* an explicit reason. It is NEVER reported as 0.
|
|
16
|
+
* - percentiles are nearest-rank over the observed samples in the window; a
|
|
17
|
+
* sample count of 0 yields nulls, not zeros.
|
|
18
|
+
* - the window is explicit so a caller can never present lifetime totals as
|
|
19
|
+
* "recent".
|
|
20
|
+
*/
|
|
21
|
+
import type { TaskRecord } from '@principles/core/runtime';
|
|
22
|
+
/**
|
|
23
|
+
* Structural mirror of `SqliteRunStore.listStageRunSamples`'s row shape
|
|
24
|
+
* (core keeps that DTO module-internal). The store is the only producer; this
|
|
25
|
+
* declaration must stay structurally identical.
|
|
26
|
+
*/
|
|
27
|
+
export interface StageRunSample {
|
|
28
|
+
readonly runId: string;
|
|
29
|
+
readonly taskId: string;
|
|
30
|
+
readonly taskKind: string;
|
|
31
|
+
readonly startedAt: string;
|
|
32
|
+
readonly endedAt: string | null;
|
|
33
|
+
readonly executionStatus: string;
|
|
34
|
+
readonly errorCategory: string | null;
|
|
35
|
+
readonly attemptNumber: number;
|
|
36
|
+
}
|
|
37
|
+
export interface LatencySummary {
|
|
38
|
+
readonly sampleCount: number;
|
|
39
|
+
readonly p50Ms: number | null;
|
|
40
|
+
readonly p95Ms: number | null;
|
|
41
|
+
readonly p99Ms: number | null;
|
|
42
|
+
readonly maxMs: number | null;
|
|
43
|
+
}
|
|
44
|
+
export interface MetricAvailability<T> {
|
|
45
|
+
readonly available: boolean;
|
|
46
|
+
readonly value: T | null;
|
|
47
|
+
readonly reason?: string;
|
|
48
|
+
}
|
|
49
|
+
export interface StageMetrics {
|
|
50
|
+
readonly taskKind: string;
|
|
51
|
+
readonly sampleCount: number;
|
|
52
|
+
readonly successCount: number;
|
|
53
|
+
readonly failureCount: number;
|
|
54
|
+
readonly retryRunCount: number;
|
|
55
|
+
readonly duration: LatencySummary;
|
|
56
|
+
}
|
|
57
|
+
export interface RecentPipelineExecution {
|
|
58
|
+
readonly taskId: string;
|
|
59
|
+
readonly parentTaskId: string | null;
|
|
60
|
+
readonly stage: 'A' | 'B' | 'C' | null;
|
|
61
|
+
readonly taskKind: string;
|
|
62
|
+
readonly status: string;
|
|
63
|
+
readonly attemptCount: number;
|
|
64
|
+
readonly startedAt: string | null;
|
|
65
|
+
readonly endedAt: string | null;
|
|
66
|
+
readonly durationMs: number | null;
|
|
67
|
+
readonly errorCategory: string | null;
|
|
68
|
+
}
|
|
69
|
+
export interface PipelineHealthMetrics {
|
|
70
|
+
readonly generatedAt: string;
|
|
71
|
+
readonly windowMs: number;
|
|
72
|
+
readonly queue: {
|
|
73
|
+
/** Parent diagnostician tasks waiting for (or being) diagnosed. */
|
|
74
|
+
readonly painQueueDepth: number;
|
|
75
|
+
/** Downstream internalization tasks ready to run. */
|
|
76
|
+
readonly readyQueueDepth: number;
|
|
77
|
+
readonly retryQueueDepth: number;
|
|
78
|
+
readonly leasedCount: number;
|
|
79
|
+
readonly oldestPendingAgeMs: number | null;
|
|
80
|
+
readonly oldestPendingTaskKind: string | null;
|
|
81
|
+
};
|
|
82
|
+
readonly stage2: {
|
|
83
|
+
readonly pendingDepth: MetricAvailability<number>;
|
|
84
|
+
};
|
|
85
|
+
readonly stages: {
|
|
86
|
+
readonly a: StageMetrics;
|
|
87
|
+
readonly b: StageMetrics;
|
|
88
|
+
readonly c: StageMetrics;
|
|
89
|
+
};
|
|
90
|
+
readonly queueWait: LatencySummary;
|
|
91
|
+
readonly reliability: {
|
|
92
|
+
readonly stageRetryCount: number;
|
|
93
|
+
/** Leases that are leased RIGHT NOW but already expired. */
|
|
94
|
+
readonly expiredActiveLeaseCount: number;
|
|
95
|
+
readonly diagnosisSuccessRate: MetricAvailability<number>;
|
|
96
|
+
readonly leaseRenewalFailureCount: MetricAvailability<number>;
|
|
97
|
+
readonly leaseRecoveryCount: MetricAvailability<number>;
|
|
98
|
+
readonly staleCommitRejectedCount: MetricAvailability<number>;
|
|
99
|
+
};
|
|
100
|
+
readonly provider: {
|
|
101
|
+
readonly errorRate: MetricAvailability<number>;
|
|
102
|
+
readonly errorCountsByCategory: Readonly<Record<string, number>>;
|
|
103
|
+
readonly rateLimitCount: number;
|
|
104
|
+
readonly timeoutCount: number;
|
|
105
|
+
};
|
|
106
|
+
readonly tokens: {
|
|
107
|
+
readonly tokensPerPain: MetricAvailability<number>;
|
|
108
|
+
};
|
|
109
|
+
readonly lineage: {
|
|
110
|
+
readonly available: boolean;
|
|
111
|
+
readonly reason?: string;
|
|
112
|
+
readonly recentExecutions: readonly RecentPipelineExecution[];
|
|
113
|
+
};
|
|
114
|
+
readonly notes: readonly string[];
|
|
115
|
+
}
|
|
116
|
+
export declare const DIAGNOSTICIAN_PARENT_TASK_KIND = "diagnostician";
|
|
117
|
+
export declare const STAGE_TASK_KIND_A = "diag_rootcause";
|
|
118
|
+
export declare const STAGE_TASK_KIND_B = "diag_distiller";
|
|
119
|
+
export declare const STAGE_TASK_KIND_C = "diag_router";
|
|
120
|
+
export declare function summarizeLatencies(samples: readonly number[]): LatencySummary;
|
|
121
|
+
/** `diag_rootcause-<parentTaskId>` → `<parentTaskId>`; anything else → null. */
|
|
122
|
+
export declare function parentTaskIdFromStageTaskId(taskId: string): string | null;
|
|
123
|
+
export declare function buildPipelineHealthMetrics(input: {
|
|
124
|
+
readonly nowMs: number;
|
|
125
|
+
readonly windowMs: number;
|
|
126
|
+
readonly tasks: readonly TaskRecord[];
|
|
127
|
+
readonly stageRuns: readonly StageRunSample[];
|
|
128
|
+
}): PipelineHealthMetrics;
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
export const DIAGNOSTICIAN_PARENT_TASK_KIND = 'diagnostician';
|
|
2
|
+
export const STAGE_TASK_KIND_A = 'diag_rootcause';
|
|
3
|
+
export const STAGE_TASK_KIND_B = 'diag_distiller';
|
|
4
|
+
export const STAGE_TASK_KIND_C = 'diag_router';
|
|
5
|
+
const INTERNALIZATION_KINDS = ['dreamer', 'philosopher', 'scribe', 'artificer', 'evaluator', 'rollout_reviewer'];
|
|
6
|
+
const STAGE_KINDS = [STAGE_TASK_KIND_A, STAGE_TASK_KIND_B, STAGE_TASK_KIND_C];
|
|
7
|
+
const RECENT_EXECUTION_LIMIT = 20;
|
|
8
|
+
function available(value) {
|
|
9
|
+
return { available: true, value };
|
|
10
|
+
}
|
|
11
|
+
function unavailable(reason) {
|
|
12
|
+
return { available: false, value: null, reason };
|
|
13
|
+
}
|
|
14
|
+
/** Nearest-rank percentile over a NON-EMPTY, ascending array. */
|
|
15
|
+
function percentile(sorted, p) {
|
|
16
|
+
const rank = Math.max(1, Math.ceil(p * sorted.length));
|
|
17
|
+
return sorted[Math.min(sorted.length - 1, rank - 1)] ?? 0;
|
|
18
|
+
}
|
|
19
|
+
export function summarizeLatencies(samples) {
|
|
20
|
+
const clean = samples.filter((value) => Number.isFinite(value) && value >= 0).slice().sort((a, b) => a - b);
|
|
21
|
+
if (clean.length === 0) {
|
|
22
|
+
return { sampleCount: 0, p50Ms: null, p95Ms: null, p99Ms: null, maxMs: null };
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
sampleCount: clean.length,
|
|
26
|
+
p50Ms: percentile(clean, 0.5),
|
|
27
|
+
p95Ms: percentile(clean, 0.95),
|
|
28
|
+
p99Ms: percentile(clean, 0.99),
|
|
29
|
+
maxMs: clean[clean.length - 1] ?? null,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function durationMs(startedAt, endedAt) {
|
|
33
|
+
if (endedAt === null)
|
|
34
|
+
return null;
|
|
35
|
+
const start = Date.parse(startedAt);
|
|
36
|
+
const end = Date.parse(endedAt);
|
|
37
|
+
if (!Number.isFinite(start) || !Number.isFinite(end) || end < start)
|
|
38
|
+
return null;
|
|
39
|
+
return end - start;
|
|
40
|
+
}
|
|
41
|
+
function stageOf(taskKind) {
|
|
42
|
+
if (taskKind === STAGE_TASK_KIND_A)
|
|
43
|
+
return 'A';
|
|
44
|
+
if (taskKind === STAGE_TASK_KIND_B)
|
|
45
|
+
return 'B';
|
|
46
|
+
if (taskKind === STAGE_TASK_KIND_C)
|
|
47
|
+
return 'C';
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
/** `diag_rootcause-<parentTaskId>` → `<parentTaskId>`; anything else → null. */
|
|
51
|
+
export function parentTaskIdFromStageTaskId(taskId) {
|
|
52
|
+
const match = /^(?:diag_rootcause|diag_distiller|diag_router)-(.+)$/.exec(taskId);
|
|
53
|
+
return match?.[1] ?? null;
|
|
54
|
+
}
|
|
55
|
+
function stageMetrics(taskKind, runs) {
|
|
56
|
+
const stageRuns = runs.filter((run) => run.taskKind === taskKind);
|
|
57
|
+
const durations = [];
|
|
58
|
+
let successCount = 0;
|
|
59
|
+
let failureCount = 0;
|
|
60
|
+
let retryRunCount = 0;
|
|
61
|
+
for (const run of stageRuns) {
|
|
62
|
+
const d = durationMs(run.startedAt, run.endedAt);
|
|
63
|
+
if (d !== null)
|
|
64
|
+
durations.push(d);
|
|
65
|
+
if (run.executionStatus === 'succeeded')
|
|
66
|
+
successCount += 1;
|
|
67
|
+
if (run.executionStatus === 'failed')
|
|
68
|
+
failureCount += 1;
|
|
69
|
+
if (run.attemptNumber > 0)
|
|
70
|
+
retryRunCount += 1;
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
taskKind,
|
|
74
|
+
sampleCount: stageRuns.length,
|
|
75
|
+
successCount,
|
|
76
|
+
failureCount,
|
|
77
|
+
retryRunCount,
|
|
78
|
+
duration: summarizeLatencies(durations),
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
function ageMs(iso, nowMs) {
|
|
82
|
+
if (typeof iso !== 'string' || iso.length === 0)
|
|
83
|
+
return null;
|
|
84
|
+
const parsed = Date.parse(iso);
|
|
85
|
+
if (!Number.isFinite(parsed))
|
|
86
|
+
return null;
|
|
87
|
+
return Math.max(0, nowMs - parsed);
|
|
88
|
+
}
|
|
89
|
+
/** First attempt's start minus the task's creation = time spent waiting. */
|
|
90
|
+
function queueWaitSamples(tasksById, runs) {
|
|
91
|
+
const firstStartByTask = new Map();
|
|
92
|
+
for (const run of runs) {
|
|
93
|
+
const start = Date.parse(run.startedAt);
|
|
94
|
+
if (!Number.isFinite(start))
|
|
95
|
+
continue;
|
|
96
|
+
const current = firstStartByTask.get(run.taskId);
|
|
97
|
+
if (current === undefined || start < current)
|
|
98
|
+
firstStartByTask.set(run.taskId, start);
|
|
99
|
+
}
|
|
100
|
+
const samples = [];
|
|
101
|
+
for (const [taskId, start] of firstStartByTask) {
|
|
102
|
+
const task = tasksById.get(taskId);
|
|
103
|
+
if (!task)
|
|
104
|
+
continue;
|
|
105
|
+
const created = Date.parse(task.createdAt);
|
|
106
|
+
if (!Number.isFinite(created) || start < created)
|
|
107
|
+
continue;
|
|
108
|
+
samples.push(start - created);
|
|
109
|
+
}
|
|
110
|
+
return samples;
|
|
111
|
+
}
|
|
112
|
+
export function buildPipelineHealthMetrics(input) {
|
|
113
|
+
const { nowMs, windowMs, tasks, stageRuns } = input;
|
|
114
|
+
const sinceMs = nowMs - windowMs;
|
|
115
|
+
const inWindow = stageRuns.filter((run) => {
|
|
116
|
+
const started = Date.parse(run.startedAt);
|
|
117
|
+
return Number.isFinite(started) && started >= sinceMs;
|
|
118
|
+
});
|
|
119
|
+
const tasksById = new Map(tasks.map((task) => [task.taskId, task]));
|
|
120
|
+
const painQueueDepth = tasks.filter((task) => task.taskKind === DIAGNOSTICIAN_PARENT_TASK_KIND && (task.status === 'pending' || task.status === 'retry_wait')).length;
|
|
121
|
+
const readyQueueDepth = tasks.filter((task) => task.status === 'pending' && INTERNALIZATION_KINDS.includes(task.taskKind)).length;
|
|
122
|
+
const retryQueueDepth = tasks.filter((task) => task.status === 'retry_wait' && INTERNALIZATION_KINDS.includes(task.taskKind)).length;
|
|
123
|
+
const leasedCount = tasks.filter((task) => task.status === 'leased').length;
|
|
124
|
+
const expiredActiveLeaseCount = tasks.filter((task) => {
|
|
125
|
+
if (task.status !== 'leased' || typeof task.leaseExpiresAt !== 'string')
|
|
126
|
+
return false;
|
|
127
|
+
const expiresAtMs = Date.parse(task.leaseExpiresAt);
|
|
128
|
+
return Number.isFinite(expiresAtMs) && expiresAtMs <= nowMs;
|
|
129
|
+
}).length;
|
|
130
|
+
const pendingLike = tasks.filter((task) => (task.status === 'pending' || task.status === 'leased' || task.status === 'retry_wait')
|
|
131
|
+
&& (task.taskKind === DIAGNOSTICIAN_PARENT_TASK_KIND || STAGE_KINDS.includes(task.taskKind)));
|
|
132
|
+
let oldestPendingAgeMs = null;
|
|
133
|
+
let oldestPendingTaskKind = null;
|
|
134
|
+
for (const task of pendingLike) {
|
|
135
|
+
const age = ageMs(task.createdAt, nowMs);
|
|
136
|
+
if (age === null)
|
|
137
|
+
continue;
|
|
138
|
+
if (oldestPendingAgeMs === null || age > oldestPendingAgeMs) {
|
|
139
|
+
oldestPendingAgeMs = age;
|
|
140
|
+
oldestPendingTaskKind = task.taskKind;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
const stageC = stageMetrics(STAGE_TASK_KIND_C, inWindow);
|
|
144
|
+
const stageCTotal = stageC.successCount + stageC.failureCount;
|
|
145
|
+
const diagnosisSuccessRate = stageCTotal === 0
|
|
146
|
+
? unavailable('no completed Stage C runs in the window')
|
|
147
|
+
: available(stageC.successCount / stageCTotal);
|
|
148
|
+
const failedRuns = inWindow.filter((run) => run.executionStatus === 'failed');
|
|
149
|
+
const providerErrorRate = inWindow.length === 0
|
|
150
|
+
? unavailable('no diagnostician stage runs in the window')
|
|
151
|
+
: available(failedRuns.length / inWindow.length);
|
|
152
|
+
const errorCountsByCategory = {};
|
|
153
|
+
for (const run of failedRuns) {
|
|
154
|
+
const key = run.errorCategory ?? 'unclassified';
|
|
155
|
+
errorCountsByCategory[key] = (errorCountsByCategory[key] ?? 0) + 1;
|
|
156
|
+
}
|
|
157
|
+
const stageRetryCount = inWindow.filter((run) => run.attemptNumber > 0).length;
|
|
158
|
+
const recentExecutions = inWindow
|
|
159
|
+
.slice()
|
|
160
|
+
.sort((a, b) => Date.parse(b.startedAt) - Date.parse(a.startedAt))
|
|
161
|
+
.slice(0, RECENT_EXECUTION_LIMIT)
|
|
162
|
+
.map((run) => {
|
|
163
|
+
const task = tasksById.get(run.taskId);
|
|
164
|
+
return {
|
|
165
|
+
taskId: run.taskId,
|
|
166
|
+
parentTaskId: parentTaskIdFromStageTaskId(run.taskId),
|
|
167
|
+
stage: stageOf(run.taskKind),
|
|
168
|
+
taskKind: run.taskKind,
|
|
169
|
+
status: run.executionStatus,
|
|
170
|
+
attemptCount: task?.attemptCount ?? run.attemptNumber,
|
|
171
|
+
startedAt: run.startedAt,
|
|
172
|
+
endedAt: run.endedAt,
|
|
173
|
+
durationMs: durationMs(run.startedAt, run.endedAt),
|
|
174
|
+
errorCategory: run.errorCategory,
|
|
175
|
+
};
|
|
176
|
+
});
|
|
177
|
+
return {
|
|
178
|
+
generatedAt: new Date(nowMs).toISOString(),
|
|
179
|
+
windowMs,
|
|
180
|
+
queue: {
|
|
181
|
+
painQueueDepth,
|
|
182
|
+
readyQueueDepth,
|
|
183
|
+
retryQueueDepth,
|
|
184
|
+
leasedCount,
|
|
185
|
+
oldestPendingAgeMs,
|
|
186
|
+
oldestPendingTaskKind,
|
|
187
|
+
},
|
|
188
|
+
stage2: {
|
|
189
|
+
pendingDepth: unavailable('Stage-2 confirmations live in trajectory.db (signal_confirmations); this console read model only opens state.db'),
|
|
190
|
+
},
|
|
191
|
+
stages: {
|
|
192
|
+
a: stageMetrics(STAGE_TASK_KIND_A, inWindow),
|
|
193
|
+
b: stageMetrics(STAGE_TASK_KIND_B, inWindow),
|
|
194
|
+
c: stageC,
|
|
195
|
+
},
|
|
196
|
+
queueWait: summarizeLatencies(queueWaitSamples(tasksById, inWindow)),
|
|
197
|
+
reliability: {
|
|
198
|
+
stageRetryCount,
|
|
199
|
+
expiredActiveLeaseCount,
|
|
200
|
+
diagnosisSuccessRate,
|
|
201
|
+
leaseRenewalFailureCount: unavailable('lease renewal failures are emitted as telemetry events (lease_renewal_failed), not persisted as task/run rows'),
|
|
202
|
+
leaseRecoveryCount: unavailable('the recovery sweep does not persist a per-task recovery marker; recovered counts are emitted as consumer cycle events'),
|
|
203
|
+
staleCommitRejectedCount: unavailable('stale_commit_rejected is emitted as a telemetry event, not persisted as a task/run row'),
|
|
204
|
+
},
|
|
205
|
+
provider: {
|
|
206
|
+
errorRate: providerErrorRate,
|
|
207
|
+
errorCountsByCategory,
|
|
208
|
+
rateLimitCount: errorCountsByCategory.rate_limit ?? 0,
|
|
209
|
+
timeoutCount: errorCountsByCategory.timeout ?? 0,
|
|
210
|
+
},
|
|
211
|
+
tokens: {
|
|
212
|
+
tokensPerPain: unavailable('provider token usage is recorded per invocation in runtime telemetry, not aggregated in state.db'),
|
|
213
|
+
},
|
|
214
|
+
lineage: {
|
|
215
|
+
available: recentExecutions.length > 0,
|
|
216
|
+
...(recentExecutions.length === 0 ? { reason: 'no stage runs in the window' } : {}),
|
|
217
|
+
recentExecutions,
|
|
218
|
+
},
|
|
219
|
+
notes: [
|
|
220
|
+
'All values are DERIVED from state.db (tasks + runs) for the stated window; nothing is estimated.',
|
|
221
|
+
'Unavailable metrics are reported as available=false with a reason — never as 0.',
|
|
222
|
+
'A/B/C = diag_rootcause / diag_distiller / diag_router; parentTaskId is parsed from the stage task id.',
|
|
223
|
+
],
|
|
224
|
+
};
|
|
225
|
+
}
|
|
@@ -178,6 +178,20 @@ export async function handleApprovalsRoute(req, res, workspaceDir, subPath) {
|
|
|
178
178
|
else if (result.error === 'activation_failed') {
|
|
179
179
|
sendError(res, 500, 'activation_failed', `Approval was ${result.approvalRolledBack ? 'rolled back to pending' : 'approved but activation failed'}. Reason: ${result.reason}`, { reason: 'activation_failed', approvalRolledBack: result.approvalRolledBack, nextAction: result.nextAction ?? 'Inspect or regenerate the rule artifact, verify it is validated, then retry approval.' });
|
|
180
180
|
}
|
|
181
|
+
else if (result.error === 'precheck_stale') {
|
|
182
|
+
// P1 review: the submit-time precheck passed, then the material or
|
|
183
|
+
// its ledger identity changed before the write. Nothing was written,
|
|
184
|
+
// and this is NOT a permanent refusal — 409 tells the client to
|
|
185
|
+
// reload and re-judge rather than reject the history.
|
|
186
|
+
sendError(res, 409, 'precheck_stale', `precheck_stale: the approval precheck no longer describes the current material; nothing was written. ${result.reason}`, { reason: 'precheck_stale', nextAction: result.nextAction });
|
|
187
|
+
}
|
|
188
|
+
else if (result.error === 'strategic_conflict_unconfirmed') {
|
|
189
|
+
// SIA v1.2 Phase 3: the server-side gate refused BEFORE any write while
|
|
190
|
+
// a confirmed strategic conflict is unresolved for this exact contract.
|
|
191
|
+
// 422: the request is well-formed but the governance state forbids the
|
|
192
|
+
// write; the approval stays pending and can be retried after resolution.
|
|
193
|
+
sendError(res, 422, 'strategic_conflict_unconfirmed', `Approval refused before any write; the approval remains pending. ${result.reason}`, { reason: 'strategic_conflict_unconfirmed', nextAction: result.nextAction });
|
|
194
|
+
}
|
|
181
195
|
else if (result.error === 'prompt_capacity_refused') {
|
|
182
196
|
// R-B2: refused BEFORE any governance write — the approval stays
|
|
183
197
|
// pending. 422: the request is well-formed but the artifact cannot
|
|
@@ -20,8 +20,10 @@
|
|
|
20
20
|
* - ERR-014/ERR-016/ERR-017: Safe serialization for previews
|
|
21
21
|
* - ERR-045: ANY-segment redaction for sensitive keys
|
|
22
22
|
*/
|
|
23
|
+
import { pdProviderCatalog, pdProviderCredentials, probeProviderConnection, } from '@principles/core/runtime';
|
|
23
24
|
import { sendSuccess, sendError, sendNotFound, sendMethodNotAllowed, sendBadRequest, sendJson } from '../utils/response.js';
|
|
24
|
-
import { getConfigSummary, getConfigCatalog, updateAgentBinding, updateDefaultRuntime, checkReadiness, getPrinciplesOutputLanguage, updatePrinciplesOutputLanguage, updateFeatureFlag, createRuntimeProfile, updateRuntimeProfile, deleteRuntimeProfile, } from '../config/pd-config-store.js';
|
|
25
|
+
import { getConfigSummary, getConfigCatalog, updateAgentBinding, updateDefaultRuntime, checkReadiness, getPrinciplesOutputLanguage, updatePrinciplesOutputLanguage, updateFeatureFlag, updateAdaptiveActivationSettings, createRuntimeProfile, updateRuntimeProfile, deleteRuntimeProfile, } from '../config/pd-config-store.js';
|
|
26
|
+
import { AdaptiveActivationConsoleModel } from '../models/AdaptiveActivationConsoleModel.js';
|
|
25
27
|
// ── Constants ────────────────────────────────────────────────────────────────
|
|
26
28
|
const MAX_BODY_SIZE = 1024 * 64; // 64 KB — generous for config binding updates
|
|
27
29
|
// ── Request Body Reader ──────────────────────────────────────────────────────
|
|
@@ -58,6 +60,15 @@ function sendProfileCrudError(res, result) {
|
|
|
58
60
|
sendError(res, result.statusCode, result.error, result.message, result.nextAction ? { nextAction: result.nextAction } : undefined);
|
|
59
61
|
}
|
|
60
62
|
// ── Route Handler ────────────────────────────────────────────────────────────
|
|
63
|
+
function collectReferencedApiKeyEnvs(workspaceDir) {
|
|
64
|
+
const envs = new Set();
|
|
65
|
+
for (const profile of getConfigCatalog(workspaceDir).profiles) {
|
|
66
|
+
if (typeof profile.apiKeyEnv === 'string' && profile.apiKeyEnv !== '') {
|
|
67
|
+
envs.add(profile.apiKeyEnv);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return envs;
|
|
71
|
+
}
|
|
61
72
|
export async function handleConfigRoute(req, res, ctx) {
|
|
62
73
|
const { workspaceDir, subPath } = ctx;
|
|
63
74
|
const method = req.method ?? 'GET';
|
|
@@ -71,6 +82,44 @@ export async function handleConfigRoute(req, res, ctx) {
|
|
|
71
82
|
sendSuccess(res, { ...summary, ...(errors ? { errors } : {}) });
|
|
72
83
|
return;
|
|
73
84
|
}
|
|
85
|
+
// GET/PATCH /adaptive-activation — Codex desktop Adaptive Activation entry.
|
|
86
|
+
// Workspace-scoped: the model reads THIS workspace's config, candidates and
|
|
87
|
+
// injection events; the writer touches the same config path. Saving never
|
|
88
|
+
// sends a scoring request (zero network in this handler).
|
|
89
|
+
if (subPath === '/adaptive-activation') {
|
|
90
|
+
if (method === 'GET') {
|
|
91
|
+
const model = new AdaptiveActivationConsoleModel(workspaceDir);
|
|
92
|
+
sendSuccess(res, await model.getView());
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
if (method === 'PATCH') {
|
|
96
|
+
let bodyText;
|
|
97
|
+
try {
|
|
98
|
+
bodyText = await readBody(req);
|
|
99
|
+
}
|
|
100
|
+
catch {
|
|
101
|
+
sendBadRequest(res, 'Request body exceeds maximum allowed size');
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
const body = safeParseBody(bodyText);
|
|
105
|
+
if (body === null) {
|
|
106
|
+
sendBadRequest(res, 'Invalid JSON body');
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
const result = updateAdaptiveActivationSettings(workspaceDir, body);
|
|
110
|
+
if (!result.ok) {
|
|
111
|
+
sendError(res, result.statusCode, result.error, result.message, result.nextAction ? { nextAction: result.nextAction } : undefined);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
// Re-read the full view so the UI can show the CONFIRMED persisted state
|
|
115
|
+
// (and the same workspace's candidates/last record) in one response.
|
|
116
|
+
const model = new AdaptiveActivationConsoleModel(workspaceDir);
|
|
117
|
+
sendSuccess(res, await model.getView());
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
sendMethodNotAllowed(res);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
74
123
|
// GET /catalog
|
|
75
124
|
if (subPath === '/catalog') {
|
|
76
125
|
if (method !== 'GET') {
|
|
@@ -357,6 +406,168 @@ export async function handleConfigRoute(req, res, ctx) {
|
|
|
357
406
|
sendMethodNotAllowed(res);
|
|
358
407
|
return;
|
|
359
408
|
}
|
|
409
|
+
// GET /provider-catalog — PRI-1213 read-only projection of the pi-ai catalog.
|
|
410
|
+
// The console never edits provider endpoints or model lists; it selects.
|
|
411
|
+
if (subPath === '/provider-catalog') {
|
|
412
|
+
if (method !== 'GET') {
|
|
413
|
+
sendMethodNotAllowed(res);
|
|
414
|
+
return;
|
|
415
|
+
}
|
|
416
|
+
sendSuccess(res, { providers: pdProviderCatalog.list() });
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
419
|
+
// GET/PUT/DELETE /credentials/:envName — local credentials file (env wins).
|
|
420
|
+
const credentialMatch = /^\/credentials\/([^/]+)$/.exec(subPath);
|
|
421
|
+
if (credentialMatch) {
|
|
422
|
+
let envName;
|
|
423
|
+
try {
|
|
424
|
+
envName = decodeURIComponent(credentialMatch[1] ?? '');
|
|
425
|
+
}
|
|
426
|
+
catch {
|
|
427
|
+
sendBadRequest(res, 'Invalid credential name encoding');
|
|
428
|
+
return;
|
|
429
|
+
}
|
|
430
|
+
if (!pdProviderCredentials.isValidEnvName(envName)) {
|
|
431
|
+
sendBadRequest(res, 'Credential name must be a valid environment variable name');
|
|
432
|
+
return;
|
|
433
|
+
}
|
|
434
|
+
// Only env names a configured profile actually references may be read or
|
|
435
|
+
// written. Otherwise this endpoint would disclose the last4 of any host
|
|
436
|
+
// environment variable to the browser.
|
|
437
|
+
if (!collectReferencedApiKeyEnvs(workspaceDir).has(envName)) {
|
|
438
|
+
if (method === 'GET') {
|
|
439
|
+
sendSuccess(res, {
|
|
440
|
+
envName,
|
|
441
|
+
configured: false,
|
|
442
|
+
source: 'none',
|
|
443
|
+
error: 'credential_env_not_referenced',
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
else {
|
|
447
|
+
sendBadRequest(res, 'Credential env is not referenced by any runtime profile');
|
|
448
|
+
}
|
|
449
|
+
return;
|
|
450
|
+
}
|
|
451
|
+
if (method === 'GET') {
|
|
452
|
+
sendSuccess(res, { envName, ...pdProviderCredentials.status(envName) });
|
|
453
|
+
return;
|
|
454
|
+
}
|
|
455
|
+
if (method === 'PUT') {
|
|
456
|
+
let bodyText;
|
|
457
|
+
try {
|
|
458
|
+
bodyText = await readBody(req);
|
|
459
|
+
}
|
|
460
|
+
catch {
|
|
461
|
+
sendBadRequest(res, 'Request body exceeds maximum allowed size');
|
|
462
|
+
return;
|
|
463
|
+
}
|
|
464
|
+
const body = safeParseBody(bodyText);
|
|
465
|
+
if (body === null) {
|
|
466
|
+
sendBadRequest(res, 'Invalid JSON body');
|
|
467
|
+
return;
|
|
468
|
+
}
|
|
469
|
+
if (!isObject(body) || !Object.hasOwn(body, 'apiKey') || typeof body.apiKey !== 'string') {
|
|
470
|
+
sendBadRequest(res, 'Body must be a JSON object with a string apiKey field');
|
|
471
|
+
return;
|
|
472
|
+
}
|
|
473
|
+
const saved = pdProviderCredentials.save(envName, body.apiKey);
|
|
474
|
+
if (!saved.ok) {
|
|
475
|
+
// `saved.error` never contains the key; it is a reason + path.
|
|
476
|
+
sendError(res, 500, 'credentials_write_failed', saved.error);
|
|
477
|
+
return;
|
|
478
|
+
}
|
|
479
|
+
const status = pdProviderCredentials.status(envName);
|
|
480
|
+
sendSuccess(res, {
|
|
481
|
+
envName,
|
|
482
|
+
...status,
|
|
483
|
+
filePermissions: saved.permissions,
|
|
484
|
+
// Env wins over the file: surface it so the UI never implies the pasted
|
|
485
|
+
// key is in effect when an environment variable shadows it.
|
|
486
|
+
envOverridesFile: status.source === 'env',
|
|
487
|
+
});
|
|
488
|
+
return;
|
|
489
|
+
}
|
|
490
|
+
if (method === 'DELETE') {
|
|
491
|
+
const deleted = pdProviderCredentials.remove(envName);
|
|
492
|
+
if (!deleted.ok) {
|
|
493
|
+
sendError(res, 500, 'credentials_delete_failed', deleted.error);
|
|
494
|
+
return;
|
|
495
|
+
}
|
|
496
|
+
sendSuccess(res, { envName, ...pdProviderCredentials.status(envName), removed: deleted.removed });
|
|
497
|
+
return;
|
|
498
|
+
}
|
|
499
|
+
sendMethodNotAllowed(res);
|
|
500
|
+
return;
|
|
501
|
+
}
|
|
502
|
+
// POST /connection-test — optional live check; the only console route that
|
|
503
|
+
// makes outbound provider requests. Budget is bounded by the probe itself.
|
|
504
|
+
if (subPath === '/connection-test') {
|
|
505
|
+
if (method !== 'POST') {
|
|
506
|
+
sendMethodNotAllowed(res);
|
|
507
|
+
return;
|
|
508
|
+
}
|
|
509
|
+
let bodyText;
|
|
510
|
+
try {
|
|
511
|
+
bodyText = await readBody(req);
|
|
512
|
+
}
|
|
513
|
+
catch {
|
|
514
|
+
sendBadRequest(res, 'Request body exceeds maximum allowed size');
|
|
515
|
+
return;
|
|
516
|
+
}
|
|
517
|
+
const body = safeParseBody(bodyText);
|
|
518
|
+
if (body === null) {
|
|
519
|
+
sendBadRequest(res, 'Invalid JSON body');
|
|
520
|
+
return;
|
|
521
|
+
}
|
|
522
|
+
if (!isObject(body)) {
|
|
523
|
+
sendBadRequest(res, 'Body must be a JSON object');
|
|
524
|
+
return;
|
|
525
|
+
}
|
|
526
|
+
const { provider, model, apiKeyEnv } = body;
|
|
527
|
+
if (typeof provider !== 'string' || provider.trim() === '' || provider.length > 200) {
|
|
528
|
+
sendBadRequest(res, 'provider must be a non-empty string');
|
|
529
|
+
return;
|
|
530
|
+
}
|
|
531
|
+
if (typeof model !== 'string' || model.trim() === '' || model.length > 200) {
|
|
532
|
+
sendBadRequest(res, 'model must be a non-empty string');
|
|
533
|
+
return;
|
|
534
|
+
}
|
|
535
|
+
if (typeof apiKeyEnv !== 'string' || !pdProviderCredentials.isValidEnvName(apiKeyEnv)) {
|
|
536
|
+
sendBadRequest(res, 'apiKeyEnv must be a valid environment variable name');
|
|
537
|
+
return;
|
|
538
|
+
}
|
|
539
|
+
let baseUrl;
|
|
540
|
+
const { baseUrl: candidateBaseUrl } = body;
|
|
541
|
+
if (Object.hasOwn(body, 'baseUrl') &&
|
|
542
|
+
candidateBaseUrl !== undefined &&
|
|
543
|
+
candidateBaseUrl !== '') {
|
|
544
|
+
if (typeof candidateBaseUrl !== 'string' || candidateBaseUrl.length > 2000) {
|
|
545
|
+
sendBadRequest(res, 'baseUrl must be a string');
|
|
546
|
+
return;
|
|
547
|
+
}
|
|
548
|
+
let parsed;
|
|
549
|
+
try {
|
|
550
|
+
parsed = new URL(candidateBaseUrl);
|
|
551
|
+
}
|
|
552
|
+
catch {
|
|
553
|
+
sendBadRequest(res, 'baseUrl must be a valid URL');
|
|
554
|
+
return;
|
|
555
|
+
}
|
|
556
|
+
if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {
|
|
557
|
+
sendBadRequest(res, 'baseUrl must use http or https');
|
|
558
|
+
return;
|
|
559
|
+
}
|
|
560
|
+
baseUrl = candidateBaseUrl;
|
|
561
|
+
}
|
|
562
|
+
const result = await probeProviderConnection({
|
|
563
|
+
provider: provider.trim(),
|
|
564
|
+
model: model.trim(),
|
|
565
|
+
apiKeyEnv,
|
|
566
|
+
...(baseUrl !== undefined ? { baseUrl } : {}),
|
|
567
|
+
});
|
|
568
|
+
sendSuccess(res, result);
|
|
569
|
+
return;
|
|
570
|
+
}
|
|
360
571
|
// 404 fallback
|
|
361
572
|
sendNotFound(res, `Route /api/config${subPath} not found`);
|
|
362
573
|
}
|
|
@@ -110,7 +110,12 @@ export function createDiagnosticianRuntime(opts = {}) {
|
|
|
110
110
|
workspaceDir,
|
|
111
111
|
'--preflight',
|
|
112
112
|
'--json',
|
|
113
|
-
], {
|
|
113
|
+
], {
|
|
114
|
+
shell: false,
|
|
115
|
+
windowsHide: true,
|
|
116
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
117
|
+
env: { ...process.env, PD_INVOCATION_SOURCE: 'console' },
|
|
118
|
+
});
|
|
114
119
|
const timer = setTimeout(() => {
|
|
115
120
|
if (settled)
|
|
116
121
|
return;
|
|
@@ -161,7 +166,13 @@ export function createDiagnosticianRuntime(opts = {}) {
|
|
|
161
166
|
}
|
|
162
167
|
return new Promise((resolve) => {
|
|
163
168
|
let settled = false;
|
|
164
|
-
const child = spawn(process.execPath, [invocation.entryPath, 'diagnose', 'run', '--task-id', taskId, '--workspace', workspaceDir, '--json'], {
|
|
169
|
+
const child = spawn(process.execPath, [invocation.entryPath, 'diagnose', 'run', '--task-id', taskId, '--workspace', workspaceDir, '--json'], {
|
|
170
|
+
detached: true,
|
|
171
|
+
stdio: 'ignore',
|
|
172
|
+
shell: false,
|
|
173
|
+
windowsHide: true,
|
|
174
|
+
env: { ...process.env, PD_INVOCATION_SOURCE: 'console' },
|
|
175
|
+
});
|
|
165
176
|
const timer = setTimeout(() => {
|
|
166
177
|
if (settled)
|
|
167
178
|
return;
|