Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/changes/unreleased/1823-quirks-restart-fixtures.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
kind: internal
title: provider restart fixtures drain learned-memo writers before resetting memory
pr: 1823
surface: [build]
invalidates:
- "The restart fixtures forced a synchronous save but left a scheduled save running while they discarded process memory. They now drain the owned writer before resetting memory and reloading the memo, preserving the original startup and request-count assertions."
---
11 changes: 10 additions & 1 deletion internal/provider/quirks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,14 @@ func TestLearnedQuirksSurviveTheProcessThatLearnedThem(t *testing.T) {
t.Fatalf("memo = %s, want the model that refused", raw)
}

// A fresh process reads it and never sends the refused shape at all.
// A fresh process reads it and never sends the refused shape at all. The
// synchronous save above does not join the separately scheduled writer;
// drain that writer before discarding the old process's memory, or it can
// overwrite the verified file with the deliberately emptied map.
quirks.settle()
quirks.mutex.Lock()
quirks.mandatory = map[string]time.Time{}
quirks.mutex.Unlock()
LoadQuirks(dir)
if !ReasoningMandatory("strict/persisted") {
t.Fatal("a memo on disk must be believed at startup")
Expand Down Expand Up @@ -176,6 +182,9 @@ func TestASilentlyIgnoredDisableSurvivesTheProcessThatLearnedIt(t *testing.T) {
t.Fatalf("memo = %s, want the model that ignored the disable", raw)
}

// The old process's scheduled save must finish before its memory is
// discarded, for the same reason as the mandatory-reasoning restart above.
quirks.settle()
quirks.mutex.Lock()
quirks.disableIgnored = map[string]time.Time{}
quirks.mutex.Unlock()
Expand Down
Loading