Cause: the bakery lock's wait for a peer is bounded at LOCK_WAIT_MS (250ms). When it ran out, Store.change returned undefined and the charge's callback never ran: the chat succeeded and its charge was dropped. Two hosts charging back to back on a busy runner (a GC or scheduling stall in the holder, or many contenders) hit that, which is the 199 of 200 in publish run 43040437938. An unreadable ledger dropped the change the same way. Mutual exclusion itself held: an instrumented copy logged one lock timeout per missing charge and no unexplained loss. Fix: Store.update. A change whose lock wait runs out, or whose read fails, hasn't run, so it is kept in memory (capped at 1000) and runs once, in order, the next time the store holds the lock and can read the ledger: on its next update, from an unref'd retry timer (25ms doubling to 5s, each waiting 25ms), or from the exit hook, which waits up to 2s. A failed read still never writes. A throwing callback still leaves the disk as it was. change, anchor and setPrices go through it. charge and the credit refusal date their record when the call ended, not when a kept change runs. The crash-phase tests' instrumented module goes to a file: as a data: URL on the command line it passed Windows' 32K limit. Tests: the live-owner, leftover-record and choosing tests now hold that the waiting changes land (they asserted the drop). New: a Node and a Bun host that exits while its charge waits for a busy peer still writes it. Ran (worktree ata69931ec+ this change): - stress: 8 processes x 60 changes, holder pauses up to 200ms: old code lost 17-71 (mote), 93-108 (Windows) charges, each a lock timeout; new 480/480 on mote, Linux and Windows, Node and Bun, with 39-146 timeouts each. - old gumloop.mjs under the new tests: 6 red. - broken by hand: no exit flush -> both exit tests red; no retry timer -> the live-owner test red. - packages/gumloop bun test x20: mote 20/20, magpie-desktop (Linux) 20/20, xiaomi-gpu (Windows, temp HOME/USERPROFILE) 20/20. - bun scripts/check.mjs ok; root bun test on magpie-desktop (Linux, under the suite lock): 8374 pass, 19 skip, 0 fail - rebased on2b87fad9(no gumloop change between): packages/gumloop bun test x5 on mote 5/5, bun scripts/check.mjs ok. Not tried: a host killed (not exited) with kept changes loses them; no network filesystem.
37 lines
881 B
JSON
37 lines
881 B
JSON
{
|
|
"name": "@magpie-community/opencode-gumloop-auth",
|
|
"version": "0.1.1",
|
|
"description": "Gumloop (gumloop.com) with your API key and user id in OpenCode and magpie: per-account models, and a credit estimate Gumloop's API doesn't give",
|
|
"homepage": "https://www.gumloop.com/",
|
|
"type": "module",
|
|
"main": "./opencode.mjs",
|
|
"exports": { ".": "./opencode2.mjs" },
|
|
"files": [
|
|
"index.mjs",
|
|
"gumloop.mjs",
|
|
"opencode.mjs",
|
|
"opencode2.mjs",
|
|
"README.md",
|
|
"LICENSE"
|
|
],
|
|
"keywords": [
|
|
"opencode",
|
|
"opencode-plugin",
|
|
"magpie",
|
|
"gumloop"
|
|
],
|
|
"license": "MIT",
|
|
"repository": {
|
|
"type": "git",
|
|
"url": "https://github.com/magpie-community/plugins",
|
|
"directory": "packages/gumloop"
|
|
},
|
|
"scripts": {
|
|
"test": "bun test"
|
|
},
|
|
"magpie": {
|
|
"icon": "https://www.gumloop.com/favicon.ico",
|
|
"maxConcurrency": 4
|
|
}
|
|
}
|