# Testing and publishing

A plugin is tested as Blossom runs it — built for WebAssembly, loaded by the real host, asked with the scope the test grants — and it is published by merging it.

![Signed static catalog publishing and verification pipeline](/docs/catalog.jpg)

## Test it through the host

```sh
bun run test                        # every plugin of the workspace
cargo test --package blossom-tides  # one plugin
```

`blossom-harness` loads a plugin with a home folder of the test, a `Recorded` network that never reaches the internet, and a clock that stands still until the test moves it. One test of every plugin runs the battery:

```rust
#[test]
fn it_keeps_the_rules_every_plugin_keeps() {
    blossom_harness::conforms("blossom-tides");
}
```

It fails with the list of what the plugin broke:

- **Without a grant** it reaches nothing and says what it is missing.
- **With a grant** it stays inside it: no host the manifest does not list, no post to a host it does not name in `sends`.
- **Hostile input** leaves it answering: a file too large or outside the folder, a link out of it, broken JSON, a server that hangs, text that reorders itself.
- **A token** never shows and never travels anywhere but in the header Blossom adds.

> [!NOTE]
> The battery knows nothing of what your plugin should show. Test that yourself, on fixtures read once from the real service.

## Install it locally

```sh
cargo build --package blossom-tides --target wasm32-unknown-unknown --release
```

Open settings with <kbd>⌘</kbd> <kbd>,</kbd>, choose **Plugins**, then **Add plugin**, and pick `target/wasm32-unknown-unknown/release/blossom_tides.wasm`, or `build/<name>.js` for a plugin in JavaScript. Blossom checks the module, copies it into its folder of plugins and turns it on; turn on its network or its files next to what it lists.

## Publish it

A plugin joins this repository through a pull request that adds its folder under `plugins/`, its entry in the index and its row in `plugins/README.md`:

```sh
bun run index            # writes both from what the plugin tells the host
bun run index -- --check # checks them without writing
```

1. **You** open the pull request with the source, the README, the tests and the battery.
2. **Continuous integration** builds, lints and tests it, and its job `catalog` compares it with what is published.
3. **The maintainer** reviews what a machine cannot see — what it sends, what it shows, how narrow its grants are — and merges it.
4. **Merging is publishing.** The workflow builds the version from `main`, signs the index and deploys it to the catalog on GitHub Pages.

> [!WARNING]
> **A published version is kept, never rebuilt.** A change to the folder of a plugin already published raises `version` in its `Cargo.toml`, or in its `package.json` for a plugin in AssemblyScript or JavaScript; its `README.md` aside. A change to an SDK or to the core raises no version.

> [!TIP]
> There are no accounts and no upload of a module: what users download is always built from the code merged in `main`.
