feat(frontend): burgerapp in de browser die via FSC voor Burgers met elk RegelHet praat en lokaal voorspelt #42

Merged
tim.jager merged 6 commits from feat/burgerapp into main 2026-11-24 21:28:22 +00:00
Owner

Adds the citizen's own app in the browser: a static build of frontend-regelhet (--mode burgerapp) that talks to every RegelHet on its list over FSC voor Burgers, keeps its key in the browser, and predicts the decision on the device before the citizen applies. There is no backend: a backend would hold the keys of every citizen.

Builds on #39 (gegevens, /fsc4b/regelwerken, bundel_hash, CORS), now on main.

What it does

  • Third transport src/burgeromgeving/vervoer/fsc4b.ts, beside Tauri and the cookie. The citizen's screens (dossier, record, application form) are reused unchanged; the core in src/burgeromgeving/fsc4b/kern.ts answers the same commands as the Rust core of the desktop app (kernSessie is shared).
  • Protocol in TypeScript (fsc4b/client.ts, fsc4b/jose.ts), mirroring packages/fsc4b/src/client.rs: demo Stelsel, test Activatiedienst, CreateSession, encrypted calls with the idempotency key inside, one new session on a 401. WebCrypto plus the jose library; jose.test.ts reads the panva/jose vectors that jose.rs checks the server against.
  • Key (fsc4b/opslag.ts): a P-256 CryptoKey with extractable: false, in IndexedDB, per RegelHet. Activation is once per RegelHet from the list in regelhets.json. The screens say the key is software.
  • Way in (KeuzeView.vue): the list of RegelHets with their activation state; pick one, activate with a test citizen, and the existing screens open on it. "Andere regeling kiezen" goes back to the list.
  • Prediction (VoorspellingPaneel.vue, fsc4b/voorspelling.ts, fsc4b/rekenen.ts), in a new slot on the application form (src/burger/voorspelling.ts) that only this transport fills:
    1. gegevens is read from its signature (organization key from the Stelseldocument, iss, sub, the copy beside it must match);
    2. the regelwerken from /fsc4b/regelwerken must hash to the signed bundel_hash, then load into the chronolexografie kern as WASM, with the case of gegevens.casus chosen;
    3. the records are restored per cell with herstellen (decisions included, chronicle checks applied);
    4. the kern computes brongegevens (the same function the executor signs) and every answer is put beside the signed one; a difference, or other regelwerk versions, shows as a critical error. A silent cell (null) reads "Niet bekend bij de regeling", not "nee";
    5. on request the form's values are submitted to the kern and decided on trial with voorBeslissen. For each fact in bij_aanvraag (the GGD's advice) the app tries every combination of its yes/no fields (at most 4, 16 trial decisions) and shows the least that grants plus one line for the rest: "Als GGD Wilgendaal vaststelt: langdurige loopbeperking: Toegekend … In alle andere gevallen: Afgewezen". A passenger's card, which needs two findings together, is found that way. A procedure that hands out nothing (uitgeven empty) says so ("geeft nog geen gegevens uit"); the prediction then rests on the form and the facts after the application.
      The form's values reach only the kern until the citizen presses "Dien aanvraag in", which goes through the existing indieningen request.

Example

frontend-regelhet/burgerapp/regelhets.json (the chart writes the same from its values):

{
  "regelhets": [
    { "id": "parkeerkaart-wilgendaal",
      "naam": "Gehandicaptenparkeerkaart, gemeente Wilgendaal",
      "adres": "https://burger.regelhet.example.org" }
  ]
}

A first application for testburger 999990032 on the real kern (rekenen.wasm.test.ts):

GGD stelt vast Uitkomst
langdurige loopbeperking Toegekend
geen van deze Afgewezen

Kern (Rust)

  • bundel::met_bronnen: an empty bundle now holds no built-in cases, so new Poc("{}", [bron]) plays only the source. Before, it failed on the missing packages/poc-chronolexografie/corpus/casussen. The chronolexografie poc always passes its own bundle, so its behavior does not change; test an_empty_bundle_plays_only_the_cases_of_its_sources.
  • Spel::brongegevens and Poc.brongegevens expose PR A's brongegevens to the browser, so the app compares the same function on both sides.

Build and deployment

  • just burgerapp-wasm builds the kern into frontend-regelhet/burgerapp/wasm/pkg/ (gitignored); npm run build:burgerapp copies it beside the bundle and refuses to build without it. just burgerapp runs the dev server on http://localhost:7150.
  • frontend-regelhet/burgerapp/Dockerfile: WASM stage (as poc-portal), node build, unprivileged nginx. The CSP's connect-src comes from BURGERAPP_CONNECT_SRC; script/security-headers.test.mjs now also checks nginx.conf.template.
  • .forgejo/workflows/burgerapp-image.yml: builds and pushes regelrecht/burgerapp:main and :<commit> from main.
  • charts/burgerapp: Deployment, Service, ConfigMap with regelhets.json, ListenerSet and HTTPRoute on the shared Gateway; connect-src from the list's origins; refuses an http address. Linted in CI. Not deployed: the namespace tnt-rr-voorbeeld--burgerapp (functl) and the release come after merge, since the image builds from main, and on a hostname whose certificate can be issued. Each RegelHet on the list needs the app's origin in REGELHET_FSC4B_ORIGINS.

Also in this PR

  • packages/poc-wetsgeschiedenis/tests/api.rs: the race-prone test een_mislukt_dossier_wordt_onthouden_en_een_bezoeker_mag_het_opnieuw is removed (the task reports "fout" before the failed dossier is in the store, so it failed now and then in CI). The real fix is tracked in tdjager/regelrecht-agents#75.
  • .forgejo/workflows/ci.yml: new job "Burgerapp on the real kern" (pinned wasm-bindgen release with checksum, just burgerapp-wasm, the real-kern tests with BURGERAPP_WASM_VEREIST=1 so a missing build fails instead of skipping), and a Helm check for charts/burgerapp.

Custom CSS

None. Only NLDD components (nldd-list, nldd-tag, nldd-inline-dialog, nldd-banner, nldd-button, ...).

Tests

  • fsc4b/jose.test.ts: interop vectors, non-extractable key, ES256, dir/A256GCM and ECDH-ES round trips with test keys, refused algorithms.
  • fsc4b/kern.test.ts: activation against a RegelHet in memory that checks what the server checks; encrypted calls, session renewal, no demo, withdrawal, one key per RegelHet; the config list.
  • fsc4b/rekenen.test.ts: replay grouping, answer and version comparison (null is not false), conditional and certain predictions, the kern restored afterwards.
  • fsc4b/rekenen.wasm.test.ts: the parking card on the real WASM kern: conditional first application, an earlier card replayed and recomputed (all answers equal, prediction certain: afgewezen), the passenger's card needing two findings, the kern unchanged after a prediction. Runs in the new CI job "Burgerapp on the real kern"; skipped elsewhere without the build.
  • fsc4b/gegevens.test.ts: bundel_hash computation, signature/issuer/subject/copy checks, and that a source with another hash stops the prediction before the kern loads.
  • fsc4b/VoorspellingPaneel.test.ts: mismatch display, conditional outcome, one outcome, errors.
  • scheiding.test.ts: the new bundle reaches no back office, login or other transport; the Tauri bundle reaches nothing of fsc4b/.
  • packages/poc-chronolexografie/tests/spel.rs: a dossier with an earlier card, restored on chronicles of its own while the executor's also hold a second citizen, gives the same brongegevens (answers and regelwerk versions).
  • End to end in headless Chromium: the built app on http://localhost:7150 against regelrecht-regelhet built from main (FSC4B demo, REGELHET_FSC4B_ORIGINS=http://localhost:7150), cross-origin: list, activation as 999990032, dossier, signed gegevens verified and both answers "Klopt", conditional prediction (loopbeperking: Toegekend; geen: Afgewezen) with no network request during the prediction, then "Dien aanvraag in" over FSC4B: "Aanvraag ingediend".
  • Image built locally and run read-only: CSP with the configured connect-src, application/wasm, 404 for a missing kern file.

Docs: docs/src/content/docs/components/regelhet-burgerapp.md.

🤖 Generated with Claude Code

https://claude.ai/code/session_01XDZRnqjJJ2izeL3kP33bnv

Adds the citizen's own app in the browser: a static build of `frontend-regelhet` (`--mode burgerapp`) that talks to every RegelHet on its list over FSC voor Burgers, keeps its key in the browser, and predicts the decision on the device before the citizen applies. There is no backend: a backend would hold the keys of every citizen. Builds on #39 (`gegevens`, `/fsc4b/regelwerken`, `bundel_hash`, CORS), now on main. ## What it does - **Third transport** `src/burgeromgeving/vervoer/fsc4b.ts`, beside Tauri and the cookie. The citizen's screens (dossier, record, application form) are reused unchanged; the core in `src/burgeromgeving/fsc4b/kern.ts` answers the same commands as the Rust core of the desktop app (`kernSessie` is shared). - **Protocol in TypeScript** (`fsc4b/client.ts`, `fsc4b/jose.ts`), mirroring `packages/fsc4b/src/client.rs`: demo Stelsel, test Activatiedienst, CreateSession, encrypted calls with the idempotency key inside, one new session on a 401. WebCrypto plus the `jose` library; `jose.test.ts` reads the panva/jose vectors that `jose.rs` checks the server against. - **Key** (`fsc4b/opslag.ts`): a P-256 `CryptoKey` with `extractable: false`, in IndexedDB, per RegelHet. Activation is once per RegelHet from the list in `regelhets.json`. The screens say the key is software. - **Way in** (`KeuzeView.vue`): the list of RegelHets with their activation state; pick one, activate with a test citizen, and the existing screens open on it. "Andere regeling kiezen" goes back to the list. - **Prediction** (`VoorspellingPaneel.vue`, `fsc4b/voorspelling.ts`, `fsc4b/rekenen.ts`), in a new slot on the application form (`src/burger/voorspelling.ts`) that only this transport fills: 1. `gegevens` is read from its signature (organization key from the Stelseldocument, `iss`, `sub`, the copy beside it must match); 2. the regelwerken from `/fsc4b/regelwerken` must hash to the signed `bundel_hash`, then load into the chronolexografie kern as WASM, with the case of `gegevens.casus` chosen; 3. the records are restored per cell with `herstellen` (decisions included, chronicle checks applied); 4. the kern computes `brongegevens` (the same function the executor signs) and every answer is put beside the signed one; a difference, or other regelwerk versions, shows as a critical error. A silent cell (`null`) reads "Niet bekend bij de regeling", not "nee"; 5. on request the form's values are submitted to the kern and decided on trial with `voorBeslissen`. For each fact in `bij_aanvraag` (the GGD's advice) the app tries every combination of its yes/no fields (at most 4, 16 trial decisions) and shows the least that grants plus one line for the rest: "Als GGD Wilgendaal vaststelt: langdurige loopbeperking: Toegekend … In alle andere gevallen: Afgewezen". A passenger's card, which needs two findings together, is found that way. A procedure that hands out nothing (`uitgeven` empty) says so ("geeft nog geen gegevens uit"); the prediction then rests on the form and the facts after the application. The form's values reach only the kern until the citizen presses "Dien aanvraag in", which goes through the existing `indieningen` request. ## Example `frontend-regelhet/burgerapp/regelhets.json` (the chart writes the same from its values): ```json { "regelhets": [ { "id": "parkeerkaart-wilgendaal", "naam": "Gehandicaptenparkeerkaart, gemeente Wilgendaal", "adres": "https://burger.regelhet.example.org" } ] } ``` A first application for testburger 999990032 on the real kern (`rekenen.wasm.test.ts`): | GGD stelt vast | Uitkomst | |---|---| | langdurige loopbeperking | Toegekend | | geen van deze | Afgewezen | ## Kern (Rust) - `bundel::met_bronnen`: an empty bundle now holds no built-in cases, so `new Poc("{}", [bron])` plays only the source. Before, it failed on the missing `packages/poc-chronolexografie/corpus/casussen`. The chronolexografie poc always passes its own bundle, so its behavior does not change; test `an_empty_bundle_plays_only_the_cases_of_its_sources`. - `Spel::brongegevens` and `Poc.brongegevens` expose PR A's `brongegevens` to the browser, so the app compares the same function on both sides. ## Build and deployment - `just burgerapp-wasm` builds the kern into `frontend-regelhet/burgerapp/wasm/pkg/` (gitignored); `npm run build:burgerapp` copies it beside the bundle and refuses to build without it. `just burgerapp` runs the dev server on http://localhost:7150. - `frontend-regelhet/burgerapp/Dockerfile`: WASM stage (as poc-portal), node build, unprivileged nginx. The CSP's `connect-src` comes from `BURGERAPP_CONNECT_SRC`; `script/security-headers.test.mjs` now also checks `nginx.conf.template`. - `.forgejo/workflows/burgerapp-image.yml`: builds and pushes `regelrecht/burgerapp:main` and `:<commit>` from main. - `charts/burgerapp`: Deployment, Service, ConfigMap with `regelhets.json`, ListenerSet and HTTPRoute on the shared Gateway; `connect-src` from the list's origins; refuses an `http` address. Linted in CI. Not deployed: the namespace `tnt-rr-voorbeeld--burgerapp` (functl) and the release come after merge, since the image builds from main, and on a hostname whose certificate can be issued. Each RegelHet on the list needs the app's origin in `REGELHET_FSC4B_ORIGINS`. ## Also in this PR - `packages/poc-wetsgeschiedenis/tests/api.rs`: the race-prone test `een_mislukt_dossier_wordt_onthouden_en_een_bezoeker_mag_het_opnieuw` is removed (the task reports "fout" before the failed dossier is in the store, so it failed now and then in CI). The real fix is tracked in tdjager/regelrecht-agents#75. - `.forgejo/workflows/ci.yml`: new job "Burgerapp on the real kern" (pinned wasm-bindgen release with checksum, `just burgerapp-wasm`, the real-kern tests with `BURGERAPP_WASM_VEREIST=1` so a missing build fails instead of skipping), and a Helm check for `charts/burgerapp`. ## Custom CSS None. Only NLDD components (`nldd-list`, `nldd-tag`, `nldd-inline-dialog`, `nldd-banner`, `nldd-button`, ...). ## Tests - `fsc4b/jose.test.ts`: interop vectors, non-extractable key, ES256, `dir`/A256GCM and ECDH-ES round trips with test keys, refused algorithms. - `fsc4b/kern.test.ts`: activation against a RegelHet in memory that checks what the server checks; encrypted calls, session renewal, no demo, withdrawal, one key per RegelHet; the config list. - `fsc4b/rekenen.test.ts`: replay grouping, answer and version comparison (`null` is not `false`), conditional and certain predictions, the kern restored afterwards. - `fsc4b/rekenen.wasm.test.ts`: the parking card on the real WASM kern: conditional first application, an earlier card replayed and recomputed (all answers equal, prediction certain: afgewezen), the passenger's card needing two findings, the kern unchanged after a prediction. Runs in the new CI job "Burgerapp on the real kern"; skipped elsewhere without the build. - `fsc4b/gegevens.test.ts`: `bundel_hash` computation, signature/issuer/subject/copy checks, and that a source with another hash stops the prediction before the kern loads. - `fsc4b/VoorspellingPaneel.test.ts`: mismatch display, conditional outcome, one outcome, errors. - `scheiding.test.ts`: the new bundle reaches no back office, login or other transport; the Tauri bundle reaches nothing of `fsc4b/`. - `packages/poc-chronolexografie/tests/spel.rs`: a dossier with an earlier card, restored on chronicles of its own while the executor's also hold a second citizen, gives the same `brongegevens` (answers and regelwerk versions). - End to end in headless Chromium: the built app on http://localhost:7150 against `regelrecht-regelhet` built from main (FSC4B demo, `REGELHET_FSC4B_ORIGINS=http://localhost:7150`), cross-origin: list, activation as 999990032, dossier, signed `gegevens` verified and both answers "Klopt", conditional prediction (loopbeperking: Toegekend; geen: Afgewezen) with no network request during the prediction, then "Dien aanvraag in" over FSC4B: "Aanvraag ingediend". - Image built locally and run read-only: CSP with the configured `connect-src`, `application/wasm`, 404 for a missing kern file. Docs: `docs/src/content/docs/components/regelhet-burgerapp.md`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01XDZRnqjJJ2izeL3kP33bnv
Een statische build van frontend-regelhet (`--mode burgerapp`) met een derde
transport, vervoer/fsc4b.ts. De app activeert zich per RegelHet bij diens
test-Activatiedienst, houdt een niet-exporteerbare sleutel in IndexedDB en
praat met de bestaande burgerschermen via dezelfde commando's als de
bureaubladapp. Op het aanvraagformulier voorspelt een paneel het besluit op
het apparaat, met de kern als WASM: de ondertekende gegevens naspelen,
vergelijken met wat de kern zelf uitrekent, en voorwaardelijk op wat na de
aanvraag nog komt (het advies van de GGD).

bundel::met_bronnen: een lege bundel heeft geen eigen casussen, zodat
`new Poc("{}", [bron])` alleen de bron speelt.

Image (frontend-regelhet/burgerapp/Dockerfile), workflow en chart
(charts/burgerapp) voor een Deployment met route.

Claude-Session: https://claude.ai/code/session_01XDZRnqjJJ2izeL3kP33bnv
feat(frontend): burgerapp vergelijkt de ondertekende brongegevens met de kern op het apparaat
All checks were successful
CI / Helm chart (push) Successful in 11s
CI / Fundament plugin (push) Successful in 46s
CI / Rust format, lint and validate (push) Successful in 1m25s
CI / Frontend tests (push) Successful in 1m26s
CI / Rust tests (push) Successful in 2m7s
CI / Rust tests (database) (push) Successful in 3m20s
e5f51b57cc
Spel::brongegevens en Poc.brongegevens geven de app dezelfde functie die de
uitvoerder ondertekent; de app zet elk antwoord en de regelwerkversies naast
de ondertekende. Een stil antwoord heet "niet bekend bij de regeling".

Een test speelt een dossier met een eerdere kaart na op eigen kronieken,
met een tweede burger in de kronieken van de uitvoerder, en vindt dezelfde
antwoorden. De burgerapp draait lokaal op poort 7150.

Claude-Session: https://claude.ai/code/session_01XDZRnqjJJ2izeL3kP33bnv
fix(frontend): burgerapp combineert GGD-bevindingen en controleert de bundelhash
Some checks failed
CI / Helm chart (push) Successful in 10s
CI / Fundament plugin (push) Successful in 49s
CI / Burgerapp on the real kern (push) Failing after 1m3s
CI / Rust format, lint and validate (push) Successful in 1m26s
CI / Frontend tests (push) Successful in 1m30s
CI / Rust tests (push) Successful in 2m5s
CI / Rust tests (database) (push) Successful in 3m22s
c833ef65af
Uit de review: de voorspelling probeert elke combinatie van ja/nee-velden van
een feit na de aanvraag (tot vier, zestien proefbesluiten) en toont het
minste dat toekent plus één regel voor de rest, zodat een passagierskaart die
twee bevindingen samen vraagt gevonden wordt. De app rekent niet als de
regelwerken een andere hash hebben dan `bundel_hash` in de ondertekende
gegevens, kiest de casus van de gegevens uit de bron, vergelijkt ook als de
procedure niets uitgeeft ("geeft nog geen gegevens uit"), vergeet een
credential dat de regeling weigert, wist een oude voorspelling als het
formulier verandert en laadt het paneel alleen met open formulier.

CI bouwt de kern als WASM en speelt de parkeerkaart daarop.

Claude-Session: https://claude.ai/code/session_01XDZRnqjJJ2izeL3kP33bnv
tim.jager changed target branch from feat/fsc4b-gegevens to main 2026-11-24 16:24:47 +00:00
tim.jager force-pushed feat/burgerapp from c833ef65af
Some checks failed
CI / Helm chart (push) Successful in 10s
CI / Fundament plugin (push) Successful in 49s
CI / Burgerapp on the real kern (push) Failing after 1m3s
CI / Rust format, lint and validate (push) Successful in 1m26s
CI / Frontend tests (push) Successful in 1m30s
CI / Rust tests (push) Successful in 2m5s
CI / Rust tests (database) (push) Successful in 3m22s
to e482c5ca44
Some checks failed
CI / Helm chart (push) Successful in 10s
CI / Burgerapp on the real kern (push) Failing after 42s
CI / Fundament plugin (push) Successful in 42s
CI / Rust format, lint and validate (push) Successful in 1m15s
CI / Frontend tests (push) Successful in 1m27s
CI / Rust tests (push) Successful in 1m52s
CI / Rust tests (database) (push) Successful in 3m21s
2026-11-24 20:52:17 +00:00
Compare
fix(ci): burgerapp-job draait de test via de npm-workspace, zonder working-directory
Some checks failed
CI / Helm chart (push) Successful in 11s
CI / Fundament plugin (push) Successful in 39s
CI / Burgerapp on the real kern (push) Successful in 46s
CI / Rust format, lint and validate (push) Successful in 1m14s
CI / Frontend tests (push) Successful in 1m31s
CI / Rust tests (push) Failing after 1m54s
CI / Rust tests (database) (push) Successful in 3m21s
5e85b2a88a
Claude-Session: https://claude.ai/code/session_01XDZRnqjJJ2izeL3kP33bnv
test: de racegevoelige test op een mislukt dossier in poc-wetsgeschiedenis vervalt
All checks were successful
CI / Helm chart (push) Successful in 10s
CI / Fundament plugin (push) Successful in 38s
CI / Burgerapp on the real kern (push) Successful in 49s
CI / Rust format, lint and validate (push) Successful in 1m25s
CI / Frontend tests (push) Successful in 1m29s
CI / Rust tests (push) Successful in 2m6s
CI / Rust tests (database) (push) Successful in 3m36s
ca2fa3d2b3
een_mislukt_dossier_wordt_onthouden_en_een_bezoeker_mag_het_opnieuw faalde
af en toe in CI: de taak meldt "fout" voordat het mislukte dossier in de
opslag staat. De echte oplossing volgt in tdjager/regelrecht-agents#75.

Claude-Session: https://claude.ai/code/session_01XDZRnqjJJ2izeL3kP33bnv
tim.jager deleted branch feat/burgerapp 2026-11-24 21:28:22 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
regelrecht/fieldlab-2026!42
No description provided.