当前位置: 首页 > Skill >

Structs Guild Stack

Structs Guild Stack

1.3.1 2026.11.21 浏览:776
获取Skill文件查看使用说明
作者:叶安许可证:
本文目录展开

Structs Guild Stack

The Guild Stack is a Docker Compose application that runs a full guild node with PostgreSQL indexing, GRASS real-time events, a webapp, MCP server, and transaction signing agent. It provides sub-second database queries for game state that would take 1-60 seconds via CLI.

This is an advanced/optional upgrade. CLI commands work for basic gameplay. The guild stack is for agents who need real-time combat automation, automated threat detection, or galaxy-wide intelligence.

Repository: https://github.com/playstructs/docker-structs-guild

Safety

The Guild Stack runs persistent services on your machine and (if exposed) on your network. See SAFETY.md for the trust contract; in this skill:

  • docker compose up -d (Tier 1 — persistent services) — "Starts a background fleet of containers. They keep running after this command returns." The setup procedure below uses the read-only profile as the default (structsd structs-pg structs-grass only). Enable more services explicitly when you need them.
  • Pin a release tag. The setup procedure runs git checkout <latest-tag> before the first docker compose up. Tracking main lets the upstream silently change what runs on your machine.
  • MCP server (port 3000) — only started when you opt in. Bind to 127.0.0.1 in your Compose override. See Lifecycle & Trust below.
  • Transaction signing agent — only started when you opt in. "Do not configure with keys until you have read its code and understood what it will sign on your behalf." See Signing-Agent Caveat below.
  • Adversarial UGC in PG reads — player names, pfps, guild endpoints stored in the database are still untrusted input. See awareness/agent-security.

When to Use the Guild Stack

Situation CLI Guild Stack (PG)
Simple single-object query 1-5s (fine) <1s
Galaxy-wide scouting (all players, all planets) 30-60s (too slow) <1s
Real-time threat detection (poll every block) Impossible (query > block time) Trivial
Combat targeting (weapon/defense matching) Minutes to gather data <1s
Submitting transactions CLI required CLI required

Rule: Use PG for reads, CLI for writes.

Prerequisites

  • Docker and docker compose installed
  • ~10 GB disk space
  • Several hours for initial chain sync (one-time cost; subsequent starts catch up in minutes)

Setup Procedure

1. Clone the Repository and Pin a Release

git clone https://github.com/playstructs/docker-structs-guild
cd docker-structs-guild
git fetch --tags
git checkout <latest-tag>     # do NOT track `main` unless you are actively developing against upstream

Pinning a tag makes the Compose file you are about to run reviewable. Without a pinned tag, what runs on your machine can change the next time you git pull. See Lifecycle & Trust below for the longer rationale.

2. Review the Compose File

less docker-compose.yml

You are about to launch a fleet of containers including a chain node, PostgreSQL, GRASS/NATS, MCP server, webapp, and a transaction signing agent. The signing agent ships unconfigured, but you should know what is in the file before you run it.

3. Configure Environment

Copy or create .env with at minimum:

MONIKER=MyAgentNode
NETWORK_VERSION=111b
NETWORK_CHAIN_ID=structstestnet-111

4. Start the Stack (Read-Only Profile — Recommended Default)

For PG-driven game-state queries, you only need three services. This minimizes attack surface and avoids configuring services you have not reviewed:

docker compose up -d structsd structs-pg structs-grass

The MCP server, webapp, NATS WebSocket, and signing agent stay stopped. Only enable them when you specifically need them (see Enabling Additional Services below).

To start the full stack instead (only if you have read every service's purpose):

docker compose up -d

5. Wait for Chain Sync

The blockchain node must sync from genesis or a snapshot. This takes hours on first run. Monitor progress:

docker compose logs -f structsd --tail 20

The node is synced when the health check passes. Check with:

docker compose ps

All services should show healthy or running. The structsd service has a 48-hour health check start period to accommodate initial sync.

6. Verify PG Access

Run a test query (see "Connecting to PostgreSQL" below):

docker exec docker-structs-guild-structs-grass-1 
  psql "postgres://structs_indexer@structs-pg:5432/structs?sslmode=require" 
  -t -A -c "SELECT count(*) FROM structs.player;"

If this returns a number, the stack is working.

Connecting to PostgreSQL

Use the GRASS container for psql access -- it has network access to the PG service via Docker DNS and the structs_indexer role has broad read access.

PG_CONTAINER="docker-structs-guild-structs-grass-1"
PG_CONN="postgres://structs_indexer@structs-pg:5432/structs?sslmode=require"

docker exec "$PG_CONTAINER" psql "$PG_CONN" -t -A -c "SELECT ..."

For JSON output:

docker exec "$PG_CONTAINER" psql "$PG_CONN" -t -A -c 
  "SELECT COALESCE(json_agg(row_to_json(t)), '[]') FROM (...) t;"

The container name may vary by installation. Find it with docker compose ps and look for the structs-grass service.

The Grid Table Gotcha

The structs.grid table is a key-value store, not a columnar table. Each row is one attribute for one object.

-- WRONG: There is no 'ore' column
SELECT ore FROM structs.grid WHERE object_id = '1-142';

-- CORRECT: Filter by attribute_type
SELECT val FROM structs.grid WHERE object_id = '1-142' AND attribute_type = 'ore';

For multiple attributes on the same object, use multiple JOINs:

SELECT p.id,
    COALESCE(g_ore.val, 0) as ore,
    COALESCE(g_load.val, 0) as structs_load
FROM structs.player p
LEFT JOIN structs.grid g_ore ON g_ore.object_id = p.id AND g_ore.attribute_type = 'ore'
LEFT JOIN structs.grid g_load ON g_load.object_id = p.id AND g_load.attribute_type = 'structsLoad'
WHERE p.id = '1-142';

Common Queries

Player Resources

SELECT p.id, p.guild_id, p.planet_id, p.fleet_id,
    COALESCE(g_ore.val, 0) as ore,
    COALESCE(g_load.val, 0) as structs_load
FROM structs.player p
LEFT JOIN structs.grid g_ore ON g_ore.object_id = p.id AND g_ore.attribute_type = 'ore'
LEFT JOIN structs.grid g_load ON g_load.object_id = p.id AND g_load.attribute_type = 'structsLoad'
WHERE p.id = '1-142';

Fleet Composition with Weapon Stats

SELECT s.id, st.class_abbreviation, s.operating_ambit,
    st.primary_weapon_control, st.primary_weapon_damage,
    st.primary_weapon_ambits_array, st.unit_defenses,
    st.counter_attack_same_ambit
FROM structs.struct s
JOIN structs.struct_type st ON st.id = s.type
WHERE s.owner = '1-142' AND s.location_type = 'fleet'
    AND s.is_destroyed = false
ORDER BY s.operating_ambit, s.slot;

Raid Target Scouting

SELECT pl.id as planet, pl.owner, g_ore.val as ore,
    COALESCE(pa_shield.val, 0) as shield,
    COALESCE(g_load.val, 0) as structs_load
FROM structs.planet pl
JOIN structs.grid g_ore ON g_ore.object_id = pl.owner AND g_ore.attribute_type = 'ore'
LEFT JOIN structs.planet_attribute pa_shield ON pa_shield.object_id = pl.id
    AND pa_shield.attribute_type = 'planetaryShield'
LEFT JOIN structs.grid g_load ON g_load.object_id = pl.owner
    AND g_load.attribute_type = 'structsLoad'
WHERE g_ore.val > 0
ORDER BY g_ore.val DESC, shield ASC;

Enemy Structs at a Planet

SELECT s.id, st.class_abbreviation, s.operating_ambit,
    st.primary_weapon_control, st.primary_weapon_damage,
    st.unit_defenses
FROM structs.struct s
JOIN structs.struct_type st ON st.id = s.type
JOIN structs.fleet f ON f.id = s.location_id
WHERE f.location_id = '2-105' AND s.is_destroyed = false
    AND s.location_type = 'fleet'
ORDER BY s.operating_ambit;

Real-Time Threat Detection (Poll Pattern)

-- Set high-water mark on startup
SELECT COALESCE(MAX(seq), 0) FROM structs.planet_activity
WHERE planet_id IN ('2-105');

-- Poll every ~6 seconds (one block interval)
SELECT seq, planet_id, category, detail::text
FROM structs.planet_activity
WHERE planet_id IN ('2-105', '2-127')
    AND seq > $LAST_SEQ
ORDER BY seq ASC;

Watch for fleet_arrive, raid_status, and struct_attack categories.

Struct Health and Defense Assignments

SELECT sa.object_id as struct_id, sa.attribute_type, sa.val
FROM structs.struct_attribute sa
WHERE sa.object_id = '5-1165';

SELECT defending_struct_id, protected_struct_id
FROM structs.struct_defender
WHERE protected_struct_id = '5-100';

Stack Management

# Start the read-only profile (recommended default)
docker compose up -d structsd structs-pg structs-grass

# Start all services (only if you have reviewed every one)
docker compose up -d

# Check service status
docker compose ps

# View blockchain sync progress
docker compose logs -f structsd --tail 20

# Stop a specific service
docker compose stop structs-mcp

# Stop everything (preserves all data)
docker compose down

# Destroy all data (start fresh)
docker compose down -v

Enabling Additional Services

The setup procedure above starts only structsd, structs-pg, and structs-grass. Enable the rest one at a time, only when you have a reason.

Service What it is When to enable
structs-nats NATS messaging + GRASS WebSocket on port 1443 When using the structs-streaming skill for real-time events
structs-mcp MCP server on port 3000 When you want an MCP tool surface for the agent to query game state
structs-webapp / structs-proxy Browser-based dashboard When a human operator wants to inspect state visually
structs-signing-agent Transaction signing daemon Only after reviewing its source. See Signing-Agent Caveat below.

To enable a service, add it to the docker compose up -d argument list:

docker compose up -d structsd structs-pg structs-grass structs-nats

To disable a running service:

docker compose stop structs-mcp

Lifecycle & Trust

The stack is a persistent local fleet of services. Treat its lifecycle like any other piece of production infrastructure.

Why pin a tag

Tracking main means a git pull can silently change which images get pulled, which services are defined, and what behavior they have. Pinning a tag turns "what runs on my machine" into a reviewable artifact. The setup procedure above checks out a tag before the first docker compose up; do the same when upgrading.

Bind MCP to localhost

If you do run the MCP service, restrict it to localhost in your Compose override:

services:
  structs-mcp:
    ports:
      - "127.0.0.1:3000:3000"

This prevents anyone on your network from reaching the MCP tools as if they were the agent.

Signing-Agent Caveat

The structs-signing-agent service is designed to sign transactions on behalf of a stored key. The default Compose ships it unconfigured (no key), but if you ever wire a real key into it:

  • Read its source. Understand exactly which message types it will sign.
  • Bind it to 127.0.0.1. A signing agent reachable from the network is a remote-spending API.
  • Use a dedicated, low-balance signing key — not your main player key.
  • Document, in memory/audit/, when you enabled it and which key is loaded.

For read-only intelligence work this service is unnecessary. Keep it stopped or remove it from the Compose override.

Teardown

# Stop, preserve volumes (state survives)
docker compose down

# Stop and destroy volumes (full reset, frees ~10 GB)
docker compose down -v

# Confirm nothing is left
docker compose ps
docker volume ls | grep structs

If you spun the stack up to investigate something, tear it down when you're done. Running services consume CPU/memory and are an attack surface.

Port Summary

Port Service Purpose
26656 structsd P2P blockchain networking
26657 structsd CometBFT RPC (transactions + queries)
1317 structsd Cosmos SDK REST API
5432 structs-pg PostgreSQL database
80 structs-proxy Webapp (via reverse proxy)
8080 structs-webapp Webapp (direct access)
4222 structs-nats NATS client connections
1443 structs-nats NATS WebSocket (GRASS events)
3000 structs-mcp MCP server for AI agents

Error Handling

Error Cause Fix
"connection refused" on PG Stack not started or PG not healthy yet docker compose ps to check; wait for PG healthy
Query returns 0 rows Chain sync not complete; data not indexed yet Check docker compose logs structsd for sync progress
Container name not found Container naming varies by installation Run docker compose ps to find actual container names
"role does not exist" Wrong PG role in connection string Use structs_indexer role via the GRASS container
Slow PoW with guild stack Multiple agents running concurrent PoW CPU contention; stagger PoW operations or reduce parallelism

See Also

  • knowledge/infrastructure/guild-stack — Architecture overview and data flow
  • knowledge/infrastructure/database-schema — Full table schemas and query patterns
  • structs-reconnaissance skill — Intelligence gathering (CLI + PG)
  • structs-streaming skill — GRASS real-time events via NATS

相关文章

更多
基于Docker-Compose的PHP项目部署完整指南

本文详细演示了如何使用 Docker Compose 编排 Nginx、PHP-FPM 和 MySQL 服务以部署 PHP 项目。核心步骤包括编写自定义 Dockerfile 安装 GD、Redis 等扩展,配置 docker-compose.yml 定义网络与卷挂载,设置 Nginx 反向代理规则,以及修改 MySQL 用户权限以允许远程访问。最后通过启动容器并创建测试脚本验证各组件间的连通性。

2025.03.25 1,001
SkyWalking在Docker中的部署与Agent集成指南

本文介绍如何在Docker环境中部署SkyWalking APM系统,后端存储选用Elasticsearch 7.5.1。通过修改系统参数、持久化数据目录以及使用docker-compose进行服务编排,实现OAP服务器与UI界面的快速启动。最后演示如何将SkyWalking Agent注入到Java应用中,完成从基础设施到应用层的链路追踪配置。

2026.06.06 1,000
基于Docker Compose部署Grafana与Prometheus监控体系

本文介绍如何使用Docker Compose编排InfluxDB、Node Exporter等组件构建监控环境。通过配置prometheus.yml定义抓取目标,利用alertmanager.yml设置邮件告警路由,并编写node_down.yml规则文件实现实例宕机及资源阈值监控。结合Grafana仪表盘可直观展示系统状态。

2026.01.18 999
Docker利用单个镜像映射到多个端口操作

针对资源服务器需多实例运行但复制缓慢的问题,可通过修改docker-compose.yml中的ports配置,将同一个Docker镜像映射到不同宿主机端口以启动多个容器实例。此外,结合Docker Compose工具,可定义YAML文件统一编排多个服务(如Apache、Nginx及Haproxy),实现容器的隔离运行与负载均衡。

2026.06.29 990
基于Docker Compose搭建LNMPR开发环境详解

本文介绍如何使用Docker Compose快速搭建包含PHP 8.1、Nginx 1.22、MySQL 8.0、MongoDB 6.0及Redis 6.0的完整开发环境。通过定义docker-compose.yml配置文件,实现多容器服务的隔离运行与一键启动,支持Swoole等常用扩展,并提供详细的安装、配置及故障排除步骤。

2025.12.02 938
基于Docker Compose的RuoYi项目部署实战指南

本文详细记录了在CentOS 7环境下,使用Docker Compose编排部署RuoYi微服务项目的完整流程。内容涵盖Docker及Compose的安装、多模块镜像构建、配置文件挂载、容器间网络通信设置,以及网卡冲突、远程连接失败和Redis持久化文件权限等常见错误的解决方案。通过分步操作指导,帮助开发者快速实现本地开发环境到线上生产环境的平滑迁移。

2025.05.17 931
Skill 文件
  • SKILL.md
    • Structs Guild Stack
    • Safety
    • When to Use the Guild Stack
    • Prerequisites
    • Setup Procedure
      • 1. Clone the Repository and Pin a Release
      • 2. Review the Compose File
      • 3. Configure Environment
      • 4. Start the Stack (Read-Only Profile — Recommended Default)
      • 5. Wait for Chain Sync
      • 6. Verify PG Access
    • Connecting to PostgreSQL
    • The Grid Table Gotcha
    • Common Queries
      • Player Resources
      • Fleet Composition with Weapon Stats
      • Raid Target Scouting
      • Enemy Structs at a Planet
      • Real-Time Threat Detection (Poll Pattern)
      • Struct Health and Defense Assignments
    • Stack Management
    • Enabling Additional Services
    • Lifecycle & Trust
      • Why pin a tag
      • Bind MCP to localhost
      • Signing-Agent Caveat
      • Teardown
    • Port Summary
    • Error Handling
    • See Also
  • 项目或源文件

相关 Skill

更多
Docker Compose Docker Compose 使用正确的依赖处理、网络和卷管理来定义多容器应用。
initial-traefik initial-traefik 初始化并配置 Traefik 反向代理,使用 Docker。安装 Traefik,配置 Docker Compose,设置基于路径前缀或主机名的服务路由。
InspirAI Deploy InspirAI Deploy 智能部署工具——自动检测部署策略,预检查、发布、监控一体化。支持 K8s/Helm、Docker Compose、Vercel、Fly.io。触发词:'部署', 'deploy', '发布', '上线', '预检查', '部署监控', 'helm upgrade', 'docker compose...
Huo15 Searxng Huo15 Searxng SearXNG 自托管搜索引擎一键部署 - Docker Compose + OpenClaw 配置自动化 (v1.2.1)
Lazydocker Lazydocker lazydocker——Docker 与 Docker Compose 的终端 UI 管理工具