Repository navigation
style: format the workspace with rustfmt (max_width 120) - #86
Merged
Merged
Conversation
Adds `rustfmt.toml` (`max_width = 120`, `use_small_heuristics = "Max"`, stable options only) and runs `cargo fmt --all` once over the workspace. This is the baseline that issue #40's `cargo fmt --all --check` step needs: the tree was not rustfmt-clean (991 hunks in 99 files at b1c9d1f under this config; about twice that at rustfmt's defaults, which wrap at 100 columns where this code was hand-wrapped to about 120). No behaviour change; formatting only. 98 `.rs` files changed (the 99th file the check named is `thrust-core/tests/common/mod.rs` reached again through a `#[path]` include). The two generated files, `thrust-core/src/{reserved_slugs,timezones}.rs`, were already clean and are untouched, so their generators need no change. Checked on the formatted tree: - `cargo fmt --all --check` exits 0, and no file other than `*.rs` and `rustfmt.toml` changed; - `cargo nextest run --profile ci --workspace`: 2213 passed, 4 skipped, 0 failed; - `cargo test --doc --workspace`: 3 passed, 0 failed; - `thrust-worker` builds for wasm32 with `--no-default-features`; - `scripts/check-deps.sh` is clean. Rust `file:line` citations in the docs and ADRs now point a few lines off. A branch with Rust changes in flight should rebase and run `cargo fmt --all` again. The merge commit of this change goes into `.git-blame-ignore-revs` with the rest of issue #40. Refs: #40 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
6 tasks done
aRustyDev
added a commit
that referenced
this pull request
Nov 6, 2026
…id ORM crates workspace-wide (#87) * chore(ci): forbid ORM crates workspace-wide; classify lint configs as Rust check-deps.sh: ADR-0044 forbids sqlx, sea-orm and diesel, but the script named only `sqlx`, and only for five crates, the memory adapter and oidc. Nothing stopped an ORM in adapters-postgres, -cloudflare, -selfhosted, the server or the worker. The new section asks the whole workspace: `cargo tree --workspace --all-features -e all --target all -i <crate>` for sqlx, sea-orm, diesel and diesel-async. It has three answers: absent, present (the tree starts with the crate), and "cargo could not answer" (offline, a stale lock), which fails with its own message instead of being read as absent or as a hit. `-e all`, not the issue's `-e normal`: with `sea-orm` as a `[dev-dependencies]` of adapters-postgres, `-e normal` prints `nothing to print`, which the script's case arm reads as absent (a pass), and `-e all` finds it. Both outputs were taken against the same tree. Controls, run against this script: - clean tree: exit 0, four `ok:` lines; - `sea-orm = { version = "1", default-features = false }` in adapters-postgres: exit 1, `FORBIDDEN: sea-orm is in the workspace graph (ADR-0044)` with the tree `sea-orm v1.1.20 └── thrust-adapters-postgres`, no ERROR line. classify-changes.sh: deny.toml, clippy.toml and rustfmt.toml were not Rust paths, so a PR that changed only one of them would have classified as docs, skipped the lint and deny jobs and passed the gate without running them. Five new cases in test-ci-scripts.sh: three that failed against the old regex (shown red, then green), a look-alike or nested copy that must stay `rust=false`, and two gate cases (a `lint` failure; `deny` skipped when Rust changed). 29 passed, 0 bad; test-required-contexts.sh 14 passed. assert-gate.sh needs no change: it reads `toJSON(needs)` generically, so only the `needs:` list in ci.yml changes (a later commit). Refs: #40 Co-Authored-By: Claude Sonnet 5.5 <[email protected]> * chore(deps): fix the advisories cargo-deny finds on main `cargo deny check` (the next commits) fails on main today with five vulnerabilities besides RUSTSEC-2023-0071, found against the live RustSec database (advisories published after #40 was drafted). The issue requires that 0071 be the only ignore, so each is fixed by upgrading, not ignored: | Advisory | Crate | Change | |---|---|---| | RUSTSEC-2026-0382 | rustls-webpki | 0.103.15 -> 0.103.16 | | RUSTSEC-2026-0381 | webpki-roots | 1.0.9 -> 1.0.11 | | RUSTSEC-2026-0385 | ctutils | 0.4.3 -> 0.4.8 | | RUSTSEC-2026-0387 | crypto-bigint | 0.5.5 -> 0.7.10, through openidconnect 4.0.1 -> 4.1.0 (p256, p384 and ed25519-dalek move a major) | | RUSTSEC-2025-0111 | tokio-tar | removed: testcontainers 0.23 -> 0.27 and testcontainers-modules 0.11 -> 0.15 use astral-tokio-tar | The same testcontainers upgrade removes rustls-pemfile (RUSTSEC-2025-0134, unmaintained) from the graph. The other unmaintained crate, smallstr under yrs (RUSTSEC-2026-0215), has no upstream fix; deny.toml reports unmaintained crates for the workspace's own dependencies only. The testcontainers upgrade needed no code change (`Postgres::default().start()`, `get_host_port_ipv4`, `ContainerAsync<Postgres>` are unchanged) and both versions default to `postgres:11-alpine`. It adds dev-only crates (tonic, prost, ureq, h2) through bollard's buildkit support, and removes the windows-sys 0.48 family. Checked on this tree: - `cargo deny check` (with the deny.toml of a later commit): advisories, bans, licenses and sources ok; - the Postgres adapter tests, run as CI runs them (`cargo test -p thrust-adapters-selfhosted --test pg_adapter`, OrbStack DOCKER_HOST): 30 passed; also under nextest: 30 passed; - `cargo nextest run --profile ci --workspace`: 2213 passed, 4 skipped; - the native-memory contract pass, which signs RS256 ID tokens in the mock IdP and verifies them through openidconnect 4.1.0: 54 of 54 expected, 16 of them `auth::`; - `thrust-worker` builds for wasm32 with `--no-default-features`; `scripts/check-deps.sh` is clean. Refs: #40 Co-Authored-By: Claude Sonnet 5.5 <[email protected]> * chore(ci): add deny.toml for cargo-deny (advisories, licences, bans, sources) ADR-0100 and ADR-0101 require a Rust supply-chain gate and none ran. `deny.toml` is the configuration; the `deny` job that runs it is a later commit. `cargo deny --locked check`: advisories, bans, licenses and sources ok on this tree. - [advisories]: RUSTSEC-2023-0071 (rsa, "Marvin Attack") is the ONLY ignore, with its reason and the re-check note beside it: why it does not apply (rsa is reached through openidconnect, which uses it only to verify RS256 signatures with the issuer's public key, `verify_rsa_signature` building an `rsa::RsaPublicKey`; Thrust's one call is `.claims(..)` in thrust-adapters-oidc; and through the contract tests' mock IdP, a throwaway key on 127.0.0.1); when to re-check (any rsa or openidconnect update, a patched advisory); to remove it once a patched rsa is adopted; the tripwire (`CoreRsaPrivateSigningKey`, which signs with an `RsaPrivateKey`, is shipped by openidconnect and never constructed by Thrust); and that RS256 is not to be avoided (owner decision, 2026-10-24: Zitadel signs with it). The claims were checked against the openidconnect 4.1.0 source. `unmaintained = "workspace"`: smallstr (under yrs, RUSTSEC-2026-0215) has no fix to adopt, so unmaintained crates are reported for the workspace's own dependencies only; vulnerabilities are reported everywhere. - [licenses]: the eight licences the graph needs (MIT, Apache-2.0, BSD-3-Clause, ISC, Unicode-3.0, Zlib, MPL-2.0, CDLA-Permissive-2.0), each exercised (no unused-licence warning); the 15 workspace crates are AGPL-3.0-only and `publish = false`, so `[licenses.private] ignore = true` skips them and AGPL is not on the list for anybody else. - [bans]: sqlx, sea-orm, diesel and diesel-async (ADR-0044; the second guard after check-deps.sh); `wildcards = "deny"` with `allow-wildcard-paths` for the thrust-* path dependencies; `multiple-versions = "warn"` because 28 crates appear in two or three versions and "deny" would block every update. - [sources]: crates.io only. - [graph] `all-features = true`, so a bare `cargo deny check` sees what CI sees. Controls, each run against this tree: - delete the RUSTSEC-2023-0071 entry: `advisories FAILED`, `error[vulnerability]: Marvin Attack`, `rsa v0.9.10`. With the entry it passes, so the ignore is what makes the check pass and the advisory is really in the graph; - remove `MPL-2.0` from `allow`: `error[rejected]: failed to satisfy license requirements`, `cssparser v0.38.0` (exit code 4, the licences bit); - add `sea-orm` to thrust-adapters-postgres: `error[banned]: crate 'sea-orm = 1.1.20' is explicitly banned` (exit code 2, the bans bit); - the same `sea-orm` as an optional dependency behind a feature that nothing enables: `bans FAILED` with `all-features = true` and `bans ok` with `false`, so the setting is what catches it. (The default and all-features graphs are identical today, 419 crates each, because `--workspace` unifies features, so this guards a future change. check-deps.sh catches the same case.) Refs: #40 Co-Authored-By: Claude Sonnet 5.5 <[email protected]> * chore(lint): deny unwrap, expect, panic and indexing in core, ports and the adapters ADR-0006's panic policy says clippy denies `unwrap_used`, `expect_used`, `panic` and `indexing_slicing` in core, ports and adapters, and recorded it as "not yet enforced". On the Worker (`panic=abort`) a panic fails its own request and can fail others on the same isolate. `[workspace.lints.clippy]` sets the four to `deny` (they are in clippy's `restriction` group, off unless named); thrust-core, thrust-ports and all five adapters (the issue says four; thrust-adapters-oidc arrived after it was filed) opt in with `[lints] workspace = true`. `deny`, not `forbid`, so a site that is right can say so with `#[allow(.., reason = "..")]`. `clippy.toml` exempts `#[test]` functions and `#[cfg(test)]` modules. Measured on the formatted tree, in the seven crates: 93 sites in library code, 6 in the `migrate` bin and a core example, and 261 in integration tests that `clippy.toml` does not exempt (helper functions with no `#[test]`: selfhosted `tests/model` alone has 161 index sites). Now 0 in all targets. Library code: - thrust-adapters-memory: 75 `Mutex::lock().unwrap()` become one private `lock_unpoisoned()` (`unwrap_or_else(PoisonError::into_inner)`). Its doc comment gives the reasoning: the adapter is test and local state; a Worker cannot poison a mutex (`panic=abort`); the native server unwinds under `CatchPanicLayer`, and carrying on is what `parking_lot` does. `from_timestamp(0, 0).expect(..)` is `DateTime::UNIX_EPOCH`. `api_keys[at]` keeps a reasoned allow: `at` is a position found a few lines above. - thrust-adapters-postgres, BEHAVIOUR CHANGE: `PgTx::client` panicked ("transaction already finished") whenever the transaction had no connection, and `ensure_tx` removes it deliberately when `BEGIN` fails. So a failed first write followed by any further call on the same transaction, or by `commit`, was a reachable panic. `client()` now returns `DbError::Backend`, `commit` on such a transaction returns the same error (it cannot claim success), and `rollback` returns Ok (the discarded connection was closed, so the server has rolled it back). Three hermetic tests pin it; with the old `expect` code back they all fail at the old panic sites (`lib.rs:2174`, `:2358`, `:2375`). `columns[4..]` is one `.get(4..)`. - thrust-adapters-postgres `migrate`: `main` returns a `Result` instead of three `expect`s. A failure exits 1 with an `Error:` line, where it was a panic with exit 101; `contract.sh` treats any non-zero as "migrate failed". - thrust-adapters-cloudflare: the two lock unwraps recover from poison inline. `JsClock::now` keeps a reasoned `expect`: the port returns no error, and a fallback such as the epoch would make every session expiry look far off, so a clock that cannot be read must fail the request. - thrust-adapters-selfhosted: `ReqwestFetch::new` keeps a reasoned `expect` (a fixed configuration, built once at startup). - thrust-core: `hex` writes `{b:02x}` instead of indexing a digit table (same lower-case output), and `contains_url` uses `at(i)` and a slice pattern instead of `s[i]` and `w[0]..w[3]`. - Tests and the example: 21 test files and `argon2_timing.rs` carry an `#![allow(..., reason = "test code: ..")]` at their top. The `lint` job runs clippy with `-D warnings`, which brought 47 warnings of other lints in; they are fixed here, not allowed: `cargo clippy --fix` applied the mechanical ones (sort_by_key, map_or, is_multiple_of, redundant closures, unused imports, needless borrows), and by hand the `Reverse` sorts, an enum variant named for its enum (`Call::UpdateProjectCall` -> `UpdateProject`), a type alias, two `zip`s, `matches!`, doc-list indentation, and four sites in thrust-editor-doc (`?`, `if let`, `Option::filter`, `iter_mut`). One `too_many_arguments` (`put_attachment`, eight parameters) keeps a reasoned allow, as a public use-case entry point. Checked on this tree: `cargo fmt --all --check`; `cargo clippy --workspace --all-targets --locked -- -D warnings` and `cargo clippy -p thrust-worker --no-default-features --target wasm32-unknown-unknown --locked -- -D warnings` (0 diagnostics); nextest 2216 passed, 4 skipped (2213 before the three new tests, with every fix in); the Postgres adapter tests (30 passed) as CI runs them; the native-memory and native-pg contract passes (54 of 54 each). Refs: #40 Co-Authored-By: Claude Sonnet 5.5 <[email protected]> * chore(ci): run rustfmt, clippy and cargo-deny, and gate on them Two new jobs, both added to `gate`'s `needs` (the only required check): - `lint`: `cargo fmt --all --check`; `cargo clippy --workspace --all-targets --locked -- -D warnings` (every target of every member, so the four denied lints, ADR-0006's panic policy, and every other warning fail it); and `cargo clippy -p thrust-worker --no-default-features --target wasm32-unknown-unknown --locked -- -D warnings`, the Worker as it ships (no `memory` adapter set), which also lints the wasm-only adapters. Without `--no-deps`, so the path dependencies are linted for wasm32 too. The two clippy steps run even when rustfmt failed (`!cancelled()`), so one push reports everything. - `deny`: `cargo deny --locked check` from deny.toml (advisories, licences, bans, sources), with cargo-deny 0.20.2 installed through the `taiki-e/install-action` already pinned by SHA for nextest (its manifest at that SHA has 0.20.2). Both carry exactly `needs: changes` and `if: needs.changes.outputs.rust == 'true'`, like `deps`: assert-gate.sh fails a job that is `skipped` when Rust changed, so an extra condition (a pull_request-only job, say) would turn the gate red on main and in the merge queue. assert-gate.sh itself needs no change, because it reads `toJSON(needs)` generically. `.github/actions/setup-rust` gains a `components` input, passed to dtolnay/rust-toolchain, which installs the toolchain without clippy or rustfmt. Both new jobs use setup-rust with their own cache key. Neither is added to the ruleset: it requires only `gate` (ruleset 25418178), and they reach it through `gate`'s `needs`. Checked: the workflow and the action parse; a script asserts that both jobs `need` only `changes`, share `deps`'s `if`, run on ubuntu-24.04 with `contents: read`, pin every external action by SHA, that `gate.needs` equals every job but `gate`, and that setup-rust passes `components` through. Run against the files before this commit it fails with six named reasons, so it discriminates. Refs: #40 Co-Authored-By: Claude Sonnet 5.5 <[email protected]> * docs: record the lint, deny and ORM gates, and the reformat's blame-ignore entry The book said clippy, rustfmt and the dependency audit were not in CI ("Not in CI" in cicd.md, "no `deny.toml`", "nothing runs `cargo fmt`"). They are now, so the pages that state what is enforced say so, each with its command and the control that makes it fail. - cicd.md: "Not in CI" no longer names clippy, fmt or the audit. The change classifier's path list has deny.toml, clippy.toml and rustfmt.toml. The counts are re-measured (21 external actions, all pinned by SHA; 12 checkouts, all with `persist-credentials: false`), and `deny.toml` and the advisory-drift behaviour are recorded under supply chain. The ADR-0100 and ADR-0101 comparisons say what is now in place (a lint step; one of the Rust gates, cargo-deny) and what is not (cargo-vet and cargo audit, Scorecard, attestation, trivy). It also says the unpinned `stable` toolchain means a new clippy release can fail `lint` with no change to the code. - running.md: the `lint` and `deny` rows of the CI job table, and the commands with `[verified]` tags. - standards.md: three new rows in "Enforced by a command" (rustfmt, the panic lints, cargo-deny), the ORM ban in the check-deps row, and the controls shown on 2026-11-05. The "Stated, but not enforced" rows for dependency licences and for format and lint are corrected or gone, and "Decided, and built only in part" no longer says there is no lint step or dependency audit. - architecture-gates.md: the ORM check, what its three answers mean, and the `sea-orm` control next to the `worker` one, with the two variants that justify `-e all` and `--all-features`. - crates.md: "13 crates" is 15 and "four adapter crates" is five (both stale before this change); a new step for opting a crate into the lints. - defect-matrix.md: X10's target says what `cargo deny` does and does not do yet (it bans only the ORM crates). - AGENTS.md: one row in the Commands table. - `.git-blame-ignore-revs` lists the reformat (65ed0e5, #86). Checked: `git blame` on thrust-ports/src/lib.rs blames 41 lines on it without the file and 0 with it. GitHub's blame view reads the file by itself. - ADR-0006, Q-0044, research/0012 and ADR-0044 state the old gap. They are records, so each gets a dated `*(amended 2026-11-05: ..)*` note in the repo's existing style and its original text is left as written. Checked: `mdbook build docs` has 0 `^ERROR` lines (run with the mermaid preprocessor made optional by environment variable, because mdbook-mermaid is not installed here; nothing was written under docs/), and a search of docs/src finds no remaining claim that clippy, rustfmt or the dependency audit is absent, and no mention of them outside the pages edited here. Refs: #40 Co-Authored-By: Claude Sonnet 5.5 <[email protected]> --------- Co-authored-by: Claude Sonnet 5.5 <[email protected]>
This was referenced Nov 15, 2026
Closed
Merged
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.
What
Prerequisite for #40. Adds
rustfmt.toml(max_width = 120,use_small_heuristics = "Max", stable options only) and runscargo fmt --allonce. Formatting only, no behaviour change. The follow-up PR for #40 adds thelintjob that runscargo fmt --all --check, which needs the tree to be clean first.Why a separate PR
The repo squash-merges, so a reformat folded into the #40 PR could never be named in
.git-blame-ignore-revs. Landing it alone givesthat file a real SHA, and gives every in-flight branch one rebase point.
Why these settings
The tree was not rustfmt-clean: 991 hunks in 99 files at
b1c9d1funder this config, and about twice that at rustfmt's defaults. Thecode was hand-wrapped to about 120 columns, and rustfmt's default width of 100 would have re-wrapped most long lines.
max_width = 120with
use_small_heuristics = "Max"is the closest stable configuration to the existing style.Review guidance
.rsfiles plusrustfmt.toml; nothing else changed (git diff --stathas no other path).crates/thrust-core/src/reserved_slugs.rsandtimezones.rs(written bytools/compat-record/gen-*.py), were already clean and are untouched, so their generators need no change.git diff -wwill not help much (the changes are re-wrapping); the check is thatcargo fmt --all --checkpasses and the tests do.Verification (on the formatted tree, local)
cargo fmt --all --checkcargo nextest run --profile ci --workspacecargo test --doc --workspacecargo build -p thrust-worker --no-default-features --target wasm32-unknown-unknownscripts/check-deps.shCI runs the full suite on this PR.
Heads-up for open branches
Rust
file:linecitations in the docs and ADRs now point a few lines off. A branch with Rust changes in flight (for examplefeat/compat-work-items-stage,feat/compat-work-items-update-history) will conflict on rebase: rebase, then runcargo fmt --allagain.Refs #40
🤖 Generated with Claude Code