Skip to content

feat: serve the occupation keys at GET /v1/npc/occupations - #2

Merged
GentBajko merged 4 commits into
mainfrom
feat/occupation-keys
Nov 15, 2026
Merged

GentBajko merged 4 commits into
mainfrom
feat/occupation-keys

Conversation

@GentBajko

Copy link
Copy Markdown
Member

For DiceMaster: POST /v1/npc/generate takes job (96 keys) and office (21 kinds), and until now no route listed them, so DiceMaster would have had to pin a hand copy.

What

  • Route: GET /v1/npc/occupations, stable, family npc_format (unchanged at 1).
  • Schema: OccupationList (/v1/schema/OccupationList.json), with TS bindings OccupationList, Occupation, OccupationKind and OccupationTier.
  • Body: {"occupations": [...]} lists every job, then every office, each in key order. Each entry carries:
    • key;
    • kind, either job or office;
    • label, a job's title, or an office's title without its place;
    • label_female;
    • category, the JobCategory (jobs only);
    • tiers, a list of {tier, rank} (SocialRank), smallest tier first.
  • Jobs: tiers are exactly the tiers generate accepts the job in. A {job, tier, rank} taken from one entry always generates, and no unlisted tier does.
  • Offices: all four tiers, each with the lowest rank a holder has there (a holder ranks at the higher of job and office).
  • Same key in both kinds: seven keys are both a job and an office (elder, harbourmaster, high_priest, lord, reeve, shrine_keeper, steward), so (kind, key) is the unique pair.
  • Where the list comes from: arda_npc::occupations() (crates/arda-npc/src/one/catalog.rs) builds it from the bundled tables and the generator's own tier rule, so it cannot drift from what generate accepts. It is the same on every world.
  • Office labels: offices gain a label in occupations.json (its roles.json title without the place).
  • Contract kit: new case npc-occupations (61 cases over 48 of 49 stable routes). The schema-index golden gained the entry; no other golden changed.

Evidence

  • Catalogue tests: crates/arda-npc/tests/occupation_catalog.rs checks two things:
    • every listed job, tier and rank generates (the generated NPC has that job and rank), and every unlisted tier is refused;
    • every office generates in all four tiers, by a notable at or above the listed rank.
  • Route tests: world_api/occupations.rs (same bytes with and without society/, 96 + 21 entries), plus the mirror round-trip test and the inventory probe.
  • Gates: cargo fmt --check and cargo clippy --workspace --all-targets -D warnings pass. cargo test --workspace --all-features --release passes, including the contract kit and the world_api suites.
  • Not run: the viewer's npm checks (the bindings change is additive).

Docs

API.md, logic/13 §npc-occupations, logic/16, 09-interfaces.md, 02-models.md, 01-architecture.md, versioning.md (56 rows, 49 stable), the contract-kit README, CHANGELOG.md (Unreleased), and the ledger.

Process note

The user was away. The capstone feature chain ran without its approval gates: spec and plan were written from the DiceMaster session's brief and kept locally under docs/capstone/features/. This PR is the approval gate.

This PR, the thicket-obscurement PR and the memory-ceiling PR each add an ## Unreleased section to CHANGELOG.md and an entry at the top of docs/capstone/changelog.md, so whichever merges second will need a trivial conflict resolution.

@GentBajko

Copy link
Copy Markdown
Member Author

Converted to draft: Arda's feature process needs the maintainer's approval of this change's plan before code, and that approval has not been given. The code here was written ahead of it. The maintainer can approve the plan as built (review this PR and mark it ready) or ask for the plan to be redone first.

@GentBajko
GentBajko merged commit c2e59e4 into main Nov 15, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant