Skip to content

feat: Halmos assert mode#69

Merged
GalloDaSballo merged 1 commit intomainfrom
feat-halmos-assert-mode
Sep 24, 2025
Merged

feat: Halmos assert mode#69
GalloDaSballo merged 1 commit intomainfrom
feat-halmos-assert-mode

Conversation

@0kn0t
Copy link
Copy Markdown
Contributor

@0kn0t 0kn0t commented Sep 24, 2025

sample output:

Recon Recap for create-chimera-app [WSL: Ubuntu]

Fuzzer overview

  • Fuzzer: HALMOS
  • Duration: 3.29s
  • Coverage: 0
  • Failed: 1
  • Passed: 10
  • Number of tests: 1

Results

Property Status
invariant_number_never_zero()
add_new_asset(uint8)
asset_approve(address,uint128)
asset_mint(address,uint128)
counter_increment()
counter_increment_asAdmin()
counter_setNumber1(uint256)
counter_setNumber2(uint256)
doomsday_increment_never_reverts()
switchActor(uint256)
switch_asset(uint256)

Broken Properties

Broken property

doomsday_increment_never_reverts

Sequence

// forge test --match-test test_doomsday_increment_never_reverts__0 -vv 
 function test_doomsday_increment_never_reverts__0() public {
   counter_setNumber1(115792089237316195423570985008687907853269984665640564039457584007913129639935);
   doomsday_increment_never_reverts();
}

Copilot AI review requested due to automatic review settings September 24, 2025 09:45
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for Halmos assert mode, which allows the tool to handle inline assertion failures in addition to standard [FAIL] lines. The changes enable proper detection and reporting of assertion failures that occur within target functions, improving coverage reporting accuracy.

Key changes:

  • Enhanced parsing to detect inline assertion failures alongside standard [FAIL] lines
  • Added target function signature parsing with full parameter information in reports
  • Improved counterexample generation logic to avoid duplicates and filter by failed properties

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/reportBuilder/reportBuilder.ts Updates regex patterns to capture full function signatures with parameters in property names
src/halmos/index.ts Adds comprehensive logic for parsing target functions, handling inline assertions, and synthesizing results
src/halmos/functionGenerator.ts Implements target function parsing and inline assertion failure detection with deduplication logic
package.json Version bump to 0.0.38

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

}
// 2) Inline assertion failures
// Example: Assertion failure detected in CryticToFoundry.doomsday_increment_never_reverts()
const assertionRe = /Assertion failure detected in\s+[\w$]+\.([^\)]+)\(\)/g;
Copy link

Copilot AI Sep 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The regex pattern has an unescaped closing parenthesis ) inside the character class. This should be escaped as \) to match a literal closing parenthesis.

Copilot uses AI. Check for mistakes.
Comment on lines +228 to +231
const m1 = /^CALL\s+[^:]+::([^\(]+)\(/.exec(sanitized);
if (m1 && m1[1]) return m1[1].trim();
const m2 = /^CALL\s+(0x[a-fA-F0-9]{8,40})::([^\(]+)\(/.exec(sanitized);
if (m2 && m2[2]) return m2[2].trim();
Copy link

Copilot AI Sep 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The two regex patterns are very similar and could be consolidated into a single pattern. Consider using /^CALL\s+(?:[^:]+|(0x[a-fA-F0-9]{8,40}))::([^\(]+)\(/ and adjusting the capture group handling accordingly.

Suggested change
const m1 = /^CALL\s+[^:]+::([^\(]+)\(/.exec(sanitized);
if (m1 && m1[1]) return m1[1].trim();
const m2 = /^CALL\s+(0x[a-fA-F0-9]{8,40})::([^\(]+)\(/.exec(sanitized);
if (m2 && m2[2]) return m2[2].trim();
const m = /^CALL\s+(?:[^:]+|(0x[a-fA-F0-9]{8,40}))::([^\(]+)\(/.exec(sanitized);
if (m && m[2]) return m[2].trim();

Copilot uses AI. Check for mistakes.
@GalloDaSballo GalloDaSballo merged commit e7083d7 into main Sep 24, 2025
0 of 2 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.

3 participants