@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
54 lines • 2.5 kB
TypeScript
/**
* The tool child's job policy (senpi#3566, plan todo 6; DESIGN PART 1 (c)). Pure decisions over an injected clock:
* per-kind server backstop deadlines and retry rules, the cancel ladder, control liveness and the crash loop. The
* client applies them; nothing here starts a timer of its own.
*/
export interface KindPolicy {
/** Server backstop in ms for a job of this kind, from its arguments; `undefined` = no backstop (liveness bounds it). */
readonly backstopMs: (args: unknown) => number | undefined;
readonly idempotent: boolean;
/** What the user reads when the backstop fires. */
readonly userText: string;
}
export declare const KIND_POLICIES: Readonly<Record<string, KindPolicy>>;
/** The longest a `module` / `offload.*` job may run, on the child and in-process alike. */
export declare const OFFLOAD_MAX_MS = 300000;
/** The policy for one job: the table, `offload.<id>` / `module` (caller value, max 300 s), or a `qa.*` fixture kind. */
export declare function policyFor(kind: string, options?: {
readonly idempotent?: boolean;
readonly deadlineMs?: number;
readonly env?: NodeJS.ProcessEnv;
}): KindPolicy;
/** `SENPI_TOOL_CHILD_DEADLINE_<KIND>_MS` for a `qa.*` fixture kind (`qa.sleep` -> `..._QA_SLEEP_MS`). */
export declare function fixtureDeadline(kind: string, env: NodeJS.ProcessEnv): number | undefined;
export declare const CANCEL_ACK_MS = 5000;
export declare const TERM_GRACE_MS = 2000;
export declare const PING_INTERVAL_MS = 5000;
export declare const MISSED_PONGS_LIMIT = 3;
export declare const READY_MS = 10000;
/** The cancel ladder: cancel, wait 5 s for the child to settle the job, then TERM, then 2 s later KILL. */
export declare const CANCEL_LADDER: readonly ({
atMs: number;
step: "term";
} | {
atMs: number;
step: "kill";
})[];
export declare const CRASH_LOOP_EXITS = 3;
export declare const CRASH_LOOP_WINDOW_MS = 5000;
export declare const CRASH_LOOP_COOLDOWN_MS = 60000;
/** Three exits within 5 s make the child `unavailable` for 60 s; within that time no spawn is attempted. */
export declare class CrashLoop {
#private;
constructor(now: () => number);
recordExit(): void;
unavailable(): boolean;
}
/** Control liveness: a ping per interval while work exists; three unanswered pings in a row mean the child is gone. */
export declare class Liveness {
#private;
pingSent(): void;
pongReceived(): void;
unresponsive(): boolean;
}
//# sourceMappingURL=job-policy.d.ts.map