Skip to content

fix: remove L1 bootstrap snapshot cache to fix workspace file staleness#43901

Closed
mikejuyoon wants to merge 1 commit intoopenclaw:mainfrom
mikejuyoon:fix/remove-bootstrap-snapshot-cache
Closed

fix: remove L1 bootstrap snapshot cache to fix workspace file staleness#43901
mikejuyoon wants to merge 1 commit intoopenclaw:mainfrom
mikejuyoon:fix/remove-bootstrap-snapshot-cache

Conversation

@mikejuyoon
Copy link
Copy Markdown

@mikejuyoon mikejuyoon commented Mar 12, 2026

Summary

Removes the L1 bootstrap snapshot cache (bootstrap-cache.ts), which cached workspace files per session key with no invalidation. This caused workspace files modified after initial load — by other sessions, cron/heartbeat, sub-agents, or the agent itself — to remain permanently stale.

The L2 cache in workspace.ts already validates file identity (dev, inode, size, mtime) on every read and auto-invalidates on disk changes. The L1 cache sat on top and short-circuited L2 entirely, preventing it from ever detecting changes.

+7 / -215 lines. Pure deletion — no new code paths.

Symptoms this fixes

Why this is safe

L2 already handles caching correctly with mtime/inode validation. The "uncached" path (calling loadWorkspaceBootstrapFiles directly) is already exercised in production when sessionKey is absent. Performance impact is negligible: 7-9 stat calls on sub-KB markdown files per message, sub-millisecond total vs. seconds of LLM latency.

Fixes

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime commands Command implementations agents Agent runtime and tooling size: M labels Mar 12, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Mar 12, 2026

Greptile Summary

This PR removes the Level 1 bootstrap snapshot cache (bootstrap-cache.ts) that stored workspace bootstrap files (AGENTS.md, SOUL.md, TOOLS.md, etc.) per session key with no TTL or invalidation. The fix correctly delegates all caching to the Level 2 file-content cache in workspace.ts, which already validates file identity (dev:ino:size:mtimeMs) on every read and auto-invalidates when files change on disk.

Key changes:

  • Deleted src/agents/bootstrap-cache.ts and its test suite — the faulty Map<sessionKey, WorkspaceBootstrapFile[]> cache is gone entirely.
  • resolveBootstrapFilesForRun in bootstrap-files.ts now unconditionally calls loadWorkspaceBootstrapFiles(), while still passing sessionKey to filterBootstrapFilesForSession for correct subagent/cron file scoping.
  • All clearBootstrapSnapshot / clearBootstrapSnapshotOnSessionRollover call-sites are removed from session-reset-service.ts, auto-reply/reply/session.ts, commands/agent/session.ts, and cron/isolated-agent/session.ts.
  • Test files updated to remove stale mocks and assertions referencing the deleted module.

The PR is a net −215 lines and eliminates a class of bugs where workspace files edited on disk remained invisible to active sessions indefinitely.

Confidence Score: 5/5

  • This PR is safe to merge — it removes a defective cache with no replacement semantics lost, and all correctness is delegated to the already-correct L2 cache.
  • The change is a focused deletion of a problematic caching layer. The L2 cache in workspace.ts already handles caching correctly with mtime/inode validation. All callers go through resolveBootstrapFilesForRun, which is preserved. Session-scoped filtering via filterBootstrapFilesForSession is unaffected. Tests are correctly updated and the vi.clearAllMocks() substitution in the cron session tests is safe (it clears call history but preserves module-level vi.mock() implementations). No new logic is introduced — only dead code removed.
  • No files require special attention.

Last reviewed commit: 6e06b2d

@openclaw-barnacle
Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Apr 27, 2026
@clawsweeper
Copy link
Copy Markdown
Contributor

clawsweeper Bot commented Apr 27, 2026

Closing this as duplicate or superseded after Codex automated review.

This contributor PR identifies a real bootstrap-staleness bug, but it is now superseded by the newer maintainer-tracked #72406, which explicitly carries this work forward with credit and a narrower refresh-in-place implementation. Current main still has the stale session-keyed L1 cache, so this is not implemented-on-main yet; the correct path is to review/land #72406 or an equivalent maintainer-approved fix.

Best possible solution:

Close this older deletion-style PR as superseded, preserve credit to @mikejuyoon, and focus maintainer review on #72406 because it is the current maintainer-tracked implementation for refreshing long-lived session bootstrap snapshots without removing the cache outright.

What I checked:

So I’m closing this here and keeping the remaining discussion on the canonical linked item.

Codex Review notes: model gpt-5.5, reasoning high; reviewed against 91e835ebe0ab.

@clawsweeper clawsweeper Bot closed this Apr 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling commands Command implementations gateway Gateway runtime size: M stale Marked as stale due to inactivity

Projects

None yet

1 participant