nextloop 0.3.0rc2__tar.gz → 0.5.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 (128) hide show
  1. nextloop-0.5.0/PKG-INFO +256 -0
  2. nextloop-0.5.0/README.md +227 -0
  3. {nextloop-0.3.0rc2 → nextloop-0.5.0}/docs/adr/0003-python-and-centralized-contracts.md +1 -1
  4. nextloop-0.5.0/docs/adr/0005-pending-input.md +32 -0
  5. nextloop-0.5.0/docs/architecture/development-plan.md +71 -0
  6. nextloop-0.5.0/docs/architecture/discussion-roadmap.md +50 -0
  7. nextloop-0.5.0/docs/architecture/feature-worklist.md +34 -0
  8. {nextloop-0.3.0rc2 → nextloop-0.5.0}/docs/architecture/requirements.md +4 -4
  9. {nextloop-0.3.0rc2 → nextloop-0.5.0}/docs/design/agent-loop.md +38 -28
  10. nextloop-0.5.0/docs/design/architecture.md +69 -0
  11. nextloop-0.5.0/docs/design/harness.md +173 -0
  12. {nextloop-0.3.0rc2 → nextloop-0.5.0}/docs/design/loop-interface.md +16 -8
  13. nextloop-0.5.0/docs/design/verification-matrix.md +91 -0
  14. nextloop-0.5.0/docs/research/2026-11-10-nextloop-optimization-review.md +197 -0
  15. {nextloop-0.3.0rc2 → nextloop-0.5.0}/examples/harness-skills/echo/SKILL.md +1 -1
  16. {nextloop-0.3.0rc2 → nextloop-0.5.0}/examples/harness.toml +1 -1
  17. {nextloop-0.3.0rc2 → nextloop-0.5.0}/pyproject.toml +2 -1
  18. {nextloop-0.3.0rc2 → nextloop-0.5.0}/src/nextloop/__init__.py +50 -0
  19. nextloop-0.5.0/src/nextloop/adapters/__init__.py +14 -0
  20. {nextloop-0.3.0rc2 → nextloop-0.5.0}/src/nextloop/adapters/anthropic.py +74 -9
  21. {nextloop-0.3.0rc2 → nextloop-0.5.0}/src/nextloop/adapters/memory.py +25 -15
  22. nextloop-0.5.0/src/nextloop/adapters/observing.py +282 -0
  23. {nextloop-0.3.0rc2 → nextloop-0.5.0}/src/nextloop/adapters/openai.py +66 -9
  24. {nextloop-0.3.0rc2 → nextloop-0.5.0}/src/nextloop/adapters/sqlite.py +15 -1
  25. {nextloop-0.3.0rc2 → nextloop-0.5.0}/src/nextloop/contracts.py +169 -3
  26. {nextloop-0.3.0rc2 → nextloop-0.5.0}/src/nextloop/driver.py +195 -9
  27. {nextloop-0.3.0rc2 → nextloop-0.5.0}/src/nextloop/events/__init__.py +3 -0
  28. {nextloop-0.3.0rc2 → nextloop-0.5.0}/src/nextloop/events/outcome.py +128 -9
  29. nextloop-0.5.0/src/nextloop/events/pending.py +25 -0
  30. {nextloop-0.3.0rc2 → nextloop-0.5.0}/src/nextloop/events/project.py +13 -0
  31. {nextloop-0.3.0rc2 → nextloop-0.5.0}/src/nextloop/events/repair.py +14 -7
  32. nextloop-0.5.0/src/nextloop/events/trace.py +351 -0
  33. {nextloop-0.3.0rc2 → nextloop-0.5.0}/src/nextloop/execute/batch.py +47 -13
  34. nextloop-0.5.0/src/nextloop/execute/cancellation.py +29 -0
  35. nextloop-0.5.0/src/nextloop/execute/cleanup.py +22 -0
  36. {nextloop-0.3.0rc2 → nextloop-0.5.0}/src/nextloop/execute/composite.py +9 -3
  37. nextloop-0.5.0/src/nextloop/execute/mcp.py +207 -0
  38. nextloop-0.5.0/src/nextloop/execute/model.py +237 -0
  39. nextloop-0.5.0/src/nextloop/execute/preview.py +207 -0
  40. nextloop-0.5.0/src/nextloop/execute/result_read.py +99 -0
  41. nextloop-0.5.0/src/nextloop/execute/stdio.py +219 -0
  42. nextloop-0.3.0rc2/src/nextloop/execute/stdio.py → nextloop-0.5.0/src/nextloop/execute/stdio_transport.py +90 -208
  43. {nextloop-0.3.0rc2 → nextloop-0.5.0}/src/nextloop/execute/tools.py +7 -20
  44. {nextloop-0.3.0rc2 → nextloop-0.5.0}/src/nextloop/harness.py +197 -54
  45. {nextloop-0.3.0rc2 → nextloop-0.5.0}/src/nextloop/loop.py +49 -1
  46. nextloop-0.5.0/src/nextloop/testing.py +308 -0
  47. nextloop-0.5.0/src/nextloop.egg-info/PKG-INFO +256 -0
  48. {nextloop-0.3.0rc2 → nextloop-0.5.0}/src/nextloop.egg-info/SOURCES.txt +32 -0
  49. nextloop-0.5.0/tests/test_budgets.py +228 -0
  50. {nextloop-0.3.0rc2 → nextloop-0.5.0}/tests/test_cli.py +1 -1
  51. nextloop-0.5.0/tests/test_complexity_regressions.py +56 -0
  52. nextloop-0.5.0/tests/test_correctness_regressions.py +174 -0
  53. nextloop-0.5.0/tests/test_fault_injection.py +131 -0
  54. nextloop-0.5.0/tests/test_fault_matrix.py +247 -0
  55. {nextloop-0.3.0rc2 → nextloop-0.5.0}/tests/test_harness.py +1 -1
  56. nextloop-0.5.0/tests/test_harness_injection.py +87 -0
  57. nextloop-0.5.0/tests/test_import_contract.py +203 -0
  58. nextloop-0.5.0/tests/test_mcp.py +169 -0
  59. nextloop-0.5.0/tests/test_mcp_hardening.py +84 -0
  60. nextloop-0.5.0/tests/test_observability.py +800 -0
  61. nextloop-0.5.0/tests/test_observability_close_deadline.py +53 -0
  62. nextloop-0.5.0/tests/test_pending_inputs.py +290 -0
  63. nextloop-0.5.0/tests/test_preview.py +178 -0
  64. nextloop-0.5.0/tests/test_projection_parity.py +17 -0
  65. nextloop-0.5.0/tests/test_provider_terminal.py +105 -0
  66. nextloop-0.5.0/tests/test_result_budget_regressions.py +51 -0
  67. nextloop-0.5.0/tests/test_result_policies.py +168 -0
  68. nextloop-0.5.0/tests/test_review_regressions.py +205 -0
  69. {nextloop-0.3.0rc2 → nextloop-0.5.0}/tests/test_skills.py +1 -1
  70. nextloop-0.5.0/tests/test_store_contract.py +81 -0
  71. nextloop-0.5.0/tests/test_surface_snapshot.py +70 -0
  72. nextloop-0.3.0rc2/PKG-INFO +0 -170
  73. nextloop-0.3.0rc2/README.md +0 -142
  74. nextloop-0.3.0rc2/docs/architecture/development-plan.md +0 -47
  75. nextloop-0.3.0rc2/docs/architecture/discussion-roadmap.md +0 -53
  76. nextloop-0.3.0rc2/docs/architecture/feature-worklist.md +0 -30
  77. nextloop-0.3.0rc2/docs/design/harness.md +0 -91
  78. nextloop-0.3.0rc2/docs/design/verification-matrix.md +0 -93
  79. nextloop-0.3.0rc2/src/nextloop/adapters/__init__.py +0 -6
  80. nextloop-0.3.0rc2/src/nextloop/execute/cleanup.py +0 -17
  81. nextloop-0.3.0rc2/src/nextloop/execute/model.py +0 -134
  82. nextloop-0.3.0rc2/src/nextloop.egg-info/PKG-INFO +0 -170
  83. {nextloop-0.3.0rc2 → nextloop-0.5.0}/LICENSE +0 -0
  84. {nextloop-0.3.0rc2 → nextloop-0.5.0}/MANIFEST.in +0 -0
  85. {nextloop-0.3.0rc2 → nextloop-0.5.0}/docs/adr/0001-embeddable-agent-loop.md +0 -0
  86. {nextloop-0.3.0rc2 → nextloop-0.5.0}/docs/adr/0002-dsh-aligned-agent-loop.md +0 -0
  87. {nextloop-0.3.0rc2 → nextloop-0.5.0}/docs/architecture/agent-loop-capability-review.md +0 -0
  88. {nextloop-0.3.0rc2 → nextloop-0.5.0}/docs/design/context-builder.md +0 -0
  89. {nextloop-0.3.0rc2 → nextloop-0.5.0}/docs/design/react-protocol.md +0 -0
  90. {nextloop-0.3.0rc2 → nextloop-0.5.0}/docs/design/skills.md +0 -0
  91. {nextloop-0.3.0rc2 → nextloop-0.5.0}/docs/research/2026-11-02-dsh-primary-sources.md +0 -0
  92. {nextloop-0.3.0rc2 → nextloop-0.5.0}/docs/research/2026-11-02-loop-evidence-notes.md +0 -0
  93. {nextloop-0.3.0rc2 → nextloop-0.5.0}/docs/research/2026-11-03-hermes-turn-control.md +0 -0
  94. {nextloop-0.3.0rc2 → nextloop-0.5.0}/docs/research/2026-11-03-tool-batch-failures.md +0 -0
  95. {nextloop-0.3.0rc2 → nextloop-0.5.0}/docs/research/2026-11-03-tool-call-validation.md +0 -0
  96. {nextloop-0.3.0rc2 → nextloop-0.5.0}/docs/research/2026-11-03-yomi-turn-control.md +0 -0
  97. {nextloop-0.3.0rc2 → nextloop-0.5.0}/docs/research/2026-11-06-open-source-agent-loops.md +0 -0
  98. {nextloop-0.3.0rc2 → nextloop-0.5.0}/docs/research/2026-11-06-react-tool-event-recovery.md +0 -0
  99. {nextloop-0.3.0rc2 → nextloop-0.5.0}/examples/basic.py +0 -0
  100. {nextloop-0.3.0rc2 → nextloop-0.5.0}/examples/live_smoke.py +0 -0
  101. {nextloop-0.3.0rc2 → nextloop-0.5.0}/examples/python_tools.py +0 -0
  102. {nextloop-0.3.0rc2 → nextloop-0.5.0}/examples/skills/coding/SKILL.md +0 -0
  103. {nextloop-0.3.0rc2 → nextloop-0.5.0}/examples/skills_demo.py +0 -0
  104. {nextloop-0.3.0rc2 → nextloop-0.5.0}/examples/workers/cpp_worker.cpp +0 -0
  105. {nextloop-0.3.0rc2 → nextloop-0.5.0}/examples/workers/python_worker.py +0 -0
  106. {nextloop-0.3.0rc2 → nextloop-0.5.0}/examples/workers/rust_worker.rs +0 -0
  107. {nextloop-0.3.0rc2 → nextloop-0.5.0}/setup.cfg +0 -0
  108. {nextloop-0.3.0rc2 → nextloop-0.5.0}/src/nextloop/adapters/_sse.py +0 -0
  109. {nextloop-0.3.0rc2 → nextloop-0.5.0}/src/nextloop/cli.py +0 -0
  110. {nextloop-0.3.0rc2 → nextloop-0.5.0}/src/nextloop/events/response.py +0 -0
  111. {nextloop-0.3.0rc2 → nextloop-0.5.0}/src/nextloop/execute/__init__.py +0 -0
  112. {nextloop-0.3.0rc2 → nextloop-0.5.0}/src/nextloop/py.typed +0 -0
  113. {nextloop-0.3.0rc2 → nextloop-0.5.0}/src/nextloop/skills.py +0 -0
  114. {nextloop-0.3.0rc2 → nextloop-0.5.0}/src/nextloop.egg-info/dependency_links.txt +0 -0
  115. {nextloop-0.3.0rc2 → nextloop-0.5.0}/src/nextloop.egg-info/entry_points.txt +0 -0
  116. {nextloop-0.3.0rc2 → nextloop-0.5.0}/src/nextloop.egg-info/requires.txt +0 -0
  117. {nextloop-0.3.0rc2 → nextloop-0.5.0}/src/nextloop.egg-info/top_level.txt +0 -0
  118. {nextloop-0.3.0rc2 → nextloop-0.5.0}/tests/test_aggregate_close.py +0 -0
  119. {nextloop-0.3.0rc2 → nextloop-0.5.0}/tests/test_events.py +0 -0
  120. {nextloop-0.3.0rc2 → nextloop-0.5.0}/tests/test_failures.py +0 -0
  121. {nextloop-0.3.0rc2 → nextloop-0.5.0}/tests/test_loop.py +0 -0
  122. {nextloop-0.3.0rc2 → nextloop-0.5.0}/tests/test_providers.py +0 -0
  123. {nextloop-0.3.0rc2 → nextloop-0.5.0}/tests/test_stdio.py +0 -0
  124. {nextloop-0.3.0rc2 → nextloop-0.5.0}/tests/test_stdio_cleanup.py +0 -0
  125. {nextloop-0.3.0rc2 → nextloop-0.5.0}/tests/test_stdio_frames.py +0 -0
  126. {nextloop-0.3.0rc2 → nextloop-0.5.0}/tests/test_stdio_safety.py +0 -0
  127. {nextloop-0.3.0rc2 → nextloop-0.5.0}/tests/test_stores.py +0 -0
  128. {nextloop-0.3.0rc2 → nextloop-0.5.0}/tests/test_worker_conformance.py +0 -0
@@ -0,0 +1,256 @@
1
+ Metadata-Version: 2.4
2
+ Name: nextloop
3
+ Version: 0.5.0
4
+ Summary: An embeddable AgentLoop with explicit event, tool, recovery, and delivery semantics
5
+ Author-email: 12bitsD <bis12@163.com>
6
+ License-Expression: MIT
7
+ Project-URL: Repository, https://github.com/12bitsD/nextloop
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3.11
11
+ Classifier: Programming Language :: Python :: 3.12
12
+ Classifier: Programming Language :: Python :: 3.13
13
+ Classifier: Programming Language :: Python :: 3.14
14
+ Classifier: Typing :: Typed
15
+ Requires-Python: >=3.11
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+ Requires-Dist: httpx<1,>=0.27
19
+ Requires-Dist: jsonschema<5,>=4.23
20
+ Provides-Extra: dev
21
+ Requires-Dist: build<2,>=1.2; extra == "dev"
22
+ Requires-Dist: mypy<2,>=1.13; extra == "dev"
23
+ Requires-Dist: pytest<10,>=8; extra == "dev"
24
+ Requires-Dist: pytest-asyncio<2,>=0.24; extra == "dev"
25
+ Requires-Dist: ruff<1,>=0.8; extra == "dev"
26
+ Requires-Dist: twine<7,>=5; extra == "dev"
27
+ Requires-Dist: types-jsonschema<5,>=4.23; extra == "dev"
28
+ Dynamic: license-file
29
+
30
+ # nextloop
31
+
32
+ **Small core. Serious runtime semantics.**
33
+
34
+ nextloop is an embeddable Python AgentLoop for developers who want to build their own agent runtime — not inherit a heavyweight framework. Deterministic scheduling and state folding, append-only history, explicit crash recovery, typed Tools, and committed-event observability, all in a package you can actually read.
35
+
36
+ **Your agent, your rules. No magic, no black box.**
37
+
38
+ Current version: **0.5.0**.
39
+
40
+ ## Install
41
+
42
+ ```bash
43
+ python -m pip install nextloop==0.5.0
44
+ ```
45
+
46
+ For local development:
47
+
48
+ ```bash
49
+ uv venv --python 3.11 .venv
50
+ uv pip install --python .venv/bin/python -e '.[dev]'
51
+ ```
52
+
53
+ ## Why nextloop
54
+
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
+ - **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
+ - **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.
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
+ - **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
+ - **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.
62
+
63
+ It is a library, not an HTTP service, product bot, Router, EventBus, or multi-agent framework. **The Loop stays in your application; the decisions stay with you.**
64
+
65
+ ## Under the hood
66
+
67
+ - Session/Turn/Step execution with 4D integer coordinates and writer fencing.
68
+ - Append-only Trajectory with `surface_op` watermark semantics and Turn-private surface snapshots.
69
+ - Log-derived Pending Input and in-memory inbox signaling for steer and final commitment.
70
+ - Whole-batch Tool Schema validation, bounded parallel calls, and exclusive failure barriers.
71
+ - Closed five-variant `ToolOutcome`: `Completed`, `Skipped`, `Cancelled`, `UncertainSettled`, `UncertainHanging`.
72
+ - Bounded Provider retries, protocol correction, WorkingContext, Compaction, and cancellation.
73
+ - SQLite and in-memory EventStores, crash closers, and delivery-only recovery.
74
+ - OpenAI-compatible and Anthropic streaming Provider adapters.
75
+ - Directory-based `SkillRegistry` for progressive, on-demand `SKILL.md` loading with dependency and version validation.
76
+ - Strict `harness.toml` assembly, Python adapter injection, `module:register`, and persistent Python/Rust/C++ stdio workers.
77
+ - MCP stdio lifecycle, paginated catalogs, request-scoped cancellation, and no replay after crashes.
78
+ - Optional Step, model-call, Tool-call, token, and Turn-deadline budgets with structured terminal reasons.
79
+ - Turn-private surface snapshots and `PREVIEW` / `PAGED` / `FULL` Tool Result policies with `read_tool_result`.
80
+ - Optional transient `PreviewSink`, legacy-Provider snapshots, bounded queues, and RESET recovery.
81
+ - Offline `nextloop` CLI for configuration, worker, Tool, and Skill diagnostics.
82
+ - Committed-event observability with Model/Tool/Turn DTOs, asynchronous Exporters, optional Exporter lifecycle, and Session history.
83
+
84
+ ## Public API
85
+
86
+ ```python
87
+ AgentLoop.run(TurnContext) -> TurnOutcome
88
+ AgentLoop.steer(session_id, content, *, input_id=None) -> bool
89
+ AgentLoop.cancel(session_id, cause="user_stop") -> bool
90
+ AgentLoop.recover(session_id, store, delivery) -> RecoveryOutcome
91
+ AgentLoop.pending_inputs(session_id, store) -> tuple[PendingInput, ...]
92
+ ```
93
+
94
+ 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`.
95
+
96
+ ## Guarantees and non-guarantees
97
+
98
+ | Area | Guarantee | Not a guarantee |
99
+ |---|---|---|
100
+ | Accepted input | Accepted inputs are projected from the log by `input_id` and can be queried with `AgentLoop.pending_inputs`. Explicit IDs are non-empty; identical retries deduplicate, conflicting content is rejected without consuming the original. | Automatic deduplication when callers retry with a different or missing ID. |
101
+ | Delivery | Delivery is at least once; DeliveryOwner must deduplicate by stable `final_message_id`. | Exactly-once delivery or delivery without an idempotent owner. |
102
+ | 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. |
103
+ | Resource locks | Unresolved uncertain results block later calls sharing declared resources. | Global idempotency across different resources or Tools without resource declarations. |
104
+ | 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. |
105
+ | Preview | Preview is transient and cannot execute partial Tool arguments. | Preview as a durable EventStore fact or a substitute for committed Delivery. |
106
+ | Observability | Committed Events are authoritative and can be replayed for history. | The current in-memory Exporter queue as a durable outbox. |
107
+ | MCP | stdio lifecycle, paginated static catalogs, and uncertain crash handling. | Remote MCP, OAuth, dynamic `listChanged`, or non-text content mapping. |
108
+
109
+ `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.
110
+
111
+ Adapters can also be injected directly; caller-owned dependencies are not closed by Harness:
112
+
113
+ ```python
114
+ harness = Harness.load(
115
+ "harness.toml",
116
+ provider=my_provider,
117
+ store=my_store,
118
+ delivery=my_delivery,
119
+ tools=my_runtime,
120
+ )
121
+ ```
122
+
123
+ Use `ToolSpec(result_mode=ToolResultMode.PREVIEW | PAGED | FULL)` to control model-visible Tool output. `read_tool_result` retrieves committed full results by `event_id` and UTF-8 byte range. Use `TurnContext(preview=my_sink)` for transient Provider previews; committed Turn results still come only from `AgentLoop.run()` and the EventStore.
124
+
125
+ ```bash
126
+ nextloop check examples/harness.toml
127
+ nextloop tools call python_worker__echo '{"text":"hello"}' examples/harness.toml
128
+ nextloop skills view echo-guide examples/harness.toml
129
+ ```
130
+
131
+ The example Python module is found when running from a source checkout with `PYTHONPATH=examples`. Examples and reference workers ship in the repository and sdist; wheels contain the library and CLI. No API key is needed for these diagnostic commands.
132
+
133
+ ## Observability
134
+
135
+ Enable committed-event traces with a built-in stdout Exporter:
136
+
137
+ ```toml
138
+ [trace]
139
+ exporter = "stdout"
140
+ ```
141
+
142
+ Or pass a sync/async function directly:
143
+
144
+ ```python
145
+ harness = Harness.load("harness.toml", exporter=my_exporter)
146
+ ```
147
+
148
+ Use `module.path:function` in TOML for a custom Exporter. No Exporter is enabled by default. Every Exporter receives `ModelCallTrace`, `ToolCallTrace`, or `TurnTrace`; exports are queued asynchronously and flushed by `await harness.close()`. Close has a bounded wait, but it cannot forcibly stop an already running synchronous Exporter thread; late residual calls are reported through `on_error`.
149
+
150
+ ```python
151
+ turn = await harness.get_turn(1)
152
+ if turn is not None:
153
+ for tool in turn.tool_calls:
154
+ print(tool.name, tool.result, tool.duration_ms)
155
+
156
+ history = await harness.history(from_turn=1, to_turn=10)
157
+ ```
158
+
159
+ History works with memory and SQLite Stores even when no Exporter is configured.
160
+
161
+ `ToolRegistry` is the built-in `ToolRuntime` implementation:
162
+
163
+ ```python
164
+ from nextloop import ToolRegistry, ToolSpec, ToolExecutionMode
165
+
166
+ registry = ToolRegistry()
167
+ registry.register(
168
+ ToolSpec(
169
+ "read",
170
+ "Read a file",
171
+ {
172
+ "type": "object",
173
+ "properties": {"path": {"type": "string"}},
174
+ "required": ["path"],
175
+ },
176
+ mode=ToolExecutionMode.PARALLEL,
177
+ ),
178
+ lambda arguments, context: "file contents",
179
+ )
180
+ ```
181
+
182
+ Run the complete fake-Provider example:
183
+
184
+ ```bash
185
+ python examples/basic.py
186
+ ```
187
+
188
+ It executes model → Tool → Observation → model → delivery without a hosted model.
189
+
190
+ For a directory-based Skill example, run:
191
+
192
+ ```bash
193
+ python examples/skills_demo.py
194
+ ```
195
+
196
+ ## Code structure
197
+
198
+ ```text
199
+ src/nextloop/
200
+ contracts.py # public schemas, ToolOutcome, four Protocols, LoopConfig
201
+ loop.py # AgentLoop and active Session registry
202
+ driver.py # thin Turn/Step orchestration and SessionActor
203
+ events/ # pure projection, response/outcome folds, crash repair
204
+ execute/ # model retries, Tool registration, batch scheduling
205
+ adapters/ # SQLite, memory, OpenAI, Anthropic
206
+ testing.py # Store conformance and deterministic fault injection
207
+ ```
208
+
209
+ `events/` performs no I/O. `execute/` owns side effects and classified failures. `driver.py` only composes them.
210
+
211
+ ## Verification
212
+
213
+ The release checks cover:
214
+
215
+ - text, Tool, multi-Step, mixed, empty, truncated, and malformed responses;
216
+ - whole-batch rejection and parallel/exclusive scheduling with deterministic gates;
217
+ - steer/final ordering, cancellation, WorkingContext, and Compaction;
218
+ - protocol exhaustion, exact-byte retry, and partial-output failure;
219
+ - every append point on Memory and SQLite, before and after commit, with recovery and no-replay assertions;
220
+ - Tool/Delivery side-effect failures, writer takeover, late results, parallel partial completion, and repeated recovery;
221
+ - public Store conformance plus deliberately broken Store rejection;
222
+ - resource-lock recovery, conflict prevention, and explicit release;
223
+ - real subprocess exits during Tool execution and final delivery, followed by SQLite recovery;
224
+ - recorded OpenAI and Anthropic SSE streams;
225
+ - 12 live Kimi scenarios across both protocols, real Tool usage, parallel execution, recovery, steer, cancellation, Compaction, and WorkingContext;
226
+ - live DeepSeek text + Preview + usage and real Tool Call + Delivery smoke;
227
+ - a 10,505-event benchmark with cross-Store, incremental, and required-content parity;
228
+ - 299 offline tests, `ruff`, `mypy`, wheel/sdist builds, `twine check`, and clean wheel installation.
229
+
230
+ Current limits:
231
+
232
+ - nika integration is separate acceptance work.
233
+ - Concurrent writers across multiple processes fail closed; they are not coordinated by time-based leases.
234
+ - Large-asset lifecycle, backup, and GC are not part of this release.
235
+ - Official OpenAI and Anthropic API acceptance remains a 1.0 hard gate; recorded streams and DeepSeek do not substitute for it.
236
+
237
+ ## Documents
238
+
239
+ - [Architecture and import contract](docs/design/architecture.md)
240
+ - [Domain glossary](CONTEXT.md)
241
+ - [AgentLoop design](docs/design/agent-loop.md)
242
+ - [Public interface](docs/design/loop-interface.md)
243
+ - [Harness and extension interface](docs/design/harness.md)
244
+ - [ReAct protocol](docs/design/react-protocol.md)
245
+ - [Directory-based SkillRegistry](docs/design/skills.md)
246
+ - [Verification matrix](docs/design/verification-matrix.md)
247
+ - [Development plan](docs/architecture/development-plan.md)
248
+ - [Contributing](CONTRIBUTING.md) and [Security](SECURITY.md)
249
+ - [Changelog](CHANGELOG.md)
250
+ - [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)
251
+
252
+ ## Release
253
+
254
+ 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.
255
+
256
+ This is a public repository. Do not commit credentials, private trajectories, internal endpoints, or personal data.
@@ -0,0 +1,227 @@
1
+ # nextloop
2
+
3
+ **Small core. Serious runtime semantics.**
4
+
5
+ nextloop is an embeddable Python AgentLoop for developers who want to build their own agent runtime — not inherit a heavyweight framework. Deterministic scheduling and state folding, append-only history, explicit crash recovery, typed Tools, and committed-event observability, all in a package you can actually read.
6
+
7
+ **Your agent, your rules. No magic, no black box.**
8
+
9
+ Current version: **0.5.0**.
10
+
11
+ ## Install
12
+
13
+ ```bash
14
+ python -m pip install nextloop==0.5.0
15
+ ```
16
+
17
+ For local development:
18
+
19
+ ```bash
20
+ uv venv --python 3.11 .venv
21
+ uv pip install --python .venv/bin/python -e '.[dev]'
22
+ ```
23
+
24
+ ## Why nextloop
25
+
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
+ - **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
+ - **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.
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
+ - **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
+ - **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.
33
+
34
+ It is a library, not an HTTP service, product bot, Router, EventBus, or multi-agent framework. **The Loop stays in your application; the decisions stay with you.**
35
+
36
+ ## Under the hood
37
+
38
+ - Session/Turn/Step execution with 4D integer coordinates and writer fencing.
39
+ - Append-only Trajectory with `surface_op` watermark semantics and Turn-private surface snapshots.
40
+ - Log-derived Pending Input and in-memory inbox signaling for steer and final commitment.
41
+ - Whole-batch Tool Schema validation, bounded parallel calls, and exclusive failure barriers.
42
+ - Closed five-variant `ToolOutcome`: `Completed`, `Skipped`, `Cancelled`, `UncertainSettled`, `UncertainHanging`.
43
+ - Bounded Provider retries, protocol correction, WorkingContext, Compaction, and cancellation.
44
+ - SQLite and in-memory EventStores, crash closers, and delivery-only recovery.
45
+ - OpenAI-compatible and Anthropic streaming Provider adapters.
46
+ - Directory-based `SkillRegistry` for progressive, on-demand `SKILL.md` loading with dependency and version validation.
47
+ - Strict `harness.toml` assembly, Python adapter injection, `module:register`, and persistent Python/Rust/C++ stdio workers.
48
+ - MCP stdio lifecycle, paginated catalogs, request-scoped cancellation, and no replay after crashes.
49
+ - Optional Step, model-call, Tool-call, token, and Turn-deadline budgets with structured terminal reasons.
50
+ - Turn-private surface snapshots and `PREVIEW` / `PAGED` / `FULL` Tool Result policies with `read_tool_result`.
51
+ - Optional transient `PreviewSink`, legacy-Provider snapshots, bounded queues, and RESET recovery.
52
+ - Offline `nextloop` CLI for configuration, worker, Tool, and Skill diagnostics.
53
+ - Committed-event observability with Model/Tool/Turn DTOs, asynchronous Exporters, optional Exporter lifecycle, and Session history.
54
+
55
+ ## Public API
56
+
57
+ ```python
58
+ AgentLoop.run(TurnContext) -> TurnOutcome
59
+ AgentLoop.steer(session_id, content, *, input_id=None) -> bool
60
+ AgentLoop.cancel(session_id, cause="user_stop") -> bool
61
+ AgentLoop.recover(session_id, store, delivery) -> RecoveryOutcome
62
+ AgentLoop.pending_inputs(session_id, store) -> tuple[PendingInput, ...]
63
+ ```
64
+
65
+ 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`.
66
+
67
+ ## Guarantees and non-guarantees
68
+
69
+ | Area | Guarantee | Not a guarantee |
70
+ |---|---|---|
71
+ | Accepted input | Accepted inputs are projected from the log by `input_id` and can be queried with `AgentLoop.pending_inputs`. Explicit IDs are non-empty; identical retries deduplicate, conflicting content is rejected without consuming the original. | Automatic deduplication when callers retry with a different or missing ID. |
72
+ | 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. |
75
+ | 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
+ | Preview | Preview is transient and cannot execute partial Tool arguments. | Preview as a durable EventStore fact or a substitute for committed Delivery. |
77
+ | 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. |
79
+
80
+ `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
+
82
+ Adapters can also be injected directly; caller-owned dependencies are not closed by Harness:
83
+
84
+ ```python
85
+ harness = Harness.load(
86
+ "harness.toml",
87
+ provider=my_provider,
88
+ store=my_store,
89
+ delivery=my_delivery,
90
+ tools=my_runtime,
91
+ )
92
+ ```
93
+
94
+ Use `ToolSpec(result_mode=ToolResultMode.PREVIEW | PAGED | FULL)` to control model-visible Tool output. `read_tool_result` retrieves committed full results by `event_id` and UTF-8 byte range. Use `TurnContext(preview=my_sink)` for transient Provider previews; committed Turn results still come only from `AgentLoop.run()` and the EventStore.
95
+
96
+ ```bash
97
+ nextloop check examples/harness.toml
98
+ nextloop tools call python_worker__echo '{"text":"hello"}' examples/harness.toml
99
+ nextloop skills view echo-guide examples/harness.toml
100
+ ```
101
+
102
+ The example Python module is found when running from a source checkout with `PYTHONPATH=examples`. Examples and reference workers ship in the repository and sdist; wheels contain the library and CLI. No API key is needed for these diagnostic commands.
103
+
104
+ ## Observability
105
+
106
+ Enable committed-event traces with a built-in stdout Exporter:
107
+
108
+ ```toml
109
+ [trace]
110
+ exporter = "stdout"
111
+ ```
112
+
113
+ Or pass a sync/async function directly:
114
+
115
+ ```python
116
+ harness = Harness.load("harness.toml", exporter=my_exporter)
117
+ ```
118
+
119
+ Use `module.path:function` in TOML for a custom Exporter. No Exporter is enabled by default. Every Exporter receives `ModelCallTrace`, `ToolCallTrace`, or `TurnTrace`; exports are queued asynchronously and flushed by `await harness.close()`. Close has a bounded wait, but it cannot forcibly stop an already running synchronous Exporter thread; late residual calls are reported through `on_error`.
120
+
121
+ ```python
122
+ turn = await harness.get_turn(1)
123
+ if turn is not None:
124
+ for tool in turn.tool_calls:
125
+ print(tool.name, tool.result, tool.duration_ms)
126
+
127
+ history = await harness.history(from_turn=1, to_turn=10)
128
+ ```
129
+
130
+ History works with memory and SQLite Stores even when no Exporter is configured.
131
+
132
+ `ToolRegistry` is the built-in `ToolRuntime` implementation:
133
+
134
+ ```python
135
+ from nextloop import ToolRegistry, ToolSpec, ToolExecutionMode
136
+
137
+ registry = ToolRegistry()
138
+ registry.register(
139
+ ToolSpec(
140
+ "read",
141
+ "Read a file",
142
+ {
143
+ "type": "object",
144
+ "properties": {"path": {"type": "string"}},
145
+ "required": ["path"],
146
+ },
147
+ mode=ToolExecutionMode.PARALLEL,
148
+ ),
149
+ lambda arguments, context: "file contents",
150
+ )
151
+ ```
152
+
153
+ Run the complete fake-Provider example:
154
+
155
+ ```bash
156
+ python examples/basic.py
157
+ ```
158
+
159
+ It executes model → Tool → Observation → model → delivery without a hosted model.
160
+
161
+ For a directory-based Skill example, run:
162
+
163
+ ```bash
164
+ python examples/skills_demo.py
165
+ ```
166
+
167
+ ## Code structure
168
+
169
+ ```text
170
+ src/nextloop/
171
+ contracts.py # public schemas, ToolOutcome, four Protocols, LoopConfig
172
+ loop.py # AgentLoop and active Session registry
173
+ driver.py # thin Turn/Step orchestration and SessionActor
174
+ events/ # pure projection, response/outcome folds, crash repair
175
+ execute/ # model retries, Tool registration, batch scheduling
176
+ adapters/ # SQLite, memory, OpenAI, Anthropic
177
+ testing.py # Store conformance and deterministic fault injection
178
+ ```
179
+
180
+ `events/` performs no I/O. `execute/` owns side effects and classified failures. `driver.py` only composes them.
181
+
182
+ ## Verification
183
+
184
+ The release checks cover:
185
+
186
+ - text, Tool, multi-Step, mixed, empty, truncated, and malformed responses;
187
+ - whole-batch rejection and parallel/exclusive scheduling with deterministic gates;
188
+ - steer/final ordering, cancellation, WorkingContext, and Compaction;
189
+ - protocol exhaustion, exact-byte retry, and partial-output failure;
190
+ - every append point on Memory and SQLite, before and after commit, with recovery and no-replay assertions;
191
+ - Tool/Delivery side-effect failures, writer takeover, late results, parallel partial completion, and repeated recovery;
192
+ - public Store conformance plus deliberately broken Store rejection;
193
+ - resource-lock recovery, conflict prevention, and explicit release;
194
+ - real subprocess exits during Tool execution and final delivery, followed by SQLite recovery;
195
+ - recorded OpenAI and Anthropic SSE streams;
196
+ - 12 live Kimi scenarios across both protocols, real Tool usage, parallel execution, recovery, steer, cancellation, Compaction, and WorkingContext;
197
+ - live DeepSeek text + Preview + usage and real Tool Call + Delivery smoke;
198
+ - a 10,505-event benchmark with cross-Store, incremental, and required-content parity;
199
+ - 299 offline tests, `ruff`, `mypy`, wheel/sdist builds, `twine check`, and clean wheel installation.
200
+
201
+ Current limits:
202
+
203
+ - nika integration is separate acceptance work.
204
+ - Concurrent writers across multiple processes fail closed; they are not coordinated by time-based leases.
205
+ - Large-asset lifecycle, backup, and GC are not part of this release.
206
+ - Official OpenAI and Anthropic API acceptance remains a 1.0 hard gate; recorded streams and DeepSeek do not substitute for it.
207
+
208
+ ## Documents
209
+
210
+ - [Architecture and import contract](docs/design/architecture.md)
211
+ - [Domain glossary](CONTEXT.md)
212
+ - [AgentLoop design](docs/design/agent-loop.md)
213
+ - [Public interface](docs/design/loop-interface.md)
214
+ - [Harness and extension interface](docs/design/harness.md)
215
+ - [ReAct protocol](docs/design/react-protocol.md)
216
+ - [Directory-based SkillRegistry](docs/design/skills.md)
217
+ - [Verification matrix](docs/design/verification-matrix.md)
218
+ - [Development plan](docs/architecture/development-plan.md)
219
+ - [Contributing](CONTRIBUTING.md) and [Security](SECURITY.md)
220
+ - [Changelog](CHANGELOG.md)
221
+ - [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)
222
+
223
+ ## Release
224
+
225
+ 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.
226
+
227
+ 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,32 @@
1
+ # ADR-0005: Pending Input as a pure log projection
2
+
3
+ Status: accepted
4
+
5
+ ## Context
6
+
7
+ `steer()` persists INPUT_ACCEPTED before writing the in-memory actor inbox. INPUT_ACCEPTED alone is not part of the model-visible projection. A crash can therefore acknowledge an input that the model never sees. Rebuilding this state in `recover()` would create another writer and another crash window.
8
+
9
+ ## Decision
10
+
11
+ The event log is the sole source of truth. The actor inbox is only a wake-up signal.
12
+
13
+ - Scan INPUT_ACCEPTED and USER_MESSAGE in seq order and match them by `input_id`.
14
+ - Accepted inputs without a corresponding USER_MESSAGE are Pending Input.
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.
17
+ - Pending historical inputs appear before the new Turn's initial_input. Inputs accepted during approval suspension appear only after the corresponding Tool results.
18
+ - Inputs from cancelled or budget-terminated Turns carry into the next Turn by default.
19
+ - Active execution also uses the log's consumption state, so an input present in both the log and actor inbox is injected once.
20
+ - Pending is queryable with `input_id`, original seq, original Turn, and content. No cleanup event is introduced in this version.
21
+ - `recover()` may be called repeatedly without duplicating Pending. A crash between recover and run has the same projection.
22
+
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.
24
+
25
+ No cleanup event is introduced. Pending remains visible until the caller consumes it or the protocol later defines an explicit discard fact.
26
+
27
+ ## Consequences
28
+
29
+ - Accepted inputs are not silently lost after process crashes.
30
+ - No second recovery writer or in-memory Pending copy can diverge from the log.
31
+ - Callers that blindly retry with a new ID may intentionally receive duplicate content; this is not deduplicated.
32
+ - Compaction and approval pairing must preserve Pending ordering and must not split a Tool Intent from its result.
@@ -0,0 +1,71 @@
1
+ # nextloop development and verification plan
2
+
3
+ Current stage: **0.5.0 implementation and release verification**. `0.5.0rc2` 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.