Function-calling - enforcement guard (Phase 1)#952
Conversation
Introduce `check-keyword-only`, an AST-based dev CLI guard that enforces the keyword-only-arguments convention across pipelex/ source: non-subject function parameters must be keyword-only (behind a bare `*`) so call sites are self-documenting. Only the subject (first param) may be passed positionally, and that is a permission, not a requirement — all-keyword signatures are fine too. The guard ships red-to-green: it baselines the existing violations and fails only on NEW, non-baselined ones, so the rule is enforced on new code immediately while the backlog is burned down package-by-package. Wired into both `make agent-check` and `make check`. Carve-outs (skipped entirely): dunders, pydantic validators/serializers, framework entrypoints (Typer/Temporal/pytest), and @OverRide (sound because pyproject enforces reportImplicitOverride). Inline `# kw-only: ignore` escape hatch. Exception 2 is a small, explicit symmetric-tuple allowlist. Adds the convention spec, cold-start state, and per-package inventory under wip/keyword-only-args/, plus the master plan/tracker in TODOS.md. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Greptile SummaryThis PR adds a keyword-only argument guard for Pipelex source. The main changes are:
Confidence Score: 5/5This looks safe to merge.
Important Files Changed
Reviews (2): Last reviewed commit: "refactor(dev): address PR review on keyw..." | Re-trigger Greptile |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d18a63fc45
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
4 issues found across 10 files
Tip: cubic can generate docs of your entire codebase and keep them up to date. Try it here.
Re-trigger cubic
Match bare @fixture and bare Argument()/Option() forms in the keyword-only carve-outs, consistent with the existing pydantic / @OverRide bare-name handling. Closes two latent false positives (valid call-style Typer entrypoints and bare-imported fixtures would otherwise be flagged once such imports are introduced). Fix the convention.md copy_file worked example, which presented a signature the strict rule still rejects (a second positional after the subject); reframe to the compliant form and point to the Exception 2 open question for the directional-pair alternative. Document the signature-agnostic baseline key as a known limitation: a parameter-count key was deliberately rejected because it would penalize partial improvements (shrinking a baselined function would fail CI). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Phase 1 — keyword-only-arguments enforcement guard
First phase of the keyword-only-arguments refactor (plan + tracker in
TODOS.md). This PR is purely additive — a new dev CLI guard plus its wiring, no runtime behavior change — so it can merge ahead of the burn-down and start enforcing the convention on new code immediately.What it does
check-keyword-only(apipelex-devAST command) enforces that non-subject function parameters acrosspipelex/source are keyword-only, so call sites readdo_thing(retries=3, timeout=30)instead ofdo_thing(3, 30). Only the subject (first param) may be positional — and that is a permission, not a requirement; all-keyword signatures are always fine.It ships red-to-green: existing violations are recorded in a baseline (
wip/keyword-only-args/violations-baseline.txt, keyed onrelpath::qualified_name), and the guard fails only on NEW, non-baselined violations. The backlog is burned down package-by-package in later PRs (waves inTODOS.md).Wired into both
make agent-check(fast everyday gate) andmake check(+ CI).Carve-outs & exceptions
Annotateddetection), and@override(sound because pyproject enforcesreportImplicitOverride+reportIncompatibleMethodOverride).set_env,unified_diff,diff_files,diff_dirs).# kw-only: ignoreescape hatch.Verification
make agent-check: pyright 0 errors, mypy clean, guard passes against baselinemake agent-test: full suite greenSee
wip/keyword-only-args/convention.mdfor the full spec andstate.mdfor the cold-start log.🤖 Generated with Claude Code
Summary by cubic
Add AST guard
check-keyword-onlyto enforce keyword-only arguments acrosspipelex/without changing runtime behavior. CI fails only on new violations, using a committed baseline to ship red-to-green.New Features
check-keyword-onlyto enforce that non-subject params are keyword-only.make checkandmake agent-check, with Make targetscheck-keyword-only/cko.wip/keyword-only-args/violations-baseline.txt; guard fails only on non-baselined violations. Key isrelpath::qualified_name(signature-agnostic) to avoid penalizing partial improvements.wip/keyword-only-args/convention.md(example fixed),state.md,inventory.json;TODOS.mdis the tracker.Rules & Exceptions
*. All-keyword is fine.@fixtureand bare TyperArgument/Option, and@override.set_env,unified_diff,diff_files,diff_dirs).# kw-only: ignore.Written for commit a58456f. Summary will update on new commits.