@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
69 lines • 3.21 kB
TypeScript
import type { CompactContentIndex } from "./compact-content-index.ts";
import type { SeededMessage } from "./compact-seeded-messages.ts";
import type { SettledRow } from "./compact-state-view.ts";
import type { CompactPersistence, CompactTransition } from "./compact-transition.ts";
export type CompactColdOperation = Extract<CompactTransition, {
type: "message_status" | "message_remove";
}>
/** Old-message edit: the settled row's content is replaced whole; persistence and correlation are kept. */
| {
readonly type: "message_replace";
readonly messageId: string;
readonly message: SeededMessage;
}
/** Branch replacement: the row is installed whole, present or not, with the replacement's persistence. */
| {
readonly type: "message_install";
readonly messageId: string;
readonly message: SeededMessage;
readonly persistence: CompactPersistence;
};
export type CompactColdOutcome = {
readonly kind: "applied";
readonly afterSequence: number;
} | {
readonly kind: "rejected";
readonly afterSequence: number;
readonly reason: "unknown_message" | "active_message" | "capacity" | "retired";
} | {
readonly kind: "failed";
readonly afterSequence: number;
readonly cause: unknown;
};
type Index = Pick<CompactContentIndex<SettledRow>, "store" | "values" | "overlays" | "freeze" | "lookup" | "patch" | "delete" | "release">;
type Keep = Pick<SettledRow, "persistence" | "correlation">;
type Install = (messageId: string, message: SeededMessage, keep: Keep) => void;
/** Non-acceptance FIFO. Capacity rejection leaves work unqueued; callers await admitted operations. */
export declare class CompactColdOperations {
private chain;
private readonly keys;
private pending;
private readonly index;
private readonly isActive;
private readonly install;
constructor(index: Index, isActive: (key: string) => boolean, install: Install);
activate(key: string): void;
run(input: CompactColdOperation, afterSequence: number): Promise<CompactColdOutcome>;
/**
* One FIFO unit holding one capacity slot; each operation keeps its order and its own typed outcome. Every step
* reads first and the flow then publishes all of them in one synchronous pass, so a reader's cut holds the whole
* flow or none of it. Live targets answer `active_message` before capacity, as `run` does; such a flow, like an
* empty one, queues nothing.
*/
runAll(inputs: readonly CompactColdOperation[], afterSequence: number): Promise<readonly CompactColdOutcome[]>;
idle(): Promise<void>;
private active;
private enqueue;
private admit;
/** Reads under its own cut; the returned commit re-checks liveness and removal before it publishes. */
private prepare;
private failure;
/**
* The kept fields of the row as a reader sees it at the cut: its stored value plus any pending field patch. `read`
* assembles a fresh value without recursion, so a row whose message came from a transcript flow (never checked at
* the protocol depth limit) is not serialized here (RULING-59 C).
*/
private current;
}
export {};
//# sourceMappingURL=compact-cold-operations.d.ts.map