Skip to content

Function-calling - enforcement guard (Phase 1)#952

Open
lchoquel wants to merge 2 commits into
refactor/Function-callingfrom
refactor/Function-calling-1
Open

Function-calling - enforcement guard (Phase 1)#952
lchoquel wants to merge 2 commits into
refactor/Function-callingfrom
refactor/Function-calling-1

Conversation

@lchoquel
Copy link
Copy Markdown
Member

@lchoquel lchoquel commented May 31, 2026

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 (a pipelex-dev AST command) enforces that non-subject function parameters across pipelex/ source are keyword-only, so call sites read do_thing(retries=3, timeout=30) instead of do_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 on relpath::qualified_name), and the guard fails only on NEW, non-baselined violations. The backlog is burned down package-by-package in later PRs (waves in TODOS.md).

Wired into both make agent-check (fast everyday gate) and make check (+ CI).

Carve-outs & exceptions

  • Skipped entirely: dunders, pydantic validators/serializers, framework entrypoints (Typer/Temporal/pytest, incl. Typer call-style Annotated detection), and @override (sound because pyproject enforces reportImplicitOverride + reportIncompatibleMethodOverride).
  • Exception 1: the subject param may stay positional.
  • Exception 2: a short, explicit symmetric-tuple allowlist (set_env, unified_diff, diff_files, diff_dirs).
  • Inline # kw-only: ignore escape hatch.

Verification

  • make agent-check: pyright 0 errors, mypy clean, guard passes against baseline
  • make agent-test: full suite green
  • guard unit tests: all green

See wip/keyword-only-args/convention.md for the full spec and state.md for the cold-start log.

🤖 Generated with Claude Code


Summary by cubic

Add AST guard check-keyword-only to enforce keyword-only arguments across pipelex/ without changing runtime behavior. CI fails only on new violations, using a committed baseline to ship red-to-green.

  • New Features

    • New dev CLI command check-keyword-only to enforce that non-subject params are keyword-only.
    • Wired into make check and make agent-check, with Make targets check-keyword-only/cko.
    • Baseline at wip/keyword-only-args/violations-baseline.txt; guard fails only on non-baselined violations. Key is relpath::qualified_name (signature-agnostic) to avoid penalizing partial improvements.
    • Added unit tests and docs: wip/keyword-only-args/convention.md (example fixed), state.md, inventory.json; TODOS.md is the tracker.
  • Rules & Exceptions

    • Rule: subject may be positional-or-keyword; all other params must be after a bare *. All-keyword is fine.
    • Skipped: dunders, pydantic validators/serializers, framework entrypoints (Typer/Temporal/pytest), incl. bare @fixture and bare Typer Argument/Option, and @override.
    • Allowlist for symmetric tuples (e.g., set_env, unified_diff, diff_files, diff_dirs).
    • Escape hatch: inline # kw-only: ignore.

Written for commit a58456f. Summary will update on new commits.

Review in cubic

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-apps
Copy link
Copy Markdown

greptile-apps Bot commented May 31, 2026

Greptile Summary

This PR adds a keyword-only argument guard for Pipelex source. The main changes are:

  • New pipelex-dev check-keyword-only AST command with baseline support.
  • Makefile wiring into check, agent-check, and a cko shortcut.
  • Carve-outs for framework entrypoints, overrides, dunders, pydantic hooks, and explicit symmetric helpers.
  • Unit tests and rollout docs for the convention and burn-down plan.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Important Files Changed

Filename Overview
pipelex/cli/dev_cli/commands/check_keyword_only_cmd.py Adds the AST-based keyword-only guard and latest carve-out handling for bare fixture and Typer annotation forms.
tests/unit/pipelex/cli/dev/test_check_keyword_only_cmd.py Covers the guard behavior, including the latest bare fixture and bare Typer annotation cases.
wip/keyword-only-args/convention.md Documents the enforced convention, rollout model, carve-outs, and known baseline limitation.

Reviews (2): Last reviewed commit: "refactor(dev): address PR review on keyw..." | Re-trigger Greptile

Comment thread pipelex/cli/dev_cli/commands/check_keyword_only_cmd.py
Comment thread pipelex/cli/dev_cli/commands/check_keyword_only_cmd.py
Comment thread pipelex/cli/dev_cli/commands/check_keyword_only_cmd.py
Comment thread pipelex/cli/dev_cli/commands/check_keyword_only_cmd.py Outdated
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread wip/keyword-only-args/convention.md Outdated
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread pipelex/cli/dev_cli/commands/check_keyword_only_cmd.py Outdated
Comment thread pipelex/cli/dev_cli/commands/check_keyword_only_cmd.py Outdated
Comment thread wip/keyword-only-args/convention.md Outdated
Comment thread pipelex/cli/dev_cli/commands/check_keyword_only_cmd.py
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>
@lchoquel lchoquel changed the title feat(dev): keyword-only-arguments enforcement guard (Phase 1) Function-calling - enforcement guard (Phase 1) May 31, 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