Skip to content

feat(core): sync crate contracts, FFI sync surface and fakes - #4572

Merged
datlechin merged 8 commits into
mainfrom
feat/core-sync-contracts
Nov 26, 2026
Merged

datlechin merged 8 commits into
mainfrom
feat/core-sync-contracts

Conversation

@datlechin

@datlechin datlechin commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Summary

  • tablepro-sync (core/crates/sync): the contracts the engine, transport and key lanes build against, in src/api/:
    • Transport and ServiceTransport: pull a page, push a batch with one outcome per change, the scopes body, Sign Out's key-device revoke, stop reports, the device row removal, 0051's rejected codes and whole-request refusals, and the DPoP key each call is signed with.
    • CloudKitTransport: 0054's callback, with its records, outcomes and failures.
    • StateStore, StateTxn and StateFiles: a typed row for every 0054 table, sync and key, behind one commit, the primary key encoding the digests order by, and what opening the file found.
    • HostDeviceStore: device keys, account keys, a proposed reset's keys, the state MAC key and the anchor, each item with its class.
    • RecordAdapter and HostSettings.
    • Key flows as one trait per lane (AccountFlows, ApprovalFlows, DeviceFlows, ResetFlows, TeamFlows, RestoreFlows, StopFlows, together KeyFlows), and KeyHooks to stop, lock and report.
    • SyncControl: status, passes, providers and moves, approvals, conflicts, held records, the history window.
    • ADR 0062 and 0064: KeyVersionRow.stopped_cause (catch_up, restart_held or restore_wait) after state; two causes keep the stricter, personal and history rows stop only as catch_up; clear_stop takes the event and refuses one the cause does not allow; end drops the cause.
    • ADR 0064: the pending_bases table, a held team restart with held_restart and accept_restart bound to the compared IK, and its notice. stores keeps one row per store file (0060).
    • Roster::of decides only with the CaughtUp of a pull of that team.
    • Lane gaps: CloudKit creation time on records and bases, the kinds a pull read, LegacyMetadata::for_account (another account imports only dirty keys and standing), category and password switches, a host journal call, RecordAdapter per scope, HeldReason::AwaitingDeviceApproval, pass reasons for the journal, key flows and CKAccountChanged.
    • Roster carries the scopes body's stop reports into TeamKeys.stopped.
    • Every unfilled body answers sync.unimplemented.
  • tablepro-sync-testing (core/crates/sync/testing), dev-only fakes, each with tests of its ADR behavior: an in-memory /v2/sync server, a CloudKit, a device store, a state store and the key flows.
  • LegacyMirror: the Swift engine's metadata (token, dirty and tombstone keys with their dates, deferred deletions, the three unreadable-copy sets, standing, SyncRecordCache), read at launch for the import and written after each pass while the previous stable runs it.
  • FFI (core/crates/ffi/src/sync/): Core::open_sync, SyncService, SyncListener, every key-flow call, the CloudKitTransport foreign trait (uniffi::export(with_foreign)), and the HostSettings, HostDeviceStore and HostLegacyMirror callbacks, bridged to the engine's traits. C# bindings regenerated.
  • ErrorInfo.sync: a sync refusal's step-up challenge, Retry-After, rejected change code or lock cause.
  • apple/Packages/TableProFFI: the generated module compiles in Swift 5 mode, since UniFFI 0.31's Swift for an async foreign trait fails Swift 6 (Swift 6 strict concurrency: async foreign-trait codegen emits #SendingClosureRisksDataRace hard error (0.31.2) mozilla/uniffi-rs#2929, fixed in 0.32, which uniffi-bindgen-cs does not support yet). The apps stay in Swift 6.
  • ARCHITECTURE.md, Bindings: the device store's values cross the FFI as plain bytes, listed with the other plain buffers.
  • core/ARCHITECTURE.md, core/AGENTS.md and core.yml: the sync crates' rows, graph edges, platform seams, bindings and packages; tablepro-records joins the core.yml check.
  • detect-changed-paths.sh: the Apple suites skip the sync fakes, the key vectors with their script and fuzz targets, and the records' fixtures; the package suites skip the keys' fuzz project.
  • test_the_mac_app_runs_on_the_shortcut_presets_it_bundles becomes test_the_apple_apps_run_on_the_shortcut_presets_the_core_they_link_bundles and expects ios true: the iOS app links the core since feat(ios): sign in to a TablePro account through the shared core #4492, and the old expectation fails on main.

Test plan

  • verify.sh --platform windows --jobs 4 core tablepro-sync and core tablepro-sync-testing: 17 and 88 tests, the fakes' ADR behavior included.
  • verify.sh --platform windows --jobs 4 core: tablepro-ffi, 383 tests, with the CloudKit, device store and legacy mirror bridges and the unfilled-call error.
  • cargo clippy -p tablepro-ffi -p tablepro-sync -p tablepro-sync-testing --tests: clean.
  • verify.sh --platform windows bindings: PASS on the committed C#; build: the interop compiles against it.
  • python3 -m unittest test_detect_changed_paths in scripts/ci: the new suite cases and the updated shortcut presets case pass.
  • cargo clippy --target aarch64-apple-darwin -p tablepro-ffi --tests with -D warnings: clean.
  • Reviews: Codex, two rounds, and Claude (fresh agent) review and security pass; every finding fixed.

@datlechin
datlechin enabled auto-merge (squash) November 25, 2026 20:20
@datlechin
datlechin disabled auto-merge November 25, 2026 20:30
@datlechin
datlechin enabled auto-merge (squash) November 26, 2026 01:59
@datlechin
datlechin merged commit ba7b463 into main Nov 26, 2026
44 of 47 checks passed
datlechin added a commit that referenced this pull request Nov 26, 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.

1 participant