app

Local-first trade for farms and co-ops
git clone https://radroots.dev/git/app.git
Log | Files | Refs | README | LICENSE

commit 5d4339aabdba86e7f88eb4c05fe7fefc4975bb09
parent f6237db0d0013ef1771eb30d1d3fd623411c6ba3
Author: triesap <tyson@radroots.org>
Date:   Tue,  6 Oct 2026 04:17:07 +0000

test: Connect TS conformance and explicit cross-runtime orchestration (HCR-015)

- Consume the shared Food manifest through actual TypeScript adapters
- Reject changed semantics and hash inputs with explicit unsupported outcomes
- Add the standalone and governed combined native and web fixture gate
- Preserve Cargo-free ordinary web commands and explicit generation

Diffstat:
MMakefile | 9+++++++++
Mconfig/repository/runtime-ownership.v1.json | 9+++++++++
Mcontracts/interop/manifest.json | 1-
Atools/check-interop.sh | 17+++++++++++++++++
Aweb/tests/conformance/interop-consumer.test.ts | 121+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aweb/tests/conformance/interop-consumer.ts | 205+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mweb/tests/conformance/interop-manifest.ts | 1-
7 files changed, 361 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile @@ -20,6 +20,14 @@ endif .PHONY: help doctor governed-doctor lock metadata build-logic-check build-logic-stability-check mode-check design-source-check design-goldens-update format format-fix lint test check governed-check build bindings api-check dev-check dev run audit licenses foundation-check package host-package-check governed-package-check source-check governed-source-check package-check integration-check governed-integration-check development-provenance-check development-check governed-development-check governed-linux-x86_64-development-check host-ui-lifecycle-check acceptance-check unsigned-release-check _unsigned-release-check signing-check _signing-check notarization-check _notarization-check release-check _release-check clean .PHONY: native-doctor native-dev native-check native-build native-package-check .PHONY: web-doctor web-install web-dev web-check web-build +.PHONY: interop-check + +interop-check: + $(BUILD_RUNNER) tools/check-interop.sh + +ifeq ($(BUILD_MODE),governed) +interop-check: governed-doctor +endif web-doctor: cd web && $(BUILD_RUNNER) node tools/doctor.mjs @@ -51,6 +59,7 @@ native-package-check: package-check help: @printf '%s\n' 'Unqualified targets below retain native meaning.' 'Browser: web-doctor web-install web-dev web-check web-build' + @printf '%s\n' 'Explicit cross-runtime fixture gate: interop-check' @printf '%s\n' doctor governed-doctor lock metadata build-logic-check build-logic-stability-check mode-check design-source-check design-goldens-update format format-fix lint test check governed-check build bindings api-check dev-check dev run audit licenses foundation-check package host-package-check governed-package-check source-check governed-source-check package-check integration-check governed-integration-check development-check governed-development-check governed-linux-x86_64-development-check host-ui-lifecycle-check acceptance-check unsigned-release-check signing-check notarization-check release-check clean design-source-check: doctor diff --git a/config/repository/runtime-ownership.v1.json b/config/repository/runtime-ownership.v1.json @@ -193,6 +193,15 @@ ] }, { + "path": "tools/check-interop.sh", + "kind": "exact", + "owners": [ + "native", + "web", + "interop" + ] + }, + { "path": "tools/interop", "kind": "prefix", "owners": [ diff --git a/contracts/interop/manifest.json b/contracts/interop/manifest.json @@ -69,7 +69,6 @@ "manifest": "Derived metadata and expectations, not a second editable protocol policy." }, "pending_checks": [ - "combined_orchestration_HCR015", "Message_adapters_HCP071_HCP130", "deployed_Tera_qualification" ], diff --git a/tools/check-interop.sh b/tools/check-interop.sh @@ -0,0 +1,17 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-3.0-only +set -eu +fail() { printf '%s\n' "HarvestCircle interop check: $*" >&2; exit 1; } +[ "$#" -eq 0 ] || fail "unexpected arguments" +repository_root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd) +for tool in node corepack cargo; do + command -v "$tool" >/dev/null 2>&1 || fail "required tool is unavailable: $tool" +done +cd "$repository_root/web" +node tools/doctor.mjs +cd "$repository_root" +cargo +1.97.1 --version +cargo +1.97.1 test --manifest-path contracts/interop/food_availability/oracle/Cargo.toml --locked --test native_manifest -- --nocapture +cd "$repository_root/web" +corepack pnpm exec node --test tests/conformance/interop-consumer.test.ts +printf '%s\n' 'harvestcircle.interop.fixture_consumers=pass' 'harvestcircle.interop.qualification=source_only_no_Message_or_deployed_Tera_claim' diff --git a/web/tests/conformance/interop-consumer.test.ts b/web/tests/conformance/interop-consumer.test.ts @@ -0,0 +1,121 @@ +import assert from 'node:assert/strict'; +import { lstat, readFile } from 'node:fs/promises'; +import test from 'node:test'; +import { readFoodEvent } from '../../src/lib/contracts/food-availability-v1/read.ts'; +import { buildFoodTemplate } from '../../src/lib/contracts/food-availability-v1/write.ts'; +import { + interopInputPaths, + type buildInteropManifest +} from './interop-manifest.ts'; +import { consumeInteropTypescript } from './interop-consumer.ts'; +import { webTemplates } from './food-writer-cases.ts'; +const root = new URL('../../../', import.meta.url); +const inputs = new Map<string, Uint8Array>(); +for (const path of interopInputPaths) { + const file = new URL(path, root); + const info = await lstat(file); + assert.ok( + info.isFile() && + !info.isSymbolicLink() && + info.size > 0 && + info.size <= 1024 * 1024 + ); + const bytes = new Uint8Array(await readFile(file)); + assert.equal(bytes.byteLength, info.size); + inputs.set(path, bytes); +} +const manifest: unknown = JSON.parse( + await readFile(new URL('contracts/interop/manifest.json', root), 'utf8') +); +void test('shared manifest executes actual TS adapters and reports every unsupported counterpart', () => { + const result = consumeInteropTypescript(manifest, inputs); + assert.equal(result.executed_cases, 40); + assert.equal(result.unsupported_cases, 26); + assert.equal(new Set(result.cases.map((row) => row.id)).size, 66); + console.log(JSON.stringify(result)); +}); +void test('changed actual reader projection fails against the pinned oracle expectation', () => { + assert.throws(() => + consumeInteropTypescript(manifest, inputs, { + read: (raw) => { + const actual = readFoodEvent(raw); + return actual.outcome === 'admitted' + ? { + ...actual, + projection: { + ...actual.projection, + location: 'deliberately changed reader semantics' + } + } + : actual; + } + }) + ); +}); +void test('changed actual writer output fails against retained Rust wire parts', () => { + const writers = structuredClone(webTemplates); + writers[0] = { + ...writers[0], + wire_parts: { + ...writers[0].wire_parts, + content: + writers[0].wire_parts.content + 'deliberately changed writer semantics' + } + }; + assert.throws(() => consumeInteropTypescript(manifest, inputs, { writers })); +}); +void test('changed actual boundary builder output fails rather than accepting matching metadata', () => { + assert.throws(() => + consumeInteropTypescript(manifest, inputs, { + build: (draft) => { + const actual = buildFoodTemplate(draft); + return actual.ok + ? { + ...actual, + wire_parts: { + ...actual.wire_parts, + tags: actual.wire_parts.tags.map((tag) => + tag[0] === 'published_at' ? [tag[0], '2'] : tag + ) + } + } + : actual; + } + }) + ); +}); +void test('unsafe JavaScript timestamps cannot be promoted from unsupported to accepted', () => { + assert.throws(() => + consumeInteropTypescript(manifest, inputs, { + build: (draft) => { + const actual = buildFoodTemplate(draft); + return Number.isSafeInteger(draft.published_at) + ? actual + : buildFoodTemplate({ ...draft, published_at: 1, created_at: 1 }); + } + }) + ); +}); +void test('zero matching profile cases fails', () => { + assert.throws( + () => + consumeInteropTypescript(manifest, inputs, { + profile: 'unmatched_profile' + }), + /zero matching/ + ); +}); +void test('changed manifest vector hash fails the actual TS consumer', () => { + const changed = structuredClone(manifest) as ReturnType< + typeof buildInteropManifest + >; + changed.cases[0].fixture.sha256 = '0'.repeat(64); + assert.throws(() => consumeInteropTypescript(changed, inputs)); +}); +void test('changed raw vector bytes fail the actual TS consumer', () => { + const changed = new Map(inputs); + const path = interopInputPaths[0]; + const bytes = inputs.get(path)!; + changed.set(path, new Uint8Array([...bytes, 32])); + assert.throws(() => consumeInteropTypescript(manifest, changed)); +}); diff --git a/web/tests/conformance/interop-consumer.ts b/web/tests/conformance/interop-consumer.ts @@ -0,0 +1,205 @@ +import assert from 'node:assert/strict'; +import { readFoodEvent } from '../../src/lib/contracts/food-availability-v1/read.ts'; +import { + buildFoodTemplate, + type FoodDraft +} from '../../src/lib/contracts/food-availability-v1/write.ts'; +import { webTemplates } from './food-writer-cases.ts'; +import { + validateInteropManifest, + type InteropInputs, + buildInteropManifest +} from './interop-manifest.ts'; + +type Manifest = ReturnType<typeof buildInteropManifest>; +type Recipe = { + id: string; + expected: Record<string, unknown>; + signed_wires: Record<string, string>; +}; +type Boundary = { + id: string; + kind: 'timestamp' | 'identifier'; + value: string; + expected: { typescript: Record<string, unknown> }; +}; +const base: FoodDraft = { + identifier: 'boundary-id', + title: 'Fresh food', + description: 'Fresh food available locally.', + location: 'Victoria', + amount: '1', + currency: 'CAD', + unit: 'g', + status: 'active', + published_at: 1, + created_at: 1 +}; + +function reader( + raw: string, + expected: Record<string, unknown>, + read: typeof readFoodEvent +) { + const actual = read(raw); + if ('error' in expected) { + assert.equal(actual.outcome, 'rejected'); + assert.ok(actual.outcome === 'rejected'); + assert.deepEqual(actual.error, expected.error); + return { outcome: actual.outcome, error: actual.error }; + } + assert.ok(actual.outcome !== 'rejected'); + assert.equal(actual.event_id, expected.event_id); + if ('partition' in expected) { + assert.ok(actual.outcome === 'excluded'); + assert.deepEqual(actual.partition, expected.partition); + return { + outcome: actual.outcome, + event_id: actual.event_id, + partition: actual.partition + }; + } + assert.ok(actual.outcome === 'admitted'); + if ('projection' in expected) { + assert.deepEqual(actual.projection, expected.projection); + return { + outcome: actual.outcome, + event_id: actual.event_id, + projection: actual.projection + }; + } + assert.ok('image_count' in expected); + const observed = { + event_id: actual.event_id, + image_count: actual.projection.images.length, + first_raw_tag: actual.projection.images[0]?.raw_tag, + last_raw_tag: actual.projection.images.at(-1)?.raw_tag, + diagnostics: actual.projection.diagnostics + }; + for (const [key, value] of Object.entries(observed)) + assert.deepEqual(value, expected[key], key); + return { outcome: actual.outcome, ...observed }; +} + +export function consumeInteropTypescript( + manifest: unknown, + inputs: InteropInputs, + options: { + profile?: string; + read?: typeof readFoodEvent; + build?: typeof buildFoodTemplate; + writers?: typeof webTemplates; + } = {} +) { + const writers = options.writers ?? webTemplates; + validateInteropManifest(manifest, inputs, writers); + const checked = manifest as Manifest; + const decode = (path: string): unknown => + JSON.parse( + new TextDecoder('utf-8', { fatal: true }).decode(inputs.get(path)) + ); + const corpus = decode( + 'contracts/interop/food_availability/corpus.v1.json' + ) as { vectors: Recipe[] }; + const boundaries = decode( + 'contracts/interop/food_availability/numeric_boundaries.v1.json' + ) as { vectors: Boundary[] }; + const cases: { + id: string; + result: 'PASS' | 'UNSUPPORTED'; + actual?: unknown; + reason?: string; + }[] = []; + for (const row of checked.cases) { + if ( + row.protocol.profile !== (options.profile ?? 'food_availability_profile') + ) + continue; + const participation = row.participation.typescript; + if (participation === 'UNSUPPORTED_CURRENT_ADAPTER') { + assert.ok(row.participation.unsupported_reason); + cases.push({ + id: row.id, + result: 'UNSUPPORTED', + reason: row.participation.unsupported_reason + }); + } else if (participation === 'food_reader') { + const recipe = corpus.vectors[row.fixture.case_index]; + assert.equal(recipe.id, row.id); + cases.push({ + id: row.id, + result: 'PASS', + actual: reader( + recipe.signed_wires.event, + recipe.expected, + options.read ?? readFoodEvent + ) + }); + } else if (participation === 'food_writer') { + const actual = writers[row.fixture.case_index]; + assert.equal(actual.id, row.id); + assert.deepEqual( + { result: 'accepted', wire_parts: actual.wire_parts }, + row.expected + ); + cases.push({ + id: row.id, + result: 'PASS', + actual: { wire_parts: actual.wire_parts, summary: actual.summary } + }); + } else { + const recipe = boundaries.vectors[row.fixture.case_index]; + assert.equal(recipe.id, row.id); + const build = options.build ?? buildFoodTemplate; + const value = recipe.kind === 'timestamp' ? BigInt(recipe.value) : null; + const result = build( + recipe.kind === 'identifier' + ? { ...base, identifier: recipe.value } + : { ...base, published_at: Number(value), created_at: Number(value) } + ); + if (participation === 'UNSUPPORTED_JAVASCRIPT_U64') { + assert.ok(value !== null && value > BigInt(Number.MAX_SAFE_INTEGER)); + assert.equal(result.ok, false); + assert.ok(!result.ok); + assert.equal(result.error.code, 'timestamp_invalid'); + assert.ok(row.participation.unsupported_reason); + cases.push({ + id: row.id, + result: 'UNSUPPORTED', + reason: row.participation.unsupported_reason, + actual: { rejected_code: result.error.code } + }); + } else { + assert.equal(participation, 'food_boundary'); + const actual = !result.ok + ? { result: 'rejected', code: result.error.code } + : recipe.kind === 'identifier' + ? { result: 'accepted', identifier: result.wire_parts.tags[0][1] } + : { + result: 'accepted', + timestamp: String(Number(value)), + encoded_published_at: result.wire_parts.tags.find( + (tag) => tag[0] === 'published_at' + )?.[1] + }; + assert.deepEqual(actual, recipe.expected.typescript); + cases.push({ id: row.id, result: 'PASS', actual }); + } + } + } + assert.ok(cases.length > 0, 'zero matching TypeScript manifest cases'); + assert.equal(cases.length, 66); + const executed = cases.filter((row) => row.result === 'PASS').length; + assert.equal(executed, 40); + assert.equal(cases.length - executed, 26); + return { + consumer: 'actual_typescript_food_adapters', + matched_cases: cases.length, + executed_cases: executed, + unsupported_cases: cases.length - executed, + revision: checked.oracle.revision, + qualification: checked.qualification, + signing: checked.signing, + cases + }; +} diff --git a/web/tests/conformance/interop-manifest.ts b/web/tests/conformance/interop-manifest.ts @@ -224,7 +224,6 @@ export function buildInteropManifest( 'Derived metadata and expectations, not a second editable protocol policy.' }, pending_checks: [ - 'combined_orchestration_HCR015', 'Message_adapters_HCP071_HCP130', 'deployed_Tera_qualification' ],