Skip to content

Add mctp-rs as in-tree workspace member (port of dymk/mctp-rs @ 3d941ba) - #823

Merged
dymk merged 5 commits into
OpenDevicePartnership:v0.2.0from
dymk:dymk/phase-31-mctp-rs-in-tree
May 6, 2026
Merged

dymk merged 5 commits into
OpenDevicePartnership:v0.2.0from
dymk:dymk/phase-31-mctp-rs-in-tree

Conversation

@dymk

@dymk dymk commented May 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Imports dymk/mctp-rs as an in-tree workspace member at mctp-rs/ and flips the existing [workspace.dependencies] git pin to a path dep. The imported source is at SHA 3d941ba5205ca7781bf37e3dc7c5dfdc99a082d6, which matches the pre-edit Cargo.lock pin exactly — so all four mctp-rs consumers (uart-service, espi-service, embedded-service, plus its macro re-exports) compile and test unchanged.

What changed

  • New mctp-rs/ directory: snapshot copy of dymk/mctp-rs main @ 3d941ba source. No git history preserved.
  • Root Cargo.toml: "mctp-rs" appended to [workspace] members; mctp-rs = { git = "..." } replaced with mctp-rs = { path = "./mctp-rs" }.
  • Cargo.lock regenerated.
  • mctp-rs/Cargo.toml: dropped cargo-husky from [dev-dependencies] (its build script searches for .cargo-husky/hooks/ at the workspace root, which is now this repo, not the crate).
  • mctp-rs/rustfmt.toml removed; source reformatted under this repo's rustfmt.toml (max_width = 120).
  • Excluded from the copy: .cargo-husky/, .github/, .vscode/, source Cargo.lock, source .gitignore. A follow-up PR will add the dedicated mctp-rs CI workflow.

Why

mctp-rs lived in a personal fork and was already consumed here via a git pin. Bringing it in-tree as a sibling of uart-service etc. removes a layer of cross-repo indirection and lets future changes flow through normal workspace PR review. SHA 3d941ba was chosen specifically because it matches the consumer pin — so this PR has zero behavioral surface.

The mctp-rs repo holds further commits beyond 3d941ba that change the MctpMedium API. Those, together with the corresponding consumer updates and the eventual archival of the personal fork, land in a separate PR after this one.

Verifying locally

git fetch origin dymk/phase-31-mctp-rs-in-tree
git switch dymk/phase-31-mctp-rs-in-tree

cargo build --workspace
cargo test --workspace                 # 178 pass / 0 fail
cargo fmt --all --check                # clean
cargo clippy --workspace --all-targets -- -D warnings   # clean

Spot-check the source is byte-identical to upstream:

git -C <local-clone-of-dymk/mctp-rs> show 3d941ba:src/lib.rs           | diff - mctp-rs/src/lib.rs
git -C <local-clone-of-dymk/mctp-rs> show 3d941ba:src/medium/smbus_espi.rs | diff - mctp-rs/src/medium/smbus_espi.rs

(Both empty diffs, modulo the rustfmt-style reflow noted above for the second one.)

Notes for reviewer

  • cargo test --workspace count went from 128 → 178. The 50-test delta is mctp-rs's own test suite, which now runs as part of the workspace. Every consumer test result line from before is preserved exactly.
  • Cargo.lock picks up mctp-rs's dev-dep chain (rstest, tokio, pretty_assertions, etc.) for the same reason — these are dev-only and don't affect runtime. The two production-tree changes are hashbrown 0.15.5 → 0.17.0 and indexmap 2.11.0 → 2.14.0; both are pulled in only by the partition-manager-generation build script (via toml), so no runtime impact.
  • The PR is intentionally split across four atomic commits: source import, workspace bootstrap, cargo-husky drop, rustfmt.toml drop + reformat. Each is reviewable in isolation.

dymk added 5 commits May 5, 2026 15:51
Plain `cp -r` snapshot of the dymk/mctp-rs source tree (src/, Cargo.toml,
README.md, LICENSE.md, rustfmt.toml). Excludes .cargo-husky/, .github/,
.vscode/, .cursorrules, backlog/, source's Cargo.lock, source's .gitignore
(destination's existing /target rule already covers it), and all .git*
infrastructure. No git history preserved.

Rationale: SHA 3d941ba matches embedded-services::v0.2.0 Cargo.lock pin;
v1.7 bumps to 1b8b7f5 + updates consumers atomically.

Source: dymk/mctp-rs main @ 3d941ba
…ath dep

- [workspace] members: append "mctp-rs" at end of list (after
  "fw-update-interface-mocks")
- [workspace.dependencies]: replace `mctp-rs = { git = "https://github.com/dymk/mctp-rs" }`
  with `mctp-rs = { path = "./mctp-rs" }` (no version pin; path deps
  don't need one)
- Cargo.lock regenerated via `cargo build --workspace`; mctp-rs entry's
  `source` field removed (path-only). No transitive churn — SHA matches
  pre-edit lock pin (verified via cargo tree diff in Task 3).

Source: dymk/mctp-rs main @ 3d941ba (path-pinned in-tree)
… compatibility

cargo-husky's build script searches for `.cargo-husky/hooks/` at the
cargo workspace root. In the in-tree location the workspace root is
embedded-services/ (one level above mctp-rs/), so the hook search would
fail. The .cargo-husky/ directory is intentionally NOT carried over per
D-31-06 (incompatible with multi-crate workspaces; embedded-services
has its own pre-commit conventions). Phase 32 will add an equivalent
cargo-hack feature-powerset CI workflow.

Cargo.lock entry for cargo-husky removed by re-resolution.

Source: dymk/mctp-rs main @ 3d941ba (Cargo.toml only; src/ untouched)
… style

Removes mctp-rs/rustfmt.toml so the in-tree crate uses the destination
workspace's rustfmt.toml (max_width = 120, stable rustfmt).

The original per-crate config was nightly-rustfmt-only and exercised many
unstable features (imports_granularity = "Crate", group_imports =
"StdExternalCrate", wrap_comments, format_code_in_doc_comments, etc.)
that silently fail on stable rustfmt with 'can't set X = Y, unstable
features are only available in nightly channel' warnings.

Per the in-tree convention, the workspace formatter governs going forward;
no per-crate overrides. cargo fmt --all reformatted source under the
workspace style — net change is +90 / -300 lines (lines previously broken
at width 100 now fit at width 120; no behavioral changes).

cargo test --workspace still produces 178 passed / 0 failed (identical to
the post-Phase-31 baseline). cargo fmt --check now passes silently with
no warnings on stable rustfmt.

Source: dymk/mctp-rs main @ 3d941ba (mctp-rs source); reformatted under
embedded-services::v0.2.0 rustfmt.toml
…tree mctp-rs

CI failures on the previous push were entirely about workspace-resolution
state lagging behind the git→path source pin shift in the previous commits:

- examples/{std,rt685s-evk,pico-de-gallo}/Cargo.lock had stale git+SHA
  entries for mctp-rs (the example crates are independent cargo projects
  with their own lockfiles; the workspace's Cargo.lock regen doesn't reach
  them). Re-resolved each via 'cargo update -p mctp-rs' against the
  in-tree path. examples/rt633 doesn't depend on mctp-rs and was already
  green.
- cargo-machete flagged embedded-batteries, espi-device, uuid as unused
  in mctp-rs/Cargo.toml — they're feature-gated optional deps that ARE
  used when the relevant feature is on. Added [package.metadata.cargo-machete]
  ignored block.
- cargo-vet flagged 16 unvetted deps newly visible in the workspace lock:
  hashbrown 0.17.0 + indexmap 2.14.0 (production deps bumped during
  re-resolution; pulled in only by the partition-manager-generation build
  script via toml) and 14 dev-deps (mctp-rs's [dev-dependencies] now
  appear in the lock because path-pinned workspace members expose dev-deps;
  git deps did not). Added safe-to-deploy exemptions for the 2 production
  bumps + safe-to-run exemptions for the 14 dev-deps. Sorted via
  'cargo vet fmt'. 'cargo vet --locked' now reports 'Vetting Succeeded
  (163 fully audited, 5 partially audited, 68 exempted)'.
@dymk
dymk marked this pull request as ready for review May 5, 2026 23:52
@dymk
dymk requested review from a team as code owners May 5, 2026 23:52
@dymk
dymk merged commit 1b4ed11 into OpenDevicePartnership:v0.2.0 May 6, 2026
19 of 20 checks passed
jerrysxie added a commit that referenced this pull request May 14, 2026
# Bump in-tree mctp-rs to dymk/mctp-rs @ 1b8b7f5

Bumps the in-tree `mctp-rs/` source from `3d941ba` (current `v0.2.0`
baseline imported in
[#823](#823))
to `1b8b7f5` (the head of `dymk/mctp-rs main`). This brings the in-tree
copy to parity with the dymk fork's main, after which `dymk/mctp-rs`
will be archived.

The high-level
`MctpPacketContext::deserialize_packet`/`serialize_packet` API
signatures are **identical** between `3d941ba` and `1b8b7f5` (only
internal `MctpMedium::deserialize/serialize` cursor types changed). All
4 in-tree consumers (`uart-service`, `espi-service`, `embedded-service`,
plus macro re-exports) use the high-level `MctpPacketContext` API, so
**zero consumer source changes** were required. Consumer test counts are
unchanged at 128.

## What's picked up

- **`BufferEncoding` trait + `EncodingDecoder`/`EncodingEncoder` cursor
wrappers** (`src/buffer_encoding.rs`, NEW) — stateless cross-medium
encoding abstraction; threads through
`MctpMedium::deserialize/serialize` internals
- **`MctpSerialMedium` DSP0253 byte-stuffed serial framer with
CRC-16/X-25 FCS** (`src/medium/serial.rs`, NEW; gated behind opt-in
`serial` feature)
- **`wire_size_of` chunk-sizing fix** in `src/serialize.rs` (correctly
accounts for encoding overhead during packet chunking)
- **`SerialEncoding` byte-stuffing implementation** (in
`medium/serial.rs`)

## Source lineage

```
Source: dymk/mctp-rs main @ 1b8b7f5
Bumps from: 3d941ba (v0.2.0 baseline imported in #823)
```

## Carry-forwards from #823

These edits are preserved across the bump:

- Dropped `cargo-husky` from `[dev-dependencies]` (workspace-root build
script incompatibility; the source at `1b8b7f5` still has cargo-husky
declared but the in-tree copy must drop it)
- Did NOT re-introduce per-crate `mctp-rs/rustfmt.toml` (workspace style
governs; source at `1b8b7f5` has a `rustfmt.toml` for nightly rustfmt,
but the workspace uses stable rustfmt with `max_width = 120`)
- `[package.metadata.cargo-machete] ignored` block updated to add
`"crc"` (now an opt-in optional dep behind the `serial` feature;
cargo-machete would otherwise false-positive at default features)
- Source reformatted under the workspace style (separate fmt-only
commit; no semantic change)

## Test results

| Suite | Pre-bump | Post-bump | Delta |
|-------|---------:|----------:|------:|
| Workspace total `passed`  | 178 | 185 | +7 |
| `mctp-rs` unit tests      | ~47 | 54  | +7 |
| `mctp-rs` doctests        | 3   | 3   |  0 |
| Consumer crates (sum)     | 128 | 128 | **0** |

`cargo test --workspace` exits 0. New mctp-rs tests come from
`buffer_encoding.rs` cursor unit tests at default features. The 41+
`medium/serial.rs` golden-fixture tests live behind opt-in `--features
serial` and are exercised by the `hack-clippy` cargo-hack
feature-powerset job in `check.yml`.

## Cargo.lock churn

- Workspace `Cargo.lock` regenerated via `cargo build --workspace`.
`mctp-rs` entry remains source-less (path-pinned).
- **NEW transitive entries in `Cargo.lock`:** `crc 3.4.0` and
`crc-catalog 2.4.0` (both gated behind opt-in `serial`; neither is
reachable from `cargo build --workspace` at default features).
- `cargo tree -p mctp-rs` is **byte-identical** pre/post at default
features (verified via `diff`).
- Example lockfiles regenerated via `cd examples/<name> && cargo update
-p mctp-rs`: `examples/std`, `examples/rt685s-evk`,
`examples/pico-de-gallo` updated. `examples/rt633` does not depend on
`mctp-rs` and is untouched.

## cargo-vet

`cargo vet --locked` reports: `Vetting Succeeded (220 fully audited, 1
partially audited, 15 exempted)`.

Added **one** new exemption for `crc 3.4.0` as `safe-to-deploy` in
`supply-chain/config.toml` (alphabetically interleaved via `cargo vet
fmt`). `crc-catalog 2.4.0` did not require a new exemption — already
audited via `imports.lock` (OpenDevicePartnership-imported audit by
Jerry Xie, Microsoft).

## CI matrix coverage (`hack-clippy`)

`check.yml`'s `hack-clippy` job runs `cargo hack --feature-powerset
--mutually-exclusive-features=log,defmt,defmt-timestamp-uptime`
workspace-wide across `{stable,beta} × {x86_64-unknown-linux-gnu,
thumbv8m.main-none-eabihf}`. Since `mctp-rs` is a workspace member, this
matrix automatically exercises the new `serial` feature (16 feature
combinations total).

---------

Co-authored-by: Jerry Xie <139205137+jerrysxie@users.noreply.github.com>
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.

3 participants