AGENT SKILL

raft-manager

Use when an org role acts as Raft manager and must keep one replicated log consistent via leader election and majority-committed replication. Covers randomized election timeouts, persisting term and vote, idempotent ops, split-brain tests and snapshotting; crash faults only, not Byzantine.

License 许可
Apache-2.0
所属仓库
monoes/monomind
最近更新
2026-11-14
Stars
★ 23
Forks
2

01 前言 Front Matter

name
raft-manager
tags
[ "operations", "coordination", "reliability", "architecture" ]
tools
[]
source
https://github.com/monoes/monomind
license
Apache-2.0
description
Use when an org role acts as Raft manager and must keep one replicated log consistent via leader election and majority-committed replication. Covers randomized election timeouts, persisting term and vote, idempotent ops, split-brain tests and snapshotting; crash faults only, not Byzantine.

03 SKILL.md 正文

Raft Manager — Best Practices

Focus

Maintains a single authoritative, replicated log across participants via leader election and log replication — consensus under crash/omission faults, not malicious ones.

Best practices

  • Keep the three subproblems separate in reasoning and implementation: leader election, log replication, and safety. Raft's whole value is that each is tractable in isolation — don't blur them together.
  • Use randomized election timeouts so followers don't all become candidates simultaneously; without randomization, split votes recur and elections stall.
  • Only mark a log entry committed once it's replicated to a majority of servers — never apply an entry to the state machine before that majority is confirmed.
  • Give every client operation an idempotency key (e.g. a sequence number) so re-execution from the log after a leader change or retry can't double-apply it.
  • Persist term number and vote state to stable storage before responding to any RPC — a node that forgets its term or vote across a restart can violate safety.
  • Never let a leader with a stale term keep acting as leader; step down immediately on discovering a higher term from any peer.

Common pitfalls

  • Conflating consensus, coordination, and replication — consensus is agreeing on a single ordered log; coordination (e.g. distributed locks) is a use case built on top of it; replication just copies data without ordering guarantees on its own. Building one where the problem actually needs another is a common design error.
  • Relying on wall-clock time without accounting for clock issues — NTP slews or a backward time jump can break election-timeout assumptions and cause spurious elections or missed heartbeats.
  • Treating "leader elected" as "state agreed" — a new leader must still catch followers up to the latest committed entry before the cluster is actually consistent.
  • Skipping snapshotting/log compaction on long-running clusters, letting the replicated log grow unbounded and making new-node catch-up impractically slow.
  • Applying an Raft-replicated decision as though it also tolerates malicious participants — Raft assumes honest-but-possibly-crashed nodes; it gives no protection against a node that lies.

Tools & techniques

  • Verify committed status by checking replication count against cluster majority explicitly, not by trusting the leader's local view alone.
  • Attach a monotonic operation id to every client request so re-application from the log is detectable and skippable.
  • Test explicitly for split-brain scenarios (partitioned leader still receiving client writes) — the term/quorum mechanism should make the partitioned leader's writes unable to commit, verify that it actually does.
  • Log every term change and leader transition; when debugging a consistency issue, the term/log-index history is almost always where the answer is.

04 同仓库更多 Skills

monoes
monoes/monomind

zk-steward

Org role guidance for a ZK steward: engineer zero-knowledge proof systems with circuit design, SNARK vs STARK choice and security review. This is zero-knowledge cryptography, not Zettelkasten note-taking.

★ 23
monoes
monoes/monomind

writing-plans

Use when you have a spec or requirements for a multi-step coding task and must write an implementation plan before touching code. Produces bite-sized TDD tasks with exact file paths, code and commands for an engineer with zero context.

内容创作者写作与文案
★ 23
monoes
monoes/monomind

write-spec

Write a feature spec or PRD from a problem statement or feature idea. Use when turning a vague idea or user request into a structured document, scoping a feature with goals and non-goals, defining success metrics and acceptance criteria, or breaking a big ask into a phased spec.

产品经理
★ 23
monoes
monoes/monomind

write-query

Write optimized SQL for your dialect with best practices. Use when translating a natural-language data need into SQL, building a multi-CTE query with joins and aggregations, optimizing a query against a large partitioned table, or getting dialect-specific syntax for Snowflake, BigQuery, Postgres, etc.

数据分析师
★ 23
monoes
monoes/monomind

workflow-automation

Org role guidance for workflow automation: build and maintain CI/CD definitions in GitHub Actions or equivalent: triggers, jobs, matrices, caching. Covers path filters, dependency caching, parallel jobs, timeouts and fail-fast ordering.

运维与部署Skill与智能体开发
★ 23
monoes
monoes/monomind

workflow-architect

Org role guidance for a workflow architect: map full workflow trees for systems, user journeys and agents, covering every branch and failure. Covers discovering workflows from code, handoff contracts, timeouts, recovery paths and observable state.

Skill与智能体开发
★ 23