Repository navigation
fix(rest): /meta negotiates the request locale against the held locales before it picks a pack - #36561
Conversation
…t the held locales Claude-Session: https://claude.ai/code/session_01ADHkmRB34k9WUWeGpRnVNm Co-authored-by: Claude <noreply@anthropic.com>
…tql and the cached arm Claude-Session: https://claude.ai/code/session_01ADHkmRB34k9WUWeGpRnVNm Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ADHkmRB34k9WUWeGpRnVNm Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift Check2 anchor(s) derived from 1 changed package(s); no hand-written page names any of them, so this run has nothing to list — not a clean bill of health. This check sees only pages that NAME a derived anchor: one that documents this change in prose, or enumerates it in an authoring dialect, names none and stays invisible to it on every run. What this run could not see
Coarse fallback — 19 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older |
|
repo:objectstack#2 · os-steve · session_01ADHkmRB34k9WUWeGpRnVNm 席位核对ACCEPT — PR #36561 @ 5555e3e (head of record, full sha on the PR) · card #36466 · L1 first read by area s2-B (area order rule 9) · 2026-11-22T23:58Z
|
Requested by Steve · project thread
Fixes #36466
Clause-②: no
Metadata-protocol: none
维护者速读
What changes
The card's ruling, quoted: "Make the
/metaread (packages/rest/src/meta-item-read-gate.ts) negotiate the request tag the way the other readers do before it picks a pack. No spec change."metaTranslateOptions(theResolveOptionsevery metadata-document translation builds) now carrieslocaleas the request tag negotiated against the locales the i18n service reports:resolveBundleLocale(@objectstack/spec/system, the platform's one locale ladder) overgetLocales(). That is the question objectql'snegotiatedMessageLocaleand plugin-approvals'negotiatedReaderLocalealready ask, over the same set. Neither of those is importable from@objectstack/restwithout a new export (objectql does not export it; plugin-approvals is downstream), so a private helper beside it (negotiatedTranslationLocale) repeats only the offered-set plumbing and calls the shared rule. It adds no second rule and no new export.getLocales, a throwing, empty or non-array answer, or no match. So a locale the deployment holds no pack for still walks the declared chain to the default locale.metaTranslateOptionsis the one builder, so the item read and the list read on both transports (RestServerand the runtime dispatcher, which sharetranslateMetaDocument/translateMetaList), the view container, the stale-plural rule, theGET /metatypes listing and the public form's object labels (translateOptionsFordelegates here) all read the negotiated tag. The doc locale collapse (resolveDocLocale) andextractLocale's other callers (export, import template) are untouched.packages/specchange.Tests
New top-level describe
#36466 §7inpackages/rest/src/meta-i18n-declared-fallback-chain.test.ts, the shared harness of the/metai18n pins (§6 is this deployment'ssourceLocalecase). The fixture issourceLocale: 'en',defaultLocale: 'zh-CN', the chain collapsed tozh-CN, azh-CNpack, and anenpack that holds noaccountrows.en-USrequest with only anenpack readsAccountfrom/meta(item read, list read, and bareenagree).fr-FR), and a header-less request, still read the default locale (客户).enlocale held,en-UShas nothing to negotiate to and walks to客户;zhstill reads thezh-CNpack.en-USandfr-FR,/meta's label and the label objectql'sDELETE_RESTRICTED(code and status asserted) names on the same i18n service are the same (Accountand客户), and the other one is absent.getMetaItemCached, the default door):en-USis servedAccountandenthe same body; theen-USvalidator revalidates its own request (304); sent withzh-CNorfr-FRit answers200with客户, never a304for the English body.Acceptance notes
extractLocale,meta-item-read-routes.ts, [P2] i18n: zh-CN ↔ English switch occasionally garbled — requires page refresh #1319). Translation runs after it with the negotiated tag. So within a running server each sent tag maps to one body:en-USandenget separate validators over identical bodies (fewer shared304s, never a wrong one), and a validator never crosses languages (pinned above). Keying the validator on the negotiated tag would needmeta-item-read-routes.ts, outside this card's file surface, so it is raised as a question in the report. Not pinned, because it is already true of any pack edit: the validator hashes no translation input, so a client that cached anen-USbody before this deploy can be answered304on the old客户body until the document changes.controlled-by-parent-master-edit-user-message.test.ts(deleted, not committed) on an i18n service withsourceLocale: 'en',defaultLocale/fallbackzh-CNand anenpack: the master-detail refusal'suserMessagenames the masterContractforen,合同foren-US, andContractforfr-FR.denialLocaleOfreturns the raw request tag anddenialLabelshands it totranslateObjectas written. So after this PR,/meta(Contract) and plugin-security (合同) still disagree foren-US, and forfr-FR(/metaserves合同, plugin-security falls back to anensentence namingContract). This is reported for the seat to file, not fixed here.GET /metatypes listing negotiate too, because they read the same builder. That is the same defect class on the same function; no pin was added for them.Verification
Two-minute check:
pnpm --filter @objectstack/rest exec vitest run --maxWorkers=2 src/meta-i18n-declared-fallback-chain.test.ts. Expect 30 passed, including#36466 §7 … an en-US request with only an en pack reads Account.Read first:
packages/rest/src/meta-item-read-gate.ts, themetaTranslateOptionshunk (locale: negotiatedTranslationLocale(service, locale)) and the new helper below it.packages/rest/src/meta-i18n-declared-fallback-chain.test.ts, the#36466 §7describe (the parity and cached-arm cases).Test readings (head 5555e3e)
pnpm --filter @objectstack/rest test && pnpm --filter @objectstack/rest typecheckunder the verify lock: Test Files 427 passed (427), Tests 8788 passed, 351 skipped (9139);tsc --noEmitandcheck:test-typecheckOK (0 files in debt). Lock VERDICT command-exit 0.pnpm --workspace-concurrency=2 --filter '@objectstack/rest^...' build, lock VERDICT command-exit 0. The parity case reads@objectstack/objectqlfrom that build.Ablation (fix committed first)
node scripts/ablation-replace.mjs --file packages/rest/src/meta-item-read-gate.ts --anchor 'locale: negotiatedTranslationLocale(service, locale),' --replacement 'locale, /* ABLATION-36466 */' -- …vitest run … meta-i18n-declared-fallback-chain.test.ts: anchor 1 to 0, marker 0 to 1, blob 3b1e09164a86 to e2c5192f903c. The test imports./rest-server.jsfrom source, so no dist step is involved. Result: 3 failed, 27 passed. Red:an en-US request with only an en pack reads Account,for the same request, /meta and objectql name the object with the same label, and the cached-arm case. The no-pack, no-en andzhcontrols stayed green. Restore: blob equals HEAD (3b1e09164a86), andgit diff HEADis empty.Gates
Derived with
node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstackat 5555e3e: 69 commands (3 changed paths). Each was run with stdin closed and its exit captured before any pipe.check:type-check-debthit the per-command 420 s cap (exit 124) on the first pass; re-run alone, it reportedOK — 0 ledger entr(ies) re-measured … 0 raw tsc error(s), exit 0.check:dual-build-cjs-loadsexited 3 (PREREQUISITE NOT MET, no full build); afterpnpm turbo run build --concurrency=2 --filter='!@objectstack/docs'(lock VERDICT command-exit 0, 120/120 tasks) it reported124 published require entry point(s) across 72 package(s) load, exit 0.--ranreconciliation:69 derived famil(ies) accounted for — 69 run, 0 NOT-MEASURED.node scripts/pm/overlap-check.mjs --branch=HEAD:VERDICT clean exit 0(merges cleanly with origin/main d463c46; no open PR head shares a file).🤖 Generated with Claude Code
https://claude.ai/code/session_01ADHkmRB34k9WUWeGpRnVNm