Files
MobileGL/docs/Disaggregated/notes/p5/p5-results/c1-v2.md
T
swung0x48 aba329cc53 [Docs] (Disaggregated): P6's plan and contract draft; the working notes move from a local directory into the repository
Two things land together: the plan and contract draft P6 needs before it starts, and the
working notes that until now existed on exactly one machine.

1. P6's plan and contract draft (neither started; not one line of code)

     docs/Disaggregated/P6-SPAWN-PLAN.md      the package plan
     docs/Disaggregated/P6-CONTRACT-DRAFT.md  the contract draft (moves to
                                              MG_Remote/CONTRACT-P6.md when c6 lands)

   The three findings that mattered, all written into the documents:

   a. P6 is SMALLER than its roadmap cell suggests. The transport primitives are already in
      the tree and already tested: SocketDoorbell including hangup detection and the two
      lost-wakeup fences (Doorbell.cpp:211-360, four cases in FdPassingTest), SCM_RIGHTS fd
      passing, ShmSegment::Adopt, and the SurfaceOp / WindowKind schema already defined in
      protocol.fbs. inproc uses a real second shm mapping rather than an alias, and
      SessionRings.h:22-28 says that was done so today is not the first time it runs. P6 is
      assembly plus a control plane plus a process, not "write a socket transport".

   b. The evidence for "P6 is only a transport swap" has EXPIRED. It was bought by P5c, whose
      audit found 59 direct memory accesses in a tree that already looked clean. P5e changed
      the tree again. So the first package, a6, is a read-only audit that writes no code, and
      every contract row that depends on it is marked PENDING a6 rather than decided in
      advance.

   c. P6 does not get a game running on the phone. ANativeWindow* is meaningless in the child,
      and protocol.fbs:186-196's own comment says Android transfers the window out of band -
      that band is P12. P6 lands pbuffer / surfaceless / offscreen, which is what HeadlessGL,
      the split-equivalent lane and trace replay need, and which is exactly what P6's own exit
      gate measures. A real window reaching the server is a named refusal. This gets its own
      section because "P6 is done" would otherwise read as "the game runs now".

   The contract adds rule G: a role may not name a process-local handle. It extends P5c's
   rule E (a role may not name the other role's memory) from memory to identity - EGLDisplay /
   EGLSurface / EGLContext / ANativeWindow* / fd number / pid / mapped address either cross as
   a token this contract defines or they do not cross, and a descriptor crosses only through
   SCM_RIGHTS, where the kernel renumbers it.

   What P5e left for P6 gets its own section. The latch semantics are already designed
   (ARCHITECTURE.md:504) and are copied unchanged. What is new is that after run-ahead the
   client no longer waits while the peer process can DIE: the client holds records that were
   published and will never be applied, and Android's freezer suspends the child without
   closing anything. So slow and dead must be distinguishable WITHOUT a timeout threshold.
   That is P6's only new design; everything else is carriage. It shares a predicate with E1's
   outstanding re-specification (ID-122), and the two should be designed together.

   Two gates carried over from P5e's lessons: G2 requires integration-spawn's test-name set to
   match integration-split's name for name, because a differing set means the lane is quietly
   running less; and the arm-proof gate requires every entry to record the child pid and
   transport=spawn in its OWN private log - ID-124 established that this kind of false green
   really happens, and a spawn lane that actually ran monolith would pass every other gate.
   S2's shape must be settled before it is written, and the document says why: E1 is the
   cautionary case.

2. The working notes move into the repository (docs/Disaggregated/notes/, 415 .md files)

   ROADMAP / CURRENT_STAGE_PROGRESS / MEASUREMENTS cite ruling numbers, audit line numbers and
   the provenance of gate figures from ~/w7/notes/, a directory that exists on one machine and
   is under no version control. A record cited hundreds of times that lives only locally is not
   a record, so it moves in whole, with its directory structure intact.

   Only .md moves. Scripts, run logs, census and gate result JSON, patches, APKs and nm dumps
   stay where they are: they are evidence DATA rather than documents - large, regenerated per
   run, and mostly carrying absolute paths and device serials that mean something only on the
   machine that produced them. The mapping and this split are written in
   docs/Disaggregated/notes/README.md.

   Two exceptions are recorded there too: P6's BRIEF has been promoted to a first-class
   document and keeps no copy under notes/, so the two cannot drift apart; and recovered/ holds
   material salvaged from failed workflow runs, which may duplicate the like-named phase
   directories and is kept because a few of those were the only complete version at the time.

   CI's citation lint takes docs/Disaggregated/*.md only (non-recursive), and notes/ is
   deliberately outside it: those notes' file:line citations were written against their own
   code heads, and resolving them against today's HEAD would fail wholesale - which is not an
   error, it is their correct state as a historical record. To check one, use the revision it
   declares (--rev).

3. Inconsistencies fixed in passing

   - README.md's status line still said P5e was in progress while the stage table already said
     closed.
   - CURRENT_STAGE_PROGRESS's next-step item 1 still listed the exit gate as pending, though
     (a) and (b) were run in the previous commit; rewritten to closed plus the one item that
     actually remains (E1).
   - ROADMAP's P6 row still had the pre-phase plan in three of its cells; it now carries the
     package order, the scope boundary and the two new gates.

Checked with check_doc_citations.py: 125 citations across docs/Disaggregated/*.md, 0 problems.
2026-09-18 23:31:39 -04:00

388 lines
29 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# c1-v2 — R-17's routing, the reply mailbox, and the first IPC frame
Branch `p5/c1`. Base `d628d906` (round 1), then three merges and one work commit:
```
d628d906 c1 round 1
87c1e1be Merge feat/disaggregated (5e5bf7b9) ID-44, step 0
4ba14fa4..571cbabb (via) Merge p5/v1 see §2
02f15bb6 [Feat] R-17 - the routing c1's round-2 work, 25 files, +2336/-273
41992649 Merge feat/disaggregated (39292958) s1 round 3 / ID-47's helper, t1, w1, b1
```
Commit range **`d628d906..41992649`**. c1's own commit is `02f15bb6`.
---
## 1. What landed
| area | file | before | now |
|---|---|---|---|
| the generator's one asymmetry | `scripts/gen_pipe.py` | a `kVarTail` row's table signature gained `varTail`+`varTailCount`; a `kHasBlob` row gained nothing | 5 lines: a `kHasBlob` row gains `const void* blobBytes, Uint64 blobByteCount`. 10 rows changed |
| the monolith arm | `MG_Pipe/PipeRoute.{h,cpp}` **(new)** | `gMGPipeScreen`/`gMGPipeContext` were **never installed** — every entry null | 33 generated rows + 4 escapes installed; the reply mailbox; 37 `MGPipeRoute*` call-site names |
| the client arm | `MG_Remote/Client/WireTables.{h,cpp}` **(new)** | `gMGPipeWireRecordApply` had no encode twin | 37 emitters over `EmitAndWait`, installed at the end of `Start`, uninstalled at the top of `Stop` |
| the call sites | `MG_Impl/Pipe/*` (8 files) | 40 direct `MGPipeApply*` calls | 40 `MGPipeRoute*` calls; `MGPipeApplyVerifyCorruption` untouched |
| R-13.2 / R-13.3's missing producers | `MG_Impl/Pipe/PipeFill.cpp` | a split respecify carried `initialBytes`; a split flush carried none | the content follows as `resource_subdata`, exactly as CONTRACT §2 rows 19/20 prescribe |
| the acceptance answers | `MG_Remote/Wire/PipeWireCodec.cpp` | `noteAcceptance` recorded them and posted nothing | 4 lines: it `PostReply`s. **w1's file — see §7** |
| the EGL seam | `MG_Remote/Client/BackendObject_Remote.cpp` | private trampolines over `RunOnApplyThread` + `Backend()` | v1's twelve `Server*` forwarders; −188/+~60 |
| `m_started` | `MG_Remote/Client/ClientSession.cpp` | **never set** — round 1 dropped s1's line | set before `g_active`, with the order stated |
| ID-47 | `MG_Remote/Client/EmitTables.cpp` | a local copy of the refusal | s1's `ClientSession::RequireReadPixelsReplyFits` |
| ID-49 | `MG_Remote/Client/EmitTables.cpp` | `DstSize` was GL 8.4.4's **packed** size | `DstSize` is the **tight** `w*h*bpp`; the client scatters the rows |
| the ID-31 fallout | `MG_Test/Wire/PipeWireCodecTest.cpp` | `:1203` asserted `ResourceCreate` has no reply slot | the rule kept, the row moved to one that is really `kNone`; 3 sibling assertions updated; 1 case added |
| R-8's negative control | `MG_Test/SanityTest.cpp` | the accessor had a counted refusal; the GATE did not | `ACapsMaskWithoutTheResourceFamilyEmitsNothingAndCountsTheRefusal` |
---
## 2. Two merges that were not in the charter, and why
**`p5/v1` is merged into `p5/c1`** (`4ba14fa4..571cbabb`). The coordinator put two edits in *c1's* files into this round's
scope — `m_started`, and routing the EGL virtuals through v1's twelve `Server*` forwarders — and the second one names
symbols that exist only on `p5/v1` (`ServerLoop.h:196-212`). There was no way to ship a *compiling, tested* version of
that edit without v1 in the tree. One conflict, `MG_Test/Wire/CMakeLists.txt`, the same-point-append shape; both blocks
kept, and the second merge turned it into a `foreach` over three names so there is no fourth conflict.
**`feat/disaggregated @ 39292958` is merged** (s1 round 3, ID-47's helper, plus t1/w1/b1). Two conflicts, both trivial
(`ClientSession.cpp`'s include block; the same CMakeLists).
**The integrator merging v1 first and c1 second is unaffected** — v1's commits are already ancestors, so nothing is
duplicated. It does mean the diff of `p5/c1` against the integration head is 45 files rather than 25; `git show 02f15bb6`
is c1's work by itself.
---
## 3. R-17's real size versus the estimate
R-17 costed it as "~41 direct call sites converted to the `MGP_*` thunks, the two install functions, and 37 thin client
emitters over `EmitAndWait`". **The call-site number was exactly right (40, measured). The emitters really are thin. The
ROUTING was not, and it is bigger by four rows and one whole mechanism.**
The generated table signature is the **P2-era monolith interface**: `void (*Name)(const Payload*, ...)`,
async-with-handle, no return value, no companion pointer. Of the 37 apply entry points, as the tables stood
(`~/w7/p5-c1-r2-sigdiff.py`, which prints the pairing):
| | count |
|---|---|
| the row could carry every argument the call site passes today | **24** |
| it could not | **13** (14 counting `SetResidualValueState`'s type mismatch) |
The thirteen split three ways, and only the first is a generator question:
**(a) Nine carry a blob companion** — `chunkBytes`, `blobBytes`, `parameters`, `bytes` — which is CONTRACT §2 table 1's
"companion pointer today" column. This is the whole generator change and it is **five lines** in `Call.Signature`: a
`kHasBlob` row gains `const void* blobBytes, Uint64 blobByteCount`, *exactly* as a `kVarTail` row already gains its pair.
Ten rows gained it (the nine plus `GetCaps`, which has no applier). `--check` up to date, `--self-test` 9/9 trips,
`gen_pipe_field_ownership --check` up to date. No `.def` file was touched.
**(b) Four return a value the row cannot** — `ResourceCreate`, `ResourceRespecify`, `ResourceSubData`,
`SetTextureParams` return `Bool`, `MapPersistent` returns `void*`. These are exactly CONTRACT §2's reply-slot rows.
`MGPReplySlot` is `{Uint64 Id;}` — an **identifier, not a value** — so a *reader* had to exist before minting one meant
anything. That is the reply mailbox (§4), and it is the part of R-17 that no amount of "thin emitter" covers.
**(c) Four cannot go through a generated row at all**, each for a written-down ruling. They are a hand-written third
table, `gMGPipeRouteEscapes`, installed and uninstalled by the same two functions so there is one mechanism and not two:
| row | why | what would overturn it |
|---|---|---|
| `ResourceRespecify` | `initialBytes` has no `kHasBlob` and R-13.3 forbids giving it one | give `MGPResourceDesc` a blobref (c0's `MGPipeTypes.h`) |
| `ResourceFlushRange` | R-13.2: a blobref here "would be a second, forgeable way to say the same thing" | the same |
| `MapPersistent` | `size` + `seedBytes` have no carrier (`MGPHandleOnly` is `{Handle, Kind}`) and it returns `void*` | give `MGPHandleOnly` a size, and P6 a real remote map |
| `CreateShaderState` | **seven** blobrefs (`Spirv[6]` + `Reflection`) and two typed frontend pointers; one `blobBytes` pair cannot express seven runs, and serialising under monolith to deserialise in the adapter would put `EncodeProgramArtifacts` on the monolith path, which `PipeApply.h` explicitly promises it is not | measure that a per-stage SPIR-V run beats one archive |
So: **33 rows through the two generated tables, 4 through the escapes, 37 total** — and `PipeCatalogueTest` asserts both
numbers, because a row moved out of the generated tables with its escape forgotten would otherwise read only as a
smaller count while its call site took a null.
**Three of the 37 wrappers take one argument more than their applier**, and the extra is always a byte count the record
does not declare (CONTRACT §2 rule A requires it under split; five rows already declare and the wrapper reads it back):
`SetGlobalConstants` (the length is `GetUBOSize()`), `ResourceSubData`'s **texture half** (`levelBytes` — this closes
row 7's open half, "the byte count is the server's to compute", which table 1 itself says "cannot be a bounds check"),
and `BufferSubDataResident`. A defaulted argument was rejected: a default lets a site that *has* the number forget it and
still compile, and the failure is a silently short upload.
---
## 4. Every ruling made this round, with evidence and what would overturn it
**R-17.1 — the reply mailbox is one entry deep, thread-local, and has no default answer.**
Evidence: `ReplySlot.h` — "under R-1's verb barrier the in-flight depth is one". A second posting before the first is
taken is not a capacity problem, it is a barrier that has stopped holding, so it is `Fatal{ReplyOverrun}`. A take with
nothing posted is `Fatal{ReplyMissing, "<row>"}` — **not `false` and emphatically not `true`**: "always accept" is
ID-39's 66 lost uploads and "always refuse" is an emitter that re-sends for ever. `ERROR` is refused as an acceptance
answer at all (a transport fault is not a resource decision). Overturned when R-1's barrier retires for a family: the
mailbox becomes a slot pool keyed on seq, which is what `Transport::ReplySlot` already is on the wire side.
**R-17.2 — the install is driven by an `inline` variable in the header, not a static initialiser in the .cpp.**
This one was **found by the gate, not designed**. The first version put the installer in `PipeRoute.cpp`'s dynamic
init, on correct reasoning about constant-initialised inline variables — and five `CsoCacheTest` cases SEGFAULTed in the
push and verify lanes, because every `MG_Test` target is its own binary over a static archive, `CsoCache.h` reaches the
table through an inline thunk and names no symbol in `PipeRoute.o`, so the linker dropped the object. The shared library
linked it and was fine, which is the shape that ships. An inline variable fixes both halves: its initialiser is a COMDAT
in every TU that includes the header, and naming `MGPipeInstallMonolithTables` from that header forces the archive
member into the link. Overturned by a toolchain that defers inline-variable dynamic init past first use.
**R-17.3 — the client emitters run the MONOLITH adapter when they find themselves on the server role's thread.**
The second gate-found defect, and the more serious one. `gMGPipeScreen`/`gMGPipeContext` are **process** globals; under
`inproc` the server role is a thread in the same process, so the apply thread running the server's own backend (the EGL
bring-up, `InitCapabilities`, the applier) reaches these very emitters. The first joint run died
`Fatal{BarrierTimeout, "ResourceRespecify"}` logged by **`mgl-srv-apply`**, thirty seconds in: the apply thread had
published a record and was waiting for itself to apply it. The predicate is v1's `ServerLoop::OnApplyThread()`; the
answer is not "suppress the record" but "run the server's own code", which is what `PipeWireCodec` already does on the
decode side. Under `spawn` it is constantly false in one process and constantly true in the other, so it costs one
atomic load. **This is also what makes the integrator's `ScopedApplierEntry` bracket safe to add** — on the apply thread
the emitters never reach `EmitAndWait` at all.
**R-13.2 / R-13.3 — the contract's prescribed follow-ups had no producer, and now do.**
CONTRACT §2 row 19 says initial content "arrives as `ResourceSubData` records immediately after this one" and row 20
says the flush's bytes "arrive ahead of it". Nothing emitted either. Evidence: the joint run died
`Fatal{UncarriedInitialBytes, "resource_respecify"}` on the first `glBufferData` with data, and then
`Fatal{ProtocolCorruption} resource_flush_range ... a non-empty flush carries no bytes (offset=0, size=120,
storage=120 bytes)`. Both are now emitted through `MGPipeForEachSubDataRecordRange` — the contract's own route ("reuses a
path that is already chunked and already acceptance-gated") — **split-only**, because under monolith the applier reads
`initialBytes` directly and a second upload would be a real change in the control arm. The flush stages **exactly** its
own range, never the whole buffer, because widening is what ID-37 forbids. Overturned if a caller is found that needs
the bytes and the range in one record — which cannot happen while the barrier holds.
**ID-49 — `DstSize` is the tight extent and the client scatters.** Ratified as issued and implemented; the emitter keeps
a zero-copy fast path when the pack state is neutral, and `TheFastPathIsTakenExactlyWhenTheScatterWouldChangeNothing`
drives the predicate and the scatter together, because testing either alone would pass a predicate that said "tight" for
a layout the scatter would have rearranged. The rule is format-agnostic, so the depth/stencil reads the 21 split entries
touch take it with no special case.
**Ratified from round 1, no further debate, and unchanged:** `MGPClear::Kind` (`kRemoteClearWhole` only); the `Fbo` and
`ReadFbo`/`DrawFbo` nulls; `OnReadPixels` writes exactly `DstSize` bytes — which ID-49 now defines as the tight extent,
so "exactly `DstSize`" means "into the reply", and the application's layout is the client's business.
**R-12 — which of the four reverse-channel arms are wired.** Asked and answered: **`OnGpuWritten`, `OnBufferWriteback`
and `OnSurfaceChanged` are wired; `OnCapsInvalidated` is not, and deliberately.** DirectGLES has no
`OnCapsInvalidated` producer at all; c0's ruling is that a **second CapsSnapshot arrival IS the invalidation**, and v1's
`ServerMakeEGLCurrent`/`ServerInitCapabilities` republish one. The joint log shows it working:
`CapsMirror generation 2 adopted`, then `generation 3`. So the fourth arm has a *consumer* and no *producer*, on
purpose, and adding one would be an eleventh `MGPipeCallbacks` slot for something already expressible.
---
## 5. The four self-tests
On `41992649`, five build dirs, all configure + build `rc=0`.
**G1 — against the ID-44 baseline (`~/w7/p5-before-libMobileGL.so.READY` = `4595163c`):**
```
.text 10806611 -> 10806611 (+0, +0.000%)
27814 -> 27814 defined symbols: 0 added, 0 removed, 0 resized, 0 renamed
nm --defined-only build-linux/libMobileGL.so | grep -ic MG_Remote -> 0
nm --defined-only build-split/libMobileGL.so | grep -ic MG_Remote -> 602
```
R-17 predicted "push-build-only, so G1 should be free". It is, and the proof is structural as well as measured: every
`MG_Impl/Pipe/*Emit.h` body is inside `#if MOBILEGL_PIPE_PUSH`, `PipeRoute.{h,cpp}` is inside it, `WireTables.*` is
inside `#if MOBILEGL_BUILD_DISAGGREGATED`, and the two tables are inline variables that stay zero in a pull build.
**`ctest -L unit`, five lanes:**
| pull | push | verify | split | verify-split |
|---|---|---|---|---|
| **1816 / 1816** | **1816 / 1816** | **1816 / 1816** | **2025 / 2025** | **2025 / 2025** |
All five 100%. The two split reds the charter listed are both gone: `PipeWireCodecTest:1203` is this package's fix,
`RingTest.TheTwoFlagSpacesAreDisjointByTranslation` is s1's and arrived with the second merge.
**`ctest -L integration-gpu`, `build-push`, `MOBILEGL_TRANSPORT=monolith`: 1128 / 1128, 0 failed.** G2 green.
**Generators:** `gen_pipe --check` up to date, `--self-test` 9 trips + positive control OK,
`gen_pipe_field_ownership --check` up to date, `check_include_closure` 4 probes / 0 problems.
**G2 / G14 names** (`~/w7/p5-c1-r2-names.sh`; `LC_ALL=C` for both the sort and the comm):
baseline 2902, push 2944, split 3174. **push-vs-baseline: 0 removed**, 42 added. **split-vs-push: 0 removed**, 230
added, of which **21 are `DirectGLES.Split.`** entries.
One note for the next package that renames a case: **a rename is a removal to G2/G14.** Rewriting
`PipeCatalogue.UninstalledTablesAreAllNull` cost one removed name, which is indistinguishable from a deleted case from
the gate's side. The name is kept, asserting the half that is still true (the 34 unrouted rows are null), and the new
statement is an added name beside it.
**G5, the untouched regions:** `scripts/p3a_untouched_regions.sh ff2994d9 HEAD` and the p4a twin are **both rc=0** on
this head — b1's ID-41 re-pin arrived with the second merge, so the one admitted red is closed and nothing else moved.
---
## 6. `integration-split`: what arms it, and the first IPC frame
**`MOBILEGL_TRANSPORT=inproc`, `build-split`, `ctest -L integration-split`: 14 / 21 pass.**
Both `TriangleScenario` entries and all five `ClearThenReadPixelsScenario` entries pass, on **both** the default and the
`SmallRing` arm. **The first IPC frame on the reduced path renders.**
**What arms the lane** — the charter asked for this precisely, so: `InstallClientWireTables()` is called from **the end
of a successful `ClientSession::Start`, step 9, on the GL thread (the thread that called `MG_Backend::Init()`), after
`ServerLoop::Start` has returned**. Each of the four orderings is a different failure:
1. after Hello/Welcome — an emitter publishing earlier writes into a ring the peer has not mapped;
2. after the first `CapsSnapshot` — R-8's liveness gates read the caps mirror, a placeholder mirror consumes nothing, so
a record emitted earlier goes to a server this client has not been told consumes that family;
3. **after `ServerLoop::Start`** — `EmitAndWait` blocks on `appliedSeq`, and with no apply thread the first
`resource_create` spends 30 s in the barrier and then `Fatal{BarrierTimeout}`;
4. on the GL thread — table 3 makes `gPipeInputs` its to touch while the barrier holds, and installing from the apply
thread would publish the tables to the GL thread with no synchronisation at all.
`UninstallClientWireTables()` runs at the **top** of `Stop()`, before the rings go away, and puts the **monolith
adapters back** rather than nulling the rows: a null row is the pre-migration state and would be an undiagnosed crash at
whatever GL call raced teardown.
**The 14/21 is measured WITH the integrator's merge-time one-liner in `MG_Backend/Init.cpp` applied locally, and c1 did
not commit it** (the coordinator ruled it v1's). Without it the lane is **19 failed / 21** on this head, all of them
v1's weak `CreateRemoteBackendObject` placeholder aborting — and note that the failures are *aborts*, not skips, because
t1's ID-48 work made the split entries `MOBILEGL_ITEST_REQUIRE_GPU`. The exact patch is reproduced in
`~/w7/p5-c1-r2-redcheck.py` (`init_patch`), where two controls depend on it.
**The remaining 7 are one root cause, and it is a server-side seam, not c1's.** All seven are
`PersistentCoherentMapScenario` (both arms) and all seven abort with
```
Fatal{ProtocolCorruption} resource_flush_range {slot=1, gen=0, glName=1}:
a non-empty flush carries no bytes (offset=0, size=120, storage=120 bytes)
```
`MGPipeApplyResourceFlushRange` (`PipeApply.cpp:1873`) faults when `record.Size != 0 && bytes == nullptr`, and the
decode arm passes `nullptr` unconditionally (`PipeWireCodec.cpp:1665`) — correctly, because R-13.2 says the record
carries no bytes under split. The client half is landed (the covering `resource_subdata` now precedes the flush); the
consumer half has to read those bytes from v1's server-owned `StagedShadowStore` (R-11 / ID-37) instead of from a
companion pointer that no longer exists. **That is the only thing between 14/21 and 21/21.** The same seven are the only
`integration-gpu` failures in `build-split` under monolith (1149, 7 failed).
---
## 7. What v1, w1 and the integrator must provide
1. **`MG_Backend/Init.cpp`'s direct `MakeUnique<BackendObject_Remote>()`** — v1's file, the integrator's at the merge.
Without it nothing in the split lane runs.
2. **`PipeApplier::ApplyOne`'s `ScopedApplierEntry` bracket** — v1's file, the integrator's at the merge. Until it lands
`ApplyThreadIsInsideApplier()` is permanently false and R-1's mutual-exclusion assertion is inert. §4's R-17.3 makes
it safe to add.
3. **`resource_flush_range`'s bytes under split** (§6) — the last blocker for the 7. `MG_Pipe/PipeApply.cpp` +
`MG_Remote/Wire/PipeWireCodec.cpp`; c1 did not touch either arm of it.
4. **`MG_Remote/Wire/PipeWireCodec.cpp`'s `noteAcceptance` now calls `PostReply`, and that file is w1's.** The hunk is
four lines inside one lambda. It is made under R-17 because it is the server half of the routing R-17 assigns, and
because the file's own comment named this as the pending edit: it said the answer could not ride a slot "until the
integrator rules on which half of the contract moves (table 0 says these four use DECLINED; the catalogue gives them
no slot)". Both halves have since moved the same way — ID-31 gave `ResourceCreate` the flag and `kMGPipeCallFlags`
now carries it on all four (`PipeWire.inc` rows 2, 3, 47, 48), and R-17 says the acceptance answers come back through
the reply slot. **Without it the client cannot run at all**: `EmitAndWait` asks the catalogue, not the caller, so all
four rows would wait for an answer nobody wrote and take `Fatal{ReplyMissing}` inside the barrier. Move it if it
belongs elsewhere; the diff is self-contained.
5. **One CMakeLists line each** for `MG_Pipe/PipeRoute.cpp` (the `MOBILEGL_PIPE_PUSH` list) and
`MG_Remote/Client/WireTables.cpp` (the `MOBILEGL_BUILD_DISAGGREGATED` list). Root `CMakeLists.txt` is c0's; R-17
grants the generated-table install and a build line is inseparable from it, but it is flagged rather than smuggled.
**On v1's note about §8.4.** v1 is right and round 1's report was wrong: `TriangleScenario` does **not** fail without the
37-entry routing under `inproc` — the P3a handle arm defers non-owner-thread GL touches and the apply thread drains them
at the draw, so it renders **right by accident**. That is not evidence against R-17; it is the strongest possible
argument *for* it, and it is ARCHITECTURE 10.3's exact shape. A green triangle produced by a client that executed every
resource, CSO and program record synchronously on the GL thread is a split lane running monolith, and the thing that
makes the difference visible is not the picture but `ClientWireRecordsEmitted()` — which is why t1's fourth arming fact
is "the client encoder's record ordinal actually moving during the case" and not "the scenario passed". The round-1
claim should be read as "needs the routing to be *split*", never "will not render".
---
## 8. R-16: I made every gate red once, by doing X
`~/w7/p5-c1-r2-redcheck.py`, log `~/w7/p5-c1-r2-redcheck.log`. It extends round 1's harness with a per-case target and
binary (so a control in `PipeCatalogueTest`, `SanityTest`, `PipeWireCodecTest` or the integration binary is driven the
same way) and a multi-edit form for the controls whose subject is a scenario.
**Run it with `python3 ~/w7/p5-c1-r2-redcheck.py`.** Result: **20 / 20 RED, `CONTROLS_THAT_DID_NOT_GO_RED=none`**,
all four unit binaries green again afterwards (26 / 106 / 66 / 32 cases).
| control | I made it red by |
|---|---|
| R1 the install fills the escape table | commenting out `gMGPipeRouteEscapes.MapPersistent` |
| R2 the install is reachable from a header | replacing the inline variable's initialiser with `true` |
| R3 a missing answer Fatals | renaming the `ReplyMissing` tag |
| R4 a missing answer is not silently false | `if (g_reply.Slot == 0)` → `if (false)` |
| R5 two outstanding answers are a barrier fault | renaming the `ReplyOverrun` tag |
| R6 ERROR is not an acceptance answer | renaming the `ReplyError` tag |
| R7 DECLINED is COUNTED | `if (g_reply.Status == 1) ++Declined` → `if (false)` |
| R8 DECLINED is not folded into accepted | `return true;` |
| ID47-a the boundary is the pool's real cap | `CanHold` → `m_base != nullptr` |
| ID47-b the emitter really asks the helper | passing `tight * 1000` (split scenario aborts by name) |
| ID49-a `DstSize` is the tight extent | `+ 16` |
| ID49-b the scatter honours the skips | dropping the skip terms from the destination |
| ID49-c the scatter writes the ROW, not the stride | `writtenPerRow` → `strideBytes` |
| ID49-d the fast path equals the scatter | `\|\| true` in `ReadbackPackStateIsTight` |
| ID31 the acceptance rides the slot | deleting the `PostReply` from `noteAcceptance` |
| ID31-b the status agrees with the applier | hard-coding `kStatusOk` |
| R8 the liveness gate reads the mirror | putting `MGPipeGetResourceOps() != nullptr` back |
| R17 the role gate keeps the apply thread off the wire | `RunsAsTheServerRole()` → `false` |
| v1-seam `m_started` before `g_active` | deleting the line |
| R13.3 the bytes follow as sub-data | deleting the follow-up walk |
**THE HARNESS ITSELF WAS THE FIRST THING THAT FAILED FOR THE WRONG REASON, TWICE, AND BOTH ARE WORTH THE LINES.**
*First:* the opening run printed `BUILD-BREAK (also a red)` for **all twenty** controls **and for the restore** — the
submodule symlinks had been toggled off for a git command and never toggled back (PACKAGE-PREAMBLE trap 1). Twenty
controls "going red" for a reason that had nothing to do with any of them is R-16's own failure mode one level up. The
harness now has a **preflight** that builds all five targets *before anything is broken* and exits with "a red measured
against a broken baseline is not a red" if any of them fails.
*Second:* two controls reported `STILL GREEN` while in fact aborting exactly as designed — a control whose subject is a
`Fatal` kills the process with `SIGABRT`, so gtest never prints `[ FAILED ]` at all, and the harness was looking only
for that string. The return code is now part of the verdict.
*And two controls were mis-aimed rather than the code being wrong*, which is the third shape: ID49-d broke a function
its named case never called, and R13.3's subject produced no observable difference in any scenario's **picture**,
because every P5 scenario re-uploads its vertices through the ordinary dirty path afterwards. ID49-d got a case that
drives the predicate and the scatter together; R13.3's producer got a **counted self-check** — it compares
`ClientWireRecordsEmitted()` across the walk and `Fatal{InitialBytesNotCarried}`s if nothing was emitted, so the
statement "the content followed" is made where it can be made instead of left to a lane that cannot see it.
---
## 9. The G1 codegen trap (round 1) — self-contained, for ARCHITECTURE/MEASUREMENTS
> **A Bool-valued macro is not a drop-in replacement for a pointer-valued condition, and the difference is 144 bytes of
> `.text`.** CONTRACT-P5 §7 requires the 41 call sites that null-check a `GLFunctionsTable` slot to stop doing so under
> split, because with no null slot in the client's table every one of those checks answers "supported" and the fallback
> behind it silently disappears. The obvious conversion is a macro that answers the capability question as a `Bool`:
> `if (MGL_BACKEND_SLOT_CAP(Slot, kCapX))`. In a *pull* build that macro expands to exactly the null check it replaced,
> so it looks free. It is not. Two sites in `GL_Getter.cpp` were written as `if (const auto f = TABLE.GL.Slot)` — a
> condition **with an init-statement** — and rewriting them as `if (BOOL_MACRO) { const auto f = TABLE.GL.Slot; ... }`
> is semantically identical and generates different code: G1 came back `.text -144` with **2 symbols resized**,
> `GLImpl::GetInteger64v` −150 and `GLImpl::GetIntegerv` +2. The fix is a second spelling,
> `MGL_BACKEND_SLOT_PTR_CAP` / `_PTR_LOCAL`, which in a pull build expands to **the slot expression itself**, so the
> init-statement survives verbatim and the codegen is byte-identical. `GL_Sync.cpp`'s `FenceSync` had the same shape and
> did *not* happen to move; it was converted to the pointer form anyway, because "did not happen to" is not a property.
> **The general rule: when a gate requires byte-identical codegen, a macro must preserve the EXPRESSION SHAPE of what it
> replaces, not merely its truth value.** A rewrite that changes an init-statement into a block, a short-circuit into a
> call, or a pointer into a `bool` is a codegen change even when it is not a behaviour change.
---
## 10. Debts
1. **`resource_flush_range`'s bytes under split** (§6, §7.3) — the 7 remaining split entries. Not c1's arm.
2. **`MapPersistent` under split is asserted to DECLINE, loudly.** `Wire_Escape_MapPersistent` Fatals if the server ever
*accepts*, because a host pointer arriving there is one this client cannot dereference. R-6 says it never will; when
P6 gives it a real remote map, that Fatal is the line to change.
3. **`MarkGpuWritesForDispatch` still has no gate** (round 1 §11.2) — `DispatchCompute` is class C.
4. **The XFB span family still needs an `MGPCapBit`** (round 1 §11.3) before its probes can move; that is an
`MGPipeTypes.h` edit, i.e. c0's.
5. **`Encoder().MaxRecordBytesSeen()` still has no `PipeStats` publisher**, so R-10's MEASUREMENTS number is still
unowned. `SetGlobalConstants` is the row most worth watching — per program per frame, unbounded length — and it is
now a real staged blob rather than a companion pointer, so the number finally means something.
6. **E2's emitter-drop control is still armed and still not RUN by c1** (round 1 §11.1). `MOBILEGL_IPC_E2_DROP_CLEAR=1`
is read with `getenv` because `Config.h` is c0's; adopt it into `IpcTable` or tell me to take it out.
7. **The three-way merge in `p5/c1`** (§2). If the integrator would rather have c1 standalone, the work commit
`02f15bb6` is a clean cherry-pick onto any tree that already has v1 — but the two coordinator-assigned edits in
`BackendObject_Remote.cpp` will not compile without v1's `ServerLoop.h`.
---
## 11. Files and scripts (the ones this report cites; the rest are deleted)
- `~/w7/p5-c1-r2-redcheck.py` / `.log` — R-16, 20 controls, with the preflight and the return-code verdict.
- `~/w7/p5-c1-r2-sigdiff.py` — §3's table: all 37 apply signatures beside the generated row that replaces them.
- `~/w7/p5-c1-r2-build.sh`, `-units.sh`, `-integ.sh`, `-names.sh`, `-isplit.sh` — the five cells, the four self-tests,
the integration lanes and the G2/G14 comparison.
- `~/w7/p5-c1-r2-jointdbg.sh` / `-jointrun.sh` — apply the integrator's merge-time `Init.cpp` one-liner, drive one split
scenario with its log captured, revert. This is how §6's numbers and §4's two defects were found.
- `~/w7/p5-c1-r2-symbols.md` — G1's symbol report.