create-principles-disciple 1.152.5 → 1.153.1
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/agent-skill/pd-setup/SKILL.md +70 -0
- package/codex-adapter/dist/background-selection.d.ts +9 -0
- package/codex-adapter/dist/background-selection.js +142 -0
- package/codex-adapter/dist/ingestion/adaptive-append-state.d.ts +209 -0
- package/codex-adapter/dist/ingestion/adaptive-append-state.js +544 -0
- package/codex-adapter/dist/pd-hook.js +329 -5
- package/codex-adapter/package.json +1 -1
- package/console/dist/server/config/pd-config-store.d.ts +11 -15
- package/console/dist/server/config/pd-config-store.js +92 -17
- package/console/dist/server/models/ActivationsConsoleModel.d.ts +8 -0
- package/console/dist/server/models/ActivationsConsoleModel.js +3 -2
- package/console/dist/server/models/AdaptiveActivationConsoleModel.d.ts +43 -4
- package/console/dist/server/models/AdaptiveActivationConsoleModel.js +36 -7
- package/console/dist/server/models/ExaminerEvidenceModel.d.ts +6 -2
- package/console/dist/server/models/ExaminerEvidenceModel.js +13 -2
- package/console/dist/server/routes/config.js +34 -8
- package/console/dist/server/routes/examiner-executor.d.ts +33 -0
- package/console/dist/server/routes/examiner-executor.js +95 -0
- package/console/dist/server/routes/examiner.js +12 -9
- package/console/dist/web/assets/app.css +14 -10
- package/console/dist/web/assets/app.js +27 -27
- package/core/dist/ledger-file-lock.d.ts +38 -0
- package/core/dist/ledger-file-lock.d.ts.map +1 -0
- package/core/dist/ledger-file-lock.js +240 -0
- package/core/dist/ledger-file-lock.js.map +1 -0
- package/core/dist/principle-text-normalization.d.ts +32 -0
- package/core/dist/principle-text-normalization.d.ts.map +1 -0
- package/core/dist/principle-text-normalization.js +34 -0
- package/core/dist/principle-text-normalization.js.map +1 -0
- package/core/dist/principle-tree-ledger.d.ts +22 -21
- package/core/dist/principle-tree-ledger.d.ts.map +1 -1
- package/core/dist/principle-tree-ledger.js +77 -204
- package/core/dist/principle-tree-ledger.js.map +1 -1
- package/core/dist/runtime/activation/sqlite-approval-store.d.ts.map +1 -1
- package/core/dist/runtime/activation/sqlite-approval-store.js +7 -1
- package/core/dist/runtime/activation/sqlite-approval-store.js.map +1 -1
- package/core/dist/runtime/adapter/principle-tree-ledger-adapter.d.ts +13 -0
- package/core/dist/runtime/adapter/principle-tree-ledger-adapter.d.ts.map +1 -1
- package/core/dist/runtime/adapter/principle-tree-ledger-adapter.js +90 -1
- package/core/dist/runtime/adapter/principle-tree-ledger-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 +21 -30
- package/core/dist/runtime/adapter/schema-prompt-adapter.js.map +1 -1
- package/core/dist/runtime/candidate-intake-service.d.ts +40 -1
- package/core/dist/runtime/candidate-intake-service.d.ts.map +1 -1
- package/core/dist/runtime/candidate-intake-service.js +548 -110
- package/core/dist/runtime/candidate-intake-service.js.map +1 -1
- package/core/dist/runtime/candidate-intake.d.ts +59 -2
- package/core/dist/runtime/candidate-intake.d.ts.map +1 -1
- package/core/dist/runtime/candidate-intake.js +23 -0
- package/core/dist/runtime/candidate-intake.js.map +1 -1
- package/core/dist/runtime/candidate-seed-suppression.d.ts +63 -0
- package/core/dist/runtime/candidate-seed-suppression.d.ts.map +1 -0
- package/core/dist/runtime/candidate-seed-suppression.js +29 -0
- package/core/dist/runtime/candidate-seed-suppression.js.map +1 -0
- package/core/dist/runtime/config/pd-config-agent-binding.d.ts +5 -5
- package/core/dist/runtime/config/pd-config-agent-binding.d.ts.map +1 -1
- package/core/dist/runtime/config/pd-config-agent-binding.js +22 -16
- package/core/dist/runtime/config/pd-config-agent-binding.js.map +1 -1
- package/core/dist/runtime/config/pd-config-feature-flags.d.ts +10 -0
- package/core/dist/runtime/config/pd-config-feature-flags.d.ts.map +1 -1
- package/core/dist/runtime/config/pd-config-feature-flags.js +14 -0
- package/core/dist/runtime/config/pd-config-feature-flags.js.map +1 -1
- package/core/dist/runtime/config/pd-config-types.d.ts +9 -0
- package/core/dist/runtime/config/pd-config-types.d.ts.map +1 -1
- package/core/dist/runtime/config/pd-config-types.js.map +1 -1
- package/core/dist/runtime/config/pd-config-validate.d.ts.map +1 -1
- package/core/dist/runtime/config/pd-config-validate.js +10 -2
- package/core/dist/runtime/config/pd-config-validate.js.map +1 -1
- package/core/dist/runtime/config/pd-credentials.d.ts.map +1 -1
- package/core/dist/runtime/config/pd-credentials.js +7 -1
- package/core/dist/runtime/config/pd-credentials.js.map +1 -1
- package/core/dist/runtime/diagnostician/distiller-prompt-builder.d.ts.map +1 -1
- package/core/dist/runtime/diagnostician/distiller-prompt-builder.js +30 -3
- package/core/dist/runtime/diagnostician/distiller-prompt-builder.js.map +1 -1
- package/core/dist/runtime/diagnostician/rootcause-prompt-builder.d.ts.map +1 -1
- package/core/dist/runtime/diagnostician/rootcause-prompt-builder.js +16 -5
- package/core/dist/runtime/diagnostician/rootcause-prompt-builder.js.map +1 -1
- package/core/dist/runtime/diagnostician/router-prompt-builder.d.ts.map +1 -1
- package/core/dist/runtime/diagnostician/router-prompt-builder.js +16 -4
- package/core/dist/runtime/diagnostician/router-prompt-builder.js.map +1 -1
- package/core/dist/runtime/feature-flags/feature-flag-lifecycle.d.ts.map +1 -1
- package/core/dist/runtime/feature-flags/feature-flag-lifecycle.js +13 -2
- package/core/dist/runtime/feature-flags/feature-flag-lifecycle.js.map +1 -1
- package/core/dist/runtime/index.d.ts +4 -2
- package/core/dist/runtime/index.d.ts.map +1 -1
- package/core/dist/runtime/index.js +3 -1
- package/core/dist/runtime/index.js.map +1 -1
- package/core/dist/runtime/intent/intent-doc.d.ts +22 -0
- package/core/dist/runtime/intent/intent-doc.d.ts.map +1 -1
- package/core/dist/runtime/intent/intent-doc.js +79 -0
- package/core/dist/runtime/intent/intent-doc.js.map +1 -1
- package/core/dist/runtime/intent/intent-friction-block.d.ts +7 -0
- package/core/dist/runtime/intent/intent-friction-block.d.ts.map +1 -1
- package/core/dist/runtime/intent/intent-friction-block.js +34 -1
- package/core/dist/runtime/intent/intent-friction-block.js.map +1 -1
- package/core/dist/runtime/intent/intent-snapshot.d.ts +44 -5
- package/core/dist/runtime/intent/intent-snapshot.d.ts.map +1 -1
- package/core/dist/runtime/intent/intent-snapshot.js +83 -15
- package/core/dist/runtime/intent/intent-snapshot.js.map +1 -1
- package/core/dist/runtime/intent/strategic-conflict-gate.d.ts +19 -0
- package/core/dist/runtime/intent/strategic-conflict-gate.d.ts.map +1 -1
- package/core/dist/runtime/intent/strategic-conflict-gate.js +94 -26
- package/core/dist/runtime/intent/strategic-conflict-gate.js.map +1 -1
- package/core/dist/runtime/internalization/diag-rootcause-runner.d.ts +22 -11
- package/core/dist/runtime/internalization/diag-rootcause-runner.d.ts.map +1 -1
- package/core/dist/runtime/internalization/diag-rootcause-runner.js +101 -28
- package/core/dist/runtime/internalization/diag-rootcause-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 +177 -28
- package/core/dist/runtime/internalization/dreamer-prompt-builder.js.map +1 -1
- package/core/dist/runtime/internalization/dreamer-runner.d.ts +9 -2
- package/core/dist/runtime/internalization/dreamer-runner.d.ts.map +1 -1
- package/core/dist/runtime/internalization/dreamer-runner.js +11 -1
- package/core/dist/runtime/internalization/dreamer-runner.js.map +1 -1
- package/core/dist/runtime/internalization/evaluator-runner.d.ts.map +1 -1
- package/core/dist/runtime/internalization/evaluator-runner.js +7 -0
- package/core/dist/runtime/internalization/evaluator-runner.js.map +1 -1
- package/core/dist/runtime/internalization/formation-context.d.ts +16 -0
- package/core/dist/runtime/internalization/formation-context.d.ts.map +1 -1
- package/core/dist/runtime/internalization/formation-context.js +109 -8
- 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 +55 -4
- package/core/dist/runtime/internalization/intent-contract.d.ts.map +1 -1
- package/core/dist/runtime/internalization/intent-contract.js +111 -30
- package/core/dist/runtime/internalization/intent-contract.js.map +1 -1
- package/core/dist/runtime/internalization/internalization-orchestrator.d.ts +16 -2
- package/core/dist/runtime/internalization/internalization-orchestrator.d.ts.map +1 -1
- package/core/dist/runtime/internalization/internalization-orchestrator.js +48 -14
- package/core/dist/runtime/internalization/internalization-orchestrator.js.map +1 -1
- package/core/dist/runtime/internalization/philosopher-prompt-builder.d.ts.map +1 -1
- package/core/dist/runtime/internalization/philosopher-prompt-builder.js +7 -6
- package/core/dist/runtime/internalization/philosopher-prompt-builder.js.map +1 -1
- package/core/dist/runtime/internalization/philosopher-runner.d.ts +9 -2
- package/core/dist/runtime/internalization/philosopher-runner.d.ts.map +1 -1
- package/core/dist/runtime/internalization/philosopher-runner.js +11 -1
- package/core/dist/runtime/internalization/philosopher-runner.js.map +1 -1
- package/core/dist/runtime/internalization/scribe-prompt-builder.d.ts +13 -6
- package/core/dist/runtime/internalization/scribe-prompt-builder.d.ts.map +1 -1
- package/core/dist/runtime/internalization/scribe-prompt-builder.js +15 -10
- package/core/dist/runtime/internalization/scribe-prompt-builder.js.map +1 -1
- package/core/dist/runtime/internalization/scribe-runner.d.ts.map +1 -1
- package/core/dist/runtime/internalization/scribe-runner.js +17 -7
- package/core/dist/runtime/internalization/scribe-runner.js.map +1 -1
- package/core/dist/runtime/pain-signal-bridge.d.ts +3 -0
- package/core/dist/runtime/pain-signal-bridge.d.ts.map +1 -1
- package/core/dist/runtime/pain-signal-bridge.js +224 -93
- package/core/dist/runtime/pain-signal-bridge.js.map +1 -1
- package/core/dist/runtime/pain-submit-capability.d.ts.map +1 -1
- package/core/dist/runtime/pain-submit-capability.js +3 -5
- package/core/dist/runtime/pain-submit-capability.js.map +1 -1
- package/core/dist/runtime/pain-to-principle-service.d.ts.map +1 -1
- package/core/dist/runtime/pain-to-principle-service.js +18 -21
- package/core/dist/runtime/pain-to-principle-service.js.map +1 -1
- package/core/dist/runtime/store/candidate/admission-document.d.ts +129 -0
- package/core/dist/runtime/store/candidate/admission-document.d.ts.map +1 -1
- package/core/dist/runtime/store/candidate/admission-document.js +196 -0
- package/core/dist/runtime/store/candidate/admission-document.js.map +1 -1
- package/core/dist/runtime/store/candidate/candidate-store.d.ts +54 -1
- package/core/dist/runtime/store/candidate/candidate-store.d.ts.map +1 -1
- package/core/dist/runtime/store/candidate/memory-candidate-store.d.ts +32 -1
- package/core/dist/runtime/store/candidate/memory-candidate-store.d.ts.map +1 -1
- package/core/dist/runtime/store/candidate/memory-candidate-store.js +24 -1
- package/core/dist/runtime/store/candidate/memory-candidate-store.js.map +1 -1
- package/core/dist/runtime/store/candidate/sqlite-candidate-store.d.ts +32 -1
- package/core/dist/runtime/store/candidate/sqlite-candidate-store.d.ts.map +1 -1
- package/core/dist/runtime/store/candidate/sqlite-candidate-store.js +76 -1
- package/core/dist/runtime/store/candidate/sqlite-candidate-store.js.map +1 -1
- package/core/dist/runtime/store/intent/sqlite-intent-decision-store.d.ts +10 -0
- 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 +15 -4
- package/core/dist/runtime/store/intent/sqlite-intent-decision-store.js.map +1 -1
- package/core/dist/runtime/store/runtime-state-manager.d.ts +34 -1
- package/core/dist/runtime/store/runtime-state-manager.d.ts.map +1 -1
- package/core/dist/runtime/store/runtime-state-manager.js +10 -0
- package/core/dist/runtime/store/runtime-state-manager.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 +6 -0
- package/core/dist/telemetry-event.js.map +1 -1
- package/core/package.json +1 -1
- package/dist/agent-skill.d.ts +59 -0
- package/dist/agent-skill.d.ts.map +1 -0
- package/dist/agent-skill.js +198 -0
- package/dist/agent-skill.js.map +1 -0
- package/dist/i18n.d.ts.map +1 -1
- package/dist/i18n.js +12 -0
- package/dist/i18n.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +171 -3
- package/dist/index.js.map +1 -1
- package/dist/install-summary.d.ts +52 -0
- package/dist/install-summary.d.ts.map +1 -1
- package/dist/install-summary.js +104 -0
- package/dist/install-summary.js.map +1 -1
- package/host-runtime/dist/adaptive-background-append.d.ts +70 -0
- package/host-runtime/dist/adaptive-background-append.js +165 -0
- package/host-runtime/dist/governance-signal-admission.js +1 -5
- package/host-runtime/dist/index.d.ts +1 -0
- package/host-runtime/dist/index.js +5 -0
- package/host-runtime/package.json +1 -1
- package/package.json +3 -2
- package/pd-cli/dist/commands/candidate.d.ts.map +1 -1
- package/pd-cli/dist/commands/candidate.js +243 -28
- package/pd-cli/dist/commands/candidate.js.map +1 -1
- package/pd-cli/dist/commands/diagnose.d.ts.map +1 -1
- package/pd-cli/dist/commands/diagnose.js +110 -7
- package/pd-cli/dist/commands/diagnose.js.map +1 -1
- package/pd-cli/dist/commands/health-console.d.ts +21 -0
- package/pd-cli/dist/commands/health-console.d.ts.map +1 -0
- package/pd-cli/dist/commands/health-console.js +106 -0
- package/pd-cli/dist/commands/health-console.js.map +1 -0
- package/pd-cli/dist/commands/health.d.ts +159 -0
- package/pd-cli/dist/commands/health.d.ts.map +1 -1
- package/pd-cli/dist/commands/health.js +162 -2
- package/pd-cli/dist/commands/health.js.map +1 -1
- package/pd-cli/dist/commands/mcp-probe.d.ts +48 -0
- package/pd-cli/dist/commands/mcp-probe.d.ts.map +1 -0
- package/pd-cli/dist/commands/mcp-probe.js +479 -0
- package/pd-cli/dist/commands/mcp-probe.js.map +1 -0
- package/pd-cli/dist/commands/pain-retry.d.ts.map +1 -1
- package/pd-cli/dist/commands/pain-retry.js +3 -0
- package/pd-cli/dist/commands/pain-retry.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 +70 -4
- package/pd-cli/dist/commands/runtime-internalization-run-once.js.map +1 -1
- package/pd-cli/dist/program.d.ts.map +1 -1
- package/pd-cli/dist/program.js +68 -1
- package/pd-cli/dist/program.js.map +1 -1
- package/pd-cli/dist/services/admission-write-gate.d.ts.map +1 -1
- package/pd-cli/dist/services/admission-write-gate.js +18 -7
- package/pd-cli/dist/services/admission-write-gate.js.map +1 -1
- package/pd-cli/dist/services/console-launcher.d.ts +3 -0
- package/pd-cli/dist/services/console-launcher.d.ts.map +1 -1
- package/pd-cli/dist/services/console-launcher.js +3 -2
- package/pd-cli/dist/services/console-launcher.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 +8 -3
- package/pd-cli/dist/services/demo-story-a-runner.js.map +1 -1
- package/pd-cli/dist/services/reuse-park-release.d.ts +142 -0
- package/pd-cli/dist/services/reuse-park-release.d.ts.map +1 -0
- package/pd-cli/dist/services/reuse-park-release.js +201 -0
- package/pd-cli/dist/services/reuse-park-release.js.map +1 -0
- package/pd-cli/package.json +1 -1
- package/plugin/dist/bundle.js +914 -640
- package/plugin/dist/openclaw.plugin.json +1 -1
- package/plugin/openclaw.plugin.json +1 -1
- package/plugin/package.json +1 -1
- package/release-manager/dist/i18n.js +12 -0
- package/release-manager/package.json +2 -1
- package/workbuddy-adapter/dist/pd-hook.js +37 -3
- package/workbuddy-adapter/package.json +1 -1
|
@@ -799,7 +799,13 @@ const ADAPTIVE_ACTIVATION_FLAG_NAMES = new Set([
|
|
|
799
799
|
'host.openclaw.adaptive_activation',
|
|
800
800
|
'host.workbuddy.adaptive_activation',
|
|
801
801
|
]);
|
|
802
|
-
const
|
|
802
|
+
export const ADAPTIVE_ACTIVATION_HOST_FLAGS = {
|
|
803
|
+
codex: 'host.codex.adaptive_activation',
|
|
804
|
+
workbuddy: 'host.workbuddy.adaptive_activation',
|
|
805
|
+
};
|
|
806
|
+
export function isAdaptiveActivationHost(value) {
|
|
807
|
+
return value === 'codex' || value === 'workbuddy';
|
|
808
|
+
}
|
|
803
809
|
/**
|
|
804
810
|
* The ONE team-confirmed Decisions combination the Console offers on first
|
|
805
811
|
* setup. The endpoint/model/provider/credential-variable are frozen: the entry
|
|
@@ -815,7 +821,7 @@ export const ADAPTIVE_ACTIVATION_SERVICE_PRESET = {
|
|
|
815
821
|
/** Frozen EXACT response-model allowlist from the accepted real runs. */
|
|
816
822
|
responseModels: ['respan/span-01-lite:free', 'respan/span-01-lite-20260925'],
|
|
817
823
|
};
|
|
818
|
-
const ADAPTIVE_ACTIVATION_UPDATE_KEYS = new Set(['enabled', 'service']);
|
|
824
|
+
const ADAPTIVE_ACTIVATION_UPDATE_KEYS = new Set(['enabled', 'service', 'host', 'timing']);
|
|
819
825
|
function isConfiguredSection(section) {
|
|
820
826
|
return section !== undefined
|
|
821
827
|
&& typeof section.endpoint === 'string' && section.endpoint.length > 0
|
|
@@ -893,35 +899,66 @@ function readRawConfigForUpdate(workspaceDir) {
|
|
|
893
899
|
/**
|
|
894
900
|
* Write the workspace's Adaptive Activation settings.
|
|
895
901
|
*
|
|
896
|
-
* Supported payload (
|
|
897
|
-
* { enabled?: boolean; service?: 'decisions-openrouter-respan'
|
|
902
|
+
* Supported payload (at least one of enabled/service required):
|
|
903
|
+
* { enabled?: boolean; service?: 'decisions-openrouter-respan';
|
|
904
|
+
* host?: 'codex' | 'workbuddy' }
|
|
898
905
|
*
|
|
899
906
|
* Guarantees:
|
|
900
907
|
* - ZERO network: saving a configuration never sends a scoring request;
|
|
901
908
|
* - append-only v1: a non-empty `replaceableActivationIds` refuses BOTH a
|
|
902
909
|
* service write and `enabled: true`, while `enabled: false` always works;
|
|
903
910
|
* - the service section is workspace-scoped and shared with the other hosts,
|
|
904
|
-
* so it is not rewritten
|
|
911
|
+
* so it is not rewritten while ANOTHER host (relative to `host`) has
|
|
905
912
|
* Adaptive enabled;
|
|
913
|
+
* - `host` selects ONE existing switch; enabling never touches a second one.
|
|
914
|
+
* Omitting it keeps the original Codex behaviour (PRI-1196 compatible).
|
|
906
915
|
* - enable requires a complete section — it is never "enabled but unusable".
|
|
907
916
|
*/
|
|
917
|
+
function workbuddyIntegrationDisabled() {
|
|
918
|
+
return {
|
|
919
|
+
ok: false,
|
|
920
|
+
statusCode: 409,
|
|
921
|
+
error: 'adaptive_workbuddy_host_disabled',
|
|
922
|
+
message: 'WorkBuddy integration is disabled for this workspace.',
|
|
923
|
+
nextAction: 'Enable the WorkBuddy host integration before enabling Adaptive Activation.',
|
|
924
|
+
};
|
|
925
|
+
}
|
|
908
926
|
export function updateAdaptiveActivationSettings(workspaceDir, payload) {
|
|
909
927
|
if (!isRecord(payload)) {
|
|
910
|
-
return { ok: false, statusCode: 400, error: 'bad_request', message: 'Body must be a JSON object with enabled and/or
|
|
928
|
+
return { ok: false, statusCode: 400, error: 'bad_request', message: 'Body must be a JSON object with enabled, service and/or timing fields' };
|
|
911
929
|
}
|
|
912
930
|
for (const key of Object.keys(payload)) {
|
|
913
931
|
if (!ADAPTIVE_ACTIVATION_UPDATE_KEYS.has(key)) {
|
|
914
|
-
return { ok: false, statusCode: 400, error: 'unknown_field', message: `Unknown field '${key}'. Supported fields: enabled, service` };
|
|
932
|
+
return { ok: false, statusCode: 400, error: 'unknown_field', message: `Unknown field '${key}'. Supported fields: enabled, service, host, timing` };
|
|
915
933
|
}
|
|
916
934
|
}
|
|
935
|
+
const requestedHost = payload.host;
|
|
936
|
+
if (requestedHost !== undefined && !isAdaptiveActivationHost(requestedHost)) {
|
|
937
|
+
return { ok: false, statusCode: 400, error: 'unknown_host', message: `Unknown Adaptive host '${String(requestedHost)}'. Supported hosts: codex, workbuddy` };
|
|
938
|
+
}
|
|
939
|
+
const host = isAdaptiveActivationHost(requestedHost) ? requestedHost : 'codex';
|
|
940
|
+
const hostFlag = ADAPTIVE_ACTIVATION_HOST_FLAGS[host];
|
|
917
941
|
const hasEnabled = Object.hasOwn(payload, 'enabled');
|
|
918
942
|
const hasService = Object.hasOwn(payload, 'service');
|
|
919
|
-
|
|
920
|
-
|
|
943
|
+
const hasTiming = Object.hasOwn(payload, 'timing');
|
|
944
|
+
if (hasTiming && host !== 'codex') {
|
|
945
|
+
return { ok: false, statusCode: 400, error: 'adaptive_timing_unsupported_host', message: 'Selection timing is configurable only for Codex.' };
|
|
946
|
+
}
|
|
947
|
+
if (!hasEnabled && !hasService && !hasTiming) {
|
|
948
|
+
return { ok: false, statusCode: 400, error: 'bad_request', message: 'Nothing to update: send enabled, service and/or timing' };
|
|
921
949
|
}
|
|
922
950
|
if (hasEnabled && typeof payload.enabled !== 'boolean') {
|
|
923
951
|
return { ok: false, statusCode: 400, error: 'bad_request', message: `enabled must be a boolean. Got: ${typeof payload.enabled}` };
|
|
924
952
|
}
|
|
953
|
+
if (hasTiming && payload.timing !== 'sync' && payload.timing !== 'background') {
|
|
954
|
+
return {
|
|
955
|
+
ok: false,
|
|
956
|
+
statusCode: 400,
|
|
957
|
+
error: 'bad_request',
|
|
958
|
+
message: `timing must be 'sync' or 'background'. Got: ${String(payload.timing)}`,
|
|
959
|
+
nextAction: "Send { timing: 'sync' } (decide before the first request) or { timing: 'background' } (send Native first, append later in the turn)",
|
|
960
|
+
};
|
|
961
|
+
}
|
|
925
962
|
if (hasService && payload.service !== ADAPTIVE_ACTIVATION_SERVICE_PRESET.id) {
|
|
926
963
|
return {
|
|
927
964
|
ok: false,
|
|
@@ -937,6 +974,9 @@ export function updateAdaptiveActivationSettings(workspaceDir, payload) {
|
|
|
937
974
|
return { ok: false, ...rawRead.failure };
|
|
938
975
|
}
|
|
939
976
|
const { configPath, rawConfig, featuresSection, config } = rawRead;
|
|
977
|
+
if (host === 'workbuddy' && enableRequested && config.features['host.workbuddy']?.enabled !== true) {
|
|
978
|
+
return workbuddyIntegrationDisabled();
|
|
979
|
+
}
|
|
940
980
|
const currentSection = config.adaptiveActivation;
|
|
941
981
|
const replaceableIds = currentSection?.replaceableActivationIds ?? [];
|
|
942
982
|
if (replaceableIds.length > 0 && (hasService || enableRequested)) {
|
|
@@ -950,14 +990,16 @@ export function updateAdaptiveActivationSettings(workspaceDir, payload) {
|
|
|
950
990
|
nextAction: 'Keep the existing configuration unchanged (disable is still allowed), or remove adaptiveActivation.replaceableActivationIds in .pd/config.yaml to switch to append-only.',
|
|
951
991
|
};
|
|
952
992
|
}
|
|
953
|
-
|
|
954
|
-
|
|
993
|
+
// "Other host" is relative to the SELECTED entry: a WorkBuddy save must not
|
|
994
|
+
// be blocked by its own flag, but must still be blocked by Codex/OpenClaw.
|
|
995
|
+
const otherHostAaEnabled = ['host.codex.adaptive_activation', 'host.openclaw.adaptive_activation', 'host.workbuddy.adaptive_activation']
|
|
996
|
+
.filter((name) => name !== hostFlag && config.features[name]?.enabled === true);
|
|
955
997
|
if (hasService && otherHostAaEnabled.length > 0) {
|
|
956
998
|
return {
|
|
957
999
|
ok: false,
|
|
958
1000
|
statusCode: 409,
|
|
959
1001
|
error: 'shared_service_config_locked',
|
|
960
|
-
message: `Another host in this workspace already has Adaptive enabled (${otherHostAaEnabled.join(', ')}). The Decisions service configuration is shared per workspace and cannot be rewritten from the
|
|
1002
|
+
message: `Another host in this workspace already has Adaptive enabled (${otherHostAaEnabled.join(', ')}). The Decisions service configuration is shared per workspace and cannot be rewritten from the ${host} entry.`,
|
|
961
1003
|
nextAction: 'Disable the other host Adaptive flag in .pd/config.yaml first, then save the service configuration here.',
|
|
962
1004
|
};
|
|
963
1005
|
}
|
|
@@ -977,16 +1019,38 @@ export function updateAdaptiveActivationSettings(workspaceDir, payload) {
|
|
|
977
1019
|
nextAction: `Save the '${ADAPTIVE_ACTIVATION_SERVICE_PRESET.id}' service preset first, or add adaptiveActivation: {endpoint, model, apiKeyEnv} to .pd/config.yaml.`,
|
|
978
1020
|
};
|
|
979
1021
|
}
|
|
1022
|
+
// PRI-1196: selection timing belongs to the SAME section as the service.
|
|
1023
|
+
// Writing it without a usable service would create an invalid section, and
|
|
1024
|
+
// 'background' with a replacement configuration would contradict the
|
|
1025
|
+
// append-only guarantee of the async mode.
|
|
1026
|
+
if (hasTiming && !isConfiguredSection(effectiveSection)) {
|
|
1027
|
+
return {
|
|
1028
|
+
ok: false,
|
|
1029
|
+
statusCode: 400,
|
|
1030
|
+
error: 'adaptive_activation_not_configured',
|
|
1031
|
+
message: 'Cannot save the selection timing: no complete adaptiveActivation section (endpoint, model, apiKeyEnv) is configured in this workspace.',
|
|
1032
|
+
nextAction: `Save the '${ADAPTIVE_ACTIVATION_SERVICE_PRESET.id}' service preset first, then choose the timing.`,
|
|
1033
|
+
};
|
|
1034
|
+
}
|
|
1035
|
+
if (hasTiming && payload.timing === 'background' && replaceableIds.length > 0) {
|
|
1036
|
+
return {
|
|
1037
|
+
ok: false,
|
|
1038
|
+
statusCode: 409,
|
|
1039
|
+
error: 'append_only_conflict',
|
|
1040
|
+
message: `Background timing is append-only and cannot be combined with adaptiveActivation.replaceableActivationIds (${replaceableIds.join(', ')}).`,
|
|
1041
|
+
nextAction: 'Remove adaptiveActivation.replaceableActivationIds in .pd/config.yaml to use background timing, or keep the synchronous timing.',
|
|
1042
|
+
};
|
|
1043
|
+
}
|
|
980
1044
|
// Merge — preserve unrelated sections and every other feature entry.
|
|
981
1045
|
const nextFeatures = { ...featuresSection };
|
|
982
1046
|
if (hasEnabled) {
|
|
983
|
-
const existingEntry = Object.hasOwn(nextFeatures,
|
|
984
|
-
? nextFeatures[
|
|
1047
|
+
const existingEntry = Object.hasOwn(nextFeatures, hostFlag)
|
|
1048
|
+
? nextFeatures[hostFlag]
|
|
985
1049
|
: undefined;
|
|
986
1050
|
const category = (isRecord(existingEntry) && Object.hasOwn(existingEntry, 'category') && typeof existingEntry.category === 'string')
|
|
987
1051
|
? existingEntry.category
|
|
988
|
-
: (DEFAULT_FLAG_CATEGORY.get(
|
|
989
|
-
nextFeatures[
|
|
1052
|
+
: (DEFAULT_FLAG_CATEGORY.get(hostFlag) ?? 'quiet');
|
|
1053
|
+
nextFeatures[hostFlag] = { category, enabled: payload.enabled === true, source: 'owner' };
|
|
990
1054
|
}
|
|
991
1055
|
rawConfig.features = nextFeatures;
|
|
992
1056
|
if (hasService) {
|
|
@@ -1002,6 +1066,13 @@ export function updateAdaptiveActivationSettings(workspaceDir, payload) {
|
|
|
1002
1066
|
responseModels: [...ADAPTIVE_ACTIVATION_SERVICE_PRESET.responseModels],
|
|
1003
1067
|
};
|
|
1004
1068
|
}
|
|
1069
|
+
if (hasTiming) {
|
|
1070
|
+
// Merge into whatever section the service write (if any) just produced.
|
|
1071
|
+
const existingSectionRaw = Object.hasOwn(rawConfig, 'adaptiveActivation') && isRecord(rawConfig.adaptiveActivation)
|
|
1072
|
+
? rawConfig.adaptiveActivation
|
|
1073
|
+
: {};
|
|
1074
|
+
rawConfig.adaptiveActivation = { ...existingSectionRaw, timing: payload.timing };
|
|
1075
|
+
}
|
|
1005
1076
|
const validation = validatePdConfig(rawConfig);
|
|
1006
1077
|
if (!validation.ok) {
|
|
1007
1078
|
return {
|
|
@@ -1032,7 +1103,8 @@ export function updateAdaptiveActivationSettings(workspaceDir, payload) {
|
|
|
1032
1103
|
const confirmed = confirmResult.effective.config;
|
|
1033
1104
|
return {
|
|
1034
1105
|
ok: true,
|
|
1035
|
-
|
|
1106
|
+
host,
|
|
1107
|
+
enabled: confirmed.features[hostFlag]?.enabled === true,
|
|
1036
1108
|
serviceConfigured: isConfiguredSection(confirmed.adaptiveActivation),
|
|
1037
1109
|
};
|
|
1038
1110
|
}
|
|
@@ -1089,6 +1161,9 @@ export function updateFeatureFlag(workspaceDir, featureName, enabled) {
|
|
|
1089
1161
|
// mode. The generic toggle must not be able to cross that boundary
|
|
1090
1162
|
// (the dedicated Adaptive entry refuses the same combination).
|
|
1091
1163
|
if (enabled === true && ADAPTIVE_ACTIVATION_FLAG_NAMES.has(featureName)) {
|
|
1164
|
+
if (featureName === ADAPTIVE_ACTIVATION_HOST_FLAGS.workbuddy && rawRead.config.features['host.workbuddy']?.enabled !== true) {
|
|
1165
|
+
return workbuddyIntegrationDisabled();
|
|
1166
|
+
}
|
|
1092
1167
|
const replaceableIds = rawRead.config.adaptiveActivation?.replaceableActivationIds ?? [];
|
|
1093
1168
|
if (replaceableIds.length > 0) {
|
|
1094
1169
|
return {
|
|
@@ -68,6 +68,14 @@ export interface ActivationsResponse {
|
|
|
68
68
|
reason?: string;
|
|
69
69
|
/** Present when status is 'degraded' — next operator action. */
|
|
70
70
|
nextAction?: string;
|
|
71
|
+
/**
|
|
72
|
+
* Stable machine code for the degraded reason (rc-9 companion to `reason`):
|
|
73
|
+
* the Owner-facing UI translates THIS, while `reason` stays the raw
|
|
74
|
+
* operator/forensics detail. Undefined when status is 'ok'.
|
|
75
|
+
*/
|
|
76
|
+
reasonCode?: 'state_db_missing' | 'activation_table_missing' | 'dangling_artifact_references'
|
|
77
|
+
/** Produced by ExaminerEvidenceModel's own catch when the read throws. */
|
|
78
|
+
| 'activation_read_failed';
|
|
71
79
|
/** R-A3/AC-01: route context for the per-activation injection statuses. */
|
|
72
80
|
promptInjectionRoute?: PromptInjectionRouteSummaryWire;
|
|
73
81
|
/**
|
|
@@ -234,7 +234,7 @@ export class ActivationsConsoleModel {
|
|
|
234
234
|
const enforcement = readDegradedEnforcement(this.workspaceDir);
|
|
235
235
|
const stateDbPath = resolveStateDbPath(this.workspaceDir);
|
|
236
236
|
if (!fs.existsSync(stateDbPath)) {
|
|
237
|
-
return { activations: [], status: 'degraded', reason: 'state.db not found — workspace may not be initialized', nextAction: 'Run pd runtime diagnostics to check workspace state', enforcement };
|
|
237
|
+
return { activations: [], status: 'degraded', reason: 'state.db not found — workspace may not be initialized', nextAction: 'Run pd runtime diagnostics to check workspace state', reasonCode: 'state_db_missing', enforcement };
|
|
238
238
|
}
|
|
239
239
|
const conn = new SqliteConnection({ workspaceDir: this.workspaceDir, readonly: true });
|
|
240
240
|
try {
|
|
@@ -246,7 +246,7 @@ export class ActivationsConsoleModel {
|
|
|
246
246
|
}
|
|
247
247
|
catch (err) {
|
|
248
248
|
if (isMissingTableError(err)) {
|
|
249
|
-
return { activations: [], status: 'degraded', reason: 'activation table not found — workspace may not be initialized', nextAction: 'Run pd runtime internalization integrity to check schema', enforcement };
|
|
249
|
+
return { activations: [], status: 'degraded', reason: 'activation table not found — workspace may not be initialized', nextAction: 'Run pd runtime internalization integrity to check schema', reasonCode: 'activation_table_missing', enforcement };
|
|
250
250
|
}
|
|
251
251
|
throw err;
|
|
252
252
|
}
|
|
@@ -497,6 +497,7 @@ export class ActivationsConsoleModel {
|
|
|
497
497
|
status: 'degraded',
|
|
498
498
|
reason: `${danglingArtifactIds.size} activation(s) reference non-existent artifact_id(s): ${Array.from(danglingArtifactIds).join(', ')}`,
|
|
499
499
|
nextAction: 'Run pd runtime internalization integrity to check for orphaned activations',
|
|
500
|
+
reasonCode: 'dangling_artifact_references',
|
|
500
501
|
promptInjectionRoute,
|
|
501
502
|
enforcement,
|
|
502
503
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type AdaptiveInjectionRecord } from '@principles/host-runtime';
|
|
2
|
-
import { type AdaptiveServicePresetId } from '../config/pd-config-store.js';
|
|
2
|
+
import { type AdaptiveActivationHost, type AdaptiveServicePresetId } from '../config/pd-config-store.js';
|
|
3
3
|
export type AdaptiveCandidateEmptyState = 'ok' | 'zero' | 'prompt_disabled' | 'db_missing' | 'read_failed';
|
|
4
4
|
/**
|
|
5
5
|
* Evidence tri-state. `unknown` exists so a failed read can NEVER be reported
|
|
@@ -23,6 +23,21 @@ export interface AdaptiveEvidenceView {
|
|
|
23
23
|
}
|
|
24
24
|
export interface AdaptiveActivationView {
|
|
25
25
|
workspaceDir: string;
|
|
26
|
+
/**
|
|
27
|
+
* PRI-1127: the ONE host this view is scoped to. Every switch, log read and
|
|
28
|
+
* last-turn result below belongs to this host's existing flag — never to a
|
|
29
|
+
* second truth and never to another workspace.
|
|
30
|
+
*/
|
|
31
|
+
host: {
|
|
32
|
+
kind: AdaptiveActivationHost;
|
|
33
|
+
/** Existing workspace flag id, shown so the Owner knows what is toggled. */
|
|
34
|
+
flag: string;
|
|
35
|
+
enabled: boolean;
|
|
36
|
+
serviceConfigured: boolean;
|
|
37
|
+
saved: boolean;
|
|
38
|
+
integrationEnabled?: boolean;
|
|
39
|
+
};
|
|
40
|
+
/** Kept for the original Codex card contract — always Codex's REAL state. */
|
|
26
41
|
codex: {
|
|
27
42
|
/** The existing switch — `host.codex.adaptive_activation`. */
|
|
28
43
|
enabled: boolean;
|
|
@@ -30,6 +45,11 @@ export interface AdaptiveActivationView {
|
|
|
30
45
|
serviceConfigured: boolean;
|
|
31
46
|
/** Enabled AND service configured — what "已保存" means. */
|
|
32
47
|
saved: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* PRI-1196: when the decision runs relative to the first request.
|
|
50
|
+
* Absent in config = `sync` (historical behavior).
|
|
51
|
+
*/
|
|
52
|
+
timing: 'sync' | 'background';
|
|
33
53
|
};
|
|
34
54
|
service: {
|
|
35
55
|
presetId: AdaptiveServicePresetId;
|
|
@@ -49,8 +69,8 @@ export interface AdaptiveActivationView {
|
|
|
49
69
|
*/
|
|
50
70
|
replaceableActivationIds: string[];
|
|
51
71
|
appendOnlyEligible: boolean;
|
|
52
|
-
/** Other hosts sharing the same workspace-scoped service config. */
|
|
53
|
-
otherHostAaEnabled: ('openclaw' | 'workbuddy')[];
|
|
72
|
+
/** Other hosts sharing the same workspace-scoped service config (excluding the selected host). */
|
|
73
|
+
otherHostAaEnabled: ('openclaw' | 'codex' | 'workbuddy')[];
|
|
54
74
|
candidates: {
|
|
55
75
|
/** Candidates the assembly could actually draw from. */
|
|
56
76
|
validCount: number;
|
|
@@ -63,6 +83,23 @@ export interface AdaptiveActivationView {
|
|
|
63
83
|
emptyState: AdaptiveCandidateEmptyState;
|
|
64
84
|
};
|
|
65
85
|
lastRecord: AdaptiveInjectionRecord | null;
|
|
86
|
+
/**
|
|
87
|
+
* PRI-1127: the result fields the page was missing. Derived ONLY from the
|
|
88
|
+
* SAME recorded injection event — no re-derivation, no model-output guess.
|
|
89
|
+
* `runId` is the host's real current-turn identity (WorkBuddy generation_id,
|
|
90
|
+
* Codex turn_id); `appendedActivationId` is the FINAL assembly basis;
|
|
91
|
+
* `independentRequestSent` is whether a scoring request actually left the
|
|
92
|
+
* process this turn. Delivery itself is NEVER claimed by the Console: it is
|
|
93
|
+
* confirmed by independent model-request evidence (engine-level capture).
|
|
94
|
+
*/
|
|
95
|
+
lastRound: {
|
|
96
|
+
runId: string | null;
|
|
97
|
+
appendedActivationId: string | null;
|
|
98
|
+
activationIds: string[];
|
|
99
|
+
independentRequestSent: boolean;
|
|
100
|
+
/** Match keys this record was selected by — workspace + host + same turn. */
|
|
101
|
+
matchedBy: readonly ['workspace', 'host', 'turn'];
|
|
102
|
+
} | null;
|
|
66
103
|
/**
|
|
67
104
|
* Tri-state evidence for the last turn. `lastRecord === null` alone says
|
|
68
105
|
* nothing — always branch on this status, never on the record's absence.
|
|
@@ -73,7 +110,9 @@ export interface AdaptiveActivationView {
|
|
|
73
110
|
export declare function adaptiveActivationStateDir(workspaceDir: string): string;
|
|
74
111
|
export declare class AdaptiveActivationConsoleModel {
|
|
75
112
|
private readonly workspaceDir;
|
|
76
|
-
|
|
113
|
+
/** Scopes EVERY read below: config switch, injection events and last turn. */
|
|
114
|
+
private readonly hostKind;
|
|
115
|
+
constructor(workspaceDir: string, hostKind?: AdaptiveActivationHost);
|
|
77
116
|
private stateDir;
|
|
78
117
|
getView(): Promise<AdaptiveActivationView>;
|
|
79
118
|
}
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
import path from 'node:path';
|
|
18
18
|
import { readAdaptiveInjectionRecords, readPromptActivationCandidates, } from '@principles/host-runtime';
|
|
19
19
|
import { pdProviderCredentials } from '@principles/core/runtime';
|
|
20
|
-
import { loadPdConfig, ADAPTIVE_ACTIVATION_SERVICE_PRESET } from '../config/pd-config-store.js';
|
|
20
|
+
import { loadPdConfig, ADAPTIVE_ACTIVATION_SERVICE_PRESET, ADAPTIVE_ACTIVATION_HOST_FLAGS, } from '../config/pd-config-store.js';
|
|
21
21
|
const UNKNOWN_EVIDENCE = {
|
|
22
22
|
status: 'unknown',
|
|
23
23
|
reason: 'logs_unreadable',
|
|
@@ -63,8 +63,11 @@ export function adaptiveActivationStateDir(workspaceDir) {
|
|
|
63
63
|
}
|
|
64
64
|
export class AdaptiveActivationConsoleModel {
|
|
65
65
|
workspaceDir;
|
|
66
|
-
|
|
66
|
+
/** Scopes EVERY read below: config switch, injection events and last turn. */
|
|
67
|
+
hostKind;
|
|
68
|
+
constructor(workspaceDir, hostKind = 'codex') {
|
|
67
69
|
this.workspaceDir = workspaceDir;
|
|
70
|
+
this.hostKind = hostKind;
|
|
68
71
|
}
|
|
69
72
|
stateDir() {
|
|
70
73
|
return adaptiveActivationStateDir(this.workspaceDir);
|
|
@@ -74,6 +77,8 @@ export class AdaptiveActivationConsoleModel {
|
|
|
74
77
|
const config = loaded.ok ? loaded.effective.config : loaded.defaults.config;
|
|
75
78
|
const section = config.adaptiveActivation;
|
|
76
79
|
const flags = config.features;
|
|
80
|
+
const hostFlag = ADAPTIVE_ACTIVATION_HOST_FLAGS[this.hostKind];
|
|
81
|
+
const hostEnabled = flags[hostFlag]?.enabled === true;
|
|
77
82
|
const codexEnabled = flags['host.codex.adaptive_activation']?.enabled === true;
|
|
78
83
|
const serviceConfigured = section !== undefined
|
|
79
84
|
&& typeof section.endpoint === 'string' && section.endpoint.length > 0
|
|
@@ -101,7 +106,8 @@ export class AdaptiveActivationConsoleModel {
|
|
|
101
106
|
const report = readAdaptiveInjectionRecords({
|
|
102
107
|
stateDir: this.stateDir(),
|
|
103
108
|
workspaceDir: this.workspaceDir,
|
|
104
|
-
|
|
109
|
+
// PRI-1127: NEVER read another host's (or another workspace's) result.
|
|
110
|
+
hostKind: this.hostKind,
|
|
105
111
|
limit: 1,
|
|
106
112
|
});
|
|
107
113
|
lastRecord = report.records[0] ?? null;
|
|
@@ -113,17 +119,33 @@ export class AdaptiveActivationConsoleModel {
|
|
|
113
119
|
// internal filesystem location.
|
|
114
120
|
evidence = { ...UNKNOWN_EVIDENCE };
|
|
115
121
|
}
|
|
122
|
+
// Exclude the SELECTED host: its own flag is the switch on this card, not
|
|
123
|
+
// a competing owner of the shared service section.
|
|
116
124
|
const otherHostAaEnabled = [];
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
125
|
+
const sharedHostChecks = [
|
|
126
|
+
['openclaw', 'host.openclaw.adaptive_activation'],
|
|
127
|
+
['codex', 'host.codex.adaptive_activation'],
|
|
128
|
+
['workbuddy', 'host.workbuddy.adaptive_activation'],
|
|
129
|
+
];
|
|
130
|
+
for (const [kind, flag] of sharedHostChecks) {
|
|
131
|
+
if (kind !== this.hostKind && flags[flag]?.enabled === true)
|
|
132
|
+
otherHostAaEnabled.push(kind);
|
|
133
|
+
}
|
|
121
134
|
return {
|
|
122
135
|
workspaceDir: this.workspaceDir,
|
|
136
|
+
host: {
|
|
137
|
+
kind: this.hostKind,
|
|
138
|
+
flag: hostFlag,
|
|
139
|
+
enabled: hostEnabled,
|
|
140
|
+
serviceConfigured,
|
|
141
|
+
saved: hostEnabled && serviceConfigured,
|
|
142
|
+
...(this.hostKind === 'workbuddy' ? { integrationEnabled: flags['host.workbuddy']?.enabled === true } : {}),
|
|
143
|
+
},
|
|
123
144
|
codex: {
|
|
124
145
|
enabled: codexEnabled,
|
|
125
146
|
serviceConfigured,
|
|
126
147
|
saved: codexEnabled && serviceConfigured,
|
|
148
|
+
timing: section?.timing === 'background' ? 'background' : 'sync',
|
|
127
149
|
},
|
|
128
150
|
service: {
|
|
129
151
|
presetId: ADAPTIVE_ACTIVATION_SERVICE_PRESET.id,
|
|
@@ -145,6 +167,13 @@ export class AdaptiveActivationConsoleModel {
|
|
|
145
167
|
emptyState: classifyEmptyState(candidates),
|
|
146
168
|
},
|
|
147
169
|
lastRecord,
|
|
170
|
+
lastRound: lastRecord === null ? null : {
|
|
171
|
+
runId: lastRecord.runId,
|
|
172
|
+
appendedActivationId: lastRecord.appendedActivationId,
|
|
173
|
+
activationIds: [...lastRecord.activationIds],
|
|
174
|
+
independentRequestSent: lastRecord.scored,
|
|
175
|
+
matchedBy: ['workspace', 'host', 'turn'],
|
|
176
|
+
},
|
|
148
177
|
evidence,
|
|
149
178
|
};
|
|
150
179
|
}
|
|
@@ -34,6 +34,8 @@ export interface ExaminerEvidenceAuditProjection {
|
|
|
34
34
|
status: 'ok' | 'degraded';
|
|
35
35
|
reason?: string;
|
|
36
36
|
nextAction?: string;
|
|
37
|
+
/** Stable machine code for the degraded reason (mirrors coverage.reasonCode). */
|
|
38
|
+
reasonCode?: string;
|
|
37
39
|
/** P1-3: LOADED counts (the audit page window) — never presented as totals. */
|
|
38
40
|
counts: {
|
|
39
41
|
deliveries: number;
|
|
@@ -99,6 +101,8 @@ export interface ExaminerActivationProjection {
|
|
|
99
101
|
status: 'ok' | 'degraded';
|
|
100
102
|
reason?: string;
|
|
101
103
|
nextAction?: string;
|
|
104
|
+
/** Stable machine code for the degraded reason — the UI translates this. */
|
|
105
|
+
reasonCode?: 'state_db_missing' | 'activation_table_missing' | 'dangling_artifact_references' | 'activation_read_failed';
|
|
102
106
|
prompt: ExaminerPromptActivationRow[];
|
|
103
107
|
ruleCode: ExaminerRuleCodeRow[];
|
|
104
108
|
promptInjectionRoute?: PromptInjectionRouteSummaryWire;
|
|
@@ -107,6 +111,8 @@ export interface ExaminerInjectionProjection {
|
|
|
107
111
|
status: 'available' | 'degraded';
|
|
108
112
|
/** Present when no status could be computed at all (fail-loud, rc-9). */
|
|
109
113
|
globalReason?: string;
|
|
114
|
+
/** Machine code for the degraded lane; globalReason stays the forensics detail. */
|
|
115
|
+
reasonCode?: 'injection_status_unavailable';
|
|
110
116
|
statuses: {
|
|
111
117
|
activationId: string;
|
|
112
118
|
status: string;
|
|
@@ -139,8 +145,6 @@ export interface ExaminerPrincipleEvidence {
|
|
|
139
145
|
adherenceRate: number;
|
|
140
146
|
valueScore: number;
|
|
141
147
|
runtimeDeactivated?: boolean;
|
|
142
|
-
/** Asset status ≠ runtime activation — pinned for the UI (SPEC §4.1). */
|
|
143
|
-
ledgerStatusNote: string;
|
|
144
148
|
};
|
|
145
149
|
activation: ExaminerActivationProjection;
|
|
146
150
|
injection: ExaminerInjectionProjection;
|
|
@@ -94,6 +94,7 @@ export class ExaminerEvidenceModel {
|
|
|
94
94
|
status: 'degraded',
|
|
95
95
|
reason: `activation read failed: ${errorMessage(error)}`,
|
|
96
96
|
nextAction: 'check workspace .pd/state.db readability and the activation schema',
|
|
97
|
+
reasonCode: 'activation_read_failed',
|
|
97
98
|
};
|
|
98
99
|
}
|
|
99
100
|
const rows = activations.activations.filter((row) => row.principleId === principleId);
|
|
@@ -101,6 +102,7 @@ export class ExaminerEvidenceModel {
|
|
|
101
102
|
status: activations.status,
|
|
102
103
|
reason: activations.reason,
|
|
103
104
|
nextAction: activations.nextAction,
|
|
105
|
+
reasonCode: activations.reasonCode,
|
|
104
106
|
promptInjectionRoute: activations.promptInjectionRoute,
|
|
105
107
|
prompt: rows
|
|
106
108
|
.filter((row) => row.channel === 'prompt')
|
|
@@ -132,6 +134,7 @@ export class ExaminerEvidenceModel {
|
|
|
132
134
|
const injection = {
|
|
133
135
|
status: injectionReport.globalReason ? 'degraded' : 'available',
|
|
134
136
|
globalReason: injectionReport.globalReason,
|
|
137
|
+
reasonCode: injectionReport.globalReason ? 'injection_status_unavailable' : undefined,
|
|
135
138
|
statuses: targetStatuses.map((row) => ({
|
|
136
139
|
activationId: row.activationId,
|
|
137
140
|
status: row.status,
|
|
@@ -193,6 +196,10 @@ export class ExaminerEvidenceModel {
|
|
|
193
196
|
status: audit.status,
|
|
194
197
|
reason: audit.reason,
|
|
195
198
|
nextAction: audit.nextAction,
|
|
199
|
+
// The audit's own coverage already carries the stable degraded code
|
|
200
|
+
// (state_db_missing / ledger_flag_disabled / evidence_read_failed …);
|
|
201
|
+
// pass it through instead of re-deriving a second truth.
|
|
202
|
+
reasonCode: audit.status === 'degraded' ? audit.coverage?.reasonCode : undefined,
|
|
196
203
|
counts: {
|
|
197
204
|
deliveries: audit.deliveries.length,
|
|
198
205
|
applications: audit.applications.length,
|
|
@@ -263,8 +270,12 @@ export class ExaminerEvidenceModel {
|
|
|
263
270
|
painPreventedCount: detail.painPreventedCount,
|
|
264
271
|
adherenceRate: detail.adherenceRate,
|
|
265
272
|
valueScore: detail.valueScore,
|
|
266
|
-
|
|
267
|
-
|
|
273
|
+
// PRI-956 semantics: runtime revocation is an ACTIVATIONS-table fact.
|
|
274
|
+
// getPrincipleDetail does not populate this field (only the list
|
|
275
|
+
// projection does), so derive it here from the rows already read:
|
|
276
|
+
// rows exist and every one is explicitly deactivated (2026-11-16
|
|
277
|
+
// Owner review P1-2 — the field was previously always undefined).
|
|
278
|
+
runtimeDeactivated: rows.length > 0 && rows.every((row) => row.status === 'deactivated'),
|
|
268
279
|
},
|
|
269
280
|
activation,
|
|
270
281
|
injection,
|
|
@@ -22,10 +22,35 @@
|
|
|
22
22
|
*/
|
|
23
23
|
import { pdProviderCatalog, pdProviderCredentials, probeProviderConnection, } from '@principles/core/runtime';
|
|
24
24
|
import { sendSuccess, sendError, sendNotFound, sendMethodNotAllowed, sendBadRequest, sendJson } from '../utils/response.js';
|
|
25
|
-
import { getConfigSummary, getConfigCatalog, updateAgentBinding, updateDefaultRuntime, checkReadiness, getPrinciplesOutputLanguage, updatePrinciplesOutputLanguage, updateFeatureFlag, updateAdaptiveActivationSettings, createRuntimeProfile, updateRuntimeProfile, deleteRuntimeProfile, } from '../config/pd-config-store.js';
|
|
25
|
+
import { getConfigSummary, getConfigCatalog, updateAgentBinding, updateDefaultRuntime, checkReadiness, getPrinciplesOutputLanguage, updatePrinciplesOutputLanguage, updateFeatureFlag, updateAdaptiveActivationSettings, isAdaptiveActivationHost, createRuntimeProfile, updateRuntimeProfile, deleteRuntimeProfile, } from '../config/pd-config-store.js';
|
|
26
26
|
import { AdaptiveActivationConsoleModel } from '../models/AdaptiveActivationConsoleModel.js';
|
|
27
27
|
// ── Constants ────────────────────────────────────────────────────────────────
|
|
28
28
|
const MAX_BODY_SIZE = 1024 * 64; // 64 KB — generous for config binding updates
|
|
29
|
+
/**
|
|
30
|
+
* PRI-1127: resolve the ONE host this request is scoped to.
|
|
31
|
+
*
|
|
32
|
+
* Review fix: for a PATCH the BODY is the write authority. `updateAdaptive
|
|
33
|
+
* ActivationSettings` defaults to codex when the body has no `host`, so falling
|
|
34
|
+
* back to a query-string host here would make the re-read show a DIFFERENT host
|
|
35
|
+
* than the switch that was just written. GET has no body and uses the query.
|
|
36
|
+
* Unknown values fall back to `codex` for reads; writes are rejected up front
|
|
37
|
+
* by the settings writer itself.
|
|
38
|
+
*/
|
|
39
|
+
function adaptiveHostFor(req, body) {
|
|
40
|
+
if (body !== undefined) {
|
|
41
|
+
let fromBody;
|
|
42
|
+
if (typeof body === 'object' && body !== null && !Array.isArray(body) && Object.hasOwn(body, 'host')) {
|
|
43
|
+
fromBody = body.host;
|
|
44
|
+
}
|
|
45
|
+
return isAdaptiveActivationHost(fromBody) ? fromBody : 'codex';
|
|
46
|
+
}
|
|
47
|
+
let fromQuery = null;
|
|
48
|
+
try {
|
|
49
|
+
fromQuery = new URL(req.url ?? '/', 'http://localhost').searchParams.get('host');
|
|
50
|
+
}
|
|
51
|
+
catch { /* malformed URL: keep the default host */ }
|
|
52
|
+
return isAdaptiveActivationHost(fromQuery) ? fromQuery : 'codex';
|
|
53
|
+
}
|
|
29
54
|
// ── Request Body Reader ──────────────────────────────────────────────────────
|
|
30
55
|
function readBody(req) {
|
|
31
56
|
return new Promise((resolve, reject) => {
|
|
@@ -82,13 +107,14 @@ export async function handleConfigRoute(req, res, ctx) {
|
|
|
82
107
|
sendSuccess(res, { ...summary, ...(errors ? { errors } : {}) });
|
|
83
108
|
return;
|
|
84
109
|
}
|
|
85
|
-
// GET/PATCH /adaptive-activation —
|
|
86
|
-
// Workspace-scoped: the model reads THIS workspace's
|
|
87
|
-
// injection events; the writer touches the
|
|
110
|
+
// GET/PATCH /adaptive-activation — append-only Adaptive Activation entry.
|
|
111
|
+
// Workspace- AND host-scoped (PRI-1127): the model reads THIS workspace's
|
|
112
|
+
// config, candidates and THIS host's injection events; the writer touches the
|
|
113
|
+
// same config path and ONLY the selected host's existing switch. Saving never
|
|
88
114
|
// sends a scoring request (zero network in this handler).
|
|
89
115
|
if (subPath === '/adaptive-activation') {
|
|
90
116
|
if (method === 'GET') {
|
|
91
|
-
const model = new AdaptiveActivationConsoleModel(workspaceDir);
|
|
117
|
+
const model = new AdaptiveActivationConsoleModel(workspaceDir, adaptiveHostFor(req));
|
|
92
118
|
sendSuccess(res, await model.getView());
|
|
93
119
|
return;
|
|
94
120
|
}
|
|
@@ -111,9 +137,9 @@ export async function handleConfigRoute(req, res, ctx) {
|
|
|
111
137
|
sendError(res, result.statusCode, result.error, result.message, result.nextAction ? { nextAction: result.nextAction } : undefined);
|
|
112
138
|
return;
|
|
113
139
|
}
|
|
114
|
-
// Re-read the full view so the UI
|
|
115
|
-
//
|
|
116
|
-
const model = new AdaptiveActivationConsoleModel(workspaceDir);
|
|
140
|
+
// Re-read the full view FOR THE SAME HOST so the UI shows the CONFIRMED
|
|
141
|
+
// persisted state and that host's own last record in one response.
|
|
142
|
+
const model = new AdaptiveActivationConsoleModel(workspaceDir, adaptiveHostFor(req, body));
|
|
117
143
|
sendSuccess(res, await model.getView());
|
|
118
144
|
return;
|
|
119
145
|
}
|
|
@@ -106,6 +106,39 @@ export declare function readStudyJson(studyDir: string, rel: string): Record<str
|
|
|
106
106
|
* studies root (sorted). The route layer treats this list as the allowlist.
|
|
107
107
|
*/
|
|
108
108
|
export declare function listStudyNames(studiesRoot: string): string[];
|
|
109
|
+
/**
|
|
110
|
+
* Owner-facing study-list entry: identity + the few facts the list needs
|
|
111
|
+
* (target principle, mode, creation time, report status, point estimate).
|
|
112
|
+
* Raw facts only — the human "direction" wording is derived in the UI from
|
|
113
|
+
* ONE shared helper, never here (P4: no second conclusion truth).
|
|
114
|
+
*
|
|
115
|
+
* Per-study degradation is honest, never silent: an unreadable manifest or
|
|
116
|
+
* report keeps the row with a problemCode (rc-9) instead of dropping it.
|
|
117
|
+
*/
|
|
118
|
+
export interface StudySummary {
|
|
119
|
+
studyId: string;
|
|
120
|
+
readOnly: boolean;
|
|
121
|
+
targetPrincipleId: string | null;
|
|
122
|
+
experimentMode: string | null;
|
|
123
|
+
createdAt: string | null;
|
|
124
|
+
reportStatus: string | null;
|
|
125
|
+
hasExaminerResult: boolean;
|
|
126
|
+
pointEstimate: {
|
|
127
|
+
status: string;
|
|
128
|
+
value: number | null;
|
|
129
|
+
} | null;
|
|
130
|
+
problemCode?: 'manifest_unreadable' | 'report_unreadable';
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Study list with the metadata the Owner-facing list renders. Writable
|
|
134
|
+
* (console-owned) studies first, then historical names not shadowed by a
|
|
135
|
+
* writable one — same ordering rule the old name-only list had.
|
|
136
|
+
*
|
|
137
|
+
* readOnly mirrors the REAL access boundary (P2-2): a directory under the
|
|
138
|
+
* writable root that fails console-ownership verification is read-only for
|
|
139
|
+
* every write route, so the list must not label it writable.
|
|
140
|
+
*/
|
|
141
|
+
export declare function listStudySummaries(roots: StudyRoots): StudySummary[];
|
|
109
142
|
export type StudyAccess = {
|
|
110
143
|
dir: string;
|
|
111
144
|
studyId: string;
|