Repository navigation
refactor: offload Exact builds through the iOS plugin interface - #6650
Merged
Merged
Conversation
Replace the typed exact fields of build.offer, build.start and BuildTarget with one generic plugin field: id, version and pins, plus payload and checkout in the start. The job host validates the checkout name and sibling path itself and looks the plugin up by id; the worker runs one sequence driven by the plugin the job names. Exact keeps every message, code, label and log event.
The renamed field is read only by the job of the same Stim build that sent it, and Exact builds are never retained, so no compatibility bump.
janicduplessis
marked this pull request as ready for review
November 28, 2026 22:29
This was referenced Nov 28, 2026
Open
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.
Closes #6649
Slice S3 of the plan in the design comment on #6599.
Description
After #6648 the local iOS path of the built-in Exact integration ran through the internal plugin interface, but its remote-build path still named Exact in the wire protocol and the generic host: typed
exactfields inbuild.offer,build.startandBuildTarget, the job host callingexactPinsParam,exactOffloadParamandexactToolProblemsdirectly, and the worker'sselected.id !== 'exact'check with its Exact-only sequence.This changes no behaviour and loads no plugin. A worker still builds only the built-in Exact module, which the job looks up by id.
Two parts of the issue are not done here, on purpose, because each needs a decision the issue did not make. They are listed first under "Deviations".
Solution
What moved where
packages/core/protocol.tsand the JSON Schema inpackages/server/src/protocol.ts:BuildExactPinsand theexactfields becomeBuildPluginPinsand onepluginfield. The offer carries{ id, version, pins }, the offer resultplugin: { missing }, the start{ id, version, pins, payload, checkout: { name, sibling } }. For Exact,pinsis the old pin object unchanged,payloadis{ env },checkout.nameis the oldnameandcheckout.siblingthe oldlink.BuildTarget(engine/toolchain.ts) carriesplugin?: BuildPluginPinsinstead ofexact?: ExactPins.integrations/plugin-offload.ts: the host's own validation of the checkout name and sibling path (today'sAPP_NAMEandLINKrules), and the readers of the offer's and the start'spluginfield, which look the plugin up by id and call its validators.integrations/ios-plugins.ts: the built-in iOS plugin list (Exact only) andiosPlugin(id). The Exact source and its offload member moved here fromexact-ios.ts, which keeps only the project and doctor bindings.integrations/plugin-ios.ts:IosPluginSourcegainsversionand theoffloadmember; the adapter builds the target and the request generically and validates the checkout layout on the client before an offer.job/offload/host.ts: the offer and the start readpluginthroughplugin-offload.ts; the fingerprint-replay skip keys onplugin.job/offload/worker.ts:compileExactbecomescompilePlugin, selected by the id the job names. Codes, the simulator label and the progress line are built from the id and name:exact-tools,exact-simulator,exact-build-failed,stim-exact-,Exact Debug, andexact_buildthrough the sharedrunPluginIosBuild.integrations/exact-offload.ts:exactOffloadParamsplit into the pins validator it already called andexactPayloadParam; the worker's app.json check (exactProjectProblem) and environment filter (exactBuildEnv) moved here unchanged.The interface as it ended up
Deviations from the design comment
PluginHost, and the tool checks stay synchronous on the host side. The design gives the module one host object (execplus an abort signal) for the tool checks. The Exact module is lint-restricted to Node built-ins, so a module-side check needs that host passed in.exact-offload.test.tscallsexactToolProblems(pins, env),exactLocalToolProblems(app, env)andexactCheckoutDir(pins, home)with no host, and the plan is read synchronously:ProjectDoctor.offloadTargetsreturnsnullsynchronously for an app that cannot offload, whichcommands/doctor.tsturns intocheck: null, and a test asserts thatnull. Moving these behind an asyncexectherefore needs one of: a host argument added to those test calls; host-side wrappers that only tests use, whichknip --productionand CLAUDE.md reject; or a test helper that binds a host. Each edits tests beyond an import or anawait, so this PR leaves Exact's plan, tools and checkout lookup inexact-offload.ts, synchronous, wired into the genericoffloadmember byios-plugins.ts, and adds no host object (a host with no caller would be a member Exact does not use). The doctor'sexact-toolsfindings stay where refactor: serve Exact iOS through an internal plugin interface #6648 left them.OffloadProblem.codeis part of the publishedstimAPI (packages/stim-cli/api.api.txt, throughBuildMachineReport.problemsinstim doctor --json). Replacing'exact'with a generic code changes that line, whichplugin-api-report.mjsrejects without aSTIM_API_VERSIONbump and a release note. SoofferProblems,problemCode, the doctor's title and fix, and theexact-toolsremedy incommands/ios/artifact.tsare unchanged apart from readingtarget.pluginandoffer.plugin.check(pins, payload). The offer validates pins alone and the start validates pins and payload; the existing validators were already split that way.malformed,projectandenv. The offer and start refusals ("An Exact offer needs the exact2 commit and the Bun and Rust versions.", "An Exact build needs an iOS request with its app name, pins and settings.") cannot be built from the id and name, and the host also needs them for its own checks (native present, platform not iOS, bad checkout).projectholds the app.json and declared-settings refusals, which run before the tool check;envholds the environment filter. The design put the filter insidebuild; keeping it a separate member leaves the localbuilduntouched.sourcereturns the commit too. Sibling placement checks the placed checkout out at the pinned commit, and only the plugin knows which pin that is.versionis the Stim version for the built-in. The wire carries it and the job host requires a string, but nothing compares it in this slice, so it cannot refuse a build.Compatibility of the renamed wire field
The client and the job that reads
build.offerandbuild.startare always the same Stim build:ownBuild()andBuildConnection.startJobinpackages/stim-cli/src/offload/client.ts(lines 464 and 645).entry(),packages/server/src/offload-jobs.ts:290-300). It fetches the npm release or takes the client's packed build only underserver.acceptClientBuilds, and checks the installed build id (:377). When it cannot,job.startanswersjob-refusedorjob-needs-package(:228-252), and the client gets no job and sends no offer.build.offerandbuild.startitself (packages/stim-cli/src/job/offload/serve.ts:67,72) and passes the job to its worker child, a process of the same build (packages/stim-cli/src/job/main.ts:26), over stdin.Components that see these frames but may be another version:
exacttodaypluginoffload-jobs.ts:146,405), as LLP 0009 "Run the client build" freezes.job.startfails first, and the peer check refuses it.tsdown.config.ts:62only writesdist/protocol.schema.json, and the schema is read by tests.BuildStartParams.plugin.apps/mobile/mock-server/fixtures, test JSON)exact.jsonis a status payload.checkout/.../up/<name>,.stim-exact2-,stim.exact2-source,stim-exact-simulators.STIM_BUILD_COMPATstays 6. LLP 0009 "Artifact compatibility" asks for a bump when a machine with the same value but the other version of a listed file would build a different artifact or read a build or artifact message differently. Exact artifacts are never retained or reused, nothing else a worker builds changed, and the renamed field is read only by the job of the same build that sent it.scripts/build-compat.jsonrecords the new digest.New refusal texts, unreachable for Exact
build.offer names no plugin this Stim builds.andbuild.start names no plugin this Stim builds.for an unknown id or apluginthat is not an object.This Stim builds no <id> plugin.(unsupported-provider), after the job host has already checked the id.<name> asks for a checkout layout a build machine does not place, when a plan returns a checkout the host rules reject; Exact's plan already applies the same rules and returns its own reasons.For later slices
PluginHostand the tool checks moved into the module (deviation 1), with the test edits it needs.STIM_API_VERSIONbump (deviation 2).pluginssetting, comparingversion, and theJOB_SIMULATORpattern.Moved unchanged, and still odd
.stim-exact2-staging prefix and thestim.exact2-sourcegit config key. Changing the names would orphan a worker's existing checkouts.reservedAreaEntryandEXACT2_MAKINGstay inexact-offload.ts, which the worker imports.Test plan
Checks, each with its exit code:
pnpm run format:check0,pnpm run lint0,pnpm run typecheck0,pnpm run build0,pnpm run knip0,node scripts/build-compat.mjs0 (after--update),node scripts/plugin-api-report.mjs0.Tests:
exact-ios.test.ts,exact-offload.test.ts,project-registry.test.ts,project-contracts.test.ts,build-headroom.test.ts,ios-command.test.ts,mobile-protocol.test.ts,receive-protocol.test.ts,guide-budget.test.ts,offload-engine-admission.test.ts: 826 passed.pnpm run test:integrationonoffload,exact-offload-worker,offload-job,server-builds,build-toolchain,protocol-2-cli,offload-worker-entryandoffload-connection: 188 passed. The first two also passed onmainbefore the change (53). Pull request CI does not run these two. The worker test runs the real generic sequence with real git: checkout naming, sibling placement and its containment refusals, the environment filter and the build.EXACT2=/nonexistent CARGO_TARGET_DIR=/nonexistent: 37 and 8 passed.pnpm test --changed origin/main, run on the commit beforeoffload-engine-admission.test.tswas updated: 8468 passed. That file passes on the head (5 of 5). Onestatus.integration.test.tscase, "status prints the end command for a stimd that did not answer...", failed under load in that run; it passes when run alone and touches no offload code.Test edits, each one naming the renamed field:
exact-ios.test.ts: the fake machine answersplugin:instead ofexact:in its offer.offload.integration.test.ts: the target, offers and start usepluginin place ofexact; the expected reasons are unchanged.exact-offload-worker.integration.test.ts: the job builder writespluginfrom the same plan; assertions unchanged.exact-offload.test.ts: the doctor test readstarget.plugin?.pins. The malformed-request test goes throughpluginStartParamwith the same valid, older-client and eight malformed requests, now in thepluginshape; a malformed request returns the refusal text instead ofnull.mobile-protocol.test.ts: the fullBuildStartParamscarriesplugin.offload-engine-admission.test.ts: the admitted Exact start sendspluginin place ofexact.Added: the round-trip test named above (changing the plan mapping's payload shape fails it), and one assertion in the malformed-request test: a start naming a plugin id this Stim does not build is refused. Making
iosPluginaccept any id fails it, and replacing the host's checkout-name or sibling rule with/./fails the rows for a hostile checkout name and sibling path.Before and after, on a real Exact app, with a scratch Stim home:
mainstim ios --plan --jsonstim ios --plan --json --remote-build localstim ios --plan --json --remote-build <machine>stim doctor --jsonstim ios --json --remote-build locallaunched: trueIn this copy the offload plan is unsupported (the app copy and its exact2 checkout share no top directory), so these captures exercise the plan, placement and doctor paths around the offload member, not the target or request mapping. The new test
a build machine reads the Exact build request the client plans as the client sent itcovers that mapping: the plan the client builds goes through the job host's reader unchanged.Real remote builds, from one scratch Stim home approved for builds on a second Mac acting as build machine, first with the merge base (e0e746f) and then with this branch (c09fafb), on the same copy of a real Exact app. The build machine's stimd is the stable 2.0.0 release, so the renamed field passes through an older stimd. Each client pushed its own Stim build into its jobs: the machine's engine store gained both build ids.
--remote-build <machine>stim ios --json(Debug)launched: truestim ios --configuration Release --jsonproduction updater requires deploy.signing.keys)stim ios --jsonwithmodulesdeclaredstim-exact-<job>simulator, then Exact rejects the module namestim doctor, exact2 commit absent on the machinestim ios --json, exact2 commit absent on the machineSTIM_OFFLOAD_REFUSEDwith the same commands, no job startedstim ios --plan --jsonin each stateAfter removing timestamps, ids, ports and paths, what still differs follows from the order of the runs: a cold compile and a created simulator on the first build, an incremental compile on the second, and a
stim status --jsonright after the second, short build that printed the snapshot its stimd took at boot (ageMs22522), because the home already listed that directory from the earlier status calls; the status code is not in this diff. Not covered: a Release build or a build with native modules that succeeds on the machine (both fail inside Exact with the merge base too, for reasons in the app), and a cold Debug build with this branch.