Skip to content

Send the sweep strip as a bitmap rather than a list of positions - #365

Merged
ahernsean merged 2 commits into
mainfrom
claude/bitmap-sweep-strip-v2
Sep 20, 2026
Merged

ahernsean merged 2 commits into
mainfrom
claude/bitmap-sweep-strip-v2

Conversation

@ahernsean

Copy link
Copy Markdown
Owner

Summary

A branch's sweep strip — which candidates have been evaluated — was serialized as completed_candidate_indexes, one JSON integer per swept candidate. Its cost therefore grew with the swept fraction of the vocabulary, so the payload was smallest when a branch was least interesting and largest when it was nearly done.

completed_candidate_bitmap replaces it: one bit per candidate, base64-encoded, sized by the vocabulary rather than by progress. At 14,855 candidates that is a flat 2,476 bytes per branch regardless of how far the sweep has reached. Measured on the production overview, the whole report went from 412,016 bytes to 34,917.

Run-length encoding was considered first and rejected on measurement: six workers claim scattered ranges, so runs are short, and on the worst live branch an RLE strip was still 64.7% of the raw list. A bitset has no fragmented case to degrade into.

The strip keeps full per-position resolution rather than being pre-aggregated into buckets, because the two renderers disagree on resolution — the browser draws up to 50 cells, the terminal 10 to 40 — so any fixed bucketing would be lossy for one of them.

Changes:

  • report_model.encode_candidate_bitmap / decode_candidate_bitmap, with both emission sites rewired (overview branch rows, branch report).
  • report_client.html decodes with atob and tests done[index>>3] & (1<<(index&7)) in place, instead of building a Set of every swept position on each redraw.
  • report_terminal.py decodes at its call site.
  • SCHEMA_VERSION 3 → 4 in both the model and the client. The key is new and the old one is gone, so a client from before this change must not read the payload as though the strip were simply empty.
  • All 16 report fixtures regenerated at schema 4.

Five codec tests cover round-tripping, the empty set, out-of-range positions, and a corrupt bitmap. Each was proven to fail against a deliberate break: bounds check removed, bitmap sized by highest index rather than by vocabulary, and corruption tolerance removed.

🤖 Generated with Claude Code

https://claude.ai/code/session_01PpacbZRqT46b4Duhxq5QNQ

A branch's completed-candidate set was serialized as one JSON integer per
swept candidate, so the overview's cost grew with the swept fraction of the
vocabulary rather than with the vocabulary. One bit per candidate makes the
cost constant: 2,476 bytes per branch at 14,855 candidates, whatever the
sweep has reached. Measured on the production overview, 412,016 bytes to
34,917.

Both renderers decode it. The client tests bits in place instead of
building a Set of every swept position on each redraw.

SCHEMA_VERSION goes to 4: the key is new and the old one is gone, so a
client from before this change must not read the payload as if the strip
were simply empty.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PpacbZRqT46b4Duhxq5QNQ

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 27dff10891

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread report_client.html
The browser tests set the sweep strip on a report payload from inside the
page, so they construct the wire format by hand rather than reading a
fixture file.  Six such sites still wrote a list of positions, which the
client no longer reads, and a strip that decodes to nothing renders as a
strip nobody has swept.

`SWEEP_BITMAP_JS` builds the bitset once and every site calls it, so a
test states the two numbers the format needs -- how many candidates the
branch holds, and how many of them are swept -- rather than restating the
packing.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PpacbZRqT46b4Duhxq5QNQ
@ahernsean

Copy link
Copy Markdown
Owner Author

@codex review again

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: 240a6b3d00

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ahernsean
ahernsean merged commit 807fc0a into main Sep 20, 2026
8 checks passed
@ahernsean
ahernsean deleted the claude/bitmap-sweep-strip-v2 branch September 20, 2026 14:14
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