Repository navigation
fix(inbox): archive closes questions and reviews without telling the agent - #2862
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@coderabbitai review |
Action not completed
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 26050af8cd
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Nothing is sent on archive any more, so a failed complete can always release the staged claim; leaving it would make every answer to the question 409. From security review of #2862. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From review of #2862. Archiving a question in D1 asks used to clear it live only as a side effect of delivering the agent notice, so with the notice gone an open chat kept showing the question until it refetched. Archive now calls ProjectData.recordQuestionArchived, which broadcasts attention.resolved (reason 'archived'). Unlike a withdrawal it keeps SAM's check-in hold until the question's deadline, so archiving does not nudge the agent. Never throws. Also: the inbox Archive button's accessible name no longer says it tells the agent, and the API reference / noticeRetryMinutes descriptions match. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… archived Questions and reviews archived before silent archive, whose notice was never queued, still had notified_at NULL, so the notice sweep would have told their agents after deploy and the error sweep could have reported the omitted notice as undelivered. Both sweeps now skip archived questions and reviews. From the Codex review of #2862. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Staging verification blocked by staging infrastructure (not by this change). Not merging.
Waiting on a human decision: add AI Gateway credits (then I re-run the live check), or approve merging on the automated coverage. That coverage includes real-route, Durable Object and D1 worker tests of every archive path. |
Nothing is sent on archive any more, so a failed complete can always release the staged claim; leaving it would make every answer to the question 409. From security review of #2862. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From review of #2862. Archiving a question in D1 asks used to clear it live only as a side effect of delivering the agent notice, so with the notice gone an open chat kept showing the question until it refetched. Archive now calls ProjectData.recordQuestionArchived, which broadcasts attention.resolved (reason 'archived'). Unlike a withdrawal it keeps SAM's check-in hold until the question's deadline, so archiving does not nudge the agent. Never throws. Also: the inbox Archive button's accessible name no longer says it tells the agent, and the API reference / noticeRetryMinutes descriptions match. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… archived Questions and reviews archived before silent archive, whose notice was never queued, still had notified_at NULL, so the notice sweep would have told their agents after deploy and the error sweep could have reported the omitted notice as undelivered. Both sweeps now skip archived questions and reviews. From the Codex review of #2862. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
a63042c to
4411f6b
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e67c97fd01
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Archiving a marker-era inbox question always tried to deliver a "the person archived your question" prompt to the chat's live agent. For a chat whose workspace was deleted (task cancelled, session stopped), the live-agent resolver returned 404, the archive claim was released, and the inbox UI treats 404 as "already handled elsewhere", so it silently refetched and the item came back. Such items could never be archived. archiveAttention now checks for a live workspace bridging the chat (the same liveSessionWorkspaceCondition the delivery uses; sleeping workspaces still count as live) and, when there is none, closes the marker with reason 'archived' without notifying anyone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Raphaël (2026-11-17) revised inbox spec decision 4: archiving should leave the agent where it is. A person who wants the agent to act answers or engages in the chat; archive just closes the item. - archiveAttention (marker-era questions) no longer prepares or sends a live-agent prompt. It checks the caller is a writer of the chat, claims and resolves the marker with reason `archived`, and completes an archive claim an earlier build left staged. This also removes the dependency on a live agent that made items from finished chats impossible to archive. - Asks (questions, reviews) close with `notified_at` set in the same write, as error items already do, so the notice sweep never sends one later. The agent-wake grant is no longer needed to archive, since nothing wakes. - Permissions, approvals and secret requests still archive as deny/decline, and human tasks still wake their watchers. - Receipt reads "Archived"; Connector tool text and docs updated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Nothing is sent on archive any more, so a failed complete can always release the staged claim; leaving it would make every answer to the question 409. From security review of #2862. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From review of #2862. Archiving a question in D1 asks used to clear it live only as a side effect of delivering the agent notice, so with the notice gone an open chat kept showing the question until it refetched. Archive now calls ProjectData.recordQuestionArchived, which broadcasts attention.resolved (reason 'archived'). Unlike a withdrawal it keeps SAM's check-in hold until the question's deadline, so archiving does not nudge the agent. Never throws. Also: the inbox Archive button's accessible name no longer says it tells the agent, and the API reference / noticeRetryMinutes descriptions match. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… archived Questions and reviews archived before silent archive, whose notice was never queued, still had notified_at NULL, so the notice sweep would have told their agents after deploy and the error sweep could have reported the omitted notice as undelivered. Both sweeps now skip archived questions and reviews. From the Codex review of #2862. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From the Codex review of #2862 (P2): archiving resolved the only thing that kept SAM's silent-agent reconciliation off the chat (the unresolved needs_input marker, or the open ask's deadline hold), so an idle task chat became a check-in candidate and the agent got a "[SAM Orchestrator Check-In]" despite archive telling it nothing. - Archiving a question (asks-era or marker-era) now holds the chat's reconciliation gate (questionHold) until a person writes in the chat, for at most inbox.archiveCheckinHoldHours (new admin setting, default 168). holdReconciliationAfterArchive keeps a permanent task exclusion and a pending check-in intent, and never shortens a longer hold. - Any person's chat message now releases a question hold, not only one that closed an open question, so the archive hold ends when the person engages. Tests: reconciliation candidates exclude the chat after an archive hold and include it again after the release (real SQLite); worker tests assert the gate after archiving through the real route (asks and marker) and its release by a real human message. Each guard was removed once and its test went red. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A human message now releases an archive check-in hold, which reads the chat's reconciliation gate: one primary-key do_meta lookup per user message batch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When completing a marker archive fails, release the shared answer/archive claim only if this request staged it. A claim found already staged may belong to another request still in progress (an earlier build during a rolling deploy), so it is left alone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#2881 added result asks. Archive was already silent for every agent ask kind; the two sweeps now also skip results an earlier build archived without a notice, as they do for questions and reviews. The question archived notice text had no caller left and is removed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
e67c97f to
679b7e5
Compare
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
The archive closes its record, then installs SAM's check-in hold through a separate ProjectData call. A person's message persisted in between released a hold that did not exist yet, and the hold was then installed anyway. The archive now reads archivedAt before the closing write and carries it with the hold; ProjectData skips the hold when a person wrote in the chat after it (humanMessageSince). A call without archivedAt (an earlier build) installs the hold as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|



Summary
Problem. Inbox items from finished chats could not be archived. You clicked Archive, saw "Archived · the agent will be told", and ~5 s later the item came back with no error. The reported item,
attention:chat_01M4XS6EE6EAHKSMF9VCZNFGXH:7eece64c-…, is areconciliation_loopcheck-in pause on PR Shepherd run #163. In production its task wascancelled(2026-10-21), its workspacedeleted, its chat stopped, and the marker was still unresolved.Root cause. Archive always tried to tell the agent.
archiveAttentioncalledpreparePromptForLiveAgent, which threw 404No active workspace found for this sessionwhen the chat had no workspace. The claim was then released. The inbox UI treats any 404 as "answered elsewhere" (isStaleInboxError), so it refetched and the item reappeared.Decision (Raphaël, 2026-11-17, reviewing this PR). Archive does not tell the agent: "Either the user chooses to engage, and the agent responds accordingly, or the user archives and leaves things in limbo." This revises decision 4 of inbox spec idea
01M7G03ZCQ6TM6CMEYDRKQ8ST9. Here it applies to questions and reviews; follow-up #2873 extends it to every kind, per his later answer.Change.
archived; no prompt (archiveAttention); a failed complete releases the claimasksarchived+ queued notice; sweep retried missesarchivedwithnotified_atset in the same write (closeAsk(..., { silent: true })); open chat views getattention.resolved(ProjectData.recordQuestionArchived)[SAM Orchestrator Check-In]reached the agent ~5 min laterinbox.archiveCheckinHoldHours(new admin setting, default 168 h):holdReconciliationAfterArchive; any human message releases it (closeQuestionAsks→releaseQuestionHold). The archive time is read before the closing write, so a message landing between the close and the hold call ends it (humanMessageSince)notified_at IS NULLarchiveAttentionrequirestask:writeand a chat writer (requireSessionWriter). Ask archive no longer callsauthorizeAnswerWake, since nothing wakes. An archive claim left staged by an earlier build is completed, and a failed complete releases the claim only when this request staged it.Validation
pnpm lint(eslint on all changed files clean)pnpm typecheck(api, web, operations, project-data)pnpm test(affected suites; CI: every test job green)Additional validation run: worker suites
inbox-capability(16),inbox-agent-tools-capability,inbox-tasks-capability; api unit operations / services/inbox / system-errors / mcp; web inbox 428/428If this PR changes candidate selection for a sweep/cron/alarm loop: the two inbox sweeps gain an exclusion (
NOT (status='archived' AND kind IN ('question','review'))), which can only shrink their candidate sets; per-candidate cost is unchangedI/O: archive adds no round trips (the hold rides the existing
recordQuestionArchivedRPC, plus one indexed read in the DO). Each human chat message adds one primary-keydo_metaread (releasing a hold); the ingest-cost snapshot records it.Discrimination: with the old notify-on-archive code restored, exactly the rewritten archive tests failed. Each of these goes red with its guard removed, and only it:
reconciliation-loop.test.ts: archive hold → no candidate, human message → candidate);inbox-capability.test.ts);archivedAt-before-close assertion (question-asks.test.ts);chat-attention-archive-claim.test.ts).Staging Verification (REQUIRED for all code changes — merge-blocking)
Deploy Stagingrun 44222314000 (staging2, heada817fdf88) passed, including smoke testsapp.sammy2.partyasstaging2-test-user(workload identity) and drove the real inbox UI/dashboard,/projects, project Overview, project Chat and/settingsload, with no failed API calls and no console errorsStaging Verification Evidence
Full detail: #2862 (comment)
inbox_write askquestions.{outcome:"archived", agentNotified:false}. The item left the inbox, no chat messages arrived in 45 s, and the agent stayedawaiting_followup.Check-in hold (staging2, head
e67c97fd0,Deploy Stagingrun 44268113294):{outcome:"archived", agentNotified:false}, and the chat card reads "Archived".in_progress.[SAM Orchestrator Check-In]arrived about 5 minutes later. So check-ins are live on staging2, and writing in the chat ends the hold.resultleft by Inbox: agents hand finished answers to you as Result items #2881's staging run before that kind existed on this branch; it is merged now.UI Compliance Checklist (Required for UI changes)
UI Screenshot Evidence
Screenshots taken with Playwright on staging2 and stored in the project Library at
/pr-evidence/2862-inbox-archive/staging2/. Listed in #2862 (comment).Surface: Inbox item Archive receipt (desktop list + item view)
desktop-live-before.png,desktop-live-receipt.png, 1280×800)mobile-stopped-receipt.png, 375×667)Surface: Inbox item view on phone (full-screen item)
desktop-live-before.png)mobile-stopped-before.png,mobile-stopped-receipt.png)End-to-End Verification (Required for multi-component changes)
Data Flow Trace
usePendingArchive(apps/web/src/components/inbox/useInbox.ts) →archiveInboxItem(apps/web/src/lib/api/inbox.ts) →POST /api/projects/:projectId/inbox/items/:ref/archive(apps/api/src/routes/inbox.ts).archiveInboxItem(packages/operations/src/inbox-write-core.ts) →requireActable. Then:closeAsk(..., { silent: true })setsstatus='archived'andnotified_atin one write, thenports.inbox.questionArchived→announceQuestionArchived(apps/api/src/services/inbox/agent-asks.ts) →ProjectData.recordQuestionArchivedbroadcastsattention.resolved.ports.inbox.archiveAttention→archiveAttention(apps/api/src/routes/chat-attention.ts), which callsprepareAttentionArchivethencompleteAttentionArchive(packages/project-data/src/do/attention.ts).archiveCheckinHold(read before the closing write) →ProjectData.recordQuestionArchived→holdReconciliationAfterArchive(packages/project-data/src/do/reconciliation-candidate-state.ts) unlesshumanMessageSince(archivedAt). The reconciliation loop then skips the chat until the gate'snextAttemptAt; a human message →closeQuestionAsks→releaseQuestionHold.runInboxAskSweep(apps/api/src/services/inbox/sweep.ts) andfileUndeliveredAskAnswers(apps/api/src/services/inbox/system-errors.ts) skip archived questions, reviews and results.Untested Gaps
N/A: full flow covered by automated tests and the staging run. One limitation: marker-era questions (filed before slice G) can't be created on staging any more; they are covered by worker tests through the real route, Durable Object and D1.
Post-Mortem (Required for bug fix PRs)
What broke
Inbox items from chats whose workspace was gone could never be archived. Archive appeared to work, then the item silently returned.
Root cause
Inbox slice A/C (#2776, #2779) implemented archive as "tell the agent" through the live-agent prompt path. That path requires a live workspace (
resolveLiveAgentSessionForChat), andisStaleInboxErrortreated the resulting 404 as an item closed elsewhere.Class of bug
An action that depends on a downstream side effect (notifying a runtime that may no longer exist) whose failure is classified by the client as benign. The user-visible operation becomes impossible without any error.
Why it wasn't caught
Every archive test used a live workspace and agent. No test archived an item from a chat whose runtime was gone, and the client's 404 → "stale" mapping hid the failure.
Process fix included in this PR
The incident-shape test (archive on a stopped chat with a deleted workspace) and archive tests that assert no notice. The design that made archive depend on a live agent is removed. No rule change: rules 62 and 58 already cover "reach the feature the way production does" and destroyer/resumer agreement.
Post-mortem file
This PR body; spec note on idea
01M7G03ZCQ6TM6CMEYDRKQ8ST9(note01M7N16136DNNG3T7F0HGENXST).Specialist Review Evidence (Required for agent-authored PRs)
needs-human-reviewlabel added and merge deferred to human (N/A: every reviewer completed.)recordQuestionArchived). Stale button label and docs fixed in 991084farchivedAt+humanMessageSince). P2 finishing another request's in-flight claim: release now limited to our own claim; completing a stranded claim kept, with reasons. P2 failed hold RPC not repaired: accepted, worst case is the pre-PR check-in, reasons in the thread. All threads resolvedCodeRabbit Review Evidence (Required for agent-authored PRs)
CodeRabbit Notes
Requested at 15:50Z by applying the
coderabbit-reviewlabel when the PR was marked ready. Within minutes CodeRabbit replied with a rate-limit notice, so the wait ended at once and no review arrived (rule 25: recorded and skipped).Exceptions (If any)
9b79bb5f4) was not redeployed to staging. Staging verified the feature ona817fdf88ande67c97fd0(above). Later commits:665823e7e(claim release on a failure path);679b7e570(results archive silently through the samecloseAsk(..., { silent: true })path staging exercised for questions; sweep exclusions);9b79bb5f4(a race between an archive and a chat message).Agent Preflight (Required)
Classification
External References
N/A: no external APIs involved; the change is internal to the inbox operations, ProjectData Durable Object and D1.
Codebase Impact Analysis
packages/operations/src/inbox-write-core.ts(archive switch,closeAsksilent option) andports.ts(questionArchived).apps/api/src/routes/chat-attention.ts(archiveAttention: writer check, claim, complete, no prompt) andapps/api/src/services/inbox/{agent-asks,port,sweep,system-errors}.ts.packages/project-data(recordQuestionArchivedRPC + client).apps/web/src/components/inbox/{useInbox,useInboxWalk}.tsandapps/web/src/pages/inbox/InboxPage.tsx: receipt and accessible-name copy only.requireActableand thecloseAskpredicate; markers still requiretask:writeand a chat writer.Documentation & Specs
apps/www/src/content/docs/docs/guides/inbox.md(Archive section)apps/www/src/content/docs/docs/reference/api.md(archive route and paragraph, wake-right sentence)apps/www/src/content/docs/docs/guides/admin-settings.mdandpackages/operations/src/inbox-settings-definition.ts(noticeRetryMinutes)apps/www/src/content/docs/docs/guides/recent-product-changes.md01M7G03ZCQ6TM6CMEYDRKQ8ST9: decision note addedConstitution & Risk Check
🤖 Generated with Claude Code