Skip to content

test: add the outside-in test taxonomy and its first scenarios - #187

Merged
pgermishuys merged 1 commit into
mainfrom
phase/test-taxonomy
Sep 20, 2026
Merged

pgermishuys merged 1 commit into
mainfrom
phase/test-taxonomy

Conversation

@pgermishuys

Copy link
Copy Markdown
Contributor

Part of #183 — task group 9.

Why

The suite is 187 files, 119,097 lines, 5,630 cases, and overwhelmingly white-box: 144 of 187 files import a deep internal module, across 146 distinct modules. Most internal renames are breaking changes by construction. There was no organising principle a newcomer could navigate, and no way to tell a test guarding a user-visible promise from one pinning an implementation detail.

The taxonomy

User-observable behaviour is tested as a black box through the three surfaces Weave actually exposes:

Bucket Directory Input Output asserted Entry seam
DSL tests/dsl/ .weave source text resolved agents, categories, errors parseConfig → materializeAgents
CLI tests/cli/ argv + virtual filesystem exit code, stdout, stderr run({ argv, terminal, fs })
Adapters tests/adapters/ .weave source text generated harness files adapter ctor + init/spawnSubagent/flush

The adapter bucket is the widest box: .weave in at one end, the plugin files a user would find on disk at the other, with nothing in between asserted directly.

Module-level unit tests stay beside their source in packages/*/src/__tests__/ and keep their existing style. The rule is about where a promise is made: if a user can observe it, it belongs in tests/.

Naming

describe(…) names the situation, it(…) names one promise:

describe("a user turns off the shuttle agent entirely", () => {
  it("removes every category shuttle with it, so no orphaned routes remain", async () => {

versus the shape that dominates today:

describe("toPermissionRules", () => {
  describe("read dimension", () => {
    it("maps allow", () => {

The second tells you which function was called. The first tells you what breaks for a user, and survives that function being renamed, inlined or replaced.

The CLI needed a seam

CliDeps carried no filesystem, so any command driven through run() hit the real disk — there was no way to write a hermetic black-box CLI test at all. fs is now threaded to the handlers that already accept one (validate, init). The remaining five commands follow in task group 13.

Also in here

The category examples in AGENTS.md still showed patterns [...], a key dropped from CategoryConfigSchema in favour of triggers — routing is model-guided, not glob matching. docs/dsl-reference.md was already correct. That stale key is what invalidated the global config which surfaced #185, so it is fixed here rather than left to mislead the next reader.

Review notes

  • 19 scenarios to start, not a migration. Nothing is deleted or moved in this PR; existing tests are untouched.
  • docs/testing-strategy.md carries the full inventory, ten findings, and the remaining plan with per-step status.
  • Two of my assertions in tests/cli/ were written against guessed CLI wording and corrected against real output (File not found, not missing). Worth a glance that the assertions match what the commands actually print.

Verification

  • bun test ./tests: 19 pass, 0 fail
  • bun run test: 6,133 pass, 15 skip, 0 fail
  • bun run typecheck, bun run lint, bun run verify:test-coverage, bun run docs:check-links: pass

🤖 Generated with Claude Code

https://claude.ai/code/session_01DisVZW27sd6Pe7uhbjXNve

An audit of the suite — 187 files, 119,097 lines, 5,630 cases — found it
overwhelmingly white-box: 144 of 187 files import a deep internal module,
across 146 distinct modules, so most internal renames are breaking
changes by construction. There was no organising principle a newcomer
could navigate, and no way to tell a test that guards a user-visible
promise from one that pins an implementation detail.

Introduce `tests/`, where user-observable behaviour is tested as a black
box through the three surfaces Weave actually exposes:

  - `tests/dsl/`      — `.weave` source in, resolved agents and errors out
  - `tests/cli/`      — argv plus a virtual filesystem in, exit code and
                        output out
  - `tests/adapters/` — `.weave` source in, generated harness files out

Each enters through a seam a real caller has and asserts only what a user
can observe, so a refactor that preserves behaviour does not touch them.
`describe(…)` names the situation and `it(…)` names one promise, so a
newcomer can read a file and learn what Weave guarantees. Module-level
unit tests stay beside their source and keep their existing style.

The CLI had no seam to test through: `CliDeps` carried no filesystem, so
any command driven via `run()` hit the real disk. Thread `fs` through to
the handlers that already accept one (`validate`, `init`). The remaining
five commands follow separately.

Also correct the category examples in AGENTS.md, which still showed
`patterns [...]` — a key dropped from CategoryConfigSchema in favour of
`triggers`. Routing is model-guided, not glob matching.

19 scenarios to start. `docs/testing-strategy.md` records the inventory,
the findings behind it, and the remaining plan.

Refs #183 (task group 9)

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DisVZW27sd6Pe7uhbjXNve
Copilot AI lite review requested due to automatic review settings September 20, 2026 15:39
@coderabbitai

coderabbitai Bot commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Next included review available in 11 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 7f10da28-5daf-41fb-90b9-9d1b847c00f9

📥 Commits

Reviewing files that changed from the base of the PR and between 5f3aa78 and 938632f.

⛔ Files ignored due to path filters (4)
  • .codesight/CODESIGHT.md is excluded by !.codesight/**
  • .codesight/coverage.md is excluded by !.codesight/**
  • .codesight/graph.md is excluded by !.codesight/**
  • .codesight/middleware.md is excluded by !.codesight/**
📒 Files selected for processing (12)
  • AGENTS.md
  • biome.json
  • docs/README.md
  • docs/testing-strategy.md
  • package.json
  • packages/cli/src/cli.ts
  • tests/README.md
  • tests/adapters/claude-code.scenario.test.ts
  • tests/cli/validate.scenario.test.ts
  • tests/dsl/category-routing.scenario.test.ts
  • tests/support/scenario.ts
  • tsconfig.json

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pgermishuys
pgermishuys merged commit 163cbf9 into main Sep 20, 2026
7 checks passed
@pgermishuys
pgermishuys deleted the phase/test-taxonomy branch September 20, 2026 15:44

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The new seams still permit real filesystem/process access in CLI paths, and the adapter scenario fails on Windows path separators.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 4 Medium severity

Open (4)
What changed in this PR

Part of #183, this PR establishes Weave’s outside-in test taxonomy and adds initial DSL, CLI, and Claude Code adapter scenarios.

Changes:

  • Adds 19 scenario tests and shared Given/When/Then helpers.
  • Threads injectable filesystem support through CLI validation and initialization.
  • Documents the taxonomy and updates category examples from patterns to triggers.
File Description
tsconfig.json Includes scenario tests in typechecking.
tests/​support/​scenario.ts Adds shared scenario helpers.
tests/​README.md Defines bucket and naming conventions.
tests/​dsl/​category-routing.scenario.test.ts Tests category materialization and conflicts.
tests/​cli/​validate.scenario.test.ts Tests CLI validation behavior with virtual files.
tests/​adapters/​claude-code.scenario.test.ts Tests Claude Code bundle generation.
packages/​cli/​src/​cli.ts Adds injectable filesystem dependencies.
package.json Runs scenarios and lints their files.
docs/​testing-strategy.md Documents inventory and cleanup plan.
docs/​README.md Links the testing strategy.
biome.json Adds tests/ to linting.
AGENTS.md Corrects category routing documentation.
.codesight/​middleware.md Updates generated metadata.
.codesight/​graph.md Updates generated metadata.
.codesight/​coverage.md Updates generated metadata.
.codesight/​CODESIGHT.md Updates generated metadata.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread packages/cli/src/cli.ts
// this router lean and avoid circular deps during init
const { runValidate } = await import("./commands/validate.js");
return runValidate({ terminal, theme, flags });
return runValidate({ terminal, theme, flags, fs });
Comment thread packages/cli/src/cli.ts
case "init": {
const { runInit } = await import("./commands/init.js");
return runInit({ terminal, theme, flags });
return runInit({ terminal, theme, flags, fs });
const flushed = await adapter.flush();
expect(flushed.isOk()).toBe(true);

return written;
Comment thread tests/support/scenario.ts
export async function whenMaterialized(
source: string,
): Promise<MaterializationPlan> {
const result = await materializeAgents({ config: givenConfig(source) });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants