feat(miner-manage): local pr_outcome record writer (#4274) - #4450
Conversation
Add packages/gittensory-miner/lib/pr-outcome.js: the miner's OWN local record of
the outcomes of its OWN PRs (merged / closed), layered on the generic append-only
event-ledger.js exactly like manage-status.js layers MANAGE_PR_UPDATE_EVENT.
- MINER_PR_OUTCOME_EVENT + normalizePrOutcomePayload: a distinct local event type
and a tolerant payload normalizer (returns null on a malformed shape). A closed
decision may carry a reason bucket reused from rejection-templates.js's
REJECTION_REASONS (shared vocabulary with the rejection-state-machine sibling); a
merged decision or an unrecognized reason normalizes the reason to null.
- recordPrOutcomeSnapshot(input, { eventLedger }): a thin writer over an injected
ledger (same DI shape as recordManagePollSnapshot, unit-testable without a real
file). Fail-soft: a missing repo or invalid payload returns null; only an unusable
ledger throws.
- readPrOutcomes(eventLedger, filter): reduces the append-only stream to the latest
outcome per repo/PR, mirroring indexLatestManageUpdates.
Distinct from the SERVER-side pr_outcome path (recordPrOutcome, src/review/
outcomes-wire.ts): same concept name, different codebase layer, no shared code (a
laptop-mode miner may have no webhook relay). Adds the hand-written .d.ts and a
README note recording that distinction.
Closes JSONbored#4274
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
1 similar comment
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4450 +/- ##
=======================================
Coverage 93.97% 93.97%
=======================================
Files 414 414
Lines 37317 37317
Branches 13636 13636
=======================================
Hits 35068 35068
Misses 1594 1594
Partials 655 655 🚀 New features to boost your workflow:
|
|
Tip 🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩 ✅ Gittensory review result - approve/merge recommendedReview updated: 2026-07-09 19:24:02 UTC
✅ Suggested Action - Approve/Merge
Review summary Nits — 5 non-blocking
Linked issue satisfactionAddressed 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.
|
Adds
packages/gittensory-miner/lib/pr-outcome.js— the miner's own local record of the outcomes of its own PRs (merged / closed), layered on the generic append-onlyevent-ledger.jsexactly likemanage-status.jslayersMANAGE_PR_UPDATE_EVENT.API (mirrors the manage-status pattern)
MINER_PR_OUTCOME_EVENT+normalizePrOutcomePayload— a distinct local event type and a tolerant payload normalizer (returnsnullon any malformed shape). Acloseddecision may carry a reason bucket reused fromrejection-templates.js'sREJECTION_REASONS(one shared vocabulary with the rejection-state-machine sibling); amergeddecision — or an unrecognized reason — normalizes the reason tonull.recordPrOutcomeSnapshot(input, { eventLedger })— a thin writer over an injected ledger (same DI shape asrecordManagePollSnapshot, so it's unit-testable without a real SQLite file). Fail-soft: a missing repo or invalid payload returnsnull; only an unusable ledger throws.readPrOutcomes(eventLedger, filter)— reduces the append-only stream to the latest outcome per repo/PR, mirroringindexLatestManageUpdates.Distinct from the server-side namesake
This is not
src/review/outcomes-wire.ts'srecordPrOutcome(which writes hosted-backend audit rows from the GitHub App's webhook stream). Same concept name, different codebase layer, no shared code — a laptop-mode miner may have no webhook relay at all. Uses a distinctMINER_PR_OUTCOME_EVENTconstant, adds the hand-written.d.ts, and records the distinction in the package README.Tests
test/unit/miner-pr-outcome.test.ts: normalizer validation (non-object / bad prNumber / unknown decision / merged-drops-reason / closed-keeps-recognized-reason / null-non-string-whitespace coercion), the writer (unusable-ledger throw, fail-soft null, valid append), and the reader (latest-per-PR reduction, foreign-type / blank-repo / bad-payload skips, unreadable-ledger). 100% branch coverage on the new module; typecheck clean; miner-package skeleton suite green.Closes #4274