Skip to content

fix(clones): bound body bytes before tokenizing large literals - #1784

Merged
ScriptedAlchemy merged 1 commit into
masterfrom
fix/clone-body-dual-bound
Sep 18, 2026
Merged

ScriptedAlchemy merged 1 commit into
masterfrom
fix/clone-body-dual-bound

Conversation

@ScriptedAlchemy

Copy link
Copy Markdown
Owner

Live regression after the token-only cut

With the cgroup and flexible builder fixes installed, the fresh generation finally reached the real deterministic blocker:

contract violation: one admitted clone body exceeds the page byte bound

The 4,096-token guard does not bound serialized bytes: one multi-megabyte string/raw literal is one syntax token. #1577 is the only open PR touching clone_body.rs; it optimizes token deserialization and predates even the token bound, so it does not solve this.

Fix

  • Restore a 64 KiB source byte guard before tokenization, alongside the 4,096 non-trivia-token guard after tokenization.
  • Either limit yields ExcludedTooLarge, drops conservative/rename streams, and carries both maximum_tokens and maximum_bytes through MCP/dashboard contracts.
  • Byte-precluded bodies truthfully report partial tokenization with BodyExceedsSizeBound and count 0; no giant literal is copied merely to count it.
  • Dashboard wording states the disjunctive 4,096-token / 65,536-byte exclusion.
  • Regenerate dashboard and TypeScript SDK contracts.
  • Move every extractor revision again (Rust v10, TS/protobuf/SQL v6, others v5), in the same cut, so already sealed token-only artifacts are re-extracted rather than parking forever.

Behavioral evidence

  • New Rust body with a >64 KiB one-token literal is excluded before tokenization with empty streams.
  • Existing over-token and under-both-bounds behaviors remain pinned.
  • Clone-body extraction tests: 10/10.
  • Code-index library: 256/256.
  • Stale extractor generation rebuild: 1/1.
  • Production CLI check passes.
  • Dashboard typecheck, coverage wording test 6/6, contract generator/check pass.
  • SDK generation is idempotent.
  • IDE lints and rustfmt clean.

The 4,096-token exclusion still admitted a body containing one multi-megabyte literal because the literal is a single token. That record again exceeded the 4 MiB text page and parked graph seating. Enforce the original 64 KiB source-byte guard before tokenization alongside the token guard; carry both limits through contracts and UI, and retain no token streams for either exclusion. Move every extractor revision in the same cut so old poisoned artifacts are re-extracted.
@changeset-bot

changeset-bot Bot commented Sep 18, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 941d908

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@ScriptedAlchemy
ScriptedAlchemy merged commit 542d28c into master Sep 18, 2026
1 check passed
ScriptedAlchemy added a commit that referenced this pull request Sep 18, 2026
The packaged query-fallback receipts drifted once every extractor revision
moved for the clone-body bound: c7eb62e (PR #1741) took Rust v8 to v9,
TypeScript/protobuf/SQL v4 to v5 and the rest v3 to v4, and 542d28c
(PR #1784) took Rust to v10. The extractor revision is part of the
extraction batch identity, so the sealed generation every candidate
binding names moves with it, and the fallback subpayload digest hashes
those bindings. Bisecting the packaged comparison over the range since the
last re-pin (3320ad4) lands on c7eb62e, whose only production change
is those three revision integers.

The ranking did not change. Comparing the packaged report at 3320ad4
against the current tip, every per-query row is byte identical: same first
useful rank, returned candidates, wrong-scope and forbidden hits, and
quality. Both partitions keep their exact conceptual-miss sets (10 train,
7 validation) and their mean reciprocal rank (476881 ppm train, 587222 ppm
validation). Only the provenance identity inside the receipt moved.

Re-pin both partition receipts, packaged::WORKLOAD_SHA256, and the
byte-pinned workload digest both search-eval bins assert.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
cursor Bot pushed a commit that referenced this pull request Sep 18, 2026
The packaged query-fallback receipts drifted once every extractor revision
moved for the clone-body bound: c7eb62e (PR #1741) took Rust v8 to v9,
TypeScript/protobuf/SQL v4 to v5 and the rest v3 to v4, and 542d28c
(PR #1784) took Rust to v10. The extractor revision is part of the
extraction batch identity, so the sealed generation every candidate
binding names moves with it, and the fallback subpayload digest hashes
those bindings. Bisecting the packaged comparison over the range since the
last re-pin (3320ad4) lands on c7eb62e, whose only production change
is those three revision integers.

The ranking did not change. Comparing the packaged report at 3320ad4
against the current tip, every per-query row is byte identical: same first
useful rank, returned candidates, wrong-scope and forbidden hits, and
quality. Both partitions keep their exact conceptual-miss sets (10 train,
7 validation) and their mean reciprocal rank (476881 ppm train, 587222 ppm
validation). Only the provenance identity inside the receipt moved.

Re-pin both partition receipts, packaged::WORKLOAD_SHA256, and the
byte-pinned workload digest both search-eval bins assert.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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