feat(agent): scheduled re-gate sweep (#777) - #844
Conversation
Complete Phase 0 (#768) with the scheduling rail. GitHub fires no per-PR event when a base branch advances (or a sibling duplicate merges, or the focus manifest / settings change), so an open PR's gate verdict can drift stale with nothing to refresh it. An hourly cron sweep recomputes those verdicts. - index.ts: hourly `agent-regate-sweep` fan-out job (the 30-min cron's top-of- hour tick). - processors.ts: fanOutAgentRegateSweepJobs enqueues one per-repo sweep for every repo with an acting autonomy level (isAgentConfigured); sweepRepoRegate recomputes the DETERMINISTIC gate verdict for that repo's stalest open PRs and records an `agent.sweep.regate` audit event. ADVISORY ONLY — nothing is published to GitHub and no PR is mutated; #778 turns flagged verdicts into actions later. Respects the #776 kill-switch: a global or per-repo pause records a skip and recomputes nothing. - settings/agent-sweep.ts: pure selectRegateCandidates — drops drafts + PRs fresh within the hour (already gated by their webhook), takes the 25 stalest. Idempotent + rate-aware. - settings/autonomy.ts: isAgentConfigured (any acting action class). No new repo setting, migration, or config-as-code surface — reuses the autonomy/agentPaused/agentDryRun config from #773/#774/#776. Tests: agent-sweep selection (incl. unparseable-now + caps), isAgentConfigured, and 5 processor cases (fan-out filtering, advisory recompute with flagged + clean verdicts, kill-switch skip, defensive no-ops, quiet-when-fresh). New code 100% covered; full suite green (2037).
|
Note Gittensory Gate skippedPR closed before full evaluation. No late first comment was created.
💰 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 · advisory review Reviewed 9 changed file(s) — two independent AI reviewers. Changed files (9)
Suggested action: ✅ Safe to merge — both reviewers found no blocking issues. Reviewer A · Suggestions
Worth double-checking
Reviewer B · No blocking issues spotted. |
|
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 #844 +/- ##
==========================================
+ Coverage 96.59% 96.60% +0.01%
==========================================
Files 100 101 +1
Lines 14244 14295 +51
Branches 5192 5208 +16
==========================================
+ Hits 13759 13810 +51
Misses 105 105
Partials 380 380 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Closes #777
What & why
This completes Phase 0 (#768) — the agent layer's deny-by-default trust scaffolding — with the scheduling rail.
GitHub fires no per-PR event when a base branch advances (and none when a sibling duplicate merges, or the focus manifest / repo settings change). So an open PR's
Gittensory Gateverdict can quietly go stale with nothing to refresh it. An hourly cron sweep recomputes those verdicts.How
index.ts— the existing 30-min cron enqueues an hourlyagent-regate-sweepfan-out job (top-of-hour tick), right next to the other hourly refreshes.queue/processors.tsfanOutAgentRegateSweepJobs— enqueues one per-repo sweep for every repo that opted the agent in (isAgentConfigured= at least one acting autonomy level). Mirrors the signal-snapshot fan-out so each repo's sweep is its own bounded, retryable queue message.sweepRepoRegate— recomputes the deterministic gate verdict (buildPullRequestAdvisory→evaluateGateCheck, the exact webhook path) for that repo's stalest open PRs and records anagent.sweep.regateaudit event.settings/agent-sweep.ts— pureselectRegateCandidates: drops drafts + PRs updated within the last hour (already gated by their webhook), takes the 25 stalest. Idempotent + rate-aware.settings/autonomy.ts—isAgentConfigured(any acting action class).Safety (Phase-0 posture)
AGENT_ACTIONS_PAUSED) or per-repo (agentPaused) pause records a skip and recomputes nothing.Scope
No new repo setting, migration, or config-as-code surface — reuses the
autonomy/agentPaused/agentDryRunconfig from #773/#774/#776.Tests
test/unit/agent-sweep.test.ts— candidate selection: freshness skip, stalest-first ordering + cap, missing-timestamp handling, draft/closed exclusion, deterministic tie-break, unparseable-now, defaults.test/unit/autonomy.test.ts—isAgentConfigured.test/unit/queue.test.ts— 5 processor cases: fan-out filtering (acting vs non-acting), advisory recompute with both a flagged (missing linked issue) and a clean verdict, kill-switch skip, defensive no-ops (missing repo arg / un-configured repo), and quiet-when-nothing-stale.New code 100% covered (statements + branches); full suite green (2037 passed).
With this merged, Phase 0 is complete (#773/#774/#775/#776/#777). Next is Phase 1 #778 — the real write-actions layer — which mutates live PRs and so will come with an explicit design + sign-off before any code.