document-compute.js 1.3.84 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +1 -1
  2. package/package.json +10 -8
package/README.md CHANGED
@@ -113,7 +113,7 @@ One thing #573 asks for was closed at adoption rather than built here: `Quantity
113
113
 
114
114
  Scoped to point-valued (`Quantity`) answers: every value this harness computes comes from evaluating a closed statement with no bindings, which `evaluate` cannot turn into an `Interval` (an `Interval` only ever arises by binding a symbol to one) — a genuinely interval-valued worked example (`0.87 <= cos(phi) <= 1`, #573's own illustration of interval arithmetic) has no representation in this "symbol = expression" equality grammar at all, since neither `MathExpression` nor `documents.js`'s LaTeX lowering has a compound-inequality-to-range reading, and is out of scope for this pass rather than silently mishandled.
115
115
 
116
- `src/harness/corpus.test.ts` proves the whole pipeline end to end — markdown text through `markdown-codec`'s `$$` block recognition and `documents.js`'s `lowerMarkdownMath` (the "LaTeX lowering" #794 names as the natural source of worked examples) into this harness — against a small, hand-authored starter corpus. `markdown-codec` and `documents.js` are **devDependencies only**: both sit above this package in the family's own dependency order (see the monorepo root README's package table), so neither can be a runtime dependency here without a cycle. The harness itself is not test-only, though — `src/index.ts` exports it as real public API (`runWorkedExampleSequence`, `collectFormulas`, `runCorpus`, `formatCorpusReport`), the same as `evaluate`/`solveFor`; what's actually true is narrower: it has no runtime consumer anywhere else in the family yet, unlike `evaluate`/`solveFor` below it, which `document-mcp`'s `compute_formula` tool does depend on directly (see Conventions). A large real-world corpus (the issue's own stated differentiator at scale) is not includedgathering one is a data-curation task, not a code onebut is a straightforward local addition: point a `test/corpus/` directory (gitignored, matching `pdf-codec`'s own `test:corpus` convention) at real markdown documents with worked examples and feed `readMarkdownContent` `lowerMarkdownMath` `runCorpus` the same way `corpus.test.ts` does.
116
+ `src/harness/corpus.test.ts` proves the whole pipeline end to end — markdown text through `markdown-codec`'s `$$` block recognition and `documents.js`'s `lowerMarkdownMath` (the "LaTeX lowering" #794 names as the natural source of worked examples) into this harness — against a small, hand-authored starter corpus. `markdown-codec` and `documents.js` are **devDependencies only**: both sit above this package in the family's own dependency order (see the monorepo root README's package table), so neither can be a runtime dependency here without a cycle. The harness itself is not test-only, though — `src/index.ts` exports it as real public API (`runWorkedExampleSequence`, `collectFormulas`, `runCorpus`, `formatCorpusReport`), the same as `evaluate`/`solveFor`; what's actually true is narrower: it has no runtime consumer anywhere else in the family yet, unlike `evaluate`/`solveFor` below it, which `document-mcp`'s `compute_formula` tool does depend on directly (see Conventions). An at-scale corpus layer now exists: `pnpm test:corpus` runs the gitignored `test/corpus/` suite that `scripts/generate-corpus.mjs` regenerates 300 deterministic worked-example documents over the mechanically-lowered arithmetic grammar (explicit \times/\frac/\sqrt compositions, never juxtaposition), each stated answer computed by the generator's own parallel evaluation measuring 300/300 matched, 0 gaps, 0 unresolved, with the measured report written to `test/corpus/report.txt`. Its first run paid for itself immediately: every document with a NEGATIVE stated answer degraded its whole equality under the lowering's leading-minus-only unary reading, which now generalises past that (a minus after a relation or operator signs the following operand). Real textbook corpora remain a local addition on top: point the same `test/corpus/files/` directory at real markdown documents and the harness measures them identically.
117
117
 
118
118
  While building this harness's own fixtures, a real bug surfaced in `documents.js`'s LaTeX lowering: `F = m \times a` (the textbook-standard way to write almost any formula) lowers to `(F = m) \times a` rather than `F = (m \times a)`, because the lowering folds relational and arithmetic operators at the same precedence with no notion that `=` should bind loosest — filed as [ExaDev/documents.js#812](https://github.com/ExaDev/documents.js/issues/812). This package's own fixtures work around it with an explicit braced right-hand side (`F = {m \times a}`, which lowers correctly), since fixing the lowering itself is out of scope for this package.
119
119
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "document-compute.js",
3
- "version": "1.3.84",
3
+ "version": "1.4.0",
4
4
  "description": "Units-typed, tree-walking evaluator for document-schema.js's MathExpression -- exact-rational unit conversion, interval arithmetic, and bisection/Newton numeric solve-for, the compute package for the documents.js family.",
5
5
  "type": "module",
6
6
  "repository": {
@@ -57,18 +57,20 @@
57
57
  "_typecheck": "tsc -p tsconfig.json && tsc -p tsconfig.node.json",
58
58
  "_typecheck:attw": "attw --pack",
59
59
  "test": "turbo run _test",
60
- "_test": "vitest run",
61
- "_test:coverage": "vitest run --coverage",
60
+ "_test": "vitest run --project unit",
61
+ "_test:coverage": "vitest run --project unit --coverage",
62
62
  "test:mutation": "turbo run _test:mutation",
63
63
  "_test:mutation": "stryker run stryker.config.mjs",
64
- "test:watch": "vitest",
64
+ "test:watch": "vitest --project unit",
65
65
  "test:workers": "turbo run _test:workers",
66
66
  "_test:workers": "vitest run --config vitest.workers.config.ts",
67
- "prepare": "husky"
67
+ "prepare": "husky",
68
+ "test:corpus": "turbo run _test:corpus",
69
+ "_test:corpus": "vitest run --project corpus"
68
70
  },
69
71
  "packageManager": "pnpm@11.6.0",
70
72
  "dependencies": {
71
- "document-schema.js": "7.5.1"
73
+ "document-schema.js": "7.6.0"
72
74
  },
73
75
  "devDependencies": {
74
76
  "@arethetypeswrong/cli": "0.18.5",
@@ -77,10 +79,10 @@
77
79
  "@stryker-mutator/typescript-checker": "10.0.0",
78
80
  "@stryker-mutator/vitest-runner": "10.0.0",
79
81
  "@types/node": "26.2.0",
80
- "documents.js": "7.17.2",
82
+ "documents.js": "7.17.4",
81
83
  "eslint": "10.8.1",
82
84
  "husky": "9.1.7",
83
- "markdown-codec": "6.6.0",
85
+ "markdown-codec": "6.6.1",
84
86
  "publint": "0.3.22",
85
87
  "tsdown": "0.22.14",
86
88
  "turbo": "2.10.8",