Repository navigation
feat(safety): safety manifest generator (--emit-manifest) - #290
Merged
Merged
Conversation
MISRA Phase 1: emit FLOW_CHECKED_ADD/SUB/MUL macros for signed integer
+,-,* operations. Uses __builtin_{add,sub,mul}_overflow on Clang/GCC
with a portable fallback for other compilers. Calls flow_overflow_handler
(abort + stderr message, overridable via FLOW_OVERFLOW_HANDLER) on trap.
Float and unsigned arithmetic are excluded: float overflow is IEEE
(Inf/NaN, not UB), unsigned wraparound is well-defined modular arithmetic.
Also fixes _infer_expr_type to unwrap memref_ prefix so memref_f32 array
accesses resolve to f32, not the i32 fallback.
Closes #263
Generated with [Devin](https://devin.ai)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Overflow-checked +,-,* broke existing tests and the flowc self-host roundtrip because the macros were always emitted. Now they only appear under FLOW_PROFILE=safety/flight or FLOW_OVERFLOW_CHECK=1, matching the -Werror pattern from MISRA Phase 0. - Add overflow_check parameter to CGenerator and flow_to_c - Auto-enable from FLOW_PROFILE env var - Move FLOW_CHECKED_ADD/SUB/MUL macros and flow_overflow_handler inside the overflow_checks_enabled guard - Add test_default_profile_no_overflow_check - Update existing overflow tests to use _c_overflow helper Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Add `flow transpile --c --emit-manifest` that collects safety facts from the AST, type checker, and C generator into a structured compliance report. The manifest has three categories per the safety profile design: PROVEN, REJECTED, REQUIRES EVIDENCE. Properties reported: - Integer overflow (MISRA 12.1 / CERT INT32-C) - Division by zero (MISRA 12.5 / CERT INT33-C) - Shift UB (MISRA 12.2 / CERT INT34-C) - RT-safety / @rt_safe call graph (Flow policy) - Dynamic allocation (MISRA 21.3) - Unbounded recursion (MISRA 17.2) - Unbounded loops (MISRA 17.4) - Null pointer dereference (MISRA 11.8 / CERT ERR33-C) Call graph analysis detects: - Recursive functions (cycle detection via DFS) - Heap-using functions (fixed-point propagation from malloc/calloc/etc) - RT-safe function verification (transitive banned-API reachability) Output formats: text (default) and JSON (--manifest-format json). Manifest goes to stderr so stdout stays clean for C output. 13 unit tests in test_safety_manifest.py covering recursion, heap, loops, RT-safety, overflow, div0, text/JSON output. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Contributor
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
--emit-manifestflag emits a structured safety compliance report to stderr--manifest-format json)Example
Test plan
test_safety_manifest.pyGenerated with Devin