class_id is the rulebook's word; the world has callings — that was the whole §17
reconcile. The contract the Narrator reads should say what the world says. There
are no saves (M9) and no deployed clients, so this is as cheap as it will ever be
and strictly more expensive every milestone after.
race_id reaches the log because the AI must be able to describe the player:
api/app/prompts.py rendered 'a sellsword' and now renders 'a beastfolk cutpurse'.
It humanizes the id (the model must never read 'hedge_mage') and picks the right
article ('an elf', not 'a elf').
LogPlayer's hardcoded CLASSES const is deleted — the roster is Callings.IDS. A
parity test reads the JSON Schema from the client and asserts its enum equals the
code, so the two sides of the HTTP boundary cannot drift.
The deserter allowed three callings that no longer exist. He now allows all seven;
a thematic gate is a content decision for the Greywater authoring.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QYa9u7Kdxv5gX4AnwWexy8
38 lines
1.3 KiB
GDScript
38 lines
1.3 KiB
GDScript
extends "res://addons/gut/test.gd"
|
|
## The canon log crosses the HTTP boundary, so its roster exists twice: in code
|
|
## (Callings.IDS / Races.IDS) and in the JSON Schema the API validates against.
|
|
## Nothing at runtime reconciles them. This does.
|
|
|
|
const ContentDB = preload("res://scripts/content/content_db.gd")
|
|
|
|
|
|
func _player_schema() -> Dictionary:
|
|
var path := ProjectSettings.globalize_path("res://") \
|
|
.path_join("../docs/schemas/canon-log.schema.json").simplify_path()
|
|
var doc: Variant = ContentDB.load_json(path)
|
|
assert_eq(typeof(doc), TYPE_DICTIONARY, "canon-log schema did not parse")
|
|
return doc["properties"]["player"]
|
|
|
|
|
|
func test_schema_calling_enum_matches_the_code():
|
|
var enum_ids: Array = _player_schema()["properties"]["calling_id"]["enum"]
|
|
enum_ids.sort()
|
|
var code_ids: Array = Callings.IDS.duplicate()
|
|
code_ids.sort()
|
|
assert_eq(enum_ids, code_ids)
|
|
|
|
|
|
func test_schema_race_enum_matches_the_code():
|
|
var enum_ids: Array = _player_schema()["properties"]["race_id"]["enum"]
|
|
enum_ids.sort()
|
|
var code_ids: Array = Races.IDS.duplicate()
|
|
code_ids.sort()
|
|
assert_eq(enum_ids, code_ids)
|
|
|
|
|
|
func test_schema_requires_race_and_calling():
|
|
var required: Array = _player_schema()["required"]
|
|
assert_true("race_id" in required)
|
|
assert_true("calling_id" in required)
|
|
assert_false("class_id" in required, "class_id is the rulebook's word — it is gone")
|