/**
 * memory-host-process-migration.ts — idempotent cleanup of the Phase A
 * host-process model's residual state on disk.
 *
 * Phase A spawned `agentmemory` as a host child process and recorded its PID
 * at `~/.olam/memory.pid` + stdout/stderr at `~/.olam/memory-service.log`.
 * Phase B repoints `olam memory start` at the Docker substrate (this skill's
 * `MemoryServiceContainerController`); the legacy pidfile + log become orphan
 * artefacts the moment the new substrate runs.
 *
 * This helper is called from `runMemoryStart` / `runMemoryStop` (B1 / B2) BEFORE
 * the substrate handoff so operators upgrading from the host-process model
 * never have to manually clean up.
 *
 * PID-reuse defence (T2 mitigation). A stale pidfile can record a PID that
 * the OS has since recycled to an unrelated process. SIGTERMing the wrong PID
 * is a foot-gun. Defence:
 *   1. If pidfile is absent → no-op.
 *   2. If recorded PID is dead (kill(0) throws ESRCH) → unlink pidfile only.
 *   3. If recorded PID is alive BUT `ps -p <pid> -o comm=` doesn't return
 *      `node` (the legacy host-process was always a node child) → unlink
 *      pidfile WITHOUT signalling. Logs a warning so support can diagnose.
 *   4. Only when PID is alive AND comm=node → SIGTERM, wait up to 5s,
 *      SIGKILL on timeout, then unlink.
 *
 * Plan reference: docs/plans/memory-service-as-docker-peripheral/phase-b-tasks.md B5
 */
export interface MigrationResult {
    /** True if any legacy artefact (pidfile or log) was found + cleaned. */
    readonly cleaned: boolean;
    /** One-line description of what happened (for operator-visible logging). */
    readonly summary: string;
}
export interface MigrationOptions {
    /** Remove `memory-service.log` in addition to the pidfile (B2 stop path uses this). */
    removeLog?: boolean;
    /** Override the pidfile path. Defaults to MEMORY_PID_PATH. Used by tests. */
    pidPath?: string;
    /** Override the log path. Defaults to MEMORY_LOG_PATH. Used by tests. */
    logPath?: string;
}
/**
 * Detect + clean up legacy host-process state. Idempotent — safe to call on
 * every `olam memory start` / `olam memory stop` invocation; no-op when no
 * legacy artefacts present.
 *
 * Side effects (only when artefacts present):
 *   - Unlink `~/.olam/memory.pid` if it exists.
 *   - Send SIGTERM (then SIGKILL on timeout) to the recorded PID iff it's
 *     alive AND its comm name is `node` (the legacy spawn shape).
 *   - Leave `~/.olam/memory-service.log` in place by default — operators
 *     may want to inspect it post-migration. Pass `{ removeLog: true }` to
 *     remove it explicitly (B2's stop path uses this).
 */
export declare function migrateFromHostProcess(opts?: MigrationOptions): MigrationResult;
//# sourceMappingURL=memory-host-process-migration.d.ts.map