Spec-first port of the Flask app (still on main): - schema.arch: signed arch-llm spec (single source of truth) - paste_bin/: generated FastAPI backend, verified 51/51 frozen owner tests, 92.5% coverage (build r3, 2026-11-18) - ui/: SPA + emitted OpenAPI contract (openapi.json + generated client.js); the app calls only window.PasteBinAPI - 7 old bugs fixed (file raw 500, silent expiry, AVI-as-webp, stripped content, limiter leak, trusted mimetype, stale tmp) - 62/62 live probe green; /health + JSON index added; JSON API Full report on the wiki: 'FastAPI port (arch-llm pipeline)'.
3.6 KiB
3.6 KiB
AGENTS.md
Orientation
- This repo is a spec-first project.
schema.arch(the signed arch-llm spec) is the single source of truth for the backend.paste_bin/is generated from it and verified against frozen owner tests;ui/client.js+ui/openapi.jsonare emitted from it (deterministic, no LLM). The SPA (ui/index.html,ui/app.js) is the only hand-maintained frontend code. - The old Flask implementation still lives on
main(single-fileapp.py). This branch (fastapi-port) replaces it. Port report: repo wiki, FastAPI port (arch-llm pipeline).
Hard rules
- Never hand-edit
paste_bin/*.py(exceptapp.py/glue if you understand the deterministic-glue invariant) orui/client.js/ui/openapi.json. Changeschema.arch(or the design session), re-sign, rebuild, re-emit. The next build overwrites hand-edits. - Never weaken or modify
tests/— they are owner-authored ground truth, frozen intotests/manifest.jsonfor every build. A failing test means the spec or the generation is wrong, not the test. - The SPA must call only
window.PasteBinAPI(the generated client). No hand-rolledfetch, no hardcoded endpoints, no second copy of error literals except the client-side-feedback mirror inui/app.js(keep it in sync withx-error-literalswhen re-emitting). - Keep the deployed UI same-origin: API paths + SPA + contract artifacts under one origin
via
ui/Caddyfile. - Paste IDs:
^[a-f0-9]{16}$. Validate before any filesystem access (path-traversal guard). - Image uploads: magic-byte validation (PNG/JPEG/GIF/BMP/WEBP-as-RIFF+
WEBP@8..11/ TIFF); SVG rejected. Mimetype derived server-side from extension — never trust the client's.
Commands
# backend
docker build -t paste-bin .
docker run -d --name paste-bin -p 18900:8080 -v paste-bin-data:/app/data paste-bin
pytest # 51 owner tests
# spec pipeline (requires the arch-llm CLI + the `paste-bin` design session)
archllm build --session paste-bin --out /tmp/paste-bin-build # regenerate backend (signoff-gated)
archllm openapi paste-bin --client --out ui # re-emit contract artifacts
Editing the spec: prefer the arch-llm design session (canvas / spec-ops), which owns
draft/schema.arch + draft/tests/; design paste-bin signoff after edits, then
rebuild. Editing schema.arch in this repo directly also works — just re-run the build
against it (archllm build schema.arch ...) and update signoff.yaml provenance.
Deploy notes
- Caddy 2.6.2 quirk: the
rootdirective is site-level (arootinside ahandleblock fails the Caddyfile adapter).ui/Caddyfileuses the flat idiom:handleper API path (reverse proxy) + site-levelfile_server. Run it from theui/directory (root * .resolves against CWD):cd ui && caddy run --config Caddyfile. - Backend container: uvicorn on
:8080inside, data under/app/data(store/metadata JSON,<id>.txttext content,uploads/image/file bytes). Volumepaste-bin-datapersists it;docker restart paste-binresets the in-process rate limiter (10 uploads / 60 s per IP) but not the data. - HEAD requests must work on API routes (Flask-compat; FastAPI needs an explicit
methods=["GET", "HEAD"]— the spec pins this).
Verified state (provenance)
- Build r3 (2026-11-18, qwen27b):
status=ok, 51/51 tests, 92.5% coverage, boot ok. - Signoff: schema
07e1c8b9e27e…/ testsce3bef1efa30…(seesignoff.yaml). - Live probe: 62/62 assertions green (headers, roundtrips, all 7 bug-fix cases, 400/404/413/429 with exact error strings, expiry-delete, restart persistence).