/** * Subset of `DkgConfig['store']` used by the wipe step to talk to an * external SPARQL endpoint. Decoupled from the CLI's config types so * this module stays free of upward dependencies. */ export interface ChainResetWipeStoreConfig { backend: string; options?: { url?: string; queryEndpoint?: string; updateEndpoint?: string; auth?: string; /** * True when the namespace was provisioned by the CLI (PR 3 Docker * convenience path). Operator-provided URLs default to false; the * wipe then scopes deletes to the V10 named-graph prefix to avoid * clobbering V6/V8 data sharing the same Blazegraph instance. */ managedByDkg?: boolean; }; } export interface ChainResetWipeResult { /** True when a wipe was performed. */ wiped: boolean; /** The marker we had persisted before this boot, or null on first boot / no persisted state. */ prevMarker: string | null; /** Files removed during the wipe (relative to dataDir). Empty when `wiped=false`. */ removedFiles: string[]; /** * Files we attempted to wipe but could not remove. When non-empty, the * marker is intentionally not persisted so the wipe retries on next boot. */ failedFiles: Array<{ file: string; error: string; }>; } export interface ChainResetWipeOptions { /** Node data directory (e.g. `~/.dkg`). */ dataDir: string; /** * Bundled network config's `chainResetMarker`. `undefined` means the * network has not opted into the auto-wipe protocol — the hook is then * a no-op (no state file written, no wipe). */ currentMarker: string | undefined; /** * Resolved runtime path of the random-sampling WAL. When the operator * sets `randomSampling.walPath` in their config, the prover writes to * that path instead of the default `dataDir/random-sampling.wal`. We * have to wipe whichever path is actually in use; the default-path * wipe alone would leave a stale WAL under operator-supplied paths. * Falsy → fall back to `dataDir/random-sampling.wal` (the default). */ randomSamplingWalPath?: string; /** * Operator's `config.store` block. Required to wipe an external SPARQL * endpoint when the backend is `blazegraph` / `sparql-http`. Local * backends ignore this field. */ storeConfig?: ChainResetWipeStoreConfig; /** * Override for the SPARQL HTTP transport. Tests inject a mock to * assert the issued UPDATE body; defaults to `globalThis.fetch`. * Kept on the options surface (rather than module-scope monkey-patch) * so parallel test cases don't race. */ fetch?: typeof globalThis.fetch; /** Optional logger. Defaults to no-op so the function is silent in tests by default. */ log?: (msg: string) => void; } export declare function chainResetWipe(opts: ChainResetWipeOptions): Promise; export interface BackendSwitchDetectOptions { dataDir: string; /** * Backend name from the current config. Pass the effective value * including the default — e.g. when `config.store?.backend` is * undefined, callers should pass `'oxigraph-worker'` so the check * is symmetric across "no store block" ↔ "explicit store block". */ currentBackend: string; /** * Operator opt-in to proceed despite a backend change. Sourced from * `process.env.DKG_ACCEPT_STORE_RESET === '1'` in production; tests * inject explicitly. */ acceptStoreReset: boolean; log?: (msg: string) => void; } export interface BackendSwitchDetectResult { /** True when `lastBackend` was recorded and differs from `currentBackend`. */ changed: boolean; /** Previously-recorded backend, or null if none / legacy state file. */ previous: string | null; /** Effective current backend (passed through for callers). */ current: string; /** * True when the daemon should abort boot. Set on `changed && !acceptStoreReset`. * Caller exits the process so the operator can either flip the env * var or revert their config edit. */ aborted: boolean; } export declare function detectBackendSwitch(opts: BackendSwitchDetectOptions): BackendSwitchDetectResult; //# sourceMappingURL=chain-reset-wipe.d.ts.map