diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 519eae808..f152508da 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -2,9 +2,9 @@ blank_issues_enabled: true contact_links: - name: Security vulnerability report (private) - url: https://github.com/protocolith/protocolith/security/advisories/new + url: https://github.com/Protocolith/protocolith/security/advisories/new about: Use GitHub Security Advisories instead of opening a public issue for vulnerabilities or sensitive disclosures. - name: Code of Conduct process question (public) - url: https://github.com/protocolith/protocolith/issues/new?labels=conduct&title=%5Bconduct-process%5D%20 + url: https://github.com/Protocolith/protocolith/issues/new?labels=conduct&title=%5Bconduct-process%5D%20 about: Use only for non-sensitive Code of Conduct process questions. Do not post private or personal details in public issues. diff --git a/.github/ISSUE_TEMPLATE/ledger_problem.yml b/.github/ISSUE_TEMPLATE/ledger_problem.yml new file mode 100644 index 000000000..8a69beb25 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/ledger_problem.yml @@ -0,0 +1,67 @@ +name: Ledger or core problem +description: A freeze, record, verify-ledger, issue, summary, atlas or MCP command behaves wrongly (non-security). +title: "[core] " +labels: ["bug"] + +body: + - type: markdown + attributes: + value: | + Use this form for the ledger core: `init`, `freeze`, `record`, `deviation`, `verify-ledger`, `issue`, `summary`, `show`, + `capture`, `schema`, `atlas` and the MCP server. Do **not** paste secrets or private data. If a ledger fails to verify, the + error codes are enough; do not attach the ledger unless it is a small test ledger. + + - type: input + id: version + attributes: + label: Protocolith version + description: Output of `protocolith --version`. + placeholder: protocolith 0.6.0 + validations: + required: true + + - type: dropdown + id: platform + attributes: + label: Operating system + options: + - Linux + - macOS + - Windows + - Other + validations: + required: true + + - type: input + id: python + attributes: + label: Python version + description: Output of `python --version`. + placeholder: Python 3.13.1 + validations: + required: true + + - type: textarea + id: command + attributes: + label: Command that failed + description: The exact command and, if short, the input file. + render: shell + validations: + required: true + + - type: textarea + id: output + attributes: + label: Output and exit code + description: Everything the command printed, including the error code (for example BAD_HASH) and the exit code (0, 1, 2 or 3). + render: text + validations: + required: true + + - type: textarea + id: expected + attributes: + label: What you expected + validations: + required: true diff --git a/README.md b/README.md index 35c47651d..45ca26717 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ -->

- Terminal recording of the card-level commands: version, doctor, inspect, validate-card, hash and verify + Terminal recording: init, freeze a protocol, record a result, verify the ledger, summary, issue a card, build the atlas, then a one-word edit of the ledger that verify-ledger detects

## Why diff --git a/docs/assets/protocolith/README_ASSETS.txt b/docs/assets/protocolith/README_ASSETS.txt index d7553d728..a8f679ca0 100644 --- a/docs/assets/protocolith/README_ASSETS.txt +++ b/docs/assets/protocolith/README_ASSETS.txt @@ -6,7 +6,7 @@ FILES (bytes) concept_b.svg 2306 concept_c.svg 7011 contact_sheet.svg 109897 - demo.gif 247755 + demo.gif 415254 favicon.svg 422 logo-dark.svg 2311 logo-mark-512.png 4421 @@ -37,20 +37,12 @@ technical, verifiable character without any cliche (no lock, shield or chain), a marks "recorded" detail. A is more literal but reads as a generic tower/server at small sizes; C is handsome but detailed rings and teeth vanish below about 32 px. -DEMO GIF (demo.gif): real output, run in the repository root with UV_CACHE_DIR set to a temp directory - uv run protocolith --version - uv run protocolith doctor - uv run protocolith inspect registry - uv run protocolith validate-card docs/evidence_cards/PLITH-AI_PRODUCT_CLAIM_D001-2026-05-07.json - uv run protocolith hash LICENSE - uv run protocolith verify static-registry-spec (works offline, rc=0, all PASS) -All six commands exited 0. Edits to the captured text, nothing else changed: - - doctor: the two lines repo_root= and runs_root= (absolute home paths) are replaced by one - dimmed "# ... omitted (local paths)" note. - - hash and verify: the absolute repository prefix is shown as /. - - The card file name in the validate-card line contains "AI" because that is the real file name. -Not run: verify packs that need network (nasa-rerun, noaa-rerun, eea-drift, api-parity, ai-boundary was -run once to check it works but is not shown). Typed-command animation 3 chars/frame at 12 fps, loops forever. +DEMO GIF (demo.gif): generated by scripts/build_demo_gif.py from a real run (no hand edited text) + uv run --no-project --with pillow python scripts/build_demo_gif.py +The script copies examples/quickstart to a temporary directory and runs init, freeze, record, verify-ledger, summary, +issue 1 and atlas. It then changes one word of the ledger (PASSED to FAILED) and runs verify-ledger again, which exits 1. +Only hexadecimal strings of 40 or more characters are shortened to 12 characters plus "...". The frames contain the date of +the run (it is part of the card ids). Pillow is needed only for this script. WORKFLOW GIF (workflow.gif): drawn with Pillow, 900x300, 10 fps, loops. Captioned "Workflow overview" and "Design overview, not a product demo". diff --git a/docs/assets/protocolith/demo.gif b/docs/assets/protocolith/demo.gif index 537e6c0c9..d762695e8 100644 Binary files a/docs/assets/protocolith/demo.gif and b/docs/assets/protocolith/demo.gif differ diff --git a/scripts/build_demo_gif.py b/scripts/build_demo_gif.py new file mode 100644 index 000000000..ef5a7fab5 --- /dev/null +++ b/scripts/build_demo_gif.py @@ -0,0 +1,179 @@ +#!/usr/bin/env python3 +"""Build docs/assets/protocolith/demo.gif from a real run of the ledger commands. + +The script copies examples/quickstart to a temporary directory, runs the real commands +(init, freeze, record, verify-ledger, summary, issue, atlas), then edits one word of the ledger +and verifies again to show that tampering is detected. The terminal output in the frames is +the captured output of those commands; only long hexadecimal strings (40 characters or more) +are shortened to their first 12 characters followed by "..." so that lines fit the frame. + +Pillow is needed only here, not by Protocolith: + + uv run --no-project --with pillow python scripts/build_demo_gif.py [--out FILE] + +Standard output shows the progress in percent. The frames contain the current date (it is part of the card ids). +""" + +from __future__ import annotations + +import argparse +import os +import re +import shutil +import subprocess +import sys +import tempfile +import tomllib +from pathlib import Path + +from PIL import Image, ImageDraw, ImageFont + +ROOT = Path(__file__).resolve().parent.parent +WIDTH, HEIGHT = 820, 500 +PAD, TOP = 18, 44 +FONT_SIZE = 15 +LINE_H = 20 +BG, BAR, TEXT = (14, 20, 27), (24, 33, 44), (238, 242, 246) +PROMPT, OK, BAD, DIM = (232, 176, 74), (110, 200, 140), (240, 110, 110), (140, 156, 176) +FONT_CANDIDATES = ( + "/System/Library/Fonts/Menlo.ttc", + "/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf", + "C:/Windows/Fonts/consola.ttf", +) +HEX = re.compile(r"[0-9a-f]{40,}") +VERSION = tomllib.loads((ROOT / "pyproject.toml").read_text(encoding="utf-8"))["project"]["version"] +RUNNER = "import sys; from protocolith.cli import main; sys.exit(main())" + + +def short(text: str) -> str: + return HEX.sub(lambda m: m.group(0)[:12] + "...", text) + + +def run(argv: list[str], cwd: Path) -> tuple[list[str], int]: + env = dict(os.environ, PYTHONPATH=str(ROOT / "src"), PYTHONIOENCODING="utf-8") + proc = subprocess.run( + [sys.executable, "-c", RUNNER, *argv], cwd=cwd, env=env, capture_output=True, text=True, check=False + ) + lines = (proc.stdout + proc.stderr).rstrip("\n").splitlines() + return [short(line) for line in lines], proc.returncode + + +def script(work: Path) -> list[tuple[str, list[str], int]]: + """Run every step for real and return (shown command, output lines, exit code).""" + steps: list[tuple[str, list[str], int]] = [] + + def step(shown: str, argv: list[str]) -> None: + out, code = run(argv, work) + steps.append((shown, out, code)) + + step("protocolith --version", ["--version"]) + step("protocolith init", ["init"]) + step("protocolith freeze protocol.json", ["freeze", "protocol.json"]) + step("protocolith record record.json", ["record", "record.json"]) + step("protocolith verify-ledger", ["verify-ledger"]) + step("protocolith summary", ["summary"]) + step("protocolith issue 1", ["issue", "1"]) + step("protocolith atlas --store .protocolith --out atlas.html", ["atlas", "--store", ".protocolith", "--out", "atlas.html"]) + ledger = work / ".protocolith" / "ledger.jsonl" + ledger.write_text(ledger.read_text(encoding="utf-8").replace("PASSED_UNDER_PROTOCOL", "FAILED_UNDER_PROTOCOL", 1), encoding="utf-8") + steps.append(("sed -i 's/PASSED/FAILED/' .protocolith/ledger.jsonl # tamper", [], 0)) + step("protocolith verify-ledger", ["verify-ledger"]) + return steps + + +def load_font() -> ImageFont.FreeTypeFont: + for path in FONT_CANDIDATES: + if Path(path).exists(): + return ImageFont.truetype(path, FONT_SIZE) + raise SystemExit("no monospace font found; pass a path with --font") + + +def colour(line: str, code: int) -> tuple[int, int, int]: + if line.startswith("$"): + return TEXT + if code != 0: + return BAD + if line.startswith(("OK", "wrote", "frozen", "recorded", "issued", "ledger OK")): + return OK + return TEXT + + +def frame(font: ImageFont.FreeTypeFont, rows: list[tuple[str, tuple[int, int, int]]], cursor: bool) -> Image.Image: + img = Image.new("RGB", (WIDTH, HEIGHT), BG) + draw = ImageDraw.Draw(img) + draw.rectangle((0, 0, WIDTH, 30), fill=BAR) + for i, colr in enumerate(((240, 110, 110), (232, 176, 74), (110, 200, 140))): + draw.ellipse((14 + i * 20, 9, 26 + i * 20, 21), fill=colr) + draw.text((WIDTH // 2 - 60, 7), f"protocolith {VERSION}", font=font, fill=DIM) + visible = (HEIGHT - TOP - PAD) // LINE_H + y = TOP + for text, colr in rows[-visible:]: + if text.startswith("$ "): + draw.text((PAD, y), "$", font=font, fill=PROMPT) + draw.text((PAD + 20, y), text[2:], font=font, fill=TEXT) + else: + draw.text((PAD, y), text, font=font, fill=colr) + y += LINE_H + if cursor: + last = rows[-1][0] if rows else "" + x = PAD + 20 + int(font.getlength(last[2:])) if last.startswith("$ ") else PAD + draw.rectangle((x, y - LINE_H + 2, x + 9, y - 4), fill=TEXT) + return img + + +def build(steps: list[tuple[str, list[str], int]], font: ImageFont.FreeTypeFont) -> tuple[list[Image.Image], list[int]]: + frames: list[Image.Image] = [] + delays: list[int] = [] + rows: list[tuple[str, tuple[int, int, int]]] = [] + + def add(delay: int, cursor: bool = False) -> None: + img = frame(font, rows, cursor) + if frames and list(img.getdata()) == list(frames[-1].getdata()): + delays[-1] += delay + return + frames.append(img) + delays.append(delay) + + for index, (shown, out, code) in enumerate(steps): + for n in range(0, len(shown) + 1, 4): + rows.append((("$ " + shown[:n]), TEXT)) + add(40, cursor=True) + rows.pop() + rows.append(("$ " + shown, TEXT)) + add(350) + for line in out: + rows.append((line if len(line) <= 90 else line[:87] + "...", colour(line, code))) + add(70) + if code != 0: + rows.append((f"exit code {code}", BAD)) + add(1100 if index < len(steps) - 1 else 3200) + print(f"progress {int(100 * (index + 1) / len(steps))}%", flush=True) + return frames, delays + + +def main() -> int: + parser = argparse.ArgumentParser(description=__doc__.split("\n")[0]) + parser.add_argument("--out", default=str(ROOT / "docs" / "assets" / "protocolith" / "demo.gif")) + parser.add_argument("--font", default=None, help="path to a monospace font") + args = parser.parse_args() + if args.font: + FONT_CANDIDATES_LOCAL = (args.font,) + font = ImageFont.truetype(FONT_CANDIDATES_LOCAL[0], FONT_SIZE) + else: + font = load_font() + with tempfile.TemporaryDirectory() as tmp: + work = Path(tmp) + for name in ("protocol.json", "record.json", "results.txt"): + shutil.copy(ROOT / "examples" / "quickstart" / name, work / name) + steps = script(work) + frames, delays = build(steps, font) + palette = frames[0].quantize(colors=48, method=Image.Quantize.MEDIANCUT) + quantized = [f.quantize(palette=palette, dither=Image.Dither.NONE) for f in frames] + out = Path(args.out) + quantized[0].save(out, save_all=True, append_images=quantized[1:], duration=delays, loop=0, optimize=True, disposal=1) + print(f"wrote {out} frames={len(frames)} bytes={out.stat().st_size}") + return 0 + + +if __name__ == "__main__": + raise SystemExit(main())