Skip to content

fix: pre-release review findings (FTS remnants, plaintext FtM copy, false-empty results, NO_PROXY pin, possibly-sent faxes) - #156

Merged
JordanCoin merged 6 commits into
mainfrom
claude/open-prs-merge-review-e6z0ep
Nov 19, 2026
Merged

JordanCoin merged 6 commits into
mainfrom
claude/open-prs-merge-review-e6z0ep

Conversation

@JordanCoin

Copy link
Copy Markdown
Owner

An independent pre-release review of everything merged since v5.0.0 found one deleted-data issue that counts as a blocker under the project's own rules, plus six should-fix issues. This PR fixes all of them.

Every fix was reproduced first, using the reviewer's scripts or a new test. Each new test fails on the old code and passes with the fix.

Blocker: deleted text survived in the full-text index (openfoia/db.py, migration 009)

The flag that triggers the FTS5 merge lived in memory and was cleared before the merge ran. So a merge that never finished left a deleted page's words in data.db. There were two ways that happened:

  • another process held the database past the busy timeout;
  • OpenFOIA was killed right after the commit.

The words stayed until some unrelated later delete happened to trigger a merge.

The fix:

  • The deleting transaction now records the owed merge in a one-row table, fts_merge_pending. The record is cleared only after a merge succeeds, and every session merges first if it is set.
  • Migration 009 sets it once for upgraded databases, since they may already hold leftover words.

Fixing this also turned up a second bug:

  • SQLite before 3.47 refuses schema-qualified names (main.x) in a trigger's INSERT. That is the SQLite bundled with Python 3.11.
  • The setup error was swallowed by a bare except, so on those systems no trigger was created at all.
  • The trigger now uses an unqualified name, and a setup failure is logged instead of hidden.

Should-fix

  1. Plaintext copy of the entity graph. records fetch -s aleph|companieshouse wrote downloads/ftm/*.ftm.json (officers' names, birth dates, nationalities) next to an encrypted database and never removed it.
    • Fix: entities are now imported from memory. ftm_import gains parse_ftm_lines and a lines= argument.
  2. Aleph filter drops everything, user sees "No results". When the local --type/--jurisdiction re-check dropped every hit, the output was a bare "No results found".
    • Fix: it now says the hits were dropped and how to see them.
    • It also reads more FtM country-typed properties: mainCountry, birthCountry, residency, pastFlags.
  3. OpenSanctions offline miss reads as a clean screening.
    • Fix: a miss now says that exact whole-name and alias matching is not proof the name isn't listed. This shows in records search and in openfoia search (as the source's reason).
  4. NO_PROXY hosts skipped the DNS-rebinding pin. They were mounted as a plain transport.
    • Fix: they now use the same pinned direct transport.
  5. Fax or letter POST timeout showed an empty error.
    • Fix: the error now says either that nothing was sent (no connection was made), or that the request may have been accepted and charged, so check the Twilio or Lob dashboard before sending again.
  6. records search table cut off the id that records fetch needs.
    • Fix: the ID column now wraps instead of truncating.

Nits

  • --all-sources now prints the OpenSanctions API-key notice.
  • The Aleph date check is anchored.
  • Related-entity schemas are validated before they are stored.

Not changed

  • Aleph schema= parameter: the reviewer recalled filter:schemata=. But Aleph's live /api/openapi.json (checked 2026-11-19) documents schema on /api/2/entities, and results are re-checked locally either way.

Docs

  • THREAT_MODEL:
    • Limitation 2 now covers the full-text index as well as the journal after a kill or busy database.
    • Limitation 6 describes the durable pending-merge record.
    • Limitation 9 says NO_PROXY hosts are pinned too.
  • CHANGELOG: the unreleased entries are updated to match.

Checks

  • ruff: clean.
  • Full suite:
    • Python 3.13: 1520 passed, 8 skipped.
    • Python 3.11: 1372 passed, 156 skipped (optional extras not installed).
    • I ran 3.11 this time because the last CI failure was version-specific.

Generated by Claude Code

…atabase

The flag that triggers the FTS5 merge lived in memory and was cleared before
the merge ran, so a merge that failed (another process holding the database)
or never ran (killed after the commit) left the deleted page's words in
data.db until some later delete. The deleting transaction now records the
owed merge in a one-row table (migration 009), cleared only after a merge
succeeds; every session merges first if it is set. The trigger uses an
unqualified table name (SQLite before 3.47 refuses main.x in a trigger's
INSERT), and a failure to set it up is logged instead of silently dropped.

Found in an independent pre-release review.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016LaGpHLuSRHzGARb38X7YS
records fetch -s aleph|companieshouse wrote downloads/ftm/<name>.ftm.json
(officers' names, birth dates, nationalities) next to an encrypted database
and never removed it. ftm_import gains parse_ftm_lines and a lines= argument;
nothing is written outside the database now.

Found in an independent pre-release review.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016LaGpHLuSRHzGARb38X7YS
- Aleph: when the local --type/--jurisdiction re-check drops every hit, say
  so instead of a bare 'No results'; read more FtM country properties
  (mainCountry, birthCountry, residency, pastFlags).
- OpenSanctions offline: a miss says exact whole-name/alias matching is not
  proof the name is not listed (records search and openfoia search).
- The records search ID column folds instead of cutting the id records fetch
  needs; --all-sources prints the OpenSanctions API key notice.
- Aleph: anchored date check; related-entity schemas validated before storing.

Found in an independent pre-release review.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016LaGpHLuSRHzGARb38X7YS
A NO_PROXY match was mounted as a plain transport, so public_addresses_only()
was never consulted for it. It now uses the same pinned direct transport.

Found in an independent pre-release review.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016LaGpHLuSRHzGARb38X7YS
A read timeout after the POST went out printed an empty error, with no hint
that Twilio or Lob may already have accepted (and charged for) it. Errors now
say either that nothing was sent (no connection) or that it may have been
accepted and to check the dashboard before sending again.

Found in an independent pre-release review.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016LaGpHLuSRHzGARb38X7YS
…faxes

Found in an independent pre-release review.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016LaGpHLuSRHzGARb38X7YS
@JordanCoin
JordanCoin merged commit fb65043 into main Nov 19, 2026
9 checks passed
@JordanCoin JordanCoin mentioned this pull request Nov 19, 2026
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.

2 participants