feat(model): numeric primitives (Price, Quantity, Side, ArithmeticError)#51
Merged
Conversation
Approved brainstorming design for the first real oath-model content: Price/Quantity/Side value types, checked exact-domain arithmetic, and ArithmeticError. Reconciles the manifest (drop rust_decimal/uuid/time) and aligns deferred work (zerocopy, Timestamp, symbology, notional) with ADR-0023/0002/0020/0027. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Bite-sized TDD plan (6 tasks) for Price/Quantity/Side/ArithmeticError. All code prototyped and verified against the workspace lints (clippy -D warnings with pedantic/nursery), tests, doctests, cargo deny, and rustfmt. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Removing/adding deps makes Cargo.lock stale; the pre-commit hook runs cargo check --locked, which fails on a stale lock. Tasks 1 and 3 now regenerate and commit Cargo.lock. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Running just mutants / mutants-diff leaves a mutants.out/ directory in the working tree; ignore it (and mutants.out.old/) so it is never committed. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Note both overflow and underflow in the Price/Quantity checked-op summaries (the # Errors sections already did); 'rather than wrapping or panicking' reflects overflow-checks=true. Add a Quantity checked_sub doctest, and de-stale the spec's ADR-0027 reference now that #49 landed. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds four oath-model Numeric Primitives
Changesoath-model Numeric Primitives
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Use `.as_deref().ok()` to compare against `&str` literals instead of allocating owned `String`s via `to_owned()`. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
First real content for
oath-model, the workspace root contract: the exact-domain numeric primitivesPrice(signedi128),Quantity(unsignedu128magnitude),Side(Buy/Sell), andArithmeticError. Checkedconst fnadd/sub that error rather than wrap (ADR-0023),serde-derived (the universal bus bound, ADR-0002/0020/0027), and property-tested. Built spec → plan → TDD per the superpowers workflow.Related Issue
Closes #50
Type of change
Changes
Price,Quantity,Side, andArithmeticError— one module each, re-exported fromlib.rs.const fnchecked_add/checked_subwith correct signed/unsigned overflow→Overflow/Underflowmapping; no bare arithmetic operators exposed.proptesttests: raw round-trip, add/sub inverse,i128::MIN/MAXandu128::MAXboundaries,serde_jsonround-trip over the full numeric range; plus doctests.rust_decimal/uuid/time; addproptest/serde_jsondev-deps; remove the now-emptycargo-macheteignore block.cargo-mutantsoutput (mutants.out*/).docs/superpowers/;CHANGELOG.mdentry.Checklist
just cipasses locally (fmt + lint + test + deny + doc + …)CHANGELOG.mdupdatedMutation testing note
just mutants-diff: 13 caught, 2 surviving. Both survivors are provably equivalent mutants — thePriceoverflow-guard boundary (self.0 > 0/rhs.0 < 0) is unreachable when the operand is0(addition/subtraction can't overflow against0), so>/>=and</<=are behaviorally identical. Independently verified via an exhaustivei8overflow sweep. Left as-is rather than contorting correct, clear code.🤖 Generated with Claude Code
Summary by CodeRabbit