RE: verify Enrichment persistence, fix silent judgement clobber (item 1) - #119
Merged
Merged
Conversation
PLAN-FINISH-REPOS.md item 1's done test: a curator can record and revisit
an enrichment judgement, and a judgement whose evidence moved says so.
Most of this was already built (JUDGEMENTS/OBSERVATIONS, evidenceSnapshot/
movedSince, PATCH .../field, load-before-render on the pane) and is now
verified end to end rather than assumed.
Found and fixed one real defect: POST /api/context/{type}/{slug}
(save_context) built its stored document from ContextData.model_dump(),
and ContextData.enrichment defaults to {} when a request omits it. The
classic `/` page's Context form always omits it, so saving that form
after recording an Enrichment judgement in /next silently wiped the
judgement. question_answers had the same exposure. Fixed by reading the
raw request body and only replacing either collection when the caller's
JSON actually names the key, keeping what is on record otherwise; a
caller that means to clear one still can by sending it explicitly.
Adds:
- tests/test_enrichment_fields.py: TestReviseAfterReload -- PATCH-then-GET
round trip through the real HTTP routes, and a regression for the
classic-form-clobber bug above.
- tests/test_next_enrichment_persistence.py: executes (not just pattern-
matches) movedSince/evidenceSnapshot under node with a minimal state
stand-in, confirming the evidence-moved flag reacts to real facts
changing rather than just comparing timestamps correctly in isolation.
Full suite: uv run pytest tests/ -q -k "not Postgres" -- 4837 passed,
103 skipped, 18 deselected, 0 failed.
Signed-off-by: dwolfson04@gmail.com
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Signed-off-by: Dan Wolfson <dan.wolfson@pdr-associates.com>
2 tasks
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
POST /api/context/{type}/{slug}built its stored document viaContextData.model_dump(), which defaultsenrichment/question_answersto{}when a request omits them. The classic/page's Context form always omitsenrichment, so saving it after recording a judgement in/nextsilently erased that judgement. Fixed inresource_explorer/web/routes/context.py: the route now reads the raw request body and only replaces a field when the caller's JSON actually names that key.tests/test_enrichment_fields.py::TestReviseAfterReload(PATCH→GET round trip, regression for the clobber bug) andtests/test_next_enrichment_persistence.py(executesmovedSince/evidenceSnapshotunder Node against a live-changing fact set).Full suite: 4837 passed, 0 failed, 103 skipped.
See
docs/design-notes/ITEM-1-ENRICHMENT-IMPLEMENTED.md— includes what could NOT be verified live (no dev server available against this branch in the agent's sandbox; the save/revisit/evidence-moved paths were pinned by executed tests and code tracing instead) and what to check first once this merges into the served checkout.Test plan
uv run pytest tests/test_enrichment_fields.py tests/test_next_enrichment_persistence.py -q— 24/24 passuv run pytest tests/ -q -k "not Postgres"— 4837 passed🤖 Generated with Claude Code