@principles/codex-adapter 0.15.1 → 0.16.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.
|
@@ -77,10 +77,18 @@ export interface CodexWorkerCycleOptions {
|
|
|
77
77
|
/**
|
|
78
78
|
* WHO drove this cycle (PRI-1264 attribution, Phase 2 extension). The
|
|
79
79
|
* Service Host sets `PD_INVOCATION_SOURCE=service_host` on its Worker
|
|
80
|
-
* children
|
|
81
|
-
*
|
|
80
|
+
* children; without the second value the stall attribution would misreport
|
|
81
|
+
* service-driven cycles as manual (TD §5.2).
|
|
82
|
+
*
|
|
83
|
+
* PRI-1278 Phase 5 (Companion-runtime removal): the companion worker driver
|
|
84
|
+
* is retired — there is no Companion runtime left that could legitimately
|
|
85
|
+
* produce it. A process still self-declaring `PD_INVOCATION_SOURCE=companion`
|
|
86
|
+
* (a legacy env leftover) is not authoritative: no resident supervisor backs
|
|
87
|
+
* it, so it is attributed as what it factually is — manual. Historical
|
|
88
|
+
* liveness records already persisted with `lastCycleDriver: 'companion'`
|
|
89
|
+
* stay readable as-is; they are durable facts and are never rewritten.
|
|
82
90
|
*/
|
|
83
|
-
export declare function codexWorkerCycleDriver(): '
|
|
91
|
+
export declare function codexWorkerCycleDriver(): 'service_host' | 'manual';
|
|
84
92
|
export declare function readCodexWorkerLiveness(workspaceDir: string): Record<string, unknown> | null;
|
|
85
93
|
/**
|
|
86
94
|
* SPEC §9.1 fair-share pick (review P1): pending and due-retry are both
|
|
@@ -32,7 +32,12 @@ import { createWorkspaceBehaviorEvidencePort, createCodexArtificerTrustedFactsPo
|
|
|
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
|
-
|
|
35
|
+
// PRI-1278 Phase 5 (Companion-runtime removal): the lease/consumer owner
|
|
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.
|
|
40
|
+
const WORKER_OWNER = 'service-host-worker';
|
|
36
41
|
const DEFAULT_DIAG_CANDIDATE_LIMIT = 5;
|
|
37
42
|
/** CR-05 §9.1: bounded per-cycle post-processing continuation budget. */
|
|
38
43
|
const DEFAULT_POST_PROCESSING_LIMIT = 2;
|
|
@@ -51,13 +56,19 @@ const LIVENESS_STAGE_DEADLINE_MS = {
|
|
|
51
56
|
/**
|
|
52
57
|
* WHO drove this cycle (PRI-1264 attribution, Phase 2 extension). The
|
|
53
58
|
* Service Host sets `PD_INVOCATION_SOURCE=service_host` on its Worker
|
|
54
|
-
* children
|
|
55
|
-
*
|
|
59
|
+
* children; without the second value the stall attribution would misreport
|
|
60
|
+
* service-driven cycles as manual (TD §5.2).
|
|
61
|
+
*
|
|
62
|
+
* PRI-1278 Phase 5 (Companion-runtime removal): the companion worker driver
|
|
63
|
+
* is retired — there is no Companion runtime left that could legitimately
|
|
64
|
+
* produce it. A process still self-declaring `PD_INVOCATION_SOURCE=companion`
|
|
65
|
+
* (a legacy env leftover) is not authoritative: no resident supervisor backs
|
|
66
|
+
* it, so it is attributed as what it factually is — manual. Historical
|
|
67
|
+
* liveness records already persisted with `lastCycleDriver: 'companion'`
|
|
68
|
+
* stay readable as-is; they are durable facts and are never rewritten.
|
|
56
69
|
*/
|
|
57
70
|
export function codexWorkerCycleDriver() {
|
|
58
71
|
const source = process.env.PD_INVOCATION_SOURCE;
|
|
59
|
-
if (source === 'companion')
|
|
60
|
-
return 'companion';
|
|
61
72
|
if (source === 'service_host')
|
|
62
73
|
return 'service_host';
|
|
63
74
|
return 'manual';
|
|
@@ -66,9 +77,9 @@ export function codexWorkerCycleDriver() {
|
|
|
66
77
|
* F13 (TD §5.2): the coordinator passes a unique invocation id; when
|
|
67
78
|
* present it lands in the liveness record so the shared per-workspace file
|
|
68
79
|
* can be correlated back to the exact Service Host invocation.
|
|
69
|
-
* R5 review fix: a manual
|
|
70
|
-
* patch must CLEAR the field — otherwise a completed manual run
|
|
71
|
-
* masquerading under the previous shadow run's id.
|
|
80
|
+
* R5 review fix: a manual (non-Service-Host) cycle carries NO invocation
|
|
81
|
+
* id, so the patch must CLEAR the field — otherwise a completed manual run
|
|
82
|
+
* would keep masquerading under the previous shadow run's id.
|
|
72
83
|
*/
|
|
73
84
|
function invocationIdLivenessPatch() {
|
|
74
85
|
const invocationId = process.env.PD_INVOCATION_ID;
|
|
@@ -198,11 +209,13 @@ export async function runCodexWorkspaceWorkerCycle(options) {
|
|
|
198
209
|
// PRI-1264 review round (2026-11-18): an intentional CONFIG pause must
|
|
199
210
|
// keep the liveness heartbeat alive — the worker process IS alive and
|
|
200
211
|
// cycling, it is just deliberately idle. Without this heartbeat the
|
|
201
|
-
//
|
|
202
|
-
//
|
|
203
|
-
//
|
|
204
|
-
//
|
|
205
|
-
//
|
|
212
|
+
// stall attribution reading this record (last-completed-cycle age —
|
|
213
|
+
// originally the retired Companion's detector, now the `pd codex worker
|
|
214
|
+
// --status` verdict and the Service Host health projection) read the
|
|
215
|
+
// stale pre-pause record and reported a deliberately idle worker as
|
|
216
|
+
// stalled — guidance no restart could ever fix, because the pause is
|
|
217
|
+
// config-intentional. The workspace directory and config were already
|
|
218
|
+
// proven readable above (CR-08 ordering), so the write is legitimate.
|
|
206
219
|
writeLiveness(workspaceDir, {
|
|
207
220
|
runningStage: 'paused',
|
|
208
221
|
// Explicit null: a paused state has no in-flight stage, and the merge
|
|
@@ -221,9 +234,10 @@ export async function runCodexWorkspaceWorkerCycle(options) {
|
|
|
221
234
|
runningStage: 'catch_up',
|
|
222
235
|
stageDeadline: new Date(cycleStartedAt.getTime() + LIVENESS_STAGE_DEADLINE_MS.catch_up).toISOString(),
|
|
223
236
|
// PRI-1264: record WHO drove this cycle. `pd codex worker --status` reads
|
|
224
|
-
// the marker so the Owner can tell a
|
|
225
|
-
//
|
|
226
|
-
//
|
|
237
|
+
// the marker so the Owner can tell a Service-Host-driven cycle (a bounded
|
|
238
|
+
// worker spawned by the OS-scheduled Service Host, expected to recur on
|
|
239
|
+
// its interval) from a manual one-shot — "registered" alone says nothing
|
|
240
|
+
// about whether a driver is actually alive.
|
|
227
241
|
lastCycleDriver: codexWorkerCycleDriver(),
|
|
228
242
|
});
|
|
229
243
|
const consumerFlag = loadFeatureFlagFromConfig(workspaceDir, 'internalization_auto_consumer', { info: (m) => logger.info(m), warn: (m) => logger.warn(m) });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@principles/codex-adapter",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.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,9 +33,9 @@
|
|
|
33
33
|
"lint": "eslint \"src/**/*.ts\""
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@principles/core": "^8.
|
|
37
|
-
"@principles/host-runtime": "^4.
|
|
38
|
-
"@principles/install-layout": "^0.
|
|
36
|
+
"@principles/core": "^8.4.0",
|
|
37
|
+
"@principles/host-runtime": "^4.8.0",
|
|
38
|
+
"@principles/install-layout": "^0.12.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/node": "^26.6.6",
|
|
@@ -52,5 +52,5 @@
|
|
|
52
52
|
"publishConfig": {
|
|
53
53
|
"access": "public"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "ff62137821c993773cc7df104a01625310776c51"
|
|
56
56
|
}
|