Skip to content

C1: Failure inputs per treatment step (#21, #22, #23) - #28

Draft
yaniv-kwb wants to merge 7 commits into
mainfrom
c1-failure-inputs
Draft

yaniv-kwb wants to merge 7 commits into
mainfrom
c1-failure-inputs

Conversation

@yaniv-kwb

@yaniv-kwb yaniv-kwb commented Sep 25, 2026 •

Copy link
Copy Markdown

Do not merge before the release. Failure work stays out of main until C1–C5 are released together (roadmap decision D5): every merge into main deploys to production. This PR stays open, is kept up to date with main, and is tested on dev. C2 and C3 will build on it.

What changes

Users can enter a failure frequency (failure days per year, 0–365, default 0) and a failure duration (whole minutes, 1–1440, default 30) for each treatment step, and the values are stored with the scenario. Nothing in the calculation changes yet: results and export packages are identical with and without failure inputs (C2 adds the effect).

The branch also carries the docs commits for the C1 and C2 tickets. These include the per-pathogen rule for arranging combined failures in the C2 Spec and in CONTEXT.md (Combined failure).

Spec and Tickets

Checks

  • Mock-data check (Controlled server):
    • The full test suite passes (46 tests), including 24 new HTTP-level tests through Django's test client.
    • A local server with scratch databases, driven by a headless browser, checked three flows:
      • guest errors shown and cleared;
      • a personal step rejected, then saved and copied into an assessment (2.5 and 90), with a bundled step at 0 and 30;
      • the copy changed to 10 and 15 and reopened, while the personal step kept 2.5 and 90.
    • Still to do: the manual check on dev (see the list below).
  • Real-data check (Workstation): not done yet.
  • Quality goals checked:
    • Input validity: every failure input shows its unit, and values outside 0–365 or 1–1440, fractional minutes, empty fields and D4 violations are rejected with a message. Covered by HTTP tests for the saved configurator, the guest result and the personal step form.
    • Reproducibility: reopening returns exactly the stored values, and assessments from before C1 read back 0 and 30 (HTTP tests).
    • Export stability: the export package of an assessment is byte-identical with and without failure inputs (HTTP test).
    • Privacy of registered-user data: another user's list of personal treatment steps doesn't contain the step (HTTP test).

Manual check on dev

  • Before the deploy, note the results or export of one or two saved assessments on dev. Afterwards they reopen with 0 and 30 and unchanged results.
  • Configurator (registered user): the fields and units are there, and values survive save, reopen, edit and delete. The listed invalid values are rejected with messages. A step whose only positive LRV is protozoa 0–2 is accepted with frequency 1.
  • Guest: valid failure inputs give a result. Frequency 400 is marked on the field and on the step, and the marks clear after correcting.
  • Personal treatment step: invalid input shows a message. After saving, adding the step copies its values, the copy can be changed without touching the personal step, and a second account doesn't see it.

Known behaviour that isn't from C1:

Once this is on dev, the migrations can't be reversed there. Only C1 and branches built on it should go to dev until the release. A merge into main would put dev back on code without these columns, until this branch is pushed again.

Definition of Done

  • Tests pass
  • code-review findings are handled (fixed, or answered in this PR)
  • Mock-data check done (automated and local browser checks, and the manual check on dev)
  • Real-data check done, or marked not needed above
  • No secrets or Real data committed
  • Glossary, ADRs and Vision document updated if this Change affects them (C1 needs no update; the C2 docs commit updated CONTEXT.md)
  • Relevant Quality goals checked
  • I can explain this Change in my own words

🤖 Generated with Claude Code

ma-z-am and others added 6 commits September 25, 2026 09:52
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ent per pathogen [skip ci]

The best-case arrangement of combined failure events longer than a day is
chosen separately for each reference pathogen; failure days stay shared.
Recorded in the C2 Spec and in CONTEXT.md (Combined failure).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Each treatment step of an assessment gets a failure frequency (failure
days per year, 0-365, default 0) and a failure duration (whole minutes,
1-1440, default 30). The configurator shows both fields with their units
below the LRVs, rejects values outside the ranges with a message, and
keeps the values with their step through save, reopen and edit. Existing
steps get the defaults via the migration. The calculation is unchanged,
so results and export packages stay the same (C2 adds the effect).

Tidy-up: the min <= max LRV check duplicated in the configurator and the
personal treatment step form is now one shared rule, which also holds the
failure ranges. The two existing treatment form tests pass the two new
required fields in their input data; their assertions are unchanged.

Adds the first HTTP-level tests (Django test client, logged-in user).

Refs #21

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…sts (#22)

A treatment step can have a failure frequency above 0 only if at least
one of its six LRVs is positive (an empty LRV counts as 0), since a
failure removes only positive LRVs (D4). The shared treatment step rule
rejects it with a message on the failure frequency field.

Guests: an invalid guest result now answers 422 with the error messages
keyed by input name instead of an empty body. The configurator marks the
affected inputs and treatment step and explains in the result pane why
nothing ran; the marks clear on the next run. Registered users keep their
path (the saved configurator re-renders with the errors). This also makes
existing LRV errors visible to guests.

Also fixes the treatments section from #21: its fixed height hid the
failure fields and their messages under the footer; it now grows with
its content.

Refs #22

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…tor copies them in (#23)

A personal treatment step gets a failure frequency (failure days per
year) and a failure duration (minutes), with the same shared rule as the
configurator: ranges, whole minutes, a positive LRV for a frequency above
0 (D4), and minimum <= maximum LRV. Existing personal steps get 0 and 30
via the migration. Invalid input now shows the messages in the form (422
with the rendered form), like the duplicate-name error already did.

The owner's list of personal treatment steps includes both values, and
adding a personal step in the configurator copies them into the new step
card together with its LRVs. Bundled steps carry no failure inputs, so
their card keeps 0 and 30. The copy can be changed in the assessment
without touching the personal step.

Refs #23

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The manual check on the dev environment in 06 stays open until it is
done on the deployed pull request.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

This branch was successfully deployed

1 active (outdated) deployment
dev — 315517e9 Deployed Sep 25, 2026 by yaniv-kwb via deploy-dev / deploy #88
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.

2 participants