Skip to content

Admit experiment events before resolving registration - #131

Closed
Stephen Belanger (Qard) wants to merge 1 commit into
refactor/eager-client-operationsfrom
refactor/eager-experiment-events
Closed

Stephen Belanger (Qard) wants to merge 1 commit into
refactor/eager-client-operationsfrom
refactor/eager-experiment-events

Conversation

@Qard

Copy link
Copy Markdown
Contributor

Experiment events previously registered first and queued their trace later, only after the caller polled the async method. A shutdown between those steps could close delivery admission before the event reached the queue. Make Experiment.log admit its write immediately and resolve registration during bounded delivery preparation; its Completion returns the row ID after full batch delivery. Experiment.flush now captures a cutoff immediately and returns the ordinary flush report token.

  • Reserve response capacity before admitting the dependent write. Response overload creates no write obligation; queue overload retires the response reservation and drops the registration future unpolled. Dropping an observer leaves accepted work running.
  • Resolve an immutable experiment destination inside the existing preparation pipeline. Registration errors fail the logical batch and covering flush, then retire with that batch; fresh events can retry registration without a failure ledger. Keep remaining async experiment methods pinned to the same execution binding while their conversion follows.
  • Reuse span event normalization for the complete event snapshot. Return typed admission/execution errors when adapting delivery outcomes to BraintrustError, preserving API preparation causes.
  • Detach canceled commands and barriers before notifying/dropping them outside service locks. Deferred commands may own the last queue producer, whose destructor reenters the service. Rejected rows with unresolved destinations log a diagnostic rather than initiating registration to produce a debug dump.

Stacked on #130. Other experiment methods and client span updates remain subsequent layers.

Validation: 327 unit/integration tests and 9 doctests passed; existing ignored tests unchanged. Strict all-target/all-feature Clippy, rustdoc, formatting, and diff checks passed. New regressions cover plain-thread unobserved progress after owner drop, shutdown before first poll, terminal registration failure and fresh retry, both admission limits without extra writes/registration, deferred-registration timeout, reentrant command cleanup, and stopped runtimes holding the last queue producer.

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