/** * Conflict report formatter for the T311 A/B JSON restore engine. * * Reads {@link JsonRestoreReport}[] (from T354) plus optional re-auth and * schema-compatibility warnings, and emits the markdown report format * defined in T311 spec §6.5. * * PURE FORMATTER — the only I/O in this module is inside * {@link writeConflictReport}, which writes a single file via * `fs.writeFileSync`. Everything else is a pure string transformation. * * @task T357 * @epic T311 * @why ADR-038 §10 — restore writes a markdown conflict report at * .cleo/restore-conflicts.md so users (and downstream agents) can * review classifications + resolve manual-review fields + finalize * via `cleo restore finalize`. * @what Pure formatter. Reads JsonRestoreReport[] from T354 + extra * metadata (re-auth warnings, schema warnings) and emits markdown. * @module restore-conflict-report */ import type { JsonRestoreReport } from './restore-json-merge.js'; /** * Warning emitted when a signaldock.db agent was encrypted with the * source machine's global-salt and therefore cannot be decrypted on the * target machine. * * @task T357 * @epic T311 */ export interface ReauthWarning { /** Canonical agent identifier, e.g. `"cleo-prime"`. */ agentId: string; /** Human-readable reason the agent needs re-authentication. */ reason: string; } /** * Warning emitted when a bundled database's schema version differs from * the local schema version. * * @task T357 * @epic T311 */ export interface SchemaCompatWarning { /** Database name without extension, e.g. `"brain"` or `"conduit"`. */ db: string; /** Schema version string found in the bundle. */ bundleVersion: string; /** Schema version string found in the local installation. */ localVersion: string; /** * Severity of the mismatch: * - `older-bundle` — bundle schema is behind local; forward migration will * run on first open. * - `newer-bundle` — bundle schema is ahead of local; upgrading cleo is * recommended before using the restored database. */ severity: 'older-bundle' | 'newer-bundle'; } /** * All inputs required to build the `.cleo/restore-conflicts.md` report. * * @task T357 * @epic T311 */ export interface BuildConflictReportInput { /** Per-file A/B comparison results produced by T354. */ reports: JsonRestoreReport[]; /** Filesystem path of the bundle file that was imported. */ bundlePath: string; /** Machine fingerprint recorded in the bundle manifest (source machine). */ sourceMachineFingerprint: string; /** Machine fingerprint of the local machine (target machine). */ targetMachineFingerprint: string; /** Cleo version string of the importing installation, e.g. `"2026.4.13"`. */ cleoVersion: string; /** * Agent re-authentication warnings for agents whose credentials were * encrypted with the source machine's global-salt. * Omit or pass an empty array when no agents need re-auth. */ reauthWarnings?: ReauthWarning[]; /** * Schema version mismatch warnings for bundled databases. * Omit or pass an empty array when all schemas match. */ schemaWarnings?: SchemaCompatWarning[]; } /** * Builds the complete markdown content for `.cleo/restore-conflicts.md`. * * The output follows the T311 spec §6.5 format: * - Header with bundle metadata and timestamps * - One `##` section per file in `input.reports` * - Agent re-authentication section (or _None_ when empty) * - Schema compatibility warnings section (or _None_ when empty) * - Footer instruction for `cleo restore finalize` * * @task T357 * @epic T311 * @param input - All data required to render the report. * @returns The full markdown string. Does NOT write to disk. */ export declare function buildConflictReport(input: BuildConflictReportInput): string; /** * Writes the conflict report markdown to * `/.cleo/restore-conflicts.md`. * * Creates the `.cleo/` directory if it does not already exist. * * @task T357 * @epic T311 * @param projectRoot - Absolute path to the project root directory. * @param content - Markdown string produced by {@link buildConflictReport}. * @returns The absolute path of the written file. */ export declare function writeConflictReport(projectRoot: string, content: string): string; //# sourceMappingURL=restore-conflict-report.d.ts.map