fix(advice): the remaining review findings
Four things from the earlier review of this PR. The prompt test did not test the prompt --------------------------------------- `test_the_advice_is_about_the_reading_that_was_saved` asserted which dict was PASSED to the generator - not what the model was actually ASKED. So it passed even while the prompt still said "give advice for the most recent reading", which is the bug that made the model advise about the wrong number while the advice was filed against the right one. It now asserts on the prompt content: the reading is marked, its date is named, and "most recent reading" is gone. Verified by reverting the prompt fix - the test fails, and so does `test_the_prompt_names_the_reading_to_advise_about`. Two tests now guard it, and reverting the fix breaks both. A write that matches nothing was silent -------------------------------------- The advice writer discarded the return value of `set_reading_advice`. A write that matched 0 documents - which is now the EXPECTED outcome when the brewer corrected the reading while the advice was being generated - was dropped without a word. It is logged now. A stale docstring ----------------- The background thread "builds its own" client - it has used the shared one since the leak was fixed. A missing CSS class ------------------- `advice--reading` is used on the active-beers card and the run detail page, and was never defined, so it had no styles. 173 tests (unchanged - the new assertions were added to existing tests).
This commit is contained in:
@@ -498,6 +498,20 @@ def test_the_advice_is_about_the_reading_that_was_saved():
|
||||
"the advice was generated about the wrong reading"
|
||||
)
|
||||
|
||||
# And the PROMPT must ask about that reading - not just pass it
|
||||
# through. Asserting only which dict was passed would not have
|
||||
# caught the prompt still saying "give advice for the most recent
|
||||
# reading", which is the bug that made the model advise about the
|
||||
# wrong number.
|
||||
prompt = brew_advice.build_prompt(
|
||||
{"canonical_name": "Ale"},
|
||||
captured["reading"],
|
||||
captured["history"],
|
||||
)
|
||||
assert "THIS IS THE READING TO ADVISE ON" in prompt
|
||||
assert "2026-01-01" in prompt
|
||||
assert "most recent reading" not in prompt
|
||||
|
||||
|
||||
def test_the_shared_repository_is_built_only_once():
|
||||
"""Concurrent advice threads must not each build their own client.
|
||||
|
||||
Reference in New Issue
Block a user