Skip to content

perf: reuse compiled matchers for support redaction - #170225

Merged
steipete merged 6 commits into
mainfrom
dbasync/loopstall
Oct 13, 2026
Merged

steipete merged 6 commits into
mainfrom
dbasync/loopstall

Conversation

@steipete

@steipete steipete commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Support redaction runs synchronously while the Gateway prepares trajectory metadata. It compiled a separate array of vendor-token regexes at module load, bypassing the canonical compiler's prefix filters and linear matchers. CPU profiles place this scanning path inside warmed main-thread stall windows.

User Impact

Reuse the canonical compiled vendor matchers and delete the duplicate compilation path. Benign metadata can skip unnecessary regex scans. Preserve support-specific full AWS masking, Unicode boundaries, data-URL exemptions, and all other masking output. Five compatibility fixtures cover the cutover. The updater's isolated test loader loads the real redaction dependency closure.

This is a small, behavior-preserving optimization of one contributor to stalls. It does not resolve the larger tool/schema preparation cost. There are no configuration, schema, SDK, update, or service-lifecycle behavior changes. No authority/integrity check or SQL operation is removed. Removed checks and accepted edge cases: none. The diff is three files, +25/-5 lines (production +6/-5).

Evidence

Where the stalls occur

An earlier diagnostic CPU profile of synchronized source ddaf75ff383b0bef772a5eb8c37a75b80869ec88 ran on a remote Linux Testbox with four visible AMD EPYC CPUs and Node 24.19.0. CPU idle was 99.75% before and 99.88% after the workload. It captured all 72 timer windows >=8 ms across ten warmed turns. Nineteen windows were dominated by tool/schema/catalog work; 47 were mixed. The largest window was 34.417 ms, with 34.095 ms assigned to GC samples; the allocating owner remains unresolved.

Selected stack grouping Sample intervals in >=8 ms windows
Tool construction / schema / catalog 211.432 ms
Other agent / runtime 104.115 ms
Garbage collection 99.895 ms
Trajectory / prompt preparation 95.448 ms
Infrastructure / worker plumbing 65.638 ms
Diagnostic / redaction 21.710 ms
Sparse gaps, unattributed 57.514 ms

These are exclusive, rule-based sample-interval groupings, not causal CPU-time totals. Sparse intervals over 2 ms remain unattributed. The profile includes instrumentation overhead and is separate from the final comparison below.

Patch comparison timing observations

Three unprofiled alternating pairs, M,C,M,C,M,C, compare baseline 3c79d119f2945474a483073eaa827c9801eb0c42 with candidate 6d3ca762b292140ea30b0be227c42cf37ba50e2b, ten warmed turns per run. Source manifests and collector bytes were verified; all six runs have complete warmed coverage and no dropped windows.

Quiet-host latency is unmeasured for this patch. The final remote request queued and was canceled under the immediate-capacity policy. These local controls ran on a 32-core Mac, Node 26.11.1, with sampled one-minute load 55.79-114.26. They are observations only: neither a latency improvement nor a regression can be inferred. The p99 <=8 ms / max <=15 ms targets are not demonstrated.

Metric, ms Baseline median [min-max] Candidate median [min-max]
Event-loop delay p50 1.51 [1.48-1.55] 1.51 [1.36-1.53]
Event-loop delay p99 110.85 [43.22-147.46] 61.21 [50.22-93.22]
Event-loop delay run maximum 337.64 [241.57-919.60] 293.86 [184.94-680.00]
Warmed-turn p50 1914.28 [1011.10-4271.83] 1234.43 [1203.83-1667.92]
Warmed-turn p95 2095.67 [1858.86-15744.24] 2525.92 [1846.57-3059.57]

Event-loop p50/p99 rows aggregate each run's median per-turn percentile. Worst observed delay: 919.60 -> 680.00 ms. Pooled 30-turn p50/p95: 1914.28/8700.19 -> 1403.61/2525.92 ms (nearest-rank p95). Pair directions vary, the median run p95 is higher for the candidate, and one baseline turn took 15.74 seconds; the pooled result is not a causal performance claim.

Timer-window histogram, pooled across 30 warmed turns Baseline Candidate
8-12 ms 393 277
12-15 ms 186 136
15-20 ms 198 149
20-30 ms 206 184
>=30 ms 523 237

SQL and requests

One complete alternating SQL pair on the same compared source pins, ten warmed turns per revision, using a task copy of the shared harness with unchanged counting/attribution helpers. The first candidate attempt and the next baseline attempt both hit the existing 15-second WebSocket handshake deadline before any measured turn. Both incomplete attempts are excluded. The current one-live-pair testing allowance is used; this is not three-pair SQL evidence, and repeatability is unmeasured. The three timing pairs above are complete.

Metric Baseline Candidate Delta
Turn-caused warmed statements/turn 181.0 182.8 +1.8 (+0.99%)
Turn-caused warmed requests/turn 43.6 43.6 0
Warmed MAIN statements/turn 0 0 0
Raw warmed-window statements/turn 223.7 244.6 +20.9 (+9.34%)
Raw warmed-window requests/turn 64.4 69.8 +5.4 (+8.39%)
Whole-workload statements 6,990 7,179 +189 (+2.70%)
Whole-workload requests 1,399 1,445 +46 (+3.29%)
Whole-workload MAIN statements 840 838 -2

These are single run-level observations, so median [min-max] equals each displayed value [value-value]. Raw windows include background work; whole totals include startup, other flows, and shutdown. All 3,638 causal warmed statements link to actual request records. Of 109 normalized warmed SQL shapes, 25 have different counts.

Causal operation Baseline SQL/turn Candidate SQL/turn Baseline requests/turn Candidate requests/turn
execute 146.2 147.5 32.2 32.2
task 34.8 35.3 11.4 11.4
Touched redaction producer 0 0 0 0

The +18 causal statements across ten turns comprise one 13-statement temporary-trigger setup in session-lifecycle projection, four transcript-worker statements, one auth-profile read, one entry-admission statement, and one fewer actor-durable statement. Trigger setup is cached by database handle/schema version. Whole-workload setup counts were 65 -> 104, so this is genuinely additional setup in the observed run, not solely a shift from startup into a warmed window. No added SQL/request path exists in this patch; it changes only synchronous string matching. The setup/read-count variation is outside that owner, and this single pair does not establish patch causation.

Shared read family Baseline SQL/requests per turn Candidate SQL/requests per turn
Exact entry facts 4.1 / 4.1 4.1 / 4.1
Selected-row helper shapes 7.1 / 6.1 7.1 / 6.1
Standalone participant 10.1 / 9.1 10.1 / 9.1
Committed watermark 1.0 / 1.0 1.0 / 1.0
Hot watermark 0 / 0 0 / 0
Actor hydration 1.2 / 1.2 1.1 / 1.1
Entry-cache snapshot 0.1 / 0.1 0 / 0
Auth profile 1.2 / 1.2 1.3 / 1.3

Families classify normalized SQL shapes; selected-row helper shapes use execution-site mapping. Request IDs are unioned within each family; families may overlap. The raw-window +209 statements split into +18 turn-caused and +191 background statements. By execution site, memory-core accounts for +128, trigger setup +26, and other sites +55. SQL run-boundary load was 82.85-90.79 for baseline and 90.40-196.96 for candidate on 32 CPUs. No SQL saving or whole-Gateway performance improvement is claimed.

Validation

Pre-integration CI run 38322403843 passed: 36 successful jobs, 26 intentionally skipped, and the required CI gate green. That CI merge combines measured candidate 6d3ca762 with main 5cf2615e65ec2e8344c836a5572c523783981e60. Build, Critical Quality, and all seven selected Security High CodeQL shards also passed.

  • Support-redaction tests: 54/54; Vitest 2.33 seconds, CI wrapper 4.31 seconds with one worker.
  • Redaction reentrancy: 11/11 passed locally on the exact head; Vitest 35.35 seconds, shard wrapper 96.65 seconds, total invocation 139.25 seconds on the loaded host.
  • Updater dependency fixture: 19 internal cases, no failures or skips; suite 3.15 seconds. This repairs the isolated test loader's dependency closure; update behavior is unchanged.
  • CI production/test types, type-aware lint, formatting, source contracts, export-name collisions, and Madge passed (zero import cycles).
  • CI whole-tree T1: 456 -> 456; compatibility-only: 9 -> 9. Changed-production dialect groups: 0 -> 0 in every category.
  • Two independent Codex autoreview rounds completed with no remaining actionable findings. The completed ClawSweeper review has no findings or before-merge requirements.
  • No SDK API diff or published-driver update cell is applicable: public APIs and update/Doctor/schema/plugin-loading/service-lifecycle behavior are unchanged.

Touched production-area T1 is 0 -> 0: the changed redaction module contains none of the native inventory's five SQLite primitives in either revision, so the inventory excludes it before call classification. The whole-tree ratchet result above comes from CI.

A supplemental local static pass did not complete successfully: its three concurrent Knip scans reached the existing 600-second limit before returning findings. Redundant local Madge, export-collision, and worker-ratchet work was then canceled and replaced by the already-passing exact-head CI evidence. These cancellations and the timeout are not counted as passes.

An additional synthetic check confirmed identical redaction output for 14 short inputs across six counterbalanced batches. Its elapsed timings varied widely on the loaded host and supply no performance claim; it is not a Gateway responsiveness benchmark.

Follow-up

The larger measured contributor is tool/schema/catalog preparation. A follow-up should let the existing tool-finalization owner publish one immutable provider-specific descriptor snapshot, with projection and fingerprint computed once, while keeping executors, abort state, and current authority per attempt. That work is outside this small matcher cutover.

Supplemental Static Gate

The sequential local Knip retry was canceled before starting after roughly 30 minutes without a CPU slot. The supported exact-head main-tier CI fallback completed all three export scans. The script scan passed with zero entries; production and full-tree scans reported only obsolete Control UI exports. The dependency/unused-file checks also reported an obsolete UI select shim. No changed file has a finding.

This Knip result is inherited, not green. Every reported finding exactly matches scheduled main run 38322669274, including the same symbols, files, and scan categories. Main subsequently removed those exports and the shim in 61edf206c15d201e857e6bf8419b30ff4dd1673f. GitHub's stored PR merge ref still used the older CI base, so the branch was updated with main to incorporate the repair. The remaining jobs in that old-head fallback were canceled after saving the completed dependency result. The timeout, inherited failure, and canceled jobs are not counted as passes.

The redaction reentrancy test passed 11/11 on the exact head. No timeout or canceled check is counted as a pass. The recorded source pins and measurement limitations above are unchanged.

Landing Head and Validation

Landing head ba1167ad2ebe10c6e68c9ed7b6a32e15c5825eb6 merges main f9af58c66f79f23a2e051cfe5b9feccf6befc2da without conflicts. All three changed files are byte-identical to the reviewed/measured candidate 6d3ca762; the diff against integrated main is still +25/-5 lines. Existing focused behavior proof and reviews are reused for that unchanged patch. Measurements above remain evidence for their recorded source pins, not a new measurement of the integrated main base.

Fresh PR CI 38340082322 passed on this head: 35 successful jobs, 26 intentionally skipped, and the required CI gate green. Its types, lint, formatting, source contracts, export-name collision checks, Madge, selected tests, and ratchets passed. Whole-tree T1 is 455 -> 455, compatibility-only 9 -> 9; touched-area T1 stays 0 -> 0. All changed-file dialect categories stay 0 -> 0.

The new-head dependency shard completed every Knip export scan. Script exports and full-tree unused files passed with zero entries. Production/full-tree export scans and the production unused-file check failed on existing writer-admission, skills, and dropdown exports/types, plus the unused writer-admission service. All 18 emitted finding lines exactly match latest scheduled main, in the same scan categories. None is in a changed file. This is proven inherited static failure, not a passing Knip result; the campaign's inherited exception applies and the findings are recorded for the main-repair owner.

Remaining supplemental-run jobs were canceled after the dependency result was captured. That supplemental run is not claimed green. The required PR CI above completed successfully. The unchanged patch retains its two clean reviews and focused behavior evidence; no new performance claim is made for the integrated base.

Account for CPU work in async preparation continuations, split tool construction into event-loop slices, and reuse canonical diagnostic redaction matchers. Preserve FIFO admission, live tool authority, masking semantics, and SQL behavior.
@clawsweeper

clawsweeper Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@github-actions

github-actions Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: ba1167ad2ebe10c6e68c9ed7b6a32e15c5825eb6
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/logging/diagnostic-support-redaction.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.

Carefully review these changes before merging.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S labels Oct 12, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 12, 2026
@clawsweeper

clawsweeper Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This PR reuses canonical compiled vendor-token matchers in support redaction while preserving support-specific masks.

Example: Redacting the support string "vendor ghp_abcdefghij".

  • Before: Produces "vendor ***" using separately compiled regexes.
  • After: Produces "vendor ***" using canonical matchers and their admission filters.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A useful, narrowly scoped cutover with shipped-path observations, preserved masking contracts, and no actionable findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The supplied exact-candidate Gateway runs exercise warmed preparation through the shipped server path, supported by masking compatibility fixtures and passing CI; the noisy timing observations establish execution, not a causal performance gain.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: Support redaction performs avoidable synchronous scanning during Gateway preparation.
Reason: The maintainer-authored change consolidates an existing optimization in a small patch and explicitly leaves broader Gateway responsiveness work outside its claim.

Merge readiness

⛔ Needs changes before merge - 1 item remains

Keep this maintainer-authored PR open: the focused matcher cutover is useful and has no actionable findings; the author's validation hold remains active.

Priority: P2
Reviewed head: 6d3ca762b292140ea30b0be227c42cf37ba50e2b

Before merge

  • Complete next step - Resolve the recorded merge hold after the Knip export scan and redaction reentrancy check complete.

Findings

None.

Agent review details

How this fits together

Support redaction sanitizes strings and snapshots used by diagnostic exports and trajectory metadata, returning masked text before those consumers record or export it.

flowchart TD
  A[Trajectory metadata] --> C[Support redaction]
  B[Diagnostic export] --> C
  C --> D[Canonical compiled matchers]
  D --> E[Vendor admission filters]
  C --> F[Support specific masks]
  E --> G[Sanitized output]
  F --> G
Loading

Technical review

Best possible solution:

Retain this narrow reuse of the canonical matcher owner while preserving the existing support masking contract.

Do we have a high-confidence way to reproduce the issue?

Source confirms support redaction bypasses canonical matcher optimizations on main; supplied Gateway profiles place redaction within preparation stalls, but do not establish a causal latency improvement for this patch.

Is this the best way to solve the issue?

Reusing the existing compiler removes duplicate matcher construction without introducing another owner, changing configuration, or altering support-specific AWS masking.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 76edfee2d220.

Provenance checked

  • Support vendor matcher compilation keeps the original intent (1111174: Preserve complete vendor-token context, public URL boundaries, and support-specific full AWS masking.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 9280c61 adds src/logging/diagnostic-support-redaction.ts:319 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 9280c615c0c3; files: src/logging/diagnostic-support-redaction.ts)
  • Ayaan Zaidi: Raw commit 1111174 adds src/logging/diagnostic-support-redaction.ts:314 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 1111174136f7; files: src/logging/diagnostic-support-redaction.ts)
  • Gustavo Madeira Santana: Raw commit 28818f9 adds src/logging/diagnostic-support-redaction.ts:298 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 28818f914074; files: src/logging/diagnostic-support-redaction.ts)

PR surface

Source +1, Tests +19. Total +20 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 6 5 +1
Tests 2 19 0 +19
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 25 5 +20

Labels

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.

Label justifications:

  • P2: A focused synchronous redaction optimization with limited scope and no demonstrated urgent user-facing regression.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (8 earlier review cycles)
  • reviewed 2026-10-12T20:45:33.029Z sha 9ff3bf3 :: blocked before merge. :: [P1] Keep hsk credentials reachable through the vendor prefilter
  • reviewed 2026-10-12T21:10:39.417Z sha c74f84d :: needs changes before merge. :: [P2] Keep the mocked clock monotonic across scheduler tests
  • reviewed 2026-10-12T21:18:35.316Z sha c74f84d :: needs changes before merge. :: [P2] Keep the mocked clock monotonic across scheduler tests
  • reviewed 2026-10-12T21:57:19.264Z sha a8f415d :: needs maintainer review before merge. :: none
  • reviewed 2026-10-12T23:26:47.924Z sha 739e65a :: needs maintainer review before merge. :: none
  • reviewed 2026-10-12T23:37:41.481Z sha 6d3ca76 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-12T23:49:33.112Z sha 6d3ca76 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-13T02:35:45.528Z sha 6d3ca76 :: needs changes before merge. :: none

Reviewed October 12, 2026, 10:55 PM ET / October 13, 2026, 02:55 UTC (Revision 9).

Preserve the prepared profile facts alongside event-loop yields. Extract final hook wrapping without changing its ordering or caller context to keep tool assembly within the source-size limit.
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels Oct 12, 2026
@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Oct 12, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 12, 2026
Three alternating comparisons showed worse warmed latency in two candidate runs. Retain only the separately reviewed support-redaction matcher optimization and its compatibility fixtures for a focused performance comparison.
@openclaw-barnacle openclaw-barnacle Bot added size: XS and removed agents Agent runtime and tooling size: S labels Oct 12, 2026
@steipete steipete changed the title fix: keep Gateway responsive during agent preparation perf: reuse compiled matchers for support redaction Oct 12, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 13, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Oct 13, 2026
@steipete
steipete merged commit 3e4745c into main Oct 13, 2026
205 of 285 checks passed
@steipete
steipete deleted the dbasync/loopstall branch October 13, 2026 03:17
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 13, 2026
Reuse canonical vendor-token matchers, including their prefix filters and linear scans, for synchronous support redaction. Preserve support-specific full AWS masking and existing redaction output.

Add compatibility fixtures and load the real redaction dependency closure in the isolated updater test fixture.

This addresses one profiled contributor to Gateway stalls. Quiet-host latency improvement is unmeasured; SQL and authority behavior are unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. scripts Repository scripts security-sensitive-changed size: XS status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant