Organisation¶
Company structure facades: company, departments, teams, and role versions.
Enums¶
enums
¶
Models¶
models
¶
Organization-layer domain models.
Holds the input models for company, department, and agent mutations so
the organization service layer can validate the same input shapes
without importing from the API layer. The synthorg.api.dto_org
module re-exports these for HTTP controllers.
UpdateCompanyRequest
pydantic-model
¶
Bases: BaseModel
Partial update for company-level settings.
Lives in the organization domain layer so the service can
validate input without importing from synthorg.api.dto_org.
Config:
frozen:Trueallow_inf_nan:Falseextra:forbid
Fields:
-
company_name(NotBlankStr | None) -
autonomy_level(AutonomyLevel | None) -
budget_monthly(float | None) -
communication_pattern(NotBlankStr | None)
autonomy_level
pydantic-field
¶
Org-wide autonomy level (full, semi, supervised, locked).
budget_monthly
pydantic-field
¶
Monthly budget cap for the company in the operator's configured currency; set to 0 to disable enforcement.
communication_pattern
pydantic-field
¶
Communication strategy or pattern identifier.
CreateDepartmentRequest
pydantic-model
¶
Bases: BaseModel
Request body for creating a new department.
Config:
frozen:Trueallow_inf_nan:Falseextra:forbid
Fields:
-
name(NotBlankStr) -
head(NotBlankStr | None) -
budget_percent(float) -
autonomy_level(AutonomyLevel | None)
UpdateDepartmentRequest
pydantic-model
¶
Bases: BaseModel
Partial update for an existing department.
Config:
frozen:Trueallow_inf_nan:Falseextra:forbid
Fields:
-
head(NotBlankStr | None) -
budget_percent(float | None) -
autonomy_level(AutonomyLevel | None) -
teams(tuple[Team, ...] | None) -
ceremony_policy(dict[str, object] | None)
Validators:
-
_validate_ceremony_policy→ceremony_policy
ReorderDepartmentsRequest
pydantic-model
¶
Bases: BaseModel
Reorder departments -- must be an exact permutation.
Config:
frozen:Trueallow_inf_nan:Falseextra:forbid
Fields:
-
department_names(tuple[NotBlankStr, ...])
CreateAgentOrgRequest
pydantic-model
¶
Bases: BaseModel
Request body for creating a new agent in the org config.
Config:
frozen:Trueallow_inf_nan:Falseextra:forbid
Fields:
-
name(NotBlankStr) -
role(NotBlankStr) -
department(NotBlankStr) -
level(SeniorityLevel) -
model_provider(NotBlankStr | None) -
model_id(NotBlankStr | None)
Validators:
-
_validate_model_pair
UpdateAgentOrgRequest
pydantic-model
¶
Bases: BaseModel
Partial update for an existing agent in the org config.
Config:
frozen:Trueallow_inf_nan:Falseextra:forbid
Fields:
-
name(NotBlankStr | None) -
role(NotBlankStr | None) -
department(NotBlankStr | None) -
level(SeniorityLevel | None) -
autonomy_level(AutonomyLevel | None) -
model_provider(NotBlankStr | None) -
model_id(NotBlankStr | None)
Validators:
-
_validate_model_pair
ReorderAgentsRequest
pydantic-model
¶
Bases: BaseModel
Reorder agents within a department -- must be an exact permutation.
Config:
frozen:Trueallow_inf_nan:Falseextra:forbid
Fields:
-
agent_names(tuple[NotBlankStr, ...])
Services¶
services
¶
Organization facades for the MCP handler layer.
Company read/versions, department CRUD + health, team CRUD, and
role-version history. Writes route through org_mutation_service
where it already owns the flow; other paths use in-memory stores until
durable repositories land.
The file-level EM101 suppression is intentional: every capability
gap in this module raises :class:CapabilityNotSupportedError from a
short identifier and operator-readable reason, both string literals by
design so capability telemetry (logged via
:data:MCP_HANDLER_CAPABILITY_GAP) has a stable, grep-able message.
Hoisting them to msg = ... locals would obscure the one-line intent
with no runtime benefit.
UnsetType
¶
Sentinel type for "field not provided" distinct from None.
Used by update operations where None is a legitimate value the
caller may want to persist (e.g. clearing a department_id) and
must be distinguished from "leave this field unchanged".
CompanyReadService
¶
Read + light mutation facade over the company/org surface.
Source code in src/synthorg/organization/services.py
get_company
async
¶
Return the company snapshot or raise if the capability is missing.
Raises:
| Type | Description |
|---|---|
CapabilityNotSupportedError
|
When the wired
|
Source code in src/synthorg/organization/services.py
update_company
async
¶
Apply a partial company-settings update.
The payload is validated against :class:UpdateCompanyRequest
here so unknown keys are rejected before reaching the mutation
service. The call then matches the target signature
update_company(data, *, saved_by=...) -- actor_id is
recorded as saved_by in the persisted snapshot.
Returns:
| Type | Description |
|---|---|
object
|
The updated company snapshot returned by the mutation service. |
Raises:
| Type | Description |
|---|---|
CapabilityNotSupportedError
|
When |
Source code in src/synthorg/organization/services.py
list_departments
async
¶
Return the company's departments.
Raises:
| Type | Description |
|---|---|
CapabilityNotSupportedError
|
When |
Source code in src/synthorg/organization/services.py
reorder_departments
async
¶
Apply a new department ordering, auditing the change.
Raises:
| Type | Description |
|---|---|
CapabilityNotSupportedError
|
When |
Source code in src/synthorg/organization/services.py
list_versions
async
¶
Return all company-snapshot versions.
Raises:
| Type | Description |
|---|---|
CapabilityNotSupportedError
|
When |
Source code in src/synthorg/organization/services.py
get_version
async
¶
Fetch a single company-snapshot version by id.
Returns:
| Type | Description |
|---|---|
object | None
|
The matching company-snapshot version, or |
object | None
|
version has that id. |
Raises:
| Type | Description |
|---|---|
CapabilityNotSupportedError
|
When |
Source code in src/synthorg/organization/services.py
DepartmentService
¶
Department CRUD + health.
Mutations are serialised through a single :class:asyncio.Lock so
concurrent MCP handler calls cannot race on the in-memory dict
(check-then-act in :meth:update_department and
:meth:delete_department).
Source code in src/synthorg/organization/services.py
list_departments
async
¶
Return paginated departments newest-first plus unfiltered total.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
offset
|
int
|
Non-negative page offset. |
0
|
limit
|
int | None
|
Optional positive page size; |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/synthorg/organization/services.py
get_department
async
¶
Fetch a single department by UUID or None if not found.
Returns:
| Type | Description |
|---|---|
_DepartmentRecord | None
|
A deep copy of the stored department, or |
_DepartmentRecord | None
|
is malformed or no such department exists. |
Source code in src/synthorg/organization/services.py
create_department
async
¶
Create a department, auditing the event on success.
Returns:
| Type | Description |
|---|---|
_DepartmentRecord
|
A deep copy of the newly created department record. |
Source code in src/synthorg/organization/services.py
update_department
async
¶
Patch a department's name / description in place.
Returns:
| Type | Description |
|---|---|
_DepartmentRecord | None
|
A deep copy of the updated department, or |
_DepartmentRecord | None
|
is malformed or no such department exists. |
Source code in src/synthorg/organization/services.py
delete_department
async
¶
Remove a department; emit the audit event only on real removal.
Returns:
| Type | Description |
|---|---|
bool
|
|
bool
|
is malformed or no such department exists. |
Source code in src/synthorg/organization/services.py
get_health
async
¶
Return a summary health payload for the department.
Source code in src/synthorg/organization/services.py
TeamService
¶
Team CRUD.
Mutations are serialised through a single :class:asyncio.Lock so
concurrent MCP handler calls cannot race on the in-memory dict.
Source code in src/synthorg/organization/services.py
list_teams
async
¶
Return paginated teams newest-first plus unfiltered total.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
offset
|
int
|
Non-negative page offset. |
0
|
limit
|
int | None
|
Optional positive page size; |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/synthorg/organization/services.py
get_team
async
¶
Fetch a single team by UUID or None if not found.
Returns:
| Type | Description |
|---|---|
_TeamRecord | None
|
A deep copy of the stored team, or |
_TeamRecord | None
|
malformed or no such team exists. |
Source code in src/synthorg/organization/services.py
create_team
async
¶
Create a team, auditing the event on success.
Returns:
| Type | Description |
|---|---|
_TeamRecord
|
A deep copy of the newly created team record. |
Source code in src/synthorg/organization/services.py
update_team
async
¶
Update a team; department_id=None clears the field.
The default department_id=UNSET sentinel means "leave
unchanged"; pass department_id=None explicitly to clear a
team's department assignment.
Returns:
| Type | Description |
|---|---|
_TeamRecord | None
|
A deep copy of the updated team, or |
_TeamRecord | None
|
malformed or no such team exists. |
Source code in src/synthorg/organization/services.py
delete_team
async
¶
Remove a team; emit the audit event only on real removal.
Returns:
| Type | Description |
|---|---|
bool
|
|
bool
|
malformed or no such team exists. |
Source code in src/synthorg/organization/services.py
RoleVersionService
¶
Read facade for the role-version snapshot history.
Source code in src/synthorg/organization/services.py
list_versions
async
¶
Return role-snapshot versions, optionally filtered by role name.
Raises:
| Type | Description |
|---|---|
CapabilityNotSupportedError
|
When no |
Source code in src/synthorg/organization/services.py
get_version
async
¶
Fetch a single role-snapshot version by id.
Returns:
| Type | Description |
|---|---|
object | None
|
The matching role-snapshot version, or |
object | None
|
version has that id. |
Raises:
| Type | Description |
|---|---|
CapabilityNotSupportedError
|
When no |