GeezerVison is showing github.com — id(find/search/show/peek): --first and --last together silently discard --last — SearchOptions::apply is if/else-if, and none of the four commands declares the conflict Peek's own head/tail pair declares · Issue #3029 · developing-today/code
id(find/search/show/peek): --first and --last together silently discard --last — SearchOptions::apply is if/else-if, and none of the four commands declares the conflict Peek's own head/tail pair declares #3029Labels app/idPackage/app: id (pkgs/ or apps/ in this repo)effort/xsTrivial: expected under 30 minutes of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/lowNice to have; do when convenientsource/creatorFiled by the new-issue-creator jobtask/triageQueue packet kind: verify, reproduce, and route this item DescriptionProblem
--first and --last are mutually exclusive in effect — SearchOptions::apply can only honour one — but nothing says so, so setting both silently discards --last:
SearchOptions::apply (pkgs/id/src/commands/find.rs:128) limits with if let Some(n) = self.first { take(n) } else if let Some(n) = self.last { tail(n) } (find.rs:137-139). When both are Some, the last branch is unreachable: the caller's --last value is dropped with no error and no warning.
- All four CLI commands that carry the pair define both flags with no
conflicts_with: Show (cli.rs:727/730), Peek (cli.rs:808/811), Find (cli.rs:894/897), Search (cli.rs:961/964). So id find --first 2 --last 3 config parses cleanly, returns the first 2 matches, and never mentions that --last 3 was ignored.
- The same file shows the house rule for mutually exclusive flags: Peek's own
--head-only / --tail-only in the same command DO declare conflicts_with each other (cli.rs:786/789), as do --words/--chars. first/last are the exception.
- The REPL path has the same hole:
FindArgs::to_search_options (repl/runner.rs:602) passes both fields straight into SearchOptions::new, and its parser sets both when both flags appear.
Evidence (this run, main ab55f3c)
- Laptop probe with
apply + should_exclude copied verbatim from find.rs (stub TaggedMatch only; find.rs md5 b64b2edef7c416f9357bc2c1d8c2de4f on both clones; probe ~/git/fleet/probe-2026-10-31-laneB-firstlast/ on the laptop): 3 tests passed —
first=Some(2), last=Some(3) over 5 matches returns [a, b]: first wins, last silently ignored;
last=Some(3) alone returns [c, d, e]; first=Some(2) alone returns [a, b] — each flag works on its own, only the combination is silently misread.
- Callers: main.rs constructs
SearchOptions::new(first, last, …) for Find, Search, Show and Peek with whatever clap accepted, so the CLI combination reaches apply unchallenged on all four commands.
Why it matters
A user who writes --first 2 --last 3 (or a script that assembles both flags from different layers) gets a result set shaped by only one of their two instructions, presented as if both were honoured. For find, the returned matches are the ones whose content is written to disk / stdout, so the silent choice changes which file the user ends up with — the worst kind of CLI surprise: no error, plausible-looking output, wrong semantics. The fix the codebase already uses for exactly this shape (conflicts_with, as on Peek's head/tail pair) costs one attribute per command.
Acceptance criteria
- Triage confirms on current main:
SearchOptions::apply (find.rs:137-139) is if/else-if over first/last, and none of Show/Peek/Find/Search in cli.rs declares a first↔last conflict.
- Passing both
--first and --last to any of find, search, show, peek is a loud parse error (clap conflicts_with, matching the head-only/tail-only precedent at cli.rs:786/789), not a silent precedence.
- The REPL find/search parser rejects (or loudly reports) the both-flags combination the same way, instead of passing both into
SearchOptions.
- Single-flag behaviour is byte-identical:
--first N alone and --last N alone return exactly what they return today; a regression test pins both-alone and both-together for at least one command.
- Alternatively, if triage decides both-set should mean something (e.g. last-within-first), that semantics is implemented in
apply, documented in the flag help, and pinned by a test — silence is the only unacceptable outcome.
Distinct from: #2009 (REPL: a non-numeric --first/--last value becomes a query — different failure, REPL token parsing), #2274 (REPL: unknown/mistyped flags swallowed — REPL parser again; this issue is the CLI clap definitions plus the shared apply precedence, and the REPL's both-set case), #2178 (--all --dir overwrite in find downloads). Activityadded kind/bugSomething isn't working (prefixed form of the classic bug label) task/triageQueue packet kind: verify, reproduce, and route this item app/idPackage/app: id (pkgs/ or apps/ in this repo) effort/xsTrivial: expected under 30 minutes of work on Oct 31, 2026dezren39 commented on Oct 31, 2026 🤖 Agent note · filed
- Agent: new-issue-creator-code-b (new-issue-creator job, lane B)
- Session / ID: new-issue-creator-code-b run 2026-10-31 05:50 CDT
- Found via: filed this run
- Task: Filed this issue: --first and --last together silently discard --last (SearchOptions::apply if/else-if; no conflicts_with in Show/Peek/Find/Search). Verified this run on the laptop with a verbatim-apply probe (find.rs md5 b64b2edef7c416f9357bc2c1d8c2de4f on both clones; probe ~/git/fleet/probe-2026-10-31-laneB-firstlast/): first=2+last=3 over 5 matches returns the first 2; each flag alone works.
- Expectation: effort/xs — triage confirms and routes the conflicts_with fix (CLI four commands + REPL parser) with both-alone/both-together regression tests.
- Links: evidence in issue body; body file hidden_files/issue-code-first-last-body.md (goal workspace)
dezren39 commented on Nov 1, 2026 agent-note:v1 — triage (queue task 4388, lane C, 2026-11-01)
Verdict: CONFIRMED on current main c6bf93371. Routed to a fix: task 5524 (small_fix) enqueued on queue repo-health-code-pilot (packet: packet-3029-fix.json).
Fresh evidence on main c6bf933713baa8107e4ffe5a28a82f750baa506b:
pkgs/id/src/commands/find.rs — SearchOptions::apply still reads if let Some(n) = self.first { take(n) } else if let Some(n) = self.last { … }: with both set, --last is unreachable.
pkgs/id/src/cli.rs — the first/last field pairs at 727/730 (Show), 808/811 (Peek), 894/897 (Find), 961/964 (Search) are all plain #[arg(long, num_args = 0..=1, default_missing_value = "1")] with no conflicts_with; Peek's own head_only/tail_only at 786/789 do declare conflicts_with — the precedent for the fix.
pkgs/id/src/repl/runner.rs — FindArgs first/last fields at 591/593, to_search_options passes both through at 604/605, and the parser sets --first (~675) / --last (~687) with no both-set rejection.
- The issue's laptop probe stands unrebutted: first=2 + last=3 over 5 matches returns
[a,b]; last=3 alone returns [c,d,e].
Routing decision: declare the conflict — conflicts_with on all four commands + a loud both-set rejection in the REPL parser + regression tests pinning first-alone/last-alone (unchanged) and both-together (parse error). The alternative (defining a both-set semantics in apply) was considered and rejected: the codebase's own convention for mutually exclusive limiters in the same file is a declared conflict, and silence is the only unacceptable outcome — a parse error removes the silence. apply's single-flag semantics stay untouched. dezren39 commented on Nov 1, 2026 🤖 Agent note · picked up
- Agent: queue worker (repo-worker-code), OpenChamber scheduled lane
- Session / ID: OpenCode session ses_e5e68cde887ffeDkSKcq8nPIpq · queue task 5524 (small_fix, resumed)
- Found via: queue claim / parked-task resume
- Task: Resume the already-pushed id(find/search/show/peek): --first and --last together silently discard --last — SearchOptions::apply is if/else-if, and none of the four commands declares the conflict Peek's own head/tail pair declares #3029 fix from branch
queue/5524-3029-first-last-conflict; preserve its changes, refresh main, revalidate issue/PR ownership, then open the PR and continue through the first outcome.
- Expectation: all four CLI commands reject
--first + --last, the REPL rejects both together, one-sided behavior stays unchanged, tests pass, and a PR is opened. Prior progress records commit a0bb94886 and passing targeted tests; GitHub write cooldown has elapsed.
dezren39 commented on Nov 1, 2026 🤖 Agent note · done
- Agent: queue worker (repo-worker-code), OpenChamber scheduled lane
- Session / ID: OpenCode session ses_e5e68cde887ffeDkSKcq8nPIpq · queue task 5524 (small_fix, resumed)
- Found via: queue claim / parked-task resume
- Task: Add explicit mutual exclusion for
--first / --last across Show, Peek, Find, Search, plus loud rejection in the REPL parser, without changing one-sided behavior.
- Outcome: Task 5524 completed as
pr_opened. PR #3695 is open from queue/5524-3029-first-last-conflict at d56ad5627b3e85936d086ca971879b131aca33f0; fresh PR state showed checks SUCCESS and no blockers.
- Verification: targeted regressions 3/3; REPL find parser tests 12/12; REPL peek parser tests 9/9; CLI parser suite 109/109; rustfmt and
git diff --check pass. The fix is pushed and current origin/main was merged before PR creation. In-flight issue labels removed.
dezren39 commented on Nov 1, 2026 🤖 Agent note · done
- Agent: queue worker (repo-worker-code), Lane F
- Session / ID: queue task 5626 (unblocking step; PR opened by task 5524, which completed as pr_opened)
- Found via: PR fix(id): reject conflicting first and last limits #3695 blocked task 5626's file overlap; verified and merged it as its shepherd
- Task: PR id(event-store): apply the groups fold on production ingest (#168) #3725-style shepherd for id(find/search/show/peek): --first and --last together silently discard --last — SearchOptions::apply is if/else-if, and none of the four commands declares the conflict Peek's own head/tail pair declares #3029's PR fix(id): reject conflicting first and last limits #3695: diff is exactly the scoped change (clap
conflicts_with on --first/--last across find/search/show/peek + REPL rejection + tests), Codex review clean (no findings on d56ad56), task 5524's recorded tests all pass (3/3, 12/12, 9/9, 109/109, rustfmt). Merged 2026-11-01T14:45:38Z as d4e192292. Closing id(find/search/show/peek): --first and --last together silently discard --last — SearchOptions::apply is if/else-if, and none of the four commands declares the conflict Peek's own head/tail pair declares #3029 on that evidence.
MetadataMetadataapp/idPackage/app: id (pkgs/ or apps/ in this repo)effort/xsTrivial: expected under 30 minutes of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/lowNice to have; do when convenientsource/creatorFiled by the new-issue-creator jobtask/triageQueue packet kind: verify, reproduce, and route this item DevelopmentNo branches or pull requestsIssue actions
|