mirror of
https://github.com/stablyai/orca.git
synced 2026-11-16 19:07:41 +00:00
perf(github): share automatic PR reads and reuse the host budget (#42033)
* perf(github): share and pace timed pull request reads on the host
Reuse exact completed results for automatic refreshes, back off unchanged
settled pull requests, and route server revalidation through the existing
host budget while preserving foreground reads and older clients.
Co-authored-by: Jinjing <6427696+AmethystLiang@users.noreply.github.com>
* fix(github): preserve shared producer settlement and selected demand
Co-authored-by: Jinjing <6427696+AmethystLiang@users.noreply.github.com>
* test(github): cover paired receipt retries and watch fairness
* test(github): explain shared fake-clock fixture
* test(github): typecheck host and renderer integration together
* test(github): name exported fixture mock types
* Revert "test(github): typecheck host and renderer integration together"
This reverts commit 756a38787c.
* test(github): place host and renderer loops in cross-layer suite
* fix(github): preserve refresh policy and shared callers
Use the same validated freshness for cached queue reads and their follow-up. Keep forced mergeability rereads and detach cancelled consumers independently from the shared lookup.
Co-authored-by: Jinjing <6427696+AmethystLiang@users.noreply.github.com>
* fix(github): refresh settled rows when exposed again
Use the same finite foreground age to admit and consume the queued read. A recent exact result can still satisfy it, and settled rows do not acquire a recurring timer.
Co-authored-by: Jinjing <6427696+AmethystLiang@users.noreply.github.com>
* fix(github): accept only current PR read completions
Keep shared publication and retry planning on the accepted actual read. Preserve legacy own replies, terminal loading and ordinary work after a superseded lookup, and honor the accepted error gate before automatic recovery.
Co-authored-by: Jinjing <6427696+AmethystLiang@users.noreply.github.com>
* test(github): follow moved request contracts
* test(github): explain the partial event fixture type assertion
* fix(github): preserve queued deadlines and detachable PR waits
* fix(github): compare refresh wakes on the elapsed clock
* test(github): format queued refresh deadline cases
* fix(github): charge actual producers and fence retry gates
* fix(github): preserve fresh intent and producer error policy
* fix(github): retain owned cold-read retry gates
---------
Co-authored-by: Jinjing <6427696+AmethystLiang@users.noreply.github.com>
This commit is contained in:
co-authored by
Jinjing
parent
bff57f1e37
commit
a36620afd0
@@ -0,0 +1,22 @@
|
||||
import type { PRInfo } from '../pull-request-types'
|
||||
|
||||
export const QUIET_PR_REFRESH_INTERVAL_MS = 5 * 60_000
|
||||
|
||||
export function prChecksDone(pr: PRInfo): boolean {
|
||||
return (
|
||||
pr.checksFinal === true || (pr.checksReadComplete === true && pr.checksSummary?.total === 0)
|
||||
)
|
||||
}
|
||||
|
||||
export function isQuietPR(pr: PRInfo, currentHeadOid: string | null): boolean {
|
||||
return (
|
||||
(pr.state === 'open' || pr.state === 'draft') &&
|
||||
!!currentHeadOid &&
|
||||
pr.headSha === currentHeadOid &&
|
||||
pr.checksReadComplete === true &&
|
||||
prChecksDone(pr) &&
|
||||
(pr.mergeable === 'MERGEABLE' || pr.mergeable === 'CONFLICTING') &&
|
||||
pr.autoMergeEnabled === false &&
|
||||
pr.mergeQueueRequired === false
|
||||
)
|
||||
}
|
||||
@@ -12,7 +12,7 @@ export type PRRefreshErrorType =
|
||||
| 'server_error'
|
||||
| 'unknown'
|
||||
|
||||
export type PRRefreshOutcome =
|
||||
export type PRRefreshOutcome = (
|
||||
| { kind: 'found'; pr: PRInfo; fetchedAt: number }
|
||||
| { kind: 'no-pr'; fetchedAt: number; rejectedPRUrls?: string[] }
|
||||
| {
|
||||
@@ -24,6 +24,27 @@ export type PRRefreshOutcome =
|
||||
nextAutoRetryAt?: number
|
||||
retryDisabledUntil?: number
|
||||
}
|
||||
) & { revalidation?: { retryAfterMs: number } }
|
||||
|
||||
export type PRRevalidationOnly = { revalidation: { invalidated: true; retryAfterMs: number } }
|
||||
export type PRSnapshotReply = PRRefreshOutcome | PRRevalidationOnly
|
||||
|
||||
export function isPRRevalidationOnly(value: unknown): value is PRRevalidationOnly {
|
||||
if (!value || typeof value !== 'object' || 'kind' in value || !('revalidation' in value)) {
|
||||
return false
|
||||
}
|
||||
const receipt = value.revalidation
|
||||
return (
|
||||
!!receipt &&
|
||||
typeof receipt === 'object' &&
|
||||
'invalidated' in receipt &&
|
||||
receipt.invalidated === true &&
|
||||
'retryAfterMs' in receipt &&
|
||||
typeof receipt.retryAfterMs === 'number' &&
|
||||
Number.isFinite(receipt.retryAfterMs) &&
|
||||
receipt.retryAfterMs >= 0
|
||||
)
|
||||
}
|
||||
|
||||
/** `watch` is host-only: a background read for a chat's CI lines, never sent by a client. */
|
||||
export type GitHubPRRefreshReason = 'visible' | 'active' | 'post-push' | 'manual' | 'swr' | 'watch'
|
||||
|
||||
Reference in New Issue
Block a user