feat(miner-manage): loop-closure summary builder (pre-reentry, read-only) (#4282) - #4378
Conversation
…nly) (JSONbored#4282) Add packages/gittensory-miner/lib/loop-closure.js exporting a pure, read-only buildLoopClosureSummary(sources, options): aggregate what happened in a completed discover->plan->prepare->manage cycle before the miner loop considers re-entering (idle -> discovering again). In the spirit of manage-status.js's collectManageStatus - it never calls GitHub, writes a store, or decides/performs the re-entry itself. The cycle boundary is caller-supplied: options.sinceSeq is the event-ledger seq at the end of the prior cycle, so events with a strictly greater seq are 'this cycle', reusing event-ledger.js's readEvents({ since }) cursor rather than inventing a new persisted boundary marker. The ledger stores an open type vocabulary, so events are tallied generically by type (new phase event types surface automatically). Output: per-type event counts + last seq (the next cycle's boundary), queue state by status at cycle end, and the current run-state. Adds the hand-written loop-closure.d.ts declaration alongside the module, matching the package's per-lib .d.ts convention. Deciding whether to re-enter, and the re-entry itself (setRunState), are explicitly out of scope. Closes JSONbored#4282
|
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 #4378 +/- ##
=======================================
Coverage 93.96% 93.96%
=======================================
Files 401 401
Lines 36869 36869
Branches 13480 13480
=======================================
Hits 34644 34644
Misses 1569 1569
Partials 656 656 🚀 New features to boost your workflow:
|
|
Tip 🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩 ✅ Gittensory review result - approve/merge recommendedReview updated: 2026-07-09 17:17:36 UTC
✅ Suggested Action - Approve/Merge
Review summary Nits — 5 non-blocking
Linked issue satisfactionPartially addressed 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
buildLoopClosureSummary(sources, options)inpackages/gittensory-miner/lib/loop-closure.js— a pure, read-only aggregator that summarizes a completeddiscover → plan → prepare → managecycle before the miner loop considers re-entering (idle → discoveringagain). In the spirit ofmanage-status.js'scollectManageStatus: it never calls GitHub, writes a local store, or decides/performs the re-entry itself.Design
options.sinceSeqis the event-ledger seq at the end of the prior cycle, so events with a strictly greater seq are "this cycle" — reusingevent-ledger.js's ownreadEvents({ since })cursor rather than inventing a new persisted boundary marker.type— new phase event types (plans built, PRs prepared/opened, outcomes recorded — landing via sibling issues) surface in the tally automatically without a hardcoded list here.lastSeq(the boundary a caller passes as the next cycle'ssinceSeq), queue state by status at cycle end, and the current run-state. Split data-collection from any rendering, mirroringmanage-status.js.setRunState).Adds the hand-written
loop-closure.d.tsalongside the module, matching the package's per-lib.d.tsconvention.Tests
test/unit/miner-loop-closure.test.ts: invalid-sources rejection, empty cycle, generic multi-type tally + last-seq, thesinceSeqboundary excluding prior-cycle events,unknownfallback for missing event/queue kinds + non-integer seq ignored, run-state present/absent, and determinism. Typecheck clean, 100% branch coverage on the new module.Closes #4282