Skip to content

Issue #1513: feat: give the seed dev's models 3, 6, 14 and 17, and remove 29 - #1521

Merged
bjagg merged 12 commits into
mainfrom
issue-1513-replace-models
Nov 20, 2026
Merged

bjagg merged 12 commits into
mainfrom
issue-1513-replace-models

Conversation

@bjagg

@bjagg bjagg commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor
Description of Change

#1520 is merged, and this branch has main merged in, including #1523.

Step 1 of #1513, applied to the seed, as decided: models 3 (CLR v2), 6 (Ed-Fi v5), 14 (CASE) and 17 (StateU LIF) take dev's content, and model 29 (Open Badges v3) is removed. Dev has no separate Open Badges v3; its model 3 covers both. Dev's public and tenant_lif_team hold the same 3, 6 and 14, byte for byte. For 17, the seed takes tenant_lif_team's version, which the reference mappings were written against. In both of the seed's schemas:

  1. Groups: the live groups touching those models (23–26, all → 17) are exported and soft-deleted with their rules.
  2. Each model: the old model is soft-deleted with everything in it. Dev's export of it (GET /portable/models/{id} from dev's tenant_lif_team, 2026-11-15) is imported, and the two Ids are swapped, so the new content keeps the model's Id (17 is pinned in every compose file's OPENAPI_DATA_MODEL_ID) and the old soft-deleted rows move to the new Id. DataModels.Id is GENERATED ALWAYS, so the swap relaxes it to BY DEFAULT and restores it in the same transaction.
  3. Model 29: soft-deleted with everything in it (public only; the seed's tenant_lif_team has none).
  4. Groups again: groups 23–26 are re-imported against the new model 17, all rules resolving (0, 0, 4 and 1), each with its old group's ActivationDate, so the local stack translates as before.
  5. V1.11: dev's model 17 has 35 Reference associations per schema with Array true, the V1.7 copies V1.11 (MDR portability: decide whether a Reference association can be a list #1471) resets. restore.sh replays V1.11 on every local load anyway, so it's applied before the dump, and backup.sql holds what a local stack loads.

No live crosswalk goes through any of these models. 91 value mappings start at model 3's and 14's values, but each ends at a value of a model 1 value set deleted long ago.

Result (scripts/measure_export_blockers.py): every model and group in the seed exports, 18 of 18 and 6 of 6 in each schema.

Behaviour change

Model 17's Type is now SourceSchema, not OrgLIF. The portable format doesn't carry Type, so import_model writes SourceSchema, which fits ADR data_model/0004. In the local MDR UI, StateU LIF moves from the Org LIF group to the source schemas, and Data Extensions (GET /datamodels/orglif) shows nothing. Model 18, converted in place, stays PartnerLIF.

How it was checked
  • Dev parity. In both schemas, export_model on 3, 6, 14 and 17 gives dev's file byte for byte.
  • Generated schemas against dev's. All 16 outputs per model were compared with GET /datamodels/open_api_schema/{id} from dev's tenant_lif_team, row Ids aside:
    • The default schema (what GraphQL, the Translator and semantic search load) is the same for all four. For 17, the only difference is enum value order (Id order, and the Ids are new).
    • The other flags differ only where the portable format normalizes legacy element columns (Portability Spec §5.4 and its migration table):
      • with attribute metadata, attributes' free-text Array/Required on 3, 6 and 14;
      • under public_only, three child entities of model 17 (OperationalStatus, OrganizationCode, Ranges, whose parents are Private) come out single, because a child entity's legacy Array isn't carried;
      • under full_export, CreationDate, which the format doesn't carry.
    • Any import of these files gives the same result, so these aren't regeneration errors.
  • The reference transformations now fit the seed. Checked on a throwaway copy:
    • Ed-Fi-v5_StateU-LIF__v1.0.json (Issue #1511: feat: import the reference transformations through the portable endpoint #1517) imports, all 83 rules, into both seed schemas. Before, public refused it with MODEL_MISSING.
    • The two old-format outbound files: StateU LIF → Ed-Fi v5 resolves 70 of 70 (44 failed before), and StateU LIF → CLR v2 / OB3 resolves 30 of 32. The other two have no source and target attributes in the file itself.
    • So the outbound files can now be converted to the portable format from the seed; that's left for a follow-up.
  • No dump noise, no schema change. Same pg_dump 18.6 container as Issue #1513: feat: convert the seed's overlays and clean it as dev was cleaned #1520. The DDL, everything but data and setval lines, is identical to Issue #1513: feat: convert the seed's overlays and clean it as dev was cleaned #1520's, including the 33 GENERATED ALWAYS identity columns.
  • Every foreign key in both schemas was checked for orphans after the swap (29 FKs, none).
  • The migrations replay cleanly. Loading the new dump and replaying V1.2–V1.11 as restore.sh does changes no row.
  • Rows added are the same in both schemas, dev's four models: 116 entities, 826 attributes, 48 value sets, 1,414 values, 138 entity associations, 1,111 attribute associations, plus the re-imported groups (4) and rules (5).

The procedure ran once, on a fresh load of #1520's seed, so the dump's Ids and sequence values don't depend on any dry runs.

Tests

test/scripts, test/bases/lif/mdr_restapi and test/components/lif/mdr_services: 728 passed, 1 skipped (PG 16.15 locally). One fewer than #1520 because model 29 left the snapshot set. After merging main (with #1523), the full suite: 1927 passed, 1 skipped.

Docs: reference_data/transformations/README.md now says where the files import against this seed.

Related Issues

Refs #1513 (the seed is done; demo, step 6, and the migration question, step 4, stay open there), #1511, #1514

Type of Change
  • Bug fix (non-breaking change which fixes an issue)
  • Documentation update
Project Area(s) Affected
  • projects/
  • reference_data/
  • test/ or e2e/

Checklist
  • commit message follows commit guidelines (see commitlint.config.mjs)
  • tests are included (unit and/or integration tests)
  • code passes linting checks (uv run ruff check)
  • code passes formatting checks (uv run ruff format)
  • pre-commit hooks have been run successfully
Additional Notes

🤖 Generated with Claude Code

bjagg and others added 2 commits November 15, 2026 16:26
…s cleaned

Runs cleanup_export_blockers.py, remove_test_data.py and convert_overlays.py
on backup.sql in public and tenant_lif_team, and removes model 16, as dev got
in #1388 and #1393. Dumped with pg_dump 18.6, as the seed last was.

Tests that need overlays load the unconverted seed, kept as
test/fixtures/backup-unconverted.sql (the same blob as the old backup.sql).
The rest pin the converted seed; the snapshots are regenerated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…move 29

As decided on #1513: models 3, 6, 14 and 17 take dev's content (exported
from dev's tenant_lif_team), keeping their Ids, and model 29 is removed. The
groups on model 17 are re-imported and keep their activation. V1.11 is applied
before the dump, since restore.sh replays it on every local load.

Every model and group in the seed now exports. Tests that need model 29 or
CASE's TargetEntityId attributes run on the unconverted seed; model 17 joins
4 and 10 as a model whose association names aren't derived by the V1.7 rule.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
bjagg and others added 2 commits November 16, 2026 13:17
…kup.sql

backup.sql is no longer a snapshot of V1.1's content. Per the decision on
#1513 step 4, no migration converts a fresh environment; the deployment
guide now says so and names the scripts that give it the seed's content.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…f V1.1

Comment only. backup.sql still replaces V1.1 locally, but its content has
moved past V1.1's; point at the deployment guide's note.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
bjagg and others added 3 commits November 16, 2026 14:47
…veat, model 17 precondition

- deployment.md: a fresh Flyway environment has no supported path to the
  seed's content until #1514; the scripts were never run against V1.1.
- conftest.py: backup-unconverted.sql replays no migrations, so a later
  migration has to be applied to it too.
- test_type_name_does_not_select_the_overlay_path asserts model 17 is
  Type OrgLIF instead of only saying so.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#1520's review added an assertion that model 17 is Type OrgLIF. Here 17 is
dev's copy, Type SourceSchema; assert that, and note the OrgLIF case is
tested through MODEL_ID.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bjagg
bjagg changed the base branch from issue-1513-convert-seed to main November 17, 2026 00:33
bjagg and others added 2 commits November 16, 2026 16:34
#1520's head (66d62be) is already in this branch, and main's tree equals it,
so this records the squash without changing any file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Per #1520's review: handbook chapter 3 now says overlays are gone (dev and
the seed converted, demo won't be), lists the seed's 18 live models, and
replaces the overlay walkthrough with a pointer. Chapter 7's add-a-field step
adds to model 17 directly (checked against the seed: 201, field in 17's
generated schema). The fixture comments say the unconverted seed lasts until
the overlay code is removed, not that the scripts run on demo.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@cbeach47 cbeach47 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From Claude:

I checked this against main (which now includes #1523) and #1513's decisions. The seed side looks right:

  • The live groups (the 23–26 groups, now 28–31) keep their rule counts (0, 0, 4, 1).
  • No code or config in the repo refers to the old group Ids.
  • The Id swap covers every model-Id column.

1. Chapter 7's recipe sets fields that POST /attributes/ ignores. CreateAttributeDTO (components/lif/mdr_dto/attribute_dto.py:36) has no LevelOfAccess, Queryable or Modifiable, and Pydantic drops unknown fields without an error. The attribute gets the defaults (Public, false, false), so x-queryable / x-mutable can't be set this way. UpdateAttributeDTO doesn't have these fields either. Before, the inclusion row carried these flags. On a self-contained model, no API call sets them now, though the format carries them on elements (§5.3). Could the recipe say they default and can't be set yet, with a follow-up issue to add them to both DTOs?

2. Model 17's Type changed from OrgLIF to SourceSchema. The portable format doesn't carry Type, so import_model writes SourceSchema (model_converter.py:550). That fits ADR data_model/0004, but it changes the local MDR UI, and the PR doesn't mention it:

  • StateU LIF moves from the Org LIF group to source schemas (SimpleTree.tsx:312).
  • Data Extensions (DataExtensions.tsx, GET /datamodels/orglif) shows nothing.
  • 18, converted in place, stays PartnerLIF, so the seed's two converted models now have different types.

Please list this as a behaviour change. Either is fine with me: leave it, or set 18 to SourceSchema too so they match.

3. Two tests now depend on #1523's temporary pass for NOT_MIGRATED. test_clone_datamodel_sql and test_schema_generation_cycle now run on the unconverted seed. Its models 14 and 29 still have attributes with DataType entity, so they're only generated because CODES_NOT_YET_REFUSED lets them through. When #1468 removes that pass (#1513's "Done means"), both tests fail.

  • The cycle test can go along with #1463's guard.
  • The clone test checks something the format keeps (Relationship, Placement, Required, Array). I'd run it on the converted seed's 3 and 14, and drop the TargetEntityId coverage, since the format retired that form.

4. CI predates #1523. The run on 503ea8f was on 2026-11-17, and #1523 merged on 2026-11-18, so CI hasn't run generation's refusal against this seed. I merged main into this branch locally and ran the snapshot, portability, generation, endpoint, association-name and export-measurement tests. The new seed and #1523 work together: every snapshot matches, and nothing is refused. A rebase and a green CI run before merging would confirm it.

5. The new wording still describes dev and demo as live. Chapter 3 ("dev and the local seed: converted; demo won't be"), chapter 7, frontend chapter 2 and reference_data/transformations/README.md ("into dev's tenant_lif_team", "doesn't import into dev's public") all do. Now that both are decommissioned, these sentences can describe the seed alone.

On the Array question in the description: under §5.4, the association's Array is the cardinality. The element's own Array is a legacy column the format doesn't carry. So the 224 list associations are what model 17 means, and not checking 17 against the V1.7 rule is right. If any of them shouldn't be lists, that's a content change to 17, separate from this PR.

Nits

  • test_association_name_seed.py: the attribute query filters on x."Name" IS NOT NULL, so a model-17 row with no Name is never checked. The entity test adds OR p."DataModelId" IN %s. Doing the same here would make "both are set" true.
  • test_schema_generation_element_flags.py: the comment says "since #1521"; elsewhere it's #1513.

bjagg and others added 2 commits November 19, 2026 13:21
… fix the recipe and wording

- Clone test: run on the seed's self-contained models 3 (CLR v2 / Open
  Badges v3) and 14 (CASE) instead of the unconverted seed, and drop the
  TargetEntityId coverage the format retired. clone_datamodel sets no
  ContributorOrganization, so with the pass gone generation refuses every
  clone (MODEL_IDENTITY_INCOMPLETE); the test sets the source's
  organization on the clone, which leaves the open question of what a
  clone's organization should be. With CODES_NOT_YET_REFUSED emptied, the
  clone test passes.
- Cycle test: say that it runs on the unconverted seed only because of the
  pass, and goes with #1463's guard when #1468 removes it.
- Chapter 7: POST /attributes/ ignores LevelOfAccess, Queryable and
  Modifiable (neither CreateAttributeDTO nor UpdateAttributeDTO has them),
  so the recipe says the attribute gets the defaults.
- Frontend chapter 2: StateU LIF (17) is now SourceSchema, so the tree
  lists it with source schemas and Data Extensions is empty; 18 is still
  PartnerLIF.
- Describe the seed, or what a schema needs, instead of named environments
  (chapters 3 and 7, frontend chapter 2, the transformations README).
- test_association_name_seed: check model 17's attribute rows with no Name
  too, and require both Name and Array on them. Comment cites #1513.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
bjagg added a commit that referenced this pull request Nov 19, 2026
Resolves the transformations README: "Where the portable files import"
keeps this branch's content, describes the seed and what a schema needs
rather than named environments, and the old-format bullet says none are
left at the top level.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bjagg

bjagg commented Nov 19, 2026

Copy link
Copy Markdown
Contributor Author

From Claude:

Thanks. I merged main (with #1523) and added cf1dea9:

  1. Chapter 7's recipe no longer sends LevelOfAccess, Queryable or Modifiable. It says the attribute gets the defaults, that neither CreateAttributeDTO nor UpdateAttributeDTO takes them (Pydantic drops them silently), and that the format carries them (§5.3). The follow-up to add them to both DTOs is MDR: let POST and PUT /attributes/ set LevelOfAccess, Queryable and Modifiable #1531.
  2. Model 17's Type: listed as a behaviour change in the description, and in frontend chapter 2: StateU LIF moves to the source schemas, and Data Extensions is empty. 18 stays PartnerLIF for now.
  3. The two tests:
  4. CI: this push is the first run with Issue #1468: feat: refuse a non-portable model in schema generation #1523 in the branch. I also ran the full suite locally on the merge: 1927 passed, 1 skipped; ty --error-on-warning is clean.
  5. The dev and demo wording is gone from chapters 3 and 7, frontend chapter 2 and the transformations README. Each now describes the seed, or what a schema needs. Chapter 3 says an MDR that still holds overlays keeps them until convert_overlays.py runs on it.

Nits: both done. The attribute query now includes model 17 rows with no Name, and requires both Name and Array on them, and the comment says #1513.

@cbeach47

Copy link
Copy Markdown
Contributor

From Claude:

Thanks, cf1dea9 covers everything, and CI passed with #1523 in the branch. I'd recommend approval.

One small thing: the description doesn't list model 17's Type change yet. It's in frontend chapter 2 and the commit message. Could you add it under a behaviour-change note before merging, so it ends up in the squash commit?

I've added the clone gap (no ContributorOrganization on a clone) to #1468, since removing the MODEL_IDENTITY_INCOMPLETE pass depends on it.

@cbeach47 cbeach47 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spot checked. Approved.

@bjagg

bjagg commented Nov 19, 2026

Copy link
Copy Markdown
Contributor Author

From Claude:

Thanks. The description now has a Behaviour change section on model 17's Type. My last reply said it was already in the description, and it wasn't. I also fixed two stale parts: the note that this PR was stacked on #1520, and the clone and cycle test bullet, which predated cf1dea9. Thanks for adding the clone gap to #1468.

…models

# Conflicts:
#	test/scripts/test_measure_export_blockers.py
@bjagg
bjagg merged commit b4204b1 into main Nov 20, 2026
4 checks passed
@bjagg
bjagg deleted the issue-1513-replace-models branch November 20, 2026 01:05
@github-project-automation github-project-automation Bot moved this from Backlog to Done in Current Community Efforts Nov 20, 2026
bjagg added a commit that referenced this pull request Nov 20, 2026
…ortable format (#1522)

##### Description of Change

**Stacked on #1521** (itself on #1520), so the diff shows only this
step. Merge those first; this PR's base then becomes `main`.

The two outbound reference groups, StateU LIF → CLR v2 / Open Badges v3
and StateU LIF → Ed-Fi v5, were the last old-format files in
`reference_data/transformations/` (#1511). Their groups on dev have
never had mappings, so there was nothing to export them from. Since
#1521, the seed's models 3, 6 and 17 are dev's `tenant_lif_team`
versions, which these files were written against, so they now convert
through the seed:

1. Each old file was imported into the seed
(`import_transformation_group`, as `POST
/transformation_groups/{id}/import` does) as a new 17 → 3 or 17 → 6
group, version `1.0`.
2. That group was exported with `export_mapping_group` (`GET
/portable/mapping_groups/{id}`) and replaces the old file under the same
name.

Both of the seed's schemas give the same two files, byte for byte.

All three files in the directory are now portable, so
`scripts/import-transformations.sh` loads all three instead of skipping
two.

**What changed in the content:**

- **Rules:** every converted rule has the old rule's name, expression,
expression language, target and sources, compared rule by rule (old
paths' dotted `UniqueName`s and numeric prefixes reduced to the portable
path's segments). That's 70 of 70 for Ed-Fi v5 and 30 of 32 for CLR v2 /
Open Badges v3.
- **Two rules dropped:** `AchievementSubject.activityStartDate` and
`AchievementSubject.result` have no source or target attributes in the
old file, and both read `Name.firstName`. The portable format needs a
target, and they look like placeholders.
- **Group names** follow the `<source>_<target>` pattern every other
group uses: `StateU LIF_CLR v2 / Open Badges v3` and `StateU LIF_Ed-Fi
v5`. The old files had `StateU-LIF_CLR-v2-Open-Badges-v3__v1.0` and
`StateU LIF_Ed-Fi_v5_v1.0`.
- **Not carried over:** the old files' `ActivationDate` (2026-06-18). An
imported group arrives inactive (#1350), like the inbound file's. No
rule had `Notes`, `Alignment` or a contributor to lose.

##### Where they import

Checked on throwaway copies of #1521's seed:

- **The seed, both schemas:** each file imports with every rule,
re-exports byte for byte, and a second import is refused with
`GROUP_EXISTS`.
- **Dev's `public`:** none of the three files imports, and that includes
the inbound file already on `main`. With dev's `public` export of model
17 in place of the seed's, they're refused with 53, 8 and 47
`PATH_INVALID` errors. That StateU LIF has fewer entities than
`tenant_lif_team`'s, as the README already says for the inbound file.
- **Dev's `tenant_lif_team`:** its models 3, 6 and 17 are the ones the
seed now holds, so the paths resolve there. Not imported, since that
would be a dev write. One thing to check before running the script
there: `GROUP_EXISTS` keys on the two models plus `Version`. If dev
already has an empty 17 → 3 or 17 → 6 group at `1.0`, the script reports
the file as already installed while that group still has no mappings.

##### Tests

- New `test/bases/lif/mdr_restapi/test_reference_transformations.py`
runs every portable file in the directory (not recursively, like the
script) in both seed schemas. It checks four things: the rule count, the
import, the byte-for-byte re-export, and `GROUP_EXISTS` on the second
import. 7 passed.
- **Mutations:** the old-format Ed-Fi file put back fails 2 tests, and
so does a mapping removed from it.

##### Related Issues

Refs #1511, #1513

##### Type of Change

- [x] Bug fix (non-breaking change which fixes an issue)
- [x] Documentation update

##### Project Area(s) Affected

- [x] reference_data/
- [x] test/ or e2e/

---

##### Checklist

- [x] commit message follows commit guidelines (see
commitlint.config.mjs)
- [x] tests are included (unit and/or integration tests)
- [x] code passes linting checks (`uv run ruff check`)
- [x] code passes formatting checks (`uv run ruff format`)
- [x] pre-commit hooks have been run successfully

##### Additional Notes

- **Conflicts:** with #1518 in
`reference_data/transformations/README.md`, like #1521. Whichever merges
second resolves.
- **The diff is mostly the two JSON files:** the old format carried
database Ids and nulls on every rule; the portable one names paths only.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants