Repository navigation
test(app-shell): skip fetch-free files before parsing in the bearer ratchet scan - #38148
Merged
objectstack-fleet[bot] merged 2 commits intoNov 28, 2026
Merged
Conversation
… bearer ratchet scan Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cxRDKprCtjpEdtiPFW
…t links Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cxRDKprCtjpEdtiPFW
Contributor
Author
|
repo:objectstack#1 · os-elon-musk · session_016WV4cxRDKprCtjpEdtiPFW L1 verdict: ACCEPT (in-area self-review,
|
objectstack-fleet
Bot
deleted the
claude/issue-38101-bearer-ratchet-scan-speed
branch
November 28, 2026 05:31
This was referenced Nov 28, 2026
Nenzyz
pushed a commit
to Nenzyz/objectstack
that referenced
this pull request
Dec 1, 2026
…he bearer ratchet reads four more spellings (objectstack-ai#38173) <!-- claude-projects-attribution: {"github_login":"os-tesla"} --> _Requested by **Tesla** · [project thread](https://claude.ai/code/project/chan_01AXsQkLFKRdQCqQ3RTr6Jao?thread=cmsg_01AXsQkLFKRdQCqQ3RTr6JaoDanEGNW6fHMedo6Br7tobU)_ Fixes objectstack-ai#37505 Fixes objectstack-ai#37506 Fixes objectstack-ai#37507 repo:objectstack#3 · os-tesla · session_01L9qic11DcdSCqDBNNUAXcb Clause-②: no Metadata-protocol: none ## 维护者速读 - 嵌入或云租户里只靠令牌登录的用户:数据适配器的两个上传方法以前只带 cookie,现在和其他请求一样带上令牌;控制台界面没有变化。 - 属于「纯令牌登录和分源部署下请求都带上身份」专题:补全检查「同服务器请求必须带令牌」的那条测试,它以前漏数四种写法。 - 只换了上传用哪个请求通道,地址、内容和连接状态都不变;有问题可以直接撤回。顺带发现标准服务端上这两个上传地址本身不存在,已另立卡,本次没有修。 - 无 ## What changes - `@object-ui/data-objectstack` (objectstack-ai#37506): `uploadFile` and `uploadFiles` call the host's injected `fetch` as given (`uploadTransport`, kept aside in the constructor), not the global `fetch`. The console hands `createAuthenticatedFetch()`, so an upload under a bearer-only session now carries the stored bearer like every other request of the adapter. Both stay outside the connection-state observer (`observeServerAnswer`), so an upload's outcome still does not move the connection state, as the README says; only the README's "call the global `fetch`" wording changes. URL, body and headers are unchanged. `metadata-client` has no bare call left on main, so nothing changes there. - The same-server bearer ratchet (`sameServerFetch.bearer.ratchet.test.ts`, objectstack-ai#37505) now reads four spellings that used to pass uncounted: - a URL held in a `const` of the file (`const url = ` + template naming `/api/`), and a `+` concatenation with an `/api/` part; - `credentials: 'same-origin'` spelled out (the default: the cookie alone); - an init that spreads a `const` of the file (`{ ...COOKIE_INIT, method: 'POST' }`), with later keys overriding, as at run time. A spread of anything else (`{ ...init }`) stays unknown and uncounted; a credentials value written before such a spread is kept. - Each spelling has pins in the detector case table (counted and not-counted). The `ALLOWED` list is unchanged: on the widened detector the whole tree matches it row for row. - The ratchet gains `REGISTERED_CHANNELS` (objectstack-ai#37505, objectstack-ai#37507): three calls that read like a bare fetch and are not one, each with its reason, and a case that fails once a file no longer holds the registered spelling or the scan starts counting a call in it: - `react` `useDatasetDimensionLabels` and `useElementApiDataSource`: `apiFetch ?? fetch`, the host's channel off `SchemaRendererContext`. - `auth` `createAuthClient`: the stale-bearer self-heal retry of `get-session`, token-less on purpose. Every other request of that client already goes through `bearerFetch`, so objectstack-ai#37507 needs no production change. - `patch` changeset for `@object-ui/data-objectstack`. Not here: objectstack-ai#38101 (the same test file's scan time) is claimed by another seat; whichever lands second merges main. ## Tests - New `uploadTransport-37506.test.ts`: the injected fetch adds a bearer and records what reached the network; the global `fetch` is stubbed to record and refuse (the control, the pre-fix transport). `uploadFile` and `uploadFiles` each send exactly one `POST` to the upload URL carrying the bearer, and never touch the global fetch; a refused upload leaves the connection state at `connected` with no event. - The ratchet: the detector case table gains 15 rows for the four spellings and one row flips from 0 to 1 (`credentials: 'same-origin'` on an `/api/` path); one new case for `REGISTERED_CHANNELS`. <details><summary>Readings (base origin/main 581ae76)</summary> - Premise, before any change: a port of the detector run over the whole `ui` tree (2466 files) matched `ALLOWED` exactly (15 rows, 21 calls); with the four spellings on, the only new hits were the two uploads in `data-objectstack` (`uploadFile` and `uploadFiles`, `fetch(url, …)`). - `uploadTransport-37506.test.ts`: `Tests 3 passed (3)`. Ablation (both uploads put back to the global `fetch`, fix committed first, restored with `git checkout HEAD`): `Tests 3 failed (3)`. - `sameServerFetch.bearer.ratchet.test.ts`: `Tests 5 passed (5)`. Ablations, one at a time against the committed file: uploads back to the global `fetch` reds "every bare cookie-only call is a counted row" with exactly the two upload lines; dropping the `+` branch, the URL-const lookup, the `same-origin` reading or the spread reading each reds the detector case for that spelling. - `eslint` on the three changed `.ts` files: 0 errors; the warnings are the existing `no-explicit-any` ones in `index.ts`, none on a changed line. - `@object-ui/data-objectstack` `type-check` (`tsc --noEmit`) exit 0, after a build of its dependency closure. - `dispatch-gates --commands` at 96332e4: 40 families derived, 40 run, every one exit 0 (`--ran`: 0 NOT-MEASURED, a derived zero), `pnpm --dir ui exec vitest run scripts/` included (`Tests 5144 passed | 2 skipped`). - `overlap-check`: clean against origin/main 33a0d4f and against objectstack-ai#38148 (the scan-time change in the same test file). The ratchet with both changes merged (`git merge-file`, not committed here): `Tests 5 passed (5)`. </details> ## Acceptance notes - Out of scope: the upload route itself, see objectstack-ai#38163. On a stock stack both upload methods' path answers 404 whatever the credentials; this PR changes only which fetch carries them. - No boot reading of an upload through the console; the pins drive the adapter through an injected fetch double. ## Verification Read first (by risk): 1. `data-objectstack/src/index.ts`: the `uploadTransport` field, its assignment in the constructor, and the two `this.uploadTransport(url, …)` calls. 2. The ratchet's `credentialsOf` and `namesApiPath`, and the new rows of the detector case table. Two-minute check: `pnpm --dir ui exec vitest run packages/data-objectstack/src/uploadTransport-37506.test.ts packages/app-shell/src/sameServerFetch.bearer.ratchet.test.ts` passes; put either upload call back to `fetch(url, {` and both files red. --- _Generated by [Claude Code](https://claude.ai/code/session_01L9qic11DcdSCqDBNNUAXcb)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
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.
Requested by Elon · project thread
Fixes #38101
Clause-②: no
Metadata-protocol: none
维护者速读
What changes
ui/packages/app-shell/src/sameServerFetch.bearer.ratchet.test.tsonly. The scan was already computed once per run and shared by the two cases that read it; the time went to the TypeScript parse of every scanned file.Measured on this container (2464 scanned files, about 41 MB of source): walk 22 ms, read 146 ms, parse of every file about 3.5 s, AST visits about 0.2 s. So the parse is the cost, and two changes cut it:
fetchas a whole word norsharedGetJson(MAY_HOLD_A_COUNTED_CALL). Every transport the detector counts is matched on its written text (fetch,window.fetch,globalThis.fetch,self.fetch, an alias whose initializer is one of those, orsharedGetJson), so a file without either token cannot produce a row. 397 of 2464 files are kept.jsDocParsingMode: ParseNone,setParentNodes: false). The detector reads neither; everygetText/getStartcall is handed the source file.The scanned set is unchanged, and so are the counted rows (proof below). A new assertion in the detector case pins the pre-filter: every positive detector spelling must pass
MAY_HOLD_A_COUNTED_CALL, so narrowing the filter reds the file.Tests
Timings are from a shared 4-core box under
os-verify-lock(load average about 4), so ratios are the reading to trust. The base file (a copy oforigin/main's test) and the new file ran in the same process, one after the other, twice (--maxWorkers=1 --no-file-parallelism):every bare cookie-only call…That is 0.26 to 0.38 of the base time. Applied to the 15202 ms CI reading on job 140828751977, that is about 4 to 5.8 s on a CI shard, well under the 15 s timeout. The CI figure on this PR's own
Test UIshard is NOT MEASURED here: read it off the check-run.Same counted rows before and after
A temporary case (not committed) ran the full unfiltered scan next to the filtered
scan()and compared the two maps:FILES 2464 ROWFILES 15 CALLS 21 EQUAL true. It ran once against each commit's parse options. Both before and after, the allow-list caseevery allow-list row is still exactis green: all 15 rows (21 calls) match exactly.Ablations (on disk, restored, tree clean afterwards)
fetchtoken before the edit (ui/packages/fields/src/FieldEditWidget.tsx:await fetch('/api/v1/x', { credentials: 'include' })). The caseevery bare cookie-only call is a counted row…goes red withpackages/fields/src/FieldEditWidget.tsx:495 :: fetch('/api/v1/x', …). The ratchet keeps its teeth.MAY_HOLD_A_COUNTED_CALLnarrowed to/sharedGetJson/. The detector case goes red ("kept": false), and so doesevery allow-list row is still exact.Acceptance notes
skip-changeset:@object-ui/app-shellisprivate: true, and itsfiles[](dist,src/styles.css, …) does not ship this test file.Verification
Files to read first:
MAY_HOLD_A_COUNTED_CALLand its use inscan(). This is the risk hunk: a filter that is too narrow drops files without saying so. Check the claim that every counted transport is matched on written text containingfetchorsharedGetJson.createSourceFileoptions inbareCookieOnlyCalls.Two-minute check:
pnpm --filter @object-ui/app-shell exec vitest run --root ../.. packages/app-shell/src/sameServerFetch.bearer.ratchet.test.ts. Expect 4 passed, with the counted-row case at about a third of its time onmain.🤖 Generated with Claude Code
https://claude.ai/code/session_016WV4cxRDKprCtjpEdtiPFW