Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions apps/loopover-ui/src/lib/ams-env-reference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const AMS_ENV_REFERENCE_ROWS: MinerEnvReferenceRow[] = [
{
name: "LOOPOVER_MINER_GOVERNOR_LEDGER_DB",
firstReference: "lib/governor-ledger.js",
defaultValue: "",
defaultValue: null,
},
{
name: "LOOPOVER_MINER_GOVERNOR_STATE_DB",
Expand All @@ -84,7 +84,7 @@ export const AMS_ENV_REFERENCE_ROWS: MinerEnvReferenceRow[] = [
{
name: "LOOPOVER_MINER_PLAN_STORE_DB",
firstReference: "lib/plan-store.js",
defaultValue: "",
defaultValue: null,
},
{
name: "LOOPOVER_MINER_POLICY_DOC_CACHE_DB",
Expand All @@ -104,7 +104,7 @@ export const AMS_ENV_REFERENCE_ROWS: MinerEnvReferenceRow[] = [
{
name: "LOOPOVER_MINER_PREDICTION_LEDGER_DB",
firstReference: "lib/prediction-ledger.js",
defaultValue: "",
defaultValue: null,
},
{
name: "LOOPOVER_MINER_RANKED_CANDIDATES_DB",
Expand Down Expand Up @@ -175,16 +175,16 @@ export const AMS_ENV_REFERENCE_MARKDOWN = [
"| `LOOPOVER_MINER_CONTRIBUTION_PROFILE_CACHE_DB` | `lib/contribution-profile-cache.js` | (none) |",
'| `LOOPOVER_MINER_DENY_HOOK_SYNTHESIS_DB` | `lib/deny-hook-synthesis.js` | `""` |',
"| `LOOPOVER_MINER_EVENT_LEDGER_DB` | `lib/event-ledger.js` | (none) |",
'| `LOOPOVER_MINER_GOVERNOR_LEDGER_DB` | `lib/governor-ledger.js` | `""` |',
"| `LOOPOVER_MINER_GOVERNOR_LEDGER_DB` | `lib/governor-ledger.js` | (none) |",
"| `LOOPOVER_MINER_GOVERNOR_STATE_DB` | `lib/governor-state.js` | (none) |",
'| `LOOPOVER_MINER_LOG_LEVEL` | `lib/logger.js` | `""` |',
'| `LOOPOVER_MINER_NO_UPDATE_CHECK` | `lib/update-check.js` | `""` |',
'| `LOOPOVER_MINER_ORB_EXPORT_DB` | `lib/orb-export.js` | `""` |',
'| `LOOPOVER_MINER_PLAN_STORE_DB` | `lib/plan-store.js` | `""` |',
"| `LOOPOVER_MINER_PLAN_STORE_DB` | `lib/plan-store.js` | (none) |",
"| `LOOPOVER_MINER_POLICY_DOC_CACHE_DB` | `lib/policy-doc-cache.js` | (none) |",
"| `LOOPOVER_MINER_POLICY_VERDICT_CACHE_DB` | `lib/policy-verdict-cache.js` | (none) |",
"| `LOOPOVER_MINER_PORTFOLIO_QUEUE_DB` | `lib/portfolio-queue.js` | (none) |",
'| `LOOPOVER_MINER_PREDICTION_LEDGER_DB` | `lib/prediction-ledger.js` | `""` |',
"| `LOOPOVER_MINER_PREDICTION_LEDGER_DB` | `lib/prediction-ledger.js` | (none) |",
"| `LOOPOVER_MINER_RANKED_CANDIDATES_DB` | `lib/ranked-candidates.js` | (none) |",
"| `LOOPOVER_MINER_REPLAY_SNAPSHOT_DB` | `lib/replay-snapshot.js` | (none) |",
'| `LOOPOVER_MINER_REPO_CLONE_DIR` | `lib/repo-clone.js` | `""` |',
Expand Down
6 changes: 3 additions & 3 deletions packages/loopover-miner/docs/env-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ Generated by `npm run miner:env-reference`. Do not edit manually.
| `LOOPOVER_MINER_CONTRIBUTION_PROFILE_CACHE_DB` | `lib/contribution-profile-cache.js` | (none) |
| `LOOPOVER_MINER_DENY_HOOK_SYNTHESIS_DB` | `lib/deny-hook-synthesis.js` | `""` |
| `LOOPOVER_MINER_EVENT_LEDGER_DB` | `lib/event-ledger.js` | (none) |
| `LOOPOVER_MINER_GOVERNOR_LEDGER_DB` | `lib/governor-ledger.js` | `""` |
| `LOOPOVER_MINER_GOVERNOR_LEDGER_DB` | `lib/governor-ledger.js` | (none) |
| `LOOPOVER_MINER_GOVERNOR_STATE_DB` | `lib/governor-state.js` | (none) |
| `LOOPOVER_MINER_LOG_LEVEL` | `lib/logger.js` | `""` |
| `LOOPOVER_MINER_NO_UPDATE_CHECK` | `lib/update-check.js` | `""` |
| `LOOPOVER_MINER_ORB_EXPORT_DB` | `lib/orb-export.js` | `""` |
| `LOOPOVER_MINER_PLAN_STORE_DB` | `lib/plan-store.js` | `""` |
| `LOOPOVER_MINER_PLAN_STORE_DB` | `lib/plan-store.js` | (none) |
| `LOOPOVER_MINER_POLICY_DOC_CACHE_DB` | `lib/policy-doc-cache.js` | (none) |
| `LOOPOVER_MINER_POLICY_VERDICT_CACHE_DB` | `lib/policy-verdict-cache.js` | (none) |
| `LOOPOVER_MINER_PORTFOLIO_QUEUE_DB` | `lib/portfolio-queue.js` | (none) |
| `LOOPOVER_MINER_PREDICTION_LEDGER_DB` | `lib/prediction-ledger.js` | `""` |
| `LOOPOVER_MINER_PREDICTION_LEDGER_DB` | `lib/prediction-ledger.js` | (none) |
| `LOOPOVER_MINER_RANKED_CANDIDATES_DB` | `lib/ranked-candidates.js` | (none) |
| `LOOPOVER_MINER_REPLAY_SNAPSHOT_DB` | `lib/replay-snapshot.js` | (none) |
| `LOOPOVER_MINER_REPO_CLONE_DIR` | `lib/repo-clone.js` | `""` |
Expand Down
23 changes: 3 additions & 20 deletions packages/loopover-miner/lib/governor-ledger.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { homedir } from "node:os";
import { join } from "node:path";
import { normalizeGovernorLedgerEvent } from "@loopover/engine";
import { openLocalStoreDb } from "./local-store.js";
import { normalizeLocalStoreDbPath, openLocalStoreDb, resolveLocalStoreDbPath } from "./local-store.js";
import { applySchemaMigrations } from "./schema-version.js";
import {
GOVERNOR_LEDGER_PURGE_SPEC,
Expand All @@ -22,26 +20,11 @@ const defaultDbFileName = "governor-ledger.sqlite3";
let defaultGovernorLedger = null;

export function resolveGovernorLedgerDbPath(env = process.env) {
const explicitPath = typeof env.LOOPOVER_MINER_GOVERNOR_LEDGER_DB === "string"
? env.LOOPOVER_MINER_GOVERNOR_LEDGER_DB.trim()
: "";
if (explicitPath) return explicitPath;

const explicitConfigDir = typeof env.LOOPOVER_MINER_CONFIG_DIR === "string"
? env.LOOPOVER_MINER_CONFIG_DIR.trim()
: "";
if (explicitConfigDir) return join(explicitConfigDir, defaultDbFileName);

const configHome = typeof env.XDG_CONFIG_HOME === "string" && env.XDG_CONFIG_HOME.trim()
? env.XDG_CONFIG_HOME.trim()
: join(homedir(), ".config");
return join(configHome, "loopover-miner", defaultDbFileName);
return resolveLocalStoreDbPath(defaultDbFileName, "LOOPOVER_MINER_GOVERNOR_LEDGER_DB", env);
}

function normalizeDbPath(dbPath) {
const path = (dbPath ?? resolveGovernorLedgerDbPath()).trim();
if (!path) throw new Error("invalid_governor_ledger_db_path");
return path;
return normalizeLocalStoreDbPath(dbPath, resolveGovernorLedgerDbPath(), "invalid_governor_ledger_db_path");
}

function normalizeOptionalRepoFullName(repoFullName) {
Expand Down
23 changes: 3 additions & 20 deletions packages/loopover-miner/lib/plan-store.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { homedir } from "node:os";
import { join } from "node:path";
import { openLocalStoreDb } from "./local-store.js";
import { normalizeLocalStoreDbPath, openLocalStoreDb, resolveLocalStoreDbPath } from "./local-store.js";
import { applySchemaMigrations } from "./schema-version.js";

// Local SQLite persistence for the stateless MCP plan DAG (#2318). `loopover_build_plan`/`plan_status`/
Expand All @@ -20,26 +18,11 @@ const defaultDbFileName = "plan-store.sqlite3";
let defaultPlanStore = null;

export function resolvePlanStoreDbPath(env = process.env) {
const explicitPath = typeof env.LOOPOVER_MINER_PLAN_STORE_DB === "string"
? env.LOOPOVER_MINER_PLAN_STORE_DB.trim()
: "";
if (explicitPath) return explicitPath;

const explicitConfigDir = typeof env.LOOPOVER_MINER_CONFIG_DIR === "string"
? env.LOOPOVER_MINER_CONFIG_DIR.trim()
: "";
if (explicitConfigDir) return join(explicitConfigDir, defaultDbFileName);

const configHome = typeof env.XDG_CONFIG_HOME === "string" && env.XDG_CONFIG_HOME.trim()
? env.XDG_CONFIG_HOME.trim()
: join(homedir(), ".config");
return join(configHome, "loopover-miner", defaultDbFileName);
return resolveLocalStoreDbPath(defaultDbFileName, "LOOPOVER_MINER_PLAN_STORE_DB", env);
}

function normalizeDbPath(dbPath) {
const raw = dbPath ?? resolvePlanStoreDbPath();
if (typeof raw !== "string" || !raw.trim()) throw new Error("invalid_plan_store_db_path");
return raw.trim();
return normalizeLocalStoreDbPath(dbPath, resolvePlanStoreDbPath(), "invalid_plan_store_db_path");
}

function normalizePlanId(planId) {
Expand Down
23 changes: 3 additions & 20 deletions packages/loopover-miner/lib/prediction-ledger.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { homedir } from "node:os";
import { join } from "node:path";
import { openLocalStoreDb } from "./local-store.js";
import { normalizeLocalStoreDbPath, openLocalStoreDb, resolveLocalStoreDbPath } from "./local-store.js";
import { applySchemaMigrations } from "./schema-version.js";
import {
PREDICTION_LEDGER_PURGE_SPEC,
Expand All @@ -24,26 +22,11 @@ const defaultDbFileName = "prediction-ledger.sqlite3";
let defaultPredictionLedger = null;

export function resolvePredictionLedgerDbPath(env = process.env) {
const explicitPath = typeof env.LOOPOVER_MINER_PREDICTION_LEDGER_DB === "string"
? env.LOOPOVER_MINER_PREDICTION_LEDGER_DB.trim()
: "";
if (explicitPath) return explicitPath;

const explicitConfigDir = typeof env.LOOPOVER_MINER_CONFIG_DIR === "string"
? env.LOOPOVER_MINER_CONFIG_DIR.trim()
: "";
if (explicitConfigDir) return join(explicitConfigDir, defaultDbFileName);

const configHome = typeof env.XDG_CONFIG_HOME === "string" && env.XDG_CONFIG_HOME.trim()
? env.XDG_CONFIG_HOME.trim()
: join(homedir(), ".config");
return join(configHome, "loopover-miner", defaultDbFileName);
return resolveLocalStoreDbPath(defaultDbFileName, "LOOPOVER_MINER_PREDICTION_LEDGER_DB", env);
}

function normalizeDbPath(dbPath) {
const path = (dbPath ?? resolvePredictionLedgerDbPath()).trim();
if (!path) throw new Error("invalid_prediction_ledger_db_path");
return path;
return normalizeLocalStoreDbPath(dbPath, resolvePredictionLedgerDbPath(), "invalid_prediction_ledger_db_path");
}

function normalizeRepoFullName(repoFullName) {
Expand Down
Loading