10 std::size_t result = 1;
12 for (
const auto& child : *array) {
13 if (result >
limit)
break;
14 result += nodeCount(child,
limit - std::min(result,
limit));
17 for (
const auto& [
key, child] : *
object) {
19 if (result >
limit)
break;
20 result += nodeCount(child,
limit - std::min(result,
limit));
26bool includes(
const std::vector<std::string>&
values,
const std::string&
value) {
32 case DiagnosticSeverity::Info:
return 0;
33 case DiagnosticSeverity::Warning:
return 1;
34 case DiagnosticSeverity::Error:
return 2;
35 case DiagnosticSeverity::Fatal:
return 3;
44 return eve::editing::failed<void>(EditorStatus::Rejected,
RuleId(
"editor.timeline.capacity"),
45 "Timeline capacity must be between 1 and 1,000,000");
47 while (events_.size() > capacity_) { events_.pop_front(); ++dropped_; }
49 return eve::editing::applied<void>();
53 std::size_t maximumPayloadNodes) {
54 if (event.
domain.empty() || event.
type.empty() || maximumPayloadNodes == 0 ||
55 nodeCount(event.
payload, maximumPayloadNodes) > maximumPayloadNodes)
56 return eve::editing::failed<std::uint64_t>(EditorStatus::Rejected,
57 RuleId(
"editor.timeline.invalid-event"),
"Timeline event identity or payload budget is invalid");
58 if (event.
sequence == 0)
event.sequence = nextSequence_++;
61 return eve::editing::failed<std::uint64_t>(EditorStatus::Conflict,
62 RuleId(
"editor.timeline.sequence"),
"Timeline event sequence is stale or duplicated");
63 nextSequence_ =
event.sequence + 1;
65 const std::uint64_t
sequence =
event.sequence;
66 if (events_.size() == capacity_) { events_.pop_front(); ++dropped_; }
67 events_.push_back(std::move(event)); ++generation_;
68 return eve::editing::applied<std::uint64_t>(
sequence);
73 std::optional<std::uint64_t>
generation)
const {
75 return eve::editing::failed<EditorTimelinePage>(EditorStatus::Rejected,
76 RuleId(
"editor.timeline.page-size"),
"Timeline page size must be between 1 and 10,000");
78 return eve::editing::failed<EditorTimelinePage>(EditorStatus::Conflict,
79 RuleId(
"editor.timeline.stale-generation"),
"Timeline changed while paging");
80 std::vector<EditorTimelineEvent> matched;
81 for (
const auto& event : events_) {
82 if (!includes(
filter.domains, event.domain) || !includes(
filter.types, event.type) ||
83 (!
filter.source.empty() &&
event.source !=
filter.source) ||
84 (!
filter.correlation.empty() &&
event.correlation !=
filter.correlation) ||
85 (
filter.minimumSeverity && severityRank(event.severity) < severityRank(*
filter.minimumSeverity)) ||
86 event.tick <
filter.firstTick || (
filter.lastTick > 0 && event.tick >
filter.lastTick))
continue;
87 matched.push_back(event);
90 const std::size_t
begin = std::min(
offset, matched.size());
91 const std::size_t
end = std::min(
begin +
limit, matched.size());
92 result.
values.assign(matched.begin() +
static_cast<std::ptrdiff_t
>(
begin),
93 matched.begin() +
static_cast<std::ptrdiff_t
>(
end));
95 return eve::editing::applied<EditorTimelinePage>(std::move(result));
99 events_.clear(); ++generation_;
std::map< std::string, Var > values
std::unique_ptr< gpgpu::Sequence > sequence
Move-only operation result carrying either a value or Status.
std::vector< Value > Array
std::map< std::string, Value > Object
Result< EditorTimelinePage > query(const EditorTimelineQuery &filter, std::size_t offset, std::size_t limit, std::optional< std::uint64_t > generation=std::nullopt) const
Query a deterministic page; stale generations return Conflict.
Result< void > setCapacity(std::size_t capacity)
Set retained event capacity; shrinking drops oldest events.
void clear()
Clear retained events while preserving the next sequence number.
std::uint64_t generation() const
Generation.
Result< std::uint64_t > append(EditorTimelineEvent event, std::size_t maximumPayloadNodes=10000)
Copy one event, assigning a monotonic sequence when it is zero.
eve::editing::Value EditorValue
Compatibility alias for the UI-independent authoring value tree.
eve::editing::RuleId RuleId
eve::Severity DiagnosticSeverity
Immutable normalized runtime event copied into the editor timeline.
Generation-qualified timeline query page.
std::uint64_t droppedEvents
std::vector< EditorTimelineEvent > values
Deterministic event filter used by headless and visual presenters.