Now I have all the context I need.

---

## Code Review: Fix summary for large belief networks

### CLAUDE.md (new file)
VERDICT: PASS
CORRECTNESS: VALID
SPEC_COMPLIANCE: N/A
ISSUE_COMPLIANCE: UNRELATED
BELIEF_COMPLIANCE: N/A
TEST_COVERAGE: N/A
INTEGRATION: N/A
REASONING: Standard project documentation file. Content is reasonable and matches the project. Not related to the issue but harmless.
---

### ftl_project_expert/cli.py:summary
VERDICT: CONCERN
CORRECTNESS: QUESTIONABLE
SPEC_COMPLIANCE: N/A
ISSUE_COMPLIANCE: PARTIAL
BELIEF_COMPLIANCE: N/A
TEST_COVERAGE: UNTESTED
INTEGRATION: WIRED
REASONING:

The change addresses the core issue (belief network too large for the model context) by capping to 500 beliefs and filtering to IN-status beliefs sorted by impact. The integration is correct -- the only caller of `build_summary_prompt` is updated to pass `total_count`. However, there are several concerns:

1. **`beliefs.md` truncation is by file order, not by impact.** For the `reasons list` path, `--by-impact` ensures the top-500 are the most important. For the `beliefs.md` fallback path (line 2053-2059), sections are split and truncated in file order. The `beliefs.md` file is produced by `reasons export-markdown`, which may not order sections by impact. The status message at line 2071 correctly distinguishes "by impact" vs "by file order", but the user might still get a low-quality summary from the `beliefs.md` path on a large network. This is a minor quality concern, not a bug.

2. **`reasons list --by-impact` failure mode.** If the `reasons` CLI doesn't support `--by-impact` (e.g., older version installed), `result.returncode` will be non-zero. The code then falls through to the `beliefs.md` path -- silently losing the `--status IN` filter and impact sorting. This is acceptable graceful degradation but could be confusing. **Update:** Verified `--by-impact` is a valid flag in the current `reasons` CLI, so this is only a concern for version skew.

3. **No tests.** The observation confirms `test_count: 0` for `build_summary_prompt` and no test files exist for the `summary` command. Given this is a user-facing behavior change (truncation), at least a unit test for `build_summary_prompt` with `total_count > belief_count` and a test for the truncation logic would be valuable.

4. **`total_count` is 0 when count <= max_beliefs and using `beliefs.md` path.** Wait -- no, looking at line 2056, `total_count = len(sections)` is set before the comparison. If `total_count <= max_beliefs`, then `total_count == belief_count`, and the prompt correctly shows just "Beliefs analyzed: N" without the "top by impact" qualifier. This is correct.

5. **Hardcoded `max_beliefs = 500`.** Not configurable. Fine for now, but worth noting. The issue suggested sampling by recency/depth/topic diversity -- this implementation only does impact sorting, which is a reasonable pragmatic choice.

6. **Error message improvement is good.** Line 2094 now includes prompt size in KB, which directly addresses the issue's complaint about empty error messages.
---

### ftl_project_expert/prompts/summary.py:build_summary_prompt
VERDICT: PASS
CORRECTNESS: VALID
SPEC_COMPLIANCE: N/A
ISSUE_COMPLIANCE: ADDRESSES
BELIEF_COMPLIANCE: N/A
TEST_COVERAGE: UNTESTED
INTEGRATION: WIRED
REASONING: The `total_count` parameter is added with a backward-compatible default of `0`. The conditional logic at line 11 correctly detects truncation (`total_count > belief_count`) and informs the LLM that it's seeing a subset. This is important so the model doesn't claim to have analyzed the full network. The f-string formatting is clean. The only caller is updated.
---

## Overall Assessment

The changes are a pragmatic, correct fix for the reported issue. The core problem (10k+ beliefs exceeding context limits) is solved by capping to 500 beliefs sorted by impact. The LLM is informed of truncation, and error messages now include prompt size. The approach is sound.

**Primary concerns:**
- **No test coverage at all** -- the `summary` command has zero tests, and this PR doesn't add any. A unit test for the truncation logic and the prompt builder would catch regressions.
- **The `beliefs.md` fallback path truncates by file order**, which may yield a poor-quality summary for large networks using that path. Consider documenting this limitation or sorting sections in that path too.

### SELF_REVIEW
LIMITATIONS: Could not verify the output format of `reasons list --by-impact` to confirm that line-based splitting (line 2047) correctly separates individual beliefs. If beliefs span multiple lines, the count and truncation would be wrong. Also could not verify what `reasons export-markdown` section ordering looks like to assess the `beliefs.md` truncation quality.
---

### FEATURE_REQUESTS
- Include the output format of CLI tools called via `subprocess.run` when they're being parsed -- the review can't verify parsing correctness without knowing the format
- Flag when a modified function has zero test coverage as an automatic finding
---
