Organize configs and modules and support nested report exports

Move shared YAML settings into config/ and Typst modules into modules/, updating imports, resource paths, and documentation.

Preserve report subfolders in PDF output and encrypted ZIP exports. Add --clean to both renderers, scoped to the report category or selected file, and use it in Jenkins.

Validated report rendering, diagnostics fixtures and assertions, cleanup isolation, and encrypted ZIP contents.
This commit is contained in:
Dandaedre 2026-09-15 14:10:26 +02:00
parent ee560a7b9c
commit ddac30c96e
17 changed files with 115 additions and 41 deletions

6
Jenkinsfile vendored
View File

@ -96,9 +96,9 @@ pipeline {
sh '''
set -eu
# Only clear generated build outputs, never source PDFs.
rm -rf build "${CI_ARTIFACT_DIR}"
./render.sh --all
./render-diagnostics.sh --all "${DIAGNOSTICS_AUTHOR}"
rm -rf "${CI_ARTIFACT_DIR}"
./render.sh --clean --all
./render-diagnostics.sh --clean --all "${DIAGNOSTICS_AUTHOR}"
'''
}
}

View File

@ -30,6 +30,20 @@ The PDF is written to `build/my-report.pdf`. To render every report recursively:
./render.sh --all
```
Subfolders are preserved: `reports/customer/report.yaml` produces
`build/customer/report.pdf`, including in ZIP exports. `build/diagnostics/`
is reserved for diagnostic PDFs.
Remove old PDFs before regenerating all reports:
```bash
./render.sh --clean --all
./render-diagnostics.sh --clean --all "Your Name"
```
Each command cleans only its own report category. With a single input,
`--clean` removes only that input's PDF. Other files are retained.
Set the report's purpose explicitly:
```yaml
@ -86,8 +100,9 @@ typst compile \
```text
report.typ Typst entry point
model.typ Shared layout and YAML renderer
modules/ Shared Typst layouts and diagnostics normalization
render.sh Convenience build script
config/ Shared YAML themes, diagnostics rules, and watchlist
assets/ Logos and other static assets
reports/ Authoritative YAML report sources
build/ Generated PDFs
@ -108,7 +123,7 @@ docs/ Detailed documentation and examples
## Core principle
YAML files are the authoritative report sources. Keep content and report state
in YAML, and keep visual presentation in `model.typ`. For example, prefer
in YAML, and keep visual presentation in `modules/model.typ`. For example, prefer
`severity: high` over fields that specify colors or fonts.
Generated PDFs are reproducible artifacts suitable for email, handoff,
@ -124,7 +139,7 @@ See [LICENSE](LICENSE).
Jenkins renders YAML reports and JSON diagnostics, validates the PDFs, and
publishes encrypted archives to the same `/mnt/books` mount used by the books:
- `/mnt/books/Reports/Reports.zip`: YAML report PDFs.
- `/mnt/books/Reports/Reports.zip`: YAML report PDFs, preserving subfolders.
- `/mnt/books/Reports/Diagnostics.zip`: diagnostic PDFs, preserving subfolders.
Only the ZIPs are archived as Jenkins artifacts. The agent needs `uv` and Python 3, access to PyPI,

View File

@ -1,5 +1,5 @@
#import "diagnostics-model.typ": diagnostics-model
#import "diagnostics-normalize.typ": normalize, datetime-day
#import "modules/diagnostics-model.typ": diagnostics-model
#import "modules/diagnostics-normalize.typ": normalize, datetime-day
#let diagnostics-file = sys.inputs.at("diagnostics", default: none)
#let author = sys.inputs.at("author", default: none)
@ -36,7 +36,7 @@
)
}
#let rules = yaml("diagnostics-rules.yaml")
#let rules = yaml("config/diagnostics-rules.yaml")
#let data = normalize(source, rules: rules, source-name: diagnostics-file)
#if datetime-day(source.at("generated_at", default: "")) == none {
@ -46,7 +46,7 @@
)
}
#let themes = yaml("themes.yaml")
#let themes = yaml("config/themes.yaml")
#let theme-name = lower(str(sys.inputs.at("theme", default: "default")))
#if theme-name not in themes {
@ -60,5 +60,5 @@
data: data,
author: author,
theme: themes.at(theme-name),
logo: "assets/beffroi.png",
logo: "/assets/beffroi.png",
)

View File

@ -19,6 +19,16 @@ templates/
└── incident.yaml
```
PDFs and exported ZIPs preserve the path beneath `reports/`, so
`reports/2026/incidents/api-latency.yaml` becomes
`build/2026/incidents/api-latency.pdf`. The top-level `diagnostics/` output
folder is reserved; use another name for YAML report groups.
Use `./render.sh --clean --all` to remove old report PDFs before rebuilding.
Diagnostic PDFs are cleaned separately with
`./render-diagnostics.sh --clean --all "Your Name"`.
With a single input, `--clean` removes only its output PDF.
To avoid rendering template YAML during `--all`, keep reusable templates
outside `reports/`, for example in a top-level `templates/` directory.
@ -26,7 +36,7 @@ outside `reports/`, for example in a top-level `templates/` directory.
- Replace `assets/beffroi.png` with your logo, or update the `logo` argument in
`report.typ`.
- Change colors, typography, spacing, and components in `model.typ`.
- Change colors, typography, spacing, and components in `modules/model.typ`.
- Keep report-specific content out of the Typst model so historical YAML files
remain reusable with later design changes.
@ -44,7 +54,7 @@ A report selects its theme by name:
theme: eridani
```
All themes live in the top-level `themes.yaml` registry. The built-in choices
All themes live in the `config/themes.yaml` registry. The built-in choices
are `default`, `cic`, and `eridani`. To add one, copy an existing mapping, give
it a new key, and adjust its values:
@ -66,7 +76,7 @@ my_theme:
Color values use hexadecimal RGB notation. Fonts must be installed wherever
the report is compiled; keeping the supplied DejaVu families is the most
portable option for this repository. After editing `themes.yaml`, compile at
portable option for this repository. After editing `config/themes.yaml`, compile at
least one representative report with each affected theme.
### Image sources
@ -101,7 +111,7 @@ A minimal CI job only needs to install Typst and execute:
Treat any non-zero exit code as a failed build. Pin the Typst version in CI if
reproducible output is important, and use the same version locally when changing
`model.typ`.
`modules/model.typ`.
For a lightweight local pre-commit check:

View File

@ -46,11 +46,11 @@ message.
## Pipeline
1. `diagnostics-normalize.typ` reads WinDiagnostics schema versions 1 and 2 JSON,
1. `modules/diagnostics-normalize.typ` reads WinDiagnostics schema versions 1 and 2 JSON,
deduplicates event records, classifies signals, and builds normalized data
entirely inside Typst.
2. `diagnostics.typ` validates the inputs and selected YAML theme.
3. `diagnostics-model.typ` renders the final PDF and uses PrimaViz for the
3. `modules/diagnostics-model.typ` renders the final PDF and uses PrimaViz for the
summary visualization.
No Python conversion or external normalization step is required for native captures. Typst reads
@ -128,7 +128,7 @@ Routine evidence is conditional:
## Upgradeable event heuristics
Event interpretation lives in `diagnostics-rules.yaml`, separate from the Typst
Event interpretation lives in `config/diagnostics-rules.yaml`, separate from the Typst
parser and layout. Each rule matches an exact provider and event ID and defines
its severity, rationale, and a heuristic confidence estimate:
@ -160,7 +160,7 @@ the arithmetic mean of displayed finding confidence values.
The health graph is deliberately simple and reproducible: it begins at 100,
subtracts 8 points per critical finding, 2 per warning, and 1 per unanalysed
signal, then clamps the result to 0–100. Change those weights in
`diagnostics-normalize.typ` if operational experience calls for different
`modules/diagnostics-normalize.typ` if operational experience calls for different
priorities.
## Closing findings safely
@ -228,7 +228,7 @@ and unknown events. Those signals may be persistent, intermittent, or unsafe to
treat as resolved merely because no newer event was captured.
The defaults can be overridden per safe rule with `fade_after_days` and
`fade_to_half_days` in `diagnostics-rules.yaml`.
`fade_to_half_days` in `config/diagnostics-rules.yaml`.
A DISM result of `repairable` is classified as a warning, not a critical
finding. Microsoft distinguishes it from a non-repairable image and provides
@ -272,7 +272,7 @@ typst compile \
```
Available themes are `default`, `cic`, and `eridani` and are defined in
`themes.yaml`.
`config/themes.yaml`.
## Input expectations
@ -363,7 +363,7 @@ Explicit unhealthy disk states and IsSigned=false also receive review findings;
missing fields do not establish either problem.
The maintained [known-issue list](known-issues.md) explains matching and sources.
Its machine-readable rules live in `diagnostics-watchlist.yaml`. Warnings link to
Its machine-readable rules live in `config/diagnostics-watchlist.yaml`. Warnings link to
the PDF watchlist and vendor advice; the PDF also links Microsoft's driver list.
The watchlist is curated and offline, not an exhaustive or automatically updated
vulnerability database. Compilation makes no network requests for advisories.

View File

@ -1,7 +1,7 @@
# Known driver, software and feature issues
Reviewed: **2026-09-15**. The executable list is
[diagnostics-watchlist.yaml](../diagnostics-watchlist.yaml). It flags documented
[config/diagnostics-watchlist.yaml](../config/diagnostics-watchlist.yaml). It flags documented
risks and compatibility conditions, not old release dates or vendor reputation.
Every match becomes a warning with an advisory link and an internal link to the
PDF's list. It adds no score penalty; independent event findings still do.

View File

@ -144,7 +144,7 @@
]
]
#let diagnostics-model(data: (:), author: "", theme: (:), logo: "assets/beffroi.png", body) = {
#let diagnostics-model(data: (:), author: "", theme: (:), logo: "/assets/beffroi.png", body) = {
set page(
paper: "a4", margin: (top: 18mm, bottom: 17mm, left: 18mm, right: 18mm),
header: context header(theme, data, logo), footer: context footer(theme, data),

View File

@ -202,7 +202,7 @@
item.insert("severity", if rule == none and get(event, "level", none) in (4, 5) { "info" } else if rule == none { get(rules, "unknown_event_severity", "unanalysed") } else { get(rule, "severity", "unanalysed") })
item.insert("rationale", if rule == none and get(event, "level", none) in (4, 5) { "Informational record retained without a reviewed interpretation; no fault inferred." } else if rule == none { "No reviewed interpretation is available for this event." } else { get(rule, "rationale", "") })
item.insert("remediation", if rule == none { "Add a reviewed provider/ID rule before attempting cleanup." } else { get(rule, "remediation", "") })
item.insert("resolution_steps", if rule == none { ("Review the raw event and add a rule to diagnostics-rules.yaml.", "Re-run the report after the rule has been reviewed.") } else { get(rule, "resolution_steps", ()) })
item.insert("resolution_steps", if rule == none { ("Review the raw event and add a rule to config/diagnostics-rules.yaml.", "Re-run the report after the rule has been reviewed.") } else { get(rule, "resolution_steps", ()) })
item.insert("reference_url", if rule == none { "" } else { get(rule, "reference_url", "") })
item.insert("reference_label", if rule == none { "" } else { get(rule, "reference_label", "Microsoft guidance") })
item.insert("confidence", if rule == none { 20 } else { get(rule, "confidence", 70) })
@ -258,7 +258,7 @@
fields.map(pair => pair.at(0) + ": " + if pair.at(1) in ("LastWriteTime", "TimeGenerated", "DriverDate") { display-time(get(item, pair.at(1), "Unknown")) } else { value-text(get(item, pair.at(1), "Unknown")) }).join("\n", default: "")
}
#let watchlist-catalog = yaml("diagnostics-watchlist.yaml")
#let watchlist-catalog = yaml("../config/diagnostics-watchlist.yaml")
#let watch-matches(report, matcher) = {
let name = matcher.section

View File

@ -666,7 +666,7 @@
#let report-model(
report: (:),
theme: (:),
logo: "assets/beffroi.png",
logo: "/assets/beffroi.png",
body,
) = {
set page(

View File

@ -5,11 +5,13 @@ ROOT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
DIAGNOSTICS_DIR="${ROOT_DIR}/diagnostics"
BUILD_DIR="${ROOT_DIR}/build/diagnostics"
CLEAN=0
usage() {
cat <<'EOF_USAGE'
Usage:
./render-diagnostics.sh REPORT.json "Author Name" [theme]
./render-diagnostics.sh --all "Author Name" [theme]
./render-diagnostics.sh [--clean] REPORT.json "Author Name" [theme]
./render-diagnostics.sh [--clean] --all "Author Name" [theme]
Examples:
./render-diagnostics.sh diagnostics/windows_system_report_PC.json "Jane Doe"
@ -17,6 +19,9 @@ Examples:
./render-diagnostics.sh --all "Jane Doe"
./render-diagnostics.sh --all "Jane Doe" eridani
--clean removes old PDFs before rendering: all PDFs in this category with
--all, or only the selected output with a single input. Other files are kept.
The theme is optional and defaults to "default".
Available themes: default, cic, eridani
EOF_USAGE
@ -53,6 +58,10 @@ render_diagnostics() {
local output="${BUILD_DIR}/${relative_output}"
mkdir -p "$(dirname -- "$output")"
if [[ "$CLEAN" -eq 1 ]]; then
rm -f -- "$output"
fi
echo "Rendering: $input_typst"
echo " -> ${output#"$ROOT_DIR/"}"
@ -75,6 +84,10 @@ render_all() {
[[ -d "$DIAGNOSTICS_DIR" ]] \
|| die "diagnostics directory not found: $DIAGNOSTICS_DIR"
if [[ "$CLEAN" -eq 1 && -d "$BUILD_DIR" ]]; then
find "$BUILD_DIR" -type f -name '*.pdf' -exec rm -f -- {} +
fi
while IFS= read -r -d '' input; do
found=1
render_diagnostics "$input" "$author" "$theme"
@ -89,6 +102,15 @@ render_all() {
}
main() {
local args=()
for arg in "$@"; do
case "$arg" in
--clean) CLEAN=1 ;;
-h|--help) usage; return ;;
*) args+=("$arg") ;;
esac
done
set -- "${args[@]}"
command -v typst >/dev/null 2>&1 || die "typst was not found"
[[ $# -ge 2 && $# -le 3 ]] || { usage; exit 1; }

View File

@ -4,21 +4,25 @@ set -euo pipefail
ROOT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
REPORT_DIR="${ROOT_DIR}/reports"
BUILD_DIR="${ROOT_DIR}/build"
CLEAN=0
ENTRYPOINT="${ROOT_DIR}/report.typ"
usage() {
cat <<'EOF'
Usage:
./render.sh PATH
./render.sh --all
./render.sh [--clean] PATH
./render.sh [--clean] --all
Examples:
./render.sh reports/2026-09-04-clevo-handoff.yaml
./render.sh --all
./render.sh --clean --all
Outputs PDFs into:
./build/
--clean removes old PDFs before rendering: all PDFs in this category with
--all, or only the selected output with a single input. Other files are kept.
Requirements:
- typst must be available in PATH
EOF
@ -54,9 +58,19 @@ render_report() {
filename="$(basename -- "$input")"
basename="${filename%.*}"
output="${BUILD_DIR}/${basename}.pdf"
local relative="$basename"
if [[ "$input" == "$REPORT_DIR/"* ]]; then
relative="${input#"$REPORT_DIR/"}"
relative="${relative%.*}"
fi
[[ "$relative" != diagnostics && "$relative" != diagnostics/* ]] \
|| die "reports/diagnostics is reserved for diagnostic PDF output"
output="${BUILD_DIR}/${relative}.pdf"
mkdir -p "$BUILD_DIR"
mkdir -p "$(dirname -- "$output")"
if [[ "$CLEAN" -eq 1 ]]; then
rm -f -- "$output"
fi
echo "Rendering: $input"
echo " -> $output"
@ -86,6 +100,10 @@ render_all() {
mkdir -p "$BUILD_DIR"
if [[ "$CLEAN" -eq 1 ]]; then
find "$BUILD_DIR" -path "$BUILD_DIR/diagnostics" -prune -o -type f -name '*.pdf' -exec rm -f -- {} +
fi
local found=0
while IFS= read -r -d '' report; do
@ -109,6 +127,15 @@ render_all() {
}
main() {
local args=()
for arg in "$@"; do
case "$arg" in
--clean) CLEAN=1 ;;
-h|--help) usage; return ;;
*) args+=("$arg") ;;
esac
done
set -- "${args[@]}"
check_dependencies
[[ $# -eq 1 ]] || {

View File

@ -1,4 +1,4 @@
#import "model.typ": report-model
#import "modules/model.typ": report-model
#let report-file = sys.inputs.at("report", default: none)
@ -28,7 +28,7 @@
)
}
#let themes = yaml("themes.yaml")
#let themes = yaml("config/themes.yaml")
#let theme-name = lower(str(report.at("theme", default: "default")))
#if theme-name not in themes {
@ -44,5 +44,5 @@
#show: report-model.with(
report: report,
theme: theme,
logo: "assets/beffroi.png",
logo: "/assets/beffroi.png",
)

View File

@ -1,6 +1,6 @@
#import "../diagnostics-normalize.typ": normalize, value-text, datetime-day, date-index, datetime-second, catalog-correlation, group-events, display-time
#import "../modules/diagnostics-normalize.typ": normalize, value-text, datetime-day, date-index, datetime-second, catalog-correlation, group-events, display-time
#let rules = yaml("../diagnostics-rules.yaml")
#let rules = yaml("../config/diagnostics-rules.yaml")
#let fixture = json("fixtures/windiagnostics-v1.json")
#let data = normalize(fixture, rules: rules, source-name: "tools/fixtures/windiagnostics-v1.json")
@ -163,7 +163,7 @@ Diagnostics JSON regression checks passed.
#assert.eq(captured-v2.event_groups.find(item => item.provider == "Microsoft-Windows-CodeIntegrity" and item.id == "3099").severity, "info")
#assert(captured-v2.findings.any(item => item.at("watch_id", default: "") == "intel-wifi-observed"))
#assert(not captured-v2.findings.any(item => item.at("watch_id", default: "") == "obs-overlay"))
#import "../diagnostics-normalize.typ": watchlist-findings, reliability-events
#import "../modules/diagnostics-normalize.typ": watchlist-findings, reliability-events
#let watch-report = json("fixtures/windiagnostics-watchlist.json")
#let watch = normalize(watch-report, rules: rules)
#let watch-ids = watch.findings.filter(f => "watch_id" in f).map(f => f.watch_id)

View File

@ -16,7 +16,7 @@ for category in Reports Diagnostics; do
mkdir -p "$staging_dir/$category"
if [[ "$category" == Reports ]]; then
source_dir="$build_dir"
depth=(-maxdepth 1)
depth=(-path "$build_dir/diagnostics" -prune -o)
else
source_dir="$build_dir/diagnostics"
depth=()