Skip to content

fix(harden): cap the run summary at the ceiling its own reader enforces - #362

Open
DeryFerd wants to merge 1 commit into
qybaihe:mainfrom
DeryFerd:fix/harden-summary-write-cap
Open

DeryFerd wants to merge 1 commit into
qybaihe:mainfrom
DeryFerd:fix/harden-summary-write-cap

Conversation

@DeryFerd

@DeryFerd DeryFerd commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

hardenProject serialises bla-harden-summary.json and writes it whole, while readHardenRunSummary refuses to read a summary above MAX_HARDEN_SUMMARY_BYTES (8 MiB). The two halves of the same feature disagreed about what a valid summary is: a large enough tree produced a file that BLA's own bla_run_lookup and the run-evidence path would reject, so the run that wrote it looked like it had no summary at all.

What changed

  • src/engine/run-evidence.ts gains serializeHardenSummary, which serialises the payload and returns json: null once the UTF-8 byte length crosses MAX_HARDEN_SUMMARY_BYTES, reporting the measured size and the ceiling either way. This is the same constant the reader already enforces, so writer and reader now share one source of truth.
  • hardenProject routes its summary through the helper. When the ceiling would be crossed it records the existing summaryWriteFailure with the size and the ceiling instead of writing a summary the reader would then refuse (src/engine/harden.ts).
  • tests/harden-summary-write-cap.test.ts pins both directions: a small summary serialises as indented JSON with a real byte count, and an oversized one comes back as json: null.

Why this matters

The summary is documented as BLA-authored metadata that a later pass reads back. Writing one the reader will reject is a silent dead end; failing the write honestly, with the size in the message, tells the caller exactly what happened and keeps the report truthful.

Tests

  • npx vitest run tests/harden-summary-write-cap.test.ts tests/run-evidence.test.ts tests/run-evidence-bounded.test.ts tests/harden-seed-location.test.ts tests/harden-progress-cancel.test.ts passes, 16 tests.
  • npx vitest run tests/hardening-engine.test.ts passes, 15 tests.

Compatibility

A summary that fits is byte-identical to before, because the serialisation is the same JSON.stringify(payload, null, 2). Only a summary that would exceed 8 MiB changes behaviour, and it now fails closed with a named reason rather than writing a file the reader would never accept.

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