Add Policies domain (drafting, versioning, tracked acceptance) #15

Merged
thatguygriff merged 1 commits from feature/policies into main 2026-06-05 18:22:17 +00:00
Owner

Implements #6 (Policies) — the second registration gate (standalone, no payment dependency).

What's included

  • src/Policy/ domainPolicy, PolicyVersion (draft/published/archived), PolicyAcceptance value objects; PolicyRepository, PolicyVersionRepository, AcceptanceRepository; PolicyService; PolicyEndpoint; PolicyController + templates/admin/policies.php
  • Tables in Schema.phpus_policies, us_policy_versions, us_policy_acceptances
  • PolicyService orchestrates the multi-table publish flow: archive the prior current version, stamp published_at, and repoint current_version_id
  • Admin — a Policies menu (gated on manage_policies): create a policy, add/publish draft versions, see which version is current
  • Wiring — Plugin, RestRegistrar, AdminMenu

REST API

Method Endpoint Permission
GET /policies public (current published versions)
POST /policies manage_policies
POST /policies/{id}/versions manage_policies
PATCH /policies/{id}/versions/{vid} manage_policies (draft only)
POST /policies/{id}/versions/{vid}/publish manage_policies

Versioning & acceptance

Acceptance is bound to policy_version_id, so publishing a new version leaves it unaccepted — students must re-accept at their next booking. AcceptanceRepository is built here and consumed by the booking/enrolment gate in #3/#4.

Also

Bumped PHPStan to --memory-limit=1G in the composer lint script — the default 128M now crashes analysis as the codebase has grown (would otherwise fail the static-analysis CI job).

Tests

  • tests/Unit/Policy/ — value objects, three repositories, and the PolicyService publish orchestration (25 new tests)
  • composer test (90 total), composer cs, and PHPStan level 6 all pass

Refs #6

🤖 Generated with Claude Code

Implements **#6 (Policies)** — the second registration gate (standalone, no payment dependency). ## What's included - **`src/Policy/` domain** — `Policy`, `PolicyVersion` (draft/published/archived), `PolicyAcceptance` value objects; `PolicyRepository`, `PolicyVersionRepository`, `AcceptanceRepository`; `PolicyService`; `PolicyEndpoint`; `PolicyController` + `templates/admin/policies.php` - **Tables** in `Schema.php` — `us_policies`, `us_policy_versions`, `us_policy_acceptances` - **`PolicyService`** orchestrates the multi-table publish flow: archive the prior current version, stamp `published_at`, and repoint `current_version_id` - **Admin** — a **Policies** menu (gated on `manage_policies`): create a policy, add/publish draft versions, see which version is current - **Wiring** — Plugin, RestRegistrar, AdminMenu ## REST API | Method | Endpoint | Permission | |---|---|---| | GET | `/policies` | public (current published versions) | | POST | `/policies` | `manage_policies` | | POST | `/policies/{id}/versions` | `manage_policies` | | PATCH | `/policies/{id}/versions/{vid}` | `manage_policies` (draft only) | | POST | `/policies/{id}/versions/{vid}/publish` | `manage_policies` | ## Versioning & acceptance Acceptance is bound to `policy_version_id`, so publishing a new version leaves it unaccepted — students must re-accept at their next booking. `AcceptanceRepository` is built here and consumed by the booking/enrolment gate in #3/#4. ## Also Bumped PHPStan to `--memory-limit=1G` in the `composer lint` script — the default 128M now crashes analysis as the codebase has grown (would otherwise fail the `static-analysis` CI job). ## Tests - `tests/Unit/Policy/` — value objects, three repositories, and the `PolicyService` publish orchestration (25 new tests) - `composer test` (90 total), `composer cs`, and PHPStan level 6 all pass Refs #6 🤖 Generated with [Claude Code](https://claude.com/claude-code)
thatguygriff added 1 commit 2026-06-05 18:01:24 +00:00
Add Policies domain (drafting, versioning, tracked acceptance)
CI / Coding Standards (pull_request) Successful in 1m0s
CI / PHPStan (pull_request) Successful in 1m4s
CI / Tests (PHP 8.1) (pull_request) Successful in 59s
CI / Tests (PHP 8.2) (pull_request) Successful in 56s
CI / Tests (PHP 8.3) (pull_request) Successful in 57s
CI / No Debug Code (pull_request) Successful in 3s
CI / Build Plugin Zip (pull_request) Has been skipped
6225e772f8
Implements #6: studio admins draft, version, and publish policies; the
public registration gate reads the current published version of each, and
acceptance is recorded against the exact version so a new version must be
re-accepted at the next booking.

- src/Policy/: Policy, PolicyVersion, PolicyAcceptance value objects;
  PolicyRepository, PolicyVersionRepository, AcceptanceRepository;
  PolicyService (orchestrates create/add-draft/publish across the policies
  and versions tables); PolicyEndpoint (REST); PolicyController +
  templates/admin/policies.php (Policies admin menu, manage_policies)
- us_policies, us_policy_versions, us_policy_acceptances tables in Schema
- REST: public GET /policies (current published versions); manage_policies
  for create, add version, edit draft, and publish
- Wiring in Plugin, RestRegistrar, AdminMenu

AcceptanceRepository is built now and consumed by the booking/enrolment
gate in #3/#4.

Also bump PHPStan to --memory-limit=1G in the composer lint script; the
default 128M now crashes the analysis as the codebase has grown.

Tests: tests/Unit/Policy/ (value objects, repositories, service).
composer test (90 total), cs, and PHPStan level 6 all pass.

Refs #6

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
thatguygriff merged commit 5352fb7d69 into main 2026-06-05 18:22:17 +00:00
thatguygriff deleted branch feature/policies 2026-06-05 18:22:17 +00:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Unsupervised/unsupervised-scheduler#15