Repository navigation
perf(logging): speed up secret redaction for large text - #166701
Conversation
Skip impossible AWS windows and built-in rule scans while retaining match order, masks, modes, registered-secret lifecycle, and mutable regex behavior. Keep the outer word-admission gate conservative and preserve native global replacement state when a scan is skipped. Record synthetic byte-identity fixtures and exercise shared-regex mutation. Move existing mask helpers into one small module so the main redactor shrinks. Extend the existing redaction benchmark with 1 KiB, 64 KiB, and 200 KiB text and content-field workloads.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
|
Codex review: needs maintainer review before merge. Reviewed October 7, 2026, 3:37 PM ET / 19:37 UTC (Revision 2). ClawSweeper reviewWhat this changesThe PR speeds up secret masking in large text and structured content by skipping impossible matches, while adding benchmarks and byte-equivalence coverage. Merge readiness✅ Ready for maintainer review This optimization remains useful on current main. The pinned patch has no actionable correctness or security findings, and the fixture correction preserves decoded inputs and expected hashes. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw’s redaction subsystem receives log records, transcript text, and tool content before they reach output or persistence. It applies registered-secret masking and ordered credential rules, returning sanitized text and records. flowchart TD
A[Logs and tool content] --> B[Registered secret masking]
B --> C[Conservative admission probes]
C --> D[Ordered credential rules]
C --> E[No possible rule match]
D --> F[Sanitized output]
E --> F
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +2505, Tests +189, Other +34. Total +2728 across 12 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Retain one ordered redaction owner with conservative, mutation-aware probes that reduce scanning without changing masking bytes or operator settings. Do we have a high-confidence way to reproduce the issue? Not applicable to a functional bug; the existing benchmark provides a concrete performance comparison through the changed text and content-field entrypoints. Is this the best way to solve the issue? Yes. The probes supplement the existing ordered rules, and the recorded simpler-design comparisons justify the additional runtime machinery. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 53393f7d8668. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
Use a JSON Unicode escape in synthetic key markers so the byte-level private-key scanner accepts the fixture without any policy exception. All 468 decoded cases and recorded output hashes remain identical.
Pull Request is not mergeable
Culprit de7c3b7 (#166539) moved health device-identity reads into the shared SQLite worker. The threaded wizard fixture lacks its host broker. Register the unchanged test with the existing isolated fork-based owner, preserving real health authentication and ambient-endpoint isolation. Validation: focused finalization/health/Doctor tests, whole wizard and unit-fast configs, registry and planner guards, full test-types, typed and boundary lint, complete check-changed, four real manifest shapes, and P2. Whole tooling completed with 941 files passed and 7 skipped; its sole failure is the inherited logging-suppression inventory from #166701. Full infra config gate waived by coordinator: fleet at cap; registry/planner/tooling proof passed
) * perf(logging): speed up secret redaction for large text Skip impossible AWS windows and built-in rule scans while retaining match order, masks, modes, registered-secret lifecycle, and mutable regex behavior. Keep the outer word-admission gate conservative and preserve native global replacement state when a scan is skipped. Record synthetic byte-identity fixtures and exercise shared-regex mutation. Move existing mask helpers into one small module so the main redactor shrinks. Extend the existing redaction benchmark with 1 KiB, 64 KiB, and 200 KiB text and content-field workloads. * test(logging): encode synthetic PEM fixture markers Use a JSON Unicode escape in synthetic key markers so the byte-level private-key scanner accepts the fixture without any policy exception. All 468 decoded cases and recorded output hashes remain identical.
Culprit 8b189ec (openclaw#166539) moved health device-identity reads into the shared SQLite worker. The threaded wizard fixture lacks its host broker. Register the unchanged test with the existing isolated fork-based owner, preserving real health authentication and ambient-endpoint isolation. Validation: focused finalization/health/Doctor tests, whole wizard and unit-fast configs, registry and planner guards, full test-types, typed and boundary lint, complete check-changed, four real manifest shapes, and P2. Whole tooling completed with 941 files passed and 7 skipped; its sole failure is the inherited logging-suppression inventory from openclaw#166701. Full infra config gate waived by coordinator: fleet at cap; registry/planner/tooling proof passed
* perf(logging): speed up secret redaction for large text Skip impossible AWS windows and built-in rule scans while retaining match order, masks, modes, registered-secret lifecycle, and mutable regex behavior. Keep the outer word-admission gate conservative and preserve native global replacement state when a scan is skipped. Record synthetic byte-identity fixtures and exercise shared-regex mutation. Move existing mask helpers into one small module so the main redactor shrinks. Extend the existing redaction benchmark with 1 KiB, 64 KiB, and 200 KiB text and content-field workloads. * test(logging): encode synthetic PEM fixture markers Use a JSON Unicode escape in synthetic key markers so the byte-level private-key scanner accepts the fixture without any policy exception. All 468 decoded cases and recorded output hashes remain identical. (cherry picked from commit 05e6660) Backport of 05e6660 (#166701) adapted for 2026.10.2. parsePattern takes main's shared-policy shape (linear matchers fall through the regex path's policy registration, from 7e27d6c); structured-properties test takes main's consolidated form (f3698fa test-only reshuffle).
What Problem This Solves
Large model contexts and log strings repeatedly scan the built-in redaction rules even when most rule families cannot match. Reconnect-storm CPU profiles attributed 383–503 ms of a roughly 5.8-second main-thread window to redaction.
User Impact
Reduces redaction CPU for large contexts, logs, and structured content fields while retaining the same matching rules, replacement bytes, and modes, including
mode: "tools". No configuration or migration is required.Why This Change Was Made
Compiled default rules and registered-value matchers were already cached; repeated scanning was the remaining cost. Reject impossible AWS candidate windows, gate assignment/vendor families by necessary characters, attach per-rule probes at compilation, and reuse vendor admission only while the current input is unchanged. Compiled-regex mutation invalidates the associated probe, skipped global replacements still reset lastIndex, and the outer word-admission gate remains conservative for shared mutable rules. Registered secret values retain their existing revision-owned matcher and snapshot lifecycle.
The runtime grows by 151 lines, plus 33 lines in the existing benchmark. The growth preserves ordered replacements and full-context matching while attaching necessary-condition probes to their rules; mutable shared regexes require source/flags/executor/replacement-hook validity checks. In the earlier AWS ablation, a smaller variant without per-rule probes took 25.34 ms for a matched 200 KiB context versus 11.39 ms for the full candidate. Dropping both the per-rule and vendor probes took 19.94 ms for clean source versus 7.13 ms. Neither simpler measured design retained the speedup. The line-cap gate also required moving the existing token-mask helpers into a 66-line module; the main redactor shrinks by 20 lines, and this extraction changes no masking logic. Its new module is included in the trusted PR-wrapper source inventory. No old redaction implementation or cross-call output cache is retained; the large new JSON file is a synthetic test fixture, not runtime code. The requested non-test path filter reports 2,668 insertions and 129 deletions (+2,539): +151 runtime lines, +33 benchmark lines, +2,354 fixture-data lines, and one wrapper-inventory entry.
Evidence
Final comparative Linux measurements (Node 24.19.0, Hetzner Crabbox
cbx_70204d6e74ab, alternating baseline/candidate in one process, five rounds of five calls; synthetic inputs and an empty exact-value registry during timing; registry lifecycle is checked separately):The fresh differential harness passed 8,984/8,984 comparisons across all 124 compiled patterns, including seven API/mode combinations, padded inputs, near misses, registry lifecycle/snapshots, and ordered custom replacements. The permanent corpus adds 468 baseline-hashed cases covering seven API/mode combinations alongside the existing 250-case byte fixture. All 58 logging test files have passing behavior evidence (807 tests), including the final 97-case focused entrypoint run and the corrected 11-case structured-probe file. The replacement-hook, lastIndex, and default-gate mutation regressions each demonstrably fail when their corresponding fix is removed. The new corpus section takes 132 ms in the final run. Preserving the original outer admission behavior gives up part of the experimental clean-input speedup; the table reports the compatible final candidate. Measured
pnpm test <file> --maxWorkers=1wall times: byte identity 4.838 s, reentrancy 4.414 s, pattern families 3.616 s, redaction 4.782 s, structured properties 4.261 s. The full staged changed-file gate passed on the final runtime; the subsequent one-line wrapper-inventory change passed its scoped gate and all 20 closure tests. Full core lint reported five existing max-lines warnings outside this diff and zero errors. Final-head CI run 37675013684 passed: 54 successful jobs, 721 seconds workflow wall time, and 2,583 summed Node-test job seconds across 15 jobs (whole-job cost, not per-file attribution). The first run was cancelled after its byte-level private-key scanner matched a synthetic PEM marker in the JSON fixture; the marker is now serialized with a standard JSON Unicode escape, with all 468 decoded cases and expected hashes verified identical.Benchmark:
pnpm perf:redaction --largecovers 1 KiB, 64 KiB, and 200 KiB prose/context/source strings, each with and without a synthetic secret.Final differential/benchmark proof: https://crabbox.openclaw.ai/portal/runs/run_df42bfdf5bebe1f464925ea958eb4bca — all 8,984 comparisons passed in 48.18 seconds. The same payload completed
node scripts/check-changed.mjs --stagedsuccessfully before the separate closure tests identified the missing inventory entry. After that entry was added, https://crabbox.openclaw.ai/portal/runs/run_5ebd80f41c7061619d5a249069523ecc passed the scoped inventory gate, 97 focused tests, and the published benchmark command (payload exit 0, 209.84 seconds).Remote commands and recovery results
All runs used source hashes and the pinned baseline. No heavy validation ran on the Mac. Every lease is stopped/released.
tbx_01m4bfr86q12m45q0x7p95ba3dcrabbox warmup --keep --timing-jsoncbx_054ccde1eeferun_9f3613b6a000a849fcd40f8d24fc1c1ft3.small.cbx_054ccde1eefepnpm testfiles, then logging siblings; runrun_f58aada71e2f03bce102535c050e42e2cbx_70204d6e74ab(ccx33)run_0d16127b5cf224743a2992c203189362run_8d722b7f90d361d5fde9759df5b20d66run_53d8e4c42ff5ede45aa10894859303c5node scripts/check-changed.mjs --staged; runrun_93b3ad037df40806b0d812c532ac9296run_df42bfdf5bebe1f464925ea958eb4bcarun_5c6122a0164f175c89e132b38d54e2e3rg, absent from the base image.rg; scoped inventory gate; final focused entrypoints;scripts/bench-redaction-prefilters.ts --large; runrun_5ebd80f41c7061619d5a249069523ecctbx_01m4bvzpas4dbgj7vdm883jkxkcbx_22ff5e954d11(c7a.8xlarge)pnpm test src/logging/redact-byte-identity.test.ts --maxWorkers=1; runrun_734a0333861550d6bfce98967aeb3622Independent autoreview: scoped-clean through P2 for the final runtime and wrapper-inventory change, with complete production source supplied. The fixture-only CI correction also passed independent review through P2. The earlier replacement-hook finding was fixed and verified with failing/passing regression evidence.
Security review: the modified logging paths match the credentials category in the security-review policy. No current CODEOWNERS rule names an owner for these files; the SecOps-only ownership paths are unchanged. Required GitHub security/review gates remain applicable.
Limits: synthetic throughput measurements do not predict total Gateway CPU savings. No production Gateway replay or deployment is included.