Add wireframe-verification crate with placeholder Stateright model#527
Add wireframe-verification crate with placeholder Stateright model#527
Conversation
…aceholder Stateright model - Add `crates/wireframe-verification` as an internal crate for formal verification. - Include a small semantic placeholder connection model using Stateright. - Provide a shared bounded-checker harness and integration tests with rstest. - Update root workspace manifest to include the verification crate without widening default members. - Update documentation and regression tests to reflect new verification crate and workspace changes. - Align stateright dependency to 0.31.0 and use normal wireframe features to ensure compatibility. This foundational change introduces the dedicated formal verification crate to the workspace, enabling subsequent roadmap items to build more detailed connection actor models and verification tooling. Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Reviewer's GuideIntroduces a new internal crate Sequence diagram for asserting Stateright properties via the shared harnesssequenceDiagram
actor Developer
participant TestRunner
participant ConnectionActorTest
participant VerificationHarness as VerificationHarnessHelpers
participant Model as PlaceholderConnectionModel
participant Stateright as Checker
Developer->>TestRunner: cargo test -p wireframe-verification
TestRunner->>ConnectionActorTest: run tests
ConnectionActorTest->>Model: create PlaceholderConnectionModel::default()
ConnectionActorTest->>VerificationHarness: assert_model_properties(model)
VerificationHarness->>VerificationHarness: create VerificationBounds::default()
VerificationHarness->>VerificationHarness: checker(model, bounds)
VerificationHarness->>Stateright: spawn_bfs()
Stateright-->>VerificationHarness: Checker result
VerificationHarness->>Stateright: assert_properties()
Stateright-->>VerificationHarness: all properties hold
VerificationHarness-->>ConnectionActorTest: return
ConnectionActorTest-->>TestRunner: test pass
TestRunner-->>Developer: report success
Class diagram for wireframe-verification placeholder connection model and harnessclassDiagram
class ActiveOutput {
<<enum>>
Idle
Response
MultiPacket
}
class ConnectionState {
+u8 steps
+bool high_priority_queued
+bool low_priority_queued
+bool fairness_allows_low
+ActiveOutput active_output
+bool shutdown_requested
+bool emitted_high_priority
+bool emitted_low_priority
+bool response_completed
+bool multi_packet_completed
+bool shutdown_during_output
+u8 multi_packet_terminal_count
}
class ConnectionAction {
<<enum>>
EnqueueHigh
EnqueueLow
InstallResponse
InstallMultiPacket
EmitQueued
EmitActiveFrame
CompleteActiveOutput
Shutdown
TickFairness
}
class PlaceholderConnectionModel {
-u8 max_steps
+PlaceholderConnectionModel()
+PlaceholderConnectionModel new(max_steps u8)
+Vec~ConnectionState~ init_states()
+void actions(state ConnectionState, actions Vec~ConnectionAction~)
+Option~ConnectionState~ next_state(state ConnectionState, action ConnectionAction)
+Vec~Property~ properties()
+bool within_boundary(state ConnectionState)
}
class VerificationBounds {
+usize max_depth
+usize max_state_count
+VerificationBounds()
}
class VerificationHarnessHelpers {
<<utility>>
+CheckerBuilder~PlaceholderConnectionModel~ checker(model PlaceholderConnectionModel, bounds VerificationBounds)
+void assert_model_properties(model PlaceholderConnectionModel)
+void assert_model_properties_with_bounds(model PlaceholderConnectionModel, bounds VerificationBounds)
}
ActiveOutput <.. ConnectionState : uses
ConnectionAction <.. PlaceholderConnectionModel : uses
ConnectionState <.. PlaceholderConnectionModel : uses
VerificationBounds <.. VerificationHarnessHelpers : uses
PlaceholderConnectionModel <.. VerificationHarnessHelpers : uses
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
@coderabbitai Please suggest a fix for this issue and supply a prompt for an AI coding agent to enable it to apply the fix. Include the file and symbol names indicated in the issue at the head of your response. crates/wireframe-verification/src/connection_model/model.rs Comment on lines +42 to +122 fn next_state(&self, state: &Self::State, action: Self::Action) -> Option<Self::State> {
let mut next = state.clone();
next.steps = next.steps.saturating_add(1);
match action {
ConnectionAction::EnqueueHigh if !state.high_priority_queued => {
next.high_priority_queued = true;
Some(next)
}
ConnectionAction::EnqueueLow if !state.low_priority_queued => {
next.low_priority_queued = true;
Some(next)
}
ConnectionAction::InstallResponse
if !state.shutdown_requested
&& matches!(state.active_output, ActiveOutput::Idle) =>
{
next.active_output = ActiveOutput::Response;
Some(next)
}
ConnectionAction::InstallMultiPacket
if !state.shutdown_requested
&& matches!(state.active_output, ActiveOutput::Idle) =>
{
next.active_output = ActiveOutput::MultiPacket;
next.multi_packet_terminal_count = 0;
Some(next)
}
ConnectionAction::EmitQueued if state.high_priority_queued => {
next.high_priority_queued = false;
next.emitted_high_priority = true;
next.fairness_allows_low = true;
Some(next)
}
ConnectionAction::EmitQueued
if state.low_priority_queued
&& (!state.high_priority_queued || state.fairness_allows_low) =>
{
next.low_priority_queued = false;
next.emitted_low_priority = true;
next.fairness_allows_low = false;
Some(next)
}
ConnectionAction::EmitActiveFrame
if !matches!(state.active_output, ActiveOutput::Idle) =>
{
if state.shutdown_requested {
next.shutdown_during_output = true;
}
Some(next)
}
ConnectionAction::CompleteActiveOutput
if matches!(state.active_output, ActiveOutput::Response) =>
{
next.active_output = ActiveOutput::Idle;
next.response_completed = true;
Some(next)
}
ConnectionAction::CompleteActiveOutput
if matches!(state.active_output, ActiveOutput::MultiPacket) =>
{
next.active_output = ActiveOutput::Idle;
next.multi_packet_completed = true;
next.multi_packet_terminal_count =
next.multi_packet_terminal_count.saturating_add(1);
Some(next)
}
ConnectionAction::Shutdown if !state.shutdown_requested => {
next.shutdown_requested = true;
if !matches!(state.active_output, ActiveOutput::Idle) {
next.shutdown_during_output = true;
}
Some(next)
}
ConnectionAction::TickFairness if state.low_priority_queued => {
next.fairness_allows_low = true;
Some(next)
}
_ => None,
}
}❌ New issue: Complex Method |
|
@coderabbitai Please suggest a fix for this issue and supply a prompt for an AI coding agent to enable it to apply the fix. Include the file and symbol names indicated in the issue at the head of your response. crates/wireframe-verification/src/connection_model/model.rs Comment on lines +77 to +78 if state.low_priority_queued
&& (!state.high_priority_queued || state.fairness_allows_low) =>❌ New issue: Complex Conditional |
|
@coderabbitai Please suggest a fix for this issue and supply a prompt for an AI coding agent to enable it to apply the fix. Include the file and symbol names indicated in the issue at the head of your response. crates/wireframe-verification/src/connection_model/model.rs Comment on lines +42 to +122 fn next_state(&self, state: &Self::State, action: Self::Action) -> Option<Self::State> {
let mut next = state.clone();
next.steps = next.steps.saturating_add(1);
match action {
ConnectionAction::EnqueueHigh if !state.high_priority_queued => {
next.high_priority_queued = true;
Some(next)
}
ConnectionAction::EnqueueLow if !state.low_priority_queued => {
next.low_priority_queued = true;
Some(next)
}
ConnectionAction::InstallResponse
if !state.shutdown_requested
&& matches!(state.active_output, ActiveOutput::Idle) =>
{
next.active_output = ActiveOutput::Response;
Some(next)
}
ConnectionAction::InstallMultiPacket
if !state.shutdown_requested
&& matches!(state.active_output, ActiveOutput::Idle) =>
{
next.active_output = ActiveOutput::MultiPacket;
next.multi_packet_terminal_count = 0;
Some(next)
}
ConnectionAction::EmitQueued if state.high_priority_queued => {
next.high_priority_queued = false;
next.emitted_high_priority = true;
next.fairness_allows_low = true;
Some(next)
}
ConnectionAction::EmitQueued
if state.low_priority_queued
&& (!state.high_priority_queued || state.fairness_allows_low) =>
{
next.low_priority_queued = false;
next.emitted_low_priority = true;
next.fairness_allows_low = false;
Some(next)
}
ConnectionAction::EmitActiveFrame
if !matches!(state.active_output, ActiveOutput::Idle) =>
{
if state.shutdown_requested {
next.shutdown_during_output = true;
}
Some(next)
}
ConnectionAction::CompleteActiveOutput
if matches!(state.active_output, ActiveOutput::Response) =>
{
next.active_output = ActiveOutput::Idle;
next.response_completed = true;
Some(next)
}
ConnectionAction::CompleteActiveOutput
if matches!(state.active_output, ActiveOutput::MultiPacket) =>
{
next.active_output = ActiveOutput::Idle;
next.multi_packet_completed = true;
next.multi_packet_terminal_count =
next.multi_packet_terminal_count.saturating_add(1);
Some(next)
}
ConnectionAction::Shutdown if !state.shutdown_requested => {
next.shutdown_requested = true;
if !matches!(state.active_output, ActiveOutput::Idle) {
next.shutdown_during_output = true;
}
Some(next)
}
ConnectionAction::TickFairness if state.low_priority_queued => {
next.fairness_allows_low = true;
Some(next)
}
_ => None,
}
}❌ New issue: Bumpy Road Ahead |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Extract per-action transition logic in `PlaceholderConnectionModel` into eleven `apply_*` helpers with early-return guards, plus a `stepped` helper that owns the step counter increment. The `next_state` body becomes a flat dispatch match; `EmitQueued` and `CompleteActiveOutput` use `or_else` chaining to preserve high-priority-first ordering and the response-then-multi-packet completion order. Add three predicate methods on `ConnectionState` (`is_output_idle`, `can_install_output`, `can_emit_low_priority`) to replace inline compound boolean expressions and a duplicated `!shutdown_requested && active_output == Idle` guard, addressing the CodeScene Complex Method (CC=19), Complex Conditional, and Bumpy Road Ahead findings. No behaviour change; `cargo test -p wireframe-verification` and `cargo clippy -p wireframe-verification --all-targets --all-features -- -D warnings` both pass.
There was a problem hiding this comment.
Gates Failed
Enforce advisory code health rules
(1 file with Code Duplication)
Gates Passed
5 Quality Gates Passed
See analysis details in CodeScene
Reason for failure
| Enforce advisory code health rules | Violations | Code Health Impact | |
|---|---|---|---|
| model.rs | 1 advisory rule | 9.39 | Suppress |
Quality Gate Profile: Pay Down Tech Debt
Install CodeScene MCP: safeguard and uplift AI-generated code. Catch issues early with our IDE extension and CLI tool.
| fn apply_emit_high(state: &ConnectionState) -> Option<ConnectionState> { | ||
| if !state.high_priority_queued { | ||
| return None; | ||
| } | ||
| let mut next = Self::stepped(state); | ||
| next.high_priority_queued = false; | ||
| next.emitted_high_priority = true; | ||
| next.fairness_allows_low = true; | ||
| Some(next) | ||
| } |
There was a problem hiding this comment.
❌ New issue: Code Duplication
The module contains 4 functions with similar structure: PlaceholderConnectionModel.apply_emit_active_frame,PlaceholderConnectionModel.apply_emit_high,PlaceholderConnectionModel.apply_emit_low,PlaceholderConnectionModel.apply_shutdown
Summary
Introduce an internal crate for formal verification support:
crates/wireframe-verification. It provides a shared Stateright harness, a placeholder connection model, and tests to exercise the verification workflow. This lays the groundwork for roadmap item 15.1.2 and later extensions toward the real ConnectionActor model.Changes
crates/wireframe-verificationCargo.toml: addcrates/wireframe-verificationto workspace members; keep default member as rootdocs/execplans/15-1-2-wireframe-verification-crate.mddescribing purpose, constraints, and validation goalsdocs/formal-verification-methods-in-wireframe.md,docs/roadmap.md, and related sections to reflect the new cradle and its scopeWhy
This implements the 15.1.2 milestone: an internal, non-published crate to host Stateright models and a reusable bounded-checker harness, enabling safe, repeatable verification workflows while the real ConnectionActor model matures in follow-up roadmap items.
How to test
Next steps
Validation plan (from ExecPlan)
cargo test -p wireframe-verificationpassespublish = false)◳ Generated by DevBoxer ◰
ℹ️ Tag @devboxerhub to ask questions and address PR feedback
📎 Task: https://www.devboxer.com/task/7849551b-1b21-4381-a196-34d9041706d2
Summary by Sourcery
Introduce an internal
wireframe-verificationcrate for Stateright-based formal models and a shared verification harness, and wire it into the workspace, tests, and documentation as the home for connection-actor verification work.New Features:
wireframe-verificationcrate providing a placeholder connection-actor Stateright model and shared bounded-checker harness.Enhancements:
Build:
Cargo.tomlworkspace members to includecrates/wireframe-verificationwithout changing default members.Documentation:
wireframedependency features and workspace metadata behavior after adding the verification crate.Tests:
rstest.