Skip to content

[PHP] fix: keep host/browser runtime and SharedFS state coherent#757

Merged
brandonpayton merged 29 commits into
integration/kd-6nz-php-phpt-platform-fixesfrom
gascity/kd-6nz/kd-lnp-pr717-host-runtime-browser-split
Jul 11, 2026
Merged

[PHP] fix: keep host/browser runtime and SharedFS state coherent#757
brandonpayton merged 29 commits into
integration/kd-6nz-php-phpt-platform-fixesfrom
gascity/kd-6nz/kd-lnp-pr717-host-runtime-browser-split

Conversation

@brandonpayton

@brandonpayton brandonpayton commented Jun 20, 2026

Copy link
Copy Markdown
Member

Why

Browser PHPT workloads exposed platform-contract failures at the shared
filesystem, process-worker, networking, clock, and package-image boundaries.
This change repairs those boundaries in Kandelo's normal runtime path for both
Node.js and browsers; it does not weaken PHPT expectations or synthesize
application success.

What changed

  • Make SharedFS namespace mutation, sparse and partial writes, ENOSPC rollback,
    lazy-file/archive identity, hard links, rebasing, and quiescent image
    persistence coherent across workers. Preserve POSIX O_EXCL, unlink,
    rename, timestamp, directory-read, and append behavior.
  • Resolve Node host-backed paths component by component inside their mount
    root; preserve virtual ownership and native timestamp identity; carry mount
    and worker-resource policy into process workers.
  • Keep Node/browser process launch and runtime behavior aligned: preflight
    exec/spawn Wasm, share process longjmp tags with side modules, route host
    diagnostics separately from guest stderr, and use generation-safe
    kernel-worker timers for cooperative VM interruption.
  • Align browser networking (MSG_PEEK, synthetic DNS validation, CORS proxy
    routing), virtual interface naming, and supported clock/timer behavior
    across hosts.
  • Preserve fork-instrument output permissions, including in-place
    instrumentation.
  • Make /etc/services authoritative in rootfs-derived images, align
    WordPress/LAMP on PHP 8.3.15, give PHP shutdown callbacks a fresh bounded
    soft-timeout phase, and invalidate changed package/VFS revisions.
  • Keep GNU netcat on ordinary FIN close because Kandelo truthfully rejects
    abortive SO_LINGER until every transport can model reset-style close.
    Its build now honors resolver source identity, verifies SHA-256, activates
    the worktree SDK, rejects non-wasm32 targets, applies patches idempotently,
    and installs resolver builds only into their declared output directory.
  • Update architecture, POSIX-status, fork-instrumentation, and test
    documentation for supported behavior and remaining boundaries.

Review changes

The reviewed branch starts at exact Batch-2 tip 23e70c569. It carries 20
source-derived commits plus nine review commits, without duplicating stronger
#756/#859 dylink and poll-deadline work.

Review removed false artifact and performance claims and repaired in-place
instrumentation permissions, Node mount/resource behavior, Node/browser
runtime parity and diagnostics, SharedFS persistence races, canonical rootfs
inputs, PHP shutdown timing, the netcat package boundary, and Linux coarse
clock handling. Performance was not measured and no performance claim is made.

The first canonical ./run.sh browser attempt exposed a real review
regression: LAMP preinstall timed out before /data/wordpress, with no
MariaDB bootstrap/error log. A controlled comparison traced the spin to
#757 rejecting Linux CLOCK_REALTIME_COARSE and
CLOCK_MONOTONIC_COARSE requests. The repair maps those IDs to Kandelo's
corresponding realtime/monotonic host domains, adds kernel coverage, and
documents the approximation.

Validation

Validation on the final reviewed tree:

  • cargo test -p kandelo --target aarch64-apple-darwin --lib:
    1,071 passed.
  • Full host Vitest: 140 files passed; 1,206 tests passed; 2 expected
    failures; 19 skipped
    .
  • scripts/run-libc-tests.sh: 302 passed, 20 expected failures,
    1 flake-pass, and 1 unexpected failure
    :
    regression/raise-race exited 3.
  • bash scripts/check-abi-version.sh: synchronized and passed. This is
    structural evidence, not semantic ABI clearance.
  • Focused fork-instrument: 185/185.
  • Focused final SharedFS/MemoryFS set: 161/161.
  • Focused virtual-network/netcat set: 8/8.
  • Final canonical ./run.sh browser: all 66/66 resolver assets were
    available, with no source rebuilds or fallback artifacts; LAMP and
    WordPress final checks passed; preparation reached Vite in 3m23s.
  • Real Chromium reached PHP Ready in 1.004s; PHP 8.3.15 exited 0
    with correct output; console, page, request, and HTTP-error collections
    were empty.

The full PHP PHPT suite, POSIX suite, Sortix suite, final aggregate gate, and
performance benchmarks were not run for this constituent.

ABI and landing boundary

This constituent remains at ABI 16 and is not standalone- or main-ready. The
new PHP host import, existing Batch-2 kernel/host semantic changes, and the
fork-buffer repair required for raise-race belong in the single aggregate
ABI 16->17 reconciliation.

The raise-race case also fails on exact #871 tip; #757 did not introduce it.
Existing repair e8fa12447 makes the focused case pass but changes the
fork-buffer meaning, so it must not ship under ABI 16.

Before #871 can merge to main, Batch 2 must incorporate that repair,
regenerate abi/snapshot.json and generated C/TypeScript bindings, raise the
PHP package ABI floor, rebuild ABI-bound packages/VFS images/indexes, and run
the full aggregate gate.

Review view

Accept into quarantined Batch 2. Do not merge this PR independently to main,
and do not treat its structural ABI check or constituent browser evidence as
aggregate merge clearance.

@github-actions

Copy link
Copy Markdown

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

ABI v16. 66 built, 1 failed, 67 total.

Package Arch Status Sha
libcurl wasm32 built 05131d85
libcxx wasm32 built 8da1dda5
libcxx wasm64 built 3f9d7318
libiconv wasm32 built 98ae39cc
libiconv wasm64 built 364f191d
libpng wasm32 built 57911579
libxml2 wasm32 built c9190593
libxml2 wasm64 built 29606a80
openssl wasm32 built b830c422
openssl wasm64 built 0ad8e76e
sqlite wasm32 built 22892317
sqlite wasm64 built a488b172
zlib wasm32 built 6258205e
zlib wasm64 built 10905a61
bc wasm32 built f45b6fc6
bzip2 wasm32 built ccaed6f7
coreutils wasm32 built 9c2f9610
curl wasm32 built 2a9910ba
dash wasm32 built dad4f1d0
diffutils wasm32 built 243e8f6c
dinit wasm32 built 8692ce28
fbdoom wasm32 built 4de08e20
file wasm32 built 37c5ed26
findutils wasm32 built abaccfbd
gawk wasm32 built 5870aeeb
git wasm32 built 3a505148
grep wasm32 built 873a4b9d
gzip wasm32 built bbf648b6
kandelo-sdk wasm32 built 6054195f
kernel wasm32 failed
less wasm32 built cff77508
lsof wasm32 built b2808d0b
m4 wasm32 built eeecbe81
make wasm32 built 73a97016
mariadb wasm32 built d51494dd
mariadb wasm64 built 019f4e3b
modeset wasm32 built 26449a18
msmtpd wasm32 built 8d5e57c3
nano wasm32 built e11bb2fe
ncurses wasm32 built 077d7b78
netcat wasm32 built 81674bbc
nginx wasm32 built a39e497d
php wasm32 built 5a58aac5
posix-utils-lite wasm32 built b6e3e07f
sed wasm32 built 2dbe649f
spidermonkey wasm32 built 022c3dd5
tar wasm32 built 79facabd
tcl wasm32 built 950a960f
unzip wasm32 built 87cc1e61
userspace wasm32 built 3ca5b0d1
vim wasm32 built 0d676ada
wget wasm32 built de9df728
xz wasm32 built 52fe1260
zip wasm32 built a4a53388
zstd wasm32 built 346b97c8
bash wasm32 built 9d94677c
mariadb-test wasm32 built 00b542dd
mariadb-vfs wasm32 built 83005b2b
mariadb-vfs wasm64 built a79c1b0d
nethack wasm32 built 799bbd26
node wasm32 built d57f5d71
spidermonkey-node wasm32 built fbcde318
vim-browser-bundle wasm32 built 22e962ba
nethack-browser-bundle wasm32 built a1711c12
rootfs wasm32 built c314bfde
shell wasm32 built 6ddcec14
node-vfs wasm32 built 685a8cbd

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

Kandelo Agent and others added 20 commits July 11, 2026 05:27
Propagate mount ownership and native metadata through Node worker setup, preserve host-backed filesystem semantics, and apply the configured process-worker stack policy.
Validate hostnames before synthetic browser resolution, reserve the .invalid namespace for failures, and keep localhost aliases available without claiming general DNS reachability.
Preserve MSG_PEEK across browser networking backends and carry CORS proxy configuration through the browser worker protocol without consuming queued data.
Implement POSIX O_CREAT|O_EXCL handling in SharedFS so open fails with EEXIST when the final pathname already exists, including a final symlink.
Track directory entries and allocation hints explicitly for large PHP test directories. This commit makes no performance claim; performance was not measured.
Carry the cooperative VM interrupt hook into browser process workers so kernel-requested deadlines can interrupt CPU-bound guest execution.
Validate supported clock and timer IDs, carry runtime hooks through Node and browser process launches, keep host time conversion bounded, and preserve PHP runner filesystem expectations.
Resolve host-backed paths component by component, preserve virtual ownership and native timestamp identity, and keep mount operations inside their configured root. Validate the larger Node worker stack policy with real recursive Wasm workers.
Validate exec and spawn modules before committing process state, share process longjmp tags with side modules, keep network and interface behavior host-parallel, validate CPU clock encodings, enforce generation-safe VM deadlines, and route host failures outside guest stderr.
Serialize namespace mutations, bound sparse growth, preserve partial-write and ENOSPC state, snapshot only quiescent filesystem data, bind deferred backing to inode generations and data sequences, and preserve hard-link identity during rebases. Performance was not measured.
Use the canonical services database and dinit image helpers when deriving browser VFS artifacts, align WordPress and LAMP on PHP 8.3.15, and invalidate every serialized image whose inputs changed.
Keep the soft-plus-hard deadline for unresponsive Wasm execution, but reset shutdown callbacks to a new soft timeout so ordinary PHP cleanup remains bounded without being killed immediately.
GNU netcat treats reset-style SO_LINGER as an optimization. Kandelo truthfully rejects that mode until every transport can model it, so the wasm package retains ordinary FIN close semantics instead.

Make source builds resolver-safe at the same time: activate the worktree SDK, verify resolver-provided source identity, keep scratch state under the resolver work directory, and install resolver builds only into their declared output directory.
Map CLOCK_REALTIME_COARSE and CLOCK_MONOTONIC_COARSE to Kandelo's corresponding host clock domains. The hosts do not expose distinct coarse sources, but returning EINVAL causes libc consumers such as MariaDB to retry before startup. Cover clock_gettime and clock_getres and document the fallback.
Each timeout flag byte is written with an atomic store; the pair is not one atomic transaction.
@brandonpayton brandonpayton force-pushed the gascity/kd-6nz/kd-lnp-pr717-host-runtime-browser-split branch from 62a5771 to bb5a0b1 Compare July 11, 2026 12:41
@brandonpayton brandonpayton changed the title [PHP] fix: split host browser and SharedFS runtime fixes [PHP] fix: keep host/browser runtime and SharedFS state coherent Jul 11, 2026
@brandonpayton brandonpayton changed the base branch from integration/kd-6nz-php-phpt-fork-process-shm-base to integration/kd-6nz-php-phpt-platform-fixes July 11, 2026 12:41
@brandonpayton brandonpayton merged commit 98fac9d into integration/kd-6nz-php-phpt-platform-fixes Jul 11, 2026
@brandonpayton brandonpayton deleted the gascity/kd-6nz/kd-lnp-pr717-host-runtime-browser-split branch July 11, 2026 12:42
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