11# Self-Drawn Platform Host Architecture
22
3- Status: planned. The all-content self-drawn direction is decided; the thin
4- desktop hosts described here are not implemented yet.
3+ Status: H0 contract and dependency firewall complete; H1 shared window runtime
4+ is next. The desktop OS shells described here are not implemented yet.
55
66Updated: 2026-08-01
77
@@ -30,20 +30,25 @@ or layout container with a toolkit widget.
3030
3131## Current State and Gap
3232
33- The repository currently contains two different generations of code :
33+ The repository currently contains three distinct layers :
3434
35351 . ` appkit_native/ ` , ` gtk4_native/ ` , and ` winui_native/ ` create toolkit
3636 controls. They provide migration evidence for behavior, input,
3737 accessibility, packaging, and real OS execution.
38382 . ` layout/ ` and ` drawing/layout_scene.rs ` form the new generic self-drawn
3939 path. The calculator already lowers into stable layout and scene records,
4040 and the software and offscreen GPU renderers have executable evidence.
41-
42- The missing layer is a production window host that attaches the Graphics GPU
43- renderer to a real top-level surface and returns OS services to the portable
44- runtime without constructing content controls. The old control backends are
45- frozen until this replacement passes its gates. They are migration inputs,
46- not the target architecture and not a base for new TSX work.
41+ 3 . ` platform_host/ ` is the H0 zero-widget boundary. It provides bounded window,
42+ presentation, raw-input, text-input, stable-id accessibility, and explicit
43+ system-service records; atomic revision transactions; a recording host; and
44+ executable dependency/source firewalls.
45+
46+ The next missing layer is the H1 shared runtime that connects committed layout,
47+ scene, hit-region, accessibility, and service state to the new host contract.
48+ Production H2-H4 hosts must then attach Graphics to real top-level surfaces and
49+ return OS services without constructing content controls. The old control
50+ backends are frozen until this replacement passes its gates. They are migration
51+ inputs, not the target architecture and not a base for new TSX work.
4752
4853## Target Pipeline
4954
@@ -178,32 +183,63 @@ a fake host and by all three desktop shells.
178183- avoid exposing native handles or arbitrary platform calls to components or
179184 the TSX process
180185
181- ## Planned Repository Shape
186+ ## Repository Shape
182187
183188``` text
184189src/platform_host/
185- |- mod.rs
186- |- contract.rs window, frame, event, and service records
187- |- runtime.rs render/service transaction orchestration
188- |- conformance.rs shared fake-host and zero-widget assertions
189- |- macos/ NSWindow + custom NSView shell
190- |- windows/ Win32 HWND shell
191- `- linux/ Wayland primary + X11 fallback shell
190+ |- mod.rs public H0 boundary
191+ |- contract.rs revision transaction, presentation, events, host trait
192+ |- window.rs top-level window records only
193+ |- input.rs un-targeted pointer, key, and wheel records
194+ |- text_input.rs bounded IME/edit-session state and events
195+ |- accessibility.rs stable PlatformElementId tree, bounds, and actions
196+ |- system.rs typed clipboard, picker, URL, permission, menu services
197+ |- recording.rs bounded deterministic fake host
198+ |- validation.rs shared record validation
199+ `- tests.rs contract, recovery, redaction, and wire-shape tests
200+
201+ tests/platform_host_firewall.rs
202+
203+ Planned next:
204+ src/platform_host/runtime.rs
205+ src/platform_host/macos/
206+ src/platform_host/windows/
207+ src/platform_host/linux/
192208
193209examples/self_drawn_calculator.rs
194210src/bin/a3s_gui_host.rs
195211```
196212
197- The target Cargo feature names are planned as ` host-macos ` , ` host-windows ` ,
198- ` host-linux-wayland ` , and ` host-linux-x11 ` , with an optional ` host-linux `
199- aggregate. They are not public features until H0 lands. None may enable or
200- import ` appkit-native ` , ` gtk4-native ` , ` winui-native ` , or the legacy
201- widget-planning modules.
213+ The ` platform-host ` , ` host-macos ` , ` host-windows ` , ` host-linux-wayland ` ,
214+ ` host-linux-x11 ` , and ` host-linux ` features landed in H0. The target features
215+ currently select the common contract only; OS dependencies arrive with their
216+ H2-H4 implementation. None enables or imports ` appkit-native ` , ` gtk4-native ` ,
217+ ` winui-native ` , or the legacy widget-planning modules.
202218
203219The new modules are created beside the legacy directories rather than by
204220renaming a control backend. This makes accidental content-widget reuse visible
205221and lets each old backend be deleted after its replacement evidence exists.
206222
223+ ## H0 Transaction and Thread Contract
224+
225+ ` PlatformHost ` is intentionally thread-affine. The trait does not require
226+ ` Send ` or ` Sync ` , so an H2-H4 implementation can stay on its owning OS event
227+ loop. Every public record crossing the boundary is ` Send + Sync ` and contains
228+ no native or GPU handle.
229+
230+ The runtime prepares one complete ` PlatformHostTransaction ` at a monotonically
231+ increasing ` PlatformHostRevision ` . Validation runs before host mutation and
232+ enforces bounded command counts, finite geometry, stable accessibility ids,
233+ UTF-8 text ranges, sensitive-value rules, and unique per-revision presentation,
234+ accessibility, and system-request identities.
235+
236+ Commit atomically applies the pending revision. A failed commit leaves that
237+ revision pending so the owner must explicitly retry or roll it back; rollback
238+ does not advance the last committed revision. Shutdown rejects a pending
239+ transaction, releases queued events, and makes later operations fail. The
240+ recording host keeps bounded diagnostic history with text-input and sensitive
241+ clipboard payloads redacted while preserving byte lengths and command shape.
242+
207243## Delivery Plan
208244
209245The host track is named H0-H5. It is dependency-coupled to renderer milestones
@@ -237,7 +273,7 @@ accessibility gates require M4.
237273
238274### H0 - Contract and dependency firewall
239275
240- Status: next .
276+ Status: complete .
241277
242278Deliverables:
243279
@@ -251,15 +287,27 @@ Deliverables:
251287Gates:
252288
253289- the contract contains no widget create/update/remove operation
254- - platform-host records contain no ` NativeElement ` , portable style, Node,
255- toolkit object, or ` wgpu ` handle
290+ - platform-host records contain no ` NativeElement ` , portable style, Node.js
291+ runtime value, toolkit object, or ` wgpu ` handle
256292- semantic-only builds remain free of Graphics and platform dependencies
257293- every host-facing record is bounded, deterministic, and ` Send + Sync ` where
258294 thread affinity does not require an owning executor
259295
296+ Evidence:
297+
298+ - all six H0/target marker features compile without a legacy renderer
299+ - the common ` platform-host ` dependency graph contains no Graphics or OS
300+ toolkit package
301+ - 13 unit tests cover validation, stable ids, wire shape, atomic revisions,
302+ commit failure, rollback, teardown, bounded storage, and redaction
303+ - three integration tests recursively audit source imports, Cargo feature
304+ edges, the public feature gate, and absence of widget CRUD
305+ - ` just verify ` runs the H0 compile, dependency-graph, contract, and firewall
306+ gates on every normal CI change
307+
260308### H1 - Shared self-drawn window runtime
261309
262- Status: planned after H0 ; depends on the M3 presentation boundary.
310+ Status: next ; depends on the M3 presentation boundary.
263311
264312Deliverables:
265313
@@ -415,17 +463,16 @@ or dependency-boundary evidence.
415463
416464## First Reviewable Commit Sequence
417465
418- 1 . Add H0 contract records, fake-host conformance, feature firewall, and tests.
419- 2 . Add H1 shared frame orchestration and raw-surface presentation lifecycle.
420- 3 . Present the rectangle-only shared calculator through the Windows host.
421- 4 . Present the same rectangle-only calculator through the macOS host.
422- 5 . Present it through Wayland, then add the separately gated X11 fallback.
423- 6 . Land text shaping, editing, input/IME, and accessibility slices against the
466+ 1 . Add H1 shared frame orchestration and raw-surface presentation lifecycle.
467+ 2 . Present the rectangle-only shared calculator through the Windows host.
468+ 3 . Present the same rectangle-only calculator through the macOS host.
469+ 4 . Present it through Wayland, then add the separately gated X11 fallback.
470+ 5 . Land text shaping, editing, input/IME, and accessibility slices against the
424471 shared host contract, one subsystem at a time.
425- 7 . Pass the full calculator cutover matrix on all three platforms.
426- 8 . Delete WinUI/XAML, GTK4, and AppKit content-control code in independent
472+ 6 . Pass the full calculator cutover matrix on all three platforms.
473+ 7 . Delete WinUI/XAML, GTK4, and AppKit content-control code in independent
427474 platform commits while preserving the new shells.
428- 9 . Switch defaults, examples, packaging, and documentation, then run the final
475+ 8 . Switch defaults, examples, packaging, and documentation, then run the final
429476 repository-wide dead-code and dependency audit.
430477
431478Each commit must leave the tree buildable for its declared feature set. No
0 commit comments