feat(miner): add append-only event ledger#2754
Conversation
|
🚨 Contributor flagged. Click here for more info: Superagent Dashboard |
|
Warning 🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨 ⏸️ Gittensory review result - manual review recommendedReview updated: 2026-07-03 18:37:49 UTC
⏸️ Suggested Action - Manual Review Review summary Nits — 5 non-blocking
Review context
Contributor next steps
Signal definitions
🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2754 +/- ##
=======================================
Coverage 96.09% 96.09%
=======================================
Files 245 245
Lines 27391 27391
Branches 9947 9947
=======================================
Hits 26322 26322
Misses 443 443
Partials 626 626 🚀 New features to boost your workflow:
|
8e0e97a to
5b0863a
Compare
|
Fixed the flagged concurrency defect. |
Add packages/gittensory-miner/lib/event-ledger.js: an immutable, append-only local audit trail of miner-loop events (discovered_issue, plan_built, plan_step_completed, pr_prepared, ...), backed by a local SQLite table and mirroring the run-state/portfolio-queue local-store pattern. appendEvent stamps a module-maintained monotonic seq (MAX(seq)+1, not AUTOINCREMENT reuse) and an ISO timestamp; readEvents returns events in seq order, optionally filtered by repoFullName and/or a strictly-greater seq `since`. Immutability invariant: the module only ever INSERTs and SELECTs, never rewriting or removing a row, so the history cannot be retroactively edited; a test asserts the source issues no mutating SQL. The DB is owner-only (0o600) and never leaves the machine. Closes JSONbored#2290.
5b0863a to
8bfdf03
Compare
|
Fixed the payload round-trip defect. |
Summary
Adds the local append-only event ledger to
@jsonbored/gittensory-miner— an immutable audit trail of every significant miner-loop event (discovered_issue,plan_built,plan_step_completed,pr_prepared, … — a small fixed vocabulary for this foundation phase that grows later), backed by a small local SQLite table. It mirrors the package's existing local-store pattern (lib/run-state.js,lib/portfolio-queue.js) and never uploads, syncs, or phones home — the DB is owner-only and stays on the miner's machine.Immutability invariant: the module only ever issues
INSERTandSELECT— it never rewrites or removes a row — so a contributor auditing the miner's history later can trust it was not retroactively edited. The header comment states this constraint explicitly, and a test asserts the module source contains no mutating/removing SQL keyword.API (
lib/event-ledger.js):appendEvent({ type, repoFullName?, payload })→LedgerEntry— stamps a module-maintained monotonicseqand an ISO timestamp;payloadis stored as JSON and round-trips verbatim.readEvents(filter?)— all events inseq ASCorder, optionally filtered byrepoFullNameand/orsince(events with a seq strictly greater thansince— the "give me everything after the last seq I saw" polling shape).Schema is per the issue spec:
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 NULL.seqis maintained by the module (MAX(seq) + 1) rather than relying onAUTOINCREMENT's reuse-after-vacuum behavior, so consumers get a stable ordering guarantee.Closes #2290.
Scope
type(scope): short summaryConventional Commit format.CONTRIBUTING.mdand does not reintroduce GitHub Pages, VitePress,site/, orCNAME.Validation
git diff --checknpm run typechecknpm run test:coveragelocally — the newtest/unit/miner-event-ledger.test.tspasses (whole miner suite green). This change lives entirely inpackages/**, which Codecov does not measure, so it carries nocodecov/patchobligation; the logic is nonetheless exercised across append/read round-trip, seq monotonicity, both filters (and their combination), null vs present repo scope, input rejection, and the append-only-source assertion.node --check lib/event-ledger.jsvianpm run --workspace @jsonbored/gittensory-miner buildnpm audit --audit-level=moderate— this PR adds no dependencies, so dependency-review has nothing new to evaluate.If any required check was skipped, explain why:
packages/gittensory-miner/libplus its test — nosrc/**, UI, API schema, Drizzle, or Cloudflare-binding surface is touched. The SQLite table is a miner-local file, not a repo migration.Safety
0o600in a0o700dir, owner-only, and never leaves the machine.UI Evidencesection. — n/a: no visible UI, frontend, docs, or extension change.Notes
Additive and consistent with the package's existing local-store pattern: two new files (
lib/event-ledger.js+ itslib/event-ledger.d.ts) mirroringlib/run-state.js/lib/portfolio-queue.js(path resolution,0o600/0o700perms, prepared statements, default-store singleton), one line added to the packagebuild(node --check) gate, and one new test file. No existing code is modified.