Repository navigation
fix(atemschutz): put the Trupp-Typ rules in the Stammdaten, not in its name - #411
Conversation
…s name
"CSA-Trupp" and "LPA-Trupp" were compiled-in literals that AtemschutzTrupp
matched the designation against: the first decided whether a Trupp needed
three people, both picked which Einsatzzeit was suggested. But the Trupp-Typen
are a list the brigade edits freely, so a Wehr writing "CSA Trupp",
"CSA-Trupp (Chemikalienschutz)" or "Chemietrupp" got a two-person CSA-Trupp
accepted without complaint, on 30 minutes instead of 20 -- no warning, nothing
in the Einsatztagebuch.
A Trupp-Typ now carries its own Staerke and Einsatzzeit, so the rules follow
the type however it is named and a brigade can define its own. The three global
Einsatzzeit settings (AGT/CSA/LPA) are replaced by the per-type value; the
Rueckzugsdruck and the ILS intervals stay where they were.
The per-type crew size is enforced in ScbaViewModel, the only layer that can
read the Stammdaten -- not threaded into AtemschutzTrupp.Register. Passing the
number in would mean growing the sync wire format to re-check a value the
caller just derived from the same master data, and having CommandApplier look
it up itself would need MasterDataSet inside the domain, which is a reference
cycle. The domain keeps what it can prove on its own, and that check is now
stronger: a crew must fill its positions contiguously from Truppfuehrer, so
{Truppfuehrer, 2. Truppmann} with a hole in the middle is no longer accepted.
Existing stores migrate once, on first open, mapping the two old names to the
values the old rule gave them -- so nothing changes for a brigade using the
shipped spellings. That mapping is the only place a Trupp-Typ name is compared
to a literal, it is shared with the JSON parser so a restored backup and a
reopened masterdata.db agree, and it is gated on a marker row rather than on
the column being absent, so a repaired store is not mistaken for a first
migration.
Also closes #397: EnsureSchema's reconciliation was three hand-written lines,
and a column added without one would break every existing store while a fresh
one looked fine. The drop-column sweep it asks for is now a test -- it found
md_personnel's optional columns unguarded on its first run.
Fixes #398
Closes #397
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>
|
@claude review |
|
Claude finished @DeepDiver1975's task in 2m 25s —— View job Reviewing PR #411
SummaryThis is a well-scoped, well-reasoned fix. Read through the domain ( The core design holds up. Moving crew size and Einsatzzeit onto the Migration logic checked out. Sync surface unchanged, as claimed. Confirmed Minor observations (non-blocking)
Everything else — the crew-gap validation, the JSON legacy bare-string import path, the drop-column sweep test that caught the real |
…it too Two follow-ups to the same change. #418 is the practitioner's answer to #398: a Strahlenschutztrupp is also a three-person Trupp, but on the full 30 minutes rather than a CSA-Trupp's 20. It needs no code -- it is a Stammdaten row now -- so it joins the shipped examples in docs/master-data.example.json and docs/samples/demo-stammdaten.json. Keeping both in the demo set is deliberate: two three-person types with *different* Einsatzzeiten is precisely what a rule keyed off the designation could never express, so the sample now demonstrates the point rather than merely benefiting from it. The issue's second ask, that the third crew field not be labelled "(CSA)", was already done earlier on this branch. The review on #411 found the other one: MaxDurationMinutes crossed the trust boundary unclamped, unlike MemberCount. A zero or negative value out of a hand-edited masterdata.db or an imported file reached AtemschutzTrupp.Register's ThrowIfNegativeOrZero from inside a fire-and-forget mutation -- the UI-crash shape #217 fixed once already. ClampMaxDurationMinutes now guards all three entrances: the SQLite read, the JSON parse, and the editor's ToValues, which the review did not name but is the same boundary and already clamps the crew size on the very next argument. It is a floor only. A crew size has a structural ceiling because TruppRole fixes how many people fit on the sheet; an Einsatzzeit has none, and a brigade running a four-hour LPA must not find that silently shortened. The editor's Maximum is a convenience for the spinner, not a rule about Atemschutz. The review's other observation -- RequiresThirdMember reading >= MaxMemberCount rather than == 3 -- it flagged as consistent rather than a defect, and it is left alone. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>
|
Pushed #418 — StrahlenschutztruppThree people like a CSA-Trupp, but the full 30 minutes. With this PR that is a Stammdaten row, not a code change, so it goes into the two shipped examples ( Keeping both three-person types in the demo set is deliberate rather than incidental: two three-person types with different Einsatzzeiten (20 and 30) is exactly what a rule keyed off the designation could never have expressed. The sample now demonstrates the fix instead of merely benefiting from it, and The issue's second point was already done earlier on this branch: The issue's "Zu klären" — that 30 minutes is one brigade's practice, not a universal rule — needs nothing: it lands in the Stammdaten, so it is a Voreinstellung a Wehr can change, which is the whole intent of #398. Review finding 1 — the unclamped Einsatzzeit: taken, and widened slightlyCorrect, and the reasoning about the Floor only, no ceiling. A crew size has a structural ceiling because Covered at each entrance: Review finding 2 —
|
…the defaults Found in review of this PR, and the more serious of the three because it was silent and pointed the wrong way for a safety parameter. The Einsatzzeiten were never constants at runtime. AGT, CSA and LPA each had a row in md_settings, edited in Stammdaten -> Einstellungen, and ScbaViewModel read them from there. The one-time migration ignored all three and wrote the shipped defaults onto the rows instead -- and EnsureSchema then deleted the settings, so the real values were gone. A Wehr that had shortened its CSA-Trupp to 15 minutes came up at 20: longer under air than it had decided on, with no warning and nothing in the Einsatztagebuch. The comment above the DELETE even claimed the migration was allowed to read them; it did not. It reads them now, before the delete, and uses them per row -- csa for the CSA-Trupp, lpa for the LPA-Trupp, agt for everything else -- with the old IncidentSettings defaults only as a per-key fallback. The same fix applies to the legacy JSON branch, where the file being imported still carries those three keys in its settings object: the two entrances agreeing with each other is only worth anything if they agree on the brigade's own numbers. Also from the review: the Atemschutz form's Einsatzzeit spinner stopped at 120 while the Stammdaten editor offered 180, so a Trupp-Typ could be configured and then not registered at its own Einsatzzeit. Both bind one bound now, generous enough for a four-hour LPA, with a test that they cannot drift apart. The review's remaining observation -- RequiresThirdMember reading >= MaxMemberCount rather than == 3 -- it called consistent rather than a defect, and it is left alone. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>
|
Review addressed in 1. Migration discarded the brigade's configured Einsatzzeiten — fixedThis one was right and it was the serious one. The Einsatzzeiten were never constants at runtime: AGT, CSA and LPA each had a row in The reviewer also caught that my comment above the This also corrects a claim in the PR description. I wrote that migration meant "nothing changes for a brigade using the shipped spellings". That was only true for a brigade that had never opened Einstellungen. It is true now. 2. Same loss at the JSON entrance — fixedCorrect, and the framing was the useful part: "the two entrances agreeing with each other just means they are consistently wrong together." A legacy file carries those three keys in its own
3. Three disagreeing spinner bounds — fixedAlso correct: no ceiling in the data, 180 in the editor, 120 on the Atemschutz form. A Trupp-Typ configured above 120 could not be registered at the Einsatzzeit its own row specifies. Both spinners now bind one 4.
|
The changelog rule was never actually written down. AGENTS.md and CONTRIBUTING.md said "add a changelog entry as its own file", which does not say how many, and #431 arrived with seven fragments — one per commit, describing a single feature layer by layer, plus an unrelated build fix. State the rule in both places and in the PR template: exactly one entry per pull request, describing what the change does for the reader rather than the layers it was built in. A PR carrying an unrelated fix folds it into the same entry; if the two cannot share an entry they are two pull requests. Then make the existing fragments follow it. Seven merged pull requests had contributed more than one entry, 22 files between them, now 7 — #313, #310, #355, #390, #395, #411 and #431. The prose is rewritten rather than concatenated, but nothing a reader would act on is dropped: schema versions, migrated JSON keys, file-format compatibility, what changes on first open and what stays untouched all survive, as do the ticket references. The remaining 27 fragments were already one-per-PR and are untouched. `towncrier build --draft` renders 34 entries across Added, Changed, Fixed and Security. Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>

Fixes #398. Closes #397.
The defect
AtemschutzTruppdecided two operational rules by comparing the Trupp's designation against a compiled-in literal:The designation comes from
md_trupp_types— a free-text list the brigade edits in the Stammdaten editor. A Wehr writingCSA Trupp,CSA-Trupp (Chemikalienschutz)orChemietruppgot a two-person CSA-Trupp accepted without complaint, on a 30-minute Einsatzzeit instead of 20. No warning, no fallback, nothing in the Einsatztagebuch. The rule simply was not there any more, and the crew under the suits would have been the ones to find out.The change
A Trupp-Typ carries its own Stärke and Einsatzzeit. The rules follow the type however it is named, and a brigade can give a
Sicherheitstruppor a type of its own the same treatment.Before — just a list of names; the rules lived in the app.
After — Stärke and Einsatzzeit per row; the CSA-Trupp is three people on 20 minutes because its row says so.
The three global Einsatzzeit settings (AGT / CSA / LPA) are gone from Einstellungen, replaced by the per-type value; the Rückzugsdruck and the ILS-Intervalle stay where they were.
Where the crew-size rule lives — the one deliberate departure from #398
The issue proposes that
Register"takes the required crew size and duration as arguments it already half-takes". I went the other way, and this is the part worth reviewing:/masterdatais ever fetched, so both sides always hold the sameMasterDataSetand would compute the same number. A rule you satisfy by restating it is not validation.CommandApplierlook the type up itself means passing aMasterDataSetintoIncident.AddScbaTrupp— andMasterDataSetlives inLageBuch.Persistence, which already referencesLageBuch.Domain.RemoteIncidentSession.Sendis fire-and-forget (_ = SendAsync(...)), so the host's 400 lands in a discarded Task: the ETB line, sent as a separate command, succeeds while the Trupp silently never appears. Locally the sameArgumentExceptionpropagates out ofAddTruppCommandand crashes the UI — the failure Atemschutz: If Truppnummer already exists, application crashes #217 already fixed once. What actually protects the operator isCanAddTruppgreying out the button.So the per-type count is enforced in
ScbaViewModel, the only layer that can read the Stammdaten. The domain keeps what it can prove on its own — and that check is now stronger than before: a crew must fill its positions contiguously from Truppführer, so{Truppführer, 2. Truppmann}with a hole in the middle is rejected where the old duplicate-only check let it through.Trade-off, stated plainly: a hand-crafted sync command could register a two-person "CSA-Trupp". The UI cannot produce one.
Migration
Existing stores migrate once, on first open, mapping the two old names to the rules the old code gave them (
CSA-Trupp→ 3 people,LPA-Trupp→ the longer Einsatzzeit) and carrying over the Einsatzzeiten that store actually had configured — the threemd_settingsrows the brigade edited in Einstellungen — with the oldIncidentSettingsdefaults only as a per-key fallback. Nothing changes for a brigade using the shipped spellings; a brigade that had renamed the type gets a row it can now correct itself.That mapping is the only place a Trupp-Typ name is compared against a literal, it runs once, and:
masterdata.dbend up with identical rows;memberCountis clamped, never rejected, at every entrance. This parses a payload that crossed a trust boundary, andHomeViewModelcatches only the JSON exception types around a sync host's/masterdata— throwing would escape that catch and leak the open hub connection instead of failing the join cleanly.An older exported JSON, where
truppTypesis an array of bare strings, still imports. The reverse is not true: a new sample file opened by an older release fails the import cleanly (Import fehlgeschlagen), which matters because the README linksdemo-stammdaten.jsondirectly.#397, folded in
This PR adds the first new
md_*columns since #397 was filed — the exact case it describes. The drop-column sweep it asks for is now a test, and it found a real gap on its first run:md_personnel's optional columns had noAddColumnIfMissingline. No shipped version ever lacked them, so nothing was broken in practice, but nothing would have caught it either.Verification
dotnet buildclean: analyzers atAnalysisMode=All, StyleCop, warnings as errors.dotnet test: 1362 passed, 0 failed, 1 pre-existing skip.make samplesandmake screenshotsregenerated.docs/screenshots/stammdaten-editor.pngis byte-identical — it renders the Fahrzeuge section, which did not change.StammdatenCatalogue.Find, theTruppTypesSectioneditor, an unlisted designation falling back rather than blocking, and the crew-gap rejection.Not covered by tests, and worth a human doing once before release: opening a real pre-existing
masterdata.dband confirming Trupp-Typen reads CSA-Trupp at 3 / 20.🤖 Generated with Claude Code