/** * Action-intent parser — reads `data/action-intent.json` from the customer * gitops repo and returns a pattern_hash → Action lookup. * * Pair with `action-intent-writer.ts` which writes the file. * * File location (relative to gitops repo root): * `data/action-intent.json` * (sibling to the cap CSV at `pipelines/run/receive/rate/caps.csv`) * * Parse contract: * - Unknown schema_version → accepted with a soft warning (forward compat). * - Missing or null entries → treated as empty (no actions). * - Unrecognised action value on an entry → that entry is skipped and * pushed to `malformed_entries` for caveat surfacing. * - All other parse failures → surfaced via `malformed_entries`; partial * results are still returned. * - Entries with `until_epoch_sec > 0` and past the current wall time * are treated as expired and excluded from the lookup (same semantics * as the rate receiver's epoch-expiry on mute/compact rows). */ import type { Action } from './cost.js'; import type { ActionIntentEntry } from './action-intent-writer.js'; export interface ActionIntentParseResult { /** * All well-formed, non-expired entries from the file. * Entries with `until_epoch_sec > 0` and in the past are excluded. */ entries: ActionIntentEntry[]; /** * pattern_hash → Action lookup, built from `entries`. * This is the primary consumer interface — most callers use this * rather than iterating `entries` directly. */ by_pattern: Map; /** * Entries or raw values that could not be parsed or had an * unrecognised action. Exposed for caveat surfacing; never throws. */ malformed_entries: string[]; /** * True when the file could not be parsed as JSON at all (structural * failure). When true, `entries` and `by_pattern` are both empty. */ json_parse_error: boolean; /** * `schema_version` from the file header. Undefined when the file was * empty or unparseable. */ schema_version?: string; } /** * Parse an action-intent JSON string. * * Returns an empty result (no throws) on any input failure. Callers must * treat an empty `by_pattern` map as "no action plan available — fall back * to the cap-CSV container-default path or the single-bucket drop fallback". * * @param content Raw JSON string from the gitops repo. * @param nowEpochSec Wall time for expiry evaluation. Defaults to `Date.now() / 1000`. */ export declare function parseActionIntent(content?: string | null, nowEpochSec?: number): ActionIntentParseResult; /** * Fetch and parse the action-intent.json from the gitops repo using `gh api`. * * Returns undefined on any failure (no `gh`, no repo, file not found, parse * error). Callers MUST treat undefined as "no action plan available". * * @param repo `owner/repo` string from env.gitops.repo. * @param path Path within the repo (default: `data/action-intent.json`). */ export declare function fetchAndParseActionIntent(repo: string, path?: string): Promise;