nextloop 0.6.0__tar.gz → 0.8.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.6.0/src/nextloop.egg-info → nextloop-0.8.0}/PKG-INFO +25 -11
- {nextloop-0.6.0 → nextloop-0.8.0}/README.md +24 -10
- nextloop-0.8.0/docs/adr/0008-lease.md +24 -0
- nextloop-0.8.0/docs/adr/0009-outbox.md +30 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/docs/architecture/development-plan.md +2 -1
- {nextloop-0.6.0 → nextloop-0.8.0}/docs/architecture/discussion-roadmap.md +6 -6
- {nextloop-0.6.0 → nextloop-0.8.0}/docs/architecture/feature-worklist.md +3 -3
- {nextloop-0.6.0 → nextloop-0.8.0}/docs/architecture/requirements.md +1 -1
- {nextloop-0.6.0 → nextloop-0.8.0}/docs/design/architecture.md +3 -3
- {nextloop-0.6.0 → nextloop-0.8.0}/docs/design/harness.md +14 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/docs/design/loop-interface.md +5 -3
- {nextloop-0.6.0 → nextloop-0.8.0}/docs/design/verification-matrix.md +35 -3
- {nextloop-0.6.0 → nextloop-0.8.0}/pyproject.toml +1 -1
- {nextloop-0.6.0 → nextloop-0.8.0}/src/nextloop/__init__.py +12 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/src/nextloop/adapters/__init__.py +2 -0
- nextloop-0.8.0/src/nextloop/adapters/_sqlite.py +19 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/src/nextloop/adapters/memory.py +78 -7
- {nextloop-0.6.0 → nextloop-0.8.0}/src/nextloop/adapters/observing.py +18 -2
- nextloop-0.8.0/src/nextloop/adapters/outbox.py +300 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/src/nextloop/adapters/sqlite.py +128 -16
- {nextloop-0.6.0 → nextloop-0.8.0}/src/nextloop/contracts.py +46 -2
- {nextloop-0.6.0 → nextloop-0.8.0}/src/nextloop/driver.py +1 -0
- nextloop-0.8.0/src/nextloop/events/trace_ids.py +28 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/src/nextloop/harness.py +13 -5
- {nextloop-0.6.0 → nextloop-0.8.0}/src/nextloop/loop.py +90 -29
- {nextloop-0.6.0 → nextloop-0.8.0}/src/nextloop/testing.py +15 -2
- {nextloop-0.6.0 → nextloop-0.8.0/src/nextloop.egg-info}/PKG-INFO +25 -11
- {nextloop-0.6.0 → nextloop-0.8.0}/src/nextloop.egg-info/SOURCES.txt +8 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/tests/test_approval.py +3 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/tests/test_harness.py +14 -1
- {nextloop-0.6.0 → nextloop-0.8.0}/tests/test_import_contract.py +7 -0
- nextloop-0.8.0/tests/test_lease.py +461 -0
- nextloop-0.8.0/tests/test_outbox.py +137 -0
- nextloop-0.8.0/tests/test_outbox_regressions.py +344 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/tests/test_skills.py +1 -1
- {nextloop-0.6.0 → nextloop-0.8.0}/LICENSE +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/MANIFEST.in +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/docs/adr/0001-embeddable-agent-loop.md +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/docs/adr/0002-dsh-aligned-agent-loop.md +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/docs/adr/0003-python-and-centralized-contracts.md +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/docs/adr/0004-event-compatibility.md +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/docs/adr/0005-pending-input.md +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/docs/adr/0006-operation-id.md +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/docs/adr/0007-approval.md +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/docs/architecture/agent-loop-capability-review.md +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/docs/design/agent-loop.md +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/docs/design/context-builder.md +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/docs/design/react-protocol.md +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/docs/design/skills.md +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/docs/research/2026-11-02-dsh-primary-sources.md +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/docs/research/2026-11-02-loop-evidence-notes.md +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/docs/research/2026-11-03-hermes-turn-control.md +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/docs/research/2026-11-03-tool-batch-failures.md +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/docs/research/2026-11-03-tool-call-validation.md +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/docs/research/2026-11-03-yomi-turn-control.md +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/docs/research/2026-11-06-open-source-agent-loops.md +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/docs/research/2026-11-06-react-tool-event-recovery.md +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/docs/research/2026-11-10-nextloop-optimization-review.md +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/examples/basic.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/examples/harness-skills/echo/SKILL.md +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/examples/harness.toml +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/examples/live_smoke.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/examples/python_tools.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/examples/skills/coding/SKILL.md +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/examples/skills_demo.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/examples/workers/cpp_worker.cpp +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/examples/workers/python_worker.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/examples/workers/rust_worker.rs +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/setup.cfg +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/src/nextloop/adapters/_sse.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/src/nextloop/adapters/anthropic.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/src/nextloop/adapters/openai.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/src/nextloop/cli.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/src/nextloop/events/__init__.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/src/nextloop/events/approval.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/src/nextloop/events/input.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/src/nextloop/events/outcome.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/src/nextloop/events/pending.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/src/nextloop/events/project.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/src/nextloop/events/repair.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/src/nextloop/events/response.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/src/nextloop/events/trace.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/src/nextloop/events/upcast.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/src/nextloop/execute/__init__.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/src/nextloop/execute/batch.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/src/nextloop/execute/cancellation.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/src/nextloop/execute/cleanup.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/src/nextloop/execute/composite.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/src/nextloop/execute/mcp.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/src/nextloop/execute/model.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/src/nextloop/execute/preview.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/src/nextloop/execute/result_read.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/src/nextloop/execute/stdio.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/src/nextloop/execute/stdio_transport.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/src/nextloop/execute/tools.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/src/nextloop/py.typed +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/src/nextloop/skills.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/src/nextloop.egg-info/dependency_links.txt +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/src/nextloop.egg-info/entry_points.txt +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/src/nextloop.egg-info/requires.txt +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/src/nextloop.egg-info/top_level.txt +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/tests/test_aggregate_close.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/tests/test_approval_regressions.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/tests/test_budgets.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/tests/test_cli.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/tests/test_compaction_lineage.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/tests/test_complexity_regressions.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/tests/test_correctness_regressions.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/tests/test_events.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/tests/test_failures.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/tests/test_fault_injection.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/tests/test_fault_matrix.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/tests/test_harness_injection.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/tests/test_loop.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/tests/test_mcp.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/tests/test_mcp_hardening.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/tests/test_observability.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/tests/test_observability_close_deadline.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/tests/test_operations.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/tests/test_pending_inputs.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/tests/test_preview.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/tests/test_projection_parity.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/tests/test_provider_terminal.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/tests/test_providers.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/tests/test_result_budget_regressions.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/tests/test_result_policies.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/tests/test_retry_regressions.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/tests/test_review_regressions.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/tests/test_stdio.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/tests/test_stdio_cleanup.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/tests/test_stdio_frames.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/tests/test_stdio_safety.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/tests/test_store_contract.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/tests/test_stores.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/tests/test_surface_snapshot.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.0}/tests/test_upcasting.py +0 -0
- {nextloop-0.6.0 → nextloop-0.8.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.8.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.8.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.8.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.
|
|
@@ -86,8 +86,9 @@ It is a library, not an HTTP service, product bot, Router, EventBus, or multi-ag
|
|
|
86
86
|
```python
|
|
87
87
|
AgentLoop.run(TurnContext) -> TurnOutcome
|
|
88
88
|
AgentLoop.steer(session_id, content, *, input_id=None) -> bool
|
|
89
|
+
AgentLoop.steer_result(session_id, content, *, input_id=None) -> SteerResult
|
|
89
90
|
AgentLoop.cancel(session_id, cause="user_stop") -> bool
|
|
90
|
-
AgentLoop.recover(session_id, store, delivery) -> RecoveryOutcome
|
|
91
|
+
AgentLoop.recover(session_id, store, delivery, *, force=False) -> RecoveryOutcome
|
|
91
92
|
AgentLoop.pending_inputs(session_id, store) -> tuple[PendingInput, ...]
|
|
92
93
|
AgentLoop.resume(context, *, decisions=None, reject_all=False, new_input=None) -> TurnOutcome
|
|
93
94
|
AgentLoop.retry_operation(context, operation_id) -> TurnOutcome
|
|
@@ -101,7 +102,8 @@ Core adapter seams are `EventStore`, `ModelProvider`, `ToolRuntime`, and `Delive
|
|
|
101
102
|
|
|
102
103
|
| Area | Guarantee | Not a guarantee |
|
|
103
104
|
|---|---|---|
|
|
104
|
-
| Accepted input | Accepted inputs are projected from the log by `input_id` and can be queried with `AgentLoop.pending_inputs`. Explicit IDs are non-empty; identical retries deduplicate, conflicting content is rejected without consuming the original. | Automatic deduplication when callers retry with a different or missing ID. |
|
|
105
|
+
| Accepted input | Accepted inputs are projected from the log by `input_id` and can be queried with `AgentLoop.pending_inputs`. Explicit IDs are non-empty; identical retries deduplicate, conflicting content is rejected without consuming the original. `steer_result` exposes structured rejection reasons. | Automatic deduplication when callers retry with a different or missing ID. |
|
|
106
|
+
| Writer lease | Optional owner/epoch/expiry checks with heartbeat, same-owner restart, expiry or forced takeover, and spawn-verified same-host contention. Legacy behavior remains when no owner is configured. | Distributed locks, cross-host leases, or execution after an expired/stale writer check. |
|
|
105
107
|
| Delivery | Delivery is at least once; DeliveryOwner must deduplicate by stable `final_message_id`. | Exactly-once delivery or delivery without an idempotent owner. |
|
|
106
108
|
| Tool execution | The library never automatically replays an already dispatched Tool. Explicit reconciliation is limited to READ_ONLY and IDEMPOTENT operations. | No duplicate external effect when a model reissues a call or a Tool is not idempotent. |
|
|
107
109
|
| Resource locks | Unresolved uncertain results retain declared resources; otherwise NON_IDEMPOTENT uses the Tool name. Successful reconciliation releases all locks associated with the operation. | Global idempotency across different resources or operations, or safe concurrent execution of NON_IDEMPOTENT calls. |
|
|
@@ -109,7 +111,7 @@ Core adapter seams are `EventStore`, `ModelProvider`, `ToolRuntime`, and `Delive
|
|
|
109
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. |
|
|
110
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. |
|
|
111
113
|
| Preview | Preview is transient and cannot execute partial Tool arguments. | Preview as a durable EventStore fact or a substitute for committed Delivery. |
|
|
112
|
-
| 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. |
|
|
113
115
|
| MCP | stdio lifecycle, paginated static catalogs, operation metadata, and uncertain crash handling. | Remote MCP, OAuth, dynamic `listChanged`, or non-text content mapping. |
|
|
114
116
|
|
|
115
117
|
`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.
|
|
@@ -164,6 +166,17 @@ history = await harness.history(from_turn=1, to_turn=10)
|
|
|
164
166
|
|
|
165
167
|
History works with memory and SQLite Stores even when no Exporter is configured.
|
|
166
168
|
|
|
169
|
+
For replay that survives process restart, drive a durable Outbox from your application:
|
|
170
|
+
|
|
171
|
+
```python
|
|
172
|
+
outbox = SQLiteOutbox(store, "outbox.sqlite3", [my_exporter], max_attempts=3)
|
|
173
|
+
report = await outbox.export_pending() # all Sessions; pass session_id to select one
|
|
174
|
+
print(report.exported, outbox.gaps())
|
|
175
|
+
outbox.close()
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
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.
|
|
179
|
+
|
|
167
180
|
`ToolRegistry` is the built-in `ToolRuntime` implementation:
|
|
168
181
|
|
|
169
182
|
```python
|
|
@@ -230,14 +243,15 @@ The release checks cover:
|
|
|
230
243
|
- recorded OpenAI and Anthropic SSE streams;
|
|
231
244
|
- 12 live Kimi scenarios across both protocols, real Tool usage, parallel execution, recovery, steer, cancellation, Compaction, and WorkingContext;
|
|
232
245
|
- live DeepSeek text + Preview + usage and real Tool Call + Delivery smoke;
|
|
246
|
+
- durable Outbox ack/crash windows, replay identity, bounded retries/gaps, lock heartbeat/takeover, and concurrent schema migration;
|
|
233
247
|
- a 10,505-event benchmark with cross-Store, incremental, and required-content parity;
|
|
234
|
-
-
|
|
248
|
+
- 373 offline tests, `ruff`, `mypy`, wheel/sdist builds, `twine check`, and clean wheel installation.
|
|
235
249
|
|
|
236
250
|
Current limits:
|
|
237
251
|
|
|
238
252
|
- nika integration is separate acceptance work.
|
|
239
|
-
-
|
|
240
|
-
- Large-asset lifecycle, backup, and GC are not part of this release.
|
|
253
|
+
- Writer leases coordinate same-host processes only; distributed locks and exactly-once export are not provided.
|
|
254
|
+
- Large-asset lifecycle, backup, Session deletion, and GC are not part of this release.
|
|
241
255
|
- Official OpenAI and Anthropic API acceptance remains a 1.0 hard gate; recorded streams and DeepSeek do not substitute for it.
|
|
242
256
|
|
|
243
257
|
## Documents
|
|
@@ -253,7 +267,7 @@ Current limits:
|
|
|
253
267
|
- [Development plan](docs/architecture/development-plan.md)
|
|
254
268
|
- [Contributing](CONTRIBUTING.md) and [Security](SECURITY.md)
|
|
255
269
|
- [Changelog](CHANGELOG.md)
|
|
256
|
-
- [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),
|
|
270
|
+
- [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), and [ADR-0009 Durable Outbox](docs/adr/0009-outbox.md)
|
|
257
271
|
|
|
258
272
|
## Release
|
|
259
273
|
|
|
@@ -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.8.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.8.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.
|
|
@@ -57,8 +57,9 @@ It is a library, not an HTTP service, product bot, Router, EventBus, or multi-ag
|
|
|
57
57
|
```python
|
|
58
58
|
AgentLoop.run(TurnContext) -> TurnOutcome
|
|
59
59
|
AgentLoop.steer(session_id, content, *, input_id=None) -> bool
|
|
60
|
+
AgentLoop.steer_result(session_id, content, *, input_id=None) -> SteerResult
|
|
60
61
|
AgentLoop.cancel(session_id, cause="user_stop") -> bool
|
|
61
|
-
AgentLoop.recover(session_id, store, delivery) -> RecoveryOutcome
|
|
62
|
+
AgentLoop.recover(session_id, store, delivery, *, force=False) -> RecoveryOutcome
|
|
62
63
|
AgentLoop.pending_inputs(session_id, store) -> tuple[PendingInput, ...]
|
|
63
64
|
AgentLoop.resume(context, *, decisions=None, reject_all=False, new_input=None) -> TurnOutcome
|
|
64
65
|
AgentLoop.retry_operation(context, operation_id) -> TurnOutcome
|
|
@@ -72,7 +73,8 @@ Core adapter seams are `EventStore`, `ModelProvider`, `ToolRuntime`, and `Delive
|
|
|
72
73
|
|
|
73
74
|
| Area | Guarantee | Not a guarantee |
|
|
74
75
|
|---|---|---|
|
|
75
|
-
| Accepted input | Accepted inputs are projected from the log by `input_id` and can be queried with `AgentLoop.pending_inputs`. Explicit IDs are non-empty; identical retries deduplicate, conflicting content is rejected without consuming the original. | Automatic deduplication when callers retry with a different or missing ID. |
|
|
76
|
+
| Accepted input | Accepted inputs are projected from the log by `input_id` and can be queried with `AgentLoop.pending_inputs`. Explicit IDs are non-empty; identical retries deduplicate, conflicting content is rejected without consuming the original. `steer_result` exposes structured rejection reasons. | Automatic deduplication when callers retry with a different or missing ID. |
|
|
77
|
+
| Writer lease | Optional owner/epoch/expiry checks with heartbeat, same-owner restart, expiry or forced takeover, and spawn-verified same-host contention. Legacy behavior remains when no owner is configured. | Distributed locks, cross-host leases, or execution after an expired/stale writer check. |
|
|
76
78
|
| Delivery | Delivery is at least once; DeliveryOwner must deduplicate by stable `final_message_id`. | Exactly-once delivery or delivery without an idempotent owner. |
|
|
77
79
|
| Tool execution | The library never automatically replays an already dispatched Tool. Explicit reconciliation is limited to READ_ONLY and IDEMPOTENT operations. | No duplicate external effect when a model reissues a call or a Tool is not idempotent. |
|
|
78
80
|
| Resource locks | Unresolved uncertain results retain declared resources; otherwise NON_IDEMPOTENT uses the Tool name. Successful reconciliation releases all locks associated with the operation. | Global idempotency across different resources or operations, or safe concurrent execution of NON_IDEMPOTENT calls. |
|
|
@@ -80,7 +82,7 @@ Core adapter seams are `EventStore`, `ModelProvider`, `ToolRuntime`, and `Delive
|
|
|
80
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. |
|
|
81
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. |
|
|
82
84
|
| Preview | Preview is transient and cannot execute partial Tool arguments. | Preview as a durable EventStore fact or a substitute for committed Delivery. |
|
|
83
|
-
| 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. |
|
|
84
86
|
| MCP | stdio lifecycle, paginated static catalogs, operation metadata, and uncertain crash handling. | Remote MCP, OAuth, dynamic `listChanged`, or non-text content mapping. |
|
|
85
87
|
|
|
86
88
|
`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.
|
|
@@ -135,6 +137,17 @@ history = await harness.history(from_turn=1, to_turn=10)
|
|
|
135
137
|
|
|
136
138
|
History works with memory and SQLite Stores even when no Exporter is configured.
|
|
137
139
|
|
|
140
|
+
For replay that survives process restart, drive a durable Outbox from your application:
|
|
141
|
+
|
|
142
|
+
```python
|
|
143
|
+
outbox = SQLiteOutbox(store, "outbox.sqlite3", [my_exporter], max_attempts=3)
|
|
144
|
+
report = await outbox.export_pending() # all Sessions; pass session_id to select one
|
|
145
|
+
print(report.exported, outbox.gaps())
|
|
146
|
+
outbox.close()
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
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.
|
|
150
|
+
|
|
138
151
|
`ToolRegistry` is the built-in `ToolRuntime` implementation:
|
|
139
152
|
|
|
140
153
|
```python
|
|
@@ -201,14 +214,15 @@ The release checks cover:
|
|
|
201
214
|
- recorded OpenAI and Anthropic SSE streams;
|
|
202
215
|
- 12 live Kimi scenarios across both protocols, real Tool usage, parallel execution, recovery, steer, cancellation, Compaction, and WorkingContext;
|
|
203
216
|
- live DeepSeek text + Preview + usage and real Tool Call + Delivery smoke;
|
|
217
|
+
- durable Outbox ack/crash windows, replay identity, bounded retries/gaps, lock heartbeat/takeover, and concurrent schema migration;
|
|
204
218
|
- a 10,505-event benchmark with cross-Store, incremental, and required-content parity;
|
|
205
|
-
-
|
|
219
|
+
- 373 offline tests, `ruff`, `mypy`, wheel/sdist builds, `twine check`, and clean wheel installation.
|
|
206
220
|
|
|
207
221
|
Current limits:
|
|
208
222
|
|
|
209
223
|
- nika integration is separate acceptance work.
|
|
210
|
-
-
|
|
211
|
-
- Large-asset lifecycle, backup, and GC are not part of this release.
|
|
224
|
+
- Writer leases coordinate same-host processes only; distributed locks and exactly-once export are not provided.
|
|
225
|
+
- Large-asset lifecycle, backup, Session deletion, and GC are not part of this release.
|
|
212
226
|
- Official OpenAI and Anthropic API acceptance remains a 1.0 hard gate; recorded streams and DeepSeek do not substitute for it.
|
|
213
227
|
|
|
214
228
|
## Documents
|
|
@@ -224,7 +238,7 @@ Current limits:
|
|
|
224
238
|
- [Development plan](docs/architecture/development-plan.md)
|
|
225
239
|
- [Contributing](CONTRIBUTING.md) and [Security](SECURITY.md)
|
|
226
240
|
- [Changelog](CHANGELOG.md)
|
|
227
|
-
- [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),
|
|
241
|
+
- [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), and [ADR-0009 Durable Outbox](docs/adr/0009-outbox.md)
|
|
228
242
|
|
|
229
243
|
## Release
|
|
230
244
|
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# ADR-0008: Optional owner leases and writer-scoped input
|
|
2
|
+
|
|
3
|
+
Status: accepted
|
|
4
|
+
|
|
5
|
+
## Context
|
|
6
|
+
|
|
7
|
+
Writer epochs reject stale appends but do not express ownership or expiry. A paused process can resume after another instance takes over, and inactive processes currently cannot describe why steer or cancel was rejected. Lease behavior must be optional so existing single-writer deployments do not migrate.
|
|
8
|
+
|
|
9
|
+
## Decision
|
|
10
|
+
|
|
11
|
+
- `owner_id` is opt-in. Without it, `attach_writer` keeps its existing unconditional epoch increment and writer checks keep their existing semantics.
|
|
12
|
+
- Lease-enabled Stores bind `session_id`, `owner_id`, `writer_epoch`, and `expires_at`. The Store clock decides expiry. Same-owner restart may take over immediately; a different owner waits for expiry or explicit `force=True` takeover. Every takeover increments writer_epoch.
|
|
13
|
+
- `check_writer` and append validate owner, epoch, and expiry for lease-enabled Stores. `renew_writer` extends expiry without changing epoch and cannot revive an expired lease.
|
|
14
|
+
- AgentLoop heartbeat renews independently of event appends, including during long Tools. Heartbeat proves only that the process is scheduled; forced takeover remains available for a stuck main loop. SQLite promises same-host, multi-process behavior only, not distributed locking.
|
|
15
|
+
- Every Tool dispatch keeps a writer check after TOOL_CALL. An expired writer fails its next append and cannot dispatch new Tools. A late external result that cannot be committed is discarded and remains uncertain.
|
|
16
|
+
- `steer() -> bool` remains. `steer_result()` additionally returns `accepted`, `session_missing`, `not_writer`, `turn_closed`, `queue_full`, `invalid_input`, or `approval_pending`. Non-writers never append INPUT_ACCEPTED or cancellation facts.
|
|
17
|
+
- Pending Input remains a pure log projection. The in-memory inbox is bounded by `max_pending_inputs`, while Pending remains recoverable from the log after process restart.
|
|
18
|
+
|
|
19
|
+
## Consequences
|
|
20
|
+
|
|
21
|
+
- Existing deployments keep legacy behavior unless they configure an owner and lease duration.
|
|
22
|
+
- Ownership, expiry, renewal, and forced takeover are durable facts rather than process-local assumptions.
|
|
23
|
+
- Callers receive machine-readable input rejection reasons without a second input authority.
|
|
24
|
+
- Multi-process input acceptance is limited to the current valid writer; cross-host lease coordination is explicitly excluded.
|
|
@@ -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; whole-Session Event deletion belongs to the later retention milestone.
|
|
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.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# nextloop development and verification plan
|
|
2
2
|
|
|
3
|
-
Current stage: **0.
|
|
3
|
+
Current stage: **0.8.0 release verification**. `0.7.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.8.0 durable Outbox and release closure**. The executable implementation plan is [development-plan.md](development-plan.md).
|
|
6
6
|
|
|
7
7
|
## Fixed guardrails
|
|
8
8
|
|
|
@@ -23,11 +23,11 @@ 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 |
|
|
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
31
|
| Retention | Reentrant whole-Session deletion with tombstones | 0.9, not currently claimed |
|
|
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 |
|
|
@@ -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.8 line
|
|
6
6
|
|
|
7
7
|
| Feature | Implementation | Evidence |
|
|
8
8
|
|---|---|---|
|
|
@@ -14,10 +14,12 @@ Purpose: distinguish implemented capabilities from remaining work. Executable ev
|
|
|
14
14
|
| Context | Append-only projection, WorkingContext, Compaction, result preview/page/full | Projection parity, compaction, UTF-8 paging, read-back, and capacity tests |
|
|
15
15
|
| EventStore | Memory and SQLite, atomic conditional append, idempotency, writer checks | Public conformance plus deliberately broken Store rejection |
|
|
16
16
|
| Event compatibility | Read-only 1.0→1.1 upcasting, raw append comparison | Real 1.0/1.1 SQLite fixtures and unknown-schema negative paths |
|
|
17
|
+
| Owner leases | Optional owner/epoch/expiry, heartbeat, forced takeover, steer_result | Same/different owner, renewal failure, concurrent resume, late results, and spawn-based multiprocess contention |
|
|
17
18
|
| Operation identity | operation_id, ToolEffect, resource locks, explicit Reconciliation | End-to-end propagation, dynamic locks, repeated/concurrent retry, and no-replay evidence |
|
|
18
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 |
|
|
19
20
|
| Providers | OpenAI-compatible and Anthropic streaming adapters | Recorded protocol streams plus separately identified live-provider smoke |
|
|
20
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, and closed-Turn filtering |
|
|
21
23
|
| Integrations | Harness, directory Skills, stdio workers, MCP stdio | Offline diagnostics, subprocess conformance, lifecycle, and clean-wheel examples |
|
|
22
24
|
| Release contract | Frozen root/module re-exports, Python 3.11–3.14 CI | Import snapshot, complete gates, wheel/sdist, and clean-install checks |
|
|
23
25
|
|
|
@@ -25,8 +27,6 @@ Purpose: distinguish implemented capabilities from remaining work. Executable ev
|
|
|
25
27
|
|
|
26
28
|
| Feature | Target and boundary |
|
|
27
29
|
|---|---|
|
|
28
|
-
| Time-based writer leases | 0.7; opt-in owner identity, heartbeat, expiry, and takeover |
|
|
29
|
-
| Durable Outbox | 0.8; caller-driven export, persistent acknowledgement, auditable gaps |
|
|
30
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 |
|
|
@@ -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.8.0 implemented; release verification in progress.** Fault matrix, benchmark, Python 3.14, import contract, upcasting, operation, approval, owner lease, durable Outbox, and package gates are required; publication and later milestones remain separate |
|
|
25
25
|
|
|
26
26
|
## Independence rule
|
|
27
27
|
|
|
@@ -25,14 +25,14 @@ The Loop coordinates execution; the Store owns ordering and writer fencing. `eve
|
|
|
25
25
|
|
|
26
26
|
## Invariants
|
|
27
27
|
|
|
28
|
-
- Event append checks `writer_epoch` and `expected_seq` atomically.
|
|
28
|
+
- Event append checks `writer_epoch` and `expected_seq` atomically. With an optional owner lease, it also validates owner identity and expiry in the same transaction. Legacy attach behavior is unchanged when no owner is configured.
|
|
29
29
|
- TOOL_CALL is committed before Tool dispatch. A second `check_writer()` runs after that commit and immediately before `ToolRuntime.execute()`.
|
|
30
30
|
- Recovery does not replay a dispatched Tool. Missing results become explicit skipped or uncertain outcomes.
|
|
31
31
|
- FINAL_MESSAGE and TURN_END are durable before Delivery. Delivery is at least once and owners deduplicate by `final_message_id`.
|
|
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
|
-
|
|
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`; Session deletion remains a later milestone.
|
|
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 100 names and rejects accidental additions, removals, and duplicate entries.
|
|
54
54
|
|
|
55
55
|
Core integration paths:
|
|
56
56
|
|
|
@@ -82,6 +82,12 @@ Skills remain instructions only. Their metadata is added to the system prompt, a
|
|
|
82
82
|
|
|
83
83
|
Exporters may optionally implement `flush()` and `close()`, synchronously or asynchronously. The queue is flushed before Exporter lifecycle calls. Harness closes Exporters created from `[trace]`; runtime-injected Exporters are flushed but not closed. `nextloop.testing.check_event_store(store)` exposes the same basic atomicity, idempotency, fencing, surface, and recovery-read contract used by the built-in Stores.
|
|
84
84
|
|
|
85
|
+
## Store leases and Pending limits
|
|
86
|
+
|
|
87
|
+
`[store]` accepts optional `owner_id` and `lease_seconds`. When `owner_id` is absent, Store construction and writer semantics stay legacy. When configured, same-owner restarts take over immediately, another owner needs expiry or `recover(force=True)`, and active Turns renew through an independent heartbeat. SQLite initialization includes bounded lock backoff for same-host process contention.
|
|
88
|
+
|
|
89
|
+
`loop.max_pending_inputs` bounds the active in-memory inbox (default 100). Pending Input remains recoverable from the Event log; the limit is not a second persistence policy. `steer_result()` reports `session_missing`, `not_writer`, `turn_closed`, `queue_full`, `invalid_input`, or `approval_pending` alongside `accepted`.
|
|
90
|
+
|
|
85
91
|
## Tool effects and approval
|
|
86
92
|
|
|
87
93
|
Each `[[tools]]` entry accepts optional `effect = "read_only" | "idempotent" | "non_idempotent"`. The default is NON_IDEMPOTENT, and `nextloop check` reports a migration warning when it is unset. Explicit `resources` still control normal conflict checks; otherwise only uncertain outcomes use the Tool name as a lock.
|
|
@@ -139,6 +145,14 @@ history = await harness.history(from_turn=1, to_turn=10)
|
|
|
139
145
|
|
|
140
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.
|
|
141
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
|
+
|
|
142
156
|
## MCP stdio
|
|
143
157
|
|
|
144
158
|
`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.8.0**, with public contracts in `src/nextloop/contracts.py`.
|
|
4
4
|
|
|
5
5
|
## Independence and version dependency
|
|
6
6
|
|
|
@@ -11,8 +11,9 @@ This document and `src/nextloop/contracts.py` are the integration dependency bet
|
|
|
11
11
|
```text
|
|
12
12
|
AgentLoop.run(TurnContext) -> TurnOutcome
|
|
13
13
|
AgentLoop.steer(session_id, content, *, input_id=None) -> bool
|
|
14
|
+
AgentLoop.steer_result(session_id, content, *, input_id=None) -> SteerResult
|
|
14
15
|
AgentLoop.cancel(session_id, cause="user_stop") -> bool
|
|
15
|
-
AgentLoop.recover(session_id, store, delivery) -> RecoveryOutcome
|
|
16
|
+
AgentLoop.recover(session_id, store, delivery, *, force=False) -> RecoveryOutcome
|
|
16
17
|
AgentLoop.pending_inputs(session_id, store) -> tuple[PendingInput, ...]
|
|
17
18
|
AgentLoop.resume(context, *, decisions=None, reject_all=False, new_input=None) -> TurnOutcome
|
|
18
19
|
AgentLoop.retry_operation(context, operation_id) -> TurnOutcome
|
|
@@ -39,13 +40,14 @@ Context assembly and Compaction are built-in mechanisms configured through `Loop
|
|
|
39
40
|
|
|
40
41
|
### 1. EventStore
|
|
41
42
|
|
|
43
|
+
- `session_ids() -> Sequence[str]` — stable enumeration of Sessions with committed Events for caller-driven Outbox export.
|
|
42
44
|
- `attach_writer(session_id) -> (writer_epoch, last_seq, last_turn)`
|
|
43
45
|
- `check_writer(session_id, writer_epoch) -> None` — rejects a stale writer immediately before Tool dispatch.
|
|
44
46
|
- `append(session_id, writer_epoch, expected_seq, events) -> Sequence[Event]` — validates epoch/seq and inserts atomically; identical retries are idempotent.
|
|
45
47
|
- `load_surface(session_id) -> Sequence[Event]` — returns model-visible Events from the latest `SurfaceOp.EPOCH` watermark plus INPUT_ACCEPTED and protocol correction facts.
|
|
46
48
|
- `load_recovery(session_id) -> Sequence[Event]` — full ordered history for deterministic crash repair and Pending projection.
|
|
47
49
|
|
|
48
|
-
Third-party implementations must pass `nextloop.testing.check_event_store()`.
|
|
50
|
+
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.
|
|
49
51
|
|
|
50
52
|
**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.
|
|
51
53
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# AgentLoop verification matrix
|
|
2
2
|
|
|
3
|
-
Status: 0.
|
|
3
|
+
Status: 0.8.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
|
|
|
@@ -77,7 +77,7 @@ Conversation Projection is bounded by the returned Surface and serialized messag
|
|
|
77
77
|
|
|
78
78
|
## Public contracts and packaging
|
|
79
79
|
|
|
80
|
-
- `tests/test_import_contract.py` freezes all
|
|
80
|
+
- `tests/test_import_contract.py` freezes all 97 root re-exports and the complete `__all__` of `events`, `adapters`, `execute`, and `testing`, plus explicit supported names on other integration modules.
|
|
81
81
|
- `tests/test_store_contract.py` is the third-party Store conformance entrypoint.
|
|
82
82
|
- Python 3.11, 3.12, 3.13, and 3.14 run CI. Local clean Python 3.11 and 3.14 environments also run the full suite and benchmark before 0.6.0 publication.
|
|
83
83
|
- `ruff`, format check, strict mypy, wheel/sdist build, Twine, clean wheel installation, examples, and CLI diagnostics are required gates.
|
|
@@ -100,10 +100,42 @@ Conversation Projection is bounded by the returned Surface and serialized messag
|
|
|
100
100
|
|
|
101
101
|
The 0.6 review closed non-boolean grants, lock-delay expiry, duplicate dispatch, concurrent reconciliation, repeated-retry lock leakage, unknown-schema bypass, resource/budget approval bypass, finalization divergence, and input/dedup duplication. Every original counterexample has a regression and incremental Risk verification.
|
|
102
102
|
|
|
103
|
+
## 0.7 lease and input evidence
|
|
104
|
+
|
|
105
|
+
| Claim | Closing evidence |
|
|
106
|
+
|---|---|
|
|
107
|
+
| No-owner behavior remains compatible | Legacy epoch checks and raw 1.0/1.1 fixture bytes remain unchanged; lease tables are opt-in |
|
|
108
|
+
| Same-owner restart and renewal | Immediate takeover, independent renewal during a long Tool, and expiry rejection |
|
|
109
|
+
| Different-owner takeover | Expiry or `recover(force=True)` with increasing epoch and stale-writer rejection |
|
|
110
|
+
| Legacy takeover fences old lease owners | Global epoch plus owner/expiry validation in check/append/has_writer |
|
|
111
|
+
| Heartbeat failure cannot continue silently | Operational RuntimeError cancels execution without CANCELLATION_REQUESTED |
|
|
112
|
+
| Late results never fabricate completion | No result before recovery; recovered result is uncertain_hanging |
|
|
113
|
+
| Lease resume/recovery is idempotent | Concurrent resume has one winner and repeated recover does not duplicate facts |
|
|
114
|
+
| Same-host multiprocess works | Spawn-based simultaneous initialization and contention pass 20 consecutive runs with bounded WAL lock backoff |
|
|
115
|
+
| Renewal cannot silently succeed after expiry | Atomic UPDATE with `rowcount == 1` and has_writer=False afterward |
|
|
116
|
+
| Input rejection is machine-readable | accepted, session_missing, not_writer, turn_closed, queue_full, invalid_input, and approval_pending |
|
|
117
|
+
| Idempotent input is not capacity-rejected | Accepted ID replay precedes queue_full checks; non-writers never append facts |
|
|
118
|
+
| Lease cancellation is writer-scoped | Active stale writers and inactive non-owners are rejected before cancellation append |
|
|
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
|
+
|
|
103
135
|
## Review and external evidence
|
|
104
136
|
|
|
105
137
|
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.
|
|
106
138
|
|
|
107
139
|
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**.
|
|
108
140
|
|
|
109
|
-
Current non-guarantees:
|
|
141
|
+
Current non-guarantees: distributed writer coordination, exactly-once export, Session deletion, 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.8.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,
|
|
@@ -47,6 +50,8 @@ from .contracts import (
|
|
|
47
50
|
SkillError,
|
|
48
51
|
SkillSpec,
|
|
49
52
|
Skipped,
|
|
53
|
+
SteerResult,
|
|
54
|
+
SteerStatus,
|
|
50
55
|
StoreConfig,
|
|
51
56
|
SurfaceOp,
|
|
52
57
|
TimingSource,
|
|
@@ -74,6 +79,7 @@ from .contracts import (
|
|
|
74
79
|
UncertainSettled,
|
|
75
80
|
ValidatedCall,
|
|
76
81
|
ValidationIssue,
|
|
82
|
+
WriterLeaseError,
|
|
77
83
|
new_id,
|
|
78
84
|
utc_now,
|
|
79
85
|
)
|
|
@@ -107,6 +113,8 @@ __all__ = [
|
|
|
107
113
|
"Event",
|
|
108
114
|
"EventStore",
|
|
109
115
|
"EventType",
|
|
116
|
+
"ExportGap",
|
|
117
|
+
"ExportReport",
|
|
110
118
|
"FinalMessage",
|
|
111
119
|
"FinishReason",
|
|
112
120
|
"Harness",
|
|
@@ -138,6 +146,7 @@ __all__ = [
|
|
|
138
146
|
"ProviderError",
|
|
139
147
|
"RecoveryOutcome",
|
|
140
148
|
"SQLiteEventStore",
|
|
149
|
+
"SQLiteOutbox",
|
|
141
150
|
"SkillConfig",
|
|
142
151
|
"SkillDocument",
|
|
143
152
|
"SkillError",
|
|
@@ -148,6 +157,8 @@ __all__ = [
|
|
|
148
157
|
"StdioProtocolError",
|
|
149
158
|
"StdoutExporter",
|
|
150
159
|
"StoreConfig",
|
|
160
|
+
"SteerResult",
|
|
161
|
+
"SteerStatus",
|
|
151
162
|
"SurfaceOp",
|
|
152
163
|
"TimingSource",
|
|
153
164
|
"ToolCall",
|
|
@@ -177,6 +188,7 @@ __all__ = [
|
|
|
177
188
|
"UncertainSettled",
|
|
178
189
|
"ValidatedCall",
|
|
179
190
|
"ValidationIssue",
|
|
191
|
+
"WriterLeaseError",
|
|
180
192
|
"load_harness_spec",
|
|
181
193
|
"new_id",
|
|
182
194
|
"project_traces",
|
|
@@ -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
|
]
|