Template formal

From docxology/template · View interactive version

Template formal is an AI agent skill from the GitHub repository docxology/template. Strongly-typed multiagent ant-robot colony exemplar — ADTs, session-typed protocols, affine-discipline resource handles, storage-as-functor framing, Active-Inference-flavored decision loop, mypy-as-oracle negative controls.

How to use this skill

Skill file

template-formal

Project-scoped skill for the in-repo exemplar at

projects/templates/template_formal/. Load this when working inside the

project.

When to Use

src/template_formal/, or adding a new typed invariant.

subject is illegal-state-unrepresentable design or a decentralized

multiagent simulation.

every ADT/session-type/affine-handle claim needs both a

tests/mypy_fixtures/ negative-control fixture (mypy rejects the bad

program) and a runtime unit test (the discipline actually raises).

testing, no compile-time linear/dependent-type claims) still hold after

changes.

Quick Reference

# From the repository root
uv run pytest projects/templates/template_formal/tests --cov=projects/templates/template_formal/src --cov-fail-under=90
MYPYPATH=projects/templates/template_formal/src \
  uv run mypy --strict --explicit-package-bases --namespace-packages \
  projects/templates/template_formal/src
uv run python projects/templates/template_formal/scripts/02_run_analysis.py
uv run python scripts/pipeline/stage_03_render.py --project templates/template_formal
uv run python scripts/pipeline/stage_04_validate.py --project templates/template_formal
uv run python scripts/pipeline/stage_05_copy.py --project templates/template_formal

# Optional formal side-specs (non-default; require lake/elan + a Java runtime)
projects/templates/template_formal/scripts/check_formal_specs.sh

Pitfalls

has neither. Affine handles (TransactionHandle, protocol-phase objects)

are a runtime-guarded discipline — they raise on reuse, they are not

type-checked against reuse. Grep for "dependent type" and

"linear type" outside the manuscript's explicit limitations/scoping

section must return zero matches.

negative-control fixture under tests/mypy_fixtures/ proves what mypy

--strict rejects; a runtime unit test proves what actually raises. One

without the other is an unfalsifiable claim.

not in scripts/.

in-process fault-injectable bus, and real mypy --strict subprocess

invocations — never MagicMock/unittest.mock/mocker.patch.

and one protocol endpoint; the colony coordinator only ever holds the

public Agent/PheromoneField interfaces.

or formal/tla/ ship, they must be reachable from

scripts/check_formal_specs.sh — never a vestigial, unwired file.

Cross-refs

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.