Catalog: say when a watched row changes, as it is (#19)
jonas, 2026-11-27 00:09 UTC ยท 58f97d7ecce8c6fd284cc84a81b3cccc8562f459 ยท parent 6f4fd09
2 files changed
M core/itx/src/context/awake.ts
@@ -13,10 +13,21 @@ // - One Durable Object accepts 32,768 sockets. A dial refused past that is logged, and that // context is missing from the list: nothing else depends on the socket. // -// The same socket carries what a context says about itself (context-summary.ts), at most once per -// 15 s while it works and once before it closes. The accepting context keeps the newest of each in -// one SQLite row (context-catalog.ts): one row written per wake of a context, beside the rows that -// wake writes in its own log. +// The same socket carries what a context says about itself (context-summary.ts). A context that +// works sends its summary at three times: +// - `AWAKE_ACTIVITY_DEBOUNCE_MS` after its activity stack changed or it said what it is. That +// wait gathers a burst of such changes into one summary. It is no least time between two +// summaries; +// - at a recheck, each `AWAKE_QUIET_MS` while it is busy, when such a change is not yet said or +// the last summary is `AWAKE_SUMMARY_EVERY_MS` old; +// - before it closes. +// A summary whose text equals the last one sent is not sent, so a wake can send none. A context +// whose activity stack changes often sends about ten summaries a second; one long activity that +// only appends sends one per `AWAKE_SUMMARY_EVERY_MS`. The accepting context keeps the durable +// part of each summary that comes in one SQLite row (context-catalog.ts `store`). It writes that +// row at each summary of an equal or later offset and does not compare the two: a summary that +// differs in its activities alone writes the same row again. These rows are beside the rows +// that the wake writes in the context's own log. // // THE CATALOG ANSWERS EACH SUMMARY, on the same socket: it kept it, or it refused it. A context // that goes quiet keeps its socket until its last summary is answered, at most
M core/lib/src/api.ts
@@ -1873,8 +1873,14 @@ /** ONE CONTEXT AS A WATCH SENDS IT: its listing without `awake` and `activities` (the awake list * is a watch of its own, `{ awake: true }`), the two values that the orders sort by, and the - * catalog's revision at which the row last changed. A row changes when its context says - * something new of itself: at most once in 15 s while it works, and once when it goes quiet. */ + * catalog's revision at which the row last changed. A ROW CHANGES WHEN ITS CONTEXT SENDS A + * SUMMARY THAT DIFFERS in something the row holds: the counts and times of its events, its + * storage, what it says of itself. A context that works sends a summary shortly after each + * burst of changes of its activity stack, once in 15 s with no such change, and once when it + * goes quiet. It gathers a burst for 100 ms, and that is no least time between two summaries. + * So the row of a context that does many short pieces of work, each of which adds to its log, + * changes about ten times a second: a watcher that draws should not draw at each frame. One + * long piece of work that only adds to the log changes the row once in 15 s. */ export type CatalogRow = Omit<ContextListing, "awake" | "activities"> & { /** What the order `active` sorts by, in milliseconds: when the context was last active * (`lastActivityAt`, or `lastEventAt` when it has had no activity of its own). */