Crashtest docs

Scenario packs (the ONE extension surface)

A pack is a bundle you author once and reuse across run roots: scenario modules (same contract as the built-ins), bundled imports, and - going forward - recipes and target declarations. Zero new concepts to learn: a pack’s scenario modules satisfy the exact same contract the seed libraries do (that contract is now on the site: The Scenario Contract).

One surface, three ways in. Packs used to sit beside two other words (“plugins” via config import specifiers, “presets” via repo scaffolding). Since the unified-surface merge (v0.3, 2026-10) packs are the master surface: a pack can carry files in its own directory AND declare "plugins" imports in its manifest; the config’s plugins: knob is the top-level escape for specifiers that belong to no pack. Presets are not a runtime surface at all - they are a CLI helper that writes a config for an agent-builder export (see Builder Presets). Language-wise: if it has a pack directory, it is a pack; if it is a bare specifier in the config, it is a plugin; if it scaffolds the config, it is a preset.

The schema (pack.json, v1)

{
  "schemaVersion": 1,
  "name": "my-money-pack",
  "description": "one line - what it attacks and how honest its oracles are",
  "version": "0.1.0",
  "entry": "index.js",
  "plugins": ["./bundled-canary.js", "some-npm-shape-pack"],
  "requires": ["wordpress"]
}

entry points at an ESM file under the pack directory whose default export is a scenario module ({ name, description, attacks: [{ name, run }] }). The scenario shape is crashtest’s own profile and loadPacks() enforces it by default. Host faces that carry OTHER entry profiles (the packstruct SPEC section 7 clean case - a manifest-conformant, entry-importable minimal pack of any profile) can defer just the shape check with loadPacks(roots, seen, check, { validateProfile: false }): the manifest contract (schemaVersion/name/description/entry) stays fully enforced, only the scenario-shape validation moves to the host’s own run-time check. The CLI’s run and packs surfaces keep the strict default - byte-identical behavior, never silently weaker.

requires - the ignore mechanism (relevance, not a deny-list)

A pack that only makes sense against a particular kind of target (a WordPress install, a Next.js app, a Vite dev server) can declare that as capability tokens:

{ "name": "wp-roles", "requires": ["wordpress"] }

A run root declares what its target provides:

// crashtest.config.js
export default { provides: ['node', 'cloudflare-pages'], /* ... */ };

The loader then skips any pack whose requires the target does not provide - before import, so the pack costs the run nothing. This is the honest inverse of a deny-list: a deny-list fails open (a newly-shipped pack runs everywhere until someone remembers to deny it), while requires fails closed (a pack that names a capability the target lacks skips itself, forever, with no per-app upkeep). Requires-filtering engages only once the run root declares a non-empty provides; a run root that declares nothing is unchanged. Every shipped target-specific pack already carries its token: wp-* needs wordpress, next-middleware-shapes needs next, vite-dev-shapes needs vite, qs-shapes needs qs.

The escape hatch - ignore and .packignore

Relevance answers “can this target serve it?” The escape hatch answers the rarer “my target could, but I do not want it here” (dev noise, a slow hobbyist run):

// crashtest.config.js - inline
export default { ignore: ['wp-*', 'next-middleware-shapes'], /* ... */ };
# .packignore (run root) - one token per line, # comments, * globs
wp-*
next-middleware-shapes

Tokens match a pack’s name or its origin (public/<name> / local/<name>), with * as the only metacharacter. ignore wins over relevance: an explicit “not here” is never overridden by “the target could serve it”. A skipped pack is always named (packs: skipped wp-roles (unmet-requires) - requires wordpress - target provides node) and rides packs --json and run --module-plan as a skipped row - a skip is never a silent green.

Spec lint (crashtest lint-packs)

When your tree has packs, run the packstruct spec linter over them at author time - the failure classes it catches (bad schemaVersion, name/dir mismatch, missing entry, dotted-version rule) read better at edit time than at first red-team run:

npx crashtest lint-packs [--deep] [--json] [--against <lib>] [dir]
crashtest run --lint-packs        # same lint INSTEAD of the campaign

Pin rules (issue #32):

plugins (optional, bundled imports) - a pack can carry MORE scenario modules than its own files: the manifest lists import specifiers (npm packages, or ESM files the pack itself ships, relative to the pack directory). They load through the same validator as everything else, join the same campaign, and the plan labels carry the pack they came in with (pack:public/your-pack -> plugin:./bundled-canary.js). A self-contained pack can therefore ship its whole attack surface - files plus imports - with zero config wiring by the adopting repo. A broken listing (missing file, wrong shape, name collision) fails the run loudly naming the pack, the same rule as every other surface.

env (optional, binding claims) - the pack TELLS the run root what it needs of the harness instead of every attack hand-probing harness.env and stringing its own skip prose:

{
  "schemaVersion": 1,
  "name": "my-money-pack",
  "description": "one line",
  "env": {
    "d1":    { "DB": { "tables": ["charges", "settings"] } },
    "kv":    { "UPLOADS": {} },
    "routes": ["charge", "profile"],
    "seed": {
      "kv": { "UPLOADS": { "canary": "v1" } },
      "d1": { "DB": { "devices": { "rows": [{ "id": 1, "name": "d0" }] } } }
    }
  }
}

Semantics, pinned the same way everything else is:

public @0.3.1 - my-money-pack: 3 attacks from public/my-money-pack / claims d1[DB: charges, settings], kv[UPLOADS], routes[charge, profile]
         a pack example
         prerequisites UNMET - d1[DB:charges], kv[UPLOADS], route[charge]

Where packs live

packs/
+-- public/          <- tracked: shipped examples + shared packs
|   `-- my-pack/
`-- local/           <- gitignored: machine-private packs
    `-- my-private-pack/

crashtest run discovers BOTH visibility dirs under packs/ at the run root - automatically, with no config changes. Visibility is a privacy convention, not a semantic difference: code in local/ runs exactly like code in public/; only the file location (and the gitignore) changes.

Installing crashtest from npm ships the two reusable shape packs (wp-money-shapes, wp-stock-smoke) as installed files, so the packs: ['node_modules/crashtest/packs'] adoption shape is real, offline, and version-clean. The crashtest-site pack is NOT in the tarball on purpose: it is this repo’s self-dogfood, bound to the OSS checkout’s own web/ tree - vendoring it would blind it. test/packaging.test.js pins the tarball contents either way.

Packs from other repos (the killer feature, spelled out)

A pack does not need to live in the repo under attack. crashtest run discovers packs/ at the run root - the repo whose crashtest.config.js declares the target - and the packs: knob accepts any directory on disk. The natural shapes:

// crashtest.config.js - in the run root, attacking ANOTHER repo's handlers
import { buildRoutes, ENV_SPEC } from '../target-repo/src/app.js';

export default {
  routes: buildRoutes(),
  env: ENV_SPEC,
  packs: [
    './packs',                                          // the run root's own
    '/abs/path/to/prestruct/packs',                     // another repo's packs/ wholesale
    '/abs/path/to/prestruct/packs/public/one-pack',     // one pack dir only
    'node_modules/@you/crashtest-pack',                 // an npm-vendored pack
  ],
};

A self-contained pack makes this even cleaner: because its manifest can bundle its own imports ("plugins"), adopting a pack from another repo is TWO lines in the consuming config - the packs: entry and nothing else. No shims, no config wiring, no copy-paste; the loaded rows still label which pack and repo they came from. Cross-repo name collisions fail the run loudly, the same as everywhere else.

The ROOT-vs-visibility-dir footgun (the packstruct#13 family shape) is closed on this side too: a packs: root whose basename is public/ or local/ refuses LOUDLY (pass the packs ROOT - the parent of public/) instead of silently scanning public/public/ and loading zero packs. The one-pack-dir shape above (a pack.json directly inside) stays legal - that is a named pack, not a visibility dir.

This is how a pack published in its own repo (like a committed packs/public/ in the prestruct repo) gets consumed: point the consuming run root’s packs: at that repo’s checkout - or, in CI, at the installed npm package. The pack lives where the pack work lives; the attacks run where the target code is.

The naming decision, so it doesn’t come as a surprise: crashtest deliberately does not use vant’s models/public + models/private layout. “Models” carries an AI/ML meaning in this ecosystem’s vocabulary; “pack” is already crashtest’s own word (scenario pack), and public/local names the git reality directly - tracked vs machine-private.

Natural extension points

Naming convention

Pack names are kebab-case, and the prefix names the surface the pack speaks, not the product that inspired it:

What “money” means here: the dollar-shaped abuse family. The same family the built-in volume library already covers (credential-stuffing, storage-fill, cost-amplification) - attacks whose payoff is value: an anonymous write with payment intent must not stick (write-volley), one paid receipt must not buy a second registration (txn-replay), a metered wall must trip under rapid floods (gate-burst). “Shapes” = engines, not instances: every name (CPTs, meta keys, actions) is injected from the target’s moduleCtx[<pack-name>], so one pack serves every plugin and the khf/fm-specific lore stays in their private instantiations.

Public vs local - the decision rule

So: no packs/public/vant-* branded by target. Vant’s generic surface is already covered by the built-in libraries (the raw-node run-root recipe landed 13/13 REFUSED with zero custom code), and anything vant-specific

Config knobs

// crashtest.config.js
export default {
  packs: true,       // default - discover packs/public/ + packs/local/
  // packs: false,   // opt out entirely (the dogfood does: shipped packs
  //                 //   which need their own worker must not join the demo)
  // packs: ['/abs/path', 'node_modules/@you/crashtest-pack'],

  // The ignore mechanism (relevance + escape hatch):
  provides: ['node', 'cloudflare-pages'],  // what THIS target is; packs whose
  //                                        //   `requires` is unmet skip
  ignore: ['wp-*'],                        // explicit "not here" (wins over
  //                                        //   relevance); also a .packignore file
};

Name collisions between a pack and the built-in libraries (or another pack) fail the run loudly - one name, one attack, no ambiguity.

Inventory any run root with:

npx crashtest packs
# local @0.0.1 - vant-core: 1 attacks from local/vant-core / armedBy moduleCtx['vant-core']
#         TODO: one line on what vant-core attacks

npx crashtest packs add vant-core          # -> packs/local/vant-core/ (gitignored)
npx crashtest packs add my-shapes --public # -> packs/public/my-shapes/ (tracked)
npx crashtest packs --json                 # machine inventory (LAST stdout line) - pair with `npm view <pkg> version` in CI for version joins

Family lanes (receipts, not asks)

The packstruct@1 grammar is shared with the wider struct family, and this repo’s lint lane is where the family’s staged packs get grating receipts (files-on-disk, no runtime dependency, exact-pin receipt):

Citation rule for every row here: the receipt’s citation names the source the lane ACTUALLY read - a live repo pin for shipped family members. Same-commit->same-findings applies to receipts too.