effect-agent 0.1.0-beta.135 → 0.1.0-beta.136
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/dist/{Admin-DKqg6zQa.d.mts → Admin-Fx85KT-W.d.mts} +5 -1
- package/dist/{DurableAgentRuntime-DgzI83ng.mjs → DurableAgentRuntime-Bso5grIH.mjs} +4 -4
- package/dist/{DurableAgentRuntime-DgzI83ng.mjs.map → DurableAgentRuntime-Bso5grIH.mjs.map} +1 -1
- package/dist/{EventSource-P4hq8Opp.d.mts → EventSource-DLT8oDK8.d.mts} +2 -2
- package/dist/{PreparedInputAdmission-ChcWS1xV.d.mts → PreparedInputAdmission-CKFgG6Em.d.mts} +3 -3
- package/dist/{RunJournal-BXrq0VIK.mjs → RunJournal-Gd83HYqG.mjs} +50 -27
- package/dist/RunJournal-Gd83HYqG.mjs.map +1 -0
- package/dist/{Subscription-jOOrT8Js.d.mts → Subscription-CCmHgOYM.d.mts} +2 -2
- package/dist/{SubscriptionInput-CPyqenXR.d.mts → SubscriptionInput-BFJMhu4K.d.mts} +2 -2
- package/dist/durable/Admin.d.mts +1 -1
- package/dist/durable/AgentRegistration.d.mts +1 -1
- package/dist/durable/Certification.d.mts +1 -1
- package/dist/durable/CommittedActivity.d.mts +1 -1
- package/dist/durable/DurableAgentRuntime.d.mts +1 -1
- package/dist/durable/DurableAgentRuntime.mjs +1 -1
- package/dist/durable/EventSource.d.mts +1 -1
- package/dist/durable/GitHubWorkflowSource.d.mts +3 -3
- package/dist/durable/MessageDelivery.d.mts +41 -41
- package/dist/durable/MessageDeliveryStoreConformance.d.mts +1 -1
- package/dist/durable/PersistentHistory.d.mts +1 -1
- package/dist/durable/PersistentHistory.mjs +1 -1
- package/dist/durable/PreparedInputAdmission.d.mts +1 -1
- package/dist/durable/Recovery.d.mts +1 -1
- package/dist/durable/RunJournal.d.mts +1 -1
- package/dist/durable/RunJournal.mjs +1 -1
- package/dist/durable/Scheduling.d.mts +1 -1
- package/dist/durable/SqlStorageV2Upgrade.d.mts +1 -1
- package/dist/durable/SqlSubscriptionStore.d.mts +1 -1
- package/dist/durable/SqlThreadNativeReads.d.mts +1 -1
- package/dist/durable/SqlThreadNativeReads.mjs +1 -1
- package/dist/durable/SubmissionLedger.d.mts +1 -1
- package/dist/durable/SubmissionLedgerConformance.d.mts +1 -1
- package/dist/durable/SubmissionLedgerConformance.mjs +1 -1
- package/dist/durable/SubmissionStatus.d.mts +1 -1
- package/dist/durable/Subscription.d.mts +1 -1
- package/dist/durable/SubscriptionInput.d.mts +1 -1
- package/dist/durable/SubscriptionStoreConformance.d.mts +1 -1
- package/dist/durable/SubscriptionTools.d.mts +2 -2
- package/dist/durable/SubscriptionTransition.d.mts +1 -1
- package/dist/durable/Subscriptions.d.mts +5 -5
- package/dist/durable/ThreadContextHistory.d.mts +1 -1
- package/dist/durable/ThreadInvariants.d.mts +1 -1
- package/dist/durable/ThreadInvariants.mjs +1 -1
- package/dist/durable/ThreadProjectionMaintenance.d.mts +1 -1
- package/dist/durable/ThreadStore.d.mts +1 -1
- package/dist/durable/ThreadStore.mjs +1 -1
- package/dist/durable/ThreadStoreConformance.d.mts +1 -1
- package/dist/durable/ThreadStoreConformance.mjs +1 -1
- package/dist/durable/WorkerHost.d.mts +1 -1
- package/dist/index.d.mts +5 -5
- package/dist/index.mjs +2 -2
- package/package.json +1 -1
- package/src/durable/RunJournal.ts +120 -56
- package/src/durable/internal/journal-checkpoint.ts +1 -1
- package/src/durable/internal/journal-metadata.ts +10 -3
- package/dist/RunJournal-BXrq0VIK.mjs.map +0 -1
|
@@ -555,6 +555,9 @@ const PROMPT_TRANSPARENT_TAGS: ReadonlySet<string> = new Set([
|
|
|
555
555
|
* are never canonical settlements or evidence for compaction, recovery or accounting. Real
|
|
556
556
|
* results replace them at the original declaration, including results appended after another Run.
|
|
557
557
|
* Prior user intent and assistant text remain visible; prior system instructions do not.
|
|
558
|
+
* Each Run retains the history preceding its start and its own continuation. Other Runs'
|
|
559
|
+
* subsequent Turns cannot replace its input. Compaction covers only its creator's Run view;
|
|
560
|
+
* a projection without an owner retains interleaved exchanges from the complete Thread history.
|
|
558
561
|
*/
|
|
559
562
|
/** @internal Lightweight canonical boundaries collected without retaining record payloads. */
|
|
560
563
|
export interface JournalBoundary {
|
|
@@ -598,13 +601,11 @@ export const projectRunJournalStream = Effect.fn("RunJournal.projectRunJournalSt
|
|
|
598
601
|
committedTurns: seed?.committedTurns ?? 0,
|
|
599
602
|
};
|
|
600
603
|
|
|
601
|
-
// RUN-026 pre-scan:
|
|
602
|
-
//
|
|
603
|
-
//
|
|
604
|
-
//
|
|
605
|
-
//
|
|
606
|
-
// coversThrough resolve to the record appended later (higher sequence),
|
|
607
|
-
// matching at-most-once replay intent.
|
|
604
|
+
// RUN-026 pre-scan: valid compactions retire only their creator's Run view. A bound
|
|
605
|
+
// stays below its own sequence and cannot split a visible response from its settled results.
|
|
606
|
+
// Pruning and rollovers may cover complete owner-Run batches; a summarize record carries
|
|
607
|
+
// its summary. Invalid records leave full history authoritative. A wider containing view
|
|
608
|
+
// replaces earlier coverage, with equal bounds preferring the later record.
|
|
608
609
|
// One span per settled record, paired with its declaring response the same
|
|
609
610
|
// way the fold pairs them: a settled belongs to the most recent
|
|
610
611
|
// ModelResponseRecorded of its Run. A bound inside (response, settled)
|
|
@@ -634,9 +635,39 @@ export const projectRunJournalStream = Effect.fn("RunJournal.projectRunJournalSt
|
|
|
634
635
|
toolExecutionEvidence,
|
|
635
636
|
settledToolCallRecordIds,
|
|
636
637
|
settledById,
|
|
637
|
-
compactions,
|
|
638
638
|
} = metadata;
|
|
639
639
|
|
|
640
|
+
const declarationByResultSequence = new Map(settledSpans.map(({ from, to }) => [to, from]));
|
|
641
|
+
|
|
642
|
+
const isInRunView = (
|
|
643
|
+
sequence: number,
|
|
644
|
+
payload: { readonly _tag: string; readonly runId?: RunId | undefined },
|
|
645
|
+
runId: RunId | undefined,
|
|
646
|
+
): boolean => {
|
|
647
|
+
if (runId === undefined || payload.runId === undefined || payload.runId === runId) return true;
|
|
648
|
+
const first = firstSequenceByRun.get(runId) ?? Number.POSITIVE_INFINITY;
|
|
649
|
+
|
|
650
|
+
return (
|
|
651
|
+
sequence < first ||
|
|
652
|
+
(payload._tag === "ToolCallSettled" &&
|
|
653
|
+
(declarationByResultSequence.get(sequence) ?? Number.POSITIVE_INFINITY) < first)
|
|
654
|
+
);
|
|
655
|
+
};
|
|
656
|
+
|
|
657
|
+
const compactions = metadata.compactions.filter(({ sequence, payload }) =>
|
|
658
|
+
isInRunView(sequence, payload, ownerRunId),
|
|
659
|
+
);
|
|
660
|
+
|
|
661
|
+
const recordsForRun = records.pipe(
|
|
662
|
+
Stream.filter(({ sequence, record: { payload } }) =>
|
|
663
|
+
isInRunView(sequence, payload, ownerRunId),
|
|
664
|
+
),
|
|
665
|
+
);
|
|
666
|
+
|
|
667
|
+
const isCovered = (envelope: CanonicalRecordEnvelope, compaction: CompactionCreated): boolean =>
|
|
668
|
+
envelope.sequence <= compaction.coversThrough &&
|
|
669
|
+
isInRunView(envelope.sequence, envelope.record.payload, compaction.runId);
|
|
670
|
+
|
|
640
671
|
const settledCoverage = compactions.reduce(
|
|
641
672
|
(through, { payload }) =>
|
|
642
673
|
payload.kind !== "summarize" ? Math.max(through, payload.coversThrough) : through,
|
|
@@ -671,7 +702,7 @@ export const projectRunJournalStream = Effect.fn("RunJournal.projectRunJournalSt
|
|
|
671
702
|
: yield* decodePromptMessages(seed.protectedContext);
|
|
672
703
|
|
|
673
704
|
if (settledCoverage > 0) {
|
|
674
|
-
yield* Stream.runForEach(
|
|
705
|
+
yield* Stream.runForEach(recordsForRun, (envelope) =>
|
|
675
706
|
Effect.gen(function* () {
|
|
676
707
|
const payload = envelope.record.payload;
|
|
677
708
|
|
|
@@ -727,21 +758,54 @@ export const projectRunJournalStream = Effect.fn("RunJournal.projectRunJournalSt
|
|
|
727
758
|
incompleteResponseSequences.some(
|
|
728
759
|
(response) =>
|
|
729
760
|
response.sequence <= coversThrough &&
|
|
761
|
+
isInRunView(
|
|
762
|
+
response.sequence,
|
|
763
|
+
{ _tag: "ModelResponseRecorded", runId: response.runId },
|
|
764
|
+
runId,
|
|
765
|
+
) &&
|
|
730
766
|
!isTerminalPriorRun(response.runId, runId, ownSequence),
|
|
731
767
|
)
|
|
732
768
|
)
|
|
733
769
|
return false;
|
|
734
770
|
for (const span of settledSpans) {
|
|
735
|
-
if (
|
|
771
|
+
if (
|
|
772
|
+
span.from <= coversThrough &&
|
|
773
|
+
coversThrough < span.to &&
|
|
774
|
+
isInRunView(span.from, { _tag: "ModelResponseRecorded", runId: span.runId }, runId)
|
|
775
|
+
)
|
|
776
|
+
return false;
|
|
736
777
|
}
|
|
737
778
|
|
|
738
779
|
return true;
|
|
739
780
|
};
|
|
740
781
|
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
let
|
|
744
|
-
let
|
|
782
|
+
type CompactionView = (typeof compactions)[number];
|
|
783
|
+
|
|
784
|
+
let replacements: ReadonlyArray<CompactionView> = [];
|
|
785
|
+
let clearings: ReadonlyArray<CompactionView> = [];
|
|
786
|
+
|
|
787
|
+
const retainCompaction = (views: ReadonlyArray<CompactionView>, next: CompactionView) => {
|
|
788
|
+
// Independent Run views overlap without containing one another. Retire an overlay only
|
|
789
|
+
// when the replacement actually contains its view, not merely a larger sequence number.
|
|
790
|
+
if (
|
|
791
|
+
views.some(
|
|
792
|
+
(prior) =>
|
|
793
|
+
prior.payload.coversThrough > next.payload.coversThrough &&
|
|
794
|
+
isInRunView(next.sequence, next.payload, prior.payload.runId),
|
|
795
|
+
)
|
|
796
|
+
)
|
|
797
|
+
return views;
|
|
798
|
+
|
|
799
|
+
return [
|
|
800
|
+
...views.filter(
|
|
801
|
+
(prior) =>
|
|
802
|
+
next.payload.coversThrough < prior.payload.coversThrough ||
|
|
803
|
+
!isInRunView(prior.sequence, prior.payload, next.payload.runId),
|
|
804
|
+
),
|
|
805
|
+
next,
|
|
806
|
+
];
|
|
807
|
+
};
|
|
808
|
+
|
|
745
809
|
let latestWindowId: string | undefined = seed?.contextWindowId;
|
|
746
810
|
let latestWindowSequence = seed?.throughSequence ?? -1;
|
|
747
811
|
let rolloverCoveredThrough = 0;
|
|
@@ -756,53 +820,48 @@ export const projectRunJournalStream = Effect.fn("RunJournal.projectRunJournalSt
|
|
|
756
820
|
rolloverCoveredThrough = Math.max(rolloverCoveredThrough, payload.coversThrough);
|
|
757
821
|
if (payload.kind === "summarize" || payload.kind === "rollover") {
|
|
758
822
|
if (payload.kind === "summarize" && payload.summary === undefined) continue;
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
(payload.coversThrough === summarizeBound && sequence > summarizeSequence)
|
|
762
|
-
) {
|
|
763
|
-
summarizeBound = payload.coversThrough;
|
|
764
|
-
summarizeSequence = sequence;
|
|
765
|
-
replacement = payload;
|
|
766
|
-
}
|
|
767
|
-
} else if (payload.coversThrough > clearBound) {
|
|
768
|
-
clearBound = payload.coversThrough;
|
|
769
|
-
}
|
|
823
|
+
replacements = retainCompaction(replacements, { payload, sequence });
|
|
824
|
+
} else clearings = retainCompaction(clearings, { payload, sequence });
|
|
770
825
|
}
|
|
771
826
|
let summaryEmitted = false;
|
|
772
827
|
|
|
773
|
-
const retainedPrefix =
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
828
|
+
const retainedPrefix = replacements.some(
|
|
829
|
+
({ payload }) =>
|
|
830
|
+
payload.kind === "rollover" &&
|
|
831
|
+
payload.runId === ownerRunId &&
|
|
832
|
+
ownerPrefixSequence <= payload.coversThrough,
|
|
833
|
+
)
|
|
834
|
+
? (protectedContext?.content ?? [])
|
|
835
|
+
: [];
|
|
779
836
|
|
|
780
|
-
const replacementLength =
|
|
837
|
+
const replacementLength = retainedPrefix.length + replacements.length;
|
|
781
838
|
|
|
782
839
|
if (seed?.frontier !== undefined)
|
|
783
840
|
onBoundary?.({ ...seed.frontier, promptLength: replacementLength });
|
|
784
841
|
|
|
785
842
|
const emitSummary = () => {
|
|
786
|
-
if (summaryEmitted ||
|
|
843
|
+
if (summaryEmitted || replacements.length === 0) return;
|
|
787
844
|
summaryEmitted = true;
|
|
845
|
+
state.all.push(...retainedPrefix);
|
|
846
|
+
for (const { payload: replacement } of replacements) {
|
|
847
|
+
const message =
|
|
848
|
+
replacement.kind === "rollover"
|
|
849
|
+
? contextWindowMessage(
|
|
850
|
+
contextWindowId(replacement.runId, replacement.turn),
|
|
851
|
+
replacement.handoff,
|
|
852
|
+
)
|
|
853
|
+
: Prompt.makeMessage("user", {
|
|
854
|
+
content: [
|
|
855
|
+
Prompt.makePart("text", {
|
|
856
|
+
text: `${COMPACTION_SUMMARY_PREFIX}${replacement.summary}`,
|
|
857
|
+
}),
|
|
858
|
+
],
|
|
859
|
+
});
|
|
788
860
|
|
|
789
|
-
|
|
790
|
-
replacement.kind
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
replacement.handoff,
|
|
794
|
-
)
|
|
795
|
-
: Prompt.makeMessage("user", {
|
|
796
|
-
content: [
|
|
797
|
-
Prompt.makePart("text", {
|
|
798
|
-
text: `${COMPACTION_SUMMARY_PREFIX}${replacement.summary}`,
|
|
799
|
-
}),
|
|
800
|
-
],
|
|
801
|
-
});
|
|
802
|
-
|
|
803
|
-
state.all.push(...retainedPrefix, message);
|
|
804
|
-
if (replacement.kind !== "rollover" || replacement.runId !== ownerRunId)
|
|
805
|
-
state.before.push(message);
|
|
861
|
+
state.all.push(message);
|
|
862
|
+
if (replacement.kind !== "rollover" || replacement.runId !== ownerRunId)
|
|
863
|
+
state.before.push(message);
|
|
864
|
+
}
|
|
806
865
|
};
|
|
807
866
|
|
|
808
867
|
const modelUsage: Array<ModelCallUsage> = [];
|
|
@@ -986,7 +1045,7 @@ export const projectRunJournalStream = Effect.fn("RunJournal.projectRunJournalSt
|
|
|
986
1045
|
};
|
|
987
1046
|
});
|
|
988
1047
|
|
|
989
|
-
yield* Stream.runForEach(
|
|
1048
|
+
yield* Stream.runForEach(recordsForRun, (envelope) =>
|
|
990
1049
|
Effect.gen(function* () {
|
|
991
1050
|
const payload = envelope.record.payload;
|
|
992
1051
|
|
|
@@ -1020,8 +1079,8 @@ export const projectRunJournalStream = Effect.fn("RunJournal.projectRunJournalSt
|
|
|
1020
1079
|
(payload._tag === "ModelResponseRecorded" || payload._tag === "ToolCallSettled")
|
|
1021
1080
|
)
|
|
1022
1081
|
return;
|
|
1023
|
-
if (
|
|
1024
|
-
//
|
|
1082
|
+
if (replacements.some(({ payload }) => isCovered(envelope, payload))) {
|
|
1083
|
+
// Retiring Prompt payloads does not retire the owning Run's policy or usage accounting.
|
|
1025
1084
|
if (payload._tag === "ModelResponseRecorded" && payload.runId === ownerRunId) {
|
|
1026
1085
|
const messages = yield* decodePromptMessages(payload.messages);
|
|
1027
1086
|
|
|
@@ -1032,7 +1091,7 @@ export const projectRunJournalStream = Effect.fn("RunJournal.projectRunJournalSt
|
|
|
1032
1091
|
onBoundary?.({
|
|
1033
1092
|
sequence: envelope.sequence,
|
|
1034
1093
|
tag: payload._tag,
|
|
1035
|
-
promptLength: replacementLength,
|
|
1094
|
+
promptLength: Math.max(replacementLength, state.all.length),
|
|
1036
1095
|
...(isTerminalPriorRun(payload.runId, ownerRunId, Number.POSITIVE_INFINITY)
|
|
1037
1096
|
? { terminalPriorRun: true }
|
|
1038
1097
|
: {}),
|
|
@@ -1059,7 +1118,9 @@ export const projectRunJournalStream = Effect.fn("RunJournal.projectRunJournalSt
|
|
|
1059
1118
|
slot.parts[slot.partIndex] = Prompt.makePart("tool-result", {
|
|
1060
1119
|
id: payload.toolCallId,
|
|
1061
1120
|
name: payload.toolName,
|
|
1062
|
-
result:
|
|
1121
|
+
result: clearings.some(({ payload }) => isCovered(envelope, payload))
|
|
1122
|
+
? CLEARED_TOOL_RESULT
|
|
1123
|
+
: payload.result,
|
|
1063
1124
|
isFailure: payload.isFailure,
|
|
1064
1125
|
providerExecuted: false,
|
|
1065
1126
|
});
|
|
@@ -1086,7 +1147,10 @@ export const projectRunJournalStream = Effect.fn("RunJournal.projectRunJournalSt
|
|
|
1086
1147
|
) {
|
|
1087
1148
|
state = yield* flushTools(state);
|
|
1088
1149
|
}
|
|
1089
|
-
state.pendingTools.push({
|
|
1150
|
+
state.pendingTools.push({
|
|
1151
|
+
record: payload,
|
|
1152
|
+
cleared: clearings.some(({ payload }) => isCovered(envelope, payload)),
|
|
1153
|
+
});
|
|
1090
1154
|
state = {
|
|
1091
1155
|
...state,
|
|
1092
1156
|
pendingToolsForRun: payload.runId === ownerRunId,
|
|
@@ -56,7 +56,7 @@ export class RecoveryCheckpointContents extends Schema.Class<RecoveryCheckpointC
|
|
|
56
56
|
digest: Digest,
|
|
57
57
|
}) {}
|
|
58
58
|
|
|
59
|
-
export const RECOVERY_ENGINE_VERSION = "effect-agent/recovery@
|
|
59
|
+
export const RECOVERY_ENGINE_VERSION = "effect-agent/recovery@2";
|
|
60
60
|
|
|
61
61
|
/**
|
|
62
62
|
* Late evidence can invalidate an old compaction. Such histories use full canonical replay;
|
|
@@ -14,7 +14,11 @@ export interface JournalMetadata {
|
|
|
14
14
|
readonly firstSequenceByRun: ReadonlyMap<string, number>;
|
|
15
15
|
readonly lastResponseSequenceByRun: ReadonlyMap<string, number>;
|
|
16
16
|
readonly terminalSequenceByRun: ReadonlyMap<string, number>;
|
|
17
|
-
readonly settledSpans: ReadonlyArray<{
|
|
17
|
+
readonly settledSpans: ReadonlyArray<{
|
|
18
|
+
readonly from: number;
|
|
19
|
+
readonly to: number;
|
|
20
|
+
readonly runId: RunId;
|
|
21
|
+
}>;
|
|
18
22
|
readonly toolExecutionEvidence: ReadonlySet<string>;
|
|
19
23
|
readonly settledToolCallRecordIds: ReadonlySet<string>;
|
|
20
24
|
readonly settledById: ReadonlyMap<
|
|
@@ -45,7 +49,10 @@ export const makeJournalMetadata = (
|
|
|
45
49
|
if (seed?.firstSequence !== undefined) firstSequenceByRun.set(seed.runId, seed.firstSequence);
|
|
46
50
|
const lastResponseSequenceByRun = new Map<string, number>();
|
|
47
51
|
const terminalSequenceByRun = new Map<string, number>();
|
|
48
|
-
|
|
52
|
+
|
|
53
|
+
const settledSpans: Array<{ readonly from: number; readonly to: number; readonly runId: RunId }> =
|
|
54
|
+
[];
|
|
55
|
+
|
|
49
56
|
const toolExecutionEvidence = new Set<string>();
|
|
50
57
|
const settledToolCallRecordIds = new Set<string>();
|
|
51
58
|
|
|
@@ -98,7 +105,7 @@ export const makeJournalMetadata = (
|
|
|
98
105
|
const from = lastResponseSequenceByRun.get(payload.runId);
|
|
99
106
|
|
|
100
107
|
if (from !== undefined && from < envelope.sequence)
|
|
101
|
-
settledSpans.push({ from, to: envelope.sequence });
|
|
108
|
+
settledSpans.push({ from, to: envelope.sequence, runId: payload.runId });
|
|
102
109
|
}
|
|
103
110
|
},
|
|
104
111
|
snapshot: (): JournalMetadata => ({
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RunJournal-BXrq0VIK.mjs","names":[],"sources":["../src/durable/internal/journal-metadata.ts","../src/durable/RunJournal.ts"],"sourcesContent":["import { type RunId } from \"../../core/Identifiers.ts\";\nimport {\n type CanonicalRecordEnvelope,\n type CompactionCreated,\n type ToolCallPrepared,\n type ToolCallSettled,\n} from \"../Records.ts\";\nimport { type JournalCheckpointSeed } from \"./journal-checkpoint.ts\";\n\n/** Metadata for one exact canonical prefix, including the same optional checkpoint seed. */\nexport interface JournalMetadata {\n readonly ownerRunId: RunId | undefined;\n readonly seed: JournalCheckpointSeed | undefined;\n readonly firstSequenceByRun: ReadonlyMap<string, number>;\n readonly lastResponseSequenceByRun: ReadonlyMap<string, number>;\n readonly terminalSequenceByRun: ReadonlyMap<string, number>;\n readonly settledSpans: ReadonlyArray<{ readonly from: number; readonly to: number }>;\n readonly toolExecutionEvidence: ReadonlySet<string>;\n readonly settledToolCallRecordIds: ReadonlySet<string>;\n readonly settledById: ReadonlyMap<\n string,\n Pick<ToolCallSettled, \"isFailure\" | \"budgetRejected\" | \"toolSelection\">\n >;\n readonly compactions: ReadonlyArray<{\n readonly payload: CompactionCreated;\n readonly sequence: number;\n }>;\n}\n\nexport const toolExecutionKey = (\n call: Pick<ToolCallPrepared, \"runId\" | \"turn\" | \"toolCallId\">,\n): string => JSON.stringify([call.runId, call.turn, call.toolCallId]);\n\n/**\n * Attempt-local metadata collector. Feed every validated record exactly once, in canonical order,\n * including records omitted from the control view. A snapshot is independent of later suffix\n * additions and may only accompany a replay stream bounded at that same captured tail.\n */\nexport const makeJournalMetadata = (\n ownerRunId: RunId | undefined,\n seed?: JournalCheckpointSeed,\n) => {\n const firstSequenceByRun = new Map<string, number>();\n\n if (seed?.firstSequence !== undefined) firstSequenceByRun.set(seed.runId, seed.firstSequence);\n const lastResponseSequenceByRun = new Map<string, number>();\n const terminalSequenceByRun = new Map<string, number>();\n const settledSpans: Array<{ readonly from: number; readonly to: number }> = [];\n const toolExecutionEvidence = new Set<string>();\n const settledToolCallRecordIds = new Set<string>();\n\n const settledById = new Map<\n string,\n Pick<ToolCallSettled, \"isFailure\" | \"budgetRejected\" | \"toolSelection\">\n >();\n\n const compactions: Array<{ readonly payload: CompactionCreated; readonly sequence: number }> = [];\n\n return {\n add: (envelope: CanonicalRecordEnvelope): void => {\n const payload = envelope.record.payload;\n\n if (\n (payload._tag === \"RunCompleted\" ||\n payload._tag === \"RunFailed\" ||\n payload._tag === \"SubmissionSettled\") &&\n payload.runId !== undefined &&\n !terminalSequenceByRun.has(payload.runId)\n )\n terminalSequenceByRun.set(payload.runId, envelope.sequence);\n if (payload._tag === \"CompactionCreated\") {\n compactions.push({ payload, sequence: envelope.sequence });\n\n return;\n }\n if (\n \"runId\" in payload &&\n typeof payload.runId === \"string\" &&\n !firstSequenceByRun.has(payload.runId)\n )\n firstSequenceByRun.set(payload.runId, envelope.sequence);\n if (payload._tag === \"ModelResponseRecorded\") {\n lastResponseSequenceByRun.set(payload.runId, envelope.sequence);\n } else if (payload._tag === \"ToolCallPrepared\" || payload._tag === \"ToolCallUnknown\") {\n toolExecutionEvidence.add(toolExecutionKey(payload));\n } else if (payload._tag === \"ToolCallSettled\") {\n settledToolCallRecordIds.add(envelope.record.recordId);\n if (payload.runId === ownerRunId)\n settledById.set(envelope.record.recordId, {\n isFailure: payload.isFailure,\n ...(payload.toolSelection === undefined\n ? {}\n : { toolSelection: payload.toolSelection }),\n ...(payload.budgetRejected === undefined\n ? {}\n : { budgetRejected: payload.budgetRejected }),\n });\n const from = lastResponseSequenceByRun.get(payload.runId);\n\n if (from !== undefined && from < envelope.sequence)\n settledSpans.push({ from, to: envelope.sequence });\n }\n },\n snapshot: (): JournalMetadata => ({\n ownerRunId,\n seed,\n firstSequenceByRun: new Map(firstSequenceByRun),\n lastResponseSequenceByRun: new Map(lastResponseSequenceByRun),\n terminalSequenceByRun: new Map(terminalSequenceByRun),\n settledSpans: [...settledSpans],\n toolExecutionEvidence: new Set(toolExecutionEvidence),\n settledToolCallRecordIds: new Set(settledToolCallRecordIds),\n settledById: new Map(settledById),\n compactions: [...compactions],\n }),\n };\n};\n","import { type Crypto, Effect, Schema, Stream, type DateTime } from \"effect\";\nimport { Prompt } from \"effect/unstable/ai\";\n\nimport { ThreadId, RunId, ToolCallId, TurnId, type SubmissionId } from \"../core/Identifiers.ts\";\nimport { type ExhaustedLimit } from \"../core/RunEvent.ts\";\nimport { RunPolicyUsage } from \"../core/RunPolicyUsage.ts\";\nimport { type Selection, type Snapshot } from \"../core/ToolExposure.ts\";\nimport type { ToolParameterRejection } from \"../core/ToolResult.ts\";\nimport { ModelCallUsage, summarizeModelUsage, type RunUsageSummary } from \"../core/Usage.ts\";\nimport type { WorkerRef } from \"../core/Worker.ts\";\nimport {\n CLEARED_TOOL_RESULT,\n COMPACTION_SUMMARY_PREFIX,\n contextWindowId,\n contextWindowMessage,\n} from \"../engine/Compaction.ts\";\nimport { digestJson, type DigestError } from \"./Digest.ts\";\nimport { type JournalCheckpointSeed } from \"./internal/journal-checkpoint.ts\";\nimport {\n makeJournalMetadata,\n toolExecutionKey,\n type JournalMetadata,\n} from \"./internal/journal-metadata.ts\";\nimport {\n BatchId,\n CanonicalBatch,\n CompactionCreated,\n ModelResponseRecorded,\n PersistedJson,\n RecordEnvelope,\n RecordId,\n RunCompleted,\n ToolCallSettled,\n type CanonicalRecordEnvelope,\n type CanonicalSequence,\n type DeploymentId,\n type ProducerId,\n} from \"./Records.ts\";\nimport { IdempotencyKey } from \"./SubmissionLedger.ts\";\n\n/** A canonical record could not be projected into Run/Prompt state. */\nexport class RunJournalError extends Schema.TaggedError<RunJournalError>()(\"RunJournalError\", {\n message: Schema.String,\n cause: Schema.optionalKey(Schema.Defect()),\n}) {}\n\nconst journalError = (message: string, cause?: unknown): RunJournalError =>\n cause === undefined\n ? RunJournalError.make({ message })\n : RunJournalError.make({ message, cause });\n\nconst decodeRunId = Schema.decodeSync(RunId);\nconst decodeTurnId = Schema.decodeSync(TurnId);\nconst decodeBatchId = Schema.decodeSync(BatchId);\nconst decodeRecordId = Schema.decodeSync(RecordId);\n\n/**\n * Deterministic Run identity pinned per Submission (plan §Coordinator flow). Every Attempt of one\n * Submission shares this Run identity, so canonical per-Turn records from different Attempts\n * belong to one logical Run.\n */\nexport const runIdForSubmission = (submissionId: SubmissionId): RunId =>\n decodeRunId(`run:${submissionId}`);\n\n/** Stable canonical clock identity shared by every Attempt of one Run. */\nexport const runStartedRecordId = (runId: RunId): RecordId => decodeRecordId(`run-start:${runId}`);\n\nexport const runStartedBatchId = (runId: RunId): BatchId => decodeBatchId(`run-start:${runId}`);\n\nexport const runDurationRecordId = (runId: RunId): RecordId =>\n decodeRecordId(`run-duration:${runId}`);\n\nexport const runDurationBatchId = (runId: RunId): BatchId => decodeBatchId(`run-duration:${runId}`);\n\n/** Deterministic Turn identity: Attempt-independent for one (Run, canonical turn) pair. */\nexport const turnIdForRun = (runId: RunId, turn: number): TurnId =>\n decodeTurnId(`turn:${runId}:${turn}`);\n\n/** Deterministic batch identity of one committed canonical no-tool Turn (P4 single-batch shape). */\nexport const turnBatchId = (runId: RunId, turn: number): BatchId =>\n decodeBatchId(`turn:${runId}:${turn}`);\n\n/**\n * Deterministic batch identity of a tool-declaring Turn's RESPONSE commit (plan §2.1 commit 1):\n * the assistant response plus pending steering becomes canonical BEFORE approval preflight and\n * tool preparation, creating the durability §15 \"resume tool scheduling\" window.\n */\nexport const turnResponseBatchId = (runId: RunId, turn: number): BatchId =>\n decodeBatchId(`turn-response:${runId}:${turn}`);\n\n/**\n * Deterministic batch identity of a tool-declaring Turn's RESULTS commit (plan §2.1 commit 5):\n * every `ToolCallSettled` record of the Turn, in declaration order, model-visible atomically.\n */\nexport const turnResultsBatchId = (runId: RunId, turn: number): BatchId =>\n decodeBatchId(`turn-results:${runId}:${turn}`);\n\n/**\n * Deterministic per-call late-settle batch identity used by the resolution path when one\n * recovered/resolved call settles outside its Turn's results batch. Record identity\n * (`tool-settled:{runId}:{turn}:{toolCallId}`) dedupes double-settles across both paths.\n */\nexport const toolCallResultBatchId = (\n runId: RunId,\n turn: number,\n toolCallId: ToolCallId,\n): BatchId => decodeBatchId(`turn-results:${runId}:${turn}:${toolCallId}`);\n\n/** Deterministic batch identity of one Turn's `ToolCallPrepared` commit (plan §2.1 commit 3). */\nexport const turnPreparedBatchId = (runId: RunId, turn: number): BatchId =>\n decodeBatchId(`turn-prepared:${runId}:${turn}`);\n\n/**\n * Deterministic identity of one pre-Turn compaction record (RUN-026,\n * RUN-026). Keyed by Run, Turn, and kind — the engine performs at most one\n * threshold compaction per Turn plus at most one overflow-forced summarize,\n * so a superseding Attempt that re-decides the same compaction replays the\n * batch identity instead of duplicating the record.\n */\nexport const compactionRecordId = (\n runId: RunId,\n turn: number,\n kind: \"clear-tool-results\" | \"summarize\" | \"rollover\",\n): RecordId => decodeRecordId(`compaction:${runId}:${turn}:${kind}`);\n\n/** Deterministic batch identity of one compaction append (same string as its record id). */\nexport const compactionBatchId = (\n runId: RunId,\n turn: number,\n kind: \"clear-tool-results\" | \"summarize\" | \"rollover\",\n): BatchId => decodeBatchId(`compaction:${runId}:${turn}:${kind}`);\n\n/** Deterministic canonical record identity of one Turn's `ModelResponseRecorded` record. */\nexport const modelResponseRecordId = (runId: RunId, turn: number): RecordId =>\n decodeRecordId(`model-response:${runId}:${turn}`);\n\n/** Terminal Tool completion marker committed atomically with its settled Tool result. */\nexport const runCompletedRecordId = (runId: RunId): RecordId =>\n decodeRecordId(`run-completed:${runId}`);\n\n/** Native source reservation locator, including the first admission of a continuing worker. */\nexport const workerInputRecordId = (messageId: IdempotencyKey): RecordId =>\n decodeRecordId(`worker-input:${messageId}`);\n\n/** Source-owned first reservation; native worker identity is minted from its first message. */\nexport const firstWorkerInputRecordId = (worker: WorkerRef): RecordId =>\n decodeRecordId(`worker-input:${worker.threadId}`);\n\nexport const workerOriginRecordId = (threadId: ThreadId): RecordId =>\n decodeRecordId(`worker-origin:${threadId}`);\n\nexport const workerReportRecordId = (messageId: IdempotencyKey): RecordId =>\n decodeRecordId(`worker-report:${messageId}`);\n\nexport const peerMessageRecordId = (messageId: IdempotencyKey): RecordId =>\n decodeRecordId(messageId);\n\n/** Same immutable tuple used by native update admission; callers never parse its hash. */\nexport const agentUpdateRecordId = Effect.fn(\"RunJournal.agentUpdateRecordId\")(function* (\n threadId: ThreadId,\n runId: RunId,\n updateId: IdempotencyKey,\n) {\n return decodeRecordId(`agent-update:${yield* digestJson([threadId, runId, updateId])}`);\n});\n\n/** Deterministic canonical record identity of one Turn's `ToolCallSettled` record. */\nexport const toolCallSettledRecordId = (\n runId: RunId,\n turn: number,\n toolCallId: ToolCallId,\n): RecordId => decodeRecordId(`tool-settled:${runId}:${turn}:${toolCallId}`);\n\n/** Deterministic canonical record identity of one Tool Call's `ToolCallPrepared` record. */\nexport const toolCallPreparedRecordId = (\n runId: RunId,\n turn: number,\n toolCallId: ToolCallId,\n): RecordId => decodeRecordId(`tool-prepared:${runId}:${turn}:${toolCallId}`);\n\n/** Deterministic batch identity of one Turn's `ToolCallUnknown` marking append. */\nexport const markUnknownBatchId = (submissionId: SubmissionId, turn: number): BatchId =>\n decodeBatchId(`mark-unknown:${submissionId}:${turn}`);\n\n/** Deterministic canonical record identity of one Tool Call's `ToolCallUnknown` record. */\nexport const toolCallUnknownRecordId = (\n runId: RunId,\n turn: number,\n toolCallId: ToolCallId,\n): RecordId => decodeRecordId(`tool-unknown:${runId}:${turn}:${toolCallId}`);\n\n/** Deterministic batch identity of one Tool Call's resolution append (DUR-017). */\nexport const toolCallResolutionBatchId = (\n submissionId: SubmissionId,\n toolCallId: ToolCallId,\n): BatchId => decodeBatchId(`resolve:${submissionId}:${toolCallId}`);\n\n/** Deterministic canonical record identity of one Tool Call's `ToolCallResolved` record. */\nexport const toolCallResolvedRecordId = (\n runId: RunId,\n turn: number,\n toolCallId: ToolCallId,\n): RecordId => decodeRecordId(`tool-resolved:${runId}:${turn}:${toolCallId}`);\n\n/**\n * Deterministic identity of one accepted Durable Step result. The one-record batch reuses the\n * SAME string, so batch idempotency plus the epoch fence realize the durability §11\n * racing-writers rule: only the fenced winner's record commits; the loser replays it.\n * A versioned JSON tuple keeps separator characters in each identity component distinct.\n * Replay derives this key from the structured payload, including records with legacy IDs.\n */\nexport const toolStepSettledRecordId = (\n runId: RunId,\n toolCallId: ToolCallId,\n stepName: string,\n): RecordId => decodeRecordId(JSON.stringify([\"step@2\", runId, toolCallId, stepName]));\n\n/** Deterministic batch identity of one Durable Step commit (same string as its record id). */\nexport const toolStepSettledBatchId = (\n runId: RunId,\n toolCallId: ToolCallId,\n stepName: string,\n): BatchId => decodeBatchId(toolStepSettledRecordId(runId, toolCallId, stepName));\n\n/** Deterministic batch identity of one Turn's canonical approval-request append (plan §2.6). */\nexport const turnApprovalsBatchId = (runId: RunId, turn: number): BatchId =>\n decodeBatchId(`turn-approvals:${runId}:${turn}`);\n\n/** Deterministic canonical record identity of one Tool Call's `ToolApprovalRequested` record. */\nexport const toolApprovalRequestRecordId = (\n runId: RunId,\n turn: number,\n toolCallId: ToolCallId,\n): RecordId => decodeRecordId(`approval-request:${runId}:${turn}:${toolCallId}`);\n\n/** Deterministic batch identity of one Tool Call's canonical approval-decision append. */\nexport const approvalDecisionBatchId = (\n submissionId: SubmissionId,\n toolCallId: ToolCallId,\n): BatchId => decodeBatchId(`approval-decision:${submissionId}:${toolCallId}`);\n\n/** Deterministic canonical record identity of one Tool Call's `ToolApprovalDecided` record. */\nexport const toolApprovalDecisionRecordId = (\n runId: RunId,\n turn: number,\n toolCallId: ToolCallId,\n): RecordId => decodeRecordId(`approval-decision:${runId}:${turn}:${toolCallId}`);\n\n/**\n * Deterministic identity of one superseded Attempt's `ModelResponseInterrupted` audit record\n * (durability §9). Keyed by the superseded epoch, so each interrupted ownership period is\n * recorded at most once; the one-record batch reuses the same string.\n */\nexport const modelResponseInterruptedRecordId = (runId: RunId, supersededEpoch: number): RecordId =>\n decodeRecordId(`interrupted:${runId}:${supersededEpoch}`);\n\n/** Deterministic batch identity of one `ModelResponseInterrupted` append (same string). */\nexport const modelResponseInterruptedBatchId = (runId: RunId, supersededEpoch: number): BatchId =>\n decodeBatchId(`interrupted:${runId}:${supersededEpoch}`);\n\nconst decodeThreadId = Schema.decodeSync(ThreadId);\nconst decodeIdempotencyKey = Schema.decodeSync(IdempotencyKey);\n\n/**\n * Deterministic canonical record identity of one parent Tool Call's `SubagentRequested` record.\n * The one-record batch reuses the same string, so batch\n * idempotency plus the parent epoch fence make the request append exactly-once-canonical.\n */\nexport const subagentRequestedRecordId = (runId: RunId, toolCallId: ToolCallId): RecordId =>\n decodeRecordId(`subagent-requested:${runId}:${toolCallId}`);\n\n/** Deterministic batch identity of one `SubagentRequested` append (same string). */\nexport const subagentRequestedBatchId = (runId: RunId, toolCallId: ToolCallId): BatchId =>\n decodeBatchId(`subagent-requested:${runId}:${toolCallId}`);\n\n/**\n * Deterministic canonical record identity of one parent Tool Call's `SubagentStarted` record.\n * Recovery's start-link repair appends the EXACT same record\n * under this identity, so a raced repair replays instead of duplicating (SUB-016/SUB-017).\n */\nexport const subagentStartedRecordId = (runId: RunId, toolCallId: ToolCallId): RecordId =>\n decodeRecordId(`subagent-started:${runId}:${toolCallId}`);\n\n/** Deterministic batch identity of one `SubagentStarted` append (same string). */\nexport const subagentStartedBatchId = (runId: RunId, toolCallId: ToolCallId): BatchId =>\n decodeBatchId(`subagent-started:${runId}:${toolCallId}`);\n\n/**\n * Deterministic batch identity of one parent Tool Call's atomic settlement join: the\n * `SubagentJoined` record plus the parent's `ToolCallSettled` record (its existing\n * `tool-settled:{runId}:{turn}:{toolCallId}` identity) commit as ONE canonical batch (SUB-019).\n */\nexport const subagentJoinBatchId = (runId: RunId, toolCallId: ToolCallId): BatchId =>\n decodeBatchId(`subagent-join:${runId}:${toolCallId}`);\n\n/** Deterministic canonical record identity of one parent Tool Call's `SubagentJoined` record. */\nexport const subagentJoinedRecordId = (runId: RunId, toolCallId: ToolCallId): RecordId =>\n decodeRecordId(`subagent-joined:${runId}:${toolCallId}`);\n\n/**\n * Deterministic identity of one child Thread's `SubagentLineageRecorded` record.\n * Its own single-record batch reuses the same string so the generic\n * `thread-created:{cid}` batch identity is never contradicted.\n */\nexport const subagentLineageRecordId = (threadId: ThreadId): RecordId =>\n decodeRecordId(`subagent-lineage:${threadId}`);\n\n/** Deterministic batch identity of one `SubagentLineageRecorded` append (same string). */\nexport const subagentLineageBatchId = (threadId: ThreadId): BatchId =>\n decodeBatchId(`subagent-lineage:${threadId}`);\n\n/**\n * Deterministic intended child Thread identity: the\n * parent Submission and Tool Call pair addresses exactly one child Thread, so a replayed\n * establishment converges on the one existing child (SUB-016).\n */\nexport const childThreadIdFor = (\n parentSubmissionId: SubmissionId,\n toolCallId: ToolCallId,\n): ThreadId => decodeThreadId(`subagent:${parentSubmissionId}:${toolCallId}`);\n\n/**\n * Deterministic child admission idempotency key: scoped to\n * the parent Run and Tool Call identity, so duplicate admission attempts resolve through the\n * ledger's idempotency contract to one child Receipt (SUB-016, SUB-031). The ledger key is\n * bounded (256); coordinator-minted Run and Tool Call identities stay far below that bound.\n */\nexport const childIdempotencyKeyFor = (\n parentRunId: RunId,\n toolCallId: ToolCallId,\n): IdempotencyKey => decodeIdempotencyKey(`subagent:${parentRunId}:${toolCallId}`);\n\nconst decodePromptMessages = Effect.fn(\"RunJournal.decodePromptMessages\")(\n (messages: PersistedJson): Effect.Effect<Prompt.Prompt, RunJournalError> =>\n Schema.decodeUnknownEffect(Prompt.Prompt)(messages).pipe(\n Effect.mapError((cause) =>\n journalError(\"Canonical messages are not Schema-encoded Prompt messages\", cause),\n ),\n ),\n);\n\ninterface PendingSettledTool {\n readonly record: ToolCallSettled;\n /** RUN-026: a `clear-tool-results` compaction covers this record's sequence. */\n readonly cleared: boolean;\n}\n\nconst toolMessageFromSettled = Effect.fn(\"RunJournal.toolMessageFromSettled\")(\n (settled: ReadonlyArray<PendingSettledTool>): Effect.Effect<Prompt.Message, RunJournalError> =>\n Effect.try({\n try: () =>\n Prompt.makeMessage(\"tool\", {\n content: settled.map(({ record, cleared }) =>\n Prompt.makePart(\"tool-result\", {\n id: record.toolCallId,\n name: record.toolName,\n result: cleared ? CLEARED_TOOL_RESULT : record.result,\n isFailure: record.isFailure,\n providerExecuted: false,\n }),\n ),\n }),\n catch: (cause) => journalError(\"Unable to rebuild Tool message from ToolCallSettled\", cause),\n }),\n);\n\n/**\n * Pure canonical projection of one Run's durable execution state.\n *\n * Prompt reconstruction contract (D8):\n *\n * - `ModelResponseRecorded.messages` carries the Schema-encoded Prompt messages the Turn appended\n * to the model-visible prompt — for the Run's FIRST committed Turn that includes the evaluated\n * instruction and user-input messages, for later Turns only the assistant response messages.\n * Tool messages are excluded from `messages`.\n * - `ToolCallSettled` records (committed in the same per-Turn batch, in declaration order)\n * deterministically rebuild the Turn's single Tool message.\n * - `UserInputRecorded` records input, with a Submission identity only for durable admission. Its\n * Prompt-visible form (instructions + user message) becomes canonical inside the owning Run's\n * first `ModelResponseRecorded`. The projection consumes it only for Run correlation.\n * - Immediate retained history uses `ModelCompleted.messages` for the successful Run's exact\n * native Prompt suffix, including any input examples. It has no resumable Turn state.\n */\n/** Cumulative committed usage of the projected Run (RUN-023 resume re-seed). */\nexport interface RunJournalUsage {\n readonly modelCalls: number;\n /** Known accounting gaps retained across Attempts without changing numeric usage totals. */\n readonly unobservedModelCalls?: number | undefined;\n readonly inputTokens: number;\n readonly outputTokens: number;\n readonly lastInputTokens: number;\n readonly lastOutputTokens: number;\n /** Cumulative persisted spend of the projected Run's committed calls (RUN-023). */\n readonly costMicrousd: number;\n /** Canonical per-call detail used for settlement aggregation and recovery. */\n readonly modelUsage: ReadonlyArray<ModelCallUsage>;\n /** Detailed usage of retired records, grouped without retaining per-call payloads. */\n readonly summarizedModelUsage?: RunUsageSummary | undefined;\n}\n\nexport interface RunJournalProjection {\n readonly toolSelection?: Selection | undefined;\n readonly policyUsage: RunPolicyUsage;\n /** Canonical projection for the requested Run; may end at its resumable Tool declaration. */\n readonly prompt: Prompt.Prompt;\n /** Prior-Run history with model-only unknown results closing incomplete application calls. */\n readonly historyBefore: Prompt.Prompt;\n /** Number of canonical Turns already committed for the projected Run. */\n readonly committedTurns: number;\n /** Summed per-call usage of the projected Run's committed responses; zeros for records predating usage capture. */\n readonly usage: RunJournalUsage;\n /** Latest committed context window identity, retained across ownership changes. */\n readonly contextWindowId?: string | undefined;\n /** Canonical evaluated instructions and initial input for this Run, independent of the view. */\n readonly protectedContext?: Prompt.Prompt | undefined;\n /** Last successful singleton Tool awaiting possible context-control interpretation by the engine. */\n readonly pendingContextToolCallId?: string | undefined;\n}\n\ninterface ProjectedResponseUsage {\n readonly modelCalls: number;\n readonly inputTokens: number;\n readonly outputTokens: number;\n readonly costMicrousd: number;\n readonly modelUsage: ReadonlyArray<ModelCallUsage>;\n}\n\nconst projectedResponseUsage = (\n response: ModelResponseRecorded,\n): Effect.Effect<ProjectedResponseUsage, RunJournalError> =>\n Effect.gen(function* () {\n const calls = response.modelUsage;\n\n if (calls === undefined) {\n return {\n modelCalls: 1,\n inputTokens: response.inputTokens ?? 0,\n outputTokens: response.outputTokens ?? 0,\n costMicrousd: response.costMicrousd ?? 0,\n modelUsage: [],\n };\n }\n if (calls.length === 0) {\n return yield* journalError(\"A canonical modelUsage list must not be empty\");\n }\n\n const summary = yield* summarizeModelUsage(calls).pipe(\n Effect.mapError((cause) =>\n journalError(\"Canonical model usage exceeds accounting bounds\", cause),\n ),\n );\n\n if (\n (response.inputTokens !== undefined && response.inputTokens !== summary.inputTokens.total) ||\n (response.outputTokens !== undefined &&\n response.outputTokens !== summary.outputTokens.total) ||\n (response.costMicrousd !== undefined && response.costMicrousd !== summary.costMicrousd)\n ) {\n return yield* journalError(\"Canonical detailed and aggregate model usage disagree\");\n }\n\n return {\n modelCalls: summary.modelCalls,\n inputTokens: summary.inputTokens.total,\n outputTokens: summary.outputTokens.total,\n costMicrousd: summary.costMicrousd,\n modelUsage: calls,\n };\n });\n\nconst addProjectedUsage = (\n field: string,\n left: number,\n right: number,\n): Effect.Effect<number, RunJournalError> =>\n Schema.decodeEffect(Schema.Natural)(left + right).pipe(\n Effect.mapError((cause) =>\n journalError(`Canonical projected usage exceeds safe-integer bounds at ${field}`, cause),\n ),\n );\n\ninterface FoldState {\n readonly all: Array<Prompt.Message>;\n readonly before: Array<Prompt.Message>;\n readonly pendingTools: Array<PendingSettledTool>;\n readonly pendingToolsForRun: boolean;\n readonly committedTurns: number;\n}\n\nconst decodeToolCallId = Schema.decodeSync(ToolCallId);\n\nconst declaredApplicationToolCallIds = (prompt: Prompt.Prompt): ReadonlyArray<string> => {\n const ids: Array<string> = [];\n\n for (const message of prompt.content) {\n if (message.role !== \"assistant\") continue;\n for (const part of message.content) {\n if (part.type === \"tool-call\" && !part.providerExecuted) ids.push(part.id);\n }\n }\n\n return ids;\n};\n\n/**\n * Phase 5 audit tags that are prompt-transparent: they carry durability evidence (preparation,\n * unknown marking, resolution, Step results, approvals, interruption) but contribute nothing to\n * the model-visible Prompt, and — unlike the P4 tags — they do NOT split a contiguous\n * `ToolCallSettled` group into separate Tool messages, so a late-settled call's audit records\n * cannot change the replayed prompt shape.\n *\n * The four S2 Subagent lifecycle tags are prompt-transparent for the same reason (spec §5/§11):\n * the parent prompt never carries child transcript or establishment evidence — the joined child\n * result reaches the model exclusively through the paired `ToolCallSettled` record, and the\n * child-log lineage record is not model input.\n */\nconst PROMPT_TRANSPARENT_TAGS: ReadonlySet<string> = new Set([\n \"RunPolicyUsageReserved\",\n \"RunStarted\",\n \"RunDurationExhausted\",\n \"ToolCallPrepared\",\n \"ToolCallUnknown\",\n \"ToolCallResolved\",\n \"ToolStepSettled\",\n \"ToolApprovalRequested\",\n \"ToolApprovalDecided\",\n \"ModelResponseInterrupted\",\n \"SubagentRequested\",\n \"SubagentStarted\",\n \"SubagentJoined\",\n \"SubagentLineageRecorded\",\n \"WorkerInputRequested\",\n \"WorkerOriginRecorded\",\n \"WorkerInputCompleted\",\n \"WorkerReportPrepared\",\n \"AgentUpdateEmitted\",\n \"WorkerReportRefused\",\n \"PeerMessagePrepared\",\n \"SubtreeBudgetReserved\",\n]);\n\n/**\n * Pure projection: rebuild one Run's resume state from canonical records (DUR-015). Canonical\n * order is authoritative; the fold projects each `ModelResponseRecorded` Turn and the\n * owning Run's resumable incomplete Tool Turn. It flushes each contiguous group of valid `ToolCallSettled` records into one Tool message,\n * exactly mirroring the per-Turn commit shape produced by `turnCanonicalBatch` (no-tool Turns) and\n * by the\n * `turnResponseBatch`/`turnResultsBatch` split (tool-declaring Turns). The Phase 5 audit tags\n * are skipped transparently, so split-batch commits replay to the same prompt as P4 single-batch\n * commits.\n *\n * An incomplete application Tool turn remains visible while projecting its owning Run so active\n * recovery can resume the declared batch. It is not a valid model-visible Turn boundary for a\n * later Run until model-only unknown results close its missing calls. Those explanatory results\n * are never canonical settlements or evidence for compaction, recovery or accounting. Real\n * results replace them at the original declaration, including results appended after another Run.\n * Prior user intent and assistant text remain visible; prior system instructions do not.\n */\n/** @internal Lightweight canonical boundaries collected without retaining record payloads. */\nexport interface JournalBoundary {\n readonly sequence: CanonicalSequence;\n readonly tag: \"ModelResponseRecorded\" | \"ToolCallSettled\";\n readonly promptLength: number;\n /** A declaration without all settled results requires terminal-prior-Run proof for coverage. */\n readonly incomplete?: true | undefined;\n /** The Run terminated after its last response and differs from the projection's owner. */\n readonly terminalPriorRun?: true | undefined;\n}\n\n/**\n * Reconstruct a fixed canonical prefix from a re-readable stream. The caller must keep the same\n * records visible on every traversal. The first collects compaction and settlement metadata;\n * rollovers additionally validate covered Tool batches before rebuilding Prompt and usage. Metadata and the\n * live Prompt remain resident; covered historical message/tool payloads do not. An uncompacted Prompt still grows\n * with its conversation, so hosts must configure an appropriate context compaction policy.\n * Prepared metadata must describe exactly this stream and seed through the same fixed tail;\n * it skips only the metadata scan, never covered-Tool validation or the canonical fold.\n * @internal\n */\nexport const projectRunJournalStream = Effect.fn(\"RunJournal.projectRunJournalStream\")(function* <\n E,\n R,\n>(\n records: Stream.Stream<CanonicalRecordEnvelope, E, R>,\n ownerRunId: RunId | undefined,\n onBoundary?: (boundary: JournalBoundary) => void,\n seed?: JournalCheckpointSeed,\n preparedMetadata?: JournalMetadata,\n): Effect.fn.Return<RunJournalProjection, RunJournalError | E, R> {\n if (seed !== undefined && seed.runId !== ownerRunId)\n return yield* journalError(\"Recovery checkpoint belongs to another Run\");\n\n let state: FoldState = {\n all: [],\n before: [],\n pendingTools: [],\n pendingToolsForRun: false,\n committedTurns: seed?.committedTurns ?? 0,\n };\n\n // RUN-026 pre-scan: the widest VALID compaction bounds govern the fold. A\n // valid record covers strictly below its own sequence and never splits a response from its\n // settled tool results. Pruning and rollovers may cover complete owner-Run batches;\n // a summarize record must carry its summary. Invalid records\n // are ignored fail-safe — the full history stays authoritative. Ties on\n // coversThrough resolve to the record appended later (higher sequence),\n // matching at-most-once replay intent.\n // One span per settled record, paired with its declaring response the same\n // way the fold pairs them: a settled belongs to the most recent\n // ModelResponseRecorded of its Run. A bound inside (response, settled)\n // would orphan the tool message from its declaring response. Orphaned\n // settleds (filtered later by the fold) still contribute spans —\n // over-invalidating is the fail-safe direction.\n if (\n preparedMetadata !== undefined &&\n (preparedMetadata.ownerRunId !== ownerRunId || preparedMetadata.seed !== seed)\n )\n return yield* journalError(\"Prepared journal metadata belongs to another replay\");\n\n let metadata = preparedMetadata;\n\n if (metadata === undefined) {\n const collected = makeJournalMetadata(ownerRunId, seed);\n\n yield* Stream.runForEach(records, (envelope) => Effect.sync(() => collected.add(envelope)));\n metadata = collected.snapshot();\n }\n\n const {\n firstSequenceByRun,\n lastResponseSequenceByRun,\n terminalSequenceByRun,\n settledSpans,\n toolExecutionEvidence,\n settledToolCallRecordIds,\n settledById,\n compactions,\n } = metadata;\n\n const settledCoverage = compactions.reduce(\n (through, { payload }) =>\n payload.kind !== \"summarize\" ? Math.max(through, payload.coversThrough) : through,\n 0,\n );\n\n // Terminality changes only prompt coverage; it never settles or resolves the Tool Call.\n // Compare against the compaction's Run and sequence, independent of the replay's owner.\n const isTerminalPriorRun = (\n candidateRunId: RunId,\n compactionRunId: RunId | undefined,\n beforeSequence: number,\n ): boolean => {\n const terminal = terminalSequenceByRun.get(candidateRunId);\n\n return (\n candidateRunId !== compactionRunId &&\n terminal !== undefined &&\n terminal < beforeSequence &&\n terminal > (lastResponseSequenceByRun.get(candidateRunId) ?? 0)\n );\n };\n\n const incompleteResponseSequences: Array<{ readonly sequence: number; readonly runId: RunId }> =\n [];\n\n let ownerPrefixSequence = seed?.firstSequence ?? Number.POSITIVE_INFINITY;\n\n let protectedContext: Prompt.Prompt | undefined =\n seed?.protectedContext === undefined\n ? undefined\n : yield* decodePromptMessages(seed.protectedContext);\n\n if (settledCoverage > 0) {\n yield* Stream.runForEach(records, (envelope) =>\n Effect.gen(function* () {\n const payload = envelope.record.payload;\n\n if (payload._tag !== \"ModelResponseRecorded\" || envelope.sequence > settledCoverage) return;\n const messages = yield* decodePromptMessages(payload.messages);\n const declared = declaredApplicationToolCallIds(messages);\n\n for (const id of declared) {\n const callId = yield* Schema.decodeEffect(ToolCallId)(id).pipe(\n Effect.mapError((cause) =>\n journalError(\"Failed to decode a declared Tool Call ID\", cause),\n ),\n );\n\n if (\n !settledToolCallRecordIds.has(\n toolCallSettledRecordId(payload.runId, payload.turn, callId),\n )\n ) {\n incompleteResponseSequences.push({ sequence: envelope.sequence, runId: payload.runId });\n break;\n }\n }\n if (\n payload.runId === ownerRunId &&\n payload.turn === 1 &&\n payload.runScopedPrefixLength !== undefined\n ) {\n ownerPrefixSequence = envelope.sequence;\n protectedContext = Prompt.fromMessages(\n messages.content.slice(0, payload.runScopedPrefixLength),\n );\n }\n }),\n );\n }\n\n const boundIsValid = (payload: CompactionCreated, ownSequence: number): boolean => {\n const { runId, coversThrough } = payload;\n\n if (coversThrough <= 0 || coversThrough >= ownSequence) return false;\n if (seed !== undefined && ownSequence === seed.compaction.sequence)\n return (\n seed.compaction.record.payload._tag === \"CompactionCreated\" &&\n Schema.toEquivalence(CompactionCreated)(payload, seed.compaction.record.payload)\n );\n const ownerFirst = firstSequenceByRun.get(runId);\n\n if (payload.kind === \"summarize\" && ownerFirst !== undefined && coversThrough >= ownerFirst)\n return false;\n if (\n payload.kind !== \"summarize\" &&\n incompleteResponseSequences.some(\n (response) =>\n response.sequence <= coversThrough &&\n !isTerminalPriorRun(response.runId, runId, ownSequence),\n )\n )\n return false;\n for (const span of settledSpans) {\n if (span.from <= coversThrough && coversThrough < span.to) return false;\n }\n\n return true;\n };\n\n let summarizeBound = 0;\n let replacement: CompactionCreated | undefined;\n let summarizeSequence = -1;\n let clearBound = 0;\n let latestWindowId: string | undefined = seed?.contextWindowId;\n let latestWindowSequence = seed?.throughSequence ?? -1;\n let rolloverCoveredThrough = 0;\n\n for (const { payload, sequence } of compactions) {\n if (!boundIsValid(payload, sequence)) continue;\n if (payload.kind === \"rollover\" && sequence > latestWindowSequence) {\n latestWindowId = contextWindowId(payload.runId, payload.turn);\n latestWindowSequence = sequence;\n }\n if (payload.kind === \"rollover\")\n rolloverCoveredThrough = Math.max(rolloverCoveredThrough, payload.coversThrough);\n if (payload.kind === \"summarize\" || payload.kind === \"rollover\") {\n if (payload.kind === \"summarize\" && payload.summary === undefined) continue;\n if (\n payload.coversThrough > summarizeBound ||\n (payload.coversThrough === summarizeBound && sequence > summarizeSequence)\n ) {\n summarizeBound = payload.coversThrough;\n summarizeSequence = sequence;\n replacement = payload;\n }\n } else if (payload.coversThrough > clearBound) {\n clearBound = payload.coversThrough;\n }\n }\n let summaryEmitted = false;\n\n const retainedPrefix =\n replacement?.kind === \"rollover\" &&\n replacement.runId === ownerRunId &&\n ownerPrefixSequence <= summarizeBound\n ? (protectedContext?.content ?? [])\n : [];\n\n const replacementLength = replacement === undefined ? 0 : retainedPrefix.length + 1;\n\n if (seed?.frontier !== undefined)\n onBoundary?.({ ...seed.frontier, promptLength: replacementLength });\n\n const emitSummary = () => {\n if (summaryEmitted || replacement === undefined) return;\n summaryEmitted = true;\n\n const message =\n replacement.kind === \"rollover\"\n ? contextWindowMessage(\n contextWindowId(replacement.runId, replacement.turn),\n replacement.handoff,\n )\n : Prompt.makeMessage(\"user\", {\n content: [\n Prompt.makePart(\"text\", {\n text: `${COMPACTION_SUMMARY_PREFIX}${replacement.summary}`,\n }),\n ],\n });\n\n state.all.push(...retainedPrefix, message);\n if (replacement.kind !== \"rollover\" || replacement.runId !== ownerRunId)\n state.before.push(message);\n };\n\n const modelUsage: Array<ModelCallUsage> = [];\n let unobservedModelCalls = seed?.unobservedModelCalls ?? 0;\n\n const usage = {\n modelCalls: seed?.modelCalls ?? 0,\n inputTokens: seed?.inputTokens ?? 0,\n outputTokens: seed?.outputTokens ?? 0,\n lastInputTokens: seed?.lastInputTokens ?? 0,\n lastOutputTokens: seed?.lastOutputTokens ?? 0,\n costMicrousd: seed?.costMicrousd ?? 0,\n modelUsage,\n ...(seed === undefined ? {} : { summarizedModelUsage: seed.summarizedModelUsage }),\n };\n\n let toolSelection = seed?.toolSelection;\n let usageTurn = seed?.committedTurns ?? 0;\n\n const incompleteToolTurns = new Set<string>();\n const incompleteToolCalls = new Set<string>();\n let pendingContextToolCallId: string | undefined;\n let ownerTerminated = false;\n\n const policyUsage = {\n committedTurns: seed?.policyUsage.committedTurns ?? 0,\n toolCalls: seed?.policyUsage.toolCalls ?? 0,\n programmaticToolCalls: seed?.policyUsage.programmaticToolCalls ?? 0,\n consecutiveToolFailures: seed?.policyUsage.consecutiveToolFailures ?? 0,\n finalizationUsed: seed?.policyUsage.finalizationUsed ?? false,\n };\n\n const accountResponse = Effect.fn(\"RunJournal.accountResponse\")(function* (\n envelope: CanonicalRecordEnvelope,\n payload: ModelResponseRecorded,\n messages: Prompt.Prompt,\n ) {\n const record = envelope.record;\n\n const declared = declaredApplicationToolCallIds(messages);\n const declaredRecordIds: Array<RecordId> = [];\n\n for (const id of declared) {\n const toolCallId = yield* Effect.try({\n try: () => decodeToolCallId(id),\n catch: (cause) => journalError(\"Failed to decode a declared Tool Call ID\", cause),\n });\n\n declaredRecordIds.push(toolCallSettledRecordId(payload.runId, payload.turn, toolCallId));\n }\n if (declaredRecordIds.some((recordId) => !settledToolCallRecordIds.has(recordId))) {\n incompleteToolTurns.add(envelope.record.recordId);\n for (const recordId of declaredRecordIds) incompleteToolCalls.add(recordId);\n }\n if (payload.runId !== ownerRunId) return;\n if (seed !== undefined && envelope.sequence <= seed.throughSequence) return;\n if (payload.turn === 1 && payload.runScopedPrefixLength !== undefined) {\n protectedContext = Prompt.fromMessages(\n messages.content.slice(0, payload.runScopedPrefixLength),\n );\n }\n\n const responseUsage = yield* projectedResponseUsage(payload);\n\n unobservedModelCalls = yield* addProjectedUsage(\n \"unobservedModelCalls\",\n unobservedModelCalls,\n payload.unobservedModelCalls ?? 0,\n );\n\n usage.modelCalls = yield* addProjectedUsage(\n \"modelCalls\",\n usage.modelCalls,\n responseUsage.modelCalls,\n );\n usage.inputTokens = yield* addProjectedUsage(\n \"inputTokens\",\n usage.inputTokens,\n responseUsage.inputTokens,\n );\n usage.outputTokens = yield* addProjectedUsage(\n \"outputTokens\",\n usage.outputTokens,\n responseUsage.outputTokens,\n );\n usage.costMicrousd = yield* addProjectedUsage(\n \"costMicrousd\",\n usage.costMicrousd,\n responseUsage.costMicrousd,\n );\n usage.modelUsage.push(...responseUsage.modelUsage);\n if (payload.turn > usageTurn) {\n usageTurn = payload.turn;\n usage.lastInputTokens = responseUsage.inputTokens;\n usage.lastOutputTokens = responseUsage.outputTokens;\n }\n\n policyUsage.committedTurns = Math.max(policyUsage.committedTurns, payload.turn);\n\n const calls = messages.content.flatMap((message) =>\n message.role === \"assistant\"\n ? message.content.filter((part) => part.type === \"tool-call\")\n : [],\n );\n\n const candidate = calls.length === 1 ? calls[0] : undefined;\n\n const candidateResult =\n candidate === undefined\n ? undefined\n : settledById.get(`tool-settled:${ownerRunId}:${payload.turn}:${candidate.id}`);\n\n pendingContextToolCallId =\n candidate !== undefined &&\n !candidate.providerExecuted &&\n candidateResult?.isFailure === false &&\n candidateResult.budgetRejected !== true &&\n envelope.sequence > rolloverCoveredThrough\n ? candidate.id\n : undefined;\n\n policyUsage.toolCalls += calls.length;\n if (payload.toolExposure !== undefined) toolSelection = payload.toolExposure.selection;\n if (incompleteToolTurns.has(record.recordId)) return;\n for (const call of calls) {\n const result = call.providerExecuted\n ? messages.content\n .flatMap((message) => (message.role === \"assistant\" ? message.content : []))\n .find(\n (part) => part.type === \"tool-result\" && part.providerExecuted && part.id === call.id,\n )\n : settledById.get(`tool-settled:${ownerRunId}:${payload.turn}:${call.id}`);\n\n if (result === undefined || (\"budgetRejected\" in result && result.budgetRejected === true))\n continue;\n if (!(\"isFailure\" in result)) continue;\n if (!result.isFailure && \"toolSelection\" in result && result.toolSelection !== undefined)\n toolSelection = result.toolSelection;\n policyUsage.consecutiveToolFailures = result.isFailure\n ? policyUsage.consecutiveToolFailures + 1\n : 0;\n }\n });\n\n // Slots refer to the retained Prompt itself, not an additional history payload index.\n // Only still-unseen results retain a slot; late results fill the original declaration in place.\n const historicalResults = new Map<\n string,\n {\n readonly allIndex: number;\n readonly beforeIndex: number;\n readonly parts: Array<Prompt.ToolResultPart>;\n readonly partIndex: number;\n }\n >();\n\n let pendingToolOrder = new Map<string, number>();\n\n const flushTools = Effect.fn(\"RunJournal.flushTools\")(function* (\n current: FoldState,\n ): Effect.fn.Return<FoldState, RunJournalError> {\n if (current.pendingTools.length === 0) return current;\n\n // Suspension can persist an ordinary sibling before a delegated call joins. Model context\n // still uses declaration order, matching the live interpreter's completed results batch.\n const ordered = current.pendingTools.toSorted(\n (left, right) =>\n (pendingToolOrder.get(left.record.toolCallId) ?? Number.MAX_SAFE_INTEGER) -\n (pendingToolOrder.get(right.record.toolCallId) ?? Number.MAX_SAFE_INTEGER),\n );\n\n const toolMessage = yield* toolMessageFromSettled(ordered);\n\n current.all.push(toolMessage);\n if (!current.pendingToolsForRun) current.before.push(toolMessage);\n\n return {\n ...current,\n pendingTools: [],\n pendingToolsForRun: false,\n };\n });\n\n yield* Stream.runForEach(records, (envelope) =>\n Effect.gen(function* () {\n const payload = envelope.record.payload;\n\n if (\n ((payload._tag === \"RunCompleted\" || payload._tag === \"RunFailed\") &&\n payload.runId === ownerRunId) ||\n (payload._tag === \"SubmissionSettled\" &&\n runIdForSubmission(payload.submissionId) === ownerRunId)\n )\n ownerTerminated = true;\n\n if (payload._tag === \"RunPolicyUsageReserved\" && payload.runId === ownerRunId) {\n if (seed !== undefined && envelope.sequence <= seed.throughSequence) return;\n if (\n payload.programmaticToolCalls < policyUsage.programmaticToolCalls ||\n (policyUsage.finalizationUsed && !payload.finalizationUsed)\n ) {\n return yield* journalError(\"Run policy reservations must be monotonic\");\n }\n policyUsage.programmaticToolCalls = payload.programmaticToolCalls;\n policyUsage.finalizationUsed = payload.finalizationUsed;\n }\n if (PROMPT_TRANSPARENT_TAGS.has(payload._tag)) return;\n // The compaction record governs the fold (pre-scan) and contributes no\n // message of its own; records at or below the summarize bound render as\n // the one summary message emitted at the covered/kept transition.\n if (payload._tag === \"CompactionCreated\") return;\n if (\n seed !== undefined &&\n envelope.sequence <= seed.throughSequence &&\n (payload._tag === \"ModelResponseRecorded\" || payload._tag === \"ToolCallSettled\")\n )\n return;\n if (envelope.sequence <= summarizeBound) {\n // Projecting an earlier Run after a later summary still accounts for its covered responses.\n if (payload._tag === \"ModelResponseRecorded\" && payload.runId === ownerRunId) {\n const messages = yield* decodePromptMessages(payload.messages);\n\n yield* accountResponse(envelope, payload, messages);\n state = { ...state, committedTurns: Math.max(state.committedTurns, payload.turn) };\n }\n if (payload._tag === \"ModelResponseRecorded\" || payload._tag === \"ToolCallSettled\") {\n onBoundary?.({\n sequence: envelope.sequence,\n tag: payload._tag,\n promptLength: replacementLength,\n ...(isTerminalPriorRun(payload.runId, ownerRunId, Number.POSITIVE_INFINITY)\n ? { terminalPriorRun: true }\n : {}),\n ...(incompleteToolTurns.has(envelope.record.recordId) ||\n incompleteToolCalls.has(envelope.record.recordId)\n ? { incomplete: true }\n : {}),\n });\n }\n\n return;\n }\n emitSummary();\n if (payload._tag === \"ToolCallSettled\") {\n if (payload.runId !== ownerRunId) {\n const slot = historicalResults.get(envelope.record.recordId);\n\n if (slot === undefined)\n return yield* journalError(\"Historical Tool result has no matching declaration\");\n const declared = slot.parts[slot.partIndex];\n\n if (declared?.id !== payload.toolCallId || declared.name !== payload.toolName)\n return yield* journalError(\"Historical Tool result differs from its declaration\");\n slot.parts[slot.partIndex] = Prompt.makePart(\"tool-result\", {\n id: payload.toolCallId,\n name: payload.toolName,\n result: envelope.sequence <= clearBound ? CLEARED_TOOL_RESULT : payload.result,\n isFailure: payload.isFailure,\n providerExecuted: false,\n });\n const message = Prompt.makeMessage(\"tool\", { content: [...slot.parts] });\n\n state.all[slot.allIndex] = message;\n state.before[slot.beforeIndex] = message;\n historicalResults.delete(envelope.record.recordId);\n onBoundary?.({\n sequence: envelope.sequence,\n tag: payload._tag,\n promptLength: state.all.length,\n ...(incompleteToolCalls.has(envelope.record.recordId) ? { incomplete: true } : {}),\n ...(isTerminalPriorRun(payload.runId, ownerRunId, Number.POSITIVE_INFINITY)\n ? { terminalPriorRun: true }\n : {}),\n });\n\n return;\n }\n if (\n state.pendingTools.length > 0 &&\n state.pendingToolsForRun !== (payload.runId === ownerRunId)\n ) {\n state = yield* flushTools(state);\n }\n state.pendingTools.push({ record: payload, cleared: envelope.sequence <= clearBound });\n state = {\n ...state,\n pendingToolsForRun: payload.runId === ownerRunId,\n };\n onBoundary?.({\n sequence: envelope.sequence,\n tag: payload._tag,\n promptLength: state.all.length + 1,\n ...(isTerminalPriorRun(payload.runId, ownerRunId, Number.POSITIVE_INFINITY)\n ? { terminalPriorRun: true }\n : {}),\n ...(incompleteToolCalls.has(envelope.record.recordId) ? { incomplete: true } : {}),\n });\n\n return;\n }\n state = yield* flushTools(state);\n if (payload._tag === \"ModelCompleted\" && payload.messages !== undefined) {\n const messages = yield* decodePromptMessages(payload.messages);\n\n for (const message of messages.content) {\n state.all.push(message);\n if (payload.runId !== ownerRunId) state.before.push(message);\n }\n\n return;\n }\n if (payload._tag !== \"ModelResponseRecorded\") return;\n const messages = yield* decodePromptMessages(payload.messages);\n const forRun = payload.runId === ownerRunId;\n\n pendingToolOrder = new Map(\n declaredApplicationToolCallIds(messages).map((id, index) => [id, index]),\n );\n\n yield* accountResponse(envelope, payload, messages);\n\n const visibleMessages = forRun\n ? messages.content\n : messages.content.filter((message) => message.role !== \"system\");\n\n for (const message of visibleMessages) {\n state.all.push(message);\n if (!forRun) state.before.push(message);\n }\n if (!forRun) {\n const calls = messages.content.flatMap((message) =>\n message.role === \"assistant\"\n ? message.content.filter(\n (part): part is Prompt.ToolCallPart =>\n part.type === \"tool-call\" && !part.providerExecuted,\n )\n : [],\n );\n\n if (calls.length > 0) {\n const parts = yield* Effect.forEach(calls, (call) =>\n Effect.gen(function* () {\n const callId = yield* Schema.decodeEffect(ToolCallId)(call.id).pipe(\n Effect.mapError((cause) => journalError(\"Invalid historical Tool Call ID\", cause)),\n );\n\n const operation = payload.toolOperations?.find(\n (operation) => operation.toolCallId === callId && operation.toolName === call.name,\n );\n\n // Only the recorded execution contract can prove that dispatch required a\n // preparation. Ordinary readonly calls may execute without one.\n const notExecuted =\n operation !== undefined &&\n (operation.executionClass !== \"readonly\" ||\n operation.executionKind !== \"ordinary\") &&\n !toolExecutionEvidence.has(\n toolExecutionKey({\n runId: payload.runId,\n turn: payload.turn,\n toolCallId: callId,\n }),\n );\n\n return Prompt.makePart(\"tool-result\", {\n id: call.id,\n name: call.name,\n result: notExecuted\n ? {\n _tag: \"ToolUnavailable\",\n toolName: call.name,\n execution: \"not-executed\",\n message:\n \"This earlier call never reached durable preparation and was not executed.\",\n }\n : {\n _tag: \"ToolOutcomeUnknown\",\n message:\n \"This earlier operation has no recorded outcome. It may have executed. Do not assume success or retry it; its original operation remains unresolved.\",\n },\n isFailure: true,\n providerExecuted: false,\n });\n }),\n );\n\n const allIndex = state.all.length;\n const beforeIndex = state.before.length;\n const message = Prompt.makeMessage(\"tool\", { content: parts });\n\n state.all.push(message);\n state.before.push(message);\n for (const [partIndex, call] of calls.entries()) {\n const callId = yield* Schema.decodeEffect(ToolCallId)(call.id).pipe(\n Effect.mapError((cause) => journalError(\"Invalid historical Tool Call ID\", cause)),\n );\n\n historicalResults.set(toolCallSettledRecordId(payload.runId, payload.turn, callId), {\n allIndex,\n beforeIndex,\n parts,\n partIndex,\n });\n }\n }\n }\n state = {\n ...state,\n committedTurns: forRun\n ? Math.max(state.committedTurns, payload.turn)\n : state.committedTurns,\n };\n onBoundary?.({\n sequence: envelope.sequence,\n tag: payload._tag,\n promptLength: state.all.length,\n ...(isTerminalPriorRun(payload.runId, ownerRunId, Number.POSITIVE_INFINITY)\n ? { terminalPriorRun: true }\n : {}),\n ...(incompleteToolTurns.has(envelope.record.recordId) ? { incomplete: true } : {}),\n });\n }),\n );\n emitSummary();\n state = yield* flushTools(state);\n\n const validatedPolicyUsage = yield* Schema.decodeEffect(RunPolicyUsage)(policyUsage).pipe(\n Effect.mapError((cause) =>\n journalError(\"Run policy accounting exceeds its Schema bounds\", cause),\n ),\n );\n\n return {\n ...(toolSelection === undefined ? {} : { toolSelection }),\n policyUsage: validatedPolicyUsage,\n prompt: Prompt.fromMessages(state.all),\n historyBefore: Prompt.fromMessages(state.before),\n committedTurns: state.committedTurns,\n usage: unobservedModelCalls === 0 ? usage : { ...usage, unobservedModelCalls },\n ...(latestWindowId === undefined ? {} : { contextWindowId: latestWindowId }),\n ...(protectedContext === undefined ? {} : { protectedContext }),\n ...(ownerTerminated || pendingContextToolCallId === undefined\n ? {}\n : { pendingContextToolCallId }),\n };\n});\n\n/** Pure projection of one Run's durable recovery state from canonical records. */\nexport const projectRunJournal = Effect.fn(\"RunJournal.projectRunJournal\")(\n (\n records: ReadonlyArray<CanonicalRecordEnvelope>,\n runId: RunId,\n ): Effect.Effect<RunJournalProjection, RunJournalError> =>\n projectRunJournalStream(Stream.fromIterable(records), runId),\n);\n\n/**\n * Pure valid-prompt projection from canonical records: `UserInputRecorded` +\n * `ModelResponseRecorded` + complete `ToolCallSettled` batches → the deterministic model-visible\n * Prompt (plan §Coordinator flow step 3).\n */\nexport const promptFromCanonicalRecords = Effect.fn(\"RunJournal.promptFromCanonicalRecords\")(\n (\n records: ReadonlyArray<CanonicalRecordEnvelope>,\n ): Effect.Effect<Prompt.Prompt, RunJournalError> =>\n projectRunJournalStream(Stream.fromIterable(records), undefined).pipe(\n Effect.map((projection) => projection.prompt),\n ),\n);\n\n/** Everything one committed Turn contributes to its canonical batch. */\n/**\n * Staged usage is validated, never repaired: clamping negatives or truncating\n * fractions would under-record canonical usage, and NaN/Infinity must fail\n * typed instead of escaping as a record-construction defect (RUN-023).\n */\nconst validStagedUsage = (label: string, value: number): Effect.Effect<number, RunJournalError> =>\n Number.isSafeInteger(value) && value >= 0\n ? Effect.succeed(value)\n : Effect.fail(\n journalError(`Staged ${label} must be a non-negative safe integer, got ${String(value)}`),\n );\n\nexport interface TurnCommitInput {\n readonly toolOperations?: ModelResponseRecorded[\"toolOperations\"] | undefined;\n readonly toolParameterRejections?: ReadonlyArray<ToolParameterRejection> | undefined;\n readonly toolExposure?: Snapshot | undefined;\n readonly toolSelections?: ReadonlyMap<string, Selection> | undefined;\n readonly budgetRejectedCalls?: ReadonlySet<string>;\n readonly runId: RunId;\n /** Canonical (Run-relative, Attempt-independent) Turn number; must be positive. */\n readonly turn: number;\n readonly turnId: TurnId;\n /**\n * The Prompt messages this Turn appended to official history, in order, including the Turn's\n * Tool message when application Tools ran. Tool messages become `ToolCallSettled` records; the\n * remaining messages become the Turn's `ModelResponseRecorded.messages`.\n */\n readonly appended: ReadonlyArray<Prompt.Message>;\n readonly producerId: ProducerId;\n readonly deploymentId: DeploymentId;\n readonly createdAt: DateTime.Utc;\n /** Leading instruction/wake messages that stay canonical but are hidden from later Runs. */\n readonly runScopedPrefixLength?: number | undefined;\n /** Terminal output committed atomically with this Turn's final canonical batch. */\n readonly runCompletion?:\n | {\n readonly output: PersistedJson;\n readonly runDisposition?: PersistedJson | undefined;\n readonly finishReason?: \"budget-exhausted\" | undefined;\n readonly exhausted?: ExhaustedLimit | undefined;\n }\n | undefined;\n /** Known missing-accounting invocations staged before this canonical response. */\n readonly unobservedModelCalls?: number | undefined;\n /** Per-call provider usage staged by the engine's `noteTurnUsage` (RUN-023). */\n readonly usage?:\n | {\n readonly inputTokens: number;\n readonly outputTokens: number;\n readonly costMicrousd?: number | undefined;\n readonly modelUsage?: ReadonlyArray<ModelCallUsage> | undefined;\n }\n | undefined;\n}\n\nconst decodePersistedJson = Schema.decodeUnknownEffect(PersistedJson);\nconst encodePrompt = Schema.encodeEffect(Prompt.Prompt);\nconst decodeModelUsage = Schema.decodeUnknownEffect(Schema.Array(ModelCallUsage));\n\nconst requireCanonicalTurn = (turn: number): Effect.Effect<void, RunJournalError> =>\n !Number.isInteger(turn) || turn <= 0\n ? Effect.fail(journalError(`Canonical turn number must be a positive integer: ${turn}`))\n : Effect.void;\n\ninterface SplitTurnMessages {\n readonly promptMessages: ReadonlyArray<Prompt.Message>;\n readonly toolParts: ReadonlyArray<Prompt.ToolResultPart>;\n}\n\nconst splitTurnMessages = (appended: ReadonlyArray<Prompt.Message>): SplitTurnMessages => {\n const promptMessages: Array<Prompt.Message> = [];\n const toolParts: Array<Prompt.ToolResultPart> = [];\n\n for (const message of appended) {\n if (message.role !== \"tool\") {\n promptMessages.push(message);\n continue;\n }\n for (const part of message.content) {\n if (part.type !== \"tool-result\") continue;\n toolParts.push(part);\n }\n }\n\n return { promptMessages, toolParts };\n};\n\nconst modelResponseRecord = Effect.fn(\"RunJournal.modelResponseRecord\")(function* (\n input: TurnCommitInput,\n promptMessages: ReadonlyArray<Prompt.Message>,\n): Effect.fn.Return<RecordEnvelope, RunJournalError | DigestError, Crypto.Crypto> {\n if (promptMessages.length === 0) {\n return yield* journalError(`Turn ${input.turn} appended no model-visible Prompt messages`);\n }\n const runScopedPrefixLength = input.runScopedPrefixLength;\n\n if (\n runScopedPrefixLength !== undefined &&\n (input.turn !== 1 ||\n !Number.isSafeInteger(runScopedPrefixLength) ||\n runScopedPrefixLength <= 0 ||\n runScopedPrefixLength >= promptMessages.length ||\n promptMessages\n .slice(0, runScopedPrefixLength)\n .some((message) => message.role !== \"system\" && message.role !== \"user\"))\n ) {\n return yield* journalError(\n \"Run-scoped Prompt provenance must identify a non-empty system/user prefix of Turn 1 before its assistant response\",\n );\n }\n\n const encodedMessages = yield* encodePrompt(Prompt.fromMessages([...promptMessages])).pipe(\n Effect.mapError((cause) => journalError(\"Turn Prompt messages failed to encode\", cause)),\n );\n\n const messages = yield* decodePersistedJson(encodedMessages).pipe(\n Effect.mapError((cause) =>\n journalError(\"Turn Prompt messages exceed canonical persistence bounds\", cause),\n ),\n );\n\n const messagesDigest = yield* digestJson(messages);\n\n const modelUsage =\n input.usage?.modelUsage === undefined\n ? undefined\n : yield* decodeModelUsage(input.usage.modelUsage).pipe(\n Effect.mapError((cause) => journalError(\"Turn model usage failed to decode\", cause)),\n );\n\n if (modelUsage !== undefined) {\n if (modelUsage.length === 0) {\n return yield* journalError(\"Turn model usage must contain at least one completed call\");\n }\n\n const summary = yield* summarizeModelUsage(modelUsage).pipe(\n Effect.mapError((cause) => journalError(\"Turn model usage exceeds accounting bounds\", cause)),\n );\n\n if (\n input.usage === undefined ||\n input.usage.inputTokens !== summary.inputTokens.total ||\n input.usage.outputTokens !== summary.outputTokens.total ||\n (input.usage.costMicrousd ?? 0) !== summary.costMicrousd\n ) {\n return yield* journalError(\"Turn detailed and aggregate model usage disagree\");\n }\n }\n\n return RecordEnvelope.make({\n recordId: modelResponseRecordId(input.runId, input.turn),\n family: \"thread\",\n schemaVersion: 1,\n createdAt: input.createdAt,\n deploymentId: input.deploymentId,\n payload: ModelResponseRecorded.make({\n ...(input.toolOperations === undefined ? {} : { toolOperations: input.toolOperations }),\n ...(input.toolParameterRejections === undefined || input.toolParameterRejections.length === 0\n ? {}\n : { toolParameterRejections: input.toolParameterRejections }),\n ...(input.toolExposure === undefined ? {} : { toolExposure: input.toolExposure }),\n runId: input.runId,\n turnId: input.turnId,\n turn: input.turn,\n messages,\n messagesDigest,\n ...(runScopedPrefixLength === undefined ? {} : { runScopedPrefixLength }),\n ...(modelUsage === undefined ? {} : { modelUsage }),\n ...(input.unobservedModelCalls === undefined || input.unobservedModelCalls === 0\n ? {}\n : {\n unobservedModelCalls: yield* validStagedUsage(\n \"unobservedModelCalls\",\n input.unobservedModelCalls,\n ),\n }),\n ...(input.usage === undefined\n ? {}\n : {\n inputTokens: yield* validStagedUsage(\"inputTokens\", input.usage.inputTokens),\n outputTokens: yield* validStagedUsage(\"outputTokens\", input.usage.outputTokens),\n // Written only when non-zero: absent re-seeds as zero, so the\n // no-estimator case stays byte-identical to pre-cost histories.\n ...(input.usage.costMicrousd === undefined || input.usage.costMicrousd === 0\n ? {}\n : {\n costMicrousd: yield* validStagedUsage(\"costMicrousd\", input.usage.costMicrousd),\n }),\n }),\n }),\n });\n});\n\nconst toolSettledRecords = Effect.fn(\"RunJournal.toolSettledRecords\")(function* (\n input: TurnCommitInput,\n toolParts: ReadonlyArray<Prompt.ToolResultPart>,\n): Effect.fn.Return<Array<RecordEnvelope>, RunJournalError> {\n const toolRecords: Array<RecordEnvelope> = [];\n\n for (const part of toolParts) {\n const result = yield* decodePersistedJson(part.result).pipe(\n Effect.mapError((cause) =>\n journalError(`Tool result ${part.id} exceeds canonical persistence bounds`, cause),\n ),\n );\n\n const toolCallId = yield* Effect.try({\n try: () => decodeToolCallId(part.id),\n catch: (cause) => journalError(`Invalid Tool Call ID ${part.id}`, cause),\n });\n\n toolRecords.push(\n RecordEnvelope.make({\n recordId: toolCallSettledRecordId(input.runId, input.turn, toolCallId),\n family: \"thread\",\n schemaVersion: 1,\n createdAt: input.createdAt,\n deploymentId: input.deploymentId,\n payload: ToolCallSettled.make({\n ...(input.toolSelections?.get(part.id) === undefined\n ? {}\n : { toolSelection: input.toolSelections.get(part.id) }),\n runId: input.runId,\n toolCallId,\n toolName: part.name,\n result,\n isFailure: part.isFailure,\n ...(input.budgetRejectedCalls?.has(part.id) === true ? { budgetRejected: true } : {}),\n }),\n }),\n );\n }\n\n return toolRecords;\n});\n\n/** Integrity of the original validated terminal values; never a current-code projection. */\nexport const runCompletionDigest = (\n completion: Pick<\n RunCompleted,\n \"runId\" | \"output\" | \"runDisposition\" | \"finishReason\" | \"exhausted\"\n >,\n) =>\n digestJson({\n runId: completion.runId,\n output: completion.output,\n runDisposition: completion.runDisposition ?? null,\n finishReason: completion.finishReason ?? null,\n exhausted: completion.exhausted ?? null,\n });\n\nconst runCompletionRecord = Effect.fn(\"RunJournal.runCompletionRecord\")(function* (\n input: TurnCommitInput,\n) {\n if (input.runCompletion === undefined) return undefined;\n const completion = { runId: input.runId, ...input.runCompletion };\n\n return RecordEnvelope.make({\n recordId: runCompletedRecordId(input.runId),\n family: \"thread\",\n schemaVersion: 1,\n createdAt: input.createdAt,\n deploymentId: input.deploymentId,\n payload: RunCompleted.make({\n ...completion,\n resultDigest: yield* runCompletionDigest(completion),\n }),\n });\n});\n\n/**\n * Pure per-Turn canonical batch builder (TurnCompleted seam fold, D6/D8): one\n * `ModelResponseRecorded` record plus one `ToolCallSettled` record per terminal Tool result, all\n * under the WP0-style deterministic identities, committed as ONE atomic batch. The same input\n * always yields byte-identical content, so an in-Attempt append retry is an honest batch replay.\n *\n * Phase 5 keeps this shape for Turns that declare no application Tool calls; their terminal\n * `RunCompleted` marker joins the response in this same atomic batch. Tool-declaring Turns split\n * into `turnResponseBatch` + `turnResultsBatch`.\n */\nexport const turnCanonicalBatch = Effect.fn(\"RunJournal.turnCanonicalBatch\")(function* (\n input: TurnCommitInput,\n): Effect.fn.Return<CanonicalBatch, RunJournalError | DigestError, Crypto.Crypto> {\n yield* requireCanonicalTurn(input.turn);\n const { promptMessages, toolParts } = splitTurnMessages(input.appended);\n const modelResponse = yield* modelResponseRecord(input, promptMessages);\n const toolRecords = yield* toolSettledRecords(input, toolParts);\n const completionRecord = yield* runCompletionRecord(input);\n\n return CanonicalBatch.make({\n batchId: turnBatchId(input.runId, input.turn),\n producerId: input.producerId,\n records:\n completionRecord === undefined\n ? [modelResponse, ...toolRecords]\n : [modelResponse, ...toolRecords, completionRecord],\n });\n});\n\n/**\n * Commit 1 of a tool-declaring Turn: the Turn's `ModelResponseRecorded` record, including\n * provider results retained in assistant content before application Tools execute.\n * — pending steering plus the assistant response with its declared tool calls — under batch\n * identity `turn-response:{runId}:{turn}`. Committing the response before preparation creates\n * the provably-safe durability §15 window (\"after model item commit, before tool preparation →\n * resume tool scheduling\"): a crash there resumes the declared batch with no model re-invocation\n * and no Unknown. Tool messages in `appended` are ignored; the record identity is the same\n * `model-response:{runId}:{turn}` as the single-batch shape, so record-id assertions and the\n * prompt projection are unchanged.\n */\nexport const turnResponseBatch = Effect.fn(\"RunJournal.turnResponseBatch\")(function* (\n input: TurnCommitInput,\n): Effect.fn.Return<CanonicalBatch, RunJournalError | DigestError, Crypto.Crypto> {\n yield* requireCanonicalTurn(input.turn);\n const { promptMessages } = splitTurnMessages(input.appended);\n const modelResponse = yield* modelResponseRecord(input, promptMessages);\n\n return CanonicalBatch.make({\n batchId: turnResponseBatchId(input.runId, input.turn),\n producerId: input.producerId,\n records: [modelResponse],\n });\n});\n\n/**\n * Commit 5 of a tool-declaring Turn (plan §2.1): the Turn's `ToolCallSettled` records in\n * declaration order under batch identity `turn-results:{runId}:{turn}` — the batch becomes\n * model-visible atomically. Non-tool messages in `appended` are ignored; a Turn without any\n * terminal Tool result has no results batch and fails typed.\n */\nexport const turnResultsBatch = Effect.fn(\"RunJournal.turnResultsBatch\")(function* (\n input: TurnCommitInput,\n): Effect.fn.Return<CanonicalBatch, RunJournalError | DigestError, Crypto.Crypto> {\n yield* requireCanonicalTurn(input.turn);\n const { toolParts } = splitTurnMessages(input.appended);\n const toolRecords = yield* toolSettledRecords(input, toolParts);\n const first = toolRecords[0];\n\n if (first === undefined) {\n return yield* journalError(`Turn ${input.turn} has no terminal Tool results to commit`);\n }\n if (input.runCompletion !== undefined && toolRecords.length !== 1) {\n return yield* journalError(\"A terminal Tool completion requires exactly one settled result\");\n }\n const completionRecord = yield* runCompletionRecord(input);\n\n return CanonicalBatch.make({\n batchId: turnResultsBatchId(input.runId, input.turn),\n producerId: input.producerId,\n records:\n completionRecord === undefined\n ? [first, ...toolRecords.slice(1)]\n : [first, ...toolRecords.slice(1), completionRecord],\n });\n});\n"],"mappings":";;;;;;;;;;;AA6BA,MAAa,oBACX,SACW,KAAK,UAAU;CAAC,KAAK;CAAO,KAAK;CAAM,KAAK;AAAU,CAAC;;;;;;AAOpE,MAAa,uBACX,YACA,SACG;CACH,MAAM,qCAAqB,IAAI,IAAoB;CAEnD,IAAI,MAAM,kBAAkB,KAAA,GAAW,mBAAmB,IAAI,KAAK,OAAO,KAAK,aAAa;CAC5F,MAAM,4CAA4B,IAAI,IAAoB;CAC1D,MAAM,wCAAwB,IAAI,IAAoB;CACtD,MAAM,eAAsE,CAAC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