import { type SandboxUser } from '../codebase/git-workspace.js'; import type { Project } from '../projects/index.js'; import type { AIProvider } from '../resolver/ai-provider.js'; import type { Incident, ResolutionResult } from '../resolver/types.js'; /** How the repo's tests run. `docker` (the default for new setups) installs with network, then tests offline in a container. */ export type SandboxMode = 'docker' | 'none'; export interface FixProject extends Pick { /** Installs dependencies (with network). Without it the whole testCommand runs with network, as before offline tests existed. */ installCommand?: string; sandbox?: SandboxMode; /** Container image for offline tests; must have the project's toolchain. */ sandboxImage?: string; } /** What the audit comment on the PR records besides the run itself. */ export interface AuditContext { /** AI providers configured, in failover order. Names only. */ providers?: string[]; /** Calls made to the model during this job. */ modelCalls?: () => number; /** Fix attempts allowed. */ maxAttempts?: number; } export interface FixJobOptions { project: FixProject; incident: Incident; /** How many customers reported it. Customers are never identified on GitHub, only counted. */ reportCount: number; token: string; ai: AIProvider; /** Overrides github.com for clone and push (tests use a local bare repo). */ remoteUrl?: string; fetch?: typeof fetch; /** The GitHub issue this incident lives in: the PR closes it, and a failure is reported on it instead of a new issue. */ issueNumber?: number; /** Unprivileged user the repo's tests and builds run as (see resolveFixSandbox). */ sandbox?: SandboxUser; /** Exact secret values a fix must never contain. Defaults to every secret-looking variable in this process's environment. */ secretValues?: string[]; audit?: AuditContext; /** Whether Docker is usable. Tests set this; by default it is checked for real. */ dockerUp?: () => boolean; } export type FixSandbox = { ok: true; sandbox?: SandboxUser; } | { ok: false; problem: string; }; /** * Whether the fix engine may run, and as whom. Each fix's tests execute code no human has reviewed (the AI's patch, * which a crafted customer report can influence), so they must not run as the server's user: that user can read the * server's API keys and GitHub token (e.g. /proc/1/environ) and every customer report. * - BLAZE_SANDBOX_USER: a dedicated unprivileged user; the server must run as root to start tests as it. * - Otherwise BLAZE_ALLOW_UNSANDBOXED_FIXES=true is an explicit opt-in for a trusted local setup. */ export declare function resolveFixSandbox(env?: NodeJS.ProcessEnv, serverUid?: number | undefined, lookup?: (name: string) => SandboxUser | undefined): FixSandbox; export type FixOutcome = { status: 'pr_opened'; url: string; } | { status: 'needs_human'; url?: string; reason: string; }; /** Offline container settings for a project, or undefined when tests run with network. Fails closed if Docker was asked for and is missing. */ export declare function resolveOffline(project: FixProject, dockerUp?: () => boolean): { image: string; } | undefined; /** * The comment left on every PR: what produced it, what it touched, how it was verified, and which checks it passed. * A record a reviewer can trust more than the PR description, because it is written by the harness and not by the model. */ export declare function auditComment(a: { result: ResolutionResult; project: FixProject; offline: { image: string; } | undefined; unprivileged: boolean; durationMs: number; reportCount: number; issueNumber?: number; audit?: AuditContext; }): string; /** * Keeps the server's customer data and secrets on disk out of the sandbox user's reach: no access for other users. * Paths match IncidentStore's and ProjectRegistry's defaults. */ export declare function lockDownServerFiles(env?: NodeJS.ProcessEnv): void; /** * One incident, start to a GitHub pull request: clone, resolve in isolated workspaces, push a branch, open the PR. * When no fix passes, it opens an issue with the findings instead of a PR. It never merges or pushes to the default branch. * * Tests and builds get a minimal environment and, with `sandbox`, run as an unprivileged user in a copy without .git. * They still have network access, so the repo's own source is what unreviewed code could send out. */ export declare function runFix(opts: FixJobOptions): Promise; //# sourceMappingURL=fix.d.ts.map