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

@ -152,5 +152,50 @@ services:
max-size: "10m"
max-file: "3"
# Phase C: isolated inventory DB the Go ingestion writes to (never production).
inventory-go-db:
image: postgres:14
container_name: inventory-go-db
ports:
- "127.0.0.1:5435:5432"
environment:
POSTGRES_DB: "inventory_db"
POSTGRES_USER: "inventory_user"
POSTGRES_PASSWORD: "${INVENTORY_DB_PASSWORD}"
volumes:
- inventory-go-data:/var/lib/postgresql/data
restart: unless-stopped
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
# Read-write inventory-go instance: owns inventory-go-db, exposes the ingestion
# endpoints. Used to validate ingestion (POST a character's items, compare the
# resulting normalized rows to production) without touching the production DB.
inventory-go-shadow:
image: inventory-go:local
container_name: inventory-go-shadow
ports:
- "127.0.0.1:8773:8773"
environment:
PORT: "8773"
DATABASE_URL: "postgresql://inventory_user:${INVENTORY_DB_PASSWORD}@inventory-go-db:5432/inventory_db"
READ_ONLY: "false"
ENUM_DB_PATH: "/enums/comprehensive_enum_database_v2.json"
LOG_LEVEL: "INFO"
volumes:
- ./inventory-service/comprehensive_enum_database_v2.json:/enums/comprehensive_enum_database_v2.json:ro
depends_on:
- inventory-go-db
restart: unless-stopped
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
volumes:
dereth-go-data:
inventory-go-data: