Closes the residual that R3/R4 Path A's commit `c73a33e` deferred:
the OperationStatus.context field was always None because no
in-flight correlation map existed in SessionInner, and the
mxaccess-compat broadcast channels for OnWriteComplete /
OperationComplete were exposed on the public API but had no
fan-out task draining session events into them.
**mxaccess (Part 1 — per-operation correlation):**
- New `pending_ops: Mutex<HashMap<[u8; 16], OperationContext>>` on
SessionInner. Populated when `Session::write*` / `subscribe*`
dispatches an outstanding operation; entry removed when the
matching OperationStatus event fires (one-shot semantics).
- New `Session::write_with_handle` (and equivalents for the secured /
timestamped paths) returns a `WriteHandle { correlation_id }` so
consumers can correlate completions back to their originating
call. Existing `write` / `write_value` / etc. signatures unchanged
and delegate to the handle-returning variant.
- Callback router extended to look up `pending_ops` by correlation_id
on each operation-status event. When found, populates
`OperationStatus.context: Some(OperationContext { correlation_id,
op_kind, reference, retry_count: 0 })`. When not found, falls
through with `context: None` (verbatim-preserve per CLAUDE.md).
- New unit tests assert: matching correlation_id populates context,
unknown correlation_id leaves context None, the entry is removed
from `pending_ops` after one event fires.
**mxaccess-compat (Part 2 — compat-layer fan-out):**
- New `correlation_to_item: tokio::sync::Mutex<HashMap<[u8; 16], i32>>`
on LmxClientInner.
- `LmxClient::write` / `write_2` / `write_secured` / `write_secured_2`
call `Session::write_with_handle` (or equivalent) and insert
`correlation_id → item_handle` into the map before returning.
- `LmxClient::register` / `register_asb` spawn a background task that
drains `session.operation_status_stream()`. Per event, looks up
`correlation_to_item[event.context?.correlation_id]` to find the
item_handle, then routes:
- `OperationKind::Write` / `OperationKind::WriteSecured` →
`WriteCompleteEvent { server_handle, item_handle, statuses,
is_during_recovery }` into `on_write_complete_tx`.
- Other variants → `OperationCompleteEvent { ... }` into
`on_operation_complete_tx`.
- Removes the correlation_id from `correlation_to_item` after
firing (one-shot).
- Events with no matching item_handle (correlation_id not in map)
are dropped silently — no bogus item_handle=0 events.
- Task cancelled on LmxClient drop via `JoinHandle::abort` (matches
the existing `subscription_task` pattern).
- New unit tests cover: Write op routes to on_write_complete, Read
op routes to on_operation_complete, unknown correlation_id is
dropped.
Result: the C# `LMX_OnWriteComplete(int hLMXServerHandle, int
phItemHandle, ref MXSTATUS_PROXY[] pVars)` callback shape is now
end-to-end-achievable. A consumer calls `LmxClient::write(hServer,
hItem, value, userId)` and drains `client.on_write_complete()`; the
yielded `WriteCompleteEvent` carries the right `(server_handle,
item_handle, statuses, is_during_recovery)` tuple.
Public API: `Session::write_with_handle` + `WriteHandle` are new;
existing signatures unchanged. `cargo public-api` baselines
regenerated under `design/public-api/{mxaccess,mxaccess-compat}.txt`.
Workspace: 765 → 823 tests pass (~58 new tests from F54). Clippy
`-D warnings` clean. Rustdoc `-D warnings` clean.
F54 status in `design/followups.md` moved Open → Resolved.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
cargo public-api baselines
F41 — public-api baseline established 2026-05-06. One file per
workspace crate; each is the verbatim output of
cargo +nightly public-api --simplified -p <crate>.
Why a baseline
mxaccess and friends are heading for cargo publish. Once the
crates are on crates.io, semver-breaking changes to the public surface
need to be intentional. The baseline is what CI diffs against to
catch unintentional drift.
Update procedure
When a PR intentionally changes the public API:
- Build the crate against nightly +
cargo-public-api:rustup toolchain install nightly # one-time cargo install cargo-public-api # one-time - Regenerate the affected baseline file:
cd rust cargo +nightly public-api --simplified -p <crate> > ../design/public-api/<crate>.txt - Commit the regenerated file alongside the API change. Reviewers
inspect the diff at
design/public-api/<crate>.txtto verify the intent matches the wire-up.
CI
.github/workflows/rust.yml runs cargo +nightly public-api --simplified -p <crate>
for each workspace crate after the standard build/test/clippy/fmt
matrix and diffs the live output against the committed baseline.
Drift fails the CI step; the PR author either adjusts the
implementation or updates the baseline (per the procedure above).
What --simplified strips
--simplified (single -s) omits blanket impls (e.g.
impl<T: Clone> Clone for Vec<T>-style noise) but keeps everything
that's reachable through the crate's named public items. Doubling
(-ss) would also strip auto-trait impls (Send, Sync,
UnwindSafe); we don't because intentional Send / Sync losses
on a Session clone are a semver break we want to catch.
Per-crate sizes (line counts)
Captured at baseline date:
| crate | lines |
|---|---|
mxaccess-codec |
~2516 |
mxaccess-asb |
~1258 |
mxaccess-rpc |
~1273 |
mxaccess-asb-nettcp |
~708 |
mxaccess |
~542 |
mxaccess-galaxy |
~374 |
mxaccess-callback |
~170 |
mxaccess-compat |
~123 |
mxaccess-nmx |
~118 |