Skip to content

perf(diagnostics): reuse redaction and directory work per scope - #2056

Merged
thymikee merged 3 commits into
mainfrom
perf/diagnostics-flush-scope
Aug 26, 2026
Merged

perf(diagnostics): reuse redaction and directory work per scope#2056
thymikee merged 3 commits into
mainfrom
perf/diagnostics-flush-scope

Conversation

@thymikee

Copy link
Copy Markdown
Member

Summary

Redact structured event data once at emit time, reuse sorted redaction literals within a diagnostics scope, and memoize ensured log directories per scope.

The scope boundary remains explicit: a new diagnostics scope recreates a deleted log directory rather than inheriting stale process-global state. This is the diagnostics-only slice extracted from #2051.

Validation

  • Planted-red regression proved that a second scope must recreate a deleted directory.
  • pnpm check:affected --run — 593 files / 4,307 tests passed; format, lint, typecheck, layering, Fallow, and build passed.
  • 2 files changed.

Flushed entries were already fully redacted at emit time; re-running
redactDiagnosticData over them at flush is idempotent-but-wasted work, so
flush now repeats only the caller-declared value replacement (keeping the
property that literals registered between emit and flush are still
scrubbed). The sorted sensitive-value list is cached per scope and
invalidated on registration instead of being re-sorted per call, and
appendDiagnosticLine ensures each log directory once instead of once per
appended line.
Data payloads are redacted once at emit time; the flush pass repeats only
caller-declared literal replacement so late registrations still win. State
explicitly that metadata fields are generated identifiers/internal phase
names and are no longer re-normalized at flush, and drop the false claim
that replacement output stays length-bounded. Also collapse trivial
declarations to bring the module back under the 300-line target.
@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Aug 26, 2026
@thymikee
thymikee merged commit ab4ee0b into main Aug 26, 2026
2 of 3 checks passed
@thymikee
thymikee deleted the perf/diagnostics-flush-scope branch August 26, 2026 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant