fix(briefing): invalidate cached briefing on workspace data change#237
Draft
Ovaculos wants to merge 2 commits into
Draft
fix(briefing): invalidate cached briefing on workspace data change#237Ovaculos wants to merge 2 commits into
Ovaculos wants to merge 2 commits into
Conversation
The briefing cache was purely TTL-based, so adding entities to bundle apps (todos, CRM rows, notes) left the home dashboard showing the pre-update briefing for up to the full TTL window. Invalidate by content fingerprint instead. `computeBriefingFingerprint` signatures the data a briefing is built from — activity logs and each running bundle's entity data (file count, newest mtime, total size) — and `BriefingCache.get()` serves a stored briefing only while that fingerprint still matches. A fingerprint is vector-agnostic: any path that mutates the underlying files (agent, iframe widget, external MCP client, bundle install) is caught, with no read/write guessing and no SSE-driven refresh loop. Facets sourced from live MCP resource/tool calls rather than entity files are not fingerprinted and still fall back to the TTL; this is documented on `computeBriefingFingerprint`. Refs NimbleBrainInc#225. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
dirSignature used statSync, which follows symlinks and throws ENOENT on a dangling link — crashing computeBriefingFingerprint and erroring the briefing tool. Switch to lstatSync (never follows, never throws on a dangling link, counts a symlink as a leaf) and skip entries that vanish between readdir and lstat (concurrent entity-file delete). Refs NimbleBrainInc#225. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The home-dashboard briefing cache was purely TTL-based — adding entities to bundle apps (todos, CRM rows, notes) left the dashboard showing the pre-update briefing for up to the full TTL window. Closes #225.
Invalidation is now content-based.
computeBriefingFingerprintsignatures the data a briefing is built from — activity logs and each running bundle's entity data (file count, newest mtime, total size) — andBriefingCache.get()serves a stored briefing only while that fingerprint still matches.Why a fingerprint, not events
#225 suggested subscribing to
data.changed. Event-based invalidation doesn't work here:data.changedfrom/mcploops — the iframe widget bridge calls tools over/mcp, so a broadcast triggers auseDataSyncrefresh, which is another/mcpcall, which broadcasts again.A tool call can't distinguish a read from a write. A content fingerprint invalidates if and only if the underlying data actually changed — no heuristic, no event plumbing.
Coverage
The fingerprint watches data, not the write path, so it is vector-agnostic — agent, iframe widget, external MCP client, and bundle install are all caught. Coverage is by data source:
entityDataRoot) — the issue's core case{wsDir}/logs)resource/toolcalls instead of entity files are not fingerprinted; they fall back to the TTL. Documented oncomputeBriefingFingerprint.dirSignatureuseslstatSync(a dangling symlink is sized, not thrown) and skips entries that vanish mid-walk, so a concurrently-mutating tree cannot crash a briefing.Context
#225 was surfaced during testing of #219 (now merged); this completes the cache-invalidation design that #219 deferred.
Test plan
bun run verify— static, unit, web, integration greenbriefing-cacheunit tests: fingerprint matching +computeBriefingFingerprint(file add/edit, entity data, non-running exclusion, missing dirs, symlinks)🤖 Generated with Claude Code