// The single controlled filesystem-WRITE boundary (ADR-0006 D2). WorkspaceFs stays read-only
// (ADR-0005); all mutation goes through this port so the apply phase is auditable and testable
// with an in-memory fake. Callers (patch.ts) MUST pre-validate every absolute path via
// resolveWithinWorkspace + isDenied before handing it here; this adapter does no validation
// itself — it is the effectful edge, kept deliberately thin. Synchronous, mirroring nodeWorkspaceFs.
import { mkdirSync, renameSync, rmSync, writeFileSync } from "node:fs";
export const nodeWorkspaceWriter = {
    writeFileUtf8: (absolutePath, content) => {
        writeFileSync(absolutePath, content, "utf8");
    },
    mkdirp: (absoluteDir) => {
        mkdirSync(absoluteDir, { recursive: true });
    },
    remove: (absolutePath) => {
        rmSync(absolutePath, { force: true });
    },
    rename: (fromAbsolute, toAbsolute) => {
        renameSync(fromAbsolute, toAbsolute);
    },
};
