docs(adr): ADR-0117 记录级业务单元归属(owning business unit)提案 - #4392
Merged
Conversation
为集团管控层补上记录归属的中间一层:部门/法人归属今天是从 owner 推导的 (深度档位编译为 owner_id IN …),带来归属漂移、无所有者数据无归属、 报表无可聚合列三个问题。 决策要点: - owning_business_unit_id 挂靠既有 ownership 轴,新增 business_unit 一档; - 盖章策略 pinned(默认,单据语义)/ follow_owner(CRM)/ transferable; - 不变量 org_id 由 BU 链推导、服务端权威盖章,伪造值覆盖; - 归属变更复用 allowTransfer,且目标 BU 必须在写作用域内; - IHierarchyScopeResolver 改为返回谓词规格(破坏性),解除 OWNER_FIELD 硬编码; - 迁移用回填 + fail-closed 启用门,不做空值回退兼容层; - 开源拥有列与盖章,企业版拥有层级解析。 含五个提交评审的未决问题(法人归属是否物化、新枚举档是否值得、 pinned 默认是否正确、启用门粒度、是否独立权限位)。 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BPXSoZoXtpQecCsQXwMYTK
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BPXSoZoXtpQecCsQXwMYTK
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.
概要
集团管控设计的第一块地基规格:给记录归属补上缺失的中间一层。
今天一条记录只有
owner_id(人)和organization_id(租户墙)两个归属戳,"属于哪个部门 / 哪个法人"是从所有者推导的——层级深度档位最终编译成owner_id IN (…)(plugin-sharing/src/sharing-service.ts:47,151,214)。这带来三个问题:归属漂移(所有者调动,历史单据的部门归属无声跟随)、无所有者语义的数据没有归属(库存、台账)、报表没有可聚合列。决策要点
owning_business_unit_id挂靠既有ownership轴(spec/src/data/object.zod.ts:818),新增business_unit一档;org/none与平台表照现有规则跳过;pinned(默认,单据/凭证语义)/follow_owner(CRM 语义)/transferable;默认值来源为调用方显式值 → 所有者主 BU → 按required决定拒绝或留空;org_id == BU 所属 org,服务端推导、伪造值覆盖(与现有organization_id盖章纪律一致);allowTransfer,且目标 BU 必须落在调用方写作用域内;pinned下策略优先于权限位;IHierarchyScopeResolver.resolveOwnerIds(): Promise<string[]>改为返回"按哪个戳过滤"的谓词规格,解除sharing-service.ts:47的OWNER_FIELD硬编码,并为后续公司轴(organization_id过滤)留出同形位置;ownership为org/none、关闭租户列、以及集团集中管控的配置/主数据对象不注入也不受 BU 轴约束;hierarchySecurity;sys_user.primary_business_unit_id(那是用户属性,不是记录戳)。评审重点(ADR 内含五个未决问题)
ownership: 'business_unit'新档是否值得,还是让这类对象接受一个名义所有者?pinned作为默认值——与平台既有 CRM 形态对象的直觉相反,但对 ERP 类对象更安全;allowChangeOwningUnit而非复用allowTransfer。说明
仅新增一份 ADR 文档,无代码变更。D6 的契约变更需与企业版层级解析器同步发布,实现另行开 PR。
🤖 Generated with Claude Code
https://claude.ai/code/session_01BPXSoZoXtpQecCsQXwMYTK
Generated by Claude Code