Skip to content

Add failure_signature: normalise + hash errors to stable signatures#410

Merged
JE-Chen merged 1 commit into
devfrom
feat/failure-signature-batch
Jun 24, 2026
Merged

Add failure_signature: normalise + hash errors to stable signatures#410
JE-Chen merged 1 commit into
devfrom
feat/failure-signature-batch

Conversation

@JE-Chen

@JE-Chen JE-Chen commented Jun 24, 2026

Copy link
Copy Markdown
Member

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_signature strips 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 placeholders
  • failure_signature — a short stable SHA-256 of the normalised message
  • group_failures — group a list of errors by signature, most frequent first

This is the first (foundational) item of the test-robustness lane — pulled forward because the others consume it.

Design

  • Pure standard library (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).
  • 5 layers wired: core → facade __all__AC_failure_signature / AC_group_failures → read-only ac_* MCP tools (in flakiness_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.

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.
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 24 complexity · 0 duplication

Metric Results
Complexity 24
Duplication 0

View in Codacy

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.

@JE-Chen JE-Chen merged commit 2660cc8 into dev Jun 24, 2026
16 checks passed
@JE-Chen JE-Chen deleted the feat/failure-signature-batch branch June 24, 2026 17:34
@sonarqubecloud

Copy link
Copy Markdown

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.

1 participant