@terreno/mcp 58.0.1 → 58.0.3
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 +31 -0
- package/README.md +6 -4
- package/dist/docs/templates/bootstrap/frontend/app/_layout.template.tsx +2 -0
- package/dist/docs/upgrades/58.0.3.md +28 -0
- package/dist/docs/versioned/next/explanation/ai-development-loop.md +10 -7
- package/dist/docs/versioned/next/explanation/dependency-management.md +2 -9
- package/dist/docs/versioned/next/explanation/roadmap-seed-issues.md +13 -0
- package/dist/docs/versioned/next/explanation/test-isolation.md +2 -1
- package/dist/docs/versioned/next/explanation/test-sharding.md +111 -0
- package/dist/docs/versioned/next/how-to/README.md +1 -0
- package/dist/docs/versioned/next/how-to/circleci.md +12 -4
- package/dist/docs/versioned/next/how-to/debug-with-mcp.md +10 -1
- package/dist/docs/versioned/next/how-to/fix-code-scanning-alerts.md +43 -0
- package/dist/docs/versioned/next/how-to/run-tests-locally.md +5 -0
- package/dist/docs/versioned/next/how-to/set-up-terreno-mcp.md +3 -1
- package/dist/docs/versioned/next/how-to/update-dependencies.md +1 -1
- package/dist/docs/versioned/next/implementationPlans/mcp-agent-debugger-gaps.md +257 -0
- package/dist/docs/versioned/next/implementationPlans/syncdb-high-churn-fields.md +266 -0
- package/dist/docs/versioned/next/reference/environment-variables.md +2 -0
- package/dist/docs/versioned/next/reference/mcp-server.md +12 -0
- package/dist/docs/versioned/next/reference/test.md +4 -1
- package/dist/docs/versioned/next/tasks/mcp-agent-debugger-gaps.md +151 -0
- package/dist/local/localTools.d.ts.map +1 -1
- package/dist/local/localTools.js +94 -1
- package/dist/local/localTools.js.map +1 -1
- package/dist/local/metro/metroDevSession.d.ts +1 -0
- package/dist/local/metro/metroDevSession.d.ts.map +1 -1
- package/dist/local/metro/metroDevSession.js +104 -1
- package/dist/local/metro/metroDevSession.js.map +1 -1
- package/dist/local/native/nativeLogs.d.ts +12 -0
- package/dist/local/native/nativeLogs.d.ts.map +1 -0
- package/dist/local/native/nativeLogs.js +103 -0
- package/dist/local/native/nativeLogs.js.map +1 -0
- package/dist/local/tools/clientDev.d.ts +22 -0
- package/dist/local/tools/clientDev.d.ts.map +1 -0
- package/dist/local/tools/clientDev.isolated.d.ts +2 -0
- package/dist/local/tools/clientDev.isolated.d.ts.map +1 -0
- package/dist/local/tools/clientDev.isolated.js +55 -0
- package/dist/local/tools/clientDev.isolated.js.map +1 -0
- package/dist/local/tools/clientDev.js +224 -0
- package/dist/local/tools/clientDev.js.map +1 -0
- package/dist/local/tools/readLogs.d.ts.map +1 -1
- package/dist/local/tools/readLogs.js +22 -3
- package/dist/local/tools/readLogs.js.map +1 -1
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +3 -1
- package/dist/tools.js.map +1 -1
- package/package.json +7 -7
- package/src/docs/templates/bootstrap/frontend/app/_layout.template.tsx +2 -0
- package/src/docs/upgrades/58.0.3.md +28 -0
- package/src/docs/versioned/next/explanation/ai-development-loop.md +10 -7
- package/src/docs/versioned/next/explanation/dependency-management.md +2 -9
- package/src/docs/versioned/next/explanation/roadmap-seed-issues.md +13 -0
- package/src/docs/versioned/next/explanation/test-isolation.md +2 -1
- package/src/docs/versioned/next/explanation/test-sharding.md +111 -0
- package/src/docs/versioned/next/how-to/README.md +1 -0
- package/src/docs/versioned/next/how-to/circleci.md +12 -4
- package/src/docs/versioned/next/how-to/debug-with-mcp.md +10 -1
- package/src/docs/versioned/next/how-to/fix-code-scanning-alerts.md +43 -0
- package/src/docs/versioned/next/how-to/run-tests-locally.md +5 -0
- package/src/docs/versioned/next/how-to/set-up-terreno-mcp.md +3 -1
- package/src/docs/versioned/next/how-to/update-dependencies.md +1 -1
- package/src/docs/versioned/next/implementationPlans/mcp-agent-debugger-gaps.md +257 -0
- package/src/docs/versioned/next/implementationPlans/syncdb-high-churn-fields.md +266 -0
- package/src/docs/versioned/next/reference/environment-variables.md +2 -0
- package/src/docs/versioned/next/reference/mcp-server.md +12 -0
- package/src/docs/versioned/next/reference/test.md +4 -1
- package/src/docs/versioned/next/tasks/mcp-agent-debugger-gaps.md +151 -0
package/CHANGELOG.md
CHANGED
|
@@ -20,6 +20,37 @@ Upgrade notes for consumer action live in [`mcp-server/src/docs/upgrades/`](mcp-
|
|
|
20
20
|
|
|
21
21
|
Unreleased changes live in [`changelog/unreleased/`](changelog/unreleased/). Add one Markdown file per feature (see that directory's README) instead of editing this section.
|
|
22
22
|
|
|
23
|
+
## [58.0.3] - 2026-11-11
|
|
24
|
+
|
|
25
|
+
Upgrade note: [`mcp-server/src/docs/upgrades/58.0.3.md`](mcp-server/src/docs/upgrades/58.0.3.md).
|
|
26
|
+
|
|
27
|
+
### Added
|
|
28
|
+
|
|
29
|
+
- `fix-code-scanning-alerts` skill: clears every open CodeQL alert on one PR. Fixes close on the master rescan; reviewed false positives go in `.github/code-scanning/dismissals.json` and a workflow dismisses them after merge. CodeQL now also scans pull requests and ignores test files. See `docs/how-to/fix-code-scanning-alerts.md`.
|
|
30
|
+
- **@terreno/syncdb:** `registerTerrenoDevClientDispatch`, `registerTerrenoDevStorage`, and `registerTerrenoDevCommand` for `terreno-mcp-local` dev tooling.
|
|
31
|
+
- **@terreno/mcp-server:** `read_logs` sources `network` and `native`; `dispatch_client_action`, storage read/write, and dev command list/invoke; CDP network capture with header redaction.
|
|
32
|
+
|
|
33
|
+
### Changed
|
|
34
|
+
|
|
35
|
+
- Package tests run as concurrent `bun test --shard` processes through `scripts/test-shards.ts` (half the cores by default, `TERRENO_TEST_SHARDS` to override), and `test:coverage` merges the shards' LCOV. CircleCI now pins Bun 1.4.4, the same version as the local toolchain.
|
|
36
|
+
|
|
37
|
+
### Fixed
|
|
38
|
+
|
|
39
|
+
- `Avatar` no longer freezes release builds when its image fails to load. The image error handler passed the native error event to `console.warn`, and with Sentry enabled the app hung while turning that event into a breadcrumb. It now logs only the error message.
|
|
40
|
+
- Mongo filters built from request values reject non-string input with 400 instead of running it as a query operator: AI request explorer `model`, observability review `status`, review batch `promptName`, experiment `datasetId`, trace list filters, push-token `platform`, and `loadDocOr404` ids (404). Sync conflict reloads and tombstone lookups match `_id` with `$eq`.
|
|
41
|
+
- Nested-path helpers in `populate`, RBAC field views, and MCP `excludeFields` skip `__proto__`, `constructor`, and `prototype`, so a crafted path can no longer touch `Object.prototype`.
|
|
42
|
+
- Removed polynomial-time regexes from bearer-header parsing, trailing-slash trimming (syncdb, ui `ListDetailLayout`, jobs Cloud Tasks runner, admin route paths), prompt references, judge score ranges, AI JSON fence stripping, and the MCP import parser.
|
|
43
|
+
- Dataset schema validation stops at the first error (`allErrors` off) to bound work on untrusted input.
|
|
44
|
+
- `isTestUser` in `@terreno/ui` matches `nang.io` and `example.com` as the email domain or a subdomain, not as a substring, and always returns a boolean.
|
|
45
|
+
- MCP OAuth metadata responses set an explicit JSON content type.
|
|
46
|
+
- The example app's AI session id comes from `expo-crypto` `randomUUID` instead of `Math.random`.
|
|
47
|
+
|
|
48
|
+
## [58.0.2] - 2026-11-09
|
|
49
|
+
|
|
50
|
+
### Fixed
|
|
51
|
+
|
|
52
|
+
- Patch the remaining critical and high security advisories in Terreno's dependency tree. `@terreno/ui` now asks for `@react-navigation/native` `^7.5.1`, whose `@react-navigation/core` no longer pulls in the vulnerable `decode-uri-component` (#1693). The docs site moves to tinypool 2.2.0 (critical) and serialize-javascript 7.1.4 (#1690, #1691), Metro's stale nested copy no longer brings in image-size 1.x (#1694), and rulesync 43.8.0 drops its pinned zod 4.6.5 (#1695). Dependabot now opens one security PR per advisory instead of one grouped PR per package block (#1689). Expo tooling still carries zod 3.25.76, which has no fixed 3.x release.
|
|
53
|
+
|
|
23
54
|
## [58.0.1] - 2026-11-09
|
|
24
55
|
|
|
25
56
|
### Added
|
package/README.md
CHANGED
|
@@ -91,16 +91,18 @@ Restart the editor, then ask the agent to call `terreno_search_docs` or `applica
|
|
|
91
91
|
`terreno_get_update_note`, `terreno_ask_update_help`, `terreno_generate_model`,
|
|
92
92
|
`terreno_generate_route`, `terreno_generate_screen`, `terreno_generate_form_fields`,
|
|
93
93
|
`terreno_validate_model_schema`, `terreno_validate_ui_blocks`, `terreno_install_admin`
|
|
94
|
-
- Local `terreno-mcp-local` tools (
|
|
94
|
+
- Local `terreno-mcp-local` tools (15): `application_info`, `database_schema`, `database_query`,
|
|
95
95
|
`read_logs`, `last_error`, `get_syncdb_state`, `syncdb_snapshot`, `syncdb_action`, `evaluate`,
|
|
96
|
-
`navigate`, `
|
|
96
|
+
`navigate`, `dispatch_client_action`, `read_local_storage`, `write_local_storage`,
|
|
97
|
+
`list_dev_commands`, `invoke_dev_command`, `browser`
|
|
97
98
|
- Nine workflow prompts (`terreno_bootstrap`, `terreno_create_crud_feature`, `terreno_upgrade`, and
|
|
98
99
|
more) and `terreno://docs/*` documentation resources on the hosted server
|
|
99
100
|
- Code generators return text with a target path; the agent writes the files
|
|
100
101
|
- Rate limiting: the hosted server allows 120 requests per 60 seconds per client IP by default and
|
|
101
102
|
answers `429` with `Retry-After` beyond that
|
|
102
|
-
- `TERRENO_MCP_EVAL` gate: `evaluate`, `navigate`, `syncdb_action`,
|
|
103
|
-
|
|
103
|
+
- `TERRENO_MCP_EVAL` gate: `evaluate`, `navigate`, `syncdb_action`, `dispatch_client_action`,
|
|
104
|
+
`write_local_storage`, `invoke_dev_command`, and the `browser` `evaluate` action run only when
|
|
105
|
+
the local server's environment sets `TERRENO_MCP_EVAL=1` (or `true`)
|
|
104
106
|
|
|
105
107
|
## Documentation
|
|
106
108
|
|
|
@@ -7,12 +7,14 @@ import {DefaultTheme, ThemeProvider} from "expo-router/react-navigation";
|
|
|
7
7
|
import type React from "react";
|
|
8
8
|
import {useEffect} from "react";
|
|
9
9
|
import "react-native-reanimated";
|
|
10
|
+
import {registerTerrenoDevStorage} from "@terreno/syncdb";
|
|
10
11
|
import {installDevConsoleLogger} from "@terreno/syncdb/app";
|
|
11
12
|
import {betterAuthClient} from "@/lib/betterAuth";
|
|
12
13
|
import {apiClient} from "@/store/apiClient";
|
|
13
14
|
import {setSyncDbReady, syncDb} from "@/store/syncdb";
|
|
14
15
|
|
|
15
16
|
installDevConsoleLogger({baseUrl});
|
|
17
|
+
registerTerrenoDevStorage({asyncStorage: true});
|
|
16
18
|
|
|
17
19
|
export {ErrorBoundary} from "expo-router";
|
|
18
20
|
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Upgrading to 58.0.3
|
|
2
|
+
|
|
3
|
+
**Action required:** No
|
|
4
|
+
**Affected packages:** None
|
|
5
|
+
|
|
6
|
+
## Summary
|
|
7
|
+
|
|
8
|
+
A patch release with bug and security fixes. `Avatar` no longer freezes release builds when its image fails to load. Mongo filters built from request values, nested-path helpers, and several regexes are hardened against untrusted input. Consumers only need to bump their `@terreno/*` versions.
|
|
9
|
+
|
|
10
|
+
## Breaking changes
|
|
11
|
+
|
|
12
|
+
None
|
|
13
|
+
|
|
14
|
+
The only `Changed` entry affects this repository's own test tooling (sharded `bun test` and Bun 1.4.4 on CircleCI). Nothing changes for consumer apps.
|
|
15
|
+
|
|
16
|
+
## Deprecations
|
|
17
|
+
|
|
18
|
+
None
|
|
19
|
+
|
|
20
|
+
## New capabilities
|
|
21
|
+
|
|
22
|
+
- **@terreno/syncdb:** `registerTerrenoDevClientDispatch`, `registerTerrenoDevStorage`, and `registerTerrenoDevCommand` for `terreno-mcp-local` dev tooling. These are optional.
|
|
23
|
+
- **@terreno/mcp-server:** `read_logs` sources `network` and `native`, client action dispatch, storage read/write, and dev commands.
|
|
24
|
+
|
|
25
|
+
## Verification
|
|
26
|
+
|
|
27
|
+
- `bun run compile` and `bun run lint` at the app root
|
|
28
|
+
- In a release build, show an `Avatar` whose `src` fails to load. It falls back to initials and the app stays responsive.
|
|
@@ -15,7 +15,7 @@ flowchart LR
|
|
|
15
15
|
ASK["1. Ask<br/>terreno_search_docs<br/>terreno_get_component_docs<br/>application_info"]
|
|
16
16
|
GEN["2. Generate<br/>terreno_generate_*<br/>terreno_validate_model_schema"]
|
|
17
17
|
RUN["3. Run<br/>backend dev server<br/>Metro (Expo)"]
|
|
18
|
-
OBS["4. Observe<br/>read_logs (backend / browser / metro / app)<br/>last_error<br/>get_client_state"]
|
|
18
|
+
OBS["4. Observe<br/>read_logs (backend / browser / metro / app / network / native)<br/>last_error<br/>get_client_state"]
|
|
19
19
|
FIX["5. Fix<br/>edit, then navigate<br/>browser snapshot + screenshot"]
|
|
20
20
|
ASK --> GEN --> RUN --> OBS --> FIX
|
|
21
21
|
FIX -->|"iterate"| ASK
|
|
@@ -79,7 +79,7 @@ The agent reads what the app did.
|
|
|
79
79
|
|
|
80
80
|
| Tool | Contributes |
|
|
81
81
|
| --- | --- |
|
|
82
|
-
| `read_logs` | One merged, time-ordered tail from
|
|
82
|
+
| `read_logs` | One merged, time-ordered tail from six sources: `backend` (server JSONL), `browser` (web errors and warnings JSONL), `metro` (bundler events), `app` (the Hermes console over CDP), `network` (CDP Network events on the same session), and `native` (adb / iOS Simulator log tail when available). Default sources omit `native`. Its `connection` field says which live sources are attached. |
|
|
83
83
|
| `last_error` | The newest error-level entry across the same sources, as the raw line. It includes a stack when the entry carries one. |
|
|
84
84
|
| `get_client_state` | The client data layer in the running app. It reports which `layer` it found (`rtk`, `syncdb`, both, or `none`) and returns the RTK Query cache and auth state, the SyncDB state, or both. `get_rtk_state` is a deprecated alias. |
|
|
85
85
|
| `get_syncdb_state`, `syncdb_snapshot` | SyncDB entities, outbox, conflicts, cursors, and debug events, plus snapshots to compare before and after a change |
|
|
@@ -96,13 +96,16 @@ result.
|
|
|
96
96
|
| --- | --- |
|
|
97
97
|
| `navigate` | Moves a native app to an expo-router path over the same CDP connection the logs use |
|
|
98
98
|
| `browser` | Drives the web app in a headless WebView: open, click, type, scroll, then `snapshot` the rendered page and save a `screenshot` as proof |
|
|
99
|
-
| `
|
|
99
|
+
| `dispatch_client_action` | Dispatches a known Redux action on the dev store (prefer over raw `evaluate`) |
|
|
100
|
+
| `read_local_storage` / `write_local_storage` | Read or write AsyncStorage keys registered for MCP dev tooling |
|
|
101
|
+
| `list_dev_commands` / `invoke_dev_command` | List and run app-registered dev-only command handlers |
|
|
102
|
+
| `evaluate` | Runs a JavaScript expression in the app's Hermes runtime when no fixed tool fits |
|
|
100
103
|
| `syncdb_action` | Changes a live SyncDB client: mutate, flush, resync, resolve conflicts, go offline |
|
|
101
104
|
|
|
102
|
-
`evaluate`, `navigate`, `
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
actions do not need it.
|
|
105
|
+
`evaluate`, `navigate`, `dispatch_client_action`, `write_local_storage`, `invoke_dev_command`,
|
|
106
|
+
`syncdb_action`, and the `browser` tool's `evaluate` action run code or change state inside the
|
|
107
|
+
app, so they refuse unless the local server was started with `TERRENO_MCP_EVAL=1`. Generated
|
|
108
|
+
editor configuration never sets it. The other `browser` actions do not need it.
|
|
106
109
|
|
|
107
110
|
After the fix, the loop goes back to Observe. A change is done when the logs and state show
|
|
108
111
|
the new behavior, not when the edit compiles.
|
|
@@ -69,16 +69,9 @@ JavaScript packages, GitHub Actions, and a few Expo JS-only names may update. Me
|
|
|
69
69
|
|
|
70
70
|
## Dependabot configuration
|
|
71
71
|
|
|
72
|
-
`.github/dependabot.yml` sets `open-pull-requests-limit: 0` on every block. That turns off version-update PRs; security updates ignore the limit and still honor `ignore`.
|
|
72
|
+
`.github/dependabot.yml` sets `open-pull-requests-limit: 0` on every block. That turns off version-update PRs; security updates ignore the limit and still honor `ignore`. Security updates are not grouped: each advisory opens its own PR per block (`github-actions` at `/`, `bun` at `/`, the backend directories, and the frontend directories), so one fix can merge without waiting on another.
|
|
73
73
|
|
|
74
|
-
|
|
75
|
-
| --- | --- |
|
|
76
|
-
| `github-actions` | `github-actions` at `/` |
|
|
77
|
-
| `root` | `bun` at `/` (root catalog and root tools) |
|
|
78
|
-
| `backend` | `bun` under api, ai, backends, … |
|
|
79
|
-
| `frontend` | `bun` under ui, syncdb, admin-frontend, demo, apps, … |
|
|
80
|
-
|
|
81
|
-
Frontend ignores catalog-managed names so those fixes land once, in the root catalog. Root ignores fingerprint-skip names, so a security fix for a native/Expo package never opens a PR; handle it by hand in a release. `dependabot-auto-merge.yml` approves patch and minor Dependabot PRs and enables squash auto-merge, so those security PRs merge when required checks pass. A semver-major security PR (or a group containing one) gets no approval or auto-merge and waits for a human. When one fails because the fix needs code changes, fold the bump into the rolling PR ([Update dependencies](../how-to/update-dependencies.md)); never push to the `dependabot/*` branch.
|
|
74
|
+
Frontend ignores catalog-managed names so those fixes land once, in the root catalog. Root ignores fingerprint-skip names, so a security fix for a native/Expo package never opens a PR; handle it by hand in a release. `dependabot-auto-merge.yml` approves patch and minor Dependabot PRs and enables squash auto-merge, so those security PRs merge when required checks pass. A semver-major security PR gets no approval or auto-merge and waits for a human. When one fails because the fix needs code changes, fold the bump into the rolling PR ([Update dependencies](../how-to/update-dependencies.md)); never push to the `dependabot/*` branch.
|
|
82
75
|
|
|
83
76
|
## Daily rolling PR
|
|
84
77
|
|
|
@@ -1451,6 +1451,19 @@ Delete the `@terreno/rtk` package and every Redux dependency from the monorepo.
|
|
|
1451
1451
|
|
|
1452
1452
|
---
|
|
1453
1453
|
|
|
1454
|
+
## syncdb-high-churn-fields
|
|
1455
|
+
|
|
1456
|
+
**Title:** `SyncDB: high-churn fields without a sequence claim per write`
|
|
1457
|
+
|
|
1458
|
+
**Labels:** `area:api`, `type:feature`
|
|
1459
|
+
**Project fields:** Area=`api`, Target=`Next`, Impact=`Feature`, IP=`syncdb-high-churn-fields`, Status=`Shaping`
|
|
1460
|
+
|
|
1461
|
+
A synced document can carry fields that change every few seconds (a gauge, a heartbeat, a progress counter) without each change costing three replicated writes and a round trip through the stream's counter document.
|
|
1462
|
+
|
|
1463
|
+
- **Implementation plan:** [syncdb-high-churn-fields.md](https://github.com/TerrenoLabs/terreno/blob/master/docs/implementationPlans/syncdb-high-churn-fields.md)
|
|
1464
|
+
|
|
1465
|
+
---
|
|
1466
|
+
|
|
1454
1467
|
# Shipped, umbrella, and declined IPs
|
|
1455
1468
|
|
|
1456
1469
|
Tracking issues created for IPs that previously lacked a `**Roadmap issue:**` header.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# Test isolation in Bun suites
|
|
2
2
|
|
|
3
|
-
`bun test` runs every test file of a package
|
|
3
|
+
`bun test` runs every test file of a package, or of one [shard](test-sharding.md) of it,
|
|
4
|
+
in one process. `mock.module` replaces a
|
|
4
5
|
module for that whole process, and `mock.restore()` does not undo it. A test that
|
|
5
6
|
mocks a module can pass on its own, then break other files, or be broken by them,
|
|
6
7
|
when the whole package runs. CI always runs the whole package, so this kind of
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# Test sharding in Bun suites
|
|
2
|
+
|
|
3
|
+
Every package runs its tests through `scripts/test-shards.ts`. The runner starts several
|
|
4
|
+
`bun test --shard=<i>/<n>` processes at once, one per shard, and fails when any of them
|
|
5
|
+
fails. Bun 1.4.4 or newer is required: older versions have no `--shard`.
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
cd api
|
|
9
|
+
bun run test:ci # shards chosen from the machine's cores
|
|
10
|
+
TERRENO_TEST_SHARDS=1 bun run test:ci # one unsplit process
|
|
11
|
+
TERRENO_TEST_SHARDS=3 bun run test:ci # exactly three shards
|
|
12
|
+
bun test ./src/auth.test.ts # one file, no runner
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Why shards and not `bun test --parallel`
|
|
16
|
+
|
|
17
|
+
A shard is an ordinary `bun test` process. It loads the preload once, keeps one module
|
|
18
|
+
registry, and starts one in-memory Mongo, exactly as an unsplit run does. A test file sees
|
|
19
|
+
the same world either way. Only the set of files that share its process changes.
|
|
20
|
+
|
|
21
|
+
`bun test --parallel` gives each file a fresh global. That re-runs the preload's
|
|
22
|
+
`beforeAll` and `afterAll` for every file, so a backend package starts and stops Mongo once
|
|
23
|
+
per file and reloads every module. Measured on `@terreno/api` (169 files, 4 cores): 648 s
|
|
24
|
+
unsplit, 459 s with `--parallel`, 408 s with two shards.
|
|
25
|
+
|
|
26
|
+
## How many shards
|
|
27
|
+
|
|
28
|
+
| Source | Shards |
|
|
29
|
+
| --- | --- |
|
|
30
|
+
| `TERRENO_TEST_SHARDS` set | That number |
|
|
31
|
+
| Not set | Half the cores, at least 1, at most 4 |
|
|
32
|
+
|
|
33
|
+
A backend shard keeps a Bun process and a `mongod` busy, about two cores. More shards than
|
|
34
|
+
half the cores slows every shard down and makes timing-sensitive tests fail.
|
|
35
|
+
|
|
36
|
+
CircleCI jobs set `TERRENO_TEST_SHARDS` themselves, because a container reports the host's
|
|
37
|
+
cores and not its own CPU limit. Medium jobs (2 vCPU) run 1 shard. `api-ci`, the longest
|
|
38
|
+
test job, runs on `large` (4 vCPU) with 2 shards.
|
|
39
|
+
|
|
40
|
+
Root `bun run test` and `bun run test:agent` set `TERRENO_TEST_SHARDS=1`: they already run
|
|
41
|
+
every package at the same time.
|
|
42
|
+
|
|
43
|
+
## Measured speedup
|
|
44
|
+
|
|
45
|
+
One 4-core machine, every package's `test:ci` run one after another:
|
|
46
|
+
|
|
47
|
+
| Package | Unsplit | 2 shards |
|
|
48
|
+
| --- | --- | --- |
|
|
49
|
+
| `api` | 648 s | 408 s |
|
|
50
|
+
| `ai` | 314 s | 187 s |
|
|
51
|
+
| `example-backend` | 253 s | 135 s |
|
|
52
|
+
| `admin-frontend` | 142 s | 75 s |
|
|
53
|
+
| `admin-backend` | 124 s | 83 s |
|
|
54
|
+
| `ui` | 95 s | 65 s |
|
|
55
|
+
| All 21 packages | 1849 s | 1163 s |
|
|
56
|
+
|
|
57
|
+
Packages that finish in a few seconds gain nothing and lose nothing.
|
|
58
|
+
|
|
59
|
+
## Isolated files
|
|
60
|
+
|
|
61
|
+
`ai` and `admin-frontend` pass `--isolated` to the runner. After the shards pass, each
|
|
62
|
+
`src/isolated/*.isolated.ts(x)` file runs in a process of its own, as many at a time as there
|
|
63
|
+
are shards. See [Test isolation](test-isolation.md).
|
|
64
|
+
|
|
65
|
+
## Coverage
|
|
66
|
+
|
|
67
|
+
`bun run test:coverage` (`scripts/check-coverage.ts`) uses the same shards. Each shard writes
|
|
68
|
+
its own LCOV report. The script merges them, writes `coverage/lcov.info`, and gates the
|
|
69
|
+
merged numbers at 95%.
|
|
70
|
+
|
|
71
|
+
Line coverage merges exactly: a line counts when any shard ran it. The sharded line figure
|
|
72
|
+
equals the unsplit one.
|
|
73
|
+
|
|
74
|
+
Function coverage cannot merge exactly. Bun's LCOV has no per-function records, only a found
|
|
75
|
+
and hit count per file, and Bun counts a nested function only after its parent ran, so shards
|
|
76
|
+
disagree on how many functions a file has. The script takes the largest found count and the
|
|
77
|
+
largest hit count for each file. That estimate usually reads low, because functions hit in
|
|
78
|
+
different shards are not added together. It can read high when one shard runs most of a file
|
|
79
|
+
and another shard finds nested functions that nothing calls.
|
|
80
|
+
|
|
81
|
+
A sharded run that misses 95% is run again as one unsplit process, and the gate uses that
|
|
82
|
+
exact result. A package whose function coverage is near 95% therefore pays for a second pass;
|
|
83
|
+
set `TERRENO_TEST_SHARDS=1` to skip the first. CircleCI gates every package unsplit except
|
|
84
|
+
`api` and `ai`, which run 2 shards.
|
|
85
|
+
|
|
86
|
+
While shards run, their output is held and printed one shard at a time. The runner prints a
|
|
87
|
+
`[shards] still running` line once a minute so CI does not see a silent job.
|
|
88
|
+
|
|
89
|
+
## When a test fails only in a shard
|
|
90
|
+
|
|
91
|
+
Sharding changes which files share a process. A test that passed only because an earlier
|
|
92
|
+
file left something behind now fails. Run the file alone to confirm:
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
bun test ./src/models/configuration.test.ts
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Fix the file so it passes alone. The usual causes:
|
|
99
|
+
|
|
100
|
+
1. **A missing import.** The test reads state that another file's import registered. Import
|
|
101
|
+
the module in the test.
|
|
102
|
+
2. **A module mock from another file.** A snapshot or assertion matches another file's
|
|
103
|
+
`mock.module` shape. Register the mock once in the package preload.
|
|
104
|
+
3. **A timing budget.** Shards load the machine. Freeze the clock with `setSystemTime` or give
|
|
105
|
+
a slow test its own timeout; do not rely on wall-clock windows.
|
|
106
|
+
|
|
107
|
+
To reproduce the exact process a shard ran, pass the shard to Bun directly:
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
bun test --shard=2/3
|
|
111
|
+
```
|
|
@@ -16,6 +16,7 @@ Problem-oriented, practical steps. Use these when you know what you want to do.
|
|
|
16
16
|
|
|
17
17
|
- [Create a Terreno app](create-a-terreno-app.md) — Scaffold a full-stack app with `create-terreno-app` (Bun or npm)
|
|
18
18
|
- [Update dependencies](update-dependencies.md) — Daily rolling PR, exercise test, Expo fingerprint freeze
|
|
19
|
+
- [Fix code scanning alerts](fix-code-scanning-alerts.md) — One PR per sweep; fixes close on rescan, reviewed false positives are dismissed after merge
|
|
19
20
|
- [CircleCI](circleci.md) — Dual-run CI on CircleCI (package CI / policy / e2e; deploys later)
|
|
20
21
|
- [Release automation](release-automation.md) — Let agents merge release notes and roadmap updates; publish only merged notes
|
|
21
22
|
- [Set up tests in a Terreno app](set-up-app-tests.md) — Bun backend and frontend tests, Playwright web E2E, Maestro on iOS/Android
|
|
@@ -49,10 +49,18 @@ list pipelines on the slug above.
|
|
|
49
49
|
|
|
50
50
|
## Bun version is pinned
|
|
51
51
|
|
|
52
|
-
`install_bun_and_deps` pins Bun with `node/install-bun` `version
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
`bun run test:coverage` in each package first
|
|
52
|
+
`install_bun_and_deps` pins Bun with `node/install-bun` `version`, currently 1.4.4, the
|
|
53
|
+
same version as the local toolchain and the GitHub workflows. Package tests run through
|
|
54
|
+
`bun test --shard`, which needs 1.4.4 or newer. Bump the pin together with the local
|
|
55
|
+
toolchain and re-run `bun run test:coverage` in each package first: coverage numbers move
|
|
56
|
+
between Bun releases.
|
|
57
|
+
|
|
58
|
+
## Test shards
|
|
59
|
+
|
|
60
|
+
Each executor sets `TERRENO_TEST_SHARDS`, the number of concurrent `bun test --shard`
|
|
61
|
+
processes a package's tests use. Medium executors set 1. `api-ci`, the longest test
|
|
62
|
+
job, overrides it to 2 and runs on `large`. See
|
|
63
|
+
[Test sharding](../explanation/test-sharding.md).
|
|
56
64
|
|
|
57
65
|
## Bun install is uncached
|
|
58
66
|
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Debug a Terreno app with MCP
|
|
2
2
|
|
|
3
|
+
**This is the standard agent workflow** for finding and fixing issues on Terreno apps: run the
|
|
4
|
+
dev stack, call **`terreno-local`** MCP tools to observe and drive the app, edit code, then
|
|
5
|
+
observe again. Installable skill: **`debug-with-mcp`**. SyncDB-only depth: **`debug-syncdb-with-mcp`**.
|
|
6
|
+
|
|
3
7
|
Use the local MCP server (`terreno-mcp-local`) to go from a symptom to a verified fix without
|
|
4
8
|
pasting logs into the chat. This guide follows one real failure from start to finish, then lists
|
|
5
9
|
what each tool does. Every tool output below was copied unchanged from a real run against
|
|
@@ -12,6 +16,11 @@ what each tool does. Every tool output below was copied unchanged from a real ru
|
|
|
12
16
|
| API returns 500 | `last_error` with `sources: ["backend"]`. The stack is inside `message`. | `read_logs` with `sources: ["backend"]` and `since` to see the requests around it. |
|
|
13
17
|
| API returns 403 (or another 4xx) | `read_logs` with `sources: ["backend"]` and `level: "warn"`. Every `APIError` under 500 is logged at `warn` as `ForbiddenError(403): <title> — <detail>`, so `last_error` does not show it. | `database_query` to compare the document's `ownerId` with the user in the log line. |
|
|
14
18
|
| App crashes on a screen | Web: `last_error` with `sources: ["browser"]`. An uncaught error carries a separate `stack` field. A render error caught by an error boundary has no `stack`; its `message` names the component instead (see [A screen crashes on web](#a-screen-crashes-on-web)). Native: `last_error` with `sources: ["app"]`. | Native: `navigate` to the screen and call `last_error` again. Web: the `browser` tool. |
|
|
19
|
+
| Wrong API URL or status on device | `read_logs` with `sources: ["network"]` after reproducing the tap. | `database_query` or backend logs to compare server truth. |
|
|
20
|
+
| Auth/session oddities (token in storage) | `read_local_storage` with `prefix: "persist:"` or known key names. | `write_local_storage` only with `TERRENO_MCP_EVAL=1` to fix dev keys; prefer fixing app code for prod. |
|
|
21
|
+
| Native-only crash (no Hermes console) | `read_logs` with `sources: ["native"]` (needs `adb` or iOS Simulator). | `last_error` with `sources: ["app"]` when Hermes is attached. |
|
|
22
|
+
| Need a one-off dev action in the app | `list_dev_commands`, then `invoke_dev_command` with `TERRENO_MCP_EVAL=1`. | Register handlers with `registerTerrenoDevCommand` in app code. |
|
|
23
|
+
| Redux state wrong but SyncDB OK | `get_client_state` or `dispatch_client_action` with a known action type. | `syncdb_action` only for collection CRUD, not Redux. |
|
|
15
24
|
| Data looks wrong | `database_query` to read what the server stored. | `get_client_state` (RTK cache) or `get_syncdb_state` (SyncDB) to compare the client's copy. |
|
|
16
25
|
| Screen renders empty | `get_client_state` or `get_syncdb_state` on native. On web, `browser` with `snapshot`. | `read_logs` with `sources: ["backend"]` to check that the list request ran and returned 200. |
|
|
17
26
|
| Bundler fails | The terminal that runs `expo start`. The `metro` source is always empty under Expo CLI 57: the `/events` socket connects but Expo never sends on it. | On native, `read_logs` with `sources: ["app"]` once the app loads again. |
|
|
@@ -161,7 +170,7 @@ On web this returns `layer: "none"`:
|
|
|
161
170
|
```json
|
|
162
171
|
{
|
|
163
172
|
"connection": "CDP: Error: No debuggable Hermes/React Native target with webSocketDebuggerUrl (is the app running?); Metro events: not connected",
|
|
164
|
-
"hint": "No client data layer found. For
|
|
173
|
+
"hint": "No client data layer found. For SyncDB, create the client with `createSyncDb({debug: true})`. For custom client actions, call `registerTerrenoDevClientDispatch` from `@terreno/syncdb` in __DEV__. Keep the app running; when the MCP process cannot see the app heap, start Metro so CDP can reach Hermes (see `connection`).",
|
|
165
174
|
"layer": "none",
|
|
166
175
|
"reasons": {
|
|
167
176
|
"rtk": "Error: No debuggable Hermes/React Native target with webSocketDebuggerUrl (is the app running?)",
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Fix code scanning alerts
|
|
2
|
+
|
|
3
|
+
Run `/fix-code-scanning-alerts` to clear every open CodeQL alert on one PR. When that PR merges, each alert closes: fixes close when CodeQL rescans `master`, and reviewed false positives are dismissed by a workflow.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
gh api "repos/{owner}/{repo}/code-scanning/alerts?state=open&per_page=100" --paginate \
|
|
7
|
+
| jq -s 'add | group_by(.rule.id) | map({rule: .[0].rule.id, count: length})'
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## How alerts close
|
|
11
|
+
|
|
12
|
+
| Lane | In the PR | After merge |
|
|
13
|
+
| --- | --- | --- |
|
|
14
|
+
| Fix | Code change and a regression test | The CodeQL push scan on `master` no longer reports it, so it closes as **fixed** |
|
|
15
|
+
| Dismiss | An entry in `.github/code-scanning/dismissals.json` | `code-scanning-dismissals.yml` dismisses it with the entry's reason and comment |
|
|
16
|
+
|
|
17
|
+
Dismissals wait for the merge so a reviewer approves each one, and the Security tab never shows an alert closed by an unmerged branch.
|
|
18
|
+
|
|
19
|
+
## Pieces
|
|
20
|
+
|
|
21
|
+
- `.github/codeql/codeql-config.yml`: CodeQL configuration. Test files are ignored, so their alerts close on the next `master` scan.
|
|
22
|
+
- `.github/workflows/codeql-analysis.yml`: also runs on pull requests (diff-informed: only changed lines) and on manual dispatch. Dispatch it on a branch for a full scan that proves each fix clears its alert before merge.
|
|
23
|
+
- `.github/code-scanning/dismissals.json`: the dismissal ledger. Each entry has `alert`, `rule`, `path`, `reason` (`false positive`, `won't fix`, or `used in tests`), and a `comment` of 280 characters or fewer.
|
|
24
|
+
- `.github/workflows/code-scanning-dismissals.yml`: runs on `master` when the ledger changes, and on manual dispatch.
|
|
25
|
+
- `scripts/ci/codeScanning/applyDismissals.ts`: applies the ledger. It dismisses an entry only when the live alert is still open and its rule and path still match. A mismatch fails the job.
|
|
26
|
+
|
|
27
|
+
## Check a ledger locally
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
bun test scripts/ci/codeScanning/
|
|
31
|
+
GITHUB_TOKEN="$(gh auth token)" GITHUB_REPOSITORY=TerrenoLabs/terreno \
|
|
32
|
+
bun scripts/ci/codeScanning/applyDismissals.ts --dry-run
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
The dry run must report `mismatched 0`.
|
|
36
|
+
|
|
37
|
+
## Rate limiting alerts
|
|
38
|
+
|
|
39
|
+
`js/missing-rate-limiting` flags every Express route because CodeQL only recognizes known limiter libraries. `TerrenoApp` mounts its own limiter before all plugins (see [Rate limiting](rate-limiting.md)), so these alerts go in the ledger as false positives. A route mounted outside `TerrenoApp` has no limiter and needs a real fix.
|
|
40
|
+
|
|
41
|
+
## Dependabot
|
|
42
|
+
|
|
43
|
+
Dependabot opens **security PRs only**. Routine upgrades go through [Update dependencies](update-dependencies.md). Every workspace package directory is listed in `.github/dependabot.yml`. Add a new package's directory there when you create it.
|
|
@@ -52,6 +52,11 @@ bun run test # every workspace `test:ci`
|
|
|
52
52
|
bun run test:agent # same suites; passing cases suppressed
|
|
53
53
|
```
|
|
54
54
|
|
|
55
|
+
Each package's `test`, `test:ci`, `test:agent`, and `test:coverage` scripts split the suite
|
|
56
|
+
into concurrent `bun test --shard` processes, half the cores by default. Set
|
|
57
|
+
`TERRENO_TEST_SHARDS=1` for one unsplit process. See
|
|
58
|
+
[Test sharding](../explanation/test-sharding.md).
|
|
59
|
+
|
|
55
60
|
Closest package during a red/green cycle:
|
|
56
61
|
|
|
57
62
|
```bash
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
# Set up Terreno MCP
|
|
2
2
|
|
|
3
3
|
Configure both Terreno servers: the hosted server supplies documentation and generators; the local
|
|
4
|
-
stdio server inspects the app, database, logs, Metro, and
|
|
4
|
+
stdio server inspects the app, database, logs, Metro, SyncDB state, web and native navigation.
|
|
5
|
+
After setup, invoke **`debug-with-mcp`** (and when applicable **`debug-syncdb-with-mcp`**) for the
|
|
6
|
+
standard diagnostic workflow.
|
|
5
7
|
- **`terreno`** (hosted, Streamable HTTP) supplies documentation search and code generators.
|
|
6
8
|
- **`terreno-local`** (stdio, runs in your repository) reads the app's packages, database, logs,
|
|
7
9
|
Metro, and client state.
|
|
@@ -60,4 +60,4 @@ CircleCI attributes a pipeline to the GitHub user whose token pushed it and emai
|
|
|
60
60
|
|
|
61
61
|
## Dependabot security PRs
|
|
62
62
|
|
|
63
|
-
`.github/dependabot.yml` sets `open-pull-requests-limit: 0` on every block, so Dependabot opens no version-update PRs. Security updates still open,
|
|
63
|
+
`.github/dependabot.yml` sets `open-pull-requests-limit: 0` on every block, so Dependabot opens no version-update PRs. Security updates still open, one PR per advisory, and skip ignored native/Expo names. `dependabot-auto-merge.yml` approves them and enables squash auto-merge, so a green security PR merges without this skill. A red one gets its bump folded into the rolling PR. A security fix for an ignored native package is a manual release task (`release` + `upgrading-expo`).
|