Warring Nations

Architecture

Docs / Architecture. Warring Nations 5.0, pre-release.

A gameplay-agnostic framework, gameplay as packages, and seven jars that each carry the same framework.

The framework knows nothing about nations, claims, wars or economies. Those rules live in packages. A build check fails if framework code imports any wn.* package or host class, and packages may only depend on the framework API and the gameplay contracts.

Article 1Layers

Module layers. Arrows point at what a layer depends on.Four stacked layers: hosts above packages above gameplay contracts above the framework.HostsMinecraft (16 loader shells), web, discord, mapsGameplay packageswn.core:nations, territory, war, peace, treasury ...Gameplay contractscontracts-gameplay, map-disclosureFrameworkapi (pure types), runtime (packages, actions, state)
Module layers. Arrows point at what a layer depends on.
ModuleRole
framework/apiPure types: manifests, action requests and plans, state mutations, events, permissions, capability ids, language catalog, TOML config, and the economy and claims provider interfaces.
framework/contracts-gameplayDomain capability interfaces: organization directory and relations, war rules and status, treasury and territory settlement, approval queue, block journal, presence, progression awards.
framework/runtimePackage manager, authorized action service, file state store, durable event dispatcher, persistent jobs, permission policy.
hosts/minecraft/commonOne source tree shared by 16 loader shells (Fabric and NeoForge, 8 Minecraft versions).
packages/*The gameplay packages, each with a wn-package.json manifest.

Article 2Packages and manifests

2.1A manifest declares dependencies, the capabilities a package provides and consumes, state schemas with indexes and migrations, actions, events, subscriptions, commands, permissions and a configuration schema. Install validates the manifest and the signature (Ed25519, .wnpkg archives). Activation is staged and rolls back on failure. Upgrades migrate state and configuration. A package an operator disables is never re-enabled by the host.

Package graph, a sample of capability links. An arrow points from a consumer to its provider.War consumes nations, territory and war-rules. Peace negotiation consumes war, territory and treasury. Claims protection consumes territory. The treasury bridge consumes the ledger and treasury.nationsdirectoryterritoryclaims.lookupclaims-protectionwn_conformwar-rulesrulesetswarthe enginepeace-negotiationoffers, mediationeconomy ledgerwn.economy.ledgertreasury bridgewallet to treasurytreasurytreasury.settlement
Package graph, a sample of capability links. An arrow points from a consumer to its provider.

2.2Optional consumers stay dormant when their provider is absent, so a package list that leaves things out still starts.

Article 3The action pipeline

The action pipeline. Every state change takes this path.Six steps from host adapter to event dispatch, in two rows.Host adaptercommand, web, DiscordAuthorizeread lease until commitIdempotencysame key replaysEvaluatehandler returns a planCommitstate, events, receiptDispatchdurable, at least once
The action pipeline. Every state change takes this path.
  • Idempotency keys are 1 to 200 characters. Replaying the same key and payload returns the stored receipt. The same key with a different payload raises a conflict.
  • Handlers read an immutable state snapshot and return a plan. A single commit is capped at 16 MiB.
  • Commit is atomic and optimistic: if state moved under a read, the action retries.
  • Actions are marked HOST_THREAD (touch game APIs, hop onto the server thread with a 10 second timeout) or OFF_HOST_THREAD.

Article 4State

4.1The only shipped store is a file store: one checksummed snapshot (format 8) replaced atomically, plus an append-only framed journal. A torn tail is truncated, because no receipt was issued for it. Corruption in the middle of history stops startup instead of guessing. Limits: 4,000,000 records, 1 GiB image, property indexes fail closed above 2,500,000 records. Retention keeps 10,000 events and expires receipts after 30 days.

Article 5Events and jobs

5.1Events enter a durable outbox inside the action commit and are delivered at least once, with one checkpoint per subscriber. Consumers dedupe by event id. A subscriber that keeps failing is parked so it cannot block retention. Persistent jobs allow 64 pending per package and 4,096 total, back off up to 1 minute and give up after 20 attempts.

Article 6Permissions

6.1Each permission has a privilege: PLAYER, STAFF, OPERATOR or INTERNAL. Undeclared permissions resolve to operator. Policy combines explicit and timed grants, host permission mappings (for example LuckPerms) and host level grants. See Permissions.

Article 7The seven jars

JarMod idHolds
warring-nationswarring_nationsThe wn.core:* gameplay packages
wn-claimswn_claimsOpen Parties and Claims and FTB Chunks providers (reflection only, no compile dependency)
wn-conformwn_conformClaims protection; Create, Mekanism and AE2 adapters (NeoForge 1.21.1)
wn-economywn_economyLedger and treasury bridge
wn-webwn_webWeb host and Cloudflare front
wn-discordwn_discordDiscord host (SnakeYAML relocated inside it)
wn-mapswn_mapsClient map sync and the map-layers package

7.1All seven nest the same framework jar. The loader keeps the highest version it is offered. A build check requires the seven copies to be byte-identical and that no class or resource repeats across any subset of the jars. The base mod reaches the optional web, discord and maps jars by probing for a sentinel class, not by linking against them.

Article 8Failure model

8.1State and trust fail closed. Configuration never does: an unusable config file is replaced by safe defaults and logged. Providers answer UNSUPPORTED or UNAVAILABLE rather than guess. Failed activations roll back, and poison subscribers are parked.

Article 9War lifecycle

  1. Declare: the declaration gate collects facts for the ruleset (claim counts, approval, government vote, price) and may require confirmation. Phase is preparing.
  2. Start: the war clock moves it to active on a tick. War rollback begins journaling block changes.
  3. Score: host reports (kills, deaths) and presence samples update the ledger.
  4. End: by rule (time, score), surrender, ceasefire, nation disband or treaty.
  5. Peace and spoils: peace negotiation moves money and land through treasury and territory settlement. Spoils react to the end. Rollback restores blocks.

Article 10Known gaps (from the repository docs)

  • Nothing has run on a live server in the recorded evidence. CI runs no server smoke test.
  • Treasury records keyed by nation name can leak a reserve to a new nation that reuses the name.
  • A peace reparation queued before a war ends can still move money afterwards.
  • Remote commands have no idempotency key, so a retry can run twice.
  • Presence AFK state resets on reconnect.
  • Language files are missing for diplomacy, territory, war, government, treasury, peace and approvals, so those results are in English in every language.
  • Trusted compiled packages are not sandboxed, and revoking a signer does not stop an installed package by itself.

Type at least two letters. Esc closes.