Skip to content
Closed
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
78 changes: 59 additions & 19 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,86 @@ concurrency:
cancel-in-progress: true

jobs:
build-kernel:
name: Build verified Dafny kernel
runs-on: ubuntu-24.04
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
with:
dotnet-version: "8.0.x"
- name: Install Dafny 4.11 (with bundled Z3)
shell: bash
run: |
DAFNY_DIR="${{ runner.temp }}/dafny"
curl -fsSL -o "${{ runner.temp }}/dafny.zip" "https://github.com/dafny-lang/dafny/releases/download/v4.11.0/dafny-4.11.0-x64-ubuntu-22.04.zip"
unzip -q "${{ runner.temp }}/dafny.zip" -d "$DAFNY_DIR"
rm -f "${{ runner.temp }}/dafny.zip"
chmod +x "$DAFNY_DIR/dafny/dafny" "$DAFNY_DIR/dafny/z3/bin/"*
echo "$DAFNY_DIR/dafny" >> "$GITHUB_PATH"
"$DAFNY_DIR/dafny/dafny" --version
- name: Verify and compile Dafny kernel to Python
run: python3 scripts/tools/build_kernel.py --verify
- name: Upload compiled kernel artifact
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: dafny-kernel-gen
path: src/vkit/kernel/_dafny_gen
if-no-files-found: error
retention-days: 1

tests:
name: Core tests (${{ matrix.os }})
needs: [build-kernel]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v4
- name: Download compiled Dafny kernel
uses: actions/download-artifact@v4
with:
name: dafny-kernel-gen
path: src/vkit/kernel/_dafny_gen
- uses: astral-sh/setup-uv@v6
- run: uv sync --python 3.11 --extra test
- run: uv run pytest -ra
- run: uvx ruff@0.14.0 check --isolated --select E4,E7,E9,F src tests scripts formal
- run: uvx ruff@0.14.0 check --isolated --select E4,E7,E9,F --exclude src/vkit/kernel/_dafny_gen src tests scripts formal
- run: uv build
- name: Run the installed wheel CLI
run: uv run python -c "from pathlib import Path; import subprocess; wheel = next(Path('dist').glob('*.whl')); subprocess.run(['uv', 'run', '--isolated', '--no-project', '--with', str(wheel.resolve()), 'vkit', '--help'], check=True)"

formal:
name: Lean and TLC evidence
name: Dafny, Lean, and TLC evidence
needs: [build-kernel]
runs-on: ubuntu-24.04
timeout-minutes: 20
env:
VKIT_ALLOW_YES: "1"
steps:
- uses: actions/checkout@v4
- name: Download compiled Dafny kernel
uses: actions/download-artifact@v4
with:
name: dafny-kernel-gen
path: src/vkit/kernel/_dafny_gen
- uses: astral-sh/setup-uv@v6
- uses: actions/setup-dotnet@v4
with:
dotnet-version: "8.0.x"
- name: Install Dafny 4.11 (with bundled Z3)
shell: bash
run: |
DAFNY_DIR="${{ runner.temp }}/dafny"
curl -fsSL -o "${{ runner.temp }}/dafny.zip" "https://github.com/dafny-lang/dafny/releases/download/v4.11.0/dafny-4.11.0-x64-ubuntu-22.04.zip"
unzip -q "${{ runner.temp }}/dafny.zip" -d "$DAFNY_DIR"
rm -f "${{ runner.temp }}/dafny.zip"
chmod +x "$DAFNY_DIR/dafny/dafny" "$DAFNY_DIR/dafny/z3/bin/"*
echo "$DAFNY_DIR/dafny" >> "$GITHUB_PATH"
"$DAFNY_DIR/dafny/dafny" --version
- uses: leanprover/lean-action@v1
with:
lake-package-directory: examples/lean-proof
Expand Down Expand Up @@ -85,31 +139,17 @@ jobs:
with open(os.environ["GITHUB_ENV"], "a", encoding="utf-8") as output:
output.write(f"VKIT_TLA2TOOLS_JAR={jar}\n")
- run: uv sync --python 3.11 --extra test
- run: uv run python formal/checks/run.py --suite all --output "${{ runner.temp }}/vkit-formal-suite"
- run: uv run python formal/checks/verify_formal.py --backend all --output "${{ runner.temp }}/vkit-formal-evidence"
- run: uv run pytest tests/formal/test_logical_trust.py tests/formal/test_tlc_evidence.py -q
- run: uv run python formal/checks/check_lifecycle.py
- run: uv run python formal/checks/check_authority.py --output "${{ runner.temp }}/vkit-authority-evidence"
- run: uv run python formal/checks/check_authority.py --suite differences --output "${{ runner.temp }}/vkit-difference-evidence"
- run: uv run python formal/checks/check_authority.py --suite shadow --output "${{ runner.temp }}/vkit-shadow-authority-evidence"
- run: uv run python formal/checks/check_delegated_claim_authority.py --output "${{ runner.temp }}/vkit-delegated-claim-evidence"
- run: uv run python formal/checks/check_difference_decisions.py --output "${{ runner.temp }}/vkit-difference-decisions"
- run: uv run python formal/checks/check_finite_decisions.py --output "${{ runner.temp }}/vkit-finite-decisions/report.json"
- run: uv run pytest tests/formal/test_transition_model.py -q --basetemp "${{ runner.temp }}/vkit-transition-evidence"
- run: uv run pytest tests/formal/test_logical_trust.py tests/formal/test_tlc_evidence.py tests/formal/test_protocol_trace.py -q
- name: Retain formal evidence
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: formal-evidence-${{ github.sha }}
path: |
${{ runner.temp }}/vkit-formal-suite
${{ runner.temp }}/vkit-formal-evidence
.audit/lifecycle-model
${{ runner.temp }}/vkit-authority-evidence
${{ runner.temp }}/vkit-difference-evidence
${{ runner.temp }}/vkit-shadow-authority-evidence
${{ runner.temp }}/vkit-delegated-claim-evidence
${{ runner.temp }}/vkit-difference-decisions
${{ runner.temp }}/vkit-finite-decisions
${{ runner.temp }}/vkit-transition-evidence
include-hidden-files: true
if-no-files-found: error
retention-days: 14
127 changes: 0 additions & 127 deletions .github/workflows/ledger-qualification.yml

This file was deleted.

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ node_modules/
/.audit/
/TASKS.md
.worktrees/
*_TTrace_*.bin
*_TTrace_*.tla
src/vkit/kernel/_dafny_gen/
7 changes: 7 additions & 0 deletions decisions.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ts phase decision why evidence result
2026-12-02T22:17:20Z Phase-A Cloned vkit at d076db42632edf1b07925214a39b3f560f45e1a8 with --depth 50 and stripped PAT from origin Establish clean baseline while enforcing VM disk-safety and PAT hygiene .vm_scratch/setup_env.py; df /=16% /tmp=1% /usr/local=66% VERIFIED
2026-12-02T22:38:00Z Phase-A Completed 6-way parallel domain audit of entire vkit repo at d076db4 Cover all 264+ files without bloating main context window 6 subagent reports; pytest 926p/2f/9s in 443.79s; ruff clean; finite_decisions 354346 tuples VERIFIED
2026-12-02T23:08:56Z Phase-C Completed Milestone 2 across 4 disjoint workers (Core/Runtime, Verifiers/Change, CLI/Console/MCP/Plugin, Formal/TLA+) Fix all P0/P1 bugs, extract pure core/acceptance.py & pure interpreter cores, decompose cli.py & console.js, add SSE /api/events, and verify StoreRunnerLifecycle.tla & AgentStopHookProtocol.tla with TLC + Python conformance Core 283p; Verifiers+Change 346p + 2304 interpreter tuples (10/10 mutants); CLI+Console 119p + node --check 6/6; Formal TLC 7 models all PASS + 8/8 coordination mutants caught VERIFIED
2026-12-02T23:24:09Z Phase-C Completed Milestone 3 test compaction across tests/core, tests/rust, and tests/change Apply lean-test-discipline 4-lever hierarchy while preserving all verification/manifest.json and state.DOUBTS nodeids tests/core+rust -36 LOC & 30% faster on touched files (422p); tests/change -354 LOC (308p/4s); test_source_hygiene 4/4 PASS VERIFIED
2026-12-02T23:48:26Z Phase-E Passed all final verification gates across entire vkit repository Confirm zero regressions before committing branch audit/formal-arch-upgrade pytest 956p/9s/0f; ruff clean; all 12 formal checks PASS; 6/6 JS ES modules PASS; comment_lint plugin 0 findings; df /=16% /tmp=1% /usr/local=69% VERIFIED
2026-12-03T02:34:41Z Phase-E Completed Option 2 Waves 1-3 (Patchwork removal, 5-module Dafny->Python kernel, unified VKitProtocol.tla + TraceVKit.tla NDJSON trace validation) Eliminate formal patchwork without Verus, prove pure kernel directly into shipped Python with zero new PyPI deps, and bind real Python limbs to TLA+ via NDJSON traces dafny verify 39/39 (3.64s) + byte-identical regen; formal/checks/run.py --suite all 8/8 PASS; pytest 953p/9s/0f; wheel 462KB pure py3-none-any; ruff & comment_lint clean VERIFIED
2 changes: 1 addition & 1 deletion examples/formal-ci/tla2tools.sha256
Original file line number Diff line number Diff line change
@@ -1 +1 @@
fdffef247f563ef6edbfd44958d2a82db79e7564e07cb673262d896353fa6713
71c10e61d3ffe3b55549a9915142f5e2da106449d83119ee5418524ac719aae7
119 changes: 119 additions & 0 deletions formal/checks/_tlc_env.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
from __future__ import annotations

import hashlib
import os
import re
import shutil
import subprocess
import sys
from pathlib import Path
from typing import Mapping

ROOT = Path(__file__).resolve().parents[2]
EXPECTED_JAR_DIGEST = ROOT / "examples" / "formal-ci" / "tla2tools.sha256"

if str(ROOT / "src") not in sys.path:
sys.path.insert(0, str(ROOT / "src"))

from vkit.runtime.nowindow import hidden_window # noqa: E402

_ANSI = re.compile(r"\x1b\[[0-9;]*[A-Za-z]")
_VERSION = re.compile(r"Version\s+([0-9]+(?:\.[0-9]+)+)")

__all__ = [
"EXPECTED_JAR_DIGEST",
"ROOT",
"ToolchainUnavailable",
"expected_tlc_sha256",
"hidden_window",
"resolve_java",
"resolve_tlc_jar",
"sha256_file",
"tlc_version",
]


class ToolchainUnavailable(RuntimeError):
pass


def sha256_file(path: Path) -> str:
return hashlib.sha256(path.read_bytes()).hexdigest()


def expected_tlc_sha256() -> str:
return EXPECTED_JAR_DIGEST.read_text(encoding="ascii").strip()


def resolve_java(
java_arg: Path | None = None,
*,
env: Mapping[str, str] | None = None,
) -> Path:
env_map = os.environ if env is None else env
executable = "java.exe" if os.name == "nt" else "java"
path_env = env_map.get("PATH")
if java_arg is not None:
configured = java_arg.expanduser()
located = shutil.which(str(configured), path=path_env)
java = (
configured.resolve()
if configured.is_file()
else (Path(located).resolve() if located else None)
)
else:
java_home = env_map.get("JAVA_HOME")
home_candidate = Path(java_home) / "bin" / executable if java_home else None
located = shutil.which("java", path=path_env) or (
shutil.which("java.exe", path=path_env) if os.name == "nt" else None
)
java = (
home_candidate.resolve()
if home_candidate and home_candidate.is_file()
else (Path(located).resolve() if located else None)
)
if java is None or not java.is_file():
raise ToolchainUnavailable("Java is unavailable; set JAVA_HOME or pass --java")
return java


def resolve_tlc_jar(
jar_arg: Path | None = None,
*,
env: Mapping[str, str] | None = None,
verify_sha256: bool = True,
) -> Path:
env_map = os.environ if env is None else env
raw_env = env_map.get("VKIT_TLA2TOOLS_JAR", "").strip()
configured = jar_arg or (Path(raw_env) if raw_env else None)
if configured is None:
raise ToolchainUnavailable(
"TLC jar is unavailable; set VKIT_TLA2TOOLS_JAR or pass --jar"
)
jar = configured.expanduser().resolve()
if not jar.is_file():
raise ToolchainUnavailable(f"TLC jar does not exist: {jar}")
if verify_sha256:
expected = expected_tlc_sha256()
observed = sha256_file(jar)
if observed != expected:
raise RuntimeError(
f"TLC jar SHA-256 mismatch: expected {expected}, observed {observed}"
)
return jar


def tlc_version(java: Path, jar: Path) -> str:
done = subprocess.run(
[str(java), "-cp", str(jar), "tlc2.TLC", "-help"],
capture_output=True,
text=True,
timeout=30,
check=False,
**hidden_window(),
)
text = _ANSI.sub("", (done.stdout or "") + "\n" + (done.stderr or ""))
match = _VERSION.search(text)
if match is None:
raise RuntimeError(f"could not determine TLC version from {jar}")
return match.group(1)
Loading
Loading