Skip to content

Add event history TTL controls#30

Open
pirate wants to merge 55 commits into
mainfrom
event-history-ttl-index
Open

Add event history TTL controls#30
pirate wants to merge 55 commits into
mainfrom
event-history-ttl-index

Conversation

@pirate

@pirate pirate commented Jun 29, 2026

Copy link
Copy Markdown
Member

Summary

Adds event history retention controls consistently across Python, TypeScript, Go, and Rust:

  • event_ttl for dropping completed events from a bus history
  • event_result_ttl for pruning a bus's completed event results after the parent event completes
  • handler_result_ttl for handler-level result retention overrides

The implementation keeps default hydration late and follows the existing timeout/slow-warning precedence model: bus defaults, event overrides, and handler overrides where applicable. null/undefined inherits defaults, -1 means retain indefinitely, 0 prunes on the next natural trim pass, and values below -1 are rejected.

Implementation Notes

  • Adds a lightweight per-bus TTL expiry index with stale-entry checks so trim work scales with expired candidates instead of scanning all history on every emit.
  • Stores each bus's current expiry deadline on the shared event instance, allowing forwarded events to be retained or pruned independently per bus.
  • Keeps TTL enforcement best-effort through existing history trimming and dispatch-time boundary checks; no timers or background TTL worker were added.
  • Preserves shared forwarded-event semantics while pruning only the results produced by the processing bus.

Validation

  • uv run pytest tests/test_eventbus_timeout.py tests/test_eventbus_forwarding.py tests/test_eventbus_dispatch_defaults.py -q
  • go test ./tests -run 'TTL|TypedEventConfigDefaultsPopulateBaseEventFields|TypedEventPointerZeroTTLsAreExplicitOverrides|CompletedForwardedEventWithPrunedTargetResults' -count=1
  • cargo fmt --manifest-path abxbus-rust/Cargo.toml --check
  • cargo test --manifest-path abxbus-rust/Cargo.toml ttl -- --nocapture
  • cargo test --manifest-path abxbus-rust/Cargo.toml typed_event_config_defaults -- --nocapture
  • cargo test --manifest-path abxbus-rust/Cargo.toml completed_forwarded_event_with_pruned_target_results -- --nocapture
  • npm run typecheck
  • NODE_OPTIONS='--expose-gc' node --expose-gc --test --import tsx tests/EventBus_timeout.test.ts tests/EventBus_forwarding.test.ts tests/EventBus_dispatch_defaults.test.ts

Summary by cubic

Adds TTL controls for event/result history and an option-aware event reset across Python, TypeScript, Go, and Rust. Also hardens completed-event handling, forwarding, and restore/validate logic, fixes TTL validation/retracking (including a Rust lock-order fix), and enforces nonnegative execution timeouts across runtimes.

  • New Features

    • TTLs: event_ttl, event_result_ttl, handler_result_ttl with precedence (bus → event → handler). Semantics: inherit on null/undefined; keep forever on -1; prune on 0 at natural trim; reject < -1.
    • TTL engine: prunes at dispatch/trim, retracks when defaults/overrides change, rebuilds on restore/validate, skips scans when no TTLs, tracks per-bus forwarded deadlines, and avoids global scans for single-bus completions.
    • Forwarding: events stay shared; each bus prunes only its own results; handler_result_ttl is serialized in EventResult.
    • Event reset: option-aware reset regenerates ids/routing by default, preserves event_created_at and TTL defaults, and clears status/timestamps/results; added read-only payload accessors; TypeScript exports EventPayloadFields and EventResetOptions.
  • Bug Fixes

    • Completed events: skip handlers only on buses that processed them, seal terminal state at emit, preserve started/completed timestamps, keep runloops alive, allow first-time dispatch on new buses, and let completed replays bypass TTL drops; Go skips reprocessing sealed events.
    • Forwarding: record timeouts on the target bus; keep terminal status even if target results are pruned; avoid duplicate queue notifications; keep completed-history replays idempotent.
    • Restore/validate: rebuild TTL indexes for completed history and enforce TTL pruning with bounded histories.
    • Validation: Python/TypeScript/Go/Rust reject negative execution timeouts (0 disables), Python/TypeScript validate TTLs (reject < -1); TypeScript validates TTLs on mutation paths and tightens schemas/fixes TTL retracking; Go enforces result payload schema on read; Rust avoids TTL retrack lock inversion and rejects non-finite timeout/TTL values.

Written for commit 5ce24e3. Summary will update on new commits.

Review in cubic

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4ab53dc9ab

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread abxbus/event_bus.py
Comment thread abxbus-ts/src/EventBus.ts
Comment thread abxbus-go/event_bus.go
Comment thread abxbus-rust/src/event_bus.rs

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

9 issues found across 41 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread abxbus-ts/src/EventBus.ts Outdated
Comment thread abxbus-ts/src/EventBus.ts
Comment thread abxbus-ts/src/BaseEvent.ts Outdated
Comment thread abxbus/event_handler.py
Comment thread abxbus-rust/src/typed.rs
Comment thread abxbus-go/base_event.go
Comment thread abxbus/base_event.py
Comment thread abxbus-go/event_bus.go Outdated
Comment thread abxbus-go/event_bus.go

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 633768bed4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread abxbus-ts/src/EventHandler.ts

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 12 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread abxbus-ts/src/BaseEvent.ts

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ce80a1ea40

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread abxbus/base_event.py
Comment thread abxbus-ts/src/EventBus.ts Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3be16898b4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread abxbus-go/event_bus.go Outdated
Comment thread abxbus-rust/src/event_bus.rs Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e7dc5ad236

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread abxbus/event_bus.py Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b853527548

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread abxbus/event_bus.py Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 19218ee6ee

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread abxbus-go/event_result.go
Comment thread abxbus-rust/src/event_handler.rs

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5 issues found across 14 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread abxbus-rust/src/event_bus.rs Outdated
Comment thread abxbus-go/event_bus.go Outdated
Comment thread abxbus-ts/src/EventBus.ts Outdated
Comment thread abxbus-rust/src/event_bus.rs Outdated
Comment thread abxbus-go/event_bus.go Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6f99c69488

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread abxbus-go/base_event.go

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 380ad88736

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread abxbus/event_bus.py Outdated
)
):
self.event_history.trim_event_history(owner_label=str(self))
if not include_ttl or not self._has_ttl_cleanup_sources():

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Honor per-event TTLs without bus defaults

When a bus has no bus-level TTLs and no registered handler TTLs, but a completed event itself sets event_ttl or event_result_ttl, this guard returns before scanning history and resolving those per-event overrides. A later natural trim therefore never removes the event or its results, so per-event TTLs only work when some unrelated bus/handler TTL is configured; track per-event TTL sources or inspect retained history before skipping the scan.

Useful? React with 👍 / 👎.

Comment thread abxbus-ts/src/EventBus.ts Outdated
})
}

if (!include_ttl || !this._hasTTLCleanupSources()) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Honor per-event TTLs without bus defaults

When an event carries event_ttl or event_result_ttl but the TS bus itself has both TTL defaults unset and no handler currently has handler_result_ttl, this early return skips the only loop that resolves the event-level TTLs. In that configuration, a subsequent emit/trim pass leaves completed events and results retained indefinitely despite the event override; the skip condition needs to include TTLs present on retained events/results.

Useful? React with 👍 / 👎.

Comment thread abxbus-go/event_bus.go Outdated
if b.EventHistory.MaxHistorySize != nil && (*b.EventHistory.MaxHistorySize == 0 || b.EventHistory.MaxHistoryDrop) {
b.EventHistory.TrimEventHistory(nil)
}
if !includeTTL || !b.hasTTLCleanupSources() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Honor per-event TTLs without bus defaults

For a Go bus with no bus-level TTL defaults and no registered handler TTLs, a completed event can still have EventTTL or EventResultTTL set on the event, but this guard returns before the history scan that resolves those fields. The next natural trim pass then never prunes that event or its results, so event-level TTL overrides are silently ignored unless an unrelated bus/handler TTL is configured.

Useful? React with 👍 / 👎.

Comment thread abxbus-rust/src/event_bus.rs Outdated
if let Some(max_size) = self.runtime.max_history_size {
self.trim_history_to_capacity(max_size, false);
}
if !include_ttl || !self.has_ttl_cleanup_sources() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Honor per-event TTLs without bus defaults

If a Rust bus has no bus-level TTL defaults and no handler TTLs, completed events can still carry event_ttl or event_result_ttl, but this return prevents trim_event_history from ever examining those per-event values. A later natural trim therefore retains expired events/results forever in that common override-only configuration; the cleanup source check should account for TTLs stored in history.

Useful? React with 👍 / 👎.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4 issues found across 5 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread abxbus-rust/src/event_bus.rs Outdated
Comment thread abxbus/event_bus.py Outdated
Comment thread abxbus-go/event_bus.go Outdated
Comment thread abxbus-ts/src/EventBus.ts Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 954af21dec

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread abxbus-ts/src/BaseEvent.ts Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 issues found across 6 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="abxbus/event_bus.py">

<violation number="1" location="abxbus/event_bus.py:2265">
P2: The sorted `_ttl_deadline_queue` optimization means completed events are only re-evaluated when their precomputed deadline is reached. If a bus, event, or handler TTL is shortened at runtime after an event has already completed, the old (longer) deadline remains in the queue and the event will not be pruned until that stale future time. The previous scan-based trim loop honored updated TTLs on the next pass for all history, but the new queue-only inspection loses that behavior for events whose original deadline has not yet arrived. Consider retracking or recomputing deadlines for affected events when a bus-level or handler-level TTL is mutated, or document this limitation if runtime TTL adjustment is no longer supported.</violation>
</file>

<file name="abxbus-go/event_bus.go">

<violation number="1" location="abxbus-go/event_bus.go:822">
P2: The queue-based TTL pruning removes the previous full-history scan, which introduces a blind spot for already-completed events after runtime TTL changes. Events that finished while `EventTTL` or handler TTLs were unset are never added to `ttlDeadlineQueue`; if those fields are tightened later, existing history events silently remain unpruned. Consider adding an occasional fallback scan or a backfill hook when TTL config changes so that previously untracked events can still be evaluated against current settings.</violation>
</file>

<file name="abxbus-ts/src/EventBus.ts">

<violation number="1" location="abxbus-ts/src/EventBus.ts:523">
P2: The TTL deadline is indexed before event results are relinked to canonical bus handlers in `fromJSON`. `_earliestTTLDeadline` depends on `result.handler.handler_result_ttl`, but `_linkEventResultHandlers` replaces `result.handler` after the queue is built. If the canonical handler has a smaller TTL than the deserialized stub, the stored deadline is too late and pruning is delayed until that incorrect timestamp. Move `_trackEventTTLDeadline` to after the `_linkEventResultHandlers` loop, or re-track deadlines once relinking is complete.</violation>
</file>

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread abxbus-ts/src/EventBus.ts
Comment thread abxbus/event_bus.py
Comment thread abxbus-go/event_bus.go

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 9 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="abxbus-go/tests/eventbus_timeout_test.go">

<violation number="1" location="abxbus-go/tests/eventbus_timeout_test.go:151">
P2: The new test creates three separate EventBus instances and calls Destroy() only at the end of each sub-section without defer or t.Cleanup. If any t.Fatal/t.Fatalf assertion in a sub-section fires before reaching the Destroy() call — for example, the assertion on line ~139 checking that the event remains before runtime changes — the test exits immediately and the bus resources (goroutines, channels) for that bus are leaked. All other tests in this file consistently use defer bus.Destroy() or t.Cleanup(bus.Destroy) right after each bus is created. Consider adding defer right after each bus creation to match the established pattern and ensure cleanup on early failure.</violation>
</file>

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread abxbus-go/tests/eventbus_timeout_test.go Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1824ec6e98

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread abxbus/event_bus.py Outdated
Comment thread abxbus-ts/src/EventBus.ts Outdated
Comment thread abxbus-go/event_bus.go
Comment thread abxbus-rust/src/event_bus.rs

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 255025a7b7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread abxbus-ts/src/BaseEvent.ts Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 8 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread abxbus-ts/src/EventBus.ts

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0d98916206

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread abxbus/event_bus.py Outdated
Comment thread abxbus-go/event_bus.go Outdated
Comment thread abxbus-rust/src/event_bus.rs Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 15 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread abxbus-rust/src/event_handler.rs Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b37225e3ad

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread abxbus-ts/src/EventHandler.ts
Comment thread abxbus-ts/src/BaseEvent.ts Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5ce24e3de1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread abxbus/event_bus.py
return completed_at.astimezone(UTC).timestamp()

def _resolve_event_ttl(self, event: BaseEvent[Any]) -> float | None:
return event.event_ttl if event.event_ttl is not None else self.event_ttl

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Validate mutable Python event TTLs before resolving

Because BaseEvent disables assignment validation and EventBus exposes mutable TTL attributes, a caller can set event.event_ttl = -2 or bus.event_ttl = -2 after construction and then emit/trim the event. This resolver returns that invalid value directly, and the trim path treats negative TTLs as “retain forever”, so the new >= -1 TTL contract is bypassed for runtime edits; validate the resolved TTL (and the analogous result TTL path) before using it.

Useful? React with 👍 / 👎.

Comment thread abxbus-go/base_event.go
const jsonSchemaDraft202012 = jsonschema.Draft202012

func validateOptionalSecondsAtLeastMinusOne(name string, value *float64) error {
if value != nil && *value < -1 {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reject non-finite Go TTL values

When Go callers pass math.NaN() or math.Inf(1) for a TTL option or restored TTL field, this check accepts it because the < -1 comparison is false for NaN and true infinities pass the lower-bound test. Those values later produce inconsistent retention behavior in deadline tracking/trimming instead of being rejected under the finite seconds contract used by the other runtimes; check math.IsNaN/math.IsInf here before accepting the value.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant