e2e_rb 0.1.0.beta

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c62996900399ca2c5297b570d8df16489b67d485e4a3286ddac4ac76b499b287
4
+ data.tar.gz: 712cdae49e9018cd2767d00f2a03339f44617419a9b071b18a68901c50f94e16
5
+ SHA512:
6
+ metadata.gz: 87757e679bc5434e3d4c5c229337dd1f35bdd3a0a0bc0a510807a2c170c52e06671b463d69adbf817d24d1336bcdd80576e9419fef1e9eb2c9294eb175ab976b
7
+ data.tar.gz: b41a292abee423aff3c11b4c2aa3c2cd88ddba4a26ffd4d66279260bca92dba8a5b8a668a6e3083cca8dbe3566668f7729371a95f1faa93d44b1b665f1ed6e67
data/CHANGELOG.md ADDED
@@ -0,0 +1,24 @@
1
+ # Changelog
2
+
3
+ All notable changes to e2e_rb. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/);
4
+ versions follow [Semantic Versioning](https://semver.org/).
5
+
6
+ ## [Unreleased]
7
+
8
+ ## [0.1.0.beta] - 2026-12-01
9
+
10
+ First release, a beta (git tag `v0.1.0.beta`): `gem install e2e_rb --pre`.
11
+ Works with e2e `~> 0.23.1` (npm), Ruby >= 3.2, RSpec 3.13, Minitest 5 and 6.
12
+
13
+ ### Added
14
+ - RSpec adapter (`require "e2e_rb/rspec"`, `type: :e2e`) with e2e's 16 locator/screen matchers.
15
+ - Minitest adapter (`require "e2e_rb/minitest"`): `include E2eRb::Minitest` into any `Minitest::Test`
16
+ subclass, or subclass `E2eRb::Minitest::Test`; `assert_*` / `refute_*` for all 16 matchers.
17
+ - One e2e session per test through a Node bridge (`bridge/server.mjs`, JSON-RPC 2.0 on fd 3).
18
+ - The e2e host closes at the end of the suite; a close failure fails the run.
19
+ - Strict settings (`E2E_RB_*` / `E2eRb.configure`): malformed values and unknown `E2E_RB_*` names raise.
20
+ - Ruby regexps are translated to JavaScript (`\A`, `\z`, `\Z`, `\h`, line anchors); syntax JavaScript
21
+ lacks raises `ArgumentError`.
22
+ - The bridge refuses a Node outside e2e's `engines.node` and results that have no JSON form.
23
+ - The gem passes RubyGems' strict validation (`gem build --strict`: no warnings); `rake` runs the unit
24
+ specs and RuboCop, `rake build` packages the gem (strict); there is no `rake release`.
data/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
data/README.md ADDED
@@ -0,0 +1,219 @@
1
+ # e2e_rb
2
+
3
+ [![License: Apache-2.0](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](LICENSE)
4
+ [![Ruby >= 3.2](https://img.shields.io/badge/ruby-%3E%3D%203.2-red.svg)](e2e_rb.gemspec)
5
+ [![e2e ~> 0.23.1](https://img.shields.io/badge/e2e-~%3E%200.23.1-black.svg)](https://github.com/e2e-inc/e2e)
6
+
7
+ RSpec and Minitest tests on top of [e2e](https://github.com/e2e-inc/e2e), the agentic end-to-end
8
+ testing framework: `agent.act` / `agent.assert` plus e2e's auto-waiting locators and `expect`, from Ruby.
9
+
10
+ - **Ruby owns the test run**: RSpec / Minitest collection, hooks, filters and reporting; e2e owns the browser, the
11
+ model, secrets and traces.
12
+ - **Agentic and deterministic steps in one test**: `agent.act("…")` next to `screen.get_by_role(…).click`.
13
+ - **e2e's own matchers**, as RSpec matchers and Minitest assertions (16 each), auto-waiting.
14
+ - **Any app** e2e can start, any [AI SDK](https://ai-sdk.dev) model, or none (deterministic steps need no model).
15
+ - **Process parallelism**: one bridge and one app port per worker.
16
+
17
+ ```ruby
18
+ RSpec.describe "billing", type: :e2e do
19
+ it "upgrades to Pro" do
20
+ app.open("/settings/billing")
21
+ agent.act("upgrade the workspace to the Pro plan")
22
+ agent.assert("the invoice preview shows a prorated amount")
23
+ expect(screen.get_by_role("status")).to contain_text("Pro")
24
+ end
25
+ end
26
+ ```
27
+
28
+ ```ruby
29
+ class BillingTest < MyApp::Test # your suite's own base class
30
+ include E2eRb::Minitest
31
+
32
+ def test_upgrade
33
+ app.open("/settings/billing")
34
+ screen.get_by_role("button", "Upgrade").click
35
+ assert_contains_text screen.get_by_role("status"), "Pro"
36
+ end
37
+ end
38
+ ```
39
+
40
+ ## Install
41
+
42
+ | | |
43
+ | --- | --- |
44
+ | Ruby | `gem "e2e_rb", "~> 0.1.0.beta"` in the `Gemfile`, or `gem install e2e_rb --pre` (Ruby >= 3.2; RSpec 3.13, Minitest 5 or 6) |
45
+ | Node | `^22.22.3 \|\| >=24.8.0` (e2e's `engines.node`; the bridge refuses any other) |
46
+ | npm, in the project under test | `npm i -D e2e@~0.23.1 @e2e-dev/web` (the web engine) — e2e_rb `0.1.x` needs e2e `~> 0.23.1` |
47
+ | Browser | the Chromium build of the engine's `playwright-core`: `npx playwright-core install --with-deps chromium` |
48
+
49
+ The project under test is a normal e2e project: `package.json` with `e2e` and an engine, plus `e2e.config.ts`
50
+ (targets, how to start the app, agents/models). [`example/`](example/) is a complete one.
51
+
52
+ ### Docker
53
+
54
+ Headless; no X server. Either start from Playwright's image (`mcr.microsoft.com/playwright:v<playwright-core
55
+ version>-noble`, Node and browsers included) and add Ruby, or start from Ruby and add Node + Chromium, as this
56
+ repo's [`Dockerfile`](Dockerfile) does:
57
+
58
+ ```dockerfile
59
+ FROM node:24.21.0-bookworm-slim AS node
60
+ FROM ruby:3.4-slim-bookworm
61
+ COPY --from=node /usr/local/bin/node /usr/local/bin/node
62
+ COPY --from=node /usr/local/lib/node_modules /usr/local/lib/node_modules
63
+ RUN ln -s ../lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm
64
+ ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
65
+ # ... bundle install, then in the e2e project:
66
+ RUN npm ci && node_modules/.bin/playwright-core install --with-deps chromium
67
+ ```
68
+
69
+ ### CI without a model
70
+
71
+ Locators, actions and matchers are deterministic: they need no model and no network. With no model in
72
+ `e2e.config.ts`, an `agent.*` step fails at once with e2e's `MODEL_UNAVAILABLE` (an `E2eRb::ConfigurationError`);
73
+ everything else runs. This repo's own suite runs that way in a container with **no network at all**
74
+ (`network_mode: none`), so a gate built on deterministic steps cannot depend on a model or the internet.
75
+
76
+ ### Telemetry
77
+
78
+ e2e's CLI sends anonymous usage data. In e2e 0.23.1 only `e2e run` and the CLI send it; the host API the
79
+ bridge uses (`openHost`) sends none. Set `E2E_TELEMETRY_DISABLED=1` (or `DO_NOT_TRACK=1`) anyway, e.g. in CI,
80
+ so a future e2e that adds it stays off. [e2e's telemetry docs](https://github.com/e2e-inc/e2e#telemetry).
81
+
82
+ ## Settings
83
+
84
+ e2e's own config is `e2e.config.ts`. e2e_rb's settings are these env vars, or `E2eRb.configure { |c| ... }`
85
+ (before the first session):
86
+
87
+ | env | default | meaning |
88
+ | --- | --- | --- |
89
+ | `E2E_RB_PROJECT_DIR` | cwd | directory with `package.json`, `node_modules/e2e`, `e2e.config.ts` |
90
+ | `E2E_RB_CONFIG` | e2e's discovery | config file, relative to the project dir |
91
+ | `E2E_RB_TARGET` | e2e's rule (the only target) | target name |
92
+ | `E2E_RB_HEADED` | `0` | `1` runs the browser headed |
93
+ | `E2E_RB_NODE` | `node` | Node executable |
94
+ | `E2E_RB_TIMEOUT_MS` | config's `timeout` | per-test session deadline, a positive integer |
95
+ | `E2E_RB_VERBOSE` | `0` | `1` prints every e2e step |
96
+
97
+ Values are checked: a flag other than `0`/`1`, a timeout that is not a positive integer, a project dir without
98
+ `package.json`, or an `E2E_RB_*` name not in this table raises `E2eRb::ConfigurationError` naming it.
99
+
100
+ Also fails loudly on: an e2e version outside `E2eRb::E2E_REQUIREMENT`, a Node outside e2e's `engines.node`, a
101
+ protocol mismatch, a missing `node_modules/e2e`, an unknown fixture. e2e's own errors (e.g. `MODEL_UNAVAILABLE`)
102
+ arrive with their code.
103
+
104
+ ### Models
105
+
106
+ The model is e2e's `agents` config, any [AI SDK](https://ai-sdk.dev) model. [`example/e2e.config.ts`](example/e2e.config.ts)
107
+ picks it from env, explicitly: `E2E_MODEL_PROVIDER=openai-compatible` + `E2E_MODEL_BASE_URL` + `E2E_MODEL` for any
108
+ OpenAI-compatible server (a local vLLM, llama.cpp, Ollama, ...), or `E2E_MODEL_PROVIDER=gateway` + `E2E_MODEL` +
109
+ `AI_GATEWAY_API_KEY`. A half-set combination fails, naming what is missing.
110
+
111
+ ## Writing tests
112
+
113
+ ### RSpec
114
+
115
+ ```ruby
116
+ require "e2e_rb/rspec" # tag groups with type: :e2e
117
+ ```
118
+
119
+ ### Minitest
120
+
121
+ ```ruby
122
+ require "e2e_rb/minitest"
123
+ class BrowserTest < MyApp::Test
124
+ include E2eRb::Minitest # or: class BrowserTest < E2eRb::Minitest::Test
125
+ end
126
+ ```
127
+
128
+ ### Matchers
129
+
130
+ e2e's 16 locator/screen matchers, one table ([`lib/e2e_rb/matchers.rb`](lib/e2e_rb/matchers.rb)), all taking e2e's
131
+ options (e.g. `timeout: 500`):
132
+
133
+ | e2e | RSpec | Minitest |
134
+ | --- | --- | --- |
135
+ | `toBeVisible` `toBeHidden` `toBeAttached` | `be_visible` `be_hidden` `be_attached` | `assert_/refute_visible` `_hidden` `_attached` |
136
+ | `toBeEnabled` `toBeDisabled` `toBeChecked` | `be_enabled` `be_disabled` `be_checked` | `_enabled` `_disabled` `_checked` |
137
+ | `toBeSelected` `toBeExpanded` `toBeFocused` | `be_selected` `be_expanded` `be_focused` | `_selected` `_expanded` `_focused` |
138
+ | `toHaveText` `toContainText` `toHaveValue` | `have_text` `contain_text` `have_value` | `_text` `_contains_text` `_value` |
139
+ | `toHaveAttribute` `toHaveCount` | `have_attribute` `have_count` | `_attribute` `_count` |
140
+ | `toHaveAccessibleName` `toHaveScreenshot` | `have_accessible_name` `have_screenshot` | `_accessible_name` `_screenshot` |
141
+
142
+ Any matcher also as `e2e_expect(locator).to_have_text("x")` / `.not.to_be_visible`.
143
+
144
+ Text matchers take strings or Ruby regexps. Regexps are translated: `^`/`$` stay line anchors, `\A` `\z` `\Z` `\h`
145
+ work, `/m` is JavaScript's `s`; syntax JavaScript lacks (`\G`, `\K`, atomic groups, inline options, `&&`) raises
146
+ `ArgumentError`.
147
+
148
+ ### Failures
149
+
150
+ A failed matcher or `agent.assert` is the framework's own failure (`ExpectationNotMetError` / `Minitest::Assertion`);
151
+ config and infrastructure problems are errors. Every failed e2e test names its `trace.md`, whatever failed.
152
+ The e2e host (the app, the engine) closes at the end of the suite; if that fails, the run fails with the reason.
153
+
154
+ ## How it works
155
+
156
+ ```
157
+ Ruby process Node process (one per Ruby process)
158
+ ┌────────────────────────────┐ stdin ─────► ┌───────────────────────────────────┐
159
+ │ RSpec / Minitest adapter │ │ bridge/server.mjs │
160
+ │ E2eRb core: Proxy, Session, │ JSON-RPC 2.0 │ e2e/runner openHost() │
161
+ │ Expectation, Bridge │ LSP framing │ host.openSession() per test │
162
+ └────────────────────────────┘ ◄───── fd 3 │ engine · model · secrets · trace │
163
+ └───────────────────────────────────┘
164
+ ```
165
+
166
+ - Ruby owns collection, hooks, retries and reporting. e2e owns the engine, the model, secrets and traces.
167
+ - One e2e **session per test**: opened before each test, closed after it. Close-time failures
168
+ (soft expectations, cleanup) fail the test.
169
+ - `screen.get_by_role("button", "greet").click` sends the whole call chain; Node re-applies it to the
170
+ session's `screen`. Locators are immutable expressions in e2e, so nothing is held across the wire.
171
+ Two locator proxies of the same expression are `==` and hash alike.
172
+ - Ruby names map to e2e names: `get_by_label` → `getByLabel`, `visible?` → `isVisible`,
173
+ option keys `max_steps:` → `maxSteps` (`params:` keys stay as written). A member e2e does not have is a
174
+ `NoMethodError`.
175
+ - Results cross as JSON; a result with no JSON form (a Buffer, a class instance) is refused with its type.
176
+ - A request abandoned by `Timeout` or `Interrupt` does not break the session: its late reply is skipped.
177
+ - Secrets never enter Ruby: `secret(:api_token)`, `credential(:admin, :password)` send only names.
178
+ - Protocol output goes to fd 3, so anything e2e or a browser prints to stdout cannot corrupt it.
179
+
180
+ ## Parallelism
181
+
182
+ e2e allows one hosted session per process, so parallelize with processes (one Ruby process per test file,
183
+ parallel_tests, `rspec` per shard), not threads: `parallelize_me!` and any parallel run order raise. A forked
184
+ worker starts its own bridge. Use a port-0 app URL (`http://127.0.0.1:0` + `env: { PORT: '{port}' }`) so each
185
+ worker's app gets its own free port. CI runs 4 worker processes at once and checks each had its own bridge and
186
+ app port with all 4 sessions open together ([`scripts/parallel_workers.rb`](scripts/parallel_workers.rb)).
187
+
188
+ ## Known limits
189
+
190
+ - **No replay cache**: e2e's public host API (`openHost`) gives hosted sessions no stable test identity or
191
+ verdict, so `agent.act` calls the model on every run under e2e_rb. Deterministic steps are unaffected.
192
+ Needs an upstream e2e change (`openSession({ testId, attempt })` + a verdict on close).
193
+ - No in-process app or transactional rollback: the app is its own process (started by e2e from
194
+ `e2e.config.ts`); reset state in your own `setup` / `before` hooks.
195
+ - Not yet: `agent.extract` with a schema (Standard Schema has no wire form yet), custom `test.extend()`
196
+ fixtures, cancelling a running step (a step runs to its own timeout).
197
+
198
+ ## Develop
199
+
200
+ Everything runs in Docker:
201
+
202
+ ```bash
203
+ cp .env.example .env
204
+ docker compose build
205
+ docker compose run --rm test # scripts/ci/suite.sh: bridge tests, unit specs, RSpec + Minitest
206
+ # examples, parallel workers, the built gem installed — no network
207
+ docker compose run --rm agentic # agent steps against a real model (E2E_MODEL_*, .env.example)
208
+ scripts/ci/test.sh matrix # what CI runs: Ruby 3.2 / 3.3 / 3.4 / 4.0, Minitest 6 and 5
209
+ docker compose run --rm test bundle exec rake # only the unit specs + RuboCop (Rakefile)
210
+ ```
211
+
212
+ ## Contributing
213
+
214
+ Issues and pull requests are welcome: [CONTRIBUTING.md](CONTRIBUTING.md) (setup, tests, what a PR needs).
215
+ Security issues: [SECURITY.md](SECURITY.md), never a public issue. Changes per release: [CHANGELOG.md](CHANGELOG.md).
216
+
217
+ ## License
218
+
219
+ [Apache-2.0](LICENSE). e2e itself is a separate project ([e2e-inc/e2e](https://github.com/e2e-inc/e2e), Apache-2.0).
@@ -0,0 +1,66 @@
1
+ // Does a Node version satisfy a package's `engines.node` range? The subset of npm's
2
+ // range syntax packages use for `engines`: `||` alternatives of space-separated
3
+ // comparators (`>=`, `>`, `<=`, `<`, `=`, bare), `^` and `~` ranges, `x` wildcards.
4
+ // Anything else throws: an unreadable range is reported, never guessed at.
5
+
6
+ function parse(version, range) {
7
+ const match = /^v?(\d+|[xX*])(?:\.(\d+|[xX*]))?(?:\.(\d+|[xX*]))?$/.exec(version);
8
+ if (match === null) throw new Error(`cannot read version ${JSON.stringify(version)} in engines range ${JSON.stringify(range)}`);
9
+ return match.slice(1).map((part) => (part === undefined || /^[xX*]$/.test(part) ? undefined : Number(part)));
10
+ }
11
+
12
+ function compare(a, b) {
13
+ for (let i = 0; i < 3; i += 1) if (a[i] !== b[i]) return a[i] < b[i] ? -1 : 1;
14
+ return 0;
15
+ }
16
+
17
+ // A partial version as the [lower, upper) interval it stands for: 22 -> [22.0.0, 23.0.0).
18
+ function interval(parts) {
19
+ const [major, minor, patch] = parts;
20
+ if (major === undefined) return [[0, 0, 0], undefined];
21
+ if (minor === undefined) return [[major, 0, 0], [major + 1, 0, 0]];
22
+ if (patch === undefined) return [[major, minor, 0], [major, minor + 1, 0]];
23
+ return [[major, minor, patch], [major, minor, patch + 1]];
24
+ }
25
+
26
+ function comparator(token, range) {
27
+ const match = /^(\^|~|>=|<=|>|<|=)?(.+)$/.exec(token);
28
+ const [, operator = '=', version] = match;
29
+ const parts = parse(version, range);
30
+ const [lower, upper] = interval(parts);
31
+ const full = parts.map((part) => part ?? 0);
32
+ switch (operator) {
33
+ case '=':
34
+ return (v) => compare(v, lower) >= 0 && (upper === undefined || compare(v, upper) < 0);
35
+ case '>=':
36
+ return (v) => compare(v, full) >= 0;
37
+ case '>':
38
+ return (v) => (upper === undefined ? false : compare(v, upper) >= 0);
39
+ case '<':
40
+ return (v) => compare(v, full) < 0;
41
+ case '<=':
42
+ return (v) => upper === undefined || compare(v, upper) < 0;
43
+ case '^': {
44
+ const [major, minor, patch] = full;
45
+ const ceiling = major > 0 || parts[1] === undefined ? [major + 1, 0, 0] : minor > 0 || parts[2] === undefined ? [0, minor + 1, 0] : [0, 0, patch + 1];
46
+ return (v) => compare(v, full) >= 0 && compare(v, ceiling) < 0;
47
+ }
48
+ case '~': {
49
+ const ceiling = parts[1] === undefined ? [full[0] + 1, 0, 0] : [full[0], full[1] + 1, 0];
50
+ return (v) => compare(v, full) >= 0 && compare(v, ceiling) < 0;
51
+ }
52
+ default:
53
+ throw new Error(`cannot read engines range ${JSON.stringify(range)}`);
54
+ }
55
+ }
56
+
57
+ export function satisfies(version, range) {
58
+ if (typeof range !== 'string' || range.trim() === '') throw new Error(`cannot read engines range ${JSON.stringify(range)}`);
59
+ const current = parse(version, range).map((part) => part ?? 0);
60
+ return range.split('||').some((alternative) => {
61
+ const tokens = alternative.trim().replace(/(>=|<=|>|<|=|\^|~)\s+/g, '$1').split(/\s+/);
62
+ if (tokens.length === 1 && tokens[0] === '') throw new Error(`cannot read engines range ${JSON.stringify(range)}`);
63
+ if (tokens.includes('-')) throw new Error(`hyphen ranges are not supported in engines range ${JSON.stringify(range)}`);
64
+ return tokens.map((token) => comparator(token, range)).every((test) => test(current));
65
+ });
66
+ }
data/bridge/plain.mjs ADDED
@@ -0,0 +1,34 @@
1
+ // Results cross the wire as JSON values only. A class instance, a Buffer, a Map, a function,
2
+ // a non-finite number has no faithful wire form, so it is refused with its type instead of
3
+ // arriving in Ruby as {} or a byte array. `undefined` keeps its JSON meaning: null inside
4
+ // an array, left out of an object.
5
+
6
+ export function wireError(message) {
7
+ const error = new Error(message);
8
+ error.name = 'BridgeProtocolError';
9
+ error.code = 'BRIDGE_PROTOCOL';
10
+ return error;
11
+ }
12
+
13
+ export function plain(value, where) {
14
+ if (value === null || typeof value === 'string' || typeof value === 'boolean') return value;
15
+ if (typeof value === 'number') {
16
+ if (!Number.isFinite(value)) throw wireError(`${where} is ${value}, which JSON cannot carry`);
17
+ return value;
18
+ }
19
+ if (Array.isArray(value)) {
20
+ return value.map((inner, index) => (inner === undefined ? null : plain(inner, `${where}[${index}]`)));
21
+ }
22
+ if (typeof value === 'object') {
23
+ const proto = Object.getPrototypeOf(value);
24
+ if (proto !== Object.prototype && proto !== null) {
25
+ throw wireError(`${where} is a ${value.constructor?.name ?? 'non-plain object'}, which has no wire form`);
26
+ }
27
+ const out = {};
28
+ for (const [key, inner] of Object.entries(value)) {
29
+ if (inner !== undefined) out[key] = plain(inner, `${where}.${key}`);
30
+ }
31
+ return out;
32
+ }
33
+ throw wireError(`${where} is a ${typeof value}, which has no wire form`);
34
+ }