Skip to content

feat(hud): restore decisions/pitfalls counts segment#250

Closed
dean0x wants to merge 2 commits into
mainfrom
feat/hud-decisions-counts
Closed

feat(hud): restore decisions/pitfalls counts segment#250
dean0x wants to merge 2 commits into
mainfrom
feat/hud-decisions-counts

Conversation

@dean0x

@dean0x dean0x commented Jul 4, 2026

Copy link
Copy Markdown
Owner

Summary

  • Restores the HUD learning-counts line removed with the learning pipeline in refactor(dream): remove learning pipeline + per-task skills with dynamic model loading #238, rebuilt on the decisions ledger
  • New decisionsCounts component reads .devflow/decisions/decisions-ledger.jsonl and counts active anchored rowsdecisions_status absent or outside Deprecated/Superseded/Retired, mirroring render-decisions.cjs exactly (D309) — so the HUD numbers always match the rendered decisions.md/pitfalls.md
  • Renders a dim Learning: N decisions, M pitfalls line; hidden when the ledger is missing or every entry is retired; zero-count parts omitted
  • Layout flattened: todos moved to the end of the capacity line and the Info/Activity blank-line break removed — the HUD renders as one compact block (null section-break support dropped from LINE_GROUPS, pendingBreak machinery deleted)
  • Default-enabled via HUD_COMPONENTS; devflow hud component listing picks it up automatically
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

Test plan

  • npm run build:cli (tsc) clean
  • node scripts/build-hud.js — import graph copies the new component + project-paths (28 files)
  • 112 HUD-surface tests green (13 new component tests; layout tests rewritten for the flattened block)
  • Live render against this repo's real ledger → compact 4-line block ending Learning: 3 decisions
  • Snyk code scan on changed code: 0 issues

dean0x added 2 commits July 4, 2026 09:35
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.
@dean0x

dean0x commented Jul 4, 2026

Copy link
Copy Markdown
Owner Author

Folded into #248 (cherry-picked as 481a787 + 34fd95b) — keeping one PR for the whole simplify-dream-system batch.

@dean0x dean0x closed this Jul 4, 2026
@dean0x dean0x deleted the feat/hud-decisions-counts branch July 4, 2026 07:38
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>
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