nextloop 0.7.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.
Files changed (137) hide show
  1. {nextloop-0.7.0/src/nextloop.egg-info → nextloop-0.8.0}/PKG-INFO +21 -9
  2. {nextloop-0.7.0 → nextloop-0.8.0}/README.md +20 -8
  3. nextloop-0.8.0/docs/adr/0009-outbox.md +30 -0
  4. {nextloop-0.7.0 → nextloop-0.8.0}/docs/architecture/development-plan.md +2 -1
  5. {nextloop-0.7.0 → nextloop-0.8.0}/docs/architecture/discussion-roadmap.md +6 -6
  6. {nextloop-0.7.0 → nextloop-0.8.0}/docs/architecture/feature-worklist.md +2 -2
  7. {nextloop-0.7.0 → nextloop-0.8.0}/docs/architecture/requirements.md +1 -1
  8. {nextloop-0.7.0 → nextloop-0.8.0}/docs/design/architecture.md +2 -2
  9. {nextloop-0.7.0 → nextloop-0.8.0}/docs/design/harness.md +8 -0
  10. {nextloop-0.7.0 → nextloop-0.8.0}/docs/design/loop-interface.md +3 -2
  11. {nextloop-0.7.0 → nextloop-0.8.0}/docs/design/verification-matrix.md +17 -2
  12. {nextloop-0.7.0 → nextloop-0.8.0}/pyproject.toml +1 -1
  13. {nextloop-0.7.0 → nextloop-0.8.0}/src/nextloop/__init__.py +6 -0
  14. {nextloop-0.7.0 → nextloop-0.8.0}/src/nextloop/adapters/__init__.py +2 -0
  15. nextloop-0.8.0/src/nextloop/adapters/_sqlite.py +19 -0
  16. {nextloop-0.7.0 → nextloop-0.8.0}/src/nextloop/adapters/memory.py +4 -0
  17. {nextloop-0.7.0 → nextloop-0.8.0}/src/nextloop/adapters/observing.py +6 -0
  18. nextloop-0.8.0/src/nextloop/adapters/outbox.py +300 -0
  19. {nextloop-0.7.0 → nextloop-0.8.0}/src/nextloop/adapters/sqlite.py +9 -12
  20. {nextloop-0.7.0 → nextloop-0.8.0}/src/nextloop/contracts.py +18 -1
  21. nextloop-0.8.0/src/nextloop/events/trace_ids.py +28 -0
  22. {nextloop-0.7.0 → nextloop-0.8.0}/src/nextloop/testing.py +3 -0
  23. {nextloop-0.7.0 → nextloop-0.8.0/src/nextloop.egg-info}/PKG-INFO +21 -9
  24. {nextloop-0.7.0 → nextloop-0.8.0}/src/nextloop.egg-info/SOURCES.txt +6 -0
  25. {nextloop-0.7.0 → nextloop-0.8.0}/tests/test_harness.py +1 -1
  26. {nextloop-0.7.0 → nextloop-0.8.0}/tests/test_import_contract.py +4 -0
  27. nextloop-0.8.0/tests/test_outbox.py +137 -0
  28. nextloop-0.8.0/tests/test_outbox_regressions.py +344 -0
  29. {nextloop-0.7.0 → nextloop-0.8.0}/tests/test_skills.py +1 -1
  30. {nextloop-0.7.0 → nextloop-0.8.0}/LICENSE +0 -0
  31. {nextloop-0.7.0 → nextloop-0.8.0}/MANIFEST.in +0 -0
  32. {nextloop-0.7.0 → nextloop-0.8.0}/docs/adr/0001-embeddable-agent-loop.md +0 -0
  33. {nextloop-0.7.0 → nextloop-0.8.0}/docs/adr/0002-dsh-aligned-agent-loop.md +0 -0
  34. {nextloop-0.7.0 → nextloop-0.8.0}/docs/adr/0003-python-and-centralized-contracts.md +0 -0
  35. {nextloop-0.7.0 → nextloop-0.8.0}/docs/adr/0004-event-compatibility.md +0 -0
  36. {nextloop-0.7.0 → nextloop-0.8.0}/docs/adr/0005-pending-input.md +0 -0
  37. {nextloop-0.7.0 → nextloop-0.8.0}/docs/adr/0006-operation-id.md +0 -0
  38. {nextloop-0.7.0 → nextloop-0.8.0}/docs/adr/0007-approval.md +0 -0
  39. {nextloop-0.7.0 → nextloop-0.8.0}/docs/adr/0008-lease.md +0 -0
  40. {nextloop-0.7.0 → nextloop-0.8.0}/docs/architecture/agent-loop-capability-review.md +0 -0
  41. {nextloop-0.7.0 → nextloop-0.8.0}/docs/design/agent-loop.md +0 -0
  42. {nextloop-0.7.0 → nextloop-0.8.0}/docs/design/context-builder.md +0 -0
  43. {nextloop-0.7.0 → nextloop-0.8.0}/docs/design/react-protocol.md +0 -0
  44. {nextloop-0.7.0 → nextloop-0.8.0}/docs/design/skills.md +0 -0
  45. {nextloop-0.7.0 → nextloop-0.8.0}/docs/research/2026-11-02-dsh-primary-sources.md +0 -0
  46. {nextloop-0.7.0 → nextloop-0.8.0}/docs/research/2026-11-02-loop-evidence-notes.md +0 -0
  47. {nextloop-0.7.0 → nextloop-0.8.0}/docs/research/2026-11-03-hermes-turn-control.md +0 -0
  48. {nextloop-0.7.0 → nextloop-0.8.0}/docs/research/2026-11-03-tool-batch-failures.md +0 -0
  49. {nextloop-0.7.0 → nextloop-0.8.0}/docs/research/2026-11-03-tool-call-validation.md +0 -0
  50. {nextloop-0.7.0 → nextloop-0.8.0}/docs/research/2026-11-03-yomi-turn-control.md +0 -0
  51. {nextloop-0.7.0 → nextloop-0.8.0}/docs/research/2026-11-06-open-source-agent-loops.md +0 -0
  52. {nextloop-0.7.0 → nextloop-0.8.0}/docs/research/2026-11-06-react-tool-event-recovery.md +0 -0
  53. {nextloop-0.7.0 → nextloop-0.8.0}/docs/research/2026-11-10-nextloop-optimization-review.md +0 -0
  54. {nextloop-0.7.0 → nextloop-0.8.0}/examples/basic.py +0 -0
  55. {nextloop-0.7.0 → nextloop-0.8.0}/examples/harness-skills/echo/SKILL.md +0 -0
  56. {nextloop-0.7.0 → nextloop-0.8.0}/examples/harness.toml +0 -0
  57. {nextloop-0.7.0 → nextloop-0.8.0}/examples/live_smoke.py +0 -0
  58. {nextloop-0.7.0 → nextloop-0.8.0}/examples/python_tools.py +0 -0
  59. {nextloop-0.7.0 → nextloop-0.8.0}/examples/skills/coding/SKILL.md +0 -0
  60. {nextloop-0.7.0 → nextloop-0.8.0}/examples/skills_demo.py +0 -0
  61. {nextloop-0.7.0 → nextloop-0.8.0}/examples/workers/cpp_worker.cpp +0 -0
  62. {nextloop-0.7.0 → nextloop-0.8.0}/examples/workers/python_worker.py +0 -0
  63. {nextloop-0.7.0 → nextloop-0.8.0}/examples/workers/rust_worker.rs +0 -0
  64. {nextloop-0.7.0 → nextloop-0.8.0}/setup.cfg +0 -0
  65. {nextloop-0.7.0 → nextloop-0.8.0}/src/nextloop/adapters/_sse.py +0 -0
  66. {nextloop-0.7.0 → nextloop-0.8.0}/src/nextloop/adapters/anthropic.py +0 -0
  67. {nextloop-0.7.0 → nextloop-0.8.0}/src/nextloop/adapters/openai.py +0 -0
  68. {nextloop-0.7.0 → nextloop-0.8.0}/src/nextloop/cli.py +0 -0
  69. {nextloop-0.7.0 → nextloop-0.8.0}/src/nextloop/driver.py +0 -0
  70. {nextloop-0.7.0 → nextloop-0.8.0}/src/nextloop/events/__init__.py +0 -0
  71. {nextloop-0.7.0 → nextloop-0.8.0}/src/nextloop/events/approval.py +0 -0
  72. {nextloop-0.7.0 → nextloop-0.8.0}/src/nextloop/events/input.py +0 -0
  73. {nextloop-0.7.0 → nextloop-0.8.0}/src/nextloop/events/outcome.py +0 -0
  74. {nextloop-0.7.0 → nextloop-0.8.0}/src/nextloop/events/pending.py +0 -0
  75. {nextloop-0.7.0 → nextloop-0.8.0}/src/nextloop/events/project.py +0 -0
  76. {nextloop-0.7.0 → nextloop-0.8.0}/src/nextloop/events/repair.py +0 -0
  77. {nextloop-0.7.0 → nextloop-0.8.0}/src/nextloop/events/response.py +0 -0
  78. {nextloop-0.7.0 → nextloop-0.8.0}/src/nextloop/events/trace.py +0 -0
  79. {nextloop-0.7.0 → nextloop-0.8.0}/src/nextloop/events/upcast.py +0 -0
  80. {nextloop-0.7.0 → nextloop-0.8.0}/src/nextloop/execute/__init__.py +0 -0
  81. {nextloop-0.7.0 → nextloop-0.8.0}/src/nextloop/execute/batch.py +0 -0
  82. {nextloop-0.7.0 → nextloop-0.8.0}/src/nextloop/execute/cancellation.py +0 -0
  83. {nextloop-0.7.0 → nextloop-0.8.0}/src/nextloop/execute/cleanup.py +0 -0
  84. {nextloop-0.7.0 → nextloop-0.8.0}/src/nextloop/execute/composite.py +0 -0
  85. {nextloop-0.7.0 → nextloop-0.8.0}/src/nextloop/execute/mcp.py +0 -0
  86. {nextloop-0.7.0 → nextloop-0.8.0}/src/nextloop/execute/model.py +0 -0
  87. {nextloop-0.7.0 → nextloop-0.8.0}/src/nextloop/execute/preview.py +0 -0
  88. {nextloop-0.7.0 → nextloop-0.8.0}/src/nextloop/execute/result_read.py +0 -0
  89. {nextloop-0.7.0 → nextloop-0.8.0}/src/nextloop/execute/stdio.py +0 -0
  90. {nextloop-0.7.0 → nextloop-0.8.0}/src/nextloop/execute/stdio_transport.py +0 -0
  91. {nextloop-0.7.0 → nextloop-0.8.0}/src/nextloop/execute/tools.py +0 -0
  92. {nextloop-0.7.0 → nextloop-0.8.0}/src/nextloop/harness.py +0 -0
  93. {nextloop-0.7.0 → nextloop-0.8.0}/src/nextloop/loop.py +0 -0
  94. {nextloop-0.7.0 → nextloop-0.8.0}/src/nextloop/py.typed +0 -0
  95. {nextloop-0.7.0 → nextloop-0.8.0}/src/nextloop/skills.py +0 -0
  96. {nextloop-0.7.0 → nextloop-0.8.0}/src/nextloop.egg-info/dependency_links.txt +0 -0
  97. {nextloop-0.7.0 → nextloop-0.8.0}/src/nextloop.egg-info/entry_points.txt +0 -0
  98. {nextloop-0.7.0 → nextloop-0.8.0}/src/nextloop.egg-info/requires.txt +0 -0
  99. {nextloop-0.7.0 → nextloop-0.8.0}/src/nextloop.egg-info/top_level.txt +0 -0
  100. {nextloop-0.7.0 → nextloop-0.8.0}/tests/test_aggregate_close.py +0 -0
  101. {nextloop-0.7.0 → nextloop-0.8.0}/tests/test_approval.py +0 -0
  102. {nextloop-0.7.0 → nextloop-0.8.0}/tests/test_approval_regressions.py +0 -0
  103. {nextloop-0.7.0 → nextloop-0.8.0}/tests/test_budgets.py +0 -0
  104. {nextloop-0.7.0 → nextloop-0.8.0}/tests/test_cli.py +0 -0
  105. {nextloop-0.7.0 → nextloop-0.8.0}/tests/test_compaction_lineage.py +0 -0
  106. {nextloop-0.7.0 → nextloop-0.8.0}/tests/test_complexity_regressions.py +0 -0
  107. {nextloop-0.7.0 → nextloop-0.8.0}/tests/test_correctness_regressions.py +0 -0
  108. {nextloop-0.7.0 → nextloop-0.8.0}/tests/test_events.py +0 -0
  109. {nextloop-0.7.0 → nextloop-0.8.0}/tests/test_failures.py +0 -0
  110. {nextloop-0.7.0 → nextloop-0.8.0}/tests/test_fault_injection.py +0 -0
  111. {nextloop-0.7.0 → nextloop-0.8.0}/tests/test_fault_matrix.py +0 -0
  112. {nextloop-0.7.0 → nextloop-0.8.0}/tests/test_harness_injection.py +0 -0
  113. {nextloop-0.7.0 → nextloop-0.8.0}/tests/test_lease.py +0 -0
  114. {nextloop-0.7.0 → nextloop-0.8.0}/tests/test_loop.py +0 -0
  115. {nextloop-0.7.0 → nextloop-0.8.0}/tests/test_mcp.py +0 -0
  116. {nextloop-0.7.0 → nextloop-0.8.0}/tests/test_mcp_hardening.py +0 -0
  117. {nextloop-0.7.0 → nextloop-0.8.0}/tests/test_observability.py +0 -0
  118. {nextloop-0.7.0 → nextloop-0.8.0}/tests/test_observability_close_deadline.py +0 -0
  119. {nextloop-0.7.0 → nextloop-0.8.0}/tests/test_operations.py +0 -0
  120. {nextloop-0.7.0 → nextloop-0.8.0}/tests/test_pending_inputs.py +0 -0
  121. {nextloop-0.7.0 → nextloop-0.8.0}/tests/test_preview.py +0 -0
  122. {nextloop-0.7.0 → nextloop-0.8.0}/tests/test_projection_parity.py +0 -0
  123. {nextloop-0.7.0 → nextloop-0.8.0}/tests/test_provider_terminal.py +0 -0
  124. {nextloop-0.7.0 → nextloop-0.8.0}/tests/test_providers.py +0 -0
  125. {nextloop-0.7.0 → nextloop-0.8.0}/tests/test_result_budget_regressions.py +0 -0
  126. {nextloop-0.7.0 → nextloop-0.8.0}/tests/test_result_policies.py +0 -0
  127. {nextloop-0.7.0 → nextloop-0.8.0}/tests/test_retry_regressions.py +0 -0
  128. {nextloop-0.7.0 → nextloop-0.8.0}/tests/test_review_regressions.py +0 -0
  129. {nextloop-0.7.0 → nextloop-0.8.0}/tests/test_stdio.py +0 -0
  130. {nextloop-0.7.0 → nextloop-0.8.0}/tests/test_stdio_cleanup.py +0 -0
  131. {nextloop-0.7.0 → nextloop-0.8.0}/tests/test_stdio_frames.py +0 -0
  132. {nextloop-0.7.0 → nextloop-0.8.0}/tests/test_stdio_safety.py +0 -0
  133. {nextloop-0.7.0 → nextloop-0.8.0}/tests/test_store_contract.py +0 -0
  134. {nextloop-0.7.0 → nextloop-0.8.0}/tests/test_stores.py +0 -0
  135. {nextloop-0.7.0 → nextloop-0.8.0}/tests/test_surface_snapshot.py +0 -0
  136. {nextloop-0.7.0 → nextloop-0.8.0}/tests/test_upcasting.py +0 -0
  137. {nextloop-0.7.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.7.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.7.0**.
38
+ Current version: **0.8.0**.
39
39
 
40
40
  ## Install
41
41
 
42
42
  ```bash
43
- python -m pip install nextloop==0.7.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 Session history. No second execution path and no telemetry-driven control flow.
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,7 @@ 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 and can be replayed for history. | The current in-memory Exporter queue as a durable outbox. |
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
115
  | MCP | stdio lifecycle, paginated static catalogs, operation metadata, and uncertain crash handling. | Remote MCP, OAuth, dynamic `listChanged`, or non-text content mapping. |
116
116
 
117
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.
@@ -166,6 +166,17 @@ history = await harness.history(from_turn=1, to_turn=10)
166
166
 
167
167
  History works with memory and SQLite Stores even when no Exporter is configured.
168
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
+
169
180
  `ToolRegistry` is the built-in `ToolRuntime` implementation:
170
181
 
171
182
  ```python
@@ -232,14 +243,15 @@ The release checks cover:
232
243
  - recorded OpenAI and Anthropic SSE streams;
233
244
  - 12 live Kimi scenarios across both protocols, real Tool usage, parallel execution, recovery, steer, cancellation, Compaction, and WorkingContext;
234
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;
235
247
  - a 10,505-event benchmark with cross-Store, incremental, and required-content parity;
236
- - 357 offline tests, `ruff`, `mypy`, wheel/sdist builds, `twine check`, and clean wheel installation.
248
+ - 373 offline tests, `ruff`, `mypy`, wheel/sdist builds, `twine check`, and clean wheel installation.
237
249
 
238
250
  Current limits:
239
251
 
240
252
  - nika integration is separate acceptance work.
241
- - Concurrent writers across multiple processes fail closed; they are not coordinated by time-based leases.
242
- - 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.
243
255
  - Official OpenAI and Anthropic API acceptance remains a 1.0 hard gate; recorded streams and DeepSeek do not substitute for it.
244
256
 
245
257
  ## Documents
@@ -255,7 +267,7 @@ Current limits:
255
267
  - [Development plan](docs/architecture/development-plan.md)
256
268
  - [Contributing](CONTRIBUTING.md) and [Security](SECURITY.md)
257
269
  - [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), and [ADR-0007 Approval](docs/adr/0007-approval.md), and [ADR-0008 Owner leases](docs/adr/0008-lease.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)
259
271
 
260
272
  ## Release
261
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.7.0**.
9
+ Current version: **0.8.0**.
10
10
 
11
11
  ## Install
12
12
 
13
13
  ```bash
14
- python -m pip install nextloop==0.7.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 Session history. No second execution path and no telemetry-driven control flow.
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,7 @@ 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 and can be replayed for history. | The current in-memory Exporter queue as a durable outbox. |
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
86
  | MCP | stdio lifecycle, paginated static catalogs, operation metadata, and uncertain crash handling. | Remote MCP, OAuth, dynamic `listChanged`, or non-text content mapping. |
87
87
 
88
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.
@@ -137,6 +137,17 @@ history = await harness.history(from_turn=1, to_turn=10)
137
137
 
138
138
  History works with memory and SQLite Stores even when no Exporter is configured.
139
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
+
140
151
  `ToolRegistry` is the built-in `ToolRuntime` implementation:
141
152
 
142
153
  ```python
@@ -203,14 +214,15 @@ The release checks cover:
203
214
  - recorded OpenAI and Anthropic SSE streams;
204
215
  - 12 live Kimi scenarios across both protocols, real Tool usage, parallel execution, recovery, steer, cancellation, Compaction, and WorkingContext;
205
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;
206
218
  - a 10,505-event benchmark with cross-Store, incremental, and required-content parity;
207
- - 357 offline tests, `ruff`, `mypy`, wheel/sdist builds, `twine check`, and clean wheel installation.
219
+ - 373 offline tests, `ruff`, `mypy`, wheel/sdist builds, `twine check`, and clean wheel installation.
208
220
 
209
221
  Current limits:
210
222
 
211
223
  - nika integration is separate acceptance work.
212
- - Concurrent writers across multiple processes fail closed; they are not coordinated by time-based leases.
213
- - 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.
214
226
  - Official OpenAI and Anthropic API acceptance remains a 1.0 hard gate; recorded streams and DeepSeek do not substitute for it.
215
227
 
216
228
  ## Documents
@@ -226,7 +238,7 @@ Current limits:
226
238
  - [Development plan](docs/architecture/development-plan.md)
227
239
  - [Contributing](CONTRIBUTING.md) and [Security](SECURITY.md)
228
240
  - [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), and [ADR-0007 Approval](docs/adr/0007-approval.md), and [ADR-0008 Owner leases](docs/adr/0008-lease.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)
230
242
 
231
243
  ## Release
232
244
 
@@ -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.7.0 release verification**. `0.6.0` is published; later milestones are not claimed as implemented.
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.0 falsification and integration-contract closure**. The executable implementation plan is [development-plan.md](development-plan.md).
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 for single-process fencing; timed leases remain 0.7 |
27
- | Pending Input | Log projection by `input_id` and Step-boundary consumption | Implemented; cross-process steering reasons remain 0.7 |
28
- | Observability | Committed-event Trace projection with failure isolation | Implemented; persistent Outbox remains 0.8 |
29
- | Schema evolution | Read-only upcasting and versioned real fixtures | 0.6, not currently claimed |
30
- | Operation identity and approval | Persistent `operation_id`, effect declarations, approved new-Turn resume | 0.6, not currently claimed |
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.7 line
5
+ ## Implemented in the current 0.8 line
6
6
 
7
7
  | Feature | Implementation | Evidence |
8
8
  |---|---|---|
@@ -19,6 +19,7 @@ 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, and closed-Turn filtering |
22
23
  | Integrations | Harness, directory Skills, stdio workers, MCP stdio | Offline diagnostics, subprocess conformance, lifecycle, and clean-wheel examples |
23
24
  | Release contract | Frozen root/module re-exports, Python 3.11–3.14 CI | Import snapshot, complete gates, wheel/sdist, and clean-install checks |
24
25
 
@@ -26,7 +27,6 @@ Purpose: distinguish implemented capabilities from remaining work. Executable ev
26
27
 
27
28
  | Feature | Target and boundary |
28
29
  |---|---|
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.7.0 implemented and verified.** Fault matrix, benchmark, Python 3.14, import contract, upcasting, operation, approval, owner lease, and clean package gates pass; publication and later milestones remain separate |
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
 
@@ -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. Persistent Outbox and Session deletion remain later milestones.
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 97 names and rejects accidental additions, removals, and duplicate entries.
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
 
@@ -145,6 +145,14 @@ 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
+
148
156
  ## MCP stdio
149
157
 
150
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.7.0**, with public contracts in `src/nextloop/contracts.py`.
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
 
@@ -40,13 +40,14 @@ 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 Sessions with committed Events for caller-driven Outbox export.
43
44
  - `attach_writer(session_id) -> (writer_epoch, last_seq, last_turn)`
44
45
  - `check_writer(session_id, writer_epoch) -> None` — rejects a stale writer immediately before Tool dispatch.
45
46
  - `append(session_id, writer_epoch, expected_seq, events) -> Sequence[Event]` — validates epoch/seq and inserts atomically; identical retries are idempotent.
46
47
  - `load_surface(session_id) -> Sequence[Event]` — returns model-visible Events from the latest `SurfaceOp.EPOCH` watermark plus INPUT_ACCEPTED and protocol correction facts.
47
48
  - `load_recovery(session_id) -> Sequence[Event]` — full ordered history for deterministic crash repair and Pending projection.
48
49
 
49
- Third-party implementations must pass `nextloop.testing.check_event_store()`. Current writer epochs are not time-based leases and do not coordinate active multi-process writers.
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.
50
51
 
51
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.
52
53
 
@@ -1,6 +1,6 @@
1
1
  # AgentLoop verification matrix
2
2
 
3
- Status: 0.7.0 release gate. A claim is closed only by the executable evidence named here; test count alone is not evidence.
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
 
@@ -117,10 +117,25 @@ 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
+
120
135
  ## Review and external evidence
121
136
 
122
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.
123
138
 
124
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**.
125
140
 
126
- Current non-guarantees: time-based writer leases, durable Outbox, Session deletion, remote MCP/OAuth, event-level erasure, and external large-asset lifecycle.
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.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,
@@ -110,6 +113,8 @@ __all__ = [
110
113
  "Event",
111
114
  "EventStore",
112
115
  "EventType",
116
+ "ExportGap",
117
+ "ExportReport",
113
118
  "FinalMessage",
114
119
  "FinishReason",
115
120
  "Harness",
@@ -141,6 +146,7 @@ __all__ = [
141
146
  "ProviderError",
142
147
  "RecoveryOutcome",
143
148
  "SQLiteEventStore",
149
+ "SQLiteOutbox",
144
150
  "SkillConfig",
145
151
  "SkillDocument",
146
152
  "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,19 @@
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)
@@ -47,6 +47,10 @@ class InMemoryEventStore:
47
47
  self.lease_seconds = lease_seconds if owner_id is not None else None
48
48
  self._clock = clock
49
49
 
50
+ async def session_ids(self) -> Sequence[str]:
51
+ async with self._lock:
52
+ return tuple(sorted(self._events))
53
+
50
54
  async def attach_writer(self, session_id: str, *, force: bool = False) -> tuple[int, int, int]:
51
55
  async with self._lock:
52
56
  if self.lease_seconds is not None:
@@ -20,6 +20,7 @@ from ..contracts import (
20
20
  TurnTrace,
21
21
  )
22
22
  from ..events.trace import TraceProjector, project_traces
23
+ from ..events.trace_ids import span_id, trace_id
23
24
  from ..execute.cleanup import wait_for_cleanup
24
25
 
25
26
  TraceErrorHandler = Callable[[Exception, TraceRecord | None], None]
@@ -39,6 +40,8 @@ class StdoutExporter:
39
40
  output = {
40
41
  "schema": TRACE_SCHEMA,
41
42
  "trace_type": trace_type,
43
+ "trace_id": trace_id(trace.session_id),
44
+ "span_id": span_id(trace),
42
45
  "data": dataclasses.asdict(trace),
43
46
  }
44
47
  stream = self.stream or sys.stdout
@@ -76,6 +79,9 @@ class ObservingEventStore:
76
79
  self._close_lock = asyncio.Lock()
77
80
  self.dropped_count = 0
78
81
 
82
+ async def session_ids(self) -> Sequence[str]:
83
+ return await self._store.session_ids()
84
+
79
85
  async def attach_writer(self, session_id: str, *, force: bool = False) -> tuple[int, int, int]:
80
86
  result = await self._store.attach_writer(session_id, force=force)
81
87
  try: