Skip to content

feat(miner-foundation): local run-state SQLite store for gittensory-miner #2289

Description

@JSONbored

Add the first piece of 100%-client-side persistence: a small SQLite-backed run-state store (packages/gittensory-miner/lib/run-state.js or a TS module built alongside) tracking the miner's current state machine position (e.g. idle / discovering / planning / preparing — a small fixed enum, NOT the full discover→create→manage loop's business logic, just the persistence shape) per target repo. No network calls, no shared credentials — this is local infra only, mirroring how src/selfhost/ already hosts self-host-specific local infra modules (audit.ts, health.ts, migrate.ts) alongside the Worker-hosted code.

Deliverables

  • A run-state module exposing initRunStateStore(dbPath), getRunState(repoFullName), setRunState(repoFullName, state) with a small fixed RunState union type.
  • A local SQLite schema (single small table: repo_full_name TEXT PRIMARY KEY, state TEXT NOT NULL, updated_at TEXT NOT NULL) created idempotently on first use (CREATE TABLE IF NOT EXISTS).
  • Default DB path follows an XDG-style convention (~/.config/gittensory-miner/run-state.sqlite3 or $XDG_CONFIG_HOME-aware), mirroring gittensory-mcp's own configPath/cacheDir resolution pattern (env override, then XDG_CONFIG_HOME, then ~/.config).
  • Unit tests covering: first-run table creation, read-before-any-write (returns a sensible default/null), write-then-read round-trip, and re-opening an existing DB file without re-creating/truncating it.
  • Explicit doc comment stating this store is 100% local/client-side and never uploads its contents anywhere, matching the phase's no-phone-home requirement.

References

  • packages/gittensory-mcp/bin/gittensory-mcp.js (lines 135-141) — the configPath/cacheDir env-then-XDG-then-default resolution pattern to mirror for the run-state DB path.
  • src/selfhost/migrate.ts — self-host local migration/schema-application pattern to mirror for idempotent local schema setup (note: this new module is SQLite-based client tooling, distinct from the D1/Postgres migration system migrate.ts drives, but the idempotent-apply spirit is the same).
  • New path: packages/gittensory-miner/lib/run-state.js (or .ts, per whichever this package's build issue settled on).

Metadata

Metadata

Assignees

No one assigned

    Labels

    gittensor:featureGittensor-scored feature linked to a feature issue — scores a 0.25x multiplier.help wantedExtra attention is needed

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions