Files
MobileGL/docs/Disaggregated/notes/p5b/p5b-results/p5b-close-codex-review.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

196 lines
14 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.
# P5b phase-close Codex review
Date: 2026-09-16. Reviewed tree: `/home/swung/w7/p5b-integrate-codex`.
Pinned target: **348d22a4b9c15cc571af840dedc4b4edc8c53dbb**; diff base: **37fc4fdb**.
HEAD was rechecked at the end and still matched. This is the phase's one closing review,
not an additional implementation-round review.
**Verdict: 0 blocker, 2 major, 1 minor.** The two new major findings concern the now-live
user-index carrier and the now-live blocking sync call. The minor is the previously named
ReadPixels reply-status gap, which remains present. Findings below are source-confirmed;
no new runtime reproduction, mutation, build, broad test, or device operation was performed.
They do not claim that the four selected Minecraft targets exercise these edge cases.
## Findings
### 1. A user-index span can declare fewer bytes than the draw consumes — major
Locations:
- `MobileGL/MG_Remote/Wire/PipeWireCodec.cpp:1049`: encoder host-span check.
- `MobileGL/MG_Remote/Wire/PipeWireCodec.cpp:1966`: decoder host-span check.
- `MobileGL/MG_Remote/Server/PipeApplier.cpp:555`: the sink resolves the span.
- `MobileGL/MG_Remote/Server/PipeApplier.cpp:593`: the ordinary indexed arm hands the
resolved pointer and independent range count to the backend; the other indexed arms do
the same at lines 582, 586, 590, 598, 602, 607 and 610.
`CheckHostSpanIsHonest` proves that **the declared** `Offset + Size` lies in a registered
segment. Neither codec direction compares `Size` with `MGPDrawRange::Count * IndexSize`.
The sink casts `range.Count` to GLsizei and passes it on without that check. Once the pointer
is resolved, `span.Size` no longer constrains the backend's reads.
Concrete corrupt-record trigger: one direct indexed draw, `IndexSize=2`, `NumDraws=1`,
`Flags=kDrawHasUserIndices`, range `{Start=0, Count=3, IndexBias=0}`, and a null-Ptr span
`{Seg=SEG_STAGE, Offset=segment_capacity-2, Size=2}`. The existing layout, tail-size and
four honesty checks all accept this shape. The sink then asks the backend to consume six
index bytes from the last two bytes of the segment. Even away from the segment boundary,
this can consume bytes from an adjacent staged allocation rather than the declared run.
This is a newly armed P5b carrier-boundary defect, not the documented P8 host-index mirror
deferral. The ordinary emitter currently stages `count * indexSize`, so a healthy emitter
does not itself produce the mismatch; the missing defense is against corrupted/inconsistent
wire input, which the codec expressly promises to reject before handing the sink validated
arguments. No driver read outside memory was deliberately executed during this review.
Suggested bounded fix: share a DrawVbo user-index validation helper between encode and
decode. For the supported one-range client-index shape, validate the index width, range
shape and stage carrier, and require the declared run to cover the count-derived extent
(the producer's exact-size contract permits equality). Use checked/widened arithmetic.
Keep the already documented multi-draw client-index refusal. A focused short-span negative
case and its exact-span positive counterpart are sufficient evidence for this finding.
### 2. A legal long ClientWaitSync is cut short by the 30-second transport watchdog — major
Locations:
- `MobileGL/MG_Remote/Client/EmitTables.cpp:1483`: `EmitClientWaitSync` preserves the
application's Uint64 timeout, then calls `ReadFenceReply` at line 1471.
- `MobileGL/MG_Remote/Server/PipeApplier.cpp:127`: `OnFenceWait` forwards that timeout
unchanged to the native backend at line 137.
- `MobileGL/MG_Remote/Client/ClientSession.cpp:126`: fixed `kBarrierTimeoutMs = 30000`.
- `MobileGL/MG_Remote/Client/ClientSession.cpp:779`: all reply-owning records use that
fixed timeout for `WaitForApplied`; line 797 aborts on expiry.
- `MobileGL/MG_Backend/DirectGLES/DirectGLES.cpp:12114`: the backend synchronously waits
in native `glClientWaitSync`. DirectVulkan's wait entry at `DirectVulkan.cpp:1045` is
also reached through the same client deadline.
Concrete trigger: an unsignaled fence and
`glClientWaitSync(sync, GL_SYNC_FLUSH_COMMANDS_BIT, 60000000000ULL)`, while valid queued
work keeps the native wait outstanding beyond 30 seconds. The server is still carrying out
the application's permitted 60-second wait, so it cannot post the result or advance
appliedSeq yet. At 30 seconds the client aborts with `Fatal{BarrierTimeout,"FenceWait"}`
instead of returning the eventual native wait result. A timeout longer than 30 seconds is
not rejected by frontend GL validation and CONTRACT-P5B's sync appendix preserves the
64-bit timeout. This is different from a wedged ordinary verb: the call explicitly authorizes
the server to remain inside it for that interval.
Suggested minimal fix: derive the **applied/reply** wait budget for `FenceWait` from its
declared timeout, plus the existing transport grace period, leaving command-capacity waits
and all other opcodes unchanged. Round nanoseconds upward, handle overflow and the doorbell's
Uint32-millisecond / wait-forever sentinel deliberately, and retain shutdown wakeup. A budget
helper can be tested with 0, a short wait, 60 seconds and UINT64_MAX without a 30-second sleep.
Alternatively split the server's native wait into bounded pieces while preserving the full
client-visible timeout and final GL result; merely clamping the native timeout changes GL
semantics and does not close this finding. Update the timeout diagnostic to report the actual
selected budget. `FenceWaitServer` is a server-side GPU ordering call and should not inherit
the application's GL_TIMEOUT_IGNORED as a CPU deadline by accident.
### 3. ReadPixels still accepts an unknown reply status when the byte count matches — minor
Locations: `MobileGL/MG_Remote/Client/EmitTables.cpp:863`, used at lines 969 and 982;
the stricter exposed predicate is at line 1792.
`RequireReadbackReplyComplete` rejects ERROR and DECLINED individually, then checks only
the byte count. An exact-sized reply with status 3 (or another non-OK value) passes and is
returned/scattered as pixels. `ReadbackReplyIsComplete` correctly requires status OK, but
the production helper does not invoke that predicate. Reply-slot reading does not reject
unknown status values earlier.
This was already named in the P5 close review's unassigned-debt section and r2's follow-up
table. It is not a newly observed normal server output: the production server currently posts
the expected statuses. Close it by requiring OK after the named ERROR/DECLINED diagnostics,
and drive the actual live readback return path with an exact-sized status-3 answer. Testing
only the exposed stricter predicate would miss the current disconnect again.
## Previous P5 findings 1–13
The inspected integration contains the intended r1/r2 repairs. No additional defect in those
repairs was established during this review. This is source review plus inspection of the
package evidence references, not a claim that their runtime controls were rerun here.
| Prior finding | Reviewed disposition at this target |
|---|---|
| 1 coherent-map server producer re-entry | Backend sync early-outs on the apply role; producer guards precede map reads / serial mutations. r1's client-only suppression report addresses the earlier shared-knob blind spot. |
| 2 frontend framebuffer death | The callback synchronously uses the apply control mailbox before twin destruction/cache edits; reentrant server calls stay on the apply thread. P6 still owns separate-process lifetime transport. |
| 3 PACK_SWAP_BYTES | Client applies component/packed-word swaps on both tight and scatter paths, with the mixed float/depth-stencil type split into two 32-bit words. |
| 4 false RingOverrun on delayed retirement | Staging waits after immediate reclaim; command retry retains both draw tails and accounts for wrap padding. Individually oversized allocations still refuse. |
| 5 census prevents CI controls | Broad inproc status is recorded as debt; hard reduced gates remain; negative controls have `!cancelled()`. |
| 6 pull control poisons following draw-drop | Frozen library backup/EXIT restoration exists; both controls check library symbols, including nm failure. |
| 7 intentional E3 skips and combined diagnostic | E3 selects the four pixel cases; assertions and private logs are checked per selected entry. |
| 8 reclaim count mislabeled as wait | Immediate reclamation does not increment waits; outstanding-retirement blocking does. SmallRing asserts an actual wait as well as wrap. |
| 9 all-skip false green | Baseline failure/nonzero exit/all-skip rejects; CI has the runtime-only nonempty-success tally. |
| 10 optional EGL unit proof | Split unit CI explicitly requires GPU. |
| 11 census zero-run / stale log | Updated external runners clear private logs before launch, reject zero executed gtests, and retain process-status distinctions; these external tools still must accompany the integration. |
| 12 pin self-test bypasses production selection | Both revised self-tests call production `extract_baseline`, rather than directly testing the pin helper alone. |
| 13 obsolete c1f test name | The runner selects the current different-tuple case and checks the identical-tuple companion in baseline/restoration. |
## Scope and limits
Read CONTRACT-P5/P5B, the P5b brief, prior P5 closing review, and the r1/r2/d1/i1/t2/f1,
named-blit, mip and sync reports; inspected the affected emit/codec/sink/lifetime paths and
CI/control changes. Also inspected the new Redmi runner/reducer's exact-head prerequisites,
fresh attempt paths, fixed serial, stage profile and completeness checks. No new general
runner false-green finding was established.
The 256 MiB stage profile is explicit and applies to the four A/B arms; the production
32 MiB default and its large-upload boundary are recorded limits. The named-blit scoped
binding override and mip descriptor's existing identity lookup remain intentional inproc
barrier dependencies. They are not claimed as spawn-safe. Client vertex arrays, resource
identity pulls, P7/P8/P9 readback/query work, rd12, and the known deferred shapes remain their
recorded debts, not newly relabeled blockers in this review.
In particular, i1's old comment claiming the missing copy shadow is always bounded by a
GetTexImage Fatal must be read with the recorded frontend-shadow fallback debt: the frontend
can still select its local GetTexImage fallback. The established texture readback failures
already cover that limitation; this review does not count the same debt as a new finding.
The final host gate, merged census, APK build and Redmi runs were underway concurrently.
Their incompleteness at review time is not a finding, and no successful phase exit or final
binary identity is inferred here. The integrator must append their actual pinned results
and the targeted closure evidence for findings 1–3 before claiming P5b complete. This report
does not request a second full review or a repeated full gate after focused repairs.
## Integrator addendum, 2026-09-16 — pinned results and closure evidence
All concurrently-running evidence named above has since completed; nothing below reruns a
gate or a review, it appends the pinned outcomes the report asked for.
- **Host closing gate (`348d22a4`, `~/w7/p5b-final-host-348d22a4/`)**: the WSL restart left
31/32 steps at rc=0; the missing `retrace-verify` arm was resumed against the SHA-256
pinned verify library (`verify-recovery-r1/`), 75 remaining entries serial, exit 0.
Combined: **retrace-verify 79/79**, retrace-push 79/79, OpenRA 2/2; all unit/gpu/split/
verify/audit lanes 0 failed. Step-by-step reconciliation in `reconciliation-20260916.md`;
`exit-code.txt=0`, `complete=true`, `summary-counts.{json,md}` regenerated.
- **Merged census (`348d22a4`, `~/w7/p5b-final-census-348d22a4/`)**: lane **1267 selected =
811 passed / 203 skipped / 62 aborted / 191 failed**, zero regressions against the c0b
baseline (1149 retained, 118 added, 0 removed). Trace census **79 = 72 passed / 6 aborted
/ 1 failed** after a three-round resume (resume1: create-indirect DirectVulkan >60 GiB
RSS guard-killed; resume2: same case guard-killed again = the 1 failed, five cases
deferred by the memory guard; resume3 on a fresh instance: 4 passed / 1 aborted).
Non-passing first blockers: rd12 GLES `InitialBytesNotCarried/resource_respecify`, rd12
Vulkan `BarrierTimeout/Present`, iris-photon GLES / iris-derivative GLES /
create-indirect GLES `UnmigratedEmulation/texture-remint-pull`, iris-bsl-esc-menu GLES
`InitialBytesNotCarried/resource_respecify`, create-indirect Vulkan memory-guard kill.
Census block injected into `joint-codex-v1.md`; `identity.json`/`counts.json`/
`trace-transitions.json` beside it.
- **Findings 1–3 closure**: fixes `a021e3cc` (finding 1) and `82683d4a` (findings 2–3) keep
their package evidence (`indexspan-codex-v1.md` 9/9, `wait-codex-v1.md` 7/7). The two
`PipeWireCodecTest.UserIndexSpan*` failures in the pre-`7cb29d46` quickgate were the
test log-capture defect fixed by `7cb29d46`; re-evidenced green on `c77831e0`
(3/3). Final device source: **`82683d4a83b5c8f4f7c375a7a92ebee9a1854646`** (APK phase
`p5bcodex2`: pull/push/split signed APKs, provenance and proofs in
`~/w7/notes/p5b/apk/p5bcodex2/`).
- **Redmi exit (device 2f7cbe2e, stage 256 MiB explicit profile)**: correctness matrix
**8/8** (4 traces x 2 backends, inproc split arm, per-group pin evidence and inproc/
apply-thread/wire-record proofs; `MOBILEGL_IPC_STAGE_MB=256`). Benchmark four-arm A/B:
**24/32 groups green with validated 200-frame tails** (all groups of
improved-transparency-26.3, 1.21.4-in-world, 1.21.4-sodium-in-world; first barrier-tax
measurement, see `ab-tables.md`). The 8 `iris-bsl-in-world` groups failed validation on a
fixture limit, not a regression: the trace yields only 123 benchmark frames, below the
runner's 200-frame-tail rule, on every arm including pull. Their retained 123-frame
series were reduced separately as a labeled supplement (p99 is shader-compile dominated
on all arms, as already recorded in the P2 baseline). Note for future campaigns: the
device no longer holds the vendor GPU ceiling observed 2026-09-11; the deterministic pin
is now 1100 MHz (pin_device.sh updated 2026-09-16), so these numbers are not
clock-comparable with a campaign pinned at 1050 MHz.