MotirBuilding in public
MOTIR · moooon
onMotir
You’re viewing a public project. Anyone can view it — no account needed. Sign in to submit, upvote, or comment on requests.View-only — you can’t edit work items
MOTIR-2128

BUG (motir-ai) — the `augment` and `expand_item` handlers ALSO ignore `context.generateExplanations`, so two of the three plan-edit paths still drop explanations

Done
Description

Repo: motir-ai. One PR. Surfaced while running MOTIR-2111 (notes.html #27 — an out-of-scope defect found mid-subtask is logged as its own card, never absorbed).

The defect

MOTIR-2110's producer half puts generateExplanations on the envelope for all three plan-edit job kinds — aiPlanEditsService.ts:43 types them as Extract<JobKind, 'augment' | 'expand_item' | 'replan'> and line 134 sets the flag on every one of them. MOTIR-2111 fixed the replan consumer. The other two consumers still ignore it (verified on origin/main @ 9d41e8d, counted with python since grep finds nothing in these long-line files):

handlerrunGenerationPass callsmentions generateExplanations
generateTree.ts14 ✅
replan.ts12 ✅ (MOTIR-2111)
augment.ts10
expandItem.ts10

So a project with "AI-drafted explanations" ON still gets explanation-less nodes from an augment or an expand — the same silent no-op MOTIR-2110/2111 fixed for re-plan. aiPlanEditsService.ts:129-130 even notes the contextual turn can resolve an augment submit into a re-plan, which is why the producer set the flag on all three rather than replan alone.

Acceptance criteria

  • augment.ts and expandItem.ts each read the flag off the job envelope exactly as generateTree.ts / replan.ts do (the same defensive req?.context?.generateExplanations === true) and pass it to their runGenerationPass call.
  • A grep for runGenerationPass( across src/jobs/handlers/** finds NO call site that omits the option spread — write the AC as the grep, so it does not go stale on a new handler.
  • With the flag ON, each path's propose_node proposals carry explanationMd + explanationSource: 'ai_draft' through to addProposals — asserted by a test per handler, not by inspection.
  • With the flag OFF or absent, each composed pass input is byte-identical to today's (assert the key is ABSENT, not false).
  • Do NOT read motir-core config directly — the flag rides the envelope.
  • PR title carries MOTIR-<id>.

Context refs

  • src/jobs/handlers/augment.ts, src/jobs/handlers/expandItem.ts — the two handlers edited.
  • src/jobs/handlers/replan.ts — the reference fix (MOTIR-2111), and generateTree.ts before it.
  • tests/replanHandler.test.ts — the test shape to mirror: flag ON / OFF / non-boolean, plus the sink carry-through into addProposals.
  • motir-core lib/services/aiPlanEditsService.ts:43,134 — the producer proving all three kinds carry the flag.