Repository navigation
fix(codebase_analyze): default to no file cap, treat max_files<=0 as unbounded - #25
Merged
Merged
Conversation
…unbounded The previous default of max_files=500 — and the cortex-setup-project skill's explicit max_files=5000 — silently truncated real codebases at exactly the cap. Two of the user's repos (~ai-architect-prd-builder, ai-prd) hit 5000 exactly during a full-scale bootstrap, meaning files were dropped from the knowledge graph. Change the contract so max_files<=0 means "no limit". Split the helper into _collect_bounded (preserves ADR-0045 §R2 streaming for callers who opt into a cap) and _collect_unbounded (walks the whole tree but only materialises post-filter survivors — memory is O(filtered_files), not O(tree_size)). Default now 0 across handler, schema, and tool registry. Add 4 regression tests: 7500-file unbounded walk, negative-as-unbounded, language/IGNORE_DIRS filtering still applied in unbounded mode, plus the existing 7 bounded-mode tests unchanged. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
1 of 3 tasks
cdeust
added a commit
that referenced
this pull request
May 12, 2026
Bundles four PRs landed since v3.15.3: #25 codebase_analyze: default max_files=0 (no cap); fixed truncation at 5000 in skill invocation #26 wiki slug/title leaks (.md.md, timestamp-slugs, path-titles) #27 ADR-2244 Phase 1: multi-axis classification (kind, lifecycle, audience, provenance) + Task #8 (file→reference/ routing fix) #28 ADR-2244 follow-up: data-driven axis registry replacing closed enums with wiki/_schema/<axis>/<value>.md user-extensible files Changelog entry documents migration impact and the extension contract for adding new classification values without code changes. Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
3 of 5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
max_files=500(and thecortex-setup-projectskill's explicitmax_files=5000) silently truncated real codebases at the cap. During a full-scale bootstrap,ai-architect-prd-builderandai-prdboth hit the cap at exactly 5000 — meaning files were dropped from the knowledge graph with no warning.max_files <= 0mean "no limit" and default to 0. Positive values still cap (opt-in) and still preserve the ADR-0045 §R2 bounded-memory walk.O(filtered_files), notO(tree_size).Files changed
mcp_server/handlers/codebase_analyze.py—DEFAULT_MAX_FILES = 0; schemaminimum: 0, removedmaximum: 50000, description updated.mcp_server/handlers/codebase_analyze_helpers.py— splitcollect_source_filesinto_collect_bounded(preserves §R2 streaming) and_collect_unbounded(filter-then-materialise). Shared_file_matchesfilter.mcp_server/tool_registry_manage.py—max_files: int = 0.tests_py/handlers/test_codebase_analyze_rglob.py— +4 regression tests (unbounded 7500-file walk, negative-as-unbounded, language/IGNORE_DIRS filters in unbounded mode), 7 existing bounded-mode tests unchanged.Behavioural change
Callers that did not pass
max_filespreviously got 500; they will now get the whole codebase. This is intentional — the silent truncation was the bug. Callers that need a cap can still pass one explicitly.Test plan
pytest tests_py/handlers/test_codebase_analyze_rglob.py— 11/11 passpytest tests_py/handlers/test_ingest_codebase.py tests_py/handlers/test_backfill_discover_files_issue15.py tests_py/infrastructure/test_workflow_graph_source_native_ast.py— 30 passed, 8 skippedcortex-setup-projecton a multi-repo bootstrap and verify no repo lands on a round-number cap🤖 Generated with Claude Code