mml 2.4.7 → 2.4.8
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.
- checksums.yaml +4 -4
- data/.gitattributes +12 -0
- data/.github/workflows/corpus.yml +106 -0
- data/.github/workflows/portable-models.yml +32 -0
- data/.github/workflows/release.yml +10 -10
- data/.rubocop.yml +5 -0
- data/README.adoc +14 -0
- data/lib/mml/opal.rb +1 -0
- data/lib/mml/portable.rb +53 -0
- data/lib/mml/version.rb +1 -1
- data/lib/mml.rb +1 -0
- data/mml.gemspec +2 -1
- data/model/portable/manifest.json +31 -0
- data/model/portable/mathml-v3.bundle.json +1 -0
- data/model/portable/mathml-v4.bundle.json +1 -0
- data/scripts/export_portable_models.rb +66 -0
- data/scripts/replay_corpus.rb +457 -0
- data/scripts/verify_portable_models.rb +38 -0
- metadata +12 -3
- data/CLAUDE.md +0 -145
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8cc80dd6916058d101e80a45c9cbbf3844278ae23b2253df13a6001b2220e0c0
|
|
4
|
+
data.tar.gz: 2e2e8225fc8d7ff8dea18e3e2660e64429d9041c937a9f18e2078d6a4d5751e5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f85bd1b87499a7e213335a193a166c9242aed2d5adeed81934c2f4af3b59d2eeb48f56c0c60a54f15fc4fa51849d359b6e7c5e6a69ab3f65780b941e8d2fef76
|
|
7
|
+
data.tar.gz: b29e27186265e89bb09c19305112cb2e14001ba6ac7ca5d60474f0b9b3f438acd4cd74597a2f49ecb0c61c9c664b773ac6379ffd27e8fdb16377fce4307f30d1
|
data/.gitattributes
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Preserve the bytes the pinned replay hashes on every checkout.
|
|
2
|
+
*.yaml text eol=lf
|
|
3
|
+
*.yml text eol=lf
|
|
4
|
+
*.json text eol=lf
|
|
5
|
+
*.parg text eol=lf
|
|
6
|
+
*.txt text eol=lf
|
|
7
|
+
*.rb text eol=lf
|
|
8
|
+
*.mml text eol=lf
|
|
9
|
+
*.gemspec text eol=lf
|
|
10
|
+
Gemfile text eol=lf
|
|
11
|
+
Rakefile text eol=lf
|
|
12
|
+
bin/* text eol=lf
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
name: corpus
|
|
2
|
+
|
|
3
|
+
# Replays the plurimath-testsuite stage generation pinned in
|
|
4
|
+
# spec/fixtures/testsuite-pin.yml: the testsuite's own validator checks the
|
|
5
|
+
# pin, tampered copies of the pin must fail that check, and every
|
|
6
|
+
# model-roundtrip row of the pinned generation must give its expected model
|
|
7
|
+
# and to_xml output (scripts/replay_corpus.rb).
|
|
8
|
+
|
|
9
|
+
on:
|
|
10
|
+
push:
|
|
11
|
+
branches: [ main ]
|
|
12
|
+
pull_request:
|
|
13
|
+
schedule:
|
|
14
|
+
- cron: "37 4 * * 1"
|
|
15
|
+
workflow_dispatch:
|
|
16
|
+
|
|
17
|
+
permissions:
|
|
18
|
+
contents: read
|
|
19
|
+
|
|
20
|
+
defaults:
|
|
21
|
+
run:
|
|
22
|
+
shell: bash
|
|
23
|
+
|
|
24
|
+
# The testsuite commit is a literal here (not read from a step output) so the
|
|
25
|
+
# checkout ref is fixed by this file; a step checks it against the pin.
|
|
26
|
+
env:
|
|
27
|
+
TESTSUITE_COMMIT: 337262eda0483ceaa43a02cc52362c5b721e5eb3
|
|
28
|
+
PIN: spec/fixtures/testsuite-pin.yml
|
|
29
|
+
|
|
30
|
+
jobs:
|
|
31
|
+
replay:
|
|
32
|
+
name: Pinned testsuite generation replay (${{ matrix.os }})
|
|
33
|
+
runs-on: ${{ matrix.os }}
|
|
34
|
+
strategy:
|
|
35
|
+
fail-fast: false
|
|
36
|
+
matrix:
|
|
37
|
+
os: [ ubuntu-latest, windows-latest, macos-latest ]
|
|
38
|
+
timeout-minutes: 30
|
|
39
|
+
|
|
40
|
+
steps:
|
|
41
|
+
- name: Keep line endings as committed
|
|
42
|
+
run: git config --global core.autocrlf false
|
|
43
|
+
|
|
44
|
+
- uses: actions/checkout@v4
|
|
45
|
+
|
|
46
|
+
- uses: ruby/setup-ruby@v1
|
|
47
|
+
with:
|
|
48
|
+
ruby-version: "3.4"
|
|
49
|
+
bundler-cache: true
|
|
50
|
+
|
|
51
|
+
- name: Check TESTSUITE_COMMIT matches the pin
|
|
52
|
+
run: |
|
|
53
|
+
pinned=$(ruby -ryaml -e 'puts YAML.safe_load_file(ARGV[0]).fetch("commit")' "$PIN")
|
|
54
|
+
test "$pinned" = "$TESTSUITE_COMMIT" || { echo "TESTSUITE_COMMIT=$TESTSUITE_COMMIT but $PIN has $pinned"; exit 1; }
|
|
55
|
+
|
|
56
|
+
- uses: actions/checkout@v4
|
|
57
|
+
with:
|
|
58
|
+
repository: plurimath/plurimath-testsuite
|
|
59
|
+
ref: ${{ env.TESTSUITE_COMMIT }}
|
|
60
|
+
path: tmp/testsuite
|
|
61
|
+
persist-credentials: false
|
|
62
|
+
|
|
63
|
+
- name: Validate the pin with the testsuite's validator
|
|
64
|
+
run: ruby tmp/testsuite/scripts/validate-stages.rb tmp/testsuite --pin "$PIN"
|
|
65
|
+
|
|
66
|
+
- name: A wrong commit, digest or generation fails the validator
|
|
67
|
+
run: |
|
|
68
|
+
mkdir -p tmp/pins
|
|
69
|
+
tamper() {
|
|
70
|
+
ruby -ryaml -e '
|
|
71
|
+
pin = YAML.safe_load_file(ARGV[0])
|
|
72
|
+
pin[ARGV[1]] = ARGV[1] == "generation" ? Integer(ARGV[2]) : ARGV[2]
|
|
73
|
+
File.write(ARGV[3], YAML.dump(pin))
|
|
74
|
+
' "$PIN" "$1" "$2" "tmp/pins/$3.yml"
|
|
75
|
+
if ruby tmp/testsuite/scripts/validate-stages.rb tmp/testsuite --pin "tmp/pins/$3.yml" > "tmp/pins/$3.log" 2>&1; then
|
|
76
|
+
echo "the validator accepted a pin with a wrong $1"; exit 1
|
|
77
|
+
fi
|
|
78
|
+
# The failure must be the pin's, not some other file's.
|
|
79
|
+
grep -A2 "FAIL tmp/pins/$3.yml" "tmp/pins/$3.log" || { cat "tmp/pins/$3.log"; exit 1; }
|
|
80
|
+
echo "ok: wrong $1 rejected"
|
|
81
|
+
}
|
|
82
|
+
tamper commit 0000000000000000000000000000000000000000 commit
|
|
83
|
+
tamper snapshot_digest "sha256:$(printf '0%.0s' {1..64})" digest
|
|
84
|
+
tamper generation 1 generation-1
|
|
85
|
+
tamper generation 99 generation-99
|
|
86
|
+
|
|
87
|
+
- name: Pin and replay specs
|
|
88
|
+
run: bundle exec rspec spec/corpus
|
|
89
|
+
|
|
90
|
+
- name: Replay every model-roundtrip row of the pinned generation
|
|
91
|
+
run: >-
|
|
92
|
+
mkdir -p tmp/corpus &&
|
|
93
|
+
bundle exec ruby scripts/replay_corpus.rb
|
|
94
|
+
--testsuite tmp/testsuite
|
|
95
|
+
--pin "$PIN"
|
|
96
|
+
--report tmp/corpus/replay-report.json
|
|
97
|
+
2>&1 | tee tmp/corpus/replay.log
|
|
98
|
+
|
|
99
|
+
- uses: actions/upload-artifact@v4
|
|
100
|
+
if: always()
|
|
101
|
+
with:
|
|
102
|
+
name: corpus-replay-${{ matrix.os }}
|
|
103
|
+
path: |
|
|
104
|
+
tmp/corpus
|
|
105
|
+
tmp/pins
|
|
106
|
+
if-no-files-found: warn
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
name: Portable MathML model graphs
|
|
2
|
+
on:
|
|
3
|
+
pull_request:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
permissions:
|
|
7
|
+
contents: read
|
|
8
|
+
jobs:
|
|
9
|
+
portable-models:
|
|
10
|
+
runs-on: ubuntu-24.04
|
|
11
|
+
timeout-minutes: 25
|
|
12
|
+
env:
|
|
13
|
+
LUTAML_MODEL_SOURCE: ${{ github.workspace }}/tmp/lutaml-model-candidate
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
with:
|
|
18
|
+
repository: lutaml/lutaml-model
|
|
19
|
+
ref: fd2989fd8478b1ecb2508d98fa2d66792c09c72b
|
|
20
|
+
path: tmp/lutaml-model-candidate
|
|
21
|
+
persist-credentials: false
|
|
22
|
+
- uses: ruby/setup-ruby@v1
|
|
23
|
+
with:
|
|
24
|
+
ruby-version: '3.3'
|
|
25
|
+
bundler-cache: true
|
|
26
|
+
- name: Regenerate the complete versioned graphs through the upstream API
|
|
27
|
+
run: bundle exec ruby scripts/export_portable_models.rb "$RUNNER_TEMP/portable-models"
|
|
28
|
+
- run: diff -r model/portable "$RUNNER_TEMP/portable-models"
|
|
29
|
+
- name: Qualify namespaces, mixed content, order and writer roundtrips
|
|
30
|
+
run: bundle exec ruby scripts/verify_portable_models.rb
|
|
31
|
+
- name: Record resolved dependencies
|
|
32
|
+
run: bundle list
|
|
@@ -1,19 +1,15 @@
|
|
|
1
|
-
#
|
|
2
|
-
#
|
|
1
|
+
# Based on the Cimas rubygems-release profile used by plurimath/amath.
|
|
2
|
+
# The RubyGems API key is passed as in amath, so metanorma/ci's
|
|
3
|
+
# rubygems-release.yml publishes through the API-key path. id-token: write
|
|
4
|
+
# stays so a trusted publisher can replace the key later.
|
|
3
5
|
name: release
|
|
4
6
|
|
|
5
|
-
permissions:
|
|
6
|
-
contents: write
|
|
7
|
-
packages: write
|
|
8
|
-
id-token: write
|
|
9
|
-
|
|
10
7
|
on:
|
|
11
8
|
workflow_dispatch:
|
|
12
9
|
inputs:
|
|
13
10
|
next_version:
|
|
14
11
|
description: |
|
|
15
|
-
Next release version. Possible values: x.y.z, major, minor, patch
|
|
16
|
-
Also, you can pass 'skip' to skip 'git tag' and do 'gem push' for the current version
|
|
12
|
+
Next release version. Possible values: x.y.z, major, minor, patch or pre|rc|etc
|
|
17
13
|
required: true
|
|
18
14
|
default: 'skip'
|
|
19
15
|
repository_dispatch:
|
|
@@ -21,8 +17,12 @@ on:
|
|
|
21
17
|
|
|
22
18
|
jobs:
|
|
23
19
|
release:
|
|
24
|
-
|
|
20
|
+
permissions:
|
|
21
|
+
contents: write
|
|
22
|
+
id-token: write
|
|
23
|
+
uses: metanorma/ci/.github/workflows/rubygems-release.yml@main
|
|
25
24
|
with:
|
|
26
25
|
next_version: ${{ github.event.inputs.next_version }}
|
|
27
26
|
secrets:
|
|
28
27
|
rubygems-api-key: ${{ secrets.PLURIMATH_CI_RUBYGEMS_API_KEY }}
|
|
28
|
+
pat_token: ${{ secrets.PLURIMATH_CI_PAT_TOKEN }}
|
data/.rubocop.yml
CHANGED
|
@@ -16,3 +16,8 @@ AllCops:
|
|
|
16
16
|
- 'spec/fixtures/mml3-testsuite/**/*'
|
|
17
17
|
- 'spec/fixtures/mmlcore-testsuite/**/*'
|
|
18
18
|
- 'spec/tasks/**/*'
|
|
19
|
+
|
|
20
|
+
# .gitattributes checks Ruby files out with LF on every OS, so check for LF
|
|
21
|
+
# rather than the platform-native line ending.
|
|
22
|
+
Layout/EndOfLine:
|
|
23
|
+
EnforcedStyle: lf
|
data/README.adoc
CHANGED
|
@@ -657,6 +657,20 @@ Locally it needs an `@lutaml/lutaml-model` compiled with Opal from a
|
|
|
657
657
|
lutaml-model version this gem accepts, for example a local build of
|
|
658
658
|
https://github.com/lutaml/lutaml-model-js[lutaml-model-js].
|
|
659
659
|
|
|
660
|
+
== Portable model declarations
|
|
661
|
+
|
|
662
|
+
`Mml::Portable.bundle(version: 3)` returns checksum-verified UTF-8 LML bundle
|
|
663
|
+
bytes for a compatible target importer or generator. The shipped MathML 3 and 4
|
|
664
|
+
graphs contain 194 and 195 models. Their producer, source revision and pinned
|
|
665
|
+
upstream LML candidate are recorded in `model/portable/manifest.json`.
|
|
666
|
+
Portable bundle generation currently uses an open upstream candidate; the
|
|
667
|
+
ordinary Ruby parser dependency range is unchanged.
|
|
668
|
+
|
|
669
|
+
Regenerate from that pinned framework checkout with
|
|
670
|
+
`LUTAML_MODEL_SOURCE=/path/to/lutaml-model bundle exec ruby scripts/export_portable_models.rb model/portable`.
|
|
671
|
+
The dedicated CI job checks the complete graphs and six namespace,
|
|
672
|
+
mixed-content, element-order and imported-writer roundtrips.
|
|
673
|
+
|
|
660
674
|
== Contributing
|
|
661
675
|
|
|
662
676
|
Bug reports and pull requests are welcome on GitHub at
|
data/lib/mml/opal.rb
CHANGED
data/lib/mml/portable.rb
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
if RUBY_ENGINE != "opal"
|
|
4
|
+
require "digest"
|
|
5
|
+
require "json"
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
module Mml
|
|
9
|
+
# Immutable model declarations for supported portable LML consumers.
|
|
10
|
+
# Reading the bundle does not load or implement a target model runtime.
|
|
11
|
+
module Portable
|
|
12
|
+
class ArtifactError < Mml::Error; end
|
|
13
|
+
|
|
14
|
+
DIRECTORY = RUBY_ENGINE == "opal" ? nil : File.expand_path("../../model/portable", __dir__)
|
|
15
|
+
FORMAT = "mml-portable-models/1"
|
|
16
|
+
|
|
17
|
+
module_function
|
|
18
|
+
|
|
19
|
+
def manifest
|
|
20
|
+
if RUBY_ENGINE == "opal"
|
|
21
|
+
raise ArtifactError, "load model bundle JSON through the target runtime; Ruby filesystem access is unavailable"
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
data = JSON.parse(File.read(File.join(DIRECTORY, "manifest.json"), encoding: "UTF-8"))
|
|
25
|
+
unless data.is_a?(Hash) && data["format"] == FORMAT
|
|
26
|
+
raise ArtifactError, "unsupported portable model manifest"
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
data
|
|
30
|
+
rescue SystemCallError, JSON::ParserError => e
|
|
31
|
+
raise ArtifactError, "cannot load portable model manifest: #{e.message}"
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Returns checksum-verified UTF-8 LML bundle bytes for a target generator.
|
|
35
|
+
def bundle(version: 3)
|
|
36
|
+
key = version.to_s
|
|
37
|
+
record = manifest.fetch("versions").fetch(key) do
|
|
38
|
+
raise ArgumentError, "no portable model bundle for MathML #{version} (supported: 3, 4)"
|
|
39
|
+
end
|
|
40
|
+
filename = "mathml-v#{key}.bundle.json"
|
|
41
|
+
raise ArtifactError, "unexpected portable model path" unless record.fetch("path") == filename
|
|
42
|
+
|
|
43
|
+
bytes = File.binread(File.join(DIRECTORY, filename))
|
|
44
|
+
unless Digest::SHA256.hexdigest(bytes) == record.fetch("sha256")
|
|
45
|
+
raise ArtifactError, "checksum mismatch: #{filename}"
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
bytes.force_encoding(Encoding::UTF_8).freeze
|
|
49
|
+
rescue SystemCallError, KeyError, TypeError => e
|
|
50
|
+
raise ArtifactError, "cannot load portable model bundle: #{e.message}"
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
data/lib/mml/version.rb
CHANGED
data/lib/mml.rb
CHANGED
|
@@ -33,6 +33,7 @@ module Mml
|
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
autoload :Namespace, "mml/namespace"
|
|
36
|
+
autoload :Portable, "mml/portable"
|
|
36
37
|
autoload :CommonElements, "mml/common_elements"
|
|
37
38
|
autoload :ContextOptions, "mml/context_options"
|
|
38
39
|
autoload :ContextConfiguration, "mml/context_configuration"
|
data/mml.gemspec
CHANGED
|
@@ -20,9 +20,10 @@ Gem::Specification.new do |spec|
|
|
|
20
20
|
|
|
21
21
|
# Specify which files should be added to the gem when it is released.
|
|
22
22
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
23
|
+
local_context = %w[AGENTS.md CLAUDE.md .codex-context .codex .claude]
|
|
23
24
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
|
24
25
|
`git ls-files -z`.split("\x0").reject do |f|
|
|
25
|
-
f.match(%r{^(test|spec|features)/})
|
|
26
|
+
f.match?(%r{^(test|spec|features)/}) || (f.split("/") & local_context).any?
|
|
26
27
|
end
|
|
27
28
|
end
|
|
28
29
|
spec.bindir = "exe"
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"format": "mml-portable-models/1",
|
|
3
|
+
"source_repository": "https://github.com/plurimath/mml",
|
|
4
|
+
"source_revision": "a88197810737e7eb809bbb5f887703a25beac3db",
|
|
5
|
+
"source_version": "2.4.7",
|
|
6
|
+
"framework_repository": "https://github.com/lutaml/lutaml-model",
|
|
7
|
+
"framework_revision": "fd2989fd8478b1ecb2508d98fa2d66792c09c72b",
|
|
8
|
+
"framework_status": "open candidate; not a released dependency",
|
|
9
|
+
"versions": {
|
|
10
|
+
"3": {
|
|
11
|
+
"path": "mathml-v3.bundle.json",
|
|
12
|
+
"sha256": "ee79ea4bcc910f91f1b118ae0accc5baeb058501c76f4d233e5c4724ef74aab4",
|
|
13
|
+
"bundle_checksum": "sha256:23bc156260b4dab3933351dadbae27a8f146c239875c630b2d76adcb27b778a4",
|
|
14
|
+
"models": 194,
|
|
15
|
+
"root": "Mml::V3::Math@mml_v3",
|
|
16
|
+
"capabilities": [
|
|
17
|
+
"xml"
|
|
18
|
+
]
|
|
19
|
+
},
|
|
20
|
+
"4": {
|
|
21
|
+
"path": "mathml-v4.bundle.json",
|
|
22
|
+
"sha256": "7b1041645156d9df7b94a8c9c3acce6256b12d1df5f6cc611d39465e0556e26a",
|
|
23
|
+
"bundle_checksum": "sha256:5b823b450161072ff2adbdf4cf5b765909f4c85a7ea4e53dd17706a86165404c",
|
|
24
|
+
"models": 195,
|
|
25
|
+
"root": "Mml::V4::Math@mml_v4",
|
|
26
|
+
"capabilities": [
|
|
27
|
+
"xml"
|
|
28
|
+
]
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|