Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/review-2026-10-dev-scenarios.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,5 @@ Answers (2026-10-16):

| Ticket | Finding | Change | Branch |
|--------|---------|--------|--------|
| | | | |
| 14 (#36) Number of parallel units on a treatment step in the configurator | F2 (D7) | C1 | `c1-failure-inputs` |
| 15 (#37) Personal treatment steps store the number of parallel units | F2 (D7) | C1 | `c1-failure-inputs` |
328 changes: 201 additions & 127 deletions docs/specs/c1-failure-inputs.md

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions docs/specs/c2-failure-calculation.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ failure frequency is 0 gives exactly the same results as before C2.
train minus the removable maximum LRVs of the steps down in it. The failure events of the
day are arranged within 1,440 minutes so that this average concentration is lowest. This
gives no overlap when the durations fit into one day and otherwise the minimal overlap,
placed on the steps whose joint loss matters least (`CONTEXT.md`, *Combined failure*). For
placed on the steps whose joint loss matters least (`CONTEXT.md`, *Combined failure*).
Because the LRVs differ per pathogen group, the arrangement is chosen separately for each
reference pathogen; the failure days themselves stay shared. For
a single failing step it equals Eq. 5 of the failure approach. With the few failing steps
per day that occur in practice, the arrangement can be found exactly, for example by
choosing the time share of each combination of failing steps.
Expand Down Expand Up @@ -163,7 +165,9 @@ failure frequency is 0 gives exactly the same results as before C2.
by the constant mixed LRV from Eq. 5, computed by hand in the test.
- **Combined failures:** two steps always failing with 900 + 900 minutes equal the
hand-computed constant LRV with 360 minutes of overlap; three steps always failing with
durations above a day in total equal the hand-computed lowest-concentration arrangement.
durations above a day in total equal the hand-computed lowest-concentration arrangement;
with three steps whose least important pair differs between two pathogen groups, each
reference pathogen equals its own hand-computed arrangement.
- **Monotonicity:** raising a failure frequency never lowers any mean; raising a failure
duration never lowers a best-case mean and leaves worst-case unchanged.
- **Case order:** worst-case mean ≥ best-case mean for every pathogen and risk measure,
Expand Down
24 changes: 24 additions & 0 deletions docs/tickets/04-c1-failure-inputs-in-configurator.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# 04: Failure inputs on a treatment step in the configurator: enter, check ranges, save, reopen, edit

**What to build:** Every treatment step in the assessment configurator gets two more fields: **failure frequency** (failure days per year) and **failure duration** (minutes). Registered users can save an assessment with these values, and when they reopen or edit it they see the same values again. The values do not change the result yet; the calculation follows in C2.

Tidy-up comes first. The configurator's treatment step form and the personal treatment step form both contain the same minimum ≤ maximum LRV check. It becomes one shared rule that both forms use, and the failure rules are added to it later. This Ticket also adds the first HTTP-level tests. They use Django's test client and a logged-in test user, and they check what a browser or a later request can see.

Delivered on branch `c1-failure-inputs` as part of the single C1 pull request. The pull request stays open until the release (D5).

Source: Spec C1 Failure inputs (`docs/specs/c1-failure-inputs.md`), Change C1 in `docs/failure_roadmap.md`. The Spec issue does not exist yet. GitHub issue #21.

**Blocked by:** None (can start immediately)

**Status:** in-progress

- [x] The minimum ≤ maximum LRV check is defined once and used by both treatment step forms. Nothing changes that a user can notice, and the existing test suite passes unchanged.
- [x] A schema migration adds failure frequency (a decimal number) and failure duration (a whole number) to the treatment steps of an assessment. Existing rows get failure frequency 0 and failure duration 30.
- [x] Each treatment step card in the configurator shows both fields below its LRV rows, labelled "Failure frequency (days per year)" and "Failure duration (minutes)". New steps start at 0 and 30, bundled steps included.
- [x] Failure frequency outside 0–365, and failure duration outside 1–1440 or not a whole number, are rejected with a message on the saved configurator. The duration range is checked even when the frequency is 0.
- [x] A fractional failure frequency such as 0.5 is accepted.
- [x] Saving an assessment and reopening it gives back the same failure values for each step. Editing them and saving again stores the new values.
- [x] Each value stays with its own step when other steps are removed. Two copies of the same bundled step can have different values.
- [x] An assessment created without failure values, as before the migration, reopens with failure frequency 0 and failure duration 30.
- [x] An assessment's result and export package are the same with and without failure inputs.
- [x] All of the above is covered by HTTP-level tests through Django's test client, and the existing test suite passes unchanged.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# 05: Failure frequency only on steps with a positive LRV (D4), with messages for guests too

**What to build:** A treatment step can only have a failure frequency above 0 if at least one of its LRVs is positive, because a failure removes only positive LRVs (D4). The configurator checks this when the assessment is run or saved, and the error appears on the failure frequency field.

Guests can use the failure fields too, and the same rules apply to them. Today, when a guest runs an assessment with invalid input, the guest result sends back an empty error and nothing appears on the page. With this Ticket, the guest result sends back the error messages and the configurator shows them on the affected treatment step, as it does for registered users. This also makes the existing LRV errors, such as minimum above maximum, visible to guests.

Delivered on branch `c1-failure-inputs` as part of the single C1 pull request.

Source: Spec C1 Failure inputs (`docs/specs/c1-failure-inputs.md`), roadmap decision D4. The Spec issue does not exist yet. GitHub issue #22.

**Blocked by:** 04 (#21)

**Status:** in-progress

- [x] A failure frequency above 0 is rejected, with a message on the failure frequency field, if none of the step's six LRVs (minimum and maximum for bacteria, viruses and protozoa) is above 0. An empty LRV counts as 0.
- [x] A step whose only positive LRV is one maximum (for example protozoa 0–2) accepts a failure frequency above 0.
- [x] A step with only negative LRVs (recontamination) or only empty LRVs keeps failure frequency 0. A higher value is rejected.
- [x] A guest sees the failure fields, can run an assessment with valid failure inputs, and nothing is stored.
- [x] When a guest's input is invalid, whether a failure input or an LRV, the guest result sends back the error messages and the configurator shows them on the affected step. The rules are the same as for registered users.
- [x] HTTP-level tests cover the D4 cases on the saved configurator and on the guest result, and cover rejection with a message on the guest result. The existing test suite passes unchanged.
24 changes: 24 additions & 0 deletions docs/tickets/06-c1-personal-treatment-step-failure-inputs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# 06: Personal treatment steps store failure inputs and the configurator copies them in

**What to build:** A registered user can store a failure frequency and a failure duration on a personal treatment step, with the same rules as in the configurator. When they add the step to an assessment, its failure values are copied in together with its LRVs. The copy can then be changed in that one assessment without changing the personal treatment step.

Today the personal treatment step form sends back an empty error for invalid input, so the user sees nothing. With this Ticket it shows the messages, the same way it already does for a duplicate name.

Delivered on branch `c1-failure-inputs` and closes the C1 pull request. The pull request is tested on the dev environment and not merged before the release (D5).

Source: Spec C1 Failure inputs (`docs/specs/c1-failure-inputs.md`). The Spec issue does not exist yet. GitHub issue #23.

**Blocked by:** 04 (#21), 05 (#22)

**Status:** in-progress

- [x] A schema migration adds failure frequency and failure duration to personal treatment steps. Existing personal treatment steps get failure frequency 0 and failure duration 30.
- [x] The personal treatment step form shows both fields with their units and applies the same shared rule as the configurator: the ranges, whole minutes, D4 and minimum ≤ maximum LRV. Invalid input is rejected and the message is shown in the form.
- [x] A personal treatment step saved with failure inputs appears with them in its owner's list of personal treatment steps. Another user's list does not contain it.
- [x] Adding a personal treatment step to an assessment copies its failure frequency and failure duration into the new step. Bundled steps still start at 0 and 30.
- [x] Changing the copied values in an assessment and saving leaves the personal treatment step unchanged.
- [x] HTTP-level tests cover the form rules, old personal treatment steps reading back 0 and 30, and owner-only visibility. The existing test suite passes unchanged.
- [x] Manual check on the dev environment, announced to the team first:
- Create a personal treatment step with failure inputs and add it to an assessment.
- See the copied values, change them, save and reopen.
- Confirm that the personal treatment step itself is unchanged.
18 changes: 18 additions & 0 deletions docs/tickets/07-c2-calculation-per-exposure-event.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# 07: Tidy-up: the calculation works per exposure event, with results unchanged

**What to build:** Tidy-up before failures enter the calculation. No result changes.

The Monte Carlo simulation is reorganised to work per simulated exposure event. Each event picks its concentration sample by position instead of by value, which uses exactly the same random numbers as today, and each event gets its own LRV. For now every event still gets the same LRV. Best-case and worst-case use the same building blocks, and the summary statistics (mean, minimum, quartiles, median, maximum) and the reference-level exceedance are computed in one place for both cases and both risk measures. The calculation's public entry point keeps its interface.

Delivered on branch `c2-failure-calculation`, based on `c1-failure-inputs`, as part of the single C2 pull request. The pull request stays open until the release (D5).

Source: Spec C2 Failure calculation (`docs/specs/c2-failure-calculation.md`), Change C2 in `docs/failure_roadmap.md`. The Spec issue does not exist yet. GitHub issue #24.

**Blocked by:** None (can start immediately)

**Status:** ready-for-agent

- [ ] Every simulated exposure event has its own concentration sample, picked by position, and its own LRV. The random numbers are the same as today's.
- [ ] Best-case and worst-case share the same calculation steps. Summary statistics and the reference-level exceedance are computed in one place.
- [ ] The existing regression test passes with exactly the same numbers, and the existing test suite passes unchanged.
- [ ] A new test at the calculation's public entry point shows that calculating the same scenario twice gives identical results.
21 changes: 21 additions & 0 deletions docs/tickets/08-c2-failure-days-and-worst-case.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# 08: Failure days drawn per exposure event; worst-case loses the positive LRVs of failing steps

**What to build:** The worst-case result includes treatment failures. For every simulated exposure event, and for every treatment step with a failure frequency above 0, the step fails that day with probability failure frequency / 365 (ADR-0001). On a failure day, worst-case calculates the event with the positive minimum LRVs of every failing step removed, whatever the failure duration. LRVs of 0, below 0 or empty stay in place (D4).

The failure draws come from their own fixed-seed random generator and are shared by both cases and all reference pathogens. Raising a failure frequency therefore only adds failure days. If every failure frequency is 0, no failure draws are made and the results are exactly today's. Best-case does not change in this Ticket; the mixed-water assumption follows in the next one.

The result page, the reference-level exceedance, saved results and the export's result table show whatever the calculation returns. Their layout does not change.

Source: Spec C2 Failure calculation (`docs/specs/c2-failure-calculation.md`), ADR-0001, roadmap decision D4. The Spec issue does not exist yet. GitHub issue #25.

**Blocked by:** 07 (#24), 04 (#21, C1 stored failure inputs)

**Status:** ready-for-agent

- [ ] With every failure frequency at 0, all results equal today's exactly, including the existing regression test's numbers.
- [ ] A step with failure frequency 365 gives the same worst-case results as the same scenario without that step's positive minimum LRVs.
- [ ] Raising a failure frequency never lowers any mean. Changing a failure duration leaves worst-case unchanged.
- [ ] Worst-case mean ≥ best-case mean for every reference pathogen and risk measure, with and without failures.
- [ ] D4: a failing step with a negative LRV in one pathogen group and a positive LRV in another leaves the first group's results unchanged. A group with LRV 0 is unaffected.
- [ ] Calculating the same scenario with failures twice gives identical results.
- [ ] All tests go through the calculation's public entry point and check only the returned results. The existing test suite passes unchanged.
30 changes: 30 additions & 0 deletions docs/tickets/09-c2-best-case-mixed-water.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# 09: Best-case applies the mixed-water assumption, including combined failures

**What to build:** The best-case result includes treatment failures under the mixed-water assumption. On a failure day, the consumed water is a mixture of water treated during the failure events and water treated in normal operation, in proportion to the failure durations. The event's LRV is −log₁₀ of the time-weighted average of 10^(−LRV) over the segments of the day, where a segment's LRV is the best-case LRV of the train minus the positive maximum LRVs of the steps down in that segment.

The failure events of the day are arranged within 1,440 minutes so that the mixed concentration is lowest:
- if their durations fit into one day, they do not overlap;
- otherwise they overlap only as much as necessary, on the steps whose joint loss matters least.

The arrangement is chosen separately for each reference pathogen, because the LRVs differ per pathogen group. The failure days themselves stay shared. For a single failing step, the result equals Eq. 5 of the failure approach. Work per failure day is reused for repeated combinations of failing steps.

This Ticket closes C2: it includes the manual check on the dev environment and the time measurement.

Source: Spec C2 Failure calculation (`docs/specs/c2-failure-calculation.md`), ADR-0001, `CONTEXT.md` (*Mixed-water assumption*, *Combined failure*), decision 6 in `docs/QMRA_Failure_Approach.md`. The Spec issue does not exist yet. GitHub issue #26.

**Blocked by:** 08 (#25)

**Status:** ready-for-agent

- [ ] A step with failure frequency 365 and failure duration 1,440 gives the same best-case results as the same scenario without that step's positive maximum LRVs.
- [ ] A step with failure frequency 365 and failure duration 60 gives the same best-case results as the scenario with the train's best-case LRV replaced by the Eq. 5 mixed LRV, computed by hand in the test.
- [ ] Two steps always failing with 900 + 900 minutes equal the hand-computed result with 360 minutes of overlap.
- [ ] Three steps always failing with more than a day in total equal the hand-computed lowest-concentration arrangement.
- [ ] Three steps whose least important pair differs between two pathogen groups: each reference pathogen equals its own hand-computed arrangement.
- [ ] Raising a failure duration never lowers a best-case mean, and raising a failure frequency never lowers any mean.
- [ ] Worst-case mean ≥ best-case mean for every reference pathogen and risk measure, with failures.
- [ ] With every failure frequency at 0, all results equal today's exactly. The same scenario gives identical results every time. The existing test suite passes unchanged.
- [ ] Manual check on the dev environment, announced to the team first:
- Enter a scenario with failures and run it as a guest and as a registered user.
- Confirm that the result page, the saved-assessments page, the assessment comparison and the export's result table show the changed results, with unchanged layout.
- [ ] The calculation time for a drinking-water scenario (365 events per year) with failures is measured on the dev environment and recorded in the pull request.
24 changes: 24 additions & 0 deletions docs/tickets/14-c1-parallel-units-in-configurator.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# 14: Number of parallel units on a treatment step in the configurator: enter, check, save, reopen, edit

**What to build:** Every treatment step in the assessment configurator gets a third failure input next to failure frequency and failure duration: the **number of parallel units**, starting at 1. Guests and registered users see and use it. Registered users can save an assessment with it, and when they reopen or edit the assessment they see the same value again, for each step. The value does not change the result yet; the failure LRV follows in C2 (ADR-0002).

The shared validation rule that both treatment step forms use is extended with the new input, not duplicated. A number of parallel units is a whole number of 1 or more, with no upper limit (D7).

Delivered on branch `c1-failure-inputs` as part of the C1 pull request (#28). The pull request is tested on the dev environment again and not merged before the release (D5).

Source: Spec C1 Failure inputs, revision for D7 (`docs/specs/c1-failure-inputs.md`), Change C1 in `docs/failure_roadmap.md`, roadmap decision D7, ADR-0002. The Spec issue does not exist yet. GitHub issue #36.

**Blocked by:** None (can start immediately)

**Status:** ready-for-agent

- [x] A schema migration adds the number of parallel units to the treatment steps of assessments. Existing treatment steps get 1.
- [x] Each treatment step card in the configurator shows the field "Number of parallel units" below the LRV rows, next to failure frequency and failure duration, starting at 1. It is always shown, also when the failure frequency is 0. Guests see the same field.
- [x] A bundled treatment step added to an assessment starts at 1 parallel unit.
- [x] The shared rule rejects a number of parallel units of 0, a negative number or a fraction such as 1.5 with a message that names the field and its range, on the saved configurator and on the guest result. 1, 2 and a large value such as 1000 are accepted.
- [x] Saving an assessment and reopening it returns the same number of parallel units per step. Editing and saving again stores the new value, and values stay with their step when other steps are reordered or removed.
- [x] An assessment saved before this Ticket reopens with 1 parallel unit, failure frequency 0 and failure duration 30, and its result is unchanged.
- [x] The result and the export package of an assessment are identical with and without failure inputs, including a number of parallel units above 1.
- [x] HTTP-level tests through Django's test client cover the cases above, extending the existing C1 failure input tests. The existing test suite passes unchanged.

Quality goals (`docs/vision.md`): Input validity (label and checked range), Reproducibility (saved values and old assessments read back unchanged), Export stability (export package unchanged by C1).
Loading