Skip to content

feat(plugin-auth): the platform OP emits the standard locale claim at userinfo - #26012

Merged
objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/project-thread-v17ls7
Oct 26, 2026
Merged

objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/project-thread-v17ls7

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Leehom · project thread

Fixes #25529

Clause-②: yes
Metadata-protocol: none

What

The OIDC provider plugin-auth composes (oauthProvider({...}) in auth-manager-plugin-list.ts, where the composition now lives after the auth-manager.ts split) gains customUserInfoClaims. It returns { locale } only when the access token's scopes include profile and the user's sys_user.locale, read through the data engine in system context, is a tag the platform's one column reader accepts (normalizeRecipientLocale: non-empty, BCP-47-shaped, never the stringified-nothing literals). Otherwise it returns nothing. The rule lives in the new oidc-userinfo-locale-claim.ts.

  • No new host configuration key, no new column, no better-auth additionalField: every ObjectStack OP emits the claim.
  • Userinfo only. The ID token is untouched (the provider keeps profile claims out of it); the first test asserts the ID token carries no locale.
  • A failed locale read never fails userinfo: the claim is omitted and the host logger gets one warn naming the user (functional degradation, AGENTS.md degradation log levels).

Measured premises (tree 05f7758f05)

  • better-auth and @better-auth/oauth-provider are both 1.7.12 on main. customUserInfoClaims(info: { user, scopes, jwt, requestedClaims }) exists there (oauth-DXiqbRzK.d.mts:1761), is called only when scopes are non-empty, and its result is merged after the provider's own claims with sub re-pinned (introspect-DeWu79D4.mjs userinfo).
  • The OP composition named in the card moved: auth-manager.ts:4252 on the filing tree is now auth-manager-plugin-list.ts:500. Still plugin-auth, inside the claimed file surface.

Tests

packages/plugins/plugin-auth/src/oidc-userinfo-locale-claim.test.ts drives a REAL AuthManager with its OIDC provider on, over the shared in-memory engine, through its HTTP surface (sign-up, create-client, authorize with PKCE, consent, token, userinfo):

  • zh-CN user under profile: userinfo locale: "zh-CN", ID token without locale;
  • no stored locale: no locale key;
  • stored "undefined" literal: no locale key;
  • profile not granted: no locale, and the column is never read;
  • the locale read throws: userinfo still 200 with sub/name, no locale, exactly one warn carrying the user id;
  • one round trip end to end: a second AuthManager as the platform RP (genericOAuth, provider objectstack-cloud, configured by OIDC discovery) signs in through this OP over a fetch routed to the OP's handler (the discovery document through oauthProviderOpenIdConfigMetadata, as registerOidcDiscoveryRoutes mounts it). The RP's JIT path (idp-locale-claim.ts) stores zh-CN on the RP's own sys_user.

Red first, on main plus the test only (b6c90526): 3 failed / 13 passed — the zh-CN leg (expected undefined to be 'zh-CN'), the read-failure leg (warn called 0 times) and the round trip (RP user's locale undefined). The other three legs assert absence and are green on main by construction.

Green with the fix (630e39c2): 16/16 in the file (the count includes the imported shared engine module's own cases).

Ablation (node scripts/ablation-replace.mjs, anchor customUserInfoClaims: ({ user, scopes }) => renamed so the provider never reads it; the test imports ./auth-manager from source, no dist in the path): anchor 1 → 0, blob dade996dd516 → 2de5c1541934; the same 3 legs red (3 failed / 13 passed); restored to the HEAD blob dade996dd516, git diff HEAD empty.

  • pnpm --filter @objectstack/plugin-auth typecheck: exit 0 (incl. check:test-typecheck: no new test-layer errors).
  • pnpm --filter @objectstack/plugin-auth exec vitest run: 196 files / 3737 passed / 10 skipped, exit 0.
  • eslint --no-inline-config packages/plugins/plugin-auth: exit 0.

Gates (head 630e39c2)

node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack on this diff: 68 commands, every exit code captured before any pipe; --ran reconciliation: 68 derived, 68 run, 0 NOT-MEASURED, exit 0. Three first runs exited 3 (PREREQUISITE NOT MET, nothing measured) and were re-run green after the prerequisite: check-plugin-teardown-shape.mjs --self-test (shallow clone, positive-control commit fetched), check:dual-build-cjs-loads (needs a full build; turbo run build 120/120), check:type-check-debt (lock budget spent behind that build). Every CI family is read off this PR's check-runs, not re-run here.

Acceptance notes

  • Discovery claims_supported does not list locale. The provider computes that list itself from its standard-claim table and overwrites any claims option; only advertisedMetadata.claims_supported would replace it wholesale. OIDC Discovery makes the list RECOMMENDED and non-exhaustive, the platform RP never reads it, and a claims.userinfo request naming locale is filtered by it, so a client asking for locale individually without profile gets nothing, which matches the ruled scope rule. Noted, not filed.
  • A second read site of sys_user.locale exists beside storedRecipientLocale (email/SMS). It shares the column constant and the normalizer; it does not reuse that function because that function swallows a read failure silently by contract, and this order asks the failure to be logged.

Generated by Claude Code

@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Oct 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/plugin-auth, touching 7 documentable anchor(s).

1 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:

  • content/docs/permissions/tenant-audit-census.mdx (via SYSTEM_CTX (symbol, a top-level const object))

⛔ 1 release-owned page(s) also name something this change touched. These are read-only:

  • content/docs/releases/v17/17-0.mdx (via SYSTEM_CTX (symbol, a top-level const object))

content/docs/releases/ is RELEASE-OWNED (AGENTS.md "Documentation Guardrails"): release
notes are written centrally at release time, and a code PR that edits them is the exact PR
that guardrail exists to stop. They are still audited — read-only. If one of them is actually
wrong, file an issue or open a dedicated docs-only PR; do not edit it here.

What this run could not see
  • 1 anchor(s) matched too much of the corpus to be a work list: sys_user (literal, 43 pages)
  • 3 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 54 of 206 client-bound route-ledger rows — the other 152 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 152: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 55 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 97 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 21 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 3518664cb63a56903dcb69414e377d04b97cae57 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 213dd7d067813bf3f441b6dcac2bcfd624a18017 — the merge of head 630e39c241aafdaf16e276229aa28eb187c6955e into base 3518664cb63a56903dcb69414e377d04b97cae57, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 213dd7d067813bf3f441b6dcac2bcfd624a18017 && git checkout 213dd7d067813bf3f441b6dcac2bcfd624a18017
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 3518664cb63a56903dcb69414e377d04b97cae57 630e39c241aafdaf16e276229aa28eb187c6955e && git checkout -B drift-repro 3518664cb63a56903dcb69414e377d04b97cae57 && git merge --no-ff 630e39c241aafdaf16e276229aa28eb187c6955e

node scripts/docs-audit/affected-docs.mjs --json 3518664cb63a56903dcb69414e377d04b97cae57

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs 3518664cb63a56903dcb69414e377d04b97cae57 → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

席位核对 · ACCEPT · domain:server seat 1 · os-project-manager · session_01R1q2xdtYgU6FKrZ7LgjPCC · 2026-10-26T09:12Z

Head 630e39c241, report 6412234517 (on #25529), claim 6411343047. No contract review owed: no packages/spec/** diff and no narrowing.

item reading
Shape draft, base main, Fixes #25529, Clause-②: yes, Metadata-protocol: none, patch on @objectstack/plugin-auth.
Files 4 files, +443/−0: oidc-userinfo-locale-claim.ts, its wiring in the OP plugin list, one suite, one changeset. No host key, no column, no additionalField. Not governed.
Fix the platform OP's userinfo carries locale under the profile scope when the user's sys_user.locale is a non-empty BCP-47 tag, read through the data engine in system context; omitted otherwise; userinfo only.
Evidence red first 3/16 failed; ablation reds the same 3; plugin-auth 3737 green; one real OP → RP round trip stores zh-CN; 68/68 derived gates.
Carried objectstack-ai/cloud#3159 resumes as a pin bump once this ships.
Landing 「按照 pm-dispatch 规则复核过的都授权」 (Leehom, 2026-10-25T11:35Z): ready + auto-merge through the relay once every check on this head is green or an expected skip.

Generated by Claude Code

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review October 26, 2026 09:14
@objectstack-fleet
objectstack-fleet Bot enabled auto-merge October 26, 2026 09:14
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Oct 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

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

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

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

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

  • Test Core (8/8) — 失败步骤: Run this shard's tests

    @objectstack/objectql:test:  FAIL   local  src/hook-run-as.test.ts > #14010 Hook.runAs — the identity a hook's ctx.api presents > [#24497] a 'user' pin carries the user's grants and peer list, through
      ↳ 失败原因: @objectstack/objectql:test: Error: Test timed out in 5000ms.
    

↳ 失败原因 是判读的关键:超时(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,按失败测试文件聚合):

  • src/hook-run-as.test.ts — 24h 窗口内只有本 PR 撞到过,暂不汇总(再有一个不同 PR 撞到就会自动开汇总 issue)。
  • ⚠️ 24h 评论账本没读完(超过 5 页仍未读到窗口尽头),所以上面的「不同 PR 数」是下界,不是全量。

历史信号:

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

分诊清单:

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

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

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

席位核对 · queue note · domain:server seat 1 · os-project-manager · session_01R1q2xdtYgU6FKrZ7LgjPCC · 2026-10-26T09:53Z

Merge-queue build 40300684735 failed on one test, packages/objectql/src/hook-run-as.test.ts ([#24497] a 'user' pin …), with Error: Test timed out in 5000ms., not an assertion.

Not this PR's: the diff is four paths under packages/plugins/plugin-auth/** plus a changeset and touches nothing @objectstack/objectql runs. A wall-clock timeout in the full-suite queue build. No fix to port. The queue dropped auto-merge; re-armed once through the relay. A second queue failure on the same test gets a card of its own.


Generated by Claude Code

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 tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

2 participants