npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@mmmnt/feat-runtime

v0.10.0

Published

What generated tests import: loadConfig, config-driven adapter loading (createAdapter contract), lifecycle/capture orchestration, precondition executor, toMatchPrediction. Deps: feat-types + Ajv only (ADR-0001).

Readme

@mmmnt/feat-runtime

The library every generated Feature test imports. It loads and validates feat.config.json, loads adapters, and runs each case as one fixed choreography: reset, preconditions, a capture window, the stimulus, a consistency-aware sweep, and a prediction diff. A failure names the exact spec coordinate it came from. If something was captured and not predicted, the case fails.

It is deliberately light, because it rides in every consumer's test process. Its dependencies are @mmmnt/feat-types, Ajv and ajv-formats.

Where it sits

generated test (feat-emit-ts)  --imports-->  feat-runtime  --loads-->  adapters (createAdapter)
         ^                                        |
   run by feat-runner (vitest)           loadConfig, createHarness, matcher

Most users never import it. feat generate writes test files whose only Feature import is this package, and feat run runs them. Depend on it directly when you:

  • load and validate a config the way Feature does (loadConfig), in a tool or a CI check;
  • write an adapter or a spec host and want its contract and refusal codes in front of you;
  • drive the harness from your own test code (createHarness, runCase);
  • reuse the prediction matcher.

A generated suite also needs vitest.

Install

npm install @mmmnt/feat-runtime
  • Node 20 or later. The package is ESM only.
  • Adapters named in your config are installed in your project, not here (npm install @mmmnt/feat-adapter-memory, for example). The runtime resolves them from your project root.

Use

A harness over a config with a response adapter and one service. AddItem is routed by the config; the stubs here stand in for your adapters.

import { createHarness, HarnessConfigurationError, type HarnessCase } from "@mmmnt/feat-runtime";

const h = await createHarness({ configPath: "feat.config.json", specPath: "specs/add-item.feat" });

const addItem: HarnessCase = {
  anchor: 'SPEC-ITM-001 › "adds"',
  name: "adds",
  when: { command: "AddItem", payload: { itemId: "a-1" } },
  prediction: {
    type: "success",
    response: { status: 201, schemaName: "AddResponse" },
    services: {
      store: {
        records: [{ type: "ItemAdded", schemaName: "ItemEvent", valueBlock: { itemId: { matcher: "whenRef", path: "itemId" } } }],
      },
    },
  },
};
const inline = { schemas: { AddResponse: { type: "object" }, ItemEvent: { type: "object" } }, goldens: {} };

try {
  await h.runCase(addItem, inline); // resolves when every prediction holds
} catch (e) {
  // A refused configuration carries a code; a violated prediction is a PredictionViolation.
  if (e instanceof HarnessConfigurationError) console.error(e.code, e.service, e.message);
  else throw e;
} finally {
  await h.teardown();
}

A generated test does exactly this: createHarness in beforeAll, h.runCase(c, INLINE) in each it, h.teardown() in afterAll.

What a case does

runCase runs these steps in order. The order is part of the contract.

One harness runs one case at a time (SPEC-RT-007). Starting a case supersedes any case still running on that harness, which happens when a test runner gives up on a case (its test timed out) while the case's invoke or convergence wait has not returned. The superseded case makes no adapter call after the next case has started: at its next call it rejects with CaseSupersededError (CASE_SUPERSEDED), naming both anchors. A call already in flight finishes on its own. The next case runs as if the superseded one had never started.

  1. Preflight, before any adapter is called. A case that asks for something its adapters cannot give is refused here: CLOCK_UNSUPPORTED, then for each fault FAULT_UNSUPPORTED and FAULT_REQUIRES_SERIAL, then MODE_UNSUPPORTED.
  2. Variables. The spec's variables: table resolves once for the case (see below).
  3. Reset. reset() on every service, in config order.
  4. Clock. setClock(clock) to the response adapter, then to each service adapter that has one. clock is the case's given.clock, or null, on every case.
  5. Seeds and executes, in written order (SPEC-RT-009, ADR-0025). given.order lists the kinds as the spec wrote them: a "seed" calls seed(records) on the next seed's service, an "execute" runs the next given.executes entry through the response adapter. Without given.order (a given of one kind, or an IR an earlier parser wrote) every seed runs, then every execute. A string @given.response.<path> in a later payload reads the most recent execute's response body. An order that does not name each seed and each execute once is refused in the preflight with an Error naming the anchor.
  6. Faults. Each given.faults entry is armed with fault({ operation, fault, detail, times }), in written order. Arming is never a captured effect.
  7. Capture window. startCapture({ specType }) on every service.
  8. Stimulus. The when through the response adapter, then each delivers to its service. The response adapter's namespace is checked right after the invoke.
  9. Convergence. The harness waits for eventual services (below).
  10. Capture. stopCapture() on every service.
  11. Fault consumption. For a service with firedFaults(), an armed fault that fired fewer times than armed adds a FAULT_NOT_CONSUMED violation.
  12. Diff. The response, then each service's records (has) and contains. Every violation is collected, and the case throws one PredictionViolation listing them all.

Configuration

loadConfig({ path }) reads and validates a config file. A bad config does not throw. It resolves { status, body }:

import { loadConfig } from "@mmmnt/feat-runtime";

const r = await loadConfig({ path: "feat.integration.config.json" }); // path is relative to the cwd
if (r.status === "ERR") console.error(r.body.code, r.body.message, r.body.detail);
else console.log(r.body.environment); // the merged, validated config

On success body is the validated config. On failure body is { code, message, ...extra }, with the codes in the table below. Validation is Ajv, draft-07, against the schema this package bundles.

The config file

A minimal feat.config.json. schemas, services and specs are required; no unknown top-level key is allowed.

{
  "featVersion": "1.0",
  "environment": "spec",
  "schemas": { "adapter": "@mmmnt/feat-schema-json" },
  "response": {
    "adapter": "@mmmnt/feat-adapter-handler",
    "commands": { "AddItem": { "module": "src/add-item.ts", "export": "addItem" } }
  },
  "services": {
    "store": { "adapter": "@mmmnt/feat-adapter-memory", "consistency": "strong" }
  },
  "specs": {
    "dir": "specs",
    "pattern": "**/*.feat",
    "contractPattern": "**/*.contract.json",
    "outputPattern": "{name}.test.ts"
  },
  "report": { "format": ["console", "junit"], "junitOutput": "reports/feat-junit.xml" }
}

| Key | Meaning | | --- | --- | | featVersion | Language version, major.minor. | | extends | Makes this file a tier overlay of the named base. See below. | | environment | Names the environment this config verifies, lower case with hyphens. Stamped into evidence. Not part of generation. | | schemas.adapter | The schema adapter, a package name or a path. | | response | adapter, invoke (adapter-wide options), commands (name to routing), actors. Required only when specs use when: or execute. | | services.<key> | adapter, consistency (acid, strong or eventual), convergenceTimeout (ms), absenceTimeout (ms), options. | | specs | dir, pattern, contractPattern, outputPattern, and optionally exclude (globs relative to dir). | | report | format (console and junit) and junitOutput. |

consistency: "eventual" requires convergenceTimeout, or the load fails with MISSING_CONVERGENCE_TIMEOUT. The schema also accepts absenceTimeout, and the evidence bundle records it. The harness does not read it. A route under response.commands.<Name> may carry "namespace": true to declare that its handler reads ctx.namespace.

An adapter specifier is a package name or a path. A specifier that starts with . or / resolves against the directory of the config file you pass to createHarness. Any other specifier resolves from that directory's package.json, never from the toolchain's own node_modules: the project owns its adapters. An adapter module exports createAdapter(config), as a named export or on its default export.

Tier overlays (extends, SPEC-RT-004, ADR-0024)

One set of specs runs at more than one tier: in-process and in-memory, then against real products. An overlay is a config file with extends that replaces what differs.

{
  "extends": "./feat.config.json",
  "environment": "integration",
  "services": {
    "store": {
      "adapter": "@mmmnt/feat-adapter-kurrent",
      "consistency": "eventual",
      "convergenceTimeout": 5000,
      "options": { "connectionStringEnv": "FEAT_KURRENT_URL" }
    }
  }
}

The rules:

  • The base path is relative to the overlay. The base is read and validated as an ordinary config.
  • One level only. A base that itself has extends, or a file that extends itself, is EXTENDS_CHAIN.
  • environment, response, specs and report are replaced whole when the overlay has them. services.<key> is replaced whole for each key the overlay names. Every other service is the base's. Nothing is deep-merged, so one product's options never leak into another's.
  • environment is not inherited. An overlay without one has none and resolves it at run time.
  • featVersion and schemas are inherited, and an overlay may not redeclare them.
  • The closed spaces must match. An overlay may not add a service key, and may not add or remove a command name or an actor name (TIER_SPACE_MISMATCH). Since an unnamed service is inherited, an overlay cannot remove one either.
  • The merged document is what the schema validates, so an overlay file alone need not carry schemas, services or specs. The result keeps extends, so a consumer can tell an overlay.

A spec means the same thing in both tiers by construction, and drift is a load error.

Environment

function resolveEnvironment(config: { environment?: string }): string;

Returns config.environment when set, else FEAT_ENVIRONMENT, else ENVIRONMENT. With none of the three it throws a HarnessConfigurationError with code NO_ENVIRONMENT: Configuration error (exit 2): [NO_ENVIRONMENT] No environment declared — set ENVIRONMENT or FEAT_ENVIRONMENT, or pin config.environment.

variablesSidecarPath(projectRoot, configPath) returns <projectRoot>/.feature/run/<config file name without .json>-variables.jsonl, where the harness records each case's resolved variables.

Namespaces (SPEC-RT-006)

Two spec files run in parallel against one product must not see each other's data. So the harness derives one namespace per spec file, from the file's path alone:

namespace = "s" + the first 12 hex characters of sha256(path)

The path is relative to the config directory, with / separators, no leading ./, and case kept. It always matches NAMESPACE_PATTERN, /^s[0-9a-f]{12}$/. For example adapters/kurrent/observe.feat gives s0599e33863c1, whether you write it with /, with \, or as an absolute path under the config directory.

import { deriveNamespace } from "@mmmnt/feat-runtime";

deriveNamespace("adapters/kurrent/observe.feat", "/path/to/config/dir"); // "s0599e33863c1"

When createHarness gets a specPath, it:

  • derives the namespace once and keeps it for the whole file, so reset() never changes it;
  • creates the response adapter and every service adapter with createAdapter({ ...config, namespace }), namespace being a top-level key beside options;
  • sets process.env.FEAT_NAMESPACE for the file, and restores the prior value on teardown;
  • asks any adapter that implements reportedNamespace() to report the namespace it runs under. A service adapter is asked at setup. The response adapter is asked after each case's invoke and before any prediction is compared, because an in-process handler can only report it once it has read it. A report that differs from the delivered one is NAMESPACE_NOT_HONOURED. A host that ignores its namespace writes outside it, and an absence prediction would pass while the system misbehaves, so the check is not optional.

Without specPath there is no namespace.

Namespaces isolate data, not availability. A fault that takes a product away from every file is exclusive and runs in the runner's serial pass.

assertNoNamespaceCollision(specPaths, configDir) checks a whole run's spec set. Two files that derive one namespace throw NAMESPACE_COLLISION. feat run calls it before any file starts. assertNamespaceNotConfigured(config, configPath) refuses a namespace key written in the response config or in a service's options (NAMESPACE_CONFIGURED), because a configured value is shared by every file. createHarness calls it on the merged config, after loadConfig's own checks.

Faults (SPEC-RT-003, SPEC-RT-005, ADR-0023)

A fault is a precondition, never an assertion. A spec writes fault <service> <Operation> <Fault> [{ detail }] [once | times <n> | until reset] in given:, and predicts what the system does about it with the ordinary predict forms.

An adapter declares what it can produce in a catalog: operation, then fault, then the counts that fault accepts.

faults: {
  Append: { WrongVersion: ["once", "times"], AccessDenied: ["reset"] },
  Connection: { Timeout: ["reset"] },
}

once, times and reset are the counts. times covers every n. The earlier shape, an array of fault names per operation ({ Append: ["WrongVersion"] }), is still accepted and declares all three counts. A case's once is times 1: it counts as once when the fault declares it, otherwise as times.

At preflight, each fault of the case must pass faultProblem(adapter, fault). It returns the reason the adapter cannot arm it, or undefined:

| Reason in the message | Cause | | --- | --- | | service '<s>' is not configured | The fault names a service not in the config. | | has no fault() method | The adapter implements no fault(). | | cannot carry a fault detail to the product | The fault has a detail and acceptsFaultDetail is false. | | offers no operation '<op>' (offers: ...) | The operation is not in the catalog. | | offers no fault '<f>' under '<op>' (offers: ...) | The fault is not under that operation. | | declares only <counts>, not <count> | The fault does not declare the count the case writes. |

Any of these refuses the case as FAULT_UNSUPPORTED, before the case has any effect.

A fault is armed after every seed and given.executes entry, so setup never consumes it, and before the capture window opens, so arming is never a captured effect. After stopCapture(), for each service that was armed and has firedFaults(), a fault armed times n must have fired n times, and one armed until reset at least once. Otherwise the case gets the violation FAULT_NOT_CONSUMED: <anchor> › <service>: fault <Operation>/<Fault> armed for <n> call(s), consumed <m>. A service without firedFaults() is not checked. Adapters must disarm every fault in reset().

A fault named in EXCLUSIVE_FAULTS from @mmmnt/feat-types (today BrokerLoss) is refused with FAULT_REQUIRES_SERIAL unless process.env.FEAT_SERIAL is 1. feat run sets it only in the serial pass (see @mmmnt/feat-runner).

Clock and observation modes (SPEC-RT-002, ADR-0023)

Clock. A case with clock at needs a response adapter with setClock(). If there is no response adapter, at least one service adapter must have it. Otherwise: CLOCK_UNSUPPORTED. A service adapter without setClock is never refused, it is simply not called. The clock reaches every adapter that has the hook on every case, after the resets, as an ISO-8601 instant with a zone designator or null, so one case's frozen clock never leaks into the next.

Modes. has is the diff mode and contains the state mode. Every adapter serves diff, through stopCapture(). State is optional. An adapter declares observes: { diff: "native" | "snapshot", state: boolean }. One that declares nothing is { diff: "native", state: true }. A prediction with contains on a service whose observes.state is false is refused as MODE_UNSUPPORTED, with mode set to "state".

For contains, the harness calls read({ expect }). expect has one entry per predicted record: its type, and as key its top-level fields whose matcher is a literal or an @when reference. This is a hint. The adapter may narrow its read, may answer more, never fewer.

The adapter contract

The harness drives the interfaces in @mmmnt/feat-types. A service adapter, in outline:

import type { CapturedRecord, FaultArm, FaultFiring, FeatServiceAdapter } from "@mmmnt/feat-types";

export function createAdapter(cfg: { key: string; namespace?: string }): FeatServiceAdapter {
  let captured: CapturedRecord[] = [];
  let armed: FaultArm[] = [];
  const fired: FaultFiring[] = [];
  return {
    // operation -> fault -> the counts it accepts
    faults: { Append: { WrongVersion: ["once", "times"], AccessDenied: ["reset"] } },
    observes: { diff: "native", state: true },
    async setup() {},
    async teardown() {},
    async reset() {
      captured = [];
      armed = []; // reset() MUST disarm every fault
      fired.length = 0;
    },
    async fault(arm) {
      armed.push(arm);
    },
    async firedFaults() {
      return [...fired];
    },
    async startCapture(context) {
      captured = [];
      void context?.specType; // "query" | "command" | ...
    },
    async stopCapture() {
      return captured;
    },
    async read(query) {
      void query.expect; // a hint: answer at least these, never fewer
      return captured;
    },
    async reportedNamespace() {
      return cfg.namespace;
    },
  };
}

Required: setup, teardown, reset, startCapture, stopCapture, read. Optional: seed, deliver, setClock, faults with fault and firedFaults, observes, reportedNamespace, peekCapture and settle (below). A response adapter has setup(config), teardown(), invoke(command, input, actor?) and optionally setClock and reportedNamespace.

createAdapter receives, for a service, { key, ...serviceConfig, projectRoot, namespace? }, and for the response adapter { ...responseConfig, projectRoot, namespace? }. The response adapter's setup gets response.invoke ?? {}. importAdapter(specifier, projectRoot) is the one door every adapter comes through, so resolution and failure messages are the same everywhere.

Convergence

After the stimulus, the harness decides when to stop capturing. It considers only services that the prediction names and whose consistency is eventual. The window never exceeds the largest of their convergenceTimeout.

| Mode | When | Ends | | --- | --- | --- | | none | No eventual service in the prediction. | At once. | | fence | Every such service has settle() and every one vouches true before the ceiling. | On proof. Absence predictions included. | | peek | Every such service predicts records, no contains, and has peekCapture(). | When each target count has arrived and the capture went quiet for one more poll (150 ms). | | ceiling | Anything else, including absence without a fence. | After the full convergenceTimeout. |

Set FEAT_FENCE_AUDIT to any value to check a fence against the clock it replaces: the harness waits out the ceiling anyway and throws if the capture grew after settle() vouched.

The default ordering of has is the active tier's: unordered (a multiset) for an eventual service, ordered (a sequence) for any other. A spec's has ordered or has unordered overrides it.

The prediction matcher

import { applyMatcher, applyValueBlock, diffRecords, diffResponse } from "@mmmnt/feat-runtime";

All four are pure. They append violation strings to an array you pass and never throw.

A record matches a prediction when the types are equal, the captured payload validates against the predicted schema (inlined at generate time), and then the payload equals the golden fixture or satisfies the value block. Ajv compiles each schema once, in the dialect its $schema names (draft-07 by default, 2020-12 when it says so).

import { applyValueBlock, diffRecords } from "@mmmnt/feat-runtime";
import type { InlineData, MatchContext } from "@mmmnt/feat-runtime";
import type { CapturedRecord, PredictedRecord } from "@mmmnt/feat-types";

const inline: InlineData = { schemas: { ItemEvent: { type: "object", required: ["itemId"] } }, goldens: {} };
const ctx: MatchContext = { when: { itemId: "a-1" }, inline };

const captured: CapturedRecord[] = [
  { type: "ItemAdded", payload: { itemId: "a-1" }, timestamp: 1 },
  { type: "ItemAdded", payload: { itemId: "zzz" }, timestamp: 2 },
];
const predicted: PredictedRecord[] = [
  { type: "ItemAdded", schemaName: "ItemEvent", valueBlock: { itemId: { matcher: "whenRef", path: "itemId" } } },
];

const violations: string[] = [];
diffRecords(captured, predicted, "unordered", ctx, "SPEC-X › row", violations);
console.log(violations); // [ 'SPEC-X › row: UNPREDICTED record ItemAdded' ]

const out: string[] = [];
applyValueBlock({ id: "nope" }, { id: { matcher: "any", ofType: "uuid" } }, ctx, "response", out);
console.log(out); // [ 'response › id: expected any uuid, got "nope"' ]
  • diffRecords(captured, predicted, ordering, ctx, anchor, out): ordered compares position by position. unordered pairs each predicted record with a distinct captured one (a multiset). Leftovers are reported as UNPREDICTED record <type> and gaps as MISSING predicted record <type>.
  • diffResponse(actual, predicted, ctx, anchor, out): status, then schema, then golden or value block.
  • applyValueBlock(actual, block, ctx, anchor, out) and applyMatcher(actual, present, matcher, ctx, anchor, out): one value block, or one matcher.

Matchers: literal, whenRef (@when.<path>), deliverRef (@deliver.<path>), captureRef (@<service>[i].<path>, a value captured on another surface), any (optionally uuid, timestamp, string, number or boolean), regex, absent, goldenFixture, nested (exact from 0.10.0: an undeclared key of its object is UNPREDICTED, ADR-0039), not, f32Digest, list and object. @when and @deliver equal the values actually sent, after @given.response.* resolved. A captureRef whose service captured nothing, or whose index is out of range, is a violation, never a pass. A placeholder matcher that reaches the runtime is a violation too: derive should have replaced it.

not (SPEC-RT-011, ADR-0027) passes when the field is present and its operand fails on the value. An absent field is a violation, whatever the operand. A reference operand that cannot resolve (a service that captured nothing, an index out of range, a path absent from the when: payload, the delivered stimulus or the captured record) is a violation too, never a pass, and so is an operand the language refuses (absent, not, nested, goldenFixture, f32Digest, list, object, any without a type) found in an IR. A violation names the operand as written and, for a reference, the value it resolved to: expected not @log[0].cycleId (= "c-1"), got "c-1".

f32Digest (SPEC-RT-014, ADR-0030) passes when the field is an array of exactly dims numbers, each exactly an f32 (Math.fround(x) === x), whose consecutive little-endian f32 bytes hash (sha256, lowercase hex) to sha256. The first failing check is the one violation: absent, not an array of numbers, a wrong length, a value that is not an f32 (it is never hashed rounded), a differing digest (both shown in full). An IR whose dims is not a positive integer or whose sha256 is not 64 lowercase hex is a violation, never a pass.

list (SPEC-RT-015, ADR-0034) passes when the field is an array of exactly as many items as the list holds and each item, in order, passes its matcher; a value that is not an array, or one of another length, is one violation and no item is checked (expected a list of 2 item(s), got 3). object, an object inside such a list, is exact: each declared field passes its matcher and a key that is not declared is a violation (a[0]: UNPREDICTED field 'size' = 120). Violations name the index and field (a[1] › text: expected any string, got 42). An IR list without items, an absent item, or an object without fields is a violation, never a pass.

contains is a subset check against read(): every predicted record must match a distinct state record, and extra state is not a violation. Exclusivity belongs to has.

Variables and given references

resolveVariables(vars, frozenClock?) resolves a case's variables: table once, and substituteVariables(value, resolved) replaces every ${name} of a declared name through a value tree. A variable is now() (epoch milliseconds), iso() (an ISO-8601 string), unique(), a number, or a template of strings and other variables. now and iso take an offset and honour a frozen scenario clock, so a frozen clock stays fully deterministic. Resolved values are appended to the sidecar from variablesSidecarPath.

import { resolveVariables, substituteVariables } from "@mmmnt/feat-runtime";

const vars = resolveVariables(
  [
    { name: "when", type: "string", definition: { kind: "call", fn: "iso", offsetMs: 60_000 } },
    { name: "label", type: "string", definition: { kind: "template", parts: ["order-", { ref: "when" }] } },
  ],
  "2026-07-16T00:00:00Z",
);
substituteVariables({ note: "${label}" }, vars); // { note: "order-2026-07-16T00:01:00.000Z" }

A string that is exactly @given.response.<path> in a payload is replaced by that path of the most recent execute's response body. An unresolvable reference fails the case loudly, naming the anchor.

Errors and refusals

loadConfig: the ERR body

| Code | When | Extra fields | | --- | --- | --- | | CONFIG_NOT_FOUND | No file at the path. | path | | INVALID_CONFIG | The file is not valid JSON. The merged document violates the schema, and detail names the first failing path and the allowed values. A base config violates the schema, or is unreadable. An overlay redeclares featVersion or schemas. | detail |

loadConfig raises none of these as an exception. createHarness does: it throws a HarnessConfigurationError carrying the same code (see below), and importAdapter raises INVALID_CONFIG when a module named as an adapter cannot be used. | MISSING_CONVERGENCE_TIMEOUT | A service is eventual and has no convergenceTimeout. For an overlay, the merged service. | detail: the service key | | EXTENDS_NOT_FOUND | The base file does not exist. | detail names the path as written and as resolved | | EXTENDS_CHAIN | The base itself has extends, or the file extends itself. | detail names both files | | TIER_SPACE_MISMATCH | An overlay adds a service, or adds or removes a command or an actor. | space (service, command or actor), change (added or removed), detail: the name |

HarnessConfigurationError

A subclass of Error with code, detail (the message without its prefix), and service and mode where they apply. Its message is Configuration error (exit 2): [CODE] <detail>, so the runner's output shows the code. Each is raised before the case has any effect. None is a silent pass.

| Code | When it fires | Raised at | | --- | --- | --- | | CLOCK_UNSUPPORTED | A case has clock at and no adapter that could receive it has setClock(). | Preflight | | MODE_UNSUPPORTED | A prediction has contains on a service whose observes.state is false. mode is "state". | Preflight | | FAULT_UNSUPPORTED | A fault names an unconfigured service, an operation or fault the adapter does not offer, an adapter with no fault(), a detail the adapter cannot carry, or a count the fault does not declare. | Preflight | | FAULT_REQUIRES_SERIAL | A case arms an exclusive fault and FEAT_SERIAL is not 1. | Preflight | | NAMESPACE_COLLISION | Two spec files of one run derive one namespace. | assertNoNamespaceCollision, before any file starts | | NAMESPACE_NOT_HONOURED | An adapter reports a namespace other than the one delivered, or none. | A service adapter at setup. The response adapter after the invoke. | | NAMESPACE_CONFIGURED | The response config or a service's options carries a namespace key. | createHarness, after the config loads | | SEED_UNSUPPORTED | A case seeds a service whose adapter has no seed(). service is set. | The case, before it runs | | DELIVER_UNSUPPORTED | A case delivers an event to a target that has no deliver(): a service whose adapter lacks it, or to response when the response adapter lacks it or none is configured (ADR-0036). service is the target. | The case, before the capture window closes | | NO_ENVIRONMENT | resolveEnvironment finds neither config.environment, FEAT_ENVIRONMENT nor ENVIRONMENT. | resolveEnvironment | | INVALID_CONFIG | A module named as an adapter cannot be resolved, cannot be loaded, or exports no createAdapter. | importAdapter | | ROUTE_UNLOADABLE | The response adapter's setup() threw an error with this code: a route the file invokes cannot be loaded (SPEC-RT-008, SPEC-ADPHND-003). The message is the adapter's. | createHarness, at the response adapter's setup | | CONFIG_NOT_FOUND, INVALID_CONFIG, MISSING_CONVERGENCE_TIMEOUT, EXTENDS_NOT_FOUND, EXTENDS_CHAIN, TIER_SPACE_MISMATCH | The config createHarness was given is refused by loadConfig. The message is the loader's message, then its detail. | createHarness, first |

Example message:

Configuration error (exit 2): [FAULT_UNSUPPORTED] SPEC-ITM-001 › "adds": fault store Append Timeout: the adapter for 'store' offers no fault 'Timeout' under 'Append' (offers: WrongVersion).

Other failures

| Failure | Shape | | --- | --- | | A prediction does not hold | PredictionViolation, with violations: string[]. Its message is Prediction violated: and one line per violation, each starting with the case anchor. | | An armed fault was never consumed | A FAULT_NOT_CONSUMED: line inside that PredictionViolation. | | A case needs what the config lacks | A plain Error naming the anchor: a seed for an unknown service, an execute or when with no response adapter, a delivers to an unknown service, a fixture seed that was not inlined at generate time, an undeclared ${variable}, a @given.response reference that does not resolve. (A seed or delivery to an adapter that cannot take it is a HarnessConfigurationError, above.) | | read() answered something that is not an array | A violation: adapter read() did not return a record array — configuration error. | | A case resumed after the next case on its harness started | CaseSupersededError, code: "CASE_SUPERSEDED", with anchor and by (the next case's anchor). Not a configuration error: the runner had already failed the case (SPEC-RT-007). |

Bundled schema

schemas/feat.config.schema.json ships in this package, a copy of the repository's schemas/ file that a test keeps in sync, so validation works from node_modules. It is JSON Schema draft-07 and exported as a subpath:

import { createRequire } from "node:module";

const schema = createRequire(import.meta.url)("@mmmnt/feat-runtime/schemas/feat.config.schema.json");
console.log(schema.title); // "FeatConfig"

Validate a config document with it directly, for example in an editor or a pre-commit check. Note that the schema describes a complete config. An overlay file alone fails its required list, which is why loadConfig validates the merged document.

API summary

| Export | Kind | | --- | --- | | loadConfig, resolveEnvironment, variablesSidecarPath | Config | | importAdapter | Adapter loading | | createHarness, Harness, HarnessCase, CaseVariable | Harness | | HarnessConfigurationError, PredictionViolation, CaseSupersededError | Errors | | faultProblem | Faults | | deriveNamespace, normalizeSpecPath, assertNoNamespaceCollision, assertNamespaceNotConfigured, NAMESPACE_PATTERN | Namespaces | | resolveVariables, substituteVariables | Variables | | applyMatcher, applyValueBlock, diffRecords, diffResponse, InlineData, MatchContext | Matcher | | CapturedResponse, LoadConfigInput, AdapterModule | Types |

Environment variables the runtime reads or sets: FEAT_ENVIRONMENT and ENVIRONMENT (resolveEnvironment), FEAT_NAMESPACE (set per file), FEAT_SERIAL (read in preflight) and FEAT_FENCE_AUDIT (read in the convergence wait).

What changed in 0.10.0 (breaking)

  • A nested value block is exact (ADR-0039, SPEC-RT-017; founder rulings 02af6938). A { … } in a field position now reports each key of its object that it does not declare: <anchor>: UNPREDICTED field '<key>' = <value, cut to 80>. This holds at every depth, in has (ordered and unordered), in contains, and in a response body.
  • Inside partial too. A partial record or response keeps its top level unchecked beyond its listed fields, but its nested blocks are exact.
  • Unchanged:
    • The top-level block of a record or response checks only its listed fields (ADR-0002, ADR-0038).
    • absent inside a nested block works as before.
    • A failing record still reports "captured X does not match predicted Y".
  • Why it is breaking: a spec that predicted part of a nested object now fails with no change of its own.
  • To migrate: state every key of the object, or write the field any to leave a sub-object unchecked.
  • Finding the blocks: @mmmnt/feature 0.16.0's feat lint warns NESTED_SCHEMA_OPEN on every nested block whose schema is open, which is where an unstated key can appear.

What changed in 0.2.2

  • The file's commands at setup (SPEC-RT-008). createHarness({ configPath, specPath, cases }) takes the file's cases and calls the response adapter's setup(invoke, { commands }) with each command they invoke (given executes, then the stimulus, once each). Without cases it calls setup(invoke) as before. Generated suites pass their cases from @mmmnt/feat-emit-ts 0.2.1.
  • ROUTE_UNLOADABLE. An error the response adapter's setup() throws with that code becomes a HarnessConfigurationError, so feat run exits 2 with [ROUTE_UNLOADABLE]. Any other error from setup() propagates as before.

What changed in 0.2.1

  • One case at a time (SPEC-RT-007). A case that a test runner gave up on no longer touches the adapters once the next case starts. It rejects with CaseSupersededError (CASE_SUPERSEDED). Before, its late stopCapture or reset could land inside the next case's window, and one timeout became two failures.

What changed in 0.2.0

  • Namespaces (SPEC-RT-006). deriveNamespace and its helpers, createHarness({ specPath }), FEAT_NAMESPACE, reportedNamespace() checks, and the codes NAMESPACE_COLLISION, NAMESPACE_NOT_HONOURED and NAMESPACE_CONFIGURED. A response route can declare "namespace": true.
  • Faults (SPEC-RT-003, SPEC-RT-005, ADR-0023). Catalogs with per-fault counts, preflight refusal, arming after the executes, consumption checks, faultProblem, FAULT_UNSUPPORTED, FAULT_NOT_CONSUMED and FAULT_REQUIRES_SERIAL.
  • Clock and observation modes (SPEC-RT-002, ADR-0023). setClock delivery on every case, observes, the read() query hint, CLOCK_UNSUPPORTED and MODE_UNSUPPORTED.
  • Tier overlays (SPEC-RT-004, ADR-0024). extends in loadConfig, EXTENDS_NOT_FOUND, EXTENDS_CHAIN, TIER_SPACE_MISMATCH, and the default has ordering resolved from the active tier's consistency.
  • Codes in messages. A harness configuration error's message now begins Configuration error (exit 2): [CODE], so the runner's output shows which refusal it was.

Specs and decisions

License

MIT

Part of Feature — the .feat execution specification language. Docs: https://github.com/mmmnt/feature/wiki