Skip to content

Add --force flag and inconsistency auto-detection#108

Merged
n-dusan merged 2 commits intomainfrom
ndusan/inconsistency-check
Apr 22, 2026
Merged

Add --force flag and inconsistency auto-detection#108
n-dusan merged 2 commits intomainfrom
ndusan/inconsistency-check

Conversation

@n-dusan
Copy link
Copy Markdown
Contributor

@n-dusan n-dusan commented Apr 21, 2026

Description (e.g. "Related to ...", etc.)

Adds a --force flag to stelae update and automatic detection of database inconsistencies caused by force-pushes or repository rollbacks. When an inconsistency is detected (mismatched publication count or a missing auth commit), the stele is automatically wiped and rebuilt from scratch. --force skips the checks and always rebuilds. Also enables PRAGMA foreign_keys = ON per connection so cascade deletes work correctly.

Code review checklist (for code reviewer to complete)

  • Pull request represents a single change (i.e. not fixing disparate/unrelated things in a single PR)
  • Title summarizes what is changing
  • Commit messages are meaningful (see this for details)
    [ ] Tests have been included and/or updated, as appropriate
  • Docstrings have been included and/or updated, as appropriate
    [ ] Standalone docs have been updated accordingly

Automated tests, benchmarks and linters

You can run the tests, lints and benchmarks that are run on CI locally with:

just ci

…telae update

- Add \`--force\` / \`-f\` flag to the \`update\` subcommand; when set, the
  database records for each included stele are deleted and fully rebuilt
  from scratch, skipping all consistency checks. Respects --include and
  --exclude filters.
- On each normal run, two consistency checks are performed before the
  delta insert:
  - Publication count: if the RDF repository's \`_publication/\` directory
    has fewer entries at HEAD than non-revoked publications in the DB,
    the RDF repository was likely force-pushed or rolled back and a
    full rebuild is triggered with a warning.
  - Auth commit existence: for each historical HTML data repository, the
    most-recently-recorded \`auth_commit_hash\` in \`data_repo_commits\` is
    verified against the auth repository; a missing commit triggers a
    rebuild.
- When a rebuild is triggered, \`DELETE FROM stele\` cascades through all
  child tables via \`ON DELETE CASCADE\`. To make cascades reliable, enable
  \`PRAGMA foreign_keys = ON\` on every pool connection via \`after_connect\`.
- Add \`stele::TxManager::delete\`, \`publication::TxManager::count_non_revoked\`,
  and \`data_repo_commits::TxManager::find_last_auth_commit_for_stele\` to
  support the above.
@n-dusan n-dusan requested a review from BojanG99 April 21, 2026 16:50
@n-dusan n-dusan self-assigned this Apr 21, 2026
@n-dusan n-dusan merged commit e74122f into main Apr 22, 2026
7 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