32class NativeHistoryOwner;
41class NativeExecutionConsumer;
71 return left.value == right.value;
74 return !(left == right);
77 return left.value < right.value;
124using SizeBasis = std::variant<CashValue, EquityFraction>;
237using ReductionSize = std::variant<ExplicitUnits, OwnerOpenedUnits, ScopeFraction>;
251using OrderIntent = std::variant<Flatten, Reduce, Transact, ReverseTo, HostSized, Sized>;
315 std::optional<TrailTicks>
ticks = std::nullopt;
318using Trigger = std::variant<Market, Limit, Stop, StopLimit, Trail>;
404using Capacity = std::variant<ImmediateRemaining, PointBudget>;
487 : count_(
count), context_(context), reader_(reader) {}
488 std::uint64_t
count() const noexcept
override {
return count_; }
490 std::uint64_t index,
RequestHandle& out)
const noexcept override;
492 std::uint64_t count_;
502 std::shared_ptr<const OpeningReadback>& out);
524using Owner = std::variant<Independent, WaitForApplied, BindOpening, BindOpenings, BindCohort>;
533using Group = std::variant<NoGroup, Member>;
564 return find(
"label", out);
567 return find(
"comment", out);
572 if (std::holds_alternative<execution::Flatten>(action))
return Flatten{};
573 if (
const auto* transact = std::get_if<order_action::Transact>(&action)) {
574 return Transact{transact->signed_units};
576 const auto& reduce = std::get<order_action::Reduce>(action);
581 std::string
label = {},
582 std::string comment = {}) {
587 return std::holds_alternative<Market>(request.trigger)
588 && std::holds_alternative<ImmediateRemaining>(request.capacity)
589 && std::holds_alternative<Independent>(request.owner)
590 && std::holds_alternative<NoGroup>(request.group)
591 && std::holds_alternative<Absolute>(request.anchor);
600 return a.
ordinal == b.ordinal && a.
run == b.run;
610 return a.point.ordinal == b.point.ordinal && a.t == b.t
611 && a.point.interval_index == b.point.interval_index
612 && a.point.effective_time_ms == b.point.effective_time_ms
613 && a.point.provenance == b.point.provenance
614 && a.point.path_phase == b.point.path_phase;
619 return static_cast<std::uint8_t
>(cursor.point.path_phase);
679using Enrollment = std::variant<EnrollmentFromCommand, EnrollmentFromApplied>;
712using ExecutionScope = std::variant<execution::Book, execution::OpeningExposure, SelectedExposure>;
829 std::optional<RequestHandle>
root;
865 const std::optional<RequestHandle>&
predecessor() const noexcept {
882 uint64_t point_ordinal,
883 int64_t effective_time_ms)
noexcept {
884 return point_eligible(live.birth(), point_ordinal, effective_time_ms);
891 if (!std::isfinite(q) || !std::isfinite(step) || step <= 0.0)
return false;
892 const double abs_q = std::abs(q);
893 const double r = abs_q / step;
894 if (!std::isfinite(r))
return false;
895 const double n = std::round(r);
896 if (!std::isfinite(n) || n < 1.0 || n > 0x1p53)
return false;
897 const double g = n * step;
898 if (!std::isfinite(g))
return false;
899 const double err = std::abs(abs_q - g);
900 const double span = std::max(abs_q, std::abs(g));
901 const double ulp = std::nextafter(span, std::numeric_limits<double>::infinity()) - span;
902 const double ulp_bound = 4.0 * ulp;
903 const double half_step = step / 2.0;
904 if (!std::isfinite(err) || !std::isfinite(ulp_bound) || !std::isfinite(half_step))
906 return err <= ulp_bound && err < half_step;
941 std::optional<RequestRejectReason>
reason;
948 std::optional<RequestRejectReason>
reason;
1022 return std::visit([](
const auto& alternative) ->
ExecutionPlan {
1267 return cursor.point.last_traded_close_ms;
1271 return static_cast<std::uint8_t
>(
cursor.point.provenance);
1424 std::uint64_t
size() const noexcept
override {
return length_; }
1428 std::uint64_t length_ = 0;
1448 for (std::size_t i = 0; i < size_ && i < inline_.size(); ++i) {
1449 inline_[i] = std::move(other.inline_[i]);
1451 overflow_ = std::move(other.overflow_);
1455 if (
this != &other) {
1457 size_ = other.size_;
1458 for (std::size_t i = 0; i < size_ && i < inline_.size(); ++i) {
1459 inline_[i] = std::move(other.inline_[i]);
1461 overflow_ = std::move(other.overflow_);
1467 for (std::size_t i = 0; i < size_ && i < inline_.size(); ++i) {
1468 inline_[i] = other.inline_[i];
1470 overflow_ = other.overflow_;
1473 if (
this != &other) {
1475 size_ = other.size_;
1476 for (std::size_t i = 0; i < size_ && i < inline_.size(); ++i) {
1477 inline_[i] = other.inline_[i];
1479 overflow_ = other.overflow_;
1484 std::size_t
size() const noexcept {
return size_; }
1485 bool empty() const noexcept {
return size_ == 0; }
1487 template<
class Event>
1493 if (overflow_.empty() && size_ < inline_.size()) {
1494 inline_[size_++].emplace(std::move(event));
1497 if (overflow_.empty()) {
1498 overflow_.reserve(inline_.size() * 2U);
1499 for (std::size_t i = 0; i < size_; ++i) {
1500 overflow_.push_back(std::move(*inline_[i]));
1504 overflow_.push_back(std::move(event));
1509 for (std::size_t i = 0; i < size_ && i < inline_.size(); ++i) {
1519 return overflow_.empty() ? *inline_[index] : overflow_[index];
1522 return overflow_.empty() ? *inline_[index] : overflow_[index];
1526 std::array<std::optional<CommandEvent>, 2> inline_{};
1527 std::vector<CommandEvent> overflow_{};
1528 std::size_t size_ = 0;
1608 double offset,
double kernel_level)>;
1913 return cohort_receipts_;
1918 return cohort_receipts_base_ + cohort_receipts_.size();
1949 const
std::function<
bool(const
EventId&)>& visit) const;
2001 int64_t decision_time_ms,
2002 uint64_t& next_order_incarnation,
2003 uint64_t& next_timeline_ordinal,
2004 std::optional<
double> quantity_grid =
std::nullopt);
2008 int64_t decision_time_ms,
2009 uint64_t& next_order_incarnation,
2010 uint64_t& next_timeline_ordinal,
2011 std::optional<
double> quantity_grid =
std::nullopt,
2022 uint64_t& next_order_incarnation,
2023 uint64_t& next_timeline_ordinal,
2028 uint64_t& next_order_incarnation,
2029 uint64_t& next_timeline_ordinal,
2043 uint64_t& next_timeline_ordinal);
2059 uint64_t& next_timeline_ordinal,
2060 bool open_activation_grant);
2066 uint64_t& next_timeline_ordinal,
2067 std::optional<Side> cohort_side = std::nullopt,
2076 uint64_t& next_timeline_ordinal,
2077 std::optional<Side> cohort_side,
2079 bool open_activation_grant);
2084 uint64_t& next_timeline_ordinal);
2089 uint64_t& next_timeline_ordinal,
2090 bool open_activation_grant);
2095 uint64_t& next_timeline_ordinal);
2099 uint64_t& next_timeline_ordinal);
2104 std::optional<ExecutionTerms> attempted_terms,
2105 uint64_t& next_timeline_ordinal);
2109 uint64_t& next_timeline_ordinal);
2115 uint64_t& next_timeline_ordinal);
2122 uint64_t& next_timeline_ordinal);
2137 bool open_activation_grant);
2146 uint64_t& next_timeline_ordinal);
2151 uint64_t& next_timeline_ordinal,
2152 bool open_activation_grant);
2161 double resolved_units,
2164 bool* exhausted)
noexcept;
2190 uint64_t& next_timeline_ordinal);
2198 const std::optional<OpeningObservation>& observation,
2199 uint64_t& next_timeline_ordinal,
2204 uint64_t& next_timeline_ordinal);
2207 uint64_t& next_timeline_ordinal);
2232 uint64_t& next_order_incarnation,
2233 uint64_t& next_timeline_ordinal,
2238 uint64_t& next_order_incarnation,
2239 uint64_t& next_timeline_ordinal,
2242 uint64_t& next_timeline_ordinal,
2247 uint64_t& next_timeline_ordinal);
2252 uint64_t& next_timeline_ordinal,
2253 bool open_activation_grant);
2257 uint64_t& next_timeline_ordinal,
2258 std::optional<Side> cohort_side = std::nullopt,
2265 uint64_t& next_timeline_ordinal,
2266 std::optional<Side> cohort_side,
2268 bool open_activation_grant);
2271 uint64_t& next_timeline_ordinal);
2275 std::optional<ExecutionTerms> attempted_terms,
2276 uint64_t& next_timeline_ordinal);
2280 uint64_t& next_timeline_ordinal);
2282 uint64_t& next_timeline_ordinal);
2284 uint64_t& next_timeline_ordinal);
2287 uint64_t& next_timeline_ordinal);
2290 const std::optional<OpeningObservation>& observation,
2291 uint64_t& next_timeline_ordinal,
2296 uint64_t& next_timeline_ordinal);
2299 uint64_t& next_timeline_ordinal);
2302 uint64_t& next_timeline_ordinal);
2309 uint64_t& next_timeline_ordinal,
2310 bool open_activation_grant);
2314 uint64_t& next_timeline_ordinal);
2318 uint64_t& next_timeline_ordinal,
2319 bool open_activation_grant);
2327 bool open_activation_grant)
const noexcept;
2332 bool open_activation_grant)
const noexcept;
2336 bool existing_matching_bit)
const noexcept;
2338 std::optional<Side> cohort_side = std::nullopt)
const noexcept;
2349 const detail::NativeHistoryOwner* managed_history_owner() const noexcept;
2352 const
detail::ScratchByteSource&) noexcept;
2364 static
void require_grid(
std::optional<
double> quantity_grid);
2365 static
void require_distinct_counters(uint64_t& next_order_incarnation,
2366 uint64_t& next_timeline_ordinal);
2379 enum class ReceiptLookup :
std::uint8_t { Absent = 0, Present = 1, Conflict = 2 };
2385 std::vector<EventId> inline_ids;
2387 bool external =
false;
2388 uint64_t offset = 0;
2404 std::size_t receipts_first_above(uint64_t retired)
const;
2405 void apply_receipt_base(std::size_t base)
noexcept;
2408 void ensure_receipt_store();
2410 void prepare_codec_frames();
2411 void ensure_chain_segments();
2418 void note_chain_birth(
const CommandEvent& event)
noexcept;
2419 void note_chain_loss(
const LiveRequest& row)
noexcept;
2422 void erase_live(std::size_t index)
noexcept;
2426 bool trail_level_ok(
double best,
double offset,
bool is_buy,
double* stop,
2427 double ladder_tick = 0.0) const noexcept;
2435 bool cohort_exists(
CohortHandle cohort) const noexcept;
2439 void index_committed(const
CommandEvent& event) noexcept;
2442 std::optional<uint64_t> pending_chain_floor() const;
2444 uint64_t usable_ordinal(uint64_t next) const;
2445 uint64_t usable_incarnation(uint64_t next) const;
2449 std::
size_t repriced_position(uint64_t incarnation) const noexcept;
2455 uint64_t* next_timeline_ordinal,
bool open_activation_grant);
2458 uint64_t& next_timeline_ordinal);
2459 TargetKind classify_repriced(uint64_t incarnation,
std::
size_t* live_index) const noexcept;
2460 const
LiveRequest* find_repriced(uint64_t incarnation) const noexcept;
2465 void note_repriced(uint64_t incarnation, uint64_t priority) noexcept;
2467 TargetKind classify_resident(const
RequestHandle& handle,
std::
size_t* live_index) const;
2473 bool bump_epoch() noexcept;
2474 void require_epoch_room() const;
2475 void clear_unbound() noexcept;
2477 struct InstanceBinding {
2478 uint64_t generation = 1;
2479 bool expired =
false;
2481 struct MutationPlan {
2482 std::weak_ptr<InstanceBinding> instance;
2483 uint64_t generation = 0;
2486 std::size_t history_size = 0;
2487 uint64_t last_ordinal = 0;
2488 bool consumed =
false;
2489 InlineCommandEvents events;
2490 std::uint8_t live_change = 0;
2491 std::size_t live_index = 0;
2492 LiveRequest live_row{};
2493 bool consume_incarnation =
false;
2494 uint64_t incarnation_used = 0;
2497 uint64_t skipped_ordinal = 0;
2498 bool add_receipt =
false;
2499 EventId receipt_cause{};
2500 RequestHandle receipt_recipient{};
2502 uint64_t receipt_outcome = 0;
2506 bool chain_segment =
false;
2507 uint64_t chain_event_ordinal = 0;
2508 uint64_t chain_offset = 0;
2509 uint64_t chain_count = 0;
2511 std::optional<InstallError> validate_plan(
const MutationPlan& plan)
const noexcept;
2515 PreparedReplace prepare_replace_kept(std::size_t live_index,
const RequestHandle& staged_target,
2516 Request&& staged, uint64_t ordinal, uint64_t incarnation,
2517 const CommandContext& context, ReplaceOptions options,
2518 MutationPlan&& plan);
2521 template <
bool Kept>
2522 CommandInstalled<ReplaceResult> apply_replace_as(
const RequestHandle& target,
2523 const Request& request,
2524 const CommandContext& context,
2525 uint64_t& next_order_incarnation,
2526 uint64_t& next_timeline_ordinal,
2527 ReplaceOptions options);
2528 CommandInstalled<ReplaceResult> apply_replace_kept(
const RequestHandle& target,
2529 const Request& request,
2530 const CommandContext& context,
2531 uint64_t& next_order_incarnation,
2532 uint64_t& next_timeline_ordinal,
2533 ReplaceOptions options);
2534 LiveRequest kept_successor(std::size_t live_index,
const RequestHandle& staged_target,
2535 Request&& staged, uint64_t ordinal, uint64_t incarnation,
2536 const CommandContext& context, ReplaceOptions options)
const;
2538 MutationPlan begin_plan()
const;
2539 void reserve_plan(
const MutationPlan& plan);
2540 void bind_plan(MutationPlan& plan)
const;
2541 void seal_plan(MutationPlan& plan);
2542 PreparedMutation finish_mutation(MutationPlan plan);
2555 void begin_direct()
const;
2556 void seal_direct(std::size_t events,
bool push_live,
bool add_receipt,
2557 bool consume_incarnation,
bool chain_segment =
false);
2560 void note_chain_segment(uint64_t event_ordinal, uint64_t offset, uint64_t count)
noexcept;
2561 template <
class Event>
2562 void append_direct(Event&& event,
bool consume_incarnation);
2563 EventRange finish_direct(std::size_t first)
noexcept;
2564 template <
class Event>
2565 Installed end_direct(std::size_t live_index, Event&& event);
2570 struct ExecutionValues {
2571 std::size_t live_index = 0;
2572 uint64_t ordinal = 0;
2573 double filled = 0.0;
2574 bool flatten =
false;
2575 bool units_exhausted =
false;
2577 Allowance allowance_after = AllowanceUnset{};
2580 Preparation<ExecutionValues> execution_values(
const RequestHandle& target,
2581 const ExecutionProposal& proposal,
2582 uint64_t& next_timeline_ordinal,
2583 bool open_activation_grant);
2589 struct JournalStore;
2590 struct ReceiptStore;
2591 struct ChainSegments;
2605 std::size_t spilled_count() const noexcept;
2606 const std::
string& scratch_directory() const noexcept;
2612 uint64_t spilled_priority = 0;
2614 void make_book_room();
2615 bool promote_book_row(uint64_t incarnation, std::size_t* index);
2616 const LiveRequest* spilled_row(uint64_t incarnation)
const;
2617 std::shared_ptr<LiveRequest> spilled_held(uint64_t incarnation)
const;
2618 const LiveRequest* find_resident(
const RequestHandle& handle)
const noexcept;
2621 uint64_t book_generation() const noexcept;
2627 std::shared_ptr<const LiveRequest> hold_scanned(const RequestHandle& handle, uint64_t at,
2628 uint64_t generation) const;
2629 void forget_repriced(uint64_t incarnation) noexcept;
2630 BookCursor book_begin() const;
2631 bool book_done(const BookCursor& cursor) const noexcept;
2632 bool book_next_spilled(const BookCursor& cursor) const noexcept;
2633 void book_step(BookCursor& cursor) const;
2634 const LiveRequest& live_back() const;
2637 template <class Visit>
2638 void visit_book(Visit&& visit) const;
2640 RunIdentity identity_;
2641 std::shared_ptr<InstanceBinding> instance_;
2642 std::vector<LiveRequest> live_;
2643 std::shared_ptr<BookSpill> book_spill_;
2644 uint64_t last_ordinal_ = 0;
2645 uint64_t last_incarnation_ = 0;
2646 uint64_t epoch_ = 0;
2651 std::shared_ptr<JournalStore> journal_;
2652 std::
size_t history_base_ = 0;
2653 uint64_t retired_through_ = 0;
2657 static constexpr uint64_t kNoChainFloor = std::numeric_limits<uint64_t>::max();
2658 mutable uint64_t chain_floor_ = kNoChainFloor;
2659 mutable
bool chain_floor_exact_ = true;
2660 std::shared_ptr<ChainSegments> chain_segments_;
2663 struct SuccessorRootIndex;
2664 void reserve_successor_root();
2665 void append_successor_root(uint64_t incarnation, uint64_t root) noexcept;
2666 std::optional<uint64_t> successor_root(uint64_t incarnation) const;
2667 std::vector<std::pair<uint64_t, uint64_t>> issued_;
2668 std::shared_ptr<SuccessorRootIndex> successor_roots_;
2676 std::vector<std::pair<uint64_t, uint64_t>> repriced_;
2681 std::shared_ptr<ReceiptStore> receipt_store_;
2682 std::uint64_t next_cohort_handle_ = 1;
2686 std::map<std::uint64_t, CohortRoster> cohorts_;
2687 std::vector<CohortReceipt> cohort_receipts_;
2690 std::
size_t cohort_receipts_base_ = 0;
2710 pointer operator->() const noexcept {
return &**
this; }
2713 auto previous = *
this;
2718 return left.core_ == right.core_ && left.index_ == right.index_;
2721 return !(left == right);
2727 : core_(core), index_(index) {}
2729 std::size_t index_ = 0;
2733 std::size_t
size() const noexcept {
2734 return static_cast<std::size_t
>(core_->next_cohort_handle_ - 1);
2769 reference operator*()
const {
return core_->history_at(position_); }
2785 position_ =
static_cast<std::size_t
>(
static_cast<difference_type>(position_) + offset);
2807 return left.position_ == right.position_;
2810 return left.position_ != right.position_;
2813 return left.position_ < right.position_;
2816 return left.position_ > right.position_;
2819 return left.position_ <= right.position_;
2822 return left.position_ >= right.position_;
2828 : core_(core), position_(position) {}
2830 std::size_t position_ = 0;
2838 std::size_t
size() const noexcept {
return core_->history_end() - core_->history_base(); }
2841 return static_cast<std::size_t
>(std::numeric_limits<std::ptrdiff_t>::max()) / 4;
2845 return core_->history_at(core_->history_base() + index);
2848 if (index >=
size())
throw std::out_of_range(
"native journal index is not retained");
2849 return (*
this)[index];
2857 operator std::vector<CommandEvent>()
const {
return std::vector<CommandEvent>(
begin(),
end()); }
2891 std::shared_ptr<const LiveRequest>
hold()
const;
2899 return left.core_ == right.core_ && left.cursor_.r == right.cursor_.r
2900 && left.cursor_.at == right.cursor_.at;
2903 return !(left == right);
2908 friend class ::pineforge::engine_script_run_v20::NativeExecutionConsumer;
2910 : core_(core), cursor_(cursor) {}
2913 uint64_t spilled_at() const noexcept {
return held_ ? cursor_.at : 0; }
2917 BookCursor cursor_{};
2918 std::shared_ptr<LiveRequest> held_;
2926 std::size_t
size() const noexcept {
return core_->live_size(); }
2936 operator std::vector<LiveRequest>()
const;
2952 explicit operator
bool() const noexcept;
2959 std::unique_ptr<Impl> impl_;
2971 explicit operator
bool() const noexcept;
2978 std::unique_ptr<Impl> impl_;
2990 explicit operator
bool() const noexcept;
2997 std::unique_ptr<Impl> impl_;
3009 explicit operator
bool() const noexcept;
3014 std::unique_ptr<Impl> impl_;
3026 explicit operator
bool() const noexcept;
3031 std::unique_ptr<Impl> impl_;
3035static_assert(
std::is_nothrow_move_constructible_v<
Request>);
3036static_assert(
std::is_nothrow_move_assignable_v<
Request>);
3067 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={})
friend class ::pineforge::engine_script_run_v20::NativeExecutionConsumer
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 (the direct reque...
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 (the direct request-core forms).
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