@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
53 lines • 2.69 kB
TypeScript
import { type StagingRefusal, type TransferStaging } from "./compact-transfer-staging.ts";
import { HostPermits, type WorkerPermitLedger } from "./session-worker-permits.ts";
import type { SessionWorkerToHost } from "./session-worker-protocol.ts";
type Fragment = Extract<SessionWorkerToHost, {
type: "fragment";
}>;
/**
* A staging refusal of one worker transfer (RULING-80 (3a)): its cause and the event it carried, the message type and,
* in the ordered stream, the record's commit-frame ordinal. It fails the whole incarnation, and the host keeps it.
*/
export interface TransferRefusal {
readonly cause: StagingRefusal | "failed";
readonly event: {
readonly type: string;
readonly ordinal?: number;
readonly length: number;
};
}
/**
* The host half of one worker incarnation's payload transport (S12b): its permits, its one physical ordinal sequence,
* and the staging of fragments into the lane's S12a store. A fragment is owned once staged, so its permit returns then;
* the message exists only once its final commit frame arrived and every staged leaf read back verified, and the staged
* copy is released exactly once either way. Fragment frames never reach acceptance, so they never move the high-water
* or a first-start binding (RULING-64); the final frame's ordinal is checked with the message it completes.
*/
export declare class WorkerIntake {
readonly permits: HostPermits;
private readonly staging;
private readonly fail;
private expected;
private serial;
private open;
private refused;
/** Messages this intake reassembled: their fragments already returned every permit they were paid with. */
private readonly assembled;
constructor(staging: TransferStaging, fail: (error: string) => void, ledger?: WorkerPermitLedger);
/** The physical ordinal this incarnation must send next: a typed diagnostic seam (carry 11). */
get nextOrdinal(): number;
/** The staging refusal that ended this incarnation, if one did: never a silent worker loss. */
get refusal(): TransferRefusal | undefined;
received(message: SessionWorkerToHost): void;
/** A gap, duplicate or reordered physical frame is denied and ends this incarnation before any mutation. */
inOrder(message: {
readonly ordinal?: number;
readonly signal?: SharedArrayBuffer;
}): boolean;
/** Stages one fragment; the final one resolves to the whole message, which then takes the ordinary receive path. */
fragment(frame: Fragment): Promise<SessionWorkerToHost> | undefined;
private refuse;
private whole;
}
export {};
//# sourceMappingURL=session-worker-intake.d.ts.map