Skip to content

feat(entrypoints): rule-based bulk overrides in entrypoints.toml#21

Merged
tob-scott-a merged 1 commit intomainfrom
bulk-override-patterns
Apr 23, 2026
Merged

feat(entrypoints): rule-based bulk overrides in entrypoints.toml#21
tob-scott-a merged 1 commit intomainfrom
bulk-override-patterns

Conversation

@tob-scott-a
Copy link
Copy Markdown
Collaborator

The override file previously accepted only single-node entries; tagging every PHP script in public_html/ or every function taking a PSR-7 request required listing each function by id. This adds rule-based entries that match many nodes at once.

Three new fields on [[entrypoint]] tables (any combination; multiple compose with AND):

  • file_glob = "public_html/**/*.php" — match against CodeUnit.location.file_path with a shell glob supporting ** (recursive) and * (single-segment).
  • param_type = "ServerRequestInterface" — match any function whose parameter list includes a declared type with this name.
  • name_regex = "^handle_" — match function names via regex.

Conditions inside an entry compose with AND. Later entries in the file override earlier ones — same precedence rule as before.

_glob_to_regex translates shell globs into regexes with explicit ** handling so the feature works on Python 3.12 (which lacks PurePath.full_match). Paths are normalized to forward slashes before matching so the same pattern works on Windows.

Malformed patterns (bad regex, bad glob) are silently skipped so one broken rule can't disable the whole override file.

8 new tests: file_glob at various depths, single-star scoping, param_type matching, name_regex, AND composition, rule-over-heuristic precedence, malformed glob tolerance, and zero-match non-error.

README documents each rule type with examples, including the canonical "mark all PHP scripts in public_html/" and "mark any function taking a PSR-7 request" cases from the design discussion.

The override file previously accepted only single-node entries; tagging
every PHP script in public_html/ or every function taking a PSR-7
request required listing each function by id. This adds rule-based
entries that match many nodes at once.

Three new fields on `[[entrypoint]]` tables (any combination; multiple
compose with AND):

- `file_glob = "public_html/**/*.php"` — match against
  CodeUnit.location.file_path with a shell glob supporting `**`
  (recursive) and `*` (single-segment).
- `param_type = "ServerRequestInterface"` — match any function whose
  parameter list includes a declared type with this name.
- `name_regex = "^handle_"` — match function names via regex.

Conditions inside an entry compose with AND. Later entries in the file
override earlier ones — same precedence rule as before.

`_glob_to_regex` translates shell globs into regexes with explicit `**`
handling so the feature works on Python 3.12 (which lacks
`PurePath.full_match`). Paths are normalized to forward slashes before
matching so the same pattern works on Windows.

Malformed patterns (bad regex, bad glob) are silently skipped so one
broken rule can't disable the whole override file.

8 new tests: file_glob at various depths, single-star scoping,
param_type matching, name_regex, AND composition, rule-over-heuristic
precedence, malformed glob tolerance, and zero-match non-error.

README documents each rule type with examples, including the canonical
"mark all PHP scripts in public_html/" and "mark any function taking a
PSR-7 request" cases from the design discussion.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@tob-scott-a tob-scott-a merged commit 8899f1c into main Apr 23, 2026
13 checks passed
@tob-scott-a tob-scott-a deleted the bulk-override-patterns branch April 23, 2026 16:05
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