Build and check a daw_event_response/v1 for a decision_required event #21

Closed
opened 2026-11-15 19:40:15 +01:00 by michael · 2 comments
Owner

Problem

A module asks a question by emitting a daw_event/v1 (decision_required).
The answer comes back as daw_event_response/v1, correlated by event_id
and operation_id. Every adapter (cli, web, api) needs the same two steps:
build the response from the event, and check the given value against the
field the module declared with daw_field_type/v1. berhtjan-core has the
field type registry and compose(), but nothing to build or check a
response. Common to all adapters, so it belongs in core.

First use case: yes/no confirmation before a module is removed
(DAW/daw-module-manager), declared as a selection / static / single
field with two answers.

Scope

  • one public function: event + value -> daw_event_response/v1 | daw_error/v1
  • event_id and operation_id are copied from the event, never generated
  • check the value against the declared field using the closed vocabulary
    only (cardinality, acquisition[].kind, collection.source); never
    switch on the open value.kind
  • first step: selection with static values (the value must be one of
    the declared ones, cardinality respected); other combinations are
    out of scope and return a daw_error/v1
  • errors as daw_error/v1, one resource_id per error site
  • no input/output, no conversion of entered text: each adapter maps its
    input to a value itself

Provisional (marked as such until validated)

  • placement: the declared field in data.answer of the event, the value
    in data.value of the response; daw_event/v1 and
    daw_event_response/v1 do not fix this yet
  • the form of collection.values entries (object with value, message,
    resource_id), see the companion issue in DAW/daw-contracts

A contract proposal follows after the first validation.

Acceptance criteria

  • signatures agreed before implementation
  • 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 the function

DAW/daw-contracts (daw_event/v1, daw_event_response/v1, daw_field_type/v1),
DAW/daw-modul-berhtjan-cli#14, DAW/fragjan#137

## Problem A module asks a question by emitting a `daw_event/v1` (`decision_required`). The answer comes back as `daw_event_response/v1`, correlated by `event_id` and `operation_id`. Every adapter (cli, web, api) needs the same two steps: build the response from the event, and check the given value against the field the module declared with `daw_field_type/v1`. berhtjan-core has the field type registry and `compose()`, but nothing to build or check a response. Common to all adapters, so it belongs in core. First use case: yes/no confirmation before a module is removed (DAW/daw-module-manager), declared as a `selection` / `static` / `single` field with two answers. ## Scope - one public function: event + value -> `daw_event_response/v1` | `daw_error/v1` - `event_id` and `operation_id` are copied from the event, never generated - check the value against the declared field using the closed vocabulary only (`cardinality`, `acquisition[].kind`, `collection.source`); never switch on the open `value.kind` - first step: `selection` with `static` values (the value must be one of the declared ones, cardinality respected); other combinations are out of scope and return a `daw_error/v1` - errors as `daw_error/v1`, one `resource_id` per error site - no input/output, no conversion of entered text: each adapter maps its input to a value itself ## Provisional (marked as such until validated) - placement: the declared field in `data.answer` of the event, the value in `data.value` of the response; `daw_event/v1` and `daw_event_response/v1` do not fix this yet - the form of `collection.values` entries (object with `value`, `message`, `resource_id`), see the companion issue in DAW/daw-contracts A contract proposal follows after the first validation. ## Acceptance criteria - [ ] signatures agreed before implementation - [ ] 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 the function ## Related DAW/daw-contracts (`daw_event/v1`, `daw_event_response/v1`, `daw_field_type/v1`), DAW/daw-modul-berhtjan-cli#14, DAW/fragjan#137
Author
Owner

Cross references

## Cross references - Companion: DAW/daw-modul-berhtjan-cli#15 (asks the field, hands the value to this function) - Contract question: DAW/daw-contracts#17 (form of `collection.values` entries); the object form used here is provisional until it is decided
Author
Owner

Implemented on main

Commits: 92dc194

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

## Implemented on main Commits: 92dc194 Pushed. Follow-up points, if any, are tracked in their own issues.
michael 2026-11-18 11:57:36 +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#21
No description provided.