@principles/codex-adapter 0.16.2 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/pd-hook.js
CHANGED
|
@@ -4,7 +4,7 @@ import path from 'node:path';
|
|
|
4
4
|
import process from 'node:process';
|
|
5
5
|
import { pathToFileURL, fileURLToPath } from 'node:url';
|
|
6
6
|
import { appendEventLogLine, redactTelemetryString, isRuleHostEvaluatedEventData } from '@principles/core/runtime';
|
|
7
|
-
import { ADAPTIVE_SELECTION_LIMITS, createAdaptivePriorityProviderForConfig, createCodexRuleContextProvider, createProductionHostRuntime, environmentFactDigestOrNull, loadPdConfigForPlugin, renderAcceptedAdaptiveAppend, resolveHostToolSemanticsForHook, resolveNearestPdWorkspace } from '@principles/host-runtime';
|
|
7
|
+
import { ADAPTIVE_SELECTION_LIMITS, createAdaptivePriorityProviderForConfig, createCodexRuleContextProvider, createProductionHostRuntime, environmentFactDigestOrNull, loadPdConfigForPlugin, renderAcceptedAdaptiveAppend, resolveHostToolSemanticsForHook, resolveNearestPdWorkspace, recordIdleAuditTurnCompleted, } from '@principles/host-runtime';
|
|
8
8
|
import { resolvePdHome } from '@principles/install-layout';
|
|
9
9
|
import { classifyBashRisk } from '@principles/core/runtime/internalization/bash-risk';
|
|
10
10
|
import { CODEX_TOOL_SEMANTIC_MAPPINGS, CODEX_TOOL_SEMANTICS } from './tool-semantics.js';
|
|
@@ -464,6 +464,15 @@ export async function processHookInvocation(rawStdin, _env = process.env, cwd =
|
|
|
464
464
|
if (hasAdaptiveAppendTurn(backgroundKey))
|
|
465
465
|
finalizeBackgroundTurn(backgroundKey);
|
|
466
466
|
}
|
|
467
|
+
if (ingestionEnabled) {
|
|
468
|
+
recordIdleAuditTurnCompleted({
|
|
469
|
+
workspaceDir: resolution.workspaceDir,
|
|
470
|
+
hostKind: 'codex',
|
|
471
|
+
sessionId: event.context.sessionId,
|
|
472
|
+
turnEndSource: 'stop_hook',
|
|
473
|
+
hasActiveRun: false,
|
|
474
|
+
});
|
|
475
|
+
}
|
|
467
476
|
return { stdout: {}, exitCode: 0, stderr };
|
|
468
477
|
}
|
|
469
478
|
try {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type TargetEvidenceReconcileReport } from '@principles/core/runtime';
|
|
2
|
-
import { type InternalizationConsumerCycleOutcome, type ConsumerCycleLogger, type ReconcileGovernanceContinuationResult, type SignalLlmClassifier, type Stage2CorrectionCycleReport } from '@principles/host-runtime';
|
|
2
|
+
import { type InternalizationConsumerCycleOutcome, type ConsumerCycleLogger, type ReconcileGovernanceContinuationResult, type SignalLlmClassifier, type Stage2CorrectionCycleReport, type RunIdleTurnAuditCycleReport, type IdleTurnAuditor } from '@principles/host-runtime';
|
|
3
3
|
import { type CodexCatchUpResult } from '../ingestion/catch-up.js';
|
|
4
4
|
import type { TranscriptPort } from '../ingestion/transcript-decoder.js';
|
|
5
5
|
export type CodexWorkerMode = 'ready' | 'manual_action_required' | 'paused' | 'degraded';
|
|
@@ -47,6 +47,7 @@ export interface CodexWorkerCycleStepReport {
|
|
|
47
47
|
* the Diagnostician (bounded to ≤2 candidates / ≤60s aggregate).
|
|
48
48
|
*/
|
|
49
49
|
readonly stage2?: Stage2CorrectionCycleReport;
|
|
50
|
+
readonly idleAudit?: RunIdleTurnAuditCycleReport;
|
|
50
51
|
}
|
|
51
52
|
export interface CodexWorkerCycleResult {
|
|
52
53
|
readonly workspaceDir: string;
|
|
@@ -73,6 +74,8 @@ export interface CodexWorkerCycleOptions {
|
|
|
73
74
|
*/
|
|
74
75
|
readonly stage2Classifier?: SignalLlmClassifier | null;
|
|
75
76
|
readonly stage2AggregateBudgetMs?: number;
|
|
77
|
+
/** Test seam: undefined = production auditor resolution; null = explicitly unavailable. */
|
|
78
|
+
readonly idleTurnAuditor?: IdleTurnAuditor | null;
|
|
76
79
|
}
|
|
77
80
|
/**
|
|
78
81
|
* WHO drove this cycle (PRI-1264 attribution, Phase 2 extension). The
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
import fs from 'node:fs';
|
|
29
29
|
import path from 'node:path';
|
|
30
30
|
import { computeFeatureFlagsFromConfig, createRuntimeStateHandle, createPainSignalBridge, isRetryWaitBackoffElapsed, pickDiagnosticianCandidate, reconcileWaitingTargetEvidenceTasks, PrincipleTreeLedgerAdapter, resolveDiagnosticianCapability, PDRuntimeError, } from '@principles/core/runtime';
|
|
31
|
-
import { createWorkspaceBehaviorEvidencePort, createCodexArtificerTrustedFactsPort, loadPdConfigForPlugin, loadFeatureFlagFromConfig, reconcileGovernanceContinuation, runInternalizationConsumerCycle, runStage2CorrectionCycle, createSignalClassifierForWorkspace, createConsentLedgerSourceMaterialAuthorization, resolveWorkspacePipelineHostDeps, saveHostToolDeclaration, HOST_TOOL_DECLARATION_VERSION, } from '@principles/host-runtime';
|
|
31
|
+
import { createWorkspaceBehaviorEvidencePort, createCodexArtificerTrustedFactsPort, loadPdConfigForPlugin, loadFeatureFlagFromConfig, reconcileGovernanceContinuation, runInternalizationConsumerCycle, runStage2CorrectionCycle, runIdleTurnAuditCycle, createIdleTurnAuditorForWorkspace, createSignalClassifierForWorkspace, createConsentLedgerSourceMaterialAuthorization, resolveWorkspacePipelineHostDeps, saveHostToolDeclaration, HOST_TOOL_DECLARATION_VERSION, } from '@principles/host-runtime';
|
|
32
32
|
import { catchUpCodexIngestion } from '../ingestion/catch-up.js';
|
|
33
33
|
import { readCodexTargetTurnEvidence } from '../ingestion/pain-receipt-fallback.js';
|
|
34
34
|
import { CODEX_TOOL_SEMANTIC_MAPPINGS, CODEX_TOOL_SEMANTICS } from '../tool-semantics.js';
|
|
@@ -602,6 +602,24 @@ export async function runCodexWorkspaceWorkerCycle(options) {
|
|
|
602
602
|
...(options.now !== undefined ? { now: options.now } : {}),
|
|
603
603
|
onEvent: emitEvent,
|
|
604
604
|
});
|
|
605
|
+
// R5: one bounded idle-turn audit per worker cycle, after every
|
|
606
|
+
// higher-priority diagnosis/internalization step. Auditor unavailability is
|
|
607
|
+
// observable but does not degrade the whole worker cycle.
|
|
608
|
+
const idleResolution = options.idleTurnAuditor === undefined
|
|
609
|
+
? createIdleTurnAuditorForWorkspace(workspaceDir, {
|
|
610
|
+
log: (event, detail) => emitEvent(event, detail),
|
|
611
|
+
})
|
|
612
|
+
: null;
|
|
613
|
+
const idleAuditor = options.idleTurnAuditor !== undefined
|
|
614
|
+
? options.idleTurnAuditor
|
|
615
|
+
: (idleResolution?.ok === true ? idleResolution.auditor : null);
|
|
616
|
+
if (idleResolution !== null && !idleResolution.ok) {
|
|
617
|
+
emitEvent('IDLE_AUDIT_AUDITOR_UNAVAILABLE', JSON.stringify({ reason: idleResolution.reason, readiness: idleResolution.readiness }));
|
|
618
|
+
}
|
|
619
|
+
const idleAudit = await runIdleTurnAuditCycle({
|
|
620
|
+
workspaceDir,
|
|
621
|
+
auditor: idleAuditor,
|
|
622
|
+
});
|
|
605
623
|
// Aggregated mode: degraded overrides all (review P1). Any component
|
|
606
624
|
// degrading — catch-up, reconciliation, diagnostician or downstream —
|
|
607
625
|
// surfaces the workspace as degraded, with the highest-priority reason.
|
|
@@ -630,7 +648,7 @@ export async function runCodexWorkspaceWorkerCycle(options) {
|
|
|
630
648
|
...base,
|
|
631
649
|
mode: degradedReason !== undefined ? 'degraded' : 'ready',
|
|
632
650
|
...(degradedReason !== undefined ? { reason: degradedReason, nextAction: 'Inspect the Workspace .pd/config.yaml runtime profile and the per-step report above; the worker retries automatically on the next cycle.' } : {}),
|
|
633
|
-
report: { catchUp, reconcile, postProcessing, diagnostician, downstream, ...(targetEvidenceReconcile !== null ? { targetEvidenceReconcile } : {}), stage2 },
|
|
651
|
+
report: { catchUp, reconcile, postProcessing, diagnostician, downstream, ...(targetEvidenceReconcile !== null ? { targetEvidenceReconcile } : {}), stage2, idleAudit },
|
|
634
652
|
};
|
|
635
653
|
}
|
|
636
654
|
// Slice D (PRI-625): the mode authority moved to host-runtime so the CLI and
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@principles/codex-adapter",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"description": "Codex CLI host adapter for Principles Disciple — implements HostAdapter interface for OpenAI Codex CLI's stdin/stdout JSON hook model (ADR-0020).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"lint": "eslint \"src/**/*.ts\""
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@principles/core": "^
|
|
37
|
-
"@principles/host-runtime": "^4.
|
|
36
|
+
"@principles/core": "^9.0.0",
|
|
37
|
+
"@principles/host-runtime": "^4.11.0",
|
|
38
38
|
"@principles/install-layout": "^0.12.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
@@ -52,5 +52,5 @@
|
|
|
52
52
|
"publishConfig": {
|
|
53
53
|
"access": "public"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "1e6fc5c3f3083d24dc50a65c420609e21307d9d5"
|
|
56
56
|
}
|