Repository navigation
Description
Part of #1341.
Context
CLI: limit: flags.limit ? parseInt(flags.limit as string, 10) : 20 (packages/core/src/cli/commands/list.ts:29). --limit abc yields NaN; --limit 100000 is passed through. MCP: Math.min(Math.max(1, params.limit), MAX_LIST_LIMIT) (packages/core/src/mcp-server.ts:441). The same operation behaves differently per surface.
Approved limit policy
2026-10-09: CLI policy A approved. brain list --limit accepts a whole integer in 1..100, defaults to 20 when omitted, and rejects malformed, fractional, missing-value and out-of-range input as a usage error (exit 1, correcting the original issue's exit-2 proposal). Do not partially parse 10abc or 1.5, silently clamp, or reach SQL with an invalid limit. This deliberately tightens prior CLI behavior, including formerly accepted values above 100.
2026-10-09: MCP policy C approved. Both CLI and brain_list require an integer in 1..100, default 20. MCP rejects fractional/out-of-range values rather than clamping. This explicitly authorizes the breaking tightening of its numeric input schema and behavior. Retain existing successful result shapes and existing MCP error conventions; no new error envelope is selected.
Scope
- Implement the approved CLI policy with one shared range constant and validation/normalization helper used by both surfaces. Use the same strict integer/range policy for both. CLI parsing must validate the whole supplied string; MCP schema and shared runtime validation enforce the numeric integer/range constraints.
Out of scope
- Other flags (separate issue).
Acceptance criteria
- Real CLI tests verify omission defaults to 20; 1 and 100 succeed; abc, 10abc, fractions, missing value, zero, negatives and 101 fail with usage exit 1 in human and JSON modes, without executing a list query. The fix-removed mutation fails the intended behavioral assertion.
- CLI and MCP share one limit constant and one strict validator. Real MCP registration/transport tests verify default 20 and boundaries 1/100 succeed; fractions, zero, negative and 101 fail through existing error conventions. Schema snapshots record the intentional integer/range constraints; successful documents/warnings shapes remain unchanged. A removed range/integer guard causes the corresponding independent assertion to fail.
-
docs/integration-contract.mdstates the limit behaviour.
Verification
bun run test packages/coreContract impact
Yes: CLI input handling is deliberately tightened by the maintainer ruling. Use contract and breaking, a CONTRACT: commit, a same-commit integration-contract update and a changeset describing the before/after CLI limit behavior; follow pre-1.0 breaking version policy. The MCP schema/behavior tightening from numeric clamping to strict 1..100 integers is also explicitly approved. Document both surfaces and update schema snapshots only for that selected change.
Blocked by #1349
2026-10-09: sequenced against the other code-quality issues to avoid overlapping edits; see the epic's planned-order comment.
2026-10-09 decision pass: both limit policies are now settled; remove needs: decision and add agent-ready. Keep blocked while #1349 remains open; ready specification does not permit bypassing the implementation dependency.
Activity
schlessera commentedon Oct 9, 2026
Decision (maintainer, 2026-10-09): CLI limit policy
Choose A:
brain list --limitrequires an integer from 1 through 100, defaulting to 20 when omitted. Reject malformed, fractional, missing-value and out-of-range input with the existing usage-error exit 1. Do not partially parse strings or clamp silently. This is an approved tightening of the previous CLI contract; record it as breaking with the contract update and changeset.The body now follows this choice. MCP's published numeric/clamping behavior still needs an explicit preservation-or-tightening choice so shared validation cannot change it accidentally. Keep
needs: decisionand the dependency on #1349; no readiness yet.schlessera commentedon Oct 9, 2026
Decision (maintainer, 2026-10-09): MCP policy C
Require integers from 1 through 100 on both CLI and MCP, default 20. MCP rejects fractions and out-of-range values instead of clamping. This explicitly approves the breaking MCP input-schema/behavior tightening alongside the recorded CLI tightening; retain current success shapes and MCP error conventions. Use one constant and strict shared validator, with full-string CLI parsing.
The body includes boundary/invalid-input tests, deliberate schema snapshot updates, mutation evidence and contract documentation requirements. No decision remains: remove
needs: decisionand addagent-ready. Keepblockedon open #1349 and retaincontract/breaking; implementation must follow that dependency.schlessera commentedon Oct 10, 2026
Unblocked: #1349 merged in #1468 (62cf4d6), its only listed blocker.
schlessera commentedon Oct 10, 2026
Claimed (claim token
wi-1351-a7). Working on branchfix/1351-list-limit.schlessera commentedon Oct 10, 2026
PR: #1470 (branch
fix/1351-list-limit).test(ui-backend-pi): compare pi's clamped list limit with core's acce…
schlessera commentedon Oct 10, 2026
Done in #1470, squash-merged as 6cb61cb on main (milestone 0.41.0).
brain list --limitandbrain_listshareDEFAULT_LIST_LIMIT(20),MAX_LIST_LIMIT(100) andlistLimitSchemainpackages/core/src/lib/ops/read.ts. The CLI requires a full integer literal, validates before opening the database and exits 1 in human and JSON modes.brain_list's schema isinteger, 1–100, default 20, and other values are rejected through the SDK's invalid-input convention.brain_list.limit) and the changeset (minor, 0.40.0 → 0.41.0, no major) record the before and after.