Skip to content

Commit ec8c2a0

Browse files
author
Sorra
committed
Merge feature/SB-0MNI23PTF005PGQ6-add-cli-runner-tests into main
2 parents 7a811cd + 8654f1d commit ec8c2a0

14 files changed

Lines changed: 2094 additions & 11 deletions
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Test Coverage
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
16+
- name: Use Node.js 20
17+
uses: actions/setup-node@v4
18+
with:
19+
node-version: 20
20+
21+
- name: Install dependencies
22+
run: npm install
23+
24+
- name: Run tests with coverage
25+
run: npm run test:coverage

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ See [Local Setup](#local-setup) below for detailed instructions.
100100
- `npm run start` - Run compiled bot from `dist/`
101101
- `npm run lint` - Type check without emitting files
102102
- `npm run test` - Run unit tests
103+
- `npm run test:coverage` - Run tests with coverage and enforce >=80% coverage for the bot/ module
103104
- `npm run db:migrate` - Apply SQL migrations to PostgreSQL
104105

105106
## CLI Commands

docs/coverage-followups.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Coverage follow-ups for src/bot (SB-0MNFT3MI1005HXOD)
2+
3+
Summary of local run
4+
5+
- Test coverage for src/bot (cli-runner.ts) is currently 76.22% (statements/lines/functions/branches below 80%).
6+
- CI will now run coverage and fail if threshold is not met.
7+
8+
Proposed follow-up work items
9+
10+
1) Add unit tests to cover uncovered branches and lines in src/bot/cli-runner.ts
11+
- Focus areas: error handling branches, timeout behavior, child process termination paths.
12+
- Estimated effort: small (2-4 tests per area).
13+
14+
2) Add integration tests for edge-case CLI outputs (invalid NDJSON lines, stderr-only errors)
15+
- Use vi.mock for child_process.spawn to simulate CLI behaviour.
16+
- Ensure last-event mapping and failed path exercised.
17+
18+
3) Add test utility to reset and restore setCliPath / process.env between tests
19+
- Ensure no cross-test leakage of CLI path.
20+
21+
If you want, I can create these follow-up work items in the worklog and begin implementing the highest-priority tests.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Feature Request: Playwright Fallback for Content Retrieval Failures
2+
3+
## Summary
4+
5+
OpenBrain should use a headless Playwright browser as a fallback when the standard retrieval path fails to return usable content.
6+
7+
## Problem
8+
9+
Some pages are rendered mostly or fully through JavaScript. The current retrieval path can fail on these pages, returning empty or low-value content, which then causes extraction and summarization to fail.
10+
11+
## Why this matters
12+
13+
- Shared links in Discord can fail ingestion even when the page is valid in a normal browser.
14+
- Community knowledge capture quality drops when JavaScript-heavy sites cannot be indexed.
15+
- Operators currently have no reliable fallback for blocked or dynamically rendered content.
16+
17+
## Current architecture context
18+
19+
SourceBase (Discord bot) does not implement page retrieval directly. It delegates ingestion to OpenBrain via `ob add`.
20+
21+
Because of this separation, the fallback logic belongs in OpenBrain, not in SourceBase.
22+
23+
## Requested behavior
24+
25+
1. Attempt the current retrieval path first (fast path).
26+
2. If retrieval or extraction fails due to known failure modes (for example: blocked response, script-rendered content, empty extraction), retry with Playwright.
27+
3. Feed Playwright-derived HTML/content into the existing extraction flow so downstream behavior stays consistent.
28+
4. Emit clear telemetry/event data when fallback is used.
29+
30+
## Acceptance criteria
31+
32+
- OpenBrain continues to use the existing retrieval path by default.
33+
- OpenBrain invokes Playwright fallback only when the fast path fails or yields unusable content.
34+
- JavaScript-heavy pages that previously failed can now be ingested successfully when fallback is enabled.
35+
- Timeout and resource controls exist for browser-based fallback.
36+
- Logs or progress output make fallback activation visible for diagnostics.
37+
- Automated tests cover success and failure cases for both fast path and fallback path.
38+
39+
## Non-goals
40+
41+
- Implementing custom retrieval logic in the SourceBase Discord bot.
42+
- Making Playwright the primary path for all URLs.
43+
44+
## Related work
45+
46+
- Work item: Use playright retrieve content if existing retrieval path fails (SB-0MNHOYCUK000RALJ)
47+
- Historical draft (deleted): Add Playwright fallback for blocked content extraction (SB-0MN4FHM2B0PI69AE)

0 commit comments

Comments
 (0)