CSEMA Go Rewrite: Progress
Work log for the rewrite plan. Updated: 01 Nov 2026, 20:01 IST.
Live demo
The demo runs on the development machine through a Cloudflare quick tunnel. The address changes when the tunnel restarts. Mail goes to a local Mailpit, so sign up and use the account without the verify link.
https://michelle-quality-short-repeat.trycloudflare.com
Phases
| Phase | State | Notes |
| P0 Set up | Done | Go module, csema database, Makefile, CI checks, Nuxt app with the theme override. |
| P1 Skeleton, auth, progress | Implemented, checks open | Server, db, mail, auth, onboarding, progress and all 23 tables work. Google and GitHub sign-in still need configured keys. |
| P2 Learner backend | Implemented, few checks open | Learner routes, import, staff CRUD and uploads exist. A real Razorpay checkout remains open. |
| P3 Labs | Implemented, few checks open | Host setup, Docker isolation, SSH gateway, browser terminal, code runner and wildcard HTTPS work. See the plan table for the open checks. |
| P4 UI | In progress | Learner and staff screens exist. The polish segment below is complete. |
| P5 Events | Implemented, UI checks open | Backend and screens exist. The browser dry run and load check remain open. |
| P6 Verify and harden | Pending | Needs load checks, upgrade checks and owner approval. |
| P7 Migration and cutover | Plan later | |
Current work order
The UI polish segment and the content and lab cleanup are complete. Next: the open checks in the plan table.
UI polish segment (01 Nov 2026)
- The landing page is at
/. The signed-in home is at /dashboard.
- Auth screens, Ctrl+K search, buttons, cards and focus states use one calm theme with soft neutral surfaces.
- A flag capture or a finished lesson shows a short celebration.
- Learn, Practice, leaderboard, teams, events, profile, account, billing and admin lists are restyled.
- The sidebar has its own surface and a raised active row. Its collapse button is at the bottom.
- All 765 challenge titles, categories and stories are rewritten. Categories drop from 38 to 15.
- A machine flag can be per-player: the lab gets the user ID and writes a flag from it and a secret. 25 labs use this.
- A user can have many sessions. A session lasts 7 days by default.
- Browser check: admin, auth and sidebar in light, dark, collapsed and narrow states.
- Reworked the Learn list to match Practice: floating search and filter bar, card grid, done count in the title bar. A Continue link replaces the resume banner, and paths in progress come first. Each card has a topic icon in the topic colour, a summary, and a footer with level, lessons and state.
- Rewrote all 27 learning path titles and summaries with Codex, to a fixed length. Learn cards now have one height.
- Added review guides with the working prompts for learning paths and challenges.
- Reworked the Learn path page: brief and section list on the left on desktop, lessons on the right, and one list on phones. The next lesson has a blue number, and finished sections show a green count. The API now returns the lesson kind.
- Shortened all section names with Codex so they fit on one line. Deleted one path and corrected 5 path labels.
- Refined the Learn path page after a design review: narrower centred layout, taller rows, a larger next-lesson marker, a locked-path message, and better keyboard and screen reader behaviour.
- Learn and Practice search bars show a shadow only after the page scrolls. Both use one shared component.
- The challenge cover is a rounded card on phones. Desktop keeps the full-width design.
- Event posters show a shimmer while they load.
- Home, Learn, Practice and Events show shimmer cards instead of a spinner while they load.
- Practice loads more challenges on scroll. The Load more button is gone.
- The no matches text splits into two lines on phones.
- Opened the CSEM v3 pull request. It is not merged.
- Next: the lesson screens in the learning path.
- Bottom sheets now stay above the phone keyboard, and the sheet handle is easier to see.
- The flag list is simpler on phones, and flag questions now name what to submit. The flag input has an outline.
- Next: Rabbit, our own presentation tool with voice and interactive parts, to replace Marp and hand-built decks. The plan is written and waits for approval.
Content and lab cleanup (01 Nov 2026)
Every challenge was checked, fixed or unpublished, and every machine lab was started on a real lab host. Now 384 of 632 challenges and 63 of 152 machine labs are published.
- Codex (gpt-6-luna, high effort) rewrote all 784 challenges and machines: title, story, hook, objective, known facts, questions, hints, category and tags from a fixed list. A script checked each result: challenge data, file names and links stay the same, flag parts and XP do not change, and no flag is in the text. All titles are unique.
- 8 challenges with very long flags got short flags taken from the evidence. Each one passed a blind solve.
- 122 reviewed challenges are now published.
- Unpublished, with the reason in the log: challenges whose external target is down, challenges that need a private registry login on the player's computer, and a riddle with no known answer.
- Each machine lab was started on the lab host with the same limits as the agent: 1 CPU and 512 processes. The test checked that each container runs, that each port answers and that SSH greets. It did not solve the labs.
- Fixed lab specifications: wrong ports on 8 labs and memory that was too low on 2 labs.
- Unpublished machine labs that cannot run safely or at all: labs that need privileged containers or extra capabilities, labs whose containers must share a volume, broken images and OVA virtual machines.
- 3 entries without a runnable lab became plain challenges. A plain challenge can now have several flag questions, like a machine.
- Private registry logins are a setting (
lab_registries). Each sync sends them to the agents, and the agent uses only these logins to pull images.
- The lab panel is simpler: one start button, one short starting message. Opening a machine page now starts its lab when the player has time left and no other lab runs.
- The challenge file viewer shows "Open target" next to "Download" in its header.
- Challenge page redesign: the lab toolbar holds "Open web target", the time left and Stop. The Access tab became Connect, with each value in its own field and copy button. The flag panel puts the question and its XP on one line. On a phone the page fits the screen: Brief, Lab, Flags and Hints are tabs, and a floating Flag button opens a sheet. Long text has a 24 px line height.
Lab resources
Measured on a 2 CPU, 8 GB lab host, about 20 seconds after start, with no player activity. The suggested limit is the measured peak times 1.5 (at least peak plus 64 MB), rounded up to 64 MB, with a minimum of 128 MB.
Applied. 58 containers now use the suggested limit. A retest of all 72 labs with the new limits had no out-of-memory stop. The 9 labs that need more than 100 MB in total are unpublished for now, so the table below is for reference.
| Measure | Value |
| Published labs measured | 72 labs, 80 containers |
| Sum of memory limits | 27.6 GB |
| Sum of measured peaks | 4.8 GB |
| Sum of suggested limits | 13.8 GB |
| Median container | 26 MB peak, 50 MB image |
| Containers under a quarter of their limit | 58 (most have 500 MB and use 20 to 30 MB) |
Largest containers:
| Lab | Container | Peak | Limit | Image | First pull |
| 398 | OpenSearch | 851 MB | 1536 MB | 919 MB | 100 s |
| 1132 | main | 496 MB | 768 MB | 188 MB | 1 s (cached) |
| 354 | target | 433 MB | 704 MB | 248 MB | 22 s |
| 397 | MongoDB | 263 MB | 768 MB | 280 MB | 36 s |
| 353 | target | 205 MB | 320 MB | 123 MB | 25 s |
| 344 | target | 192 MB | 320 MB | 154 MB | 28 s |
OpenSearch (398) needs about 60 seconds before it answers. LocalStack (387) has a 409 MB image and takes about 48 seconds on its first pull.
What works now
- One binary (16 MB with the UI) serves
/api, /files and the embedded Nuxt app. Unknown paths get 200.html.
- AutoMigrate creates all 23 tables on the local MariaDB 11.8. A second start changes nothing.
- Sign up, verify mail (through the outbox to Mailpit), log in by email or username, many sessions per user, forgot and reset password, change password, log out.
- A real Django
pbkdf2_sha256 hash logs in and is replaced with argon2id.
- A cookie request that changes data from another origin (for example a lab site) gets 403.
progress.Record is the one writer of users.xp. Event rows never change it.
- Content import from the Postgres copy: 43 paths (27 published), 752 modules, 434 activities, 763 challenges (367 published), 4 plans, the 30 ranks and the onboarding survey. 2,832 content files copied.
- The old flag hashes work: 30 flags found in the old lab sources match their stored HMAC hashes with the copied pepper.
- Practice: challenge list with filters, detail, flag submit (machines with several flags), hints in order with XP cost.
- Learn: paths, lessons, quiz grading, module completion with XP, path certificates with a public check.
- Teams: create, invite, join request, join code, accept, remove, owner transfer, member limit.
- Settings table with typed values, defaults in code, admin list and PATCH.
- Labs: a host becomes ready through the admin API. A real imported private image runs with an attack box. The browser terminal executes commands through the core and agent.
- A second session cannot reach the first session, host SSH or the internet. Stop removes the session containers. An agent restart keeps the existing lab containers.
- Zero-downtime upgrade with
tableflip on SIGHUP (not yet tested under load).
- The browser makes no request to a third-party host. Inter and Lucide icons are bundled.
Decisions to review
I made these choices without asking. Each one is easy to change.
- Echo v5 (v5.4.4, stable) instead of v4.
- Module path is
csema.
- OAuth without a library. The Google and GitHub code flow uses the standard library only. The provider URLs are in code, because the providers fix them.
- User tiers are
free, prime, elite. The old basic becomes free at migration.
- Challenge difficulty keeps the old 4 values: easy, medium, hard, expert.
- Extra columns not in the ERD:
paths.tier (prime and elite paths), plans.features and plans.position (the pricing page reads them), lab_sessions.password (SSH gateway), subscribers.status = pending (double opt-in), mail_outbox.headers (one-click unsubscribe), users.disabled.
- Technical constants stay in code: drain timeout (30 s), mail retry (5 attempts), argon2id cost, DB pool size. Business values are in settings: session days, token lifetimes, minimum password length, auth rate limit, body limit, ranks.
- Ranks default to one rank in code. The content import will store the 30 current ranks in the settings table.
- Machine flags keep the old questions: one flag part for each question, each with its own XP. The last part marks the machine solved with 0 XP, so XP is not counted twice.
- Activity XP is 0. As before, only module completion gives XP. A quiz keeps its score.
- Global teams: a user can be in more than one team (as before). Team XP is the sum of the members' XP.
- tygo is pinned as a Go tool (
go tool tygo generate).
Open questions
- Uploaded files. 408 challenge files and 31 badges and videos exist only in the production media backup. I did not touch the backup. Can I extract only
challenge_files/ and learning/ from media.tar into the local files folder?
- Importer dependency.
cmd/csema-import uses pgx to read Postgres. It is a separate one-time binary, so the core binary does not include it. It goes away after cutover.
Found in the data
- 2 pairs of users share an email when lowercased. The P7 migration must merge or rename them.
- 223 usernames have characters that new sign-ups cannot use (for example
@). They stay valid.