Repository navigation
feat(trace): inspect bounded metadata evidence and find Window calls - #782
Conversation
yyjeqhc
left a comment
There was a problem hiding this comment.
Reviewed on OE against the complete PR diff and the current main integration. The design keeps ActionAudit as the bounded searchable call index, private trace storage as evidence rather than authority, and read_tool_trace admin-only / protocol-gated. Metadata capture remains bounded and fail-open, raw payload reads stay explicit, trace/Window identifiers grant no authority, and Runtime Console/MCP share the same authorized read path. The Window search correctly preserves missing Host identity instead of inferring it from Project.
One concrete WebUI boundedness defect was fixed in review: the advertised 240-event display ceiling could be exceeded when a size-bounded final page crossed the boundary. Review commit aa660b44 now slices accumulated evidence at the exact ceiling, removes further paging at the bound, adds a regression, and regenerates the Runtime bundle.
Validation: PR-head GitHub CI before the review fix was fully green. After the frontend-only fix, OE frontend full suite is 157/157 across 24 files, typecheck and check:dist pass, Rust trace tests 59/59 and tool-contracts 258/258 pass. The exact conflict-free merge with current main (55b7085a, including #779/#781) was additionally tested: tool-contracts all-features 267/267, trace tests 59/59, and full webcodex --lib 3127 passed / 3 ignored / 0 failed. Current-head CI has all completed core Linux/tooling/contract/Mac-core/Windows-runner/package lanes green; remaining native lanes are still running with no failures. No remaining blocking findings.
Summary
Complete the interrupted metadata-trace work saved by the user as
41d1c2345b50fe176d51f337bcbf03e391cdbdcdon base6524f559a85d2509b7379c472bd63ceb933cd57a. Development and verification continued on xa at/disk6/xie_rh/jialin/git/webcodex. The saved commit is retained, followed by four implementation/review commits:05f9d9c5— complete bounded metadata capture, reader/query boundaries, integration and schema regressions.ccfcb8dc— wire explicit Window call search and lazy diagnostic inspection, fix stale reads, translations, tests and generated bundles.1cd4b365— maintainer documentation, capture limits, validation and deployment distinction.aa660b44— review fix: enforce the advertised 240-event WebUI display ceiling even when a bounded server page crosses the final boundary, with regression coverage and regenerated Runtime bundle.Final HEAD
aa660b44e2aacd30e7fa9a5c3565deb64886202b.Metadata evidence without routine full capture
Enabled metadata mode now persists lifecycle events and selected bounded diagnostic summaries in the existing private trace directory. ActionAudit remains the Window/call/time index; there is no second business ledger or raw-payload database.
Capture stages distinguish:
_wcbefore envelope parsing, preserving gateway entry versus actual selected target;Selected tools cover bootstrap, reading/search, process/script/shell, structured edits/Git, validation and Job observation. Explicit
_wcis also observable on other ordinary tools, without capturing their business body. Trace-reader and continuation suppression remains intact.not_observedis no longer dropped by the existing semantic-status telemetry projection.Each diagnostic is at most 8 KiB, with bounded traversal depth/nodes/items/text. Large scripts, file/patch/text bodies, stdin, stdout/stderr and log tails are omitted without cloning/serializing the entire source just to truncate it. Credential-labelled fields are omitted. Real paths, search selectors, command and argv prefixes are operator data and can contain arbitrary inline secrets; this is not a universal sanitizer. Existing business-audit allowlists are unchanged.
Metadata uses existing bounded asynchronous writes; saturation remains fail-open. Aggregate process-since-start queue/budget/write failure counters are visible, explicitly not per-trace completeness or durable historical counters. Runner request/result/terminal correlation remains downstream of authoritative acceptance, without serializing every Job log update. Capture-off stops new capture but does not delete or prohibit authorized reads of retained data.
Query and read boundaries
Extend the existing admin-only
read_tool_traceoperator extension rather than adding Direct tools:trace_refto search retained ActionAudit calls by time, exact Project/tool and optional Window.payload_indexexplicitly for one already-retained full payload, with existing digest, private-file and read-size checks.The shared method is used by MCP and
/api/runtime-console/trace; both recheck administrator authority. The Console retains same-origin JSON checks and MCP retains diagnostic protocol admission. A trace or Window ID never grants authority. No Session is created, inferred or recorded by the Console read.Defaults: 24-hour query range, maximum 31 days, at most 64 results/page and offset <=10,000. The returned effective range is reusable on subsequent pages. Window candidates/counts describe only returned calls; missing Host identity stays null. Query paging reads the live retained index, not a frozen cross-request report. A single observed-time expression and matching partial index own filtering/order, including legacy fallback; a regression proves coarse audit time cannot incorrectly exclude an exact millisecond match.
Trace index reads are bounded to 2 MiB / 4,096 entries, with at most 64 KiB of event entries per page. File reads serialize against append only while copying the bounded snapshot, not during JSON parsing. Missing capture is reported as
trace_not_retainedwith possible not-captured/dropped/expired/evicted causes, not as proof an operation never occurred. Handler handoff is not client receipt or model reading.The default exact trace response now lists events rather than only payload indexes. The input/output schema changes deliberately reflect query mode and metadata evidence. No App resource URI or Direct inventory change is introduced.
WebUI
The Work/Windows sidebar has an explicit time/Project/tool call search, so no pre-known Window hash is needed. Existing Window call rows can inspect the same trace. Metadata loads only on expansion; cached re-expansion, explicit refresh, paging and separately requested full payloads are supported. No new polling or automatic retry. Superseded/aborted responses cannot clear or append into a newer trace view. The page stops at 240 displayed events and points to the exact reader for further inspection.
Generated Runtime and Admin bundles are included; their larger diff is generated output, not an unrelated manual rewrite.
Validation
Implementation frozen through final validation:
cargo test --locked -p webcodex --lib tracepassed, then full default Server library: 3,124 passed / 3 ignored / 0 failed (115.16 s test phase). These selections overlap.check:distpassed.main(55b7085a, including fix(desktop): harden Tunnel recovery and macOS signing pipeline #779/fix(runtime): complete Session and AgentTask selector contracts #781): tool-contracts all-features 267 passed, trace-focused Server tests 59 passed, and the full Server library 3,127 passed / 3 ignored / 0 failed.Intermediate failures were resolved without weakening production checks: saved dispatcher syntax, test-module path, old required-trace schema assertion, Bootstrap-vs-ordinary test identity, and an adapter fixture exceeding the unchanged HTTP request limit. A frontend check interrupted by Runner process replacement was confirmed stopped and then rerun.
No full workspace/all-features suite, native Windows/macOS verification, browser E2E, or production full-vs-metadata performance benchmark was run. This PR does not add per-Window full-capture arming, automatic escalation or retroactive reconstruction of omitted data; these remain separate operator-control work.
Operations performed separately from this feature
At the user's request, the already-built xa dogfood Runner 0.4.3 / 6524f55 / dirty=false was deployed through a detached launcher and independent systemd user unit. Only
webcodex-runner-xa.servicewas restarted; its config digest stayed unchanged and the separatexrhRunner retained its PID. The previous binary is retained under~/.local/state/webcodex/xa-upgrade-6524f559-20260929/previous.That deployment does not deploy this trace feature. No Server deployment, production trace/ledger edit or merge was performed. xa's Git credential could push only its existing fork; identical reviewed objects were transmitted there, then the authorized GitHub connector fast-forwarded this canonical branch with
force=false. No credential configuration or published history was rewritten.Usage, limitations and examples:
docs/agent/tool-request-tracing.mdanddocs/implementation/bounded-meta-trace-diagnostics.md.