Repository navigation
Let producers settle windows when act output completes - #51
Conversation
There was a problem hiding this comment.
Devin Review found 1 potential issue.
1 flag not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)
| if (entry.kind === 'consequence' && entry.settles === true && state.open.summary.firstActIndex !== -1) { | ||
| state.open.endedAt = observationTime(entry); |
There was a problem hiding this comment.
🔴 Replay closes legacy windows early
After an upgrade, ingest treats legacy settles: true metadata in a stored consequence as a completion signal. Replay applies the new rule to old inputs. The judge misses output that arrives within the original grace period.
Learn more
Before revision 7, event copying preserved extra top-level fields without interpreting settles. The NDJSON event parser also forwards those fields to the engine. A snapshot records the open window at a checkpoint; its tail contains the accepted inputs since then. Replay uses the snapshot's policy but applies the current reducer to the tail, and scope loading schedules the resulting state. This turns an old consequence's metadata into an end deadline, even when every process has upgraded and no producer uses the new feature. Python replay has the same behavior with _ingest.
Example: A revision-6 writer accepts a save at 100 ms and a consequence with application metadata settles: true at 110 ms. With a 500 ms closing grace, the saved window is due at 600 ms. Restarting on revision 7 at 110 ms with the consequence in the tail makes it due at 110 ms. The judge sees the save and that consequence, but the real output at 120 ms lands in a background-only window instead of joining the save.
Recommended fix: Preserve revision-6 settlement semantics when replaying a pre-7 tail. Keep legacy metadata in the payload without treating it as control data. Apply the new interpretation only to inputs written under revision 7, and add upgrade tests in both runtimes that verify the deadline and judged payload.
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
Fixed in 74b837a. replay now gives settles its meaning only when the tail sits under a snapshot taken at revision 7 or later (or under no snapshot). A tail logged under an older snapshot keeps the field as plain metadata, so the old closing grace stands. There's a regression test in each runtime (test/closing-settlement.test.ts, python/tests/test_closing_settlement.py), and docs/storage.md says so. quietForMs on a closing event can't appear in an older tail, because revision 6 refused it at admission.
A tail replayed under an older snapshot was written by a reducer that gave settles no meaning, so it stays plain metadata there instead of ending the window early. Both runtimes, with a regression test in each.
Summary
A fixed closing grace can wake an agent before output arrives or keep it waiting after output is complete.
quietForMs. The closing deadline is the latest of the default grace for closing events that omit the field and each explicit observation time plus its duration.settles: trueto end the acts already in the open window through push, attach or serial intake. It can end an active continuous stream with reasonclosingand wait still eligible. After a wait, a fresh act must precede the marker. Accumulating retries keep their strict deadline.Evidence
pnpm checkwith 1,671 tests passed and two existing Redis poll cases skipped. All 128 oracle tests and eight shared fixture checks passed.