feat(miner-manage): add local pr_outcome record writer - #4429
Conversation
The miner needs its OWN local record of the outcome (merged / closed) of its OWN PRs, so a later self-improve pass can pair a prediction with its realized outcome. In laptop mode there may be no webhook relay at all, so this records outcomes locally via the existing event ledger rather than the server-side hosted-D1 path. - packages/gittensory-miner/lib/pr-outcome.js: normalizePrOutcomePayload (a strict, JSON-round-trippable normalizer — a `closed` decision may carry one REJECTION_REASONS reason bucket, a merged/unknown reason normalizes to null), recordPrOutcomeSnapshot (a thin dependency-injected writer with the same shape as recordManagePollSnapshot, so it's unit-testable without a real ledger), and readPrOutcomes (reduces the append-only ledger to the latest outcome per repo/PR). Deliberately reuses the MINER_PR_OUTCOME_EVENT = "pr_outcome" event type and REJECTION_REASONS vocabulary; no shared code with the server side. - packages/gittensory-miner/lib/pr-outcome.d.ts: hand-written types. - packages/gittensory-miner/README.md: one-line entry for the writer. - test/unit/miner-pr-outcome.test.ts: normalization, write, and read coverage against an injected fake ledger. Reopens the change from JSONbored#4389, which the orb auto-closed for a base-branch conflict after sibling miner PRs (JSONbored#4376/JSONbored#4390) merged and advanced the shared README; rebased onto current main, no conflict. Closes JSONbored#4274
❌ 4 Tests Failed:
View the top 3 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
|
Caution 🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥 🛑 Gittensory review result - fixes requiredReview updated: 2026-07-09 17:59:11 UTC
🛑 Suggested Action - Fix Blockers Review summary Nits — 5 non-blocking
CI checks failing
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.
|
|
Gittensory is closing this pull request on the maintainer's behalf (CI is failing (validate, validate-code)). This is an automated maintenance action — to pursue this change, please open a new pull request with the issues resolved. Closed PRs may be analyzed later to improve review accuracy, but they are not automatically reopened or re-reviewed. |
Closes #4274
What
packages/gittensory-miner/lib/event-ledger.jsis a generic append-only local ledger;manage-status.jsshows the established pattern for a typed event layered on top of it (MANAGE_PR_UPDATE_EVENT+ a normalizer + a thin writer). There was no equivalent for PR outcomes. This adds one — the miner's own local record of the outcomes of its own PRs, so a later self-improve pass can pair a prediction (the prediction-ledger, #4263) with its realized outcome. In laptop mode there may be no webhook relay at all, so this records outcomes locally rather than via the server-side hosted-D1 path.New
packages/gittensory-miner/lib/pr-outcome.js:MINER_PR_OUTCOME_EVENT("pr_outcome") +normalizePrOutcomePayload— a plain, JSON-round-trippable{ prNumber, decision, reason, closedAt }; returnsnullon missing/invalid required fields.recordPrOutcomeSnapshot(input, options)— a thin writer over the ledger with the same dependency-injection shape asrecordManagePollSnapshot, so it's unit-testable without a real ledger file. Aclosed-not-merged PR may carry oneREJECTION_REASONSreason bucket (rejection-templates.js), so this writer and the rejection-note renderer share one reason vocabulary.readPrOutcomes(eventLedger, filter)— the read-side reducer (mirroringindexLatestManageUpdates) that reconstructs the current outcome per repo/PR from the append-only event stream.This is deliberately the miner's local bookkeeping — distinct from the server-side
recordPrOutcome(src/review/outcomes-wire.ts), which writes hosted-D1 ground truth from the App's webhook stream. Same concept name, different codebase layer, no shared code; a distinct constant name (MINER_PR_OUTCOME_EVENT) and a README note make that explicit.Deliverables
pr-outcome.jswithMINER_PR_OUTCOME_EVENT+ payload normalizer, mirroringmanage-status.js.recordPrOutcomeSnapshot(input, options)thin writer (DI shape ofrecordManagePollSnapshot), reusingREJECTION_REASONSfor the closed-PR reason bucket.readPrOutcomes(eventLedger, filter)read-side reducer mirroringindexLatestManageUpdates.test/unit/miner-pr-outcome.test.ts— writer (merged + closed), normalizer validation, and the read-side reduction over a multi-event history.recordPrOutcome.Testing
5/5 tests pass; typecheck clean. (
packages/gittensory-miner/lib/**carries no coverage wall.)