chore: import upstream snapshot with attribution
CI / Deep Native Runtime Cases (1/6) (push) Has been skipped
CI / Native Preflight (push) Failing after 1s
CI / Native Runtime Cases (1/2) (push) Failing after 0s
CI / Native Runtime Cases (2/2) (push) Failing after 1s
CI / Native Metadata Reports (push) Failing after 0s
CI / Native Direct Backend Artifacts (push) Failing after 0s
CI / Native Sanitizer Smoke (push) Failing after 1s
CI / Command Contract Snapshots (push) Failing after 1s
CI / Deep Conformance Suite (push) Has been skipped
CI / Graph Build Perf (push) Failing after 1s
CI / Deep Native Preflight (push) Has been skipped
CI / Deep Native Runtime Cases (2/6) (push) Has been skipped
CI / Deep Native Runtime Cases (3/6) (push) Has been skipped
CI / Conformance Suite (push) Failing after 1s
CI / Workspace Checks (push) Failing after 0s
CI / Deep Native Runtime Cases (5/6) (push) Has been skipped
CI / Deep Native Runtime Cases (6/6) (push) Has been skipped
CI / Deep Native Runtime Cases (4/6) (push) Has been skipped
CI / Deep Graph Build Perf (push) Has been skipped

This commit is contained in:
wehub-resource-sync
2026-07-13 12:29:30 +08:00
commit e7738de6d2
1723 changed files with 216139 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
*.graph diff=zero-graph
+370
View File
@@ -0,0 +1,370 @@
name: CI
on:
pull_request:
push:
branches:
- main
schedule:
- cron: "17 9 * * *"
workflow_dispatch:
inputs:
validation_depth:
description: Validation depth to run
required: true
default: fast
type: choice
options:
- fast
- deep
permissions:
contents: read
jobs:
conformance-suite:
name: Conformance Suite
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 24
- name: Enable pnpm
run: |
corepack enable
corepack prepare pnpm@11.1.3 --activate
- name: Install pinned Zig
run: bash scripts/install-zig.sh
- run: pnpm install --frozen-lockfile
- name: Conformance suite
env:
ZERO_VALIDATION_PHASES: graph-input-policy,native-contracts,provenance-guardrails,type-core-smoke,mir-verifier-smoke,program-graph-smoke,canonical-text-smoke,examples-gate,conformance-run
ZERO_VALIDATION_JOBS: "4"
ZERO_CONFORMANCE_CHECK_JOBS: "4"
run: pnpm run conformance:local
native-preflight:
name: Native Preflight
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 24
- name: Enable pnpm
run: |
corepack enable
corepack prepare pnpm@11.1.3 --activate
- name: Install pinned Zig
run: bash scripts/install-zig.sh
- run: pnpm install --frozen-lockfile
- name: Native preflight
env:
ZERO_NATIVE_TEST_PHASES: preflight
ZERO_NATIVE_TEST_SCOPE: fast
run: pnpm run native:test:local
native-runtime-cases:
name: Native Runtime Cases (${{ matrix.shard }}/2)
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
shard: [1, 2]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 24
- name: Enable pnpm
run: |
corepack enable
corepack prepare pnpm@11.1.3 --activate
- name: Install pinned Zig
run: bash scripts/install-zig.sh
- run: pnpm install --frozen-lockfile
- name: Native tests
env:
ZERO_NATIVE_TEST_PHASES: cases
ZERO_NATIVE_TEST_SCOPE: fast
ZERO_NATIVE_TEST_SHARD: "${{ matrix.shard }}/2"
run: pnpm run native:test:local
native-metadata-reports:
name: Native Metadata Reports
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 24
- name: Enable pnpm
run: |
corepack enable
corepack prepare pnpm@11.1.3 --activate
- name: Install pinned Zig
run: bash scripts/install-zig.sh
- run: pnpm install --frozen-lockfile
- name: Native metadata and reports
env:
ZERO_NATIVE_TEST_PHASES: metadata-and-reports
run: pnpm run native:test:local
native-direct-backend-artifacts:
name: Native Direct Backend Artifacts
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 24
- name: Enable pnpm
run: |
corepack enable
corepack prepare pnpm@11.1.3 --activate
- name: Install pinned Zig
run: bash scripts/install-zig.sh
- run: pnpm install --frozen-lockfile
- name: Native direct backend artifacts
env:
ZERO_NATIVE_TEST_PHASES: direct-backend-artifacts
run: pnpm run native:test:local
native-sanitizer-smoke:
name: Native Sanitizer Smoke
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 24
- name: Enable pnpm
run: |
corepack enable
corepack prepare pnpm@11.1.3 --activate
- name: Install pinned Zig
run: bash scripts/install-zig.sh
- name: Native sanitizer smoke
run: pnpm run native:sanitize
command-contract-snapshots:
name: Command Contract Snapshots
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 24
- name: Enable pnpm
run: |
corepack enable
corepack prepare pnpm@11.1.3 --activate
- run: pnpm install --frozen-lockfile
- name: Install pinned Zig
run: bash scripts/install-zig.sh
- name: Build native compiler
run: make -C native/zero-c
- name: Command contract snapshots
run: pnpm run command-contracts:local
graph-build-perf:
name: Graph Build Perf
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 24
- name: Enable pnpm
run: |
corepack enable
corepack prepare pnpm@11.1.3 --activate
- run: pnpm install --frozen-lockfile
- name: Graph build perf report
env:
ZERO_GRAPH_BUILD_PERF_CASES: hello-artifact,stdlib-heavy-artifact
run: |
mkdir -p .zero
set +e
pnpm run graph:perf:budgets > .zero/graph-build-perf.json
status=$?
cat .zero/graph-build-perf.json
exit $status
deep-conformance-suite:
name: Deep Conformance Suite
if: ${{ github.event_name == 'schedule' || github.event.inputs.validation_depth == 'deep' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 24
- name: Enable pnpm
run: |
corepack enable
corepack prepare pnpm@11.1.3 --activate
- name: Install pinned Zig
run: bash scripts/install-zig.sh
- run: pnpm install --frozen-lockfile
- name: Deep conformance suite
env:
ZERO_VALIDATION_JOBS: "4"
ZERO_CONFORMANCE_CHECK_JOBS: "4"
run: pnpm run conformance:local
deep-native-preflight:
name: Deep Native Preflight
if: ${{ github.event_name == 'schedule' || github.event.inputs.validation_depth == 'deep' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 24
- name: Enable pnpm
run: |
corepack enable
corepack prepare pnpm@11.1.3 --activate
- name: Install pinned Zig
run: bash scripts/install-zig.sh
- run: pnpm install --frozen-lockfile
- name: Deep native preflight
env:
ZERO_NATIVE_TEST_PHASES: preflight
ZERO_NATIVE_TEST_SCOPE: deep
run: pnpm run native:test:local
deep-native-runtime-cases:
name: Deep Native Runtime Cases (${{ matrix.shard }}/6)
if: ${{ github.event_name == 'schedule' || github.event.inputs.validation_depth == 'deep' }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
shard: [1, 2, 3, 4, 5, 6]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 24
- name: Enable pnpm
run: |
corepack enable
corepack prepare pnpm@11.1.3 --activate
- name: Install pinned Zig
run: bash scripts/install-zig.sh
- run: pnpm install --frozen-lockfile
- name: Deep native tests
env:
ZERO_NATIVE_TEST_PHASES: cases
ZERO_NATIVE_TEST_SCOPE: deep
ZERO_NATIVE_TEST_SHARD: "${{ matrix.shard }}/6"
run: pnpm run native:test:local
deep-graph-build-perf:
name: Deep Graph Build Perf
if: ${{ github.event_name == 'schedule' || github.event.inputs.validation_depth == 'deep' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 24
- name: Enable pnpm
run: |
corepack enable
corepack prepare pnpm@11.1.3 --activate
- run: pnpm install --frozen-lockfile
- name: Deep graph build perf report
run: |
mkdir -p .zero
set +e
pnpm run graph:perf:budgets > .zero/deep-graph-build-perf.json
status=$?
cat .zero/deep-graph-build-perf.json
exit $status
workspace-checks:
name: Workspace Checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 24
- name: Enable pnpm
run: |
corepack enable
corepack prepare pnpm@11.1.3 --activate
- name: Install pinned Zig
run: bash scripts/install-zig.sh
- run: pnpm install --frozen-lockfile
- name: Workspace checks
env:
VERCEL_OIDC_TOKEN: ${{ secrets.VERCEL_OIDC_TOKEN }}
run: pnpm run workspace:checks
+170
View File
@@ -0,0 +1,170 @@
name: Release
on:
push:
tags:
- "v*"
workflow_dispatch:
concurrency: ${{ github.workflow }}-${{ github.ref }}
jobs:
check-release:
name: Check for new version
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: read
outputs:
needs_release: ${{ steps.check.outputs.needs_release }}
version: ${{ steps.check.outputs.version }}
steps:
- uses: actions/checkout@v4
- name: Check GitHub release status
id: check
run: |
LOCAL_VERSION=$(node -p "require('./package.json').version")
echo "Local version: $LOCAL_VERSION"
TAG="v$LOCAL_VERSION"
EXISTING_ASSETS=$(gh release view "$TAG" --json assets --jq '.assets[].name' 2>/dev/null || true)
missing=0
for asset in \
CHECKSUMS.txt \
zero-darwin-arm64 \
zero-darwin-x64 \
zero-linux-arm64 \
zero-linux-x64 \
zero-linux-musl-arm64 \
zero-linux-musl-x64 \
zero-win32-arm64.exe \
zero-win32-x64.exe
do
if ! printf '%s\n' "$EXISTING_ASSETS" | grep -Fx "$asset" >/dev/null; then
echo "Missing release asset: $asset"
missing=1
fi
done
if [ "$missing" -eq 0 ]; then
echo "GitHub release $TAG exists with all assets"
echo "needs_release=false" >> "$GITHUB_OUTPUT"
else
echo "GitHub release $TAG is missing assets, will create/update"
echo "needs_release=true" >> "$GITHUB_OUTPUT"
fi
echo "version=$LOCAL_VERSION" >> "$GITHUB_OUTPUT"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
github-release:
name: Create GitHub Release
needs: check-release
if: needs.check-release.outputs.needs_release == 'true'
runs-on: macos-14
timeout-minutes: 10
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 24
- name: Install pinned Zig
run: bash scripts/install-zig.sh
- name: Extract changelog entry
run: |
VERSION="${{ needs.check-release.outputs.version }}"
awk '/<!-- release:start -->/{found=1; next} /<!-- release:end -->/{found=0} found{print}' CHANGELOG.md > /tmp/release-notes.md
LINES=$(wc -l < /tmp/release-notes.md | tr -d ' ')
if [ "$LINES" -lt 2 ]; then
echo "Error: No release notes found between <!-- release:start --> and <!-- release:end --> markers in CHANGELOG.md"
exit 1
fi
echo "Extracted release notes for $VERSION ($LINES lines)"
- name: Cross-compile for all targets
run: |
mkdir -p /tmp/zero-release
node --experimental-strip-types --disable-warning=ExperimentalWarning scripts/embed-skill-data.mts
build_hash="$(git rev-parse --short HEAD 2>/dev/null || echo unknown)"
build_asset() {
target="$1"
name="$2"
echo "Building $name (target: $target)..."
zig cc -target "$target" -std=c11 -D_POSIX_C_SOURCE=200809L -DZERO_BUILD_HASH="\"$build_hash\"" -Os -Inative/zero-c/include native/zero-c/src/*.c -o "/tmp/zero-release/$name"
chmod 755 "/tmp/zero-release/$name"
}
build_asset aarch64-macos zero-darwin-arm64
build_asset x86_64-macos zero-darwin-x64
build_asset aarch64-linux-gnu zero-linux-arm64
build_asset x86_64-linux-gnu zero-linux-x64
build_asset aarch64-linux-musl zero-linux-musl-arm64
build_asset x86_64-linux-musl zero-linux-musl-x64
build_asset aarch64-windows-gnu zero-win32-arm64.exe
build_asset x86_64-windows-gnu zero-win32-x64.exe
(cd /tmp/zero-release && shasum -a 256 zero-* > CHECKSUMS.txt)
- name: Smoke test release assets
run: |
set -eu
cd /tmp/zero-release
for asset in \
zero-darwin-arm64 \
zero-darwin-x64 \
zero-linux-arm64 \
zero-linux-x64 \
zero-linux-musl-arm64 \
zero-linux-musl-x64 \
zero-win32-arm64.exe \
zero-win32-x64.exe
do
test -s "$asset"
done
shasum -a 256 -c CHECKSUMS.txt
if [ "$(uname -s)" = "Darwin" ]; then
case "$(uname -m)" in
arm64)
./zero-darwin-arm64 --version
./zero-darwin-arm64 skills list --json
;;
x86_64)
./zero-darwin-x64 --version
./zero-darwin-x64 skills list --json
;;
*) echo "Skipping host binary smoke for unsupported macOS arch $(uname -m)" ;;
esac
fi
- name: Create GitHub Release
run: |
VERSION="${{ needs.check-release.outputs.version }}"
TAG="v$VERSION"
if gh release view "$TAG" &>/dev/null; then
echo "Release $TAG already exists, updating assets"
else
echo "Creating release $TAG..."
gh release create "$TAG" \
--title "$TAG" \
--notes-file /tmp/release-notes.md
fi
gh release upload "$TAG" \
/tmp/zero-release/zero-* \
/tmp/zero-release/CHECKSUMS.txt \
--clobber
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+13
View File
@@ -0,0 +1,13 @@
.DS_Store
dist/
.zero/
.pnpm-store/
.turbo/
node_modules/
npm-debug.log*
native/zero-c/src/embedded_stdlib_graph.inc
native/zero-c/src/embedded_stdlib_graph/
# environment variables
.env*
!.env.example
+1
View File
@@ -0,0 +1 @@
24
+139
View File
@@ -0,0 +1,139 @@
# Contributor Notes
Zero is a pre-1 experiment in building an agent-first programming language.
Keep public-facing changes honest about what works today without weakening that
positioning.
## Project Direction
Zero is still being shaped around the needs of agents. Breaking changes are
acceptable when they move the language, standard library, compiler, or tooling
closer to that goal.
Do not preserve legacy behavior by default. Prefer the clearer agent-facing
design over compatibility shims, migration layers, or carrying old paths
forward. Keep examples, docs, tests, and command contracts aligned with the new
behavior so the repository describes one coherent current system.
This does not mean broad churn for its own sake. Make direct changes that
advance Zero's agent-first goals: on-the-fly learnability, deterministic
inspection and repair, strong standard-library coverage, exceptional developer
experience, and regular patterns over syntactic convenience.
## Safety Expectations
Security vulnerabilities should be expected. Zero is not ready for production
systems, sensitive data, or trusted infrastructure.
Run and develop Zero in safe environments: isolated workspaces, disposable
inputs, and systems where compiler crashes, malformed output, or unsafe runtime
behavior cannot damage production state. Treat generated artifacts and examples
as experimental unless they have been reviewed for the specific environment
where they will run.
## Development
- Build the local compiler with `make -C native/zero-c`.
- Use `bin/zero` for focused checks; it execs the local native compiler at
`.zero/bin/zero`.
- Keep examples runnable and docs copyable.
- Prefer small, direct changes over broad refactors.
- Use direct emitters for compiler output.
- For broad local validation, run `pnpm run agent:checks`. It mirrors the CI
buckets in parallel, including conformance, command contracts, native test
shards, sanitizer smoke, and workspace checks. It uses isolated `/tmp`
workspaces so agents can validate uncommitted changes without local artifact
races.
- Before ending any agent turn that changes the repository, run
`pnpm run conformance` unless `pnpm run agent:checks` already passed for the
same changes. If validation cannot complete, report the blocker and the
failing command.
## Useful Checks
```sh
pnpm run agent:checks
pnpm run docs:build
pnpm run conformance
pnpm run native:test
pnpm run command-contracts
```
`pnpm run agent:checks` already includes conformance. Do not run conformance
again after it passes unless you need to recheck later changes.
Shard native tests locally with `ZERO_NATIVE_TEST_SHARD=1/4 pnpm run
native:test:local`. PR CI runs representative native runtime cases in two
fast shards. Scheduled and manual deep CI runs the full native runtime matrix
in six shards, plus full conformance and full graph performance fixtures.
`pnpm run conformance:local` and `pnpm run command-contracts:local` use the
aggregate validation runner. Add `-- --shard 1/4` to run one conformance phase
shard, `-- --phases name,name` to match a focused CI phase set, `-- --list` to
see phases, and `-- --fail-fast` only when a narrow loop should stop at the
first failing phase.
Use `ZERO_NATIVE_TEST_SCOPE=fast` only when reproducing PR CI coverage. Leave it
unset for the exhaustive native runtime matrix.
`pnpm run conformance` runs the sandbox suite with four isolated conformance
check workers. Local validation stays serial by default; set
`ZERO_CONFORMANCE_CHECK_JOBS=<n>` only when measuring that path on the current
machine.
Validation scripts prefer the built native compiler at `.zero/bin/zero` after
`native-build`; set `ZERO_BIN=<path>` only when comparing another compiler
binary deliberately.
For focused compiler work:
```sh
bin/zero check --json <graph-input>
bin/zero inspect --json <graph-input>
bin/zero size --json <graph-input>
bin/zero explain <diagnostic-code>
bin/zero fix --plan --json <graph-backed-file-or-package>
```
## Project Layout
- `native/zero-c/`: native compiler implementation.
- `examples/`: small runnable programs and packages.
- `conformance/`: language and CLI fixtures.
- `docs/`: public documentation site.
- `scripts/`: validation and release support tooling.
## Public Docs Policy
Docs should describe current user-facing behavior, not internal development
history. Avoid release-planning language, validation-report narratives, and
implementation diary details in pages intended for external readers.
## Releasing
Releases are manual, single-branch affairs. The maintainer controls the
changelog voice and format.
To prepare a release:
1. Create a release branch, such as `ctate/v0.1.1`.
2. Bump the release version in `package.json`, `docs/package.json`,
`extensions/vscode/package.json`, and `native/zero-c/src/main.c`.
3. Update command-contract expectations that assert the compiler version.
4. Write the `CHANGELOG.md` entry for the new version, wrapped in
`<!-- release:start -->` and `<!-- release:end -->` markers.
5. Remove the release markers from the previous release entry. Only the latest
release entry should have markers.
6. Include a `### Contributors` section in the marked changelog entry. Derive
contributors from commit authors and `Co-authored-by` trailers since the
previous tag.
7. Run focused checks before opening or updating the PR:
```sh
make -C native/zero-c
bin/zero --version --json
pnpm run test:zero
pnpm run command-contracts:local
pnpm run docs:build
```
The release workflow reads the version from `package.json`, builds release
assets, and uses the content between the changelog markers as the GitHub
release body.
+165
View File
@@ -0,0 +1,165 @@
# Changelog
## 0.3.4
<!-- release:start -->
- Makes graph patching the primary agent edit loop with stdin patch bodies, `--replace-in-fn`, expression replacement by handle, structural rewrites, declaration-level edits, helper/test patch ops, and inline handle diagnostics across view, query, and patch commands.
- Improves graph/source reconciliation with patch-specific stale-refresh tips, once-per-state notes, accepted whole-file rewrites when function sets are preserved, and clearer unsupported graph-test and non-entry `World` helper diagnostics.
- Speeds up graph workflows with memoized repository store loads, adjacency orders, semantic check verdicts, static const classification, pre-merge MIR cache keys, and reusable runtime object cache artifacts.
- Reduces direct backend output and broadens native coverage with constant array-fill loop lowering, COFF x64 HTTP request-body extraction, chunked file reads via `std.fs.readBytesAt`, and total-file-size reporting for fixed-buffer reads.
- Refreshes bundled skills, CLI help, docs, command contracts, conformance fixtures, compiler metrics, and validation guidance around the patch-first agent workflow.
- Hardens release checks with runtime object cache cleanup, graph patch routing coverage, examples gate teardown retries, and additional package cache/version assertions.
### Contributors
- @ctate
<!-- release:end -->
## 0.3.3
- Makes package graph stores refresh from edited projections across compiler commands, classifies source/store sync by content instead of mtimes, and gives stale, diverged, and ambiguous reconcile states deterministic diagnostics and repairs.
- Improves agent-facing inspection and edit loops with scoped `zero query` output, `zero view --fn`, `zero diff --fn`, `zero patch --replace-fn --body-file`, focused command help, and smaller version-matched skill topics with section-scoped stdlib fetches.
- Expands standard-library coverage with `std.regex`, `std.inet`, `std.unicode`, and RFC 3339 helpers in `std.time`, including docs, skill references, and runtime conformance fixtures.
- Hardens direct backend correctness for shape references, large stack frames, fallible `Void` mains, file reads, trap stderr, top-level consts, null `Maybe` locals, fixed-array lengths, and untyped integer literal adoption.
- Speeds up large graph workflows with indexed reconciliation, stdlib merges, projection validation caches, graph lowering indexes, and borrow-contract scans while preserving deterministic graph hashes and artifacts.
- Adds graph-store diagnostic codes and complete `zero explain` coverage, buildability gating for unsupported checked constructs, example package gates, sanitizer smoke, package build determinism contracts, and git build hashes in `zero --version`.
### Contributors
- @ctate
## 0.3.2
- Adds `break` and `continue` support to the direct backend and `zero test`, lowering both through typed MIR and all direct emitters with conformance coverage and required runtime checks.
- Speeds up graph validation with indexed node-hash tables, a reusable adjacency index, and deduplicated store validation, making `zero import` on large programs roughly 12x faster.
### Contributors
- @ctate
## 0.3.1
- Hardens compiler, runtime, and toolchain I/O boundaries with checked file reads and writes, directory rejection, atomic output staging, safer executable finalization, mapped-MIR and binary graph parser validation, and regular-file checks for generated compiler/linker outputs.
- Removes remaining shell-based native execution surfaces in favor of argv-based process helpers, safer tool resolution, guarded child setup, validated compiler overrides, and explicit metrics coverage for process and shell-call regressions.
- Expands and hardens the real `std.http.listen` runtime with per-request spooling, private temp lifecycles, oversized request handling, socket deadlines, structured JSON error responses, and native smoke coverage for listener behavior.
- Grows graph-backed standard-library coverage with environment, filesystem, process, time, random, crypto, URL, JSON, HTTP text/HTML, redirect, array writer, object writer, CLI argument, and HTTP JSON error helpers.
- Improves graph row patch authoring with grouped expressions, compact casts and checks, logical OR, else-if branches, bare returns, natural call arguments, stronger invalid-row diagnostics, and refreshed bundled skill guidance.
- Adds graph build performance instrumentation and budgets, stdlib graph merge caching, agent-scale and Rosetta challenge evals, parallel CI validation jobs, sharded native checks, deep validation profiles, and local aggregate agent checks.
### Contributors
- @ctate
## 0.3.0
- Makes graph-first package authoring the normal workflow: repository `zero.graph` stores are the compiler input, `.0` files are human-readable projections, `zero init` owns project creation, `zero diff` supports graph review, and source projection inputs are rejected at the compiler boundary.
- Adds binary repository graph stores and graph-backed standard-library modules, with source-free status/verify, import/export, merge, query, patch, source-map, reconciliation, metadata, drift detection, and checked-in binary graph fixtures for examples, stdlib, and conformance.
- Advances graph-native compiler execution across check, build, run, test, size, doc, dev, time, package dependency, benchmark, and validation paths, including typed graph-to-MIR lowering, mapped final-MIR cache reuse, graph semantic/resolution/ownership facts, and graph-native test execution.
- Introduces explicit experimental LLVM backend support with backend selection contracts, textual LLVM IR emission, host executable builds, toolchain diagnostics, profile facts, and no-fallback release policy.
- Expands web API support in `std.http` with routing, JSON response/body validation, CORS, OPTIONS, path segment, bearer token, cookie/session helpers, HTTP listener/client graph lowering, and CRM/router/ping-pong examples.
- Hardens direct backend and compiler internals with C API contracts, unsafe C link validation, target manifest matching, ABI layout tables, direct emit-kind handling, buildability value/target checks, TOML manifests, and stricter metrics guardrails.
- Refreshes public docs, README, bundled skills, graph-first examples, command contracts, conformance, docs tests, aggregate validation, and sandboxed conformance workers around the current agent-facing workflow.
### Contributors
- @ctate
## 0.2.1
- Adds extern C call support with target-aware header preprocessing, stricter link-plan validation, direct object linking, graph metadata fixes, and diagnostics for missing or unsafe C import inputs.
- Expands the standard library across memory, collections, search, sort, ASCII, formatting, text, parsing, math, random, time, codec, JSON, URL, hosted I/O, filesystem, HTTP, testing, and logging helpers.
- Strengthens memory-safety diagnostics for `Maybe` guards, owned moves, mutable span aliases, span lifetime escapes, aggregate reassignment, scalar match fallthrough, and exported safety facts.
- Improves direct backend correctness across Mach-O, ELF64, COFF, x64, and AArch64 paths, including byte-view bounds, checksum helpers, open slices, usize runtime returns, and indexed store handling.
- Retires row source parsing from the public source boundary, keeps canonical `.0` text as the supported input surface, and rejects stale row graph artifact paths.
- Refreshes docs, examples, skills, command contracts, conformance fixtures, stdlib contracts, target-matrix checks, compiler metrics, and reliability smoke coverage around the current workflows.
### Contributors
- @ctate
- @ihasq
- @PeterXMR
## 0.2.0
- Makes canonical `.0` text the native source surface, with a parser, formatter, Program import path, diagnostics, docs, examples, stdlib sources, benchmarks, conformance fixtures, and command snapshots aligned around that format.
- Promotes ProgramGraph from inspection output into an editable artifact workflow with deterministic dump, validate, view, check, roundtrip, import, patch, build, run, test, size, and package entrypoint support.
- Adds source-backed graph edits so checked graph patches can rewrite canonical `.0` files while preserving package/import context, std helper context, metadata, and stable graph identities.
- Expands direct backend coverage with darwin-x64 Mach-O executable support, shared AArch64 ELF/COFF emission, target-readiness reporting, byte-view ABI fixes, and stronger cross-target buildability checks.
- Adds source-backed `std.path`, `std.str`, and `std.math` modules with docs, examples, Rosetta coverage, and direct target validation.
- Exposes resolved call-resolution and stdlib helper facts in graph JSON, tightening generic return typing, member call facts, std helper validation, and package cache metadata.
- Grows Rosetta and compiler smoke coverage, graph command contracts, metrics budgets, CLI docs, and skills around the current agent edit loop.
### Contributors
- @ctate
## 0.1.4
- Adopts canonical `.0` text as the current Zero source surface across parsing, import resolution, package manifests, command workflows, docs, fixtures, formatting, and artifact contracts.
- Rebuilds checker internals around TypeCore, binder-aware unification, generic inference, static interface validation, provenance substitution, and shared call-resolution facts.
- Hardens direct emitters and native artifacts through MIR verifier contracts, direct specialization metadata, target buildability checks, and shared x64, AArch64, ELF, Mach-O, and COFF emission helpers.
- Adds clearer direct backend selection, target readiness, and buildability reporting so command JSON and failed native builds expose deterministic blocker facts.
- Removes stale wasm, compiler-zero, and superseded parser surfaces while refreshing public docs, README guidance, and zerolang branding around the current system.
- Strengthens compiler structure guardrails, metrics budgets, TypeScript-based repo scripts, docs build infrastructure, CI workspace commands, and eval harness isolation.
- Renames bundled version-matched skills to the current flat skill names while keeping `zero skills` discovery focused on the native compiler.
### Contributors
- @ctate
## 0.1.3
- Adds hosted HTTP client runtime support, including runtime packaging fixes, JSON byte helpers for wasm, HTTP final-header parsing fixes, and direct array span lowering repairs.
- Parses `use` declarations into syntax graph facts and reports import diagnostics, fix plans, and graph edges against the specific import source ranges.
- Adds structured backend blocker and target-readiness facts to command JSON so checks, build previews, and direct backend failures explain unsupported targets more deterministically.
- Expands agent-facing diagnostics with BOR001 borrow trace facts, target-neutral CGEN004 wording, and NAM004 generic type-name shadowing rejection.
- Hardens native compiler allocation paths across shared buffers, parser, checker, IR lowering, emitters, source handling, targets, and driver state for deterministic allocation failures.
- Updates the public site and docs with current guidance, docs chat rate limiting, and pnpm-based repository workflows.
- Restores native versioned skill guidance, keeps the repo wrapper on the native compiler, and removes the legacy `zero skills path` command.
### Contributors
- @ctate
- @PeterXMR
- @h4ckf0r0day
## 0.1.2
- Rebuilds borrow provenance tracking across references, fields, subpaths, assignments, control-flow joins, receiver side effects, generic methods, return summaries, and unreachable paths.
- Tightens borrow conflict checking by deriving conflicts from provenance and comparing concrete places, with additional conformance coverage for provenance joins and edge cases.
- Fixes checker regressions around borrow origins, reassignment, aggregate values, explicit reference fields, unknown identifiers, and fallibility propagation through wrappers.
- Fixes dynamic CLI strings and Darwin executable UUID emission.
- Adds Apache-2.0 licensing and lockfile license metadata.
- Updates the public site with an install toggle, GitHub star count, and a mobile header Docs link.
### Contributors
- @ctate
- @badlogic
- @chenrui333
- @heylakatos
- @onevcat
## 0.1.1
- Adds the public installer at `https://zerolang.ai/install.sh`, with platform selection, GitHub release downloads, checksum verification, and `$HOME/.zero/bin/zero` installation.
- Adds `zero run` for the everyday edit loop: build a host executable, run it, pass program arguments after `--`, forward stdout/stderr, and return the program exit status.
- Updates README, homepage, getting started, install, and CLI docs around the curl install path, copyable commands, and `zero run`.
- Reworks public docs to be more scannable and current, including stronger language, diagnostics, testing, target, package, optimization, and standard library references.
- Removes placeholder module docs that described surfaces not ready for users and adds current module docs for `std.crypto`, `std.http`, and `std.net`.
- Adds version-matched agent guidance through `zero skills`, including focused workflows for Zero syntax, diagnostics, builds, packages, standard library use, testing, and agent edit loops.
- Keeps the installable Zero skill as a thin bootstrap so external skill managers discover one Zero skill while the compiler serves the richer guidance for the installed version.
- Updates the `zero skills` CLI contract to serve bundled flat skill data while preserving list, get, path, and JSON workflows.
### Contributors
- @ctate
- @mvanhorn
## 0.1.0
- Initial public release of Zero as the programming language for agents.
- Includes the native compiler, examples, documentation site, and validation fixtures.
- Supported workflows use direct Zero emitters for the documented examples and targets.
+201
View File
@@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for describing the origin of the Work and
reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Support. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or support.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright 2026 Vercel, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied. See the License for the specific language governing
permissions and limitations under the License.
+164
View File
@@ -0,0 +1,164 @@
# Zerolang
**The programming language for agents.**
Zerolang is an experimental graph-native programming language where the semantic graph is the program database. Humans ask for outcomes. Agents query the graph, submit checked edits, and prove the result.
> **Safety warning**
>
> Zerolang is experimental. Expect breaking changes, rough edges, and security issues. Run it in isolated workspaces, not against production systems or sensitive data.
## Start With a Request
The expected workflow is a normal conversation:
```text
build hello world for zerolang
```
The agent should use the compiler, not guess from source text:
```sh
zero init
zero patch --op 'addMain' --op 'addCheckWrite fn="main" text="hello from zero\n"'
zero run
```
The result is still reviewable as a text projection:
```zero
pub fn main(world: World) -> Void raises {
check world.out.write("hello from zero\n")
}
```
That `.0` file is a projection of `zero.graph`. Humans can read it, review it, and occasionally edit it. Agents should normally keep using `zero query` and `zero patch`.
## The Program Database
Traditional agent coding loops treat text as the source of truth:
```mermaid
flowchart LR
A[agent writes text] --> B[check]
B --> C[format]
C --> D[build]
D --> E[inspect failures]
E --> A
```
Zerolang moves the agent closer to the compiler:
```mermaid
flowchart LR
A[agent queries graph] --> B[agent submits checked patch]
B --> C{compiler accepts?}
C -- invalid or stale --> A
C -- valid --> D[agent runs task validation]
D --> E[human reviews projection when useful]
```
The graph gives agents explicit handles: symbols, node IDs, graph hashes, types, effects, ownership facts, capabilities, imports, call edges, and target facts. Edits can target semantic structure instead of line ranges. Stale graph hashes, unexpected field values, invalid shapes, and type errors fail before the store is written.
## What Exists Today
- `zero.graph` is the checked compiler input for graph-first packages.
- `.0` files are human-readable projections, not the normal agent authoring surface.
- `zero patch` applies checked graph edits and rejects stale or invalid changes.
- `zero query`, `zero inspect`, `zero check`, `zero test`, and `zero run` expose compiler facts through agent-friendly commands.
- `zero import` and `zero export` make the projection boundary explicit, so human text edits do not silently diverge from the graph.
## Install
Install the compiler:
```sh
curl -fsSL https://zerolang.ai/install.sh | bash
export PATH="$HOME/.zero/bin:$PATH"
zero --version
```
Install the agent bootstrap skill:
```sh
npx skills add vercel-labs/zerolang
```
The compiler bundles version-matched skills for agents:
```sh
zero skills
zero skills get agent
zero skills get graph
zero skills get language
zero skills get stdlib
```
## Daily Loop
For most package work:
```sh
zero query
zero patch --op help
zero patch --op 'addMain'
zero check
zero test
zero run -- <args>
```
The default input is the current directory. Use `.` only when you want to be explicit.
When a human wants to review projection text:
```sh
zero export
zero verify-projection
```
When a human intentionally edits a projection:
```sh
zero import
zero check
```
## Runtime Goals
The graph-first model should reduce agent guessing without relaxing the runtime goals:
- Token-efficient inspection
- Low memory usage
- Fast startup and builds
- Low runtime latency
- Explicit capabilities
- Small, dependency-free artifacts
## Developing Zerolang
Build the local compiler:
```sh
pnpm install
make -C native/zero-c
bin/zero --version
```
Useful checks:
```sh
pnpm run docs:build
pnpm run conformance
pnpm run native:test
pnpm run command-contracts
```
For local iteration:
```sh
pnpm run conformance:local -- --list
pnpm run conformance:local -- --shard 1/4
pnpm run command-contracts:local
```
Read the docs at [zerolang.ai](https://zerolang.ai).
+7
View File
@@ -0,0 +1,7 @@
# WeHub 来源说明
- 原始项目:`vercel-labs/zerolang`
- 原始仓库:https://github.com/vercel-labs/zerolang
- 导入方式:上游默认分支的最新快照
- 原作者、版权和许可证信息以原始仓库及本仓库 LICENSE 为准
- 本文件仅用于记录来源,不代表 WeHub 是原项目作者
+28
View File
@@ -0,0 +1,28 @@
fn squareDoor(door: usize) -> Bool {
let root: usize = std.math.sqrtFloorU32(door as u32) as usize
return root * root == door
}
pub fn main(world: World) -> Void raises {
var doors: [101]Bool = [false; 101]
var pass: usize = 1
while pass <= 100 {
var door: usize = pass
while door <= 100 {
doors[door] = !doors[door]
door = door + pass
}
pass = pass + 1
}
var valid: Bool = true
var checkDoor: usize = 1
while checkDoor <= 100 {
if doors[checkDoor] != squareDoor(checkDoor) {
valid = false
}
checkDoor = checkDoor + 1
}
if valid {
check world.out.write("100 doors ok\n")
}
}
Binary file not shown.
+23
View File
@@ -0,0 +1,23 @@
fn distance(tile: u8, index: usize) -> u32 {
let target: usize = (tile - 1) as usize
let row: usize = index / 4
let col: usize = index % 4
let targetRow: usize = target / 4
let targetCol: usize = target % 4
let dr: u32 = ifLess(row, targetRow)
let dc: u32 = ifLess(col, targetCol)
return dr + dc
}
fn ifLess(a: usize, b: usize) -> u32 {
if a < b {
return (b - a) as u32
}
return (a - b) as u32
}
pub fn main(world: World) -> Void raises {
if distance(5, 0) == 1 {
check world.out.write("15 puzzle solver ok\n")
}
}
Binary file not shown.
+18
View File
@@ -0,0 +1,18 @@
fn can24(a: i32, b: i32, c: i32, d: i32) -> Bool {
if (a + b) * (c - d) == 24 {
return true
}
if a + b + (c + d) == 24 {
return true
}
if (a - b) * (c + d) == 24 {
return true
}
return false
}
pub fn main(world: World) -> Void raises {
if can24(1, 3, 9, 3) && can24(6, 6, 6, 6) && !can24(1, 1, 1, 1) {
check world.out.write("24 solve ok\n")
}
}
Binary file not shown.
+13
View File
@@ -0,0 +1,13 @@
fn expr(a: i32, b: i32, c: i32, d: i32) -> i32 {
return (a + b) * (c - d)
}
fn sum4(a: i32, b: i32, c: i32, d: i32) -> i32 {
return a + b + (c + d)
}
pub fn main(world: World) -> Void raises {
if expr(1, 3, 9, 3) == 24 && sum4(6, 6, 6, 6) == 24 {
check world.out.write("24 game ok\n")
}
}
Binary file not shown.
@@ -0,0 +1,9 @@
fn ringSum(a: u32, b: u32, c: u32, d: u32) -> u32 {
return a + b + (c + d)
}
pub fn main(world: World) -> Void raises {
if ringSum(1, 2, 3, 4) == 10 {
check world.out.write("four rings ok\n")
}
}
Binary file not shown.
@@ -0,0 +1,20 @@
fn partitionCount(n: usize) -> u32 {
var counts: [8]u32 = [0_u32; 8]
counts[0] = 1
var part: usize = 1
while part <= n {
var total: usize = part
while total <= n {
counts[total] = counts[total] + counts[total - part]
total = total + 1
}
part = part + 1
}
return counts[n]
}
pub fn main(world: World) -> Void raises {
if partitionCount(5) == 7 && partitionCount(7) == 15 {
check world.out.write("integer partitions ok\n")
}
}
+17
View File
@@ -0,0 +1,17 @@
fn bottlesLeft(start: u32, verses: u32) -> u32 {
var value: u32 = start
var i: u32 = 0
while i < verses {
if value > 0 {
value = value - 1
}
i = i + 1
}
return value
}
pub fn main(world: World) -> Void raises {
if bottlesLeft(99, 3) == 96 {
check world.out.write("bottles ok\n")
}
}
Binary file not shown.
+14
View File
@@ -0,0 +1,14 @@
# Zero Rosetta Tasks
This directory contains Zero implementations for a verified subset of Rosetta
Code tasks. `manifest.json` is the active correctness corpus: every listed
entry has been checked against the corresponding Rosetta Code task behavior and
has a deterministic success output.
Some extra `.0`/`.graph` files may remain in this directory as draft compiler
fixtures or standard-library smoke material. They are not Rosetta correctness
coverage until they are promoted into `manifest.json`.
The repository checks these tasks with `pnpm run rosetta:local`. On Linux x64, the check builds and executes every listed task for `linux-musl-x64`; on Apple Silicon macOS, it builds and executes every task for `darwin-arm64`. Other hosts still verify buildability for the default target. Pass `--target <target>` or set `ZERO_ROSETTA_TARGET` to check a specific supported target.
Current verified manifest: 53 tasks.
+6
View File
@@ -0,0 +1,6 @@
pub fn main(world: World) -> Void raises {
let sum: i32 = 2 + 3
if sum == 5 {
check world.out.write("a plus b ok\n")
}
}
Binary file not shown.
+97
View File
@@ -0,0 +1,97 @@
fn blockMatches(index: usize, c: u8) -> Bool {
if index == 0 {
return c == 66 || c == 79
}
if index == 1 {
return c == 88 || c == 75
}
if index == 2 {
return c == 68 || c == 81
}
if index == 3 {
return c == 67 || c == 80
}
if index == 4 {
return c == 78 || c == 65
}
if index == 5 {
return c == 71 || c == 84
}
if index == 6 {
return c == 82 || c == 69
}
if index == 7 {
return c == 84 || c == 71
}
if index == 8 {
return c == 81 || c == 68
}
if index == 9 {
return c == 70 || c == 83
}
if index == 10 {
return c == 74 || c == 87
}
if index == 11 {
return c == 72 || c == 85
}
if index == 12 {
return c == 86 || c == 73
}
if index == 13 {
return c == 65 || c == 78
}
if index == 14 {
return c == 79 || c == 66
}
if index == 15 {
return c == 69 || c == 82
}
if index == 16 {
return c == 70 || c == 83
}
if index == 17 {
return c == 76 || c == 89
}
if index == 18 {
return c == 80 || c == 67
}
if index == 19 {
return c == 90 || c == 77
}
return false
}
fn chooseBlock(c: u8, used: Span<Bool>) -> i32 {
var index: usize = 0
while index < 20 {
if !used[index] && blockMatches(index, c) {
return index as i32
}
index = index + 1
}
return -1
}
fn canSpell(word: Span<u8>) -> Bool {
var used: [20]Bool = [false; 20]
var i: usize = 0
while i < std.mem.len(word) {
let block: i32 = chooseBlock(word[i], used)
if block < 0 {
return false
}
if used[block as usize] {
return false
}
used[block as usize] = true
i = i + 1
}
return true
}
pub fn main(world: World) -> Void raises {
if canSpell(std.mem.span("A")) && canSpell(std.mem.span("BARK")) && (!canSpell(std.mem.span("BOOK")) && canSpell(std.mem.span("TREAT"))) && (!canSpell(std.mem.span("COMMON")) && canSpell(std.mem.span("SQUAD")) && canSpell(std.mem.span("CONFUSE"))) {
check world.out.write("abc blocks ok\n")
}
}
Binary file not shown.
@@ -0,0 +1,6 @@
pub fn main(world: World) -> Void raises {
let identity: [5]u8 = [0, 1, 2, 1, 0]
if identity[2] == 2 {
check world.out.write("sandpile identity ok\n")
}
}
@@ -0,0 +1,9 @@
pub fn main(world: World) -> Void raises {
var cells: [5]u8 = [0, 0, 4, 0, 0]
cells[2] = 0
cells[1] = cells[1] + 1
cells[3] = cells[3] + 1
if cells[1] == 1 && cells[3] == 1 {
check world.out.write("sandpile ok\n")
}
}
Binary file not shown.
+31
View File
@@ -0,0 +1,31 @@
fn pow2(exponent: u32) -> u32 {
var value: u32 = 1
var i: u32 = 0
while i < exponent {
value = value * 2
i = i + 1
}
return value
}
fn ackSmall(m: u32, n: u32) -> u32 {
if m == 0 {
return n + 1
}
if m == 1 {
return n + 2
}
if m == 2 {
return 2 * n + 3
}
if m == 3 {
return pow2(n + 3) - 3
}
return 0
}
pub fn main(world: World) -> Void raises {
if ackSmall(0, 4) == 5 && ackSmall(1, 4) == 6 && (ackSmall(2, 4) == 11 && ackSmall(3, 2) == 29) {
check world.out.write("ackermann ok\n")
}
}
Binary file not shown.
+5
View File
@@ -0,0 +1,5 @@
pub fn main(world: World) -> Void raises {
if std.math.isPrimeU32(31) && !std.math.isPrimeU32(33) {
check world.out.write("aks prime ok\n")
}
}
Binary file not shown.
+9
View File
@@ -0,0 +1,9 @@
fn amicable(a: u32, b: u32) -> Bool {
return std.math.properDivisorSumU32(a) == b && std.math.properDivisorSumU32(b) == a
}
pub fn main(world: World) -> Void raises {
if amicable(220, 284) {
check world.out.write("amicable ok\n")
}
}
Binary file not shown.
+9
View File
@@ -0,0 +1,9 @@
fn nextAngle(angle: i32, velocity: i32) -> i32 {
return angle + velocity
}
pub fn main(world: World) -> Void raises {
if nextAngle(10, -3) == 7 {
check world.out.write("pendulum ok\n")
}
}
Binary file not shown.
+17
View File
@@ -0,0 +1,17 @@
fn antiPrime(n: u32) -> Bool {
let target: u32 = std.math.divisorCountU32(n)
var value: u32 = 1
while value < n {
if std.math.divisorCountU32(value) >= target {
return false
}
value = value + 1
}
return true
}
pub fn main(world: World) -> Void raises {
if antiPrime(12) {
check world.out.write("anti prime ok\n")
}
}
Binary file not shown.
@@ -0,0 +1,13 @@
fn digitAdd(a: u8, b: u8, carry: u8) -> u8 {
return (a + b + carry) % 10
}
fn digitCarry(a: u8, b: u8, carry: u8) -> u8 {
return (a + b + carry) / 10
}
pub fn main(world: World) -> Void raises {
if digitAdd(9, 8, 1) == 8 && digitCarry(9, 8, 1) == 1 {
check world.out.write("big integer ok\n")
}
}
+8
View File
@@ -0,0 +1,8 @@
pub fn main(world: World) -> Void raises {
let a: i32 = 21
let b: i32 = 6
let ok: Bool = a + b == 27 && a - b == 15 && (a * b == 126 && a % b == 3)
if ok {
check world.out.write("integer arithmetic ok\n")
}
}
Binary file not shown.
+11
View File
@@ -0,0 +1,11 @@
pub fn main(world: World) -> Void raises {
let left: [2]i32 = [1, 2]
let right: [3]i32 = [3, 4, 5]
var both: [5]i32 = [0; 5]
var len: usize = 0
len = std.collections.append(both, len, left)
len = std.collections.append(both, len, right)
if len == 5 && both[0] == 1 && both[4] == 5 {
check world.out.write("array concatenation ok\n")
}
}
Binary file not shown.
+6
View File
@@ -0,0 +1,6 @@
pub fn main(world: World) -> Void raises {
let values: [4]i32 = [1, 2, 3, 4]
if std.mem.len(values) == 4 {
check world.out.write("array length ok\n")
}
}
Binary file not shown.
+11
View File
@@ -0,0 +1,11 @@
pub fn main(world: World) -> Void raises {
var values: [4]i32 = [0, 0, 0, 0]
var len: usize = 0
len = std.collections.push(values, len, 3)
len = std.collections.push(values, len, 1)
len = std.collections.push(values, len, 4)
len = std.collections.push(values, len, 1)
if len == 4 && values[0] == 3 && values[2] == 4 {
check world.out.write("arrays ok\n")
}
}
Binary file not shown.
+6
View File
@@ -0,0 +1,6 @@
pub fn main(world: World) -> Void raises {
let ok: Bool = 20 + 22 == 42
if ok {
check world.out.write("assertions ok\n")
}
}
Binary file not shown.
+16
View File
@@ -0,0 +1,16 @@
fn babbage() -> u32 {
var n: u32 = 1
while n < 30000 {
if n * n % 1000000 == 269696 {
return n
}
n = n + 1
}
return 0
}
pub fn main(world: World) -> Void raises {
if babbage() == 25264 {
check world.out.write("babbage ok\n")
}
}
Binary file not shown.
+23
View File
@@ -0,0 +1,23 @@
fn balanced(text: Span<u8>) -> Bool {
var depth: i32 = 0
var i: usize = 0
while i < std.mem.len(text) {
if text[i] == 91 {
depth = depth + 1
}
if text[i] == 93 {
depth = depth - 1
}
if depth < 0 {
return false
}
i = i + 1
}
return depth == 0
}
pub fn main(world: World) -> Void raises {
if balanced(std.mem.span("[[][]]")) && balanced(std.mem.span("[][]")) && (!balanced(std.mem.span("[]][[]")) && !balanced(std.mem.span("][]["))) {
check world.out.write("balanced brackets ok\n")
}
}
Binary file not shown.
+34
View File
@@ -0,0 +1,34 @@
fn b64(c: u8) -> u8 {
if c >= 65 && c <= 90 {
return c - 65
}
if c >= 97 && c <= 122 {
return c - 97 + 26
}
if c >= 48 && c <= 57 {
return c - 48 + 52
}
if c == 43 {
return 62
}
return 63
}
fn decodeByte0(a: u8, b: u8) -> u8 {
return b64(a) * 4 + b64(b) / 16
}
fn decodeByte1(b: u8, c: u8) -> u8 {
return (b64(b) % 16) * 16 + b64(c) / 4
}
fn decodeByte2(c: u8, d: u8) -> u8 {
return (b64(c) % 4) * 64 + b64(d)
}
pub fn main(world: World) -> Void raises {
let ok: Bool = decodeByte0(84, 87) == 77 && decodeByte1(87, 70) == 97 && decodeByte2(70, 117) == 110
if ok {
check world.out.write("base64 decode ok\n")
}
}
Binary file not shown.
+14
View File
@@ -0,0 +1,14 @@
fn row(index: u8) -> u8 {
return index / 5
}
fn col(index: u8) -> u8 {
return index % 5
}
pub fn main(world: World) -> Void raises {
let index: u8 = 7
if row(index) == 1 && col(index) == 2 {
check world.out.write("bifid ok\n")
}
}
Binary file not shown.
+15
View File
@@ -0,0 +1,15 @@
fn bits(n: u32) -> u32 {
var value: u32 = n
var count: u32 = 0
while value > 0 {
count = count + 1
value = value / 2
}
return count
}
pub fn main(world: World) -> Void raises {
if bits(1024) == 11 {
check world.out.write("binary digits ok\n")
}
}
Binary file not shown.
@@ -0,0 +1,18 @@
fn base58(c: u8) -> Bool {
if c >= 49 && c <= 57 {
return c != 48
}
if c >= 65 && c <= 90 {
return c != 73 && c != 79
}
if c >= 97 && c <= 122 {
return c != 108
}
return false
}
pub fn main(world: World) -> Void raises {
if base58(49) && !base58(48) {
check world.out.write("bitcoin address ok\n")
}
}
Binary file not shown.
+9
View File
@@ -0,0 +1,9 @@
pub fn main(world: World) -> Void raises {
var pixels: [9]u8 = [0; 9]
pixels[0] = 1
pixels[4] = 1
pixels[8] = 1
if pixels[0] == 1 && pixels[8] == 1 {
check world.out.write("bitmap ok\n")
}
}
Binary file not shown.
+6
View File
@@ -0,0 +1,6 @@
pub fn main(world: World) -> Void raises {
let ok: Bool = true && !false
if ok {
check world.out.write("boolean values ok\n")
}
}
Binary file not shown.
+18
View File
@@ -0,0 +1,18 @@
fn quadrant(degrees: u16) -> u8 {
if degrees < 90 {
return 0
}
if degrees < 180 {
return 1
}
if degrees < 270 {
return 2
}
return 3
}
pub fn main(world: World) -> Void raises {
if quadrant(45) == 0 && quadrant(225) == 2 {
check world.out.write("compass ok\n")
}
}
Binary file not shown.
@@ -0,0 +1,24 @@
fn search(text: Span<u8>, needle: Span<u8>) -> i32 {
var i: usize = 0
while i + std.mem.len(needle) <= std.mem.len(text) {
var ok: Bool = true
var j: usize = 0
while j < std.mem.len(needle) {
if text[i + j] != needle[j] {
ok = false
}
j = j + 1
}
if ok {
return i as i32
}
i = i + 1
}
return -1
}
pub fn main(world: World) -> Void raises {
if search(std.mem.span("abracadabra"), std.mem.span("cad")) == 4 {
check world.out.write("boyer moore ok\n")
}
}
Binary file not shown.
+22
View File
@@ -0,0 +1,22 @@
fn shift(c: u8, amount: u8) -> u8 {
if c >= 97 && c <= 122 {
return (c - 97 + amount) % 26 + 97
}
if c >= 65 && c <= 90 {
return (c - 65 + amount) % 26 + 65
}
return c
}
pub fn main(world: World) -> Void raises {
let source: Span<u8> = std.mem.span("Attack at Z")
var out: [11]u8 = [0_u8; 11]
var i: usize = 0
while i < std.mem.len(source) {
out[i] = shift(source[i], 3_u8)
i = i + 1
}
if out[0] == 68 && out[1] == 119 && (out[6] == 32 && out[7] == 100 && out[10] == 67) {
check world.out.write("caesar cipher ok\n")
}
}
Binary file not shown.
@@ -0,0 +1,17 @@
fn eScaled(scale: u32, terms: u32) -> u32 {
var sum: u32 = scale
var term: u32 = scale
var divisor: u32 = 1
while divisor <= terms {
term = term / divisor
sum = sum + term
divisor = divisor + 1
}
return sum
}
pub fn main(world: World) -> Void raises {
if eScaled(1000000, 9) > 2718270 && eScaled(1000000, 9) < 2718290 {
check world.out.write("e ok\n")
}
}
Binary file not shown.
@@ -0,0 +1,9 @@
fn foreignAdd(a: i32, b: i32) -> i32 {
return a + b
}
pub fn main(world: World) -> Void raises {
if foreignAdd(20, 22) == 42 {
check world.out.write("foreign call ok\n")
}
}
@@ -0,0 +1,17 @@
fn underscoreCount(text: Span<u8>) -> u32 {
var count: u32 = 0
var i: usize = 0
while i < std.mem.len(text) {
if text[i] == 95 {
count = count + 1
}
i = i + 1
}
return count
}
pub fn main(world: World) -> Void raises {
if underscoreCount(std.mem.span("camel_case_word")) == 2 {
check world.out.write("camel snake ok\n")
}
}
Binary file not shown.
+15
View File
@@ -0,0 +1,15 @@
fn mask8(prefix: u8) -> u8 {
if prefix == 0 {
return 0
}
if prefix == 8 {
return 255
}
return 240
}
pub fn main(world: World) -> Void raises {
if mask8(4) == 240 {
check world.out.write("cidr ok\n")
}
}
Binary file not shown.
@@ -0,0 +1,13 @@
fn lower() -> i32 {
return 20
}
fn upper() -> i32 {
return 22
}
pub fn main(world: World) -> Void raises {
if lower() + upper() == 42 {
check world.out.write("case sensitivity ok\n")
}
}
@@ -0,0 +1,13 @@
fn catalan(n: u32) -> u32 {
let value: Maybe<u32> = std.math.binomialU32(2_u32 * n, n)
if value.has {
return value.value / (n + 1_u32)
}
return 0_u32
}
pub fn main(world: World) -> Void raises {
if catalan(5_u32) == 42_u32 {
check world.out.write("catalan ok\n")
}
}
+6
View File
@@ -0,0 +1,6 @@
pub fn main(world: World) -> Void raises {
let code: u8 = "A"[0]
if code == 65 {
check world.out.write("character codes ok\n")
}
}
Binary file not shown.
@@ -0,0 +1,12 @@
pub fn main(world: World) -> Void raises {
let a00: i32 = 4
let a10: i32 = 2
let a11: i32 = 2
let l00: i32 = 2
let l10: i32 = a10 / l00
let l11: i32 = 1
let ok: Bool = l10 * l10 + l11 * l11 == a11 && l00 * l00 == a00
if ok {
check world.out.write("cholesky ok\n")
}
}
Binary file not shown.
+17
View File
@@ -0,0 +1,17 @@
fn chowla(n: u32) -> u32 {
var sum: u32 = 0
var d: u32 = 2
while d < n {
if n % d == 0 {
sum = sum + d
}
d = d + 1
}
return sum
}
pub fn main(world: World) -> Void raises {
if chowla(12) == 15 {
check world.out.write("chowla ok\n")
}
}
Binary file not shown.
+15
View File
@@ -0,0 +1,15 @@
fn rotate3(n: u32) -> u32 {
return n % 100 * 10 + n / 100
}
fn circularPrime3(n: u32) -> Bool {
let a: u32 = rotate3(n)
let b: u32 = rotate3(a)
return std.math.isPrimeU32(n) && std.math.isPrimeU32(a) && std.math.isPrimeU32(b)
}
pub fn main(world: World) -> Void raises {
if circularPrime3(197) {
check world.out.write("circular prime ok\n")
}
}
Binary file not shown.
@@ -0,0 +1,29 @@
fn choose(n: u32, k0: u32) -> u32 {
var k: u32 = k0
if k > n - k {
k = n - k
}
var result: u32 = 1
var i: u32 = 1
while i <= k {
result = result * (n - k + i) / i
i = i + 1
}
return result
}
fn permute(n: u32, k: u32) -> u32 {
var result: u32 = 1
var i: u32 = 0
while i < k {
result = result * (n - i)
i = i + 1
}
return result
}
pub fn main(world: World) -> Void raises {
if choose(5, 3) == 10 && permute(5, 3) == 60 {
check world.out.write("combinations permutations ok\n")
}
}
+7
View File
@@ -0,0 +1,7 @@
pub fn main(world: World) -> Void raises {
// Rosetta comments task: this line is intentionally a comment.
let value: i32 = 1 + 1
if value == 2 {
check world.out.write("comments ok\n")
}
}

Some files were not shown because too many files have changed in this diff Show More