Skip to content

test: hermetic W3C N3 reasoning spec test suite - #1961

Draft
jeswr wants to merge 2 commits into
mainfrom
test/spec-tests-runner
Draft

test: hermetic W3C N3 reasoning spec test suite#1961
jeswr wants to merge 2 commits into
mainfrom
test/spec-tests-runner

Conversation

@jeswr

@jeswr jeswr commented Jul 4, 2026

Copy link
Copy Markdown
Member

🚧 Draft — agent-generated PR. Written by an AI agent working on the issue backlog; please review before considering it for merge.

Closes #336

What this adds

A jest runner for the reasoning part of the W3C N3 test suite (tests/N3Tests/manifest-reasoner.ttl), runnable with:

npm run test:spec

Per review, the upstream test suite is not committed to this repo — it is fetched at a pinned commit and cached in CI.

  • scripts/fetch-n3-tests.ts (npm run spec:fetch) — downloads tests/N3Tests from w3c/N3 at a pinned commit (N3_TESTS_COMMIT) into the git-ignored __tests__/spec/.w3c-n3-tests/. It is a no-op once the directory is present, so local re-runs and CI cache hits skip the download. npm run test:spec runs it first.
  • CI cache — the spec-tests job wraps the run in actions/cache@v4, keyed on hashFiles('scripts/fetch-n3-tests.ts') (which holds the pin), so runs are deterministic and a cold cache only downloads once; bumping the pin busts the cache automatically. The job is intentionally not in the release job's needs — a newly surfacing deviation should be triaged into the skip list, not block releases.
  • __tests__/spec/spec-test.ts — parses the fetched manifest with the already-present n3 dependency, runs each test:TestN3Reason entry through n3reasoner, and compares the derived graph to the reference by RDF isomorphism (jest-rdf / rdf-isomorphic, already a devDependency). The cwm-style test:options map onto EYE output modes (conclusionsderivations, datadeductive_closure, neither → deductive_closure_plus_rules), and output/reference graphs are rebased onto a common base IRI (n3reasoner loads its input as data_0.n3s while the references resolve relative IRIs against the original input file name). If the suite is missing it throws with a pointer to npm run spec:fetch.
  • __tests__/spec/skip-list.json — every known EYE deviation recorded with a reason, so the suite stays green while deviations are triaged one by one. Removing an entry re-enables the test.
  • Separate jest project (jest.spec.config.json) + testPathIgnorePatterns in the main config, so the coverage-thresholded unit suite is unaffected.

Upstream manifest typo

The pinned manifest concatenates two entries without whitespace in mf:entries:cwm_includes_t4:cwm_includes_t6 — which Turtle parses as a single, undefined prefixed name (: is legal in local names), so both tests would silently vanish. Since the suite is now fetched unpatched, spec-test.ts applies a small self-healing in-code patch (insert the missing space) to the manifest text before parsing; it becomes a no-op once upstream fixes it. Filed upstream as w3c-cg/N3#232.

Current results

count
manifest entries 89
passing 50
skipped (known deviations, with reasons) 39
failing 0

Local run (both cold-fetch and warm-cache paths): Tests: 39 skipped, 51 passed, 90 total (the extra test asserts the manifest loaded), ~20 s. The 39 skips cluster into: WASM sub-reasoner gaps (log:conclusion needs shell/2/exec — same root as #873 / eyereasoner/eye#177), tests that dereference sibling files via log:semantics (not exposed through the single-document n3reasoner API), math: numeric edge cases, EYE output constructs the n3.js parser rejects, and reference files that aren't standalone-parseable. Each entry in skip-list.json carries its specific reason.

Notes


@jeswr will review — expect a delay; active review happens Wed–Fri.

🤖 Generated with Claude Code

Adds a jest runner for the reasoning entries of the W3C N3 test suite
(w3c/N3 tests/N3Tests/manifest-reasoner.ttl), run as a separate jest
project so the coverage-thresholded unit suite is unaffected:

- __tests__/spec/w3c-n3-tests: vendored snapshot (manifest + the 178
  files it references, ~850K) of w3c/N3 @ 97653d4, so the suite runs
  fully offline
- __tests__/spec/spec-test.ts: parses the manifest with n3, runs each
  entry through n3reasoner, and compares graphs by RDF isomorphism
  (jest-rdf), mapping the cwm-style test:options onto EYE output modes
- __tests__/spec/skip-list.json: 39 known EYE deviations recorded with
  reasons so CI stays green while they are triaged; 50/89 manifest
  entries currently pass
- npm run test:spec + a non-release-blocking spec-tests CI job

Closes #336

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@jeswr
jeswr force-pushed the test/spec-tests-runner branch from f5a35d1 to b1b5bef Compare July 4, 2026 23:27

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'EYE JS Benchmark'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.25.

Benchmark suite Current: b1b5bef Previous: d129aee Ratio
Run socrates query 16.01 ops/sec (±4.93%) 22.2 ops/sec (±2.39%) 1.39
Executing the socrates query 117 ops/sec (±19.58%) 3890 ops/sec (±1.67%) 33.25
Run deep taxonomy benchmark [10] 6.92 ops/sec (±0.43%) 18.83 ops/sec (±6.56%) 2.72
Run deep taxonomy benchmark [50] 0.26 ops/sec (±0.38%) 19.63 ops/sec (±7.26%) 75.50
Run deep taxonomy benchmark [100] 0.04 ops/sec (±0.69%) 18.67 ops/sec (±6.95%) 466.75
Run deep taxonomy benchmark [10] [reasoning only] 7.8 ops/sec (±16.64%) 4107 ops/sec (±1.65%) 526.54
Run deep taxonomy benchmark [50] [reasoning only] 0.65 ops/sec (±23.07%) 4147 ops/sec (±1.85%) 6380
Run deep taxonomy benchmark [100] [reasoning only] 0.17 ops/sec (±24.95%) 4136 ops/sec (±1.60%) 24329.41
Run timbl + foaf + rdfs rules 2.05 ops/sec (±2.66%) 17.23 ops/sec (±6.18%) 8.40
Run timbl + foaf + owl2rl rules 1.22 ops/sec (±1.56%) 17.03 ops/sec (±3.91%) 13.96
Run timbl + rdfs rules 4.7 ops/sec (±2.46%) 18.28 ops/sec (±6.60%) 3.89
Run timbl + owl2rl rules 6 ops/sec (±0.27%) 17.1 ops/sec (±6.85%) 2.85
Run timbl + foaf + rdfs rules [string] 2.13 ops/sec (±0.21%) 18.45 ops/sec (±7.08%) 8.66
Run timbl + foaf + owl2rl rules [string] 1.26 ops/sec (±0.13%) 18.54 ops/sec (±6.64%) 14.71
Run timbl + rdfs rules [string] 4.81 ops/sec (±0.30%) 18.77 ops/sec (±6.77%) 3.90
Run timbl + owl2rl rules [string] 6.19 ops/sec (±0.26%) 18.98 ops/sec (±6.47%) 3.07

This comment was automatically generated by workflow using github-action-benchmark.

CC: @jeswr

Addresses review on #1961: the upstream test suite should not be
committed to this repo.

- Remove the vendored __tests__/spec/w3c-n3-tests/ snapshot (180 files).
- Add scripts/fetch-n3-tests.ts: downloads tests/N3Tests from w3c/N3 at a
  pinned commit into the git-ignored __tests__/spec/.w3c-n3-tests/; a no-op
  once present. npm run spec:fetch, invoked first by npm run test:spec.
- CI: cache that directory with actions/cache keyed on the fetch script
  (which pins the commit), so runs stay deterministic and cache-hit fast.
  The spec-tests job stays out of the release job's needs.
- spec-test.ts reads the fetched suite (via cacheDir), throws a helpful
  error if it is missing, and applies a small self-healing in-code patch
  for the upstream manifest typo :cwm_includes_t4:cwm_includes_t6 (filed as
  w3c-cg/N3#232) instead of patching a committed file.
- README + .gitignore updated.

Closes #336

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chore: spec tests

1 participant