Repository navigation
feat(host)!: migrate the ngx catalog and RSS surface to Unit/Option/Result - #3
Merged
Merged
Conversation
Advance the RustScript core pin from 87d8c5d5 to fc8b0c8179 (CORE_TARGET) and refresh Cargo.lock, which relocks exactly pd-host-function, pd-host-schema, and pd-vm. fc8b0c81 extends HostTypeSchema with Unit/Option/Result. The library and every test target still compile: the only source break was a non-exhaustive match in ngx_scheduler_contract's callable walker, now recursing into Option/Result and treating Unit as a leaf. Host-contract adaptation is NOT included: the new core rejects host functions whose declared return schema is Unknown, Null, or Optional (host_output_forbidden), and rejects RSS `null` literals. 76 of the 199 catalogued ngx hosts still declare a rejected return schema, so the runtime suite is red until that migration lands.
The pinned pd-host-function/pd-vm (fc8b0c81) compiler rejects any host function whose declared return schema is Null, Optional, or Unknown with "returns a dynamic or legacy-null schema, which RustScript does not admit". Every void ngx host therefore failed at configuration time, which is most of the runtime rejection surface. - 46 void host returns move from `HostTypeSchema::Null` to `::Unit`; `ngx::core::null_value` keeps `Null` because it deliberately hands guest code a null value and is the null-literal probe. - Unit's physical carrier is the internal Null value, so the host implementations already emit it through `ret(())`; no implementation path had to change. - Bump NGX_HOST_CATALOG_SCHEMA_VERSION to 4 and refresh the fingerprint golden, which the schema tags feed. - Sync every catalog return-type assertion in the integration tests and add a guard test that keeps legacy Null host returns out of the catalog.
Pin pd-vm at fc8b0c81 and move every host output onto the RustScript guest
contract. RustScript now rejects `unknown`, `null`, and the legacy
`optional<T>` schema anywhere in a host output, so the catalog, the host
implementations, and every RSS consumer move together.
Catalog (schema version 5, fingerprint retargeted):
* Logical absence is guest `Option<T>` (`{tag, payload}` carriers built from
`vm::option::{some_carrier,none_carrier}`): `var::get`,
`req::get_body_data`, `req::get_body_file`, `req::http_version`,
`decode_base64`, `decode_base64mime`, `parse_http_time`, `ctx::get`,
`ctx::delete`, `header::get`, and every option-typed named field.
* Void results are Unit: `ngx::core::null_value` (was `Null`), timer
registration (was `Bool`), and every `error`/`value` absence carrier.
* Header and argument bags are typed entry arrays instead of dynamic maps:
`HeaderEntry { name, value }`, `ArgEntry { name, value: Option<string> }`.
Repeated names repeat the entry, so duplicate headers and repeated query
arguments survive; a bare query key is `Option::None`, `a=` is
`Some("")`.
* Shared dictionary values are the tagged `SharedValue` record (`kind` plus
one `Option` payload) and `ngx::shared::delete` returns `bool`.
* `ngx::ctx` values are `string`: get/delete return `Option<string>` and a
non-string value is rejected.
* `ngx::header::get` returns the first value as `Option<string>`.
* timer callback schema is `fn(bool) -> ()` and the registration returns
`()`.
Compile/runtime contract:
* `compile_host_catalog()` now merges pd-vm's standard host catalog
(I/O, HTTP, SQLite) with the ngx surface and the production registry
installs those modules from the same snapshot. Without that, a standard
handle resolved through the legacy builtin table carried an `int` that
the resource-typed sibling hosts reject.
* Quiescent buffered HTTP (`http::*` request/response/header resources) is
admitted to statically reused request VMs; SQLite/I/O/SSE stay excluded.
* Standard-family use is detected from catalog imports as well as legacy
builtins, so request-owned execution selection is unchanged for both
paths.
RSS consumers: tests, fixtures, examples, and documentation use the guest
types (`Option::Some`/`Option::None`, `Result::Ok`/`Result::Err` with `?`,
`()`), the resource-based HTTP builder (`http::request::new`,
`set_header(&mut ..)`, `http::response::*`), the `SqliteOpenOptions`/
`SqliteValue` records, and typed entry arrays. Stub- and zone-backed test
binaries serialize on a per-binary lock so process-global stub counters and
in-process zones no longer race under the default test threading.
…t polls parse_http_time now returns a guest Option, so the fixed-date test asserts Some(1290079655) and None instead of a bare int and a physical Null. The live-socket poll-order tests take the existing socket test lock: a loaded machine can flip a Pending poll to Ready when they overlap.
Driver::new() pays the worker runtime start (~2.7s on a loaded host), which the 1.5s bound was counting as connect latency. Build the driver first and start the clock at pump_until, so the assertion still proves the oversized host is rejected before any lookup.
fffonion
force-pushed
the
feat/unit-option-result-contract
branch
from
November 15, 2026 08:59
b0bbd20 to
0f41f58
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Moves ngx-rustscript onto core
fc8b0c81and removes the legacyNull/Optional/Unknownhost exits the compiler now rejects.Core pin
pd-host-function,vm, and the metadatarustscript-revpoint atfc8b0c81; the lock moves only the three core packages.Catalog
Unitinstead ofNull; a guard test asserts no host output carriesUnknown,Null, orOptionalrecursively.var::get,req::get_body_data,req::get_body_file,req::http_version,decode_base64,decode_base64mime,parse_http_time,ctx::get,ctx::delete, andheader::getreturn guestOption<T>built fromvm::option::{some_carrier, none_carrier}.{name, value}entry arrays (ArgEntry.valueisOption<string>: a bare key isNone,a=isSome("")); repeats survive.SharedValuerecord (kind+ oneOptionpayload),error: Option<string>, anddelete -> bool; attlmiss yieldsvalue: None.ctxis string-valued; timers register with aUnitresult and invokefn(bool) -> ().compile_host_catalog()merges pd-vm's standard catalog (I/O, HTTP, SQLite) and the production registry installs those modules from the same snapshot, so resource handles bind exactly. Quiescent buffered HTTP is admitted to VM reuse.RSS surface and docs
nullliteral andT?annotation in tests, fixtures, examples, and docs becomes(),Option::Some/Option::None, orResultwith?.http::request::new,set_header(&mut …),http::response::*); SQLite usesSqliteOpenOptions/SqliteValue.standard-async,ctx,shared-dict,request,response,codec,timer,host-descriptors, compatibility, security, examples, and README follow the new contract.Verification (real nginx 1.31.4, default test threads)
cargo check --locked: 0cargo test --locked: 1609 passed / 0 failed / 0 ignored, exit 0cargo fmt --all -- --check: 0cargo clippy --locked --all-targets -- -D warnings: 0Test-fixture changes only serialize fixtures that contend for worker slots and move measurement start points past VM/driver setup; no assertion was weakened and no business code was touched for them.