Add hybrid CASE_HASH support#157
Conversation
CASE_HASH support
1e30535 to
44af70e
Compare
There was a problem hiding this comment.
Pull request overview
Adds hybrid support for CASE_HASH by parsing it from env_case.xml, persisting
it on simulations, and exposing it via simulation schemas/API while keeping
case-name-based grouping authoritative and emitting warnings on hash drift.
Changes:
- Parse
CASE_HASHinto ingestion metadata and persist it onSimulation. - Add
simulations.case_hashvia Alembic migration and exposecaseHashin
SimulationCreate/SimulationOut. - Add drift-detection logic that warns on conflicting hashes for the same case
name (without changing grouping), plus test updates.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| backend/app/features/ingestion/ingest.py | Tracks CASE_HASH observations during ingestion and logs drift warnings. |
| backend/app/features/ingestion/parsers/case_docs.py | Parses CASE_HASH from env_case.xml into metadata. |
| backend/app/features/ingestion/parsers/parser.py | Plumbs parsed case_hash into ParsedSimulation. |
| backend/app/features/ingestion/parsers/types.py | Extends ParsedSimulation with optional case_hash. |
| backend/app/features/simulation/models.py | Adds nullable case_hash column to ORM model. |
| backend/app/features/simulation/schemas.py | Exposes case_hash on create/out schemas with descriptions. |
| backend/migrations/versions/20260414_000000_add_case_hash_to_simulations.py | Adds case_hash column to simulations table. |
| backend/tests/features/ingestion/parsers/test_case_docs.py | Verifies CASE_HASH is parsed (or None on read error). |
| backend/tests/features/ingestion/test_ingest.py | Verifies persistence of case_hash and drift warning behavior. |
| backend/tests/features/simulation/test_api.py | Asserts caseHash is returned by simulation GET endpoint. |
| backend/tests/features/simulation/test_schemas.py | Updates schema tests to include caseHash/case_hash. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 44af70e685
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Summary
CASE_HASHfromenv_case.xmlCASE_HASHdrifts across executions for the same case namecase_hashon simulation schemas and add a migration forsimulations.case_hashCASE_HASHas the canonical Case identifier #136Why not group by CASE_HASH yet?
Issue #136 now has confirmed real-world evidence that
CASE_HASHcan be consistent across some executions and drift across others for the same logical case. Making it the sole grouping key now would risk splitting one logical case into multiple SimBoard cases.This change implements the safe hybrid path:
CASE_HASHTesting
uv run pytest tests/features/ingestion/parsers/test_case_docs.py tests/features/ingestion/test_ingest.py tests/features/simulation/test_schemas.py tests/features/simulation/test_api.pymake backend-testRefs #136