docs(worker): state why pinned requests drop the channel filter, and pin it - #523
Draft
TennyZhuang wants to merge 2 commits into
Draft
TennyZhuang wants to merge 2 commits into
TennyZhuang wants to merge 2 commits into
Conversation
added 2 commits
September 15, 2026 03:25
…pin it Raft task #proj-hands #208 (Hands-lane follow-up from Computer task #816). `?version=` (pinned) requests look the version up across channels: the SQL predicate `((?5 IS NULL AND ch.slug = ?2) OR ?5 IS NOT NULL)` stops filtering by channel and the CASE ordering prefers `main`. That is deliberate, but nothing in the code said so, and the surrounding shape reads like a bug — the obvious "fix" (re-add a channel filter for pinned requests) would actually narrow a documented contract and break pinning a build that lives on another channel. This is comment + contract tests only. No behaviour change, no SQL change. The comment records why the widening is safe: safety lives in the artifact identity comparison below it (divergent same-name bytes across channels fail closed with UPDATE_IDENTITY_CONFLICT), together with version_name being unique per release. It also states the guard's precondition explicitly (`rows.length > 1`), so the single-row path is documented rather than implied. Tests pin the behaviours @Archer specified, all three of which were previously unstated: - cross-channel lookup is the contract, not an accident: a pin naming `main` still resolves a version that only exists on `alpha`, and the response reports the channel the release actually lives on; - divergent same-name bytes across channels fail closed with 409 (the existing test, kept, now adjacent to the contract it belongs to); - byte-identical duplicates across channels are served normally, not rejected as a conflict — this is what makes the divergence test meaningful; - a single-row hit is served as-is with the guard unable to run. Honest note on teeth: only the divergence arm is mutation-detectable. Removing the identity guard reddens it. Narrowing the pinned lookup back to one channel reddens it plus the cross-channel arm. The single-row arm is a behavioural pin only — the guard's precondition is inherent to the match count, so changing it cannot be observed from that test, and the test says so rather than implying a tooth it does not have. Worker suite 580 passed / 1 failed — the failure is the pre-existing `spawnSync /usr/bin/sqlite3 ENOENT` (feedback_closure_reason_migration), a machine fact that worker-tests.yml already documents as unrelated to the commit. `tsc --noEmit` is 900 before and after with an empty delta, as expected for a comment-and-test change. Signed-off-by: Volta <volta@mail.build>
…g tests Addresses @Huarong's CHANGES on a87f861 (task #proj-hands #208 / review #209). No behaviour or SQL change. Three valid objections, all accepted: 1. The three tests I added duplicated existing coverage. Base already had "allows an exact pin that exists only on alpha" (cross-channel lookup), "prefers main when cross-channel artifact identity matches" (byte-identical duplicates), "fails closed when a pinned cross-channel artifact diverges" (409), and "selects an exact pinned active version" (single row). Removing my copies and narrowing the pinned lookup to one channel still reddens 4 of the existing tests, so my additions contributed no mutation coverage — only duplicate fixtures. They are deleted; the existing tests are instead given the assertions that carry the contract (release id and version alongside the channel, and the byte-identical case explained), which is where the teeth already were. 2. "No other channel consulted" was wrong, and the single-row test could not support it. The query still enumerates every eligible channel; exactly one row merely matches. The claim is removed, and the comment now describes the precondition as an implementation precondition rather than an observable response shape — which is what `rows.length >= 0` staying green shows. 3. "version_name is unique per release" was the wrong justification. The schema constrains UNIQUE (app_id, version_name, target) on external_build_targets (migration 0044), i.e. per app/version/target — not a cross-release or cross-channel uniqueness guarantee. The comment no longer attributes safety to uniqueness and instead states the actual contract: candidates are collected by version/target across eligible channels; with more than one row the artifact identity set must collapse to one member or the request fails closed with UPDATE_IDENTITY_CONFLICT; with exactly one row there is nothing to compare against, so no cross-row check runs, while the per-row integrity checks below always do. Verification: focused 16/16 (base count, no duplicated fixtures). Full worker suite 577 passed / 1 failed — the failure is the pre-existing `spawnSync /usr/bin/sqlite3 ENOENT` (feedback_closure_reason_migration), a machine fact worker-tests.yml documents as unrelated to the commit. `tsc --noEmit` 900, unchanged. Mutation re-check on the existing tests: narrowing the pinned lookup reddens 4, dropping the identity guard reddens the divergence test. Signed-off-by: Volta <volta@mail.build>
This branch has not been 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.
Hands-lane follow-up from Computer task #816, Raft task #proj-hands #208. Scoped by @Archer: comment + contract tests only.
Why
?version=(pinned) requests look a version up across channels — the SQL predicate((?5 IS NULL AND ch.slug = ?2) OR ?5 IS NOT NULL)stops filtering by channel, and the CASE ordering prefersmain.That is deliberate, but nothing in the code said so. The shape reads like an oversight, and the obvious "fix" — re-adding a channel filter for pinned requests — would actually narrow a documented contract and break pinning a build that lives on another channel (e.g. a feature-channel build). This PR makes the intent legible so the next reader doesn't "correct" it.
What changed
Comment only, in
handlePublicCliBinaryUpdateCheck. It records:version_nameon multiple channels with divergent bytes fails closed withUPDATE_IDENTITY_CONFLICT, andversion_nameis unique per release;rows.length > 1. A single matching row is served as-is and is not identity-checked against other channels.No SQL change. No behaviour change.
Tests
All three previously-unstated behaviours are now pinned:
mainstill resolves a version that exists only onalpha, and the response reports the channel the release actually lives on;Honest note on teeth
Only the divergence arm is mutation-detectable:
The single-row arm is a behavioural pin only — the guard's precondition is inherent to the match count, so widening or narrowing it cannot be observed from that test. The test says so in a comment rather than implying a tooth it does not have. (I verified this: forcing
rows.length >= 0leaves the suite green.)Verification
spawnSync /usr/bin/sqlite3 ENOENT(feedback_closure_reason_migration), whichworker-tests.ymldocuments as a machine fact unrelated to the commit.tsc --noEmit: 900 before, 900 after, empty delta — expected for a comment-and-test change.6acebaa(currentmain).Overlap note for the lander
PR #522 (
volta/hands-206-channel-alias-shadowing) is also based on6acebaaand touchesworker/src/routes/public_v2.ts— a different region (the channel lookup / alias resolution), but the same file. Whichever lands second should expect a trivial rebase. Both are independent, reviewed separately, and neither contains the other.Not part of Computer PR #7764. Source only — no merge, deploy, or production action.