Skip to content

feat(route): add PR-level provider stickiness with grace fallback - #49

Merged
cgl-agent-coordinator[bot] merged 1 commit into
mainfrom
feat/pr-provider-stickiness
Dec 5, 2026
Merged

cgl-agent-coordinator[bot] merged 1 commit into
mainfrom
feat/pr-provider-stickiness

Conversation

@Pigbibi

@Pigbibi Pigbibi commented Dec 4, 2026

Copy link
Copy Markdown
Collaborator

AI assistance

  • Model / agent: Antigravity (planning + implementation); verified locally with full unit test suite.

What changed

  • Added optional stickyProvider support to planApiReviewer() in packages/review-core/route.mjs: for single-provider PRs with a prior trusted review (previousReview.provider), the sticky provider runs immediately even when configured as fallback, while a non-sticky provider waits graceMinutes (waiting_for_sticky_provider) before taking over (fallback_after_sticky_grace).
  • Moved findPreviousReview() before planApiReviewer() in adapters/cloudflare-workflow/worker.mjs and forwarded stickyProvider: previousReview?.provider ?? null.
  • Added unit tests in tests/review-core.test.mjs covering sticky fallback execution, non-sticky wait, grace-period takeover, and forceProvider override.

How verified

  • node --test tests/*.test.mjs: 84 passed, 0 failed.
  • /usr/local/bin/gitleaks git --config /Users/lisiyi/.gemini/antigravity/scratch/governance-p0/PrGovernance/pr-governance/.gitleaks.toml --log-opts="origin/main..HEAD" --redact: no leaks found.

Why

  • Eliminates model oscillation during incremental re-reviews (e.g., after resolving base-outdated on a PR already cleared by one provider) while keeping fallback availability intact if the sticky provider stalls past grace.

Risk

  • Low (packages/review-core/route.mjs, adapters/cloudflare-workflow/worker.mjs, tests/review-core.test.mjs): applies only when stickyProvider is supplied and requiredProviders < 2 && existing.size === 0 && !forceProvider.

Co-authored-by: Antigravity <noreply@google.com>
@cgl-opencode-reviewer

Copy link
Copy Markdown

AI Code Review (opencode / glm-5.4+kimi-k3.1-pro)

[glm-5.4] The PR adds PR-level provider stickiness to planApiReviewer() (pure, boundary-clean, default-off via stickyProvider=null) and moves findPreviousReview() earlier in the Cloudflare worker to feed it. The core function is unit-tested and no security/credential issues were found. Main concern: the new wait path now applies to primary-role providers, but escaping the wait depends entirely on the pre-existing, fallback-named waitedForFallback flag, and the diff shows no orchestration change or test proving the retry wiring sets that flag for non-fallback roles; if it does not, a non-sticky primary can re-wait indefinitely whenever the sticky provider fails to publish. Secondary concerns are edge-case behavior when the sticky provider is no longer enabled, minor duplication of the grace pattern, a misleading reason string, and missing negative tests. [kimi-k3.1-pro] No concrete correctness, security, architecture, or critical test issues found in the supplied diff. Sticky routing is limited to empty single-provider quorum state, preserves forced-provider behavior and grace-period takeover, and includes focused unit coverage.

Reviewed commit: b37c1ad1be · Coverage: complete · Unresolved findings: true

Findings

  • [MEDIUM] adapters/cloudflare-workflow/worker.mjs: The new 'waiting_for_sticky_provider' wait is returned for primary-role providers (a role that previously never waited), and the only escape is waitedForFallback=true. That flag pre-existed specifically for the fallback-grace path, and the diff shows no orchestration change or test demonstrating that the workflow's sleep-and-retry loop sets waitedForFallback=true when retrying a non-fallback role (or that it does not match on the old waiting-for-fallback reason string). If the retry wiring is fallback-specific, a non-sticky primary re-enters the grace wait on every retry and the review stalls indefinitely whenever the sticky provider fails to publish a review. Add a worker-level test or otherwise verify/show the retry wiring for the primary role.
  • [LOW] adapters/cloudflare-workflow/worker.mjs: stickyProvider is forwarded straight from previousReview?.provider without checking that this provider is still enabled/executable in the current run (e.g., disabled subscription, missing credentials in this environment). In that case every incremental re-review incurs the full grace delay before takeover, and after grace both non-sticky providers can return run:true and publish redundant duplicate reviews. Consider filtering the sticky provider against the currently enabled provider set before passing it.
  • [LOW] packages/review-core/route.mjs: The new sticky block duplicates the waitedForFallback-takeover / parseGraceMinutes-wait pattern of the fallback-grace block immediately below it (~10 lines of parallel structure). Consider extracting a small shared grace-decision helper so the two paths cannot drift apart.
  • [LOW] packages/review-core/route.mjs: Reason 'fallback_after_sticky_grace' is returned even when role is 'primary' (as the new test itself asserts), which is misleading in logs/metrics/dashboards that key off reason strings; a role-neutral name like 'takeover_after_sticky_grace' would be clearer.
  • [LOW] tests/review-core.test.mjs: Missing negative coverage for the sticky branch: stickyProvider is ignored when requiredProviders >= 2, when quorum is already satisfied (existing.size > 0), and the immediate-takeover path when graceMinutes resolves to 0. These guard the exact conditions the PR description claims as its risk boundary.

@cgl-agent-coordinator

Copy link
Copy Markdown
Contributor

@Pigbibi needs a human: merging this repository deploys; owner approval needed.

@cgl-agent-coordinator

Copy link
Copy Markdown
Contributor

Autoland: escalated to the owner: merging this repository deploys; owner approval needed

@cgl-agent-coordinator

Copy link
Copy Markdown
Contributor

@Pigbibi needs a human: merging this repository deploys; owner approval needed.

@cgl-agent-coordinator

Copy link
Copy Markdown
Contributor

Autoland: escalated to the owner: merging this repository deploys; owner approval needed

@cgl-agent-coordinator

Copy link
Copy Markdown
Contributor

@Pigbibi needs a human: merging this repository deploys; owner approval needed.

@cgl-agent-coordinator

Copy link
Copy Markdown
Contributor

Autoland: escalated to the owner: merging this repository deploys; owner approval needed

@cgl-agent-coordinator
cgl-agent-coordinator Bot merged commit dfad97b into main Dec 5, 2026
14 checks passed
@cgl-agent-coordinator
cgl-agent-coordinator Bot deleted the feat/pr-provider-stickiness branch December 5, 2026 00:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant