40class NativeExecutionConsumer;
70 return left.value == right.value;
73 return !(left == right);
76 return left.value < right.value;
123using SizeBasis = std::variant<CashValue, EquityFraction>;
236using ReductionSize = std::variant<ExplicitUnits, OwnerOpenedUnits, ScopeFraction>;
250using OrderIntent = std::variant<Flatten, Reduce, Transact, ReverseTo, HostSized, Sized>;
314 std::optional<TrailTicks>
ticks = std::nullopt;
317using Trigger = std::variant<Market, Limit, Stop, StopLimit, Trail>;
403using Capacity = std::variant<ImmediateRemaining, PointBudget>;
486 : count_(
count), context_(context), reader_(reader) {}
487 std::uint64_t
count() const noexcept
override {
return count_; }
489 std::uint64_t index,
RequestHandle& out)
const noexcept override;
491 std::uint64_t count_;
501 std::shared_ptr<const OpeningReadback>& out);
523using Owner = std::variant<Independent, WaitForApplied, BindOpening, BindOpenings, BindCohort>;
532using Group = std::variant<NoGroup, Member>;
563 return find(
"label", out);
566 return find(
"comment", out);
571 if (std::holds_alternative<execution::Flatten>(action))
return Flatten{};
572 if (
const auto* transact = std::get_if<order_action::Transact>(&action)) {
573 return Transact{transact->signed_units};
575 const auto& reduce = std::get<order_action::Reduce>(action);
580 std::string label = {},
581 std::string comment = {}) {
586 return std::holds_alternative<Market>(request.trigger)
587 && std::holds_alternative<ImmediateRemaining>(request.capacity)
588 && std::holds_alternative<Independent>(request.owner)
589 && std::holds_alternative<NoGroup>(request.group)
590 && std::holds_alternative<Absolute>(request.anchor);
599 return a.
ordinal == b.ordinal && a.
run == b.run;
609 return a.point.ordinal == b.point.ordinal && a.t == b.t
610 && a.point.interval_index == b.point.interval_index
611 && a.point.effective_time_ms == b.point.effective_time_ms
612 && a.point.provenance == b.point.provenance
613 && a.point.path_phase == b.point.path_phase;
618 return static_cast<std::uint8_t
>(cursor.point.path_phase);
678using Enrollment = std::variant<EnrollmentFromCommand, EnrollmentFromApplied>;
711using ExecutionScope = std::variant<execution::Book, execution::OpeningExposure, SelectedExposure>;
828 std::optional<RequestHandle>
root;
864 const std::optional<RequestHandle>&
predecessor() const noexcept {
881 uint64_t point_ordinal,
882 int64_t effective_time_ms)
noexcept {
883 return point_eligible(live.birth(), point_ordinal, effective_time_ms);
890 if (!std::isfinite(q) || !std::isfinite(step) || step <= 0.0)
return false;
891 const double abs_q = std::abs(q);
892 const double r = abs_q / step;
893 if (!std::isfinite(r))
return false;
894 const double n = std::round(r);
895 if (!std::isfinite(n) || n < 1.0 || n > 0x1p53)
return false;
896 const double g = n * step;
897 if (!std::isfinite(g))
return false;
898 const double err = std::abs(abs_q - g);
899 const double span = std::max(abs_q, std::abs(g));
900 const double ulp = std::nextafter(span, std::numeric_limits<double>::infinity()) - span;
901 const double ulp_bound = 4.0 * ulp;
902 const double half_step = step / 2.0;
903 if (!std::isfinite(err) || !std::isfinite(ulp_bound) || !std::isfinite(half_step))
905 return err <= ulp_bound && err < half_step;
940 std::optional<RequestRejectReason>
reason;
947 std::optional<RequestRejectReason>
reason;
1021 return std::visit([](
const auto& alternative) ->
ExecutionPlan {
1266 return cursor.point.last_traded_close_ms;
1270 return static_cast<std::uint8_t
>(
cursor.point.provenance);
1423 std::uint64_t
size() const noexcept
override {
return length_; }
1427 std::uint64_t length_ = 0;
1447 for (std::size_t i = 0; i < size_ && i < inline_.size(); ++i) {
1448 inline_[i] = std::move(other.inline_[i]);
1450 overflow_ = std::move(other.overflow_);
1454 if (
this != &other) {
1456 size_ = other.size_;
1457 for (std::size_t i = 0; i < size_ && i < inline_.size(); ++i) {
1458 inline_[i] = std::move(other.inline_[i]);
1460 overflow_ = std::move(other.overflow_);
1466 for (std::size_t i = 0; i < size_ && i < inline_.size(); ++i) {
1467 inline_[i] = other.inline_[i];
1469 overflow_ = other.overflow_;
1472 if (
this != &other) {
1474 size_ = other.size_;
1475 for (std::size_t i = 0; i < size_ && i < inline_.size(); ++i) {
1476 inline_[i] = other.inline_[i];
1478 overflow_ = other.overflow_;
1483 std::size_t
size() const noexcept {
return size_; }
1484 bool empty() const noexcept {
return size_ == 0; }
1486 template<
class Event>
1492 if (overflow_.empty() && size_ < inline_.size()) {
1493 inline_[size_++].emplace(std::move(event));
1496 if (overflow_.empty()) {
1497 overflow_.reserve(inline_.size() * 2U);
1498 for (std::size_t i = 0; i < size_; ++i) {
1499 overflow_.push_back(std::move(*inline_[i]));
1503 overflow_.push_back(std::move(event));
1508 for (std::size_t i = 0; i < size_ && i < inline_.size(); ++i) {
1518 return overflow_.empty() ? *inline_[index] : overflow_[index];
1521 return overflow_.empty() ? *inline_[index] : overflow_[index];
1525 std::array<std::optional<CommandEvent>, 2> inline_{};
1526 std::vector<CommandEvent> overflow_{};
1527 std::size_t size_ = 0;
1607 double offset,
double kernel_level)>;
1912 return cohort_receipts_;
1917 return cohort_receipts_base_ + cohort_receipts_.size();
1948 const
std::function<
bool(const
EventId&)>& visit) const;
2000 int64_t decision_time_ms,
2001 uint64_t& next_order_incarnation,
2002 uint64_t& next_timeline_ordinal,
2003 std::optional<
double> quantity_grid =
std::nullopt);
2007 int64_t decision_time_ms,
2008 uint64_t& next_order_incarnation,
2009 uint64_t& next_timeline_ordinal,
2010 std::optional<
double> quantity_grid =
std::nullopt,
2021 uint64_t& next_order_incarnation,
2022 uint64_t& next_timeline_ordinal,
2027 uint64_t& next_order_incarnation,
2028 uint64_t& next_timeline_ordinal,
2042 uint64_t& next_timeline_ordinal);
2058 uint64_t& next_timeline_ordinal,
2059 bool open_activation_grant);
2065 uint64_t& next_timeline_ordinal,
2066 std::optional<Side> cohort_side = std::nullopt,
2075 uint64_t& next_timeline_ordinal,
2076 std::optional<Side> cohort_side,
2078 bool open_activation_grant);
2083 uint64_t& next_timeline_ordinal);
2088 uint64_t& next_timeline_ordinal,
2089 bool open_activation_grant);
2094 uint64_t& next_timeline_ordinal);
2098 uint64_t& next_timeline_ordinal);
2103 std::optional<ExecutionTerms> attempted_terms,
2104 uint64_t& next_timeline_ordinal);
2108 uint64_t& next_timeline_ordinal);
2114 uint64_t& next_timeline_ordinal);
2121 uint64_t& next_timeline_ordinal);
2136 bool open_activation_grant);
2145 uint64_t& next_timeline_ordinal);
2150 uint64_t& next_timeline_ordinal,
2151 bool open_activation_grant);
2160 double resolved_units,
2163 bool* exhausted)
noexcept;
2189 uint64_t& next_timeline_ordinal);
2197 const std::optional<OpeningObservation>& observation,
2198 uint64_t& next_timeline_ordinal,
2203 uint64_t& next_timeline_ordinal);
2206 uint64_t& next_timeline_ordinal);
2231 uint64_t& next_order_incarnation,
2232 uint64_t& next_timeline_ordinal,
2237 uint64_t& next_order_incarnation,
2238 uint64_t& next_timeline_ordinal,
2241 uint64_t& next_timeline_ordinal,
2246 uint64_t& next_timeline_ordinal);
2251 uint64_t& next_timeline_ordinal,
2252 bool open_activation_grant);
2256 uint64_t& next_timeline_ordinal,
2257 std::optional<Side> cohort_side = std::nullopt,
2264 uint64_t& next_timeline_ordinal,
2265 std::optional<Side> cohort_side,
2267 bool open_activation_grant);
2270 uint64_t& next_timeline_ordinal);
2274 std::optional<ExecutionTerms> attempted_terms,
2275 uint64_t& next_timeline_ordinal);
2279 uint64_t& next_timeline_ordinal);
2281 uint64_t& next_timeline_ordinal);
2283 uint64_t& next_timeline_ordinal);
2286 uint64_t& next_timeline_ordinal);
2289 const std::optional<OpeningObservation>& observation,
2290 uint64_t& next_timeline_ordinal,
2295 uint64_t& next_timeline_ordinal);
2298 uint64_t& next_timeline_ordinal);
2301 uint64_t& next_timeline_ordinal);
2308 uint64_t& next_timeline_ordinal,
2309 bool open_activation_grant);
2313 uint64_t& next_timeline_ordinal);
2317 uint64_t& next_timeline_ordinal,
2318 bool open_activation_grant);
2326 bool open_activation_grant)
const noexcept;
2331 bool open_activation_grant)
const noexcept;
2335 bool existing_matching_bit)
const noexcept;
2337 std::optional<Side> cohort_side = std::nullopt)
const noexcept;
2357 friend class ::pineforge::engine_script_run_v19::NativeExecutionConsumer;
2360 static void require_grid(std::optional<double> quantity_grid);
2361 static void require_distinct_counters(uint64_t& next_order_incarnation,
2362 uint64_t& next_timeline_ordinal);
2363 std::optional<RequestRejectReason> validate_request(
2366 const std::optional<RequestHandle>& replace_target)
const;
2370 static std::optional<RequestRejectReason> resolve_tick_spellings(
2375 enum class ReceiptLookup : std::uint8_t { Absent = 0, Present = 1, Conflict = 2 };
2381 std::vector<EventId> inline_ids;
2383 bool external =
false;
2384 uint64_t offset = 0;
2400 std::size_t receipts_first_above(uint64_t retired)
const;
2401 void apply_receipt_base(std::size_t base)
noexcept;
2404 void ensure_receipt_store();
2406 void prepare_codec_frames();
2407 void ensure_chain_segments();
2414 void note_chain_birth(
const CommandEvent& event)
noexcept;
2415 void note_chain_loss(
const LiveRequest& row)
noexcept;
2418 void erase_live(std::size_t index)
noexcept;
2422 bool trail_level_ok(
double best,
double offset,
bool is_buy,
double* stop,
2423 double ladder_tick = 0.0) const noexcept;
2431 bool cohort_exists(
CohortHandle cohort) const noexcept;
2435 void index_committed(const
CommandEvent& event) noexcept;
2438 std::optional<uint64_t> pending_chain_floor() const;
2440 uint64_t usable_ordinal(uint64_t next) const;
2441 uint64_t usable_incarnation(uint64_t next) const;
2445 std::
size_t repriced_position(uint64_t incarnation) const noexcept;
2451 uint64_t* next_timeline_ordinal,
bool open_activation_grant);
2454 uint64_t& next_timeline_ordinal);
2455 TargetKind classify_repriced(uint64_t incarnation,
std::
size_t* live_index) const noexcept;
2456 const
LiveRequest* find_repriced(uint64_t incarnation) const noexcept;
2461 void note_repriced(uint64_t incarnation, uint64_t priority) noexcept;
2463 TargetKind classify_resident(const
RequestHandle& handle,
std::
size_t* live_index) const;
2469 bool bump_epoch() noexcept;
2470 void require_epoch_room() const;
2471 void clear_unbound() noexcept;
2473 struct InstanceBinding {
2474 uint64_t generation = 1;
2475 bool expired =
false;
2477 struct MutationPlan {
2478 std::weak_ptr<InstanceBinding> instance;
2479 uint64_t generation = 0;
2482 std::size_t history_size = 0;
2483 uint64_t last_ordinal = 0;
2484 bool consumed =
false;
2485 InlineCommandEvents events;
2486 std::uint8_t live_change = 0;
2487 std::size_t live_index = 0;
2488 LiveRequest live_row{};
2489 bool consume_incarnation =
false;
2490 uint64_t incarnation_used = 0;
2493 uint64_t skipped_ordinal = 0;
2494 bool add_receipt =
false;
2495 EventId receipt_cause{};
2496 RequestHandle receipt_recipient{};
2498 uint64_t receipt_outcome = 0;
2502 bool chain_segment =
false;
2503 uint64_t chain_event_ordinal = 0;
2504 uint64_t chain_offset = 0;
2505 uint64_t chain_count = 0;
2507 std::optional<InstallError> validate_plan(
const MutationPlan& plan)
const noexcept;
2511 PreparedReplace prepare_replace_kept(std::size_t live_index,
const RequestHandle& staged_target,
2512 Request&& staged, uint64_t ordinal, uint64_t incarnation,
2513 const CommandContext& context, ReplaceOptions options,
2514 MutationPlan&& plan);
2517 template <
bool Kept>
2518 CommandInstalled<ReplaceResult> apply_replace_as(
const RequestHandle& target,
2519 const Request& request,
2520 const CommandContext& context,
2521 uint64_t& next_order_incarnation,
2522 uint64_t& next_timeline_ordinal,
2523 ReplaceOptions options);
2524 CommandInstalled<ReplaceResult> apply_replace_kept(
const RequestHandle& target,
2525 const Request& request,
2526 const CommandContext& context,
2527 uint64_t& next_order_incarnation,
2528 uint64_t& next_timeline_ordinal,
2529 ReplaceOptions options);
2530 LiveRequest kept_successor(std::size_t live_index,
const RequestHandle& staged_target,
2531 Request&& staged, uint64_t ordinal, uint64_t incarnation,
2532 const CommandContext& context, ReplaceOptions options)
const;
2534 MutationPlan begin_plan()
const;
2535 void reserve_plan(
const MutationPlan& plan);
2536 void bind_plan(MutationPlan& plan)
const;
2537 void seal_plan(MutationPlan& plan);
2538 PreparedMutation finish_mutation(MutationPlan plan);
2551 void begin_direct()
const;
2552 void seal_direct(std::size_t events,
bool push_live,
bool add_receipt,
2553 bool consume_incarnation,
bool chain_segment =
false);
2556 void note_chain_segment(uint64_t event_ordinal, uint64_t offset, uint64_t count)
noexcept;
2557 template <
class Event>
2558 void append_direct(Event&& event,
bool consume_incarnation);
2559 EventRange finish_direct(std::size_t first)
noexcept;
2560 template <
class Event>
2561 Installed end_direct(std::size_t live_index, Event&& event);
2566 struct ExecutionValues {
2567 std::size_t live_index = 0;
2568 uint64_t ordinal = 0;
2569 double filled = 0.0;
2570 bool flatten =
false;
2571 bool units_exhausted =
false;
2573 Allowance allowance_after = AllowanceUnset{};
2576 Preparation<ExecutionValues> execution_values(
const RequestHandle& target,
2577 const ExecutionProposal& proposal,
2578 uint64_t& next_timeline_ordinal,
2579 bool open_activation_grant);
2585 struct JournalStore;
2586 struct ReceiptStore;
2587 struct ChainSegments;
2601 std::size_t spilled_count() const noexcept;
2602 const std::
string& scratch_directory() const noexcept;
2608 uint64_t spilled_priority = 0;
2610 void make_book_room();
2611 bool promote_book_row(uint64_t incarnation, std::size_t* index);
2612 const LiveRequest* spilled_row(uint64_t incarnation)
const;
2613 std::shared_ptr<LiveRequest> spilled_held(uint64_t incarnation)
const;
2614 const LiveRequest* find_resident(
const RequestHandle& handle)
const noexcept;
2617 uint64_t book_generation() const noexcept;
2623 std::shared_ptr<const LiveRequest> hold_scanned(const RequestHandle& handle, uint64_t at,
2624 uint64_t generation) const;
2625 void forget_repriced(uint64_t incarnation) noexcept;
2626 BookCursor book_begin() const;
2627 bool book_done(const BookCursor& cursor) const noexcept;
2628 bool book_next_spilled(const BookCursor& cursor) const noexcept;
2629 void book_step(BookCursor& cursor) const;
2630 const LiveRequest& live_back() const;
2633 template <class Visit>
2634 void visit_book(Visit&& visit) const;
2636 RunIdentity identity_;
2637 std::shared_ptr<InstanceBinding> instance_;
2638 std::vector<LiveRequest> live_;
2639 std::shared_ptr<BookSpill> book_spill_;
2640 uint64_t last_ordinal_ = 0;
2641 uint64_t last_incarnation_ = 0;
2642 uint64_t epoch_ = 0;
2647 std::shared_ptr<JournalStore> journal_;
2648 std::
size_t history_base_ = 0;
2649 uint64_t retired_through_ = 0;
2653 static constexpr uint64_t kNoChainFloor = std::numeric_limits<uint64_t>::max();
2654 mutable uint64_t chain_floor_ = kNoChainFloor;
2655 mutable
bool chain_floor_exact_ = true;
2656 std::shared_ptr<ChainSegments> chain_segments_;
2659 struct SuccessorRootIndex;
2660 void reserve_successor_root();
2661 void append_successor_root(uint64_t incarnation, uint64_t root) noexcept;
2662 std::optional<uint64_t> successor_root(uint64_t incarnation) const;
2663 std::vector<std::pair<uint64_t, uint64_t>> issued_;
2664 std::shared_ptr<SuccessorRootIndex> successor_roots_;
2672 std::vector<std::pair<uint64_t, uint64_t>> repriced_;
2677 std::shared_ptr<ReceiptStore> receipt_store_;
2678 std::uint64_t next_cohort_handle_ = 1;
2682 std::map<std::uint64_t, CohortRoster> cohorts_;
2683 std::vector<CohortReceipt> cohort_receipts_;
2686 std::
size_t cohort_receipts_base_ = 0;
2706 pointer operator->() const noexcept {
return &**
this; }
2709 auto previous = *
this;
2714 return left.core_ == right.core_ && left.index_ == right.index_;
2717 return !(left == right);
2723 : core_(core), index_(index) {}
2725 std::size_t index_ = 0;
2729 std::size_t
size() const noexcept {
2730 return static_cast<std::size_t
>(core_->next_cohort_handle_ - 1);
2765 reference operator*()
const {
return core_->history_at(position_); }
2781 position_ =
static_cast<std::size_t
>(
static_cast<difference_type>(position_) + offset);
2803 return left.position_ == right.position_;
2806 return left.position_ != right.position_;
2809 return left.position_ < right.position_;
2812 return left.position_ > right.position_;
2815 return left.position_ <= right.position_;
2818 return left.position_ >= right.position_;
2824 : core_(core), position_(position) {}
2826 std::size_t position_ = 0;
2834 std::size_t
size() const noexcept {
return core_->history_end() - core_->history_base(); }
2837 return static_cast<std::size_t
>(std::numeric_limits<std::ptrdiff_t>::max()) / 4;
2841 return core_->history_at(core_->history_base() + index);
2844 if (index >=
size())
throw std::out_of_range(
"native journal index is not retained");
2845 return (*
this)[index];
2853 operator std::vector<CommandEvent>()
const {
return std::vector<CommandEvent>(
begin(),
end()); }
2887 std::shared_ptr<const LiveRequest>
hold()
const;
2895 return left.core_ == right.core_ && left.cursor_.r == right.cursor_.r
2896 && left.cursor_.at == right.cursor_.at;
2899 return !(left == right);
2904 friend class ::pineforge::engine_script_run_v19::NativeExecutionConsumer;
2906 : core_(core), cursor_(cursor) {}
2909 uint64_t spilled_at() const noexcept {
return held_ ? cursor_.at : 0; }
2913 BookCursor cursor_{};
2914 std::shared_ptr<LiveRequest> held_;
2922 std::size_t
size() const noexcept {
return core_->live_size(); }
2932 operator std::vector<LiveRequest>()
const;
2948 explicit operator
bool() const noexcept;
2955 std::unique_ptr<Impl> impl_;
2967 explicit operator
bool() const noexcept;
2974 std::unique_ptr<Impl> impl_;
2986 explicit operator
bool() const noexcept;
2993 std::unique_ptr<Impl> impl_;
3005 explicit operator
bool() const noexcept;
3010 std::unique_ptr<Impl> impl_;
3022 explicit operator
bool() const noexcept;
3027 std::unique_ptr<Impl> impl_;
3031static_assert(
std::is_nothrow_move_constructible_v<
Request>);
3032static_assert(
std::is_nothrow_move_assignable_v<
Request>);
3063 return static_cast<std::size_t
>(value.value ^ (value.value >> 32));
All reads borrow store/version; no owning row or text reconstruction.
ScratchHandle version() const noexcept
PayloadReadback() noexcept=default
ScratchStatus find(std::string_view name, PayloadField &out) const noexcept
Almost every prepared command yields one history event.
CommandEvent & front() noexcept
CommandEvent & operator[](std::size_t index) noexcept
void emplace_back(Event &&event)
InlineCommandEvents(const InlineCommandEvents &other)
const CommandEvent & front() const noexcept
const CommandEvent & operator[](std::size_t index) const noexcept
std::size_t size() const noexcept
InlineCommandEvents()=default
void push_back(CommandEvent event)
InlineCommandEvents & operator=(InlineCommandEvents &&other) noexcept
bool empty() const noexcept
InlineCommandEvents(InlineCommandEvents &&other) noexcept
InlineCommandEvents & operator=(const InlineCommandEvents &other)
std::uint64_t size() const noexcept override
JournalRecordSource(const CommandEvent &) noexcept
detail::ScratchStatus read(std::uint64_t, detail::ScratchBuffer) const noexcept override
Borrowed through the enclosing command/evaluation and any prepare/install pair that copies its Target...
virtual detail::ScratchStatus observation_at(std::uint64_t index, OpeningObservation &out) const noexcept=0
virtual std::uint64_t count() const noexcept=0
virtual ~OpeningObservationReadback() noexcept=default
Immutable membership, independent of a source scratch scope.
virtual detail::ScratchStatus opening_at(std::uint64_t index, RequestHandle &out) const noexcept=0
virtual ~OpeningReadback() noexcept=default
virtual std::uint64_t count() const noexcept=0
PreparedCancel() noexcept
const CancelResult & predicted() const
EventId predicted_event_id() const
friend class WorkingRequestCore
PreparedExecution() noexcept
friend class WorkingRequestCore
PreparedMutation() noexcept
friend class WorkingRequestCore
EventId predicted_event_id() const
PreparedReplace() noexcept
const ReplaceResult & predicted() const
friend class WorkingRequestCore
PreparedSubmit() noexcept
const SubmitResult & predicted() const
EventId predicted_event_id() const
friend class WorkingRequestCore
RequestReadback(detail::PayloadReadback view) noexcept
detail::ScratchStatus comment(detail::PayloadField &out) const noexcept
detail::ScratchStatus label(detail::PayloadField &out) const noexcept
RequestReadback() noexcept=default
std::ptrdiff_t difference_type
const_iterator & operator++() noexcept
friend bool operator==(const const_iterator &left, const const_iterator &right) noexcept
const CohortRoster * pointer
const_iterator() noexcept=default
const_iterator operator++(int)
std::input_iterator_tag iterator_category
friend bool operator!=(const const_iterator &left, const const_iterator &right) noexcept
const CohortRoster & reference
const_iterator begin() const noexcept
bool empty() const noexcept
CohortRoster operator[](std::size_t index) const
const_iterator end() const noexcept
std::size_t size() const noexcept
friend class WorkingRequestCore
const_iterator & operator++() noexcept
const_iterator & operator-=(difference_type offset) noexcept
const_iterator & operator--() noexcept
friend bool operator==(const const_iterator &left, const const_iterator &right) noexcept
friend bool operator>(const const_iterator &left, const const_iterator &right) noexcept
const CommandEvent * pointer
const_iterator() noexcept=default
const_iterator & operator+=(difference_type offset) noexcept
friend const_iterator operator+(const_iterator iterator, difference_type offset) noexcept
std::ptrdiff_t difference_type
friend bool operator>=(const const_iterator &left, const const_iterator &right) noexcept
friend const_iterator operator+(difference_type offset, const_iterator iterator) noexcept
const_iterator operator--(int) noexcept
friend bool operator<(const const_iterator &left, const const_iterator &right) noexcept
reference operator[](difference_type offset) const
const_iterator operator++(int) noexcept
friend bool operator!=(const const_iterator &left, const const_iterator &right) noexcept
friend difference_type operator-(const const_iterator &left, const const_iterator &right) noexcept
const CommandEvent & reference
friend bool operator<=(const const_iterator &left, const const_iterator &right) noexcept
pointer operator->() const
friend const_iterator operator-(const_iterator iterator, difference_type offset) noexcept
std::random_access_iterator_tag iterator_category
const_iterator cend() const noexcept
const CommandEvent & reference
bool empty() const noexcept
const CommandEvent & operator[](std::size_t index) const
const CommandEvent & at(std::size_t index) const
std::size_t size() const noexcept
const_iterator begin() const noexcept
std::size_t max_size() const noexcept
const_iterator end() const noexcept
const_iterator cbegin() const noexcept
const CommandEvent & front() const
const CommandEvent & back() const
friend class WorkingRequestCore
std::size_t capacity() const noexcept
const CommandEvent & const_reference
const LiveRequest * pointer
const_iterator operator++(int)
std::forward_iterator_tag iterator_category
friend bool operator==(const const_iterator &left, const const_iterator &right) noexcept
const_iterator & operator++()
std::ptrdiff_t difference_type
const LiveRequest & reference
std::shared_ptr< const LiveRequest > hold() const
The row the iterator stands on, held as hold_live holds it: a spilled row stays valid as long as the ...
friend bool operator!=(const const_iterator &left, const const_iterator &right) noexcept
const_iterator() noexcept=default
const LiveRequest & at(std::size_t rank) const
std::size_t size() const noexcept
const_iterator cbegin() const
const LiveRequest & back() const
const_iterator cend() const
const LiveRequest & const_reference
const_iterator begin() const
const LiveRequest & operator[](std::size_t rank) const
const_iterator end() const
bool empty() const noexcept
const LiveRequest & front() const
friend class WorkingRequestCore
const LiveRequest & reference
const CommandEvent & history_at(std::size_t absolute) const
The event at an absolute journal position; std::out_of_range when it is not retained.
Preparation< Installed > apply_margin_call(const MarginCallEvent &event, uint64_t &next_timeline_ordinal)
bool refresh_allowance(const RequestHandle &target, const EvaluationContext &context, const TargetObservation &observation, uint64_t &next_timeline_ordinal, bool open_activation_grant)
The timeline-handed refresh under the open activation grant.
const LiveRequest * find_live(const RequestHandle &handle) const
void waiting_children(const RequestHandle &parent, std::vector< RequestHandle > &out) const
Preparation< PreparedMutation > prepare_evaluation(const RequestHandle &target, const EvaluationContext &context, const TargetObservation &observation, uint64_t &next_timeline_ordinal)
LiveView live() const noexcept
The working book, in queue order: ascending LiveRequest::priority, which is incarnation order until a...
Preparation< PreparedExecution > prepare_execution(const RequestHandle &target, const ExecutionProposal &proposal, uint64_t &next_timeline_ordinal)
const CommandEvent * event_at(const EventId &id) const
void visit_group_recipients(const EventId &, void *, HandleVisitor) const
Synchronous queue-order reads.
friend class PreparedReplace
void set_successor_roots_directory(const std::string &directory)
WorkingRequestCore(RunIdentity identity)
uint64_t retired_through() const noexcept
The ordinal of the newest retired event, 0 while none is.
void visit_bound_close_handles(void *, HandleVisitor) const
friend class PreparedExecution
std::size_t prior_adjustment_count(const EventId &resolution) const
How many prior adjustment ids that event spent (0 when none or unknown).
Preparation< std::monostate > check_execution(const RequestHandle &target, const ExecutionProposal &proposal, uint64_t &next_timeline_ordinal)
CommandInstalled< ReplaceResult > apply_replace(const RequestHandle &target, const Request &request, const CommandContext &context, uint64_t &next_order_incarnation, uint64_t &next_timeline_ordinal, ReplaceOptions options={})
Preparation< Installed > apply_trigger(const RequestHandle &target, const TriggerTransition &transition, DriverEligibilityClass driver_class, uint64_t &next_timeline_ordinal, std::optional< Side > cohort_side=std::nullopt, const ActivationGrid &grid={})
bool refresh_allowance(const RequestHandle &target, const EvaluationContext &context, const TargetObservation &observation)
PreparedReplace prepare_replace(const RequestHandle &target, const Request &request, const CommandContext &context, uint64_t &next_order_incarnation, uint64_t &next_timeline_ordinal, ReplaceOptions options={})
Preparation< Installed > apply_parent_terminal(const EventId &terminal_or_replaced, const RequestHandle &child, uint64_t &next_timeline_ordinal)
InstallResult install_execution(PreparedExecution &&prepared, const CommittedExecutionFacts &facts) noexcept
std::size_t live_size() const noexcept
How many requests are live, resident or not, in O(1); and the request at queue rank rank (std::out_of...
CommandInstalled< CancelResult > apply_cancel(const RequestHandle &target, uint64_t &next_timeline_ordinal, CancelReason reason=CancelReason::User)
CohortView cohorts() const noexcept
Logical roster sequence in allocation order, including empty rosters whose members have been removed.
TailWindowStats tail_window_stats() const noexcept
std::size_t retire_cohort_receipts(std::size_t through) noexcept
Drop the prefix strictly below the absolute position through, clamped to the window.
bool evaluation_eligible(const LiveRequest &live, const EvaluationContext &context) const noexcept
Preparation< Installed > apply_risk_event(const NativeRiskEvent &event, uint64_t &next_timeline_ordinal)
friend detail::ScratchStatus append_journal_record(WorkingRequestCore &, const detail::ScratchByteSource &) noexcept
Preparation< PreparedMutation > prepare_risk_event(const NativeRiskEvent &event, uint64_t &next_timeline_ordinal)
Append one NativeRiskEvent to the immutable history.
Preparation< PreparedMutation > prepare_terms(const RequestHandle &target, const EvaluationContext &context, const TermsResolvedInput &input, uint64_t &next_timeline_ordinal)
bool cohort_contains(CohortHandle cohort, const RequestHandle &opening) const
bool book_spilled() const noexcept
Whether some live rows are outside the heap: live_at and live_back then walk the book in queue order ...
static constexpr std::size_t kInlineAdjustmentIds
The longest chain whose ids an event still carries inline.
bool working_is_buy(const LiveRequest &live, std::optional< Side > cohort_side=std::nullopt) const noexcept
std::size_t group_effect_receipt_base() const noexcept
Group-effect keys in cause/commit order, retaining [base, count).
EligibilityFacts eligibility_facts(const LiveRequest &live, const EvaluationContext &context, bool open_activation_grant) const noexcept
eligibility_facts and evaluation_eligible under the open activation grant of prepare_evaluation: the ...
bool refresh_allowance(const RequestHandle &target, const EvaluationContext &context, const TargetObservation &observation, uint64_t &next_timeline_ordinal)
The same refresh, handed the run's timeline: an unbound close that carried a binding the book still h...
const std::vector< std::pair< uint64_t, uint64_t > > & issued_incarnations() const noexcept
The incarnations this run issued – every accepted request and every replace successor – as disjoint a...
Preparation< PreparedMutation > prepare_evaluation(const RequestHandle &target, const EvaluationContext &context, const TargetObservation &observation, uint64_t &next_timeline_ordinal, bool open_activation_grant)
The same preparation under an explicit open activation grant: the caller vouches, for this handle alo...
std::vector< RequestHandle > waiting_children(const RequestHandle &parent) const
friend class PreparedCancel
InstalledCommand< SubmitResult > install_submit(PreparedSubmit &&prepared) noexcept
InstallResult apply_execution(const RequestHandle &target, const ExecutionProposal &proposal, const CommittedExecutionFacts &facts, uint64_t &next_timeline_ordinal, bool open_activation_grant)
friend class PreparedMutation
std::size_t retire_history(uint64_t through_ordinal)
Retire the journal prefix whose ordinals are <= through_ordinal.
void cohort_add(CohortHandle cohort, RequestHandle origin)
void visit_waiting_children(const RequestHandle &, void *, HandleVisitor) const
std::size_t history_base() const noexcept
How many events have been retired from the front of the journal.
Preparation< PreparedMutation > prepare_match_rejected(const RequestHandle &target, const EvaluationContext &context, MatchRejectReason reason, uint64_t &next_timeline_ordinal)
bool refresh_allowance(const RequestHandle &target, const EvaluationContext &context, const TargetObservation &observation, bool open_activation_grant)
refresh_allowance under the open activation grant of prepare_evaluation.
void refresh_point_allowances(uint64_t point, const PositionIdentity &position)
Consumer-only no-event form of the ordinary allowance refresh.
bool carry_book_read_failure(std::exception_ptr failure) const noexcept
A read of the book's spilled rows that failed where its reader cannot throw (a noexcept fold of the b...
bool refresh_cohort_allowance(const RequestHandle &target, const EvaluationContext &context, const TargetObservation &observation)
const LiveRequest & live_at(std::size_t rank) const
JournalView history() const noexcept
The command journal's retained window, oldest first.
friend const detail::ScratchReadback & journal_readback(const WorkingRequestCore &)
Preparation< PreparedMutation > prepare_match_rejected(const RequestHandle &target, const EvaluationContext &context, MatchRejectReason reason, std::optional< ExecutionTerms > attempted_terms, uint64_t &next_timeline_ordinal)
InstalledCommand< CancelResult > install_cancel(PreparedCancel &&prepared) noexcept
PreparedSubmit prepare_submit(const Request &request, const CommandContext &context, uint64_t &next_order_incarnation, uint64_t &next_timeline_ordinal, RequestOrigin origin=RequestOrigin::Host)
Consumer-only typed prepare/install.
Preparation< PreparedMutation > prepare_no_effect(const RequestHandle &target, const EvaluationContext &context, uint64_t &next_timeline_ordinal)
friend void bind_journal_codec(WorkingRequestCore &, detail::CommandScratchStore &)
InstalledCommand< ReplaceResult > install_replace(PreparedReplace &&prepared) noexcept
Preparation< PreparedMutation > prepare_bound_expiry(const EventId &physical_cause, const RequestHandle &child, const TargetObservation &observation, uint64_t &next_timeline_ordinal)
Preparation< Installed > apply_owner_applied(const EventId &applied, const RequestHandle &child, const std::optional< OpeningObservation > &observation, uint64_t &next_timeline_ordinal, const ArmContext &arm={})
WorkingRequestCore(RunIdentity identity, TailWindowConfig windows)
void reserve(std::size_t expected_events)
WorkingRequestCore(RunIdentity identity, CacheCapacity successor_roots, CacheCapacity receipts, CacheCapacity chain_segments)
Inclusive committed-row read-cache allowances.
Preparation< Installed > apply_evaluation(const RequestHandle &target, const EvaluationContext &context, const TargetObservation &observation, uint64_t &next_timeline_ordinal, bool open_activation_grant)
apply_evaluation under the open activation grant of prepare_evaluation.
ReplaceResult replace(const RequestHandle &target, const Request &request, int64_t decision_time_ms, uint64_t &next_order_incarnation, uint64_t &next_timeline_ordinal, std::optional< double > quantity_grid=std::nullopt, ReplaceOptions options={})
Preparation< Installed > apply_match_rejected(const RequestHandle &target, const EvaluationContext &context, MatchRejectReason reason, std::optional< ExecutionTerms > attempted_terms, uint64_t &next_timeline_ordinal)
void bound_close_handles(std::vector< RequestHandle > &out) const
Preparation< std::monostate > check_execution(const RequestHandle &target, const ExecutionProposal &proposal, uint64_t &next_timeline_ordinal, bool open_activation_grant)
check_execution and apply_execution under the open activation grant of prepare_evaluation.
BookLookupReads book_lookup_reads() const noexcept
GroupEffectReceipt group_effect_receipt(std::size_t index) const
friend class PreparedSubmit
Preparation< PreparedMutation > prepare_group_effect(const EventId &applied, const RequestHandle &recipient, uint64_t &next_timeline_ordinal)
detail::ReadThroughCacheStats tail_read_cache_stats(TailWindowKind kind) const noexcept
std::vector< RequestHandle > group_recipients(const EventId &applied) const
The live siblings an applied member's fill reaches – its group, another cohort, born before the fill;...
std::size_t cohort_receipt_base() const noexcept
SubmitResult submit(const Request &request, int64_t decision_time_ms, uint64_t &next_order_incarnation, uint64_t &next_timeline_ordinal, std::optional< double > quantity_grid=std::nullopt)
R1 producer convenience: prepare then install one command.
std::size_t group_effect_receipt_count() const noexcept
Preparation< Installed > apply_group_effect(const EventId &applied, const RequestHandle &recipient, uint64_t &next_timeline_ordinal)
bool trigger_permits_driver(const Trigger &trigger, const TriggerState &state, DriverEligibilityClass driver_class, bool existing_matching_bit) const noexcept
bool has_waiting_children(const RequestHandle &parent) const
Preparation< PreparedMutation > prepare_trigger(const RequestHandle &target, const TriggerTransition &transition, DriverEligibilityClass driver_class, uint64_t &next_timeline_ordinal, std::optional< Side > cohort_side, const ActivationGrid &grid, bool open_activation_grant)
prepare_trigger under the open activation grant of prepare_evaluation: the cursor test every trigger ...
InstallResult install_mutation(PreparedMutation &&prepared) noexcept
static Allowance evaluated_allowance(const LiveRequest &live, uint64_t point) noexcept
The allowance that prepare_evaluation would install for this point.
InstallResult apply_execution(const RequestHandle &target, const ExecutionProposal &proposal, const CommittedExecutionFacts &facts, uint64_t &next_timeline_ordinal)
Preparation< Installed > apply_no_effect(const RequestHandle &target, const EvaluationContext &context, uint64_t &next_timeline_ordinal)
Preparation< PreparedMutation > prepare_owner_applied(const EventId &applied, const RequestHandle &child, const std::optional< OpeningObservation > &observation, uint64_t &next_timeline_ordinal, const ArmContext &arm={})
arm carries the materialization facts of an anchored leg (the price tick a rounded anchor snaps to,...
const RunIdentity & identity() const noexcept
std::size_t cohort_receipt_count() const noexcept
Every cohort receipt this run committed, retained or not.
Preparation< PreparedMutation > prepare_trigger(const RequestHandle &target, const TriggerTransition &transition, DriverEligibilityClass driver_class, uint64_t &next_timeline_ordinal, std::optional< Side > cohort_side=std::nullopt, const ActivationGrid &grid={})
grid carries the run's activation grid (ActivationGrid); the default is the raw rule,...
CancelResult cancel(const RequestHandle &target, uint64_t &next_timeline_ordinal)
Preparation< PreparedMutation > prepare_parent_terminal(const EventId &terminal_or_replaced, const RequestHandle &child, uint64_t &next_timeline_ordinal)
TailWindowConfig tail_window_config() const noexcept
std::size_t history_end() const noexcept
The absolute journal length: every event this run has committed, retained or not.
const std::map< std::uint64_t, CohortRoster > & nonempty_cohorts() const noexcept
Borrow the rosters holding origins, in ascending cohort-handle order.
uint64_t last_ordinal() const noexcept
The core's two durable counters: the ordinal of the last committed event and the last incarnation a c...
std::shared_ptr< const LiveRequest > hold_live(const RequestHandle &handle) const
find_live for a reader that keeps the row across further reads of the book.
const std::vector< CohortReceipt > & cohort_receipts() const noexcept
The retained cohort-receipt window, in command order.
Preparation< PreparedExecution > prepare_execution(const RequestHandle &target, const ExecutionProposal &proposal, uint64_t &next_timeline_ordinal, bool open_activation_grant)
prepare_execution under the open activation grant of prepare_evaluation.
void cohort_remove(CohortHandle cohort, RequestHandle origin)
Preparation< PreparedMutation > prepare_margin_call(const MarginCallEvent &event, uint64_t &next_timeline_ordinal)
Append one MarginCallEvent to the immutable history.
void reset(RunIdentity identity)
static bool effective_host_units(const PendingAdjustments &pending, double resolved_units, double *deduction, double *after, bool *exhausted) noexcept
Pure arithmetic over the cached pending total.
Preparation< Installed > apply_terms(const RequestHandle &target, const EvaluationContext &context, const TermsResolvedInput &input, uint64_t &next_timeline_ordinal)
void bind_scratch_slab(const std::shared_ptr<::pineforge::detail::ScratchSlab > &slab)
uint64_t last_incarnation() const noexcept
bool visit_prior_adjustments(const EventId &resolution, const std::function< bool(const EventId &)> &visit) const
The prior adjustment ids a TermsResolvedEvent or QuantityBoundEvent spent, in chain order,...
bool evaluation_eligible(const LiveRequest &live, const EvaluationContext &context, bool open_activation_grant) const noexcept
void rethrow_book_read_failure() const
Throws the failure carry_book_read_failure kept, if any.
PreparedCancel prepare_cancel(const RequestHandle &target, uint64_t &next_timeline_ordinal, CancelReason reason=CancelReason::User)
reason lets the kernel withdraw its own request under the durable Superseded receipt.
EligibilityFacts eligibility_facts(const LiveRequest &live, const EvaluationContext &context) const noexcept
void group_recipients(const EventId &applied, std::vector< RequestHandle > &out) const
The same three lists written over out, whose capacity a caller that keeps it reuses (R5 lane L3): the...
Preparation< Installed > apply_evaluation(const RequestHandle &target, const EvaluationContext &context, const TargetObservation &observation, uint64_t &next_timeline_ordinal)
Preparation< Installed > apply_trigger(const RequestHandle &target, const TriggerTransition &transition, DriverEligibilityClass driver_class, uint64_t &next_timeline_ordinal, std::optional< Side > cohort_side, const ActivationGrid &grid, bool open_activation_grant)
apply_trigger under the open activation grant of prepare_evaluation; every parameter is explicit,...
CommandInstalled< SubmitResult > apply_submit(const Request &request, const CommandContext &context, uint64_t &next_order_incarnation, uint64_t &next_timeline_ordinal, RequestOrigin origin=RequestOrigin::Host)
The direct forms (R5 lane L3).
CohortHandle cohort_open()
Command-boundary roster maintenance.
Preparation< Installed > apply_bound_expiry(const EventId &physical_cause, const RequestHandle &child, const TargetObservation &observation, uint64_t &next_timeline_ordinal)
std::vector< RequestHandle > bound_close_handles() const
std::variant< Flatten, order_action::Reduce, order_action::Transact > Action
std::variant< ExplicitUnits, OwnerOpenedUnits, ScopeFraction > ReductionSize
How much a Reduce takes: literal units, the owner's own opening, or a fraction of the bound scope.
std::variant< T, NoChange, PreparationError > Preparation
std::variant< PendingNone, PendingDeferred > PendingAdjustments
bool quantity_on_grid(double q, double step) noexcept
v2 exact binary64 grid: r=abs(q)/s, n=round(r) half away from zero, g=n*s.
Request market_request(execution::Action action, std::string label={}, std::string comment={})
bool has_market_defaults(const Request &request) noexcept
std::variant< Independent, WaitForApplied, BindOpening, BindOpenings, BindCohort > Owner
detail::ScratchStatus decode_journal_record(const detail::ScratchByteSource &, detail::ScratchBuffer, CommandEvent &)
std::variant< CashValue, EquityFraction > SizeBasis
The two bases a Sized intent may name.
std::variant< AcceptedEvent, RejectedEvent, ReplacedEvent, ReplaceRejectedEvent, CancelledEvent, NotWorkingEvent, InvalidHandleEvent, NoEffectEvent, MatchRejectedEvent, ExecutionAppliedEvent, CloseBoundEvent, ActivatedEvent, ReservationReducedEvent, DeferredGroupAdjustmentEvent, QuantityBoundEvent, ArmedEvent, TermsResolvedEvent, MarginCallEvent, NativeRiskEvent > CommandEvent
Every alternative of one request's history, as one value.
MatchRejectReason
Why a CANDIDATE was refused at a matching point.
@ UnrepresentableQuantity
The settlement's inspection answered execution::Status:: UnrepresentableQuantity: a close split binar...
@ RiskLimit
An opening refused while the run spec's generic risk limits are blocking (L9).
std::uint64_t opening_observation_count(const TargetObservation &) noexcept
ScopeClaim
Gross claims the whole bound scope; NetOfSiblings first subtracts the units already claimed by the li...
NativeArmVisibility
Whether an owner-related request that arms is a working order before its arm.
std::variant< Market, Limit, Stop, StopLimit, Trail > Trigger
SizePrice
WHICH price the basis is converted at.
std::shared_ptr< const RequestDefinition > DefinitionRef
std::variant< Flatten, Reduce, Transact, ReverseTo, HostSized, Sized > OrderIntent
What a request does.
RequestOrigin
Who authored a request.
detail::ScratchStatus freeze_openings(const RunIdentity &, const OpeningReadback &, std::shared_ptr< const OpeningReadback > &out)
Freeze and canonicalize a same-run, unique stream.
SizeTime
AtMatch resolves the basis at the matching candidate; AtAcceptance freezes the resolved units when th...
std::function< std::optional< double >( const LiveRequest &leg, const ExecutionAppliedEvent &owner_fill, Side leg_side, double offset, double kernel_level)> AnchoredLevelResolver
The one policy point of an anchored materialization.
ExecutionGridPolicy
Resolved host sizing normally remains subject to the run's quantity grid.
std::variant< NoGroup, Member > Group
bool operator==(CohortHandle left, CohortHandle right) noexcept
std::variant< PositionFlat, PositionNonflat > PositionIdentity
std::variant< CommandInstalled< R >, InstallError > InstalledCommand
std::variant< Absolute, FromOwnerFill > TriggerAnchor
RiskLimitKind
Which generic risk limit of NativeRunSpec::risk a NativeRiskEvent reports.
std::variant< ImmediateRemaining, PointBudget > Capacity
bool operator<(CohortHandle left, CohortHandle right) noexcept
RequestRejectReason
Why an acceptance was refused, on a Rejected SubmitResult.
@ PlacementAdmission
A Sized{SizeTime::AtAcceptance} whose acceptance-resolved quantity does not pass the run's opening ad...
std::uint64_t opening_count(const std::vector< RequestHandle > &, const OpeningReadback *) noexcept
JournalRecordSource encode_journal_record(const CommandEvent &) noexcept
ScopeBasis
Which measurement of the bound scope the fraction is taken of.
detail::ScratchStatus opening_observation_at(const TargetObservation &, std::uint64_t, OpeningObservation &) noexcept
@ ConfirmedAfterCalculationClose
void(*)(void *, const RequestHandle &) HandleVisitor
NativeAnchorRounding
How a materialized anchored level is snapped onto the run's price tick ladder (NativeRunSpec::price_t...
bool point_eligible(const LiveRequest &live, uint64_t point_ordinal, int64_t effective_time_ms) noexcept
Whether a request may be considered at this driver point: the point's ordinal must be strictly past t...
std::variant< AllowanceUnset, AllowanceUnits, AllowanceAllScope, AllowanceDeferred > Allowance
std::variant< BeginTrailTracking, ObserveTrailExtremum, ActivateStop, ActivateStopLimit, ActivateTrail > TriggerTransition
CancelReason
Why a request left the book.
@ Superseded
A kernel-originated request the kernel itself withdrew: the liquidation level or its units moved,...
@ NonrepresentableQuantity
@ UnrepresentableReservation
A group deduction's pending total that overflows binary64 (or a non-finite reservation,...
std::variant< execution::Book, execution::OpeningExposure, SelectedExposure > ExecutionScope
What one execution acted on: the whole book, one opening's exposure, or a bound selection.
NativeArmFirstMatch
When an armed request may first match.
std::variant< BookTransaction, Wait, ArmedTransaction, UnboundBookClose, BookClose, OpeningClose, OpeningsClose, CohortClose > Authority
execution::Flatten Flatten
std::variant< Installed, InstallError > InstallResult
ExecutionPlan to_execution_plan(const execution::Action &action)
detail::ScratchStatus append_journal_record(WorkingRequestCore &, const detail::ScratchByteSource &) noexcept
OrderIntent intent_from_physical(const execution::Action &action)
NativeCandidatePriceKind
Which price a candidate is being offered at: the point's own price, or the request's trigger level (a...
const detail::ScratchReadback & journal_readback(const WorkingRequestCore &)
std::variant< RemainingUnbound, RemainingFlattenAll, RemainingUnits, RemainingDeferred, NoTarget > Remaining
std::variant< RemainingProjectionUnbound, RemainingProjectionFlattenAll, RemainingProjectionUnits, RemainingProjectionDeferred, RemainingProjectionNoTarget > RemainingProjection
bool operator!=(CohortHandle left, CohortHandle right) noexcept
std::variant< execution::Flatten, order_action::Reduce, order_action::Transact, execution::ReverseTo > ExecutionPlan
The settlement shape one execution takes.
NativeArmScope
What an armed CLOSING request (Reduce, Flatten, a HostSized close) closes.
std::uint8_t display_waypoint(const MatchCursor &cursor) noexcept
void bind_journal_codec(WorkingRequestCore &, detail::CommandScratchStore &)
std::variant< EnrollmentFromCommand, EnrollmentFromApplied > Enrollment
std::variant< MarketReady, LimitReady, StopIdle, StopActive, StopLimitPending, StopLimitLive, TrailWaitArm, TrailTrack, TrailActive > TriggerState
order_action::Transact Transact
A signed book transaction: finite nonzero units on the side their sign names.
Everything the kernel knows about WHERE a point is, as one owning value: its event ordinal,...
Where a request's trigger level comes from.
One request was accepted: the definition, and the timeline ordinal it was accepted at.
const Request & request() const noexcept
const RequestHandle & handle() const noexcept
const Birth & birth() const noexcept
What the consumer hands to prepare_trigger under an opted-in price grid (NativeRunSpec::price_grid ==...
What the consumer hands to prepare_owner_applied for an anchored leg's materialization,...
AnchoredLevelResolver resolve_level
std::optional< double > price_tick
An anchored leg was materialized, exactly once: fill + offset, then the rounding, then resolve_anchor...
std::optional< EventId > quantity_resolution
Bind to a host-built roster (cohort_open / cohort_add / cohort_remove), read at the match rather than...
Bind to ONE already-live opening, by its handle and the positive cycle it is live in.
Bind to a fixed cohort of already-live openings.
std::shared_ptr< const OpeningReadback > external_openings
std::vector< RequestHandle > openings
The authority an armed leg acquires under NativeArmScope::Book: the whole position its owner's fill l...
MatchCursor binding_cursor
const Request & request() const noexcept
Authority prior_authority
std::optional< EventId > cause
const RequestHandle & handle() const noexcept
RemainingProjection unexecuted
PendingAdjustments pending
Native sizing bases (L3).
A host-maintained, run-scoped roster identity.
CohortReceiptStatus status
CohortReceiptOperation operation
std::vector< RequestHandle > origins
Canonical origin handles, ordered by origin incarnation rather than by host insertion order.
What acceptance needs from the run to judge a command: the point's ordinal and coordinate,...
bool units_are_scope_boundary
A Reduce's ExplicitUnits are a FIFO boundary of its scope: the binary64 sum, in book order,...
std::optional< double > sizing_scope
Placement-time sizing measurements the execution consumer owns, supplied only for the intent that ask...
std::vector< OpeningObservation > openings
std::optional< OpeningObservation > opening
std::optional< double > sizing_units
Kernel-resolved acceptance-time units for a Sized{AtAcceptance} request.
std::optional< double > sizing_price
const OpeningObservationReadback * external_openings
std::optional< double > price_tick
The run's price tick, needed only to resolve a tick-spelled trail offset or trigger anchor.
std::optional< double > quantity_grid
ExecutionPlan committed_action
TargetObservation post_target
A group effect's deduction deferred into a sibling whose units are not known yet: its pending total g...
PendingDeferred pending_after
PendingAdjustments pending_before
std::optional< EventId > previous_pending_receipt
const Authority * authority
const TriggerState * trigger_state
const Allowance * allowance
const Remaining * remaining
A fraction in (0, 1] of MARKED equity at the sizing point.
std::optional< Side > cohort_side
Set only while resolving a CohortClose candidate.
DriverEligibilityClass driver_class
bool pre_open_birth_eligible
Generic current-point delivery.
bool existing_matching_bit
Where an install put its events: first_index is an ABSOLUTE journal position – the count of events th...
One committed execution: the definition, the cursor, the resolved price and units,...
int64_t effective_time_ms() const noexcept
std::size_t closed_trade_count
const Request & request() const noexcept
const RequestHandle & handle() const noexcept
std::size_t first_trade_index
uint64_t opened_lot_incarnation
Allowance allowance_after
int interval_index() const noexcept
Allowance allowance_before
std::uint8_t provenance() const noexcept
RemainingProjection remaining_after
std::optional< AppliedTerminalReason > terminal_reason
int64_t interval_open_ms() const noexcept
RemainingProjection remaining_before
int64_t interval_last_traded_close_ms() const noexcept
const Birth & birth() const noexcept
double inspected_closed_units
double inspected_current_ticket
bool pre_open_birth_eligible
Carries the generic pre-open delivery authorization from the matching evaluation through the synchron...
double inspected_opened_units
PositionIdentity pre_fill
ExecutionPlan physical_action
TargetObservation pre_target
std::optional< double > units
ExecutionGridPolicy grid_policy
A reduction of exactly these units, finite and positive.
Defer a level to the owner's fill: at the arm the level becomes fill + offset, with offset signed (ad...
NativeAnchorRounding rounding
One group-effect receipt: the applied event that caused it, the request it acted on,...
An opening or a closing whose quantity the HOST resolves, in NativeStrategyHost::resolve_execution_te...
std::optional< Side > side
Take whatever the point allows, with no per-point cap.
No owner: the request stands on its own book authority.
std::optional< Request > attempted
fill_through makes the limit a touch trigger (market-if-touched): the level still gates when the requ...
PendingAdjustments pending
const std::optional< RequestHandle > & predecessor() const noexcept
std::optional< double > sizing_scope
uint64_t priority() const noexcept
Its place in the queue (RequestDefinition::priority): the handle's incarnation, unless a re-price kep...
std::optional< double > sizing_price
std::optional< double > sizing_units
Placement-time sizing measurements frozen from the accepting command context.
const Request & request() const noexcept
const Birth & birth() const noexcept
const RequestHandle & handle() const noexcept
TriggerState trigger_state
A kernel-issued liquidation that actually filled.
const Request & request() const noexcept
const RequestHandle & handle() const noexcept
Match at the next eligible matching point, with no level to reach.
A candidate the run refused, with its MatchRejectReason and the cursor it was refused at.
const Birth & birth() const noexcept
std::optional< ExecutionTerms > attempted_terms
const Request & request() const noexcept
const RequestHandle & handle() const noexcept
RemainingProjection remaining
One generic risk limit breaching (L9).
A reduction or a flatten that had nothing to close: terminal, with no execution identity,...
const RequestHandle & handle() const noexcept
const Request & request() const noexcept
const Birth & birth() const noexcept
RemainingProjection remaining
A dynamic cohort has no currently live member.
std::optional< Request > attempted
bool has_live_matching_lot
PositionIdentity current_position
RequestHandle queried_opening
std::vector< RequestHandle > openings
std::shared_ptr< const OpeningReadback > external_openings
A reduction of exactly what the owner's fill opened, bound at the arm and reported by a QuantityBound...
Cap what this request may execute at ONE matching point at units.
A working-request preparation that could not produce a representable instruction — a nonrepresentable...
A Reduce{OwnerOpenedUnits} was bound, at its owner's fill, to what that fill opened.
std::vector< EventId > prior_adjustment_ids
double effective_deduction
RemainingProjection remaining
RequestRejectReason reason
A resolved remaining quantity, in units.
Replacement behaviour that is not expressible in the successor request.
bool retain_trigger_state
RequestRejectReason reason
const Request & live_request() const noexcept
DefinitionRef live_definition
const RequestHandle & target() const noexcept
std::optional< RequestHandle > successor
std::optional< RequestRejectReason > reason
bool kept_handle() const noexcept
Whether the replace kept the handle (ReplaceOptions::keep_handle): the successor definition is the sa...
const RequestHandle & successor() const noexcept
const Request & successor_request() const noexcept
DefinitionRef successor_definition
const Request & predecessor_request() const noexcept
DefinitionRef predecessor_definition
const RequestHandle & predecessor() const noexcept
const Birth & successor_birth() const noexcept
The immutable accepted form of one request: its handle, the request value as accepted,...
uint64_t priority
Where the definition stands in the run's queue: the number of the run's request sequence the command ...
std::optional< RequestHandle > root
The first handle of this request's replace chain – the request the chain began with,...
RequestOrigin origin
Appended last so every existing aggregate initializer keeps its meaning.
std::optional< PositionNonflat > kept_binding
The book binding a replace carried forward (ReplaceOptions:: keep_binding): the cycle and side of the...
std::optional< RequestHandle > predecessor
Aggregate field order keeps market construction: Request{Transact{1.0}, "buy", "comment"}...
A group effect's deduction from a live sibling whose remaining units are known (GroupEffect::Reduce):...
RemainingProjection after
Exact target exposure for an explicit reversal request.
A fraction in (0, 1] of the bound scope, resolved at the matching candidate.
ScopeBasis basis
Appended last so every existing aggregate initializer keeps its meaning.
Native authorization receipt, converted to a call-local financial SelectedOpeningSet only at the cons...
std::vector< uint64_t > incarnations
SizePrice price
Which price the basis converts at; see SizePrice.
ExecutionGridPolicy grid_policy
SnapToGrid floors the resolved units onto the run's quantity grid.
bool reserve_percent_fee
Divide the sizing cash by (1 + fee) when the run's fee kind is NativeFeeKind::Percent.
A stop that, once reached, becomes a limit at limit.
A stop trigger: the modeled path has to reach price from the adverse side.
std::optional< RequestHandle > handle
std::optional< RequestRejectReason > reason
Payload row policy for pending batches and committed-row read caches.
std::size_t successor_root_rows
std::size_t chain_segment_rows
Storage observations only, excluded from continuation state.
std::uint64_t receipt_reads
std::size_t chain_index_capacity_rows
std::size_t successor_root_capacity_rows
std::uint64_t chain_index_reads
std::size_t receipt_pending_bytes
std::size_t chain_index_pending_bytes
std::uint64_t successor_root_read_bytes
std::size_t successor_root_pending_bytes
std::uint64_t receipt_read_bytes
std::size_t successor_root_control_bytes
std::uint64_t chain_index_read_bytes
std::size_t receipt_capacity_rows
std::uint64_t successor_root_reads
std::size_t receipt_control_bytes
std::size_t chain_index_control_bytes
std::uint64_t chain_id_reads
PositionIdentity current_position
std::vector< OpeningObservation > openings
const OpeningObservationReadback * external_openings
std::optional< OpeningObservation > opening
One candidate's execution terms, recorded.
std::vector< EventId > prior_adjustment_ids
const Request & request() const noexcept
double effective_deduction
RemainingProjection remaining_after
Allowance allowance_after
const RequestHandle & handle() const noexcept
const Birth & birth() const noexcept
RemainingProjection remaining_before
A triggered trail; activation_ordinal carries TrailTrack's.
uint64_t activation_ordinal
Trail offset spelled in price ticks instead of a price distance.
A trail riding its running best.
uint64_t activation_ordinal
offset is a price distance: the stop rides offset behind the running best.
std::optional< TrailTicks > ticks
std::optional< double > arm_price
std::optional< double > best_seed
The one owner relation that arms (the ArmedEvent).
NativeArmFirstMatch first_match
NativeArmVisibility visibility
The authority an unarmed WaitForApplied child holds: accepted and live, but never a matching candidat...
How many spilled rows the book has read back to answer a lookup – by handle (find_live,...
std::size_t operator()(pineforge::native_order::CohortHandle value) const noexcept