Repository navigation
feat(core): live skills in the V2 session core — watcher-driven cache invalidation (#1740, partial) - #1852
Draft
aarontrowbridge wants to merge 4 commits into
Draft
feat(core): live skills in the V2 session core — watcher-driven cache invalidation (#1740, partial)#1852aarontrowbridge wants to merge 4 commits into
aarontrowbridge wants to merge 4 commits into
Conversation
The per-Location skill parse cache invalidates on filesystem watch events: the consumer subscribes to the existing Location-scoped watcher's bus events, marks changed files immediately, and flushes debounced (50ms) — dropping the cache entry of every source whose directories contain a changed file so the next list() re-globs it. Reloads stay lazy and coalesced; a consumer failure logs and degrades to the boot-frozen behavior. Tests cover invalidation, add/unlink of skill directories, burst coalescing, disposal, the fail-safe floor, and delivery through the SystemContext + SessionContextEpoch machinery (ContextUpdated event on a real db session).
The skill tool serves the SKILL.md body from disk at invocation time via a new SkillTool.liveContent seam, matching its fresh companion-file glob — the parse cache only pins name/description metadata between watcher invalidations. A failed read falls back to the cached body, never a tool failure.
The v1/TUI skill cache stays deliberately boot-frozen — InstanceState loads once per directory and never re-reads. Live watcher-driven invalidation ships in the V2 session core only; document that boundary honestly at the code site so no silent parity is claimed.
The debounced flush lands asynchronously; poll the observable outcome with a 5s bound instead of fixed 200ms sleeps so the tests stay green under a loaded shared bun process. The reload is lazy, so the polls drive list() — a fixed sleep never observes the re-glob on its own.
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Part of #1740.
What it does
core/src/skill.ts(V2): subscribes toWatcher.Event.Updatedon the EventV2 bus. Changed files are marked immediately, and a 50ms-debounced flush drops the cache entry of every source whose directories contain a changed file, so the nextlist()re-globs it.core/src/tool/skill.ts(V2): the skill body is re-read from disk on each invocation. If the read fails, it falls back to the cached body.opencode/src/skill/index.ts(V1): a comment documenting that this path stays boot-frozen.Why it's a draft: it doesn't reach the fleet yet
The fleet's sessions run on the V1 path.
opencode/src/tool/skill.tsandsession/system.tsimport the V1Skillservice, which loads once per instance and is never re-read. So this PR does not make skill edits visible to running hub sessions, which is #1740's motivating problem (every skill fix needs a hub restart). To close #1740, the V1Skilldiscovered/stateInstanceStates need the same invalidation, either from watcher events under the discovered skill dirs or from a cheap fingerprint check like #1850'sauth.jsonstamp.Tests
core/test/skill.test.ts+core/test/tool-skill.test.ts: 12/0 on a fresh materialize at current main.