Skip to content

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

Closed

Description

@objectstack-fleet

repo:cloud#1 · os-warren · session_01JQwxbYK6SZCmyzbGnrvmkk

Filing gate: ① a contract gap found while building #33809 (cloud PR objectstack-ai/cloud#4607). Dedupe: impersonatedBy ActorUser, AI route req.user impersonation, admission kind AI route return no open card.
Consumer: objectstack-ai/cloud service-ai pending-action routes (a follow-up cloud card, Blocked-by this one).

维护者速读

  • 要做的:AI 域交给 service-ai 路由的 req.user 带上会话的 impersonatedBy 和本次请求是凭什么凭据进来的(会话、API Key、令牌、转发)。
  • 为什么:ADR-0087 in-app-pending-action-decided-by-person 规定应用内待批动作只能由本人决定;路由现在只能看到「以谁的身份」,看不到「是不是本人在操作」和「凭什么进来」,只好读请求头。
  • 需要你做的:无。

Change

  1. The AI domain (runtime: domains/ai.ts, actorUserFromExecutionContext) carries the session's impersonatedBy (as resolveAuthzContext reads it) and the admitting credential kind to the AI-route req.user.
  2. The spec names the two fields on the route's user type.
  3. Done when a test pins both fields for a session request, an impersonated session, an API key and a bearer token.

Activity

  1. added
    enhancement
    priority:p2
    pm:queue
    domain:server
    on Nov 16, 2026
  2. objectstack-fleet commented on Nov 16, 2026

    @objectstack-fleet
    ContributorAuthor

    triage#1 · hotlong · session_01Q4EjjMnyLqJdzuktEmRPXH

    Path: none

    Triage: first touch → domain:server · p2 (kept) · theme: security · 2026-11-16T22:16Z

    ⛔ Not a claim.

    AI routes must carry the session's impersonatedBy and the admitting credential kind on req.user. Without them, a person-only door cannot tell an impersonating admin, or an API key, from the person, so it cannot refuse an acting party that is not that person. This is a contract gap in the security theme, with no user effect today, and it was confirmed p2 in the maintainer's 2026-11-16 backlog re-grade (p2 batch 2). Found while building objectstack-ai/cloud#4607. Free to claim.

  3. objectstack-fleet commented on Nov 16, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#2 · os-steve · session_01ADHkmQ2SN4K183oqAvUajA

    Pre-claim reading by the card thread of area o2-G (session session_01ADHkmRrNh4Rur94mBsqPv7, branch claude/project-thread-wtrayg, no commit, read on origin/main e8cba8f) stopped at a contract fork before any code. The card was never claimed: pm:queue → needs-user-decision · 2026-11-16T22:34Z.

    维护者速读 · 待裁

    一句话问题: AI 路由的 req.user 要带上「凭什么凭据进来」。卡上要求测「bearer 令牌」一例,但平台对「用 Bearer 头携带的登录会话令牌算不算本人已登录会话」现有两种说法:平台(API Key 管理门)说算;已合入的 changeset 33808-ai-door-confirmation-in-app.md 把「API key or bearer token」列为拒收凭据。值集合取哪套,决定 cloud 门会不会把 split-origin 部署的 Console 用户(会话一律走 Bearer 头)挡在「本人批准自己的待批动作」之外。

    Governing text: ADR-0087 in-app-pending-action-decided-by-person;裁决 6893484458(#33808「B 同一规则,两套流程暂留」);runtime domains/keys.ts 与 core api-key-management-credential.ts(交互会话 = admission.credential === 'session',含 Bearer 携带);spec ExecutionContext.impersonatedBy 描述「ATTRIBUTION ONLY — no security middleware reads it」;AGENTS.md 第 13 条。

    Q1 凭据类型值集合

    选项 做什么 客户可感知后果 工作量
    A 沿用已有三值 session | api_key | oauth:会话(cookie 或 Bearer 携带)= session,API Key = api_key,OAuth 令牌与进程内转发 = oauth;把 runtime 的 AdmittingCredentialKind 搬进 spec 作唯一词表 Console(含 split-origin)用户能在应用内批准自己的待批动作;cloud 门分不出 cookie 与 Bearer M:runtime AI 域 + 一个 spec 新导出,不动 core;33808 changeset 那句「bearer token」读作 OAuth/服务令牌
    B 按载体拆 cookie_session | bearer_session | api_key | oauth cloud 门若拒 Bearer,split-origin Console 用户无法批准自己的动作 约 A 的 3 倍:core 解析器记载体、HttpProtocolContext.admission 改型、keys 门与 API Key 管理规则重判;改变已有「已登录会话」含义,需 ADR 级记录

    Q2(随 Q1 一并确认)impersonatedBy 交给门做判定

    选项 做什么
    A 原样携带:新路由用户类型的描述写明它是门可用来拒绝「只能本人做」的事实、永不是授权主体;ExecutionContext.impersonatedBy 描述不动
    B 先修订 ExecutionContext 描述与其 ADR 记录,再携带

    业务含义直译: Q1-A 是「用 Bearer 头登录的人也是本人」,与平台现有定义一致;Q1-B 是「只认 cookie 登录」,代价是部分部署的 Console 用户批不了自己的单。Q2-A 是「门可以看到是不是管理员在代办」,平台其余部分不变。

    os-decision-facets
    ① 项目长远合理性:A 与平台唯一已有的「本人已登录会话」定义(keys 门)同一答案;B 让 cloud 门与平台对同一句话两种答案,并改动 core 已有语义。
    ② 实际业务拉动:有实测拉动——cloud PR objectstack-ai/cloud#4607(#33809)的待批动作路由今天在读请求头补这两项;Console 每个 dataSource 调用都带 Authorization: Bearer(ui app-shell/src/utils/authToken.ts)。
    ③ 防 AI 犯错:A 一个词表(spec 导出)全平台共用,没有第二套写法;B 多一个载体维度,cloud 与平台各判一次,易写错。
    ④ 创业阶段不扩散:A 一个新导出;B 改 core/runtime/rest 三处并需 ADR。
    Prior rulings read: ruling 6893484458 (#33808); maintainer ruling 2026-08-13 in plugin-auth impersonation-bearer-rotation.ts header (bearer clients keep impersonation); ADR-0087; thread: this card's comments.
    Analysis-tier: seat default (CONTRACT_REVIEW_TIER not used: the maintainer, 2026-11-15T21:53Z, 「fable 不多了」).

    推荐:Q1 选 A,Q2 选 A(卡线程与席位同)。只看①选 A;②③④ 是否翻转:否,四轴同向。新导出名是席位的事,按 A 定为 AIRouteUser + AIRouteCredentialKind(spec contracts/ai-service.ts)。
    裁后执行: 选 A/A ⇒ 本卡回 pm:queue,区 o2-G 认领、原卡线程从零开工(大卡,改 spec 导出,Clause-② 以认领行为准),33808 changeset 的措辞随本卡 PR 改成「OAuth or service token」。选 B ⇒ 席位先立 ADR 卡(Tier H),本卡挂 Blocked-by: 它。Q2 选 B ⇒ 本卡 PR 内同改 ExecutionContext 描述,另立 ADR 注记卡。

  4. added
    needs-user-decision
    and removed
    pm:queue
    on Nov 16, 2026
  5. objectstack-fleet commented on Nov 17, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#2 · os-steve · session_01ADHkmQ2SN4K183oqAvUajA

    2026-11-17T08:29Z Ruled. Steve chose an option on this project's decision card for #34184 at 2026-11-17T08:26:17Z. Option text verbatim: 「全部按推荐」 — 「七张都按上面写的推荐回队开工,#33952 按包取翻译,#34427 只写文档后关卡。」. It answers the seat analysis 6931424442 (this card is one of the seven). Freshness: no comment on this card is newer than that analysis, and the body was not edited after it.

    Ruled: Q1 A · Q2 A

    • Q1 → A: the admitting credential kind stays session | api_key | oauth; a login session carried in a Bearer header counts as session.
    • Q2 → A: the session's impersonatedBy is carried to the gate unchanged; the gate judges it.
  6. added
    pm:queue
    and removed
    needs-user-decision
    on Nov 17, 2026
  7. objectstack-fleet commented on Nov 17, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#2 · os-steve · session_01ADHkmSPLX3Q1ZVi4YC8GKg

    Claim: PM loop round o2-G (card thread)
    Session: session_01ADHkmRfW5u1LRmhWwaYHRp
    Thread session: session_01ADHkmSPLX3Q1ZVi4YC8GKg
    Account: os-steve
    Branch: claude/project-thread-7j2uii
    Worktree: objectstack (the card thread's own checkout)
    Domain: domain:server
    Seat: repo:objectstack#2 · lease:o2-G
    File surface: packages/runtime/src/domains/ai.ts + new packages/runtime/src/domains/ai-request-user-credential.test.ts; packages/runtime/src/security/admitting-credential.ts (its vocabulary re-pointed at the spec export); packages/spec/src/contracts/ai-service.ts (new exports, proposed AIRouteUser + AIRouteCredentialKind, the names the seat analysis 6931424442 set) + the spec generated files they owe (api-surface, export-origins); root .changeset/ (new changeset; the pending 33808-ai-door-confirmation-in-app.md wording "API key or bearer token" → OAuth or service token, as the ruled option A's execution note says, declared as a deliberate correction)
    Container & model: L, mode:thread, model: opus (dispatch-gates --tier at dc66d330: no path-derived mandate, Clause-② suspect surface packages/spec/src/**; contract review routed to the L2 review seat per the maintainer 2026-11-15T21:53Z 「fable 不多了」), effort: high
    Clause-②: yes
    Metadata-protocol: none
    Responsibility: n/a — not a defect card
    Thread-read: 6942875153
    Premise: holds — on origin/main dc66d33 domains/ai.ts builds req.user with actorUserFromExecutionContext(ec, …) and passes neither ec.impersonatedBy (set by core resolve-authz-context.ts:692-721, assembled at assemble-execution-context.ts:387) nor the admitting credential (HttpProtocolContext.admission, read by security/admitting-credential.ts as session | api_key | oauth); the spec has no AI-route user type (dispatcher-plugin.ts:236 handler: (req: any)). Ruled 6942875153: Q1 A, Q2 A.
    Prior rulings read: ruling 6942875153 (this card, Q1 A · Q2 A); seat analysis 6931424442; ruling 6893484458 (#33808); check-prior-rulings.mjs --card 34184 names ADR-0090 D10, ADR-0044 D2, ADR-0045 §6, ADR-0061 D2 on broad terms, none answers this card's question differently
    Serial constraints cleared: not yet measured — the open-PR intersection on domains/ai.ts, security/admitting-credential.ts and contracts/ai-service.ts is read before the first push and reported to area o2-G; no sibling card the triage named

  8. added
    pm:dispatched
    and removed
    pm:queue
    on Nov 17, 2026
  9. objectstack-fleet commented on Nov 17, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#2 · os-steve · session_01ADHkmSPLX3Q1ZVi4YC8GKg
    os-dev-report

    {
      "issue": 34184,
      "status": "done",
      "branch": "claude/project-thread-7j2uii",
      "pr": "https://github.com/objectstack-ai/objectstack/pull/34736",
      "session": "session_01ADHkmSPLX3Q1ZVi4YC8GKg",
      "premise_still_valid": true,
      "summary": "Executes ruling 6942875153 (Q1 A, Q2 A). The spec declares AIRouteUser (EvalUser core + actor-envelope keys + impersonatedBy? + credential?) and AIRouteCredentialKind = session | api_key | oauth in contracts/ai-service.ts; runtime domains/ai.ts builds req.user as AIRouteUser, adding ec.impersonatedBy (trimmed, absent when blank) and admittingCredentialKind(context), whose type now names the spec's. The pending 33808 changeset's FROM line no longer lists a bearer token among refused credentials (DELIBERATE CORRECTION declared in the PR body). Head 30f7347df0.",
      "tests": "New ai-request-user-credential.test.ts, 9 cases (6 through HttpDispatcher.dispatch: cookie session, impersonated session, API key, API key beside impersonated cookie, bearer session, bearer impersonated session; 3 at handleAIRequest: oauth scopes, no admission, blank impersonatedBy). On 30f7347df0 with 4 neighbouring AI/actor files: Test Files 5 passed (5), Tests 145 passed (145). Ablation (ablation-replace --delete of the two spread lines in ai.ts): anchor 1 -> 0, Tests 8 failed | 1 passed (9), restored blob == HEAD d4c61d834758. runtime + spec typecheck: VERDICT command-exit 0.",
      "gates": "dispatch-gates --commands derived 92; all ran (91 exit 0); --ran: 92 derived, 92 run, 0 NOT-MEASURED. Red by design: check-empty-changeset --base origin/main (the 33808 DELIBERATE CORRECTION). check:dual-build-cjs-loads exit 3 then 0 after full build; it, test-source-alias (fixed: module-top import), cross-package-test-inputs, tier-file-adoption, type-check-coverage, nul-bytes, empty-changeset re-run on 30f7347df0. spec check:generated: all 14 up to date. CI on 30f7347df0 at report time: Check Changeset failure (same correction), Lint/Type Check source/consumer/debt, Build Core, Live E2E UI, Governed Surface Queue Guard, PR-body guards success; Test Core, Test UI, Type Check workspace in_progress. File: /mnt/project-files/objectstack-seat2/34184-gates-ran.txt",
      "dogfood_battery": "n/a — no `!` in the PR title and no (narrowing) arm",
      "mcp_calls": "5 — issue_read get, issue_read get_comments, list_pull_requests, pull_request_read get_check_runs, get_job_logs",
      "api_writes": "3 relay strokes — label-write claim (comment 6943289412 + labels_add + labels_remove + assign), pr_create #34736 (+ assignee os-steve), issue_patch #34736 body; plus this report comment",
      "open_questions": [
        { "question": "Contract review owed: PR touches packages/spec/src (new public exports AIRouteUser, AIRouteCredentialKind; Clause-②: yes).", "options": ["route to the L2 review seat at head 30f7347df0"], "recommendation": "L1-c2 + L2 at 30f7347df0, then Tier H via the seat" }
      ],
      "security_findings": "none",
      "out_of_scope_findings": [
        "carrier: none · noted, not filed: AIRouteUser re-declares runtime ActorUser's key set; a key added to ActorUser alone is not caught by the assignment (PR Acceptance notes)",
        "carrier: none · noted, not filed: 'token' wording in the semantic entry in-app-pending-action-decided-by-person, .changeset/34189 and the rejectPendingAction docblock left as is (reads as OAuth/service token under Q1 A)"
      ],
      "deviations": "two read-only gh calls (gh run view --log for the Check Changeset job; gh api pulls/34736 to fetch the live body before issue_patch) where the session rule says gh only for search"
    }
  10. objectstack-fleet commented on Nov 17, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#2 · os-steve · session_01ADHkmRfW5u1LRmhWwaYHRp

    Hand-off · 2026-11-17T12:42Z · repo:objectstack#2 → repo:objectstack#3 (maintainer order 2026-11-17 12:33–12:34Z)

    • PR: feat(spec,runtime): an AI route's req.user carries impersonatedBy and the admitting credential kind #34736 (draft)
    • Current head: 30f7347df0539e8fe0e56fcd21c93c9827e9c9a4, CI 71 check-runs: 56 success, 13 skipped, 2 failed. Both failures are Check Changeset, refusing the edit of the pending .changeset/33808-ai-door-confirmation-in-app.md. That edit is the DELIBERATE CORRECTION the PR body declares (ruling 6942875153, Q1 A); per that gate's text it is confirmed by the dispatching seat's ACCEPT or a same-head at-tier contract-review PASS, never by restoring the base text (final-head comment 6948243919).
    • Records on this head: none. No L1 and no contract review were run before the maintainer stopped reviews (12:34Z). The review#1 request 6948257512 was withdrawn (6948280654).
    • Open items: L1 and contract review are not done, so the DELIBERATE CORRECTION still needs its confirming record. If Version Packages chore: version packages #33849 ships before this lands, the 33808 sentence goes out as it was and the correction becomes a docs-only amend.
    • Next: awaiting review, then approval. It touches packages/spec/src (Clause-②: yes: new AIRouteUser and AIRouteCredentialKind in @objectstack/spec/contracts), so Tier H ①–④ with os-zhuang's approval. Small-flaw rule by maintainer order: when a review leaves only small flaws, the PR may merge first and the flaws go to their own cards; a governed PR still needs os-zhuang's approval.
    • lease:o2-G is removed in this stroke; the assignee and pm:dispatched are left for repo:objectstack#3's takeover claim.
  11. objectstack-fleet commented on Nov 17, 2026

    @objectstack-fleet
    ContributorAuthor

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

    Takeover · #34184 · PR #34736 · 2026-11-17T13:12Z

    Release: claim 6943289412 (session session_01ADHkmRfW5u1LRmhWwaYHRp, thread session session_01ADHkmSPLX3Q1ZVi4YC8GKg, account os-steve), handed over, not abandoned. Provenance: seat 2's maintainer ordered the hand-over on 2026-11-17 at 12:33–12:34Z (quoted in seat 2's mailbox hand-off 6948334887 on #34585: 「L1 L2 不继续审核了,让 3号席位跟进」; completion addendum 6948911954); seat 3's maintainer ruled at 12:44Z in the seat 3 project thread that seat 3 takes every non-security PR seat 2 handed over, merge-first-then-card for nit-level flaws only (「只对 nit 级采用」). The area's hand-off on this card is 6948356800.
    Hand-off record: branch claude/project-thread-7j2uii, last pushed sha 30f7347df0539e8fe0e56fcd21c93c9827e9c9a4 (no L1 or contract review on any head; Check Changeset red on the declared DELIBERATE CORRECTION of .changeset/33808-ai-door-confirmation-in-app.md (ruling 6942875153, Q1 A), which needs the dispatching seat's ACCEPT or a same-head at-tier contract-review PASS).

    Claim: PM loop round 1 (area o3-J, repo:objectstack#3; takeover of an open PR for its review rounds and landing)
    Session: session_01WGufzfr1xZSFZzCR8HnqXX
    Account: os-support-ai
    Branch: claude/project-thread-7j2uii
    Worktree: objectstack-issue-34184
    Domain: domain:server
    Seat: repo:objectstack#3
    File surface: the claimed surface of the released claim as amended (stop on breach; explain in the report)
    Container & model: M, mode:subagent, model: default judgment tier, effort: high
    Clause-②: yes (widening)
    Metadata-protocol: none
    Responsibility: as stated in the released claim
    Thread-read: 6948356800
    Premise: holds (measured at the released claim)
    Serial constraints cleared: overlap-check of 30f7347d against origin/main dfbc316d and #33849 (shares the 33808 changeset): merges cleanly, VERDICT clean exit 0.
    Resume-from: claude/project-thread-7j2uii@30f7347df0539e8fe0e56fcd21c93c9827e9c9a4
    Pre-claim lane: unchanged from the released claim.
    Pre-claim deps: none open.
    Prior rulings read: ruling 6942875153 (Q1 A), as listed in 6943289412.
    Next step: this seat's full L1 on 30f7347d, then the seat's contract review (Clause-②: yes, new AIRouteUser / AIRouteCredentialKind in @objectstack/spec/contracts), whose same-head PASS confirms the changeset correction. check-governed-merges.mjs --pr 34736 reads NOT governed (361 lines). If L1 reads the impersonatedBy carriage as security behaviour, it goes to the seat before anything else.

  12. removed
    pm:dispatched
    on Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

domain:serverenhancementpriority:p2

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions