Files
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

3.1 KiB

Phase 2 — Course definition

Status: Not started — depends on Phase 1 Outcome: A complete data layer for defining the spatial and procedural shape of an event: stages, segments (typed: liaison / special-stage / parc-ferme), geofences (PostGIS polygons), waypoints, and speed_limit_zones. Operators can populate the full course before each stage from the roadbook. No processor logic yet — Phase 2 of processor consumes this data and writes crossings/penalties.

Why this is a separate phase

  • Phase 1 ships a usable system. Live tracking + entry registration is enough for the Rally Albania 2026 dogfood. Course definition adds operator workload but no live functionality until processor Phase 2 ships.
  • PostGIS introduction. Phase 2 is where CREATE EXTENSION postgis lands in db-init/. Geometry columns require it; no other Phase 1 work does.
  • Scope creep risk. Course definition has surprising depth (geofence editing UX, polygon validation, segment ordering UX). Isolating it as its own phase prevents Phase 1 from ballooning.

Tasks (sketched, not detailed)

These tasks will get full task files when Phase 2 starts. For now, this is the planned shape:

# Task Notes
2.1 PostGIS extension migration db-init/004_postgis.sql adds the extension. Idempotent.
2.2 stages collection Per directus-schema-draft: event_id, name, sort_order, role, starts_at, start_interval_seconds, start_order_strategy, start_order_strategy_params, start_order_input_stage_id.
2.3 segments collection stage_id, sort_order, type (liaison/special-stage/parc-ferme), entry_geofence_id, exit_geofence_id, target_duration_seconds.
2.4 geofences collection PostGIS polygon column. event_id, name, kind, geometry, manual_verification, retroactive.
2.5 waypoints collection PostGIS point. segment_id, location, tolerance_meters, sort_order.
2.6 speed_limit_zones collection PostGIS polygon. segment_id, geometry, max_speed_kmh, evaluation_window_meters, retroactive.
2.7 Geometry editor evaluation Directus's built-in map interface vs. a custom extension panel. Decide based on usability for operators authoring real geofences from a roadbook.
2.8 Snapshot regeneration + CI verification All new collections in the snapshot; CI dry-run still passes.

Open questions blocking task-level detail

(These get answered when Phase 2 starts.)

  1. Is Directus's built-in map interface adequate for authoring geofence polygons, or does Phase 2 need a custom extension with a richer editor (drawing tools, vertex snapping, polygon validation)?
  2. How are roadbook coordinates (typically WGS84 lat/lon) imported — bulk upload, copy-paste, manual click-to-place?
  3. Are checkpoint geofences a separate kind value or is manual_verification = true enough to identify them?
  4. Should start_order_strategy_params be a JSON field (flexible) or a dedicated table (queryable)? JSON is the schema-draft default; revisit if querying is needed.