create-principles-disciple 1.145.0 → 1.145.3
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/LICENSE +73 -21
- package/NOTICE +2 -0
- package/README.md +1 -1
- package/_release/product-identity.json +2 -2
- package/codex-adapter/package.json +5 -3
- package/console/dist/server/models/ApprovalsGroupedConsoleModel.js +4 -4
- package/console/dist/ui/i18n/en.json +17 -16
- package/console/dist/ui/i18n/zh-CN.json +17 -16
- package/console/dist/ui/pages/focus/FocusPage.js +9 -5
- package/console/dist/ui/pages/focus/OwnerDecisionCard.js +1 -1
- package/console/dist/ui/pages/principles/PrincipleDetailPage.js +10 -4
- package/console/dist/ui/pages/principles/PrinciplesPage.js +1 -1
- package/console/dist/ui/utils/reading-layout.d.ts +19 -0
- package/console/dist/ui/utils/reading-layout.js +46 -0
- package/console/dist/web/assets/app.js +30 -28
- package/console/package.json +2 -1
- package/core/dist/runtime-v2/index.d.ts +10 -0
- package/core/dist/runtime-v2/index.d.ts.map +1 -1
- package/core/dist/runtime-v2/index.js +5 -0
- package/core/dist/runtime-v2/index.js.map +1 -1
- package/core/dist/runtime-v2/internalization/artificer-prompt-builder.d.ts +25 -6
- package/core/dist/runtime-v2/internalization/artificer-prompt-builder.d.ts.map +1 -1
- package/core/dist/runtime-v2/internalization/artificer-prompt-builder.js +21 -7
- package/core/dist/runtime-v2/internalization/artificer-prompt-builder.js.map +1 -1
- package/core/dist/runtime-v2/internalization/artificer-run-correlation.d.ts +82 -0
- package/core/dist/runtime-v2/internalization/artificer-run-correlation.d.ts.map +1 -0
- package/core/dist/runtime-v2/internalization/artificer-run-correlation.js +79 -0
- package/core/dist/runtime-v2/internalization/artificer-run-correlation.js.map +1 -0
- package/core/dist/runtime-v2/internalization/artificer-runner.d.ts +16 -2
- package/core/dist/runtime-v2/internalization/artificer-runner.d.ts.map +1 -1
- package/core/dist/runtime-v2/internalization/artificer-runner.js +89 -9
- package/core/dist/runtime-v2/internalization/artificer-runner.js.map +1 -1
- package/core/dist/runtime-v2/internalization/consumer-evidence-preflight.d.ts +141 -0
- package/core/dist/runtime-v2/internalization/consumer-evidence-preflight.d.ts.map +1 -0
- package/core/dist/runtime-v2/internalization/consumer-evidence-preflight.js +284 -0
- package/core/dist/runtime-v2/internalization/consumer-evidence-preflight.js.map +1 -0
- package/core/dist/runtime-v2/internalization/evidence-readiness.d.ts +170 -0
- package/core/dist/runtime-v2/internalization/evidence-readiness.d.ts.map +1 -0
- package/core/dist/runtime-v2/internalization/evidence-readiness.js +335 -0
- package/core/dist/runtime-v2/internalization/evidence-readiness.js.map +1 -0
- package/core/dist/runtime-v2/internalization/owner-evidence-recovery.d.ts +190 -0
- package/core/dist/runtime-v2/internalization/owner-evidence-recovery.d.ts.map +1 -0
- package/core/dist/runtime-v2/internalization/owner-evidence-recovery.js +488 -0
- package/core/dist/runtime-v2/internalization/owner-evidence-recovery.js.map +1 -0
- package/core/dist/runtime-v2/internalization/owner-retry.d.ts +23 -1
- package/core/dist/runtime-v2/internalization/owner-retry.d.ts.map +1 -1
- package/core/dist/runtime-v2/internalization/owner-retry.js +19 -3
- package/core/dist/runtime-v2/internalization/owner-retry.js.map +1 -1
- package/core/dist/runtime-v2/internalization/peer-runner-contracts.d.ts +8 -0
- package/core/dist/runtime-v2/internalization/peer-runner-contracts.d.ts.map +1 -1
- package/core/dist/runtime-v2/internalization/peer-runner-contracts.js.map +1 -1
- package/core/dist/runtime-v2/internalization/pitask-metadata.d.ts +12 -0
- package/core/dist/runtime-v2/internalization/pitask-metadata.d.ts.map +1 -1
- package/core/dist/runtime-v2/internalization/pitask-metadata.js +24 -0
- package/core/dist/runtime-v2/internalization/pitask-metadata.js.map +1 -1
- package/core/dist/runtime-v2/recovery-actions-log.d.ts +40 -0
- package/core/dist/runtime-v2/recovery-actions-log.d.ts.map +1 -1
- package/core/dist/runtime-v2/recovery-actions-log.js +77 -2
- package/core/dist/runtime-v2/recovery-actions-log.js.map +1 -1
- package/core/dist/runtime-v2/store/runtime-state-manager.d.ts +6 -1
- package/core/dist/runtime-v2/store/runtime-state-manager.d.ts.map +1 -1
- package/core/dist/runtime-v2/store/runtime-state-manager.js +6 -2
- package/core/dist/runtime-v2/store/runtime-state-manager.js.map +1 -1
- package/core/dist/runtime-v2/store/task/memory-task-store.d.ts +3 -1
- package/core/dist/runtime-v2/store/task/memory-task-store.d.ts.map +1 -1
- package/core/dist/runtime-v2/store/task/memory-task-store.js +6 -1
- package/core/dist/runtime-v2/store/task/memory-task-store.js.map +1 -1
- package/core/dist/runtime-v2/store/task/sqlite-task-store.d.ts +3 -1
- package/core/dist/runtime-v2/store/task/sqlite-task-store.d.ts.map +1 -1
- package/core/dist/runtime-v2/store/task/sqlite-task-store.js +10 -2
- package/core/dist/runtime-v2/store/task/sqlite-task-store.js.map +1 -1
- package/core/dist/runtime-v2/store/task/task-store.d.ts +11 -5
- package/core/dist/runtime-v2/store/task/task-store.d.ts.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 +13 -0
- package/core/dist/telemetry-event.js.map +1 -1
- package/core/package.json +9 -3
- package/dist/installers/workbuddy-host-installer.d.ts +16 -3
- package/dist/installers/workbuddy-host-installer.d.ts.map +1 -1
- package/dist/installers/workbuddy-host-installer.js +57 -10
- package/dist/installers/workbuddy-host-installer.js.map +1 -1
- package/host-runtime/dist/internalization-consumer-cycle.d.ts +12 -1
- package/host-runtime/dist/internalization-consumer-cycle.js +141 -16
- package/host-runtime/dist/workspace-telemetry-emitter.js +13 -0
- package/host-runtime/package.json +5 -3
- package/install-layout/package.json +5 -3
- package/package.json +6 -5
- package/pd-cli/dist/commands/runtime-internalization-audit-artificer-evidence.d.ts +44 -0
- package/pd-cli/dist/commands/runtime-internalization-audit-artificer-evidence.d.ts.map +1 -0
- package/pd-cli/dist/commands/runtime-internalization-audit-artificer-evidence.js +138 -0
- package/pd-cli/dist/commands/runtime-internalization-audit-artificer-evidence.js.map +1 -0
- package/pd-cli/dist/commands/runtime-internalization-evidence.d.ts +72 -0
- package/pd-cli/dist/commands/runtime-internalization-evidence.d.ts.map +1 -0
- package/pd-cli/dist/commands/runtime-internalization-evidence.js +424 -0
- package/pd-cli/dist/commands/runtime-internalization-evidence.js.map +1 -0
- package/pd-cli/dist/commands/runtime-internalization-run-once.d.ts.map +1 -1
- package/pd-cli/dist/commands/runtime-internalization-run-once.js +22 -1
- package/pd-cli/dist/commands/runtime-internalization-run-once.js.map +1 -1
- package/pd-cli/dist/commands/runtime-internalization-run-rulehost.d.ts.map +1 -1
- package/pd-cli/dist/commands/runtime-internalization-run-rulehost.js +45 -4
- package/pd-cli/dist/commands/runtime-internalization-run-rulehost.js.map +1 -1
- package/pd-cli/dist/index.js +8 -0
- package/pd-cli/dist/index.js.map +1 -1
- package/pd-cli/dist/services/artificer-evidence-audit.d.ts +156 -0
- package/pd-cli/dist/services/artificer-evidence-audit.d.ts.map +1 -0
- package/pd-cli/dist/services/artificer-evidence-audit.js +321 -0
- package/pd-cli/dist/services/artificer-evidence-audit.js.map +1 -0
- package/pd-cli/dist/services/rulehost-pipeline-runner.d.ts.map +1 -1
- package/pd-cli/dist/services/rulehost-pipeline-runner.js +17 -3
- package/pd-cli/dist/services/rulehost-pipeline-runner.js.map +1 -1
- package/pd-cli/package.json +5 -3
- package/plugin/dist/bundle.js +491 -491
- package/plugin/dist/openclaw.plugin.json +1 -1
- package/plugin/dist/rulehost-evidence.js +26 -26
- package/plugin/openclaw.plugin.json +1 -1
- package/plugin/package.json +5 -3
- package/release-manager/dist/installers/workbuddy-host-installer.d.ts +16 -3
- package/release-manager/dist/installers/workbuddy-host-installer.d.ts.map +1 -1
- package/release-manager/dist/installers/workbuddy-host-installer.js +57 -10
- package/release-manager/dist/installers/workbuddy-host-installer.js.map +1 -1
- package/release-manager/package.json +5 -4
- package/workbuddy-adapter/package.json +5 -3
- package/console/dist/ui/utils/navigation.d.ts +0 -9
- package/console/dist/ui/utils/navigation.js +0 -7
- package/core/dist/runtime-v2/internalization/dimension-coverage-policy.d.ts +0 -54
- package/core/dist/runtime-v2/internalization/dimension-coverage-policy.d.ts.map +0 -1
- package/core/dist/runtime-v2/internalization/dimension-coverage-policy.js +0 -70
- package/core/dist/runtime-v2/internalization/dimension-coverage-policy.js.map +0 -1
|
@@ -0,0 +1,488 @@
|
|
|
1
|
+
import { PDRuntimeError } from '../error-categories.js';
|
|
2
|
+
import { createPITaskDiagnosticJson, hydratePITaskRecord, mergePITaskMetadata, } from './pitask-metadata.js';
|
|
3
|
+
import { assessEvidenceReadiness, validateOwnerEvidenceSelectionShape, } from './evidence-readiness.js';
|
|
4
|
+
import { resolveArtificerCanonicalPainId } from './consumer-evidence-preflight.js';
|
|
5
|
+
import { buildArtificerRunCorrelation } from './artificer-run-correlation.js';
|
|
6
|
+
import { ownerRetryNeedsHumanReviewTask } from './owner-retry.js';
|
|
7
|
+
import { appendOwnerEvidenceAction } from '../recovery-actions-log.js';
|
|
8
|
+
// ── evidence-waiting task identification (FR-06 1/2) ────────────────────────
|
|
9
|
+
/**
|
|
10
|
+
* FR-04: a task is "waiting for Owner evidence" iff it sits in
|
|
11
|
+
* needs_human_review with one of the four stable reason codes in its
|
|
12
|
+
* humanReviewContext. Other NHR tasks (verdict reviews etc.) are NOT
|
|
13
|
+
* evidence-waiting and are never touched by this module.
|
|
14
|
+
*/
|
|
15
|
+
export const EVIDENCE_WAIT_REASON_CODES = new Set([
|
|
16
|
+
'owner_behavior_examples_required',
|
|
17
|
+
'owner_behavior_examples_invalid',
|
|
18
|
+
'owner_behavior_examples_stale',
|
|
19
|
+
'owner_behavior_examples_scope_mismatch',
|
|
20
|
+
]);
|
|
21
|
+
/** Field names whose absence the readiness gate reports (FR-06 2). */
|
|
22
|
+
const SELECTION_FIELD_NAMES = [
|
|
23
|
+
'sourcePainId',
|
|
24
|
+
'sourceNegativeToolCallId',
|
|
25
|
+
'positiveToolCallIds',
|
|
26
|
+
'ownerDesiredOutcome',
|
|
27
|
+
];
|
|
28
|
+
function nextActionForReasonCode(reasonCode) {
|
|
29
|
+
switch (reasonCode) {
|
|
30
|
+
case 'owner_behavior_examples_required':
|
|
31
|
+
return 'Attach evidence (dry-run by default): pd runtime internalization evidence attach --task <taskId> --pain <canonicalPainId> --negative <toolCallId> --positive <id>... --outcome "<desired behavior>" — then resume with evidence resume --confirm.';
|
|
32
|
+
case 'owner_behavior_examples_invalid':
|
|
33
|
+
return 'The stored selection failed validation; re-attach a corrected selection with evidence attach --confirm (revision increments), then resume.';
|
|
34
|
+
case 'owner_behavior_examples_stale':
|
|
35
|
+
return 'The referenced trajectory changed or was cleaned; re-attach fresh examples with evidence attach --confirm, then resume (resume refuses stale digests).';
|
|
36
|
+
case 'owner_behavior_examples_scope_mismatch':
|
|
37
|
+
return 'The selection references another pain/session; re-attach examples that belong to the referenced pain session, then resume.';
|
|
38
|
+
default:
|
|
39
|
+
return 'Inspect the task: pd runtime internalization queue --json';
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* FR-06 1/2: list Artificer tasks waiting for Owner evidence. Read-only;
|
|
44
|
+
* non-artificer or non-evidence NHR tasks are not listed. Hydration
|
|
45
|
+
* failures are skipped (the task is not listable as evidence-waiting —
|
|
46
|
+
* `pd runtime internalization integrity` is the surface for those).
|
|
47
|
+
*/
|
|
48
|
+
// ── shared helpers ──────────────────────────────────────────────────────────
|
|
49
|
+
function hydrateOrNull(task) {
|
|
50
|
+
return hydratePITaskRecord(task);
|
|
51
|
+
}
|
|
52
|
+
function readDiagnosticJson(task) {
|
|
53
|
+
const raw = task.diagnosticJson;
|
|
54
|
+
return typeof raw === 'string' && raw.trim() !== '' ? raw : null;
|
|
55
|
+
}
|
|
56
|
+
export async function listEvidenceWaitingTasks(stateManager) {
|
|
57
|
+
const tasks = await stateManager.listTasks({ status: 'needs_human_review', taskKind: 'artificer' });
|
|
58
|
+
const summaries = [];
|
|
59
|
+
for (const task of tasks) {
|
|
60
|
+
const piTask = hydrateOrNull(task);
|
|
61
|
+
if (!piTask)
|
|
62
|
+
continue;
|
|
63
|
+
const context = piTask.humanReviewContext;
|
|
64
|
+
if (!context || !EVIDENCE_WAIT_REASON_CODES.has(context.reasonCode))
|
|
65
|
+
continue;
|
|
66
|
+
const selection = piTask.ownerEvidenceSelection;
|
|
67
|
+
summaries.push({
|
|
68
|
+
taskId: task.taskId,
|
|
69
|
+
channel: piTask.channel,
|
|
70
|
+
painId: selection?.sourcePainId ?? null,
|
|
71
|
+
reasonCode: context.reasonCode,
|
|
72
|
+
missingFields: context.reasonCode === 'owner_behavior_examples_required'
|
|
73
|
+
? SELECTION_FIELD_NAMES
|
|
74
|
+
: [],
|
|
75
|
+
nextAction: nextActionForReasonCode(context.reasonCode),
|
|
76
|
+
attemptCount: task.attemptCount,
|
|
77
|
+
maxAttempts: task.maxAttempts,
|
|
78
|
+
evidenceRevision: selection?.revision ?? 0,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
return summaries;
|
|
82
|
+
}
|
|
83
|
+
function ownerOperationLabel(decidedBy) {
|
|
84
|
+
return decidedBy !== undefined && decidedBy.trim() !== '' ? `cli:attach:${decidedBy.trim()}` : 'cli:attach';
|
|
85
|
+
}
|
|
86
|
+
async function loadEvidenceTask(stateManager, taskId) {
|
|
87
|
+
const task = await stateManager.getTask(taskId);
|
|
88
|
+
if (!task) {
|
|
89
|
+
return { ok: false, refusal: { status: 'refused', taskId, reason: 'task_not_found', nextAction: 'Verify the task id and workspace (pd runtime internalization queue --json).' } };
|
|
90
|
+
}
|
|
91
|
+
if (task.status !== 'needs_human_review') {
|
|
92
|
+
return {
|
|
93
|
+
ok: false,
|
|
94
|
+
refusal: {
|
|
95
|
+
status: 'refused',
|
|
96
|
+
taskId,
|
|
97
|
+
reason: 'task_not_needs_human_review',
|
|
98
|
+
// PRI-980 review P2-2: name the REAL out-chain — a terminal-failed
|
|
99
|
+
// task (e.g. the run-once input_invalid landing) must first be
|
|
100
|
+
// recovered to pending before the consumer preflight can park it
|
|
101
|
+
// here for evidence attach.
|
|
102
|
+
nextAction: 'Only needs_human_review tasks waiting for Owner evidence accept this operation (pd runtime internalization evidence list). '
|
|
103
|
+
+ 'A failed task returns to pending via pd runtime recovery failed-tasks --confirm; the consumer evidence preflight then parks it in needs_human_review for evidence attach.',
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
const piTask = hydrateOrNull(task);
|
|
108
|
+
if (!piTask) {
|
|
109
|
+
return {
|
|
110
|
+
ok: false,
|
|
111
|
+
refusal: {
|
|
112
|
+
status: 'refused',
|
|
113
|
+
taskId,
|
|
114
|
+
reason: 'metadata_invalid',
|
|
115
|
+
nextAction: 'Task metadata failed PI hydration; inspect with pd runtime internalization integrity --json before any owner action.',
|
|
116
|
+
},
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
const context = piTask.humanReviewContext;
|
|
120
|
+
if (!context || !EVIDENCE_WAIT_REASON_CODES.has(context.reasonCode)) {
|
|
121
|
+
return {
|
|
122
|
+
ok: false,
|
|
123
|
+
refusal: {
|
|
124
|
+
status: 'refused',
|
|
125
|
+
taskId,
|
|
126
|
+
reason: 'not_evidence_review',
|
|
127
|
+
nextAction: 'This needs_human_review task is not an evidence review (verdict/decision tasks use the governance focus or pd runtime internalization retry).',
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
return { ok: true, task, piTask };
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* FR-03/FR-06 3-6: assemble + validate the Owner selection, then persist it
|
|
135
|
+
* (with revision/contentDigest/ownerOperation/attachedAt) into
|
|
136
|
+
* `pi_metadata.ownerEvidenceSelection` via the narrow diagnosticJson CAS.
|
|
137
|
+
* Dry-run assembles and reports without writing ANY state (cli-5); failures
|
|
138
|
+
* refuse with the stable FR-04 reason codes and zero mutation.
|
|
139
|
+
*/
|
|
140
|
+
export async function attachOwnerEvidence(stateManager, input) {
|
|
141
|
+
const loaded = await loadEvidenceTask(stateManager, input.taskId);
|
|
142
|
+
if (loaded.ok === false)
|
|
143
|
+
return loaded.refusal;
|
|
144
|
+
const { task, piTask } = loaded;
|
|
145
|
+
const canonicalPainId = await resolveArtificerCanonicalPainId(input.taskId, (id) => stateManager.getTask(id));
|
|
146
|
+
if (canonicalPainId === null || canonicalPainId !== input.selection.sourcePainId) {
|
|
147
|
+
return {
|
|
148
|
+
status: 'refused',
|
|
149
|
+
taskId: input.taskId,
|
|
150
|
+
reason: 'owner_behavior_examples_scope_mismatch',
|
|
151
|
+
nextAction: 'Selected Pain must match the task canonical seed Pain; inspect the task lineage before attaching evidence.',
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
// One shared judgment: shape → assembly → pack contract (ready ⇒ pack +
|
|
155
|
+
// digest). The shape check runs first even in dry-run so an unusable
|
|
156
|
+
// selection refuses before any assembly I/O.
|
|
157
|
+
const selectionProblems = validateOwnerEvidenceSelectionShape(input.selection);
|
|
158
|
+
if (selectionProblems.length > 0) {
|
|
159
|
+
return {
|
|
160
|
+
status: 'refused',
|
|
161
|
+
taskId: input.taskId,
|
|
162
|
+
reason: 'owner_behavior_examples_invalid',
|
|
163
|
+
detail: selectionProblems.join('; '),
|
|
164
|
+
nextAction: 'Provide a positive safe integer negative tool call id, 1..3 unique positive positive ids, and a non-empty outcome text.',
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
const readiness = assessEvidenceReadiness({
|
|
168
|
+
channelRequiresOwnerEvidence: true,
|
|
169
|
+
ownerSelection: input.selection,
|
|
170
|
+
assemblePack: () => input.assemble.assemble(input.selection),
|
|
171
|
+
});
|
|
172
|
+
if (readiness.status !== 'ready') {
|
|
173
|
+
if (readiness.status === 'owner_evidence_required') {
|
|
174
|
+
// Unreachable: the caller provided the selection above.
|
|
175
|
+
return {
|
|
176
|
+
status: 'refused',
|
|
177
|
+
taskId: input.taskId,
|
|
178
|
+
reason: 'owner_behavior_examples_invalid',
|
|
179
|
+
nextAction: 'Provide the complete Owner selection.',
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
if (readiness.status === 'not_applicable') {
|
|
183
|
+
return {
|
|
184
|
+
status: 'refused',
|
|
185
|
+
taskId: input.taskId,
|
|
186
|
+
reason: 'owner_behavior_examples_invalid',
|
|
187
|
+
nextAction: 'Evidence gate returned not_applicable — caller bug (channel is hard-required for attach).',
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
if (readiness.status === 'evidence_source_error') {
|
|
191
|
+
// PRI-980 review P2-1 (SPEC §6.2 case 3): a trajectory-store I/O fault
|
|
192
|
+
// is not an Owner evidence fault — the refusal carries the storage
|
|
193
|
+
// reason verbatim and mutates nothing (attach is zero-mutation until
|
|
194
|
+
// its CAS anyway; cli-5).
|
|
195
|
+
return {
|
|
196
|
+
status: 'refused',
|
|
197
|
+
taskId: input.taskId,
|
|
198
|
+
reason: readiness.reason,
|
|
199
|
+
detail: readiness.detail,
|
|
200
|
+
nextAction: readiness.nextAction,
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
return {
|
|
204
|
+
status: 'refused',
|
|
205
|
+
taskId: input.taskId,
|
|
206
|
+
reason: readiness.reasonCode,
|
|
207
|
+
detail: readiness.detail,
|
|
208
|
+
nextAction: readiness.nextAction,
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
const previousRevision = piTask.ownerEvidenceSelection?.revision ?? 0;
|
|
212
|
+
const revision = previousRevision + 1;
|
|
213
|
+
const ownerOperation = ownerOperationLabel(input.decidedBy);
|
|
214
|
+
const attachedAt = new Date().toISOString();
|
|
215
|
+
const persisted = {
|
|
216
|
+
...input.selection,
|
|
217
|
+
revision,
|
|
218
|
+
contentDigest: readiness.evidenceHash,
|
|
219
|
+
ownerOperation,
|
|
220
|
+
attachedAt,
|
|
221
|
+
};
|
|
222
|
+
if (input.mode === 'dry_run') {
|
|
223
|
+
return {
|
|
224
|
+
status: 'dry_run',
|
|
225
|
+
taskId: input.taskId,
|
|
226
|
+
painId: persisted.sourcePainId,
|
|
227
|
+
wouldPersist: {
|
|
228
|
+
revision,
|
|
229
|
+
contentDigest: readiness.evidenceHash,
|
|
230
|
+
ownerOperation,
|
|
231
|
+
attachedAt,
|
|
232
|
+
},
|
|
233
|
+
nextAction: 'Dry-run only — nothing was written. Re-run with --confirm to attach this selection (the task stays needs_human_review until evidence resume --confirm).',
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
// Narrow CAS: single conditional UPDATE on diagnostic_json (status untouched
|
|
237
|
+
// — attach must not unblock). A concurrent writer between our read and write
|
|
238
|
+
// makes us lose the CAS and refuse observably instead of clobbering.
|
|
239
|
+
const merged = mergePITaskMetadata(piTask, { ownerEvidenceSelection: persisted });
|
|
240
|
+
const updated = await stateManager.updateTaskIfDiagnosticJsonUnchanged(input.taskId, readDiagnosticJson(task), { diagnosticJson: createPITaskDiagnosticJson(merged) }, { expectedStatus: 'needs_human_review' });
|
|
241
|
+
if (!updated) {
|
|
242
|
+
return {
|
|
243
|
+
status: 'conflict',
|
|
244
|
+
taskId: input.taskId,
|
|
245
|
+
nextAction: 'The task row changed concurrently; re-run evidence list / attach (the CAS refused this write — nothing was mutated).',
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
// Read-back invariant (EP-07): only a durable effect may be reported.
|
|
249
|
+
const reread = await stateManager.getTask(input.taskId);
|
|
250
|
+
const rereadPi = reread ? hydrateOrNull(reread) : null;
|
|
251
|
+
if (reread === null || rereadPi === null || rereadPi.ownerEvidenceSelection?.revision !== revision
|
|
252
|
+
|| rereadPi.ownerEvidenceSelection.contentDigest !== readiness.evidenceHash) {
|
|
253
|
+
throw new PDRuntimeError('storage_unavailable', `owner evidence attach not durable for task ${input.taskId} (read-back revision/digest mismatch)`);
|
|
254
|
+
}
|
|
255
|
+
appendOwnerEvidenceAction(input.workspaceDir, {
|
|
256
|
+
taskId: input.taskId,
|
|
257
|
+
action: 'attach_evidence',
|
|
258
|
+
painId: persisted.sourcePainId,
|
|
259
|
+
revision,
|
|
260
|
+
contentDigest: readiness.evidenceHash,
|
|
261
|
+
operator: input.decidedBy ?? null,
|
|
262
|
+
});
|
|
263
|
+
input.eventEmitter.emitTelemetry({
|
|
264
|
+
eventType: 'artificer_owner_evidence_attached',
|
|
265
|
+
traceId: input.taskId,
|
|
266
|
+
timestamp: attachedAt,
|
|
267
|
+
sessionId: input.owner,
|
|
268
|
+
agentId: 'artificer',
|
|
269
|
+
payload: {
|
|
270
|
+
// FR-08 run-correlation block (PRI-984): attach never leases an NHR
|
|
271
|
+
// task → persistentRunId/adapterRunId are semantically absent.
|
|
272
|
+
...buildArtificerRunCorrelation({
|
|
273
|
+
taskId: input.taskId,
|
|
274
|
+
attemptNumber: task.attemptCount, // attach never touches the budget — real value at write time
|
|
275
|
+
executionMode: 'recovery',
|
|
276
|
+
reasonCode: 'attached', // no failure reason code exists → the operation status
|
|
277
|
+
workspaceDir: input.workspaceDir,
|
|
278
|
+
evidenceDigest: readiness.evidenceHash,
|
|
279
|
+
}),
|
|
280
|
+
painId: persisted.sourcePainId,
|
|
281
|
+
revision,
|
|
282
|
+
contentDigest: readiness.evidenceHash,
|
|
283
|
+
ownerOperation,
|
|
284
|
+
taskStillNeedsHumanReview: true,
|
|
285
|
+
},
|
|
286
|
+
});
|
|
287
|
+
return {
|
|
288
|
+
status: 'attached',
|
|
289
|
+
taskId: input.taskId,
|
|
290
|
+
revision,
|
|
291
|
+
contentDigest: readiness.evidenceHash,
|
|
292
|
+
ownerOperation,
|
|
293
|
+
attachedAt,
|
|
294
|
+
taskStillNeedsHumanReview: true,
|
|
295
|
+
nextAction: 'Selection attached (task still needs_human_review). Verify with evidence resume (dry-run), then execute: pd runtime internalization evidence resume --task <taskId> --confirm.',
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* FR-06 7/8: digest-verified, atomic, single-authority recovery.
|
|
300
|
+
*
|
|
301
|
+
* Sequence: NHR + evidence-code gate → stored selection present → re-assemble
|
|
302
|
+
* through the shared readiness judgment → digest comparison (mismatch ⇒
|
|
303
|
+
* `owner_behavior_examples_stale`, missing digest ⇒ `invalid`) → ONE
|
|
304
|
+
* conditional authority reset via `ownerRetryNeedsHumanReviewTask` (CAS
|
|
305
|
+
* option; loser gets `conflict`). Run history / audit records are never
|
|
306
|
+
* deleted; the attempt budget reset is explicit and audited (see header).
|
|
307
|
+
*/
|
|
308
|
+
export async function resumeOwnerEvidenceTask(stateManager, input) {
|
|
309
|
+
const loaded = await loadEvidenceTask(stateManager, input.taskId);
|
|
310
|
+
if (loaded.ok === false)
|
|
311
|
+
return loaded.refusal;
|
|
312
|
+
const { task, piTask } = loaded;
|
|
313
|
+
const previousAttemptCount = task.attemptCount;
|
|
314
|
+
const selection = piTask.ownerEvidenceSelection;
|
|
315
|
+
if (selection === undefined) {
|
|
316
|
+
return {
|
|
317
|
+
status: 'refused',
|
|
318
|
+
taskId: input.taskId,
|
|
319
|
+
reason: 'owner_behavior_examples_required',
|
|
320
|
+
nextAction: 'No evidence selection is attached yet; run evidence attach (dry-run by default) first.',
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
const canonicalPainId = await resolveArtificerCanonicalPainId(input.taskId, (id) => stateManager.getTask(id));
|
|
324
|
+
if (canonicalPainId === null || canonicalPainId !== selection.sourcePainId) {
|
|
325
|
+
return {
|
|
326
|
+
status: 'refused',
|
|
327
|
+
taskId: input.taskId,
|
|
328
|
+
reason: 'owner_behavior_examples_scope_mismatch',
|
|
329
|
+
nextAction: 'Owner evidence does not match the canonical task Pain; re-attach evidence for this task lineage.',
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
const readiness = assessEvidenceReadiness({
|
|
333
|
+
channelRequiresOwnerEvidence: true,
|
|
334
|
+
ownerSelection: selection,
|
|
335
|
+
assemblePack: () => input.assemble.assemble(selection),
|
|
336
|
+
});
|
|
337
|
+
if (readiness.status !== 'ready') {
|
|
338
|
+
if (readiness.status === 'owner_evidence_required' || readiness.status === 'not_applicable') {
|
|
339
|
+
return {
|
|
340
|
+
status: 'refused',
|
|
341
|
+
taskId: input.taskId,
|
|
342
|
+
reason: 'owner_behavior_examples_invalid',
|
|
343
|
+
nextAction: 'Stored selection is unusable; re-attach with evidence attach --confirm.',
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
if (readiness.status === 'evidence_source_error') {
|
|
347
|
+
// PRI-980 review P2-1 (SPEC §6.2 case 3): a storage fault during the
|
|
348
|
+
// re-assembly must not read as a stale/invalid Owner selection. The
|
|
349
|
+
// task STAYS needs_human_review with its existing owner-fault reason
|
|
350
|
+
// untouched — the refusal reports the storage reason so the operator
|
|
351
|
+
// can retry when the store recovers.
|
|
352
|
+
return {
|
|
353
|
+
status: 'refused',
|
|
354
|
+
taskId: input.taskId,
|
|
355
|
+
reason: readiness.reason,
|
|
356
|
+
detail: readiness.detail,
|
|
357
|
+
nextAction: readiness.nextAction,
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
return {
|
|
361
|
+
status: 'refused',
|
|
362
|
+
taskId: input.taskId,
|
|
363
|
+
reason: readiness.reasonCode,
|
|
364
|
+
detail: readiness.detail,
|
|
365
|
+
nextAction: readiness.nextAction,
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
if (selection.contentDigest === undefined) {
|
|
369
|
+
return {
|
|
370
|
+
status: 'refused',
|
|
371
|
+
taskId: input.taskId,
|
|
372
|
+
reason: 'owner_behavior_examples_invalid',
|
|
373
|
+
detail: 'stored selection carries no contentDigest (legacy pre-B1 record); resume cannot verify it',
|
|
374
|
+
nextAction: 'Re-attach the selection with evidence attach --confirm (this upgrades it to a digest-verified revision), then resume.',
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
if (readiness.evidenceHash !== selection.contentDigest) {
|
|
378
|
+
return {
|
|
379
|
+
status: 'refused',
|
|
380
|
+
taskId: input.taskId,
|
|
381
|
+
reason: 'owner_behavior_examples_stale',
|
|
382
|
+
detail: `re-assembled digest ${readiness.evidenceHash} != stored ${selection.contentDigest}`,
|
|
383
|
+
nextAction: 'Evidence content changed since attach; re-attach fresh examples with evidence attach --confirm, then resume.',
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
if (input.mode === 'dry_run') {
|
|
387
|
+
return {
|
|
388
|
+
status: 'dry_run',
|
|
389
|
+
taskId: input.taskId,
|
|
390
|
+
reasonCode: 'owner_behavior_examples_verified',
|
|
391
|
+
previousAttemptCount,
|
|
392
|
+
revision: selection.revision ?? 0,
|
|
393
|
+
contentDigest: selection.contentDigest,
|
|
394
|
+
painId: selection.sourcePainId,
|
|
395
|
+
nextAction: 'Digest verified — nothing was written. Re-run with --confirm to atomically requeue this task (attempt budget resets; the reset is audited with previousAttemptCount).',
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
// Single recovery authority (owner-retry.ts) with the B1 CAS precondition:
|
|
399
|
+
// at most one concurrent resume can win (T06); the loser gets `conflict`
|
|
400
|
+
// with the row untouched.
|
|
401
|
+
const retryOutcome = await ownerRetryNeedsHumanReviewTask(stateManager, input.taskId, {
|
|
402
|
+
expectedDiagnosticJson: readDiagnosticJson(task),
|
|
403
|
+
});
|
|
404
|
+
if (retryOutcome.status === 'conflict') {
|
|
405
|
+
return {
|
|
406
|
+
status: 'conflict',
|
|
407
|
+
taskId: input.taskId,
|
|
408
|
+
nextAction: 'Another writer changed the task concurrently (possible parallel resume); inspect status and re-run evidence resume if still appropriate.',
|
|
409
|
+
};
|
|
410
|
+
}
|
|
411
|
+
if (retryOutcome.status === 'rejected') {
|
|
412
|
+
return {
|
|
413
|
+
status: 'refused',
|
|
414
|
+
taskId: input.taskId,
|
|
415
|
+
reason: retryOutcome.reason,
|
|
416
|
+
nextAction: 'This task awaits an Owner decision (governance focus) — recover is not a governance exit.',
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
if (retryOutcome.status === 'metadata_invalid') {
|
|
420
|
+
return {
|
|
421
|
+
status: 'refused',
|
|
422
|
+
taskId: input.taskId,
|
|
423
|
+
reason: 'metadata_invalid',
|
|
424
|
+
nextAction: 'Task metadata failed PI hydration mid-resume; inspect pd runtime internalization integrity --json.',
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
if (retryOutcome.status !== 'requeued') {
|
|
428
|
+
// not_found / skipped: state moved between our read and the authority.
|
|
429
|
+
return {
|
|
430
|
+
status: 'conflict',
|
|
431
|
+
taskId: input.taskId,
|
|
432
|
+
nextAction: `Task state changed concurrently (authority outcome: ${retryOutcome.status}); inspect with evidence list and re-run if appropriate.`,
|
|
433
|
+
};
|
|
434
|
+
}
|
|
435
|
+
appendOwnerEvidenceAction(input.workspaceDir, {
|
|
436
|
+
taskId: input.taskId,
|
|
437
|
+
action: 'resume_evidence',
|
|
438
|
+
painId: selection.sourcePainId,
|
|
439
|
+
revision: selection.revision ?? 0,
|
|
440
|
+
contentDigest: selection.contentDigest,
|
|
441
|
+
previousAttemptCount,
|
|
442
|
+
operator: input.decidedBy ?? null,
|
|
443
|
+
});
|
|
444
|
+
const resumedAt = new Date().toISOString();
|
|
445
|
+
input.eventEmitter.emitTelemetry({
|
|
446
|
+
eventType: 'artificer_owner_evidence_resumed',
|
|
447
|
+
traceId: input.taskId,
|
|
448
|
+
timestamp: resumedAt,
|
|
449
|
+
sessionId: input.owner,
|
|
450
|
+
agentId: 'artificer',
|
|
451
|
+
payload: {
|
|
452
|
+
// FR-08 run-correlation block (PRI-984): the resume requeues to
|
|
453
|
+
// pending; the next attempt's run row is minted by the NEXT lease
|
|
454
|
+
// (deterministic `run_<taskId>_<max+1>`), so persistentRunId stays
|
|
455
|
+
// absent here and the correlation joins through
|
|
456
|
+
// (taskId, attemptNumber) — proven by the recovery T10 test.
|
|
457
|
+
...buildArtificerRunCorrelation({
|
|
458
|
+
taskId: input.taskId,
|
|
459
|
+
// PRI-984/F-1 wording: this is the WRITE-TIME value the authority
|
|
460
|
+
// reset landed (attemptCount=0). It is NOT "a new budget start" — the
|
|
461
|
+
// NEXT lease renumbers attempt_count from run history
|
|
462
|
+
// (lease-manager.ts, T10 pins the renumbered value). The correlation
|
|
463
|
+
// join keys on this write-time value.
|
|
464
|
+
attemptNumber: 0,
|
|
465
|
+
executionMode: 'recovery',
|
|
466
|
+
reasonCode: 'owner_behavior_examples_verified',
|
|
467
|
+
workspaceDir: input.workspaceDir,
|
|
468
|
+
evidenceDigest: selection.contentDigest,
|
|
469
|
+
}),
|
|
470
|
+
painId: selection.sourcePainId,
|
|
471
|
+
revision: selection.revision ?? 0,
|
|
472
|
+
contentDigest: selection.contentDigest,
|
|
473
|
+
previousAttemptCount,
|
|
474
|
+
ownerOperation: input.decidedBy !== undefined && input.decidedBy.trim() !== '' ? `cli:resume:${input.decidedBy.trim()}` : 'cli:resume',
|
|
475
|
+
},
|
|
476
|
+
});
|
|
477
|
+
return {
|
|
478
|
+
status: 'resumed',
|
|
479
|
+
taskId: input.taskId,
|
|
480
|
+
previousStatus: 'needs_human_review',
|
|
481
|
+
newStatus: 'pending',
|
|
482
|
+
previousAttemptCount,
|
|
483
|
+
revision: selection.revision ?? 0,
|
|
484
|
+
contentDigest: selection.contentDigest,
|
|
485
|
+
nextAction: 'Task requeued with its full history; the evidence-aware auto-consumer picks up Code Rule tasks. run-once is not an evidence-capable execution entry. The attempt budget reset is audited.',
|
|
486
|
+
};
|
|
487
|
+
}
|
|
488
|
+
//# sourceMappingURL=owner-evidence-recovery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"owner-evidence-recovery.js","sourceRoot":"","sources":["../../../src/runtime-v2/internalization/owner-evidence-recovery.ts"],"names":[],"mappings":"AA6DA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EACL,0BAA0B,EAC1B,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,uBAAuB,EACvB,mCAAmC,GAGpC,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E;gBAClE,sEAAsE;gBACtE,sDAAsD;gBACtD,qEAAqE;gBACrE,sCAAsC;gBACtC,aAAa,EAAE,CAAC;gBAChB,aAAa,EAAE,UAAU;gBACzB,UAAU,EAAE,kCAAkC;gBAC9C,YAAY,EAAE,KAAK,CAAC,YAAY;gBAChC,cAAc,EAAE,SAAS,CAAC,aAAa;aACxC,CAAC;YACF,MAAM,EAAE,SAAS,CAAC,YAAY;YAC9B,QAAQ,EAAE,SAAS,CAAC,QAAQ,IAAI,CAAC;YACjC,aAAa,EAAE,SAAS,CAAC,aAAa;YACtC,oBAAoB;YACpB,cAAc,EAAE,KAAK,CAAC,SAAS,KAAK,SAAS,IAAI,KAAK,CAAC,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,cAAc,KAAK,CAAC,SAAS,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,YAAY;SACvI;KACF,CAAC,CAAC;IAEH,OAAO;QACL,MAAM,EAAE,SAAS;QACjB,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,cAAc,EAAE,oBAAoB;QACpC,SAAS,EAAE,SAAS;QACpB,oBAAoB;QACpB,QAAQ,EAAE,SAAS,CAAC,QAAQ,IAAI,CAAC;QACjC,aAAa,EAAE,SAAS,CAAC,aAAa;QACtC,UAAU,EAAE,2LAA2L;KACxM,CAAC;AACJ,CAAC"}
|
|
@@ -42,7 +42,29 @@ export type OwnerRetryOutcome = {
|
|
|
42
42
|
previousStatus: string;
|
|
43
43
|
reason: 'owner_decision_required';
|
|
44
44
|
nextAction: 'open_governance_focus';
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* PRI-983 (SPEC-PD-IAER-001 FR-06/T06): only with `options.expectedDiagnosticJson`
|
|
48
|
+
* — the CAS precondition was lost to a concurrent writer (another resume /
|
|
49
|
+
* metadata mutation landed between this caller's read and write). The task
|
|
50
|
+
* row is untouched; the caller must re-read and re-evaluate. Never returned
|
|
51
|
+
* by the legacy two-argument call shape.
|
|
52
|
+
*/
|
|
53
|
+
| {
|
|
54
|
+
status: 'conflict';
|
|
55
|
+
taskKind: string;
|
|
56
|
+
previousStatus: string;
|
|
45
57
|
};
|
|
58
|
+
export interface OwnerRetryOptions {
|
|
59
|
+
/**
|
|
60
|
+
* PRI-983: optional CAS precondition — apply the authority reset ONLY while
|
|
61
|
+
* the task's diagnostic_json is still byte-equal to this value (the caller's
|
|
62
|
+
* read). Absent (the existing two-argument call shape used by
|
|
63
|
+
* `pd runtime internalization retry` and the Console recover endpoint)
|
|
64
|
+
* keeps the exact historical unconditional-write semantics.
|
|
65
|
+
*/
|
|
66
|
+
readonly expectedDiagnosticJson?: string | null;
|
|
67
|
+
}
|
|
46
68
|
/**
|
|
47
69
|
* 对单个 needs_human_review 任务执行 Owner authority reset(→ pending)。
|
|
48
70
|
*
|
|
@@ -57,5 +79,5 @@ export type OwnerRetryOutcome = {
|
|
|
57
79
|
* 保留 revisionCount / revisionCauseId / rolloutRevisionPayload / repairPayload
|
|
58
80
|
* / lineage —— revision budget 证据不动。
|
|
59
81
|
*/
|
|
60
|
-
export declare function ownerRetryNeedsHumanReviewTask(stateManager: RuntimeStateManager, taskId: string): Promise<OwnerRetryOutcome>;
|
|
82
|
+
export declare function ownerRetryNeedsHumanReviewTask(stateManager: RuntimeStateManager, taskId: string, options?: OwnerRetryOptions): Promise<OwnerRetryOutcome>;
|
|
61
83
|
//# sourceMappingURL=owner-retry.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"owner-retry.d.ts","sourceRoot":"","sources":["../../../src/runtime-v2/internalization/owner-retry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAS7E,MAAM,MAAM,iBAAiB,GACzB;IAAE,MAAM,EAAE,WAAW,CAAA;CAAE,GACvB;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,QAA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CAAC;IAAC,cAAc,EAAE,MAAM,CAAA;CAAE,CAAC;AAErE,MAAM,WAAW,iBAAiB;IAChC;;;;;;OAMG;IACH,QAAQ,CAAC,sBAAsB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACjD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,8BAA8B,CAClD,YAAY,EAAE,mBAAmB,EACjC,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,iBAAiB,CAAC,CAgF5B"}
|
|
@@ -15,7 +15,7 @@ import { factStoreFromStateManager } from './owner-resolution-service.js';
|
|
|
15
15
|
* 保留 revisionCount / revisionCauseId / rolloutRevisionPayload / repairPayload
|
|
16
16
|
* / lineage —— revision budget 证据不动。
|
|
17
17
|
*/
|
|
18
|
-
export async function ownerRetryNeedsHumanReviewTask(stateManager, taskId) {
|
|
18
|
+
export async function ownerRetryNeedsHumanReviewTask(stateManager, taskId, options) {
|
|
19
19
|
const task = await stateManager.getTask(taskId);
|
|
20
20
|
if (!task) {
|
|
21
21
|
return { status: 'not_found' };
|
|
@@ -60,11 +60,27 @@ export async function ownerRetryNeedsHumanReviewTask(stateManager, taskId) {
|
|
|
60
60
|
runnerDecision: undefined,
|
|
61
61
|
completionIntent: undefined,
|
|
62
62
|
});
|
|
63
|
-
|
|
63
|
+
const patch = {
|
|
64
64
|
status: 'pending',
|
|
65
65
|
attemptCount: 0,
|
|
66
66
|
diagnosticJson: createPITaskDiagnosticJson(merged),
|
|
67
|
-
}
|
|
67
|
+
};
|
|
68
|
+
if (options?.expectedDiagnosticJson !== undefined) {
|
|
69
|
+
// PRI-983 CAS variant: single conditional UPDATE — the authority reset
|
|
70
|
+
// lands only while the task row is still byte-identical to the caller's
|
|
71
|
+
// read AND still sits in needs_human_review (SPEC §6.3: 前置状态 + 版本
|
|
72
|
+
// 检查). The status precondition is what arbitrates two concurrent
|
|
73
|
+
// resumes when the reset is content-neutral (an artificer NHR task has no
|
|
74
|
+
// runnerDecision/completionIntent to clear): the first writer moves the
|
|
75
|
+
// status to pending, the second's precondition fails → `conflict`.
|
|
76
|
+
const updated = await stateManager.updateTaskIfDiagnosticJsonUnchanged(taskId, options.expectedDiagnosticJson, patch, { expectedStatus: 'needs_human_review' });
|
|
77
|
+
if (!updated) {
|
|
78
|
+
return { status: 'conflict', taskKind: task.taskKind, previousStatus: task.status };
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
await stateManager.updateTask(taskId, patch);
|
|
83
|
+
}
|
|
68
84
|
return {
|
|
69
85
|
status: 'requeued',
|
|
70
86
|
taskKind: task.taskKind,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"owner-retry.js","sourceRoot":"","sources":["../../../src/runtime-v2/internalization/owner-retry.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,mBAAmB,EAAE,0BAA0B,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC5G,OAAO,EACL,yBAAyB,EACzB,6BAA6B,EAC7B,yCAAyC,GAC1C,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"owner-retry.js","sourceRoot":"","sources":["../../../src/runtime-v2/internalization/owner-retry.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,mBAAmB,EAAE,0BAA0B,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC5G,OAAO,EACL,yBAAyB,EACzB,6BAA6B,EAC7B,yCAAyC,GAC1C,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAiC1E;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,KAAK,UAAU,8BAA8B,CAClD,YAAiC,EACjC,MAAc,EACd,OAA2B;IAE3B,MAAM,IAAI,GAAG,MAAM,YAAY,CAAC,OAAO,CAAC,MAAM,CAA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AAS;KAC5B,CAAC,CAAC;IACH,MAAM,KAAK,GAAG;QACZ,MAAM,EAAE,SAAkB;QAC1B,YAAY,EAAE,CAAC;QACf,cAAc,EAAE,0BAA0B,CAAC,MAAM,CAAC;KACnD,CAAC;IACF,IAAI,OAAO,EAAE,sBAAsB,KAAK,SAAS,EAAE,CAAC;QAClD,uEAAuE;QACvE,wEAAwE;QACxE,kEAAkE;QAClE,iEAAiE;QACjE,0EAA0E;QAC1E,wEAAwE;QACxE,mEAAmE;QACnE,MAAM,OAAO,GAAG,MAAM,YAAY,CAAC,mCAAmC,CACpE,MAAM,EACN,OAAO,CAAC,sBAAsB,EAC9B,KAAK,EACL,EAAE,cAAc,EAAE,oBAAoB,EAAE,CACzC,CAAC;QACF,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,cAAc,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;QACtF,CAAC;IACH,CAAC;SAAM,CAAC;QACN,MAAM,YAAY,CAAC,UAAU,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC/C,CAAC;IAED,OAAO;QACL,MAAM,EAAE,UAAU;QAClB,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,cAAc,EAAE,IAAI,CAAC,MAAM;KAC5B,CAAC;AACJ,CAAC"}
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import type { TaskRecord } from '../task-status.js';
|
|
17
17
|
import type { RepairPayload, RunnerDecision, RolloutRevisionPayload, RunnerCompletionIntent, HumanReviewContext, OwnerResolutionRecord } from './pitask-metadata.js';
|
|
18
|
+
import type { OwnerEvidenceSelection } from './evidence-readiness.js';
|
|
18
19
|
/**
|
|
19
20
|
* The 4 channels through which principle internalization can occur.
|
|
20
21
|
*
|
|
@@ -141,6 +142,13 @@ export interface PITaskRecord extends TaskRecord {
|
|
|
141
142
|
humanReviewContext?: HumanReviewContext;
|
|
142
143
|
/** PRI-629: task-scoped Owner resolution log (append-only; not a state source). */
|
|
143
144
|
ownerResolutions?: readonly OwnerResolutionRecord[];
|
|
145
|
+
/**
|
|
146
|
+
* PRI-982 (SPEC-PD-IAER-001 FR-03): Owner-labelled evidence selection —
|
|
147
|
+
* written only by the authorized Owner operation (never fabricated by an
|
|
148
|
+
* internal agent); ABSENT = evidence not yet provided. The single shape
|
|
149
|
+
* authority is `validateOwnerEvidenceSelectionShape` (evidence-readiness.ts).
|
|
150
|
+
*/
|
|
151
|
+
ownerEvidenceSelection?: OwnerEvidenceSelection;
|
|
144
152
|
}
|
|
145
153
|
/**
|
|
146
154
|
* All valid peer runner kinds. Useful for validation and iteration.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"peer-runner-contracts.d.ts","sourceRoot":"","sources":["../../../src/runtime-v2/internalization/peer-runner-contracts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"peer-runner-contracts.d.ts","sourceRoot":"","sources":["../../../src/runtime-v2/internalization/peer-runner-contracts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AACrK,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAItE;;;;GAIG;AACH,MAAM,MAAM,sBAAsB,GAC9B,QAAQ,GACR,OA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