Skip to content

[v0.17 CAP-1c] Text lanes bound files by a compile-time constant, not the active source policy #1823

Description

@TheGreenCedar

Found by adversarial review of #1821, and confirmed against the tree.

The gap

The indexer admits a file by self.source_file_byte_cap, taken from
SourceIndexPolicy.byte_cap, which source_index_policy_from_env_value
(codestory-cli/src/config.rs:73-78) sets from
CODESTORY_INDEX_SOURCE_FILE_BYTE_CAP with no upper clamp — only > 0.

Three per-file text bounds are compile-time constants:

Lane Constant Checked at
lexical FTS MAX_FILE_BYTES codestory-retrieval/src/lexical_index.rs:970
repo-text scan REPO_TEXT_MAX_FILE_BYTES codestory-runtime/src/repo_text.rs:90,109
semantic doc bodies SEMANTIC_FILE_TEXT_MAX_BYTES codestory-runtime/src/support.rs:389

Set CODESTORY_INDEX_SOURCE_FILE_BYTE_CAP=4000000 and a 3 MB Rust file is
indexed with full symbols, nodes, and dense anchors, while all three lanes drop
it. There is no error row and no retry_required; derive_degraded_mode
discards the component reason and strict readiness still reports Full. The
user gets a file indexed_files calls complete that search cannot find.

What #1821 did and did not do

#1821 made the three constants derive from DEFAULT_SOURCE_FILE_BYTE_CAP and
added a compile-time assertion to each. That closes the default configuration
and stops a future default bump from silently stranding a band of files — which
is what would have happened when the cap went to 2 MB.

It does not close this, and the assertions cannot: they compare two
compile-time constants and are blind to a runtime override. code-review-2026-08.md
has been corrected to say so rather than retiring CR-068's oversized half.

Done when

  • The three lanes bound files by the active SourceIndexPolicy, not by a
    constant
  • A test sets CODESTORY_INDEX_SOURCE_FILE_BYTE_CAP above the default,
    indexes a file in the widened band, and asserts it is lexically
    recallable
    — a constant-comparison assertion is not sufficient, because
    it passes when a lane is bounded by something nobody listed
  • Or, if plumbing is rejected: the env override is clamped to the lane
    bound, and the setting's registry description says the cap cannot be
    raised past it

Note

This is a pre-existing gap — CR-068 described it before #1821 — but it is worth
its own issue now because the surrounding claim changed and the residual would
otherwise be invisible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions