Repository navigation
feat(runners): the runner core without Coder, in the layers of runner-layers.md (17c, #305) - #920
Merged
Merged
Conversation
Runners::Allocator replaces Machines on the start path for every runner type; the environment state machine gains its provisioned arm; every difference between types on the start path becomes an Adapter method. Signed-off-by: Alex <[email protected]>
Signed-off-by: Alex <[email protected]>
…s; runtime-layers doc Signed-off-by: Alex <[email protected]>
…est fixes Signed-off-by: Alex <[email protected]>
Signed-off-by: Alex <[email protected]>
Signed-off-by: Alex <[email protected]>
Signed-off-by: Alex <[email protected]>
…dempotent acquire - RunnerEnvironment#being_built? and .being_built replace provisioning?||booting? in the dead-container scan and Registration. - Bound registration locks its environment before the token (runner, environment, credentials). - Allocator.take! re-checks the session's hold under the runner lock and saves the hold through the session's validations. - implementation-patterns.md lists all RunnerEnvironment states. Signed-off-by: Alex <[email protected]>
Signed-off-by: Aixle Flow <[email protected]> Signed-off-by: Alex <[email protected]>
Signed-off-by: Alex <[email protected]>
…e-without-coder # Conflicts: # db/schema.rb
|
All contributors have signed the CLA. Thank you! |
NOX73
commented
Nov 30, 2026
NOX73
commented
Nov 30, 2026
NOX73
commented
Nov 30, 2026
NOX73
commented
Nov 30, 2026
NOX73
commented
Nov 30, 2026
NOX73
commented
Nov 30, 2026
Signed-off-by: Alex <[email protected]>
Signed-off-by: Aixle Flow <[email protected]> Signed-off-by: Alex <[email protected]>
…ls tests Signed-off-by: Alex <[email protected]>
Signed-off-by: Alex <[email protected]>
Signed-off-by: Alex <[email protected]>
Signed-off-by: Alex <[email protected]>
Signed-off-by: Alex <[email protected]>
Signed-off-by: Alex <[email protected]>
Signed-off-by: Alex <[email protected]>
…e index Signed-off-by: Alex <[email protected]>
aixle-com
Bot
force-pushed
the
feature/runner-core-without-coder
branch
from
November 30, 2026 13:01
9e68af2 to
561857e
Compare
…nt limit - Runners::Interface is the one module code outside app/services/runners calls; the layering test fails on any other layer reference outside it. - Adapter#finish_leaving! and #let_go! write the teardown-then-signal and let-go-then-signal sequences once. - Core::Registration.revoke! and .unregister! replace the public end_registration!. - Gateway::Platform takes the gateway URL, binaries and config out of Registration. - scan_contact! takes the session only; TerminalSession and Runner name the predicates and the environment limit. - Allocation.take! drops its savepoint. Signed-off-by: Alex <[email protected]>
…e interface Signed-off-by: Alex <[email protected]>
…tializer test Signed-off-by: Alex <[email protected]>
…y machine_revoked is sent twice Signed-off-by: Alex <[email protected]>
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.
Row 17c of
docs/design/agent-runtimes/runner-coder.md§14 (task #305), reworked to the layer design of task #308:docs/design/agent-runtimes/runner-layers.mdonfeature/runners-layers-designatee5a255e(PR #931, not merged). For names, layout, the adapter interface, locks, state changes, transactions and IO that design wins; the behaviour of row 17c and "What must not change" still hold. Nothing here creates acoderrunner:coderstays out ofAdapter::REGISTRY, and the Coder services, the Coder adapter, the reconciler and the UI are 17b, 17d and 17e.What changed in the rework
app/services/runners/is now four layers (runner-layers.md §3, §4):Runners::ReasonsandRunners::Errors(§8):NoMachineisErrors::NoEnvironment, the wait and refusal reasons are one set of constants,Pending,ProvisionError,UnsupportedOperation,Refused, plus the newInTransactionandInvalidTransition.AdmittedPhaseActivity,SessionAdmission,SessionService,WorkflowServiceread them.Infrastructure::Store::Environments(locked,locked_under_runner, strictapply!,create!,take_free!,free!,let_go!) is the only code that firesRunnerEnvironmentStateMachineevents.apply!raisesInvalidTransitionfor an event the state does not allow and rolls a multi-event call back; the tolerant callers checkmay_<event>?insidelocked.Store::Locksis the only code that locks a runner row.Adapterand raisingNotImplementedError;Adapters::Manual(wasManualAdapter) andAdapters::Provisioned(wasRunners::Provisioning, now the base class whoseadvance!is the step machine).ReleaseContextreplacesruntime:;Operations::RunandOperations::Outcomemoved down fromRunnerRuntime.fail!andend_registration!are state-only,teardown!is the IO step. The registration trio (issue_registration!,lock_registration_target!,register_machine!) andcheck_in!replace the branch on a bound token and the type checks.Credentials::Tokens.mint_unbound_registration!and.mint_bound_registration!.Credentials.rotate!split intoCredentials::Rotation.rotate_pair!andCore::Registration.refresh!, which fails the environment through its adapter in the same transaction.Operations::Queue.enqueue!no longer wakes (the caller runsQueue.wake),Relay::Signalspublishes at once and each method that changes a hold publishes, theRunnerEnvironmentafter_saveis gone, andStore::Transactions.none_open!guards every method that does IO.Core::Registration.revoke_runner!and.delete_runner!replace theRunnerafter_savecallbacks andRunnerStateMachine#soft_delete!; the controllers call them.finish_pending_retirements!(D16) is called bySettleAbandonedActivity.Core::Management(runner_types,form_attributes,save,check_health!,list_environments,machine_counts) andInfrastructure::ConfigSchema.record_rules, which moves theRunnervalidations by type into data (§10).core/,adapters/,infrastructure/<area>/);machines_test.rbandmachines_concurrency_test.rbkeep their paths. New:layering_test.rb,adapter_contract_test.rb,state_machines/runner_environment_ownership_test.rb,state_machines/runner_ownership_test.rb,infrastructure/store/environments_test.rb,core/registration_retirement_test.rb, and a reused refresh token on a provisioned environment.docs/architecture/runtime-layers.mdas §12.4 says (the layers, where differences live, a new "Transactions and IO" section, the guarantees with the new names, adding a runner type); the names inimplementation-patterns.md,docs/architecture/index.mdand thePROTOCOL.mdnote.The behaviour of the first round of this PR (17c) is unchanged: the allocator's steps, the provisioned arm, the migration (version kept, staging applied it), the two §17 checks, and the five fixes of triage batch 1.
Review round 3 (Alex's six threads and the board review)
Runners::Interface, the one module code outsideapp/services/runnerscalls (controllers, activities,RunnerRuntime,SessionService,WorkflowService,Sessions::Lifecycle, the initializers, models). Each method is one delegation to a core module or to read-only infrastructure;layering_test.rbfails on an interface method that is more than that. Name: I kept Alex'sInterface.Gatewayis taken (Infrastructure::Gateway, the runner gateway controllers),Apireads as HTTP, andFacadenames the pattern, not what a caller programs against;Runners::Interface.revoke!(machine)reads well at the call site.OUTSIDE_ALLOWLISTinlayering_test.rb, each with its reason; the test fails on any otherRunners::constant outside the directory, and on an allowlist entry nobody uses):Runners::Errors,Runners::Reasons(public by the test'sPUBLIC_MODULES),Runners::Adapter::ReleaseContext(data the runtime builds),Infrastructure::Credentials::Refused(the error the gateway and the page map),Infrastructure::Gateway::ResultUploads::Unreadable(the error the runtime maps),Infrastructure::ConfigSchema(Runner's validations).scan_contact!(session)reads the environment from the session.TerminalSession#on_runner_environment?and#runner_environment_being_built?replace the two conditions inScanDeadContainersActivity.Runner#environment_limitreplacesmax_environments || max_concurrency.Core::Registration.revoke!(machine)and.unregister!(machine)(the machine's ownaixle-runner unregister) replace the publicend_registration!, which is private now. The gateway, the runner pages andRunnerMachineReturncall them through the interface.Adapter#finish_leaving!(environment, held_before)(the teardown of atearing_downenvironment, then the relay's signal if the hold changed) andAdapter#let_go!(session)(let go, then the signal) are on theAdapterbase.Allocation.release!,.sweep_abandoned!,.scan_contact!andRegistration.check_in!,.refresh!,end_one!and the retirement's session step call them; the sequence is written once.Infrastructure::Gateway::PlatformtakesBinary,binaries_for,configandgateway_urlout ofCore::Registration.Allocation.take!has no savepoint:acquire!refuses an open transaction, so no caller's transaction exists. The concurrency suites pass without it.git diffof the old and the new head was empty before the force push), as decided.Costs (§14 of runner-coder.md)
Core::Allocation.acquire!takes the runner rowFOR UPDATEfor every type, whereMachinestookFOR SHAREfor amanualrunner.MachinesConcurrencyTest(two sessions racing for onemanualmachine, two attempts of one session, revoke against acquire in both orders) passes.manualmachine throughend_registration!(§6.1, D50): every machine becomesgonewithstate_reasonrevoked.manual-specific code is inAdapters::Manual(andAdapters::Manual::Availability).The first run of
finish_pending_retirements!, and other behaviour changesdevelop, a runner's Revoke revoked its credentials and ended its sessions but left itsmanualmachinesregistered(orfailed). The first run offinish_pending_retirements!(one minute after deploy, on the abandoned-session schedule) finds every environment that is notgone(and nottearing_down) under a revoked or deleted runner and runs the second step of the retirement for that runner: the relay is toldmachine_revokedfor each of its machines, any session of it that is still not ended fails with the revoked message (and lets its machine go), and each machine becomesgonewithstate_reasonrevoked, its credentials revoked again (they already are). What a person sees: the machines of an already-revoked runner show as gone instead of offline or failed. No live runner is touched. Cost: one pass over those runners, once; afterwards the query finds nothing. Covered byRegistrationRetirementTest("on its first run it ends the machines a runner revoked before this code left registered or failed").acquire!,release!,sweep_abandoned!,check_in!,refresh!,end_registration!,revoke_runner!,delete_runner!,Operations::Run.calland the outside adapter methods raiseErrors::InTransactionwhen a transaction is open. Before,Operations.awaitonly said so in a comment. The full Rails suite passes with it; a caller found later would fail loudly instead of holding a lock across an op.Design deviations
Where the design did not fit the code, the closest reading, for the design to be updated from:
Store::Transactions.none_open!is ininfrastructure/store/transactions.rb(gap 1 of the decision; missing from the §4 tree).ReleaseContext#deadline_atis a callable, not a value. The scrub and the reset that follows it each get the lifecycle budget from the moment they are sent, asRunnerRuntime#lifecycle_opgave them; a value computed once would shorten the reset's deadline.Adapter#end_registration!answers the id of the session the environment held, so the core knows whether to tell the relay the hold went. The adapter still fails that session itself (after the row's own transaction), as §5.2 says.Resolveris gone, with no alias.Core::Selection.resolve!(the name keeps the bang: it raises) andErrors::Refused;SessionService,WorkflowServiceandLaunchStepSessionActivitycall them directly. §8 keptResolver::Refusedas an alias; nothing else referenced it.Core::Managementnames:runner_typesandform_attributes(the two halves ofform),save(answers true or false, asRunners::Save.calldid;save!would say it raises),check_runner!andapply_health(one runner, used by the tests),machine_counts(the runner list's busy/total, whichRunnerResourcereads).Core::Allocation.cleanup_ready?(session, environment)and.stop_first?(environment)take the recordsRunnerRuntimealready read.Relay::Signals.hold_changed(environment_id, before): one helper that publishesmachine_sessiononly when the hold differs from what it was before the step.Store::Environments.held_by,.holder_idand.take_free!, andRunnerEnvironment.held_by(the read L1 uses, §3 rule 4), are small additions.mint_bound_registration!checks the state only. With no runner parameter, "another runner's environment" cannot be passed; the row's own runner is locked first. The test of anorigin: registeredrow inprovisioningwas dropped, as §5.3 says the state is the whole condition.finish_pending_retirements!takes nonow:(nothing in it depends on the time) and leavestearing_downrows to the type's reconciler (17d).machines_concurrency_test,allocation_concurrency_test,revocation_concurrency_test,first_use_concurrency_test) hold a transaction open around a core method to force the order of a race. They stubStore::Transactions.none_open!; nothing else in them changed.machines_test.rbandmachines_concurrency_test.rbkeep their paths, as §4 says for the suites of §1 (§12.5 suggests splittingmachines_test; not done).Runner.retired(scope) is added forfinish_pending_retirements!;retired?was the record's form.Runners::Interfaceis the one public module (Alex's decision on the review of this PR); it is not inrunner-layers.md, which lets entry points callCore::*directly (§3 rule 4).OUTSIDE_ALLOWLISTis the list of §3's exceptions.end_registration!runs as an outside method ofCore::Registration: its own transaction (the adapter's), then the session's failure, thenfinish_leaving!and the relay'smachine_revoked. It is private; the callers userevoke!andunregister!.Adapterbase (finish_leaving!,let_go!;Adapter::SHARED_METHODSlists them, so the contract tests do not ask a type to implement them), not in each core module. A core method calls it on the adapter it already holds.finish_leaving!tears down only an environment that istearing_down(amanualmachine'steardown!does nothing, so the change is for a type that isgoneat once).Infrastructure::Gateway::Platform(gateway URL, binaries, the config the runner is told) is a new module; the design did not place them.Not done in this round
developsquash-merges (Alex's decision). The branch was force-pushed once, to rewrite the authors of theAixle Flowcommit, soclapasses.Tests
On a Coder workspace, logs under
/var/lib/aixle-jobs/run1/on it:bin/rails test, no coverage) at0fde84e1: 11995 runs, 1 failure (RunnerProxySettingsTest, which readsrequired_env.rbfor the old constant; fixed in0c025fc4), 0 errors (full-r2.log).0c025fc4:test/services/runners, the two model tests,test/config,test/docsandtest/temporal/activities: 830 runs, 0 failures, 0 errors (run7.log).rubocopon the changed Ruby files: no offenses (rubocop-r4.log).zeitwerk:check: all good.Runner#environment_limit, the twoTerminalSessionpredicates,Adapter#finish_leaving!and#let_go!,Gateway::Platform,end_registration!private, and inlayering_test.rbthe outside-references rule, its allowlist and "the interface only delegates".