Repository navigation
feat(sync): reliable secure LAN sync — whph_sync_core engine, security propagation, simulator oracle and SC-001 proof - #318
Merged
Conversation
New pure-Dart package for the reliable and secure LAN sync (change 0001, M1): HLC + field-level LWW, per-origin version vectors with declared ranges, Noise XXpsk3 sessions, signed batch manifests, group epochs and key handover, membership with grow-only trust anchors, and an out-of-data-dir sync ledger. Includes the simulator with an independent oracle, fuzz and regression suites. U11 fixes (F1, F3, F4, G1, G2/G2b) and the security review rounds: - ledger keeps signed revocation records, written before the DB commit - ledger revoker entries are verify-only and grant no trust - a storage error stops further commits in the session - a flagged signer without a record is held as unverified - ledger-only revocations set local cutoffs only: no self-extension, rotation, anchor flag or self-removal Known open gap F5 (relay omits a superseded change) is tracked by the f5-pending test, skipped by default.
Protocol v3 (F5 step 1a): ChangeBatchMessage.ranges carries a list of ranges per origin. The receiver sorts each origin's ranges, rejects duplicate or overlapping ones, requires every envelope to lie in exactly one range, and advances the cursor ascending. maxRangesPerBatch caps the count before any other work. The sender still emits one range per origin, so sync behaviour is unchanged; the superseded-change relay builds on this.
F5 step 1b: SyncStore keeps, per origin, the seqs whose version was replaced by a newer winner, with the key of that cell. Recorded only in the replace branch of _put; a same-version re-put, the _clone rebuild and the adoption re-keying in switchOrigin record nothing. _clone copies the index, an origin switch prunes entries whose cell is gone, and a debug-only check (run by the simulation after every op) keeps the index disjoint from the stored winners. Nothing reads the index yet, so sync behaviour is unchanged.
… security rows on the sealed origin
…y-loss simulation
…re they left the device
… below unsent writes switches origin
…instead of reusing them
…copy-time, not only at snapshots
… session start/end and before restore, and count failures
…peers can enforce them
…ooted, key-lost re-issue only after repair, quiet-check counts security cells
…imulator per Efe rulings A+C - needsRepairing-driven repair step (re-pair self, re-invite stranded, never revoked keys); SIM_NO_REPAIR negative control - causal staleRestored marking on restore ops; mutual-complete cluster partition; auth-only evidence (K=2); never-stale member blocks exclusion - stranded-revoked accounting: identities whose only revocation records live inside an excluded cluster are not expectable revoked on the converged set (stat + log line) - provisional exclusion in the quiesce loop so excluded devices do not block quiet - regression tests: dir-restore stranding/flag-only-cleared-by-pair; registration relearn probes; sim_stale_cluster_test (100006 clusters+stranded+det, 100003 clean no-exclusion, SIM_NO_REPAIR 100160)
…er the engineered guard cases - decideStaleExclusion pure function (cluster partition + evidence gating) - never-stale acceptor blocks exclusion; other-failure blocks; whole-set-stale reported not excluded
…revocation decision core, assert exclusion counters F1: only explicit notAuthorized/refusedByPeer counts as auth evidence at pair level; unknown/transport failures count as otherFail so a cluster that merely cannot reach outsiders is never excluded as stale. Extract strandedRevokedPubs as a pure decision core with a data-level test for rule (7): relaxation only when every holder of the record is inside the excluded cluster. sim_stale_cluster_test now asserts the F2 evidence counters and the second-run trace stability on seed 100006.
…stranding per Efe 100336 ruling (a) unreachableClusterWinners: a required/optional write is not expectable on the converged side iff its author is inside the excluded cluster AND no converged device holds a copy of that version (crossed copies keep the winner required). Authors come from the oracle itself, not from holders. (b) strandedMemberIdentities: a final identity whose every member row was authored inside the excluded cluster is not expected in converged views; id-level view diffs fully attributable to excluded-cluster identities are counted as staleClusterDivergence (device-id clause), not violations. Guards: a1/a2/b1/b2 engineered tests; 100003 no-relaxation control (both new counters zero); 100006 determinism extended to the new counters. Mutation-red for A (third condition deleted) and B (every->any) recorded.
…M INTO backups, sqlite connection setup, spike suites and fixtures Prepares Phase 2 (T13-T19) on the phase2 branch: - database_backup_service: VACUUM INTO snapshot writer injected from the open connection (Drift does not wrap onUpgrade in a transaction); - sqlite_connection_setup: shared WAL/busy-timeout connection wiring; - spike suites (crypto/dedupe/scale/trigger) + fixtures + WAL/backup tests that T13-T19 build on; - run_tests.sh: sync spike lanes; pubspec: whph_sync_core path dependency.
… cannot be checked without the key file stay on disk (#332 follow-ups M-1, M-2)
…-joiners feat(sync): expose stranded joiner ids in the origin switch outcome (ACF-37)
…ac-followups fix(sync): ledger MAC follow-ups from the #332 review (M-1, M-2)
…ember-table boundary, ordering (#333 review survivors)
…tore (ACF-47) SyncGroupState.needsRepairing was set by restore/key loss but only removedFromGroup had a card, so a device restored from an old backup stopped syncing without a word. NeedsRepairingCard explains it and offers pairing, in all 22 locales.
…-tests test(sync): close the #333 mutation survivors for stranded member ids
…rompt feat(sync): prompt to pair again after a stale restore (ACF-47)
…ate (#336 review MINOR) Extracts SyncGroupStateCard from the sync devices page so the mapping from SyncGroupState to card is testable; widening needsRepairing to ungrouped now fails a test.
…d on an origin no single member owns (ACF-49) maintainMembership already re-issued own records stranded on a sealed origin. It now also re-issues a directory-verified record authored by another member when its carrier origin is unregistered or conflicted, so peers reject the carrier cell and cannot fetch the record. Ledger-only records are never re-issued and the re-issue stays idempotent.
…rty-reissue test(sync): group-state card shows only the card meant for its state (#336 MINOR)
…rty-reissue feat(sync): third-party revocation re-issue for records stranded on an unowned origin (ACF-49)
…can button works Navigator.pushNamed<String> cast the app's PageRouteBuilder<dynamic> to Route<String?> and threw, so the scanner page never opened on Android. QRCodeScannerPage.scan pushes a MaterialPageRoute<String> instead.
…evice can sync Joining a group schedules the reauthor phase, but only app start ran the job, so every sync was skipped silently until a restart. The membership service now starts it in the background once the switch commits, and logs a failure instead of dropping it.
…a device joins The manual dialog only took an IP and port, which cannot pair under the invitation flow, so it now takes the pairing code the other device shows (with a copy button). The old connection string is removed. The connect-info dialog is centred and tells the page when a device paired so the list reloads. This commit also carries the translation keys and the 22 locale files for the progress and hint texts of the next commit. feat(sync): show per-device progress and the last failure on the device card A syncing device's card shows an approximate percentage and a bar (processed batches over the total known after the vector exchange); the loading overlay and the failure toast are gone because the card and the AppBar button already say it. Not-reachable gets a hint to start Server Mode on the other device. The desktop, which answers sessions, now records the peer's last success and clears a stale not-reachable result, and its sync button also shows in server mode. The Server Mode card is hidden while the server is off.
…ted session's result when the status write fails
…ring code, show a stalled preparation and drop the pending ledger entry on a refused switch
…ng, and correct three locale hints
…onnection mode the same on desktop and phone
…rs again with a fresh one
…enew its identity
…0 notes outrun the 30 s default on CI runners
… min limit and its first-sync gate (10 min) is unmet (~23 min)
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.
Summary
Adds the pure-Dart sync engine package
packages/whph_sync_core(M1 + review fixes) and the simulator/oracle that proves it, per plan 0001 reliable-secure-lan-sync (F5 program).Engine fixes (Efe-reviewed, card A + B.2 + C + 100336 rulings)
0a504772), several disjoint ranges per origin in a batch (b3b03ea9).6e6d0e6e,3b7a8da5): flush the written watermark at session start/end, before restore and at copy time via the store's dirty flag; failure counters.9162e629,b8de0534): re-publish own directory-verified revocations stranded on sealed unserved carriers; "served" means manifested + rooted carrier origin + seq ≤ persisted sent mark; key-lost re-issue only after re-pair; quiet-sync counts security cells.29aa047d,656fca91): trust anchored in key-file anchors; key loss leaves no member row on the new origin.Simulator/oracle model (Efe rulings A+C, then 100336)
35ae4692,a45b8486,b507db6c).70ee43d8). Pure decision cores (decideStaleExclusion,strandedRevokedPubs,unreachableClusterWinners,strandedMemberIdentities) with engineered guard tests and 4 recorded mutation-red checks.SC-001 status: CLOSED
70ee43d8: smoke +23, stale-cluster suite 12/12, 16/16 targeted seeds violations=0 (incl. the former failure 100336 → 0), determinism double-run, negative controls..agents/state/reliable-secure-lan-sync/evidence/sc001-closure.md(working-tree only, gitignored); key logs:ruling-gates.log,mutation-red.log,sc001-full2.log,sc001-seed100336*.log,release-condition-justification.txt.Documented limitations
Commit chain:
9162e629..70ee43d8(28 commits on top of origin/main).Test plan
fvm dart test --tags sim-smoke(+23), full non-soak suite (+501 ~2 skipped), stale-cluster suite 12/12 — all green on70ee43d8.agents/state/...(gitignored; ask @ayg-n for copies if needed)Known gap: T28 performance gate is UNMET
The T28 loopback benchmark (
test/performance_sync/sync_performance_loopback_test.dart, tagperf-sync) has a gate: first sync of thelarge_usagefixture (about 657k cells) must finish in 10 minutes or less. It does not. We measured about 23 minutes on a desktop over loopback (about 480 cells/s; the cost is per-cell SQL statements and pure-Dart ChaCha). The gate was not raised or weakened.The benchmark is a manual run (its file header says how). CI used to run it inside the generic
flutter testand it hit the 30 minute limit, so the generic runs and the Performance Tests job now pass--exclude-tags perf-sync(commit 21e9c4c). The speedup (batched per-cell SQL and crypto) is a separate follow-up, ACF-99.Also in this round: EC-04 got its own 3 minute test timeout (a4dcbff), because four sessions over 1500 notes take about 20 s locally and more on CI runners; its assertions are unchanged.