Skip to content

feat(miner-governor): append-only local event ledger schema + writer #2328

Description

@JSONbored

Every governor decision (allowed, denied, throttled, kill-switch-tripped) needs to land in an immutable local event ledger so a contributor can audit what their own miner did — before any enforcement logic exists to populate it. This issue is schema + a pure/append-only writer function only.

Mirror src/selfhost/audit.ts's AuditEvent/logAudit shape (one structured JSON record per lifecycle event, easy to grep/pipe) but for local SQLite storage instead of stdout, since the miner's state must be 100% client-side per the architecture skeleton.

Deliverables

  • New migration-style SQL (e.g. packages/gittensory-miner/migrations/0001_governor_ledger.sql) defining an append-only governor_events table: id, ts, event_type, repo_full_name, action_class, decision, reason, payload_json — no UPDATE/DELETE path, insert-only
  • A typed GovernorLedgerEvent type + a pure appendGovernorEvent(db, event) writer, mirroring logAudit's one-JSON-record-per-event shape
  • Unit tests: successful append round-trips all fields, malformed event type is rejected before insert (fail closed on unknown event_type)
  • Explicitly note in comments that this issue does NOT wire the ledger into any real governor decision path — it only defines the storage contract other issues will write into

References

  • src/selfhost/audit.ts (39 lines) — the AuditEvent/logAudit structured-event pattern to mirror
  • migrations/0010_agent_orchestrator.sql (55 lines) — the existing orchestrator seed-schema style (append-friendly tables, CREATE INDEX per query pattern) to follow for the new miner-local migration
  • .gittensory-miner.yml (new MinerGoalSpec config file, per the architecture skeleton) — NOT touched by this issue but the eventual consumer of ledger-driven throttling config

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