Skip to content

Milestone 2 slice 1: program-version schema, domain services, and export/import #14

Closed

Description

@TusanHomichi

Existing issue check

  • I searched open and closed issues for this work.

Problem or outcome

#12 recorded the Milestone 2 design direction and ADR 0007 (#13) encodes it. This issue is the work record for the first implementation slice: the configuration schema, the domain services that author and publish program versions, and the versioned JSON export/import — the foundation every later Milestone 2 slice (authoring interface, enrollment pinning) builds on.

After merge, an operator-less test can create a program, author a draft version (phases, transitions, competencies, tasks, rating scales, forms, standards citations), publish it, prove the database rejects mutation of the published version, and round-trip it through export/import losslessly.

Scope

In scope:

  • migration adding program, program_version, and owned typed rows: phases, allowed phase transitions, competencies, tasks, rating scales with anchors and modifiers, evaluation forms with per-competency scale bindings, and external standards citations — STRICT tables, UTC unix-second instants, CHECK-constrained enums, per ADR 0007 and the 0002 idiom;
  • publish freeze enforced by database triggers (INSERT/UPDATE/DELETE rejected on the version and its owned rows once published_at is set), the audit_event enforcement class;
  • phases optional: a version with zero phases is valid (annual/in-service shape);
  • domain services for draft authoring, publish-time validation (transition endpoints, scale bindings, and citations all belong to the version; monotonic version numbering), and publish;
  • documented, versioned JSON export of a whole program version and import that round-trips losslessly, normalization per docs/records-integrity.md canonical-bytes semantics;
  • audit events for program and version lifecycle actions; and
  • integration tests proving each of the above, invented fixtures only.

Out of scope:

Acceptance criteria

  • A draft program version can be created, populated, validated, and published through domain services.
  • Once published, UPDATE and DELETE on the version and INSERT/UPDATE/DELETE on its owned rows fail at the database with explicit errors, proven by tests that attempt raw SQL mutation.
  • A version with zero phases publishes successfully.
  • Publish-time validation rejects transitions, scale bindings, or citations referencing rows outside the version.
  • Export produces the documented versioned JSON; import reproduces an identical version (round-trip test compares canonical forms).
  • Rating scales cover all three kinds (anchored numeric, pass/fail, narrative-only) in fixtures and tests.
  • Standards citations attach at version, competency, and task level and survive the round trip.
  • Lifecycle actions append audit events.

Expected proof

  • cargo fmt --check
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo test --workspace

Related roadmap, decisions, or issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions