Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.git
.github
target
dist
.nosrc-cache
.nosrc-exports
165 changes: 156 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,185 @@ on:
push:
tags:
- "v*"
pull_request:

permissions:
contents: write
contents: read

jobs:
validate:
name: Validate milestone tag
name: Validate release ref
runs-on: ubuntu-latest
steps:
- name: Check out source
- name: Check out source and history
uses: actions/checkout@v7
with:
fetch-depth: 0

- name: Validate milestone tag
if: github.event_name == 'push'
run: bash scripts/check-release-tag.sh "$GITHUB_REF_NAME"

# Windows and macOS only run selectively on ordinary commits, so a release must pass them.
- name: Require a commit already merged to main
if: github.event_name == 'push'
run: |
git fetch origin main --no-tags
git merge-base --is-ancestor "$GITHUB_SHA" origin/main || {
echo "Release tags must point to a commit reachable from main" >&2
exit 1
}

platforms:
name: Windows and macOS tests
needs: validate
permissions:
contents: read
uses: ./.github/workflows/platforms.yml

build:
name: Build (${{ matrix.target }})
needs: validate
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- runner: ubuntu-24.04
target: x86_64-unknown-linux-gnu
- runner: ubuntu-24.04-arm
target: aarch64-unknown-linux-gnu
- runner: macos-15
target: aarch64-apple-darwin
- runner: windows-2025
target: x86_64-pc-windows-msvc
steps:
- name: Check out source
uses: actions/checkout@v7

- name: Install stable Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}

- name: Cache Cargo artifacts
uses: Swatinem/rust-cache@v2
with:
key: release-${{ matrix.target }}
cache-on-failure: true

- name: Build release binary
run: cargo build --locked --release --target "${{ matrix.target }}"

- name: Package Unix binary
if: runner.os != 'Windows'
shell: bash
run: |
mkdir -p dist
tar -C "target/${{ matrix.target }}/release" -czf "dist/nosrc-${{ matrix.target }}.tar.gz" nosrc

- name: Package Windows binary
if: runner.os == 'Windows'
shell: pwsh
run: |
New-Item -ItemType Directory -Force -Path dist | Out-Null
Compress-Archive -Path "target/${{ matrix.target }}/release/nosrc.exe" -DestinationPath "dist/nosrc-${{ matrix.target }}.zip"

- name: Upload release archive
uses: actions/upload-artifact@v7
with:
name: nosrc-${{ matrix.target }}
path: dist/nosrc-${{ matrix.target }}.*
if-no-files-found: error
retention-days: 7

artifact-smoke:
name: Smoke-test Linux release binary offline
needs: build
runs-on: ubuntu-24.04
steps:
- name: Check out source
uses: actions/checkout@v7

- name: Install stable Rust
uses: dtolnay/rust-toolchain@stable

- name: Download Linux x86_64 release binary
uses: actions/download-artifact@v7
with:
name: nosrc-x86_64-unknown-linux-gnu
path: dist

- name: Extract release binary
run: |
tar -xzf dist/nosrc-x86_64-unknown-linux-gnu.tar.gz -C dist
chmod +x dist/nosrc
dist/nosrc --help

- name: Export and serve an offline bundle using the release binary
env:
NOSRC_TEST_BINARY: ${{ github.workspace }}/dist/nosrc
run: |
cargo test --locked --test mcp_stdio mcp_exported_generation_can_be_served_offline_without_provider_credentials -- --exact

publish:
name: Create GitHub Release
needs: [validate, platforms]
runs-on: ubuntu-latest
if: github.event_name == 'push'
name: Publish GitHub Release and container
needs: [validate, platforms, build, artifact-smoke]
runs-on: ubuntu-24.04
permissions:
contents: write
packages: write
steps:
- name: Check out source
uses: actions/checkout@v7

- name: Create GitHub Release
- name: Download all release archives
uses: actions/download-artifact@v7
with:
pattern: nosrc-*
path: dist
merge-multiple: true

- name: Create SHA-256 checksums
run: |
cd dist
sha256sum nosrc-*.tar.gz nosrc-*.zip 2>/dev/null > SHA256SUMS

- name: Create GitHub Release and upload artifacts
env:
GH_TOKEN: ${{ github.token }}
run: gh release create "$GITHUB_REF_NAME" --title "$GITHUB_REF_NAME" --generate-notes
run: |
gh release create "$GITHUB_REF_NAME" --title "$GITHUB_REF_NAME" --generate-notes
gh release upload "$GITHUB_REF_NAME" dist/nosrc-* dist/SHA256SUMS

- name: Prepare multi-architecture container context
run: |
mkdir -p container-context
tar -xzf dist/nosrc-x86_64-unknown-linux-gnu.tar.gz -C container-context
mv container-context/nosrc container-context/nosrc-linux-amd64
tar -xzf dist/nosrc-aarch64-unknown-linux-gnu.tar.gz -C container-context
mv container-context/nosrc container-context/nosrc-linux-arm64
cp Dockerfile container-context/Dockerfile

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Publish multi-architecture container image
uses: docker/build-push-action@v6
with:
context: container-context
platforms: linux/amd64,linux/arm64
push: true
tags: |
ghcr.io/nonops/nosrc:${{ github.ref_name }}
ghcr.io/nonops/nosrc:latest
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM debian:trixie-slim

LABEL org.opencontainers.image.source="https://github.com/NonOps/nosrc"

ARG TARGETARCH
COPY nosrc-linux-${TARGETARCH} /usr/local/bin/nosrc

RUN groupadd --system --gid 10001 nosrc \
&& useradd --system --uid 10001 --gid nosrc --home-dir /var/lib/nosrc \
--create-home --shell /usr/sbin/nologin nosrc \
&& chmod 0555 /usr/local/bin/nosrc

USER 10001:10001
WORKDIR /var/lib/nosrc

ENTRYPOINT ["/usr/local/bin/nosrc"]
25 changes: 18 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,23 @@ These are operating modes of one executable, not separate guest runtimes. MCP ca

The model-generated assertion suite is supplemental. It does not replace the operator-authored SPEC verification suite, and passing tests do not prove correctness or security.

## Install a release binary

Prebuilt binaries for Linux (x86_64 and aarch64, glibc 2.39+), macOS (Apple Silicon), and Windows (x86_64 MSVC) are attached to each [GitHub Release](https://github.com/NonOps/nosrc/releases). Verify downloads with the published SHA-256 checksums. See [Installation and deployment](docs/INSTALL.md) for exact commands, container usage, and supervisor examples.

For a source build, Rust 1.97 or later is required:

```sh
cargo install --path .
```

## Quick start: HTTP

Requirements: Rust 1.97 or later, Cargo, and an OpenAI-compatible API key.
Requirements: an installed nosrc binary and an OpenAI-compatible API key. Rust is not required when using a release binary.

```sh
export LLM_API_KEY="your-api-key"
cargo run -- --spec ./examples/minimal/SPEC.md --port 8080
nosrc --spec ./examples/minimal/SPEC.md --port 8080
```

The listener binds to `127.0.0.1` by default. Use `--bind 0.0.0.0` only when external access is intended. Check the runtime and example endpoint:
Expand All @@ -81,23 +91,23 @@ curl -i http://localhost:8080/hello

```sh
export LLM_API_KEY="your-api-key" # required for source: "spec"
cargo run -- mcp --spec ./examples/minimal/SPEC.md
nosrc mcp --spec ./examples/minimal/SPEC.md
```

The default MCP mode uses stdio and does not open an HTTP listener. It exposes six tools: `prepare_app`, `activate_app`, `invoke_app`, `get_app_status`, `rollback_app`, and `export_app`. Exports are confined to the configured `--export-root` (default `./.nosrc-exports`). Rollback is limited to the immediately previous retained generation. Generation state and rollback history are process-local and disappear when the MCP process exits. Failed `prepare_app` calls return bounded structured diagnostics: stable verification-case IDs, expected/actual status, allowlisted response headers, redacted JSON body previews where safe, compiler details, and resource-limit categories. Trusted verification policy, request inputs, and arbitrary non-JSON response bodies are not returned.

MCP can also start without an operator SPEC:

```sh
cargo run -- mcp
nosrc mcp
```

This starts with empty application state and baseline runtime resource limits. The agent can prepare direct JavaScript with `source: "direct_js"`, or provide a draft contract with `source: "draft_spec"` and a `draft_spec` Markdown string. Draft SPEC data is synthesis input and candidate-test material, not trusted operator policy. Prepared generations can be inspected, and draft-SPEC generations can be exported for review, but **cannot be activated** until an operator reviews the draft and restarts nosrc with it as `--spec PATH`; activation always requires at least one operator-controlled trusted verification case. Direct-JavaScript preparation without a startup SPEC is a compile/preparation check only: it cannot be invoked, activated, or exported. MCP `export_app` accepts only a single bundle directory name beneath the configured `--export-root` (default `./.nosrc-exports`), never an arbitrary filesystem path. The bundle includes `SPEC.md`, handler source, component, assertions, and manifest, and can be served without an API key.

To expose HTTP from the same process and share the active generation with MCP, add `--http-port` (and optionally `--http-bind`):

```sh
LLM_API_KEY="your-api-key" cargo run -- mcp --spec ./examples/minimal/SPEC.md --http-port 8080
LLM_API_KEY="your-api-key" nosrc mcp --spec ./examples/minimal/SPEC.md --http-port 8080
```

MCP activation and rollback update the handler used by HTTP ingress. This is one application lifecycle and one generation history, not two runtimes synchronized over a network. The HTTP listener defaults to loopback; use `--http-bind 0.0.0.0` only when external exposure is intended. The stdio transport itself remains local and has no MCP-level authentication.
Expand Down Expand Up @@ -134,7 +144,7 @@ The `--spec` file is the operator-controlled trusted policy: a connected agent c

```sh
export LLM_API_KEY="your-api-key"
cargo run -- export --spec ./examples/minimal/SPEC.md --out-dir ./dist
nosrc export --spec ./examples/minimal/SPEC.md --out-dir ./dist
```

The export command runs synthesis (or loads a cache entry), componentization/compilation, trusted and generated verification, and fresh production-instance creation before writing:
Expand All @@ -152,7 +162,7 @@ The export directory is for inspection, audit support, and version control. The
After exporting a bundle, start the HTTP runtime without an API key or model-provider request:

```sh
cargo run -- serve --bundle ./dist --bind 127.0.0.1 --port 8080
nosrc serve --bundle ./dist --bind 127.0.0.1 --port 8080
```

Startup validates the bundle files and SHA-256 metadata, compiles the prebuilt component with the current Wasmtime engine, reruns the assertion suites on separate candidate instances according to the manifest policy mode, runs the fixed host-owned ABI probes on another disposable instance, and creates a fresh serving instance only after every check passes. The HTTP listener opens only after successful validation. This mode does not read a SPEC file, synthesize code, or access an LLM provider.
Expand Down Expand Up @@ -221,6 +231,7 @@ Git tags and GitHub Releases use the short milestone form: `v0.1`, `v0.2`, `v0.3

## Project documentation

- [Installation and deployment](docs/INSTALL.md)
- [Architecture and implemented design](ARCHITECTURE.md)
- [CLI reference](docs/CLI.md)
- [Exported artifact format](docs/ARTIFACTS.md)
Expand Down
Loading
Loading