docs(chord): testing a plugin alone

This commit is contained in:
Mario Zechner 2026-11-02 10:26:25 +00:00
parent 95e2015f3b
commit 7edaa131dd
2 changed files with 13 additions and 0 deletions

View file

@ -2212,6 +2212,17 @@ validation and copies the v2 kernel added around Delta.
(host packages), no other files and no contract files for others; it may serve objects, define contracts for
itself inline and contribute to registries. When it needs more, it becomes a directory with the same name, which a
reload treats as the same plugin. The watcher's `set` mark covers files appearing and disappearing at a root's top.
- **Testing a plugin alone (owner, 2026-11-01: "let's do that"; plugin model point 6):** `testPlugin(dir, { kind,
modules, stubs, start?, principal? }, ctx)` builds the plugin as production does and loads it on an in-memory host
of that kind with an in-memory store. A plugin depends on four things, each answered without a mocking framework:
the app's API and Chord are the real modules (definitions only); other plugins' and core objects are reached
through contracts, so the test passes stubs, ordinary facets serving those contracts with fake data; registries
the plugin contributes to are served by the helper, which collects the contributions for the test to read (a
registry it reads gets fake entries from a stub); process values come as fake start data. The result is a live host:
the test gets the plugin's objects, calls them, watches their state, and acts as any principal. A contract no stub
serves leaves its requests waiting `not_served`; the helper lists those names, so the test says what to stub.
Several hosts at once (a server plugin calling a worker) is a later, larger helper over memory links; the app kit
may ship stubs for its core contracts.
- **A plugin's npm dependencies are bundled; external only by opt-in (owner, 2026-10-29: "explicit opt in + (a)"):**
a plugin's `dependencies` are installed into its own `node_modules` (`npm install --ignore-scripts`) and bundled into
each facet that imports them (host packages, its `peerDependencies`, stay external and are passed in). On Node a

View file

@ -194,6 +194,8 @@ deleted (the slice's spec and code are the record). Moved here from `carry-over.
skill and documentation for agents on a plugin's layout and build.
- **Single-file plugins** (decision "Single-file plugins"): discovery of `<name>.<kind>.ts(x)` files, grouped by
name; their import rule; the watcher's `set` for them.
- **`testPlugin`** (decision "Testing a plugin alone"): stub facets, collected contributions, the list of contracts
nobody serves.
### After slice 11