Metadata-Version: 2.4
Name: factory-framework
Version: 0.3.1
Summary: Factory Framework (ff) links human intents and specs to parallel executable checks, records validated metrics, and exports stakeholder-ready proofs.
Keywords: ai,ai-agents,agent-skills,agents-md,fitness-functions,local-first,mcp,model-context-protocol,python,software-engineering,software-factory,spec-driven-development,traceability
Author: Médéric Hurier
License-Expression: MIT
License-File: LICENSE
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Operating System :: MacOS
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Software Development :: Quality Assurance
Classifier: Topic :: Software Development :: Testing
Classifier: Typing :: Typed
Requires-Dist: jsonschema>=4.26.0,<5
Requires-Dist: markdown>=3.11,<4
Requires-Dist: pyyaml>=6.0.3,<7
Requires-Dist: rich>=15.0.0,<16
Requires-Dist: mcp>=2.3,<3 ; extra == 'mcp'
Requires-Dist: pydantic>=2.14,<3 ; extra == 'mcp'
Requires-Dist: uvicorn>=0.54,<1 ; extra == 'mcp'
Requires-Dist: pytest>=9.1.1,<10 ; extra == 'pytest'
Requires-Python: >=3.14
Project-URL: Changelog, https://fmind.github.io/factory-framework/changelog/
Project-URL: Documentation, https://fmind.github.io/factory-framework/
Project-URL: Issues, https://github.com/fmind/factory-framework/issues
Project-URL: Repository, https://github.com/fmind/factory-framework
Project-URL: Security, https://github.com/fmind/factory-framework/security/policy
Provides-Extra: mcp
Provides-Extra: pytest
Description-Content-Type: text/markdown

<p align="center">
  <img
    src="docs/assets/factory-framework.svg"
    alt="Factory Framework mirrored F | F logo"
    width="128"
    height="128"
  >
</p>

# Factory Framework

**Turn plain-Markdown requirements into proven software.**

[![CI](https://github.com/fmind/factory-framework/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/fmind/factory-framework/actions/workflows/ci.yml) [![Python 3.14+](https://img.shields.io/badge/python-3.14%2B-174EA6)](pyproject.toml) [![License: MIT](https://img.shields.io/badge/license-MIT-174EA6)](LICENSE)

Factory Framework (`ff`) connects human product goals to automated tests in plain files inside your repository. Product owners, engineers, and AI coding agents work from one source of truth, and proof reports come from real executions — never manual checkboxes.

[Overview](#overview) · [Benefits](#benefits) · [Installation](#installation) · [Usage](#usage) · [Example](#example) · [Documentation](#documentation)

## Overview

Teams lose alignment when requirements live in wikis, tests check implementation details instead of user outcomes, and nobody knows what is truly proven.

`ff` organizes every domain inside `factory/` with 1-to-1 file symmetry:

- **Intents** (`intents/<domain>.md`) capture **why** a capability matters for humans (User Stories recommended).
- **Specs** (`specs/<domain>.md`) define **what** the system guarantees (Given/When/Then or EARS recommended).
- **Checks** (`checks/<domain>.yaml` + `tests/*`) map specs and numeric bounds to real tests in any language.
- **Proofs** (`proofs/<domain>.json`) record digests, measured metrics, evidence, and computed `PROVEN`, `FAILING`, `UNPROVEN`, `UNCLEAR`, or `ERROR` verdicts.

<p align="center">
  <a href="docs/assets/how-it-works.png">
    <img
      src="docs/assets/how-it-works.png"
      alt="How Factory Framework links Markdown intents and specs to parallel tests and domain proofs"
      width="960"
    >
  </a>
</p>

## Benefits

- **Plain Markdown, zero clutter.** Write pure headings and prose with zero `{#id}` anchors or `[x]` checkboxes. Folder and heading names wire `intent <- spec <- check` automatically.
- **Computed verdicts you can trust.** A spec turns `PROVEN` only when its checks execute, exit `0`, and satisfy every metric bound declared in `checks/<domain>.yaml`.
- **Polyglot by default.** Run Python, Bash, Node.js, Java, Go, or Rust tests in parallel. Scripts can optionally write JSON metrics and evidence to `$FF_RECORD`, or keep using plain exit codes.
- **Change accountability built in.** Document contract shifts in `factory/changes/YYYY-MM-DD_<slug>.md` or labeled GitHub issues; `ff verify --base` blocks silent weakening of proven specs, checks, or thresholds.
- **Built for both humans and coding agents.** Export polished HTML, Markdown, CSV, or JSONL summaries with `ff export`, and equip agents with `/ff` (`ff skill install`) and optional read-only `ff mcp`.

## Installation

Requires Python 3.14+ on Linux or macOS with [`uv`](https://docs.astral.sh/uv/getting-started/installation/):

```bash
uv tool install --python 3.14 factory-framework
```

Add optional extras when needed (`[pytest]` for pytest test-suite helpers, `[mcp]` for the read-only MCP server):

```bash
uv tool install --python 3.14 "factory-framework[pytest,mcp]"
```

## Usage

Scaffold a starter contract, run checks, verify reproducibility, and export a report:

```bash
ff init --example          # Add --pytest to scaffold pytest fixtures instead of a standalone script
ff run
ff status
ff verify --strict
ff export -f html -o proof-report.html
```

Everyday commands at a glance:

- `ff init [--example] [--pytest]` — create `factory/` with a zero-dependency starter check (or `pytest` fixtures with `--pytest`).
- `ff status` and `ff ls --tree` — inspect domain verdicts and trace links from intents to specs and checks.
- `ff show <id>` — read full statements, metric bounds, and latest recorded evidence for any item.
- `ff lint` and `ff verify` — check domain symmetry (`FF001`–`FF012`), re-run tests, and enforce `--base` anti-weakening rules (`FFR0`–`FFR4`).
- `ff export -f html|md|csv|jsonl` — share proof reports with stakeholders.
- `ff skill install` and `ff mcp` — equip coding agents with `/ff` workflow instructions and read-only contract inspection.

## Example

Suppose you want fast, accurate checkout pricing in domain `checkout`.

**1. State why in `factory/intents/checkout.md`:**

```markdown
# Checkout

## Fast Totals

As a shopper, I want accurate order totals immediately, so that slow pricing never delays my purchase.
```

**2. State what in `factory/specs/checkout.md`:**

```markdown
# Checkout

## Fast Totals

### Latency

Given a cart with regional shipping rules, when checkout totals are requested, then pricing, tax, and totals return in 50 ms or less.
```

**3. Declare bounds and check targets in `factory/checks/checkout.yaml`:**

```yaml
version: 1
domain: checkout

checks:
  check_checkout_fast-totals_latency:
    file: tests/check_checkout.py
    metrics:
      p95_ms: { max: 50, precision: 0, unit: ms }
```

**4. Prove it with a behavioral check in `factory/tests/check_checkout.py`:**

```python
import json, os
from pathlib import Path

elapsed_ms, body = call_checkout(items=3, region="EU")
assert body["tax"] > 0 and body["total"] > body["subtotal"]

if record_path := os.environ.get("FF_RECORD"):
    Path(record_path).write_text(
        json.dumps(
            {
                "summary": "Checkout returned tax and totals under 50 ms",
                "metrics": {"p95_ms": elapsed_ms},
                "evidence": [f"p95_ms={elapsed_ms}", f"total={body['total']}"],
            }
        ),
        encoding="utf-8",
    )
```

Using Bash, JavaScript, Go, Java, or `pytest`? Point `file:` at `.sh`/`.mjs`/`.js` scripts, use `argv: [go, test, ./...]` for compiled binaries, or pass `--pytest` on `ff init` for `ff_record` pytest fixtures.

**5. Run and inspect the verdict:**

```bash
ff run
ff status
```

```text
Factory: shop-api  |  Proofs: fresh  |  Gate: PASSED
Intents: 1/1 proven  |  Specs: 1/1 proven  |  Checks: 1/1 passing
```

Explore [`examples/demo-service/`](examples/demo-service/README.md) for a multi-domain `pytest` + Bash project and [`examples/checks/`](examples/checks/) for reusable check recipes.

## Documentation

- [Documentation home](docs/docs/index.md) — architecture overview and core principles
- [Getting started](docs/docs/getting-started.md) — installation, walkthrough, and `factory/` layout
- [Core concepts](docs/docs/concepts.md) — `<domain>` symmetry, leaf IDs, `$FF_RECORD`, proofs, and changes
- [Configuration](docs/docs/configuration.md) — `factory/ff.yaml`, `factory/checks/<domain>.yaml`, and polyglot runners
- [Commands](docs/docs/commands.md) — full CLI reference, rules (`FF001`–`FF012`, `FFR0`–`FFR4`), schemas, and MCP
- [Workflow](docs/docs/workflow.md) — daily loop, `--base` CI gates, exports, and `/ff` agent setup
- [AGENTS.md](AGENTS.md) · [CONTRIBUTING.md](CONTRIBUTING.md) · [CHANGELOG.md](CHANGELOG.md) · [LICENSE](LICENSE)
