mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-11-28 16:58:31 +01:00
SharedPrimitives.guardrails.test.ts runs scripts/shared-template-audit.mjs under Vitest's default 5000ms timeout. Without caching, each of the 152 pattern guards re-walked src/ with statSync/readdirSync and re-read every matching file from disk, taking ~9.3s in Vitest (~25.1s standalone) and timing out the guardrail test locally under Vitest's default timeout. Memoize file existence checks, sorted recursive scope traversal (using dirent file types), and UTF-8 file reads per audit run, skip Set/sort for single-scope guards, and evaluate longer patterns first while preserving exact audit rules, missing-scope checks, and failure messages. Allow overriding the audit root via PULSE_SHARED_TEMPLATE_AUDIT_ROOT for isolated regression testing and add frontend-modern/scripts/__tests__/shared-template-audit.test.mjs. Contract-Neutral: Internal caching and pattern-order optimization in shared-template-audit.mjs plus a unit test; no audit rule, registry schema, UI, API, or subsystem contract delta. --- Fleet candidate `20261128T140410Z-web-product` from the `web-product` lane. Reviewed tip `b8c4d8b1e601282d2cf034c4ff47bf64e31edfd3` on `main`. [How Pulse handles triage](https://github.com/rcourtman/Pulse/blob/main/docs/AI_TRANSPARENCY.md)