Skip to content

Category overview v2: combined bypass with gender-specific gearing (#102) - #142

Merged
Atrium0804 merged 13 commits into
mainfrom
feature/102-category-overview-v2
Nov 18, 2026
Merged

Atrium0804 merged 13 commits into
mainfrom
feature/102-category-overview-v2

Conversation

@Atrium0804

@Atrium0804 Atrium0804 commented Nov 17, 2026 •

Copy link
Copy Markdown
Owner

Closes #102. Closes #143. This is the second, independent build of the combined overview (Leeftijdscategorie, Oude categorie-indeling, Maximaal toegestaan verzet, Licentie in one deterministische bypass answer). This build was chosen over the preserved first build (protocol: #126). #141 is merged into this branch.

Summary

flowchart TD
    A["POST /chat"] --> B{"lookups.recognize_turn<br/>(message + lookup-toestand)"}
    B -- Ready --> C["bypass: flat overview, 0 LLM calls"]
    B -- NeedsInformation --> D["intake → complete_with_intake → bypass or agent"]
    B -- NotEligible --> E["intake → direct-domein / router (never bypass)"]
Loading

Slices, each merged into feature/102-category-overview-v2:

#134  knwu_categories.json  verzetten.per_geslacht + one approved correction (meisjes U9 veld = vrij), drift check on both columns
#137  lookups.py            recognize_turn / complete_with_intake / render_answer, typed decisions, flat answer
#136  main.py, intake.py,   per-conversation lookup-toestand + revision guard, eval replays beurten in order
      run_eval.py
#135  lookups.py + docs     data-only input, closing question, one source per document, reference + ADR-0009 amendment

Reference: docs/reference/categorieoverzicht.md. Routing: docs/explanation/vraag-routing.md.

Evidence

On d470ac3 (content identical to b154e21):

  • .\.venv\Scripts\python.exe -m pytest app\tests tests: 562 passed, 7 skipped (real PDFs not in git), 52 subtests. -m pdf with the local PDFs: 7 passed.
  • pyright: 0 errors. Node app/tests/test_*.cjs: 47/47. The docs link/naming test passes.
  • The routecontract replays every conversation through POST /chat, including adversarial intake extras for rejected input.
  • No live or paid eval was run, and eval/last_run.json is unchanged.

Comparison handoff (#126)

Build Ref Commit
Preserved first build feature/bypass-verzetten-en-categorieen-tonen (local only, not on origin) 2b167b2, based on 2f277c4 (#99)
Second build feature/102-category-overview-v2 (this PR) b154e21 (#141 squash of d470ac3), base origin/main 52f6494

Run both side by side. Use one worktree per build. Each worktree needs its own .venv and .env (CONTRIBUTING: Werkwijze per agentsessie). Use the same .env and start both on the same day:

git worktree add ..\WTChatbot-v1 feature/bypass-verzetten-en-categorieen-tonen
git worktree add ..\WTChatbot-v2 origin/feature/102-category-overview-v2
# in each worktree:
$env:LOCAL_DEBUG_TRACES = "1"
.\.venv\Scripts\python -m uvicorn main:app --app-dir app --host 127.0.0.1 --port 8001   # v2: 8002

Inspect routing. Open http://127.0.0.1:<port>/debug, or search the terminal for chat_trace. The route event shows bypass + regex_lookup (0 LLM calls), intake_lookup, direct-* or router. Both builds have this facility (docs/how-to/bekijk-lokale-routing-traces.md).

Material differences:

  • Date. Both builds take the date from context.today_in_netherlands. It is not configurable, so run them on the same day. Answers depend on the date: the candidate seasons change on 1 March and 1 October.
  • Without an API key (stub mode), deterministic bypasses work in both builds. The intake-assisted path and agent answers need MISTRAL_API_KEY + agent ids, and both builds use the same agents.
  • Base. The preserved build is based on an older main. Its eval set has no peildatum.
  • Known design differences (not regressions):
    • The original build renders nested lists and changes the renderer. v2 uses the flat format from the Combineer categorie, verzet en licentie in bypass met geslachtsspecifieke verzetdata #102 amendment and leaves the renderer unchanged.
    • v2 shows a B1 source line on every bypass answer, with each document once.
    • v2 closes with "Moet ik de KNWU-documenten doorzoeken voor een gedetailleerder antwoord?".
    • Optional discipline: "Welk verzet?" → "2012" gives both disciplines.
  • Known gap in v2 (accepted): questions about a licence package, costs ("kost") or "mijn zoon en mijn dochter" still get the bypass. Eval case knwu-licentie-u13-geen-pakketten will fail in a live run. main has the same gap.
  • Unverified: I did not start the preserved build in this session. Publishing its branch needs a separate instruction.

No agent publication, library sync, deployment or winner selection was done.

Merge Danger

Door: two-way. Code, data and docs only; no migration. The lookup-toestand is in memory.

Blast Radius: routing. All lookup and follow-up routing changes, together with the bypass answer text and format. Feedback storage and agent prompts are unchanged.

Ivo Stieltjes and others added 5 commits November 16, 2026 23:06
* feat(lookups): add typed category overview module (#137)

Co-authored-by: Copilot <[email protected]>

* fix(lookups): tighten category recognition and intake (#137)

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Ivo Stieltjes <[email protected]>
Co-authored-by: Copilot <[email protected]>
…ing (#136) (#140)

* feat(chat): integrate category overview lookups with safe state ordering (#136)

Chat, intake and eval now share recognize_turn, complete_with_intake and
render_answer. Each conversation keeps a revisioned lookup state, separate
from feedback history; a background intake job only publishes its state if
its revision is still current. Intake can complete only NeedsInformation,
never rescue rejected input. The legacy match_lookup/resolve_lookup_message
adapters are removed.

Co-authored-by: Copilot <[email protected]>

* refactor(chat): address review of lookup integration (#136)

Route becomes a tagged union with one shared route_reason for app and
eval; the accepted turn travels to the job as one LookupTurn. The eval
replay now completes an earlier incomplete beurt with the intake, like the
app. GLOSSARY no longer says the intake fills in discipline or works with
the regex lookup.

Co-authored-by: Copilot <[email protected]>

* test(chat): give every chat-test client one long-lived event loop (#136)

A bare TestClient runs each request in its own event loop, so a background
chat job could be stranded and time out (seen in CI on
test_chat_sends_language_level_context).

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Ivo Stieltjes <[email protected]>
Co-authored-by: Copilot <[email protected]>
…141)

* feat(lookups): name each source once and label the club source (#135)

The bypass source line listed ALGEMENE BEPALINGEN twice (age categories and licences). Each document now appears once; at B2 its articles are merged. The old-category mapping source is labelled as club source.

Co-authored-by: Copilot <[email protected]>

* docs(categories): reference, routing, ADR-0009 amendment and drift notes (#135)

Add docs/reference/categorieoverzicht.md, link it from the routing explanation, record the B1 source exception for every bypass answer as an ADR-0009 amendment, add Peiljaar to the glossary, document the stale_revision trace event and the approved-correction rule for document changes.

Co-authored-by: Copilot <[email protected]>

* feat(lookups): data-only lookup messages and closing question (#135)

Recognize messages that contain only lookup data, e.g. 'jongen uit 2015, U12, weg' (the #102/#125 example), as a first message and as a reply to a pending lookup; a bare year in such a message is a birth year. Routecontract rows added. Bypass answers now end with 'Moet ik de KNWU-documenten doorzoeken voor een gedetailleerder antwoord?'. Error messages in max_gear, complete_with_intake, render_answer and decide_route now state an action (CODING_PRINCIPLES).

Co-authored-by: Copilot <[email protected]>

* docs(categories): data-only input and closing question (#135)

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Ivo Stieltjes <[email protected]>
Co-authored-by: Copilot <[email protected]>
@Atrium0804

Copy link
Copy Markdown
Owner Author

Ter info vanuit #143 (geboortejaar als antwoord op een vraag van de agent gaat naar de bypass).

Deze PR verruimt dat probleem. Na een inhoudelijke vraag (geen lookup), bijvoorbeeld "Aan welke voorwaarden moet mijn dochter voldoen om mee te doen aan een clubwedstrijd?", gaan deze antwoorden op main naar de agent, maar op deze branch naar de bypass:

  • geboren in 2014
  • 2014, meisje
  • 2014 weg
  • meisje 2014

Een kaal 2014 gaat op beide naar de bypass; dat is #143 zelf. Na een echte (onvolledige) lookup moeten deze vervolgen wél bypassen; het gaat alleen om de context na een inhoudelijke beurt.

Graag in deze PR bewust kiezen: inperken, of accepteren en laten oplossen door #143. In het laatste geval neemt #143 deze vier formuleringen mee in de acceptatiecriteria.

Ivo Stieltjes and others added 4 commits November 18, 2026 11:47
Ready -> ReadyForBypass, NeedsInformation -> NeedsInputForBypass, NotEligible -> NotEligibleForBypass, LookupDecision -> BypassDecision, eligible -> eligible_for_bypass, revision -> accepted_turn_count. Trace-redenen en route_reden blijven ongewijzigd.

Co-authored-by: Copilot <[email protected]>
Tien regels falen bewust: een kaal jaartal, alleen gegevens of een fragment na een inhoudelijke beurt gaat nu naar de bypass in plaats van naar de agent. Twee regels bewaken bestaand gedrag (#102: los jaartal als eerste beurt; #91: zelfstandige lookupvraag midden in een gesprek).

Co-authored-by: Copilot <[email protected]>
…up (#143)

Een kaal jaartal, alleen gegevens ("2014, meisje") of een losse oude categorie zonder open of voltooide lookup is een vervolgbericht op de vorige beurt. recognize_turn krijgt daarvoor is_first_turn, afgeleid van accepted_turn_count. Na een inhoudelijke beurt gaat zo'n bericht naar de agent; als eerste beurt en als vervolg op een lookup blijft de bypass (#102, #91/#136).

Glossary: Gesprek, Beurt, Agentgesprek en Vervolgbericht.

Co-authored-by: Copilot <[email protected]>
B1-bypass eindigt op de slotvraag zonder Bron-regel (4cd5190); de achtergrond is sinds 2ad94d8 liggend.

Co-authored-by: Copilot <[email protected]>
@Atrium0804
Atrium0804 marked this pull request as ready for review November 18, 2026 12:43
@Atrium0804
Atrium0804 merged commit d3a4410 into main Nov 18, 2026
10 checks passed
@Atrium0804
Atrium0804 deleted the feature/102-category-overview-v2 branch November 18, 2026 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant