Skip to content

Commit 9cf2c67

Browse files
committed
docs: rewrite README for low-friction onboarding and production usage
1 parent e2c66ad commit 9cf2c67

1 file changed

Lines changed: 139 additions & 88 deletions

File tree

README.md

Lines changed: 139 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,156 +1,207 @@
1-
# FACET Compiler (Rust)
1+
# FACET Compiler (`facet-fct`)
22

33
[![CI](https://github.com/rokoss21/facet-compiler/actions/workflows/ci.yml/badge.svg)](https://github.com/rokoss21/facet-compiler/actions/workflows/ci.yml)
44
[![Release](https://github.com/rokoss21/facet-compiler/actions/workflows/release.yml/badge.svg)](https://github.com/rokoss21/facet-compiler/actions/workflows/release.yml)
55
[![Latest Release](https://img.shields.io/github/v/release/rokoss21/facet-compiler?sort=semver)](https://github.com/rokoss21/facet-compiler/releases)
6-
[![FACET Spec](https://img.shields.io/badge/FACET-v2.1.3-0A66C2)](./FACET-v2.1.3-Production-Language-Specification.md)
6+
[![FACET Spec](https://img.shields.io/badge/spec-FACET%20v2.1.3-0A66C2)](./FACET-v2.1.3-Production-Language-Specification.md)
77
[![Rust](https://img.shields.io/badge/rust-stable-orange?logo=rust)](https://www.rust-lang.org/)
88
[![License](https://img.shields.io/badge/license-MIT%20OR%20Apache--2.0-blue)](./LICENSE-MIT)
99

10-
Deterministic compiler/runtime for **FACET v2.1.3** — a contract-first language for reliable AI request construction.
10+
Deterministic compiler and execution layer for **FACET v2.1.3**.
1111

12-
FACET Compiler turns `.facet` programs into validated, reproducible canonical payloads with strict typing, deterministic execution, policy guard enforcement, and provenance artifacts.
12+
`facet-fct` compiles `.facet` contracts into canonical, policy-aware AI request context with explicit failure semantics (`F*` codes), deterministic ordering, and bounded execution behavior.
1313

14-
## Why FACET Compiler
14+
## What You Get
1515

16-
Most AI stacks fail at the contract boundary: schemas drift, tool calls are weakly enforced, context packing is ad hoc, and behavior differs across runs/providers.
16+
- Deterministic pipeline: normalization -> resolution -> type check -> compute -> layout -> render
17+
- Strict type and placement checks (FTS)
18+
- Policy and guard fail-closed behavior (`F454`, `F455`)
19+
- Canonical JSON output + stable document and policy hashes
20+
- Spec-oriented examples and conformance suites in CI
1721

18-
FACET Compiler addresses this by enforcing the contract **before generation**:
22+
## Quick Start (2 Minutes)
1923

20-
- deterministic phases (resolution -> type check -> compute -> layout -> render)
21-
- strict FTS typing and placement rules
22-
- fail-closed policy/guard model (`F454`, `F455`)
23-
- canonical JSON with stable hashes for replay/audit
24-
- deterministic context budget behavior (Token Box Model)
24+
### 1) Build the compiler
2525

26-
## What This Repository Is
26+
```bash
27+
cargo build --release --bin facet-fct
28+
./target/release/facet-fct --version
29+
# fct 0.1.2
30+
```
31+
32+
### 2) Create a minimal contract
33+
34+
```facet
35+
@meta
36+
name: "hello"
2737
28-
This repository is the **Rust reference compiler implementation** for FACET v2.1.3.
38+
@context
39+
budget: 32000
2940
30-
- Language target: FACET v2.1.3 REC-PROD
31-
- Binary: `facet-fct` (`fct --version`)
32-
- Conformance tracker: [`docs/14-v2.1.3-migration-checklist.md`](./docs/14-v2.1.3-migration-checklist.md)
33-
- Canonical spec in this repo: [`FACET-v2.1.3-Production-Language-Specification.md`](./FACET-v2.1.3-Production-Language-Specification.md)
41+
@vars
42+
query: @input(type="string")
3443
35-
## Quick Start
44+
@system
45+
content: "You are a helpful assistant."
46+
47+
@user
48+
content: $query
49+
```
50+
51+
Save as `hello.facet` and create runtime input:
52+
53+
```json
54+
{ "query": "Hello FACET" }
55+
```
3656

37-
### 1) Build
57+
Save as `hello.input.json`.
58+
59+
### 3) Validate and run
3860

3961
```bash
40-
cargo build --release --bin facet-fct
41-
./target/release/facet-fct --version
62+
./target/release/facet-fct build --input hello.facet
63+
./target/release/facet-fct run --input hello.facet --runtime-input hello.input.json --exec --format pretty
4264
```
4365

44-
### 2) Validate a `.facet` file (Phases 1-2)
66+
## Installation
67+
68+
### Option A: Download release binary
69+
70+
From [Releases](https://github.com/rokoss21/facet-compiler/releases/latest):
71+
72+
- Linux: `facet-fct-linux-x86_64.tar.gz`
73+
- macOS (Intel): `facet-fct-macos-x86_64.tar.gz`
74+
- Windows: `facet-fct-windows-x86_64.zip`
75+
76+
Example (Linux/macOS):
4577

4678
```bash
47-
./target/release/facet-fct build --input examples/spec/01_minimal.facet
79+
tar -xzf facet-fct-*.tar.gz
80+
chmod +x facet-fct
81+
./facet-fct --version
4882
```
4983

50-
### 3) Run full pipeline (Phases 1-5)
84+
### Option B: Install from local source with Cargo
5185

5286
```bash
53-
./target/release/facet-fct run --input examples/spec/01_minimal.facet --exec --format pretty
87+
cargo install --path . --bin facet-fct
88+
facet-fct --version
5489
```
5590

56-
### 4) Run deterministic suites used in CI/release gates
91+
### Option C: Build from source
5792

5893
```bash
59-
./scripts/smoke_examples_spec.sh ./target/release/facet-fct
60-
./scripts/spec_matrix_examples.sh ./target/release/facet-fct
94+
git clone https://github.com/rokoss21/facet-compiler
95+
cd facet-compiler
96+
cargo build --release --bin facet-fct
6197
```
6298

63-
## CLI Overview
99+
## CLI Cheatsheet
64100

65101
```bash
66-
# Global help
67-
./target/release/facet-fct --help
102+
# Parse + resolve + type check
103+
facet-fct build --input file.facet
68104

69-
# Build: parse + resolve + validate
70-
./target/release/facet-fct build --input file.facet
105+
# Full execution (default mode: --exec)
106+
facet-fct run --input file.facet --exec
107+
facet-fct run --input file.facet --pure
71108

72-
# Run: full execution pipeline
73-
./target/release/facet-fct run --input file.facet --exec
74-
./target/release/facet-fct run --input file.facet --pure
109+
# Provide runtime @input values
110+
facet-fct run --input file.facet --runtime-input input.json --exec
75111

76-
# Test: execute @test blocks
77-
./target/release/facet-fct test --input file.facet --exec
112+
# Run @test blocks
113+
facet-fct test --input file.facet --exec
78114

79-
# Inspect: dump compiler internals
80-
./target/release/facet-fct inspect --input file.facet \
115+
# Dump internals
116+
facet-fct inspect --input file.facet \
81117
--ast ast.json --dag dag.json --layout layout.json --policy policy.json
82-
```
83-
84-
Runtime inputs for `@input(...)`:
85118

86-
```bash
87-
./target/release/facet-fct run \
88-
--input examples/spec/03_input_runtime.facet \
89-
--runtime-input examples/spec/03_input_runtime.input.json \
90-
--exec
119+
# Help
120+
facet-fct --help
121+
facet-fct run --help
91122
```
92123

93-
## Architecture (Compiler Pipeline)
124+
## Docs Map
94125

95-
| Phase | Purpose |
96-
| --- | --- |
97-
| Phase 1 | Normalize, parse, resolve `@import`, deterministic merge |
98-
| Phase 2 | Type checking, semantic validation, policy schema validation |
99-
| Phase 3 | Reactive compute (R-DAG), lens execution, input materialization |
100-
| Phase 4 | Deterministic context packing (Token Box Model) |
101-
| Phase 5 | Canonical JSON render + execution provenance emission |
126+
- Documentation portal: [rokoss21.github.io/facet-compiler](https://rokoss21.github.io/facet-compiler/)
127+
- Quick Start: [docs/01-quickstart.md](./docs/01-quickstart.md)
128+
- Execution Model: [docs/15-execution-model.md](./docs/15-execution-model.md)
129+
- Production Failure Scenario: [docs/16-production-scenario.md](./docs/16-production-scenario.md)
130+
- Integration Guide: [docs/18-integration-guide.md](./docs/18-integration-guide.md)
131+
- Spec-conformance checklist: [docs/14-v2.1.3-migration-checklist.md](./docs/14-v2.1.3-migration-checklist.md)
132+
- Language specification: [FACET-v2.1.3-Production-Language-Specification.md](./FACET-v2.1.3-Production-Language-Specification.md)
102133

103-
## Ecosystem and Methodology
134+
## Common Workflows
104135

105-
FACET Compiler is part of a broader engineering model around deterministic AI systems and measurable delivery:
136+
### Validate contracts in CI
106137

107-
- **FACET Standard**: language/specification source of truth
108-
[github.com/rokoss21/facet-standard](https://github.com/rokoss21/facet-standard)
109-
- **IOSM Specification**: methodology for controlled improvement cycles
110-
[github.com/rokoss21/IOSM](https://github.com/rokoss21/IOSM)
111-
- **IOSM CLI Runtime**: terminal execution runtime implementing IOSM
112-
[github.com/rokoss21/iosm-cli](https://github.com/rokoss21/iosm-cli)
113-
114-
How they connect conceptually:
115-
116-
- FACET defines the **deterministic contract layer** for AI behavior.
117-
- IOSM defines the **engineering methodology** (Improve -> Optimize -> Shrink -> Modularize) for iterative system quality improvement with artifacts/metrics.
118-
- iosm-cli operationalizes IOSM as a runtime for real repositories.
138+
```bash
139+
facet-fct build --input examples/spec/01_minimal.facet
140+
```
119141

120-
Together they align language contracts, execution control, and process governance.
142+
### Run deterministic example suites
121143

122-
## Quality Gates
144+
```bash
145+
./scripts/smoke_examples_spec.sh ./target/release/facet-fct
146+
./scripts/spec_matrix_examples.sh ./target/release/facet-fct
147+
```
123148

124-
Recommended local gate:
149+
### Local quality gate
125150

126151
```bash
127152
cargo fmt --all -- --check
128153
cargo clippy --all-targets --all-features -- -D warnings
129154
cargo test -q --workspace
130155
```
131156

132-
Release tag gate (`v*`) includes:
157+
## Integration Pattern (Brownfield)
133158

134-
- workspace tests
135-
- spec smoke/matrix runs
136-
- compliance report artifact generation
159+
Minimal-risk adoption path:
137160

138-
## Project Layout
161+
1. Keep your current provider SDK and business logic.
162+
2. Replace prompt assembly with `facet-fct run`.
163+
3. Keep strict response schema validation in host code.
164+
4. Add bounded retry/fallback policy in host runtime.
139165

140-
- `src/commands/*` — CLI commands (`build`, `run`, `test`, `inspect`, `codegen`)
141-
- `crates/fct-parser` — parser + normalization
142-
- `crates/fct-resolver` — import resolution + deterministic merge
143-
- `crates/fct-validator` — Phase 2 semantic/type/policy validation
144-
- `crates/fct-engine` — Phase 3/4 runtime + guard-aware compute
145-
- `crates/fct-render` — canonical payload/provenance render
146-
- `crates/fct-std` — standard lens registry/library
147-
- `docs/` — documentation and migration evidence
148-
- `examples/spec/` — ordered spec-conformance examples
166+
Detailed guide: [docs/18-integration-guide.md](./docs/18-integration-guide.md)
167+
168+
## Project Scope
169+
170+
FACET **does** guarantee deterministic contract compilation/execution boundaries.
171+
172+
FACET **does not** guarantee deterministic model generation output or correctness of external APIs.
173+
174+
## Repository Structure
175+
176+
- `src/commands/*` - CLI commands (`build`, `run`, `test`, `inspect`, `codegen`)
177+
- `crates/fct-parser` - parser and normalization
178+
- `crates/fct-resolver` - import resolution and deterministic merge
179+
- `crates/fct-validator` - type/semantic/policy checks
180+
- `crates/fct-engine` - compute/layout and guard-aware runtime behavior
181+
- `crates/fct-render` - canonical JSON and provenance output
182+
- `crates/fct-std` - standard lens registry
183+
- `docs/` - documentation and conformance evidence
184+
- `examples/spec/` - ordered specification scenarios
185+
186+
## Ecosystem
187+
188+
- FACET Standard: [github.com/rokoss21/facet-standard](https://github.com/rokoss21/facet-standard)
189+
- IOSM Methodology: [github.com/rokoss21/IOSM](https://github.com/rokoss21/IOSM)
190+
- IOSM CLI: [github.com/rokoss21/iosm-cli](https://github.com/rokoss21/iosm-cli)
191+
192+
## Contributing
193+
194+
- Contribution guide: [CONTRIBUTING.md](./CONTRIBUTING.md)
195+
- Issues: [github.com/rokoss21/facet-compiler/issues](https://github.com/rokoss21/facet-compiler/issues)
149196

150197
## Author
151198

152199
**Emil Rokossovskiy**
153200

201+
- GitHub: [github.com/rokoss21](https://github.com/rokoss21)
202+
- Email: [ecsiar@gmail.com](mailto:ecsiar@gmail.com)
203+
- Site: [facetcore.dev](https://facetcore.dev/)
204+
154205
## License
155206

156207
Dual-licensed under [MIT](./LICENSE-MIT) or [Apache-2.0](./LICENSE-APACHE).

0 commit comments

Comments
 (0)