Skip to content

perf(app-shell): a cold Console load asks the app bundle the moment the app list answers - #38252

Merged
objectstack-fleet[bot] merged 6 commits into
mainfrom
claude/issue-38170-console-cold-boot-parallel
Nov 28, 2026
Merged

objectstack-fleet[bot] merged 6 commits into
mainfrom
claude/issue-38170-console-cold-boot-parallel

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Fixes #38170

Clause-②: no
Metadata-protocol: none

维护者速读

  • 用户能看到什么变化:在应用页面冷启动时,控制台拿到应用列表的同一刻就去请求应用包,不再等界面重绘一轮;机器忙时页面标题出现的中位时间从约 2.3 秒降到约 2.0 秒,空闲机器上没有可测的变化。
  • 为什么做:属于「控制台首屏 2.5 秒内打开」专题,也是端到端测试在忙碌机器上等标题偶发超时的成因之一。
  • 出错会怎样:最坏是应用包被多请求一次或晚一点请求,页面仍按原路读取并正常显示;可直接撤回本改动。
  • 要你做什么:无。

What changes

On an app route the console root (useAppObjectScopePrefetch) entered the app's metadata bundle from an effect of the render that names the app. On a cold load the app list is still on the wire when that hook mounts, so a full tree re-render (and the effects after it) sat between the GET /api/v1/meta/app answer and GET /api/v1/meta/app/NAME/bundle. The hook now also asks for the bundle in the app list's own answer: it joins the provider's eager app-list read (ensureType('app') never asks again), resolves the route segment against that list exactly as the render does (matchAppBySegment: package id first, then name), and enters that app through the same adapter. The render-time effect sees that this visit already entered the app and does not ask again; any other visit (another app, a return after leaving, an app list already in hand) enters as before.

Only WHEN changes. The request, its adapter and session, the app it names and the number of requests are the same:

  • Same auth/session: the bundle is still asked through the adapter's own loadAppBundle (pinned: this is the adapter).
  • An app the user cannot see: the app list is still what names the app. A route naming an app the list does not hold asks no bundle, before or after the list lands (pinned). AppContent, which draws the refusal, is untouched.
  • Nothing moved ahead of the permission read: the root's bundle entry never waited on /auth/me/permissions (the hook sits above the permission scope by design), and the bundle answer is filtered by the server's own checks. AppContent's entry, below the permission read, is unchanged.
  • Same number of requests or fewer: one bundle request and one app-list read per cold load (pinned); measured API request counts are unchanged (below).

Why

The card's suggested direction was to start the bundle "as soon as the route names the app". On current main the route cannot name the bundle on its own: the /apps/SEGMENT segment is the package id (ADR-0048) or the app name, the bundle route is keyed by the app name, a package may ship several apps, and only the app list says whether this user may see the app. Asking by segment would fetch a wrong or refused bundle on most canonical URLs and add a request for apps the user cannot see, so the earliest point that keeps the invariants is the app list's answer. That is what this change does.

Tests

  • New top-level describe in the shared harness appObjectScope-12811.test.tsx (5 tests): the ordering pin (the bundle request lands after the app list answers and before the render that names the app), bundle named by app not by segment through the same adapter, the hidden-app control, the leave-before-answer control, and the list-in-hand control (entered once, from the render).
  • Ablation, one mutation at a time on the committed fix, restored to the HEAD blob each time (scripts/ablation-replace.mjs, git diff HEAD empty after restore):
    • list-answer entry disabled: the ordering pin goes red (expected 4 to be less than 3: the bundle comes after render:named), the four controls stay green.
    • render-time de-duplication removed: two tests red (expected [ 'bundle:crm', 'bundle:crm' ] to deeply equal [ 'bundle:crm' ]).
  • The 42 test files that reach the changed hook (useAppObjectScopePrefetch, enterAppBundle, loadAppBundle, ConsoleShell, ConnectedShell, including the App-level boot-wave and boot-reads-once pins): 42 files, 334 tests passed. The full app-shell package (2445 test files) was not run locally; CI's Test UI runs it.

Acceptance notes

  • Measured on e3bdc748 (before) and this branch (after), the card's lane rebuilt locally: backend objectstack dev --seed-admin --fresh on examples/app-showcase, Console vite build with VITE_BASE_PATH=/, vite preview proxying to it, Playwright Chromium, a fresh context per load, route /apps/showcase_app/page/showcase_project_workspace, heading New Project + Tasks. Before and after were served side by side from two vite previews and alternated in blocks, 27 cold loads each, idle and with four CPU-bound processes on a 4-core box. Absolute times are readings on a shared box.

  • Hop order (same in both builds): runtime/config + get-session + discovery, then me/localization, then me/permissions + organization reads + i18n + meta/app + preferences, then the bundle. Three serial API hops before the bundle request, before and after. The card's five-hop chain did not reproduce on e3bdc748: me/apps and meta/object?package leave in the same wave as the bundle, not before it.

  • What moved is the render gap inside that last hop:

    median over 27 cold loads idle before idle after busy before busy after
    bundle request leaves (ms after goto) 946 764 1343 974
    bundle request leaves after meta/app lands (ms) 226 19 378 17
    later of bundle and package list answered (ms, n=12) 1087 1046 1557 1421
    heading visible (ms) 1668 1690 2300 2035
    heading visible, p90 / max (ms) 1803 / 2295 1892 / 2256 2700 / 2745 2560 / 2687
    API requests before the heading 33 33 34 33
  • Heading-ready on an idle box did not move outside noise. A delay probe (1.5 s held on one request family, 3 loads each) puts the heading behind both the bundle and meta/object?package (+1.0 to +1.5 s each), and not behind me/apps, meta/view, the approvals read, settings, agents or the inbox reads. The two critical reads leave within ~60 ms of each other and are answered by the server together, so on an idle box the bundle's earlier start buys about 40 ms of "both in hand". On the busy box the gain is larger because the render gap was larger.

  • Not reproduced red: the 5 s heading budget held in every load measured here, before and after (worst 2745 ms before, 2687 ms after), so the card's second acceptance line (the busy-runner beforeEach wait) is not shown red-to-green locally; it is the Live E2E UI lane's to confirm.

  • What remains on the cold path is outside this card's surface: the gate between the session answer and the meta/app request (sign-in locale, adapter connect and the route guards in the Console app), the server's time to answer the bundle and the package object list together, and the client render after both land (300 to 1000 ms on the busy box).

Verification

Read first, by risk:

  1. ui/packages/app-shell/src/console/appObjectScope.ts, the two effects added before the render-time bundle effect, and the enteredByList check in it: the de-duplication between the two entry points is the only place a second bundle request could come from.
  2. ui/packages/app-shell/src/console/__tests__/appObjectScope-12811.test.tsx, the objectstack#38170 describe at the end.
  3. .changeset/38170-bundle-on-app-list.md.

Two-minute check: pnpm --dir ui exec vitest run packages/app-shell/src/console/__tests__/appObjectScope-12811.test.tsx from the repository root prints Tests 28 passed (28).

Local gates at 4f299c6: the derived set (38 of 38 run, exit codes captured before any pipe) plus the app-shell type-check and the narrowed suite
  • exit 0 · pnpm --filter @object-ui/app-shell type-check

  • exit 0 · pnpm exec vitest run (the 42 files that reach the changed hook)

  • exit 0 · node scripts/check-adr-0087-registration.mjs --base origin/main

  • exit 0 · node scripts/check-adr-0087-registration.mjs --self-test

  • exit 0 · node scripts/check-changeset-no-major.mjs --base origin/main

  • exit 0 · node scripts/check-closing-keyword-parity.mjs

  • exit 0 · node scripts/check-closing-keyword-parity.mjs --self-test

  • exit 0 · node scripts/check-comment-mask-corpus.mjs

  • exit 0 · node scripts/check-empty-changeset.mjs --base origin/main

  • exit 0 · node scripts/check-empty-changeset.mjs --self-test

  • exit 0 · node scripts/check-sdui-manifest.mjs

  • exit 0 · node scripts/check-sdui-manifest.mjs --self-test

  • exit 0 · node scripts/ci/snapshot-next.mjs --self-test

  • exit 0 · node scripts/pm/check-governed-queue-guard.mjs --self-test

  • exit 0 · node scripts/pm/release-rehearsal-clone.mjs --self-test

  • exit 0 · node scripts/release-pending-publish.mjs --self-test

  • exit 0 · pnpm --dir ui exec vitest run scripts/

  • exit 0 · pnpm --filter @objectstack/spec run check:duration-unit-keys

  • exit 0 · pnpm check:adr-anchors

  • exit 0 · pnpm check:changeset-gate-self-tests

  • exit 0 · pnpm check:closed-ceremony-text

  • exit 0 · pnpm check:cross-package-test-inputs

  • exit 0 · pnpm check:dispatcher-error-vocabulary

  • exit 0 · pnpm check:driver-memory-census

  • exit 0 · pnpm check:engine-double-contract

  • exit 0 · pnpm check:gitlink-declared

  • exit 0 · pnpm check:nul-bytes

  • exit 0 · pnpm check:published-files

  • exit 0 · pnpm check:query-options-erasure

  • exit 0 · pnpm check:refd-timer-probe

  • exit 0 · pnpm check:registry-log-declared

  • exit 0 · pnpm check:rest-log-spy-declared

  • exit 0 · pnpm check:skill-identifier-liveness

  • exit 0 · pnpm check:test-source-alias

  • exit 0 · pnpm check:tier-file-adoption

  • exit 0 · pnpm check:type-check-coverage

  • exit 0 · pnpm check:type-check-debt

  • exit 0 · pnpm check:undeclared-dep-imports

  • exit 0 · pnpm check:watch-hint-literal

  • exit 0 · pnpm check:where-matcher

  • node scripts/pm/dispatch-gates.mjs --ran: 38 derived families accounted for, 38 run, 0 NOT-MEASURED, 0 UNRUN.

  • The app-shell type-check ran after building its dependency closure (turbo run build --filter='@object-ui/app-shell^...', exit 0); both tsc programs exit 0.

  • pnpm exec eslint on the two changed sources: 0 errors; 3 more no-explicit-any warnings than base, from the test's as any casts on the adapter double, the shape the harness already uses.

  • CI owns the rest: Test UI (the full app-shell package), Lint UI, Type Check UI, Build & E2E UI, Live E2E UI.

Human Minimum

  • 1. Schemas start as Zod; packages/spec holds no runtime logic.
  • 2. Every name I added uses the casing for its kind.
  • 3. No formatter ran; pnpm lint is CI's (Lint UI); eslint on the changed files reports 0 errors.
  • 4. One issue, one branch off an up-to-date main, one pull request.
  • 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset.
  • 6. packages/spec touched: its generated artifacts are regenerated and committed. (Not touched.)
  • 7. No hand edits to content/docs/references/, packages/*/CHANGELOG.md or content/docs/releases/.
  • 8. Title, body and comments are in English.
  • The Before Submitting list in CONTRIBUTING.md is done.

🤖 Generated with Claude Code

https://claude.ai/code/session_017xRBcWDb7S8Z7oRDGzvfT2


Generated by Claude Code

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#8 · sunhaolin · session_017xRBcSAaBEfQpU2yJexSJ8

L1: ACCEPT · head c26f3e243f · 2026-11-28T11:23Z · card #38170

Seat checks

  1. Shape: draft on main, mergeable_state clean, first line Fixes #38170 only, Clause-②: no · Metadata-protocol: none. The PR author is objectstack-fleet[bot]: the seat opened it through the relay from the dev's payload (ruling Q1 = A, recorded in comment 7237736376 on perf(app-shell): a cold Console load waits on five serial request hops before the app bundle is even requested, so a page heading lands up to ~3.6 s after goto on a busy runner #38170 with the dev's report). The relay pr_create was refused by the dev session's permission classifier, and the dev did not reroute it.
  2. Fixes is right.
    • Acceptance line 1 ("the critical path to the bundle request is shorter, with a before/after reading on the same lane") is delivered and measured. The bundle leaves 17–19 ms after meta/app lands, against 226 ms idle and 378 ms busy before (medians of 27 cold loads each).
    • Acceptance line 2 (flake: Live E2E master-detail.spec.ts「Create with a task line」在 beforeEach 等页面标题超时,把 #38090 踢出合并队列 #38138's heading wait under 5 s on a busy runner) is Live E2E UI's to confirm. No local load breached 5 s before or after (worst 2745 ms → 2687 ms). Ruling Q2 = C: no new cards until that flake shows again after this lands.
    • The card's "five serial hops" premise did not reproduce (three hops). That is recorded in the Acceptance notes.
  3. Read by the seat, appObjectScope.ts (+50/−2):
    • The list-answer effect resolves the route segment with the same matchAppBySegment the render uses, through the same adapter (load.call(dataSource, name)). An app the list does not hold asks no bundle.
    • listEnteredRef hands the visit to the render-time effect, which then does not ask again. It is cleared on a route-segment or adapter change and when the render-time effect reads it.
    • rootEnteredApps blocks a re-entry by the root.
    • Same input, same match, so no visit can issue two bundle requests. The de-dup ablation pin proves the single request.
    • Only WHEN changes: the auth/session, the app named and the request count are unchanged.
  4. Pins: 5 new tests (ordering, named by app not segment, hidden-app CONTROL, leave-before-answer CONTROL, list-in-hand CONTROL). Two ablations, each red, then restored. The changeset was read sentence by sentence and every figure matches the measurement table.
  5. Gates at this head (main merged through the relay's pr_update_branch): 38 success · 13 expected skip · 0 failed · 0 pending. NOT governed (+210/−2). L2 not owed (no contract face).
    • landing-k.mjs cannot answer for a ui/**-only PR (no Test Core shard runs). The branch was synced with main at 11:00Z.

Landing: non-governed, ≤3000 lines. The seat lands it through the ordinary queue.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 28, 2026 11:23
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

⛔ merge queue 构建失败 — 先分诊,再决定要不要重排

队列构建 46139727451 红了。队列跑的是全量套件(PR 侧 CI 只跑 affected 子集),
所以失败的测试可能在本 PR 没碰过的包里 —— 那不是重排能修的。每次盲目重排都会让排在后面的所有 PR 重建一轮。

分类:failure —— 按下面的日志分诊。

失败的 job(日志抽取,best effort):

  • Dogfood Regression Gate (3/3) — 失败步骤: Boot example apps and exercise real user flows

    @objectstack/dogfood:test:  FAIL   isolated  test/expression-conformance.test.ts > ADR-0058 D7 — expression surface conformance ledger > is a sound conformance ledger + ratchet (ADR-0060 checkLedger)
      ↳ 失败原因: @objectstack/dogfood:test: AssertionError: UNCLASSIFIED surface — add a ledger row (ADR-0060): data/object.zod.ts:ObjectSchemaBase.uiReadonlyWhen: expected [ Array(1) ] to deeply equal []
    

↳ 失败原因 是判读的关键:超时(Test timed out in … / Hook timed out in …)多半是负载/时序,不是本 PR 的回归;
断言(AssertionError: …)才指向真实的行为改变。两者的 FAIL 行长得一模一样,只有这一行能区分。

⚠️ 断言这一侧有一类例外,判据是断言在测什么,不是它是不是 AssertionError。 断言的对象是产品行为(一个值、一个形状、一次拒收)⇒ 照上面读:真实的行为改变,去查,⛔ 不要重排掉;
断言的对象是这次实验自身的有效性前提(跑完的耗时、负载下的先后、任何只在时间预算内才成立的条件)⇒ 它跟超时是同一类,同样对负载敏感,重排一次是合法的判别手段。
识别是机械的:断言的消息或它比较的值本身点名了一段时长、一个时间戳、一个耗时计数。实测过的一对 —— AssertionError: SecurityPlugin.init() ran: expected false to be true 测的是产品行为(真回归);
AssertionError: this run took over a second, so second-precision stamps could have differed too: expected 1006 to be less than 1000 测的是实验前提:它守护的那条不变式当时是绿的,同一个 head 原样重排一次即成功。
穿着 AssertionError 外衣的时间测量,仍然是时间测量。(⛔ 这只改「怎么读一次红」,不改「哪些测试可以重排」——后者由别处管。)

跨 PR 相同签名(24h,按失败测试文件聚合):

历史信号:

  • 本 PR 过去 24h 无队列失败记录(首次)。
  • 过去 24h 队列共有 27 个失败构建(不含本次)。

分诊清单:

  1. 失败测试在本 PR 改动的包里 → 真回归,修 PR。
  2. 失败测试与本 PR 无关 → 看上面的「跨 PR 相同签名」;已有汇总 issue ⇒ flaky/环境问题实锤,去那张 issue 上谈,修好前重排只会再烧一轮全队列。
  3. 两者都不是 → 可能与同组 PR 语义冲突;等前面的 PR 落地或失败出队后再重排一次即可,不要连续重排。

Generated by Claude Code · merge-queue-triage workflow (#4859)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

2 participants