Skip to content

Close stale question cards and let a Main Bot void one - #1

Closed
neotechnet wants to merge 3 commits into
mainfrom
feat/question-lifecycle
Closed

neotechnet wants to merge 3 commits into
mainfrom
feat/question-lifecycle

Conversation

@neotechnet

@neotechnet neotechnet commented Nov 1, 2026 •

Copy link
Copy Markdown
Owner

Job

Job 2 of the bot team hardening packet: question lifecycle, so stale cards can be cleared.

Why this PR is on the DS-Bot fork

The packet was written for deepseek-harness, but the code is not there. state.questions, ask_user and the card answer route exist only in the ds-bot plugin (ds-bot/src/host/), so this is the only repo the fix can live in. Base is neotechnet/DS-Bot main at f823773, which is 0.2.4, the version installed.

Cause

Proven live on 2026-10-31: state.questions[<session>] was deleted only by a user message or by the card's own answer or dismiss route. A later Bot turn left it in place, and no tool could remove it. Eight open cards were in the bot store when this was written.

What changed

  • turns.js: a turn notes the card it opened on, and a completed turn the user could see that left that same card standing deletes it. A turn that asked has a different card id, so it keeps its own.
  • tools.js: new void_question, Main Bot only. It removes the card and tells the Bot in a new turn, under a new voided role with a [Question voided by <name>] header (delivery.js). If telling the Bot fails, the card is still gone and the Main Bot is told to pass it on.
  • Late answers: answer-question already refuses a closed card with bot/stale. No new refusal was needed; two new tests pin it.
  • privacy.js: void_question cannot reach a private Bot. prompt.js: Bots are told a card lasts only until their next finished turn the user can see, and Main Bots are told about the tool. constants.js, install.test.js: the tool list.

Steve's decision on hidden turns (commit b130e29)

The first version of this PR cleared the card on any completed turn that asked nothing, and flagged that as the one behaviour to review. Steve reviewed it and decided: a completed turn clears the card it opened only when that turn was user-facing. A hidden Bot-to-Bot turn must not clear a card waiting on the user, because the question can then vanish before Steve ever reads it.

"Hidden" uses the plugin's existing test, not a new one: the turn is recorded in state.exchangeTurns, which is what ask_user and the live feed already check. So a request a Bot sends with reply_to: "user" is user-facing and still clears the card, and a [Reply from ...] turn, which is not recorded there, still clears it too.

Unchanged by this commit: void_question and an explicit void clearing the card, a late answer to a closed card being refused, a turn that asks keeping only its own card, and a failed or stopped turn clearing nothing.

What deliberately keeps a card

  • A hidden Bot-to-Bot turn (Steve's decision above).
  • A failed or stopped turn. It said nothing about the card.
  • The handoff turn of a fresh part, which carries the card over.
  • A turn cut off for a written tool call that is being retried.

Scope

ds-bot/src/host/{constants,delivery,privacy,prompt,tools,turns}.js, ds-bot/test/{install,question-lifecycle}.test.js, ds-bot/README.md, CHANGELOG.md. No client code, no build output.

Test output for the hidden turn change

Three new cases. The first is the one that bites. The other two pass on both sides by design: they guard against the fix going too far, one proving a held card still closes at the next visible turn, the other that a Bot-started turn the user can see still clears it.

Command, the same before and after, run against the built harness tree at C:\d215:

cd C:\Projects\_wt\ds-bot-question-lifecycle\ds-bot
$env:DSH_HARNESS = "C:\d215"
node --import ./test/harness-resolve.mjs --test test/question-lifecycle.test.js

Before the fix, source at e62783b with only the new tests added:

✔ the turn that asks keeps its card (108.9344ms)
✔ a card followed by a plain turn leaves nothing pending (56.0995ms)
✖ a hidden Bot-to-Bot turn leaves a waiting card for the user, who can still answer it (78.1456ms)
✔ a card that outlived a hidden turn closes at the next turn the user sees (76.2066ms)
✔ a Bot-started turn that answers the user in its own chat clears the card (54.5807ms)
✔ a turn that asks again leaves only its own card (45.0968ms)
✔ a turn that failed or was stopped asked nothing, so the card stays (49.1508ms)
✔ the handoff turn of a fresh part keeps the card it carried over (45.093ms)
✔ a card followed by a Main Bot void leaves nothing pending, and the Bot is told (42.06ms)
✔ voiding belongs to a Main Bot (37.0514ms)
✔ voiding says so when the Bot has no open question (29.3538ms)
✔ a void reaches the card even when telling the Bot fails (58.3657ms)
✔ a late answer to a voided card is refused and reaches nobody (43.831ms)
✔ a late answer to a card a plain turn cleared is refused and reaches nobody (48.6785ms)
✔ a normal card answered by the user behaves as it always did (50.3511ms)
ℹ tests 15
ℹ pass 14
ℹ fail 1

AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
+ actual - expected
+ undefined
- '2a1a30e4-6031-44f0-aeb3-8f6e2e3613da'

After the fix:

✔ the turn that asks keeps its card (109.5851ms)
✔ a card followed by a plain turn leaves nothing pending (38.8763ms)
✔ a hidden Bot-to-Bot turn leaves a waiting card for the user, who can still answer it (83.4152ms)
✔ a card that outlived a hidden turn closes at the next turn the user sees (82.0388ms)
✔ a Bot-started turn that answers the user in its own chat clears the card (49.4525ms)
✔ a turn that asks again leaves only its own card (50.366ms)
✔ a turn that failed or was stopped asked nothing, so the card stays (53.8912ms)
✔ the handoff turn of a fresh part keeps the card it carried over (40.563ms)
✔ a card followed by a Main Bot void leaves nothing pending, and the Bot is told (45.1962ms)
✔ voiding belongs to a Main Bot (43.9403ms)
✔ voiding says so when the Bot has no open question (34.9463ms)
✔ a void reaches the card even when telling the Bot fails (49.3539ms)
✔ a late answer to a voided card is refused and reaches nobody (48.6864ms)
✔ a late answer to a card a plain turn cleared is refused and reaches nobody (48.3859ms)
✔ a normal card answered by the user behaves as it always did (49.4212ms)
ℹ tests 15
ℹ pass 15
ℹ fail 0

Full suite after this commit (test/*.test.js, C:\d215): 1288 tests, 1283 pass, 3 fail, 2 skipped.

  • at-menu, show-view-scope and styles fail at load with ERR_MODULE_NOT_FOUND: the harness tree on this machine does not expose @deepseek-ai/dsh-session-reference, @deepseek-ai/dsh-scope or @deepseek-ai/dsh-client-modules/client to the resolver. This branch changes none of those three test files and no client code.
  • The timing test that failed once in the earlier full run did not fail this time.

Test output for the original change

Recorded against C:\d216 when the PR was opened.

Before the change:

✔ the turn that asks keeps its card (138.3789ms)
✖ a card followed by a plain turn leaves nothing pending (46.7511ms)
✔ a turn that asks again leaves only its own card (68.6044ms)
✔ a turn that failed or was stopped asked nothing, so the card stays (56.5921ms)
✔ the handoff turn of a fresh part keeps the card it carried over (49.5523ms)
✖ a card followed by a Main Bot void leaves nothing pending, and the Bot is told (44.9191ms)
✖ voiding belongs to a Main Bot (44.0532ms)
✖ voiding says so when the Bot has no open question (32.3498ms)
✖ a void reaches the card even when telling the Bot fails (45.1777ms)
✖ a late answer to a voided card is refused and reaches nobody (44.2621ms)
✖ a late answer to a card a plain turn cleared is refused and reaches nobody (53.9662ms)
✔ a normal card answered by the user behaves as it always did (51.0133ms)
ℹ tests 12
ℹ pass 5
ℹ fail 7

After the change: 12 tests, 12 pass, 0 fail.

npm run lint was run on the original change and exited 0 with warnings only, none in files this PR changes. It was not rerun for b130e29. No CI ran: this fork has no registered workflows, so test.yml did not run, and the results above are from this Windows machine only.

Not done here

Not installed. This does not reach the running app until the change is carried into the profile's patches/ds-bot@0.2.4.patch or a release of the plugin, and the app restarts. No live bot state was written.

Not merged.

🤖 Generated with Claude Code

neotechnet and others added 2 commits October 31, 2026 20:53
A question card was cleared only when the user answered it. A Bot that moved
on in a later turn left the card on screen, and nobody but the user could
remove it.

A completed turn that asked nothing now closes the card the turn opened on,
so a turn that asks keeps its own card. A failed or stopped turn says nothing
about the card and leaves it, as does the handoff turn of a fresh part, which
carries it over.

void_question lets a Main Bot withdraw another Bot's card; the Bot is told in
a new turn. A click on a closed card takes the existing bot/stale refusal.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-01T00:56:18.709871Z e62783b PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e62783b98b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread CHANGELOG.md Outdated
Comment on lines +7 to +9
### Changed

- A question card closes when its Bot finishes a later turn that asks nothing, so a stale card no longer stays on screen until you answer it. A click on a closed card is refused.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Move the changelog entries into the PR's Changelog field

This commit edits CHANGELOG.md directly, contrary to the explicit workflow rule in AGENTS.md. Revert these additions and provide the user-visible change in the pull request's Changelog field instead.

AGENTS.md reference: AGENTS.md:L51-L51

Useful? React with 👍 / 👎.

Steve's decision: a completed turn clears the card it opened only when that
turn was user-facing. A hidden Bot-to-Bot turn shows the user nothing, so
clearing there could remove a question before it was ever read.

Hidden means what the rest of the plugin means by it: the turn is recorded in
exchangeTurns, the same test ask_user and the live feed use. A request a Bot
sends with reply_to "user" stays visible, so that turn still clears the card.

The Bot prompt, README and changelog now say the same thing. Voiding, the
refusal of a late answer, a turn that asks keeping only its own card, and a
failed or stopped turn clearing nothing are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@neotechnet

Copy link
Copy Markdown
Owner Author

Superseded by #4: this change is carried in stack/installed-0.2.7 (21eff5d), installed in the live profile and proven on 2026-11-03. Head was b130e29.

@neotechnet neotechnet closed this Nov 3, 2026
@neotechnet
neotechnet deleted the feat/question-lifecycle branch November 3, 2026 21:54
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