fix(grokbot): make only the mirror slices durable, not the import source

Marking the whole provider durable also kept a removed usage import's rows,
so removing an import no longer restored the local figures. Durability is now
a per-source override (SessionSource.durable, which replaces the snapshot flag
from the Quick Desktop fix): Grok Bot's mirror slices merge, Quick Desktop's
sessions.db replaces, and orphan handling stays with the provider.
This commit is contained in:
Resham Joshi 2026-11-06 04:59:31 -08:00
parent e6c60b592d
commit d1b16169ac
4 changed files with 12 additions and 10 deletions

View file

@ -3982,7 +3982,7 @@ export async function parseProviderSources(
// Durable providers (e.g. copilot OTel) never clear existing entries so
// that pruned-away data is preserved for monotonic monthly totals.
const priorEntry = section.files[source.path]
if ((!provider.durableSources || source.snapshot) && !clearedPaths.has(source.path)) {
if (!(source.durable ?? provider.durableSources) && !clearedPaths.has(source.path)) {
delete section.files[source.path]
markCacheDirty(diskCache, providerName, source.path)
clearedPaths.add(source.path)
@ -4056,7 +4056,7 @@ export async function parseProviderSources(
// migrated cache with an anchor the virgin cache had - dropping the
// post-compaction residual (#946 validation round 6, see (c6)).
// Non-durable providers keep the original overwrite-or-append behaviour.
if (provider.durableSources && !source.snapshot) {
if (source.durable ?? provider.durableSources) {
const existingEntry = section.files[source.path]
if (existingEntry) {
const freshByKey = new Map(turns.flatMap(t => t.calls).map(c => [c.deduplicationKey, c]))

View file

@ -266,6 +266,9 @@ async function discoverSessions(dir: string): Promise<SessionSource[]> {
project: botName ?? agentId,
provider: 'grokbot',
sourceId: agentId,
// The mirror is a sliding window: requests that slid out of it stay
// cached, or the bot's history would shrink as it works.
durable: true,
...(botName ? { sourceLabel: botName, agentName: botName } : {}),
})
}
@ -280,9 +283,6 @@ export function createGrokbotProvider(persistenceDir?: string): Provider {
return {
name: 'grokbot',
displayName: 'Grok Bot',
// The mirror is a sliding window: requests that slide out of it are kept
// from the cache, or the bot's history would shrink as it works.
durableSources: true,
async probeRoots(): Promise<ProbeRoot[]> {
return [{ path: resolveDir(), label: 'client persistence' }]

View file

@ -176,7 +176,7 @@ async function discoverSources(): Promise<SessionSource[]> {
provider: 'quickdesk',
sourceId: 'sessions-db',
sourcePath: base.path,
snapshot: true,
durable: false,
})
}
}

View file

@ -23,10 +23,12 @@ export type SessionSource = {
// #992 that exemption is redundant (only ORPHANS age out) — kept as the
// explicit statement of intent, not as the thing enforcing it.
retainWhilePresent?: boolean
// This source is a projection of a store's current state, not a record, so
// a re-parse replaces its cached calls even under a durableSources provider
// (Quick Desktop's sessions.db estimates, superseded once metrics land).
snapshot?: boolean
// Overrides the provider's durableSources for how a re-parse lands in the
// cache: true merges into the cached calls (Grok Bot's sliding mirror keeps
// requests that slid out), false replaces them (Quick Desktop's sessions.db
// estimates are superseded once metrics land). Orphan handling still
// follows the provider.
durable?: boolean
}
// Thrown by a parser whose source is temporarily unreadable (a network fetch