Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ jobs:
cargo check --locked --target "$TARGET" --features "$FEATURES" --features "$IN_PROCESS_SSH" \
-p tablepro-core -p tablepro-net -p tablepro-storage -p tablepro-ssh -p tablepro-session \
-p tablepro-foreign-import -p tablepro-ai -p tablepro-mcp -p tablepro-cloud-api -p tablepro-account -p tablepro-keys \
-p tablepro-cli \
-p tablepro-test-support -p tablepro-test-fixtures \
-p tablepro-records -p tablepro-sync -p tablepro-cli \
-p tablepro-test-support -p tablepro-test-fixtures -p tablepro-sync-testing \
-p tablepro-driver-cassandra -p tablepro-driver-clickhouse -p tablepro-driver-duckdb \
-p tablepro-driver-mongodb -p tablepro-driver-mssql -p tablepro-driver-mysql \
-p tablepro-driver-postgres -p tablepro-driver-redis -p tablepro-driver-sqlite
Expand Down
36 changes: 36 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ members = [
"core/crates/session",
"core/crates/ssh",
"core/crates/storage",
"core/crates/sync",
"core/crates/sync/testing",
"core/crates/test-fixtures",
"core/crates/test-support",
"core/crates/drivers/cassandra",
Expand Down Expand Up @@ -53,13 +55,16 @@ tablepro-driver-postgres = { path = "core/crates/drivers/postgres" }
tablepro-driver-redis = { path = "core/crates/drivers/redis" }
tablepro-driver-sqlite = { path = "core/crates/drivers/sqlite" }
tablepro-foreign-import = { path = "core/crates/foreign-import" }
tablepro-keys = { path = "core/crates/keys" }
tablepro-mcp = { path = "core/crates/mcp" }
tablepro-net = { path = "core/crates/net" }
tablepro-records = { path = "core/crates/records" }
tablepro-linux-platform = { path = "linux/crates/platform" }
tablepro-session = { path = "core/crates/session" }
tablepro-ssh = { path = "core/crates/ssh" }
tablepro-storage = { path = "core/crates/storage" }
tablepro-sync = { path = "core/crates/sync" }
tablepro-sync-testing = { path = "core/crates/sync/testing" }
tablepro-test-fixtures = { path = "core/crates/test-fixtures" }
tablepro-test-support = { path = "core/crates/test-support" }
async-trait = "0.1"
Expand Down
4 changes: 4 additions & 0 deletions apple/Packages/TableProFFI/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ let package = Package(
.target(
name: "TableProFFI",
dependencies: ["TableProFFIC"],
// UniFFI 0.31's Swift for an async foreign trait starts a Task over non-Sendable closures, which Swift 6
// refuses (mozilla/uniffi-rs#2929). The fix ships in 0.32, which uniffi-bindgen-cs does not support yet, so
// the generated code alone is checked in Swift 5 mode; the apps stay in Swift 6.
swiftSettings: [.swiftLanguageMode(.v5)],
linkerSettings: [
.linkedFramework("CoreFoundation"),
.linkedFramework("Security"),
Expand Down
2 changes: 1 addition & 1 deletion core/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ This is the guide for work under `core/`. The root `AGENTS.md` holds the rules e

## Map

- `crates/core`, `crates/net`, `crates/ssh`, `crates/storage`, `crates/session`, `crates/ai`, `crates/mcp`, `crates/cloud-api`, `crates/account`, `crates/keys`, `crates/cli`: the libraries. `crates/drivers/*`: one crate per engine. `crates/ffi`: the library the Windows and Apple apps load (`ARCHITECTURE.md`, Bindings). `crates/bindgen`: the Swift binding generator. `crates/test-fixtures` and `crates/test-support`: test-only.
- `crates/core`, `crates/net`, `crates/ssh`, `crates/storage`, `crates/session`, `crates/ai`, `crates/mcp`, `crates/cloud-api`, `crates/account`, `crates/keys`, `crates/records`, `crates/sync`, `crates/cli`: the libraries. `crates/drivers/*`: one crate per engine. `crates/ffi`: the library the Windows and Apple apps load (`ARCHITECTURE.md`, Bindings). `crates/bindgen`: the Swift binding generator. `crates/test-fixtures`, `crates/test-support` and `crates/sync/testing`: test-only.
- `ARCHITECTURE.md`: the crates, the graph, the platform seams and the driver layer. `docs/decisions/`: the cross-platform decisions.
- The Cargo workspace and its tool settings are at the top of the repository: `Cargo.toml`, `Cargo.lock`, `rust-toolchain.toml`, `rustfmt.toml`, `clippy.toml`, `deny.toml`, `.config/nextest.toml`.
- Until another app builds the core, the Linux docs hold its contracts: `linux/docs/adding-drivers.md`, `linux/docs/drivers/`, `linux/docs/error-handling.md`, `linux/docs/testing.md` and `linux/docs/storage.md`.
Expand Down
15 changes: 12 additions & 3 deletions core/ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ core/crates/
├── account/ the TablePro account: sign-in, device, entitlement and the feature gate
├── cloud-api/ tablepro-cloud's /v2 client, generated from the vendored document
├── keys/ end-to-end keys for TablePro Sync: suite tp1, key objects, wraps, envelopes
├── sync/ the sync engine for TablePro Sync and iCloud, its state file and the key flows
│ └── testing/ dev-only fakes: the /v2 server, CloudKit, the device store, the state file, the key flows
├── mcp/ the MCP server: transport, token and tools
├── cli/ the tablepro command line: parsing, the MCP client and the output formats
├── ffi/ the library C# and Swift load: one UniFFI API and the grid's C ABI
Expand Down Expand Up @@ -55,7 +57,9 @@ core/crates/
| `cloud-api` | no workspace crate |
| `account` | `cloud-api`, `core`, `storage` |
| `keys` | no workspace crate |
| `ffi` | `account`, `ai`, `cli`, `core`, `foreign-import`, `mcp`, `net`, `records`, `session`, `ssh`, `storage`, and every driver behind its default `engines` feature |
| `sync` | `account`, `cloud-api`, `keys`, `records`, `storage` |
| `sync/testing` (`tablepro-sync-testing`) | `keys`, `records`, `sync` |
| `ffi` | `account`, `ai`, `cli`, `core`, `foreign-import`, `mcp`, `net`, `records`, `session`, `ssh`, `storage`, `sync`, and every driver behind its default `engines` feature |
| An app, such as `linux/crates/app` | every crate above, and its platform crate |

Rules, enforced by review:
Expand All @@ -71,10 +75,11 @@ Rules, enforced by review:
- `ai` depends on `core` and `net`. It speaks the providers' protocols and builds the prompts from what the app hands it; the app decides what a prompt may carry.
- `cloud-api` depends on no workspace crate. It holds the `/v2` client `build.rs` generates from `openapi/v2.openapi-3.0.json`, what a call's problem or 429 answer means, and the one HTTP client a TablePro server is called through; the caller brings the token. `core/scripts/update-cloud-api.sh` refreshes the document.
- `keys` depends on no workspace crate and does no I/O: no tokio, network or SQLite. It holds ADR 0056's encodings, key objects and checks over aws-lc-rs, and HPKE from rustls's aws-lc-rs module ([0056](docs/decisions/0056-end-to-end-keys-per-account-and-device.md), Libraries); the flows and the state file build on it.
- `sync` depends on `account`, `cloud-api`, `keys`, `records` and `storage` ([0054](docs/decisions/0054-one-sync-engine-in-the-core-for-tablepro-sync-and-icloud.md), Crates). Its `api` module holds the contracts its parts build against: the transports, the state file, the device store, the record adapters, the key flows and the control surface `ffi` wraps. CloudKit, the device store and each app's settings reach it through traits the app implements; it never names CloudKit's framework.
- `account` depends on `cloud-api`, `core` and `storage`. It reaches the browser, the keyring and the machine ID through what the app passes in ([0016](docs/decisions/0016-tablepro-accounts.md)).
- `ffi` stands in for an app outside Rust: it names every driver and passes the host's services in. No other core crate depends on it.
- No core crate depends on a GUI toolkit or on a platform crate. An app, or `ffi` for one outside Rust, is the only crate that names every driver.
- `test-support` and `test-fixtures` are dev-dependencies, with one exception: `session` takes `test-support` as an optional dependency behind its `fakes` feature, which only an app's dev-dependencies turn on.
- `test-support`, `test-fixtures` and `sync/testing` are dev-dependencies, with one exception: `session` takes `test-support` as an optional dependency behind its `fakes` feature, which only an app's dev-dependencies turn on.

Consequences:

Expand All @@ -96,6 +101,9 @@ A value or a trait the app passes in:
| `RefreshTokenVaults`, `BrowserLauncher`, `WebAuthenticator`, `MachineId`, `AppClient` and `ServerSettings` (`tablepro-account`) | the keyring through `SecretStore`, `gtk::UriLauncher`, `MachineId::derive` of what `tablepro_linux_platform::read_machine_id` reads, `AppClient::LINUX`, tablepro.app | the Core's secret store, one item per server; the `HostBrowser` callback; Windows: `MachineId::derive_machine_guid` of the registry's MachineGuid and `AppClient::WINDOWS` ([ADR 0026](docs/decisions/0026-the-windows-app-signs-in-through-the-ffi.md)); the Mac: the `HostWebAuthenticator` callback, its own 64-hex machine ID, `AppClient::MACOS` and its managed policy ([ADR 0047](docs/decisions/0047-the-apple-apps-sign-in-through-the-core.md)) |
| `Host` (`tablepro-cli`) | `LinuxHost` in the app crate: the port and switch from GSettings, the token read from the keyring, `NameHasOwner` for a running app, each connection's peer checked by `Host::verify_peer` through `tablepro_net::loopback_peer_is_ours` | `WindowsHost` in `ffi`'s `command_line`, for the `tablepro-cli` program: the port and switch from the app's `settings.json`, the token read from Credential Manager, the app's process id from the `runtime\app.lock` it holds, each peer checked to be that process through `tablepro_net::loopback_peer_process` ([0036](docs/decisions/0036-mcp-and-the-command-line-through-the-ffi.md)) |
| `McpHost` (`tablepro-mcp`) | `GtkMcpHost` in the app crate: sessions from the session registry, the write question in the connection's window | `ffi`'s own: sessions `connect_saved` opened, and the `McpAppHost` callback to open a connection and ask about a write ([0036](docs/decisions/0036-mcp-and-the-command-line-through-the-ffi.md)) |
| `CloudKitTransport` (`tablepro-sync`) | none | the Apple apps' `CloudKitTransport`, an async foreign trait `TableProSyncTransport` implements over CloudKit's operations ([0054](docs/decisions/0054-one-sync-engine-in-the-core-for-tablepro-sync-and-icloud.md)); none on Windows |
| `HostDeviceStore` (`tablepro-sync`): the device keys, the account keys and the state file's anchor, never synced | the Secret Service; none without a keyring, which syncs team records only | the Apple apps' `HostDeviceStore` callback, Keychain items that never sync; on Windows the core's own Credential Manager items with local machine persistence |
| `HostSettings` (`tablepro-sync`) | the app's GSettings | the `HostSettings` callback |
| `ForeignAppDirs` and `ForeignHost` (`tablepro-foreign-import`) | `tablepro_linux_platform::foreign_app_dirs`, the host's XDG directories inside a Flatpak, and `PlainHost`: no other app's store | `ForeignAppDirsArg` from the app; on Windows `ffi`'s own host with the user's DPAPI and Credential Manager's generic credentials ([0033](docs/decisions/0033-foreign-import-and-result-editing-through-the-ffi.md), [0039](docs/decisions/0039-dbx-passwords-from-its-key.md)), elsewhere `PlainHost` |

A `cfg` split inside a crate:
Expand Down Expand Up @@ -125,14 +133,15 @@ Each boundary error has a stable `code()`, such as `driver.timeout` or `ssh.host

- One UniFFI API. `Core` lists the engines with the family each is listed under, opens a file, connects a saved connection or tests one from a form, and parses a connection URL with `tablepro_core::connection_url`, refusing one that needs a setting its record has no field for. Its `ConnectionLibrary` reads and changes the saved connections with their details and device-only settings, groups, favourites, tags and SSH and credential profiles in `connections.json` and stores their secrets, and gives the Apple apps the library's CloudKit records and merges a pull into it (`tablepro_records::cloudkit::library`). A `DatabaseSession` reads the catalog one level at a time, writes a table's sorted page at an offset and counts the table, writes a query re-run with a sort (`docs/decisions/0007-sorting-a-result.md`), picks the statement at a caret with the session's grammar (`statement_at`), says what completes at a caret for an editor in one of the server's databases as a `CompletionList` that ranks again for each word typed, read from the catalog the other views share (`complete`, over `tablepro_core::sql_syntax::completion` and `tablepro_session::completion`), says what Safe Mode lets an editor run do at the session's level and takes a level saved while it is open (`gate_run`, over `SafeModeLevel::gate`, and `set_safe_mode`), reports and waits on the session's health, opens a `QueryEditor`, and opens a `TableEditor`, which plans a table tab's typed edits into a `RowSave` and runs it (`docs/decisions/0019-row-edits-through-the-ffi.md`). `QueryEditor::run` returns a `QueryRun` at once; the app drains its events after a `RunListener` call, which comes only when no earlier one is waiting to be drained, and the last says which transaction the editor is left in. Each result set is a `ResultSet`, whose `sorted` gives the rows it holds in a column's order.
- `Core::open_account` opens the TablePro account as an `AccountService`, whose `AccountListener` only signals that `status()` changed. It also shares links: `create_share` builds a result's snapshot from a `ResultSet` in Rust, and a table page's `view_sql` is the query its view stands for ([ADR 0027](docs/decisions/0027-share-links.md)). `create_share` takes the share sheet's Keep, Mask or Remove for each column, and `ResultSet::share_masking`, `share_preview` and `share_summary` start the sheet's columns from the detectors and show and count what a share sends ([ADR 0028](docs/decisions/0028-data-masking.md)). `scan_sql_for_secrets`, `scan_columns_for_secrets`, `scan_sql_for_personal_data` and `share_token_from_link` are functions of their own. So are `format_sql` and `format_sql_selection`, which reformat a script or a selection through `tablepro_core::sql_syntax::format` and keep a statement as typed where the formatter would change its tokens.
- `Core::open_sync` gives a `SyncService` over an `AccountService`: the status, a pass now, the provider and the moves between providers, the approvals, the team conflicts, the held records, the history window and every key flow a person starts ([0054](docs/decisions/0054-one-sync-engine-in-the-core-for-tablepro-sync-and-icloud.md), [0056](docs/decisions/0056-end-to-end-keys-per-account-and-device.md)). Its `SyncListener` only signals that the status or the keys changed. `CloudKitTransport` is an async foreign trait (`uniffi::export(with_foreign)`), and `HostSettings`, `HostDeviceStore` and the Mac's `HostLegacyMirror`, which reads and writes the Swift engine's metadata while the previous stable runs it, are callback interfaces.
- `Core::ai_assistant` gives an `AiAssistant` over the core's one AI client and its secret store: it says whether a provider's key is kept and keeps or removes one (the key never crosses back), lists the provider's models, reads a session's catalog into the system prompt of a conversation (`start_conversation`), and streams a reply as an `AiReply`, drained after an `AiReplyListener` call as a run is. Both refuse a saved connection whose AI policy is Never with `ai.blocked`; asking under Ask is the app's ([ADR 0032](docs/decisions/0032-ai-through-the-ffi.md)).
- `Core::mcp_server` gives an `McpService` that runs the MCP server on the sessions `connect_saved` opened, keeps its token in the Core's secret store, and asks the app to open a connection or approve a write through `McpAppHost`; `McpListener` only signals that `status()` or `seen_clients()` changed. The package also builds `tablepro-cli`, the Windows package's command ([0036](docs/decisions/0036-mcp-and-the-command-line-through-the-ffi.md)).
- `Core::foreign_sources(dirs, depth)` lists the other apps over `tablepro_foreign_import::sources_blocking`, each with its availability (`Unreadable` with a code when its data is there and cannot be read), password offer, and whether it starts ticked or preselected; `ScanDepthTag::Presence` reads no count. `ForeignImportReview::apply` returns the ids it wrote in `ForeignImportOutcome.connection_ids` ([0057](docs/decisions/0057-a-setup-guide-shows-on-an-empty-library.md)). `keymap_preset(id, platform)` and `keymap_presets(platform)` read `tablepro_core::keymap` for the platform named, never the build target ([0058](docs/decisions/0058-shortcut-presets-from-one-file.md)).
- The grid reads a `ResultSet` through the C ABI in `src/window_abi.rs`: `tablepro_cursor_fetch` packs the display text of one visible range, and `tablepro_cursor_free` ends the cursor. The editor reads SQL there from its own UTF-16 text: `tablepro_syntax_tokens` gives the highlight tokens, and `tablepro_script_statements` every statement as `ScriptPlan` splits the text for `statement_at` and the drivers.
- The library owns one tokio runtime. Each async export runs on it and is aborted when the foreign side drops the call; a `CancelToken` stops it sooner, since UniFFI cannot cancel.
- A result set takes rows as the driver reads them. Each column keeps a kind byte, a raw `i64` and the exact text `tablepro_core::export::value_text` writes, or a binary value's bytes, in chunks of 65,536 rows. A window only cuts and copies.
- A `CoreError` carries the `code()` of each error from the outermost in; the innermost decides.
- A secret crosses as the `SecretString` custom type, a `String` to the app, so Rust holds it in `secrecy` from the lift and wipes it on drop. Still plain: the serialized buffer UniFFI frees for a record, enum, option or callback answer that carries one; for a secret going to the app (`HostSecrets::store` and `store_item`, `ParsedConnectionUrl.password`), the `String` lowered and its buffer; every string the app holds, which the generated C# records also print in full. The blob Credential Manager hands back is wiped before `CredFree`.
- A secret crosses as the `SecretString` custom type, a `String` to the app, so Rust holds it in `secrecy` from the lift and wipes it on drop. Still plain: the serialized buffer UniFFI frees for a record, enum, option or callback answer that carries one; for a secret going to the app (`HostSecrets::store` and `store_item`, `ParsedConnectionUrl.password`), the `String` lowered and its buffer; the device keys, account keys and anchor items `HostDeviceStore` loads and stores, which cross as plain bytes, wrapped in `Zeroizing` only once back in Rust; every string the app holds, which the generated C# records also print in full. The blob Credential Manager hands back is wiped before `CredFree`.

How the bindings are generated, and where they live: `windows/AGENTS.md`, Bindings, for C#, and `apple/AGENTS.md`, Repository map, for Swift.

Expand Down
Loading
Loading