create-principles-disciple 1.150.2 → 1.150.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/_release/product-identity.json +1 -1
- package/codex-adapter/dist/ingestion/admission.js +2 -0
- package/codex-adapter/dist/pd-hook.d.ts +7 -5
- package/codex-adapter/dist/pd-hook.js +18 -7
- package/codex-adapter/dist/tool-semantics.js +5 -1
- package/codex-adapter/dist/worker/workspace-worker.js +4 -2
- package/codex-adapter/package.json +1 -1
- package/console/dist/lib/utils.js +16 -1
- package/console/dist/web/assets/app.css +147 -46
- package/console/dist/web/assets/app.js +35 -32
- package/console/package.json +2 -0
- package/core/dist/runtime/activation/adaptive-selection-output.d.ts +35 -0
- package/core/dist/runtime/activation/adaptive-selection-output.d.ts.map +1 -0
- package/core/dist/runtime/activation/adaptive-selection-output.js +38 -0
- package/core/dist/runtime/activation/adaptive-selection-output.js.map +1 -0
- package/core/dist/runtime/activation-compatibility-read-model.d.ts.map +1 -1
- package/core/dist/runtime/activation-compatibility-read-model.js +2 -1
- package/core/dist/runtime/activation-compatibility-read-model.js.map +1 -1
- package/core/dist/runtime/adapter/artificer-l2-adapter.d.ts.map +1 -1
- package/core/dist/runtime/adapter/artificer-l2-adapter.js +89 -27
- package/core/dist/runtime/adapter/artificer-l2-adapter.js.map +1 -1
- package/core/dist/runtime/adapter/context-budget.d.ts +49 -0
- package/core/dist/runtime/adapter/context-budget.d.ts.map +1 -0
- package/core/dist/runtime/adapter/context-budget.js +127 -0
- package/core/dist/runtime/adapter/context-budget.js.map +1 -0
- package/core/dist/runtime/adapter/output-schema-registry.d.ts.map +1 -1
- package/core/dist/runtime/adapter/output-schema-registry.js +7 -0
- package/core/dist/runtime/adapter/output-schema-registry.js.map +1 -1
- package/core/dist/runtime/adapter/pi-ai-runtime-adapter.d.ts +30 -7
- package/core/dist/runtime/adapter/pi-ai-runtime-adapter.d.ts.map +1 -1
- package/core/dist/runtime/adapter/pi-ai-runtime-adapter.js +559 -211
- package/core/dist/runtime/adapter/pi-ai-runtime-adapter.js.map +1 -1
- package/core/dist/runtime/candidate-audit.d.ts.map +1 -1
- package/core/dist/runtime/candidate-audit.js +2 -1
- package/core/dist/runtime/candidate-audit.js.map +1 -1
- package/core/dist/runtime/config/pd-config-effective.d.ts.map +1 -1
- package/core/dist/runtime/config/pd-config-effective.js +2 -0
- package/core/dist/runtime/config/pd-config-effective.js.map +1 -1
- package/core/dist/runtime/config/pd-config-types.d.ts +52 -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 +134 -0
- package/core/dist/runtime/config/pd-config-validate.js.map +1 -1
- package/core/dist/runtime/feature-flags/feature-flag-contract.d.ts.map +1 -1
- package/core/dist/runtime/feature-flags/feature-flag-contract.js +8 -0
- package/core/dist/runtime/feature-flags/feature-flag-contract.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 +24 -0
- package/core/dist/runtime/feature-flags/feature-flag-lifecycle.js.map +1 -1
- package/core/dist/runtime/index.d.ts +2 -0
- package/core/dist/runtime/index.d.ts.map +1 -1
- package/core/dist/runtime/index.js +2 -0
- package/core/dist/runtime/index.js.map +1 -1
- package/core/dist/runtime/internalization/rule-host-input-builder.d.ts +16 -0
- package/core/dist/runtime/internalization/rule-host-input-builder.d.ts.map +1 -1
- package/core/dist/runtime/internalization/rule-host-input-builder.js +18 -0
- package/core/dist/runtime/internalization/rule-host-input-builder.js.map +1 -1
- package/core/dist/runtime/internalization/split-diagnostician-runner.d.ts +8 -0
- package/core/dist/runtime/internalization/split-diagnostician-runner.d.ts.map +1 -1
- package/core/dist/runtime/internalization/split-diagnostician-runner.js +24 -2
- package/core/dist/runtime/internalization/split-diagnostician-runner.js.map +1 -1
- package/core/dist/runtime/internalization/tool-semantic-registry.d.ts +26 -0
- package/core/dist/runtime/internalization/tool-semantic-registry.d.ts.map +1 -1
- package/core/dist/runtime/internalization/tool-semantic-registry.js +55 -5
- package/core/dist/runtime/internalization/tool-semantic-registry.js.map +1 -1
- package/core/dist/runtime/internalization-chain-integrity-read-model.d.ts.map +1 -1
- package/core/dist/runtime/internalization-chain-integrity-read-model.js +2 -2
- package/core/dist/runtime/internalization-chain-integrity-read-model.js.map +1 -1
- package/core/dist/runtime/internalization-integrity-remediation.d.ts.map +1 -1
- package/core/dist/runtime/internalization-integrity-remediation.js +2 -2
- package/core/dist/runtime/internalization-integrity-remediation.js.map +1 -1
- package/core/dist/runtime/operator-health-read-model.d.ts.map +1 -1
- package/core/dist/runtime/operator-health-read-model.js +2 -2
- package/core/dist/runtime/operator-health-read-model.js.map +1 -1
- package/core/dist/runtime/pain-recall-read-model.d.ts.map +1 -1
- package/core/dist/runtime/pain-recall-read-model.js +4 -3
- package/core/dist/runtime/pain-recall-read-model.js.map +1 -1
- package/core/dist/runtime/pruning-read-model.d.ts.map +1 -1
- package/core/dist/runtime/pruning-read-model.js +3 -2
- package/core/dist/runtime/pruning-read-model.js.map +1 -1
- package/core/dist/runtime/risk/risk-calculator-policy.d.ts +12 -2
- package/core/dist/runtime/risk/risk-calculator-policy.d.ts.map +1 -1
- package/core/dist/runtime/risk/risk-calculator-policy.js +33 -22
- package/core/dist/runtime/risk/risk-calculator-policy.js.map +1 -1
- package/core/dist/runtime/schema-conformance-read-model.js +2 -2
- package/core/dist/runtime/schema-conformance-read-model.js.map +1 -1
- package/core/dist/runtime/store/sqlite-connection.d.ts +0 -5
- package/core/dist/runtime/store/sqlite-connection.d.ts.map +1 -1
- package/core/dist/runtime/store/sqlite-connection.js +4 -12
- package/core/dist/runtime/store/sqlite-connection.js.map +1 -1
- package/core/dist/runtime/store/storage-paths.d.ts +17 -0
- package/core/dist/runtime/store/storage-paths.d.ts.map +1 -0
- package/core/dist/runtime/store/storage-paths.js +52 -0
- package/core/dist/runtime/store/storage-paths.js.map +1 -0
- package/core/dist/runtime/trajectory-retention.d.ts +257 -0
- package/core/dist/runtime/trajectory-retention.d.ts.map +1 -0
- package/core/dist/runtime/trajectory-retention.js +598 -0
- package/core/dist/runtime/trajectory-retention.js.map +1 -0
- 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 +5 -0
- package/core/dist/telemetry-event.js.map +1 -1
- package/core/dist/trajectory-store.d.ts +9 -9
- package/core/dist/trajectory-store.d.ts.map +1 -1
- package/core/dist/trajectory-store.js +9 -12
- package/core/dist/trajectory-store.js.map +1 -1
- package/core/package.json +1 -1
- package/dist/installers/codex-host-installer.d.ts.map +1 -1
- package/dist/installers/codex-host-installer.js +92 -5
- package/dist/installers/codex-host-installer.js.map +1 -1
- package/dist/installers/mcp-binding-shape-mirror.d.ts +27 -0
- package/dist/installers/mcp-binding-shape-mirror.d.ts.map +1 -0
- package/dist/installers/mcp-binding-shape-mirror.js +105 -0
- package/dist/installers/mcp-binding-shape-mirror.js.map +1 -0
- package/dist/skill-catalog.d.ts +35 -0
- package/dist/skill-catalog.d.ts.map +1 -0
- package/dist/skill-catalog.js +85 -0
- package/dist/skill-catalog.js.map +1 -0
- package/dist/skill-delivery-parity.d.ts +22 -0
- package/dist/skill-delivery-parity.d.ts.map +1 -0
- package/dist/skill-delivery-parity.js +31 -0
- package/dist/skill-delivery-parity.js.map +1 -0
- package/host-runtime/dist/active-principle-prompt.d.ts +8 -0
- package/host-runtime/dist/active-principle-prompt.js +15 -5
- package/host-runtime/dist/adaptive-decision-protocol.d.ts +142 -0
- package/host-runtime/dist/adaptive-decision-protocol.js +190 -0
- package/host-runtime/dist/adaptive-priority-provider.d.ts +37 -13
- package/host-runtime/dist/adaptive-priority-provider.js +65 -62
- package/host-runtime/dist/adaptive-selection.d.ts +67 -62
- package/host-runtime/dist/adaptive-selection.js +218 -301
- package/host-runtime/dist/adaptive-skip-decision.d.ts +26 -14
- package/host-runtime/dist/adaptive-skip-decision.js +33 -29
- package/host-runtime/dist/codex-rule-context-provider.js +4 -1
- package/host-runtime/dist/governance-observation-store.d.ts +40 -1
- package/host-runtime/dist/governance-observation-store.js +188 -9
- package/host-runtime/dist/governance-signal-admission.d.ts +19 -3
- package/host-runtime/dist/governance-signal-admission.js +12 -4
- package/host-runtime/dist/host-tool-declaration.d.ts +18 -2
- package/host-runtime/dist/host-tool-declaration.js +67 -11
- package/host-runtime/dist/host-tool-semantic-resolver.d.ts +7 -0
- package/host-runtime/dist/host-tool-semantic-resolver.js +22 -2
- package/host-runtime/dist/index.d.ts +3 -0
- package/host-runtime/dist/index.js +14 -0
- package/host-runtime/dist/production-rulehost-gate.js +36 -4
- package/host-runtime/dist/trajectory-retention.d.ts +147 -0
- package/host-runtime/dist/trajectory-retention.js +907 -0
- package/host-runtime/package.json +1 -1
- package/install-layout/dist/index.d.ts +9 -2
- package/install-layout/dist/index.js +26 -9
- package/install-layout/dist/mcp-binding-contract.d.ts +91 -0
- package/install-layout/dist/mcp-binding-contract.js +230 -0
- package/install-layout/package.json +1 -1
- package/package.json +4 -4
- package/pd-cli/dist/commands/build-trajectory-evidence.d.ts.map +1 -1
- package/pd-cli/dist/commands/build-trajectory-evidence.js +17 -11
- package/pd-cli/dist/commands/build-trajectory-evidence.js.map +1 -1
- package/pd-cli/dist/commands/codex-reconcile.d.ts +7 -0
- package/pd-cli/dist/commands/codex-reconcile.d.ts.map +1 -1
- package/pd-cli/dist/commands/codex-reconcile.js +11 -2
- package/pd-cli/dist/commands/codex-reconcile.js.map +1 -1
- package/pd-cli/dist/commands/codex-worker.d.ts.map +1 -1
- package/pd-cli/dist/commands/codex-worker.js +35 -0
- package/pd-cli/dist/commands/codex-worker.js.map +1 -1
- package/pd-cli/dist/commands/command-helpers.d.ts +1 -1
- package/pd-cli/dist/commands/command-helpers.js +1 -1
- package/pd-cli/dist/commands/errors-list.d.ts +1 -1
- package/pd-cli/dist/commands/errors-list.js +1 -1
- package/pd-cli/dist/commands/health-mcp.d.ts +23 -1
- package/pd-cli/dist/commands/health-mcp.d.ts.map +1 -1
- package/pd-cli/dist/commands/health-mcp.js +81 -22
- package/pd-cli/dist/commands/health-mcp.js.map +1 -1
- package/pd-cli/dist/commands/health.d.ts +1 -1
- package/pd-cli/dist/commands/health.d.ts.map +1 -1
- package/pd-cli/dist/commands/health.js +12 -5
- package/pd-cli/dist/commands/health.js.map +1 -1
- package/pd-cli/dist/commands/principles-stats.d.ts +1 -1
- package/pd-cli/dist/commands/principles-stats.js +1 -1
- package/pd-cli/dist/commands/trajectory-retention.d.ts +23 -0
- package/pd-cli/dist/commands/trajectory-retention.d.ts.map +1 -0
- package/pd-cli/dist/commands/trajectory-retention.js +159 -0
- package/pd-cli/dist/commands/trajectory-retention.js.map +1 -0
- package/pd-cli/dist/commands/workbuddy-setup.d.ts +69 -0
- package/pd-cli/dist/commands/workbuddy-setup.d.ts.map +1 -0
- package/pd-cli/dist/commands/workbuddy-setup.js +379 -0
- package/pd-cli/dist/commands/workbuddy-setup.js.map +1 -0
- package/pd-cli/dist/commands/workbuddy-worker.d.ts.map +1 -1
- package/pd-cli/dist/commands/workbuddy-worker.js +42 -6
- package/pd-cli/dist/commands/workbuddy-worker.js.map +1 -1
- package/pd-cli/dist/index.d.ts +1 -7
- package/pd-cli/dist/index.d.ts.map +1 -1
- package/pd-cli/dist/index.js +15 -1201
- package/pd-cli/dist/index.js.map +1 -1
- package/pd-cli/dist/program.d.ts +17 -0
- package/pd-cli/dist/program.d.ts.map +1 -0
- package/pd-cli/dist/program.js +1263 -0
- package/pd-cli/dist/program.js.map +1 -0
- package/pd-cli/dist/services/delivery-surfaces.d.ts.map +1 -1
- package/pd-cli/dist/services/delivery-surfaces.js +7 -5
- package/pd-cli/dist/services/delivery-surfaces.js.map +1 -1
- package/pd-cli/dist/services/version-report.d.ts.map +1 -1
- package/pd-cli/dist/services/version-report.js +30 -4
- package/pd-cli/dist/services/version-report.js.map +1 -1
- package/pd-cli/package.json +1 -1
- package/pd-mcp-server/dist/version.d.ts +1 -1
- package/pd-mcp-server/dist/version.js +1 -1
- package/pd-mcp-server/package.json +3 -1
- package/plugin/dist/bundle.js +477 -471
- package/plugin/dist/constants/tools.d.ts +8 -1
- package/plugin/dist/core/trajectory-retention-trigger.d.ts +13 -0
- package/plugin/dist/core/trajectory.d.ts +14 -0
- package/plugin/dist/hooks/gate-block-helper.d.ts +17 -0
- package/plugin/dist/hooks/gate.d.ts +7 -2
- package/plugin/dist/host-runtime/openclaw-host-runtime.d.ts +1 -0
- package/plugin/dist/index.d.ts +5 -0
- package/plugin/dist/openclaw.plugin.json +1 -1
- package/plugin/dist/rulehost-evidence.js +29 -23
- package/plugin/dist/templates/langs/en/skills/pd-cli-operator/SKILL.md +16 -5
- package/plugin/dist/templates/langs/en/skills/pd-control/SKILL.md +7 -6
- package/plugin/dist/templates/langs/en/skills/pd-pain-signal/SKILL.md +141 -28
- package/plugin/dist/templates/langs/en/skills/pd-review/SKILL.md +15 -1
- package/plugin/dist/templates/langs/zh/skills/pd-cli-operator/SKILL.md +16 -5
- package/plugin/dist/templates/langs/zh/skills/pd-control/SKILL.md +7 -6
- package/plugin/dist/templates/langs/zh/skills/pd-pain-signal/SKILL.md +142 -29
- package/plugin/dist/templates/langs/zh/skills/pd-review/SKILL.md +15 -1
- package/plugin/openclaw.plugin.json +1 -1
- package/plugin/package.json +1 -1
- package/plugin/templates/langs/en/skills/pd-cli-operator/SKILL.md +16 -5
- package/plugin/templates/langs/en/skills/pd-control/SKILL.md +7 -6
- package/plugin/templates/langs/en/skills/pd-pain-signal/SKILL.md +141 -28
- package/plugin/templates/langs/en/skills/pd-review/SKILL.md +15 -1
- package/plugin/templates/langs/zh/skills/pd-cli-operator/SKILL.md +16 -5
- package/plugin/templates/langs/zh/skills/pd-control/SKILL.md +7 -6
- package/plugin/templates/langs/zh/skills/pd-pain-signal/SKILL.md +142 -29
- package/plugin/templates/langs/zh/skills/pd-review/SKILL.md +15 -1
- package/release-manager/dist/installers/codex-host-installer.js +92 -5
- package/release-manager/dist/installers/mcp-binding-shape-mirror.js +105 -0
- package/release-manager/package.json +1 -1
- package/workbuddy-adapter/dist/codec/input-decoder.d.ts +10 -0
- package/workbuddy-adapter/dist/codec/input-decoder.js +62 -5
- package/workbuddy-adapter/dist/host-adapter.js +1 -0
- package/workbuddy-adapter/dist/index.d.ts +1 -0
- package/workbuddy-adapter/dist/index.js +1 -0
- package/workbuddy-adapter/dist/ingestion/catch-up.d.ts +25 -0
- package/workbuddy-adapter/dist/ingestion/catch-up.js +161 -0
- package/workbuddy-adapter/dist/ingestion/encode-cwd.d.ts +6 -0
- package/workbuddy-adapter/dist/ingestion/encode-cwd.js +39 -0
- package/workbuddy-adapter/dist/ingestion/index.d.ts +13 -0
- package/workbuddy-adapter/dist/ingestion/index.js +13 -0
- package/workbuddy-adapter/dist/ingestion/ingestion.d.ts +46 -0
- package/workbuddy-adapter/dist/ingestion/ingestion.js +135 -0
- package/workbuddy-adapter/dist/ingestion/transcript-decoder.d.ts +70 -0
- package/workbuddy-adapter/dist/ingestion/transcript-decoder.js +554 -0
- package/workbuddy-adapter/dist/ingestion/transcript-path.d.ts +39 -0
- package/workbuddy-adapter/dist/ingestion/transcript-path.js +117 -0
- package/workbuddy-adapter/dist/ingestion/transcript-source.d.ts +15 -0
- package/workbuddy-adapter/dist/ingestion/transcript-source.js +152 -0
- package/workbuddy-adapter/dist/pd-hook.d.ts +8 -0
- package/workbuddy-adapter/dist/pd-hook.js +59 -2
- package/workbuddy-adapter/dist/worker/workspace-worker.d.ts +9 -0
- package/workbuddy-adapter/dist/worker/workspace-worker.js +46 -17
- package/workbuddy-adapter/package.json +1 -1
- package/workbuddy-adapter/plugin/hooks/hooks.json +11 -0
- package/workbuddy-adapter/plugin/skills/pd-cli-operator/SKILL.md +57 -19
- package/workbuddy-adapter/plugin/skills/pd-control/SKILL.md +21 -9
- package/workbuddy-adapter/plugin/skills/pd-pain-signal/SKILL.md +72 -61
- package/workbuddy-adapter/plugin/skills/pd-review/SKILL.md +27 -12
|
@@ -68,6 +68,7 @@ export interface ActivePrinciplePromptResult {
|
|
|
68
68
|
injectedExpectationsOverflow?: number;
|
|
69
69
|
}
|
|
70
70
|
export interface AdaptivePackingReport {
|
|
71
|
+
source?: 'native_gap';
|
|
71
72
|
status: 'target_present' | 'prioritized' | 'unavailable';
|
|
72
73
|
reason?: string;
|
|
73
74
|
targetActivationId: string;
|
|
@@ -223,6 +224,13 @@ export declare function buildActivePrinciplePromptContext(input: {
|
|
|
223
224
|
artifactId: string;
|
|
224
225
|
activationId: string;
|
|
225
226
|
};
|
|
227
|
+
/** Select only from principles absent from the Native prompt for this invocation. */
|
|
228
|
+
selectNativeGap?: (candidates: readonly ActivatedPrinciple[]) => Promise<{
|
|
229
|
+
artifactId: string;
|
|
230
|
+
activationId: string;
|
|
231
|
+
signal?: AbortSignal;
|
|
232
|
+
deadlineAt?: number;
|
|
233
|
+
} | undefined>;
|
|
226
234
|
/**
|
|
227
235
|
* PRI-1140 (Owner supplementary condition): additive-only adaptive packing.
|
|
228
236
|
* Only meaningful together with `adaptivePriority`. When true, the
|
|
@@ -345,11 +345,20 @@ export async function buildActivePrinciplePromptContext(input) {
|
|
|
345
345
|
};
|
|
346
346
|
const nativePacking = pack(nativeScanOrder);
|
|
347
347
|
const nativeResult = makeResult(nativePacking, principles);
|
|
348
|
-
const
|
|
348
|
+
const gapPriority = input.adaptivePriority === undefined && input.selectNativeGap && warnings.length === 0
|
|
349
|
+
? await input.selectNativeGap(principles.filter((principle) => !nativeResult.principleIds.includes(principle.principleId)))
|
|
350
|
+
: undefined;
|
|
351
|
+
const priority = input.adaptivePriority ?? gapPriority;
|
|
349
352
|
if (priority === undefined)
|
|
350
353
|
return nativeResult;
|
|
354
|
+
const signal = gapPriority?.signal ?? input.signal ?? new AbortController().signal;
|
|
355
|
+
const deadlineAt = gapPriority?.deadlineAt ?? input.deadlineAt;
|
|
356
|
+
const additiveOnly = gapPriority !== undefined || input.additiveOnly === true;
|
|
357
|
+
if (gapPriority && (signal.aborted || (deadlineAt !== undefined && Date.now() >= deadlineAt)))
|
|
358
|
+
return nativeResult;
|
|
351
359
|
const report = (status, reason, displacedActivationIds = []) => ({
|
|
352
360
|
status,
|
|
361
|
+
...(gapPriority ? { source: 'native_gap' } : {}),
|
|
353
362
|
...(reason ? { reason } : {}),
|
|
354
363
|
targetActivationId: typeof priority.activationId === 'string' ? priority.activationId : '',
|
|
355
364
|
targetArtifactId: typeof priority.artifactId === 'string' ? priority.artifactId : '',
|
|
@@ -360,7 +369,7 @@ export async function buildActivePrinciplePromptContext(input) {
|
|
|
360
369
|
const [nativeTarget] = nativeTargetMatches;
|
|
361
370
|
const baselineHasTarget = nativePacking.included.some((principle) => principle.artifactId === priority.artifactId && principle.activationId === priority.activationId);
|
|
362
371
|
const withoutTarget = (reason) => {
|
|
363
|
-
if (nativeTargetMatches.length !== 1 || !nativeTarget)
|
|
372
|
+
if (gapPriority || nativeTargetMatches.length !== 1 || !nativeTarget)
|
|
364
373
|
return { ...nativeResult, adaptivePacking: report('unavailable', reason) };
|
|
365
374
|
const targetPrincipleId = nativeTarget.principleId;
|
|
366
375
|
const safePrinciples = principles.filter((principle) => principle.principleId !== targetPrincipleId);
|
|
@@ -402,12 +411,11 @@ export async function buildActivePrinciplePromptContext(input) {
|
|
|
402
411
|
|| authorizedTarget.artifactContentSha256 !== nativeTarget.artifactContentSha256) {
|
|
403
412
|
return withoutTarget('target_changed');
|
|
404
413
|
}
|
|
405
|
-
const signal = input.signal ?? new AbortController().signal;
|
|
406
414
|
const targetRendered = renderPrinciplesToDirectives([nativeTarget], new Set([nativeTarget.principleId]), { escapeFn: escapeXml });
|
|
407
415
|
const targetBody = targetRendered.slice(targetRendered.indexOf('<directive '), targetRendered.indexOf('</directive>') + '</directive>'.length);
|
|
408
416
|
const prepared = (status, displaced = []) => ({
|
|
409
417
|
...report(status, undefined, displaced), targetSnapshot: authorizedTarget, targetBody,
|
|
410
|
-
nativeBaseline: nativeResult, ...(
|
|
418
|
+
nativeBaseline: nativeResult, ...(deadlineAt !== undefined ? { deadlineAt } : {}),
|
|
411
419
|
});
|
|
412
420
|
if (baselineHasTarget) {
|
|
413
421
|
const stillValid = await revalidateAdaptivePrinciple(input.workspaceDir, authorizedTarget, signal);
|
|
@@ -434,7 +442,7 @@ export async function buildActivePrinciplePromptContext(input) {
|
|
|
434
442
|
// native baseline already assembled. Decided BEFORE the revalidation read so
|
|
435
443
|
// a refused placement costs no further I/O; the would-be displacement is the
|
|
436
444
|
// recorded reason (bounded like the other diagnostic id lists).
|
|
437
|
-
if (
|
|
445
|
+
if (additiveOnly && displacedActivationIds.length > 0) {
|
|
438
446
|
return {
|
|
439
447
|
...nativeResult,
|
|
440
448
|
adaptivePacking: report('unavailable', 'would_displace_native_assembly', displacedActivationIds.slice(0, MAX_SHARED_DIAGNOSTIC_IDS)),
|
|
@@ -443,6 +451,8 @@ export async function buildActivePrinciplePromptContext(input) {
|
|
|
443
451
|
const stillValid = await revalidateAdaptivePrinciple(input.workspaceDir, authorizedTarget, signal);
|
|
444
452
|
if (!stillValid)
|
|
445
453
|
return { ...nativeResult, adaptivePacking: report('unavailable', 'target_changed') };
|
|
454
|
+
if (gapPriority && (signal.aborted || (deadlineAt !== undefined && Date.now() >= deadlineAt)))
|
|
455
|
+
return nativeResult;
|
|
446
456
|
const result = makeResult(prioritizedPacking, principles, prepared('prioritized', displacedActivationIds));
|
|
447
457
|
// Adaptive assembly is deliberately limited to the existing renderer's Native budget cap.
|
|
448
458
|
return result;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PRI-1182 — Adaptive Activation: the real Decisions scoring protocol.
|
|
3
|
+
*
|
|
4
|
+
* Extracted from the already-verified lab implementation
|
|
5
|
+
* (`scripts/dev/adaptive-selector-lab/diagnostic.mjs`): one POST with
|
|
6
|
+
* `{model, state, questions, provider}`, one `{model, answers}` response.
|
|
7
|
+
*
|
|
8
|
+
* The difference from the lab experiment is the QUESTION SET: the lab asked
|
|
9
|
+
* four task-level questions, while production asks one independent
|
|
10
|
+
* applicability condition per candidate plus one "insufficient context"
|
|
11
|
+
* condition. Each answer is an independent `noul` score in [0, 1] — not a
|
|
12
|
+
* distribution — so PD adjudicates locally instead of trusting the model to
|
|
13
|
+
* emit a decision.
|
|
14
|
+
*
|
|
15
|
+
* Everything here is pure: no I/O, no clock, no transport. The caller owns
|
|
16
|
+
* scheduling, cancellation and diagnostics.
|
|
17
|
+
*/
|
|
18
|
+
export declare const ADAPTIVE_DECISION_INSUFFICIENT_QUESTION = "insufficient_context";
|
|
19
|
+
/**
|
|
20
|
+
* PRESET evaluation criteria for this acceptance batch (v1-20261111).
|
|
21
|
+
*
|
|
22
|
+
* These numbers are a deliberate preset, NOT a value derived from the old
|
|
23
|
+
* GLM task-level samples: the old batch scored four task-level questions and
|
|
24
|
+
* is not the same question set. Those samples are used ONLY to replay the
|
|
25
|
+
* adjudicator against already-recorded numbers:
|
|
26
|
+
* replay-02 .9594 .9565 .0708 insufficient .1962 → uncertain (lead below margin)
|
|
27
|
+
* replay-03 .0496 .9958 .2068 insufficient .1375 → selected
|
|
28
|
+
* replay-04 .0624 .0340 .9888 insufficient .2668 → selected
|
|
29
|
+
*
|
|
30
|
+
* Do NOT tune these per failing turn, and do not tune them while a real
|
|
31
|
+
* batch is running: changing them is a product decision that requires a new
|
|
32
|
+
* version string and a new frozen batch.
|
|
33
|
+
*/
|
|
34
|
+
export declare const ADAPTIVE_DECISION_CRITERIA: {
|
|
35
|
+
readonly version: 'v1-20261111';
|
|
36
|
+
/** A candidate must reach this independent score to be eligible. */
|
|
37
|
+
readonly selectThreshold: 0.7;
|
|
38
|
+
/** The winner must lead the runner-up by this much, or the turn is ambiguous. */
|
|
39
|
+
readonly leadMargin: 0.25;
|
|
40
|
+
/** Above this "information is insufficient" score, PD refuses to select. */
|
|
41
|
+
readonly insufficientThreshold: 0.6;
|
|
42
|
+
};
|
|
43
|
+
export interface DecisionQuestion {
|
|
44
|
+
readonly type: 'noul';
|
|
45
|
+
readonly instructions: string;
|
|
46
|
+
}
|
|
47
|
+
export type DecisionQuestions = Record<string, DecisionQuestion>;
|
|
48
|
+
export interface DecisionRequestEnvelope {
|
|
49
|
+
readonly model: string;
|
|
50
|
+
readonly state: string;
|
|
51
|
+
readonly questions: DecisionQuestions;
|
|
52
|
+
readonly provider?: {
|
|
53
|
+
readonly only: readonly string[];
|
|
54
|
+
readonly allow_fallbacks: false;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
export type DecisionProtocolError = 'DECISION_MODEL_MISMATCH' | 'DECISION_PROVIDER_MISMATCH' | 'DECISION_OUTPUT_INVALID' | 'DECISION_QUESTION_MISMATCH' | 'DECISION_SCORE_INVALID' | 'INPUT_REFUSED';
|
|
58
|
+
export interface BuildDecisionRequestInput {
|
|
59
|
+
readonly model: string;
|
|
60
|
+
readonly provider?: string;
|
|
61
|
+
readonly currentInstruction: string;
|
|
62
|
+
readonly priorMessages: readonly {
|
|
63
|
+
readonly text: string;
|
|
64
|
+
readonly source: string;
|
|
65
|
+
readonly index: number;
|
|
66
|
+
}[];
|
|
67
|
+
readonly candidates: readonly {
|
|
68
|
+
readonly ref: string;
|
|
69
|
+
readonly text: string;
|
|
70
|
+
readonly digest: string;
|
|
71
|
+
}[];
|
|
72
|
+
/** Bounded by the caller; a request larger than this is refused locally. */
|
|
73
|
+
readonly maxPayloadChars: number;
|
|
74
|
+
}
|
|
75
|
+
export type BuildDecisionRequestResult = {
|
|
76
|
+
readonly ok: true;
|
|
77
|
+
readonly body: DecisionRequestEnvelope;
|
|
78
|
+
readonly questionIds: readonly string[];
|
|
79
|
+
} | {
|
|
80
|
+
readonly ok: false;
|
|
81
|
+
readonly reason: DecisionProtocolError;
|
|
82
|
+
};
|
|
83
|
+
export declare function candidateQuestionId(ref: string): string;
|
|
84
|
+
/**
|
|
85
|
+
* One question per candidate (its applicability condition) plus one
|
|
86
|
+
* "insufficient context" question. Instructions refer to the snapshot by ref;
|
|
87
|
+
* the candidate text itself travels once, in `state`.
|
|
88
|
+
*/
|
|
89
|
+
export declare function buildDecisionQuestions(candidates: readonly {
|
|
90
|
+
readonly ref: string;
|
|
91
|
+
readonly text: string;
|
|
92
|
+
}[]): DecisionQuestions;
|
|
93
|
+
export declare function buildDecisionRequest(input: BuildDecisionRequestInput): BuildDecisionRequestResult;
|
|
94
|
+
/**
|
|
95
|
+
* Model identity is exact against an explicit allowlist when one is frozen
|
|
96
|
+
* (the acceptance batch does this). Otherwise one bounded alias class is
|
|
97
|
+
* accepted: a `:free` tag may be absent, and a dated canonical slug
|
|
98
|
+
* (`<base>-YYYYMMDD`) is accepted — the two aliases the lab verified.
|
|
99
|
+
*
|
|
100
|
+
* An unregistered DATE is never accepted through the allowlist path: the
|
|
101
|
+
* observed id must be one of the frozen strings, so a same-prefix slug with a
|
|
102
|
+
* different date is a mismatch.
|
|
103
|
+
*/
|
|
104
|
+
export declare function isDecisionModelIdentity(configured: string, observed: string, allowedResponseModels?: readonly string[]): boolean;
|
|
105
|
+
export type DecisionValidationResult = {
|
|
106
|
+
readonly ok: true;
|
|
107
|
+
readonly scores: Readonly<Record<string, number>>;
|
|
108
|
+
} | {
|
|
109
|
+
readonly ok: false;
|
|
110
|
+
readonly reason: DecisionProtocolError;
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* Validates model identity, provider identity (when configured), completeness
|
|
114
|
+
* of the exact question set, and every score range. Any missing, extra or
|
|
115
|
+
* malformed answer is a rejected turn — never a partial score table.
|
|
116
|
+
*/
|
|
117
|
+
export declare function validateDecisionResponse(value: unknown, expected: {
|
|
118
|
+
readonly model: string;
|
|
119
|
+
readonly questionIds: readonly string[];
|
|
120
|
+
readonly provider?: string;
|
|
121
|
+
/** Frozen exact response-model allowlist. Present = exact membership only. */
|
|
122
|
+
readonly allowedResponseModels?: readonly string[];
|
|
123
|
+
}): DecisionValidationResult;
|
|
124
|
+
export type DecisionOutcome = {
|
|
125
|
+
readonly status: 'selected';
|
|
126
|
+
readonly ref: string;
|
|
127
|
+
readonly reason: 'selected';
|
|
128
|
+
readonly scores: Readonly<Record<string, number>>;
|
|
129
|
+
} | {
|
|
130
|
+
readonly status: 'none_applicable' | 'uncertain';
|
|
131
|
+
readonly ref: null;
|
|
132
|
+
readonly reason: 'below_selection_threshold' | 'lead_below_margin' | 'information_insufficient';
|
|
133
|
+
readonly scores: Readonly<Record<string, number>>;
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* Local adjudication of the INDEPENDENT condition scores. Order matters:
|
|
137
|
+
* insufficient information first (it invalidates any candidate ranking), then
|
|
138
|
+
* the eligibility threshold, then the lead margin.
|
|
139
|
+
*/
|
|
140
|
+
export declare function adjudicateDecision(scores: Readonly<Record<string, number>>, candidates: readonly {
|
|
141
|
+
readonly ref: string;
|
|
142
|
+
}[], criteria?: typeof ADAPTIVE_DECISION_CRITERIA): DecisionOutcome;
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PRI-1182 — Adaptive Activation: the real Decisions scoring protocol.
|
|
3
|
+
*
|
|
4
|
+
* Extracted from the already-verified lab implementation
|
|
5
|
+
* (`scripts/dev/adaptive-selector-lab/diagnostic.mjs`): one POST with
|
|
6
|
+
* `{model, state, questions, provider}`, one `{model, answers}` response.
|
|
7
|
+
*
|
|
8
|
+
* The difference from the lab experiment is the QUESTION SET: the lab asked
|
|
9
|
+
* four task-level questions, while production asks one independent
|
|
10
|
+
* applicability condition per candidate plus one "insufficient context"
|
|
11
|
+
* condition. Each answer is an independent `noul` score in [0, 1] — not a
|
|
12
|
+
* distribution — so PD adjudicates locally instead of trusting the model to
|
|
13
|
+
* emit a decision.
|
|
14
|
+
*
|
|
15
|
+
* Everything here is pure: no I/O, no clock, no transport. The caller owns
|
|
16
|
+
* scheduling, cancellation and diagnostics.
|
|
17
|
+
*/
|
|
18
|
+
export const ADAPTIVE_DECISION_INSUFFICIENT_QUESTION = 'insufficient_context';
|
|
19
|
+
/**
|
|
20
|
+
* PRESET evaluation criteria for this acceptance batch (v1-20261111).
|
|
21
|
+
*
|
|
22
|
+
* These numbers are a deliberate preset, NOT a value derived from the old
|
|
23
|
+
* GLM task-level samples: the old batch scored four task-level questions and
|
|
24
|
+
* is not the same question set. Those samples are used ONLY to replay the
|
|
25
|
+
* adjudicator against already-recorded numbers:
|
|
26
|
+
* replay-02 .9594 .9565 .0708 insufficient .1962 → uncertain (lead below margin)
|
|
27
|
+
* replay-03 .0496 .9958 .2068 insufficient .1375 → selected
|
|
28
|
+
* replay-04 .0624 .0340 .9888 insufficient .2668 → selected
|
|
29
|
+
*
|
|
30
|
+
* Do NOT tune these per failing turn, and do not tune them while a real
|
|
31
|
+
* batch is running: changing them is a product decision that requires a new
|
|
32
|
+
* version string and a new frozen batch.
|
|
33
|
+
*/
|
|
34
|
+
export const ADAPTIVE_DECISION_CRITERIA = {
|
|
35
|
+
version: 'v1-20261111',
|
|
36
|
+
/** A candidate must reach this independent score to be eligible. */
|
|
37
|
+
selectThreshold: 0.7,
|
|
38
|
+
/** The winner must lead the runner-up by this much, or the turn is ambiguous. */
|
|
39
|
+
leadMargin: 0.25,
|
|
40
|
+
/** Above this "information is insufficient" score, PD refuses to select. */
|
|
41
|
+
insufficientThreshold: 0.6,
|
|
42
|
+
};
|
|
43
|
+
export function candidateQuestionId(ref) {
|
|
44
|
+
return `candidate_${ref}`;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* One question per candidate (its applicability condition) plus one
|
|
48
|
+
* "insufficient context" question. Instructions refer to the snapshot by ref;
|
|
49
|
+
* the candidate text itself travels once, in `state`.
|
|
50
|
+
*/
|
|
51
|
+
export function buildDecisionQuestions(candidates) {
|
|
52
|
+
const questions = {};
|
|
53
|
+
for (const candidate of candidates) {
|
|
54
|
+
questions[candidateQuestionId(candidate.ref)] = {
|
|
55
|
+
type: 'noul',
|
|
56
|
+
instructions: `候选 ${candidate.ref} 的适用性:仅当当前输入明确要求交付、实现、修复、审查或验证,`
|
|
57
|
+
+ `且补入这条尚未装配的候选(见 state.candidates.${candidate.ref})能改善下一步的具体行动时,概率接近 1;仅仅主题相关不够。`
|
|
58
|
+
+ '仅礼貌、闲聊、元问题或与当前任务无关时,概率接近 0。',
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
questions[ADAPTIVE_DECISION_INSUFFICIENT_QUESTION] = {
|
|
62
|
+
type: 'noul',
|
|
63
|
+
instructions: '信息不足:当前输入是否缺少判断候选是否适用所需的信息(例如只有确认词、指代不明、'
|
|
64
|
+
+ '不知道在问哪一个任务)?信息不足时概率接近 1;能够明确判断时为 0。',
|
|
65
|
+
};
|
|
66
|
+
return questions;
|
|
67
|
+
}
|
|
68
|
+
export function buildDecisionRequest(input) {
|
|
69
|
+
if (input.candidates.length === 0) {
|
|
70
|
+
return { ok: false, reason: 'INPUT_REFUSED' };
|
|
71
|
+
}
|
|
72
|
+
const questions = buildDecisionQuestions(input.candidates);
|
|
73
|
+
const state = {
|
|
74
|
+
currentInstruction: input.currentInstruction,
|
|
75
|
+
priorMessages: input.priorMessages,
|
|
76
|
+
candidates: input.candidates.map((candidate) => ({
|
|
77
|
+
ref: candidate.ref,
|
|
78
|
+
text: candidate.text,
|
|
79
|
+
digest: candidate.digest,
|
|
80
|
+
})),
|
|
81
|
+
};
|
|
82
|
+
const body = {
|
|
83
|
+
model: input.model,
|
|
84
|
+
state: JSON.stringify(state),
|
|
85
|
+
questions,
|
|
86
|
+
...(input.provider
|
|
87
|
+
? { provider: { only: [input.provider], allow_fallbacks: false } }
|
|
88
|
+
: {}),
|
|
89
|
+
};
|
|
90
|
+
if (JSON.stringify({ state: body.state, questions }).length > input.maxPayloadChars) {
|
|
91
|
+
return { ok: false, reason: 'INPUT_REFUSED' };
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
ok: true,
|
|
95
|
+
body,
|
|
96
|
+
questionIds: [...Object.keys(questions)],
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
/** rc-1/rc-2: parsed JSON is unknown until these guards pass. */
|
|
100
|
+
function isRecord(value) {
|
|
101
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Model identity is exact against an explicit allowlist when one is frozen
|
|
105
|
+
* (the acceptance batch does this). Otherwise one bounded alias class is
|
|
106
|
+
* accepted: a `:free` tag may be absent, and a dated canonical slug
|
|
107
|
+
* (`<base>-YYYYMMDD`) is accepted — the two aliases the lab verified.
|
|
108
|
+
*
|
|
109
|
+
* An unregistered DATE is never accepted through the allowlist path: the
|
|
110
|
+
* observed id must be one of the frozen strings, so a same-prefix slug with a
|
|
111
|
+
* different date is a mismatch.
|
|
112
|
+
*/
|
|
113
|
+
export function isDecisionModelIdentity(configured, observed, allowedResponseModels) {
|
|
114
|
+
if (allowedResponseModels !== undefined && allowedResponseModels.length > 0) {
|
|
115
|
+
return allowedResponseModels.includes(observed);
|
|
116
|
+
}
|
|
117
|
+
if (configured === observed)
|
|
118
|
+
return true;
|
|
119
|
+
const base = configured.endsWith(':free') ? configured.slice(0, -':free'.length) : configured;
|
|
120
|
+
if (base === observed)
|
|
121
|
+
return true;
|
|
122
|
+
return new RegExp(`^${base.replace(/[.*+?^${}()|[\]\\]/gu, '\\$&')}-\\d{8}$`, 'u').test(observed);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Validates model identity, provider identity (when configured), completeness
|
|
126
|
+
* of the exact question set, and every score range. Any missing, extra or
|
|
127
|
+
* malformed answer is a rejected turn — never a partial score table.
|
|
128
|
+
*/
|
|
129
|
+
export function validateDecisionResponse(value, expected) {
|
|
130
|
+
if (!isRecord(value))
|
|
131
|
+
return { ok: false, reason: 'DECISION_OUTPUT_INVALID' };
|
|
132
|
+
const { model } = value;
|
|
133
|
+
if (typeof model !== 'string'
|
|
134
|
+
|| !isDecisionModelIdentity(expected.model, model, expected.allowedResponseModels)) {
|
|
135
|
+
return { ok: false, reason: 'DECISION_MODEL_MISMATCH' };
|
|
136
|
+
}
|
|
137
|
+
if (expected.provider !== undefined) {
|
|
138
|
+
const { provider } = value;
|
|
139
|
+
if (provider !== undefined
|
|
140
|
+
&& (typeof provider !== 'string' || provider.toLowerCase() !== expected.provider.toLowerCase())) {
|
|
141
|
+
return { ok: false, reason: 'DECISION_PROVIDER_MISMATCH' };
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
const { answers } = value;
|
|
145
|
+
if (!isRecord(answers))
|
|
146
|
+
return { ok: false, reason: 'DECISION_OUTPUT_INVALID' };
|
|
147
|
+
const answerKeys = Object.keys(answers);
|
|
148
|
+
if (answerKeys.length !== expected.questionIds.length
|
|
149
|
+
|| expected.questionIds.some((id) => !Object.hasOwn(answers, id))) {
|
|
150
|
+
return { ok: false, reason: 'DECISION_QUESTION_MISMATCH' };
|
|
151
|
+
}
|
|
152
|
+
const scores = {};
|
|
153
|
+
for (const id of expected.questionIds) {
|
|
154
|
+
const answer = answers[id];
|
|
155
|
+
if (!isRecord(answer) || answer.type !== 'noul') {
|
|
156
|
+
return { ok: false, reason: 'DECISION_OUTPUT_INVALID' };
|
|
157
|
+
}
|
|
158
|
+
const { noul } = answer;
|
|
159
|
+
if (typeof noul !== 'number' || !Number.isFinite(noul) || noul < 0 || noul > 1) {
|
|
160
|
+
return { ok: false, reason: 'DECISION_SCORE_INVALID' };
|
|
161
|
+
}
|
|
162
|
+
scores[id] = noul;
|
|
163
|
+
}
|
|
164
|
+
return { ok: true, scores };
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Local adjudication of the INDEPENDENT condition scores. Order matters:
|
|
168
|
+
* insufficient information first (it invalidates any candidate ranking), then
|
|
169
|
+
* the eligibility threshold, then the lead margin.
|
|
170
|
+
*/
|
|
171
|
+
export function adjudicateDecision(scores, candidates, criteria = ADAPTIVE_DECISION_CRITERIA) {
|
|
172
|
+
const insufficient = scores[ADAPTIVE_DECISION_INSUFFICIENT_QUESTION];
|
|
173
|
+
if (insufficient !== undefined && insufficient >= criteria.insufficientThreshold) {
|
|
174
|
+
return { status: 'uncertain', ref: null, reason: 'information_insufficient', scores };
|
|
175
|
+
}
|
|
176
|
+
const ranked = candidates
|
|
177
|
+
.map((candidate) => ({
|
|
178
|
+
ref: candidate.ref,
|
|
179
|
+
score: scores[candidateQuestionId(candidate.ref)] ?? 0,
|
|
180
|
+
}))
|
|
181
|
+
.sort((left, right) => right.score - left.score);
|
|
182
|
+
const [top, runnerUp] = ranked;
|
|
183
|
+
if (!top || top.score < criteria.selectThreshold) {
|
|
184
|
+
return { status: 'none_applicable', ref: null, reason: 'below_selection_threshold', scores };
|
|
185
|
+
}
|
|
186
|
+
if (runnerUp && top.score - runnerUp.score < criteria.leadMargin) {
|
|
187
|
+
return { status: 'uncertain', ref: null, reason: 'lead_below_margin', scores };
|
|
188
|
+
}
|
|
189
|
+
return { status: 'selected', ref: top.ref, reason: 'selected', scores };
|
|
190
|
+
}
|
|
@@ -9,10 +9,16 @@
|
|
|
9
9
|
* mapping. Any missing identity/config/model keeps the Native path unchanged.
|
|
10
10
|
*/
|
|
11
11
|
import type { HostEvent } from '@principles/core/host';
|
|
12
|
-
import type { PdConfig } from '@principles/core/runtime';
|
|
12
|
+
import type { ActivatedPrinciple, PdConfig } from '@principles/core/runtime';
|
|
13
13
|
import { type AdaptiveSelectionModel } from './adaptive-selection.js';
|
|
14
14
|
/** Independent switch. `features.host.codex.enabled` remains the whole-hook gate. */
|
|
15
15
|
export declare const ADAPTIVE_ACTIVATION_FLAG = "host.codex.adaptive_activation";
|
|
16
|
+
export type AdaptiveActivationFlag = typeof ADAPTIVE_ACTIVATION_FLAG | 'host.workbuddy.adaptive_activation' | 'host.openclaw.adaptive_activation';
|
|
17
|
+
/**
|
|
18
|
+
* PRI-1182 §2: time kept back from the host window for the principle assembly
|
|
19
|
+
* and the hook's own output. Selection never spends the reserve.
|
|
20
|
+
*/
|
|
21
|
+
export declare const ADAPTIVE_OUTPUT_RESERVE_MS = 200;
|
|
16
22
|
export interface AdaptivePrioritySelection {
|
|
17
23
|
readonly artifactId: string;
|
|
18
24
|
readonly activationId: string;
|
|
@@ -20,7 +26,7 @@ export interface AdaptivePrioritySelection {
|
|
|
20
26
|
readonly deadlineAt?: number;
|
|
21
27
|
readonly signal?: AbortSignal;
|
|
22
28
|
}
|
|
23
|
-
export type AdaptivePriorityProvider = (event: HostEvent) => Promise<AdaptivePrioritySelection | undefined>;
|
|
29
|
+
export type AdaptivePriorityProvider = (event: HostEvent, candidates: readonly ActivatedPrinciple[]) => Promise<AdaptivePrioritySelection | undefined>;
|
|
24
30
|
export interface AdaptiveActivationReadiness {
|
|
25
31
|
readonly readiness: 'ready' | 'disabled' | 'needs_setup';
|
|
26
32
|
readonly reason: string;
|
|
@@ -29,30 +35,42 @@ export interface AdaptiveActivationReadiness {
|
|
|
29
35
|
export type AdaptiveModelResolution = {
|
|
30
36
|
readonly ok: true;
|
|
31
37
|
readonly model: AdaptiveSelectionModel;
|
|
32
|
-
readonly profileId: string;
|
|
33
38
|
} | {
|
|
34
39
|
readonly ok: false;
|
|
40
|
+
readonly readiness: 'disabled' | 'needs_setup';
|
|
35
41
|
readonly reason: string;
|
|
36
42
|
readonly nextAction: string;
|
|
37
43
|
};
|
|
38
|
-
export declare function resolveAdaptiveSelectionModel(config: PdConfig, env: Record<string, string | undefined
|
|
44
|
+
export declare function resolveAdaptiveSelectionModel(config: PdConfig, env: Record<string, string | undefined>, flag?: AdaptiveActivationFlag): AdaptiveModelResolution;
|
|
39
45
|
export interface AdaptiveSelectionDiagnosticLine {
|
|
40
46
|
readonly status: string;
|
|
41
47
|
readonly reason: string;
|
|
42
48
|
readonly stage: string;
|
|
43
49
|
readonly sends: number;
|
|
50
|
+
readonly requestSentAt: number | null;
|
|
44
51
|
readonly firstByteAt: number | null;
|
|
45
52
|
readonly generationEndedAt: number | null;
|
|
53
|
+
readonly validatedAt: number | null;
|
|
46
54
|
readonly cancelledAt: number | null;
|
|
47
55
|
readonly httpStatus: number | null;
|
|
48
56
|
readonly finishReason: string;
|
|
57
|
+
/** Observed response model; null when no body was parsed. */
|
|
58
|
+
readonly modelObserved: string | null;
|
|
59
|
+
/** Observed response provider; null when absent or no body was parsed. */
|
|
60
|
+
readonly providerObserved: string | null;
|
|
61
|
+
/** Bounded local adjudication evidence (ids only, never prompt text). */
|
|
62
|
+
readonly decision: {
|
|
63
|
+
readonly status: string;
|
|
64
|
+
readonly ref: string | null;
|
|
65
|
+
readonly reason: string;
|
|
66
|
+
readonly scores: Readonly<Record<string, number>>;
|
|
67
|
+
} | null;
|
|
49
68
|
readonly failures: readonly string[];
|
|
50
69
|
}
|
|
51
70
|
export interface CreateAdaptivePriorityProviderOptions {
|
|
52
71
|
readonly workspaceDir: string;
|
|
53
72
|
readonly model: AdaptiveSelectionModel;
|
|
54
|
-
readonly
|
|
55
|
-
readonly generationTimeoutMs?: number;
|
|
73
|
+
readonly requestTimeoutMs?: number;
|
|
56
74
|
/**
|
|
57
75
|
* Absolute host deadline (Codex: the plugin hook window minus the Native
|
|
58
76
|
* reserve). Selection, revalidation and packing all share it: a selection
|
|
@@ -60,13 +78,19 @@ export interface CreateAdaptivePriorityProviderOptions {
|
|
|
60
78
|
*/
|
|
61
79
|
readonly outerDeadlineAt?: number;
|
|
62
80
|
/**
|
|
63
|
-
* PRI-
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
|
|
81
|
+
* PRI-1182 §2: reserved for assembly and output after the decision. The
|
|
82
|
+
* effective deadline is the earlier of the host's remaining window (minus
|
|
83
|
+
* this reserve) and the request's own short limit.
|
|
84
|
+
*/
|
|
85
|
+
readonly outputReserveMs?: number;
|
|
86
|
+
/**
|
|
87
|
+
* PRI-1181/PRI-1182: below this remaining budget the turn is skipped before
|
|
88
|
+
* the candidate read — no model request is sent at all. Defaults to the
|
|
89
|
+
* request's minimum executable envelope
|
|
90
|
+
* (`ADAPTIVE_SKIP_LIMITS.minExecutableBudgetMs`); 0 disables the gate for
|
|
91
|
+
* scenarios that isolate transport cancellation.
|
|
67
92
|
*/
|
|
68
|
-
readonly
|
|
69
|
-
readonly maxTokens?: number;
|
|
93
|
+
readonly minExecutableBudgetMs?: number;
|
|
70
94
|
readonly now?: () => number;
|
|
71
95
|
/** Test seam: production uses the global transport. */
|
|
72
96
|
readonly fetchImpl?: typeof fetch;
|
|
@@ -81,12 +105,12 @@ export type AdaptivePriorityProviderResolution = (AdaptiveActivationReadiness &
|
|
|
81
105
|
readonly ok: true;
|
|
82
106
|
readonly readiness: 'ready';
|
|
83
107
|
readonly provider: AdaptivePriorityProvider;
|
|
84
|
-
readonly profileId: string;
|
|
85
108
|
}) | (AdaptiveActivationReadiness & {
|
|
86
109
|
readonly ok: false;
|
|
87
110
|
});
|
|
88
111
|
export interface CreateAdaptiveProviderFromConfigOptions extends Omit<CreateAdaptivePriorityProviderOptions, 'workspaceDir' | 'model'> {
|
|
89
112
|
readonly env?: Record<string, string | undefined>;
|
|
113
|
+
readonly flag?: AdaptiveActivationFlag;
|
|
90
114
|
}
|
|
91
115
|
/**
|
|
92
116
|
* Config-first factory for hosts (Codex pd-hook) that already loaded the
|