mirror of
https://github.com/stablyai/orca.git
synced 2026-11-18 11:54:46 +00:00
* fix: separate chat option input from inventory observations * fix: preserve scoped chat choices and publication ownership * fix: complete scoped catalog and applied control ownership * test: make catalog fixture dependency boundaries explicit * test: request catalog discovery explicitly in demand contracts * fix(chat): preserve option observations and operation boundaries * fix(chat): finish pending option and catalog lifetimes * fix(chat): project saved permissions without launch preparation * fix(chat): correct option rejection and catalog retirement * Preserve Claude effort validation advice through chat rejection * test: align refresh mocks and preserve fixture type evidence * fix: share catalog claims only across equivalent owners * test: use typed catalog corpus instrumentation * fix: consolidate structured launch imports * Validate SDK queue regression envelopes without assertions * fix: complete catalog runtime and fixture type contracts * Align native option fixtures with explicit discovery and applied facts * Keep initial compatibility catalog reads on held memory * Complete the installed catalog fixture envelope * Observe learned defaults after asynchronous projection settles * Consolidate host fixture journal type imports * test(native-chat): align goal and seed fixtures with applied inputs * fix(codex): retain applied proof when goal settings skip a write * test: load rejection wording before timed queue regression * Fix catalog fixtures and queued option snapshot typing * Align permission publication fixture with passive option reads * Separate startup config from held turn permission fixture * Align input lifecycle fixtures with sparse applied choices * Simplify scoped catalog refresh ownership and coalesce cache snapshots * Load catalog persistence real-module fixture during collection * Compose catalog availability fixtures from valid session records * Align catalog and startup fixtures with current option contracts * Fix permission read types and separate catalog fixture preparation * Align option and restart fixtures with current lifecycle owners * test(mobile): retain reported model alongside discovery * test(mobile): recalibrate the measured route script envelope * test: let the preflight shell-capture mock run its detection callback
72 lines
2.2 KiB
TypeScript
72 lines
2.2 KiB
TypeScript
import type { ResolvedWorktree } from './runtime-worktree-path-identity'
|
|
|
|
export type ResolvedWorktreeSnapshot = {
|
|
worktrees: ResolvedWorktree[]
|
|
platformByRepoId: ReadonlyMap<string, NodeJS.Platform>
|
|
}
|
|
|
|
type ResolvedCache = ResolvedWorktreeSnapshot & { expiresAt: number; inventoryRevision: number }
|
|
type ResolvedInFlight = {
|
|
generation: number
|
|
inventoryRevision: number
|
|
promise: Promise<ResolvedWorktreeSnapshot>
|
|
}
|
|
export class RuntimeResolvedWorktreeCache {
|
|
private resolved: ResolvedCache | null = null
|
|
private resolvedInFlight: ResolvedInFlight | null = null
|
|
private resolvedGeneration = 0
|
|
|
|
get generation(): number {
|
|
return this.resolvedGeneration
|
|
}
|
|
|
|
peek(): ResolvedCache | null {
|
|
return this.resolved
|
|
}
|
|
|
|
/** Revision invalidates catalogs missing newly registered repos; TTL alone could wrongly report remote worktrees absent. */
|
|
isFresh(inventoryRevision: number, now = Date.now()): boolean {
|
|
return Boolean(
|
|
this.resolved &&
|
|
this.resolved.inventoryRevision === inventoryRevision &&
|
|
this.resolved.expiresAt > now
|
|
)
|
|
}
|
|
|
|
async getSnapshot(
|
|
compute: () => Promise<ResolvedWorktreeSnapshot>,
|
|
ttlMs: number,
|
|
inventoryRevision: number
|
|
): Promise<ResolvedWorktreeSnapshot> {
|
|
if (this.resolved && this.isFresh(inventoryRevision)) {
|
|
return this.resolved
|
|
}
|
|
const generation = this.resolvedGeneration
|
|
if (
|
|
this.resolvedInFlight?.generation === generation &&
|
|
this.resolvedInFlight.inventoryRevision === inventoryRevision
|
|
) {
|
|
return this.resolvedInFlight.promise
|
|
}
|
|
const promise = compute()
|
|
this.resolvedInFlight = { generation, inventoryRevision, promise }
|
|
try {
|
|
const result = await promise
|
|
if (generation === this.resolvedGeneration) {
|
|
// Start TTL on completion or slow computation publishes already-expired entries.
|
|
this.resolved = { ...result, inventoryRevision, expiresAt: Date.now() + ttlMs }
|
|
}
|
|
return result
|
|
} finally {
|
|
if (this.resolvedInFlight?.promise === promise) {
|
|
this.resolvedInFlight = null
|
|
}
|
|
}
|
|
}
|
|
|
|
invalidateResolved(): void {
|
|
this.resolvedGeneration += 1
|
|
this.resolved = null
|
|
}
|
|
}
|