Skip to content

test(rules): engine-path residency probe for the leaked-secrets collector #1552 - #1648

Closed
nc9 wants to merge 2 commits into
mainfrom
test/leaked-secrets-residency-1552
Closed

nc9 wants to merge 2 commits into
mainfrom
test/leaked-secrets-residency-1552

Conversation

@nc9

@nc9 nc9 commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Closes the last open box of #1552: an engine-level test that fails if the per-page retention of the leaked-secrets collector returns. Test only, no behaviour change.

What it does

packages/audit-engine/tests/leaked-secrets-residency-1552.test.ts runs helpers/leaked-secrets-residency-probe.ts in one child process (like residency-probe.ts for the page-rule residency test). The probe runs runStreamingRules over 16 pages of about 1.5 MB, each with secret-shaped values in two inline scripts and in an attribute (the attribute value is the one a record holds as a slice of the serialized markup), with only security/leaked-secrets enabled. It forces a GC after every batch and records heapStats().heapSize (process.memoryUsage().heapUsed lags string memory on Bun, which is why my first in-process try could not see the retention). The test asserts the heap grows by under 25% of a page per page, a ratio rather than an absolute size. About 4.5 s.

Measured

  • With the fix: about 85 KB a page (about 6% of a page); three runs pass.
  • Both copy layers removed: about 1.58 MB a page (105%), fails.

Mutation check (each mutant applied, run, restored, git diff --stat checked between runs)

  • detachSecret as identity: passes.
  • structuredClone in detachFromPage as identity: passes.
  • Both together: fails (heap per page 1,578,288 of 1,500,000 bytes).

Two layers copy the strings (detachSecret in the rule and the structuredClone in detachFromPage) and either is enough, so removing one alone is not a retention regression and the test does not fail on it. It fails when retention actually returns, which needs both gone. The test comment says so.

Agent skill

No skill change needed.

Gates

New test passes three times in a row; tsgo clean on audit-engine.

@nc9
nc9 marked this pull request as ready for review November 9, 2026 11:15
@nc9

nc9 commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

Already on main as b56a1c6, which landed through an earlier bundle, so merging this changes nothing. Closing as landed.

nik

@nc9 nc9 closed this Nov 13, 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.

1 participant