Skip to content

Feat: Record plain-HTTP bodies and body sizes in lineage (contract v1.8) - #1506

Merged
huang195 merged 1 commit into
rossoctl:mainfrom
s-and-p-team:fix/lineage-http-payload
Oct 27, 2026
Merged

huang195 merged 1 commit into
rossoctl:mainfrom
s-and-p-team:fix/lineage-http-payload

Conversation

@JoshSag

@JoshSag JoshSag commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1505.

The lineage plugin recorded no payload for an exchange no parser claimed, so a tool's REST backend (a GET to a weather service, a POST of a card to a payment provider) always arrived with no input.value / output.value.

What changes:

  • Under capture_io, the raw request and response bodies become the http payload, capped by max_payload_bytes like the parsed ones. A body is emitted only when it is UTF-8 text with no NUL byte (an OTLP string attribute must be UTF-8, and one that is not fails the export batch; a NUL fails it at the consumer's JSON column). A response body is emitted only when the listener's buffer holds all of it, judged by the listener's own byte count against the buffer: a streamed response leaves at most its tail, and a response rewriter that changes the length reads as not whole. A denied exchange's response is not emitted: its client never received that body.
  • Two facts on every exchange, http.request.body.size and http.response.body.size, so a consumer can tell "no body" from "body not captured". They are emitted whatever capture_io says. A size is what the listener counted; the contract names the envoy-sidecar cases where that is 0 although a body existed.
  • The plugin still declares no body capability. Every parser in its RequiresAny declares ReadsBody, so the bodies are already buffered. Declaring the flag would forbid lineage after a plugin that rewrites the body, which is where it records the request as it was forwarded. Two tests pin this: one fails if a required parser stops declaring ReadsBody, the other fails if lineage starts declaring it.
  • Contract v1.8.0 (docs/lineage-wire-contract.md). The lab-data-governance copy on its risk branch gets the same text.
  • The plugin's docs and the attach kit's docs now say that capture_io carries plain-HTTP bodies, credentials included (a token request's client_secret, the token in its reply).

Tests:

  • go test ./... in core, go vet, gofmt and pre-commit are clean.
  • cmd/cortex (full profile) and cmd/cortex-envoy (envoy profile) build and pass their tests. Both boot with lineage configured and a body rewriter ahead of it, with no capability warning.
  • Removing the two http cases fails five tests: four new ones and the extended extractor table.

Live, on a kind cluster in proxy-sidecar mode, one tool pod's sidecar was run three times: as the image the platform deploys (v0.7.0-alpha.10), as main, and as this branch. The tool POSTs a card to a payment API. With this branch, that exchange carries both bodies and their sizes, and the MCP spans gain the size facts. On that pod's spans nothing else differs from main, and main does not differ from v0.7.0-alpha.10.

Assisted-By: Claude (Anthropic AI) noreply@anthropic.com

Summary by CodeRabbit

  • New Features
    • Spans can now include raw request bodies and complete response bodies from plain HTTP exchanges when payload capture is enabled. Bodies are included only when they contain valid text; response bodies must also be complete and not denied.
    • Body sizes are reported independently of payload capture. Captured content remains subject to size limits and may contain credentials.
  • Documentation
    • Updated setup and configuration guidance to describe plain HTTP body capture and its security considerations.

The lineage plugin recorded no payload for an exchange no parser claimed:
ioInputValue / ioOutputValue had no http case, so a tool's REST backend (a
GET to a weather service, a POST of a card to a payment provider) always
landed with NULL payloads, invisible to classification and data lineage.

Under capture_io the raw request and response bodies are now the http
payload, bounded by max_payload_bytes like the parsed ones. A body is
emitted only when it is text: valid UTF-8 (an OTLP string attribute must
be, and one that is not fails the whole export batch) with no NUL byte
(which a JSON or text column downstream refuses, with the same effect).
The response is emitted only when the listener's buffer holds the whole
body, judged by the listener's own byte count against its buffer, and
not when the exchange was denied (the client never received that body).

Two facts on every exchange, http.request.body.size and
http.response.body.size, let the consumer tell "no body" from "body not
captured". A size is what the listener counted, and the contract says
where that is 0 although a body existed (envoy-sidecar never handing the
producer the body).

The plugin still declares no body capability: every parser it requires
declares ReadsBody, so the bodies are buffered already, and declaring it
would forbid lineage after a plugin that rewrites the body, which is where
it records the request as forwarded. Tests pin both.

Contract bumped to v1.8.0 in docs/lineage-wire-contract.md; the
lab-data-governance copy takes the same text in a change of its own. The
attach kit's and the plugin's docs now say that capture_io carries plain
HTTP bodies, credentials included.

Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com>
Signed-off-by: YehoshuaSagron <ysagron@gmail.com>
@JoshSag
JoshSag requested a review from a team as a code owner October 26, 2026 15:41
@coderabbitai

coderabbitai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 07eb9634-a5ce-4b46-96c8-0d2bd54f711e
Commits

Reviewing files that changed from the base of the PR and between e455a04 and 3e6f4e4.

Files selected for processing: 12
  • core/plugins/lineage/config.go
  • core/plugins/lineage/plugin.go
  • core/plugins/lineage/plugin_test.go
  • demos/lineage/README.md
  • deploy/lineage-attach/DESIGN.md
  • deploy/lineage-attach/README.md
  • deploy/lineage-attach/RECIPE.md
  • deploy/lineage-attach/attach-lineage.sh
  • docs/framework-architecture.md
  • docs/lineage-telemetry-plugin.md
  • docs/lineage-wire-contract.md
  • docs/plugin-catalog.md

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Walkthrough

The lineage plugin now records HTTP request and response body sizes. When capture_io is enabled, it can add eligible raw HTTP bodies to spans. The wire contract and related configuration and operator documentation describe the capture conditions and credential exposure.

Changes: Plain HTTP lineage capture

Layer / File(s) Summary
Body-size attributes and body-read contract
core/plugins/lineage/plugin.go, core/plugins/lineage/plugin_test.go, docs/framework-architecture.md, docs/lineage-wire-contract.md
The plugin records request and response body sizes independently of payload capture. Tests cover body sizes across protocols and CONNECT exchanges. The documentation describes the body-read requirements and wire attributes.
Raw HTTP payload capture
core/plugins/lineage/config.go, core/plugins/lineage/plugin.go, core/plugins/lineage/plugin_test.go, deploy/lineage-attach/*, demos/lineage/README.md, docs/lineage-telemetry-plugin.md, docs/lineage-wire-contract.md, docs/plugin-catalog.md
When capture is enabled, the plugin includes nonempty UTF-8 HTTP bodies without NUL bytes. It omits response payloads when the response is denied or the buffered response length differs from the recorded byte count. Tests cover these conditions, payload limits, and truncation. Documentation describes the capture behavior and notes that bodies may contain credentials.

Priority: Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Feature · Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant HTTPListener
  participant LineagePlugin
  participant LineageSpan
  participant Collector
  HTTPListener->>LineagePlugin: Request and response buffers with response byte count
  LineagePlugin->>LineageSpan: Eligible raw payloads and body-size attributes
  LineageSpan->>Collector: Captured content over plain gRPC
Loading

Suggested reviewers: huang195, esnible

Merge Risk: Minimal · up to 3e6f4

No confirmed issue currently blocks merging; the consumer implementation has not been verified from the available source.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely summarizes the main changes: recording plain-HTTP bodies and body sizes in lineage, with the wire contract version.
Linked Issues check Passed Issue #1505 coding requirements are implemented. core/plugins/lineage/plugin.go emits raw http request and complete response bodies under capture_io, applies text validation and the configured p…
Out of Scope Changes check Passed The changed implementation, tests, contract, architecture note, plugin catalog, demo documentation, and lineage-attach documentation all support issue #1505. The documentation changes explain raw HTTP…
Docstring Coverage Passed Docstring coverage is 95.45% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 22 functions across 4 files. (8 skipped: 8 …
Full details: Linked Issues check

Explanation

Issue #1505 coding requirements are implemented. core/plugins/lineage/plugin.go emits raw http request and complete response bodies under capture_io, applies text validation and the configured payload cap, suppresses denied or incomplete responses, and emits http.request.body.size and http.response.body.size on every exchange. The plugin keeps ReadsBody false while required parsers declare body reads. Tests cover capture gates, truncation, invalid UTF-8, NUL bytes, incomplete and rewritten responses, denied responses, body sizes, and capability behavior. docs/lineage-wire-contract.md updates the contract to v1.8.0 and documents the new behavior.

Full details: Out of Scope Changes check

Explanation

The changed implementation, tests, contract, architecture note, plugin catalog, demo documentation, and lineage-attach documentation all support issue #1505. The documentation changes explain raw HTTP payloads, body sizes, capture limits, and credential exposure. No unrelated change is demonstrated by the reviewed diff.

Full details: Docstring Coverage

Explanation

Docstring coverage is 95.45% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 22 functions across 4 files. (8 skipped: 8 unsupported.)

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@JoshSag

JoshSag commented Oct 26, 2026

Copy link
Copy Markdown
Contributor Author

A question for the framework, separate from this change:

In the lineage plugin we want to read the body after the body rewrites, because we want the payload as it went on the wire and as the receiver actually got it. For example: parsers → tool-prune → lineage-telemetry.

Declaring ReadsBody on lineage refuses that chain: a body reader may not come after a mutator. Reading the body without declaring it, as this PR does, works but is not ideal either.

This seems like a general framework issue. Maybe the framework needs a third body capability, ObservesBody or similar: buffered like ReadsBody, but allowed after the mutators.

@huang195 huang195 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The http payload logic holds up against the listeners. I checked it against extproc (ResponseBytes summed per chunk, ResponseBody bounded or replaced on the SSE arm), the two proxies' bodycount.Wrap choke points, and the oversize and read-failure paths, where ResponseBody stays nil while the count is non-zero. In each case len(ResponseBody) == ResponseBytes says what the PR says it does. Each parser in RequiresAny declares ReadsBody unconditionally, so skipping the capability is safe. The two tests pin both halves of that.

Two suggestions inline: the upgrade behaviour of capture_io, and the cost of copying a whole body to emit 4 KB of it. Neither blocks.

// OTel backend enforces appropriate access controls. The raw bodies carry
// whatever the app sends in plain HTTP, credentials included (a token
// request's client_secret, the access token in its reply).
CaptureIO bool `json:"capture_io" description:"Attach request/response content as input.value / output.value: parsed for a2a/mcp/inference, the raw body for plain HTTP (credentials included)." default:"false"`

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: this widens what an existing capture_io: true means, and nothing in the config shows the change.

A deployment that turned capture on under v1.7 agreed to the parsers' reduction. After upgrading, it starts exporting raw plain-HTTP bodies too — credentials included, as the new docs say — and it has no way to keep the v1.7 behaviour short of turning capture off entirely. demos/lineage is one such deployment, and on the stock platform the collector prints every attribute into its pod log.

The contract's "configuration unchanged" is accurate, but that is the problem: the flag stays the same while what it exports grows. Two options:

  • a separate opt-in (capture_http_bodies, default false), so existing configs export exactly what they did; or
  • keep one flag, and file the PR so the release notes show it as a behaviour change, not only under New features.

The first is safer for a flag whose whole job is privacy.

// the batch. The plugin decodes nothing — a compressed or binary body is
// reported by its size fact alone, which is the honest shape: a body existed,
// and it was not text.
func textBody(b []byte) string {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: textBody scans the whole body twice and copies it into a string, and then truncate keeps the first max_payload_bytes (4096 by default) and drops the rest.

The forward proxy buffers requests up to 32 MiB and responses up to 10 MB. With capture on, an unparsed upload therefore costs a full-size allocation plus two full scans, and the request half runs in OnRequest, on the request path. Only the prefix is ever emitted, so it is enough to check and convert that prefix. Cut b to the cap, back up to a rune start (as truncate does), and run utf8.Valid/IndexByte on the result. -1 keeps today's whole-body path.

One semantic difference to decide on: a body whose NUL or invalid byte sits past the cap would then be emitted as its (clean) prefix. That still meets the OTLP constraint, which applies to the bytes emitted, but the contract's "emitted only when it is text" would need to say "when the emitted prefix is text".

@huang195
huang195 merged commit a617df6 into rossoctl:main Oct 27, 2026
31 checks passed
@github-project-automation github-project-automation Bot moved this from New/ToDo to Done in Rossoctl Issue Prioritization Oct 27, 2026
boazdavid added a commit that referenced this pull request Nov 29, 2026
- Pin context-guru v0.7.10 in core, cmd/cortex and cmd/cortex-envoy.
- keepalive.Record lost its Agent field (context-guru #1506). Pass the
  client as Identity, from agent.Identify of the request headers, as the
  context-guru proxy does.
- TestAPanicInOnFinishStillDeparts got its panic from a store write that
  context-guru now recovers itself (#1513). It now panics in stashSent,
  which runs in this plugin before Record.
- TestPolicyDefaults expects no flat per-ping cap: since context-guru
  #1428 a value rule decides, and an operator opts in to a cap with
  keepalive_max_usd_per_ping.

Behavior change: a keep-alive ping is no longer refused at a flat $0.50.
It runs when the planned pings cost less than the cache miss they protect.

Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com>
Signed-off-by: DAVID BOAZ <DAVIDBO@il.ibm.com>
boazdavid added a commit that referenced this pull request Nov 29, 2026
- Pin context-guru v0.7.10 in core, cmd/cortex and cmd/cortex-envoy.
- keepalive.Record lost its Agent field (context-guru #1506). Pass the
  client as Identity, from agent.Identify of the request headers, as the
  context-guru proxy does.
- TestAPanicInOnFinishStillDeparts got its panic from a store write that
  context-guru now recovers itself (#1513). It now panics in stashSent,
  which runs in this plugin before Record.
- TestPolicyDefaults expects no flat per-ping cap: since context-guru
  #1428 a value rule decides, and an operator opts in to a cap with
  keepalive_max_usd_per_ping.

Behavior change: a keep-alive ping is no longer refused at a flat $0.50.
It runs when the planned pings cost less than the cache miss they protect.

Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com>
Signed-off-by: DAVID BOAZ <DAVIDBO@il.ibm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Lineage plugin records no payload for plain-HTTP exchanges

2 participants