You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
test(ci): ratchet remaining fetchWithAuth bridge importers and hand-built API URLs by identity (#12363) - #21057
The typed client layer, the SLM contract hook and the raw-fetch lint ban of #12363 already landed on main through earlier slices. What was left unpinned is the remaining debt: files still importing the fetchWithAuth bridge and code lines still assembling ${getApiBase()}/... URLs by hand. This PR makes that debt shrink-only so the migration (follow-up #21050) is finite.
What Changed
One file, repo_tests/frontend_api_contract_ratchet_test.py:
Two new ratchet dimensions, fetch_with_auth_importers and hand_built_urls, gated against the merge base like the existing dimensions.
Both are compared by identity, not count: importers by file path, hand-built URLs by (file path, stripped line text) with multiplicity, never a line number. Replacing one site with another at an equal count fails; moving a line within a file does not.
The client-class detector now reads the heritage clause only after a bracket-depth scan over the type-parameter list, so class X<T extends ApiClientBase> {} is counted as a client while a class that really extends ApiClientBase is not.
Control fixtures: generic-constraint decoy, nested generic params that really extend the base, implements-only, multi-line headers, equal-count swap per dimension, line-shift and duplicate-line contrast.
No baseline file: base identities are measured from the exported merge-base tree, so no new file read is added to the python filter.
Verification
No tests were run locally; CI is the gate.
Static counts on this branch tree with git grep (main frontend, SLM frontend is 0 in both): 37 files import the fetchWithAuth bridge; 571 non-comment, non-WebSocket lines contain ${getApiBase()}/ after excluding test files, generated and node_modules paths. The earlier claim of 644 for the URL dimension did not reproduce at this head and is dropped; the ratchet compares against the base tree, so it needs no pinned number.
Notice: 29 open PRs — past the runaway threshold (25)
This is not a request to defer this PR. There is no cap on open PRs (#19397) -- nothing blocks opening or pushing a PR.
This notice only means the count is high enough to be worth a glance for a runaway — something opening PRs in a loop, or a merge pipeline that has stalled so nothing is draining.
If the queue is draining normally, ignore this. Otherwise:
Check whether CI is dispatching at all — see the ci-dispatch-watchdog status on these PRs
Approved PRs land through the merge train the coordinator sequences (merge commits, never squash) -- check the open chore(merge-train) PR is moving, not each PR on its own
Look for a loop opening near-identical PRs
Warn-only runaway detector — .github/workflows/pr-queue-gate.yml. It never blocks a merge.
Reviewing files that changed from the base of the PR and between d8c18a8 and 0673ce6.
Files selected for processing: 1
repo_tests/frontend_api_contract_ratchet_test.py
Walkthrough
The frontend API contract ratchet adds client-pattern detection and measures fetchWithAuth importer files and manually assembled API URL lines. Tests cover detector behaviour and compare dimension growth or shrinkage against the base.
Changes: Frontend API contract ratchet
Layer / File(s)
Summary
Detectors, measurements, and regression tests repo_tests/frontend_api_contract_ratchet_test.py
Client detection includes bare ApiClient and ApiService names, excludes ApiClientBase subclasses, and retains mock exclusions. Inline generic detection includes .call<...>. New dimensions count files importing fetchWithAuth and lines assembling ${getApiBase()}/, with comment and WebSocket URL exclusions. Tests cover these patterns and verify that increases are reported against the base while decreases are not.
Merge Risk: Moderate · previous review d8c18
The new frontend API ratchet has two gaps that let new raw-client or bridge usage slip past the guard. Several earlier concerns about the typed client, type generation and docs are still open and should be confirmed fixed before merge. None of these is a runtime outage; they weaken API-contract enforcement and some typed-call behavior.
Pre-merge checks: 4
Check name
Status
Explanation
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title names the main change: it ratchets the remaining fetchWithAuth bridge importers and hand-built API URLs in the frontend API contract ratchet test. The raw summary confirms the change adds bo…
Full details: Title check
Explanation
The title names the main change: it ratchets the remaining fetchWithAuth bridge importers and hand-built API URLs in the frontend API contract ratchet test. The raw summary confirms the change adds both dimensions to the ratchet test, with detectors, advice text and tests. The title is specific and matches the changeset. It does not cover the detector refinements (ApiClientBase exclusion, comment-line exclusion), which is acceptable. The title is long at 103 characters, but it remains a single clear sentence.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
contractPath hook (identity by default); the SLM override strips ^/api(?=/) once; getContract is a thin view over call. Final-URL tests exist for both bases (ApiClientBase.test.ts, ApiClient.test.ts, ApiClient.transport.spec.ts). The /api/api case is closed.
none
Verified
ApiClientBase.ts:117-140,177-182
JsonMethodsOf restricts call to JSON 200/201 or 204; 204 returns undefined (void); a non-JSON content type or none throws and points at callRaw.
none
Verified
ApiClientBase.ts:164-175
fillPathParams throws on a missing value and on unused keys.
Only verify-types-run changed in the fixture. changes_job_equivalence_15360_test recomputes digests from the workflow and passes, so it is the computed value, not hand-edited. AppConfig.js is back at 612 lines (one comment line removed); frontend_file_size_ratchet_test passes.
The SLM job still dumps raw and strips x-websocket-paths in an inline Python snippet, while the main job and gen:types:openapi use --no-websocket-paths. Output is the same, but the strip now exists in two places for SLM.
Switch the SLM step to --dump-slm-openapi ... --no-websocket-paths and drop the snippet's pop (optional, can follow in a later slice).
Not checked: Ran repo_tests/*12363*_test.py, changes_job_equivalence_15360_test, frontend_file_size_ratchet_test, frontend_api_contract_ratchet_test and scripts/audit_api_wiring_test.py (445 passed). I ran no vitest, vue-tsc or eslint, so the TS tests were read, not executed. I did not check generated api.ts/openapi.json freshness, and CI status was not assessed.
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
Verdict: CHANGES. 31 files, 47 behind main, merge state DIRTY (the no-merge-conflicts check fails; the conflict is in scripts/python_file_size_known_large.py), 11 unresolved threads, none answered in the thread or in code. The head is the last review's head plus an auto-sync merge, so the earlier pass never covered these threads. Refs #12363 is correct.
An array query value from the contract (for example tags) is sent as String(value), i.e. red,blue, one filter instead of two. call types the query from the contract, so the array is accepted and silently mangled (thread 4502577527; confirmed at this head).
Serialise arrays as repeated keys, with a test.
MEDIUM
ApiClientBase.tsQueryPart
query is always optional, so a required query parameter can be omitted and fail only at the backend (thread 4502577512; confirmed).
Make query required when any contract query field is required.
MEDIUM
.github/workflows/verify-generated-types.yml
The path filters list scripts/audit_api_wiring.py but not the new scripts/audit_api_wiring_args.py; a PR touching only that helper skips both regeneration jobs and the verdict still passes (thread 4502577472; confirmed by grep).
Add the helper to both job filters and the push filter.
LOW
ApiClientBase.tsbuildInit
A Blob body is sent raw while Content-Type stays the JSON default, so an upload reaches the backend labelled JSON (thread 4502577504; confirmed).
Use blob.type when the caller supplies no content type.
LOW
ApiClientBase.tsCallResponse
An operation that documents both a JSON 200 and a 204 is typed as the JSON body only, while a 204 resolves to undefined (thread 4502577496).
Union with void.
LOW
docs/developer/FRONTEND_API_CLIENTS.md
The Roles table still says to add domain endpoints to the domain clients, contradicting "do not add endpoints to them" two lines above (thread 4502577490; confirmed).
Direct new endpoints to apiClient.call and call the domain clients legacy.
LOW
autobot-frontend/src/utils/ApiClient.ts
Typed calls use contract keys that start with /api; with a non-default VITE_API_BASE_PATH the typed path does not follow the configured base (thread 4502577482). Not reproduced, so the verdict is "not answered", not "confirmed".
Add contractPath here as the SLM client has, or state why the base is always /api.
LOW
repo_tests/frontend_api_contract_ratchet_test.py
require('./fetchWithAuth') is not counted by the census (thread 4502577532; no require( handling found).
Count it and add a fixture.
LOW
package.jsongen:types; kit test type-check; SLM / and SCIM paths
Threads 4502577477, 4502577492, 4502577486: pre-existing script design or tooling suggestions, not answered.
Answer each in-thread (accept, or a reason).
LOW
verify-generated-types.yml SLM step
The SLM job still strips x-websocket-paths in an inline snippet while the main job uses --no-websocket-paths: two copies of one strip.
Use the flag for SLM too.
Verified
fillPathParams, readCallBody, contractPath
Missing and unused path params throw; non-JSON replies point to callRaw; the SLM prefix strip exists once with final-URL tests.
none
Threads: 0 resolved by me; no head code answers any of the 11. The required fixes are the merge from main plus the three MEDIUM items and an in-thread answer for each of the rest. Changed-file ceilings: ApiClientBase.ts is 436 lines (was 308), under 600. Not run: vitest, vue-tsc.
merged origin/main; scripts/python_file_size_known_large.py: main's 1145 for repo_tests/sys_modules_leak_guard.py, branch's 855 for scripts/audit_api_wiring.py (both equal the files' line counts)
python file-size ratchet
MEDIUM array query as red,blue
libs/autobot-ui/src/utils/ApiClientBase.tswithQuery repeats the key; QueryValue type
ApiClientBase.test.ts: @ts-expect-error on /api/search (no query; query without tags)
MEDIUM filters miss audit_api_wiring_args.py
added in api-wiring.yml, company-os-contract.yml, verify-generated-types.yml (push + both job filters) and the shared .github/filters/backend-python-paths.yml; equivalence fixture re-frozen
changes_job_equivalence_15360_test.py 374 passed
LOW Blob JSON Content-Type
ApiClientBase.tsbuildInit
ApiClientBase.test.ts: Blob media type
LOW 204 beside 200
ApiClientBase.tsCallResponse / ReturnsJson union
ApiClientBase.test.ts: Item | void
LOW Roles table contradiction
docs/developer/FRONTEND_API_CLIENTS.md
n/a
LOW ratchet misses require(
repo_tests/frontend_api_contract_ratchet_test.py regex + planted control
same file, ..._static_dynamic_and_require_imports_only
CR gen:types fresh schema
both package.jsongen:types chain gen:types:openapi; docs
Local results: pytest batch 569 passed; kit tests 70 passed; both app specs pass with a temporary reka-ui stub (it is not installed here); npm run type-check in both apps shows only the 5 reka-ui TS2307 errors each.
Verdict: APPROVE. Delta reviewed from 07847eb; every prior finding is fixed in code with a test, and nothing new blocks.
Prior finding
Result
Evidence
MED array query as repeated keys
Fixed
withQuery appends each item (QueryValue allows arrays); tests assert ?a=red&a=blue&n=1 and ?tags=red&tags=blue through call
MED QueryPart keeps required query required
Fixed
{} extends ParamsOf<Op,'query'> branch; @ts-expect-error on no query and on {limit:1} missing tags; all-optional stays optional
MED args helper in filters, fixture re-frozen
Fixed
audit_api_wiring_args.py is in api-wiring, company-os-contract, verify-generated-types (push and both job filters) and the shared wiring filter; pre_15360_changes_jobs.json hashes updated
LOW Blob media type
Fixed
Blob's own type, none when empty, caller header wins; test covers all four cases
LOW 204/200 unions
Fixed
CallResponse and ReturnsJson union 200, 201 and void for 204; expectTypeOf test `Item
LOW Roles table
Fixed
domain-client row now says new endpoints use apiClient.call
LOW ratchet misses require(
Fixed
regex covers require(; positive control cjs.js counted, cjsother.js (look-alike module) not
NEW (non-blocking) type assertions not enforced in CI
Open, tracked
the kit has no type-check over __tests__, so the @ts-expect-error and expectTypeOf checks run only by hand; tracked in #21091
Hygiene: 0 behind main, mergeable is MERGEABLE (state BLOCKED on checks/approval only); no failing checks at review time; no fixed sleeps or line-number comments in the author's commits; ApiClient.ts 560 and ApiClientBase.ts 450 lines (<=600); audit_api_wiring.py 855 is at its ceiling; new functions are short. Also checked 6cb4955: contractPath honours the configured API base and the SLM client refuses keys outside /api, both tested.
Threads: 2 of 4 open threads resolved on code evidence (configured base, SLM key refusal); the QueryPart thread also resolved. The kit type-check thread stays open until #21091 lands.
Scope at this head: the typed call/callRaw layer, the SLM contractPath hook, the ESLint raw-fetch ban and the call-site exemptions are already on main (slices 1 to 4 landed via earlier trains). This PR now adds only the ratchet dimensions in repo_tests/frontend_api_contract_ratchet_test.py (+118/-5). The 24 non-merge commits ahead of main are the older slice branch history (type regeneration and auto-sync merges), not part of the net diff. The title and body still describe the whole slice 0 and need rewriting.
Still valid. The header capture [^{;]* includes type parameters, so class FreshApiClient<T extends ApiClientBase> {} matches extends ApiClientBase and escapes the client count.
Match extends only after the type-parameter list (strip a leading <...> from the header, or anchor on \)?\s*extends), and add that declaration as a positive fixture in test_a_class_extending_the_kit_base_is_not_counted_but_a_bare_service_is.
Still valid. fetch_with_auth_importers and hand_built_urls are compared as counts. Removing one bridge importer or hand-built URL and adding another leaves the count equal, so a new finding passes.
Compare identities against the base (importer paths; path:line-text sites for URLs), keep counts for reporting, and add an equal-count replacement fixture per dimension.
Low
PR title/body
Title and body claim the typed layer, offline generation, ESLint ban and "Kit tests: 67 passed" for work that is not in this diff. Unverifiable evidence.
Retitle to the ratchet dimensions; rewrite What Changed and Verification to match the 1-file diff.
Low
Test coverage
The detectors have control fixtures, but no test covers the layer here (it is covered on main in ApiClient.transport.spec.ts and ApiClientBase.test.ts). Fine for this diff.
None.
Checked, no finding: no console.*, hardcoded URLs or UI strings in the diff; the layer is wired on main (12 files call .call('<verb>', 92 files still reference fetchWithAuth, which is the debt the new dimension pins); mergeable against main 6199adc (mergeStateStatus BLOCKED by the paused CI and unresolved threads, no conflict); milestone M4 and label phase:M4.9 present; body headings present.
AC coverage of #12363 (Refs, not Closes): the typed layer, offline generation and ESLint ban are met by main, not by this diff; this diff delivers only the guard dimensions for slices 3 and 5. The migration ACs (remaining raw fetch sites, hand-typed responses) are not met.
Not verified: no test or type-check was run (read-only review); the exact pin values (fetch_with_auth_importers 37, hand_built_urls 644) were not recounted.
mrveiss
changed the title
feat(frontend): typed call/callRaw over the one kit client, offline type generation, raw-fetch ban (#12363)
test(ci): ratchet remaining fetchWithAuth bridge importers and hand-built API URLs by identity (#12363)
Nov 12, 2026
Round fix for Verdict: CHANGES @ b47350aa57, pushed as a40db9b (one fix commit plus a merge of the branch's own auto-sync head).
Finding
Fix
Medium: generic constraint escaped the client count
The class regex now captures only the name. _type_params_end does a bracket-depth scan over a possibly nested <...> list (an => is not a closer) and _class_heritage reads the clause after it; extends ApiClientBase must start that clause. Fixtures: class FreshApiClient<T extends ApiClientBase> {} is counted; nested <T extends Foo<Bar>, U = Baz> extends ApiClientBase<T, U> is excluded; implements-only is counted; multi-line headers are covered for both an implements and an extends class.
Medium: count-only comparison
_identities / _new_members compare the measured members against the exported merge-base tree: importers by file path, hand-built URLs by (file path, stripped line text) with multiplicity, no line number. New test test_no_new_bridge_importer_or_hand_built_url_even_at_equal_count runs per app and dimension. Fixtures: an equal-count swap in each dimension fails (while the count-only _regressions stays blind to it), a line shift is not a new member, a duplicated identical line is. No baseline file was added, so the python filter is untouched.
Low: title and body
Retitled and rewritten to the one-file change.
Counts derived statically with git grep on this tree: 37 importers of the bridge (matches). The hand-built URL count is 571 under the detector's exclusions (582 raw hits), not the 644 the old body claimed; the claim is dropped. The ratchet compares against the base tree, so no pinned number is needed.
Not verified: no tests, type-check or CI were run locally; the detector was not executed.
Both earlier findings are fixed in code. The only non-merge commit ahead of main is d47b93b (plus the already-reviewed 633b8be); the net diff is still the one test file, 557 lines (under the 600 ceiling). Nothing was executed; the traces below are by reading.
Fixture trace: FreshApiClient<T extends ApiClientBase> gives an empty heritage and is counted. The nested <T extends Foo<Bar>, U = Baz> extends ApiClientBase<T, U> and the multi-line extends class are excluded. implements-only and the { a: 1 } / () => void multi-line generic are counted. That matches the asserted set.
A moved or renamed file, or any edit of a hand-built URL line's interior text (reformatting, variable rename), reads as a new member; the failure message lists members but does not say what to do.
Add one sentence to the two _DIMENSION_ADVICE entries saying that a move or reformat of an existing site must be done in the migration PR that removes it.
Break attempts on the class detector (false exclusion = escape; false count = noise):
Case
Result
Matters?
<T extends Array<() => void>>
Depth scan correct (=> skipped)
No
> in a string or comparison in a default type
Premature close, heritage starts mid-list, so the class is counted
Noise only
class X<T> // comment {
Comment sits in the heritage text; not an extends start, so counted
Noise only
/* c */ extends ApiClientBase
Heritage starts with the comment, so counted
Noise only
export default class, abstract class, const X = class FooClient {
Name found, handled
No
const FooClient = class { or an anonymous class
Not matched
Escape, but a pre-existing blind spot of a name-based detector
extends mixin(ApiClientBase)
Counted
Conservative, noise only
extends ApiClientBaseExtra
Counted (word boundary holds)
No
Class name inside a comment or string
Counted if a { follows before a ;
Noise only
No case produces a false exclusion from a real independent client.
Identity comparison: _new_members is a Counter difference (now - then), so duplicates and swaps register and line shifts do not. The base is _ratchet_base.base_commit: in CI it is the merge-group base_sha, before on a main push, or HEAD^1 for a PR; locally it is the merge-base with origin/main. On main's own push run the base is the previous main tip, so a landed commit that already passed is not re-judged. The two fixture tests do what they claim, including the count-only _regressions staying blind to a swap.
No numeric pin exists for these dimensions (no 644 or 37 in the file or the repo tests; the only 644 hit is an unrelated file-mode test). The body states 37 and 571 as static counts and says the 644 claim is dropped. The new helpers are all underscore-prefixed, the file adds no ast use, no new file is added so the python filter pin is untouched, and the title and body describe the one-file change.
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
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.
Thinking Path
The typed client layer, the SLM contract hook and the raw-fetch lint ban of #12363 already landed on main through earlier slices. What was left unpinned is the remaining debt: files still importing the
fetchWithAuthbridge and code lines still assembling${getApiBase()}/...URLs by hand. This PR makes that debt shrink-only so the migration (follow-up #21050) is finite.What Changed
One file,
repo_tests/frontend_api_contract_ratchet_test.py:fetch_with_auth_importersandhand_built_urls, gated against the merge base like the existing dimensions.class X<T extends ApiClientBase> {}is counted as a client while a class that really extendsApiClientBaseis not.implements-only, multi-line headers, equal-count swap per dimension, line-shift and duplicate-line contrast.No baseline file: base identities are measured from the exported merge-base tree, so no new file read is added to the python filter.
Verification
git grep(main frontend, SLM frontend is 0 in both): 37 files import thefetchWithAuthbridge; 571 non-comment, non-WebSocket lines contain${getApiBase()}/after excluding test files, generated and node_modules paths. The earlier claim of 644 for the URL dimension did not reproduce at this head and is dropped; the ratchet compares against the base tree, so it needs no pinned number.Risks
Test-only change. Rollback: revert the PR.
Model Used
Claude Sonnet 5.5 (claude-sonnet-5-5)
Issue Link
Refs #12363
Changelog fragment
Checklist
CLAUDE.mdmain(notrelease)