Skip to content

feat(agent): scheduled re-gate sweep (#777) - #844

Merged
JSONbored merged 1 commit into
mainfrom
feat/agent-write-permission
Jun 17, 2026
Merged

feat(agent): scheduled re-gate sweep (#777)#844
JSONbored merged 1 commit into
mainfrom
feat/agent-write-permission

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

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 Gate verdict 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 hourly agent-regate-sweep fan-out job (top-of-hour tick), right next to the other hourly refreshes.
  • queue/processors.ts
    • fanOutAgentRegateSweepJobs — 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 (buildPullRequestAdvisoryevaluateGateCheck, the exact webhook path) for that repo's stalest open PRs and records an agent.sweep.regate audit event.
  • settings/agent-sweep.ts — pure selectRegateCandidates: drops drafts + PRs updated within the last hour (already gated by their webhook), takes the 25 stalest. Idempotent + rate-aware.
  • settings/autonomy.tsisAgentConfigured (any acting action class).

Safety (Phase-0 posture)

Scope

No new repo setting, migration, or config-as-code surface — reuses the autonomy / agentPaused / agentDryRun config 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.tsisAgentConfigured.
  • 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.

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).
@dosubot dosubot Bot added the size:L label Jun 17, 2026
@ghost

ghost commented Jun 17, 2026

Copy link
Copy Markdown

Note

Gittensory Gate skipped

PR closed before full evaluation. No late first comment was created.

Signal Result Evidence Action
Gate result ⚠️ Skipped #844 is no longer open. No action.

💰 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.

@ghost ghost added the gittensory:reviewed label Jun 17, 2026
@ghost

ghost commented Jun 17, 2026

Copy link
Copy Markdown

gittensory · advisory review

Reviewed 9 changed file(s) — two independent AI reviewers.

Changed files (9)
  • src/index.ts
  • src/queue/processors.ts
  • src/settings/agent-sweep.ts
  • src/settings/autonomy.ts
  • src/types.ts
  • test/unit/agent-sweep.test.ts
  • test/unit/autonomy.test.ts
  • test/unit/index.test.ts
  • test/unit/queue.test.ts

Suggested action:Safe to merge — both reviewers found no blocking issues.

Reviewer A · gpt-oss-120b — recommends ✅ merge
The PR introduces a scheduled re‑gate sweep for stale PRs, adding a new job type, helper functions, and comprehensive tests. The implementation respects existing pause mechanisms, stays advisory, and does not expose any forbidden public content.

Suggestions

  • Add a unit test covering the global pause (isGlobalAgentPause) to verify the sweep is denied when the whole system is paused.
  • Update the project documentation or changelog to mention the new agent-regate-sweep scheduled job.

Worth double-checking

  • Ensure the new job type is included in any job‑type validation or routing that may exist elsewhere in the codebase.
  • Confirm that resolveAgentActionMode correctly handles all pause/dry‑run combos in production.

Reviewer B · nemotron-3-120b-a12b — recommends ✅ merge
This PR implements a scheduled re-gate sweep feature (#777) that periodically recomputes advisory gate verdicts for stale open PRs in agent-configured repositories. The changes are well-structured, add comprehensive tests, respect the public/private boundary (advisory-only audit events), and follow existing patterns (e.g., mirroring signal-snapshot fan-out). The code is deterministic, includes safety checks (pauses, autonomy configuration), and avoids public-facing actions.

No blocking issues spotted.

@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@codecov

codecov Bot commented Jun 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.60%. Comparing base (6930213) to head (f2d2c5c).
⚠️ Report is 1 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JSONbored
JSONbored merged commit df4cd7f into main Jun 17, 2026
20 checks passed
@JSONbored
JSONbored deleted the feat/agent-write-permission branch June 17, 2026 22:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(agent): scheduling/cron for agent runs

1 participant