Skip to content
Kavachकवच

Workspaces

● Intermediate3 minBefore this: PackagesSpec 10.14

A workspace is several packages in one repository, checked, tested and built together, with one lock for all of them.

The kavach.toml at the repository's root lists the members. packages/* is every folder in packages/ that has a kavach.toml:

[workspace]
members = ["packages/*"]
kavach.toml: TOML code
/// The price of `qty` pens, in cents.
pub fn pens(qty: Int) -> Int
    require qty >= 0 and qty <= 1_000_000
    example pens(3) == 30
{
    qty * 10
}
packages/prices/src/lib.kav: Kavach code
[package]
name = "shop"
version = "0.1.0"
edition = "2026"

[dependencies]
prices = { path = "../prices" }
packages/shop/kavach.toml: TOML code
use prices

fn main() {
    print("4 pens cost {prices.pens(4)} cents")
}
packages/shop/src/main.kav: Kavach code

At the root, with no file, kavach check, kavach test and kavach build run on every member, and say which member each line is about. pens is tested from its example and from 200 generated inputs that keep its require:

terminal
kavach check
== packages/prices
src/lib.kav: no errors
== packages/shop
src/main.kav: no errors
kavach test --seed 7
== packages/prices
✓ pens: example pens(3) == 30
1 passed, 0 failed
seed 7
✓ pens  200 cases
1 functions   1 ✓   0 ✗   0 weakly tested
== packages/shop
0 passed, 0 failed
seed 7
0 functions   0 ✓   0 ✗   0 weakly tested
kavach run packages/shop/src/main.kav
4 pens cost 40 cents
  • Members run in the order members lists them, and the command fails when any member fails. In a member's folder, a command runs on that member alone.
  • Members use each other by path, as any package does: prices = { path = "../prices" }.
  • kavach test runs a package's own tests only: shop uses prices, but doesn't test pens again.
  • Every member's git dependencies are fetched once, into the root's kavach_modules/, and recorded in the root's kavach.lock, so all members use the same commit of each.
  • A member's settings ([build], [test], [env]) are its own. The root may be a package too, with a [package] of its own.
  • A package in a folder of a git repository is named with dir: router = { git = "https://…", dir = "packages/router" }.
rath/
  kavach.toml          # [workspace]: no [package] needed
  kavach.lock          # one for the whole workspace
  kavach_modules/      # one for the whole workspace
  packages/
    router/            # a member: its own kavach.toml and src/
    sessions/
  tools/cli/
my-repo/: Text code