Files
plugins/packages/workbuddy/package.json
T
yetone 3167531336 workbuddy 0.2.13: the free window's ledger read is linear in its rows, not their square
xmoon76 (Discord #feedback, 2026-11-02): with WorkBuddy on, the plugin
host (magpie-bun run host-*.js) sat at 99% CPU, every session stalled,
restarting magpie didn't help, and turning WorkBuddy off did.

The cause: readLedgerTail called pinned(chain) after every row of the
account it kept, and pinned walks the whole chain, so a chain with no
edge in it (no readable refusal, no day-wide gap: an account a server
spends on the free model all day) cost the square of its rows. Measured
on mote (bun 1.4.2), a call a minute: 2,000 rows 187 ms, 4,000 771 ms,
8,000 3.1 s, 16,000 10.5 s. That ran on the host's one thread at every
usage read, and the ledger changes with every call so the parse cache
never held: a month of such use (~43,000 rows) is minutes per read. It
reaches the China build since 0.2.12 read its window too, and WorkBuddy
AI before that.

pinning() now answers row by row in constant time what pinned answered
for the rows read so far: the rows only grow at their oldest end and
pinned was asked only while it said 0, so the one new thing a row
brings is the first (newest) readable refusal or a gap between it and
the oldest answered row before it. pinned stays as it was.

Run at this head on mote (bun 1.4.2, HOME=$(mktemp -d)):
- packages/workbuddy bun test: 313 pass, 0 fail.
- whole repo bun test: 4793 pass, 14 skip, 0 fail.
- bun scripts/check.mjs workbuddy: ok.
- The same ledger after: 16,000 rows 14 ms, 64,000 45 ms, same window.
On Linux (wsl-run, magpie-desktop): packages/workbuddy 313 pass, 0 fail;
16,000 rows 28 ms, 64,000 69 ms.

Broken by hand:
- the old per-row pinned(chain) put back: "a busy account's ledger is
  read in time linear in its rows" red, 18,009,000 Date.parse calls for
  12,000 lines (bound 48,000).
- pinning answering a gap with the newer row: "pinning answers as pinned
  does, row by row" and "a gap of a day or more pins the chain too" red.
- pinning keeping the oldest refusal instead of the newest: the
  row-by-row test red.

Not tried: the reporter's own ledger or a Docker install; their magpie
and plugin versions are unknown, so that this was their spin is the
best fit (it persists over restarts, stops with WorkBuddy off, and is
CPU on the host's thread), not a confirmed one.
2026-11-02 18:51:41 +08:00

25 lines
612 B
JSON

{
"name": "@magpie-community/opencode-workbuddy-auth",
"version": "0.2.13",
"description": "OpenCode provider plugins for WorkBuddy's plans: WorkBuddy (CodeBuddy, copilot.tencent.com) and WorkBuddy AI (www.workbuddy.ai)",
"type": "module",
"main": "./index.mjs",
"exports": "./index.mjs",
"files": [
"index.mjs",
"README.md"
],
"keywords": [
"opencode",
"opencode-plugin",
"workbuddy",
"codebuddy"
],
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/magpie-community/plugins.git",
"directory": "packages/workbuddy"
}
}