@principles/codex-adapter 0.15.0 → 0.15.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.
@@ -28,7 +28,7 @@
28
28
  * `tool_call` rows, or look-alike strings (SPEC TD §1.3).
29
29
  */
30
30
  import * as path from 'node:path';
31
- import { listGovernanceConversationTextsForHostTurn, readSourceMaterialAuthorization } from '@principles/host-runtime';
31
+ import { createConsentLedgerSourceMaterialAuthorization, listGovernanceConversationTextsForHostTurn, readSourceMaterialAuthorization } from '@principles/host-runtime';
32
32
  import { isSentinelSessionId } from '@principles/core/runtime';
33
33
  import { recoverTaskIdentityFromReceipt, validatePainSubmitReceipt, } from '@principles/core/runtime';
34
34
  import { isPainSubmitPostToolUseToolName } from '../codec/input-decoder.js';
@@ -205,7 +205,8 @@ export async function attemptPainReceiptFallback(input) {
205
205
  toolCallId,
206
206
  },
207
207
  authorization: { minimalMetadataGranted: input.minimalMetadataGranted },
208
- targetTurnTextAvailable: (hostSessionId, targetTurnId) => codexTargetTurnTextAvailable(normalizedWorkspace, hostSessionId, targetTurnId),
208
+ readTargetTurnEvidence: (hostSessionId, targetTurnId) => readCodexTargetTurnEvidence(normalizedWorkspace, hostSessionId, targetTurnId),
209
+ sourceMaterialAuthorization: createConsentLedgerSourceMaterialAuthorization(normalizedWorkspace),
209
210
  ...(input.now !== undefined ? { now: input.now } : {}),
210
211
  });
211
212
  return { status: 'attempted', outcome };
@@ -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, } from '@principles/core/runtime';
31
- import { createWorkspaceBehaviorEvidencePort, createCodexArtificerTrustedFactsPort, loadPdConfigForPlugin, loadFeatureFlagFromConfig, reconcileGovernanceContinuation, runInternalizationConsumerCycle, runStage2CorrectionCycle, createSignalClassifierForWorkspace, createGovernanceTrajectoryTurnReader, createConsentLedgerSourceMaterialAuthorization, createHostIntentDocReader, isAutomaticPainSubmissionAuthorized, saveHostToolDeclaration, HOST_TOOL_DECLARATION_VERSION, } from '@principles/host-runtime';
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';
@@ -310,6 +310,7 @@ export async function runCodexWorkspaceWorkerCycle(options) {
310
310
  stateManager: handle.stateManager,
311
311
  readTargetTurnEvidence: (sessionId, turnId) => readCodexTargetTurnEvidence(path.resolve(workspaceDir), sessionId, turnId),
312
312
  sourceMaterialAuthorization: createConsentLedgerSourceMaterialAuthorization(path.resolve(workspaceDir)),
313
+ hostKind: 'codex',
313
314
  nowIso: new Date().toISOString(),
314
315
  });
315
316
  if (targetEvidenceReconcile.flipped > 0 || targetEvidenceReconcile.blocked > 0 || targetEvidenceReconcile.errors.length > 0) {
@@ -320,6 +321,26 @@ export async function runCodexWorkspaceWorkerCycle(options) {
320
321
  const stateDir = path.join(workspaceDir, '.state');
321
322
  let releaseBridge;
322
323
  try {
324
+ // SPEC-PD-PIPELINE-SPINE-001 §4.2 (PRI-1292 Phase 2A): ONE assembly
325
+ // point for the five host collaborators. The trajectory reader and
326
+ // the source-material gate share the SAME consent-ledger
327
+ // authorization instance (previously two separate instances per
328
+ // call). PRI-1233 / SPEC §9.2: this worker is where Stage A
329
+ // actually runs for governance-admitted Codex pains; PRI-1265: the
330
+ // Stage A gets the bound session's ORIGINAL turns from the
331
+ // workspace's consent-tiered governance store.
332
+ const hostDeps = resolveWorkspacePipelineHostDeps({
333
+ workspaceDir,
334
+ effectiveConfig: config.effective,
335
+ telemetryPersistenceFailureHandler: (detail) => {
336
+ try {
337
+ emitEvent('CODEX_WORKER_CRITICAL_TELEMETRY_PERSIST_FAILED', detail);
338
+ }
339
+ catch {
340
+ // Telemetry persistence warnings must never fail the worker cycle.
341
+ }
342
+ },
343
+ });
323
344
  const bridge = await createPainSignalBridge({
324
345
  workspaceDir,
325
346
  stateDir,
@@ -327,18 +348,15 @@ export async function runCodexWorkspaceWorkerCycle(options) {
327
348
  owner: WORKER_OWNER,
328
349
  effectiveConfig: config.effective,
329
350
  getEnvVar: (name) => process.env[name],
330
- // PRI-1233 / SPEC §9.2: this worker is where Stage A actually runs
331
- // for governance-admitted Codex pains — the neutral host reader
332
- // must ride along (flag-off = zero filesystem access inside it).
333
- intentDocReader: createHostIntentDocReader({ workspaceDir, effectiveConfig: config.effective }),
334
- // PRI-1265: the worker's Stage A gets the bound session's ORIGINAL
335
- // turns from the workspace's own consent-tiered governance store.
336
- trajectoryTurnReader: createGovernanceTrajectoryTurnReader({ workspaceDir, sourceMaterialAuthorization: createConsentLedgerSourceMaterialAuthorization(workspaceDir) }),
337
- // PRI-1283 R2: latest-consent gate consulted per assembly / model call.
338
- sourceMaterialAuthorization: createConsentLedgerSourceMaterialAuthorization(workspaceDir),
351
+ intentDocReader: hostDeps.intentDocReader,
352
+ trajectoryTurnReader: hostDeps.trajectoryTurnReader,
353
+ sourceMaterialAuthorization: hostDeps.sourceMaterialAuthorization,
354
+ // PRI-939 Option A: allowlisted runner/bridge events persist to
355
+ // the workspace sink instead of the unsubscribed singleton.
356
+ telemetrySink: hostDeps.telemetrySink,
339
357
  // SPEC §9.6: lazy probe — a revoked flag stops persisted
340
358
  // automatic_hook tasks at the bridge's execution boundary.
341
- isAutoPainSubmissionAuthorized: () => isAutomaticPainSubmissionAuthorized(workspaceDir),
359
+ isAutoPainSubmissionAuthorized: hostDeps.isAutoPainSubmissionAuthorized,
342
360
  }, (release) => { releaseBridge = release; });
343
361
  const executed = await bridge.executePendingDiagnosis({ taskId: candidate.taskId });
344
362
  // PRI-917 v0.3.3 review fix (P2-2): forward the parked-candidate
@@ -421,6 +439,22 @@ export async function runCodexWorkspaceWorkerCycle(options) {
421
439
  const stateDir = path.join(workspaceDir, '.state');
422
440
  let releaseBridge;
423
441
  try {
442
+ // SPEC-PD-PIPELINE-SPINE-001 §4.2 (PRI-1292 Phase 2A): same single
443
+ // assembly point as the diagnosis site above — PRI-1265 authorized
444
+ // trajectory context, PRI-1283 R2 latest-consent gate, and the
445
+ // SAME consent-ledger authorization instance for both.
446
+ const hostDeps = resolveWorkspacePipelineHostDeps({
447
+ workspaceDir,
448
+ effectiveConfig: config.effective,
449
+ telemetryPersistenceFailureHandler: (detail) => {
450
+ try {
451
+ emitEvent('CODEX_WORKER_CRITICAL_TELEMETRY_PERSIST_FAILED', detail);
452
+ }
453
+ catch {
454
+ // Telemetry persistence warnings must never fail the worker cycle.
455
+ }
456
+ },
457
+ });
424
458
  const bridge = await createPainSignalBridge({
425
459
  workspaceDir,
426
460
  stateDir,
@@ -428,14 +462,15 @@ export async function runCodexWorkspaceWorkerCycle(options) {
428
462
  owner: WORKER_OWNER,
429
463
  effectiveConfig: config.effective,
430
464
  getEnvVar: (name) => process.env[name],
431
- // PRI-1265: post-processing resumes see the same authorized
432
- // trajectory context as the initial diagnosis run.
433
- trajectoryTurnReader: createGovernanceTrajectoryTurnReader({ workspaceDir, sourceMaterialAuthorization: createConsentLedgerSourceMaterialAuthorization(workspaceDir) }),
434
- // PRI-1283 R2: latest-consent gate consulted per assembly / model call.
435
- sourceMaterialAuthorization: createConsentLedgerSourceMaterialAuthorization(workspaceDir),
465
+ intentDocReader: hostDeps.intentDocReader,
466
+ trajectoryTurnReader: hostDeps.trajectoryTurnReader,
467
+ sourceMaterialAuthorization: hostDeps.sourceMaterialAuthorization,
468
+ // PRI-939 Option A: allowlisted runner/bridge events persist to
469
+ // the workspace sink instead of the unsubscribed singleton.
470
+ telemetrySink: hostDeps.telemetrySink,
436
471
  // SPEC §9.6: lazy probe — automatic_hook backlog resumes honor
437
472
  // the Workspace authorization too.
438
- isAutoPainSubmissionAuthorized: () => isAutomaticPainSubmissionAuthorized(workspaceDir),
473
+ isAutoPainSubmissionAuthorized: hostDeps.isAutoPainSubmissionAuthorized,
439
474
  }, (release) => { releaseBridge = release; });
440
475
  for (const item of backlog) {
441
476
  const resumed = await bridge.resumeSucceededDiagnosisPostProcessing({ taskId: item.taskId });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@principles/codex-adapter",
3
- "version": "0.15.0",
3
+ "version": "0.15.1",
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.2.0",
37
- "@principles/host-runtime": "^4.7.0",
38
- "@principles/install-layout": "^0.11.0"
36
+ "@principles/core": "^8.3.0",
37
+ "@principles/host-runtime": "^4.7.1",
38
+ "@principles/install-layout": "^0.11.1"
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": "06a20cb7842f41a6510937f92340343158164b9f"
55
+ "gitHead": "16f7e15c5832284db3836b8babed2b7980bca8c9"
56
56
  }