Skip to content

BAD CODE™: stream machine-local path scans with bounded memory #840

Description

@flyingrobots

Classification

BAD CODE™ — bounded-memory tooling debt discovered while hardening #838.

Problem

GitMachineLocalPathGuard.findTreePaths() sends every unique tree blob to one git cat-file --batch process and materializes the complete response in one buffer. MAX_INSPECTED_BLOB_BYTES caps that aggregate response at 512 MiB.

The guard fails closed, which is correct, but its memory and success envelope scale with the total bytes in the committed tree. A clean tree can therefore be rejected solely because the aggregate batch crosses the fixed ceiling. That is inconsistent with the repository direction toward streaming and bounded materialization.

Required correction

  • Consume git cat-file --batch incrementally or inspect deterministic bounded object batches.
  • Bound memory independently of total committed-tree size.
  • Preserve exact object identity, binary-blob inspection, symlink-target inspection, and deterministic offender ordering.
  • Detect policy tokens that cross internal read-chunk boundaries.
  • Continue to fail closed on malformed or truncated Git output.
  • Never print matching content; report only safe repo-relative paths or object identifiers.

Acceptance

  • A test forces a deliberately small inspection window and proves a clean aggregate larger than that window completes.
  • A test detects a forbidden token split across internal chunks.
  • Malformed and truncated batch streams remain hard failures.
  • Existing working-tree, staged-index, outgoing-object, and exact-tree guard tests pass.

Related: #838.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:testingPrimary work area: testing.area:toolingPrimary work area: tooling.priority:nextNext in line after active work.status:availableOpen and available for prioritization; not blocked or actively in progress.type:bugDefect or incorrect behavior.type:debtDebt, rot, or structural risk.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions