@ngockhoale/ukit 3.4.76 → 3.4.78
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/CHANGELOG.md +11 -637
- package/package.json +1 -1
- package/template_project/.claude/hooks/skill-router.sh +192 -19
- package/template_project/.claude/ukit/index/publication-intent.mjs +130 -18
- package/template_project/.claude/ukit/runtime/cron-operation-adapter.mjs +13 -1
- package/template_project/.claude/ukit/runtime/execution-ledger.mjs +410 -62
- package/template_project/.claude/ukit/runtime/operation-evidence.mjs +32 -4
- package/template_project/.claude/ukit/runtime/stop-coordinator.mjs +2 -0
- package/template_project/.omp/hooks/pre/ukit-bridge.js +10 -2
|
@@ -48,8 +48,10 @@ export function foldOperationEvidence(bank = {}, receipt, ledger) {
|
|
|
48
48
|
}
|
|
49
49
|
const prior = bank[key] || {};
|
|
50
50
|
const seen = Array.isArray(bank.seenToolUseIds) ? bank.seenToolUseIds : [];
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
// Dedup per (toolUseId, domain): one chained command may prove several goals, never the same goal twice.
|
|
52
|
+
const seenKey = `${receipt.toolUseId}|${op.domain}`;
|
|
53
|
+
if (receipt.toolUseId && (seen.includes(seenKey) || seen.includes(receipt.toolUseId) || Object.values(bank).some((entry) =>
|
|
54
|
+
[entry?.mutation, entry?.state].some((proof) => proof?.toolUseId === receipt.toolUseId && proof.operation?.domain === op.domain)))) return bank;
|
|
53
55
|
if (receipt.toolUseId && (!bounded(receipt.toolUseId) || seen.length >= 256)) return { ...bank, overflow: true };
|
|
54
56
|
// Carry remote parity across successful state checks only until the next mutation; gate checks live HEAD.
|
|
55
57
|
const lastMutation = Object.values(bank).reduce((max, entry) => {
|
|
@@ -84,7 +86,7 @@ export function foldOperationEvidence(bank = {}, receipt, ledger) {
|
|
|
84
86
|
...(remoteSync ? { remoteSync } : {}),
|
|
85
87
|
...(github ? { github } : {}),
|
|
86
88
|
} };
|
|
87
|
-
return { ...bank, seenToolUseIds: receipt.toolUseId ? [...seen,
|
|
89
|
+
return { ...bank, seenToolUseIds: receipt.toolUseId ? [...seen, seenKey] : seen,
|
|
88
90
|
[key]: { ...prior, [op.role]: proof } };
|
|
89
91
|
}
|
|
90
92
|
|
|
@@ -155,10 +157,36 @@ export function operationEvidenceStatus(goal, ledger = {}) {
|
|
|
155
157
|
return { complete: true, operationProof: 'executed-and-verified' };
|
|
156
158
|
}
|
|
157
159
|
|
|
160
|
+
// Every independent native obligation of the contract. `operationGoals` lists them all (a prompt that orders
|
|
161
|
+
// commit/push AND a script deploy owns both); `operationGoal` stays the primary for older readers. A stale list
|
|
162
|
+
// whose head is not exactly the primary goal (stale after a re-route that only replaced operationGoal) is
|
|
163
|
+
// ignored rather than trusted.
|
|
164
|
+
export function contractOperationGoals(contract) {
|
|
165
|
+
const primary = contract?.operationGoal;
|
|
166
|
+
if (!primary) return [];
|
|
167
|
+
const list = Array.isArray(contract.operationGoals) ? contract.operationGoals.filter((goal) => goal && typeof goal === 'object') : [];
|
|
168
|
+
return list.length > 1 && JSON.stringify(list[0]) === JSON.stringify(primary) ? list.slice(0, 4) : [primary];
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// A task-owned native mutation attempt (successful or not) for this goal. Completion evidence only: it never
|
|
172
|
+
// gates whether an operation may run, it only separates "attempted, now prove it" from "not yet attempted".
|
|
173
|
+
export function operationAttempted(goal, ledger = {}) {
|
|
174
|
+
if (!goal || !ledger.taskInstanceId || !ledger.sessionKey || !goal.scope) return false;
|
|
175
|
+
return Object.entries(ledger.operationBank || {}).some(([key, entry]) => key !== 'overflow' && key !== 'seenToolUseIds'
|
|
176
|
+
&& entry?.mutation?.taskInstanceId === ledger.taskInstanceId && entry.mutation.sessionKey === ledger.sessionKey
|
|
177
|
+
&& entry.mutation.operation?.domain === goal.domain && entry.mutation.operation.scope === goal.scope);
|
|
178
|
+
}
|
|
179
|
+
|
|
158
180
|
export function operationCompletionPolicy(contract, _adapterGoal, ledger) {
|
|
159
181
|
if (contract?.publication && !contract.operationGoal) return null; // Publication uses the registry-bound release-publication proof.
|
|
160
182
|
const kind = String(contract?.taskKind || '').toUpperCase();
|
|
161
183
|
if (!['OPERATIONAL', 'MIXED', 'CONFIGURATION'].includes(kind)
|
|
162
184
|
|| (kind === 'CONFIGURATION' && contract.configurationScope !== 'external')) return null;
|
|
163
|
-
|
|
185
|
+
const goals = contractOperationGoals(contract);
|
|
186
|
+
if (goals.length <= 1) return operationEvidenceStatus(contract.operationGoal, ledger) || { complete: false, operationProof: null };
|
|
187
|
+
// Multi-operation task: each independent goal needs its own proof; one never stands in for another.
|
|
188
|
+
const statuses = goals.map((goal) => ({ goal, status: operationEvidenceStatus(goal, ledger) || { complete: false, operationProof: null } }));
|
|
189
|
+
const unmet = statuses.filter((entry) => entry.status.complete !== true).map((entry) => entry.goal);
|
|
190
|
+
return { complete: unmet.length === 0, operationProof: unmet.length === 0 ? statuses.map((entry) => entry.status.operationProof).join('+') : null,
|
|
191
|
+
unmetGoals: unmet };
|
|
164
192
|
}
|
|
@@ -209,6 +209,8 @@ export function normalizeEvaluatorStdout(stdout) {
|
|
|
209
209
|
...(parsed.outcome === 'blocked' && parsed.complete === false ? { outcome: 'blocked', complete: false } : {}),
|
|
210
210
|
};
|
|
211
211
|
}
|
|
212
|
+
// A message-less non-completion release (the finite handback was already delivered) is never a pass.
|
|
213
|
+
if (parsed && parsed.outcome === 'blocked' && parsed.complete === false) return { kind: 'none', outcome: 'blocked', complete: false };
|
|
212
214
|
return { kind: 'complete' };
|
|
213
215
|
}
|
|
214
216
|
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
evidencePromptKey,
|
|
17
17
|
incrementContinuation,
|
|
18
18
|
markNotified,
|
|
19
|
+
markHandback,
|
|
19
20
|
readExecutionLedger,
|
|
20
21
|
readRouteState,
|
|
21
22
|
ownerStopActive,
|
|
@@ -2100,6 +2101,11 @@ export async function runSessionStop(
|
|
|
2100
2101
|
await resetCompletionCrashStreak(projectRoot);
|
|
2101
2102
|
if (!evaluation.continue) {
|
|
2102
2103
|
if (evaluation.capped) pi.logger?.warn?.(`[UKit] ${evaluation.reason}`);
|
|
2104
|
+
// Finite handback: record the one handback per task state; a later Stop at the same state is silent.
|
|
2105
|
+
if (suppliedLedger === undefined && (evaluation.outcome === 'handback' || evaluation.capped === true)
|
|
2106
|
+
&& evaluation.gateRelease !== 'handback-delivered') {
|
|
2107
|
+
try { await markHandback(projectRoot, payload, evaluation, { deadlineMs: lockBudgetMs }); } catch { /* repeats one handback at most */ }
|
|
2108
|
+
}
|
|
2103
2109
|
const missingEvidence = Array.isArray(evaluation.missingEvidence) ? evaluation.missingEvidence : [];
|
|
2104
2110
|
// The visible-blocker exit (verification loop) carries no missingEvidence but must still
|
|
2105
2111
|
// reach the user — a silent release is indistinguishable from a stall.
|
|
@@ -2131,8 +2137,10 @@ export async function runSessionStop(
|
|
|
2131
2137
|
try {
|
|
2132
2138
|
// TASK-007 (OMP-2a): the 600ms lock budget — a contended ledger lock must
|
|
2133
2139
|
// never hold the omp host near its hook deadline.
|
|
2134
|
-
|
|
2135
|
-
|
|
2140
|
+
const marker = { stateFp: evaluation.stateFingerprint, taskKey: evaluation.handbackKey,
|
|
2141
|
+
opOnly: evaluation.missingEvidence?.length > 0 && evaluation.missingEvidence.every((item) => item === 'operation-verification') };
|
|
2142
|
+
if (evaluation.finalNotice) await markNotified(projectRoot, payload, ledger, { deadlineMs: lockBudgetMs, ...marker });
|
|
2143
|
+
else await incrementContinuation(projectRoot, payload, ledger, state?.requestKey || null, evidencePromptKey(state), { deadlineMs: lockBudgetMs, ...marker });
|
|
2136
2144
|
} catch (error) {
|
|
2137
2145
|
pi.logger?.warn?.(`[UKit] continuation bookkeeping failed open: ${error?.message || error}`);
|
|
2138
2146
|
}
|