Skip to content

fix(derive): name the count type in standing presence checks - #1205

Merged
jdx merged 1 commit into
mainfrom
cursor/fix-count-standing-partialeq-9f61
Aug 22, 2026
Merged

fix(derive): name the count type in standing presence checks#1205
jdx merged 1 commit into
mainfrom
cursor/fix-count-standing-partialeq-9f61

Conversation

@jdx

@jdx jdx commented Aug 22, 2026

Copy link
Copy Markdown
Owner

Summary

update_from standing presence for count fields generated != Default::default(). When an adopter also has serde_json in the same crate, PartialEq<Value> for u8 makes that comparison ambiguous and the derive fails to compile.

hk's CLI (verbose: u8 with count, plus completion / globals / overrides) hits this on current main after #1197. Name the field type so the comparison stays u8.

This is a blocker for repinning the fleet clap→usage PRs onto current main for the v6 swap.

Fleet readiness (companion)

Reviewed and locally checked against this revision:

PR Status vs latest usage
tak#47, pitchfork#754 compile ok; need git SHA repin
fnox#725 CI green; need repin (local check blocked on libudev)
hk#1211 needs this fix, then repin + regenerate hk.usage.kdl (flagset)
aube#1336 compile ok; CI red on completion flag order (force/install); patch ready
communique#265 compile ok; oldest pin — need repin + regen kdl
mise#12221 compile ok with rustls; rebase + unify vfox dual pin + repin

This agent only has write access to jdx/usage, so fleet PR updates could not be pushed from here.

Test plan

  • New conformance test a_standing_count_compiles_beside_serde_json
  • Full update_from suite green
  • Minimal repro with completion + global count + overrides + serde_json compiles
  • hk on agent/usage-6-experiment compiles against this revision
Open in Web Open in Cursor 

Summary by CodeRabbit

  • Bug Fixes
    • Fixed updates for standing counted u8 flags so their existing values remain unchanged when no new value is provided.
    • Improved handling of counted short flags, subcommands, and default quiet-state behavior.
    • Resolved type handling issues that could affect presence checks for counted options.

`verbose: u8` with `count` generated `!= Default::default()`, which is
ambiguous when serde_json's PartialEq<Value> for u8 is also in scope.
hk's CLI failed to compile against the update_from standing code from
#1197 for that reason. Name the field type so the comparison stays u8.

Co-authored-by: jdx <jdx@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Aug 22, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 17f12bb6-4c4d-46c7-9381-e5e50fe3705b

📥 Commits

Reviewing files that changed from the base of the PR and between 543d4eb and 2ce0090.

📒 Files selected for processing (2)
  • conformance/tests/update_from.rs
  • derive/src/codegen.rs

Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

The change resolves count-field default comparisons through each field’s declared type. It adds a conformance fixture and regression test for counted flags during updates with subcommands and serde_json in scope.

Changes

Count update handling

Layer / File(s) Summary
Typed count detection and regression coverage
derive/src/codegen.rs, conformance/tests/update_from.rs
Count presence and merge checks use the field’s explicit type when resolving Default::default(). The regression test verifies that -vv remains counted after an update containing only the subcommand.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 2ce00

This localized derive fix makes standing presence checks use the generated count field's declared type, avoiding an ambiguity with serde_json comparisons; no actionable merge-blocking risk remains after normal checks and review.

Poem

A rabbit checked the flags with care,
Two verbose hops stayed counted there.
Through subcommands, values held true,
Typed defaults guided the view.
serde_json joined the run—
The update left the count as one?
No, two! The test was done.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the fix to name the count type in generated standing presence checks.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@jdx
jdx marked this pull request as ready for review August 22, 2026 02:14
@jdx
jdx enabled auto-merge (squash) August 22, 2026 02:17
@github-actions

Copy link
Copy Markdown
Contributor

Instruction counts

benchmark trend instructions Δ wall (min) Δ
markdown ▁▁▁▁▁▁▅▅███████ 270,656,622 → 270,565,260 -0.03% 23.25 → 23.36ms +0.45%
startup ▁▁▁▁▁▁▃▃▆▆▆▆███ 868,282 → 868,452 +0.02% 0.85 → 0.88ms +3.34%

No instruction-count regression above 1%.

Only instruction counts gate. Wall clock is shown for context — on identical hardware it moves 4-20% run to run.

Measured by tak — instruction-counted CLI benchmarks, stored in this repository's git notes.

Shadow comparison

Parsing mise use -g node@20 against a shadow of mise's committed spec.
Reported, not gated: the shadow grows as the derive learns to express more, so
what to watch is the ratio rather than either column.

framework instructions, cold parse vs usage
usage 8425
argh 6307 0.7x
clap 6316290 749x
bpaf 21909019 2600x
                                              min       p01       p10    median
usage-rs: argv -> struct                      423       427       430       436  ns
argh: argv -> struct                          291       294       300       309  ns
clap: build tree + parse -> struct         510734    511761    516974    535788  ns
bpaf: build parser + parse -> struct      1589336   1589336   1602472   1645729  ns

usage: argv -> struct                             453 ns      0.45 µs
clap: build tree + parse -> struct             529397 ns    529.40 µs
clap: parse -> struct, tree reused              23554 ns     23.55 µs
clap: build tree only                          330171 ns    330.17 µs

2ce009012796 vs 543d4ebb011b · measured on the runner, not pushed to the history.

@jdx
jdx merged commit 1f0915b into main Aug 22, 2026
10 checks passed
@jdx
jdx deleted the cursor/fix-count-standing-partialeq-9f61 branch August 22, 2026 02:22
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.

2 participants