Skip to content

feat(latency): integrate WCTT bounds into end-to-end latency (Track D commit 6/6)#171

Merged
avrabe merged 1 commit intomainfrom
feat/v0.8.0-track-d-commit6-latency-integration
Apr 26, 2026
Merged

feat(latency): integrate WCTT bounds into end-to-end latency (Track D commit 6/6)#171
avrabe merged 1 commit intomainfrom
feat/v0.8.0-track-d-commit6-latency-integration

Conversation

@avrabe
Copy link
Copy Markdown
Contributor

@avrabe avrabe commented Apr 26, 2026

Summary

Closes Track D Phase 1 (FIFO + Priority networks). The latency analysis pass now alternates RTA-derived WCET on compute hops with WCTT-derived bounds on network hops, realising the WCET+WCTT end-to-end framing recorded in the project memory.

  • spar-analysis::wctt::compute_network_hop_latency: new public helper returns Option<NetworkHopLatency> with (min_ps, max_ps, unservable) for a connection segment that binds to one or more Spar_Network::Switch_Type-annotated buses. Re-uses the same NC primitives (residual service, delay bound, output bound) as the existing WcttAnalysis::analyze walk.
  • spar-analysis::latency: walks every connection segment in each end-to-end flow; when the helper returns Some(...), the per-hop contribution comes from the NC-derived bound and the legacy sampling-delay / inter-processor-overhead path is suppressed for that segment to avoid double-counting. When the helper returns None, the v0.7.0 path runs unchanged — that is the non-regression contract that gates Phase 1 close-out.
  • Diagnostics: [network hop] annotation on per-hop diagnostics when the bound is WCTT-derived; [compute hop] annotation for same-CPU compute segments on chains that also see a network hop; LatencyHopMixed Info marker on chains that exercise both hop types.
  • Unservable propagation: when compute_network_hop_latency flags a saturated residual service, latency.rs emits an Error and aborts aggregation for that chain — mirrors wctt.rs's existing WcttUnservable semantics.

What's NOT in this PR

  • Phase 2 TSN-shaped service curves (TAS, CBS, frame preemption) — v0.8.x scope. Phase 2 will surface those via richer service curves in spar-network::curves and a wider Spar_TSN::* property set.
  • MBPTA / stochastic NC — v0.9.0+.
  • Track D Lean theorems for NC primitives (commit 5/6) — sibling PR; this commit moves forward independently because the NC Rust API is stable.
  • Track E surfaces (spar moves verify deterministic-apply, MCP read-only) — Track E is parallel.

How to verify the WCET+WCTT framing on a sample model

Build a minimal cross-CPU chain with a switched bus:

bus eth
  properties
    Spar_Network::Switch_Type        => FIFO;
    Spar_Network::Output_Rate        => 1000000000 bitsps;
    Spar_Network::Forwarding_Latency => 0 us .. 0 us;
end eth;

with a system whose Actual_Connection_Binding => (reference (sw)) covers a sensor (cpu1) -> c1 -> controller (cpu2) flow. Run spar analyze and look for:

end-to-end flow 'e2e_cross' latency: [3.012 ms .. 3.012 ms]
end-to-end flow 'e2e_cross': connection 'c1' [network hop] [0.000 ms .. 0.012 ms]
LatencyHopMixed: end-to-end flow 'e2e_cross' alternates RTA-derived WCET on ...

The 0.012 ms hop is the canonical Le Boudec bound D = T + sigma/R = 0 + 1500*8*10^12 / 1 Gbps = 12 us. Removing the Spar_Network::* annotations falls back to the v0.7.0 scalar path; removing the Actual_Connection_Binding entirely also falls back. Both fall-through cases are covered by unit tests.

Test plan

  • cargo build --workspace — clean
  • cargo test -p spar-analysis --lib — 834 passing (824 baseline + 10 new latency tests)
  • cargo test --workspace — green, no failures
  • cargo clippy --workspace --all-targets -- -D warnings — clean
  • cargo fmt --all -- --check — clean
  • rivet validate — PASS (existing pre-existing schema warnings only)

10 new latency::tests covering: non-regression (no_spar_network_models_unchanged_v07), single-CPU chain (compute_only_chain_unchanged), single-hop NC bound matching helper (single_network_hop_uses_wctt), three-stage WCET+WCTT alternation (compute_then_network_then_compute), scalar fallback when no Switch_Type (network_hop_falls_back_to_bus_latency_when_no_switch_type), NC switchover when Switch_Type added (network_hop_uses_wctt_when_switch_type_present), LatencyHopMixed marker (latency_hop_mixed_diagnostic_emitted), unservable propagation (wctt_unservable_propagates_to_latency), unannotated-bus fallback (unannotated_bus_in_chain_falls_back), simple-fixture regression (existing_latency_fixtures_unchanged).

Generated with Claude Code

… commit 6/6)

Closes Track D Phase 1 (FIFO + Priority networks). The latency.rs
analysis pass now alternates RTA-derived WCET on compute hops with
wctt-derived WCTT on network hops, realising the WCET+WCTT end-to-end
framing recorded in the project memory.

Models without Spar_Network::* annotations fall back to the existing
Bus_Properties::Latency scalar — non-regression preserved (verified by
no_spar_network_models_unchanged_v07).

New diagnostic LatencyHopMixed signals chains that exercise both hop
types end-to-end.

COMPLIANCE.md updated with the Track D Phase 1 close-out narrative
(5/6 commits delivered; commit 5 Lean is a sibling PR).

New requirement: REQ-NETWORK-008.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 26, 2026

Codecov Report

❌ Patch coverage is 98.41270% with 11 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
crates/spar-analysis/src/wctt.rs 91.86% 10 Missing ⚠️
crates/spar-analysis/src/latency.rs 99.82% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@avrabe avrabe merged commit 6f640dd into main Apr 26, 2026
17 checks passed
@avrabe avrabe deleted the feat/v0.8.0-track-d-commit6-latency-integration branch April 26, 2026 20:20
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.

1 participant