/** * Reports "this run is about to restart the agent that is executing it". * * WHY THIS EXISTS: the `ai_support_agent_k8s` bundled role may deploy the very * agent running the play. Every spec-changing kubectl call for that target is * deferred until all other projects are deployed (ansible/roles/ * ai_support_agent_k8s/tasks/self.yml), but it still ends the run without a * result: Kubernetes replaces the Pod, so the process that would call * `submitResult` is gone. Server-side the execution stays `running` until the * watchdog reclaims it two hours later, and the UI can only show "実行中". * * The role therefore drops a marker file on the controller — this agent's own * filesystem — immediately before it touches its own StatefulSet, and then * *waits* for the ack file this module writes. That wait is what turns * "declared before restarted" into an ordering guarantee instead of a race * between a 1-second poll and `kubectl apply`. * * DECIDING ON A FILE, NOT ON WORDING: the signal is the marker's **existence**. * Nothing here parses ansible's or kubectl's output — the previous round of * review removed exactly such a check (`'unchanged' not in stdout`-style * matching) because it misfired on every run. The marker's content is read for * the log line only, and a content that cannot be read does not change the * decision. * * WHEN THE DECLARATION FAILS, IT HAS TO BE VISIBLE. The deployment still * proceeds — that part is deliberate — but the failure is no longer confined to * this process's stdout, which Kubernetes is about to throw away along with the * process. Three things now carry it: * 1. a `failed` entry in the execution's own task log, through the same * progress channel the run's Ansible tasks use (where an operator looks); * 2. the ack file's **content** (`{"declared": false, ...}`), which the role * reads back and prints — existence alone never proved anything, since * this file is written locally and therefore almost always succeeds; * 3. a warning on the api side, logged the moment it answers 200 to a notice * it could not apply. * The likeliest failure is not a thrown error at all: the api applies the flag * best-effort and answers 200 either way, so `acknowledged: false` in the reply * is a failure here, and a caller that only caught rejections would miss it. */ import type { SelfRestartDeclarationAck, ServerSetupProgressEvent } from '../types/server-setup'; /** * Task name the failure notice carries into the execution's task log. * * Shaped like an Ansible task name (`role : what it does`) because it lands in * the same list as real ones — an operator scanning the run should not have to * work out where this line came from. */ export declare const SELF_RESTART_NOTICE_TASK_NAME = "ai_support_agent_k8s : Report this run as awaiting a self restart"; export interface SelfRestartDeclarerOptions { /** Controller-side path the role writes just before restarting this agent. */ markerPath: string; /** Controller-side path the role waits on before it proceeds. */ ackPath: string; /** * Sends the declaration to the API. * * Rejections are absorbed (see below), and so is an ack that says the api * could not apply it: a 200 with `acknowledged: false` is a *failure* here, * not a success, and is the likelier of the two — the api applies the flag on * a best-effort path that answers 200 even when its own write threw. */ declare: () => Promise; /** * Appends to the execution's task log — the same channel the mid-run progress * uses. Used for exactly one thing: recording that the declaration did not * get through. * * This is what makes the failure *visible*. A `logger.error` goes to this * process's stdout, and this process is about to be replaced by Kubernetes; * nothing of it survives into the execution the operator is looking at. * Omitted on paths with no execution row to append to (local dev runs). */ reportProgress?: (events: ServerSetupProgressEvent[]) => Promise; } export interface SelfRestartDeclarer { /** * Declares once if the role has raised the marker. Never rejects: it runs on * the progress poll loop, which must keep ticking regardless. */ check(): Promise; } export declare function createSelfRestartDeclarer(options: SelfRestartDeclarerOptions): SelfRestartDeclarer; //# sourceMappingURL=self-restart-declaration.d.ts.map