Repository navigation
fix(engine): harden apply/bounds validation, fix year overflow, and improve DX helpers - #63
Merged
Merged
Conversation
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
Hardens engine determinism, bounds checking, and state-transition invariants while keeping 100% conformance with RFCs 0001–0005, all 44 conformance scenarios, and the downstream
mclemoreauction.comprivate engine helper contract.Determinism, Bounds & Validation Fixes
1..9999) inRBBB::Timestamp:Timestamp.parseandTimestamp.dumpenforce UTC years1..9999(removing duplicated checks inInitialClosingScheduleandSharedClosingClock), andEngine#extended_closing_timerejects year-9999 extension overflow cleanly insidedecide(invalid_closing_time) instead of returning an accepted decision that failsapply.Engine#applytransition guards: Rejects transitions applied to a closedState, rejects non-monotoniceffective_at(< state.last_effective_at), rejects non-empty event batches without exactly one privileged state-transition event, and preservesapply(state, []) == statecompatibility for rejected-decision event batches.command_idvalues ("", non-string,> 255chars) tonilinEngine#rejectso rejections always satisfyrejection.schema.json.Integeror out-of-rangeexpected_version(e.g.0.0float) asinvalid_command.bid_id: falseinstead of falling back tocommand_id.MAX_SAFE_INTEGERupper bounds onState#version(and guards version exhaustion inEngine#decide/#apply) and on all monetary/integer fields inState#validate!.State#validate!saturation check so arbitrarystanding_minor_units == next_required_minor_units(e.g.10_000) is rejected while preserving genuine ladder-ceiling saturation round-trips.RBBB::InvalidConfiguration(notNoMethodError) forConfiguration.from_h(nil)/ non-Hash input.Timeobjects in addition to ISO 8601 strings forcloses_atinchange_closing_time.Cleanup & Additive DX Helpers
RBBB::UnsupportedFeatureconstant.Decision#transition_event,Decision#public_events, andDecision#privileged_events.#==,#eql?,#hash) onState,Configuration,Event,Decision, andSharedClosingClock.attr_reader :group_id, :unit_idsonSharedClosingClock.Engineby hoistingTWO_DECIMAL_CURRENCIES, callingapply_executions!directly inbuild_bid_decision, and extractingleader_key,transition_snapshot,standing_bid_event, andclosing_time_eventwhile preserving exact names/signatures of:position_priority,:price_positions,:apply_executions!, and:replay_authorizations.Verification
ruby scripts/validate_documents.rb: 21 JSON Schemas, 44 conformance scenarios, OpenAPI/AsyncAPI valid.cd ruby/engine && bundle exec rake: 425 runs, 357,439 assertions, 0 failures, 0 errors, 0 skips;verify_package.rbpassed.