mirror of
https://github.com/rustfs/rustfs.git
synced 2026-09-03 02:38:12 +00:00
fix(guards): catch dotted-form leaf deps, pin madmin to rustfs-signer (#6692)
fix(guards): catch dotted-form leaf deps; pin madmin to rustfs-signer
This commit is contained in:
+7
-5
@@ -115,11 +115,13 @@ default build (lifecycle:
|
|||||||
1. **Layers flow downward.** Server → Admin/App → Storage → ecstore → rio/io-core.
|
1. **Layers flow downward.** Server → Admin/App → Storage → ecstore → rio/io-core.
|
||||||
No upward imports.
|
No upward imports.
|
||||||
|
|
||||||
2. **Leaf crates depend only on external crates, with one adjudicated exception.**
|
2. **Leaf crates depend only on external crates, with adjudicated exceptions
|
||||||
`config`, `credentials`, `crypto`, `io-metrics`, and `madmin` take no internal
|
pinned by a guard.** `config`, `credentials`, and `crypto` take no internal
|
||||||
dependency except `io-metrics → rustfs-s3-ops` (transitively `rustfs-s3-types`),
|
dependency. `io-metrics` takes exactly `rustfs-s3-ops` (transitively
|
||||||
a pure contract crate with no I/O and no global state. Adjudicated in
|
`rustfs-s3-types`), a pure contract crate with no I/O and no global state —
|
||||||
rustfs/backlog#1834 and pinned by the leaf allowlist in
|
adjudicated in rustfs/backlog#1834. `madmin` left the leaf set when #6166 made
|
||||||
|
it the SigV4-signed admin SDK client; its internal dependency surface is pinned
|
||||||
|
to exactly `rustfs-signer`. Both pins live in the leaf allowlist in
|
||||||
`scripts/check_architecture_migration_rules.sh`; any other internal dependency
|
`scripts/check_architecture_migration_rules.sh`; any other internal dependency
|
||||||
fails the guard ([crate boundaries](docs/architecture/crate-boundaries.md)).
|
fails the guard ([crate boundaries](docs/architecture/crate-boundaries.md)).
|
||||||
- ✅ RESOLVED: the historical `utils → config` and `common → filemeta`/`madmin`
|
- ✅ RESOLVED: the historical `utils → config` and `common → filemeta`/`madmin`
|
||||||
|
|||||||
@@ -39,14 +39,18 @@ Leaf crates carry exactly one adjudicated allowed edge:
|
|||||||
`io-metrics -> rustfs-s3-ops` (transitively `rustfs-s3-types`). Both are pure
|
`io-metrics -> rustfs-s3-ops` (transitively `rustfs-s3-types`). Both are pure
|
||||||
contract crates — types and enums only, no I/O, no global state, no non-contract
|
contract crates — types and enums only, no I/O, no global state, no non-contract
|
||||||
internal dependencies — so `io-metrics` reuses the `S3Operation` vocabulary
|
internal dependencies — so `io-metrics` reuses the `S3Operation` vocabulary
|
||||||
instead of copying it. The allowance covers that edge and nothing else: the
|
instead of copying it. `madmin` is no longer counted a leaf: since #6166 it is
|
||||||
leaf-crate allowlist in `scripts/check_architecture_migration_rules.sh` fails any
|
the SigV4-signed admin SDK client and deliberately depends on `rustfs-signer`;
|
||||||
other `rustfs-*` dependency in `config`, `credentials`, `crypto`, `io-metrics`,
|
the guard pins its internal dependency surface to exactly that edge so it cannot
|
||||||
or `madmin`. Adjudicated in
|
quietly grow storage-side dependencies. The leaf-crate allowlist in
|
||||||
|
`scripts/check_architecture_migration_rules.sh` fails any other `rustfs-*`
|
||||||
|
dependency in `config`, `credentials`, `crypto`, `io-metrics`, or `madmin`, in
|
||||||
|
either TOML spelling (`rustfs-x = ...` or `rustfs-x.workspace = true`).
|
||||||
|
Adjudicated in
|
||||||
[`rustfs/backlog#1834`](https://github.com/rustfs/backlog/issues/1834); a further
|
[`rustfs/backlog#1834`](https://github.com/rustfs/backlog/issues/1834); a further
|
||||||
exception must meet the same criterion — pure contract crate, no I/O, no globals,
|
leaf exception must meet the pure-contract criterion — types and enums only, no
|
||||||
no non-contract internal dependencies — and land its guard allowlist entry
|
I/O, no globals, no non-contract internal dependencies — and land its guard
|
||||||
alongside the dependency.
|
allowlist entry alongside the dependency.
|
||||||
|
|
||||||
Dependency direction also applies to compile-time source reads:
|
Dependency direction also applies to compile-time source reads:
|
||||||
`include_str!`/`include!` of a `.rs` file must not resolve outside the
|
`include_str!`/`include!` of a `.rs` file must not resolve outside the
|
||||||
|
|||||||
@@ -5452,13 +5452,17 @@ require_source_contains \
|
|||||||
"SetDisks storage-api HealOperations compile-time coverage test"
|
"SetDisks storage-api HealOperations compile-time coverage test"
|
||||||
|
|
||||||
# --- Leaf crates must stay free of internal dependencies (backlog#1834) ---
|
# --- Leaf crates must stay free of internal dependencies (backlog#1834) ---
|
||||||
# ARCHITECTURE.md invariant 2 names config, credentials, crypto, io-metrics,
|
# ARCHITECTURE.md invariant 2 names config, credentials, crypto, and io-metrics
|
||||||
# and madmin as leaf crates that depend only on external crates. Allowlist:
|
# as leaf crates that depend only on external crates. Allowlist:
|
||||||
# io-metrics -> rustfs-s3-ops. That edge is DECIDED in backlog#1834: allowed as a
|
# io-metrics -> rustfs-s3-ops. That edge is DECIDED in backlog#1834: allowed as a
|
||||||
# pure-contract-crate exception (types/enums only, no I/O, no globals, no
|
# pure-contract-crate exception (types/enums only, no I/O, no globals, no
|
||||||
# non-contract internal deps), narrowed to exactly this edge. Adding any other
|
# non-contract internal deps), narrowed to exactly this edge.
|
||||||
# rustfs-* dependency to a leaf crate needs its own adjudication, not a quiet
|
# madmin left the leaf set when #6166 made it the SigV4-signed admin SDK client;
|
||||||
# Cargo.toml edit.
|
# its internal dependency surface is pinned to exactly rustfs-signer so it cannot
|
||||||
|
# quietly grow storage-side dependencies. Adding any other rustfs-* dependency to
|
||||||
|
# any of these five crates needs its own adjudication, not a quiet Cargo.toml edit.
|
||||||
|
# The pattern matches both TOML dependency spellings: `rustfs-x = ...` and the
|
||||||
|
# dotted `rustfs-x.workspace = true` form (which previously escaped this guard).
|
||||||
LEAF_CRATE_DEP_HITS_FILE="${TMP_DIR}/leaf_crate_dep_hits.txt"
|
LEAF_CRATE_DEP_HITS_FILE="${TMP_DIR}/leaf_crate_dep_hits.txt"
|
||||||
: >"$LEAF_CRATE_DEP_HITS_FILE"
|
: >"$LEAF_CRATE_DEP_HITS_FILE"
|
||||||
(
|
(
|
||||||
@@ -5467,20 +5471,26 @@ LEAF_CRATE_DEP_HITS_FILE="${TMP_DIR}/leaf_crate_dep_hits.txt"
|
|||||||
manifest="crates/${leaf}/Cargo.toml"
|
manifest="crates/${leaf}/Cargo.toml"
|
||||||
[[ -f "$manifest" ]] || continue
|
[[ -f "$manifest" ]] || continue
|
||||||
leaf_dep_status=0
|
leaf_dep_status=0
|
||||||
rg -n --with-filename '^rustfs-[a-z0-9-]+ *=' "$manifest" >"${TMP_DIR}/leaf_dep_raw.txt" || leaf_dep_status=$?
|
rg -n --with-filename '^rustfs-[a-z0-9-]+(\.[a-zA-Z_-]+)* *=' "$manifest" >"${TMP_DIR}/leaf_dep_raw.txt" || leaf_dep_status=$?
|
||||||
if [[ "$leaf_dep_status" -ne 0 && "$leaf_dep_status" -ne 1 ]]; then
|
if [[ "$leaf_dep_status" -ne 0 && "$leaf_dep_status" -ne 1 ]]; then
|
||||||
exit "$leaf_dep_status"
|
exit "$leaf_dep_status"
|
||||||
fi
|
fi
|
||||||
if [[ "$leaf" == "io-metrics" ]]; then
|
case "$leaf" in
|
||||||
rg -v '^[^:]*:[0-9]+:rustfs-s3-ops *=' "${TMP_DIR}/leaf_dep_raw.txt" >>"$LEAF_CRATE_DEP_HITS_FILE" || true
|
io-metrics)
|
||||||
else
|
rg -v '^[^:]*:[0-9]+:rustfs-s3-ops(\.[a-zA-Z_-]+)* *=' "${TMP_DIR}/leaf_dep_raw.txt" >>"$LEAF_CRATE_DEP_HITS_FILE" || true
|
||||||
cat "${TMP_DIR}/leaf_dep_raw.txt" >>"$LEAF_CRATE_DEP_HITS_FILE"
|
;;
|
||||||
fi
|
madmin)
|
||||||
|
rg -v '^[^:]*:[0-9]+:rustfs-signer(\.[a-zA-Z_-]+)* *=' "${TMP_DIR}/leaf_dep_raw.txt" >>"$LEAF_CRATE_DEP_HITS_FILE" || true
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
cat "${TMP_DIR}/leaf_dep_raw.txt" >>"$LEAF_CRATE_DEP_HITS_FILE"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
done
|
done
|
||||||
)
|
)
|
||||||
|
|
||||||
if [[ -s "$LEAF_CRATE_DEP_HITS_FILE" ]]; then
|
if [[ -s "$LEAF_CRATE_DEP_HITS_FILE" ]]; then
|
||||||
report_failure "leaf crates (config/credentials/crypto/io-metrics/madmin) must not depend on internal rustfs-* crates (sole adjudicated exception, decided in backlog#1834: io-metrics -> rustfs-s3-ops, a pure contract crate; any new edge needs its own adjudication): $(paste -sd '; ' "$LEAF_CRATE_DEP_HITS_FILE")"
|
report_failure "leaf/pinned-dep crates: config/credentials/crypto take no internal rustfs-* dependency; io-metrics only rustfs-s3-ops (pure contract crate, backlog#1834); madmin only rustfs-signer (admin SDK SigV4 client, #6166); any new edge needs its own adjudication: $(paste -sd '; ' "$LEAF_CRATE_DEP_HITS_FILE")"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# --- ecstore module-level lint blankets (backlog#1823 step 9) ---
|
# --- ecstore module-level lint blankets (backlog#1823 step 9) ---
|
||||||
|
|||||||
Reference in New Issue
Block a user