33 isOrchestrationV2WorkActive ,
44 type OrchestrationV2TurnItem ,
55 type PullRequestSummary ,
6+ PullRequestUnavailableError ,
67 type ThreadId ,
78 type ThreadPullRequestKey ,
89 type ThreadPullRequestLink ,
@@ -175,6 +176,7 @@ export function changeRequestsCreatedBy(input: string, output: string) {
175176}
176177
177178const isPullRequestProviderError = Schema . is ( PullRequestProviderError ) ;
179+ const isPullRequestUnavailableError = Schema . is ( PullRequestUnavailableError ) ;
178180
179181type SnapshotFields = Omit < ThreadPullRequestSnapshot , "syncedAt" > ;
180182
@@ -316,6 +318,11 @@ function rateLimitRetryAt(cause: Cause.Cause<unknown>): number | undefined {
316318 return undefined ;
317319}
318320
321+ function isProviderUnsupported ( cause : Cause . Cause < unknown > ) : boolean {
322+ const error = Cause . squash ( cause ) ;
323+ return isPullRequestUnavailableError ( error ) && error . reason === "provider-unsupported" ;
324+ }
325+
319326function isUnsettled ( thread : ProjectionStore . ProjectionThreadPullRequests ) : boolean {
320327 return thread . settledOverride !== "settled" && thread . settledAt === null ;
321328}
@@ -348,6 +355,8 @@ export const make = Effect.gen(function* () {
348355 const retryStacks = new Set < string > ( ) ;
349356 // Pause per project and host because credentials are project-specific; leave paused PRs due until reset.
350357 const pausedUntil = new Map < string , number > ( ) ;
358+ // Links whose host this server cannot browse; only sweeps wait, a requested refresh reads through.
359+ const unsupportedUntil = new Map < string , number > ( ) ;
351360
352361 const isDue = ( key : string , entries : ReadonlyArray < LinkEntry > , nowMs : number ) : boolean => {
353362 if ( requested . has ( key ) || retryStacks . has ( key ) ) return true ;
@@ -404,6 +413,7 @@ export const make = Effect.gen(function* () {
404413 for ( const key of lastSyncedAt . keys ( ) ) if ( ! groups . has ( key ) ) lastSyncedAt . delete ( key ) ;
405414 for ( const key of retryStacks ) if ( ! groups . has ( key ) ) retryStacks . delete ( key ) ;
406415 for ( const key of requested . keys ( ) ) if ( ! groups . has ( key ) ) requested . delete ( key ) ;
416+ for ( const key of unsupportedUntil . keys ( ) ) if ( ! groups . has ( key ) ) unsupportedUntil . delete ( key ) ;
407417
408418 const linkedThisSweep = new Set < string > ( ) ;
409419 // Fresh stack reads by group, so a member flagged by a sibling is compared against what the
@@ -582,12 +592,18 @@ export const make = Effect.gen(function* () {
582592 const skips = new Map < string , { count : number ; readonly key : string } > ( ) ;
583593 const readGroup = ( key : string , entries : ReadonlyArray < LinkEntry > , pauseKey : string ) =>
584594 syncGroup ( key , entries ) . pipe (
595+ Effect . tap ( ( ) => Effect . sync ( ( ) => unsupportedUntil . delete ( key ) ) ) ,
585596 Effect . catchCause ( ( cause ) => {
586597 if ( Cause . hasInterruptsOnly ( cause ) ) return Effect . failCause ( cause ) ;
587598 const retryAt = rateLimitRetryAt ( cause ) ;
588599 if ( retryAt !== undefined ) {
589600 pausedUntil . set ( pauseKey , Math . max ( retryAt , pausedUntil . get ( pauseKey ) ?? 0 ) ) ;
590601 }
602+ if ( isProviderUnsupported ( cause ) ) {
603+ unsupportedUntil . set ( key , nowMs + SLOW_SYNC_INTERVAL_MS ) ;
604+ // The refresh was answered; keeping it would bypass the pause on every sweep.
605+ requested . delete ( key ) ;
606+ }
591607 const reason = skipReason ( cause ) ;
592608 const skip = skips . get ( reason ) ;
593609 if ( skip === undefined ) skips . set ( reason , { count : 1 , key } ) ;
@@ -606,7 +622,8 @@ export const make = Effect.gen(function* () {
606622 // Check pauses at each read so changes during the sweep apply immediately.
607623 return Clock . currentTimeMillis . pipe (
608624 Effect . flatMap ( ( startedAtMs ) =>
609- ( pausedUntil . get ( pauseKey ) ?? 0 ) > startedAtMs
625+ ( pausedUntil . get ( pauseKey ) ?? 0 ) > startedAtMs ||
626+ ( ! requested . has ( key ) && ( unsupportedUntil . get ( key ) ?? 0 ) > startedAtMs )
610627 ? Effect . void
611628 : readGroup ( key , entries , pauseKey ) ,
612629 ) ,
0 commit comments