Skip to content

CLAUDE.md: record the write/read rule this header already states in its own docs - #24

Merged
rowan-claude merged 1 commit into
mainfrom
docs/write-read-rule
Jul 26, 2026
Merged

CLAUDE.md: record the write/read rule this header already states in its own docs#24
rowan-claude merged 1 commit into
mainfrom
docs/write-read-rule

Conversation

@rowan-claude

Copy link
Copy Markdown
Contributor

serialize.h says it at :870, :918 and :933 — "All checking is performed by debug asserts on write." That is the contract. I audited this header, quoted that exact line in my own notes, and filed the write path as a defect anyway. Recording it so the next pass doesn't.

Two things worth keeping from the audit:

  1. The bytes % 8 contract is genuinely load-bearing. A 100-byte buffer written to exactly capacity — within capacity, violating no assert even in debug — flushes 8 bytes at offset 96, four past the end. Proved with a canary. Still caller responsibility, which is why yojimbo masks its packet size deliberately (yojimbo_connection.cpp:248).
  2. ASan does not report that overflow. It's a partial-granule write and ASan is blind to it — an identical raw memcpy is also unreported. I nearly recorded "no ASan report" as evidence of safety. Anyone doing sanitizer work in this header needs a canary region instead.

The read path is confirmed clean by two independent audits, with the specific companion check for every BitReader assert cited.

Docs only, no code change.

🤖 Generated with Claude Code

serialize.h says it at :870, :918 and :933 -- 'All checking is performed by debug
asserts on write.' I audited this header, quoted that line in my own notes, and
filed the write path as a defect anyway. Recording it so the next pass does not.

Also records two things worth keeping. The BitWriter bytes%8 contract really is
load-bearing -- a 100-byte buffer written to exactly capacity flushes four bytes past
the end, proved with a canary -- and it is still caller responsibility, which is why
yojimbo masks its packet size deliberately.

And a warning about the tool: ASan does NOT report that overflow. It is a
partial-granule write and ASan is blind to it; an identical raw memcpy is also
unreported. I nearly recorded 'no ASan report' as evidence of safety here.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@rowan-claude
rowan-claude merged commit 19d332e into main Jul 26, 2026
13 checks passed
@rowan-claude
rowan-claude deleted the docs/write-read-rule branch July 26, 2026 21:18
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