Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Every skill action maps to a `reg-*` CLI command. An agent performing any Lecter
| Run item analysis from Gradescope evaluations | `reg-gradescope-stats` | `gradescope_stats` |
| Normalize Canvas grades export | `reg-lms-grades-import` | `lms_grades` |
| Normalize CSULB enrollment roster | `reg-lms-roster-import` | `lms_roster` |
| Canvas API: export/push grades, roster check, post announcements, discussions, assignments, syllabus | `reg-canvas` | `canvas` (client: `canvas_api`) |
| Pre-seed GitHub Classroom roster | `reg-classroom-roster-seed` | `classroom_seed` |
| Bind student GitHub IDs to roster entries | `reg-github-bind` | `github_bind` |
| Publish ISA grading artifacts to Drive | `reg-isa-publish` | `isa_publish` |
Expand All @@ -43,6 +44,8 @@ releases. `reg-exam-readinglist` is installed as a standalone `~/bin` wrapper (n
- All commands accept `--vault-root <path>` to locate vault notes. Pass it explicitly; never rely on a hard-coded default.
- Prefer `--dry-run` on `reg-term-finalize` before committing; the agent should surface the preview output for review.
- `reg-term-archive --check` exits 0 on a clean bundle and nonzero on drift — use the exit code as a quality gate.
- **`reg-canvas` writes are dry runs until `--apply`.** Show the dry run first. An agent never passes `--apply` to a live section (announcements notify students at once; grades are visible once posted) without the instructor's go-ahead for that specific run. Test against the sandbox course with `--course-id`.
- **Never read the Canvas token file** (`~/.config/lectern/canvas-token`). The client reads it; nothing else needs to.
- All state lives in plain files (Markdown · CSV · YAML · LaTeX) — the agent can read and diff these directly.

## Skill file
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ All notable changes to lectern are documented here.
## [Unreleased]

### Added
- **`reg-canvas`: Canvas API support.** CSULB ATS issued a personal Canvas token on 2026-10-21. Until then lectern had no Canvas integration, and every Canvas step was a manual export, upload or paste. The new `canvas_api` module is the only code that touches the token. It reads the token from `~/.config/lectern/canvas-token` and refuses a file that group or other can read. It never takes the token from argv or the environment, sends it only to the configured host, refuses redirects (urllib would forward the `Authorization` header to the redirect's host), and scrubs it from every error. It uses only the standard library, so lectern's runtime dependencies do not change. `reg-canvas` puts nine subcommands on top of it. The read commands are `whoami`, `courses` (`--bind` writes `canvas.course-id` into each class note, using the term name when a class number recurs across years), `grades-export` and `roster-check` (Canvas compared with the registrar roster, for census week). `grades-export` writes the same CSV that Canvas's *Export* button does, so `reg-lms-grades-import` and `reg-gradebook export-canvas --template` take it unchanged; the per-group subtotal columns are the one difference, and nothing reads them. The write commands are `grades-push`, `announce`, `discussion`, `assignment` and `syllabus`, and each is a dry run until `--apply`. `grades-push` applies an overlay CSV, changed cells only. A blank cell never clears a grade, and a file whose assignment IDs belong to another course is refused. `discussion` and `assignment` create items unpublished, `assignment --lab N` takes its name and points from the vault, `syllabus` refuses a file without the class note's serial, and all three content commands skip a title that already exists. Data scope is what was promised to CSULB IT: names, student IDs and grades for the instructor's own sections. Scores come from the submissions endpoint, but only score fields are kept and submission content is dropped on arrival. Exports are written mode 600. Live-checked on 2026-10-21 against the three Fa26 sections (reads) and the sandbox course (an unpublished discussion and assignment, since deleted). Runbook: `docs/canvas-api.md`, which opens with how the pieces fit and ends with troubleshooting. The README (intro, command table, architecture, dependencies, an optional quickstart), `SKILL.md`, `AGENTS.md` and `docs/canvas-grades-workflow.md` all describe the API path, and each repeats that writes are dry runs until `--apply`.
- **`reg-exam-build` writes a per-outcome `GRADING_NOTE.md` for every Gradescope build.** The note was a one-line-per-question summary table, which left the grader to invent the Gradescope rubric. It is now the ISA work order: every question gets one rubric row per possible outcome (each MC choice, both T/F sides, each FIB blank plus a wrong-order row, and every item of an authored `Gradescope rubric` block on written questions), with the points that row carries and a stable `form·Qn·slot` key. Graders enter the rows verbatim and only choose which one applies, so points land the same way whoever grades, and `reg-gradescope-stats` reads the note directly. Graduated from the CECS 378 Su26 prototype (`build_grading_note.py`) into `lectern.grading_note`, with two fixes on the way: a code question keyed True/False no longer loses its credit to a trailing brace, and math in choices renders as `2^(n/2)` rather than `2^{n/2`. `% order: any` before a multi-blank fill drops the wrong-order row. New **`--grading-note-only`** rewrites just the note for an exam that is already printed.
- **`reg-guardcheck`: the student's half of the guard-file check.** The instructor-side check reads git history from outside the student's control and is the record; this is the notice the *student* sees, in the CI run they already look at. `stamp` records a template's expected digests to `grading/guard.sha256` (`sha256sum`-format, so `sha256sum -c` verifies it with no tooling); `check` runs as one step in the lab's own `autograde.yml` and reports what changed. ==It notifies, it never grades==: no points, no pass/fail, and it always exits 0 (`--strict` opts out) because failing a student's build over a file that does not affect their program is a bad way to open a conversation. It never invents a `result.json` either, since a result file conjured from nothing reads downstream as a zero-point run; it only records a `notices` array in one that already exists. The message is deliberately unaccusing: what changed, that it does not affect the assignment or the grade, that the instructor sees it in the history, and the `git checkout` line that restores it, plus a GitHub Actions run annotation. Stdlib-only, so a template vendors the single file as `grading/guardcheck.py` and the runner's bare `python3` runs it. Workflow snippet at `lectern/references/guardcheck.workflow.yml`. ==A student controls their own workflow, so this is a courtesy and not evidence==: the sweep is what counts.
- **Guard-file integrity: grading checks for repos that modify `AGENTS.md`.** Every lab template ships `AGENTS.md`, the high-authority AI-assistant surface, and the doctrine has always been that a student may delete it because doing so is a visible act in the git history. Nothing actually looked. The new `lectern.triage_guardfile` module compares each declared **guard file** at the grading commit against its baseline and reports `intact`, `modified`, `deleted` or `absent`, with the commits that touched it and a copy-pasteable reproduce command. Wired into all three surfaces: `reg-triage sweep` (a `guard` column in `results.csv`, a Guard column and a *Guard files* roll-up in `TRIAGE.md`), `reg-triage report` (section **A.6 Guard-file integrity**), and `reg-lab-recon` (a `guard` column in `cohort.csv`, a *Guard files* section in `FACTS.md`). Both manifests take `guard_files:`, defaulting to `["AGENTS.md"]`; an entry may be `{path, sha256}` to compare against the file **as distributed**, which is the only way to catch an edit made inside a squashed initial commit. Otherwise the baseline is the file's first appearance in that repo, and a file born modified reads as intact. ==It is a Part A fact and never a score==: `guardfile_forensics` does not register in `SIGNALS`, awards no points, and cannot move a bucket, because there are innocuous reasons to touch these files and the engine's standing rule is that no adverse finding is automated. Report schema bumped to v2; the signal set is unchanged.
Expand Down
32 changes: 28 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

**The Registrar** — a 100% open-source teaching-operations toolkit for university instructors.

Lectern handles the full administrative lifecycle of running courses: term scaffolding, gradebook consolidation, exam build and verification, ISA grading artifact publishing, GitHub Classroom binding, campus-LMS (Canvas) roster/grade import, and end-of-term archival. All state lives in plain, version-controllable files. All tools are scriptable CLI commands in the `reg-*` family.
Lectern handles the full administrative lifecycle of running courses: term scaffolding, gradebook consolidation, exam build and verification, ISA grading artifact publishing, GitHub Classroom binding, campus-LMS (Canvas) integration, and end-of-term archival. With a Canvas API token, Lectern exports the gradebook, pushes grades back, checks the roster, and posts announcements, discussions, assignments and the syllabus; without one, the same records move through Canvas's CSV export and import. All state lives in plain, version-controllable files. All tools are scriptable CLI commands in the `reg-*` family.

---

Expand All @@ -22,7 +22,7 @@ ways: driven by an AI agent (Claude Code skill) *or* run directly by a human via

| Tool | Role | Repo |
|---|---|---|
| **[Lectern](https://github.com/agiacalone/lectern)** — the Registrar | Course **administration** — terms, sections, gradebook, exam build/verify, Classroom binding, archival. | `agiacalone/lectern` |
| **[Lectern](https://github.com/agiacalone/lectern)** — the Registrar | Course **administration** — terms, sections, gradebook, exam build/verify, Classroom binding, Canvas sync, archival. | `agiacalone/lectern` |
| **[Scriptorium](https://github.com/agiacalone/scriptorium)** — the workshop | Course **content** — lecture notes, Cornell handouts, quizzes, slides, question banks. | `agiacalone/scriptorium` |
| **[Oracle](https://github.com/agiacalone/oracle)** *(private)* — the secret box | **Grading** — a verify-by-proof oracle service + a sandboxed code-runner (gradebox). | `agiacalone/oracle` *(private — licensed)* |

Expand Down Expand Up @@ -70,6 +70,7 @@ This is a deliberate design principle, not an accident. Proprietary LMS gradeboo
| `reg-exam-build` | `exam_build` | Assemble exam PDFs — single-source `.tex` mode or pack-mode `.yaml` manifest (multi-form A/B/C, per-student individualized, Gradescope products). See below. |
| `reg-exam-verify` | `exam_verify` | Verify a student exam serial against the register. Confirms which form and which student a paper belongs to. |
| `reg-lms-grades-import` | `lms_grades` | Normalize a Canvas `grades.csv` export to Lectern's canonical format. |
| `reg-canvas` | `canvas` + `canvas_api` | **Canvas API.** Reads: `whoami`, `courses` (`--bind` links each section to its Canvas course in the class note), `grades-export` (the gradebook in Canvas's own export layout, so `reg-lms-grades-import` and `reg-gradebook export-canvas --template` take it unchanged), `roster-check` (Canvas compared with the registrar roster). Writes, each a **dry run until `--apply`**: `grades-push` (an overlay CSV, changed cells only; a blank never clears a grade), `announce`, `discussion` and `assignment` (both unpublished by default), and `syllabus` (refuses a file without its serial). The token lives in one mode-600 file and is sent to one host. See [docs/canvas-api.md](docs/canvas-api.md). |
| `reg-lms-roster-import` | `lms_roster` | Normalize a faculty-center enrollment roster (`.xls`/`.xlsx`) to Lectern's canonical format. |
| `reg-classroom-roster-seed` | `classroom_seed` | Pre-seed a GitHub Classroom roster from a normalized roster CSV, using the 9-digit student ID as the identifier. |
| `reg-github-bind` | `github_bind` | Bind student GitHub usernames to roster entries — from a Google Form CSV, a GitHub Classroom roster CSV, or org-scrape mode. |
Expand Down Expand Up @@ -139,6 +140,8 @@ lectern/
exam_verify.py register-based serial verification
lms_grades.py Canvas grades CSV normalization
lms_roster.py enrollment roster normalization (.xls → .csv)
canvas_api.py Canvas REST client: the only module that reads the token
canvas.py reg-canvas: gradebook export/push, roster check, content posting
classroom_seed.py GitHub Classroom roster pre-seeding
github_bind.py student-id → GitHub username binding
isa_publish.py Drive publishing (rclone/service-account backend)
Expand Down Expand Up @@ -174,7 +177,7 @@ See `docs/design/lab-digest.md` and `docs/design/lab-report.md` for the contract

**Vault awareness.** Most commands accept `--vault-root <path>` to locate course notes, class notes, and archive bundles relative to a notes root. If you do not use a notes-based workflow, pass explicit `--vault-root .` or use the modules as a library with fully explicit paths. The vault path is never hard-coded.

**Dependencies.** Python 3.11+. `pyyaml`, `jsonschema`. LaTeX toolchain (`pdflatex`, `pdfunite` or `qpdf`) for exam builds. `rclone` or a service-account credential for ISA publish. *Optional for `reg-exam-verify`:* `pdfplumber` (else falls back to the `pdftotext` CLI). The former `vaultkit` dependency was removed — the one helper used (`slugify`) is vendored into `lectern/_text.py` (the PyPI name `vaultkit` is an unrelated third-party package, so depending on it was a dependency-confusion risk).
**Dependencies.** Python 3.11+. `pyyaml`, `jsonschema`. The Canvas API client uses only the standard library; it needs a personal Canvas token, and `pandoc` to turn Markdown into Canvas HTML. LaTeX toolchain (`pdflatex`, `pdfunite` or `qpdf`) for exam builds. `rclone` or a service-account credential for ISA publish. *Optional for `reg-exam-verify`:* `pdfplumber` (else falls back to the `pdftotext` CLI). The former `vaultkit` dependency was removed — the one helper used (`slugify`) is vendored into `lectern/_text.py` (the PyPI name `vaultkit` is an unrelated third-party package, so depending on it was a dependency-confusion risk).

---

Expand Down Expand Up @@ -206,6 +209,26 @@ reg-term-create --help
reg-exam-build --help
```

### Canvas API (optional)

Everything above works without Canvas access. To let Lectern talk to Canvas
directly, store a personal token and link each section to its course:

```bash
mkdir -p ~/.config/lectern && chmod 700 ~/.config/lectern
( umask 077; read -rsp "Canvas token: " t; echo; printf '%s\n' "$t" > ~/.config/lectern/canvas-token )
reg-canvas whoami
reg-canvas courses --bind --term fa26 --vault-root <V>
reg-canvas grades-export --term fa26 --vault-root <V> --import
```

> [!CAUTION]
> Every `reg-canvas` write is a dry run until you add `--apply`. Read the dry
> run first: announcements notify students as soon as they post.

The full guide, including token activation and troubleshooting, is
[docs/canvas-api.md](docs/canvas-api.md).

### Minimal exam build (single form)

```bash
Expand Down Expand Up @@ -275,7 +298,7 @@ Lectern addresses several standardized-infrastructure concerns directly:

**Autograding integration.** Code and lab autograding is performed by **[Oracle](https://github.com/agiacalone/oracle)** — a verify-by-proof oracle service paired with a sandboxed `gradebox` runner. Lectern *coordinates and records* the results: the archive bundle's `manifest.yaml` tracks template repo commits and lab names alongside exam serials and grade distributions, and ISA-published artifacts (keys, rubrics) live in a structured Drive folder matching the term/section/course hierarchy so graders can always find the authoritative rubric for a given assignment. (MC-bubble and Gradescope exam autograding are Lectern's own — see [`docs/gradescope-workflow.md`](docs/gradescope-workflow.md).)

**Gradebook as data.** `reg-gradebook` produces `gradebook.csv` — a plain CSV that is the canonical, diff-able record of every student's grades. It is never the sole copy: Canvas is the student-facing authority, the archive bundle is the institutional record, and the CSV is the analytical layer that enables DFW rollups, section-to-section comparisons, and grade-appeal lookups from the command line.
**Gradebook as data.** `reg-gradebook` produces `gradebook.csv` — a plain CSV that is the canonical, diff-able record of every student's grades. It is never the sole copy: Canvas is the student-facing authority (grades reach it through `reg-canvas grades-push`, or a CSV import without a token), the archive bundle is the institutional record, and the CSV is the analytical layer that enables DFW rollups, section-to-section comparisons, and grade-appeal lookups from the command line.

---

Expand All @@ -286,6 +309,7 @@ Lectern addresses several standardized-infrastructure concerns directly:
| [docs/README.md](docs/README.md) | Documentation index |
| [docs/design/exam-system.md](docs/design/exam-system.md) | Multi-form exam system design: A/B variants, individualized builds, Gradescope products, defensibility |
| [docs/design/exam-tex-format.md](docs/design/exam-tex-format.md) | House `.tex` format: header block, answer key toggle, per-student serials, color conventions, appeals runbook |
| [docs/canvas-api.md](docs/canvas-api.md) | `reg-canvas`: token setup, the read and write commands, data scope, and the safety rules |
| [docs/gradescope-workflow.md](docs/gradescope-workflow.md) | Using Lectern-built exams with Gradescope: region/bubble, A/B Version Sets, roster, identity verification |

---
Expand Down
Loading
Loading