fix(runtime): dispatcher 面 /share-links 整体透传 ExecutionContext 给 enforcement (#6551) - #6647
Merged
os-project-manager merged 3 commits intoAug 8, 2026
Merged
Conversation
…xt to enforcement (#6551) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017uFVNMmTxLpmfQYiuKM1Yx
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017uFVNMmTxLpmfQYiuKM1Yx
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017uFVNMmTxLpmfQYiuKM1Yx
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Contributor
📓 Docs Drift CheckThis PR changes 1 package(s): 21 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:
|
os-project-manager
marked this pull request as ready for review
August 8, 2026 08:50
os-project-manager
deleted the
claude/issue-6551-sharelinks-full-envelope
branch
August 8, 2026 09:13
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #6551
缺陷
packages/runtime/src/domains/share-links.ts在 dispatcher 面(cloud 每环境 kernel 的设计主面,registerShareLinkRoutes: false时的唯一入口)把已解析完整的ExecutionContext重新裁成{ userId, tenantId }两个字段,再喂给三个裁决方法(createLink/listLinks/revokeLink)。按 #6511 契约,这三个方法的 context 形参是完整ExecutionContext,TSDoc 写明调用方 MUST NOT rebuild a subset;结构化子类型让两字段对象照样编译通过,tsc 报不了。这是 #6206(plugin-sharing 面,PR #6552)同一条 enforcement 路径的另一张脸,两处互不覆盖。前提已在当前
origin/main(e39dd66e7)复核:裁剪在share-links.ts:77-78,消费点:217(create)/:237(list)/:244(revoke),401 判定:199。修法(与 #6552 同形)
不再重建
callerCtx:const ec = context.executionContext,三个裁决调用整体透传ec;路由自己的 401 判定只读ec?.userId(鉴别"是否登录"不需要授权信封,#6552 的isAuthenticated同理)。dispatcher 侧resolveExecutionContext产出的信封本身已带isSystem: false,不需要 #6552 那样的{ ...authz, isSystem: false }重组——无 cargo-cult 字段。实现面仅share-links.ts一个文件(同时删掉了旧的ec: any,svc是契约类型,透传处由 tsc 实际检查)。复现与测试(
packages/runtime/src/domains/share-links-enforcement-context.test.ts)真实件:
handleShareLinksRequest(被测的产线入口)、@objectstack/plugin-sharing的真ShareLinkService([Finding-2] 可见性读)、@objectstack/plugin-security的整个SecurityPlugin中间件(照该包自己的vama-write-path-convergence.test.ts样板起真件,tenancy 姿态经产线路径tenancy服务下发;Layer 0 墙与 Layer 1 RLS 都是产线裁决,不是重实现)。双件:仅存储(内存表;写动词以生产方的assertEngineUpdateDispatch/assertEngineDeleteDispatch开门)。错误信封用 runtime 真的apiErrorResponse构造,error.code/status 断言对着 ADR-0112 真形状。group姿态(accessible_org_ids支,同族第三处组装:share-link 路由把授权信封裁成 4 个字段后直接当 enforcement context 喂给 engine.find ——group租户姿态下 Layer 0 墙恒判否 #6206 已证族内机制):调用者是记录属主、记录在其成员组织 → 201(修前 403,见反向验证);组织外记录仍 403 FORBIDDEN(墙活着,不是被绕过);MOAC 并集 201;显式删掉accessible_org_ids的信封仍 403(ADR-0105 D2 fail closed——此条修前修后同判,测试内注明不作为修复 pin,它 pin 的是"修的是信封,不是权限")。single姿态(positions/permissions支——issue 标注"未复现"的那半):只有通过 position 绑定的 permission set(east_viewer,applicabilitypositions: ['pos_east'],ADR-0090 P2)才可见的同事记录 → 完整信封 201;仅基线集(截断退化到的状态,additive fallback)403 FORBIDDEN。该半边已复现并 pin 住。测试放在 runtime 自己的测试树(派发单默认位置;未动用扩展 plugin-security 测试文件的预授权)。为此给
packages/runtime加了 devDependency@objectstack/plugin-sharing(sharing 不依赖 runtime,直接或传递均无环;plugin-security 本来就是 runtime 生产依赖)。未动packages/plugins/plugin-sharing、packages/spec、resolve-execution-context.ts。反向验证(预测先于测量,记录于 scratchpad)
工作树临时恢复两字段截断重跑本测试文件,预测:4 红(group 属主 201→403 FORBIDDEN、MOAC 201→403、single position 支 201→403、缝 pin 点名 9 个被丢 key)+ 4 绿(组织外 403、显式缺 set 403、基线控制 403、401——修前修后同判,如实排除在修复 pin 之外)。实测与预测逐条一致:
4 failed | 4 passed,三个建链例expected 403 to be 201,缝 pin 红为dropped/altered keys: expected [ 'email', 'isSystem', …(7) ] to deeply equal [](9 个被丢 key)。方向为常规"红"类,无 #5009 式反转。恢复修复后 8/8 绿。本地验证
pnpm --filter @objectstack/runtime test:112 文件 / 1619 用例全绿(含新文件 8/8)。pnpm --filter @objectstack/runtime typecheck:通过。pnpm lint:通过。check:*门:32 个根门 + spec 全套(check:generated --reconcile-only/authorable-surface/docs/api-surface/dual-source-exports/exported-any/skill-*/spec-changes/upgrade-guide/react-blocks/ spec tsc)+check:i18n/check:i18n-coverage/check:type-check-coverage/check:driver-conformance/check:stall-guard/check:doc-formula-expressions/ downstream-contract 与 examples typecheck 全部 PASS(check:type-check-debt在全量构建后复跑,结果见 PR 评论/报告)。变更集
@objectstack/runtimepatch:dispatcher 面授权判定结果改变(group姿态下对可读记录建链 403→201、position 绑定可见性恢复),用户可见。🤖 Generated with Claude Code
https://claude.ai/code/session_017uFVNMmTxLpmfQYiuKM1Yx
Generated by Claude Code