Repository navigation
Conversation
routeOnce() walked every folder under hive/agents and every outbox on the main thread each 1.5 s tick, archived agents included. On a floor with over a thousand archived temps that walk froze the cursor every 1.5 s (HarnessMD#811). The router now reads the archived ids from registry.json, re-parsing only when the file's mtime or size changes, and skips those outboxes on ordinary ticks. It still walks them on a full sweep: on the tick after registry.json changes, so an agent's last messages are drained after it is archived, and every ROUTER_FULL_SWEEP_EVERY ticks (60 s at the default interval) as a backstop for anything written into an archived outbox later. Refs HarnessMD#811 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
✅ Evidence received. Before and after are both attached. Thanks — this is what makes a PR reviewable in one pass. |
ugurcany
added a commit
to ugurcany/munder-difflin
that referenced
this pull request
Nov 9, 2026
ugurcany
added a commit
to ugurcany/munder-difflin
that referenced
this pull request
Nov 9, 2026
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.
What & why
The hive router (
routeOnce()insrc/main/hive.ts, run every 1.5 s bystartRouter) did a synchronous walk of every folder underhive/agentsand every outbox, archived agents included, on the Electron main thread. Issue #811 measured that walk at 68 to 79 ms per tick over 1,363 folders, and showed it is the 1.5 s series of cursor stalls: moving the archived folders out cut the stalls from 33 to 10 in 30 s and the 1.5 s rhythm disappeared.This change makes ordinary ticks skip agents that
registry.jsonmarksarchived. The archived ids are cached and the registry is re-parsed only when its mtime or size changes, so a tick costs onestatSyncon top of the folder listing.Messages in an archived agent's outbox are still routed, on a full sweep that walks every outbox as before:
registry.jsonchanges. Archiving an agent (setArchived) writes the registry, so whatever that agent left in its outbox just before its tab closed is drained on the next tick.ROUTER_FULL_SWEEP_EVERYticks (40, so 60 s at the default 1.5 s interval), as a backstop for anything written into an archived outbox later, for example by a process the agent left running. Worst case such a message waits 60 s instead of 1.5 s.Agent folders that are not in the registry are still walked every tick, as before.
Not fixed here, because the code is not in this repository: the puck window's
setIgnoreMouseEventsforward hook, and the 3 s series the issue's follow-up attributes tostartConnectionRequests()/processAgentFileRequests(). Both exist only in the packaged 0.5.7 build. I also checkedWORKER_TICK_MS = 1500insrc/main/index.ts: that tick only looks at live workers and thespawn-requestsfolder, not at every agent folder, so it does not have this problem.Refs #811 (the public part only; the 3 s series stays open).
Type of change
Evidence
Performance change, so the evidence is the measurement before and after on the same machine. The benchmark builds a fake hive with 1,363 agent folders, 69 live and 1,294 archived in
registry.json(the shape from the issue), then times 40 calls torouteOnce(). The first call is a full sweep in both cases; the figures below are the other 39. Two runs each, Windows 11, Node 24.12.Before
New test on
main:After
New test on this branch:
The absolute numbers are higher than the issue's 68 to 79 ms because the fake hive sits in the temp folder, which the antivirus scans on this machine; the ratio is the point. What is left per tick (about 10 ms here) is the one
readdirSyncofhive/agentsplus the live agents' outboxes.How I tested it
test/hive-router-archived-walk.test.cjs(its temp folder name contains a space). It checks that an ordinary tick visits only live outboxes, that a message left by an agent that is then archived is routed on the next tick, and that a late write into an archived outbox is routed by the periodic full sweep. Ran it onmain(1 of 3 fails, above) and on this branch (3 of 3 pass).npm run typecheck: passes.npm run test:focused: 965 tests, 936 pass, 15 fail, 14 skipped. The 15 failures are in 11 files (worktree-deps,telemetry-message-count,hooks-socket,quit-sweep.electron,restart-terminal-preserve, and others) and the same 15 fail on unchangedmainon this machine: Windows symlink permissions and anode-ptythat was not rebuilt (npm install --ignore-scripts, because the native rebuild fails here). None touch the router.npm run build: succeeds.mainand this branch.Agent self-review: checked cross-platform paths (only
join), paths with spaces (test uses one), provider neutrality (the router does not look at the provider), and the hot path (onestatSyncper tick; the registry is parsed only when it changes). One thing considered and left: the registry cache keys on mtime plus size, so two writes within the same mtime tick that keep the same size would be missed until the next 60 s sweep. That only delays delivery, it does not lose a message.Credit (optional)
Discord:
X:
Checklist
npm run typecheckpasses.npm run test:focusedpasses. (Passes except 15 failures that also fail onmainon Windows; see above.)npm run buildsucceeds.commented-out code, or unrelated formatting churn in it.
DESIGN.md/tokens.ts— no ad-hoc colors,spacing, or fonts. (No UI change.)
ATTRIBUTION.md. (No art.)🤖 Generated with Claude Code