🌊 The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated
TypeScript agentic-aiagentic-frameworkagentic-workflowagentsai-agentsai-assistantai-skillsautonomous-agentsclaudecodexdsh-pluginharnessmcp-servermulti-agentmulti-agent-systemsnpmskillsswarmswarm-intelligencetypescript
fix(ruflo-console): the hive strip holds still between writes; halo and byzantine agree
ruva0d970d62b45
diff --git a/plugins/ruflo-console/hooks/data/hive.ts b/plugins/ruflo-console/hooks/data/hive.tsindex 6b43b91d94..2dc6c8797f 100644--- a/plugins/ruflo-console/hooks/data/hive.ts+++ b/plugins/ruflo-console/hooks/data/hive.ts@@ -116,7 +116,7 @@ export function waveOf(events: readonly ConsoleEvent[], id: string, nowMs: numbe/*** When the console first saw each broadcast, so the ticker slides a new one in once. Everything present at the first- * read counts as old (arrived at 0), so opening the view never animates what was already there.+ * read counts as old (arrived at -Infinity), so opening the view never animates what was already there.*/export class Arrivals {private readonly seen = new Map<string, number>()@@ -130,7 +130,7 @@ export class Arrivals {this.seen.clear()}- for (const id of ids) if (!this.seen.has(id)) this.seen.set(id, isFirst ? 0 : nowMs)+ for (const id of ids) if (!this.seen.has(id)) this.seen.set(id, isFirst ? Number.NEGATIVE_INFINITY : nowMs)// Forget what the hive no longer keeps (it holds the last 100), so the map stays the hive's size.if (this.seen.size > ids.length * 2 + 16) for (const id of [...this.seen.keys()]) if (!ids.includes(id)) this.seen.delete(id)diff --git a/plugins/ruflo-console/hooks/gfx/hive-strip.ts b/plugins/ruflo-console/hooks/gfx/hive-strip.tsindex f2b53f6de7..9dcbcd4b98 100644--- a/plugins/ruflo-console/hooks/gfx/hive-strip.ts+++ b/plugins/ruflo-console/hooks/gfx/hive-strip.ts@@ -20,7 +20,8 @@ export type StripModel = {shield: Shieldstrategy: stringstartMs: number- nowMs: number+ /** The axis ends at the hive's last write, not the clock, so the marks hold still between writes. */+ endMs: numberterm?: numberelectedAtMs?: numbermarks: Mark[]@@ -60,7 +61,7 @@ function drawShield(grid: Grid, shield: Shield, strategy: string): void {grid.text(2, 1, `f ${shield.faulty}`.padEnd(4), HIVE_COLOR.gold, bg)grid.text(6, 1, `of ${shield.of}`.slice(0, 5), HIVE_COLOR.white, bg)- grid.text(2, 2, (shield.rule.split(' ')[1] ?? '').slice(0, 8), addLight(tone, HIVE_COLOR.white, 0.3), bg)+ grid.text(2, 2, shield.rule.split(' ').slice(1).join('').slice(0, 8), addLight(tone, HIVE_COLOR.white, 0.3), bg)// One pip per worker, the ones the strategy survives losing in gold.const pips = Math.min(MAX_PIPS, shield.of)@@ -70,15 +71,15 @@ function drawShield(grid: Grid, shield: Shield, strategy: string): void {grid.text(3, 4, strategy.slice(0, 6), tone, bg)}-/** The column a time falls in on an axis `width` cells wide from `startMs` to `nowMs`. */-export function axisAt(atMs: number, startMs: number, nowMs: number, width: number): number {- const span = Math.max(1, nowMs - startMs)+/** The column a time falls in on an axis `width` cells wide from `startMs` to `endMs`. */+export function axisAt(atMs: number, startMs: number, endMs: number, width: number): number {+ const span = Math.max(1, endMs - startMs)return Math.max(0, Math.min(width - 1, Math.round(((atMs - startMs) / span) * (width - 1))))}function drawTimeline(grid: Grid, model: StripModel, x0: number, width: number): void {- const at = (ms: number) => x0 + axisAt(ms, model.startMs, model.nowMs, width)+ const at = (ms: number) => x0 + axisAt(ms, model.startMs, model.endMs, width)const elected = model.electedAtMs === undefined ? null : at(model.electedAtMs)grid.text(x0, 0, 'TERMS', HIVE_COLOR.pink)@@ -102,7 +103,7 @@ function drawTimeline(grid: Grid, model: StripModel, x0: number, width: number):if (grid.glyph(x, 3) === 0x20) grid.text(x, 3, mark.label.slice(0, 5), addLight(0x000000, color, 0.7))}- const right = 'now'+ const right = 'last write'grid.text(x0 + width - right.length, 1, right, HIVE_COLOR.grey)}diff --git a/plugins/ruflo-console/hooks/gfx/hive.ts b/plugins/ruflo-console/hooks/gfx/hive.tsindex bec1b35777..8dec288004 100644--- a/plugins/ruflo-console/hooks/gfx/hive.ts+++ b/plugins/ruflo-console/hooks/gfx/hive.ts@@ -135,6 +135,9 @@ export function heartbeat(t: number): number {return HEART[Math.floor(phase * HEART.length) % HEART.length] as number}+/** The halo's wall colour at `t`: half lit at rest (still pink after 256-colour quantisation, not a grey wall), brighter at the beat. */+export const haloColor = (t: number): number => addLight(HIVE_COLOR.faint, HIVE_COLOR.pink, 0.5 + heartbeat(t))+/** The walls of a cell, the bottom edge carrying the cell's own light under it. */export function drawWalls(grid: Grid, x: number, y: number, wall: number, bg?: number): void {SHAPE.forEach((line, dy) => {@@ -182,8 +185,6 @@ function drawQueen(grid: Grid, model: HivePictureModel, x: number, y: number, t:/** The halo: the six cells around the queen get pink light on their walls, swelling and fading with her heartbeat; a* blinking or Byzantine neighbour keeps its own walls. */function drawHalo(grid: Grid, columns: number, rows: number, t: number, lit: Set<string>): void {- const k = heartbeat(t)-for (const [q, r] of [[1, 0], [1, -1], [0, -1], [-1, 0], [-1, 1], [0, 1]] as const) {if (lit.has(`${q},${r}`)) continue@@ -194,7 +195,7 @@ function drawHalo(grid: Grid, columns: number, rows: number, t: number, lit: Setconst at = grid.glyph(x + dx, y + dy)// Only the walls the queen does not share: hers stay pink whatever the beat.- if (ch !== ' ' && at === ch.codePointAt(0)) grid.set(x + dx, y + dy, ch, addLight(HIVE_COLOR.faint, HIVE_COLOR.pink, 0.3 + k))+ if (ch !== ' ' && at === ch.codePointAt(0)) grid.set(x + dx, y + dy, ch, haloColor(t))})})}diff --git a/plugins/ruflo-console/hooks/views/hive.ts b/plugins/ruflo-console/hooks/views/hive.tsindex 23eed96967..e7651f1e3f 100644--- a/plugins/ruflo-console/hooks/views/hive.ts+++ b/plugins/ruflo-console/hooks/views/hive.ts@@ -50,6 +50,8 @@ export function hivePictureModelOf(state: State, nowMs: number): HivePictureModeif (snap === null || hive === null) return nullconst picked = pickedProposal(hive, state.select.item)+ // Red walls for a voter any open proposal excluded as Byzantine, the same count the heading gives.+ const flagged = new Set(hive.pending.flatMap(proposal => proposal.byzantine))const members = membersOf(hive, snap.hiveAgents, snap.agents).map((member): HiveCell => {const ballot = picked?.ballots.find(entry => entry.voter === member.id)const wave = waveOf(state.events, member.id, nowMs)@@ -60,7 +62,7 @@ export function hivePictureModelOf(state: State, nowMs: number): HivePictureModeglow: member.liveness,tag: shortId(member.id).slice(-4),...(picked !== null && { vote: ballot === undefined ? ('pending' as const) : ballot.isFor ? ('for' as const) : ('against' as const) }),- ...(picked?.byzantine.includes(member.id) === true && { isByzantine: true }),+ ...(flagged.has(member.id) && { isByzantine: true }),...(wave !== null && { wave }),}})@@ -114,20 +116,22 @@ export function stripOf(hive: HiveInfo, nowMs: number): StripModel {...hive.pending.flatMap(proposal => (proposal.proposedAtMs === undefined ? [] : [{ atMs: proposal.proposedAtMs, kind: 'opened' as const, label: proposal.type, ...(proposal.term !== undefined && { term: proposal.term }) }])),].sort((a, b) => a.atMs - b.atMs)const seen = arrivals.arrivedAt(`${hive.createdAtMs ?? 0}:${hive.queen ?? ''}`, hive.broadcasts.map(entry => entry.id), nowMs)- const times = [hive.createdAtMs, hive.queenElectedAtMs, ...marks.map(mark => mark.atMs)].filter((ms): ms is number => ms !== undefined && ms <= nowMs)+ const times = [hive.createdAtMs, hive.queenElectedAtMs, hive.updatedAtMs, ...marks.map(mark => mark.atMs)].filter((ms): ms is number => ms !== undefined)+ // The axis runs from the hive's first date to its last write: read from the file, so it holds still between writes.+ const startMs = times.length === 0 ? 0 : Math.min(...times)return {shield: faultTolerance(hive.strategy, hive.workers.length),strategy: hive.strategy ?? 'n/a',- startMs: times.length === 0 ? nowMs - 60_000 : Math.min(...times),- nowMs,+ startMs,+ endMs: times.length === 0 ? 1 : Math.max(startMs + 1, ...times),...(hive.queenTerm !== undefined && { term: hive.queenTerm }),...(hive.queenElectedAtMs !== undefined && { electedAtMs: hive.queenElectedAtMs }),marks,pheromones: hive.broadcasts.slice().reverse()- .map(entry => ({ id: entry.id, text: `${entry.priority === 'normal' ? '' : `[${entry.priority}] `}${entry.from}: ${entry.message}`, isLoud: entry.priority === 'high' || entry.priority === 'critical', arrivedAtMs: seen.get(entry.id) ?? 0 })),+ .map(entry => ({ id: entry.id, text: `${entry.priority === 'normal' ? '' : `[${entry.priority}] `}${entry.from}: ${entry.message}`, isLoud: entry.priority === 'high' || entry.priority === 'critical', arrivedAtMs: seen.get(entry.id) ?? Number.NEGATIVE_INFINITY })),keys: hive.memoryKeys.filter(key => key !== 'broadcasts'),}}diff --git a/plugins/ruflo-console/tests/hive.spec.ts b/plugins/ruflo-console/tests/hive.spec.tsindex 22bc99d1bc..9720b328a5 100644--- a/plugins/ruflo-console/tests/hive.spec.ts+++ b/plugins/ruflo-console/tests/hive.spec.ts@@ -9,7 +9,7 @@ import { diffEvents } from '../hooks/data/events'import { Arrivals, faultTolerance, membersOf, nextVoter, pickedProposal, proposalStrategyOf, proposeBlock, requiredVotes, tallyOf, waveOf } from '../hooks/data/hive'import { parseAgents, parseHive, parseHiveAgents, type HiveInfo } from '../hooks/data/parse'import type { Snapshot } from '../hooks/data/snapshot'-import { CELL_BG, CELL_H, CELL_W, cellOrigin, drawWalls, fieldOf, HEARTBEAT_MS, heroRows, hexDistance, HIVE_COLOR, hivePicture, INTERIOR, type HiveCell, type HivePictureModel, type Role } from '../hooks/gfx/hive'+import { CELL_BG, CELL_H, CELL_W, cellOrigin, drawWalls, fieldOf, haloColor, HEARTBEAT_MS, heroRows, hexDistance, HIVE_COLOR, hivePicture, INTERIOR, type HiveCell, type HivePictureModel, type Role } from '../hooks/gfx/hive'import { chamberLayout, chamberRows, chambersPicture, type Chamber } from '../hooks/gfx/hive-chamber'import { EGG_BOTTOM_ROWS, EGG_TOP_ROWS, eggBottomPicture, eggTopPicture } from '../hooks/gfx/hive-egg'import { axisAt, STRIP_ROWS, stripPicture, tickerShift, type StripModel } from '../hooks/gfx/hive-strip'@@ -17,6 +17,7 @@ import { DEFAULT, Grid } from '../hooks/gfx/raster'import { hiveBroadcast, hivePropose, hiveSpawn, hiveVote, proposalText } from '../hooks/hive'import { BFT_ID, HIVE_AGENTS, HIVE_STATE, RAFT_ID, WORKERS } from './fixtures/hive'import { HIVE_TOKEN } from './fixtures/ruflo-run'+import { stripOf } from '../hooks/views/hive'const hive = parseHive(JSON.stringify(HIVE_STATE)) as HiveInfoconst NOW = Date.parse('2026-10-02T01:10:10.000Z')@@ -269,6 +270,8 @@ describe('the honeycomb', () => {const half = hivePicture(still, 90, 1_000 + HEARTBEAT_MS / 2)expect(hivePicture(still, 90, 1_000 + HEARTBEAT_MS).encode()).toBe(grid.encode())+ // At rest the halo is still pink in 256 colours, not a grey wall, and it brightens at the beat.+ expect(new Set([haloColor(0), haloColor((HEARTBEAT_MS * 3) / 8), HIVE_COLOR.wall, HIVE_COLOR.faint].map(xterm256)).size).toBe(4)expect(half.encode()).not.toBe(grid.encode())for (let y = 0; y < grid.rows; y++) {@@ -321,10 +324,10 @@ describe('the hive\'s motion comes from events', () => {it('says a broadcast arrived only once it is new: what the first read finds is old', () => {const log = new Arrivals()- expect(log.arrivedAt('h1', ['a', 'b'], 5_000).get('a')).toBe(0)+ expect(log.arrivedAt('h1', ['a', 'b'], 5_000).get('a')).toBe(Number.NEGATIVE_INFINITY)expect(log.arrivedAt('h1', ['a', 'b', 'c'], 6_000).get('c')).toBe(6_000)expect(log.arrivedAt('h1', ['a', 'b', 'c'], 7_000).get('c')).toBe(6_000)- expect(log.arrivedAt('h2', ['c'], 8_000).get('c')).toBe(0)+ expect(log.arrivedAt('h2', ['c'], 8_000).get('c')).toBe(Number.NEGATIVE_INFINITY)})})@@ -357,7 +360,7 @@ describe('the strip', () => {shield: { faulty: 1, of: 3, rule: 'raft f < n/2' },strategy: 'raft',startMs: 0,- nowMs: 100_000,+ endMs: 100_000,term: 2,electedAtMs: 40_000,marks: [@@ -366,7 +369,7 @@ describe('the strip', () => {],pheromones: [{ id: 'b', text: '[high] system: freeze the main branch', isLoud: true, arrivedAtMs: 50_000 },- { id: 'a', text: 'console-operator: standup in 5', isLoud: false, arrivedAtMs: 0 },+ { id: 'a', text: 'console-operator: standup in 5', isLoud: false, arrivedAtMs: Number.NEGATIVE_INFINITY },],keys: ['design-notes'],}@@ -386,6 +389,13 @@ describe('the strip', () => {expect(still).toContain('◇')})+ it('holds the timeline still between writes: its axis ends at the hive\'s last write, not the clock', () => {+ const now = stripPicture(stripOf(hive, NOW), 100, 0)++ expect(stripPicture(stripOf(hive, NOW + 50_000), 100, 0).encode()).toBe(now.encode())+ expect(stillOf(now)).toContain('last write')+ })+it('slides a new pheromone in for two seconds, then holds still, at one size', () => {expect(tickerShift(model.pheromones, 50_000)).toBe((model.pheromones[0]?.text.length ?? 0) + 5)expect(tickerShift(model.pheromones, 51_000)).toBeGreaterThan(0)@@ -429,6 +439,7 @@ describe('stills for review', () => {'empty comb (egg + start buttons between)': `${stillOf(eggTopPicture(96))}\n [▸ start a hive-mind (raft)] [▸ spawn 3 hive workers]\n${stillOf(eggBottomPicture(96))}`,'a queen and three workers': stillOf(hivePicture(cellModel(3), 96, 0)),'a busy hive: ballots, a byzantine voter, scars, a wave mid-flight at 900 ms': stillOf(hivePicture(waving, 110, 900)),+ 'the strip: shield, terms, pheromones': stillOf(stripPicture(stripOf(hive, NOW), 110, 0)),'voting chambers': stillOf(chambersPicture([{ label: 'design', note: 'raft T2 · timed out', votesFor: 1, votesAgainst: 0, required: 2, nodes: 3, ballots: [{ tag: 'a1b2', isFor: true }], byzantine: [], isPicked: true }, { label: 'deploy', note: 'bft', votesFor: 0, votesAgainst: 1, required: 3, nodes: 3, ballots: [{ tag: 'c3d4', isFor: false }], byzantine: ['e5f6'], isPicked: false }], 110, 0)),}