# Learnitive 2.0 — Hotfix30 Autonomous Continuation Prompt

## Objective

Continue Learnitive 2.0 autonomously from the hotfix30 source state. Do not redo completed source phases. The immediate task is authoritative staging acceptance after the canonical Learn seed-integrity defect was repaired.

## Protected boundaries

Deployment target only:

- `https://os.learnitive.com`
- `/var/www/os.learnitive.com`
- `/var/www/os.learnitive.com/public_html`
- `/etc/learnitive`

Do not modify production `learnitive.com` / `www.learnitive.com`, `texise.com` / `www.texise.com`, `/etc/texise/*`, TeXise vhosts, or TeXise services.

Canonical staging ports:

- API 4210
- collaboration 4211
- Redis 7387
- Console Gateway 9887
- Universal Runner 9890

## Authoritative latest staging state

The hotfix29 staging installer passed:

- canonical port/lock/trusted-runtime/R12 preflights;
- unified execution image and extracted Node `v22.20.0`;
- production browser build and dist activation;
- trusted-server/Console Gateway dependency preflights;
- Learn media sandbox verification;
- SaaS preflight against `localhost:3306/learnitive_os` with `schema=34`, `learnSchemaRepaired=false`, `migrationNameMismatches=3`, `adminProvisioned=true`;
- Apache syntax;
- Redis, Universal Runner, Console Gateway and main API health;
- isolated template validation **69/69 valid**, `failedBuiltins: 0`, `published: 69`.

It then reached the seeded Learn validator and failed with:

`Error: Missing seeded Learn course: latex-fundamentals`

This proves hotfix29 fixed the prior standalone validator environment defect: the validator now sees the SaaS DB. The remaining failure is a real seed-integrity problem.

## Hotfix30 root cause and fix

The staging database has three numeric migration-name collisions. The Learn schema is structurally current, but the historical numeric ledger caused migration 27 seed INSERTs to be skipped. Structural reconciliation therefore reported no schema drift while canonical Learn rows were absent.

Hotfix30 adds migration 35, `interactive_learn_seed_integrity_repair`:

- detects which of the nine canonical built-in Learn course slugs are missing;
- if none are missing, records migration 35 without rewriting Learn content;
- if courses are missing, replays only idempotent historical `INSERT IGNORE` Learn course/module/lesson seed statements from migrations 27-34;
- preserves all surviving Admin-edited rows;
- replays React seed-runtime repairs only if `react-fundamentals` was entirely missing;
- replays detailed migrated LaTeX guide content only if `latex-fundamentals` was entirely missing;
- restores current duration values only for courses that were absent;
- never deletes or rewrites the migration ledger.

The canonical seed slug list is now exported by `server/saas-migrations.mjs` and consumed directly by `server/validate-learn-library.mjs`, preventing validator/migration catalog drift.

`server/saas-preflight.mjs` now reports `learnSeedsRepaired` and `learnSeedMissing`.

Expected first hotfix30 preflight against the current staging DB: schema should advance to 35, and if the catalog is absent the log should show `learnSeedsRepaired=true` with a nonzero `learnSeedMissing` count. The exact count may be less than nine if some seed courses already exist.

## Verification already completed

Supported suite:

- `node --test server/*.node.test.mjs scripts/learnitive-*.node.test.mjs`
- **329 tests / 329 pass / 0 fail / 0 skipped**

Project runtime:

- `node --experimental-strip-types --test packages/js-lib/project-runtime/src/index.node.test.mjs`
- **10 / 10 pass**

Release/source gates:

- frozen pnpm lock sync PASS: 69 importers / 1581 package records / 1583 snapshots / 1171 reachable snapshots
- trusted runtime manifest PASS: 9 production imports
- R12 namespace/static Web Preview/full release contract PASS
- Learnitive brand-reference audit PASS: 0 violations
- branding/provenance PASS: 708 production-facing text files
- staging/root installer `bash -n` PASS
- modified server modules `node --check` PASS

Regression coverage explicitly verifies both the structurally-complete/missing-seeds collision and the no-overwrite path when canonical courses already exist.

## Exact current phase

Deploy/rerun hotfix30 on authoritative staging.

Expected sequence:

1. SaaS preflight reports `schema=35`.
2. Missing canonical Learn courses are restored one time before service activation; preflight shows `learnSeedsRepaired=true` if repair was needed.
3. Redis, Universal Runner, Console Gateway and main API health remain green.
4. Template validation again reports 69/69 valid.
5. Seeded Learn validation proceeds beyond `latex-fundamentals` lookup and validates all canonical courses through Universal Runner.
6. Any new failure after this point should be treated as a specific course/runtime validation defect, not a migration/environment bootstrap defect. Keep validation fail-closed.

## Remaining acceptance in order

1. Complete seeded Learn runtime validation for all canonical courses.
2. Verify Node/Python/C++ queue smoke.
3. Verify LaTeX API -> Redis -> Universal Runner smoke and PDF output/fallback behavior.
4. Verify React JS/TS, TypeScript/Vite, Vue and Svelte rendered Web Preview plus runtime error overlay.
5. Verify Markdown Bangle flow.
6. Verify uploaded/YouTube/Wistia Learn video, captions/posters and Free/Pro entitlement boundaries.
7. Verify public HTTPS `/projects`, favicon, font and SNI routes.
8. Record exact live results in `docs/learnitive-2-autonomous-state.md`.
9. If another defect appears, diagnose the complete failure class, patch it, add regression coverage, rerun supported tests/audits, and package a new non-overwriting hotfix ZIP with SHA-256. Do not patch production or TeXise.

## Autonomous execution rules

Execute continuously. Do not stop after a phase for confirmation. Use Execute -> Verify -> Diagnose -> Fix -> Verify again -> Continue. Make reasonable architecture, implementation and testing decisions independently. Ask only when genuinely impossible to infer, an external credential/permission is required, or an irreversible high-impact action requires approval.

Maintain project state continuously: completed phases, current phase, remaining phases, decisions, assumptions, requirements, dependencies, tests, verification, errors/fixes, files/artifacts and risks.

## Context handoff rule

If this chat approaches its practical context limit, finish the current safe subtask, update the state document, record the exact stopping point, and generate another complete self-contained `NEXT_CHAT_CONTINUATION_PROMPT.md` containing all information needed by the next chat. Preserve this same autonomous execution, verification and handoff rule.

Continue autonomously from this exact state. Do not restart completed phases. Do not ask for confirmation. Execute all remaining phases sequentially, verify each phase, fix problems, and continue until the project is complete. If this chat again approaches its context limit, generate another complete continuation prompt for the next chat before stopping.
