Skip to content

fix(pending-questions): honor the # Resolved divider in active-question parsers - #1402

Merged
liususan091219 merged 4 commits into
sonichi:mainfrom
chetanunadkat:fix/check-pending-questions-honor-resolved-divider
Jun 3, 2026
Merged

liususan091219 merged 4 commits into
sonichi:mainfrom
chetanunadkat:fix/check-pending-questions-honor-resolved-divider

Conversation

@chetanunadkat

@chetanunadkat chetanunadkat commented Jun 2, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Two consumers parse pending-questions.md by splitting on every ## heading across the whole file, ignoring the top-level # Resolved divider that answered questions are filed under (an audit-trail convention this file has used since mid-May). So resolved questions are counted as still-open:

  • src/check-pending-questions.py — the cron re-notifies the owner (macOS + Discord DM + voice) about already-answered questions on every fire.
  • src/morning-briefing.py — the daily spoken briefing says "6 pending questions" when only 3 are open, and can read out a resolved item as the "top" question.

Observed live: both report 6 when the active section has 3.

Fix

In both parsers, truncate the parsed content at the # Resolved divider before splitting:

content = re.split(r'^#\s+Resolved\b', content, maxsplit=1, flags=re.MULTILINE)[0]

Verification

Against the live pending-questions.md, both get_waiting_questions() and get_pending_questions() drop 6 → 3 (only genuinely-open entries remain). python3 -m py_compile clean on both files. Single concern (one bug class, identical one-line fix in two parsers).

Related (not in this PR)

A separate, opposite bug class exists in dashboard.py, agent-api.py, and friction-detector.py: they require **Status:** markers that the current free-form file never has, so they undercount to 0. That's a format-recognition fix (align with #1265's "no status = unanswered"), filed separately to keep this PR single-concern.

🤖 Generated with Claude Code

chetanunadkat and others added 2 commits June 2, 2026 11:37
get_waiting_questions() splits on every `## ` heading across the whole
file, so entries kept below the `# Resolved` divider (the audit-trail
convention this file has used since mid-May) were miscounted as still
pending — the owner got re-notified (macOS + Discord DM + voice) about
already-answered questions on every cron fire.

Truncate the parsed content at the top-level `# Resolved` divider before
splitting. No-op when no such divider exists, so the free-form-delete
convention assumed by sonichi#1265 still works unchanged.

Verified against the live pending-questions.md: count drops 6 → 3
(the 3 resolved entries are no longer notified).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
get_pending_questions() splits on every `## ` heading across the whole
file, so entries under the `# Resolved` divider were spoken as still
pending in the daily briefing ("6 pending questions" when only 3 are
open). Same divider-blindness as the check-pending-questions fix in
this PR — apply the identical truncation at `^#\s+Resolved\b`.

Verified against the live pending-questions.md: count drops 6 → 3.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@chetanunadkat chetanunadkat changed the title fix(check-pending-questions): stop counting resolved items as pending fix(pending-questions): honor the # Resolved divider in active-question parsers Jun 2, 2026

@liususan091219 liususan091219 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: LGTM — approve. Correct root-cause fix for the resolved-question miscount, applied symmetrically to both consumers, no-op when the divider is absent. I see this bug live: check-pending-questions.py re-notifies on every cron fire about already-answered items.

Things done right:

  1. Root cause is precisely the divider, not the question parser. Both consumers split on ^## file-wide; the audit-trail # Resolved section (kept, not deleted) gets swept in. Cutting content at the first # Resolved before the existing ## walk is the minimal correct fix — it leaves the proven section-parsing untouched. (src/check-pending-questions.py:87, src/morning-briefing.py:213).

  2. The regex correctly distinguishes the h1 divider from an h2 question heading. ^#\s+Resolved\b requires whitespace immediately after a single #, so ## Resolved follow-up? (a question titled "Resolved…") does NOT match and won't truncate the active region prematurely. That's the subtle case that a naive ^# Resolved or a .find("Resolved") would get wrong — good that this shape avoids it.

  3. maxsplit=1 + [0] is the right idiom: everything before the first divider, and a clean no-op ([whole] → [0]) when there's no # Resolved at all. Safe on legacy files.

  4. Symmetric. Both parsers get the identical cut + an explanatory comment, so they can't drift in how they interpret the file.

Non-blocking observations:

  • Case/spacing sensitivity: matches # Resolved exactly — # resolved, # RESOLVED, or #Resolved (no space) would slip through. Given the convention is fixed (# Resolved), fine as-is; re.IGNORECASE would be a cheap robustness bump if the divider is ever hand-typed.
  • DRY: the one-line cut is duplicated across the two files. For a single line that's acceptable, but if a third consumer ever parses this file, a shared active_region(content) helper (alongside wherever the ## walk lives) would keep the divider semantics in one place.
  • Tests: +11/-0 with no test. The over-count is exactly the regression to guard — a 4-line unit test (# Resolved-divided fixture → asserts only active sections counted, + a no-divider fixture → unchanged) would lock it cheaply. Not blocking for a fix this small.

Assumes active-above / resolved-below ordering, which matches the file's convention. Clean, scoped, ready to merge.

— Lucy (Mac Studio bot)

@liususan091219 liususan091219 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified (triage skill) — bug-fix. The bug: the pending-questions counter swept the whole file, so resolved questions were miscounted as pending and re-notified the owner about already-answered questions. The fix cuts content at the '# Resolved' divider before counting (check-pending-questions.py + morning-briefing.py); no-op when there's no divider. CI green, mergeable, CLA passing. — Lucy (Mac Studio bot)

@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

@cla-assistant check

@liususan091219
liususan091219 merged commit 29c8668 into sonichi:main Jun 3, 2026
3 checks passed
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.

2 participants