Skip to content

Category overview v2: chat, intake and eval integration with safe state ordering #136

Closed

Description

@Atrium0804

Goal

Integrate the pure lookup module into the real chat, intake, context and eval flows for the independent second implementation of Combineer categorie, verzet en licentie in bypass met geslachtsspecifieke verzetdata.

Use the recognition/state-model resolution, the pure-module slice's typed interface, and the flat-output amendment. Do not build another parser in chat or intake.

Storage and request contract

  • Store per-conversation lookup state separately from bounded feedback history, inside the existing app-owned in-memory state. No database migration or new persistence layer is required. Fresh app/conversation means no lookup profile; clear/reset behavior follows the agreed state model.
  • Keep a monotonically increasing lookup revision per conversation. At acceptance of a valid chat request, increment the revision, recognize against the current profile, and commit its proposed next lookup state before awaiting external work. Rate-limited/invalid HTTP requests do not create lookup turns.
  • Ready returns the existing synchronous bypass response with zero intake/agent calls. NeedsInformation alone may call complete_with_intake after the existing intake call. NotEligible can still use intake for expert/router selection, but may never be re-recognized with intake fields into a bypass.
  • Background jobs capture their request's decision, date and revision. Publish any subsequent lookup-state update only if that revision is still current; use a synchronous compare-and-set without an intervening await, or an equivalent narrowly scoped atomic operation under the existing execution model. An older success or failure must not restore or clear newer lookup state.
  • Each job keeps its existing own response/status behavior; do not cancel old jobs, reject concurrent questions, redesign agent-conversation concurrency, reorder feedback history, or silently change response semantics. The revision guard protects lookup state only. Use existing route/trace mechanisms, and surface genuine internal errors using repository conventions rather than success-shaped fallbacks.
  • Preserve raw user text for feedback, source-aware deterministic context for agents, existing B1/B2 context and date injection, and valid standalone lookups. Do not infer lookup state from feedback history or agent answer text. Profile values used in a substantive answer must follow the agreed clearing rules, not resurrect cleared filters.

Eval and callers

Migrate eval/run_eval.py and directly dependent callers to the same recognize/complete/render operations and sequential state transitions. Replay existing beurten as ordered user inputs through that module, not by concatenating text or scanning rendered answers. Use its existing fixed peildatum, and retain the recorded distinction between deterministic bypass, intake-assisted bypass and substantive routes. Update affected offline fixtures/tests; do not perform a paid live eval or claim one ran. Remove old duplicate/transitional recognition adapters once every caller is migrated.

Test-first integration checks

  • Add/update app/tests/fixtures/routecontract.yaml rows with herkomst before the routing code changes. Run through actual POST /chat, including adversarial intake extras for rejected inputs. Preserve earlier regression families; update old expectations only where the new specification deliberately changes behavior.
  • Check answer facts/profile state as well as routes in focused chat tests: new primary filter replacement, standalone reset, same-topic why/reset, pending completion, single-prefix gender change versus paired/old selector filtering, and no stale inheritance after rejection/topic change.
  • Prove ordering deterministically with controlled intake events/barriers, not sleeps: pause an older intake job, accept a newer completed or cleared lookup turn, then release the older job. Both its successful completion and failure must leave the newer profile unchanged. Prove a normal current intake completion can commit, and conversation state is isolated.
  • Check that supported complete questions and short replies cause no extra model calls. Test the actual flow, not only mocked recognition return values.

Run targeted chat/route-contract/intake/context/eval/lookup tests and pyright; extend only the existing test runner/tooling. Review and commit the slice. Work in a new branch/worktree from feature/102-category-overview-v2 after the pure-module slice is merged, and PR into that integration branch. Do not deploy the partial build or modify the preserved first branch.

Prerequisite: Category overview v2: pure recognition, profile transitions and flat answers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ready-for-agent

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions