Metadata-Version: 2.4
Name: factory-framework
Version: 0.4.0
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`) links plain-Markdown human goals directly to executable tests inside your repository. Stakeholders, engineers, and AI coding agents read the exact same contract, and verdicts come solely from executed checks — never manual checkboxes.

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

## Overview

Requirements rot in external wikis when tests verify implementation trivia instead of user outcomes and releases ship on guesswork.

`ff` organizes every domain inside `factory/` using implicit `<domain>` filenames:

- **Intents** (`intents/<domain>.md`) state **why** a capability matters for humans (User Stories recommended).
- **Specs** (`specs/<domain>.md`) define **what** the system guarantees (Given/When/Then or EARS recommended, with optional parent overview prose).
- **Checks** (`tests/*` + optional `checks/<domain>.yaml`) run real behavioral tests in any language and enforce standard JSON Schema metric bounds.
- **Proofs** (`proofs/<domain>.json`) record file 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 overview prose with zero `{#id}` anchors or `[x]` checkboxes. Folder and heading names wire `intent <- spec <- check` automatically, and splitting a proven spec into deeper child leaves stays frictionless.
- **Zero-boilerplate `pytest` & polyglot runners.** Use Python (`ff_record` built-in plugin or standard `record_property`), Bash, Node.js, Go, Java, or Rust in parallel with optional `$FF_RECORD` JSON output.
- **Standard metric rules & single source of truth.** Declare bounds once under `specs.<id>.metrics` using JSON Schema keywords (`minimum`, `maximum`, `const`, optional `unit`) — omit `checks/<domain>.yaml` completely when conventions suffice.
- **Anti-weakening governance.** Track breaking shifts in `factory/changes/YYYY-MM-DD_<slug>.md` (with optional `issue:` links); `ff verify --base` blocks silent deletion or weakening of proven specs and bounds.
- **Ready for humans and agents.** Export standalone HTML, Markdown, CSV, or JSONL reports with `ff export`, install the `/ff` skill from [`skills/ff/`](skills/ff/SKILL.md) (or `ff skill install`), and serve read-only context with `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
```

Include `[pytest]` for built-in pytest fixtures and `[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 tests/test_hello.py with built-in ff_record
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 script (or `pytest` check via `--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 rules, and latest evidence for any item.
- `ff lint` and `ff verify` — check headings, schemas, proof parity, and `--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 require fast, accurate checkout totals 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 metric bounds and script target in `factory/checks/checkout.yaml`:**

```yaml
version: 1
specs:
  spec_checkout_fast-totals_latency:
    metrics:
      p95_ms: { maximum: 50, unit: ms }
checks:
  test_checkout_fast_totals_latency:
    file: tests/check_checkout.py
```

**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 `pytest`? Omit `checks/checkout.yaml`'s `checks:` block, name your function `test_checkout_fast_totals_latency(ff_record: Recorder)`, and omit `file:` — `ff` discovers `tests/test_checkout.py` automatically via the built-in `pytest11` plugin.

**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/index.md) — architecture overview and core principles
- [Getting started](docs/getting-started.md) — installation, walkthrough, and `factory/` layout
- [Core concepts](docs/concepts.md) — leaf headings, parent prose, `$FF_RECORD`, `pytest`, and proofs
- [Configuration](docs/configuration.md) — `factory/ff.yaml`, optional `factory/checks/<domain>.yaml`, and runners
- [Commands](docs/commands.md) — all 12 CLI commands, lint rules (`FF001`–`FF012`, `FFR0`–`FFR4`), and schemas
- [Workflow](docs/workflow.md) — daily loop, change notes (`issue:`), `--base` CI gates, exports, and agent skills
- [AGENTS.md](AGENTS.md) · [CONTRIBUTING.md](CONTRIBUTING.md) · [CHANGELOG.md](CHANGELOG.md) · [LICENSE](LICENSE)
