Repository navigation
fix(dsh): stale verifyAttachAndRecover landings must never clobber the self-healed register (#1783) - #1787
Conversation
…e self-healed register windows-22 CI on the v0.1.176 release PR (#1783) deadlocked the #983 self-heal test: the apply() attach chain resolves long after it started (loopback probe + evidence grace + process spawn are all slow there), and in the meantime maybeRetry can already have healed the register onto a new origin — the late landing then wiped register.base/toolsReady unconditionally, or registerTools' catch armed a global 10s retryAt against a base the register had already moved past, freezing every later heal attempt behind the wall. Three changes, one contract: a landing may only write the register while it still owns it (base undefined, or still the stale origin the chain set out to replace): - landingOwnsRegister() guards both wipe sites and the fallback origin reset in verifyAttachAndRecover - the unfreeze wipe also clears retryAt — a back-off armed against the stale base dies with it - registerTools scopes its back-off to the base that actually failed Two deterministic regression tests pin the interleavings (slow preset probe; slow spawn seam) — both fail on master, pass with the fix.
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.1764-pr.1787.643b6efThis exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr1787.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 Review 完成 — 结论:可合并,解除 v0.1.176(#1783)的 windows-22 死锁。 结构化七问1. 是什么问题 2. 什么原因导致的 3. 怎么修复的 4. 是否有回归问题 — 审过以下既有行为,逐项结论:
5. 是否破坏缓存 — 不涉及。改动全部限于 dsh 插件进程内的 register/backoff 状态;proxy 侧前缀缓存、会话持久化、去重键均未触碰。 6. 是否改了设计方向 — 没有转向。扩展既有 #983/#1130/#1365 恢复设计,加一条所有权不变量;自愈仍是 request-driven、同一 10s 退避,只是不再被 stale landing 投毒。一个非阻塞观察:同函数内 probe-healthy(:285-286)与 pinned-recovered(:293-294)两处写入仍未纳入契约——分析认为当前安全(飞行中 7. 是否引入了新的配置 — 不涉及。无新 env/config/默认值。 验证证据
后续动作合并 #1787 后请对 release PR #1783 重新触发 CI(它的 windows-latest/node-22 job 就是被这个 bug 卡住的)。按规矩我不合并 PR,请人工合入:#1787 |
Unblocks the v0.1.176 release PR #1783 (windows-22 test deadlock).
Root cause
tests/dsh-native.test.ts#983 maybeRetry self-heals a base-less register after a failed respawntimed out on windows-latest/node 22 only (both attempts of run 36740908901,timeout waiting for plugin headers stamped, 5109ms vs ~62ms locally).The apply() attach chain is a long-lived async landing: loopback probe + evidence grace + process spawn are all slow on the windows runner. While it is in flight,
maybeRetrycan already have self-healed the register onto a NEW origin. When the stale landing finally resolved it:register.base/register.toolsReadyunconditionally (clobbering the heal), orregisterTools' catch armed a globalretryAt = now + 10sagainst a base the register had already moved past, freezing every later heal behind the wall.Local repro: wrapping
globalThis.fetchwith a 40–200ms delay on the dead port-1 preset turns the fast green path into the exact CI deadlock; 0ms always passes.Fix — one contract, three changes
A landing may only write the register while it still owns it (
base === undefinedorbase === staleOrigin):landingOwnsRegister()guards both wipe sites + the fallbackstate.originreset inverifyAttachAndRecoverretryAt— a back-off armed against the stale base dies with itregisterToolsscopes its back-off to the base that actually failed (if (register.base === base))Regression tests
Two deterministic interleavings added to
tests/dsh-native.test.ts:Both fail on master, pass with the fix (verified via stash-revert). Full file: 41/41. Typecheck clean. Product semantics unchanged — self-heal stays request-driven with the same back-off; retries are simply no longer poisoned by stale landings.