Skip to content

fix(core): a tolerated skip no longer erases an earlier verdict (#293) - #365

Merged
AkashS0510 merged 1 commit into
mainfrom
fix/skip-erases-verdict
Sep 4, 2026
Merged

fix(core): a tolerated skip no longer erases an earlier verdict (#293)#365
AkashS0510 merged 1 commit into
mainfrom
fix/skip-erases-verdict

Conversation

@AkashS0510

Copy link
Copy Markdown
Collaborator

Closes #293.

The bug

generate_evaluator_result rolled resources up with one variable that every branch wrote to. A failing resource set it False; a tolerated skip set it None, unconditionally. Two consequences, both order-dependent:

  • Violation, then skip → skipped. The None id was removed from eval_expression, so the violation vanished. Under !id the policy passed.
  • Pass, then skip → skipped. A plan with one compliant resource and one destroyed one exited 1, reading as a tool failure.

A destroyed resource is severity 0, tolerated at every error_tolerance, so every terraform_plan attribute policy was exposed on every plan that destroys a resource of the type it checks. The error_tolerance: 2 idiom ("where the attribute exists, it must be X") was exposed on any plan mixing resources with and without the attribute.

The fix

Two flags, decided once at the end:

Resources Verdict
any failure False
no failure, at least one evaluated True
every resource tolerated away None

The all-skipped case, the hard-failure branches (bare provider error, severity above tolerance) and the empty-input case are unchanged. [PASS, skip, PASS] is now True; the issue asked for this to be decided here.

Verdict change

This changes exit codes on real plans, so CHANGELOG labels it a verdict change under Fixed:

Plan Before After
compliant bucket + destroyed bucket, tags policy 1 0
open security group + group with no ingress blocks, error_tolerance: 2 1 3
RDS retention 3 + RDS retention unset, GreaterThanEqualTo 7 with tolerance 2 0 3

Tests

Regression tests for both orderings of fail+skip, three shapes of pass+skip, all-skipped, and a bare provider error followed by a skip. core, cli, providers, platform and the readme tests pass. tests/tui/test_app.py hangs on main as well in this environment and was excluded from the local run.

Found while a second agent session exercised the new agent skills (#361) against the engine; those skills carry a warning about this bug that can be removed once this merges.

Closes #293.

generate_evaluator_result rolled resources up with one variable that every branch wrote to:
a failing resource set it False, a tolerated skip set it None, unconditionally. So a violating
resource followed by a skipped one reported the evaluator as skipped, the None id was removed
from eval_expression, and the violation vanished. A passing resource followed by a skipped one
reported skipped too, so a plan with one compliant and one destroyed resource exited 1. Both
depended on the order of resource_changes, and a destroyed resource is severity 0, which is
tolerated at every error_tolerance, so every terraform_plan attribute policy was exposed on
every plan that destroys a resource of the type it checks.

The roll-up is now two flags decided once at the end: any failure fails the evaluator;
otherwise it passes if at least one resource was actually evaluated; only when every resource
was tolerated away is it skipped. The all-skipped case, the hard-failure branches for bare
provider errors and above-tolerance severities, and the empty-input case are unchanged.

[PASS, skip, PASS] is now True. It used to print "Passed: 0 Failed: 0 Skipped: 1" and exit 1,
which read as a tool failure for a plan that was compliant.

Regression tests cover both orderings of fail+skip, three shapes of pass+skip, all-skipped,
and a bare provider error followed by a skip. Verified against real plans: a compliant bucket
next to a destroyed one now exits 0 (was 1); an open security group next to one with no
ingress blocks now exits 3 (was 1); an RDS instance with retention 3 next to one with
retention unset now exits 3 (was 0).
@sonarqubecloud

sonarqubecloud Bot commented Sep 4, 2026

Copy link
Copy Markdown

❌ The last analysis has failed.

See analysis details on SonarQube Cloud

@codecov

codecov Bot commented Sep 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
src/tirith/core/core.py 85.51% <100.00%> (+0.13%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@AkashS0510
AkashS0510 merged commit d41255b into main Sep 4, 2026
20 of 21 checks passed
@AkashS0510
AkashS0510 deleted the fix/skip-erases-verdict branch September 4, 2026 13:00
AkashS0510 added a commit that referenced this pull request Sep 4, 2026
PR #365 changed the roll-up so a tolerated skip no longer erases a sibling's verdict. Both skills
now state the fixed behaviour where they used to warn about the bug, and the SSH example's notes
say a skipped group leaves the bastion's failure standing. Re-verified: the probe plan that
masked the bastion before now exits 3, and a compliant bucket next to a destroyed one exits 0.
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.

fix(core): a tolerated skip erases an earlier real failure — verdicts depend on resource order

3 participants