You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This turns the public experiment/environment/sample seam into persisted provenance and a candidate buffer. It lets streamed and batch environments contribute candidate samples without immediately launching work.
What Actually Changes
Adds experiment SQLModel rows under core/persistence/experiments.
Adds migration/metadata wiring for experiment persistence.
Adds CoreExperimentPersistencePort.
Adds repository and candidate pool logic under core/application/experiments.
Persists experiment rows, environment rows, sampler invocations, and candidate pool entries.
Stores both sample_ref_json and full sample_json for candidate rows.
Reuses pending unselected rows before pulling more samples from environments.
Round-robins environments during fill and dedupes on environment/sample key.
Adds sample_from_pool_entry(...) to rehydrate candidate JSON through public Task.from_definition(...), while avoiding materialized runtime sample IDs.
Gotchas / Review Risks
This PR should not create SampleRecord runtime rows or WAL rows. It is persistence and buffering only.
The implemented schema follows the PR 04 plan more than the broader sketch: sampler_name, sampler_config_json, requested_k, and sample_ref_json are the important review fields.
Candidate refill can advance streaming environments; retained unselected rows are what prevent dropped candidates.
record_sampler_invocation may look uncalled in this PR because the real caller lands in PR 05.
At review time, this PR had known red CI from migration ordering (sample_context_events before sample_task_attempts) and architecture-guard expectations that later stack cleanup adjusts.
Cleaned Later
PR 05 records sampler invocations from real submit and materializes selected samples.
PR 11 removes definition-backed compatibility.
PR 12 uses candidate pool entries for trainer rollout batches.
Validation Notes
Key review tests are experiment persistence roundtrip, candidate pool behavior, Alembic/metadata checks, and architecture guards around where persistence code is allowed to live.
Closed after landing the cumulative episode/sample stack snapshot through PR132 directly onto dev in merge commit 1c22130. This PR's changes are included in dev.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Review Guide
Stack position: PR 04, base
codex/episode-sample-pr03-public-authoring-api, headcodex/episode-sample-pr04-experiment-persistence.Implements RFC Docs
03a-persistence-schemas.md:experiments,experiment_environments,experiment_sampler_invocations, andexperiment_sample_pool_entries.03-core-runtime-persistence-fe.md: candidate buffering and retention.03b-implementation-churn.md:persist_experiment, candidate pool fill, sampler invocation records.09-implementation-plan/05-pr-04-experiment-persistence-candidate-pool.md.Why This PR Exists
This turns the public experiment/environment/sample seam into persisted provenance and a candidate buffer. It lets streamed and batch environments contribute candidate samples without immediately launching work.
What Actually Changes
core/persistence/experiments.CoreExperimentPersistencePort.core/application/experiments.sample_ref_jsonand fullsample_jsonfor candidate rows.sample_from_pool_entry(...)to rehydrate candidate JSON through publicTask.from_definition(...), while avoiding materialized runtime sample IDs.Gotchas / Review Risks
SampleRecordruntime rows or WAL rows. It is persistence and buffering only.sampler_name,sampler_config_json,requested_k, andsample_ref_jsonare the important review fields.record_sampler_invocationmay look uncalled in this PR because the real caller lands in PR 05.sample_context_eventsbeforesample_task_attempts) and architecture-guard expectations that later stack cleanup adjusts.Cleaned Later
Validation Notes
Key review tests are experiment persistence roundtrip, candidate pool behavior, Alembic/metadata checks, and architecture guards around where persistence code is allowed to live.