@akagilnc/pi-workflow-roles 0.1.4278 → 0.1.4286
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.
|
@@ -16142,32 +16142,29 @@ async function settleLawfulSeatAcceptedTerminalResult(admitted, authority, spec,
|
|
|
16142
16142
|
const entries = await readLawfulSettlementEntries(sessionFile) ?? [];
|
|
16143
16143
|
const submissions = await recordedSubmissionPayloads(admitted, scope);
|
|
16144
16144
|
const scanStart = currentAttemptStartIndex(entries);
|
|
16145
|
+
let thisAttemptHasSeatSuccess = false;
|
|
16146
|
+
let residual;
|
|
16145
16147
|
for (let index = entries.length - 1; index >= scanStart; index -= 1) {
|
|
16146
16148
|
const message = entries[index]?.message;
|
|
16147
16149
|
if (message?.role !== "toolResult") continue;
|
|
16148
|
-
|
|
16149
|
-
|
|
16150
|
-
index,
|
|
16151
|
-
|
|
16152
|
-
|
|
16153
|
-
|
|
16154
|
-
|
|
16155
|
-
|
|
16156
|
-
|
|
16157
|
-
|
|
16158
|
-
|
|
16159
|
-
|
|
16160
|
-
|
|
16161
|
-
details
|
|
16162
|
-
},
|
|
16163
|
-
authority,
|
|
16164
|
-
scope ?? {}
|
|
16150
|
+
if (message.toolName !== spec.toolName) continue;
|
|
16151
|
+
if (message.isError === false) {
|
|
16152
|
+
if (boundRoleToolCallForResult(entries, index, message, spec.toolName) !== void 0) {
|
|
16153
|
+
thisAttemptHasSeatSuccess = true;
|
|
16154
|
+
}
|
|
16155
|
+
continue;
|
|
16156
|
+
}
|
|
16157
|
+
if (residual === void 0) {
|
|
16158
|
+
residual = boundErroredToolCandidate(
|
|
16159
|
+
entries,
|
|
16160
|
+
index,
|
|
16161
|
+
message,
|
|
16162
|
+
spec.toolName
|
|
16165
16163
|
);
|
|
16166
|
-
return withSubmissions(failed, submissions);
|
|
16167
16164
|
}
|
|
16168
16165
|
}
|
|
16169
16166
|
const roleOutcome = await closedLedgerOutcome(admitted, spec.role, scope);
|
|
16170
|
-
if (roleOutcome
|
|
16167
|
+
if (roleOutcome !== void 0 && (thisAttemptHasSeatSuccess || residual === void 0)) {
|
|
16171
16168
|
const navigator = extractNavigatorFact(entries);
|
|
16172
16169
|
return withSubmissions(
|
|
16173
16170
|
await withOptionalGateProjection(
|
|
@@ -16183,21 +16180,19 @@ async function settleLawfulSeatAcceptedTerminalResult(admitted, authority, spec,
|
|
|
16183
16180
|
submissions
|
|
16184
16181
|
);
|
|
16185
16182
|
}
|
|
16186
|
-
if (
|
|
16187
|
-
const
|
|
16188
|
-
|
|
16189
|
-
|
|
16190
|
-
|
|
16191
|
-
|
|
16192
|
-
|
|
16193
|
-
|
|
16194
|
-
|
|
16195
|
-
|
|
16196
|
-
|
|
16197
|
-
detourGateContext(admitted, scope)
|
|
16198
|
-
),
|
|
16199
|
-
submissions
|
|
16183
|
+
if (residual !== void 0) {
|
|
16184
|
+
const details = isRecord11(residual.candidate) ? residual.candidate : { candidate: residual.candidate };
|
|
16185
|
+
const failed = await settleFailureTerminalResult(
|
|
16186
|
+
admitted,
|
|
16187
|
+
{
|
|
16188
|
+
cause: "output",
|
|
16189
|
+
diagnostic: residual.diagnostic,
|
|
16190
|
+
details
|
|
16191
|
+
},
|
|
16192
|
+
authority,
|
|
16193
|
+
scope ?? {}
|
|
16200
16194
|
);
|
|
16195
|
+
return withSubmissions(failed, submissions);
|
|
16201
16196
|
}
|
|
16202
16197
|
return void 0;
|
|
16203
16198
|
}
|
|
@@ -15508,32 +15508,29 @@ async function settleLawfulSeatAcceptedTerminalResult(admitted, authority, spec,
|
|
|
15508
15508
|
const entries = await readLawfulSettlementEntries(sessionFile) ?? [];
|
|
15509
15509
|
const submissions = await recordedSubmissionPayloads(admitted, scope);
|
|
15510
15510
|
const scanStart = currentAttemptStartIndex(entries);
|
|
15511
|
+
let thisAttemptHasSeatSuccess = false;
|
|
15512
|
+
let residual;
|
|
15511
15513
|
for (let index = entries.length - 1; index >= scanStart; index -= 1) {
|
|
15512
15514
|
const message = entries[index]?.message;
|
|
15513
15515
|
if (message?.role !== "toolResult") continue;
|
|
15514
|
-
|
|
15515
|
-
|
|
15516
|
-
index,
|
|
15517
|
-
|
|
15518
|
-
|
|
15519
|
-
|
|
15520
|
-
|
|
15521
|
-
|
|
15522
|
-
|
|
15523
|
-
|
|
15524
|
-
|
|
15525
|
-
|
|
15526
|
-
|
|
15527
|
-
details
|
|
15528
|
-
},
|
|
15529
|
-
authority,
|
|
15530
|
-
scope ?? {}
|
|
15516
|
+
if (message.toolName !== spec.toolName) continue;
|
|
15517
|
+
if (message.isError === false) {
|
|
15518
|
+
if (boundRoleToolCallForResult(entries, index, message, spec.toolName) !== void 0) {
|
|
15519
|
+
thisAttemptHasSeatSuccess = true;
|
|
15520
|
+
}
|
|
15521
|
+
continue;
|
|
15522
|
+
}
|
|
15523
|
+
if (residual === void 0) {
|
|
15524
|
+
residual = boundErroredToolCandidate(
|
|
15525
|
+
entries,
|
|
15526
|
+
index,
|
|
15527
|
+
message,
|
|
15528
|
+
spec.toolName
|
|
15531
15529
|
);
|
|
15532
|
-
return withSubmissions(failed, submissions);
|
|
15533
15530
|
}
|
|
15534
15531
|
}
|
|
15535
15532
|
const roleOutcome = await closedLedgerOutcome(admitted, spec.role, scope);
|
|
15536
|
-
if (roleOutcome
|
|
15533
|
+
if (roleOutcome !== void 0 && (thisAttemptHasSeatSuccess || residual === void 0)) {
|
|
15537
15534
|
const navigator = extractNavigatorFact(entries);
|
|
15538
15535
|
return withSubmissions(
|
|
15539
15536
|
await withOptionalGateProjection(
|
|
@@ -15549,21 +15546,19 @@ async function settleLawfulSeatAcceptedTerminalResult(admitted, authority, spec,
|
|
|
15549
15546
|
submissions
|
|
15550
15547
|
);
|
|
15551
15548
|
}
|
|
15552
|
-
if (
|
|
15553
|
-
const
|
|
15554
|
-
|
|
15555
|
-
|
|
15556
|
-
|
|
15557
|
-
|
|
15558
|
-
|
|
15559
|
-
|
|
15560
|
-
|
|
15561
|
-
|
|
15562
|
-
|
|
15563
|
-
detourGateContext(admitted, scope)
|
|
15564
|
-
),
|
|
15565
|
-
submissions
|
|
15549
|
+
if (residual !== void 0) {
|
|
15550
|
+
const details = isRecord11(residual.candidate) ? residual.candidate : { candidate: residual.candidate };
|
|
15551
|
+
const failed = await settleFailureTerminalResult(
|
|
15552
|
+
admitted,
|
|
15553
|
+
{
|
|
15554
|
+
cause: "output",
|
|
15555
|
+
diagnostic: residual.diagnostic,
|
|
15556
|
+
details
|
|
15557
|
+
},
|
|
15558
|
+
authority,
|
|
15559
|
+
scope ?? {}
|
|
15566
15560
|
);
|
|
15561
|
+
return withSubmissions(failed, submissions);
|
|
15567
15562
|
}
|
|
15568
15563
|
return void 0;
|
|
15569
15564
|
}
|
package/dist/public-cli/main.js
CHANGED
|
@@ -26701,32 +26701,29 @@ async function settleLawfulSeatAcceptedTerminalResult(admitted, authority, spec,
|
|
|
26701
26701
|
const entries = await readLawfulSettlementEntries(sessionFile) ?? [];
|
|
26702
26702
|
const submissions = await recordedSubmissionPayloads(admitted, scope);
|
|
26703
26703
|
const scanStart = currentAttemptStartIndex(entries);
|
|
26704
|
+
let thisAttemptHasSeatSuccess = false;
|
|
26705
|
+
let residual;
|
|
26704
26706
|
for (let index = entries.length - 1; index >= scanStart; index -= 1) {
|
|
26705
26707
|
const message = entries[index]?.message;
|
|
26706
26708
|
if (message?.role !== "toolResult") continue;
|
|
26707
|
-
|
|
26708
|
-
|
|
26709
|
-
index,
|
|
26710
|
-
|
|
26711
|
-
|
|
26712
|
-
|
|
26713
|
-
|
|
26714
|
-
|
|
26715
|
-
|
|
26716
|
-
|
|
26717
|
-
|
|
26718
|
-
|
|
26719
|
-
|
|
26720
|
-
details
|
|
26721
|
-
},
|
|
26722
|
-
authority,
|
|
26723
|
-
scope ?? {}
|
|
26709
|
+
if (message.toolName !== spec.toolName) continue;
|
|
26710
|
+
if (message.isError === false) {
|
|
26711
|
+
if (boundRoleToolCallForResult(entries, index, message, spec.toolName) !== void 0) {
|
|
26712
|
+
thisAttemptHasSeatSuccess = true;
|
|
26713
|
+
}
|
|
26714
|
+
continue;
|
|
26715
|
+
}
|
|
26716
|
+
if (residual === void 0) {
|
|
26717
|
+
residual = boundErroredToolCandidate(
|
|
26718
|
+
entries,
|
|
26719
|
+
index,
|
|
26720
|
+
message,
|
|
26721
|
+
spec.toolName
|
|
26724
26722
|
);
|
|
26725
|
-
return withSubmissions(failed, submissions);
|
|
26726
26723
|
}
|
|
26727
26724
|
}
|
|
26728
26725
|
const roleOutcome = await closedLedgerOutcome(admitted, spec.role, scope);
|
|
26729
|
-
if (roleOutcome
|
|
26726
|
+
if (roleOutcome !== void 0 && (thisAttemptHasSeatSuccess || residual === void 0)) {
|
|
26730
26727
|
const navigator = extractNavigatorFact(entries);
|
|
26731
26728
|
return withSubmissions(
|
|
26732
26729
|
await withOptionalGateProjection(
|
|
@@ -26742,21 +26739,19 @@ async function settleLawfulSeatAcceptedTerminalResult(admitted, authority, spec,
|
|
|
26742
26739
|
submissions
|
|
26743
26740
|
);
|
|
26744
26741
|
}
|
|
26745
|
-
if (
|
|
26746
|
-
const
|
|
26747
|
-
|
|
26748
|
-
|
|
26749
|
-
|
|
26750
|
-
|
|
26751
|
-
|
|
26752
|
-
|
|
26753
|
-
|
|
26754
|
-
|
|
26755
|
-
|
|
26756
|
-
detourGateContext(admitted, scope)
|
|
26757
|
-
),
|
|
26758
|
-
submissions
|
|
26742
|
+
if (residual !== void 0) {
|
|
26743
|
+
const details = isRecord10(residual.candidate) ? residual.candidate : { candidate: residual.candidate };
|
|
26744
|
+
const failed = await settleFailureTerminalResult(
|
|
26745
|
+
admitted,
|
|
26746
|
+
{
|
|
26747
|
+
cause: "output",
|
|
26748
|
+
diagnostic: residual.diagnostic,
|
|
26749
|
+
details
|
|
26750
|
+
},
|
|
26751
|
+
authority,
|
|
26752
|
+
scope ?? {}
|
|
26759
26753
|
);
|
|
26754
|
+
return withSubmissions(failed, submissions);
|
|
26760
26755
|
}
|
|
26761
26756
|
return void 0;
|
|
26762
26757
|
}
|
|
@@ -2244,27 +2244,37 @@ async function settleLawfulSeatAcceptedTerminalResult(admitted, authority, spec,
|
|
|
2244
2244
|
const { sessionDirectory, sessionFile } = coordinates;
|
|
2245
2245
|
const entries = await readLawfulSettlementEntries(sessionFile) ?? [];
|
|
2246
2246
|
const submissions = await recordedSubmissionPayloads(admitted, scope);
|
|
2247
|
-
//
|
|
2247
|
+
// #843: collector shape (ledger closed first) plus current user-turn freshness.
|
|
2248
|
+
// A lawful bound non-error seat toolResult (isError === false + one-to-one call
|
|
2249
|
+
// bind, same grade as residual) means this turn sealed — a prior bounce residual
|
|
2250
|
+
// in the same turn must not outrank it. Missing isError, unbound, or mis-bound
|
|
2251
|
+
// results do not establish success and do not reject/abort. A current-attempt
|
|
2252
|
+
// residual without that success is this turn's own failure and must not be
|
|
2253
|
+
// masked by run-scoped stale acceptance (bare resume without courtAttemptId).
|
|
2254
|
+
// Same-turn accept-then-bounce keeps the success marker: terminal stays
|
|
2255
|
+
// accepted; rejection facts remain on payloads/gate (not latest-wins flip).
|
|
2248
2256
|
const scanStart = currentAttemptStartIndex(entries);
|
|
2257
|
+
let thisAttemptHasSeatSuccess = false;
|
|
2258
|
+
let residual;
|
|
2249
2259
|
for (let index = entries.length - 1; index >= scanStart; index -= 1) {
|
|
2250
2260
|
const message = entries[index]?.message;
|
|
2251
2261
|
if (message?.role !== "toolResult")
|
|
2252
2262
|
continue;
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2263
|
+
if (message.toolName !== spec.toolName)
|
|
2264
|
+
continue;
|
|
2265
|
+
if (message.isError === false) {
|
|
2266
|
+
if (boundRoleToolCallForResult(entries, index, message, spec.toolName) !==
|
|
2267
|
+
undefined) {
|
|
2268
|
+
thisAttemptHasSeatSuccess = true;
|
|
2269
|
+
}
|
|
2270
|
+
continue;
|
|
2271
|
+
}
|
|
2272
|
+
if (residual === undefined) {
|
|
2273
|
+
residual = boundErroredToolCandidate(entries, index, message, spec.toolName);
|
|
2264
2274
|
}
|
|
2265
2275
|
}
|
|
2266
2276
|
const roleOutcome = await closedLedgerOutcome(admitted, spec.role, scope);
|
|
2267
|
-
if (roleOutcome
|
|
2277
|
+
if (roleOutcome !== undefined && (thisAttemptHasSeatSuccess || residual === undefined)) {
|
|
2268
2278
|
const navigator = extractNavigatorFact(entries);
|
|
2269
2279
|
return withSubmissions(await withOptionalGateProjection({
|
|
2270
2280
|
roleOutcome,
|
|
@@ -2273,14 +2283,16 @@ async function settleLawfulSeatAcceptedTerminalResult(admitted, authority, spec,
|
|
|
2273
2283
|
runId: admitted.runId,
|
|
2274
2284
|
}, sessionDirectory, detourGateContext(admitted, scope)), submissions);
|
|
2275
2285
|
}
|
|
2276
|
-
if (
|
|
2277
|
-
const
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2286
|
+
if (residual !== undefined) {
|
|
2287
|
+
const details = isRecord(residual.candidate)
|
|
2288
|
+
? residual.candidate
|
|
2289
|
+
: { candidate: residual.candidate };
|
|
2290
|
+
const failed = await settleFailureTerminalResult(admitted, {
|
|
2291
|
+
cause: "output",
|
|
2292
|
+
diagnostic: residual.diagnostic,
|
|
2293
|
+
details,
|
|
2294
|
+
}, authority, scope ?? {});
|
|
2295
|
+
return withSubmissions(failed, submissions);
|
|
2284
2296
|
}
|
|
2285
2297
|
return undefined;
|
|
2286
2298
|
}
|
package/package.json
CHANGED
|
@@ -3226,36 +3226,42 @@ async function settleLawfulSeatAcceptedTerminalResult(
|
|
|
3226
3226
|
const { sessionDirectory, sessionFile } = coordinates;
|
|
3227
3227
|
const entries = await readLawfulSettlementEntries(sessionFile) ?? [];
|
|
3228
3228
|
const submissions = await recordedSubmissionPayloads(admitted, scope);
|
|
3229
|
-
//
|
|
3229
|
+
// #843: collector shape (ledger closed first) plus current user-turn freshness.
|
|
3230
|
+
// A lawful bound non-error seat toolResult (isError === false + one-to-one call
|
|
3231
|
+
// bind, same grade as residual) means this turn sealed — a prior bounce residual
|
|
3232
|
+
// in the same turn must not outrank it. Missing isError, unbound, or mis-bound
|
|
3233
|
+
// results do not establish success and do not reject/abort. A current-attempt
|
|
3234
|
+
// residual without that success is this turn's own failure and must not be
|
|
3235
|
+
// masked by run-scoped stale acceptance (bare resume without courtAttemptId).
|
|
3236
|
+
// Same-turn accept-then-bounce keeps the success marker: terminal stays
|
|
3237
|
+
// accepted; rejection facts remain on payloads/gate (not latest-wins flip).
|
|
3230
3238
|
const scanStart = currentAttemptStartIndex(entries);
|
|
3239
|
+
let thisAttemptHasSeatSuccess = false;
|
|
3240
|
+
let residual: BoundErroredToolCandidate | undefined;
|
|
3231
3241
|
for (let index = entries.length - 1; index >= scanStart; index -= 1) {
|
|
3232
3242
|
const message = entries[index]?.message;
|
|
3233
3243
|
if (message?.role !== "toolResult") continue;
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
},
|
|
3251
|
-
authority,
|
|
3252
|
-
scope ?? {},
|
|
3244
|
+
if (message.toolName !== spec.toolName) continue;
|
|
3245
|
+
if (message.isError === false) {
|
|
3246
|
+
if (
|
|
3247
|
+
boundRoleToolCallForResult(entries, index, message, spec.toolName) !==
|
|
3248
|
+
undefined
|
|
3249
|
+
) {
|
|
3250
|
+
thisAttemptHasSeatSuccess = true;
|
|
3251
|
+
}
|
|
3252
|
+
continue;
|
|
3253
|
+
}
|
|
3254
|
+
if (residual === undefined) {
|
|
3255
|
+
residual = boundErroredToolCandidate(
|
|
3256
|
+
entries,
|
|
3257
|
+
index,
|
|
3258
|
+
message,
|
|
3259
|
+
spec.toolName,
|
|
3253
3260
|
);
|
|
3254
|
-
return withSubmissions(failed, submissions);
|
|
3255
3261
|
}
|
|
3256
3262
|
}
|
|
3257
3263
|
const roleOutcome = await closedLedgerOutcome(admitted, spec.role as TerminalRoleName, scope);
|
|
3258
|
-
if (roleOutcome
|
|
3264
|
+
if (roleOutcome !== undefined && (thisAttemptHasSeatSuccess || residual === undefined)) {
|
|
3259
3265
|
const navigator = extractNavigatorFact(entries);
|
|
3260
3266
|
return withSubmissions(
|
|
3261
3267
|
await withOptionalGateProjection(
|
|
@@ -3271,21 +3277,21 @@ async function settleLawfulSeatAcceptedTerminalResult(
|
|
|
3271
3277
|
submissions,
|
|
3272
3278
|
);
|
|
3273
3279
|
}
|
|
3274
|
-
if (
|
|
3275
|
-
const
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
submissions,
|
|
3280
|
+
if (residual !== undefined) {
|
|
3281
|
+
const details = isRecord(residual.candidate)
|
|
3282
|
+
? residual.candidate
|
|
3283
|
+
: { candidate: residual.candidate };
|
|
3284
|
+
const failed = await settleFailureTerminalResult(
|
|
3285
|
+
admitted,
|
|
3286
|
+
{
|
|
3287
|
+
cause: "output",
|
|
3288
|
+
diagnostic: residual.diagnostic,
|
|
3289
|
+
details,
|
|
3290
|
+
},
|
|
3291
|
+
authority,
|
|
3292
|
+
scope ?? {},
|
|
3288
3293
|
);
|
|
3294
|
+
return withSubmissions(failed, submissions);
|
|
3289
3295
|
}
|
|
3290
3296
|
return undefined;
|
|
3291
3297
|
}
|