P5 audit remediation: backup KDF portability, migration drift test, deviation log - #28
Merged
tyler-rich merged 2 commits intoJul 6, 2026
Conversation
…ion drift test, deviation log Addresses the P5 tier of docs/reviews/full-audit-2026-07-05.md §10 (maintainability, process, long tail): - item (g): backup restore derives the passphrase key from the bundle's advertised scrypt params (kdf.n/r/p) instead of the module constants, so a bundle written under a different (e.g. older) work factor still restores. derive_key / passphrase_cipher take explicit, validated n/r/p; restore passes the recorded values. - QUA-23: new tests/test_migrations.py runs the real Alembic chain to head against a throwaway DB and asserts the tables/columns match Base.metadata (the rest of the suite builds via create_all). alembic/env.py now respects a caller-provided URL. Deviation-logging debt recorded in docs/PLAN.md (required regardless of fix): FE-2 (hand-rolled API client), INF-10 (HIGH/CRITICAL dogfood floor), API-12 (created_at vs started_at index), FEAT-4 (DB-schedule actuation). QUA-4/QUA-9, QUA-16, and FE-10 are explicitly deferred with rationale.
Per user decision (2026-07-05): keep the merged-PR-only :dev publish trigger for now — while the repo is private, fork-based contributions can't happen, so the fork-secrets gap can't be triggered. Record in docs/PLAN.md that INF-2 must be revisited specifically before the repo is made public, since that is the event that enables fork PRs (and therefore the actual bug). INF-3's CLAUDE.md wording stays matched to the current trigger.
tyler-rich
force-pushed
the
claude/audit-fixes-2026-07-05-9bqe6n-p5
branch
from
July 6, 2026 04:20
6fd0808 to
a09c324
Compare
tyler-rich
merged commit Jul 6, 2026
879b544
into
claude/audit-fixes-2026-07-05-9bqe6n-p4
4 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements the P5 tier of
docs/reviews/full-audit-2026-07-05.md§10 (maintainability, process, long tail).Concrete fixes (with tests)
kdf.n/r/p) instead of the module constants, so a bundle written under a different (e.g. older) work factor still restores.derive_key/passphrase_ciphertake explicit, validatedn/r/p(defaulting to the current constants for new backups);restore_bundlepasses the recorded values. Tests cover parameterized derivation, invalid-param rejection, a low-param round-trip, and a bundle whose recordednis honored (tampering it fails the restore).tests/test_migrations.pyruns the real Alembic chain to head against a throwaway database and asserts the resulting tables/columns matchBase.metadata— the rest of the suite builds the schema viacreate_all, so a migration that drifts from the models would otherwise pass unnoticed.alembic/env.pynow respects a caller-providedsqlalchemy.urlso the test can target its own DB.On your item (g) question
I checked before touching the KDF code: this environment has no backup bundles at all (
/datais absent; zero.scryebakfiles anywhere), so nothing is already unrestorable — there is no pre-2^15→2^17-bump bundle to regenerate. This fix is forward-looking: future work-factor changes won't strand existing bundles.Required deviation-logging debt (logged regardless of fix)
Per CLAUDE.md, dated
docs/PLAN.md§ Deviations entries were added for the four un-logged divergences the audit named: FE-2 (hand-rolled API client), INF-10 (HIGH/CRITICAL-only dogfood floor), API-12 (created_atvsstarted_atscans index), FEAT-4 (DB-schedule actuation dropped from Phase 6 — now actually implemented in P3).Explicitly deferred (recorded with rationale, not half-done)
lib/dates.tsis a natural first target. Deferred to keep P5 scoped.Testing
Full backend suite: 440 passed.
ruff+blackclean.