简介
部署本地PostgreSQL访问游戏状态,实现亚秒级实时情报查询与自动化战斗分析,相比CLI提速60倍以上
原始描述
Deploys the Guild Stack (Docker Compose) for local PostgreSQL access to game state. Use when you need faster queries for combat automation, real-time threat...
通过你的 Agent 添加
点「快速安装」复制一段指令贴给你的 Agent:它会先下载到 /tmp、把文件清单和校验值给你看,你确认之后才解压安装。不会一步装完、也不改系统其它位置。
或者手动安装
包是「根级 SKILL.md + 作者附带的文件」,解压到上面的 <slug>/ 目录即可;
目录名不用换,也不要把包直接解压到 skills 根目录。
技能申请的权限由作者决定:装之前先看清单里有没有脚本、它会读写什么。
中文使用说明 来自收录源
核心用法
Structs Guild Stack 是一个 Docker Compose 本地节点栈,专为高性能游戏数据查询设计。核心工作流分为三步:
-
部署阶段:克隆仓库并锁定版本标签(
git checkout <tag>),启动只读配置(structsd structs-pg structs-sync-state structs-grass),等待链同步完成(数小时首次,后续分钟级) -
查询阶段:通过 GRASS 容器使用
psql连接 PostgreSQL,利用预建的索引表(structs.player、structs.grid、structs.struct等)执行复杂情报分析 -
维护阶段:按需启用附加服务(webapp、TSA 签名代理、MCP 服务器),定期监控同步状态,必要时销毁重建
关键设计原则:PG 用于读,CLI 用于写。签名代理默认禁用,需代码审计后方可启用。
显著优点
- 性能跃迁:星系级侦察(全玩家/全星球)从 30-60 秒降至 <1 秒,实时威胁检测从不可能变为可行
- 查询能力质变:支持复杂 SQL JOIN、窗口函数、聚合分析,实现武器/防御匹配、舰队构成分析、掠夺目标筛选等 CLI 无法完成的计算
- 模块化架构:服务按需启动,默认只读配置最小化攻击面
- 实时事件流:集成 GRASS/NATS,支持区块级轮询的事件驱动架构
潜在局限与风险
- 资源门槛高:~10GB 磁盘、数小时初始同步、持续 CPU/内存占用
- 数据模型特殊:
structs.grid为键值存储而非列式表,查询需多表 JOIN,学习曲线陡峭 - 签名代理高危:TSA 服务若配置私钥即成为自动签名机,需严格代码审计、127.0.0.1 绑定、专用低余额密钥
- UGC 不可信:玩家名、头像、公会端点等数据库内容仍为对抗性输入
- 单点故障:
structs-sync-state仅允许单实例,无法水平扩展
适合人群
- 开发自动化战斗/情报系统的进阶玩家
- 需要实时威胁检测的安全运营型公会
- 运行星系级经济分析或掠夺策略优化的数据驱动型玩家
- 具备 Docker/SQL 基础、能接受基础设施运维成本的技术用户
常规风险
| 风险类型 | 描述 | 缓解措施 |
|---|---|---|
| 供应链攻击 | 跟踪 main 分支导致上游静默更新 |
强制锁定版本标签,升级前 diff 审查 |
| 私钥泄露 | TSA 配置不当成为网络可访问的远程支出 API | 禁用或 127.0.0.1 绑定,专用密钥,审计日志 |
| 数据投毒 | 读取未经验证的玩家生成内容 | 查询结果 sanitization,参见 awareness/agent-security |
| 资源耗尽 | PoW 并发导致 CPU 争用 | 错峰执行,降低并行度 |
| 同步滞后 | 索引器落后链头导致决策基于旧数据 | 监控 sync_state.sync_cursor.lag_blocks |
来源可信度:官方开源仓库
playstructs/docker-structs-guild,具备完整安全文档与版本锁定机制。安全等级:基础设施级持久服务,涉及容器逃逸、网络暴露、密钥管理风险,需严格遵循只读默认配置与标签锁定实践。
技能正文
name: structs-guild-stack description: Deploys the Guild Stack (Docker Compose) for local PostgreSQL access to game state. Use when you need faster queries for combat automation, real-time threat detection, raid target scouting, fleet composition analysis, or galaxy-wide intelligence. Advanced/optional -- CLI works for basic gameplay, but PG access transforms what is possible.
Structs Guild Stack
The Guild Stack is a Docker Compose application that runs a full guild node with sync-state indexing, GRASS real-time events, a webapp, and an optional 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-sync-state structs-grass). Enable more services explicitly when you need them.- Pin a release tag. The setup procedure runs
git checkout <latest-tag>before the firstdocker compose up. Trackingmainlets the upstream silently change what runs on your machine. - MCP server — not part of
compose.yaml. Deploy structs-mcp separately if needed; bind to127.0.0.1only. - 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 Caveatbelow. - 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 composeinstalled - ~10 GB disk space
- Several hours for initial chain sync and sync-state indexing (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 compose.yaml
You are about to launch a fleet of containers including a chain node, sync-state indexer, PostgreSQL, GRASS/NATS, webapp, and an optional 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=113b
NETWORK_CHAIN_ID=structstestnet-111
STRUCTS_PG_BRANCH=main
4. Start the Stack (Read-Only Profile — Recommended Default)
For PG-driven game-state queries, you need four services. structs-sync-state is required — without it, PG has no indexed game state:
docker compose up -d structsd structs-pg structs-sync-state structs-grass
The webapp, TSA, crawler, and NATS (if not needed for GRASS) 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
Check sync-state indexer progress:
docker exec docker-structs-guild-structs-grass-1 \
psql "postgres://structs_indexer@structs-pg:5432/structs?sslmode=require" \
-t -A -c "SELECT chain_id, last_height, status, lag_blocks FROM sync_state.sync_cursor;"
The node is synced when the structsd health check passes. All services should show healthy or running:
docker compose ps
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 (with UGC)
SELECT p.id, p.username, p.pfp, 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.name, 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.
Sync-State Health
SELECT chain_id, last_height, status, lag_blocks, tip_height, updated_at
FROM sync_state.sync_cursor;
SELECT chain_id, height, num_handler_errors, ingested_at
FROM sync_state.block_log
ORDER BY height DESC
LIMIT 5;
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-sync-state 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
# View sync-state indexer progress
docker compose logs -f structs-sync-state --tail 20
# 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, structs-sync-state, 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 | Required for GRASS (included in read-only profile when using structs-grass) |
structs-webapp |
Browser/API dashboard on port 8080 | When you need the HTTP guild API locally |
structs-tsa |
Transaction signing daemon | Only after reviewing its source. See Signing-Agent Caveat below. |
structs-crawler |
Guild metadata crawler | When running a guild node that publishes guild config |
structs-mcp (separate repo) |
MCP server on port 3000 | Deploy from structs-mcp; bind to 127.0.0.1 |
To enable a service, add it to the docker compose up -d argument list:
docker compose up -d structsd structs-pg structs-sync-state structs-grass structs-webapp
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.
Signing-Agent Caveat
The structs-tsa 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 |
| 8080 | structs-webapp | Webapp HTTP API |
| 443 | structs-webapp | Webapp HTTPS |
| 4222 | structs-nats | NATS client connections |
| 1443 | structs-nats | NATS WebSocket (GRASS events) |
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 or sync-state catch-up incomplete | Check sync_state.sync_cursor; wait for status to leave catching_up |
| 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 |
| Second sync-state instance fails | Writer lock — only one indexer allowed | Never scale structs-sync-state |
See Also
- knowledge/infrastructure/guild-stack — Architecture overview and data flow
- knowledge/infrastructure/database-schema — Table schemas and query patterns
- schemas/database-schema — Full structural schema catalog
- structs-reconnaissance skill — Intelligence gathering (CLI + PG)
- structs-streaming skill — GRASS real-time events via NATS
正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。