package com.correx.core.toolintent

import java.nio.file.Files
import java.nio.file.Path

/** Abstracts filesystem observation so rules are testable and replay never re-stats. */
interface WorldProbe {
    fun exists(path: Path): Boolean

    /** Symlink-resolved real path if it exists; otherwise the normalized absolute path. */
    fun resolveReal(path: Path): Path
}

class FileSystemWorldProbe : WorldProbe {
    override fun exists(path: Path): Boolean = Files.exists(path)

    override fun resolveReal(path: Path): Path =
        runCatching { path.toRealPath() }.getOrElse { path.toAbsolutePath().normalize() }
}
