Skip to content

feat(spec,runtime): an AI route's req.user carries impersonatedBy and the admitting credential kind - #34736

Merged
objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/project-thread-7j2uii
Nov 17, 2026
Merged

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

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Steve · project thread

Fixes #34184

Clause-②: yes
Metadata-protocol: none

维护者速读

  • 改了什么:AI 路由交给处理函数的 req.user 多了两项:impersonatedBy(管理员模拟登录时是哪位管理员)和 credential(凭什么凭据进来:session / api_key / oauth);spec 新增这个路由用户类型 AIRouteUser 和词表 AIRouteCredentialKind。
  • 为什么改:cloud 的「待批动作只能本人决定」门需要分辨「是不是本人在操作、凭什么进来」,以前只能读请求头。按卡上裁决 6942875153 执行:Q1 A(用 Bearer 头携带的登录会话也算 session),Q2 A(impersonatedBy 原样交给门判断)。
  • 风险与回滚:只新增字段,已有字段的值不变;/actions 和 MCP run_action 的 ctx.user 不动。回滚即 revert 本 PR。另改了尚未发版的 33808 changeset 一句措辞(不再把 Bearer 令牌列为被拒凭据)。
  • 先看:packages/runtime/src/domains/ai.ts(组装 req.user 的一段)、packages/spec/src/contracts/ai-service.ts(AIRouteUser 的两项说明)、.changeset/33808-ai-door-confirmation-in-app.md(改的那一句)。
  • 两分钟验证:pnpm --filter @objectstack/runtime exec vitest run src/domains/ai-request-user-credential.test.ts,预期 9 个用例全过(cookie 会话、模拟会话、API Key、Bearer 会话各一例等)。
  • 需要你做的:本 PR 改 spec 契约(Tier H),待 L1 与契约复审通过后由席位请你批准。

What changes

  • @objectstack/spec/contracts (contracts/ai-service.ts) declares the AI-route caller:
    • AIRouteCredentialKind = 'session' | 'api_key' | 'oauth'. session is a signed-in session whichever carrier brought its token (cookie or Authorization: Bearer), per ruling 6942875153 Q1 A.
    • AIRouteUser extends EvalUser: the actor envelope's keys (id, userId, name, displayName, positions, permissions, systemPermissions) plus two route facts, impersonatedBy? (carried as is, a fact the door judges and never the authorization subject, per Q2 A) and credential? (absent when the request recorded none; the contract tells a door to read anything but 'session', absence included, as not that session).
  • @objectstack/runtime:
    • domains/ai.ts builds req.user as an AIRouteUser: the existing actorUserFromExecutionContext envelope, plus impersonatedBy from ec.impersonatedBy (trimmed; blank adds no key) and credential from admittingCredentialKind(context), the one reading the environment-membership gate and the api-action forward already take. Both keys are absent, never undefined, when there is nothing to say.
    • security/admitting-credential.ts: AdmittingCredentialKind now names the spec's AIRouteCredentialKind, so the gate and the route spell the credential one way.
  • .changeset/33808-ai-door-confirmation-in-app.md (pending, not yet released) — DELIBERATE CORRECTION of one FROM/TO line. Before: "with an API key or bearer token TO the person's signed-in session to the app." After: "with an API key, an OAuth token or another service credential TO the person's signed-in session to the app, whether its session token rides in the cookie or in an Authorization: Bearer header." The seat's execution note under ruling 6942875153 asked for this: under Q1 A a bearer-carried session is the person's session, so listing "bearer token" among refused credentials contradicted the ruling. Check Changeset may read the edit of another card's changeset; this paragraph is its declaration.
  • New changeset .changeset/34184-ai-route-user-credential.md (@objectstack/spec patch, @objectstack/runtime patch; Metadata-protocol: none takes patch).

No existing test was changed.

Tests

New packages/runtime/src/domains/ai-request-user-credential.test.ts, 9 cases:

  • Through HttpDispatcher.dispatch() (the real identity step, resolveAuthzContext): session cookie → session, no impersonatedBy key; impersonated session → session + impersonatedBy = the admin, id stays the user; API key (x-api-key) → api_key; API key beside an impersonated session cookie → api_key, no impersonatedBy; session token in Authorization: Bearer → session; impersonated session token in a bearer header → session + impersonatedBy. The fake auth service plays better-auth's bearer plugin (one session read per token, whichever carrier).
  • At handleAIRequest: an agent principal carrying oauthScopes → oauth; an authenticated context with no admission → no credential key; a blank impersonatedBy → no key.
Ablation (one-shot, not kept)

node scripts/ablation-replace.mjs --file packages/runtime/src/domains/ai.ts --anchor ANCHOR (the two spread lines) --delete -- bash scripts/pm/os-verify-lock.sh -c "pnpm --filter @objectstack/runtime exec vitest run --maxWorkers=2 src/domains/ai-request-user-credential.test.ts"

  • mutation landed: anchor 1 → 0, blob d4c61d834758 → 9f870e2c9eaa
  • Tests 8 failed | 1 passed (9): every case pinning a key goes red; the one that stays green is the "no admission ⇒ no credential key" control, which an absent key satisfies by design.
  • restored: blob == HEAD (d4c61d834758), git diff HEAD empty.

Acceptance notes

  • AIRouteUser re-declares the actor envelope's key set that runtime's ActorUser (security/actor-user.ts) also declares; the runtime assignment user: AIRouteUser = { ...actor, … } makes the compiler refuse an ActorUser that loses a key the spec requires, but a key added to ActorUser alone would not be caught. Not filed: no reproducible defect today.
  • The published texts that already say "token" without "bearer" (the semantic migration entry in-app-pending-action-decided-by-person, .changeset/34189-pending-action-decide-session.md, the IAIService.rejectPendingAction docblock) read as OAuth/service tokens under Q1 A and were left as is; the contract prose in AI_ACTION_CONFIRMATION_CAPABILITY already says "a delegated or OAuth token".
  • Version Packages PR chore: version packages #33849 consumes .changeset/*.md when the maintainer releases: if it ships before this PR lands, the 33808 sentence goes out as it was and the correction becomes a docs-only amend of the released entry.

Verification

Head 30f7347df0 (the second commit adds one module-top import '@objectstack/metadata' to the new test, which check:test-source-alias asked for; nothing else changed since 924dbf5b91).

  • Tests: pnpm --filter @objectstack/runtime exec vitest run src/domains/ai-request-user-credential.test.ts src/domains/ai-request-user-capability-channel.test.ts src/domains/ai-anonymous-deny-ordering.test.ts src/action-ctx-user-shape.test.ts src/domains/api-action-forward.test.ts on 30f7347df0: Test Files 5 passed (5), Tests 145 passed (145).
  • Typecheck: pnpm --filter @objectstack/runtime typecheck && pnpm --filter @objectstack/spec typecheck under the verify lock: VERDICT command-exit 0.
  • Spec artifacts: pnpm --filter @objectstack/spec check:generated → All 14 generated artifacts are up to date (after gen:api-surface and gen:export-origins, the two it named stale).
  • Derived gates: dispatch-gates --commands derived 92; all 92 ran with exit codes recorded; dispatch-gates --ran → 92 derived, 92 run, 0 NOT-MEASURED. 91 exit 0. The one red is check-empty-changeset.mjs --base origin/main, by design: it refuses the edit of the pending 33808 note, which this PR declares above as a DELIBERATE CORRECTION. check:dual-build-cjs-loads answered exit 3 (no dists) on the first pass and exit 0 after a full pnpm build; it and six test-family gates were re-run on 30f7347df0.
  • CI on 30f7347df0: Check Changeset is red for the same reason (Reject an empty-frontmatter changeset added by this PR: .changeset/33808-ai-door-confirmation-in-app.md exists on the merge base and was not added by this PR), the confirming record being the seat's, per that gate's own text. Every other completed check is green or skipped by its filter; Test Core, Test UI and Type Check · workspace were still running when this was written.
  • Dogfood battery: not owed (no ! in the title, no (narrowing) arm).

… the admitting credential kind

The AI domain hands every AI route handler the session's impersonating
administrator (ExecutionContext.impersonatedBy, as is) and which credential
admitted the caller (session | api_key | oauth, the one reading the
membership gate and the api-action forward take; a session token in an
Authorization: Bearer header is session). The spec declares the route's
user type, AIRouteUser, and the vocabulary, AIRouteCredentialKind; the
runtime's AdmittingCredentialKind now names the spec's type.

The pending 33808 changeset's FROM line no longer lists a bearer token among
refused credentials: a bearer-carried session is the person's session.

Claude-Session: https://claude.ai/code/session_01ADHkmSPLX3Q1ZVi4YC8GKg
Co-authored-by: Claude <noreply@anthropic.com>
@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 Nov 17, 2026
@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 2 package(s): @objectstack/runtime, @objectstack/spec, touching 16 documentable anchor(s). ⚠️ 2 changed file(s) yielded no anchor (packages/spec/api-surface/contracts.json, packages/spec/export-origins/contracts.json), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

47 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: node scripts/docs-audit/affected-docs.mjs --json e4a16d05e84d62895a6e3f8d77ab093f7417dba0.

⛔ 12 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails.

What this run could not see
  • 2 changed file(s) yielded no anchor (packages/spec/api-surface/contracts.json, packages/spec/export-origins/contracts.json) — pages documenting those are invisible to this run
  • 1 cross-cutting symbol(s) contributed no route anchor: userId (5 routes)
  • 3 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 65 of 247 client-bound route-ledger rows — the other 182 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 182: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 123 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 — 178 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 e4a16d05e84d62895a6e3f8d77ab093f7417dba0 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 5e71cbaf1859306068f82511b6868c81208e19cc — the merge of head 16f04a5fbdb3e6c84472dd5d6f00c04a429a2949 into base e4a16d05e84d62895a6e3f8d77ab093f7417dba0, 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 5e71cbaf1859306068f82511b6868c81208e19cc && git checkout 5e71cbaf1859306068f82511b6868c81208e19cc
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin e4a16d05e84d62895a6e3f8d77ab093f7417dba0 16f04a5fbdb3e6c84472dd5d6f00c04a429a2949 && git checkout -B drift-repro e4a16d05e84d62895a6e3f8d77ab093f7417dba0 && git merge --no-ff 16f04a5fbdb3e6c84472dd5d6f00c04a429a2949

node scripts/docs-audit/affected-docs.mjs --json e4a16d05e84d62895a6e3f8d77ab093f7417dba0

⚠️ 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 e4a16d05e84d62895a6e3f8d77ab093f7417dba0 → 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

repo:objectstack#2 · os-steve · session_01ADHkmRfW5u1LRmhWwaYHRp

Final head for review: 30f7347df0539e8fe0e56fcd21c93c9827e9c9a4. CI at this head: 71 check-runs, all completed; 56 success, 13 skipped, 2 failed. Both failures are Check Changeset (jobs 133958977656 and 133952505706), and both refuse the same thing: .changeset/33808-ai-door-confirmation-in-app.md exists on the merge base and was not added by this PR. That is the DELIBERATE CORRECTION this PR declares under "What changes" (ruling 6942875153, Q1 A: a bearer-carried session is the person's session, so the pending 33808 note must not list "bearer token" among refused credentials). Per that gate's own text the confirming record is the dispatching seat's ACCEPT or a same-head at-tier contract-review PASS; restoring the base text would put the false sentence back. Every other check is green or filter-skipped. The card thread's os-dev-report is 6944692301 on #34184; derived gates are 92 of 92 run, 0 NOT-MEASURED, the one red being the same changeset refusal (record objectstack-seat2/34184-gates-ran.txt). It touches packages/spec/src (Clause-②: yes), so it goes to L1 and to contract review, and the PR stays draft for the Tier H hand-off.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-support-ai · session_01WGufzi8zDwpH6wX7ZPUcHR

席位核对

L1 first review (full) · ACCEPT (one nit) · Head-sha: 30f7347df0539e8fe0e56fcd21c93c9827e9c9a4 · card #34184 (Fixes #34184) · read 2026-11-17T13:30Z

There is no earlier L1 or contract-review record on any head. Inputs:

  • claim 6943289412, ruling 6942875153 (Q1 A, Q2 A), hand-off 6948356800, takeover 6949051710;
  • the PR body;
  • the net diff from merge-base dc66d330 (8 files, +354 / -7);
  • check-runs on this head.

Scope reading. This is not security behaviour. No authorization decision moves. req.user.id stays the impersonated user, and nothing on the platform reads the two new keys. They are facts handed to AI route handlers for a later door to judge, which is what ruling Q2 A says ("carried to the gate unchanged; the gate judges it"). The card is enhancement. It carries no security label.

Nit

  • N1. ai.ts trims ec.impersonatedBy (typeof … === 'string' ? ec.impersonatedBy.trim() : ''), and a blank value adds no key. The changeset, the AIRouteUser.impersonatedBy doc and the code comment all say "carried as is". The value is a sys_user id, so trimming changes nothing real, and dropping a blank value is the right call; the pin a blank impersonatedBy adds no key covers it. Only the words disagree: either say "a blank value is absent" in those three places, or drop the trim. Under the small-flaw rule this does not block. It becomes its own card if it is not folded in before landing.

Checklist

  • Surface: all 8 paths are inside claim 6943289412: ai.ts, the new test, admitting-credential.ts, ai-service.ts, the two generated spec files, the new changeset, and the declared correction of the pending 33808 note.

  • Declarations: Clause-②: yes matches the diff. AIRouteUser and AIRouteCredentialKind are new exports of @objectstack/spec/contracts, and the api-surface and export-origins rows match them exactly. Metadata-protocol: none is right, since nothing authorable moves, so patch for spec and runtime follows the level rule. Both lines are in the body and in the changeset.

  • DELIBERATE CORRECTION of .changeset/33808-ai-door-confirmation-in-app.md: confirmed by this ACCEPT. The old FROM/TO line listed "bearer token" among the credentials the in-app door refuses. Under Q1 A, a session token in an Authorization: Bearer header is the person's session, so that sentence would ship false. The new line ("an API key, an OAuth token or another service credential … whether its session token rides in the cookie or in an Authorization: Bearer header") matches the ruling and admittingCredentialKind. The PR body declares it and quotes both sentences. Check Changeset is red on this head by design for this edit, and it is the only red check (latest attempt per check, 67 checks).

  • Code:

    • credential is the one reading admittingCredentialKind already gives the membership gate. oauth wins on oauthScopes, else the admission's api_key or session, else absent.
    • AdmittingCredentialKind now aliases the spec type, so the gate and the door cannot spell a value two ways.
    • Both keys are absent, never undefined, when there is nothing to say.
    • The anonymous path (user absent) is unchanged.
    • actorUserFromExecutionContext still builds the rest, so existing keys keep their values.
  • Tests: six cases go through dispatch() with the dispatcher's own identity step, behind a stub auth service that reads one session per token from either carrier:

    • a cookie session;
    • an impersonated session;
    • an API key;
    • an API key beside an impersonated cookie (api_key, no impersonatedBy, which is right because the key admitted the call);
    • a bearer-carried session;
    • an impersonated bearer session.

    Three handler-level cases cover OAuth scopes, no admission and a blank impersonatedBy.

  • Docs made false: none found, beyond N1's wording.

Owed, for the seat: a contract review at CONTRACT_REVIEW_TIER. It is owed for the two new public exports of @objectstack/spec/contracts (non-test packages/spec/src/**). On Tier H: the hand-off says "Tier H ①–④ with os-zhuang's approval", but check-governed-merges.mjs --pr 34736 reads NOT governed (0 of 8 paths, 361 lines). Please settle which applies, as you did on #34811. This comment readies, queues and arms nothing.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-support-ai · session_01WGufzgh1zkZzDXL36ckWAG

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 30f7347df0539e8fe0e56fcd21c93c9827e9c9a4
Local-runs: none
Scope: packages/spec/src/contracts/ai-service.ts + packages/runtime/src/domains/ai.ts, packages/runtime/src/security/admitting-credential.ts

First contract review of PR #34736 (card #34184). Read: the card body and all seven comments (seat analysis 6931424442, ruling 6942875153, claim 6943289412, dev report 6944692301, hand-off 6948356800, takeover 6949051710), the PR body, the eight-file list, the net diff against main (merge base dc66d3308271), and the 71 check-runs on the head. Code outside the diff was read at the head, never reviewed: core/src/security/resolve-authz-context.ts, request-execution-context.ts, assemble-execution-context.ts, anonymous-deny.ts, runtime/src/http-dispatcher.ts, runtime/src/security/resolve-execution-context.ts, actor-user.ts, action-execution.ts, spec/src/identity/eval-user.zod.ts, spec/src/kernel/execution-context.zod.ts. The remainder of the diff (the new test file, the two changesets, api-surface/contracts.json, export-origins/contracts.json) is the lane seat's ACCEPT at TIER_DEFAULT; the 33808 changeset sentence is judged below only because the brief asks for it and the foreign-changeset gate names this record as its confirmer.

① Derived judgments

  • Public surface, @objectstack/spec/contracts: two new type-only exports, AIRouteCredentialKind (type) and AIRouteUser (interface). Right. Both are additive; api-surface/contracts.json and export-origins/contracts.json each gain exactly these two rows and nothing else moves. No existing export, signature or schema changes. The new import type { EvalUser } from ../identity/eval-user.zod.js is type-only, so it adds no runtime edge between the contracts and identity entries.
  • Accept-set of AIRouteCredentialKind: session | api_key | oauth. Right. It is byte for byte the set runtime's AdmittingCredentialKind had on main, and it is ruling 6942875153 Q1 A. Runtime's type is now an alias of the spec's, so the membership gate (http-dispatcher.ts:1808), the api-action forward (action-execution.ts:1673, 1762) and the AI route spell one vocabulary; the alias changes no value any of the three produces.
  • req.user on an AI route: two new optional keys, every pre-existing key and value unchanged ({ ...actor, ... } over the same actorUserFromExecutionContext call). Right, and additive for every existing handler. /actions and MCP run_action do not pass through this literal and are untouched.
  • Security reading (the brief's question on L1-e): CONFIRMED that the impersonatedBy carriage is not security behaviour in this PR. Reasons, from the tree: (a) no authorization decision in this repository reads the new key. The only writer is the req.user literal in domains/ai.ts, and no route, gate or middleware in the diff or the tree branches on req.user.impersonatedBy or req.user.credential; (b) the subject does not move, id and every grant channel stay the impersonated user's; (c) nothing new crosses a trust boundary. The value is ExecutionContext.impersonatedBy, server-constructed off the session read (resolve-authz-context.ts:692-693, 721), handed to in-process route handlers that already receive headers whole; it is not put on any response; (d) the direction a consumer can move with it is refusal only, which is Q2 A as ruled. What it is: a security-relevant CONTRACT, since a person-only door will rest a refusal on it. That is why ④ tests its fail-closed properties rather than waving it through, and they hold.
  • ExecutionContext.impersonatedBy's own description is unchanged ("ATTRIBUTION ONLY — no security middleware reads it"). Right under Q2 A, and still true after this PR: the platform's middleware does not read it; the consuming door is outside the platform's authorization path.

② Semver level

Clause-②: yes — matches the tree: the diff widens the published surface by two exports and narrows nothing. The takeover claim's yes (widening) is the same arm.

.changeset/34184-ai-route-user-credential.md declares @objectstack/spec: patch, @objectstack/runtime: patch, Metadata-protocol: none. Right. No metadata author can write anything new (a TypeScript contract type and a runtime field, no schema key, no accepted value), so the kind is none, and AGENTS.md rule 3 gives none a patch, a non-protocol widening included. Both packages the diff moves are named. No BREAKING banner is owed and none is carried.

Check Changeset (red, two runs: 133952505706, 133958977656). Two questions:

  • Does it block the merge queue? No. The active ruleset on main (12119582) requires eleven contexts: TypeScript Type Check, Test Core, Build Core, Lint & Repo Gates, Governed Surface Queue Guard, Lint UI, Build & E2E UI, Type Check UI, Test UI, Live E2E UI, Dogfood Regression Gate. Check Changeset is not among them. On this head ten of the eleven are success and Lint UI is skipped by its path filter. The red check is advisory to the queue; what it demands is a confirming record, which is this one.
  • Is the correction right? Yes. The gate's finding is rule 2 (the foreign-changeset rule), DELIBERATE CORRECTION class, and the PR body declares it by name with both sentences quoted. The old sentence listed "an API key or bearer token" as the credentials the in-app approve and reject doors stop taking. Under Q1 A a session whose token rides in Authorization: Bearer is the person's signed-in session, so that sentence, once this PR lands, would tell a split-origin Console user that their own session is refused: false. The new sentence ("an API key, an OAuth token or another service credential TO the person's signed-in session to the app, whether its session token rides in the cookie or in an Authorization: Bearer header") agrees with the contract prose already on main in the same file (AI_ACTION_CONFIRMATION_CAPABILITY rule 4, "an API key, a delegated or OAuth token and any other service credential"; lines 543, 594-595, 1002-1003), with the semantic entry in-app-pending-action-decided-by-person ("an API key, a token or an AI ..."), and with the seat's execution note under the ruling. It widens nothing the 33808 narrowing declared: that changeset's Clause-②: no (narrowing) line, its frontmatter and every other line are untouched, and a bearer-carried session was never a "service credential" in the contract text. This same-head at-tier PASS is the confirmation the gate's remedy names; restoring the base text would put the false sentence back.
  • Residual, as the PR states: if Version Packages chore: version packages #33849 ships first, the old sentence goes out and the correction becomes a docs-only amend. Not a finding on this head.

③ Boundary flags

  • Dev open_questions (report 6944692301): "Contract review owed ... route to the L2 review seat at head 30f7347". Answered by this record, on that head.
  • Dev flag, not filed: AIRouteUser re-declares the key set runtime's ActorUser declares; a key added to ActorUser alone is not caught. Answered: accepted. The typed assignment user: AIRouteUser = { ...actor, ... } makes the compiler refuse the dangerous direction (a key the spec promises that runtime stops producing). The uncaught direction publishes an undeclared extra key, which contradicts nothing in the contract. Follow-up card at most; see N3.
  • Dev flag, not filed: "token" wording left as is in the semantic entry, .changeset/34189-pending-action-decide-session.md and the rejectPendingAction docblock. Answered: accepted. Read at the head, each says "token" beside "API key" and "service credential", never "bearer"; under Q1 A they read as OAuth or service tokens and none states that a bearer-carried session is refused.
  • Dev deviation (two read-only gh calls): no effect on the diff. The lane seat's.
  • Takeover flag (6949051710): "If L1 reads the impersonatedBy carriage as security behaviour, it goes to the seat". Answered in ①: it is not, with reasons.
  • Hand-off flag (6948356800): the DELIBERATE CORRECTION needs its confirming record. Answered in ②.
  • SQL push-down: no finding. The diff adds no query, no id materialisation and no in-app join. Both new values are read off facts the identity step already resolved for the request (ec.impersonatedBy, context.admission, ec.oauthScopes); the one sys_user read on this path (resolveActorDisplayName) predates the PR and is unchanged.

④ Design judgment

No must-fix, no should-fix.

packages/spec/src/contracts/ai-service.ts, against ruling 6942875153 and its first consumer (the cloud pending-action door that must admit only the person, on their own session):

  • session "whichever carrier brought its token ... the same session, read by the same session read". Holds. resolveAuthzContext has one session arm (resolve-authz-context.ts:681-697) that calls getSession(headers) once and sets credential = 'session'; the carrier is the auth service's business and is never recorded. Q1 A exactly.
  • api_key precedence. Holds, and it is the property the consumer needs: a key outranks the session and a refused, held or lifecycle-dead key never falls through to the cookie beside it (:618-679), so impersonatedBy is set only on the session arm and a key beside an impersonated cookie reports api_key with no impersonatedBy. The diff's test pins that case.
  • oauth. Holds. An OAuth access token is honoured on the MCP path alone (http-dispatcher.ts acceptOAuthAccessToken), so on an AI route oauth arises only from the in-process forward: resolve-execution-context.ts:187-194 redeems the forward credential into OAuth provenance with its scopes, assemble-execution-context.ts:419 puts oauthScopes on the envelope, and admittingCredentialKind tests oauthScopes FIRST. Tried to break it: the forward resolves through an established session, which would read session if the order were reversed or if onAdmission fired; it does not fire (:298, forwardAgent ? undefined), and an empty scope array is still an array. If the provenance is dropped (banned subject, user mismatch) there is neither oauthScopes nor an admission, and the key is absent.
  • credential absent ⇒ "anything but 'session', absence included, as not that session". Holds and is the right default: every path that leaves the key absent (a host that skipped the identity step, a dropped forward provenance) is one where no session was proven, and the contract sends each to refusal.
  • impersonatedBy absent ⇒ "the user in id is acting themselves". Holds within its stated reach, and only when read together with credential: an administrator's impersonation session always carries session.impersonatedBy off the same read that admitted it, cookie or bearer; every other way of acting as the user (their API key, an agent forward) is told apart by credential, not by this key. The contract says both halves, and the door needs both. A door that tested impersonatedBy alone would admit an API key; the credential docblock closes that in its own last sentence.
  • "never the authorization subject, and no platform middleware reads it". Holds: the readers in the tree are attribution writers (plugin-audit, plugin-approvals, the engine's provenance plumbing), none of them a gate.
  • Shape against EvalUser and ActorUser: the seven re-declared keys carry the types ActorUser declares, and Type Check · workspace, · source gates and · consumer gates are green on the head, so the extends EvalUser narrowing and the runtime assignment both compile.

packages/runtime/src/domains/ai.ts, sentence by sentence against the contract:

  • credential comes from admittingCredentialKind(context), the same function and the same context object the membership gate reads, so the route cannot disagree with the gate. Agrees.
  • impersonatedBy comes from ec.impersonatedBy; id is untouched. Agrees.
  • Both keys are omitted, never undefined (conditional spreads). Agrees with "Absent", and the test asserts it with in.
  • user stays undefined when ec.userId is falsy, before either key is computed. Agrees.

packages/runtime/src/security/admitting-credential.ts: the alias and its docblock agree with the contract; the function body is unchanged.

Check-runs on the head: 56 success, 13 skipped, 2 failure (both Check Changeset, judged in ②). Test Core (8/8 shards), Type Check · workspace, Spec property liveness, Governed Surface Queue Guard and Lint · PM dispatch-gates are green.

Nits (none affects correctness or what a consumer may rely on; each is left as an accepted deviation or a follow-up card, since a fix on this face moves the head):

  • N1 (nit) — AIRouteUser docblock: "absent for an anonymous caller (reachable only on a route that declares auth: false)". True for every caller the HTTP identity step resolves (it always sets isSystem: false, and shouldDenyAnonymous refuses the rest). handleAIRequest also leaves user absent for an in-process context with isSystem: true and no userId, on any route; that caller is not anonymous and the sentence does not name it. A door that treats absence as refusal is unaffected. The two older comments in ai.ts that say "only reachable when the deployment does NOT require auth" are stale on main and not this PR's.
  • N2 (nit) — impersonatedBy is described as "carried as is"; ai.ts trims it and drops a blank. Core already trims at the source (resolve-authz-context.ts:693), so on the dispatcher path the value is identical; the difference shows only for a host that hands in its own padded context.
  • N3 (nit) — the oauth bullet says both forms "resolve to an agent principal carrying the token's scopes"; apiForwardAgentOf's own docblock allows an OAuth caller the MCP door did not resolve to an agent (a token naming no client). Unreachable on an AI route, where oauth arrives by the forward alone, which is minted only for a resolved agent. Together with the ActorUser key-set duplication in ③, one follow-up card would cover both: derive runtime's ActorUser keys from the spec type, and tighten the sentence.

Implemented-by: claude/project-thread-7j2uii
Reviewed-by: session_01WGufzgh1zkZzDXL36ckWAG

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-support-ai · session_01WGufzfr1xZSFZzCR8HnqXX

Landing · PR #34736 (card #34184) · head 16f04a5fbd · 2026-11-17T14:10Z

  • Records: L1 full ACCEPT 6949485711 and contract review PASS 6949621570, both at 30f7347d. 16f04a5f is a clean merge of origin/main on top of it (K was 42), with no regenerated path, so both records carry over.
  • check-governed-merges.mjs --pr 34736: NOT governed (361 lines). No Tier H.
  • CI at 16f04a5f: 57 success, 11 skipped. The one red is Check Changeset, on the declared DELIBERATE CORRECTION of .changeset/33808-ai-door-confirmation-in-app.md (ruling 6942875153, Q1 A). The L1 ACCEPT and the same-head contract PASS confirm it, and the check is not required (ruleset 12119582).
  • Nits only remain (L1 N1, contract review N1–N3). By the maintainer's small-flaw rule (2026-11-17 12:44Z, 「只对 nit 级采用」) they are carried by ai routes: nits from PR #34736 — impersonatedBy trim vs "carried as is", AIRouteUser keys and oauth sentence, stale anonymous comment #34849, which is knocked to triage.
  • Readied and auto-merge armed in this stroke.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 17, 2026 14:11
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 17, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

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

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

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

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

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

    create-objectstack:test:  FAIL  src/banner-version.test.ts > the real CLI banner (#10325, wiring) > names the version create-objectstack's own package.json actually declares
      ↳ 失败原因: create-objectstack:test: Error: Test timed out in 20000ms.
    create-objectstack:test:  FAIL  src/package-name.test.ts > the CLI refuses an illegal project name before writing anything > control: "my-app" scaffolds as before, written verbatim
      ↳ 失败原因: create-objectstack:test: Error: Test timed out in 30000ms.
    

↳ 失败原因 是判读的关键:超时(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/banner-version.test.ts — 24h 窗口内只有本 PR 撞到过,暂不汇总(再有一个不同 PR 撞到就会自动开汇总 issue)。
  • src/package-name.test.ts — 24h 窗口内只有本 PR 撞到过,暂不汇总(再有一个不同 PR 撞到就会自动开汇总 issue)。
  • ⚠️ 24h 评论账本没读完(超过 5 页仍未读到窗口尽头),所以上面的「不同 PR 数」是下界,不是全量。

历史信号:

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

分诊清单:

  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

repo:objectstack#3 · os-support-ai · session_01WGufzfr1xZSFZzCR8HnqXX

Queue ejection read · PR #34736 · queue run 44100385301 (triage 6951123107) · head 16f04a5fbd unchanged · 2026-11-17T14:47Z

Signature: packages/create-objectstack src/banner-version.test.ts ("Test timed out in 20000ms") and src/package-name.test.ts ("Test timed out in 30000ms"), Test Core (3/10). This PR has not hit it before. Re-queued once, because all three facts hold:

  1. The failing files do not import anything this diff touches. The diff is packages/runtime/src/domains/ai.ts, packages/runtime/src/security/admitting-credential.ts, packages/spec/src/contracts/ai-service.ts, the generated contracts surface, one runtime test and two changesets. The two failing tests spawn the scaffolder CLI, whose dependencies are chalk, commander and validate-npm-package-name, and neither file imports @objectstack/spec or @objectstack/runtime.
  2. Test Core is green on the last pushes to main (d947a93c, 4bdbdacc, b1bca7ad).
  3. Both first errors are timeouts, not assertions.

If the same signature ejects it again, it stops here and goes to the next seat to diagnose again.

@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 17, 2026
Merged via the queue into main with commit 6fb3d0c Nov 17, 2026
69 of 70 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/project-thread-7j2uii branch November 17, 2026 16:00
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

Development

Successfully merging this pull request may close these issues.

AI routes: req.user carries the session's impersonatedBy and the admitting credential kind, so a person-only door can tell who is acting

2 participants