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
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,23 @@ Format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).

## [Unreleased]

### Added
- **Fact sheets for case studies (`--artifact fact-sheet`).** A one-page,
student-facing reference card per named case study (a botnet, a breach, an
outage): a facts table, grouped bullets such as removal and prevention steps,
and a linked *Sources* line. The Cornell handout teaches a case and withholds
part of it; the fact sheet is what a student keeps afterwards. Facts are a new
role tag in the lecture main, `#fact [case:: Name]`, with `[label::]` for a table
row or `[group::]` for a bullet (`#steps` numbers a group). A `#case-study` with
the same `[case::]` supplies the opening paragraph. A fact without `[case::]` is
a hard error, and one inside a numbered section is a warning, since facts live
under an unnumbered `## Fact sheet: <case>` heading that section-walking artifacts
never read. The sheet is skipped, with no file written, when a lecture has no
facts, so `all` is unchanged for every existing lecture. First built for Mirai in
CECS 378's Denial of Service lecture, from the CISA alert TA16-288A. The PDF is
tagged; veraPDF's PDF/UA-1 check reports one advisory rule (7.1-3), from the shared
preamble rather than the table, like the lecture notes' remaining finding.

### Fixed
- **Links in LaTeX handouts.** A Markdown link (`[OSTEP](https://…)`) printed as
raw Markdown, and a vault wikilink (`[[note|alias]]`) leaked into a Cornell case-study
Expand Down
2 changes: 2 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ priors, but the formats split into two tiers:
- `<topic>_cornell_handout.pdf` (student) + `<topic>_cornell_handout_key.pdf` (instructor answer key — never distribute)
- `<topic>_study_questions.md` (student review)
- `<topic>_quiz.pdf` + `<topic>_quiz_key.pdf`
- `<topic>_fact_sheet.pdf` (student reference, one page per case study)
- `<topic>_slides.md` (Slidev) — render/export with the `slides:dev` / `slides:build` scripts
- `README.md` (GitHub Classroom)
- (exams are no longer produced here — built by lectern's `reg-exam-build` from the
Expand Down Expand Up @@ -142,6 +143,7 @@ assembly draws from, and the per-exam *reading-list* study guide.
| `[topic]_quiz.pdf` + `[topic]_quiz_key.pdf` | Pop quiz | 5 questions (~10 min), MC+short answer, separate key PDF; `.tex` retained |
| `[topic]_question_bank.md` | Question bank | ~50 tagged questions (mc/tf/code/fib/sa · ★/★★/★★★ · subtopic); source of truth for exam assembly (in lectern) |
| `[topic]_reading_list.md` *or* `[scope]_reading_list.md` | Reading-list companion | Hybrid scaffold paired 1:1 (or 1:N) with Cornell handout(s). Generator emits cue-table rows inside `<!-- generator: cue-tables -->` … `<!-- /generator -->`; manual content (curated primary sources, References, instructor notes) outside the fence is preserved on regen. |
| `[topic]_fact_sheet.pdf` | Case-study fact sheet | One student-facing page per case, from `#fact [case::]` items under an unnumbered heading; facts table + grouped bullets + Sources; skipped when there are no facts; `.tex` retained |
| `README.md` | GitHub Classroom README | Rigid boilerplate — copy structure exactly |
| `[topic]_slides.md` | Slide deck (Slidev) | 14–18 slides; render live or export via the `slides:dev` / `slides:build` scripts. *(Slide styling is mid-migration — the Beamer-era palette notes below are being reworked.)* |

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,10 @@ Run against the bundled sample (`examples/file_systems_abstraction_lecture_main.
| Slide deck | `slides` | `.md` (Slidev) | no |
| GitHub Classroom README | `readme` | `.md` | no |
| Reading-list companion | `reading-list` | `.md` | no |
| Case-study fact sheet | `fact-sheet` | `.tex` → `.pdf` | yes |
| Consistency audit | `audit` | console report | no |

Printed artifacts (`lecture-notes`, `cornell`, `quiz`) compile to PDF with
Printed artifacts (`lecture-notes`, `cornell`, `quiz`, `fact-sheet`) compile to PDF with
`pdflatex`. Pass `--no-pdf` to emit the `.tex` and skip compilation if you don't have
a LaTeX toolchain installed. The slide deck is Slidev Markdown — preview it live with
`npm run slides:dev` or export with `npm run slides:build`.
Expand Down
5 changes: 5 additions & 0 deletions SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ These fields live in the YAML frontmatter and `#meta` section of the
| Pop quiz | `[topic]_quiz.pdf` + `[topic]_quiz_key.pdf` (`.tex` retained) | 5-question in-class quiz with separate instructor answer-key PDF |
| Question bank | `[topic]_question_bank.md` | ~50 tagged questions (mc/tf/code/fib/sa), scoped to full topic (2–4 sessions) |
| Reading-list companion | `[topic]_reading_list.md` (single topic) or `[scope]_reading_list.md` (multi-topic, e.g. `final_third_reading_list.md`) | Hybrid scaffold paired 1:1 (or 1:N) with Cornell handout(s); the generator emits a `<!-- generator: cue-tables -->` … `<!-- /generator -->` fence with cue-to-source rows; manual content outside the fence is preserved on regen. Can also serve as a pre-exam review deliverable. |
| Fact sheet | `[topic]_fact_sheet.pdf` (`.tex` retained) | One student-facing reference page per case study, from `#fact` items under an unnumbered `## Fact sheet: <case>` heading. Withholds nothing (unlike the Cornell handout). Skipped when the lecture has no facts. |
| GitHub README | `README.md` | GitHub Classroom assignment (reading or lab/programming variant) |
| Slide deck | `[topic]_slides.md` (Slidev markdown) | 14–18 slides. Theme auto-selected from `course:` frontmatter: **blueprint** (CECS 326, 378) or **terminal** (CECS 478); default blueprint. Present live via `npx slidev [topic]_slides.md` — no PDF export (slides are a presentation artifact, not a distributed document). |

Expand Down Expand Up @@ -181,6 +182,7 @@ generators/
slides.js # → [topic]_slides.md (Slidev markdown)
question-bank.js # → [topic]_question_bank.md
reading-list.js # → [topic]_reading_list.md (fenced scaffold; manual content preserved)
fact-sheet.js # → [topic]_fact_sheet.tex + .pdf (one page per #fact case)
archive/
spec-driven-2025/ # historical: init-spec.js + lecture-spec.json (do not author new specs)
```
Expand All @@ -198,6 +200,7 @@ node generate.js --main /mnt/es1/anthony/obsidian/vault/classes/326/file_systems
node generate.js --main path/to/topic_lecture_main.md --artifact slides
node generate.js --main path/to/topic_lecture_main.md --artifact bank
node generate.js --main path/to/topic_lecture_main.md --artifact reading-list
node generate.js --main path/to/topic_lecture_main.md --artifact fact-sheet

# Override output directory and skip pdflatex
node generate.js --main path/to/topic_lecture_main.md --out ./out --no-pdf
Expand Down Expand Up @@ -334,6 +337,7 @@ cryptography_quiz_key.pdf
cryptography_question_bank.md
cryptography_slides.md
cryptography_reading_list.md
cryptography_fact_sheet.pdf # one page per case study
README.md

# Reading-list companion (multi-topic — covers a unit or final third):
Expand All @@ -356,6 +360,7 @@ rules. In particular, check it for:
- quiz timing, answer-key format, and question constraints
- question-bank schema, numbering, dedupe, and tagging
- reading-list companion frontmatter, callouts, cue-table format, and References discipline
- fact-sheet source schema (`#fact`, `[case::]`, `[label::]`, `[group::]`, `#steps`) and content rules
- GitHub README boilerplate and Markdown rules
- Slidev theme palettes (blueprint / terminal), layout mapping, `<Schematic>` and `<EventChain>` components, and standard deck structure
- ADA Title II compliance: `[alt::]` requirement on `#diagram` and diagram slide layouts; color-and-glyph pairing on Cornell sections; tagged-PDF preference
16 changes: 16 additions & 0 deletions generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { generateStudyQuestions } from './generators/study-questions.js';
import { generateQuiz } from './generators/quiz.js';
import { generateReadingList } from './generators/reading-list.js';
import { generateReadme } from './generators/readme.js';
import { generateFactSheet } from './generators/fact-sheet.js';
import { generateAudit } from './generators/audit.js';
import { markUsedTags } from './generators/mark-used.js';

Expand All @@ -46,6 +47,7 @@ const ARTIFACTS = new Set([
'quiz',
'reading-list',
'readme',
'fact-sheet',
]);

const ARTIFACT_ALIASES = {
Expand All @@ -67,6 +69,7 @@ Artifacts (--artifact):
quiz
reading-list
readme
fact-sheet one page per case study, from #fact items (skipped when there are none)

Flags:
--main <path> path to <topic>_lecture_main.md
Expand Down Expand Up @@ -340,6 +343,18 @@ async function runArtifact({ artifact, parsed, slug, outDir, log, opts }) {
log.info(`✓ readme (${variant}) → ${path.basename(out)}`);
return;
}
case 'fact-sheet': {
const { tex, cases } = generateFactSheet(parsed, { ...filterOpts });
if (!tex) {
log.info('· fact-sheet skipped (no #fact items)');
return;
}
const out = path.join(outDir, `${slug}_fact_sheet.tex`);
writeText(out, tex);
log.info(`✓ fact-sheet → ${path.basename(out)} (${cases.join(', ')})`);
maybeCompile(out, outDir, log, opts.noPdf);
return;
}
default:
throw new Error(`unhandled artifact: ${artifact}`);
}
Expand All @@ -354,6 +369,7 @@ const ALL_ARTIFACTS = [
'quiz',
'reading-list',
'readme',
'fact-sheet',
];

async function runMain(args) {
Expand Down
138 changes: 138 additions & 0 deletions generators/fact-sheet.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
// Fact sheet: a one-page, student-facing reference card for each named case
// study in a lecture (a botnet, a breach, an outage). Unlike the Cornell
// handout it withholds nothing: it is the "what happened, when, how big, what
// to do about it" summary a student keeps after the case has been taught.
//
// Source schema (see references/style-guide.md § Fact Sheet):
// #fact [case:: Mirai] [label:: Discovered] August 2016
// → a row in that case's facts table (label | text)
// #fact [case:: Mirai] [group:: Preventing infection] Change every default password.
// → a bullet under that group's heading; add #steps to any item in the
// group to number the whole group
// #case-study [case:: Mirai] … → the case's opening paragraph (first one wins)
// [citation:: …] on any of them → the case's Sources line, linked the same way
// the exam reference sheet links them
//
// One case per page, in the order each case first appears in the source.
// #draft items are skipped, and the --semester / --strict-semester filters apply.

import { createRequire } from 'node:module';
import { applyTermFilter } from './_filter.js';
import { renderCitation, citationUrlMap } from './exam-reference-sheet.js';
const require = createRequire(import.meta.url);
const { texPreamble, texEscape, texDocHeader } = require('../lib/tex-helpers.js');

const DEFAULT_GROUP = 'Key points';

function field(item, k) {
return (item.fields && item.fields.get && item.fields.get(k)) || '';
}

function live(items, opts) {
return applyTermFilter(items || [], opts).filter((it) => !it.tags.has('draft'));
}

// Group the #fact items by [case::], keeping source order for cases, rows and
// groups alike. Items without a case are left to the validator, which rejects them.
export function collectCases(parsed, opts = {}) {
const facts = live(parsed.byRole.get('fact'), opts)
.slice().sort((a, b) => (a.sourceLine || 0) - (b.sourceLine || 0));
const cases = new Map();
for (const f of facts) {
const name = field(f, 'case').trim();
if (!name) continue;
if (!cases.has(name)) cases.set(name, { name, intro: null, rows: [], groups: new Map(), cites: [] });
const c = cases.get(name);
const label = field(f, 'label').trim();
if (label) {
c.rows.push({ label, text: f.text });
} else {
const g = field(f, 'group').trim() || DEFAULT_GROUP;
if (!c.groups.has(g)) c.groups.set(g, { items: [], numbered: false });
const grp = c.groups.get(g);
grp.items.push(f.text);
if (f.tags.has('steps')) grp.numbered = true;
}
if (field(f, 'citation')) c.cites.push(field(f, 'citation'));
}
for (const cs of live(parsed.byRole.get('case-study'), opts)) {
const c = cases.get(field(cs, 'case').trim());
if (c && !c.intro) {
c.intro = cs.text;
if (field(cs, 'citation')) c.cites.unshift(field(cs, 'citation'));
}
}
return [...cases.values()];
}

function sourcesLine(cites, citeOpts) {
const seen = new Map();
for (const raw of cites) {
for (const part of String(raw).split(/\s*;\s*/)) {
const r = renderCitation(part, citeOpts);
if (r && !seen.has(r.key)) seen.set(r.key, r.md);
}
}
return [...seen.values()].join(' · ');
}

function factsTable(rows) {
if (!rows.length) return '';
// \textcolor, not {\color …}: a \color switch at the start of a p{} cell
// opens an empty line and drops the label below its detail.
const body = rows
.map((r) => `\\textcolor{instrNavy}{\\textbf{${texEscape(r.label)}}} & ${texEscape(r.text)} \\\\\\hline`)
.join('\n');
// Header row tagged /TH for PDF/UA (same group-scoped directive as texComparisonTable).
return `
{\\tagpdfsetup{table/header-rows={1}}\\renewcommand{\\arraystretch}{1.3}%
\\noindent\\begin{tabularx}{\\linewidth}{|p{0.24\\linewidth}|X|}
\\hline
\\rowcolor{instrNavy}
\\textcolor{white}{\\textbf{Fact}} & \\textcolor{white}{\\textbf{Detail}} \\\\\\hline
${body}
\\end{tabularx}}
\\vspace{6pt}
`;
}

function groupBlock(name, grp) {
const env = grp.numbered ? 'enumerate' : 'itemize';
const items = grp.items.map((t) => ` \\item ${texEscape(t)}`).join('\n');
return `
\\needspace{4\\baselineskip}
{\\color{instrNavy}\\textbf{${texEscape(name)}}}
\\begin{${env}}
${items}
\\end{${env}}
\\vspace{4pt}
`;
}

function caseBlock(c, course, citeOpts) {
const out = [texDocHeader(c.name, 'Fact sheet', course)];
if (c.intro) out.push(`${texEscape(c.intro)}\n\n\\vspace{6pt}`);
out.push(factsTable(c.rows));
for (const [name, grp] of c.groups) out.push(groupBlock(name, grp));
const src = sourcesLine(c.cites, citeOpts);
if (src) out.push(`\n\\vspace{2pt}\n{\\small\\textbf{Sources:} ${texEscape(src)}}\n`);
return out.join('\n');
}

// Returns { tex, cases } — tex is null when the lecture has no #fact items, so
// the orchestrator can skip the artifact instead of writing an empty sheet.
export function generateFactSheet(parsed, opts = {}) {
const cases = collectCases(parsed, opts);
if (!cases.length) return { tex: null, cases: [] };
const fm = parsed.frontmatter || {};
const course = fm.course || '';
const topic = fm.title || 'Case studies';
const citeOpts = { citationUrls: citationUrlMap(fm) };
const out = [
texPreamble(`Fact sheet: ${topic}`, course, { fontSize: '11pt', margin: '0.75in' }),
'\\begin{document}',
cases.map((c) => caseBlock(c, course, citeOpts)).join('\n\\newpage\n'),
'\\end{document}',
];
return { tex: out.join('\n'), cases: cases.map((c) => c.name) };
}
97 changes: 97 additions & 0 deletions generators/fact-sheet.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import { describe, it, expect } from 'vitest';
import { parse, validate } from '../parser/index.js';
import { generateFactSheet, collectCases } from './fact-sheet.js';
import { generateLectureNotes } from './lecture-notes.js';

const SOURCE = `---
title: Denial of Service Attacks
course: CECS 378
topic-slug: denial_of_service
term: fa26
citation-urls:
- citation: 'CISA TA16-288A'
url: https://www.cisa.gov/news-events/alerts/2016/10/14/heightened-ddos-threat-posed-mirai-and-other-botnets
---

# Denial of Service Attacks

## I. Opener (10 min)

- Mirai turned cameras and DVRs into a botnet. #concept #section/I [slide:: 1]
- Mirai (2016) took down Dyn. #case-study #section/I [case:: Mirai] [citation:: Krebs 2016]

## Fact sheet: Mirai

- IoT botnet malware for DDoS attacks #fact [case:: Mirai] [label:: What]
- August 2016 #fact [case:: Mirai] [label:: Discovered] [citation:: CISA TA16-288A]
- Telnet on ports 23 and 2323, with 62 default passwords #fact [case:: Mirai] [label:: Infection]
- Disconnect the device. #fact #steps [case:: Mirai] [group:: Removing an infection]
- Reboot it while offline. #fact [case:: Mirai] [group:: Removing an infection]
- Change every default password. #fact [case:: Mirai] [group:: Preventing infection]
- Old rumour, cut. #fact #draft [case:: Mirai] [label:: Rumour]

## Fact sheet: Smurf

- 1997 #fact [case:: Smurf] [label:: First seen]
`;

const parsed = () => parse({ source: SOURCE });

describe('fact-sheet generator', () => {
it('validates the fact schema cleanly', () => {
const v = validate(parsed());
expect(v.ok).toBe(true);
expect(v.warnings.filter((w) => /#fact/.test(w.message))).toEqual([]);
});

it('groups facts by case in source order, rows before groups, drafts dropped', () => {
const cases = collectCases(parsed());
expect(cases.map((c) => c.name)).toEqual(['Mirai', 'Smurf']);
const m = cases[0];
expect(m.rows.map((r) => r.label)).toEqual(['What', 'Discovered', 'Infection']);
expect([...m.groups.keys()]).toEqual(['Removing an infection', 'Preventing infection']);
expect(m.groups.get('Removing an infection').numbered).toBe(true);
expect(m.groups.get('Preventing infection').numbered).toBe(false);
expect(m.intro).toBe('Mirai (2016) took down Dyn.');
});

it('renders one page per case with a tagged header row, steps numbered, sources linked', () => {
const { tex, cases } = generateFactSheet(parsed());
expect(cases).toEqual(['Mirai', 'Smurf']);
expect(tex).toMatch(/^\\DocumentMetadata/);
expect((tex.match(/\\newpage/g) || []).length).toBe(1);
expect(tex).toContain('table/header-rows={1}');
expect(tex).toContain('\\begin{enumerate}');
expect(tex).toContain('\\begin{itemize}');
expect(tex).toContain('cisa.gov');
expect(tex).toContain('Krebs 2016');
expect(tex).not.toContain('Rumour');
expect(tex).not.toMatch(/#fact|\[case::/);
});

it('returns null tex when a lecture has no facts', () => {
const r = parse({ source: '---\ntitle: T\n---\n\n## I. A\n\n- x #concept\n' });
expect(generateFactSheet(r)).toEqual({ tex: null, cases: [] });
});

it('keeps facts out of section-walking artifacts', () => {
const notes = generateLectureNotes(parsed());
expect(notes).not.toContain('62 default passwords');
});
});

describe('fact validators', () => {
it('rejects a #fact without [case::]', () => {
const r = parse({ source: '---\ntitle: T\n---\n\n## Facts\n\n- 1997 #fact [label:: Year]\n' });
const v = validate(r);
expect(v.ok).toBe(false);
expect(v.errors[0].message).toMatch(/\[case::/);
});

it('warns on a fact placed inside a numbered lecture section', () => {
const r = parse({ source: '---\ntitle: T\n---\n\n## I. A\n\n- 1997 #fact [case:: X] [label:: Year]\n' });
const v = validate(r);
expect(v.ok).toBe(true);
expect(v.warnings.some((w) => /unnumbered heading/.test(w.message))).toBe(true);
});
});
Loading
Loading