[Feature] Expose hierarchy and function-type resolution for function-scoped consumers #5

Closed
opened 2026-07-28 18:59:04 +02:00 by zemion · 1 comment
Owner

Outcome

Organizations exposes enough normalized structure for Postbox and other modules to address a function type across organizational units and to evaluate explicitly bounded ancestor/descendant rules without importing organization models.

Existing foundation

organizations.directory already resolves concrete units/functions and can enumerate functions below a unit. Function types and richer hierarchy queries are not yet part of the public Core capability.

Acceptance criteria

  • Add Core-owned refs and capability methods for organization unit types and function types.
  • Resolve concrete functions by function type and unit scope, and units by type/structure scope.
  • Provide tenant-safe batch ancestor/descendant/path resolution with maximum depth and cycle diagnostics.
  • Preserve structure/relation provenance where a tenant has parallel hierarchies; do not assume one universal parent chain for every purpose.
  • Return inactive/missing state explicitly so consumers can explain why an address is unavailable.
  • Emit versioned unit/function/type lifecycle events suitable for directory invalidation.
  • Do not import Postbox or IDM implementations.
  • Tests cover parallel structures, bounded ancestry, moved/deactivated units, function-type matching, and tenant isolation.

Consumer

This is a P1 foundation for function-scoped Postbox templates and bounded parent-copy routing.

## Outcome Organizations exposes enough normalized structure for Postbox and other modules to address a function type across organizational units and to evaluate explicitly bounded ancestor/descendant rules without importing organization models. ## Existing foundation `organizations.directory` already resolves concrete units/functions and can enumerate functions below a unit. Function types and richer hierarchy queries are not yet part of the public Core capability. ## Acceptance criteria - Add Core-owned refs and capability methods for organization unit types and function types. - Resolve concrete functions by function type and unit scope, and units by type/structure scope. - Provide tenant-safe batch ancestor/descendant/path resolution with maximum depth and cycle diagnostics. - Preserve structure/relation provenance where a tenant has parallel hierarchies; do not assume one universal parent chain for every purpose. - Return inactive/missing state explicitly so consumers can explain why an address is unavailable. - Emit versioned unit/function/type lifecycle events suitable for directory invalidation. - Do not import Postbox or IDM implementations. - Tests cover parallel structures, bounded ancestry, moved/deactivated units, function-type matching, and tenant isolation. ## Consumer This is a P1 foundation for function-scoped Postbox templates and bounded parent-copy routing.
Author
Owner

Codex State: done

Summary

  • Added a backward-compatible, Core-owned organizations.hierarchyDirectory capability alongside the existing direct directory contract.
  • Implemented tenant-safe type/function resolution and explicit structure-scoped ancestor, descendant, and path batches with bounded depth, provenance, cycle diagnostics, and inactive/missing state.
  • Organization unit/function/type/structure/relation changes now emit versioned commit-coupled lifecycle events for consumer invalidation.

Changed Files

  • src/govoplan_organizations/backend/directory.py
  • src/govoplan_organizations/backend/api/v1/routes.py
  • src/govoplan_core/core/organizations.py

Verification

  • Organizations hierarchy/lifecycle suite: 5 tests passed; Ruff passed.
  • Affected Core Organizations/IDM compatibility suite: 20 tests passed.

Next / Blocked

  • Postbox #18 can now consume this capability for bounded parent-copy routing.
## Codex State: done ### Summary - Added a backward-compatible, Core-owned organizations.hierarchyDirectory capability alongside the existing direct directory contract. - Implemented tenant-safe type/function resolution and explicit structure-scoped ancestor, descendant, and path batches with bounded depth, provenance, cycle diagnostics, and inactive/missing state. - Organization unit/function/type/structure/relation changes now emit versioned commit-coupled lifecycle events for consumer invalidation. ### Changed Files - `src/govoplan_organizations/backend/directory.py` - `src/govoplan_organizations/backend/api/v1/routes.py` - `src/govoplan_core/core/organizations.py` ### Verification - `Organizations hierarchy/lifecycle suite: 5 tests passed; Ruff passed.` - `Affected Core Organizations/IDM compatibility suite: 20 tests passed.` ### Next / Blocked - Postbox #18 can now consume this capability for bounded parent-copy routing.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: GovOPlaN/govoplan-organizations#5