Skip to content

fix(pr): stop spilling captured review evidence to disk - #201775

Merged
steipete merged 2 commits into
mainfrom
steipete/perf-2663-captured-hash-pipe
Nov 19, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/perf-2663-captured-hash-pipe

Conversation

@steipete

@steipete steipete commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Preparing and recovering a PR with retained baseline evidence can write gigabytes of temporary data just to verify evidence hashes. Each correction validation spills captured buffers to disk, and replacement recovery repeats that validation several times.

User Impact

Maintainer PR operations stop writing captured evidence to temporary files. In a synthetic 62,000-file repository, Linux/Btrfs storage writes fell 81% per successor validation (333 MB to 64 MB). No user configuration, migration, or public behavior changes.

Why This Change Was Made

baseline-refresh.mjs now supplies its already-captured buffer directly to git hash-object --no-filters --stdin using synchronous piped input. Git never reopens an authority pathname. This deletes the temporary directory, exclusive writer, reopened descriptor, unlink, and cleanup machinery (production LOC: −24).

The captured-bytes invariant is unchanged. readRegular still owns no-follow capture and concurrent-change checks; Git still owns the object ID and conditional -w object write. Signature verification, expected head/tree/review bindings, merge-base ancestry, retained evidence comparisons, operation/lifetime locks, sweep behavior, and all validation calls are unchanged. No cache or memoization is added. The repeated validator calls run in separate processes; sharing results across them would require state beyond one invocation and additional authority semantics.

Earlier #173899 and #186821 used file descriptors after reported stdin stalls, without reproducing the underlying pipe failure. This change explicitly exercises binary/newline-sensitive inputs, post-capture pathname mutation, Git/spawn failures, written Git blobs, and large native validation on macOS Node 26 and Linux Node 24. It does not claim to identify the cause of those historical stalls.

The pipe trades disk I/O for memory transport. Warm validator latency was about 6% higher on Linux in this sample and essentially flat on macOS; peak RSS stayed within 1%. This is a storage-write fix, not a claim of a general latency improvement. Temporary Git index writes remain.

Evidence

The 32 MiB no-spool regression fails on the parent with EFBIG under a 1 KiB file-size limit and passes with the fix. The existing full correction-validator integration case now rejects any temporary hash snapshot creation; this also fails on the exact parent and passes in about eight seconds. The opt-in workload uses the real signed baseline/preparation/publication owners, two changed product files, 62,000 synthetic 18 KB files (1.116 GB), and a 128 MiB retained build log across two archives. It compares every hash and the complete validation decision against the parent.

Acceptance: zero hash-snapshot bytes, identical object IDs and decisions, and materially fewer kernel storage writes. Baseline controls and five alternating warm base/candidate pairs passed on both platforms.

Warm per-validation metric Parent Candidate
Captured hash calls / bytes 31 / 268,457,912 identical
Temporary hash files / bytes 31 / 268,457,912 0 / 0
Btrfs write_bytes, median 332,529,664 63,975,424
Btrfs wchar, median 361,887,378 361,887,386
Linux owner wall time, median / p95 1,169 / 1,695 ms 1,236 / 1,575 ms
Linux process-tree CPU, median 1.322 s 1.396 s
Linux peak RSS, median 460.3 MiB 460.9 MiB
macOS owner wall time, median / p95 1,770 / 1,817 ms 1,749 / 1,763 ms
macOS process-tree CPU, median 3.503 s 3.750 s
macOS peak RSS, median 480.7 MiB 480.9 MiB
Captured-read buffer allocation volume 268,462,698 bytes identical

wchar includes pipe traffic, so it deliberately does not establish the storage improvement. Btrfs cancelled writes were zero. The removed 268.6 MB of kernel writes closely matches the 268.5 MB of hash snapshots; roughly 64 MB of remaining writes include temporary Git indexes. CPU/allocation profiles were collected separately from timing samples; the base's snapshot writeBuffer samples disappear.

The existing replacement-recovery fixture counted seven validate children plus one local preflight (initial attempt: six plus preflight). At this workload, eight passes avoid approximately 2.15 GB of snapshots. Repeated authority checks remain intact.

Focused snapshot/baseline tests: 32 passed. Both no-spill regressions fail on the exact parent and pass with the fix. Production-shaped differential validation passed on macOS/APFS and Linux/Btrfs. Two isolated Codex autoreviews found no actionable P0–P2 findings. Final pnpm check:changed --base 82b682c627ba8 passed.

Exact-head CI is green: run 44512184419, attempt 2, head 03a9a1d827fb1ebac718ca49f2fe2364c8e13d82. Attempt 1 passed every executed test shard; one shard failed before tests because an Ubuntu package-mirror index had the wrong size. One diagnosed infrastructure retry passed. No code-red rerun or admin exception.

The broad local scripts/pr run completed: 89 files (81 passed, 7 failed, 1 skipped); 2,454 tests passed, 11 failed, 30 skipped. Two earlier passing files (32 tests) were reused. Its failures remain recorded:

  • Two prior-CI REST cases missed the expected admin-refusal message without dispatching. Exact-parent targeted replay, complete original-order parent replay (59 tests), and final-head targeted replay pass. The original refusals remain unexplained; passing replays are not a fix.
  • Eight unchanged native lifecycle/provisioning cases exceeded the existing 120-second local limit. Seven reproduce as timeouts on the exact parent; the remaining case passes there in 109 seconds. All eight pass their semantic assertions on the final head with an explicit 600-second diagnostic limit. No committed timeout or assertion changed; no inherited-CI waiver is claimed.
  • The offline native-GH fixture passed after selecting its required native CLI for that fixture only. Real GitHub/landing operations retain the normal protected transport.

Native review preserves tests.result=fail and all investigated local failures. ClawSweeper reviewed final head 03a9a1d827fb1ebac718ca49f2fe2364c8e13d82 with zero findings/open items (review). The local timing failures need follow-up even though exact-head CI is green; their causal introducer is not established. Landing uses the ordinary exact-head native route, without an admin or inherited-failure exception.

Existing retained workflow bindings continue to execute their pinned implementation. Normal reviewed workflow succession or new bindings adopt this change; no trust anchors are rewritten.

Reproduce the synthetic differential workload
OPENCLAW_PR_HASH_MEASURE=/absolute/new-directory \
OPENCLAW_PR_HASH_BASE=82b682c627ba8 \
node scripts/run-vitest.mjs test/scripts/pr-baseline-hash-measure.test.ts \
  --testTimeout 900000

The directory retains only synthetic fixture/evidence and a generated measure.py for replay on the same absolute paths. The production-scale measurement is opt-in; routine no-spill assertions reuse existing owner tests without adding another full native preparation workflow. Benchmark controls separate initial cold execution from warm alternating samples. No production databases or workspaces are copied.

The additional test code provides the full validator regression and reproducible measurement; normal runtime code shrinks. Open #199006 also touches the owner but changes workflow-equivalence admission, not this transport.

@clawsweeper

clawsweeper Bot commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation scripts Repository scripts size: M labels Nov 19, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper review

Please review the captured-byte stdin transport and its security invariant. The PR includes differential validation on macOS and Linux, and preserves all authority, ancestry, signature, lock, and replay checks.

@clawsweeper

clawsweeper Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 19, 2026
@clawsweeper

clawsweeper Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR sends captured evidence buffers directly to Git instead of writing temporary hash snapshots.

Example: Validate retained baseline evidence containing 268,457,912 captured bytes.

  • Before: Hashing writes 31 temporary snapshots totaling 268,457,912 bytes.
  • After: Hashing creates no temporary snapshots and preserves the reported object IDs and validation decision.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A focused, correct simplification with green exact-head CI; supporting behavior evidence comes from synthetic production-owner fixtures rather than an independently inspected operational trace.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored internal tooling change requires no application-facing demonstration; supplied synthetic macOS/Linux runs exercise the real validation owner and Git, with reported identical hashes and decisions.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: Maintainer preparation and recovery repeatedly write large captured evidence buffers to temporary storage solely to compute hashes.
Reason: The maintainer-authored direction accepts the measured latency tradeoff for substantially fewer storage writes, with no new state owner or configuration.

Merge readiness

✅ Ready for maintainer review

No introduced correctness or security defect was found. This maintainer-authored PR provides a measured storage-write reduction and has green exact-head CI; the author’s explicit local-validation hold remains.

Priority: P2
Reviewed head: 03a9a1d827fb1ebac718ca49f2fe2364c8e13d82

Before merge

None.

Findings

None.

Agent review details

How this fits together

Native PR preparation and correction validation capture evidence bytes, compute Git object IDs, and use those identities when reconstructing signed candidates and checking retained review evidence.

flowchart LR
A[Retained evidence] --> B[Regular file capture]
B --> C[Captured buffer]
C --> D[Git stdin pipe]
D --> E[Git object identity]
E --> F[Correction validation]
Loading

Technical review

Best possible solution:

Use the existing hash owner’s direct buffer transport while preserving exact bytes, Git object semantics, and all existing validation boundaries.

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

Current-main source writes every captured hash buffer to a temporary snapshot, directly establishing the storage-write path; supplied parent/head results report matching regression failures and passes, but no target code was executed during this review.

Is this the best way to solve the issue?

The change is the smallest complete repair within the existing owner: remove redundant disk transport, retain Git hashing and writes, and reuse existing correctness tests plus an opt-in measurement workload.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 18b04f2fd591.

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Focused production change: The pinned introduction replaces temporary snapshot creation and descriptor cleanup with execFileSync input while retaining --no-filters and conditional -w. (scripts/pr-lib/baseline-refresh.mjs:36, 03a9a1d827fb)
  • Captured-byte boundary preserved: readRegular still opens with O_NOFOLLOW, captures bytes from the descriptor, checks concurrent changes, and closes the descriptor; the changed hash owner consumes that buffer without reopening its pathname. (scripts/pr-lib/preparation-state.mjs:21, 03a9a1d827fb)
  • Current main still spills snapshots: Fetched main retains the temporary-file implementation, so the central storage improvement is not already implemented there. (scripts/pr-lib/baseline-refresh.mjs:37, 18b04f2fd591)
  • Distinct regression coverage: Coverage includes a 32 MiB input under a 1 KiB file-size limit, exact binary and newline-sensitive hashes, post-capture pathname mutation, Git failures, stored blob bytes, and correction validation using the existing fixture. (test/scripts/pr-baseline-snapshot-hash.test.ts:88, 03a9a1d827fb)
  • Measured and accepted tradeoff: The maintainer-authored body reports alternating macOS/APFS and Linux/Btrfs differential validation, identical hashes and decisions, and an 81% Linux storage-write reduction; it explicitly accepts slightly higher Linux latency and does not claim to explain the historical pipe stalls. (03a9a1d827fb)
  • Exact-head CI: CI run 44512184419 attempt 2 completed successfully for the reviewed head, and dependency-review, security-sensitive-review, and ci-gate commit statuses are successful. (03a9a1d827fb)

Likely related people:

  • Vincent Koc: Raw commit da63d5f adds scripts/pr-lib/baseline-refresh.mjs:18 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: da63d5f71f9c; files: scripts/pr-lib/baseline-refresh.mjs)
  • Peter Steinberger: Raw commit 054fd97 adds docs/reference/scripts/pr-tooling.md:52 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 054fd9788bc0; files: docs/reference/scripts/pr-tooling.md)

PR surface

Tests +173, Docs -5, Other -24. Total +144 across 7 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 5 185 12 +173
Docs 1 5 10 -5
Config 0 0 0 0
Generated 0 0 0 0
Other 1 8 32 -24
Total 7 198 54 +144

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
Production versus test/support delta Production +8/-32; tests/support +185/-12. Production removes the snapshot lifecycle; test growth supplies an opt-in differential workload and extends existing boundary regressions.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: The change addresses substantial repeated storage writes in maintainer tooling without an established urgent application-runtime failure.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-11-19T11:01:06.475Z sha 44246ee :: needs maintainer review before merge. :: none

Reviewed November 19, 2026, 7:10 AM ET / 12:10 UTC (Revision 2).

@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The previous review had no open items. The new head consolidates the no-spill assertion into the existing correction-validator integration case (green in 8 seconds, red on the exact parent), and keeps the production-scale benchmark opt-in. Production code is unchanged. Please review the final head.

@clawsweeper

clawsweeper Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@steipete
steipete marked this pull request as ready for review November 19, 2026 11:09
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-19T11:11:07.741505Z 03a9a1d 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.

@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The previous final-head request completed as superseded (run 44512201663), but the durable report still names 44246ee. Please review current head 03a9a1d. The older report has zero open items; production code is unchanged, and the regression was consolidated into the existing validator fixture.

@clawsweeper

clawsweeper Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper explain

Two requests to review head 03a9a1d completed as superseded by a newer review tuple (runs 44512201663 and 44513944268), but the durable review comment still names 44246ee. Please identify the current review/publication state and the supported recovery for this mismatch. No merge has been submitted.

@clawsweeper

clawsweeper Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

ClawSweeper status:

  • Current PR: 201775
  • Branch: steipete/perf-2663-captured-hash-pipe
  • Checks: SUCCESS:50 SKIPPED:52 FAILURE:1 IN_PROGRESS:1 PENDING:1 NEUTRAL:1
  • Check blockers: checks-node-compact-small-1-1:FAILURE, checks-node-compact-small-3:IN_PROGRESS, openclaw/ci-gate:PENDING

@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Please review head 03a9a1d with the updated evidence. Exact-head CI is green (44512184419, attempt 2); investigated local failures and passing diagnostic replays are documented in the body. The previous report had zero open items. Production code is unchanged since that report; the no-spill regression now reuses the existing validator fixture.

The earlier superseded requests overlapped readiness/body updates. This request follows the completed body update; I will leave those inputs unchanged while the review runs. No merge has been submitted.

@clawsweeper

clawsweeper Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@steipete
steipete merged commit 894a15d into main Nov 19, 2026
256 of 261 checks passed
@steipete
steipete deleted the steipete/perf-2663-captured-hash-pipe branch November 19, 2026 12:48
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 20, 2026
)

* fix(pr): stop spilling captured review evidence to disk

* test(pr): reuse the validator fixture for no-spill regression
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: M 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.

1 participant