Skip to content

test(audit-engine): golden gates pin finding message, value and expected (#229) - #1361

Closed
nc9 wants to merge 3 commits into
mainfrom
test/golden-message-229
Closed

nc9 wants to merge 3 commits into
mainfrom
test/golden-message-229

Conversation

@nc9

@nc9 nc9 commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Closes #229

  • Golden snapshot and divergence report now carry message, value and expected, with tie-breakers so ordering is stable.
  • New pinned baseline tests/golden/finding-messages.json (per rule: digit-normalized distinct lines + digest) with a readable per-rule diff on failure and UPDATE_GOLDEN=1 to regenerate.
  • streaming-rules-golden finding tuples include the text fields; v1/v2 now compared on them.
  • fingerprint-parity.test.ts renamed fingerprint-parity-golden.test.ts so test:golden runs it.
  • Surfaced v1 and streaming engines count a 4xx error page differently in per-page-rule messages (31 vs 30 pages) #1359 (v1 vs streaming page count differs for a bodyless 404 in two messages); exempted in that one edge test with the issue ref.

Test-only. Skill change: none.

nik

@claude

claude Bot commented Oct 30, 2026

Copy link
Copy Markdown

Test-only change, and the approach is sound. I found no blocking problems. I only read the diff; I did not run the suites.

  • (low) streaming-rules-golden.test.ts findingTuples: ${check.value ?? ""} and ${check.expected ?? ""} stringify object or array values as [object Object]. Two different structured values would compare equal there. The new golden-baseline.ts helper already uses JSON.stringify, so use the same here.
  • (low) golden-finding-messages-229.test.ts: with UPDATE_GOLDEN=1 the test writes the file and returns without asserting, so a run with that variable set in CI would pass with no check. Consider failing when process.env.CI is set. Writing the file with JSON.stringify(actual, null, 1) is fine.
  • (nit) The -229 issue suffix in the test file name is unlike its neighbours. The fingerprint-parity-golden.test.ts rename is good. Please run bun run scripts/test-suites.ts --check to confirm the new file lands in exactly one suite.
  • (nit) The exemption for url/slug-convention and perf/total-byte-weight hides all of their text differences in that edge test, not only the page count. This is acceptable because it references v1 and streaming engines count a 4xx error page differently in per-page-rule messages (31 vs 30 pages) #1359, but a narrower normalisation would keep the other fields checked.
  • (nit) The exports in a test file (pinMessages, diffPinned) are only used locally. Importing them from another test file would re-register its tests.

@claude

claude Bot commented Oct 30, 2026

Copy link
Copy Markdown

Review of #1361. The pinning approach looks sound, and the digit-normalized lines plus a digest give a readable diff. Findings:

  • (medium) .secrets.baseline:253,256 still lists packages/audit-engine/tests/fingerprint-parity.test.ts, which this PR renames. detect-secrets will probably report the baseline as updated and fail CI. Per AGENTS.md, regenerate the baseline, git add it and rerun the scan to exit 0.
  • (low) fingerprint.ts:23 and template-cluster-key-golden.test.ts:12 still refer to fingerprint-parity.test.ts. Update both to the new name.
  • (low) golden-finding-messages-229.test.ts: the UPDATE_GOLDEN=1 branch returns without failing, so a stray env var in CI silently rewrites the pin and passes. Consider refusing to write when CI is set.
  • (low) The pin test runs the full 500-page engine capture with a 120s timeout. The golden suite is already memory heavy, so confirm test-suites.ts --check and the golden job's memory still hold.
  • (nit) streaming-rules-golden.test.ts: the findingTuples signature and tuple line exceed the formatter width. packages/audit-engine is not covered by CI format, so this is cosmetic.
  • (nit) expect(divergences).toEqual([]) after the throw is unreachable when it would fail. It is harmless.

nc9 added 3 commits October 31, 2026 06:18
…s; fingerprint parity test joins test:golden #229

Signed-off-by: Nik Cubrilovic <[email protected]>
…exemption to digits, fix stale filenames #229

Signed-off-by: Nik Cubrilovic <[email protected]>
@nc9
nc9 force-pushed the test/golden-message-229 branch from d2c6c01 to 888b60a Compare October 30, 2026 19:19
@claude

claude Bot commented Oct 30, 2026

Copy link
Copy Markdown

Review of #1361: test-only change. I read the diff but did not run the tests.

  • (low) golden-finding-messages-229.test.ts: the UPDATE_GOLDEN=1 branch returns early and passes silently. Running the whole suite with that variable set in CI would regenerate the pin and go green. Consider failing when process.env.CI is set.
  • (low) golden-finding-messages-229.test.ts: the digest is only 48 bits of sha1 over the lines. That is fine as a change detector, but the file comment says it catches a changed count or value, and that only holds because the digits are hashed. This is OK, just worth keeping in mind when reading failures.
  • (nit) streaming-rules-golden.test.ts: the new findingTuples line is very long and the nested template literal is hard to read. Split it into a small helper. Packages are not format-checked by CI, but it is still hard to review.
  • (nit) streaming-rules-golden.test.ts: the digit-masking exemption for url/slug-convention and perf/total-byte-weight hides any number drift in those two rules for that edge test. This is acceptable because it references v1 and streaming engines count a 4xx error page differently in per-page-rule messages (31 vs 30 pages) #1359, but remove it when v1 and streaming engines count a 4xx error page differently in per-page-rule messages (31 vs 30 pages) #1359 is fixed.
  • (nit) The new test file name has an -229 suffix, which is an issue number rather than a topic. It also exports helpers from a test file. Neither is a problem, and the *golden* glob picks the file up for test:golden.

The fingerprint-parity rename into the *golden* glob is a good catch. The fingerprint comment is updated to match, and the pinned messages contain no paths or timestamps, so the baseline should be stable.

@nc9

nc9 commented Oct 30, 2026

Copy link
Copy Markdown
Contributor Author

Landed in v0.0.145 as 330433ca ab97400b fd3908fc via #1377. Release: https://github.com/squirrelscan/squirrelscan/releases/tag/v0.0.145. Closing this original.

nik

@nc9 nc9 closed this Oct 30, 2026
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.

Engine golden gate ignores finding message/value/expected, so a re-fingerprinting change passes silently

1 participant