Files
directus/.planning/phase-1-slice-1-schema/09-rally-albania-2026-seed.md
T
julian a8e808e71c Scaffold directus service planning structure
Initial commit. Establishes the .planning/ tree mirroring processor's
shape (ROADMAP.md as nav hub + per-phase folders with READMEs and
granular task files).

Six phases:

1. Slice 1 schema + deploy pipeline — what Rally Albania 2026 needs.
   Org catalog (orgs, users, vehicles, devices) + event participation
   (events, classes, entries, entry_crew, entry_devices). db-init/
   for the positions hypertable + faulty column. snapshot/apply
   tooling. Gitea CI dry-run. Dogfood seed of Rally Albania 2026.
   Nine task files with full Goal / Deliverables / Specification /
   Acceptance criteria / Risks / Done sections.

2. Course definition — stages, segments, geofences, waypoints, SLZs.
   PostGIS extension introduced here.

3. Timing & penalty tables — co-developed with processor Phase 2.
   entry_segment_starts, entry_crossings, entry_penalties,
   stage_results, penalty_formulas.

4. Permissions & policies — Directus 11 dynamic-filter Policies per
   logical role. Deployment-time work, deferred to keep early phases
   focused on the data model.

5. Custom extensions — TypeScript hooks/endpoints implementing the
   cross-plane workflows the schema implies (faulty-flag → Redis
   stream emit, stage-open materializer, etc.).

6. Future / optional — retroactivity preview UI, command-routing
   Flows, audit trails, federation rule import. Not committed.

Non-negotiable design rules captured in ROADMAP.md: schema authority
in Directus + snapshot-as-code + db-init for non-Directus DDL +
sequential idempotent migrations + entrypoint apply order + no
application logic in Flows + permissions deferred to Phase 4.

Architectural anchors point at the wiki at ../docs/wiki/ — the schema
draft, the Rally Albania 2025 source page, plus the existing
processor/postgres-timescaledb/live-channel pages. Each task file
calls out the wiki refs an implementing agent should read first.

README.md mirrors the processor service README structure: quick start,
local Docker test, prod/stage deployment notes, env vars, CI behavior.
2026-05-01 20:42:44 +02:00

107 lines
5.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Task 1.9 — Rally Albania 2026 dogfood seed
**Phase:** 1 — Slice 1 schema + deploy pipeline
**Status:** ⬜ Not started
**Depends on:** 1.5, 1.7 (need event-participation collections live; need a deployable image to run them on stage)
**Wiki refs:** `docs/wiki/sources/rally-albania-regulations-2025.md` (§2.2–§2.5 class catalog, §1 event metadata), memory `project_rally_albania_2026.md`
## Goal
Seed the stage instance with real data: the "Motorsport Club Albania" organization, the "Rally Albania 2026" event, the full class catalog from the regulations, and at least one fully-registered test entry. Walk the registration workflow end-to-end through the admin UI to confirm the slice-1 schema actually supports a real event registration without surprises. **This is the dogfood gate.**
## Deliverables
Done via the admin UI on the stage Directus instance (no code changes — this task is operational, not a build). Capture screenshots / brief notes in this task's "Done" section.
### 1. Organization
| Field | Value |
|---|---|
| `name` | Motorsport Club Albania |
| `slug` | msc-albania |
### 2. Event
| Field | Value |
|---|---|
| `organization_id` | (the org from step 1) |
| `name` | Rally Albania 2026 |
| `slug` | rally-albania-2026 |
| `discipline` | rally |
| `starts_at` | 2026-06-06T00:00:00Z |
| `ends_at` | 2026-06-13T23:59:59Z |
| `regulation_doc_url` | https://www.rallyalbania.org or the wiki source page URL |
### 3. Class catalog (per Rally Albania §2.2–§2.5)
Create one row per class. `event_id` = the event from step 2.
| code | name | sort_order |
|---|---|---|
| M-1 | MOTO Under 450cc | 10 |
| M-2 | MOTO 450600cc | 20 |
| M-3 | MOTO over 600cc, single cylinder | 30 |
| M-4 | MOTO over 600cc, bi-cylinder | 40 |
| M-5 | MOTO Senior, under 450cc | 50 |
| M-6 | MOTO Senior, over 450cc | 60 |
| M-7 | MOTO Veteran (any bike) | 70 |
| M-8 | MOTO Female driver | 80 |
| Q-1 | QUAD 2WD | 90 |
| Q-2 | QUAD 4WD | 100 |
| Q-3 | QUAD Female pilot | 110 |
| C-1 | CAR Modified | 120 |
| C-2 | CAR Production | 130 |
| C-A | CAR Standard Automobiles | 140 |
| C-3 | CAR All-female team | 150 |
| S-1 | SSV Single pilot | 160 |
| S-2 | SSV Two-driver team | 170 |
| S-3 | SSV All-female team | 180 |
> **Numbering note:** The regulations doc uses `M-7` for both Veteran and Female driver — apparent typo. This seed renames the Female driver class to **M-8** to disambiguate. Flag this in the post-event review with the organizer; if they confirm M-8 is wrong, rename later.
### 4. Test entry — full registration walkthrough
Pick (or create) a test user in `directus_users`, a test vehicle in `vehicles`, and two test devices in `devices`. Register them all in the event:
1. Add the test user to `organization_users` with role `participant`.
2. Add the test vehicle to `organization_vehicles`.
3. Add the test devices to `organization_devices`.
4. Create an `entries` row: `event_id` = Rally Albania 2026, `vehicle_id` = test vehicle, `class_id` = M-1 (or whatever fits the test vehicle), `race_number` = 1, `status` = `registered`.
5. Create one `entry_crew` row: `entry_id` = the entry, `user_id` = test user, `role` = `pilot`.
6. Create two `entry_devices` rows: one with `assigned_user_id` = test user (panic button), one with `assigned_user_id` = null (vehicle-mounted). `mount_position` field filled in for both.
7. Verify the live map (Phase 1 of [[processor]]) still renders the test devices' positions correctly under the new entry-aware schema. (If the SPA isn't yet wired to look up entries, that's fine — verify in DB / processor logs that the device IDs match what the entry registered.)
### 5. Post-walkthrough checklist
In this task's "Done" section, capture:
- [ ] Any field that was awkward to enter via admin UI (interface improvements for Phase 5 hooks).
- [ ] Any constraint that fired unexpectedly (data model bugs to fix in a follow-up).
- [ ] Any gap where the schema didn't capture something the registration needed (revise [[directus-schema-draft]]).
- [ ] How long the full registration took. Realistic baseline for "register N entries" planning.
## Specification
- **Stage env, not local.** This task verifies the deploy pipeline end-to-end: image was built by Phase 1.8 CI, pulled by Portainer, booted with snapshot+db-init applied, then operator interacts with the live admin UI.
- **Real-ish data.** Use plausible names / IMEIs / VINs — not "test1", "foo", "bar". The data will be reviewed by the organizer eventually; quality matters.
- **One full crew, not many.** A single pilot entry is enough to dogfood. Save the multi-crew rally car case for a Phase 2 dogfood.
- **No SPA work in this task.** The registration is admin-UI only. SPA-side work (operator-friendly registration UX) is a separate workstream not blocked on Phase 1.
## Acceptance criteria
- [ ] All 18 class rows visible in admin UI under the Rally Albania 2026 event.
- [ ] One complete entry exists with vehicle + class + crew + devices.
- [ ] Live map shows the test devices' positions tagged with their device IDs (existing Phase 1 [[processor]] behavior).
- [ ] Post-walkthrough checklist filled in.
- [ ] Any schema bugs surfaced are tracked as new tasks (or revisions to existing task files).
- [ ] Decision: does the slice-1 schema support Rally Albania 2026 as a test event, or does it need revisions before June? Captured as a one-line verdict in this task's Done section.
## Risks / open questions
- **Phase 4 (permissions) hasn't landed yet.** Operators using admin UI for registration are doing so as Directus admins, which is fine for dogfood but obviously not for production use. Phase 4 is the gate for non-admin users.
- **The "live map" verification step** depends on Phase 1 [[processor]] being deployed and pointed at the same database. Confirm before starting.
## Done
(Fill in commit SHA / dogfood date + one-line verdict when this lands.)