create-principles-disciple 1.155.2 → 1.156.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/_release/product-identity.json +2 -2
- package/codex-adapter/dist/ingestion/pain-receipt-fallback.d.ts +28 -1
- package/codex-adapter/dist/ingestion/pain-receipt-fallback.js +53 -17
- package/codex-adapter/dist/worker/workspace-worker.js +86 -66
- package/codex-adapter/package.json +1 -1
- package/console/dist/server/index.d.ts +11 -1
- package/console/dist/server/index.js +84 -19
- package/console/dist/server/release-handover.d.ts +256 -0
- package/console/dist/server/release-handover.js +402 -0
- package/console/dist/server/routes/onboarding.js +1 -0
- package/console/dist/server/routes/update-transaction.js +37 -3
- package/console/dist/server/routes/update.js +21 -1
- package/console/dist/server/successor.d.ts +46 -0
- package/console/dist/server/successor.js +128 -0
- package/console/dist/web/assets/app.css +18 -0
- package/console/dist/web/assets/app.js +32 -31
- package/console/package.json +2 -2
- package/core/dist/runtime/candidate-intake-service.d.ts +1 -1
- package/core/dist/runtime/candidate-intake-service.d.ts.map +1 -1
- package/core/dist/runtime/candidate-intake-service.js +89 -12
- package/core/dist/runtime/candidate-intake-service.js.map +1 -1
- package/core/dist/runtime/context-payload.d.ts +11 -0
- package/core/dist/runtime/context-payload.d.ts.map +1 -1
- package/core/dist/runtime/context-payload.js +27 -0
- package/core/dist/runtime/context-payload.js.map +1 -1
- package/core/dist/runtime/host-submission-context.d.ts +13 -6
- package/core/dist/runtime/host-submission-context.d.ts.map +1 -1
- package/core/dist/runtime/host-submission-context.js +77 -8
- package/core/dist/runtime/host-submission-context.js.map +1 -1
- package/core/dist/runtime/index.d.ts +2 -1
- package/core/dist/runtime/index.d.ts.map +1 -1
- package/core/dist/runtime/index.js +8 -0
- package/core/dist/runtime/index.js.map +1 -1
- package/core/dist/runtime/pain-ingress.d.ts +8 -0
- package/core/dist/runtime/pain-ingress.d.ts.map +1 -1
- package/core/dist/runtime/pain-ingress.js +8 -1
- package/core/dist/runtime/pain-ingress.js.map +1 -1
- package/core/dist/runtime/pain-recall-read-model.d.ts +72 -0
- package/core/dist/runtime/pain-recall-read-model.d.ts.map +1 -1
- package/core/dist/runtime/pain-recall-read-model.js +46 -21
- package/core/dist/runtime/pain-recall-read-model.js.map +1 -1
- package/core/dist/runtime/pain-receipt-recovery.d.ts +4 -1
- package/core/dist/runtime/pain-receipt-recovery.d.ts.map +1 -1
- package/core/dist/runtime/pain-receipt-recovery.js +28 -10
- package/core/dist/runtime/pain-receipt-recovery.js.map +1 -1
- package/core/dist/runtime/pain-signal-bridge.d.ts +38 -23
- package/core/dist/runtime/pain-signal-bridge.d.ts.map +1 -1
- package/core/dist/runtime/pain-signal-bridge.js +533 -182
- package/core/dist/runtime/pain-signal-bridge.js.map +1 -1
- package/core/dist/runtime/pain-signal-runtime-factory.d.ts +8 -1
- package/core/dist/runtime/pain-signal-runtime-factory.d.ts.map +1 -1
- package/core/dist/runtime/pain-signal-runtime-factory.js +196 -25
- package/core/dist/runtime/pain-signal-runtime-factory.js.map +1 -1
- package/core/dist/runtime/pain-target-evidence-reconcile.d.ts +78 -4
- package/core/dist/runtime/pain-target-evidence-reconcile.d.ts.map +1 -1
- package/core/dist/runtime/pain-target-evidence-reconcile.js +229 -18
- package/core/dist/runtime/pain-target-evidence-reconcile.js.map +1 -1
- package/core/dist/runtime/pain-to-principle-service.d.ts +26 -5
- package/core/dist/runtime/pain-to-principle-service.d.ts.map +1 -1
- package/core/dist/runtime/pain-to-principle-service.js +63 -52
- package/core/dist/runtime/pain-to-principle-service.js.map +1 -1
- package/core/dist/runtime/store/candidate/admission-document.d.ts +43 -0
- package/core/dist/runtime/store/candidate/admission-document.d.ts.map +1 -1
- package/core/dist/runtime/store/candidate/admission-document.js +130 -0
- package/core/dist/runtime/store/candidate/admission-document.js.map +1 -1
- package/core/dist/runtime/store/candidate/candidate-store.d.ts +3 -1
- package/core/dist/runtime/store/candidate/candidate-store.d.ts.map +1 -1
- package/core/dist/runtime/store/candidate/memory-candidate-store.d.ts +2 -1
- package/core/dist/runtime/store/candidate/memory-candidate-store.d.ts.map +1 -1
- package/core/dist/runtime/store/candidate/memory-candidate-store.js +27 -1
- package/core/dist/runtime/store/candidate/memory-candidate-store.js.map +1 -1
- package/core/dist/runtime/store/candidate/sqlite-candidate-store.d.ts +2 -1
- package/core/dist/runtime/store/candidate/sqlite-candidate-store.d.ts.map +1 -1
- package/core/dist/runtime/store/candidate/sqlite-candidate-store.js +59 -2
- package/core/dist/runtime/store/candidate/sqlite-candidate-store.js.map +1 -1
- package/core/dist/runtime/store/context/sqlite-context-assembler.d.ts.map +1 -1
- package/core/dist/runtime/store/context/sqlite-context-assembler.js +18 -3
- package/core/dist/runtime/store/context/sqlite-context-assembler.js.map +1 -1
- package/core/dist/runtime/store/runtime-state-manager.d.ts +2 -1
- package/core/dist/runtime/store/runtime-state-manager.d.ts.map +1 -1
- package/core/dist/runtime/store/runtime-state-manager.js +4 -0
- package/core/dist/runtime/store/runtime-state-manager.js.map +1 -1
- 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/package.json +1 -1
- package/dist/i18n.d.ts.map +1 -1
- package/dist/i18n.js +72 -0
- package/dist/i18n.js.map +1 -1
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +145 -35
- package/dist/index.js.map +1 -1
- package/dist/installer.d.ts +149 -9
- package/dist/installer.d.ts.map +1 -1
- package/dist/installer.js +562 -38
- package/dist/installer.js.map +1 -1
- package/dist/installers/codex-host-installer.js +1 -1
- package/dist/installers/codex-host-installer.js.map +1 -1
- package/dist/installers/index.d.ts +10 -0
- package/dist/installers/index.d.ts.map +1 -1
- package/dist/installers/index.js +4 -0
- package/dist/installers/index.js.map +1 -1
- package/dist/mvp-config.js +1 -1
- package/dist/mvp-config.js.map +1 -1
- package/dist/prompts.d.ts +36 -12
- package/dist/prompts.d.ts.map +1 -1
- package/dist/prompts.js +102 -30
- package/dist/prompts.js.map +1 -1
- package/dist/service-host-bridge.d.ts +71 -12
- package/dist/service-host-bridge.d.ts.map +1 -1
- package/dist/service-host-bridge.js +228 -48
- package/dist/service-host-bridge.js.map +1 -1
- package/dist/service-host-provisioning.d.ts +102 -0
- package/dist/service-host-provisioning.d.ts.map +1 -0
- package/dist/service-host-provisioning.js +595 -0
- package/dist/service-host-provisioning.js.map +1 -0
- package/dist/uninstaller.js +1 -1
- package/dist/uninstaller.js.map +1 -1
- package/dist/update/apply-payload.d.ts +9 -0
- package/dist/update/apply-payload.d.ts.map +1 -1
- package/dist/update/apply-payload.js +44 -2
- package/dist/update/apply-payload.js.map +1 -1
- package/dist/update/console-surface.d.ts +2 -1
- package/dist/update/console-surface.d.ts.map +1 -1
- package/dist/update/console-surface.js +6 -1
- package/dist/update/console-surface.js.map +1 -1
- package/dist/update/install-layout.d.ts +12 -0
- package/dist/update/install-layout.d.ts.map +1 -1
- package/dist/update/install-layout.js +49 -7
- package/dist/update/install-layout.js.map +1 -1
- package/dist/update/release-manager-authority.d.ts +16 -0
- package/dist/update/release-manager-authority.d.ts.map +1 -1
- package/dist/update/release-manager-authority.js +45 -3
- package/dist/update/release-manager-authority.js.map +1 -1
- package/dist/update/release-manager.d.ts +8 -3
- package/dist/update/release-manager.d.ts.map +1 -1
- package/dist/update/release-manager.js +29 -1
- package/dist/update/release-manager.js.map +1 -1
- package/dist/update/transaction-progress.d.ts +63 -0
- package/dist/update/transaction-progress.d.ts.map +1 -0
- package/dist/update/transaction-progress.js +207 -0
- package/dist/update/transaction-progress.js.map +1 -0
- package/dist/utils/env.d.ts +16 -1
- package/dist/utils/env.d.ts.map +1 -1
- package/dist/utils/env.js +55 -43
- package/dist/utils/env.js.map +1 -1
- package/host-runtime/dist/diagnostician-auto-run.js +37 -31
- package/host-runtime/dist/governance-observation-store.d.ts +38 -0
- package/host-runtime/dist/governance-observation-store.js +41 -0
- package/host-runtime/dist/governance-trajectory-turn-reader.js +26 -33
- package/host-runtime/package.json +1 -1
- package/install-layout/dist/background-execution-transition.d.ts +11 -1
- package/install-layout/dist/background-execution-transition.js +45 -1
- package/install-layout/dist/index.d.ts +3 -3
- package/install-layout/dist/index.js +10 -4
- package/install-layout/dist/pd-home.d.ts +12 -0
- package/install-layout/dist/pd-home.js +6 -1
- package/install-layout/package.json +1 -1
- package/package.json +10 -10
- package/pd-cli/dist/commands/candidate.d.ts +15 -0
- package/pd-cli/dist/commands/candidate.d.ts.map +1 -1
- package/pd-cli/dist/commands/candidate.js +449 -93
- package/pd-cli/dist/commands/candidate.js.map +1 -1
- package/pd-cli/dist/commands/console.d.ts.map +1 -1
- package/pd-cli/dist/commands/console.js +10 -0
- package/pd-cli/dist/commands/console.js.map +1 -1
- package/pd-cli/dist/commands/diagnose.d.ts.map +1 -1
- package/pd-cli/dist/commands/diagnose.js +254 -160
- package/pd-cli/dist/commands/diagnose.js.map +1 -1
- package/pd-cli/dist/commands/intake-outcome-guidance.d.ts +57 -0
- package/pd-cli/dist/commands/intake-outcome-guidance.d.ts.map +1 -0
- package/pd-cli/dist/commands/intake-outcome-guidance.js +206 -0
- package/pd-cli/dist/commands/intake-outcome-guidance.js.map +1 -0
- package/pd-cli/dist/commands/mcp-probe.d.ts.map +1 -1
- package/pd-cli/dist/commands/mcp-probe.js +1 -0
- package/pd-cli/dist/commands/mcp-probe.js.map +1 -1
- package/pd-cli/dist/commands/pain-record.d.ts.map +1 -1
- package/pd-cli/dist/commands/pain-record.js +18 -4
- package/pd-cli/dist/commands/pain-record.js.map +1 -1
- package/pd-cli/dist/commands/pain-retry.d.ts.map +1 -1
- package/pd-cli/dist/commands/pain-retry.js +91 -21
- package/pd-cli/dist/commands/pain-retry.js.map +1 -1
- package/pd-cli/dist/commands/runtime-uat.d.ts.map +1 -1
- package/pd-cli/dist/commands/runtime-uat.js +1 -0
- package/pd-cli/dist/commands/runtime-uat.js.map +1 -1
- package/pd-cli/dist/commands/service-lifecycle.js +1 -1
- package/pd-cli/dist/commands/service-lifecycle.js.map +1 -1
- package/pd-cli/dist/commands/service-run-once.d.ts +1 -1
- package/pd-cli/dist/commands/service-run-once.d.ts.map +1 -1
- package/pd-cli/dist/commands/service-run-once.js +9 -5
- package/pd-cli/dist/commands/service-run-once.js.map +1 -1
- package/pd-cli/dist/program.d.ts.map +1 -1
- package/pd-cli/dist/program.js +14 -3
- package/pd-cli/dist/program.js.map +1 -1
- package/pd-cli/dist/services/admission-write-gate.d.ts +4 -0
- package/pd-cli/dist/services/admission-write-gate.d.ts.map +1 -1
- package/pd-cli/dist/services/admission-write-gate.js +50 -48
- package/pd-cli/dist/services/admission-write-gate.js.map +1 -1
- package/pd-cli/dist/services/console-launcher.js +3 -3
- package/pd-cli/dist/services/console-launcher.js.map +1 -1
- package/pd-cli/dist/services/service-host/managed-run.d.ts.map +1 -1
- package/pd-cli/dist/services/service-host/managed-run.js +25 -8
- package/pd-cli/dist/services/service-host/managed-run.js.map +1 -1
- package/pd-cli/dist/services/service-host/scheduler/service-status.d.ts +12 -0
- package/pd-cli/dist/services/service-host/scheduler/service-status.d.ts.map +1 -1
- package/pd-cli/dist/services/service-host/scheduler/service-status.js +16 -7
- package/pd-cli/dist/services/service-host/scheduler/service-status.js.map +1 -1
- package/pd-cli/dist/services/service-host/status/service-run-status.d.ts +7 -5
- package/pd-cli/dist/services/service-host/status/service-run-status.d.ts.map +1 -1
- package/pd-cli/dist/services/service-host/status/service-run-status.js +1 -1
- package/pd-cli/dist/services/service-host/status/service-run-status.js.map +1 -1
- package/pd-cli/package.json +1 -1
- package/pd-mcp-server/dist/submit-assembly.js +61 -18
- 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 +1 -1
- package/plugin/dist/bundle.js +493 -493
- package/plugin/dist/openclaw-worker.js +263 -263
- package/plugin/dist/openclaw.plugin.json +1 -1
- package/plugin/openclaw.plugin.json +1 -1
- package/plugin/package.json +1 -1
- package/release-manager/dist/i18n.js +72 -0
- package/release-manager/dist/installer.js +562 -38
- package/release-manager/dist/installers/codex-host-installer.js +1 -1
- package/release-manager/dist/installers/index.js +4 -0
- package/release-manager/dist/mvp-config.js +1 -1
- package/release-manager/dist/service-host-bridge.js +228 -48
- package/release-manager/dist/service-host-provisioning.js +595 -0
- package/release-manager/dist/update/apply-payload.js +44 -2
- package/release-manager/dist/update/console-surface.js +6 -1
- package/release-manager/dist/update/install-layout.js +49 -7
- package/release-manager/dist/update/release-manager-authority.js +45 -3
- package/release-manager/dist/update/release-manager.js +29 -1
- package/release-manager/dist/update/transaction-progress.js +207 -0
- package/release-manager/dist/utils/env.js +55 -43
- package/release-manager/package.json +8 -8
- package/workbuddy-adapter/dist/codec/input-decoder.d.ts +21 -0
- package/workbuddy-adapter/dist/codec/input-decoder.js +50 -1
- package/workbuddy-adapter/dist/ingestion/pain-receipt-fallback.d.ts +68 -0
- package/workbuddy-adapter/dist/ingestion/pain-receipt-fallback.js +225 -0
- package/workbuddy-adapter/dist/pd-hook.js +60 -0
- package/workbuddy-adapter/dist/worker/workspace-worker.js +46 -44
- package/workbuddy-adapter/package.json +1 -1
- package/console/dist/server/utils/gateway.d.ts +0 -29
- package/console/dist/server/utils/gateway.js +0 -175
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { TargetTurnEvidenceRead } from '@principles/core/runtime';
|
|
1
2
|
import { type PainReceiptRecoveryOutcome } from '@principles/core/runtime';
|
|
2
3
|
/** The MCP tool id this fallback processes (the server gate lives in the
|
|
3
4
|
* codec parser — exact match on both namespace segments, never a pattern). */
|
|
@@ -25,12 +26,38 @@ export interface PainReceiptFallbackInput {
|
|
|
25
26
|
readonly minimalMetadataGranted: boolean;
|
|
26
27
|
readonly now?: () => Date;
|
|
27
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* PRI-1273 (A2): the structured target-turn evidence read the worker's
|
|
31
|
+
* waiting-task reconcile consumes. This is the EXACT-turn authority for the
|
|
32
|
+
* Codex host boundary:
|
|
33
|
+
*
|
|
34
|
+
* 1. the source-material consent ledger is consulted FIRST (PRI-1283 R2
|
|
35
|
+
* parity with the submit path): a missing / revoked / not-granted /
|
|
36
|
+
* unreadable decision returns `blocked_by_consent` BEFORE any store
|
|
37
|
+
* query — a denial is never mixed into the waiting set;
|
|
38
|
+
* 2. the governance store is queried for the EXACT (rollout identity, host
|
|
39
|
+
* turn id) — never a session scan, never the submission turn, never a
|
|
40
|
+
* recent-turn fallback;
|
|
41
|
+
* 3. rows keep the same retention/excerpt contract the submit path's
|
|
42
|
+
* enrichment uses (user/assistant turns, operational|promoted retention,
|
|
43
|
+
* `governance_observation:<logicalKey>` sourceRef, bounded note) so the
|
|
44
|
+
* backfilled entries are indistinguishable from submit-time evidence.
|
|
45
|
+
*
|
|
46
|
+
* Expired/purged rows (retention outside operational|promoted, empty text)
|
|
47
|
+
* simply do not qualify — an honest not_found until retention re-promotes
|
|
48
|
+
* or the turn is re-collected.
|
|
49
|
+
*/
|
|
50
|
+
export declare function readCodexTargetTurnEvidence(workspaceDir: string, sessionId: string, turnId: string): TargetTurnEvidenceRead;
|
|
28
51
|
/**
|
|
29
52
|
* P1-3: does the authorized governance store already hold readable text for
|
|
30
53
|
* the EXACT (session, turn)? Shared by the receipt fallback (disposition
|
|
31
54
|
* choice) and the workspace worker's waiting-task reconcile (the flip) —
|
|
32
55
|
* the diagnosis itself re-reads the turn through the same store.
|
|
33
|
-
* Unreadable ⇒ missing.
|
|
56
|
+
* Unreadable ⇒ missing. Since PRI-1273 this boolean is the `available`
|
|
57
|
+
* projection of the consent-gated structured read above: a consent denial
|
|
58
|
+
* reads as "not available", so the receipt fallback's waiting disposition
|
|
59
|
+
* is reclassified to `blocked_by_source_material_consent` by the worker
|
|
60
|
+
* reconcile on its next bounded pass.
|
|
34
61
|
*/
|
|
35
62
|
export declare function codexTargetTurnTextAvailable(workspaceDir: string, sessionId: string, turnId: string): boolean;
|
|
36
63
|
/**
|
|
@@ -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 {
|
|
31
|
+
import { 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';
|
|
@@ -80,32 +80,68 @@ function normalizeEventId(value, opts) {
|
|
|
80
80
|
return id.length > 0 && id.length <= 200 && !isSentinelSessionId(id) ? id : null;
|
|
81
81
|
}
|
|
82
82
|
/**
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
83
|
+
* PRI-1273 (A2): the structured target-turn evidence read the worker's
|
|
84
|
+
* waiting-task reconcile consumes. This is the EXACT-turn authority for the
|
|
85
|
+
* Codex host boundary:
|
|
86
|
+
*
|
|
87
|
+
* 1. the source-material consent ledger is consulted FIRST (PRI-1283 R2
|
|
88
|
+
* parity with the submit path): a missing / revoked / not-granted /
|
|
89
|
+
* unreadable decision returns `blocked_by_consent` BEFORE any store
|
|
90
|
+
* query — a denial is never mixed into the waiting set;
|
|
91
|
+
* 2. the governance store is queried for the EXACT (rollout identity, host
|
|
92
|
+
* turn id) — never a session scan, never the submission turn, never a
|
|
93
|
+
* recent-turn fallback;
|
|
94
|
+
* 3. rows keep the same retention/excerpt contract the submit path's
|
|
95
|
+
* enrichment uses (user/assistant turns, operational|promoted retention,
|
|
96
|
+
* `governance_observation:<logicalKey>` sourceRef, bounded note) so the
|
|
97
|
+
* backfilled entries are indistinguishable from submit-time evidence.
|
|
98
|
+
*
|
|
99
|
+
* Expired/purged rows (retention outside operational|promoted, empty text)
|
|
100
|
+
* simply do not qualify — an honest not_found until retention re-promotes
|
|
101
|
+
* or the turn is re-collected.
|
|
88
102
|
*/
|
|
89
|
-
export function
|
|
103
|
+
export function readCodexTargetTurnEvidence(workspaceDir, sessionId, turnId) {
|
|
104
|
+
const authorization = readSourceMaterialAuthorization({ workspaceDir, hostKind: 'codex' });
|
|
105
|
+
if (authorization.status === 'blocked') {
|
|
106
|
+
return { status: 'blocked_by_consent', reason: authorization.reason };
|
|
107
|
+
}
|
|
90
108
|
try {
|
|
91
|
-
const result =
|
|
109
|
+
const result = listGovernanceConversationTextsForHostTurn({
|
|
92
110
|
workspaceDir,
|
|
93
111
|
hostKind: 'codex',
|
|
94
112
|
rolloutIdentity: sessionId,
|
|
95
113
|
hostTurnId: turnId,
|
|
96
|
-
limit:
|
|
114
|
+
limit: 12,
|
|
97
115
|
});
|
|
98
|
-
if (!result.ok)
|
|
99
|
-
return
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
116
|
+
if (!result.ok) {
|
|
117
|
+
return { status: 'read_failed', reason: result.reason };
|
|
118
|
+
}
|
|
119
|
+
const entries = result.rows.map((row) => ({
|
|
120
|
+
sourceRef: 'governance_observation:' + row.logicalKey,
|
|
121
|
+
note: row.visibleText.slice(0, 2000),
|
|
122
|
+
}));
|
|
123
|
+
return entries.length > 0
|
|
124
|
+
? { status: 'available', entries }
|
|
125
|
+
: { status: 'not_found' };
|
|
104
126
|
}
|
|
105
|
-
catch {
|
|
106
|
-
return
|
|
127
|
+
catch (error) {
|
|
128
|
+
return { status: 'read_failed', reason: error instanceof Error ? error.message.slice(0, 120) : 'store_exception' };
|
|
107
129
|
}
|
|
108
130
|
}
|
|
131
|
+
/**
|
|
132
|
+
* P1-3: does the authorized governance store already hold readable text for
|
|
133
|
+
* the EXACT (session, turn)? Shared by the receipt fallback (disposition
|
|
134
|
+
* choice) and the workspace worker's waiting-task reconcile (the flip) —
|
|
135
|
+
* the diagnosis itself re-reads the turn through the same store.
|
|
136
|
+
* Unreadable ⇒ missing. Since PRI-1273 this boolean is the `available`
|
|
137
|
+
* projection of the consent-gated structured read above: a consent denial
|
|
138
|
+
* reads as "not available", so the receipt fallback's waiting disposition
|
|
139
|
+
* is reclassified to `blocked_by_source_material_consent` by the worker
|
|
140
|
+
* reconcile on its next bounded pass.
|
|
141
|
+
*/
|
|
142
|
+
export function codexTargetTurnTextAvailable(workspaceDir, sessionId, turnId) {
|
|
143
|
+
return readCodexTargetTurnEvidence(workspaceDir, sessionId, turnId).status === 'available';
|
|
144
|
+
}
|
|
109
145
|
/**
|
|
110
146
|
* Attempt the receipt fallback for one PostToolUse event. Never throws —
|
|
111
147
|
* every failure is a structured result the hook surfaces as one bounded
|
|
@@ -30,7 +30,7 @@ import path from 'node:path';
|
|
|
30
30
|
import { computeFeatureFlagsFromConfig, createRuntimeStateHandle, createPainSignalBridge, isRetryWaitBackoffElapsed, pickDiagnosticianCandidate, reconcileWaitingTargetEvidenceTasks, PrincipleTreeLedgerAdapter, resolveDiagnosticianCapability, } from '@principles/core/runtime';
|
|
31
31
|
import { createWorkspaceBehaviorEvidencePort, createCodexArtificerTrustedFactsPort, loadPdConfigForPlugin, loadFeatureFlagFromConfig, reconcileGovernanceContinuation, runInternalizationConsumerCycle, runStage2CorrectionCycle, createSignalClassifierForWorkspace, createGovernanceTrajectoryTurnReader, createConsentLedgerSourceMaterialAuthorization, createHostIntentDocReader, isAutomaticPainSubmissionAuthorized, saveHostToolDeclaration, HOST_TOOL_DECLARATION_VERSION, } from '@principles/host-runtime';
|
|
32
32
|
import { catchUpCodexIngestion } from '../ingestion/catch-up.js';
|
|
33
|
-
import {
|
|
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
|
const WORKER_OWNER = 'companion-worker';
|
|
36
36
|
const DEFAULT_DIAG_CANDIDATE_LIMIT = 5;
|
|
@@ -299,55 +299,69 @@ export async function runCodexWorkspaceWorkerCycle(options) {
|
|
|
299
299
|
// and the picker's SQL excludes anything still waiting. Bounded work
|
|
300
300
|
// over the existing task rows + the shared authorized-store probe;
|
|
301
301
|
// no new queue, no scheduler, no scanning of general history.
|
|
302
|
+
// PRI-1273 (A2): the probe is the consent-gated EXACT-turn read —
|
|
303
|
+
// the flip CAS backfills the arrived evidence + evidenceClass onto
|
|
304
|
+
// the SAME task, and a source-material denial reclassifies the task
|
|
305
|
+
// to blocked_by_source_material_consent instead of waiting.
|
|
306
|
+
// SPEC TD §2.2 ruling 4: the SAME consent ledger is read once more
|
|
307
|
+
// right before the evidence write (the existing PRI-1283 R2 port), so
|
|
308
|
+
// a revocation landing between the read and the write persists nothing.
|
|
302
309
|
targetEvidenceReconcile = await reconcileWaitingTargetEvidenceTasks({
|
|
303
310
|
stateManager: handle.stateManager,
|
|
304
|
-
|
|
311
|
+
readTargetTurnEvidence: (sessionId, turnId) => readCodexTargetTurnEvidence(path.resolve(workspaceDir), sessionId, turnId),
|
|
312
|
+
sourceMaterialAuthorization: createConsentLedgerSourceMaterialAuthorization(path.resolve(workspaceDir)),
|
|
305
313
|
nowIso: new Date().toISOString(),
|
|
306
314
|
});
|
|
307
|
-
if (targetEvidenceReconcile.flipped > 0 || targetEvidenceReconcile.errors.length > 0) {
|
|
315
|
+
if (targetEvidenceReconcile.flipped > 0 || targetEvidenceReconcile.blocked > 0 || targetEvidenceReconcile.errors.length > 0) {
|
|
308
316
|
emitEvent('CODEX_WORKER_TARGET_EVIDENCE_RECONCILE', JSON.stringify(targetEvidenceReconcile));
|
|
309
317
|
}
|
|
310
318
|
const candidate = await pickDiagnosticianCandidate(handle.stateManager, options.diagnosticianCandidateLimit ?? DEFAULT_DIAG_CANDIDATE_LIMIT, new Date().toISOString());
|
|
311
319
|
if (candidate !== null) {
|
|
312
320
|
const stateDir = path.join(workspaceDir, '.state');
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
.
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
321
|
+
let releaseBridge;
|
|
322
|
+
try {
|
|
323
|
+
const bridge = await createPainSignalBridge({
|
|
324
|
+
workspaceDir,
|
|
325
|
+
stateDir,
|
|
326
|
+
ledgerAdapter: new PrincipleTreeLedgerAdapter({ stateDir }),
|
|
327
|
+
owner: WORKER_OWNER,
|
|
328
|
+
effectiveConfig: config.effective,
|
|
329
|
+
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),
|
|
339
|
+
// SPEC §9.6: lazy probe — a revoked flag stops persisted
|
|
340
|
+
// automatic_hook tasks at the bridge's execution boundary.
|
|
341
|
+
isAutoPainSubmissionAuthorized: () => isAutomaticPainSubmissionAuthorized(workspaceDir),
|
|
342
|
+
}, (release) => { releaseBridge = release; });
|
|
343
|
+
const executed = await bridge.executePendingDiagnosis({ taskId: candidate.taskId });
|
|
344
|
+
// PRI-917 v0.3.3 review fix (P2-2): forward the parked-candidate
|
|
345
|
+
// dispositions so the Owner sees the pending items instead of a bare
|
|
346
|
+
// degraded status with no subject.
|
|
347
|
+
const reuseReviewRequired = (executed.candidateOutcomes ?? [])
|
|
348
|
+
.filter((outcome) => outcome.reason === 'reuse_review_required')
|
|
349
|
+
.map((outcome) => outcome.candidateId);
|
|
350
|
+
diagnostician = {
|
|
351
|
+
taskId: candidate.taskId,
|
|
352
|
+
status: executed.status,
|
|
353
|
+
...(executed.message !== undefined ? { message: executed.message.slice(0, 200) } : {}),
|
|
354
|
+
...(executed.errorCategory !== undefined ? { errorCategory: executed.errorCategory } : {}),
|
|
355
|
+
...(reuseReviewRequired.length > 0 ? { reuseReviewRequiredCandidateIds: reuseReviewRequired } : {}),
|
|
356
|
+
};
|
|
357
|
+
// The bridge stays cached per workspace (bounded: one per workspace
|
|
358
|
+
// per worker process, exactly like the OpenClaw plugin host) — no
|
|
359
|
+
// per-cycle dispose, so a concurrent cycle can never hit a disposed
|
|
360
|
+
// bridge. The factory self-disposes losing concurrent constructions.
|
|
361
|
+
}
|
|
362
|
+
finally {
|
|
363
|
+
await releaseBridge?.();
|
|
364
|
+
}
|
|
351
365
|
}
|
|
352
366
|
else {
|
|
353
367
|
// No eligible candidate, but a retry_wait task may still be inside
|
|
@@ -405,32 +419,38 @@ export async function runCodexWorkspaceWorkerCycle(options) {
|
|
|
405
419
|
const resumedTaskIds = new Set();
|
|
406
420
|
if (backlog.length > 0) {
|
|
407
421
|
const stateDir = path.join(workspaceDir, '.state');
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
422
|
+
let releaseBridge;
|
|
423
|
+
try {
|
|
424
|
+
const bridge = await createPainSignalBridge({
|
|
425
|
+
workspaceDir,
|
|
426
|
+
stateDir,
|
|
427
|
+
ledgerAdapter: new PrincipleTreeLedgerAdapter({ stateDir }),
|
|
428
|
+
owner: WORKER_OWNER,
|
|
429
|
+
effectiveConfig: config.effective,
|
|
430
|
+
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),
|
|
436
|
+
// SPEC §9.6: lazy probe — automatic_hook backlog resumes honor
|
|
437
|
+
// the Workspace authorization too.
|
|
438
|
+
isAutoPainSubmissionAuthorized: () => isAutomaticPainSubmissionAuthorized(workspaceDir),
|
|
439
|
+
}, (release) => { releaseBridge = release; });
|
|
440
|
+
for (const item of backlog) {
|
|
441
|
+
const resumed = await bridge.resumeSucceededDiagnosisPostProcessing({ taskId: item.taskId });
|
|
442
|
+
if (resumed.status === 'resumed') {
|
|
443
|
+
resumedTaskIds.add(item.taskId);
|
|
444
|
+
}
|
|
445
|
+
else if (resumed.status === 'blocked') {
|
|
446
|
+
blocked.push({ candidateId: item.candidateId, reason: resumed.reason ?? 'blocked' });
|
|
447
|
+
}
|
|
448
|
+
for (const skip of resumed.skipped ?? [])
|
|
449
|
+
blocked.push(skip);
|
|
428
450
|
}
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
for (const skip of resumed.skipped ?? [])
|
|
433
|
-
blocked.push(skip);
|
|
451
|
+
}
|
|
452
|
+
finally {
|
|
453
|
+
await releaseBridge?.();
|
|
434
454
|
}
|
|
435
455
|
}
|
|
436
456
|
postProcessing = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@principles/codex-adapter",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.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",
|
|
@@ -23,5 +23,15 @@ interface AppServices {
|
|
|
23
23
|
export declare function initServices(workspaceDir: string): Promise<AppServices>;
|
|
24
24
|
export declare function closeServices(): Promise<void>;
|
|
25
25
|
export declare function handleRequest(services: AppServices): (req: http.IncomingMessage, res: http.ServerResponse) => void;
|
|
26
|
-
|
|
26
|
+
/** How this process was asked to start; the defaults describe the packaged entry. */
|
|
27
|
+
export interface ConsoleLaunch {
|
|
28
|
+
/** The command line to serve with (`[node, entry, ...flags]`); defaults to this process's own. */
|
|
29
|
+
readonly argv?: readonly string[];
|
|
30
|
+
/**
|
|
31
|
+
* Successor mode (release handover): the predecessor is still releasing the
|
|
32
|
+
* port as this process boots, so "address in use" means "try again", not "stop".
|
|
33
|
+
*/
|
|
34
|
+
readonly keepTryingToBind?: boolean;
|
|
35
|
+
}
|
|
36
|
+
export declare function main(launch?: ConsoleLaunch): Promise<void>;
|
|
27
37
|
export {};
|
|
@@ -43,6 +43,8 @@ import { handleUpdateHistoryRoute, handleUpdateHistoryPruneRoute, reconcileUpdat
|
|
|
43
43
|
import { handleUpdateTransactionRoute } from './routes/update-transaction.js';
|
|
44
44
|
import { handleConfigRoute } from './routes/config.js';
|
|
45
45
|
import { sendJson, sendNotFound, sendError } from './utils/response.js';
|
|
46
|
+
import { activeReleaseRecordPath, getInstallLayoutPathsFromPdHome } from '@principles/install-layout';
|
|
47
|
+
import { consoleIdentityUrl, decideReleaseHandoverWatch, HANDOVER_BIND_WAIT_MS, HANDOVER_HEALTHY_TIMEOUT_MS, HANDOVER_RELISTEN_RETRY_MS, isInstalledConsoleCode, listenWithHandoverRetry, performReleaseHandover, probeConsolePid, startConsoleSuccessor, startReleaseHandoverWatch, stopSuccessor, waitUntilAnswer, } from './release-handover.js';
|
|
46
48
|
const __filename = fileURLToPath(import.meta.url);
|
|
47
49
|
const __dirname = path.dirname(__filename);
|
|
48
50
|
// WEB_ROOT calculation: server is at PKG_ROOT/dist/server/index.js
|
|
@@ -681,8 +683,7 @@ export function handleRequest(services) {
|
|
|
681
683
|
sendNotFound(res, 'Not found');
|
|
682
684
|
};
|
|
683
685
|
}
|
|
684
|
-
|
|
685
|
-
export async function main() {
|
|
686
|
+
export async function main(launch = {}) {
|
|
686
687
|
// PRI-872: resolve the PD home BEFORE anything else. Everything below
|
|
687
688
|
// (registry, update history, backups, gateway probes) derives from it, and a
|
|
688
689
|
// broken experiment configuration must stop the process here instead of
|
|
@@ -703,8 +704,9 @@ export async function main() {
|
|
|
703
704
|
}
|
|
704
705
|
throw error;
|
|
705
706
|
}
|
|
706
|
-
const
|
|
707
|
-
|
|
707
|
+
const argv = launch.argv === undefined ? process.argv : [...launch.argv];
|
|
708
|
+
const { workspace, port, host } = parseArgs(argv, pdHome.mode);
|
|
709
|
+
warnAboutLegacyAuthArgs(argv);
|
|
708
710
|
if (pdHome.mode === 'experiment') {
|
|
709
711
|
console.log(`[pd-console] Environment: experiment (PD_EXPERIMENT_ROOT=${pdHome.experimentRoot ?? ''})`);
|
|
710
712
|
console.log(`[pd-console] PD home: ${pdHome.pdHome}`);
|
|
@@ -739,24 +741,87 @@ export async function main() {
|
|
|
739
741
|
};
|
|
740
742
|
process.on('SIGTERM', () => { void shutdown('SIGTERM'); });
|
|
741
743
|
process.on('SIGINT', () => { void shutdown('SIGINT'); });
|
|
744
|
+
const stopAccepting = async () => {
|
|
745
|
+
await new Promise((resolve) => {
|
|
746
|
+
server.close(() => resolve());
|
|
747
|
+
// Keep-alive connections idle in a browser tab must not hold the port
|
|
748
|
+
// hostage; requests still in flight are left to finish, within a bound.
|
|
749
|
+
server.closeIdleConnections();
|
|
750
|
+
setTimeout(resolve, 2000).unref();
|
|
751
|
+
});
|
|
752
|
+
};
|
|
753
|
+
// Release handover: once this process is serving, it must not outlive the
|
|
754
|
+
// release it serves. The watch re-reads the active release record; when an
|
|
755
|
+
// update has replaced it, a successor on the installed code takes this port
|
|
756
|
+
// and this process exits (see release-handover.ts for the safety contract).
|
|
757
|
+
let watchingRelease = false;
|
|
758
|
+
// Only a console that IS the installed one may start "the successor beside
|
|
759
|
+
// this file" and call it the new release; decided once, at boot.
|
|
760
|
+
const handover = decideReleaseHandoverWatch(process.env, isInstalledConsoleCode(path.dirname(__filename), getInstallLayoutPathsFromPdHome(pdHome).consoleDir));
|
|
761
|
+
let handoverOffAnnounced = false;
|
|
762
|
+
/** The successor this process started, for as long as a called-off handover may have to stop it. */
|
|
763
|
+
let successor = null;
|
|
742
764
|
// PRI-872: a second instance on an occupied port must fail with an
|
|
743
765
|
// actionable message, not an unhandled 'error' stack. The usual cause is the
|
|
744
|
-
// production console already listening on 3100.
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
766
|
+
// production console already listening on 3100. A handover successor is the
|
|
767
|
+
// one legitimate second instance: it was started before its predecessor let
|
|
768
|
+
// go of the port, so for a bounded time it retries instead of giving up.
|
|
769
|
+
const listener = listenWithHandoverRetry({
|
|
770
|
+
server,
|
|
771
|
+
port,
|
|
772
|
+
host,
|
|
773
|
+
retryInUseForMs: launch.keepTryingToBind === true ? HANDOVER_BIND_WAIT_MS : 0,
|
|
774
|
+
onListening: () => {
|
|
775
|
+
console.log('[pd-console] Listening on http://' + host + ':' + port);
|
|
776
|
+
console.log('[pd-console] Workspace: ' + workspace);
|
|
777
|
+
console.log('[pd-console] Auth: none (local OS session)');
|
|
778
|
+
// rc-9: a console that will NOT hand itself over says so and why — the
|
|
779
|
+
// alternative is an update that quietly ends on "restart required".
|
|
780
|
+
if (!handover.watch) {
|
|
781
|
+
if (!handoverOffAnnounced) {
|
|
782
|
+
handoverOffAnnounced = true;
|
|
783
|
+
console.log(`[pd-console] Release handover off: ${handover.reason}.`);
|
|
784
|
+
}
|
|
785
|
+
return;
|
|
786
|
+
}
|
|
787
|
+
if (watchingRelease)
|
|
788
|
+
return;
|
|
789
|
+
watchingRelease = true;
|
|
790
|
+
startReleaseHandoverWatch({
|
|
791
|
+
recordPath: activeReleaseRecordPath(pdHome.pdHome),
|
|
792
|
+
onSuperseded: () => {
|
|
793
|
+
void performReleaseHandover({
|
|
794
|
+
log: (message) => console.log(message),
|
|
795
|
+
startSuccessor: () => {
|
|
796
|
+
successor = startConsoleSuccessor({ args: argv.slice(2) }, (message) => console.log(message));
|
|
797
|
+
return successor;
|
|
798
|
+
},
|
|
799
|
+
stopAccepting,
|
|
800
|
+
waitForSuccessor: () => waitUntilAnswer(() => probeConsolePid(consoleIdentityUrl(host, port), 1000), HANDOVER_HEALTHY_TIMEOUT_MS),
|
|
801
|
+
// Only the process this one started is ever stopped, and only when
|
|
802
|
+
// it failed to answer: it may be holding the port while it does.
|
|
803
|
+
abandonSuccessor: () => stopSuccessor(successor),
|
|
804
|
+
// A successor that was just stopped may still be letting go of the port.
|
|
805
|
+
resumeAccepting: () => listener.relisten(HANDOVER_RELISTEN_RETRY_MS),
|
|
806
|
+
exit: (code) => {
|
|
807
|
+
void closeServices().finally(() => process.exit(code));
|
|
808
|
+
},
|
|
809
|
+
});
|
|
810
|
+
},
|
|
811
|
+
});
|
|
812
|
+
},
|
|
813
|
+
giveUp: (error) => {
|
|
814
|
+
if (error.code === 'EADDRINUSE') {
|
|
815
|
+
console.error(`[pd-console] Port ${port} is already in use on ${host}.`);
|
|
816
|
+
console.error(pdHome.mode === 'production'
|
|
817
|
+
? `[pd-console] Another console is probably serving this installation. Stop it, or pick another port with --port.`
|
|
818
|
+
: `[pd-console] Stop the process holding the port, or pass a different --port (the experiment default is ${EXPERIMENT_CONSOLE_PORT}).`);
|
|
819
|
+
}
|
|
820
|
+
else {
|
|
821
|
+
console.error('[pd-console] Server error:', error);
|
|
822
|
+
}
|
|
751
823
|
process.exit(1);
|
|
752
|
-
}
|
|
753
|
-
console.error('[pd-console] Server error:', error);
|
|
754
|
-
process.exit(1);
|
|
755
|
-
});
|
|
756
|
-
server.listen(port, host, () => {
|
|
757
|
-
console.log('[pd-console] Listening on http://' + host + ':' + port);
|
|
758
|
-
console.log('[pd-console] Workspace: ' + workspace);
|
|
759
|
-
console.log('[pd-console] Auth: none (local OS session)');
|
|
824
|
+
},
|
|
760
825
|
});
|
|
761
826
|
}
|
|
762
827
|
// cli-7 / PRI-892 precedent: importing this module (a test driving
|