ADR-047 — Online workspace: no student credential, therefore no write access¶
Status¶
Accepted in heig-classroom (2026-09-17, portal milestone 2, its ADR-013); imported 2026-09-30 (merge task M0-03, ADR-035) and amended for Quiz on 2026-10-07, 2026-10-08, 2026-10-11, 2026-10-29 and 2026-11-16, and by ADR-145 on 2026-11-24. The body is classroom's, read with the merge's renames; Quiz's rules in force are under Quiz's amendments. Delivery: merge progress. The dated text of every amendment is in the historical record.
- 2026-10-07, M6-03: the portal's GitHub relay and its own login (amendment).
- 2026-10-07, M6-06: the work mode in Quiz, its grant, quota and messages (amendment).
- 2026-10-07, M6-07: Safe Exam Browser for a project (amendment); no SEB project opens to students before proof B is recorded.
- 2026-10-07, ADR-078: no App key on the engine VM; the portal seeds and relays with installation tokens Quiz issues for one repository.
- 2026-10-08: an administrator always holds the workspace grant (amendment).
- 2026-11-16: the administrator's address may hold a grant row, for its quota (amendment).
- 2026-10-09, ADR-089 (accepted 2026-11-15): an
online_sebproject may accept kiosk stations; it amends M6-06 (A) and M6-07 here (its amendment). - 2026-10-11, audit M11 and L25: the service token is single use and bound to its request, every token's lifetime capped (ADR-078's amendment).
- 2026-10-11, audit L7: the start route is a POST (amendment).
- 2026-10-11, audit L24: one origin for every session (amendment).
- 2026-11-14, ADR-129: the staff's review session — a staff member opens a project repository in the workspace, read-only, whatever its mode; it breaks the L24 premise (amendment).
- 2026-11-24, ADR-145: §2 amended — once the lab test is over, the course owner may open an
online_sebproject's repositories to their students withpull, and close them again. - 2026-11-25, ADR-146 (accepted): a session runs the default
quiz-baseor an image of its course's list; L24 rule 4 bindsquiz-base, and a course's image may bring notebook support back, the residual risk accepted by the owner. - 2026-11-26, ADR-149: decision 2, rejected alternative 1 and M6-06 (A) amended — a fourth mode,
hybrid, invites withpushbeside the workspace's relay: "only the relay writes" now holds foronlineandonline_sebonly; the two-write-paths argument was the exam's, whichhybridnever is. The same day, §7: M6-06 (A)'s freeze leavesonline→hybridopen after a launch, and a change that widens the invitations topushraises those already sent. - 2026-10-29, #958: under
commit, anonlineproject's start route opens while the repository is writable (ADR-078's amendment). - Extended 2026-10-05 by ADR-075 (proposed): the
workspacequestion type opens the workspace in a supervised evaluation, without a git channel; the project rules are unchanged.
Context¶
The apps/codespace portal makes the student work inside a hardened container served by
code-server, possibly under Safe Exam Browser. Its founding invariant is that no secret
enters the student container: no GitHub token, no SSH key, no credential helper. It is the
container that pushes — through a relay authenticated by the source IP address on the
internal bridge — and not the student from their editor.
Now, in the historical classroom flow (the "free" mode), the student repository is
provisioned with push permission: the student clones and pushes with their own GitHub
account. Keeping that right in online mode would mean two write paths coexisting on the same
repository (the portal relay, and the student from any browser), which makes the content of
an exam indefensible: nothing distinguishes a commit produced in the supervised session from
a commit pushed from home.
We also have to decide who may turn the feature on. The container engine is a privileged
component on a dedicated VM with bounded capacity (a few dozen sessions); opening it to every
teacher of classroom.chevallier.io at once makes no sense while the pilot covers one or two
classes.
Decision¶
- An assignment has a work mode (
assignments.work_mode,WorkModeof the shared contract):free(unchanged),online,online_seb. The default isfree: every existing assignment keeps exactly its behaviour. - No student credential, therefore no write access. Provisioning
(
github/provision.ts) invites the student with the permission: free→push(the historical flow, strictly unchanged);online→pull: the student reads their repository and re-reads their commits, but only the portal relay writes to it — so there is no student credential to distribute, expire or revoke;online_seb→ no invitation at all: during an exam, the student has no access to the repository before grading. The anti force-push and anti-deletion ruleset (hgc-protect, GH-21..23) stays in place in all three modes: it also protects against the relay.- A one-way door. An assignment published in an
online*mode cannot go back tofree(409work_mode_frozen). Its repositories were provisioned without write access; going back tofreewould leave every student in front of a repository they cannot push to, and grantingpushafter the fact would contradict exactly the invariant this mode protects. A new assignment is created instead. - Activation by the administrator, teacher by teacher, with a quota of simultaneous
sessions: two columns on
teacher_grants(codespace_enabledatfalse,codespace_max_active_sessionsat 2). A teacher without that grant does not see the "Work mode" section of the form (the front end readsMe.codespace) and the API refuses any non-freemode with a 403 — the server-side check is the only authoritative one. - Global absence is possible. An empty
CODESPACE_URLmeans the feature does not exist: no administration column, no selector, and the/app/codespace/*routes answer 404. ACODESPACE_URLwithout aCODESPACE_LAUNCH_SECRETof at least 32 characters makes startup fail (ADR-010: secrets travel through the environment). - Two HS256-signed messages, never a cross import (the import rule of the root
CLAUDE.md): - classroom → portal:
PUT ${CODESPACE_URL}/api/assignments/:idwith aCodespaceAssignmentSyncbody and a 2-minuteServiceTokenClaimsinAuthorization: Bearer. The call goes through a pg-boss job (codespace.sync, singleton keycodespace:<assignment>, ADR-004/ADR-011): a portal that is restarting never makes saving an assignment fail, recovery is free, and the state of the last attempt (codespace_synced_at,codespace_sync_error) is shown to the teacher with a "Resync" button. - student → portal:
GET /app/codespace/start/:aidchecks enrollment, acceptance, publication and mode, issues a 5-minuteLaunchTokenClaimswith a randomjtiand redirects with a 303 to${CODESPACE_URL}/launch?token=…. It is a navigable GET because the portal also uses it as thestartURLof Safe Exam Browser, which can only navigate. Issuance is logged (codespace.launch_issued) by itsjti; the token itself never enters the log (AU-41). - Browser Exam Keys are teacher-side secrets. They are stored on the assignment
(
browser_exam_keys), sent to the portal in the synchronization message, and never included in a student payload.
Consequences¶
- In online mode a student can no longer push from their own machine: that is the intended
effect, but it means the portal becomes indispensable to submission. An outage of the
portal during an online lab is therefore a submission incident, not merely a comfort one —
the
freemode stays the default for everything that does not need supervision. - The grading CI is unchanged: it triggers on the relay's pushes exactly as on a student's, and the whole grading chain (GR-05..16) ignores the mode.
- The migration is purely additive (columns with defaults, no rewrite): the production
service gets
work_mode = 'free'everywhere and does not change behaviour. - The quota is carried by the owner of the class, not by the staff member who saves the assignment: it is the person running the course who consumes the VM's capacity.
- The portal stays extractable: all it knows of classroom is those two signed messages.
Rejected alternatives¶
- Keeping
pushin online mode and relying on supervision: two write paths on the same repository, indefensible exam content, and the "no secret in the container" invariant would lose its point since the student would have a credential anyway. - Distributing a short-lived token inside the container so the student pushes themselves: that is exactly the secret the container hardening forbids, and it would be exfiltrable from any terminal in the editor.
- A synchronous HTTP call to the portal when the assignment is saved: an unavailable portal VM would make an unrelated teacher action fail, and we would have to reinvent the recovery that pg-boss already provides.
- Global activation through an environment variable: it would be impossible to run one class without exposing all the others, and there would be nowhere to put the per-teacher quota.
- A single global quota rather than one per teacher: a teacher starting an exam would consume everyone else's capacity without any screen showing it.
Quiz's amendments¶
Reading the imported body¶
Imported from heig-classroom (2026-09-30, merge task M0-03, ADR-035),
where it is ADR-013 — Quiz's own ADR-013 is pool sharing, so it takes the
next free number, 047. The Decision above is classroom's, verbatim. Read it
with the renames of the merge: assignment ⇒ project
(assignments.work_mode ⇒ projects.work_mode; the portal's own
/api/assignments/:id route is the portal's business); classroom
(org-bound, owned) ⇒ a Quiz course plus classroom, and "the owner
of the class" ⇒ the course's staff (D04), except for the quota below:
whose teacher_grants quota an online project consumes once several
staff share a course was for M6 to decide (M6-06 (C) below); a codespace session ⇒
workspace in Quiz's vocabulary; @hgc/codespace ⇒ @quiz/codespace;
CLASSROOM_URL ⇒ PLATFORM_URL; apps/server ⇒ apps/api;
classroom.chevallier.io ⇒ Quiz. The portal (apps/codespace) and this
mode come with phase M6, after the cutover (D09, settled 2026-10-01: the
workspace is rebuilt and tried in Quiz before any migration of it). How SEB reaches a project — the
platform building every .seb, Browser Exam Keys optional per activity —
is D21, settled 2026-10-01 on the suggestion, for M6; point 7 above held
until M6-07 implemented it (below). Its two HS256
messages are the cross-VM exception recorded in
ADR-027.
Classroom's requirement ids (GR-, GH-, NFR-, AU-) are those of
heig-classroom's specification; docs/spec/02-exigences-fonctionnelles.md
receives their Quiz form (M0-04), and until then they are read in
heig-classroom's docs/.
M6-03 (2026-10-07): the portal's relay and its own login¶
Product owner. Scope: the portal side of points 2 and 6 above, nothing
on the platform side.
(a) Relay off. The relay and the development (Forgejo) forge are
imported, heig-classroom's App-backed GitHub forge is not, and the portal
runs with FORGE_KIND=none by default: a push lands in the session's
staging.git and its PushEvent is written (the proof of submission),
nothing is relayed to GitHub. The portal refuses to start, in every
environment, when GITHUB_APP_ID or GITHUB_APP_PRIVATE_KEY_PATH is set:
the only App it was ever configured with is heig-classroom's, which Quiz
never uses (root invariant 15, D23). Settled 2026-10-07 by ADR-078: no App key on the engine VM; the portal seeds and relays with installation tokens Quiz issues for one repository (forge quiz, M6-10).
(b) No login of its own. The portal's OIDC login (/auth/*), its home
page with a Start button, its /teacher/sessions dashboard and its
standalone /exam/:id/start route are removed: a user exists only through
the platform's launch token, every portal account is a student, and an
exam opens through /launch only. A teacher sees an assignment's
workspaces in Quiz, which calls the portal's
GET /api/assignments/:id/sessions with a service token
(CodespaceSessionSummary, @quiz/contracts). The portal's seb/
directory is kept as is until M6-07 moves it onto packages/seb.
M6-06 (2026-10-07): the work mode in Quiz¶
Product owner. Scope: points 1 to 6 on the platform side, as Quiz implements them; the
portal is unchanged.
(A) The mode. projects.work_mode (free | online | online_seb,
default free, migration 0079_codespace_module). It is set by its own
route, PUT /app/api/projects/:id/workspace/mode, in any state of the
project, never by the create or the patch. Point 3's one-way door becomes:
the mode is frozen once a workspace was launched for the project — the
first launch token issued to a student seat, codespace_projects.first_launch_at
— and any change after that is 409 work_mode_frozen (but online to
hybrid, which only widens, since ADR-149 §7); a staff seat's
launch (ADR-077, a teacher testing the project on their test repository)
never freezes it; before it, every mode may
change, free included. A group project stays free (F-PROJ-06): an
online mode on a group project, or group mode on an online project, is
409 work_mode_group. Point 2 applies from the next invitation: push in
free, pull in online, none in online_seb (the repository is
provisioned, nobody is invited; a second Accept answers it as it stands);
an invitation already sent keeps the permission it had (unless the
change widens it to push: then it is raised, ADR-149 §7). online_seb can
be set, but its start is refused outside Safe Exam Browser with a named
refusal (seb_required) until M6-07, and it is not synced: the portal
refuses an exam without Browser Exam Keys, which come with M6-07.
(B) Who. Only an owner of the course (ADR-068, requireCourseRole:
an assistant gets 403 owner_required, in the loader, before the body)
whose teacher_grants row has codespace_enabled = true may set a
non-free mode (403 codespace_not_granted otherwise; going back to free
needs no grant). The grant is two columns on teacher_grants,
codespace_enabled (false) and codespace_max_active_sessions (2),
edited by an administrator (PATCH /app/api/admin/teachers/:gid/codespace).
An account's grant is read on its VERIFIED addresses only (its verified
ones, and its sign-in address when the identity provider verified it), the
most permissive row winning, as the role rule does; the administrator, whose address cannot hold a grant (it may since 2026-11-16), is not
granted (an administrator acts as an owner under Super Powers, ADR-054,
never past the grant) — superseded 2026-10-08: an administrator is always
granted (amendment below).
(C) Whose quota. The quota an online project consumes is carried by its
creator while they still hold an owner seat on the course, otherwise by
the oldest owner seat (quotaHolder, @quiz/domain); it is sent to
the portal with each sync (teacher and quota of
CodespaceAssignmentSync), and the portal enforces it at launch (its
429). Quiz does not count the live workspaces itself.
(D) Off. With CODESPACE_URL empty the codespace module registers no
route (every one a 404, indistinguishable from a missing entity), the
administration lists no grant, and a project's student view says no
workspace.
The two messages of point 6 are Quiz's: the sync is the codespace.sync
job (no singleton key: Quiz's queues dedupe nothing, #273; the PUT is
idempotent), its last outcome on codespace_projects with the staff's
Resync (POST …/workspace/sync); the start route was
GET /app/codespace/start/:projectId (a POST since 2026-10-11, audit L7) (the portal's classroomStartUrl
already builds that path), loaded through the classroom's student branch
with a claimed seat and the caller's own portal session — an
impersonation, a request carrying a Bearer token: the 404; a seb or kiosk session is
anonymous there (ADR-027's default deny) until M6-07 —; the token's jti
is audited (codespace.launch_issued), the token never; the decision is the pure
workspaceStartRefusal (@quiz/domain). The staff read the project's
workspaces through GET …/workspace/sessions, named by Quiz for the
classroom's students and by nobody otherwise (the portal's address of an
unmatched account is not sent).
Seeding, while the portal's forge was off (settled by ADR-078: Quiz issues the portal an installation token for one repository) (M6-03 amendment (a)): the
workspace is seeded from the project's distribution repository, which the
portal clones anonymously. A PUBLIC distribution repository seeds it; a
private one (Quiz's default) syncs, but cannot seed a workspace, until the
decision on Quiz's App on the engine VM (M6-04/M6-05).
M6-07 (2026-10-07): Safe Exam Browser for a project¶
D21 points 2–5. Scope: amendment "M6-06" (A)'s online_seb clauses and point 7.
Quiz builds the project's .seb (GET /app/api/projects/:id/seb, a
claimed seat of a published online_seb project); its start URL is Quiz's
one-time ticket (no second sign-in), its URL filter adds the portal's host
and SEB_EXTRA_ALLOWED_HOSTS. The ticket opens a seb session confined to
the project (ADR-027 addendum "M6-07"); from it, and from it only, the
start route mints the launch token with the seb claim, the session's
Config Key (seb_required otherwise). The portal's /launch in exam mode
refuses a token without the claim and checks SEB's header against it,
then the Browser Exam Keys when the project has some, then sets its
IP-bound exam_session. Point 7 as amended: the Browser Exam Keys are
optional on the portal (an empty list is the Config Key alone), and
Quiz sends none: BEK list: after proof B step 7 (per-student .seb
likely gives per-student BEKs) — SEB's BEK covers the configuration,
which is per student here (06 §6.3). online_seb is synced like
online. The portal builds no .seb any more (its /exam/:id.seb,
Config Key and salt are gone).
2026-10-08: an administrator always holds the grant¶
Product owner. Scope: amendment "M6-06" (B)'s last sentence, and (C)
for an administrator. An account whose role is admin (users.role, the
role rule's SUPER_ADMIN_EMAIL, whether or not a Super Powers session is
active) is granted with at least the default quota
(DEFAULT_MAX_ACTIVE_SESSIONS, 2), the most permissive of that and any
row its addresses hold. grantOf (modules/codespace/service.ts) is the
one place that says so, so the mode switch, the staff's view and the quota
sent to the portal (an administrator holding the quota as creator or
oldest owner) give one answer. The owner check is unchanged: an
administrator sets a mode on a course where they hold an owner seat, or
under Super Powers (ADR-054). The administration lists no grant row for
them and needs no switch.
Note 2026-11-16: this last sentence is overridden by the
amendment of 2026-11-16:
the administrator's address may hold a row, for its quota.
2026-11-16: the administrator's quota on a grant row¶
Product owner. Scope: the last sentence of the 2026-10-08 amendment
above, and the is_admin refusal of POST /app/api/admin/teachers.
The administrator was the quota holder of an online project with 27
students, at the default quota of 2, and nothing in the product could
raise it: the administration refused their address and listed no row for
them.
- The administrator's address may hold a
teacher_grantsrow, created by the same Grant form (Autoriser). The role rule putsadminfirst, so the row neither raises nor lowers the role, and revoking it leaves the accountadmin. - The quota is the row's when it is higher than the default, never
lower:
grantOfalready takes the most permissive of the administrator's default and the rows of their verified addresses. - The switch has no effect for them: their workspace is always on. The
teachers list marks the row of
SUPER_ADMIN_EMAILas the administrator's (AdminTeacher.admin,isSuperAdminEmailof the role rule) and reports it enabled; the screen shows that switch on and disabled, saying why, andPATCH …/codespacerefuses anenabledon such a row (409 is_admin), so the server never stores nor answers a state the screen does not show. The quota field works as for anyone.
No migration, table nor setting. There is one administrator
(SUPER_ADMIN_EMAIL), so no administrator edits another's row. A row
outlives a change of SUPER_ADMIN_EMAIL: it then becomes an ordinary
teacher grant, visible and revocable in the list.
2026-10-11: the start route is a POST¶
Security audit L7. Scope: the start route of amendment "M6-06" (its path and method) and
M6-07's launch from a seb session. A navigable GET that froze the work
mode and minted a launch token could be triggered by a cross-site link.
The launch is now POST /app/api/projects/:projectId/workspace/start,
under the double-submit CSRF check of every session write; same access
rule (the caller's own portal session or the project's seb session, the
student branch with a claimed seat, the 404 otherwise; an impersonation
writes nothing, 403), same refusals as 409 { error } (the project page
shows them as ?workspace=<code>), and it answers { url }, the portal's
/launch?token=…, Cache-Control: no-store, which the page navigates to.
The portal is unchanged: it never linked to the old path. ADR-089's
station launch was already a POST.
Amendment 2026-10-11: one origin for every session (audit L24)¶
Scope: what the portal lets a session serve on its origin, shared by every
session (/s/<session>/). Decided by the product owner on 2026-10-11 (the
short fix):
- code-server runs with
--disable-proxy, and the portal refuses/s/<session>/proxy/<port>/and…/absproxy/<port>/itself (403). - The portal drops
Set-CookieandService-Worker-Allowedfrom every answer of code-server. - The portal serves
/vscode-remote-resourcewithContent-Security-Policy: default-src 'none'; sandboxandX-Content-Type-Options: nosniff. - The student image ships no notebook support: code-server's bundled
ipynbandnotebook-renderersextensions are deleted at build time (the orchestrator's decision of the same day, on the owner's authority).
Rationale: every session shares one origin, so what a session serves must
not be able to act on that origin; the port proxy is not used by the
product. VS Code 1.137 already sends rule 3's headers, so the workbench is
known to work with them (verified in Chromium through a real portal).
Rule 4 removes notebook rendering from the student image (an .ipynb
opens only as text; verified in Chromium).
Known gaps remain, closed only by a subdomain per session (each session
its own origin, a wildcard certificate); details: operator notes
(internal). An image that must serve a web application waits for that fix.
Amendment 2026-11-14: the staff's review session (ADR-129)¶
Scope: the premise of the amendment of 2026-10-11 (audit L24) above, M6-06 (C) (whose quota a session consumes) and M6-03 (b) ("every portal account is a student"). ADR-129 owns the rule (product owner, 2026-11-14).
- The L24 premise no longer holds for a review. A student's workspace is loaded in that student's own browser; a review session loads a student's repository in a staff member's browser, beside any other portal session open there. Decision: at most one live review session per staff member, and the residual risk to the staff member's own sessions open in that browser accepted in writing (ADR-129 §1, §9). The subdomain per session stays the full fix (06, question 70).
- Quota (M6-06 (C)). A review session counts against the project's quota holder like a student's, with at most two live review sessions per holder; no review without the holder's enabled grant (ADR-129 §3).
- Accounts (M6-03 (b)). A staff member's portal account is born from a review launch token, with no role, like a student's; its review sessions are never listed among a project's workspaces (ADR-129 §10).