create-principles-disciple 1.144.26 → 1.145.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/_release/product-identity.json +2 -2
- package/codex-adapter/dist/codex-evidence-recorder.js +8 -2
- package/codex-adapter/dist/index.d.ts +2 -2
- package/codex-adapter/dist/index.js +1 -1
- package/codex-adapter/dist/ingestion/admission.js +16 -0
- package/codex-adapter/dist/ingestion/codex-version.d.ts +10 -4
- package/codex-adapter/dist/ingestion/codex-version.js +10 -4
- package/codex-adapter/dist/ingestion/explicit-owner-statement.d.ts +48 -0
- package/codex-adapter/dist/ingestion/explicit-owner-statement.js +123 -0
- package/codex-adapter/dist/ingestion/ingestion.js +50 -1
- package/codex-adapter/dist/pd-hook.js +66 -3
- package/codex-adapter/dist/worker/workspace-worker.d.ts +14 -0
- package/codex-adapter/dist/worker/workspace-worker.js +194 -11
- package/codex-adapter/package.json +2 -2
- package/console/dist/server/models/ApprovalsConsoleModel.d.ts +2 -2
- package/console/dist/server/models/ApprovalsConsoleModel.js +1 -1
- package/console/dist/server/models/ApprovalsGroupedConsoleModel.js +1 -1
- package/console/dist/server/models/PrinciplesConsoleModel.d.ts +26 -1
- package/console/dist/server/models/PrinciplesConsoleModel.js +18 -1
- package/console/dist/server/routes/activations.js +4 -4
- package/console/dist/server/routes/approvals.js +2 -2
- package/console/dist/server/routes/failed-tasks.d.ts +9 -0
- package/console/dist/server/routes/failed-tasks.js +116 -7
- package/console/dist/server/routes/principles.js +73 -1
- package/console/dist/shared/prompt-injection-contract.d.ts +1 -1
- package/console/dist/ui/api.d.ts +5 -5
- package/console/dist/ui/i18n/en.json +13 -2
- package/console/dist/ui/i18n/zh-CN.json +13 -2
- package/console/dist/ui/pages/activation/ActivationPage.js +2 -1
- package/console/dist/ui/pages/failed-tasks/FailedTasksPage.js +42 -4
- package/console/dist/ui/pages/focus/FocusPage.js +3 -3
- package/console/dist/ui/pages/principles/PrinciplesPage.js +7 -2
- package/console/dist/ui/utils/validators.d.ts +6 -2
- package/console/dist/ui/utils/validators.js +19 -4
- package/console/dist/web/assets/app.css +26 -0
- package/console/dist/web/assets/app.js +24 -24
- package/console/package.json +4 -4
- package/core/dist/host/host-installer.d.ts +3 -1
- package/core/dist/host/host-installer.d.ts.map +1 -1
- package/core/dist/host/host-installer.js.map +1 -1
- package/core/dist/runtime-v2/admission-gate.d.ts +8 -0
- package/core/dist/runtime-v2/admission-gate.d.ts.map +1 -1
- package/core/dist/runtime-v2/admission-gate.js +3 -2
- package/core/dist/runtime-v2/admission-gate.js.map +1 -1
- package/core/dist/runtime-v2/config/pd-config-defaults.d.ts.map +1 -1
- package/core/dist/runtime-v2/config/pd-config-defaults.js +16 -1
- package/core/dist/runtime-v2/config/pd-config-defaults.js.map +1 -1
- package/core/dist/runtime-v2/context-payload.d.ts +43 -3
- package/core/dist/runtime-v2/context-payload.d.ts.map +1 -1
- package/core/dist/runtime-v2/context-payload.js +15 -1
- package/core/dist/runtime-v2/context-payload.js.map +1 -1
- package/core/dist/runtime-v2/evidence-guards.d.ts +6 -0
- package/core/dist/runtime-v2/evidence-guards.d.ts.map +1 -1
- package/core/dist/runtime-v2/evidence-guards.js +11 -0
- package/core/dist/runtime-v2/evidence-guards.js.map +1 -1
- package/core/dist/runtime-v2/evolution/evolution-types.d.ts +4 -4
- package/core/dist/runtime-v2/evolution/evolution-types.d.ts.map +1 -1
- package/core/dist/runtime-v2/evolution/evolution-types.js +1 -1
- package/core/dist/runtime-v2/evolution/evolution-types.js.map +1 -1
- package/core/dist/runtime-v2/feature-flags/feature-flag-contract.d.ts.map +1 -1
- package/core/dist/runtime-v2/feature-flags/feature-flag-contract.js +6 -0
- package/core/dist/runtime-v2/feature-flags/feature-flag-contract.js.map +1 -1
- package/core/dist/runtime-v2/feature-flags/feature-flag-lifecycle.d.ts.map +1 -1
- package/core/dist/runtime-v2/feature-flags/feature-flag-lifecycle.js +8 -0
- package/core/dist/runtime-v2/feature-flags/feature-flag-lifecycle.js.map +1 -1
- package/core/dist/runtime-v2/index.d.ts +5 -2
- package/core/dist/runtime-v2/index.d.ts.map +1 -1
- package/core/dist/runtime-v2/index.js +3 -1
- package/core/dist/runtime-v2/index.js.map +1 -1
- package/core/dist/runtime-v2/internalization/adversarial-feedback.d.ts +3 -1
- package/core/dist/runtime-v2/internalization/adversarial-feedback.d.ts.map +1 -1
- package/core/dist/runtime-v2/internalization/adversarial-feedback.js +10 -1
- package/core/dist/runtime-v2/internalization/adversarial-feedback.js.map +1 -1
- package/core/dist/runtime-v2/internalization/evaluator-output.d.ts +11 -0
- package/core/dist/runtime-v2/internalization/evaluator-output.d.ts.map +1 -1
- package/core/dist/runtime-v2/internalization/evaluator-output.js +10 -0
- package/core/dist/runtime-v2/internalization/evaluator-output.js.map +1 -1
- package/core/dist/runtime-v2/internalization/evaluator-prompt-builder.d.ts +3 -3
- package/core/dist/runtime-v2/internalization/evaluator-prompt-builder.d.ts.map +1 -1
- package/core/dist/runtime-v2/internalization/evaluator-prompt-builder.js +49 -5
- package/core/dist/runtime-v2/internalization/evaluator-prompt-builder.js.map +1 -1
- package/core/dist/runtime-v2/internalization/evaluator-runner.d.ts.map +1 -1
- package/core/dist/runtime-v2/internalization/evaluator-runner.js +13 -16
- package/core/dist/runtime-v2/internalization/evaluator-runner.js.map +1 -1
- package/core/dist/runtime-v2/internalization/owner-decision-review.d.ts.map +1 -1
- package/core/dist/runtime-v2/internalization/owner-decision-review.js +5 -1
- package/core/dist/runtime-v2/internalization/owner-decision-review.js.map +1 -1
- package/core/dist/runtime-v2/internalization/owner-review.d.ts +2 -2
- package/core/dist/runtime-v2/internalization/owner-review.js +2 -2
- package/core/dist/runtime-v2/internalization/scribe-output.d.ts +12 -0
- package/core/dist/runtime-v2/internalization/scribe-output.d.ts.map +1 -1
- package/core/dist/runtime-v2/internalization/scribe-output.js +20 -0
- package/core/dist/runtime-v2/internalization/scribe-output.js.map +1 -1
- package/core/dist/runtime-v2/internalization/scribe-prompt-builder.d.ts +32 -1
- package/core/dist/runtime-v2/internalization/scribe-prompt-builder.d.ts.map +1 -1
- package/core/dist/runtime-v2/internalization/scribe-prompt-builder.js +38 -1
- package/core/dist/runtime-v2/internalization/scribe-prompt-builder.js.map +1 -1
- package/core/dist/runtime-v2/internalization-queue-read-model.d.ts +6 -0
- package/core/dist/runtime-v2/internalization-queue-read-model.d.ts.map +1 -1
- package/core/dist/runtime-v2/internalization-queue-read-model.js +8 -1
- package/core/dist/runtime-v2/internalization-queue-read-model.js.map +1 -1
- package/core/dist/runtime-v2/intervention-evidence-normalizer.d.ts.map +1 -1
- package/core/dist/runtime-v2/intervention-evidence-normalizer.js +10 -3
- package/core/dist/runtime-v2/intervention-evidence-normalizer.js.map +1 -1
- package/core/dist/runtime-v2/pain-ingress.d.ts +1 -1
- package/core/dist/runtime-v2/pain-ingress.d.ts.map +1 -1
- package/core/dist/runtime-v2/pain-signal-bridge.d.ts +68 -2
- package/core/dist/runtime-v2/pain-signal-bridge.d.ts.map +1 -1
- package/core/dist/runtime-v2/pain-signal-bridge.js +541 -18
- package/core/dist/runtime-v2/pain-signal-bridge.js.map +1 -1
- package/core/dist/runtime-v2/pain-signal-runtime-factory.d.ts.map +1 -1
- package/core/dist/runtime-v2/pain-signal-runtime-factory.js +4 -0
- package/core/dist/runtime-v2/pain-signal-runtime-factory.js.map +1 -1
- package/core/dist/runtime-v2/product-telemetry/snapshot-contract.d.ts +2 -2
- package/core/dist/runtime-v2/product-telemetry/snapshot-contract.d.ts.map +1 -1
- package/core/dist/runtime-v2/product-telemetry/snapshot-contract.js +2 -2
- package/core/dist/runtime-v2/product-telemetry/snapshot-contract.js.map +1 -1
- package/core/dist/runtime-v2/store/candidate/admission-document.d.ts +90 -0
- package/core/dist/runtime-v2/store/candidate/admission-document.d.ts.map +1 -0
- package/core/dist/runtime-v2/store/candidate/admission-document.js +142 -0
- package/core/dist/runtime-v2/store/candidate/admission-document.js.map +1 -0
- package/core/dist/runtime-v2/store/candidate/candidate-store.d.ts +53 -0
- package/core/dist/runtime-v2/store/candidate/candidate-store.d.ts.map +1 -1
- package/core/dist/runtime-v2/store/candidate/memory-candidate-store.d.ts +35 -0
- package/core/dist/runtime-v2/store/candidate/memory-candidate-store.d.ts.map +1 -1
- package/core/dist/runtime-v2/store/candidate/memory-candidate-store.js +48 -0
- package/core/dist/runtime-v2/store/candidate/memory-candidate-store.js.map +1 -1
- package/core/dist/runtime-v2/store/candidate/sqlite-candidate-store.d.ts +44 -0
- package/core/dist/runtime-v2/store/candidate/sqlite-candidate-store.d.ts.map +1 -1
- package/core/dist/runtime-v2/store/candidate/sqlite-candidate-store.js +136 -0
- package/core/dist/runtime-v2/store/candidate/sqlite-candidate-store.js.map +1 -1
- package/core/dist/runtime-v2/store/context/sqlite-context-assembler.js.map +1 -1
- package/core/dist/runtime-v2/store/intervention-evidence-schema.js +1 -1
- package/core/dist/runtime-v2/store/runtime-state-manager.d.ts +65 -0
- package/core/dist/runtime-v2/store/runtime-state-manager.d.ts.map +1 -1
- package/core/dist/runtime-v2/store/runtime-state-manager.js +46 -0
- package/core/dist/runtime-v2/store/runtime-state-manager.js.map +1 -1
- package/core/dist/runtime-v2/store/sqlite-connection.d.ts.map +1 -1
- package/core/dist/runtime-v2/store/sqlite-connection.js +42 -0
- package/core/dist/runtime-v2/store/sqlite-connection.js.map +1 -1
- package/core/dist/runtime-v2/store/sqlite-intervention-evidence-store.d.ts +1 -1
- package/core/dist/runtime-v2/store/sqlite-intervention-evidence-store.d.ts.map +1 -1
- package/core/dist/runtime-v2/store/sqlite-intervention-evidence-store.js.map +1 -1
- package/core/dist/runtime-v2/store/task/sqlite-family-reopen.d.ts +19 -0
- package/core/dist/runtime-v2/store/task/sqlite-family-reopen.d.ts.map +1 -0
- package/core/dist/runtime-v2/store/task/sqlite-family-reopen.js +36 -0
- package/core/dist/runtime-v2/store/task/sqlite-family-reopen.js.map +1 -0
- package/core/dist/runtime-v2/store/task/sqlite-task-store.d.ts +23 -0
- package/core/dist/runtime-v2/store/task/sqlite-task-store.d.ts.map +1 -1
- package/core/dist/runtime-v2/store/task/sqlite-task-store.js +50 -0
- package/core/dist/runtime-v2/store/task/sqlite-task-store.js.map +1 -1
- package/core/dist/runtime-v2/task-status.d.ts +3 -1
- package/core/dist/runtime-v2/task-status.d.ts.map +1 -1
- package/core/dist/runtime-v2/task-status.js +1 -1
- package/core/dist/runtime-v2/task-status.js.map +1 -1
- package/core/dist/runtime-v2/trajectory-schema.d.ts.map +1 -1
- package/core/dist/runtime-v2/trajectory-schema.js +11 -0
- package/core/dist/runtime-v2/trajectory-schema.js.map +1 -1
- package/core/dist/runtime-v2/types/event-types.d.ts +2 -2
- package/core/dist/runtime-v2/types/event-types.d.ts.map +1 -1
- package/core/dist/runtime-v2/types/event-types.js +1 -1
- package/core/dist/runtime-v2/types/event-types.js.map +1 -1
- package/core/dist/runtime-v2/types/evidence-chain-contract.d.ts +1 -1
- package/core/dist/runtime-v2/types/evidence-chain-contract.d.ts.map +1 -1
- package/core/dist/runtime-v2/types/evidence-chain-contract.js +2 -2
- package/core/dist/runtime-v2/types/evidence-chain-contract.js.map +1 -1
- package/core/dist/runtime-v2/types/intervention-evidence-contract.d.ts +3 -3
- package/core/dist/runtime-v2/types/intervention-evidence-contract.d.ts.map +1 -1
- package/core/dist/runtime-v2/types/intervention-evidence-contract.js +1 -0
- package/core/dist/runtime-v2/types/intervention-evidence-contract.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 +4 -0
- package/core/dist/telemetry-event.js.map +1 -1
- package/core/dist/trajectory-types.d.ts +2 -2
- package/core/dist/trajectory-types.d.ts.map +1 -1
- package/core/package.json +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +84 -8
- package/dist/index.js.map +1 -1
- package/dist/installer.d.ts +42 -11
- package/dist/installer.d.ts.map +1 -1
- package/dist/installer.js +140 -36
- package/dist/installer.js.map +1 -1
- package/dist/installers/index.d.ts +18 -7
- package/dist/installers/index.d.ts.map +1 -1
- package/dist/installers/index.js +13 -4
- package/dist/installers/index.js.map +1 -1
- package/dist/installers/workbuddy-host-installer.d.ts +246 -0
- package/dist/installers/workbuddy-host-installer.d.ts.map +1 -0
- package/dist/installers/workbuddy-host-installer.js +1419 -0
- package/dist/installers/workbuddy-host-installer.js.map +1 -0
- package/dist/mvp-config.d.ts +24 -0
- package/dist/mvp-config.d.ts.map +1 -1
- package/dist/mvp-config.js +36 -0
- package/dist/mvp-config.js.map +1 -1
- package/dist/prompts.d.ts +13 -0
- package/dist/prompts.d.ts.map +1 -1
- package/dist/prompts.js +45 -8
- package/dist/prompts.js.map +1 -1
- package/dist/uninstaller.d.ts +1 -1
- package/dist/uninstaller.d.ts.map +1 -1
- package/dist/uninstaller.js +29 -4
- package/dist/uninstaller.js.map +1 -1
- package/host-runtime/dist/governance-signal-admission.d.ts +63 -0
- package/host-runtime/dist/governance-signal-admission.js +322 -53
- package/host-runtime/dist/host-liveness-contract.js +7 -1
- package/host-runtime/dist/index.d.ts +1 -0
- package/host-runtime/dist/index.js +5 -1
- package/host-runtime/dist/internalization-consumer-cycle.d.ts +12 -0
- package/host-runtime/dist/internalization-consumer-cycle.js +43 -1
- package/host-runtime/dist/intervention-evidence-ingress.d.ts +1 -1
- package/host-runtime/dist/product-telemetry/service.js +1 -1
- package/host-runtime/dist/production-pain-evidence.d.ts +59 -1
- package/host-runtime/dist/production-pain-evidence.js +200 -17
- package/host-runtime/dist/prompt-activation-deliverability.js +5 -4
- package/host-runtime/dist/prompt-injection-event-evidence.d.ts +1 -1
- package/host-runtime/dist/prompt-injection-event-evidence.js +5 -1
- package/host-runtime/dist/prompt-injection-projection.d.ts +14 -5
- package/host-runtime/dist/prompt-injection-projection.js +30 -16
- package/host-runtime/dist/workbuddy-worker-status.d.ts +24 -0
- package/host-runtime/dist/workbuddy-worker-status.js +52 -0
- package/host-runtime/package.json +3 -3
- package/install-layout/dist/index.d.ts +18 -1
- package/install-layout/dist/index.js +15 -2
- package/install-layout/package.json +1 -1
- package/package.json +6 -5
- package/pd-cli/dist/commands/candidate.d.ts.map +1 -1
- package/pd-cli/dist/commands/candidate.js +44 -4
- package/pd-cli/dist/commands/candidate.js.map +1 -1
- package/pd-cli/dist/commands/codex-worker.d.ts.map +1 -1
- package/pd-cli/dist/commands/codex-worker.js +30 -1
- package/pd-cli/dist/commands/codex-worker.js.map +1 -1
- package/pd-cli/dist/commands/config-doctor.d.ts.map +1 -1
- package/pd-cli/dist/commands/config-doctor.js +19 -4
- package/pd-cli/dist/commands/config-doctor.js.map +1 -1
- package/pd-cli/dist/commands/diagnose.d.ts.map +1 -1
- package/pd-cli/dist/commands/diagnose.js +4 -1
- package/pd-cli/dist/commands/diagnose.js.map +1 -1
- package/pd-cli/dist/commands/health-codex-install.d.ts +85 -0
- package/pd-cli/dist/commands/health-codex-install.d.ts.map +1 -0
- package/pd-cli/dist/commands/health-codex-install.js +207 -0
- package/pd-cli/dist/commands/health-codex-install.js.map +1 -0
- package/pd-cli/dist/commands/health-codex.d.ts.map +1 -1
- package/pd-cli/dist/commands/health-codex.js +78 -0
- package/pd-cli/dist/commands/health-codex.js.map +1 -1
- package/pd-cli/dist/commands/pain-list.d.ts +3 -2
- package/pd-cli/dist/commands/pain-list.d.ts.map +1 -1
- package/pd-cli/dist/commands/pain-list.js +10 -10
- package/pd-cli/dist/commands/pain-list.js.map +1 -1
- package/pd-cli/dist/commands/pain-record.d.ts +2 -0
- package/pd-cli/dist/commands/pain-record.d.ts.map +1 -1
- package/pd-cli/dist/commands/pain-record.js +36 -0
- package/pd-cli/dist/commands/pain-record.js.map +1 -1
- package/pd-cli/dist/commands/pain-retry.d.ts +6 -0
- package/pd-cli/dist/commands/pain-retry.d.ts.map +1 -1
- package/pd-cli/dist/commands/pain-retry.js +152 -5
- package/pd-cli/dist/commands/pain-retry.js.map +1 -1
- package/pd-cli/dist/commands/runtime-activation.d.ts +1 -1
- package/pd-cli/dist/commands/runtime-activation.d.ts.map +1 -1
- package/pd-cli/dist/commands/runtime-activation.js +3 -3
- package/pd-cli/dist/commands/runtime-activation.js.map +1 -1
- package/pd-cli/dist/commands/workbuddy-worker.d.ts +19 -0
- package/pd-cli/dist/commands/workbuddy-worker.d.ts.map +1 -0
- package/pd-cli/dist/commands/workbuddy-worker.js +168 -0
- package/pd-cli/dist/commands/workbuddy-worker.js.map +1 -0
- package/pd-cli/dist/index.js +29 -1
- package/pd-cli/dist/index.js.map +1 -1
- package/pd-cli/dist/resolve-workspace.d.ts +14 -2
- package/pd-cli/dist/resolve-workspace.d.ts.map +1 -1
- package/pd-cli/dist/resolve-workspace.js +88 -21
- package/pd-cli/dist/resolve-workspace.js.map +1 -1
- package/pd-cli/dist/services/admission-write-gate.d.ts +24 -0
- package/pd-cli/dist/services/admission-write-gate.d.ts.map +1 -0
- package/pd-cli/dist/services/admission-write-gate.js +41 -0
- package/pd-cli/dist/services/admission-write-gate.js.map +1 -0
- package/pd-cli/dist/services/pd-config-loader.d.ts +39 -7
- package/pd-cli/dist/services/pd-config-loader.d.ts.map +1 -1
- package/pd-cli/dist/services/pd-config-loader.js +111 -18
- package/pd-cli/dist/services/pd-config-loader.js.map +1 -1
- package/pd-cli/dist/services/rulehost-pipeline-runner.d.ts +10 -0
- package/pd-cli/dist/services/rulehost-pipeline-runner.d.ts.map +1 -1
- package/pd-cli/dist/services/rulehost-pipeline-runner.js +59 -4
- package/pd-cli/dist/services/rulehost-pipeline-runner.js.map +1 -1
- package/pd-cli/package.json +4 -3
- package/plugin/dist/bundle.js +564 -509
- package/plugin/dist/governance-audit.js +1 -1
- package/plugin/dist/openclaw.plugin.json +1 -1
- package/plugin/dist/rulehost-evidence.js +1 -1
- package/plugin/openclaw.plugin.json +1 -1
- package/plugin/package.json +3 -3
- package/release-manager/dist/index.d.ts.map +1 -1
- package/release-manager/dist/index.js +84 -8
- package/release-manager/dist/index.js.map +1 -1
- package/release-manager/dist/installer.d.ts +42 -11
- package/release-manager/dist/installer.d.ts.map +1 -1
- package/release-manager/dist/installer.js +140 -36
- package/release-manager/dist/installer.js.map +1 -1
- package/release-manager/dist/installers/index.d.ts +18 -7
- package/release-manager/dist/installers/index.d.ts.map +1 -1
- package/release-manager/dist/installers/index.js +13 -4
- package/release-manager/dist/installers/index.js.map +1 -1
- package/release-manager/dist/installers/workbuddy-host-installer.d.ts +246 -0
- package/release-manager/dist/installers/workbuddy-host-installer.d.ts.map +1 -0
- package/release-manager/dist/installers/workbuddy-host-installer.js +1419 -0
- package/release-manager/dist/installers/workbuddy-host-installer.js.map +1 -0
- package/release-manager/dist/mvp-config.d.ts +24 -0
- package/release-manager/dist/mvp-config.d.ts.map +1 -1
- package/release-manager/dist/mvp-config.js +36 -0
- package/release-manager/dist/mvp-config.js.map +1 -1
- package/release-manager/dist/prompts.d.ts +13 -0
- package/release-manager/dist/prompts.d.ts.map +1 -1
- package/release-manager/dist/prompts.js +45 -8
- package/release-manager/dist/prompts.js.map +1 -1
- package/release-manager/dist/uninstaller.d.ts +1 -1
- package/release-manager/dist/uninstaller.d.ts.map +1 -1
- package/release-manager/dist/uninstaller.js +29 -4
- package/release-manager/dist/uninstaller.js.map +1 -1
- package/release-manager/package.json +5 -4
- package/workbuddy-adapter/dist/codec/index.d.ts +2 -0
- package/workbuddy-adapter/dist/codec/index.js +2 -0
- package/workbuddy-adapter/dist/codec/input-decoder.d.ts +30 -0
- package/workbuddy-adapter/dist/codec/input-decoder.js +232 -0
- package/workbuddy-adapter/dist/codec/output-encoder.d.ts +62 -0
- package/workbuddy-adapter/dist/codec/output-encoder.js +75 -0
- package/workbuddy-adapter/dist/host-adapter.d.ts +33 -0
- package/workbuddy-adapter/dist/host-adapter.js +23 -0
- package/workbuddy-adapter/dist/index.d.ts +16 -0
- package/workbuddy-adapter/dist/index.js +16 -0
- package/workbuddy-adapter/dist/pd-hook.d.ts +17 -0
- package/workbuddy-adapter/dist/pd-hook.js +505 -0
- package/workbuddy-adapter/dist/tool-semantics.d.ts +22 -0
- package/workbuddy-adapter/dist/tool-semantics.js +33 -0
- package/workbuddy-adapter/dist/workbuddy-evidence-recorder.d.ts +50 -0
- package/workbuddy-adapter/dist/workbuddy-evidence-recorder.js +238 -0
- package/workbuddy-adapter/dist/worker/workspace-worker.d.ts +41 -0
- package/workbuddy-adapter/dist/worker/workspace-worker.js +219 -0
- package/workbuddy-adapter/dist/workspace-resolution.d.ts +15 -0
- package/workbuddy-adapter/dist/workspace-resolution.js +53 -0
- package/workbuddy-adapter/package.json +62 -0
- package/workbuddy-adapter/plugin/.codebuddy-plugin/plugin.json +6 -0
- package/workbuddy-adapter/plugin/hooks/hooks.json +62 -0
- package/workbuddy-adapter/plugin/scripts/wrapper.cjs +79 -0
|
@@ -112,7 +112,11 @@ export function recordCodexPromptDeliveryEvidence(input) {
|
|
|
112
112
|
principleId: entry.principleId,
|
|
113
113
|
...(activationRef.artifactId ? { artifactId: activationRef.artifactId } : {}),
|
|
114
114
|
...(contentRef ? { payloadDigest: contentRef.payloadDigest } : {}),
|
|
115
|
-
|
|
115
|
+
// A stored contentRef is an OBJECT — its truthiness must not upgrade
|
|
116
|
+
// resolution: 'resolved' without a payloadDigest is rejected by the
|
|
117
|
+
// normalizer before the store's idempotent dedup branch can no-op the
|
|
118
|
+
// replay. Only a digest-carrying reference counts as resolved.
|
|
119
|
+
resolution: contentRef?.payloadDigest !== undefined ? 'resolved' : 'revision_reference_unresolved',
|
|
116
120
|
},
|
|
117
121
|
activationRef,
|
|
118
122
|
payload: { targetKind: 'agent_context', confirmation: 'submitted', outcome: 'attempted' },
|
|
@@ -162,7 +166,9 @@ export function recordCodexDenyEvidence(input) {
|
|
|
162
166
|
principleId: input.principleId,
|
|
163
167
|
...(activationRef.artifactId ? { artifactId: activationRef.artifactId } : {}),
|
|
164
168
|
...(content ? { payloadDigest: content.payloadDigest } : {}),
|
|
165
|
-
|
|
169
|
+
// Same constraint as the prompt-delivery path above: a stored object's
|
|
170
|
+
// truthiness must not mint a digest-less 'resolved' reference.
|
|
171
|
+
resolution: content?.payloadDigest !== undefined ? 'resolved' : 'revision_reference_unresolved',
|
|
166
172
|
};
|
|
167
173
|
const observations = [
|
|
168
174
|
{
|
|
@@ -21,5 +21,5 @@ export { catchUpCodexIngestion, CODEX_CATCH_UP_NEXT_ACTION } from './ingestion/c
|
|
|
21
21
|
export type { CodexCatchUpOptions, CodexCatchUpResult, CodexCatchUpRolloutResult } from './ingestion/catch-up.js';
|
|
22
22
|
export { locateCodexTranscriptByRolloutIdentity } from './ingestion/transcript-locate.js';
|
|
23
23
|
export type { CodexTranscriptLookup } from './ingestion/transcript-locate.js';
|
|
24
|
-
export { runCodexWorkspaceWorkerCycle, computeCodexWorkerStatusMode } from './worker/workspace-worker.js';
|
|
25
|
-
export type { CodexWorkerMode, CodexWorkerCycleResult, CodexWorkerCycleStepReport, CodexWorkerCycleOptions, CodexWorkerStatusEvaluation } from './worker/workspace-worker.js';
|
|
24
|
+
export { runCodexWorkspaceWorkerCycle, computeCodexWorkerStatusMode, readCodexWorkerLiveness } from './worker/workspace-worker.js';
|
|
25
|
+
export type { CodexWorkerMode, CodexWorkerCycleResult, CodexWorkerCycleStepReport, CodexWorkerCycleOptions, CodexWorkerStatusEvaluation, CodexWorkerPostProcessingReport } from './worker/workspace-worker.js';
|
|
@@ -16,4 +16,4 @@ export { decodeTranscriptWindow, createNodeTranscriptPort, TranscriptReplacedErr
|
|
|
16
16
|
// PRI-624 Slice C: bounded catch-up + per-workspace worker cycle.
|
|
17
17
|
export { catchUpCodexIngestion, CODEX_CATCH_UP_NEXT_ACTION } from './ingestion/catch-up.js';
|
|
18
18
|
export { locateCodexTranscriptByRolloutIdentity } from './ingestion/transcript-locate.js';
|
|
19
|
-
export { runCodexWorkspaceWorkerCycle, computeCodexWorkerStatusMode } from './worker/workspace-worker.js';
|
|
19
|
+
export { runCodexWorkspaceWorkerCycle, computeCodexWorkerStatusMode, readCodexWorkerLiveness } from './worker/workspace-worker.js';
|
|
@@ -47,6 +47,15 @@ export function buildLiveToolCandidate(args) {
|
|
|
47
47
|
hostTurnId: fields.turnId,
|
|
48
48
|
toolName: fields.toolName ?? '',
|
|
49
49
|
source: CODEX_POST_TOOL_USE_SOURCE,
|
|
50
|
+
// Merge semantics (WorkBuddy × SPEC-CODEX-PAIN-CLOSURE-001): the same host
|
|
51
|
+
// `tool_use_id` feeds TWO consumers, so the candidate carries both views.
|
|
52
|
+
// I1 identity parity — the live handler derives the canonical pain from the
|
|
53
|
+
// same tool_use_id, so `toolCallId` must be present (one real call → one
|
|
54
|
+
// canonical pain across the admission + dispatch deliveries).
|
|
55
|
+
toolCallId: fields.toolUseId,
|
|
56
|
+
// CR-01 — `toolUseId` is recorded into tool_calls.tool_use_id and used for
|
|
57
|
+
// the admission dedup join against the live PostToolUse row.
|
|
58
|
+
toolUseId: fields.toolUseId,
|
|
50
59
|
...(fields.toolInput !== undefined ? { toolInput: fields.toolInput } : {}),
|
|
51
60
|
...(fields.toolResponse !== undefined ? { toolOutput: fields.toolResponse } : {}),
|
|
52
61
|
observedAt: new Date().toISOString(),
|
|
@@ -90,6 +99,13 @@ export function buildTranscriptCandidates(observations) {
|
|
|
90
99
|
hostTurnId: observation.hostTurnId,
|
|
91
100
|
toolName: typeof toolName === 'string' ? toolName : '',
|
|
92
101
|
source: CODEX_POST_TOOL_USE_SOURCE,
|
|
102
|
+
// Merge semantics: both merged views of the same host tool_use_id.
|
|
103
|
+
// I1 identity parity — the decoded observation carries the same
|
|
104
|
+
// tool_use_id the live delivery derived its canonical pain from, so a
|
|
105
|
+
// transcript replay converges on that pain instead of a second one.
|
|
106
|
+
...(typeof observation.toolUseId === 'string' && observation.toolUseId.length > 0 ? { toolCallId: observation.toolUseId } : {}),
|
|
107
|
+
// CR-01 — recorded into tool_calls.tool_use_id for the dedup join.
|
|
108
|
+
...(observation.toolUseId !== undefined ? { toolUseId: observation.toolUseId } : {}),
|
|
93
109
|
toolInput: own(facts, 'command') ?? null,
|
|
94
110
|
...(exitCode !== undefined ? { toolOutput: { exitCode, stdout: own(facts, 'stdout') ?? null, stderr: own(facts, 'stderr') ?? null } } : {}),
|
|
95
111
|
observedAt: observation.observedAt,
|
|
@@ -3,9 +3,15 @@
|
|
|
3
3
|
* Slice A; ADR-0020 §11.2 + G1 probe report §9).
|
|
4
4
|
*
|
|
5
5
|
* The G1 contract baseline is: minimum supported Codex 0.148.0, verified
|
|
6
|
-
* on-device at 0.150.1
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* on-device at 0.150.1 and re-verified at 0.162.1 (PRI-953, 2026-10-13:
|
|
7
|
+
* on-device probe against real codex-cli 0.162.1 — 125/125 captured hook
|
|
8
|
+
* payloads decode, 8/8 real rollout transcripts ingest with only designed
|
|
9
|
+
* unknown-record-type skips; sanitized fixtures:
|
|
10
|
+
* tests/fixtures/g1-contract/hook-payloads/v0.162.1/ and
|
|
11
|
+
* transcripts/v0.162.1-tool-final-turn.jsonl). The transcript itself carries
|
|
12
|
+
* `session_meta.payload.cli_version`, which is the version signal available
|
|
13
|
+
* inside a hook subprocess (hook payloads carry no version field — G1
|
|
14
|
+
* fixture contract).
|
|
9
15
|
*
|
|
10
16
|
* Older-than-minimum and newer-than-verified versions both degrade
|
|
11
17
|
* explicitly; an unknown version must never silently guess record fields.
|
|
@@ -13,7 +19,7 @@
|
|
|
13
19
|
* refreshing the fixtures (G1 report §9 drift-detection boundary).
|
|
14
20
|
*/
|
|
15
21
|
export declare const CODEX_INGESTION_MIN_VERSION = "0.148.0";
|
|
16
|
-
export declare const CODEX_INGESTION_VERIFIED_VERSION = "0.
|
|
22
|
+
export declare const CODEX_INGESTION_VERIFIED_VERSION = "0.162.1";
|
|
17
23
|
export type CodexVersionClassification = {
|
|
18
24
|
status: 'supported';
|
|
19
25
|
} | {
|
|
@@ -3,9 +3,15 @@
|
|
|
3
3
|
* Slice A; ADR-0020 §11.2 + G1 probe report §9).
|
|
4
4
|
*
|
|
5
5
|
* The G1 contract baseline is: minimum supported Codex 0.148.0, verified
|
|
6
|
-
* on-device at 0.150.1
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* on-device at 0.150.1 and re-verified at 0.162.1 (PRI-953, 2026-10-13:
|
|
7
|
+
* on-device probe against real codex-cli 0.162.1 — 125/125 captured hook
|
|
8
|
+
* payloads decode, 8/8 real rollout transcripts ingest with only designed
|
|
9
|
+
* unknown-record-type skips; sanitized fixtures:
|
|
10
|
+
* tests/fixtures/g1-contract/hook-payloads/v0.162.1/ and
|
|
11
|
+
* transcripts/v0.162.1-tool-final-turn.jsonl). The transcript itself carries
|
|
12
|
+
* `session_meta.payload.cli_version`, which is the version signal available
|
|
13
|
+
* inside a hook subprocess (hook payloads carry no version field — G1
|
|
14
|
+
* fixture contract).
|
|
9
15
|
*
|
|
10
16
|
* Older-than-minimum and newer-than-verified versions both degrade
|
|
11
17
|
* explicitly; an unknown version must never silently guess record fields.
|
|
@@ -13,7 +19,7 @@
|
|
|
13
19
|
* refreshing the fixtures (G1 report §9 drift-detection boundary).
|
|
14
20
|
*/
|
|
15
21
|
export const CODEX_INGESTION_MIN_VERSION = '0.148.0';
|
|
16
|
-
export const CODEX_INGESTION_VERIFIED_VERSION = '0.
|
|
22
|
+
export const CODEX_INGESTION_VERIFIED_VERSION = '0.162.1';
|
|
17
23
|
export const CODEX_VERSION_NEXT_ACTION = 'rerun the Codex contract probe / update supported fixtures (docs/architecture/CODEX_G1_CONTRACT_PROBE_REPORT.md §9)';
|
|
18
24
|
function isDigits(value) {
|
|
19
25
|
return value.length > 0 && /^[0-9]+$/.test(value);
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/** The exact prefix (fullwidth colon) defined by SPEC §6.4. */
|
|
2
|
+
export declare const CODEX_OWNER_STATEMENT_PREFIX = "PD\u8BB0\u5F55\u75DB\u82E6\uFF1A";
|
|
3
|
+
/** SPEC §6.1: reject instead of truncating the Owner's intent. */
|
|
4
|
+
export declare const MAX_OWNER_STATEMENT_CHARS = 500;
|
|
5
|
+
export type OwnerStatementPrefixParse = {
|
|
6
|
+
matched: false;
|
|
7
|
+
} | {
|
|
8
|
+
matched: true;
|
|
9
|
+
text: string | null;
|
|
10
|
+
reason?: 'statement_empty' | 'statement_too_long';
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Deterministic prefix parse of the CURRENT user prompt. `text === null` means
|
|
14
|
+
* the prefix matched but the remainder was empty/blank — an explicit request
|
|
15
|
+
* with no content is a bounded rejection, never a fabricated statement.
|
|
16
|
+
*/
|
|
17
|
+
export declare function parseOwnerStatementPrefix(prompt: unknown): OwnerStatementPrefixParse;
|
|
18
|
+
export type RecordOwnerStatementResult = {
|
|
19
|
+
status: 'received';
|
|
20
|
+
painId: string;
|
|
21
|
+
taskId: string;
|
|
22
|
+
disposition: 'admitted' | 'already_admitted';
|
|
23
|
+
logicalObservationKey: string;
|
|
24
|
+
/**
|
|
25
|
+
* SPEC §6.4.5: the durable task is what the receipt guarantees; evidence
|
|
26
|
+
* promotion may degrade (e.g. conversation ingestion off — no ingested
|
|
27
|
+
* rollout to promote from). The receipt discloses it instead of failing.
|
|
28
|
+
*/
|
|
29
|
+
promotionDegraded?: string;
|
|
30
|
+
} | {
|
|
31
|
+
status: 'rejected';
|
|
32
|
+
reason: 'statement_empty' | 'statement_too_long' | 'transcript_unavailable' | 'lineage_invalid' | 'rate_limited' | 'continuation_failed';
|
|
33
|
+
nextAction: string;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Persist one explicit Owner statement. The consent-gated conversation
|
|
37
|
+
* ingestion flag does NOT gate this path (no conversation tables or transcript
|
|
38
|
+
* CONTENT are read — only the path is validated for the rollout identity),
|
|
39
|
+
* mirroring SPEC §6.4 rule 3.
|
|
40
|
+
*/
|
|
41
|
+
export declare function recordExplicitOwnerStatement(args: {
|
|
42
|
+
rawPayload: unknown;
|
|
43
|
+
workspaceDir: string;
|
|
44
|
+
statementText: string;
|
|
45
|
+
env?: {
|
|
46
|
+
CODEX_HOME?: string | undefined;
|
|
47
|
+
};
|
|
48
|
+
}): Promise<RecordOwnerStatementResult>;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SPEC-CODEX-PAIN-CLOSURE-001 CR-07 — the explicit Owner pain-report entry
|
|
3
|
+
* for Codex: the user types `PD记录痛苦:<反馈原文>` as the CURRENT message
|
|
4
|
+
* and this deterministic prefix parse turns exactly that text into one
|
|
5
|
+
* canonical pain signal through the existing governance admission +
|
|
6
|
+
* diagnostician-task continuation seams.
|
|
7
|
+
*
|
|
8
|
+
* Contract (SPEC §6.4):
|
|
9
|
+
* - ONLY an exact prefix match at the start of the CURRENT user prompt
|
|
10
|
+
* counts. Quoted text, tool output, model prose and ordinary corrections
|
|
11
|
+
* never trigger it (A17).
|
|
12
|
+
* - The statement is bounded at 500 chars (rejection, not truncation).
|
|
13
|
+
* - Identity comes from THIS hook payload's verified session/turn ids plus
|
|
14
|
+
* the transcript-path-derived rollout identity — the model never guesses
|
|
15
|
+
* ids and no other file is scanned.
|
|
16
|
+
* - The same logical observation key as the generic correction path
|
|
17
|
+
* (`codex|<rollout>|<turn>|user`) means explicit and generic detection of
|
|
18
|
+
* one turn converge on ONE canonical pain (unique marker dedup).
|
|
19
|
+
* - No LLM runs here: admission + durable enqueue only, well inside the
|
|
20
|
+
* 5s hook budget; the receipt carries painId/taskId.
|
|
21
|
+
*/
|
|
22
|
+
import { admitGovernanceSignals, ensureGovernanceDiagnosticianTask, promoteAdmittedGovernanceEvidence, } from '@principles/host-runtime';
|
|
23
|
+
import { resolveCodexHome } from './codex-home.js';
|
|
24
|
+
import { validateCodexTranscriptPath } from './transcript-path.js';
|
|
25
|
+
import { extractFields } from './ingestion-fields.js';
|
|
26
|
+
/** The exact prefix (fullwidth colon) defined by SPEC §6.4. */
|
|
27
|
+
export const CODEX_OWNER_STATEMENT_PREFIX = 'PD记录痛苦:';
|
|
28
|
+
/** SPEC §6.1: reject instead of truncating the Owner's intent. */
|
|
29
|
+
export const MAX_OWNER_STATEMENT_CHARS = 500;
|
|
30
|
+
/**
|
|
31
|
+
* Deterministic prefix parse of the CURRENT user prompt. `text === null` means
|
|
32
|
+
* the prefix matched but the remainder was empty/blank — an explicit request
|
|
33
|
+
* with no content is a bounded rejection, never a fabricated statement.
|
|
34
|
+
*/
|
|
35
|
+
export function parseOwnerStatementPrefix(prompt) {
|
|
36
|
+
if (typeof prompt !== 'string')
|
|
37
|
+
return { matched: false };
|
|
38
|
+
if (!prompt.startsWith(CODEX_OWNER_STATEMENT_PREFIX))
|
|
39
|
+
return { matched: false };
|
|
40
|
+
const remainder = prompt.slice(CODEX_OWNER_STATEMENT_PREFIX.length).trim();
|
|
41
|
+
if (remainder.length === 0)
|
|
42
|
+
return { matched: true, text: null, reason: 'statement_empty' };
|
|
43
|
+
if (remainder.length > MAX_OWNER_STATEMENT_CHARS)
|
|
44
|
+
return { matched: true, text: null, reason: 'statement_too_long' };
|
|
45
|
+
return { matched: true, text: remainder };
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Persist one explicit Owner statement. The consent-gated conversation
|
|
49
|
+
* ingestion flag does NOT gate this path (no conversation tables or transcript
|
|
50
|
+
* CONTENT are read — only the path is validated for the rollout identity),
|
|
51
|
+
* mirroring SPEC §6.4 rule 3.
|
|
52
|
+
*/
|
|
53
|
+
export async function recordExplicitOwnerStatement(args) {
|
|
54
|
+
const fields = extractFields(args.rawPayload);
|
|
55
|
+
if (fields === null || fields.sessionId.length === 0 || fields.turnId === null) {
|
|
56
|
+
return { status: 'rejected', reason: 'lineage_invalid', nextAction: 'The hook payload lacks the session/turn identity this explicit submission requires; nothing was recorded.' };
|
|
57
|
+
}
|
|
58
|
+
if (fields.transcriptPath === null) {
|
|
59
|
+
return { status: 'rejected', reason: 'transcript_unavailable', nextAction: 'Codex supplied no transcript path for this event; the explicit statement was NOT recorded — resubmit it in a new message.' };
|
|
60
|
+
}
|
|
61
|
+
const home = resolveCodexHome(args.env);
|
|
62
|
+
if (!home.ok) {
|
|
63
|
+
return { status: 'rejected', reason: 'transcript_unavailable', nextAction: `${home.reason}: ${home.nextAction}`.slice(0, 400) };
|
|
64
|
+
}
|
|
65
|
+
const validated = validateCodexTranscriptPath(fields.transcriptPath, home.home);
|
|
66
|
+
if (!validated.ok) {
|
|
67
|
+
return { status: 'rejected', reason: 'lineage_invalid', nextAction: `${validated.reason}: ${validated.nextAction}`.slice(0, 400) };
|
|
68
|
+
}
|
|
69
|
+
const candidate = {
|
|
70
|
+
kind: 'user_correction',
|
|
71
|
+
hostKind: 'codex',
|
|
72
|
+
logicalObservationKey: `codex|${validated.rolloutIdentity}|${fields.turnId}|user`,
|
|
73
|
+
rolloutIdentity: validated.rolloutIdentity,
|
|
74
|
+
rootSessionId: fields.sessionId,
|
|
75
|
+
hostTurnId: fields.turnId,
|
|
76
|
+
text: args.statementText,
|
|
77
|
+
observedAt: new Date().toISOString(),
|
|
78
|
+
explicitOwnerStatement: true,
|
|
79
|
+
};
|
|
80
|
+
const admitted = admitGovernanceSignals({ workspaceDir: args.workspaceDir, candidates: [candidate] });
|
|
81
|
+
if (!admitted.ok) {
|
|
82
|
+
return { status: 'rejected', reason: 'continuation_failed', nextAction: `${admitted.reason}: ${admitted.nextAction}`.slice(0, 400) };
|
|
83
|
+
}
|
|
84
|
+
const [outcome] = admitted.outcomes;
|
|
85
|
+
if (outcome === undefined || !('disposition' in outcome)) {
|
|
86
|
+
return { status: 'rejected', reason: 'continuation_failed', nextAction: 'The governance admission returned no disposition; nothing was recorded.' };
|
|
87
|
+
}
|
|
88
|
+
if (outcome.disposition === 'not_a_signal' || outcome.disposition === 'not_admitted') {
|
|
89
|
+
return { status: 'rejected', reason: 'continuation_failed', nextAction: 'reason' in outcome ? String(outcome.reason) : 'the signal was not admitted' };
|
|
90
|
+
}
|
|
91
|
+
if (outcome.disposition === 'rate_limited') {
|
|
92
|
+
return { status: 'rejected', reason: 'rate_limited', nextAction: 'The per-root-session correction quota (5/hour) is exhausted; resubmit later — the statement was NOT recorded.' };
|
|
93
|
+
}
|
|
94
|
+
// Task ensure is the receipt's hard guarantee; evidence promotion is
|
|
95
|
+
// best-effort (SPEC §6.4.5 — a degraded promotion is disclosed, never a
|
|
96
|
+
// failed receipt: the pain + task are durably recorded).
|
|
97
|
+
const ensured = await ensureGovernanceDiagnosticianTask({
|
|
98
|
+
workspaceDir: args.workspaceDir,
|
|
99
|
+
logicalObservationKey: candidate.logicalObservationKey,
|
|
100
|
+
canonicalPainId: outcome.canonicalPainId,
|
|
101
|
+
});
|
|
102
|
+
if (!ensured.ok) {
|
|
103
|
+
return { status: 'rejected', reason: 'continuation_failed', nextAction: `${ensured.reason}: ${ensured.nextAction}`.slice(0, 400) };
|
|
104
|
+
}
|
|
105
|
+
let promotionDegraded;
|
|
106
|
+
const promoted = promoteAdmittedGovernanceEvidence({
|
|
107
|
+
workspaceDir: args.workspaceDir,
|
|
108
|
+
rolloutIdentity: validated.rolloutIdentity,
|
|
109
|
+
triggerLogicalKey: candidate.logicalObservationKey,
|
|
110
|
+
canonicalPainId: outcome.canonicalPainId,
|
|
111
|
+
});
|
|
112
|
+
if (!promoted.ok) {
|
|
113
|
+
promotionDegraded = `${promoted.reason}`.slice(0, 160);
|
|
114
|
+
}
|
|
115
|
+
return {
|
|
116
|
+
status: 'received',
|
|
117
|
+
painId: outcome.canonicalPainId,
|
|
118
|
+
taskId: ensured.taskId,
|
|
119
|
+
disposition: outcome.disposition === 'already_admitted' ? 'already_admitted' : 'admitted',
|
|
120
|
+
logicalObservationKey: candidate.logicalObservationKey,
|
|
121
|
+
...(promotionDegraded !== undefined ? { promotionDegraded } : {}),
|
|
122
|
+
};
|
|
123
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ingestGovernanceObservations, readGovernanceCheckpoint, } from '@principles/host-runtime';
|
|
1
|
+
import { ingestGovernanceObservations, readGovernanceCheckpoint, recordVerifiedToolOutcomes, } from '@principles/host-runtime';
|
|
2
2
|
import { resolveCodexHome } from './codex-home.js';
|
|
3
3
|
import { validateCodexTranscriptPath } from './transcript-path.js';
|
|
4
4
|
import { classifyCodexVersion, CODEX_VERSION_NEXT_ACTION } from './codex-version.js';
|
|
@@ -70,6 +70,43 @@ function ingestLiveObservation({ fields, rolloutIdentity, workspaceDir, now }) {
|
|
|
70
70
|
rolloutIdentity,
|
|
71
71
|
};
|
|
72
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* SPEC-CODEX-PAIN-CLOSURE-001 CR-01: project decoded CommandExecution facts
|
|
75
|
+
* onto the shared verified-outcome upgrade. The transcript's model-level call
|
|
76
|
+
* name for the shell tool is `exec` while the PostToolUse hook names it
|
|
77
|
+
* `Bash` (g1 fixture 04-post-tool-use.json ↔ normal-tool-final-turn.jsonl,
|
|
78
|
+
* same tool_use_id) — the host-specific mapping stays here in the adapter.
|
|
79
|
+
*/
|
|
80
|
+
function collectVerifiedToolOutcomes(observations) {
|
|
81
|
+
const outcomes = [];
|
|
82
|
+
for (const observation of observations) {
|
|
83
|
+
if (observation.kind !== 'tool_call' || observation.toolUseId === undefined)
|
|
84
|
+
continue;
|
|
85
|
+
const facts = observation.toolFacts;
|
|
86
|
+
if (typeof facts !== 'object' || facts === null || Array.isArray(facts))
|
|
87
|
+
continue;
|
|
88
|
+
const { exitCode } = facts;
|
|
89
|
+
if (typeof exitCode !== 'number' || !Number.isInteger(exitCode))
|
|
90
|
+
continue;
|
|
91
|
+
const rawName = facts.toolName;
|
|
92
|
+
const toolName = rawName === 'exec' || typeof rawName !== 'string' || rawName.length === 0 ? 'Bash' : rawName;
|
|
93
|
+
const { stdout } = facts;
|
|
94
|
+
const { stderr } = facts;
|
|
95
|
+
const previewParts = [];
|
|
96
|
+
if (typeof stderr === 'string' && stderr.length > 0)
|
|
97
|
+
previewParts.push(stderr);
|
|
98
|
+
if (typeof stdout === 'string' && stdout.length > 0)
|
|
99
|
+
previewParts.push(stdout);
|
|
100
|
+
outcomes.push({
|
|
101
|
+
toolUseId: observation.toolUseId,
|
|
102
|
+
toolName,
|
|
103
|
+
params: facts.command ?? undefined,
|
|
104
|
+
exitCode,
|
|
105
|
+
...(previewParts.length > 0 ? { outputPreview: previewParts.join('\n') } : {}),
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
return outcomes;
|
|
109
|
+
}
|
|
73
110
|
function ingestTranscriptDelta({ fallbackRootSessionId, canonicalPath, identity, rolloutIdentity, workspaceDir, now, port }) {
|
|
74
111
|
const checkpoint = readGovernanceCheckpoint({ workspaceDir, hostKind: 'codex', rolloutIdentity });
|
|
75
112
|
if (checkpoint !== null && !('byteOffset' in checkpoint) && 'ok' in checkpoint && checkpoint.ok === false) {
|
|
@@ -126,6 +163,18 @@ function ingestTranscriptDelta({ fallbackRootSessionId, canonicalPath, identity,
|
|
|
126
163
|
degradations.push({ reason: 'transcript_record_too_large', nextAction: 'a single transcript record exceeds the bounded-read window; inspect the rollout file.' });
|
|
127
164
|
}
|
|
128
165
|
const rootSessionId = decoded.rolloutMeta.rootSessionId ?? existing?.rootSessionId ?? fallbackRootSessionId;
|
|
166
|
+
// CR-01: upgrade text-only live observations with the host-verified exit
|
|
167
|
+
// codes BEFORE the checkpoint advances, so a write failure holds the delta
|
|
168
|
+
// and the next Stop retries instead of silently losing the verified facts.
|
|
169
|
+
const verifiedOutcomes = collectVerifiedToolOutcomes(decoded.observations);
|
|
170
|
+
if (verifiedOutcomes.length > 0) {
|
|
171
|
+
const verified = recordVerifiedToolOutcomes({ workspaceDir, sessionId: rootSessionId, outcomes: verifiedOutcomes });
|
|
172
|
+
const failed = verified.find((result) => result.status === 'unavailable');
|
|
173
|
+
if (failed !== undefined) {
|
|
174
|
+
const reason = failed.reason === 'trajectory_db_not_found' ? 'verified_outcome_db_unavailable' : `verified_outcome_write_failed:${failed.reason.split(':', 2)[1] ?? ''}`;
|
|
175
|
+
return { status: 'degraded', reason, nextAction: 'inspect the workspace trajectory database; the transcript checkpoint was NOT advanced, the next Stop retries this delta.', warnings: decoded.warnings };
|
|
176
|
+
}
|
|
177
|
+
}
|
|
129
178
|
const result = ingestGovernanceObservations({
|
|
130
179
|
workspaceDir,
|
|
131
180
|
rollout: {
|
|
@@ -12,6 +12,7 @@ import { CodexHooksHostAdapter } from './host-adapter.js';
|
|
|
12
12
|
import { CodexDecoderError, CodexEncoderError } from './codec/index.js';
|
|
13
13
|
import { ingestCodexConversation } from './ingestion/ingestion.js';
|
|
14
14
|
import { runGovernanceAdmission } from './ingestion/admission.js';
|
|
15
|
+
import { parseOwnerStatementPrefix, recordExplicitOwnerStatement } from './ingestion/explicit-owner-statement.js';
|
|
15
16
|
import { recordCodexPromptDeliveryEvidence, recordCodexDenyEvidence } from './codex-evidence-recorder.js';
|
|
16
17
|
const MAX_DIAGNOSTIC = 500;
|
|
17
18
|
function diagnostic(reason, nextAction) {
|
|
@@ -190,9 +191,15 @@ async function runConversationIngestion(args) {
|
|
|
190
191
|
// Slice B admission: hook awaits only admission + durable enqueue —
|
|
191
192
|
// never an LLM (SPEC §12/§13). Ordinary conversation returns no
|
|
192
193
|
// candidates/no admissions and stays completely silent.
|
|
194
|
+
// CR-07: when the explicit Owner-statement entry already handled this
|
|
195
|
+
// turn's prompt, its generic correction candidate is suppressed so the
|
|
196
|
+
// observation passes through exactly one pain writer.
|
|
197
|
+
const candidates = args.suppressCorrectionCandidate === true
|
|
198
|
+
? outcome.admissionCandidates.filter((candidate) => candidate.kind !== 'user_correction')
|
|
199
|
+
: outcome.admissionCandidates;
|
|
193
200
|
const admission = await runGovernanceAdmission({
|
|
194
201
|
workspaceDir,
|
|
195
|
-
candidates
|
|
202
|
+
candidates,
|
|
196
203
|
});
|
|
197
204
|
for (const degradation of admission.degradations.slice(0, 2)) {
|
|
198
205
|
diagnostics.push(diagnostic(degradation.reason, degradation.nextAction));
|
|
@@ -276,8 +283,53 @@ export async function processHookInvocation(rawStdin, _env = process.env, cwd =
|
|
|
276
283
|
return { stdout: {}, exitCode: 0, stderr: [diagnostic(health.reason ?? 'runtime_unhealthy', health.nextAction ?? 'Inspect the Workspace runtime.')] };
|
|
277
284
|
return { stdout: adapter.encodeOutput({ decision: 'allow', source: event.source }, 'session_start'), exitCode: 0, stderr: [] };
|
|
278
285
|
}
|
|
286
|
+
// SPEC-CODEX-PAIN-CLOSURE-001 CR-07: the explicit Owner statement entry
|
|
287
|
+
// runs FIRST for the current user prompt — before the generic correction
|
|
288
|
+
// detection, so the same turn can never pass through two pain writers
|
|
289
|
+
// (the shared unique observation key dedups any replay). Works regardless
|
|
290
|
+
// of the codex_conversation_ingestion flag: only the transcript PATH is
|
|
291
|
+
// validated (rollout identity), never conversation content.
|
|
292
|
+
let explicitReceiptContext;
|
|
293
|
+
let explicitSuppressedGeneric = false;
|
|
294
|
+
const explicitDiagnostics = [];
|
|
295
|
+
if (event.kind === 'before_prompt_build') {
|
|
296
|
+
const rawRecord = parsed;
|
|
297
|
+
const prefixParse = parseOwnerStatementPrefix(typeof rawRecord?.prompt === 'string' ? rawRecord.prompt : undefined);
|
|
298
|
+
if (prefixParse.matched) {
|
|
299
|
+
explicitSuppressedGeneric = true;
|
|
300
|
+
if (prefixParse.text === null) {
|
|
301
|
+
explicitDiagnostics.push(diagnostic(`owner_statement_${prefixParse.reason ?? 'rejected'}`, prefixParse.reason === 'statement_too_long'
|
|
302
|
+
? `The statement exceeds 500 characters; nothing was recorded. Resubmit within the limit.`
|
|
303
|
+
: 'The prefix carried no statement text; nothing was recorded. Resubmit as PD记录痛苦:<反馈原文>.'));
|
|
304
|
+
}
|
|
305
|
+
else {
|
|
306
|
+
const receipt = await recordExplicitOwnerStatement({
|
|
307
|
+
rawPayload: parsed,
|
|
308
|
+
workspaceDir: resolution.workspaceDir,
|
|
309
|
+
statementText: prefixParse.text,
|
|
310
|
+
env: _env,
|
|
311
|
+
});
|
|
312
|
+
if (receipt.status === 'received') {
|
|
313
|
+
explicitReceiptContext = `[PD] 已收到痛苦反馈(painId=${receipt.painId}, taskId=${receipt.taskId}${receipt.disposition === 'already_admitted' ? ', 重复提交已合并为同一信号' : ''})。后台将自动诊断;请在回复中如实转述本回执,不要声称仍在等待用户输入,也不要虚构诊断结论。${receipt.promotionDegraded !== undefined ? `(注意:会话证据提升暂不可用:${receipt.promotionDegraded};诊断仍会基于你提交的陈述进行。)` : ''}`;
|
|
314
|
+
explicitDiagnostics.push(diagnostic(`owner_statement_received:${receipt.painId}:${receipt.taskId}${receipt.promotionDegraded !== undefined ? `:promotion_degraded:${receipt.promotionDegraded}` : ''}`, 'Durable enqueue complete; the workspace worker continues diagnosis in the background.'));
|
|
315
|
+
}
|
|
316
|
+
else {
|
|
317
|
+
explicitDiagnostics.push(diagnostic(`owner_statement_${receipt.reason}`, receipt.nextAction));
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}
|
|
279
322
|
const ingestionDiagnostics = ingestionEnabled
|
|
280
|
-
? await runConversationIngestion({
|
|
323
|
+
? await runConversationIngestion({
|
|
324
|
+
rawPayload: parsed,
|
|
325
|
+
kind: event.kind,
|
|
326
|
+
workspaceDir: resolution.workspaceDir,
|
|
327
|
+
env: _env,
|
|
328
|
+
// CR-07: the explicit path already handled this turn's user prompt —
|
|
329
|
+
// suppress the generic correction candidate so exactly one writer
|
|
330
|
+
// processed the observation (A17).
|
|
331
|
+
...(explicitSuppressedGeneric && event.kind === 'before_prompt_build' ? { suppressCorrectionCandidate: true } : {}),
|
|
332
|
+
})
|
|
281
333
|
: [];
|
|
282
334
|
// PD v2 Phase 1: evidence context for this subprocess invocation. The
|
|
283
335
|
// ledger flag follows the OpenClaw convention (principle_receipt_ledger
|
|
@@ -314,6 +366,17 @@ export async function processHookInvocation(rawStdin, _env = process.env, cwd =
|
|
|
314
366
|
// v2 enforcement is suspended (PRI-780); wired honestly for the day it
|
|
315
367
|
// is not.
|
|
316
368
|
const encoded = adapter.encodeOutput(result, event.kind);
|
|
369
|
+
// CR-07 (A16): the explicit-statement receipt rides as additional context
|
|
370
|
+
// so the model can answer truthfully about what happened (received +
|
|
371
|
+
// queued), instead of guessing or claiming it is still waiting for input.
|
|
372
|
+
if (explicitReceiptContext !== undefined && event.kind === 'before_prompt_build') {
|
|
373
|
+
const output = encoded;
|
|
374
|
+
if (output.hookSpecificOutput !== undefined) {
|
|
375
|
+
output.hookSpecificOutput.additionalContext = output.hookSpecificOutput.additionalContext !== undefined
|
|
376
|
+
? `${output.hookSpecificOutput.additionalContext}\n${explicitReceiptContext}`
|
|
377
|
+
: explicitReceiptContext;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
317
380
|
if (result.decision === 'deny') {
|
|
318
381
|
try {
|
|
319
382
|
let liveActivationId;
|
|
@@ -356,7 +419,7 @@ export async function processHookInvocation(rawStdin, _env = process.env, cwd =
|
|
|
356
419
|
evidenceDiagnostics.push(diagnostic(`codex_evidence_deny_failed:${errorMessage(error)}`, 'The deny decision was already encoded; evidence replay from the durable source is safe.'));
|
|
357
420
|
}
|
|
358
421
|
}
|
|
359
|
-
const stderr = [...annotateContextWarnings(result.warnings ?? []).slice(0, 16).map((warning) => diagnostic(warning, 'Inspect PD Workspace state and retry; the hook failed open.')), ...evaluationDiagnostics, ...evidenceDiagnostics, ...ingestionDiagnostics];
|
|
422
|
+
const stderr = [...annotateContextWarnings(result.warnings ?? []).slice(0, 16).map((warning) => diagnostic(warning, 'Inspect PD Workspace state and retry; the hook failed open.')), ...evaluationDiagnostics, ...evidenceDiagnostics, ...explicitDiagnostics, ...ingestionDiagnostics];
|
|
360
423
|
return { stdout: encoded, exitCode: 0, stderr };
|
|
361
424
|
}
|
|
362
425
|
catch (error) {
|
|
@@ -2,9 +2,22 @@ import { type InternalizationConsumerCycleOutcome, type ConsumerCycleLogger, typ
|
|
|
2
2
|
import { type CodexCatchUpResult } from '../ingestion/catch-up.js';
|
|
3
3
|
import type { TranscriptPort } from '../ingestion/transcript-decoder.js';
|
|
4
4
|
export type CodexWorkerMode = 'ready' | 'manual_action_required' | 'paused' | 'degraded';
|
|
5
|
+
export interface CodexWorkerPostProcessingReport {
|
|
6
|
+
readonly resumedTaskIds: readonly string[];
|
|
7
|
+
readonly processedCount: number;
|
|
8
|
+
/** Eligible-after-this-cycle backlog size (oldest-first scan is bounded). */
|
|
9
|
+
readonly remainingCount: number;
|
|
10
|
+
readonly oldestAgeMs: number | null;
|
|
11
|
+
readonly blocked: readonly {
|
|
12
|
+
candidateId: string;
|
|
13
|
+
reason: string;
|
|
14
|
+
}[];
|
|
15
|
+
}
|
|
5
16
|
export interface CodexWorkerCycleStepReport {
|
|
6
17
|
readonly catchUp: CodexCatchUpResult;
|
|
7
18
|
readonly reconcile: ReconcileGovernanceContinuationResult;
|
|
19
|
+
/** CR-05: succeeded-diagnosis post-processing continuation (no LLM). */
|
|
20
|
+
readonly postProcessing: CodexWorkerPostProcessingReport | null;
|
|
8
21
|
/** At most ONE diagnostician execution per cycle (bounded work). */
|
|
9
22
|
readonly diagnostician: {
|
|
10
23
|
readonly taskId: string;
|
|
@@ -41,6 +54,7 @@ export interface CodexWorkerCycleOptions {
|
|
|
41
54
|
/** Cap on diagnostician candidates inspected per cycle (default 5). */
|
|
42
55
|
readonly diagnosticianCandidateLimit?: number;
|
|
43
56
|
}
|
|
57
|
+
export declare function readCodexWorkerLiveness(workspaceDir: string): Record<string, unknown> | null;
|
|
44
58
|
/**
|
|
45
59
|
* Run ONE bounded worker cycle for a canonical workspace. Never throws:
|
|
46
60
|
* every failure becomes a structured degraded result with a nextAction.
|