Add failure_signature: normalise + hash errors to stable signatures#410
Merged
Conversation
Two runs that failed the same way rarely have byte-identical error text (paths, line numbers, addresses, ids, timestamps differ), which defeats 'is this the same failure?' and 'which tests fail together?'. Strip the variable parts of an error to a canonical form and hash it (SHA-256) so the same kind of failure gets the same short signature across runs - the join key run diffing and flake clustering group on. group_failures buckets a list of errors by signature. Pure stdlib.
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 24 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
|
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.



Why
Two runs that failed the same way almost never have byte-identical error text — paths, line numbers, memory addresses, ids and timestamps differ every time. That defeats "is this the same failure as yesterday?" and "which tests fail together?".
failure_signaturestrips the variable parts of an error to a canonical form and hashes it (SHA-256), so the same kind of failure gets the same short signature across runs — the join key the rest of the test-robustness lane (run_diff,flake_cluster) will group on.normalize_error— collapse paths / hex addresses / UUIDs / timestamps /line N/ bare integers to placeholdersfailure_signature— a short stable SHA-256 of the normalised messagegroup_failures— group a list of errors by signature, most frequent firstThis is the first (foundational) item of the test-robustness lane — pulled forward because the others consume it.
Design
re+hashlib); ordered normaliser patterns (most-specific first so a path's trailing line number isn't half-collapsed). SHA-256 (Bandit-clean, no md5/sha1).__all__→AC_failure_signature/AC_group_failures→ read-onlyac_*MCP tools (inflakiness_tools) → Script Builder (Testing). Qt-free verified.Tests
test/unit_test/headless/test_failure_signature_batch.py— normalisation of paths/addr/line/timestamp, same-failure-same-signature across runs, different-failure-differs, length param, UUID + POSIX path, grouping with counts + example cap + empty-skip, and the executor paths + 5-layer wiring. 9 passed.