一种系统编程语言,优先考虑可验证的正确性、确定性和性能。
通用系统语言及生产工具链,具有默认内存安全的已发布安全语言表面、可验证的正确性、确定性执行以及内置的以重放优先的调试功能。
fzy 提供一个生产 CLI fz,用于编译工作流和确定性验证。正确性、确定性、重放、事件工件和生产证据是正常工作流的一部分,而非事后补救。如需快速了解语言的可视化概览,请在浏览器中打开随附的 FZL 展示:open fzl-showcase.html。关于为何选择它的简短论证,请参阅 WHYFZY.md。
仓库架构策略在内部是类型化的,在真实边界处仅使用 JSON。
INSTALL.mdUSAGE.mdWHYFZY.mdCODE.mddocs/production-workflow-v1.mddocs/gpu-v1.mddocs/system-safety-trust-model-v1.mddocs/unsafe-contract-authoring-v1.mddocs/language-stability-v1.mddocs/workspace-policy-v1.mddocs/operational-insights-v1.mdfzyllm:saint0x/fzyllm推荐安装方式:
curl -fsSL https://raw.githubusercontent.com/saint0x/fzy/main/install.sh | sh
这会安装 fz 到 ~/.local/bin,如需自动更新 PATH,并验证安装(fz version 和 fz env)。
源码回退方式:
curl -fsSL https://raw.githubusercontent.com/saint0x/fzy/main/install.sh | sh -s -- --from-source
想要最快的概述?用 open fzl-showcase.html 打开 fzl-showcase.html,快速浏览 WHYFZY.md 了解产品论证,然后将下面的示例作为紧凑的可执行草稿。
use core.log;
use core.path;
use core.process;
use core.time;
enum Mode {
Fast,
Safe,
}
trait Scorer {
fn score(endpoint: Url) -> i32;
}
struct HttpScorer {}
impl Scorer for HttpScorer {
fn score(endpoint: Url) -> i32 {
discard endpoint;
return 7;
}
}
struct Config<TEndpoint> {
retries: i32,
endpoint: TEndpoint,
mode: Mode,
}
fn weight(mode: Mode) -> i32 {
match mode {
Mode::Fast => return 3,
Mode::Safe => return 1,
_ => return 1,
}
}
async fn boost(v: i32) -> i32 {
checkpoint()
return v + 1
}
fn normalize<T: Scorer>(cfg: Config<Url>) -> i32 {
return weight(cfg.mode) + T.score(cfg.endpoint)
}
async fn run_once(cfg: Config<Url>) -> i32 {
let base = normalize<HttpScorer>(cfg)
return await boost(base)
}
fn main() -> i32 {
let cfg = Config { retries: 4, endpoint: url.parse("https://example.test"), mode: Mode::Fast }
let now = time.now()
let out_path = path.join("tmp", "score.log")
let mode = process.argv_or(1, "showcase")
let score = normalize<HttpScorer>(cfg)
log.info("snippet.run", out_path)
discard mode
discard run_once
if score + now > 0 then return score
return score
}
更广泛的语言覆盖请使用 CODE.md、examples/ 以及浏览器友好的 FZL 展示。
框架包遵循普通包规则:在 fozzy.toml 的 [deps] 下声明它们,然后在源码中用 use fzbounds;、use fzweb; 等包名导入。直接源码检查(例如 fz check src/services/mod.fzy --json)现在通过所属包上下文进行验证,因此依赖导入和同级模块的行为与完整项目检查中相同。
fz:编译器 CLI,用于构建、运行、测试、验证、文档、IR、RPC、头文件、ABI 检查等fz fmt、fz doc gencrates/parser、crates/ast、crates/hir、crates/fircrates/verifiercrates/runtimecrates/drivertests/*.fozzy.json目前已实现并验证:
alloc(...) / free(...) 选择加入的手动内存管理unsafe { ... } 孤岛中都有真正的运行时 defer 语义,从而强制确定性清理而非仅仅文档记录alloc(...) / free(...) 流程和验证器可见的生命周期检查fifo、random、coverage_guidedrpc_send、rpc_recv、rpc_deadline、rpc_cancelfzy 目前已设定支持以下生产声明:
alloc(...) / free(...) 保持在安全代码中fzweb 以及将会话/cookie/auth 流程保持在支持的运行时表面内的安全原语,实现生产级 Web/服务覆盖另见:
docs/system-safety-trust-model-v1.mddocs/production-memory-model-v1.mddocs/production-workflow-v1.mdcargo check --workspace
cargo test --workspace
# 在当前目录或目标路径中搭建项目
fz init [path] [--name package] [--template minimal|rust|ts] [--with run,fuzz,explore,memory,host|all] [--force]
# 构建源码/项目
fz build [path] [--release] [--lib] [--threads N] [--backend llvm|cranelift] [--pgo-generate|--pgo-use file] [-l lib] [-L path] [-framework name] [--json]
# 运行源码/项目或 .fozzy 场景
fz run [path] [--det] [--strict-verify] [--seed N] [--record path] [--host-backends] [--backend llvm|cranelift] [--max-seconds N] [--exit-on-healthcheck URL] [--smoke-http URL] [-- <args>] [--json]
# 测试源码/项目或 .fozzy 场景
fz test [path] [--det] [--strict-verify] [--sched fifo|random|coverage_guided] [--seed N] [--record path] [--backend llvm|cranelift] [--filter substring] [--json]
# 验证/检查/文档/工具
fz fmt [path ...] [--check] [--json]
fz check [path] [--json]
fz verify [path] [--json]
fz lint [path] [--tier production|pedantic|compat] [--json]
fz dx-check [project] [--strict] [--json]
fz spec-check [--json]
fz emit-ir [path] [--json]
fz perf [--artifact artifacts/bench_core_rust_vs_fzy.json] [--json]
fz stability-dashboard [--json]
fz parity [path] [--seed N] [--json]
fz audit unsafe [path] [--workspace] [--json]
fz vendor [project] [--json]
fz abi-check <current.abi.json> --baseline <baseline.abi.json> [--json]
fz debug-check [path] [--json]
fz pgo merge [path] [--out file] [--json]
fz lsp diagnostics [path] [--json]
fz lsp definition <path> <symbol> [--json]
fz lsp hover <path> <symbol> [--json]
fz lsp rename <path> <from> <to> [--json]
fz lsp smoke [path] [--json]
fz lsp serve [--path <workspace>] [--json]
fz map suites [--root dir] [--scenario-root dir] [--profile pedantic|production|compat] [--json]
fz artifacts ls latest [--json]
fz report show latest [--format json|text] [--json]
fz usage [--json]
fz env [--json]
fz version [--json]
fz inspect stdlib <module> [--json]
fz schema [--json]
fz validate <scenario> [--json]
fz trace verify <trace> [--strict] [--json]
fz replay <trace> [--json]
fz shrink <trace> [--json]
fz ci <trace> [--json]
fz trace-native <trace.fozzy> [--out path] [--json]
# FFI / RPC / 文档输出
fz headers [path] [--out path] [--json]
fz rpc gen [path] [--out-dir dir] [--json]
fz doc gen [path] [--format json|html|markdown] [--out path] [--reference path] [--json]
VS Code 集成位于 tooling/vscode,目标为 fz lsp serve。
运行时默认值和暴露的行为:
127.0.0.18787listen 时打印有效的绑定目标.env 或 FZ_DOTENV_PATH 在环境/HTTP 操作之前加载一次log.set_json(1) 选择加入core.process、core.term、core.thread、core.log、core.text、core.io、core.path 和 core.util使用 fz test <file.fzy> --det --record artifacts/name.trace.json --json 时,驱动会生成:
*.trace.json:确定性执行跟踪*.timeline.json:调度决策*.report.json:摘要、发现和失败分组*.explore.json:调度候选和场景优先级*.shrink.json:确定性收缩提示*.scenarios/ 和 *.scenarios.json:生成的语言原生场景*.manifest.json:包含主场景路径的工件映射规范编写拆分:
core.process、core.term、core.text:argv 和终端 UXcore.log:日志策略和结构化输出core.io、core.path:文件系统发现和路径组装proc.*:子进程执行示例:
use core.log;
use core.process;
use core.term;
use core.text;
fn main() -> i32 {
let mode = process.argv_or(1, "serve")
discard log.set_sink_name("stderr")
discard log.set_level_name("warn")
discard term.transcript_kv("mode", mode, 8)
if term.is_interactive() == 1 {
discard term.eprint_line(str.concat("interactive=", str.from_i32(term.is_interactive())))
}
discard term.print_line(text.indent("ready\nwaiting", " "))
return 0
}
EOF 是显式的:
term.read_line() == "" 且 term.stdin_eof() == 0term.read_line() == "" 且 term.stdin_eof() == 1对于严肃的 CLI/运行时工作,当精确的终端行为至关重要时,请使用编译器集成的启动器和构建的二进制文件。
cranelift 和 llvm--backend,然后 FZ_NATIVE_BACKEND,最后配置文件默认值dev -> cranelift,release -> llvmfozzy.lock 漂移检查fz vendor [project] --json 刷新锁定状态fozzy.lock 和 vendor/fozzy-vendor.jsondocs/dependency-locking-v1.mdfz abi-check 强制:
允许添加性导出。
docs/c-interop-production-v1.mdpubext c fn 需要 #[ffi_panic(abort|error)]ext unsafe c fn,并且仅在其内部调用 unsafe { ... }fz build --lib 生成静态/共享库以及可安装的头文件和 ABI 清单
--backend llvm 会被拒绝并带有一个迁移提示unsafe fn 和 unsafe { ... } 成为第一类公民fz audit unsafe --workspace --json 生成 .fz/unsafe-map.workspace.json、.fz/unsafe-docs.workspace.json、.fz/unsafe-docs.workspace.md 和 .fz/unsafe-docs.workspace.htmlreason、invariant、owner、scope、risk_class 和 proof_ref 由编译器生成,并由策略驱动fozzy.toml 中使用以下序列进行严格的置信度验证:
# 1) 首先进行确定性审计
fz doctor --deep --scenario tests/run.pass.fozzy.json --runs 5 --seed 42 --json
# 2) 严格的确定性测试
fz test --det --strict-verify tests/run.pass.fozzy.json tests/memory.pass.fozzy.json --json
# 3) 记录一个真实跟踪
fz run tests/run.pass.fozzy.json --det --record artifacts/trace.fozzy --json
# 4) 验证重放流水线
fz trace verify artifacts/trace.fozzy --strict --json
fz replay artifacts/trace.fozzy --json
fz ci artifacts/trace.fozzy --json
# 5) 主机支持置信通道
fz run tests/host.pass.fozzy.json --host-backends --json
严格发布门控:
./scripts/ship_release_gate.sh
这包括通过 scripts/safety_claim_integrity_gate.py 进行的发布阻塞文档声明完整性检查。
cat >/tmp/demo.fzy <<'FZY'
test "alpha" {}
test "beta" nondet {}
rpc Ping(req: PingReq) -> PingRes;
async fn worker() -> i32 {}
fn main() -> i32 {
timeout(1)
return 0
}
FZY
fz test /tmp/demo.fzy --det --sched random --seed 13 --record artifacts/demo.trace.json --json
直接检查生成的原生测试工件:
artifacts/demo.trace.native.trace.jsonartifacts/demo.trace.report.jsonartifacts/demo.trace.timeline.json(当启用丰富工件时)artifacts/demo.trace.manifest.json原生测试清单是记录的原生测试运行的一等 trace verify / replay / ci 输入。它们不是场景输入,不参与场景 shrink。
所有附带的示例都遵循 v1 叙事 DX 约定:
src/main.fzy 仅用于编排,并将 fn main 放在最后src/tests/* 下mod.fzy可用项目:
examples/agent_runtimeexamples/context_runtimeexamples/minimal_runtimeexamples/service_appexamples/fullstackexamples/robust_cliexamples/live_server验证和项目流程:
fz dx-check examples/fullstack --strict --json
fz check examples/fullstack --json
fz build examples/fullstack --backend cranelift --json
fz build examples/fullstack --release --backend llvm --json
fz run examples/fullstack --backend cranelift --json
fz test examples/fullstack --det --seed 41 --backend llvm --json
fz headers examples/fullstack --json
fz abi-check examples/fullstack/include/fullstack.abi.json --baseline examples/fullstack/include/fullstack.abi.json --json
fz dx-check examples/robust_cli --strict --json
fz build examples/robust_cli --backend cranelift --json
fz run examples/robust_cli --backend llvm --json
fz test examples/robust_cli --det --seed 55 --backend cranelift --json
fz dx-check examples/live_server --strict --json
fz build examples/live_server --backend cranelift --json
fz run examples/live_server --backend llvm --json
fz test examples/live_server --det --seed 77 --backend cranelift --record artifacts/live_server.stats.trace.json --rich-artifacts --json
fz run tests/live.server.interhttp.fozzy.json --host-backends --json
如果你是从检出贡献,而不是安装发布版本,请使用 cargo run -q -p fz -- <args> 作为仅源码回退方式。
在实现过程中保持以下版本化交付文档的更新:
PLAN.mdFEATURES-TO-SHIP.mdtest 块生成语言原生场景mod 声明递归加载多文件模块pubext c fn 签名生成 C 头文件fz rpc gen 生成 RPC 模式、客户端和服务器存根core.crypto 和 core.security 提供的生产加密/安全表面,包括安全随机、哈希、HMAC、常量时间比较和 URL 安全编码fzweb 生产级 Web 框架模块,用于应用路由、cookie、会话、多部分上传、持久化、SSE、WebSocket 和 OpenAPI 导出fz run 直接执行原生输出,支持实时文本流或 JSON 捕获python3 scripts/direct_memory_architecture_gate.pypython3 scripts/direct_memory_perf_gate.pycore.gpu 的生产 GPU 表面,在 Apple 上支持实时 Metal 执行,并共享 spirv/nvptx 适配器约定core.crypto 和 core.security 涵盖安全随机、摘要、HMAC、URL 安全编码和常量时间比较,用于生产级认证/会话流程fzweb 提供按关注点分组的内置框架模块以及内置路由,用于健康检查、就绪、指标、检查、搜索、cookie、会话、上传、事件、WebSocket、项目 CRUD、OpenAPI 和静态资产