//#region ../core/dist/store/data-accessor.js
/**
* DataAccessor re-export + factory functions.
*
* The DataAccessor interface is defined in @cleocode/contracts.
* This module re-exports it and provides the concrete SQLite factory.
*
* @epic T4454
* @task T9054
*/
/**
* Assert that production database writes are forbidden in test mode.
*
* When `CLEO_TEST_MODE=1` is set, any write to a production `tasks.db` or
* `brain.db` path (i.e. paths NOT under a temp dir or the env-var override)
* throws `E_PROD_DB_WRITE_IN_TEST`. This prevents tests from accidentally
* polluting the developer's live database.
*
* Escape hatch: set `CLEO_TEST_DB_OVERRIDE=1` to suppress the guard (audited
* per ADR-051 pattern — written to `.cleo/audit/force-bypass.jsonl`).
*
* @param dbPath - Absolute resolved path to the SQLite file being opened.
* @throws Error with code `E_PROD_DB_WRITE_IN_TEST` when the guard fires.
*
* @task T1906
*/
function assertTestEnv(dbPath) {
	if (process.env["CLEO_TEST_MODE"] !== "1") return;
	if (process.env["CLEO_TEST_DB_OVERRIDE"] === "1") {
		process.stderr.write(`[T1906] CLEO_TEST_DB_OVERRIDE=1 — bypassing prod-DB guard for: ${dbPath}\n`);
		return;
	}
	const tmpDir = process.env["TMPDIR"] ?? process.env["TMP"] ?? process.env["TEMP"] ?? "/tmp";
	if (!(dbPath === ":memory:" || dbPath.startsWith(tmpDir) || dbPath.includes("/tmp/") || dbPath.includes("\\Temp\\") || dbPath.includes(".test.") || dbPath.includes("/test-") || dbPath.includes("vitest"))) throw new Error(`E_PROD_DB_WRITE_IN_TEST: CLEO_TEST_MODE=1 but attempted to open production DB at "${dbPath}". Use an in-memory or temp-dir database in tests, or set CLEO_TEST_DB_OVERRIDE=1 to bypass (audited). (T1906 / BBTT-W3-4)`);
}
/**
* Create a DataAccessor for the given working directory.
* Always creates a SQLite accessor (ADR-006 canonical storage).
*
* ALL accessors returned are safety-enabled by default via SafetyDataAccessor wrapper.
* Use CLEO_DISABLE_SAFETY=true to bypass (emergency only).
*
* @task T9054 — engine parameter dropped; CLEO is SQLite-only (ADR-006).
*/
async function createDataAccessor(cwd) {
	const { createSqliteDataAccessor } = await import('./sqlite-data-accessor2-BTjS4eNN.js');
	const inner = await createSqliteDataAccessor(cwd);
	const { wrapWithSafety } = await import('./safety-data-accessor-Bs_jU8n-.js');
	return wrapWithSafety(inner, cwd);
}
/**
* Get a tasks-DB DataAccessor for the given working directory.
*
* This is the canonical tasks-only factory. Name is explicit about scope —
* the former `getAccessor` name implied universality and caused the
* gitnexus graph to misclassify it as a universal key (T9054).
*
* @param cwd - Optional project root (defaults to process.cwd() resolution).
* @returns DataAccessor backed by tasks.db (ADR-006, ADR-068).
*/
async function getTaskAccessor(cwd) {
	return createDataAccessor(cwd);
}

var dataAccessor = /*#__PURE__*/Object.freeze({
	__proto__: null,
	assertTestEnv: assertTestEnv,
	getTaskAccessor: getTaskAccessor
});

export { createDataAccessor as c, dataAccessor as d, getTaskAccessor as g };
//# sourceMappingURL=data-accessor-CVbz8X_7.js.map
