Repository navigation
refactor(runners): clean up design problems in the merged runner code (task #209) - #669
Closed
aixle-com[bot] wants to merge 2 commits into
Closed
aixle-com[bot] wants to merge 2 commits into
aixle-com[bot] wants to merge 2 commits into
Conversation
… config rules in ConfigSchema, action-only runner policies, one tenant rule (task #209) - Runners::Operations: the runner_env_<id> channel carries typed JSON messages (op_enqueued, poll_waiting); the poll: prefix goes. - Gateway request bodies and the long-poll query are checked against JSON Schemas in runner/protocol/schemas/v1/ through Runners::ProtocolSchema. - ManualAdapter's config rules move to Runners::ConfigSchema as pure functions; Runner's validation calls only ConfigSchema, and only when config or runner_type changes. Runners::Save saves with a plain save. - Runner policies authorize the action only; the controllers' lookup decides which runner a request may touch. RunnerManagement goes; Runners::Form holds the shared form pieces. - Runner.of_tenant / Runner#of_tenant? hold the tenant rule; TenantScope, visible_for_project and RunnerReference#owned_runner call them. TenantScope.owns_runner? goes. Signed-off-by: Aixle Flow <[email protected]>
…meral registration's name (task #209, Fix CR round 1) - RegistrationsController#create: a non-string name reaches Registration.register! as nil again, so an ephemeral request answers 422 ephemeral_not_supported, not 500. - Revert item 7 to the documented pattern: TenantScope.owned(Runner) and TenantScope.owns_runner? hold the ownership rule, Runner.visible_for_project is the picker scope; Runner.of_tenant and #of_tenant? are removed. - Docs: drop the Runner exception, reword the no-IO validation bullet. Signed-off-by: Aixle Flow <[email protected]>
Contributor
Author
|
Reopened in Alex's name for the squash merge (task #209). |
aixle-com Bot
pushed a commit
that referenced
this pull request
Nov 10, 2026
Conflicts resolved: - Files touched on staging only by the pre-squash branches of task #209 (PR #669) and task #211 (PRs #667/#668) take develop's version, which carries the reviewed, merged form of the same work (#670, #671, #672). - test/integration/web/company/billing_test.rb: keeps the billing redesign's (#646) test body with develop's 14-day trial values (#678). - CHANGELOG.md: develop's 1.11.0 entry for the 14-day trial; the billing redesign entry already present above is kept once. 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.
Summary
Board task #209: fixes the design problems that the 2026-11-07 review found in the merged runner code, as Alex decided on 2026-11-08. Items 1 and 6 were dropped. Items 2, 3, 4 and 5 are done. Item 7 was reverted in Fix CR round 1 (Alex, 2026-11-09): the tenant rule stays in
TenantScope, the project's documented pattern. Behaviour is unchanged except for item 4's change, which has its own test.2. Typed messages on the long-poll channel.
runner_env_<id>now carries JSON objects with atypefield:{"type":"op_enqueued","sequence":N}is an enqueue's wake-up, and{"type":"poll_waiting","poll_id":"<uuid>"}is a waiting poll's announcement. Thepoll:prefix is gone. A message that is not a JSON object, or has another type, makes a waiting poll read the queue again. It does not end the poll.3. JSON Schemas for gateway requests. Three schemas are in
runner/protocol/schemas/v1/:register.request.json,ops.query.jsonandop_result.request.json. The new helperRunners::ProtocolSchema.valid?(name, document)validates against them throughjson_schemer, the same wayTemplates::Packagevalidatestemplate.yaml. The error codesinvalid_registration,invalid_resultandinvalid_requestare unchanged, andPROTOCOL.mdlinks to the schemas. The hand-written checksoutcome,non_negative_integerandstring_or_nilare replaced. Cases that needed care to keep behaviour unchanged:os/arch: PROTOCOL §5.1 says a value that is not a string is ignored, and fixtureregister/boundaries.jsonpins that. The schema lets such a value through, and the controller then drops it (ignored_unless_string).ephemeral: it is still read the way it was before, and its refusal still comes before the schema check (PROTOCOL §5.1 ordersephemeral_not_supportedbeforeinvalid_registration). A non-stringnamereachesRegistration.register!asnil, so an ephemeral body withname: 5still gets422 ephemeral_not_supported.Integer(value, 10)), so the schema checks the type and the range, includingafter≤ 2^63−1.1.0as an integer, so anexit_codeof1.0is now accepted and stored as1. It was a 422 before. PROTOCOL §5.5 documents this.4. Config rules move into
Runners::ConfigSchema. The three rules fromManualAdapter#validate_config(home mount path, acknowledgement of writable host mounts, Docker socket) are now pure functions inConfigSchema::TYPE_RULES.ConfigSchema.errorsreturns the schema's errors and, once the schema passes, the type's rules.Runnervalidates config only throughConfigSchema, and only whenconfigorrunner_typechanges.Runners::Saveis now thin and calls a plainsave(no moresave(validate: false)). The rule "config checks do no IO" is written in DESIGN.md §5.1 and inimplementation-patterns.md.revoke!,soft_delete!,disable!orenable!. A test covers a runner whose stored config fails the checks: it can still be disabled, enabled, revoked and deleted.5. Runner policies and controllers follow the project pattern. Both runner policies authorize the action only, through
dynamic_authorize!. Therecord.is_a?(Runner)branch andauthorize_runner!are gone. The controller's lookup decides which runner a request may touch: on the project page, writes look among the project's own runners; in company settings, among the company-level runners; index and show among the runners the page lists.RunnerManagementis deleted; the actions live in the two controllers, and the shared pieces are inRunners::Form.can_manageispolicy.update? && runner.project_id == current_project.id.404instead of the Pundit denial redirect. It is still refused.7. Tenant rule: unchanged from
develop. Perdocs/architecture/implementation-patterns.mdanddocs/project/context.md, ownership is defined inTenantScope.owned(withTenantScope.owns_runner?for a loaded row), andRunner.visible_for_projectis the picker scope, as for integrations.RunnerReference#owned_runnercallsTenantScope.owns_runner?.Related issues
Board task #209 (Simple Kanban). Runs before 8b.
Type of change
How was this tested?
Runners::ProtocolSchemaTest: every schema file is named and valid; accepted and refused bodies for each schema.exit_code: 1.0is stored as1; an ephemeral registration is refused as such even when the rest of the body is invalid (includingname: 5).ConfigSchemaTest: the manual rules (moved fromManualAdapterTest), rule ordering and type scoping,writable_host_mounts.RunnerTest: a type rule is refused by any save; config checks run only when config or type changes; a stale-config runner can still be disabled, enabled, revoked and deleted;TenantScope.owned(Runner)/owns_runner?include deleted runners and exclude other projects and companies.Runners::SaveTest: capabilities, a type-rule message, an unavailable type, the name race.can_manage; an unacknowledged writable mount is refused with the same message as before.RunnerReferenceTest:owned_runneron a deleted runner and on a stale id.Results of the Coder runs are in the board task comments.