Skip to content

feat(capture): decode selected protobuf and gRPC bodies - #5031

Merged
gensokyo-dev merged 10 commits into
morluto:mainfrom
AayushJB03:feat/decode-protobuf-capture-bodies
Oct 20, 2026
Merged

gensokyo-dev merged 10 commits into
morluto:mainfrom
AayushJB03:feat/decode-protobuf-capture-bodies

Conversation

@AayushJB03

@AayushJB03 AayushJB03 commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #4986. Selected historical HTTP bodies expose bounded Protobuf/gRPC facts, optional supplied-schema interpretations and compact field queries through the same CLI/MCP implementation. Continues @AayushJB03's original PR with its commit preserved and follow-up fixes.

Behavior and ownership

  • Exact uint64 values, occurrence/parent identities, byte ranges and source/body hashes replace recursive guessed trees. Ambiguous UTF-8/nested/packed readings remain candidates. Partial/unknown coverage is explicit.
  • Existing analysis views provide body/frame/field collections, batch filters, columns and paging. Defaults omit large values; complete retained Evidence remains accessible after source deletion. Immutable validation and a bounded recent-filter cache share work.
  • Only selected records are interpreted. Raw Protobuf, gRPC and gRPC-web framing stay distinct. Local compiled FileDescriptorSet plus message type optionally adds scalar, packed and nested readings without schema downloads or target execution.
  • Independent credential inspection precedes HTTP eligibility, schema I/O and fact allocation. Hidden metadata cannot bypass trailer exclusion; unavailable coding metadata plus uninspectable framing fails before retaining unchecked source. Safe source otherwise survives typed later failures. Header names/unknown values and raw spelling remain owned by capture metadata.
  • Nested schema errors remain local, UTF-8 preserves BOM, packed interpretation yields/cancels, overrides require body coordinates and descriptor errors identify their actual input. Shared capture/process owners retain cleanup authority.

Domain contracts describe facts; browser/history adapters own parsing; shared application workflows serve named CLI/MCP contracts. SDK-converted schemas are validated against AJV2020. Additive options/view variant; authored docs/skill updated. Pinned @bufbuild/[email protected] has verified Apache/BSD notices and locked inventory.

Expected effects: read selected existing files/captured data and launch existing owned capture-decoder workers. No new target execution, injection, mutation or protection-recovery capability requiring a scope decision.

Executed validation

Head 06ac908f5; main snapshot 4668cea24:

  • npm run check, npm run docs:check: static/architecture/generated-doc/license checks and 5 README tests passed.
  • Twelve relevant source suites: 392 passed. Ghidra cases qualify source integration, not a new real-provider run.
  • Focused SAZ, historical decoder, advertised MCP schema and public Protobuf CLI/MCP suites: 42 passed, 1 existing runtime-condition skip. Includes retained/exported Evidence, source removal, malformed input, exclusions, hidden metadata, cancellation, capacity and cleanup.
  • npm run verify:package: packed install/update, CLI/MCP/Evidence, planned/idempotent setup, backups, uninstall and cleanup passed.
  • Original overflow and first six review failures reproduced on earlier compiled heads; SAZ whitespace and unknown-coding regressions also reproduced before their fixes. All 9 review threads resolved; reviewer confirmed the final source-admission fix. Codex automated review unavailable due repository quota.
  • Official Connect Eliza responses: Say 69 bytes/1 data frame, Introduce 230 bytes/4 data frames, each plus trailer. CLI/MCP values, all frame/field ranges and source/body/descriptor hashes matched independent protoc/Python oracles; Evidence IDs matched. Response bytes/headers/status/URL were observed; HAR timing is synthetic. Pinned official schema; descriptor SHA256 375f4946642425dbc53c0fe89467235016ff4dea543be1bf82720bddc948580d.

Example interpretation: field_id: "offset:5", schema_name: "sentence", schema_value: "hello", with mandatory provenance/coordinates, coverage and parent links.

Current-head GitHub CI: 45 checks passed, including all five test shards, Windows/package, native packages and real-application lanes. CI checked merge preview ff8c1be730 (head 06ac908f5 plus main 799e8265b); its only addition over the local qualification snapshot is the upstream Hopper-owner verification fix. All 9 review threads are resolved. A prior-head unchanged Windows fixture EBUSY passed on subsequent heads without an unrelated code change.

Measured completed tasks

Token estimates, latency, CPU, memory and limitations

Baseline a9370a906 retains the original decoder; candidate 06ac908f5 shares main 4668cea24. Both read the same selected UTF-8 candidate with source/body hashes and exact range; eight baseline sidecars were independently audited. Real Say uses complete inspection in both; generated 20,001-field data uses original complete inspection versus summary plus one field page.

Primary task Original token estimate Follow-up token estimate
Real Say: used input declarations, arguments, complete replies 5,212 6,422
Generated 20k fields: same accounting 1,380,174 20,551
Generated 20k fields: all catalog input declarations included 1,610,547 238,508

Tokenx estimates count the extra RPC. Actual model usage/rendering is unmeasured; small answers grow. Generated data is a stress case, not observed application scale.

Two fresh-process primary-only runs, complete verification harness including SDK/catalog/schema checks, token estimates and teardown:

Workload/version Wall s Family CPU s Sampled family RSS GiB
Real/original 5.16–5.30 5.06–5.18 0.66–0.66
Real/follow-up 5.35–5.35 5.23–5.23 0.66–0.66
Generated/original 6.60–7.62 6.47–7.30 0.66–0.68
Generated/follow-up 8.94–9.40 8.85–9.30 0.85–0.88

Cold generated-case RPCs regress: original 1.38–1.65 s versus follow-up 2.80–3.04 s for summary plus first page. Smaller context and stronger facts cost initial time/memory; no cold-speedup claim.

Separate retained reads after source removal: original 2,029/733/775 ms; selected fields 10.57/8.39/6.46 ms. These probes are excluded from primary counters. Full probe harness: original 14.01 s wall/13.93 s CPU/0.913 GiB; follow-up 8.99 s/8.89 s/0.870 GiB. Two-RPC real-schema correctness harness: 13.28 s/13.10 s/1.222 GiB; the old decoder has no equivalent schema capability.

Linux/Node24.18, two CPUs, 3 GiB V8 heaps, 8 GiB family guard; no retries/stops. RSS sampled every20ms sums family RSS and can double-count shared pages/miss short peaks. Runtime caches fresh; OS cache/host load uncontrolled. Engine-only costs and post-task sidecar audit unmeasured. Results qualify scoped projection/reuse, not a general provider speedup.

Real traffic verification is Linux/HAR only. Generated SAZ files exercise the production reader, not a Fiddler producer golden. Real native-gRPC, mitmproxy and other-OS protocol coverage remains unverified. Compression, map semantics, extensions and required-field validation remain explicitly unsupported. Supplied schemas do not establish the sender's schema; missing/mismatched interpretations remain visible.

Author readiness

Human owner: @gensokyo-dev

The human owner explicitly authorized this work, delegated the technical review and validation to Codex, directed these declarations to be recorded on their behalf, and requested ready-for-review submission and normal merge. This records that direction; it does not assert a separate, independent human diff review. Codex performed the documented technical review and checks.

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

…e records

Adds a derived protobuf view to inspect_web_network_capture for records chosen
with record_ordinals: gRPC/gRPC-web framing (including trailers and
grpc-web-text) and a protoc --decode_raw style wire decode with byte offsets.
Length-delimited readings are marked inferred. Retained base64 stays the source
of truth.

Refs morluto#4986

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>

Copy link
Copy Markdown

Reproducible wire-decoding correctness issue in the new readVarint helper (source-only review of this PR; no full REA test suite run):

const payload = Buffer.from("0880808080808080808002", "hex");
const decoded = decodeProtobufWire(payload);
// Current logic reports field 1's value as "0".

The payload is a valid field-1 varint tag followed by an invalid 10-byte uint64 varint: nine continuation bytes 80 and final byte 02 encode 2^64, which exceeds protobuf's 64-bit varint range. readVarint currently applies BigInt.asUintN(64, value), silently converting that invalid value to zero. I verified that the ten payload bytes evaluate to 18446744073709551616 before masking and 0 afterward.

Please reject an overflowing tenth byte (index === 9 && byte > 1) and retain a malformed-input error rather than publishing a false observed value. Regression controls: the invalid payload above must report an error; the maximum valid uint64 varint (ff ff ff ff ff ff ff ff ff 01) must still decode exactly to 18446744073709551615. It may also be worth rejecting a tenth byte with the continuation bit set.

This is limited to the proposed decoder and does not assert a bug in REA's current released runtime.

@gensokyo-dev gensokyo-dev changed the title feat(capture): decode protobuf and gRPC-web bodies in selected records feat(capture): decode selected protobuf and gRPC bodies Oct 20, 2026
@gensokyo-dev
gensokyo-dev marked this pull request as ready for review October 20, 2026 05:01
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-20T05:01:20.359669Z 3aae719 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@greptile-apps

greptile-apps Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The reviewed changes appear safe to merge, with the previous credential-exposure finding fixed.

Summary

Adds selected Protobuf and gRPC body reads, optional local schemas, and paged field views.

  • Selected capture bodies now yield Protobuf and gRPC facts with optional schema readings.
  • Saved Protobuf facts can be summarized and paged by body, frame, or field.

Live supersession status could not be checked because GitHub access was not authenticated. No tests were run during this review.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Selected capture bodies] --> B[Check credentials]
  B --> C{Credential found?}
  C -->|Yes| D[Exclude body bytes and digest]
  C -->|No| E{Hidden coding and incomplete check?}
  E -->|Yes| F[Stop without source Evidence]
  E -->|No| G{Identity coding established?}
  G -->|No| H[Keep source opaque]
  G -->|Yes| I[Read frames and fields]
  D --> J[Retain sanitized Evidence]
  H --> J
  I --> J
  J --> K[Page retained facts]
Loading

Reviews (6) · Last reviewed commit: "fix(capture): inspect credentials before..." · Reviewed by Greptile

@gensokyo-dev
gensokyo-dev merged commit 0134732 into morluto:main Oct 20, 2026
46 checks passed
@github-actions github-actions Bot mentioned this pull request Oct 20, 2026
3 tasks done
earakely-scale added a commit to earakely-scale/rea that referenced this pull request Oct 20, 2026
… into feat/environment-state-coverage

Keep main's tool description and change only its environment-state
documents clause to this branch's rule.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
kangyishuai pushed a commit to kangyishuai/rea that referenced this pull request Oct 20, 2026
…ansition-view

Resolve conflicts with main's protobuf capture view (morluto#5031). Main now
derives UnsignedAnalysisView from AnalysisViewResult instead of listing
each kind, so the browser-scenario result needs no separate entry. The
inspect_analysis_view description is main's text, including the protobuf
sentence, plus this branch's capture_browser_scenario additions.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sanjeev-Chakaravarthy pushed a commit to Sanjeev-Chakaravarthy/rea that referenced this pull request Oct 29, 2026
Sanjeev-Chakaravarthy pushed a commit to Sanjeev-Chakaravarthy/rea that referenced this pull request Nov 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: runtime Process capture and runtime observation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Decode protobuf and gRPC bodies in inspect-web-network-capture

4 participants