docs(website): settle how module schema fragments are validated and replayed #128
Reference in New Issue
Block a user
No description provided.
Delete Branch "docs/module-schema-replay"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Docs half of Phase 2 PR 3. Code half: RunicGateway/website#130.
MODULE_SYSTEM.md§2.7 gains the PR 3 entry;MODULE_API.md§2.6 gains the four decisions the section did not previously answer.The decision that shaped the code
A fragment is validated at load time and executed later — the split is whether a database is needed to know the answer. Everything §2.6 states about the SQL (namespaced tables,
IF NOT EXISTS, noDROP) is knowable by reading the file, so breaking one of those rules costs the module its mount entirely (§4.4's left-hand column) rather than mounting and then 503ing with its tables half created. What is left for the replay is the class of failure only the server can report — an unknown column type, a bad foreign key — and that is post-mount and answers 503.The other three
DROPdenylist.CREATE,ALTER,INSERT,UPDATE— the four core's ownschema.sqluses. §2.6 words the rule as "noDROP", but the file is replayed on every boot:TRUNCATEandDELETEwould empty a table at every restart andRENAMEwould fail at the second one. A denylist only ever bans what somebody thought of. The section is explicit that this is a leading-verb check and claims no more —ALTER TABLE x DROP COLUMN ypasses it, and catching that needs a SQL parser.ensureSchema()'s retry loop. That loop exists to wait for the database; a fragment that throws is one module's failure, not a signal the database is not ready, and retrying core's whole schema nine more times over one module's bad SQL would turn a 503'd module into a two-minute boot.One thing found while wiring it
db/seed.js(npm run seed) callsensureSchema()standalone without ever requiringapp.js, so no scan has happened andfragments()'s §7.6 throw would have broken seeding outright. It is now the one sanctioned caller that replays nothing and says so in the log — everywhere else, reading the module list beforeload()still throws, because a booting server quietly getting no module tables is what §7.6 exists to prevent.