Skip to content

Generalised question schema: per-type answer resolution into the decide envelope #14149

Backlog

Description

@developing-today-fleet

Generalised question schema: per-type answer resolution into the decide envelope

Filed 2026-11-24 from the PM-OFFLINE-PUSH-AMEND record on #14043 (comment 7124012537).

Background

Drew's 2026-11-24 requirements generalise PM questions: checkboxes, radio, always a custom free-text option plus all standard options; answering per question or per set; lossless radio→checklist conversion preserving already-recorded answers.

The gap

#14043 §1 holds the broker's decide envelope boolean: "The broker's decide verb does not learn about PM schemas. It keeps receiving {handle, approve}." A checkbox (multi-select) or free-text answer to a broker-sourced question has no boolean meaning until a resolution rule exists.

Work

  1. Define the generalised question/answer schema (types: radio, checkbox, custom text, the standard option sets) as the single model behind notification actions, click-through detail views, and the console surface — one recordAnswer stream.
  2. Define, per answer type, the resolution rule that maps an answer into the broker's {handle, approve} envelope for broker-sourced questions — or explicitly restrict broker-sourced questions to boolean-resolvable types. Unresolvable answers follow pm-stack: push answer write-back to the queue broker — a phone tap applies broker-sourced decides (Actions-exec extensions first) #14043 §4's visible-alert pattern (never silently dropped).
  3. Prove radio→checklist conversion preserves recorded answers and the answer-to-handle mapping (joins write-back slice S2, task 21654).

Acceptance

Activity

  1. developing-today commented on Nov 24, 2026

    @developing-today
    Contributor
  2. dezren39 commented on Nov 24, 2026

    @dezren39
    Member

    Design note: generalised question/answer schema + per-type resolution (queue task 23332, lane oc-code-02)

    Follows the PM-OFFLINE-PUSH-AMEND record (Drew, 2026-11-24) and the #14043 design of record (doc/2026-11-24_design_pm14043_answer_writeback.md). The broker envelope does not change: it keeps receiving {handle, approve} (design §1, amendment point 3).

    1. Schema (extends pm-stack/aggregator/src/needs-drew.ts)

    Current model: NeedsDrewOption {id, label}, NeedsDrewAnswer {optionId?, freeText?, at, via}, NeedsDrewQuestion {ledgerId, question, context?, options, links, token, raisedAt, source, brokerMapping?, answer?} — single-select only. Additions (all optional/back-compatible; absent = today's radio behaviour):

    • NeedsDrewQuestion.answerType: "radio" | "checkbox" | "text" (default "radio" when absent).
    • NeedsDrewQuestion.optionSet?: { setId: string; version: number } — standard sets (e.g. approve-deny) referenced by id+version; the question's options array stays the frozen resolved copy at raise time, so later set edits never rewrite raised questions.
    • Per-question custom options remain plain entries in options; there is ALWAYS a custom free-text path (freeText), including on radio/checkbox questions.
    • NeedsDrewAnswer.optionIds?: string[] — checkbox multi-select. optionId? stays for radio. freeText? stays for the custom-text path. answerType echoes the question type at answer time.
    • Answer identity = ledgerId. recordAnswer stays first-answer-wins and stays the single stream for notification-action taps, click-through detail views, console answers, and pm-stack notifications Phase 2 step 3: edge answer intake + heartbeat drain (#8569) #13469 edge drains. Per-set answering = one submission recording N answers, each under its own ledgerId via the same recordAnswer — no second answer path, no set-level record.

    2. Per-type resolution into {handle, approve} (broker-sourced questions only)

    Resolution runs applier-side (S3), after needsDrewAnswerHandle (S2, PR #14105) yields the handle. Non-broker questions never resolve — the applier ignores them, as today. Each broker-sourced question carries its resolution map at raise (option id → boolean, frozen with the options), so resolution never depends on live set definitions.

    • radio: optionId maps via the frozen map (approve→true, deny→false) → {handle, approve}. A free-text-only answer has no mapping → unresolvable → §4 alert (below). Notification-action taps land here: each action button is one optionId.
    • checkbox: default rule unanimous — all selected ids map to the same boolean → resolve to it. Mixed or empty selection → unresolvable → §4 alert. Per-question override at raise: resolution: "any-deny" | "all-approve" | "unanimous" (default "unanimous"); the override is recorded on the question, not inferred at apply time.
    • text / custom free-text: unresolvable by definition → §4 alert. No intake restriction is imposed (intake cannot reject Drew's tap); the applier resolves-or-alerts. Broker-sourced raises SHOULD prefer boolean-resolvable types, but a text answer is never silently dropped.
    • Unresolvable answers follow pm-stack: push answer write-back to the queue broker — a phone tap applies broker-sourced decides (Actions-exec extensions first) #14043 §4 exactly: source fleet-actions-exec, key actions-exec-apply:<answer_id>, high severity, naming the handle, the answer, and why it cannot resolve (mixed selection / free text with no mapping). Deduped by key, retried while transient, re-raised when the throat recovers. This extends S4's surface (amendment scope note) without changing S4's mechanism.

    3. Radio→checklist conversion proof (against merged S2)

    Proven live 2026-11-24 against origin/main S2 code (needsDrewAnswerHandle, raiseNeedsDrew, recordAnswer; S2 suite needs-drew-writeback.test.ts 2 pass):

    • Raised a broker-sourced radio question (source fleet-actions-exec, key actions-exec-ext:proof-handle-1), recorded {optionId: "approve"} → needsDrewAnswerHandle returned proof-handle-1.
    • Converted radio→checklist: added options, kept every existing option id, set answerType: "checkbox", left answer and brokerMapping byte-identical.
    • After conversion: recorded answer still references a valid option id, and needsDrewAnswerHandle still returns proof-handle-1.
    • Why it holds: the S2 resolver keys only on answer presence + source + re-verified mapping (actionsExecMapping re-parse + handle equality). It never reads options or any type field, so conversion code only has to preserve ids, the answer, and the mapping. Conversion rule: add options freely; never rename or remove an option id; never touch answer or brokerMapping.
    • Gap confirmed in the same run: today's recordAnswer/NeedsDrewAnswer has no optionIds field — a multi-select answer is not storable until §1 lands. The schema extension is real build work for the S3/S4 lanes, not a restatement.

    4. Slice impact (amendment points restated as build constraints)

    • S1: unchanged. Unresolved-answer behaviour is aggregator-side, not envelope-side.
    • S2 (landed): conversion code must preserve the stored mapping — proven in §3.
    • S3: input stream widens (notification actions, click-through, delayed client-queue drains); loop assumptions hold; add the §2 resolver before signing.
    • S4: §4 pattern extends to cannot-resolve answers (same mechanism, new trigger).
    • S5 (task 21657, currently blocked): live demo of a checkbox answer resolving by §2 rule stays in S5 scope; phase acceptance unchanged. S5 should additionally cover one client-queued offline answer and one notification-action answer per the amendment.

    Part of #14043. Referenced from #14043.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions