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 .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,9 @@ data/surnames/surnames.csv filter=lfs diff=lfs merge=lfs -text
data/surnames/forenames.csv filter=lfs diff=lfs merge=lfs -text
data/raw/personachat/personachat.tgz filter=lfs diff=lfs merge=lfs -text
cmake/hnswlib-prefetch-bounds.patch text eol=lf

# AIST model shards + tokenizer vocab must stay byte-identical (SHA-256 on reassembly).
models/** -text
models/**/*.part-* binary
models/mdbr-leaf-ir/vocab.txt binary
models/manifest.json text eol=lf
17 changes: 9 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
sudo apt-get install -y cmake build-essential pkg-config libsqlite3-dev

- name: Configure CMake
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCORTEXT_FETCH_AIST_MODEL=OFF -DCORTEXT_DISABLE_OPENTELEMETRY=ON -DCORTEXT_EXPERIMENT_HOOKS=ON
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCORTEXT_EMBED_AIST_MODEL=OFF -DCORTEXT_FETCH_AIST_MODEL=OFF -DCORTEXT_DISABLE_OPENTELEMETRY=ON -DCORTEXT_EXPERIMENT_HOOKS=ON

- name: Build
run: cmake --build build -j8
Expand All @@ -38,7 +38,7 @@ jobs:
docker run --rm -v "$PWD:/workspace" -w /workspace archlinux:base-devel bash -lc '
pacman -Syu --noconfirm cmake make gcc pkgconf sqlite git
git config --global --add safe.directory /workspace
cmake -S . -B build-arch -DCMAKE_BUILD_TYPE=Release -DCORTEXT_FETCH_AIST_MODEL=OFF -DCORTEXT_DISABLE_OPENTELEMETRY=ON -DCORTEXT_EXPERIMENT_HOOKS=ON
cmake -S . -B build-arch -DCMAKE_BUILD_TYPE=Release -DCORTEXT_EMBED_AIST_MODEL=OFF -DCORTEXT_FETCH_AIST_MODEL=OFF -DCORTEXT_DISABLE_OPENTELEMETRY=ON -DCORTEXT_EXPERIMENT_HOOKS=ON
cmake --build build-arch -j"$(nproc)"
./build-arch/tests/cortext_tests "~[aist]" --reporter compact
'
Expand Down Expand Up @@ -66,7 +66,7 @@ jobs:
run: python3 scripts/download_aist_model.py --output-dir models --quant q8_0

- name: Configure CMake
run: cmake -S . -B build-aist -DCMAKE_BUILD_TYPE=Release -DCORTEXT_FETCH_AIST_MODEL=OFF -DCORTEXT_DISABLE_OPENTELEMETRY=ON -DCORTEXT_EXPERIMENT_HOOKS=ON
run: cmake -S . -B build-aist -DCMAKE_BUILD_TYPE=Release -DCORTEXT_EMBED_AIST_MODEL=ON -DCORTEXT_FETCH_AIST_MODEL=OFF -DCORTEXT_DISABLE_OPENTELEMETRY=ON -DCORTEXT_EXPERIMENT_HOOKS=ON

- name: Build
run: cmake --build build-aist -j8
Expand All @@ -86,7 +86,7 @@ jobs:
sudo apt-get install -y cmake build-essential pkg-config libsqlite3-dev

- name: Configure CMake
run: cmake -S . -B build-sanitizers -DCMAKE_BUILD_TYPE=Debug -DCORTEXT_FETCH_AIST_MODEL=OFF -DCORTEXT_DISABLE_OPENTELEMETRY=ON -DCORTEXT_EXPERIMENT_HOOKS=ON -DCORTEXT_ENABLE_ASAN=ON -DCORTEXT_ENABLE_UBSAN=ON
run: cmake -S . -B build-sanitizers -DCMAKE_BUILD_TYPE=Debug -DCORTEXT_EMBED_AIST_MODEL=OFF -DCORTEXT_FETCH_AIST_MODEL=OFF -DCORTEXT_DISABLE_OPENTELEMETRY=ON -DCORTEXT_EXPERIMENT_HOOKS=ON -DCORTEXT_ENABLE_ASAN=ON -DCORTEXT_ENABLE_UBSAN=ON

- name: Build
run: cmake --build build-sanitizers -j8
Expand Down Expand Up @@ -130,13 +130,13 @@ jobs:
sudo apt-get install -y libsqlite3-dev

- name: Fetch Zig dependencies
run: zig build --fetch -Dshared=true
run: zig build --fetch -Dshared=true -Dembed-aist-model=false

- name: Build Zig host FFI library
run: zig build -Dshared=true
run: zig build -Dshared=true -Dembed-aist-model=false

- name: Cross-build Zig FFI library
run: zig build -Dtarget=x86_64-linux-gnu -Dshared=true
run: zig build -Dtarget=x86_64-linux-gnu -Dshared=true -Dembed-aist-model=false

zig-cli-install:
runs-on: ${{ matrix.os }}
Expand All @@ -158,7 +158,7 @@ jobs:

- name: Build installable Zig CLI
shell: bash
run: zig build -Doptimize=ReleaseFast -Dshared=false -Dcli=true -Dfetch-aist-model=false
run: zig build -Doptimize=ReleaseFast -Dshared=false -Dcli=true -Dembed-aist-model=false -Dfetch-aist-model=false

- name: Check installed CLI artifact
shell: bash
Expand Down Expand Up @@ -199,6 +199,7 @@ jobs:
-Doptimize=ReleaseFast \
-Dshared=false \
-Dcli=true \
-Dembed-aist-model=false \
-Dfetch-aist-model=false

- name: Check target CLI artifact
Expand Down
172 changes: 172 additions & 0 deletions .github/workflows/release-assets.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
name: Release assets

# Publishes multi-arch shared libraries + AIST model shards as GitHub Release
# assets so language bindings (cortext.py, cortext.go, plugins) do not each
# vendor the same ~160 MiB of natives/model data.
#
# Artifact names:
# cortext-assets-<version>.tar.gz
# cortext-assets-<version>.tar.gz.sha256
#
# Unpacked layout (also documented in scripts/build_release_assets.py):
# native/<platform-tag>/libcortext.* | cortext.dll
# models/manifest.json + chunked AIST + vocab

on:
push:
tags:
- "v*"
release:
types: [published]
workflow_dispatch:
inputs:
tag:
description: "Existing release tag to attach assets to (e.g. v1.2.3). Empty = build only."
required: false
default: ""
upload:
description: "Upload tarball to the GitHub release for the tag"
required: false
type: boolean
default: true

permissions:
contents: write

jobs:
build-and-upload:
runs-on: ubuntu-latest
steps:
# Resolve the git ref before checkout so workflow_dispatch with inputs.tag
# builds the same revision that the release will receive.
- name: Resolve checkout ref
id: checkout_ref
shell: bash
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" && -n "${{ inputs.tag }}" ]]; then
REF="${{ inputs.tag }}"
elif [[ "${{ github.event_name }}" == "release" ]]; then
REF="${{ github.event.release.tag_name }}"
else
# Tag push (or any other trigger): use the event ref.
REF="${{ github.ref }}"
fi
echo "ref=$REF" >> "$GITHUB_OUTPUT"
echo "Checkout ref=$REF"

- uses: actions/checkout@v4
Comment thread
gabewillen marked this conversation as resolved.
with:
ref: ${{ steps.checkout_ref.outputs.ref }}

- uses: mlugg/setup-zig@v2
with:
version: 0.15.2

- name: Install host deps
run: |
sudo apt-get update
sudo apt-get install -y libsqlite3-dev

- name: Cache AIST q8_0 model
uses: actions/cache@v4
with:
path: |
models/AIST-87M-GGUF/AIST-87M_q8_0.gguf
models/mdbr-leaf-ir/vocab.txt
key: aist-q8_0-bf4c49954eccc65183f1a97e44606e86c7ee5a4fea500457124b687a3ec97898-bert-vocab-07eced375cec144d27c900241f3e339478dec958f92fddbc551f295c992038a3

- name: Resolve version
id: ver
shell: bash
run: |
if [[ "${{ github.event_name }}" == "push" && "${{ github.ref_type }}" == "tag" ]]; then
TAG="${{ github.ref_name }}"
elif [[ "${{ github.event_name }}" == "release" ]]; then
TAG="${{ github.event.release.tag_name }}"
elif [[ -n "${{ inputs.tag }}" ]]; then
TAG="${{ inputs.tag }}"
else
TAG=""
fi
if [[ -n "$TAG" ]]; then
VERSION="${TAG#v}"
else
VERSION="$(python3 -c "import re,pathlib; t=pathlib.Path('bindings/python/pyproject.toml').read_text(); m=re.search(r'version\s*=\s*\"([^\"]+)\"', t); print(m.group(1) if m else '0.0.0-dev')")"
TAG="v${VERSION}"
fi
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "Resolved tag=$TAG version=$VERSION"

- name: Build release asset tree + tarball
run: |
python3 scripts/build_release_assets.py \
--version "${{ steps.ver.outputs.version }}" \
--optimize ReleaseSmall

- name: Inventory assets
run: |
echo "== tree =="
find dist/release-assets -type f | sort
echo "== tarball =="
ls -lh dist/cortext-assets-*.tar.gz*
python3 - <<'PY'
import json
from pathlib import Path
root = Path("dist/release-assets")
native = json.loads((root / "native" / "manifest.json").read_text())
models = json.loads((root / "models" / "manifest.json").read_text())
tags = [t["package_tag"] for t in native["targets"]]
assert len(tags) == 6, tags
for tag in tags:
art = next(t["artifact"] for t in native["targets"] if t["package_tag"] == tag)
path = root / "native" / tag / art
assert path.is_file() and path.stat().st_size > 100_000, path
chunks = models["assets"][0]["chunks"]
assert len(chunks) >= 2, chunks
for c in chunks:
p = root / "models" / c["filename"]
assert p.is_file(), p
print("inventory ok:", tags, "chunks", len(chunks))
PY

- name: Upload workflow artifacts
uses: actions/upload-artifact@v4
with:
name: cortext-assets-${{ steps.ver.outputs.version }}
path: |
dist/cortext-assets-${{ steps.ver.outputs.version }}.tar.gz
dist/cortext-assets-${{ steps.ver.outputs.version }}.tar.gz.sha256
dist/release-assets/manifest.json
if-no-files-found: error

- name: Attach to GitHub Release
if: |
(github.event_name == 'push' && github.ref_type == 'tag') ||
github.event_name == 'release' ||
(github.event_name == 'workflow_dispatch' && inputs.upload && inputs.tag != '')
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: |
set -euo pipefail
TAG="${{ steps.ver.outputs.tag }}"
VERSION="${{ steps.ver.outputs.version }}"
TGZ="dist/cortext-assets-${VERSION}.tar.gz"
SUM="dist/cortext-assets-${VERSION}.tar.gz.sha256"
test -s "$TGZ"
test -s "$SUM"

# Create a draft release if the tag exists but no release yet, so
# maintainers can edit notes before publishing.
if ! gh release view "$TAG" >/dev/null 2>&1; then
echo "Creating draft release $TAG"
gh release create "$TAG" \
--title "Cortext v${VERSION}" \
--notes "Automated release assets for language bindings (natives + AIST model shards)." \
--draft \
--verify-tag
Comment thread
gabewillen marked this conversation as resolved.
fi

gh release upload "$TAG" "$TGZ" "$SUM" --clobber
echo "Uploaded $TGZ and $SUM to $TAG"
21 changes: 12 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,18 @@ data/raw/
data/memory_evals/
data/emotion/
data/ravdess/
models/
!include/cortext/models/
!include/cortext/models/**
!src/models/
!src/models/**
!bindings/python/augmem/cortext/models/
!bindings/python/augmem/cortext/models/.gitkeep
!bindings/javascript/models/
!bindings/javascript/models/.gitkeep
# Full GGUF payloads stay local/build-time only. Git-friendly AIST shards +
# vocab + manifest are tracked so binding repos can vendor without re-sharding.
/models/*
!/models/manifest.json
!/models/AIST-87M-GGUF/
/models/AIST-87M-GGUF/*
!/models/AIST-87M-GGUF/chunks/
/models/AIST-87M-GGUF/chunks/*
!/models/AIST-87M-GGUF/chunks/*.part-*
!/models/mdbr-leaf-ir/
/models/mdbr-leaf-ir/*
!/models/mdbr-leaf-ir/vocab.txt
*.dat
*.npy

Expand Down
Loading
Loading