Skip to content

fix(wasm)!: unblock host-backed shell compatibility - #2968

Merged
chaliy merged 2 commits into
mainfrom
codex/wasm-shell-compat
Nov 22, 2026
Merged

chaliy merged 2 commits into
mainfrom
codex/wasm-shell-compat

Conversation

@chaliy

@chaliy chaliy commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

What changed

Host filesystem metadata now carries UID/GID, and both [ -O/-G ... ] and [[ -O/-G ... ]] compare owners against sandbox user/group 1000. Omitted ownership retains the existing single-user defaults; Unix RealFs reports host ownership.

[() { ...; } now defines and dispatches a function. WASM custom builtins accept { stdout?, stderr?, exitCode? } (sync or Promise), preserving status through $?, conditionals, AND/OR lists and errexit. Existing string callbacks continue to work.

Why

Thebird's integration ledger reports these compatibility gaps blocking host ownership tests and silent custom test failures.

Before / After

Reproduced against published 0.21.1, then exercised against the rebuilt release package:

Case Before After
Host reports UID/GID 0; sandbox identity 1000 Ownership tests succeed Both ownership tests fail
[() { echo override; return 7; }; [ x ]; echo status=$? Parse error override\nstatus=7\n
Callback returns { stdout: "out\n", exitCode: 7 } Empty output, status 0 Output retained, status 7
Custom [ returns { exitCode: 1 } Status 0 Status 1, empty stderr

Validation:

  • All eight PR workflows, CodeQL analysis and required checks passed on a121a247.
  • All 82 tests against the optimized WASM release package, including npm archive/source identity.
  • All 51 RealFs tests; CLI bracket-function smoke matches real Bash.
  • HTTP-enabled native workspace tests pass with the glibc-specific iconv oracle excluded locally; all 19 single-threaded failpoint tests pass.
  • All-target/all-feature Clippy, 272 Python script tests (8 existing skips), cargo-vet, knowledge/docs/capability/workflow/changelog/Monty checks.
  • Targeted Criterion file-write/read comparison: no significant change (p=0.16); report and generated site data included.

Local gate limitations: full just pre-pr / just test encounter the existing macOS iconv byte-order mismatch, also reproduced on unchanged main. Full cargo deny check reports existing unmaintained chrono/chrono-tz advisories; no dependencies, advisory exceptions or test assertions were changed. Linux CI passed the full test suite unchanged.

Risk

Source-breaking for Rust backends constructing public Metadata literals: provide the new fields or use ..Metadata::default(); examples and fixtures are updated. Release this in the next minor series. Existing JavaScript string callbacks remain compatible. The v1 filesystem ABI layout is unchanged and retains sandbox ownership. Ownership metadata does not enforce permissions. Malformed JS result shapes and owner IDs now fail explicitly.

Checklist

  • Tests added or updated; original failures reproduced before implementation
  • Backward compatibility considered; Rust literal migration documented

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
bashkit a121a24 Commit Preview URL

Branch Preview URL
Nov 22 2026, 02:24 AM

@bashkit-pr-reviewer

bashkit-pr-reviewer Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Review summary — #2968 fix(wasm): unblock host-backed shell compatibility

Verdict (new push a121a24): no findings — nothing to block. This push resolves all three findings from the previous review, and the new/changed hunks check out. Per workflow I am not submitting an inline review when there are no findings.

Earlier findings, now resolved (verified in the diff):

  • hostfs-uid-silent-default → the omit-vs-malformed contract is now documented in js/index.d.ts (HostStat), crates/bashkit-wasm/README.md, knowledge/runtimes/browser-package.md, and docs/filesystem.md.
  • wasm-builtinresult-deny-unknown-fields → deny_unknown_fields removed from BuiltinResult; the WASM test locks it in with an extra: "host metadata" property; README/.d.ts state extras are ignored.
  • test-O-RealFs-uid-mismatch → divergence recorded in RealFs rustdocs ("Ownership"), docs/filesystem.md, knowledge/foundations/vfs.md, limitations L-FS-002/L-FS-006, plus a dedicated realfs_reports_host_ownership test that computes the owner/group expectation dynamically (portable across runner UIDs).

Reviewed in this push: index.d.ts contract docs, README host-contract section, WASM tests (bracket override, structured sync/async results incl. set -e and executeSync, invalid shapes, custom false [, host owner matrix + invalid IDs), realfs_tests.rs ownership test, functions.test.sh bracket-override spec, builtins/mod.rs re-export, mechanical uid/gid: 1000 additions across backends/fixtures/examples/tests, RealFs rustdoc, knowledge updates (vfs.md, parser.md, browser-package.md, limitations.md, log.md), docs pages, and the Criterion bench note (no significant change, p = 0.16). Checked and fine: [[ -O/-G ]] uses the same args indexing contract as sibling arms; owner_id range check is exact (u32::MAX is exactly representable in f64) and null/absent behave as documented.

Still outstanding (tooling, not code): submit_github_pull_request_review keeps returning 422 for this PR — including a single-comment probe on a confirmed added line — so findings continue to live in this summary. No code modified; no tests run (shell cannot build/test per project setup). Full diff reviewed: +449/-17, 36 files, head a121a24.

chaliy commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Addressed all three review findings in a121a24:

  • hostfs-uid-silent-default: HostStat API docs and the package README now state the compatibility default (1000) and that malformed supplied IDs fail the metadata operation. Existing regressions cover omitted and malformed IDs.
  • wasm-builtinresult-deny-unknown-fields: removed the misleading deny_unknown_fields annotation, documented ignored extra host properties, and extended the sync/Promise result regression with an extra property. Direct execution showed serde-wasm-bindgen already ignored that property even with the annotation; the declared contract now matches the tested behavior.
  • test-O-RealFs-uid-mismatch: documented the intentional fixed sandbox identity in RealFs Rustdoc, the filesystem guide, and limitation L-FS-006. Extended realfs_reports_host_ownership to assert both real metadata and sandbox-ID comparisons through [ and [[ ]] without changing the shell's identity.

Validation: all 82 optimized WASM package tests, the extended RealFs ownership test, all-target/all-feature Clippy, knowledge and documentation checks pass. The original full RealFs suite (51 tests), HTTP-enabled native suite apart from the reproduced main/macOS iconv mismatch, and all 19 failpoint tests also passed. CI is rerunning on the new head.

@chaliy chaliy changed the title fix(wasm): unblock host-backed shell compatibility fix(wasm)!: unblock host-backed shell compatibility Nov 22, 2026
@chaliy
chaliy merged commit 076a85e into main Nov 22, 2026
71 checks passed
@chaliy
chaliy deleted the codex/wasm-shell-compat branch November 22, 2026 03:00
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