Skip to content

fix(workbench): reconcile subscribed Worker turns on Lark replay - #9727

Open
hhyykk wants to merge 2 commits into
mainfrom
codex/workbench-lark-subscribed-worker-recovery
Open

hhyykk wants to merge 2 commits into
mainfrom
codex/workbench-lark-subscribed-worker-recovery

Conversation

@hhyykk

@hhyykk hhyykk commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

Goal and delivered outcome

Workbench could start a second Worker turn for a Lark message when the first Worker received it and the Hub exited before recording the delivery. On the parent revision, replay sent the same source twice to one matter. If a newer thread had been linked in the meantime, the second copy could go to that thread.

The receiver now binds the source ID and subscribed matter to the original work thread, turn, and private account scope before native dispatch. Replaying a completed turn repairs the sender's record. An unresolved attempt stays visible on the matter without waking the Worker or the Router. A distinct message with the same text can still start its own turn.

Review follow-up

The P2 review identified a restored Hub with two surviving records: the Lark cursor remembers the source and the independent receiver remembers a queued or started Worker turn. At the original head both new recovery cases failed. The follow-up resumes only the original queued target. For a started attempt without turn evidence, it restores the original matter association and displays the uncertain result without another host call. A later subscriber receives fresh sources only.

  • Follow-up revision: 427d64ceec3293ce2dd297b334d4df97b360db38
  • 40 focused daemon tests passed. This includes an already-materialized legacy cursor record, the cursor-only case with no Worker receipt, and independent identical-text B.

Author declaration

  • Written by OpenAI Codex (model agent).
  • Specification and revision. The direct-delivery recovery request in this PR is the acceptance basis. The affected behavior is documented in docs/product/use-cases/office-operations/personal-follow-through.zh-CN.md at the tested revision.
Criterion Disposition Implementation Check
Reuse the original native turn after an ACK is lost. Keep separate source IDs independent. implemented LarkChannel.receive, Store.signalWorkerReceipts Crash and replay with identical-text A and B in lark-worker-recovery.test.ts
Bind delivery per matter, including fan-out, queue recovery, and withdrawal. implemented ThreadManager.startTurn, Store.acceptWorkerSignal Mid-fan-out crash, relink, queue restart, manual withdrawal
Keep an uncertain prior attempt observable and suppress further work until evidence returns. implemented reconcileWorkerResults, MatterSignals Restored Hub database, missing completion, and pre-native interruption

Scope and continuation

This covers direct delivery to an existing subscribed matter. The receiver keeps attempt metadata in lark-worker-receipts.db, independently of the Hub's turn history. Recovery after restoring both databases together and the Worker's later external business effects require separate evidence. The personal Router's intake and Todo-proposal path is tracked separately. Related PR #9712

Validation

  • Tested revision: d5201a602f3ee273c50a38990740b5036559b314
  • Run state: finished
  • Input classes: synthetic
Check kind Result Evidence and limitations
integration passed Eight recovery scenarios counted actual prompts in a separate synthetic Pi process. The unpatched parent failed all four comparable crash/replay scenarios. A threefold replay produced one Worker prompt per original matter. Ambiguous replay produced zero additional host prompts.
real_entrypoint passed Normal Workbench collection and Worker dispatch with a fake Lark CLI and fake Pi host. The compiled daemon repeated confirmed and uncertain recovery on Node 24. No live tenant or external Worker tools were used.
unit passed 37 focused daemon cases, 679 web cases, 43 board-extension cases, 2 LoopX-extension cases, and 30 runner cases passed.
regression_parity failed Full daemon suite: 1,434 passed, 10 failed, 1 skipped. Eight failures reproduced on the parent. The remaining two, the MCP stdin and event-page tests, passed when run separately on both versions.
static passed Workbench typecheck and build, isolated Hub smoke test, standard premerge, and lean regression/WorkbenchWorkerDelivery.lean. The model assumes the independent receiver record survives.

Frontend / visual evidence

  • UI impact: changed
  • Source data: synthetic
  • The original matter's expanded source list shows the recovery result. The existing status field carries the new label. The following first viewports render the public component on each revision with the corresponding synthetic archive row after restoring a Hub database. Desktop views are 1440 × 900. The narrow view is 390 × 844.
Before After
Parent reporting delivery after a replay Original matter showing delivery needs review
Narrow viewport, dark theme

Delivery needs review on the original matter

Boundary

This DCO-signed bug fix covers the Workbench Lark integration, its source-list status, tests, and operator documentation. The standard premerge check passed on the submitted commit. No paired RFC changed.

@chatgpt-codex-connector

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

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-01T09:05:49.639501Z 427d64c New commits
ℹ️ 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: d5201a602f

ℹ️ 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 on lines +488 to +490
if (!record.disposition.pending) {
this.reconcileWorkerResults(key, record.disposition);
continue;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Reconcile surviving receipts before skipping legacy-seen signals

If hub.db is restored to before intake while lark-cursors.json and lark-worker-receipts.db survive, collect() finds the source in seen and inserts a non-pending router/legacy-seen record. This branch then skips delivery reconciliation, and reconcileWorkerResults() immediately returns because that record has no workerStates. For a previously queued delivery, the in-memory queue is gone and the surviving queued receipt is never resumed, silently losing the message; started attempts likewise never acquire the promised unconfirmed state or original matter association. Consult surviving receiver receipts before treating a cursor-only source as legacy history.

Useful? React with 👍 / 👎.

@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: 427d64ceec

ℹ️ 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".

<time>{formatDateTime(signal.at, { month: 'numeric', day: 'numeric', hour: '2-digit', minute: '2-digit' })}</time>
<span className="desk-signal-summary" title={summary}>{summary}</span>
<span className="desk-signal-where" title={signalDestination(signal.disposition)}>{signalDestination(signal.disposition)}</span>
<span className="desk-signal-where" title={destination}>{destination}</span>

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 Surface unconfirmed deliveries outside collapsed source history

When recovery leaves a delivery unconfirmed (for example, after restoring hub.db without the original turn evidence), the new receiver deliberately suppresses both Worker dispatch and Router fallback, so the owner must review the outcome. However, this label is rendered only inside MatterSignalList's open branch: the component starts closed, fetches signals only on expansion, and its collapsed control shows no unresolved-delivery indicator. Inspection of the web consumers found no other projection of these Worker states. Consequently, an interrupted delivery looks normal unless the owner happens to inspect its source history. Surface a compact unresolved-delivery indicator in the matter overview while keeping the detailed history lazy; the scoped UI guidance explicitly requires errors and pending decisions to remain directly visible.

AGENTS.md reference: apps/workbench/AGENTS.md:L19-L19

Useful? React with 👍 / 👎.

This branch has not been deployed

No deployments
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