-
Notifications
You must be signed in to change notification settings - Fork 0
Checks Surface
Relevant source files
- src/lib/check.test.ts
- src/lib/check.ts
- src/lib/spend.test.ts
- src/lib/spend.ts
- src/lib/styles/layout/checks.css
- src/routes/checks/+page.svelte
- src/routes/checks/[id]/+page.svelte
The Checks Surface provides a detailed observability layer for the job-fetch pipeline. It allows users to monitor the execution of automated runs, inspect the step-by-step telemetry of scraping and LLM tasks, and track resource consumption (ScrapingBee credits and OpenRouter USD costs).
The surface consists of two primary views:
- Checks List: A ledger of all historical and active pipeline runs (e.g.,
job_check,job_detail) with high-level rollups of status and cost. - Check Detail: A deep-dive into a single run, displaying a chronological table of
Stepentities, including cache performance and error logs.
The frontend communicates with the Rust backend via Tauri commands to read check data stored as Markdown files in the vault's checks/ directory.
The pipeline's telemetry is persisted to the vault by the backend. The frontend synchronizes with these updates using a combination of reactive stores and event listeners.
| Component | Role |
|---|---|
checksStore |
Svelte state managing the list of CheckSummary objects. |
onRunStep |
Listener for incremental pipeline progress events. |
onRunFinished |
Listener for terminal pipeline events to trigger a final reload. |
getCheck |
Fetches the full Check object (including steps) for a specific ID. |
Sources:src/routes/checks/+page.svelte#18-36src/lib/check.ts#81-89
The checksStore (defined in src/lib/checks.svelte) is the central repository for run summaries. Because the pipeline's writes to check files are "self-writes" (suppressed by the vault watcher to prevent infinite loops), the store manually reloads when the pipeline emits events.
Costs are tracked in two distinct units:
- Credits: Integer units consumed by ScrapingBee.
- USD Micro: Micro-dollars (1,000,000 = $1.00) consumed by OpenRouter, stored as integers to maintain precision.
The runSpend and totalSpend functions in src/lib/spend.ts calculate these rollups by inspecting the class of each step.
Run Spend Logic:
- If
step.class === "scrape", the cost is added tocredits. - If
step.class === "llm"or"llm+web", the cost is added tousdMicro.
Sources:src/lib/spend.ts#11-20src/lib/check.ts#61-62src/routes/checks/+page.svelte#43-48
The Check Detail page (src/routes/checks/[id]/+page.svelte) renders the full Check object. It provides a steps-table that visualizes the execution flow of the pipeline.
Rows in the step table are styled based on their terminal state. Specifically, steps with a status of "failed" receive the .steps-row--failed class, which applies a semantic danger-soft background.
For LLM steps, the UI displays prompt caching performance using the formatCache utility. This identifies how many tokens were read from or written to the OpenRouter/provider cache.
| Scenario | Output Example |
|---|---|
| Cold Cache (First call) | · cache 7,000 write |
| Cache Hit | · cache 6,656 read |
| Partial Hit | · cache 6,656 read · 7,000 write |
Sources:src/lib/check.ts#32-44src/routes/checks/[id]/+page.svelte:60-69, src/lib/styles/layout/checks.css#105-107
This diagram maps the UI concepts to the underlying TypeScript interfaces and Rust-proxied data structures.
flowchart LR
subgraph subGraph2 ["Persistence (Vault)"]
I["/checks/*.md"]
end
subgraph subGraph1 ["Code Entity Space (TypeScript)"]
D["CheckSummary #91;src/lib/check.ts#93;"]
E["Step #91;src/lib/check.ts#93;"]
F["Spend #91;src/lib/spend.ts#93;"]
G["checksStore #91;src/lib/checks.svelte#93;"]
H["getCheck() #91;src/lib/check.ts#93;"]
end
subgraph subGraph0 ["Natural Language Space"]
A["Run Ledger"]
B["Step Telemetry"]
C["Financial Rollup"]
end
A --> D
B --> E
C --> F
D --> G
E --> H
G --> I
H --> I
Sources:src/lib/check.ts#7-79src/lib/spend.ts#5-8src/routes/checks/+page.svelte#4-12
The sequence of events when a user views a specific check run and the pipeline is active.
sequenceDiagram
participant UI as +page.svelte (Detail)
participant Pipe as Pipeline (Rust)
participant Store as checksStore
participant API as Tauri Bridge (invoke)
Note over UI: User navigates to /checks/[id]
UI->>API: getCheck(vault | id)
API-->>UI: Return Check { steps: Step[] }
Note over Pipe: Pipeline completes a step
Pipe->>UI: Emit "record:step" event
UI->>Store: reload()
Store->>API: list_checks
API-->>Store: Update summaries
Note over UI: Reactive $derived(spend) updates
UI->>UI: runSpend(check.steps)
Sources:src/routes/checks/[id]/+page.svelte:17-30, src/routes/checks/+page.svelte#18-36src/lib/spend.ts#11-20
The surface uses semantic <table> elements rather than CSS grids to handle the dense telemetry data.
- Status Pills: The
.checks__statusclass uses semantic tokens (e.g.,--good-soft,--danger-soft) to color-code statuses likeok,partial,complete, andfailed. - Precision Formatting: LLM costs are formatted with sub-cent precision using
(cost / 1e6).toFixed(4)to reflect the micro-dollar storage format.
| Function | File | Description |
|---|---|---|
formatCache |
src/lib/check.ts#32 | Converts cache_read_tokens and cache_write_tokens into a human-readable string. |
runSpend |
src/lib/spend.ts#11 | Iterates through Step[] and aggregates costs based on the class field. |
fmtCost |
src/routes/checks/[id]/+page.svelte:12 | Local helper to append "cr" for scraping or "$" for LLM costs in the UI. |
listChecks |
src/lib/check.ts#82 | Invokes the list_checks Tauri command to retrieve all run summaries. |
Sources:src/lib/check.ts#32-44src/lib/spend.ts#11-20src/routes/checks/[id]/+page.svelte:12-15, src/lib/styles/layout/checks.css#54-73