letitloop 0.7.0__tar.gz → 0.7.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {letitloop-0.7.0 → letitloop-0.7.2}/CHANGELOG.md +35 -0
- letitloop-0.7.2/PKG-INFO +251 -0
- letitloop-0.7.2/README.md +208 -0
- letitloop-0.7.2/docs/ARCHITECTURE_AND_TRADE_OFFS.md +45 -0
- letitloop-0.7.2/docs/adr/README.md +4 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/letitloop/__init__.py +1 -1
- letitloop-0.7.2/letitloop/adapters/__init__.py +71 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/letitloop/adapters/autogen.py +6 -13
- {letitloop-0.7.0 → letitloop-0.7.2}/letitloop/adapters/crewai.py +6 -8
- {letitloop-0.7.0 → letitloop-0.7.2}/letitloop/adapters/fastapi.py +3 -7
- {letitloop-0.7.0 → letitloop-0.7.2}/letitloop/adapters/langgraph.py +26 -37
- {letitloop-0.7.0 → letitloop-0.7.2}/letitloop/adapters/smolagents.py +17 -11
- {letitloop-0.7.0 → letitloop-0.7.2}/letitloop/conformance/adapters/atomic_wal_adapter.py +1 -1
- {letitloop-0.7.0 → letitloop-0.7.2}/letitloop/conformance/adapters/in_memory_adapter.py +1 -1
- {letitloop-0.7.0 → letitloop-0.7.2}/letitloop/conformance/adapters/snapshot_graph_adapter.py +1 -1
- {letitloop-0.7.0 → letitloop-0.7.2}/letitloop/conformance/harness/runner.py +11 -9
- letitloop-0.7.2/letitloop.egg-info/PKG-INFO +251 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/letitloop.egg-info/SOURCES.txt +6 -31
- {letitloop-0.7.0 → letitloop-0.7.2}/letitloop.egg-info/requires.txt +4 -0
- letitloop-0.7.2/letitloop.egg-info/top_level.txt +2 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/orchestrator/__init__.py +13 -1
- {letitloop-0.7.0 → letitloop-0.7.2}/orchestrator/cli.py +16 -18
- letitloop-0.7.2/orchestrator/codecs.py +210 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/orchestrator/decorators.py +157 -79
- {letitloop-0.7.0 → letitloop-0.7.2}/orchestrator/lock.py +52 -22
- {letitloop-0.7.0 → letitloop-0.7.2}/orchestrator/state.py +80 -12
- {letitloop-0.7.0 → letitloop-0.7.2}/orchestrator/supervisor/liveness.py +37 -11
- {letitloop-0.7.0 → letitloop-0.7.2}/pyproject.toml +6 -2
- {letitloop-0.7.0 → letitloop-0.7.2}/tests/adapters/test_adapters_init.py +14 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/tests/adapters/test_langgraph.py +8 -2
- {letitloop-0.7.0 → letitloop-0.7.2}/tests/adapters/test_smolagents.py +21 -0
- letitloop-0.7.2/tests/test_atomic_marker_concurrency.py +142 -0
- letitloop-0.7.2/tests/test_codecs.py +234 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/tests/test_durable_async.py +25 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/tests/test_durable_decorator.py +82 -0
- letitloop-0.7.2/tests/test_interactive_demo.py +146 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/tests/test_lock.py +46 -0
- letitloop-0.7.2/tests/test_playwright_scraper_cookbook.py +138 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/tests/test_state.py +78 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/tests/test_supervise.py +51 -0
- letitloop-0.7.0/.github/workflows/all-contributors.yml +0 -23
- letitloop-0.7.0/.github/workflows/issue-claim.yml +0 -123
- letitloop-0.7.0/.github/workflows/stale.yml +0 -29
- letitloop-0.7.0/PKG-INFO +0 -306
- letitloop-0.7.0/README.md +0 -266
- letitloop-0.7.0/conformance/adapters/atomic_wal_adapter.py +0 -101
- letitloop-0.7.0/conformance/adapters/autogen_adapter.py +0 -32
- letitloop-0.7.0/conformance/adapters/base.py +0 -22
- letitloop-0.7.0/conformance/adapters/crewai_adapter.py +0 -31
- letitloop-0.7.0/conformance/adapters/in_memory_adapter.py +0 -82
- letitloop-0.7.0/conformance/adapters/langgraph_adapter.py +0 -43
- letitloop-0.7.0/conformance/adapters/letitloop_adapter.py +0 -9
- letitloop-0.7.0/conformance/adapters/raw_python_adapter.py +0 -30
- letitloop-0.7.0/conformance/adapters/snapshot_graph_adapter.py +0 -98
- letitloop-0.7.0/conformance/adapters/unmanaged_script_adapter.py +0 -80
- letitloop-0.7.0/conformance/harness/injector.py +0 -90
- letitloop-0.7.0/conformance/harness/runner.py +0 -286
- letitloop-0.7.0/conformance/harness/schema.py +0 -31
- letitloop-0.7.0/conformance/harness/synthetic_engine.py +0 -88
- letitloop-0.7.0/docs/MCP_GUIDE.md +0 -179
- letitloop-0.7.0/docs/MCP_SETUP.md +0 -78
- letitloop-0.7.0/docs/SKILL_GUIDE.md +0 -81
- letitloop-0.7.0/docs/V033_SCORECARD.md +0 -184
- letitloop-0.7.0/docs/adr/0002-deterministic-verifiers.md +0 -41
- letitloop-0.7.0/docs/adr/0003-headless-cli-adapters.md +0 -45
- letitloop-0.7.0/docs/adr/0004-format-aware-acceptance-checks.md +0 -27
- letitloop-0.7.0/docs/adr/README.md +0 -21
- letitloop-0.7.0/docs/auto_healing.md +0 -92
- letitloop-0.7.0/letitloop/adapters/__init__.py +0 -50
- letitloop-0.7.0/letitloop/conformance/__init__.py +0 -1
- letitloop-0.7.0/letitloop/conformance/harness/__init__.py +0 -5
- letitloop-0.7.0/letitloop/conformance/scenarios/__init__.py +0 -40
- letitloop-0.7.0/letitloop/mcp/__init__.py +0 -33
- letitloop-0.7.0/letitloop/mcp/__main__.py +0 -6
- letitloop-0.7.0/letitloop-action/scripts/verify_ast.py +0 -140
- letitloop-0.7.0/letitloop.egg-info/PKG-INFO +0 -306
- letitloop-0.7.0/letitloop.egg-info/top_level.txt +0 -4
- {letitloop-0.7.0 → letitloop-0.7.2}/.github/ISSUE_TEMPLATE/bug_report.yml +0 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/.github/ISSUE_TEMPLATE/config.yml +0 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/.github/ISSUE_TEMPLATE/feature_request.yml +0 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/.github/dependabot.yml +0 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/.github/release-drafter.config.yml +0 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/.github/release-drafter.yml +0 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/.github/workflows/ci.yml +0 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/.github/workflows/codeql.yml +0 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/.github/workflows/dependency-review.yml +0 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/.github/workflows/pages.yml +0 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/.github/workflows/pr-health-guard.yml +0 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/.github/workflows/release-drafter.yml +0 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/.github/workflows/release-pypi.yml +0 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/.github/workflows/scorecard.yml +0 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/LICENSE +0 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/MANIFEST.in +0 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/docs/adapters.md +0 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/docs/adr/0001-write-ahead-logging.md +0 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/docs/adr/template.md +0 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/docs/state_machine.md +0 -0
- {letitloop-0.7.0 → letitloop-0.7.2/letitloop}/conformance/__init__.py +0 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/letitloop/conformance/adapters/__init__.py +0 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/letitloop/conformance/adapters/_durable_mixin.py +0 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/letitloop/conformance/adapters/autogen_adapter.py +0 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/letitloop/conformance/adapters/base.py +0 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/letitloop/conformance/adapters/crewai_adapter.py +0 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/letitloop/conformance/adapters/json_checkpoint_adapter.py +0 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/letitloop/conformance/adapters/langgraph_adapter.py +0 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/letitloop/conformance/adapters/letitloop_adapter.py +0 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/letitloop/conformance/adapters/llamaindex_adapter.py +0 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/letitloop/conformance/adapters/raw_python_adapter.py +0 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/letitloop/conformance/adapters/sqlite_wal_adapter.py +0 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/letitloop/conformance/adapters/swarm_adapter.py +0 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/letitloop/conformance/adapters/unmanaged_script_adapter.py +0 -0
- {letitloop-0.7.0 → letitloop-0.7.2/letitloop}/conformance/harness/__init__.py +0 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/letitloop/conformance/harness/injector.py +0 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/letitloop/conformance/harness/schema.py +0 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/letitloop/conformance/harness/synthetic_engine.py +0 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/letitloop/conformance/reporter.py +0 -0
- {letitloop-0.7.0 → letitloop-0.7.2/letitloop}/conformance/scenarios/__init__.py +0 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/letitloop.egg-info/dependency_links.txt +0 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/letitloop.egg-info/entry_points.txt +0 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/orchestrator/exceptions.py +0 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/orchestrator/process_guard.py +0 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/orchestrator/supervisor/__init__.py +0 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/orchestrator/token_gate.py +0 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/pytest.ini +0 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/requirements-ci.txt +0 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/setup.cfg +0 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/tests/__init__.py +0 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/tests/adapters/__init__.py +0 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/tests/adapters/test_autogen.py +0 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/tests/adapters/test_crewai.py +0 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/tests/adapters/test_fastapi.py +0 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/tests/test_browser_use_cookbook.py +0 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/tests/test_cli_watch.py +0 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/tests/test_conformance_benchmark.py +0 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/tests/test_cookbooks.py +0 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/tests/test_fuzz_wal_corruptions.py +0 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/tests/test_process_guard.py +0 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/tests/test_step_failclosed.py +0 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/tests/test_token_gate.py +0 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/tests/test_wal_corruption_recovery.py +0 -0
- {letitloop-0.7.0 → letitloop-0.7.2}/tests/test_wal_v2_checksums.py +0 -0
|
@@ -3,6 +3,41 @@
|
|
|
3
3
|
All notable changes to this project are documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
5
5
|
|
|
6
|
+
## [0.7.2] - 2026-11-23
|
|
7
|
+
|
|
8
|
+
### 🔒 Kernel Correctness Fixes, Async Parallelism & Protocol Hardening
|
|
9
|
+
- **True `asyncio.gather()` Concurrency (`orchestrator/decorators.py`)**: Scoped `DurableAsyncContext._lock` strictly to WAL commit and cache mutation rather than holding the lock across `await async_fn(...)`, allowing parallel `async_step()` calls in `asyncio.gather()` to execute concurrently.
|
|
10
|
+
- **WAL Key Deletion Replay Fix (`orchestrator/state.py`)**: Fixed `_apply_event` sentinel comparison (`v == _DELETE_SENTINEL` instead of object identity `is`), preventing deleted state keys from resurrecting after JSON deserialization on WAL replay.
|
|
11
|
+
- **$O(1)$ In-Memory Delta Rollback (`orchestrator/state.py`)**: Eliminated per-step `copy.deepcopy(self.data)` and `copy.deepcopy(self.events)` on `DATA_PATCH` events, preserving $O(1)$ per-step memory and CPU overhead for multi-hundred-step pipelines.
|
|
12
|
+
- **Nested `@durable` Context Preservation (`orchestrator/decorators.py`)**: Restores prior active thread-local context on exit instead of unconditionally resetting to `None`.
|
|
13
|
+
- **Live Process Lock Preservation (`orchestrator/lock.py`)**: Prevents `_lock_is_stale` and `FileLock._lock_file_is_stale` from stealing locks held by a demonstrably live local process with a matching OS process start token after 300 seconds.
|
|
14
|
+
- **Orphaned `.pending.<pid>` Reclamation & NTFS Retry (`orchestrator/decorators.py`)**: `atomic_marker` now sweeps orphaned `.pending.<dead_pid>` files left by `SIGKILL` crashes and applies a 6-attempt exponential backoff around `os.replace` on Windows NTFS.
|
|
15
|
+
- **Recursive Custom Codec Hydration (`orchestrator/codecs.py`)**: Custom codecs registered via `register_codec()` now recursively encode and hydrate nested built-in types (`datetime`, `uuid.UUID`, `pathlib.Path`, `tuple`) with full cycle detection.
|
|
16
|
+
- **Adapter Hardening & Lazy Spec Detection (`letitloop/adapters/*`)**:
|
|
17
|
+
- Replaced eager package imports in `get_available_adapters()` with `importlib.util.find_spec()`, reducing availability detection overhead from ~40s to <1ms.
|
|
18
|
+
- Updated `LetItLoopCheckpointSaver` (`langgraph.py`) to use `DurableCodecRegistry` instead of `pickle`, yield an async iterator from `alist()`, support `task_path` in `put_writes()`/`aput_writes()`, and preserve `parent_checkpoint_id=None` on root checkpoints.
|
|
19
|
+
- Updated `SmolagentsWALCallback.wrap_agent()` (`smolagents.py`) to register with `smolagents 1.26+` `CallbackRegistry` objects without overwriting them with a raw list.
|
|
20
|
+
- Added `LILWAL02` CRC32 frame verification to `lil inspect` (`orchestrator/cli.py`).
|
|
21
|
+
- **Bounded SHA-256 Markers (`SEC-PROTO-01` & `SEC-PROTO-02`)**: Replaced regex identifier sanitization with canonical SHA-256 digest filenames (`m-{sha256[:32]}`). Eliminates identifier collisions (`stripe/charge` vs `stripe_charge`), path traversal attempts (`../../`), and Windows NTFS `MAX_PATH` (>260 char) crashes.
|
|
22
|
+
- **Strict Directory Jailing**: Legacy marker compatibility lookups now strictly verify containment within `markers_dir` via `os.path.commonpath`, preventing path hijacking.
|
|
23
|
+
- **Split-Brain Elimination in `FileLock.release()` (`SEC-PROTO-03`)**: Added CAS-style lock ownership token (`process_start_token` + PID) verification before unlinking lock files. Prevents stolen or replaced locks from being blindly deleted by slow contender processes.
|
|
24
|
+
- **Codec Recursion & Cycle Protection**: Added in-flight visited object cycle detection and maximum recursion depth (256) guards to `DurableCodecRegistry.encode()`, failing closed with `DurableCodecError` instead of leaking raw unhandled `RecursionError`.
|
|
25
|
+
- **Safe Hydration Exception Handling**: Wrapped tagged payload hydration in `DurableCodecRegistry.decode()` to catch malformed payload data (invalid tuple iterables, malformed datetime/uuid strings) and fail closed with `DurableCodecError`.
|
|
26
|
+
- **Timestamp Sanity & Replay Preservation**: Added ISO-8601 parsing validation and clock-drift bounds on live appends, while maintaining clean backward compatibility for offline replay of historical WAL files.
|
|
27
|
+
- **Durability Contract Boundary Transparency**: Formally clarified in documentation that `atomic_marker` guarantees serialized execution and durable local completion records; recommended upstream `Idempotency-Key` headers for remote non-idempotent HTTP API side-effects.
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## [0.7.1] - 2026-10-12
|
|
32
|
+
|
|
33
|
+
### 🛡️ Concurrency Mutex, O(N) WAL Compaction & Type Preservation
|
|
34
|
+
- **2-Tier `atomic_marker` Mutex**: Upgraded atomic step markers with process-local `threading.Lock` and cross-process `FileLock` mutual exclusion, moving `.committed` checks inside the acquired lock and publishing markers via atomic tempfile `os.replace` (`os.fsync` + atomic rename) to eliminate multi-process and multi-thread race conditions.
|
|
35
|
+
- **Elimination of $O(N^2)$ Write Amplification**: Replaced full-dictionary serialization in `step()` and `async_step()` with discrete subkey delta patching under `step_outputs`. Compresses WAL size by 168x (from 83.2 MB down to 378 KB for 1,000 steps) and accelerates replay recovery by 17.6x (down to 72.39 $\mu$s/step).
|
|
36
|
+
- **Safe Type Preservation (`DurableCodecRegistry`)**: Introduced safe, extensible codec registry for standard Python objects (`datetime`, `uuid.UUID`, `pathlib.Path`, `tuple`, dataclasses, and Pydantic models). Enforces zero dynamic import execution and fails closed with `DurableSerializationError` on unhandled types.
|
|
37
|
+
- **Conformance Transparency (DCP-2.0)**: Added explicit `adapter_kind` (`native_kernel` vs `simulated_archetype`) and `framework_executed` flags to DCP-2.0 conformance receipts to distinguish native micro-kernel executions from simulated baseline archetypes.
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
6
41
|
## [0.7.0] - 2026-10-07
|
|
7
42
|
|
|
8
43
|
### ⚡ The SQLite of Durable Execution (Micro-Kernel Architecture)
|
letitloop-0.7.2/PKG-INFO
ADDED
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: letitloop
|
|
3
|
+
Version: 0.7.2
|
|
4
|
+
Summary: The SQLite of Durable Execution — Zero-daemon in-process durability and process supervisor for Python functions & AI agents.
|
|
5
|
+
Author-email: sdageltc <sdageltc@users.noreply.github.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://sdageltc.github.io/letitloop/
|
|
8
|
+
Project-URL: Documentation, https://github.com/sdageltc/letitloop#readme
|
|
9
|
+
Project-URL: Repository, https://github.com/sdageltc/letitloop
|
|
10
|
+
Project-URL: Bug Tracker, https://github.com/sdageltc/letitloop/issues
|
|
11
|
+
Project-URL: Discussions, https://github.com/sdageltc/letitloop/discussions
|
|
12
|
+
Keywords: durable-execution,wal,crash-resilience,agentic-ai,supervisor,langgraph,browser-use,pydantic-ai,dspy,zero-daemon
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Intended Audience :: Science/Research
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Operating System :: OS Independent
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
22
|
+
Classifier: Topic :: Software Development :: Testing
|
|
23
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
24
|
+
Requires-Python: >=3.11
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
License-File: LICENSE
|
|
27
|
+
Requires-Dist: psutil>=5.9.0
|
|
28
|
+
Provides-Extra: adapters
|
|
29
|
+
Requires-Dist: fastapi>=0.100.0; extra == "adapters"
|
|
30
|
+
Requires-Dist: langgraph<2,>=1.2; extra == "adapters"
|
|
31
|
+
Provides-Extra: financial-agent
|
|
32
|
+
Requires-Dist: langgraph<2,>=1.2; extra == "financial-agent"
|
|
33
|
+
Requires-Dist: yfinance>=0.2.40; extra == "financial-agent"
|
|
34
|
+
Provides-Extra: dev
|
|
35
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
36
|
+
Requires-Dist: pytest-cov>=4.0; extra == "dev"
|
|
37
|
+
Requires-Dist: pytest-asyncio>=0.21; extra == "dev"
|
|
38
|
+
Requires-Dist: pytest-xdist>=3.0; extra == "dev"
|
|
39
|
+
Requires-Dist: hypothesis>=6.100.0; extra == "dev"
|
|
40
|
+
Requires-Dist: langgraph<2,>=1.2; extra == "dev"
|
|
41
|
+
Requires-Dist: ruff>=0.1.0; extra == "dev"
|
|
42
|
+
Dynamic: license-file
|
|
43
|
+
|
|
44
|
+
<p align="center">
|
|
45
|
+
<img src="assets/logo.png" alt="let it loop (LIL)" width="320" style="border-radius: 20px;">
|
|
46
|
+
</p>
|
|
47
|
+
|
|
48
|
+
<div align="center">
|
|
49
|
+
|
|
50
|
+
# let it loop (LIL)
|
|
51
|
+
|
|
52
|
+
**Single-Process Local Write-Ahead Log (`LILWAL02`) & Process Supervisor for Python Scripts (`v0.7.2`)**
|
|
53
|
+
|
|
54
|
+
[](https://sdageltc.github.io/letitloop/)
|
|
55
|
+
[](https://pypi.org/project/letitloop/)
|
|
56
|
+
[](https://github.com/sdageltc/letitloop/actions/workflows/ci.yml)
|
|
57
|
+
[](https://github.com/sdageltc/letitloop-action)
|
|
58
|
+
[](https://sdageltc.github.io/agent-durability-bench/)
|
|
59
|
+
[](https://www.python.org/downloads/)
|
|
60
|
+
[](https://opensource.org/licenses/MIT)
|
|
61
|
+
|
|
62
|
+
**[Official Website](https://sdageltc.github.io/letitloop/)** • **[Architecture & Trade-Offs](docs/ARCHITECTURE_AND_TRADE_OFFS.md)** • **[DCP-2.0 Simulation Harness](https://sdageltc.github.io/agent-durability-bench/)** • **[PyPI Package](https://pypi.org/project/letitloop/)**
|
|
63
|
+
|
|
64
|
+
</div>
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
> **Status & Scope**: `letitloop` is a single-maintainer, single-writer local filesystem Write-Ahead Log (`LILWAL02`) and process supervisor (`lil watch` / `@supervise`) for Python functions, scrapers, and batch scripts. It requires only `psutil>=5.9.0` and stores state in human-readable, CRC32-framed JSONL files.
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
<p align="center">
|
|
73
|
+
<img src="docs/assets/crash_recovery_demo.gif" alt="LetItLoop Process Crash & WAL Recovery Demo" width="100%">
|
|
74
|
+
</p>
|
|
75
|
+
|
|
76
|
+
## ⚡ Quickstart
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
from letitloop import atomic_marker, durable, step
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
@durable(goal_id="customer_sync", wal_dir=".durable_wal")
|
|
83
|
+
def sync_workflow():
|
|
84
|
+
# If this process crashes or receives SIGKILL midway,
|
|
85
|
+
# completed steps are skipped from the local WAL on restart.
|
|
86
|
+
user = step("fetch_user", fetch_crm_record, user_id=123)
|
|
87
|
+
summary = step("summarize", call_llm_model, user)
|
|
88
|
+
|
|
89
|
+
# Guard local side effects with a 2-phase file marker
|
|
90
|
+
with atomic_marker("slack_notification") as should_execute:
|
|
91
|
+
if should_execute:
|
|
92
|
+
step("notify", send_slack, summary)
|
|
93
|
+
|
|
94
|
+
return summary
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
if __name__ == "__main__":
|
|
98
|
+
sync_workflow()
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
pip install letitloop
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
For asynchronous pipelines, use `@durable_async` and `await async_step(...)` with `ContextVar` isolation across `asyncio.gather()`.
|
|
106
|
+
|
|
107
|
+
### Interactive Crash-Recovery Visualizer
|
|
108
|
+
|
|
109
|
+
Run the local Streamlit visualizer (uses deterministic local steps, zero external API calls):
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
python -m pip install -e .
|
|
113
|
+
python -m pip install -r examples/interactive_demo/requirements.txt
|
|
114
|
+
streamlit run examples/interactive_demo/app.py
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## 🧭 When to Use LetItLoop (and When Not To)
|
|
120
|
+
|
|
121
|
+
| Workload / Requirement | Recommended Tool | Why |
|
|
122
|
+
|---|---|---|
|
|
123
|
+
| **Single-writer local Python script, scraper, or CLI job** | **LetItLoop (`@durable` + `lil watch`)** | Zero external daemon, human-readable JSONL WAL (`LILWAL02`) with CRC32 + SHA-256 hash chain, and built-in subprocess crash supervision (`lil watch`). |
|
|
124
|
+
| **SQLite / PostgreSQL transactional workflows with durable `sleep` & queues** | **[DBOS (`dbos`)](https://github.com/dbos-inc/dbos-transact-py)** | Runs in-process on SQLite by default with a production PostgreSQL upgrade path and official PydanticAI / OpenAI Agents SDK integrations. |
|
|
125
|
+
| **LangGraph graph or `@entrypoint` / `@task` pipelines** | **[LangGraph `SqliteSaver`](https://pypi.org/project/langgraph-checkpoint-sqlite/)** | Native checkpointer maintained by the LangGraph core team. |
|
|
126
|
+
| **Data engineering DAGs & scheduled flows** | **[Prefect](https://github.com/PrefectHQ/prefect)** | Mature Python `@flow` / `@task` engine with ephemeral local SQLite mode and observability UI. |
|
|
127
|
+
| **Multi-node distributed microservices & multi-day timers** | **[Temporal](https://github.com/temporalio/sdk-python)** or **[Restate](https://github.com/restatedev/sdk-python)** | Dedicated workflow server clusters with distributed event histories and multi-language workers. |
|
|
128
|
+
|
|
129
|
+
See [docs/ARCHITECTURE_AND_TRADE_OFFS.md](docs/ARCHITECTURE_AND_TRADE_OFFS.md) for a detailed architectural analysis and contract boundaries.
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## 🔄 Process Liveness: Auto-Supervision & CLI Watcher
|
|
134
|
+
|
|
135
|
+
LetItLoop pairs **State Durability** (saving step outputs to disk) with **Process Liveness** (restarting a script after `SIGKILL 137` or an unhandled crash):
|
|
136
|
+
|
|
137
|
+
### 1. Terminal Watcher (`lil watch`)
|
|
138
|
+
Supervise any Python script with sliding-window rapid-failure circuit breaking and clean signal forwarding:
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
lil watch agent_pipeline.py --max-restarts 10 --backoff 1.0
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### 2. Entrypoint Decorator (`@supervise`)
|
|
145
|
+
```python
|
|
146
|
+
from letitloop import durable, step, supervise
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
@supervise(max_restarts=5, backoff=1.0)
|
|
150
|
+
@durable(goal_id="equity_analyst", wal_dir=".equity_wal")
|
|
151
|
+
def run_pipeline():
|
|
152
|
+
user = step("fetch_data", fetch_financials)
|
|
153
|
+
report = step("generate_report", analyze, user)
|
|
154
|
+
return report
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
if __name__ == "__main__":
|
|
158
|
+
run_pipeline()
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
## 💎 Core Design Guarantees & Contract Boundaries
|
|
164
|
+
|
|
165
|
+
1. **CRC32-Framed Append-Only WAL (`LILWAL02`)**:
|
|
166
|
+
Each step delta is framed as `\nLILWAL02:<byte_len_hex>:<crc32_hex>:<canonical_json>\n` and linked via a sequential SHA-256 hash chain (`prev_hash` -> `event_hash`). Torn tail writes from mid-append power loss or `SIGKILL` are truncated back to the last valid frame on replay, while mid-file corruption fails closed with `StateError`.
|
|
167
|
+
2. **$O(1)$ Delta Patching & Atomic Snapshots**:
|
|
168
|
+
Step outputs append discrete delta patches under `step_outputs` and write periodic atomic snapshots (`state.json` via tempfile + `os.fsync` + 6-attempt Windows NTFS `os.replace` retry + POSIX directory fsync).
|
|
169
|
+
3. **2-Tier Mutex (`atomic_marker`)**:
|
|
170
|
+
Combines a process-local `threading.Lock` and a cross-process `FileLock` (with PID start-time token verification to prevent PID-reuse lock false positives) and sweeps orphaned `.pending.<dead_pid>` markers on recovery.
|
|
171
|
+
> **External API Boundary**: No local filesystem marker can prevent duplicate execution if `SIGKILL` strikes after an HTTP request leaves the host NIC but before the response is committed to disk. For non-idempotent remote APIs (e.g. Stripe charges), pass an upstream `Idempotency-Key` header derived from `f"{goal_id}:{marker_id}"`.
|
|
172
|
+
4. **Allowlist-Only Type Hydration (`DurableCodecRegistry`)**:
|
|
173
|
+
Preserves `datetime`, `uuid.UUID`, `pathlib.Path`, `tuple`, and custom types registered via `register_codec()` across initial execution and WAL replay without using `pickle` or dynamic code imports.
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
## 🍳 Runnable Examples & Cookbooks
|
|
178
|
+
|
|
179
|
+
Self-contained examples in [`examples/`](examples/):
|
|
180
|
+
|
|
181
|
+
| Target | Example / Cookbook | Description |
|
|
182
|
+
|---|---|---|
|
|
183
|
+
| **Playwright** | [`examples/cookbooks/playwright_scraper.py`](examples/cookbooks/playwright_scraper.py) | Multi-page scraper with `@durable_async` checkpointing that skips already-scraped pages on resume |
|
|
184
|
+
| **Streamlit UI** | [`examples/interactive_demo/app.py`](examples/interactive_demo/README.md) | Local crash injection and WAL replay visualizer |
|
|
185
|
+
| **Browser-Use** | [`examples/cookbooks/browser_use_durable.py`](examples/cookbooks/browser_use_durable.py) | Release digest workflow with step-level crash recovery |
|
|
186
|
+
| **LangGraph** | [`examples/cookbooks/langgraph_financial_analyst.py`](examples/cookbooks/langgraph_financial_analyst.py) | 4-step financial analyst pipeline with offline and live DeepSeek modes |
|
|
187
|
+
| **DSPy** | [`examples/cookbooks/dspy_durable_optimize.py`](examples/cookbooks/dspy_durable_optimize.py) | Prompt optimizer pipeline with step-level checkpointing |
|
|
188
|
+
| **Pydantic AI** | [`examples/cookbooks/pydantic_ai_durable.py`](examples/cookbooks/pydantic_ai_durable.py) | Type-safe agent workflow wrapped with LetItLoop step persistence |
|
|
189
|
+
| **FastAPI** | [`examples/fastapi_durable_background.py`](examples/fastapi_durable_background.py) | Single-worker durable background task queue backed by local WAL |
|
|
190
|
+
| **CrewAI / LlamaIndex** | [`examples/crewai_durable_tools.py`](examples/crewai_durable_tools.py) • [`examples/llamaindex_durable_workflow.py`](examples/llamaindex_durable_workflow.py) | Tool-call and step wrapper examples |
|
|
191
|
+
|
|
192
|
+
Run the financial analyst cookbook offline without API keys:
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
python -m pip install -e ".[financial-agent]"
|
|
196
|
+
python examples/cookbooks/langgraph_financial_analyst.py --ticker AAPL --offline
|
|
197
|
+
python examples/cookbooks/langgraph_financial_analyst.py --ticker AAPL --offline --demo
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
---
|
|
201
|
+
|
|
202
|
+
## 🛡️ GitHub Action CI Gate (`letitloop-action@v2`)
|
|
203
|
+
|
|
204
|
+
Verify `LILWAL02` frame checksums and Python AST syntax in GitHub Actions:
|
|
205
|
+
|
|
206
|
+
```yaml
|
|
207
|
+
name: Verify WAL & Python AST
|
|
208
|
+
on: [pull_request]
|
|
209
|
+
|
|
210
|
+
jobs:
|
|
211
|
+
verify:
|
|
212
|
+
runs-on: ubuntu-latest
|
|
213
|
+
steps:
|
|
214
|
+
- uses: actions/checkout@v4
|
|
215
|
+
- uses: sdageltc/letitloop-action@v2
|
|
216
|
+
with:
|
|
217
|
+
token: ${{ secrets.GITHUB_TOKEN }}
|
|
218
|
+
mode: 'gate'
|
|
219
|
+
wal-dir: '.bench_wal'
|
|
220
|
+
workspace: '.'
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
---
|
|
224
|
+
|
|
225
|
+
## 📜 Architecture Documentation
|
|
226
|
+
|
|
227
|
+
- [**Architecture & Trade-Offs**](docs/ARCHITECTURE_AND_TRADE_OFFS.md): Single-writer design contract, failure modes, and comparison with DBOS, LangGraph, and Temporal.
|
|
228
|
+
- [**ADR-0001**](docs/adr/0001-write-ahead-logging.md): Write-Ahead Logging (`LILWAL02`) & Torn-Tail Recovery.
|
|
229
|
+
- [**State Machine Specification**](docs/state_machine.md): Event-sourced state transitions and replay rules.
|
|
230
|
+
- [**Adapter Reference**](docs/adapters.md): Optional adapter shims under `letitloop.adapters`.
|
|
231
|
+
|
|
232
|
+
---
|
|
233
|
+
|
|
234
|
+
## 👥 Contributors
|
|
235
|
+
|
|
236
|
+
<table>
|
|
237
|
+
<tbody>
|
|
238
|
+
<tr>
|
|
239
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/sdageltc"><img src="https://avatars.githubusercontent.com/u/268154463?v=4" width="100px;" alt="sdageltc"/><br /><sub><b>sdageltc</b></sub></a></td>
|
|
240
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/h4syy"><img src="https://avatars.githubusercontent.com/u/59239840?v=4" width="100px;" alt="Yash Paudel"/><br /><sub><b>Yash Paudel</b></sub></a></td>
|
|
241
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/wangshen-tech"><img src="https://avatars.githubusercontent.com/u/190895315?v=4" width="100px;" alt="wangshen-tech"/><br /><sub><b>wangshen-tech</b></sub></a></td>
|
|
242
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/MagMueller"><img src="https://github.com/MagMueller.png" width="100px;" alt="MagMueller"/><br /><sub><b>MagMueller</b></sub></a></td>
|
|
243
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/darkseidpaul"><img src="https://github.com/darkseidpaul.png" width="100px;" alt="darkseidpaul"/><br /><sub><b>darkseidpaul</b></sub></a></td>
|
|
244
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/Aaqibhafeezkhan"><img src="https://github.com/Aaqibhafeezkhan.png" width="100px;" alt="Aaqibhafeezkhan"/><br /><sub><b>Aaqibhafeezkhan</b></sub></a></td>
|
|
245
|
+
</tr>
|
|
246
|
+
</tbody>
|
|
247
|
+
</table>
|
|
248
|
+
|
|
249
|
+
## License
|
|
250
|
+
|
|
251
|
+
Distributed under the MIT License. Copyright (c) 2026 sdageltc. See [LICENSE](LICENSE) for details.
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="assets/logo.png" alt="let it loop (LIL)" width="320" style="border-radius: 20px;">
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<div align="center">
|
|
6
|
+
|
|
7
|
+
# let it loop (LIL)
|
|
8
|
+
|
|
9
|
+
**Single-Process Local Write-Ahead Log (`LILWAL02`) & Process Supervisor for Python Scripts (`v0.7.2`)**
|
|
10
|
+
|
|
11
|
+
[](https://sdageltc.github.io/letitloop/)
|
|
12
|
+
[](https://pypi.org/project/letitloop/)
|
|
13
|
+
[](https://github.com/sdageltc/letitloop/actions/workflows/ci.yml)
|
|
14
|
+
[](https://github.com/sdageltc/letitloop-action)
|
|
15
|
+
[](https://sdageltc.github.io/agent-durability-bench/)
|
|
16
|
+
[](https://www.python.org/downloads/)
|
|
17
|
+
[](https://opensource.org/licenses/MIT)
|
|
18
|
+
|
|
19
|
+
**[Official Website](https://sdageltc.github.io/letitloop/)** • **[Architecture & Trade-Offs](docs/ARCHITECTURE_AND_TRADE_OFFS.md)** • **[DCP-2.0 Simulation Harness](https://sdageltc.github.io/agent-durability-bench/)** • **[PyPI Package](https://pypi.org/project/letitloop/)**
|
|
20
|
+
|
|
21
|
+
</div>
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
> **Status & Scope**: `letitloop` is a single-maintainer, single-writer local filesystem Write-Ahead Log (`LILWAL02`) and process supervisor (`lil watch` / `@supervise`) for Python functions, scrapers, and batch scripts. It requires only `psutil>=5.9.0` and stores state in human-readable, CRC32-framed JSONL files.
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
<p align="center">
|
|
30
|
+
<img src="docs/assets/crash_recovery_demo.gif" alt="LetItLoop Process Crash & WAL Recovery Demo" width="100%">
|
|
31
|
+
</p>
|
|
32
|
+
|
|
33
|
+
## ⚡ Quickstart
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
from letitloop import atomic_marker, durable, step
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
@durable(goal_id="customer_sync", wal_dir=".durable_wal")
|
|
40
|
+
def sync_workflow():
|
|
41
|
+
# If this process crashes or receives SIGKILL midway,
|
|
42
|
+
# completed steps are skipped from the local WAL on restart.
|
|
43
|
+
user = step("fetch_user", fetch_crm_record, user_id=123)
|
|
44
|
+
summary = step("summarize", call_llm_model, user)
|
|
45
|
+
|
|
46
|
+
# Guard local side effects with a 2-phase file marker
|
|
47
|
+
with atomic_marker("slack_notification") as should_execute:
|
|
48
|
+
if should_execute:
|
|
49
|
+
step("notify", send_slack, summary)
|
|
50
|
+
|
|
51
|
+
return summary
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
if __name__ == "__main__":
|
|
55
|
+
sync_workflow()
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
pip install letitloop
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
For asynchronous pipelines, use `@durable_async` and `await async_step(...)` with `ContextVar` isolation across `asyncio.gather()`.
|
|
63
|
+
|
|
64
|
+
### Interactive Crash-Recovery Visualizer
|
|
65
|
+
|
|
66
|
+
Run the local Streamlit visualizer (uses deterministic local steps, zero external API calls):
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
python -m pip install -e .
|
|
70
|
+
python -m pip install -r examples/interactive_demo/requirements.txt
|
|
71
|
+
streamlit run examples/interactive_demo/app.py
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## 🧭 When to Use LetItLoop (and When Not To)
|
|
77
|
+
|
|
78
|
+
| Workload / Requirement | Recommended Tool | Why |
|
|
79
|
+
|---|---|---|
|
|
80
|
+
| **Single-writer local Python script, scraper, or CLI job** | **LetItLoop (`@durable` + `lil watch`)** | Zero external daemon, human-readable JSONL WAL (`LILWAL02`) with CRC32 + SHA-256 hash chain, and built-in subprocess crash supervision (`lil watch`). |
|
|
81
|
+
| **SQLite / PostgreSQL transactional workflows with durable `sleep` & queues** | **[DBOS (`dbos`)](https://github.com/dbos-inc/dbos-transact-py)** | Runs in-process on SQLite by default with a production PostgreSQL upgrade path and official PydanticAI / OpenAI Agents SDK integrations. |
|
|
82
|
+
| **LangGraph graph or `@entrypoint` / `@task` pipelines** | **[LangGraph `SqliteSaver`](https://pypi.org/project/langgraph-checkpoint-sqlite/)** | Native checkpointer maintained by the LangGraph core team. |
|
|
83
|
+
| **Data engineering DAGs & scheduled flows** | **[Prefect](https://github.com/PrefectHQ/prefect)** | Mature Python `@flow` / `@task` engine with ephemeral local SQLite mode and observability UI. |
|
|
84
|
+
| **Multi-node distributed microservices & multi-day timers** | **[Temporal](https://github.com/temporalio/sdk-python)** or **[Restate](https://github.com/restatedev/sdk-python)** | Dedicated workflow server clusters with distributed event histories and multi-language workers. |
|
|
85
|
+
|
|
86
|
+
See [docs/ARCHITECTURE_AND_TRADE_OFFS.md](docs/ARCHITECTURE_AND_TRADE_OFFS.md) for a detailed architectural analysis and contract boundaries.
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## 🔄 Process Liveness: Auto-Supervision & CLI Watcher
|
|
91
|
+
|
|
92
|
+
LetItLoop pairs **State Durability** (saving step outputs to disk) with **Process Liveness** (restarting a script after `SIGKILL 137` or an unhandled crash):
|
|
93
|
+
|
|
94
|
+
### 1. Terminal Watcher (`lil watch`)
|
|
95
|
+
Supervise any Python script with sliding-window rapid-failure circuit breaking and clean signal forwarding:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
lil watch agent_pipeline.py --max-restarts 10 --backoff 1.0
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### 2. Entrypoint Decorator (`@supervise`)
|
|
102
|
+
```python
|
|
103
|
+
from letitloop import durable, step, supervise
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
@supervise(max_restarts=5, backoff=1.0)
|
|
107
|
+
@durable(goal_id="equity_analyst", wal_dir=".equity_wal")
|
|
108
|
+
def run_pipeline():
|
|
109
|
+
user = step("fetch_data", fetch_financials)
|
|
110
|
+
report = step("generate_report", analyze, user)
|
|
111
|
+
return report
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
if __name__ == "__main__":
|
|
115
|
+
run_pipeline()
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## 💎 Core Design Guarantees & Contract Boundaries
|
|
121
|
+
|
|
122
|
+
1. **CRC32-Framed Append-Only WAL (`LILWAL02`)**:
|
|
123
|
+
Each step delta is framed as `\nLILWAL02:<byte_len_hex>:<crc32_hex>:<canonical_json>\n` and linked via a sequential SHA-256 hash chain (`prev_hash` -> `event_hash`). Torn tail writes from mid-append power loss or `SIGKILL` are truncated back to the last valid frame on replay, while mid-file corruption fails closed with `StateError`.
|
|
124
|
+
2. **$O(1)$ Delta Patching & Atomic Snapshots**:
|
|
125
|
+
Step outputs append discrete delta patches under `step_outputs` and write periodic atomic snapshots (`state.json` via tempfile + `os.fsync` + 6-attempt Windows NTFS `os.replace` retry + POSIX directory fsync).
|
|
126
|
+
3. **2-Tier Mutex (`atomic_marker`)**:
|
|
127
|
+
Combines a process-local `threading.Lock` and a cross-process `FileLock` (with PID start-time token verification to prevent PID-reuse lock false positives) and sweeps orphaned `.pending.<dead_pid>` markers on recovery.
|
|
128
|
+
> **External API Boundary**: No local filesystem marker can prevent duplicate execution if `SIGKILL` strikes after an HTTP request leaves the host NIC but before the response is committed to disk. For non-idempotent remote APIs (e.g. Stripe charges), pass an upstream `Idempotency-Key` header derived from `f"{goal_id}:{marker_id}"`.
|
|
129
|
+
4. **Allowlist-Only Type Hydration (`DurableCodecRegistry`)**:
|
|
130
|
+
Preserves `datetime`, `uuid.UUID`, `pathlib.Path`, `tuple`, and custom types registered via `register_codec()` across initial execution and WAL replay without using `pickle` or dynamic code imports.
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## 🍳 Runnable Examples & Cookbooks
|
|
135
|
+
|
|
136
|
+
Self-contained examples in [`examples/`](examples/):
|
|
137
|
+
|
|
138
|
+
| Target | Example / Cookbook | Description |
|
|
139
|
+
|---|---|---|
|
|
140
|
+
| **Playwright** | [`examples/cookbooks/playwright_scraper.py`](examples/cookbooks/playwright_scraper.py) | Multi-page scraper with `@durable_async` checkpointing that skips already-scraped pages on resume |
|
|
141
|
+
| **Streamlit UI** | [`examples/interactive_demo/app.py`](examples/interactive_demo/README.md) | Local crash injection and WAL replay visualizer |
|
|
142
|
+
| **Browser-Use** | [`examples/cookbooks/browser_use_durable.py`](examples/cookbooks/browser_use_durable.py) | Release digest workflow with step-level crash recovery |
|
|
143
|
+
| **LangGraph** | [`examples/cookbooks/langgraph_financial_analyst.py`](examples/cookbooks/langgraph_financial_analyst.py) | 4-step financial analyst pipeline with offline and live DeepSeek modes |
|
|
144
|
+
| **DSPy** | [`examples/cookbooks/dspy_durable_optimize.py`](examples/cookbooks/dspy_durable_optimize.py) | Prompt optimizer pipeline with step-level checkpointing |
|
|
145
|
+
| **Pydantic AI** | [`examples/cookbooks/pydantic_ai_durable.py`](examples/cookbooks/pydantic_ai_durable.py) | Type-safe agent workflow wrapped with LetItLoop step persistence |
|
|
146
|
+
| **FastAPI** | [`examples/fastapi_durable_background.py`](examples/fastapi_durable_background.py) | Single-worker durable background task queue backed by local WAL |
|
|
147
|
+
| **CrewAI / LlamaIndex** | [`examples/crewai_durable_tools.py`](examples/crewai_durable_tools.py) • [`examples/llamaindex_durable_workflow.py`](examples/llamaindex_durable_workflow.py) | Tool-call and step wrapper examples |
|
|
148
|
+
|
|
149
|
+
Run the financial analyst cookbook offline without API keys:
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
python -m pip install -e ".[financial-agent]"
|
|
153
|
+
python examples/cookbooks/langgraph_financial_analyst.py --ticker AAPL --offline
|
|
154
|
+
python examples/cookbooks/langgraph_financial_analyst.py --ticker AAPL --offline --demo
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
## 🛡️ GitHub Action CI Gate (`letitloop-action@v2`)
|
|
160
|
+
|
|
161
|
+
Verify `LILWAL02` frame checksums and Python AST syntax in GitHub Actions:
|
|
162
|
+
|
|
163
|
+
```yaml
|
|
164
|
+
name: Verify WAL & Python AST
|
|
165
|
+
on: [pull_request]
|
|
166
|
+
|
|
167
|
+
jobs:
|
|
168
|
+
verify:
|
|
169
|
+
runs-on: ubuntu-latest
|
|
170
|
+
steps:
|
|
171
|
+
- uses: actions/checkout@v4
|
|
172
|
+
- uses: sdageltc/letitloop-action@v2
|
|
173
|
+
with:
|
|
174
|
+
token: ${{ secrets.GITHUB_TOKEN }}
|
|
175
|
+
mode: 'gate'
|
|
176
|
+
wal-dir: '.bench_wal'
|
|
177
|
+
workspace: '.'
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
## 📜 Architecture Documentation
|
|
183
|
+
|
|
184
|
+
- [**Architecture & Trade-Offs**](docs/ARCHITECTURE_AND_TRADE_OFFS.md): Single-writer design contract, failure modes, and comparison with DBOS, LangGraph, and Temporal.
|
|
185
|
+
- [**ADR-0001**](docs/adr/0001-write-ahead-logging.md): Write-Ahead Logging (`LILWAL02`) & Torn-Tail Recovery.
|
|
186
|
+
- [**State Machine Specification**](docs/state_machine.md): Event-sourced state transitions and replay rules.
|
|
187
|
+
- [**Adapter Reference**](docs/adapters.md): Optional adapter shims under `letitloop.adapters`.
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
## 👥 Contributors
|
|
192
|
+
|
|
193
|
+
<table>
|
|
194
|
+
<tbody>
|
|
195
|
+
<tr>
|
|
196
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/sdageltc"><img src="https://avatars.githubusercontent.com/u/268154463?v=4" width="100px;" alt="sdageltc"/><br /><sub><b>sdageltc</b></sub></a></td>
|
|
197
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/h4syy"><img src="https://avatars.githubusercontent.com/u/59239840?v=4" width="100px;" alt="Yash Paudel"/><br /><sub><b>Yash Paudel</b></sub></a></td>
|
|
198
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/wangshen-tech"><img src="https://avatars.githubusercontent.com/u/190895315?v=4" width="100px;" alt="wangshen-tech"/><br /><sub><b>wangshen-tech</b></sub></a></td>
|
|
199
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/MagMueller"><img src="https://github.com/MagMueller.png" width="100px;" alt="MagMueller"/><br /><sub><b>MagMueller</b></sub></a></td>
|
|
200
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/darkseidpaul"><img src="https://github.com/darkseidpaul.png" width="100px;" alt="darkseidpaul"/><br /><sub><b>darkseidpaul</b></sub></a></td>
|
|
201
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/Aaqibhafeezkhan"><img src="https://github.com/Aaqibhafeezkhan.png" width="100px;" alt="Aaqibhafeezkhan"/><br /><sub><b>Aaqibhafeezkhan</b></sub></a></td>
|
|
202
|
+
</tr>
|
|
203
|
+
</tbody>
|
|
204
|
+
</table>
|
|
205
|
+
|
|
206
|
+
## License
|
|
207
|
+
|
|
208
|
+
Distributed under the MIT License. Copyright (c) 2026 sdageltc. See [LICENSE](LICENSE) for details.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Architectural Design, Contract Boundaries & Trade-Offs (`v0.7.2`)
|
|
2
|
+
|
|
3
|
+
This document specifies what `letitloop` guarantees, where its single-process local filesystem model stops, and when you should use an established database-backed workflow engine instead.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 1. Core Mechanism (`LILWAL02`)
|
|
8
|
+
|
|
9
|
+
`letitloop` persists step execution state in a local directory (`wal_dir`, defaulting to `.durable_wal`):
|
|
10
|
+
- **Write-Ahead Log (`state.wal.jsonl`)**: Every completed `step()` or `async_step()` appends an event record encoded in `LILWAL02` framing:
|
|
11
|
+
```text
|
|
12
|
+
\nLILWAL02:<byte_len_hex>:<crc32_hex>:<canonical_json_payload>\n
|
|
13
|
+
```
|
|
14
|
+
Each event includes a monotonic sequence number (`seq >= 1`, starting with `INIT`) and an unkeyed SHA-256 hash chain (`prev_hash` -> `event_hash`) followed by `f.flush()` and `os.fsync()`.
|
|
15
|
+
- **Periodic Atomic Snapshots (`state.json`)**: Every 50 steps and on clean context exit (`close()`), the projected state is written to a PID/timestamped temporary file in the same directory, flushed with `os.fsync()`, atomically swapped into `state.json` via `os.replace()` (with a 6-attempt exponential backoff loop on Windows NTFS to survive transient antivirus/indexer handles), and followed by a parent directory `fsync` on POSIX.
|
|
16
|
+
- **Crash Recovery**: On restart, `load_state()` reads `state.wal.jsonl`. If the final frame was torn mid-write by `SIGKILL` or power loss, the corrupt tail is truncated back to the last valid byte offset (`good_end`). Any corruption *prior* to the final frame raises `StateError` (fail-closed).
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## 2. Explicit Contract Boundaries & Limitations
|
|
21
|
+
|
|
22
|
+
1. **Single-Writer Local Filesystem Contract**:
|
|
23
|
+
- `letitloop` is designed for a **single active process per `wal_dir`** on a local POSIX or Windows NTFS volume.
|
|
24
|
+
- Do not place `wal_dir` on network filesystems (NFS, SMB, cloud-synced FUSE mounts) where `O_CREAT | O_EXCL` or `os.replace()` atomicity is not guaranteed.
|
|
25
|
+
2. **Step Identity (`step_id`)**:
|
|
26
|
+
- `step(step_id, fn, *args, **kwargs)` keys completed outputs strictly by `step_id` within `wal_dir`.
|
|
27
|
+
- Inside loops, assign a distinct `step_id` per iteration (for example, `step(f"scrape_page_{i}", scrape, url)`).
|
|
28
|
+
- To run a completed workflow again from scratch with new inputs, either pass a distinct `wal_dir` per run ID (`wal_dir=f".wal/{run_id}"`) or remove the prior `wal_dir`.
|
|
29
|
+
3. **Integrity vs. Cryptographic Authentication**:
|
|
30
|
+
- `LILWAL02` uses **CRC32** frame checksums and an **unkeyed SHA-256 hash chain** to detect accidental disk corruption and torn writes. It does not perform keyed HMAC authentication on WAL frames; any local process with write permissions to `wal_dir` can rewrite the file.
|
|
31
|
+
4. **External Side Effects (`atomic_marker`)**:
|
|
32
|
+
- `atomic_marker(marker_id)` serializes local execution via a two-tier lock (thread lock + `FileLock` with OS process start-time token verification) and records `.pending.<pid>` before yielding and `.committed` after the block succeeds.
|
|
33
|
+
- If `SIGKILL` strikes *after* an outbound HTTP request leaves the machine but *before* `.committed` is written, the block will yield `True` again on restart. Always pair non-idempotent remote HTTP calls with an upstream `Idempotency-Key` header.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## 3. Why We Narrowed Scope (November 2026 Landscape Note)
|
|
38
|
+
|
|
39
|
+
`letitloop` began in 2024 as a 70-file autonomous coding-agent harness before being stripped down in October 2026 (`v0.7.0`) into a single-dependency (`psutil`) local durability kernel.
|
|
40
|
+
|
|
41
|
+
By late 2026, two major shifts occurred across the Python AI ecosystem:
|
|
42
|
+
1. **In-process SQLite workflow engines matured**: **DBOS (`dbos`)** runs zero-daemon on embedded SQLite by default with `@DBOS.workflow()` / `@DBOS.step()`, durable timers (`DBOS.sleep`), queues, a zero-code upgrade path to PostgreSQL, and official integrations with PydanticAI and the OpenAI Agents SDK. **Prefect** similarly offers an ephemeral local SQLite mode.
|
|
43
|
+
2. **Agent frameworks shipped native local checkpointers**: **LangGraph** (`SqliteSaver` + `@entrypoint` / `@task`), **CrewAI** (`@persist` Flows on SQLite), **Google ADK** (`DatabaseSessionService`), **OpenAI Agents SDK** (`SQLiteSession`), and **LlamaIndex** (`WorkflowCheckpointer`) all provide built-in state persistence.
|
|
44
|
+
|
|
45
|
+
Consequently, `letitloop` does not attempt to compete with DBOS, Temporal, or native framework savers. It remains a compact, auditable reference implementation (~2,000 lines of core Python in `orchestrator/`) for developers who want a zero-SQLite, human-readable JSONL Write-Ahead Log and a cross-platform CLI crash supervisor (`lil watch`) with one dependency.
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"""letitloop/adapters — Official Multi-Framework Durability Adapter Suite.
|
|
2
|
+
|
|
3
|
+
Provides drop-in, zero-daemon WAL durability handlers and checkpointers across
|
|
4
|
+
major multi-agent frameworks and web stacks:
|
|
5
|
+
- CrewAI (`CrewAIDurabilityHandler`)
|
|
6
|
+
- Hugging Face Smolagents (`SmolagentsWALCallback`)
|
|
7
|
+
- Microsoft AutoGen 0.4 / Magentic-One (`AutoGenStateSerializer`)
|
|
8
|
+
- LangGraph (`LetItLoopCheckpointSaver`)
|
|
9
|
+
- FastAPI / Starlette (`DurableBackgroundTasks`, `DurableTaskManager`)
|
|
10
|
+
|
|
11
|
+
All adapters support zero mandatory runtime dependencies with optional lazy loading.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
import importlib.util
|
|
17
|
+
from typing import Any, Dict
|
|
18
|
+
|
|
19
|
+
__all__ = [
|
|
20
|
+
"CrewAIDurabilityHandler",
|
|
21
|
+
"SmolagentsWALCallback",
|
|
22
|
+
"AutoGenStateSerializer",
|
|
23
|
+
"LetItLoopCheckpointSaver",
|
|
24
|
+
"DurableBackgroundTasks",
|
|
25
|
+
"DurableTaskManager",
|
|
26
|
+
"durable_task",
|
|
27
|
+
"install_durable_background_tasks",
|
|
28
|
+
"get_available_adapters",
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def get_available_adapters() -> Dict[str, bool]:
|
|
33
|
+
"""Return status of optional host framework installations without eager heavy imports."""
|
|
34
|
+
return {
|
|
35
|
+
"crewai": importlib.util.find_spec("crewai") is not None,
|
|
36
|
+
"smolagents": importlib.util.find_spec("smolagents") is not None,
|
|
37
|
+
"autogen": (
|
|
38
|
+
importlib.util.find_spec("autogen_core") is not None or importlib.util.find_spec("autogen") is not None
|
|
39
|
+
),
|
|
40
|
+
"langgraph": importlib.util.find_spec("langgraph") is not None,
|
|
41
|
+
"fastapi": importlib.util.find_spec("fastapi") is not None,
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def __getattr__(name: str) -> Any:
|
|
46
|
+
if name == "CrewAIDurabilityHandler":
|
|
47
|
+
from .crewai import CrewAIDurabilityHandler
|
|
48
|
+
|
|
49
|
+
return CrewAIDurabilityHandler
|
|
50
|
+
if name == "SmolagentsWALCallback":
|
|
51
|
+
from .smolagents import SmolagentsWALCallback
|
|
52
|
+
|
|
53
|
+
return SmolagentsWALCallback
|
|
54
|
+
if name == "AutoGenStateSerializer":
|
|
55
|
+
from .autogen import AutoGenStateSerializer
|
|
56
|
+
|
|
57
|
+
return AutoGenStateSerializer
|
|
58
|
+
if name == "LetItLoopCheckpointSaver":
|
|
59
|
+
from .langgraph import LetItLoopCheckpointSaver
|
|
60
|
+
|
|
61
|
+
return LetItLoopCheckpointSaver
|
|
62
|
+
if name in (
|
|
63
|
+
"DurableBackgroundTasks",
|
|
64
|
+
"DurableTaskManager",
|
|
65
|
+
"durable_task",
|
|
66
|
+
"install_durable_background_tasks",
|
|
67
|
+
):
|
|
68
|
+
from . import fastapi as _fa
|
|
69
|
+
|
|
70
|
+
return getattr(_fa, name)
|
|
71
|
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|