Repository navigation
WebIDL bindings (7.12): generated glue, conversions, overloads, wrappers, DOMException; DOM, Window, Location, History, Navigator and console exposed to script - #295
Closed
atiernan wants to merge 6 commits into
Conversation
…shared natives WebIDL attributes are accessor properties on prototypes (WebIDL §3.7.6), so item 7.12 needs them in the engine: - clazel-js-vm: an accessor property is an ACCESSOR attribute bit and a Cell::Accessor pair in its slot. OrdinaryGet (§10.1.8.1 steps 4 to 8) and OrdinarySetWithOwnDescriptor (§10.1.9.2 steps 4 to 7) call the getter and setter with the receiver, for property reads and writes, global identifiers and primitive bases; ValidateAndApplyPropertyDescriptor (§10.1.6.3) gets its accessor steps (2.c, 5.c, 5.d, 6.a, 6.b); object literal getters and setters (DefineMethod forms 1 and 2) run; the instanceof operator (§13.10.2, OrdinaryHasInstance §7.3.21) runs. - clazel-js-builtins: ToPropertyDescriptor (§6.2.6.5) reads get and set. - clazel-js: define_property takes accessors; get_own_property; delete_property, new_array, new_array_from and is_array over the VM's arrays; shared_function, a re-entrant native for Sync closures (open question 14's proposal, beside function, which keeps its Busy rule). The Test262 runners gain two classifications for tests that instanceof now reaches and that stop at the missing eval (fail stays 0). The API test that listed arrays and delete_property as NotImplemented now asserts that they work. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The spec and the contracts first (CLAUDE.md rule 3); the exec functions and their theorems follow in the next commit. - set_data: DOM §4.10 "replace data" with offset 0 and count the node's length, which is what CharacterData's data setter (and textContent and nodeValue on character data) do. Requires a Text, Comment or ProcessingInstruction node. - set_wrapper: the wrapper slot Phase 4 reserved becomes the bindings' object id; nothing else changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The exec functions meet the contracts of the previous commit, and Verus proves them (477 verified, 0 errors locally): - theorem_set_data_wf and theorem_set_data_host_acyclic: replacing all of a character data node's data keeps wf and host_acyclic, the node keeps its kind (and a processing instruction its target), its data is the new data, and every other node is unchanged. - theorem_set_wrapper_wf and theorem_set_wrapper_host_acyclic, through lemma_set_wrapper_wf (no clause of wf_with reads a wrapper): the slot holds the given id and nothing else changes. Two mutations, each killed with a certificate: set-data-keeps-old and set-wrapper-ignored. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ppers, DOMException Item 7.12 over clazel-js's public API: - xtask/src/bindings/glue.rs: cargo xtask bindings now also writes src/generated/bindings.rs from the vendored IDL: for each exposed interface a trait the platform implements (IDL values as Rust types; every method defaults to a NotSupportedError naming the member), a native function per member (this check, argument count, conversions, overload resolution, the call, the result), and the installation of interface objects, prototypes, constants, attributes and operations (WebIDL §3.7). Dictionaries, enumerations and unions become Rust types with their conversions (§3.2.18, §3.2.19, §3.2.24). Members it cannot bind are listed with the reason in the file's header. check keeps failing when the file is stale. - convert.rs: §3.2 for every type used (ConvertToInt with EnforceRange and Clamp, float and double, DOMString with LegacyNullToEmptyString, ByteString, USVString, object, interface, callback interface and function, sequence from an Array). - overload.rs: the effective overload set and the overload resolution algorithm (§2.5.8, §3.6). - platform.rs: one wrapper per platform object, made on first access with its unforgeable members and kept by the platform; brand checks; [SameObject]. - install.rs: [Replaceable], [PutForwards]; exception.rs: DOMException. - tests/bindings.rs: idlharness-style checks over a small platform. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Page is the clazel-js host and clazel-webidl's platform (items 7.12, 7.13, and 7.15's Window, Location, History, Navigator and console): - Node, Document, DocumentType, DocumentFragment, CharacterData, Text, Comment, Element, NodeList, HTMLCollection, DOMTokenList and the exposed HTML element interfaces, over clazel-dom's proven operations (pre-insert, replace, replace all, remove, clone, attribute changes, set_data), with their preconditions checked first. A node's wrapper is kept in clazel-dom's wrapper slot, the others' in a side table. - EventTarget, Event, CustomEvent, AbortController and AbortSignal over the events module's dispatch; listeners are JS values kept by handles, and a listener can read the event and change listeners while it runs; its exception is reported to the host's log. events::TargetId gains Object for targets that are not nodes. - Window, Location (navigation through PageHooks::navigate), History (pushState and replaceState with "can have its URL rewritten", through PageHooks::update_url), Navigator with a fixed user agent string naming only Clazel, and console, written by hand (console.idl is not vendored), which logs to the host and never to the page. - tests/bindings.rs runs script against parsed documents, with checks transcribed from WPT's dom/ and html/ tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
atiernan
had a problem deploying
to
full-verification
November 23, 2026 12:41 — with
GitHub Actions
Error
Miri found it: 4294967297 converted to long gave 0 under Miri and 1 natively, because step 10 used f64 %. Step 10 is now computed exactly on the double's significand and exponent, and [Clamp]'s round-half-to-even reads the parity of an integer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
atiernan
requested a deployment
to
full-verification
November 23, 2026 17:10 — with
GitHub Actions
Waiting
atiernan
added a commit
that referenced
this pull request
Nov 23, 2026
Both sides made native closures re-entrant. One API: every closure is an Arc<NativeFn> that is Send + Sync (#294's design); Scope::shared_function (#295's name) stays as an alias of Scope::function, and SharedNativeFn is an alias of NativeFn. Cargo.toml dependencies are the union. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
Author
|
Contained in #298 (renderer pipeline, 7.17), which merges this branch together with the other half so they verify as one. Branch kept. |
This branch is waiting to be deployed
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.
Phase 7 item 7.12 (WebIDL bindings), on top of the phase 7 integration branch (#286), as one pull request. It also exposes the DOM,
Window,Location,History,Navigatorandconsoleto script through the bindings.What landed (commit by commit)
instanceof, re-entrant natives. WebIDL attributes are accessor properties, and the VM had none.ACCESSORattribute bit with aCell::Accessorpair in the slot. OrdinaryGet and OrdinarySetWithOwnDescriptor now call getters and setters, for property access, global identifiers and primitive bases. ValidateAndApplyPropertyDescriptor gained its accessor steps.get/set(DefineMethod forms 1 and 2), and theinstanceofoperator (§13.10.2, OrdinaryHasInstance).ToPropertyDescriptornow readsgetandset.define_propertynow takes accessors, andget_own_propertyis new.delete_property,new_array,new_array_fromandis_arraynow work over the VM's arrays.shared_functionis new: a re-entrant native forSyncclosures. This is open question 14's proposal, added besidefunction, which keeps itsBusyrule and its test.set_dataandset_wrapper. Committed on their own first (rule 3).theorem_set_data_wf,theorem_set_wrapper_wf,theorem_set_data_host_acyclicandtheorem_set_wrapper_host_acyclic.killedwith a certificate:set-data-keeps-oldandset-wrapper-ignored.cargo xtask bindingsnow also writessrc/generated/bindings.rsfrom the vendored IDL. For each exposed interface it writes:NotSupportedErrornaming the member;checkfails when it is stale.[SameObject],[Replaceable],[PutForwards],[LegacyUnforgeable],[LegacyLenientSetter],[Reflect](forDOMStringandboolean) and[Global];DOMException, written by hand becausewebidl.idlis not vendored.Page. It is the clazel-js host and the bindings' platform.Node,Document,DocumentType,DocumentFragment,CharacterData,Text,Comment,Element,NodeList,HTMLCollection,DOMTokenList, and the exposed HTML element interfaces. They run on clazel-dom's proven operations, with each operation's preconditions checked first.EventTarget,Event,CustomEvent,AbortControllerandAbortSignal, over the events module's dispatch.Window,Location,History,Navigator:Navigatorhas a fixed user-agent string that names only Clazel:Mozilla/5.0 (compatible) Clazel/0.0.console: writes to the host's log, never to the page.location.href = …,assign,replace, the component setters andreloadcallPageHooks::navigate.pushStateandreplaceStatecallPageHooks::update_url. No renderer-side hook exists yet: clazel-renderer does not run clazel-web (that is item 7.17), and 7.16'sUpdateUrlmessage is not built. ThesePageHooksmethods are the hooks the renderer will implement; the page also records every call.tests/bindings.rsruns scripts against parsed documents, with checks transcribed from WPTdom/andhtml/tests.Not done
[LegacyUnenumerableNamedProperties]too. clazel-js never callsHostObject's exotic hooks.list[0]does not work.item()andnamedItem()do work.iterable,maplikeandsetlike, and@@toStringTag. Asequence<T>is read from an Array only, by index.onclick, and the rest);[SecureContext]members;Promise,record, buffer types, interfaces that are not exposed.innerHTML,outerHTMLandsetHTML*. Fragment parsing into the arena is not done. Their getters work.importNode,adoptNode,normalize,compareDocumentPosition,isEqualNode, the namespace lookups, most*NSmethods, andinsertAdjacent*.queueMicrotaskandrequestAnimationFrame. That is the event loop, item 7.15.document.writeandopen, and modules. The tree builder's driver is untouched.AbortSignal.timeoutandAbortSignal.any.Deviations
Window. clazel-js cannot yet make a host-object global.Window.prototype.WindowPropertiesobject.TypeError.[PutForwards]sets with a strictSet.history.stateholds the value itself. There is no StructuredSerializeForStorage yet.characterSetis alwaysUTF-8. The arena does not keep the document's encoding.HTMLElement.ProcessingInstructiongetsCharacterData.alert,confirmandpromptact as "cannot show simple dialogs" and only write to the log.createElement's name check is an approximation of "valid element local name".consoleformatting is not implemented: arguments are ToString'd and joined.%s-style directives are not interpreted.clazel-js/tests/api.rs'swhat_the_vm_lacks_says_solisted arrays anddelete_propertyasNotImplemented. Those three assertions now assert that the operations work.instanceofnow reaches, which then stop at the missingeval.failstays 0.Verification
cargo xtask verify --changed origin/claude/phase7-integrationdid not finish, and there is no final line to report. It was not evenCHANGED CRATES PASSED. Becausextask/changed, the run checks every crate.What the run did:
fail=0.Separately:
cargo xtask verify --part miri clazel-webidl,clazel-web: FAILED onconversions. ConvertToInt used float%, which under Miri gave 0 for 4294967297 →long. The last commit fixes that.cargo xtask verify --part miri clazel-webidlthen gaveMIRI PART PASSED.events_dispatch_through_the_tree, at 216 s.cargo verus verifyon clazel-dom, run by hand from a clean build, gave 477 verified, 0 errors.CI's full verification has not run. Its proof jobs need a reviewer's approval of the
full-verificationenvironment, and this work is not done until that run is green.🤖 Generated with Claude Code