Skip to content

refactor: rewrite bootstrap server in Go for zero-dependency single-binary deployment #36

@Jing-yilin

Description

@Jing-yilin

Background

The bootstrap nodes (bootstrap/server.mjs) are standalone EC2 processes — not OpenClaw plugins, so there is no constraint to remain in Node.js.

Current stack: Node.js 22 + Fastify + tweetnacl + node_modules/ (~60 MB RAM per node, requires npm install on deploy).

Motivation

Rewriting in Go would give:

  • Single binary deployment — SSM deploy becomes copy one file + systemctl restart, no npm install step
  • Lower memory footprint — ~10 MB vs ~60 MB per node (meaningful at 5-node fleet scale)
  • Faster cold start — no Node.js runtime init, relevant after AMI replacement or spot interruption
  • No runtime dependency — eliminates the node_modules/ directory on EC2, simplifying Dockerfile and user-data scripts

Scope

Replace bootstrap/server.mjs with a Go binary that implements the same HTTP API:

  • GET /peer/ping — {ok:true, ts}
  • POST /peer/announce — verify Ed25519 sig, exchange peer tables, run Kimi welcome bot
  • GET /peer/peers — return known peer list
  • POST /peer/message — trust pipeline + Kimi bot reply

Crypto: golang.org/x/crypto/ed25519 (stdlib-adjacent, no heavy deps).
HTTP: net/http standard library — no framework needed at this scale.

Non-goals

  • Do NOT change src/ (TypeScript plugin) — it must remain Node.js
  • Do NOT change the HTTP API contract — clients are existing DeClaw plugin instances
  • Performance is not the primary goal; deployment simplicity is

Acceptance Criteria

  • bootstrap/server.go implements all existing endpoints with identical request/response shapes
  • bootstrap/Dockerfile updated to multi-stage Go build with distroless/scratch final image
  • SSM deploy snippet in AGENTS.md updated (no npm install step)
  • bootstrap-health.yml CI passes against new binary
  • bootstrap/server.mjs and bootstrap/package.json removed or archived

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requeststaleInactive issue/PR — will be closed soon

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions