Skip to content

refactor(master): extract claim eligibility into a pure module - #336

Merged
beinan merged 1 commit into
lance-format:mainfrom
beinan:refactor/eligibility-pure-function
Oct 8, 2026
Merged

beinan merged 1 commit into
lance-format:mainfrom
beinan:refactor/eligibility-pure-function

Conversation

@beinan

@beinan beinan commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator

Part of #333 (P0.1).

Problem

claim_next in task_store.rs decides per queued candidate whether this poller may attempt the claim transaction through a chain of inlined continues: kind filter, resident-only filter (#331), preparation shape (#308/#327), commit-ready yield (#324), the seven-key ownership predicate, and the worker-execution rule. None of it was testable without etcd, the preparing predicate existed twice, and no skip had a name.

Approach

New eligibility.rs with three pure functions: pre_dependency_filter, claim_shape, admission_filter, each returning Result<(), Skip>. claim_next performs the same etcd reads in the same order and feeds them in; YieldToPreparedCommit and OwnershipBlocked map to the existing counters, every other skip is traced with its reason.

No behaviour change. This is the foundation for the planner's filter phase and for the "why not now" surface.

Alternatives

Testing through etcd integration only (status quo): too slow and too coarse to pin down individual predicates. A trait over the store: more machinery than needed; plain inputs are enough.

Validation

  • 7 new etcd-free unit tests: resident filtering incl. wildcard, preparation opt-in excluding draining/generic, catch-up sharing exact-match, commit-ready yield incl. recovery bypass and stale-hint ignore, each ownership predicate, worker-execution rule.
  • cargo clippy --all-targets -D warnings, cargo fmt --check, typos clean.
  • Locally against real etcd: task_store 23/23, scheduler 31/31.

🤖 Generated with Claude Code

`claim_next` decided per candidate whether this poller may attempt the
claim transaction through a chain of inlined `continue`s: kind filter,
resident-only filter, preparation shape, commit-ready yield, seven-key
ownership predicate and the worker-execution rule. None of it was unit
testable without etcd and no skip had a name.

Move those decisions to `eligibility.rs` as functions of plain inputs
(`pre_dependency_filter`, `claim_shape`, `admission_filter`) returning
`Result<(), Skip>`. `claim_next` keeps the same etcd reads in the same
order, maps `YieldToPreparedCommit` and `OwnershipBlocked` to the
existing counters, and traces every other skip with its reason.

No behaviour change. `requires_target_lock` moves unchanged. The
`preparing` predicate, which was computed twice with slightly different
spelling, now exists once.

Validation: 7 new etcd-free unit tests cover resident filtering,
preparation opt-in, catch-up sharing, the commit-ready yield including
the recovery bypass, every ownership predicate, and the worker-execution
rule. Clippy -D warnings, fmt and typos clean. task_store (23) and
scheduler (31) etcd-backed suites pass locally.

Refs lance-format#333.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@beinan
beinan merged commit 27a75cc into lance-format:main Oct 8, 2026
11 checks passed
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