mirror of
https://github.com/ruvnet/ruflo.git
synced 2026-11-23 21:59:14 +09:00
fix(ruflo-console): hive vote asks for JSON so a refused vote reads as refused
`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 <ruv@ruv.net>
This commit is contained in:
1 parent
aef399f623
commit
9a26876efc
4 files changed
+6
-4
No files matched your search
@@ -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,
|
||||
}
|
||||
|
||||
@@ -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)}`),
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@@ -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()
|
||||
})
|
||||
|
||||
|
||||
@@ -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()
|
||||
})
|
||||
|
||||
|
||||
Reference in new issue
Block a user