struct-audit

command
v0.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 24, 2026 License: MIT Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

struct-audit

Audits how well our Go decode structs match the live game API. Compares three sources, flattened to dotted JSON paths:

  1. Go — structs in pkg/game/serverapi/ and the cmd/data/import-* KB importers (dumped by this command via go/ast, nested types expanded).
  2. Spec — server_docs/openapi.json component schemas.
  3. Live — real response snapshots in data/game-api/latest/*.json.

Run

From the repo root:

python3 cmd/data/struct-audit/audit.py

Writes server_docs/import_struct_audit.md (gitignored). Re-run after each data scrape — the openapi.json symlink and latest/ snapshots update, so the report always reflects current drift.

The Go half can be run on its own to dump structs as JSON:

go run ./cmd/data/struct-audit pkg/game/serverapi

Report sections

  • A — fields in live data the Go struct lacks (add these).
  • B — spec-declared fields Go lacks, with no live sample (lower confidence).
  • C — structs with no snapshot, Go-vs-spec only (2-way).
  • D / D2 — Go fields gone from spec+live (candidate removals); D2 is unconfirmed (the snapshot's parent array/object was empty so it can't verify).
  • E — action echo field (WebSocket-only; usually harmless).
  • F — cmd/data/import-* importers vs their catalog/base/map snapshots.

Confidence notes

  • Snapshots/openapi describe the HTTP REST API. Go also decodes the WebSocket protocol, which bundles extra context (action, nearby, poi, current_tick) — these are reported separately, not as deletions.
  • Go map[string]... fields cover their dynamic subkeys (no false "missing").
  • A "stale" field is only confirmed when its parent array/object is populated in the live snapshot (empty arrays can't prove a field was removed).

Documentation

Overview

Command struct-audit dumps Go struct definitions (name, fields, json tags, resolved types) as JSON for the import-struct audit pipeline.

It is the Go half of the audit; the comparison + report generation lives in audit.py (which invokes this command). Run via audit.py, or directly:

go run ./cmd/data/struct-audit pkg/game/serverapi

Output: a JSON array of {name, file, fields:[{json,go_name,go_type,omitempty,inline}]} on stdout. Only stdlib is used so it compiles standalone within the module.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL