dream report: normalizeMutation discards ok/status, consumers can only string-match the summary

Open Beginner friendly
#61 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
66/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
typescript
Domain
ai

Research direction

Start at normalizeMutation (dist/agent/dream.js:77) and find its TypeScript source, then trace where the dream report's ok, status and steps fields are dropped on the way to the flattened summary. Compare with the same flattening at dist/agent/agent.js:181 and agent.js:145 before changing anything, so all call sites stay consistent. Done means a returned report carries ok, status and steps again, and you can show a failed and a clean dream pass differing by report.ok alone rather than by the dream run failed: prefix.

Written by the indexing model from the issue text.

Description

runDream's report is flattened by normalizeMutation (dist/agent/dream.js:77), which keeps summary and filesChanged and discards ok and status. Consumers of the client therefore never receive the success/failure flag — they only get the flattened summary text.

Impact

The Pithagoras portal extension is affected: a dream (tidy-up) pass that ran out of steps is indistinguishable from a clean one via any structured field. The portal currently has to key off the literal dream run failed: prefix that normalizeMutation itself prepends to every failed outcome — brittle string matching that breaks silently if the wording ever changes. (Interim portal-side fix: thecodacus/pithagoras#382.)

Proposed fix

  • Preserve ok (and status, which already distinguishes partial from failed) on the report instead of discarding it.
  • Surface the steps count on the success path, so consumers can see how close a pass ran to AGENT_MAX_STEPS without guessing from wall-clock time.

With ok present, the portal-side check becomes report.ok === false and the string matching can be removed.

Note

The same dist carries near-identical step-limit strings for search (dist/agent/agent.js:181) and search-without-files (agent.js:145) — the same flattening probably applies there too; worth checking while touching this code.

Dominant language
TypeScript
Stars
342
Forks
78
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from thecodacus/understory

All issues in thecodacus/understory

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.