Repository navigation
Commit 5a62fbc
refactor(adapter/copilot): drop unused _event_id param + trim 3 multi-paragraph comments
External review ccusage#13 raised two related items:
## Nit a: Drop unused `_event_id` from `build_aggregate_credit_entry`
The function takes `_event_id: &str` but never uses it — the dedup
key is content-based by design (`credit-aggregate:{session_id}:{nano_aiu}`
omits event_id deliberately, mirroring the per-model credit-only
path). Since this is a private helper with one call site, drop the
parameter entirely rather than passing-and-discarding `&event.id`.
Removed both the parameter declaration in `build_aggregate_credit_entry`
(parser.rs:1040) and the corresponding argument at the call site in
`parse_session_state_file` (parser.rs:884). Pure simplification —
behavior unchanged, no caller exists that passed a meaningful event_id.
## Item 3: Comment-trim pass on three remaining multi-paragraph blocks
Reviewer flagged that despite the recent comment-density work in
`b529041`, three blocks (mode-dispatch table in `usage_entry_to_loaded`,
aggregate-credit guard in `parse_session_state_file`, and the
`build_aggregate_credit_entry` dedup-key doc) still read as design
docs inlined into source. Continued the trim direction the branch has
been moving:
- **`loader.rs` mode-dispatch comment**: 47 lines -> 20 lines. Kept
the load-bearing field-presence invariant, the behavior table, the
free-tier middle-column note, and the synthetic-aggregate bypass
pointer. Dropped: the multi-paragraph era-vs-date justification
(now points to the adapter README), the duplicate "`auto`/`display`
follow this ladder" restatement, and the prose about each cell's
derivation (the table is self-explanatory).
- **`parser.rs` aggregate-credit guard comment**: 47 lines -> 18
lines. Restructured as three labeled invariants (priced-billing
check / `skip_metrics_row` mirror / narrower-than-any-data) with
the load-bearing trade-off (visible over-count vs. silent
under-count) preserved as a single bullet. Dropped: the
multi-paragraph "corpus measurement" prose (the unobserved
forward-compat status is captured in one phrase), the redundant
closing summary, and the Display-no-stack note (already implicit
in the mode-dispatch table).
- **`parser.rs` `build_aggregate_credit_entry` dedup-key doc**:
19 lines -> 9 lines. Kept the structural decision (content-based
key, omits event_id, mirrors per-model path), the load-bearing
trade-off (silent-under-count vs. silent-double-count), and the
README cross-reference. Dropped: the longer real-data explanation
(already in the README's "Resumed sessions and dedup-key design"
section that the new comment now references) and the monotonic-
totals aside.
Net: -85 comment lines, -1 unused parameter. Same load-bearing
rationale, denser presentation. Future maintainers can follow the
adapter README cross-references for the longer context.
## Items NOT actioned this round
- Item 2 (fold OTel removal vs re-file ccusage#1208): user decision.
- Item 4 (confirm product intent on global `--mode api`): maintainer
decision (not the contributor's call).
- Item 5 (`== 0.0` float compare): explicitly "acceptable as-is per
the comment" by the reviewer.
- Nit b (schema oxfmt churn): "not actionable, heads-up".
- Nit c (72 commits, squash-merge): squash-message content already
captured in the PR body's "Behavior changes" section.
## Validation at this tip
- `cd rust && cargo fmt --check` — clean
- `cd rust && cargo clippy --workspace --all-targets -- -D warnings` — clean
- `cd rust && cargo test --workspace` — 368 tests pass (unchanged;
comment-and-param-only change, all parsed-output behavior unchanged)
Refs ccusage#1174.
Co-authored-by: Copilot <[email protected]>1 parent af5dca0 commit 5a62fbc
2 files changed
Lines changed: 48 additions & 109 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
226 | 226 | | |
227 | 227 | | |
228 | 228 | | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
249 | 234 | | |
250 | 235 | | |
251 | 236 | | |
252 | 237 | | |
253 | 238 | | |
254 | 239 | | |
255 | 240 | | |
256 | | - | |
257 | | - | |
258 | | - | |
259 | | - | |
260 | | - | |
261 | | - | |
262 | | - | |
263 | | - | |
264 | | - | |
265 | | - | |
266 | | - | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
267 | 248 | | |
268 | | - | |
269 | | - | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
275 | 253 | | |
276 | 254 | | |
277 | 255 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
824 | 824 | | |
825 | 825 | | |
826 | 826 | | |
827 | | - | |
| 827 | + | |
828 | 828 | | |
829 | | - | |
830 | | - | |
831 | | - | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
832 | 832 | | |
833 | | - | |
834 | | - | |
835 | | - | |
836 | | - | |
837 | | - | |
838 | | - | |
839 | | - | |
840 | | - | |
841 | | - | |
842 | | - | |
843 | | - | |
844 | | - | |
845 | | - | |
846 | | - | |
847 | | - | |
848 | | - | |
849 | | - | |
850 | | - | |
851 | | - | |
852 | | - | |
853 | | - | |
854 | | - | |
855 | | - | |
856 | | - | |
857 | | - | |
858 | | - | |
859 | | - | |
860 | | - | |
861 | | - | |
862 | | - | |
863 | | - | |
864 | | - | |
865 | | - | |
866 | | - | |
867 | | - | |
868 | | - | |
869 | | - | |
870 | | - | |
871 | | - | |
872 | | - | |
873 | | - | |
874 | | - | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
875 | 850 | | |
876 | 851 | | |
877 | 852 | | |
| |||
880 | 855 | | |
881 | 856 | | |
882 | 857 | | |
883 | | - | |
884 | | - | |
885 | | - | |
886 | | - | |
887 | | - | |
888 | | - | |
| 858 | + | |
889 | 859 | | |
890 | 860 | | |
891 | 861 | | |
| |||
1040 | 1010 | | |
1041 | 1011 | | |
1042 | 1012 | | |
1043 | | - | |
1044 | 1013 | | |
1045 | 1014 | | |
1046 | 1015 | | |
| |||
1055 | 1024 | | |
1056 | 1025 | | |
1057 | 1026 | | |
1058 | | - | |
1059 | | - | |
1060 | | - | |
1061 | | - | |
1062 | | - | |
1063 | | - | |
1064 | | - | |
1065 | | - | |
1066 | | - | |
1067 | | - | |
1068 | | - | |
1069 | | - | |
1070 | | - | |
1071 | | - | |
1072 | | - | |
1073 | | - | |
1074 | | - | |
1075 | | - | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
1076 | 1037 | | |
1077 | 1038 | | |
1078 | 1039 | | |
| |||
0 commit comments