js/php: the capability table per target #65
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
Which
stdpackage is real, simulated or a compile error at its import, per target. The table itself is decided: JAVASCRIPT-AND-PHP.md section 2b has the browser and PHP columns (PHP floor 5.6, section 2d, closed #62). This issue is the implementation of that table, not a new decision.Today
compiler/src/project/capability.trbhas one browser column (the playground'sbrowser-wasm64, which hosts the VM) and ignores the architecture, and the only enforcement ismissingCapabilitiesOfincompiler/src/vm/run.trb(the VM, host target).torb build --target browser-jsandtorb check --every-targetcheck no import at all.Source
docs/design/JAVASCRIPT-AND-PHP.mdsection 2b ("It is the input of the checker rule of #65"),docs/design/JAVASCRIPT-BACKEND.mdsection 8 row 8stdname looked up by string; plain TorbScript incompiler/srcthat the current seed already compiles). Do not touchseed/.Scope (decided by the loop)
One PR, two Conventional Commits:
feat(compiler): ...(table, enforcement, tests) anddocs: ...(user-facing table, regeneratedskills/).browser-wasm64(unchanged exceptstd/dns, see below) andbrowser-js. The PHP column is documented in the user-facing table but not enforced yet: there is no PHPBuildTarget(design step: #702). Its enforcement is added with the PHP target, as a just-in-time follow-up issue then (not filed up front, per the contract).std/dnsisRealon both browser architectures (decided by the loop: the package is pure, no natives, the table in section 2b says "#65 should align that"; only its transport,std/network, is missing, and that stays a compile error).browser-wasm64otherwise stays as it is (section 2b):std/sandboxandstd/machinestayRealthere because the playground hosts the VM.Changes
compiler/src/project/capability.trbcapabilityOf(target, package): for.Browser, branch ontarget.architecture:.Wasm64keepsbrowserCapabilityOf(remove"std/dns"from theMissingarm),.JavaScriptcalls a newbrowserJsCapabilityOf.browserJsCapabilityOf(package)encodes the Browser column of section 2b, per package (standardPackageOfis the key, never a module below it):Missing(why):std/process,std/sandbox,std/machine,std/network,std/tls,std/http(eachwhyis the row's reason in one short sentence, e.g. "a program in the browser starts no processes", "a program compiled to JavaScript has neither the front end nor the VM", "a page has no sockets").Simulated(how):std/fsandstd/archive(the origin private file system;extractfollowsstd/fs),std/os(target constants answer, the rest fails withOsError.Unsupported),std/io(sink to the console, standard input at its end),std/parallel(one chunk after another on the event loop).Real: everything else, includingstd/console,std/time,std/task,std/random,std/digest/cipher/signature,std/resource,std/storage,std/dnsand the pure packages of the last table row.missingCapabilitiesOf/MissingCapability(now incompiler/src/vm/run.trb). Make its note depend ontarget.architecture(the playground sentence stays for.Wasm64; for.JavaScript: a program compiled to JavaScript runs in a browser, and a pointer to the capability table page ofdocs/tooling/). The message stays`std/process` does not exist in the browser: <why>. Ifbuild.trbimportingvm/runcreates a cycle or drags the VM in, the worker may move the function and type unchanged to a neutral module (suggested:compiler/src/project/missing-capability.trb), re-export or update the imports invm/run.trbandcompiler/tests/capability.test.trb.compiler/src/cli/build.trb: fortoJavaScript(around line 317, before lowering), call the check, print each diagnostic likereportMissingCapabilitiesdoes invm/run.trb, fail withbuildFailedCodeand the existing problem-count line; nothing is built.compiler/src/cli/targets.trb(problemsOfEveryTarget) and its caller incompiler/src/cli/check.trb: for every target whosecapabilityOfisMissingfor an import of the program's own files, report the import under that target (sotorb check --every-targetshowsbrowser-js:/browser-wasm64:with the error).std/packages are not asked (same rule as the VM). Check howLoweredProblemis rendered and add the diagnostic there rather than a second reporter if that is simpler; the output format of existing problems must not change.torb run/VM path (vm/run.trb) is unchanged (host target, nowstd/dnsis no longer refused in the playground).docs/tooling/target-capabilities.md(frontmatter likedocs/tooling/package-capabilities.md,ordernext to it,source:listingcompiler/src/project/capability.trb), the table of section 2b as a user-facing page: one row per package, columns Browser (JavaScript) and PHP (5.6 floor), Real / Simulation / Compile error, one short reason, how a compile error looks, that the PHP column is documented and enforced once the PHP target exists. Link it fromdocs/tooling/torb-build.md("### --target") anddocs/tooling/torb-check.md(--every-target), and from the playground page for the wasm64 difference (std/sandbox,std/machinereal there).docs/design/JAVASCRIPT-AND-PHP.mdsection 2b andJAVASCRIPT-BACKEND.mdsection 8 row 8 only where they say #65 is open; do not change the decided table.skills/:torb docs skill docs skills, thentorb docs skill docs skills --checkclean.Acceptance criteria
capabilityOf(BuildTarget(.Browser, .JavaScript), p)equals the Browser column of section 2b for every package in the table (sixMissing, the simulations above, the restReal); every machine target staysRealfor all.capabilityOf(BuildTarget(.Browser, .Wasm64), "std/dns")isReal; its other rows, andstd/sandbox/std/machineasReal, are unchanged.torb build --target browser-json a program that importsstd/process(orstd/sandbox,std/machine,std/network,std/tls,std/http) fails with an error at the import statement,`std/process` does not exist in the browser: ..., prints no.mjs, and exits with the build-failed code; an import of aSimulatedpackage (std/fs) still builds.torb check --every-target <program importing std/process>reports the error underbrowser-js:andbrowser-wasm64:and under no machine target; programs without such imports andcheck --every-target std/os(the gate) are unchanged.std/packages are not asked.docs/tooling/target-capabilities.mdexists with both columns, is linked fromtorb-build.mdandtorb-check.md, and agrees with the code (the test below checks the Browser column).browser-wasm64,torb run) behaves as before except thatstd/dnsimports are no longer refused.Test plan
compiler/tests/capability.test.trb(existing; extend):browserJsconstant next tobrowser; table-driven test over the section-2b Browser column: a list of(package, kind)pairs (missing/simulated/real) asserted againstkindOf(capabilityOf(browserJs, package));std/dnsisrealon both browser targets (adjust the existing lists that putstd/dnsundermissing);refusedIn(importsProcess, browserJs)has the one expected message;refusedIn(source with std/fs, browserJs)is empty; "names every missing package once" forbrowserJs;.Wasm64).tools/registry/tests/capability-table.test.trb: parse the Browser column ofdocs/tooling/target-capabilities.mdand compare it withcapabilityOf(browserJs, ...), so the page and the code cannot drift.torb build --target browser-json a program that importsstd/process(stderr andexitpinned) intools/command-line.sh/tests/command-line/arguments.expectedstyle (--updateregenerates), and onetorb check --every-targetcase.sh tools/gates.sh a(andbifCLAUDE.mdasks) in the forge CI; locally onlytorb format --checkon touched files and the one capability test.tools/check-commits.shclean.Dependencies
Moved from the planning lists of the docs; the design record stays the specification.
[loop:torbscript] intake: in scope (author orion, label loop), source ROADMAP.md milestone 9, not a duplicate. A docs table plus a checker rule per target; depends on #62. next: waiting (dependency #62) until 2026-10-10T04:00:00Z
[loop:torbscript] refine: re-checked 2026-10-29T20:10Z: still depends on #62 (PHP version floor; owner decision asked in the TorbScript group 2026-10-29). The capability table per target needs the floor.
next: waiting (dependency #62 owner decision)
[loop:torbscript] claim refine by session:loop-torbscript-20261030 @anthropic:tkoehn until 2026-10-30T23:24Z
[loop:torbscript] decided by the loop: (1) one PR, two commits, no split: the table, the build/check enforcement and the tests are one small change in
capability.trb,build.trb,targets.trbplus docs. (2) The PHP column is documented now and enforced with the PHP target (none exists yet, #702); its follow-up issue is filed just in time, not up front. (3)std/dnsis Real on both browser architectures: the package is pure and section 2b asks #65 to align it; the transport (std/network) stays a compile error. (4)browser-wasm64keeps its other rows (the playground hosts the VM);browser-jsgets its own function keyed on the architecture. (5) The diagnostic reusesmissingCapabilitiesOfwith an architecture-specific note. No owner decision is needed: all of it follows the decided design record.[loop:torbscript] refine: issue body rewritten (goal, files, acceptance criteria, test plan, no seed touch), one PR, label
readyset; tokens used ~120000next: implementation
[loop:torbscript] claim implementation by session:loop-torbscript-20261030 @anthropic:tkoehn until 2026-10-31T03:42Z
[loop:torbscript] release implementation by session:loop-torbscript-20261030 @anthropic:tkoehn: the worker run was cancelled after opening PR #704 (head
efd7f065, mergeable, argus requested); CI on that head is pending. Release of the claim.next: waiting (CI and review of PR #704)