From 4cadc0b75f07ccb2043929c5f1527a39ee359021 Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Sat, 17 Oct 2026 09:04:43 -0500 Subject: [PATCH 1/5] docs(id): plan phases 11 and 12 --- .opencode/plans/phase-11-foundations.md | 86 +++++++++++++++++ .../plans/phase-12-platform-flexibility.md | 93 +++++++++++++++++++ .opencode/plans/phase-9-portable-platform.md | 4 + ...00-00Z_architecture_next_stage_platform.md | 30 ++++++ 4 files changed, 213 insertions(+) create mode 100644 .opencode/plans/phase-11-foundations.md create mode 100644 .opencode/plans/phase-12-platform-flexibility.md create mode 100644 doc/2026-10-17T15-00-00Z_architecture_next_stage_platform/2026-10-17T15-00-00Z_architecture_next_stage_platform.md diff --git a/.opencode/plans/phase-11-foundations.md b/.opencode/plans/phase-11-foundations.md new file mode 100644 index 0000000000..fa39a1c95b --- /dev/null +++ b/.opencode/plans/phase-11-foundations.md @@ -0,0 +1,86 @@ +# Phase 11: foundations for the next stage + +See the [architecture record](../../doc/2026-10-17T15-00-00Z_architecture_next_stage_platform/2026-10-17T15-00-00Z_architecture_next_stage_platform.md) and the follow-on [Phase 12 plan](phase-12-platform-flexibility.md). + +## Goal + +Phase 9 and 10 added many capabilities quickly. Phase 11 makes them trustworthy, measurable, and easy to change before more is stacked on top. Nothing here adds a user-visible feature for its own sake. Each task either removes a known blocker, makes a cost visible, or removes a structural obstacle that Phase 12 needs. + +## Evidence this plan starts from + +| Observation | Source | +| --- | --- | +| The Nix check has never passed in recorded history (392 runs since 2026-03-25, none successful). | `id` workflow history | +| The disk filled on the runner (ENOSPC, then a linker bus error). Fixed by line-table debuginfo and no incremental cache in `mkCheck`. | CI runs 39023225921, 39023472983 | +| `relay_ops` reads the relay kit from outside the Nix source, which fails `id-test`, `id-test-web`, and the `id` package build (its `doCheck` runs `cargo test`). The NixOS VM tests then cannot build. | Issue #238, run 39032425456 | +| Firefox E2E: 12 failed, 2 flaky of 130 in the only run that reached a summary. One shared server and one browser serve all tests. | Issue #229 | +| The Rust unit suite takes about 480 seconds in CI. A full run with `--keep-going` takes over an hour. | CI logs | +| The bulk LogSync test is retried over a mid-stream reset that nobody has explained. | Issue #241 | +| Territory's styled view uses about 7.1M of the 10M fuel limit, and nothing reports it. | Fuel probe during P9.4 | +| `world.rs` is 6,120 lines (about 3,600 before its first test module). `world_session.rs` is 4,017 and `cli.rs` is 3,958. `cmd_world` has a 730 KB stack frame warning. | `wc -l`, clippy | +| Every example module is 0.5 to 0.7 MB. | `examples/*/*.wasm` | +| Joiners can read the install seed, chat, and nothing of host events, with no single place that decides visibility. | Issues #240, #242; roles record | +| Older binaries silently truncate an unreadable final journal line. | Issue #227, PR #244 | + +## Workstreams + +Tasks are numbered F11.n. Each names an exit criterion that a test or a CI job can check. + +### A. Make CI trustworthy + +This comes first, because every later task needs a signal it can believe. + +- **F11.1 Relay kit location (#238).** Move the deployable kit into `pkgs/id/deploy/relay/` and point the test and the design record at it, or skip `relay_ops` in Nix. Exit: `id-test`, `id-test-web`, and the `id` package build pass in Nix. +- **F11.2 Firefox E2E isolation (#229).** Reproduce locally per spec file, then give each spec file its own `id serve --ephemeral` server and port, and restart the browser per file. Exit: two consecutive green runs on one commit, and the E2E derivation under 10 minutes. +- **F11.3 Explain the LogSync reset (#241).** Find which side resets the connection, fix it, and delete the retry. Exit: the bulk test passes 50 consecutive runs under `--test-threads=1` and under full-suite load without a retry. +- **F11.4 A fast lane.** Split CI into a lane that gives feedback in under 15 minutes (fmt, clippy, unit tests) and a full lane (integration, VM, E2E). Use `--keep-going` in both. Exit: median PR feedback for the fast lane under 15 minutes, measured over ten runs. +- **F11.5 Injected time.** Introduce a `Clock` that the actor and the scheduler read, with a manual clock for tests, so schedule and tick tests stop sleeping. Exit: no `sleep` in `world.rs` tests, and the schedule tests run in under one second. + +### B. Make cost visible + +- **F11.6 Per-call fuel metrics and budgets.** Record fuel used per guest call, add `id world measure`, and add a budget test for every checked-in example that fails when a call grows by more than 25 percent. Exit: the test exists and the headroom table is in the record. In progress on `platform-perf-budgets`. +- **F11.7 Host metrics and tracing.** Counters and histograms for actor queue depth, command latency, journal append and fsync latency, checkpoint duration, session count, and frame bytes. Expose them in `id world stats` and, when `--web` is on, as Prometheus text at an admin-token-protected path. Add `tracing` spans around each actor command. Exit: a test reads each metric after a scripted session, and the cost of metrics is under 2 percent in the benchmark below. +- **F11.8 Benchmarks.** A benchmark harness for guest replay of N events, journal append with fsync, checkpoint compaction, and session fan-out to K clients. Record baselines in the repository and run the harness in a non-blocking CI job that posts the numbers. Exit: baselines committed, and a regression of more than 20 percent is reported on the PR. +- **F11.9 Bytes per frame.** Measure full-screen frame sizes for each example at 80x24 and 200x60. This is the baseline that Phase 12 delta frames must beat. Exit: a table in the record. + +### C. Make the code easy to change + +- **F11.10 Split the large modules, with no behavior change.** `world.rs` into scopes and roles, journal entries and replay, the capability ledger and providers, the actor, and tests. `world_session.rs` into frames, session loop, and hub glue. `cli.rs` into one file per command group. Box large command variants so `cmd_world` stays under a stack budget. Exit: no file over 2,500 lines of production code, the full test suite passes unchanged, and `git diff --stat` shows moves only. +- **F11.11 One client projection.** A single function maps core events and snapshots to what a given scope may see. It owns the decisions in #240 (install seed), the chat-visibility gap, and #242 (host events), each with a policy table and a test per row. Exit: no code path serializes a `WorldEvent` to a client except through the projection, enforced by a test that greps for the old call sites. +- **F11.12 Journal format management.** A version header, `id world journal check`, `id world journal backup`, and a writer that refuses to open a journal written by a newer format. This turns the rollback rule into tooling. Exit: a test opens a journal with a future version and gets a clear refusal, and `backup` produces a file that restores byte for byte. +- **F11.13 Error taxonomy.** Typed errors with stable codes and reasons on the wire, including the reason that `schedule.at` currently drops. Exit: every `CapError` carries a documented code, and the guide lists them. + +### D. Make guests cheaper + +- **F11.14 Cheaper `Screen`.** Replace the per-cell record list with row strings and style runs, so a full redraw costs less fuel. Exit: territory's view at or under 40 percent of the fuel limit, enforced by the F11.6 budget. +- **F11.15 Smaller modules.** Run `wasm-opt -Os` and strip in each `build.sh`. Exit: every checked-in module at or under 400 KB, with instantiate time measured. +- **F11.16 Replay self-check.** `id world verify` replays a world's journal twice, compares the records, and reports any divergence. This is the determinism guard for everything the guests do. Exit: a test with a deliberately nondeterministic guest fails the check. + +## Sequencing + +```text +F11.1 -> F11.2 -> F11.4 (CI trust, then speed) +F11.3, F11.5 (parallel with the above) +F11.6 -> F11.14 -> F11.15 (measure, then optimise guests) +F11.7, F11.8 -> F11.9 (host metrics, benchmarks, baselines) +F11.10 -> F11.11 -> F11.12 (split, then project, then format) +F11.13, F11.16 (anytime after F11.10) +``` + +F11.10 should land before F11.11 and F11.12, because those two touch the code the split moves. + +## Decisions needed before work starts + +1. F11.1: move the relay kit into `pkgs/id`, or skip the test in Nix. +2. F11.11: install seeds secret or public; chat visible to join-only participants or not. Recommendation: secret and not visible, with an explicit scope to opt in. +3. F11.2: whether to take the E2E work on now. + +## Out of scope + +New guest capabilities, new transports, and new roles. Those belong to [Phase 12](phase-12-platform-flexibility.md). + +## References + +- [Architecture record](../../doc/2026-10-17T15-00-00Z_architecture_next_stage_platform/2026-10-17T15-00-00Z_architecture_next_stage_platform.md) +- [Phase 12 plan](phase-12-platform-flexibility.md) +- [Phase 9 and 10 plan](phase-9-portable-platform.md) diff --git a/.opencode/plans/phase-12-platform-flexibility.md b/.opencode/plans/phase-12-platform-flexibility.md new file mode 100644 index 0000000000..d70f0d6751 --- /dev/null +++ b/.opencode/plans/phase-12-platform-flexibility.md @@ -0,0 +1,93 @@ +# Phase 12: platform flexibility + +See the [architecture record](../../doc/2026-10-17T15-00-00Z_architecture_next_stage_platform/2026-10-17T15-00-00Z_architecture_next_stage_platform.md). This phase builds on [Phase 11](phase-11-foundations.md); the dependencies are named per task. + +## Goal + +Make the platform something other people can build on without changing its core: new capabilities added as components, worlds described and reproduced as data, programs written in several languages and upgraded without losing state, and many worlds run on one node and across nodes, all with the same sandbox and authority rules. + +## What "best in class" means here + +These are the exit tests for the whole phase. Each is measurable. + +| Criterion | Target | +| --- | --- | +| Time from empty directory to a running world a friend can join | Under 5 minutes, one command per step, documented | +| Adding a host capability | A new provider and its manifest, no edits to `world.rs` | +| Guest languages with a passing conformance suite | At least 3 (Roc plus two of Rust, TypeScript or AssemblyScript, Zig) | +| Upgrading a running program | State preserved across versions, failed upgrade rolls back, proven by a test | +| Idle worlds on one node | 1,000, with bounded memory per world | +| Active worlds on one node | 100 worlds at 20 events per second each, with p99 command latency under 50 ms | +| Reproducing a world | `world.toml` plus a module hash recreates grants, ceilings, profile, schedules, and invites | +| Bandwidth for a typical redraw | Under 10 percent of the full-frame size (baseline from F11.9) | +| Authority and sandbox | No new path to files, network, or processes except through a named, ceilinged provider | + +## Workstreams + +Tasks are numbered F12.n. + +### A. Worlds as data + +- **F12.1 Declarative world manifest.** A `world.toml` that names the module (hash or source), seed, grants, ceilings, resource profile, roles and invites, and schedules. `id world apply` reconciles a live world to the file, `--dry-run` prints a plan, and `id world diff` shows drift. Applying is idempotent and journaled, and every step uses the existing admin operations. Depends on F11.11 and F11.12. Exit: apply twice and the second run changes nothing; drift is detected after a manual `caps` change. +- **F12.2 Forking and templates.** `id world fork` creates a world from another's module and snapshot with provenance recorded, and templates are forks marked reusable. The install seed policy from F11.11 decides whether a fork may inherit the seed. Exit: a fork replays to the parent's records at the fork point. +- **F12.3 Roles v2.** Journaled grants for builder (install modules) and moderator (revoke participants) as scope bits, with an audit record for each use. Builder never receives network, file, or process authority. Depends on F12.1. Exit: a builder installs a module, a moderator revokes a participant, and a guest cannot do either. + +### B. A real extension model + +- **F12.4 Provider registry.** Capability providers become components with a manifest: name, version, argument schema, bounds, required scope, and default ceiling. The ledger, the compile gate, and the CLI read the registry, so the catalog stops being a hard-coded list. Depends on F11.10 and F11.13. Exit: a test provider is added without editing `world.rs`, and it appears in `caps`, the ceiling, and the compile gate. +- **F12.5 First new providers.** `kv` (a bounded, durable, per-world key-value store), `blob` (content-addressed, over iroh-blobs), `http.fetch` (admin allowlist, size and rate bounds, no redirects off the list, off by default), and `notify` (user-visible, rate limited). Each ships behind a ceiling and with an audit entry per use. Exit: each has bound, refusal, and replay tests; `http.fetch` has a test that proves an unlisted host is refused. +- **F12.6 Observability and audit.** A structured audit log of administrative actions and provider use, with OpenTelemetry export, building on F11.7. Exit: every admin frame produces an audit line, and a test replays the log to the final grants. + +### C. More languages, stable contract + +- **F12.7 ABI specification and conformance suite.** Write down the `plaza_*` exports and the capability protocol as a versioned specification, add a `plaza_abi_version` export, and publish a conformance suite built on fixtures from F11.16 and the recording work (#239). Exit: the Roc examples pass the suite unchanged. +- **F12.8 Second and third guest SDKs.** A Rust SDK for `wasm32-unknown-unknown` and one of TypeScript (AssemblyScript) or Zig, each with `screen`, `json`, `grid`, and `cap` helpers equal to the Roc libraries, and an example world. Evaluate the Wasm component model and WIT as the long-term interface, and record the decision. Depends on F12.7. Exit: each SDK passes the conformance suite and ships a playable example. +- **F12.9 Program upgrade with state migration.** Versioned snapshots and an optional `migrate` export. An upgrade runs on a probe instance first (the way checkpoints already do), commits only if the migrated state round-trips, and otherwise rolls back. Exit: a test upgrades a counter across a snapshot format change and a deliberately failing upgrade leaves the old program running. + +### D. Scale + +- **F12.10 Fair scheduling and quotas.** A hub scheduler that shares fuel and CPU fairly across worlds, with per-account quotas for worlds, storage, and fuel per second, and back-pressure for slow clients. Depends on F11.7 and F11.8. Exit: a world that spins on fuel cannot raise another world's p99 latency by more than 10 percent, shown in a benchmark. +- **F12.11 Delta and binary frames.** Screen patches as cell runs, an optional binary encoding, optional compression, and resume tokens so a reconnecting client receives a patch, not a snapshot. Baseline from F11.9. Exit: the bandwidth target in the table above, with a parity test that a patched client equals a full-frame client. +- **F12.12 Many worlds per node.** Lazy world open, idle eviction with checkpoint, and a bounded memory budget per world. Exit: the 1,000 idle and 100 active targets, measured by the F11.8 harness. + +### E. Across nodes + +- **F12.13 Journal replication.** Read replicas that follow a world's journal over a signed stream. A world keeps a single writer, so there are no write conflicts. Replicas serve spectators and survive the writer being offline. The rollback and format rules from F11.12 apply to the stream. Exit: a replica reproduces the writer's records, and a tampered stream is refused. +- **F12.14 Portals.** Cross-world messaging through a capability that both worlds' admins have granted, with bounded rate and size and an audit entry on each side. Depends on F12.4 and F12.6. Exit: two worlds exchange a message only when both sides have granted the portal. + +### F. Authoring + +- **F12.15 `id world dev`.** Watch the source, rebuild, and hot-swap into a scratch world using the F12.9 migration, with fixture replay on every change and a deterministic fuzz harness that drives a guest with generated inputs against declared invariants. Exit: an edit-to-running loop under 3 seconds for a small Roc app, and the fuzz harness finds a seeded bug. +- **F12.16 `id world doctor`.** Checks the toolchain, platform build, ceilings, profile, journal format, and clock, and prints the fix for each problem. Exit: each check has a failing-case test. + +### G. Security hardening + +- **F12.17 Trust and provenance.** Verify module signatures against an admin trust list, extend the observed provenance (#225) with a compiler version, and record the trust decision in the journal. This is trust, not only observation. Exit: an unsigned module is refused when the list is non-empty. +- **F12.18 Denial-of-service tests.** A suite that tries to exhaust fuel, memory, journal size, frame size, session count, schedule count, and provider bounds, and asserts each is refused with the documented code and that the node stays responsive. Exit: the suite passes in CI. + +## Sequencing + +```text +Phase 11 done: F11.1, F11.4, F11.10, F11.11, F11.12 +F12.4 -> F12.5 -> F12.6 -> F12.14 +F12.1 -> F12.2, F12.3 +F12.7 -> F12.8 -> F12.9 -> F12.15 +F11.7/8/9 -> F12.10, F12.11, F12.12 +F12.13 after F11.12 and F12.6 +F12.16, F12.17, F12.18 anytime after F11.10 +``` + +The provider registry (F12.4) and the manifest (F12.1) have the highest return, because each turns a core-code change into data. + +## Risks + +- **Scope.** Eighteen tasks is too many to run at once. Treat F12.4, F12.1, and F12.7 as the first slice, and decide on the rest after the exit tests for those three. +- **Authority creep.** `http.fetch`, `notify`, `blob`, and portals each widen what a guest can cause. Each must ship off by default, behind a ceiling, with an audit entry, and with a refusal test. None may add a Wasm import. +- **Compatibility.** Every new journal entry is forward-only for older binaries (#227). F11.12 must land before the first Phase 12 entry type. +- **Hidden state.** Hot upgrade and forking both copy or migrate program state. The seed and visibility decisions from F11.11 apply to both. + +## References + +- [Phase 11 plan](phase-11-foundations.md) +- [Architecture record](../../doc/2026-10-17T15-00-00Z_architecture_next_stage_platform/2026-10-17T15-00-00Z_architecture_next_stage_platform.md) +- [Phase 9 and 10 plan](phase-9-portable-platform.md) diff --git a/.opencode/plans/phase-9-portable-platform.md b/.opencode/plans/phase-9-portable-platform.md index a32d281bcf..7e89cd7699 100644 --- a/.opencode/plans/phase-9-portable-platform.md +++ b/.opencode/plans/phase-9-portable-platform.md @@ -76,6 +76,10 @@ each one is useful alone and does not depend on a later one. - **P10.1 started in this worktree:** role-scoped invites (`spectator`, `player`, `guest`, `delegator`) over the existing scope machinery, and `id world list --json` for directory feeds. Builder/moderator roles with their own authority, and a cross-node directory feed, remain follow-ups. Record: [roles and directory](../../doc/2026-10-17T08-00-00Z_feature_world_roles_directory/2026-10-17T08-00-00Z_feature_world_roles_directory.md). +## Next stage + +Phase 11 ([foundations](phase-11-foundations.md)) and Phase 12 ([platform flexibility](phase-12-platform-flexibility.md)) continue from here. Phase 10 items still open: builder and moderator roles (F12.3), world forking and templates (F12.2), outbound notifications (F12.5), and the directory feed. + ## Phase 10 sketch: worlds as places Not committed beyond the slice above, recorded so the direction is visible. diff --git a/doc/2026-10-17T15-00-00Z_architecture_next_stage_platform/2026-10-17T15-00-00Z_architecture_next_stage_platform.md b/doc/2026-10-17T15-00-00Z_architecture_next_stage_platform/2026-10-17T15-00-00Z_architecture_next_stage_platform.md new file mode 100644 index 0000000000..83c6b60c48 --- /dev/null +++ b/doc/2026-10-17T15-00-00Z_architecture_next_stage_platform/2026-10-17T15-00-00Z_architecture_next_stage_platform.md @@ -0,0 +1,30 @@ +# Next stage of the platform: foundations, then flexibility + +See the [Phase 11 plan](../../.opencode/plans/phase-11-foundations.md) and the [Phase 12 plan](../../.opencode/plans/phase-12-platform-flexibility.md). + +## Intent + +Phases 9 and 10 delivered portable screens, structured Roc libraries, per-world execution profiles, capability ceilings, roles, fixtures, and scheduled events. They were delivered faster than they were verified. This record sets the direction for the next stage: first make the platform trustworthy and measurable (Phase 11), then make it flexible enough that other people extend it without changing its core (Phase 12). + +## Decisions + +- **Foundations before features.** The Nix check has no recorded success, and the failures found so far are test setup, not product logic. Every later task needs a signal it can trust, so CI repair comes first and is a prerequisite, not a parallel track. +- **Measure before optimising.** Fuel is the guests' main ceiling, and the first optimisation target (territory at about 71 percent of the limit) was found by hand. Budgets as tests make regressions visible and make optimisation work checkable. +- **One place decides what a client may see.** Three open issues (#240 seed, chat visibility, #242 host events) are the same question asked in different places. A single client projection answers it once, with a test per row. +- **Make the rollback rule into tooling.** Older binaries truncate an unreadable final journal line (#227, #244). A journal format version, a check, and a backup command turn a documented hazard into something enforced, and must land before any new journal entry type in Phase 12. +- **Extensibility through data and registries.** The provider registry and the world manifest turn core-code changes into declarations. This is the main flexibility lever, and the plans put them first in Phase 12. +- **Every new reach is ceilinged, audited, and off by default.** Providers such as `http.fetch` and `notify` widen what a guest can cause. They arrive behind the ceiling machinery from P9.3e, with a refusal test and an audit entry, and none adds a Wasm import. + +## What is not decided here + +The relay kit location (#238), seed secrecy (#240), chat visibility, whether to take the Firefox E2E work on (#229), and the choice between the Wasm component model and the current ABI as the long-term interface (F12.8). The Phase 11 plan lists the first three as decisions needed before work starts. + +## Progress + +- F11.6 per-call fuel metrics and budgets: in progress on `platform-perf-budgets`. + +## References + +- [Phase 11 plan](../../.opencode/plans/phase-11-foundations.md) +- [Phase 12 plan](../../.opencode/plans/phase-12-platform-flexibility.md) +- [Phase 9 and 10 plan](../../.opencode/plans/phase-9-portable-platform.md) From 0619c86c9f58ddd085de6a6476cf2929201a42f4 Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Sat, 17 Oct 2026 09:28:43 -0500 Subject: [PATCH 2/5] docs(id): record the territory fuel finding in the phase 11 plan --- .opencode/plans/phase-11-foundations.md | 5 +++-- .../2026-10-17T15-00-00Z_architecture_next_stage_platform.md | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.opencode/plans/phase-11-foundations.md b/.opencode/plans/phase-11-foundations.md index fa39a1c95b..bd07609d9e 100644 --- a/.opencode/plans/phase-11-foundations.md +++ b/.opencode/plans/phase-11-foundations.md @@ -16,7 +16,7 @@ Phase 9 and 10 added many capabilities quickly. Phase 11 makes them trustworthy, | Firefox E2E: 12 failed, 2 flaky of 130 in the only run that reached a summary. One shared server and one browser serve all tests. | Issue #229 | | The Rust unit suite takes about 480 seconds in CI. A full run with `--keep-going` takes over an hour. | CI logs | | The bulk LogSync test is retried over a mid-stream reset that nobody has explained. | Issue #241 | -| Territory's styled view uses about 7.1M of the 10M fuel limit, and nothing reports it. | Fuel probe during P9.4 | +| Territory's styled view uses 78% of the 10M fuel limit with two seats, and each further seat adds about 0.8M, so six or more seats trap, and a trapped view poisons the world. Nothing reported it until F11.6. | PR #247 | | `world.rs` is 6,120 lines (about 3,600 before its first test module). `world_session.rs` is 4,017 and `cli.rs` is 3,958. `cmd_world` has a 730 KB stack frame warning. | `wc -l`, clippy | | Every example module is 0.5 to 0.7 MB. | `examples/*/*.wasm` | | Joiners can read the install seed, chat, and nothing of host events, with no single place that decides visibility. | Issues #240, #242; roles record | @@ -54,6 +54,7 @@ This comes first, because every later task needs a signal it can believe. - **F11.14 Cheaper `Screen`.** Replace the per-cell record list with row strings and style runs, so a full redraw costs less fuel. Exit: territory's view at or under 40 percent of the fuel limit, enforced by the F11.6 budget. - **F11.15 Smaller modules.** Run `wasm-opt -Os` and strip in each `build.sh`. Exit: every checked-in module at or under 400 KB, with instantiate time measured. +- **F11.17 A view trap must not poison the world.** Today a guest view that traps (fuel, memory, or a guest bug) marks the program unhealthy for good. Degrade to an error screen that names the failing call, keep the program's state, retry on the next event, and count the failure in the F11.7 metrics. Exit: a guest that traps on `view` leaves the world accepting input, and the next healthy `view` recovers. - **F11.16 Replay self-check.** `id world verify` replays a world's journal twice, compares the records, and reports any divergence. This is the determinism guard for everything the guests do. Exit: a test with a deliberately nondeterministic guest fails the check. ## Sequencing @@ -64,7 +65,7 @@ F11.3, F11.5 (parallel with the above) F11.6 -> F11.14 -> F11.15 (measure, then optimise guests) F11.7, F11.8 -> F11.9 (host metrics, benchmarks, baselines) F11.10 -> F11.11 -> F11.12 (split, then project, then format) -F11.13, F11.16 (anytime after F11.10) +F11.13, F11.16, F11.17 (anytime after F11.10; F11.17 can start earlier) ``` F11.10 should land before F11.11 and F11.12, because those two touch the code the split moves. diff --git a/doc/2026-10-17T15-00-00Z_architecture_next_stage_platform/2026-10-17T15-00-00Z_architecture_next_stage_platform.md b/doc/2026-10-17T15-00-00Z_architecture_next_stage_platform/2026-10-17T15-00-00Z_architecture_next_stage_platform.md index 83c6b60c48..40cb93e2e6 100644 --- a/doc/2026-10-17T15-00-00Z_architecture_next_stage_platform/2026-10-17T15-00-00Z_architecture_next_stage_platform.md +++ b/doc/2026-10-17T15-00-00Z_architecture_next_stage_platform/2026-10-17T15-00-00Z_architecture_next_stage_platform.md @@ -21,7 +21,7 @@ The relay kit location (#238), seed secrecy (#240), chat visibility, whether to ## Progress -- F11.6 per-call fuel metrics and budgets: in progress on `platform-perf-budgets`. +- F11.6 per-call fuel metrics and budgets: PR #247. It found that territory traps with six or more seats; the fix is in progress on `platform-territory-fuel`, and F11.17 plans the platform-level defence. ## References From 58591d5cc39bd9610e5847eec172cbcf4a23790e Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Sat, 17 Oct 2026 09:56:56 -0500 Subject: [PATCH 3/5] docs(id): add the pinned-toolchain task to the phase 11 plan --- .opencode/plans/phase-11-foundations.md | 3 ++- .../2026-10-17T15-00-00Z_architecture_next_stage_platform.md | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.opencode/plans/phase-11-foundations.md b/.opencode/plans/phase-11-foundations.md index bd07609d9e..d23b6ee93a 100644 --- a/.opencode/plans/phase-11-foundations.md +++ b/.opencode/plans/phase-11-foundations.md @@ -55,6 +55,7 @@ This comes first, because every later task needs a signal it can believe. - **F11.14 Cheaper `Screen`.** Replace the per-cell record list with row strings and style runs, so a full redraw costs less fuel. Exit: territory's view at or under 40 percent of the fuel limit, enforced by the F11.6 budget. - **F11.15 Smaller modules.** Run `wasm-opt -Os` and strip in each `build.sh`. Exit: every checked-in module at or under 400 KB, with instantiate time measured. - **F11.17 A view trap must not poison the world.** Today a guest view that traps (fuel, memory, or a guest bug) marks the program unhealthy for good. Degrade to an error screen that names the failing call, keep the program's state, retry on the next event, and count the failure in the F11.7 metrics. Exit: a guest that traps on `view` leaves the world accepting input, and the next healthy `view` recovers. +- **F11.18 Pinned toolchain for checked-in artifacts.** The checked-in territory module was built by an older system `roc` than the one pinned in `nix/roc.nix`, and that alone cost about 4.2M fuel per view. Rebuild every example with the pinned compiler, have each `build.sh` refuse a different one, and add a CI job that rebuilds the examples and checks behavior with the sandbox suite and the fuel budgets. Same-source builds are not byte-stable, so compare behavior, never hashes. Exit: the job fails when an example is built by another compiler. - **F11.16 Replay self-check.** `id world verify` replays a world's journal twice, compares the records, and reports any divergence. This is the determinism guard for everything the guests do. Exit: a test with a deliberately nondeterministic guest fails the check. ## Sequencing @@ -62,7 +63,7 @@ This comes first, because every later task needs a signal it can believe. ```text F11.1 -> F11.2 -> F11.4 (CI trust, then speed) F11.3, F11.5 (parallel with the above) -F11.6 -> F11.14 -> F11.15 (measure, then optimise guests) +F11.6 -> F11.18 -> F11.14 -> F11.15 (measure, pin the compiler, then optimise guests) F11.7, F11.8 -> F11.9 (host metrics, benchmarks, baselines) F11.10 -> F11.11 -> F11.12 (split, then project, then format) F11.13, F11.16, F11.17 (anytime after F11.10; F11.17 can start earlier) diff --git a/doc/2026-10-17T15-00-00Z_architecture_next_stage_platform/2026-10-17T15-00-00Z_architecture_next_stage_platform.md b/doc/2026-10-17T15-00-00Z_architecture_next_stage_platform/2026-10-17T15-00-00Z_architecture_next_stage_platform.md index 40cb93e2e6..53eb427700 100644 --- a/doc/2026-10-17T15-00-00Z_architecture_next_stage_platform/2026-10-17T15-00-00Z_architecture_next_stage_platform.md +++ b/doc/2026-10-17T15-00-00Z_architecture_next_stage_platform/2026-10-17T15-00-00Z_architecture_next_stage_platform.md @@ -21,7 +21,7 @@ The relay kit location (#238), seed secrecy (#240), chat visibility, whether to ## Progress -- F11.6 per-call fuel metrics and budgets: PR #247. It found that territory traps with six or more seats; the fix is in progress on `platform-territory-fuel`, and F11.17 plans the platform-level defence. +- F11.6 per-call fuel metrics and budgets: PR #247. It found that territory traps with six or more seats; the fix is PR #248 (full house 1.6M fuel, 16% of the limit; part of the saving was a stale compiler, see F11.18), and F11.17 plans the platform-level defence. ## References From a77c07c42febd400e1d96e943abf947b60a82991 Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Sat, 17 Oct 2026 09:57:39 -0500 Subject: [PATCH 4/5] docs(id): widen the LogSync task in the phase 11 plan --- .opencode/plans/phase-11-foundations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.opencode/plans/phase-11-foundations.md b/.opencode/plans/phase-11-foundations.md index d23b6ee93a..a6863ef1d9 100644 --- a/.opencode/plans/phase-11-foundations.md +++ b/.opencode/plans/phase-11-foundations.md @@ -32,7 +32,7 @@ This comes first, because every later task needs a signal it can believe. - **F11.1 Relay kit location (#238).** Move the deployable kit into `pkgs/id/deploy/relay/` and point the test and the design record at it, or skip `relay_ops` in Nix. Exit: `id-test`, `id-test-web`, and the `id` package build pass in Nix. - **F11.2 Firefox E2E isolation (#229).** Reproduce locally per spec file, then give each spec file its own `id serve --ephemeral` server and port, and restart the browser per file. Exit: two consecutive green runs on one commit, and the E2E derivation under 10 minutes. -- **F11.3 Explain the LogSync reset (#241).** Find which side resets the connection, fix it, and delete the retry. Exit: the bulk test passes 50 consecutive runs under `--test-threads=1` and under full-suite load without a retry. +- **F11.3 Explain the LogSync flakes (#241).** Find which side resets the connection, fix it, and delete the retry. The retry does not hold under load, and `test_an_interrupted_session_restarts_without_duplicates` flakes the same way, so cover both. Exit: both tests pass 50 consecutive runs under `--test-threads=1` and under full-suite load without a retry. - **F11.4 A fast lane.** Split CI into a lane that gives feedback in under 15 minutes (fmt, clippy, unit tests) and a full lane (integration, VM, E2E). Use `--keep-going` in both. Exit: median PR feedback for the fast lane under 15 minutes, measured over ten runs. - **F11.5 Injected time.** Introduce a `Clock` that the actor and the scheduler read, with a manual clock for tests, so schedule and tick tests stop sleeping. Exit: no `sleep` in `world.rs` tests, and the schedule tests run in under one second. From b2d593db6b66ce44e15506425a9d762904ae9047 Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Sat, 17 Oct 2026 22:54:09 -0500 Subject: [PATCH 5/5] docs(id): bring the phase 11 plan up to date with main --- .opencode/plans/phase-11-foundations.md | 16 ++++++++-------- ...15-00-00Z_architecture_next_stage_platform.md | 5 ++++- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/.opencode/plans/phase-11-foundations.md b/.opencode/plans/phase-11-foundations.md index a6863ef1d9..85db305d24 100644 --- a/.opencode/plans/phase-11-foundations.md +++ b/.opencode/plans/phase-11-foundations.md @@ -30,9 +30,9 @@ Tasks are numbered F11.n. Each names an exit criterion that a test or a CI job c This comes first, because every later task needs a signal it can believe. -- **F11.1 Relay kit location (#238).** Move the deployable kit into `pkgs/id/deploy/relay/` and point the test and the design record at it, or skip `relay_ops` in Nix. Exit: `id-test`, `id-test-web`, and the `id` package build pass in Nix. +- **F11.1 Relay kit location (#238).** Done on `main` by #249: the kit is vendored under `pkgs/id/tests/fixtures/relay`, the doc copy stays canonical, and a drift test fails whenever the doc copy is present and differs. Residual risk: drift is only caught in a full checkout, not in the Nix sandbox. Exit met: `id-test`, `id-test-web`, and the `id` package build no longer fail on the kit. - **F11.2 Firefox E2E isolation (#229).** Reproduce locally per spec file, then give each spec file its own `id serve --ephemeral` server and port, and restart the browser per file. Exit: two consecutive green runs on one commit, and the E2E derivation under 10 minutes. -- **F11.3 Explain the LogSync flakes (#241).** Find which side resets the connection, fix it, and delete the retry. The retry does not hold under load, and `test_an_interrupted_session_restarts_without_duplicates` flakes the same way, so cover both. Exit: both tests pass 50 consecutive runs under `--test-threads=1` and under full-suite load without a retry. +- **F11.3 Explain the LogSync flakes (#241).** `main` fixed the interrupted-session test (#254). The live failure on `main` is the bulk test hitting `Timeout(30s)`: it takes about 23.5s on an idle machine, so the shared 30s test deadline has no headroom, and #224 aligns it with the 60s production deadline. Still open: why a bulk transfer of that size takes 23s, and the connection reset seen only in `--keep-going` runs. Exit: both tests pass 50 consecutive runs under full-suite load without a retry, and the bulk test runs in under 10s. - **F11.4 A fast lane.** Split CI into a lane that gives feedback in under 15 minutes (fmt, clippy, unit tests) and a full lane (integration, VM, E2E). Use `--keep-going` in both. Exit: median PR feedback for the fast lane under 15 minutes, measured over ten runs. - **F11.5 Injected time.** Introduce a `Clock` that the actor and the scheduler read, with a manual clock for tests, so schedule and tick tests stop sleeping. Exit: no `sleep` in `world.rs` tests, and the schedule tests run in under one second. @@ -46,7 +46,7 @@ This comes first, because every later task needs a signal it can believe. ### C. Make the code easy to change - **F11.10 Split the large modules, with no behavior change.** `world.rs` into scopes and roles, journal entries and replay, the capability ledger and providers, the actor, and tests. `world_session.rs` into frames, session loop, and hub glue. `cli.rs` into one file per command group. Box large command variants so `cmd_world` stays under a stack budget. Exit: no file over 2,500 lines of production code, the full test suite passes unchanged, and `git diff --stat` shows moves only. -- **F11.11 One client projection.** A single function maps core events and snapshots to what a given scope may see. It owns the decisions in #240 (install seed), the chat-visibility gap, and #242 (host events), each with a policy table and a test per row. Exit: no code path serializes a `WorldEvent` to a client except through the projection, enforced by a test that greps for the old call sites. +- **F11.11 One client projection.** A single function maps core events and snapshots to what a given scope may see, used by `events_after`, the snapshot, and the live stream. Decided by the project owner: the install seed is secret (done on `main` in #250 for `events_after` and the snapshot) and join-only participants do not see chat, with an explicit `history` scope to opt in to reading it (in progress on `fix-chat-visibility`, which also unifies the three paths and checks the live stream for a seed leak). Host events (#242) remain open. Exit: no code path serializes a `WorldEvent` to a client except through the projection, enforced by a test. - **F11.12 Journal format management.** A version header, `id world journal check`, `id world journal backup`, and a writer that refuses to open a journal written by a newer format. This turns the rollback rule into tooling. Exit: a test opens a journal with a future version and gets a clear refusal, and `backup` produces a file that restores byte for byte. - **F11.13 Error taxonomy.** Typed errors with stable codes and reasons on the wire, including the reason that `schedule.at` currently drops. Exit: every `CapError` carries a documented code, and the guide lists them. @@ -69,13 +69,13 @@ F11.10 -> F11.11 -> F11.12 (split, then project, then format) F11.13, F11.16, F11.17 (anytime after F11.10; F11.17 can start earlier) ``` -F11.10 should land before F11.11 and F11.12, because those two touch the code the split moves. +F11.10 should land before F11.12, because that task touches the code the split moves. F11.10 must wait until the open platform stack (#209 to #248) has merged: `world.rs`, `world_session.rs`, and `cli.rs` are edited by every one of those PRs, so a split now would conflict with all of them. -## Decisions needed before work starts +## Decisions -1. F11.1: move the relay kit into `pkgs/id`, or skip the test in Nix. -2. F11.11: install seeds secret or public; chat visible to join-only participants or not. Recommendation: secret and not visible, with an explicit scope to opt in. -3. F11.2: whether to take the E2E work on now. +1. Relay kit (#238): settled on `main` by #249 with a vendored copy and a drift test, not a move. The move into `pkgs/id/deploy/relay/` was approved but is not needed now. +2. Seeds and chat (F11.11): seeds secret, join-only participants do not see chat, an explicit `history` scope opts in. Approved. +3. Firefox E2E (#229, F11.2): not yet decided. It remains the last red check once the sync tests are fixed. ## Out of scope diff --git a/doc/2026-10-17T15-00-00Z_architecture_next_stage_platform/2026-10-17T15-00-00Z_architecture_next_stage_platform.md b/doc/2026-10-17T15-00-00Z_architecture_next_stage_platform/2026-10-17T15-00-00Z_architecture_next_stage_platform.md index 53eb427700..f3d6ba2ea0 100644 --- a/doc/2026-10-17T15-00-00Z_architecture_next_stage_platform/2026-10-17T15-00-00Z_architecture_next_stage_platform.md +++ b/doc/2026-10-17T15-00-00Z_architecture_next_stage_platform/2026-10-17T15-00-00Z_architecture_next_stage_platform.md @@ -17,12 +17,15 @@ Phases 9 and 10 delivered portable screens, structured Roc libraries, per-world ## What is not decided here -The relay kit location (#238), seed secrecy (#240), chat visibility, whether to take the Firefox E2E work on (#229), and the choice between the Wasm component model and the current ABI as the long-term interface (F12.8). The Phase 11 plan lists the first three as decisions needed before work starts. +Whether to take the Firefox E2E work on (#229), and the choice between the Wasm component model and the current ABI as the long-term interface (F12.8). The relay kit (#238) was settled on `main` by #249, and the project owner decided that install seeds stay secret and join-only participants do not see chat, with an explicit `history` scope to opt in. ## Progress - F11.6 per-call fuel metrics and budgets: PR #247. It found that territory traps with six or more seats; the fix is PR #248 (full house 1.6M fuel, 16% of the limit; part of the saving was a stale compiler, see F11.18), and F11.17 plans the platform-level defence. +- Seed redaction landed on `main` (#250); chat visibility and a single projection are in progress on `fix-chat-visibility`. +- Main CI: the live failure is the bulk LogSync test hitting its 30s deadline; #224 aligns it to 60s and carries the disk cap and `--keep-going`. + ## References - [Phase 11 plan](../../.opencode/plans/phase-11-foundations.md)