Clean up adapters/ui _contracts terminology (bool_or_err/value_or_err/result_or_err) #133

Open
opened 2026-08-11 20:02:46 +02:00 by michael · 0 comments
Owner

Goal

Clean up the inconsistent _contracts/return-shape terminology
between adapters/ui and the UI provider modules it dispatches to
(e.g. daw-modul-berhtjan-core), starting here ("von unten nach
oben" -- fix the adapter/tooling layer first, then the modules).

Background

Found while reviewing adapters/ui/init.lua and
adapters/ui/renderers.lua during the daw-modul-berhtjan-core 2.1
migration:

  • adapters/ui/init.lua's own M._contracts declares
    check = "bool_or_err", required_ops = "list",
    dispatch = "result_or_err", build_usage = "result_or_err",
    render = "bool_or_err".
  • daw-modul-berhtjan-core's M._contracts (documenting the
    contract UI provider modules like daw-modul-berhtjan-cli must
    implement) uses different terms for comparable shapes:
    dispatch = "bool_or_err", build_usage = "value_or_err",
    render = "bool_or_err".
  • adapters/ui/init.lua's M.check(mod) does not actually read
    mod._contracts at all -- it only checks that
    type(mod[op]) == "function" for each op in required_ops(). The
    _contracts table is therefore currently pure documentation, not
    an enforced contract, on both sides.
  • dispatch()'s actual behavior doesn't cleanly match either
    "bool_or_err" label: a provider's dispatch() returns
    ok, result where result can be a number (exit code) on success,
    not just nil.

Scope

  • Decide a single, consistent vocabulary for describing public
    function return shapes (bool/value/result_or_err, or something
    else) and document it once
  • Align adapters/ui/init.lua's _contracts and
    daw-modul-berhtjan-core's _contracts to use the same terms
    for the same shapes
  • Either make M.check() actually validate against _contracts,
    or remove/relabel _contracts as documentation-only if
    enforcement isn't intended
  • Reconcile the dispatch() shape description with its actual
    behavior (result can be a number on success)

Acceptance criteria

  • _contracts terminology consistent between adapters/ui and
    at least daw-modul-berhtjan-core
  • Clear, documented answer to whether _contracts is enforced or
    purely descriptive
  • dispatch()'s documented shape matches its actual return
    behavior

Affected repositories

  • fragjan (adapters/ui/init.lua, adapters/ui/renderers.lua)
  • daw-modul-berhtjan-core (init.lua's M._contracts)

Order: fragjan/adapter layer first, then modules, per prior team
decision ("von unten nach oben").

## Goal Clean up the inconsistent `_contracts`/return-shape terminology between `adapters/ui` and the UI provider modules it dispatches to (e.g. `daw-modul-berhtjan-core`), starting here ("von unten nach oben" -- fix the adapter/tooling layer first, then the modules). ## Background Found while reviewing `adapters/ui/init.lua` and `adapters/ui/renderers.lua` during the `daw-modul-berhtjan-core` 2.1 migration: - `adapters/ui/init.lua`'s own `M._contracts` declares `check = "bool_or_err"`, `required_ops = "list"`, `dispatch = "result_or_err"`, `build_usage = "result_or_err"`, `render = "bool_or_err"`. - `daw-modul-berhtjan-core`'s `M._contracts` (documenting the contract UI *provider* modules like `daw-modul-berhtjan-cli` must implement) uses different terms for comparable shapes: `dispatch = "bool_or_err"`, `build_usage = "value_or_err"`, `render = "bool_or_err"`. - `adapters/ui/init.lua`'s `M.check(mod)` does not actually read `mod._contracts` at all -- it only checks that `type(mod[op]) == "function"` for each op in `required_ops()`. The `_contracts` table is therefore currently pure documentation, not an enforced contract, on both sides. - `dispatch()`'s actual behavior doesn't cleanly match either `"bool_or_err"` label: a provider's `dispatch()` returns `ok, result` where `result` can be a number (exit code) on success, not just `nil`. ## Scope - [ ] Decide a single, consistent vocabulary for describing public function return shapes (bool/value/result_or_err, or something else) and document it once - [ ] Align `adapters/ui/init.lua`'s `_contracts` and `daw-modul-berhtjan-core`'s `_contracts` to use the same terms for the same shapes - [ ] Either make `M.check()` actually validate against `_contracts`, or remove/relabel `_contracts` as documentation-only if enforcement isn't intended - [ ] Reconcile the `dispatch()` shape description with its actual behavior (result can be a number on success) ## Acceptance criteria - [ ] `_contracts` terminology consistent between `adapters/ui` and at least `daw-modul-berhtjan-core` - [ ] Clear, documented answer to whether `_contracts` is enforced or purely descriptive - [ ] `dispatch()`'s documented shape matches its actual return behavior ## Affected repositories - `fragjan` (`adapters/ui/init.lua`, `adapters/ui/renderers.lua`) - `daw-modul-berhtjan-core` (`init.lua`'s `M._contracts`) Order: fragjan/adapter layer first, then modules, per prior team decision ("von unten nach oben").
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/fragjan#133
No description provided.