Skip to content

Bound fenced intervals and open no interval for a record without a scope - #3237

Merged
Sinity merged 4 commits into
masterfrom
close-intervals-that-cannot-change
Nov 26, 2026
Merged

Sinity merged 4 commits into
masterfrom
close-intervals-that-cannot-change

Conversation

@Sinity

@Sinity Sinity commented Nov 26, 2026 •

Copy link
Copy Markdown
Owner

A window that reads an interval kind by overlap is handed every live interval of that kind with no recorded end that started before it, whatever its age. On the deployed store (schema 50, 91.7 million events, 2026-11-26) 475,867 live intervals were open in that sense and were returned, payloads included, to every later window read of their kind. This change makes an interval that can no longer change stop being open, in the read index and in the derivations that produce it.

What was open, and why

Counts from core.live_intervals and core.events on the deployed store, read-only, 2026-11-26 21:20 CET.

Kind and state Open Cause
state.interval, machine.unit 412,098 of 466,548 411,758 are runs of earlier boots: the next boot fenced them, which records fenced_at and leaves ended_at unknown, and the index kept only the end. 340 are runs of the current boot with no end record in the journal.
state.interval, machine.boot 6 of 6 Five earlier boots, fenced the same way, and the current boot.
state.interval, desktop.focus 63,604 of 74,328 63,603 on one logical day: one per window.focused record that names no scope. One is the current focus.
state.interval, desktop.workspace 159 of 2,272 158 on the same day, one per workspace.switched record that names no scope. One is current.

The focus and workspace records without a scope were written by an earlier parser version (1,002,246 live window.focused events up to 2026-11-13). The fold made a record that names no scope its own scope. A scope of one record has no next transition, so its interval never ended, its day key waited for good and was recomputed on every runner pass, and each recompute read forward to the end of the stored focus history looking for 63,761 closers that cannot exist.

What changes

An interval reaches to its end, or to its bound when its end is unknown. An interval kind can declare the payload field that bounds an unknown end (fenced_at for state.interval). core.live_intervals.ended_at now holds how far the interval reaches: the end, else the bound. Admission and restore write it; the reaching read is unchanged, because it already asks which rows contain the window's start and which are open. The query layer and admission's affected-output check already treated a fence this way; the window read now agrees with them. A fenced interval still has an unknown end and an unknown duration.

Schema step 52, fenced_interval_bounds. One statement reads the stored state.interval events that have a fence and sets the reach of their open rows. No event row is written and no derivation recomputes.

A record that names no scope opens no interval. This covers a focus or workspace change with no scope, a unit start with no host, and a boot or sleep with no host. Nothing can be matched to such a record, so an interval for it would stay open for good, be listed as current by now and reach every later window. The record stays queryable as its own event. An observed span carries its own end and still stands without a scope. The bounded reader of a day's transitions selects no scope for such a record, which removes its fallback lookups by equivalence key, native ID and material. One case goes with them: two records with no scope that shared a native ID were folded as one scope. No typed focus or workspace payload carries a native ID, and a shared record identity is not a place a state lives in. state.intervals goes from version 6 to 7 and unit.intervals from 1 to 2.

A unit run of the current boot with no end record stays open until the next boot fences it. The journal holds no end record for about three quarters of transient scope runs, nothing stored says when such a run ended, and it may still be running, so no end is made up. It costs nothing while open: its key waits on its host's boots key only, and only a reader that asks for unit runs is handed it.

Work episodes read the state kinds they use. The episode key read every state.interval over its extent by overlap, so each episode was handed every open unit run in the store. It now names lock, display and suspend states, in its read and in its affected-range check, so an admitted unit run or focus interval no longer looks up stored episodes. work.episodes goes from version 5 to 6.

Decisions and rejected alternatives

  • An age limit or an end after some time without evidence was rejected: the design rules out fixed lookbacks and invented times, and a service legitimately runs for a whole boot.
  • Keeping an interval for a record without a scope and marking it as never closing was rejected: the window read, the affected-output check, now and the waiting flag would each need a third state, for an output that restates one input event.
  • Taking the event's source as the missing scope was rejected: it invents a scope the record does not state. The records in question get scope and host from a replay with the current parser, which is filed as follow-up work.
  • core.live_intervals.ended_at keeps its name. It now holds a reach, which the table's description says; a rename would have needed frozen copies of the version 50 table and indexes for one step.

After deploy

Stop the daemon, run the schema upgrade (51 to 52), start the daemon; nothing else has to be run for the open intervals to be corrected.

  • The upgrade step corrects the 411,763 fenced unit and boot intervals. Its scan covers the state.interval events only (1.57 million by planner estimate on the deployed store).
  • The two day keys holding the 63,761 focus and workspace intervals are waiting keys, and waiting keys recompute under a new version without a switch. On the first pass with a dirty state.intervals key they are recomputed, their open intervals are archived and they stop waiting. By the lifecycle rules, archiving those intervals also marks the keys of other derivations whose reads included them (activity hours since that day, for example), which then recompute once; that burst was not measured.
  • The version changes leave state.intervals, unit.intervals and work.episodes with a pending switch for their history (selected on the deployed store today: 1, 1 and 5). None is needed for the above, since the runner computes dirty and waiting keys with the running version. Until a derivation is switched, a plain recompute of it is refused. The unit.intervals switch changes no stored output there: no unit record on that store lacks a host. A switch of state.intervals archives the focus intervals earlier builds computed for the 17 days before 2026-11-12 from records without a scope and computes none in their place, so replaying those records first keeps that history.

Verification

The hosted check and test jobs on the head are the verification (run 45899693641 passed on 35729e5, 2,342 tests; the head after merging master is checked by the run on it). The hosted code review of 35729e5 reported no findings. The tests that carry the change:

  • sinex-store a_fenced_interval_reaches_no_window_after_its_fence: a fenced interval is read by windows starting before and at its fence and by none after it, narrowed and whole-type, as admitted and after an archive and restore; an interval with neither end nor fence is read by every later window.
  • sinex-store window_reads_over_intervals_equal_the_predicate_over_every_event: the indexed read equals one statement over every event for eleven windows, now with fenced intervals in the fixture.
  • sinex-schema upgrade_fills_live_intervals_of_every_interval_kind: a version 49 database through the fill and the bound step; bound after start, end and bound, bound at or before start, unreadable bound; catalog equal to a fresh database.
  • sinex-store records_that_name_no_scope_do_not_extend_the_read_past_the_closers: 300 records without a scope in a day leave the forward read at the page that reaches the named scope's closer, with 4,096 later records unread.
  • sinex-derivations a_transition_that_names_no_scope_opens_no_interval_and_its_day_does_not_wait, a_span_that_names_no_scope_is_still_its_own_interval, a_boot_or_sleep_that_names_no_host_has_no_key_and_opens_no_interval, a_unit_record_without_a_host_has_no_key_and_opens_no_interval.
  • sinexd a_day_of_focus_records_without_a_scope_stops_waiting: a day key holding 40 stored open intervals for records without a scope, waiting, as the earlier fold left it; after the next pass they are archived, the key is not waiting and one interval is open.
  • sinexd an_episode_reads_absence_states_and_no_unit_run: an episode's read holds the suspend intervals that reach or start in it and no unit run or focus interval; admitting a unit run marks no episode.

Not run: the upgrade step against the deployed store, and the counts after deploy. Not measured: the runner's read time after the change, which needs the deployed store.

🤖 Generated with Claude Code

https://claude.ai/code/session_01UuFixsXwismFLxbfWcuXHU

Task: sxnext-pib.23

Sinity and others added 2 commits November 26, 2026 21:54
A window read by overlap returned every live interval with no recorded
end to every later window. Fenced state intervals keep their end unknown,
so each boot left its unit runs open for good, and a focus or workspace
record that names no scope became its own scope with an interval nothing
could close.

An interval now reaches to its end or to the bound its kind declares for
an unknown end (fenced_at for state.interval); the store keeps that reach
for live intervals and a schema step brings stored fenced intervals up to
date. A record that names no scope (focus, workspace) or no host (unit,
boot, sleep) opens no interval. Work episodes read the state kinds they
use.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UuFixsXwismFLxbfWcuXHU
The live intervals table keeps the end or the bound of an unknown end;
the admission page and the vocabulary said it keeps the end.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UuFixsXwismFLxbfWcuXHU
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-26T22:14:09.509722Z be7026b Manual request
🔒 Security Review ✅ Completed 2026-11-26T21:21:45.482576Z 4ecb552 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

… scope case

A state interval without start evidence has an unknown time, so the
fixtures of the two new daemon tests were never read by time. The bounds
test closed one record by another through a shared native ID with no
scope; such records now open no interval. A sleep record without a host
still names the focus and workspace days it may interrupt. The
episode's affected-range check compares the state kind directly, since
admission asks it for every stored state interval.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UuFixsXwismFLxbfWcuXHU
@Sinity

Sinity commented Nov 26, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: 35729e5977

ℹ️ 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".

…t-cannot-change

# Conflicts:
#	crates/sinex-schema/src/upgrades.rs
@Sinity

Sinity commented Nov 26, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: be7026bded

ℹ️ 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".

@Sinity
Sinity merged commit 6f928f7 into master Nov 26, 2026
2 checks passed
@Sinity
Sinity deleted the close-intervals-that-cannot-change branch November 26, 2026 22:30
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