Skip to content

Fix extraction placeholders, incidental parties, filing-type sync, and draft identity - #220

Merged
nonprofittechy merged 2 commits into
mainfrom
fix/217-218-filing-data-integrity
Sep 5, 2026
Merged

Fix extraction placeholders, incidental parties, filing-type sync, and draft identity#220
nonprofittechy merged 2 commits into
mainfrom
fix/217-218-filing-data-integrity

Conversation

@nonprofittechy

Copy link
Copy Markdown
Member

Summary

Closes #217. Closes #218.

Four related data-integrity problems are fixed together because each one touches the same extraction-to-submission pipeline.


What changed

Filter extraction placeholders (#217)

The LLM sometimes returns "unknown", "none", "N/A", and similar non-answers instead of leaving a field empty. These leaked through to the data extraction review page and were shown as if they were real case facts.

  • New clean_extracted_value() in extraction_fields.py recursively strips a configurable set of placeholder strings before normalization and before display, so older saved extractions are covered without a migration.
  • Matching is accent/punctuation-insensitive (N/Ana); meaningful values like "All Unknown Occupants" are preserved because the full phrase is not in the placeholder list.

Keep incidental names as evidence only (#217)

Witnesses, guardians, children, and other people mentioned in passing were being auto-promoted to case parties. The filer then had to manually delete them from the party list.

  • review_rows() in extracted_parties.py now only surfaces auto-party suggestions when the extracted side is INITIATING or RESPONDING.
  • The extraction review column is relabelled "Other names mentioned in the document" to make its advisory nature clear.
  • The other party names key is removed from CONFIRMED_IN_FORM_KEYS so these names are never treated as form-confirmed data.

Synchronize filing types (#218)

The draft's filing_type_code / filing_type_name summary fields could fall out of sync with the lead FilingDocument after uploads, reordering, or partial saves, causing the wrong filing type to appear on review and in the submission payload.

  • FilingDocument.save() in models.py calls the new sync_primary_filing_type() helper after every document save, keeping the draft in sync atomically.
  • write_case_data() in drafts.py writes explicit client edits through to the lead document before saving the draft summary, so legacy API calls cannot clobber the authoritative source.
  • mark_submitted() calls sync_primary_filing_type() once more just before the status flip as a final safety net.

Preserve draft identity across redirects (#218)

When a view redirected to another URL (e.g., after saving or submitting), the draft PK query-parameter was silently dropped. The next page then resolved a different draft or created a new one, corrupting the filer's session.

  • New DraftIdentityMiddleware in middleware.py:
    • process_view resolves and validates the named draft before the view runs; raises DraftIdentityError (409) on a mismatch.
    • process_response re-injects the draft PK into Location headers and redirect_url JSON keys so redirects carry the identity forward.
    • API callers receive a structured JSON 409; browser requests get a draft_unavailable.html page.
  • Registered in MIDDLEWARE and wired up via the signals module imported in apps.py.
  • get_current_draft() default changed to resume_latest=False so API calls cannot silently adopt a draft that belongs to a different browser tab.

Validation

  • Pre-commit hooks passed: Ruff, djLint, Stylelint, ESLint, type checking, Bandit, migration check.
  • uv run pytest -q685 passed.
  • npm run test:unit43 passed.
  • Local Playwright browser smoke tests — 2 regressions passed.

nonprofittechy and others added 2 commits September 5, 2026 16:55
The workflow screens stamp their own draft into the URL on load, via the
replaceState in draft-scope.js, so a direct visit to /payment/ settles on
/payment/?draft=1. routePattern anchored at end of string, so all nine
screens in WORKFLOW_VIEWS failed the URL assertion before Axe ever ran --
which is why filing options, plans, and my drafts passed while the
workflow steps did not.

Match the path and ignore any query or fragment. A screen that redirects
somewhere else is still caught. All nine screens audit clean at WCAG 2
A/AA with no findings at any impact.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BEU5k33H4u1aKT6bnzR1KG
@nonprofittechy
nonprofittechy merged commit 95e1a39 into main Sep 5, 2026
7 checks passed
@nonprofittechy
nonprofittechy deleted the fix/217-218-filing-data-integrity branch September 5, 2026 21:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant