feat: unify complexity threshold between cfusa comp and check's COMP001 - #113
Merged
Conversation
…01 (#107) check's automatic COMP001 gate (comp_threshold() in cmd_safety_rules.c) previously only recognized DO-178C DAL tags in .fusa.json's standards[] array, so a project declaring only ISO 26262 (e.g. standards: ["iso26262:ASIL-D"]) silently got the unscaled default threshold (10) instead of the ASIL-appropriate one (4), unless it separately ran 'cfusa comp --asil-d'. comp_threshold() now also recognizes an ISO 26262 ASIL declaration, using the same threshold table cmd_comp.c's --asil-d/c/b/a aliases already use (ASIL D=4, C=10, B=15, A=20). When both a DO-178C DAL and an ISO 26262 ASIL are declared, the stricter (lower) threshold wins — a project claiming both standards must satisfy whichever is more demanding, same combination rule --dal/--asil in cfusa coverage (#106) already uses. 4 new regression tests in tests/test_safety_rules.c using a deliberately-crafted V(G)=5 function that's clean under the unscaled default (10) and DAL-D (20) but exceeds ASIL-D's threshold (4) — a probe that only fires when the ASIL-scaled threshold is genuinely the one in effect, plus a boundary test confirming check's ASIL-D threshold exactly matches 'cfusa comp --asil-d' (4, not 3 or 5). Part of #103. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Signed-off-by: Matt Jones <47545907+SoundMatt@users.noreply.github.com>
| if (strcmp(r->id, "COMP001") == 0) r->run(SR_DIR, &cfg, &rpt); | ||
| } | ||
| int n = rpt.warning_count; | ||
| cfusa_report_free(&rpt); |
| if (strcmp(r->id, "COMP001") == 0) r->run(SR_DIR, &cfg, &rpt); | ||
| } | ||
| int n = rpt.warning_count; | ||
| cfusa_report_free(&rpt); |
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.
Fixes #107. Part of the ASIL-scaling initiative tracked in #103. Builds on #104 (merged).
Summary
check's automaticCOMP001gate (comp_threshold()incmd_safety_rules.c) previously only recognized DO-178C DAL tags in.fusa.json'sstandards[]array, so a project declaring only ISO 26262 (e.g.standards: ["iso26262:ASIL-D"]) silently got the unscaled default threshold (10) instead of the ASIL-appropriate one (4), unless it separately rancfusa comp --asil-d.comp_threshold()now also recognizes an ISO 26262 ASIL declaration, using the same threshold tablecmd_comp.c's--asil-d/c/b/aaliases already use:When both a DO-178C DAL and an ISO 26262 ASIL are declared, the stricter (lower) threshold wins — same combination rule
--dal/--asilincfusa coverage(#106) already uses.Testing
4 new regression tests in
tests/test_safety_rules.cusing a deliberately-crafted V(G)=5 function that's clean under the unscaled default (10) and DAL-D (20) but exceeds ASIL-D's threshold (4) — a probe that only fires when the ASIL-scaled threshold is genuinely the one in effect — plus a boundary test confirmingcheck's ASIL-D threshold exactly matchescfusa comp --asil-d(4, not 3 or 5), and a combination test proving DAL-D's lax threshold doesn't suppress an ASIL-D declaration given alongside it.(Caught and fixed a requirement-id collision while writing this —
REQ-COMP002turned out to already be a pre-existing, unregistered tag incmd_comp.c; renamed my new requirement toREQ-COMPTHR001before it could clobber that one's meaning.)ctest: 42/42 passing.cfusa check --dir .: 0 errors.cfusa trace --dir .: newREQ-COMPTHR001traced + tested correctly, no dangling references, no id collision.🤖 Generated with Claude Code