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
3 changes: 3 additions & 0 deletions examples/basic_cycle.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# SPDX-FileCopyrightText: 2026 Сацук Артём Венедиктович (Satsuk Artem)
# SPDX-License-Identifier: Apache-2.0

from __future__ import annotations

import asyncio
Expand Down
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ name = "spiral-autonomy-kernel"
version = "1.0.0"
description = "Persistent, policy-bounded self-evolution runtime for LLM-based systems"
readme = "README.md"
license = { file = "LICENSE" }
requires-python = ">=3.10"
dependencies = [
"httpx>=0.27,<1",
]
classifiers = [
"License :: OSI Approved :: Apache Software License",
]

[project.optional-dependencies]
dev = [
Expand Down
35 changes: 26 additions & 9 deletions scripts/build_proof_pack.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# SPDX-FileCopyrightText: 2026 Сацук Артём Венедиктович (Satsuk Artem)
# SPDX-License-Identifier: Apache-2.0

from __future__ import annotations

import json
Expand All @@ -13,16 +16,30 @@
RUNTIME_DIR = ROOT / '.sif'


def _run(command: list[str]) -> subprocess.CompletedProcess[str]:
def _run(command: list[str], retries: int = 0) -> subprocess.CompletedProcess[str]:
env = dict(os.environ)
env['PYTHONPATH'] = 'src'
return subprocess.run(
command,
cwd=ROOT,
text=True,
capture_output=True,
check=True,
env=env,
attempts = retries + 1
last_result: subprocess.CompletedProcess[str] | None = None
for _ in range(attempts):
result = subprocess.run(
command,
cwd=ROOT,
text=True,
capture_output=True,
check=False,
env=env,
)
if result.returncode == 0:
return result
last_result = result

assert last_result is not None
command_str = " ".join(command)
raise RuntimeError(
f"Command failed after {attempts} attempt(s): {command_str}\n"
f"stdout:\n{last_result.stdout}\n"
f"stderr:\n{last_result.stderr}"
)


Expand All @@ -33,7 +50,7 @@ def main() -> None:

try:
compile_result = _run([sys.executable, '-m', 'compileall', '-q', 'src'])
test_result = _run([sys.executable, '-m', 'pytest', '-q'])
test_result = _run([sys.executable, '-m', 'pytest', '-q'], retries=1)
smoke_result = _run([
sys.executable,
'-m',
Expand Down
4 changes: 4 additions & 0 deletions scripts/check.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#!/usr/bin/env bash
# SPDX-FileCopyrightText: 2026 Сацук Артём Венедиктович (Satsuk Artem)
# SPDX-License-Identifier: Apache-2.0

set -euo pipefail

python scripts/check_license_headers.py
pytest -q
python -m compileall -q src
PYTHONPATH=src python -m sif.cli --cycles 1 --json >/dev/null
Expand Down
38 changes: 38 additions & 0 deletions scripts/check_license_headers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# SPDX-FileCopyrightText: 2026 Сацук Артём Венедиктович (Satsuk Artem)
# SPDX-License-Identifier: Apache-2.0

from __future__ import annotations

from pathlib import Path

ROOTS = ("src", "tests", "scripts", "examples")
SUFFIXES = {".py", ".sh"}
COPYRIGHT_TAG = "SPDX-FileCopyrightText:"
LICENSE_TAG = "SPDX-License-Identifier: Apache-2.0"


def main() -> int:
missing: list[str] = []

for root in ROOTS:
for path in sorted(Path(root).rglob("*")):
if path.suffix not in SUFFIXES:
continue
header = path.read_text().splitlines()[:8]
has_copyright = any(COPYRIGHT_TAG in line for line in header)
has_license = any(LICENSE_TAG in line for line in header)
if not (has_copyright and has_license):
missing.append(str(path))

if missing:
print("Missing SPDX header tags in:")
for path in missing:
print(f" - {path}")
return 1

print("All checked code files include SPDX copyright and license tags.")
return 0


if __name__ == "__main__":
raise SystemExit(main())
3 changes: 3 additions & 0 deletions scripts/run_demo.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#!/usr/bin/env bash
# SPDX-FileCopyrightText: 2026 Сацук Артём Венедиктович (Satsuk Artem)
# SPDX-License-Identifier: Apache-2.0

set -euo pipefail

PYTHONPATH=src python -m sif.cli --cycles 1 --json
3 changes: 3 additions & 0 deletions src/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# SPDX-FileCopyrightText: 2026 Сацук Артём Венедиктович (Satsuk Artem)
# SPDX-License-Identifier: Apache-2.0

"""Spiral Autonomy Kernel source tree."""

__all__: list[str] = []
22 changes: 19 additions & 3 deletions src/aiosqlite.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# SPDX-FileCopyrightText: 2026 Сацук Артём Венедиктович (Satsuk Artem)
# SPDX-License-Identifier: Apache-2.0

from __future__ import annotations

"""Lightweight local subset of the aiosqlite API used by this repository.
Expand All @@ -22,11 +25,17 @@


class Cursor:
def __init__(self, connection: 'Connection', sql: str, parameters: Iterable[Any] | None = None) -> None:
def __init__(
self,
connection: 'Connection',
sql: str,
parameters: Iterable[Any] | None = None,
prefetched_rows: list[Any] | None = None,
) -> None:
self._connection = connection
self._sql = sql
self._parameters = tuple(parameters or ())
self._rows: list[Any] | None = None
self._rows: list[Any] | None = prefetched_rows
self._index = 0

async def _ensure_rows(self) -> list[Any]:
Expand Down Expand Up @@ -100,7 +109,14 @@ async def __aexit__(self, exc_type, exc, tb) -> None:

async def execute(self, sql: str, parameters: Iterable[Any] | None = None) -> Cursor:
await self._ensure_open()
return Cursor(self, sql, parameters)
async with self._lock:
def _run() -> list[Any]:
assert self._conn is not None
sqlite_cursor = self._conn.execute(sql, tuple(parameters or ()))
return list(sqlite_cursor.fetchall())

rows = await asyncio.to_thread(_run)
return Cursor(self, sql, parameters, prefetched_rows=rows)

async def executemany(self, sql: str, seq_of_parameters: Iterable[Iterable[Any]]) -> None:
await self._ensure_open()
Expand Down
3 changes: 3 additions & 0 deletions src/cli.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# SPDX-FileCopyrightText: 2026 Сацук Артём Венедиктович (Satsuk Artem)
# SPDX-License-Identifier: Apache-2.0

from sif.cli import main

__all__ = ['main']
Expand Down
3 changes: 3 additions & 0 deletions src/components/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
# SPDX-FileCopyrightText: 2026 Сацук Артём Венедиктович (Satsuk Artem)
# SPDX-License-Identifier: Apache-2.0

"""Component definitions for Spiral Autonomy Kernel."""
3 changes: 3 additions & 0 deletions src/components/adaptation.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# SPDX-FileCopyrightText: 2026 Сацук Артём Венедиктович (Satsuk Artem)
# SPDX-License-Identifier: Apache-2.0

from dataclasses import dataclass
from typing import Any, Dict, List

Expand Down
3 changes: 3 additions & 0 deletions src/components/autonomy_scope.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# SPDX-FileCopyrightText: 2026 Сацук Артём Венедиктович (Satsuk Artem)
# SPDX-License-Identifier: Apache-2.0

from dataclasses import dataclass
import json
from typing import Any, Dict, List
Expand Down
3 changes: 3 additions & 0 deletions src/components/base.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# SPDX-FileCopyrightText: 2026 Сацук Артём Венедиктович (Satsuk Artem)
# SPDX-License-Identifier: Apache-2.0

from dataclasses import dataclass, field
from typing import Any, Dict, List

Expand Down
3 changes: 3 additions & 0 deletions src/components/code_mutation.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# SPDX-FileCopyrightText: 2026 Сацук Артём Венедиктович (Satsuk Artem)
# SPDX-License-Identifier: Apache-2.0

from dataclasses import dataclass
from pathlib import Path
from typing import Any, Dict, List
Expand Down
3 changes: 3 additions & 0 deletions src/components/constraint_explorer.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# SPDX-FileCopyrightText: 2026 Сацук Артём Венедиктович (Satsuk Artem)
# SPDX-License-Identifier: Apache-2.0

from dataclasses import dataclass
import json
from typing import Any, Dict, List
Expand Down
3 changes: 3 additions & 0 deletions src/components/generated/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
# SPDX-FileCopyrightText: 2026 Сацук Артём Венедиктович (Satsuk Artem)
# SPDX-License-Identifier: Apache-2.0

"""Generated components package."""
3 changes: 3 additions & 0 deletions src/components/generated/auto_component.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# SPDX-FileCopyrightText: 2026 Сацук Артём Венедиктович (Satsuk Artem)
# SPDX-License-Identifier: Apache-2.0

from dataclasses import dataclass
from typing import Any, Dict, List

Expand Down
3 changes: 3 additions & 0 deletions src/components/governance.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# SPDX-FileCopyrightText: 2026 Сацук Артём Венедиктович (Satsuk Artem)
# SPDX-License-Identifier: Apache-2.0

from dataclasses import dataclass
from typing import Any, Dict, List

Expand Down
3 changes: 3 additions & 0 deletions src/components/improvement_protocol.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# SPDX-FileCopyrightText: 2026 Сацук Артём Венедиктович (Satsuk Artem)
# SPDX-License-Identifier: Apache-2.0

from dataclasses import dataclass
from typing import Any, Dict, List

Expand Down
3 changes: 3 additions & 0 deletions src/components/mission_alignment.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# SPDX-FileCopyrightText: 2026 Сацук Артём Венедиктович (Satsuk Artem)
# SPDX-License-Identifier: Apache-2.0

from dataclasses import dataclass
import json
from typing import Any, Dict, List
Expand Down
3 changes: 3 additions & 0 deletions src/components/registry.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# SPDX-FileCopyrightText: 2026 Сацук Артём Венедиктович (Satsuk Artem)
# SPDX-License-Identifier: Apache-2.0

import logging
from dataclasses import dataclass, field
from importlib import import_module
Expand Down
3 changes: 3 additions & 0 deletions src/core/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
# SPDX-FileCopyrightText: 2026 Сацук Артём Венедиктович (Satsuk Artem)
# SPDX-License-Identifier: Apache-2.0

"""Core modules for Spiral Autonomy Kernel."""
3 changes: 3 additions & 0 deletions src/core/adaptive_rules.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# SPDX-FileCopyrightText: 2026 Сацук Артём Венедиктович (Satsuk Artem)
# SPDX-License-Identifier: Apache-2.0

from dataclasses import dataclass, field
import json
from typing import Any, Dict, List, Tuple
Expand Down
3 changes: 3 additions & 0 deletions src/core/async_cpu.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# SPDX-FileCopyrightText: 2026 Сацук Артём Венедиктович (Satsuk Artem)
# SPDX-License-Identifier: Apache-2.0

from __future__ import annotations

import asyncio
Expand Down
3 changes: 3 additions & 0 deletions src/core/async_fs.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# SPDX-FileCopyrightText: 2026 Сацук Артём Венедиктович (Satsuk Artem)
# SPDX-License-Identifier: Apache-2.0

from __future__ import annotations

import asyncio
Expand Down
3 changes: 3 additions & 0 deletions src/core/autonomous_evolution.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# SPDX-FileCopyrightText: 2026 Сацук Артём Венедиктович (Satsuk Artem)
# SPDX-License-Identifier: Apache-2.0

from dataclasses import dataclass
import json
from typing import Any, Dict, List
Expand Down
3 changes: 3 additions & 0 deletions src/core/autonomy.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# SPDX-FileCopyrightText: 2026 Сацук Артём Венедиктович (Satsuk Artem)
# SPDX-License-Identifier: Apache-2.0

from __future__ import annotations

from typing import Any, Dict, List
Expand Down
3 changes: 3 additions & 0 deletions src/core/autonomy_charter.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# SPDX-FileCopyrightText: 2026 Сацук Артём Венедиктович (Satsuk Artem)
# SPDX-License-Identifier: Apache-2.0

from __future__ import annotations

from typing import Any, Dict, List
Expand Down
3 changes: 3 additions & 0 deletions src/core/bandit.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# SPDX-FileCopyrightText: 2026 Сацук Артём Венедиктович (Satsuk Artem)
# SPDX-License-Identifier: Apache-2.0

from __future__ import annotations
from sif.core.time_utils import utc_now_iso

Expand Down
3 changes: 3 additions & 0 deletions src/core/benchmarks.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# SPDX-FileCopyrightText: 2026 Сацук Артём Венедиктович (Satsuk Artem)
# SPDX-License-Identifier: Apache-2.0

from __future__ import annotations

import time
Expand Down
6 changes: 5 additions & 1 deletion src/core/cache_store.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# SPDX-FileCopyrightText: 2026 Сацук Артём Венедиктович (Satsuk Artem)
# SPDX-License-Identifier: Apache-2.0

from __future__ import annotations

import asyncio
Expand Down Expand Up @@ -241,7 +244,8 @@ async def _close_db(self) -> None:
async def _load_cache_from_db(self) -> Dict[str, Any]:
db = self._require_db()
payload: Dict[str, Any] = {}
async with db.execute("SELECT cache_key, value_json FROM cache_entries") as cursor:
cursor = await db.execute("SELECT cache_key, value_json FROM cache_entries")
async with cursor:
async for row in cursor:
try:
payload[row["cache_key"]] = json.loads(row["value_json"])
Expand Down
3 changes: 3 additions & 0 deletions src/core/candidates.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# SPDX-FileCopyrightText: 2026 Сацук Артём Венедиктович (Satsuk Artem)
# SPDX-License-Identifier: Apache-2.0

from __future__ import annotations

from dataclasses import dataclass, field
Expand Down
3 changes: 3 additions & 0 deletions src/core/code_intelligence.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# SPDX-FileCopyrightText: 2026 Сацук Артём Венедиктович (Satsuk Artem)
# SPDX-License-Identifier: Apache-2.0

from dataclasses import dataclass
import ast
import asyncio
Expand Down
3 changes: 3 additions & 0 deletions src/core/evaluator.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# SPDX-FileCopyrightText: 2026 Сацук Артём Венедиктович (Satsuk Artem)
# SPDX-License-Identifier: Apache-2.0

from __future__ import annotations

import asyncio
Expand Down
3 changes: 3 additions & 0 deletions src/core/events.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# SPDX-FileCopyrightText: 2026 Сацук Артём Венедиктович (Satsuk Artem)
# SPDX-License-Identifier: Apache-2.0

from __future__ import annotations

import asyncio
Expand Down
3 changes: 3 additions & 0 deletions src/core/evolution.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# SPDX-FileCopyrightText: 2026 Сацук Артём Венедиктович (Satsuk Artem)
# SPDX-License-Identifier: Apache-2.0

from dataclasses import dataclass
import json
from pathlib import Path
Expand Down
3 changes: 3 additions & 0 deletions src/core/experiment_manager.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# SPDX-FileCopyrightText: 2026 Сацук Артём Венедиктович (Satsuk Artem)
# SPDX-License-Identifier: Apache-2.0

from __future__ import annotations

import asyncio
Expand Down
3 changes: 3 additions & 0 deletions src/core/impact_ledger.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# SPDX-FileCopyrightText: 2026 Сацук Артём Венедиктович (Satsuk Artem)
# SPDX-License-Identifier: Apache-2.0

from __future__ import annotations

from dataclasses import dataclass
Expand Down
Loading
Loading