Skip to content

feat(decision-events): the answer write path at the edge (#13491) - #17083

Merged
dezren39 merged 2 commits into
mainfrom
xaltha/2347-f-13491-answer-edge
Nov 30, 2026
Merged

dezren39 merged 2 commits into
mainfrom
xaltha/2347-f-13491-answer-edge

Conversation

@dezren39

@dezren39 dezren39 commented Nov 30, 2026 •

Copy link
Copy Markdown
Member

Refs #13491 — the answer write path at the edge, the first named remainder from the definitions slice (#16778, comment 7256475432 on #13491).

What changed

decision-events Worker

  • New POST /sets/<setId>/answers (shared-secret auth, like every data route): accepts {submissions: [...]}, the laptop submit endpoint's shape, and judges the batch against the set's stored definitions. 404 when no definitions are stored for the set — without the questions there is nothing to judge an answer against.
  • New pure module src/answers.ts mirrors the aggregator's own rules (recordResolutions / parseDecisionSubmissions): first resolution wins, each submission judged independently with the laptop's outcome reasons (unknown-question, already-resolved, bad-option, too-many-options, empty-answer, bad-lean), guided defers, multi-mode picks.
  • An applied ruling is recorded the way the laptop records it: the resolution summary (kind + chosen option labels + lean — never the owner's free text) joins the stored definitions document, so the edge's next read shows the question as ruled; and one decision-set event per ruling (type submit/defer/request-info, the laptop's payload shape) is stored in D1 and fanned out to the set's Durable Object, so the laptop reads the answer back from the event log when it returns. Fan-out failure is reported in the response, not failed as the answer — D1 is the durable store.

console edge

  • submitQuestionAnswers in edge/src/questions.ts: the edge client for the answers endpoint, returning the Worker's per-submission outcomes and recorded event ids; a failed POST throws and nothing is recorded.
  • The Questions discovery note now says plainly which case a set is in: with definitions read, an answer is recorded by the Worker itself with no laptop in the path; without them, the questions (and answering) still need the laptop.

Verification

Remote dispatch via fleet-run.yml against head d7885d3:

  • decision-events Worker: bun install && bun test && bunx tsc --noEmit — run 46363330264
  • console: bun test test/questions.test.ts — run 46363360768

(Conclusions recorded on the PR / issue when the runs land; CI is not a merge gate.)

Still open on #13491 after this slice

agent=xaltha lane=2347-R-F

{
  "direct_parent": null,
  "links": [],
  "lineage": {
    "design": null,
    "roadmap_item": null,
    "priority": null
  },
  "pm_meta": 1,
  "provenance": {
    "queue_id": null,
    "scheduled_start": null,
    "picked_up_at": null,
    "work_started_at": null,
    "created_at": "2026-11-30T06:00:59Z",
    "session_id": null,
    "lane": null,
    "host": "htch-runtime",
    "worktree": "/home/hatch",
    "model": null,
    "lane_start_issues": [],
    "workspace_ref": {
      "kind": "worktree",
      "id": "/home/hatch",
      "repo": "developing-today/code",
      "branch": "main",
      "sha": "c36a28d672723b085b14125996bcd72b1931e09d"
    },
    "auth_subject": "xaltha",
    "stamped_by": "fleet 0.1.0 (native)"
  }
}

Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

The decision-events Worker now records answers itself:
POST /sets/<setId>/answers judges a submission batch against the
set's stored definitions (src/answers.ts mirrors the laptop's
recordResolutions rules), writes each applied ruling into the
stored definitions as the question's resolution summary, and
appends it to the set's events in D1 with fan-out to the set's
Durable Object — so a question can be answered while the laptop
is away, and the laptop reads the answer back from the event log
when it returns.

The console edge gains submitQuestionAnswers, the client for
that endpoint, and the Questions discovery note now says an
answer is recorded by the Worker itself where definitions were
read (a set without definitions still needs the laptop, and
cannot be answered at the edge).
@coderabbitai

coderabbitai Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 49 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0783b856-0b7e-4e0e-9568-fc435b4ff197
Commits

Reviewing files that changed from the base of the PR and between 7ed58d9 and 0331b37.

Files selected for processing: 6

  • pm-stack/console/edge/src/questions.ts
  • pm-stack/console/test/questions.test.ts
  • pm-stack/decision-events-worker/README.md
  • pm-stack/decision-events-worker/src/answers.ts
  • pm-stack/decision-events-worker/src/index.ts
  • pm-stack/decision-events-worker/test/answers.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@dezren39

Copy link
Copy Markdown
Member Author

Verification (lane 2347-R-F), remote dispatch via fleet-run.yml:

  • decision-events Worker suite + typecheck (bun install && bun test && bunx tsc --noEmit): run 46363330264 — success at d7885d3 (the Worker code is unchanged by the later test-only commit).
  • Console questions tests (bun test test/questions.test.ts): first run 46363360768 failed on one expectation in the new submit test (it expected a redacted placeholder instead of the fixture secret it sends); fixed in 0331b37, re-run 46364088088 — success.

Merging on this verification (full diff read; CI is not a gate).

agent=xaltha lane=2347-R-F

@dezren39
dezren39 merged commit c20e2c7 into main Nov 30, 2026
2 checks passed
@dezren39
dezren39 deleted the xaltha/2347-f-13491-answer-edge branch November 30, 2026 06:11
dezren39 added a commit that referenced this pull request Nov 30, 2026
…17084)

The decision-events sync gains an inbound half on its webhook
leg: before the definitions publish, each stored set's events are
read back from the Worker and the answers recorded at the edge
(PR #17083) that the local event log does not hold are applied to
the local store through recordResolutions — the laptop's own
recording rules, via edge-answer, first resolution wins — and
taken into the local event log verbatim (log only, never the
outbox), which makes the pull idempotent.

Applying before the publish matters: the publish projects from
the local file, so an edge ruling the file never learned would
have its summary reverted in the Worker's stored definitions by
the next publish. Now the same run settles it everywhere.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant