Skip to content

Commit 32d3c52

Browse files
committed
Config: CI, docs, Makefile, package.json, yarn.lock
1 parent 7765e33 commit 32d3c52

File tree

11 files changed

+2343
-193
lines changed

11 files changed

+2343
-193
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
name: investigate
3+
description: Investigate a rewatch OTEL trace report from a span ID.
4+
user-invocable: true
5+
---
6+
7+
# OTEL Investigation Skill
8+
9+
The user invokes this as `/investigate-otel <span_id>` where `<span_id>` is a 16-character hex string identifying an `lsp.llm_report` span in the local otel-viewer.
10+
11+
## OTEL Viewer API (http://localhost:4707)
12+
13+
Only these endpoints exist — do NOT invent others:
14+
15+
- `GET /api/spans/{span_id}/context`**start here** for `lsp.llm_report` spans. Returns the report's `message` attribute AND the session timeline (filtered `did_save`/`did_change`/`flush` siblings) in one call.
16+
- `GET /api/spans/{span_id}/flush` — structured flush summary with errors inlined. Use for flush spans found in the context.
17+
- `GET /api/spans/{span_id}` — full span detail (attributes, events). Use for drill-down.
18+
- `GET /api/spans/{span_id}/children` — direct children of a span. Use for drill-down.
19+
20+
## Procedure
21+
22+
1. **Fetch context** — this is the entry point, gives you the report message and session timeline:
23+
24+
```
25+
curl -s http://localhost:4707/api/spans/{SPAN_ID}/context | jq .
26+
```
27+
28+
The `target_span.attributes.message` is the user's problem description. `session_spans` is the chronological editing session.
29+
30+
2. **Drill into flushes** — for `lsp.flush` spans in `session_spans` (especially with `has_error: true`):
31+
32+
```
33+
curl -s http://localhost:4707/api/spans/{FLUSH_SPAN_ID}/flush | jq .
34+
```
35+
36+
3. **Drill deeper** if needed via `/api/spans/{id}` or `/api/spans/{id}/children`.
37+
38+
4. **Read rewatch source** based on what the traces reveal:
39+
- `rewatch/src/lsp/` — LSP logic
40+
- `rewatch/src/build/` — build system
41+
- `rewatch/src/watcher.rs` — file watching
42+
43+
5. **Summarize**: what the report describes, session timeline, where things went wrong, root cause hypothesis, suggested fix.
44+
45+
## Notes
46+
47+
- Attributes like `code.filepath`, `code.namespace`, `code.lineno`, `thread.name` are instrumentation noise — ignore them.
48+
- The `/context` endpoint already filters to session-relevant spans with gap detection.
49+
- The `/flush` endpoint shows build stages with error texts inlined; collapsed subtrees have `span_id` for drill-down.

.github/workflows/ci.yml

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -324,18 +324,6 @@ jobs:
324324
if: runner.os != 'Windows'
325325
run: make -C tests/gentype_tests/typescript-react-example clean test
326326

327-
# On Windows, after running setup-ocaml (if it wasn't cached yet or the cache couldn't be restored),
328-
# Cygwin bash is used instead of Git Bash for Windows, breaking the rewatch tests.
329-
# So we need to adjust the path to bring back Git Bash for Windows.
330-
- name: Rewatch tests need Git Bash for Windows
331-
if: ${{ runner.os == 'Windows' }}
332-
run: echo "C:\Program Files\Git\bin" >> $GITHUB_PATH
333-
shell: bash
334-
335-
- name: Run rewatch tests
336-
run: ./rewatch/tests/suite.sh rewatch/target/release/rescript
337-
shell: bash
338-
339327
- name: Run syntax benchmarks
340328
if: matrix.benchmarks
341329
run: |
@@ -401,14 +389,14 @@ jobs:
401389

402390
- name: "Upload artifacts: binaries"
403391
if: matrix.upload_binaries
404-
uses: actions/upload-artifact@v7
392+
uses: actions/upload-artifact@v6
405393
with:
406394
name: binaries-${{ matrix.node-target }}
407395
path: packages/@rescript/${{ matrix.node-target }}/bin
408396

409397
- name: "Upload artifacts: lib/ocaml"
410398
if: matrix.upload_libs
411-
uses: actions/upload-artifact@v7
399+
uses: actions/upload-artifact@v6
412400
with:
413401
name: lib-ocaml
414402
path: |
@@ -423,7 +411,7 @@ jobs:
423411
- name: "Upload artifacts: scripts/res/apiDocs"
424412
id: upload-api-docs
425413
if: ${{ matrix.generate_api_docs }}
426-
uses: actions/upload-artifact@v7
414+
uses: actions/upload-artifact@v6
427415
with:
428416
name: api
429417
path: scripts/res/apiDocs/
@@ -445,7 +433,7 @@ jobs:
445433
node-version-file: .nvmrc
446434

447435
- name: Download artifacts
448-
uses: actions/download-artifact@v8
436+
uses: actions/download-artifact@v7
449437
with:
450438
pattern: "@(binaries-*|lib-ocaml)"
451439

@@ -475,7 +463,7 @@ jobs:
475463
ssh-key: ${{ secrets.RESCRIPT_LANG_ORG_DEPLOY_KEY }}
476464

477465
- name: Download artifacts
478-
uses: actions/download-artifact@v8
466+
uses: actions/download-artifact@v7
479467
with:
480468
artifact-ids: ${{ needs.build-compiler.outputs.api-docs-artifact-id }}
481469
path: data/api
@@ -648,15 +636,18 @@ jobs:
648636
# Run integration tests with the oldest supported node version.
649637
node-version: 20
650638

651-
- name: Install ReScript package in rewatch/testrepo
639+
- name: Install npm packages
640+
run: yarn install
641+
642+
- name: Install ReScript package in test fixture
652643
run: |
653644
COMMIT_SHA="${{ needs.pkg-pr-new.outputs.commit_sha }}"
654645
yarn add "rescript@https://pkg.pr.new/rescript-lang/rescript@${COMMIT_SHA}"
655646
shell: bash
656-
working-directory: rewatch/testrepo
647+
working-directory: tests/rewatch_tests/fixture
657648

658649
- name: Run rewatch integration tests
659-
run: ./rewatch/tests/suite.sh rewatch/testrepo/node_modules/.bin/rescript
650+
run: node scripts/test.js -rewatch
660651
shell: bash
661652

662653
publish:
@@ -680,7 +671,7 @@ jobs:
680671
registry-url: https://registry.npmjs.org # Needed to make auth work for publishing
681672

682673
- name: Download artifacts
683-
uses: actions/download-artifact@v8
674+
uses: actions/download-artifact@v7
684675
with:
685676
pattern: "@(binaries-*|lib-ocaml)"
686677

AGENTS.md

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -387,21 +387,7 @@ make test-rewatch # Run integration tests
387387

388388
**Note**: The rewatch project is located in the `rewatch/` directory with its own `Cargo.toml` file. All cargo commands should be run from the project root using the `--manifest-path rewatch/Cargo.toml` flag, as shown in the CI workflow.
389389

390-
**Integration Tests**: The `make test-rewatch` command runs bash-based integration tests located in `rewatch/tests/suite.sh`. These tests use the `rewatch/testrepo/` directory as a test workspace with various package configurations to verify rewatch's behavior across different scenarios.
391-
392-
**Running Individual Integration Tests**: You can run individual test scripts directly by setting up the environment manually:
393-
394-
```bash
395-
cd rewatch/tests
396-
export REWATCH_EXECUTABLE="$(realpath ../target/debug/rescript)"
397-
eval $(node ./get_bin_paths.js)
398-
export RESCRIPT_BSC_EXE
399-
export RESCRIPT_RUNTIME
400-
source ./utils.sh
401-
bash ./watch/06-watch-missing-source-folder.sh
402-
```
403-
404-
This is useful for iterating on a specific test without running the full suite.
390+
**Integration Tests**: The `make test-rewatch` command runs Vitest-based integration tests located in `tests/rewatch_tests/`. These tests use a sandbox copy of `tests/rewatch_tests/fixture/` to verify rewatch's behavior across different scenarios (build, watch, clean, format, etc.).
405391

406392
#### Debugging
407393

@@ -410,6 +396,26 @@ This is useful for iterating on a specific test without running the full suite.
410396
- **Dependencies**: Inspect module dependency graph in `deps.rs`
411397
- **File Watching**: Monitor file change events in `watcher.rs`
412398

399+
#### OpenTelemetry Tracing
400+
401+
Rewatch supports OpenTelemetry (OTEL) tracing for build, watch, and LSP commands. Any OTLP-compatible viewer (Jaeger, Grafana, etc.) will work. For a lightweight option tailored to rewatch development, see `rewatch/otel-viewer/` — it requires only `uv` (no Docker) and includes features like LLM export.
402+
403+
```bash
404+
# Start the viewer (see rewatch/otel-viewer/README.md for setup)
405+
cd rewatch/otel-viewer
406+
uv run python server.py
407+
```
408+
409+
Then run rewatch with the OTLP endpoint set:
410+
411+
```bash
412+
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4707 cargo run --manifest-path rewatch/Cargo.toml -- build
413+
```
414+
415+
Open http://localhost:4707 to browse traces.
416+
417+
Note: Use `tracing::debug!` (not `log::debug!`) for events you want to appear in OTEL traces — they use separate logging systems.
418+
413419
#### Running Rewatch Directly
414420

415421
When running the rewatch binary directly (via `cargo run` or the compiled binary) during development, you need to set environment variables to point to the local compiler and runtime. Otherwise, rewatch will try to use the installed versions:
@@ -493,5 +499,3 @@ When clippy suggests refactoring that could impact performance, consider the tra
493499
## CI Gotchas
494500

495501
- **`sleep` is fragile** — Prefer polling (e.g., `wait_for_file`) over fixed sleeps. CI runners are slower than local machines.
496-
- **`exit_watcher` is async** — It only signals the watcher to stop (removes the lock file), it doesn't wait for the process to exit. Avoid triggering config-change events before exiting, as the watcher may start a concurrent rebuild.
497-
- **`sed -i` differs across platforms** — macOS requires `sed -i '' ...`, Linux does not. Use the `replace` / `normalize_paths` helpers from `rewatch/tests/utils.sh` instead of raw `sed`.

0 commit comments

Comments
 (0)