Instructions for AI coding agents (OpenAI Codex and other AGENTS.md-aware tools)
working in this repository. Claude Code / Claude Agent SDK: see
CLAUDE.md — it is the twin of this file. Keep the two in sync
when you change one.
Read this before you write code. The deeper reference docs are in docs/
(linked throughout).
Garlemald Server is a Rust port of a FINAL FANTASY XIV v1.23b server emulator (the original 2010 1.0 release, not A Realm Reborn) — a from-scratch port of the C# Project Meteor Server. It is a single Cargo workspace (edition 2024, Rust 1.95) of four service binaries plus a shared library, backed by SQLite, hosting ~1,142 Lua content scripts.
# Build everything
cargo build --workspace
# Run the full stack (build + launch all four binaries; logs in ./logs/)
./scripts/run-all.sh # PROFILE=debug for a debug build
# Run one service
./scripts/run-{web,lobby,world,map}.sh
# Tests
cargo test --workspaceEach binary also runs standalone: ./target/release/<name> --config configs/<name>.toml.
Ports (localhost defaults): web 54993, lobby 54994, world 54992, map
1989. Full detail: docs/dev-environment.md.
First boot creates ./data/garlemald.db from the bundled schema; no external DB
or web server is needed (SQLite is bundled, Lua 5.4 is vendored — a C toolchain
is required to compile them).
RUST_LOG=map_server=debug(ortrace, or per-crate filters) —tracingviaEnvFilter(common/src/logging.rs). Default: our crates atdebug, dependencies atinfo.GARLEMALD_PACKET_LOG_DIR=<dir>— hex-dump every packet to<tag>-packets.log; addGARLEMALD_PACKET_LOG_PLAINTEXT=1for pre-encryption bytes (common/src/packet_log.rs).
| Crate | Owns |
|---|---|
common |
Wire primitives (packet.rs, subpacket.rs), blowfish.rs, bitstream.rs, packet_log.rs, logging.rs, db.rs |
web-server |
axum HTTP signup/login; session tokens (server.rs, handlers.rs, session.rs) |
lobby-server |
Character list/creation, world handoff (processor.rs, database.rs, character_creator.rs, hardcoded.rs) |
world-server |
Session ownership, party/group hierarchy, zone routing (server.rs, world_master.rs, group.rs, database.rs) |
map-server |
Zone sim: actor/, battle/, processor.rs, command_processor.rs, world_manager.rs, and the Lua runtime in lua/ + runtime/ |
Architecture and the wire protocol: docs/architecture.md.
The Lua content system (engine, scheduler, hooks, the LuaCommand →
packet pipeline): docs/lua-runtime.md.
Lua bindings: before relying on a Lua engine binding, confirm it actually exists in
map-server/src/lua/. The upstream C# server has server-side conveniences that are not real 1.x engine bindings — don't assume parity.
Every .rs file (including build.rs, examples, and tests) must open with the
AGPL header below, verbatim. Copy it from a sibling file rather than retyping it.
Markdown / TOML / SQL files do not carry it.
// garlemald-server — Rust port of a FINAL FANTASY XIV v1.23b server emulator (lobby/world/map)
// Copyright (C) 2026 Samuel Stegall
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//
// SPDX-License-Identifier: AGPL-3.0-or-laterIf you port code from a new upstream, also credit it in NOTICE.md.
Verbatim translations from the GPL-3.0 LandSandBoat reference trigger the
combined-work rule — read NOTICE.md and prefer "read, re-derive, cite".
- Branch off
develop(the default/integration branch); never commit todevelopormaindirectly. PR intodevelop. develop→mainis the release path; releases are tag-driven (seedocs/RELEASING.md). Don't bump versions by hand — the release workflow ownsCargo.toml's version.- Link the issue you're working from in the PR.
cargo fmt --all --check
cargo clippy --workspace --all-targets -- -D warnings
cargo build --workspace --all-targets --locked
cargo test --workspace --locked--locked means: if you change dependencies, commit the updated Cargo.lock.
Do not open a PR until all four are green.
- AGPL header on every new
.rsfile (above). - Never cross-commit between repos. This repo is one of several independent
git repositories in a shared workspace (e.g.
Garlemald-Client). Only ever commit here. - Keep CI green before raising a PR.
- Branch off
develop, PR intodevelop. - Don't invent Lua engine bindings — verify against
map-server/src/lua/. - Keep this file and
CLAUDE.mdin sync.
docs/architecture.md— topology, per-binary roles, wire protocol.docs/lua-runtime.md— Lua engine, scheduler, hooks, command pipeline.docs/dev-environment.md— build/run, logging, packet capture, save state.docs/agents.md— running an agent on an issue (human-facing).CONTRIBUTING.md— the contribution workflow.docs/RELEASING.md— branching & release automation.NOTICE.md— upstream attribution & licensing rules.