nextloop 0.5.0rc2__tar.gz → 0.7.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 (138) hide show
  1. {nextloop-0.5.0rc2/src/nextloop.egg-info → nextloop-0.7.0}/PKG-INFO +32 -14
  2. {nextloop-0.5.0rc2 → nextloop-0.7.0}/README.md +30 -13
  3. {nextloop-0.5.0rc2 → nextloop-0.7.0}/docs/adr/0003-python-and-centralized-contracts.md +1 -1
  4. nextloop-0.7.0/docs/adr/0004-event-compatibility.md +27 -0
  5. {nextloop-0.5.0rc2 → nextloop-0.7.0}/docs/adr/0005-pending-input.md +2 -1
  6. nextloop-0.7.0/docs/adr/0006-operation-id.md +24 -0
  7. nextloop-0.7.0/docs/adr/0007-approval.md +25 -0
  8. nextloop-0.7.0/docs/adr/0008-lease.md +24 -0
  9. nextloop-0.7.0/docs/architecture/development-plan.md +71 -0
  10. nextloop-0.7.0/docs/architecture/discussion-roadmap.md +50 -0
  11. nextloop-0.7.0/docs/architecture/feature-worklist.md +34 -0
  12. {nextloop-0.5.0rc2 → nextloop-0.7.0}/docs/architecture/requirements.md +4 -4
  13. {nextloop-0.5.0rc2 → nextloop-0.7.0}/docs/design/agent-loop.md +38 -28
  14. nextloop-0.7.0/docs/design/architecture.md +69 -0
  15. {nextloop-0.5.0rc2 → nextloop-0.7.0}/docs/design/harness.md +14 -2
  16. {nextloop-0.5.0rc2 → nextloop-0.7.0}/docs/design/loop-interface.md +22 -9
  17. nextloop-0.7.0/docs/design/verification-matrix.md +126 -0
  18. {nextloop-0.5.0rc2 → nextloop-0.7.0}/examples/workers/python_worker.py +8 -0
  19. {nextloop-0.5.0rc2 → nextloop-0.7.0}/pyproject.toml +2 -1
  20. {nextloop-0.5.0rc2 → nextloop-0.7.0}/src/nextloop/__init__.py +12 -0
  21. {nextloop-0.5.0rc2 → nextloop-0.7.0}/src/nextloop/adapters/memory.py +84 -7
  22. {nextloop-0.5.0rc2 → nextloop-0.7.0}/src/nextloop/adapters/observing.py +15 -2
  23. {nextloop-0.5.0rc2 → nextloop-0.7.0}/src/nextloop/adapters/sqlite.py +145 -17
  24. {nextloop-0.5.0rc2 → nextloop-0.7.0}/src/nextloop/cli.py +1 -0
  25. {nextloop-0.5.0rc2 → nextloop-0.7.0}/src/nextloop/contracts.py +92 -4
  26. {nextloop-0.5.0rc2 → nextloop-0.7.0}/src/nextloop/driver.py +58 -16
  27. {nextloop-0.5.0rc2 → nextloop-0.7.0}/src/nextloop/events/__init__.py +2 -0
  28. nextloop-0.7.0/src/nextloop/events/approval.py +145 -0
  29. nextloop-0.7.0/src/nextloop/events/input.py +29 -0
  30. {nextloop-0.5.0rc2 → nextloop-0.7.0}/src/nextloop/events/outcome.py +47 -1
  31. {nextloop-0.5.0rc2 → nextloop-0.7.0}/src/nextloop/events/project.py +57 -2
  32. {nextloop-0.5.0rc2 → nextloop-0.7.0}/src/nextloop/events/repair.py +55 -5
  33. {nextloop-0.5.0rc2 → nextloop-0.7.0}/src/nextloop/events/response.py +8 -2
  34. {nextloop-0.5.0rc2 → nextloop-0.7.0}/src/nextloop/events/trace.py +10 -1
  35. nextloop-0.7.0/src/nextloop/events/upcast.py +47 -0
  36. {nextloop-0.5.0rc2 → nextloop-0.7.0}/src/nextloop/execute/batch.py +24 -3
  37. {nextloop-0.5.0rc2 → nextloop-0.7.0}/src/nextloop/execute/mcp.py +13 -1
  38. {nextloop-0.5.0rc2 → nextloop-0.7.0}/src/nextloop/execute/stdio.py +14 -1
  39. {nextloop-0.5.0rc2 → nextloop-0.7.0}/src/nextloop/execute/stdio_transport.py +20 -6
  40. {nextloop-0.5.0rc2 → nextloop-0.7.0}/src/nextloop/execute/tools.py +7 -3
  41. {nextloop-0.5.0rc2 → nextloop-0.7.0}/src/nextloop/harness.py +25 -5
  42. nextloop-0.7.0/src/nextloop/loop.py +819 -0
  43. nextloop-0.7.0/src/nextloop/testing.py +318 -0
  44. {nextloop-0.5.0rc2 → nextloop-0.7.0/src/nextloop.egg-info}/PKG-INFO +32 -14
  45. {nextloop-0.5.0rc2 → nextloop-0.7.0}/src/nextloop.egg-info/SOURCES.txt +19 -0
  46. nextloop-0.7.0/tests/test_approval.py +401 -0
  47. nextloop-0.7.0/tests/test_approval_regressions.py +304 -0
  48. {nextloop-0.5.0rc2 → nextloop-0.7.0}/tests/test_cli.py +8 -1
  49. nextloop-0.7.0/tests/test_compaction_lineage.py +75 -0
  50. nextloop-0.7.0/tests/test_fault_injection.py +131 -0
  51. nextloop-0.7.0/tests/test_fault_matrix.py +247 -0
  52. {nextloop-0.5.0rc2 → nextloop-0.7.0}/tests/test_harness.py +14 -1
  53. nextloop-0.7.0/tests/test_import_contract.py +210 -0
  54. nextloop-0.7.0/tests/test_lease.py +461 -0
  55. {nextloop-0.5.0rc2 → nextloop-0.7.0}/tests/test_mcp.py +25 -2
  56. nextloop-0.7.0/tests/test_operations.py +330 -0
  57. nextloop-0.7.0/tests/test_pending_inputs.py +290 -0
  58. nextloop-0.7.0/tests/test_projection_parity.py +17 -0
  59. nextloop-0.7.0/tests/test_retry_regressions.py +148 -0
  60. {nextloop-0.5.0rc2 → nextloop-0.7.0}/tests/test_skills.py +1 -1
  61. {nextloop-0.5.0rc2 → nextloop-0.7.0}/tests/test_stdio.py +12 -1
  62. {nextloop-0.5.0rc2 → nextloop-0.7.0}/tests/test_store_contract.py +16 -1
  63. nextloop-0.7.0/tests/test_upcasting.py +162 -0
  64. nextloop-0.5.0rc2/docs/architecture/development-plan.md +0 -47
  65. nextloop-0.5.0rc2/docs/architecture/discussion-roadmap.md +0 -53
  66. nextloop-0.5.0rc2/docs/architecture/feature-worklist.md +0 -30
  67. nextloop-0.5.0rc2/docs/design/verification-matrix.md +0 -93
  68. nextloop-0.5.0rc2/src/nextloop/loop.py +0 -194
  69. nextloop-0.5.0rc2/src/nextloop/testing.py +0 -107
  70. nextloop-0.5.0rc2/tests/test_pending_inputs.py +0 -135
  71. {nextloop-0.5.0rc2 → nextloop-0.7.0}/LICENSE +0 -0
  72. {nextloop-0.5.0rc2 → nextloop-0.7.0}/MANIFEST.in +0 -0
  73. {nextloop-0.5.0rc2 → nextloop-0.7.0}/docs/adr/0001-embeddable-agent-loop.md +0 -0
  74. {nextloop-0.5.0rc2 → nextloop-0.7.0}/docs/adr/0002-dsh-aligned-agent-loop.md +0 -0
  75. {nextloop-0.5.0rc2 → nextloop-0.7.0}/docs/architecture/agent-loop-capability-review.md +0 -0
  76. {nextloop-0.5.0rc2 → nextloop-0.7.0}/docs/design/context-builder.md +0 -0
  77. {nextloop-0.5.0rc2 → nextloop-0.7.0}/docs/design/react-protocol.md +0 -0
  78. {nextloop-0.5.0rc2 → nextloop-0.7.0}/docs/design/skills.md +0 -0
  79. {nextloop-0.5.0rc2 → nextloop-0.7.0}/docs/research/2026-11-02-dsh-primary-sources.md +0 -0
  80. {nextloop-0.5.0rc2 → nextloop-0.7.0}/docs/research/2026-11-02-loop-evidence-notes.md +0 -0
  81. {nextloop-0.5.0rc2 → nextloop-0.7.0}/docs/research/2026-11-03-hermes-turn-control.md +0 -0
  82. {nextloop-0.5.0rc2 → nextloop-0.7.0}/docs/research/2026-11-03-tool-batch-failures.md +0 -0
  83. {nextloop-0.5.0rc2 → nextloop-0.7.0}/docs/research/2026-11-03-tool-call-validation.md +0 -0
  84. {nextloop-0.5.0rc2 → nextloop-0.7.0}/docs/research/2026-11-03-yomi-turn-control.md +0 -0
  85. {nextloop-0.5.0rc2 → nextloop-0.7.0}/docs/research/2026-11-06-open-source-agent-loops.md +0 -0
  86. {nextloop-0.5.0rc2 → nextloop-0.7.0}/docs/research/2026-11-06-react-tool-event-recovery.md +0 -0
  87. {nextloop-0.5.0rc2 → nextloop-0.7.0}/docs/research/2026-11-10-nextloop-optimization-review.md +0 -0
  88. {nextloop-0.5.0rc2 → nextloop-0.7.0}/examples/basic.py +0 -0
  89. {nextloop-0.5.0rc2 → nextloop-0.7.0}/examples/harness-skills/echo/SKILL.md +0 -0
  90. {nextloop-0.5.0rc2 → nextloop-0.7.0}/examples/harness.toml +0 -0
  91. {nextloop-0.5.0rc2 → nextloop-0.7.0}/examples/live_smoke.py +0 -0
  92. {nextloop-0.5.0rc2 → nextloop-0.7.0}/examples/python_tools.py +0 -0
  93. {nextloop-0.5.0rc2 → nextloop-0.7.0}/examples/skills/coding/SKILL.md +0 -0
  94. {nextloop-0.5.0rc2 → nextloop-0.7.0}/examples/skills_demo.py +0 -0
  95. {nextloop-0.5.0rc2 → nextloop-0.7.0}/examples/workers/cpp_worker.cpp +0 -0
  96. {nextloop-0.5.0rc2 → nextloop-0.7.0}/examples/workers/rust_worker.rs +0 -0
  97. {nextloop-0.5.0rc2 → nextloop-0.7.0}/setup.cfg +0 -0
  98. {nextloop-0.5.0rc2 → nextloop-0.7.0}/src/nextloop/adapters/__init__.py +0 -0
  99. {nextloop-0.5.0rc2 → nextloop-0.7.0}/src/nextloop/adapters/_sse.py +0 -0
  100. {nextloop-0.5.0rc2 → nextloop-0.7.0}/src/nextloop/adapters/anthropic.py +0 -0
  101. {nextloop-0.5.0rc2 → nextloop-0.7.0}/src/nextloop/adapters/openai.py +0 -0
  102. {nextloop-0.5.0rc2 → nextloop-0.7.0}/src/nextloop/events/pending.py +0 -0
  103. {nextloop-0.5.0rc2 → nextloop-0.7.0}/src/nextloop/execute/__init__.py +0 -0
  104. {nextloop-0.5.0rc2 → nextloop-0.7.0}/src/nextloop/execute/cancellation.py +0 -0
  105. {nextloop-0.5.0rc2 → nextloop-0.7.0}/src/nextloop/execute/cleanup.py +0 -0
  106. {nextloop-0.5.0rc2 → nextloop-0.7.0}/src/nextloop/execute/composite.py +0 -0
  107. {nextloop-0.5.0rc2 → nextloop-0.7.0}/src/nextloop/execute/model.py +0 -0
  108. {nextloop-0.5.0rc2 → nextloop-0.7.0}/src/nextloop/execute/preview.py +0 -0
  109. {nextloop-0.5.0rc2 → nextloop-0.7.0}/src/nextloop/execute/result_read.py +0 -0
  110. {nextloop-0.5.0rc2 → nextloop-0.7.0}/src/nextloop/py.typed +0 -0
  111. {nextloop-0.5.0rc2 → nextloop-0.7.0}/src/nextloop/skills.py +0 -0
  112. {nextloop-0.5.0rc2 → nextloop-0.7.0}/src/nextloop.egg-info/dependency_links.txt +0 -0
  113. {nextloop-0.5.0rc2 → nextloop-0.7.0}/src/nextloop.egg-info/entry_points.txt +0 -0
  114. {nextloop-0.5.0rc2 → nextloop-0.7.0}/src/nextloop.egg-info/requires.txt +0 -0
  115. {nextloop-0.5.0rc2 → nextloop-0.7.0}/src/nextloop.egg-info/top_level.txt +0 -0
  116. {nextloop-0.5.0rc2 → nextloop-0.7.0}/tests/test_aggregate_close.py +0 -0
  117. {nextloop-0.5.0rc2 → nextloop-0.7.0}/tests/test_budgets.py +0 -0
  118. {nextloop-0.5.0rc2 → nextloop-0.7.0}/tests/test_complexity_regressions.py +0 -0
  119. {nextloop-0.5.0rc2 → nextloop-0.7.0}/tests/test_correctness_regressions.py +0 -0
  120. {nextloop-0.5.0rc2 → nextloop-0.7.0}/tests/test_events.py +0 -0
  121. {nextloop-0.5.0rc2 → nextloop-0.7.0}/tests/test_failures.py +0 -0
  122. {nextloop-0.5.0rc2 → nextloop-0.7.0}/tests/test_harness_injection.py +0 -0
  123. {nextloop-0.5.0rc2 → nextloop-0.7.0}/tests/test_loop.py +0 -0
  124. {nextloop-0.5.0rc2 → nextloop-0.7.0}/tests/test_mcp_hardening.py +0 -0
  125. {nextloop-0.5.0rc2 → nextloop-0.7.0}/tests/test_observability.py +0 -0
  126. {nextloop-0.5.0rc2 → nextloop-0.7.0}/tests/test_observability_close_deadline.py +0 -0
  127. {nextloop-0.5.0rc2 → nextloop-0.7.0}/tests/test_preview.py +0 -0
  128. {nextloop-0.5.0rc2 → nextloop-0.7.0}/tests/test_provider_terminal.py +0 -0
  129. {nextloop-0.5.0rc2 → nextloop-0.7.0}/tests/test_providers.py +0 -0
  130. {nextloop-0.5.0rc2 → nextloop-0.7.0}/tests/test_result_budget_regressions.py +0 -0
  131. {nextloop-0.5.0rc2 → nextloop-0.7.0}/tests/test_result_policies.py +0 -0
  132. {nextloop-0.5.0rc2 → nextloop-0.7.0}/tests/test_review_regressions.py +0 -0
  133. {nextloop-0.5.0rc2 → nextloop-0.7.0}/tests/test_stdio_cleanup.py +0 -0
  134. {nextloop-0.5.0rc2 → nextloop-0.7.0}/tests/test_stdio_frames.py +0 -0
  135. {nextloop-0.5.0rc2 → nextloop-0.7.0}/tests/test_stdio_safety.py +0 -0
  136. {nextloop-0.5.0rc2 → nextloop-0.7.0}/tests/test_stores.py +0 -0
  137. {nextloop-0.5.0rc2 → nextloop-0.7.0}/tests/test_surface_snapshot.py +0 -0
  138. {nextloop-0.5.0rc2 → nextloop-0.7.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.5.0rc2
3
+ Version: 0.7.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
@@ -10,6 +10,7 @@ Classifier: Programming Language :: Python :: 3
10
10
  Classifier: Programming Language :: Python :: 3.11
11
11
  Classifier: Programming Language :: Python :: 3.12
12
12
  Classifier: Programming Language :: Python :: 3.13
13
+ Classifier: Programming Language :: Python :: 3.14
13
14
  Classifier: Typing :: Typed
14
15
  Requires-Python: >=3.11
15
16
  Description-Content-Type: text/markdown
@@ -34,12 +35,12 @@ nextloop is an embeddable Python AgentLoop for developers who want to build thei
34
35
 
35
36
  **Your agent, your rules. No magic, no black box.**
36
37
 
37
- Current version: **0.5.0rc2**.
38
+ Current version: **0.7.0**.
38
39
 
39
40
  ## Install
40
41
 
41
42
  ```bash
42
- python -m pip install nextloop==0.5.0rc2
43
+ python -m pip install nextloop==0.7.0
43
44
  ```
44
45
 
45
46
  For local development:
@@ -85,9 +86,14 @@ It is a library, not an HTTP service, product bot, Router, EventBus, or multi-ag
85
86
  ```python
86
87
  AgentLoop.run(TurnContext) -> TurnOutcome
87
88
  AgentLoop.steer(session_id, content, *, input_id=None) -> bool
89
+ AgentLoop.steer_result(session_id, content, *, input_id=None) -> SteerResult
88
90
  AgentLoop.cancel(session_id, cause="user_stop") -> bool
89
- AgentLoop.recover(session_id, store, delivery) -> RecoveryOutcome
91
+ AgentLoop.recover(session_id, store, delivery, *, force=False) -> RecoveryOutcome
90
92
  AgentLoop.pending_inputs(session_id, store) -> tuple[PendingInput, ...]
93
+ AgentLoop.resume(context, *, decisions=None, reject_all=False, new_input=None) -> TurnOutcome
94
+ AgentLoop.retry_operation(context, operation_id) -> TurnOutcome
95
+ AgentLoop.resource_locks(session_id, store) -> frozenset[str]
96
+ AgentLoop.release_resource(session_id, store, resource, *, actor, evidence) -> bool
91
97
  ```
92
98
 
93
99
  Core adapter seams are `EventStore`, `ModelProvider`, `ToolRuntime`, and `DeliveryOwner`. Additional extension points include `PreviewSink`, Exporters, Skills, and stdio/MCP workers. Context projection and Compaction are built in and configured through `LoopConfig`.
@@ -96,14 +102,17 @@ Core adapter seams are `EventStore`, `ModelProvider`, `ToolRuntime`, and `Delive
96
102
 
97
103
  | Area | Guarantee | Not a guarantee |
98
104
  |---|---|---|
99
- | Accepted input | Accepted inputs are projected from the log by `input_id` and can be queried with `AgentLoop.pending_inputs`. | 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. |
100
107
  | Delivery | Delivery is at least once; DeliveryOwner must deduplicate by stable `final_message_id`. | Exactly-once delivery or delivery without an idempotent owner. |
101
- | Tool execution | The library never automatically replays an already dispatched Tool. | No duplicate external effect when a model reissues a call or a Tool is not idempotent. |
102
- | Resource locks | Unresolved uncertain results block later calls sharing declared resources. | Global idempotency across different resources or Tools without resource declarations. |
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. |
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. |
110
+ | Approval | Any approval-required item suspends the whole batch before dispatch. Resume requires explicit decisions, binds original IDs/arguments, and rechecks expiry and prior dispatch inside the Session lock. | Automatic approval, execution before a durable grant, or replay after dispatch without recovery. |
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. |
103
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. |
104
113
  | Preview | Preview is transient and cannot execute partial Tool arguments. | Preview as a durable EventStore fact or a substitute for committed Delivery. |
105
114
  | Observability | Committed Events are authoritative and can be replayed for history. | The current in-memory Exporter queue as a durable outbox. |
106
- | MCP | stdio lifecycle, paginated static catalogs, and uncertain crash handling. | Remote MCP, OAuth, dynamic `listChanged`, or non-text content mapping. |
115
+ | MCP | stdio lifecycle, paginated static catalogs, operation metadata, and uncertain crash handling. | Remote MCP, OAuth, dynamic `listChanged`, or non-text content mapping. |
107
116
 
108
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.
109
118
 
@@ -202,33 +211,41 @@ src/nextloop/
202
211
  events/ # pure projection, response/outcome folds, crash repair
203
212
  execute/ # model retries, Tool registration, batch scheduling
204
213
  adapters/ # SQLite, memory, OpenAI, Anthropic
214
+ testing.py # Store conformance and deterministic fault injection
205
215
  ```
206
216
 
207
217
  `events/` performs no I/O. `execute/` owns side effects and classified failures. `driver.py` only composes them.
208
218
 
209
219
  ## Verification
210
220
 
211
- The release-candidate checks cover:
221
+ The release checks cover:
212
222
 
213
223
  - text, Tool, multi-Step, mixed, empty, truncated, and malformed responses;
214
224
  - whole-batch rejection and parallel/exclusive scheduling with deterministic gates;
215
225
  - steer/final ordering, cancellation, WorkingContext, and Compaction;
216
226
  - protocol exhaustion, exact-byte retry, and partial-output failure;
227
+ - every append point on Memory and SQLite, before and after commit, with recovery and no-replay assertions;
228
+ - Tool/Delivery side-effect failures, writer takeover, late results, parallel partial completion, and repeated recovery;
229
+ - public Store conformance plus deliberately broken Store rejection;
217
230
  - resource-lock recovery, conflict prevention, and explicit release;
218
231
  - real subprocess exits during Tool execution and final delivery, followed by SQLite recovery;
219
232
  - recorded OpenAI and Anthropic SSE streams;
220
233
  - 12 live Kimi scenarios across both protocols, real Tool usage, parallel execution, recovery, steer, cancellation, Compaction, and WorkingContext;
221
234
  - live DeepSeek text + Preview + usage and real Tool Call + Delivery smoke;
222
- - 215 offline tests, `ruff`, `mypy`, wheel/sdist builds, `twine check`, and clean wheel installation.
235
+ - 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.
223
237
 
224
238
  Current limits:
225
239
 
226
240
  - nika integration is separate acceptance work.
227
- - Concurrent writers across multiple processes fail closed; they are not coordinated.
228
- - Large-asset lifecycle, backup, and GC are not part of this release candidate.
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.
243
+ - Official OpenAI and Anthropic API acceptance remains a 1.0 hard gate; recorded streams and DeepSeek do not substitute for it.
229
244
 
230
245
  ## Documents
231
246
 
247
+ - [Architecture and import contract](docs/design/architecture.md)
248
+ - [Domain glossary](CONTEXT.md)
232
249
  - [AgentLoop design](docs/design/agent-loop.md)
233
250
  - [Public interface](docs/design/loop-interface.md)
234
251
  - [Harness and extension interface](docs/design/harness.md)
@@ -236,11 +253,12 @@ Current limits:
236
253
  - [Directory-based SkillRegistry](docs/design/skills.md)
237
254
  - [Verification matrix](docs/design/verification-matrix.md)
238
255
  - [Development plan](docs/architecture/development-plan.md)
256
+ - [Contributing](CONTRIBUTING.md) and [Security](SECURITY.md)
239
257
  - [Changelog](CHANGELOG.md)
240
- - [ADR-0002](docs/adr/0002-dsh-aligned-agent-loop.md), [ADR-0003](docs/adr/0003-python-and-centralized-contracts.md), and [ADR-0005 Pending Input](docs/adr/0005-pending-input.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)
241
259
 
242
260
  ## Release
243
261
 
244
- CI covers Python 3.11, 3.12, and 3.13. A `v*` tag runs the release workflow, which verifies the package, publishes wheel and sdist to PyPI through Trusted Publishing, and creates a GitHub Release.
262
+ CI covers Python 3.11, 3.12, 3.13, and 3.14. A `v*` tag runs the release workflow, which verifies the package and benchmark, publishes wheel and sdist to PyPI through Trusted Publishing, and creates a GitHub Release.
245
263
 
246
264
  This is a public repository. Do not commit credentials, private trajectories, internal endpoints, or personal data.
@@ -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.5.0rc2**.
9
+ Current version: **0.7.0**.
10
10
 
11
11
  ## Install
12
12
 
13
13
  ```bash
14
- python -m pip install nextloop==0.5.0rc2
14
+ python -m pip install nextloop==0.7.0
15
15
  ```
16
16
 
17
17
  For local development:
@@ -57,9 +57,14 @@ 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, ...]
64
+ AgentLoop.resume(context, *, decisions=None, reject_all=False, new_input=None) -> TurnOutcome
65
+ AgentLoop.retry_operation(context, operation_id) -> TurnOutcome
66
+ AgentLoop.resource_locks(session_id, store) -> frozenset[str]
67
+ AgentLoop.release_resource(session_id, store, resource, *, actor, evidence) -> bool
63
68
  ```
64
69
 
65
70
  Core adapter seams are `EventStore`, `ModelProvider`, `ToolRuntime`, and `DeliveryOwner`. Additional extension points include `PreviewSink`, Exporters, Skills, and stdio/MCP workers. Context projection and Compaction are built in and configured through `LoopConfig`.
@@ -68,14 +73,17 @@ Core adapter seams are `EventStore`, `ModelProvider`, `ToolRuntime`, and `Delive
68
73
 
69
74
  | Area | Guarantee | Not a guarantee |
70
75
  |---|---|---|
71
- | Accepted input | Accepted inputs are projected from the log by `input_id` and can be queried with `AgentLoop.pending_inputs`. | 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. |
72
78
  | Delivery | Delivery is at least once; DeliveryOwner must deduplicate by stable `final_message_id`. | Exactly-once delivery or delivery without an idempotent owner. |
73
- | Tool execution | The library never automatically replays an already dispatched Tool. | No duplicate external effect when a model reissues a call or a Tool is not idempotent. |
74
- | Resource locks | Unresolved uncertain results block later calls sharing declared resources. | Global idempotency across different resources or Tools without resource declarations. |
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. |
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. |
81
+ | Approval | Any approval-required item suspends the whole batch before dispatch. Resume requires explicit decisions, binds original IDs/arguments, and rechecks expiry and prior dispatch inside the Session lock. | Automatic approval, execution before a durable grant, or replay after dispatch without recovery. |
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. |
75
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. |
76
84
  | Preview | Preview is transient and cannot execute partial Tool arguments. | Preview as a durable EventStore fact or a substitute for committed Delivery. |
77
85
  | Observability | Committed Events are authoritative and can be replayed for history. | The current in-memory Exporter queue as a durable outbox. |
78
- | MCP | stdio lifecycle, paginated static catalogs, and uncertain crash handling. | Remote MCP, OAuth, dynamic `listChanged`, or non-text content mapping. |
86
+ | MCP | stdio lifecycle, paginated static catalogs, operation metadata, and uncertain crash handling. | Remote MCP, OAuth, dynamic `listChanged`, or non-text content mapping. |
79
87
 
80
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.
81
89
 
@@ -174,33 +182,41 @@ src/nextloop/
174
182
  events/ # pure projection, response/outcome folds, crash repair
175
183
  execute/ # model retries, Tool registration, batch scheduling
176
184
  adapters/ # SQLite, memory, OpenAI, Anthropic
185
+ testing.py # Store conformance and deterministic fault injection
177
186
  ```
178
187
 
179
188
  `events/` performs no I/O. `execute/` owns side effects and classified failures. `driver.py` only composes them.
180
189
 
181
190
  ## Verification
182
191
 
183
- The release-candidate checks cover:
192
+ The release checks cover:
184
193
 
185
194
  - text, Tool, multi-Step, mixed, empty, truncated, and malformed responses;
186
195
  - whole-batch rejection and parallel/exclusive scheduling with deterministic gates;
187
196
  - steer/final ordering, cancellation, WorkingContext, and Compaction;
188
197
  - protocol exhaustion, exact-byte retry, and partial-output failure;
198
+ - every append point on Memory and SQLite, before and after commit, with recovery and no-replay assertions;
199
+ - Tool/Delivery side-effect failures, writer takeover, late results, parallel partial completion, and repeated recovery;
200
+ - public Store conformance plus deliberately broken Store rejection;
189
201
  - resource-lock recovery, conflict prevention, and explicit release;
190
202
  - real subprocess exits during Tool execution and final delivery, followed by SQLite recovery;
191
203
  - recorded OpenAI and Anthropic SSE streams;
192
204
  - 12 live Kimi scenarios across both protocols, real Tool usage, parallel execution, recovery, steer, cancellation, Compaction, and WorkingContext;
193
205
  - live DeepSeek text + Preview + usage and real Tool Call + Delivery smoke;
194
- - 215 offline tests, `ruff`, `mypy`, wheel/sdist builds, `twine check`, and clean wheel installation.
206
+ - 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.
195
208
 
196
209
  Current limits:
197
210
 
198
211
  - nika integration is separate acceptance work.
199
- - Concurrent writers across multiple processes fail closed; they are not coordinated.
200
- - Large-asset lifecycle, backup, and GC are not part of this release candidate.
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.
214
+ - Official OpenAI and Anthropic API acceptance remains a 1.0 hard gate; recorded streams and DeepSeek do not substitute for it.
201
215
 
202
216
  ## Documents
203
217
 
218
+ - [Architecture and import contract](docs/design/architecture.md)
219
+ - [Domain glossary](CONTEXT.md)
204
220
  - [AgentLoop design](docs/design/agent-loop.md)
205
221
  - [Public interface](docs/design/loop-interface.md)
206
222
  - [Harness and extension interface](docs/design/harness.md)
@@ -208,11 +224,12 @@ Current limits:
208
224
  - [Directory-based SkillRegistry](docs/design/skills.md)
209
225
  - [Verification matrix](docs/design/verification-matrix.md)
210
226
  - [Development plan](docs/architecture/development-plan.md)
227
+ - [Contributing](CONTRIBUTING.md) and [Security](SECURITY.md)
211
228
  - [Changelog](CHANGELOG.md)
212
- - [ADR-0002](docs/adr/0002-dsh-aligned-agent-loop.md), [ADR-0003](docs/adr/0003-python-and-centralized-contracts.md), and [ADR-0005 Pending Input](docs/adr/0005-pending-input.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)
213
230
 
214
231
  ## Release
215
232
 
216
- CI covers Python 3.11, 3.12, and 3.13. A `v*` tag runs the release workflow, which verifies the package, publishes wheel and sdist to PyPI through Trusted Publishing, and creates a GitHub Release.
233
+ CI covers Python 3.11, 3.12, 3.13, and 3.14. A `v*` tag runs the release workflow, which verifies the package and benchmark, publishes wheel and sdist to PyPI through Trusted Publishing, and creates a GitHub Release.
217
234
 
218
235
  This is a public repository. Do not commit credentials, private trajectories, internal endpoints, or personal data.
@@ -8,7 +8,7 @@
8
8
 
9
9
  ### Language and dependencies
10
10
 
11
- - Python 3.11+ with native `asyncio`; CI covers 3.11, 3.12, and 3.13.
11
+ - Python 3.11+ with native `asyncio`; CI covers 3.11, 3.12, 3.13, and 3.14.
12
12
  - Standard-library `dataclasses`, `typing`, and `sqlite3`.
13
13
  - `httpx` for Provider HTTP/SSE and `jsonschema` for Tool argument validation.
14
14
  - `pytest` and `pytest-asyncio` for tests; `ruff` and `mypy` for static checks.
@@ -0,0 +1,27 @@
1
+ # ADR-0004: Event compatibility and read-only upcasting
2
+
3
+ Status: accepted
4
+
5
+ ## Context
6
+
7
+ nextloop 0.5.0 writes Event schema 1.0. The 0.6 operation identity, approval, and Compaction lineage work adds payload fields without changing the Event envelope. Compatibility must not rewrite history, silently accept a future schema, or compare upcast payloads as if they were original bytes.
8
+
9
+ ## Decision
10
+
11
+ New Events are written as schema 1.1. Stores accept 1.0 history and upcast it only while loading. Unknown schema versions fail closed with `InvariantViolation`; older readers that only understand 1.0 therefore cannot read a 1.1 Session.
12
+
13
+ - Upcasting is a pure, deterministic, idempotent function. No Store UPDATE or rewrite is part of loading.
14
+ - The original stored payload and event ID remain authoritative for idempotent append comparison. Comparing a draft with an upcast representation is not equivalent to comparing original bytes and is rejected when they differ.
15
+ - A schema-1.0 TOOL_CALL without `operation_id` receives a deterministic ID derived from `session_id`, `turn`, `step`, and `call_id`. The same coordinates in ASSISTANT_MESSAGE Tool Calls receive the same ID; identical call IDs in different Steps receive different IDs.
16
+ - A schema-1.0 COMPACTION without lineage receives `source_seqs=None`. No exact source range is fabricated.
17
+ - Projection, Trace, and Recovery consume upcast Events; idempotent append uses the stored, non-upcast representation.
18
+ - The reserved single-key payload `{"_nextloop_erased": True}` denotes erased content for future retention work. Reusing that event ID raises `PayloadErasedError` without comparing payload content. No content hash is retained for low-entropy PII, and event-level erasure itself is outside 0.6.
19
+ - Every released schema has a real Store fixture produced by that release. The 1.0 fixture contains normal multi-Step Tool Calls with a repeated call ID, Compaction, and an interrupted Tool Call. New readers must preserve raw fixture bytes while loading and upcasting.
20
+
21
+ ## Consequences
22
+
23
+ - Old 1.0 logs remain readable without a migration write or downtime.
24
+ - New 1.1 logs are intentionally not readable by 0.5.0 and earlier.
25
+ - Read-time compatibility does not weaken append idempotency or future-version checks.
26
+ - Operation identity for legacy calls is deterministic and coordinate-scoped. New operation IDs introduced in 0.6 are persisted facts, not regenerated during recovery.
27
+ - Payload erasure has a fail-closed identity rule without prematurely implementing deletion or retaining PII hashes.
@@ -13,13 +13,14 @@ The event log is the sole source of truth. The actor inbox is only a wake-up sig
13
13
  - Scan INPUT_ACCEPTED and USER_MESSAGE in seq order and match them by `input_id`.
14
14
  - Accepted inputs without a corresponding USER_MESSAGE are Pending Input.
15
15
  - Compute Pending Input at the start of each Turn. Recovery never writes the actor inbox.
16
+ - A new Turn commits recovered Pending as USER_MESSAGE at its first Step boundary. This consumption fact is required; injecting Pending only into a Provider request would leave it pending forever.
16
17
  - Pending historical inputs appear before the new Turn's initial_input. Inputs accepted during approval suspension appear only after the corresponding Tool results.
17
18
  - Inputs from cancelled or budget-terminated Turns carry into the next Turn by default.
18
19
  - Active execution also uses the log's consumption state, so an input present in both the log and actor inbox is injected once.
19
20
  - Pending is queryable with `input_id`, original seq, original Turn, and content. No cleanup event is introduced in this version.
20
21
  - `recover()` may be called repeatedly without duplicating Pending. A crash between recover and run has the same projection.
21
22
 
22
- `input_id` is the idempotency boundary. A caller retrying initial input or steer must supply the same `input_id`, or query Pending before retrying. An absent or automatically generated ID does not provide cross-crash deduplication.
23
+ `input_id` is the idempotency boundary. A caller retrying initial input or steer must supply the same `input_id`, or query Pending before retrying. An absent or automatically generated ID does not provide cross-crash deduplication. Explicit IDs must be non-empty. The same ID with identical content is a no-op retry; the same ID with different content is rejected before a new INPUT_ACCEPTED is committed, so the original Pending content is preserved.
23
24
 
24
25
  No cleanup event is introduced. Pending remains visible until the caller consumes it or the protocol later defines an explicit discard fact.
25
26
 
@@ -0,0 +1,24 @@
1
+ # ADR-0006: Operation identity and Tool effects
2
+
3
+ Status: accepted
4
+
5
+ ## Context
6
+
7
+ A model can issue the same Tool Call again after an uncertain result. Without a persisted logical operation identity and an explicit effect declaration, the runtime cannot distinguish a new intent from a safe same-operation reconciliation.
8
+
9
+ ## Decision
10
+
11
+ - Every admitted assistant Tool Intent receives a new `operation_id` when ASSISTANT_MESSAGE is committed. TOOL_CALL, ToolContext, Tool Result, Trace, recovery, MCP, and stdio preserve that same ID. A new model intent receives a new ID even when `call_id`, Tool name, and arguments repeat.
12
+ - `ToolEffect = READ_ONLY | IDEMPOTENT | NON_IDEMPOTENT`; the default is NON_IDEMPOTENT. IDEMPOTENT means repeated or concurrent execution with the same operation ID has the same external effect as one execution.
13
+ - Declared `resources` continue to control normal conflict checks. A separate `uncertain_resources` projection is used only after uncertain execution: explicit resources win; otherwise NON_IDEMPOTENT uses the Tool name. This default does not serialize normal parallel scheduling.
14
+ - `AgentLoop.resource_locks(session_id, store)` and `release_resource(...)` expose log-derived lock state. Release writes an Event with actor and caller evidence rather than mutating a side table.
15
+ - `AgentLoop.retry_operation(context, operation_id)` is an explicit new Turn. Only READ_ONLY and IDEMPOTENT operations are eligible; NON_IDEMPOTENT is rejected. The caller accepts that the original hanging operation may still run concurrently.
16
+ - Reconciliation executes the original Tool and arguments with the original operation ID. It emits a Reconciliation Result notification linked to the original coordinate, never a second Tool Result at that coordinate. Success releases corresponding locks; another uncertain result retains them. The library never automatically retries.
17
+ - Harness TOML `effect` is explicit configuration. `nextloop check` reports a migration warning when it is absent. MCP annotations are untrusted hints and do not choose the effect.
18
+
19
+ ## Consequences
20
+
21
+ - Default uncertainty becomes visible for side-effecting Tools that declare no resources; this is an intentional breaking change.
22
+ - Explicit resource-based parallelism is unchanged.
23
+ - Reconciliation is auditable and does not rewrite old history or create ambiguous duplicate Results.
24
+ - Caller-provided idempotency is a semantic contract, not a hint the library can verify.
@@ -0,0 +1,25 @@
1
+ # ADR-0007: Approval suspension and cross-Turn resume
2
+
3
+ Status: accepted
4
+
5
+ ## Context
6
+
7
+ TOOL_CALL is a dispatch-boundary fact, not a Tool Intent. Approval must be decided before side effects and must survive crashes without changing original operation identity or arguments.
8
+
9
+ ## Decision
10
+
11
+ - `ApprovalPolicy(version, predicate=None, expires_after_seconds=None)` is a ToolSpec declaration. A missing policy needs no approval; a missing predicate always requires it; a predicate is a pure argument callback.
12
+ - If any call in a validated batch requires approval, Tool Intent and APPROVAL_REQUESTED commit atomically and the entire batch waits before its first TOOL_CALL. The request binds operation IDs, canonical arguments, policy versions, Event schema, and optional expiry.
13
+ - The waiting Turn ends with `approval_pending`. A crash closer must not turn undispatched approval intents into Skipped Results. New `run()` input and `steer()` are rejected while suspended; `cancel()` writes cancellation and invalidates the approval.
14
+ - `resume()` uses a new Turn and tail-conditional append. Decisions bind operation IDs. Any rejection or expiry rejects the whole batch; all approvals preserve the original parallel/exclusive order.
15
+ - APPROVAL_GRANTED commits before dispatch. A crash after permission but before TOOL_CALL can be resumed without another side effect. TOOL_CALL after permission follows ordinary uncertain recovery.
16
+ - Results physically append in the resume Turn and carry `origin_turn/origin_step`. Projection, Trace, and Recovery pair them to the original Tool Intent without rewriting the original coordinate.
17
+ - Rejected calls produce Skipped Results in the resume Turn, followed by new input. `resume(reject_all=True, new_input=...)` is the exit path.
18
+ - Expiry is evaluated lazily at resume, never by a background timer. Resume uses fresh Turn budgets and deadlines. Concurrent resume is serialized by the Session actor and revalidated against the log.
19
+
20
+ ## Consequences
21
+
22
+ - Approval cannot produce side effects before a durable permission fact.
23
+ - Permission and dispatch are separate crash windows with explicit recovery behavior.
24
+ - Original IDs and arguments survive across Turns; model projection sees Results before new Pending input.
25
+ - Approval waiting time is not Tool execution time.
@@ -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,71 @@
1
+ # nextloop development and verification plan
2
+
3
+ Current stage: **0.7.0 release verification**. `0.6.0` is published; later milestones are not claimed as implemented.
4
+
5
+ ## Delivery order
6
+
7
+ ```text
8
+ 0.5.0rc2: Pending Input recovery and guarantee documentation
9
+ → 0.5.0: fault matrix, Store conformance, 10k benchmark, Python 3.14, import contract
10
+ → 0.6: upcasting, operation_id, approval/resume, Compaction source ranges
11
+ → 0.7: opt-in owner leases and persistent Pending behavior
12
+ → 0.8: caller-driven durable Outbox and OTel ID mapping
13
+ → 0.9: reentrant whole-Session deletion and tombstones
14
+ → 1.0: all hard gates and official OpenAI/Anthropic acceptance
15
+ ```
16
+
17
+ Each stage requires an independent Standards / Spec / Risk review, complete regression gates, and a separate release. A design or ADR is not accepted evidence until its fault scenarios pass.
18
+
19
+ ## 0.5.0 — falsification and frozen integration paths
20
+
21
+ - `nextloop.testing` provides Store, ToolRuntime, and DeliveryOwner fault injection, including after-side-effect and after-commit failures.
22
+ - The standard Tool + steer + final scenario traverses every append point on Memory and SQLite, before and after commit, and verifies seq, Pending, resource locks, Delivery, and no Tool replay.
23
+ - Explicit scenarios cover writer takeover before dispatch, late Tool results, parallel partial completion, Compaction, and repeated recovery.
24
+ - `check_event_store()` accepts both built-in Stores and rejects unchecked writers, duplicate event IDs, and incorrect Surface implementations.
25
+ - A 10,505-event benchmark checks Memory/SQLite Conversation Projection parity and incremental/whole-history Trace parity while reporting timings.
26
+ - CI covers Python 3.11, 3.12, 3.13, and 3.14.
27
+ - Existing root re-exports and core/extras module paths are frozen without a physical package split.
28
+
29
+ See [Architecture and import contract](../design/architecture.md), [Verification matrix](../design/verification-matrix.md), and [CONTRIBUTING](../../CONTRIBUTING.md).
30
+
31
+ ## 0.6 — explicit operation and approval semantics
32
+
33
+ - Versioned, read-only Event upcasting with real historical fixtures and fail-fast unknown versions.
34
+ - `operation_id` is created and persisted with Tool Intent; new model intent receives a new ID.
35
+ - `ToolEffect = READ_ONLY | IDEMPOTENT | NON_IDEMPOTENT`, defaulting to NON_IDEMPOTENT. Default Tool-name locking applies only to unresolved uncertain outcomes and is an explicit breaking change.
36
+ - Explicit same-ID reconciliation is allowed only for READ_ONLY and IDEMPOTENT operations. It creates a Reconciliation Result notification, never a second Tool Result at the original coordinate.
37
+ - Approval distinguishes Tool Intent from dispatch, binds canonical arguments and policy versions, and uses conditional append. Approval precedes side effects; resume uses original IDs and arguments in a new Turn.
38
+ - Compaction records source seq ranges and cannot split a Tool Intent from its result.
39
+
40
+ ## 0.7 — opt-in writer leases
41
+
42
+ - `owner_id` remains optional; existing `attach_writer` behavior stays unchanged when leases are not configured.
43
+ - Same-owner restart can take over immediately. Different owners wait for expiry or explicit forced takeover.
44
+ - Store time determines expiry; heartbeat renewal is independent. Every actual dispatch retains a writer/lease check.
45
+ - SQLite promises same-host multi-process behavior only. Late results from stale writers are discarded and remain uncertain.
46
+ - Existing `steer() -> bool` remains compatible; `steer_result()` adds explicit rejection reasons.
47
+
48
+ ## 0.8 — durable, caller-driven Outbox
49
+
50
+ - Export state and cursors live outside the Event log and do not consume writer epochs.
51
+ - `export_pending(session_id=None)` is caller-driven and can enumerate Sessions with unexported closed Turns without starting recovery.
52
+ - Watermarks advance only after durable Export acknowledgement. Bounded retries record auditable gaps rather than blocking forever or pretending success.
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
+
55
+ ## 0.9 — whole-Session deletion
56
+
57
+ - Deletion first commits a deleting tombstone and fences writers, then deletes primary and derived local state. Interrupted deletion is reentrant.
58
+ - A Session-ID-only tombstone prevents recreation. Event-level erasure and external blob reference counting are excluded.
59
+ - SQLite verification scans DB, WAL, SHM, and rollback-journal bytes with synthetic canaries. Third-party exports and user backups are not covered.
60
+
61
+ ## 1.0 hard gates
62
+
63
+ - All Store, ToolRuntime, DeliveryOwner, negative-conformance, takeover, and recovery scenarios pass.
64
+ - The 10k benchmark and parity checks pass.
65
+ - Python 3.14 CI passes.
66
+ - Official OpenAI and Anthropic API acceptance passes. Missing official credentials blocks 1.0; DeepSeek is not a substitute.
67
+ - Documentation, ADRs, migration notes, guarantee tables, and actual behavior agree.
68
+
69
+ ## Explicit non-goals through 1.0
70
+
71
+ No streaming `async for` API, OTel Exporter implementation, remote MCP/OAuth, additional Providers, `@tool` decorator, agent-as-Tool framework, Postgres implementation, physical core/extras split, automatic replay, in-place same-Turn resume, event-level erasure, or external blob lifecycle.
@@ -0,0 +1,50 @@
1
+ # nextloop discussion and delivery roadmap
2
+
3
+ Purpose: preserve the accepted direction and remaining decision boundaries without duplicating nika's product roadmap.
4
+
5
+ Current entry: **0.5.0 falsification and integration-contract closure**. The executable implementation plan is [development-plan.md](development-plan.md).
6
+
7
+ ## Fixed guardrails
8
+
9
+ - One embeddable Loop, not a service or multi-agent framework.
10
+ - Append-only Trajectory is authoritative; Conversation and Traces are derived.
11
+ - Whole-batch validation precedes every Tool side effect.
12
+ - TOOL_CALL precedes dispatch, and a writer check follows that commit immediately before execution.
13
+ - Unknown effects stop new dispatch and are never automatically replayed.
14
+ - Every exit has one finalization path; committed finals recover by Delivery only.
15
+ - Pending Input is derived from the Event log; in-memory inboxes do not become a second authority.
16
+ - Provider connection configuration stays outside Trajectory.
17
+ - No Feishu, Wiki, concrete product Tools, or Proactive product policy in nextloop.
18
+
19
+ ## Topic closure
20
+
21
+ | Topic | Accepted direction | Current state |
22
+ |---|---|---|
23
+ | Execution and ReAct | Turn/Step driver, bounded correction, ordered steer, common finalization | Implemented; normal and terminal behavior covered |
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
+ | 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 |
31
+ | Retention | Reentrant whole-Session deletion with tombstones | 0.9, not currently claimed |
32
+ | Consumer integration | Public versioned Adapters; nika is a consumer, not a dependency | Separate acceptance |
33
+ | Release | Python 3.11–3.14, frozen imports, fault matrix, benchmark, official API gates | 0.5 verifies engineering; official OpenAI/Anthropic acceptance blocks 1.0 |
34
+
35
+ ## Decision order
36
+
37
+ 1. Falsify current guarantees before freezing them.
38
+ 2. Add operation identity and approval before changing writer ownership.
39
+ 3. Add leases before promising coordinated multi-process behavior.
40
+ 4. Add persistent export acknowledgement before calling Traces durable.
41
+ 5. Add tombstones before promising deletion.
42
+ 6. Require official Provider evidence before 1.0.
43
+
44
+ The [verification matrix](../design/verification-matrix.md) is the executable checklist. Documentation alone never marks a requirement implemented.
45
+
46
+ ## Integration links
47
+
48
+ - [nika](https://github.com/12bitsD/nika) independently owns personal-agent behavior, Feishu, AgentWiki, Skills, Prompts, deployment, and Proactive behavior.
49
+ - [ADR-0002](../adr/0002-dsh-aligned-agent-loop.md) records the DSH-aligned decision and deltas.
50
+ - [Open-source evaluation](../research/2026-11-06-open-source-agent-loops.md) preserves the earlier candidate comparison.
@@ -0,0 +1,34 @@
1
+ # nextloop feature worklist
2
+
3
+ Purpose: distinguish implemented capabilities from remaining work. Executable evidence is owned by the [verification matrix](../design/verification-matrix.md).
4
+
5
+ ## Implemented in the current 0.7 line
6
+
7
+ | Feature | Implementation | Evidence |
8
+ |---|---|---|
9
+ | Turn/Step driver | 4D coordinates, append-only Events, thin orchestration | Text, Tool, multi-Step, cancellation, final-order, and budget tests |
10
+ | Response protocol | Bounded correction, terminal failures, exact-byte retry | Empty, truncated, malformed, exhaustion, retry, and partial-output tests |
11
+ | Tool scheduling | Whole-batch Schema validation, bounded parallel calls, exclusive barriers | Zero-side-effect rejection, concurrency gates, ordering, and truncation tests |
12
+ | Recovery | Crash closers, explicit uncertainty, resource locks, delivery-only retry | Every-append fault matrix, real process exits, takeover, late-result, and repeated-recovery tests |
13
+ | Pending Input | Log projection by `input_id`, query API, Step-boundary consumption | Accepted/not-consumed windows, duplicate recovery, retry, cancellation, and next-Turn tests |
14
+ | Context | Append-only projection, WorkingContext, Compaction, result preview/page/full | Projection parity, compaction, UTF-8 paging, read-back, and capacity tests |
15
+ | EventStore | Memory and SQLite, atomic conditional append, idempotency, writer checks | Public conformance plus deliberately broken Store rejection |
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 |
18
+ | Operation identity | operation_id, ToolEffect, resource locks, explicit Reconciliation | End-to-end propagation, dynamic locks, repeated/concurrent retry, and no-replay evidence |
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
+ | Providers | OpenAI-compatible and Anthropic streaming adapters | Recorded protocol streams plus separately identified live-provider smoke |
21
+ | Observability | Model/Tool/Turn Trace DTOs, async Exporters, history | Live/history parity, failure isolation, bounded close, and 10k incremental parity |
22
+ | Integrations | Harness, directory Skills, stdio workers, MCP stdio | Offline diagnostics, subprocess conformance, lifecycle, and clean-wheel examples |
23
+ | 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
+ ## Remaining work
26
+
27
+ | Feature | Target and boundary |
28
+ |---|---|
29
+ | Durable Outbox | 0.8; caller-driven export, persistent acknowledgement, auditable gaps |
30
+ | Whole-Session deletion | 0.9; tombstones and local derived-state cleanup |
31
+ | Official OpenAI/Anthropic acceptance | 1.0 hard gate; recorded streams and DeepSeek do not substitute |
32
+ | nika product integration | Separate consumer acceptance; no Feishu/Wiki dependency enters nextloop |
33
+ | Large external-asset lifecycle | Not claimed; current large Tool Results remain in the EventStore |
34
+ | Remote MCP/OAuth and more Providers | Explicitly outside the 1.0 plan |
@@ -17,11 +17,11 @@ This map records reusable execution requirements and verification ownership. No
17
17
  | L11 | Make Tool implementations replaceable behind one contract | [ToolRuntime](../design/loop-interface.md#toolruntime) | **Generic design closed.** Consumer Schemas, resources, cancellation, unknown and assets conformance |
18
18
  | L12 | Keep one append-only event authority and derive Conversation | [Event model](../design/agent-loop.md#8-event-model-and-transaction-groups) | **Design closed.** Field schema, seq, idempotency, lease/fence, transactions and malformed history |
19
19
  | L13 | Recover from every commit window without replaying side effects | [Recovery](../design/agent-loop.md#9-recovery-and-delivery) | **Design closed.** Process-exit matrix, stale leases and persistent resource tests |
20
- | L14 | Preserve large outputs and their references | [Content access](../design/context-builder.md#content-access-and-task-performance) | **Open implementation.** Asset identity, preview, retrieval, retention, backup and GC |
20
+ | L14 | Preserve large outputs and their references | [Content access](../design/context-builder.md#content-access-and-task-performance) | **Partially implemented.** Durable full Tool Results, bounded preview/page projections, and read-back are verified; backup, GC, and external-asset lifecycle remain open |
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
- | L16 | Prove consumer independence through public Adapters | [Loop interface](../design/loop-interface.md) | **Open.** Fake and nika Adapters pass the same suite with no Feishu/Wiki dependency |
23
- | L18 | Load third-party instruction Skills from directories on demand | [SkillRegistry](../design/skills.md) | **Implemented for 0.2.0rc1.** 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.2.0rc1 implemented.** Tests, static checks, wheel/sdist and clean-install verification pass; CI publication and consumer smoke remain separate |
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
+ | 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 |
25
25
 
26
26
  ## Independence rule
27
27