Closer/seed
null eaedeb398c fix(seed): make build_db.py produce a Room-loadable asset database
build_db.py could not produce a shippable app.db and would have crashed the
app on first launch. It created only 2 tables (Question, QuestionCategory)
while AppDatabase declares 4 entities, and it never wrote room_master_table.
Since createFromAsset runs with no migrations and no destructive fallback,
Room validates strictly against identity hash 7e7d78fc... — so the output was
guaranteed to fail. Hence the standing "never run build_db.py" rule; the tool
had drifted from the schema it feeds.

Schema is now taken from Room's own exported schema
(app/schemas/app.closer.data.local.AppDatabase/1.json, via room.schemaLocation)
rather than hand-written DDL: all 4 entity tables + indices + the identity row
are created from it, so the script follows future schema changes automatically.
Verified the output's PRAGMA table_info/index_list is identical to the shipped
known-good db for all 5 tables, with a matching identity hash.

Also fixes the answer_config contract. The app's only parser
(QuestionMapper.parseAnswerConfig) reads camelCase keys, but the shipped db
stores snake_case and the old script emitted a third shape again — so scale
labels silently resolved to "" (the UI then shows bare numbers) and written
max_length was ignored. The authoring JSON stays snake_case per
QUESTION_SCHEMA.md; translating to the parser's shape is now this script's job.

Content problems are now hard failures instead of silent corruption. Previously
a JSON parse error or missing category made the script skip/mislabel a whole
pack ("unknown"). Now rejected with a precise message: parse errors, missing
category object (patch manifest under a production filename), zero questions,
missing id, duplicate id/text, invalid type/access, category_id mismatch,
non-integer depth, choice without options, this_or_that without exactly 2.
All 12 guards verified against mutated fixtures; a valid pack still builds.

Adds --check (validate only) and --out (build elsewhere). Builds are staged to
a temp file, verified, and only then moved into place, backing up the existing
asset db first.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-14 18:37:59 -05:00
..
questions review 2026-07-14 18:22:45 -05:00
build_db.py fix(seed): make build_db.py produce a Room-loadable asset database 2026-07-14 18:37:59 -05:00
degender_desire_sync.py feat: update desire sync question bank, degender scripts, app.db rebuild 2026-06-18 21:41:14 -05:00
degender_wheel_sexual_prefs.py feat: update desire sync question bank, degender scripts, app.db rebuild 2026-06-18 21:41:14 -05:00
fix_depth5_grammar.py chore: Q3 asset DB cleanup (remove 300 dead rows), Q5 grammar fix for depth-5 questions in emotional_intimacy + stress 2026-06-18 22:03:52 -05:00
fix_question_quality_q2.py fix: Q2 grammar quality pass on emotional_intimacy, parenting, stress questions + app.db rebuild 2026-06-19 00:50:23 -05:00
improve_question_variety_q1.py chore: update Q1 scripts with minor fixes 2026-06-19 00:38:43 -05:00
validate_question_variety.py fix: Q2 grammar quality pass on emotional_intimacy, parenting, stress questions + app.db rebuild 2026-06-19 00:50:23 -05:00