ruby_llm-ag_ui 0.2.0 → 0.4.0

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 (46) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +52 -0
  3. data/README.md +1 -1
  4. data/docs/_advanced/client-example.md +11 -0
  5. data/docs/_advanced/provider-verification.md +70 -0
  6. data/docs/_advanced/rails-integration.md +5 -2
  7. data/docs/_advanced/security-and-deployment.md +2 -2
  8. data/docs/_advanced/worker-recovery.md +104 -0
  9. data/docs/_core_features/approval-and-resume.md +9 -0
  10. data/docs/_core_features/cancellation.md +84 -0
  11. data/docs/_core_features/reconnects.md +22 -1
  12. data/docs/_core_features/streaming-runs.md +14 -0
  13. data/docs/_getting_started/configuration.md +7 -2
  14. data/docs/_getting_started/whats-new-in-0-4.md +57 -0
  15. data/docs/_reference/api-reference.md +2 -1
  16. data/docs/_reference/compatibility.md +121 -11
  17. data/docs/_reference/public-api.md +102 -0
  18. data/docs/_reference/release-history.md +3 -1
  19. data/docs/_reference/releasing.md +10 -0
  20. data/docs/_reference/upgrading.md +17 -16
  21. data/docs/{_getting_started → _reference}/whats-new-in-0-2.md +2 -1
  22. data/docs/_reference/whats-new-in-0-3.md +62 -0
  23. data/lib/ruby_llm/ag_ui/configuration.rb +14 -11
  24. data/lib/ruby_llm/ag_ui/emitter.rb +6 -2
  25. data/lib/ruby_llm/ag_ui/error.rb +13 -2
  26. data/lib/ruby_llm/ag_ui/error_sanitizer.rb +2 -1
  27. data/lib/ruby_llm/ag_ui/immutable.rb +34 -0
  28. data/lib/ruby_llm/ag_ui/input.rb +5 -4
  29. data/lib/ruby_llm/ag_ui/interrupt.rb +10 -10
  30. data/lib/ruby_llm/ag_ui/mapper.rb +8 -0
  31. data/lib/ruby_llm/ag_ui/message_parser.rb +1 -1
  32. data/lib/ruby_llm/ag_ui/persistence.rb +18 -0
  33. data/lib/ruby_llm/ag_ui/rails/active_record_store.rb +21 -11
  34. data/lib/ruby_llm/ag_ui/rails/record.rb +8 -3
  35. data/lib/ruby_llm/ag_ui/rails/streaming.rb +3 -3
  36. data/lib/ruby_llm/ag_ui/reconnect.rb +1 -1
  37. data/lib/ruby_llm/ag_ui/resume.rb +9 -5
  38. data/lib/ruby_llm/ag_ui/resume_entry.rb +3 -3
  39. data/lib/ruby_llm/ag_ui/run.rb +18 -18
  40. data/lib/ruby_llm/ag_ui/run_record.rb +27 -14
  41. data/lib/ruby_llm/ag_ui/sse_writer.rb +16 -4
  42. data/lib/ruby_llm/ag_ui/store/base.rb +24 -1
  43. data/lib/ruby_llm/ag_ui/store/memory_store.rb +6 -10
  44. data/lib/ruby_llm/ag_ui/validation.rb +1 -1
  45. data/lib/ruby_llm/ag_ui/version.rb +1 -1
  46. metadata +31 -3
@@ -23,10 +23,11 @@ dependency does.
23
23
 
24
24
  | Component | Range | Evidence |
25
25
  |---|---|---|
26
- | Ruby | `>= 3.2` | CI passes on 3.2.11, 3.3.12, and 3.4.11; 3.3.5 checked locally |
27
- | RubyLLM | `>= 2.1`, `< 3.0` | 2.1.1 (callback, approval and cancellation behavior read from its source) |
26
+ | Ruby | `>= 3.2` | Recorded 0.4 CI passes on 3.2.11, 3.3.12, and 3.4.11 |
27
+ | RubyLLM | `>= 2.1`, `< 3.0` | 2.1.0 and 2.1.1 pass the 0.4 CI matrix; the recorded live session uses 2.1.1 |
28
28
  | `ag-ui-protocol` | `~> 0.2.0` | 0.2.0 |
29
- | Rails (adapter only) | `railties`, `actionpack`, `activerecord` `>= 8.0` | CI passes on 8.0.5.1 and 8.1.4 with Ruby 3.3/3.4; 8.1.4 checked locally |
29
+ | JSON | `>= 2.0`, `< 3` | 2.21.2 passes both Rails lines; JSON 3 removes the `quirks_mode` option used by Rails 8.0 |
30
+ | Rails (adapter only) | `railties`, `actionpack`, `activerecord` `>= 8.0` | Recorded 0.4 CI passes on 8.0.5.1 and 8.1.4 with Ruby 3.3/3.4 |
30
31
  | AG-UI schema | pinned commit `89cedd3fd549feeee41e50e1d7c6d373e549241a` | vendored, SHA-256 recorded in [AG-UI Protocol Coverage]({% link _reference/protocol-coverage.md %}) |
31
32
 
32
33
  The pure-Ruby core uses `ruby_llm` and `ag-ui-protocol`, plus the patched
@@ -53,7 +54,110 @@ adapter is only loaded when `Rails::Railtie` is already defined.
53
54
 
54
55
  The RSpec suite runs offline with fakes and no provider credentials. Package verification uses the network only to install dependencies, then runs its core and Rails checks without a provider. Its advisory check includes the actual default-library gem versions activated by the isolated core install.
55
56
 
56
- ## Recorded Client Verification
57
+ ## 0.4 Release Acceptance
58
+
59
+ The [2026-10-21 acceptance CI](https://github.com/yorzi/ruby_llm-ag-ui/actions/runs/39518735488)
60
+ passes all 17 jobs at `e09b81b`. Each test job reports 296 examples, zero failures,
61
+ and two opt-in provider skips across the Ruby, Rails, and RubyLLM matrix below.
62
+ Local checks also pass 296 examples and lint on 95 files. Both installed
63
+ endpoints verify one original tool call and one result with its original id.
64
+
65
+ The added regressions cover `Run#record` on reconnect and real RubyLLM denial
66
+ without tool execution. Denial uses intercepted HTTP. The local OpenRouter
67
+ text and approval/resume examples are separately rerun on the release code:
68
+ two live cases plus one offline harness example pass with zero failures.
69
+
70
+ The browser suite again passes 18 workflows and validates all 242 consumed
71
+ events. Desktop approval progress and 390px mobile denial screenshots were
72
+ inspected. The earlier candidate record below retains its own commit and counts.
73
+
74
+ ## Local 0.4 Development Verification
75
+
76
+ On 2026-10-21, the candidate passes 294 offline examples with zero failures
77
+ and two opt-in provider checks skipped. Separate runs use RubyLLM 2.1.0 and
78
+ 2.1.1 on Ruby 3.3.5 with Rails 8.1.4 and JSON 2.21.2. The [0.4 candidate CI](https://github.com/yorzi/ruby_llm-ag-ui/actions/runs/39515383346)
79
+ passes all 17 jobs at `14b3c15`: six Ruby jobs across 3.2.11, 3.3.12, and
80
+ 3.4.11 with both RubyLLM versions; eight Rails jobs across 8.0.5.1 and 8.1.4
81
+ on Ruby 3.3/3.4 with both versions; lint, installed-host, and browser checks.
82
+ Each suite reports 294 examples, zero failures, and two opt-in provider skips.
83
+
84
+ The maintained client passes 18 workflows and validates all 242 consumed
85
+ events. Approval assertions inspect the official client's messages as well as
86
+ the wire: one original call, one associated result, no duplicate visible text
87
+ after reconnect. The remote browser uses Chromium 156.0.8078.4; local and remote
88
+ desktop progress and 390px denial screenshots were inspected. The fixture now fires the same resumed before-tool callback
89
+ as a real RubyLLM chat. Installed-host and generated Rails model checks pass. A fixed local 66-file
90
+ artifact independently passes clean core loading, activated dependency audit,
91
+ and Rails generator migration up/down. The isolated core uses JSON 2.7.1.
92
+ The root and activated-core audit reports no findings against the recorded
93
+ advisory database. These are development artifact checks, not public downloads.
94
+
95
+ ### Recorded Live Provider Session
96
+
97
+ The 2026-10-21 local session uses OpenRouter with `openai/gpt-4.1-mini`,
98
+ RubyLLM 2.1.1, and Ruby 3.3.5. Both live examples pass: streamed text, then a
99
+ synthetic tool approval/resume with its original call id, redaction, and completed
100
+ resume reconnect. The tool is not executed before approval and executes once
101
+ after it. The same command includes one offline harness example, for three
102
+ examples total with zero failures. It verifies the gem's Ruby path, not a live
103
+ provider session through the browser or a deployed Rails application.
104
+
105
+ This session first exposed duplicate tool-call starts on a real resume.
106
+ An intercepted-HTTP real-chat test reproduces that defect before the fix and
107
+ passes afterward. Text, tool results, and approval are live evidence for this
108
+ route and model only. Live cancellation, timeout timing, network loss, denial,
109
+ and other providers remain unverified. Follow
110
+ [Provider Verification]({% link _advanced/provider-verification.md %}) to reproduce.
111
+
112
+ The checked current `ag-ui-protocol` remains 0.2.0. Its missing cancelled
113
+ outcome and `RUN_STARTED.protocolVersion` still require the local protocol
114
+ shims. Their encoded events pass the pinned schema checks; no workaround is
115
+ removed solely because a new version was expected.
116
+
117
+ ## Local 0.3 Development Verification
118
+
119
+ On 2026-10-19, Ruby 3.3.5, RubyLLM 2.1.1, and Rails 8.1.4 pass 284 examples
120
+ with zero failures and one opt-in provider example skipped. The 18 browser
121
+ workflows pass with `@ag-ui/client` 1.0.3, Playwright 1.64.1, and Puma 8.0.2;
122
+ all 242 consumed events validate against the pinned schema. Desktop disconnect
123
+ and 390px cancellation screenshots were inspected.
124
+
125
+ Independent Ruby processes share one SQLite file to check reservations,
126
+ approval decisions, and competing outcome writes. Write barriers force both
127
+ processes to observe the old payload before either updates it. A producer
128
+ killed after a synthetic tool effect is explicitly recovered; reconnect never
129
+ executes the tool again. Mutation checks reject removal of either SQL compare
130
+ conditions or revision validation.
131
+
132
+ The real RubyLLM chat is also checked with intercepted HTTP: cancellation at
133
+ a checkpoint makes no provider request, and a request timeout produces a
134
+ sanitized, reconnectable failure. These tests make no live provider call.
135
+ Installed-host checks pass for both endpoints and generated Rails models.
136
+ ## Recorded 0.3 CI Verification
137
+
138
+ The [2026-10-20 CI run](https://github.com/yorzi/ruby_llm-ag-ui/actions/runs/39375830117)
139
+ passes all ten jobs at `aa9e035`: Ruby 3.2.11, 3.3.12, and 3.4.11; Rails
140
+ 8.0.5.1 and 8.1.4 on Ruby 3.3/3.4; lint; installed-host checks; and the browser
141
+ suite on Ubuntu 24.04. Each test job passes 284 examples with zero failures
142
+ and one opt-in provider skip. The browser suite passes 18 workflows and
143
+ validates all 242 consumed events with `@ag-ui/client` 1.0.3.
144
+ It uses Playwright 1.64.1 and Chromium 156.0.8078.4. Desktop disconnection and
145
+ 390px cancellation screenshots from this run were inspected.
146
+
147
+ The first candidate failed when Rails 8.0 and JSON 3 loaded a real RubyLLM
148
+ chat. Version 0.3 bounds JSON to 2.x; the passing matrix uses 2.21.2. Intercepted
149
+ HTTP tests reproduce the failure before the bound and pass after it. These
150
+ checks make no live provider call.
151
+
152
+ The [0.3.0 release workflow](https://github.com/yorzi/ruby_llm-ag-ui/actions/runs/39376258843)
153
+ passes offline tests, browser workflows, advisory checks, and installed-host
154
+ plus clean core/Rails checks. After publication, the actual GitHub and RubyGems
155
+ downloads have matching SHA-256 hashes and all 62 packaged files match the tag.
156
+ The downloaded artifact independently passes both installed endpoints and fresh
157
+ core, advisory, and Rails generator migration checks. The isolated macOS core
158
+ activates JSON 2.7.1; the remote test matrix uses 2.21.2.
159
+
160
+ ## Recorded 0.2 Client Verification
57
161
 
58
162
  On 2026-10-19, the local 0.2.0 candidate passes the maintained browser workflows
59
163
  with `@ag-ui/client` 1.0.3, Playwright 1.64.1, and Chrome 155.0.8059.82 on macOS.
@@ -79,23 +183,29 @@ scenarios, with 154 consumed events validated against the schema. Its desktop
79
183
  progress and mobile denial screenshots were also inspected. These remain
80
184
  synthetic checks; no live provider session is recorded.
81
185
 
186
+ The [0.2.0 release workflow](https://github.com/yorzi/ruby_llm-ag-ui/actions/runs/39180349362)
187
+ also passes browser, advisory, installed-host, and clean-install verification.
188
+ The published GitHub and RubyGems downloads have matching checksums. The actual
189
+ published artifact separately passes the installed-host and clean core/Rails
190
+ checks after download.
191
+
82
192
  ## What is not asserted
83
193
 
84
194
  - **Other clients or versions.** CopilotKit and client versions other than the
85
195
  recorded `@ag-ui/client` version have not been verified. Schema conformance
86
196
  does not establish that every UI renders the events correctly.
87
- - **Live providers.** `spec/live/live_run_spec.rb` is the opt-in check
88
- (`RUBY_LLM_LIVE=1`, plus a provider key); its provider context is skipped in the default suite. The same run setup
89
- is exercised separately with an offline chat. Provider behavior in 2.1.1 is derived from its source, not from a recorded
90
- session.
197
+ - **Other live paths.** Only the recorded OpenRouter model's text and approval
198
+ workflow is verified live. Browser provider sessions, other providers,
199
+ cancellation timing, timeouts, and network-loss recovery need separate evidence.
91
200
  - **Every RubyLLM patch release in the `>= 2.1, < 3.0` range.** The upper bound
92
- is enforced by the gemspec; the verified version is 2.1.1.
201
+ is a dependency resolver bound; verified versions are 2.1.0 and 2.1.1. Future
202
+ 2.x releases need the same checks before a compatibility claim.
93
203
  - **Rails versions before 8.0.** The adapter uses `Rails.setup!` and an
94
204
  initializer, and its specs run on 8.0/8.1. It may work on 7.2 and it is not
95
205
  tested there.
96
206
  - **Databases other than SQLite** for the ActiveRecord store. The store uses a
97
- unique index and `with_lock`; PostgreSQL and MySQL should behave the same, and
98
- that is untested.
207
+ unique index and conditional payload updates. PostgreSQL and MySQL are
208
+ untested; the SQLite checks do not establish their concurrency behavior.
99
209
 
100
210
  ## Deliberate behavior worth knowing
101
211
 
@@ -0,0 +1,102 @@
1
+ ---
2
+ layout: default
3
+ title: Public API Contract
4
+ nav_order: 3
5
+ description: Build against the application API and custom-store contract proposed for 1.0.
6
+ ---
7
+
8
+ # {{ page.title }}
9
+
10
+ {{ page.description }}
11
+ {: .fs-6 .fw-300 }
12
+
13
+ After reading this guide, you will know:
14
+
15
+ * Which entry points applications can depend on.
16
+ * Which values and failures cross the integration boundary.
17
+ * How to implement a custom store without depending on orchestration internals.
18
+
19
+ ## Run One Authorized Turn
20
+
21
+ ```ruby
22
+ input = RubyLLM::AgUI::Input.parse(request_body)
23
+ record = RubyLLM::AgUI::Run.new(
24
+ chat: host_chat, input: input, scope: authenticated_scope, store: run_store
25
+ ).stream(to: response_stream)
26
+ record.status
27
+ ```
28
+
29
+ The host owns its chat, authentication, authorization, history, model, and tools.
30
+ Parsing client data never adds messages or tools to that chat. A completed run
31
+ returns its stored outcome on an exact retry; it never repeats the turn.
32
+ An active duplicate is refused. See
33
+ [Reconnects]({% link _core_features/reconnects.md %}).
34
+
35
+ Version 0.4 proposes the following application contract for 1.0. It is not a
36
+ 1.0 stability promise yet. Breaking changes before 1.0 have upgrade steps.
37
+
38
+ | Entry point | Application contract |
39
+ | --- | --- |
40
+ | `RubyLLM::AgUI.configure`, `.config`, `.reset_configuration!` | Application defaults listed in [Configuration]({% link _getting_started/configuration.md %}). |
41
+ | `Input.parse(raw, max_bytes: nil, strict: false, logger: nil)` | Accept a Hash, JSON String, or readable body; return parsed identity, data, digest, warnings, and `to_h`. |
42
+ | `Run.new(...).stream(to:)` | Reserve before execution; return a `RunRecord`; serialize callbacks and detach a failed transport. `Run#record` exposes the reserved record and, after completion or reconnect, the returned outcome. |
43
+ | `SSEWriter#write`, `#flush`, `#close`, `#closed?`, `.headers` | Encode schema-valid events on an IO-like stream; direct write failures raise `TransportError`. |
44
+ | `RunRecord`, `Interrupt`, `ResumeEntry` | Read-only identity and JSON data, predicates, documented transitions, and serialization. Transitions return new values. |
45
+ | `Redaction.default`, `.none` and a host callable | Transform tool output and opt-in progress; nil uses the default redactor. |
46
+ | `Coverage` | Inspect produced and unsupported event types for the pinned schema. |
47
+
48
+ `Mapper` is an advanced event projection API. Its documented methods accept
49
+ RubyLLM chunks, messages, and tool calls; they return events and do not persist
50
+ or execute work. Prefer `Run` when you need identity and terminal guarantees.
51
+ The protocol shim's concrete model classes and constructors are implementation
52
+ details. Depend on encoded AG-UI events, not on a shim class name.
53
+
54
+ ## Implement a Store
55
+
56
+ Implement the public methods on `Store::Base`: `reserve`, `find`, `latest_run`,
57
+ `latest_interrupted`, `save`, `find_interrupt`, and `redeem_interrupt`.
58
+ `recover` is supplied by the base class, or you can implement the same conditional
59
+ contract. Return `Reservation` and `Redemption` values where the interface
60
+ requires them. Their constructors and predicates are extension API.
61
+
62
+ Keep scope and run identity isolated. Reserve identities and redeem approvals
63
+ atomically. `save(record)` compares the observed revision and returns a new
64
+ record with a higher revision. Retain the return value. A stale write raises
65
+ `StaleRecordError`. A recovery never supersedes a terminal or newer outcome.
66
+ Read [Worker Recovery]({% link _advanced/worker-recovery.md %}) before using it.
67
+
68
+ Use `MemoryStore` within one process, or `Rails::ActiveRecordStore` with the
69
+ shipped migration. The verified database is SQLite. Other databases require
70
+ independent concurrency evidence.
71
+
72
+ ## Handle Errors at the Right Boundary
73
+
74
+ `InputError#http_status` is 400 for malformed or invalid input, 413 for size
75
+ limits, and 409 for identity conflicts or rejected resumes. `ConfigurationError`
76
+ is a host setup error. An active duplicate raises `StreamError`; the Rails
77
+ adapter refuses it before committing the stream with 409.
78
+
79
+ A provider or tool failure becomes a sanitized `RUN_ERROR` and failed record.
80
+ A cooperative cancellation becomes a cancelled outcome. A `PersistenceError`
81
+ propagates because acknowledgement may be uncertain. Inspect storage before
82
+ recovery; do not infer whether an external tool effect happened from that error.
83
+ A `RunConflictError`, including `StaleRecordError`, also propagates.
84
+
85
+ The Rails entry point is `stream_ag_ui_run { |input| authorized_chat }`.
86
+ Override `ag_ui_scope` and optionally `ag_ui_state`. Configure storage with
87
+ `config.run_store`. Private concern helpers are not extension API. Follow the
88
+ [Rails guide]({% link _advanced/rails-integration.md %}) for their signatures.
89
+
90
+ ## Avoid Orchestration Internals
91
+
92
+ `Emitter`, `Resume`, `Reconnect`, `MessageParser`, input parser helpers,
93
+ `Validation`, `ErrorSanitizer`, `Persistence`, and `Immutable` are internal.
94
+ Their names, constructors, and methods can change without an application API
95
+ migration. Store private helpers and generated Rails model internals have the
96
+ same boundary.
97
+
98
+ ## Next Steps
99
+
100
+ * [API Reference]({% link _reference/api-reference.md %}) - inspect source signatures.
101
+ * [Compatibility]({% link _reference/compatibility.md %}) - read tested versions and limits.
102
+ * [Upgrading]({% link _reference/upgrading.md %}) - adapt older applications.
@@ -17,7 +17,9 @@ description: Review RubyLLM AG-UI releases, newest first, with highlights and up
17
17
 
18
18
  | Release | Date | Highlights |
19
19
  | --- | --- | --- |
20
- | [0.2.0](https://github.com/yorzi/ruby_llm-ag-ui/releases/tag/v0.2.0) | 2026-10-19 | [Client workflows and tool progress]({% link _getting_started/whats-new-in-0-2.md %}): opt-in redacted progress, a real-client demo, and completed resume reconnect |
20
+ | [0.4.0](https://github.com/yorzi/ruby_llm-ag-ui/releases/tag/v0.4.0) | 2026-10-21 | [API and compatibility]({% link _getting_started/whats-new-in-0-4.md %}): effective configuration, immutable records, and real-chat approval verification |
21
+ | [0.3.0](https://github.com/yorzi/ruby_llm-ag-ui/releases/tag/v0.3.0) | 2026-10-20 | [Lifecycle and worker recovery]({% link _reference/whats-new-in-0-3.md %}): disconnect handling, scoped cancellation, and conditional durable writes |
22
+ | [0.2.0](https://github.com/yorzi/ruby_llm-ag-ui/releases/tag/v0.2.0) | 2026-10-19 | [Client workflows and tool progress]({% link _reference/whats-new-in-0-2.md %}): opt-in redacted progress, a real-client demo, and completed resume reconnect |
21
23
  | [0.1.0](https://github.com/yorzi/ruby_llm-ag-ui/releases/tag/v0.1.0) | 2026-10-18 | [First release]({% link _reference/whats-new-in-0-1.md %}): AG-UI event mapping, approval and resume, cancellation, reconnect, and the optional Rails adapter |
22
24
 
23
25
  To move an application from one release to the next, follow [Upgrading]({% link _reference/upgrading.md %}).
@@ -67,3 +67,13 @@ Replace the example tag with the version you are releasing. The `Release Gem` wo
67
67
  On success, the workflow creates a GitHub Release with the gem, checksum, and CHANGELOG notes. The Docs workflow runs after the release workflow succeeds. It publishes the tagged version at `/` and current `main` at `/next/`.
68
68
 
69
69
  Check the version on RubyGems, the GitHub Release assets, and the documentation installation command. If a publish attempt fails, inspect its logs before retrying. A published RubyGems version cannot be overwritten.
70
+
71
+ Download the published gem from both RubyGems and the GitHub Release. Compare
72
+ their SHA-256 hashes with the release's `SHA256SUMS` and RubyGems metadata.
73
+ Verify that its packaged files match the tag. The publish job builds its own
74
+ artifact, so a verification job's earlier hash is not proof of the public bytes.
75
+
76
+ Place the downloaded gem under `pkg/` and repeat the installed-host check with
77
+ `--built`, followed by `bin/verify-package --rails --audit`. Do not rebuild the
78
+ gem between downloading and checking it. Confirm the rendered stable and
79
+ `/next/` guides, API links, and version menu after the Docs deployment succeeds.
@@ -15,33 +15,34 @@ After reading this guide, you will know:
15
15
  * How to move between versioned releases.
16
16
  * Where to find changes that need code updates.
17
17
 
18
- ## Move from 0.1 to 0.2
18
+ ## Move from 0.3 to 0.4
19
19
 
20
- Change your Gemfile and update the dependency:
20
+ Update your Gemfile and dependency:
21
21
 
22
22
  ```ruby
23
- gem 'ruby_llm-ag_ui', '~> 0.2.0'
23
+ gem 'ruby_llm-ag_ui', '~> 0.4.0'
24
24
  ```
25
25
 
26
26
  ```sh
27
27
  bundle update ruby_llm-ag_ui
28
28
  ```
29
29
 
30
- The 0.2 release keeps the 0.1 run, store, and Rails APIs. It does not require
31
- another migration or installer run.
30
+ This release keeps JSON 2.x and the 0.3 store revision contract. It needs no
31
+ additional SQL migration. Drain old workers before replacing their code.
32
32
 
33
- Tool progress is off by default. Set `config.emit_tool_progress = true` only
34
- when your client handles activity snapshots, and review its redaction policy.
35
- See [Tool Progress]({% link _core_features/tool-progress.md %}).
33
+ Remove assignments to `config.allow_client_history`. The unused setting is
34
+ removed, including its diagnostic key. The gem never imports client messages
35
+ into the host chat; reconcile history in your host application.
36
36
 
37
- ## Completed Resume Retries in 0.2
37
+ `config.protocol_version` remains `"1.0"`. Assigning any other value now raises
38
+ `ConfigurationError` instead of accepting a setting the emitted events ignore.
38
39
 
39
- An exact retry of a completed resume run now returns its recorded outcome.
40
- Keep the original run id and full input, including `resume`. A new run id that
41
- tries to answer an already answered interrupt is still refused, and changed
42
- input under the original id is a conflict. No approval or tool is executed again.
40
+ Nested request and JSON record values are now read-only. In-place edits raise
41
+ `FrozenError`. Build a new input, or use record transitions and `store.save`,
42
+ instead of mutating ids, snapshots, failure hashes, or interrupt values.
43
+ Caller-owned JSON objects remain mutable and do not alias the stored record.
43
44
 
44
- ## Older Development Checkouts
45
+ ## Older Releases
45
46
 
46
- For the initial release's generator namespace correction, read the
47
- [0.1 upgrading guide](https://github.com/yorzi/ruby_llm-ag-ui/blob/v0.1.0/docs/_reference/upgrading.md).
47
+ Read the [0.3 upgrading guide](https://github.com/yorzi/ruby_llm-ag-ui/blob/v0.3.0/docs/_reference/upgrading.md)
48
+ for JSON 2.x, worker draining, and the custom-store revision contract.
@@ -1,7 +1,8 @@
1
1
  ---
2
2
  layout: default
3
3
  title: "What's New in 0.2"
4
- nav_order: 0
4
+ nav_order: 2
5
+ parent: Release History
5
6
  description: Verify real AG-UI client workflows and opt in to redacted tool progress.
6
7
  ---
7
8
 
@@ -0,0 +1,62 @@
1
+ ---
2
+ layout: default
3
+ title: "What's New in 0.3"
4
+ nav_order: 30
5
+ parent: Release History
6
+ description: Verify transport failure, scoped cancellation, and explicit worker recovery.
7
+ ---
8
+
9
+ # {{ page.title }}
10
+
11
+ {{ page.description }}
12
+ {: .fs-6 .fw-300 }
13
+
14
+ After reading this guide, you will know:
15
+
16
+ * How a run continues after its client disconnects.
17
+ * How to reconnect without executing a turn twice.
18
+ * How to recover after confirmed worker loss.
19
+ * How host cancellation differs from HTTP abort and provider timeout.
20
+
21
+ ## Keep the Recorded Outcome
22
+
23
+ ```ruby
24
+ record = RubyLLM::AgUI::Run.new(chat: chat, input: input, scope: scope,
25
+ store: store).stream(to: response_stream)
26
+ ```
27
+
28
+ If the response transport disconnects, the worker continues the same turn and
29
+ persists its real outcome. A failed terminal write cannot change an already
30
+ recorded result. This is not a background job: worker termination still stops
31
+ execution. See [Streaming Runs]({% link _core_features/streaming-runs.md %}).
32
+
33
+ ## Reconnect with the Same Input
34
+
35
+ Resend the original input and run id after completion. The store returns its
36
+ recorded outcome without running the chat or tool again. A second stream while
37
+ the original is still running is refused. See
38
+ [Reconnects and Run Identity]({% link _core_features/reconnects.md %}).
39
+
40
+ ## Recover Lost Workers Explicitly
41
+
42
+ After confirming a worker has stopped, load its authorized record and call
43
+ `store.recover(record)`. The recorded failure uses code `worker_lost` and keeps
44
+ the identity reserved. Stale record writes are refused by revision checks.
45
+ Storage acknowledgement failures propagate as `PersistenceError` rather than
46
+ inventing a terminal outcome. See
47
+ [Worker Recovery]({% link _advanced/worker-recovery.md %}).
48
+
49
+ ## Cancel the Authorized Run
50
+
51
+ The client example now shows separate controls for host cancellation and HTTP
52
+ abort. Its cancel endpoint checks the fixture actor and exact run identity;
53
+ disconnecting the browser leaves the producer running. RubyLLM's HTTP timeout
54
+ is recorded as `transport_timeout`, without raw provider details. See
55
+ [Cancellation and Timeouts]({% link _core_features/cancellation.md %}).
56
+
57
+ Version 0.3 adds independent-process SQLite tests, including a producer killed
58
+ after a synthetic tool effect.
59
+ These tests do not establish live provider or other-database behavior.
60
+
61
+ Before updating, read [Upgrading]({% link _reference/upgrading.md %}) for worker
62
+ draining, the custom-store contract, and the JSON 2.x dependency requirement.
@@ -10,8 +10,8 @@ module RubyLLM
10
10
  # config.logger = Rails.logger
11
11
  # end
12
12
  #
13
- # Every value can be overridden per run by passing the matching keyword to
14
- # RubyLLM::AgUI::Run.new.
13
+ # Run.new can override storage, logging, redaction, clock, interrupt expiry,
14
+ # and tool progress. Input.parse uses the configured request limits.
15
15
  class Configuration
16
16
  # The object that reserves run identity and stores interrupts. Defaults
17
17
  # to nil; set a RubyLLM::AgUI::Store::MemoryStore for single-process use,
@@ -38,7 +38,17 @@ module RubyLLM
38
38
 
39
39
  # The AG-UI protocol version this producer speaks, emitted on
40
40
  # RUN_STARTED so a consumer can detect a downgrade.
41
- attr_accessor :protocol_version
41
+ attr_reader :protocol_version
42
+
43
+ # Accepts only the protocol implemented by this producer. A different
44
+ # version is refused instead of silently reporting a misleading setting.
45
+ def protocol_version=(value)
46
+ unless value == Protocol::PROTOCOL_VERSION
47
+ raise ConfigurationError, "This producer supports protocol #{Protocol::PROTOCOL_VERSION} only."
48
+ end
49
+
50
+ @protocol_version = value
51
+ end
42
52
 
43
53
  # Maximum accepted request body size in bytes.
44
54
  attr_accessor :max_input_bytes
@@ -58,23 +68,17 @@ module RubyLLM
58
68
  # A callable returning the current UTC Time. Injected in tests.
59
69
  attr_accessor :clock
60
70
 
61
- # Whether client-supplied message history is reconciled against
62
- # host-stored history. Always off in the first release: client messages
63
- # are never trusted as system or tool turns.
64
- attr_accessor :allow_client_history
65
-
66
71
  def initialize
67
72
  @run_store = nil
68
73
  @redact = Redaction.method(:default)
69
74
  @logger = nil
70
- @protocol_version = '1.0'
75
+ @protocol_version = Protocol::PROTOCOL_VERSION
71
76
  @max_input_bytes = 256_000
72
77
  @max_messages = 500
73
78
  @max_tools = 64
74
79
  @max_context = 64
75
80
  @interrupt_ttl = 900
76
81
  @clock = -> { Time.now.utc }
77
- @allow_client_history = false
78
82
  @emit_tool_progress = false
79
83
  end
80
84
 
@@ -110,7 +114,6 @@ module RubyLLM
110
114
  max_tools: max_tools,
111
115
  max_context: max_context,
112
116
  interrupt_ttl: interrupt_ttl,
113
- allow_client_history: allow_client_history,
114
117
  emit_tool_progress: emit_tool_progress
115
118
  }
116
119
  end
@@ -14,7 +14,7 @@ module RubyLLM
14
14
  # The emitter decides nothing about the outcome and executes nothing. What it
15
15
  # owns is the one ordering rule a caller should never have to remember: a
16
16
  # run's open text, tool calls and step are closed before the terminal event.
17
- class Emitter
17
+ class Emitter # :nodoc:
18
18
  # The run record, including the sequence numbers written so far.
19
19
  attr_reader :record
20
20
 
@@ -94,7 +94,11 @@ module RubyLLM
94
94
  private
95
95
 
96
96
  def emit(event)
97
+ return if @detached
98
+
97
99
  @writer.write(event)
100
+ rescue TransportError
101
+ @detached = true
98
102
  end
99
103
 
100
104
  # Closes whatever content is still open, then writes the terminal event.
@@ -108,7 +112,7 @@ module RubyLLM
108
112
  end
109
113
 
110
114
  def persist(record)
111
- @store.save(record)
115
+ Persistence.write { @store.save(record) }
112
116
  end
113
117
 
114
118
  def now
@@ -37,6 +37,10 @@ module RubyLLM
37
37
  end
38
38
  end
39
39
 
40
+ # An observed run was changed by another writer. Reload before deciding
41
+ # whether an update is still valid; never overwrite the newer outcome.
42
+ class StaleRecordError < RunConflictError; end
43
+
40
44
  # Raised when run identity is required but missing.
41
45
  class InvalidRunIdentityError < InvalidInputError; end
42
46
 
@@ -56,10 +60,17 @@ module RubyLLM
56
60
  # Raised when the pinned protocol version is not the one this gem speaks.
57
61
  class UnsupportedProtocolVersionError < InputError; end
58
62
 
59
- # Raised when the stream cannot be closed in order (for example the
60
- # transport died mid-run). The run is reported as RUN_ERROR.
63
+ # Raised when run or stream ordering cannot be honored.
61
64
  class StreamError < Error; end
62
65
 
66
+ # The response transport is closed. A running producer detaches its writer
67
+ # and continues to persist the real outcome while its worker remains alive.
68
+ class TransportError < StreamError; end
69
+
70
+ # A store write failed without a reliable acknowledgement. The persisted
71
+ # outcome may be unknown; inspect storage before attempting recovery.
72
+ class PersistenceError < Error; end
73
+
63
74
  # Raised when RubyLLM paused the run for something the pinned AG-UI shape
64
75
  # cannot express as an interrupt this producer may answer, such as an MCP
65
76
  # input request or a long-running MCP task. Reported as a sanitized
@@ -9,7 +9,7 @@ module RubyLLM
9
9
  # module never does that: it classifies the error by class and returns a
10
10
  # fixed, public message. The raw exception goes to the host logger, if the
11
11
  # host configured one, and nowhere else.
12
- module ErrorSanitizer
12
+ module ErrorSanitizer # :nodoc:
13
13
  # Ordered by specificity. The first ancestor of the error whose name is a
14
14
  # key wins, so subclass relationships are respected without loading
15
15
  # optional error classes eagerly.
@@ -40,6 +40,7 @@ module RubyLLM
40
40
  ],
41
41
  'RubyLLM::AgUI::StreamError' => ['The run could not be streamed to completion.', 'stream_failed'],
42
42
  'RubyLLM::Error' => ['The model provider returned an error.', 'provider_error'],
43
+ 'Faraday::TimeoutError' => ['The model provider request timed out.', 'transport_timeout'],
43
44
  'Faraday::Error' => ['The model provider request failed.', 'transport_error'],
44
45
  'Timeout::Error' => ['The model provider request timed out.', 'transport_timeout'],
45
46
  'Errno::ETIMEDOUT' => ['The model provider request timed out.', 'transport_timeout']
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyLLM
4
+ module AgUI
5
+ # Isolated JSON-shaped values for request and storage boundaries.
6
+ module Immutable # :nodoc:
7
+ module_function
8
+
9
+ def copy(value)
10
+ case value
11
+ when Hash
12
+ value.to_h { |key, item| [copy(key), copy(item)] }.freeze
13
+ when Array
14
+ value.map { |item| copy(item) }.freeze
15
+ when String, Time
16
+ value.dup.freeze
17
+ when ::AgUiProtocol::Core::Types::Model
18
+ copy_model(value)
19
+ else
20
+ value
21
+ end
22
+ end
23
+
24
+ def copy_model(value)
25
+ value.dup.tap do |model|
26
+ model.instance_variables.each do |name|
27
+ model.instance_variable_set(name, copy(model.instance_variable_get(name)))
28
+ end
29
+ end.freeze
30
+ end
31
+ private_class_method :copy_model
32
+ end
33
+ end
34
+ end
@@ -17,8 +17,8 @@ module RubyLLM
17
17
  #
18
18
  # Nothing here grants trust. Client messages, state, tools, context and
19
19
  # forwardedProps are accepted as data only; the host decides which tools
20
- # and model a run may use, and client history is reconciled by id against
21
- # host-stored history rather than appended as trusted system or tool turns.
20
+ # and model a run may use. This gem never reconciles or appends client
21
+ # history to the host chat. The host owns that policy.
22
22
  class Input
23
23
  # The protocol versions this gem can act on.
24
24
  SUPPORTED_PROTOCOL_VERSIONS = [Protocol::PROTOCOL_VERSION].freeze
@@ -71,6 +71,7 @@ module RubyLLM
71
71
  end
72
72
 
73
73
  def initialize(attributes)
74
+ attributes = Immutable.copy(attributes)
74
75
  @thread_id = attributes[:thread_id]
75
76
  @run_id = attributes[:run_id]
76
77
  @parent_run_id = attributes[:parent_run_id]
@@ -118,7 +119,7 @@ module RubyLLM
118
119
  #
119
120
  # Kept separate from Input so the value object stays immutable and every
120
121
  # failure message stays in one place.
121
- class Parser
122
+ class Parser # :nodoc:
122
123
  include Validation
123
124
 
124
125
  MAX_NESTING = 32
@@ -246,7 +247,7 @@ module RubyLLM
246
247
 
247
248
  # Builds the composite members of a RunAgentInput: the client tool
248
249
  # definitions, the context entries and the resume entries.
249
- class PartBuilder
250
+ class PartBuilder # :nodoc:
250
251
  include Validation
251
252
 
252
253
  def tools(values)