Skip to content

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

Merged
Atrium0804 merged 3 commits into
feature/102-category-overview-v2from
issue-136-chat-integration-v2
Nov 17, 2026
Merged

Atrium0804 merged 3 commits into
feature/102-category-overview-v2from
issue-136-chat-integration-v2

Conversation

@Atrium0804

Copy link
Copy Markdown
Owner

Summary

Chat, intake and eval now share recognize_turn → complete_with_intake → render_answer; each conversation keeps a revisioned lookup state, separate from the feedback history.

 POST /chat
-  resolve_lookup_message(feedback history) + match_lookup
+  recognize_turn(message, lookup state)        # state + revision committed synchronously
+  Ready            -> 200, 0 model calls
   else 202 + job
     classify_message (intake)
-    decide_route(message, intake)               # could rescue rejected input
+    decide_route(decision, intake)              # only NeedsInformation may become a bypass
+    publish lookup state only if revision is still current

Removed: match_lookup, render_lookup_answer, resolve_lookup_message. The eval replays beurten in order through the same operations (with intake completion for an earlier incomplete turn) and records route_reden.

Deliberate route changes, each with a routecontract row (herkomst):

Evidence

  • Before: 18 new routecontract rows red against the legacy flow.
    After: routecontract 53/53 green.
  • Ordering: an older intake job is paused with a barrier while a newer completed/cleared turn is accepted, then released (success and failure). With the revision check disabled, both success cases fail; with it, all pass.
  • Full Python suite: 550 passed, 7 skipped; pyright 0 errors; Node 48/48; docs link check green. No live/paid eval was run.

Merge Danger

Door: two-way

Pure code/test/doc change into the integration branch; no data migration, persistence or deployment.

Blast Radius: routing

Which messages bypass vs. go to an agent changes as listed above; eval bypass expectations were updated accordingly.

Closes #136

Ivo Stieltjes and others added 3 commits November 17, 2026 10:00
…ing (#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]>
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]>
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]>
@Atrium0804
Atrium0804 merged commit b9ac7f8 into feature/102-category-overview-v2 Nov 17, 2026
10 checks passed
@Atrium0804
Atrium0804 deleted the issue-136-chat-integration-v2 branch November 17, 2026 10:01
Atrium0804 added a commit that referenced this pull request Nov 18, 2026
) (#142)

* feat(categories): add gender-specific gearing data (#134)

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

* test(categories): reject unknown source gear values (#134)

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

* feat(lookups): typed category overview module (#137) (#139)

* 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]>

* feat(chat): integrate category overview lookups with safe state ordering (#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]>

* Category overview v2: final validation, docs and review fixes (#135) (#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]>

* fix((bypass): niet verwijzen naar clubsite
fix(bypass): geen bronregel in taalniveau B1

* fix(UI): liggende achtergrond t.b.v. bredere schermformaten

* chore(contributing): geen worktree aanmaken, werk altijd op een featurebranch

* chore: code-review lookups.py

* refactor(routing): beschrijvende namen voor de bypassbeslissing (#143)

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]>

* test(routecontract): los gegeven na een inhoudelijke beurt (#143)

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]>

* fix(routing): los gegeven is alleen in de eerste beurt een eigen lookup (#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]>

* test: verouderde verwachtingen na slotvraag en liggende achtergrond

B1-bypass eindigt op de slotvraag zonder Bron-regel (4cd5190); de achtergrond is sinds 2ad94d8 liggend.

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

---------

Co-authored-by: Ivo Stieltjes <[email protected]>
Co-authored-by: Copilot <[email protected]>
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.

1 participant