@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
59 lines • 3.57 kB
TypeScript
/**
* A successor's startup, driven by its launcher (senpi#4602, A-amended sections 1 and 4, N1).
*
* The successor's path is P0..P5, then P7 (presenter), then P6 (publication), then P8 (public answer). The
* presenter exchange starts only when P7 is entered, after internal and observer readiness, while the predecessor
* still serves its unchanged public endpoint. Publication is granted only after a validated P7 result: an
* enrollment that is rejected, closes or expires ends the candidate before it ever touched the predecessor's
* public name, key or pointer. An uncoordinated successor (a command not known to report progress) keeps today's
* order and waits for its public answer under the bounded legacy phase instead of a fixed 30 s.
*/
import type { ChildProcess } from "node:child_process";
import type { Duplex } from "node:stream";
import { type HostProtocolInfo } from "./host-decision.ts";
import { type StartupController, type StartupOutcome } from "./host-startup-policy.ts";
import { type PresenterRelayResult } from "./mcp-presenter-bootstrap.ts";
export type PresenterResult = PresenterRelayResult;
export interface SuccessorAttempt {
readonly controller: StartupController;
readonly coordinated: boolean;
/** Writes the publication grant: the authority file first, then the wake-up on the startup pipe. */
grant(): Promise<void>;
}
export type SuccessorStartupResult = {
readonly ready: true;
readonly answer: HostProtocolInfo;
} | {
readonly ready: false;
readonly outcome: Exclude<StartupOutcome, {
readonly kind: "ready";
}>;
};
export declare function driveSuccessorStartup(options: {
readonly attempt: SuccessorAttempt;
/** Starts (or joins) the presenter exchange; called only once P7 is entered. */
readonly presenter: (() => Promise<PresenterResult>) | undefined;
/** The successor's own answer on the PUBLIC socket within `budgetMs`, or undefined. */
readonly awaitAnswer: (budgetMs: number) => Promise<HostProtocolInfo | undefined>;
}): Promise<SuccessorStartupResult>;
/**
* The presenter exchange of one successor. A coordinated successor whose owner channel is DEFERRED (a running
* host's idle handover) asks for the fresh permit only when called, at its P7. An eager owner channel, and every
* channel of an uncoordinated launch, is relayed from the spawn as before; calling the result joins that relay.
*/
export declare function successorPresenter(bootstrap: Duplex | (() => Promise<Duplex | undefined>) | undefined, child: ChildProcess, predecessor: HostProtocolInfo, coordinated: boolean): (() => Promise<PresenterResult>) | undefined;
/** The refusal detail of a failed successor attempt, in the same machine-readable form an initial start reports. */
export declare function failureDetail(outcome: Exclude<StartupOutcome, {
readonly kind: "ready";
}>, cleanupFailure: string | undefined): string;
/** The grant for one attempt: authority in the candidate's own generation directory, wake-up on its startup pipe. */
export declare function adoptionGrant(attempt: string, generationDir: string, child: ChildProcess): {
grant(): Promise<void>;
revoke: () => Promise<void>;
};
/**
* Q1 (LEAD ruling, senpi#4602): the owner-token guard is claimed only against a predecessor that advertises it.
* Without the capability the successor adopts the way it always did, and the old host's late-rename race remains.
*/
export declare function predecessorOwnerArgs(host: HostProtocolInfo): string[];
//# sourceMappingURL=host-successor-startup.d.ts.map