feat(skills): flat skill versioning + UCB1 adaptive-bandit routing (Phase 4)#24
Merged
Conversation
…g (Phase 4)
Per the proposed architecture: a skill keeps its full history in ONE directory
behind a flat manifest — no symlinks, no split-brain, identical on
Windows/macOS/Linux, no admin rights.
~/.qodex/skills/<id>/
manifest.json ← single source of truth (versions, champion/challenger, stats)
SKILL.v1.md SKILL.v2.md …
- src/skills/learning/skill-versioning.ts (PURE, unit-tested): the exact types
(VersionStats / VersionDetail / SkillManifest) + initManifest, createNextVersion
(adds a challenger, never touches other versions), routeSkillVersion (UCB1 —
explores an unsampled arm first, then balances exploit/explore, conservative on
ties), recordVersionExecution, and decideChampion (promote a clearly-better
challenger, RETIRE a worse one). Robustness over the sketch: next tag is max+1
(not count+1) and a retired version is KEPT in history (marked retired) so tags
never collide and its SKILL.v{N}.md stays referenced.
- src/skills/learning/versioned-store.ts (thin, atomic I/O): routedSkillBody
resolves the UCB1-routed version, FALLING BACK to legacy single-file SKILL.md so
nothing breaks; ensureVersioned / addChallenger / recordOutcomeAndConverge.
- CLI: `qodex skill versions <name>` — champion/challenger, per-version success
rate, tokens, and the routed pick.
Live-verified end-to-end: seeded v1, added a v2 challenger, fed the bandit a
strong champion + a weak challenger → it auto-RETIRED the bad challenger and kept
routing the champion. Tests: 14 (UCB1 explore/exploit, tag robustness after
retire, stat updates, promote/retire/keep-testing convergence). typecheck + full
suite (1212) + build green.
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.
Phase 4 of the proposed evolution architecture — flat, OS-agnostic skill versioning with UCB1 adaptive-bandit A/B routing.
Storage (no symlinks, no split-brain)
Identical on Windows/macOS/Linux, no admin rights. Legacy single-file
SKILL.mdskills keep working unchanged (routedSkillBodyfalls back).The algorithm (pure, tested)
src/skills/learning/skill-versioning.ts— the exact spec'd types + functions:routeSkillVersion— UCB1: an unsampled version is explored first; otherwise it balances exploit (champion) vs explore (challenger); a challenger whose success rate collapses loses traffic automatically. Conservative on ties.createNextVersion— adds a challenger (parent = champion) without touching any other version's state.recordVersionExecution/decideChampion— converge the test: promote a clearly-better challenger, retire a worse one.count+1), and a retired version is kept in history (markedretired) so tags never collide and its file stays referenced.I/O + CLI
versioned-store.ts(atomic manifest writes):routedSkillBody,ensureVersioned,addChallenger,recordOutcomeAndConverge.qodex skill versions <name>— shows champion/challenger, per-version success rate + tokens, and the routed pick.Live-verified
Seeded v1 → added a v2 challenger → fed the bandit a strong champion + weak challenger → it auto-retired the bad challenger and kept routing the champion.
Tests
14 (UCB1 explore/exploit, tag robustness after retire, stat updates, promote/retire/keep-testing). ✅ typecheck · ✅ full suite (1212) · ✅ build.