Problem
Profiling the drift stage on cladding's own repo (per-detector timing):
HARDCODED_SECRET 4425 ms (secretlint subprocess)
ARCHITECTURE_VIOLATION 1406 ms (madge subprocess)
… every other detector < 60 ms
These two shell-out detectors are ~97% of the drift stage. And they run twice per gate: once inside the Drift stage (stage_1.3 sweeps every detector) and again as their dedicated stage — Secret (stage_1.6) and Arch (stage_1.5) are thin adapters over the same detectors. src/stages/secret.ts even documents that the layering "avoids spawning the scanner twice when both runSecret and runDrift execute" — but nothing enforced it. So a full gate pays ~5.8s of pure duplicate subprocess time (secretlint ×2 + madge ×2).
Measured clad check --tier=pre-commit: ~11.9s, of which ~5.8s is the redundant second spawn.
Proposed fix
A gate-scoped memo (mirroring the existing run-scoped spec cache, F-cd0415): clad check primes it around the stage loop; the second invocation of an identical (cwd, cmd, args) scan is a cache hit, so each external tool spawns once. Pass-through when unprimed (standalone / MCP unchanged); cleared in a finally so the long-lived MCP server never serves a stale scan.
Measured result (isolated worktree A/B)
|
clad check --tier=pre-commit |
| develop (spawn ×2) |
~11.9s |
| with memo (spawn ×1) |
~6.3s |
| delta |
−47%, identical findings |
Implemented by F-5a49899e.
Problem
Profiling the drift stage on cladding's own repo (per-detector timing):
These two shell-out detectors are ~97% of the drift stage. And they run twice per gate: once inside the Drift stage (stage_1.3 sweeps every detector) and again as their dedicated stage — Secret (stage_1.6) and Arch (stage_1.5) are thin adapters over the same detectors.
src/stages/secret.tseven documents that the layering "avoids spawning the scanner twice when bothrunSecretandrunDriftexecute" — but nothing enforced it. So a full gate pays ~5.8s of pure duplicate subprocess time (secretlint ×2 + madge ×2).Measured
clad check --tier=pre-commit: ~11.9s, of which ~5.8s is the redundant second spawn.Proposed fix
A gate-scoped memo (mirroring the existing run-scoped spec cache, F-cd0415):
clad checkprimes it around the stage loop; the second invocation of an identical(cwd, cmd, args)scan is a cache hit, so each external tool spawns once. Pass-through when unprimed (standalone / MCP unchanged); cleared in afinallyso the long-lived MCP server never serves a stale scan.Measured result (isolated worktree A/B)
clad check --tier=pre-commitImplemented by F-5a49899e.