UNPKG

@code-yeongyu/senpi

Version:

Coding agent CLI with read, bash, edit, write tools and session management

58 lines • 3.34 kB
import { familyId, memberId } from "./compact-catalog-registry.js"; import { literalFields, objectSteps, storedSteps, walkedSteps, } from "./compact-catalog-steps.js"; import { textComponent } from "./compact-catalog-transcript.js"; import { emptyComponent, stepsComponent } from "./compact-catalog-writer.js"; const SETTLED = familyId("settled"); const IDENTITY = familyId("identity"); /** * The settled member of the terminal a message ended at: `message-<terminalSequence>`. A compact peer's live * `message_end` carries that `terminalSequence` and the row's `messageId` (RULING-120, #5331). */ export const settledMember = (terminalSequence) => memberId("message", terminalSequence); /** The identity member of this epoch's n-th entry join: `join-<n>`, whose `messageId` an `entry_appended` names. */ const joinMember = (ordinal) => memberId("join", ordinal); /** A terminal as stored: its row, its payload (terminal record and correlation) spliced in, its paged call walked. */ function terminalSteps(settled, row, valid) { const { kind: _kind, payload, call, ...fields } = row; return objectSteps([ ...literalFields(fields), ["payload", storedSteps(settled.store, payload)], ["call", walkedSteps(settled.values, call, valid)], ]); } /** * The settled family (R4.B2, S05, RULING-13 Q2): one `message-<terminal sequence>` member per terminal still pending * or failed in the cut, with its status, error, entry join, terminal payload and the call projection it retired, paged * and never truncated (RULING-60 Q3); or the explicit empty. The id is the terminal's own accepted sequence, so it * stays put while other terminals settle. */ export async function* settledComponents(reader, settled) { let count = 0; for await (const member of settled.members(reader.valid)) { if (member.kind !== "terminal") continue; const steps = terminalSteps(settled, member.row, reader.valid); yield* stepsComponent(reader.store, SETTLED, settledMember(member.row.terminalSequence), steps); count += 1; } if (count === 0) yield emptyComponent("settled"); } /** * The identity family (R4.B2, C1.1): the lane's own correlation state at the cut (`identity/identity`: epoch, * sequence, active message, turn, the standing client correlation with the sequence it took, and how many client * correlations this epoch refused at the protocol depth limit, RULING-67 (4)), then one `join-<ordinal>` member per * message joined to its durable entry in this epoch, its id the epoch-local order the join was made in. */ export async function* identityComponents(reader, root, settled) { const { sessionEpoch, sequence, activeMessageId, turnId, correlation, refusedCorrelations } = root; const identity = { sessionEpoch, sequence, activeMessageId, turnId, correlation, refusedCorrelations }; yield* textComponent(reader.store, IDENTITY, IDENTITY, JSON.stringify(identity)); for await (const member of settled.members(reader.valid)) { if (member.kind !== "owner") continue; const join = JSON.stringify({ messageId: member.messageId, entryId: member.entryId }); yield* textComponent(reader.store, IDENTITY, joinMember(member.ordinal), join); } } //# sourceMappingURL=compact-catalog-settled.js.map