Skip to content
Open
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
16 changes: 16 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,24 @@ name: ci
on:
push:
branches: [main]
tags: ["v*"]
pull_request:
workflow_dispatch:

jobs:

quality:
name: Lint and type check
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.2.2
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
with:
python-version: '3.12'
- run: python -m pip install --upgrade pip nox
- run: nox -s lint typecheck

test:
strategy:
fail-fast: false
Expand All @@ -22,6 +36,8 @@ jobs:
run: |
python -m pip install --upgrade pip
python -m pip install -e ".[dev]"
- name: Fetch pinned benchmark font
run: python spikes/fetch_b0_font.py
- name: Test
run: python -m pytest -q
- name: Validate frozen benchmark manifest
Expand Down
42 changes: 42 additions & 0 deletions .github/workflows/scorecard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Scorecard supply-chain security
on:
branch_protection_rule:
schedule:
- cron: '30 1 * * 1'
push:
branches: ["main"]
workflow_dispatch:

permissions: read-all

jobs:
analysis:
name: Scorecard analysis
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
security-events: write
id-token: write
contents: read
actions: read
steps:
- name: Checkout code
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.2.2
with:
persist-credentials: false
- name: Run analysis
uses: ossf/scorecard-action@62b2cac7ed8198b15735ed49ab1e5cf35480ba46 # v2.4.0
with:
results_file: results.sarif
results_format: sarif
publish_results: true
- name: Upload artifact
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: SARIF file
path: results.sarif
retention-days: 5
- name: Upload to code-scanning
uses: github/codeql-action/upload-sarif@f09c1c0a94de965c15400f5634aa42fac8fb8f88 # v3.27.5
with:
sarif_file: results.sarif
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,15 @@ venv/
# Generated holdout samples and labels (sealed; only seal.json is committed)
benchmark/holdout/*
!benchmark/holdout/seal.json
!benchmark/holdout/BURNED

# OS / editor
.DS_Store
Thumbs.db
.pytest-tmp/

# Local verification virtualenvs
.venv*/

# Internal planning notes
.superpowers/
36 changes: 36 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
minimum_pre_commit_version: "3.7.0"
default_language_version:
python: python3
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: check-yaml
args: [--allow-multiple-documents]
- id: check-toml
- id: check-json
- id: check-added-large-files
args: [--maxkb=2048]
- id: check-merge-conflict
- id: check-case-conflict
- id: end-of-file-fixer
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]
- id: mixed-line-ending
args: [--fix=lf]
# Local hooks so the hook and the CI job run the exact same binary version.
# Install once: python -m pip install ruff mypy (or from the shared wheelhouse)
- repo: local
hooks:
- id: ruff
name: ruff
entry: ruff check --fix --exit-non-zero-on-fix
language: system
types_or: [python, pyi]
require_serial: true
- id: mypy
name: mypy
entry: mypy --config-file=pyproject.toml
language: system
pass_filenames: false
types_or: [python, pyi]
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@

## Unreleased

- Add a deterministic frozen-manifest holdout generator with pre-execution sample ID, PDF,
source, label, code and runtime hashes; the seal excludes labels and records the lack of an
independent custodian or human PDF-review session.
- Add a one-shot Windows-only holdout runner that refuses changed code/input/runtime evidence,
retains full raw reports, and publishes pooled/per-class precision, recall, false-PASS,
UNKNOWN and ERROR rates with 95% Wilson intervals. No detector threshold tuning is exposed.
- Correct package metadata to describe bounded local font-cmap evidence and run CI on `v*` tags.
- Record that v3 TDD exercised `H01.clean.s1` before sealing, burning the current manifest under
B0 §6.6; add a fail-closed `BURNED` guard and make no holdout accuracy claim.

## 0.1.0a3 — 2026-11-29

- Add structured CLI errors, explicit force semantics, paired rollback-safe reports, OS-fd output isolation and strict Windows output-component checks.
Expand Down
58 changes: 44 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
# PlotProof

[![CI](https://github.com/gedouluhui/plotproof/actions/workflows/ci.yml/badge.svg)](https://github.com/gedouluhui/plotproof/actions/workflows/ci.yml)
[![Release](https://img.shields.io/github/v/tag/gedouluhui/plotproof?label=release&sort=semver)](https://github.com/gedouluhui/plotproof/releases)
[![Python](https://img.shields.io/badge/python-3.12%2B-blue)](https://github.com/gedouluhui/plotproof/blob/main/pyproject.toml)
[![License](https://img.shields.io/github/license/gedouluhui/plotproof)](LICENSE)
[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/gedouluhui/plotproof/badge)](https://securityscorecards.dev/viewer/?uri=github.com/gedouluhui/plotproof)

**Source-assisted export evidence for Matplotlib figures.** PlotProof records what a
figure intends to draw at save time, compares that record with the exported PDF, and
reports what went wrong — or `UNKNOWN` when the evidence is not strong enough.

> **Status: B1 engineering preview (2026-11-19).** The deterministic checker core, the
> bounded PDF reader and the CA1 save-time capture layer are implemented and tested.
> An experimental assembly runs the whole path end to end on one figure.
> It is **not** a certified detector: there is no holdout run and no accuracy number.
> D4 now uses bounded local font-cmap evidence; unavailable provenance is reported as
> `UNKNOWN`, never as a missing-glyph pass. Read
> [What this does not do](#what-this-does-not-do) before trusting any output.
> **Status: B1 engineering preview with v3 holdout tooling.** The deterministic checker core,
> bounded PDF reader, CA1 capture layer and reproducible sealed-holdout runner are implemented
> and tested. There is **no valid holdout result or accuracy number**: the v3 TDD worker contract
> exercised `H01.clean.s1` before sealing, which burns this manifest for confirmatory use under
> B0 §6.6. The runner refuses burned holdouts; a new preregistered seed/template set is required.
> D4 uses bounded local font-cmap evidence; unavailable provenance is reported as `UNKNOWN`,
> never as a missing-glyph pass. Read [What this does not do](#what-this-does-not-do) before
> trusting any output.

## The problem

Expand Down Expand Up @@ -182,9 +189,10 @@ text, unresolved alignment, coverage below 0.90, or a finding at medium confiden

## What this does not do

- **No holdout, no accuracy claim.** The benchmark manifest is frozen at B0; its
holdout has never been generated or inspected. Nothing here is a precision/recall
measurement.
- **No valid holdout, no accuracy claim.** The v3 TDD worker test ran the frozen
`H01.clean.s1` input before sealing. B0 §6.6 therefore burns this manifest for confirmatory
use; no precision/recall result from it would be valid. `benchmark/holdout/BURNED` records
the cause, and the runner fails closed on that marker.
- **Font evidence is bounded and local.** D4 reads Unicode cmaps only from the renderer-selected
font files, binds them by SHA-256, and treats missing, malformed or over-budget provenance as
`UNKNOWN`. It does not certify font licensing, embedding, or every backend/version combination.
Expand Down Expand Up @@ -258,7 +266,7 @@ Verified facts worth knowing before extending this:
| B1 | deterministic core for D1–D4, bounded PDF reader, CA1 capture | core/reader/capture implemented and tested |
| B1.5 | end-to-end assembly, D1/D3 assessment, class-scoped reports | this preview |
| B2 | font evidence (D4), complete paint inventory (D2 for collections/images), dev-split calibration | not started |
| B3 | one sealed holdout run, preregistered report | not started |
| B3 | one sealed holdout run, preregistered report | runner implemented; current manifest burned by pre-seal TDD exposure |
| B4 | release, documentation, examples | not started |

## Development
Expand All @@ -267,9 +275,31 @@ Verified facts worth knowing before extending this:
.venv/Scripts/python -m pip install -e ".[dev]"
python -m pytest # run the full suite; see task report for verified totals
.venv/Scripts/python benchmark/validate_manifest.py

# Windows + the pinned runtime/font only; generate once, review once, then execute once:
.venv/Scripts/python benchmark/generate_holdout.py --generate-only --output-dir benchmark/holdout
# Owner opens every PDF and corrects labels in the logged review session; no detector runs.
.venv/Scripts/python benchmark/generate_holdout.py --seal-reviewed --reviewed-by OWNER --output-dir benchmark/holdout
.venv/Scripts/python benchmark/run_holdout.py --holdout-dir benchmark/holdout
```

CI runs the suite on Ubuntu 3.12 and Windows 3.12 with Matplotlib 3.10.8.
The generator seals all 114 holdout sample IDs and PDF/source hashes before benchmark execution.
Generation writes `generation.json`, unreviewed `labels.json` and `label_review_log.json`, but no
seal. Sealing is a separate explicit step requiring `--reviewed-by`; it rejects changed code,
runtime, labels or malformed review metadata and binds the review-log hash. The runner verifies
the frozen manifest, labels, code bytes, pinned Windows runtime and every input hash, logs the
unseal, refuses burned holdouts, and refuses a second run once predictions exist. It writes
`predictions.jsonl`, full `raw_outcomes.jsonl`, `results.json` and `summary.md`; the summary
reports pooled and per-class precision/recall, false-PASS, UNKNOWN/ERROR rates, macro alignment
coverage and 95% Wilson intervals. Generated holdout files are git-ignored. The procedural seal
is not access control: no independent custodian or human PDF label-review session is claimed by
the tooling itself, and synthetic-template results do not establish real-world accuracy.

The current runner implements the detector metrics and Wilson intervals, but **not** the B0
baseline-B delta gate or template-cluster bootstrap. Its aggregate `all_pass` therefore fails
closed. See [B3 holdout methodology](docs/B3_HOLDOUT.md) for evidence boundaries and commands.

CI runs the suite on Ubuntu 3.12 and Windows 3.12 with Matplotlib 3.10.8, and on `v*` tags.

## License

Expand Down Expand Up @@ -326,10 +356,10 @@ python -m plotproof check does-not-exist.py --json missing-report.json --html mi
Expected: The missing figure module returns a structured stdout JSON error with exit 2 and no success is claimed. Existing outputs require explicit `--force`; safe error JSON is published when possible. `--max-d3-work` bounds all D3 pair evaluation.

### Evidence and coverage boundaries
Evidence includes the full pytest suite for the deterministic core, bounded PDF reader, CA1 capture, structured CLI, safe publication, complexity budget, local font-cmap evidence and end-to-end assembly. There is no holdout run or accuracy number. D4 is assessed only when renderer-selected font provenance is available; otherwise it is explicitly UNKNOWN. PASS means only that no supported defect was found with sufficient coverage in assessed classes.
Evidence includes the full pytest suite for the deterministic core, bounded PDF reader, CA1 capture, structured CLI, safe publication, complexity budget, local font-cmap evidence, end-to-end assembly and sealed-holdout validation/metrics. There is no valid holdout run or accuracy number: pre-seal TDD exposure burned the current manifest under B0 §6.6. D4 is assessed only when renderer-selected font provenance is available; otherwise it is explicitly UNKNOWN. PASS means only that no supported defect was found with sufficient coverage in assessed classes.

### Support status
Version 0.1.0a4 is a B1 engineering preview for Python 3.12 and Matplotlib 3.10.8. The PDF worker path is verified on Windows only. It is not a certified detector and has no accuracy claim. Maintenance is best-effort with no SLA.
Version 0.1.0a4 is a B1 engineering preview for Python 3.12 and Matplotlib 3.10.8. The PDF worker path is verified on Windows only. The v3 sealed-holdout runner is implemented, but the current manifest is burned and has no valid accuracy claim. Maintenance is best-effort with no SLA.

### Limitations
Rotated text, mathtext, TeX, wrapped/rasterized text, path effects, arbitrary/multi-page/rotated PDFs, and semantic or aesthetic judgment are outside scope. D2 is skipped when images or collections prevent a complete paint inventory. D3 is skipped as a whole when its declared work budget is exceeded. Output rollback is not crash atomicity.
4 changes: 2 additions & 2 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ estimated_work = pairs + operand_work + intersection_work + union_sort_work
估算值等于上限时仍执行 D3。矩形并集采用精确有理数坐标压缩线段树扫描,复杂度 O(m log m);有理坐标避免混合尺度下溢与中间溢出,真正无法表示为有限非零浮点数的面积会抛错,而不是返回虚假的有限零值。

### 证据与覆盖边界
证据包括完整 pytest 测试,覆盖确定性核心、受限 PDF 读取器、CA1 采集、结构化 CLI、安全发布、复杂度预算、本地字体 cmap 证据和端到端装配。没有保留集结果或准确率数字。D4 仅在渲染器选中的字体来源可用时评估,否则明确报告 `UNKNOWN`。PASS 仅表示在已评估类别中且覆盖足够时未发现受支持的缺陷。
证据包括完整 pytest 测试,覆盖确定性核心、受限 PDF 读取器、CA1 采集、结构化 CLI、安全发布、复杂度预算、本地字体 cmap 证据、端到端装配,以及保留集封存验证和指标计算。没有有效的保留集结果或准确率数字:v3 TDD worker 测试在封存前运行了 `H01.clean.s1`,依据 B0 §6.6 烧毁了当前清单。运行器会拒绝已烧毁的保留集;需要新的预注册种子/模板集。D4 仅在渲染器选中的字体来源可用时评估,否则明确报告 `UNKNOWN`。PASS 仅表示在已评估类别中且覆盖足够时未发现受支持的缺陷。

### 支持状态
版本 0.1.0a4 是面向 Python 3.12 和 Matplotlib 3.10.8 的 B1 工程预览。PDF worker 路径仅在 Windows 上验证。它不是认证检测器,也没有准确率声明。维护为尽力而为,不提供 SLA。
版本 0.1.0a4 是面向 Python 3.12 和 Matplotlib 3.10.8 的 B1 工程预览。PDF worker 路径仅在 Windows 上验证。v3 保留集运行器已实现,但当前清单已烧毁,没有有效准确率声明。维护为尽力而为,不提供 SLA。

### 限制
不支持旋转文字、数学公式、TeX、自动换行/栅格化文字、路径效果、任意/多页/旋转 PDF,也不做语义或美学判断。当图像或集合导致绘制清单不完整时,D2 会被跳过;D3 估算工作量超过预算时整类跳过。输出回滚不具备崩溃原子性。
Loading
Loading