create-principles-disciple 1.147.0 → 1.147.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/_release/product-identity.json +1 -1
- package/codex-adapter/dist/ingestion/admission.d.ts +5 -10
- package/codex-adapter/dist/ingestion/admission.js +19 -77
- package/codex-adapter/dist/ingestion/explicit-owner-statement.js +1 -1
- package/codex-adapter/dist/ingestion/ingestion.d.ts +0 -2
- package/codex-adapter/dist/ingestion/ingestion.js +6 -4
- package/codex-adapter/dist/pd-hook.js +5 -7
- package/codex-adapter/package.json +1 -1
- package/console/dist/shared/prompt-injection-contract.d.ts +1 -1
- package/console/dist/web/assets/app.js +31 -31
- package/core/dist/prompt-builder/size-guard.d.ts.map +1 -1
- package/core/dist/prompt-builder/size-guard.js +6 -1
- package/core/dist/prompt-builder/size-guard.js.map +1 -1
- package/core/dist/prompt-builder/types.d.ts +2 -1
- package/core/dist/prompt-builder/types.d.ts.map +1 -1
- package/core/dist/runtime-v2/activation/prompt-activation-reader-contract.d.ts +12 -1
- package/core/dist/runtime-v2/activation/prompt-activation-reader-contract.d.ts.map +1 -1
- package/core/dist/runtime-v2/activation/prompt-activation-reader-contract.js +12 -1
- package/core/dist/runtime-v2/activation/prompt-activation-reader-contract.js.map +1 -1
- package/core/dist/runtime-v2/activation/prompt-budget-policy.d.ts +42 -11
- package/core/dist/runtime-v2/activation/prompt-budget-policy.d.ts.map +1 -1
- package/core/dist/runtime-v2/activation/prompt-budget-policy.js +82 -30
- package/core/dist/runtime-v2/activation/prompt-budget-policy.js.map +1 -1
- package/core/dist/runtime-v2/adapter/pi-ai-catalog.d.ts.map +1 -1
- package/core/dist/runtime-v2/adapter/pi-ai-catalog.js +17 -5
- package/core/dist/runtime-v2/adapter/pi-ai-catalog.js.map +1 -1
- package/core/dist/runtime-v2/evidence-triage/index.d.ts +0 -1
- package/core/dist/runtime-v2/evidence-triage/index.d.ts.map +1 -1
- package/core/dist/runtime-v2/evidence-triage/index.js +0 -2
- package/core/dist/runtime-v2/evidence-triage/index.js.map +1 -1
- package/core/dist/runtime-v2/evidence-triage/source-descriptors.d.ts +3 -8
- package/core/dist/runtime-v2/evidence-triage/source-descriptors.d.ts.map +1 -1
- package/core/dist/runtime-v2/evidence-triage/source-descriptors.js +5 -17
- package/core/dist/runtime-v2/evidence-triage/source-descriptors.js.map +1 -1
- package/core/dist/runtime-v2/evidence-triage/triage-policy.d.ts +11 -9
- package/core/dist/runtime-v2/evidence-triage/triage-policy.d.ts.map +1 -1
- package/core/dist/runtime-v2/evidence-triage/triage-policy.js +10 -103
- package/core/dist/runtime-v2/evidence-triage/triage-policy.js.map +1 -1
- package/core/dist/runtime-v2/evidence-triage/trigger-controller.js +1 -1
- package/core/dist/runtime-v2/evidence-triage/trigger-controller.js.map +1 -1
- package/core/dist/runtime-v2/evidence-triage/types.d.ts +4 -16
- package/core/dist/runtime-v2/evidence-triage/types.d.ts.map +1 -1
- package/core/dist/runtime-v2/evidence-triage/types.js.map +1 -1
- package/core/dist/runtime-v2/index.d.ts +1 -1
- package/core/dist/runtime-v2/index.d.ts.map +1 -1
- package/core/dist/runtime-v2/index.js +1 -1
- package/core/dist/runtime-v2/index.js.map +1 -1
- package/core/dist/runtime-v2/intent/intent-friction-block.d.ts +2 -2
- package/core/dist/runtime-v2/intent/intent-friction-block.js +2 -2
- package/core/dist/runtime-v2/types/event-types.d.ts +2 -2
- package/core/dist/runtime-v2/types/event-types.d.ts.map +1 -1
- package/core/dist/runtime-v2/types/event-types.js +1 -0
- package/core/dist/runtime-v2/types/event-types.js.map +1 -1
- package/core/package.json +1 -1
- package/host-runtime/dist/governance-signal-admission.d.ts +1 -77
- package/host-runtime/dist/governance-signal-admission.js +34 -294
- package/host-runtime/dist/production-pain-evidence.d.ts +8 -69
- package/host-runtime/dist/production-pain-evidence.js +19 -157
- package/host-runtime/dist/prompt-injection-budget-observation.js +4 -2
- package/host-runtime/package.json +1 -1
- package/package.json +3 -3
- package/pd-cli/package.json +1 -1
- 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 +411 -412
- package/plugin/dist/governance-audit.js +2 -2
- package/plugin/dist/hooks/after-tool-call-helpers.d.ts +2 -35
- package/plugin/dist/hooks/after-tool-call-types.d.ts +1 -30
- package/plugin/dist/hooks/pain.d.ts +6 -19
- package/plugin/dist/hooks/trajectory-evidence.d.ts +3 -10
- package/plugin/dist/hooks/triage-adapter.d.ts +7 -20
- package/plugin/dist/host-runtime/openclaw-host-runtime.d.ts +0 -1
- package/plugin/dist/openclaw.plugin.json +1 -1
- package/plugin/openclaw.plugin.json +1 -1
- package/plugin/package.json +1 -1
- package/release-manager/package.json +1 -1
- package/workbuddy-adapter/dist/codec/input-decoder.js +3 -1
- package/workbuddy-adapter/dist/pd-hook.js +0 -26
- package/workbuddy-adapter/dist/worker/workspace-worker.d.ts +1 -7
- package/workbuddy-adapter/dist/worker/workspace-worker.js +11 -21
- package/workbuddy-adapter/package.json +1 -1
|
@@ -29,17 +29,12 @@ export declare function buildLiveCorrectionCandidate(args: {
|
|
|
29
29
|
fields: PayloadFields;
|
|
30
30
|
rolloutIdentity: string;
|
|
31
31
|
}): GovernanceSignalCandidate | null;
|
|
32
|
-
/** Live PostToolUse payload → tool-failure candidate (logical key mirrors the observation). */
|
|
33
|
-
export declare function buildLiveToolCandidate(args: {
|
|
34
|
-
fields: PayloadFields;
|
|
35
|
-
rolloutIdentity: string;
|
|
36
|
-
projectDir?: string;
|
|
37
|
-
}): GovernanceSignalCandidate | null;
|
|
38
32
|
/**
|
|
39
|
-
* Decoded transcript observations → candidates.
|
|
40
|
-
* tool
|
|
41
|
-
* the
|
|
42
|
-
*
|
|
33
|
+
* Decoded transcript observations → candidates. Only user turns produce
|
|
34
|
+
* candidates: tool-call observations remain technical trajectory (recorded by
|
|
35
|
+
* the workflow's own writers), never a behavioral-deviation Pain by themselves.
|
|
36
|
+
* The logical keys are the decoded ones, so a replay of an already-admitted
|
|
37
|
+
* live event is an observation-level no-op (SPEC §10).
|
|
43
38
|
*/
|
|
44
39
|
export declare function buildTranscriptCandidates(observations: readonly GovernanceObservationInput[]): readonly GovernanceSignalCandidate[];
|
|
45
40
|
/**
|
|
@@ -14,9 +14,6 @@
|
|
|
14
14
|
* authority exists here.
|
|
15
15
|
*/
|
|
16
16
|
import { admitGovernanceSignals, ensureGovernanceContinuation, } from '@principles/host-runtime';
|
|
17
|
-
import { isRecord, own } from './ingestion-fields.js';
|
|
18
|
-
/** The live host-event source used by the identity derivation (parity with the dispatch handler). */
|
|
19
|
-
const CODEX_POST_TOOL_USE_SOURCE = 'codex:post_tool_use';
|
|
20
17
|
/** Live UserPromptSubmit payload → correction candidate (logical key mirrors the observation). */
|
|
21
18
|
export function buildLiveCorrectionCandidate(args) {
|
|
22
19
|
const { fields } = args;
|
|
@@ -33,85 +30,30 @@ export function buildLiveCorrectionCandidate(args) {
|
|
|
33
30
|
observedAt: new Date().toISOString(),
|
|
34
31
|
};
|
|
35
32
|
}
|
|
36
|
-
/** Live PostToolUse payload → tool-failure candidate (logical key mirrors the observation). */
|
|
37
|
-
export function buildLiveToolCandidate(args) {
|
|
38
|
-
const { fields } = args;
|
|
39
|
-
if (fields.turnId === null || fields.toolUseId === null)
|
|
40
|
-
return null;
|
|
41
|
-
return {
|
|
42
|
-
kind: 'tool_failure',
|
|
43
|
-
hostKind: 'codex',
|
|
44
|
-
logicalObservationKey: `codex|${args.rolloutIdentity}|${fields.toolUseId}`,
|
|
45
|
-
rolloutIdentity: args.rolloutIdentity,
|
|
46
|
-
rootSessionId: fields.sessionId,
|
|
47
|
-
hostTurnId: fields.turnId,
|
|
48
|
-
toolName: fields.toolName ?? '',
|
|
49
|
-
source: CODEX_POST_TOOL_USE_SOURCE,
|
|
50
|
-
// Merge semantics (WorkBuddy × SPEC-CODEX-PAIN-CLOSURE-001): the same host
|
|
51
|
-
// `tool_use_id` feeds TWO consumers, so the candidate carries both views.
|
|
52
|
-
// I1 identity parity — the live handler derives the canonical pain from the
|
|
53
|
-
// same tool_use_id, so `toolCallId` must be present (one real call → one
|
|
54
|
-
// canonical pain across the admission + dispatch deliveries).
|
|
55
|
-
toolCallId: fields.toolUseId,
|
|
56
|
-
// CR-01 — `toolUseId` is recorded into tool_calls.tool_use_id and used for
|
|
57
|
-
// the admission dedup join against the live PostToolUse row.
|
|
58
|
-
toolUseId: fields.toolUseId,
|
|
59
|
-
...(args.projectDir !== undefined ? { projectDir: args.projectDir } : {}),
|
|
60
|
-
...(fields.toolInput !== undefined ? { toolInput: fields.toolInput } : {}),
|
|
61
|
-
...(fields.toolResponse !== undefined ? { toolOutput: fields.toolResponse } : {}),
|
|
62
|
-
observedAt: new Date().toISOString(),
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
33
|
/**
|
|
66
|
-
* Decoded transcript observations → candidates.
|
|
67
|
-
* tool
|
|
68
|
-
* the
|
|
69
|
-
*
|
|
34
|
+
* Decoded transcript observations → candidates. Only user turns produce
|
|
35
|
+
* candidates: tool-call observations remain technical trajectory (recorded by
|
|
36
|
+
* the workflow's own writers), never a behavioral-deviation Pain by themselves.
|
|
37
|
+
* The logical keys are the decoded ones, so a replay of an already-admitted
|
|
38
|
+
* live event is an observation-level no-op (SPEC §10).
|
|
70
39
|
*/
|
|
71
40
|
export function buildTranscriptCandidates(observations) {
|
|
72
41
|
const candidates = [];
|
|
73
42
|
for (const observation of observations) {
|
|
74
|
-
if (observation.kind
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
else if (observation.kind === 'tool_call') {
|
|
89
|
-
const facts = observation.toolFacts;
|
|
90
|
-
if (!isRecord(facts))
|
|
91
|
-
continue;
|
|
92
|
-
const toolName = own(facts, 'toolName');
|
|
93
|
-
const exitCode = own(facts, 'exitCode');
|
|
94
|
-
candidates.push({
|
|
95
|
-
kind: 'tool_failure',
|
|
96
|
-
hostKind: 'codex',
|
|
97
|
-
logicalObservationKey: observation.logicalObservationKey,
|
|
98
|
-
rolloutIdentity: observation.rolloutIdentity,
|
|
99
|
-
rootSessionId: observation.rootSessionId,
|
|
100
|
-
hostTurnId: observation.hostTurnId,
|
|
101
|
-
toolName: typeof toolName === 'string' ? toolName : '',
|
|
102
|
-
source: CODEX_POST_TOOL_USE_SOURCE,
|
|
103
|
-
// Merge semantics: both merged views of the same host tool_use_id.
|
|
104
|
-
// I1 identity parity — the decoded observation carries the same
|
|
105
|
-
// tool_use_id the live delivery derived its canonical pain from, so a
|
|
106
|
-
// transcript replay converges on that pain instead of a second one.
|
|
107
|
-
...(typeof observation.toolUseId === 'string' && observation.toolUseId.length > 0 ? { toolCallId: observation.toolUseId } : {}),
|
|
108
|
-
// CR-01 — recorded into tool_calls.tool_use_id for the dedup join.
|
|
109
|
-
...(observation.toolUseId !== undefined ? { toolUseId: observation.toolUseId } : {}),
|
|
110
|
-
toolInput: own(facts, 'command') ?? null,
|
|
111
|
-
...(exitCode !== undefined ? { toolOutput: { exitCode, stdout: own(facts, 'stdout') ?? null, stderr: own(facts, 'stderr') ?? null } } : {}),
|
|
112
|
-
observedAt: observation.observedAt,
|
|
113
|
-
});
|
|
114
|
-
}
|
|
43
|
+
if (observation.kind !== 'user_turn')
|
|
44
|
+
continue;
|
|
45
|
+
if (observation.visibleText === undefined)
|
|
46
|
+
continue;
|
|
47
|
+
candidates.push({
|
|
48
|
+
kind: 'user_correction',
|
|
49
|
+
hostKind: 'codex',
|
|
50
|
+
logicalObservationKey: observation.logicalObservationKey,
|
|
51
|
+
rolloutIdentity: observation.rolloutIdentity,
|
|
52
|
+
rootSessionId: observation.rootSessionId,
|
|
53
|
+
hostTurnId: observation.hostTurnId,
|
|
54
|
+
text: observation.visibleText,
|
|
55
|
+
observedAt: observation.observedAt,
|
|
56
|
+
});
|
|
115
57
|
}
|
|
116
58
|
return candidates;
|
|
117
59
|
}
|
|
@@ -78,7 +78,7 @@ export async function recordExplicitOwnerStatement(args) {
|
|
|
78
78
|
if (outcome === undefined || !('disposition' in outcome)) {
|
|
79
79
|
return { status: 'rejected', reason: 'continuation_failed', nextAction: 'The governance admission returned no disposition; nothing was recorded.' };
|
|
80
80
|
}
|
|
81
|
-
if (outcome.disposition === 'not_a_signal'
|
|
81
|
+
if (outcome.disposition === 'not_a_signal') {
|
|
82
82
|
return { status: 'rejected', reason: 'continuation_failed', nextAction: 'reason' in outcome ? String(outcome.reason) : 'the signal was not admitted' };
|
|
83
83
|
}
|
|
84
84
|
if (outcome.disposition === 'rate_limited') {
|
|
@@ -23,8 +23,6 @@ import { type GovernanceSignalCandidate } from '@principles/host-runtime';
|
|
|
23
23
|
import { type TranscriptPort } from './transcript-decoder.js';
|
|
24
24
|
export interface CodexIngestionOptions {
|
|
25
25
|
readonly workspaceDir: string;
|
|
26
|
-
/** Native live-hook cwd; intentionally omitted for transcript catch-up. */
|
|
27
|
-
readonly projectDir?: string;
|
|
28
26
|
readonly env?: {
|
|
29
27
|
CODEX_HOME?: string | undefined;
|
|
30
28
|
};
|
|
@@ -4,7 +4,7 @@ import { validateCodexTranscriptPath } from './transcript-path.js';
|
|
|
4
4
|
import { classifyCodexVersion, CODEX_VERSION_NEXT_ACTION } from './codex-version.js';
|
|
5
5
|
import { decodeTranscriptWindow, createNodeTranscriptPort, CODEX_INGESTION_MAX_BATCH_BYTES, TranscriptReplacedError } from './transcript-decoder.js';
|
|
6
6
|
import { extractFields } from './ingestion-fields.js';
|
|
7
|
-
import { buildLiveCorrectionCandidate,
|
|
7
|
+
import { buildLiveCorrectionCandidate, buildTranscriptCandidates } from './admission.js';
|
|
8
8
|
let activePort = null;
|
|
9
9
|
/** Test seam: inject/inspect the transcript filesystem boundary (zero-read proofs). */
|
|
10
10
|
export function setCodexTranscriptPortForTest(port) {
|
|
@@ -13,7 +13,7 @@ export function setCodexTranscriptPortForTest(port) {
|
|
|
13
13
|
function activeTranscriptPort(options) {
|
|
14
14
|
return options.port ?? activePort ?? createNodeTranscriptPort();
|
|
15
15
|
}
|
|
16
|
-
function ingestLiveObservation({ fields, rolloutIdentity, workspaceDir,
|
|
16
|
+
function ingestLiveObservation({ fields, rolloutIdentity, workspaceDir, now }) {
|
|
17
17
|
const nowIso = now.toISOString();
|
|
18
18
|
let observation = null;
|
|
19
19
|
if (fields.turnId !== null && fields.prompt !== null) {
|
|
@@ -61,9 +61,11 @@ function ingestLiveObservation({ fields, rolloutIdentity, workspaceDir, projectD
|
|
|
61
61
|
return { status: 'degraded', reason: result.reason ?? 'governance_write_failed', nextAction: result.nextAction ?? 'inspect the workspace trajectory database.', warnings: result.warnings };
|
|
62
62
|
// Slice B: hand the live observation to the admission pass as a normalized
|
|
63
63
|
// candidate (SPEC §12) — the caller (pd-hook) runs detection/admission.
|
|
64
|
+
// Phase A: tool-call observations stay technical trajectory only; they never
|
|
65
|
+
// become a behavioral-deviation Pain candidate by themselves.
|
|
64
66
|
const candidate = observation.kind === 'user_turn'
|
|
65
67
|
? buildLiveCorrectionCandidate({ fields, rolloutIdentity })
|
|
66
|
-
:
|
|
68
|
+
: null;
|
|
67
69
|
return {
|
|
68
70
|
status: 'ok', inserted: result.inserted, enriched: result.enriched, duplicates: result.duplicates, warnings: result.warnings, lagBytes: 0,
|
|
69
71
|
admissionCandidates: candidate !== null ? [candidate] : [],
|
|
@@ -258,7 +260,7 @@ export function ingestCodexConversation(rawPayload, kind, options) {
|
|
|
258
260
|
return { status: 'degraded', reason: validated.reason, nextAction: validated.nextAction, warnings: [] };
|
|
259
261
|
const now = options.now ?? new Date();
|
|
260
262
|
if (kind === 'before_prompt_build' || kind === 'after_tool_call') {
|
|
261
|
-
return ingestLiveObservation({ fields, rolloutIdentity: validated.rolloutIdentity, workspaceDir: options.workspaceDir,
|
|
263
|
+
return ingestLiveObservation({ fields, rolloutIdentity: validated.rolloutIdentity, workspaceDir: options.workspaceDir, now });
|
|
262
264
|
}
|
|
263
265
|
return ingestTranscriptDelta({
|
|
264
266
|
fallbackRootSessionId: fields.sessionId,
|
|
@@ -151,17 +151,16 @@ function recordRuleHostEvaluations(stateDir, sessionId, evaluations) {
|
|
|
151
151
|
// Runs only when BOTH host.codex and codex_conversation_ingestion are
|
|
152
152
|
// enabled — the flag gate below happens BEFORE any transcript path
|
|
153
153
|
// validation or filesystem I/O, so flag-off means the transcript boundary
|
|
154
|
-
// receives zero calls (SPEC §10 hard privacy invariant). Admission
|
|
155
|
-
//
|
|
156
|
-
//
|
|
157
|
-
// then converges to a no-op (exactly one pain per real tool call).
|
|
154
|
+
// receives zero calls (SPEC §10 hard privacy invariant). Admission covers
|
|
155
|
+
// Owner corrections only: tool-call facts stay technical trajectory and never
|
|
156
|
+
// become a behavioral-deviation Pain by themselves (Phase A).
|
|
158
157
|
async function runConversationIngestion(args) {
|
|
159
|
-
const { rawPayload, kind, workspaceDir,
|
|
158
|
+
const { rawPayload, kind, workspaceDir, env } = args;
|
|
160
159
|
if (kind !== 'turn_complete' && kind !== 'before_prompt_build' && kind !== 'after_tool_call')
|
|
161
160
|
return [];
|
|
162
161
|
const diagnostics = [];
|
|
163
162
|
try {
|
|
164
|
-
const outcome = ingestCodexConversation(rawPayload, kind, { workspaceDir,
|
|
163
|
+
const outcome = ingestCodexConversation(rawPayload, kind, { workspaceDir, env });
|
|
165
164
|
if (outcome.status === 'degraded') {
|
|
166
165
|
diagnostics.push(diagnostic(outcome.reason, outcome.nextAction));
|
|
167
166
|
}
|
|
@@ -334,7 +333,6 @@ export async function processHookInvocation(rawStdin, _env = process.env, cwd =
|
|
|
334
333
|
rawPayload: parsed,
|
|
335
334
|
kind: event.kind,
|
|
336
335
|
workspaceDir: resolution.workspaceDir,
|
|
337
|
-
projectDir: requestedCwd,
|
|
338
336
|
env: _env,
|
|
339
337
|
// CR-07: the prefix parse above already decided this turn's user
|
|
340
338
|
// prompt belongs to the explicit path — suppress the generic
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@principles/codex-adapter",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.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",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
export type PromptInjectionTargetHostName = 'openclaw' | 'codex' | 'workbuddy';
|
|
16
16
|
export type PromptInjectionRouteName = 'legacy_trim' | 'shared_render';
|
|
17
17
|
export type PromptInjectionBudgetScopeName = 'selected_lines' | 'full_directive_context';
|
|
18
|
-
export type PromptBudgetCapacitySourceWire = 'operator_declared' | 'host_effective_window' | 'pi_catalog_exact' | 'legacy_fallback';
|
|
18
|
+
export type PromptBudgetCapacitySourceWire = 'operator_declared' | 'host_effective_window' | 'pi_catalog_exact' | 'pi_catalog_model_id' | 'legacy_fallback';
|
|
19
19
|
export type PromptBudgetCapacityStatusWire = 'confirmed' | 'unknown';
|
|
20
20
|
/**
|
|
21
21
|
* Bounded machine-readable fallback reason. Closed set mirroring the core
|