Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

Commits on main

fix(brain): keep a failure visible while an automatic retry is in flight\n\n`coderabbitai` is right, and the defect is one this PR created. `setError(null)`\nat the top of every `load()` was correct while every load was user- or\nevent-driven: the previous failure is no longer what is being reported. A\ntimer-driven retry is different — nothing has changed from the user's point of\nview, so blanking the alert (or #5942's stale-data warning) for the duration of\nthe request makes the failure flicker out and back for no perceivable reason.\nThe window where the user sees nothing is exactly the window the ladder creates.\n\nTook the proposed `load(isAutomaticRetry = false)` shape over deriving it from\n`attempt > 0`: `attempt` is reset by a success, so it answers "how deep is the\nladder", not "who asked for this load", and the two come apart precisely in the\noverlapping-load cases this PR already had to reason about. An explicit\nparameter says the thing being asked.\n\nThe error still clears on an accepted success, which is when it stops being true.\n\nAlso hardened the ladder test `tinysweeper` flagged: it advanced timers straight\nafter dispatching the refetch event, so it could have measured a retry arming\nthat had not happened yet — the timer is armed inside the catch. It now asserts\nthe alert is present first, which proves the catch ran.\n\nThat assertion is deliberately NOT wrapped in `waitFor`. This file runs on fake\ntimers and `waitFor` polls on real ones, so it never retries and hangs to the\n30s test timeout instead of failing — I hit exactly that writing this, twice.\nThe enclosing `act` has already flushed the rejection's microtask, which is what\nmakes the direct read sound.\n\nRevert-proofed:\n - P3, unconditional `setError(null)` restored -> ONLY the new visibility test\n fails.\n - M1', retry never scheduled -> the visibility test AND the collision test\n fail, among others, which is the evidence that both genuinely depend on the\n ladder firing.\n\n22/22 across all three Brain suites (Brain, Brain.errorRecovery,\nBrain.autoRetry), sources restored, typecheck clean.\n
M3gA-Mind committed 3 months ago
7b7838a
fix(brain): let a superseded success through when the newer load failed\n\nThe rebase onto #5942 surfaced a real disagreement between the two PRs, not a\nmerge artefact. #5942's test `does not warn when an older load succeeds after a\nnewer one failed` fails against this branch, and it is right to.\n\nThe guard was asking the wrong question. `generation` says which REQUEST is\nnewest; what a success needs protecting from is newer DATA. Those are the same\nthing right up until the newer request FAILS, and then they are not: with\n`myGeneration !== generation` the older success was dropped even though nothing\nnewer had rendered, leaving the user with an error and no graph. That is worse\nthan either PR intends — #5945 wanted to protect a newer graph, and there was\nno newer graph to protect.\n\nSo the success path now tracks `renderedGeneration`, the generation of the\nresponse actually on screen, and discards a success only when NEWER DATA has\nalready rendered. The failure path is unchanged and still strict: a superseded\nrejection must never set an error or arm a retry, because a newer request has\nalready superseded whatever it would say.\n\nThe retry armed by the newer failure is deliberately left armed. The newest\nthing known about the backend is that it failed, so continuing to retry while\nshowing the older data is the correct combination, not a leftover — the new\ntest asserts both halves so a fix that got only one would not pass.\n\nRevert-proofed, and the two halves fall out independently:\n - P1, the strict `myGeneration !== generation` restored -> ONLY the two\n collision tests fail (#5942's, now on main, and the new one).\n - P2, `renderedGeneration` never advanced -> ONLY the superseded-SUCCESS test\n fails, the stale payload overwriting the newer graph.\n\n14/14 across both Brain suites, sources restored, typecheck clean.\n
M3gA-Mind committed 3 months ago
6947060
35f3775
fix(brain): ignore results from superseded graph loads\n\n`chatgpt-codex-connector` and `coderabbitai` independently flagged the same\nrace, and it is real. Two `load()` calls can be in flight at once — the initial\none and a `memory-tree-completed` event, or an automatic retry overtaken by an\nevent — and they share `graph`, `error` and the retry ladder with nothing to\ntell them apart.\n\n`cancelled` does not cover this. It distinguishes THIS effect run from the next\none; it says nothing about two loads inside the same run.\n\nThe retry ladder makes the consequence worse than it was before this PR, which\nis why the guard belongs here: an obsolete rejection did not merely set a stale\nerror, it scheduled a whole retry ladder against a graph that had already\nrefreshed successfully. The mutation below measures that as 5 calls where 2 are\ncorrect.\n\nAdds a monotonic `generation`, captured per invocation, and checks it after the\nawait on both the success and failure paths.\n\nRevert-proofed, both directions:\n - M6, failure-side guard removed -> ONLY the superseded-FAILURE test fails,\n "expected 2 calls, got 5" — the obsolete failure running a full ladder.\n - M7, success-side guard removed -> ONLY the superseded-SUCCESS test fails,\n the stale payload having rolled the newer graph back.\n7/7 green, sources restored, typecheck clean.\n\n#5942 carries the narrower half of this fix (clearing the error on an accepted\nsuccess) because it is the PR that makes a leftover error VISIBLE as a false\n"data is stale" warning. The two are complementary, not duplicates: that one\nremoves the false alarm, this one stops the obsolete work.\n
M3gA-Mind committed 3 months ago
4a5f426
fix(brain): retry a failed graph load automatically, with bounded backoff\n\n`load()` ran only when `[mode, refreshKey, authUserId]` changed or the\n`openhuman:memory-tree-completed` event fired. Nothing retried on its own, so a\nblip during a background refresh left the panel failed until the user noticed\nand pressed Refresh.\n\nAdds a three-step ladder (2s, 4s, 8s) inside the existing effect.\n\nTo be precise about what this is NOT fixing, because the issue was originally\nmisreported and the correction matters: this was never an unrecoverable latch.\n`setError(null)` runs at the top of every `load()`, and `MemoryControls` renders\nabove the error branch, so manual Refresh always worked. The manual path is\nuntouched here. What was missing is AUTOMATIC recovery.\n\nFour decisions worth stating:\n\n - **Bounded, not infinite.** Past three attempts a failure is unlikely to be\n transient, and retrying forever would hammer the core and hide a real\n outage. When the ladder is spent the error stays and manual Refresh is the\n way back.\n - **`attempt` and `retryTimer` are effect-scoped, not refs.** That is what\n makes a manual Refresh restart the ladder rather than inherit a spent one:\n a `refreshKey` change re-runs the effect and both reset naturally.\n - **A success resets the ladder**, so the next transient failure gets the full\n set of retries instead of resuming where an old one left off.\n - **Every `load()` clears a pending timer first**, so a Refresh or a\n `memory-tree-completed` event cannot race a scheduled retry into a double\n fetch. The cleanup clears it too, so no timer outlives the component.\n\nThe delays are a written-out array rather than computed from an exponent: the\ntwo things a reader needs — how long the waits are, and that there are exactly\nthree — are then both visible, and the bound is not an off-by-one away.\n\nTESTS — new file `Brain.autoRetry.test.tsx` rather than extending\n`Brain.errorRecovery.test.tsx`, deliberately: PR #5942 (#5895) edits that file,\nand keeping these in separate files lets the two branches merge in either order.\nFive cases: the retry fires with no user action; it does NOT fire before its\ndelay (otherwise "it retried" would be satisfied by a tight re-fetch loop, the\nthing backoff exists to prevent); it stops after the ladder rather than\nretrying forever; a success resets the ladder; and unmount cancels a pending\nretry so no timer setStates against a dead tree.\n\nNOT VERIFIED BY EXECUTION: local builds and test runs are prohibited under a\ncurrent standing rule, so none of this was run. Verified by reading\nBrain.tsx:94-127 and the harness in Brain.errorRecovery.test.tsx that this file\nreuses; `renderWithProviders` returns `unmount` via `{ store, ...render(...) }`\nat test-utils.tsx:119. The fake-timer interaction in particular is the part I\nwould most want a real run to confirm. CI is the check.\n\nCloses #5904\n
M3gA-Mind committed 3 months ago
8403184