nextloop 0.7.0__tar.gz → 0.9.0__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.
- {nextloop-0.7.0/src/nextloop.egg-info → nextloop-0.9.0}/PKG-INFO +23 -9
- {nextloop-0.7.0 → nextloop-0.9.0}/README.md +22 -8
- nextloop-0.9.0/docs/adr/0009-outbox.md +30 -0
- nextloop-0.9.0/docs/adr/0010-session-deletion.md +28 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/docs/architecture/development-plan.md +2 -1
- {nextloop-0.7.0 → nextloop-0.9.0}/docs/architecture/discussion-roadmap.md +7 -7
- {nextloop-0.7.0 → nextloop-0.9.0}/docs/architecture/feature-worklist.md +3 -3
- {nextloop-0.7.0 → nextloop-0.9.0}/docs/architecture/requirements.md +1 -1
- {nextloop-0.7.0 → nextloop-0.9.0}/docs/design/architecture.md +2 -2
- {nextloop-0.7.0 → nextloop-0.9.0}/docs/design/harness.md +14 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/docs/design/loop-interface.md +6 -2
- {nextloop-0.7.0 → nextloop-0.9.0}/docs/design/verification-matrix.md +31 -2
- {nextloop-0.7.0 → nextloop-0.9.0}/pyproject.toml +1 -1
- {nextloop-0.7.0 → nextloop-0.9.0}/src/nextloop/__init__.py +8 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/src/nextloop/adapters/__init__.py +2 -0
- nextloop-0.9.0/src/nextloop/adapters/_sqlite.py +31 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/src/nextloop/adapters/memory.py +23 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/src/nextloop/adapters/observing.py +85 -36
- nextloop-0.9.0/src/nextloop/adapters/outbox.py +319 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/src/nextloop/adapters/sqlite.py +101 -18
- {nextloop-0.7.0 → nextloop-0.9.0}/src/nextloop/contracts.py +23 -1
- {nextloop-0.7.0 → nextloop-0.9.0}/src/nextloop/events/trace.py +3 -0
- nextloop-0.9.0/src/nextloop/events/trace_ids.py +28 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/src/nextloop/testing.py +24 -0
- {nextloop-0.7.0 → nextloop-0.9.0/src/nextloop.egg-info}/PKG-INFO +23 -9
- {nextloop-0.7.0 → nextloop-0.9.0}/src/nextloop.egg-info/SOURCES.txt +8 -0
- nextloop-0.9.0/tests/test_deletion.py +326 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/tests/test_harness.py +1 -1
- {nextloop-0.7.0 → nextloop-0.9.0}/tests/test_import_contract.py +5 -0
- nextloop-0.9.0/tests/test_outbox.py +137 -0
- nextloop-0.9.0/tests/test_outbox_regressions.py +344 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/tests/test_skills.py +1 -1
- {nextloop-0.7.0 → nextloop-0.9.0}/LICENSE +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/MANIFEST.in +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/docs/adr/0001-embeddable-agent-loop.md +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/docs/adr/0002-dsh-aligned-agent-loop.md +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/docs/adr/0003-python-and-centralized-contracts.md +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/docs/adr/0004-event-compatibility.md +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/docs/adr/0005-pending-input.md +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/docs/adr/0006-operation-id.md +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/docs/adr/0007-approval.md +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/docs/adr/0008-lease.md +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/docs/architecture/agent-loop-capability-review.md +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/docs/design/agent-loop.md +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/docs/design/context-builder.md +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/docs/design/react-protocol.md +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/docs/design/skills.md +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/docs/research/2026-11-02-dsh-primary-sources.md +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/docs/research/2026-11-02-loop-evidence-notes.md +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/docs/research/2026-11-03-hermes-turn-control.md +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/docs/research/2026-11-03-tool-batch-failures.md +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/docs/research/2026-11-03-tool-call-validation.md +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/docs/research/2026-11-03-yomi-turn-control.md +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/docs/research/2026-11-06-open-source-agent-loops.md +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/docs/research/2026-11-06-react-tool-event-recovery.md +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/docs/research/2026-11-10-nextloop-optimization-review.md +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/examples/basic.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/examples/harness-skills/echo/SKILL.md +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/examples/harness.toml +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/examples/live_smoke.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/examples/python_tools.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/examples/skills/coding/SKILL.md +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/examples/skills_demo.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/examples/workers/cpp_worker.cpp +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/examples/workers/python_worker.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/examples/workers/rust_worker.rs +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/setup.cfg +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/src/nextloop/adapters/_sse.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/src/nextloop/adapters/anthropic.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/src/nextloop/adapters/openai.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/src/nextloop/cli.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/src/nextloop/driver.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/src/nextloop/events/__init__.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/src/nextloop/events/approval.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/src/nextloop/events/input.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/src/nextloop/events/outcome.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/src/nextloop/events/pending.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/src/nextloop/events/project.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/src/nextloop/events/repair.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/src/nextloop/events/response.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/src/nextloop/events/upcast.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/src/nextloop/execute/__init__.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/src/nextloop/execute/batch.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/src/nextloop/execute/cancellation.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/src/nextloop/execute/cleanup.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/src/nextloop/execute/composite.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/src/nextloop/execute/mcp.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/src/nextloop/execute/model.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/src/nextloop/execute/preview.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/src/nextloop/execute/result_read.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/src/nextloop/execute/stdio.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/src/nextloop/execute/stdio_transport.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/src/nextloop/execute/tools.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/src/nextloop/harness.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/src/nextloop/loop.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/src/nextloop/py.typed +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/src/nextloop/skills.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/src/nextloop.egg-info/dependency_links.txt +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/src/nextloop.egg-info/entry_points.txt +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/src/nextloop.egg-info/requires.txt +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/src/nextloop.egg-info/top_level.txt +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/tests/test_aggregate_close.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/tests/test_approval.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/tests/test_approval_regressions.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/tests/test_budgets.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/tests/test_cli.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/tests/test_compaction_lineage.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/tests/test_complexity_regressions.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/tests/test_correctness_regressions.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/tests/test_events.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/tests/test_failures.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/tests/test_fault_injection.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/tests/test_fault_matrix.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/tests/test_harness_injection.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/tests/test_lease.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/tests/test_loop.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/tests/test_mcp.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/tests/test_mcp_hardening.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/tests/test_observability.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/tests/test_observability_close_deadline.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/tests/test_operations.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/tests/test_pending_inputs.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/tests/test_preview.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/tests/test_projection_parity.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/tests/test_provider_terminal.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/tests/test_providers.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/tests/test_result_budget_regressions.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/tests/test_result_policies.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/tests/test_retry_regressions.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/tests/test_review_regressions.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/tests/test_stdio.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/tests/test_stdio_cleanup.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/tests/test_stdio_frames.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/tests/test_stdio_safety.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/tests/test_store_contract.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/tests/test_stores.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/tests/test_surface_snapshot.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/tests/test_upcasting.py +0 -0
- {nextloop-0.7.0 → nextloop-0.9.0}/tests/test_worker_conformance.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: nextloop
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.9.0
|
|
4
4
|
Summary: An embeddable AgentLoop with explicit event, tool, recovery, and delivery semantics
|
|
5
5
|
Author-email: 12bitsD <bis12@163.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -35,12 +35,12 @@ nextloop is an embeddable Python AgentLoop for developers who want to build thei
|
|
|
35
35
|
|
|
36
36
|
**Your agent, your rules. No magic, no black box.**
|
|
37
37
|
|
|
38
|
-
Current version: **0.
|
|
38
|
+
Current version: **0.9.0**.
|
|
39
39
|
|
|
40
40
|
## Install
|
|
41
41
|
|
|
42
42
|
```bash
|
|
43
|
-
python -m pip install nextloop==0.
|
|
43
|
+
python -m pip install nextloop==0.9.0
|
|
44
44
|
```
|
|
45
45
|
|
|
46
46
|
For local development:
|
|
@@ -55,7 +55,7 @@ uv pip install --python .venv/bin/python -e '.[dev]'
|
|
|
55
55
|
- **Execution you can reason about.** DSH-aligned Session/Turn/Step/attempt coordinates, writer fencing, and append-only Trajectory instead of implicit runner state.
|
|
56
56
|
- **Crash recovery without blind replay.** Resource locks, uncertain outcomes, crash closers, and delivery-only recovery tell you what is known, what is unknown, and what must not run twice.
|
|
57
57
|
- **Tools without framework lock-in.** Register Python functions directly, connect MCP stdio servers, or run persistent Rust and C++ workers over stdio JSON-RPC. Schema validation, parallel calls, and exclusive barriers are built in.
|
|
58
|
-
- **Observability from committed facts.** Structured Model/Tool/Turn traces, asynchronous Exporters, and
|
|
58
|
+
- **Observability from committed facts.** Structured Model/Tool/Turn traces, asynchronous Exporters, Session history, and a durable caller-driven SQLite Outbox. No second execution path and no telemetry-driven control flow.
|
|
59
59
|
- **Small, explicit integration.** Assemble Providers, Stores, Tools, and Skills with `harness.toml`, or inject your own adapters in Python. OpenAI-compatible and Anthropic Providers are included.
|
|
60
60
|
- **Bounded execution and context.** Optional Step, Provider-attempt, Tool, token, and deadline budgets. Large Tool Results use explicit preview/page/full policies with durable read-back.
|
|
61
61
|
- **Transient previews, authoritative results.** Optional OpenAI/Anthropic deltas with bounded queues and snapshot recovery. Previews never enter the EventStore, execute partial Tool Calls, or replace committed Delivery.
|
|
@@ -111,7 +111,8 @@ Core adapter seams are `EventStore`, `ModelProvider`, `ToolRuntime`, and `Delive
|
|
|
111
111
|
| Event compatibility | Schema 1.0 is upcast only during reads; original payload bytes are preserved for idempotent append. | Reading schema 1.1 with 0.5.0 or earlier, or accepting unknown future schemas. |
|
|
112
112
|
| Recovery | Recovery writes crash closers; the caller starts a new Turn with projected prior messages and Pending Input. | In-place replay of the interrupted Turn or automatic execution of uncertain calls. |
|
|
113
113
|
| Preview | Preview is transient and cannot execute partial Tool arguments. | Preview as a durable EventStore fact or a substitute for committed Delivery. |
|
|
114
|
-
| Observability | Committed Events are authoritative
|
|
114
|
+
| Observability | Committed Events are authoritative. The live queue is best-effort; `SQLiteOutbox` durably replays closed Turns with cursors, bounded attempts, gaps, and owner-token locks. | Exactly-once export, exporting active Turns, or cleanup of third-party exported copies. |
|
|
115
|
+
| Session deletion | Idempotent deleting/deleted tombstones fence writers and reads; local Events, Trace state, and Outbox rows are removed, with SQLite secure-delete/checkpoint/VACUUM byte cleanup. | Event-level erasure, external Tool rollback, or deletion of caller copies, third-party exports, backups, and external assets. |
|
|
115
116
|
| MCP | stdio lifecycle, paginated static catalogs, operation metadata, and uncertain crash handling. | Remote MCP, OAuth, dynamic `listChanged`, or non-text content mapping. |
|
|
116
117
|
|
|
117
118
|
`Harness.load("harness.toml")` assembles those adapters without changing the Loop. Use `await harness.check()` for offline validation and `await harness.run("input")` for a model-backed Turn. See [Harness and extension interface](docs/design/harness.md) for the strict TOML schema, stdio protocol, lifecycle rules, and CLI.
|
|
@@ -166,6 +167,17 @@ history = await harness.history(from_turn=1, to_turn=10)
|
|
|
166
167
|
|
|
167
168
|
History works with memory and SQLite Stores even when no Exporter is configured.
|
|
168
169
|
|
|
170
|
+
For replay that survives process restart, drive a durable Outbox from your application:
|
|
171
|
+
|
|
172
|
+
```python
|
|
173
|
+
outbox = SQLiteOutbox(store, "outbox.sqlite3", [my_exporter], max_attempts=3)
|
|
174
|
+
report = await outbox.export_pending() # all Sessions; pass session_id to select one
|
|
175
|
+
print(report.exported, outbox.gaps())
|
|
176
|
+
outbox.close()
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
Only closed Turns are eligible. Successful Exporter calls advance an independent cursor; failures persist attempts and eventually produce auditable gaps. Owner-token locks and heartbeats prevent concurrent callers from exporting the same pending records, while expired locks allow crash takeover. Export is at least once; synchronous calls that time out can still produce late side effects. Asynchronous Exporters must respond to cancellation, because code that suppresses cancellation can delay cleanup. Neither case counts as a successful acknowledgement.
|
|
180
|
+
|
|
169
181
|
`ToolRegistry` is the built-in `ToolRuntime` implementation:
|
|
170
182
|
|
|
171
183
|
```python
|
|
@@ -232,14 +244,16 @@ The release checks cover:
|
|
|
232
244
|
- recorded OpenAI and Anthropic SSE streams;
|
|
233
245
|
- 12 live Kimi scenarios across both protocols, real Tool usage, parallel execution, recovery, steer, cancellation, Compaction, and WorkingContext;
|
|
234
246
|
- live DeepSeek text + Preview + usage and real Tool Call + Delivery smoke;
|
|
247
|
+
- durable Outbox ack/crash windows, replay identity, bounded retries/gaps, lock heartbeat/takeover, and concurrent schema migration;
|
|
248
|
+
- reentrant Session deletion, stale-writer/read fencing, queue isolation, Outbox anti-resurrection, and raw SQLite content-canary scans;
|
|
235
249
|
- a 10,505-event benchmark with cross-Store, incremental, and required-content parity;
|
|
236
|
-
-
|
|
250
|
+
- 384 offline tests, `ruff`, `mypy`, wheel/sdist builds, `twine check`, and clean wheel installation.
|
|
237
251
|
|
|
238
252
|
Current limits:
|
|
239
253
|
|
|
240
254
|
- nika integration is separate acceptance work.
|
|
241
|
-
-
|
|
242
|
-
-
|
|
255
|
+
- Writer leases coordinate same-host processes only; distributed locks and exactly-once export are not provided.
|
|
256
|
+
- Event-level erasure, external-asset lifecycle, backup/GC, and deletion of third-party copies are not part of this release.
|
|
243
257
|
- Official OpenAI and Anthropic API acceptance remains a 1.0 hard gate; recorded streams and DeepSeek do not substitute for it.
|
|
244
258
|
|
|
245
259
|
## Documents
|
|
@@ -255,7 +269,7 @@ Current limits:
|
|
|
255
269
|
- [Development plan](docs/architecture/development-plan.md)
|
|
256
270
|
- [Contributing](CONTRIBUTING.md) and [Security](SECURITY.md)
|
|
257
271
|
- [Changelog](CHANGELOG.md)
|
|
258
|
-
- [ADR-0002](docs/adr/0002-dsh-aligned-agent-loop.md), [ADR-0003](docs/adr/0003-python-and-centralized-contracts.md), [ADR-0004 Event compatibility](docs/adr/0004-event-compatibility.md), [ADR-0005 Pending Input](docs/adr/0005-pending-input.md), [ADR-0006 Operation identity](docs/adr/0006-operation-id.md),
|
|
272
|
+
- [ADR-0002](docs/adr/0002-dsh-aligned-agent-loop.md), [ADR-0003](docs/adr/0003-python-and-centralized-contracts.md), [ADR-0004 Event compatibility](docs/adr/0004-event-compatibility.md), [ADR-0005 Pending Input](docs/adr/0005-pending-input.md), [ADR-0006 Operation identity](docs/adr/0006-operation-id.md), [ADR-0007 Approval](docs/adr/0007-approval.md), [ADR-0008 Owner leases](docs/adr/0008-lease.md), [ADR-0009 Durable Outbox](docs/adr/0009-outbox.md), and [ADR-0010 Session deletion](docs/adr/0010-session-deletion.md)
|
|
259
273
|
|
|
260
274
|
## Release
|
|
261
275
|
|
|
@@ -6,12 +6,12 @@ nextloop is an embeddable Python AgentLoop for developers who want to build thei
|
|
|
6
6
|
|
|
7
7
|
**Your agent, your rules. No magic, no black box.**
|
|
8
8
|
|
|
9
|
-
Current version: **0.
|
|
9
|
+
Current version: **0.9.0**.
|
|
10
10
|
|
|
11
11
|
## Install
|
|
12
12
|
|
|
13
13
|
```bash
|
|
14
|
-
python -m pip install nextloop==0.
|
|
14
|
+
python -m pip install nextloop==0.9.0
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
For local development:
|
|
@@ -26,7 +26,7 @@ uv pip install --python .venv/bin/python -e '.[dev]'
|
|
|
26
26
|
- **Execution you can reason about.** DSH-aligned Session/Turn/Step/attempt coordinates, writer fencing, and append-only Trajectory instead of implicit runner state.
|
|
27
27
|
- **Crash recovery without blind replay.** Resource locks, uncertain outcomes, crash closers, and delivery-only recovery tell you what is known, what is unknown, and what must not run twice.
|
|
28
28
|
- **Tools without framework lock-in.** Register Python functions directly, connect MCP stdio servers, or run persistent Rust and C++ workers over stdio JSON-RPC. Schema validation, parallel calls, and exclusive barriers are built in.
|
|
29
|
-
- **Observability from committed facts.** Structured Model/Tool/Turn traces, asynchronous Exporters, and
|
|
29
|
+
- **Observability from committed facts.** Structured Model/Tool/Turn traces, asynchronous Exporters, Session history, and a durable caller-driven SQLite Outbox. No second execution path and no telemetry-driven control flow.
|
|
30
30
|
- **Small, explicit integration.** Assemble Providers, Stores, Tools, and Skills with `harness.toml`, or inject your own adapters in Python. OpenAI-compatible and Anthropic Providers are included.
|
|
31
31
|
- **Bounded execution and context.** Optional Step, Provider-attempt, Tool, token, and deadline budgets. Large Tool Results use explicit preview/page/full policies with durable read-back.
|
|
32
32
|
- **Transient previews, authoritative results.** Optional OpenAI/Anthropic deltas with bounded queues and snapshot recovery. Previews never enter the EventStore, execute partial Tool Calls, or replace committed Delivery.
|
|
@@ -82,7 +82,8 @@ Core adapter seams are `EventStore`, `ModelProvider`, `ToolRuntime`, and `Delive
|
|
|
82
82
|
| Event compatibility | Schema 1.0 is upcast only during reads; original payload bytes are preserved for idempotent append. | Reading schema 1.1 with 0.5.0 or earlier, or accepting unknown future schemas. |
|
|
83
83
|
| Recovery | Recovery writes crash closers; the caller starts a new Turn with projected prior messages and Pending Input. | In-place replay of the interrupted Turn or automatic execution of uncertain calls. |
|
|
84
84
|
| Preview | Preview is transient and cannot execute partial Tool arguments. | Preview as a durable EventStore fact or a substitute for committed Delivery. |
|
|
85
|
-
| Observability | Committed Events are authoritative
|
|
85
|
+
| Observability | Committed Events are authoritative. The live queue is best-effort; `SQLiteOutbox` durably replays closed Turns with cursors, bounded attempts, gaps, and owner-token locks. | Exactly-once export, exporting active Turns, or cleanup of third-party exported copies. |
|
|
86
|
+
| Session deletion | Idempotent deleting/deleted tombstones fence writers and reads; local Events, Trace state, and Outbox rows are removed, with SQLite secure-delete/checkpoint/VACUUM byte cleanup. | Event-level erasure, external Tool rollback, or deletion of caller copies, third-party exports, backups, and external assets. |
|
|
86
87
|
| MCP | stdio lifecycle, paginated static catalogs, operation metadata, and uncertain crash handling. | Remote MCP, OAuth, dynamic `listChanged`, or non-text content mapping. |
|
|
87
88
|
|
|
88
89
|
`Harness.load("harness.toml")` assembles those adapters without changing the Loop. Use `await harness.check()` for offline validation and `await harness.run("input")` for a model-backed Turn. See [Harness and extension interface](docs/design/harness.md) for the strict TOML schema, stdio protocol, lifecycle rules, and CLI.
|
|
@@ -137,6 +138,17 @@ history = await harness.history(from_turn=1, to_turn=10)
|
|
|
137
138
|
|
|
138
139
|
History works with memory and SQLite Stores even when no Exporter is configured.
|
|
139
140
|
|
|
141
|
+
For replay that survives process restart, drive a durable Outbox from your application:
|
|
142
|
+
|
|
143
|
+
```python
|
|
144
|
+
outbox = SQLiteOutbox(store, "outbox.sqlite3", [my_exporter], max_attempts=3)
|
|
145
|
+
report = await outbox.export_pending() # all Sessions; pass session_id to select one
|
|
146
|
+
print(report.exported, outbox.gaps())
|
|
147
|
+
outbox.close()
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Only closed Turns are eligible. Successful Exporter calls advance an independent cursor; failures persist attempts and eventually produce auditable gaps. Owner-token locks and heartbeats prevent concurrent callers from exporting the same pending records, while expired locks allow crash takeover. Export is at least once; synchronous calls that time out can still produce late side effects. Asynchronous Exporters must respond to cancellation, because code that suppresses cancellation can delay cleanup. Neither case counts as a successful acknowledgement.
|
|
151
|
+
|
|
140
152
|
`ToolRegistry` is the built-in `ToolRuntime` implementation:
|
|
141
153
|
|
|
142
154
|
```python
|
|
@@ -203,14 +215,16 @@ The release checks cover:
|
|
|
203
215
|
- recorded OpenAI and Anthropic SSE streams;
|
|
204
216
|
- 12 live Kimi scenarios across both protocols, real Tool usage, parallel execution, recovery, steer, cancellation, Compaction, and WorkingContext;
|
|
205
217
|
- live DeepSeek text + Preview + usage and real Tool Call + Delivery smoke;
|
|
218
|
+
- durable Outbox ack/crash windows, replay identity, bounded retries/gaps, lock heartbeat/takeover, and concurrent schema migration;
|
|
219
|
+
- reentrant Session deletion, stale-writer/read fencing, queue isolation, Outbox anti-resurrection, and raw SQLite content-canary scans;
|
|
206
220
|
- a 10,505-event benchmark with cross-Store, incremental, and required-content parity;
|
|
207
|
-
-
|
|
221
|
+
- 384 offline tests, `ruff`, `mypy`, wheel/sdist builds, `twine check`, and clean wheel installation.
|
|
208
222
|
|
|
209
223
|
Current limits:
|
|
210
224
|
|
|
211
225
|
- nika integration is separate acceptance work.
|
|
212
|
-
-
|
|
213
|
-
-
|
|
226
|
+
- Writer leases coordinate same-host processes only; distributed locks and exactly-once export are not provided.
|
|
227
|
+
- Event-level erasure, external-asset lifecycle, backup/GC, and deletion of third-party copies are not part of this release.
|
|
214
228
|
- Official OpenAI and Anthropic API acceptance remains a 1.0 hard gate; recorded streams and DeepSeek do not substitute for it.
|
|
215
229
|
|
|
216
230
|
## Documents
|
|
@@ -226,7 +240,7 @@ Current limits:
|
|
|
226
240
|
- [Development plan](docs/architecture/development-plan.md)
|
|
227
241
|
- [Contributing](CONTRIBUTING.md) and [Security](SECURITY.md)
|
|
228
242
|
- [Changelog](CHANGELOG.md)
|
|
229
|
-
- [ADR-0002](docs/adr/0002-dsh-aligned-agent-loop.md), [ADR-0003](docs/adr/0003-python-and-centralized-contracts.md), [ADR-0004 Event compatibility](docs/adr/0004-event-compatibility.md), [ADR-0005 Pending Input](docs/adr/0005-pending-input.md), [ADR-0006 Operation identity](docs/adr/0006-operation-id.md),
|
|
243
|
+
- [ADR-0002](docs/adr/0002-dsh-aligned-agent-loop.md), [ADR-0003](docs/adr/0003-python-and-centralized-contracts.md), [ADR-0004 Event compatibility](docs/adr/0004-event-compatibility.md), [ADR-0005 Pending Input](docs/adr/0005-pending-input.md), [ADR-0006 Operation identity](docs/adr/0006-operation-id.md), [ADR-0007 Approval](docs/adr/0007-approval.md), [ADR-0008 Owner leases](docs/adr/0008-lease.md), [ADR-0009 Durable Outbox](docs/adr/0009-outbox.md), and [ADR-0010 Session deletion](docs/adr/0010-session-deletion.md)
|
|
230
244
|
|
|
231
245
|
## Release
|
|
232
246
|
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# ADR-0009: Caller-driven durable Outbox
|
|
2
|
+
|
|
3
|
+
Status: accepted
|
|
4
|
+
|
|
5
|
+
## Context
|
|
6
|
+
|
|
7
|
+
The existing Exporter queue is in memory and can lose traces on crash. A durable export must not own writer epochs, require a running AgentLoop, or report active Turns as complete.
|
|
8
|
+
|
|
9
|
+
## Decision
|
|
10
|
+
|
|
11
|
+
- `SQLiteOutbox` owns export cursors, attempt counters, and gaps in a separate table. These records never advance `writer_epoch` and are not an Event authority.
|
|
12
|
+
- `export_pending(session_id=None)` is caller-driven and has no resident worker. It can enumerate all EventStore Sessions and continue exporting a closed Turn after process restart without calling `recover()`.
|
|
13
|
+
- Only Turns with a committed TURN_END are exported. Model, Tool, and Turn traces come from the same `TraceProjector` used for live/history projection. An active later Turn does not block already closed earlier Turns.
|
|
14
|
+
- A trace is eligible only when its source seq exceeds the durable cursor. Successful Export acknowledgement commits the cursor in a separate transaction. A crash after acknowledgement but before that commit can replay; a crash after the commit cannot replay.
|
|
15
|
+
- Failed exports persist an attempt counter. `max_attempts` is bounded; reaching it records an auditable export gap and advances to the next exportable point instead of blocking forever or claiming success.
|
|
16
|
+
- OTel mapping uses a deterministic 128-bit `trace_id` per Session and deterministic 64-bit `span_id` per trace record. The OTel Exporter itself is outside this milestone.
|
|
17
|
+
- Tool duration measures actual execution only. Approval waiting does not enter Tool duration; Turn duration remains separate.
|
|
18
|
+
- Each exporting instance writes a unique owner token with its Session lock. A heartbeat runs only during `export_pending()` and renews at one-third of `lock_timeout_seconds`; release and renewal must match that token. Expired locks can be reclaimed after a process crash, and an old owner cannot delete its successor's lock. Old lock tables migrate under a write transaction.
|
|
19
|
+
|
|
20
|
+
## Third-party EventStore migration
|
|
21
|
+
|
|
22
|
+
Implementations and decorators must add or delegate `session_ids() -> Sequence[str]`, returning all Sessions with committed Events in stable order. Without this method, caller-driven export cannot enumerate unexported Sessions after restart. No writer ownership or lease behavior is required.
|
|
23
|
+
|
|
24
|
+
`export_timeout_seconds` bounds each cooperative Exporter call. A timeout follows the same attempt/gap path as other failures; cancelling a Python thread does not forcibly stop its code, and an asynchronous Exporter that suppresses cancellation can delay cleanup. Late side effects remain possible and are not reported as successful acknowledgement. Asynchronous Exporters must respond to cancellation; arbitrary user code is not hard-isolated by the timeout. `delete_session(session_id)` removes only Outbox cursor, attempts, gaps, and locks, with the same SQLite physical cleanup used for Events. Whole-Session Event deletion is specified by ADR-0010. Outbox attempts, cursor advances, and gaps validate the current owner token in their write transaction so deleted state cannot be resurrected by an old export.
|
|
25
|
+
|
|
26
|
+
## Consequences
|
|
27
|
+
|
|
28
|
+
- Export is at least once across process crashes and supports durable replay without starting the Loop.
|
|
29
|
+
- Cursor acknowledgement and export-gap persistence are separate from Event append transactions.
|
|
30
|
+
- Active work is never misrepresented as a complete Trace, and persistent failures remain inspectable.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# ADR-0010: Reentrant whole-Session deletion
|
|
2
|
+
|
|
3
|
+
Status: accepted
|
|
4
|
+
|
|
5
|
+
## Context
|
|
6
|
+
|
|
7
|
+
Event history, writer leases, Trace projection state, live Exporter queues, and Outbox cursors can all retain Session-derived data. Deleting only Event rows neither fences stale writers nor removes local derived copies. Whole-Session deletion is required; event-level erasure remains outside this milestone.
|
|
8
|
+
|
|
9
|
+
## Decision
|
|
10
|
+
|
|
11
|
+
- `EventStore.delete_session(session_id)` is idempotent and uses a Session-ID-only tombstone with `deleting` and `deleted` states. The first transaction commits `deleting`, increments any existing writer epoch, and removes lease ownership. The second removes Events and writer state and commits `deleted`.
|
|
12
|
+
- A tombstone in either state fails closed for attach, append, writer checks/renewal, surface reads, and recovery reads. Tombstoned Sessions are excluded from `session_ids()` and cannot be recreated through the EventStore API.
|
|
13
|
+
- InMemoryEventStore applies the same tombstone and cache-removal semantics without claiming physical destruction of caller-owned copies or Python runtime history.
|
|
14
|
+
- SQLite creates the tombstone table lazily on first deletion, preserving read-only historical fixture bytes. Surface and recovery reads use one consistent snapshot for tombstone validation and Event selection.
|
|
15
|
+
- SQLite enables `secure_delete` before row deletion. After logical deletion it checkpoints and truncates the WAL, vacuums the database, and checkpoints again. A busy checkpoint or failed physical cleanup surfaces an error; repeating deletion retries cleanup while the tombstone continues to fail closed.
|
|
16
|
+
- ObservingEventStore serializes append/export activity with deletion. It removes TraceProjector state, queued records for the deleted Session, and seed markers, and suppresses a record already fetched by the worker. No deleted-Session Trace is newly exported after deletion returns.
|
|
17
|
+
- SQLiteOutbox.delete_session remains the owner of Outbox cursor, attempts, gaps, and locks and applies the same SQLite physical cleanup. Every attempt, cursor, and gap write validates the current owner token in its write transaction, so an in-flight export cannot recreate deleted rows. Whole-Session retention calls both idempotent APIs; no cross-database transaction is claimed.
|
|
18
|
+
- Tests inject deleting/deleted intermediate states and cleanup crashes, verify stale-writer and read rejection, preserve an unrelated Session, and scan DB, WAL, SHM, and rollback-journal bytes for synthetic content canaries.
|
|
19
|
+
|
|
20
|
+
## Boundaries
|
|
21
|
+
|
|
22
|
+
Deletion does not roll back an already dispatched external Tool effect. Callers must quiesce active Loops and Exporters when they require physical destruction without late side effects. Caller-owned Event/Trace copies, third-party exports, backups, offline replicas, external assets, and event-level erasure are outside this guarantee.
|
|
23
|
+
|
|
24
|
+
## Consequences
|
|
25
|
+
|
|
26
|
+
- A crash at any point leaves either a fail-closed deleting/deleted tombstone or a completed deletion; repeating both Store-specific cleanup APIs resumes the remaining work.
|
|
27
|
+
- Only the Session ID and deletion state remain in the EventStore. No Event payload or Compaction summary is retained in the tombstone.
|
|
28
|
+
- Third-party EventStores and decorators must implement or delegate `delete_session()` and preserve fail-closed tombstone behavior to satisfy the updated public contract.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# nextloop development and verification plan
|
|
2
2
|
|
|
3
|
-
Current stage: **0.
|
|
3
|
+
Current stage: **0.9.0 release verification**. `0.8.0` is published; later milestones are not claimed as implemented.
|
|
4
4
|
|
|
5
5
|
## Delivery order
|
|
6
6
|
|
|
@@ -51,6 +51,7 @@ See [Architecture and import contract](../design/architecture.md), [Verification
|
|
|
51
51
|
- `export_pending(session_id=None)` is caller-driven and can enumerate Sessions with unexported closed Turns without starting recovery.
|
|
52
52
|
- Watermarks advance only after durable Export acknowledgement. Bounded retries record auditable gaps rather than blocking forever or pretending success.
|
|
53
53
|
- Trace replay uses stable OTel 128-bit trace IDs and 64-bit span IDs. No OTel Exporter implementation is included in this milestone.
|
|
54
|
+
- Per-Session export locks carry owner tokens and are renewed only during a caller-driven export. Renewal and release reject stale owners; expired locks support crash takeover and old schemas migrate under a write transaction.
|
|
54
55
|
|
|
55
56
|
## 0.9 — whole-Session deletion
|
|
56
57
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Purpose: preserve the accepted direction and remaining decision boundaries without duplicating nika's product roadmap.
|
|
4
4
|
|
|
5
|
-
Current entry: **0.
|
|
5
|
+
Current entry: **0.9.0 reentrant Session deletion and release closure**. The executable implementation plan is [development-plan.md](development-plan.md).
|
|
6
6
|
|
|
7
7
|
## Fixed guardrails
|
|
8
8
|
|
|
@@ -23,12 +23,12 @@ Current entry: **0.5.0 falsification and integration-contract closure**. The exe
|
|
|
23
23
|
| Execution and ReAct | Turn/Step driver, bounded correction, ordered steer, common finalization | Implemented; normal and terminal behavior covered |
|
|
24
24
|
| Model and Context | Frozen in-memory requests, external Provider configuration, append-only projection, Compaction | Implemented; recorded Adapter contracts and separately identified live smoke |
|
|
25
25
|
| Tool contracts | Admission, parallel/exclusive scheduling, ordered Observations, explicit uncertainty | Implemented; full append and side-effect fault scenarios covered |
|
|
26
|
-
| Durable state | Atomic conditional append, idempotency, writer fencing, crash closers | Implemented
|
|
27
|
-
| Pending Input | Log projection by `input_id` and Step-boundary consumption | Implemented
|
|
28
|
-
| Observability | Committed-event Trace projection with failure isolation | Implemented
|
|
29
|
-
| Schema evolution | Read-only upcasting and versioned real fixtures |
|
|
30
|
-
| Operation identity and approval | Persistent `operation_id`, effect declarations, approved new-Turn resume |
|
|
31
|
-
| Retention | Reentrant whole-Session deletion with tombstones |
|
|
26
|
+
| Durable state | Atomic conditional append, idempotency, writer fencing, crash closers | Implemented with optional same-host timed leases; distributed coordination is not claimed |
|
|
27
|
+
| Pending Input | Log projection by `input_id` and Step-boundary consumption | Implemented with structured steer_result rejection reasons |
|
|
28
|
+
| Observability | Committed-event Trace projection with failure isolation | Implemented with caller-driven durable Outbox, acknowledgement cursors, and export gaps |
|
|
29
|
+
| Schema evolution | Read-only upcasting and versioned real fixtures | Implemented for Event schema 1.0→1.1 |
|
|
30
|
+
| Operation identity and approval | Persistent `operation_id`, effect declarations, approved new-Turn resume | Implemented with explicit reconciliation and approval recovery evidence |
|
|
31
|
+
| Retention | Reentrant whole-Session deletion with tombstones | Implemented for local Event/Trace/Outbox state; third-party copies and external assets excluded |
|
|
32
32
|
| Consumer integration | Public versioned Adapters; nika is a consumer, not a dependency | Separate acceptance |
|
|
33
33
|
| Release | Python 3.11–3.14, frozen imports, fault matrix, benchmark, official API gates | 0.5 verifies engineering; official OpenAI/Anthropic acceptance blocks 1.0 |
|
|
34
34
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Purpose: distinguish implemented capabilities from remaining work. Executable evidence is owned by the [verification matrix](../design/verification-matrix.md).
|
|
4
4
|
|
|
5
|
-
## Implemented in the current 0.
|
|
5
|
+
## Implemented in the current 0.9 line
|
|
6
6
|
|
|
7
7
|
| Feature | Implementation | Evidence |
|
|
8
8
|
|---|---|---|
|
|
@@ -19,6 +19,8 @@ Purpose: distinguish implemented capabilities from remaining work. Executable ev
|
|
|
19
19
|
| Approval | Atomic Intent/request, new-Turn resume, origin pairing, lazy expiry | Zero pre-grant dispatch, crash windows, concurrent resume, rejection, cancellation, and fresh budgets |
|
|
20
20
|
| Providers | OpenAI-compatible and Anthropic streaming adapters | Recorded protocol streams plus separately identified live-provider smoke |
|
|
21
21
|
| Observability | Model/Tool/Turn Trace DTOs, async Exporters, history | Live/history parity, failure isolation, bounded close, and 10k incremental parity |
|
|
22
|
+
| Durable Outbox | Caller-driven replay, persistent cursor/attempts/gaps, owner-token locks and heartbeat | Ack/crash windows, retry exhaustion, lock ownership/timeout/migration, closed-Turn filtering, and no resurrection after deletion |
|
|
23
|
+
| Session deletion | Reentrant deleting/deleted tombstones, writer fencing, local Trace/Outbox cleanup, SQLite byte purge | Crash/interruption windows, stale writers, read snapshots, queue isolation, raw DB/WAL/SHM/journal canaries |
|
|
22
24
|
| Integrations | Harness, directory Skills, stdio workers, MCP stdio | Offline diagnostics, subprocess conformance, lifecycle, and clean-wheel examples |
|
|
23
25
|
| Release contract | Frozen root/module re-exports, Python 3.11–3.14 CI | Import snapshot, complete gates, wheel/sdist, and clean-install checks |
|
|
24
26
|
|
|
@@ -26,8 +28,6 @@ Purpose: distinguish implemented capabilities from remaining work. Executable ev
|
|
|
26
28
|
|
|
27
29
|
| Feature | Target and boundary |
|
|
28
30
|
|---|---|
|
|
29
|
-
| Durable Outbox | 0.8; caller-driven export, persistent acknowledgement, auditable gaps |
|
|
30
|
-
| Whole-Session deletion | 0.9; tombstones and local derived-state cleanup |
|
|
31
31
|
| Official OpenAI/Anthropic acceptance | 1.0 hard gate; recorded streams and DeepSeek do not substitute |
|
|
32
32
|
| nika product integration | Separate consumer acceptance; no Feishu/Wiki dependency enters nextloop |
|
|
33
33
|
| Large external-asset lifecycle | Not claimed; current large Tool Results remain in the EventStore |
|
|
@@ -21,7 +21,7 @@ This map records reusable execution requirements and verification ownership. No
|
|
|
21
21
|
| L15 | Retry delivery without rerunning model or Tools | [DeliveryOwner](../design/loop-interface.md#deliveryowner) | **Design closed.** `final_message_id`, delivery_unknown, durable handoff and writer-release tests |
|
|
22
22
|
| L16 | Prove consumer independence through public Adapters | [Loop interface](../design/loop-interface.md) | **Open.** Fake Adapters and public Store conformance are implemented; nika consumer acceptance remains separate |
|
|
23
23
|
| L18 | Load third-party instruction Skills from directories on demand | [SkillRegistry](../design/skills.md) | **Implemented.** Metadata discovery, current-body loading, duplicate/dependency/version errors, and `skill_view` tests |
|
|
24
|
-
| L17 | Package and release only after protocol verification | [Development plan](development-plan.md), [ADR-0003](../adr/0003-python-and-centralized-contracts.md) | **0.
|
|
24
|
+
| L17 | Package and release only after protocol verification | [Development plan](development-plan.md), [ADR-0003](../adr/0003-python-and-centralized-contracts.md) | **0.9.0 implemented; release verification in progress.** Fault matrix, benchmark, Python 3.14, import contract, upcasting, operation, approval, owner lease, durable Outbox, whole-Session deletion, and package gates are required; publication and the 1.0 gates remain separate |
|
|
25
25
|
|
|
26
26
|
## Independence rule
|
|
27
27
|
|
|
@@ -32,7 +32,7 @@ The Loop coordinates execution; the Store owns ordering and writer fencing. `eve
|
|
|
32
32
|
- Pending Input is derived from INPUT_ACCEPTED and USER_MESSAGE by `input_id`. A later Step boundary commits its consumption; the in-memory inbox is only a wake-up signal.
|
|
33
33
|
- Trace records are projections of committed Events. Export failures cannot change Turn outcomes.
|
|
34
34
|
|
|
35
|
-
Owner leases are optional. Same-owner restarts take over immediately; different owners require expiry or explicit force. Heartbeat renewal is independent of appends, and the Store clock decides expiry. SQLite promises same-host multi-process contention only, not distributed coordination.
|
|
35
|
+
Owner leases are optional. Same-owner restarts take over immediately; different owners require expiry or explicit force. Heartbeat renewal is independent of appends, and the Store clock decides expiry. SQLite promises same-host multi-process contention only, not distributed coordination. Durable Trace export is implemented by the caller-driven `SQLiteOutbox`. Reentrant whole-Session deletion uses fail-closed tombstones, local Trace/Outbox cleanup, and SQLite byte purging; third-party exports and external assets remain outside that guarantee.
|
|
36
36
|
|
|
37
37
|
## Complexity boundaries
|
|
38
38
|
|
|
@@ -50,7 +50,7 @@ The benchmark checks Memory/SQLite Conversation Projection parity, Model/Tool Tr
|
|
|
50
50
|
|
|
51
51
|
## Frozen import contract
|
|
52
52
|
|
|
53
|
-
The root `nextloop` package keeps its existing convenience re-exports. `tests/test_import_contract.py` snapshots all
|
|
53
|
+
The root `nextloop` package keeps its existing convenience re-exports. `tests/test_import_contract.py` snapshots all 101 names and rejects accidental additions, removals, and duplicate entries.
|
|
54
54
|
|
|
55
55
|
Core integration paths:
|
|
56
56
|
|
|
@@ -145,6 +145,20 @@ history = await harness.history(from_turn=1, to_turn=10)
|
|
|
145
145
|
|
|
146
146
|
History reads the complete EventStore log and uses the same TraceProjector as live export. Only new-format Events are supported; missing measured Model/Tool fields produce `timing_source="unknown"`, not estimated durations.
|
|
147
147
|
|
|
148
|
+
### Durable Outbox
|
|
149
|
+
|
|
150
|
+
The live queue is best-effort. For replay after process restart, construct `SQLiteOutbox(store, path, exporters)` and call `await outbox.export_pending()` from the application. Passing a `session_id` restricts one run; omitting it enumerates `store.session_ids()`. Only Turns with a committed `TURN_END` are exported.
|
|
151
|
+
|
|
152
|
+
Each successful Exporter return advances an independent durable cursor. A crash before that commit can replay; a crash after it cannot. Failed calls persist attempts and become auditable `ExportGap` records at `max_attempts`, allowing later records to proceed. `watermark()`, `gaps()`, and `delete_session()` inspect or clear Outbox-owned state without consuming writer epochs or deleting Events.
|
|
153
|
+
|
|
154
|
+
Concurrent exporters use per-Session owner-token locks. A heartbeat renews only during `export_pending()` at one-third of `lock_timeout_seconds`; stale locks can be reclaimed after a crash. `export_timeout_seconds` bounds cooperative calls, but a timed-out synchronous Exporter thread can still produce late side effects. An asynchronous Exporter that suppresses cancellation can delay cleanup and must be made cancellation-aware by the caller. Neither case is a successful acknowledgement or hard isolation of user code. Delivery is therefore at least once, not exactly once, and exporters should deduplicate using the stable OTel `trace_id` and `span_id` emitted by `StdoutExporter`.
|
|
155
|
+
|
|
156
|
+
### Whole-Session deletion
|
|
157
|
+
|
|
158
|
+
Call `await store.delete_session(session_id)` for Event state and `outbox.delete_session(session_id)` for its separately owned export state. Both are idempotent; repeat both after interruption. EventStore deletion leaves only a deleting/deleted Session-ID tombstone and rejects subsequent reads, writes, and writer ownership operations with `SessionDeletedError`.
|
|
159
|
+
|
|
160
|
+
ObservingEventStore also clears projected and queued Trace records without blocking normal Turns on slow Exporters. Outbox write transactions verify their owner token so an in-flight export cannot recreate deleted state. SQLite uses `secure_delete`, WAL checkpoints, and VACUUM for local byte cleanup. Physical cleanup errors are explicit and safe to retry; already dispatched external effects, caller-owned copies, third-party exports, backups, and external assets are outside the deletion guarantee.
|
|
161
|
+
|
|
148
162
|
## MCP stdio
|
|
149
163
|
|
|
150
164
|
`driver = "mcp"` starts a standard MCP `2025-06-18` stdio server. The adapter performs initialize, the initialized notification, and paginated `tools/list` until the cursor is exhausted, then keeps a static catalog for the process lifetime. Remote annotations do not grant parallel execution, resources, or approval privileges.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Loop interface and ownership
|
|
2
2
|
|
|
3
|
-
Status: **v1.1 implemented for 0.
|
|
3
|
+
Status: **v1.1 implemented for 0.9.0**, with public contracts in `src/nextloop/contracts.py`.
|
|
4
4
|
|
|
5
5
|
## Independence and version dependency
|
|
6
6
|
|
|
@@ -40,16 +40,20 @@ Context assembly and Compaction are built-in mechanisms configured through `Loop
|
|
|
40
40
|
|
|
41
41
|
### 1. EventStore
|
|
42
42
|
|
|
43
|
+
- `session_ids() -> Sequence[str]` — stable enumeration of non-tombstoned Sessions with committed Events for caller-driven Outbox export.
|
|
44
|
+
- `delete_session(session_id) -> None` — idempotently fences the Session and removes its local Event state; tombstoned reads and writes raise `SessionDeletedError`.
|
|
43
45
|
- `attach_writer(session_id) -> (writer_epoch, last_seq, last_turn)`
|
|
44
46
|
- `check_writer(session_id, writer_epoch) -> None` — rejects a stale writer immediately before Tool dispatch.
|
|
45
47
|
- `append(session_id, writer_epoch, expected_seq, events) -> Sequence[Event]` — validates epoch/seq and inserts atomically; identical retries are idempotent.
|
|
46
48
|
- `load_surface(session_id) -> Sequence[Event]` — returns model-visible Events from the latest `SurfaceOp.EPOCH` watermark plus INPUT_ACCEPTED and protocol correction facts.
|
|
47
49
|
- `load_recovery(session_id) -> Sequence[Event]` — full ordered history for deterministic crash repair and Pending projection.
|
|
48
50
|
|
|
49
|
-
Third-party implementations must pass `nextloop.testing.check_event_store()`.
|
|
51
|
+
Third-party implementations must pass `nextloop.testing.check_event_store()`. Writer epochs alone are not time-based leases. Optional `owner_id` and `lease_seconds` add same-host owner/expiry checks, heartbeat renewal, and takeover; they do not provide distributed coordination. Decorators must delegate `session_ids()` so caller-driven Outbox export can enumerate committed Sessions and `delete_session()` so retention cannot bypass tombstones or derived-state cleanup.
|
|
50
52
|
|
|
51
53
|
**Migration from 0.5.0rc2 and earlier:** every EventStore implementation must add `check_writer(session_id, writer_epoch)`. It must read the currently committed epoch and raise `InvariantViolation("Stale writer_epoch")` when the supplied epoch is not current. Decorators must delegate this check to their wrapped Store. No default no-op is provided because it would reopen the post-TOOL_CALL stale-dispatch window.
|
|
52
54
|
|
|
55
|
+
**Migration from 0.8:** every EventStore implementation must add idempotent `delete_session(session_id)`, with fail-closed tombstones for reads and writer operations. Decorators must delegate deletion and clear their own derived Session state. Built-in SQLite Stores create tombstone schema lazily on first deletion, so opening historical fixtures for read-only upcasting does not rewrite their bytes. Whole-Session retention must also call `SQLiteOutbox.delete_session()`; no cross-database transaction is implied.
|
|
56
|
+
|
|
53
57
|
Initial input and explicit steer IDs must be non-empty. Reusing an ID with identical content is an idempotent retry; reusing it with different content raises `InvariantViolation` before a new INPUT_ACCEPTED is committed, preserving the original Pending input.
|
|
54
58
|
|
|
55
59
|
### 2. ModelProvider
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# AgentLoop verification matrix
|
|
2
2
|
|
|
3
|
-
Status: 0.
|
|
3
|
+
Status: 0.9.0 release gate. A claim is closed only by the executable evidence named here; test count alone is not evidence.
|
|
4
4
|
|
|
5
5
|
## Evidence rules
|
|
6
6
|
|
|
@@ -117,10 +117,39 @@ The 0.6 review closed non-boolean grants, lock-delay expiry, duplicate dispatch,
|
|
|
117
117
|
| Idempotent input is not capacity-rejected | Accepted ID replay precedes queue_full checks; non-writers never append facts |
|
|
118
118
|
| Lease cancellation is writer-scoped | Active stale writers and inactive non-owners are rejected before cancellation append |
|
|
119
119
|
|
|
120
|
+
## 0.8 durable Outbox evidence
|
|
121
|
+
|
|
122
|
+
| Claim | Closing evidence |
|
|
123
|
+
|---|---|
|
|
124
|
+
| Only committed closed Turns export | Active Turns are excluded; closed earlier Turns replay without `recover()` |
|
|
125
|
+
| Ack and cursor have distinct crash windows | Ack-before-cursor replays identical content and identity; post-cursor crash does not replay |
|
|
126
|
+
| Export failures cannot block forever | Persistent attempts, immediate `max_attempts` gap recording, cursor advance, and later-Session continuation |
|
|
127
|
+
| Replay identity is OTel-compatible | Deterministic 32-hex Trace IDs and unique 16-hex Span IDs across replay |
|
|
128
|
+
| Export locks exclude concurrent owners | Async and same-instance serialization, monotonic cursor, bounded acquisition with original IntegrityError cause |
|
|
129
|
+
| Long calls retain ownership | Heartbeat renewal across `lock_timeout_seconds`, with no premature duplicate export |
|
|
130
|
+
| Lock cleanup and takeover are owner-scoped | Old-owner release cannot delete a new lock; failed renewal cannot advance cursor and still releases an owned lock |
|
|
131
|
+
| Existing Outbox state migrates safely | Missing owner-token column is added once under concurrent initialization |
|
|
132
|
+
| Session cleanup is bounded to Outbox state | Cursor, attempts, gaps, and locks are removed without deleting Events or changing writer epochs |
|
|
133
|
+
| Approval waiting is not Tool execution | Tool duration excludes approval delay; Turn duration remains separate |
|
|
134
|
+
|
|
135
|
+
## 0.9 whole-Session deletion evidence
|
|
136
|
+
|
|
137
|
+
| Claim | Closing evidence |
|
|
138
|
+
|---|---|
|
|
139
|
+
| Deletion is reentrant and cannot recreate a Session | Memory/SQLite repeated deletion, persistent deleting/deleted tombstones, attach/append/writer rejection |
|
|
140
|
+
| Tombstoned reads fail closed | Surface/recovery/renew/has_writer rejection and reopen; consistent read snapshots never turn deleted history into a valid empty Session |
|
|
141
|
+
| Unrelated Sessions survive | A retained Session remains readable and enumerable after another Session is deleted |
|
|
142
|
+
| Local derived data is removed | TraceProjector state, queued live records, Outbox cursor/attempts/gaps/locks, Events, Compaction, and writer/lease state |
|
|
143
|
+
| Old exports cannot resurrect Outbox state | Success, retry, and max-attempt exporters paused across deletion; transactional owner checks leave all four tables empty |
|
|
144
|
+
| SQLite content bytes are purged | Synthetic Event/Compaction/Outbox canaries absent from DB, WAL, SHM, and rollback-journal scans in WAL and DELETE modes |
|
|
145
|
+
| Cleanup crashes remain resumable | Post-logical-delete crash persists deleted tombstone and a later call completes byte cleanup |
|
|
146
|
+
| Historical fixtures remain read-only | Real 1.0/1.1 SQLite fixture bytes remain unchanged; tombstone schema is created lazily on deletion |
|
|
147
|
+
| Live export does not block the Loop | Existing slow-Exporter and bounded-close regressions plus deletion-specific activity/export lock coverage |
|
|
148
|
+
|
|
120
149
|
## Review and external evidence
|
|
121
150
|
|
|
122
151
|
Standards, Spec, and Risk reviews run independently. Original counterexamples must become regressions, and fixes receive incremental review. The 0.5.0 review closed stale dispatch, Pending consumption, ID conflicts, Compaction identity, export-contract gaps, wrapper duplication, and erased-content test oracles.
|
|
123
152
|
|
|
124
153
|
Recorded OpenAI and Anthropic SSE scenarios are Adapter evidence, not official API acceptance. Twelve live Kimi scenarios and live DeepSeek text/Preview/usage and Tool/Delivery smoke are separately identified. Official OpenAI and Anthropic API acceptance remains a **1.0 hard gate**.
|
|
125
154
|
|
|
126
|
-
Current non-guarantees:
|
|
155
|
+
Current non-guarantees: distributed writer coordination, exactly-once export, deletion of third-party copies or backups, remote MCP/OAuth, event-level erasure, and external large-asset lifecycle.
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "nextloop"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.9.0"
|
|
8
8
|
description = "An embeddable AgentLoop with explicit event, tool, recovery, and delivery semantics"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.11"
|
|
@@ -2,6 +2,7 @@ from .adapters.anthropic import AnthropicProvider
|
|
|
2
2
|
from .adapters.memory import InMemoryEventStore
|
|
3
3
|
from .adapters.observing import ObservingEventStore, StdoutExporter
|
|
4
4
|
from .adapters.openai import OpenAIProvider
|
|
5
|
+
from .adapters.outbox import SQLiteOutbox
|
|
5
6
|
from .adapters.sqlite import SQLiteEventStore
|
|
6
7
|
from .contracts import (
|
|
7
8
|
API_VERSION,
|
|
@@ -18,6 +19,8 @@ from .contracts import (
|
|
|
18
19
|
Event,
|
|
19
20
|
EventStore,
|
|
20
21
|
EventType,
|
|
22
|
+
ExportGap,
|
|
23
|
+
ExportReport,
|
|
21
24
|
FinalMessage,
|
|
22
25
|
FinishReason,
|
|
23
26
|
HarnessError,
|
|
@@ -42,6 +45,7 @@ from .contracts import (
|
|
|
42
45
|
ProviderConfig,
|
|
43
46
|
ProviderError,
|
|
44
47
|
RecoveryOutcome,
|
|
48
|
+
SessionDeletedError,
|
|
45
49
|
SkillConfig,
|
|
46
50
|
SkillDocument,
|
|
47
51
|
SkillError,
|
|
@@ -110,6 +114,8 @@ __all__ = [
|
|
|
110
114
|
"Event",
|
|
111
115
|
"EventStore",
|
|
112
116
|
"EventType",
|
|
117
|
+
"ExportGap",
|
|
118
|
+
"ExportReport",
|
|
113
119
|
"FinalMessage",
|
|
114
120
|
"FinishReason",
|
|
115
121
|
"Harness",
|
|
@@ -141,6 +147,8 @@ __all__ = [
|
|
|
141
147
|
"ProviderError",
|
|
142
148
|
"RecoveryOutcome",
|
|
143
149
|
"SQLiteEventStore",
|
|
150
|
+
"SQLiteOutbox",
|
|
151
|
+
"SessionDeletedError",
|
|
144
152
|
"SkillConfig",
|
|
145
153
|
"SkillDocument",
|
|
146
154
|
"SkillError",
|
|
@@ -2,6 +2,7 @@ from .anthropic import AnthropicProvider
|
|
|
2
2
|
from .memory import InMemoryEventStore
|
|
3
3
|
from .observing import ObservingEventStore, StdoutExporter
|
|
4
4
|
from .openai import OpenAIProvider
|
|
5
|
+
from .outbox import SQLiteOutbox
|
|
5
6
|
from .sqlite import SQLiteEventStore
|
|
6
7
|
|
|
7
8
|
__all__ = [
|
|
@@ -10,5 +11,6 @@ __all__ = [
|
|
|
10
11
|
"ObservingEventStore",
|
|
11
12
|
"OpenAIProvider",
|
|
12
13
|
"SQLiteEventStore",
|
|
14
|
+
"SQLiteOutbox",
|
|
13
15
|
"StdoutExporter",
|
|
14
16
|
]
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import sqlite3
|
|
4
|
+
import time
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def execute_with_busy_retry(connection: sqlite3.Connection, statement: str) -> None:
|
|
8
|
+
deadline = time.monotonic() + 5.0
|
|
9
|
+
while True:
|
|
10
|
+
try:
|
|
11
|
+
connection.execute(statement)
|
|
12
|
+
return
|
|
13
|
+
except sqlite3.OperationalError as exc:
|
|
14
|
+
message = str(exc).lower()
|
|
15
|
+
if "locked" not in message and "busy" not in message:
|
|
16
|
+
raise
|
|
17
|
+
if time.monotonic() >= deadline:
|
|
18
|
+
raise
|
|
19
|
+
time.sleep(0.01)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def purge_deleted_bytes(connection: sqlite3.Connection) -> None:
|
|
23
|
+
_checkpoint(connection)
|
|
24
|
+
connection.execute("VACUUM")
|
|
25
|
+
_checkpoint(connection)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def _checkpoint(connection: sqlite3.Connection) -> None:
|
|
29
|
+
row = connection.execute("PRAGMA wal_checkpoint(TRUNCATE)").fetchone()
|
|
30
|
+
if row is not None and int(row[0]) != 0:
|
|
31
|
+
raise sqlite3.OperationalError("SQLite WAL checkpoint is busy")
|