Repository navigation
Select a derivation by its version, switch while inputs arrive, keep a paused derivation's dirty marks - #3235
Merged
Merged
Conversation
Work in progress for the three selection defects: the build leaves the selection, a comparison stops requiring unchanged inputs, and a derivation turned off keeps its dirty marks. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UuFixsXwismFLxbfWcuXHU
The switch joined the recursion flat to core.event_children, which the planner turned into a scan of the whole child index per level, and then walked the same chains again through mark_archived_dirty. On the deployed store the flat walk of state.intervals' chains was cancelled at 150 s; the probe form took 71 s for 410,551 events. Stored comparison examples use one form for keyed and per-event derivations. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UuFixsXwismFLxbfWcuXHU
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
… drops Its database is rebuilt at schema version 47, before selection_by_version, so the step needs the build column to be there. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UuFixsXwismFLxbfWcuXHU
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
On a store that captures continuously, the documented ways to recompute or switch a keyed derivation could not be used after a deploy. This change fixes the three defects behind that and two reads that made a comparison and a switch impractical at the deployed store's size.
What changed
The selection is the version.
registry.derivationsheld the version and the build that selected it, andrecomputecompared both with the running build, so every deploy left every derivation refusingrecompute NAME [--since]with "producer version changed" although no version had changed. The build column is dropped (schema stepselection_by_version);recompute, the on-request computation andstatuscompare versions only. The build stays where it is provenance: on each run's manifest, in each comparison and in theproducer_switchoperation. A derivation that never ran has no selection:recomputeis accepted for it andstatusreportsnever_runinstead of a pending switch.statusno longer hasselected_build.A comparison is a trial, not a hold on the inputs. A comparison refused itself at its end, and its switch was refused, if any event of an input kind had been committed since it started. A comparison that outlasts the gap between two inputs could therefore never be selected. The rule is removed, with
InputStateand its two SQL files. A switch now needs a full comparison, not yet consumed, that the running build made of the same version, declaration and logical-day settings. Unchanged inputs are not needed for correctness: a keyedrecomputeswitch archives the live output chains and marks dirty every key its inputs or outputs name in one writer transaction, and admission marks whatever is committed after it; a per-eventrecomputeswitch resets the saved position;keep_historyapplies from the switch onward. The rule protected only the comparison's counts. What keeps those honest instead: each key is computed and its stored outputs are read in one snapshot, and a key that was dirty in that snapshot (or a per-event input after the saved position) is counted as behind its inputs. The comparison stores that count and the commit positions it ran between, and its summary line shows it.A derivation turned off is paused. The daemon removed configured-off derivations from the writer's dirty-marking list, so inputs admitted meanwhile marked nothing and those keys stayed stale after the derivation was turned on. The writer now marks the keys of every keyed derivation the build has, as the offline admin commands already did; only the runner's list follows the configuration.
A key's stored outputs are read from its members.
derivations::outputsjoinedderivation.outputstocore.eventson the event ID with nothing to bound it. It now takes the key's live member IDs from the membership index and reads their rows by ID inside their ID bounds and under the derivation's name, the leading segment column of compressed batches. The comparison and the provenance stamping ofanalysis.productsandcontext.packsuse this read.A keyed switch finds its outputs by membership and walks their chains once. The switch selected a derivation's outputs with
core.events WHERE source = $1inside the writer transaction; uncompressed chunks have no index led by source. A keyed derivation's outputs are now read fromderivation.outputs. A per-event derivation keeps no such list and still uses the source read (filed as sxnext-pib.27). The walk down the output chains now probes the child index once per event; joined flat, the planner could not size the recursion and scanned the wholecore.event_childrenindex once per level. The switch then marks keys from that set directly, where it used to walk the same chains a second time throughmark_archived_dirty.Decisions and the alternatives rejected
docs/derivations.mdsaidreplay --switch ID"refuses changed inputs". That clause described this mechanism, so it now says the switch consumes the trial whatever arrived since. The client form is untouched.Figures
Read-only measurements on the deployed store (sinexd a3f4eb3, 2026-11-26, cached):
state.intervalsday key with 594 live outputsstate.intervalsoutputsstate.intervals' output chains (89,917 live outputs, 410,551 events)The "after" rows were measured by running the new statements by hand; the comparison and the switch themselves were not run on the deployed store.
Not improved here: the switch still archives every live output chain in one writer transaction, 410,551 events for
state.intervals. That is sxnext-pib.20's subject, which recorded about 390,000 outputs archived in about 30 minutes of writer time.Verification
cargo xtask checkon 5ec539e (AgentCTL job 4279).cargo xtask test -p sinex-schema -p sinex-store -p sinexd -E '<schema; store derivations, registry, telemetry, admission; sinexd derivation_runner, api versions and comparisons, daemon, dirty_keys, lifecycle; integration paused_derivation and documents>': 224 passed (AgentCTL job 4271).checkpassed;testran 997 tests and failed one,publisher_resumes_at_its_position_after_the_upgrade, whose fixture rebuilds the schema at version 47 and so lacked the column the new step drops. f12e368 gives the fixture that column; the publisher, reader-context and writer tests pass locally (AgentCTL job 4294). The hosted checks on that head are the verification of record.shell.sessionsoff admits a command, and the session appears after a restart with it on; the publicrecomputewith a time range marks keys;statusshows a pending switch only for another version; a key's outputs are read from plain and compressed chunks; the schema step keeps every selected version.Not verified: acceptance row 4 of the task (compare, switch and a time-range recompute on the deployed store), which needs the deploy. The full workspace test run is left to the hosted checks.
Deployment
The schema moves from version 50 to 51: stop
sinexd, runsystemctl start sinex-schema-upgrade, startsinexd. The step drops one column and rewrites nothing.Task: sxnext-pib.25
🤖 Generated with Claude Code
https://claude.ai/code/session_01UuFixsXwismFLxbfWcuXHU