Skip to content

feat: add department policies to default templates#852

Merged
Aureliolo merged 3 commits intomainfrom
feat/department-policies-templates
Mar 26, 2026
Merged

feat: add department policies to default templates#852
Aureliolo merged 3 commits intomainfrom
feat/department-policies-templates

Conversation

@Aureliolo
Copy link
Copy Markdown
Owner

Summary

  • Add realistic policies (review requirements and approval chains) to 4 built-in templates with 3+ departments: dev_shop, product_team, agency, full_company
  • Map issue shorthand (code_review_required, test_coverage_required, etc.) to the existing DepartmentPolicies schema (review_requirements + approval_chains)
  • Add 11 unit tests in a dedicated test_department_policies.py file with parametrized engineering review requirements, module-scoped fixtures, and helper functions
  • Document policies field in docs/design/organization.md (field list, YAML example, template structure comment)

Policy summary

Template Department Policy
dev_shop engineering review_requirements.min_reviewers: 1
dev_shop quality_assurance approval_chains: [test_coverage]
product_team engineering review_requirements.min_reviewers: 1
product_team design approval_chains: [design_review]
agency engineering review_requirements.min_reviewers: 1
agency operations approval_chains: [client_approval]
full_company engineering review_requirements.min_reviewers: 2 + approval_chains: [code_review -> Software Architect, CTO]
full_company security approval_chains: [security_review -> Security Engineer, CTO]
full_company operations approval_chains: [change_management -> COO]

Test plan

  • All 11 new policy tests pass (test_department_policies.py)
  • All 309 template tests pass
  • Full unit suite passes (10713 tests)
  • mypy clean
  • ruff clean
  • Pre-reviewed by 4 agents (docs-consistency, test-quality, conventions, issue-verifier), 8 findings addressed

Closes #723

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 26, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 0326770c-d36d-4e65-b5aa-9a71a779b1a8

📥 Commits

Reviewing files that changed from the base of the PR and between d4ce7f3 and 0a536c1.

📒 Files selected for processing (6)
  • docs/design/organization.md
  • src/synthorg/templates/builtins/agency.yaml
  • src/synthorg/templates/builtins/dev_shop.yaml
  • src/synthorg/templates/builtins/full_company.yaml
  • src/synthorg/templates/builtins/product_team.yaml
  • tests/unit/templates/test_department_policies.py
📜 Recent review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: Build Web
  • GitHub Check: Build Backend
  • GitHub Check: Build Sandbox
  • GitHub Check: Test (Python 3.14)
  • GitHub Check: Dependency Review
  • GitHub Check: Analyze (python)
🧰 Additional context used
📓 Path-based instructions (4)
docs/design/**/*.md

📄 CodeRabbit inference engine (CLAUDE.md)

docs/design/**/*.md: ALWAYS read the relevant docs/design/ page before implementing any feature or planning any issue. The design spec is the starting point for architecture, data models, and behavior.
If implementation deviates from the spec (better approach found, scope evolved, etc.), alert the user and explain why - user decides whether to proceed or update the spec. Do NOT silently diverge - every deviation needs explicit user approval.
When approved deviations occur, update the relevant docs/design/ page to reflect the new reality.

Files:

  • docs/design/organization.md
**/*

📄 CodeRabbit inference engine (CLAUDE.md)

NEVER use 'cd' in Bash commands - the working directory is already set to the project root. Use absolute paths or run commands directly. Do NOT prefix commands with 'cd C:/Users/Aurelio/synthorg &&'.

Files:

  • docs/design/organization.md
  • src/synthorg/templates/builtins/agency.yaml
  • src/synthorg/templates/builtins/dev_shop.yaml
  • tests/unit/templates/test_department_policies.py
  • src/synthorg/templates/builtins/full_company.yaml
  • src/synthorg/templates/builtins/product_team.yaml
**/*.md

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.md: Every implementation plan must be presented to the user for accept/deny before coding starts. At every phase of planning and implementation, be critical - actively look for ways to improve the design in the spirit of what we're building (robustness, correctness, simplicity, future-proofing). Surface improvements as suggestions, not silent changes - user decides.
Prioritize issues by dependency order, not priority labels - unblocked dependencies come first.

Files:

  • docs/design/organization.md
tests/**/*.py

📄 CodeRabbit inference engine (CLAUDE.md)

tests/**/*.py: Mark all tests with @pytest.mark.unit, @pytest.mark.integration, @pytest.mark.e2e, or @pytest.mark.slow markers.
Maintain 80% minimum code coverage - enforced in CI.
asyncio_mode = "auto" is configured - no manual @pytest.mark.asyncio needed. Global timeout is 30 seconds per test in pyproject.toml - do not add per-file pytest.mark.timeout(30) markers; non-default overrides like timeout(60) are allowed.
Always run pytest with '-n auto' for parallelism via pytest-xdist - never run tests sequentially.
Prefer @pytest.mark.parametrize for testing similar cases.
NEVER use real vendor names (Anthropic, OpenAI, Claude, GPT, etc.) in project-owned code, docstrings, comments, tests, or config examples. Use generic names: example-provider, example-large-001, example-medium-001, example-small-001, large/medium/small as aliases. Tests must use test-provider, test-small-001, etc.
For timing-sensitive tests, mock time.monotonic() and asyncio.sleep() to make them deterministic instead of widening timing margins. For tasks that must block indefinitely until cancelled, use asyncio.Event().wait() instead of asyncio.sleep(large_number) - it is cancellation-safe and carries no timing assumptions. NEVER skip, dismiss, or ignore flaky tests - always fix them fully and fundamentally.
Use Hypothesis for property-based testing with @given + @settings. Hypothesis profiles: ci (50 examples, default) and dev (1000 examples), controlled via HYPOTHESIS_PROFILE env var.

Files:

  • tests/unit/templates/test_department_policies.py
🧠 Learnings (3)
📚 Learning: 2026-03-19T07:13:44.964Z
Learnt from: CR
Repo: Aureliolo/synthorg PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-19T07:13:44.964Z
Learning: Applies to src/synthorg/budget/**/*.py : Budget package (budget/): cost tracking, budget enforcement (pre-flight/in-flight checks, auto-downgrade), billing periods, cost tiers, quota/subscription tracking, CFO cost optimization (anomaly detection, efficiency analysis, downgrade recommendations, approval decisions), spending reports, budget errors (BudgetExhaustedError, DailyLimitExceededError, QuotaExhaustedError)

Applied to files:

  • docs/design/organization.md
📚 Learning: 2026-03-19T07:12:14.508Z
Learnt from: CR
Repo: Aureliolo/synthorg PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-19T07:12:14.508Z
Learning: Applies to src/synthorg/security/**/*.py : Security package (security/): SecOps agent, rule engine (soft-allow/hard-deny, fail-closed), audit log, output scanner, output scan response policies (redact/withhold/log-only/autonomy-tiered), risk classifier, risk tier classifier, action type registry, ToolInvoker security integration, progressive trust (4 strategies), autonomy levels (presets, resolver, change strategy), timeout policies (park/resume)

Applied to files:

  • src/synthorg/templates/builtins/full_company.yaml
📚 Learning: 2026-03-17T06:30:14.180Z
Learnt from: CR
Repo: Aureliolo/synthorg PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-17T06:30:14.180Z
Learning: Applies to src/synthorg/security/**/*.py : Security module includes SecOps agent, rule engine (soft-allow/hard-deny), audit log, output scanner, risk classifier, autonomy levels (4 strategies), timeout policies.

Applied to files:

  • src/synthorg/templates/builtins/full_company.yaml
🔇 Additional comments (13)
src/synthorg/templates/builtins/product_team.yaml (2)

46-48: Policy structure for engineering is correctly wired.

review_requirements.min_reviewers is valid and aligns with the intended template behavior.


63-67: Design approval chain looks correct.

The design_review chain and approver role are consistent with the template’s department/agent definitions.

src/synthorg/templates/builtins/agency.yaml (2)

42-46: Operations client-approval policy is well defined.

Action type and approver assignment are consistent and valid.


56-58: Engineering review requirement is correctly configured.

The policy block is schema-compatible and aligns with the expected reviewer threshold.

docs/design/organization.md (3)

109-114: Department policy YAML example is clear and aligned with implementation.

Good addition for discoverability of review_requirements and approval_chains.


161-161: Default policy semantics are documented accurately.

The stated defaults match runtime behavior when policies is omitted.


187-187: Template-structure note update is appropriate.

Nice small sync so the simplified skeleton no longer under-documents department policies.

src/synthorg/templates/builtins/dev_shop.yaml (2)

41-43: Engineering review policy is correctly added.

This is valid and consistent with the intended default template behavior.


59-63: QA test-coverage approval chain is correctly modeled.

The policy payload is consistent with department ownership and role definitions.

tests/unit/templates/test_department_policies.py (1)

42-106: Test coverage for new department policies is solid.

Good targeted assertions for both review_requirements and approval_chains across all updated built-ins.

src/synthorg/templates/builtins/full_company.yaml (3)

60-67: Engineering policy block is well configured for enterprise flow.

Reviewer threshold and code_review chain are consistent and valid.


114-118: Operations change-management chain is correctly defined.

Approver mapping to COO is internally consistent with the template.


127-132: Security review approval chain is properly modeled.

The chain captures expected security + executive sign-off cleanly.


Walkthrough

This change introduces department-level policies to built-in templates (agency, dev_shop, product_team, and full_company) by adding review_requirements (with min_reviewers) and approval_chains keyed by action_type (e.g., code_review, design_review, client_approval, change_management, security_review, test_coverage). Documentation in docs/design/organization.md was updated to document the optional policies field and its structure. A new pytest module verifies rendered templates include the expected department policies.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 27.27% which is insufficient. The required threshold is 40.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat: add department policies to default templates' clearly and concisely summarizes the main change: adding policy configurations to built-in templates.
Description check ✅ Passed The description is well-related to the changeset, providing a clear summary of policy additions, a comprehensive policy matrix, test coverage, and documentation updates.
Linked Issues check ✅ Passed The PR successfully implements all coding requirements from issue #723: adds realistic policies to dev_shop, product_team, agency, and full_company templates with correct review requirements and approval chains as specified, plus comprehensive test coverage and documentation.
Out of Scope Changes check ✅ Passed All changes are within scope: YAML policy additions to templates, documentation updates to organization.md, and unit tests for policy validation. No unrelated modifications are present.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@Aureliolo Aureliolo temporarily deployed to cloudflare-preview March 26, 2026 18:57 — with GitHub Actions Inactive
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 26, 2026

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Snapshot Warnings

⚠️: No snapshots were found for the head SHA 0a536c1.
Ensure that dependencies are being submitted on PR branches. Re-running this action after a short time may resolve the issue. See the documentation for more information and troubleshooting advice.

Scanned Files

None

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces department-level operational policies, including review requirements and approval chains, across several built-in organization templates such as agency, dev_shop, full_company, and product_team. It also updates the design documentation to reflect these new optional fields and adds a comprehensive suite of unit tests to verify the correct rendering of these policies. I have no feedback to provide.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/unit/templates/test_department_policies.py`:
- Around line 79-86: The test test_engineering_review_requirements currently
calls render_template(load_template(template_name)) inside the test body for
each param, causing redundant renders; change to indirect parametrization so the
module-scoped fixture does the rendering by adding pytest.mark.parametrize(...,
indirect=['template_name']) and implement/adjust the fixture that accepts
template_name to call render_template(load_template(template_name)) (or
alternatively pass an already-rendered config fixture into the test), then
update the test to accept the rendered config (or fixture) and use
_get_dept(config, "engineering") and the existing assertion; reference
test_engineering_review_requirements, render_template, load_template, and
_get_dept when locating code to edit.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 8fc8c89b-acd9-4044-8dab-2e0659f2445c

📥 Commits

Reviewing files that changed from the base of the PR and between 15abc43 and d4ce7f3.

📒 Files selected for processing (6)
  • docs/design/organization.md
  • src/synthorg/templates/builtins/agency.yaml
  • src/synthorg/templates/builtins/dev_shop.yaml
  • src/synthorg/templates/builtins/full_company.yaml
  • src/synthorg/templates/builtins/product_team.yaml
  • tests/unit/templates/test_department_policies.py
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: Build Web
  • GitHub Check: Build Backend
  • GitHub Check: Build Sandbox
  • GitHub Check: Test (Python 3.14)
  • GitHub Check: Dependency Review
  • GitHub Check: Analyze (python)
🧰 Additional context used
📓 Path-based instructions (3)
docs/design/*.md

📄 CodeRabbit inference engine (CLAUDE.md)

docs/design/*.md: ALWAYS read the relevant docs/design/ page before implementing any feature or planning any issue. The design spec is the starting point for architecture, data models, and behavior
When implementation deviates from the spec (better approach found, scope evolved, etc.), alert the user and explain why -- user decides whether to proceed or update the spec. Do NOT silently diverge -- every deviation needs explicit user approval
When approved deviations occur, update the relevant docs/design/ page to reflect the new reality

Files:

  • docs/design/organization.md
**/*.py

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.py: Do not use from __future__ import annotations -- Python 3.14 has PEP 649 native lazy annotations
Use PEP 758 except syntax: use except A, B: (no parentheses) on Python 3.14 -- ruff enforces this
Include type hints on all public functions; mypy must pass in strict mode
Use Google-style docstrings on all public classes and functions (enforced by ruff D rules)
Create new objects instead of mutating existing ones; use copy.deepcopy() at construction and MappingProxyType for read-only enforcement on non-Pydantic internal collections (registries, BaseTool)
For dict/list fields in frozen Pydantic models, rely on frozen=True for field reassignment prevention and copy.deepcopy() at system boundaries (tool execution, LLM provider serialization, inter-agent delegation, persistence serialization)
Use frozen Pydantic models for config/identity; use separate mutable-via-copy models (using model_copy(update=...)) for runtime state that evolves (e.g. agent execution state, task progress). Never mix static config fields with mutable runtime fields in one model
Use Pydantic v2 (BaseModel, model_validator, computed_field, ConfigDict). Use @computed_field for derived values instead of storing + validating redundant fields (e.g. TokenUsage.total_tokens); use NotBlankStr for all identifier/name fields -- including optional (NotBlankStr | None) and tuple (tuple[NotBlankStr, ...]) variants
Prefer asyncio.TaskGroup for fan-out/fan-in parallel operations in new code (e.g. multiple tool invocations, parallel agent calls). Prefer structured concurrency over bare create_task
Keep functions under 50 lines and files under 800 lines
Handle errors explicitly; never silently swallow exceptions
Validate at system boundaries (user input, external APIs, config files)
Every module with business logic MUST have: from synthorg.observability import get_logger then logger = get_logger(__name__)
Never use import logging / logging.getLogger() / `pri...

Files:

  • tests/unit/templates/test_department_policies.py
tests/**/*.py

📄 CodeRabbit inference engine (CLAUDE.md)

tests/**/*.py: Use pytest markers: @pytest.mark.unit, @pytest.mark.integration, @pytest.mark.e2e, @pytest.mark.slow on all tests
Maintain 80% test coverage minimum (enforced in CI)
Use asyncio_mode = "auto" in pytest config -- no manual @pytest.mark.asyncio needed
Set global test timeout to 30 seconds (do not add per-file pytest.mark.timeout(30) markers; non-default overrides like timeout(60) are allowed)
Use pytest-xdist via -n auto -- ALWAYS include -n auto when running pytest, never run tests sequentially
Prefer @pytest.mark.parametrize for testing similar cases
NEVER use real vendor names (Anthropic, OpenAI, Claude, GPT, etc.) in project-owned code, docstrings, comments, tests, or config examples. Use generic names: example-provider, example-large-001, example-medium-001, example-small-001, large/medium/small aliases. Vendor names only in: (1) docs/design/operations.md provider list, (2) .claude/ files, (3) third-party import paths. Tests must use test-provider, test-small-001, etc.
Use Hypothesis (@given + @settings) for property-based testing. Profiles: ci (50 examples, default) and dev (1000 examples). Run dev profile: HYPOTHESIS_PROFILE=dev uv run python -m pytest tests/ -m unit -n auto -k properties
NEVER skip, dismiss, or ignore flaky tests -- always fix them fully. For timing-sensitive tests, mock time.monotonic() and asyncio.sleep() to make deterministic. For tasks that must block indefinitely until cancelled, use asyncio.Event().wait() instead of asyncio.sleep(large_number)

Files:

  • tests/unit/templates/test_department_policies.py
🧠 Learnings (4)
📚 Learning: 2026-03-16T06:24:56.341Z
Learnt from: CR
Repo: Aureliolo/synthorg PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-16T06:24:56.341Z
Learning: Applies to docs/design/**/*.md : Design specification pages in `docs/design/` must be consulted before implementing features (7 pages: index, agents, organization, communication, engine, memory, operations)

Applied to files:

  • docs/design/organization.md
📚 Learning: 2026-03-19T07:13:44.964Z
Learnt from: CR
Repo: Aureliolo/synthorg PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-19T07:13:44.964Z
Learning: Applies to src/synthorg/budget/**/*.py : Budget package (budget/): cost tracking, budget enforcement (pre-flight/in-flight checks, auto-downgrade), billing periods, cost tiers, quota/subscription tracking, CFO cost optimization (anomaly detection, efficiency analysis, downgrade recommendations, approval decisions), spending reports, budget errors (BudgetExhaustedError, DailyLimitExceededError, QuotaExhaustedError)

Applied to files:

  • docs/design/organization.md
📚 Learning: 2026-03-19T07:12:14.508Z
Learnt from: CR
Repo: Aureliolo/synthorg PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-19T07:12:14.508Z
Learning: Applies to src/synthorg/security/**/*.py : Security package (security/): SecOps agent, rule engine (soft-allow/hard-deny, fail-closed), audit log, output scanner, output scan response policies (redact/withhold/log-only/autonomy-tiered), risk classifier, risk tier classifier, action type registry, ToolInvoker security integration, progressive trust (4 strategies), autonomy levels (presets, resolver, change strategy), timeout policies (park/resume)

Applied to files:

  • src/synthorg/templates/builtins/agency.yaml
  • src/synthorg/templates/builtins/full_company.yaml
📚 Learning: 2026-03-17T06:30:14.180Z
Learnt from: CR
Repo: Aureliolo/synthorg PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-17T06:30:14.180Z
Learning: Applies to src/synthorg/security/**/*.py : Security module includes SecOps agent, rule engine (soft-allow/hard-deny), audit log, output scanner, risk classifier, autonomy levels (4 strategies), timeout policies.

Applied to files:

  • src/synthorg/templates/builtins/agency.yaml
  • src/synthorg/templates/builtins/full_company.yaml
🔇 Additional comments (16)
src/synthorg/templates/builtins/product_team.yaml (2)

46-48: LGTM!

The engineering department's review_requirements.min_reviewers: 1 aligns with the PR objective and matches the pattern used in other templates.


63-67: LGTM!

The design department's design_review approval chain with "UX Designer" approver is correctly configured. The approver matches the department's head_role and an existing agent in the design department (lines 90-95).

src/synthorg/templates/builtins/agency.yaml (2)

42-46: LGTM!

The operations department's client_approval chain with "Project Manager" approver is correctly configured and matches an existing agent in the department.


56-58: LGTM!

Engineering review_requirements.min_reviewers: 1 aligns with the PR objective.

docs/design/organization.md (3)

109-114: LGTM!

The example YAML correctly demonstrates the policies structure with both review_requirements and approval_chains, matching the DepartmentPolicies schema defined in src/synthorg/core/company.py.


161-161: LGTM!

The documentation clearly describes the optional policies field, its sub-fields (review_requirements, approval_chains), example action types, and default behavior when omitted.


187-187: LGTM!

Minor clarification accurately reflects that templates now define departments with policies.

src/synthorg/templates/builtins/dev_shop.yaml (2)

41-43: LGTM!

Engineering review_requirements.min_reviewers: 1 matches the PR objective.


59-63: LGTM!

The quality_assurance department's test_coverage approval chain with "QA Lead" approver is correctly configured and matches an existing agent (lines 105-110).

src/synthorg/templates/builtins/full_company.yaml (3)

60-67: LGTM!

Engineering department correctly defines:

  • min_reviewers: 2 (matching the PR objective for enterprise-grade review)
  • code_review approval chain with "Software Architect" and "CTO" as approvers

Both approvers exist as agents in the template (lines 219-227 and 154-162 respectively).


114-118: LGTM!

Operations department's change_management approval chain with "COO" approver is correctly configured. COO exists as an agent in the operations department (lines 172-180).


127-132: LGTM!

Security department's security_review approval chain with "Security Engineer" and "CTO" approvers is correctly configured. Both approvers exist as agents in the template.

tests/unit/templates/test_department_policies.py (4)

13-31: LGTM!

Well-designed helper functions with clear error messages that include available options, making test failures easy to diagnose.


37-58: LGTM!

Module-scoped fixtures are appropriate for these read-only template renderings, enabling efficient reuse across tests in the class.


90-103: LGTM!

Good coverage of dev_shop policies including both the positive case (test_coverage chain exists) and the negative case (operations has no approval chains).


107-149: LGTM!

Comprehensive test coverage for all approval chains defined in the PR objectives. The tests correctly verify approver membership and exact tuple equality where appropriate.

Comment on lines +79 to +86
def test_engineering_review_requirements(
self,
template_name: str,
expected_reviewers: int,
) -> None:
config = render_template(load_template(template_name))
eng = _get_dept(config, "engineering")
assert eng.policies.review_requirements.min_reviewers == expected_reviewers
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Consider using fixtures with indirect parametrization to avoid redundant template rendering.

The parametrized test re-renders each template inside the test body, bypassing the module-scoped fixtures defined above. This causes 4 extra template renders that could be avoided.

You could refactor to use indirect parametrization with a dynamic fixture, or accept the slight inefficiency for cleaner test code. Given templates render quickly, this is a minor concern.

♻️ Alternative using indirect parametrization
+@pytest.fixture(scope="module")
+def template_config(request: pytest.FixtureRequest) -> RootConfig:
+    """Render a template by name (for indirect parametrization)."""
+    return render_template(load_template(request.param))
+
+
 `@pytest.mark.parametrize`(
-    ("template_name", "expected_reviewers"),
+    ("template_config", "expected_reviewers"),
     [
         ("dev_shop", 1),
         ("product_team", 1),
         ("agency", 1),
         ("full_company", 2),
     ],
+    indirect=["template_config"],
 )
 def test_engineering_review_requirements(
     self,
-    template_name: str,
+    template_config: RootConfig,
     expected_reviewers: int,
 ) -> None:
-    config = render_template(load_template(template_name))
-    eng = _get_dept(config, "engineering")
+    eng = _get_dept(template_config, "engineering")
     assert eng.policies.review_requirements.min_reviewers == expected_reviewers
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/unit/templates/test_department_policies.py` around lines 79 - 86, The
test test_engineering_review_requirements currently calls
render_template(load_template(template_name)) inside the test body for each
param, causing redundant renders; change to indirect parametrization so the
module-scoped fixture does the rendering by adding pytest.mark.parametrize(...,
indirect=['template_name']) and implement/adjust the fixture that accepts
template_name to call render_template(load_template(template_name)) (or
alternatively pass an already-rendered config fixture into the test), then
update the test to accept the rendered config (or fixture) and use
_get_dept(config, "engineering") and the existing assertion; reference
test_engineering_review_requirements, render_template, load_template, and
_get_dept when locating code to edit.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.33%. Comparing base (31472bf) to head (0a536c1).
⚠️ Report is 4 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #852   +/-   ##
=======================================
  Coverage   92.33%   92.33%           
=======================================
  Files         584      584           
  Lines       30576    30576           
  Branches     2941     2941           
=======================================
  Hits        28233    28233           
  Misses       1854     1854           
  Partials      489      489           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Aureliolo and others added 3 commits March 26, 2026 20:11
Add realistic policies to built-in templates with 3+ departments:
dev_shop, product_team, agency, and full_company. Policies use the
existing DepartmentPolicies schema (review_requirements and
approval_chains) to encode code review, test coverage, design review,
client approval, security review, and change management constraints.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Pre-reviewed by 4 agents, 8 findings addressed:
- Extract TestBuiltinDepartmentPolicies to dedicated test file
  (test_renderer.py was over 800-line limit)
- Parametrize engineering review_requirements tests
- Add _get_chain helper, improve _get_dept error messages
- Module-scoped fixtures to reduce redundant template renders
- Document policies field in organization.md (field list, YAML
  example, template structure comment)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Replace non-ASCII box-drawing chars with ASCII dashes in separators
- Drop module-scoped fixtures in favor of inline rendering (xdist-safe)
- Use exact tuple equality for all approval chain assertions
- Clarify docs default: "single required reviewer", not "empty/default"
- Differentiate class docstring from module docstring

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Aureliolo Aureliolo force-pushed the feat/department-policies-templates branch from d4ce7f3 to 0a536c1 Compare March 26, 2026 19:15
@Aureliolo Aureliolo temporarily deployed to cloudflare-preview March 26, 2026 19:16 — with GitHub Actions Inactive
@Aureliolo Aureliolo merged commit 7a41548 into main Mar 26, 2026
31 checks passed
@Aureliolo Aureliolo deleted the feat/department-policies-templates branch March 26, 2026 19:21
@Aureliolo Aureliolo temporarily deployed to cloudflare-preview March 26, 2026 19:21 — with GitHub Actions Inactive
Aureliolo added a commit that referenced this pull request Mar 30, 2026
🤖 I have created a release *beep* *boop*
---
#MAJOR CHANGES; We got a somewhat working webui :)

##
[0.5.0](v0.4.9...v0.5.0)
(2026-03-30)


### Features

* add analytics trends and budget forecast API endpoints
([#798](#798))
([16b61f5](16b61f5))
* add department policies to default templates
([#852](#852))
([7a41548](7a41548))
* add remaining activity event types (task_started, tool_used,
delegation, cost_incurred)
([#832](#832))
([4252fac](4252fac))
* agent performance, activity, and history API endpoints
([#811](#811))
([9b75c1d](9b75c1d))
* Agent Profiles and Detail pages (biography, career, performance)
([#874](#874))
([62d7880](62d7880))
* app shell, Storybook, and CI/CD pipeline
([#819](#819))
([d4dde90](d4dde90))
* Approvals page with risk grouping, urgency indicators, batch actions
([#889](#889))
([4e9673d](4e9673d))
* Budget Panel page (P&L dashboard, breakdown charts, forecast)
([#890](#890))
([b63b0f1](b63b0f1))
* build infrastructure layer (API client, auth, WebSocket)
([#815](#815))
([9f01d3e](9f01d3e))
* CLI global options infrastructure, UI modes, exit codes, env vars
([#891](#891))
([fef4fc5](fef4fc5))
* CodeMirror editor and theme preferences toggle
([#905](#905),
[#807](#807))
([#909](#909))
([41fbedc](41fbedc))
* Company page (department/agent management)
([#888](#888))
([cfb88b0](cfb88b0))
* comprehensive hint coverage across all CLI commands
([#900](#900))
([937974e](937974e))
* config system extensions, per-command flags for
init/start/stop/status/logs
([#895](#895))
([32f83fe](32f83fe))
* configurable currency system replacing hardcoded USD
([#854](#854))
([b372551](b372551))
* Dashboard page (metric cards, activity feed, budget burn)
([#861](#861))
([7d519d5](7d519d5))
* department health, provider status, and activity feed endpoints
([#818](#818))
([6d5f196](6d5f196))
* design tokens and core UI components
([#833](#833))
([ed887f2](ed887f2))
* extend approval, meeting, and budget API responses
([#834](#834))
([31472bf](31472bf))
* frontend polish -- real-time UX, accessibility, responsive,
performance ([#790](#790),
[#792](#792),
[#791](#791),
[#793](#793))
([#917](#917))
([f04a537](f04a537))
* implement human roles and access control levels
([#856](#856))
([d6d8a06](d6d8a06))
* implement semantic conflict detection in workspace merge
([#860](#860))
([d97283b](d97283b))
* interaction components and animation patterns
([#853](#853))
([82d4b01](82d4b01))
* Login page + first-run bootstrap + Company page
([#789](#789),
[#888](#888))
([#896](#896))
([8758e8d](8758e8d))
* Meetings page with timeline viz, token bars, contribution formatting
([#788](#788))
([#904](#904))
([b207f46](b207f46))
* Messages page with threading, channel badges, sender indicators
([#787](#787))
([#903](#903))
([28293ad](28293ad))
* Org Chart force-directed view and drag-drop reassignment
([#872](#872),
[#873](#873))
([#912](#912))
([a68a938](a68a938))
* Org Chart page (living nodes, status, CRUD, department health)
([#870](#870))
([0acbdae](0acbdae))
* per-command flags for remaining commands, auto-behavior wiring,
help/discoverability
([#897](#897))
([3f7afa2](3f7afa2))
* Providers page with backend rework -- health, CRUD, subscription auth
([#893](#893))
([9f8dd98](9f8dd98))
* scaffold React + Vite + TypeScript + Tailwind project
([#799](#799))
([bd151aa](bd151aa))
* Settings page with search, dependency indicators, grouped rendering
([#784](#784))
([#902](#902))
([a7b9870](a7b9870))
* Setup Wizard rebuild with template comparison, cost estimator, theme
customization ([#879](#879))
([ae8b50b](ae8b50b))
* setup wizard UX -- template filters, card metadata, provider form
reuse ([#910](#910))
([7f04676](7f04676))
* setup wizard UX overhaul -- mode choice, step reorder, provider fixes
([#907](#907))
([ee964c4](ee964c4))
* structured ModelRequirement in template agent configs
([#795](#795))
([7433548](7433548))
* Task Board page (rich Kanban, filtering, dependency viz)
([#871](#871))
([04a19b0](04a19b0))


### Bug Fixes

* align frontend types with backend and debounce WS refetches
([#916](#916))
([134c11b](134c11b))
* auto-cleanup targets newly pulled images instead of old ones
([#884](#884))
([50e6591](50e6591))
* correct wipe backup-skip flow and harden error handling
([#808](#808))
([c05860f](c05860f))
* improve provider setup in wizard, subscription auth, dashboard bugs
([#914](#914))
([87bf8e6](87bf8e6))
* improve update channel detection and add config get command
([#814](#814))
([6b137f0](6b137f0))
* resolve all ESLint warnings, add zero-warnings enforcement
([#899](#899))
([079b46a](079b46a))
* subscription auth uses api_key, base URL optional for cloud providers
([#915](#915))
([f0098dd](f0098dd))


### Refactoring

* semantic analyzer cleanup -- shared filtering, concurrency, extraction
([#908](#908))
([81372bf](81372bf))


### Documentation

* brand identity and UX design system from
[#765](#765) exploration
([#804](#804))
([389a9f4](389a9f4))
* page structure and information architecture for v0.5.0 dashboard
([#809](#809))
([f8d6d4a](f8d6d4a))
* write UX design guidelines with WCAG-verified color system
([#816](#816))
([4a4594e](4a4594e))


### Tests

* add unit tests for agent hooks and page components
([#875](#875))
([#901](#901))
([1d81546](1d81546))


### CI/CD

* bump actions/deploy-pages from 4.0.5 to 5.0.0 in the major group
([#831](#831))
([01c19de](01c19de))
* bump astral-sh/setup-uv from 7.6.0 to 8.0.0 in
/.github/actions/setup-python-uv in the all group
([#920](#920))
([5f6ba54](5f6ba54))
* bump codecov/codecov-action from 5.5.3 to 6.0.0 in the major group
([#868](#868))
([f22a181](f22a181))
* bump github/codeql-action from 4.34.1 to 4.35.0 in the all group
([#883](#883))
([87a4890](87a4890))
* bump sigstore/cosign-installer from 4.1.0 to 4.1.1 in the
minor-and-patch group
([#830](#830))
([7a69050](7a69050))
* bump the all group with 3 updates
([#923](#923))
([ff27c8e](ff27c8e))
* bump wrangler from 4.76.0 to 4.77.0 in /.github in the minor-and-patch
group ([#822](#822))
([07d43eb](07d43eb))
* bump wrangler from 4.77.0 to 4.78.0 in /.github in the all group
([#882](#882))
([f84118d](f84118d))


### Maintenance

* add design system enforcement hook and component inventory
([#846](#846))
([15abc43](15abc43))
* add dev-only auth bypass for frontend testing
([#885](#885))
([6cdcd8a](6cdcd8a))
* add pre-push rebase check hook
([#855](#855))
([b637a04](b637a04))
* backend hardening -- eviction/size-caps and model validation
([#911](#911))
([81253d9](81253d9))
* bump axios from 1.13.6 to 1.14.0 in /web in the all group across 1
directory ([#922](#922))
([b1b0232](b1b0232))
* bump brace-expansion from 5.0.4 to 5.0.5 in /web
([#862](#862))
([ba4a565](ba4a565))
* bump eslint-plugin-react-refresh from 0.4.26 to 0.5.2 in /web
([#801](#801))
([7574bb5](7574bb5))
* bump faker from 40.11.0 to 40.11.1 in the minor-and-patch group
([#803](#803))
([14d322e](14d322e))
* bump https://github.com/astral-sh/ruff-pre-commit from v0.15.7 to
0.15.8 ([#864](#864))
([f52901e](f52901e))
* bump nginxinc/nginx-unprivileged from `6582a34` to `f99cc61` in
/docker/web in the all group
([#919](#919))
([df85e4f](df85e4f))
* bump nginxinc/nginx-unprivileged from `ccbac1a` to `6582a34` in
/docker/web ([#800](#800))
([f4e9450](f4e9450))
* bump node from `44bcbf4` to `71be405` in /docker/sandbox
([#827](#827))
([91bec67](91bec67))
* bump node from `5209bca` to `cf38e1f` in /docker/web
([#863](#863))
([66d6043](66d6043))
* bump picomatch in /site
([#842](#842))
([5f20bcc](5f20bcc))
* bump recharts 2-&gt;3 and @types/node 22-&gt;25 in /web
([#802](#802))
([a908800](a908800))
* Bump requests from 2.32.5 to 2.33.0
([#843](#843))
([41daf69](41daf69))
* bump smol-toml from 1.6.0 to 1.6.1 in /site
([#826](#826))
([3e5dbe4](3e5dbe4))
* bump the all group with 3 updates
([#921](#921))
([7bace0b](7bace0b))
* bump the minor-and-patch group across 1 directory with 2 updates
([#829](#829))
([93e611f](93e611f))
* bump the minor-and-patch group across 1 directory with 3 updates
([#841](#841))
([7010c8e](7010c8e))
* bump the minor-and-patch group across 1 directory with 3 updates
([#869](#869))
([548cee5](548cee5))
* bump the minor-and-patch group in /site with 2 updates
([#865](#865))
([9558101](9558101))
* bump the minor-and-patch group with 2 updates
([#867](#867))
([4830706](4830706))
* consolidate Dependabot groups to 1 PR per ecosystem
([06d2556](06d2556))
* consolidate Dependabot groups to 1 PR per ecosystem
([#881](#881))
([06d2556](06d2556))
* improve worktree skill with full dep sync and status enhancements
([#906](#906))
([772c625](772c625))
* remove Vue remnants and document framework decision
([#851](#851))
([bf2adf6](bf2adf6))
* update web dependencies and fix brace-expansion CVE
([#880](#880))
([a7a0ed6](a7a0ed6))
* upgrade to Storybook 10 and TypeScript 6
([#845](#845))
([52d95f2](52d95f2))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: add department policies to default templates

1 participant