Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
a7e5d82
docs(rust): add bounded application recipes
lan17 Nov 13, 2026
59d37a8
test(rust): bound the metric queue regression probe
lan17 Nov 13, 2026
ad5fb2a
test(rust): format metric watchdog assertion
lan17 Nov 13, 2026
33ffe04
test(rust): retain permits through native I/O completion
lan17 Nov 13, 2026
7b7784d
test(rust): exercise the production shadow renderer
lan17 Nov 13, 2026
d076d08
test(rust): cover value retention and decode bounds
lan17 Nov 13, 2026
5d11d21
test(rust): cover local TLS and Sentinel recovery
lan17 Nov 13, 2026
9ea00b6
test(rust): cover bounded metrics transport failures
lan17 Nov 13, 2026
2026483
test(rust): add bounded multi-worker load and drain checks
lan17 Nov 13, 2026
9a85322
test(rust): count completions against the fixed load window
lan17 Nov 13, 2026
3f8d80c
test(rust): harden load evidence and cleanup checks
lan17 Nov 13, 2026
5ea8daa
test(rust): add bounded real Redis mixed load
lan17 Nov 13, 2026
ca522c1
test(rust): wire isolated consumer checks and document opt-in suites
lan17 Nov 13, 2026
e060617
docs(rust): clarify Redis client timeout scope
lan17 Nov 13, 2026
803d0bb
fix(rust): require patched runtime dependencies
lan17 Nov 13, 2026
5934560
test(rust): bind Redis fixtures to owned processes
lan17 Nov 13, 2026
001428b
docs(rust): qualify the locked Redis compiler requirement
lan17 Nov 13, 2026
69d267c
test(rust): isolate Sentinel recovery with private TLS
lan17 Nov 13, 2026
cb5079b
docs(rust): clarify CPU executor limits
lan17 Nov 13, 2026
279b57a
test(rust): retry transient replica startup timeouts
lan17 Nov 13, 2026
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
9 changes: 9 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,15 @@ jobs:
- name: Verify the packaged Rust crate with every feature
working-directory: rust
run: cargo package --locked --all-features
- name: Check the isolated production-feature Rust consumer
working-directory: rust/tests/production_consumer
env:
CARGO_TARGET_DIR: ${{ github.workspace }}/rust/target/production-consumer
run: |
cargo tree --locked --edges features --invert dialcache
cargo fmt --check
cargo clippy --locked --all-targets -- -D warnings
cargo run --locked
- name: Install LLVM coverage tools for the pinned Rust toolchain
working-directory: rust
run: rustup component add llvm-tools-preview
Expand Down
5 changes: 3 additions & 2 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ dialcache = { path = "../DialCache/rust" }
tokio = { version = "1", features = ["macros", "rt-multi-thread", "time"] }
```

Adjust the path to your checkout. The core crate requires Rust 1.85; the `redis`
feature currently requires Rust 1.88. See the [Rust guide](languages/rust.md) for
Adjust the path to your checkout. The core crate requires Rust 1.85 or later;
building the `redis` feature with this repository's lockfile requires Rust 1.88.
See the [Rust guide](languages/rust.md) for
runtime, feature and value-ownership details.

</LanguageContent>
Expand Down
120 changes: 119 additions & 1 deletion docs/languages/rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ serde = { version = "1", features = ["derive"] }
```

Adjust the path to your checkout. The core crate requires Rust 1.85 or later;
the current `redis` dependency requires 1.88. The crate has no Node.js runtime
building the `redis` feature with this repository's lockfile requires Rust 1.88.
The crate has no Node.js runtime
dependency. Available registry versions are listed on
[crates.io](https://crates.io/crates/dialcache); docs.rs builds their API references.

Expand Down Expand Up @@ -113,3 +114,120 @@ replaces it, and is the only source of differences for an operation whose
Application codecs control their own scheduling. See
[compression](../redis.md#compression) for thresholds and fail-open behavior
when compression or decompression capacity is exhausted.

## Application-owned limits

<LanguageContent language="rust">

These four recipes use existing APIs. They add no library defaults and protect
an application only after it adopts them. Choose limits for your workload.
The complete [executable examples](https://github.com/lan17/DialCache/blob/main/rust/tests/docs_examples.rs)
include imports, test dependencies and assertions.

### Source and policy work

Acquire source capacity inside the registered source, not around `get`.
The permit then remains held when a caller stops waiting or the cache source
deadline expires. The same source guard applies to uncached and shadow calls.
Use non-waiting admission to avoid an unbounded queue of waiting callers.

This example uses a semaphore as a test dependency. Replace that wait with
source I/O that has its own finite budget:

<<< @/../rust/tests/docs_examples.rs#rust-source-budget{rust}

The application's one-second timeout drops this dependency future and releases
its permit. It does not prove cancellation of work in a client-owned task or at
the server. If your client starts separate tasks, keep the permit with the task
that owns the resource until it finishes, and bound its native queue and I/O.
Acquire the permit before scheduling that task, not after it starts.
A caller timeout only ends that caller's wait. None of these timers can preempt
blocking synchronous code.

Admission and dependency timeout errors are `Error::Source`, not
`Error::FallbackTimeout`. If stale recovery should accept one of these errors,
classify that specific error with `should_recover`; do not accept every source
failure.

Prefer a cheap local configuration snapshot. When a provider must await I/O,
bound that work separately: policy resolves before source sharing and before
the source timer starts.

<<< @/../rust/tests/docs_examples.rs#rust-provider-budget{rust}

A provider error runs the source uncached; it does not enable baseline caching.
Keep the source guard active on that path. `Ok(None)` means inherit, not
configuration failure.

### Complete mutation calls

Wrap the remote adapter before passing it to the cache builder. This example
forwards the original read request and cancellation context, and gives each
write or invalidation one 200 ms wait budget:

<<< @/../rust/tests/docs_examples.rs#rust-mutation-budget{rust}

For `RedisAdapter`, the invalidation budget covers both `EVALSHA` and its `EVAL`
retry. Keep the client's own finite connection, command and queue limits as
well. No breaker bypasses invalidation. A timed-out write preserves the source
result; a timed-out invalidation returns an error to its caller.

Timeout drops the adapter future, not an already accepted server command. A
mutation can still happen after the error, so its outcome is unknown until
verified. This budget excludes earlier serialization and compression; give an
asynchronous custom codec its own settlement bound. It is not a total-call
deadline.

### Values and request scopes

Use a value domain with a known bound on retained data, and validate remote
decodes as well as source results. This example stores only a 32-byte digest.
The codec checks the JSON payload length and the exact decoded array length:

<<< @/../rust/tests/docs_examples.rs#rust-bounded-values{rust}

The payload check runs **after** the engine's decompression. It does not prevent
decompression allocations, nor does a serialized-byte limit measure heap size.
The fixed array bounds this value type, not process memory or all temporary
allocations.

Set process-local capacity explicitly. Here `remote` is the test snapshot
adapter and `clock` is its fixed test clock; use your adapter and normal clock
in the application:

<<< @/../rust/tests/docs_examples.rs#rust-bounded-scopes{rust}

Capacity counts entries, not bytes. Request memoization has no capacity limit.
Bound simultaneous requests and keys per request, use bounded key types, and
close scopes promptly:

<<< @/../rust/tests/docs_examples.rs#rust-bounded-request{rust}

Use `request_local(false)` when request memoization is not needed. Closing a
scope releases its memo, but does not cancel source work or release `Arc`s held
by callers. Keep the request permit until the caller also releases retained
results. Apply the source controls above as well.

### Nonblocking metric transport

`DatadogObserver` maps names, tags and units, then calls `DogStatsdClient`
synchronously. A slow client delays cache calls. This client queues packets
with `try_send`; a full or closed queue drops the packet rather than waiting:

<<< @/../rust/tests/docs_examples.rs#rust-metric-queue{rust}

Create it with `sync_channel` and a fixed capacity, then pass it to
`DatadogObserver::new`. The example also caps each packet at 512 bytes and drops
unsafe wire separators. Keep application labels stable and bounded.

A separate sender must consume the queue with finite I/O budgets. The tests use
only a loopback UDP socket with a write timeout, preserve the exporter's metric
mapping, and count send errors separately. Monitor drop and send-error counters
outside this exporter to avoid recursive reporting. Stop producers and drop
their sender handles before joining the sender at shutdown.

Queue acceptance and a successful UDP send do not prove delivery to Datadog.
This example changes neither the metric schema nor the selected histogram or
distribution mode.

</LanguageContent>
5 changes: 4 additions & 1 deletion docs/redis.md
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,10 @@ bounded for large values.

Compression of payloads of at least 64 KiB (or at levels 10–22 once the
threshold is met) and every decompression run on a bounded CPU queue shared by
all instances: two workers and two queued jobs by default. When that queue is
all instances: two workers and two queued jobs by default. Tokio worker-thread
and blocking-thread limits do not change this pool. Use a custom
`Runtime::spawn_blocking` implementation for a different bounded CPU executor.
When that queue is
full, the work is rejected and DialCache fails open: a read of a compressed
value falls through to the source, and the write is skipped. Custom codecs
manage their own CPU work.
Expand Down
2 changes: 1 addition & 1 deletion formal/catalogs/go-parity.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"inputs": {
"semanticCasesSha256": "380273598e1d956a3f9fce270cc84424b342e456139b279bd56576bd3b837f65",
"executionSha256": "eaf117c3e8630013cc8df0524f84af440c470f42e8711ab4dd07b931161c784f",
"sourceAuditDispositionsSha256": "942eab018ae0d8fa189ff16c322f6d9b3301aadc7c46d00b311018728c62f34e",
"sourceAuditDispositionsSha256": "b31ef053e3ee5a2e05fcd22d940b4dd64d0a98218012ab3052ef40d36e14e27b",
"featureCoverageSha256": "a49438a0fab8997518956565f391486a569aab304f2057a667d28c5d41bde834",
"coverageWitnessesSha256": "745cebececddbfa97912621ada94072d648e8e60e8b3eb013b91eefd16f352a1",
"profilesSha256": "888a522f8ad97862ebcb0b5fe363ec7bec60367fa42c60e1623141814b1991b3"
Expand Down
18 changes: 12 additions & 6 deletions formal/catalogs/source-audit.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
},
{
"path": "docs/getting-started.md",
"sha256": "409c3e6dd51f72d8df6e746fbcf1ee5a619cdc2f0f97beaf37a5b20c9c99c3c1",
"sha256": "d9591172e2680824531564768959573dc577b7603728c0d5a58d557ccaaa47a2",
"entries": [
{"title":"Getting started","contracts":["B01"]},
{"title":"Install","contracts":["B01"]},
Expand Down Expand Up @@ -211,14 +211,19 @@
},
{
"path": "docs/languages/rust.md",
"sha256": "ae1e0dcb12f62dc827c075c0e8f3c92ac298a6758e59d6d65205180b3dee9c4c",
"sha256": "d298b5d3223a66f17342f0c645030e131526803c70f47d1dc98a1ce16b5785f4",
"entries": [
{"title":"Rust integration","contracts":["B01"]},
{"title":"Installation and runtime","contracts":["B01","B02"]},
{"title":"Request scope and operations","contracts":["C01","C02","C03","B01","B02"]},
{"title":"Policy and errors","contracts":["C16","C17","C18","C20","C21","C23","C25","C27","C29","B01","B02"]},
{"title":"Identity and values","contracts":["W01","W02","E04","B03"]},
{"title":"Integrations","contracts":["E01","B01","B03","X01","C46","C47","C60"]}
{"title":"Integrations","contracts":["E01","B01","B03","X01","C46","C47","C60"]},
{"title":"Application-owned limits","contracts":["B01","E03","X02"]},
{"title":"Source and policy work","contracts":["C01","C11","C20","C23","C25","C27","B01","B02","E03","X02"]},
{"title":"Complete mutation calls","contracts":["C27","C29","C56","B01","E01","E03","X02"]},
{"title":"Values and request scopes","contracts":["C03","C07","C08","B03","E04","X02"]},
{"title":"Nonblocking metric transport","contracts":["C30","X01","X02"]}
]
},
{
Expand Down Expand Up @@ -259,7 +264,7 @@
},
{
"path": "docs/redis.md",
"sha256": "fce0b00a5ce212e1267aa3eda28f4e9334209d87730fb0ea0fe5f543b741888b",
"sha256": "37cd276f3bbc4e60f01c3a1b2447f57e63652a75661861b49ae63743145b4af6",
"entries": [
{"title":"Redis and Valkey","contracts":["E01"]},
{"title":"Install a client","contracts":["B01","E01"]},
Expand Down Expand Up @@ -1767,7 +1772,7 @@
},
{
"path": "formal/guides/VALIDATION.md",
"sha256": "8f0a8bbd03f71d630f337a83c9c01f1e737bd7c634e7e7ac9d9a4b988fb511ea",
"sha256": "c2baf298efdc5723f991acd3e3d200c1b0aa97bcfd113a4fa683cd35b6a01715",
"entries": [
{"title":"Validation and evidence"},
{"title":"Prerequisites"},
Expand All @@ -1776,7 +1781,8 @@
{"title":"Reproducing one history"},
{"title":"Mutation evidence"},
{"title":"Exploratory runs"},
{"title":"A retained sampling regression"}
{"title":"A retained sampling regression"},
{"title":"Rust consumer and resource checks"}
],
"review": {
"kind": "tooling-guide",
Expand Down
51 changes: 51 additions & 0 deletions formal/guides/VALIDATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -419,3 +419,54 @@ public-action regressions now anchor all of them:
| policy / `remote-value:7`, `remote-value:8`, `remote-value:9` | [falsyRemoteValuesAreServedFromRemoteTest](../models/dialcache-policy-conformance.qnt) |
| layers / `source-publication-probed-in-all-three-layers` | [untrackedSourcePublicationIsProbedInAllThreeLayersTest](../models/dialcache-layers-conformance.qnt) |
| independent / `distinct-retained-recovery-values` | [independentRecoveriesServeDistinctAcquiredSnapshotsTest](../models/dialcache-independent-conformance.qnt) |

## Rust consumer and resource checks

The Rust CI job separately builds `rust/tests/production_consumer`, whose own
workspace and lockfile keep the root crate's `test-util` development dependency
out of the consumer graph. It checks the production shadow-log rendering path
and panic isolation, not the deterministic replay runtime:

```sh
cargo tree --locked --manifest-path rust/tests/production_consumer/Cargo.toml --edges features --invert dialcache
cargo fmt --manifest-path rust/tests/production_consumer/Cargo.toml --check
cargo clippy --locked --manifest-path rust/tests/production_consumer/Cargo.toml --target-dir rust/target/production-consumer --all-targets -- -D warnings
cargo run --locked --manifest-path rust/tests/production_consumer/Cargo.toml --target-dir rust/target/production-consumer
```

The consumer's first assertion distinguishes the production renderer from the
test renderer. As a negative control, adding `--features dialcache/test-util`
to the last command must fail that assertion. Do not count that expected failure
as a production validation result.

The default native suite also checks application-owned permits across actual
socket work, caller abandonment and native I/O expiry; retained result values
and post-decompression codec limits; and bounded metric queue, sender error and
shutdown behavior. These tests do not turn the recipes into library defaults.

Longer load tests and the local transport fixture are opt-in. The load runner
requires GNU `timeout`, Python 3, a clean committed checkout and a new output
directory for each run:

```sh
DIALCACHE_SOAK_CASES='hot-hit cancellation' \
DIALCACHE_SOAK_WORKER_COUNTS=1 DIALCACHE_SOAK_RATES=1000 DIALCACHE_SOAK_SECONDS=10 \
bash scripts/rust-scale-soak.sh /tmp/dialcache-scale-evidence

cargo test --locked --manifest-path rust/tests/redis_transport_recovery/Cargo.toml \
--test transport -- --test-threads=1
```

The load runner records its source and harness fingerprints, offered arrivals,
admission decisions, caller outcomes, bounded latency histograms and actual work
drain. Fixed-window completions and eventual cohort success are different
measurements. Synthetic remote results are not Redis capacity measurements, and
RSS observations do not prove a memory ceiling.

The transport fixture needs TLS-capable `redis-server` and OpenSSL and fails
when prerequisites are missing. Its separate downstream manifest selects Redis
TLS/Sentinel features and a rustls crypto provider without changing the library
defaults. It tests explicit primary rediscovery, not automatic application
failover. See its [scope and commands](../../rust/tests/redis_transport_recovery/README.md)
before running it. Neither opt-in suite replaces portable replay, required
hosted validation, or the Docker-backed interoperability matrix.
4 changes: 2 additions & 2 deletions formal/guides/course/13-catalogs-and-ledgers.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ You will edit a tracked guide and undo it at the end.
{
sources: 50,
tests: 633,
sections: 216,
sections: 221,
reviewedGuides: 19,
guideSections: 195
guideSections: 196
}
```

Expand Down
2 changes: 1 addition & 1 deletion formal/guides/course/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ so the drift is caught by the check, not by a learner:
the code may have moved for a reason the lesson should mention.
- **A quoted count comes from a check.** Quote a number only as `node
formal/tools/execution.mjs` prints it (`"regressions": 489`) or as `node
formal/tools/check-source-audit.mjs` prints it (`guideSections: 195`); the
formal/tools/check-source-audit.mjs` prints it (`guideSections: 196`); the
check compares both with today's output. When an exercise changes a count, say
so in words rather than quoting the new number.
- **The course is outside the review ledger on purpose.** The lessons are
Expand Down
24 changes: 12 additions & 12 deletions rust/Cargo.lock

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

Loading
Loading