Skip to content

fix(review): preserve branch protection in final CI rechecks - #3981

Merged
JSONbored merged 1 commit into
mainfrom
codex/fix-ci-recheck-branch-protection-handling
Jul 7, 2026
Merged

fix(review): preserve branch protection in final CI rechecks#3981
JSONbored merged 1 commit into
mainfrom
codex/fix-ci-recheck-branch-protection-handling

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Motivation

  • The final pre-mutation CI rechecks could drop branch-protection required contexts when expectedCiContexts was present, allowing a planner and an execution-time recheck to disagree on ciState and potentially merge despite a branch-protection-only pending check.
  • The goal is to ensure the executor and accept-time revalidation use the same effective required-context set the planner used (branch-protection ∪ expectedCiContexts) so branch-protection remains authoritative when readable.

Description

  • Thread an effective required-contexts field through the execution path by adding requiredCiContexts to the AgentActionExecutionContext and passing the planner-resolved requiredContexts into the executor call in src/queue/processors.ts instead of only settings.expectedCiContexts.
  • Make the executor (src/services/agent-action-executor.ts) use ctx.requiredCiContexts for its final live CI recheck so branch-protection-required contexts are preserved at actuation time.
  • Update the accept-time replay path (src/services/agent-approval-queue.ts) to re-fetch branch-protection required contexts and union them with settings.expectedCiContexts for both the accept-time CI read and the executor invocation, with a failure fallback to the configured expectedCiContexts behavior.
  • Add and adjust unit tests to cover threading requiredCiContexts into the executor, unioning branch-protection contexts at accept time, and fallback behavior when branch-protection reads fail (test/unit/agent-action-executor.test.ts, test/unit/agent-approval-queue.test.ts).

Testing

  • Ran targeted unit tests with Vitest: test/unit/agent-action-executor.test.ts and test/unit/agent-approval-queue.test.ts, including the new/updated cases for requiredCiContexts, branch-protection unioning, and branch-protection read failures, and they passed locally.
  • Ran the repo typecheck (tsc --noEmit) and git diff --check, both succeeded locally.
  • npm audit --audit-level=moderate could not be completed due to the registry audit endpoint returning 403 Forbidden in this environment (external registry error), blocking the local audit run.

Codex Task

@JSONbored JSONbored self-assigned this Jul 7, 2026
@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 7, 2026
@loopover-orb

loopover-orb Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Warning

🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨

⏸️ Gittensory review result - manual review recommended

Review updated: 2026-07-07 09:02:22 UTC

5 files · 1 AI reviewer · 2 blockers · readiness 93/100 · CI green · clean

⏸️ Suggested Action - Manual Review

  • No linked issue detected — If this PR is intended to solve an issue, link it explicitly in the PR body.
  • Maintainer requires a linked issue — Link the relevant issue (for example Closes #123) before opening the PR.

Review summary
This PR threads an effective required-CI-contexts set (branch-protection ∪ expectedCiContexts) through the executor and accept-time replay paths so the final pre-mutation CI recheck can no longer silently drop branch-protection-required contexts, which was the real bug. The executor and processors.ts wiring changes look correct and mechanical (rename expectedCiContexts→requiredCiContexts, pass a merged Set). The accept-time path in agent-approval-queue.ts is only partially hardened: the execution-context computation gets a `.catch()` fallback to `mergeRequiredCiContexts(null, settings.expectedCiContexts)`, but the accept-time disposition recheck's own `fetchRequiredStatusContexts(...).then(...).then(...)` chain (inside the `Promise.allSettled` array) has no equivalent `.catch`, contradicting the PR description's claim that the failure fallback applies to 'both the accept-time CI read and the executor invocation'.

Nits — 5 non-blocking
  • src/services/agent-approval-queue.ts: the accept-time recheck's `fetchRequiredStatusContexts(...).then(...).then(...)` chain inside the `Promise.allSettled` array (around the `shouldRecheckLiveDisposition ? ... : Promise.resolve(undefined)` ternary) has no `.catch`, unlike the later `executionRequiredContexts` computation — if branch-protection lookup fails here, that promise rejects into `ciResult` rather than falling back to `mergeRequiredCiContexts(null, settings.expectedCiContexts)` as the PR description claims for 'both' paths; confirm how a rejected `ciResult` is handled downstream and whether that matches the intended fail-open/fail-closed behavior.
  • test/unit/agent-approval-queue.test.ts: the 'falls back to expectedCiContexts when the accept-time branch-protection read fails' test only asserts `fetchLiveCiAggregate` was called with `Set(["build"])` somewhere, which the execution-time call (via the `.catch`-guarded `executionRequiredContexts`) already satisfies regardless of whether the accept-time recheck block's unguarded chain rejected — consider asserting on the accept-time `fetchLiveCiAggregate` call specifically (e.g. via call order or distinct headSha/args) to actually cover that path's failure behavior.
  • src/services/agent-approval-queue.ts: a fresh `createInstallationToken`/`fetchRequiredStatusContexts` call is issued for `executionRequiredContexts` in addition to the one already made for the accept-time recheck when `shouldRecheckLiveDisposition` is true — two branch-protection API calls per accept where one might suffice if the results are threaded through instead of refetched.
  • Add a `.catch(() => mergeRequiredCiContexts(null, settings.expectedCiContexts))` to the accept-time recheck's `fetchRequiredStatusContexts` chain in agent-approval-queue.ts for parity with the execution-context fallback and with the PR description.
  • Strengthen the 'falls back...' test to distinguish the accept-time `fetchLiveCiAggregate` call from the executor's own call so the fallback on that specific path is actually exercised.

Concerns raised — review before merging

  • No linked issue detected — If this PR is intended to solve an issue, link it explicitly in the PR body.
  • Maintainer requires a linked issue — Link the relevant issue (for example Closes #123) before opening the PR.
Signal Result Evidence
Code review ❌ 2 blockers 1 reviewer
Linked issue ⚠️ Missing No linked issue or no-issue rationale found.
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (no linked issue context).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 51 registered-repo PR(s), 43 merged, 569 issue(s).
Contributor context ✅ Confirmed Gittensor contributor JSONbored; Gittensor profile; 51 PR(s), 569 issue(s).
Gate result ❌ Blocking Repo-configured hard blocker found.
Review context
  • Author: JSONbored
  • Role context: owner (maintainer lane)
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: Python, TypeScript, JavaScript, Ruby, Go, Kotlin, MDX, Shell
  • Official Gittensor activity: 51 PR(s), 569 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Treat this as maintainer-lane context rather than normal contributor-lane activity.
  • Explain no-issue PR.
  • Link the issue being solved, or explicitly explain why this is a no-issue PR.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.

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

  • Re-run Gittensory review

@JSONbored
JSONbored force-pushed the codex/fix-ci-recheck-branch-protection-handling branch from 039df46 to b79cc0a Compare July 7, 2026 08:54
@superagent-security

Copy link
Copy Markdown
Contributor

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

@codecov

codecov Bot commented Jul 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.70%. Comparing base (61dac56) to head (b79cc0a).
⚠️ Report is 5 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3981   +/-   ##
=======================================
  Coverage   93.70%   93.70%           
=======================================
  Files         373      373           
  Lines       35076    35084    +8     
  Branches    12863    12864    +1     
=======================================
+ Hits        32868    32876    +8     
  Misses       1584     1584           
  Partials      624      624           
Files with missing lines Coverage Δ
src/queue/processors.ts 94.71% <ø> (ø)
src/services/agent-action-executor.ts 97.10% <100.00%> (+0.01%) ⬆️
src/services/agent-approval-queue.ts 99.17% <100.00%> (+0.05%) ⬆️
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@loopover-orb loopover-orb Bot added the manual-review Gittensor contributor context label Jul 7, 2026
@JSONbored
JSONbored merged commit 4a8ff4b into main Jul 7, 2026
10 checks passed
@JSONbored
JSONbored deleted the codex/fix-ci-recheck-branch-protection-handling branch July 7, 2026 09:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. manual-review Gittensor contributor context

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant