Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ The shared tokens, fonts and base styles in `src/app.css` are synchronized from

## Assay documentation

The Assay collection documents the public release [v0.0.1](https://github.com/0xbuffdev/assay/tree/v0.0.1). Use its package exports, contract types, tests and versioned guides as the technical source of truth. Do not document unreleased behavior as available.
The Assay collection documents the public release [v0.0.1](https://github.com/0xbuffdev/assay/tree/v0.0.1). Use its package exports, contract types, tests and versioned guides as the technical source of truth. Do not document unreleased behavior as available. Public installation commands use the package name without a version suffix; the automated example verifier pins the documented release.

Keep the Assay sidebar compact: installation is the index, evaluation covers criteria and composition, observations covers execution and reviews, integrity covers protected references and disclosure, and two reference pages cover the API and contracts. Use headings within those pages for related topics; add a page only for a distinct reader need. Use sentence-case titles, direct language, explicit prerequisites and expected results. Keep code fragments distinct from complete examples. Use Mermaid for data flows and trust boundaries, not decorative diagrams.
Keep the Assay sidebar compact: Introduction is the index and explains the product; Getting started covers installation and a short working example; evaluation covers criteria and composition, observations covers execution and reviews, integrity covers protected references and disclosure, and two reference pages cover the API and contracts. Keep navigation flat, without nested folders or collapsible sections. Use headings within pages for related topics; add a page only for a distinct reader need. Use sentence-case titles, direct language, explicit prerequisites and expected results. Keep code fragments distinct from complete examples. Use Mermaid for data flows and trust boundaries, not decorative diagrams.

The editorial approach draws on [Vercel's writing guidelines](https://github.com/vercel-labs/writing-guidelines), [Cloudflare's style guide](https://developers.cloudflare.com/style-guide/), [Mintlify's developer documentation checklist](https://www.mintlify.com/library/developer-documentation-best-practices) and [Diátaxis](https://diataxis.fr/). Apply the Content repository's humanizer skill when editing prose.

Expand Down
83 changes: 42 additions & 41 deletions content/docs/assay/evaluation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,48 @@ flowchart LR
A --> F[Technical result]
```

## Quick start
Start with the [quick start](/docs/assay/getting-started#quick-start) for a complete text comparison.

After [installation](/docs/assay), save this example as `calibration.mjs`. It checks a caller-supplied measurement against an inclusive voltage range.
## Criteria

Every criterion declares an ID, kind, mode, visibility and parameters. Required criteria participate in composition; advisory findings do not. Public criteria may appear in public projections. Restricted objective criteria must use [protected references](/docs/assay/integrity#protected-references).

| Kind | Observation | Parameters |
| --- | --- | --- |
| exact_text | text | expected |
| normalized_text | text | expected, normalization |
| number_with_tolerance | number | expected, tolerance, optional unit |
| number_range | number | expected, optional unit |
| set_equivalence | set | expected, itemType, order, duplicates |
| boolean_equality | boolean | expected |
| json_equality | json | expected |
| observed_execution | execution | assertions |
| manual_evidence | manual | review: required |
| qualitative_review | qualitative_review | reviewPolicyId, reviewPolicyVersion |

The first seven kinds compare a literal or content-bound reference expectation. The remaining kinds produce unresolved findings.

### Text

Exact comparison uses UTF-16 code-unit equality. Normalized text applies the declared transformations to both values, in this order: line endings (`preserve` or `lf`), case (`sensitive` or `fold`), Unicode (`none`, `NFC` or `NFKC`), whitespace (`preserve` or `collapse`) and trim (`none` or `both`). Case folding uses JavaScript lowercase conversion, not full Unicode case folding.

### Numbers

Tolerance is inclusive: the absolute difference must not exceed the greater of the absolute tolerance and the relative tolerance multiplied by the magnitude of the expected value.

```ts
parameters: {
expected: { type: "literal", value: 100 },
tolerance: { absolute: 2, relative: 0.05 },
unit: "mV",
}
```

A value of 105 passes; 106 fails. Both tolerances are finite and nonnegative. Numeric ranges specify finite min/max and both inclusion flags; equal endpoints require both flags to be true. Observations must use exactly the declared unit, including its absence. No string coercion or unit conversion occurs. A nonfinite relative bound produces `NUMERIC_OVERFLOW`.

### Example: numeric range

This complete example evaluates a caller-supplied measurement against an inclusive voltage range. Save it as `calibration.mjs`.

```js
// assay-docs: runnable
Expand Down Expand Up @@ -79,48 +118,10 @@ if (!evidence.ok) throw new Error("Invalid evidence");
const result = evaluate(definition.value, evidence.value);
const view = projectPublicResult(definition.value, result);
if (!view.ok) throw new Error("Projection rejected");
if (view.value.outcome !== "pass") throw new Error("Expected pass");
console.log(view.value.outcome);
```

Run `node calibration.mjs`. The output is `pass`. Change the observation to 103 and remove the assertion requiring a pass to see `fail`. With no observations, the outcome is `inconclusive`. Changing the unit to V instead of mV rejects the evidence.

## Criteria

Every criterion declares an ID, kind, mode, visibility and parameters. Required criteria participate in composition; advisory findings do not. Public criteria may appear in public projections. Restricted objective criteria must use [protected references](/docs/assay/integrity#protected-references).

| Kind | Observation | Parameters |
| --- | --- | --- |
| exact_text | text | expected |
| normalized_text | text | expected, normalization |
| number_with_tolerance | number | expected, tolerance, optional unit |
| number_range | number | expected, optional unit |
| set_equivalence | set | expected, itemType, order, duplicates |
| boolean_equality | boolean | expected |
| json_equality | json | expected |
| observed_execution | execution | assertions |
| manual_evidence | manual | review: required |
| qualitative_review | qualitative_review | reviewPolicyId, reviewPolicyVersion |

The first seven kinds compare a literal or content-bound reference expectation. The remaining kinds produce unresolved findings.

### Text

Exact comparison uses UTF-16 code-unit equality. Normalized text applies the declared transformations to both values, in this order: line endings (`preserve` or `lf`), case (`sensitive` or `fold`), Unicode (`none`, `NFC` or `NFKC`), whitespace (`preserve` or `collapse`) and trim (`none` or `both`). Case folding uses JavaScript lowercase conversion, not full Unicode case folding.

### Numbers

Tolerance is inclusive: the absolute difference must not exceed the greater of the absolute tolerance and the relative tolerance multiplied by the magnitude of the expected value.

```ts
parameters: {
expected: { type: "literal", value: 100 },
tolerance: { absolute: 2, relative: 0.05 },
unit: "mV",
}
```

A value of 105 passes; 106 fails. Both tolerances are finite and nonnegative. Numeric ranges specify finite min/max and both inclusion flags; equal endpoints require both flags to be true. Observations must use exactly the declared unit, including its absence. No string coercion or unit conversion occurs. A nonfinite relative bound produces `NUMERIC_OVERFLOW`.
Run `node calibration.mjs`. The output is `pass`. Change the observation to 103 to see `fail`. With no observations, the outcome is `inconclusive`. Changing the unit to V instead of mV rejects the evidence.

### Sets, booleans and JSON

Expand Down
102 changes: 102 additions & 0 deletions content/docs/assay/getting-started.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
---
title: "Getting started"
description: "Install Assay and evaluate your first result."
---

This guide takes you from installation to a working text comparison.

## Installation

Assay requires Node.js 24 or later and ECMAScript modules (ESM). TypeScript declarations are included.

```sh
npm install @0xbuff/assay
```

```sh
pnpm add @0xbuff/assay
```

```sh
yarn add @0xbuff/assay
```

## Quick start

The following example checks whether an observed text value matches the expected output. Save it as `assessment.mjs`.

```js
// assay-docs: runnable
import {
createAssessmentDefinition,
createEvidenceBundle,
evaluate,
} from "@0xbuff/assay";

const definition = createAssessmentDefinition({
schemaVersion: 4,
assessmentId: "output-check",
revision: "rev1",
policyVersion: "composed-required-v1",
criteria: [{
id: "output",
kind: "exact_text",
mode: "required",
visibility: "public",
parameters: { expected: { type: "literal", value: "ok" } },
}],
composition: {
rootGroupId: "root",
groups: [{
id: "root",
operator: "all",
children: [{ kind: "criterion", id: "output" }],
}],
},
});
if (!definition.ok) throw new Error("Invalid definition");

const evidence = createEvidenceBundle(definition.value, {
schemaVersion: 4,
observations: [{
criterionId: "output",
evidenceRef: "observation-1",
kind: "text",
completeness: "complete",
value: "ok",
}],
});
if (!evidence.ok) throw new Error("Invalid evidence");

const result = evaluate(definition.value, evidence.value);
console.log(result.outcome);
```

Run the example:

```sh
node assessment.mjs
```

Expected output:

```text
pass
```

Change the observation's value to `"error"` to get `fail`, or remove the observation to get `inconclusive`.

## What happened

1. `createAssessmentDefinition` validates the criterion and seals the definition.
2. `createEvidenceBundle` binds the observation to that definition.
3. `evaluate` verifies the records, compares the values and combines the required findings.

Keep the full evaluation result private. Use [public projection](/docs/assay/integrity#public-projection) and authorize disclosure before returning findings to users.

## Next steps

- [Evaluation](/docs/assay/evaluation): define comparisons, combine criteria and interpret outcomes.
- [Observations](/docs/assay/observations): supply execution facts, collect observations and record reviews.
- [API reference](/docs/assay/api): look up available functions and types.

58 changes: 21 additions & 37 deletions content/docs/assay/index.mdx
Original file line number Diff line number Diff line change
@@ -1,51 +1,35 @@
---
title: "Installation"
description: "Install Assay and start evaluating technical evidence."
title: "Introduction"
description: "Understand what Assay evaluates and how it fits into your application."
---

Assay evaluates technical evidence against versioned criteria. It runs offline, has no runtime dependencies, and leaves execution, authorization and decisions to your application.
Assay evaluates technical evidence against criteria you define. It returns reproducible findings that describe whether observed results match your expectations.

## Requirements
Use Assay to check program output, verify measurements, compare structured data or build assessment systems. It runs offline and has no runtime dependencies.

Node.js 24 or later and ECMAScript modules (ESM). Use an `.mjs` file or set `"type": "module"` in your package.json. TypeScript declarations are included.
## How it works

## Install

```sh
npm install @0xbuff/[email protected]
```

```sh
pnpm add @0xbuff/[email protected]
```

```sh
yarn add @0xbuff/[email protected]
```mermaid
flowchart LR
D[Assessment definition] --> E[Assay]
O[Evidence] --> E
E --> R[Technical result]
```

## Verify the installation
An assessment definition specifies the expected results and how required checks are combined. Evidence contains the observed values. Assay validates the records, compares the values and returns a finding for each criterion and an overall technical outcome.

Save this as `check.mjs`.
## Capabilities

```js
// assay-docs: runnable
import { ASSAY_SCHEMA_VERSION, ASSAY_EVALUATOR_VERSION } from "@0xbuff/assay";

console.log(ASSAY_SCHEMA_VERSION, ASSAY_EVALUATOR_VERSION);
```

Run `node check.mjs`. Expected output:

```text
4 v0.0.5
```
- Compare text, numbers, sets, booleans and JSON.
- Combine required criteria using all or any groups.
- Evaluate captured execution facts and collect observations through a host-supplied adapter.
- Record advisory human or model reviews.
- Protect expected values, verify content digests and project public results.

## Next steps
Your application supplies evidence, authorizes criteria and decides how to use the findings. Assay does not execute submitted programs, authenticate observations, assign grades or issue credentials.

- [Evaluation](/docs/assay/evaluation): define criteria, supply evidence and evaluate your first result.
- [Observations](/docs/assay/observations): integrate captured execution facts, optional adapters and reviews.
- [Integrity and security](/docs/assay/integrity): protect expectations and control disclosure.
## Get started

These pages describe release `0.0.1`, schema 4, evaluator semantics `v0.0.5` and policy `composed-required-v1`. Older schemas are unsupported. Pin the package and keep your lockfile for reproducibility.
Follow [Getting started](/docs/assay/getting-started) to install Assay and run your first evaluation.

[Source](https://github.com/0xbuffdev/assay) · [Changelog](https://github.com/0xbuffdev/assay/blob/v0.0.1/CHANGELOG.md) · [Apache-2.0 license](https://github.com/0xbuffdev/assay/blob/v0.0.1/LICENSE)
[Source](https://github.com/0xbuffdev/assay) · [Changelog](https://github.com/0xbuffdev/assay/blob/main/CHANGELOG.md) · [License](https://github.com/0xbuffdev/assay/blob/main/LICENSE)
2 changes: 1 addition & 1 deletion content/docs/assay/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
"root": true,
"pages": [
"index",
"getting-started",
"evaluation",
"observations",
"integrity",
"---Reference---",
"api",
"contracts"
]
Expand Down
24 changes: 22 additions & 2 deletions scripts/assay-docs.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ const pages = new Set(files.map((name) => name.slice(0, -4)));

test("Assay has distinct entry, task, explanation and reference pages", async () => {
const meta = JSON.parse(await readFile(join(directory, "meta.json"), "utf8"));
const listed = meta.pages.filter((entry) => !entry.startsWith("---"));
const listed = meta.pages;
assert.deepEqual([...listed].sort(), [...pages].sort());
assert.deepEqual(listed, ["index", "evaluation", "observations", "integrity", "api", "contracts"]);
assert.deepEqual(listed, ["index", "getting-started", "evaluation", "observations", "integrity", "api", "contracts"]);
});

test("Assay internal links resolve and complete examples are marked", async () => {
Expand All @@ -27,3 +27,23 @@ test("Assay internal links resolve and complete examples are marked", async () =
}
assert.ok(runnable >= 5, "Expected complete executable examples");
});

test("Introduction and Getting started have distinct purposes", async () => {
const intro = await readFile(join(directory, "index.mdx"), "utf8");
assert.match(intro, /^title: "Introduction"$/m);
assert.doesNotMatch(intro, /(?:npm install|pnpm add|yarn add)\s+@0xbuff\/assay/);
assert.ok(intro.includes("/docs/assay/getting-started"));
const source = await readFile(join(directory, "getting-started.mdx"), "utf8");
assert.match(source, /^title: "Getting started"$/m);
for (const heading of ["Installation", "Quick start"]) {
assert.ok(source.includes("## " + heading));
}
for (const command of ["npm install", "pnpm add", "yarn add"]) {
assert.ok(source.includes(command + " @0xbuff/assay\n"), command);
}
for (const file of files) {
const text = await readFile(join(directory, file), "utf8");
assert.doesNotMatch(text, /(?:npm install|pnpm add|yarn add)\s+@0xbuff\/assay@\S+/, file);
}
assert.match(source, /const result = evaluate\(/);
});
2 changes: 1 addition & 1 deletion scripts/verify-assay-examples.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const version = "0.0.1";
const directory = "content/docs/assay";
const temporary = await mkdtemp(join(tmpdir(), "assay-docs-"));
const expected = new Map([
["index.mdx", ["4 v0.0.5"]],
["getting-started.mdx", ["pass"]],
["evaluation.mdx", ["pass"]],
["observations.mdx", ["pass", "pass"]],
["integrity.mdx", ["pass withheld"]],
Expand Down
Loading