Skip to main content

Python SDK for FAF (Foundational AI-context Format) - IANA-registered application/vnd.faf+yaml

Project description

faf-python-sdk

Python SDK for FAF — parse, validate, and score .faf files with the Mk4 Championship Scoring Engine. The foundation for gemini-faf-mcp.

PyPI Downloads Tests IANA

Media Type: application/vnd.faf+yaml (IANA registered)

What's New in v1.1.0

Mk4 Championship Scoring Engine — the same 33-slot scoring algorithm used by the Rust compiler and TypeScript CLI, now in Python. Same slots, same formula, same scores. Every FAF tool in every language now agrees on what 100% means.

  • score_faf() — Mk4 scoring with 21-slot Base or 33-slot Enterprise tiers
  • 100% parity with faf-wasm-sdk (Rust) and faf-cli (TypeScript)
  • 3 crash bugs fixed (malformed YAML, null project fields)
  • 175 tests including 88 WJTTC championship-grade tests (concurrency, adversarial input, security)

Why this matters: If you're building on FAF in Python — MCP servers, Gemini extensions, CI pipelines — your scores now match every other FAF tool exactly. No more "it scored 85% in the CLI but 60% in Python." One engine, one truth.

Installation

pip install faf-python-sdk

Quick Start

from faf_sdk import parse_file, score_faf

# Parse a .faf file
faf = parse_file("project.faf")
print(f"Project: {faf.project_name}")

# Score it with the Mk4 engine
with open("project.faf") as f:
    result = score_faf(f.read())

print(f"Score: {result.score}% {result.tier}")
print(f"Slots: {result.populated}/{result.total} populated")

Mk4 Scoring

The Mk4 engine scores .faf files by checking 21 universal slots (project metadata, human context, tech stack). Each slot is Populated, Empty, or Slotignored. The score is the percentage of active slots that are populated.

from faf_sdk import score_faf, LicenseTier

# Base scoring (21 slots)
result = score_faf(yaml_content)
print(result.score)      # 0-100
print(result.tier)       # Trophy/Gold/Silver/Bronze/Green/Yellow/Red
print(result.populated)  # slots with real data
print(result.active)     # total minus slotignored
print(result.slots)      # per-slot breakdown

# Enterprise scoring (33 slots — adds monorepo/infra)
result = score_faf(yaml_content, LicenseTier.ENTERPRISE)

Placeholder rejection: Values like "null", "unknown", "n/a", "Describe your project goal" are detected and scored as Empty — not Populated.

Slotignored: Set any slot to slotignored to exclude it from scoring. A backend-only project can mark frontend: slotignored and still reach 100%.

Parsing

from faf_sdk import parse, parse_file, stringify

# Parse from string or file
faf = parse(yaml_content)
faf = parse_file("project.faf")

# Typed access
print(faf.data.project.name)
print(faf.data.project.goal)
print(faf.data.stack.backend)
print(faf.data.human_context.who)

# Raw dict access
print(faf.raw["project"]["goal"])

# Convert back to YAML
yaml_str = stringify(faf)

Validation

from faf_sdk import validate

result = validate(faf)

if result.valid:
    print(f"Valid! Score: {result.score}%")
else:
    print("Errors:", result.errors)

print("Warnings:", result.warnings)

File Discovery

from faf_sdk import find_faf_file, find_project_root

# Find project.faf (walks up directory tree)
path = find_faf_file("/path/to/src")

# Find project root by markers (package.json, pyproject.toml, .git, etc.)
root = find_project_root()

API Reference

Function Returns Description
score_faf(yaml, tier?) Mk4Result Mk4 score (21 or 33 slots)
parse(content) FafFile Parse YAML string
parse_file(path) FafFile Parse from file path
validate(faf) ValidationResult Structure validation + warnings
stringify(data) str Convert back to YAML
find_faf_file(dir?) str | None Find project.faf in tree
find_project_root(dir?) str | None Find project root

FAF Ecosystem

Package Platform Registry
faf-python-sdk Python foundation PyPI
gemini-faf-mcp Google Gemini PyPI
claude-faf-mcp Anthropic npm + MCP #2759
grok-faf-mcp xAI npm
faf-cli CLI npm

Links

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

faf_python_sdk-1.1.1.tar.gz (36.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

faf_python_sdk-1.1.1-py3-none-any.whl (15.2 kB view details)

Uploaded Python 3

File details

Details for the file faf_python_sdk-1.1.1.tar.gz.

File metadata

  • Download URL: faf_python_sdk-1.1.1.tar.gz
  • Upload date:
  • Size: 36.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for faf_python_sdk-1.1.1.tar.gz
Algorithm Hash digest
SHA256 a1fdc73902a3aac874b299a55b98bfb070d3f34bdf9b3af647f8af489491f26d
MD5 32b702c85512f27a245b4c12cd1cbb04
BLAKE2b-256 13b2a4996f41b9bf1c2747a83aa1e5c7f910953173344340176323efa2b9a67b

See more details on using hashes here.

Provenance

The following attestation bundles were made for faf_python_sdk-1.1.1.tar.gz:

Publisher: pypi.yml on Wolfe-Jam/faf-python-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file faf_python_sdk-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: faf_python_sdk-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 15.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for faf_python_sdk-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f45e07fcc6fa2ca1c45ebcb071d150d1f4bef4086cee1c949d1bf6832b1fa1c8
MD5 2e394125b52b0b2dbf81ca7a56d24197
BLAKE2b-256 5cd2bdb02b7b4b692a79b0192f1a2bd3b5d363be47df7187842d73edfe7ffe11

See more details on using hashes here.

Provenance

The following attestation bundles were made for faf_python_sdk-1.1.1-py3-none-any.whl:

Publisher: pypi.yml on Wolfe-Jam/faf-python-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page