Repository navigation
feat(server): redirect wakes aimed at a retired thread to its replacement - #211
Open
nullStack65 wants to merge 2 commits into
Open
nullStack65 wants to merge 2 commits into
nullStack65 wants to merge 2 commits into
Conversation
…ment A retired standing-bot thread now carries a tombstone (replacedByThreadId, retiredAt). Every wake aimed at it (thread_send, schedule, pr_watch, event) resolves the chain to the live replacement (max 8 hops, fail closed on cycle or dead end), so the retired thread never starts a provider turn. Each redirect appends a record to retired-thread-redirects.jsonl (override with RETIRED_REDIRECT_LEDGER). t3_thread_update gains action set_redirect; self-redirects and cycles are rejected at write time. Model: claude-sonnet-5-5 Task: CLO-1001 Agent: claude-code Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
Owner
Author
{
"reviewed_head": "354682bce7208624870a15cf984e754e70cceac1",
"reviewer": "gemini-4-neon, antigravity",
"findings": [
{
"id": "F1",
"severity": "critical",
"summary": "Unprivileged set_redirect + unchecked redirect target in t3_thread_send allows wake hijacking and runtime-mode privilege escalation (ThreadMetadataMcpService.ts:203-257, OrchestratorMcpService.ts:3622-3686).",
"outcome": "open"
},
{
"id": "F2",
"severity": "important",
"summary": "apps/server vp run typecheck fails (exit 2): PullRequestWatchReactor.ts missing ThreadId import (TS2304) and unnarrowed route (TS18048), ThreadManagementService.test.ts exactOptionalPropertyTypes (TS2379), ModelAlertReactor.ts unknown error channel (TS377030), and Effect tsgo lint errors in RetiredThreadRedirect.ts and tests.",
"outcome": "open"
},
{
"id": "F3",
"severity": "nit",
"summary": "OrchestratorMcpService.sendToThread returns the retired input.threadId/link and retries worktree preparation against input.threadId instead of the redirected target (OrchestratorMcpService.ts:3697-3727).",
"outcome": "open"
},
{
"id": "F4",
"severity": "nit",
"summary": "redirectLinkError only checks missing/deleted on immediate replacementId and accepts linking onto a chain whose downstream target is missing/deleted (packages/contracts/src/threadRedirect.ts:119-126); runtime still fails closed.",
"outcome": "open"
}
]
}Independent Cross-Family Review (
|
…ed sends, typecheck clean Addresses the cross-family review of the retired-thread redirect (CLO-1001): - F1: set_redirect (set or clear) now needs a full-access, default-mode caller (thread and client ceiling). thread_send re-validates the resolved live replacement against the caller's runtime/interaction limits and live-caller check before sending, so a redirect cannot reach a wider-mode thread. - F2: server typecheck exits 0. Ledger code uses Effect Config/FileSystem/Path instead of node builtins and process.env; tests use a shared withRedirectLedger helper; PullRequestWatchReactor narrows `route`, imports ThreadId; ModelAlertReactor takes the orchestrator's getThreadShell type. - F3: thread_send returns the live thread that took the message and retries failed worktree setup against it. - F4: redirectLinkError walks downstream and rejects a chain ending at a missing or deleted thread. Regression tests: set_redirect authority matrix, resolved-target limit refusal, live-thread result and setup retry, downstream chain validation. Model: claude-sonnet-5-5 Task: CLO-1001 Agent: claude-code Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Owner
Author
{
"reviewed_head": "354682bce7208624870a15cf984e754e70cceac1",
"rechecked_head": "266c139e996f5ba0d352f6d5bdfdb456d6b9935e",
"reviewer": "gemini-4-neon, antigravity",
"findings": [
{
"id": "F1",
"severity": "critical",
"summary": "Unprivileged set_redirect + unchecked redirect target in t3_thread_send allows wake hijacking and runtime-mode privilege escalation (ThreadMetadataMcpService.ts:203-257, OrchestratorMcpService.ts:3622-3686).",
"outcome": "confirmed",
"rechecked_head": "266c139e996f5ba0d352f6d5bdfdb456d6b9935e"
},
{
"id": "F2",
"severity": "important",
"summary": "apps/server vp run typecheck fails (exit 2): PullRequestWatchReactor.ts missing ThreadId import (TS2304) and unnarrowed route (TS18048), ThreadManagementService.test.ts exactOptionalPropertyTypes (TS2379), ModelAlertReactor.ts unknown error channel (TS377030), and Effect tsgo lint errors in RetiredThreadRedirect.ts and tests.",
"outcome": "confirmed",
"rechecked_head": "266c139e996f5ba0d352f6d5bdfdb456d6b9935e"
},
{
"id": "F3",
"severity": "nit",
"summary": "OrchestratorMcpService.sendToThread returns the retired input.threadId/link and retries worktree preparation against input.threadId instead of the redirected target (OrchestratorMcpService.ts:3697-3727).",
"outcome": "fixed",
"rechecked_head": "266c139e996f5ba0d352f6d5bdfdb456d6b9935e"
},
{
"id": "F4",
"severity": "nit",
"summary": "redirectLinkError only checks missing/deleted on immediate replacementId and accepts linking onto a chain whose downstream target is missing/deleted (packages/contracts/src/threadRedirect.ts:119-126); runtime still fails closed.",
"outcome": "fixed",
"rechecked_head": "266c139e996f5ba0d352f6d5bdfdb456d6b9935e"
}
]
}Cross-Family Focused Re-Check (
|
Owner
Author
|
Caller release for {
"reviewed_head": "354682bce7208624870a15cf984e754e70cceac1",
"rechecked_head": "266c139e996f5ba0d352f6d5bdfdb456d6b9935e",
"reviewer": "gemini-4-neon, antigravity",
"findings": [
{
"id": "F1",
"severity": "critical",
"summary": "Unprivileged set_redirect + unchecked redirect target in t3_thread_send allows wake hijacking and runtime-mode privilege escalation (ThreadMetadataMcpService.ts:203-257, OrchestratorMcpService.ts:3622-3686).",
"outcome": "released",
"rechecked_head": "266c139e996f5ba0d352f6d5bdfdb456d6b9935e",
"released_by": "CoS (gemini-4-neon, antigravity)"
},
{
"id": "F2",
"severity": "important",
"summary": "apps/server vp run typecheck fails (exit 2): PullRequestWatchReactor.ts missing ThreadId import (TS2304) and unnarrowed route (TS18048), ThreadManagementService.test.ts exactOptionalPropertyTypes (TS2379), ModelAlertReactor.ts unknown error channel (TS377030), and Effect tsgo lint errors in RetiredThreadRedirect.ts and tests.",
"outcome": "confirmed",
"rechecked_head": "266c139e996f5ba0d352f6d5bdfdb456d6b9935e"
},
{
"id": "F3",
"severity": "nit",
"summary": "OrchestratorMcpService.sendToThread returns the retired input.threadId/link and retries worktree preparation against input.threadId instead of the redirected target (OrchestratorMcpService.ts:3697-3727).",
"outcome": "fixed",
"rechecked_head": "266c139e996f5ba0d352f6d5bdfdb456d6b9935e"
},
{
"id": "F4",
"severity": "nit",
"summary": "redirectLinkError only checks missing/deleted on immediate replacementId and accepts linking onto a chain whose downstream target is missing/deleted (packages/contracts/src/threadRedirect.ts:119-126); runtime still fails closed.",
"outcome": "fixed",
"rechecked_head": "266c139e996f5ba0d352f6d5bdfdb456d6b9935e"
}
]
} |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Deploy: fleet
Problem
A retired standing-bot thread could still be woken by a message, a scheduled task, a PR watch or an event subscription, starting a provider turn on a thread that should be dead.
Fix
AppThread/ThreadShellgainreplacedByThreadIdandretiredAt(optional JSON fields, so no DB migration).thread.metadata.updatesets or clears them. Re-pointing keeps the originalretiredAt. Self-redirects, cycles, missing/deleted replacements and chains over 8 hops are rejected at write time.resolveActiveThreadTarget(packages/contracts/src/threadRedirect.ts) follows the chain, max 8 hops, and fails closed with a typedThreadRedirectError(cycle/too_deep/dead_end).thread_send,schedule(ThreadManagementService / ThreadMessageIntake),pr_watchandevent(PullRequestWatchReactor, ModelAlertReactor). On a cycle or dead end the wake is dropped with a warning, never delivered to the retired thread. The OrchestratordispatchMessagealso refuses a message to a retired thread as a backstop (human notes exempt)..1at 8 MiB, 2s timeout, errors logged and never thrown).Contract
t3_thread_updatewithaction: "set_redirect"andreplacedByThreadId: "<threadId>";nullclears the tombstone. No CLI added.$RETIRED_REDIRECT_LEDGERif set, else<T3 home>/userdata/retired-thread-redirects.jsonl(prod:~/.t3/userdata/retired-thread-redirects.jsonl).timestamp(ISO-8601),retiredThreadId,redirectedToThreadId,sourceKind(thread_send|schedule|pr_watch|event),hopCount, and when knowncallerThreadId,taskId,subscriptionId,prUrl.Known limitations
dispatchMessage.ModelAlertReactor.makehas no direct test; it sharesresolveWakeTarget, which is covered.Verification
packages/contractsandapps/servertypecheck clean. New tests: contracts resolver (16), RetiredThreadRedirect (8), ThreadManagementService thread_send/schedule, runtimeLayer pr_watch and event-row redirect, ModelAlertReactor watcher redirect. Broad targeted server run: 1445 passed, 6 failed. The 6 are pre-existing on the base:ThreadStop"switched provider instance" and the 4OrchestratorMcpToolkit.integrationchild-result tests (timeouts), both reproduced with my changes stashed. Not run: repo-wide checks (per repo policy).Release freeze is Nov 25 22:00 UTC: do not merge before then.
Model: claude-sonnet-5-5
Task: CLO-1001
🤖 Generated with Claude Code