recovery-probe 0.2.0 → 0.3.0-preview.2
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.
- package/CHANGELOG.md +36 -18
- package/CONTRIBUTING.md +39 -39
- package/LICENSE +21 -21
- package/README.md +233 -206
- package/SECURITY.md +26 -18
- package/bin/core-demo.mjs +8 -8
- package/bin/desktop.mjs +82 -0
- package/bin/recovery-probe.mjs +135 -120
- package/bin/repair.mjs +66 -0
- package/bin/web.mjs +66 -0
- package/docs/demo.svg +70 -70
- package/docs/desktop.md +133 -0
- package/docs/repair.md +208 -0
- package/examples/core-demo.mjs +39 -39
- package/examples/demo-server.mjs +57 -56
- package/examples/profile-controller.mjs +26 -26
- package/package.json +100 -84
- package/src/desktop-report.mjs +22 -0
- package/src/desktop.d.mts +23 -0
- package/src/desktop.mjs +213 -0
- package/src/fetch-fault.d.mts +19 -19
- package/src/fetch-fault.mjs +54 -54
- package/src/index.d.ts +26 -26
- package/src/index.mjs +159 -159
- package/src/repair-process.mjs +48 -0
- package/src/repair-provider.mjs +35 -0
- package/src/repair.mjs +249 -0
- package/src/web.d.mts +10 -0
- package/src/web.mjs +29 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,18 +1,36 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
All notable changes to Recovery Probe are documented here. The project follows [Semantic Versioning](https://semver.org/).
|
|
4
|
-
|
|
5
|
-
Version 0.2.0 is the first npm release. Earlier 0.1.x revisions were repository-only prototypes.
|
|
6
|
-
|
|
7
|
-
## [0.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to Recovery Probe are documented here. The project follows [Semantic Versioning](https://semver.org/).
|
|
4
|
+
|
|
5
|
+
Version 0.2.0 is the first npm release. Earlier 0.1.x revisions were repository-only prototypes.
|
|
6
|
+
|
|
7
|
+
## [0.3.0-preview.2] - Unreleased
|
|
8
|
+
|
|
9
|
+
- Add Chromium web discovery/checks and explicit private login-state saving.
|
|
10
|
+
- Add opt-in OpenAI source-edit proposals from selected source files and reproduced evidence.
|
|
11
|
+
- Reproduce and verify in a separate local clone; preserve the original repository and never push/deploy a candidate.
|
|
12
|
+
- Reject unsafe paths, ambiguous replacements, dirty baselines, preexisting target ports and setup/test mutations.
|
|
13
|
+
- Separate reviewed verification from explicit opt-in execution of unreviewed generated code.
|
|
14
|
+
- Add authenticated web and Electron before/after integration tests with controlled provider responses.
|
|
15
|
+
- Clarify release stages and source-upload/report privacy boundaries. Live model fix quality is not yet validated.
|
|
16
|
+
|
|
17
|
+
## [0.3.0-preview.1] - Unreleased
|
|
18
|
+
|
|
19
|
+
- Add Electron renderer discovery and targeted recovery checks through loopback CDP.
|
|
20
|
+
- Require a successful request after fault injection and a configured healthy UI marker.
|
|
21
|
+
- Add local HTML/JSON reports, executable reproductions, and coding-agent investigation briefs.
|
|
22
|
+
- Test real Electron attachment, preload preservation, recovery failures, automatic retry, stale UI markers, and disconnect behavior.
|
|
23
|
+
- Keep source-code fixes manual and reports local; native SDK/IPC traffic is outside this preview.
|
|
24
|
+
|
|
25
|
+
## [0.2.0] - 2026-09-22
|
|
26
|
+
|
|
27
|
+
### Added
|
|
28
|
+
|
|
29
|
+
- Deterministic HTTP error, connection failure, and invalid JSON injection.
|
|
30
|
+
- Playwright `withFault` helper with bounded counts and route cleanup.
|
|
31
|
+
- Browser-independent `createFaultFetch` adapter.
|
|
32
|
+
- JSON-configured CLI runner with human-readable and machine-readable output.
|
|
33
|
+
- Broken-versus-fixed browser demonstration.
|
|
34
|
+
- Core, real-browser, package-installation, and TypeScript integration tests.
|
|
35
|
+
|
|
36
|
+
[0.2.0]: https://github.com/BojanKovachki/recovery-probe/releases/tag/v0.2.0
|
package/CONTRIBUTING.md
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
# Contributing
|
|
2
|
-
|
|
3
|
-
Thanks for helping make recovery checks easier to trust.
|
|
4
|
-
|
|
5
|
-
## Before opening a change
|
|
6
|
-
|
|
7
|
-
- Use Node.js 22 or newer.
|
|
8
|
-
- Keep changes focused on deterministic request-level recovery testing.
|
|
9
|
-
- Open an issue first for new fault models or public API changes.
|
|
10
|
-
- Do not include real credentials, production URLs, request bodies, or response bodies in fixtures or reports.
|
|
11
|
-
|
|
12
|
-
## Development setup
|
|
13
|
-
|
|
14
|
-
```bash
|
|
15
|
-
npm ci
|
|
16
|
-
npm test
|
|
17
|
-
npm run test:package
|
|
18
|
-
npx playwright install chromium
|
|
19
|
-
npm run test:browser
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
Run the controlled demonstrations when behavior or output changes:
|
|
23
|
-
|
|
24
|
-
```bash
|
|
25
|
-
npm run demo
|
|
26
|
-
npm run demo:browser
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
## Pull requests
|
|
30
|
-
|
|
31
|
-
A useful pull request:
|
|
32
|
-
|
|
33
|
-
- explains the recovery behavior it covers;
|
|
34
|
-
- includes a failing test for a bug fix;
|
|
35
|
-
- preserves the distinction between failed, inconclusive, and skipped results;
|
|
36
|
-
- keeps fault injection bounded and verifies that the fault occurred;
|
|
37
|
-
- updates the README and changelog when the public interface changes.
|
|
38
|
-
|
|
39
|
-
By submitting a contribution, you agree that it is licensed under the project's MIT license.
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
Thanks for helping make recovery checks easier to trust.
|
|
4
|
+
|
|
5
|
+
## Before opening a change
|
|
6
|
+
|
|
7
|
+
- Use Node.js 22 or newer.
|
|
8
|
+
- Keep changes focused on deterministic request-level recovery testing.
|
|
9
|
+
- Open an issue first for new fault models or public API changes.
|
|
10
|
+
- Do not include real credentials, production URLs, request bodies, or response bodies in fixtures or reports.
|
|
11
|
+
|
|
12
|
+
## Development setup
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm ci
|
|
16
|
+
npm test
|
|
17
|
+
npm run test:package
|
|
18
|
+
npx playwright install chromium
|
|
19
|
+
npm run test:browser
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Run the controlled demonstrations when behavior or output changes:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm run demo
|
|
26
|
+
npm run demo:browser
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Pull requests
|
|
30
|
+
|
|
31
|
+
A useful pull request:
|
|
32
|
+
|
|
33
|
+
- explains the recovery behavior it covers;
|
|
34
|
+
- includes a failing test for a bug fix;
|
|
35
|
+
- preserves the distinction between failed, inconclusive, and skipped results;
|
|
36
|
+
- keeps fault injection bounded and verifies that the fault occurred;
|
|
37
|
+
- updates the README and changelog when the public interface changes.
|
|
38
|
+
|
|
39
|
+
By submitting a contribution, you agree that it is licensed under the project's MIT license.
|
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 Bojan Kovachki
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Bojan Kovachki
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,206 +1,233 @@
|
|
|
1
|
-
# Recovery Probe
|
|
2
|
-
|
|
3
|
-
[](https://github.com/BojanKovachki/recovery-probe/actions/workflows/validate.yml)
|
|
4
|
-
[](https://www.npmjs.com/package/recovery-probe)
|
|
5
|
-
[](https://nodejs.org/)
|
|
6
|
-
[](LICENSE)
|
|
7
|
-
|
|
8
|
-
**
|
|
9
|
-
|
|
10
|
-
A happy-path test can pass while a
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
`
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
1
|
+
# Recovery Probe
|
|
2
|
+
|
|
3
|
+
[](https://github.com/BojanKovachki/recovery-probe/actions/workflows/validate.yml)
|
|
4
|
+
[](https://www.npmjs.com/package/recovery-probe)
|
|
5
|
+
[](https://nodejs.org/)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
|
|
8
|
+
**Find reproducible request-recovery bugs in web and Electron apps. Propose a source fix, then test the candidate.**
|
|
9
|
+
|
|
10
|
+
A happy-path test can pass while a transient failed request leaves an app permanently loading. Recovery Probe injects controlled failures and checks what happens next. Recovery may be automatic; a Retry button or special recovery screen is not required.
|
|
11
|
+
|
|
12
|
+
## Release status
|
|
13
|
+
|
|
14
|
+
| Version | Available functionality |
|
|
15
|
+
| --- | --- |
|
|
16
|
+
| npm `0.2.0` | Playwright/fetch fault helpers and the original configured CLI. No source investigation or automatic fixes. |
|
|
17
|
+
| GitHub `0.3.0-preview.2`, `feat/repair-workflow` | Web and Electron discovery/checks; browser login-state support; opt-in AI source-edit proposals; isolated-checkout before/after verification. Not yet a stable npm release. |
|
|
18
|
+
| Not implemented | General discovery/fixing of arbitrary bugs, production self-healing, autonomous deployment, native/IPC request interception. |
|
|
19
|
+
|
|
20
|
+
The repair preview needs a local source repository, explicit source-file selection, one expected outcome, app launch/test commands, and your own API key/model for generation. It does **not** obtain these from installing an npm dependency. It returns a reviewable candidate, not a guaranteed fix. [Full setup and safety guide](docs/repair.md).
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
# Preview only; pin the commit when sharing a reproducible installation.
|
|
24
|
+
npm install --save-dev github:BojanKovachki/recovery-probe#feat/repair-workflow playwright
|
|
25
|
+
npx playwright install chromium
|
|
26
|
+
npx recovery-probe web --help
|
|
27
|
+
npx recovery-probe repair --help
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+

|
|
31
|
+
|
|
32
|
+
## What it catches
|
|
33
|
+
|
|
34
|
+
Consider an application that loads normally, but forgets to clear its loading state after an error. Its ordinary end-to-end test stays green. After a transient `503`, interrupted request, or malformed response, Retry does nothing.
|
|
35
|
+
|
|
36
|
+
Recovery Probe makes that failure deterministic:
|
|
37
|
+
|
|
38
|
+
1. Match one endpoint and request method.
|
|
39
|
+
2. Inject a bounded fault without replacing global `fetch`.
|
|
40
|
+
3. Run the real recovery interaction and assertion.
|
|
41
|
+
4. Fail if the fault was never observed, so a wrong route cannot create a false positive.
|
|
42
|
+
5. Remove only its own route handler and preserve existing mocks.
|
|
43
|
+
|
|
44
|
+
## Web and Electron preview
|
|
45
|
+
|
|
46
|
+
Use `web` for a Chromium portal and `desktop` to attach to an existing development Electron renderer. Both use the same Page-level checking engine. Checks discover GET JSON endpoints, inject selected faults, and produce local evidence. Use the separate `repair` command to reproduce in a clean checkout, request an AI proposal with explicit upload consent, and rerun the scenario after applying the candidate only to that copy. See [web/repair setup](docs/repair.md) and [desktop attachment](docs/desktop.md). npm 0.2.0 includes neither workflow.
|
|
47
|
+
|
|
48
|
+
## Install
|
|
49
|
+
|
|
50
|
+
Recovery Probe is designed to be added to an existing Playwright project:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
npm install --save-dev recovery-probe
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Node.js 22 or newer is required. Playwright is an optional peer dependency: the fetch-only API works without it, while browser/desktop commands require Playwright `^1.62.1` (1.x).
|
|
57
|
+
|
|
58
|
+
## Quick start
|
|
59
|
+
|
|
60
|
+
Use `withFault` inside an existing Playwright test. The callback contains the real user action and the application-specific recovery assertion.
|
|
61
|
+
|
|
62
|
+
```js
|
|
63
|
+
import { test, expect } from '@playwright/test';
|
|
64
|
+
import { withFault } from 'recovery-probe';
|
|
65
|
+
|
|
66
|
+
test('profile recovers after a transient 503', async ({ page }) => {
|
|
67
|
+
const stats = await withFault(page, {
|
|
68
|
+
match: '**/api/profile',
|
|
69
|
+
kind: 'http-error',
|
|
70
|
+
status: 503,
|
|
71
|
+
count: 1,
|
|
72
|
+
}, async () => {
|
|
73
|
+
await page.goto('http://127.0.0.1:3000/profile');
|
|
74
|
+
await page.getByRole('button', { name: 'Retry' }).click();
|
|
75
|
+
await expect(page.getByTestId('profile-name')).toHaveText('Test User');
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
expect(stats.applied).toBe(1);
|
|
79
|
+
});
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
If the endpoint does not match, Recovery Probe throws `FAULT_NOT_TRIGGERED` instead of allowing the test to pass silently. If the fault is applied but the recovery assertion fails, it throws `RECOVERY_ASSERTION_FAILED` and retains the original assertion error as `cause`.
|
|
83
|
+
|
|
84
|
+
## Run the demonstration
|
|
85
|
+
|
|
86
|
+
The repository includes deliberately broken and corrected applications. Both pass their normal loading check; only the corrected application recovers from all three faults.
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
npm install
|
|
90
|
+
npx playwright install chromium
|
|
91
|
+
npx recovery-probe --demo
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
The command prints a concise comparison:
|
|
95
|
+
|
|
96
|
+
```text
|
|
97
|
+
broken synthetic fixture
|
|
98
|
+
PASS Normal connection (OK)
|
|
99
|
+
CAUGHT HTTP 503 once (RECOVERY_ASSERTION_FAILED, injected 1)
|
|
100
|
+
CAUGHT Interrupted request once (RECOVERY_ASSERTION_FAILED, injected 1)
|
|
101
|
+
CAUGHT Malformed JSON once (RECOVERY_ASSERTION_FAILED, injected 1)
|
|
102
|
+
|
|
103
|
+
fixed synthetic fixture
|
|
104
|
+
PASS Normal connection (OK)
|
|
105
|
+
PASS HTTP 503 once (OK, injected 1)
|
|
106
|
+
PASS Interrupted request once (OK, injected 1)
|
|
107
|
+
PASS Malformed JSON once (OK, injected 1)
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
`--demo` exits successfully only when it observes the expected contrast: the happy path passes, the broken recovery is caught, and the corrected flow passes. Add `--json` to print the full report or `--out report.json` to save it.
|
|
111
|
+
|
|
112
|
+
## Supported faults
|
|
113
|
+
|
|
114
|
+
| Kind | Injected behavior |
|
|
115
|
+
| --- | --- |
|
|
116
|
+
| `http-error` | Fulfils the matched request with an HTTP error status; defaults to `503`. |
|
|
117
|
+
| `connection-failure` | Aborts the matched Playwright request with `connectionfailed`, or throws from the fetch adapter. |
|
|
118
|
+
| `invalid-json` | Returns status `200` with a deliberately malformed JSON body. |
|
|
119
|
+
|
|
120
|
+
Faults are bounded by `count` (default `1`, maximum `20`). The count is reserved synchronously, so concurrent matching requests cannot over-inject.
|
|
121
|
+
|
|
122
|
+
## Fetch-only tests
|
|
123
|
+
|
|
124
|
+
The lightweight `recovery-probe/fetch` entry point has no runtime dependencies and does not require Playwright. It matches one exact absolute URL, including its query string, and never patches global `fetch`.
|
|
125
|
+
|
|
126
|
+
```js
|
|
127
|
+
import { createFaultFetch } from 'recovery-probe/fetch';
|
|
128
|
+
|
|
129
|
+
const probe = createFaultFetch(fetch, {
|
|
130
|
+
url: 'http://127.0.0.1:3000/api/profile',
|
|
131
|
+
kind: 'connection-failure',
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
await exerciseApplication(probe.fetch);
|
|
135
|
+
probe.assertApplied();
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
`exerciseApplication` represents your own test adapter or application controller. Calling `assertApplied()` is essential: it proves that every requested fault was consumed.
|
|
139
|
+
|
|
140
|
+
## JSON-configured runner
|
|
141
|
+
|
|
142
|
+
The CLI supports pages that automatically load GET data, expose a visible Retry button after failure, and show a ready element after recovery.
|
|
143
|
+
|
|
144
|
+
```json
|
|
145
|
+
{
|
|
146
|
+
"name": "Profile recovery",
|
|
147
|
+
"url": "http://127.0.0.1:3000/profile",
|
|
148
|
+
"requestPattern": "**/api/profile",
|
|
149
|
+
"readySelector": "[data-testid=profile-ready]",
|
|
150
|
+
"retrySelector": "[data-testid=profile-retry]",
|
|
151
|
+
"timeoutMs": 3000
|
|
152
|
+
}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
npx recovery-probe --config recovery-probe.json --out artifacts/profile-recovery.json
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
The runner first checks the normal baseline in a fresh browser context. If that baseline fails, fault comparisons are skipped and reported as inconclusive. Each fault then receives its own fresh context with service workers blocked so Playwright can intercept the request.
|
|
160
|
+
|
|
161
|
+
Exit codes:
|
|
162
|
+
|
|
163
|
+
- `0`: every configured check passed, or the controlled demo observed its expected broken-versus-fixed result.
|
|
164
|
+
- `1`: a recovery check failed, was inconclusive, or was skipped.
|
|
165
|
+
- `2`: invalid arguments, configuration, or environment setup.
|
|
166
|
+
|
|
167
|
+
## Result semantics
|
|
168
|
+
|
|
169
|
+
| Code | Meaning |
|
|
170
|
+
| --- | --- |
|
|
171
|
+
| `OK` | The configured assertion completed and the expected fault count was observed. |
|
|
172
|
+
| `RECOVERY_ASSERTION_FAILED` | The fault occurred, but the recovery assertion did not pass. |
|
|
173
|
+
| `FAULT_NOT_TRIGGERED` | The requested fault count was not observed. Check the route, method, cache, and service worker. |
|
|
174
|
+
| `BASELINE_FAILED` | The ordinary flow failed, so the runner could not make a useful fault comparison. |
|
|
175
|
+
| `INJECTION_ERROR` | Playwright could not apply or clean up the route reliably. |
|
|
176
|
+
|
|
177
|
+
A passing result proves the configured recovery behavior for that test. It is not a certification of overall application resilience.
|
|
178
|
+
|
|
179
|
+
## API
|
|
180
|
+
|
|
181
|
+
### `withFault(page, options, exercise)`
|
|
182
|
+
|
|
183
|
+
Installs one temporary Playwright route, runs `exercise`, verifies the requested fault count, and removes only that route handler.
|
|
184
|
+
|
|
185
|
+
```ts
|
|
186
|
+
interface FaultOptions {
|
|
187
|
+
match: string | RegExp;
|
|
188
|
+
kind: 'http-error' | 'connection-failure' | 'invalid-json';
|
|
189
|
+
status?: number;
|
|
190
|
+
count?: number;
|
|
191
|
+
method?: string;
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
Register the fault after your own route mocks. The helper uses `route.fallback()` for requests it does not inject, allowing earlier handlers to continue processing them.
|
|
196
|
+
|
|
197
|
+
### `createFaultFetch(baseFetch, options)`
|
|
198
|
+
|
|
199
|
+
Creates an isolated fetch wrapper for one exact URL and method. It returns `{ fetch, summary, assertApplied }` and leaves the supplied fetch function unchanged.
|
|
200
|
+
|
|
201
|
+
### `probeRecovery(browser, config)`
|
|
202
|
+
|
|
203
|
+
Runs the baseline and the three default recovery checks used by the JSON CLI. For custom interactions or stronger assertions, prefer `withFault` inside your own test.
|
|
204
|
+
|
|
205
|
+
## Scope
|
|
206
|
+
|
|
207
|
+
Recovery Probe deliberately focuses on deterministic request-level recovery checks. It does not simulate whole-device offline states, WebSocket interruptions, token expiry, browser sleep, slow-network profiles, or duplicate-submission safety.
|
|
208
|
+
|
|
209
|
+
Playwright already provides the routing primitives used here. Recovery Probe adds bounded recipes, fault-occurrence verification, cleanup, consistent result codes, a fetch adapter, and a runnable broken-versus-fixed example. If a few direct `page.route()` calls are clearer for your test, use them; this package is most useful when teams want the recovery pattern to be repeatable.
|
|
210
|
+
|
|
211
|
+
The runner requires explicit selectors and endpoint matching. It does not discover an application's recovery policy automatically. Request/response bodies and headers are not collected by the checker. Preview reports include endpoint origin/path, selectors, expected text and configuration; optional screenshots, login state and command logs may be sensitive. Do not commit or share these blindly.
|
|
212
|
+
|
|
213
|
+
Recovery Probe sends no telemetry. Tests/discovery do not call an AI service. Only explicit repair generation with `--allow-source-upload` sends the selected source contents and bounded observations to the configured OpenAI model. Login state and command logs are not part of that upload bundle. `store: false` is set on the API request; this is not a promise of zero provider retention. Review employer policy and provider data terms first.
|
|
214
|
+
|
|
215
|
+
## Development
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
npm ci
|
|
219
|
+
npm test # 9 fetch/core tests
|
|
220
|
+
npm run test:package # isolated tarball install + TypeScript + CLI checks
|
|
221
|
+
npx playwright install chromium
|
|
222
|
+
npm run test:browser # 7 real-browser integration tests
|
|
223
|
+
npm run test:repair # safety, authenticated portal, before/after pipeline
|
|
224
|
+
# After installing the optional Electron test runtime:
|
|
225
|
+
npm run test:repair:electron
|
|
226
|
+
npm run demo:browser
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
CI runs package checks on Node.js 22 and 24, Chromium integration, and real Electron checks. Repair integration tests use a **controlled mock model response** but real apps, fault injection, source changes and reruns. They validate orchestration, not live AI diagnosis quality. See [CONTRIBUTING.md](CONTRIBUTING.md) and [SECURITY.md](SECURITY.md).
|
|
230
|
+
|
|
231
|
+
## License
|
|
232
|
+
|
|
233
|
+
[MIT](LICENSE) © 2026 Bojan Kovachki
|