From 9a26876efc137df46c1912eb7e88ccffadb6ef90 Mon Sep 17 00:00:00 2001 From: ruv Date: Fri, 2 Oct 2026 16:37:03 -0400 Subject: [PATCH] fix(ruflo-console): hive vote asks for JSON so a refused vote reads as refused MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `hive-mind consensus` exits 0 and prints "Vote recorded (For: undefined…)" when the tool refuses a vote (unregistered voter, double vote, Byzantine, already decided); only its --format json output carries the tool's "error" for the runner. The shared-memory key count no longer counts the broadcasts array it lists separately. Co-Authored-By: RuFlo --- plugins/ruflo-console/hooks/hive.ts | 3 ++- plugins/ruflo-console/hooks/views/hive.ts | 3 ++- plugins/ruflo-console/tests/hive.spec.ts | 2 +- plugins/ruflo-console/tests/views.test.ts | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/plugins/ruflo-console/hooks/hive.ts b/plugins/ruflo-console/hooks/hive.ts index 5d5faf0a06..dc4115165f 100644 --- a/plugins/ruflo-console/hooks/hive.ts +++ b/plugins/ruflo-console/hooks/hive.ts @@ -30,7 +30,8 @@ export function hiveVote(hive: HiveInfo, proposal: Proposal, isFor: boolean): Ac return { label: `vote ${isFor ? 'for' : 'against'} ${proposal.type} (${id}) as worker ${voter}`, - args: ['hive-mind', 'consensus', '--action', 'vote', '--proposal-id', id, '--vote', isFor ? 'yes' : 'no', '--voter-id', voter], + // JSON out: the subcommand exits 0 on a refused vote, and only its JSON carries the tool's "error" for the runner. + args: ['hive-mind', 'consensus', '--action', 'vote', '--proposal-id', id, '--vote', isFor ? 'yes' : 'no', '--voter-id', voter, '--format', 'json'], expect: `${voter}'s ballot on the proposal, or the proposal decided`, verify: snapshot => snapshot.hive?.history.some(entry => entry.id === id) === true || snapshot.hive?.pending.some(entry => entry.id === id && entry.ballots.some(ballot => ballot.voter === voter)) === true, } diff --git a/plugins/ruflo-console/hooks/views/hive.ts b/plugins/ruflo-console/hooks/views/hive.ts index 219ce53ac4..1076db6249 100644 --- a/plugins/ruflo-console/hooks/views/hive.ts +++ b/plugins/ruflo-console/hooks/views/hive.ts @@ -80,6 +80,7 @@ function summary(ctx: Ctx, hive: HiveInfo, members: Member[]): RenderElement[] { const required = requiredVotes(strategy ?? 'raft', nodesOf(hive)) const isRaft = strategy === 'raft' const counts = (liveness: Liveness) => members.filter(member => member.liveness === liveness).length + const keys = hive.memoryKeys.filter(key => key !== 'broadcasts').length return [ kv( @@ -92,7 +93,7 @@ function summary(ctx: Ctx, hive: HiveInfo, members: Member[]): RenderElement[] { kv(ctx, 'fault tolerance', tolerance === null ? `n/a — ${workers === 0 ? 'no workers' : `no bound stated for ${hive.strategy ?? 'this strategy'}`}` : `tolerates ${tolerance.faulty} faulty of ${tolerance.of} (${tolerance.rule})`), kv(ctx, 'quorum', `${required} of ${nodesOf(hive)} votes to pass (${ruleOf(strategy ?? 'raft')})${workers === 0 ? ' · the CLI counts an empty hive as one node' : ''}`), kv(ctx, 'workers', workers === 0 ? 'none yet — spawn one below' : `${workers} · ${counts('busy')} busy · ${counts('idle')} idle · ${counts('down') + counts('error')} down · ${members.filter(member => !member.isKnown).length} in no agent store`), - kv(ctx, 'shared memory', `${hive.memoryKeys.length} key${hive.memoryKeys.length === 1 ? '' : 's'} · ${hive.broadcasts.length} broadcast${hive.broadcasts.length === 1 ? '' : 's'} · updated ${ago(hive.updatedAtMs, ctx.nowMs)}`), + kv(ctx, 'shared memory', `${keys} key${keys === 1 ? '' : 's'} · ${hive.broadcasts.length} broadcast${hive.broadcasts.length === 1 ? '' : 's'} · updated ${ago(hive.updatedAtMs, ctx.nowMs)}`), ] } diff --git a/plugins/ruflo-console/tests/hive.spec.ts b/plugins/ruflo-console/tests/hive.spec.ts index ad048b84b7..1103a4c213 100644 --- a/plugins/ruflo-console/tests/hive.spec.ts +++ b/plugins/ruflo-console/tests/hive.spec.ts @@ -76,7 +76,7 @@ describe('hive actions', () => { const proposal = hive.pending[0] as HiveInfo['pending'][number] expect(nextVoter(hive, proposal)).toBe(WORKERS[1]) - expect(hiveVote(hive, proposal, false)?.args).toEqual(['hive-mind', 'consensus', '--action', 'vote', '--proposal-id', RAFT_ID, '--vote', 'no', '--voter-id', WORKERS[1]]) + expect(hiveVote(hive, proposal, false)?.args).toEqual(['hive-mind', 'consensus', '--action', 'vote', '--proposal-id', RAFT_ID, '--vote', 'no', '--voter-id', WORKERS[1], '--format', 'json']) expect(hiveVote({ ...hive, workers: [] }, proposal, true)).toBeNull() }) diff --git a/plugins/ruflo-console/tests/views.test.ts b/plugins/ruflo-console/tests/views.test.ts index 7016ef6a10..07e36af81f 100644 --- a/plugins/ruflo-console/tests/views.test.ts +++ b/plugins/ruflo-console/tests/views.test.ts @@ -115,7 +115,7 @@ describe('views', () => { await pane.press({ key: 'confirm' }) expect(votes()).toHaveLength(1) - expect(votes()[0]?.slice(4)).toEqual(['hive-mind', 'consensus', '--action', 'vote', '--proposal-id', RAFT_ID, '--vote', 'yes', '--voter-id', WORKERS[1]]) + expect(votes()[0]?.slice(4)).toEqual(['hive-mind', 'consensus', '--action', 'vote', '--proposal-id', RAFT_ID, '--vote', 'yes', '--voter-id', WORKERS[1], '--format', 'json']) await pane.unmount() })