diff --git a/DEVIATIONS.md b/DEVIATIONS.md
index da5e702..f9a6b8a 100644
--- a/DEVIATIONS.md
+++ b/DEVIATIONS.md
@@ -1,16 +1,22 @@
# Shell changes from the frozen shell
+## Accumulating continuation
+
+The optional `settle.continuation = 'accumulate'` reoffers waits within their allowance, retains provider failures across waits and absorbs admitted input at a strict retry not-before time. Whole-window count, rendered bytes and age constrain wait eligibility, including ties. Ordinary continuation keeps the frozen behavior. The existing reducer and delivery machinery remain in use; no host timer or alternate scheduler is introduced.
+
+Reducer revision 4 records this transition change. Accumulating waiting state retains failures; legacy separate waiting state keeps its historical zero-reset meaning. A live writer mode change requires no held batch or fresh entries. Old readers are not fenced by this revision number. [The reference](docs/reference.md#accumulating-continuation) defines the API and limits.
+
## Serial intake
The optional serial intake owns registration, asynchronous preparation and immediate effects for one scope. It gives registered raw work precedence over an idle deferred timer and suppresses the pre-input catch-up tick for that owned input only. The existing reducer tick runs after a nonempty batch. Ordinary input and frozen differential cases retain their prior scheduling.
-The queue, callbacks and catch-up metadata are local and are never stored. Persisted inputs and reducer revision 3 are unchanged. Closing fences unapplied completion results and joins their native release writes. This is local ordering, not distributed scope ownership. [Serial intake](docs/reference.md#serial-intake) defines the boundary and limits.
+The queue, callbacks and catch-up metadata are local and are never stored. Serial intake introduced no new persisted inputs or reducer-version change. Closing fences unapplied completion results and joins their native release writes. This is local ordering, not distributed scope ownership. [Serial intake](docs/reference.md#serial-intake) defines the boundary and limits.
## Continuous quiet duration
An optional `Event.quietForMs` gives a continuous event its own quiet duration. Once any continuous entry supplies it, the continuous deadline is the latest of the entries' individual end times. Entries without a duration use the policy's `streamGapMs`. Other kinds keep their independent triggers. With no explicit duration, the frozen default behavior remains unchanged, including backwards clocks.
-The reducer revision is 3. Explicit durations persist in entries and logged inputs; summaries rebuild from them. Tail replay uses the snapshot policy for omitted durations. A live policy change recomputes those defaults under the new policy, as before. Processes sharing a store must use the same revision before opting in. Shared fixtures and runtime tests cover the extension; the frozen differential cases omit it. [The reference](docs/reference.md#continuous-quiet-duration) defines admission and timing.
+Continuous durations were introduced in reducer revision 3. Explicit durations persist in entries and logged inputs; summaries rebuild from them. Tail replay uses the snapshot policy for omitted durations. A live policy change recomputes those defaults under the new policy, as before. Processes sharing a store must use the same revision before opting in. Shared fixtures and runtime tests cover the extension; the frozen differential cases omit it. [The reference](docs/reference.md#continuous-quiet-duration) defines admission and timing.
## Observation time
diff --git a/conformance/README.md b/conformance/README.md
index e5bcd4b..12f1ed3 100644
--- a/conformance/README.md
+++ b/conformance/README.md
@@ -1,8 +1,8 @@
# Conformance fixtures
-attend has two implementations, TypeScript in `src/` and Python in `python/`. Both run the JSON fixtures in this directory and must reproduce every recorded value. The TypeScript source is the spec: `pnpm conformance:update` rebuilds every fixture from `src`, and `pnpm test` fails when `src` and the fixtures disagree.
+attend has two implementations, TypeScript in `src/` and Python in `python/`. Both run the JSON fixtures in this directory and must reproduce every recorded value. `pnpm conformance:update` rebuilds the current-behavior fixtures from TypeScript `src`, and `pnpm test` fails when source and fixtures disagree. Frozen legacy fixtures are excluded from regeneration so a change cannot rewrite its compatibility baseline.
-| Fixture | What it pins | TypeScript source |
+| Fixture | What it pins | Source |
|---|---|---|
| `step-101.json`, `step-202.json`, `step-303.json` | The pure reducer. Each plan is a list of logged inputs from a seeded random plan, stepped from `initialRecord(scope)` with its config. Every step records its effects in full and a digest of the record after it, and every 16th step and the last also record the full record. | `test/conformance/fixtures.ts` |
| `ids.json` | Window ids (FNV-1a 64 over `len:scope` and each `len:id`) for pinned and random strings, lone surrogates included, and UTF-8 lengths. | `test/conformance/fixtures.ts` |
@@ -10,6 +10,7 @@ attend has two implementations, TypeScript in `src/` and Python in `python/`. Bo
| `notice.json` | `defaultNotice` text. | `test/conformance/fixtures.ts` |
| `scenarios.json` | The runtime: timed pushes, flushes and ends per scope through `createAttend` on a fake clock over the memory store, with scripted judge, sink and dead-letter answers. Each records every judge input, every delivery and dead-letter attempt, every trace by scope, each call's result, inspections, the final records and the decision log. | `test/conformance/scenario.ts`, `test/conformance/scenarios.ts` |
| `judges.json` | `jevJudge`, `decisionsJudge` and `llmJudge` against scripted replies: every request byte for byte, the budget, and how the call ended. | `test/conformance/judges.ts` |
+| `continuation-legacy.json` | Revision-3 commit groups, snapshots/tails and expected reads, captured from source commit `f111566c1fa28d7dd7a124502eca4943dbbe15d6`. Both ports load the original writes and check reads plus mode-switch behavior. Frozen; not rebuilt by `conformance:update`. | `test/continuation.test.ts`, `python/tests/test_continuation.py` |
## Comparing values
@@ -22,6 +23,8 @@ attend has two implementations, TypeScript in `src/` and Python in `python/`. Bo
A scenario starts a fake clock at `start` (default 1000), creates attend over a fresh memory store with the scenario's `kinds` map, `settle` policy and `config`, and runs it with `sweepMs` (default 1000). It then performs its steps in order and lets the runtime go idle after each one:
- `push`: push the events to the scope and await it. Events default to `at: 0` and `data: {}`.
+- `submit`: register preparation on a scope named in `intakes`. It can delay or fail preparation and return a source cursor or truncation flag. The runner opens those handles before starting attend.
+- `closeIntake`: fence and join that scope's intake.
- `advance`: advance the fake clock, firing each due timer in order and letting its work finish.
- `flush` and `end`: call them on the scope and await them.
- `release`: settle a held judge answer or handler attempt, with `answer` or with `fail` and `permanent`.
diff --git a/conformance/fixtures/continuation-legacy.json b/conformance/fixtures/continuation-legacy.json
new file mode 100644
index 0000000..642b647
--- /dev/null
+++ b/conformance/fixtures/continuation-legacy.json
@@ -0,0 +1,1515 @@
+{
+ "source": "f111566c1fa28d7dd7a124502eca4943dbbe15d6",
+ "cases": [
+ {
+ "name": "waiting-tail",
+ "through": 40,
+ "writes": [
+ [
+ {
+ "scope": "scope",
+ "expectedVersion": 0,
+ "inputs": [
+ {
+ "input": {
+ "kind": "events",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "observedAt": 0,
+ "name": "reading",
+ "text": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
+ "data": {},
+ "kind": "continuous"
+ }
+ ]
+ },
+ "now": 0
+ }
+ ],
+ "snapshot": {
+ "version": 1,
+ "record": {
+ "version": 1,
+ "scope": "scope",
+ "cursors": {},
+ "seen": [
+ "a"
+ ],
+ "buffer": {
+ "entries": [
+ {
+ "id": "a",
+ "at": 0,
+ "observedAt": 0,
+ "name": "reading",
+ "text": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
+ "data": {},
+ "kind": "continuous",
+ "seenAt": 0
+ }
+ ],
+ "dropped": 0,
+ "gap": false,
+ "forcedAt": null
+ },
+ "batch": null,
+ "outbox": {
+ "decisions": [],
+ "deadLetters": []
+ },
+ "recent": [],
+ "dueAt": 10
+ },
+ "policy": {
+ "closingGraceMs": 500,
+ "streamGapMs": 10,
+ "passiveQuietMs": 4000,
+ "waitHorizonMs": 20,
+ "maxWaits": 2,
+ "maxEvents": 250,
+ "maxWindowMs": 60000,
+ "retryBackoffMs": [
+ 30,
+ 60
+ ],
+ "judgeTimeoutMs": 15000,
+ "deliveryTimeoutMs": 10000,
+ "recentCount": 8,
+ "seenCount": 500,
+ "maxOutbox": 1000,
+ "maxDeadLetters": 1000,
+ "deadLetterBackoffMaxMs": 60000
+ },
+ "reducer": 3
+ },
+ "appends": [],
+ "due": 1000
+ }
+ ],
+ [
+ {
+ "scope": "scope",
+ "expectedVersion": 1,
+ "inputs": [
+ {
+ "input": {
+ "kind": "tick"
+ },
+ "now": 10
+ }
+ ],
+ "snapshot": null,
+ "appends": [],
+ "due": 31000
+ }
+ ],
+ [
+ {
+ "scope": "scope",
+ "expectedVersion": 2,
+ "inputs": [
+ {
+ "input": {
+ "kind": "judgeFailed",
+ "batchId": "cf8923dfae84f930",
+ "attempt": 1,
+ "message": "controlled outage",
+ "permanent": false
+ },
+ "now": 10
+ }
+ ],
+ "snapshot": null,
+ "appends": [],
+ "due": 1000
+ }
+ ],
+ [
+ {
+ "scope": "scope",
+ "expectedVersion": 3,
+ "inputs": [
+ {
+ "input": {
+ "kind": "tick"
+ },
+ "now": 40
+ }
+ ],
+ "snapshot": null,
+ "appends": [],
+ "due": 31000
+ }
+ ],
+ [
+ {
+ "scope": "scope",
+ "expectedVersion": 4,
+ "inputs": [
+ {
+ "input": {
+ "kind": "judged",
+ "batchId": "cf8923dfae84f930",
+ "attempt": 2,
+ "judgment": {
+ "route": "wait"
+ }
+ },
+ "now": 40
+ }
+ ],
+ "snapshot": null,
+ "appends": [],
+ "due": 1000
+ }
+ ]
+ ],
+ "stored": {
+ "version": 5,
+ "snapshot": {
+ "version": 1,
+ "record": {
+ "version": 1,
+ "scope": "scope",
+ "cursors": {},
+ "seen": [
+ "a"
+ ],
+ "buffer": {
+ "entries": [
+ {
+ "id": "a",
+ "at": 0,
+ "observedAt": 0,
+ "name": "reading",
+ "text": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
+ "data": {},
+ "kind": "continuous",
+ "seenAt": 0
+ }
+ ],
+ "dropped": 0,
+ "gap": false,
+ "forcedAt": null
+ },
+ "batch": null,
+ "outbox": {
+ "decisions": [],
+ "deadLetters": []
+ },
+ "recent": [],
+ "dueAt": 10
+ },
+ "policy": {
+ "closingGraceMs": 500,
+ "streamGapMs": 10,
+ "passiveQuietMs": 4000,
+ "waitHorizonMs": 20,
+ "maxWaits": 2,
+ "maxEvents": 250,
+ "maxWindowMs": 60000,
+ "retryBackoffMs": [
+ 30,
+ 60
+ ],
+ "judgeTimeoutMs": 15000,
+ "deliveryTimeoutMs": 10000,
+ "recentCount": 8,
+ "seenCount": 500,
+ "maxOutbox": 1000,
+ "maxDeadLetters": 1000,
+ "deadLetterBackoffMaxMs": 60000
+ },
+ "reducer": 3
+ },
+ "tail": [
+ {
+ "input": {
+ "kind": "tick"
+ },
+ "now": 10
+ },
+ {
+ "input": {
+ "kind": "judgeFailed",
+ "batchId": "cf8923dfae84f930",
+ "attempt": 1,
+ "message": "controlled outage",
+ "permanent": false
+ },
+ "now": 10
+ },
+ {
+ "input": {
+ "kind": "tick"
+ },
+ "now": 40
+ },
+ {
+ "input": {
+ "kind": "judged",
+ "batchId": "cf8923dfae84f930",
+ "attempt": 2,
+ "judgment": {
+ "route": "wait"
+ }
+ },
+ "now": 40
+ }
+ ]
+ },
+ "expected": {
+ "version": 5,
+ "scope": "scope",
+ "cursors": {},
+ "seen": [
+ "a"
+ ],
+ "buffer": {
+ "entries": [],
+ "dropped": 0,
+ "gap": false,
+ "forcedAt": null
+ },
+ "batch": {
+ "window": {
+ "id": "cf8923dfae84f930",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "observedAt": 0,
+ "name": "reading",
+ "text": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
+ "data": {},
+ "kind": "continuous",
+ "seenAt": 0
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 1,
+ "dropped": 0,
+ "gap": false,
+ "settledAt": 10
+ },
+ "phase": {
+ "phase": "waiting",
+ "attempt": 2,
+ "until": 60
+ }
+ },
+ "outbox": {
+ "decisions": [],
+ "deadLetters": []
+ },
+ "recent": [],
+ "dueAt": 60
+ }
+ },
+ {
+ "name": "waiting-snapshot",
+ "through": 40,
+ "writes": [
+ [
+ {
+ "scope": "scope",
+ "expectedVersion": 0,
+ "inputs": [
+ {
+ "input": {
+ "kind": "events",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "observedAt": 0,
+ "name": "reading",
+ "text": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
+ "data": {},
+ "kind": "continuous"
+ }
+ ]
+ },
+ "now": 0
+ }
+ ],
+ "snapshot": {
+ "version": 1,
+ "record": {
+ "version": 1,
+ "scope": "scope",
+ "cursors": {},
+ "seen": [
+ "a"
+ ],
+ "buffer": {
+ "entries": [
+ {
+ "id": "a",
+ "at": 0,
+ "observedAt": 0,
+ "name": "reading",
+ "text": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
+ "data": {},
+ "kind": "continuous",
+ "seenAt": 0
+ }
+ ],
+ "dropped": 0,
+ "gap": false,
+ "forcedAt": null
+ },
+ "batch": null,
+ "outbox": {
+ "decisions": [],
+ "deadLetters": []
+ },
+ "recent": [],
+ "dueAt": 10
+ },
+ "policy": {
+ "closingGraceMs": 500,
+ "streamGapMs": 10,
+ "passiveQuietMs": 4000,
+ "waitHorizonMs": 20,
+ "maxWaits": 2,
+ "maxEvents": 250,
+ "maxWindowMs": 60000,
+ "retryBackoffMs": [
+ 30,
+ 60
+ ],
+ "judgeTimeoutMs": 15000,
+ "deliveryTimeoutMs": 10000,
+ "recentCount": 8,
+ "seenCount": 500,
+ "maxOutbox": 1000,
+ "maxDeadLetters": 1000,
+ "deadLetterBackoffMaxMs": 60000
+ },
+ "reducer": 3
+ },
+ "appends": [],
+ "due": 1000
+ }
+ ],
+ [
+ {
+ "scope": "scope",
+ "expectedVersion": 1,
+ "inputs": [
+ {
+ "input": {
+ "kind": "tick"
+ },
+ "now": 10
+ }
+ ],
+ "snapshot": {
+ "version": 2,
+ "record": {
+ "version": 2,
+ "scope": "scope",
+ "cursors": {},
+ "seen": [
+ "a"
+ ],
+ "buffer": {
+ "entries": [],
+ "dropped": 0,
+ "gap": false,
+ "forcedAt": null
+ },
+ "batch": {
+ "window": {
+ "id": "cf8923dfae84f930",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "observedAt": 0,
+ "name": "reading",
+ "text": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
+ "data": {},
+ "kind": "continuous",
+ "seenAt": 0
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 0,
+ "dropped": 0,
+ "gap": false,
+ "settledAt": 10
+ },
+ "phase": {
+ "phase": "judging",
+ "attempt": 1,
+ "failures": 0,
+ "leaseUntil": 30010,
+ "offerWait": true
+ }
+ },
+ "outbox": {
+ "decisions": [],
+ "deadLetters": []
+ },
+ "recent": [],
+ "dueAt": 30010
+ },
+ "policy": {
+ "closingGraceMs": 500,
+ "streamGapMs": 10,
+ "passiveQuietMs": 4000,
+ "waitHorizonMs": 20,
+ "maxWaits": 2,
+ "maxEvents": 250,
+ "maxWindowMs": 60000,
+ "retryBackoffMs": [
+ 30,
+ 60
+ ],
+ "judgeTimeoutMs": 15000,
+ "deliveryTimeoutMs": 10000,
+ "recentCount": 8,
+ "seenCount": 500,
+ "maxOutbox": 1000,
+ "maxDeadLetters": 1000,
+ "deadLetterBackoffMaxMs": 60000
+ },
+ "reducer": 3
+ },
+ "appends": [],
+ "due": 31000
+ }
+ ],
+ [
+ {
+ "scope": "scope",
+ "expectedVersion": 2,
+ "inputs": [
+ {
+ "input": {
+ "kind": "judgeFailed",
+ "batchId": "cf8923dfae84f930",
+ "attempt": 1,
+ "message": "controlled outage",
+ "permanent": false
+ },
+ "now": 10
+ }
+ ],
+ "snapshot": {
+ "version": 3,
+ "record": {
+ "version": 3,
+ "scope": "scope",
+ "cursors": {},
+ "seen": [
+ "a"
+ ],
+ "buffer": {
+ "entries": [],
+ "dropped": 0,
+ "gap": false,
+ "forcedAt": null
+ },
+ "batch": {
+ "window": {
+ "id": "cf8923dfae84f930",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "observedAt": 0,
+ "name": "reading",
+ "text": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
+ "data": {},
+ "kind": "continuous",
+ "seenAt": 0
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 0,
+ "dropped": 0,
+ "gap": false,
+ "settledAt": 10
+ },
+ "phase": {
+ "phase": "retrying",
+ "attempt": 1,
+ "failures": 1,
+ "at": 40,
+ "offerWait": true
+ }
+ },
+ "outbox": {
+ "decisions": [],
+ "deadLetters": []
+ },
+ "recent": [],
+ "dueAt": 40
+ },
+ "policy": {
+ "closingGraceMs": 500,
+ "streamGapMs": 10,
+ "passiveQuietMs": 4000,
+ "waitHorizonMs": 20,
+ "maxWaits": 2,
+ "maxEvents": 250,
+ "maxWindowMs": 60000,
+ "retryBackoffMs": [
+ 30,
+ 60
+ ],
+ "judgeTimeoutMs": 15000,
+ "deliveryTimeoutMs": 10000,
+ "recentCount": 8,
+ "seenCount": 500,
+ "maxOutbox": 1000,
+ "maxDeadLetters": 1000,
+ "deadLetterBackoffMaxMs": 60000
+ },
+ "reducer": 3
+ },
+ "appends": [],
+ "due": 1000
+ }
+ ],
+ [
+ {
+ "scope": "scope",
+ "expectedVersion": 3,
+ "inputs": [
+ {
+ "input": {
+ "kind": "tick"
+ },
+ "now": 40
+ }
+ ],
+ "snapshot": {
+ "version": 4,
+ "record": {
+ "version": 4,
+ "scope": "scope",
+ "cursors": {},
+ "seen": [
+ "a"
+ ],
+ "buffer": {
+ "entries": [],
+ "dropped": 0,
+ "gap": false,
+ "forcedAt": null
+ },
+ "batch": {
+ "window": {
+ "id": "cf8923dfae84f930",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "observedAt": 0,
+ "name": "reading",
+ "text": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
+ "data": {},
+ "kind": "continuous",
+ "seenAt": 0
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 0,
+ "dropped": 0,
+ "gap": false,
+ "settledAt": 10
+ },
+ "phase": {
+ "phase": "judging",
+ "attempt": 2,
+ "failures": 1,
+ "leaseUntil": 30040,
+ "offerWait": true
+ }
+ },
+ "outbox": {
+ "decisions": [],
+ "deadLetters": []
+ },
+ "recent": [],
+ "dueAt": 30040
+ },
+ "policy": {
+ "closingGraceMs": 500,
+ "streamGapMs": 10,
+ "passiveQuietMs": 4000,
+ "waitHorizonMs": 20,
+ "maxWaits": 2,
+ "maxEvents": 250,
+ "maxWindowMs": 60000,
+ "retryBackoffMs": [
+ 30,
+ 60
+ ],
+ "judgeTimeoutMs": 15000,
+ "deliveryTimeoutMs": 10000,
+ "recentCount": 8,
+ "seenCount": 500,
+ "maxOutbox": 1000,
+ "maxDeadLetters": 1000,
+ "deadLetterBackoffMaxMs": 60000
+ },
+ "reducer": 3
+ },
+ "appends": [],
+ "due": 31000
+ }
+ ],
+ [
+ {
+ "scope": "scope",
+ "expectedVersion": 4,
+ "inputs": [
+ {
+ "input": {
+ "kind": "judged",
+ "batchId": "cf8923dfae84f930",
+ "attempt": 2,
+ "judgment": {
+ "route": "wait"
+ }
+ },
+ "now": 40
+ }
+ ],
+ "snapshot": {
+ "version": 5,
+ "record": {
+ "version": 5,
+ "scope": "scope",
+ "cursors": {},
+ "seen": [
+ "a"
+ ],
+ "buffer": {
+ "entries": [],
+ "dropped": 0,
+ "gap": false,
+ "forcedAt": null
+ },
+ "batch": {
+ "window": {
+ "id": "cf8923dfae84f930",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "observedAt": 0,
+ "name": "reading",
+ "text": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
+ "data": {},
+ "kind": "continuous",
+ "seenAt": 0
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 1,
+ "dropped": 0,
+ "gap": false,
+ "settledAt": 10
+ },
+ "phase": {
+ "phase": "waiting",
+ "attempt": 2,
+ "until": 60
+ }
+ },
+ "outbox": {
+ "decisions": [],
+ "deadLetters": []
+ },
+ "recent": [],
+ "dueAt": 60
+ },
+ "policy": {
+ "closingGraceMs": 500,
+ "streamGapMs": 10,
+ "passiveQuietMs": 4000,
+ "waitHorizonMs": 20,
+ "maxWaits": 2,
+ "maxEvents": 250,
+ "maxWindowMs": 60000,
+ "retryBackoffMs": [
+ 30,
+ 60
+ ],
+ "judgeTimeoutMs": 15000,
+ "deliveryTimeoutMs": 10000,
+ "recentCount": 8,
+ "seenCount": 500,
+ "maxOutbox": 1000,
+ "maxDeadLetters": 1000,
+ "deadLetterBackoffMaxMs": 60000
+ },
+ "reducer": 3
+ },
+ "appends": [],
+ "due": 1000
+ }
+ ]
+ ],
+ "stored": {
+ "version": 5,
+ "snapshot": {
+ "version": 5,
+ "record": {
+ "version": 5,
+ "scope": "scope",
+ "cursors": {},
+ "seen": [
+ "a"
+ ],
+ "buffer": {
+ "entries": [],
+ "dropped": 0,
+ "gap": false,
+ "forcedAt": null
+ },
+ "batch": {
+ "window": {
+ "id": "cf8923dfae84f930",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "observedAt": 0,
+ "name": "reading",
+ "text": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
+ "data": {},
+ "kind": "continuous",
+ "seenAt": 0
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 1,
+ "dropped": 0,
+ "gap": false,
+ "settledAt": 10
+ },
+ "phase": {
+ "phase": "waiting",
+ "attempt": 2,
+ "until": 60
+ }
+ },
+ "outbox": {
+ "decisions": [],
+ "deadLetters": []
+ },
+ "recent": [],
+ "dueAt": 60
+ },
+ "policy": {
+ "closingGraceMs": 500,
+ "streamGapMs": 10,
+ "passiveQuietMs": 4000,
+ "waitHorizonMs": 20,
+ "maxWaits": 2,
+ "maxEvents": 250,
+ "maxWindowMs": 60000,
+ "retryBackoffMs": [
+ 30,
+ 60
+ ],
+ "judgeTimeoutMs": 15000,
+ "deliveryTimeoutMs": 10000,
+ "recentCount": 8,
+ "seenCount": 500,
+ "maxOutbox": 1000,
+ "maxDeadLetters": 1000,
+ "deadLetterBackoffMaxMs": 60000
+ },
+ "reducer": 3
+ },
+ "tail": []
+ },
+ "expected": {
+ "version": 5,
+ "scope": "scope",
+ "cursors": {},
+ "seen": [
+ "a"
+ ],
+ "buffer": {
+ "entries": [],
+ "dropped": 0,
+ "gap": false,
+ "forcedAt": null
+ },
+ "batch": {
+ "window": {
+ "id": "cf8923dfae84f930",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "observedAt": 0,
+ "name": "reading",
+ "text": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
+ "data": {},
+ "kind": "continuous",
+ "seenAt": 0
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 1,
+ "dropped": 0,
+ "gap": false,
+ "settledAt": 10
+ },
+ "phase": {
+ "phase": "waiting",
+ "attempt": 2,
+ "until": 60
+ }
+ },
+ "outbox": {
+ "decisions": [],
+ "deadLetters": []
+ },
+ "recent": [],
+ "dueAt": 60
+ }
+ },
+ {
+ "name": "retrying-tail",
+ "through": 10,
+ "writes": [
+ [
+ {
+ "scope": "scope",
+ "expectedVersion": 0,
+ "inputs": [
+ {
+ "input": {
+ "kind": "events",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "observedAt": 0,
+ "name": "reading",
+ "text": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
+ "data": {},
+ "kind": "continuous"
+ }
+ ]
+ },
+ "now": 0
+ }
+ ],
+ "snapshot": {
+ "version": 1,
+ "record": {
+ "version": 1,
+ "scope": "scope",
+ "cursors": {},
+ "seen": [
+ "a"
+ ],
+ "buffer": {
+ "entries": [
+ {
+ "id": "a",
+ "at": 0,
+ "observedAt": 0,
+ "name": "reading",
+ "text": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
+ "data": {},
+ "kind": "continuous",
+ "seenAt": 0
+ }
+ ],
+ "dropped": 0,
+ "gap": false,
+ "forcedAt": null
+ },
+ "batch": null,
+ "outbox": {
+ "decisions": [],
+ "deadLetters": []
+ },
+ "recent": [],
+ "dueAt": 10
+ },
+ "policy": {
+ "closingGraceMs": 500,
+ "streamGapMs": 10,
+ "passiveQuietMs": 4000,
+ "waitHorizonMs": 20,
+ "maxWaits": 2,
+ "maxEvents": 250,
+ "maxWindowMs": 60000,
+ "retryBackoffMs": [
+ 30,
+ 60
+ ],
+ "judgeTimeoutMs": 15000,
+ "deliveryTimeoutMs": 10000,
+ "recentCount": 8,
+ "seenCount": 500,
+ "maxOutbox": 1000,
+ "maxDeadLetters": 1000,
+ "deadLetterBackoffMaxMs": 60000
+ },
+ "reducer": 3
+ },
+ "appends": [],
+ "due": 1000
+ }
+ ],
+ [
+ {
+ "scope": "scope",
+ "expectedVersion": 1,
+ "inputs": [
+ {
+ "input": {
+ "kind": "tick"
+ },
+ "now": 10
+ }
+ ],
+ "snapshot": null,
+ "appends": [],
+ "due": 31000
+ }
+ ],
+ [
+ {
+ "scope": "scope",
+ "expectedVersion": 2,
+ "inputs": [
+ {
+ "input": {
+ "kind": "judgeFailed",
+ "batchId": "cf8923dfae84f930",
+ "attempt": 1,
+ "message": "controlled outage",
+ "permanent": false
+ },
+ "now": 10
+ }
+ ],
+ "snapshot": null,
+ "appends": [],
+ "due": 1000
+ }
+ ]
+ ],
+ "stored": {
+ "version": 3,
+ "snapshot": {
+ "version": 1,
+ "record": {
+ "version": 1,
+ "scope": "scope",
+ "cursors": {},
+ "seen": [
+ "a"
+ ],
+ "buffer": {
+ "entries": [
+ {
+ "id": "a",
+ "at": 0,
+ "observedAt": 0,
+ "name": "reading",
+ "text": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
+ "data": {},
+ "kind": "continuous",
+ "seenAt": 0
+ }
+ ],
+ "dropped": 0,
+ "gap": false,
+ "forcedAt": null
+ },
+ "batch": null,
+ "outbox": {
+ "decisions": [],
+ "deadLetters": []
+ },
+ "recent": [],
+ "dueAt": 10
+ },
+ "policy": {
+ "closingGraceMs": 500,
+ "streamGapMs": 10,
+ "passiveQuietMs": 4000,
+ "waitHorizonMs": 20,
+ "maxWaits": 2,
+ "maxEvents": 250,
+ "maxWindowMs": 60000,
+ "retryBackoffMs": [
+ 30,
+ 60
+ ],
+ "judgeTimeoutMs": 15000,
+ "deliveryTimeoutMs": 10000,
+ "recentCount": 8,
+ "seenCount": 500,
+ "maxOutbox": 1000,
+ "maxDeadLetters": 1000,
+ "deadLetterBackoffMaxMs": 60000
+ },
+ "reducer": 3
+ },
+ "tail": [
+ {
+ "input": {
+ "kind": "tick"
+ },
+ "now": 10
+ },
+ {
+ "input": {
+ "kind": "judgeFailed",
+ "batchId": "cf8923dfae84f930",
+ "attempt": 1,
+ "message": "controlled outage",
+ "permanent": false
+ },
+ "now": 10
+ }
+ ]
+ },
+ "expected": {
+ "version": 3,
+ "scope": "scope",
+ "cursors": {},
+ "seen": [
+ "a"
+ ],
+ "buffer": {
+ "entries": [],
+ "dropped": 0,
+ "gap": false,
+ "forcedAt": null
+ },
+ "batch": {
+ "window": {
+ "id": "cf8923dfae84f930",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "observedAt": 0,
+ "name": "reading",
+ "text": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
+ "data": {},
+ "kind": "continuous",
+ "seenAt": 0
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 0,
+ "dropped": 0,
+ "gap": false,
+ "settledAt": 10
+ },
+ "phase": {
+ "phase": "retrying",
+ "attempt": 1,
+ "failures": 1,
+ "at": 40,
+ "offerWait": true
+ }
+ },
+ "outbox": {
+ "decisions": [],
+ "deadLetters": []
+ },
+ "recent": [],
+ "dueAt": 40
+ }
+ },
+ {
+ "name": "complete",
+ "through": 10,
+ "writes": [
+ [
+ {
+ "scope": "scope",
+ "expectedVersion": 0,
+ "inputs": [
+ {
+ "input": {
+ "kind": "events",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "observedAt": 0,
+ "name": "reading",
+ "text": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
+ "data": {},
+ "kind": "continuous"
+ }
+ ]
+ },
+ "now": 0
+ }
+ ],
+ "snapshot": {
+ "version": 1,
+ "record": {
+ "version": 1,
+ "scope": "scope",
+ "cursors": {},
+ "seen": [
+ "a"
+ ],
+ "buffer": {
+ "entries": [
+ {
+ "id": "a",
+ "at": 0,
+ "observedAt": 0,
+ "name": "reading",
+ "text": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
+ "data": {},
+ "kind": "continuous",
+ "seenAt": 0
+ }
+ ],
+ "dropped": 0,
+ "gap": false,
+ "forcedAt": null
+ },
+ "batch": null,
+ "outbox": {
+ "decisions": [],
+ "deadLetters": []
+ },
+ "recent": [],
+ "dueAt": 10
+ },
+ "policy": {
+ "closingGraceMs": 500,
+ "streamGapMs": 10,
+ "passiveQuietMs": 4000,
+ "waitHorizonMs": 20,
+ "maxWaits": 2,
+ "maxEvents": 250,
+ "maxWindowMs": 60000,
+ "retryBackoffMs": [
+ 30,
+ 60
+ ],
+ "judgeTimeoutMs": 15000,
+ "deliveryTimeoutMs": 10000,
+ "recentCount": 8,
+ "seenCount": 500,
+ "maxOutbox": 1000,
+ "maxDeadLetters": 1000,
+ "deadLetterBackoffMaxMs": 60000
+ },
+ "reducer": 3
+ },
+ "appends": [],
+ "due": 1000
+ }
+ ],
+ [
+ {
+ "scope": "scope",
+ "expectedVersion": 1,
+ "inputs": [
+ {
+ "input": {
+ "kind": "tick"
+ },
+ "now": 10
+ }
+ ],
+ "snapshot": {
+ "version": 2,
+ "record": {
+ "version": 2,
+ "scope": "scope",
+ "cursors": {},
+ "seen": [
+ "a"
+ ],
+ "buffer": {
+ "entries": [],
+ "dropped": 0,
+ "gap": false,
+ "forcedAt": null
+ },
+ "batch": {
+ "window": {
+ "id": "cf8923dfae84f930",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "observedAt": 0,
+ "name": "reading",
+ "text": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
+ "data": {},
+ "kind": "continuous",
+ "seenAt": 0
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 0,
+ "dropped": 0,
+ "gap": false,
+ "settledAt": 10
+ },
+ "phase": {
+ "phase": "judging",
+ "attempt": 1,
+ "failures": 0,
+ "leaseUntil": 30010,
+ "offerWait": true
+ }
+ },
+ "outbox": {
+ "decisions": [],
+ "deadLetters": []
+ },
+ "recent": [],
+ "dueAt": 30010
+ },
+ "policy": {
+ "closingGraceMs": 500,
+ "streamGapMs": 10,
+ "passiveQuietMs": 4000,
+ "waitHorizonMs": 20,
+ "maxWaits": 2,
+ "maxEvents": 250,
+ "maxWindowMs": 60000,
+ "retryBackoffMs": [
+ 30,
+ 60
+ ],
+ "judgeTimeoutMs": 15000,
+ "deliveryTimeoutMs": 10000,
+ "recentCount": 8,
+ "seenCount": 500,
+ "maxOutbox": 1000,
+ "maxDeadLetters": 1000,
+ "deadLetterBackoffMaxMs": 60000
+ },
+ "reducer": 3
+ },
+ "appends": [],
+ "due": 31000
+ }
+ ],
+ [
+ {
+ "scope": "scope",
+ "expectedVersion": 2,
+ "inputs": [
+ {
+ "input": {
+ "kind": "judged",
+ "batchId": "cf8923dfae84f930",
+ "attempt": 1,
+ "judgment": {
+ "route": "queue"
+ }
+ },
+ "now": 10
+ }
+ ],
+ "snapshot": {
+ "version": 3,
+ "record": {
+ "version": 3,
+ "scope": "scope",
+ "cursors": {},
+ "seen": [
+ "a"
+ ],
+ "buffer": {
+ "entries": [],
+ "dropped": 0,
+ "gap": false,
+ "forcedAt": null
+ },
+ "batch": null,
+ "outbox": {
+ "decisions": [],
+ "deadLetters": []
+ },
+ "recent": [
+ {
+ "id": "cf8923dfae84f930",
+ "route": "queue",
+ "at": 10
+ }
+ ],
+ "dueAt": null
+ },
+ "policy": {
+ "closingGraceMs": 500,
+ "streamGapMs": 10,
+ "passiveQuietMs": 4000,
+ "waitHorizonMs": 20,
+ "maxWaits": 2,
+ "maxEvents": 250,
+ "maxWindowMs": 60000,
+ "retryBackoffMs": [
+ 30,
+ 60
+ ],
+ "judgeTimeoutMs": 15000,
+ "deliveryTimeoutMs": 10000,
+ "recentCount": 8,
+ "seenCount": 500,
+ "maxOutbox": 1000,
+ "maxDeadLetters": 1000,
+ "deadLetterBackoffMaxMs": 60000
+ },
+ "reducer": 3
+ },
+ "appends": [
+ {
+ "kind": "decision",
+ "id": "cf8923dfae84f930",
+ "scope": "scope",
+ "at": 10,
+ "route": "queue",
+ "body": {
+ "id": "cf8923dfae84f930",
+ "scope": "scope",
+ "route": "queue",
+ "probabilities": {
+ "interrupt": 0,
+ "queue": 1,
+ "note": 0,
+ "ask": 0,
+ "skip": 0,
+ "wait": 0
+ },
+ "predicates": {},
+ "confidence": null,
+ "window": {
+ "id": "cf8923dfae84f930",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "observedAt": 0,
+ "name": "reading",
+ "text": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
+ "data": {},
+ "kind": "continuous",
+ "seenAt": 0
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 0,
+ "dropped": 0,
+ "gap": false,
+ "settledAt": 10
+ },
+ "at": 10
+ }
+ }
+ ],
+ "due": null
+ }
+ ]
+ ],
+ "stored": {
+ "version": 3,
+ "snapshot": {
+ "version": 3,
+ "record": {
+ "version": 3,
+ "scope": "scope",
+ "cursors": {},
+ "seen": [
+ "a"
+ ],
+ "buffer": {
+ "entries": [],
+ "dropped": 0,
+ "gap": false,
+ "forcedAt": null
+ },
+ "batch": null,
+ "outbox": {
+ "decisions": [],
+ "deadLetters": []
+ },
+ "recent": [
+ {
+ "id": "cf8923dfae84f930",
+ "route": "queue",
+ "at": 10
+ }
+ ],
+ "dueAt": null
+ },
+ "policy": {
+ "closingGraceMs": 500,
+ "streamGapMs": 10,
+ "passiveQuietMs": 4000,
+ "waitHorizonMs": 20,
+ "maxWaits": 2,
+ "maxEvents": 250,
+ "maxWindowMs": 60000,
+ "retryBackoffMs": [
+ 30,
+ 60
+ ],
+ "judgeTimeoutMs": 15000,
+ "deliveryTimeoutMs": 10000,
+ "recentCount": 8,
+ "seenCount": 500,
+ "maxOutbox": 1000,
+ "maxDeadLetters": 1000,
+ "deadLetterBackoffMaxMs": 60000
+ },
+ "reducer": 3
+ },
+ "tail": []
+ },
+ "expected": {
+ "version": 3,
+ "scope": "scope",
+ "cursors": {},
+ "seen": [
+ "a"
+ ],
+ "buffer": {
+ "entries": [],
+ "dropped": 0,
+ "gap": false,
+ "forcedAt": null
+ },
+ "batch": null,
+ "outbox": {
+ "decisions": [],
+ "deadLetters": []
+ },
+ "recent": [
+ {
+ "id": "cf8923dfae84f930",
+ "route": "queue",
+ "at": 10
+ }
+ ],
+ "dueAt": null
+ }
+ }
+ ]
+}
diff --git a/conformance/fixtures/scenarios.json b/conformance/fixtures/scenarios.json
index 7bb2588..55380b6 100644
--- a/conformance/fixtures/scenarios.json
+++ b/conformance/fixtures/scenarios.json
@@ -1,5 +1,5590 @@
{
"scenarios": [
+ {
+ "scenario": {
+ "name": "accumulating retry attributes empty gap metadata to held input",
+ "start": 0,
+ "intakes": [
+ "s"
+ ],
+ "kinds": {
+ "close": "closing",
+ "say": "flush",
+ "drag": "continuous",
+ "look": "passive",
+ "out": "consequence",
+ "said": "context"
+ },
+ "settle": {
+ "continuation": "accumulate",
+ "maxWindowMs": 100,
+ "retryBackoffMs": [
+ 30
+ ]
+ },
+ "judge": {
+ "*": {
+ "answers": [
+ {
+ "fail": "outage"
+ },
+ {
+ "route": "queue"
+ },
+ {
+ "route": "queue"
+ }
+ ]
+ }
+ },
+ "steps": [
+ {
+ "submit": "s",
+ "events": [
+ {
+ "id": "a",
+ "name": "drag",
+ "text": "drag a",
+ "quietForMs": 10
+ }
+ ]
+ },
+ {
+ "advance": 15
+ },
+ {
+ "submit": "s",
+ "events": [],
+ "source": "feed",
+ "cursor": "2",
+ "truncated": true
+ },
+ {
+ "advance": 25
+ },
+ {
+ "inspect": "s"
+ },
+ {
+ "submit": "s",
+ "events": [
+ {
+ "id": "next",
+ "name": "drag",
+ "text": "drag next",
+ "quietForMs": 10
+ }
+ ]
+ },
+ {
+ "advance": 10
+ }
+ ]
+ },
+ "expected": {
+ "judgeCalls": {
+ "s": [
+ {
+ "scope": "s",
+ "window": {
+ "id": "3ecbd4f2ef91c78f",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag a",
+ "quietForMs": 10,
+ "kind": "continuous",
+ "seenAt": 0
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 0,
+ "dropped": 0,
+ "gap": false,
+ "settledAt": 10
+ },
+ "routes": [
+ {
+ "route": "interrupt"
+ },
+ {
+ "route": "queue"
+ },
+ {
+ "route": "note"
+ },
+ {
+ "route": "ask"
+ },
+ {
+ "route": "skip"
+ },
+ {
+ "route": "wait"
+ }
+ ],
+ "predicates": [],
+ "facts": {},
+ "recent": [],
+ "now": 10
+ },
+ {
+ "scope": "s",
+ "window": {
+ "id": "3ecbd4f2ef91c78f",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag a",
+ "quietForMs": 10,
+ "kind": "continuous",
+ "seenAt": 0
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 0,
+ "dropped": 0,
+ "gap": true,
+ "settledAt": 10
+ },
+ "routes": [
+ {
+ "route": "interrupt"
+ },
+ {
+ "route": "queue"
+ },
+ {
+ "route": "note"
+ },
+ {
+ "route": "ask"
+ },
+ {
+ "route": "skip"
+ },
+ {
+ "route": "wait"
+ }
+ ],
+ "predicates": [],
+ "facts": {},
+ "recent": [],
+ "now": 40
+ },
+ {
+ "scope": "s",
+ "window": {
+ "id": "5fc4d8db379e8b70",
+ "events": [
+ {
+ "id": "next",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag next",
+ "quietForMs": 10,
+ "kind": "continuous",
+ "seenAt": 40
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 0,
+ "dropped": 0,
+ "gap": false,
+ "settledAt": 50
+ },
+ "routes": [
+ {
+ "route": "interrupt"
+ },
+ {
+ "route": "queue"
+ },
+ {
+ "route": "note"
+ },
+ {
+ "route": "ask"
+ },
+ {
+ "route": "skip"
+ },
+ {
+ "route": "wait"
+ }
+ ],
+ "predicates": [],
+ "facts": {},
+ "recent": [
+ {
+ "id": "3ecbd4f2ef91c78f",
+ "route": "queue",
+ "at": 40
+ }
+ ],
+ "now": 50
+ }
+ ]
+ },
+ "deliveries": {
+ "s": [
+ {
+ "decision": {
+ "id": "3ecbd4f2ef91c78f",
+ "scope": "s",
+ "route": "queue",
+ "probabilities": {
+ "interrupt": 0,
+ "queue": 1,
+ "note": 0,
+ "ask": 0,
+ "skip": 0,
+ "wait": 0
+ },
+ "predicates": {},
+ "confidence": null,
+ "window": {
+ "id": "3ecbd4f2ef91c78f",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag a",
+ "quietForMs": 10,
+ "kind": "continuous",
+ "seenAt": 0
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 0,
+ "dropped": 0,
+ "gap": true,
+ "settledAt": 10
+ },
+ "at": 40
+ },
+ "outcome": "ok"
+ },
+ {
+ "decision": {
+ "id": "5fc4d8db379e8b70",
+ "scope": "s",
+ "route": "queue",
+ "probabilities": {
+ "interrupt": 0,
+ "queue": 1,
+ "note": 0,
+ "ask": 0,
+ "skip": 0,
+ "wait": 0
+ },
+ "predicates": {},
+ "confidence": null,
+ "window": {
+ "id": "5fc4d8db379e8b70",
+ "events": [
+ {
+ "id": "next",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag next",
+ "quietForMs": 10,
+ "kind": "continuous",
+ "seenAt": 40
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 0,
+ "dropped": 0,
+ "gap": false,
+ "settledAt": 50
+ },
+ "at": 50
+ },
+ "outcome": "ok"
+ }
+ ]
+ },
+ "deadLetterCalls": {},
+ "traces": {
+ "s": [
+ {
+ "kind": "ingested",
+ "scope": "s",
+ "count": 1,
+ "duplicates": 0
+ },
+ {
+ "kind": "settled",
+ "scope": "s",
+ "batchId": "3ecbd4f2ef91c78f",
+ "reason": "stream_quiet",
+ "count": 1,
+ "merged": false
+ },
+ {
+ "kind": "judging",
+ "scope": "s",
+ "batchId": "3ecbd4f2ef91c78f",
+ "attempt": 1,
+ "offerWait": true
+ },
+ {
+ "kind": "retrying",
+ "scope": "s",
+ "stage": "judge",
+ "id": "3ecbd4f2ef91c78f",
+ "attempt": 1,
+ "at": 40,
+ "message": "outage"
+ },
+ {
+ "kind": "gap",
+ "scope": "s",
+ "source": "feed",
+ "cursor": "2"
+ },
+ {
+ "kind": "ingested",
+ "scope": "s",
+ "count": 0,
+ "duplicates": 0
+ },
+ {
+ "kind": "judging",
+ "scope": "s",
+ "batchId": "3ecbd4f2ef91c78f",
+ "attempt": 2,
+ "offerWait": true
+ },
+ {
+ "kind": "judged",
+ "scope": "s",
+ "batchId": "3ecbd4f2ef91c78f",
+ "route": "queue"
+ },
+ {
+ "kind": "delivering",
+ "scope": "s",
+ "deliveryId": "3ecbd4f2ef91c78f",
+ "attempt": 1
+ },
+ {
+ "kind": "delivered",
+ "scope": "s",
+ "deliveryId": "3ecbd4f2ef91c78f"
+ },
+ {
+ "kind": "ingested",
+ "scope": "s",
+ "count": 1,
+ "duplicates": 0
+ },
+ {
+ "kind": "settled",
+ "scope": "s",
+ "batchId": "5fc4d8db379e8b70",
+ "reason": "stream_quiet",
+ "count": 1,
+ "merged": false
+ },
+ {
+ "kind": "judging",
+ "scope": "s",
+ "batchId": "5fc4d8db379e8b70",
+ "attempt": 1,
+ "offerWait": true
+ },
+ {
+ "kind": "judged",
+ "scope": "s",
+ "batchId": "5fc4d8db379e8b70",
+ "route": "queue"
+ },
+ {
+ "kind": "delivering",
+ "scope": "s",
+ "deliveryId": "5fc4d8db379e8b70",
+ "attempt": 1
+ },
+ {
+ "kind": "delivered",
+ "scope": "s",
+ "deliveryId": "5fc4d8db379e8b70"
+ }
+ ]
+ },
+ "results": [
+ {
+ "step": 0,
+ "error": null
+ },
+ {
+ "step": 2,
+ "error": null
+ },
+ {
+ "step": 5,
+ "error": null
+ }
+ ],
+ "inspections": [
+ {
+ "step": 4,
+ "scope": "s",
+ "record": {
+ "version": 7,
+ "scope": "s",
+ "cursors": {
+ "feed": "2"
+ },
+ "seen": [
+ "a"
+ ],
+ "buffer": {
+ "entries": [],
+ "dropped": 0,
+ "gap": false,
+ "forcedAt": null
+ },
+ "batch": null,
+ "outbox": {
+ "decisions": [],
+ "deadLetters": []
+ },
+ "recent": [
+ {
+ "id": "3ecbd4f2ef91c78f",
+ "route": "queue",
+ "at": 40
+ }
+ ],
+ "dueAt": null
+ }
+ }
+ ],
+ "records": {
+ "s": {
+ "version": 11,
+ "scope": "s",
+ "cursors": {
+ "feed": "2"
+ },
+ "seen": [
+ "a",
+ "next"
+ ],
+ "buffer": {
+ "entries": [],
+ "dropped": 0,
+ "gap": false,
+ "forcedAt": null
+ },
+ "batch": null,
+ "outbox": {
+ "decisions": [],
+ "deadLetters": []
+ },
+ "recent": [
+ {
+ "id": "3ecbd4f2ef91c78f",
+ "route": "queue",
+ "at": 40
+ },
+ {
+ "id": "5fc4d8db379e8b70",
+ "route": "queue",
+ "at": 50
+ }
+ ],
+ "dueAt": null
+ }
+ },
+ "log": [
+ {
+ "kind": "decision",
+ "id": "3ecbd4f2ef91c78f",
+ "scope": "s",
+ "at": 40,
+ "route": "queue",
+ "body": {
+ "id": "3ecbd4f2ef91c78f",
+ "scope": "s",
+ "route": "queue",
+ "probabilities": {
+ "interrupt": 0,
+ "queue": 1,
+ "note": 0,
+ "ask": 0,
+ "skip": 0,
+ "wait": 0
+ },
+ "predicates": {},
+ "confidence": null,
+ "window": {
+ "id": "3ecbd4f2ef91c78f",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag a",
+ "quietForMs": 10,
+ "kind": "continuous",
+ "seenAt": 0
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 0,
+ "dropped": 0,
+ "gap": true,
+ "settledAt": 10
+ },
+ "at": 40
+ },
+ "position": "1"
+ },
+ {
+ "kind": "decision",
+ "id": "5fc4d8db379e8b70",
+ "scope": "s",
+ "at": 50,
+ "route": "queue",
+ "body": {
+ "id": "5fc4d8db379e8b70",
+ "scope": "s",
+ "route": "queue",
+ "probabilities": {
+ "interrupt": 0,
+ "queue": 1,
+ "note": 0,
+ "ask": 0,
+ "skip": 0,
+ "wait": 0
+ },
+ "predicates": {},
+ "confidence": null,
+ "window": {
+ "id": "5fc4d8db379e8b70",
+ "events": [
+ {
+ "id": "next",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag next",
+ "quietForMs": 10,
+ "kind": "continuous",
+ "seenAt": 40
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 0,
+ "dropped": 0,
+ "gap": false,
+ "settledAt": 50
+ },
+ "at": 50
+ },
+ "position": "2"
+ }
+ ]
+ }
+ },
+ {
+ "scenario": {
+ "name": "accumulating retry attributes empty dropped metadata to held input",
+ "start": 0,
+ "intakes": [
+ "s"
+ ],
+ "kinds": {
+ "close": "closing",
+ "say": "flush",
+ "drag": "continuous",
+ "look": "passive",
+ "out": "consequence",
+ "said": "context"
+ },
+ "settle": {
+ "continuation": "accumulate",
+ "maxWindowMs": 100,
+ "retryBackoffMs": [
+ 30
+ ]
+ },
+ "judge": {
+ "*": {
+ "answers": [
+ {
+ "fail": "outage"
+ },
+ {
+ "route": "queue"
+ },
+ {
+ "route": "queue"
+ }
+ ]
+ }
+ },
+ "steps": [
+ {
+ "submit": "s",
+ "events": [
+ {
+ "id": "a",
+ "name": "drag",
+ "text": "drag a",
+ "quietForMs": 10
+ }
+ ]
+ },
+ {
+ "advance": 15
+ },
+ {
+ "submit": "s",
+ "events": [
+ {
+ "id": "old",
+ "name": "out",
+ "text": "out old",
+ "observedAt": -100
+ }
+ ],
+ "source": "feed",
+ "cursor": "2"
+ },
+ {
+ "advance": 25
+ },
+ {
+ "inspect": "s"
+ },
+ {
+ "submit": "s",
+ "events": [
+ {
+ "id": "next",
+ "name": "drag",
+ "text": "drag next",
+ "quietForMs": 10
+ }
+ ]
+ },
+ {
+ "advance": 10
+ }
+ ]
+ },
+ "expected": {
+ "judgeCalls": {
+ "s": [
+ {
+ "scope": "s",
+ "window": {
+ "id": "3ecbd4f2ef91c78f",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag a",
+ "quietForMs": 10,
+ "kind": "continuous",
+ "seenAt": 0
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 0,
+ "dropped": 0,
+ "gap": false,
+ "settledAt": 10
+ },
+ "routes": [
+ {
+ "route": "interrupt"
+ },
+ {
+ "route": "queue"
+ },
+ {
+ "route": "note"
+ },
+ {
+ "route": "ask"
+ },
+ {
+ "route": "skip"
+ },
+ {
+ "route": "wait"
+ }
+ ],
+ "predicates": [],
+ "facts": {},
+ "recent": [],
+ "now": 10
+ },
+ {
+ "scope": "s",
+ "window": {
+ "id": "3ecbd4f2ef91c78f",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag a",
+ "quietForMs": 10,
+ "kind": "continuous",
+ "seenAt": 0
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 0,
+ "dropped": 1,
+ "gap": false,
+ "settledAt": 10
+ },
+ "routes": [
+ {
+ "route": "interrupt"
+ },
+ {
+ "route": "queue"
+ },
+ {
+ "route": "note"
+ },
+ {
+ "route": "ask"
+ },
+ {
+ "route": "skip"
+ },
+ {
+ "route": "wait"
+ }
+ ],
+ "predicates": [],
+ "facts": {},
+ "recent": [],
+ "now": 40
+ },
+ {
+ "scope": "s",
+ "window": {
+ "id": "5fc4d8db379e8b70",
+ "events": [
+ {
+ "id": "next",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag next",
+ "quietForMs": 10,
+ "kind": "continuous",
+ "seenAt": 40
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 0,
+ "dropped": 0,
+ "gap": false,
+ "settledAt": 50
+ },
+ "routes": [
+ {
+ "route": "interrupt"
+ },
+ {
+ "route": "queue"
+ },
+ {
+ "route": "note"
+ },
+ {
+ "route": "ask"
+ },
+ {
+ "route": "skip"
+ },
+ {
+ "route": "wait"
+ }
+ ],
+ "predicates": [],
+ "facts": {},
+ "recent": [
+ {
+ "id": "3ecbd4f2ef91c78f",
+ "route": "queue",
+ "at": 40
+ }
+ ],
+ "now": 50
+ }
+ ]
+ },
+ "deliveries": {
+ "s": [
+ {
+ "decision": {
+ "id": "3ecbd4f2ef91c78f",
+ "scope": "s",
+ "route": "queue",
+ "probabilities": {
+ "interrupt": 0,
+ "queue": 1,
+ "note": 0,
+ "ask": 0,
+ "skip": 0,
+ "wait": 0
+ },
+ "predicates": {},
+ "confidence": null,
+ "window": {
+ "id": "3ecbd4f2ef91c78f",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag a",
+ "quietForMs": 10,
+ "kind": "continuous",
+ "seenAt": 0
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 0,
+ "dropped": 1,
+ "gap": false,
+ "settledAt": 10
+ },
+ "at": 40
+ },
+ "outcome": "ok"
+ },
+ {
+ "decision": {
+ "id": "5fc4d8db379e8b70",
+ "scope": "s",
+ "route": "queue",
+ "probabilities": {
+ "interrupt": 0,
+ "queue": 1,
+ "note": 0,
+ "ask": 0,
+ "skip": 0,
+ "wait": 0
+ },
+ "predicates": {},
+ "confidence": null,
+ "window": {
+ "id": "5fc4d8db379e8b70",
+ "events": [
+ {
+ "id": "next",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag next",
+ "quietForMs": 10,
+ "kind": "continuous",
+ "seenAt": 40
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 0,
+ "dropped": 0,
+ "gap": false,
+ "settledAt": 50
+ },
+ "at": 50
+ },
+ "outcome": "ok"
+ }
+ ]
+ },
+ "deadLetterCalls": {},
+ "traces": {
+ "s": [
+ {
+ "kind": "ingested",
+ "scope": "s",
+ "count": 1,
+ "duplicates": 0
+ },
+ {
+ "kind": "settled",
+ "scope": "s",
+ "batchId": "3ecbd4f2ef91c78f",
+ "reason": "stream_quiet",
+ "count": 1,
+ "merged": false
+ },
+ {
+ "kind": "judging",
+ "scope": "s",
+ "batchId": "3ecbd4f2ef91c78f",
+ "attempt": 1,
+ "offerWait": true
+ },
+ {
+ "kind": "retrying",
+ "scope": "s",
+ "stage": "judge",
+ "id": "3ecbd4f2ef91c78f",
+ "attempt": 1,
+ "at": 40,
+ "message": "outage"
+ },
+ {
+ "kind": "dropped",
+ "scope": "s",
+ "entries": [
+ {
+ "id": "old",
+ "at": 0,
+ "name": "out",
+ "data": {},
+ "text": "out old",
+ "observedAt": -100,
+ "kind": "consequence",
+ "seenAt": 15
+ }
+ ],
+ "why": "age"
+ },
+ {
+ "kind": "ingested",
+ "scope": "s",
+ "count": 1,
+ "duplicates": 0
+ },
+ {
+ "kind": "judging",
+ "scope": "s",
+ "batchId": "3ecbd4f2ef91c78f",
+ "attempt": 2,
+ "offerWait": true
+ },
+ {
+ "kind": "judged",
+ "scope": "s",
+ "batchId": "3ecbd4f2ef91c78f",
+ "route": "queue"
+ },
+ {
+ "kind": "delivering",
+ "scope": "s",
+ "deliveryId": "3ecbd4f2ef91c78f",
+ "attempt": 1
+ },
+ {
+ "kind": "delivered",
+ "scope": "s",
+ "deliveryId": "3ecbd4f2ef91c78f"
+ },
+ {
+ "kind": "ingested",
+ "scope": "s",
+ "count": 1,
+ "duplicates": 0
+ },
+ {
+ "kind": "settled",
+ "scope": "s",
+ "batchId": "5fc4d8db379e8b70",
+ "reason": "stream_quiet",
+ "count": 1,
+ "merged": false
+ },
+ {
+ "kind": "judging",
+ "scope": "s",
+ "batchId": "5fc4d8db379e8b70",
+ "attempt": 1,
+ "offerWait": true
+ },
+ {
+ "kind": "judged",
+ "scope": "s",
+ "batchId": "5fc4d8db379e8b70",
+ "route": "queue"
+ },
+ {
+ "kind": "delivering",
+ "scope": "s",
+ "deliveryId": "5fc4d8db379e8b70",
+ "attempt": 1
+ },
+ {
+ "kind": "delivered",
+ "scope": "s",
+ "deliveryId": "5fc4d8db379e8b70"
+ }
+ ]
+ },
+ "results": [
+ {
+ "step": 0,
+ "error": null
+ },
+ {
+ "step": 2,
+ "error": null
+ },
+ {
+ "step": 5,
+ "error": null
+ }
+ ],
+ "inspections": [
+ {
+ "step": 4,
+ "scope": "s",
+ "record": {
+ "version": 7,
+ "scope": "s",
+ "cursors": {
+ "feed": "2"
+ },
+ "seen": [
+ "a",
+ "old"
+ ],
+ "buffer": {
+ "entries": [],
+ "dropped": 0,
+ "gap": false,
+ "forcedAt": null
+ },
+ "batch": null,
+ "outbox": {
+ "decisions": [],
+ "deadLetters": []
+ },
+ "recent": [
+ {
+ "id": "3ecbd4f2ef91c78f",
+ "route": "queue",
+ "at": 40
+ }
+ ],
+ "dueAt": null
+ }
+ }
+ ],
+ "records": {
+ "s": {
+ "version": 11,
+ "scope": "s",
+ "cursors": {
+ "feed": "2"
+ },
+ "seen": [
+ "a",
+ "old",
+ "next"
+ ],
+ "buffer": {
+ "entries": [],
+ "dropped": 0,
+ "gap": false,
+ "forcedAt": null
+ },
+ "batch": null,
+ "outbox": {
+ "decisions": [],
+ "deadLetters": []
+ },
+ "recent": [
+ {
+ "id": "3ecbd4f2ef91c78f",
+ "route": "queue",
+ "at": 40
+ },
+ {
+ "id": "5fc4d8db379e8b70",
+ "route": "queue",
+ "at": 50
+ }
+ ],
+ "dueAt": null
+ }
+ },
+ "log": [
+ {
+ "kind": "decision",
+ "id": "3ecbd4f2ef91c78f",
+ "scope": "s",
+ "at": 40,
+ "route": "queue",
+ "body": {
+ "id": "3ecbd4f2ef91c78f",
+ "scope": "s",
+ "route": "queue",
+ "probabilities": {
+ "interrupt": 0,
+ "queue": 1,
+ "note": 0,
+ "ask": 0,
+ "skip": 0,
+ "wait": 0
+ },
+ "predicates": {},
+ "confidence": null,
+ "window": {
+ "id": "3ecbd4f2ef91c78f",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag a",
+ "quietForMs": 10,
+ "kind": "continuous",
+ "seenAt": 0
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 0,
+ "dropped": 1,
+ "gap": false,
+ "settledAt": 10
+ },
+ "at": 40
+ },
+ "position": "1"
+ },
+ {
+ "kind": "decision",
+ "id": "5fc4d8db379e8b70",
+ "scope": "s",
+ "at": 50,
+ "route": "queue",
+ "body": {
+ "id": "5fc4d8db379e8b70",
+ "scope": "s",
+ "route": "queue",
+ "probabilities": {
+ "interrupt": 0,
+ "queue": 1,
+ "note": 0,
+ "ask": 0,
+ "skip": 0,
+ "wait": 0
+ },
+ "predicates": {},
+ "confidence": null,
+ "window": {
+ "id": "5fc4d8db379e8b70",
+ "events": [
+ {
+ "id": "next",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag next",
+ "quietForMs": 10,
+ "kind": "continuous",
+ "seenAt": 40
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 0,
+ "dropped": 0,
+ "gap": false,
+ "settledAt": 50
+ },
+ "at": 50
+ },
+ "position": "2"
+ }
+ ]
+ }
+ },
+ {
+ "scenario": {
+ "name": "accumulating horizon folds empty gap metadata without removing wait",
+ "start": 0,
+ "intakes": [
+ "s"
+ ],
+ "kinds": {
+ "close": "closing",
+ "say": "flush",
+ "drag": "continuous",
+ "look": "passive",
+ "out": "consequence",
+ "said": "context"
+ },
+ "settle": {
+ "continuation": "accumulate",
+ "waitHorizonMs": 20
+ },
+ "judge": {
+ "*": {
+ "answers": [
+ {
+ "route": "wait"
+ },
+ {
+ "route": "queue"
+ }
+ ]
+ }
+ },
+ "steps": [
+ {
+ "submit": "s",
+ "events": [
+ {
+ "id": "a",
+ "name": "drag",
+ "text": "drag a",
+ "quietForMs": 10
+ }
+ ]
+ },
+ {
+ "advance": 15
+ },
+ {
+ "submit": "s",
+ "events": [],
+ "truncated": true
+ },
+ {
+ "advance": 15
+ },
+ {
+ "inspect": "s"
+ }
+ ]
+ },
+ "expected": {
+ "judgeCalls": {
+ "s": [
+ {
+ "scope": "s",
+ "window": {
+ "id": "3ecbd4f2ef91c78f",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag a",
+ "quietForMs": 10,
+ "kind": "continuous",
+ "seenAt": 0
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 0,
+ "dropped": 0,
+ "gap": false,
+ "settledAt": 10
+ },
+ "routes": [
+ {
+ "route": "interrupt"
+ },
+ {
+ "route": "queue"
+ },
+ {
+ "route": "note"
+ },
+ {
+ "route": "ask"
+ },
+ {
+ "route": "skip"
+ },
+ {
+ "route": "wait"
+ }
+ ],
+ "predicates": [],
+ "facts": {},
+ "recent": [],
+ "now": 10
+ },
+ {
+ "scope": "s",
+ "window": {
+ "id": "3ecbd4f2ef91c78f",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag a",
+ "quietForMs": 10,
+ "kind": "continuous",
+ "seenAt": 0
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 1,
+ "dropped": 0,
+ "gap": true,
+ "settledAt": 10
+ },
+ "routes": [
+ {
+ "route": "interrupt"
+ },
+ {
+ "route": "queue"
+ },
+ {
+ "route": "note"
+ },
+ {
+ "route": "ask"
+ },
+ {
+ "route": "skip"
+ },
+ {
+ "route": "wait"
+ }
+ ],
+ "predicates": [],
+ "facts": {},
+ "recent": [],
+ "now": 30
+ }
+ ]
+ },
+ "deliveries": {
+ "s": [
+ {
+ "decision": {
+ "id": "3ecbd4f2ef91c78f",
+ "scope": "s",
+ "route": "queue",
+ "probabilities": {
+ "interrupt": 0,
+ "queue": 1,
+ "note": 0,
+ "ask": 0,
+ "skip": 0,
+ "wait": 0
+ },
+ "predicates": {},
+ "confidence": null,
+ "window": {
+ "id": "3ecbd4f2ef91c78f",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag a",
+ "quietForMs": 10,
+ "kind": "continuous",
+ "seenAt": 0
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 1,
+ "dropped": 0,
+ "gap": true,
+ "settledAt": 10
+ },
+ "at": 30
+ },
+ "outcome": "ok"
+ }
+ ]
+ },
+ "deadLetterCalls": {},
+ "traces": {
+ "s": [
+ {
+ "kind": "ingested",
+ "scope": "s",
+ "count": 1,
+ "duplicates": 0
+ },
+ {
+ "kind": "settled",
+ "scope": "s",
+ "batchId": "3ecbd4f2ef91c78f",
+ "reason": "stream_quiet",
+ "count": 1,
+ "merged": false
+ },
+ {
+ "kind": "judging",
+ "scope": "s",
+ "batchId": "3ecbd4f2ef91c78f",
+ "attempt": 1,
+ "offerWait": true
+ },
+ {
+ "kind": "waiting",
+ "scope": "s",
+ "batchId": "3ecbd4f2ef91c78f",
+ "waits": 1,
+ "until": 30
+ },
+ {
+ "kind": "gap",
+ "scope": "s",
+ "source": null,
+ "cursor": null
+ },
+ {
+ "kind": "ingested",
+ "scope": "s",
+ "count": 0,
+ "duplicates": 0
+ },
+ {
+ "kind": "judging",
+ "scope": "s",
+ "batchId": "3ecbd4f2ef91c78f",
+ "attempt": 2,
+ "offerWait": true
+ },
+ {
+ "kind": "judged",
+ "scope": "s",
+ "batchId": "3ecbd4f2ef91c78f",
+ "route": "queue"
+ },
+ {
+ "kind": "delivering",
+ "scope": "s",
+ "deliveryId": "3ecbd4f2ef91c78f",
+ "attempt": 1
+ },
+ {
+ "kind": "delivered",
+ "scope": "s",
+ "deliveryId": "3ecbd4f2ef91c78f"
+ }
+ ]
+ },
+ "results": [
+ {
+ "step": 0,
+ "error": null
+ },
+ {
+ "step": 2,
+ "error": null
+ }
+ ],
+ "inspections": [
+ {
+ "step": 4,
+ "scope": "s",
+ "record": {
+ "version": 7,
+ "scope": "s",
+ "cursors": {},
+ "seen": [
+ "a"
+ ],
+ "buffer": {
+ "entries": [],
+ "dropped": 0,
+ "gap": false,
+ "forcedAt": null
+ },
+ "batch": null,
+ "outbox": {
+ "decisions": [],
+ "deadLetters": []
+ },
+ "recent": [
+ {
+ "id": "3ecbd4f2ef91c78f",
+ "route": "queue",
+ "at": 30
+ }
+ ],
+ "dueAt": null
+ }
+ }
+ ],
+ "records": {
+ "s": {
+ "version": 7,
+ "scope": "s",
+ "cursors": {},
+ "seen": [
+ "a"
+ ],
+ "buffer": {
+ "entries": [],
+ "dropped": 0,
+ "gap": false,
+ "forcedAt": null
+ },
+ "batch": null,
+ "outbox": {
+ "decisions": [],
+ "deadLetters": []
+ },
+ "recent": [
+ {
+ "id": "3ecbd4f2ef91c78f",
+ "route": "queue",
+ "at": 30
+ }
+ ],
+ "dueAt": null
+ }
+ },
+ "log": [
+ {
+ "kind": "decision",
+ "id": "3ecbd4f2ef91c78f",
+ "scope": "s",
+ "at": 30,
+ "route": "queue",
+ "body": {
+ "id": "3ecbd4f2ef91c78f",
+ "scope": "s",
+ "route": "queue",
+ "probabilities": {
+ "interrupt": 0,
+ "queue": 1,
+ "note": 0,
+ "ask": 0,
+ "skip": 0,
+ "wait": 0
+ },
+ "predicates": {},
+ "confidence": null,
+ "window": {
+ "id": "3ecbd4f2ef91c78f",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag a",
+ "quietForMs": 10,
+ "kind": "continuous",
+ "seenAt": 0
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 1,
+ "dropped": 0,
+ "gap": true,
+ "settledAt": 10
+ },
+ "at": 30
+ },
+ "position": "1"
+ }
+ ]
+ }
+ },
+ {
+ "scenario": {
+ "name": "accumulating horizons include fresh entries and keep wait allowance",
+ "start": 0,
+ "intakes": [
+ "s"
+ ],
+ "kinds": {
+ "close": "closing",
+ "say": "flush",
+ "drag": "continuous",
+ "look": "passive",
+ "out": "consequence",
+ "said": "context"
+ },
+ "settle": {
+ "continuation": "accumulate",
+ "waitHorizonMs": 20,
+ "maxWaits": 2
+ },
+ "judge": {
+ "*": {
+ "answers": [
+ {
+ "route": "wait"
+ },
+ {
+ "route": "wait"
+ },
+ {
+ "route": "queue"
+ }
+ ]
+ }
+ },
+ "steps": [
+ {
+ "submit": "s",
+ "events": [
+ {
+ "id": "a",
+ "name": "drag",
+ "text": "drag a",
+ "quietForMs": 10
+ }
+ ]
+ },
+ {
+ "advance": 25
+ },
+ {
+ "submit": "s",
+ "events": [
+ {
+ "id": "b",
+ "name": "drag",
+ "text": "drag b",
+ "quietForMs": 100
+ }
+ ]
+ },
+ {
+ "advance": 25
+ }
+ ]
+ },
+ "expected": {
+ "judgeCalls": {
+ "s": [
+ {
+ "scope": "s",
+ "window": {
+ "id": "3ecbd4f2ef91c78f",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag a",
+ "quietForMs": 10,
+ "kind": "continuous",
+ "seenAt": 0
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 0,
+ "dropped": 0,
+ "gap": false,
+ "settledAt": 10
+ },
+ "routes": [
+ {
+ "route": "interrupt"
+ },
+ {
+ "route": "queue"
+ },
+ {
+ "route": "note"
+ },
+ {
+ "route": "ask"
+ },
+ {
+ "route": "skip"
+ },
+ {
+ "route": "wait"
+ }
+ ],
+ "predicates": [],
+ "facts": {},
+ "recent": [],
+ "now": 10
+ },
+ {
+ "scope": "s",
+ "window": {
+ "id": "f9df8ba2df127ca6",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag a",
+ "quietForMs": 10,
+ "kind": "continuous",
+ "seenAt": 0
+ },
+ {
+ "id": "b",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag b",
+ "quietForMs": 100,
+ "kind": "continuous",
+ "seenAt": 25
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 1,
+ "dropped": 0,
+ "gap": false,
+ "settledAt": 30
+ },
+ "routes": [
+ {
+ "route": "interrupt"
+ },
+ {
+ "route": "queue"
+ },
+ {
+ "route": "note"
+ },
+ {
+ "route": "ask"
+ },
+ {
+ "route": "skip"
+ },
+ {
+ "route": "wait"
+ }
+ ],
+ "predicates": [],
+ "facts": {},
+ "recent": [],
+ "now": 30
+ },
+ {
+ "scope": "s",
+ "window": {
+ "id": "f9df8ba2df127ca6",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag a",
+ "quietForMs": 10,
+ "kind": "continuous",
+ "seenAt": 0
+ },
+ {
+ "id": "b",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag b",
+ "quietForMs": 100,
+ "kind": "continuous",
+ "seenAt": 25
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 2,
+ "dropped": 0,
+ "gap": false,
+ "settledAt": 30
+ },
+ "routes": [
+ {
+ "route": "interrupt"
+ },
+ {
+ "route": "queue"
+ },
+ {
+ "route": "note"
+ },
+ {
+ "route": "ask"
+ },
+ {
+ "route": "skip"
+ }
+ ],
+ "predicates": [],
+ "facts": {},
+ "recent": [],
+ "now": 50
+ }
+ ]
+ },
+ "deliveries": {
+ "s": [
+ {
+ "decision": {
+ "id": "f9df8ba2df127ca6",
+ "scope": "s",
+ "route": "queue",
+ "probabilities": {
+ "interrupt": 0,
+ "queue": 1,
+ "note": 0,
+ "ask": 0,
+ "skip": 0,
+ "wait": 0
+ },
+ "predicates": {},
+ "confidence": null,
+ "window": {
+ "id": "f9df8ba2df127ca6",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag a",
+ "quietForMs": 10,
+ "kind": "continuous",
+ "seenAt": 0
+ },
+ {
+ "id": "b",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag b",
+ "quietForMs": 100,
+ "kind": "continuous",
+ "seenAt": 25
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 2,
+ "dropped": 0,
+ "gap": false,
+ "settledAt": 30
+ },
+ "at": 50
+ },
+ "outcome": "ok"
+ }
+ ]
+ },
+ "deadLetterCalls": {},
+ "traces": {
+ "s": [
+ {
+ "kind": "ingested",
+ "scope": "s",
+ "count": 1,
+ "duplicates": 0
+ },
+ {
+ "kind": "settled",
+ "scope": "s",
+ "batchId": "3ecbd4f2ef91c78f",
+ "reason": "stream_quiet",
+ "count": 1,
+ "merged": false
+ },
+ {
+ "kind": "judging",
+ "scope": "s",
+ "batchId": "3ecbd4f2ef91c78f",
+ "attempt": 1,
+ "offerWait": true
+ },
+ {
+ "kind": "waiting",
+ "scope": "s",
+ "batchId": "3ecbd4f2ef91c78f",
+ "waits": 1,
+ "until": 30
+ },
+ {
+ "kind": "ingested",
+ "scope": "s",
+ "count": 1,
+ "duplicates": 0
+ },
+ {
+ "kind": "settled",
+ "scope": "s",
+ "batchId": "f9df8ba2df127ca6",
+ "reason": "stream_quiet",
+ "count": 2,
+ "merged": true
+ },
+ {
+ "kind": "judging",
+ "scope": "s",
+ "batchId": "f9df8ba2df127ca6",
+ "attempt": 2,
+ "offerWait": true
+ },
+ {
+ "kind": "waiting",
+ "scope": "s",
+ "batchId": "f9df8ba2df127ca6",
+ "waits": 2,
+ "until": 50
+ },
+ {
+ "kind": "judging",
+ "scope": "s",
+ "batchId": "f9df8ba2df127ca6",
+ "attempt": 3,
+ "offerWait": false
+ },
+ {
+ "kind": "judged",
+ "scope": "s",
+ "batchId": "f9df8ba2df127ca6",
+ "route": "queue"
+ },
+ {
+ "kind": "delivering",
+ "scope": "s",
+ "deliveryId": "f9df8ba2df127ca6",
+ "attempt": 1
+ },
+ {
+ "kind": "delivered",
+ "scope": "s",
+ "deliveryId": "f9df8ba2df127ca6"
+ }
+ ]
+ },
+ "results": [
+ {
+ "step": 0,
+ "error": null
+ },
+ {
+ "step": 2,
+ "error": null
+ }
+ ],
+ "inspections": [],
+ "records": {
+ "s": {
+ "version": 9,
+ "scope": "s",
+ "cursors": {},
+ "seen": [
+ "a",
+ "b"
+ ],
+ "buffer": {
+ "entries": [],
+ "dropped": 0,
+ "gap": false,
+ "forcedAt": null
+ },
+ "batch": null,
+ "outbox": {
+ "decisions": [],
+ "deadLetters": []
+ },
+ "recent": [
+ {
+ "id": "f9df8ba2df127ca6",
+ "route": "queue",
+ "at": 50
+ }
+ ],
+ "dueAt": null
+ }
+ },
+ "log": [
+ {
+ "kind": "decision",
+ "id": "f9df8ba2df127ca6",
+ "scope": "s",
+ "at": 50,
+ "route": "queue",
+ "body": {
+ "id": "f9df8ba2df127ca6",
+ "scope": "s",
+ "route": "queue",
+ "probabilities": {
+ "interrupt": 0,
+ "queue": 1,
+ "note": 0,
+ "ask": 0,
+ "skip": 0,
+ "wait": 0
+ },
+ "predicates": {},
+ "confidence": null,
+ "window": {
+ "id": "f9df8ba2df127ca6",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag a",
+ "quietForMs": 10,
+ "kind": "continuous",
+ "seenAt": 0
+ },
+ {
+ "id": "b",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag b",
+ "quietForMs": 100,
+ "kind": "continuous",
+ "seenAt": 25
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 2,
+ "dropped": 0,
+ "gap": false,
+ "settledAt": 30
+ },
+ "at": 50
+ },
+ "position": "1"
+ }
+ ]
+ }
+ },
+ {
+ "scenario": {
+ "name": "accumulating retry absorbs fresh quiet duration 10 at not-before",
+ "start": 0,
+ "intakes": [
+ "s"
+ ],
+ "kinds": {
+ "close": "closing",
+ "say": "flush",
+ "drag": "continuous",
+ "look": "passive",
+ "out": "consequence",
+ "said": "context"
+ },
+ "settle": {
+ "continuation": "accumulate",
+ "retryBackoffMs": [
+ 30,
+ 60
+ ]
+ },
+ "judge": {
+ "*": {
+ "answers": [
+ {
+ "fail": "outage"
+ },
+ {
+ "route": "queue"
+ }
+ ]
+ }
+ },
+ "steps": [
+ {
+ "submit": "s",
+ "events": [
+ {
+ "id": "a",
+ "name": "drag",
+ "text": "drag a",
+ "quietForMs": 10
+ }
+ ]
+ },
+ {
+ "advance": 15
+ },
+ {
+ "submit": "s",
+ "events": [
+ {
+ "id": "b",
+ "name": "drag",
+ "text": "drag b",
+ "quietForMs": 10
+ }
+ ]
+ },
+ {
+ "advance": 24
+ },
+ {
+ "inspect": "s"
+ },
+ {
+ "advance": 1
+ }
+ ]
+ },
+ "expected": {
+ "judgeCalls": {
+ "s": [
+ {
+ "scope": "s",
+ "window": {
+ "id": "3ecbd4f2ef91c78f",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag a",
+ "quietForMs": 10,
+ "kind": "continuous",
+ "seenAt": 0
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 0,
+ "dropped": 0,
+ "gap": false,
+ "settledAt": 10
+ },
+ "routes": [
+ {
+ "route": "interrupt"
+ },
+ {
+ "route": "queue"
+ },
+ {
+ "route": "note"
+ },
+ {
+ "route": "ask"
+ },
+ {
+ "route": "skip"
+ },
+ {
+ "route": "wait"
+ }
+ ],
+ "predicates": [],
+ "facts": {},
+ "recent": [],
+ "now": 10
+ },
+ {
+ "scope": "s",
+ "window": {
+ "id": "f9df8ba2df127ca6",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag a",
+ "quietForMs": 10,
+ "kind": "continuous",
+ "seenAt": 0
+ },
+ {
+ "id": "b",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag b",
+ "quietForMs": 10,
+ "kind": "continuous",
+ "seenAt": 15
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 0,
+ "dropped": 0,
+ "gap": false,
+ "settledAt": 40
+ },
+ "routes": [
+ {
+ "route": "interrupt"
+ },
+ {
+ "route": "queue"
+ },
+ {
+ "route": "note"
+ },
+ {
+ "route": "ask"
+ },
+ {
+ "route": "skip"
+ },
+ {
+ "route": "wait"
+ }
+ ],
+ "predicates": [],
+ "facts": {},
+ "recent": [],
+ "now": 40
+ }
+ ]
+ },
+ "deliveries": {
+ "s": [
+ {
+ "decision": {
+ "id": "f9df8ba2df127ca6",
+ "scope": "s",
+ "route": "queue",
+ "probabilities": {
+ "interrupt": 0,
+ "queue": 1,
+ "note": 0,
+ "ask": 0,
+ "skip": 0,
+ "wait": 0
+ },
+ "predicates": {},
+ "confidence": null,
+ "window": {
+ "id": "f9df8ba2df127ca6",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag a",
+ "quietForMs": 10,
+ "kind": "continuous",
+ "seenAt": 0
+ },
+ {
+ "id": "b",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag b",
+ "quietForMs": 10,
+ "kind": "continuous",
+ "seenAt": 15
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 0,
+ "dropped": 0,
+ "gap": false,
+ "settledAt": 40
+ },
+ "at": 40
+ },
+ "outcome": "ok"
+ }
+ ]
+ },
+ "deadLetterCalls": {},
+ "traces": {
+ "s": [
+ {
+ "kind": "ingested",
+ "scope": "s",
+ "count": 1,
+ "duplicates": 0
+ },
+ {
+ "kind": "settled",
+ "scope": "s",
+ "batchId": "3ecbd4f2ef91c78f",
+ "reason": "stream_quiet",
+ "count": 1,
+ "merged": false
+ },
+ {
+ "kind": "judging",
+ "scope": "s",
+ "batchId": "3ecbd4f2ef91c78f",
+ "attempt": 1,
+ "offerWait": true
+ },
+ {
+ "kind": "retrying",
+ "scope": "s",
+ "stage": "judge",
+ "id": "3ecbd4f2ef91c78f",
+ "attempt": 1,
+ "at": 40,
+ "message": "outage"
+ },
+ {
+ "kind": "ingested",
+ "scope": "s",
+ "count": 1,
+ "duplicates": 0
+ },
+ {
+ "kind": "settled",
+ "scope": "s",
+ "batchId": "f9df8ba2df127ca6",
+ "reason": "stream_quiet",
+ "count": 2,
+ "merged": true
+ },
+ {
+ "kind": "judging",
+ "scope": "s",
+ "batchId": "f9df8ba2df127ca6",
+ "attempt": 2,
+ "offerWait": true
+ },
+ {
+ "kind": "judged",
+ "scope": "s",
+ "batchId": "f9df8ba2df127ca6",
+ "route": "queue"
+ },
+ {
+ "kind": "delivering",
+ "scope": "s",
+ "deliveryId": "f9df8ba2df127ca6",
+ "attempt": 1
+ },
+ {
+ "kind": "delivered",
+ "scope": "s",
+ "deliveryId": "f9df8ba2df127ca6"
+ }
+ ]
+ },
+ "results": [
+ {
+ "step": 0,
+ "error": null
+ },
+ {
+ "step": 2,
+ "error": null
+ }
+ ],
+ "inspections": [
+ {
+ "step": 4,
+ "scope": "s",
+ "record": {
+ "version": 4,
+ "scope": "s",
+ "cursors": {},
+ "seen": [
+ "a",
+ "b"
+ ],
+ "buffer": {
+ "entries": [
+ {
+ "id": "b",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag b",
+ "quietForMs": 10,
+ "kind": "continuous",
+ "seenAt": 15
+ }
+ ],
+ "dropped": 0,
+ "gap": false,
+ "forcedAt": null
+ },
+ "batch": {
+ "window": {
+ "id": "3ecbd4f2ef91c78f",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag a",
+ "quietForMs": 10,
+ "kind": "continuous",
+ "seenAt": 0
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 0,
+ "dropped": 0,
+ "gap": false,
+ "settledAt": 10
+ },
+ "phase": {
+ "phase": "retrying",
+ "attempt": 1,
+ "failures": 1,
+ "at": 40,
+ "offerWait": true
+ }
+ },
+ "outbox": {
+ "decisions": [],
+ "deadLetters": []
+ },
+ "recent": [],
+ "dueAt": 40
+ }
+ }
+ ],
+ "records": {
+ "s": {
+ "version": 7,
+ "scope": "s",
+ "cursors": {},
+ "seen": [
+ "a",
+ "b"
+ ],
+ "buffer": {
+ "entries": [],
+ "dropped": 0,
+ "gap": false,
+ "forcedAt": null
+ },
+ "batch": null,
+ "outbox": {
+ "decisions": [],
+ "deadLetters": []
+ },
+ "recent": [
+ {
+ "id": "f9df8ba2df127ca6",
+ "route": "queue",
+ "at": 40
+ }
+ ],
+ "dueAt": null
+ }
+ },
+ "log": [
+ {
+ "kind": "decision",
+ "id": "f9df8ba2df127ca6",
+ "scope": "s",
+ "at": 40,
+ "route": "queue",
+ "body": {
+ "id": "f9df8ba2df127ca6",
+ "scope": "s",
+ "route": "queue",
+ "probabilities": {
+ "interrupt": 0,
+ "queue": 1,
+ "note": 0,
+ "ask": 0,
+ "skip": 0,
+ "wait": 0
+ },
+ "predicates": {},
+ "confidence": null,
+ "window": {
+ "id": "f9df8ba2df127ca6",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag a",
+ "quietForMs": 10,
+ "kind": "continuous",
+ "seenAt": 0
+ },
+ {
+ "id": "b",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag b",
+ "quietForMs": 10,
+ "kind": "continuous",
+ "seenAt": 15
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 0,
+ "dropped": 0,
+ "gap": false,
+ "settledAt": 40
+ },
+ "at": 40
+ },
+ "position": "1"
+ }
+ ]
+ }
+ },
+ {
+ "scenario": {
+ "name": "accumulating retry absorbs fresh quiet duration 100 at not-before",
+ "start": 0,
+ "intakes": [
+ "s"
+ ],
+ "kinds": {
+ "close": "closing",
+ "say": "flush",
+ "drag": "continuous",
+ "look": "passive",
+ "out": "consequence",
+ "said": "context"
+ },
+ "settle": {
+ "continuation": "accumulate",
+ "retryBackoffMs": [
+ 30,
+ 60
+ ]
+ },
+ "judge": {
+ "*": {
+ "answers": [
+ {
+ "fail": "outage"
+ },
+ {
+ "route": "queue"
+ }
+ ]
+ }
+ },
+ "steps": [
+ {
+ "submit": "s",
+ "events": [
+ {
+ "id": "a",
+ "name": "drag",
+ "text": "drag a",
+ "quietForMs": 10
+ }
+ ]
+ },
+ {
+ "advance": 15
+ },
+ {
+ "submit": "s",
+ "events": [
+ {
+ "id": "b",
+ "name": "drag",
+ "text": "drag b",
+ "quietForMs": 100
+ }
+ ]
+ },
+ {
+ "advance": 24
+ },
+ {
+ "inspect": "s"
+ },
+ {
+ "advance": 1
+ }
+ ]
+ },
+ "expected": {
+ "judgeCalls": {
+ "s": [
+ {
+ "scope": "s",
+ "window": {
+ "id": "3ecbd4f2ef91c78f",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag a",
+ "quietForMs": 10,
+ "kind": "continuous",
+ "seenAt": 0
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 0,
+ "dropped": 0,
+ "gap": false,
+ "settledAt": 10
+ },
+ "routes": [
+ {
+ "route": "interrupt"
+ },
+ {
+ "route": "queue"
+ },
+ {
+ "route": "note"
+ },
+ {
+ "route": "ask"
+ },
+ {
+ "route": "skip"
+ },
+ {
+ "route": "wait"
+ }
+ ],
+ "predicates": [],
+ "facts": {},
+ "recent": [],
+ "now": 10
+ },
+ {
+ "scope": "s",
+ "window": {
+ "id": "f9df8ba2df127ca6",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag a",
+ "quietForMs": 10,
+ "kind": "continuous",
+ "seenAt": 0
+ },
+ {
+ "id": "b",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag b",
+ "quietForMs": 100,
+ "kind": "continuous",
+ "seenAt": 15
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 0,
+ "dropped": 0,
+ "gap": false,
+ "settledAt": 40
+ },
+ "routes": [
+ {
+ "route": "interrupt"
+ },
+ {
+ "route": "queue"
+ },
+ {
+ "route": "note"
+ },
+ {
+ "route": "ask"
+ },
+ {
+ "route": "skip"
+ },
+ {
+ "route": "wait"
+ }
+ ],
+ "predicates": [],
+ "facts": {},
+ "recent": [],
+ "now": 40
+ }
+ ]
+ },
+ "deliveries": {
+ "s": [
+ {
+ "decision": {
+ "id": "f9df8ba2df127ca6",
+ "scope": "s",
+ "route": "queue",
+ "probabilities": {
+ "interrupt": 0,
+ "queue": 1,
+ "note": 0,
+ "ask": 0,
+ "skip": 0,
+ "wait": 0
+ },
+ "predicates": {},
+ "confidence": null,
+ "window": {
+ "id": "f9df8ba2df127ca6",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag a",
+ "quietForMs": 10,
+ "kind": "continuous",
+ "seenAt": 0
+ },
+ {
+ "id": "b",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag b",
+ "quietForMs": 100,
+ "kind": "continuous",
+ "seenAt": 15
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 0,
+ "dropped": 0,
+ "gap": false,
+ "settledAt": 40
+ },
+ "at": 40
+ },
+ "outcome": "ok"
+ }
+ ]
+ },
+ "deadLetterCalls": {},
+ "traces": {
+ "s": [
+ {
+ "kind": "ingested",
+ "scope": "s",
+ "count": 1,
+ "duplicates": 0
+ },
+ {
+ "kind": "settled",
+ "scope": "s",
+ "batchId": "3ecbd4f2ef91c78f",
+ "reason": "stream_quiet",
+ "count": 1,
+ "merged": false
+ },
+ {
+ "kind": "judging",
+ "scope": "s",
+ "batchId": "3ecbd4f2ef91c78f",
+ "attempt": 1,
+ "offerWait": true
+ },
+ {
+ "kind": "retrying",
+ "scope": "s",
+ "stage": "judge",
+ "id": "3ecbd4f2ef91c78f",
+ "attempt": 1,
+ "at": 40,
+ "message": "outage"
+ },
+ {
+ "kind": "ingested",
+ "scope": "s",
+ "count": 1,
+ "duplicates": 0
+ },
+ {
+ "kind": "settled",
+ "scope": "s",
+ "batchId": "f9df8ba2df127ca6",
+ "reason": "stream_quiet",
+ "count": 2,
+ "merged": true
+ },
+ {
+ "kind": "judging",
+ "scope": "s",
+ "batchId": "f9df8ba2df127ca6",
+ "attempt": 2,
+ "offerWait": true
+ },
+ {
+ "kind": "judged",
+ "scope": "s",
+ "batchId": "f9df8ba2df127ca6",
+ "route": "queue"
+ },
+ {
+ "kind": "delivering",
+ "scope": "s",
+ "deliveryId": "f9df8ba2df127ca6",
+ "attempt": 1
+ },
+ {
+ "kind": "delivered",
+ "scope": "s",
+ "deliveryId": "f9df8ba2df127ca6"
+ }
+ ]
+ },
+ "results": [
+ {
+ "step": 0,
+ "error": null
+ },
+ {
+ "step": 2,
+ "error": null
+ }
+ ],
+ "inspections": [
+ {
+ "step": 4,
+ "scope": "s",
+ "record": {
+ "version": 4,
+ "scope": "s",
+ "cursors": {},
+ "seen": [
+ "a",
+ "b"
+ ],
+ "buffer": {
+ "entries": [
+ {
+ "id": "b",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag b",
+ "quietForMs": 100,
+ "kind": "continuous",
+ "seenAt": 15
+ }
+ ],
+ "dropped": 0,
+ "gap": false,
+ "forcedAt": null
+ },
+ "batch": {
+ "window": {
+ "id": "3ecbd4f2ef91c78f",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag a",
+ "quietForMs": 10,
+ "kind": "continuous",
+ "seenAt": 0
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 0,
+ "dropped": 0,
+ "gap": false,
+ "settledAt": 10
+ },
+ "phase": {
+ "phase": "retrying",
+ "attempt": 1,
+ "failures": 1,
+ "at": 40,
+ "offerWait": true
+ }
+ },
+ "outbox": {
+ "decisions": [],
+ "deadLetters": []
+ },
+ "recent": [],
+ "dueAt": 40
+ }
+ }
+ ],
+ "records": {
+ "s": {
+ "version": 7,
+ "scope": "s",
+ "cursors": {},
+ "seen": [
+ "a",
+ "b"
+ ],
+ "buffer": {
+ "entries": [],
+ "dropped": 0,
+ "gap": false,
+ "forcedAt": null
+ },
+ "batch": null,
+ "outbox": {
+ "decisions": [],
+ "deadLetters": []
+ },
+ "recent": [
+ {
+ "id": "f9df8ba2df127ca6",
+ "route": "queue",
+ "at": 40
+ }
+ ],
+ "dueAt": null
+ }
+ },
+ "log": [
+ {
+ "kind": "decision",
+ "id": "f9df8ba2df127ca6",
+ "scope": "s",
+ "at": 40,
+ "route": "queue",
+ "body": {
+ "id": "f9df8ba2df127ca6",
+ "scope": "s",
+ "route": "queue",
+ "probabilities": {
+ "interrupt": 0,
+ "queue": 1,
+ "note": 0,
+ "ask": 0,
+ "skip": 0,
+ "wait": 0
+ },
+ "predicates": {},
+ "confidence": null,
+ "window": {
+ "id": "f9df8ba2df127ca6",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag a",
+ "quietForMs": 10,
+ "kind": "continuous",
+ "seenAt": 0
+ },
+ {
+ "id": "b",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag b",
+ "quietForMs": 100,
+ "kind": "continuous",
+ "seenAt": 15
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 0,
+ "dropped": 0,
+ "gap": false,
+ "settledAt": 40
+ },
+ "at": 40
+ },
+ "position": "1"
+ }
+ ]
+ }
+ },
+ {
+ "scenario": {
+ "name": "accumulating wait does not refund a provider failure",
+ "start": 0,
+ "intakes": [
+ "s"
+ ],
+ "kinds": {
+ "close": "closing",
+ "say": "flush",
+ "drag": "continuous",
+ "look": "passive",
+ "out": "consequence",
+ "said": "context"
+ },
+ "settle": {
+ "continuation": "accumulate",
+ "waitHorizonMs": 20,
+ "retryBackoffMs": [
+ 30,
+ 60
+ ]
+ },
+ "judge": {
+ "*": {
+ "answers": [
+ {
+ "fail": "outage"
+ },
+ {
+ "route": "wait"
+ },
+ {
+ "fail": "outage"
+ },
+ {
+ "route": "queue"
+ }
+ ]
+ }
+ },
+ "steps": [
+ {
+ "submit": "s",
+ "events": [
+ {
+ "id": "a",
+ "name": "drag",
+ "text": "drag a",
+ "quietForMs": 10
+ }
+ ]
+ },
+ {
+ "advance": 40
+ },
+ {
+ "inspect": "s"
+ },
+ {
+ "advance": 80
+ }
+ ]
+ },
+ "expected": {
+ "judgeCalls": {
+ "s": [
+ {
+ "scope": "s",
+ "window": {
+ "id": "3ecbd4f2ef91c78f",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag a",
+ "quietForMs": 10,
+ "kind": "continuous",
+ "seenAt": 0
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 0,
+ "dropped": 0,
+ "gap": false,
+ "settledAt": 10
+ },
+ "routes": [
+ {
+ "route": "interrupt"
+ },
+ {
+ "route": "queue"
+ },
+ {
+ "route": "note"
+ },
+ {
+ "route": "ask"
+ },
+ {
+ "route": "skip"
+ },
+ {
+ "route": "wait"
+ }
+ ],
+ "predicates": [],
+ "facts": {},
+ "recent": [],
+ "now": 10
+ },
+ {
+ "scope": "s",
+ "window": {
+ "id": "3ecbd4f2ef91c78f",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag a",
+ "quietForMs": 10,
+ "kind": "continuous",
+ "seenAt": 0
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 0,
+ "dropped": 0,
+ "gap": false,
+ "settledAt": 10
+ },
+ "routes": [
+ {
+ "route": "interrupt"
+ },
+ {
+ "route": "queue"
+ },
+ {
+ "route": "note"
+ },
+ {
+ "route": "ask"
+ },
+ {
+ "route": "skip"
+ },
+ {
+ "route": "wait"
+ }
+ ],
+ "predicates": [],
+ "facts": {},
+ "recent": [],
+ "now": 40
+ },
+ {
+ "scope": "s",
+ "window": {
+ "id": "3ecbd4f2ef91c78f",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag a",
+ "quietForMs": 10,
+ "kind": "continuous",
+ "seenAt": 0
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 1,
+ "dropped": 0,
+ "gap": false,
+ "settledAt": 10
+ },
+ "routes": [
+ {
+ "route": "interrupt"
+ },
+ {
+ "route": "queue"
+ },
+ {
+ "route": "note"
+ },
+ {
+ "route": "ask"
+ },
+ {
+ "route": "skip"
+ },
+ {
+ "route": "wait"
+ }
+ ],
+ "predicates": [],
+ "facts": {},
+ "recent": [],
+ "now": 60
+ },
+ {
+ "scope": "s",
+ "window": {
+ "id": "3ecbd4f2ef91c78f",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag a",
+ "quietForMs": 10,
+ "kind": "continuous",
+ "seenAt": 0
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 1,
+ "dropped": 0,
+ "gap": false,
+ "settledAt": 10
+ },
+ "routes": [
+ {
+ "route": "interrupt"
+ },
+ {
+ "route": "queue"
+ },
+ {
+ "route": "note"
+ },
+ {
+ "route": "ask"
+ },
+ {
+ "route": "skip"
+ },
+ {
+ "route": "wait"
+ }
+ ],
+ "predicates": [],
+ "facts": {},
+ "recent": [],
+ "now": 120
+ }
+ ]
+ },
+ "deliveries": {
+ "s": [
+ {
+ "decision": {
+ "id": "3ecbd4f2ef91c78f",
+ "scope": "s",
+ "route": "queue",
+ "probabilities": {
+ "interrupt": 0,
+ "queue": 1,
+ "note": 0,
+ "ask": 0,
+ "skip": 0,
+ "wait": 0
+ },
+ "predicates": {},
+ "confidence": null,
+ "window": {
+ "id": "3ecbd4f2ef91c78f",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag a",
+ "quietForMs": 10,
+ "kind": "continuous",
+ "seenAt": 0
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 1,
+ "dropped": 0,
+ "gap": false,
+ "settledAt": 10
+ },
+ "at": 120
+ },
+ "outcome": "ok"
+ }
+ ]
+ },
+ "deadLetterCalls": {},
+ "traces": {
+ "s": [
+ {
+ "kind": "ingested",
+ "scope": "s",
+ "count": 1,
+ "duplicates": 0
+ },
+ {
+ "kind": "settled",
+ "scope": "s",
+ "batchId": "3ecbd4f2ef91c78f",
+ "reason": "stream_quiet",
+ "count": 1,
+ "merged": false
+ },
+ {
+ "kind": "judging",
+ "scope": "s",
+ "batchId": "3ecbd4f2ef91c78f",
+ "attempt": 1,
+ "offerWait": true
+ },
+ {
+ "kind": "retrying",
+ "scope": "s",
+ "stage": "judge",
+ "id": "3ecbd4f2ef91c78f",
+ "attempt": 1,
+ "at": 40,
+ "message": "outage"
+ },
+ {
+ "kind": "judging",
+ "scope": "s",
+ "batchId": "3ecbd4f2ef91c78f",
+ "attempt": 2,
+ "offerWait": true
+ },
+ {
+ "kind": "waiting",
+ "scope": "s",
+ "batchId": "3ecbd4f2ef91c78f",
+ "waits": 1,
+ "until": 60
+ },
+ {
+ "kind": "judging",
+ "scope": "s",
+ "batchId": "3ecbd4f2ef91c78f",
+ "attempt": 3,
+ "offerWait": true
+ },
+ {
+ "kind": "retrying",
+ "scope": "s",
+ "stage": "judge",
+ "id": "3ecbd4f2ef91c78f",
+ "attempt": 3,
+ "at": 120,
+ "message": "outage"
+ },
+ {
+ "kind": "judging",
+ "scope": "s",
+ "batchId": "3ecbd4f2ef91c78f",
+ "attempt": 4,
+ "offerWait": true
+ },
+ {
+ "kind": "judged",
+ "scope": "s",
+ "batchId": "3ecbd4f2ef91c78f",
+ "route": "queue"
+ },
+ {
+ "kind": "delivering",
+ "scope": "s",
+ "deliveryId": "3ecbd4f2ef91c78f",
+ "attempt": 1
+ },
+ {
+ "kind": "delivered",
+ "scope": "s",
+ "deliveryId": "3ecbd4f2ef91c78f"
+ }
+ ]
+ },
+ "results": [
+ {
+ "step": 0,
+ "error": null
+ }
+ ],
+ "inspections": [
+ {
+ "step": 2,
+ "scope": "s",
+ "record": {
+ "version": 5,
+ "scope": "s",
+ "cursors": {},
+ "seen": [
+ "a"
+ ],
+ "buffer": {
+ "entries": [],
+ "dropped": 0,
+ "gap": false,
+ "forcedAt": null
+ },
+ "batch": {
+ "window": {
+ "id": "3ecbd4f2ef91c78f",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag a",
+ "quietForMs": 10,
+ "kind": "continuous",
+ "seenAt": 0
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 1,
+ "dropped": 0,
+ "gap": false,
+ "settledAt": 10
+ },
+ "phase": {
+ "phase": "waiting",
+ "attempt": 2,
+ "until": 60,
+ "failures": 1
+ }
+ },
+ "outbox": {
+ "decisions": [],
+ "deadLetters": []
+ },
+ "recent": [],
+ "dueAt": 60
+ }
+ }
+ ],
+ "records": {
+ "s": {
+ "version": 10,
+ "scope": "s",
+ "cursors": {},
+ "seen": [
+ "a"
+ ],
+ "buffer": {
+ "entries": [],
+ "dropped": 0,
+ "gap": false,
+ "forcedAt": null
+ },
+ "batch": null,
+ "outbox": {
+ "decisions": [],
+ "deadLetters": []
+ },
+ "recent": [
+ {
+ "id": "3ecbd4f2ef91c78f",
+ "route": "queue",
+ "at": 120
+ }
+ ],
+ "dueAt": null
+ }
+ },
+ "log": [
+ {
+ "kind": "decision",
+ "id": "3ecbd4f2ef91c78f",
+ "scope": "s",
+ "at": 120,
+ "route": "queue",
+ "body": {
+ "id": "3ecbd4f2ef91c78f",
+ "scope": "s",
+ "route": "queue",
+ "probabilities": {
+ "interrupt": 0,
+ "queue": 1,
+ "note": 0,
+ "ask": 0,
+ "skip": 0,
+ "wait": 0
+ },
+ "predicates": {},
+ "confidence": null,
+ "window": {
+ "id": "3ecbd4f2ef91c78f",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag a",
+ "quietForMs": 10,
+ "kind": "continuous",
+ "seenAt": 0
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 1,
+ "dropped": 0,
+ "gap": false,
+ "settledAt": 10
+ },
+ "at": 120
+ },
+ "position": "1"
+ }
+ ]
+ }
+ },
+ {
+ "scenario": {
+ "name": "accumulating age eligibility applies at an initial quiet tie",
+ "start": 0,
+ "kinds": {
+ "close": "closing",
+ "say": "flush",
+ "drag": "continuous",
+ "look": "passive",
+ "out": "consequence",
+ "said": "context"
+ },
+ "settle": {
+ "continuation": "accumulate",
+ "maxWindowMs": 10
+ },
+ "judge": {
+ "*": {
+ "answers": [
+ {
+ "route": "queue"
+ }
+ ]
+ }
+ },
+ "steps": [
+ {
+ "push": "s",
+ "events": [
+ {
+ "id": "a",
+ "name": "drag",
+ "text": "drag a",
+ "quietForMs": 10
+ }
+ ]
+ },
+ {
+ "advance": 10
+ }
+ ]
+ },
+ "expected": {
+ "judgeCalls": {
+ "s": [
+ {
+ "scope": "s",
+ "window": {
+ "id": "3ecbd4f2ef91c78f",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag a",
+ "quietForMs": 10,
+ "kind": "continuous",
+ "seenAt": 0
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 0,
+ "dropped": 0,
+ "gap": false,
+ "settledAt": 10
+ },
+ "routes": [
+ {
+ "route": "interrupt"
+ },
+ {
+ "route": "queue"
+ },
+ {
+ "route": "note"
+ },
+ {
+ "route": "ask"
+ },
+ {
+ "route": "skip"
+ }
+ ],
+ "predicates": [],
+ "facts": {},
+ "recent": [],
+ "now": 10
+ }
+ ]
+ },
+ "deliveries": {
+ "s": [
+ {
+ "decision": {
+ "id": "3ecbd4f2ef91c78f",
+ "scope": "s",
+ "route": "queue",
+ "probabilities": {
+ "interrupt": 0,
+ "queue": 1,
+ "note": 0,
+ "ask": 0,
+ "skip": 0,
+ "wait": 0
+ },
+ "predicates": {},
+ "confidence": null,
+ "window": {
+ "id": "3ecbd4f2ef91c78f",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag a",
+ "quietForMs": 10,
+ "kind": "continuous",
+ "seenAt": 0
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 0,
+ "dropped": 0,
+ "gap": false,
+ "settledAt": 10
+ },
+ "at": 10
+ },
+ "outcome": "ok"
+ }
+ ]
+ },
+ "deadLetterCalls": {},
+ "traces": {
+ "s": [
+ {
+ "kind": "ingested",
+ "scope": "s",
+ "count": 1,
+ "duplicates": 0
+ },
+ {
+ "kind": "settled",
+ "scope": "s",
+ "batchId": "3ecbd4f2ef91c78f",
+ "reason": "stream_quiet",
+ "count": 1,
+ "merged": false
+ },
+ {
+ "kind": "judging",
+ "scope": "s",
+ "batchId": "3ecbd4f2ef91c78f",
+ "attempt": 1,
+ "offerWait": false
+ },
+ {
+ "kind": "judged",
+ "scope": "s",
+ "batchId": "3ecbd4f2ef91c78f",
+ "route": "queue"
+ },
+ {
+ "kind": "delivering",
+ "scope": "s",
+ "deliveryId": "3ecbd4f2ef91c78f",
+ "attempt": 1
+ },
+ {
+ "kind": "delivered",
+ "scope": "s",
+ "deliveryId": "3ecbd4f2ef91c78f"
+ }
+ ]
+ },
+ "results": [
+ {
+ "step": 0,
+ "error": null
+ }
+ ],
+ "inspections": [],
+ "records": {
+ "s": {
+ "version": 4,
+ "scope": "s",
+ "cursors": {},
+ "seen": [
+ "a"
+ ],
+ "buffer": {
+ "entries": [],
+ "dropped": 0,
+ "gap": false,
+ "forcedAt": null
+ },
+ "batch": null,
+ "outbox": {
+ "decisions": [],
+ "deadLetters": []
+ },
+ "recent": [
+ {
+ "id": "3ecbd4f2ef91c78f",
+ "route": "queue",
+ "at": 10
+ }
+ ],
+ "dueAt": null
+ }
+ },
+ "log": [
+ {
+ "kind": "decision",
+ "id": "3ecbd4f2ef91c78f",
+ "scope": "s",
+ "at": 10,
+ "route": "queue",
+ "body": {
+ "id": "3ecbd4f2ef91c78f",
+ "scope": "s",
+ "route": "queue",
+ "probabilities": {
+ "interrupt": 0,
+ "queue": 1,
+ "note": 0,
+ "ask": 0,
+ "skip": 0,
+ "wait": 0
+ },
+ "predicates": {},
+ "confidence": null,
+ "window": {
+ "id": "3ecbd4f2ef91c78f",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag a",
+ "quietForMs": 10,
+ "kind": "continuous",
+ "seenAt": 0
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 0,
+ "dropped": 0,
+ "gap": false,
+ "settledAt": 10
+ },
+ "at": 10
+ },
+ "position": "1"
+ }
+ ]
+ }
+ },
+ {
+ "scenario": {
+ "name": "accumulating wait checks combined rendered bytes",
+ "start": 0,
+ "intakes": [
+ "s"
+ ],
+ "kinds": {
+ "close": "closing",
+ "say": "flush",
+ "drag": "continuous",
+ "look": "passive",
+ "out": "consequence",
+ "said": "context"
+ },
+ "settle": {
+ "continuation": "accumulate",
+ "maxWindowBytes": 100,
+ "retryBackoffMs": [
+ 30,
+ 60
+ ]
+ },
+ "judge": {
+ "*": {
+ "answers": [
+ {
+ "route": "wait"
+ },
+ {
+ "route": "queue"
+ }
+ ]
+ }
+ },
+ "steps": [
+ {
+ "submit": "s",
+ "events": [
+ {
+ "id": "a",
+ "name": "drag",
+ "text": "qqqqqqqqqqqqqqqqqqqq",
+ "quietForMs": 10
+ }
+ ]
+ },
+ {
+ "advance": 15
+ },
+ {
+ "submit": "s",
+ "events": [
+ {
+ "id": "b",
+ "name": "drag",
+ "text": "qqqqqqqqqqqqqqqqqqqq",
+ "quietForMs": 100
+ }
+ ]
+ },
+ {
+ "advance": 25
+ }
+ ]
+ },
+ "expected": {
+ "judgeCalls": {
+ "s": [
+ {
+ "scope": "s",
+ "window": {
+ "id": "3ecbd4f2ef91c78f",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "qqqqqqqqqqqqqqqqqqqq",
+ "quietForMs": 10,
+ "kind": "continuous",
+ "seenAt": 0
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 0,
+ "dropped": 0,
+ "gap": false,
+ "settledAt": 10
+ },
+ "routes": [
+ {
+ "route": "interrupt"
+ },
+ {
+ "route": "queue"
+ },
+ {
+ "route": "note"
+ },
+ {
+ "route": "ask"
+ },
+ {
+ "route": "skip"
+ },
+ {
+ "route": "wait"
+ }
+ ],
+ "predicates": [],
+ "facts": {},
+ "recent": [],
+ "now": 10
+ },
+ {
+ "scope": "s",
+ "window": {
+ "id": "f9df8ba2df127ca6",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "qqqqqqqqqqqqqqqqqqqq",
+ "quietForMs": 10,
+ "kind": "continuous",
+ "seenAt": 0
+ },
+ {
+ "id": "b",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "qqqqqqqqqqqqqqqqqqqq",
+ "quietForMs": 100,
+ "kind": "continuous",
+ "seenAt": 15
+ }
+ ],
+ "reason": "size",
+ "waits": 1,
+ "dropped": 0,
+ "gap": false,
+ "settledAt": 15
+ },
+ "routes": [
+ {
+ "route": "interrupt"
+ },
+ {
+ "route": "queue"
+ },
+ {
+ "route": "note"
+ },
+ {
+ "route": "ask"
+ },
+ {
+ "route": "skip"
+ }
+ ],
+ "predicates": [],
+ "facts": {},
+ "recent": [],
+ "now": 15
+ }
+ ]
+ },
+ "deliveries": {
+ "s": [
+ {
+ "decision": {
+ "id": "f9df8ba2df127ca6",
+ "scope": "s",
+ "route": "queue",
+ "probabilities": {
+ "interrupt": 0,
+ "queue": 1,
+ "note": 0,
+ "ask": 0,
+ "skip": 0,
+ "wait": 0
+ },
+ "predicates": {},
+ "confidence": null,
+ "window": {
+ "id": "f9df8ba2df127ca6",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "qqqqqqqqqqqqqqqqqqqq",
+ "quietForMs": 10,
+ "kind": "continuous",
+ "seenAt": 0
+ },
+ {
+ "id": "b",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "qqqqqqqqqqqqqqqqqqqq",
+ "quietForMs": 100,
+ "kind": "continuous",
+ "seenAt": 15
+ }
+ ],
+ "reason": "size",
+ "waits": 1,
+ "dropped": 0,
+ "gap": false,
+ "settledAt": 15
+ },
+ "at": 15
+ },
+ "outcome": "ok"
+ }
+ ]
+ },
+ "deadLetterCalls": {},
+ "traces": {
+ "s": [
+ {
+ "kind": "ingested",
+ "scope": "s",
+ "count": 1,
+ "duplicates": 0
+ },
+ {
+ "kind": "settled",
+ "scope": "s",
+ "batchId": "3ecbd4f2ef91c78f",
+ "reason": "stream_quiet",
+ "count": 1,
+ "merged": false
+ },
+ {
+ "kind": "judging",
+ "scope": "s",
+ "batchId": "3ecbd4f2ef91c78f",
+ "attempt": 1,
+ "offerWait": true
+ },
+ {
+ "kind": "waiting",
+ "scope": "s",
+ "batchId": "3ecbd4f2ef91c78f",
+ "waits": 1,
+ "until": 10010
+ },
+ {
+ "kind": "ingested",
+ "scope": "s",
+ "count": 1,
+ "duplicates": 0
+ },
+ {
+ "kind": "settled",
+ "scope": "s",
+ "batchId": "f9df8ba2df127ca6",
+ "reason": "size",
+ "count": 2,
+ "merged": true
+ },
+ {
+ "kind": "judging",
+ "scope": "s",
+ "batchId": "f9df8ba2df127ca6",
+ "attempt": 2,
+ "offerWait": false
+ },
+ {
+ "kind": "judged",
+ "scope": "s",
+ "batchId": "f9df8ba2df127ca6",
+ "route": "queue"
+ },
+ {
+ "kind": "delivering",
+ "scope": "s",
+ "deliveryId": "f9df8ba2df127ca6",
+ "attempt": 1
+ },
+ {
+ "kind": "delivered",
+ "scope": "s",
+ "deliveryId": "f9df8ba2df127ca6"
+ }
+ ]
+ },
+ "results": [
+ {
+ "step": 0,
+ "error": null
+ },
+ {
+ "step": 2,
+ "error": null
+ }
+ ],
+ "inspections": [],
+ "records": {
+ "s": {
+ "version": 7,
+ "scope": "s",
+ "cursors": {},
+ "seen": [
+ "a",
+ "b"
+ ],
+ "buffer": {
+ "entries": [],
+ "dropped": 0,
+ "gap": false,
+ "forcedAt": null
+ },
+ "batch": null,
+ "outbox": {
+ "decisions": [],
+ "deadLetters": []
+ },
+ "recent": [
+ {
+ "id": "f9df8ba2df127ca6",
+ "route": "queue",
+ "at": 15
+ }
+ ],
+ "dueAt": null
+ }
+ },
+ "log": [
+ {
+ "kind": "decision",
+ "id": "f9df8ba2df127ca6",
+ "scope": "s",
+ "at": 15,
+ "route": "queue",
+ "body": {
+ "id": "f9df8ba2df127ca6",
+ "scope": "s",
+ "route": "queue",
+ "probabilities": {
+ "interrupt": 0,
+ "queue": 1,
+ "note": 0,
+ "ask": 0,
+ "skip": 0,
+ "wait": 0
+ },
+ "predicates": {},
+ "confidence": null,
+ "window": {
+ "id": "f9df8ba2df127ca6",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "qqqqqqqqqqqqqqqqqqqq",
+ "quietForMs": 10,
+ "kind": "continuous",
+ "seenAt": 0
+ },
+ {
+ "id": "b",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "qqqqqqqqqqqqqqqqqqqq",
+ "quietForMs": 100,
+ "kind": "continuous",
+ "seenAt": 15
+ }
+ ],
+ "reason": "size",
+ "waits": 1,
+ "dropped": 0,
+ "gap": false,
+ "settledAt": 15
+ },
+ "at": 15
+ },
+ "position": "1"
+ }
+ ]
+ }
+ },
+ {
+ "scenario": {
+ "name": "accumulating retry checks combined rendered bytes",
+ "start": 0,
+ "intakes": [
+ "s"
+ ],
+ "kinds": {
+ "close": "closing",
+ "say": "flush",
+ "drag": "continuous",
+ "look": "passive",
+ "out": "consequence",
+ "said": "context"
+ },
+ "settle": {
+ "continuation": "accumulate",
+ "maxWindowBytes": 100,
+ "retryBackoffMs": [
+ 30,
+ 60
+ ]
+ },
+ "judge": {
+ "*": {
+ "answers": [
+ {
+ "fail": "outage"
+ },
+ {
+ "route": "queue"
+ }
+ ]
+ }
+ },
+ "steps": [
+ {
+ "submit": "s",
+ "events": [
+ {
+ "id": "a",
+ "name": "drag",
+ "text": "qqqqqqqqqqqqqqqqqqqq",
+ "quietForMs": 10
+ }
+ ]
+ },
+ {
+ "advance": 15
+ },
+ {
+ "submit": "s",
+ "events": [
+ {
+ "id": "b",
+ "name": "drag",
+ "text": "qqqqqqqqqqqqqqqqqqqq",
+ "quietForMs": 100
+ }
+ ]
+ },
+ {
+ "advance": 25
+ }
+ ]
+ },
+ "expected": {
+ "judgeCalls": {
+ "s": [
+ {
+ "scope": "s",
+ "window": {
+ "id": "3ecbd4f2ef91c78f",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "qqqqqqqqqqqqqqqqqqqq",
+ "quietForMs": 10,
+ "kind": "continuous",
+ "seenAt": 0
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 0,
+ "dropped": 0,
+ "gap": false,
+ "settledAt": 10
+ },
+ "routes": [
+ {
+ "route": "interrupt"
+ },
+ {
+ "route": "queue"
+ },
+ {
+ "route": "note"
+ },
+ {
+ "route": "ask"
+ },
+ {
+ "route": "skip"
+ },
+ {
+ "route": "wait"
+ }
+ ],
+ "predicates": [],
+ "facts": {},
+ "recent": [],
+ "now": 10
+ },
+ {
+ "scope": "s",
+ "window": {
+ "id": "f9df8ba2df127ca6",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "qqqqqqqqqqqqqqqqqqqq",
+ "quietForMs": 10,
+ "kind": "continuous",
+ "seenAt": 0
+ },
+ {
+ "id": "b",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "qqqqqqqqqqqqqqqqqqqq",
+ "quietForMs": 100,
+ "kind": "continuous",
+ "seenAt": 15
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 0,
+ "dropped": 0,
+ "gap": false,
+ "settledAt": 40
+ },
+ "routes": [
+ {
+ "route": "interrupt"
+ },
+ {
+ "route": "queue"
+ },
+ {
+ "route": "note"
+ },
+ {
+ "route": "ask"
+ },
+ {
+ "route": "skip"
+ }
+ ],
+ "predicates": [],
+ "facts": {},
+ "recent": [],
+ "now": 40
+ }
+ ]
+ },
+ "deliveries": {
+ "s": [
+ {
+ "decision": {
+ "id": "f9df8ba2df127ca6",
+ "scope": "s",
+ "route": "queue",
+ "probabilities": {
+ "interrupt": 0,
+ "queue": 1,
+ "note": 0,
+ "ask": 0,
+ "skip": 0,
+ "wait": 0
+ },
+ "predicates": {},
+ "confidence": null,
+ "window": {
+ "id": "f9df8ba2df127ca6",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "qqqqqqqqqqqqqqqqqqqq",
+ "quietForMs": 10,
+ "kind": "continuous",
+ "seenAt": 0
+ },
+ {
+ "id": "b",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "qqqqqqqqqqqqqqqqqqqq",
+ "quietForMs": 100,
+ "kind": "continuous",
+ "seenAt": 15
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 0,
+ "dropped": 0,
+ "gap": false,
+ "settledAt": 40
+ },
+ "at": 40
+ },
+ "outcome": "ok"
+ }
+ ]
+ },
+ "deadLetterCalls": {},
+ "traces": {
+ "s": [
+ {
+ "kind": "ingested",
+ "scope": "s",
+ "count": 1,
+ "duplicates": 0
+ },
+ {
+ "kind": "settled",
+ "scope": "s",
+ "batchId": "3ecbd4f2ef91c78f",
+ "reason": "stream_quiet",
+ "count": 1,
+ "merged": false
+ },
+ {
+ "kind": "judging",
+ "scope": "s",
+ "batchId": "3ecbd4f2ef91c78f",
+ "attempt": 1,
+ "offerWait": true
+ },
+ {
+ "kind": "retrying",
+ "scope": "s",
+ "stage": "judge",
+ "id": "3ecbd4f2ef91c78f",
+ "attempt": 1,
+ "at": 40,
+ "message": "outage"
+ },
+ {
+ "kind": "ingested",
+ "scope": "s",
+ "count": 1,
+ "duplicates": 0
+ },
+ {
+ "kind": "settled",
+ "scope": "s",
+ "batchId": "f9df8ba2df127ca6",
+ "reason": "stream_quiet",
+ "count": 2,
+ "merged": true
+ },
+ {
+ "kind": "judging",
+ "scope": "s",
+ "batchId": "f9df8ba2df127ca6",
+ "attempt": 2,
+ "offerWait": false
+ },
+ {
+ "kind": "judged",
+ "scope": "s",
+ "batchId": "f9df8ba2df127ca6",
+ "route": "queue"
+ },
+ {
+ "kind": "delivering",
+ "scope": "s",
+ "deliveryId": "f9df8ba2df127ca6",
+ "attempt": 1
+ },
+ {
+ "kind": "delivered",
+ "scope": "s",
+ "deliveryId": "f9df8ba2df127ca6"
+ }
+ ]
+ },
+ "results": [
+ {
+ "step": 0,
+ "error": null
+ },
+ {
+ "step": 2,
+ "error": null
+ }
+ ],
+ "inspections": [],
+ "records": {
+ "s": {
+ "version": 7,
+ "scope": "s",
+ "cursors": {},
+ "seen": [
+ "a",
+ "b"
+ ],
+ "buffer": {
+ "entries": [],
+ "dropped": 0,
+ "gap": false,
+ "forcedAt": null
+ },
+ "batch": null,
+ "outbox": {
+ "decisions": [],
+ "deadLetters": []
+ },
+ "recent": [
+ {
+ "id": "f9df8ba2df127ca6",
+ "route": "queue",
+ "at": 40
+ }
+ ],
+ "dueAt": null
+ }
+ },
+ "log": [
+ {
+ "kind": "decision",
+ "id": "f9df8ba2df127ca6",
+ "scope": "s",
+ "at": 40,
+ "route": "queue",
+ "body": {
+ "id": "f9df8ba2df127ca6",
+ "scope": "s",
+ "route": "queue",
+ "probabilities": {
+ "interrupt": 0,
+ "queue": 1,
+ "note": 0,
+ "ask": 0,
+ "skip": 0,
+ "wait": 0
+ },
+ "predicates": {},
+ "confidence": null,
+ "window": {
+ "id": "f9df8ba2df127ca6",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "qqqqqqqqqqqqqqqqqqqq",
+ "quietForMs": 10,
+ "kind": "continuous",
+ "seenAt": 0
+ },
+ {
+ "id": "b",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "qqqqqqqqqqqqqqqqqqqq",
+ "quietForMs": 100,
+ "kind": "continuous",
+ "seenAt": 15
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 0,
+ "dropped": 0,
+ "gap": false,
+ "settledAt": 40
+ },
+ "at": 40
+ },
+ "position": "1"
+ }
+ ]
+ }
+ },
+ {
+ "scenario": {
+ "name": "accumulating retry checks the count after absorbing fresh acts",
+ "start": 0,
+ "intakes": [
+ "s"
+ ],
+ "kinds": {
+ "close": "closing",
+ "say": "flush",
+ "drag": "continuous",
+ "look": "passive",
+ "out": "consequence",
+ "said": "context"
+ },
+ "settle": {
+ "continuation": "accumulate",
+ "maxEvents": 2,
+ "retryBackoffMs": [
+ 30,
+ 60
+ ]
+ },
+ "judge": {
+ "*": {
+ "answers": [
+ {
+ "fail": "outage"
+ },
+ {
+ "route": "queue"
+ }
+ ]
+ }
+ },
+ "steps": [
+ {
+ "submit": "s",
+ "events": [
+ {
+ "id": "a",
+ "name": "drag",
+ "text": "drag a",
+ "quietForMs": 10
+ }
+ ]
+ },
+ {
+ "advance": 15
+ },
+ {
+ "submit": "s",
+ "events": [
+ {
+ "id": "b",
+ "name": "drag",
+ "text": "drag b",
+ "quietForMs": 100
+ },
+ {
+ "id": "c",
+ "name": "drag",
+ "text": "drag c",
+ "quietForMs": 100
+ }
+ ]
+ },
+ {
+ "advance": 25
+ }
+ ]
+ },
+ "expected": {
+ "judgeCalls": {
+ "s": [
+ {
+ "scope": "s",
+ "window": {
+ "id": "3ecbd4f2ef91c78f",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag a",
+ "quietForMs": 10,
+ "kind": "continuous",
+ "seenAt": 0
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 0,
+ "dropped": 0,
+ "gap": false,
+ "settledAt": 10
+ },
+ "routes": [
+ {
+ "route": "interrupt"
+ },
+ {
+ "route": "queue"
+ },
+ {
+ "route": "note"
+ },
+ {
+ "route": "ask"
+ },
+ {
+ "route": "skip"
+ },
+ {
+ "route": "wait"
+ }
+ ],
+ "predicates": [],
+ "facts": {},
+ "recent": [],
+ "now": 10
+ },
+ {
+ "scope": "s",
+ "window": {
+ "id": "1a353cc02182e85a",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag a",
+ "quietForMs": 10,
+ "kind": "continuous",
+ "seenAt": 0
+ },
+ {
+ "id": "b",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag b",
+ "quietForMs": 100,
+ "kind": "continuous",
+ "seenAt": 15
+ },
+ {
+ "id": "c",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag c",
+ "quietForMs": 100,
+ "kind": "continuous",
+ "seenAt": 15
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 0,
+ "dropped": 0,
+ "gap": false,
+ "settledAt": 40
+ },
+ "routes": [
+ {
+ "route": "interrupt"
+ },
+ {
+ "route": "queue"
+ },
+ {
+ "route": "note"
+ },
+ {
+ "route": "ask"
+ },
+ {
+ "route": "skip"
+ }
+ ],
+ "predicates": [],
+ "facts": {},
+ "recent": [],
+ "now": 40
+ }
+ ]
+ },
+ "deliveries": {
+ "s": [
+ {
+ "decision": {
+ "id": "1a353cc02182e85a",
+ "scope": "s",
+ "route": "queue",
+ "probabilities": {
+ "interrupt": 0,
+ "queue": 1,
+ "note": 0,
+ "ask": 0,
+ "skip": 0,
+ "wait": 0
+ },
+ "predicates": {},
+ "confidence": null,
+ "window": {
+ "id": "1a353cc02182e85a",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag a",
+ "quietForMs": 10,
+ "kind": "continuous",
+ "seenAt": 0
+ },
+ {
+ "id": "b",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag b",
+ "quietForMs": 100,
+ "kind": "continuous",
+ "seenAt": 15
+ },
+ {
+ "id": "c",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag c",
+ "quietForMs": 100,
+ "kind": "continuous",
+ "seenAt": 15
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 0,
+ "dropped": 0,
+ "gap": false,
+ "settledAt": 40
+ },
+ "at": 40
+ },
+ "outcome": "ok"
+ }
+ ]
+ },
+ "deadLetterCalls": {},
+ "traces": {
+ "s": [
+ {
+ "kind": "ingested",
+ "scope": "s",
+ "count": 1,
+ "duplicates": 0
+ },
+ {
+ "kind": "settled",
+ "scope": "s",
+ "batchId": "3ecbd4f2ef91c78f",
+ "reason": "stream_quiet",
+ "count": 1,
+ "merged": false
+ },
+ {
+ "kind": "judging",
+ "scope": "s",
+ "batchId": "3ecbd4f2ef91c78f",
+ "attempt": 1,
+ "offerWait": true
+ },
+ {
+ "kind": "retrying",
+ "scope": "s",
+ "stage": "judge",
+ "id": "3ecbd4f2ef91c78f",
+ "attempt": 1,
+ "at": 40,
+ "message": "outage"
+ },
+ {
+ "kind": "ingested",
+ "scope": "s",
+ "count": 2,
+ "duplicates": 0
+ },
+ {
+ "kind": "settled",
+ "scope": "s",
+ "batchId": "1a353cc02182e85a",
+ "reason": "stream_quiet",
+ "count": 3,
+ "merged": true
+ },
+ {
+ "kind": "judging",
+ "scope": "s",
+ "batchId": "1a353cc02182e85a",
+ "attempt": 2,
+ "offerWait": false
+ },
+ {
+ "kind": "judged",
+ "scope": "s",
+ "batchId": "1a353cc02182e85a",
+ "route": "queue"
+ },
+ {
+ "kind": "delivering",
+ "scope": "s",
+ "deliveryId": "1a353cc02182e85a",
+ "attempt": 1
+ },
+ {
+ "kind": "delivered",
+ "scope": "s",
+ "deliveryId": "1a353cc02182e85a"
+ }
+ ]
+ },
+ "results": [
+ {
+ "step": 0,
+ "error": null
+ },
+ {
+ "step": 2,
+ "error": null
+ }
+ ],
+ "inspections": [],
+ "records": {
+ "s": {
+ "version": 7,
+ "scope": "s",
+ "cursors": {},
+ "seen": [
+ "a",
+ "b",
+ "c"
+ ],
+ "buffer": {
+ "entries": [],
+ "dropped": 0,
+ "gap": false,
+ "forcedAt": null
+ },
+ "batch": null,
+ "outbox": {
+ "decisions": [],
+ "deadLetters": []
+ },
+ "recent": [
+ {
+ "id": "1a353cc02182e85a",
+ "route": "queue",
+ "at": 40
+ }
+ ],
+ "dueAt": null
+ }
+ },
+ "log": [
+ {
+ "kind": "decision",
+ "id": "1a353cc02182e85a",
+ "scope": "s",
+ "at": 40,
+ "route": "queue",
+ "body": {
+ "id": "1a353cc02182e85a",
+ "scope": "s",
+ "route": "queue",
+ "probabilities": {
+ "interrupt": 0,
+ "queue": 1,
+ "note": 0,
+ "ask": 0,
+ "skip": 0,
+ "wait": 0
+ },
+ "predicates": {},
+ "confidence": null,
+ "window": {
+ "id": "1a353cc02182e85a",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag a",
+ "quietForMs": 10,
+ "kind": "continuous",
+ "seenAt": 0
+ },
+ {
+ "id": "b",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag b",
+ "quietForMs": 100,
+ "kind": "continuous",
+ "seenAt": 15
+ },
+ {
+ "id": "c",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag c",
+ "quietForMs": 100,
+ "kind": "continuous",
+ "seenAt": 15
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 0,
+ "dropped": 0,
+ "gap": false,
+ "settledAt": 40
+ },
+ "at": 40
+ },
+ "position": "1"
+ }
+ ]
+ }
+ },
+ {
+ "scenario": {
+ "name": "accumulating retry absorbs raw backlog after delayed failure completion",
+ "start": 0,
+ "intakes": [
+ "s"
+ ],
+ "kinds": {
+ "close": "closing",
+ "say": "flush",
+ "drag": "continuous",
+ "look": "passive",
+ "out": "consequence",
+ "said": "context"
+ },
+ "settle": {
+ "continuation": "accumulate",
+ "retryBackoffMs": [
+ 30,
+ 60
+ ]
+ },
+ "judge": {
+ "*": {
+ "answers": [
+ {
+ "hold": "call"
+ },
+ {
+ "route": "queue"
+ }
+ ]
+ }
+ },
+ "steps": [
+ {
+ "submit": "s",
+ "events": [
+ {
+ "id": "a",
+ "name": "drag",
+ "text": "drag a",
+ "quietForMs": 10
+ }
+ ]
+ },
+ {
+ "advance": 15
+ },
+ {
+ "submit": "s",
+ "events": [
+ {
+ "id": "b",
+ "name": "drag",
+ "text": "drag b",
+ "observedAt": 15,
+ "quietForMs": 100
+ }
+ ]
+ },
+ {
+ "advance": 1
+ },
+ {
+ "submit": "s",
+ "events": [
+ {
+ "id": "c",
+ "name": "drag",
+ "text": "drag c",
+ "observedAt": 16,
+ "quietForMs": 100
+ }
+ ]
+ },
+ {
+ "advance": 19
+ },
+ {
+ "release": "call",
+ "fail": "outage"
+ },
+ {
+ "inspect": "s"
+ },
+ {
+ "advance": 30
+ }
+ ]
+ },
+ "expected": {
+ "judgeCalls": {
+ "s": [
+ {
+ "scope": "s",
+ "window": {
+ "id": "3ecbd4f2ef91c78f",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag a",
+ "quietForMs": 10,
+ "kind": "continuous",
+ "seenAt": 0
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 0,
+ "dropped": 0,
+ "gap": false,
+ "settledAt": 10
+ },
+ "routes": [
+ {
+ "route": "interrupt"
+ },
+ {
+ "route": "queue"
+ },
+ {
+ "route": "note"
+ },
+ {
+ "route": "ask"
+ },
+ {
+ "route": "skip"
+ },
+ {
+ "route": "wait"
+ }
+ ],
+ "predicates": [],
+ "facts": {},
+ "recent": [],
+ "now": 10
+ },
+ {
+ "scope": "s",
+ "window": {
+ "id": "1a353cc02182e85a",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag a",
+ "quietForMs": 10,
+ "kind": "continuous",
+ "seenAt": 0
+ },
+ {
+ "id": "b",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag b",
+ "observedAt": 15,
+ "quietForMs": 100,
+ "kind": "continuous",
+ "seenAt": 35
+ },
+ {
+ "id": "c",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag c",
+ "observedAt": 16,
+ "quietForMs": 100,
+ "kind": "continuous",
+ "seenAt": 35
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 0,
+ "dropped": 0,
+ "gap": false,
+ "settledAt": 65
+ },
+ "routes": [
+ {
+ "route": "interrupt"
+ },
+ {
+ "route": "queue"
+ },
+ {
+ "route": "note"
+ },
+ {
+ "route": "ask"
+ },
+ {
+ "route": "skip"
+ },
+ {
+ "route": "wait"
+ }
+ ],
+ "predicates": [],
+ "facts": {},
+ "recent": [],
+ "now": 65
+ }
+ ]
+ },
+ "deliveries": {
+ "s": [
+ {
+ "decision": {
+ "id": "1a353cc02182e85a",
+ "scope": "s",
+ "route": "queue",
+ "probabilities": {
+ "interrupt": 0,
+ "queue": 1,
+ "note": 0,
+ "ask": 0,
+ "skip": 0,
+ "wait": 0
+ },
+ "predicates": {},
+ "confidence": null,
+ "window": {
+ "id": "1a353cc02182e85a",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag a",
+ "quietForMs": 10,
+ "kind": "continuous",
+ "seenAt": 0
+ },
+ {
+ "id": "b",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag b",
+ "observedAt": 15,
+ "quietForMs": 100,
+ "kind": "continuous",
+ "seenAt": 35
+ },
+ {
+ "id": "c",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag c",
+ "observedAt": 16,
+ "quietForMs": 100,
+ "kind": "continuous",
+ "seenAt": 35
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 0,
+ "dropped": 0,
+ "gap": false,
+ "settledAt": 65
+ },
+ "at": 65
+ },
+ "outcome": "ok"
+ }
+ ]
+ },
+ "deadLetterCalls": {},
+ "traces": {
+ "s": [
+ {
+ "kind": "ingested",
+ "scope": "s",
+ "count": 1,
+ "duplicates": 0
+ },
+ {
+ "kind": "settled",
+ "scope": "s",
+ "batchId": "3ecbd4f2ef91c78f",
+ "reason": "stream_quiet",
+ "count": 1,
+ "merged": false
+ },
+ {
+ "kind": "judging",
+ "scope": "s",
+ "batchId": "3ecbd4f2ef91c78f",
+ "attempt": 1,
+ "offerWait": true
+ },
+ {
+ "kind": "retrying",
+ "scope": "s",
+ "stage": "judge",
+ "id": "3ecbd4f2ef91c78f",
+ "attempt": 1,
+ "at": 65,
+ "message": "outage"
+ },
+ {
+ "kind": "ingested",
+ "scope": "s",
+ "count": 1,
+ "duplicates": 0
+ },
+ {
+ "kind": "ingested",
+ "scope": "s",
+ "count": 1,
+ "duplicates": 0
+ },
+ {
+ "kind": "settled",
+ "scope": "s",
+ "batchId": "1a353cc02182e85a",
+ "reason": "stream_quiet",
+ "count": 3,
+ "merged": true
+ },
+ {
+ "kind": "judging",
+ "scope": "s",
+ "batchId": "1a353cc02182e85a",
+ "attempt": 2,
+ "offerWait": true
+ },
+ {
+ "kind": "judged",
+ "scope": "s",
+ "batchId": "1a353cc02182e85a",
+ "route": "queue"
+ },
+ {
+ "kind": "delivering",
+ "scope": "s",
+ "deliveryId": "1a353cc02182e85a",
+ "attempt": 1
+ },
+ {
+ "kind": "delivered",
+ "scope": "s",
+ "deliveryId": "1a353cc02182e85a"
+ }
+ ]
+ },
+ "results": [
+ {
+ "step": 0,
+ "error": null
+ },
+ {
+ "step": 2,
+ "error": null
+ },
+ {
+ "step": 4,
+ "error": null
+ }
+ ],
+ "inspections": [
+ {
+ "step": 7,
+ "scope": "s",
+ "record": {
+ "version": 5,
+ "scope": "s",
+ "cursors": {},
+ "seen": [
+ "a",
+ "b",
+ "c"
+ ],
+ "buffer": {
+ "entries": [
+ {
+ "id": "b",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag b",
+ "observedAt": 15,
+ "quietForMs": 100,
+ "kind": "continuous",
+ "seenAt": 35
+ },
+ {
+ "id": "c",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag c",
+ "observedAt": 16,
+ "quietForMs": 100,
+ "kind": "continuous",
+ "seenAt": 35
+ }
+ ],
+ "dropped": 0,
+ "gap": false,
+ "forcedAt": null
+ },
+ "batch": {
+ "window": {
+ "id": "3ecbd4f2ef91c78f",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag a",
+ "quietForMs": 10,
+ "kind": "continuous",
+ "seenAt": 0
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 0,
+ "dropped": 0,
+ "gap": false,
+ "settledAt": 10
+ },
+ "phase": {
+ "phase": "retrying",
+ "attempt": 1,
+ "failures": 1,
+ "at": 65,
+ "offerWait": true
+ }
+ },
+ "outbox": {
+ "decisions": [],
+ "deadLetters": []
+ },
+ "recent": [],
+ "dueAt": 65
+ }
+ }
+ ],
+ "records": {
+ "s": {
+ "version": 8,
+ "scope": "s",
+ "cursors": {},
+ "seen": [
+ "a",
+ "b",
+ "c"
+ ],
+ "buffer": {
+ "entries": [],
+ "dropped": 0,
+ "gap": false,
+ "forcedAt": null
+ },
+ "batch": null,
+ "outbox": {
+ "decisions": [],
+ "deadLetters": []
+ },
+ "recent": [
+ {
+ "id": "1a353cc02182e85a",
+ "route": "queue",
+ "at": 65
+ }
+ ],
+ "dueAt": null
+ }
+ },
+ "log": [
+ {
+ "kind": "decision",
+ "id": "1a353cc02182e85a",
+ "scope": "s",
+ "at": 65,
+ "route": "queue",
+ "body": {
+ "id": "1a353cc02182e85a",
+ "scope": "s",
+ "route": "queue",
+ "probabilities": {
+ "interrupt": 0,
+ "queue": 1,
+ "note": 0,
+ "ask": 0,
+ "skip": 0,
+ "wait": 0
+ },
+ "predicates": {},
+ "confidence": null,
+ "window": {
+ "id": "1a353cc02182e85a",
+ "events": [
+ {
+ "id": "a",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag a",
+ "quietForMs": 10,
+ "kind": "continuous",
+ "seenAt": 0
+ },
+ {
+ "id": "b",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag b",
+ "observedAt": 15,
+ "quietForMs": 100,
+ "kind": "continuous",
+ "seenAt": 35
+ },
+ {
+ "id": "c",
+ "at": 0,
+ "name": "drag",
+ "data": {},
+ "text": "drag c",
+ "observedAt": 16,
+ "quietForMs": 100,
+ "kind": "continuous",
+ "seenAt": 35
+ }
+ ],
+ "reason": "stream_quiet",
+ "waits": 0,
+ "dropped": 0,
+ "gap": false,
+ "settledAt": 65
+ },
+ "at": 65
+ },
+ "position": "1"
+ }
+ ]
+ }
+ },
{
"scenario": {
"name": "serial intake keeps registered backlog ahead of a timer during preparation",
diff --git a/docs/reference.md b/docs/reference.md
index b42828e..9fec866 100644
--- a/docs/reference.md
+++ b/docs/reference.md
@@ -82,7 +82,7 @@ When every continuous entry omits `quietForMs`, existing timing remains unchange
| `note` | Gets it as context for its next turn and does not respond to it. | Yes |
| `ask` | Stays quiet. Your app offers the user a prompt to call the agent in. | Yes |
| `skip` | Hears nothing. | No. The verdict joins the scope's recent verdicts. |
-| `wait` | Hears nothing yet. attend holds the window and judges it again with the next window that settles, or after `waitHorizonMs` together with everything that arrived meanwhile, with `wait` withheld. | No. A window waits at most `maxWaits` times. |
+| `wait` | Hears nothing yet. attend holds the window and judges it again with the next window that settles, or after `waitHorizonMs` with the fresh input. Separate mode withholds wait at that horizon; [accumulating continuation](#accumulating-continuation) can reoffer it within its limits. | No. A window waits at most `maxWaits` times. |
attend picks the route, and your sink carries it out. `routes()` makes you write a handler for each of the four delivered routes.
@@ -132,6 +132,31 @@ Abort before application prevents event and cursor admission. An input already a
The handle is terminal after close or engine shutdown. Recreate the engine and open a new handle before running to resume committed state. Raw registrations and callbacks are not durable. Snapshots and tails contain only the existing reducer inputs; another runtime can read them without an intake. This provides local ordering in one engine, not ownership across processes sharing a store.
+## Accumulating continuation
+
+Set `settle.continuation` to `accumulate` when waits and provider retries should retain one unresolved window. Omission or `separate` keeps the existing behavior. Serial intake and this option are independent: intake orders preparation and immediate work; continuation determines what retained state does afterward.
+
+```ts
+import { createAttend } from '@acquiredintelligence/attend';
+
+const attend = createAttend({
+ kind: { reading: 'continuous' },
+ judge: async () => ({ route: 'queue' }),
+ sink: 'log',
+ settle: { continuation: 'accumulate' },
+});
+```
+
+After a `wait`, fresh entries alone drive quiet. At the horizon, attend reoffers the whole unresolved window, including fresh entries that are not quiet yet. It can offer `wait` again until `maxWaits` or a whole-window bound requires resolution. A provider failure retains the wait count; a successful `wait` retains the provider failure count. The latter selects the next retry backoff.
+
+During retry, its deadline is a strict not-before time. Fresh quiet, direct address, `flush()`, `end()`, age, count and bytes do not start a judgment earlier. At retry time, every entry still retained after pruning joins the held window. Gap and dropped-entry metadata join its next offer even when no fresh entry survives, and are then cleared from the fresh buffer. A timer that owns serial intake before a later raw registration can retry without that later entry. `flush()` still removes wait and supplies reason `forced`. `end()` applies to fresh open input, keeps reason `closing` and permits wait within the limits; with only an already-settled held window it remains a no-op.
+
+Eligibility uses the complete offered payload after the usual background shedding. Acts are never dropped. Count above `maxEvents`, rendered bytes at or above `maxWindowBytes`, and age at or above `maxWindowMs` withhold wait. Age starts at the earliest unresolved act's effective observation time. These checks also apply at initial offers, exact quiet/age ties and after absorbing an older observation. A bound makes a waiting window due; during backoff it takes effect at retry time. It does not interrupt an already running judge. A bound can withhold wait even when another deadline supplied the window's reason. Count and rendered bytes are not hard memory-allocation limits.
+
+Wait count, provider failures and the native attempt token are separate. Release and deferral refund the attempt token, so it is not a count of physical callback starts. A non-wait judgment or terminal failure ends the held window. Exhaustion keeps the existing dead-letter record and fields; `attempts` does not become a provider-failure count. Delivery retries do not reopen judgment. Engine or intake close retains committed state for recovery and does not reset its counters.
+
+Continuation is saved with the snapshot. A live writer cannot change between modes while a held batch or fresh entries remain. Empty scopes can change mode while retaining recent decisions and outbox work. In particular, an old separate waiting snapshot has no historic failure count to recover; switching it to accumulate is refused. `inspect` reads using the saved policy. See [storage](storage.md) for version coordination.
+
## Guarantees
- **One snapshot and a short tail per scope.** The snapshot holds the open window, the judge slot and the outbox. A write appends the inputs that changed state, and a snapshot replaces the tail once it grows past the snapshot's own size. A source's cursor commits in the same write as the events it covers.
diff --git a/docs/storage.md b/docs/storage.md
index 2e11444..9e0743e 100644
--- a/docs/storage.md
+++ b/docs/storage.md
@@ -38,4 +38,6 @@ Several processes can share one store. Any of them can `push`, and any number ca
Keep processes sharing a store on the same reducer version before using [observation time](reference.md#observation-time) or [continuous quiet durations](reference.md#continuous-quiet-duration). A reducer-version mismatch triggers replay and a fresh snapshot; it does not fence out older readers or writers. Older entries without `observedAt` retain their stored `seenAt` during replay. The clock at replay time never replaces that timestamp.
+[Accumulating continuation](reference.md#accumulating-continuation) uses reducer revision 4 and retains failures in waiting state. Choose the same mode in every writer of a scope. A writer refuses a mode change while the replayed scope has a held batch or fresh entries; finish them under the saved mode first, or use a new scope. Recent decisions and outbox work can remain. Old separate waiting snapshots lack historic failure counts and stay on their old semantics. Read-only inspection uses the saved policy. This check does not fence older writers that lack it.
+
Each adapter also has an `EventLog`: `memoryLog`, `sqliteLog`, `postgresLog` and `redisLog`. When producers live in other processes and you want a durable shared log in front of attend, append to the log and attach `logSource(log, scope)` instead of calling `push`.
diff --git a/python/README.md b/python/README.md
index 13a6f3c..0f57fc0 100644
--- a/python/README.md
+++ b/python/README.md
@@ -80,6 +80,7 @@ redis-py runs each concurrent command on a pooled connection of its own, and its
- Keyword arguments and `settle` keys are snake_case, such as `create_attend(settle={"wait_horizon_ms": 5000})`. Every value that crosses a store or a judge (events, windows, decisions, dead letters, records, traces) is a dict with the TypeScript field names, such as `decision["window"]["settledAt"]`, so both runtimes share one persisted layout.
- A judge, sink, dead-letter handler, `context` or `capture` is called with `(value, signal)`, where `signal` is an `aqi_attend.AbortSignal`. Honour it with `await signal.race(work)` or by checking `signal.aborted`.
- `push`, `flush` and `end` return futures that resolve once the input is persisted. They take the input when called, as the TypeScript promises do.
+- `settle={"continuation": "accumulate"}` retains one unresolved window through waits and retries. [Accumulating continuation](../docs/reference.md#accumulating-continuation) defines its bounds, failure allowance and stored-mode boundary.
- A continuous event can carry `quietForMs` in its wire dictionary. [Continuous quiet duration](../docs/reference.md#continuous-quiet-duration) defines its validation, defaults and recovery.
- An event's optional `observedAt` keeps its camelCase wire name. It supplies source observation time for deadlines; `seenAt` remains engine ingestion time. The shared [observation-time reference](../docs/reference.md#observation-time) defines validation, ordering and replay.
- Cancelling the task that runs `run()` stops it the way `stop()` does.
diff --git a/python/src/aqi_attend/attend.py b/python/src/aqi_attend/attend.py
index b610e30..e2eb990 100644
--- a/python/src/aqi_attend/attend.py
+++ b/python/src/aqi_attend/attend.py
@@ -104,6 +104,7 @@ def subscribe(self, cursor: str | None, emit: Callable[[SourceBatch], Awaitable[
_SETTLE_KEYS: dict[str, str] = {
+ "continuation": "continuation",
"closing_grace_ms": "closingGraceMs",
"stream_gap_ms": "streamGapMs",
"passive_quiet_ms": "passiveQuietMs",
@@ -131,6 +132,8 @@ def settle_policy(settle: Mapping[str, Any] | None = None) -> SettlePolicy:
key = _SETTLE_KEYS.get(name)
if key is None:
raise TypeError(f"attend: unknown settle option {name!r}")
+ if name == "continuation" and (not isinstance(value, str) or value not in ("separate", "accumulate")):
+ raise ValueError("attend: continuation must be separate or accumulate")
policy[key] = list(value) if name == "retry_backoff_ms" else value
return cast(SettlePolicy, policy)
diff --git a/python/src/aqi_attend/core/reducer.py b/python/src/aqi_attend/core/reducer.py
index cf3007c..a22b035 100644
--- a/python/src/aqi_attend/core/reducer.py
+++ b/python/src/aqi_attend/core/reducer.py
@@ -37,6 +37,7 @@
)
from .window import (
estimate_rendered_bytes,
+ observation_time,
open_window,
shed_entries,
window_append,
@@ -45,7 +46,7 @@
window_shed,
)
-REDUCER_VERSION = 3
+REDUCER_VERSION = 4
"""Bumped whenever a release changes a transition. Stored with every snapshot."""
_LANES: tuple[OutboxLane, OutboxLane] = ("decisions", "deadLetters")
@@ -239,6 +240,36 @@ def _ingest(ctx: _Ctx, state: ScopeState, input: EventsInput) -> None:
ctx.trace({"kind": "ingested", "scope": state.scope, "count": len(input["events"]) - duplicates, "duplicates": duplicates})
+def _continuation_entries(policy: SettlePolicy, state: ScopeState) -> list[Entry]:
+ entries = [*(state.batch.window["events"] if state.batch is not None else []), *state.open.entries]
+ shed_entries(entries, policy["maxEvents"])
+ return entries
+
+
+def _size_bound(policy: SettlePolicy, entries: list[Entry]) -> SettleReason | None:
+ if not entries:
+ return None
+ if len(entries) > policy["maxEvents"]:
+ return "overflow"
+ limit = policy.get("maxWindowBytes")
+ if limit is not None and sum(estimate_rendered_bytes(entry) for entry in entries) >= limit:
+ return "size"
+ return None
+
+
+def _age_deadline(policy: SettlePolicy, entries: list[Entry]) -> float | None:
+ times = [observation_time(entry) for entry in entries if entry["kind"] not in ("context", "consequence")]
+ return min(times) + policy["maxWindowMs"] if times else None
+
+
+def _window_bound(policy: SettlePolicy, entries: list[Entry], now: float) -> SettleReason | None:
+ size = _size_bound(policy, entries)
+ if size is not None:
+ return size
+ age = _age_deadline(policy, entries)
+ return "age" if age is not None and age <= now else None
+
+
def next_due(policy: SettlePolicy, state: ScopeState) -> float | None:
"""The instant the state next wants a tick: the batch's time, the open window's deadline unless judging, and each lane head's time."""
at: float | None = None
@@ -250,10 +281,20 @@ def next_due(policy: SettlePolicy, state: ScopeState) -> float | None:
at = phase["until"]
else:
at = phase["at"]
- if phase is None or phase["phase"] != "judging":
+ accumulating = policy.get("continuation") == "accumulate"
+ if (phase is None or phase["phase"] != "judging") and not (accumulating and phase is not None and phase["phase"] == "retrying"):
due = window_deadline(policy, state.open)
if due is not None:
at = due[0] if at is None else _min(at, due[0])
+ if accumulating and phase is not None and phase["phase"] == "waiting":
+ entries = _continuation_entries(policy, state)
+ age = _age_deadline(policy, entries)
+ if age is not None:
+ at = age if at is None else _min(at, age)
+ if _size_bound(policy, entries) is not None:
+ # Count and byte triggers use admission time, as the open-window triggers do.
+ due_at = entries[-1]["seenAt"]
+ at = due_at if at is None else _min(at, due_at)
for queue in (state.decisions, state.dead_letters):
if queue:
head = queue[0]["phase"]
@@ -275,6 +316,19 @@ def _sweep(ctx: _Ctx, state: ScopeState) -> None:
for lane in _LANES:
_pump_lane(ctx, state, lane)
_prune(ctx, state)
+ held = state.batch
+ if ctx.config.policy.get("continuation") == "accumulate" and held is not None:
+ phase = held.phase
+ if phase["phase"] == "retrying":
+ if phase["at"] <= ctx.now:
+ reason = "closing" if state.open.ended_at is not None else held.window["reason"]
+ _settle_buffer(ctx, state, reason, phase["offerWait"])
+ return
+ if phase["phase"] == "waiting":
+ bound = _window_bound(ctx.config.policy, _continuation_entries(ctx.config.policy, state), ctx.now)
+ if bound is not None:
+ _settle_buffer(ctx, state, bound, False)
+ return
if state.batch is None or state.batch.phase["phase"] != "judging":
due = window_deadline(ctx.config.policy, state.open)
if due is not None and not (due[0] > ctx.now):
@@ -286,10 +340,11 @@ def _sweep(ctx: _Ctx, state: ScopeState) -> None:
if phase["phase"] == "retrying" and phase["at"] <= ctx.now:
_begin_judging(ctx, state, held.window, phase["attempt"], phase["failures"], phase["offerWait"], held.hash)
elif phase["phase"] == "waiting" and phase["until"] <= ctx.now:
- if not state.open.entries:
- _begin_judging(ctx, state, held.window, phase["attempt"], 0, False, held.hash)
+ offer_wait = ctx.config.policy.get("continuation") == "accumulate" and held.window["waits"] < ctx.config.policy["maxWaits"]
+ if not state.open.entries and ctx.config.policy.get("continuation") != "accumulate":
+ _begin_judging(ctx, state, held.window, phase["attempt"], phase.get("failures", 0), offer_wait, held.hash)
else:
- _settle_buffer(ctx, state, held.window["reason"], False)
+ _settle_buffer(ctx, state, held.window["reason"], offer_wait)
def _settle_reason(events: list[Entry], forced: bool, fired: SettleReason) -> SettleReason:
@@ -308,9 +363,16 @@ def _settle_buffer(ctx: _Ctx, state: ScopeState, fired: SettleReason, may_wait:
open.forced_at = None
ctx.out.changed = True
if held is not None:
- window = cast(Window, {**held.window, "reason": _settle_reason(held.window["events"], forced, held.window["reason"])})
+ accumulating = ctx.config.policy.get("continuation") == "accumulate"
+ reason = fired if accumulating else held.window["reason"]
+ window = cast(Window, {**held.window, "reason": _settle_reason(held.window["events"], forced, reason)})
+ if accumulating:
+ window["gap"] = held.window["gap"] or open.gap
+ window["dropped"] = held.window["dropped"] + open.dropped
+ state.open = open_window(state.scope)
attempt, failures = _counters(held)
- _begin_judging(ctx, state, window, attempt, failures, False, held.hash)
+ offer = accumulating and may_wait and window["reason"] not in ("flush", "forced") and window["waits"] < ctx.config.policy["maxWaits"]
+ _begin_judging(ctx, state, window, attempt, failures, offer, held.hash)
return
events = [*held.window["events"], *entries] if held is not None else entries
dropped = open.dropped + (held.window["dropped"] if held is not None else 0)
@@ -341,10 +403,12 @@ def _settle_buffer(ctx: _Ctx, state: ScopeState, fired: SettleReason, may_wait:
def _counters(held: HeldBatch) -> tuple[int, int]:
phase = held.phase
- return phase["attempt"], (0 if phase["phase"] == "waiting" else phase["failures"])
+ return phase["attempt"], phase.get("failures", 0)
def _begin_judging(ctx: _Ctx, state: ScopeState, window: Window, prior_attempt: int, failures: int, offer_wait: bool, hash: FnvState | None) -> None:
+ if ctx.config.policy.get("continuation") == "accumulate":
+ offer_wait = offer_wait and _window_bound(ctx.config.policy, window["events"], ctx.now) is None and window["reason"] not in ("age", "overflow", "size")
attempt = prior_attempt + 1
lease_until = ctx.now + ctx.config.policy["judgeTimeoutMs"] * 2
state.batch = HeldBatch(window, {"phase": "judging", "attempt": attempt, "failures": failures, "leaseUntil": lease_until, "offerWait": offer_wait}, hash)
@@ -407,6 +471,8 @@ def _on_judged(ctx: _Ctx, state: ScopeState, input: JudgedInput) -> None:
until = ctx.now + ctx.config.policy["waitHorizonMs"]
waits = window["waits"] + 1
state.batch = HeldBatch(cast(Window, {**window, "waits": waits}), {"phase": "waiting", "attempt": phase["attempt"], "until": until}, b.hash)
+ if ctx.config.policy.get("continuation") == "accumulate":
+ state.batch.phase["failures"] = phase["failures"]
ctx.trace({"kind": "waiting", "scope": state.scope, "batchId": window["id"], "waits": waits, "until": until})
return
decided: DecidedRoute = route
diff --git a/python/src/aqi_attend/core/state.py b/python/src/aqi_attend/core/state.py
index 0cda789..ddbe665 100644
--- a/python/src/aqi_attend/core/state.py
+++ b/python/src/aqi_attend/core/state.py
@@ -18,6 +18,8 @@ def initial_state(scope: str) -> ScopeState:
def from_record(record: ScopeRecord, policy: SettlePolicy) -> ScopeState:
"""Builds owned state from a snapshot. Copies every list it will mutate and never mutates ``record``."""
held = record["batch"]
+ if policy.get("continuation") == "accumulate" and held is not None and held["phase"]["phase"] == "waiting" and "failures" not in held["phase"]:
+ raise ValueError("attend: accumulating waiting state requires failures")
scope = record["scope"]
buffer = record["buffer"]
seen, known = seen_from(
diff --git a/python/src/aqi_attend/core/types.py b/python/src/aqi_attend/core/types.py
index a0ec2ca..00aa8de 100644
--- a/python/src/aqi_attend/core/types.py
+++ b/python/src/aqi_attend/core/types.py
@@ -50,6 +50,7 @@ class Entry(KindedEvent):
class SettlePolicy(TypedDict):
"""Round starting points, not tuned values. Every number is in ms unless it is a count."""
+ continuation: NotRequired[Literal["separate", "accumulate"]]
closingGraceMs: float
streamGapMs: float
passiveQuietMs: float
@@ -123,6 +124,7 @@ class JudgingPhase(TypedDict):
class WaitingPhase(TypedDict):
+ failures: NotRequired[int]
phase: Literal["waiting"]
attempt: int
until: float
diff --git a/python/src/aqi_attend/shell/scope.py b/python/src/aqi_attend/shell/scope.py
index a59ae91..7a42f88 100644
--- a/python/src/aqi_attend/shell/scope.py
+++ b/python/src/aqi_attend/shell/scope.py
@@ -189,9 +189,12 @@ async def _load_now(self, slot: ScopeSlot) -> None:
try:
stored = await self._store.load(slot.scope)
slot.state = initial_state(slot.scope) if stored is None else replay(slot.scope, stored, config.decisions, config.dead_letters)
+ snapshot = stored["snapshot"] if stored is not None else None
+ prior_mode = snapshot["policy"].get("continuation", "separate") if snapshot is not None else "separate"
+ if stored is not None and prior_mode != config.policy.get("continuation", "separate") and (slot.state.batch is not None or slot.state.open.entries):
+ raise ValueError("attend: cannot change continuation while a window is unresolved")
slot.tail_count = len(stored["tail"]) if stored is not None else 0
slot.tail_bytes = sum(self._input_bytes(logged) for logged in stored["tail"]) if stored is not None else 0
- snapshot = stored["snapshot"] if stored is not None else None
slot.snapshot_bytes = self._bytes(snapshot["record"]) if snapshot is not None else 0
slot.snapshot_needed = snapshot is None
slot.force_write = False
diff --git a/python/tests/interop/attend-ts.mjs b/python/tests/interop/attend-ts.mjs
index f51d4d7..7198cef 100644
--- a/python/tests/interop/attend-ts.mjs
+++ b/python/tests/interop/attend-ts.mjs
@@ -3,28 +3,14 @@
import { createAttend } from '../../../dist/index.js';
import { openIntake } from '../../../dist/intake.js';
import { fakeClock } from '../../../dist/testing.js';
+import { openStore } from './store.mjs';
const [kind, url, prefix, mode, scope] = process.argv.slice(2);
const kinds = { close: 'closing', say: 'flush', look: 'passive', out: 'consequence', move: 'continuous' };
const judge = async ({ window, routes }) => ({ route: window.events.some((e) => e.name === 'look') && routes.some((r) => r.route === 'wait') ? 'wait' : 'interrupt' });
const delivered = [];
-let store;
-let close = async () => {};
-if (kind === 'redis') {
- const { createClient } = await import('redis');
- const { redisStore } = await import('../../../dist/redis.js');
- const client = createClient({ url });
- await client.connect();
- store = redisStore((args) => client.sendCommand(args), { prefix });
- close = () => client.close();
-} else {
- const pg = (await import('pg')).default;
- const { postgresStore } = await import('../../../dist/postgres.js');
- const pool = new pg.Pool({ connectionString: url, max: 2 });
- store = postgresStore(pool, { prefix });
- close = () => pool.end();
-}
+const { store, close } = await openStore(kind, url, prefix);
const clock = fakeClock(10_000);
const attend = createAttend({ store, clock, kind: kinds, judge, sink: (d) => { delivered.push(d.id); }, settle: { closingGraceMs: 100 } });
@@ -57,6 +43,5 @@ controller.abort();
await running;
const record = await attend.inspect(scope);
const { rows } = await store.log.read({ after: null, scope, limit: 100 });
-await store.close?.();
await close();
process.stdout.write(JSON.stringify({ record, rows, delivered }));
diff --git a/python/tests/interop/continuation-ts.mjs b/python/tests/interop/continuation-ts.mjs
new file mode 100644
index 0000000..535fa8d
--- /dev/null
+++ b/python/tests/interop/continuation-ts.mjs
@@ -0,0 +1,42 @@
+import { createAttend } from '../../../dist/index.js';
+import { openIntake } from '../../../dist/intake.js';
+import { fakeClock } from '../../../dist/testing.js';
+import { openStore } from './store.mjs';
+
+const [kind, url, prefix, mode, scope] = process.argv.slice(2);
+const { store, close } = await openStore(kind, url, prefix);
+const baseClock = fakeClock(10_000);
+const retrying = Promise.withResolvers(), waiting = Promise.withResolvers(), armed = Promise.withResolvers(), delivered = Promise.withResolvers();
+const calls = [], retries = [], deliveries = [];
+const clock = { now: baseClock.now, at(at, fn) { const cancel = baseClock.at(at, fn); if (at === 10_060) armed.resolve(); return cancel; } };
+const engine = createAttend({ store, clock, kind: { reading: 'continuous' },
+ settle: { continuation: 'accumulate', streamGapMs: 10, waitHorizonMs: 20, retryBackoffMs: [30, 60] },
+ observe(trace) {
+ if (trace.kind === 'retrying' && trace.stage === 'judge') { retries.push(trace.at); retrying.resolve(); }
+ if (trace.kind === 'waiting') waiting.resolve();
+ if (trace.kind === 'delivered') delivered.resolve();
+ },
+ judge: async (input) => {
+ calls.push({ at: clock.now(), waits: input.window.waits });
+ if (calls.length === 1) throw new Error('controlled outage');
+ return { route: mode === 'write' ? 'wait' : 'queue' };
+ },
+ sink: async (decision) => { deliveries.push(decision.id); },
+});
+const intake = openIntake(engine, scope), running = engine.run();
+try {
+ if (mode === 'write') {
+ await intake.submit(async () => ({ events: [{ id: 'a', name: 'reading', at: 10_000, data: {}, text: 'x'.repeat(1000) }], cursor: '1' }), { source: 'feed' });
+ await baseClock.advance(10); await retrying.promise;
+ await baseClock.advance(30); await waiting.promise;
+ } else {
+ await armed.promise;
+ await baseClock.advance(60); await retrying.promise;
+ await baseClock.advance(60); await delivered.promise;
+ }
+} finally {
+ await intake.close(); await engine.stop(); await running;
+}
+try {
+ process.stdout.write(JSON.stringify({ record: await engine.inspect(scope), calls, retries, deliveries }));
+} finally { await close(); }
diff --git a/python/tests/interop/store.mjs b/python/tests/interop/store.mjs
new file mode 100644
index 0000000..31b1510
--- /dev/null
+++ b/python/tests/interop/store.mjs
@@ -0,0 +1,15 @@
+export async function openStore(kind, url, prefix) {
+ if (kind === 'redis') {
+ const { createClient } = await import('redis');
+ const { redisStore } = await import('../../../dist/redis.js');
+ const client = createClient({ url });
+ await client.connect();
+ const store = redisStore((args) => client.sendCommand(args), { prefix });
+ return { store, async close() { await store.close?.(); await client.close(); } };
+ }
+ const pg = (await import('pg')).default;
+ const { postgresStore } = await import('../../../dist/postgres.js');
+ const pool = new pg.Pool({ connectionString: url, max: 2 });
+ const store = postgresStore(pool, { prefix });
+ return { store, async close() { await store.close?.(); await pool.end(); } };
+}
diff --git a/python/tests/scenario.py b/python/tests/scenario.py
index 68eece7..bfa22a0 100644
--- a/python/tests/scenario.py
+++ b/python/tests/scenario.py
@@ -31,6 +31,7 @@ def event_spec(spec: Mapping[str, Any]) -> Event:
_SETTLE = {
+ "continuation": "continuation",
"closingGraceMs": "closing_grace_ms",
"streamGapMs": "stream_gap_ms",
"passiveQuietMs": "passive_quiet_ms",
@@ -270,6 +271,8 @@ async def result(index: int, work: asyncio.Future[None]) -> None:
source_batch: SourceBatch = {"events": events}
if "cursor" in step:
source_batch["cursor"] = step["cursor"]
+ if step.get("truncated"):
+ source_batch["truncated"] = True
async def prepare(
signal: AbortSignal, batch: SourceBatch = source_batch, delay: float = step.get("prepareMs", 0), fail: str | None = step.get("prepareFail")
diff --git a/python/tests/test_continuation.py b/python/tests/test_continuation.py
new file mode 100644
index 0000000..db90148
--- /dev/null
+++ b/python/tests/test_continuation.py
@@ -0,0 +1,417 @@
+"""An opted-in unresolved window retains data and counters through waits/retries."""
+
+import asyncio
+import json
+from collections.abc import AsyncGenerator, Awaitable, Callable
+from contextlib import asynccontextmanager
+from pathlib import Path
+from typing import Any, Literal, TypedDict
+
+import pytest
+
+from aqi_attend import AbortSignal, Event, JudgeInput, Judgment, SourceBatch, create_attend, memory_store
+from aqi_attend.attend import Attend
+from aqi_attend.core.state import from_record
+from aqi_attend.core.types import default_policy
+from aqi_attend.testing import FakeClock, fake_clock, scripted_judge
+
+type Answer = Literal["wait", "queue", "fail"]
+
+
+class Offer(TypedDict):
+ at: float
+ ids: list[str]
+ wait: bool
+ waits: int
+
+
+def event(id: str, observed: float, quiet: float = 10) -> Event:
+ return {"id": id, "at": observed, "observedAt": observed, "quietForMs": quiet, "name": "reading", "text": "q" * 20, "data": {}}
+
+
+@asynccontextmanager
+async def run(
+ answers: list[Answer], *, settle: dict[str, Any] | None = None, start: float = 0
+) -> AsyncGenerator[tuple[FakeClock, Callable[[list[Event]], Awaitable[None]], list[Offer]], None]:
+ clock = fake_clock(start)
+ calls: list[Offer] = []
+
+ async def judge(input: JudgeInput, signal: AbortSignal) -> Judgment:
+ calls.append(
+ Offer(at=clock.now(), ids=[e["id"] for e in input["window"]["events"]], wait=any(r["route"] == "wait" for r in input["routes"]), waits=input["window"]["waits"])
+ )
+ answer = answers[len(calls) - 1] if len(calls) <= len(answers) else "queue"
+ if answer == "fail":
+ raise RuntimeError("controlled outage")
+ return {"route": answer}
+
+ attend = create_attend(
+ clock=clock,
+ kind={"reading": "continuous"},
+ judge=judge,
+ sink="log",
+ settle={"continuation": "accumulate", "stream_gap_ms": 10, "wait_horizon_ms": 20, "max_waits": 2, "retry_backoff_ms": [30, 60], **(settle or {})},
+ )
+ intake = attend.open_intake("s")
+ running = asyncio.create_task(attend.run())
+
+ async def put(events: list[Event]) -> None:
+ async def prepare(signal: AbortSignal) -> SourceBatch:
+ return {"events": events}
+
+ await intake.submit(prepare)
+
+ try:
+ yield clock, put, calls
+ finally:
+ await intake.close()
+ await attend.stop()
+ await running
+
+
+async def test_horizon_reoffers_until_wait_allowance_is_used() -> None:
+ async with run(["wait", "wait", "queue"]) as (clock, put, calls):
+ await put([event("a", 0)])
+ await clock.advance(50)
+ assert calls == [
+ {"at": 10, "ids": ["a"], "wait": True, "waits": 0},
+ {"at": 30, "ids": ["a"], "wait": True, "waits": 1},
+ {"at": 50, "ids": ["a"], "wait": False, "waits": 2},
+ ]
+
+
+async def test_horizon_absorbs_fresh_before_quiet() -> None:
+ async with run(["wait", "wait", "queue"]) as (clock, put, calls):
+ await put([event("a", 0)])
+ await clock.advance(25)
+ await put([event("b", 25, 100)])
+ await clock.advance(25)
+ assert calls == [
+ {"at": 10, "ids": ["a"], "wait": True, "waits": 0},
+ {"at": 30, "ids": ["a", "b"], "wait": True, "waits": 1},
+ {"at": 50, "ids": ["a", "b"], "wait": False, "waits": 2},
+ ]
+
+
+@pytest.mark.parametrize("quiet", [10, 100])
+async def test_retry_absorbs_fresh_at_not_before(quiet: float) -> None:
+ async with run(["fail", "queue"]) as (clock, put, calls):
+ await put([event("a", 0)])
+ await clock.advance(15)
+ await put([event("b", 15, quiet)])
+ await clock.advance(24)
+ assert len(calls) == 1
+ await clock.advance(1)
+ assert calls == [{"at": 10, "ids": ["a"], "wait": True, "waits": 0}, {"at": 40, "ids": ["a", "b"], "wait": True, "waits": 0}]
+
+
+async def test_wait_retains_provider_failure_allowance() -> None:
+ async with run(["fail", "wait", "fail", "queue"]) as (clock, put, calls):
+ await put([event("a", 0)])
+ await clock.advance(120)
+ assert [c["at"] for c in calls] == [10, 40, 60, 120]
+ assert [c["waits"] for c in calls] == [0, 0, 1, 1]
+
+
+@pytest.mark.parametrize("fresh", [1, 2])
+async def test_merged_count_evaluates_all_entries(fresh: int) -> None:
+ async with run(["fail", "queue"], settle={"max_events": 2}) as (clock, put, calls):
+ await put([event("a", 0)])
+ await clock.advance(15)
+ await put([event(f"b{i}", 15, 100) for i in range(fresh)])
+ await clock.advance(25)
+ assert calls[1] == {"at": 40, "ids": ["a", *[f"b{i}" for i in range(fresh)]], "wait": fresh == 1, "waits": 0}
+
+
+async def test_age_withholds_wait_at_initial_quiet_tie() -> None:
+ async with run(["queue"], settle={"max_window_ms": 10}) as (clock, put, calls):
+ await put([event("a", 0)])
+ await clock.advance(10)
+ assert calls == [{"at": 10, "ids": ["a"], "wait": False, "waits": 0}]
+
+
+async def test_older_absorbed_observation_participates_in_age() -> None:
+ async with run(["fail", "queue"], settle={"max_window_ms": 100}, start=100) as (clock, put, calls):
+ await put([event("a", 100)])
+ await clock.advance(20)
+ await put([event("b", 0, 1000)])
+ assert len(calls) == 1
+ await clock.advance(20)
+ assert calls[1] == {"at": 140, "ids": ["a", "b"], "wait": False, "waits": 0}
+
+
+@pytest.mark.parametrize("answer", ["wait", "fail"])
+async def test_combined_byte_threshold(answer: Answer) -> None:
+ async with run([answer, "queue"], settle={"max_window_bytes": 100}) as (clock, put, calls):
+ await put([event("a", 0)])
+ await clock.advance(15)
+ await put([event("b", 15, 100)])
+ if answer == "fail":
+ assert len(calls) == 1
+ await clock.advance(25)
+ assert calls[1] == {"at": 15 if answer == "wait" else 40, "ids": ["a", "b"], "wait": False, "waits": 1 if answer == "wait" else 0}
+
+
+@pytest.mark.parametrize("before_mode", ["separate", "accumulate"])
+async def test_cannot_change_continuation_with_open_window(before_mode: str) -> None:
+ store, clock = memory_store(), fake_clock()
+ previous = create_attend(store=store, clock=clock, kind={"reading": "continuous"}, judge=scripted_judge([{"route": "queue"}]), sink="log", settle={"continuation": before_mode})
+ await previous.push("s", event("a", 0))
+ before = await previous.inspect("s")
+ next_engine = create_attend(
+ store=store,
+ clock=clock,
+ kind={"reading": "continuous"},
+ judge=scripted_judge([{"route": "queue"}]),
+ sink="log",
+ settle={"continuation": "accumulate" if before_mode == "separate" else "separate"},
+ )
+ with pytest.raises(ValueError, match="continuation"):
+ await next_engine.push("s", event("b", 0))
+ assert await next_engine.inspect("s") == before
+
+
+@pytest.mark.parametrize("value", [None, False, 0, "other"])
+def test_refuses_invalid_continuation(value: object) -> None:
+ with pytest.raises(ValueError, match="continuation"):
+ create_attend(kind={}, judge=scripted_judge([]), sink="log", settle={"continuation": value})
+
+
+LEGACY: dict[str, Any] = json.loads((Path(__file__).parents[2] / "conformance/fixtures/continuation-legacy.json").read_text())
+
+
+@pytest.mark.parametrize("control", ["flush", "end", "held-end"])
+async def test_explicit_control_retains_meaning_at_retry(control: str) -> None:
+ clock = fake_clock()
+ calls: list[tuple[float, str, bool]] = []
+
+ async def judge(input: JudgeInput, signal: AbortSignal) -> Judgment:
+ calls.append((clock.now(), input["window"]["reason"], any(r["route"] == "wait" for r in input["routes"])))
+ if len(calls) == 1:
+ raise RuntimeError("controlled outage")
+ return {"route": "queue"}
+
+ engine = create_attend(clock=clock, kind={"reading": "continuous"}, sink="log", judge=judge, settle={"continuation": "accumulate", "retry_backoff_ms": [30]})
+ running = asyncio.create_task(engine.run())
+ try:
+ await engine.push("s", event("a", 0))
+ await clock.advance(15)
+ if control == "end":
+ await engine.push("s", event("b", 15, 100))
+ finish = engine.flush if control == "flush" else engine.end
+ await finish("s")
+ await clock.advance(24)
+ assert len(calls) == 1
+ await clock.advance(1)
+ reason = "forced" if control == "flush" else "closing" if control == "end" else "stream_quiet"
+ assert calls[1] == (40, reason, control != "flush")
+ record = await engine.inspect("s")
+ assert record is not None and record["buffer"]["forcedAt"] is None
+ finally:
+ await engine.stop()
+ await running
+
+
+@pytest.mark.parametrize("item", LEGACY["cases"], ids=[item["name"] for item in LEGACY["cases"]])
+async def test_revision_three_read_and_mode_boundary(item: dict[str, Any]) -> None:
+ store, clock = memory_store(), fake_clock(item["through"])
+ for writes in item["writes"]:
+ assert await store.commit(writes) == ["ok"] * len(writes)
+ assert await store.load("scope") == item["stored"]
+ engine = create_attend(store=store, clock=clock, kind={"reading": "continuous"}, judge=scripted_judge([{"route": "queue"}]), sink="log", settle={"continuation": "accumulate"})
+ assert await engine.inspect("scope") == item["expected"]
+ pending = engine.push("scope", event("b", item["through"]))
+ if item["name"] == "complete":
+ await pending
+ stored = await store.load("scope")
+ assert stored is not None and stored["snapshot"] is not None
+ assert stored["snapshot"]["policy"].get("continuation") == "accumulate"
+ assert stored["snapshot"]["reducer"] == 4
+ record = await engine.inspect("scope")
+ assert record is not None and record["recent"] == item["expected"]["recent"]
+ else:
+ with pytest.raises(ValueError, match="continuation"):
+ await pending
+ assert await store.load("scope") == item["stored"]
+
+
+@pytest.mark.parametrize("cadence", ["ratio", "always"])
+async def test_failure_budget_survives_waiting_restart(cadence: Literal["ratio", "always"]) -> None:
+ store, clock = memory_store(), fake_clock()
+ first_calls = 0
+ resumed_calls: list[float] = []
+ settle = {"continuation": "accumulate", "stream_gap_ms": 10, "wait_horizon_ms": 20, "retry_backoff_ms": [30, 60]}
+
+ async def first_judge(input: JudgeInput, signal: AbortSignal) -> Judgment:
+ nonlocal first_calls
+ first_calls += 1
+ if first_calls == 1:
+ raise RuntimeError("outage")
+ return {"route": "wait"}
+
+ async def next_judge(input: JudgeInput, signal: AbortSignal) -> Judgment:
+ resumed_calls.append(clock.now())
+ if len(resumed_calls) == 1:
+ raise RuntimeError("outage")
+ return {"route": "queue"}
+
+ first = Attend(store=store, clock=clock, kind={"reading": "continuous"}, sink="log", judge=first_judge, settle=settle, snapshot=cadence)
+ intake = first.open_intake("s")
+ running = asyncio.create_task(first.run())
+
+ async def prepare(signal: AbortSignal) -> SourceBatch:
+ return {"events": [event("a", 0)]}
+
+ await intake.submit(prepare)
+ await clock.advance(40)
+ record = await first.inspect("s")
+ assert record is not None and record["batch"] is not None
+ assert record["batch"]["phase"]["phase"] == "waiting" and record["batch"]["phase"].get("failures") == 1
+ await intake.close()
+ await first.stop()
+ await running
+ resumed = create_attend(store=store, clock=clock, kind={"reading": "continuous"}, sink="log", judge=next_judge, settle=settle)
+ next_intake = resumed.open_intake("s")
+ next_run = asyncio.create_task(resumed.run())
+ try:
+ await clock.advance(0)
+ assert clock.next_at() == 60
+ await clock.advance(80)
+ assert resumed_calls == [60, 120]
+ record = await resumed.inspect("s")
+ assert record is not None and record["batch"] is None
+ finally:
+ await next_intake.close()
+ await resumed.stop()
+ await next_run
+
+
+def test_accumulating_snapshot_requires_waiting_failure_count() -> None:
+ waiting = next(item for item in LEGACY["cases"] if item["name"] == "waiting-snapshot")
+ policy = default_policy()
+ policy["continuation"] = "accumulate"
+ with pytest.raises(ValueError, match="requires failures"):
+ from_record(waiting["expected"], policy)
+
+
+async def test_exhaustion_after_wait_keeps_native_dead_letter() -> None:
+ store, clock = memory_store(), fake_clock()
+ judge = scripted_judge([{"fail": "outage"}, {"route": "wait"}, {"fail": "outage"}, {"fail": "outage"}])
+ engine = create_attend(
+ store=store,
+ clock=clock,
+ kind={"reading": "continuous"},
+ judge=judge,
+ sink="log",
+ settle={"continuation": "accumulate", "wait_horizon_ms": 20, "retry_backoff_ms": [30, 60]},
+ )
+ intake = engine.open_intake("s")
+ running = asyncio.create_task(engine.run())
+
+ async def prepare(signal: AbortSignal) -> SourceBatch:
+ return {"events": [event("a", 0)]}
+
+ try:
+ await intake.submit(prepare)
+ await clock.advance(120)
+ page = await store.log.read({"after": None, "scope": "s", "limit": 10})
+ assert len(page["rows"]) == 1
+ row = page["rows"][0]
+ assert row["kind"] == "deadLetter" and row["at"] == 120
+ assert row["body"]["stage"] == "judge" and row["body"]["attempts"] == 4 and row["body"]["window"]["waits"] == 1
+ record = await engine.inspect("s")
+ assert record is not None and record["batch"] is None
+ finally:
+ await intake.close()
+ await engine.stop()
+ await running
+
+
+@pytest.mark.parametrize("limit", [134, 135])
+async def test_whole_window_byte_threshold(limit: int) -> None:
+ async with run(["wait", "queue"], settle={"max_window_bytes": limit}) as (clock, put, calls):
+ await put([event("a", 0)])
+ await clock.advance(15)
+ await put([event("b", 15, 100)])
+ await clock.advance(15)
+ assert calls[1] == {"at": 15 if limit == 134 else 30, "ids": ["a", "b"], "wait": limit == 135, "waits": 1}
+
+
+@pytest.mark.parametrize("metadata", ["gap", "dropped"])
+async def test_empty_fresh_metadata_belongs_to_unresolved_retry(metadata: str) -> None:
+ clock = fake_clock()
+ calls: list[tuple[list[str], bool, int]] = []
+
+ async def judge(input: JudgeInput, signal: AbortSignal) -> Judgment:
+ window = input["window"]
+ calls.append(([e["id"] for e in window["events"]], window["gap"], window["dropped"]))
+ if len(calls) == 1:
+ raise RuntimeError("outage")
+ return {"route": "queue"}
+
+ engine = create_attend(
+ clock=clock,
+ kind={"reading": "continuous", "out": "consequence"},
+ judge=judge,
+ sink="log",
+ settle={"continuation": "accumulate", "max_window_ms": 100, "retry_backoff_ms": [30]},
+ )
+ intake = engine.open_intake("s")
+ running = asyncio.create_task(engine.run())
+
+ async def first(signal: AbortSignal) -> SourceBatch:
+ return {"events": [event("a", 0)]}
+
+ async def loss(signal: AbortSignal) -> SourceBatch:
+ return (
+ {"events": [], "truncated": True, "cursor": "2"}
+ if metadata == "gap"
+ else {"events": [{"id": "old", "at": -100, "observedAt": -100, "name": "out", "data": {}}], "cursor": "2"}
+ )
+
+ async def later(signal: AbortSignal) -> SourceBatch:
+ return {"events": [event("next", 40)]}
+
+ try:
+ await intake.submit(first)
+ await clock.advance(15)
+ await intake.submit(loss, source="feed")
+ await clock.advance(25)
+ assert calls[1] == (["a"], metadata == "gap", 1 if metadata == "dropped" else 0)
+ record = await engine.inspect("s")
+ assert record is not None and record["buffer"] == {"entries": [], "gap": False, "dropped": 0, "forcedAt": None}
+ assert record["cursors"] == {"feed": "2"}
+ await intake.submit(later)
+ await clock.advance(10)
+ assert calls[2] == (["next"], False, 0)
+ finally:
+ await intake.close()
+ await engine.stop()
+ await running
+
+
+async def test_gap_at_horizon_retains_wait_allowance() -> None:
+ clock, judge = fake_clock(), scripted_judge([{"route": "wait"}, {"route": "queue"}])
+ engine = create_attend(clock=clock, kind={"reading": "continuous"}, judge=judge, sink="log", settle={"continuation": "accumulate", "wait_horizon_ms": 20})
+ intake = engine.open_intake("s")
+ running = asyncio.create_task(engine.run())
+
+ async def first(signal: AbortSignal) -> SourceBatch:
+ return {"events": [event("a", 0)]}
+
+ async def gap(signal: AbortSignal) -> SourceBatch:
+ return {"events": [], "truncated": True}
+
+ try:
+ await intake.submit(first)
+ await clock.advance(15)
+ await intake.submit(gap)
+ await clock.advance(15)
+ assert judge.calls[1]["window"]["gap"]
+ assert any(r["route"] == "wait" for r in judge.calls[1]["routes"])
+ record = await engine.inspect("s")
+ assert record is not None and not record["buffer"]["gap"]
+ finally:
+ await intake.close()
+ await engine.stop()
+ await running
diff --git a/python/tests/test_continuation_interop.py b/python/tests/test_continuation_interop.py
new file mode 100644
index 0000000..64a4813
--- /dev/null
+++ b/python/tests/test_continuation_interop.py
@@ -0,0 +1,125 @@
+"""A failed-then-waiting window retains its next backoff across runtime changes."""
+
+import asyncio
+import json
+from collections.abc import Callable
+from pathlib import Path
+from typing import Any
+
+import pytest
+
+from aqi_attend import AbortSignal, Decision, JudgeInput, Judgment, SourceBatch, Trace, create_attend, window_id
+from aqi_attend.testing import fake_clock
+
+from .stores import POSTGRES_URL, REDIS_URL, make_postgres, make_redis
+from .test_interop import BACKENDS, ENABLED
+
+SCRIPT = Path(__file__).with_name("interop") / "continuation-ts.mjs"
+
+
+async def typescript(kind: str, prefix: str, mode: str, scope: str) -> dict[str, Any]:
+ url = REDIS_URL if kind == "redis" else POSTGRES_URL
+ assert url is not None
+ process = await asyncio.create_subprocess_exec("node", str(SCRIPT), kind, url, prefix, mode, scope, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE)
+ try:
+ out, err = await process.communicate()
+ assert process.returncode == 0, err.decode()
+ return json.loads(out)
+ finally:
+ if process.returncode is None:
+ process.terminate()
+ await process.wait()
+
+
+async def python(store: Any, mode: str, scope: str) -> dict[str, Any]:
+ base = fake_clock(10_000)
+ retrying, waiting, armed, delivered = asyncio.Event(), asyncio.Event(), asyncio.Event(), asyncio.Event()
+ calls: list[dict[str, float | int]] = []
+ retries: list[float] = []
+ deliveries: list[str] = []
+
+ class Clock:
+ def now(self) -> float:
+ return base.now()
+
+ def at(self, at: float, fn: Callable[[], None]) -> Callable[[], None]:
+ cancel = base.at(at, fn)
+ if at == 10_060:
+ armed.set()
+ return cancel
+
+ def observe(trace: Trace) -> None:
+ if trace["kind"] == "retrying" and trace["stage"] == "judge":
+ retries.append(trace["at"])
+ retrying.set()
+ if trace["kind"] == "waiting":
+ waiting.set()
+ if trace["kind"] == "delivered":
+ delivered.set()
+
+ async def judge(input: JudgeInput, signal: AbortSignal) -> Judgment:
+ calls.append({"at": base.now(), "waits": input["window"]["waits"]})
+ if len(calls) == 1:
+ raise RuntimeError("controlled outage")
+ return {"route": "wait" if mode == "write" else "queue"}
+
+ async def sink(decision: Decision, signal: AbortSignal) -> None:
+ deliveries.append(decision["id"])
+
+ engine = create_attend(
+ store=store,
+ clock=Clock(),
+ kind={"reading": "continuous"},
+ judge=judge,
+ sink=sink,
+ observe=observe,
+ settle={"continuation": "accumulate", "stream_gap_ms": 10, "wait_horizon_ms": 20, "retry_backoff_ms": [30, 60]},
+ )
+ intake = engine.open_intake(scope)
+ running = asyncio.create_task(engine.run())
+ try:
+ if mode == "write":
+
+ async def prepare(signal: AbortSignal) -> SourceBatch:
+ return {"events": [{"id": "a", "name": "reading", "at": 10_000, "data": {}, "text": "x" * 1000}], "cursor": "1"}
+
+ await intake.submit(prepare, source="feed")
+ await base.advance(10)
+ await retrying.wait()
+ await base.advance(30)
+ await waiting.wait()
+ else:
+ await armed.wait()
+ await base.advance(60)
+ await retrying.wait()
+ await base.advance(60)
+ await delivered.wait()
+ finally:
+ await intake.close()
+ await engine.stop()
+ await running
+ return {"record": await engine.inspect(scope), "calls": calls, "retries": retries, "deliveries": deliveries}
+
+
+@pytest.mark.skipif(not ENABLED or not BACKENDS, reason="needs ATTEND_INTEROP=1, built dist/, node, and Redis or Postgres")
+@pytest.mark.parametrize("kind", BACKENDS)
+async def test_waiting_failure_allowance_crosses_runtime_boundary(kind: str) -> None:
+ owned = await (make_redis() if kind == "redis" else make_postgres())
+ inner: Any = owned.inner
+ prefix = str(inner._prefix if kind == "redis" else inner.prefix)
+ try:
+ for writer in ("python", "typescript"):
+ scope = "continuation-" + writer
+ written = await (python(owned, "write", scope) if writer == "python" else typescript(kind, prefix, "write", scope))
+ assert written["calls"] == [{"at": 10_010, "waits": 0}, {"at": 10_040, "waits": 0}]
+ assert written["retries"] == [10_040] and not written["deliveries"]
+ assert written["record"]["batch"]["phase"] == {"phase": "waiting", "attempt": 2, "until": 10_060, "failures": 1}
+ continued = await (typescript(kind, prefix, "continue", scope) if writer == "python" else python(owned, "continue", scope))
+ assert continued["retries"] == [10_120]
+ assert continued["calls"] == [{"at": 10_060, "waits": 1}, {"at": 10_120, "waits": 1}]
+ assert continued["deliveries"] == [window_id(scope, ["a"])]
+ assert continued["record"]["batch"] is None
+ assert continued["record"]["outbox"] == {"decisions": [], "deadLetters": []}
+ assert continued["record"]["cursors"] == {"feed": "1"}
+ finally:
+ await owned.close()
diff --git a/python/tests/test_continuous_quiet.py b/python/tests/test_continuous_quiet.py
index 62d3c53..a06e135 100644
--- a/python/tests/test_continuous_quiet.py
+++ b/python/tests/test_continuous_quiet.py
@@ -254,7 +254,7 @@ async def test_revision_two_snapshot_and_mixed_tail_rebuild_end_times() -> None:
assert loaded is not None and loaded["dueAt"] == 200
assert [(event["id"], event.get("quietForMs"), event["seenAt"]) for event in loaded["buffer"]["entries"]] == [("a", None, 100), ("b", 90, 120), ("c", None, 120)]
stored = await store.load("s")
- assert stored is not None and stored["snapshot"] is not None and stored["snapshot"]["reducer"] == 3
+ assert stored is not None and stored["snapshot"] is not None and stored["snapshot"]["reducer"] == 4
finally:
await attend.stop()
await store.close()
diff --git a/python/tests/test_interop.py b/python/tests/test_interop.py
index e2f7fe3..ee12d51 100644
--- a/python/tests/test_interop.py
+++ b/python/tests/test_interop.py
@@ -156,7 +156,7 @@ async def test_intake_snapshot_and_tail_continue_without_intake_in_other_runtime
assert written["record"]["cursors"] == {"feed": "3"}
stored = await owned.load(scope)
assert stored is not None and stored["snapshot"] is not None
- assert stored["snapshot"]["reducer"] == 3 and stored["tail"]
+ assert stored["snapshot"]["reducer"] == 4 and stored["tail"]
encoded = json.dumps(stored)
assert all(field not in encoded for field in ('"catchUp"', '"catch_up"', '"prepare"', '"owner"'))
read = await (typescript(kind, prefix, "read", scope) if writer == "python" else python(owned, "read", scope))
diff --git a/python/tests/test_observation_time.py b/python/tests/test_observation_time.py
index 2aaa10a..6a2f585 100644
--- a/python/tests/test_observation_time.py
+++ b/python/tests/test_observation_time.py
@@ -259,7 +259,7 @@ async def test_prior_reducer_snapshot_and_tail_keep_ingestion_deadlines() -> Non
assert loaded is not None and loaded["dueAt"] == 2100
assert [(event["id"], event["seenAt"], event.get("observedAt")) for event in loaded["buffer"]["entries"]] == [("a", 1000, None), ("b", 1100, None)]
stored = await store.load("s")
- assert stored is not None and stored["snapshot"] is not None and stored["snapshot"]["reducer"] == 3
+ assert stored is not None and stored["snapshot"] is not None and stored["snapshot"]["reducer"] == 4
finally:
await attend.stop()
await store.close()
diff --git a/src/attend.ts b/src/attend.ts
index ce05b9d..d31063b 100644
--- a/src/attend.ts
+++ b/src/attend.ts
@@ -36,6 +36,9 @@ export function createAttendInternal(config: AttendConfig, snapshot: 'ratio' | '
throw new RangeError('attend: judgeConcurrency must be a positive integer');
}
const policy: SettlePolicy = { ...DEFAULT_POLICY, ...config.settle };
+ if (policy.continuation !== undefined && policy.continuation !== 'separate' && policy.continuation !== 'accumulate') {
+ throw new TypeError('attend: continuation must be separate or accumulate');
+ }
if (config.judge.budget) {
const bytes = windowBytesFor(config.judge.budget, share);
if (!Number.isFinite(bytes) || bytes <= 0) throw new RangeError('attend: judge window budget must be positive and finite');
diff --git a/src/core/reducer.ts b/src/core/reducer.ts
index be71838..f9d80a4 100644
--- a/src/core/reducer.ts
+++ b/src/core/reducer.ts
@@ -6,10 +6,10 @@ import type {
import { ROUTES } from './types.js';
import { fnvHex, fnvStart, foldId } from './ids.js';
import { seenAdmit, seenRelease, seenTrim } from './seen.js';
-import { estimateRenderedBytes, openWindow, shedEntries, windowAppend, windowCompact, windowDeadline, windowPrune, windowShed, windowSize } from './window.js';
+import { estimateRenderedBytes, observationTime, openWindow, shedEntries, windowAppend, windowCompact, windowDeadline, windowEntries, windowPrune, windowShed, windowSize } from './window.js';
/** Bumped whenever a release changes a transition. Stored with every snapshot. */
-export const REDUCER_VERSION = 3;
+export const REDUCER_VERSION = 4;
/** An empty output. One output may collect several inputs: `apply` only ever sets `changed`. */
export function newOutput(): ApplyOutput {
@@ -148,15 +148,52 @@ function ingest(ctx: Ctx, state: ScopeState, input: EventsInput): void {
if (ctx.config.traces) ctx.out.effects.push({ kind: 'trace', trace: { kind: 'ingested', scope: state.scope, count: input.events.length - duplicates, duplicates } });
}
-/** The instant the state next wants a tick: the batch's time, the open window's deadline unless judging, and each lane head's time. */
+function continuationEntries(policy: SettlePolicy, state: ScopeState): Entry[] {
+ const entries = [...(state.batch?.window.events ?? []), ...windowEntries(state.open)];
+ shedEntries(entries, policy.maxEvents);
+ return entries;
+}
+
+function sizeBound(policy: SettlePolicy, entries: readonly Entry[]): SettleReason | null {
+ if (entries.length === 0) return null;
+ if (entries.length > policy.maxEvents) return 'overflow';
+ if (policy.maxWindowBytes !== undefined && entries.reduce((bytes, entry) => bytes + estimateRenderedBytes(entry), 0) >= policy.maxWindowBytes) return 'size';
+ return null;
+}
+
+function ageDeadline(policy: SettlePolicy, entries: readonly Entry[]): number | null {
+ let first: number | null = null;
+ for (const entry of entries) if (entry.kind !== 'context' && entry.kind !== 'consequence') {
+ const at = observationTime(entry);
+ first = first === null ? at : Math.min(first, at);
+ }
+ return first === null ? null : first + policy.maxWindowMs;
+}
+
+function windowBound(policy: SettlePolicy, entries: readonly Entry[], now: number): SettleReason | null {
+ const size = sizeBound(policy, entries);
+ if (size !== null) return size;
+ const age = ageDeadline(policy, entries);
+ return age !== null && age <= now ? 'age' : null;
+}
+
+/** The batch, eligible open/combined window, or delivery deadline that next needs a tick. */
export function nextDue(policy: SettlePolicy, state: ScopeState): number | null {
let at: number | null = null;
const phase = state.batch?.phase;
if (phase) at = phase.phase === 'judging' ? phase.leaseUntil : phase.phase === 'waiting' ? phase.until : phase.at;
- if (phase?.phase !== 'judging') {
+ const accumulating = policy.continuation === 'accumulate';
+ if (phase?.phase !== 'judging' && !(accumulating && phase?.phase === 'retrying')) {
const due = windowDeadline(policy, state.open);
if (due) at = at === null ? due.at : Math.min(at, due.at);
}
+ if (accumulating && phase?.phase === 'waiting') {
+ const entries = continuationEntries(policy, state);
+ const age = ageDeadline(policy, entries);
+ if (age !== null) at = at === null ? age : Math.min(at, age);
+ const last = entries.at(-1);
+ if (last && sizeBound(policy, entries) !== null) at = at === null ? last.seenAt : Math.min(at, last.seenAt);
+ }
for (const lane of LANES) {
const head = state.outbox[lane][0]?.phase;
if (head) {
@@ -172,6 +209,20 @@ function sweep(ctx: Ctx, state: ScopeState): void {
if (b && b.phase.phase === 'judging' && b.phase.leaseUntil <= ctx.now) failJudge(ctx, state, { ...b, phase: b.phase }, 'judge lease expired', false);
for (const lane of LANES) pumpLane(ctx, state, lane);
prune(ctx, state);
+ const pending = state.batch;
+ if (ctx.config.policy.continuation === 'accumulate' && pending) {
+ if (pending.phase.phase === 'retrying') {
+ if (pending.phase.at <= ctx.now) {
+ const reason = state.open.endedAt !== null ? 'closing' : pending.window.reason;
+ settleBuffer(ctx, state, reason, pending.phase.offerWait);
+ }
+ return;
+ }
+ if (pending.phase.phase === 'waiting') {
+ const bound = windowBound(ctx.config.policy, continuationEntries(ctx.config.policy, state), ctx.now);
+ if (bound !== null) { settleBuffer(ctx, state, bound, false); return; }
+ }
+ }
if (state.batch?.phase.phase !== 'judging') {
const due = windowDeadline(ctx.config.policy, state.open);
if (due && !(due.at > ctx.now)) settleBuffer(ctx, state, due.reason, true);
@@ -180,8 +231,9 @@ function sweep(ctx: Ctx, state: ScopeState): void {
if (!held) return;
if (held.phase.phase === 'retrying' && held.phase.at <= ctx.now) beginJudging(ctx, state, held.window, held.phase, held.phase.offerWait, held.hash);
else if (held.phase.phase === 'waiting' && held.phase.until <= ctx.now) {
- if (windowSize(state.open) === 0) beginJudging(ctx, state, held.window, held.phase, false, held.hash);
- else settleBuffer(ctx, state, held.window.reason, false);
+ const offerWait = ctx.config.policy.continuation === 'accumulate' && held.window.waits < ctx.config.policy.maxWaits;
+ if (windowSize(state.open) === 0 && ctx.config.policy.continuation !== 'accumulate') beginJudging(ctx, state, held.window, held.phase, offerWait, held.hash);
+ else settleBuffer(ctx, state, held.window.reason, offerWait);
}
}
@@ -197,7 +249,18 @@ function settleBuffer(ctx: Ctx, state: ScopeState, fired: SettleReason, mayWait:
let forced = open.forcedAt !== null;
if (entries.length === 0) {
if (open.forcedAt !== null) { open.forcedAt = null; ctx.out.changed = true; }
- if (held) beginJudging(ctx, state, { ...held.window, reason: settleReason(held.window.events, forced, held.window.reason) }, held.phase, false, held.hash);
+ if (held) {
+ const accumulating = ctx.config.policy.continuation === 'accumulate';
+ const reason = accumulating ? fired : held.window.reason;
+ const window = { ...held.window, reason: settleReason(held.window.events, forced, reason) };
+ if (accumulating) {
+ window.gap = held.window.gap || open.gap;
+ window.dropped = held.window.dropped + open.dropped;
+ state.open = openWindow(state.scope);
+ }
+ const offer = accumulating && mayWait && window.reason !== 'flush' && window.reason !== 'forced' && window.waits < ctx.config.policy.maxWaits;
+ beginJudging(ctx, state, window, held.phase, offer, held.hash);
+ }
return;
}
const events = held ? [...held.window.events, ...entries] : entries;
@@ -226,6 +289,9 @@ function settleBuffer(ctx: Ctx, state: ScopeState, fired: SettleReason, mayWait:
}
function beginJudging(ctx: Ctx, state: ScopeState, window: Window, prior: Counters, offerWait: boolean, hash: FnvState | null): void {
+ if (ctx.config.policy.continuation === 'accumulate') {
+ offerWait = offerWait && windowBound(ctx.config.policy, window.events, ctx.now) === null && !['age', 'overflow', 'size'].includes(window.reason);
+ }
const attempt = prior.attempt + 1;
const leaseUntil = ctx.now + ctx.config.policy.judgeTimeoutMs * 2;
state.batch = { window, phase: { phase: 'judging', attempt, failures: prior.failures ?? 0, leaseUntil, offerWait }, hash };
@@ -263,6 +329,7 @@ function onJudged(ctx: Ctx, state: ScopeState, input: Extract 0)) {
+ throw new Error('attend: cannot change continuation while a window is unresolved');
+ }
slot.tailCount = stored?.tail.length ?? 0;
slot.tailBytes = stored?.tail.reduce((sum, logged) => sum + inputBytes(logged), 0) ?? 0;
slot.snapshotBytes = stored?.snapshot ? bytes(stored.snapshot.record) : 0;
diff --git a/test/conformance/scenario.ts b/test/conformance/scenario.ts
index 0501e07..e506461 100644
--- a/test/conformance/scenario.ts
+++ b/test/conformance/scenario.ts
@@ -62,7 +62,7 @@ export interface EventSpec {
export type Step =
| { push: string; events: EventSpec[] }
- | { submit: string; events: EventSpec[]; prepareMs?: number; source?: string; cursor?: string | null; prepareFail?: string }
+ | { submit: string; events: EventSpec[]; prepareMs?: number; source?: string; cursor?: string | null; truncated?: boolean; prepareFail?: string }
| { closeIntake: string }
| { advance: number }
| { flush: string }
@@ -283,6 +283,7 @@ export async function runScenario(scenario: Scenario): Promise {
const intake = intakes.get(scope);
if (!intake) throw new Error('scenario intake is not open');
const batch: SourceBatch = { events, ...(step.cursor === undefined ? {} : { cursor: step.cursor }) };
+ if (step.truncated) batch.truncated = true;
receipts.push(result(index, () => intake.submit(async (signal) => {
if (step.prepareMs) await sleep(clock, step.prepareMs, signal);
if (step.prepareFail !== undefined) throw new Error(step.prepareFail);
diff --git a/test/conformance/scenarios.ts b/test/conformance/scenarios.ts
index a9717e8..a92a678 100644
--- a/test/conformance/scenarios.ts
+++ b/test/conformance/scenarios.ts
@@ -14,6 +14,78 @@ const advance = (ms: number) => ({ advance: ms });
const T = 'test/attend.test.ts';
export const SCENARIOS: Scenario[] = [
+ ...['gap', 'dropped'].map((metadata): Scenario => ({
+ name: `accumulating retry attributes empty ${metadata} metadata to held input`,
+ start: 0, intakes: ['s'], kinds: KINDS,
+ settle: { continuation: 'accumulate', maxWindowMs: 100, retryBackoffMs: [30] },
+ judge: { '*': { answers: [{ fail: 'outage' }, { route: 'queue' }, { route: 'queue' }] } },
+ steps: [{ submit: 's', events: [ev('a', 'drag', { quietForMs: 10 })] }, advance(15),
+ metadata === 'gap' ? { submit: 's', events: [], source: 'feed', cursor: '2', truncated: true }
+ : { submit: 's', events: [ev('old', 'out', { observedAt: -100 })], source: 'feed', cursor: '2' },
+ advance(25), { inspect: 's' }, { submit: 's', events: [ev('next', 'drag', { quietForMs: 10 })] }, advance(10)],
+ })),
+ {
+ name: 'accumulating horizon folds empty gap metadata without removing wait',
+ start: 0, intakes: ['s'], kinds: KINDS, settle: { continuation: 'accumulate', waitHorizonMs: 20 },
+ judge: { '*': { answers: [{ route: 'wait' }, { route: 'queue' }] } },
+ steps: [{ submit: 's', events: [ev('a', 'drag', { quietForMs: 10 })] }, advance(15),
+ { submit: 's', events: [], truncated: true }, advance(15), { inspect: 's' }],
+ },
+ {
+ name: 'accumulating horizons include fresh entries and keep wait allowance',
+ start: 0, intakes: ['s'], kinds: KINDS,
+ settle: { continuation: 'accumulate', waitHorizonMs: 20, maxWaits: 2 },
+ judge: { '*': { answers: [{ route: 'wait' }, { route: 'wait' }, { route: 'queue' }] } },
+ steps: [{ submit: 's', events: [ev('a', 'drag', { quietForMs: 10 })] }, advance(25),
+ { submit: 's', events: [ev('b', 'drag', { quietForMs: 100 })] }, advance(25)],
+ },
+ ...[10, 100].map((quiet): Scenario => ({
+ name: `accumulating retry absorbs fresh quiet duration ${quiet} at not-before`,
+ start: 0, intakes: ['s'], kinds: KINDS,
+ settle: { continuation: 'accumulate', retryBackoffMs: [30, 60] },
+ judge: { '*': { answers: [{ fail: 'outage' }, { route: 'queue' }] } },
+ steps: [{ submit: 's', events: [ev('a', 'drag', { quietForMs: 10 })] }, advance(15),
+ { submit: 's', events: [ev('b', 'drag', { quietForMs: quiet })] }, advance(24), { inspect: 's' }, advance(1)],
+ })),
+ {
+ name: 'accumulating wait does not refund a provider failure',
+ start: 0, intakes: ['s'], kinds: KINDS,
+ settle: { continuation: 'accumulate', waitHorizonMs: 20, retryBackoffMs: [30, 60] },
+ judge: { '*': { answers: [{ fail: 'outage' }, { route: 'wait' }, { fail: 'outage' }, { route: 'queue' }] } },
+ steps: [{ submit: 's', events: [ev('a', 'drag', { quietForMs: 10 })] }, advance(40), { inspect: 's' }, advance(80)],
+ },
+ {
+ name: 'accumulating age eligibility applies at an initial quiet tie',
+ start: 0, kinds: KINDS, settle: { continuation: 'accumulate', maxWindowMs: 10 },
+ judge: { '*': { answers: [{ route: 'queue' }] } },
+ steps: [push('s', ev('a', 'drag', { quietForMs: 10 })), advance(10)],
+ },
+ ...['wait', 'retry'].map((phase): Scenario => ({
+ name: `accumulating ${phase} checks combined rendered bytes`,
+ start: 0, intakes: ['s'], kinds: KINDS,
+ settle: { continuation: 'accumulate', maxWindowBytes: 100, retryBackoffMs: [30, 60] },
+ judge: { '*': { answers: [phase === 'wait' ? { route: 'wait' } : { fail: 'outage' }, { route: 'queue' }] } },
+ steps: [{ submit: 's', events: [ev('a', 'drag', { quietForMs: 10, text: 'q'.repeat(20) })] }, advance(15),
+ { submit: 's', events: [ev('b', 'drag', { quietForMs: 100, text: 'q'.repeat(20) })] }, advance(25)],
+ })),
+ {
+ name: 'accumulating retry checks the count after absorbing fresh acts',
+ start: 0, intakes: ['s'], kinds: KINDS,
+ settle: { continuation: 'accumulate', maxEvents: 2, retryBackoffMs: [30, 60] },
+ judge: { '*': { answers: [{ fail: 'outage' }, { route: 'queue' }] } },
+ steps: [{ submit: 's', events: [ev('a', 'drag', { quietForMs: 10 })] }, advance(15),
+ { submit: 's', events: [ev('b', 'drag', { quietForMs: 100 }), ev('c', 'drag', { quietForMs: 100 })] }, advance(25)],
+ },
+ {
+ name: 'accumulating retry absorbs raw backlog after delayed failure completion',
+ start: 0, intakes: ['s'], kinds: KINDS,
+ settle: { continuation: 'accumulate', retryBackoffMs: [30, 60] },
+ judge: { '*': { answers: [{ hold: 'call' }, { route: 'queue' }] } },
+ steps: [{ submit: 's', events: [ev('a', 'drag', { quietForMs: 10 })] }, advance(15),
+ { submit: 's', events: [ev('b', 'drag', { observedAt: 15, quietForMs: 100 })] }, advance(1),
+ { submit: 's', events: [ev('c', 'drag', { observedAt: 16, quietForMs: 100 })] }, advance(19),
+ { release: 'call', fail: 'outage' }, { inspect: 's' }, advance(30)],
+ },
{
name: 'serial intake keeps registered backlog ahead of a timer during preparation',
intakes: ['s'], start: 0, kinds: KINDS,
diff --git a/test/continuation.test.ts b/test/continuation.test.ts
new file mode 100644
index 0000000..514533d
--- /dev/null
+++ b/test/continuation.test.ts
@@ -0,0 +1,273 @@
+import { expect, test } from 'vitest';
+import { readFileSync } from 'node:fs';
+import { createAttend, memoryStore } from '../src/index.js';
+import { createAttendInternal } from '../src/attend.js';
+import { fromRecord } from '../src/core/state.js';
+import { DEFAULT_POLICY } from '../src/types.js';
+import { openIntake } from '../src/intake.js';
+import type { Event, ScopeRecord, ScopeWrite, SettlePolicy, StoredScope } from '../src/types.js';
+import { fakeClock, scriptedJudge } from '../src/testing.js';
+
+type Answer = 'wait' | 'queue' | 'fail';
+interface Offer { at: number; ids: string[]; wait: boolean; waits: number }
+const event = (id: string, observedAt: number, quietForMs = 10): Event => ({ id, at: observedAt, observedAt, quietForMs, name: 'reading', text: 'q'.repeat(20), data: {} });
+
+async function run(answers: Answer[], body: (clock: ReturnType, put: (events: Event[]) => Promise, calls: Offer[]) => Promise, settle: Partial = {}, start = 0) {
+ const clock = fakeClock(start), calls: Offer[] = [];
+ const attend = createAttend({ clock, kind: { reading: 'continuous' }, sink: 'log',
+ settle: { continuation: 'accumulate', streamGapMs: 10, waitHorizonMs: 20, maxWaits: 2, retryBackoffMs: [30, 60], ...settle },
+ judge: async (input) => {
+ calls.push({ at: clock.now(), ids: input.window.events.map((e) => e.id), wait: input.routes.some((r) => r.route === 'wait'), waits: input.window.waits });
+ const answer = answers[calls.length - 1] ?? 'queue';
+ if (answer === 'fail') throw new Error('controlled outage');
+ return { route: answer };
+ },
+ });
+ const intake = openIntake(attend, 's'), running = attend.run();
+ try { await body(clock, (events) => intake.submit(async () => ({ events })), calls); }
+ finally { await intake.close(); await attend.stop(); await running; }
+}
+
+test('horizon reoffers until the wait allowance is used', async () => {
+ await run(['wait', 'wait', 'queue'], async (clock, put, calls) => {
+ await put([event('a', 0)]);
+ await clock.advance(50);
+ expect(calls).toEqual([
+ { at: 10, ids: ['a'], wait: true, waits: 0 },
+ { at: 30, ids: ['a'], wait: true, waits: 1 },
+ { at: 50, ids: ['a'], wait: false, waits: 2 },
+ ]);
+ });
+});
+
+test('horizon absorbs fresh entries before their quiet deadline', async () => {
+ await run(['wait', 'wait', 'queue'], async (clock, put, calls) => {
+ await put([event('a', 0)]);
+ await clock.advance(25);
+ await put([event('b', 25, 100)]);
+ await clock.advance(25);
+ expect(calls).toEqual([
+ { at: 10, ids: ['a'], wait: true, waits: 0 },
+ { at: 30, ids: ['a', 'b'], wait: true, waits: 1 },
+ { at: 50, ids: ['a', 'b'], wait: false, waits: 2 },
+ ]);
+ });
+});
+
+test.each([10, 100])('retry absorbs fresh events at not-before with quiet duration %s', async (quiet) => {
+ await run(['fail', 'queue'], async (clock, put, calls) => {
+ await put([event('a', 0)]);
+ await clock.advance(15);
+ await put([event('b', 15, quiet)]);
+ await clock.advance(24);
+ expect(calls).toHaveLength(1);
+ await clock.advance(1);
+ expect(calls).toEqual([
+ { at: 10, ids: ['a'], wait: true, waits: 0 },
+ { at: 40, ids: ['a', 'b'], wait: true, waits: 0 },
+ ]);
+ });
+});
+
+test('a wait retains the provider failure allowance', async () => {
+ await run(['fail', 'wait', 'fail', 'queue'], async (clock, put, calls) => {
+ await put([event('a', 0)]);
+ await clock.advance(120);
+ expect(calls.map((c) => c.at)).toEqual([10, 40, 60, 120]);
+ expect(calls.map((c) => c.waits)).toEqual([0, 0, 1, 1]);
+ });
+});
+
+test.each([1, 2])('merged count evaluates all entries with %s fresh acts', async (fresh) => {
+ await run(['fail', 'queue'], async (clock, put, calls) => {
+ await put([event('a', 0)]);
+ await clock.advance(15);
+ await put(Array.from({ length: fresh }, (_, i) => event(`b${i}`, 15, 100)));
+ await clock.advance(25);
+ expect(calls[1]).toEqual({ at: 40, ids: ['a', ...Array.from({ length: fresh }, (_, i) => `b${i}`)], wait: fresh === 1, waits: 0 });
+ }, { maxEvents: 2 });
+});
+
+test('age withholds wait at the initial quiet tie', async () => {
+ await run(['queue'], async (clock, put, calls) => {
+ await put([event('a', 0)]);
+ await clock.advance(10);
+ expect(calls).toEqual([{ at: 10, ids: ['a'], wait: false, waits: 0 }]);
+ }, { maxWindowMs: 10 });
+});
+
+test('an older absorbed observation participates in age eligibility', async () => {
+ await run(['fail', 'queue'], async (clock, put, calls) => {
+ await put([event('a', 100)]);
+ await clock.advance(20);
+ await put([event('b', 0, 1000)]);
+ expect(calls).toHaveLength(1);
+ await clock.advance(20);
+ expect(calls[1]).toEqual({ at: 140, ids: ['a', 'b'], wait: false, waits: 0 });
+ }, { maxWindowMs: 100 }, 100);
+});
+
+test.each(['wait', 'fail'])('combined byte threshold is enforced after %s', async (answer) => {
+ await run([answer, 'queue'], async (clock, put, calls) => {
+ await put([event('a', 0)]);
+ await clock.advance(15);
+ await put([event('b', 15, 100)]);
+ if (answer === 'fail') { expect(calls).toHaveLength(1); await clock.advance(25); }
+ expect(calls[1]).toEqual({ at: answer === 'wait' ? 15 : 40, ids: ['a', 'b'], wait: false, waits: answer === 'wait' ? 1 : 0 });
+ }, { maxWindowBytes: 100 });
+});
+
+test.each(['separate', 'accumulate'] as const)('cannot change continuation with an open window from %s', async (from) => {
+ const store = memoryStore(), clock = fakeClock();
+ const config = { store, clock, kind: { reading: 'continuous' } as const, judge: scriptedJudge([{ route: 'queue' }]), sink: 'log' as const };
+ const previous = createAttend({ ...config, settle: { continuation: from } });
+ await previous.push('s', event('a', 0));
+ const before = await previous.inspect('s');
+ const next = createAttend({ ...config, settle: { continuation: from === 'separate' ? 'accumulate' : 'separate' } });
+ await expect(next.push('s', event('b', 0))).rejects.toThrow('continuation');
+ expect(await next.inspect('s')).toEqual(before);
+});
+
+test.each([null, false, 0, 'other'])('refuses invalid continuation %s', (value) => {
+ expect(() => Reflect.apply(createAttend, undefined, [{ kind: {}, judge: scriptedJudge([]), sink: 'log', settle: { continuation: value } }])).toThrow('continuation');
+});
+
+interface LegacyCase { name: string; through: number; writes: ScopeWrite[][]; stored: StoredScope; expected: ScopeRecord }
+const legacy: { source: string; cases: LegacyCase[] } = JSON.parse(readFileSync(new URL('../conformance/fixtures/continuation-legacy.json', import.meta.url), 'utf8'));
+
+test.each(['flush', 'end', 'held-end'] as const)('%s retains its meaning at retry not-before', async (control) => {
+ const clock = fakeClock(), calls: { at: number; reason: string; wait: boolean }[] = [];
+ const engine = createAttend({ clock, kind: { reading: 'continuous' }, sink: 'log', settle: { continuation: 'accumulate', retryBackoffMs: [30] },
+ judge: async (input) => {
+ calls.push({ at: clock.now(), reason: input.window.reason, wait: input.routes.some((r) => r.route === 'wait') });
+ if (calls.length === 1) throw new Error('controlled outage');
+ return { route: 'queue' };
+ },
+ });
+ const running = engine.run();
+ try {
+ await engine.push('s', event('a', 0));
+ await clock.advance(15);
+ if (control === 'end') await engine.push('s', event('b', 15, 100));
+ await engine[control === 'held-end' ? 'end' : control]('s');
+ await clock.advance(24);
+ expect(calls).toHaveLength(1);
+ await clock.advance(1);
+ const reason = control === 'flush' ? 'forced' : control === 'end' ? 'closing' : 'stream_quiet';
+ expect(calls[1]).toEqual({ at: 40, reason, wait: control !== 'flush' });
+ expect((await engine.inspect('s'))?.buffer.forcedAt).toBeNull();
+ } finally { await engine.stop(); await running; }
+});
+
+test.each(legacy.cases)('reads revision-3 $name and refuses an unresolved mode switch', async (item) => {
+ const store = memoryStore(), clock = fakeClock(item.through);
+ for (const writes of item.writes) expect(await store.commit(writes)).toEqual(writes.map(() => 'ok'));
+ expect(await store.load('scope')).toEqual(item.stored);
+ const engine = createAttend({ store, clock, kind: { reading: 'continuous' }, judge: scriptedJudge([{ route: 'queue' }]), sink: 'log', settle: { continuation: 'accumulate' } });
+ expect(await engine.inspect('scope')).toEqual(item.expected);
+ const pending = engine.push('scope', event('b', item.through));
+ if (item.name === 'complete') {
+ await pending;
+ const stored = await store.load('scope');
+ expect(stored?.snapshot?.policy.continuation).toBe('accumulate');
+ expect(stored?.snapshot?.reducer).toBe(4);
+ expect((await engine.inspect('scope'))?.recent).toEqual(item.expected.recent);
+ } else {
+ await expect(pending).rejects.toThrow('continuation');
+ expect(await store.load('scope')).toEqual(item.stored);
+ }
+});
+
+test.each(['ratio', 'always'] as const)('failure budget survives a waiting restart with %s snapshots', async (cadence) => {
+ const store = memoryStore(), clock = fakeClock(), resumedCalls: number[] = [];
+ let firstCalls = 0;
+ const settle = { continuation: 'accumulate', streamGapMs: 10, waitHorizonMs: 20, retryBackoffMs: [30, 60] } as const;
+ const config = { store, clock, kind: { reading: 'continuous' } as const, sink: 'log' as const, settle: { ...settle, retryBackoffMs: [30, 60] } };
+ const first = createAttendInternal({ ...config, judge: async () => { if (++firstCalls === 1) throw new Error('outage'); return { route: 'wait' }; } }, cadence);
+ const intake = openIntake(first, 's'), running = first.run();
+ await intake.submit(async () => ({ events: [event('a', 0)] }));
+ await clock.advance(40);
+ expect((await first.inspect('s'))?.batch?.phase).toMatchObject({ phase: 'waiting', failures: 1 });
+ await intake.close(); await first.stop(); await running;
+ const resumed = createAttend({ ...config, judge: async () => { resumedCalls.push(clock.now()); if (resumedCalls.length === 1) throw new Error('outage'); return { route: 'queue' }; } });
+ const nextIntake = openIntake(resumed, 's'), nextRun = resumed.run();
+ try {
+ await clock.advance(0);
+ expect(clock.nextAt()).toBe(60);
+ await clock.advance(80);
+ expect(resumedCalls).toEqual([60, 120]);
+ expect((await resumed.inspect('s'))?.batch).toBeNull();
+ } finally { await nextIntake.close(); await resumed.stop(); await nextRun; }
+});
+
+test('an accumulating snapshot cannot invent missing waiting failures', () => {
+ const waiting = legacy.cases.find((item) => item.name === 'waiting-snapshot');
+ expect(waiting).toBeDefined();
+ if (!waiting) throw new Error('missing fixture');
+ expect(() => fromRecord(waiting.expected, { ...DEFAULT_POLICY, continuation: 'accumulate' })).toThrow('requires failures');
+});
+
+test('exhaustion after a wait keeps the native dead letter', async () => {
+ const store = memoryStore(), clock = fakeClock();
+ const judge = scriptedJudge([{ fail: 'outage' }, { route: 'wait' }, { fail: 'outage' }, { fail: 'outage' }]);
+ const engine = createAttend({ store, clock, kind: { reading: 'continuous' }, judge, sink: 'log', settle: { continuation: 'accumulate', waitHorizonMs: 20, retryBackoffMs: [30, 60] } });
+ const intake = openIntake(engine, 's'), running = engine.run();
+ try {
+ await intake.submit(async () => ({ events: [event('a', 0)] }));
+ await clock.advance(120);
+ const page = await store.log.read({ after: null, scope: 's', limit: 10 });
+ expect(page.rows).toHaveLength(1);
+ expect(page.rows[0]).toMatchObject({ kind: 'deadLetter', at: 120, body: { stage: 'judge', attempts: 4, window: { waits: 1 } } });
+ expect((await engine.inspect('s'))?.batch).toBeNull();
+ } finally { await intake.close(); await engine.stop(); await running; }
+});
+
+test.each([134, 135])('whole-window byte eligibility honors threshold %s', async (limit) => {
+ await run(['wait', 'queue'], async (clock, put, calls) => {
+ await put([event('a', 0)]); await clock.advance(15);
+ await put([event('b', 15, 100)]); await clock.advance(15);
+ expect(calls[1]).toEqual({ at: limit === 134 ? 15 : 30, ids: ['a', 'b'], wait: limit === 135, waits: 1 });
+ }, { maxWindowBytes: limit });
+});
+
+test.each(['gap', 'dropped'] as const)('empty fresh %s metadata belongs to the unresolved retry', async (metadata) => {
+ const clock = fakeClock(), calls: { ids: string[]; gap: boolean; dropped: number }[] = [];
+ const engine = createAttend({ clock, kind: { reading: 'continuous', out: 'consequence' }, sink: 'log', settle: { continuation: 'accumulate', maxWindowMs: 100, retryBackoffMs: [30] },
+ judge: async (input) => {
+ calls.push({ ids: input.window.events.map((e) => e.id), gap: input.window.gap, dropped: input.window.dropped });
+ if (calls.length === 1) throw new Error('outage');
+ return { route: 'queue' };
+ },
+ });
+ const intake = openIntake(engine, 's'), running = engine.run();
+ try {
+ await intake.submit(async () => ({ events: [event('a', 0)] }));
+ await clock.advance(15);
+ await intake.submit(async () => metadata === 'gap'
+ ? { events: [], truncated: true, cursor: '2' }
+ : { events: [{ id: 'old', at: -100, observedAt: -100, name: 'out', data: {} }], cursor: '2' }, { source: 'feed' });
+ await clock.advance(25);
+ expect(calls[1]).toEqual({ ids: ['a'], gap: metadata === 'gap', dropped: metadata === 'dropped' ? 1 : 0 });
+ const record = await engine.inspect('s');
+ expect(record?.buffer).toMatchObject({ entries: [], gap: false, dropped: 0 });
+ expect(record?.cursors).toEqual({ feed: '2' });
+ await intake.submit(async () => ({ events: [event('next', 40)] }));
+ await clock.advance(10);
+ expect(calls[2]).toEqual({ ids: ['next'], gap: false, dropped: 0 });
+ } finally { await intake.close(); await engine.stop(); await running; }
+});
+
+test('empty gap metadata at a wait horizon does not remove wait allowance', async () => {
+ const clock = fakeClock(), judge = scriptedJudge([{ route: 'wait' }, { route: 'queue' }]);
+ const engine = createAttend({ clock, kind: { reading: 'continuous' }, judge, sink: 'log', settle: { continuation: 'accumulate', waitHorizonMs: 20 } });
+ const intake = openIntake(engine, 's'), running = engine.run();
+ try {
+ await intake.submit(async () => ({ events: [event('a', 0)] }));
+ await clock.advance(15);
+ await intake.submit(async () => ({ events: [], truncated: true }));
+ await clock.advance(15);
+ expect(judge.calls[1]?.window.gap).toBe(true);
+ expect(judge.calls[1]?.routes.some((r) => r.route === 'wait')).toBe(true);
+ expect((await engine.inspect('s'))?.buffer.gap).toBe(false);
+ } finally { await intake.close(); await engine.stop(); await running; }
+});
diff --git a/test/continuous-quiet.test.ts b/test/continuous-quiet.test.ts
index 62bb482..35072eb 100644
--- a/test/continuous-quiet.test.ts
+++ b/test/continuous-quiet.test.ts
@@ -204,7 +204,7 @@ test('a revision-two snapshot and mixed tail rebuild continuous end times', asyn
const loaded = await attend.inspect('s');
expect(loaded?.dueAt).toBe(200);
expect(loaded?.buffer.entries.map((event) => [event.id, event.quietForMs, event.seenAt])).toEqual([['a', undefined, 100], ['b', 90, 120], ['c', undefined, 120]]);
- expect((await store.load('s'))?.snapshot?.reducer).toBe(3);
+ expect((await store.load('s'))?.snapshot?.reducer).toBe(4);
} finally {
await attend.stop();
}
diff --git a/test/core-inputs.test.ts b/test/core-inputs.test.ts
index 1ec7ca8..0fb70f3 100644
--- a/test/core-inputs.test.ts
+++ b/test/core-inputs.test.ts
@@ -379,7 +379,7 @@ test('assertInvariants identifies corrupt counts, rings, summaries, sizes, hashe
lane.outbox.decisions.push(lane.outbox.decisions[0]!);
lane.dueAt = nextDue(policy, lane);
assert.throws(() => assertInvariants(lane, policy), /^Error: outbox: more than one in flight/);
- assert.equal(REDUCER_VERSION, 3);
+ assert.equal(REDUCER_VERSION, 4);
});
test('fromRecord accepts frozen oracle snapshots without changing them', () => {
diff --git a/test/observation-time.test.ts b/test/observation-time.test.ts
index ba5bc02..d06f3a0 100644
--- a/test/observation-time.test.ts
+++ b/test/observation-time.test.ts
@@ -207,7 +207,7 @@ test('a prior reducer snapshot and tail retain ingestion-time deadlines on upgra
const loaded = await attend.inspect('s');
expect(loaded?.dueAt).toBe(2100);
expect(loaded?.buffer.entries.map((event) => [event.id, event.seenAt, event.observedAt])).toEqual([['a', 1000, undefined], ['b', 1100, undefined]]);
- expect((await store.load('s'))?.snapshot?.reducer).toBe(3);
+ expect((await store.load('s'))?.snapshot?.reducer).toBe(4);
} finally {
await attend.stop();
}
diff --git a/test/recovery.test.ts b/test/recovery.test.ts
index fc16215..6585d30 100644
--- a/test/recovery.test.ts
+++ b/test/recovery.test.ts
@@ -69,7 +69,7 @@ test('recovers every committed write under all snapshot cadences and policy chan
let tailInputs = 0;
let snapshotBytes = JSON.stringify(latest.record).length;
const replay = (snapshot: Snapshot, through: number, expected: ScopeRecord): void => {
- assert.equal(snapshot.reducerVersion, 3);
+ assert.equal(snapshot.reducerVersion, 4);
const restored = fromRecord(deepFreeze(json(snapshot.record)), snapshot.policy);
let bound = Math.max(snapshot.policy.seenCount, restored.seen.size);
assertInvariants(restored, { ...snapshot.policy, seenCount: bound });