Skip to content

fix(claims): bound inventory file reads - #1380

Merged
steipete merged 1 commit into
mainfrom
steipete/fix-1373-claim-size
Aug 17, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/fix-1373-claim-size

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Summary

  • cap crabbox claims list at an inclusive 1 MiB per claim file
  • reject known oversized files before allocation and bound concurrent growth with a limit-plus-one reader
  • emit a stable claim_too_large problem while preserving valid partial output and exit code 2
  • leave runtime and mutating claim readers unchanged

Closes #1373

Verification

  • exact 1 MiB acceptance and 1 MiB + 1 rejection tests
  • malformed, valid, concurrent-growth, deterministic-output, and lock-free inventory race tests
  • source-blind RSS proof: empty 49,381,376 B; 128 MiB sparse file 49,397,760 B; 1 GiB sparse file 49,414,144 B
  • go vet ./..., docs validation, gofmt, and git diff --check
  • P1 autoreview clean

@clawsweeper

clawsweeper Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@clawsweeper clawsweeper Bot added P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 17, 2026
@clawsweeper

clawsweeper Bot commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 17, 2026, 6:38 AM ET / 10:38 UTC.

ClawSweeper review

What this changes

Bounds read-only crabbox claims list claim-file reads to 1 MiB, reports oversized files as claim_too_large, and adds documentation and regression coverage.

Regression provenance

Possible regression — probable (reproduction; reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

This PR remains necessary: current main still reads each local claim file in full, while the proposed bounded inventory reader addresses the linked reliability bug. No actionable patch defect was found; maintainers should confirm the new stable inventory contract before merge.

Priority: P2
Reviewed head: abf766106e63385180008c35778562652a505ff1
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused implementation, extensive boundary/race coverage, and recorded after-fix behavior provide normal good merge-ready evidence, pending the inventory-contract decision.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The PR body supplies after-fix source-blind RSS results for sparse 128 MiB and 1 GiB files, showing fixed-envelope memory behavior alongside the intended CLI result.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body supplies after-fix source-blind RSS results for sparse 128 MiB and 1 GiB files, showing fixed-envelope memory behavior alongside the intended CLI result.
Evidence reviewed 7 items Current-main defect: Current main's read-only snapshot reader calls io.ReadAll(file) after file identity checks, so malformed or valid oversized claim files can still allocate proportionally to file size.
Bounded implementation: The PR rejects known oversized files before allocation and uses a limit-plus-one reader to detect concurrent growth while retaining the existing identity checks.
Regression coverage: Focused tests cover exact-limit acceptance, limit-plus-one rejection, valid partial output, unchanged runtime reads, growing input, sparse files, and no lock creation.
Findings None None.
Security None None.

How this fits together

The claims inventory CLI scans local JSON claim files without contacting providers, then emits human or JSON inventory output. This change sits between local file reads and that output, preserving valid partial results while classifying oversized records.

flowchart LR
A[Local claim files] --> B[Read-only inventory scan]
B --> C{File within 1 MiB?}
C -->|Yes| D[Decode valid claim]
C -->|No| E[Bounded oversized-file problem]
D --> F[Human or JSON inventory]
E --> F
F --> G[Exit status for operators]
Loading

Decision needed

Question Recommendation
Should crabbox claims list adopt a hard 1 MiB per-file inventory limit and expose claim_too_large as a stable problem code? Adopt the proposed inventory contract: Accept the documented 1 MiB limit and claim_too_large result, keeping runtime claim loading unchanged.

Why: The linked bug establishes the need for bounded reads, but its report explicitly leaves the exact threshold and problem-code spelling as product choices, and this changes output for previously valid oversized local state.

Before merge

  • Resolve merge risk (P1) - A pre-existing valid local claim larger than 1 MiB will now be omitted from claims list, reported as claim_too_large, and make the command exit 2; runtime and mutating claim readers remain unchanged.
  • Complete next step (P2) - A maintainer must accept the new stable size-limit and problem-code contract; no narrow repair defect remains for an automated worker.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Implementation and coverage production +23/-1; tests +189/-1; docs/release note +12/-6 Most growth is targeted regression coverage for boundary, growth, partial-output, and read-only invariants.
Inventory bound 1 MiB accepted; 1 MiB + 1 byte rejected The exact inclusive boundary is the new user-visible CLI contract.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #1373
Summary: This PR is the concrete candidate fix for the bounded local-claim inventory read bug tracked by the linked issue.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Adopt the documented cap (recommended)
    Accept the intentional inventory-only compatibility change because runtime and mutation readers retain their existing behavior.
  2. Revise the public contract
    Choose a different size limit or compatibility behavior and align the implementation, docs, and regression tests before merge.

Technical review

Best possible solution:

Adopt the bounded read-only inventory behavior after explicitly accepting the 1 MiB limit and stable oversized-file problem code as the operator-facing contract.

Do we have a high-confidence way to reproduce the issue?

Yes—source-reproducible with high confidence: current main still routes the read-only inventory through io.ReadAll(file), and the linked report provides a sparse-file current-main reproduction with measured RSS growth. This review did not execute the reproduction under the read-only review contract.

Is this the best way to solve the issue?

Yes, subject to maintainer acceptance of the public limit: a pre-read size check plus a limit-plus-one reader preserves the existing race checks while bounding unknown or growing inputs without changing runtime claim loading.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 808764aa25cc.

Labels

Label justifications:

  • P2: This fixes bounded-memory behavior for a local diagnostic command with limited blast radius.
  • merge-risk: 🚨 compatibility: The new hard limit intentionally changes claims list output and exit behavior for existing valid claim files above 1 MiB.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body supplies after-fix source-blind RSS results for sparse 128 MiB and 1 GiB files, showing fixed-envelope memory behavior alongside the intended CLI result.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body supplies after-fix source-blind RSS results for sparse 128 MiB and 1 GiB files, showing fixed-envelope memory behavior alongside the intended CLI result.

Evidence

What I checked:

  • Current-main defect: Current main's read-only snapshot reader calls io.ReadAll(file) after file identity checks, so malformed or valid oversized claim files can still allocate proportionally to file size. (internal/cli/claim.go:2013, 808764aa25cc)
  • Bounded implementation: The PR rejects known oversized files before allocation and uses a limit-plus-one reader to detect concurrent growth while retaining the existing identity checks. (internal/cli/claim.go:2014, abf766106e63)
  • Regression coverage: Focused tests cover exact-limit acceptance, limit-plus-one rejection, valid partial output, unchanged runtime reads, growing input, sparse files, and no lock creation. (internal/cli/claims_test.go:143, abf766106e63)
  • Documented contract: The command documentation describes the read-only 1 MiB limit, stable claim_too_large problem code, and unchanged runtime loader. (docs/commands/claims.md:53, abf766106e63)
  • Feature provenance: The current inventory behavior dates to the local claim inventory feature commit, which introduced the affected reader path. (internal/cli/claim.go:1995, 3251e056596f)
  • Real behavior evidence: The PR body records source-blind after-fix RSS measurements for empty, 128 MiB sparse, and 1 GiB sparse inputs, alongside bounded partial-output behavior. (abf766106e63)

Likely related people:

  • steipete: Introduced the current-main local claim inventory and is the dominant recent contributor across the affected claim reader and CLI paths. (role: feature introducer and recent area contributor; confidence: high; commits: 3251e056596f, f39dd170f403; files: internal/cli/claim.go, internal/cli/claims.go, internal/cli/claims_test.go)
  • coygeek: History shows repeated changes to claim-file behavior across provider implementations; the linked report also supplies the concrete reproduction and expected bounded behavior. (role: longstanding adjacent claim-file contributor; confidence: medium; commits: d6d4634eab1e, b2d058605239; files: internal/cli/claim.go, internal/cli/claims_test.go)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Confirm the 1 MiB limit and claim_too_large code as the intended stable inventory contract.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-08-17T04:45:05.373Z sha c8a6bea :: needs maintainer review before merge. :: none

Reject local claim inventory files above the inclusive 1 MiB limit while preserving bounded partial output and the existing runtime reader.

Refs #1373

Co-authored-by: Coy Geek <[email protected]>
@steipete
steipete force-pushed the steipete/fix-1373-claim-size branch from c8a6bea to abf7661 Compare August 17, 2026 10:34
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. label Aug 17, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Maintainer decision: adopt the inclusive 1 MiB per-file limit and stable claim_too_large problem code for the read-only crabbox claims list inventory contract. Runtime and mutating claim readers remain unchanged; bounding diagnostic memory use is the correct tradeoff for oversized local records. The Unreleased changelog entry remains because repository policy requires coverage for user-visible changes.

@steipete
steipete merged commit 8296793 into main Aug 17, 2026
24 checks passed
@steipete
steipete deleted the steipete/fix-1373-claim-size branch August 17, 2026 10:57
steipete added a commit to openclaw/clawsweeper that referenced this pull request Aug 17, 2026
…1188)

Production diagnostics from openclaw/crabbox#1380 showed xvfb-run guarding
the display with an xauth cookie, refusing the readiness probe and ffmpeg
recorder outside its wrapper. The driver now starts Xvfb :99 directly
(local-only, no TCP listener) with xterm in its own session pointed at the
display, and the workflow installs xfonts-base so xterm's default bitmap
font exists on hosted runners.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(claims): bound malformed claim file reads

1 participant