Skip to content

fix(cli): add --limit to the enhance command across all three layers#80

Closed
gadievron wants to merge 1 commit into
masterfrom
fix/cli-add-limit-to-the-enhance-command-across
Closed

fix(cli): add --limit to the enhance command across all three layers#80
gadievron wants to merge 1 commit into
masterfrom
fix/cli-add-limit-to-the-enhance-command-across

Conversation

@gadievron

Copy link
Copy Markdown
Collaborator

The enhance command lacked a --limit (max-units) capability while its siblings analyze and scan
have it, so a user could not cost-limit or test-run enhancement on N units -- enhance always processed the
full dataset. The gap spanned all three layers (a Go-only patch would be inert: the Python CLI rejected
--limit and the core could not consume it):

  • Go (apps/openant-cli/cmd/enhance.go): add a --limit flag (default 0 = no limit) and forward it to the
    Python args when > 0, mirroring analyze.go.
  • Python CLI (libs/openant-core/openant/cli.py): add --limit to the enhance subparser and pass
    limit=args.limit into enhance_dataset, mirroring analyze.
  • Core (libs/openant-core/core/enhancer.py): add a limit parameter to enhance_dataset and slice
    dataset["units"] to units[:limit] before enhancement, mirroring analyzer.py (limit + units[:limit]).
    Slicing dataset["units"] (not only the local list) is what makes the limit reach both the agentic and
    single-shot enhancement paths.

Scope: analyze.go / analyze_p / analyzer.py already have --limit (the parity baseline, unchanged here);
verify/report/etc. do not enhance units, so they are out of scope.

Tests:

  • libs/openant-core/tests/test_enhance_limit.py: with the LLM stubbed, enhance_dataset(limit=2) on a
    5-unit dataset makes the enhancer RECEIVE exactly 2 units (asserting on what the enhancer receives guards
    the load-bearing dataset["units"] slice -- verified by a mutant: dropping that line makes the enhancer
    see all 5 and the test fail); and enhance ... --limit 3 driven through cli.main() forwards limit=3 to
    enhance_dataset (covers the enhance_p parser + cmd_enhance glue).
  • apps/openant-cli/cmd/enhance_limit_test.go: enhanceCmd exposes a --limit flag (default 0).
    RED (pre-fix, via stash): Python "unrecognized arguments: --limit" + Go "missing --limit flag" -> GREEN.
    Full py suite 178 passed / 63 skipped; go test ./cmd/ ok; ruff + gofmt + go vet clean.

Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com

The `enhance` command lacked a `--limit` (max-units) capability while its siblings `analyze` and `scan`
have it, so a user could not cost-limit or test-run enhancement on N units -- enhance always processed the
full dataset. The gap spanned all three layers (a Go-only patch would be inert: the Python CLI rejected
--limit and the core could not consume it):

- Go (apps/openant-cli/cmd/enhance.go): add a --limit flag (default 0 = no limit) and forward it to the
  Python args when > 0, mirroring analyze.go.
- Python CLI (libs/openant-core/openant/cli.py): add --limit to the enhance subparser and pass
  limit=args.limit into enhance_dataset, mirroring analyze.
- Core (libs/openant-core/core/enhancer.py): add a `limit` parameter to enhance_dataset and slice
  dataset["units"] to units[:limit] before enhancement, mirroring analyzer.py (limit + units[:limit]).
  Slicing dataset["units"] (not only the local list) is what makes the limit reach both the agentic and
  single-shot enhancement paths.

Scope: analyze.go / analyze_p / analyzer.py already have --limit (the parity baseline, unchanged here);
verify/report/etc. do not enhance units, so they are out of scope.

Tests:
- libs/openant-core/tests/test_enhance_limit.py: with the LLM stubbed, enhance_dataset(limit=2) on a
  5-unit dataset makes the enhancer RECEIVE exactly 2 units (asserting on what the enhancer receives guards
  the load-bearing dataset["units"] slice -- verified by a mutant: dropping that line makes the enhancer
  see all 5 and the test fail); and `enhance ... --limit 3` driven through cli.main() forwards limit=3 to
  enhance_dataset (covers the enhance_p parser + cmd_enhance glue).
- apps/openant-cli/cmd/enhance_limit_test.go: enhanceCmd exposes a --limit flag (default 0).
RED (pre-fix, via stash): Python "unrecognized arguments: --limit" + Go "missing --limit flag" -> GREEN.
Full py suite 178 passed / 63 skipped; go test ./cmd/ ok; ruff + gofmt + go vet clean.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
ar7casper added a commit that referenced this pull request Jun 22, 2026
These PRs predated #69's llm-provider refactor and were never rebased, so their tests referenced removed APIs (AnthropicClient, ContextEnhancer(client=)) and #69's new registry credential probe. Updated test construction/mocking to the post-#69 API only; no assertions changed, no production code touched. Full suite: 729 passed, 0 failed.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@gadievron

Copy link
Copy Markdown
Collaborator Author

Closing as already resolved on current master. This fix's behavior shipped via the parser-fix-stack release (#133/#134); confirmed by independent reproduction — the original bug (reconstructed from its bug-pipeline investigation) no longer manifests on master, not merely by line-presence. Part of a full validated sweep of the open-PR corpus.

@gadievron gadievron closed this Jul 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant