Skip to content

[v0.17 CAP-1] Oversized-source exclusions never reach the evidence surface #1802

Description

@TheGreenCedar

Context

DEFAULT_SOURCE_FILE_BYTE_CAP is 1,000,000 bytes (crates/codestory-contracts/src/workspace.rs:7). Any source above it is excluded from indexing as an OversizedSourceExclusionCandidate and published as a policy-exclusion generation.

That exclusion never reaches the evidence surface. FileCoverageReason::Oversized exists and has a message ("source exceeds the configured indexing size limit", index_coverage.rs:90) and a code (source_oversized, :368) — but no production path constructs one. The only construction in the tree is a test fixture (services.rs:4688). Grepping crates/codestory-runtime/src/agent/ for exclusion returns nothing: the packet layer has no knowledge of excluded files at all.

So on a repository containing a 1.2 MB source file, that file is never read, and a packet answering a question about it can still report sufficient with no gap, no typed cause, and nothing in the CLI or MCP surface telling the user a file was skipped. The exclusion is durably recorded in the store and invisible to the answer.

This is the release's own thesis inverted. Milestone 14 states: "CodeStory stops overstating its evidence: a sufficient packet now means every claim is proven." An unread file that no verdict mentions is an unproven claim by construction.

Why the cap value is the smaller half of this

1 MB is low for real codebases — generated clients, lockfile-adjacent sources, vendored single-file libraries and large hand-written modules routinely exceed it. (This very repository hit it: codestory-indexer/src/lib.rs reached 987 KB, see #1801.) The cap is env-configurable via SourceIndexPolicy, so a user can raise it — but only if they know a file was skipped, which today they do not.

Raising the number narrows the window. Surfacing the exclusion closes the honesty gap at any cap.

Contract

  • An oversized exclusion produces a typed FileCoverageReason::Oversized gap on the packet coverage surface, and caps sufficiency the way other unproven-coverage causes do.
  • Status/doctor name skipped files and the cap that skipped them, so raising the cap is an informed choice rather than a guess.
  • The default cap is re-derived from evidence about real repository file-size distributions rather than left at a round number, and the rationale is recorded.

Done when

  • A repository with a file above the cap cannot produce a sufficient packet that depends on that file without a typed oversized gap, proven by a test that fails without the change.

Refs #1801. Refs #1179.

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority:p1Release blocker or high-risk reliability/security issuetype:contractRuntime, CLI, API, or evidence contract work

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions