Module site

Module site 

Source
Expand description

Static-site assembly: turn a course into a browser-deployable lesson site.

core::site owns assembly only (ADR-0008, §4.1): it decides which files a site contains and their contents, and commits them to disk. It does not call LLMs or execute learner code — that happens in the browser at learner time, via the runtime the emitted assets boot (webR / Pyodide).

The split (§2.1, §2.3): plan_site is pure — given the loaded lessons and a BuildTarget it returns the SiteFiles (relative paths + contents), with no filesystem touch, so a whole site is snapshot-testable. write_site is the single effectful step. The SiteLesson JSON is the contract between Rust (author side) and the JS runtime (learner side): a Rust-side change that keeps the JSON shape leaves the runtime untouched (§3.2).

Structs§

EmbeddedKey
An API key embedded in an encrypted site payload (§1.2 — a represented state, not a loose string). When present, the key rides inside the AES-256-GCM-encrypted index.html payload as a JSON object {"html":"...","embeddedKey":{"provider":"...","key":"..."}}. The decrypt shell extracts it and sets window.__btEmbeddedKey before the page renders, so feedback.js’s applyEmbeddedKey can pre-load it into sessionStorage — skipping the key-entry prompt.
SiteFile
One file in a planned site: a path relative to the output root and its contents — the unit write_site commits to disk.
SiteFiles
A fully planned site: every file it comprises, in a deterministic order.
SiteLesson
One lesson as the in-browser runner consumes it: the Rust↔JS JSON contract (ADR-0008, §3.2).

Enums§

BuildTarget
Which browser runtime a built site targets, and so which language it serves.
EvalReportError
A course’s bundled eval report could not be read as the Slice-13 JSON artifact.
EvalSummary
Whether a built site’s lessons carry eval validation, and at what accuracy.
PlanError
Why a site could not be planned.

Functions§

encrypt_site_files
Encrypt all content files in a planned site, replacing them with decrypt shells (for HTML pages) or base64-encoded encrypted payloads (for JSON files).
eval_summary_from_report_json
Fold a Slice-13 eval report’s JSON into the page model, taking its accuracy as-is (§3.2) — the figure the eval command recorded, never recomputed here.
plan_site
Plan the static site for lessons, targeting target, folding in the eval validation eval carries.
write_site
Write a planned site to out_dir, creating parent directories as needed.