Skip to content

RE: verify Enrichment persistence, fix silent judgement clobber (item 1) - #119

Merged
dwolfson merged 1 commit into
mainfrom
re/enrichment
Sep 17, 2026
Merged

dwolfson merged 1 commit into
mainfrom
re/enrichment

Conversation

@dwolfson

Copy link
Copy Markdown
Owner

Summary

  • PLAN-FINISH-REPOS.md item 1: verified a curator can record and revisit an Enrichment judgement, and that "evidence moved" fires correctly.
  • Real bug found and fixed: POST /api/context/{type}/{slug} built its stored document via ContextData.model_dump(), which defaults enrichment/question_answers to {} when a request omits them. The classic / page's Context form always omits enrichment, so saving it after recording a judgement in /next silently erased that judgement. Fixed in resource_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.
  • Added tests/test_enrichment_fields.py::TestReviseAfterReload (PATCH→GET round trip, regression for the clobber bug) and tests/test_next_enrichment_persistence.py (executes movedSince/evidenceSnapshot under 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 pass
  • Full suite: uv run pytest tests/ -q -k "not Postgres" — 4837 passed
  • Live browser verification once merged into the served checkout (port 8810) — recommend checking save→reload→judgement-persists and the "⚠ evidence moved" text before considering this fully closed

🤖 Generated with Claude Code

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>
@dwolfson
dwolfson merged commit 787906e into main Sep 17, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant