import type { IsoTime, NodeIdDTO } from './common.js'; /** Report kind — `crtr push {update,final}`; legacy `urgent` rows remain readable. */ export type ReportTierDTO = 'update' | 'urgent' | 'final'; /** Delivery urgency for an update report's subscriber fan-out. */ export type ReportDeliveryTierDTO = 'deferred' | 'normal' | 'urgent'; /** `POST /v1/nodes/{id}/reports` body ({id} = the reporting node). * `tier` is the stored report kind; `delivery_tier` is the optional inbox * delivery urgency for an update's subscriber fan-out. */ export interface PushReportRequest { tier: ReportTierDTO; delivery_tier?: ReportDeliveryTierDTO; body: string; } /** Result of a push. `transitioned` is present only for `final`, which drives a * server-side lifecycle transition. */ export interface PushReportResultDTO { /** Absolute path of the written report file. */ report_path: string; /** Subscriber node ids that received an inbox entry. */ notified: NodeIdDTO[]; transitioned?: { from: string; to: string; }; /** Present (and true) only for a `final` push that closes the reporting * node's managed-worktree record without `node worktree close`. An existing * checkout must be clean with its tip contained in the local base and stays * pending cleanup; a missing checkout must be proven delivered. Work not * proven delivered blocks with an `open_managed_worktree` error. */ worktree_auto_dropped?: boolean; /** Present only alongside `worktree_auto_dropped`: the closed managed-worktree path; an existing checkout remains until pending cleanup. */ worktree_auto_dropped_path?: string; } /** Why a node declined a structured result. `reason` is one plain sentence * for a reader; `code` is an opaque token the requester classifies on and * validates itself — crouter only carries it; `retryable` is the node's * claim that the same request could succeed later. */ export interface DeclinedResultDTO { reason: string; code: string; retryable: boolean; } /** `POST /v1/nodes/{id}/result` body ({id} = the submitting node). Either the * structured result to validate against the node's pending output schema — * `value` must be present; any JSON value (including null) is legal input to * validation — or a decline: `decline` is the reason sentence, `code` the * requester-classified token, `retryable` the node's retry claim. A decline * records a `failure` outcome with reason `declined` carrying all three and * clears the request without validating anything. */ export type SubmitResultRequest = { value: unknown; } | { decline: string; code: string; retryable: boolean; }; /** Result of a structured-result submission (`crtr push result`). Terminal * mode reuses the final-push machinery, so `transitioned` and the managed-worktree * closure fields carry the same meaning as on PushReportResultDTO. */ export interface SubmitResultDTO { /** Which request this answered: `terminal` finished the node; `oneoff` left it working. */ mode: 'terminal' | 'oneoff'; /** Absolute path of the recorded artifact: context/result.json for an * answered request, context/declined.json for a declined one. */ result_path: string; /** Present only when the request was declined. */ declined?: DeclinedResultDTO; /** Absolute path of the report pushed alongside the result. */ report_path: string; /** Subscriber node ids that received an inbox entry. */ notified: NodeIdDTO[]; transitioned?: { from: string; to: string; }; worktree_auto_dropped?: boolean; worktree_auto_dropped_path?: string; } /** `GET /v1/nodes/{id}/reports` query filters. */ export interface ReportsQuery { tier?: ReportTierDTO; limit?: number; } /** A single stored report entry. */ export interface ReportDTO { /** Absolute path of the report file. */ path: string; tier: ReportTierDTO; body: string; created: IsoTime; }