Skip to content

table: add record-consistency checks tables - #64

Merged
dbirman merged 7 commits into
mainfrom
record-consistency-checks
Oct 7, 2026
Merged

dbirman merged 7 commits into
mainfrom
record-consistency-checks

Conversation

@seanmcculloch

@seanmcculloch seanmcculloch commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

What changed

Add a record_consistency_checks sync job that writes two tables: record_consistency_results (one row per evaluated record and check) and record_consistency_checks (one row per check with its description, source link, code hash, counts, and timings). Checks are self-contained modules under record_consistency/checks/; sources load each record population once. Results for unchanged records are reused when a check does not compare across records and its code hash is unchanged. The first check fails DocDB v2 records that share an exact name. The record-consistency skill documents the design.

Review notes

Registry counts in the sync tests now derive from TABLE_SPECS. New tables mean a minor version bump and a pipeline run to fill bdc-v0.43. The job still needs a capsule and Nextflow wiring. CI lint fails on errors already on main, before tests run.

@seanmcculloch
seanmcculloch force-pushed the record-consistency-checks branch from d24b16c to c9c85f9 Compare October 1, 2026 16:52
raise ValueError(f"Check {check.key!r} names unknown sources: {unknown}")


def _reusable_statuses(check: Check, previous: pd.DataFrame) -> dict[tuple[str, str], str]:

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Decideds whether a previously run check is still valid (for skipping checks on unchanged records).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checks that compare records against eachother are always rerun in full

"""Evaluate one check, reusing unchanged results where allowed, and return its rows."""
records = loaded[check.source]
reusable = _reusable_statuses(check, previous)
pending = [record for record in records if (record["record_id"], record["record_last_modified"]) not in reusable]

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pending here is a list of the records that need to be checked. Records get skipped if the check's previous results are still valid (via last_modified info of records)

@seanmcculloch
seanmcculloch added this pull request to stack #67 October 1, 2026 17:31
@seanmcculloch seanmcculloch changed the title feat: add record-consistency checks table feat: add record-consistency checks tables Oct 1, 2026
@seanmcculloch
seanmcculloch marked this pull request as ready for review October 1, 2026 18:53
@seanmcculloch
seanmcculloch requested a review from dbirman October 1, 2026 18:53
raise ValueError(f"Check {check.key!r} names unknown sources: {unknown}")


def _reusable_statuses(check: Check, previous: pd.DataFrame, previous_hash: str | None) -> dict[tuple[str, str], str]:

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Decides whether a previous result is still valid, so checks can skip unchanged records.


def _reusable_statuses(check: Check, previous: pd.DataFrame, previous_hash: str | None) -> dict[tuple[str, str], str]:
"""Map ``(record_id, record_last_modified)`` to a previous status that is still valid."""
if check.compares_across_records or previous_hash != check.hash:

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checks that compare records against each other are always rerun in full, as are checks whose code hash changed since the previous run.

@dbirman

dbirman commented Oct 2, 2026

Copy link
Copy Markdown
Member

Looks like the lint errors are my fault? I'm going to fix on main before we merge these, sorry about that!

@dbirman dbirman changed the title feat: add record-consistency checks tables table: add record-consistency checks tables Oct 7, 2026
@dbirman
dbirman merged commit 884138d into main Oct 7, 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.

2 participants