feat(go-services): inventory-go Phase C — ingestion (validated, isolated DB)

Wires the validated item-processor into the ingestion endpoints, writing to an
isolated inventory-go-db (never production):
- schema.go: faithful 7-table replica of inventory-service/database.py.
- ingest.go: /process-inventory (full replace), POST/DELETE single item, with the
  exact delete-then-insert flow, dynamic INSERT builder (quotes reserved "unique"),
  spell union (is_active), and item_raw_data verbatim. enhancements always inserts.
- compose: isolated inventory-go-db (postgres:14, 127.0.0.1:5435) + read-write
  inventory-go-shadow (:8773) that owns it; schema init on boot.

Validated by ingesting a recently-ingested character's items (from production's
original_json) into the shadow DB and diffing vs production: byte-identical —
items 243, combat 243, enhancements 243, ratings 6, requirements 19, spells 52
all match; 0 per-column mismatches across 243 items.

Finding: older production normalized rows can be STALE (predate the code reading
Decal keys 218103832/218103835); Go matches the CURRENT Python code, so validate
ingestion against recently-ingested characters.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Erik 2026-06-24 12:42:26 +02:00
parent b90b52c515
commit c49b81c237
5 changed files with 466 additions and 3 deletions

View file

@ -266,7 +266,7 @@ func (s *Server) processItem(raw map[string]any) map[string]any {
"items": items,
"combat": nullify(combat, sentinelCombat),
"requirements": nullify(requirements, sentinelReq),
"enhancements": nullify(enhancements, sentinelEnh), // always present
"enhancements": nullifyKeep(enhancements, sentinelEnh), // ALWAYS inserts a row
"ratings": nullify(ratings, sentinelRating),
"spells": spellRows,
}
@ -334,8 +334,21 @@ func nullify(m map[string]any, isSentinel func(any) bool) map[string]any {
}
}
if !any_ {
// caller distinguishes; combat/req/ratings skip (nil), enhancements keeps.
return nil
return nil // combat/req/ratings: skip the insert when all-sentinel
}
return out
}
// nullifyKeep is like nullify but ALWAYS returns the map (for item_enhancements,
// which inserts a row even when every value is NULL).
func nullifyKeep(m map[string]any, isSentinel func(any) bool) map[string]any {
out := make(map[string]any, len(m))
for k, v := range m {
if isSentinel(v) {
out[k] = nil
} else {
out[k] = v
}
}
return out
}