SPEC-DDD-GRP Rev 0.3.1 · 2026-08-03

Cane Agency · DDD Seriesสถาบันอ้อย · ชุดเอกสาร DDD

Department Design — Factory Groups (กลุ่มโรงงาน)การออกแบบหน่วยงาน — กลุ่มโรงงาน

Documentเอกสาร
SPEC-DDD-GRP
Versionversion (เวอร์ชัน)
0.3.1
Scopeขอบเขต
grp · factory_group
Surfaceช่องทางใช้งาน
group (group capacity — the thirteenth surfacecapacity group — surface ที่สิบสาม)
Updatedปรับปรุงล่าสุด
2026-08-03
Masterเอกสารหลัก
SPEC-DDD

1. The context1. บริบท

One bounded context — factory_group (กลุ่มโรงงาน) — owning thirteen entities in three layers. It is a derived-read context by design: it consumes facts published by member departments and materializes a read model; it never queries inside a factory live (G4). Its directory entities are authored here but are federation machinery: federation remains the sole identity writer and the sole compiler of the perm claim.

หนึ่งบริบท — factory_group (กลุ่มโรงงาน) — เป็นเจ้าของ 13 entity ในสามชั้น เป็นบริบทแบบอ่านจากผลลัพธ์โดยการออกแบบ: บริโภคข้อเท็จจริงที่หน่วยงานสมาชิกเผยแพร่แล้วสร้าง read model; ไม่เคย query ในโรงงานแบบสด (G4) entity ไดเรกทอรีเขียนไว้ที่นี่แต่เป็นกลไกของ federation: federation ยังเป็นผู้เขียนอัตลักษณ์เพียงผู้เดียวและผู้คอมไพล์ claim perm เพียงผู้เดียว

Neighbourบริบทข้างเคียงRelationshipความสัมพันธ์
books / receivablesUPSTREAM, read-only: member trial balances and fiscal periods are snapshotted into a run. No group posting exists — the group gets no fourth book (PROP-023 unchanged).ต้นน้ำ อ่านอย่างเดียว: งบทดลองและงวดบัญชีของสมาชิกถูก snapshot เข้าการรัน ไม่มีการลงบัญชีระดับกลุ่ม — กลุ่มไม่ได้สมุดเล่มที่สี่ (PROP-023 ไม่เปลี่ยน)
federationPARTNER: the directory layer extends the applied identity model (Department, DirectoryGroup, DirectoryGroupMember, DirectoryGrant + three added columns) and federation compiles every token from it (NFR-15, FR-216).คู่ความร่วมมือ: ชั้นไดเรกทอรีขยาย model อัตลักษณ์ที่ใช้แล้ว (Department, DirectoryGroup, DirectoryGroupMember, DirectoryGrant + สามคอลัมน์ที่เพิ่ม) และ federation คอมไพล์ token ทุกใบจากมัน (NFR-15, FR-216)
platform_opsUPSTREAM: the operator verifies ownership, keeps the group register and suspends a group whose attestation lapses (WF-76, OQ-1).ต้นน้ำ: operator ตรวจความเป็นเจ้าของ ดูแลทะเบียนกลุ่ม และพักกลุ่มที่การยืนยันขาดอายุ (WF-76, OQ-1)
strategic_pricingGUARDED read: aggregated strategic cost only, behind the NFR-21 regulator wall and the str_* family; per-farmer agreement rows only through the keyed, audited FR-221 route (OQ-5).การอ่านที่มีเงื่อนไข: ต้นทุนกลยุทธ์แบบรวมเท่านั้น อยู่หลังกำแพงผู้กำกับ NFR-21 และตระกูล str_*; แถวข้อตกลงรายชาวไร่ผ่านเส้นทาง FR-221 ที่ต้องมีกุญแจและมีบันทึกตรวจสอบเท่านั้น (OQ-5)
fleet_intelligence (plt),GUARDED read: group-scoped fleet exposure only — trucks that delivered to a member mill inside its membership period; no master-level finding about a non-member factory ever crosses (PROP-025 OQ-2, NFR-55).การอ่านที่มีเงื่อนไข: ภาระกองรถขอบเขตกลุ่มเท่านั้น — รถที่ส่งอ้อยให้โรงงานสมาชิกภายในช่วงสมาชิกภาพ; ไม่มีสิ่งที่พบระดับ master เกี่ยวกับโรงงานที่ไม่ใช่สมาชิกข้ามมา (OQ-2 ของ PROP-025, NFR-55)
regulationNO EDGE. The PROP-009 wall is inherited end-to-end: nothing the group sees of strategic cost reaches a government capacity (NFR-21).ไม่มีเส้นเชื่อม กำแพงของ PROP-009 สืบทอดตลอดสาย: สิ่งที่กลุ่มเห็นเรื่องต้นทุนกลยุทธ์ไม่ไปถึง capacity ภาครัฐ (NFR-21)

2. Aggregates & invariants2. Aggregate และกฎคงที่

AggregateaggregateRoot & membersราก และสมาชิกInvariantsกฎคงที่
grp-groupFactoryGroup → GroupMembershipAt most one OPEN membership per mill (FR-197) · a group exists only with a resolved apex (FR-211) · effective dates never reach behind a published statement (G5) · verification precedes any consolidation.หนึ่งโรงงานมีสมาชิกภาพที่เปิดได้ไม่เกินหนึ่ง (FR-197) · กลุ่มมีอยู่ได้เมื่อมียอดควบคุมที่คำนวณได้ (FR-211) · วันมีผลไม่ย้อนหลังงบที่เผยแพร่แล้ว (G5) · การตรวจยืนยันมาก่อนการรวมบัญชีใด ๆ
grp-ownershipDepartment → OwnershipEdgeEvery edge in a control path carries evidence · circular self-holdings excluded from the denominator · control is computed, never asserted · group_type is derived from member topology.ทุกเส้นในเส้นทางควบคุมมีหลักฐาน · ตัดการถือหุ้นวนออกจากตัวหาร · อำนาจควบคุมคำนวณ ไม่ใช่ประกาศ · group_type คำนวณจากโครงสร้างของสมาชิก
grp-consolidationGroupConsolidation → ConsolidationLineImmutable after run · publication blocked while any unmapped line exists · a final run requires every member period closed · identical inputs → byte-identical output (NFR-64) · money baht 2 dp (A-43).เปลี่ยนไม่ได้หลังรัน · การเผยแพร่ถูก block ระหว่างที่ยังมีบรรทัดที่ไม่ได้ map · การรัน final ต้องปิดทุกงวดสมาชิก · ปัจจัยเดิม → ผลเหมือนกันทุก byte (NFR-64) · เงินเป็นบาททศนิยม 2 ตำแหน่ง (A-43)
grp-mappingGroupChartMap · InterCompanyRuleVersioned and dated; a run always names the versions it used · unmatched elimination pairs surface as exceptions, never a silent plug.มีเวอร์ชันและวันที่; การรันระบุเวอร์ชันที่ใช้เสมอ · คู่ตัดรายการที่จับไม่ได้แสดงเป็นข้อยกเว้น ไม่ใช่การอุดเงียบ
fed-directoryDepartment · DirectoryGroup → DirectoryGroupMember · DirectoryGrantThree tiers maximum, a site department has no children · a grant applies only to the department paths it names, with the single built-in inherited administrators group (DR-2) · deny beats allow at any level (DR-3) · non-delegable keys cannot be granted across departments (G2) · every delegated act writes both departments' audit trails (DR-5).สูงสุดสามชั้น หน่วยงานประจำสถานที่ไม่มีลูก · grant มีผลเฉพาะ department path ที่ระบุ ยกเว้นกลุ่มผู้ดูแลที่สืบทอดในตัวหนึ่งกลุ่ม (DR-2) · การปฏิเสธชนะการอนุญาตในทุกชั้น (DR-3) · กุญแจที่มอบไม่ได้ ห้ามมอบข้ามหน่วยงาน (G2) · ทุกการกระทำที่ได้รับมอบเขียนบันทึกตรวจสอบทั้งสองหน่วยงาน (DR-5)

3. Domain events3. เหตุการณ์โดเมน

Eventเหตุการณ์Meaningความหมาย
FactoryGroupVerifiedTwo-act operator verification passed: the group Tenant, its root department and the built-in grp_enterprise_admin group come into being; member admins are notified. Nothing consolidates before this.การตรวจยืนยันสอง act ของ operator ผ่าน: Tenant ของกลุ่ม หน่วยงานราก และกลุ่ม grp_enterprise_admin ในตัว เกิดขึ้น; ผู้ดูแลสมาชิกได้รับแจ้ง ไม่มีการรวมบัญชีก่อนสิ่งนี้
MillAdmittedToGroupA dated membership interval opens and the factory department re-parents under the group root.ช่วงสมาชิกภาพที่มีวันที่เปิดขึ้น และหน่วยงานโรงงานย้ายรากไปใต้รากของกลุ่ม
MillDivestedFromGroupThe interval closes and the department re-parents out to its own single-department tenant root; history stays as held.ช่วงปิดลง และหน่วยงานย้ายออกเป็นรากของ tenant หน่วยงานเดียวของตน; ประวัติคงอยู่ตามที่ถือครอง
GroupConsolidationRunAn immutable run completed with its inputs snapshot, map/rule versions and topology basis.การรันที่เปลี่ยนไม่ได้เสร็จสิ้น พร้อม snapshot ปัจจัยนำเข้า เวอร์ชัน map/กติกา และฐานโครงสร้าง
GroupConsolidationPublishedA run became the group's management statement set — blocked while any unmapped line remains.การรันกลายเป็นชุดงบบริหารของกลุ่ม — ถูก block ระหว่างที่ยังมีบรรทัดที่ไม่ได้ map
GroupDisclosureAcknowledgedA member factory's admin acknowledged the standing group disclosure (FR-207).ผู้ดูแลของโรงงานสมาชิกรับทราบประกาศประจำของกลุ่ม (FR-207)
DepartmentCreated · DepartmentReparentedDirectory lifecycle: the migration backfill and every grouping change. Ledgers, quotas and deliveries never move (DR-6).วงจรไดเรกทอรี: การเติมข้อมูลย้ายและทุกการเปลี่ยนกลุ่ม สมุดบัญชี โควตา และการส่งมอบไม่ย้าย (DR-6)
DirectoryGrantIssued · DirectoryGrantRevokedDelegation lifecycle — two-act at the root, disclosed at the target department, and both invalidate cached tokens (NFR-67).วงจรการมอบอำนาจ — สอง act ที่ราก เปิดเผยที่หน่วยงานเป้าหมาย และทั้งสองทำให้ token ที่ cache ไว้ใช้ไม่ได้ (NFR-67)

4. Ubiquitous language4. ภาษากลางของทีม

TermคำMeaningความหมาย
กลุ่มโรงงาน · factory groupA platform-verified container of mill tenants under common control — and the tenant itself. It administers and reads; it holds no quota, signs no delivery, posts no journal entry.ภาชนะของ tenant โรงงานใต้อำนาจควบคุมเดียวกันที่ platform ตรวจยืนยันแล้ว — และเป็น tenant เอง มันดูแลและอ่าน; ไม่ถือโควตา ไม่ลงนามการส่งมอบ ไม่บันทึกรายการบัญชี
เจ้าของผู้รับประโยชน์สูงสุด · UBOThe natural person or apex entity at the top of the dated ownership graph; where none emerges, the platform declines the group.บุคคลธรรมดาหรือนิติบุคคลยอดสุดของกราฟการถือหุ้นที่มีวันที่; หากไม่มี platform ปฏิเสธการตั้งกลุ่ม
งบบริหารแบบรวม · consolidated management statementThe deterministic read over members' books — map → eliminate → aggregate → present. A management view, never a book of record (OQ-3).การอ่านแบบ deterministic บนสมุดบัญชีของสมาชิก — map → ตัดรายการ → รวม → นำเสนอ เป็นมุมมองบริหาร ไม่ใช่สมุดทางการ (OQ-3)
หน่วยงานประจำสถานที่ · site departmentOne factory inside a tenant directory, 1:1 with the mill Tenant, holding the data that factory produced.โรงงานหนึ่งแห่งภายในไดเรกทอรีของ tenant 1:1 กับ Tenant ของโรงงาน เก็บข้อมูลที่โรงงานนั้นผลิต
กลุ่มไดเรกทอรี · directory groupA named, tenant-owned set of memberships that carries grants over named department paths — the mechanism by which head office holds rights over several factory departments.ชุดสมาชิกภาพที่มีชื่อและ tenant เป็นเจ้าของ ซึ่งถือ grant เหนือ department path ที่ระบุ — กลไกที่สำนักงานใหญ่ถือสิทธิ์เหนือหน่วยงานโรงงานหลายแห่ง
Architecture ruleกติกาสถาปัตยกรรม The group is a read model plus a directory. Two invariants keep it honest: (1) no code path lets a group principal read inside a member tenant except through a recorded, disclosed delegation (NFR-61) — the numbers come from published facts, not live queries (G4); (2) no code path lets a group principal transact — transactional keys are not delegable and a factory's four-eyes chains never accept a root grant as a signature (G2, OQ-15). กลุ่มคือ read model บวกไดเรกทอรี กฎคงที่สองข้อทำให้มันซื่อตรง: (1) ไม่มีเส้นทาง code ใดให้ principal ของกลุ่มอ่านใน tenant สมาชิก เว้นผ่านการมอบอำนาจที่บันทึกและเปิดเผย (NFR-61) — ตัวเลขมาจากข้อเท็จจริงที่เผยแพร่ ไม่ใช่ query สด (G4); (2) ไม่มีเส้นทาง code ใดให้ principal ของกลุ่มทำรายการ — กุญแจเชิงรายการมอบไม่ได้ และสายอนุมัติสี่ตาของโรงงานไม่รับ grant จากรากเป็นลายมือชื่อ (G2, OQ-15)

Related documentsเอกสารที่เกี่ยวข้อง

Revision historyประวัติการแก้ไข

RevฉบับDateวันที่Changeการเปลี่ยนแปลง
0.1.02026-07-25Created by PROP-026 (spec v0.25.0, accepted & applied 25 Jul 2026; all 17 open questions client-decided) — the GRP market perspective family opens with six documents. Rev starts at 0.1.0 per the post-PROP-014 semantic-versioning convention.สร้างโดย PROP-026 (spec v0.25.0 รับและ apply 25 ก.ค. 2569; ลูกค้าตัดสินคำถามเปิดครบทั้ง 17 ข้อ) — ตระกูล perspective ฝั่งตลาด GRP เปิดพร้อมเอกสารหกฉบับ เริ่ม rev ที่ 0.1.0 ตามธรรมเนียม semantic versioning หลัง PROP-014
0.2.02026-08-03PROP-075 approved & applied — spec v0.46.0. The group’s three layers survive intact; only the noun in the legal layer changes. LegalEntity becomes a legally-classified Department homed in the federation context, and the ownership graph joins departments — which is emphatically NOT the parent_department_id tree (R-NOTCAPTABLE). The control test, apex rule, GroupChartMap, InterCompanyRule and consolidation model are untouched, and PROP-026 OQ-14’s three-tier cap is withdrawn (R-DEPTH).PROP-075 อนุมัติและ apply — spec v0.46.0 ชั้นกฎหมายของกลุ่มเปลี่ยนคำนามเป็น Department แต่กลไกกลุ่มไม่ถูกกลับ
0.3.02026-08-03PROP-073 (spec v0.47.0): one word — Tenant. Party → Tenant, party_id (and every prefixed form) → tenant_id, PartyCapacity/PartyQualification/PartyFounded → Tenant*, party context/switcher → tenant context/switcher, cross-party → cross-tenant, organisation → organization, and ผู้เล่น retired as the Thai gloss (the Latin word tenant instead, R-THAI). Hold list untouched: counterparty · third party · tripartite working group · Person*/person_id; display codes and token claims were held by R-NULL for one release and then MOVED at v0.47.1 on client decision (C-1), because no token has ever been SIGNED — no auth exists in the built ocsb/ocsf prototypes — and the only printed codes were eight fixture strings in apps/ocsf/fund-shell.jsx, swept in the same pass: PTY- → TNT-, TCA- → TCA-, TQL- → TQL-, claim tnt → tnt, claim dep → dep. Carried in the same pass: the PROP-075 rectification — the retired directory noun domain becomes department (A-82 R-ONETREE) and the dangling A-86/A-87/A-88 citations are re-pointed at the ids they were actually given, A-81/A-82/A-83.PROP-073 (spec v0.47.0): คำเดียว — Tenant Party → Tenant, party_id ทุกรูป → tenant_id, PartyCapacity/PartyQualification/PartyFounded → Tenant*, cross-party → cross-tenant และเลิกใช้ ผู้เล่น เป็นคำแทนวัตถุนี้ในภาษาไทย (ใช้คำละติน tenant ตาม R-THAI) รายการห้ามแตะไม่ถูกแตะ: คู่สัญญา · third party · คณะทำงานไตรภาคี · Person*/person_id รอบเดียวกันแก้ค้างจาก PROP-075: domain → department (A-82) และแก้การอ้าง A-86/A-87/A-88 ที่ไม่มีอยู่จริงเป็น A-81/A-82/A-83
0.3.12026-08-03PROP-073 PATCH 1 (spec v0.47.1 / v0.47.2 / v0.47.3 as applicable): the identifiers v0.47.0 had held, moved on client decision. PTY-######## → TNT-######## · PCA-######## → TCA-######## · PQL-######## → TQL-######## · token claim pty → tnt · token claim dom → dep (v0.47.1, C-1 — R-NULL had held them as a stored VALUE and a wire format; reversed because no token has ever been signed and the only printed codes were fixture strings). quota_org_officer → quota_officer · lead_org_officer → lead_officer (v0.47.2, C-2 — org is organization abbreviated, not a resemblance). The retired role LABEL swept as a phrase family and quota organization naming the tenant → quota group / กลุ่มโควตา (v0.47.3). All retired forms are in the FR-396 crosswalk and refused in new text by NFR-142.PROP-073 PATCH 1 (spec v0.47.1 / v0.47.2 / v0.47.3 ตามที่เกี่ยวข้อง): ตัวระบุที่ v0.47.0 คงไว้ ถูกย้ายตามการตัดสินของลูกค้า PTY- → TNT- · PCA- → TCA- · PQL- → TQL- · claim pty → tnt · claim dom → dep (v0.47.1, C-1) · quota_org_officer → quota_officer · lead_org_officer → lead_officer (v0.47.2, C-2) · ป้ายชื่อบทบาทที่เลิกใช้และ องค์กรโควตา ที่เรียก tenant → กลุ่มโควตา (v0.47.3) ทุกรูปที่เลิกใช้อยู่ในตารางแปลง FR-396