Skip to content

feat(miner-foundation): immutable event ledger for gittensory-miner #2290

Description

@JSONbored

Add an append-only, immutable local event ledger (a second small SQLite table, or a separate DB file) recording every significant miner-loop event (discovered_issue, plan_built, plan_step_completed, pr_prepared, etc. — a small fixed event-type enum for this foundation phase; the full discover/analyze/plan/prepare loop's actual event vocabulary grows in later phases) with a monotonic sequence number and timestamp. This is the audit trail the phase brief calls for — append-only means no UPDATE/DELETE statements are ever issued against this table, only INSERT, so a contributor auditing the miner's history later can trust it was not retroactively edited.

Deliverables

  • An event-ledger module exposing appendEvent(event: { type: string; repoFullName?: string; payload: Record<string, unknown> }): LedgerEntry and readEvents(filter?: { repoFullName?: string; since?: number }).
  • Schema: id INTEGER PRIMARY KEY AUTOINCREMENT, seq INTEGER NOT NULL, event_type TEXT NOT NULL, repo_full_name TEXT, payload_json TEXT NOT NULL, created_at TEXT NOT NULLseq is a monotonically increasing counter maintained by the module (not just relying on AUTOINCREMENT's reuse-after-vacuum behavior) so consumers get a stable ordering guarantee.
  • A test asserting the module NEVER issues an UPDATE or DELETE against the ledger table — e.g. grep the module source in a unit test for those SQL keywords, or (stronger) wrap the DB handle in a test double that throws if either is called.
  • Unit tests: append-then-read round-trip, sequence monotonicity across multiple appends, filter-by-repoFullName, filter-by-since.
  • Doc comment stating the immutability invariant explicitly (mirroring src/signals/duplicate-winner.ts's style of stating its own PURE invariant in a header comment) so a future contributor editing this file sees the constraint before touching it.

References

  • migrations/0010_agent_orchestrator.sql (55 lines) — the existing agent_actions/agent_context_snapshots append-oriented schema shape (created_at defaults, indexed by run/time) to mirror the SPIRIT of, though this is a local SQLite table, not a D1 migration.
  • src/signals/duplicate-winner.ts (header comment, lines 1-13) — precedent for stating a hard invariant (there: PURE/no-IO; here: append-only) directly in the module's doc comment.
  • New path: packages/gittensory-miner/lib/event-ledger.js (or co-located with run-state, per the run-state issue's file layout).

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