From 8e7d429379ff7429a3985c4ba412fa85a5607b70 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Tue, 15 Sep 2026 21:31:41 +0200 Subject: [PATCH] 4.3: the shared property module is property-harness.ts, and the canonical arm filters emit refusals --- AGENTS.md | 3 ++- package.json | 2 +- src/adf-property.test.ts | 2 +- src/markdown-property.test.ts | 11 ++++++----- src/{property-generators.ts => property-harness.ts} | 0 tsconfig.build.json | 2 +- 6 files changed, 11 insertions(+), 9 deletions(-) rename src/{property-generators.ts => property-harness.ts} (100%) diff --git a/AGENTS.md b/AGENTS.md index a1c5beb..b7489a5 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -229,7 +229,8 @@ editor wrote; the CommonMark spec suite against `markdownToAdf` and `markdownToH Beside the corpus, properties run over documents generated from the node tables and over generated markdown, on a fixed seed in the gate; `PROPERTY_RUNS=` raises the runs and randomizes the -seed for local digging, and a counterexample found becomes a round-trip fixture. +seed for local digging, and a counterexample found becomes a round-trip fixture. The generators and +run parameters properties share live in `src/property-harness.ts`, outside the build and coverage. `spec/flavour.md` is read as a source too, so the node tables cannot drift from the prose they copy: each `- ` bullet in `## Block nodes`, `## Inline nodes` and `## Marks` declares the nodes diff --git a/package.json b/package.json index 5b86fde..0d696e2 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ }, "scripts": { "build": "tsc -p tsconfig.build.json", - "test": "node --test --experimental-test-coverage --test-coverage-exclude=\"src/**/*.test.ts\" --test-coverage-exclude=src/property-generators.ts --test-coverage-branches=98 --test-coverage-functions=100 --test-coverage-lines=100 \"src/**/*.test.ts\"", + "test": "node --test --experimental-test-coverage --test-coverage-exclude=\"src/**/*.test.ts\" --test-coverage-exclude=src/property-harness.ts --test-coverage-branches=98 --test-coverage-functions=100 --test-coverage-lines=100 \"src/**/*.test.ts\"", "typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.build.json" }, "devDependencies": { diff --git a/src/adf-property.test.ts b/src/adf-property.test.ts index 4e54660..41e4410 100644 --- a/src/adf-property.test.ts +++ b/src/adf-property.test.ts @@ -2,7 +2,7 @@ import fc from 'fast-check' import assert from 'node:assert/strict' import test from 'node:test' -import { adfDocument, propertyRuns, propertyTimeout } from './property-generators.ts' +import { adfDocument, propertyRuns, propertyTimeout } from './property-harness.ts' import { adfToMarkdown } from './markdown/emit/adf-to-markdown.ts' import { markdownToAdf } from './markdown/parse/markdown-to-adf.ts' import { toEditorNormal } from './adf/editor-normal.ts' diff --git a/src/markdown-property.test.ts b/src/markdown-property.test.ts index 4213794..66a8f3f 100644 --- a/src/markdown-property.test.ts +++ b/src/markdown-property.test.ts @@ -5,7 +5,8 @@ import test from 'node:test' import type { Arbitrary, DepthIdentifier } from 'fast-check' import type { AttributeVocabulary } from './adf/attribute-vocabulary.ts' import type { JsonValue } from './json-value.ts' -import { adfDocument, attributes, jsonKey, jsonValue, markdownPieces, propertyRuns, propertyTimeout, textOf } from './property-generators.ts' +import type { Result } from './result.ts' +import { adfDocument, attributes, jsonKey, jsonValue, markdownPieces, propertyRuns, propertyTimeout, textOf } from './property-harness.ts' import { adfToMarkdown } from './markdown/emit/adf-to-markdown.ts' import { blockArgument } from './markdown/block-directive-arguments.ts' import { blockDirectives } from './adf/block-directives.ts' @@ -360,10 +361,10 @@ function blockMarkdown(hostile: boolean, { inlines, oneLine }: InlineMarkdown, { const cleanMarkdown = markdownOf(false) const hostileMarkdown = markdownOf(true) -const canonical = adfDocument.map((document) => { - const emitted = adfToMarkdown(document) - return emitted.ok ? emitted.value : '' -}) +const canonical = adfDocument + .map((document) => adfToMarkdown(document)) + .filter((emitted): emitted is Extract, { ok: true }> => emitted.ok) + .map((emitted) => emitted.value) function edited(markdown: string, edits: readonly Edit[]): string { let text = markdown diff --git a/src/property-generators.ts b/src/property-harness.ts similarity index 100% rename from src/property-generators.ts rename to src/property-harness.ts diff --git a/tsconfig.build.json b/tsconfig.build.json index 6b17c1b..98a04c3 100644 --- a/tsconfig.build.json +++ b/tsconfig.build.json @@ -27,6 +27,6 @@ "forceConsistentCasingInFileNames": true, "skipLibCheck": true }, - "exclude": ["src/**/*.test.ts", "src/property-generators.ts"], + "exclude": ["src/**/*.test.ts", "src/property-harness.ts"], "include": ["src"] }