Skip to content

[PHP] Establish a reproducible PHPT conformance surface#740

Merged
brandonpayton merged 11 commits into
integration/kd-6nz-php-phpt-platform-fixesfrom
gascity/kd-6nz/kd-phb-php-phpt-harness-only-base
Jul 10, 2026
Merged

[PHP] Establish a reproducible PHPT conformance surface#740
brandonpayton merged 11 commits into
integration/kd-6nz-php-phpt-platform-fixesfrom
gascity/kd-6nz/kd-phb-php-phpt-harness-only-base

Conversation

@brandonpayton

@brandonpayton brandonpayton commented Jun 20, 2026

Copy link
Copy Markdown
Member

Purpose

PHP's upstream PHPT suite is a high-value compatibility surface for Kandelo: failures exercise package builds, libc, syscalls, process state, signals, networking, VFS behavior, and Node/browser host parity through the normal platform path.

This PR establishes a reproducible PHP 8.3.15 package and PHPT test surface for Node and browser. It does not claim that the repaired branch has rerun or passed the full PHPT suite. Runtime fixes discovered through that surface remain separate Batch 2 constituents.

What this establishes

  • A PHPT runner that parses and executes upstream test sections, supports Node and browser hosts, sharding and restartable Node chunks, structured reports, and bounded browser evaluation.
  • A PHP 8.3.15 package recipe with declared native dependencies, side modules, timeout instrumentation, and artifact validation.
  • Browser page and VFS-image wiring that layers exact PHP artifacts, maintained fixtures, and the upstream test tree over Kandelo's canonical rootfs.
  • Long-lived OpenSSL SNI fixtures and required rootfs service-name data without faking guest time.
  • Explicit reporting for PASS, FAIL, SKIP, XFAIL, XPASS, BORK, WARN, unsupported boundaries, timeouts, and warned expectation mismatches.

Review and landing repairs

The five source commits were replayed onto Batch 1 tip 5e011b6f49b1d8f8fa5ba34386934cfecd4e697e. The Vite conflict retained the current dropWorkerEntryExports() behavior while adding the PHP test-page input. Six append-only review commits were then added:

  1. Deterministic fork instrumentation

    • Sorts fork-bearing regions before local allocation and sequence rewriting.
    • Preserves a shared module's required leading dylink.0 section after Walrus emission.
    • Adds regressions for byte-stable output and dylink.0 placement.
  2. Reproducible PHP package artifacts

    • Builds PHP and native dependencies from verified sources in isolated work directories.
    • Pins Clang to its adjacent wasm-ld, uses target-correct configure cache answers, and strengthens artifact guards.
    • Aligns package architecture declarations with actual recipes.
    • Marshals POSIX timer notifications through a fixed-width libc contract and suppresses SIGEV_NONE wakeups consistently across libc, kernel, and host.
  3. Canonical browser test state

    • Builds the PHP test image from the canonical rootfs and fingerprints every image input.
    • Uses packaged ps and pgrep instead of harness-local substitutes.
    • Resolves canonical lazy-executable URLs and preserves observable PHPT filesystem state.
    • Removes static OpenSSL policy data from the kernel.
  4. Truthful PHPT verdicts

    • Aligns section environments, cleanup, expectation matching, extension probing, source discovery, and retry behavior with PHP's runner where Kandelo supports them.
    • Keeps BORK, WARN, XPASS, unsupported cases, timeouts, and warned mismatches visible in reports and exit status.
    • Labels imported PHPT evidence as historical rather than presenting it as validation of this repaired tree.
  5. Full PHPT VFS capacity

    • Rebases the canonical 256 MiB/16,384-inode rootfs into a freshly formatted 2 GiB/131,072-inode image before copying the 19,017-test corpus.
    • Allows growable SharedFS instances to expand enough for capacity-sized metadata during formatting.
    • Adds a 2 GiB rebase regression. This changes neither the VFS image format nor the kernel ABI.
  6. Clean browser readiness

    • Reuses the browser app's tracked favicon on the PHP page, eliminating the page's only browser-console asset error.

Landing boundary and recommendation

Recommendation: accept into the stacked Batch 2 aggregate only; do not land or publish this PR standalone.

The generated PHP programs deliberately import env.__wasm_posix_vm_interrupt_after. Its host implementation arrives later in #757, so PHP execution on this constituent alone would fail at the known missing-import boundary.

Batch 2 must also reconcile the two divergent ABI-16 lineages, bump ABI_VERSION to 17, regenerate all ABI artifacts, and raise PHP's kernel_abi floor to 17. The current ABI-16 consistency check below establishes only that this intermediate replay has no unrecorded structural drift; it is not the final Batch 2 ABI gate.

Validation on the repaired replay

  • Full fork-instrument host-target test suite passed.
  • cargo test -p kandelo --target aarch64-apple-darwin --lib — 971 passed.
  • Final cd host && npx vitest run — 120 files passed, 8 skipped; 899 tests passed, 2 expected failures, 26 skipped.
  • cd host && npm run typecheck — passed.
  • Focused SDK tests — 3 files and 22 tests passed.
  • Focused PHPT harness, fixture, lazy-asset, and multi-worker host tests — 4 files and 40 tests passed.
  • VFS image regression — 1 file and 41 tests passed.
  • wasm32 and wasm64 musl rebuilds passed; the timer object contains no raw setjmp/longjmp.
  • wasm64 zlib and OpenSSL recipe builds passed.
  • bash scripts/check-abi-version.sh — the intermediate ABI-16 snapshot, C header, and TypeScript bindings are current.
  • Two complete bash build.sh runs passed on the repaired tree.
  • git diff --check, shell syntax checks, and rustfmt checks for the modified fork-instrument files passed.
  • Full cargo fmt --check was unavailable in the canonical dev shell and is not claimed.

Reproducible PHP artifacts

Two complete PHP candidate builds produced exactly five outputs with byte-identical contents:

Output SHA-256
opcache.so b2445f62a55606ef77eaf9b6813d23e01162cfe2628ce5c4208aa11806f1cbbf
phar.so 1a274611837e988dd22304e1e2992d347798132bc751655fa11bf7673c62923e
php-fpm.wasm 5cbf9e6fead2799aa429a0383ee88edbb313abc69242871c274f79d234c8c97a
php.wasm 9bfb04598529dcc6aa6fca026d6bd2e6d755831b64e29534581fc6ee93e8c5cf
zend_test.so 760a079652ae8ba42521e7d62d9287d65cb203415c42ff327552b22fff55e30b

Node 24 compiled all five outputs. Artifact inspection found resolved side-module imports, ABI 16 metadata, complete fork metadata, the expected later-Batch-2 timeout-hook import, and no legacy Asyncify, raw setjmp/longjmp, native timer, forbidden SQLite/DNS, or producer-path residue. opcache.so begins with dylink.0; Kandelo's parser reports:

memorySize=45840, memoryAlign=4, tableSize=57, tableAlign=0, neededDynlibs=[]

A wasm64 executable timer smoke test was attempted but could not link because the repository-declared Clang lacks wasm64 compiler-rt builtins. No wasm64 timer runtime result is claimed.

PHP test VFS and real browser readiness

  • The image builder copied 28,631 files and produced a 195.1 MiB raw / 17.9 MiB zstd image.
  • The restored image reports 2 GiB capacity, 131,072 inodes, 19,017 .phpt files, and exact byte matches for all five reviewed PHP artifacts.
  • Image SHA-256: 668115501a466fc2a9cb9c3ea13370fd2fc08907ba25a6c6cd8d3d986f7575ca.
  • Input fingerprint: b2e8ece8f50c9867de56e757e700bad5d8c05975b2d2a0405a9895627d679752.
  • ./run.sh browser --host 127.0.0.1 --port 5417 --strictPort completed browser preparation and started Vite.
  • A headed Chromium load of /pages/php-test/ reached exact status Ready; installed window.__runPhpScript; was cross-origin isolated with SharedArrayBuffer; fetched the kernel, PHP VFS, and favicon with HTTP 200; and had no Vite overlay, console error, page error, failed request, or HTTP failure. Screenshot: /tmp/php-740-browser-ready.png in the landing environment.
  • PHP was intentionally not invoked in the browser because [PHP] fix: keep host/browser runtime and SharedFS state coherent #757 has not yet supplied the timeout-hook import.

Historical PHPT evidence — not rerun here

These counts were imported from the pre-split source tree at bc13ad8631a2. They are historical context only and are not validation of this repaired replay.

Host/run Coverage Historical result
Node full run 19,017 / 19,017 14,554 PASS, 0 FAIL, 0 TIMEOUT, 9 XFAIL, 1 XPASS, 3,987 SKIP, 466 UNSUPPORTED
Browser partial run 2,363 / 19,017 2,141 PASS, 2 FAIL, 1 XFAIL, 212 SKIP, 7 UNSUPPORTED

The full Node and browser PHPT suites were not rerun. scripts/run-libc-tests.sh, the POSIX suite, and the Sortix suite were also not run for this constituent; the full conformance and ABI-17 gate belongs on the exact Batch 2 aggregate after #757 and the remaining platform repairs land.

Replay provenance

The original remote head was 3109baf285c151471b7be1264c9cdc10478d0871. Because #740 conflicted with the current stacked base, its five source commits were replayed rather than blindly retargeted. The repaired source branch ends at 9f2c7d6ff7bab32fc230d4b069817accedec96d4 and is updated only with an exact --force-with-lease against that prior head.

@github-actions

Copy link
Copy Markdown

Phase B-1 matrix build status — pr-740-staging

ABI v15. 8 built, 0 failed, 8 total.

Package Arch Status Sha
libiconv wasm32 built 0940adeb
libiconv wasm64 built a3254e70
libxml2 wasm32 built f31b85aa
libxml2 wasm64 built 2307f0d7
php wasm32 built 9da1b62c
rootfs wasm32 built b79c2fb2
shell wasm32 built 6e925d8a
node-vfs wasm32 built ead76749

Auto-generated; replaced on each push. Raw data in the publish-status workflow artifact.

Port the PHP-specific harness, browser VFS/page wiring, PHP 8.3.15 package recipe, libiconv dependency package, and support fixtures from source PR #2 as a scoped checkpoint. General platform fixes and current validation evidence follow in later commits.
Sort fork-bearing regions before allocating locals and rewriting sequences so identical inputs produce identical output bytes.

Preserve a shared module’s leading dylink.0 section across Walrus emission, and cover both contracts with focused regressions.
Build PHP and its native dependencies from verified sources in isolated workdirs, pin clang to its adjacent wasm-ld, and use target-correct configure cache values.

Marshal POSIX timer notifications through a fixed-width libc contract and suppress SIGEV_NONE wakeups consistently across libc, kernel, and host. Keep the PHP timeout hook’s later Batch 2 ABI dependency explicit.
Layer PHP artifacts and maintained fixtures over the canonical rootfs, and fingerprint every image input so stale browser test images rebuild automatically.

Use packaged ps and pgrep, resolve canonical lazy executable URLs, preserve observable PHPT filesystem state, and remove static OpenSSL policy data from the kernel.
Align section environments, cleanup, expectation matching, extension probing, source discovery, and retry behavior with PHP’s runner where Kandelo supports them.

Keep unsupported boundaries, BORK, WARN, XPASS, timeouts, and warned mismatches visible in reports and exit status, with focused harness coverage and historical evidence labeled as such.
@brandonpayton brandonpayton force-pushed the gascity/kd-6nz/kd-phb-php-phpt-harness-only-base branch from 3109baf to 9f2c7d6 Compare July 10, 2026 23:23
@brandonpayton brandonpayton changed the title [PHP] Add upstream PHPT harness [PHP] Establish a reproducible PHPT conformance surface Jul 10, 2026
@brandonpayton brandonpayton changed the base branch from main to integration/kd-6nz-php-phpt-platform-fixes July 10, 2026 23:23
@brandonpayton brandonpayton merged commit 2f0d5ee into integration/kd-6nz-php-phpt-platform-fixes Jul 10, 2026
@brandonpayton brandonpayton deleted the gascity/kd-6nz/kd-phb-php-phpt-harness-only-base branch July 10, 2026 23:23
brandonpayton added a commit that referenced this pull request Jul 13, 2026
Rebuild PHP 8.3.15 and its dependencies through deterministic package recipes, add the canonical PHPT Node/browser harness and VFS assets, and keep verdict reporting and fork-instrumented output reproducible.

Route the required __wasm_posix_vm_interrupt_after import from process workers to kernel workers on both browser and Node hosts. Validate fixed-width POSIX timer notification fields and suppress SIGEV_NONE wakeups.

Advance ABI 26 to 27, bind the PHP package floor to 27, and regenerate the snapshot, host bindings, and libc header atomically.

Source-PR: #740

Source-PR: #757
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant