feat(hud): restore decisions/pitfalls counts segment#250
Closed
dean0x wants to merge 2 commits into
Closed
Conversation
Bring back the learning-counts HUD line removed with the learning pipeline (59db82e), rebuilt on the decisions ledger: counts active anchored rows from decisions-ledger.jsonl, mirroring the render-decisions.cjs active-row semantics so the numbers always match the rendered decisions.md/pitfalls.md (D309). Renders as a dim 'Learning: N decisions, M pitfalls' line in the Activity section, hidden when the ledger is absent or every entry is retired.
Todos render at the end of the capacity line (context · quota · todos) and the Info/Activity blank-line break is removed — the HUD is one compact block. LINE_GROUPS no longer carries null section breaks, so the pendingBreak machinery goes with it.
Owner
Author
dean0x
added a commit
that referenced
this pull request
Jul 4, 2026
…d Dream agent (#248) ## Summary Simplifies the dream (decisions) system to **capture + directive + background Dream agent**: shell scripts only capture turns and trigger processing; the LLM does all processing by reading and editing the data files directly. - **Capture**: `capture-prompt` / `capture-turn` / `capture-question` (always-on) dual-append every user turn, assistant turn, and answered `AskUserQuestion` to the memory and dream `.pending-turns.jsonl` queues via the shared `queue-append` helper (200→100 overflow truncation). Gating is **config-only** — the `decisions` field in dream config, mirroring memory's ADR-001; the `.disabled` sentinel is gone everywhere. - **Trigger**: `session-start-context` Section 2 — when the dream queue is non-empty (or a crashed run left a `.pending-turns.processing` batch older than 900s), it resolves the model (project `decisions.json` → global `~/.devflow/decisions.json` → `opus`) and emits a `--- DREAM MAINTENANCE ---` directive: spawn `Agent(subagent_type="Dream", model=<resolved>, run_in_background: true)`, do not narrate. A **fresh** `.processing` suppresses the directive (a live agent owns the batch). Queue emptiness is the natural gate — no throttle, no lock, no claude-on-PATH check. - **Processor**: the restored **Dream agent** (`shared/agents/dream.md`, opus, self-contained). It claims the queue itself (atomic `mv` → `.processing`; merges + re-claims a stale leftover; exits silently on a lost race or fresh `.processing`; heartbeat `touch` at the detection→curation boundary), reads `decisions-log.jsonl` / `decisions.md` / `pitfalls.md` / `.decisions-usage.json` **directly**, appends/edits observations **one JSONL row at a time**, and calls only three plumbing ops: `assign-anchor`, `retire-anchor` (numbering + render — Iron Law), and `rotate-observations` (date-arithmetic archival). Detection bar, ADR-XOR-PF, dedup, and curation bounds (≤5 changes, 7-day window) are unchanged. - **Consume-then-delete**: removing `.processing` is the agent's **final act**; a crash leaves the batch for the next session's stale-merge recovery. Run visibility is the agent's 1–3 line final message — native background-task visibility, no status files. ## Removed machinery - `spawn-dream-worker` hook + `background-dream-update` detached worker (318 lines: worker lock, watchdog, model resolution, success stamp) + `dream-procedure.md` + `lib/staleness.cjs` - `merge-observation` and `count-active` json-helper ops (the agent edits the log and reads rendered files itself) - `.devflow/decisions/.disabled` sentinel, `dream/.last-dream-ok`, `dream/last-run-summary`, `dream/.worker.lock` — plus `manageSentinel`/`sentinel.ts` and the three path helpers for them - `DEVFLOW_BG_DREAM` guard across all hooks (no dream `claude -p` session exists; `DEVFLOW_BG_UPDATER` stays for the memory worker) The detached `claude -p` implementation is preserved in git history (`bf34dab`, `5217b6c`, `3bb9bbb`) for future resurrection. ## CLI + migration - `devflow decisions --enable/--disable` are config-only; `--disable` (and `--clear`) drain the dream queue **unconditionally** — a mid-run agent whose files vanish aborts without changes, which is the desired outcome of disabling. - `dream.ts` slims to `removeDreamHook`/`hasDreamHook` (upgrade cleanup of the stale settings entry); init sweeps the four deleted hook files via `LEGACY_HOOK_FILES`. - New per-project migration `purge-dream-worker-state-v1` removes the inert worker-state leftovers on upgrade. ## Race safety Live-vs-crashed `.processing` is discriminated by mtime (900s, both in the hook and the agent). Two sessions racing on the queue are settled by the atomic `mv` (one winner). A double stale-reclaim is possible in a sub-second window >900s after a crash — accepted; dedup rules and `assign-anchor` preconditions bound the damage to redundant analysis. ## Accepted risks (conscious) - **Directive spawn depends on model compliance** — a skipped spawn delays processing to the next session; the queue persists (bounded by the existing 200→100 truncation). - **Unrelated `claude -p` sessions receive the directive** (SessionStart fires there) — pre-existing exposure class, lived with before. - **Transitional window**: an in-flight old worker during upgrade may capture one batch of its own turns (one-shot junk rows). ## Testing - Full suite green at every commit (1816 tests), `npm run build`, `tsc --noEmit` — zero warnings. - New directive tests cover the emission matrix (queue non-empty / empty / `decisions:false` / `DEVFLOW_BG_UPDATER=1` / fresh vs stale `.processing`), model resolution (project > global > opus), and directive format. - New `tests/dream-agent.test.ts` pins the agent contract: frontmatter, claim/heartbeat/consume-then-delete protocol, and negatives (no `count-active`, `staleness.cjs`, `merge-observation`, `.last-dream-ok`, `last-run-summary`). - Manual smoke: seeded queue → directive with resolved model + project root; empty queue → silent. ## Untouched Memory pipeline (worker, locks, throttle), knowledge system, ambient, capture semantics, ledger render engine, `decisions-index.cjs`, `/resolve`-side decisions consumption, `devflow decisions list|--configure`. ## Also in this PR (folded in) - **feat(flags)** `1260d4f` — three new default-ON Claude Code flags: `disable-bundled-skills` (`disableBundledSkills: true`), `pin-sonnet-4-6` (`ANTHROPIC_DEFAULT_SONNET_MODEL=claude-sonnet-4-6`), `disable-mouse-clicks` (`CLAUDE_CODE_DISABLE_MOUSE_CLICKS=1`); registry 18 → 21, covered in `tests/flags.test.ts`. - **feat(hud)** `481a787` + `34fd95b` (folded from #250) — restores the decisions/pitfalls counts line, rebuilt on the decisions ledger: counts **active anchored rows** from `decisions-ledger.jsonl` mirroring `render-decisions.cjs` semantics (D309), rendered as a dim `Learning: N decisions, M pitfalls` line. Layout flattened: todos moved to the end of the capacity line, Info/Activity section break removed (`pendingBreak` machinery deleted). ``` devflow · feat/payments* · 2↑ 1↓ · v2.0.0 +14 · 2 worktrees · 8 files · +280 -2 Context ███░░░░░ 34% · 5h ████░░░░ 45% (2h 15m) · 3/7 todos Fable 5 [200k] · 2 CLAUDE.md · 12 rules · 3 MCPs · 8 hooks · $4.20 Learning: 12 decisions, 4 pitfalls ``` --------- Co-authored-by: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
decisionsCountscomponent reads.devflow/decisions/decisions-ledger.jsonland counts active anchored rows —decisions_statusabsent or outside Deprecated/Superseded/Retired, mirroringrender-decisions.cjsexactly (D309) — so the HUD numbers always match the rendereddecisions.md/pitfalls.mdLearning: N decisions, M pitfallsline; hidden when the ledger is missing or every entry is retired; zero-count parts omittedLINE_GROUPS,pendingBreakmachinery deleted)HUD_COMPONENTS;devflow hudcomponent listing picks it up automaticallyTest plan
npm run build:cli(tsc) cleannode scripts/build-hud.js— import graph copies the new component +project-paths(28 files)Learning: 3 decisions