/** * Sprite config reconcile activities (#849) — the two pieces of genuine * desired-state a Sprite carries: its outbound network policy and its background * services. Unlike the sprite itself (an Op primitive with no reconcilable * create body), these are set after create and persist across cold boots, so * chant reconciles typed config against the live Sprite — the `flyApply` * plan→CRUD pattern scoped to one Sprite, not a declarable resource. * * Both use the JSON `SpritesHttp` client from `sprites.ts`; endpoint + bearer * resolution is shared. Validation is pure and runs before any HTTP (invalid * rules / a `needs` cycle throw up front), so a bad config fails the step * cleanly rather than half-applying. * * Scope (v1): network policy is a whole-object replace (converges by * construction); services reconcile is additive + update (create-or-update each * desired service, optionally start). Owned-only prune of stale services is out * of scope — the documented Services REST surface exposes no delete. */ import { type SpritesHttp } from "./sprites.js"; /** One outbound rule. Ordered — specificity is positional, so order is significant. */ export interface NetworkRule { domain: string; action: "allow" | "deny"; } export interface SpriteApplyNetworkPolicyArgs { id: string; /** The complete desired ruleset (whole-object replace). */ rules: NetworkRule[]; endpoint?: string; token?: string; } export interface SpriteApplyNetworkPolicyResult { /** True when the live policy differed and was replaced; false when already converged. */ changed: boolean; } /** * Validate a ruleset: every rule needs a non-empty `domain` and an `allow`/`deny` * `action`. Pure; throws on the first offender. */ export declare function validateNetworkRules(rules: NetworkRule[]): void; /** Order-sensitive equality of two rulesets (position is significant). Pure. */ export declare function networkRulesEqual(a: NetworkRule[], b: NetworkRule[]): boolean; /** * Reconcile a Sprite's outbound network policy. GET the live ruleset, and POST * the desired set only when it differs (`GET`/`POST /policy/network`). Returns * whether a change was applied. */ export declare function spriteApplyNetworkPolicy(args: SpriteApplyNetworkPolicyArgs, signal?: AbortSignal, http?: SpritesHttp): Promise; /** A desired background service. Keyed by `name`; PUT is create-or-update. */ export interface ServiceSpec { name: string; cmd: string; args?: string[]; env?: Record; dir?: string; /** Names of services that must start first. */ needs?: string[]; /** Route the Sprite's public URL to this port. */ http_port?: number; } export interface SpriteApplyServicesArgs { id: string; services: ServiceSpec[]; /** Start each service after applying (in dependency order). Default: false. */ start?: boolean; endpoint?: string; token?: string; } export interface SpriteApplyServicesResult { /** Names that were created or updated (converged services are skipped). */ applied: string[]; /** Names that were started (empty unless `start`). */ started: string[]; } /** * Validate a service set: names are unique, every `needs` target exists, and the * dependency graph is acyclic. Pure; throws on the first violation. Returns the * names in a valid start order (dependencies first). */ export declare function validateServices(services: ServiceSpec[]): string[]; /** Comparable service config (the fields the reconcile diffs on). Pure. */ export declare function serviceConfigEqual(a: Partial, b: Partial): boolean; /** * Reconcile a Sprite's background services (additive + update). Lists the live * services, then `PUT`s each desired service that is new or changed * (create-or-update by name); when `start` is set, `POST .../start`s them in * dependency order. Converged services are skipped. Owned-only prune is out of * scope (no delete in the Services REST surface). */ export declare function spriteApplyServices(args: SpriteApplyServicesArgs, signal?: AbortSignal, http?: SpritesHttp): Promise; //# sourceMappingURL=sprite-config.d.ts.map