@principles/codex-adapter 0.16.0 → 0.16.2
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 +7 -1
- package/dist/worker/workspace-worker.js +14 -10
- package/package.json +5 -5
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, loadPdConfigForPlugin, renderAcceptedAdaptiveAppend, resolveHostToolSemanticsForHook, resolveNearestPdWorkspace } from '@principles/host-runtime';
|
|
7
|
+
import { ADAPTIVE_SELECTION_LIMITS, createAdaptivePriorityProviderForConfig, createCodexRuleContextProvider, createProductionHostRuntime, environmentFactDigestOrNull, loadPdConfigForPlugin, renderAcceptedAdaptiveAppend, resolveHostToolSemanticsForHook, resolveNearestPdWorkspace } 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';
|
|
@@ -697,6 +697,12 @@ export async function processHookInvocation(rawStdin, _env = process.env, cwd =
|
|
|
697
697
|
projectDir: requestedCwd,
|
|
698
698
|
hostKind: 'codex',
|
|
699
699
|
toolSemantics,
|
|
700
|
+
afterToolCallEnvironment: {
|
|
701
|
+
runtimeVersion: process.version,
|
|
702
|
+
agentConfigDigest: environmentFactDigestOrNull(config.effective),
|
|
703
|
+
modelConfigDigest: environmentFactDigestOrNull(event.context.modelContext),
|
|
704
|
+
featureFlagsDigest: environmentFactDigestOrNull(flags),
|
|
705
|
+
},
|
|
700
706
|
...(adaptivePriorityProvider ? { adaptiveGapProvider: adaptivePriorityProvider } : {}),
|
|
701
707
|
ruleContextProvider: createCodexRuleContextProvider({
|
|
702
708
|
workspaceDir: resolution.workspaceDir,
|
|
@@ -27,16 +27,12 @@
|
|
|
27
27
|
*/
|
|
28
28
|
import fs from 'node:fs';
|
|
29
29
|
import path from 'node:path';
|
|
30
|
-
import { computeFeatureFlagsFromConfig, createRuntimeStateHandle, createPainSignalBridge, isRetryWaitBackoffElapsed, pickDiagnosticianCandidate, reconcileWaitingTargetEvidenceTasks, PrincipleTreeLedgerAdapter, resolveDiagnosticianCapability, } from '@principles/core/runtime';
|
|
30
|
+
import { computeFeatureFlagsFromConfig, createRuntimeStateHandle, createPainSignalBridge, isRetryWaitBackoffElapsed, pickDiagnosticianCandidate, reconcileWaitingTargetEvidenceTasks, PrincipleTreeLedgerAdapter, resolveDiagnosticianCapability, PDRuntimeError, } from '@principles/core/runtime';
|
|
31
31
|
import { createWorkspaceBehaviorEvidencePort, createCodexArtificerTrustedFactsPort, loadPdConfigForPlugin, loadFeatureFlagFromConfig, reconcileGovernanceContinuation, runInternalizationConsumerCycle, runStage2CorrectionCycle, 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';
|
|
35
|
-
//
|
|
36
|
-
// label for NEW writes is the Service Host worker identity — the PD Service
|
|
37
|
-
// Host is the only background runtime and spawns these bounded worker cycles.
|
|
38
|
-
// Historical lease records keep the retired 'companion-worker' string; they
|
|
39
|
-
// are durable facts and are deliberately NOT migrated.
|
|
35
|
+
// Lease/consumer owner label written by the Service-Host-spawned worker.
|
|
40
36
|
const WORKER_OWNER = 'service-host-worker';
|
|
41
37
|
const DEFAULT_DIAG_CANDIDATE_LIMIT = 5;
|
|
42
38
|
/** CR-05 §9.1: bounded per-cycle post-processing continuation budget. */
|
|
@@ -170,6 +166,14 @@ function finalizeLiveness(workspaceDir, cycleStartedAt, settlement) {
|
|
|
170
166
|
...invocationIdLivenessPatch(),
|
|
171
167
|
});
|
|
172
168
|
}
|
|
169
|
+
function workerCycleNextAction(error, fallback) {
|
|
170
|
+
if (error instanceof PDRuntimeError
|
|
171
|
+
&& error.category === 'storage_unavailable'
|
|
172
|
+
&& typeof error.details?.nextAction === 'string') {
|
|
173
|
+
return error.details.nextAction;
|
|
174
|
+
}
|
|
175
|
+
return fallback;
|
|
176
|
+
}
|
|
173
177
|
/**
|
|
174
178
|
* SPEC §9.1 fair-share pick (review P1): pending and due-retry are both
|
|
175
179
|
* continuously-eligible classes; neither may starve the other while new
|
|
@@ -302,7 +306,7 @@ export async function runCodexWorkspaceWorkerCycle(options) {
|
|
|
302
306
|
// consumer flag is on — an intentional capability pause never reaches
|
|
303
307
|
// candidate picking or any provider call.)
|
|
304
308
|
try {
|
|
305
|
-
const handle = await createRuntimeStateHandle({ workspaceDir, readonly: false });
|
|
309
|
+
const handle = await createRuntimeStateHandle({ workspaceDir, readonly: false, bootstrapIfMissing: false });
|
|
306
310
|
try {
|
|
307
311
|
const sweep = await handle.stateManager.runRecoverySweep();
|
|
308
312
|
if (sweep.recovered > 0 || sweep.errors.length > 0) {
|
|
@@ -420,7 +424,7 @@ export async function runCodexWorkspaceWorkerCycle(options) {
|
|
|
420
424
|
...base,
|
|
421
425
|
mode: 'degraded',
|
|
422
426
|
reason,
|
|
423
|
-
nextAction: 'Inspect the Workspace runtime profile and provider configuration; the task keeps its pending/retry state and no evidence was mutated.',
|
|
427
|
+
nextAction: workerCycleNextAction(error, 'Inspect the Workspace runtime profile and provider configuration; the task keeps its pending/retry state and no evidence was mutated.'),
|
|
424
428
|
report: { catchUp, reconcile, postProcessing: null, diagnostician: null, downstream: null },
|
|
425
429
|
};
|
|
426
430
|
}
|
|
@@ -436,7 +440,7 @@ export async function runCodexWorkspaceWorkerCycle(options) {
|
|
|
436
440
|
writeLiveness(workspaceDir, { runningStage: 'post_processing', stageDeadline: new Date(Date.now() + LIVENESS_STAGE_DEADLINE_MS.post_processing).toISOString() });
|
|
437
441
|
if (consumerFlag.enabled && !diagnosticianDisabled) {
|
|
438
442
|
try {
|
|
439
|
-
const handle = await createRuntimeStateHandle({ workspaceDir, readonly: false });
|
|
443
|
+
const handle = await createRuntimeStateHandle({ workspaceDir, readonly: false, bootstrapIfMissing: false });
|
|
440
444
|
try {
|
|
441
445
|
const { eligible: backlog, corrupt } = await handle.stateManager.listDiagnosisPostProcessingBacklog({ limit: DEFAULT_POST_PROCESSING_LIMIT });
|
|
442
446
|
const { eligible: backlogAll, corrupt: corruptAll } = await handle.stateManager.listDiagnosisPostProcessingBacklog({ limit: 200 });
|
|
@@ -528,7 +532,7 @@ export async function runCodexWorkspaceWorkerCycle(options) {
|
|
|
528
532
|
...base,
|
|
529
533
|
mode: 'degraded',
|
|
530
534
|
reason,
|
|
531
|
-
nextAction: 'Inspect the workspace state.db principle_candidates/tasks; the worker retries automatically on the next cycle.',
|
|
535
|
+
nextAction: workerCycleNextAction(error, 'Inspect the workspace state.db principle_candidates/tasks; the worker retries automatically on the next cycle.'),
|
|
532
536
|
report: { catchUp, reconcile, postProcessing: null, diagnostician, downstream: null, ...(targetEvidenceReconcile !== null ? { targetEvidenceReconcile } : {}) },
|
|
533
537
|
};
|
|
534
538
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@principles/codex-adapter",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.2",
|
|
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,14 +33,14 @@
|
|
|
33
33
|
"lint": "eslint \"src/**/*.ts\""
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@principles/core": "^8.
|
|
37
|
-
"@principles/host-runtime": "^4.
|
|
36
|
+
"@principles/core": "^8.7.0",
|
|
37
|
+
"@principles/host-runtime": "^4.10.0",
|
|
38
38
|
"@principles/install-layout": "^0.12.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/node": "^26.6.6",
|
|
42
42
|
"typescript": "^7.0.2",
|
|
43
|
-
"vite": "^8.
|
|
43
|
+
"vite": "^8.4.0",
|
|
44
44
|
"vitest": "^5.1.0"
|
|
45
45
|
},
|
|
46
46
|
"license": "Apache-2.0",
|
|
@@ -52,5 +52,5 @@
|
|
|
52
52
|
"publishConfig": {
|
|
53
53
|
"access": "public"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "1da1cdfe14b3c0a471e2b990a2aa376bbefe840b"
|
|
56
56
|
}
|