Skip to content

fix(hive): make the HOP_CAP loop guard real - harness owns hops and increments per bounce - #563

Merged
chaitanyagiri merged 1 commit into
HarnessMD:mainfrom
TTAWDTT:fix/bug-2-hive-routing
Oct 2, 2026
Merged

chaitanyagiri merged 1 commit into
HarnessMD:mainfrom
TTAWDTT:fix/bug-2-hive-routing

Conversation

@TTAWDTT

@TTAWDTT TTAWDTT commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

What & why

The relay-loop guard (HOP_CAP) existed as a check but the harness never owned or incremented the hops counter, so a god↔hookless-worker relay loop was unbounded. The fix makes the harness own the hops field and increment it on every bounce, so the fuse actually trips.

Type of change

  • Bug fix

Evidence

Before

before — tests fail on main

After

after — all tests pass on fix branch

How I tested it

  • OS: Windows 11 Pro (10.0.26200), Node v24.19.0
  • Steps:
    1. Ran node --test test/hive-hop-cap.test.cjs against unfixed main — regression tests fail (red).
    2. Same suite on this branch — all pass (green).
    3. npm run typecheck clean.

Credit (optional)

Discord: ttawdtt

X:

Checklist

  • Before and after evidence is attached above, under both headings.
  • npm run typecheck passes.
  • npm run test:focused passes (except pre-existing Windows-env failures unrelated to this change, identical on clean main).
  • npm run build succeeds.
  • This PR is one change. Unrelated fixes belong in their own PR.
  • I read the diff myself before opening this, and there is no debug output, commented-out code, or unrelated formatting churn in it.
  • Any new UI derives from DESIGN.md / tokens.ts — no ad-hoc colors, spacing, or fonts.
  • If I added art, it's my own or compatibly licensed, and listed in ATTRIBUTION.md.

…ncrements per bounce

The routeMessage() hop-cap check compared msg.hops against HOP_CAP with a
"loop guard - drop a runaway message" comment, but nothing ever incremented
hops: normalize copied the agent-supplied value verbatim and all four
harness bounce paths spread ...msg unchanged, so a god<->hookless-worker
relay loop delivered a duplicate bounce (plus a log line and a git commit)
every 1.5s router tick forever, while an outbox JSON echoing hops: 13 - a
field PROTOCOL.md says the HARNESS fills in - had its first delivery
silently dropped.

normalize() now clamps the agent-carried hops into [0, HOP_CAP] (a carried
relay count keeps climbing toward the fuse; a poison or negative value can
neither fake nor evade it), and the four bounce paths go through a new
bounceToGod() helper - the only place the counter moves, +1 per harness
bounce - where the cap fuse actually fires and drops with reason 'hop-cap'.
The dead check at the top of routeMessage() is removed: with clamped input
it could never fire, and that inoperative "loop guard" was the bug.
@chaitanyagiri
chaitanyagiri merged commit a6bc3b8 into HarnessMD:main Oct 2, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants