Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
0218ddb
ops: add event-await overnight implementation flow
miyaontherelay Sep 17, 2026
73f32ad
feat(surface): add bounded event activities
miyaontherelay Sep 17, 2026
fd1c77f
docs(evidence): record event activity surface slice
miyaontherelay Sep 17, 2026
ee3f345
fix(sdk): open activities before body work
miyaontherelay Sep 17, 2026
df433f5
docs(evidence): add activity opening fix
miyaontherelay Sep 17, 2026
5742029
feat(kernel): add durable event activities
miyaontherelay Sep 17, 2026
dfba2b7
docs(evidence): record event activity kernel slice
miyaontherelay Sep 17, 2026
d06eabd
fix(daemon): restrict activity close reasons
miyaontherelay Sep 17, 2026
a1e57bb
docs(evidence): record activity close boundary
miyaontherelay Sep 17, 2026
c5f5473
fix(daemon): reserve subscription streams
miyaontherelay Sep 17, 2026
4fbb3a5
docs(evidence): record reserved stream boundary
miyaontherelay Sep 17, 2026
ec4345a
feat(event-await): integrate local activity ingress
miyaontherelay Sep 17, 2026
2293bed
docs(evidence): record event await local slice
miyaontherelay Sep 17, 2026
6e8c3cb
test(event-await): pin unread lifetime accounting
miyaontherelay Sep 17, 2026
ef69223
docs(evidence): update event await acceptance capture
miyaontherelay Sep 17, 2026
3236011
fix(event-await): preserve durable activity wake recovery
miyaontherelay Sep 17, 2026
c9cb5de
docs(evidence): record event-await audit commit
miyaontherelay Sep 17, 2026
651d07a
fix(event-await): retain normal wakes until acknowledged
miyaontherelay Sep 17, 2026
9986618
docs(evidence): record event-await audit pass 2
miyaontherelay Sep 17, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
141 changes: 141 additions & 0 deletions docs/evidence/event-await-implementation/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
# Event-await local implementation evidence

Implementation commits: `ec4345a8c474bbe16b9727e5a0d2dd874e399569` and
`6e8c3cb697e911ddcba89999bd58bf3b0f603228`.

## Scope and acceptance map

`kernel/relayflowd/tests/event_activities.rs` is the deterministic SQLite
journal harness. It covers cases 1–8 and 10–15 from `docs/EVENT-AWAIT.md`;
case 9 is the SDK preflight test named below. The live SDK test uses the real
daemon socket and includes an actual `SIGKILL` / restart boundary after
`stream.appended`.

| Acceptance case | Test |
| --- | --- |
| 1, 3–5, 7, 8, 10–12, 15 | `remaining_event_await_acceptance_cases_use_the_real_journal` |
| 2, 6 | `accepted_append_is_buffered_deduplicated_and_survives_a_restart_before_next` (plus the SDK SIGKILL test) |
| 8 | `cancel_closes_an_open_activity_before_the_terminal_run_record` |
| 9 | `packages/sdk/tests/activity-preflight.test.ts` |
| 13 | `exact_deadline_tie_wins_and_reports_unread_range` |
| 14 | `overflow_closes_before_the_1001st_unread_frame_and_recovery_never_reopens_it` |

## Kernel acceptance command

Command (exit 0):

```sh
PATH=/Users/khaliqgant/.relayflows-toolchain/rustup/toolchains/local/bin:$PATH CARGO_HOME=/Users/khaliqgant/.relayflows-toolchain/cargo RUSTUP_HOME=/Users/khaliqgant/.relayflows-toolchain/rustup RUSTUP_TOOLCHAIN=local CARGO_TARGET_DIR=/Users/khaliqgant/.relayflows-toolchain/target/1398563233 /Users/khaliqgant/.relayflows-toolchain/rustup/toolchains/local/bin/cargo test --manifest-path kernel/Cargo.toml -p relayflowd --test event_activities
```

Captured output:

```text
Compiling relayflowd-core, relayflowd-journal, and relayflowd
Finished `test` profile [unoptimized + debuginfo] target(s) in 3.82s
Running tests/event_activities.rs (/Users/khaliqgant/.relayflows-toolchain/target/1398563233/debug/deps/event_activities-54b0211a77a95d2a)

running 6 tests
test exact_deadline_tie_wins_and_reports_unread_range ... ok
test cancel_closes_an_open_activity_before_the_terminal_run_record ... ok
test exact_deadline_tie_wins_and_reports_unread_range ... ok
test idle_wait_is_durable_and_fires_without_an_event ... ok
test accepted_append_is_buffered_deduplicated_and_survives_a_restart_before_next ... ok
test remaining_event_await_acceptance_cases_use_the_real_journal ... ok
test overflow_closes_before_the_1001st_unread_frame_and_recovery_never_reopens_it ... ok

test result: ok. 6 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 10.91s

EXIT=0
```

## SDK command

Command (exit 0):

```sh
cd packages/sdk && /Users/khaliqgant/.bun/bin/bun run typecheck && /Users/khaliqgant/.bun/bin/bun run build && /Users/khaliqgant/.bun/bin/bun run typecheck:tests && RELAYFLOWD_BIN=/Users/khaliqgant/.relayflows-toolchain/target/1398563233/debug/relayflowd /Users/khaliqgant/.bun/bin/bun x vitest run tests/authored-activity.test.ts tests/activity-preflight.test.ts tests/live-event-activities.test.ts
```

Captured output:

```text
$ tsc --noEmit && tsc -p tsconfig.type-tests.json
$ tsc && node scripts/make-cli-executable.mjs
$ tsc -p tsconfig.tests.json

RUN v2.1.9 /Volumes/Paris Drive/AgentWorkforce/.worktrees/flows-v2-lead-0913/event-await-flows-overnight-0917/packages/sdk

✓ tests/activity-preflight.test.ts (1 test) 6ms
✓ tests/authored-activity.test.ts (8 tests) 19ms
✓ tests/live-event-activities.test.ts (2 tests) 629ms
✓ runs surface f.on through the local daemon event path and journals its buffered wake 570ms

Test Files 3 passed (3)
Tests 11 passed (11)
Start at 08:04:53
Duration 2.40s (transform 839ms, setup 0ms, collect 4.48s, tests 655ms, environment 0ms, prepare 208ms)

EXIT=0
```

## Surface command

Command (exit 0):

```sh
cd packages/surface && PATH=/Users/khaliqgant/.bun/bin:$PATH /Users/khaliqgant/.bun/bin/bun run test
```

Captured output:

```text
$ bun run build && tsc -p tsconfig.test.json && vitest run
$ tsc

RUN v2.1.9 /Volumes/Paris Drive/AgentWorkforce/.worktrees/flows-v2-lead-0913/event-await-flows-overnight-0917/packages/surface

✓ tests/activity.test.ts (1 test) 1ms
✓ tests/triggers.test.ts (4 tests) 4ms
✓ tests/slack-block-kit.test.ts (5 tests) 3ms
✓ tests/provider-triggers.test.ts (3 tests) 4ms
✓ tests/flow.test.ts (20 tests) 9ms
✓ tests/helpers.snapshot.test.ts (1 test) 475ms
✓ regenerates helpers byte-identically from the pinned adapter 475ms

Test Files 6 passed (6)
Tests 34 passed (34)
Start at 08:05:02
Duration 810ms (transform 189ms, setup 0ms, collect 644ms, tests 495ms, environment 1ms, prepare 583ms)

EXIT=0
```

## Cloud handoff

No Cloud credentials, remote configuration, or deployment was touched. The
repository-owned local adapter deliberately uses `event.emit` with a provider
delivery id and actor, and the kernel records only the tenant-neutral facts.
Production router work still outside this repository is:

1. Before acknowledging `subscription.open`, durably create the fenced Cloud
binding for `(run_id, subscription_id, generation, ingress_offset)` with
the installation, canonical resource scope, authorization snapshot, event
types, pattern, and run identity. Persist that binding receipt and ingress
offset in `subscription.opened`.
2. On recovery, remove a prepared binding lacking `subscription.opened`; for
an opened binding replay ingress strictly after its saved offset before
making it visible. If the binding is `closing: overflow`, submit the same
idempotent overflow-close command and never reopen or replay it.
3. Authenticate every provider frame against the bound installation and
canonical scope, apply the actor/self filter, and pass its provider delivery
id to the per-subscription journal sequencer. A user pattern must not widen
installation or resource authorization.
4. On a would-exceed frame, first durably fence the Cloud binding and refuse
later appends; then submit the overflow close to the same sequencer as
appends and timer claims. Remove the binding only after the close commits.

There is no local blocker. The only intentionally unimplemented portion is
that Cloud-owned provider binding/ingress handoff above; its absence is why the
local acceptance case proves the journal side of the post-open handoff rather
than claiming a real provider-router crash test.
122 changes: 122 additions & 0 deletions docs/evidence/event-await-implementation/audit-pass-1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
# Event-await implementation audit — pass 1

Audited at `ef692235c3064346b5326ca7374392d484bf1b9c` plus the working-tree
fixes recorded below. Scope was every event-await commit after `c8c68315`:
`73f32ad1`, `ee3f3452`, `5742029e`, `d06eabdf`, `c5f54733`, `ec4345a8`, and
`6e8c3cb6`, together with their evidence-only commits.

Fix commit: `3236011f20f918aa347a576426b6530a3e52e107`
(`fix(event-await): preserve durable activity wake recovery`).

## Fixed findings

1. **F1 — immediate event completion was not recoverable.**
`next_subscription()` could append `wait.completed` and an acknowledgement
without first appending its `wait.event`. A crash between those records
made the completion orphaned during fold and could redeliver its frames.
It now records `wait.event` before a ready-batch completion.

2. **F2 — a fenced overflow of a parked `next()` decoded as an internal
protocol error.** The overflow close writes a durable completion result
`{ wake: "overflow" }`; the recovery decoder previously required event
offsets instead. It now returns the fenced `Wake.overflow` and leaves the
closed wake stable. The regression exercises the real SQLite journal across
the fence/restart/close boundary.

3. **F3 — activity wait ids collided at a simulated-clock instant.** They
were derived from `now_ms`, so two wakes in one millisecond reused an id.
Wait ids are now a durable per-subscription sequence reconstructed from the
journal.

4. **F4 — activity cleanup skipped authored validation errors.** A missing
`done()` or a post-body operation-validation failure left an opened cursor
live. Those paths now close it with `canceled`. The SDK test no longer uses
a zero-millisecond timing assumption; it waits for the actual open request.

## Acceptance status and blocker

The local daemon/kernel regressions cover the journal-side cases. The
provider-router portion of acceptance case 11 remains **unimplemented in this
worktree**: `open_subscription()` records `ingress_offset: 0` and the neutral
`{"transport":"local-daemon"}` receipt, while no durable prepared Cloud
binding, generation, ingress log/replay, or recovery cleanup exists here.
The current `event.emit` route is run-local, so it cannot prove a frame that
arrives between external binding preparation and body visibility. This is a
contractual blocker for a full acceptance-11 / production-router claim, not a
kernel substitute. No Cloud credentials, remote configuration, or deployment
was touched.

## Verification

Focused kernel regression, exit 0:

```text
$ cd kernel && zsh -c 'PATH=/Users/khaliqgant/.cargo/bin:$PATH RUSTUP_TOOLCHAIN=local sh ../ops/cargo.sh test -p relayflowd --test event_activities --quiet; audit_rc=$?; printf "EVENT_AWAIT_KERNEL_EXIT=%s\n" "$audit_rc"; exit "$audit_rc"'

running 8 tests
........
test result: ok. 8 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 10.84s

EVENT_AWAIT_KERNEL_EXIT=0
```

Full kernel workspace, exit 0:

```text
$ cd kernel && PATH=/Users/khaliqgant/.cargo/bin:$PATH RUSTUP_TOOLCHAIN=local sh ../ops/cargo.sh test --workspace

test result: ok. 49 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
test result: ok. 10 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
test result: ok. 40 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
```

Focused SDK regression plus test typecheck, exit 0:

```text
$ cd packages/sdk && npm exec vitest -- run tests/authored-activity.test.ts && npm run typecheck:tests

✓ tests/authored-activity.test.ts (9 tests) 69ms
Test Files 1 passed (1)
Tests 9 passed (9)

> @relayflows/sdk@2.0.14 typecheck:tests
> tsc -p tsconfig.tests.json
```

Full surface package, exit 0:

```text
$ cd packages/surface && PATH=/Users/khaliqgant/.bun/bin:$PATH /Users/khaliqgant/.bun/bin/bun run test

Test Files 6 passed (6)
Tests 34 passed (34)
```

The full SDK package command was run with the required shim paths:

```text
$ cd packages/sdk && export PATH=/Users/khaliqgant/.cargo/bin:/Users/khaliqgant/.bun/bin:$PATH; export RUSTUP_TOOLCHAIN=local; npm test
EVENT_AWAIT_SDK_FULL_EXIT=1
```

Its failure is outside this slice's source changes and is recorded rather than
masked: 1,687 tests passed and 18 were skipped; two environment preconditions
failed. `tests/authored-node-runtime.test.ts` pins Bun `1.4.0`, but the
available executable reports `1.4.2`; `tests/mcp.test.ts` falls back to the
absent `kernel/target/release/relayflowd` rather than the wrapper's debug
binary. Literal checks:

```text
$ PATH=/Users/khaliqgant/.bun/bin:$PATH bun --version
1.4.2
$ test -x kernel/target/release/relayflowd; printf 'RELEASE_RELAYFLOWD_EXISTS=%s\n' "$?"
RELEASE_RELAYFLOWD_EXISTS=1
```

The changed files pass `git diff --check` (exit 0). `cargo fmt --check` could
not run because this installed toolchain has no `fmt` component:

```text
$ cd kernel && sh ../ops/cargo.sh fmt --all -- --check
error: no such command: `fmt`
```
Loading
Loading