Skip to content

fix(api): enforce grid occupancy, foreign keys, and atomic derivation writes - #74

Merged
m-murphy merged 5 commits into
mainfrom
fix/integrity-fk-occupancy-derivation
Aug 27, 2026
Merged

m-murphy merged 5 commits into
mainfrom
fix/integrity-fk-occupancy-derivation

Conversation

@m-murphy

Copy link
Copy Markdown
Member

Summary

  • Enable SQLite foreign keys on every database open (reconnects no longer leave FK off).
  • Schema version 4: at most one Container per occupied grid position; occupancy is checked on create and move (skipValidation removed).
  • Wrap derivation writes in a transaction that stays open across await, including CSV import.
  • Integrity report lists containers with no grid position; that list is not counted in the overview issue total.

First API start against an existing file at schema 3 applies migration 004 in place. Startup fails if two occupied cells already share a position.

Test plan

  • Schema evolution 3→4 and abort on duplicate occupied cells
  • Occupancy rejects tube+tube and tube+well on the same plate
  • createDerivation rolls back a derived specimen when child create fails
  • Integrity report includes unpositioned containers; overview count excludes them
  • Restart API against a backup of the operational SQLite file; SELECT version FROM schema_version is 4

Callers pass quantity as an option instead of flattening to ContainerData before persist.
List, collection detail, GET /containers/:id, and export project from the same load. ADR 0009 records the decision.
…nd gateway.

The page and hook become a thin shell over a testable core.
… writes

Reconnects were leaving SQLite foreign keys off, and two containers could share a grid cell. Open every connection with FK on, unique-index occupied positions, and wrap derivation writes in a transaction that survives await.
@m-murphy
m-murphy merged commit 192535f into main Aug 27, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant