Repository navigation
programs(config): program versions, publish freeze, and export/import - #15
Merged
Merged
Conversation
Implement ADR 0007's first slice: migration 0004 with typed owned rows and composite foreign keys enforcing domain invariant 5, publish-freeze triggers in the audit_event enforcement class, phase-optional versions, domain services for wholesale draft authoring and validated publishing, attributable lifecycle audit events with domain subjects, and the documented versioned JSON export/import with a byte-identical round trip (docs/formats/program-version-export.md). Refs #14
This was referenced Aug 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Primary Issue
Closes #14
Problem And Outcome
Milestone 2 needs the configuration schema that finalized records will pin to forever, with immutability the database enforces rather than trusts. After merge: a program version can be authored as a draft, validated, published (frozen at the database), exported as documented versioned JSON, and reproduced byte-for-byte on a clean installation.
Changes
0004_programs.sql:program,program_version, and eleven owned typed tables (phases, transitions, competencies, tasks, rating scales/anchors/modifiers, evaluation forms, form competency bindings, form narratives, standards citations). Every cross-reference is a composite foreign key includingprogram_version_id, so domain invariant 5 — all referenced configuration belongs to the pinned version — is enforced by the schema. Publish freeze: oncepublished_atis set, the version row and every owned table reject INSERT/UPDATE/DELETE viaRAISE(ABORT)triggers, the same enforcement class asaudit_event. Phases are optional (annual/in-service shape).audit_eventgains nullablesubject_kind/subject_id(deliberately no FK, so audit rows can never block lawful disposition of their subjects).src/programs.rs: the typed content document (also the export payload), structural validation mirroring the database's case-insensitive uniqueness, and services — create program, create/replace/discard draft (wholesale replacement: single editor, honest last write per ADR 0007), publish with completeness refusals, deterministic content loading. All mutating services gate onmanage_programsand append attributable audit events in the same transaction.src/program_export.rs: versioned envelope (consolebook-program-versionv1), deterministic byte-stable export, strict import (unknown fields refused) into a new program or the next version of an existing one.docs/formats/program-version-export.md: the normative format spec, following the canonical-bytes principles indocs/records-integrity.md.src/audit.rs: program lifecycleEventKinds andrecord_for_subject.tests/programs.rs: 14 integration tests, including raw-SQL proof that all 12 tables reject mutation after publish, the phase-less publish, validation and capability refusals, audit attribution, and an export → fresh-installation import → export byte-identity round trip.One note against #14's wording: cross-version reference rejection lands earlier than publish time — document validation refuses unknown references at every write, and the composite foreign keys make a dangling reference unrepresentable at the database. Publish-time validation covers completeness (a form with no competencies and no narratives refuses to publish).
Scope
Verification
Web sources untouched; pr-gate builds
web/first as always.Review And Merge Notes
0004_programs.sql(every owned table, INSERT included, both OLD and NEW parents on UPDATE), and whether the export format doc matches what the serializer actually emits.Generated by Claude Code