Repository navigation
Conversation
…ribute exports With diagnostics.otel.captureContent enabled, safeJsonString redacted the full serialized value just to learn it was too long, then redacted every string in full on each of up to 63 truncation attempts, for gen_ai.* and openclaw.content.* separately. A model call whose context carries megabytes of tool output blocked the gateway event loop for minutes. Truncation budgets are now chosen from unredacted sizes, and only the exported candidate is redacted. A clipped string is redacted over its kept prefix plus 4,096 characters of lookahead, and a private key block cut off before its END line is dropped. Redaction input per JSON candidate is capped at 8x the attribute budget. normalizeOtelLogString uses the same bounded prefix, and mirrored gen_ai keys (input.value, output.value) reuse one serialization. Content that fits without truncation now also redacts each string before serialization; JSON escaping hid line-start assignments such as password=... from the text rules.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review blockedAutomated review did not run, so no review verdict was produced. Reason: The input-safety check rejected material in this revision. No detected value, path, or scanner output is reproduced here. Automatic review is on hold, including after source changes. Request a fresh re-review after resolving the failure; maintainers can also release the hold through an intentional scanner-policy update. Next step: If this is a genuine credential, remove and rotate it. If it is an intentional test fixture, a maintainer must review and qualify it. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
A critical redaction-boundary issue remains unresolved and could expose sensitive content.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
What changed in this PR
This PR improves OTEL content capture performance for large model payloads by bounding redaction work and reusing serialized content.
Changes:
- Adds bounded redaction lookahead and truncation safeguards.
- Reuses serialized GenAI values across mirrored attributes.
- Adds performance and redaction-boundary tests.
A critical redaction-boundary issue remains unresolved: unterminated sensitive assignments may expose secrets (2 votes).
| File | Summary |
|---|---|
extensions/diagnostics-otel/src/service-genai-content.ts |
Reuses serialized values for mirrored GenAI attributes. |
extensions/diagnostics-otel/src/service-content-normalization.ts |
Implements bounded JSON/log normalization and redaction. |
extensions/diagnostics-otel/src/service-content-normalization.test.ts |
Tests bounded work and sensitive-content handling. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Codex review: blocked before merge. What this changesThis PR bounds OpenTelemetry content-redaction work and reuses serialized values across mirrored attributes. Example: A 40-turn session reaches roughly 2.1 million prompt characters with content capture enabled.
Review scores
ProductKind: Bug fix · Worth it: Needs a maintainer decision · Fix scope: Complete Merge readiness⛔ Blocked before merge - 2 items remain Keep this PR open: it addresses a confirmed Gateway stall still present on main, with no new concrete code finding; capture semantics, SDK shape, and current-head security approval remain unresolved. Priority: P1 Decision needed
Before merge
FindingsNone. Agent review detailsHow this fits togetherThe diagnostics-otel plugin receives model, tool, and log events, normalizes and redacts captured content synchronously, then sends bounded attributes and log bodies to telemetry exporters. flowchart LR
A[Model and tool events] --> C[OTel content normalization]
B[Diagnostic log events] --> C
C --> D[Core redaction matchers]
E[Registered secret owner] --> D
D --> F[Bounded attributes and log bodies]
F --> G[OTLP or stdout exporter]
Technical reviewBest possible solution: Land one maintainer-approved capture strategy that keeps the Gateway responsive while core retains ownership of secret matching. Do we have a high-confidence way to reproduce the issue? The source exposes repeated whole-value redaction, corroborated by the incident profile and contributor's real-Gateway comparison; this read-only review did not rerun the workload. Is this the best way to solve the issue? The patch addresses repeated work at its owner and shares core matchers rather than copying secret grammar; its bounded completeness and SDK design still require an owner choice. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 0a09e1ad0a87. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +518, Tests +977, Docs +17, Other +4. Total +1516 across 20 files. Added test files: 4. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (17 earlier review cycles; latest 8 shown)
Reviewed November 3, 2026, 6:19 AM ET / 11:19 UTC (Revision 18). |
The bounded redaction window only matched a secret whose closing
delimiter fell inside the 4,096-character lookahead. Two cases still
exported the start of a secret:
- A quoted value whose closing quote lies past the window, such as
{"password": "<5,000+ characters>"} in a text part, tool result or log
body. The JSON secret-key, quoted-assignment, quoted-field, CLI-flag and
escaped-env rules all need the closing quote, and JSON escaping hides
the value from the second pass over the serialized attribute.
- Masks shorten the redacted window, so the export cut can reach into the
lookahead. A fixed-length secret (an AWS secret key, a registered secret
value) cut by the window end was then exported unmasked.
The window now checks the last quote of each kind: it asks the redactor
whether the text before that quote, a stand-in value and the closing
quote would be masked. If so, or if a private key has no END line, the
export ends with *** and the closing delimiter from where the value
starts. A window whose masks shorten it is redacted once more, widened by
twice the shortfall. If masks removed more than half of it, the export
keeps a full lookahead of redacted text after it and comes out shorter
than its budget.
Content without secrets exports the same bytes as before.
The probe that asks the redactor whether a quote opens a secret missed three shapes and could grow large: - It read "not open" whenever the redacted probe still contained the 24-zero stand-in anywhere, so zeros in the key context (a push webhook's null commit id before "password") hid a secret. - It took the 256 characters before the quote as the key context. The secret rules allow any whitespace between a key and its quote, so "password:" followed by 260 spaces lost the key. - It carried the whole escape run before the quote twice, so 7,000 backslashes made one probe over 14,000 characters. The probe now checks only that its own stand-in and closing quote come back unmasked, walks back over the separator before taking the key context, collapses separator whitespace to one space and caps escapes at 64, the redactor's own limit for serialized quotes. Each probe stays under 512 characters. A quote before the last line break is now probed with a value that crosses a line, so only rules for values spanning lines (JSON strings) mask it. This applies to every quote kind, and stops text after an unclosed quote at a line end from being masked when no rule would mask it in the whole text. Tests cover the 128K tool input and output paths. Their cut falls on the core redactor's 16,384-character chunk boundary, which already misses a token crossing it in the whole text, so the token-crossing test skips them.
…word end The probe's key context began exactly 256 characters before the separator. When that cut fell inside a word such as `xtoken="`, the probe began with `token="`, a quoted assignment the text does not have. Its value ran to the quote after a later `password:`, so the stand-in came back unmasked and a secret straddling the export cut was exported. The context now starts on the first non-word character at or before the cut, so the probe's start adds no boundary the text lacks. A context that is one word throughout keeps its cut. State the real redaction bound: masks and quote probes can make a clipped string cost up to five windows, so a JSON attribute's work can exceed the 8x window budget it is picked by. Cost tests now cover a model call full of masked secrets, a log body full of quoted secrets (probes and widening both run), and a long separator before a quote.
…action lookahead Registered secrets only match as whole values. A registered value longer than the 4,096-character lookahead that started just before an attribute's cut ended past the redaction window, so its prefix reached the exported attribute unmasked; the whole-value pass on main masked it. Core now reports the longest registered secret length through `getLongestRegisteredSecretLength()` in `openclaw/plugin-sdk/logging-core`, cached with the matcher and reset on every membership change. The lookahead is the longer of 4,096 characters and that length, for both the redaction window and the 8x per-candidate work count, so a registered secret that starts before the cut ends inside the window and is masked whole. Without a registered secret over 4,096 characters every exported attribute and redaction count is unchanged. The new function adds one public export and one callable to the SDK surface budgets.
A JSON value whose smallest truncation fit the attribute but not the 8x
redaction cap was exported as {"truncated":true,"reason":"max_attribute_size"}.
The cap dropped it, not its size, so the summary now says
`max_redaction_work`. An object of 512 strings of 5,000 characters reaches
it with no registered secret, and a registered surface form of about 1M
characters reaches it for a model call whose first message holds a longer
string.
The lookahead comment now states what a long registered secret costs:
every clipped string's window grows by its length, and JSON attributes keep
fewer items as it grows. A new test registers a 65,536-character secret and
keeps a 200 x 100,000 model call's redaction work under the model-call
bound. Counting only the 4,096-character minimum against the cap fails it
at 26,667,962 characters.
The core eviction test pins getLongestRegisteredSecretLength() across
registration, eviction and reset. The plugin imports redactSensitiveText
from openclaw/plugin-sdk/logging-core instead of the deprecated
security-runtime barrel, and the SDK docs paragraph moves after the matcher
contract and says the length counts the URL-encoded and JSON-escaped forms.
Main now imports redactSensitiveText in service-content-normalization.ts straight from the SDK; this branch keeps the ../api.js import, which the redaction-cost tests wrap. Main's plugin SDK public export and callable budgets (4590 and 2694) rise by one each for getLongestRegisteredSecretLength().
src/logging/redact.test.ts is over the 1,000-line cap, and the line-cap ratchet rejects the five lines the longest-length assertions added. The two eviction tests move, with those assertions, to secret-redaction-registry.test.ts, the registry's own test file; nothing else in them changes. The summary-reason fixture no longer shadows `_` in nested callbacks (oxlint no-shadow).
|
Updated the branch and Evidence section at @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Main and this branch both raised the plugin SDK public export budgets. Keep both justifications and sum the increments: publicExports 3810 + 5 (main) + 3 (this branch) = 3818, publicFunctionExports 2208 + 3 (main) + 3 (this branch) = 2214.
|
Updated the description for CI 39795491565 is still failing. Its executed merge No source change or CI rerun in this update. The latest source review reports no findings at |
…penclaw#180713 openclaw#180713 moved MAX_OTEL_LOG_BODY_CHARS out of service-constants.ts into its only production consumer, service-logs.ts, as a module-private const. This branch's test-api.ts and service-content-normalization.test.ts still imported it from service-constants.js. The merge with main applied without a textual conflict, but tsgo reported TS2305 in both files, and at run time the cap read as undefined: 14 content-normalization tests and the 2 root registered-secret tests failed. Export the constant from service-logs.ts, which owns it, and import it from there. The value (4 KiB) and its production use are unchanged.
Integrate main and keep clipped open-secret results unsettled while registered values exist so the bounded retry masks newly exposed prefixes. Add registry and emitted-body regressions. Validate 198 focused cases, fail-before controls, work/lookahead mutations, and touched format/type/lint checks. SDK surface overages match an executed exact-main control; maintainer capture, SDK and security decisions remain open.
Integrate the exact hosted base and set the test-line ceiling to the verified 6,311,628 total: 977 regression lines plus 91 lines already above the base ceiling. Keep all cases and assertions unchanged. Validate 235 focused cases, touched-file format, and the ratchet's pass, one-line failure, and restored-pass controls.
Resolve the concrete baseline conflict with upstream openclaw#186980 while retaining its SQLite regression coverage and all 977 telemetry regression lines. Measure the pinned base at 6,310,907 lines and the combined tree at 6,311,884; set that exact ceiling without extra allowance. The ratchet passes, rejects one added line, and passes after restoration. Touched-file format, source identities and 13 integration cases pass.
Integrate main through 0ded0ed while retaining all 977 telemetry regression lines and the upstream 6,320,000-line ceiling. The code and test blobs match tree 7b0e0d5cd879f427cccce76255dae5b3f19ca272, where 25 focused cases passed. The final tree changes only the upstream baseline; its ratchet positive, over-ceiling negative and restored controls exit 0, 1 and 0. Formatting and diff checks pass.
Resolve scripts/plugin-sdk-surface-report.mts by keeping main's budget notes and this branch's note, and setting the public budgets to main's 3,859 exports and 2,232 callable exports plus this branch's three logging-core functions: 3,862 and 2,235, which plugin-sdk:surface:check measures on the merged tree.
Record the 977 test lines this branch adds over main 2e24ab7 (normalization 772, open-secret 66, registered-secret consumer 63, emitted-body capture 36, registry 31, logging config 9) as a separate allocation, as the test-line budget requires for justified growth.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Closing as superseded by #186666, which fixed #158116 on main with a different approach: a per-export redaction memo, a 4x bound on whole-JSON redaction, and dropping oversized inline image bytes. I re-ran this PR's own 1M-window Gateway harness against main |
…law#186666's oversized-image drop v2026.11.2 carries upstream openclaw#186666 (bc871e7), which superseded openclaw#158145 upstream. The fork keeps its openclaw#158145 normalizer: with the tag's two content files in its place, 11 of the fork's own content-normalization tests fail (231/242 against 240/242 at 3eefd13, on the M4). Two of 11.2's new tests in service-genai-content.test.ts failed on the fork's normalizer: - "drops image bytes too large to export whole and keeps smaller images": the fork exported a truncated prefix of the bytes. Take openclaw#186666's drop in redactInternalReasoningParts as is, and export MAX_OTEL_CONTENT_ATTRIBUTE_CHARS from the normalizer for it. - "redacts each string of a large transcript once and masks it in every attribute (openclaw#158116)": the spy sat on plugin-sdk/security-runtime, but the fork's normalizer reaches redactSensitiveText through plugin-sdk/logging-core (its api.ts), so it saw no calls. The mock now targets logging-core. The fork redacts bounded windows of what it exports rather than memoizing whole strings, so no call ever equals a whole tool output; "once per string" becomes the same bound on total work: redacted characters <= transcript characters. Measured on this transcript: 248 calls, 662,311 characters for 800,590, largest call 84,803 (<= 4x budget), 98 ms, no secret in any attribute. Redacting each string per attribute would be about 3x the transcript. The masking assertions are unchanged.

Closes #158116
What Problem This Solves
Fixes: the Gateway event loop blocks after every model call when
diagnostics.otel.captureContentis on and the session's prompts are large.User Impact
User impact: with content capture on, every channel on the Gateway stops answering while one large session runs, and the stall grows with the prompt, not with the 128 KiB that is exported. #158116 measured ~150 s blocks per call on a live Gateway. With the 1M-token window below, main reaches 1.2 s
/readyzlatency at 2.1M characters of prompt; this PR stays under 130 ms.Why This Change Was Made
safeJsonStringredacted the whole serialized value only to learn it was over the 128 KiB budget, then retried up to 7 x 9 truncation budgets, redacting every string in full each time. That ran forgen_ai.input.messages,input.value,openclaw.content.input_messages, the output pairs and the tool definitions, on the event loop.This PR:
@, open quoted value) from where it starts, usingfindTruncatedSecretin core;logging.redactPatternsis set, since a configured rule can need any amount of text;gen_ai.input.messages/input.value, the output pair) once.Core keeps secret matching and the registered-value registry; the plugin keeps the budgets. Three functions are added to
openclaw/plugin-sdk/logging-core:findTruncatedSecret(),getLongestRegisteredSecretLength()andhasConfiguredRedactPatterns().Evidence
Head
ee8f1612a06= previous heade84c7301e2da+ merge of main2e24ab71b147+ the test-line allocation. The 17 code and test files are byte-identical toe84c7301e2da; the merge only toucheddocs/plugins/sdk-subpaths.mdand the SDK budget lines (main's 3,859 / 2,232 plus these 3).Gateway, main vs this PR. A real Gateway started through qa-lab with the mock OpenAI provider,
diagnostics-oteltraces and logs,captureContent: true, modelcontextWindow1,000,000 and a local OTLP receiver. 40 turns, each reading a 300,414-character file of log lines with fresh bearer JWTs, a GitLab token and a 5,134-character Atlassian token, while/readyzis probed every 100 ms. Same harness, same host, run back to back:2e24ab71b147ee8f1612a06/readyzmax/readyzprobes > 250 ms / > 1 smain-thread stallwarningsThe secrets were in every turn's model input on both trees, and a plain marker reached the export on both. With the default context window, compaction keeps the same session under 315K characters and main's
/readyzmax is 108 ms, which is why the comparison sets 1M. Not covered: image payloads, a real collector, a real channel, Linux; one run per tree on a busy host.Fail without the fix. With main's
service-content-normalization.tsrestored and everything else at this head, the two diagnostics-otel test files give 10 failed, 101 passed: both redaction-work bounds, the URL-password and database-URL cut cases, andredacts line-start assignments in content that fits without truncation, where main's normalizer exports the planted secret unmasked (JSON escaping turns the line break into\n, which hides a line-start assignment from the text rules). At this head the six changed test files pass 148 of 148;src/loggingplusextensions/diagnostics-otelpass 1,027 with 4 skipped.Checks.
pnpm tsgo:allpasses.plugin-sdk:surface:checkmeasures 3,862 / 2,235 public exports against those budgets, and fails with each budget lowered by one. oxlint, oxfmt, and the line-cap, max-lines, assertion-safety, database-dialect, timeout-race and mock-export ratchets pass against2e24ab71b147.Test-line ratchet. This PR adds 977 test lines and allocates exactly 977 (normalization 772, open-secret 66, registered-secret consumer 63, emitted-body capture 36, registry 31, logging config 9). Main
f5f27c3ef6eis 10 lines over its own ceiling (6,421,662 vs 6,421,652), and the script fails any change that adds lines while the tree is over, sotest-lineshere fails by exactly those 10 (over by: 10; net delta: +977). An allocation of 987 is rejected (credit 987 exceeds added test lines 977). It clears when main is back under its ceiling.CI on
ee8f1612a06: running at the time of this edit. Expecttest-linesred by main's 10 lines (above); every other job is judged on its own.Simplification pass. I ran the repo's pr-simplify pass over the whole diff and removed nothing: the log and JSON export paths share one bounded-redaction function, each core fact sits with its existing owner, and every test group fails for a distinct reason (the control above shows the work-bound and boundary groups failing on main). Against
2e24ab71b147: production TypeScript +426 code / +125 comment lines, -51, in 12 files; tests net +977 in 6 files. One alternative is in the decisions below.Decisions this needs from a maintainer
max_redaction_worksummary where main (slowly) exported more, as listed under limits below.findTruncatedSecret(),getLongestRegisteredSecretLength()andhasConfiguredRedactPatterns()inopenclaw/plugin-sdk/logging-core. The alternative is one core operation that redacts a prefix safely and owns all four concerns; I can switch to that if you prefer it, at the cost of redoing this qualification.src/logging/*redact*.tsand*secret*.tsare in the redaction category of.github/security-review-policy.yml.Capture and security limits
max_redaction_worksummary.logging.redactPatternskeep whole-value work and can still block on very large captures. The shared configured-pattern path processes long strings in 16,384-character chunks without overlap, a pre-existing limit.SG.keys, Slack webhook URLs, Telegram bot tokens andFlyV1 fm<digits>_would need to exceed the lookahead before their secret part; not covered. A JWT header longer than the lookahead can export header parameters up to the cut./, whitespace or@can be dropped where main keeps it.