Skip to content

feat: unify complexity threshold between cfusa comp and check's COMP001 - #113

Merged
SoundMatt merged 1 commit into
mainfrom
feat/comp-threshold-asil-unify
Aug 13, 2026
Merged

feat: unify complexity threshold between cfusa comp and check's COMP001#113
SoundMatt merged 1 commit into
mainfrom
feat/comp-threshold-asil-unify

Conversation

@SoundMatt

Copy link
Copy Markdown
Owner

Fixes #107. Part of the ASIL-scaling initiative tracked in #103. Builds on #104 (merged).

Summary

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 Threshold (same as)
ASIL-D 4 DAL-A
ASIL-C 10 DAL-B
ASIL-B 15 DAL-C
ASIL-A 20 DAL-D

When both a DO-178C DAL and an ISO 26262 ASIL are declared, the stricter (lower) threshold wins — same combination rule --dal/--asil in cfusa coverage (#106) already uses.

Testing

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), 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-COMP002 turned out to already be a pre-existing, unregistered tag in cmd_comp.c; renamed my new requirement to REQ-COMPTHR001 before it could clobber that one's meaning.)

  • ctest: 42/42 passing.
  • cfusa check --dir .: 0 errors.
  • cfusa trace --dir .: new REQ-COMPTHR001 traced + tested correctly, no dangling references, no id collision.

🤖 Generated with Claude Code

…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>
Comment thread tests/test_safety_rules.c
if (strcmp(r->id, "COMP001") == 0) r->run(SR_DIR, &cfg, &rpt);
}
int n = rpt.warning_count;
cfusa_report_free(&rpt);
Comment thread tests/test_safety_rules.c
if (strcmp(r->id, "COMP001") == 0) r->run(SR_DIR, &cfg, &rpt);
}
int n = rpt.warning_count;
cfusa_report_free(&rpt);
@SoundMatt
SoundMatt merged commit 7a35496 into main Aug 13, 2026
10 checks passed
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.

Unify cyclomatic-complexity threshold between cfusa comp's --asil-* aliases and check's automatic COMP001 gate

2 participants