fix(v0.5.1): round 3 follow-up — fallback_on_error + Import restore + events absolute path#22
Merged
Merged
Conversation
NewEventWriter now rejects relative paths up front with a clear error pointing the caller at the monorepo root resolution path. Two worktrees (or a CI step + a dev shell) used to race on a cwd-relative .bough/memory/events.jsonl when one ran from the monorepo root and the other from a worktree subdirectory. docs/INSTINCTS.md gains an Audit log section documenting the absolute-path contract and the default location.
…#15 + #17) MEDIUM #15: coordinator.Query now consumes instinct.fallback_on_error. On a primary backend error with the flag set and a fallback backend wired in, the same QueryReq is replayed against the fallback and a query_fallback audit event is emitted. v0.5 ships only SQLite so callers pass nil for fallback (= no-op pass-through); v0.6 wires mem0 + SQLite together and the flag starts mattering. MEDIUM #17: sqlite.Import used to walk the YAML / JSONL payload and increment counters without ever re-Storing the rows, so an Import after Forget left the table empty. The new parseExportedYAML / parseExportedJSONL helpers reconstruct memapi.Instinct records and route each through the same Store path the host uses for fresh ingest (UpsertSemantics=true). The CLI reports imported / upserted / skipped so an operator can confirm the round-trip. LOW #18 follow-on: loadInstinctCoordinator anchors the default .bough/memory/events.jsonl against the monorepo root the loadConfigAndRoot helper resolves. Combined with the NewEventWriter absolute-path requirement landed in the previous commit, the CLI now writes to the same file regardless of cwd. instinct.New takes a fourth parameter (fallback) — the package is internal so callers outside the repo are not expected; v0.5.1 stays a drop-in upgrade for plugin authors and end users.
CHANGELOG documents the three follow-up fixes and notes that v0.5.0 -> v0.5.1 is a drop-in upgrade (MemoryBackend interface, schema, and plugin binaries all unchanged). sqlite_regression_test.go adds two round-trip tests (TestImport_RestoresRows_YAML / TestImport_RestoresRows_JSONL) that seed a row, Export, Forget it to be sure, Import, and verify the row is queryable again — the assertion the old conformance test (which only checked ImportedCount > 0) failed to catch.
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
v0.5.0 の round 3 review で残った 3 follow-up を集約。 v0.5 plugin contract / SQLite schema 不変、 drop-in upgrade。
instinct.fallback_on_errorをcoordinator.Queryで consume (= primary error → fallback backend に replay +query_fallbackaudit event)。 v0.5 は SQLite 単独なので caller は nil 渡しで no-op、 v0.6 mem0 + SQLite で active 化される枠組み + sketch。sqlite.Importが YAML/JSONL row を proper parse +Store再投入 (= 旧 count のみで Forget 後の row が復元されなかった)。 CLI がimported/upserted/skippedを出力。events.jsonlの相対 path をNewEventWriterで reject、loadInstinctCoordinatorで monorepo root anchor。 cwd race を防ぐ。internal/instinct.Newが 4 引数化 (= fallback backend optional)。 internal package なので外部 caller への影響なし。Test plan
go test ./...全 green (= unit + conformance memory + sqlite + cli + instinct)golangci-lint run0 issuessqlite_regression_test.goround-trip YAML/JSONL = Forget → Import で row 復元 assertcoordinator_fallback_test.go4 path (= recovers / disabled / nil fallback / both fail)events_test.go3 case (= relative reject / empty reject / absolute success)Refs: v0.5.0 round 3 review (= #21、 https://github.com/ikeikeikeike/bough/releases/tag/v0.5.0 で ship 済)