PR4 v0.4.0 - FileMemory adapter unblocks the learning loop - #4
Open
bettercallzaal wants to merge 1 commit into
Open
PR4 v0.4.0 - FileMemory adapter unblocks the learning loop#4bettercallzaal wants to merge 1 commit into
bettercallzaal wants to merge 1 commit into
Conversation
PR1-3 had a Learner wrapper, a MemoryAdapter interface, and a
hermes-bug-fix pattern that few-shot injects retrieved hits into its
systemPrompt - but the only adapter (BonfireMemory) returns [] until
Bonfire admin labeling unlocks. The loop was wired but dormant.
PR4 adds FileMemory: a local JSONL-backed MemoryAdapter. Each
OrchestratorEvent is one line. retrieve() joins classified+completed
events by taskId, filters to the requested pattern, returns recency-
sorted MemoryHits. No embeddings, no network - just append + read.
End-to-end loop now provable:
- Run 1: orchestrate('fix type error in foo.ts') -> FileMemory records
classified + spawned + completed events -> file gets a row.
- Run 2: orchestrate('fix type error in bar.ts') -> learner.retrieve
finds run 1 -> hermesBugFix.prepare injects:
"Past similar tasks (most relevant first):
1. Past task: fix type error in foo.ts
Outcome: changed foo.ts:42 from string to number..."
into the systemPrompt of the second Hermes session.
This is also the obvious default adapter for self-hosters who don't want
to depend on Bonfires for the v1 case.
What ships:
- src/adapters/file-memory.ts - JSONL append + per-task join + recency sort
- src/index.ts + package.json exports - FileMemory + ./adapters/file-memory
- tests/file-memory.test.ts - 5 unit tests (missing file, JSONL format,
retrieve by pattern, limit, malformed lines)
- tests/learning-loop.test.ts - 2 integration tests proving run 2 sees
run 1's outcome in its systemPrompt
- Bumped to 0.4.0
BonfireMemory remains shipped + supported - FileMemory is the default
for self-hosters, Bonfire is the default for graph-backed setups.
Known limits (PR5+):
- No similarity ranking yet - retrieve is recency + pattern filter only.
When Bonfire labeling unlocks, BonfireMemory uses vector search and
this becomes a non-issue. PR5 may add naive keyword overlap to
FileMemory as a midpoint.
- Adaptive supervisor (drop loopThreshold to 2 if past runs of this
pattern looped) lands in PR5 - the data is already being recorded.
Tests: 33/33 pass.
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.
What this PR teaches
PR1-3 wired the learner end to end - Learner wrapper, MemoryAdapter interface, hermes-bug-fix few-shot injection - but the only shipped adapter (BonfireMemory) returns
[]until the Bonfire admin labeling step unlocks. The loop was wired but dormant.PR4 adds FileMemory: a local JSONL-backed MemoryAdapter. Each
OrchestratorEventis one line.retrieve()joinsclassified+completedevents bytaskId, filters to the requested pattern, returns recency-sorted MemoryHits. No embeddings, no network - just append + read.End-to-end loop now provable
This is the PR where you can actually demonstrate the learning behaviour without depending on Bonfires.
Run 1:
orchestrate('fix the type error in foo.ts')-> FileMemory recordsclassified+spawned+completedevents.Run 2:
orchestrate('fix the type error in bar.ts')->learner.retrievereturns run 1 ->hermesBugFix.prepareinjects this block into the systemPrompt of the second Hermes session:The
tests/learning-loop.test.tsintegration test runs this and asserts the second session'ssystemPromptcontains the actual outcome text from the first.What ships
src/adapters/file-memory.tsENOENTgraceful first-runsrc/index.ts+package.jsonexportsFileMemory+ adds./adapters/file-memorysubpathtests/file-memory.test.tstests/learning-loop.test.tsAdapter matrix (after PR4)
FileMemoryBonfireMemory[]until Bonfire admin labeling unlocks)Both implement the same
MemoryAdapterinterface. Swap them by changing one line of orchestrator wiring.Verification
Limits left for later PRs
loopThresholdto 2 for patterns that historically loop is recorded today; PR5 wires the supervisor to read it.Lands on merge
v0.4.0after PR3 -> PR4 cascadeFileMemorybecomes the documented default for self-hosters🤖 Generated with Claude Code