Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

docs(testing): how to tell an environmental red from a defect

M3gA-Mind5005f742ae3e
diff --git a/gitbooks/developing/testing-strategy.md b/gitbooks/developing/testing-strategy.md
index 032cffbc22..022a807738 100644
--- a/gitbooks/developing/testing-strategy.md
+++ b/gitbooks/developing/testing-strategy.md
@@ -149,6 +149,146 @@ When you add / remove / rename a feature, **update the matrix row in the same PR
---
+## A red Rust suite locally is usually not a defect
+
+Most local Rust failures in this repo are environmental, and the environments
+fail in ways that look exactly like product defects. Work down this list before
+concluding anything — each step is one command, and every one of them has caught
+a wrong conclusion that was already on its way into an issue.
+
+**Every prerequisite below carries the failure you get without it.** A step with
+its failure attached is self-auditing — anyone can check in thirty seconds
+whether it is still true, and a stale one announces itself. A bare list of steps
+cannot be audited at all, which is how it rots into folklore. *If you cannot
+produce the failure for an item, it does not belong here.*
+
+**A note that tells you the cause is not evidence of the cause.** A line in a
+doc or a memory saying "these fail locally, it is provisioning" is a
+*pre-supplied conclusion*. It terminates the investigation before it starts,
+which is worse than no note at all — one such note sent a worker looking for a
+provisioning gap when the real cause was a product defect
+(`agent definition \`harness\` was not found`, openhuman#6487). Use the steps,
+not the folklore.
+
+### 1. Did anything compile?
+
+`cargo` exits **101** for at least three states that are identical from the
+shell: nothing compiled, a test asserted false, or the process aborted.
+
+```bash
+grep -c "^test result" run.log # 0 = nothing ran
+```
+
+Zero `test result` lines means the question is *compilation or abort*, never
+"which test failed". Then read the **first** error line:
+
+- `failed to load source for dependency <x>` / `No such file or directory` →
+ a submodule is not checked out.
+- `fatal runtime error: stack overflow` with `signal: 6, SIGABRT` and no
+ `test result` line at all → the process aborted; see step 3.
+
+### 2. Are the submodules actually there — at every depth?
+
+Some crates depend on submodules **nested inside other submodules**.
+`openhuman-tinyhumans` is the clearest case: it needs `vendor/tinyhumans-sdk`
+(top level) **and** `vendor/tinyagents/vendor/tinytools` (nested). A plain
+`git submodule update --init` fetches the first and silently not the second, so
+the obvious command leaves you with a compile failure that reads as a test
+failure.
+
+```bash
+git submodule update --init
+git -C vendor/tinyagents submodule update --init --recursive
+```
+
+*Falsified:* deinitialising `vendor/tinyagents/vendor/tinytools` and re-running
+`cargo test -p openhuman-tinyhumans` gives, with **no** `test result` line:
+
+```
+error: failed to get `tinytools` as a dependency of package `openhuman-cli v0.63.31`
+ failed to load source for dependency `tinytools`
+ No such file or directory (os error 2)
+```
+
+**Check content, never status.** `git submodule status` prints `-` only for
+*unregistered* modules, and registration happens **before** checkout — so a
+mid-flight init reads as ready while every working tree is still empty.
+Observed mid-`update --init`: **13 `+`, 3 ` `, zero `-`** while `du -sh vendor`
+was **120K** and `ls vendor/tinychannels` was empty.
+
+```bash
+du -sh vendor # 120K = empty; a real checkout is GBs
+ls vendor/<module> | wc -l # 0 = empty, whatever status says
+```
+
+### 3. Is your feature set the one CI uses?
+
+`cargo test -p openhuman --lib` on default features is a **materially smaller
+product** than CI builds, and the difference changes test *outcomes*, not just
+which tests exist.
+
+The mechanism is worth understanding because it is invisible in the output: a
+feature flag can gate the *registration* of a tool, a test's expected side is a
+static allowlist while its actual side is computed by **introspecting the built
+binary**, and so the flag silently moves the actual. Nothing is stubbed, nothing
+is skipped, and the failure names a product concept —
+*"agents that carry tools but whose prompt names none of them"* — with no
+mention of a feature anywhere.
+
+*Falsified, from the two runs side by side:* on `0f1ecc9d2`, `openhuman --lib`
+fails **5** tests on default and **3** under CI's set; the two that differ are
+pure profile artefacts
+(`every_prompt_names_at_least_one_tool_it_can_call` needs `runtime-node`,
+`the_withheld_block_renders_for_a_renamed_session_with_a_filter` needs
+`documents`). Reproduce CI exactly before asserting anything:
+
+```bash
+RUST_MIN_STACK=67108864 cargo test -p openhuman --lib \
+ --features "$(bash scripts/ci/product-features.sh)"
+```
+
+Tracked as openhuman#6512; per-profile detail in openhuman#6486.
+
+**`RUST_MIN_STACK` is per-suite, not universal.**
+
+*Falsified for `openhuman-tinyhumans`:* removing it and re-running still gives
+`183 passed; 0 failed`. It is **not** a requirement there.
+
+*Reported for `openhuman --lib`:* `web_chat` aborts with
+`fatal runtime error: stack overflow` without it, which is why `ci-lite.yml`
+exports it. Not reproduced here — treat as the reason the CI command above
+carries it, and re-verify before relying on it elsewhere.
+
+Two crates, one variable, opposite answers. That is the argument against a
+single blanket recipe: do not add a prerequisite by reflex. One that is not
+needed teaches contributors the docs are unreliable, and it is precisely how the
+misleading note above came to exist — someone's defensively-accumulated setup,
+written down as necessity, never falsified.
+
+### 4. Only now suspect a defect — and make the silence speak
+
+If it compiled, the submodules are present and the feature set matches CI, then
+a failure may be real. The trap at this stage is a layer that *correctly*
+discards detail: a sanitizer, a scrubber, a redactor. The symptom is a generic
+message where a specific one was produced.
+
+Patch the discarding line to print what it drops, run once, and read the
+underlying error. On openhuman#6487 a sanitized
+`hosted agent invocation was rejected by policy` was hiding
+`Validation("agent definition \`harness\` was not found")` — which named the
+defect outright. **Reading seven links of a chain correctly is not the same as
+watching it fire.**
+
+### Why this order
+
+The cheap checks are first because a wrong answer early is invisible later: a
+suite that never compiled reports the same exit code as one that failed, and a
+plausible-but-wrong explanation gets *confirmed* rather than tested, because
+confirming it succeeds. Knowing that features matter is not enough — the rule is
+not applied at the moment of asserting. Running CI's literal command is.
+
+---
+
## When in doubt
- Push the test as low in the layer stack as possible (Rust unit > Rust integration > Vitest > WDIO). Lower layers are faster, more deterministic, and cheaper to run.