fix(stage): isolate credentialless author bootstrap and recovery rehearsal
Stage author bootstrap (dedicated repair) / bootstrap (push) Failing after 3m55s

This commit is contained in:
Canina Automation committed 2026-10-28 19:52:55 +00:00
1 parent 6ed0e73311
commit 46da1c5339
30 files changed
+1295 -62

No files matched your search

@@ -0,0 +1,24 @@
# Stage-only attribution bootstrap repair
## Scope and authorization
Stage additive DDL and five genuine attribution identities only. Production, main, prices, stock, paid actions and approval modules remain prohibited. Existing 52 Blog author references remain unchanged. No contacts, credentials or privileges are copied from Production.
## Design
`users.mobile` becomes physically nullable, but a validated CHECK continues requiring non-null mobile for every ordinary user. `is_public_author` defaults false. Public authors require no mobile/email/password, no auth/session markers, no balances and the baseline User_PetOwner value; the marker denies all authentication and permission guards independently of role. Unique non-null mobile semantics remain unchanged.
The repair API requires genuine human-admin JWT verification, exact Stage database identity, explicit maintenance mode and actual loopback socket peer. A Serializable transaction preflights all five identities and the exact orphan distribution 16/2/3/14/17; partial/conflicting states fail before inserts. Replay requires all exact safe rows and zero orphans.
The dedicated maintenance module imports no full app, seed or worker modules. Its Prisma provider only connects, never runs schema-creation hooks. Existing JWT, Redis revocation, role and human-admin guards are reused; API keys are denied.
## Recovery gates
Retain original full dump and its expected FK restore failure. Disposable rehearsal restores pre-data and data, applies/replays reviewed DDL, performs the authenticated five-author API operation, restores ALL post-data, then dumps/restores the repaired clone fully. This does not certify the original invalid archive as clean. Live Stage DDL follows only successful rehearsal; live business rows are inserted exclusively by authenticated backend API. The unchanged normal full-data recovery gate remains mandatory afterward.
## Verification obtained
- Actual PostgreSQL 16.2 migration integration: 18 checks passed, including real-user null-mobile rejection, prohibited author fields, duplicate real mobile, safe author rows, wrong database denial and idempotent DDL replay.
- Backend TypeScript build passed.
- Focused maintenance/auth/restoration suites: 83 tests passed; broader auth run: 61 passed.
- Bootstrap transport/workflow tests: 15 passed. Existing schema-operation tests: 17 passed.
- Full backend suite: 98 passed suites; two failures remain in unchanged wiki pagination expectation and PostgreSQL fixture construction with absent URL. Do not claim a clean full suite.
## Outstanding execution prerequisites
Obtain parent-assisted genuine Stage human-admin bearer via private mode0600 file visible to the runner. Configure existing repository secret administration with exact reviewed SHA and private file path; never bearer contents in source/chat/logs. Execute dedicated rehearsal then apply workflow for that exact SHA. Verify actual clone full recovery, live API readback, unchanged normal recovery gate and normal exact-SHA Stage CI/image/live behavior. No live schema or data writes have been executed by this implementation work.