Skip to content

Bound indexing resource usage with configurable limits #1347

Open

Description

@liuchong

Problem

An accidental index_repository request against an aggregate workspace or unexpectedly large tree can consume unbounded CPU, memory, temporary storage, and database space. Discovery currently has no unified admission policy shared with supervised workers and persistence.

Proposed behavior

Resolve one immutable resource policy per ordinary indexing request and enforce it across:

  • repository-root admission and bounded discovery (files, directories, entries, depth, source bytes, per-file bytes, scan deadline)
  • worker execution (CPU worker count, physical concurrency, resident memory, lower priority, wall-clock duration)
  • persistence (database, staging, task temporary output, cache admission, reserved free disk)
  • structured resource_limit_exceeded responses that preserve the last published database

Built-in exact denied roots would include the filesystem root, current user home, and the index cache. Operators could add exact aggregate roots with index_denied_roots; descendants would remain indexable.

cross-repo-intelligence would retain its existing database-linking path because it does not walk source files.

Proposed defaults

The prototype uses conservative finite defaults: 100k files, 20k directories, 500k entries, depth 64, 4 GiB accepted source, 64 MiB per file, 30-second discovery, 4 worker threads, one physical job, 8 GiB memory (also clamped to detected budget), 16 GiB database, 20 GiB staging, 24 GiB task temp, 32 GiB cache admission, 4 GiB free-disk reserve, and one-hour duration.

Prototype

A complete C implementation with tests and documentation is available for design review:

https://github.com/liuchong/codebase-memory-mcp/tree/fix/index-resource-guards

Focused ASan/UBSan suites: 640 passed, 3 platform skips. make -f Makefile.cbm lint-ci passes.

Design questions

  1. Is a unified index_* configuration namespace acceptable?
  2. Are the proposed built-in denied roots and defaults appropriate?
  3. Should the implementation be reviewed as one cross-cutting PR, or split along discovery/supervision/persistence boundaries despite the shared policy contract?

Activity

  1. added this to the 0.9.2-rc milestone on Aug 3, 2026
  2. added
    ux/behaviorDisplay bugs, docs, adoption UX
    priority/normalStandard review queue; useful PR with ordinary maintainer urgency.
    on Aug 3, 2026
  3. DeusData commented on Aug 3, 2026

    @DeusData
    Owner

    Thank you for proposing a unified resource envelope and for following it with PR #1348. This is a useful direction, but defaults, enforcement points, cancellation behavior, and compatibility for unconstrained existing installs are project-level policy decisions rather than mechanical limits. I have routed the proposal to 0.9.2-rc for that design review, without committing to the current PR shape yet.

  4. liuchong commented on Aug 5, 2026

    @liuchong
    ContributorAuthor

    Thanks, noted. Happy to wait on the design review call for defaults and compatibility before reshaping #1348. 👀

  5. DeusData commented on Oct 19, 2026

    @DeusData
    Owner

    Thank you for waiting for the defaults and compatibility decision before reshaping #1348. That decision is still needed; I have no new direction on the policy namespace, denied roots, or PR split to announce. No additional implementation work is requested in this follow-up.

  6. DeusData commented on Oct 25, 2026

    @DeusData
    Owner

    Thank you for waiting on direction before reshaping #1348. Defaults, compatibility and the shared policy contract still need a maintainer decision; no further implementation is requested. Sorry for the delay; this is waiting on maintainer follow-up, and I’ll follow up soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestpriority/normalStandard review queue; useful PR with ordinary maintainer urgency.stability/performanceServer crashes, OOM, hangs, high CPU/memoryux/behaviorDisplay bugs, docs, adoption UX

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions