Add a registry of pending decisions for decision_required events #24

Closed
opened 2026-11-16 16:27:18 +01:00 by michael · 1 comment
Owner

Problem

A program that asks a question with a decision_required event has to
remember the event until the answer comes: which event was asked, which
field it declared, and whether it was answered already. Today nothing
does that. A response is matched by operation_id only, and berhtjan-cli
asks the user before the declared field has been checked completely.
Every host (cli, web, api) needs the same thing, and berhtjan-core
already holds the field check and the response check.

Scope

A registry of pending decisions in its own file in berhtjan-core, held in
memory by the host (signatures to be agreed before implementation):

  • add a decision_required event: it is checked completely once (schema,
    type, declared field with the field-type check, response source
    rules); a faulty event is an error and is not stored; an event_id
    that is already pending is an error
  • hand in a daw_event_response/v1: the registry finds the event by
    event_id, checks operation_id, source and the value against the
    declared field, removes the event and returns event and value; an
    unknown event_id, a mismatching operation_id, an invalid value and
    a second response are different errors
  • list what is pending (for UIs that ask later or elsewhere)
  • errors as daw_error/v1, one resource_id per error site; texts as
    daw_i18n/v1 resources en/de
  • no persistence: the registry lives and dies with the host process

Resuming the operation (calling the module again with the response)
stays with the host.

Depends on

  • DAW/daw-contracts: companion issue on the typed answer field and the
    receiver rules (the place of the field decides what the registry reads)
  • the response check of build_response is reused; the defects found in
    its review are a separate issue and should be fixed first

Out of scope

  • transport and persistence across processes (mainjan, later)
  • the presentation of questions (adapters)

Acceptance criteria

  • signatures agreed before implementation
  • tests first: add, answer, unknown event, wrong operation, invalid
    value, second response, pending list, faulty event
  • own texts as daw_i18n/v1 resources, resource_id per error site
  • fragjan code . and make test (Lua 5.1 and 5.4) pass
  • README documents it

DAW/daw-contracts (companion issue), DAW/daw-modul-berhtjan-core#21,
DAW/daw-modul-berhtjan-cli#15, DAW/daw-module-manager (companion issue)

## Problem A program that asks a question with a `decision_required` event has to remember the event until the answer comes: which event was asked, which field it declared, and whether it was answered already. Today nothing does that. A response is matched by `operation_id` only, and berhtjan-cli asks the user before the declared field has been checked completely. Every host (cli, web, api) needs the same thing, and berhtjan-core already holds the field check and the response check. ## Scope A registry of pending decisions in its own file in berhtjan-core, held in memory by the host (signatures to be agreed before implementation): - add a `decision_required` event: it is checked completely once (schema, type, declared field with the field-type check, response `source` rules); a faulty event is an error and is not stored; an `event_id` that is already pending is an error - hand in a `daw_event_response/v1`: the registry finds the event by `event_id`, checks `operation_id`, `source` and the value against the declared field, removes the event and returns event and value; an unknown `event_id`, a mismatching `operation_id`, an invalid value and a second response are different errors - list what is pending (for UIs that ask later or elsewhere) - errors as `daw_error/v1`, one `resource_id` per error site; texts as `daw_i18n/v1` resources en/de - no persistence: the registry lives and dies with the host process Resuming the operation (calling the module again with the response) stays with the host. ## Depends on - DAW/daw-contracts: companion issue on the typed answer field and the receiver rules (the place of the field decides what the registry reads) - the response check of `build_response` is reused; the defects found in its review are a separate issue and should be fixed first ## Out of scope - transport and persistence across processes (`mainjan`, later) - the presentation of questions (adapters) ## Acceptance criteria - [ ] signatures agreed before implementation - [ ] tests first: add, answer, unknown event, wrong operation, invalid value, second response, pending list, faulty event - [ ] own texts as `daw_i18n/v1` resources, `resource_id` per error site - [ ] `fragjan code .` and `make test` (Lua 5.1 and 5.4) pass - [ ] README documents it ## Related DAW/daw-contracts (companion issue), DAW/daw-modul-berhtjan-core#21, DAW/daw-modul-berhtjan-cli#15, DAW/daw-module-manager (companion issue)
Author
Owner

Implemented on main

Commits: 7a098e2, 80e9c2f, f223344

Pushed. Follow-up points, if any, are tracked in their own issues.

## Implemented on main Commits: 7a098e2, 80e9c2f, f223344 Pushed. Follow-up points, if any, are tracked in their own issues.
michael 2026-11-18 11:57:44 +01:00
Sign in to join this conversation.
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
DAW/daw-modul-berhtjan-core#24
No description provided.