Skip to content

fix(sandbox): emit small dep-metrics lines (pipeline drops large ones)#4275

Merged
pedrofrxncx merged 2 commits into
mainfrom
fix/sandbox-dep-metrics-small-lines
Jul 2, 2026
Merged

fix(sandbox): emit small dep-metrics lines (pipeline drops large ones)#4275
pedrofrxncx merged 2 commits into
mainfrom
fix/sandbox-dep-metrics-small-lines

Conversation

@pedrofrxncx

@pedrofrxncx pedrofrxncx commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

Root cause (measured in prod, not inferred)

The previous chunked format emitted ~15KB sandbox.deps lines. The log pipeline rejects large lines from sandbox pods — confirmed:

  • sandbox.deps appears nowhere in VictoriaLogs (0 hits, any form), while VL logs 53 missing _msg field ingestion rejections, one from a 1.9.2 pod.
  • Across 1500 lines in all namespaces, max surviving _msg = 765 bytes; nothing >2KB exists.
  • The earlier ~250B per-dep lines (1.9.1) survived reliably.

So the 16KB truncation we saw earlier was the generous end; in practice only small lines land. My chunked cap (15.5KB) was ~20× too big → every line dropped → panel empty.

Fix

MAX_LINE_BYTES 15500 → 600. Each line stays well inside the proven-surviving range (~13 deps/line → ~27 lines for a big install, vs the 350 one-per-dep lines that got burst-sampled). Small enough to survive ingestion, few enough to cut sampling.

Residual burst-sampling is handled in the panel: stats by (deps) sum(sample_rate) (unsampled → sample_rate=1 → sum=count; sampled → reversed to an estimate).

Tests

Updated to assert the small cap: every emitted line < 700 bytes and the full set intact exactly once, across typical (391), long-name (~203-char), and 4000-short-dep inputs. 6 pass, typecheck clean.

Honest caveat

I've had three wrong iterations on this chasing undocumented pipeline limits (16KB truncation → burst sampling → large-line drop). This cap is grounded in the measured 765B ceiling + proven 250B survival, but I can only fully confirm end-to-end once it deploys and a sandbox installs. I'll verify against real sandbox.deps lines after roll before calling it done.

🤖 Generated with Claude Code


Summary by cubic

Emit small sandbox.deps log lines (~600B) and clip long repo/branch metadata so they survive ingestion; previous ~15KB lines were dropped, leaving the panel with no data.

  • Bug Fixes
    • Capped each emitted line at 600 bytes and grouped deps to stay under the ~765B observed ceiling.
    • Bounded repoName and branch to 80 chars so long metadata can’t oversize lines; chunking budgets against the clipped values.
    • Correctly budgets JSON escaping and long package names; works for large installs and thousands of short deps.
    • Updated tests to assert <700B per line and exact reconstruction, including long-name, large-count, and long repo/branch cases.
    • Panel compensates for burst sampling by summing sample_rate.

Written for commit 4ef12d1. Summary will update on new commits.

Review in cubic

Measured in prod: the log pipeline stores only small lines from sandbox
pods (max ~765B observed across namespaces); the ~15KB chunked lines from
the previous fix were rejected outright ("missing _msg field"), so the
panel got zero data. The earlier ~250B per-dep lines survived fine.

Drop MAX_LINE_BYTES 15500 -> 600 so each line stays well inside the
proven-surviving range (~13 deps/line, ~27 lines for a big install). Many
small lines may be burst-sampled by the collector; the Grafana panel sums
sample_rate to correct for that. Tests updated to assert the small cap.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

1 issue found across 2 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread packages/sandbox/daemon/setup/dep-metrics.ts
…ines

The chunker budgets deps against the measured envelope, but repoName/branch
were unbounded — a very long branch name could inflate the envelope past
the 600B cap on its own, oversizing every line (incl. the always-emitted
first dep) and getting the whole install's data dropped. Clip both to 80
chars before measuring and emitting. Adds a 500-char-branch test.
@pedrofrxncx pedrofrxncx enabled auto-merge (squash) July 2, 2026 23:00
@pedrofrxncx pedrofrxncx merged commit d2f46d7 into main Jul 2, 2026
14 checks passed
@pedrofrxncx pedrofrxncx deleted the fix/sandbox-dep-metrics-small-lines branch July 2, 2026 23:01
decocms Bot pushed a commit that referenced this pull request Jul 2, 2026
PR: #4275 fix(sandbox): emit small dep-metrics lines (pipeline drops large ones)
Bump type: patch

- @decocms/sandbox (packages/sandbox/package.json): 1.9.2 -> 1.9.3

Deploy-Scope: both
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant