Skip to content

Commit a85a54c

Browse files
committed
feat(resources): implement resource management system - Add canonical format for binary resources - Add verification functionality - Delete deprecated resource-tests module - Update panic registry documentation
1 parent 1f31aa8 commit a85a54c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+5182
-2955
lines changed

.cargo/config.toml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,13 @@
11
[alias]
2-
xtask = "run --package xtask --quiet --"
2+
xtask = "run --package xtask --quiet --"
3+
4+
[build]
5+
# Configure rustflags for different build operations
6+
7+
# For coverage builds, define a "coverage" cfg to conditionally disable problematic modules
8+
[target.'cfg(all())']
9+
rustflags = ["--cfg=coverage"]
10+
11+
# For llvm-cov, define a "coverage" flag to disable problematic modules
12+
[target.'cfg(llvm_coverage)']
13+
rustflags = ["--cfg=coverage"]

.github/workflows/publish.yml

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,34 @@ jobs:
105105
# Run coverage separately to handle errors better
106106
- name: Generate code coverage
107107
run: |
108-
# Generate coverage data using the new full approach
109-
just coverage-full || {
108+
# Generate coverage using the robust xtask command
109+
cargo xtask robust-coverage --exclude wrt-host --html || {
110110
echo "::warning::Failed to generate coverage data. Creating placeholder..."
111111
mkdir -p target/coverage/html
112112
echo "<h1>Coverage Report Not Available</h1>" > target/coverage/html/index.html
113-
mkdir -p docs/source
113+
114114
cp docs/source/_generated_coverage_summary.rst.template docs/source/_generated_coverage_summary.rst || true
115115
}
116+
117+
# Create a minimum viable coverage report if it doesn't exist
118+
if [ ! -d "target/coverage/html" ]; then
119+
echo "::warning::Creating minimal coverage report directory..."
120+
mkdir -p target/coverage/html
121+
echo "<h1>Coverage Report Not Available</h1><p>The coverage report could not be generated due to build errors.</p>" > target/coverage/html/index.html
122+
fi
123+
124+
# Ensure coverage summary exists for documentation
125+
if [ ! -f "docs/source/_generated_coverage_summary.rst" ]; then
126+
echo "::warning::Creating coverage summary placeholder..."
127+
mkdir -p docs/source
128+
cp docs/source/_generated_coverage_summary.rst.template docs/source/_generated_coverage_summary.rst 2>/dev/null || {
129+
echo ".. container:: coverage-summary" > docs/source/_generated_coverage_summary.rst
130+
echo "" >> docs/source/_generated_coverage_summary.rst
131+
echo " **Code Coverage:** 0.00% (0/0 lines)" >> docs/source/_generated_coverage_summary.rst
132+
echo "" >> docs/source/_generated_coverage_summary.rst
133+
echo " \`Full HTML Report <../_static/coverage/index.html>\`_" >> docs/source/_generated_coverage_summary.rst
134+
}
135+
fi
116136
117137
- name: Determine version
118138
id: determine-version

Cargo.lock

Lines changed: 12 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/source/conf.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,19 @@ def patched_process_doc(self, env, docname, document):
136136
dict(directive="safety", title="Safety", prefix="SAFETY_", color="#FF5D73", style="node"),
137137
dict(directive="qual", title="Qualification", prefix="QUAL_", color="#9370DB", style="node"),
138138
dict(directive="constraint", title="Constraint", prefix="CNST_", color="#4682B4", style="node"),
139+
dict(directive="panic", title="Panic", prefix="WRTQ-", color="#E74C3C", style="node"),
139140
]
140141

141142
# Add option specs to register additional options for directives
142-
needs_extra_options = ['rationale', 'verification', 'mitigation', 'implementation']
143+
needs_extra_options = [
144+
'rationale',
145+
'verification',
146+
'mitigation',
147+
'implementation',
148+
'safety_impact',
149+
'status',
150+
'handling_strategy'
151+
]
143152

144153
# Allow all sphinx-needs options for all directives
145154
needs_allow_unsafe_options = True
@@ -152,8 +161,21 @@ def patched_process_doc(self, env, docname, document):
152161
'safety_template': '**Hazard**: {{content}}\n\n**Mitigation**: {{mitigation}}',
153162
'qualification_template': '**Status**: {{status}}\n\n**Implementation**: {{implementation}}',
154163
'constraint_template': '**Constraint**: {{content}}\n\n**Rationale**: {{rationale}}\n\n**Verification**: {{verification}}',
164+
'panic_template': '**Panic Condition**: {{content}}\n\n**Safety Impact**: {{safety_impact}}\n\n**Status**: {{status}}\n\n**Handling Strategy**: {{handling_strategy}}',
155165
}
156166

167+
# Tags for filtering and displaying panic entries
168+
needs_tags = [
169+
dict(name="panic", description="Panic documentation entry", bgcolor="#E74C3C"),
170+
dict(name="low", description="Low safety impact", bgcolor="#2ECC71"),
171+
dict(name="medium", description="Medium safety impact", bgcolor="#F39C12"),
172+
dict(name="high", description="High safety impact", bgcolor="#E74C3C"),
173+
]
174+
175+
# Configure needs roles for referencing
176+
needs_role_need_template = "{title} ({id})"
177+
needs_role_need_max_title_length = 30
178+
157179
needs_id_length = 7
158180
needs_title_optional = True
159181
needs_file_pattern = '**/*.rst'

docs/source/development/panic_documentation.rst

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ All functions that may panic should include a "Panics" section in their document
3131
///
3232
/// Safety impact: [LOW|MEDIUM|HIGH] - [Brief explanation of the safety implication]
3333
///
34-
/// Tracking: WRTQ-XXX (qualification requirement tracking ID)
34+
/// Tracking: WRTQ-XXX (qualification requirement tracking ID).
3535
3636
Safety Impact Levels
3737
~~~~~~~~~~~~~~~~~~~
@@ -59,23 +59,32 @@ Implementation Approach
5959
Panic Registry
6060
-------------
6161

62-
We maintain a centralized panic registry in ``docs/source/development/panic_registry.csv`` that includes:
62+
We maintain panic documentation in two formats:
6363

64-
- File path
65-
- Function name
66-
- Line number
67-
- Panic condition
68-
- Safety impact
69-
- Tracking ID
70-
- Resolution status (Todo, In Progress, Resolved)
71-
- Handling strategy (when determined)
64+
1. A CSV file at ``docs/source/development/panic_registry.csv`` that is easy to read and maintain
65+
2. A structured RST file using sphinx-needs at ``docs/source/development/panic_registry.rst`` for qualification documentation
66+
67+
The registry is automatically updated by the ``xtask update-panic-registry`` command, which scans the codebase for documented panics and updates both formats.
68+
69+
CSV Registry
70+
~~~~~~~~~~~
71+
72+
The CSV registry includes the following information:
7273

7374
.. csv-table:: Panic Registry
7475
:file: panic_registry.csv
7576
:header-rows: 1
7677
:widths: 20, 15, 5, 20, 5, 10, 10, 15
7778

78-
The registry is automatically updated by the ``xtask update-panic-registry`` command, which scans the codebase for documented panics.
79+
Sphinx-Needs Registry
80+
~~~~~~~~~~~~~~~~~~~~
81+
82+
For qualification purposes, all panic points are also available in a structured format using sphinx-needs in the :doc:`panic_registry` document. This allows:
83+
84+
- Cross-referencing of panic points in documentation
85+
- Filtering and searching by safety impact level
86+
- Integration with qualification traceability matrices
87+
- Status tracking and reporting
7988

8089
Common Panic Scenarios
8190
---------------------
@@ -158,7 +167,4 @@ Responsible Teams
158167
Example Code
159168
-----------
160169

161-
Below is an example demonstrating proper panic documentation:
162-
163-
.. include:: examples/panic_doc_example.rs
164-
:code: rust
170+
Below is an example demonstrating proper panic documentation:
Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
File Path,Function Name,Line Number,Panic Condition,Safety Impact,Tracking ID,Resolution Status,Handling Strategy,Last Updated
2-
wrt/src/execution.rs,f32_nearest,389,This function will panic if the provided value is not an F32 value.,,,Todo,,2025-04-25
3-
wrt/src/execution.rs,f64_nearest,423,This function will panic if the provided value is not an F64 value.,,,Todo,,2025-04-25
4-
xtask/src/check_panics.rs,run,87,println!("///"); println!("/// This function will panic if [describe condition]"); println!("///");,[LOW|MEDIUM|HIGH]");,[WRTQ-XXX]");,Todo,,2025-04-25
5-
xtask/src/update_panic_registry.rs,run,133,,,,Todo,,2025-04-25
6-
xtask/src/update_panic_registry.rs,run,173,,,,Todo,,2025-04-25
7-
xtask/src/update_panic_registry.rs,run,180,,,,Todo,,2025-04-25
8-
wrt-sync/src/mutex.rs,new,53,This function does not panic.,,,Todo,,2025-04-25
9-
wrt-types/src/safe_memory.rs,new,55,This function will panic if the initial integrity verification fails. This can happen if memory corruption is detected during initialization.,,,Todo,,2025-04-25
10-
wrt-types/src/bounded.rs,push,194,This function does not panic.,,,Todo,Return Result instead of panic,2025-04-25
11-
wrt-decoder/src/module.rs,encode,214,This function will panic if it attempts to access the last element of an empty custom_sections vector, which can happen if the implementation tries to process a custom section before any custom sections have been added to the module.,,,Todo,,2025-04-25
12-
wrt-runtime/src/memory.rs,buffer,229,In `no_std` environments, this method will panic if the read lock for the metrics cannot be acquired. This would typically only happen in case of a deadlock or if the lock is poisoned due to a panic in another thread holding the lock.,,,Todo,,2025-04-25
13-
wrt-runtime/src/memory.rs,peak_memory,249,In `no_std` environments, this method will panic if the read lock for the metrics cannot be acquired. This would typically only happen in case of a deadlock or if the lock is poisoned due to a panic in another thread holding the lock.,,,Todo,,2025-04-25
14-
wrt-runtime/src/memory.rs,access_count,269,In `no_std` environments, this method will panic if the write lock for the metrics cannot be acquired. This would typically only happen in case of a deadlock or if the lock is poisoned due to a panic in another thread holding the lock.,,,Todo,,2025-04-25
15-
wrt-runtime/src/memory.rs,increment_access_count,288,In `no_std` environments, this method will panic if the write lock for the metrics cannot be acquired. This would typically only happen in case of a deadlock or if the lock is poisoned due to a panic in another thread holding the lock.,,,Todo,,2025-04-25
2+
wrt/src/execution.rs,f32_nearest,389,This function will panic if the provided value is not an F32 value.,[LOW|MEDIUM|HIGH] - [Brief explanation of the safety implication],WRTQ-XXX (qualification requirement tracking ID).,Todo,,2025-04-25
3+
wrt/src/execution.rs,f64_nearest,425,This function will panic if the provided value is not an F64 value.,[LOW|MEDIUM|HIGH] - [Brief explanation of the safety implication],WRTQ-XXX (qualification requirement tracking ID).,Todo,,2025-04-25
4+
wrt-sync/src/mutex.rs,new,53,This function does not panic.,[LOW|MEDIUM|HIGH] - [Brief explanation of the safety implication],WRTQ-XXX (qualification requirement tracking ID).,Todo,,2025-04-25
5+
wrt-types/src/safe_memory.rs,new,50,This function will panic if the initial integrity verification fails. This can happen if memory corruption is detected during initialization.,[LOW|MEDIUM|HIGH] - [Brief explanation of the safety implication],WRTQ-XXX (qualification requirement tracking ID).,Todo,,2025-04-25
6+
wrt-types/src/bounded.rs,push,196,This function does not panic.,[LOW|MEDIUM|HIGH] - [Brief explanation of the safety implication],WRTQ-XXX (qualification requirement tracking ID).,Todo,Return Result instead of panic,2025-04-25
7+
wrt-decoder/src/module.rs,encode,214,This function will panic if it attempts to access the last element of an empty custom_sections vector, which can happen if the implementation tries to process a custom section before any custom sections have been added to the module.,[LOW|MEDIUM|HIGH] - [Brief explanation of the safety implication],WRTQ-XXX (qualification requirement tracking ID).,WRTQ-XXX (qualification requirement tracking ID).,WRTQ-XXX (qualification requirement tracking ID).,2025-04-25
8+
wrt-runtime/src/memory.rs,buffer,229,In `no_std` environments, this method will panic if the read lock for the metrics cannot be acquired. This would typically only happen in case of a deadlock or if the lock is poisoned due to a panic in another thread holding the lock.,[LOW|MEDIUM|HIGH] - [Brief explanation of the safety implication],WRTQ-XXX (qualification requirement tracking ID).,WRTQ-XXX (qualification requirement tracking ID).,WRTQ-XXX (qualification requirement tracking ID).,2025-04-25
9+
wrt-runtime/src/memory.rs,peak_memory,251,In `no_std` environments, this method will panic if the read lock for the metrics cannot be acquired. This would typically only happen in case of a deadlock or if the lock is poisoned due to a panic in another thread holding the lock.,[LOW|MEDIUM|HIGH] - [Brief explanation of the safety implication],WRTQ-XXX (qualification requirement tracking ID).,WRTQ-XXX (qualification requirement tracking ID).,WRTQ-XXX (qualification requirement tracking ID).,2025-04-25
10+
wrt-runtime/src/memory.rs,access_count,273,In `no_std` environments, this method will panic if the write lock for the metrics cannot be acquired. This would typically only happen in case of a deadlock or if the lock is poisoned due to a panic in another thread holding the lock.,[LOW|MEDIUM|HIGH] - [Brief explanation of the safety implication],WRTQ-XXX (qualification requirement tracking ID).,WRTQ-XXX (qualification requirement tracking ID).,WRTQ-XXX (qualification requirement tracking ID).,2025-04-25
11+
wrt-runtime/src/memory.rs,increment_access_count,294,In `no_std` environments, this method will panic if the write lock for the metrics cannot be acquired. This would typically only happen in case of a deadlock or if the lock is poisoned due to a panic in another thread holding the lock.,[LOW|MEDIUM|HIGH] - [Brief explanation of the safety implication],WRTQ-XXX (qualification requirement tracking ID).,WRTQ-XXX (qualification requirement tracking ID).,WRTQ-XXX (qualification requirement tracking ID).,2025-04-25
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
# Panic Registry Implementation Proposal
2+
3+
## Overview
4+
5+
This document proposes an enhanced approach to tracking panics in the WRT codebase by:
6+
7+
1. Maintaining the existing CSV-based panic registry for easy reading and editing
8+
2. Adding a new RST-based representation using sphinx-needs for qualification documentation
9+
3. Implementing validation to ensure all panic documentation includes safety impact and tracking information
10+
11+
## Implementation Details
12+
13+
### 1. Enhanced `update_panic_registry.rs`
14+
15+
The existing `xtask update-panic-registry` command has been extended to:
16+
17+
- Continue to generate the CSV file as before
18+
- Additionally generate an RST file with sphinx-needs directives
19+
- Parse safety impact levels and categorize them (LOW/MEDIUM/HIGH)
20+
- Automatically create WRTQ-XXX tracking IDs for entries without them
21+
22+
### 2. sphinx-needs Configuration
23+
24+
The `docs/source/conf.py` file has been updated with:
25+
26+
- A new `panic` directive type with `WRTQ-` prefix
27+
- Additional option specs for panic-specific fields (safety_impact, status, handling_strategy)
28+
- Tags for filtering panic entries by safety impact level (low, medium, high)
29+
- A custom template for displaying panic entries
30+
31+
### 3. Documentation Updates
32+
33+
The panic documentation guidelines have been updated to:
34+
35+
- Explain both CSV and RST formats
36+
- Provide guidance on how to use the sphinx-needs representation
37+
- Maintain the existing CSV table for backward compatibility
38+
39+
### 4. Validation Enhancements
40+
41+
The `check_panics` command has been enhanced to:
42+
43+
- Check for undocumented panics as before
44+
- Additionally validate that panic documentation includes required fields:
45+
- Safety impact: [LOW|MEDIUM|HIGH] - [Brief explanation]
46+
- Tracking: WRTQ-XXX (qualification tracking ID)
47+
- Generate appropriate documentation templates when run with `--fix`
48+
49+
## Benefits
50+
51+
This approach provides several advantages:
52+
53+
1. **Dual Representation**: Maintains the simple CSV format while adding structured qualification documentation
54+
2. **Integration with Qualification**: Enables cross-referencing panic points in qualification documentation
55+
3. **Automated Validation**: Ensures consistent documentation of safety impact and tracking IDs
56+
4. **Improved Reporting**: Enables filtering and searching panic entries by various attributes
57+
5. **Traceability**: Links panic points to qualification requirements through the WRTQ-XXX IDs
58+
59+
## Usage
60+
61+
For developers:
62+
63+
1. Document panics in Rust code following the established format
64+
2. Run `xtask check-panics --fix` to add templates for undocumented panics
65+
3. Run `xtask update-panic-registry` to update both CSV and RST files
66+
67+
For documentation readers:
68+
69+
1. CSV format remains available for quick reference
70+
2. RST format provides enhanced filtering and cross-referencing capabilities
71+
3. Sphinx-needs features enable integration with qualification matrices
72+
73+
## Example of Generated RST Content
74+
75+
```rst
76+
.. _panic-registry:
77+
78+
Panic Registry
79+
==============
80+
81+
This document contains all documented panic conditions in the WRT codebase.
82+
Each panic is tracked as a qualification requirement using sphinx-needs.
83+
84+
.. contents:: Table of Contents
85+
:local:
86+
:depth: 2
87+
88+
Summary
89+
-------
90+
91+
* Total panic points: 14
92+
* Status:
93+
* Todo: 14
94+
* In Progress: 0
95+
* Resolved: 0
96+
97+
The original CSV version of this registry is maintained at:
98+
`docs/source/development/panic_registry.csv`_
99+
100+
.. csv-table:: Panic Registry CSV
101+
:file: panic_registry.csv
102+
:header-rows: 1
103+
:widths: 20, 15, 5, 20, 5, 10, 10, 15
104+
105+
Panic Details
106+
------------
107+
108+
.. qual:: f32_nearest
109+
:id: WRTQ-0001
110+
:status: Todo
111+
:implementation:
112+
:tags: panic, medium
113+
114+
**File:** wrt/src/execution.rs
115+
**Line:** 389
116+
**Function:** f32_nearest
117+
**Safety Impact:** MEDIUM - Incorrect numerical results
118+
**Last Updated:** 2025-04-25
119+
120+
This function will panic if the provided value is not an F32 value.
121+
```
122+
123+
## Next Steps
124+
125+
1. Run the updated `xtask update-panic-registry` command to generate the initial RST file
126+
2. Update qualification documentation to reference panic points using sphinx-needs
127+
3. Begin filling in missing safety impact assessments and tracking IDs
128+
129+
This implementation enables the WRT project to maintain better traceability between panic points and qualification requirements, while keeping the existing CSV format for ease of maintenance.

docs/source/qualification/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ This section contains all qualification-related documents for the WebAssembly Ru
2222
technical_report
2323
qualification_report
2424
internal_procedures
25+
panic_registry
2526

2627
Overview
2728
--------

0 commit comments

Comments
 (0)