feat(approvals): add 'position' approver type resolved via sys_user_position (ADR-0090 D3) - #2738
Merged
Merged
Conversation
…osition (ADR-0090 D3)
Post ADR-0090 D3 the 'role' approver type resolves against the better-auth
org-membership tier (sys_member.role: owner/admin/member) — it was never a
position, so downstream apps authoring { type: 'role', value: 'sales_manager' }
silently routed approvals to nobody.
- spec: ApproverType gains 'position' (value = position machine name); the
xRef picker map and value description follow. 'role' is documented as the
membership tier it actually is.
- plugin-approvals: expandApprovers resolves 'position' via sys_user_position
∪ the sys_member.role transition source (ADR-0057 D4), mirroring
PositionGraphService in plugin-sharing; the spec value 'department' is now
honored alongside the pre-existing business_unit/bu dialect.
- lint: new validateApprovalApprovers rule — approval-role-not-membership-tier
warns when a role approver's value is not a membership tier and prescribes
the position rewrite; approval-approver-type-unknown flags off-spec approver
types with a business_unit→department fix-it. Wired into os lint.
- docs/skill/showcase: approver examples switch to { type: 'position' }; the
authoring skill's Approver Types table and the approvals guide call the
trap out explicitly.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DgP1vEK6nrkkvnwQxCPGbe
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
📓 Docs Drift CheckThis PR changes 4 package(s): 97 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:
|
os-zhuang
marked this pull request as ready for review
July 10, 2026 04:45
This was referenced Jul 10, 2026
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.
问题
ADR-0090 D3 之后,审批的
roleapprover type 实际解析的是 better-auth 的组织成员级别(sys_member.role:owner/admin/member),而不是岗位。下游应用(如 hotcrm)写的{ type: 'role', value: 'sales_manager' }会静默匹配不到任何人——展开落空后回退成role:sales_manager字面量,审批请求永远停在一个不可能行动的 approver 上。规范里没有任何方式把审批路由到一个岗位。方案
spec(
packages/spec/src/automation/approval.zod.ts)ApproverType新增'position':value= 岗位 machine name,经sys_user_position展开;role的注释/描述改为它实际的语义(membership tier),xRef picker map 增加position映射。plugin-approvals(
approval-service.ts)expandApprovers新增position分支:sys_user_position∪sys_member.role过渡源(ADR-0057 D4),与 plugin-sharing 的PositionGraphService语义完全一致——同一个岗位,审批路由到的人 = 共享引擎展开的人;department之前在运行时只匹配 off-spec 的business_unit/bu方言,现在按规范拼写也能解析(方言分支保留,属既有债务)。lint(新规则
validateApprovalApprovers,已接入os lint)approval-role-not-membership-tier(warning):roleapprover 的 value 不是 membership tier(owner/admin/member/guest)时告警,fix-it 直接给出{ type: 'position', ... }改写;approval-approver-type-unknown(warning):off-spec 的 approver type(含business_unit→department的 fix-it)。文档 / skill / showcase
content/docs/automation/approvals.mdx增加positionvsrole的 Callout;approvals/flows 文档、objectstack-automationSKILL(含 Approver Types 表)、showcase 示例里所有把岗位名写成type: 'role'的示例全部改为type: 'position'(正是本 PR 要消灭的教学陷阱);content/docs/references/automation/approval.mdx由gen:docs再生成。测试
@objectstack/spec、@objectstack/lint、@objectstack/plugin-approvals、@objectstack/cli测试全绿(spec 6672 tests;新增 position 展开/租户隔离/过渡源并集/字面量回退、department 拼写、lint 规则 6 个用例);check:skill-docs同步检查通过;已附 changeset(spec/plugin-approvals/lint minor,cli patch)。
🤖 Generated with Claude Code
https://claude.ai/code/session_01DgP1vEK6nrkkvnwQxCPGbe
Generated by Claude Code