streamtrust 0.1.1 → 0.3.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.
package/README.md CHANGED
@@ -1,8 +1,24 @@
1
1
  # StreamTrust CLI
2
2
 
3
- Adapter-driven CI checks for streaming applications: compare observed output with authoritative state, exercise cancellation, and verify retry identity.
3
+ [![npm version](https://img.shields.io/npm/v/streamtrust.svg)](https://www.npmjs.com/package/streamtrust)
4
4
 
5
- **Status:** `0.1.1`, an early 0.x release for independent teams. APIs and report formats may change before 1.0. The CLI is dependency-free, ESM, and requires Node.js 22+. MIT licensed. Browser and database libraries belong to your adapter and are not installed by StreamTrust.
5
+ **[View StreamTrust on npm](https://www.npmjs.com/package/streamtrust)**
6
+
7
+ StreamTrust is a CI check for streaming applications such as AI chat. Its reusable checks compare what was displayed with what the application authoritatively saved and report disagreements as failed checks. It does not replace Playwright: Playwright drives the browser, and the bundled presets use it inside their adapters.
8
+
9
+ - **Three outcomes, kept apart.** "The app failed" (FAIL), "this capability is not supported" (UNSUPPORTED) and "we could not determine whether it failed" (HARNESS_ERROR) are reported separately, and harness errors exit with their own code.
10
+ - **Repeated runs.** Each scenario runs N times and the report shows every repetition, because cancellation and retry bugs are often intermittent.
11
+ - **Your contract, written down.** An adapter implements your app's start, stream, cancel, retry and saved-state operations; StreamTrust invokes the adapter scenarios and writes JSON, JUnit, Markdown and HTML reports.
12
+
13
+ **Status:** `0.3.0`, an early 0.x release for independent teams. APIs and report formats may change before 1.0. The CLI is dependency-free, ESM, and requires Node.js 22+. MIT licensed. Browser and database libraries belong to your adapter and are not installed by StreamTrust.
14
+
15
+ ## Watch the 66-second demo
16
+
17
+ [![Open the narrated StreamTrust demo: persistence, cancellation, retry, and CI diagnostics](docs/media/streamtrust-demo-poster.png)](https://santoshsibyala.github.io/streamtrust/)
18
+
19
+ **[Watch the narrated demo in your browser](https://santoshsibyala.github.io/streamtrust/)** · [Read the transcript](docs/media/streamtrust-demo-transcript.txt) · [Download subtitles](docs/media/streamtrust-demo-0.1.1-brian.srt) · [Silent version](https://raw.githubusercontent.com/santoshsibyala/streamtrust/main/docs/media/streamtrust-demo-0.1.1.mp4)
20
+
21
+ A 66-second walkthrough narrated with ElevenLabs’ Brian voice (synthetic English narration), on-screen captions, and an optional English subtitle track: install StreamTrust, run the example checks, inspect the diagnostic report, and see a deliberate save failure return a nonzero CI exit code. Recorded with version 0.1.1. The bundled application and injected failure are demonstrations; connect an adapter to your own application to verify its behavior. The browser player includes playback controls, captions, and an MP4 download option.
6
22
 
7
23
  ## Install
8
24
 
@@ -12,7 +28,19 @@ npx streamtrust init
12
28
  npx streamtrust verify --adapter ./streamtrust/adapter.mjs
13
29
  ```
14
30
 
15
- For reproducible CI, pin `streamtrust@0.1.1` and commit your lockfile. The generated adapter initially exercises the bundled demonstration; map it to your application before using its results as application evidence.
31
+ For reproducible CI, pin `streamtrust@0.3.0` and commit your lockfile. The generated adapter initially exercises the bundled demonstration; map it to your application before using its results as application evidence.
32
+
33
+ ## LibreChat integration
34
+
35
+ A LibreChat preset now exercises persistence, native Stop, regeneration and error-retry through its browser UI and disposable MongoDB. It uses reusable `streamtrust/checks` assertions and summary-only evidence; no chat text, screenshots or application logs are included in its reports.
36
+
37
+ **Available since StreamTrust 0.2.0.** Install from npm using the [LibreChat quick start and CI guide](examples/librechat/README.md). It requires Node 24 and optional Playwright/MongoDB dependencies. An [integration workflow](.github/workflows/librechat.yml) exercises the packed CLI against the pinned upstream version. The default `init` demonstration remains available.
38
+
39
+ ## Vercel AI SDK integration
40
+
41
+ A `vercel-ai` preset runs a minimal Next.js chat built on the AI SDK (`useChat`, `streamText`) in production mode with a synthetic OpenAI-compatible provider, so it needs no API key. It covers the same four scenarios through the browser and the app's saved state, and can be pointed at your own built AI SDK app after you adjust its selectors and saved-state read. It is not an official Vercel integration.
42
+
43
+ **Available in StreamTrust 0.3.0.** Install from npm and generate it with `npx streamtrust init streamtrust-vercel-ai --preset vercel-ai`. See the [Vercel AI SDK quick start](examples/vercel-ai/README.md) for what it does and does not verify. It requires Node 22+ and Playwright in your verification project. An [integration workflow](.github/workflows/vercel-ai.yml) exercises the packed CLI against the reference app.
16
44
 
17
45
  ## Run from source
18
46
 
@@ -32,7 +60,7 @@ Build the tarball with `npm pack` in this repository.
32
60
  Put the supplied tarball in your project's `vendor/` directory, then:
33
61
 
34
62
  ```sh
35
- npm install --save-dev ./vendor/streamtrust-0.1.1.tgz
63
+ npm install --save-dev ./vendor/streamtrust-0.3.0.tgz
36
64
  npx streamtrust init
37
65
  npx streamtrust verify --adapter ./streamtrust/adapter.mjs
38
66
  ```
@@ -123,34 +151,82 @@ node --import tsx ./node_modules/streamtrust/bin/streamtrust.js verify \
123
151
 
124
152
  ## CI
125
153
 
126
- Install the pinned version and commit package.json and package-lock.json so CI can use `npm ci`. If using a locally built tarball instead, keep it in `vendor/` so the committed file dependency can be resolved. The example workflow assumes the application under test is already running; add its start/wait commands before verification. Omit the base URL only when intentionally testing the bundled demonstration.
154
+ Add StreamTrust as a test step in your existing CI. For GitHub Actions, follow these steps:
155
+
156
+ 1. Install StreamTrust and create the starting adapter:
157
+
158
+ ```sh
159
+ npm install --save-dev --save-exact streamtrust@0.3.0
160
+ npx streamtrust init
161
+ ```
162
+
163
+ 2. Adapt `streamtrust/adapter.mjs` to your application's native start, stream, cancel, retry, and saved-state operations. **The generated adapter initially tests a bundled demo. Setting a base URL alone does not adapt it to arbitrary application APIs.** See [Connect your application](#connect-your-application) above.
164
+ 3. Commit the adapter, `package.json`, and `package-lock.json`. If the adapter imports browser or database libraries, add those dependencies and their required CI setup too.
165
+ 4. Save the workflow below as `.github/workflows/streamtrust.yml`, or copy its relevant steps into an existing job.
166
+
167
+ **Replace `npm run start:test`, port `3000`, and `/health` with your application's test-server command and readiness endpoint.** These are placeholders, not commands or routes supplied by StreamTrust. Add any required build, database, migration, fixture, or browser-install steps before starting your app. Use a disposable test environment because the checks create and modify application state.
127
168
 
128
169
  ```yaml
129
170
  name: Streaming application verification
130
171
  on: [push, pull_request]
172
+ permissions:
173
+ contents: read
131
174
  jobs:
132
175
  verify:
133
176
  runs-on: ubuntu-latest
134
177
  timeout-minutes: 10
135
178
  steps:
136
179
  - uses: actions/checkout@v4
180
+
137
181
  - uses: actions/setup-node@v4
138
182
  with:
139
183
  node-version: 22
140
184
  cache: npm
185
+
141
186
  - run: npm ci
142
- # Start your test application and wait for readiness here.
143
- - run: npx --no-install streamtrust verify --adapter ./streamtrust/adapter.mjs --output reports/streamtrust
187
+
188
+ # Add your application's build and test-service setup here.
189
+ - name: Start application and wait for readiness
190
+ shell: bash
191
+ run: |
192
+ npm run start:test > app.log 2>&1 &
193
+ app_pid=$!
194
+ for attempt in {1..30}; do
195
+ if ! kill -0 "$app_pid" 2>/dev/null; then
196
+ cat app.log
197
+ exit 1
198
+ fi
199
+ if curl --fail --silent --max-time 2 http://localhost:3000/health; then
200
+ exit 0
201
+ fi
202
+ sleep 2
203
+ done
204
+ cat app.log
205
+ echo "Application did not become ready in time."
206
+ exit 1
207
+
208
+ - name: Verify streaming behavior
209
+ run: |
210
+ npx --no-install streamtrust verify \
211
+ --adapter ./streamtrust/adapter.mjs \
212
+ --output ./reports/streamtrust
144
213
  env:
145
- STREAMTRUST_BASE_URL: http://127.0.0.1:8080
146
- STREAMTRUST_API_TOKEN: ${{ secrets.TEST_APP_TOKEN }}
147
- - uses: actions/upload-artifact@v4
214
+ STREAMTRUST_BASE_URL: http://localhost:3000
215
+
216
+ - name: Save diagnostic reports
148
217
  if: always()
218
+ uses: actions/upload-artifact@v4
149
219
  with:
150
- name: streamtrust-evidence
220
+ name: streamtrust-reports
151
221
  path: reports/streamtrust/
152
222
  ```
153
223
 
224
+ If your application is already running in the job, omit the startup step and point your adapter at its test URL. For the bundled HTTP adapter's optional bearer authentication, add `STREAMTRUST_API_TOKEN: ${{ secrets.TEST_APP_TOKEN }}` to the verification step's `env`, and configure that secret in GitHub. Fork pull requests generally do not receive repository secrets; use a suitable unauthenticated test fixture or an explicitly trusted workflow for those runs. Never put credentials in the adapter or uploaded evidence.
225
+
226
+ A failed assertion or harness error fails the verification step. The report-upload step runs even after a failure, so teams can inspect diagnostics when they were generated; startup failures may have no StreamTrust report. To block merging, configure the repository's branch protection or ruleset to require this workflow's `verify` check. StreamTrust does not configure merge rules itself.
227
+
228
+ If you use a locally built tarball instead of npm, keep it in `vendor/` and commit the corresponding file dependency and lockfile so `npm ci` can resolve it.
229
+
154
230
  | Exit | Meaning |
155
231
  |---|---|
156
232
  | 0 | Every declared scenario and assertion passed. |
@@ -163,6 +239,6 @@ Use a unique output directory per concurrent job. The CLI takes an exclusive loc
163
239
 
164
240
  ## Scope and attribution
165
241
 
166
- StreamTrust checks what an adapter asserts. It does not prove exactly-once external effects, AI factuality, automatic recovery, production incident rates or adoption. The HTTP demo is synthetic. Separate development experiments have tested pinned Vercel Chatbot and LibreChat applications; their adapters and dependencies are not bundled here.
242
+ StreamTrust checks what an adapter asserts. It does not prove exactly-once external effects, AI factuality, automatic recovery, production incident rates or adoption. The HTTP demo is synthetic. Separate development experiments have tested pinned Vercel Chatbot and LibreChat applications; the LibreChat adapter is now available as an npm preset with optional dependencies. The `vercel-ai` preset targets its own minimal reference app, not the Vercel Chatbot template; that experiment remains separate.
167
243
 
168
244
  Local preparation: `npm pack` in this package directory runs the package tests and creates the tarball. The public repository runs tests and a clean tarball installation on Node.js 22 and 24. This release is published interactively; npm build provenance is not configured.
@@ -0,0 +1,91 @@
1
+ # LibreChat CI integration
2
+
3
+ This preset runs a **built local LibreChat checkout**, native browser UI and real disposable MongoDB. A controlled OpenAI-compatible HTTP provider supplies synthetic text. No live model key or existing database is used. Four scenarios cover saved answers, Stop, regeneration branches, and retry after a provider disconnect. This is not an official LibreChat integration.
4
+
5
+ ## Installation
6
+
7
+ Use Node.js 24 and npm 11. In a separate verification project, install StreamTrust 0.3.0 from npm:
8
+
9
+ ```sh
10
+ npm init -y
11
+ npm install --save-dev --save-exact streamtrust@0.3.0
12
+ npm install --save-dev --save-exact playwright@1.64.1 mongodb@6.20.0 mongodb-memory-server@11.3.0
13
+ npx playwright install chromium
14
+ npx streamtrust init streamtrust-librechat --preset librechat
15
+ ```
16
+
17
+ Use Node.js 24 and npm 11 for this preset. Commit the generated adapter and your package lock. The core CLI still has no runtime dependencies; browser/database dependencies belong to the verification project. Browser, MongoDB binary and LibreChat installation require network access and disk space. The first build takes several minutes; this is not a five-minute cold installation.
18
+
19
+ ## Run the supported upstream version
20
+
21
+ ```sh
22
+ export STREAMTRUST_LIBRECHAT_ROOT="$PWD/.cache/librechat"
23
+ node streamtrust-librechat/setup.mjs
24
+ npx streamtrust verify --adapter streamtrust-librechat/adapter.mjs \
25
+ --output reports/librechat --repetitions 3 --timeout-ms 600000
26
+ ```
27
+
28
+ The setup script clones and builds commit `a378657583567310c841d652b0f6b00c83e2bd6b`. It refuses to reset an existing or dirty checkout. The verifier starts its own loopback-only server, chooses an available port, creates a synthetic test user, and tears down its browser, provider and disposable database. The preset refuses checkouts containing `.env`, `.env.local` or `.env.production`. Do not place production configuration in this checkout.
29
+
30
+ To test your team's committed changes, point `STREAMTRUST_LIBRECHAT_ROOT` at your **built, clean checkout** and set `STREAMTRUST_LIBRECHAT_COMMIT` to its full SHA. Skip setup if already built. This executes the actual application under test; it does not copy a test app into your repository. Compatibility with other commits is not guaranteed: changed selectors/routes/schema can cause HARNESS_ERROR rather than a product failure.
31
+
32
+ Optional settings:
33
+
34
+ | Variable | Purpose |
35
+ |---|---|
36
+ | `STREAMTRUST_LIBRECHAT_ROOT` | Required path to the built checkout |
37
+ | `STREAMTRUST_LIBRECHAT_COMMIT` | Expected full SHA; defaults to the tested upstream commit |
38
+ | `STREAMTRUST_LIBRECHAT_PORT` | Optional fixed loopback port; defaults to an ephemeral port |
39
+ | `STREAMTRUST_BROWSER_CHANNEL` | Optional installed browser channel, such as `chrome`; default is Playwright Chromium |
40
+
41
+ ## CI
42
+
43
+ In your verification project, install once and commit package.json/package-lock.json and the generated preset. Add these steps to a Node 24 GitHub Actions job:
44
+
45
+ ```yaml
46
+ - uses: actions/checkout@v4
47
+ - uses: actions/setup-node@v4
48
+ with:
49
+ node-version: '24'
50
+ cache: npm
51
+ - run: npm ci
52
+ - run: npx --no-install playwright install --with-deps chromium
53
+ - name: Build isolated LibreChat checkout
54
+ run: node streamtrust-librechat/setup.mjs
55
+ env:
56
+ STREAMTRUST_LIBRECHAT_ROOT: ${{ runner.temp }}/librechat
57
+ - name: Verify LibreChat
58
+ run: npx --no-install streamtrust verify --adapter streamtrust-librechat/adapter.mjs --output reports/librechat --repetitions 3 --timeout-ms 600000
59
+ env:
60
+ STREAMTRUST_LIBRECHAT_ROOT: ${{ runner.temp }}/librechat
61
+ - uses: actions/upload-artifact@v4
62
+ if: always()
63
+ with:
64
+ name: librechat-verification
65
+ path: |
66
+ reports/librechat/report.json
67
+ reports/librechat/report.md
68
+ reports/librechat/junit.xml
69
+ reports/librechat/index.html
70
+ retention-days: 7
71
+ ```
72
+
73
+ Use a fresh report directory for each job. Restrict workflow permissions to `contents: read`, set a 30-minute job timeout, and use normal pull-request workflows without production secrets. To verify your fork, replace the build step with checkout/build of the intended commit and pass its SHA to the verifier.
74
+
75
+ Exit 0 means all declared checks passed; 1 means failed or unsupported checks; 2 means setup, timeout, or harness error. Keep the exit status: do not use `continue-on-error`. Inspect reports before calling a failure an upstream defect.
76
+
77
+ ## Evidence and limits
78
+
79
+ `summary-only-v1` returns stable check identifiers, booleans, message counts and provider-call counts. Raw chat text, database records, user identifiers, network URLs and tokens remain in memory and are not returned as report evidence. The preset does not write screenshots, browser traces or application logs. Browser/database exceptions are replaced with fixed errors. App subprocess output is discarded. Upload only the four report files, not the entire working directory.
80
+
81
+ This is data minimization, not a universal PII detector or sandbox. Other adapters, changes to this adapter, setup/build logs and third-party processes are outside that guarantee. The core verifier still runs trusted local code. The preset deliberately does not forward application environment variables, but LibreChat can load files in its checkout: use an isolated checkout with no production configuration.
82
+
83
+ The model provider is synthetic. The test uses one server and an in-memory stream store: no Redis, real model behavior, database crash, worker kill, multi-replica or production incident-rate coverage. A single matching saved answer is not proof of exactly-once external side effects. Regeneration is a distinct sibling branch, not reuse of a request idempotency key.
84
+
85
+ The exported `streamtrust/checks` evaluator can be reused by other adapters. Map observations to `LifecycleObservation`; the evaluator validates required types, computes checks, and returns summary-only evidence. Missing or malformed observations throw, becoming HARNESS_ERROR rather than a green result.
86
+
87
+ ## Validation
88
+
89
+ Local validation used macOS arm64, Node 24.22.1, Playwright 1.64.1 Chromium 156.0.8078.4, MongoDB 8.2.6, and the pinned LibreChat commit. A clean tarball consumer passed all four scenarios with three repetitions (12 executions, 99 assertions). A checkout containing an environment file was rejected with exit 2. Success and error artifact checks found only the four intended files and no tested secret/chat-text markers. The package suite has 13 tests, including negative controls for shared checks and stale-screenshot exclusion.
90
+
91
+ The [Linux GitHub Actions run](https://github.com/santoshsibyala/streamtrust/actions/runs/40451851475) also passed a cold clone/install/build, clean tarball installation, all 12 scenario executions, and upload of exactly the four report files. The verified implementation commit is `b1b2b27a19b512c6abce164502901d1716bf86a3`. Passing results do not establish an upstream defect or production reliability.