Skip to content

fix(coordinator): emit one IDEA_PRUNED event per cascaded node - #63

Merged
ignorejjj merged 1 commit into
RUC-NLPIR:mainfrom
AmirF194:fix/62-prune-cascade-single-event
Aug 30, 2026
Merged

ignorejjj merged 1 commit into
RUC-NLPIR:mainfrom
AmirF194:fix/62-prune-cascade-single-event

Conversation

@AmirF194

Copy link
Copy Markdown
Contributor

Summary

IdeaTree.prune_node() recursively sets status = "pruned" on the target node and every
descendant (_prune(), called on node_id then each child_id), but after the recursion
finished it emitted exactly one IDEA_PRUNED event, for node_id only.

Every consumer keys off a single node_id per event: StatsCollector._inc_pruned increments
a counter by one per event, and RunState.on_idea_pruned (the source for the TUI header and,
via webui/snapshot.py, the WebUI tree) updates the record for the one node_id in the event
payload. So cascaded descendants kept their pre-prune status ("proposed") in both places even
though idea_tree.json on disk already marked them pruned, which is the TUI/WebUI count
mismatch reported in #62.

Fix: collect the ids mutated during the cascade and emit one IDEA_PRUNED event per id instead
of one for the whole cascade. Each descendant now carries the same reason as the node the
caller pruned, since it was pruned as a direct consequence of that call.

Linked issue

Closes #62

Type of change

  • Bug fix (fix)

How was this tested?

  • New regression test asserts the event set matches every mutated node id (not just the
    target) and that an untouched sibling emits nothing; both fail against unpatched
    prune_node and pass after the fix.
  • A second test drives StatsCollector and RunState end to end through the real event bus
    and asserts the pruned count and every descendant's status.
  • Full pytest (154 files) and ruff check src/ tests/ both pass clean on Python 3.10 and
    3.13, in a clean Docker container, with dependency versions pinned from uv.lock.
python -m pytest tests/ -q
python -m ruff check src/ tests/

Not checked: the live TUI/WebUI rendering itself, since neither has a scripted test harness in
this repo; the assertion is on the state each of them consumes (RunState/StatsCollector).

Checklist

  • PR title follows Conventional Commits (e.g. fix(config): ...).
  • The change is focused and reasonably small.
  • I ran the relevant tests locally (python tests/test_*.py) and they pass.
  • Docs / examples updated if behavior or config changed. (not applicable, no docs describe this event contract)
  • No secrets, API keys, or tokens are included in the diff.

prune_node() sets status="pruned" on the target node and every descendant,
but emitted a single IDEA_PRUNED event for the target only. Every consumer
(StatsCollector, RunState, which feeds the TUI header and the WebUI tree)
keys off one node_id per event, so cascaded descendants stayed at their
pre-prune status in the TUI/WebUI ledger even though idea_tree.json on disk
already marked them pruned.

Emit one IDEA_PRUNED event per pruned node id instead of one for the whole
cascade.

Fixes RUC-NLPIR#62
@ignorejjj
ignorejjj merged commit 2f4e654 into RUC-NLPIR:main Aug 30, 2026
7 checks passed
@AmirF194
AmirF194 deleted the fix/62-prune-cascade-single-event branch August 30, 2026 12:47
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.

[Bug]: Events metric in TUI and web ui

2 participants