diff --git a/.dockerignore b/.dockerignore index ce58622..bb7ab21 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,9 +1,12 @@ .git -.venv -.tox -.pytest_cache -**/__pycache__ **/.venv +**/.tox +**/.pytest_cache +**/.mypy_cache +**/__pycache__ **/dist -docs/_build -.interop +**/site +**/docs/_build +**/.interop +packages/modsim/output +packages/modsim/contrib/**/*.pdf diff --git a/.github/actions/setup-uv/action.yml b/.github/actions/setup-uv/action.yml index d704a2b..8396d37 100644 --- a/.github/actions/setup-uv/action.yml +++ b/.github/actions/setup-uv/action.yml @@ -1,7 +1,10 @@ name: "setup-uv" -description: "Set up Python and sync the locked uv environment." +description: "Set up Python and sync one workspace member's locked environment." inputs: + package: + required: true + description: "The workspace member to install: modpoll, modsim or modpoll-wot" python-version: required: false description: "The Python version to use" @@ -17,5 +20,5 @@ runs: enable-cache: true cache-dependency-glob: uv.lock - name: Install dependencies - run: uv sync --locked --all-extras --all-groups + run: uv sync --locked --all-extras --all-groups --package ${{ inputs.package }} shell: bash diff --git a/.github/workflows/preview-app.yml b/.github/workflows/modpoll-release.yml similarity index 74% rename from .github/workflows/preview-app.yml rename to .github/workflows/modpoll-release.yml index 8d70a1e..0fae62a 100644 --- a/.github/workflows/preview-app.yml +++ b/.github/workflows/modpoll-release.yml @@ -1,18 +1,24 @@ -name: preview-app +name: modpoll-release +# Releases modpoll from a `modpoll-v` tag. A push to v2 that changes this file only republishes the +# image of the current version. Tags before TOOL-01 were `v`; the scripts still take that form ($TAG). on: push: - tags: ['v2.*'] + tags: ['modpoll-v2.*'] branches: [v2] - paths: ['.github/workflows/preview-app.yml'] + paths: ['.github/workflows/modpoll-release.yml'] permissions: contents: read concurrency: group: preview-app-publish cancel-in-progress: false +defaults: + run: + working-directory: packages/modpoll jobs: candidate: runs-on: ubuntu-latest outputs: + git-tag: ${{ steps.release.outputs.git-tag }} tag: ${{ steps.release.outputs.tag }} image-version: ${{ steps.release.outputs.image-version }} steps: @@ -21,16 +27,19 @@ jobs: fetch-depth: 0 - id: release run: | - tag="$GITHUB_REF_NAME" - if [ "$tag" = v2 ]; then - tag="v$(python -c 'import tomllib; print(tomllib.load(open("pyproject.toml", "rb"))["project"]["version"])')" + if [ "$GITHUB_REF_TYPE" = tag ]; then + git_tag="$GITHUB_REF_NAME" + else + git_tag="modpoll-v$(python -c 'import tomllib; print(tomllib.load(open("pyproject.toml", "rb"))["project"]["version"])')" fi - git rev-parse --verify "refs/tags/$tag^{commit}" - git merge-base --is-ancestor "refs/tags/$tag^{commit}" origin/v2 + git rev-parse --verify "refs/tags/$git_tag^{commit}" + git merge-base --is-ancestor "refs/tags/$git_tag^{commit}" origin/v2 + tag="${git_tag#modpoll-}" image_version="${tag#v}" if [ "$GITHUB_REF_NAME" = v2 ]; then image_version="$image_version-r1" fi + echo "git-tag=$git_tag" >> "$GITHUB_OUTPUT" echo "tag=$tag" >> "$GITHUB_OUTPUT" echo "image-version=$image_version" >> "$GITHUB_OUTPUT" publish: @@ -45,44 +54,48 @@ jobs: ref: ${{ github.ref }} fetch-depth: 0 - uses: ./.github/actions/setup-uv + with: + package: modpoll - name: Require an accepted v2 preview candidate env: GH_TOKEN: ${{ github.token }} - TAG: ${{ github.ref_name }} + TAG: ${{ needs.candidate.outputs.tag }} run: | git merge-base --is-ancestor "$GITHUB_SHA" origin/v2 python .github/scripts/preview-release.py guard "$TAG" - name: Build portable distributions - run: uv build --no-sources + run: uv build --no-sources --out-dir dist - uses: actions/upload-artifact@v4 with: name: application-distributions - path: dist/* + path: packages/modpoll/dist/* - name: Verify wheel dependencies and installation run: | python .github/scripts/check-portable-wheel.py dist/*.whl + dist="$PWD/dist" cd "$RUNNER_TEMP" - uv run --isolated --with "$GITHUB_WORKSPACE"/dist/*.whl modpoll --version - uv run --isolated --with "$GITHUB_WORKSPACE"/dist/*.tar.gz modpoll --version + uv run --isolated --with "$dist"/*.whl modpoll --version + uv run --isolated --with "$dist"/*.tar.gz modpoll --version - name: Check immutable version id: pypi env: - TAG: ${{ github.ref_name }} + TAG: ${{ needs.candidate.outputs.tag }} run: python .github/scripts/preview-release.py pypi "$TAG" - name: Publish application to PyPI if: steps.pypi.outputs.state == 'absent' env: UV_PUBLISH_TOKEN: ${{ secrets.PYPI_TOKEN }} - run: uv publish --no-progress + run: uv publish --no-progress dist/* - name: Record functional prerelease env: GH_TOKEN: ${{ github.token }} - TAG: ${{ github.ref_name }} + GIT_TAG: ${{ needs.candidate.outputs.git-tag }} + TAG: ${{ needs.candidate.outputs.tag }} run: | - if ! gh release view "$TAG" >/dev/null 2>&1; then - gh release create "$TAG" --verify-tag --prerelease --latest=false --title "Modpoll ${TAG#v} — WoT configuration preview" --notes-file docs/preview-notes.md + if ! gh release view "$GIT_TAG" >/dev/null 2>&1; then + gh release create "$GIT_TAG" --verify-tag --prerelease --latest=false --title "Modpoll ${TAG#v} — WoT configuration preview" --notes-file docs/preview-notes.md fi - gh release upload "$TAG" dist/* + gh release upload "$GIT_TAG" dist/* image: needs: [candidate, publish] if: ${{ !cancelled() && needs.candidate.result == 'success' && (needs.publish.result == 'success' || (github.ref_name == 'v2' && needs.publish.result == 'skipped')) }} @@ -107,12 +120,13 @@ jobs: run: | python .github/scripts/check_release_version.py "$TAG" image="$REGISTRY/$OWNER/modpoll:$IMAGE_VERSION" + # The image installs from the workspace lock, so it builds from the repository root. if docker buildx imagetools inspect "$image" >/dev/null 2>&1; then docker run --rm "$image" | grep -Fx "v${TAG#v}" else - docker buildx build --load --platform linux/amd64 -t modpoll-preview-smoke . + docker buildx build --load --platform linux/amd64 -f Dockerfile -t modpoll-preview-smoke ../.. docker run --rm modpoll-preview-smoke | grep -Fx "v${TAG#v}" - docker buildx build --platform linux/amd64,linux/arm64 -t "$image" --push . + docker buildx build --platform linux/amd64,linux/arm64 -f Dockerfile -t "$image" --push ../.. fi docs: needs: [candidate, publish] @@ -126,15 +140,17 @@ jobs: steps: - uses: actions/checkout@v4 with: - ref: ${{ needs.candidate.outputs.tag }} + ref: ${{ needs.candidate.outputs.git-tag }} - uses: ./.github/actions/setup-uv + with: + package: modpoll - uses: ./.github/actions/setup-pandoc - name: Build preview documentation run: make docs - uses: actions/checkout@v4 with: ref: gh-pages - path: .pages + path: packages/modpoll/.pages - name: Assemble both versions while preserving the vocabulary run: | mkdir .site @@ -143,7 +159,8 @@ jobs: test -f .site/vocab/wot-modbus/acquisition-0.1.json test -f .site/vocab/wot-modbus/contract-0.1.txt wot_version=$(uv run --locked --no-sync python -c 'import importlib.metadata as m; print(m.version("modpoll-wot"))') - wot_source="https://raw.githubusercontent.com/top-maker/modpoll-wot/v$wot_version" + # modpoll-wot is released from this repository since TOOL-01, under packages/modpoll-wot. + wot_source="https://raw.githubusercontent.com/top-maker/modpoll/modpoll-wot-v$wot_version/packages/modpoll-wot" curl -fsSL "$wot_source/modpoll_wot/schemas/acquisition-0.2.json" -o vocab/wot-modbus/acquisition-0.2.json curl -fsSL "$wot_source/profile.md" -o vocab/wot-modbus/contract-0.2.txt python .github/scripts/assemble-docs.py docs/_build/html .site v2 --vocab vocab @@ -151,7 +168,7 @@ jobs: - uses: peaceiris/actions-gh-pages@v4 with: github_token: ${{ github.token }} - publish_dir: .site + publish_dir: packages/modpoll/.site acceptance: needs: [candidate, publish, image, docs] if: ${{ !cancelled() && needs.docs.result == 'success' && needs.image.result == 'success' }} @@ -159,7 +176,7 @@ jobs: steps: - uses: actions/checkout@v4 with: - ref: ${{ needs.candidate.outputs.tag }} + ref: ${{ needs.candidate.outputs.git-tag }} - uses: astral-sh/setup-uv@v6 with: version: 0.11.19 @@ -168,12 +185,12 @@ jobs: - uses: actions/checkout@v4 with: ref: 0b42099e8b22eaaa4788a9f91e8bf60b4870204c - path: .interop/modpoll-1x + path: packages/modpoll/.interop/modpoll-1x - uses: actions/checkout@v4 with: repository: top-maker/modsim ref: 92fe5d4c417b2691693feb2b6bd93fd1f54439fe - path: .interop/modsim + path: packages/modpoll/.interop/modsim - name: Download published application and install isolated fixtures env: TAG: ${{ needs.candidate.outputs.tag }} @@ -194,9 +211,9 @@ jobs: docker run -d --name preview-acceptance -p 127.0.0.1:18883:1883 -v "$RUNNER_TEMP/mqtt.conf:/mosquitto/config/mosquitto.conf:ro" eclipse-mosquitto:2 - name: Verify the registry-installed application without application source env: - MODSIM_SOURCE: ${{ github.workspace }}/.interop/modsim - MODSIM_PYTHON: ${{ github.workspace }}/.interop/modsim/.venv/bin/python - MODPOLL_1X_SOURCE: ${{ github.workspace }}/.interop/modpoll-1x + MODSIM_SOURCE: ${{ github.workspace }}/packages/modpoll/.interop/modsim + MODSIM_PYTHON: ${{ github.workspace }}/packages/modpoll/.interop/modsim/.venv/bin/python + MODPOLL_1X_SOURCE: ${{ github.workspace }}/packages/modpoll/.interop/modpoll-1x MODPOLL_MQTT_HOST: 127.0.0.1 MODPOLL_MQTT_PORT: '18883' MODPOLL_MQTT_INTEGRATION: '1' diff --git a/.github/workflows/modpoll-wot-release.yml b/.github/workflows/modpoll-wot-release.yml new file mode 100644 index 0000000..4af2c60 --- /dev/null +++ b/.github/workflows/modpoll-wot-release.yml @@ -0,0 +1,59 @@ +name: modpoll-wot-release + +on: + push: + tags: ['modpoll-wot-v*'] + +permissions: + contents: read + +concurrency: + group: release + cancel-in-progress: false + +defaults: + run: + working-directory: packages/modpoll-wot + +jobs: + publish: + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Require a tag on v2 that matches the package version + run: | + git merge-base --is-ancestor "$GITHUB_SHA" origin/v2 + version=$(python3 -c 'import tomllib; print(tomllib.load(open("pyproject.toml", "rb"))["project"]["version"])') + test "$GITHUB_REF_NAME" = "modpoll-wot-v$version" + echo "VERSION=$version" >> "$GITHUB_ENV" + - uses: jdx/mise-action@5228313ee0372e111a38da051671ca30fc5a96db # v3.6.3 + with: + version: '2026.10.1' + working_directory: packages/modpoll-wot + - run: mise run check + - name: Publish to PyPI without replacing existing files + env: + UV_PUBLISH_TOKEN: ${{ secrets.PYPI_TOKEN }} + run: uv publish --no-progress --check-url https://pypi.org/simple/ dist/* + - name: Verify the registry installation + timeout-minutes: 15 + run: | + fixture="$PWD/tests/fixtures/modsim.tm.json" + cd "$RUNNER_TEMP" + for attempt in $(seq 1 20); do + if uv run --isolated --no-project --no-cache --with "modpoll-wot==$VERSION" modpoll-wot validate "$fixture" --profile; then + exit 0 + fi + sleep 30 + done + exit 1 + - name: Record a GitHub prerelease + env: + GH_TOKEN: ${{ github.token }} + run: | + gh release view "$GITHUB_REF_NAME" >/dev/null 2>&1 || + gh release create "$GITHUB_REF_NAME" dist/* --verify-tag --prerelease --title "modpoll-wot $VERSION" --notes "See packages/modpoll-wot/CONTRACT.md and profile.md at this tag." diff --git a/.github/workflows/modpoll-wot.yml b/.github/workflows/modpoll-wot.yml new file mode 100644 index 0000000..3c5caff --- /dev/null +++ b/.github/workflows/modpoll-wot.yml @@ -0,0 +1,88 @@ +name: modpoll-wot + +on: + push: + branches: [v2] + paths: + - packages/modpoll-wot/** + - pyproject.toml + - uv.lock + - .github/workflows/modpoll-wot.yml + pull_request: + paths: + - packages/modpoll-wot/** + - pyproject.toml + - uv.lock + - .github/workflows/modpoll-wot.yml + +permissions: + contents: read + +defaults: + run: + working-directory: packages/modpoll-wot + +jobs: + test: + name: modpoll-wot test (${{ matrix.python-version }}) + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: ['3.10', '3.14'] + steps: + - uses: actions/checkout@v4 + - uses: astral-sh/setup-uv@v6 + with: + version: 0.11.19 + python-version: ${{ matrix.python-version }} + - run: uv sync --locked + - run: uv run --locked pytest -q + + package: + name: modpoll-wot package + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: jdx/mise-action@5228313ee0372e111a38da051671ca30fc5a96db # v3.6.3 + with: + version: '2026.10.1' + working_directory: packages/modpoll-wot + - run: mise run check + - uses: actions/upload-artifact@v4 + with: + name: distributions + path: packages/modpoll-wot/dist/* + + # The consumers run their own tests against the candidate wheel instead of the workspace source. + consumers: + name: consumer (${{ matrix.package }}) + needs: package + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - package: modpoll + prepare: 'true' + - package: modsim + prepare: uv run --no-sync python tools/fetch-models.py + defaults: + run: + working-directory: packages/${{ matrix.package }} + steps: + - uses: actions/checkout@v4 + - uses: actions/download-artifact@v4 + with: + name: distributions + path: ${{ runner.temp }}/dist + - uses: astral-sh/setup-uv@v6 + with: + version: 0.11.19 + python-version: '3.12' + - name: Install the consumer with the candidate interpreter + run: | + uv sync --locked --all-extras --all-groups + uv pip install --reinstall --no-deps "$RUNNER_TEMP"/dist/*.whl + - run: ${{ matrix.prepare }} + - run: uv run --no-sync pytest -q tests diff --git a/.github/workflows/main.yml b/.github/workflows/modpoll.yml similarity index 70% rename from .github/workflows/main.yml rename to .github/workflows/modpoll.yml index e617ac2..2dd77a4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/modpoll.yml @@ -1,11 +1,32 @@ -name: main +name: modpoll on: push: - branches: [main, v2] + branches: [v2] + paths: + - packages/modpoll/** + - packages/modpoll-wot/** + - pyproject.toml + - uv.lock + - .pre-commit-config.yaml + - .github/actions/** + - .github/workflows/modpoll.yml pull_request: types: [opened, synchronize, reopened, ready_for_review] + paths: + - packages/modpoll/** + - packages/modpoll-wot/** + - pyproject.toml + - uv.lock + - .pre-commit-config.yaml + - .github/actions/** + - .github/workflows/modpoll.yml +defaults: + run: + working-directory: packages/modpoll + +# Job names are the check names the release guard requires (packages/modpoll/.github/scripts/preview-release.py). jobs: quality-check: runs-on: ubuntu-latest @@ -17,6 +38,8 @@ jobs: - name: Set up uv uses: ./.github/actions/setup-uv + with: + package: modpoll - name: Run checks run: make check @@ -41,6 +64,7 @@ jobs: - name: Set up uv uses: ./.github/actions/setup-uv with: + package: modpoll python-version: ${{ matrix.python-version }} - name: Test with tox @@ -56,6 +80,8 @@ jobs: - name: Set up uv uses: ./.github/actions/setup-uv + with: + package: modpoll - name: Set up pandoc uses: ./.github/actions/setup-pandoc @@ -63,6 +89,7 @@ jobs: - name: Build documentation run: make docs + # Unchanged by TOOL-01: the interop checks keep their pinned 1.x baseline and simulator fixture. modsim-equivalence: runs-on: ubuntu-latest permissions: @@ -70,18 +97,20 @@ jobs: steps: - uses: actions/checkout@v4 - uses: ./.github/actions/setup-uv + with: + package: modpoll - name: Check out the 1.x baseline uses: actions/checkout@v4 with: repository: top-maker/modpoll ref: 0b42099e8b22eaaa4788a9f91e8bf60b4870204c - path: .interop/modpoll-1x + path: packages/modpoll/.interop/modpoll-1x - name: Check out the simulator fixture uses: actions/checkout@v4 with: repository: top-maker/modsim ref: 92fe5d4c417b2691693feb2b6bd93fd1f54439fe - path: .interop/modsim + path: packages/modpoll/.interop/modsim - name: Install isolated baseline and simulator environments run: | uv venv .interop/modpoll-1x/.venv @@ -97,13 +126,13 @@ jobs: with: node-version: '24.16.0' cache: npm - cache-dependency-path: tools/wot-interop/package-lock.json + cache-dependency-path: packages/modpoll/tools/wot-interop/package-lock.json - name: Install locked node-wot interop tools run: npm ci --prefix tools/wot-interop --ignore-scripts --no-audit --no-fund - name: Verify the pinned contract and external TD read/write semantics env: - MODSIM_PYTHON: ${{ github.workspace }}/.interop/modsim/.venv/bin/python - MODSIM_SOURCE: ${{ github.workspace }}/.interop/modsim + MODSIM_PYTHON: ${{ github.workspace }}/packages/modpoll/.interop/modsim/.venv/bin/python + MODSIM_SOURCE: ${{ github.workspace }}/packages/modpoll/.interop/modsim run: | uv run --locked --no-sync python -m modpoll_wot validate examples/modsim.tm.json --profile uv run --locked --no-sync pytest -q tests/test_profile_interop.py --junitxml=.interop/profile-results.xml @@ -112,9 +141,9 @@ jobs: uv run --locked --no-sync python tools/verify_modsim_equivalence.py --modpoll-1x .interop/modpoll-1x --modsim .interop/modsim --report .interop/report.json - name: Verify lifecycle, transports and existing write commands env: - MODSIM_PYTHON: ${{ github.workspace }}/.interop/modsim/.venv/bin/python - MODSIM_SOURCE: ${{ github.workspace }}/.interop/modsim - MODPOLL_1X_SOURCE: ${{ github.workspace }}/.interop/modpoll-1x + MODSIM_PYTHON: ${{ github.workspace }}/packages/modpoll/.interop/modsim/.venv/bin/python + MODSIM_SOURCE: ${{ github.workspace }}/packages/modpoll/.interop/modsim + MODPOLL_1X_SOURCE: ${{ github.workspace }}/packages/modpoll/.interop/modpoll-1x run: uv run --locked --no-sync pytest -q tests/test_process_lifecycle.py tests/test_modsim_interop.py tests/test_wot_reading_interop.py tests/test_transport_interop.py tests/test_failure_interop.py --junitxml=.interop/transport-results.xml - name: Start private MQTT acceptance broker run: | @@ -122,9 +151,9 @@ jobs: docker run -d --name modpoll-mqtt-${{ github.run_id }}-${{ github.run_attempt }} -p 127.0.0.1:18883:1883 -v "$RUNNER_TEMP/modpoll-mqtt.conf:/mosquitto/config/mosquitto.conf:ro" eclipse-mosquitto:2 - name: Verify MQTT equivalence, commands and broker recovery env: - MODSIM_PYTHON: ${{ github.workspace }}/.interop/modsim/.venv/bin/python - MODSIM_SOURCE: ${{ github.workspace }}/.interop/modsim - MODPOLL_1X_SOURCE: ${{ github.workspace }}/.interop/modpoll-1x + MODSIM_PYTHON: ${{ github.workspace }}/packages/modpoll/.interop/modsim/.venv/bin/python + MODSIM_SOURCE: ${{ github.workspace }}/packages/modpoll/.interop/modsim + MODPOLL_1X_SOURCE: ${{ github.workspace }}/packages/modpoll/.interop/modpoll-1x MODPOLL_MQTT_HOST: 127.0.0.1 MODPOLL_MQTT_PORT: '18883' MODPOLL_MQTT_INTEGRATION: '1' @@ -137,7 +166,7 @@ jobs: with: name: modsim-equivalence path: | - .interop/report.json - .interop/mqtt-results.xml - .interop/transport-results.xml - .interop/profile-results.xml + packages/modpoll/.interop/report.json + packages/modpoll/.interop/mqtt-results.xml + packages/modpoll/.interop/transport-results.xml + packages/modpoll/.interop/profile-results.xml diff --git a/.github/workflows/modsim-acceptance.yml b/.github/workflows/modsim-acceptance.yml new file mode 100644 index 0000000..c62122e --- /dev/null +++ b/.github/workflows/modsim-acceptance.yml @@ -0,0 +1,100 @@ +name: modsim acceptance + +on: + push: + branches: [v2] + paths: + - packages/modsim/** + - packages/modpoll-wot/** + - pyproject.toml + - uv.lock + - .github/actions/** + - .github/workflows/modsim-acceptance.yml + pull_request: + paths: + - packages/modsim/** + - packages/modpoll-wot/** + - pyproject.toml + - uv.lock + - .github/actions/** + - .github/workflows/modsim-acceptance.yml + workflow_dispatch: + +permissions: + contents: read + +defaults: + run: + working-directory: packages/modsim + +jobs: + single-device: + name: single-device (${{ matrix.os }}) + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + steps: + - uses: actions/checkout@v4 + - uses: astral-sh/setup-uv@v6 + with: + version: 0.11.19 + python-version: '3.12' + - name: Build and install isolated wheel + shell: bash + run: | + uv build --wheel --no-sources --out-dir dist + uv venv "$RUNNER_TEMP/installed-modsim" + if [ "$RUNNER_OS" = Windows ]; then python_path="$RUNNER_TEMP/installed-modsim/Scripts/python.exe"; else python_path="$RUNNER_TEMP/installed-modsim/bin/python"; fi + uv pip install --python "$python_path" dist/*.whl pytest + echo "MODSIM_INSTALLED_PYTHON=$python_path" >> "$GITHUB_ENV" + - name: Verify installed CLI outside application source + shell: bash + env: + MODSIM_CATALOG_PLATFORM: '1' + run: | + mkdir -p "$RUNNER_TEMP/cli-acceptance/tests" "$RUNNER_TEMP/cli-acceptance/examples" + cp tests/test_catalog_platform.py "$RUNNER_TEMP/cli-acceptance/tests/" + cp examples/model-source.yaml "$RUNNER_TEMP/cli-acceptance/examples/" + cd "$RUNNER_TEMP/cli-acceptance" + "$MODSIM_INSTALLED_PYTHON" -c 'import modsim; assert "site-packages" in modsim.__file__, modsim.__file__' + "$MODSIM_INSTALLED_PYTHON" -m pytest tests/test_catalog_platform.py -v + catalog-interop: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/setup-uv + with: + package: modsim + # Unchanged by TOOL-01: the independent clients stay pinned to the modpoll commit and release they used. + - uses: actions/checkout@v4 + with: + repository: top-maker/modpoll + ref: 93daa74bc859fe8a5704f3e94e4f6eb0df797ec2 + path: packages/modsim/.interop/modpoll + - uses: actions/setup-node@v4 + with: + node-version: '24' + - run: npm ci --prefix .interop/modpoll/tools/wot-interop --ignore-scripts --no-audit --no-fund + - name: Install independent public modpoll + run: | + uv venv "$RUNNER_TEMP/modpoll" + uv pip install --python "$RUNNER_TEMP/modpoll/bin/python" 'modpoll==2.0.0a2' + - name: Test fixed public model with independent clients + run: | + uv build --wheel --no-sources --out-dir dist + uv venv "$RUNNER_TEMP/modsim" + uv pip install --python "$RUNNER_TEMP/modsim/bin/python" dist/*.whl + mkdir -p "$RUNNER_TEMP/catalog-acceptance/tools" "$RUNNER_TEMP/catalog-acceptance/examples" + cp tools/catalog-interop.py tools/fetch-models.py "$RUNNER_TEMP/catalog-acceptance/tools/" + cp examples/model-source.yaml "$RUNNER_TEMP/catalog-acceptance/examples/" + reader="$PWD/.interop/modpoll/tools/wot-interop/read-write.cjs" + cd "$RUNNER_TEMP/catalog-acceptance" + "$RUNNER_TEMP/modsim/bin/python" tools/fetch-models.py --output "$RUNNER_TEMP/catalog-acceptance/inputs" + "$RUNNER_TEMP/modsim/bin/python" tools/catalog-interop.py --modpoll-python "$RUNNER_TEMP/modpoll/bin/python" --node-reader "$reader" --output "$RUNNER_TEMP/catalog-interop.json" + - uses: actions/upload-artifact@v4 + with: + name: catalog-interop + path: | + ${{ runner.temp }}/catalog-interop.json diff --git a/.github/workflows/modsim-release.yml b/.github/workflows/modsim-release.yml new file mode 100644 index 0000000..ec61cc5 --- /dev/null +++ b/.github/workflows/modsim-release.yml @@ -0,0 +1,179 @@ +name: modsim-release +# Releases modsim from a `modsim-v` tag. Tags before TOOL-01 were `v` and now carry the +# `modsim-` prefix too; the scripts still take the `v` form ($TAG). + +on: + push: + tags: ['modsim-v2.*'] + workflow_dispatch: + inputs: + tag: + description: 'Existing preview tag to validate without publishing again' + type: string + required: true + default: modsim-v2.0.0a1 + +concurrency: + group: modsim-preview + cancel-in-progress: false + +permissions: + contents: read + +defaults: + run: + working-directory: packages/modsim + +jobs: + publish: + if: github.event_name == 'push' + runs-on: ubuntu-latest + permissions: + contents: write + actions: read + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.ref }} + fetch-depth: 0 + - uses: ./.github/actions/setup-uv + with: + package: modsim + - name: Require accepted candidate + env: + GH_TOKEN: ${{ github.token }} + GIT_TAG: ${{ github.ref_name }} + run: python .github/scripts/preview-release.py guard "${GIT_TAG#modsim-}" + - run: uv build --no-sources --clear --out-dir dist + - uses: actions/upload-artifact@v4 + with: + name: preview-distributions + path: packages/modsim/dist/* + - name: Verify portable distributions + run: | + dist="$PWD/dist" + cd "$RUNNER_TEMP" + uv run --isolated --with "$dist"/*.whl modsim --version + uv run --isolated --with "$dist"/*.tar.gz modsim --version + - name: Check immutable version + id: registry + env: + GIT_TAG: ${{ github.ref_name }} + run: python .github/scripts/preview-release.py immutable "${GIT_TAG#modsim-v}" + - name: Publish PyPI package + if: steps.registry.outputs.exists == 'false' + env: + UV_PUBLISH_TOKEN: ${{ secrets.PYPI_TOKEN }} + run: uv publish --no-progress dist/* + - name: Publish GitHub prerelease + env: + GH_TOKEN: ${{ github.token }} + GIT_TAG: ${{ github.ref_name }} + run: | + if ! gh release view "$GIT_TAG" >/dev/null 2>&1; then + gh release create "$GIT_TAG" --verify-tag --prerelease --latest=false --title "Modsim ${GIT_TAG#modsim-v}" --notes-file docs/preview-notes.md + fi + gh release upload "$GIT_TAG" dist/* + + image: + needs: publish + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.ref }} + - uses: docker/setup-qemu-action@v3 + - uses: docker/setup-buildx-action@v3 + - uses: docker/login-action@v3 + with: + registry: ${{ vars.DOCKER_REGISTRY }} + username: ${{ vars.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + - name: Publish explicit preview image + env: + REGISTRY: ${{ vars.DOCKER_REGISTRY }} + USERNAME: ${{ vars.DOCKER_USERNAME }} + GIT_TAG: ${{ github.ref_name }} + # The image installs from the workspace lock, so it builds from the repository root. + run: docker buildx build --platform linux/amd64,linux/arm64 -f Dockerfile -t "$REGISTRY/$USERNAME/modsim:${GIT_TAG#modsim-v}" --push ../.. + + # The modsim documentation site is not published from this repository yet (TOOL-01 decision 7); the + # release still proves that the preview documentation builds. + docs: + needs: publish + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.ref }} + - uses: ./.github/actions/setup-uv + with: + package: modsim + - run: uv run --locked --no-sync --group docs mkdocs build -s -f mkdocs-preview.yml --site-dir "$RUNNER_TEMP/site" + + acceptance: + if: ${{ always() && (github.event_name == 'workflow_dispatch' || (needs.publish.result == 'success' && needs.image.result == 'success' && needs.docs.result == 'success')) }} + needs: [publish, image, docs] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.ref }} + - uses: actions/checkout@v4 + with: + ref: ${{ inputs.tag || github.ref }} + path: release + - uses: astral-sh/setup-uv@v6 + with: + version: 0.11.19 + python-version: '3.12' + enable-cache: true + - name: Verify release fixture version + env: + GIT_TAG: ${{ inputs.tag || github.ref_name }} + run: | + cd "$GITHUB_WORKSPACE/release/packages/modsim" + python .github/scripts/check_release_version.py "${GIT_TAG#modsim-}" + git rev-parse HEAD + - name: Install published wheel and test dependencies + timeout-minutes: 15 + env: + GIT_TAG: ${{ inputs.tag || github.ref_name }} + run: | + python .github/scripts/preview-release.py download "${GIT_TAG#modsim-v}" "$RUNNER_TEMP/distributions" + - name: Test without application source + run: | + release="$GITHUB_WORKSPACE/release/packages/modsim" + mkdir -p "$RUNNER_TEMP/acceptance" + cp -r "$release/tests" "$release/tools" "$RUNNER_TEMP/acceptance/" + if [ -d "$release/contrib" ]; then cp -r "$release/contrib" "$RUNNER_TEMP/acceptance/"; fi + if [ -d "$release/examples" ]; then cp -r "$release/examples" "$RUNNER_TEMP/acceptance/"; fi + if [ -f "$release/deployment.yaml" ]; then cp "$release/deployment.yaml" "$RUNNER_TEMP/acceptance/"; fi + prepare="$PWD/tools/prepare-acceptance.py" + cd "$RUNNER_TEMP/acceptance" + uv run --isolated --with "$RUNNER_TEMP"/distributions/*.whl python "$prepare" "$RUNNER_TEMP/acceptance" + uv run --isolated --with "$RUNNER_TEMP"/distributions/*.whl --with pytest python -m pytest tests/test_wot.py tests/test_deployment.py tests/test_codec.py -q --junitxml=acceptance.xml + - name: Verify published image and contributed deployment + env: + REGISTRY: ${{ vars.DOCKER_REGISTRY }} + USERNAME: ${{ vars.DOCKER_USERNAME }} + GIT_TAG: ${{ inputs.tag || github.ref_name }} + run: | + version="${GIT_TAG#modsim-v}" + docker run --rm "$REGISTRY/$USERNAME/modsim:$version" python -m modsim --version + # The immutable a1 image predates managed deployments. Its own + # historical fixture and CLI remain available for re-acceptance. + if [ "$version" = "2.0.0a1" ]; then + docker run -d --name modsim-preview -p 127.0.0.1:5020:5020 "$REGISTRY/$USERNAME/modsim:$version" python -m modsim --deployment examples/lab.sim.json --bind 0.0.0.0 + else + docker run -d --name modsim-preview -p 127.0.0.1:5020:5020 "$REGISTRY/$USERNAME/modsim:$version" python -m modsim up -f /app/deployment.yaml + fi + cd "$RUNNER_TEMP/acceptance" + uv run --isolated --with "$RUNNER_TEMP"/distributions/*.whl python tools/preview-acceptance.py + - if: always() + run: docker rm -f modsim-preview || true + - uses: actions/upload-artifact@v4 + if: always() + with: + name: published-acceptance + path: ${{ runner.temp }}/acceptance/acceptance.xml diff --git a/.github/workflows/modsim.yml b/.github/workflows/modsim.yml new file mode 100644 index 0000000..a474c2d --- /dev/null +++ b/.github/workflows/modsim.yml @@ -0,0 +1,110 @@ +name: modsim + +on: + push: + branches: [v2] + paths: + - packages/modsim/** + - packages/modpoll-wot/** + - pyproject.toml + - uv.lock + - .pre-commit-config.yaml + - .github/actions/** + - .github/workflows/modsim.yml + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + paths: + - packages/modsim/** + - packages/modpoll-wot/** + - pyproject.toml + - uv.lock + - .pre-commit-config.yaml + - .github/actions/** + - .github/workflows/modsim.yml + +defaults: + run: + working-directory: packages/modsim + +# Job names are prefixed so they never share a check name with modpoll's; the release guard +# (packages/modsim/.github/scripts/preview-release.py) requires exactly these jobs. +jobs: + quality: + name: modsim quality + runs-on: ubuntu-latest + steps: + - name: Check out + uses: actions/checkout@v4 + + - uses: actions/cache@v4 + with: + path: ~/.cache/pre-commit + key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }} + + - name: Set up the environment + uses: ./.github/actions/setup-uv + with: + package: modsim + + - name: Run checks + run: make check + + tox: + name: modsim tox (${{ matrix.python-version }}) + runs-on: ubuntu-latest + strategy: + matrix: + include: + - python-version: "3.10" + tox-env: py310 + - python-version: "3.14" + tox-env: py314 + fail-fast: false + steps: + - name: Check out + uses: actions/checkout@v4 + + - name: Set up uv and Python + uses: ./.github/actions/setup-uv + with: + package: modsim + python-version: ${{ matrix.python-version }} + + - name: Prepare immutable public model inputs + run: uv run --locked python tools/fetch-models.py + + - name: Test with tox + run: uv run --locked --no-sync tox -e ${{ matrix.tox-env }} + + snapshot-replay: + name: modpoll snapshot replay + runs-on: ubuntu-latest + steps: + - name: Check out + uses: actions/checkout@v4 + + - name: Set up uv and Python + uses: ./.github/actions/setup-uv + with: + package: modsim + + - name: Install an independent released modpoll + run: | + uv venv "$RUNNER_TEMP/modpoll" + uv pip install --python "$RUNNER_TEMP/modpoll/bin/python" 'modpoll==2.0.0a5' + + - name: Export with modpoll and replay with modsim + env: + MODSIM_TEST_MODPOLL_PYTHON: ${{ runner.temp }}/modpoll/bin/python + run: uv run --locked pytest tests/test_snapshot_replay.py -v + + docs: + name: modsim docs + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/setup-uv + with: + package: modsim + - run: uv run --locked --no-sync --group docs mkdocs build -s + - run: uv run --locked --no-sync python tools/generate-td.py --check diff --git a/.github/workflows/on-release-main.yml b/.github/workflows/on-release-main.yml deleted file mode 100644 index 2ff94c9..0000000 --- a/.github/workflows/on-release-main.yml +++ /dev/null @@ -1,149 +0,0 @@ -name: release-main - -on: - release: - types: [published] - -concurrency: - group: release-publish - queue: max - -jobs: - build-and-publish-pypi: - if: github.event.release.prerelease == false - runs-on: ubuntu-latest - permissions: - contents: write - steps: - - name: Check out - uses: actions/checkout@v4 - with: - ref: ${{ github.event.release.tag_name }} - - - name: Set up uv - uses: ./.github/actions/setup-uv - - - name: Export tag - id: vars - run: echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT - - - name: Check release tag eligibility - env: - GH_TOKEN: ${{ github.token }} - DOCKER_REGISTRY: ${{ vars.DOCKER_REGISTRY }} - DOCKER_USERNAME: ${{ vars.DOCKER_USERNAME }} - IMAGE_NAME: modpoll - TAG: ${{ steps.vars.outputs.tag }} - run: python .github/scripts/release_image_tags.py > "$RUNNER_TEMP/image-tags" - - - name: Build and publish to PyPI - run: | - python .github/scripts/check_release_version.py "$RELEASE_VERSION" - make build-and-publish - env: - PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} - RELEASE_VERSION: ${{ steps.vars.outputs.tag }} - - publish-docker: - runs-on: ubuntu-latest - needs: build-and-publish-pypi - outputs: - latest: ${{ steps.image-tags.outputs.latest }} - docs: ${{ steps.image-tags.outputs.docs }} - steps: - - name: Check out - uses: actions/checkout@v4 - with: - ref: ${{ github.event.release.tag_name }} - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Login to Docker Registry - uses: docker/login-action@v3 - with: - registry: ${{ vars.DOCKER_REGISTRY }} - username: ${{ vars.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - - name: Export tag - id: vars - run: echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT - - - name: Verify image version - env: - RELEASE_VERSION: ${{ steps.vars.outputs.tag }} - run: python .github/scripts/check_release_version.py "$RELEASE_VERSION" - - - name: Select release image tags - id: image-tags - env: - GH_TOKEN: ${{ github.token }} - DOCKER_REGISTRY: ${{ vars.DOCKER_REGISTRY }} - DOCKER_USERNAME: ${{ vars.DOCKER_USERNAME }} - IMAGE_NAME: modpoll - TAG: ${{ steps.vars.outputs.tag }} - run: python .github/scripts/release_image_tags.py > "$RUNNER_TEMP/image-tags" - - - name: Build and push Docker images - env: - DOCKER_REGISTRY: ${{ vars.DOCKER_REGISTRY }} - DOCKER_USERNAME: ${{ vars.DOCKER_USERNAME }} - IMAGE_NAME: modpoll - TAG: ${{ steps.vars.outputs.tag }} - run: | - args=() - while IFS= read -r image; do args+=(-t "$image"); done < "$RUNNER_TEMP/image-tags" - docker buildx build --platform linux/amd64,linux/arm64 "${args[@]}" --push . - - deploy-docs: - needs: [build-and-publish-pypi, publish-docker] - if: needs.publish-docker.outputs.docs == 'true' - concurrency: - group: modpoll-pages - cancel-in-progress: false - runs-on: ubuntu-latest - permissions: - contents: write - steps: - - name: Check out - uses: actions/checkout@v4 - with: - ref: ${{ github.event.release.tag_name }} - - - name: Set up uv - uses: ./.github/actions/setup-uv - - - name: Set up pandoc - uses: ./.github/actions/setup-pandoc - - - name: Build documentation - run: make docs - - - uses: actions/checkout@v4 - with: - ref: gh-pages - path: .pages - - - name: Preserve both documentation lines and vocabulary - env: - TAG: ${{ github.event.release.tag_name }} - UPDATE_ROOT: ${{ needs.publish-docker.outputs.latest }} - run: | - mkdir .site - rsync -a --exclude=.git .pages/ .site/ - line=v2 - if [[ "$TAG" == v1.* || "$TAG" == 1.* ]]; then line=1.x; fi - args=() - if [[ "$UPDATE_ROOT" == true ]]; then args+=(--root); fi - python .github/scripts/assemble-docs.py docs/_build/html .site "$line" "${args[@]}" - printf '%s\n' "$GITHUB_SHA" > ".site/$line/source-sha.txt" - - - name: Deploy documentation - uses: peaceiris/actions-gh-pages@v4 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: .site diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml deleted file mode 100644 index 260e607..0000000 --- a/.github/workflows/release-please.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: release-please - -on: - push: - branches: [main] - -permissions: - contents: write - pull-requests: write - -jobs: - release-please: - runs-on: ubuntu-latest - steps: - - uses: actions/create-github-app-token@v1 - id: app-token - with: - app-id: ${{ vars.TM_INFRA_ROBOT_APP_ID }} - private-key: ${{ secrets.TM_INFRA_ROBOT_PRIVATE_KEY }} - - uses: googleapis/release-please-action@v4 - with: - token: ${{ steps.app-token.outputs.token }} - release-type: python diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4b3a74d..5c8f781 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,3 +1,6 @@ +# One configuration for the workspace. Each hook keeps the scope it had in its package before TOOL-01: +# modpoll and modsim shared the same hooks and modpoll added two; modpoll-wot was never checked by pre-commit. +files: ^packages/(modpoll|modsim)/ repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: "v4.6.0" @@ -5,11 +8,13 @@ repos: - id: check-case-conflict - id: check-merge-conflict - id: check-json + files: ^packages/modpoll/ - id: check-toml - id: check-yaml - id: trailing-whitespace - id: mixed-line-ending args: [--fix=lf] + files: ^packages/modpoll/ - repo: https://github.com/psf/black rev: 24.4.2 hooks: diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 08b70b8..0000000 --- a/Dockerfile +++ /dev/null @@ -1,17 +0,0 @@ -# syntax=docker/dockerfile:1 - -# FROM python:3.12-alpine -FROM python:3.12-slim-bookworm - -COPY --from=ghcr.io/astral-sh/uv:0.11.19 /uv /uvx /bin/ - -# Copy dependency metadata first to cache the install layer. -WORKDIR /app -COPY uv.lock pyproject.toml README.md /app/ -COPY modpoll /app/modpoll - -# Project initialization: -RUN uv sync --locked --no-dev --all-extras --no-editable -ENV PATH="/app/.venv/bin:${PATH}" - -CMD ["modpoll", "--version"] diff --git a/README.md b/README.md index 9887e81..cae208d 100644 --- a/README.md +++ b/README.md @@ -1,254 +1,23 @@ -> **2.x development branch.** This checkout accepts v1 CSV and WoT TM/TD JSON using profile 0.2; `--config` detects the format from the content. Install the current preview with `uv tool install --prerelease allow 'modpoll[serial]==2.0.0a8'`; stable 1.x remains available with `uv tool install 'modpoll<2'`. For development, run `make install`, then prefix project commands with `uv run`. +# modpoll, modsim and modpoll-wot -# Modpoll - A New Command-line Tool for Modbus and MQTT +This branch (`v2`) holds three tools that read, simulate and describe Modbus devices with W3C WoT Thing Models. +They are released separately to PyPI and share one uv workspace and one lock file. -[![Release](https://img.shields.io/github/v/release/top-maker/modpoll)](https://img.shields.io/github/v/release/top-maker/modpoll) -[![Build status](https://img.shields.io/github/actions/workflow/status/top-maker/modpoll/main.yml?branch=main)](https://github.com/top-maker/modpoll/actions/workflows/main.yml?query=branch%3Amain) -[![License](https://img.shields.io/github/license/top-maker/modpoll)](https://img.shields.io/github/license/top-maker/modpoll) -[![Downloads](https://static.pepy.tech/badge/modpoll/week)](https://pepy.tech/project/modpoll) +| Package | What it does | Source | +| --- | --- | --- | +| [modpoll](https://pypi.org/project/modpoll/) | Reads Modbus TCP and RTU devices from a Thing Model, publishes to MQTT and writes verification reports | [packages/modpoll](packages/modpoll) | +| [modsim](https://pypi.org/project/modsim/) | Simulates a Modbus device from a Thing Model, over TCP or a virtual serial port | [packages/modsim](packages/modsim) | +| [modpoll-wot](https://pypi.org/project/modpoll-wot/) | The executable Thing Model profile, fingerprints and report schemas both tools share | [packages/modpoll-wot](packages/modpoll-wot) | +modpoll 1.x lives on the `main` branch. Earlier modsim and modpoll-wot history is part of this branch; +their former repositories are archived. -> Learn more about *modpoll* usage at [documentation](https://top-maker.github.io/modpoll) site. - -## Motivation - -The idea for creating this tool originated from my need to efficiently check new devices during site surveys. These surveys are often time-constrained and space-limited, with on-site work adding to the pressure. In such situations, a portable Swiss Army knife toolkit becomes a valuable companion. - -This tool can be easily deployed on a Raspberry Pi or similar embedded devices, polling data from a Modbus network or connected devices. Users can choose to log the data locally or publish it to an MQTT broker for further troubleshooting. - -The MQTT broker can be set up either on the same Raspberry Pi or in the cloud. Once data is successfully published, users can subscribe to the relevant MQTT topics and conveniently view the data on their smartphones. - -

- -

- -Moreover, you can also run this tool continuously on a server as a Modbus-MQTT gateway, i.e. polling from local Modbus devices and forwarding data to a centralized cloud service. - -In fact, *modpoll* helps to bridge between the traditional field-bus world and the new IoT world. - -> 💡 **Tips:** This tool is designed to be a standalone executable application, which works out-of-the-box on Linux/macOS/Windows. If you are looking for a Modbus python library, please consider the following great open-source projects, [pymodbus](https://github.com/riptideio/pymodbus) or [minimalmodbus](https://github.com/pyhys/minimalmodbus) - - -## Feature - -- Support Modbus RTU/TCP/UDP devices -- Show polling data for local debugging, like a typical modpoll tool -- Publish polling data to MQTT broker for remote debugging, especially on smart phone -- Export polling data to local storage for further investigation -- Provide docker solution for continuous data polling use case - - -## Installation - -This tool requires Python 3.10+ (Ubuntu 22.04+ or equivalent) and is available on the [Python Package Index](https://pypi.org/). Install it with uv. Ubuntu 20.04 and Python 3.8 are no longer supported. - -### Using uv - -Install *modpoll* using the following command, - -```bash -uv tool install --prerelease allow "modpoll==2.0.0a8" -``` - -Optionally, [pyserial](https://pyserial.readthedocs.io/) library can be installed for Modbus-RTU communication, +## Development ```bash -uv tool install --prerelease allow 'modpoll[serial]==2.0.0a8' -``` - -Upgrade the tool via the following command, - -```bash -uv tool install --upgrade --prerelease allow "modpoll<3" -``` - -The same commands work on Windows PowerShell; uv manages the isolated tool environment. - -## Quickstart - -Verify modpoll against the already deployed public Modbus TCP simulator. No -local modsim installation or Docker container is needed: - -```bash -modpoll --once \ - --tcp modsim.topmaker.net --tcp-port 502 \ - --config examples/modsim.tm.json -``` - -### Modbus ASCII and framers - -- Serial transports: use `--serial PORT --framer ascii` (alias: `--rtu` still accepted); pyserial URLs such as `socket://host:port` and `rfc2217://host:port` work for serial-over-TCP tunnels. -- Serial supports framers `ascii` and `rtu` (pymodbus defaults to RTU if `--framer default`). Binary framer is no longer supported in pymodbus 3.9+. - -### Prepare a WoT configuration - -Use [examples/modsim.tm.json](examples/modsim.tm.json) for the simulator model or -[examples/modsim.generated.td.json](examples/modsim.generated.td.json) for its -generated local TCP instance. -Both preserve the four original blocks and 37 output references. `--unit-id` -overrides the Unit ID declared consistently in Forms (fallback 1); a concrete TD's Forms must agree before overrides. -The existing transport, polling, output and MQTT arguments remain available. - -See the [current profile](https://github.com/top-maker/modpoll-wot/blob/main/profile.md) for field mapping, -access flags, byte order, multiplier semantics and supported limits; the -[execution contract](https://github.com/top-maker/modpoll-wot/blob/main/CONTRACT.md) defines the profile 0.2-only input policy. -The configuration loader detects the format from the content and reports invalid -model fields before polling. Each model describes one device; use multiple -`--config` paths for multiple devices. Give each model a unique `title`, which is -the output device name. Existing v1 CSV configurations load through the same -`--config` argument; no separate flags are needed. - -Physical RS485 polling has also been verified by the maintainer with an Eastron -meter (2026-10-28). See [validation](docs/validation.rst) for the evidence scope and -[contributed mappings](contrib/README.md) for vendor references. - -For a complete local simulator/MQTT demonstration, use the repository's -[Docker Compose example](examples/README.md). - -### Read a device and write a verification report - -Adding `--report` to a normal read verifies the Thing Model on real hardware: every point is read once, -read-only, without retries and with a timeout of at most 10 seconds, so a lost request is a result and not -something to repeat. MODEL is a local TM/TD file, an http(s) URL or a `modiohub:@` Workspace -reference. `--report FILE` writes the verification report (`-` prints it); bare `--report` asks where to -save, whether the values look right, and whether to upload: - -```sh -modpoll --config examples/modsim.tm.json --tcp 192.168.1.20 --unit-id 3 --report report.json -``` - -The report records, per point, whether the read worked (`ok`, a Modbus `exception` with its code, -`no-response`, or `not-tested` when the answer could not be decoded) and your judgment of the value: -`--confirm POINT...` (or `all`) and `--reject POINT...` for values you compared with the device, otherwise -`unchecked`. The report holds no address, Unit -ID, serial number or value; review it before sharing. It is checked with -[modpoll-wot](https://github.com/top-maker/modpoll-wot) (`modpoll-wot validate-report report.json --model -model.tm.json`), and `--export` still writes the snapshot of the same read. ModioHub resolves the product -from the model fingerprint, so you never name the product. The exit -code is 1 unless every point was read. - -### Sign in to ModioHub, read a Workspace Thing Model and upload the report - -`modpoll login` signs in with your browser: it prints a code and an address (and opens the address where a -browser can open), you confirm the code there, and the 7-day tool session is kept in a file only you can read -(`~/.config/modiohub/credentials.json`, or `%APPDATA%\modiohub` on Windows). modsim uses the same file, so -signing in with either tool signs in both. `MODIOHUB_TOKEN` in the environment replaces the file for scripts, -`MODIOHUB_URL` selects another server, and `login` and `logout` take `--server URL` for the same. `modpoll logout` forgets the login on this computer; -revoke the session in your ModioHub settings to end it on the server. - -Once signed in, `--config modiohub:@` (the version is a number or `latest`) reads one -of your custom Thing Models. A shared one needs no login. Verifying it names the Workspace model in the -report, and `modpoll --config ... --upload` shows the report and, after you confirm (or with `--yes`), -uploads it; without a login the sign-in flow starts right there: - -```sh -modpoll --config modiohub:k3x9f2m7q4a8n5bd@latest --tcp 192.168.1.20 --upload +uv sync --all-packages --all-extras --all-groups +cd packages/modpoll && uv run pytest ``` -### MQTT data and write behavior - -The local example above uses the `adam6024_raw` TD title for its default topics: -`modpoll/adam6024_raw/data` for samples and `modpoll/adam6024_raw/set` for -write commands. The publish, subscribe and diagnostics topic patterns are -configurable; see the [MQTT documentation](docs/site/usage.rst). - -Writes use literal Modbus PDU addresses and raw values. Holding-register arrays -use FC16 and must contain 1–123 unsigned 16-bit values within the address range. -Invalid, oversized, malformed, ambiguous or retained write messages are ignored -and logged. Brokers can clear the retained flag on live forwarding, so configure -the broker not to retain commands on the set topic; QoS does not make a write -exactly once. - -When a sample is invalid in a poll cycle, modpoll omits it from MQTT output and -writes `null` for that point in the JSON snapshot. Snapshots from multiple -configuration files are combined and replaced atomically. When `--timestamp` is -enabled, the timestamp is the start time of the poll cycle in Unix seconds; a -device with a point named `timestamp` cannot use it. A snapshot is -[simulation data](https://github.com/top-maker/modpoll-wot/blob/main/profile.md#simulation-data), -so `modsim --config device.tm.json --data snapshot.json` replays it locally. - - -## Run with docker - -A docker image has been provided for user to directly run the tool without local installation, - - ```bash - docker run --rm topmaker/modpoll:2.0.0a8 - ``` - -It shows the version of the tool by default. - -On Linux, host networking connects the container to a simulator on the host. -Mount the JSON configuration into the container; ``--daemon`` suppresses tables. - -If you want to load a local configure file, you need to mount a local folder onto container volume, -for example, if the child folder `examples` contains the config file `modsim.tm.json`, we can use it via the following command, - - ```bash - docker run --rm --network host -v "$(pwd)/examples:/app/examples:ro" topmaker/modpoll:2.0.0a8 \ - modpoll -d \ - --tcp 127.0.0.1 --tcp-port 5020 \ - --config /app/examples/modsim.tm.json - ``` - - -## Example Use Cases - -- Connect to Modbus TCP device - - ```bash - modpoll \ - --tcp 192.168.1.10 \ - --config examples/modsim.tm.json - ``` - -- Connect to Modbus serial device - - ```bash - modpoll \ - --serial /dev/ttyUSB0 \ - --serial-baud 9600 \ - --config examples/modsim.tm.json - ``` - -- Connect to Modbus TCP device and publish data to MQTT broker - - ```bash - modpoll \ - --tcp 127.0.0.1 --tcp-port 5020 \ - --mqtt-host broker.emqx.io \ - --config examples/modsim.tm.json - ``` - -- Connect to Modbus TCP device and export a local JSON snapshot - - ```bash - modpoll \ - --tcp 127.0.0.1 --tcp-port 5020 \ - --export data.json \ - --config examples/modsim.tm.json - ``` - -- Replay the snapshot with modsim on this computer (keep snapshots of real - devices local) - - ```bash - modsim --config examples/modsim.tm.json --port 5020 --data data.json - ``` - -> Refer to the [documentation](https://top-maker.github.io/modpoll) site for more details about the configuration and examples. - -> *If you find this tool useful, please support us by starring 🌟 our repository to encourage further improvements.* - -## Credits - -The implementation of this project is heavily inspired by the following two projects: -- https://github.com/owagner/modbus2mqtt (MIT license) -- https://github.com/mbs38/spicierModbus2mqtt (MIT license) - -Thanks to Max Brueggemann and Oliver Wagner for their great work. - - -## License - -MIT © 2021-2026, Ying Shaodong +Each package keeps its own `Makefile`, tests and release notes. A release is a tag named after the package, +for example `modsim-v2.0.0a13`, which runs that package's release workflow. diff --git a/packages/modpoll-wot/.coverage b/packages/modpoll-wot/.coverage new file mode 100644 index 0000000..164cd37 Binary files /dev/null and b/packages/modpoll-wot/.coverage differ diff --git a/packages/modpoll-wot/.gitignore b/packages/modpoll-wot/.gitignore new file mode 100644 index 0000000..a9af255 --- /dev/null +++ b/packages/modpoll-wot/.gitignore @@ -0,0 +1,4 @@ +__pycache__/ +.pytest_cache/ +.venv/ +dist/ diff --git a/packages/modpoll-wot/AGENTS.md b/packages/modpoll-wot/AGENTS.md new file mode 100644 index 0000000..d17a8fc --- /dev/null +++ b/packages/modpoll-wot/AGENTS.md @@ -0,0 +1,8 @@ +# modpoll-wot repository conventions + +- Review the working tree and current branch before editing. Integrate changes into `main` through a reviewed pull request with passing CI. +- This repository owns the shared TM/TD executable profile, its bundled schemas, and the offline CLI. Modpoll, Modsim, Open Modbus Catalog, and ModioHub consume published releases only. +- Run `mise run check` before opening a pull request. +- Released versions and tags are immutable. Release the producer first, then update consumer pins in their own repositories. See [README](README.md#releases). +- Keep the package free of Modbus execution, schedulers, network services, and product metadata records. +- Use English and lowercase kebab-case filenames except where an external tool requires a different name. diff --git a/packages/modpoll-wot/CONTRACT.md b/packages/modpoll-wot/CONTRACT.md new file mode 100644 index 0000000..932899a --- /dev/null +++ b/packages/modpoll-wot/CONTRACT.md @@ -0,0 +1,83 @@ +# Executable configuration contract 0.2 + +Current development source executes only documents declaring +`"modpoll:version": "0.2"`. Profile 0.1, missing versions and unknown versions +are rejected by model loading, instantiation, export and executable validation. +Standard-only TM/TD schema validation is separate and does not promise execution. + +[profile.md](profile.md) is the mapping/API specification. The maintained source +is a TM; a TD is an instantiated input or export artifact. Both use standard +property DataSchemas and Modbus Forms for raw types, addresses, quantities, +access, units and ordering. Acquisition groups list property names and explicit +request blocks. Bit-table offsets count physical bits, not eight-bit groups. + +To migrate an old profile, move member decoding metadata into property Forms, +keep request boundaries and holes, convert bit-table member offsets to physical +addresses, and derive Unit ID consistently from Forms/instance arguments. +Changing only the version string is insufficient. Preserve known input/output +vectors and revalidate the result; there is no implicit legacy conversion. + +Retained float16, packed-bit and register boolean codecs are explicit profile +0.2 features, not profile 0.1 document support. Their semantics and third-party +export limits remain documented in the profile. + +The profile 0.1 loader, Forms validator, schema and acceptance fixtures have +been removed. Shared member/type checks validate profile 0.2 directly. The +37-property example and independent vectors continue to cover values, requests, +access rules, aliases, ordering and conversions. + +This source change does not rewrite existing release artifacts or the exact +registry dependencies of consumers. Before release, allocate a new immutable +shared-package version, test independent installation and consumer interoperability, +publish the producer first, and only then change consumer pins. Package version +and executable profile version are distinct. Existing profile 0.2 semantics are +preserved; removing the older executable input does not redefine profile 0.2. + +## Version 0.4.0a1 + +Version 0.4.0a1 adds [simulation data](profile.md#simulation-data): schema +`simulation-data-1.json`, `load_simulation_data`, `scaled_raw` and +`modpoll-wot validate --kind data`. Modpoll `--export` snapshots are accepted +as simulation data. Verification report schema 3 replaces schema 2 and drops +`model.path`: Open Modbus Catalog keeps each baseline Thing Model at +`model.tm.json`, so the product ID and catalog commit identify it. Schema 2 +had no consumers and is removed. + +## Version 0.3.0a3 + +Version 0.3.0a3 removes the optional `modpoll:audit` plan and `AuditPlan`. +Baseline Thing Models are fully open, and a [full read](profile.md#verification-reports) +executes the whole `modpoll:acquisition` plan, so the audit list only repeated +acquisition members. Authors write `modpoll:acquisition` only. A TM or TD that +still declares `modpoll:audit` fails with `unsupported root project extension`. +Model and point fingerprints are unchanged, because the plan never contributed +to them. Open Modbus Catalog removed its audit plans before this release. + +## Version 0.3.0a2 + +Version 0.3.0a2 replaces verification report schema 1 with +[schema 2](profile.md#verification-reports): `device` becomes `product`, +`environment.carrier` becomes `environment.chassis`, and `reportVersion` is 2. +Schema 1, released in 0.3.0a1, had no consumers and is removed. A TD or TM +with an empty title now fails with `/title: title cannot be empty`. + +## Version 0.3.0a1 + +Version 0.3.0a1 adds [point and model fingerprints and verification reports](profile.md#point-and-model-fingerprints). +It removes `derive_audit_tm`, `AuditArtifact` and the `audit-tm-v1` +publication format, which existed only for restricted preview models. Point +tables now include fingerprints. The `modpoll:audit` plan is unchanged in this +version and removed in 0.3.0a3. + +## Device metadata + +Version 0.3.0a1 removes the device metadata schema 1, `validate-device` and +`modpoll_wot.metadata`, published in 0.2.0a3 and 0.2.0a4. Device metadata records +and their schema belong to [Open Modbus Catalog](https://github.com/top-maker/open-modbus-catalog). +No current consumer uses the removed API. + +Version 0.2.0a4 adds optional audit references, removed in 0.3.0a3, and the +publication APIs removed in 0.3.0a1. Earlier packages +can run existing profile 0.2 documents that omit the extension. They reject +documents with the new audit extension. The shared package validates and +derives configuration without contacting any device. diff --git a/LICENSE b/packages/modpoll-wot/LICENSE similarity index 100% rename from LICENSE rename to packages/modpoll-wot/LICENSE diff --git a/packages/modpoll-wot/README.md b/packages/modpoll-wot/README.md new file mode 100644 index 0000000..3122840 --- /dev/null +++ b/packages/modpoll-wot/README.md @@ -0,0 +1,88 @@ +# modpoll-wot (experimental) + +An independently versioned TM/TD configuration interpreter for +[Modpoll](https://github.com/top-maker/modpoll), +[Modsim](https://github.com/top-maker/modsim) and future compatible consumers. +No Modbus execution, scheduler or MQTT service is included. + +Releases up to `0.2.0a4` were developed in the Modpoll repository under +`packages/modpoll-wot`; this repository keeps that history and tags them as `v`. + +The existing TM CLI is available in `modpoll-wot==0.2.0a2`. +Version `0.5.0a1` adds the shared tool session credentials file and `modiohub:` references (`modpoll_wot.session`). +Version `0.4.0a1` adds simulation data (`--kind data`) and verification report schema 3. +Version `0.3.0a3` removes the `modpoll:audit` plan; a full read uses `modpoll:acquisition`. +Version `0.3.0a2` renames verification report fields to `product` and `chassis` (schema 2). +Version `0.3.0a1` adds point and model fingerprints and the verification report schema, +and removes the device metadata schema; see [CONTRACT.md](CONTRACT.md). + +```sh +modpoll-wot new --title "meter" +modpoll-wot validate meter.tm.json +modpoll-wot validate meter.tm.json --kind tm --profile +modpoll-wot export meter.tm.json --host 127.0.0.1 --port 5020 --unit-id 7 -o meter.td.json +modpoll-wot validate meter.td.json +modpoll-wot fingerprint meter.tm.json +modpoll-wot validate-report report.json --model meter.tm.json +modpoll-wot validate meter.data.json --kind data +``` + +Use `modpoll-wot --help` and `modpoll-wot validate --help` for options. +Validation reports each check separately with a tick or cross and an error +detail on failure. Terminal markers are colored; redirected output has no ANSI +colors, and `NO_COLOR` disables colors. The exit status is zero only on success. +Structure validation is offline and rejects duplicate JSON keys; it does not +check JSON-LD, references, device behavior or complete W3C conformance. Type is +detected from the document, so use `--kind tm` for a known TM whose type might +be missing. `--profile` checks the executable subset, accepting instance options +and `--param NAME=JSON` when needed. `new` writes `.tm.json` in the current directory by default; use `-o` +to choose another path. It never overwrites a file. The starter is a standard TM skeleton; +add profile 0.2 mappings before executable validation or export. Export accepts +`--target node-wot-0.9.2` for the documented subset and never overwrites files. + +See [profile.md](profile.md) for the current profile and +[CONTRACT.md](CONTRACT.md) for the profile 0.2-only execution policy. + +The loader validates bundled W3C TM/TD 1.1 schemas, the project extension +schema, and acquisition semantics. It does not execute Modbus requests. + +```python +from modpoll_wot.loading import load_model +model = load_model("meter.tm.json", unit_id=1) +``` + +## Development + +Install [mise](https://mise.jdx.dev/installing-mise.html), then run the source +tests, build the wheel and sdist, and smoke-test the installed wheel: + +```sh +mise trust +mise install +mise run check +``` + +The bundled W3C schemas identify themselves as 1.1-12-March-2025, retrieved from +https://www.w3.org/2022/wot/td-schema/v1.1 and +https://www.w3.org/2022/wot/tm-schema/v1.1. Standard validation does not +establish device correctness. + +Version 0.2.0a1 supports [profile 0.2](profile.md): standard Form mappings, +explicit blocks, per-property decoding and TM-to-TD export. Current development +source rejects profile 0.1. This compatibility removal is not yet published; use +a new immutable release version when promoting it, then update consumer pins. + +## Releases + +Released versions and tags are immutable. + +1. On `main`, set `version` in `pyproject.toml` to a new version and merge it + through a pull request whose CI passes, including the consumer job. +2. Push the tag `v<version>` at that commit. The release workflow checks the + tag, tests and builds, publishes to PyPI, verifies the registry installation + and records a GitHub prerelease with the built files. +3. Update the exact `modpoll-wot` pin in each consumer repository in its own + pull request. + +A failed publish never replaces an existing version: rerun the failed job, or +release a new version. diff --git a/packages/modpoll-wot/mise.toml b/packages/modpoll-wot/mise.toml new file mode 100644 index 0000000..d709566 --- /dev/null +++ b/packages/modpoll-wot/mise.toml @@ -0,0 +1,35 @@ +[tools] +python = "3.12" +uv = "0.11.19" + +[tasks.install] +description = "Install the locked development environment" +run = "uv sync --locked" + +[tasks.test] +description = "Run the source test suite" +depends = ["install"] +run = "uv run --locked pytest -q" + +[tasks.build] +description = "Build the wheel and sdist into dist/" +run = "uv build --no-sources --clear --out-dir dist" + +[tasks.check] +description = "Run the source tests, build, and smoke-test the installed wheel" +depends = ["test", "build"] +run = ''' +set -eu +fixture="$PWD/tests/fixtures/modsim.tm.json" +numeric="$PWD/tests/fixtures/numeric.tm.json" +report="$PWD/tests/fixtures/numeric.report.json" +wheel=$(ls "$PWD"/dist/*.whl) +cd "$(mktemp -d)" +uv run --isolated --no-project --with "$wheel" modpoll-wot validate "$fixture" --profile +uv run --isolated --no-project --with "$wheel" modpoll-wot export "$fixture" --host 127.0.0.1 --port 5020 -o instance.td.json +uv run --isolated --no-project --with "$wheel" modpoll-wot validate instance.td.json --profile +uv run --isolated --no-project --with "$wheel" modpoll-wot fingerprint "$fixture" > /dev/null +uv run --isolated --no-project --with "$wheel" modpoll-wot validate-report "$report" --model "$numeric" +printf '{"numeric": {"counter": 7, "missing": null}}' > snapshot.json +uv run --isolated --no-project --with "$wheel" modpoll-wot validate snapshot.json --kind data +''' diff --git a/packages/modpoll-wot/modpoll_wot/__init__.py b/packages/modpoll-wot/modpoll_wot/__init__.py new file mode 100644 index 0000000..54318d4 --- /dev/null +++ b/packages/modpoll-wot/modpoll_wot/__init__.py @@ -0,0 +1,61 @@ +"""Modpoll's versioned executable subset of WoT TM/TD and Modbus metadata.""" + +from .acquisition import AcquisitionError, Group, Member, parse_acquisition +from .loading import Model, load_model, loads_model, parse_model +from .validation import ModelValidationError, validate_standard +from .profile import instantiate, export_td, parse_parameters +from .delivery import project_point_table +from .simulation import DataError, SimulationData, load_simulation_data, scaled_raw +from .session import ( + REFERENCE_PREFIX, + CredentialError, + Reference, + Session, + active_server, + forget_session, + load_session, + parse_reference, + save_session, + server_url, +) +from .verification import ( + ReportError, + model_fingerprint, + point_fingerprints, + validate_report, +) + +__all__ = [ + "REFERENCE_PREFIX", + "CredentialError", + "Reference", + "Session", + "active_server", + "forget_session", + "load_session", + "parse_reference", + "save_session", + "server_url", + "DataError", + "SimulationData", + "load_simulation_data", + "scaled_raw", + "parse_parameters", + "ReportError", + "model_fingerprint", + "point_fingerprints", + "validate_report", + "project_point_table", + "instantiate", + "export_td", + "AcquisitionError", + "Group", + "Member", + "Model", + "ModelValidationError", + "parse_acquisition", + "load_model", + "loads_model", + "parse_model", + "validate_standard", +] diff --git a/packages/modpoll-wot/modpoll_wot/__main__.py b/packages/modpoll-wot/modpoll_wot/__main__.py new file mode 100644 index 0000000..16e9c51 --- /dev/null +++ b/packages/modpoll-wot/modpoll_wot/__main__.py @@ -0,0 +1,192 @@ +"""Offline TM/TD structure checks, executable profile checks and generation.""" + +import argparse +import json +import os +from pathlib import Path +import sys + +from . import ( + AcquisitionError, + export_td, + load_model, + point_fingerprints, + validate_report, + validate_standard, +) +from .simulation import load_simulation_data +from .loading import _document_kind, load_document +from .profile import parse_parameters +from .verification import combine_fingerprints + + +def _write_json(path, document): + with Path(path).open("x", encoding="utf-8") as stream: + stream.write(json.dumps(document, indent=2, ensure_ascii=False) + "\n") + + +def _result(passed, message, *, stream): + marker = "✓" if passed else "✗" + try: + marker.encode(stream.encoding or "utf-8") + except (UnicodeEncodeError, LookupError): + marker = "[PASS]" if passed else "[FAIL]" + if ( + stream.isatty() + and "NO_COLOR" not in os.environ + and os.environ.get("TERM") != "dumb" + ): + marker = f"\033[{'32' if passed else '31'}m{marker}\033[0m" + print(f"{marker} {message}", file=stream, flush=True) + + +def _instance_options(parser): + parser.add_argument("--host") + parser.add_argument("--port", type=int) + parser.add_argument("--unit-id", type=int) + parser.add_argument("--param", action="append", default=[], metavar="NAME=JSON") + + +def main(): + parser = argparse.ArgumentParser(prog="modpoll-wot", description=__doc__) + commands = parser.add_subparsers(dest="command", required=True) + check = commands.add_parser("validate", help="Validate TM/TD structure") + check.add_argument("input", help="Local JSON file") + check.add_argument("--kind", choices=["auto", "tm", "td", "data"], default="auto") + check.add_argument( + "--profile", action="store_true", help="Also check executable profile" + ) + _instance_options(check) + new = commands.add_parser("new", help="Create a starter TM") + new.add_argument("--title", required=True) + new.add_argument("-o", "--output", help="Output path (default: <title>.tm.json)") + export = commands.add_parser("export", help="Export a concrete TD from a TM") + export.add_argument("input", help="Source TM file") + export.add_argument("-o", "--output", required=True) + export.add_argument( + "--target", choices=["project", "node-wot-0.9.2"], default="project" + ) + _instance_options(export) + prints = commands.add_parser( + "fingerprint", help="Print model and point fingerprints of a TM or TD as JSON" + ) + prints.add_argument("input", help="Local JSON file") + report = commands.add_parser( + "validate-report", help="Validate a hardware verification report" + ) + report.add_argument("input", help="Local report JSON file") + report.add_argument( + "--model", help="Exact TM bytes the report claims; checks hash and fingerprints" + ) + args = parser.parse_args() + phase = "Input" + try: + if args.command == "new": + if not args.title.strip(): + raise AcquisitionError("title cannot be empty") + if args.output is None and ( + args.title in (".", "..") or "/" in args.title or "\\" in args.title + ): + raise AcquisitionError( + "title cannot contain path separators; use --output" + ) + output = args.output or f"{args.title}.tm.json" + document = { + "@context": "https://www.w3.org/2022/wot/td/v1.1", + "title": args.title, + "@type": "tm:ThingModel", + "properties": {}, + } + validate_standard(document, kind="tm") + _write_json(output, document) + print(f"Generated starter TM: {output} (no executable Modbus mappings)") + elif args.command == "fingerprint": + points = point_fingerprints(Path(args.input).read_bytes()) + result = {"model": combine_fingerprints(points.values()), "points": points} + print(json.dumps(result, indent=2, ensure_ascii=False)) + elif args.command == "validate-report": + phase = "Verification report" + document = load_document(args.input) + model = None if args.model is None else Path(args.model).read_bytes() + validate_report(document, model=model) + scope = "schema, hash and fingerprints" if model else "schema only" + _result(True, f"{phase}: passed ({scope})", stream=sys.stdout) + else: + document = load_document(args.input) + if not isinstance(document, dict): + raise AcquisitionError(f"{args.input}: document: expected object") + if args.command == "validate" and args.kind == "data": + phase = "Simulation data" + if args.profile: + raise AcquisitionError("--profile applies to TM and TD input") + loaded = load_simulation_data(document) + data = loaded.data + counts = ", ".join( + f"{len(data.get(key, {}))} {key}" + for key in ("initial", "generators", "bindings") + ) + _result( + True, + f"{phase} {data['version']}: passed ({loaded.source}; {counts})", + stream=sys.stdout, + ) + if loaded.unread: + print(f" Unread snapshot points left out: {', '.join(loaded.unread)}") + elif args.command == "validate": + if not args.profile and ( + args.host is not None + or args.port is not None + or args.unit_id is not None + or args.param + ): + phase = "Options" + raise AcquisitionError("instance options require --profile") + kind = _document_kind(document) if args.kind == "auto" else args.kind + phase = f"{kind.upper()} structure (WoT 1.1)" + validate_standard(document, kind=kind) + _result(True, f"{phase}: passed", stream=sys.stdout) + if args.profile: + phase = "Executable profile" + model = load_model( + args.input, + kind=kind, + host=args.host, + port=args.port, + unit_id=args.unit_id, + parameters=parse_parameters(args.param), + ) + _result( + True, + f"{phase} {model.profile_version}: passed ({model.title})", + stream=sys.stdout, + ) + print(" Device behavior and point mappings were not tested.") + else: + print( + " JSON Schema only; use --profile to check project compatibility." + ) + else: + if _document_kind(document) != "tm": + raise AcquisitionError("TD export requires a TM input") + td = export_td( + document, + host=args.host, + port=args.port, + unit_id=args.unit_id, + parameters=parse_parameters(args.param), + target=args.target, + ) + _write_json(args.output, td) + print(f"Exported TD: {args.output}") + except (ValueError, OSError, TypeError, RecursionError) as exc: + if args.command in ("validate", "validate-report"): + _result(False, f"{phase}: failed", stream=sys.stderr) + print(f" {exc}", file=sys.stderr) + else: + print(f"error: {exc}", file=sys.stderr) + return 1 + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/packages/modpoll-wot/modpoll_wot/acquisition.py b/packages/modpoll-wot/modpoll_wot/acquisition.py new file mode 100644 index 0000000..483a865 --- /dev/null +++ b/packages/modpoll-wot/modpoll_wot/acquisition.py @@ -0,0 +1,149 @@ +"""Execution plan types and profile 0.2 member validation.""" + +from dataclasses import dataclass +from decimal import Decimal, InvalidOperation +import re +import math + + +class AcquisitionError(ValueError): + """Invalid or unsupported executable configuration.""" + + +ENTITIES = { + "Coil": "coil", + "DiscreteInput": "discrete_input", + "InputRegister": "input_register", + "HoldingRegister": "holding_register", +} +WIDTHS = { + "int16": 1, + "uint16": 1, + "float16": 1, + "int32": 2, + "uint32": 2, + "float32": 2, + "int64": 4, + "uint64": 4, + "float64": 4, + "bool": 1, + "bool8": 1, + "bool16": 2, +} + + +@dataclass(frozen=True) +class Member: + property: str + offset: int + data_type: str + bit: int | None = None + multiplier: Decimal | None = None + readable: bool = True + writable: bool = False + unit: str | None = None + byte_order: str | None = None + physical_bits: bool = False + bit_count: int | None = None + scalar: bool = False + + @property + def width(self): + return type_width(self.data_type) + + +@dataclass(frozen=True) +class Group: + table: str + start: int + quantity: int + byte_order: str + members: tuple[Member, ...] + + +def type_width(dtype, *, bit_table=False): + if dtype in WIDTHS: + width = WIDTHS[dtype] + return width * 2 if bit_table and not dtype.startswith("bool") else width + if re.fullmatch(r"string[1-9][0-9]{0,3}", dtype): + length = int(dtype[6:]) + return length if bit_table else (length + 1) // 2 + raise AcquisitionError(f"unsupported data type: {dtype}") + + +def _schema_type(prop, dtype, bit, multiplier, path): + actual = prop.get("type") + if dtype.startswith("string"): + valid = actual == "string" + if multiplier is not None: + raise AcquisitionError(f"{path}: strings cannot have a multiplier") + elif dtype.startswith("bool"): + valid = ( + actual == "boolean" + if bit is not None + else ( + actual == "array" + and isinstance(prop.get("items"), dict) + and prop["items"].get("type") == "boolean" + ) + ) + if multiplier is not None: + raise AcquisitionError(f"{path}: bit values cannot have a multiplier") + else: + valid = actual in ("integer", "number") + if dtype.startswith("float") or ( + multiplier is not None and multiplier != multiplier.to_integral_value() + ): + valid = actual == "number" + if not valid: + raise AcquisitionError( + f"{path}: property type disagrees with decoded type/transform" + ) + + +def validate_member( + name, prop, dtype, *, entity, bit, multiplier, endian, scalar, count, path +): + """Validate decoded property semantics directly, without a legacy document.""" + bits = entity in ("Coil", "DiscreteInput") + if bit is not None and (bits or dtype != "bool"): + raise AcquisitionError(f"{path}: register bit selector requires register bool") + for flag in ("readOnly", "writeOnly"): + if flag in prop and type(prop[flag]) is not bool: + raise AcquisitionError(f"{path}: invalid {flag}") + if prop.get("readOnly") and prop.get("writeOnly"): + raise AcquisitionError(f"{path}: conflicting access flags") + readable = not prop.get("writeOnly", False) + writable = not prop.get("readOnly", False) + if entity in ("DiscreteInput", "InputRegister") and writable: + raise AcquisitionError(f"{path}: read-only table requires readOnly") + if multiplier is not None: + try: + multiplier = Decimal(str(multiplier)) + except InvalidOperation as exc: + raise AcquisitionError(f"{path}: invalid multiplier") from exc + if not multiplier.is_finite() or not math.isfinite(float(multiplier)): + raise AcquisitionError(f"{path}: non-finite multiplier") + if not scalar: + _schema_type(prop, dtype, bit, multiplier, path) + return Member( + name, + 0, + dtype, + bit, + multiplier, + readable, + writable, + prop.get("unit"), + ("BE" if endian[0] else "LE") + "_" + ("BE" if endian[1] else "LE"), + bits, + count if bits else None, + scalar, + ) + + +def parse_acquisition(document) -> tuple[Group, ...]: + """Return the groups of a fully validated profile 0.2 document.""" + from .loading import parse_model + + return parse_model(document).groups diff --git a/packages/modpoll-wot/modpoll_wot/delivery.py b/packages/modpoll-wot/modpoll_wot/delivery.py new file mode 100644 index 0000000..68ce8a3 --- /dev/null +++ b/packages/modpoll-wot/modpoll_wot/delivery.py @@ -0,0 +1,59 @@ +"""Project executable point tables from Thing Models.""" + +from .acquisition import AcquisitionError +from .loading import _loads_document +from .profile import instantiate +from .verification import canonical_point, fingerprint + +READ_FUNCTIONS = { + "Coil": 1, + "DiscreteInput": 2, + "HoldingRegister": 3, + "InputRegister": 4, +} + + +def _parse_tm(payload): + try: + model, effective = instantiate(_loads_document(payload)) + except (ValueError, TypeError, RecursionError) as exc: + raise AcquisitionError(str(exc)) from exc + if model.kind != "tm": + raise AcquisitionError("point tables require a project Thing Model") + return model, effective + + +def project_point_table(payload: bytes) -> list[dict]: + """Project executable point spans and decoder metadata from exact TM bytes.""" + model, effective = _parse_tm(payload) + rows = [] + for group in model.groups: + for member in group.members: + prop = effective["properties"][member.property] + form = prop["forms"][0] + point = canonical_point(prop) + entity = form["modv:entity"] + rows.append( + { + "property": member.property, + "entity": entity, + "address": form["modv:address"], + "quantity": form["modv:quantity"], + "read_function_code": ( + READ_FUNCTIONS[entity] if member.readable else None + ), + "writable": member.writable, + "data_type": member.data_type, + "byte_order": member.byte_order, + "bit": member.bit, + "bit_packing": form.get("modpoll:bitPacking"), + "multiplier": ( + str(member.multiplier) + if member.multiplier is not None + else None + ), + "unit": member.unit, + "fingerprint": fingerprint(point) if point else None, + } + ) + return rows diff --git a/packages/modpoll-wot/modpoll_wot/endpoint.py b/packages/modpoll-wot/modpoll_wot/endpoint.py new file mode 100644 index 0000000..c367be0 --- /dev/null +++ b/packages/modpoll-wot/modpoll_wot/endpoint.py @@ -0,0 +1,51 @@ +"""Validated concrete Modbus TCP endpoints shared by model instantiation.""" + +import ipaddress +import re +from urllib.parse import urlsplit, parse_qs +from .acquisition import AcquisitionError + + +def _authority(host, port): + if type(port) is not int or not 1 <= port <= 65535: + raise AcquisitionError("port: expected integer between 1 and 65535") + if not isinstance(host, str) or not host: + raise AcquisitionError("host: required for a TM") + try: + address = ipaddress.ip_address(host) + except ValueError: + if len(host) > 253 or not all( + re.fullmatch(r"[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?", label) + for label in host.split(".") + ): + raise AcquisitionError("host: expected an IP address or DNS hostname") + else: + if address.is_unspecified or address.is_multicast: + raise AcquisitionError( + "host: a listening wildcard/multicast is not an endpoint" + ) + host = str(address) + if "%" in host: + raise AcquisitionError("scoped IPv6 endpoints are not supported") + if address.version == 6: + host = f"[{host}]" + return f"{host.lower()}:{port}" + + +def _td_endpoint(form, path): + try: + url = urlsplit(form["href"]) + parts = url.path.strip("/").split("/") + unit, address = map(int, parts) + query = parse_qs(url.query, strict_parsing=True, keep_blank_values=True) + if set(query) - {"quantity"} or len(query.get("quantity", [])) > 1: + raise ValueError() + quantity = int(query.get("quantity", ["1"])[0]) + if url.scheme != "modbus+tcp" or url.username or url.password or url.fragment: + raise ValueError() + authority = _authority(url.hostname, 502 if url.port is None else url.port) + if not 1 <= unit <= 254: + raise ValueError() + except (KeyError, TypeError, ValueError) as exc: + raise AcquisitionError(f"{path}: invalid concrete Modbus TCP href") from exc + return authority, unit, address, quantity diff --git a/packages/modpoll-wot/modpoll_wot/loading.py b/packages/modpoll-wot/modpoll_wot/loading.py new file mode 100644 index 0000000..16ec4be --- /dev/null +++ b/packages/modpoll-wot/modpoll_wot/loading.py @@ -0,0 +1,115 @@ +"""Bounded JSON loading and validation of the executable Modpoll subset.""" + +import json +import math +from dataclasses import dataclass +from pathlib import Path + +from .acquisition import AcquisitionError, Group + +MAX_BYTES = 1048576 +MAX_DEPTH = 64 + + +@dataclass(frozen=True) +class Model: + title: str + kind: str + groups: tuple[Group, ...] + unit_id: int + endpoint: tuple[str, int] | None = None + properties_json: str | None = None + profile_version: str = "0.2" + + +def _pairs(pairs): + result = {} + for key, value in pairs: + if key in result: + raise AcquisitionError(f"duplicate JSON key: {key}") + result[key] = value + return result + + +def _invalid_number(value): + raise AcquisitionError(f"invalid JSON number: {value}") + + +def _check_depth(value, depth=0): + if depth > MAX_DEPTH: + raise AcquisitionError(f"JSON nesting exceeds {MAX_DEPTH}") + if isinstance(value, float) and not math.isfinite(value): + raise AcquisitionError("non-finite JSON number") + if isinstance(value, dict): + for item in value.values(): + _check_depth(item, depth + 1) + elif isinstance(value, list): + for item in value: + _check_depth(item, depth + 1) + + +def _document_kind(document): + """Select the schema from content; validation follows without fallback. + + The executable subset uses the fixed tm:ThingModel spelling. File names, + URLs and arbitrary JSON-LD alias resolution do not participate in selection. + """ + types = document.get("@type", []) + if isinstance(types, str): + types = [types] + return "tm" if isinstance(types, list) and "tm:ThingModel" in types else "td" + + +def parse_model( + document, *, kind=None, unit_id=None, host=None, port=None, parameters=None +): + # Instantiation owns executable validation; kind is only a caller assertion. + if kind is not None and ( + not isinstance(document, dict) or kind != _document_kind(document) + ): + raise AcquisitionError("document kind disagrees with tm:ThingModel declaration") + from .profile import instantiate + + return instantiate( + document, host=host, port=port, unit_id=unit_id, parameters=parameters + )[0] + + +def _loads_document(payload): + if ( + len(payload.encode("utf-8") if isinstance(payload, str) else payload) + > MAX_BYTES + ): + raise AcquisitionError("configuration exceeds 1 MiB") + document = json.loads( + payload, object_pairs_hook=_pairs, parse_constant=_invalid_number + ) + _check_depth(document) + return document + + +def loads_model(payload, *, source="<memory>", kind=None, unit_id=None, **instance): + try: + return parse_model( + _loads_document(payload), kind=kind, unit_id=unit_id, **instance + ) + except (ValueError, TypeError, RecursionError) as exc: + raise AcquisitionError(f"{source}: {exc}") from exc + + +def load_model(path, *, kind=None, unit_id=None, **instance): + document = load_document(path) + try: + return parse_model(document, kind=kind, unit_id=unit_id, **instance) + except (ValueError, TypeError, RecursionError) as exc: + raise AcquisitionError(f"{path}: {exc}") from exc + + +def load_document(path): + """Load bounded duplicate-free JSON for execution, validation and export.""" + path = Path(path) + try: + with path.open("rb") as stream: + return _loads_document(stream.read(MAX_BYTES + 1)) + except (ValueError, TypeError, OSError, RecursionError) as exc: + raise AcquisitionError(f"{path}: {exc}") from exc diff --git a/packages/modpoll-wot/modpoll_wot/profile.py b/packages/modpoll-wot/modpoll_wot/profile.py new file mode 100644 index 0000000..a21fec9 --- /dev/null +++ b/packages/modpoll-wot/modpoll_wot/profile.py @@ -0,0 +1,578 @@ +"""Executable profile 0.2: standard Forms, explicit blocks and TD instantiation.""" + +import copy +from dataclasses import replace +import json +import re + +from .acquisition import AcquisitionError, Group, type_width, validate_member, ENTITIES +from .endpoint import _authority, _td_endpoint +from .loading import _check_depth, _document_kind +from .validation import validate_standard, validate_extension, validate_modbus + +VERSION = "0.2" +TYPES = { + "xsd:unsignedShort": "uint16", + "xsd:short": "int16", + "xsd:unsignedInt": "uint32", + "xsd:int": "int32", + "xsd:unsignedLong": "uint64", + "xsd:long": "int64", + "xsd:float": "float32", + "xsd:double": "float64", +} +PLACEHOLDER = re.compile(r"\{\{([ -~]+?)\}\}") + + +def parse_parameters(items): + """Parse typed CLI bindings once for all consumers, rejecting duplicates.""" + from .loading import _pairs, _invalid_number + + result = {} + for item in items: + try: + key, value = item.split("=", 1) + if not key or key in result: + raise AcquisitionError("empty or duplicate parameter name") + result[key] = json.loads( + value, object_pairs_hook=_pairs, parse_constant=_invalid_number + ) + except (TypeError, ValueError) as exc: + raise AcquisitionError(f"invalid TM parameter {item!r}: {exc}") from exc + _check_depth(result) + return result + + +def _substitute(value, parameters, used): + if isinstance(value, dict): + return {key: _substitute(item, parameters, used) for key, item in value.items()} + if isinstance(value, list): + return [_substitute(item, parameters, used) for item in value] + if not isinstance(value, str): + return value + matches = list(PLACEHOLDER.finditer(value)) + if not matches: + if "{{" in value or "}}" in value: + raise AcquisitionError("malformed TM placeholder") + return value + for match in matches: + name = match[1] + if name not in parameters: + raise AcquisitionError(f"unbound TM placeholder: {name}") + used.add(name) + if len(matches) == 1 and matches[0].span() == (0, len(value)): + return copy.deepcopy(parameters[matches[0][1]]) + + def embedded(match): + result = parameters[match[1]] + if not isinstance(result, (str, int, float)) or isinstance(result, bool): + raise AcquisitionError( + "embedded placeholders require string/numeric parameters" + ) + return str(result) + + return PLACEHOLDER.sub(embedded, value) + + +def _codec(form, prop, count, bits, path): + raw, special = form.get("modv:type"), form.get("modpoll:codec") + scalar = False + if special is not None: + if ( + raw != "xsd:hexBinary" + or special not in ("float16", "bool", "bool8", "bool16") + or bits + ): + raise AcquisitionError(f"{path}: unsupported or redundant codec") + dtype = special + elif "modpoll:bit" in form: + if raw != "xsd:unsignedShort" or bits: + raise AcquisitionError( + f"{path}: bit extraction requires a register unsignedShort" + ) + if type(form["modpoll:bit"]) is not int: + raise AcquisitionError(f"{path}: bit index must be an integer") + dtype = "bool" + elif raw == "xsd:boolean": + if prop.get("type") not in ("boolean", "array") or ( + not bits and prop.get("type") != "boolean" + ): + raise AcquisitionError(f"{path}: invalid boolean property") + dtype, scalar = ("bool" if bits else "uint16"), prop.get("type") == "boolean" + if scalar and count != 1: + raise AcquisitionError(f"{path}: scalar boolean requires quantity 1") + elif raw == "xsd:string": + capacity = form.get("modpoll:byteLength", count // 8 if bits else count * 2) + if type(capacity) is not int or not 1 <= capacity <= 9999: + raise AcquisitionError(f"{path}: invalid string byteLength") + dtype = f"string{capacity}" + elif raw in TYPES: + dtype = TYPES[raw] + else: + raise AcquisitionError(f"{path}: unsupported or missing raw type") + if "modpoll:byteLength" in form and raw != "xsd:string": + raise AcquisitionError(f"{path}: byteLength only applies to strings") + if bits and raw != "xsd:boolean": + if form.get("modpoll:bitPacking") != "legacy-msb": + raise AcquisitionError( + f"{path}: packed bit payload requires explicit legacy-msb packing" + ) + elif "modpoll:bitPacking" in form: + raise AcquisitionError( + f"{path}: bitPacking is only for non-boolean bit-table payloads" + ) + if raw == "xsd:boolean" and "modpoll:multiplier" in form: + raise AcquisitionError(f"{path}: booleans cannot be multiplied") + expected = ( + count + if bits and raw == "xsd:boolean" + else type_width(dtype, bit_table=True) * 8 if bits else type_width(dtype) + ) + if count != expected: + raise AcquisitionError(f"{path}: quantity disagrees with raw codec width") + return dtype, scalar + + +def _validate_media(form, prop, dtype, scalar, bits, endian, path): + """Accept explicit binary parameters only when they match the raw mapping.""" + media = form.get("contentType", "application/octet-stream") + if media == "application/octet-stream": + return + if not isinstance(media, str): + raise AcquisitionError(f"{path}: invalid contentType") + parts = [part.strip() for part in media.split(";")] + if parts[0] != "application/octet-stream": + raise AcquisitionError( + f"{path}: source media type must be application/octet-stream" + ) + native_bit = bits and scalar and form.get("modv:type") == "xsd:boolean" + if ( + prop.get("type") == "array" + or any( + key in form + for key in ("modpoll:codec", "modpoll:bit", "modpoll:multiplier") + ) + or (bits and not native_bit) + or (not native_bit and dtype not in TYPES.values()) + ): + raise AcquisitionError( + f"{path}: binary media parameters require native scalar values" + ) + length = 1 if native_bit else type_width(dtype) * 2 + order = { + (True, True): "BIG_ENDIAN", + (False, False): "LITTLE_ENDIAN", + (False, True): "BIG_ENDIAN_BYTE_SWAP", + (True, False): "LITTLE_ENDIAN_BYTE_SWAP", + }[endian] + if length == 2: + order = "BIG_ENDIAN" if endian[0] else "LITTLE_ENDIAN" + expected = { + "length": str(length), + "signed": "false" if native_bit or dtype.startswith("uint") else "true", + "byteSeq": order, + } + seen = set() + for part in parts[1:]: + key, sep, value = part.partition("=") + key, value = key.strip(), value.strip() + if not sep or key in seen or key not in expected or value != expected[key]: + raise AcquisitionError( + f"{path}: conflicting or unsupported binary media parameter: {part}" + ) + seen.add(key) + + +def instantiate(document, *, host=None, port=None, unit_id=None, parameters=None): + """Return a validated execution Model and effective TD, preserving the input. + + Explicit instance arguments override a validated TD endpoint. Without them, + TD endpoints are authoritative. TM defaults are TCP port 502 / Unit ID 1; + an unbound TM may execute over a CLI-selected serial/UDP transport, but cannot + be exported as a concrete TCP TD without a host. + """ + if not isinstance(document, dict): + raise AcquisitionError("document: expected object") + _check_depth(document) + if document.get("modpoll:version") != VERSION: + raise AcquisitionError( + "unsupported executable profile; expected modpoll:version '0.2'" + ) + kind = _document_kind(document) + if parameters and kind != "tm": + raise AcquisitionError("parameters are only valid for TM input") + used = set() + explicit = dict(parameters or {}) + bindings = {"PORT": 502, "UNIT_ID": 1, **explicit} + if host is not None: + bindings["HOST"] = host + bindings["AUTHORITY"] = _authority(host, 502 if port is None else port) + if port is not None: + bindings["PORT"] = port + if unit_id is not None: + bindings["UNIT_ID"] = unit_id + td = _substitute(document, bindings, used) + if set(explicit) - used: + raise AcquisitionError(f"unused TM parameters: {sorted(set(explicit) - used)}") + _check_depth(td) + validate_standard(td, kind=kind) + if not td["title"].strip(): + raise AcquisitionError("/title: title cannot be empty") + security = td.get("security", []) + if isinstance(security, str): + security = [security] + definitions = td.get("securityDefinitions", {}) + if any(definitions.get(name, {}).get("scheme") != "nosec" for name in security): + raise AcquisitionError("this Modbus configuration subset supports only nosec") + validate_extension(td) + for key in ( + "actions", + "events", + "links", + "forms", + "uriVariables", + "tm:optional", + "tm:extends", + "base", + ): + if td.get(key): + raise AcquisitionError(f"/{key}: unsupported executable profile feature") + if any(key.startswith("modv:") for key in td): + raise AcquisitionError( + "root Modbus fields are unsupported; use Forms or instance arguments" + ) + if any( + key.startswith("modpoll:") + and key not in ("modpoll:version", "modpoll:acquisition") + for key in td + ): + raise AcquisitionError("unsupported root project extension") + contexts = {} + for item in td.get("@context", []): + if isinstance(item, dict): + contexts.update(item) + if ( + contexts.get("modpoll") + != "https://top-maker.github.io/modpoll/vocab/wot-modbus#" + or contexts.get("modv") != "https://www.w3.org/2019/wot/modbus" + or contexts.get("xsd") != "http://www.w3.org/2001/XMLSchema#" + ): + raise AcquisitionError("unsupported fixed vocabulary aliases") + # Validate explicit overrides even if a document has no bound Forms. + if unit_id is not None and (type(unit_id) is not int or not 1 <= unit_id <= 254): + raise AcquisitionError("unit_id: expected integer between 1 and 254") + if port is not None and (type(port) is not int or not 1 <= port <= 65535): + raise AcquisitionError("port: expected integer between 1 and 65535") + if host is not None: + _authority(host, 502 if port is None else port) + metadata, declared_endpoint = {}, None + declared_unit = None + properties = td.get("properties", {}) + if not properties: + raise AcquisitionError("/properties: expected nonempty object") + for name, prop in properties.items(): + path = f"/properties/{name}/forms" + if any(key.startswith(("modpoll:", "modv:")) for key in prop): + raise AcquisitionError(f"{path}: protocol metadata belongs in Forms") + forms = prop.get("forms", []) + if not isinstance(forms, list) or not forms: + raise AcquisitionError(f"{path}: a property needs Forms") + ops_seen, mapping = set(), None + bound_forms = [] + for form in forms: + entity = form.get("modv:entity") + if entity not in ( + "Coil", + "DiscreteInput", + "HoldingRegister", + "InputRegister", + ): + raise AcquisitionError(f"{path}: invalid entity") + bits = entity in ("Coil", "DiscreteInput") + if "href" in form: + remote, uid, address, count = _td_endpoint(form, path) + for key, val in ( + ("modv:address", address), + ("modv:quantity", count), + ("modv:unitID", uid), + ): + if key in form and (type(form[key]) is not int or form[key] != val): + raise AcquisitionError(f"{path}: href disagrees with {key}") + endpoint = (remote, uid) + if declared_endpoint is not None and endpoint != declared_endpoint: + raise AcquisitionError(f"{path}: multiple endpoints/Unit IDs") + declared_endpoint = endpoint + else: + if kind == "td": + raise AcquisitionError(f"{path}: missing concrete href") + address, count = form.get("modv:address"), form.get("modv:quantity", 1) + form_unit = uid if "href" in form else form.get("modv:unitID") + if form_unit is not None: + if type(form_unit) is not int or not 1 <= form_unit <= 254: + raise AcquisitionError(f"{path}: invalid modv:unitID") + if declared_unit is not None and declared_unit != form_unit: + raise AcquisitionError(f"{path}: inconsistent Unit IDs") + declared_unit = form_unit + if ( + type(address) is not int + or type(count) is not int + or not 0 <= address <= 65535 + or not 1 <= count <= (2000 if bits else 125) + or address + count > 65536 + ): + raise AcquisitionError(f"{path}: invalid Modbus span") + endian = tuple( + form.get(key, True) + for key in ("modv:mostSignificantByte", "modv:mostSignificantWord") + ) + if any(type(flag) is not bool for flag in endian): + raise AcquisitionError(f"{path}: invalid byte order") + dtype, scalar = _codec(form, prop, count, bits, path) + _validate_media(form, prop, dtype, scalar, bits, endian, path) + allowed = ([] if prop.get("writeOnly") else ["readproperty"]) + ( + [] if prop.get("readOnly") else ["writeproperty"] + ) + ops = form.get("op", allowed) + if isinstance(ops, str): + ops = [ops] + if not ops or any(op not in allowed or op in ops_seen for op in ops): + raise AcquisitionError(f"{path}: ambiguous or invalid operation") + form.setdefault("contentType", "application/octet-stream") + form["op"] = ops[0] if len(ops) == 1 else ops + ops_seen.update(ops) + current = ( + entity, + address, + count, + dtype, + endian, + scalar, + form.get("modpoll:bit"), + form.get("modpoll:multiplier"), + ) + if mapping is not None and mapping != current: + raise AcquisitionError(f"{path}: read/write Forms disagree") + mapping = current + form["modv:address"], form["modv:quantity"] = address, count + bound_forms.append(form) + if ops_seen != set(allowed): + raise AcquisitionError(f"{path}: Forms must cover property access") + metadata[name] = (mapping, bound_forms) + remote, uid = declared_endpoint or ( + None, + 1 if declared_unit is None else declared_unit, + ) + if remote is not None: + # Parse validated authority through an existing URL, preserving IPv6. + from urllib.parse import urlsplit + + parsed = urlsplit("modbus+tcp://" + remote) + actual_host, actual_port = parsed.hostname, parsed.port + else: + actual_host, actual_port = None, 502 + actual_host = actual_host if host is None else host + actual_port = actual_port if port is None else port + uid = uid if unit_id is None else unit_id + authority = ( + _authority(actual_host, actual_port) if actual_host is not None else None + ) + if authority is not None: + from urllib.parse import urlsplit + + effective = urlsplit("modbus+tcp://" + authority) + actual_host, actual_port = effective.hostname, effective.port + if authority is None and kind == "td": + raise AcquisitionError("TD requires a concrete endpoint") + validated = {} + for name, (mapping, forms) in metadata.items(): + entity, address, count, dtype, endian, scalar, bit, multiplier = mapping + validated[name] = validate_member( + name, + properties[name], + dtype, + entity=entity, + bit=bit, + multiplier=multiplier, + endian=endian, + scalar=scalar, + count=count, + path=f"/properties/{name}", + ) + for form in forms: + if "modv:unitID" in form: + form["modv:unitID"] = uid + if authority is not None: + form["href"] = ( + f"modbus+tcp://{authority}/{uid}/{address}?quantity={count}" + ) + else: + form.pop("href", None) + groups, seen = [], set() + for index, group in enumerate(td["modpoll:acquisition"]): + entity, start, count = ( + group["modv:entity"], + group["modv:address"], + group["modv:quantity"], + ) + if ( + type(start) is not int + or type(count) is not int + or count > (2000 if entity in ("Coil", "DiscreteInput") else 125) + or start + count > 65536 + ): + raise AcquisitionError(f"/modpoll:acquisition/{index}: invalid group span") + members = [] + for name in group["modpoll:members"]: + if name not in metadata or name in seen: + raise AcquisitionError( + f"/modpoll:acquisition/{index}: unknown or duplicate member {name}" + ) + mapping = metadata[name][0] + if ( + mapping[0] != entity + or mapping[1] < start + or mapping[1] + mapping[2] > start + count + ): + raise AcquisitionError( + f"/modpoll:acquisition/{index}: member outside group or wrong entity" + ) + members.append(replace(validated[name], offset=mapping[1] - start)) + seen.add(name) + groups.append(Group(ENTITIES[entity], start, count, "BE_BE", tuple(members))) + if seen != properties.keys(): + raise AcquisitionError( + "every property must belong to exactly one acquisition group" + ) + types = td.pop("@type", []) + if isinstance(types, str): + types = [types] + types = [item for item in types if item != "tm:ThingModel"] + if types: + td["@type"] = types + if "security" not in td: + td.setdefault("securityDefinitions", {})["nosec_sc"] = {"scheme": "nosec"} + td["security"] = "nosec_sc" + # An unbound TM execution plan is valid, but is not an exportable TD. + if authority is not None: + validate_standard(td, kind="td") + validate_modbus(td) + from .loading import Model + + schemas = { + name: {key: value for key, value in prop.items() if key != "forms"} + for name, prop in properties.items() + } + model = Model( + td["title"], + kind, + tuple(groups), + uid, + (actual_host, actual_port) if authority else None, + json.dumps(schemas, sort_keys=True, ensure_ascii=False), + VERSION, + ) + return model, td + + +def export_td(document, *, target="project", **instance): + model, td = instantiate(document, **instance) + if any( + "href" not in form + for prop in td["properties"].values() + for form in prop["forms"] + ): + raise AcquisitionError( + "concrete TD export requires a TCP endpoint; serial/UDP execution remains available" + ) + if target == "project": + return td + if target != "node-wot-0.9.2": + raise AcquisitionError("unknown export target") + failures = [] + for group in model.groups: + for member in group.members: + name = member.property + prop = td["properties"][name] + native_bit = ( + member.physical_bits and member.scalar and member.data_type == "bool" + ) + if ( + member.multiplier is not None + or member.bit is not None + or ( + not native_bit + and member.data_type + not in ("int16", "uint16", "int32", "uint32", "float32", "float64") + ) + or (member.physical_bits and not native_bit) + ): + failures.append(name) + continue + converted = [] + for form in prop["forms"]: + length = 1 if native_bit else type_width(member.data_type) * 2 + endian = { + "BE_BE": "BIG_ENDIAN", + "LE_LE": "LITTLE_ENDIAN", + "LE_BE": "BIG_ENDIAN_BYTE_SWAP", + "BE_LE": "LITTLE_ENDIAN_BYTE_SWAP", + }[member.byte_order] + if length == 2: + endian = ( + "BIG_ENDIAN" + if member.byte_order.startswith("BE_") + else "LITTLE_ENDIAN" + ) + if ( + member.writable + and length > 2 + and member.byte_order in ("BE_LE", "LE_BE") + ): + failures.append(name + " (node-wot mixed-order write codec)") + continue + signed = ( + "false" + if member.data_type.startswith("uint") or native_bit + else "true" + ) + form["contentType"] = ( + f"application/octet-stream;length={length};signed={signed};byteSeq={endian}" + ) + ops = form.get( + "op", + ( + ["readproperty"] + if prop.get("readOnly") + else ( + ["writeproperty"] + if prop.get("writeOnly") + else ["readproperty", "writeproperty"] + ) + ), + ) + if isinstance(ops, str): + ops = [ops] + # FC16 avoids node-wot's FC6 byte swapping of little-endian + # two-byte writes. Separate operation Forms are standard TD. + if not native_bit and "writeproperty" in ops: + if "readproperty" in ops: + read = copy.deepcopy(form) + read["op"] = "readproperty" + converted.append(read) + write = copy.deepcopy(form) + write["op"] = "writeproperty" + write.pop("modv:entity", None) + write["modv:function"] = "writeMultipleHoldingRegisters" + converted.append(write) + else: + converted.append(form) + prop["forms"] = converted + if failures: + raise AcquisitionError( + "node-wot export cannot preserve semantics for: " + ", ".join(failures) + ) + td.pop("modpoll:version", None) + td.pop("modpoll:acquisition", None) + validate_standard(td, kind="td") + validate_modbus(td) + return td diff --git a/packages/modpoll-wot/modpoll_wot/schemas/SOURCES.md b/packages/modpoll-wot/modpoll_wot/schemas/SOURCES.md new file mode 100644 index 0000000..2b16cb9 --- /dev/null +++ b/packages/modpoll-wot/modpoll_wot/schemas/SOURCES.md @@ -0,0 +1,26 @@ +# Bundled schema sources + +Retrieved 2026-10-28; official schema content is stored without modification. +Upstream repository and licensing: https://github.com/w3c/wot-thing-description + +- td-1.1.json: https://www.w3.org/2022/wot/td-schema/v1.1 + SHA-256: fd44f319f94c6f16f66978860ef2f9f4e0e9fd7fc5835a2f3840b9cf2002e0f1 +- tm-1.1.json: https://www.w3.org/2022/wot/tm-schema/v1.1 + SHA-256: 6912708a0fa9966b51ae75f91951cf48a202d873023b8cba1b53ba4af51e92d3 + +- modbus-binding.json: https://w3c.github.io/wot-binding-templates/bindings/protocols/modbus/modbus.schema.json + Retrieved 2026-10-29 without modification. + SHA-256: 284de7d3931e0093a87cc1180902ea395e338f0d9c09045af88ef6019f1b2611 + Latest upstream protocol-directory commit at retrieval: + b7f611d1f8cc136023b529db47d20a3826548d38. + Repository/licensing: https://github.com/w3c/wot-binding-templates. + This binding is a work in progress, not a W3C Recommendation. + +acquisition-0.2.json is the executable project schema. +verification-report-3.json and verification-report-4.json are the project's hardware verification report schemas. In schema 4 the product is optional: the receiving service resolves it from the model fingerprint, while older reports may still carry it. +simulation-data-1.json is the project's simulation data schema. Profile 0.1 is not +bundled or executable in current development source. The Modbus schema's TD reference resolves only to bundled TD 1.1; +other remote resolution remains disabled. + +The upstream binding notice is preserved in w3c-binding-license.txt; the project +MIT license does not replace the upstream schema license. diff --git a/packages/modpoll-wot/modpoll_wot/schemas/acquisition-0.2.json b/packages/modpoll-wot/modpoll_wot/schemas/acquisition-0.2.json new file mode 100644 index 0000000..cc26de6 --- /dev/null +++ b/packages/modpoll-wot/modpoll_wot/schemas/acquisition-0.2.json @@ -0,0 +1,189 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "Modpoll executable profile 0.2", + "type": "object", + "required": [ + "modpoll:version", + "modpoll:acquisition", + "properties" + ], + "properties": { + "modpoll:version": { + "const": "0.2" + }, + "modpoll:acquisition": { + "type": "array", + "minItems": 1, + "items": { + "type": "object", + "additionalProperties": false, + "required": [ + "modv:entity", + "modv:address", + "modv:quantity", + "modpoll:members" + ], + "properties": { + "modv:entity": { + "enum": [ + "Coil", + "DiscreteInput", + "InputRegister", + "HoldingRegister" + ] + }, + "modv:address": { + "type": "integer", + "minimum": 0, + "maximum": 65535 + }, + "modv:quantity": { + "type": "integer", + "minimum": 1, + "maximum": 2000 + }, + "modpoll:members": { + "type": "array", + "minItems": 1, + "uniqueItems": true, + "items": { + "type": "string", + "minLength": 1 + } + } + } + } + }, + "properties": { + "type": "object", + "minProperties": 1, + "additionalProperties": { + "type": "object", + "required": [ + "forms" + ], + "properties": { + "forms": { + "type": "array", + "minItems": 1, + "items": { + "type": "object", + "additionalProperties": false, + "required": [ + "modv:entity", + "modv:type" + ], + "properties": { + "href": { + "type": "string", + "minLength": 1 + }, + "contentType": { + "type": "string", + "pattern": "^application/octet-stream(?:;[^\\r\\n]+)*$" + }, + "op": { + "oneOf": [ + { + "enum": [ + "readproperty", + "writeproperty" + ] + }, + { + "type": "array", + "minItems": 1, + "uniqueItems": true, + "items": { + "enum": [ + "readproperty", + "writeproperty" + ] + } + } + ] + }, + "modv:entity": { + "enum": [ + "Coil", + "DiscreteInput", + "InputRegister", + "HoldingRegister" + ] + }, + "modv:address": { + "type": "integer", + "minimum": 0, + "maximum": 65535 + }, + "modv:quantity": { + "type": "integer", + "minimum": 1, + "maximum": 2000 + }, + "modv:type": { + "enum": [ + "xsd:unsignedShort", + "xsd:short", + "xsd:unsignedInt", + "xsd:int", + "xsd:unsignedLong", + "xsd:long", + "xsd:float", + "xsd:double", + "xsd:boolean", + "xsd:string", + "xsd:hexBinary" + ] + }, + "modv:mostSignificantByte": { + "type": "boolean" + }, + "modv:mostSignificantWord": { + "type": "boolean" + }, + "modpoll:multiplier": { + "oneOf": [ + { + "type": "number" + }, + { + "type": "string", + "pattern": "^[+-]?([0-9]+(\\.[0-9]*)?|\\.[0-9]+)([eE][+-]?[0-9]+)?$" + } + ] + }, + "modpoll:bit": { + "type": "integer", + "minimum": 0, + "maximum": 15 + }, + "modpoll:codec": { + "enum": [ + "float16", + "bool", + "bool8", + "bool16" + ] + }, + "modpoll:byteLength": { + "type": "integer", + "minimum": 1, + "maximum": 9999 + }, + "modpoll:bitPacking": { + "const": "legacy-msb" + }, + "modv:unitID": { + "type": "integer", + "minimum": 1, + "maximum": 254 + } + } + } + } + } + } + } + } +} diff --git a/packages/modpoll-wot/modpoll_wot/schemas/modbus-binding.json b/packages/modpoll-wot/modpoll_wot/schemas/modbus-binding.json new file mode 100644 index 0000000..c6b6acf --- /dev/null +++ b/packages/modpoll-wot/modpoll_wot/schemas/modbus-binding.json @@ -0,0 +1,96 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "anyOf": [ + { + "$ref": "https://www.w3.org/2022/wot/td-schema/v1.1" + } + ], + "definitions": { + "modbusForm": { + "type": "object", + "properties": { + "modv:pollingTime": { "type": "number", "minimum": 0 }, + "modv:entity": { + "type": "string", + "enum": ["Coil", "DiscreteInput", "HoldingRegister", "InputRegister"] + }, + "modv:function": { + "type": "string", + "enum": [ + "readCoil", + "readDiscreteInput", + "readHoldingRegisters", + "readInputRegisters", + "writeSingleCoil", + "writeMultipleCoils", + "writeMultipleHoldingRegisters", + "writeSingleHoldingRegister", + "readFileRecord" + ] + }, + "modv:type": { + "type": "string", + "enum": [ + "xsd:integer", + "xsd:boolean", + "xsd:string", + "xsd:float", + "xsd:decimal", + "xsd:byte", + "xsd:short", + "xsd:int", + "xsd:long", + "xsd:unsignedByte", + "xsd:unsignedShort", + "xsd:unsignedInt", + "xsd:unsignedLong", + "xsd:double", + "xsd:hexBinary" + ] + }, + "modv:mostSignificantByte": { "type": "boolean" }, + "modv:mostSignificantWord": { "type": "boolean" }, + "modv:zeroBasedAddressing": { "type": "boolean", "$comment": "Deprecated. Please refrain from using." }, + "modv:timeout": { "type": "number", "minimum": 0 } + } + }, + "affordance": { + "type": "object", + "additionalProperties": { + "type": "object", + "properties": { + "forms": { + "type": "array", + "items": { + "$ref": "#/definitions/modbusForm" + } + } + } + } + } + }, + "type": "object", + "properties": { + "@context": { + "type": "array", + "contains": { + "type": "object", + "properties": { + "modv": { + "type": "string", + "enum": ["https://www.w3.org/2019/wot/modbus"] + } + } + } + }, + "properties": { + "$ref": "#/definitions/affordance" + }, + "actions": { + "$ref": "#/definitions/affordance" + }, + "events": { + "$ref": "#/definitions/affordance" + } + } +} diff --git a/packages/modpoll-wot/modpoll_wot/schemas/simulation-data-1.json b/packages/modpoll-wot/modpoll_wot/schemas/simulation-data-1.json new file mode 100644 index 0000000..924b1b5 --- /dev/null +++ b/packages/modpoll-wot/modpoll_wot/schemas/simulation-data-1.json @@ -0,0 +1,184 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://top-maker.github.io/modpoll/schemas/simulation-data-1.json", + "title": "Modpoll simulation data, version 1", + "description": "Declarative values a simulator serves for one device described by a Thing Model. Static values in initial are the default; generators change values over time and bindings make one property follow another. No executable code. Values are engineering values as Modpoll reads them.", + "type": "object", + "additionalProperties": false, + "required": [ + "version" + ], + "properties": { + "version": { + "const": "1" + }, + "initial": { + "description": "Property name to static value.", + "type": "object", + "propertyNames": { + "type": "string", + "minLength": 1 + }, + "additionalProperties": { + "$ref": "#/$defs/value" + } + }, + "generators": { + "description": "Property name to a value that changes over time.", + "type": "object", + "propertyNames": { + "type": "string", + "minLength": 1 + }, + "additionalProperties": { + "$ref": "#/$defs/generator" + } + }, + "bindings": { + "description": "Target property name to the source property it follows.", + "type": "object", + "propertyNames": { + "type": "string", + "minLength": 1 + }, + "additionalProperties": { + "type": "string", + "minLength": 1 + } + }, + "tick": { + "description": "Update interval in seconds, default 1.", + "type": "number", + "minimum": 0.001 + }, + "seed": { + "description": "Random seed for noise, default 0.", + "type": "integer" + }, + "writePolicy": { + "description": "Whether client writes to generated properties hold (default) or are overwritten by the generator.", + "enum": [ + "hold", + "overwrite" + ] + } + }, + "$defs": { + "generator": { + "oneOf": [ + { + "type": "object", + "additionalProperties": false, + "required": [ + "kind", + "value" + ], + "properties": { + "kind": { + "const": "constant" + }, + "value": { + "$ref": "#/$defs/value" + } + } + }, + { + "type": "object", + "additionalProperties": false, + "required": [ + "kind", + "center", + "amplitude", + "period" + ], + "properties": { + "kind": { + "const": "sine" + }, + "center": { + "type": "number" + }, + "amplitude": { + "type": "number", + "minimum": 0 + }, + "period": { + "type": "number", + "exclusiveMinimum": 0 + } + } + }, + { + "type": "object", + "additionalProperties": false, + "required": [ + "kind", + "start", + "rate", + "minimum", + "maximum" + ], + "properties": { + "kind": { + "const": "ramp" + }, + "start": { + "type": "number" + }, + "rate": { + "type": "number" + }, + "minimum": { + "type": "number" + }, + "maximum": { + "type": "number" + } + } + }, + { + "type": "object", + "additionalProperties": false, + "required": [ + "kind", + "minimum", + "maximum" + ], + "properties": { + "kind": { + "const": "noise" + }, + "minimum": { + "type": "number" + }, + "maximum": { + "type": "number" + } + } + } + ] + }, + "value": { + "description": "A property value: a scalar, or an array of scalars for array properties.", + "anyOf": [ + { + "type": [ + "boolean", + "number", + "string" + ] + }, + { + "type": "array", + "items": { + "type": [ + "boolean", + "number", + "string" + ] + } + } + ] + } + } +} diff --git a/packages/modpoll-wot/modpoll_wot/schemas/td-1.1.json b/packages/modpoll-wot/modpoll_wot/schemas/td-1.1.json new file mode 100644 index 0000000..bd3daca --- /dev/null +++ b/packages/modpoll-wot/modpoll_wot/schemas/td-1.1.json @@ -0,0 +1,1493 @@ +{ + "title": "Thing Description", + "version": "1.1-12-March-2025", + "description": "JSON Schema for validating TD instances against the TD information model. TD instances can be with or without terms that have default values", + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://www.w3.org/2022/wot/td-schema/v1.1", + "definitions": { + "anyUri": { + "type": "string" + }, + "description": { + "type": "string" + }, + "descriptions": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "title": { + "type": "string" + }, + "titles": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "security": { + "oneOf": [ + { + "type": "array", + "items": { + "type": "string" + }, + "minItems": 1 + }, + { + "type": "string" + } + ] + }, + "scopes": { + "oneOf": [ + { + "type": "array", + "items": { + "type": "string" + } + }, + { + "type": "string" + } + ] + }, + "subprotocol": { + "type": "string", + "examples": [ + "longpoll", + "websub", + "sse" + ] + }, + "thing-context-td-uri-v1": { + "type": "string", + "const": "https://www.w3.org/2019/wot/td/v1" + }, + "thing-context-td-uri-v1.1": { + "type": "string", + "const": "https://www.w3.org/2022/wot/td/v1.1" + }, + "thing-context-td-uri-temp": { + "type": "string", + "const": "http://www.w3.org/ns/td" + }, + "thing-context": { + "anyOf": [ + { + "$comment": "New context URI with other vocabularies after it but not the old one", + "type": "array", + "items": [ + { + "$ref": "#/definitions/thing-context-td-uri-v1.1" + } + ], + "additionalItems": { + "anyOf": [ + { + "$ref": "#/definitions/anyUri" + }, + { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + ], + "not": { + "$ref": "#/definitions/thing-context-td-uri-v1" + } + } + }, + { + "$comment": "Only the new context URI", + "$ref": "#/definitions/thing-context-td-uri-v1.1" + }, + { + "$comment": "Old context URI, followed by the new one and possibly other vocabularies. minItems and contains are required since prefixItems does not say all items should be provided", + "type": "array", + "items": [ + { + "$ref": "#/definitions/thing-context-td-uri-v1" + }, + { + "$ref": "#/definitions/thing-context-td-uri-v1.1" + } + ], + "minItems": 2, + "additionalItems": { + "anyOf": [ + { + "$ref": "#/definitions/anyUri" + }, + { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + ] + } + }, + { + "$comment": "Old context URI, followed by possibly other vocabularies. minItems and contains are required since prefixItems does not say all items should be provided", + "type": "array", + "items": [ + { + "$ref": "#/definitions/thing-context-td-uri-v1" + } + ], + "minItems": 1, + "additionalItems": { + "anyOf": [ + { + "$ref": "#/definitions/anyUri" + }, + { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + ] + } + }, + { + "$comment": "Only the old context URI", + "$ref": "#/definitions/thing-context-td-uri-v1" + } + ] + }, + "bcp47_string": { + "type": "string", + "pattern": "^(((([A-Za-z]{2,3}(-([A-Za-z]{3}(-[A-Za-z]{3}){0,2}))?)|[A-Za-z]{4}|[A-Za-z]{5,8})(-([A-Za-z]{4}))?(-([A-Za-z]{2}|[0-9]{3}))?(-([A-Za-z0-9]{5,8}|[0-9][A-Za-z0-9]{3}))*(-([0-9A-WY-Za-wy-z](-[A-Za-z0-9]{2,8})+))*(-(x(-[A-Za-z0-9]{1,8})+))?)|(x(-[A-Za-z0-9]{1,8})+)|((en-GB-oed|i-ami|i-bnn|i-default|i-enochian|i-hak|i-klingon|i-lux|i-mingo|i-navajo|i-pwn|i-tao|i-tay|i-tsu|sgn-BE-FR|sgn-BE-NL|sgn-CH-DE)|(art-lojban|cel-gaulish|no-bok|no-nyn|zh-guoyu|zh-hakka|zh-min|zh-min-nan|zh-xiang)))$" + }, + "type_declaration": { + "oneOf": [ + { + "type": "string", + "not": { + "const": "tm:ThingModel" + } + }, + { + "type": "array", + "items": { + "type": "string", + "not": { + "const": "tm:ThingModel" + } + } + } + ] + }, + "dataSchema-type": { + "type": "string", + "enum": [ + "boolean", + "integer", + "number", + "string", + "object", + "array", + "null" + ] + }, + "dataSchema": { + "type": "object", + "properties": { + "@type": { + "$ref": "#/definitions/type_declaration" + }, + "description": { + "$ref": "#/definitions/description" + }, + "title": { + "$ref": "#/definitions/title" + }, + "descriptions": { + "$ref": "#/definitions/descriptions" + }, + "titles": { + "$ref": "#/definitions/titles" + }, + "writeOnly": { + "type": "boolean" + }, + "readOnly": { + "type": "boolean" + }, + "oneOf": { + "type": "array", + "items": { + "$ref": "#/definitions/dataSchema" + } + }, + "unit": { + "type": "string" + }, + "enum": { + "type": "array", + "minItems": 1, + "uniqueItems": true + }, + "format": { + "type": "string" + }, + "const": {}, + "default": {}, + "contentEncoding": { + "type": "string" + }, + "contentMediaType": { + "type": "string" + }, + "type": { + "$ref": "#/definitions/dataSchema-type" + }, + "items": { + "oneOf": [ + { + "$ref": "#/definitions/dataSchema" + }, + { + "type": "array", + "items": { + "$ref": "#/definitions/dataSchema" + } + } + ] + }, + "maxItems": { + "type": "integer", + "minimum": 0 + }, + "minItems": { + "type": "integer", + "minimum": 0 + }, + "minimum": { + "type": "number" + }, + "maximum": { + "type": "number" + }, + "exclusiveMinimum": { + "type": "number" + }, + "exclusiveMaximum": { + "type": "number" + }, + "minLength": { + "type": "integer", + "minimum": 0 + }, + "maxLength": { + "type": "integer", + "minimum": 0 + }, + "multipleOf": { + "$ref": "#/definitions/multipleOfDefinition" + }, + "properties": { + "additionalProperties": { + "$ref": "#/definitions/dataSchema" + } + }, + "required": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "additionalResponsesDefinition": { + "type": "array", + "items": { + "type": "object", + "properties": { + "contentType": { + "type": "string" + }, + "schema": { + "type": "string" + }, + "success": { + "type": "boolean" + } + } + } + }, + "multipleOfDefinition": { + "type": [ + "integer", + "number" + ], + "exclusiveMinimum": 0 + }, + "expectedResponse": { + "type": "object", + "properties": { + "contentType": { + "type": "string" + } + }, + "required": [ + "contentType" + ] + }, + "form_element_base": { + "type": "object", + "properties": { + "op": { + "oneOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + }, + "href": { + "$ref": "#/definitions/anyUri" + }, + "contentType": { + "type": "string" + }, + "contentCoding": { + "type": "string" + }, + "subprotocol": { + "$ref": "#/definitions/subprotocol" + }, + "security": { + "$ref": "#/definitions/security" + }, + "scopes": { + "$ref": "#/definitions/scopes" + }, + "response": { + "$ref": "#/definitions/expectedResponse" + }, + "additionalResponses": { + "$ref": "#/definitions/additionalResponsesDefinition" + } + }, + "required": [ + "href" + ], + "additionalProperties": true + }, + "form_element_property": { + "allOf": [ + { + "$ref": "#/definitions/form_element_base" + } + ], + "type": "object", + "properties": { + "op": { + "oneOf": [ + { + "type": "string", + "enum": [ + "readproperty", + "writeproperty", + "observeproperty", + "unobserveproperty" + ] + }, + { + "type": "array", + "items": { + "type": "string", + "enum": [ + "readproperty", + "writeproperty", + "observeproperty", + "unobserveproperty" + ] + }, + "minItems": 1 + } + ] + } + }, + "additionalProperties": true + }, + "form_element_action": { + "allOf": [ + { + "$ref": "#/definitions/form_element_base" + } + ], + "type": "object", + "properties": { + "op": { + "oneOf": [ + { + "type": "string", + "enum": [ + "invokeaction", + "queryaction", + "cancelaction" + ] + }, + { + "type": "array", + "items": { + "type": "string", + "enum": [ + "invokeaction", + "queryaction", + "cancelaction" + ] + }, + "minItems": 1 + } + ] + } + }, + "additionalProperties": true + }, + "form_element_event": { + "allOf": [ + { + "$ref": "#/definitions/form_element_base" + } + ], + "type": "object", + "properties": { + "op": { + "oneOf": [ + { + "type": "string", + "enum": [ + "subscribeevent", + "unsubscribeevent" + ] + }, + { + "type": "array", + "items": { + "type": "string", + "enum": [ + "subscribeevent", + "unsubscribeevent" + ] + }, + "minItems": 1 + } + ] + } + }, + "additionalProperties": true + }, + "form_element_root": { + "allOf": [ + { + "$ref": "#/definitions/form_element_base" + } + ], + "type": "object", + "properties": { + "op": { + "oneOf": [ + { + "type": "string", + "enum": [ + "readallproperties", + "writeallproperties", + "readmultipleproperties", + "writemultipleproperties", + "observeallproperties", + "unobserveallproperties", + "queryallactions", + "subscribeallevents", + "unsubscribeallevents" + ] + }, + { + "type": "array", + "items": { + "type": "string", + "enum": [ + "readallproperties", + "writeallproperties", + "readmultipleproperties", + "writemultipleproperties", + "observeallproperties", + "unobserveallproperties", + "queryallactions", + "subscribeallevents", + "unsubscribeallevents" + ] + }, + "minItems": 1 + } + ] + } + }, + "additionalProperties": true, + "required": [ + "op" + ] + }, + "form": { + "$comment": "This is NOT for validation purposes but for automatic generation of TS types. For more info, please see: https://github.com/w3c/wot-thing-description/pull/1319#issuecomment-994950057", + "oneOf": [ + { + "$ref": "#/definitions/form_element_property" + }, + { + "$ref": "#/definitions/form_element_action" + }, + { + "$ref": "#/definitions/form_element_event" + }, + { + "$ref": "#/definitions/form_element_root" + } + ] + }, + "property_element": { + "type": "object", + "properties": { + "@type": { + "$ref": "#/definitions/type_declaration" + }, + "description": { + "$ref": "#/definitions/description" + }, + "descriptions": { + "$ref": "#/definitions/descriptions" + }, + "title": { + "$ref": "#/definitions/title" + }, + "titles": { + "$ref": "#/definitions/titles" + }, + "forms": { + "type": "array", + "minItems": 1, + "items": { + "$ref": "#/definitions/form_element_property" + } + }, + "uriVariables": { + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/dataSchema" + } + }, + "observable": { + "type": "boolean" + }, + "writeOnly": { + "type": "boolean" + }, + "readOnly": { + "type": "boolean" + }, + "oneOf": { + "type": "array", + "items": { + "$ref": "#/definitions/dataSchema" + } + }, + "unit": { + "type": "string" + }, + "enum": { + "type": "array", + "minItems": 1, + "uniqueItems": true + }, + "format": { + "type": "string" + }, + "const": {}, + "default": {}, + "type": { + "$ref": "#/definitions/dataSchema-type" + }, + "items": { + "oneOf": [ + { + "$ref": "#/definitions/dataSchema" + }, + { + "type": "array", + "items": { + "$ref": "#/definitions/dataSchema" + } + } + ] + }, + "maxItems": { + "type": "integer", + "minimum": 0 + }, + "minItems": { + "type": "integer", + "minimum": 0 + }, + "minimum": { + "type": "number" + }, + "maximum": { + "type": "number" + }, + "exclusiveMinimum": { + "type": "number" + }, + "exclusiveMaximum": { + "type": "number" + }, + "minLength": { + "type": "integer", + "minimum": 0 + }, + "maxLength": { + "type": "integer", + "minimum": 0 + }, + "multipleOf": { + "$ref": "#/definitions/multipleOfDefinition" + }, + "properties": { + "additionalProperties": { + "$ref": "#/definitions/dataSchema" + } + }, + "required": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "required": [ + "forms" + ], + "additionalProperties": true + }, + "action_element": { + "type": "object", + "properties": { + "@type": { + "$ref": "#/definitions/type_declaration" + }, + "description": { + "$ref": "#/definitions/description" + }, + "descriptions": { + "$ref": "#/definitions/descriptions" + }, + "title": { + "$ref": "#/definitions/title" + }, + "titles": { + "$ref": "#/definitions/titles" + }, + "forms": { + "type": "array", + "minItems": 1, + "items": { + "$ref": "#/definitions/form_element_action" + } + }, + "uriVariables": { + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/dataSchema" + } + }, + "input": { + "$ref": "#/definitions/dataSchema" + }, + "output": { + "$ref": "#/definitions/dataSchema" + }, + "safe": { + "type": "boolean" + }, + "idempotent": { + "type": "boolean" + }, + "synchronous": { + "type": "boolean" + } + }, + "required": [ + "forms" + ], + "additionalProperties": true + }, + "event_element": { + "type": "object", + "properties": { + "@type": { + "$ref": "#/definitions/type_declaration" + }, + "description": { + "$ref": "#/definitions/description" + }, + "descriptions": { + "$ref": "#/definitions/descriptions" + }, + "title": { + "$ref": "#/definitions/title" + }, + "titles": { + "$ref": "#/definitions/titles" + }, + "forms": { + "type": "array", + "minItems": 1, + "items": { + "$ref": "#/definitions/form_element_event" + } + }, + "uriVariables": { + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/dataSchema" + } + }, + "subscription": { + "$ref": "#/definitions/dataSchema" + }, + "data": { + "$ref": "#/definitions/dataSchema" + }, + "dataResponse": { + "$ref": "#/definitions/dataSchema" + }, + "cancellation": { + "$ref": "#/definitions/dataSchema" + } + }, + "required": [ + "forms" + ], + "additionalProperties": true + }, + "base_link_element": { + "type": "object", + "properties": { + "href": { + "$ref": "#/definitions/anyUri" + }, + "type": { + "type": "string" + }, + "rel": { + "type": "string" + }, + "anchor": { + "$ref": "#/definitions/anyUri" + }, + "hreflang": { + "anyOf": [ + { + "$ref": "#/definitions/bcp47_string" + }, + { + "type": "array", + "items": { + "$ref": "#/definitions/bcp47_string" + } + } + ] + } + }, + "required": [ + "href" + ], + "additionalProperties": true + }, + "link_element": { + "allOf": [ + { + "$ref": "#/definitions/base_link_element" + }, + { + "not": { + "description": "A basic link element should not contain sizes", + "type": "object", + "properties": { + "sizes": {} + }, + "required": [ + "sizes" + ] + } + }, + { + "not": { + "description": "A basic link element should not contain icon or tm:extends", + "properties": { + "rel": { + "enum": [ + "icon", + "tm:extends" + ] + } + }, + "required": [ + "rel" + ] + } + } + ] + }, + "icon_link_element": { + "allOf": [ + { + "$ref": "#/definitions/base_link_element" + }, + { + "properties": { + "rel": { + "const": "icon" + }, + "sizes": { + "type": "string", + "pattern": "[0-9]*x[0-9]+" + } + }, + "required": [ + "rel" + ] + } + ] + }, + "additionalSecurityScheme": { + "description": "Applies to additional SecuritySchemes not defined in the WoT TD specification.", + "$comment": "Additional SecuritySchemes should always be defined via a context extension, using a prefixed value for the scheme. This prefix (e.g. 'ace', see the example below) must contain at least one character in order to reference a valid JSON-LD context extension.", + "examples": [ + { + "scheme": "ace:ACESecurityScheme", + "ace:as": "coaps://as.example.com/token", + "ace:audience": "coaps://rs.example.com", + "ace:scopes": [ + "limited", + "special" + ], + "ace:cnonce": true + } + ], + "type": "object", + "properties": { + "@type": { + "$ref": "#/definitions/type_declaration" + }, + "description": { + "$ref": "#/definitions/description" + }, + "descriptions": { + "$ref": "#/definitions/descriptions" + }, + "proxy": { + "$ref": "#/definitions/anyUri" + }, + "scheme": { + "type": "string", + "pattern": ".+:.*" + } + }, + "required": [ + "scheme" + ], + "additionalProperties": true + }, + "noSecurityScheme": { + "type": "object", + "properties": { + "@type": { + "$ref": "#/definitions/type_declaration" + }, + "description": { + "$ref": "#/definitions/description" + }, + "descriptions": { + "$ref": "#/definitions/descriptions" + }, + "proxy": { + "$ref": "#/definitions/anyUri" + }, + "scheme": { + "type": "string", + "enum": [ + "nosec" + ] + } + }, + "required": [ + "scheme" + ], + "additionalProperties": true + }, + "autoSecurityScheme": { + "type": "object", + "properties": { + "@type": { + "$ref": "#/definitions/type_declaration" + }, + "description": { + "$ref": "#/definitions/description" + }, + "descriptions": { + "$ref": "#/definitions/descriptions" + }, + "proxy": { + "$ref": "#/definitions/anyUri" + }, + "scheme": { + "type": "string", + "enum": [ + "auto" + ] + } + }, + "not": { + "required": [ + "name" + ] + }, + "required": [ + "scheme" + ], + "additionalProperties": true + }, + "comboSecurityScheme": { + "oneOf": [ + { + "type": "object", + "properties": { + "@type": { + "$ref": "#/definitions/type_declaration" + }, + "description": { + "$ref": "#/definitions/description" + }, + "descriptions": { + "$ref": "#/definitions/descriptions" + }, + "proxy": { + "$ref": "#/definitions/anyUri" + }, + "scheme": { + "type": "string", + "enum": [ + "combo" + ] + }, + "oneOf": { + "type": "array", + "minItems": 2, + "items": { + "type": "string" + } + } + }, + "required": [ + "scheme", + "oneOf" + ], + "additionalProperties": true + }, + { + "type": "object", + "properties": { + "@type": { + "$ref": "#/definitions/type_declaration" + }, + "description": { + "$ref": "#/definitions/description" + }, + "descriptions": { + "$ref": "#/definitions/descriptions" + }, + "proxy": { + "$ref": "#/definitions/anyUri" + }, + "scheme": { + "type": "string", + "enum": [ + "combo" + ] + }, + "allOf": { + "type": "array", + "minItems": 2, + "items": { + "type": "string" + } + } + }, + "required": [ + "scheme", + "allOf" + ], + "additionalProperties": true + } + ] + }, + "basicSecurityScheme": { + "type": "object", + "properties": { + "@type": { + "$ref": "#/definitions/type_declaration" + }, + "description": { + "$ref": "#/definitions/description" + }, + "descriptions": { + "$ref": "#/definitions/descriptions" + }, + "proxy": { + "$ref": "#/definitions/anyUri" + }, + "scheme": { + "type": "string", + "enum": [ + "basic" + ] + }, + "in": { + "type": "string", + "enum": [ + "header", + "query", + "body", + "cookie", + "auto" + ] + }, + "name": { + "type": "string" + } + }, + "required": [ + "scheme" + ], + "additionalProperties": true + }, + "digestSecurityScheme": { + "type": "object", + "properties": { + "@type": { + "$ref": "#/definitions/type_declaration" + }, + "description": { + "$ref": "#/definitions/description" + }, + "descriptions": { + "$ref": "#/definitions/descriptions" + }, + "proxy": { + "$ref": "#/definitions/anyUri" + }, + "scheme": { + "type": "string", + "enum": [ + "digest" + ] + }, + "qop": { + "type": "string", + "enum": [ + "auth", + "auth-int" + ] + }, + "in": { + "type": "string", + "enum": [ + "header", + "query", + "body", + "cookie", + "auto" + ] + }, + "name": { + "type": "string" + } + }, + "required": [ + "scheme" + ], + "additionalProperties": true + }, + "apiKeySecurityScheme": { + "type": "object", + "properties": { + "@type": { + "$ref": "#/definitions/type_declaration" + }, + "description": { + "$ref": "#/definitions/description" + }, + "descriptions": { + "$ref": "#/definitions/descriptions" + }, + "proxy": { + "$ref": "#/definitions/anyUri" + }, + "scheme": { + "type": "string", + "enum": [ + "apikey" + ] + }, + "in": { + "type": "string", + "enum": [ + "header", + "query", + "body", + "cookie", + "uri", + "auto" + ] + }, + "name": { + "type": "string" + } + }, + "required": [ + "scheme" + ], + "additionalProperties": true + }, + "bearerSecurityScheme": { + "type": "object", + "properties": { + "@type": { + "$ref": "#/definitions/type_declaration" + }, + "description": { + "$ref": "#/definitions/description" + }, + "descriptions": { + "$ref": "#/definitions/descriptions" + }, + "proxy": { + "$ref": "#/definitions/anyUri" + }, + "scheme": { + "type": "string", + "enum": [ + "bearer" + ] + }, + "authorization": { + "$ref": "#/definitions/anyUri" + }, + "alg": { + "type": "string" + }, + "format": { + "type": "string" + }, + "in": { + "type": "string", + "enum": [ + "header", + "query", + "body", + "cookie", + "auto" + ] + }, + "name": { + "type": "string" + } + }, + "required": [ + "scheme" + ], + "additionalProperties": true + }, + "pskSecurityScheme": { + "type": "object", + "properties": { + "@type": { + "$ref": "#/definitions/type_declaration" + }, + "description": { + "$ref": "#/definitions/description" + }, + "descriptions": { + "$ref": "#/definitions/descriptions" + }, + "proxy": { + "$ref": "#/definitions/anyUri" + }, + "scheme": { + "type": "string", + "enum": [ + "psk" + ] + }, + "identity": { + "type": "string" + } + }, + "required": [ + "scheme" + ], + "additionalProperties": true + }, + "oAuth2SecurityScheme": { + "type": "object", + "properties": { + "@type": { + "$ref": "#/definitions/type_declaration" + }, + "description": { + "$ref": "#/definitions/description" + }, + "descriptions": { + "$ref": "#/definitions/descriptions" + }, + "proxy": { + "$ref": "#/definitions/anyUri" + }, + "scheme": { + "type": "string", + "enum": [ + "oauth2" + ] + }, + "authorization": { + "$ref": "#/definitions/anyUri" + }, + "token": { + "$ref": "#/definitions/anyUri" + }, + "refresh": { + "$ref": "#/definitions/anyUri" + }, + "scopes": { + "oneOf": [ + { + "type": "array", + "items": { + "type": "string" + } + }, + { + "type": "string" + } + ] + }, + "flow": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "string", + "enum": [ + "code", + "client" + ] + } + ] + } + }, + "required": [ + "scheme" + ], + "additionalProperties": true + }, + "securityScheme": { + "oneOf": [ + { + "$ref": "#/definitions/noSecurityScheme" + }, + { + "$ref": "#/definitions/autoSecurityScheme" + }, + { + "$ref": "#/definitions/comboSecurityScheme" + }, + { + "$ref": "#/definitions/basicSecurityScheme" + }, + { + "$ref": "#/definitions/digestSecurityScheme" + }, + { + "$ref": "#/definitions/apiKeySecurityScheme" + }, + { + "$ref": "#/definitions/bearerSecurityScheme" + }, + { + "$ref": "#/definitions/pskSecurityScheme" + }, + { + "$ref": "#/definitions/oAuth2SecurityScheme" + }, + { + "$ref": "#/definitions/additionalSecurityScheme" + } + ] + } + }, + "type": "object", + "properties": { + "id": { + "type": "string", + "format": "uri" + }, + "title": { + "$ref": "#/definitions/title" + }, + "titles": { + "$ref": "#/definitions/titles" + }, + "properties": { + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/property_element" + } + }, + "actions": { + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/action_element" + } + }, + "events": { + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/event_element" + } + }, + "description": { + "$ref": "#/definitions/description" + }, + "descriptions": { + "$ref": "#/definitions/descriptions" + }, + "version": { + "type": "object", + "properties": { + "instance": { + "type": "string" + } + }, + "required": [ + "instance" + ] + }, + "links": { + "type": "array", + "items": { + "oneOf": [ + { + "$ref": "#/definitions/link_element" + }, + { + "$ref": "#/definitions/icon_link_element" + } + ] + } + }, + "forms": { + "type": "array", + "minItems": 1, + "items": { + "$ref": "#/definitions/form_element_root" + } + }, + "base": { + "$ref": "#/definitions/anyUri" + }, + "securityDefinitions": { + "type": "object", + "minProperties": 1, + "additionalProperties": { + "$ref": "#/definitions/securityScheme" + } + }, + "schemaDefinitions": { + "type": "object", + "minProperties": 1, + "additionalProperties": { + "$ref": "#/definitions/dataSchema" + } + }, + "support": { + "$ref": "#/definitions/anyUri" + }, + "created": { + "type": "string", + "format": "date-time" + }, + "modified": { + "type": "string", + "format": "date-time" + }, + "profile": { + "oneOf": [ + { + "$ref": "#/definitions/anyUri" + }, + { + "type": "array", + "minItems": 1, + "items": { + "$ref": "#/definitions/anyUri" + } + } + ] + }, + "security": { + "oneOf": [ + { + "type": "string" + }, + { + "type": "array", + "minItems": 1, + "items": { + "type": "string" + } + } + ] + }, + "uriVariables": { + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/dataSchema" + } + }, + "@type": { + "$ref": "#/definitions/type_declaration" + }, + "@context": { + "$ref": "#/definitions/thing-context" + } + }, + "required": [ + "title", + "security", + "securityDefinitions", + "@context" + ], + "additionalProperties": true +} \ No newline at end of file diff --git a/packages/modpoll-wot/modpoll_wot/schemas/tm-1.1.json b/packages/modpoll-wot/modpoll_wot/schemas/tm-1.1.json new file mode 100644 index 0000000..36bb096 --- /dev/null +++ b/packages/modpoll-wot/modpoll_wot/schemas/tm-1.1.json @@ -0,0 +1,2063 @@ +{ + "title": "Thing Model", + "version": "1.1-12-March-2025", + "description": "JSON Schema for validating Thing Models. This is automatically generated from the WoT TD Schema.", + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://www.w3.org/2022/wot/tm-schema/v1.1", + "definitions": { + "anyUri": { + "type": "string" + }, + "description": { + "type": "string" + }, + "descriptions": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "propertyNames": { + "not": { + "$ref": "#/definitions/placeholder-pattern" + } + } + }, + "title": { + "type": "string" + }, + "titles": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "propertyNames": { + "not": { + "$ref": "#/definitions/placeholder-pattern" + } + } + }, + "security": { + "oneOf": [ + { + "type": "array", + "items": { + "type": "string" + } + }, + { + "type": "string" + } + ] + }, + "scopes": { + "oneOf": [ + { + "type": "array", + "items": { + "type": "string" + } + }, + { + "type": "string" + } + ] + }, + "subprotocol": { + "type": "string", + "examples": [ + "longpoll", + "websub", + "sse" + ] + }, + "thing-context-td-uri-v1": { + "type": "string", + "const": "https://www.w3.org/2019/wot/td/v1" + }, + "thing-context-td-uri-v1.1": { + "type": "string", + "const": "https://www.w3.org/2022/wot/td/v1.1" + }, + "thing-context-td-uri-temp": { + "type": "string", + "const": "http://www.w3.org/ns/td" + }, + "thing-context": { + "anyOf": [ + { + "$comment": "New context URI with other vocabularies after it but not the old one", + "type": "array", + "items": [ + { + "$ref": "#/definitions/thing-context-td-uri-v1.1" + } + ], + "additionalItems": { + "anyOf": [ + { + "$ref": "#/definitions/anyUri" + }, + { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + ], + "not": { + "$ref": "#/definitions/thing-context-td-uri-v1" + } + } + }, + { + "$comment": "Only the new context URI", + "$ref": "#/definitions/thing-context-td-uri-v1.1" + }, + { + "$comment": "Old context URI, followed by the new one and possibly other vocabularies. minItems and contains are required since prefixItems does not say all items should be provided", + "type": "array", + "items": [ + { + "$ref": "#/definitions/thing-context-td-uri-v1" + }, + { + "$ref": "#/definitions/thing-context-td-uri-v1.1" + } + ], + "minItems": 2, + "additionalItems": { + "anyOf": [ + { + "$ref": "#/definitions/anyUri" + }, + { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + ] + } + }, + { + "$comment": "Old context URI, followed by possibly other vocabularies. minItems and contains are required since prefixItems does not say all items should be provided", + "type": "array", + "items": [ + { + "$ref": "#/definitions/thing-context-td-uri-v1" + } + ], + "minItems": 1, + "additionalItems": { + "anyOf": [ + { + "$ref": "#/definitions/anyUri" + }, + { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + ] + } + }, + { + "$comment": "Only the old context URI", + "$ref": "#/definitions/thing-context-td-uri-v1" + } + ] + }, + "bcp47_string": { + "type": "string", + "pattern": "^(((([A-Za-z]{2,3}(-([A-Za-z]{3}(-[A-Za-z]{3}){0,2}))?)|[A-Za-z]{4}|[A-Za-z]{5,8})(-([A-Za-z]{4}))?(-([A-Za-z]{2}|[0-9]{3}))?(-([A-Za-z0-9]{5,8}|[0-9][A-Za-z0-9]{3}))*(-([0-9A-WY-Za-wy-z](-[A-Za-z0-9]{2,8})+))*(-(x(-[A-Za-z0-9]{1,8})+))?)|(x(-[A-Za-z0-9]{1,8})+)|((en-GB-oed|i-ami|i-bnn|i-default|i-enochian|i-hak|i-klingon|i-lux|i-mingo|i-navajo|i-pwn|i-tao|i-tay|i-tsu|sgn-BE-FR|sgn-BE-NL|sgn-CH-DE)|(art-lojban|cel-gaulish|no-bok|no-nyn|zh-guoyu|zh-hakka|zh-min|zh-min-nan|zh-xiang)))$" + }, + "type_declaration": { + "oneOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + }, + "dataSchema-type": { + "type": "string", + "anyOf": [ + { + "enum": [ + "boolean", + "integer", + "number", + "string", + "object", + "array", + "null" + ] + }, + { + "$ref": "#/definitions/placeholder-pattern" + } + ] + }, + "dataSchema": { + "type": "object", + "properties": { + "@type": { + "$ref": "#/definitions/type_declaration" + }, + "description": { + "$ref": "#/definitions/description" + }, + "title": { + "$ref": "#/definitions/title" + }, + "descriptions": { + "$ref": "#/definitions/descriptions" + }, + "titles": { + "$ref": "#/definitions/titles" + }, + "writeOnly": { + "anyOf": [ + { + "type": "boolean" + }, + { + "$ref": "#/definitions/placeholder-pattern" + } + ] + }, + "readOnly": { + "anyOf": [ + { + "type": "boolean" + }, + { + "$ref": "#/definitions/placeholder-pattern" + } + ] + }, + "oneOf": { + "type": "array", + "items": { + "$ref": "#/definitions/dataSchema" + } + }, + "unit": { + "type": "string" + }, + "enum": { + "anyOf": [ + { + "type": "array", + "minItems": 1, + "uniqueItems": true + }, + { + "$ref": "#/definitions/placeholder-pattern" + } + ] + }, + "format": { + "type": "string" + }, + "const": {}, + "default": {}, + "contentEncoding": { + "type": "string" + }, + "contentMediaType": { + "type": "string" + }, + "type": { + "$ref": "#/definitions/dataSchema-type" + }, + "items": { + "oneOf": [ + { + "$ref": "#/definitions/dataSchema" + }, + { + "type": "array", + "items": { + "$ref": "#/definitions/dataSchema" + } + } + ] + }, + "maxItems": { + "anyOf": [ + { + "type": "integer", + "minimum": 0 + }, + { + "$ref": "#/definitions/placeholder-pattern" + } + ] + }, + "minItems": { + "anyOf": [ + { + "type": "integer", + "minimum": 0 + }, + { + "$ref": "#/definitions/placeholder-pattern" + } + ] + }, + "minimum": { + "anyOf": [ + { + "type": "number" + }, + { + "$ref": "#/definitions/placeholder-pattern" + } + ] + }, + "maximum": { + "anyOf": [ + { + "type": "number" + }, + { + "$ref": "#/definitions/placeholder-pattern" + } + ] + }, + "exclusiveMinimum": { + "type": "number" + }, + "exclusiveMaximum": { + "type": "number" + }, + "minLength": { + "anyOf": [ + { + "type": "integer", + "minimum": 0 + }, + { + "$ref": "#/definitions/placeholder-pattern" + } + ] + }, + "maxLength": { + "anyOf": [ + { + "type": "integer", + "minimum": 0 + }, + { + "$ref": "#/definitions/placeholder-pattern" + } + ] + }, + "multipleOf": { + "$ref": "#/definitions/multipleOfDefinition" + }, + "properties": { + "additionalProperties": { + "$ref": "#/definitions/dataSchema" + } + }, + "required": { + "anyOf": [ + { + "type": "array", + "items": { + "type": "string" + } + }, + { + "$ref": "#/definitions/placeholder-pattern" + } + ] + }, + "tm:ref": { + "$ref": "#/definitions/tm_ref" + } + }, + "propertyNames": { + "not": { + "$ref": "#/definitions/placeholder-pattern" + } + } + }, + "additionalResponsesDefinition": { + "type": "array", + "items": { + "type": "object", + "properties": { + "contentType": { + "type": "string" + }, + "schema": { + "type": "string" + }, + "success": { + "type": "boolean" + } + } + } + }, + "multipleOfDefinition": { + "anyOf": [ + { + "type": [ + "integer", + "number" + ], + "exclusiveMinimum": 0 + }, + { + "$ref": "#/definitions/placeholder-pattern" + } + ] + }, + "expectedResponse": { + "type": "object", + "properties": { + "contentType": { + "type": "string" + } + }, + "propertyNames": { + "not": { + "$ref": "#/definitions/placeholder-pattern" + } + } + }, + "form_element_base": { + "type": "object", + "properties": { + "op": { + "oneOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + }, + "href": { + "$ref": "#/definitions/anyUri" + }, + "contentType": { + "type": "string" + }, + "contentCoding": { + "type": "string" + }, + "subprotocol": { + "$ref": "#/definitions/subprotocol" + }, + "security": { + "$ref": "#/definitions/security" + }, + "scopes": { + "$ref": "#/definitions/scopes" + }, + "response": { + "$ref": "#/definitions/expectedResponse" + }, + "additionalResponses": { + "$ref": "#/definitions/additionalResponsesDefinition" + } + }, + "additionalProperties": true, + "propertyNames": { + "not": { + "$ref": "#/definitions/placeholder-pattern" + } + } + }, + "form_element_property": { + "allOf": [ + { + "$ref": "#/definitions/form_element_base" + } + ], + "type": "object", + "properties": { + "op": { + "oneOf": [ + { + "type": "string", + "anyOf": [ + { + "enum": [ + "readproperty", + "writeproperty", + "observeproperty", + "unobserveproperty" + ] + }, + { + "$ref": "#/definitions/placeholder-pattern" + } + ] + }, + { + "type": "array", + "items": { + "type": "string", + "anyOf": [ + { + "enum": [ + "readproperty", + "writeproperty", + "observeproperty", + "unobserveproperty" + ] + }, + { + "$ref": "#/definitions/placeholder-pattern" + } + ] + }, + "minItems": 1 + } + ] + }, + "tm:ref": { + "$ref": "#/definitions/tm_ref" + } + }, + "additionalProperties": true, + "propertyNames": { + "not": { + "$ref": "#/definitions/placeholder-pattern" + } + } + }, + "form_element_action": { + "allOf": [ + { + "$ref": "#/definitions/form_element_base" + } + ], + "type": "object", + "properties": { + "op": { + "oneOf": [ + { + "type": "string", + "anyOf": [ + { + "enum": [ + "invokeaction", + "queryaction", + "cancelaction" + ] + }, + { + "$ref": "#/definitions/placeholder-pattern" + } + ] + }, + { + "type": "array", + "items": { + "type": "string", + "anyOf": [ + { + "enum": [ + "invokeaction", + "queryaction", + "cancelaction" + ] + }, + { + "$ref": "#/definitions/placeholder-pattern" + } + ] + }, + "minItems": 1 + } + ] + }, + "tm:ref": { + "$ref": "#/definitions/tm_ref" + } + }, + "additionalProperties": true, + "propertyNames": { + "not": { + "$ref": "#/definitions/placeholder-pattern" + } + } + }, + "form_element_event": { + "allOf": [ + { + "$ref": "#/definitions/form_element_base" + } + ], + "type": "object", + "properties": { + "op": { + "oneOf": [ + { + "type": "string", + "anyOf": [ + { + "enum": [ + "subscribeevent", + "unsubscribeevent" + ] + }, + { + "$ref": "#/definitions/placeholder-pattern" + } + ] + }, + { + "type": "array", + "items": { + "type": "string", + "anyOf": [ + { + "enum": [ + "subscribeevent", + "unsubscribeevent" + ] + }, + { + "$ref": "#/definitions/placeholder-pattern" + } + ] + }, + "minItems": 1 + } + ] + }, + "tm:ref": { + "$ref": "#/definitions/tm_ref" + } + }, + "additionalProperties": true, + "propertyNames": { + "not": { + "$ref": "#/definitions/placeholder-pattern" + } + } + }, + "form_element_root": { + "allOf": [ + { + "$ref": "#/definitions/form_element_base" + } + ], + "type": "object", + "properties": { + "op": { + "oneOf": [ + { + "type": "string", + "anyOf": [ + { + "enum": [ + "readallproperties", + "writeallproperties", + "readmultipleproperties", + "writemultipleproperties", + "observeallproperties", + "unobserveallproperties", + "queryallactions", + "subscribeallevents", + "unsubscribeallevents" + ] + }, + { + "$ref": "#/definitions/placeholder-pattern" + } + ] + }, + { + "type": "array", + "items": { + "type": "string", + "anyOf": [ + { + "enum": [ + "readallproperties", + "writeallproperties", + "readmultipleproperties", + "writemultipleproperties", + "observeallproperties", + "unobserveallproperties", + "queryallactions", + "subscribeallevents", + "unsubscribeallevents" + ] + }, + { + "$ref": "#/definitions/placeholder-pattern" + } + ] + }, + "minItems": 1 + } + ] + }, + "tm:ref": { + "$ref": "#/definitions/tm_ref" + } + }, + "additionalProperties": true, + "propertyNames": { + "not": { + "$ref": "#/definitions/placeholder-pattern" + } + } + }, + "form": { + "$comment": "This is NOT for validation purposes but for automatic generation of TS types. For more info, please see: https://github.com/w3c/wot-thing-description/pull/1319#issuecomment-994950057", + "oneOf": [ + { + "$ref": "#/definitions/form_element_property" + }, + { + "$ref": "#/definitions/form_element_action" + }, + { + "$ref": "#/definitions/form_element_event" + }, + { + "$ref": "#/definitions/form_element_root" + } + ] + }, + "property_element": { + "type": "object", + "properties": { + "@type": { + "$ref": "#/definitions/type_declaration" + }, + "description": { + "$ref": "#/definitions/description" + }, + "descriptions": { + "$ref": "#/definitions/descriptions" + }, + "title": { + "$ref": "#/definitions/title" + }, + "titles": { + "$ref": "#/definitions/titles" + }, + "forms": { + "type": "array", + "minItems": 1, + "items": { + "$ref": "#/definitions/form_element_property" + } + }, + "uriVariables": { + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/dataSchema" + }, + "propertyNames": { + "not": { + "$ref": "#/definitions/placeholder-pattern" + } + } + }, + "observable": { + "anyOf": [ + { + "type": "boolean" + }, + { + "$ref": "#/definitions/placeholder-pattern" + } + ] + }, + "writeOnly": { + "anyOf": [ + { + "type": "boolean" + }, + { + "$ref": "#/definitions/placeholder-pattern" + } + ] + }, + "readOnly": { + "anyOf": [ + { + "type": "boolean" + }, + { + "$ref": "#/definitions/placeholder-pattern" + } + ] + }, + "oneOf": { + "type": "array", + "items": { + "$ref": "#/definitions/dataSchema" + } + }, + "unit": { + "type": "string" + }, + "enum": { + "anyOf": [ + { + "type": "array", + "minItems": 1, + "uniqueItems": true + }, + { + "$ref": "#/definitions/placeholder-pattern" + } + ] + }, + "format": { + "type": "string" + }, + "const": {}, + "default": {}, + "type": { + "$ref": "#/definitions/dataSchema-type" + }, + "items": { + "oneOf": [ + { + "$ref": "#/definitions/dataSchema" + }, + { + "type": "array", + "items": { + "$ref": "#/definitions/dataSchema" + } + } + ] + }, + "maxItems": { + "anyOf": [ + { + "type": "integer", + "minimum": 0 + }, + { + "$ref": "#/definitions/placeholder-pattern" + } + ] + }, + "minItems": { + "anyOf": [ + { + "type": "integer", + "minimum": 0 + }, + { + "$ref": "#/definitions/placeholder-pattern" + } + ] + }, + "minimum": { + "anyOf": [ + { + "type": "number" + }, + { + "$ref": "#/definitions/placeholder-pattern" + } + ] + }, + "maximum": { + "anyOf": [ + { + "type": "number" + }, + { + "$ref": "#/definitions/placeholder-pattern" + } + ] + }, + "exclusiveMinimum": { + "type": "number" + }, + "exclusiveMaximum": { + "type": "number" + }, + "minLength": { + "anyOf": [ + { + "type": "integer", + "minimum": 0 + }, + { + "$ref": "#/definitions/placeholder-pattern" + } + ] + }, + "maxLength": { + "anyOf": [ + { + "type": "integer", + "minimum": 0 + }, + { + "$ref": "#/definitions/placeholder-pattern" + } + ] + }, + "multipleOf": { + "$ref": "#/definitions/multipleOfDefinition" + }, + "properties": { + "additionalProperties": { + "$ref": "#/definitions/dataSchema" + } + }, + "required": { + "anyOf": [ + { + "type": "array", + "items": { + "type": "string" + } + }, + { + "$ref": "#/definitions/placeholder-pattern" + } + ] + }, + "tm:ref": { + "$ref": "#/definitions/tm_ref" + } + }, + "additionalProperties": true, + "propertyNames": { + "not": { + "$ref": "#/definitions/placeholder-pattern" + } + } + }, + "action_element": { + "type": "object", + "properties": { + "@type": { + "$ref": "#/definitions/type_declaration" + }, + "description": { + "$ref": "#/definitions/description" + }, + "descriptions": { + "$ref": "#/definitions/descriptions" + }, + "title": { + "$ref": "#/definitions/title" + }, + "titles": { + "$ref": "#/definitions/titles" + }, + "forms": { + "type": "array", + "minItems": 1, + "items": { + "$ref": "#/definitions/form_element_action" + } + }, + "uriVariables": { + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/dataSchema" + }, + "propertyNames": { + "not": { + "$ref": "#/definitions/placeholder-pattern" + } + } + }, + "input": { + "$ref": "#/definitions/dataSchema" + }, + "output": { + "$ref": "#/definitions/dataSchema" + }, + "safe": { + "anyOf": [ + { + "type": "boolean" + }, + { + "$ref": "#/definitions/placeholder-pattern" + } + ] + }, + "idempotent": { + "anyOf": [ + { + "type": "boolean" + }, + { + "$ref": "#/definitions/placeholder-pattern" + } + ] + }, + "synchronous": { + "anyOf": [ + { + "type": "boolean" + }, + { + "$ref": "#/definitions/placeholder-pattern" + } + ] + }, + "tm:ref": { + "$ref": "#/definitions/tm_ref" + } + }, + "additionalProperties": true, + "propertyNames": { + "not": { + "$ref": "#/definitions/placeholder-pattern" + } + } + }, + "event_element": { + "type": "object", + "properties": { + "@type": { + "$ref": "#/definitions/type_declaration" + }, + "description": { + "$ref": "#/definitions/description" + }, + "descriptions": { + "$ref": "#/definitions/descriptions" + }, + "title": { + "$ref": "#/definitions/title" + }, + "titles": { + "$ref": "#/definitions/titles" + }, + "forms": { + "type": "array", + "minItems": 1, + "items": { + "$ref": "#/definitions/form_element_event" + } + }, + "uriVariables": { + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/dataSchema" + }, + "propertyNames": { + "not": { + "$ref": "#/definitions/placeholder-pattern" + } + } + }, + "subscription": { + "$ref": "#/definitions/dataSchema" + }, + "data": { + "$ref": "#/definitions/dataSchema" + }, + "dataResponse": { + "$ref": "#/definitions/dataSchema" + }, + "cancellation": { + "$ref": "#/definitions/dataSchema" + }, + "tm:ref": { + "$ref": "#/definitions/tm_ref" + } + }, + "additionalProperties": true, + "propertyNames": { + "not": { + "$ref": "#/definitions/placeholder-pattern" + } + } + }, + "base_link_element": { + "type": "object", + "properties": { + "href": { + "$ref": "#/definitions/anyUri" + }, + "type": { + "type": "string" + }, + "rel": { + "type": "string" + }, + "anchor": { + "$ref": "#/definitions/anyUri" + }, + "hreflang": { + "anyOf": [ + { + "$ref": "#/definitions/bcp47_string" + }, + { + "type": "array", + "items": { + "$ref": "#/definitions/bcp47_string" + } + } + ] + }, + "instanceName": { + "type": "string" + } + }, + "additionalProperties": true, + "propertyNames": { + "not": { + "$ref": "#/definitions/placeholder-pattern" + } + } + }, + "link_element": { + "allOf": [ + { + "$ref": "#/definitions/base_link_element" + }, + { + "not": { + "description": "A basic link element should not contain sizes", + "type": "object", + "properties": { + "sizes": {} + }, + "required": [ + "sizes" + ] + } + }, + { + "not": { + "description": "A basic link element should not contain icon", + "properties": { + "rel": { + "anyOf": [ + { + "enum": [ + "icon" + ] + }, + { + "$ref": "#/definitions/placeholder-pattern" + } + ] + } + }, + "required": [ + "rel" + ] + } + } + ] + }, + "icon_link_element": { + "allOf": [ + { + "$ref": "#/definitions/base_link_element" + }, + { + "properties": { + "rel": { + "const": "icon" + }, + "sizes": { + "type": "string", + "pattern": "[0-9]*x[0-9]+" + } + }, + "required": [ + "rel" + ] + } + ] + }, + "additionalSecurityScheme": { + "description": "Applies to additional SecuritySchemes not defined in the WoT TD specification.", + "$comment": "Additional SecuritySchemes should always be defined via a context extension, using a prefixed value for the scheme. This prefix (e.g. 'ace', see the example below) must contain at least one character in order to reference a valid JSON-LD context extension.", + "examples": [ + { + "scheme": "ace:ACESecurityScheme", + "ace:as": "coaps://as.example.com/token", + "ace:audience": "coaps://rs.example.com", + "ace:scopes": [ + "limited", + "special" + ], + "ace:cnonce": true + } + ], + "type": "object", + "properties": { + "@type": { + "$ref": "#/definitions/type_declaration" + }, + "description": { + "$ref": "#/definitions/description" + }, + "descriptions": { + "$ref": "#/definitions/descriptions" + }, + "proxy": { + "$ref": "#/definitions/anyUri" + }, + "scheme": { + "type": "string", + "pattern": ".+:.*" + } + }, + "additionalProperties": true, + "propertyNames": { + "not": { + "$ref": "#/definitions/placeholder-pattern" + } + } + }, + "noSecurityScheme": { + "type": "object", + "properties": { + "@type": { + "$ref": "#/definitions/type_declaration" + }, + "description": { + "$ref": "#/definitions/description" + }, + "descriptions": { + "$ref": "#/definitions/descriptions" + }, + "proxy": { + "$ref": "#/definitions/anyUri" + }, + "scheme": { + "type": "string", + "anyOf": [ + { + "enum": [ + "nosec" + ] + }, + { + "$ref": "#/definitions/placeholder-pattern" + } + ] + }, + "tm:ref": { + "$ref": "#/definitions/tm_ref" + } + }, + "additionalProperties": true, + "propertyNames": { + "not": { + "$ref": "#/definitions/placeholder-pattern" + } + } + }, + "autoSecurityScheme": { + "type": "object", + "properties": { + "@type": { + "$ref": "#/definitions/type_declaration" + }, + "description": { + "$ref": "#/definitions/description" + }, + "descriptions": { + "$ref": "#/definitions/descriptions" + }, + "proxy": { + "$ref": "#/definitions/anyUri" + }, + "scheme": { + "type": "string", + "anyOf": [ + { + "enum": [ + "auto" + ] + }, + { + "$ref": "#/definitions/placeholder-pattern" + } + ] + } + }, + "not": { + "required": [ + "name" + ] + }, + "additionalProperties": true, + "propertyNames": { + "not": { + "$ref": "#/definitions/placeholder-pattern" + } + } + }, + "comboSecurityScheme": { + "oneOf": [ + { + "type": "object", + "properties": { + "@type": { + "$ref": "#/definitions/type_declaration" + }, + "description": { + "$ref": "#/definitions/description" + }, + "descriptions": { + "$ref": "#/definitions/descriptions" + }, + "proxy": { + "$ref": "#/definitions/anyUri" + }, + "scheme": { + "type": "string", + "anyOf": [ + { + "enum": [ + "combo" + ] + }, + { + "$ref": "#/definitions/placeholder-pattern" + } + ] + }, + "oneOf": { + "type": "array", + "minItems": 2, + "items": { + "type": "string" + } + }, + "tm:ref": { + "$ref": "#/definitions/tm_ref" + } + }, + "additionalProperties": true + }, + { + "type": "object", + "properties": { + "@type": { + "$ref": "#/definitions/type_declaration" + }, + "description": { + "$ref": "#/definitions/description" + }, + "descriptions": { + "$ref": "#/definitions/descriptions" + }, + "proxy": { + "$ref": "#/definitions/anyUri" + }, + "scheme": { + "type": "string", + "anyOf": [ + { + "enum": [ + "combo" + ] + }, + { + "$ref": "#/definitions/placeholder-pattern" + } + ] + }, + "allOf": { + "type": "array", + "minItems": 2, + "items": { + "type": "string" + } + }, + "tm:ref": { + "$ref": "#/definitions/tm_ref" + } + }, + "additionalProperties": true + } + ] + }, + "basicSecurityScheme": { + "type": "object", + "properties": { + "@type": { + "$ref": "#/definitions/type_declaration" + }, + "description": { + "$ref": "#/definitions/description" + }, + "descriptions": { + "$ref": "#/definitions/descriptions" + }, + "proxy": { + "$ref": "#/definitions/anyUri" + }, + "scheme": { + "type": "string", + "anyOf": [ + { + "enum": [ + "basic" + ] + }, + { + "$ref": "#/definitions/placeholder-pattern" + } + ] + }, + "in": { + "type": "string", + "anyOf": [ + { + "enum": [ + "header", + "query", + "body", + "cookie", + "auto" + ] + }, + { + "$ref": "#/definitions/placeholder-pattern" + } + ] + }, + "name": { + "type": "string" + }, + "tm:ref": { + "$ref": "#/definitions/tm_ref" + } + }, + "additionalProperties": true, + "propertyNames": { + "not": { + "$ref": "#/definitions/placeholder-pattern" + } + } + }, + "digestSecurityScheme": { + "type": "object", + "properties": { + "@type": { + "$ref": "#/definitions/type_declaration" + }, + "description": { + "$ref": "#/definitions/description" + }, + "descriptions": { + "$ref": "#/definitions/descriptions" + }, + "proxy": { + "$ref": "#/definitions/anyUri" + }, + "scheme": { + "type": "string", + "anyOf": [ + { + "enum": [ + "digest" + ] + }, + { + "$ref": "#/definitions/placeholder-pattern" + } + ] + }, + "qop": { + "type": "string", + "anyOf": [ + { + "enum": [ + "auth", + "auth-int" + ] + }, + { + "$ref": "#/definitions/placeholder-pattern" + } + ] + }, + "in": { + "type": "string", + "anyOf": [ + { + "enum": [ + "header", + "query", + "body", + "cookie", + "auto" + ] + }, + { + "$ref": "#/definitions/placeholder-pattern" + } + ] + }, + "name": { + "type": "string" + }, + "tm:ref": { + "$ref": "#/definitions/tm_ref" + } + }, + "additionalProperties": true, + "propertyNames": { + "not": { + "$ref": "#/definitions/placeholder-pattern" + } + } + }, + "apiKeySecurityScheme": { + "type": "object", + "properties": { + "@type": { + "$ref": "#/definitions/type_declaration" + }, + "description": { + "$ref": "#/definitions/description" + }, + "descriptions": { + "$ref": "#/definitions/descriptions" + }, + "proxy": { + "$ref": "#/definitions/anyUri" + }, + "scheme": { + "type": "string", + "anyOf": [ + { + "enum": [ + "apikey" + ] + }, + { + "$ref": "#/definitions/placeholder-pattern" + } + ] + }, + "in": { + "type": "string", + "anyOf": [ + { + "enum": [ + "header", + "query", + "body", + "cookie", + "uri", + "auto" + ] + }, + { + "$ref": "#/definitions/placeholder-pattern" + } + ] + }, + "name": { + "type": "string" + }, + "tm:ref": { + "$ref": "#/definitions/tm_ref" + } + }, + "additionalProperties": true, + "propertyNames": { + "not": { + "$ref": "#/definitions/placeholder-pattern" + } + } + }, + "bearerSecurityScheme": { + "type": "object", + "properties": { + "@type": { + "$ref": "#/definitions/type_declaration" + }, + "description": { + "$ref": "#/definitions/description" + }, + "descriptions": { + "$ref": "#/definitions/descriptions" + }, + "proxy": { + "$ref": "#/definitions/anyUri" + }, + "scheme": { + "type": "string", + "anyOf": [ + { + "enum": [ + "bearer" + ] + }, + { + "$ref": "#/definitions/placeholder-pattern" + } + ] + }, + "authorization": { + "$ref": "#/definitions/anyUri" + }, + "alg": { + "type": "string" + }, + "format": { + "type": "string" + }, + "in": { + "type": "string", + "anyOf": [ + { + "enum": [ + "header", + "query", + "body", + "cookie", + "auto" + ] + }, + { + "$ref": "#/definitions/placeholder-pattern" + } + ] + }, + "name": { + "type": "string" + }, + "tm:ref": { + "$ref": "#/definitions/tm_ref" + } + }, + "additionalProperties": true, + "propertyNames": { + "not": { + "$ref": "#/definitions/placeholder-pattern" + } + } + }, + "pskSecurityScheme": { + "type": "object", + "properties": { + "@type": { + "$ref": "#/definitions/type_declaration" + }, + "description": { + "$ref": "#/definitions/description" + }, + "descriptions": { + "$ref": "#/definitions/descriptions" + }, + "proxy": { + "$ref": "#/definitions/anyUri" + }, + "scheme": { + "type": "string", + "anyOf": [ + { + "enum": [ + "psk" + ] + }, + { + "$ref": "#/definitions/placeholder-pattern" + } + ] + }, + "identity": { + "type": "string" + }, + "tm:ref": { + "$ref": "#/definitions/tm_ref" + } + }, + "additionalProperties": true, + "propertyNames": { + "not": { + "$ref": "#/definitions/placeholder-pattern" + } + } + }, + "oAuth2SecurityScheme": { + "type": "object", + "properties": { + "@type": { + "$ref": "#/definitions/type_declaration" + }, + "description": { + "$ref": "#/definitions/description" + }, + "descriptions": { + "$ref": "#/definitions/descriptions" + }, + "proxy": { + "$ref": "#/definitions/anyUri" + }, + "scheme": { + "type": "string", + "anyOf": [ + { + "enum": [ + "oauth2" + ] + }, + { + "$ref": "#/definitions/placeholder-pattern" + } + ] + }, + "authorization": { + "$ref": "#/definitions/anyUri" + }, + "token": { + "$ref": "#/definitions/anyUri" + }, + "refresh": { + "$ref": "#/definitions/anyUri" + }, + "scopes": { + "oneOf": [ + { + "type": "array", + "items": { + "type": "string" + } + }, + { + "type": "string" + } + ] + }, + "flow": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "string", + "anyOf": [ + { + "enum": [ + "code", + "client" + ] + }, + { + "$ref": "#/definitions/placeholder-pattern" + } + ] + } + ] + }, + "tm:ref": { + "$ref": "#/definitions/tm_ref" + } + }, + "additionalProperties": true, + "propertyNames": { + "not": { + "$ref": "#/definitions/placeholder-pattern" + } + } + }, + "securityScheme": { + "anyOf": [ + { + "$ref": "#/definitions/noSecurityScheme" + }, + { + "$ref": "#/definitions/autoSecurityScheme" + }, + { + "$ref": "#/definitions/comboSecurityScheme" + }, + { + "$ref": "#/definitions/basicSecurityScheme" + }, + { + "$ref": "#/definitions/digestSecurityScheme" + }, + { + "$ref": "#/definitions/apiKeySecurityScheme" + }, + { + "$ref": "#/definitions/bearerSecurityScheme" + }, + { + "$ref": "#/definitions/pskSecurityScheme" + }, + { + "$ref": "#/definitions/oAuth2SecurityScheme" + }, + { + "$ref": "#/definitions/additionalSecurityScheme" + } + ] + }, + "tm_type_declaration": { + "oneOf": [ + { + "type": "string", + "const": "tm:ThingModel" + }, + { + "type": "array", + "items": { + "type": "string" + }, + "contains": { + "const": "tm:ThingModel" + } + } + ] + }, + "placeholder-pattern": { + "type": "string", + "pattern": "^.*[{]{2}[ -~]+[}]{2}.*$" + }, + "tm_optional": { + "type": "array", + "items": { + "$comment": "this first checks for the general structure of /properties/myProp and then prohibits using / 3 times", + "allOf": [ + { + "type": "string", + "pattern": "^((/properties/)|(/actions/)|(/events/))(([^/]))", + "$comment": "regex tests available at https://regex101.com/r/UgOzrJ/1" + }, + { + "not": { + "type": "string", + "pattern": "(/)(.*/){2}", + "$comment": "regex tests available at https://regex101.com/r/r7vB0r/2" + } + } + ] + } + }, + "tm_ref": { + "type": "string", + "format": "uri-reference" + } + }, + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "title": { + "$ref": "#/definitions/title" + }, + "titles": { + "$ref": "#/definitions/titles" + }, + "properties": { + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/property_element" + }, + "propertyNames": { + "not": { + "$ref": "#/definitions/placeholder-pattern" + } + } + }, + "actions": { + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/action_element" + }, + "propertyNames": { + "not": { + "$ref": "#/definitions/placeholder-pattern" + } + } + }, + "events": { + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/event_element" + }, + "propertyNames": { + "not": { + "$ref": "#/definitions/placeholder-pattern" + } + } + }, + "description": { + "$ref": "#/definitions/description" + }, + "descriptions": { + "$ref": "#/definitions/descriptions" + }, + "version": { + "anyOf": [ + { + "type": "object", + "properties": { + "model": { + "type": "string" + } + }, + "propertyNames": { + "not": { + "$ref": "#/definitions/placeholder-pattern" + } + }, + "not": { + "type": "object", + "properties": { + "instance": { + "type": "string" + } + }, + "required": [ + "instance" + ] + } + }, + { + "$ref": "#/definitions/placeholder-pattern" + } + ] + }, + "links": { + "type": "array", + "items": { + "oneOf": [ + { + "$ref": "#/definitions/link_element" + }, + { + "$ref": "#/definitions/icon_link_element" + } + ] + } + }, + "forms": { + "type": "array", + "minItems": 1, + "items": { + "$ref": "#/definitions/form_element_root" + } + }, + "base": { + "$ref": "#/definitions/anyUri" + }, + "securityDefinitions": { + "type": "object", + "minProperties": 1, + "additionalProperties": { + "$ref": "#/definitions/securityScheme" + }, + "propertyNames": { + "not": { + "$ref": "#/definitions/placeholder-pattern" + } + } + }, + "schemaDefinitions": { + "type": "object", + "minProperties": 1, + "additionalProperties": { + "$ref": "#/definitions/dataSchema" + }, + "propertyNames": { + "not": { + "$ref": "#/definitions/placeholder-pattern" + } + } + }, + "support": { + "$ref": "#/definitions/anyUri" + }, + "created": { + "type": "string" + }, + "modified": { + "type": "string" + }, + "profile": { + "oneOf": [ + { + "$ref": "#/definitions/anyUri" + }, + { + "type": "array", + "minItems": 1, + "items": { + "$ref": "#/definitions/anyUri" + } + } + ] + }, + "security": { + "oneOf": [ + { + "type": "string" + }, + { + "type": "array", + "minItems": 1, + "items": { + "type": "string" + } + } + ] + }, + "uriVariables": { + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/dataSchema" + }, + "propertyNames": { + "not": { + "$ref": "#/definitions/placeholder-pattern" + } + } + }, + "@type": { + "$ref": "#/definitions/tm_type_declaration" + }, + "@context": { + "$ref": "#/definitions/thing-context" + }, + "tm:optional": { + "$ref": "#/definitions/tm_optional" + } + }, + "additionalProperties": true, + "propertyNames": { + "not": { + "$ref": "#/definitions/placeholder-pattern" + } + }, + "required": [ + "@context", + "@type" + ] +} \ No newline at end of file diff --git a/packages/modpoll-wot/modpoll_wot/schemas/verification-report-3.json b/packages/modpoll-wot/modpoll_wot/schemas/verification-report-3.json new file mode 100644 index 0000000..5f8f923 --- /dev/null +++ b/packages/modpoll-wot/modpoll_wot/schemas/verification-report-3.json @@ -0,0 +1,101 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://github.com/top-maker/modpoll-wot/schemas/verification-report-3.json", + "title": "Modbus hardware verification report", + "description": "One reading of a Thing Model on a physical device, without endpoints, serial numbers or raw values.", + "type": "object", + "additionalProperties": false, + "required": ["reportVersion", "product", "model", "tool", "transport", "date", "points"], + "properties": { + "reportVersion": { "const": 3 }, + "product": { "$ref": "#/$defs/productId" }, + "model": { + "type": "object", + "additionalProperties": false, + "required": ["sha256", "fingerprint", "source"], + "properties": { + "sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" }, + "fingerprint": { "type": "string", "pattern": "^mf1:[0-9a-f]{64}$" }, + "source": { "enum": ["catalog", "workspace", "local"] }, + "ref": { "type": "string", "minLength": 1, "maxLength": 128 } + }, + "allOf": [ + { + "if": { "properties": { "source": { "const": "catalog" } } }, + "then": { + "required": ["ref"], + "properties": { "ref": { "pattern": "^[0-9a-f]{40}$" } } + } + }, + { + "if": { "properties": { "source": { "const": "workspace" } } }, + "then": { "required": ["ref"] } + }, + { + "if": { "properties": { "source": { "const": "local" } } }, + "then": { + "not": { "required": ["ref"] } + } + } + ] + }, + "tool": { + "type": "object", + "additionalProperties": false, + "required": ["name", "version", "interpreter"], + "properties": { + "name": { "$ref": "#/$defs/slug" }, + "version": { "$ref": "#/$defs/version" }, + "interpreter": { "$ref": "#/$defs/version" } + } + }, + "transport": { "enum": ["tcp", "rtu"] }, + "date": { "type": "string", "pattern": "^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$" }, + "environment": { + "type": "object", + "additionalProperties": false, + "properties": { + "chassis": { "$ref": "#/$defs/productId" }, + "firmware": { "type": "string", "minLength": 1, "maxLength": 64 }, + "configuration": { "type": "string", "minLength": 1, "maxLength": 200 } + } + }, + "points": { + "type": "array", + "minItems": 1, + "maxItems": 1000, + "items": { + "type": "object", + "additionalProperties": false, + "required": ["property", "fingerprint", "read", "expected"], + "properties": { + "property": { "type": "string", "minLength": 1, "maxLength": 128 }, + "fingerprint": { "type": "string", "pattern": "^pf1:[0-9a-f]{64}$" }, + "read": { "enum": ["ok", "exception", "no-response", "not-tested"] }, + "exceptionCode": { "type": "integer", "minimum": 1, "maximum": 255 }, + "expected": { "enum": ["confirmed", "rejected", "unchecked"] } + }, + "allOf": [ + { + "if": { "properties": { "read": { "const": "exception" } } }, + "then": { "required": ["exceptionCode"] }, + "else": { "not": { "required": ["exceptionCode"] } } + }, + { + "if": { "properties": { "read": { "not": { "const": "ok" } } } }, + "then": { "properties": { "expected": { "const": "unchecked" } } } + } + ] + } + } + }, + "$defs": { + "slug": { "type": "string", "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$", "maxLength": 64 }, + "productId": { + "type": "string", + "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*/[a-z0-9]+(?:-[a-z0-9]+)*$", + "maxLength": 129 + }, + "version": { "type": "string", "pattern": "^[0-9A-Za-z.+-]{1,64}$" } + } +} diff --git a/packages/modpoll-wot/modpoll_wot/schemas/verification-report-4.json b/packages/modpoll-wot/modpoll_wot/schemas/verification-report-4.json new file mode 100644 index 0000000..1654f9f --- /dev/null +++ b/packages/modpoll-wot/modpoll_wot/schemas/verification-report-4.json @@ -0,0 +1,258 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://github.com/top-maker/modpoll-wot/schemas/verification-report-4.json", + "title": "Modbus hardware verification report", + "description": "One reading of a Thing Model on a physical device, without endpoints, serial numbers or raw values. The receiving service resolves the catalog product from the model fingerprint; a report may still carry product.", + "type": "object", + "additionalProperties": false, + "required": [ + "reportVersion", + "model", + "tool", + "transport", + "date", + "points" + ], + "properties": { + "reportVersion": { + "const": 4 + }, + "product": { + "$ref": "#/$defs/productId" + }, + "model": { + "type": "object", + "additionalProperties": false, + "required": [ + "sha256", + "fingerprint", + "source" + ], + "properties": { + "sha256": { + "type": "string", + "pattern": "^[0-9a-f]{64}$" + }, + "fingerprint": { + "type": "string", + "pattern": "^mf1:[0-9a-f]{64}$" + }, + "source": { + "enum": [ + "catalog", + "workspace", + "local" + ] + }, + "ref": { + "type": "string", + "minLength": 1, + "maxLength": 128 + } + }, + "allOf": [ + { + "if": { + "properties": { + "source": { + "const": "catalog" + } + } + }, + "then": { + "required": [ + "ref" + ], + "properties": { + "ref": { + "pattern": "^[0-9a-f]{40}$" + } + } + } + }, + { + "if": { + "properties": { + "source": { + "const": "workspace" + } + } + }, + "then": { + "required": [ + "ref" + ] + } + }, + { + "if": { + "properties": { + "source": { + "const": "local" + } + } + }, + "then": { + "not": { + "required": [ + "ref" + ] + } + } + } + ] + }, + "tool": { + "type": "object", + "additionalProperties": false, + "required": [ + "name", + "version", + "interpreter" + ], + "properties": { + "name": { + "$ref": "#/$defs/slug" + }, + "version": { + "$ref": "#/$defs/version" + }, + "interpreter": { + "$ref": "#/$defs/version" + } + } + }, + "transport": { + "enum": [ + "tcp", + "rtu" + ] + }, + "date": { + "type": "string", + "pattern": "^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$" + }, + "environment": { + "type": "object", + "additionalProperties": false, + "properties": { + "chassis": { + "$ref": "#/$defs/productId" + }, + "firmware": { + "type": "string", + "minLength": 1, + "maxLength": 64 + }, + "configuration": { + "type": "string", + "minLength": 1, + "maxLength": 200 + } + } + }, + "points": { + "type": "array", + "minItems": 1, + "maxItems": 1000, + "items": { + "type": "object", + "additionalProperties": false, + "required": [ + "property", + "fingerprint", + "read", + "expected" + ], + "properties": { + "property": { + "type": "string", + "minLength": 1, + "maxLength": 128 + }, + "fingerprint": { + "type": "string", + "pattern": "^pf1:[0-9a-f]{64}$" + }, + "read": { + "enum": [ + "ok", + "exception", + "no-response", + "not-tested" + ] + }, + "exceptionCode": { + "type": "integer", + "minimum": 1, + "maximum": 255 + }, + "expected": { + "enum": [ + "confirmed", + "rejected", + "unchecked" + ] + } + }, + "allOf": [ + { + "if": { + "properties": { + "read": { + "const": "exception" + } + } + }, + "then": { + "required": [ + "exceptionCode" + ] + }, + "else": { + "not": { + "required": [ + "exceptionCode" + ] + } + } + }, + { + "if": { + "properties": { + "read": { + "not": { + "const": "ok" + } + } + } + }, + "then": { + "properties": { + "expected": { + "const": "unchecked" + } + } + } + } + ] + } + } + }, + "$defs": { + "slug": { + "type": "string", + "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$", + "maxLength": 64 + }, + "productId": { + "type": "string", + "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*/[a-z0-9]+(?:-[a-z0-9]+)*$", + "maxLength": 129 + }, + "version": { + "type": "string", + "pattern": "^[0-9A-Za-z.+-]{1,64}$" + } + } +} diff --git a/packages/modpoll-wot/modpoll_wot/schemas/w3c-binding-license.txt b/packages/modpoll-wot/modpoll_wot/schemas/w3c-binding-license.txt new file mode 100644 index 0000000..d4dca97 --- /dev/null +++ b/packages/modpoll-wot/modpoll_wot/schemas/w3c-binding-license.txt @@ -0,0 +1,9 @@ +All Reports in this Repository are licensed by Contributors +under the +[W3C Software and Document License](http://www.w3.org/Consortium/Legal/2015/copyright-software-and-document). + +Contributions to Specifications are made under the +[W3C CLA](https://www.w3.org/community/about/agreements/cla/). + +Contributions to Test Suites are made under the +[W3C 3-clause BSD License](https://www.w3.org/Consortium/Legal/2008/03-bsd-license.html) diff --git a/packages/modpoll-wot/modpoll_wot/session.py b/packages/modpoll-wot/modpoll_wot/session.py new file mode 100644 index 0000000..a083075 --- /dev/null +++ b/packages/modpoll-wot/modpoll_wot/session.py @@ -0,0 +1,198 @@ +"""Tool session credentials and workspace references, shared by modpoll and modsim. + +This module only defines where a tool session token is kept and how a Workspace Thing Model is named. It +makes no request: signing in (the OAuth device authorization flow against ModioHub) belongs to each tool, +so every tool that reads this file works with a login made by any other. +""" + +from dataclasses import dataclass +from datetime import datetime, timedelta, timezone +import json +import os +from pathlib import Path +import re +import stat +import sys +import tempfile +from urllib.parse import urlsplit + +DEFAULT_SERVER = "https://modiohub.com" +TOKEN_VARIABLE = "MODIOHUB_TOKEN" +SERVER_VARIABLE = "MODIOHUB_URL" +FILE_VARIABLE = "MODIOHUB_CREDENTIALS" +REFERENCE_PREFIX = "modiohub:" +FILE_VERSION = 1 +_REFERENCE = re.compile(r"^modiohub:([a-z0-9]{16})(?:@([1-9][0-9]{0,2}|latest))?$") +_LOCAL = {"localhost", "127.0.0.1", "::1"} + + +class CredentialError(ValueError): + """The credentials file or a server address cannot be used.""" + + +@dataclass(frozen=True) +class Session: + server: str + token: str + github_user: str | None + expires_at: datetime | None + source: str # "environment" or "file" + + +@dataclass(frozen=True) +class Reference: + id: str + version: str # a number as text, or "latest" + + +def parse_reference(text): + """Parse ``modiohub:<id>[@<version>]``; the version is a number or ``latest`` (the default).""" + match = _REFERENCE.match(text) + if not match: + raise ValueError( + "a Workspace Thing Model is named modiohub:<id>@<version>, " + "where the version is a number or latest" + ) + return Reference(match.group(1), match.group(2) or "latest") + + +def server_url(environ=None): + """The ModioHub origin: ``MODIOHUB_URL`` or the default; https, except for a local server.""" + environ = os.environ if environ is None else environ + text = environ.get(SERVER_VARIABLE) or DEFAULT_SERVER + parts = urlsplit(text) + if parts.scheme not in ("http", "https") or not parts.hostname: + raise CredentialError(f"{SERVER_VARIABLE} must be an http(s) address") + if parts.scheme == "http" and parts.hostname not in _LOCAL: + raise CredentialError(f"{SERVER_VARIABLE} must use https unless the server is local") + if parts.path not in ("", "/") or parts.query or parts.fragment or parts.username: + raise CredentialError(f"{SERVER_VARIABLE} must be an origin such as {DEFAULT_SERVER}") + return f"{parts.scheme}://{parts.netloc}" + + +def credentials_path(environ=None, platform=None): + """``MODIOHUB_CREDENTIALS``, else ``modiohub/credentials.json`` in the user's configuration directory.""" + environ = os.environ if environ is None else environ + if environ.get(FILE_VARIABLE): + return Path(environ[FILE_VARIABLE]) + if (platform or sys.platform) == "win32": + base = Path(environ.get("APPDATA") or Path.home() / "AppData" / "Roaming") + else: + base = Path(environ.get("XDG_CONFIG_HOME") or Path.home() / ".config") + return base / "modiohub" / "credentials.json" + + +def _now(now): + return now or datetime.now(timezone.utc) + + +def _read(path): + try: + mode = path.stat().st_mode + except FileNotFoundError: + return {"version": FILE_VERSION, "servers": {}} + if os.name == "posix" and mode & (stat.S_IRWXG | stat.S_IRWXO): + raise CredentialError(f"{path} must only be readable by you; run chmod 600 {path}") + try: + document = json.loads(path.read_text(encoding="utf-8")) + except (OSError, ValueError) as exc: + raise CredentialError(f"{path} cannot be read: {exc}") from exc + if ( + not isinstance(document, dict) + or document.get("version") != FILE_VERSION + or not isinstance(document.get("servers"), dict) + ): + raise CredentialError(f"{path} is not a version {FILE_VERSION} credentials file") + return document + + +def _expiry(text): + return datetime.fromisoformat(text.replace("Z", "+00:00")) + + +def load_session(server=None, *, environ=None, now=None): + """The session for a server, or None: ``MODIOHUB_TOKEN`` wins, then the credentials file. + + A token from the environment has no known expiry; an expired token in the file is ignored. + """ + environ = os.environ if environ is None else environ + server = server or server_url(environ) + if environ.get(TOKEN_VARIABLE): + return Session(server, environ[TOKEN_VARIABLE], None, None, "environment") + entry = _read(credentials_path(environ)).get("servers", {}).get(server) + if not isinstance(entry, dict) or not isinstance(entry.get("token"), str): + return None + try: + expires_at = _expiry(entry["expiresAt"]) + except (KeyError, TypeError, ValueError) as exc: + raise CredentialError(f"the stored login for {server} has no valid expiry") from exc + if expires_at <= _now(now): + return None + return Session(server, entry["token"], entry.get("githubUser"), expires_at, "file") + + +def _write(path, document): + path.parent.mkdir(parents=True, exist_ok=True) + if os.name == "posix": + path.parent.chmod(0o700) + fd, temporary = tempfile.mkstemp(prefix=f".{path.name}.", dir=path.parent) + try: + with os.fdopen(fd, "w", encoding="utf-8") as output: + json.dump(document, output, indent=2) + output.write("\n") + if os.name == "posix": + os.chmod(temporary, 0o600) + os.replace(temporary, path) + finally: + if os.path.exists(temporary): + os.unlink(temporary) + + +def save_session(server, token, *, expires_in, github_user=None, environ=None, now=None): + """Keep a token for a server in a file only the user can read; other servers' logins stay.""" + path = credentials_path(environ) + document = _read(path) + document["servers"][server] = { + "token": token, + "expiresAt": (_now(now) + timedelta(seconds=expires_in)).strftime("%Y-%m-%dT%H:%M:%SZ"), + **({"githubUser": github_user} if github_user else {}), + } + _write(path, document) + return path + + +def forget_session(server=None, *, environ=None): + """Remove the stored login for a server; returns whether there was one.""" + environ = os.environ if environ is None else environ + server = server or server_url(environ) + path = credentials_path(environ) + document = _read(path) + if document["servers"].pop(server, None) is None: + return False + _write(path, document) + return True + + +def active_server(environ=None, *, now=None): + """The server a tool should talk to when the user did not name one. + + ``MODIOHUB_URL`` wins. Without it, the default server stands when it has a + live session; otherwise the only stored server with a live session wins, so + a login made against one ModioHub (for example staging) keeps working in + later commands. With no live session, or with live sessions on several + servers, the default is returned and the caller starts the sign-in flow. + """ + environ = os.environ if environ is None else environ + if environ.get(SERVER_VARIABLE): + return server_url(environ) + default = server_url(environ) + if load_session(default, environ=environ, now=now) is not None: + return default + origins = [ + origin + for origin in _read(credentials_path(environ)).get("servers", {}) + if load_session(origin, environ=environ, now=now) is not None + ] + if len(origins) == 1: + return origins[0] + return default diff --git a/packages/modpoll-wot/modpoll_wot/simulation.py b/packages/modpoll-wot/modpoll_wot/simulation.py new file mode 100644 index 0000000..2d6d618 --- /dev/null +++ b/packages/modpoll-wot/modpoll_wot/simulation.py @@ -0,0 +1,128 @@ +"""Simulation data: declarative device values for simulators. + +A simulation data document has `"version": "1"` and follows +schemas/simulation-data-1.json. A Modpoll `--export` snapshot, which has no +`version`, is also accepted: the entry for one device becomes its static +`initial` values. The two shapes are told apart by the `version` key alone. +""" + +from dataclasses import dataclass +from fractions import Fraction +from functools import lru_cache +from importlib.resources import files +import json +import math + +from jsonschema import Draft202012Validator + +DATA_VERSION = "1" +SNAPSHOT_TIMESTAMP = "timestamp" + + +class DataError(ValueError): + """Simulation data or a snapshot is invalid.""" + + +@dataclass(frozen=True) +class SimulationData: + """Simulation data in document form, and where it came from.""" + + data: dict + source: str # "data" or "snapshot" + unread: tuple[str, ...] = () # snapshot points Modpoll could not read + + +@lru_cache(maxsize=1) +def _validator(): + schema = json.loads( + files("modpoll_wot") + .joinpath("schemas", "simulation-data-1.json") + .read_text(encoding="utf-8") + ) + Draft202012Validator.check_schema(schema) + return Draft202012Validator(schema) + + +def _validate(document): + error = next(_validator().iter_errors(document), None) + if error is not None: + path = "/" + "/".join(str(part) for part in error.absolute_path) + raise DataError(f"simulation data {path}: {error.message}") + + +def _snapshot_entry(snapshot, title): + if not snapshot or not all(isinstance(entry, dict) for entry in snapshot.values()): + raise DataError( + "a snapshot maps device titles to point values; " + 'simulation data needs "version": "1"' + ) + if title in snapshot: + return snapshot[title] + if len(snapshot) == 1: + return next(iter(snapshot.values())) + names = ", ".join(sorted(snapshot)) + raise DataError(f"snapshot holds devices {names}; none is titled {title!r}") + + +def load_simulation_data(document, *, title=None, properties=None): + """Return a SimulationData from a data document or a Modpoll snapshot. + + `title` selects a device from a snapshot with several devices. When + `properties` (the model's property names) is given, every referenced name + must be one of them, and a snapshot `timestamp` entry is a point only if the + model has a property of that name. + """ + if not isinstance(document, dict): + raise DataError("simulation data must be a JSON object") + if "version" in document: + data, source, unread = document, "data", () + else: + entry = _snapshot_entry(document, title) + values = { + name: value + for name, value in entry.items() + if name != SNAPSHOT_TIMESTAMP + or (properties is not None and name in properties) + } + unread = tuple(sorted(name for name, value in values.items() if value is None)) + initial = {name: value for name, value in values.items() if value is not None} + data, source = {"version": DATA_VERSION, "initial": initial}, "snapshot" + _validate(data) + if properties is not None: + names = set(properties) + bindings = data.get("bindings", {}) + referenced = ( + data.get("initial", {}).keys() + | data.get("generators", {}).keys() + | bindings.keys() + | set(bindings.values()) + ) + unknown = sorted(referenced - names) + if unknown: + raise DataError(f"simulation data names unknown properties: {unknown}") + return SimulationData(data=data, source=source, unread=unread) + + +def scaled_raw(value, multiplier): + """Return the raw integer behind an engineering value and its multiplier. + + A value is accepted when it is the raw integer times the multiplier exactly + in decimal (230.1 with 0.1), or exactly the float Modpoll computes as + float(raw) * float(multiplier) (230.10000000000002 with 0.1). Anything else + raises DataError; there is no tolerance threshold. + """ + if isinstance(value, bool) or not isinstance(value, (int, float)): + raise DataError(f"expected a number, got {value!r}") + if isinstance(value, float) and not math.isfinite(value): + raise DataError(f"expected a finite number, got {value!r}") + factor = Fraction(str(multiplier)) + exact = Fraction(str(value)) + if factor == 0: + if exact != 0: + raise DataError("a zero multiplier only represents zero") + return 0 + quotient = exact / factor + raw = round(quotient) + if quotient == raw or float(raw) * float(factor) == value: + return raw + raise DataError(f"{value!r} is not an integer multiple of {multiplier}") diff --git a/packages/modpoll-wot/modpoll_wot/validation.py b/packages/modpoll-wot/modpoll_wot/validation.py new file mode 100644 index 0000000..e65cb92 --- /dev/null +++ b/packages/modpoll-wot/modpoll_wot/validation.py @@ -0,0 +1,73 @@ +"""Offline JSON Schema validation against bundled, immutable schemas.""" + +import json +from functools import lru_cache +from importlib.resources import files + +from jsonschema import Draft7Validator +from referencing import Registry, Resource + +from .acquisition import AcquisitionError + + +class ModelValidationError(AcquisitionError): + """A document does not match its selected schema.""" + + +def _no_remote(uri): + raise ModelValidationError(f"remote schema resolution is disabled: {uri}") + + +@lru_cache(maxsize=4) +def _validator(kind): + names = { + "tm": "tm-1.1.json", + "td": "td-1.1.json", + "acquisition-0.2": "acquisition-0.2.json", + "modbus": "modbus-binding.json", + } + if kind not in names: + raise ValueError("kind must be 'tm' or 'td'") + schema = json.loads( + files("modpoll_wot") + .joinpath("schemas", names[kind]) + .read_text(encoding="utf-8") + ) + Draft7Validator.check_schema(schema) + registry = Registry(retrieve=_no_remote) + if kind == "modbus": + td = json.loads( + files("modpoll_wot") + .joinpath("schemas", "td-1.1.json") + .read_text(encoding="utf-8") + ) + registry = registry.with_resource( + "https://www.w3.org/2022/wot/td-schema/v1.1", Resource.from_contents(td) + ) + return Draft7Validator(schema, registry=registry) + + +def _validate(document, kind): + error = next(_validator(kind).iter_errors(document), None) + if error is not None: + path = "/" + "/".join( + str(p).replace("~", "~0").replace("/", "~1") for p in error.absolute_path + ) + raise ModelValidationError(f"{path}: {error.message}") + + +def validate_standard(document, *, kind): + """Validate WoT standard structure, not device or acquisition semantics.""" + if kind not in ("tm", "td"): + raise ValueError("kind must be 'tm' or 'td'") + _validate(document, kind) + + +def validate_extension(document): + """Validate the single supported executable extension schema.""" + _validate(document, "acquisition-0.2") + + +def validate_modbus(document): + """Check the pinned official binding schema offline, in addition to TD 1.1.""" + _validate(document, "modbus") diff --git a/packages/modpoll-wot/modpoll_wot/verification.py b/packages/modpoll-wot/modpoll_wot/verification.py new file mode 100644 index 0000000..6e50362 --- /dev/null +++ b/packages/modpoll-wot/modpoll_wot/verification.py @@ -0,0 +1,164 @@ +"""Point fingerprints and hardware verification reports.""" + +from decimal import Decimal +from functools import lru_cache +from hashlib import sha256 +from importlib.resources import files +import json + +from jsonschema import Draft202012Validator + +from .acquisition import AcquisitionError +from .loading import _loads_document +from .profile import instantiate + +FINGERPRINT_VERSION = "pf1" +MODEL_FINGERPRINT_VERSION = "mf1" +REPORT_VERSION = 3 +# Form fields that decide which bytes are read and how they become a value. +OPTIONAL_FIELDS = ( + "modpoll:codec", + "modpoll:bit", + "modpoll:multiplier", + "modpoll:bitPacking", +) + + +class ReportError(ValueError): + """A verification report is invalid or disagrees with its model.""" + + +def _document(model): + if isinstance(model, (bytes, bytearray)): + return _loads_document(bytes(model)) + return model + + +def _decimal_string(value): + number = Decimal(str(value)).normalize() + return "0" if number == 0 else format(number, "f") + + +def _readable_form(prop): + for form in prop["forms"]: + ops = form["op"] if isinstance(form["op"], list) else [form["op"]] + if "readproperty" in ops: + return form + return None + + +def canonical_point(prop): + """Return the canonical read mapping of one effective property, or None.""" + form = _readable_form(prop) + if form is None: + return None + raw = form["modv:type"] + point = { + "type": prop["type"], + "modv:entity": form["modv:entity"], + "modv:address": form["modv:address"], + "modv:quantity": form["modv:quantity"], + "modv:type": raw, + "modv:mostSignificantByte": form.get("modv:mostSignificantByte", True), + "modv:mostSignificantWord": form.get("modv:mostSignificantWord", True), + } + for key in OPTIONAL_FIELDS: + if key in form: + point[key] = form[key] + if "modpoll:multiplier" in point: + point["modpoll:multiplier"] = _decimal_string(point["modpoll:multiplier"]) + if raw == "xsd:string": + bits = form["modv:entity"] in ("Coil", "DiscreteInput") + quantity = form["modv:quantity"] + point["modpoll:byteLength"] = form.get( + "modpoll:byteLength", quantity // 8 if bits else quantity * 2 + ) + return point + + +def fingerprint(point): + """Hash a canonical point mapping into a versioned fingerprint.""" + encoded = json.dumps( + point, sort_keys=True, separators=(",", ":"), ensure_ascii=False + ).encode("utf-8") + return f"{FINGERPRINT_VERSION}:{sha256(encoded).hexdigest()}" + + +def point_fingerprints(model) -> dict[str, str]: + """Return fingerprints of the readable points of a TM or TD. + + ``model`` is a parsed document or its exact bytes. Instance data such as + the endpoint, Unit ID, property names and descriptions do not contribute. + """ + try: + _, effective = instantiate(_document(model)) + except (TypeError, RecursionError) as exc: + raise AcquisitionError(str(exc)) from exc + result = {} + for name, prop in effective["properties"].items(): + point = canonical_point(prop) + if point is not None: + result[name] = fingerprint(point) + return result + + +def combine_fingerprints(fingerprints) -> str: + """Hash a collection of point fingerprints into a model fingerprint.""" + encoded = json.dumps(sorted(set(fingerprints)), separators=(",", ":")).encode() + return f"{MODEL_FINGERPRINT_VERSION}:{sha256(encoded).hexdigest()}" + + +def model_fingerprint(model) -> str: + """Return the fingerprint of the set of readable point mappings of a model. + + Cosmetic edits, renames and instance data keep the fingerprint, so an + unmodified fork shares it with its parent. + """ + return combine_fingerprints(point_fingerprints(model).values()) + + +@lru_cache(maxsize=1) +def _report_validators(): + validators = {} + for version in (3, 4): + schema = json.loads( + files("modpoll_wot") + .joinpath("schemas", f"verification-report-{version}.json") + .read_text(encoding="utf-8") + ) + Draft202012Validator.check_schema(schema) + validators[version] = Draft202012Validator(schema) + return validators + + +def validate_report(report, *, model: bytes | None = None): + """Validate a verification report (schema 3 or 4), optionally against its exact TM bytes.""" + version = report.get("reportVersion") if isinstance(report, dict) else None + validator = _report_validators().get(version) + if validator is None: + raise ReportError(f"/reportVersion: unsupported report version {version!r}") + error = next(validator.iter_errors(report), None) + if error is not None: + path = "/" + "/".join( + str(p).replace("~", "~0").replace("/", "~1") for p in error.absolute_path + ) + raise ReportError(f"{path}: {error.message}") + names = [point["property"] for point in report["points"]] + duplicates = sorted({name for name in names if names.count(name) > 1}) + if duplicates: + raise ReportError(f"/points: duplicate properties {duplicates}") + if model is None: + return + if sha256(model).hexdigest() != report["model"]["sha256"]: + raise ReportError("/model/sha256: does not match the model bytes") + expected = point_fingerprints(model) + if combine_fingerprints(expected.values()) != report["model"]["fingerprint"]: + raise ReportError("/model/fingerprint: does not match the model") + for index, point in enumerate(report["points"]): + actual = expected.get(point["property"]) + if actual is None: + raise ReportError( + f"/points/{index}: no readable property {point['property']}" + ) + if actual != point["fingerprint"]: + raise ReportError(f"/points/{index}/fingerprint: does not match the model") diff --git a/packages/modpoll-wot/profile.md b/packages/modpoll-wot/profile.md new file mode 100644 index 0000000..90d4183 --- /dev/null +++ b/packages/modpoll-wot/profile.md @@ -0,0 +1,312 @@ +# Executable profile 0.2 + +The published Modpoll `2.0.0a2` preview uses `modpoll-wot==0.2.0a1`. +Shared interpreter `0.2.0a3` and current development source execute only profile +0.2; profile 0.1 must be migrated before use. Older immutable application and +interpreter releases keep their original behavior. Package, profile and metadata +schema versions are independent; no local-path dependency is introduced. + +## Source and instances + +Product TM is the maintained source; TD is a generated instance artifact and a +supported input. A single `--config` accepts either format based on content, +independently of filename/URL. Invalid input fails its selected schema without +retrying another kind. Fixed vocabulary aliases are required. + +Property DataSchemas hold standard types, access flags, units and constraints. +Forms supply literal PDU addresses, quantities, raw `modv:type`, entities and +byte/word order. Quantity defaults to 1; byte/word order flags default to true. +DataSchema `integer` does not imply a particular raw width. A combined read/write +Form or disjoint operation-specific Forms are accepted when they describe the +same mapping. Duplicate operations or disagreeing mappings fail. + +Acquisition only holds explicit physical blocks and property names: + +```json +{ + "modv:entity": "HoldingRegister", + "modv:address": 40000, + "modv:quantity": 8, + "modpoll:members": ["counter", "signed", "measurement"] +} +``` + +This group object is a project extension, even though its fields reuse Modbus +vocabulary. Group order, holes and boundaries are preserved without coalescing +or splitting. Every property belongs to one group; explicit aliases may share +addresses. Decoder metadata and offsets are derived from Forms. Offsets count +words for register tables and physical bits for bit tables. Mixed byte orders +are per member. + +TM Forms can omit href. Standard TM placeholders are also supported. CLI binds +host/port/Unit ID; TCP port defaults to 502 and Unit ID to 1 (range 1–254). +Reserved placeholder names are HOST, PORT, UNIT_ID and AUTHORITY (host plus port, +including IPv6 brackets). Named instance flags take precedence over `--param` +values for reserved bindings. Other parameters use `--param NAME=JSON`. A whole +value placeholder preserves its JSON type. Missing, malformed or unused bindings +fail; arbitrary JSON patches and code execution are not supported. + +TD declarations are validated before overrides. Standard Form modv:unitID, +when present, must agree with the URI and all other Forms and is updated on +explicit rebinding. Source TM identity is copied as defined by TM derivation; +use an id placeholder and a persistent instance UUID parameter for multiple +devices. The platform owns instance identity; the interpreter does not infer a +physical identity from IP/port or silently create a random ID. Without explicit flags its +endpoint and Unit ID are authoritative. Explicit overrides update all Forms in +the effective TD and cannot hide inconsistent source metadata. Listening wildcard +addresses cannot be exported. Plain IPv6 literals are canonicalized; scoped +IPv6 addresses are currently rejected. Simulators must distinguish listening interfaces +from advertised endpoints. Unbound TM execution supports explicit serial/UDP +connections; concrete TCP TD export requires a TCP endpoint and never invents +RTU/UDP URLs. A bound TCP instance cannot silently become serial/UDP. + +## Necessary extensions + +| Form field | Meaning | +| --- | --- | +| `modpoll:multiplier` | Finite number/decimal string; engineering = raw × multiplier, including zero/negative values | +| `modpoll:bit` | Bit 0–15 of raw xsd:unsignedShort; boolean property | +| `modpoll:codec` | float16 or historical register bool/bool8/bool16 array codec, with raw xsd:hexBinary | +| `modpoll:byteLength` | Exact UTF-8 capacity when different from the full register span; bytes, not characters | +| `modpoll:bitPacking` | legacy-msb for deliberately packed numeric/string bit-table payloads | + +Native Coil/DiscreteInput booleans/boolean arrays use xsd:boolean and physical +counts without an extension. Register boolean scalars use xsd:boolean, quantity 1. +Register strings apply byte/word order to the padded register span before taking +the declared byte capacity. Legacy register boolean arrays retain their historical +byte interpretation and widths. Explicit packed bit codecs retain legacy behavior, +including ignoring word order; they are not portable scalar Modbus mappings. + +Property schemas are retained in immutable `Model.properties_json` for consumers. +This does not invent manufacturer ranges, generate simulator state, enforce +business ranges on live samples or add inverse engineering-value writes. No +scheduler, cache or waveform is implied. Unsupported pollingTime/timeout execution, +inheritance, optional members, imports, root operations and non-nosec security +fail explicitly. These are defined subset limits, not silent fallback behavior. + +## API and CLI + +```python +from modpoll_wot import load_model, instantiate, export_td +model = load_model("meter.tm.json", host="127.0.0.1", port=5020, unit_id=7) +model, effective = instantiate(document, host="127.0.0.1", unit_id=7) +td = export_td(document, host="127.0.0.1", target="project") +``` + +No input is mutated, no connection opened, and execution needs no temporary TD. +Without an endpoint instantiate's second result is a partial description; only +export_td promises a complete TD. Exports pass bundled TD 1.1, the pinned official +Modbus schema and project cross-field checks offline. See schemas/SOURCES.md. + +From a checkout of this repository (use `modpoll-wot` directly with an installed wheel): + +```sh +uv run modpoll-wot export tests/fixtures/modsim.tm.json --host 127.0.0.1 \ + --port 5020 --unit-id 7 -o /tmp/modsim-instance.td.json +uv run modpoll-wot validate /tmp/modsim-instance.td.json --profile +``` + +Existing output files are never overwritten. These subcommands require shared package 0.2.0a2 or newer. The shared package supplies models/metadata, not a +Modbus client/server, scheduler or MQTT service. + +## Shared TD and binary media parameters + +Project TDs may retain acquisition metadata when consumed by third-party tools. +node-wot 0.9.2 preserves unknown project fields without executing them; removing +those fields is not a prerequisite for consumption. Prefer one generated TD per +TM, shared by project tools and external Consumers. + +Native scalar Forms may specify octet-stream `length`, `signed` and `byteSeq` +parameters. The interpreter checks them against the raw type, quantity and +byte/word order and rejects conflicts, duplicates and unknown parameters. +Parameterized custom codecs, arrays and transformed values are not supported. +The ADAM examples in modsim use this shared representation; filenames mark +outputs as `*.generated.td.json` and only TMs are maintained by hand. + +## Actual external Consumer + +The `node-wot-0.9.2` export target is verified with pinned @node-wot/core and +@node-wot/binding-modbus 0.9.2. It emits standard TD Forms, removes acquisition +metadata and supplies octet-stream length/signed/byteSeq media parameters. The +external Consumer contains no project decoding or value conversion. Separate +operation Forms use FC16 for register writes, avoiding the client's FC6 byte +swapping. Word order has no effect on a single register. + +Supported targets include 16/32-bit integers, 32/64-bit floats and scalar booleans. +Four read byte/word orders are verified. Multiword mixed-order writes are rejected +because this client cannot encode them correctly. Strings, arrays, 64-bit integers, +custom codecs, bit extraction and multipliers fail by property name rather than +being stripped or misrepresented. Project TD output retains those semantics. +No HTTP/cache endpoint is declared without an actual service. + +CI in this repository tests the source on the supported Python range, builds +the wheel and sdist, checks the installed wheel from outside the source tree, +and runs the Modpoll and Modsim test suites against the built wheel. The +node-wot interoperability gate remains in Modpoll and runs against its pinned +release. + +## Promotion order + +The canonical tests/fixtures/modsim.tm.json is the four-block/37-property source; generated TDs are +artifacts. Tests cover +value/request equivalence, mixed orders, aliases, holes, UTF-8 byte capacities, +physical bit offsets, parameters and external read/write round trips. + +Pass source and installed-wheel checks, publish the immutable shared package via +this repository's release workflow, verify registry installation, then independently update +consumer exact pins and CI. Project versions need not match. Until producer-first +publication completes, no consumer requires an unpublished version or local path. +The modsim TD runtime and platform lifecycle remain separate implementation tasks; +this contract does not claim those applications are implemented. + + +### Point tables + +`project_point_table(tm_bytes)` produces rows in acquisition member order. +Addresses are zero-based and quantities count the registers or bits read by +the individual Form. Read function codes are null for write-only points. +A writable flag records access without inferring a write function code. +Multipliers are decimal strings when present. Each readable row carries its +point fingerprint; write-only rows carry null. + +## Point and model fingerprints + +A point fingerprint identifies how one readable property is acquired and +decoded, independently of the file that contains it. A model fingerprint +identifies the set of readable point mappings of a whole model. Verification +statistics are keyed by the model fingerprint: titles, descriptions, units, +property names and member order do not change it, so a custom TM whose read +mappings are unchanged shares the fingerprint and statistics of its upstream +TM, while any change to a read mapping, or adding or +removing a readable point, starts a new one. + +`point_fingerprints(model)` accepts a TM or TD, as a parsed document or exact +bytes, and returns `{property: fingerprint}` for every readable property. +`model_fingerprint(model)` returns the model fingerprint. +`modpoll-wot fingerprint FILE` prints both as JSON +(`{"model": ..., "points": {...}}`). The model is +instantiated without instance arguments, then each property's read Form is +reduced to this canonical object: + +| Key | Value | +| --- | --- | +| `type` | Property DataSchema type | +| `modv:entity`, `modv:address`, `modv:quantity`, `modv:type` | From the Form; quantity is filled with its default | +| `modv:mostSignificantByte`, `modv:mostSignificantWord` | From the Form, defaulting to true | +| `modpoll:codec`, `modpoll:bit`, `modpoll:bitPacking` | Only when present | +| `modpoll:multiplier` | Only when present, as a plain decimal string without exponent or trailing zeros (`0.1`, `100`) | +| `modpoll:byteLength` | Always for `xsd:string`, filled with the full span capacity by default; never otherwise | + +The fingerprint is `pf1:` followed by the lowercase SHA-256 hex digest of the +object serialized as UTF-8 JSON with sorted keys, no whitespace and non-ASCII +characters unescaped. Property names, titles, descriptions, units, ranges, +write Forms, endpoints and Unit IDs do not contribute. Flags that a type cannot +use, such as word order for a single register, are kept as written: equivalent +spellings may split statistics but never merge different mappings. +The model fingerprint is `mf1:` followed by the SHA-256 hex digest of the +sorted, deduplicated point fingerprints serialized as a JSON array without +whitespace. Aliases with identical mappings count once; write-only properties +do not contribute. +[tests/fixtures/modsim.fingerprints.json](tests/fixtures/modsim.fingerprints.json) +pins the canonical strings, point fingerprints and model fingerprint of the +37-property fixture for other implementations. Changing either canonical form +requires a new prefix. + +## Verification reports + +A verification report records one reading of a Thing Model on a physical device. Its schema is +[schemas/verification-report-4.json](modpoll_wot/schemas/verification-report-4.json) +(JSON Schema 2020-12; schema 3 remains valid). A report carries: + +- Optional `product`: the catalog product ID `<manufacturer>/<model-number>`. The receiving + service resolves the product from the model fingerprint, so tools do not need to know it; + older reports may still carry it. A fingerprint that matches no known product is rejected. +- `model`: the SHA-256 of the exact TM bytes, its model fingerprint and its + source. Catalog models add the 40-character catalog commit as `ref`; the + product ID and commit identify the package's `model.tm.json`. Custom TMs add + an opaque version reference. Local models add no `ref`. +- `tool`: the reporting tool's name and version, and the modpoll-wot version. +- `transport` (`tcp` or `rtu`) and the reading `date`. +- Optional `environment`: chassis product ID, firmware and a short + configuration note, such as an input range code. +- `points`: per property, its fingerprint, the read result (`ok`, + `exception` with its exception code, `no-response` or `not-tested`) and + the user's judgment of the value (`confirmed`, `rejected` or `unchecked`). + Only a successful read can be judged. + +A report is a full read when its points cover every readable property of the +model and every read is `ok`, so that executing the whole +`modpoll:acquisition` plan raised no error. Receiving services derive this +from the stored per-point results. + +The schema rejects every other field. Endpoints, Unit IDs, serial numbers and +read values therefore cannot be sent. Configuration notes are free text, so +the reporting tool shows the report for review before upload. Review +markers and account data belong to the receiving service, not the report. + +`validate_report(report, model=tm_bytes)` and +`modpoll-wot validate-report REPORT [--model TM]` check the schema and unique +properties. With the model, they also check its hash and model fingerprint, and that +every point names a readable property with a matching fingerprint. + +## Tool sessions and Workspace references + +A tool such as modpoll or modsim signs in to ModioHub with the browser authorization flow +(OAuth 2.0 device authorization grant) and receives a tool session token that lives 7 days. +This package only defines where the token is kept and how a Workspace Thing Model is named, so +that a login made by any tool works for every tool on the same computer. It makes no request. + +- **Token**: `MODIOHUB_TOKEN` in the environment wins; otherwise the credentials file. `MODIOHUB_URL` names + another server (an origin, https unless local; default `https://modiohub.com`). +- **File**: `MODIOHUB_CREDENTIALS`, else `modiohub/credentials.json` under `$XDG_CONFIG_HOME` (default + `~/.config`) or `%APPDATA%`. Mode `0600` in a `0700` directory; a file other users can read is refused. + Content: `{"version": 1, "servers": {"<origin>": {"token", "expiresAt", "githubUser"}}}`. Each server + keeps its own login; an expired token is ignored. +- **Reference**: `modiohub:<id>@<version>` names a version of a custom Thing Model. The id is the 16 + characters of the custom Thing Model, the version a number or `latest` (the default). Shared versions + can be read without a login. + +`load_session`, `save_session`, `forget_session`, `server_url` and `parse_reference` implement this. + +## Simulation data + +Simulation data describes the values a simulator serves for one device of a +Thing Model. Its schema is +[schemas/simulation-data-1.json](modpoll_wot/schemas/simulation-data-1.json) +(JSON Schema 2020-12), and Modsim loads it with `--data`. + +| Field | Meaning | +| --- | --- | +| `version` | `"1"`, required | +| `initial` | Property name to static value; the default way to give a value | +| `generators` | Property name to a changing value: `constant` (`value`), `sine` (`center`, `amplitude`, positive `period`), `ramp` (`start`, `rate`, `minimum`, `maximum`) or `noise` (`minimum`, `maximum`) | +| `bindings` | Target property name to the source property it follows | +| `tick` | Update interval in seconds, at least 0.001, default 1 | +| `seed` | Random seed, default 0 | +| `writePolicy` | `hold` (default) or `overwrite`: whether a generator overwrites client writes | + +Values are engineering values as Modpoll reads them. Every other field is +rejected, so simulation data never carries executable code; simulator +behavior scripts are configured in the simulator itself. Simulation data is +not a Modbus data table (`modv:entity`). + +A Modpoll `--export` snapshot is accepted as simulation data. A document +without `version` is a snapshot, mapping device titles to point values; the +`version` key alone decides the shape. `load_simulation_data(document, +title=..., properties=...)` takes the device entry whose title matches, or the +only entry, and returns its values as `initial`. Points Modpoll could not read +(`null`) are left out and listed in `unread`. A `timestamp` entry is a point +only when the model has a property of that name. With `properties`, every +referenced name must be a property of the model. Snapshots are instance data: +they stay on the user's computer and are never part of a catalog, Thing Model +or verification report. + +`scaled_raw(value, multiplier)` returns the raw integer behind a scaled value. +It accepts the raw integer times the multiplier as an exact decimal (`230.1` +with `0.1`) or exactly the float Modpoll computes, `float(raw) * +float(multiplier)` (`230.10000000000002` with `0.1`), and rejects everything +else without a tolerance threshold, so any value Modpoll exports can be served +again unchanged. + +`modpoll-wot validate DATA --kind data` checks a data document or snapshot. + diff --git a/packages/modpoll-wot/pyproject.toml b/packages/modpoll-wot/pyproject.toml new file mode 100644 index 0000000..9c12ade --- /dev/null +++ b/packages/modpoll-wot/pyproject.toml @@ -0,0 +1,46 @@ +[project] +name = "modpoll-wot" +version = "0.6.0a2" +description = "Shared WoT Modbus configuration interpreter" +authors = [{ name = "Ying Shaodong", email = "helloysd@gmail.com" }] +readme = "README.md" +license = "MIT" +license-files = ["LICENSE"] +requires-python = ">=3.10,<4.0" +dependencies = [ + "jsonschema>=4.18,<5", + "referencing>=0.28.4,<1", +] + +[project.urls] +Repository = "https://github.com/top-maker/modpoll-wot" +Documentation = "https://github.com/top-maker/modpoll-wot#readme" + +[project.scripts] +modpoll-wot = "modpoll_wot.__main__:main" + +[dependency-groups] +dev = [ + "pytest>=8.2.2,<9", +] + +[tool.pytest.ini_options] +testpaths = ["tests"] + +[build-system] +requires = ["hatchling>=1.27,<2"] +build-backend = "hatchling.build" + +[tool.hatch.build.targets.wheel] +packages = ["modpoll_wot"] + +[tool.hatch.build.targets.wheel.force-include] +"CONTRACT.md" = "CONTRACT.md" +"profile.md" = "profile.md" + +[tool.hatch.build.targets.sdist] +include = ["CONTRACT.md", "profile.md", "README.md", "LICENSE", "modpoll_wot/**", "tests/**"] + +[tool.hatch.build.targets.sdist.force-include] +"CONTRACT.md" = "CONTRACT.md" +"profile.md" = "profile.md" diff --git a/examples/modsim.csv b/packages/modpoll-wot/tests/fixtures/modsim.csv similarity index 100% rename from examples/modsim.csv rename to packages/modpoll-wot/tests/fixtures/modsim.csv diff --git a/packages/modpoll-wot/tests/fixtures/modsim.fingerprints.json b/packages/modpoll-wot/tests/fixtures/modsim.fingerprints.json new file mode 100644 index 0000000..ed8e6e8 --- /dev/null +++ b/packages/modpoll-wot/tests/fixtures/modsim.fingerprints.json @@ -0,0 +1,155 @@ +{ + "model": "modsim.tm.json", + "version": "pf1+mf1", + "fingerprint": "mf1:72518eae5d2994efe3ea56fdd26d737c4ef0f4b4f004bc329e24caa2686a2e97", + "points": { + "coil01-08": { + "canonical": "{\"modv:address\":0,\"modv:entity\":\"Coil\",\"modv:mostSignificantByte\":true,\"modv:mostSignificantWord\":true,\"modv:quantity\":8,\"modv:type\":\"xsd:boolean\",\"type\":\"array\"}", + "fingerprint": "pf1:0a5cc398975cc1141206c13a64c5e1394b316d1bb7b8211b68c888957cdaffdf" + }, + "coil09-16": { + "canonical": "{\"modv:address\":8,\"modv:entity\":\"Coil\",\"modv:mostSignificantByte\":true,\"modv:mostSignificantWord\":true,\"modv:quantity\":8,\"modv:type\":\"xsd:boolean\",\"type\":\"array\"}", + "fingerprint": "pf1:6692950f1401e86dfd78f9b66390aaf5e2247ecf2efdd9d876af070aca4de193" + }, + "di01-08": { + "canonical": "{\"modv:address\":10000,\"modv:entity\":\"DiscreteInput\",\"modv:mostSignificantByte\":true,\"modv:mostSignificantWord\":true,\"modv:quantity\":8,\"modv:type\":\"xsd:boolean\",\"type\":\"array\"}", + "fingerprint": "pf1:88227f091cd6305714059e71341bf16c52e8cb17eca271313cb6bbb1ac5f90d3" + }, + "di09-16": { + "canonical": "{\"modv:address\":10008,\"modv:entity\":\"DiscreteInput\",\"modv:mostSignificantByte\":true,\"modv:mostSignificantWord\":true,\"modv:quantity\":8,\"modv:type\":\"xsd:boolean\",\"type\":\"array\"}", + "fingerprint": "pf1:cce7ed0073ea7b6c1570a3fbcb7a097e890f3d1eb6dc0757830ba74634cf9554" + }, + "input_reg01": { + "canonical": "{\"modv:address\":30000,\"modv:entity\":\"InputRegister\",\"modv:mostSignificantByte\":true,\"modv:mostSignificantWord\":true,\"modv:quantity\":1,\"modv:type\":\"xsd:unsignedShort\",\"type\":\"number\"}", + "fingerprint": "pf1:369f807eab8e37ff442004f002e7bf55c6f01fa09303ea74ee6d86817c053d76" + }, + "input_reg02": { + "canonical": "{\"modv:address\":30001,\"modv:entity\":\"InputRegister\",\"modv:mostSignificantByte\":true,\"modv:mostSignificantWord\":true,\"modv:quantity\":1,\"modv:type\":\"xsd:unsignedShort\",\"type\":\"number\"}", + "fingerprint": "pf1:76b1cf686cd0805deec9f221d6fa26c58e59a6cc608e0b7e1cd07aa363bcfc5d" + }, + "input_reg03": { + "canonical": "{\"modv:address\":30002,\"modv:entity\":\"InputRegister\",\"modv:mostSignificantByte\":true,\"modv:mostSignificantWord\":true,\"modv:quantity\":1,\"modv:type\":\"xsd:unsignedShort\",\"type\":\"number\"}", + "fingerprint": "pf1:09c03cd9f6bb56ad740dac0b3b92fe9af4eeb2c7fa69d820762a59e14ed3c448" + }, + "input_reg04": { + "canonical": "{\"modv:address\":30003,\"modv:entity\":\"InputRegister\",\"modv:mostSignificantByte\":true,\"modv:mostSignificantWord\":true,\"modv:quantity\":1,\"modv:type\":\"xsd:unsignedShort\",\"type\":\"number\"}", + "fingerprint": "pf1:a3b70389cc0da736d4675397dc702f431521fd548c57bf4ddce6ea5022eda646" + }, + "input_reg05": { + "canonical": "{\"modv:address\":30004,\"modv:entity\":\"InputRegister\",\"modv:mostSignificantByte\":true,\"modv:mostSignificantWord\":true,\"modv:quantity\":1,\"modv:type\":\"xsd:short\",\"type\":\"number\"}", + "fingerprint": "pf1:1c8f290c6e7bd2c6fb404578f09741967c1e7cd57fa0101bb8362cc2bcbfa095" + }, + "input_reg06": { + "canonical": "{\"modv:address\":30005,\"modv:entity\":\"InputRegister\",\"modv:mostSignificantByte\":true,\"modv:mostSignificantWord\":true,\"modv:quantity\":1,\"modv:type\":\"xsd:short\",\"type\":\"number\"}", + "fingerprint": "pf1:31ffa61afcabf712f49f048fca935607fef6e2ea453a91b1023582400db4c17e" + }, + "input_reg07": { + "canonical": "{\"modv:address\":30006,\"modv:entity\":\"InputRegister\",\"modv:mostSignificantByte\":true,\"modv:mostSignificantWord\":true,\"modv:quantity\":1,\"modv:type\":\"xsd:short\",\"type\":\"number\"}", + "fingerprint": "pf1:11926dc55e35ca89566db7dcfd342cce2e6d4264716adb37a1e1f691c3afd1db" + }, + "input_reg08": { + "canonical": "{\"modv:address\":30007,\"modv:entity\":\"InputRegister\",\"modv:mostSignificantByte\":true,\"modv:mostSignificantWord\":true,\"modv:quantity\":1,\"modv:type\":\"xsd:short\",\"type\":\"number\"}", + "fingerprint": "pf1:8bc2b64762fcecc90e66b7ddae28fee56a93ed7a5012c37c1609885e382c756a" + }, + "input_reg09": { + "canonical": "{\"modv:address\":30008,\"modv:entity\":\"InputRegister\",\"modv:mostSignificantByte\":true,\"modv:mostSignificantWord\":true,\"modv:quantity\":2,\"modv:type\":\"xsd:unsignedInt\",\"type\":\"number\"}", + "fingerprint": "pf1:1b305c7ab081f1f6d46741438bba2904400796d14d2fff547120dba33b89dc11" + }, + "input_reg10": { + "canonical": "{\"modpoll:multiplier\":\"0.001\",\"modv:address\":30010,\"modv:entity\":\"InputRegister\",\"modv:mostSignificantByte\":true,\"modv:mostSignificantWord\":true,\"modv:quantity\":2,\"modv:type\":\"xsd:unsignedInt\",\"type\":\"number\"}", + "fingerprint": "pf1:5cf94c2360f70938540e98c9e259527cf631ec0dde4fbc6ec2adcfd9894ff945" + }, + "input_reg11": { + "canonical": "{\"modv:address\":30012,\"modv:entity\":\"InputRegister\",\"modv:mostSignificantByte\":true,\"modv:mostSignificantWord\":true,\"modv:quantity\":2,\"modv:type\":\"xsd:int\",\"type\":\"number\"}", + "fingerprint": "pf1:c0381ea2e8abaefedda2ac35a4e7ee9e8140bf1150a48476410fc5273d75b16c" + }, + "input_reg12": { + "canonical": "{\"modpoll:multiplier\":\"1000\",\"modv:address\":30014,\"modv:entity\":\"InputRegister\",\"modv:mostSignificantByte\":true,\"modv:mostSignificantWord\":true,\"modv:quantity\":2,\"modv:type\":\"xsd:int\",\"type\":\"number\"}", + "fingerprint": "pf1:1cc481ac8e5ba84eaed6a65fa96e954474a1505ce7bf643d2c999d173650594f" + }, + "input_reg13": { + "canonical": "{\"modv:address\":30016,\"modv:entity\":\"InputRegister\",\"modv:mostSignificantByte\":true,\"modv:mostSignificantWord\":true,\"modv:quantity\":2,\"modv:type\":\"xsd:float\",\"type\":\"number\"}", + "fingerprint": "pf1:25098743f634f66d581e03917dfca461b240ebf3bb96664481c271a0c674574b" + }, + "input_reg14": { + "canonical": "{\"modv:address\":30018,\"modv:entity\":\"InputRegister\",\"modv:mostSignificantByte\":true,\"modv:mostSignificantWord\":true,\"modv:quantity\":2,\"modv:type\":\"xsd:float\",\"type\":\"number\"}", + "fingerprint": "pf1:c565484339f4267a761bc8647f2b6096bbb6779f59d3dd1f1810dd4e7b5664ef" + }, + "holding_reg01": { + "canonical": "{\"modv:address\":40000,\"modv:entity\":\"HoldingRegister\",\"modv:mostSignificantByte\":true,\"modv:mostSignificantWord\":true,\"modv:quantity\":1,\"modv:type\":\"xsd:unsignedShort\",\"type\":\"number\"}", + "fingerprint": "pf1:df9e449a3a999601097588ea54ef67e2a37a8d11918f9a399c2e395d94450ce4" + }, + "holding_reg02": { + "canonical": "{\"modv:address\":40001,\"modv:entity\":\"HoldingRegister\",\"modv:mostSignificantByte\":true,\"modv:mostSignificantWord\":true,\"modv:quantity\":1,\"modv:type\":\"xsd:unsignedShort\",\"type\":\"number\"}", + "fingerprint": "pf1:96d572b07e576c8e85a465b6d1addd100281f11947d0320bb61ef732d79b73da" + }, + "holding_reg03": { + "canonical": "{\"modv:address\":40002,\"modv:entity\":\"HoldingRegister\",\"modv:mostSignificantByte\":true,\"modv:mostSignificantWord\":true,\"modv:quantity\":1,\"modv:type\":\"xsd:unsignedShort\",\"type\":\"number\"}", + "fingerprint": "pf1:a42e11e6c926189623e3e59082763e1cd8a2ccbf4b5eb1cd83f641b10cefebd9" + }, + "holding_reg04": { + "canonical": "{\"modv:address\":40003,\"modv:entity\":\"HoldingRegister\",\"modv:mostSignificantByte\":true,\"modv:mostSignificantWord\":true,\"modv:quantity\":1,\"modv:type\":\"xsd:unsignedShort\",\"type\":\"number\"}", + "fingerprint": "pf1:5ae64a57465970ae7eeda59b51bc922b499cf1b76e7345f976cdb69d93cb388d" + }, + "holding_reg05": { + "canonical": "{\"modv:address\":40004,\"modv:entity\":\"HoldingRegister\",\"modv:mostSignificantByte\":true,\"modv:mostSignificantWord\":true,\"modv:quantity\":1,\"modv:type\":\"xsd:short\",\"type\":\"number\"}", + "fingerprint": "pf1:9e833a9d9860cfc9c5536b6118e4d473b7e1e46a31899b8423ff60c70abb303d" + }, + "holding_reg06": { + "canonical": "{\"modv:address\":40005,\"modv:entity\":\"HoldingRegister\",\"modv:mostSignificantByte\":true,\"modv:mostSignificantWord\":true,\"modv:quantity\":1,\"modv:type\":\"xsd:short\",\"type\":\"number\"}", + "fingerprint": "pf1:b3e823dd547628bf7810d016b1e6ff381f1376a408821ea7e114ca1a98dfd6a4" + }, + "holding_reg07": { + "canonical": "{\"modv:address\":40006,\"modv:entity\":\"HoldingRegister\",\"modv:mostSignificantByte\":true,\"modv:mostSignificantWord\":true,\"modv:quantity\":1,\"modv:type\":\"xsd:short\",\"type\":\"number\"}", + "fingerprint": "pf1:88dd09a4760ec2f496cc73348cb5a2be247c4a507c7e845c019d17e63fd7c7bd" + }, + "holding_reg08": { + "canonical": "{\"modv:address\":40007,\"modv:entity\":\"HoldingRegister\",\"modv:mostSignificantByte\":true,\"modv:mostSignificantWord\":true,\"modv:quantity\":1,\"modv:type\":\"xsd:short\",\"type\":\"number\"}", + "fingerprint": "pf1:5040aaff29790e302167b753688f3a86c6b5e5758a5330f1c0c77528719b81da" + }, + "holding_reg09": { + "canonical": "{\"modv:address\":40008,\"modv:entity\":\"HoldingRegister\",\"modv:mostSignificantByte\":true,\"modv:mostSignificantWord\":true,\"modv:quantity\":2,\"modv:type\":\"xsd:unsignedInt\",\"type\":\"number\"}", + "fingerprint": "pf1:5b008d1a575dcc8268e3068f76e1546ddff3e4a6b5ef43245cd62bb16e630272" + }, + "holding_reg10": { + "canonical": "{\"modpoll:multiplier\":\"0.001\",\"modv:address\":40010,\"modv:entity\":\"HoldingRegister\",\"modv:mostSignificantByte\":true,\"modv:mostSignificantWord\":true,\"modv:quantity\":2,\"modv:type\":\"xsd:unsignedInt\",\"type\":\"number\"}", + "fingerprint": "pf1:c962264addbd2d0f5bc0fb1c166d551bea3d2ad6be9f232f37c54548bc45c038" + }, + "holding_reg11": { + "canonical": "{\"modv:address\":40012,\"modv:entity\":\"HoldingRegister\",\"modv:mostSignificantByte\":true,\"modv:mostSignificantWord\":true,\"modv:quantity\":2,\"modv:type\":\"xsd:int\",\"type\":\"number\"}", + "fingerprint": "pf1:be3565c0f127bb9d56f7d77c7b7231b139d5569c5297c1666545dfc442026ed8" + }, + "holding_reg12": { + "canonical": "{\"modpoll:multiplier\":\"1000\",\"modv:address\":40014,\"modv:entity\":\"HoldingRegister\",\"modv:mostSignificantByte\":true,\"modv:mostSignificantWord\":true,\"modv:quantity\":2,\"modv:type\":\"xsd:int\",\"type\":\"number\"}", + "fingerprint": "pf1:2e4a9d93be8a88ebe45058252ea1a287655805f9a67e2eda9279c420ee59c187" + }, + "holding_reg13": { + "canonical": "{\"modv:address\":40016,\"modv:entity\":\"HoldingRegister\",\"modv:mostSignificantByte\":true,\"modv:mostSignificantWord\":true,\"modv:quantity\":2,\"modv:type\":\"xsd:float\",\"type\":\"number\"}", + "fingerprint": "pf1:008d56907d1e9fce9088960a5dbad33a84ef7b630ef71e329862881c851394f8" + }, + "holding_reg14": { + "canonical": "{\"modv:address\":40018,\"modv:entity\":\"HoldingRegister\",\"modv:mostSignificantByte\":true,\"modv:mostSignificantWord\":true,\"modv:quantity\":2,\"modv:type\":\"xsd:float\",\"type\":\"number\"}", + "fingerprint": "pf1:9214a021c9406fe876230b1c5adc49e68bbb42e2d49d2d771f79e8e212564bbf" + }, + "holding_reg15": { + "canonical": "{\"modv:address\":40020,\"modv:entity\":\"HoldingRegister\",\"modv:mostSignificantByte\":true,\"modv:mostSignificantWord\":true,\"modv:quantity\":4,\"modv:type\":\"xsd:unsignedLong\",\"type\":\"number\"}", + "fingerprint": "pf1:1f0b838692da984a79055d8af1a28326ba6a5e6de8f7818a7c4460dd7204c5a7" + }, + "holding_reg16": { + "canonical": "{\"modv:address\":40024,\"modv:entity\":\"HoldingRegister\",\"modv:mostSignificantByte\":true,\"modv:mostSignificantWord\":true,\"modv:quantity\":4,\"modv:type\":\"xsd:long\",\"type\":\"number\"}", + "fingerprint": "pf1:be9d25dae63e963c3e44dd84c0aa84bbbcbefe1c8a59a62593a8b1ac5f0de5ae" + }, + "holding_reg17": { + "canonical": "{\"modv:address\":40028,\"modv:entity\":\"HoldingRegister\",\"modv:mostSignificantByte\":true,\"modv:mostSignificantWord\":true,\"modv:quantity\":4,\"modv:type\":\"xsd:double\",\"type\":\"number\"}", + "fingerprint": "pf1:18eaa33af7d7db4cfe9d99f5f7dc4f1a8bdc4fe03bf3b922ee7cdf832075ec56" + }, + "holding_reg18": { + "canonical": "{\"modv:address\":40032,\"modv:entity\":\"HoldingRegister\",\"modv:mostSignificantByte\":true,\"modv:mostSignificantWord\":true,\"modv:quantity\":4,\"modv:type\":\"xsd:double\",\"type\":\"number\"}", + "fingerprint": "pf1:eee4645d649bb219a679a2b1e1b307bba6f717333009a33e9300a3edd30803d5" + }, + "holding_reg19": { + "canonical": "{\"modpoll:byteLength\":16,\"modv:address\":40036,\"modv:entity\":\"HoldingRegister\",\"modv:mostSignificantByte\":true,\"modv:mostSignificantWord\":true,\"modv:quantity\":8,\"modv:type\":\"xsd:string\",\"type\":\"string\"}", + "fingerprint": "pf1:14e82f419bf51638af5f26a74ae3d0bafb29c7dec9d46b74fe806cb940665e5b" + } + } +} diff --git a/examples/modsim.generated.td.json b/packages/modpoll-wot/tests/fixtures/modsim.generated.td.json similarity index 100% rename from examples/modsim.generated.td.json rename to packages/modpoll-wot/tests/fixtures/modsim.generated.td.json diff --git a/examples/modsim.tm.json b/packages/modpoll-wot/tests/fixtures/modsim.tm.json similarity index 100% rename from examples/modsim.tm.json rename to packages/modpoll-wot/tests/fixtures/modsim.tm.json diff --git a/packages/modpoll-wot/tests/fixtures/numeric.report.json b/packages/modpoll-wot/tests/fixtures/numeric.report.json new file mode 100644 index 0000000..f1fc52c --- /dev/null +++ b/packages/modpoll-wot/tests/fixtures/numeric.report.json @@ -0,0 +1,35 @@ +{ + "reportVersion": 4, + "model": { + "sha256": "b59cd8b5d53ccfa89c88ef579beca81f3ac38da3e8f5a49f1d7f99ab64e2e356", + "fingerprint": "mf1:2953dba3f1a8a578194267d1759bdb7f2c5b9c99ac511ff82fb8298e939fe367", + "source": "catalog", + "ref": "ffffffffffffffffffffffffffffffffffffffff" + }, + "tool": { + "name": "modpoll", + "version": "2.1.0a1", + "interpreter": "0.3.0a1" + }, + "transport": "tcp", + "date": "2026-11-09", + "environment": { + "firmware": "A2.15", + "configuration": "range 0x07 on AI0" + }, + "points": [ + { + "property": "counter", + "fingerprint": "pf1:69702f42bfedb8903c107d1885afd14b662f02c1ba41f299f5ed8bcca9cbbe1f", + "read": "ok", + "expected": "confirmed" + }, + { + "property": "signed", + "fingerprint": "pf1:0b086c37129e62fc8632706ab4b1ad69c68f7500d855add0095de4e3f36c1b6d", + "read": "exception", + "exceptionCode": 2, + "expected": "unchecked" + } + ] +} diff --git a/tests/fixtures/numeric.tm.json b/packages/modpoll-wot/tests/fixtures/numeric.tm.json similarity index 100% rename from tests/fixtures/numeric.tm.json rename to packages/modpoll-wot/tests/fixtures/numeric.tm.json diff --git a/packages/modpoll-wot/tests/test_acquisition.py b/packages/modpoll-wot/tests/test_acquisition.py new file mode 100644 index 0000000..9603577 --- /dev/null +++ b/packages/modpoll-wot/tests/test_acquisition.py @@ -0,0 +1,48 @@ +import copy +import unittest + +from modpoll_wot import AcquisitionError, parse_acquisition + + +def model(): + from pathlib import Path + import json + + d = json.loads((Path(__file__).parent / "fixtures/numeric.tm.json").read_text()) + return d + + +class AcquisitionTests(unittest.TestCase): + def test_preserves_declared_group_and_hole(self): + (group,) = parse_acquisition(model()) + self.assertEqual( + (group.start, group.quantity, group.table), (40000, 8, "holding_register") + ) + self.assertEqual( + [(m.property, m.offset) for m in group.members], + [("counter", 0), ("signed", 2), ("measurement", 4)], + ) + + def test_rejects_invalid_or_unimplemented_inputs(self): + def duplicate(group): + group["modpoll:members"].append(copy.deepcopy(group["modpoll:members"][0])) + + changes = [ + lambda g: g.update({"modv:quantity": 3}), + lambda g: g.update({"modv:address": 65535}), + lambda g: g.update({"modv:quantity": True}), + lambda g: g.update({"modv:entity": "unknown"}), + lambda g: g["modpoll:members"].__setitem__(0, "missing"), + lambda g: g.update({"modpoll:scale": 2}), + duplicate, + ] + for change in changes: + with self.subTest(change=change): + document = model() + change(document["modpoll:acquisition"][0]) + with self.assertRaises(AcquisitionError): + parse_acquisition(document) + + +if __name__ == "__main__": + unittest.main() diff --git a/packages/modpoll-wot/tests/test_cli_commands.py b/packages/modpoll-wot/tests/test_cli_commands.py new file mode 100644 index 0000000..6321ae3 --- /dev/null +++ b/packages/modpoll-wot/tests/test_cli_commands.py @@ -0,0 +1,165 @@ +import json +import os +from pathlib import Path +import subprocess +import sys +import tempfile +import unittest +from unittest.mock import patch +from io import StringIO + +from modpoll_wot import __main__ as cli + +if not hasattr(cli, "_result"): + raise unittest.SkipTest("requires the candidate shared CLI") + +_result = cli._result + + +class CommandTests(unittest.TestCase): + def run_cli(self, *arguments): + return subprocess.run( + [sys.executable, "-m", "modpoll_wot", *map(str, arguments)], + text=True, + capture_output=True, + env=os.environ.copy(), + ) + + def test_starter_and_structure_validation(self): + with tempfile.TemporaryDirectory() as directory: + path = Path(directory) / "starter.tm.json" + self.assertEqual( + self.run_cli("new", "--title", "Meter", "--output", path).returncode, + 0, + ) + self.assertEqual( + self.run_cli("validate", path, "--kind", "tm").returncode, 0 + ) + self.assertNotEqual( + self.run_cli("validate", path, "--kind", "tm", "--profile").returncode, + 0, + ) + self.assertNotEqual( + self.run_cli("new", "--title", "Meter", "--output", path).returncode, + 0, + ) + path.write_text('{"x": 1, "x": 2}', encoding="utf-8") + self.assertNotEqual(self.run_cli("validate", path).returncode, 0) + + def test_default_output_and_no_overwrite(self): + with tempfile.TemporaryDirectory() as directory: + environment = os.environ.copy() + environment["PYTHONPATH"] = os.pathsep.join( + [ + str(Path(__file__).resolve().parents[1]), + environment.get("PYTHONPATH", ""), + ] + ) + result = subprocess.run( + [sys.executable, "-m", "modpoll_wot", "new", "--title", "Meter"], + cwd=directory, + text=True, + capture_output=True, + env=environment, + ) + self.assertEqual(result.returncode, 0, result.stderr) + path = Path(directory) / "Meter.tm.json" + original = path.read_bytes() + self.assertEqual(json.loads(original)["title"], "Meter") + self.assertEqual( + self.run_cli("validate", path, "--kind", "tm").returncode, 0 + ) + again = subprocess.run( + [sys.executable, "-m", "modpoll_wot", "new", "--title", "Meter"], + cwd=directory, + text=True, + capture_output=True, + env=environment, + ) + self.assertNotEqual(again.returncode, 0) + self.assertEqual(path.read_bytes(), original) + self.assertNotEqual( + self.run_cli("new", "--title", "../escape").returncode, 0 + ) + + def test_subcommands_are_discoverable_and_old_interface_is_rejected(self): + help_text = self.run_cli("--help") + self.assertEqual(help_text.returncode, 0) + for command in ("validate", "new", "export"): + self.assertIn(command, help_text.stdout) + self.assertNotEqual(self.run_cli("--config", "model.json").returncode, 0) + self.assertNotEqual(self.run_cli("model.json").returncode, 0) + self.assertNotEqual(self.run_cli("generate", "--title", "Meter").returncode, 0) + + def test_validation_reports_checks_and_failure_stage(self): + source = Path(__file__).resolve().parent / "fixtures" / "modsim.tm.json" + basic = self.run_cli("validate", source) + self.assertEqual(basic.returncode, 0) + self.assertIn("TM structure (WoT 1.1): passed", basic.stdout) + self.assertIn("use --profile", basic.stdout) + self.assertNotIn("\x1b[", basic.stdout) + profile = self.run_cli("validate", source, "--profile") + self.assertEqual(profile.returncode, 0, profile.stderr) + self.assertIn("Executable profile 0.2: passed", profile.stdout) + with tempfile.TemporaryDirectory() as directory: + path = Path(directory) / "starter.json" + self.assertEqual( + self.run_cli("new", "--title", "Meter", "-o", path).returncode, 0 + ) + failure = self.run_cli("validate", path, "--profile") + self.assertEqual(failure.returncode, 1) + self.assertIn("TM structure (WoT 1.1): passed", failure.stdout) + self.assertIn("Executable profile: failed", failure.stderr) + path.write_text('{"@type": 42}', encoding="utf-8") + invalid = self.run_cli("validate", path, "--kind", "tm") + self.assertEqual(invalid.returncode, 1) + self.assertIn("TM structure (WoT 1.1): failed", invalid.stderr) + + def test_color_only_on_terminal_and_respects_no_color(self): + stream = StringIO() + with ( + patch.object(stream, "isatty", return_value=True), + patch.dict(os.environ, {"TERM": "xterm"}, clear=True), + ): + _result(True, "passed", stream=stream) + self.assertIn("\x1b[32m", stream.getvalue()) + stream.seek(0) + stream.truncate() + with patch.dict(os.environ, {"NO_COLOR": "1"}): + _result(False, "failed", stream=stream) + self.assertNotIn("\x1b[", stream.getvalue()) + self.assertIn("✗", stream.getvalue()) + + def test_td_generation_and_validation(self): + source = Path(__file__).resolve().parent / "fixtures" / "modsim.tm.json" + with tempfile.TemporaryDirectory() as directory: + path = Path(directory) / "instance.td.json" + result = self.run_cli( + "export", + source, + "--host", + "127.0.0.1", + "--port", + "5020", + "--unit-id", + "7", + "--output", + path, + ) + self.assertEqual(result.returncode, 0, result.stderr) + self.assertEqual( + self.run_cli("validate", path, "--kind", "td", "--profile").returncode, + 0, + ) + self.assertNotIn( + "tm:ThingModel", json.loads(path.read_text()).get("@type", []) + ) + self.assertNotEqual( + self.run_cli( + "export", + path, + "--output", + Path(directory) / "other.json", + ).returncode, + 0, + ) diff --git a/packages/modpoll-wot/tests/test_contract.py b/packages/modpoll-wot/tests/test_contract.py new file mode 100644 index 0000000..cc9a46b --- /dev/null +++ b/packages/modpoll-wot/tests/test_contract.py @@ -0,0 +1,243 @@ +"""Independent acceptance vectors for the profile 0.2 configuration contract.""" + +import copy +import json +from pathlib import Path +import unittest +from unittest.mock import patch + +from modpoll_wot import AcquisitionError, export_td +from modpoll_wot.loading import load_model, loads_model, parse_model + +ROOT = Path(__file__).resolve().parent +RAW_TYPES = { + "uint16": ("xsd:unsignedShort", 1), + "int16": ("xsd:short", 1), + "uint32": ("xsd:unsignedInt", 2), + "int32": ("xsd:int", 2), + "float32": ("xsd:float", 2), + "uint64": ("xsd:unsignedLong", 4), + "int64": ("xsd:long", 4), + "float64": ("xsd:double", 4), +} + + +def scalar(dtype="uint16", type_="integer"): + form = { + "modv:entity": "HoldingRegister", + "modv:address": 0, + "modv:quantity": 1, + "modv:type": "xsd:unsignedShort", + } + if dtype in RAW_TYPES: + form["modv:type"], form["modv:quantity"] = RAW_TYPES[dtype] + elif dtype.startswith("string"): + length = int(dtype[6:]) + form.update( + { + "modv:type": "xsd:string", + "modv:quantity": (length + 1) // 2, + "modpoll:byteLength": length, + } + ) + else: + form.update( + { + "modv:type": "xsd:hexBinary", + "modpoll:codec": dtype, + "modv:quantity": 2 if dtype == "bool16" else 1, + } + ) + return { + "@context": [ + "https://www.w3.org/2022/wot/td/v1.1", + { + "modpoll": "https://top-maker.github.io/modpoll/vocab/wot-modbus#", + "modv": "https://www.w3.org/2019/wot/modbus", + "xsd": "http://www.w3.org/2001/XMLSchema#", + }, + ], + "@type": "tm:ThingModel", + "title": "test", + "modpoll:version": "0.2", + "properties": {"value": {"type": type_, "readOnly": True, "forms": [form]}}, + "modpoll:acquisition": [ + { + "modv:entity": "HoldingRegister", + "modv:address": 0, + "modv:quantity": 125, + "modpoll:members": ["value"], + } + ], + } + + +class ContractTests(unittest.TestCase): + def test_numeric_and_string_types(self): + for dtype, width in [ + ("uint16", 1), + ("int16", 1), + ("float16", 1), + ("uint32", 2), + ("int32", 2), + ("float32", 2), + ("uint64", 4), + ("int64", 4), + ("float64", 4), + ("string3", 2), + ("string16", 8), + ]: + with self.subTest(dtype=dtype): + prop_type = "string" if dtype.startswith("string") else "number" + self.assertEqual( + parse_model(scalar(dtype, prop_type)).groups[0].members[0].width, + width, + ) + + def test_boolean_arrays_and_register_bits(self): + for entity in ("Coil", "DiscreteInput", "HoldingRegister", "InputRegister"): + for dtype in ("bool", "bool8", "bool16"): + with self.subTest(entity=entity, dtype=dtype): + d = scalar(dtype, "array") + prop = d["properties"]["value"] + prop["items"] = {"type": "boolean"} + form = prop["forms"][0] + form["modv:entity"] = entity + d["modpoll:acquisition"][0]["modv:entity"] = entity + if entity in ("Coil", "DiscreteInput"): + form.pop("modpoll:codec") + form.update({"modv:type": "xsd:boolean", "modv:quantity": 16}) + self.assertTrue(parse_model(d).groups[0].members[0].readable) + for bit in (0, 15): + d = scalar(type_="boolean") + d["properties"]["value"]["forms"][0]["modpoll:bit"] = bit + self.assertEqual(parse_model(d).groups[0].members[0].bit, bit) + + def test_all_endian_combinations(self): + for byte in (True, False): + for word in (True, False): + d = scalar() + d["properties"]["value"]["forms"][0].update( + {"modv:mostSignificantByte": byte, "modv:mostSignificantWord": word} + ) + self.assertEqual( + parse_model(d).groups[0].members[0].byte_order, + ("BE" if byte else "LE") + "_" + ("BE" if word else "LE"), + ) + + def test_access_and_multiplier(self): + for flags, expected in [ + ({}, (True, True)), + ({"readOnly": True}, (True, False)), + ({"writeOnly": True}, (False, True)), + ]: + d = scalar(type_="number") + prop = d["properties"]["value"] + prop.pop("readOnly") + prop.update(flags) + prop["forms"][0]["modpoll:multiplier"] = "0" + member = parse_model(d).groups[0].members[0] + self.assertEqual((member.readable, member.writable), expected) + self.assertEqual(member.multiplier, 0) + for factor in ("-2", "0.001", "1e3"): + d = scalar(type_="number") + d["properties"]["value"]["forms"][0]["modpoll:multiplier"] = factor + self.assertIsNotNone(parse_model(d).groups[0].members[0].multiplier) + + def test_semantic_failures(self): + mutations = [ + lambda d, g, f: g.update({"modv:address": 65535}), + lambda d, g, f: g.update({"modv:quantity": 126}), + lambda d, g, f: g.update({"modv:quantity": 0}), + lambda d, g, f: g.update({"modv:quantity": True}), + lambda d, g, f: f.update({"modv:mostSignificantByte": "BE"}), + lambda d, g, f: f.update({"modv:address": -1}), + lambda d, g, f: f.update({"modv:address": 125}), + lambda d, g, f: g.update({"modpoll:members": ["unknown"]}), + lambda d, g, f: f.update({"modv:type": "unit32"}), + lambda d, g, f: f.update({"modv:type": "xsd:float"}), + lambda d, g, f: f.update({"modpoll:bit": 1}), + lambda d, g, f: f.update({"modpoll:multiplier": "NaN"}), + lambda d, g, f: f.update({"modpoll:multiplier": "1e9999"}), + lambda d, g, f: f.update({"modpoll:multiplier": True}), + lambda d, g, f: f.update({"modpoll:scale": 1}), + lambda d, g, f: g["modpoll:members"].append("value"), + lambda d, g, f: d["properties"].update( + {"missing": copy.deepcopy(d["properties"]["value"])} + ), + lambda d, g, f: d["properties"]["value"].update({"writeOnly": True}), + lambda d, g, f: d.update({"modpoll:unknown": 1}), + ] + for index, mutation in enumerate(mutations): + with self.subTest(case=index): + d = scalar() + g = d["modpoll:acquisition"][0] + f = d["properties"]["value"]["forms"][0] + mutation(d, g, f) + with self.assertRaises(AcquisitionError): + parse_model(d) + + def test_boundary_addresses_and_limits(self): + for entity, count in [ + ("HoldingRegister", 125), + ("InputRegister", 125), + ("Coil", 2000), + ("DiscreteInput", 2000), + ]: + d = scalar() + form = d["properties"]["value"]["forms"][0] + form.update({"modv:entity": entity, "modv:address": 65536 - count}) + if count == 2000: + d["properties"]["value"].update( + {"type": "array", "items": {"type": "boolean"}} + ) + form.update({"modv:type": "xsd:boolean", "modv:quantity": count}) + g = d["modpoll:acquisition"][0] + g.update( + { + "modv:entity": entity, + "modv:quantity": count, + "modv:address": 65536 - count, + } + ) + parse_model(d) + g["modv:quantity"] += 1 + with self.assertRaises(AcquisitionError): + parse_model(d) + + def test_offline_loading_limits_and_namespaces(self): + with patch( + "socket.create_connection", side_effect=AssertionError("network used") + ): + load_model(ROOT / "fixtures/modsim.tm.json") + load_model(ROOT / "fixtures/modsim.generated.td.json") + for text in ( + '{"a":1,"a":2}', + "NaN", + "1e9999", + "[" * 80 + "0" + "]" * 80, + " " * 1048577, + ): + with self.subTest(text=text[:20]), self.assertRaises(AcquisitionError): + loads_model(text) + d = scalar() + d["@context"][1]["modpoll"] = "https://example.com/unknown#" + with self.assertRaises(AcquisitionError): + parse_model(d) + + def test_td_forms_cannot_disagree_with_acquisition(self): + source = export_td(scalar(), host="localhost", port=5020) + for change in [ + lambda f: f.update({"modv:address": 999}), + lambda f: f.update({"modv:entity": "InputRegister"}), + lambda f: f.update({"modv:function": "readHoldingRegisters"}), + lambda f: f.update({"op": "invokeaction"}), + lambda f: f.update({"href": "http://localhost/1/0"}), + lambda f: f.update({"modv:quantity": 999}), + lambda f: f.update({"modv:type": "xsd:string"}), + lambda f: f.update({"href": "modbus+tcp://localhost:5020/1/0?quantity="}), + ]: + d = copy.deepcopy(source) + change(d["properties"]["value"]["forms"][0]) + with self.assertRaises(AcquisitionError): + parse_model(d) diff --git a/packages/modpoll-wot/tests/test_delivery.py b/packages/modpoll-wot/tests/test_delivery.py new file mode 100644 index 0000000..b7c4dba --- /dev/null +++ b/packages/modpoll-wot/tests/test_delivery.py @@ -0,0 +1,29 @@ +"""Regression tests for the point-table projection.""" + +from pathlib import Path + +import pytest + +from modpoll_wot import AcquisitionError, point_fingerprints, project_point_table + +FIXTURE = Path(__file__).parent / "fixtures/numeric.tm.json" + + +def test_point_table_follows_acquisition_order_with_fingerprints(): + payload = FIXTURE.read_bytes() + rows = project_point_table(payload) + fingerprints = point_fingerprints(payload) + + assert [(r["property"], r["address"], r["quantity"]) for r in rows] == [ + ("counter", 40000, 1), + ("signed", 40002, 1), + ("measurement", 40004, 2), + ] + assert all(r["read_function_code"] == 3 and not r["writable"] for r in rows) + assert {r["property"]: r["fingerprint"] for r in rows} == fingerprints + + +def test_point_table_rejects_instance_descriptions(): + td = (FIXTURE.parent / "modsim.generated.td.json").read_bytes() + with pytest.raises(AcquisitionError, match="require a project Thing Model"): + project_point_table(td) diff --git a/packages/modpoll-wot/tests/test_loading.py b/packages/modpoll-wot/tests/test_loading.py new file mode 100644 index 0000000..d560d02 --- /dev/null +++ b/packages/modpoll-wot/tests/test_loading.py @@ -0,0 +1,188 @@ +import json +from pathlib import Path +import tempfile +import unittest + +from modpoll_wot import AcquisitionError +from modpoll_wot.loading import ( + MAX_BYTES, + load_document, + load_model, + loads_model, + parse_model, +) + +FIXTURE = Path(__file__).resolve().parent / "fixtures/modsim.tm.json" + + +class LoadingTests(unittest.TestCase): + def test_modsim_four_tables_and_values_contract(self): + model = load_model(FIXTURE, kind="tm") + self.assertEqual( + [(g.table, g.start, g.quantity) for g in model.groups], + [ + ("coil", 0, 16), + ("discrete_input", 10000, 16), + ("input_register", 30000, 20), + ("holding_register", 40000, 44), + ], + ) + self.assertEqual(sum(len(g.members) for g in model.groups), 37) + self.assertFalse(model.groups[1].members[0].writable) + self.assertTrue(model.groups[3].members[0].writable) + self.assertEqual(str(model.groups[2].members[9].multiplier), "0.001") + self.assertEqual(model.groups[3].members[-1].data_type, "string16") + + def test_unit_id_is_instance_input(self): + self.assertEqual(load_model(FIXTURE, kind="tm", unit_id=7).unit_id, 7) + for value in (True, 0, 255, "1"): + with self.subTest(value=value), self.assertRaises(AcquisitionError): + load_model(FIXTURE, kind="tm", unit_id=value) + + def test_authored_fixture_matches_csv_groups_and_members(self): + import csv + from decimal import Decimal + + source = Path(__file__).resolve().parent / "fixtures/modsim.csv" + model = load_model(FIXTURE, kind="tm") + groups = [] + for row in csv.reader(source.read_text().splitlines()): + if row[0] == "poll": + groups.append((row, [])) + elif row[0] == "ref": + groups[-1][1].append(row) + self.assertEqual(len(groups), len(model.groups)) + for (poll, refs), group in zip(groups, model.groups): + self.assertEqual( + (poll[1], int(poll[2]), int(poll[3])), + (group.table, group.start, group.quantity), + ) + self.assertEqual(len(refs), len(group.members)) + for row, member in zip(refs, group.members): + self.assertEqual( + ( + row[1], + (int(row[2]) - group.start) + * (8 if member.physical_bits else 1), + "bool" if member.physical_bits else row[3], + ), + (member.property, member.offset, member.data_type), + ) + self.assertEqual( + Decimal(row[6]) if len(row) > 6 and row[6] else None, + member.multiplier, + ) + + def test_bad_json_and_semantics_include_filename(self): + with tempfile.TemporaryDirectory() as temp: + path = Path(temp) / "broken.json" + for text in ('{"title":"a","title":"b"}', "{", "NaN"): + path.write_text(text) + with ( + self.subTest(text=text), + self.assertRaisesRegex(AcquisitionError, "broken.json"), + ): + load_model(path, kind="tm") + document = json.loads(FIXTURE.read_text()) + document["properties"]["di01-08"]["forms"][0]["modpoll:bit"] = 1 + path.write_text(json.dumps(document)) + with self.assertRaisesRegex(AcquisitionError, "bit extraction"): + load_model(path, kind="tm") + + def test_extension_schema_rejects_unknown_member(self): + with tempfile.TemporaryDirectory() as temp: + path = Path(temp) / "broken.json" + document = json.loads(FIXTURE.read_text()) + document["properties"]["coil01-08"]["forms"][0]["typo"] = 1 + path.write_text(json.dumps(document)) + with self.assertRaises(AcquisitionError): + load_model(path, kind="tm") + + +class ModelUnitDefaultsTests(unittest.TestCase): + def test_model_default_and_explicit_override(self): + from modpoll_wot import parse_model + + document = json.loads(FIXTURE.read_text()) + for prop in document["properties"].values(): + for form in prop["forms"]: + form["modv:unitID"] = 7 + self.assertEqual(parse_model(document).unit_id, 7) + self.assertEqual(parse_model(document, unit_id=2).unit_id, 2) + for value in (0, 255, True, "7"): + for prop in document["properties"].values(): + for form in prop["forms"]: + form["modv:unitID"] = value + with self.subTest(value=value), self.assertRaises(AcquisitionError): + parse_model(document) + + +class ContentDetectionTests(unittest.TestCase): + def test_tm_marker_accepts_string_and_array_with_additional_type(self): + for types in ("tm:ThingModel", ["urn:example:meter", "tm:ThingModel"]): + document = json.loads(FIXTURE.read_text()) + document["@type"] = types + with self.subTest(types=types): + self.assertEqual(parse_model(document).kind, "tm") + + def test_explicit_python_kind_is_an_assertion_not_an_override(self): + with self.assertRaisesRegex(AcquisitionError, "kind disagrees"): + parse_model(json.loads(FIXTURE.read_text()), kind="td") + + def test_td_with_or_without_application_type(self): + path = FIXTURE.with_name("modsim.generated.td.json") + for types in (None, "urn:example:meter", ["urn:example:meter"]): + document = json.loads(path.read_text()) + if types is not None: + document["@type"] = types + with self.subTest(types=types): + self.assertEqual(parse_model(document).kind, "td") + + def test_tm_filename_does_not_rescue_missing_marker(self): + document = json.loads(FIXTURE.read_text()) + del document["@type"] + with tempfile.TemporaryDirectory() as temp: + path = Path(temp) / "device.tm.json" + path.write_text(json.dumps(document)) + with self.assertRaisesRegex(AcquisitionError, "device.tm.json"): + load_model(path) + + def test_invalid_declared_tm_is_rejected(self): + document = json.loads(FIXTURE.read_text()) + document["title"] = 12 + with self.assertRaises(AcquisitionError): + parse_model(document) + + +class JsonBoundaryTests(unittest.TestCase): + def test_file_and_memory_readers_reject_the_same_invalid_inputs(self): + payloads = ( + b'{"title":"a","title":"b"}', + b"NaN", + b"1e9999", + b"\xff", + b"[" * 80 + b"0" + b"]" * 80, + b" " * (MAX_BYTES + 1), + ) + with tempfile.TemporaryDirectory() as temp: + path = Path(temp) / "invalid.tm.json" + for payload in payloads: + path.write_bytes(payload) + for reader in (load_document, load_model): + with self.subTest(payload=payload[:20], reader=reader.__name__): + with self.assertRaisesRegex( + AcquisitionError, "invalid.tm.json" + ): + reader(path) + with self.assertRaisesRegex(AcquisitionError, "remote-model"): + loads_model(payload, source="remote-model") + + def test_all_execution_entries_reject_invalid_unit_id(self): + from modpoll_wot import instantiate, export_td + + document = json.loads(FIXTURE.read_text()) + for operation in (parse_model, instantiate, export_td): + for unit_id in (True, 0, 255, "1"): + with self.subTest(operation=operation.__name__, unit_id=unit_id): + with self.assertRaisesRegex(AcquisitionError, "unit_id"): + operation(document, unit_id=unit_id) diff --git a/packages/modpoll-wot/tests/test_profile.py b/packages/modpoll-wot/tests/test_profile.py new file mode 100644 index 0000000..547df14 --- /dev/null +++ b/packages/modpoll-wot/tests/test_profile.py @@ -0,0 +1,415 @@ +"""Published-contract candidate checks, including full legacy fixture coverage.""" + +import copy +import json +from pathlib import Path +import unittest + +from modpoll_wot import AcquisitionError, load_model, parse_model + +from modpoll_wot.profile import instantiate, export_td + +ROOT = Path(__file__).resolve().parent + + +def numeric(): + d = json.loads((Path(__file__).parent / "fixtures/numeric.tm.json").read_text()) + d["modpoll:version"] = "0.2" + return d + + +class ProfileTests(unittest.TestCase): + def test_removed_audit_plan_is_an_unsupported_extension(self): + source = numeric() + source["modpoll:audit"] = {"identity": ["counter"]} + with self.assertRaisesRegex(AcquisitionError, "unsupported root project extension"): + instantiate(source) + + def test_shared_td_preserves_consistent_binary_media_parameters(self): + source = numeric() + form = source["properties"]["counter"]["forms"][0] + form["contentType"] = ( + "application/octet-stream;length=2;signed=false;byteSeq=BIG_ENDIAN" + ) + expected = instantiate(numeric(), host="localhost")[0].groups + model, td = instantiate(source, host="localhost") + self.assertEqual(model.groups, expected) + self.assertEqual(instantiate(td)[0].groups, expected) + self.assertEqual( + td["properties"]["counter"]["forms"][0]["contentType"], form["contentType"] + ) + self.assertIn("modpoll:acquisition", td) + + def test_binary_media_cannot_conflict_with_modbus_mapping(self): + for parameters in ( + "length=4", + "signed=true", + "byteSeq=LITTLE_ENDIAN", + "length=2;length=2", + "unknown=value", + "length", + "", + ): + with self.subTest(parameters=parameters): + source = numeric() + source["properties"]["counter"]["forms"][0]["contentType"] = ( + "application/octet-stream;" + parameters + ) + with self.assertRaises((AcquisitionError, ValueError)): + instantiate(source, host="localhost") + + def test_full_modsim_fixture_preserves_groups_types_and_transforms(self): + model = load_model(ROOT / "fixtures/modsim.tm.json") + self.assertEqual( + [(g.table, g.start, g.quantity) for g in model.groups], + [ + ("coil", 0, 16), + ("discrete_input", 10000, 16), + ("input_register", 30000, 20), + ("holding_register", 40000, 44), + ], + ) + self.assertEqual(sum(len(g.members) for g in model.groups), 37) + d = json.loads((ROOT / "fixtures/modsim.tm.json").read_text()) + model, td = instantiate(d, host="127.0.0.1", port=5020, unit_id=7) + self.assertEqual(model.groups, instantiate(td)[0].groups) + self.assertEqual(model.properties_json, instantiate(td)[0].properties_json) + + def test_mixed_orders_remain_in_one_block(self): + d = numeric() + d["properties"]["signed"]["forms"][0]["modv:mostSignificantByte"] = False + m, td = instantiate(d, host="localhost") + self.assertEqual(len(m.groups), 1) + self.assertEqual( + [p.byte_order for p in m.groups[0].members], ["BE_BE", "LE_BE", "BE_BE"] + ) + self.assertEqual(m.groups, instantiate(td)[0].groups) + + def test_td_defaults_and_explicit_overrides_produce_effective_td(self): + _, td = instantiate(numeric(), host="localhost", port=5020, unit_id=7) + m, effective = instantiate(td, host="127.0.0.1", port=5021, unit_id=2) + self.assertEqual(m.endpoint, ("127.0.0.1", 5021)) + self.assertEqual(m.unit_id, 2) + self.assertEqual(m.groups, instantiate(effective)[0].groups) + self.assertEqual(instantiate(td)[0].endpoint, ("localhost", 5020)) + d = copy.deepcopy(td) + d["properties"]["counter"]["forms"][0]["modv:address"] = 1 + with self.assertRaisesRegex(AcquisitionError, "disagrees"): + instantiate(d, host="other") + + def test_typed_placeholders_are_bound_and_validated(self): + d = numeric() + d["title"] = "meter {{NAME}}" + d["properties"]["counter"]["maximum"] = "{{LIMIT}}" + _, td = instantiate( + d, host="localhost", parameters={"NAME": "one", "LIMIT": 100} + ) + self.assertEqual(td["title"], "meter one") + self.assertEqual(td["properties"]["counter"]["maximum"], 100) + with self.assertRaisesRegex(AcquisitionError, "unbound"): + instantiate(d, host="localhost") + with self.assertRaisesRegex(AcquisitionError, "unused"): + instantiate(numeric(), host="localhost", parameters={"TYPO": 1}) + with self.assertRaises(AcquisitionError): + instantiate(d, host="localhost", parameters={"NAME": "one", "LIMIT": False}) + + def test_instantiation_and_result_mutation_preserve_source_and_parameters(self): + source = numeric() + source["properties"]["counter"]["enum"] = "{{VALUES}}" + parameters = {"VALUES": [1, 2, 3]} + original = copy.deepcopy(source) + _, td = instantiate(source, host="localhost", parameters=parameters) + self.assertEqual(source, original) + td["properties"]["counter"]["enum"].append(4) + td["properties"]["counter"]["forms"][0]["modv:address"] = 999 + td["modpoll:acquisition"][0]["modpoll:members"].clear() + self.assertEqual(source, original) + self.assertEqual(parameters, {"VALUES": [1, 2, 3]}) + with self.assertRaises(AcquisitionError): + instantiate(source, host="localhost", unit_id=0, parameters=parameters) + self.assertEqual(source, original) + self.assertEqual(parameters, {"VALUES": [1, 2, 3]}) + + def test_unbound_tm_is_executable_but_cannot_export_tcp_td(self): + self.assertIsNone(instantiate(numeric())[0].endpoint) + with self.assertRaisesRegex(AcquisitionError, "TCP endpoint"): + export_td(numeric()) + + def test_read_and_write_forms_are_selected_by_operation(self): + d = numeric() + p = d["properties"]["counter"] + p.pop("readOnly") + read = p["forms"][0] + write = copy.deepcopy(read) + write["op"] = "writeproperty" + p["forms"].append(write) + instantiate(d) + write["op"] = "readproperty" + with self.assertRaisesRegex(AcquisitionError, "ambiguous"): + instantiate(d) + + def test_custom_codecs_scaling_bits_and_odd_utf8_strings(self): + for typ, raw, extra, schema, qty in [ + ( + "float16", + "xsd:hexBinary", + {"modpoll:codec": "float16"}, + {"type": "number"}, + 1, + ), + ("string3", "xsd:string", {"modpoll:byteLength": 3}, {"type": "string"}, 2), + ("bool", "xsd:unsignedShort", {"modpoll:bit": 15}, {"type": "boolean"}, 1), + ( + "bool16", + "xsd:hexBinary", + {"modpoll:codec": "bool16"}, + {"type": "array", "items": {"type": "boolean"}}, + 2, + ), + ]: + d = numeric() + form = { + **d["properties"]["counter"]["forms"][0], + "modv:type": raw, + "modv:quantity": qty, + **extra, + } + d["properties"] = {"counter": {**schema, "readOnly": True, "forms": [form]}} + d["modpoll:acquisition"][0]["modpoll:members"] = ["counter"] + with self.subTest(typ=typ): + m, td = instantiate(d, host="localhost") + self.assertEqual(m.groups[0].members[0].data_type, typ) + self.assertEqual(m.groups, instantiate(td)[0].groups) + with self.assertRaisesRegex(AcquisitionError, "cannot preserve"): + export_td(d, host="localhost", target="node-wot-0.9.2") + for factor in (-0.1, 0, 1000): + d = numeric() + p = d["properties"]["counter"] + p["type"] = "number" + p["forms"][0]["modpoll:multiplier"] = factor + self.assertEqual( + str(instantiate(d)[0].groups[0].members[0].multiplier), str(factor) + ) + with self.assertRaisesRegex(AcquisitionError, "cannot preserve"): + export_td(d, host="localhost", target="node-wot-0.9.2") + + def test_rejects_invalid_groups_codecs_and_conflicts(self): + for case in ( + "span", + "duplicate", + "unmapped", + "width", + "transform-bool", + "codec", + "unknown", + ): + d = numeric() + f = d["properties"]["counter"]["forms"][0] + if case == "span": + f["modv:address"] = 39999 + elif case == "duplicate": + d["modpoll:acquisition"][0]["modpoll:members"].append("counter") + elif case == "unmapped": + d["modpoll:acquisition"][0]["modpoll:members"].remove("counter") + elif case == "width": + f["modv:quantity"] = 2 + elif case == "transform-bool": + f.update({"modv:type": "xsd:boolean", "modpoll:multiplier": 2}) + elif case == "codec": + f["modpoll:codec"] = "uint16" + elif case == "unknown": + f["typo"] = 1 + with self.subTest(case=case), self.assertRaises(AcquisitionError): + instantiate(d, host="localhost") + + +@unittest.skipUnless( + hasattr(__import__("modpoll_wot.__main__", fromlist=["_result"]), "_result"), + "requires the candidate shared CLI", +) +class ProfileCliTests(unittest.TestCase): + def test_config_content_export_roundtrip_and_no_overwrite(self): + import subprocess + import sys + import tempfile + + with tempfile.TemporaryDirectory() as temp: + source = Path(temp) / "source.td.json" + output = Path(temp) / "instance.tm.json" + source.write_text(json.dumps(numeric())) + command = [sys.executable, "-m", "modpoll_wot"] + result = subprocess.run( + command + + [ + "export", + str(source), + "--host", + "127.0.0.1", + "--unit-id", + "7", + "--output", + str(output), + ], + capture_output=True, + text=True, + ) + self.assertEqual(result.returncode, 0, result.stderr) + self.assertIn("Exported TD", result.stdout) + reread = subprocess.run( + command + ["validate", str(output), "--profile"], + capture_output=True, + text=True, + ) + self.assertEqual(reread.returncode, 0, reread.stderr) + self.assertIn("TD structure", reread.stdout) + duplicate = subprocess.run( + command + + [ + "export", + str(source), + "--host", + "localhost", + "--output", + str(output), + ], + capture_output=True, + text=True, + ) + self.assertNotEqual(duplicate.returncode, 0) + self.assertEqual( + json.loads(output.read_text())["properties"]["counter"]["forms"][0][ + "href" + ], + "modbus+tcp://127.0.0.1:502/7/40000?quantity=1", + ) + + def test_duplicate_json_and_invalid_roots_fail_with_source(self): + import subprocess + import sys + import tempfile + + with tempfile.TemporaryDirectory() as temp: + source = Path(temp) / "broken" + for text in ('{"title":"a","title":"b"}', "[]", "NaN"): + source.write_text(text) + result = subprocess.run( + [sys.executable, "-m", "modpoll_wot", "validate", str(source)], + capture_output=True, + text=True, + ) + with self.subTest(text=text): + self.assertEqual(result.returncode, 1) + self.assertIn(str(source), result.stderr) + self.assertNotIn("Traceback", result.stderr) + + +class ExternalCapabilityTests(unittest.TestCase): + def test_mixed_order_multiword_write_and_int64_fail_by_property(self): + d = numeric() + p = d["properties"]["measurement"] + p["readOnly"] = False + p["forms"][0]["op"] = ["readproperty", "writeproperty"] + p["forms"][0]["modv:mostSignificantWord"] = False + with self.assertRaisesRegex(AcquisitionError, "measurement.*mixed-order write"): + export_td(d, host="localhost", target="node-wot-0.9.2") + d = numeric() + p = d["properties"]["measurement"] + p["type"] = "integer" + p["forms"][0].update({"modv:type": "xsd:unsignedLong", "modv:quantity": 4}) + with self.assertRaisesRegex(AcquisitionError, "measurement"): + export_td(d, host="localhost", target="node-wot-0.9.2") + + +class PinnedBindingTests(unittest.TestCase): + def test_official_binding_bytes_and_canonical_endpoints(self): + import hashlib + from importlib.resources import files + + payload = ( + files("modpoll_wot").joinpath("schemas", "modbus-binding.json").read_bytes() + ) + self.assertEqual( + hashlib.sha256(payload).hexdigest(), + "284de7d3931e0093a87cc1180902ea395e338f0d9c09045af88ef6019f1b2611", + ) + for host in ("LOCALHOST", "0:0:0:0:0:0:0:1"): + with self.subTest(host=host): + model, td = instantiate(numeric(), host=host) + other, again = instantiate(td) + self.assertEqual(model.endpoint, other.endpoint) + self.assertEqual(td, again) + for host in ("0.0.0.0", "::", "bad host", "user@host", "fe80::1%eth0"): + with self.subTest(host=host), self.assertRaises(AcquisitionError): + instantiate(numeric(), host=host) + + +class CanonicalFormTests(unittest.TestCase): + def test_export_fills_binary_media_and_operations(self): + d = numeric() + form = d["properties"]["counter"]["forms"][0] + form.pop("contentType") + form.pop("op") + td = export_td(d, host="localhost") + effective = td["properties"]["counter"]["forms"][0] + self.assertEqual(effective["contentType"], "application/octet-stream") + self.assertEqual(effective["op"], "readproperty") + self.assertNotIn("contentType", form) + self.assertEqual(td, export_td(td)) + + +class UnitIdFormTests(unittest.TestCase): + def test_standard_unit_metadata_and_explicit_rebinding(self): + d = numeric() + for prop in d["properties"].values(): + prop["forms"][0]["modv:unitID"] = 7 + model, td = instantiate(d, host="localhost") + self.assertEqual(model.unit_id, 7) + rebound, effective = instantiate(td, unit_id=2) + self.assertEqual(rebound.unit_id, 2) + self.assertEqual( + effective["properties"]["counter"]["forms"][0]["modv:unitID"], 2 + ) + self.assertEqual(instantiate(effective)[0].unit_id, 2) + td["properties"]["counter"]["forms"][0]["modv:unitID"] = 8 + with self.assertRaisesRegex(AcquisitionError, "disagrees"): + instantiate(td, unit_id=2) + + +class SupportedProfileTests(unittest.TestCase): + def test_old_missing_and_unknown_profiles_are_rejected_at_every_entry(self): + from modpoll_wot import loads_model, parse_acquisition + from modpoll_wot.validation import validate_extension + + for version in ("0.1", "0.2-pilot", "9.9", None): + document = numeric() + if version is None: + del document["modpoll:version"] + else: + document["modpoll:version"] = version + for operation in (parse_model, instantiate, export_td, parse_acquisition): + with self.subTest(version=version, entry=operation.__name__): + with self.assertRaisesRegex(AcquisitionError, "expected.*0.2"): + operation(document) + with self.assertRaisesRegex(AcquisitionError, "expected.*0.2"): + loads_model(json.dumps(document), source="old-device.tm.json") + with self.assertRaises(AcquisitionError): + validate_extension(document) + + +class ProfileSemanticGuardsTests(unittest.TestCase): + def test_blank_title_is_rejected(self): + for title in ("", " "): + document = numeric() + document["title"] = title + with ( + self.subTest(title=title), + self.assertRaisesRegex(AcquisitionError, "title cannot be empty"), + ): + instantiate(document) + + def test_non_nosec_security_is_rejected_before_execution(self): + document = numeric() + document["securityDefinitions"] = {"basic": {"scheme": "basic"}} + document["security"] = "basic" + with self.assertRaisesRegex(AcquisitionError, "only nosec"): + instantiate(document) diff --git a/packages/modpoll-wot/tests/test_session.py b/packages/modpoll-wot/tests/test_session.py new file mode 100644 index 0000000..3085d86 --- /dev/null +++ b/packages/modpoll-wot/tests/test_session.py @@ -0,0 +1,132 @@ +"""Tool session credentials and Workspace references (POLL-02b): format, location and permissions.""" + +from datetime import datetime, timedelta, timezone +import json +import os +import stat + +import pytest + +import modpoll_wot +from modpoll_wot import CredentialError + +NOW = datetime(2026, 11, 12, 8, 0, tzinfo=timezone.utc) +SERVER = "https://modiohub.com" + + +def environ(tmp_path, **extra): + return {"MODIOHUB_CREDENTIALS": str(tmp_path / "credentials.json"), **extra} + + +def test_a_saved_login_is_found_until_it_expires(tmp_path): + env = environ(tmp_path) + path = modpoll_wot.save_session(SERVER, "tok", expires_in=604800, github_user="octo", environ=env, now=NOW) + session = modpoll_wot.load_session(environ=env, now=NOW + timedelta(days=6)) + assert (session.server, session.token, session.github_user, session.source) == (SERVER, "tok", "octo", "file") + assert session.expires_at == NOW + timedelta(days=7) + assert modpoll_wot.load_session(environ=env, now=NOW + timedelta(days=7)) is None + assert json.loads(path.read_text()) == { + "version": 1, + "servers": {SERVER: {"token": "tok", "expiresAt": "2026-11-19T08:00:00Z", "githubUser": "octo"}}, + } + + +@pytest.mark.skipif(os.name != "posix", reason="file modes") +def test_the_file_is_private_and_a_readable_one_is_refused(tmp_path): + env = environ(tmp_path) + path = modpoll_wot.save_session(SERVER, "tok", expires_in=60, environ=env, now=NOW) + assert stat.S_IMODE(path.stat().st_mode) == 0o600 + path.chmod(0o644) + with pytest.raises(CredentialError, match="chmod 600"): + modpoll_wot.load_session(environ=env, now=NOW) + + +def test_each_server_keeps_its_own_login_and_forgetting_one_keeps_the_rest(tmp_path): + env = environ(tmp_path) + modpoll_wot.save_session(SERVER, "prod", expires_in=60, environ=env, now=NOW) + modpoll_wot.save_session("https://modsim.dev", "staging", expires_in=60, environ=env, now=NOW) + assert modpoll_wot.load_session("https://modsim.dev", environ=env, now=NOW).token == "staging" + assert modpoll_wot.forget_session(SERVER, environ=env) is True + assert modpoll_wot.forget_session(SERVER, environ=env) is False + assert modpoll_wot.load_session(SERVER, environ=env, now=NOW) is None + assert modpoll_wot.load_session("https://modsim.dev", environ=env, now=NOW).token == "staging" + + +def test_the_environment_token_wins_and_names_no_expiry(tmp_path): + env = environ(tmp_path, MODIOHUB_TOKEN="from-env", MODIOHUB_URL="https://modsim.dev/") + modpoll_wot.save_session("https://modsim.dev", "stored", expires_in=60, environ=env, now=NOW) + session = modpoll_wot.load_session(environ=env, now=NOW) + assert (session.token, session.server, session.expires_at, session.source) == ("from-env", "https://modsim.dev", None, "environment") + + +def test_nothing_stored_is_not_an_error(tmp_path): + assert modpoll_wot.load_session(environ=environ(tmp_path), now=NOW) is None + assert modpoll_wot.forget_session(environ=environ(tmp_path)) is False + + +def test_a_broken_file_is_reported_and_never_overwritten(tmp_path): + env = environ(tmp_path) + (tmp_path / "credentials.json").write_text("not json") + (tmp_path / "credentials.json").chmod(0o600) + with pytest.raises(CredentialError, match="cannot be read"): + modpoll_wot.save_session(SERVER, "tok", expires_in=60, environ=env, now=NOW) + assert (tmp_path / "credentials.json").read_text() == "not json" + + +@pytest.mark.parametrize( + "value, expected", + [(None, SERVER), ("https://modsim.dev", "https://modsim.dev"), ("https://modsim.dev/", "https://modsim.dev"), + ("http://127.0.0.1:8787", "http://127.0.0.1:8787"), ("http://localhost", "http://localhost")], +) +def test_server_addresses(value, expected): + assert modpoll_wot.server_url({"MODIOHUB_URL": value} if value else {}) == expected + + +def test_the_active_server_falls_back_to_the_only_live_login(tmp_path): + env = environ(tmp_path) + modpoll_wot.save_session("https://modsim.dev", "staging", expires_in=60, environ=env, now=NOW) + assert modpoll_wot.active_server(environ=env, now=NOW) == "https://modsim.dev" + # The default server wins once it has a live session too. + modpoll_wot.save_session(SERVER, "prod", expires_in=60, environ=env, now=NOW) + assert modpoll_wot.active_server(environ=env, now=NOW) == SERVER + # An explicit MODIOHUB_URL always wins. + explicit = {**env, "MODIOHUB_URL": "https://modsim.dev"} + assert modpoll_wot.active_server(explicit, now=NOW) == "https://modsim.dev" + + +def test_an_expired_single_login_falls_back_to_the_default(tmp_path): + env = environ(tmp_path) + modpoll_wot.save_session("https://modsim.dev", "staging", expires_in=60, environ=env, now=NOW) + assert modpoll_wot.active_server(environ=env, now=NOW + timedelta(days=7)) == SERVER + + +def test_the_active_server_is_the_default_without_any_live_login(tmp_path): + env = environ(tmp_path) + assert modpoll_wot.active_server(environ=env, now=NOW) == SERVER + # Two live logins are ambiguous: the default stands. + modpoll_wot.save_session("https://modsim.dev", "staging", expires_in=60, environ=env, now=NOW) + modpoll_wot.save_session("https://staging.example.com", "other", expires_in=60, environ=env, now=NOW) + assert modpoll_wot.active_server(environ=env, now=NOW) == SERVER + + +@pytest.mark.parametrize("value", ["ftp://x.test", "http://example.com", "https://example.com/api", "https://u:p@example.com", "modiohub.com"]) +def test_server_addresses_that_would_send_a_token_astray_are_refused(value): + with pytest.raises(CredentialError): + modpoll_wot.server_url({"MODIOHUB_URL": value}) + + +def test_default_locations(): + from modpoll_wot.session import credentials_path + + home = {"XDG_CONFIG_HOME": "/xdg"} + assert str(credentials_path(home, "linux")) == "/xdg/modiohub/credentials.json" + assert credentials_path({"APPDATA": "C:/Users/me/AppData/Roaming"}, "win32").as_posix() == "C:/Users/me/AppData/Roaming/modiohub/credentials.json" + + +def test_workspace_references(): + assert modpoll_wot.parse_reference("modiohub:k3x9f2m7q4a8n5bd@2") == modpoll_wot.Reference("k3x9f2m7q4a8n5bd", "2") + assert modpoll_wot.parse_reference("modiohub:k3x9f2m7q4a8n5bd@latest").version == "latest" + assert modpoll_wot.parse_reference("modiohub:k3x9f2m7q4a8n5bd").version == "latest" + for bad in ("modiohub:short@1", "k3x9f2m7q4a8n5bd@1", "modiohub:k3x9f2m7q4a8n5bd@0", "modiohub:k3x9f2m7q4a8n5bd@1000", "modiohub:K3X9F2M7Q4A8N5BD@1"): + with pytest.raises(ValueError): + modpoll_wot.parse_reference(bad) diff --git a/packages/modpoll-wot/tests/test_simulation.py b/packages/modpoll-wot/tests/test_simulation.py new file mode 100644 index 0000000..3674fe2 --- /dev/null +++ b/packages/modpoll-wot/tests/test_simulation.py @@ -0,0 +1,108 @@ +import json +import os +from pathlib import Path +import subprocess +import sys +import tempfile +import unittest + +from modpoll_wot import DataError, load_simulation_data, scaled_raw + + +class SimulationDataTests(unittest.TestCase): + def test_data_document_is_returned_unchanged(self): + document = { + "version": "1", + "initial": {"VOLTAGE": 230.1, "RUNNING": True, "NAME": "SIM", "FLAGS": [True, False]}, + "generators": {"CURRENT": {"kind": "sine", "center": 5, "amplitude": 1, "period": 10}}, + "bindings": {"DO0": "DI0"}, + "tick": 0.5, + "seed": 7, + "writePolicy": "overwrite", + } + loaded = load_simulation_data(document) + self.assertEqual((loaded.data, loaded.source, loaded.unread), (document, "data", ())) + + def test_executable_and_unknown_fields_are_rejected(self): + for extra in ({"script": "behavior.py"}, {"parameters": {}}, {"vectors": {}}): + with self.subTest(extra=extra), self.assertRaises(DataError): + load_simulation_data({"version": "1", **extra}) + with self.assertRaises(DataError): + load_simulation_data({"version": "2"}) + with self.assertRaises(DataError): + load_simulation_data({"version": "1", "initial": {"A": {"nested": 1}}}) + with self.assertRaises(DataError): + load_simulation_data({"version": "1", "tick": 0}) + + def test_property_names_are_checked_when_given(self): + document = {"version": "1", "initial": {"A": 1}, "bindings": {"B": "C"}} + load_simulation_data(document, properties={"A", "B", "C"}) + with self.assertRaisesRegex(DataError, r"\['C'\]"): + load_simulation_data(document, properties={"A", "B"}) + + def test_snapshot_becomes_static_values(self): + snapshot = {"ADAM-6024": {"AI0": 4660, "AI1": None, "timestamp": 1731400000.0}} + loaded = load_simulation_data(snapshot, properties={"AI0", "AI1"}) + self.assertEqual(loaded.data, {"version": "1", "initial": {"AI0": 4660}}) + self.assertEqual((loaded.source, loaded.unread), ("snapshot", ("AI1",))) + + def test_snapshot_timestamp_is_a_point_only_when_the_model_has_one(self): + snapshot = {"logger": {"timestamp": 42}} + self.assertEqual(load_simulation_data(snapshot, properties={"timestamp"}).data["initial"], {"timestamp": 42}) + self.assertEqual(load_simulation_data(snapshot).data["initial"], {}) + + def test_snapshot_device_is_selected_by_title(self): + snapshot = {"meter": {"V": 230}, "module": {"AI0": 1}} + self.assertEqual(load_simulation_data(snapshot, title="module").data["initial"], {"AI0": 1}) + with self.assertRaisesRegex(DataError, "none is titled"): + load_simulation_data(snapshot, title="other") + with self.assertRaises(DataError): + load_simulation_data({"meter": 230}) + with self.assertRaises(DataError): + load_simulation_data({}) + + +class ScaledRawTests(unittest.TestCase): + def test_exact_decimals_and_modpoll_floats_recover_the_raw_integer(self): + self.assertEqual(scaled_raw(230.1, "0.1"), 2301) + self.assertEqual(scaled_raw(230.10000000000002, "0.1"), 2301) + self.assertEqual(scaled_raw(float(2301) * 0.1, "0.1"), 2301) + self.assertEqual(scaled_raw(4.987, "0.001"), 4987) + self.assertEqual(scaled_raw(-12, "1"), -12) + self.assertEqual(scaled_raw(1200, "100"), 12) + for raw in range(0, 70000, 7): + for multiplier in ("0.1", "0.01", "0.001", "0.5"): + value = float(raw) * float(multiplier) + self.assertEqual(scaled_raw(value, multiplier), raw, (raw, multiplier)) + + def test_other_values_are_rejected(self): + for value, multiplier in ((230.15, "0.1"), (230.1000001, "0.1"), (1, "0"), (float("nan"), "1"), (True, "1"), ("1", "1")): + with self.subTest(value=value, multiplier=multiplier), self.assertRaises(DataError): + scaled_raw(value, multiplier) + self.assertEqual(scaled_raw(0, "0"), 0) + + +class CommandTests(unittest.TestCase): + def run_cli(self, document): + with tempfile.TemporaryDirectory() as directory: + path = Path(directory) / "data.json" + path.write_text(json.dumps(document)) + return subprocess.run( + [sys.executable, "-m", "modpoll_wot", "validate", str(path), "--kind", "data"], + text=True, capture_output=True, env=os.environ.copy(), + ) + + def test_validate_data_and_snapshots(self): + result = self.run_cli({"version": "1", "initial": {"A": 1}}) + self.assertEqual(result.returncode, 0, result.stderr) + self.assertIn("Simulation data 1: passed (data; 1 initial, 0 generators, 0 bindings)", result.stdout) + result = self.run_cli({"device": {"A": 1, "B": None}}) + self.assertEqual(result.returncode, 0, result.stderr) + self.assertIn("(snapshot; 1 initial", result.stdout) + self.assertIn("Unread snapshot points left out: B", result.stdout) + result = self.run_cli({"version": "1", "script": "x.py"}) + self.assertNotEqual(result.returncode, 0) + + +if __name__ == "__main__": + unittest.main() diff --git a/packages/modpoll-wot/tests/test_validation.py b/packages/modpoll-wot/tests/test_validation.py new file mode 100644 index 0000000..821ed14 --- /dev/null +++ b/packages/modpoll-wot/tests/test_validation.py @@ -0,0 +1,33 @@ +import unittest + +from modpoll_wot.validation import ModelValidationError, validate_standard + + +class StandardValidationTests(unittest.TestCase): + def test_tm_valid(self): + validate_standard( + { + "@context": "https://www.w3.org/2022/wot/td/v1.1", + "@type": "tm:ThingModel", + "title": "Meter", + "properties": {"power": {"type": "number"}}, + }, + kind="tm", + ) + + def test_missing_title_rejected(self): + with self.assertRaises(ModelValidationError): + validate_standard( + {"@context": "https://www.w3.org/2022/wot/td/v1.1"}, kind="tm" + ) + + def test_wrong_kind(self): + with self.assertRaises(ValueError): + validate_standard({}, kind="other") + + def test_td_requires_security(self): + with self.assertRaises(ModelValidationError): + validate_standard( + {"@context": "https://www.w3.org/2022/wot/td/v1.1", "title": "Meter"}, + kind="td", + ) diff --git a/packages/modpoll-wot/tests/test_verification.py b/packages/modpoll-wot/tests/test_verification.py new file mode 100644 index 0000000..8a63016 --- /dev/null +++ b/packages/modpoll-wot/tests/test_verification.py @@ -0,0 +1,292 @@ +"""Point fingerprints and verification report contract.""" + +from copy import deepcopy +from hashlib import sha256 +import json +from pathlib import Path +import subprocess +import sys + +import pytest + +from modpoll_wot import ( + ReportError, + export_td, + model_fingerprint, + point_fingerprints, + validate_report, +) +from modpoll_wot.profile import instantiate +from modpoll_wot.verification import canonical_point, fingerprint + +FIXTURES = Path(__file__).parent / "fixtures" +NUMERIC = FIXTURES / "numeric.tm.json" + + +def numeric(): + return json.loads(NUMERIC.read_bytes()) + + +def test_shared_vectors_pin_the_canonical_encoding(): + vectors = json.loads((FIXTURES / "modsim.fingerprints.json").read_bytes()) + _, effective = instantiate(json.loads((FIXTURES / vectors["model"]).read_bytes())) + for name, expected in vectors["points"].items(): + point = canonical_point(effective["properties"][name]) + canonical = json.dumps( + point, sort_keys=True, separators=(",", ":"), ensure_ascii=False + ) + assert canonical == expected["canonical"] + assert fingerprint(point) == expected["fingerprint"] + assert ( + expected["fingerprint"] + == "pf1:" + sha256(canonical.encode()).hexdigest() + ) + payload = (FIXTURES / vectors["model"]).read_bytes() + assert vectors["points"].keys() == point_fingerprints(payload).keys() + unique = sorted({point["fingerprint"] for point in vectors["points"].values()}) + encoded = json.dumps(unique, separators=(",", ":")).encode() + assert vectors["fingerprint"] == "mf1:" + sha256(encoded).hexdigest() + assert model_fingerprint(payload) == vectors["fingerprint"] + + +def test_instance_data_and_spelling_do_not_change_fingerprints(): + source = numeric() + baseline = point_fingerprints(source) + td = export_td(source, host="192.0.2.10", port=1502, unit_id=7) + assert point_fingerprints(td) == baseline + + edited = numeric() + props = edited["properties"] + props["total"] = props.pop("counter") + props["total"]["description"] = "Renamed in a fork" + props["total"]["unit"] = "count" + edited["modpoll:acquisition"][0]["modpoll:members"][0] = "total" + form = props["signed"]["forms"][0] + form["modv:mostSignificantByte"] = True + form["modv:mostSignificantWord"] = True + edited["title"] = "Forked pilot" + edited["description"] = "Cosmetic fork" + edited["modpoll:acquisition"][0]["modpoll:members"].reverse() + renamed = point_fingerprints(edited) + assert renamed["total"] == baseline["counter"] + assert renamed["signed"] == baseline["signed"] + assert model_fingerprint(edited) == model_fingerprint(source) + assert model_fingerprint(td) == model_fingerprint(source) + + +@pytest.mark.parametrize( + ("field", "value"), + [ + ("modv:address", 40003), + ("modv:type", "xsd:unsignedShort"), + ("modv:mostSignificantByte", False), + ], +) +def test_mapping_changes_split_fingerprints(field, value): + source = numeric() + source["properties"]["signed"]["forms"][0][field] = value + if field == "modv:type": + source["properties"]["signed"]["minimum"] = 0 + assert point_fingerprints(source)["signed"] != point_fingerprints(numeric())["signed"] + assert model_fingerprint(source) != model_fingerprint(numeric()) + + +def test_multiplier_is_compared_as_a_decimal(): + def with_multiplier(value): + source = numeric() + source["properties"]["measurement"]["forms"][0]["modpoll:multiplier"] = value + return point_fingerprints(source)["measurement"] + + assert with_multiplier(0.1) == with_multiplier("0.10") == with_multiplier("1E-1") + assert with_multiplier(100) == with_multiplier("1e2") + assert with_multiplier(0.1) != with_multiplier(0.01) + + +def test_write_only_points_have_no_fingerprint(): + source = numeric() + prop = source["properties"]["counter"] + prop.pop("readOnly") + prop["writeOnly"] = True + prop["forms"][0]["op"] = "writeproperty" + assert "counter" not in point_fingerprints(source) + + +def test_adding_or_removing_a_readable_point_changes_the_model_fingerprint(): + source = numeric() + del source["properties"]["signed"] + source["modpoll:acquisition"][0]["modpoll:members"].remove("signed") + assert model_fingerprint(source) != model_fingerprint(numeric()) + + +def report_for(payload): + prints = point_fingerprints(payload) + return { + "reportVersion": 4, + "model": { + "sha256": sha256(payload).hexdigest(), + "fingerprint": model_fingerprint(payload), + "source": "catalog", + "ref": "f" * 40, + }, + "tool": {"name": "modpoll", "version": "2.1.0a1", "interpreter": "0.3.0a1"}, + "transport": "tcp", + "date": "2026-11-09", + "environment": {"firmware": "A2.15", "configuration": "range 0x07 on AI0"}, + "points": [ + { + "property": "counter", + "fingerprint": prints["counter"], + "read": "ok", + "expected": "confirmed", + }, + { + "property": "signed", + "fingerprint": prints["signed"], + "read": "exception", + "exceptionCode": 2, + "expected": "unchecked", + }, + ], + } + + +def test_a_report_validates_against_its_exact_model(): + payload = NUMERIC.read_bytes() + report = report_for(payload) + validate_report(report) + validate_report(report, model=payload) + + other = json.dumps(numeric()).encode() + with pytest.raises(ReportError, match="/model/sha256"): + validate_report(report, model=other) + + stale = deepcopy(report) + stale["model"]["fingerprint"] = "mf1:" + "0" * 64 + with pytest.raises(ReportError, match="/model/fingerprint"): + validate_report(stale, model=payload) + + forked = deepcopy(report) + forked["points"][0]["fingerprint"] = "pf1:" + "0" * 64 + with pytest.raises(ReportError, match="/points/0/fingerprint"): + validate_report(forked, model=payload) + + unknown = deepcopy(report) + unknown["points"][0]["property"] = "missing" + with pytest.raises(ReportError, match="no readable property missing"): + validate_report(unknown, model=payload) + + +def mutate(path, value): + report = report_for(NUMERIC.read_bytes()) + *parents, key = path + target = report + for part in parents: + target = target[part] + if value is KeyError: + del target[key] + else: + target[key] = value + return report + + +@pytest.mark.parametrize( + ("path", "value"), + [ + (("host",), "192.0.2.10"), + (("environment", "serialNumber"), "SN123"), + (("points", 0, "value"), 12), + (("points", 1, "exceptionCode"), KeyError), + (("points", 0, "exceptionCode"), 2), + (("points", 1, "expected"), "confirmed"), + (("points", 0, "fingerprint"), "sha256:" + "0" * 64), + (("model", "ref"), KeyError), + (("model", "fingerprint"), KeyError), + (("model", "fingerprint"), "pf1:" + "0" * 64), + (("model", "ref"), "main"), + (("product",), "Example/Numeric"), + (("device",), "example/numeric-pilot"), + (("environment", "carrier"), "example/chassis"), + (("reportVersion",), 2), + (("model", "path"), "models/numeric-pilot.tm.json"), + (("date",), "2026-11-09T10:00:00Z"), + (("points",), []), + ], +) +def test_reports_reject_private_or_inconsistent_fields(path, value): + with pytest.raises(ReportError): + validate_report(mutate(path, value)) + + +def test_model_source_rules(): + workspace = mutate(("model", "source"), "workspace") + del workspace["model"]["ref"] + with pytest.raises(ReportError): + validate_report(workspace) + workspace["model"]["ref"] = "fork-3" + validate_report(workspace) + + local = mutate(("model", "source"), "local") + with pytest.raises(ReportError): + validate_report(local) + del local["model"]["ref"] + validate_report(local) + + +def test_duplicate_points_are_rejected(): + report = report_for(NUMERIC.read_bytes()) + report["points"].append(dict(report["points"][0])) + with pytest.raises(ReportError, match="duplicate properties"): + validate_report(report) + + +def test_cli_fingerprints_and_validates_reports(tmp_path): + def cli(*args): + return subprocess.run( + [sys.executable, "-m", "modpoll_wot", *map(str, args)], + capture_output=True, + text=True, + ) + + printed = cli("fingerprint", NUMERIC) + assert printed.returncode == 0 + assert json.loads(printed.stdout) == { + "model": model_fingerprint(NUMERIC.read_bytes()), + "points": point_fingerprints(NUMERIC.read_bytes()), + } + + report = tmp_path / "report.json" + report.write_text(json.dumps(report_for(NUMERIC.read_bytes()))) + checked = cli("validate-report", report, "--model", NUMERIC) + assert checked.returncode == 0, checked.stderr + assert "hash and fingerprints" in checked.stdout + + report.write_text(json.dumps(mutate(("host",), "192.0.2.10"))) + rejected = cli("validate-report", report) + assert rejected.returncode == 1 + assert "Additional properties" in rejected.stderr + + +def test_fixture_report_matches_its_model(): + report = json.loads((FIXTURES / "numeric.report.json").read_bytes()) + assert report == report_for(NUMERIC.read_bytes()) + + +def test_version_3_reports_with_product_still_validate(): + report = report_for(NUMERIC.read_bytes()) + report["reportVersion"] = 3 + report["product"] = "example/numeric-pilot" + validate_report(report, model=NUMERIC.read_bytes()) + + +def test_unknown_report_version_is_rejected(): + report = report_for(NUMERIC.read_bytes()) + report["reportVersion"] = 5 + with pytest.raises(ReportError, match="unsupported report version"): + validate_report(report) + + +def test_present_but_invalid_product_is_still_rejected(): + report = report_for(NUMERIC.read_bytes()) + report["product"] = "Example/Numeric" + with pytest.raises(ReportError): + validate_report(report) diff --git a/.editorconfig b/packages/modpoll/.editorconfig similarity index 100% rename from .editorconfig rename to packages/modpoll/.editorconfig diff --git a/.github/scripts/assemble-docs.py b/packages/modpoll/.github/scripts/assemble-docs.py similarity index 100% rename from .github/scripts/assemble-docs.py rename to packages/modpoll/.github/scripts/assemble-docs.py diff --git a/.github/scripts/check-portable-wheel.py b/packages/modpoll/.github/scripts/check-portable-wheel.py similarity index 100% rename from .github/scripts/check-portable-wheel.py rename to packages/modpoll/.github/scripts/check-portable-wheel.py diff --git a/.github/scripts/check_release_version.py b/packages/modpoll/.github/scripts/check_release_version.py similarity index 100% rename from .github/scripts/check_release_version.py rename to packages/modpoll/.github/scripts/check_release_version.py diff --git a/.github/scripts/preview-release.py b/packages/modpoll/.github/scripts/preview-release.py similarity index 100% rename from .github/scripts/preview-release.py rename to packages/modpoll/.github/scripts/preview-release.py diff --git a/.github/scripts/release_image_tags.py b/packages/modpoll/.github/scripts/release_image_tags.py similarity index 100% rename from .github/scripts/release_image_tags.py rename to packages/modpoll/.github/scripts/release_image_tags.py diff --git a/.gitignore b/packages/modpoll/.gitignore similarity index 100% rename from .gitignore rename to packages/modpoll/.gitignore diff --git a/.tool-versions b/packages/modpoll/.tool-versions similarity index 100% rename from .tool-versions rename to packages/modpoll/.tool-versions diff --git a/CHANGELOG.md b/packages/modpoll/CHANGELOG.md similarity index 100% rename from CHANGELOG.md rename to packages/modpoll/CHANGELOG.md diff --git a/CONTRIBUTING.md b/packages/modpoll/CONTRIBUTING.md similarity index 100% rename from CONTRIBUTING.md rename to packages/modpoll/CONTRIBUTING.md diff --git a/packages/modpoll/Dockerfile b/packages/modpoll/Dockerfile new file mode 100644 index 0000000..f56975d --- /dev/null +++ b/packages/modpoll/Dockerfile @@ -0,0 +1,22 @@ +# syntax=docker/dockerfile:1 +# Build from the repository root: docker build -f packages/modpoll/Dockerfile . + +# FROM python:3.12-alpine +FROM python:3.12-slim-bookworm + +COPY --from=ghcr.io/astral-sh/uv:0.11.19 /uv /uvx /bin/ + +# The workspace lock covers every member, so each member's metadata is copied for `--locked`. +# Only modpoll and the modpoll-wot it pins are installed. +WORKDIR /app +COPY pyproject.toml uv.lock /app/ +COPY packages/modsim/pyproject.toml /app/packages/modsim/ +COPY packages/modpoll-wot /app/packages/modpoll-wot +COPY packages/modpoll/pyproject.toml packages/modpoll/README.md /app/packages/modpoll/ +COPY packages/modpoll/modpoll /app/packages/modpoll/modpoll + +# Project initialization: +RUN uv sync --locked --no-dev --all-extras --no-editable --package modpoll +ENV PATH="/app/.venv/bin:${PATH}" + +CMD ["modpoll", "--version"] diff --git a/packages/modpoll/LICENSE b/packages/modpoll/LICENSE new file mode 100644 index 0000000..f1a3303 --- /dev/null +++ b/packages/modpoll/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2021-2024, Ying Shaodong + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Makefile b/packages/modpoll/Makefile similarity index 86% rename from Makefile rename to packages/modpoll/Makefile index cdadfe1..0203acd 100644 --- a/Makefile +++ b/packages/modpoll/Makefile @@ -3,14 +3,15 @@ PROJECT_NAME ?= modpoll .PHONY: install install: ## Install the uv environment and pre-commit hooks @uv sync --all-extras --all-groups - @uv run pre-commit install --allow-missing-config + @cd ../.. && uv run --no-sync pre-commit install --allow-missing-config .PHONY: check check: ## Run code quality tools. @echo "🚀 Checking uv lock file consistency with 'pyproject.toml'" @uv lock --check @echo "🚀 Linting code: Running pre-commit" - @uv run pre-commit run -a + @# One pre-commit configuration serves the workspace; check this package's files only. + @git ls-files -z . | xargs -0 uv run pre-commit run --config ../../.pre-commit-config.yaml --files @echo "🚀 Checking for obsolete dependencies: Running deptry" @uv run deptry . @@ -45,7 +46,7 @@ build-and-publish: build publish ## Build and publish. .PHONY: docker-build-dev docker-build-dev: ## Build docker for local dev @echo "🚀 Creating docker image file" - @docker build -t ${PROJECT_NAME}:dev . + @docker build -f Dockerfile -t ${PROJECT_NAME}:dev ../.. .PHONY: docker-run-dev docker-run-dev: docker-build-dev ## Run docker compose for local dev diff --git a/packages/modpoll/README.md b/packages/modpoll/README.md new file mode 100644 index 0000000..9887e81 --- /dev/null +++ b/packages/modpoll/README.md @@ -0,0 +1,254 @@ +> **2.x development branch.** This checkout accepts v1 CSV and WoT TM/TD JSON using profile 0.2; `--config` detects the format from the content. Install the current preview with `uv tool install --prerelease allow 'modpoll[serial]==2.0.0a8'`; stable 1.x remains available with `uv tool install 'modpoll<2'`. For development, run `make install`, then prefix project commands with `uv run`. + +# Modpoll - A New Command-line Tool for Modbus and MQTT + +[![Release](https://img.shields.io/github/v/release/top-maker/modpoll)](https://img.shields.io/github/v/release/top-maker/modpoll) +[![Build status](https://img.shields.io/github/actions/workflow/status/top-maker/modpoll/main.yml?branch=main)](https://github.com/top-maker/modpoll/actions/workflows/main.yml?query=branch%3Amain) +[![License](https://img.shields.io/github/license/top-maker/modpoll)](https://img.shields.io/github/license/top-maker/modpoll) +[![Downloads](https://static.pepy.tech/badge/modpoll/week)](https://pepy.tech/project/modpoll) + + +> Learn more about *modpoll* usage at [documentation](https://top-maker.github.io/modpoll) site. + +## Motivation + +The idea for creating this tool originated from my need to efficiently check new devices during site surveys. These surveys are often time-constrained and space-limited, with on-site work adding to the pressure. In such situations, a portable Swiss Army knife toolkit becomes a valuable companion. + +This tool can be easily deployed on a Raspberry Pi or similar embedded devices, polling data from a Modbus network or connected devices. Users can choose to log the data locally or publish it to an MQTT broker for further troubleshooting. + +The MQTT broker can be set up either on the same Raspberry Pi or in the cloud. Once data is successfully published, users can subscribe to the relevant MQTT topics and conveniently view the data on their smartphones. + +<p align="center"> + <img src="docs/site/assets/modpoll-usage.png"> +</p> + +Moreover, you can also run this tool continuously on a server as a Modbus-MQTT gateway, i.e. polling from local Modbus devices and forwarding data to a centralized cloud service. + +In fact, *modpoll* helps to bridge between the traditional field-bus world and the new IoT world. + +> 💡 **Tips:** This tool is designed to be a standalone executable application, which works out-of-the-box on Linux/macOS/Windows. If you are looking for a Modbus python library, please consider the following great open-source projects, [pymodbus](https://github.com/riptideio/pymodbus) or [minimalmodbus](https://github.com/pyhys/minimalmodbus) + + +## Feature + +- Support Modbus RTU/TCP/UDP devices +- Show polling data for local debugging, like a typical modpoll tool +- Publish polling data to MQTT broker for remote debugging, especially on smart phone +- Export polling data to local storage for further investigation +- Provide docker solution for continuous data polling use case + + +## Installation + +This tool requires Python 3.10+ (Ubuntu 22.04+ or equivalent) and is available on the [Python Package Index](https://pypi.org/). Install it with uv. Ubuntu 20.04 and Python 3.8 are no longer supported. + +### Using uv + +Install *modpoll* using the following command, + +```bash +uv tool install --prerelease allow "modpoll==2.0.0a8" +``` + +Optionally, [pyserial](https://pyserial.readthedocs.io/) library can be installed for Modbus-RTU communication, + +```bash +uv tool install --prerelease allow 'modpoll[serial]==2.0.0a8' +``` + +Upgrade the tool via the following command, + +```bash +uv tool install --upgrade --prerelease allow "modpoll<3" +``` + +The same commands work on Windows PowerShell; uv manages the isolated tool environment. + +## Quickstart + +Verify modpoll against the already deployed public Modbus TCP simulator. No +local modsim installation or Docker container is needed: + +```bash +modpoll --once \ + --tcp modsim.topmaker.net --tcp-port 502 \ + --config examples/modsim.tm.json +``` + +### Modbus ASCII and framers + +- Serial transports: use `--serial PORT --framer ascii` (alias: `--rtu` still accepted); pyserial URLs such as `socket://host:port` and `rfc2217://host:port` work for serial-over-TCP tunnels. +- Serial supports framers `ascii` and `rtu` (pymodbus defaults to RTU if `--framer default`). Binary framer is no longer supported in pymodbus 3.9+. + +### Prepare a WoT configuration + +Use [examples/modsim.tm.json](examples/modsim.tm.json) for the simulator model or +[examples/modsim.generated.td.json](examples/modsim.generated.td.json) for its +generated local TCP instance. +Both preserve the four original blocks and 37 output references. `--unit-id` +overrides the Unit ID declared consistently in Forms (fallback 1); a concrete TD's Forms must agree before overrides. +The existing transport, polling, output and MQTT arguments remain available. + +See the [current profile](https://github.com/top-maker/modpoll-wot/blob/main/profile.md) for field mapping, +access flags, byte order, multiplier semantics and supported limits; the +[execution contract](https://github.com/top-maker/modpoll-wot/blob/main/CONTRACT.md) defines the profile 0.2-only input policy. +The configuration loader detects the format from the content and reports invalid +model fields before polling. Each model describes one device; use multiple +`--config` paths for multiple devices. Give each model a unique `title`, which is +the output device name. Existing v1 CSV configurations load through the same +`--config` argument; no separate flags are needed. + +Physical RS485 polling has also been verified by the maintainer with an Eastron +meter (2026-10-28). See [validation](docs/validation.rst) for the evidence scope and +[contributed mappings](contrib/README.md) for vendor references. + +For a complete local simulator/MQTT demonstration, use the repository's +[Docker Compose example](examples/README.md). + +### Read a device and write a verification report + +Adding `--report` to a normal read verifies the Thing Model on real hardware: every point is read once, +read-only, without retries and with a timeout of at most 10 seconds, so a lost request is a result and not +something to repeat. MODEL is a local TM/TD file, an http(s) URL or a `modiohub:<id>@<version>` Workspace +reference. `--report FILE` writes the verification report (`-` prints it); bare `--report` asks where to +save, whether the values look right, and whether to upload: + +```sh +modpoll --config examples/modsim.tm.json --tcp 192.168.1.20 --unit-id 3 --report report.json +``` + +The report records, per point, whether the read worked (`ok`, a Modbus `exception` with its code, +`no-response`, or `not-tested` when the answer could not be decoded) and your judgment of the value: +`--confirm POINT...` (or `all`) and `--reject POINT...` for values you compared with the device, otherwise +`unchecked`. The report holds no address, Unit +ID, serial number or value; review it before sharing. It is checked with +[modpoll-wot](https://github.com/top-maker/modpoll-wot) (`modpoll-wot validate-report report.json --model +model.tm.json`), and `--export` still writes the snapshot of the same read. ModioHub resolves the product +from the model fingerprint, so you never name the product. The exit +code is 1 unless every point was read. + +### Sign in to ModioHub, read a Workspace Thing Model and upload the report + +`modpoll login` signs in with your browser: it prints a code and an address (and opens the address where a +browser can open), you confirm the code there, and the 7-day tool session is kept in a file only you can read +(`~/.config/modiohub/credentials.json`, or `%APPDATA%\modiohub` on Windows). modsim uses the same file, so +signing in with either tool signs in both. `MODIOHUB_TOKEN` in the environment replaces the file for scripts, +`MODIOHUB_URL` selects another server, and `login` and `logout` take `--server URL` for the same. `modpoll logout` forgets the login on this computer; +revoke the session in your ModioHub settings to end it on the server. + +Once signed in, `--config modiohub:<id>@<version>` (the version is a number or `latest`) reads one +of your custom Thing Models. A shared one needs no login. Verifying it names the Workspace model in the +report, and `modpoll --config ... --upload` shows the report and, after you confirm (or with `--yes`), +uploads it; without a login the sign-in flow starts right there: + +```sh +modpoll --config modiohub:k3x9f2m7q4a8n5bd@latest --tcp 192.168.1.20 --upload +``` + +### MQTT data and write behavior + +The local example above uses the `adam6024_raw` TD title for its default topics: +`modpoll/adam6024_raw/data` for samples and `modpoll/adam6024_raw/set` for +write commands. The publish, subscribe and diagnostics topic patterns are +configurable; see the [MQTT documentation](docs/site/usage.rst). + +Writes use literal Modbus PDU addresses and raw values. Holding-register arrays +use FC16 and must contain 1–123 unsigned 16-bit values within the address range. +Invalid, oversized, malformed, ambiguous or retained write messages are ignored +and logged. Brokers can clear the retained flag on live forwarding, so configure +the broker not to retain commands on the set topic; QoS does not make a write +exactly once. + +When a sample is invalid in a poll cycle, modpoll omits it from MQTT output and +writes `null` for that point in the JSON snapshot. Snapshots from multiple +configuration files are combined and replaced atomically. When `--timestamp` is +enabled, the timestamp is the start time of the poll cycle in Unix seconds; a +device with a point named `timestamp` cannot use it. A snapshot is +[simulation data](https://github.com/top-maker/modpoll-wot/blob/main/profile.md#simulation-data), +so `modsim --config device.tm.json --data snapshot.json` replays it locally. + + +## Run with docker + +A docker image has been provided for user to directly run the tool without local installation, + + ```bash + docker run --rm topmaker/modpoll:2.0.0a8 + ``` + +It shows the version of the tool by default. + +On Linux, host networking connects the container to a simulator on the host. +Mount the JSON configuration into the container; ``--daemon`` suppresses tables. + +If you want to load a local configure file, you need to mount a local folder onto container volume, +for example, if the child folder `examples` contains the config file `modsim.tm.json`, we can use it via the following command, + + ```bash + docker run --rm --network host -v "$(pwd)/examples:/app/examples:ro" topmaker/modpoll:2.0.0a8 \ + modpoll -d \ + --tcp 127.0.0.1 --tcp-port 5020 \ + --config /app/examples/modsim.tm.json + ``` + + +## Example Use Cases + +- Connect to Modbus TCP device + + ```bash + modpoll \ + --tcp 192.168.1.10 \ + --config examples/modsim.tm.json + ``` + +- Connect to Modbus serial device + + ```bash + modpoll \ + --serial /dev/ttyUSB0 \ + --serial-baud 9600 \ + --config examples/modsim.tm.json + ``` + +- Connect to Modbus TCP device and publish data to MQTT broker + + ```bash + modpoll \ + --tcp 127.0.0.1 --tcp-port 5020 \ + --mqtt-host broker.emqx.io \ + --config examples/modsim.tm.json + ``` + +- Connect to Modbus TCP device and export a local JSON snapshot + + ```bash + modpoll \ + --tcp 127.0.0.1 --tcp-port 5020 \ + --export data.json \ + --config examples/modsim.tm.json + ``` + +- Replay the snapshot with modsim on this computer (keep snapshots of real + devices local) + + ```bash + modsim --config examples/modsim.tm.json --port 5020 --data data.json + ``` + +> Refer to the [documentation](https://top-maker.github.io/modpoll) site for more details about the configuration and examples. + +> *If you find this tool useful, please support us by starring 🌟 our repository to encourage further improvements.* + +## Credits + +The implementation of this project is heavily inspired by the following two projects: +- https://github.com/owagner/modbus2mqtt (MIT license) +- https://github.com/mbs38/spicierModbus2mqtt (MIT license) + +Thanks to Max Brueggemann and Oliver Wagner for their great work. + + +## License + +MIT © 2021-2026, Ying Shaodong diff --git a/contrib/README.md b/packages/modpoll/contrib/README.md similarity index 100% rename from contrib/README.md rename to packages/modpoll/contrib/README.md diff --git a/contrib/eastron/Eastron SDM120 MODBUS Protocol v2.4.pdf b/packages/modpoll/contrib/eastron/Eastron SDM120 MODBUS Protocol v2.4.pdf similarity index 100% rename from contrib/eastron/Eastron SDM120 MODBUS Protocol v2.4.pdf rename to packages/modpoll/contrib/eastron/Eastron SDM120 MODBUS Protocol v2.4.pdf diff --git a/contrib/eastron/Eastron SDM72D-M multi-function version V1.1.pdf b/packages/modpoll/contrib/eastron/Eastron SDM72D-M multi-function version V1.1.pdf similarity index 100% rename from contrib/eastron/Eastron SDM72D-M multi-function version V1.1.pdf rename to packages/modpoll/contrib/eastron/Eastron SDM72D-M multi-function version V1.1.pdf diff --git a/contrib/eastron/SDM120M.csv b/packages/modpoll/contrib/eastron/SDM120M.csv similarity index 100% rename from contrib/eastron/SDM120M.csv rename to packages/modpoll/contrib/eastron/SDM120M.csv diff --git a/contrib/eastron/SDM72D-M.csv b/packages/modpoll/contrib/eastron/SDM72D-M.csv similarity index 100% rename from contrib/eastron/SDM72D-M.csv rename to packages/modpoll/contrib/eastron/SDM72D-M.csv diff --git a/contrib/eastron/sdm72d-m.td.json b/packages/modpoll/contrib/eastron/sdm72d-m.td.json similarity index 100% rename from contrib/eastron/sdm72d-m.td.json rename to packages/modpoll/contrib/eastron/sdm72d-m.td.json diff --git a/contrib/eniwise/scpms6.csv b/packages/modpoll/contrib/eniwise/scpms6.csv similarity index 100% rename from contrib/eniwise/scpms6.csv rename to packages/modpoll/contrib/eniwise/scpms6.csv diff --git a/contrib/foxess/foxess.cfg b/packages/modpoll/contrib/foxess/foxess.cfg similarity index 100% rename from contrib/foxess/foxess.cfg rename to packages/modpoll/contrib/foxess/foxess.cfg diff --git a/contrib/huawei/smartlogger/Huawei SmartLogger Modbus.pdf b/packages/modpoll/contrib/huawei/smartlogger/Huawei SmartLogger Modbus.pdf similarity index 100% rename from contrib/huawei/smartlogger/Huawei SmartLogger Modbus.pdf rename to packages/modpoll/contrib/huawei/smartlogger/Huawei SmartLogger Modbus.pdf diff --git a/contrib/huawei/smartlogger/power_meter.csv b/packages/modpoll/contrib/huawei/smartlogger/power_meter.csv similarity index 100% rename from contrib/huawei/smartlogger/power_meter.csv rename to packages/modpoll/contrib/huawei/smartlogger/power_meter.csv diff --git a/contrib/huawei/smartlogger/power_meter.xlsx b/packages/modpoll/contrib/huawei/smartlogger/power_meter.xlsx similarity index 100% rename from contrib/huawei/smartlogger/power_meter.xlsx rename to packages/modpoll/contrib/huawei/smartlogger/power_meter.xlsx diff --git a/contrib/huawei/sun2000/HUAWEI_SUN2000_245KTL28KTL_MODBUS_Interface_Definitions_20150715_JP.pdf b/packages/modpoll/contrib/huawei/sun2000/HUAWEI_SUN2000_245KTL28KTL_MODBUS_Interface_Definitions_20150715_JP.pdf similarity index 100% rename from contrib/huawei/sun2000/HUAWEI_SUN2000_245KTL28KTL_MODBUS_Interface_Definitions_20150715_JP.pdf rename to packages/modpoll/contrib/huawei/sun2000/HUAWEI_SUN2000_245KTL28KTL_MODBUS_Interface_Definitions_20150715_JP.pdf diff --git a/contrib/huawei/sun2000/real_time_sampling.csv b/packages/modpoll/contrib/huawei/sun2000/real_time_sampling.csv similarity index 100% rename from contrib/huawei/sun2000/real_time_sampling.csv rename to packages/modpoll/contrib/huawei/sun2000/real_time_sampling.csv diff --git a/contrib/huawei/sun2000/real_time_sampling.xlsx b/packages/modpoll/contrib/huawei/sun2000/real_time_sampling.xlsx similarity index 100% rename from contrib/huawei/sun2000/real_time_sampling.xlsx rename to packages/modpoll/contrib/huawei/sun2000/real_time_sampling.xlsx diff --git a/contrib/labjack/labjack.csv b/packages/modpoll/contrib/labjack/labjack.csv similarity index 100% rename from contrib/labjack/labjack.csv rename to packages/modpoll/contrib/labjack/labjack.csv diff --git a/contrib/microstar/microstar_p2000.csv b/packages/modpoll/contrib/microstar/microstar_p2000.csv similarity index 100% rename from contrib/microstar/microstar_p2000.csv rename to packages/modpoll/contrib/microstar/microstar_p2000.csv diff --git a/contrib/morningstar/tristar.csv b/packages/modpoll/contrib/morningstar/tristar.csv similarity index 100% rename from contrib/morningstar/tristar.csv rename to packages/modpoll/contrib/morningstar/tristar.csv diff --git a/contrib/xy/XY-MD02.pdf b/packages/modpoll/contrib/xy/XY-MD02.pdf similarity index 100% rename from contrib/xy/XY-MD02.pdf rename to packages/modpoll/contrib/xy/XY-MD02.pdf diff --git a/contrib/xy/xy-md02.csv b/packages/modpoll/contrib/xy/xy-md02.csv similarity index 100% rename from contrib/xy/xy-md02.csv rename to packages/modpoll/contrib/xy/xy-md02.csv diff --git a/docker-compose.yml b/packages/modpoll/docker-compose.yml similarity index 89% rename from docker-compose.yml rename to packages/modpoll/docker-compose.yml index 3846dd9..88829b8 100644 --- a/docker-compose.yml +++ b/packages/modpoll/docker-compose.yml @@ -1,6 +1,8 @@ services: modpoll: - build: . + build: + context: ../.. + dockerfile: packages/modpoll/Dockerfile depends_on: - modsim - mosquitto diff --git a/docker/mosquitto.conf b/packages/modpoll/docker/mosquitto.conf similarity index 100% rename from docker/mosquitto.conf rename to packages/modpoll/docker/mosquitto.conf diff --git a/docs/preview-notes.md b/packages/modpoll/docs/preview-notes.md similarity index 100% rename from docs/preview-notes.md rename to packages/modpoll/docs/preview-notes.md diff --git a/docs/release-process.rst b/packages/modpoll/docs/release-process.rst similarity index 100% rename from docs/release-process.rst rename to packages/modpoll/docs/release-process.rst diff --git a/docs/site/Makefile b/packages/modpoll/docs/site/Makefile similarity index 100% rename from docs/site/Makefile rename to packages/modpoll/docs/site/Makefile diff --git a/docs/site/assets/modpoll-usage.png b/packages/modpoll/docs/site/assets/modpoll-usage.png similarity index 100% rename from docs/site/assets/modpoll-usage.png rename to packages/modpoll/docs/site/assets/modpoll-usage.png diff --git a/docs/site/assets/screencast-modpoll-mqtt.gif b/packages/modpoll/docs/site/assets/screencast-modpoll-mqtt.gif similarity index 100% rename from docs/site/assets/screencast-modpoll-mqtt.gif rename to packages/modpoll/docs/site/assets/screencast-modpoll-mqtt.gif diff --git a/docs/site/assets/screenshot-modpoll.png b/packages/modpoll/docs/site/assets/screenshot-modpoll.png similarity index 100% rename from docs/site/assets/screenshot-modpoll.png rename to packages/modpoll/docs/site/assets/screenshot-modpoll.png diff --git a/docs/site/conf.py b/packages/modpoll/docs/site/conf.py similarity index 100% rename from docs/site/conf.py rename to packages/modpoll/docs/site/conf.py diff --git a/docs/site/configure.rst b/packages/modpoll/docs/site/configure.rst similarity index 100% rename from docs/site/configure.rst rename to packages/modpoll/docs/site/configure.rst diff --git a/docs/site/csv-migration.rst b/packages/modpoll/docs/site/csv-migration.rst similarity index 100% rename from docs/site/csv-migration.rst rename to packages/modpoll/docs/site/csv-migration.rst diff --git a/docs/site/index.rst b/packages/modpoll/docs/site/index.rst similarity index 100% rename from docs/site/index.rst rename to packages/modpoll/docs/site/index.rst diff --git a/docs/site/installation.rst b/packages/modpoll/docs/site/installation.rst similarity index 100% rename from docs/site/installation.rst rename to packages/modpoll/docs/site/installation.rst diff --git a/docs/site/make.bat b/packages/modpoll/docs/site/make.bat similarity index 100% rename from docs/site/make.bat rename to packages/modpoll/docs/site/make.bat diff --git a/docs/site/quickstart.rst b/packages/modpoll/docs/site/quickstart.rst similarity index 100% rename from docs/site/quickstart.rst rename to packages/modpoll/docs/site/quickstart.rst diff --git a/docs/site/usage.rst b/packages/modpoll/docs/site/usage.rst similarity index 100% rename from docs/site/usage.rst rename to packages/modpoll/docs/site/usage.rst diff --git a/docs/site/v1-compatibility.rst b/packages/modpoll/docs/site/v1-compatibility.rst similarity index 100% rename from docs/site/v1-compatibility.rst rename to packages/modpoll/docs/site/v1-compatibility.rst diff --git a/docs/validation.rst b/packages/modpoll/docs/validation.rst similarity index 100% rename from docs/validation.rst rename to packages/modpoll/docs/validation.rst diff --git a/examples/README.md b/packages/modpoll/examples/README.md similarity index 100% rename from examples/README.md rename to packages/modpoll/examples/README.md diff --git a/packages/modpoll/examples/modsim.csv b/packages/modpoll/examples/modsim.csv new file mode 100644 index 0000000..9c7a652 --- /dev/null +++ b/packages/modpoll/examples/modsim.csv @@ -0,0 +1,42 @@ +device,modsim01,1,, +poll,coil,0,16,BE_BE +ref,coil01-08,0,bool8,rw +ref,coil09-16,1,bool8,rw +poll,discrete_input,10000,16,BE_BE +ref,di01-08,10000,bool8,rw +ref,di09-16,10001,bool8,rw +poll,input_register,30000,20,BE_BE +ref,input_reg01,30000,uint16,rw +ref,input_reg02,30001,uint16,rw +ref,input_reg03,30002,uint16,rw +ref,input_reg04,30003,uint16,rw +ref,input_reg05,30004,int16,rw +ref,input_reg06,30005,int16,rw +ref,input_reg07,30006,int16,rw +ref,input_reg08,30007,int16,rw +ref,input_reg09,30008,uint32,rw +ref,input_reg10,30010,uint32,rw,,0.001 +ref,input_reg11,30012,int32,rw +ref,input_reg12,30014,int32,rw,,1000 +ref,input_reg13,30016,float32,rw +ref,input_reg14,30018,float32,rw +poll,holding_register,40000,44,BE_BE +ref,holding_reg01,40000,uint16,rw +ref,holding_reg02,40001,uint16,rw +ref,holding_reg03,40002,uint16,rw +ref,holding_reg04,40003,uint16,rw +ref,holding_reg05,40004,int16,rw +ref,holding_reg06,40005,int16,rw +ref,holding_reg07,40006,int16,rw +ref,holding_reg08,40007,int16,rw +ref,holding_reg09,40008,uint32,rw +ref,holding_reg10,40010,uint32,rw,,0.001 +ref,holding_reg11,40012,int32,rw +ref,holding_reg12,40014,int32,rw,,1000 +ref,holding_reg13,40016,float32,rw +ref,holding_reg14,40018,float32,rw +ref,holding_reg15,40020,uint64,rw +ref,holding_reg16,40024,int64,rw +ref,holding_reg17,40028,float64,rw +ref,holding_reg18,40032,float64,rw +ref,holding_reg19,40036,string16,rw \ No newline at end of file diff --git a/packages/modpoll/examples/modsim.generated.td.json b/packages/modpoll/examples/modsim.generated.td.json new file mode 100644 index 0000000..be41a31 --- /dev/null +++ b/packages/modpoll/examples/modsim.generated.td.json @@ -0,0 +1,700 @@ +{ + "@context": [ + "https://www.w3.org/2022/wot/td/v1.1", + { + "modpoll": "https://top-maker.github.io/modpoll/vocab/wot-modbus#", + "modv": "https://www.w3.org/2019/wot/modbus", + "xsd": "http://www.w3.org/2001/XMLSchema#" + } + ], + "title": "modsim01", + "modpoll:version": "0.2", + "properties": { + "coil01-08": { + "type": "array", + "items": { + "type": "boolean" + }, + "forms": [ + { + "op": [ + "readproperty", + "writeproperty" + ], + "contentType": "application/octet-stream", + "modv:entity": "Coil", + "modv:address": 0, + "modv:quantity": 8, + "modv:type": "xsd:boolean", + "href": "modbus+tcp://127.0.0.1:5020/1/0?quantity=8" + } + ] + }, + "coil09-16": { + "type": "array", + "items": { + "type": "boolean" + }, + "forms": [ + { + "op": [ + "readproperty", + "writeproperty" + ], + "contentType": "application/octet-stream", + "modv:entity": "Coil", + "modv:address": 8, + "modv:quantity": 8, + "modv:type": "xsd:boolean", + "href": "modbus+tcp://127.0.0.1:5020/1/8?quantity=8" + } + ] + }, + "di01-08": { + "type": "array", + "items": { + "type": "boolean" + }, + "readOnly": true, + "forms": [ + { + "op": "readproperty", + "contentType": "application/octet-stream", + "modv:entity": "DiscreteInput", + "modv:address": 10000, + "modv:quantity": 8, + "modv:type": "xsd:boolean", + "href": "modbus+tcp://127.0.0.1:5020/1/10000?quantity=8" + } + ] + }, + "di09-16": { + "type": "array", + "items": { + "type": "boolean" + }, + "readOnly": true, + "forms": [ + { + "op": "readproperty", + "contentType": "application/octet-stream", + "modv:entity": "DiscreteInput", + "modv:address": 10008, + "modv:quantity": 8, + "modv:type": "xsd:boolean", + "href": "modbus+tcp://127.0.0.1:5020/1/10008?quantity=8" + } + ] + }, + "input_reg01": { + "type": "number", + "readOnly": true, + "forms": [ + { + "op": "readproperty", + "contentType": "application/octet-stream", + "modv:entity": "InputRegister", + "modv:address": 30000, + "modv:quantity": 1, + "modv:type": "xsd:unsignedShort", + "href": "modbus+tcp://127.0.0.1:5020/1/30000?quantity=1" + } + ] + }, + "input_reg02": { + "type": "number", + "readOnly": true, + "forms": [ + { + "op": "readproperty", + "contentType": "application/octet-stream", + "modv:entity": "InputRegister", + "modv:address": 30001, + "modv:quantity": 1, + "modv:type": "xsd:unsignedShort", + "href": "modbus+tcp://127.0.0.1:5020/1/30001?quantity=1" + } + ] + }, + "input_reg03": { + "type": "number", + "readOnly": true, + "forms": [ + { + "op": "readproperty", + "contentType": "application/octet-stream", + "modv:entity": "InputRegister", + "modv:address": 30002, + "modv:quantity": 1, + "modv:type": "xsd:unsignedShort", + "href": "modbus+tcp://127.0.0.1:5020/1/30002?quantity=1" + } + ] + }, + "input_reg04": { + "type": "number", + "readOnly": true, + "forms": [ + { + "op": "readproperty", + "contentType": "application/octet-stream", + "modv:entity": "InputRegister", + "modv:address": 30003, + "modv:quantity": 1, + "modv:type": "xsd:unsignedShort", + "href": "modbus+tcp://127.0.0.1:5020/1/30003?quantity=1" + } + ] + }, + "input_reg05": { + "type": "number", + "readOnly": true, + "forms": [ + { + "op": "readproperty", + "contentType": "application/octet-stream", + "modv:entity": "InputRegister", + "modv:address": 30004, + "modv:quantity": 1, + "modv:type": "xsd:short", + "href": "modbus+tcp://127.0.0.1:5020/1/30004?quantity=1" + } + ] + }, + "input_reg06": { + "type": "number", + "readOnly": true, + "forms": [ + { + "op": "readproperty", + "contentType": "application/octet-stream", + "modv:entity": "InputRegister", + "modv:address": 30005, + "modv:quantity": 1, + "modv:type": "xsd:short", + "href": "modbus+tcp://127.0.0.1:5020/1/30005?quantity=1" + } + ] + }, + "input_reg07": { + "type": "number", + "readOnly": true, + "forms": [ + { + "op": "readproperty", + "contentType": "application/octet-stream", + "modv:entity": "InputRegister", + "modv:address": 30006, + "modv:quantity": 1, + "modv:type": "xsd:short", + "href": "modbus+tcp://127.0.0.1:5020/1/30006?quantity=1" + } + ] + }, + "input_reg08": { + "type": "number", + "readOnly": true, + "forms": [ + { + "op": "readproperty", + "contentType": "application/octet-stream", + "modv:entity": "InputRegister", + "modv:address": 30007, + "modv:quantity": 1, + "modv:type": "xsd:short", + "href": "modbus+tcp://127.0.0.1:5020/1/30007?quantity=1" + } + ] + }, + "input_reg09": { + "type": "number", + "readOnly": true, + "forms": [ + { + "op": "readproperty", + "contentType": "application/octet-stream", + "modv:entity": "InputRegister", + "modv:address": 30008, + "modv:quantity": 2, + "modv:type": "xsd:unsignedInt", + "href": "modbus+tcp://127.0.0.1:5020/1/30008?quantity=2" + } + ] + }, + "input_reg10": { + "type": "number", + "readOnly": true, + "forms": [ + { + "op": "readproperty", + "contentType": "application/octet-stream", + "modv:entity": "InputRegister", + "modv:address": 30010, + "modv:quantity": 2, + "modv:type": "xsd:unsignedInt", + "modpoll:multiplier": "0.001", + "href": "modbus+tcp://127.0.0.1:5020/1/30010?quantity=2" + } + ] + }, + "input_reg11": { + "type": "number", + "readOnly": true, + "forms": [ + { + "op": "readproperty", + "contentType": "application/octet-stream", + "modv:entity": "InputRegister", + "modv:address": 30012, + "modv:quantity": 2, + "modv:type": "xsd:int", + "href": "modbus+tcp://127.0.0.1:5020/1/30012?quantity=2" + } + ] + }, + "input_reg12": { + "type": "number", + "readOnly": true, + "forms": [ + { + "op": "readproperty", + "contentType": "application/octet-stream", + "modv:entity": "InputRegister", + "modv:address": 30014, + "modv:quantity": 2, + "modv:type": "xsd:int", + "modpoll:multiplier": "1000", + "href": "modbus+tcp://127.0.0.1:5020/1/30014?quantity=2" + } + ] + }, + "input_reg13": { + "type": "number", + "readOnly": true, + "forms": [ + { + "op": "readproperty", + "contentType": "application/octet-stream", + "modv:entity": "InputRegister", + "modv:address": 30016, + "modv:quantity": 2, + "modv:type": "xsd:float", + "href": "modbus+tcp://127.0.0.1:5020/1/30016?quantity=2" + } + ] + }, + "input_reg14": { + "type": "number", + "readOnly": true, + "forms": [ + { + "op": "readproperty", + "contentType": "application/octet-stream", + "modv:entity": "InputRegister", + "modv:address": 30018, + "modv:quantity": 2, + "modv:type": "xsd:float", + "href": "modbus+tcp://127.0.0.1:5020/1/30018?quantity=2" + } + ] + }, + "holding_reg01": { + "type": "number", + "forms": [ + { + "op": [ + "readproperty", + "writeproperty" + ], + "contentType": "application/octet-stream", + "modv:entity": "HoldingRegister", + "modv:address": 40000, + "modv:quantity": 1, + "modv:type": "xsd:unsignedShort", + "href": "modbus+tcp://127.0.0.1:5020/1/40000?quantity=1" + } + ] + }, + "holding_reg02": { + "type": "number", + "forms": [ + { + "op": [ + "readproperty", + "writeproperty" + ], + "contentType": "application/octet-stream", + "modv:entity": "HoldingRegister", + "modv:address": 40001, + "modv:quantity": 1, + "modv:type": "xsd:unsignedShort", + "href": "modbus+tcp://127.0.0.1:5020/1/40001?quantity=1" + } + ] + }, + "holding_reg03": { + "type": "number", + "forms": [ + { + "op": [ + "readproperty", + "writeproperty" + ], + "contentType": "application/octet-stream", + "modv:entity": "HoldingRegister", + "modv:address": 40002, + "modv:quantity": 1, + "modv:type": "xsd:unsignedShort", + "href": "modbus+tcp://127.0.0.1:5020/1/40002?quantity=1" + } + ] + }, + "holding_reg04": { + "type": "number", + "forms": [ + { + "op": [ + "readproperty", + "writeproperty" + ], + "contentType": "application/octet-stream", + "modv:entity": "HoldingRegister", + "modv:address": 40003, + "modv:quantity": 1, + "modv:type": "xsd:unsignedShort", + "href": "modbus+tcp://127.0.0.1:5020/1/40003?quantity=1" + } + ] + }, + "holding_reg05": { + "type": "number", + "forms": [ + { + "op": [ + "readproperty", + "writeproperty" + ], + "contentType": "application/octet-stream", + "modv:entity": "HoldingRegister", + "modv:address": 40004, + "modv:quantity": 1, + "modv:type": "xsd:short", + "href": "modbus+tcp://127.0.0.1:5020/1/40004?quantity=1" + } + ] + }, + "holding_reg06": { + "type": "number", + "forms": [ + { + "op": [ + "readproperty", + "writeproperty" + ], + "contentType": "application/octet-stream", + "modv:entity": "HoldingRegister", + "modv:address": 40005, + "modv:quantity": 1, + "modv:type": "xsd:short", + "href": "modbus+tcp://127.0.0.1:5020/1/40005?quantity=1" + } + ] + }, + "holding_reg07": { + "type": "number", + "forms": [ + { + "op": [ + "readproperty", + "writeproperty" + ], + "contentType": "application/octet-stream", + "modv:entity": "HoldingRegister", + "modv:address": 40006, + "modv:quantity": 1, + "modv:type": "xsd:short", + "href": "modbus+tcp://127.0.0.1:5020/1/40006?quantity=1" + } + ] + }, + "holding_reg08": { + "type": "number", + "forms": [ + { + "op": [ + "readproperty", + "writeproperty" + ], + "contentType": "application/octet-stream", + "modv:entity": "HoldingRegister", + "modv:address": 40007, + "modv:quantity": 1, + "modv:type": "xsd:short", + "href": "modbus+tcp://127.0.0.1:5020/1/40007?quantity=1" + } + ] + }, + "holding_reg09": { + "type": "number", + "forms": [ + { + "op": [ + "readproperty", + "writeproperty" + ], + "contentType": "application/octet-stream", + "modv:entity": "HoldingRegister", + "modv:address": 40008, + "modv:quantity": 2, + "modv:type": "xsd:unsignedInt", + "href": "modbus+tcp://127.0.0.1:5020/1/40008?quantity=2" + } + ] + }, + "holding_reg10": { + "type": "number", + "forms": [ + { + "op": [ + "readproperty", + "writeproperty" + ], + "contentType": "application/octet-stream", + "modv:entity": "HoldingRegister", + "modv:address": 40010, + "modv:quantity": 2, + "modv:type": "xsd:unsignedInt", + "modpoll:multiplier": "0.001", + "href": "modbus+tcp://127.0.0.1:5020/1/40010?quantity=2" + } + ] + }, + "holding_reg11": { + "type": "number", + "forms": [ + { + "op": [ + "readproperty", + "writeproperty" + ], + "contentType": "application/octet-stream", + "modv:entity": "HoldingRegister", + "modv:address": 40012, + "modv:quantity": 2, + "modv:type": "xsd:int", + "href": "modbus+tcp://127.0.0.1:5020/1/40012?quantity=2" + } + ] + }, + "holding_reg12": { + "type": "number", + "forms": [ + { + "op": [ + "readproperty", + "writeproperty" + ], + "contentType": "application/octet-stream", + "modv:entity": "HoldingRegister", + "modv:address": 40014, + "modv:quantity": 2, + "modv:type": "xsd:int", + "modpoll:multiplier": "1000", + "href": "modbus+tcp://127.0.0.1:5020/1/40014?quantity=2" + } + ] + }, + "holding_reg13": { + "type": "number", + "forms": [ + { + "op": [ + "readproperty", + "writeproperty" + ], + "contentType": "application/octet-stream", + "modv:entity": "HoldingRegister", + "modv:address": 40016, + "modv:quantity": 2, + "modv:type": "xsd:float", + "href": "modbus+tcp://127.0.0.1:5020/1/40016?quantity=2" + } + ] + }, + "holding_reg14": { + "type": "number", + "forms": [ + { + "op": [ + "readproperty", + "writeproperty" + ], + "contentType": "application/octet-stream", + "modv:entity": "HoldingRegister", + "modv:address": 40018, + "modv:quantity": 2, + "modv:type": "xsd:float", + "href": "modbus+tcp://127.0.0.1:5020/1/40018?quantity=2" + } + ] + }, + "holding_reg15": { + "type": "number", + "forms": [ + { + "op": [ + "readproperty", + "writeproperty" + ], + "contentType": "application/octet-stream", + "modv:entity": "HoldingRegister", + "modv:address": 40020, + "modv:quantity": 4, + "modv:type": "xsd:unsignedLong", + "href": "modbus+tcp://127.0.0.1:5020/1/40020?quantity=4" + } + ] + }, + "holding_reg16": { + "type": "number", + "forms": [ + { + "op": [ + "readproperty", + "writeproperty" + ], + "contentType": "application/octet-stream", + "modv:entity": "HoldingRegister", + "modv:address": 40024, + "modv:quantity": 4, + "modv:type": "xsd:long", + "href": "modbus+tcp://127.0.0.1:5020/1/40024?quantity=4" + } + ] + }, + "holding_reg17": { + "type": "number", + "forms": [ + { + "op": [ + "readproperty", + "writeproperty" + ], + "contentType": "application/octet-stream", + "modv:entity": "HoldingRegister", + "modv:address": 40028, + "modv:quantity": 4, + "modv:type": "xsd:double", + "href": "modbus+tcp://127.0.0.1:5020/1/40028?quantity=4" + } + ] + }, + "holding_reg18": { + "type": "number", + "forms": [ + { + "op": [ + "readproperty", + "writeproperty" + ], + "contentType": "application/octet-stream", + "modv:entity": "HoldingRegister", + "modv:address": 40032, + "modv:quantity": 4, + "modv:type": "xsd:double", + "href": "modbus+tcp://127.0.0.1:5020/1/40032?quantity=4" + } + ] + }, + "holding_reg19": { + "type": "string", + "forms": [ + { + "op": [ + "readproperty", + "writeproperty" + ], + "contentType": "application/octet-stream", + "modv:entity": "HoldingRegister", + "modv:address": 40036, + "modv:quantity": 8, + "modv:type": "xsd:string", + "href": "modbus+tcp://127.0.0.1:5020/1/40036?quantity=8" + } + ] + } + }, + "modpoll:acquisition": [ + { + "modpoll:members": [ + "coil01-08", + "coil09-16" + ], + "modv:entity": "Coil", + "modv:address": 0, + "modv:quantity": 16 + }, + { + "modpoll:members": [ + "di01-08", + "di09-16" + ], + "modv:entity": "DiscreteInput", + "modv:address": 10000, + "modv:quantity": 16 + }, + { + "modpoll:members": [ + "input_reg01", + "input_reg02", + "input_reg03", + "input_reg04", + "input_reg05", + "input_reg06", + "input_reg07", + "input_reg08", + "input_reg09", + "input_reg10", + "input_reg11", + "input_reg12", + "input_reg13", + "input_reg14" + ], + "modv:entity": "InputRegister", + "modv:address": 30000, + "modv:quantity": 20 + }, + { + "modpoll:members": [ + "holding_reg01", + "holding_reg02", + "holding_reg03", + "holding_reg04", + "holding_reg05", + "holding_reg06", + "holding_reg07", + "holding_reg08", + "holding_reg09", + "holding_reg10", + "holding_reg11", + "holding_reg12", + "holding_reg13", + "holding_reg14", + "holding_reg15", + "holding_reg16", + "holding_reg17", + "holding_reg18", + "holding_reg19" + ], + "modv:entity": "HoldingRegister", + "modv:address": 40000, + "modv:quantity": 44 + } + ], + "securityDefinitions": { + "nosec_sc": { + "scheme": "nosec" + } + }, + "security": "nosec_sc" +} diff --git a/packages/modpoll/examples/modsim.tm.json b/packages/modpoll/examples/modsim.tm.json new file mode 100644 index 0000000..70c1f1e --- /dev/null +++ b/packages/modpoll/examples/modsim.tm.json @@ -0,0 +1,690 @@ +{ + "@context": [ + "https://www.w3.org/2022/wot/td/v1.1", + { + "modpoll": "https://top-maker.github.io/modpoll/vocab/wot-modbus#", + "modv": "https://www.w3.org/2019/wot/modbus", + "xsd": "http://www.w3.org/2001/XMLSchema#" + } + ], + "@type": "tm:ThingModel", + "title": "modsim01", + "modpoll:version": "0.2", + "properties": { + "coil01-08": { + "type": "array", + "items": { + "type": "boolean" + }, + "forms": [ + { + "op": [ + "readproperty", + "writeproperty" + ], + "contentType": "application/octet-stream", + "modv:entity": "Coil", + "modv:address": 0, + "modv:quantity": 8, + "modv:type": "xsd:boolean" + } + ] + }, + "coil09-16": { + "type": "array", + "items": { + "type": "boolean" + }, + "forms": [ + { + "op": [ + "readproperty", + "writeproperty" + ], + "contentType": "application/octet-stream", + "modv:entity": "Coil", + "modv:address": 8, + "modv:quantity": 8, + "modv:type": "xsd:boolean" + } + ] + }, + "di01-08": { + "type": "array", + "items": { + "type": "boolean" + }, + "readOnly": true, + "forms": [ + { + "op": [ + "readproperty" + ], + "contentType": "application/octet-stream", + "modv:entity": "DiscreteInput", + "modv:address": 10000, + "modv:quantity": 8, + "modv:type": "xsd:boolean" + } + ] + }, + "di09-16": { + "type": "array", + "items": { + "type": "boolean" + }, + "readOnly": true, + "forms": [ + { + "op": [ + "readproperty" + ], + "contentType": "application/octet-stream", + "modv:entity": "DiscreteInput", + "modv:address": 10008, + "modv:quantity": 8, + "modv:type": "xsd:boolean" + } + ] + }, + "input_reg01": { + "type": "number", + "readOnly": true, + "forms": [ + { + "op": [ + "readproperty" + ], + "contentType": "application/octet-stream", + "modv:entity": "InputRegister", + "modv:address": 30000, + "modv:quantity": 1, + "modv:type": "xsd:unsignedShort" + } + ] + }, + "input_reg02": { + "type": "number", + "readOnly": true, + "forms": [ + { + "op": [ + "readproperty" + ], + "contentType": "application/octet-stream", + "modv:entity": "InputRegister", + "modv:address": 30001, + "modv:quantity": 1, + "modv:type": "xsd:unsignedShort" + } + ] + }, + "input_reg03": { + "type": "number", + "readOnly": true, + "forms": [ + { + "op": [ + "readproperty" + ], + "contentType": "application/octet-stream", + "modv:entity": "InputRegister", + "modv:address": 30002, + "modv:quantity": 1, + "modv:type": "xsd:unsignedShort" + } + ] + }, + "input_reg04": { + "type": "number", + "readOnly": true, + "forms": [ + { + "op": [ + "readproperty" + ], + "contentType": "application/octet-stream", + "modv:entity": "InputRegister", + "modv:address": 30003, + "modv:quantity": 1, + "modv:type": "xsd:unsignedShort" + } + ] + }, + "input_reg05": { + "type": "number", + "readOnly": true, + "forms": [ + { + "op": [ + "readproperty" + ], + "contentType": "application/octet-stream", + "modv:entity": "InputRegister", + "modv:address": 30004, + "modv:quantity": 1, + "modv:type": "xsd:short" + } + ] + }, + "input_reg06": { + "type": "number", + "readOnly": true, + "forms": [ + { + "op": [ + "readproperty" + ], + "contentType": "application/octet-stream", + "modv:entity": "InputRegister", + "modv:address": 30005, + "modv:quantity": 1, + "modv:type": "xsd:short" + } + ] + }, + "input_reg07": { + "type": "number", + "readOnly": true, + "forms": [ + { + "op": [ + "readproperty" + ], + "contentType": "application/octet-stream", + "modv:entity": "InputRegister", + "modv:address": 30006, + "modv:quantity": 1, + "modv:type": "xsd:short" + } + ] + }, + "input_reg08": { + "type": "number", + "readOnly": true, + "forms": [ + { + "op": [ + "readproperty" + ], + "contentType": "application/octet-stream", + "modv:entity": "InputRegister", + "modv:address": 30007, + "modv:quantity": 1, + "modv:type": "xsd:short" + } + ] + }, + "input_reg09": { + "type": "number", + "readOnly": true, + "forms": [ + { + "op": [ + "readproperty" + ], + "contentType": "application/octet-stream", + "modv:entity": "InputRegister", + "modv:address": 30008, + "modv:quantity": 2, + "modv:type": "xsd:unsignedInt" + } + ] + }, + "input_reg10": { + "type": "number", + "readOnly": true, + "forms": [ + { + "op": [ + "readproperty" + ], + "contentType": "application/octet-stream", + "modv:entity": "InputRegister", + "modv:address": 30010, + "modv:quantity": 2, + "modv:type": "xsd:unsignedInt", + "modpoll:multiplier": "0.001" + } + ] + }, + "input_reg11": { + "type": "number", + "readOnly": true, + "forms": [ + { + "op": [ + "readproperty" + ], + "contentType": "application/octet-stream", + "modv:entity": "InputRegister", + "modv:address": 30012, + "modv:quantity": 2, + "modv:type": "xsd:int" + } + ] + }, + "input_reg12": { + "type": "number", + "readOnly": true, + "forms": [ + { + "op": [ + "readproperty" + ], + "contentType": "application/octet-stream", + "modv:entity": "InputRegister", + "modv:address": 30014, + "modv:quantity": 2, + "modv:type": "xsd:int", + "modpoll:multiplier": "1000" + } + ] + }, + "input_reg13": { + "type": "number", + "readOnly": true, + "forms": [ + { + "op": [ + "readproperty" + ], + "contentType": "application/octet-stream", + "modv:entity": "InputRegister", + "modv:address": 30016, + "modv:quantity": 2, + "modv:type": "xsd:float" + } + ] + }, + "input_reg14": { + "type": "number", + "readOnly": true, + "forms": [ + { + "op": [ + "readproperty" + ], + "contentType": "application/octet-stream", + "modv:entity": "InputRegister", + "modv:address": 30018, + "modv:quantity": 2, + "modv:type": "xsd:float" + } + ] + }, + "holding_reg01": { + "type": "number", + "forms": [ + { + "op": [ + "readproperty", + "writeproperty" + ], + "contentType": "application/octet-stream", + "modv:entity": "HoldingRegister", + "modv:address": 40000, + "modv:quantity": 1, + "modv:type": "xsd:unsignedShort" + } + ] + }, + "holding_reg02": { + "type": "number", + "forms": [ + { + "op": [ + "readproperty", + "writeproperty" + ], + "contentType": "application/octet-stream", + "modv:entity": "HoldingRegister", + "modv:address": 40001, + "modv:quantity": 1, + "modv:type": "xsd:unsignedShort" + } + ] + }, + "holding_reg03": { + "type": "number", + "forms": [ + { + "op": [ + "readproperty", + "writeproperty" + ], + "contentType": "application/octet-stream", + "modv:entity": "HoldingRegister", + "modv:address": 40002, + "modv:quantity": 1, + "modv:type": "xsd:unsignedShort" + } + ] + }, + "holding_reg04": { + "type": "number", + "forms": [ + { + "op": [ + "readproperty", + "writeproperty" + ], + "contentType": "application/octet-stream", + "modv:entity": "HoldingRegister", + "modv:address": 40003, + "modv:quantity": 1, + "modv:type": "xsd:unsignedShort" + } + ] + }, + "holding_reg05": { + "type": "number", + "forms": [ + { + "op": [ + "readproperty", + "writeproperty" + ], + "contentType": "application/octet-stream", + "modv:entity": "HoldingRegister", + "modv:address": 40004, + "modv:quantity": 1, + "modv:type": "xsd:short" + } + ] + }, + "holding_reg06": { + "type": "number", + "forms": [ + { + "op": [ + "readproperty", + "writeproperty" + ], + "contentType": "application/octet-stream", + "modv:entity": "HoldingRegister", + "modv:address": 40005, + "modv:quantity": 1, + "modv:type": "xsd:short" + } + ] + }, + "holding_reg07": { + "type": "number", + "forms": [ + { + "op": [ + "readproperty", + "writeproperty" + ], + "contentType": "application/octet-stream", + "modv:entity": "HoldingRegister", + "modv:address": 40006, + "modv:quantity": 1, + "modv:type": "xsd:short" + } + ] + }, + "holding_reg08": { + "type": "number", + "forms": [ + { + "op": [ + "readproperty", + "writeproperty" + ], + "contentType": "application/octet-stream", + "modv:entity": "HoldingRegister", + "modv:address": 40007, + "modv:quantity": 1, + "modv:type": "xsd:short" + } + ] + }, + "holding_reg09": { + "type": "number", + "forms": [ + { + "op": [ + "readproperty", + "writeproperty" + ], + "contentType": "application/octet-stream", + "modv:entity": "HoldingRegister", + "modv:address": 40008, + "modv:quantity": 2, + "modv:type": "xsd:unsignedInt" + } + ] + }, + "holding_reg10": { + "type": "number", + "forms": [ + { + "op": [ + "readproperty", + "writeproperty" + ], + "contentType": "application/octet-stream", + "modv:entity": "HoldingRegister", + "modv:address": 40010, + "modv:quantity": 2, + "modv:type": "xsd:unsignedInt", + "modpoll:multiplier": "0.001" + } + ] + }, + "holding_reg11": { + "type": "number", + "forms": [ + { + "op": [ + "readproperty", + "writeproperty" + ], + "contentType": "application/octet-stream", + "modv:entity": "HoldingRegister", + "modv:address": 40012, + "modv:quantity": 2, + "modv:type": "xsd:int" + } + ] + }, + "holding_reg12": { + "type": "number", + "forms": [ + { + "op": [ + "readproperty", + "writeproperty" + ], + "contentType": "application/octet-stream", + "modv:entity": "HoldingRegister", + "modv:address": 40014, + "modv:quantity": 2, + "modv:type": "xsd:int", + "modpoll:multiplier": "1000" + } + ] + }, + "holding_reg13": { + "type": "number", + "forms": [ + { + "op": [ + "readproperty", + "writeproperty" + ], + "contentType": "application/octet-stream", + "modv:entity": "HoldingRegister", + "modv:address": 40016, + "modv:quantity": 2, + "modv:type": "xsd:float" + } + ] + }, + "holding_reg14": { + "type": "number", + "forms": [ + { + "op": [ + "readproperty", + "writeproperty" + ], + "contentType": "application/octet-stream", + "modv:entity": "HoldingRegister", + "modv:address": 40018, + "modv:quantity": 2, + "modv:type": "xsd:float" + } + ] + }, + "holding_reg15": { + "type": "number", + "forms": [ + { + "op": [ + "readproperty", + "writeproperty" + ], + "contentType": "application/octet-stream", + "modv:entity": "HoldingRegister", + "modv:address": 40020, + "modv:quantity": 4, + "modv:type": "xsd:unsignedLong" + } + ] + }, + "holding_reg16": { + "type": "number", + "forms": [ + { + "op": [ + "readproperty", + "writeproperty" + ], + "contentType": "application/octet-stream", + "modv:entity": "HoldingRegister", + "modv:address": 40024, + "modv:quantity": 4, + "modv:type": "xsd:long" + } + ] + }, + "holding_reg17": { + "type": "number", + "forms": [ + { + "op": [ + "readproperty", + "writeproperty" + ], + "contentType": "application/octet-stream", + "modv:entity": "HoldingRegister", + "modv:address": 40028, + "modv:quantity": 4, + "modv:type": "xsd:double" + } + ] + }, + "holding_reg18": { + "type": "number", + "forms": [ + { + "op": [ + "readproperty", + "writeproperty" + ], + "contentType": "application/octet-stream", + "modv:entity": "HoldingRegister", + "modv:address": 40032, + "modv:quantity": 4, + "modv:type": "xsd:double" + } + ] + }, + "holding_reg19": { + "type": "string", + "forms": [ + { + "op": [ + "readproperty", + "writeproperty" + ], + "contentType": "application/octet-stream", + "modv:entity": "HoldingRegister", + "modv:address": 40036, + "modv:quantity": 8, + "modv:type": "xsd:string" + } + ] + } + }, + "modpoll:acquisition": [ + { + "modpoll:members": [ + "coil01-08", + "coil09-16" + ], + "modv:entity": "Coil", + "modv:address": 0, + "modv:quantity": 16 + }, + { + "modpoll:members": [ + "di01-08", + "di09-16" + ], + "modv:entity": "DiscreteInput", + "modv:address": 10000, + "modv:quantity": 16 + }, + { + "modpoll:members": [ + "input_reg01", + "input_reg02", + "input_reg03", + "input_reg04", + "input_reg05", + "input_reg06", + "input_reg07", + "input_reg08", + "input_reg09", + "input_reg10", + "input_reg11", + "input_reg12", + "input_reg13", + "input_reg14" + ], + "modv:entity": "InputRegister", + "modv:address": 30000, + "modv:quantity": 20 + }, + { + "modpoll:members": [ + "holding_reg01", + "holding_reg02", + "holding_reg03", + "holding_reg04", + "holding_reg05", + "holding_reg06", + "holding_reg07", + "holding_reg08", + "holding_reg09", + "holding_reg10", + "holding_reg11", + "holding_reg12", + "holding_reg13", + "holding_reg14", + "holding_reg15", + "holding_reg16", + "holding_reg17", + "holding_reg18", + "holding_reg19" + ], + "modv:entity": "HoldingRegister", + "modv:address": 40000, + "modv:quantity": 44 + } + ] +} diff --git a/modpoll/__init__.py b/packages/modpoll/modpoll/__init__.py similarity index 100% rename from modpoll/__init__.py rename to packages/modpoll/modpoll/__init__.py diff --git a/modpoll/__main__.py b/packages/modpoll/modpoll/__main__.py similarity index 100% rename from modpoll/__main__.py rename to packages/modpoll/modpoll/__main__.py diff --git a/modpoll/arg_parser.py b/packages/modpoll/modpoll/arg_parser.py similarity index 100% rename from modpoll/arg_parser.py rename to packages/modpoll/modpoll/arg_parser.py diff --git a/modpoll/config_loader.py b/packages/modpoll/modpoll/config_loader.py similarity index 100% rename from modpoll/config_loader.py rename to packages/modpoll/modpoll/config_loader.py diff --git a/modpoll/csv_config.py b/packages/modpoll/modpoll/csv_config.py similarity index 100% rename from modpoll/csv_config.py rename to packages/modpoll/modpoll/csv_config.py diff --git a/modpoll/login.py b/packages/modpoll/modpoll/login.py similarity index 100% rename from modpoll/login.py rename to packages/modpoll/modpoll/login.py diff --git a/modpoll/main.py b/packages/modpoll/modpoll/main.py similarity index 100% rename from modpoll/main.py rename to packages/modpoll/modpoll/main.py diff --git a/modpoll/modbus_task.py b/packages/modpoll/modpoll/modbus_task.py similarity index 100% rename from modpoll/modbus_task.py rename to packages/modpoll/modpoll/modbus_task.py diff --git a/modpoll/mqtt_task.py b/packages/modpoll/modpoll/mqtt_task.py similarity index 100% rename from modpoll/mqtt_task.py rename to packages/modpoll/modpoll/mqtt_task.py diff --git a/modpoll/precision.py b/packages/modpoll/modpoll/precision.py similarity index 100% rename from modpoll/precision.py rename to packages/modpoll/modpoll/precision.py diff --git a/modpoll/utils.py b/packages/modpoll/modpoll/utils.py similarity index 100% rename from modpoll/utils.py rename to packages/modpoll/modpoll/utils.py diff --git a/modpoll/verification.py b/packages/modpoll/modpoll/verification.py similarity index 100% rename from modpoll/verification.py rename to packages/modpoll/modpoll/verification.py diff --git a/modpoll/wot_config.py b/packages/modpoll/modpoll/wot_config.py similarity index 100% rename from modpoll/wot_config.py rename to packages/modpoll/modpoll/wot_config.py diff --git a/packages/modpoll/pyproject.toml b/packages/modpoll/pyproject.toml new file mode 100644 index 0000000..1248faa --- /dev/null +++ b/packages/modpoll/pyproject.toml @@ -0,0 +1,71 @@ +[project] +name = "modpoll" +version = "2.0.0a10" +description = "A New Command-line Tool for Modbus and MQTT" +authors = [{ name = "Ying Shaodong", email = "helloysd@gmail.com" }] +readme = "README.md" +requires-python = ">=3.10,<4.0" +dependencies = [ + "pymodbus~=3.16.1", + "paho-mqtt>=2.1.0,<3.0.0", + "prettytable>=3.9.0,<4.0.0", + "requests>=2.32.5,<3.0.0", + "modpoll-wot==0.6.0a2", +] + +[project.optional-dependencies] +serial = ["pyserial>=3.5,<4.0"] + +[dependency-groups] +dev = [ + "pre-commit>=3.5.0,<4.0.0", + "pytest>=8.2.2,<9.0.0", + "deptry>=0.16.1,<0.17.0", + "tox>=4.16.0,<5.0.0", + "tomli>=2,<3; python_version < '3.11'", + "pytest-cov>=5,<8", +] +docs = [ + "sphinx>=6,<8", + "sphinx-argparse>=0.3.1,<0.4.0", + "sphinx-rtd-theme>=1.0.0,<2.0.0", + "sphinx-autobuild==2021.3.14", + "pandoc>=2.3,<3.0.0", +] + +[build-system] +requires = ["uv_build>=0.11.19,<0.12.0"] +build-backend = "uv_build" + +[tool.uv.build-backend] +module-name = "modpoll" +module-root = "" + +[tool.uv.sources] +# Inside the workspace modpoll-wot comes from packages/modpoll-wot; `uv build --no-sources` keeps the published pin. +modpoll-wot = { workspace = true } + +[project.urls] +Repository = "https://github.com/top-maker/modpoll" +Documentation = "https://top-maker.github.io/modpoll" + +[tool.deptry] +package_module_name_map = { pyserial = "serial" } + +[tool.deptry.per_rule_ignores] +DEP002 = ["pyserial"] + +[tool.pytest.ini_options] +testpaths = ["tests"] +markers = ["integration: marks tests as integration tests"] + +[project.scripts] +modpoll = "modpoll.main:app" +modpoll-wot = "modpoll_wot.__main__:main" + +[tool.coverage.run] +source = ["modpoll"] + +[tool.coverage.report] +# Measured by the default offline suite (about 84%); raise it as coverage grows. +fail_under = 80 diff --git a/tests/__init__.py b/packages/modpoll/tests/__init__.py similarity index 100% rename from tests/__init__.py rename to packages/modpoll/tests/__init__.py diff --git a/tests/conftest.py b/packages/modpoll/tests/conftest.py similarity index 100% rename from tests/conftest.py rename to packages/modpoll/tests/conftest.py diff --git a/packages/modpoll/tests/fixtures/numeric.tm.json b/packages/modpoll/tests/fixtures/numeric.tm.json new file mode 100644 index 0000000..abb5a70 --- /dev/null +++ b/packages/modpoll/tests/fixtures/numeric.tm.json @@ -0,0 +1,69 @@ +{ + "@context": [ + "https://www.w3.org/2022/wot/td/v1.1", + { + "modpoll": "https://top-maker.github.io/modpoll/vocab/wot-modbus#", + "modv": "https://www.w3.org/2019/wot/modbus", + "xsd": "http://www.w3.org/2001/XMLSchema#" + } + ], + "@type": "tm:ThingModel", + "title": "numeric-pilot", + "modpoll:version": "0.2", + "properties": { + "counter": { + "type": "integer", + "readOnly": true, + "forms": [ + { + "op": "readproperty", + "contentType": "application/octet-stream", + "modv:entity": "HoldingRegister", + "modv:address": 40000, + "modv:quantity": 1, + "modv:type": "xsd:unsignedShort" + } + ] + }, + "signed": { + "type": "integer", + "readOnly": true, + "forms": [ + { + "op": "readproperty", + "contentType": "application/octet-stream", + "modv:entity": "HoldingRegister", + "modv:address": 40002, + "modv:quantity": 1, + "modv:type": "xsd:short" + } + ] + }, + "measurement": { + "type": "number", + "readOnly": true, + "forms": [ + { + "op": "readproperty", + "contentType": "application/octet-stream", + "modv:entity": "HoldingRegister", + "modv:address": 40004, + "modv:quantity": 2, + "modv:type": "xsd:float" + } + ] + } + }, + "modpoll:acquisition": [ + { + "modv:entity": "HoldingRegister", + "modv:address": 40000, + "modv:quantity": 8, + "modpoll:members": [ + "counter", + "signed", + "measurement" + ] + } + ] +} diff --git a/tests/test_bit_point.py b/packages/modpoll/tests/test_bit_point.py similarity index 100% rename from tests/test_bit_point.py rename to packages/modpoll/tests/test_bit_point.py diff --git a/tests/test_cli_errors.py b/packages/modpoll/tests/test_cli_errors.py similarity index 100% rename from tests/test_cli_errors.py rename to packages/modpoll/tests/test_cli_errors.py diff --git a/tests/test_csv_config.py b/packages/modpoll/tests/test_csv_config.py similarity index 100% rename from tests/test_csv_config.py rename to packages/modpoll/tests/test_csv_config.py diff --git a/tests/test_equivalence_tool.py b/packages/modpoll/tests/test_equivalence_tool.py similarity index 100% rename from tests/test_equivalence_tool.py rename to packages/modpoll/tests/test_equivalence_tool.py diff --git a/tests/test_failure_interop.py b/packages/modpoll/tests/test_failure_interop.py similarity index 100% rename from tests/test_failure_interop.py rename to packages/modpoll/tests/test_failure_interop.py diff --git a/tests/test_framer_validation.py b/packages/modpoll/tests/test_framer_validation.py similarity index 100% rename from tests/test_framer_validation.py rename to packages/modpoll/tests/test_framer_validation.py diff --git a/tests/test_local_mqtt_broker.py b/packages/modpoll/tests/test_local_mqtt_broker.py similarity index 100% rename from tests/test_local_mqtt_broker.py rename to packages/modpoll/tests/test_local_mqtt_broker.py diff --git a/tests/test_login.py b/packages/modpoll/tests/test_login.py similarity index 100% rename from tests/test_login.py rename to packages/modpoll/tests/test_login.py diff --git a/tests/test_m3_compatibility.py b/packages/modpoll/tests/test_m3_compatibility.py similarity index 100% rename from tests/test_m3_compatibility.py rename to packages/modpoll/tests/test_m3_compatibility.py diff --git a/tests/test_main.py b/packages/modpoll/tests/test_main.py similarity index 100% rename from tests/test_main.py rename to packages/modpoll/tests/test_main.py diff --git a/tests/test_modbus_task.py b/packages/modpoll/tests/test_modbus_task.py similarity index 100% rename from tests/test_modbus_task.py rename to packages/modpoll/tests/test_modbus_task.py diff --git a/tests/test_modsim_interop.py b/packages/modpoll/tests/test_modsim_interop.py similarity index 100% rename from tests/test_modsim_interop.py rename to packages/modpoll/tests/test_modsim_interop.py diff --git a/tests/test_mqtt_modsim_interop.py b/packages/modpoll/tests/test_mqtt_modsim_interop.py similarity index 98% rename from tests/test_mqtt_modsim_interop.py rename to packages/modpoll/tests/test_mqtt_modsim_interop.py index c215a94..f61a389 100644 --- a/tests/test_mqtt_modsim_interop.py +++ b/packages/modpoll/tests/test_mqtt_modsim_interop.py @@ -188,7 +188,8 @@ def test_csv_tm_td_mqtt_equivalence_and_local_write_commands( ) output = tmp_path / (label + ".json") command = [ - str(source / ".venv/bin/python"), + # 2.x runs in the test interpreter: the workspace environment is at the repository root. + sys.executable if source == ROOT else str(source / ".venv/bin/python"), "-m", "modpoll", "--daemon", diff --git a/tests/test_mqtt_task.py b/packages/modpoll/tests/test_mqtt_task.py similarity index 100% rename from tests/test_mqtt_task.py rename to packages/modpoll/tests/test_mqtt_task.py diff --git a/tests/test_mqtt_tls.py b/packages/modpoll/tests/test_mqtt_tls.py similarity index 100% rename from tests/test_mqtt_tls.py rename to packages/modpoll/tests/test_mqtt_tls.py diff --git a/tests/test_mqtt_write_command.py b/packages/modpoll/tests/test_mqtt_write_command.py similarity index 100% rename from tests/test_mqtt_write_command.py rename to packages/modpoll/tests/test_mqtt_write_command.py diff --git a/tests/test_poll_cycle.py b/packages/modpoll/tests/test_poll_cycle.py similarity index 100% rename from tests/test_poll_cycle.py rename to packages/modpoll/tests/test_poll_cycle.py diff --git a/tests/test_portable_wheel.py b/packages/modpoll/tests/test_portable_wheel.py similarity index 100% rename from tests/test_portable_wheel.py rename to packages/modpoll/tests/test_portable_wheel.py diff --git a/tests/test_precision.py b/packages/modpoll/tests/test_precision.py similarity index 100% rename from tests/test_precision.py rename to packages/modpoll/tests/test_precision.py diff --git a/tests/test_preview_release.py b/packages/modpoll/tests/test_preview_release.py similarity index 100% rename from tests/test_preview_release.py rename to packages/modpoll/tests/test_preview_release.py diff --git a/tests/test_process_lifecycle.py b/packages/modpoll/tests/test_process_lifecycle.py similarity index 100% rename from tests/test_process_lifecycle.py rename to packages/modpoll/tests/test_process_lifecycle.py diff --git a/tests/test_profile_interop.py b/packages/modpoll/tests/test_profile_interop.py similarity index 100% rename from tests/test_profile_interop.py rename to packages/modpoll/tests/test_profile_interop.py diff --git a/tests/test_publish_outputs.py b/packages/modpoll/tests/test_publish_outputs.py similarity index 100% rename from tests/test_publish_outputs.py rename to packages/modpoll/tests/test_publish_outputs.py diff --git a/tests/test_release_image_tags.py b/packages/modpoll/tests/test_release_image_tags.py similarity index 100% rename from tests/test_release_image_tags.py rename to packages/modpoll/tests/test_release_image_tags.py diff --git a/tests/test_shutdown.py b/packages/modpoll/tests/test_shutdown.py similarity index 100% rename from tests/test_shutdown.py rename to packages/modpoll/tests/test_shutdown.py diff --git a/tests/test_transport_interop.py b/packages/modpoll/tests/test_transport_interop.py similarity index 96% rename from tests/test_transport_interop.py rename to packages/modpoll/tests/test_transport_interop.py index 40d48a3..7f7a6fe 100644 --- a/tests/test_transport_interop.py +++ b/packages/modpoll/tests/test_transport_interop.py @@ -105,9 +105,12 @@ def expected_serial(framer): def run_client(source, config, arguments, output): + # The 2.x client is this checkout, run in the interpreter running the tests: the workspace + # environment lives at the repository root since TOOL-01. A baseline keeps its own venv. + python = sys.executable if source == ROOT else str(source / ".venv/bin/python") result = subprocess.run( [ - str(source / ".venv/bin/python"), + python, "-m", "modpoll", "--once", diff --git a/tests/test_verification.py b/packages/modpoll/tests/test_verification.py similarity index 100% rename from tests/test_verification.py rename to packages/modpoll/tests/test_verification.py diff --git a/tests/test_versioned_docs.py b/packages/modpoll/tests/test_versioned_docs.py similarity index 100% rename from tests/test_versioned_docs.py rename to packages/modpoll/tests/test_versioned_docs.py diff --git a/tests/test_wot_config.py b/packages/modpoll/tests/test_wot_config.py similarity index 100% rename from tests/test_wot_config.py rename to packages/modpoll/tests/test_wot_config.py diff --git a/tests/test_wot_reading_interop.py b/packages/modpoll/tests/test_wot_reading_interop.py similarity index 100% rename from tests/test_wot_reading_interop.py rename to packages/modpoll/tests/test_wot_reading_interop.py diff --git a/tests/test_write_commands.py b/packages/modpoll/tests/test_write_commands.py similarity index 100% rename from tests/test_write_commands.py rename to packages/modpoll/tests/test_write_commands.py diff --git a/tests/test_write_validation.py b/packages/modpoll/tests/test_write_validation.py similarity index 100% rename from tests/test_write_validation.py rename to packages/modpoll/tests/test_write_validation.py diff --git a/tests/wot_helpers.py b/packages/modpoll/tests/wot_helpers.py similarity index 100% rename from tests/wot_helpers.py rename to packages/modpoll/tests/wot_helpers.py diff --git a/tools/verify_modsim_equivalence.py b/packages/modpoll/tools/verify_modsim_equivalence.py similarity index 95% rename from tools/verify_modsim_equivalence.py rename to packages/modpoll/tools/verify_modsim_equivalence.py index 9ad47d7..aa55afe 100644 --- a/tools/verify_modsim_equivalence.py +++ b/packages/modpoll/tools/verify_modsim_equivalence.py @@ -12,6 +12,7 @@ import socketserver import struct import subprocess +import sys import tempfile import threading import time @@ -242,10 +243,13 @@ def main(): raise TimeoutError("modsim did not start") time.sleep(0.05) with tempfile.TemporaryDirectory() as temp: - for label, root, config in ( - ("1.x CSV", old, old / "examples/modsim.csv"), - ("2.x TM", ROOT, ROOT / "examples/modsim.tm.json"), - ("2.x TD", ROOT, ROOT / "examples/modsim.generated.td.json"), + # 2.x runs in the interpreter that runs this tool: the workspace environment, + # which since TOOL-01 lives at the repository root rather than in this package. + current = Path(sys.executable) + for label, root, python, config in ( + ("1.x CSV", old, old / ".venv/bin/python", old / "examples/modsim.csv"), + ("2.x TM", ROOT, current, ROOT / "examples/modsim.tm.json"), + ("2.x TD", ROOT, current, ROOT / "examples/modsim.generated.td.json"), ): with Proxy(("127.0.0.1", 0), Handler) as proxy: proxy.upstream = (host, port) @@ -254,7 +258,7 @@ def main(): worker.start() output = Path(temp) / "values.json" command = [ - str(root / ".venv/bin/python"), + str(python), "-m", "modpoll", "--once", diff --git a/tools/wot-interop/package-lock.json b/packages/modpoll/tools/wot-interop/package-lock.json similarity index 100% rename from tools/wot-interop/package-lock.json rename to packages/modpoll/tools/wot-interop/package-lock.json diff --git a/tools/wot-interop/package.json b/packages/modpoll/tools/wot-interop/package.json similarity index 100% rename from tools/wot-interop/package.json rename to packages/modpoll/tools/wot-interop/package.json diff --git a/tools/wot-interop/read-write.cjs b/packages/modpoll/tools/wot-interop/read-write.cjs similarity index 100% rename from tools/wot-interop/read-write.cjs rename to packages/modpoll/tools/wot-interop/read-write.cjs diff --git a/tox.ini b/packages/modpoll/tox.ini similarity index 100% rename from tox.ini rename to packages/modpoll/tox.ini diff --git a/vocab/wot-modbus/index.html b/packages/modpoll/vocab/wot-modbus/index.html similarity index 100% rename from vocab/wot-modbus/index.html rename to packages/modpoll/vocab/wot-modbus/index.html diff --git a/packages/modsim/.editorconfig b/packages/modsim/.editorconfig new file mode 100644 index 0000000..be2ace7 --- /dev/null +++ b/packages/modsim/.editorconfig @@ -0,0 +1,50 @@ +# EditorConfig is awesome: https://EditorConfig.org + +# top-most EditorConfig file +root = true + +[*] +indent_style = space +indent_size = 2 +charset = utf-8 +end_of_line = lf +trim_trailing_whitespace = true +max_line_length = 80 + +[*.md] +indent_style = space +indent_size = 4 +max_line_length = 0 + +[*.{yml,yaml}] +indent_style = space +indent_size = 2 + +[*.json] +indent_style = space +indent_size = 2 +insert_final_newline = false + +[COMMIT_EDITMSG] +max_line_length = 0 + +[{Makefile, makefile, GNUmakefile, Makefile.*}] +indent_style = tab +indent_size = 4 + +[*.sh] +indent_style = space +indent_size = 4 + +[*.{ps1,psm1,psd1}] +indent_style = space +indent_size = 4 + +# Black/Ruff has its own set of formatting rules and defaults, which will re-format the code after .editorconfig is applied +[*.py] +indent_size = 4 +max_line_length = 88 + +[*.{tf,tfvars,hcl}] +indent_style = space +indent_size = 2 diff --git a/packages/modsim/.gitattributes b/packages/modsim/.gitattributes new file mode 100644 index 0000000..72b2de9 --- /dev/null +++ b/packages/modsim/.gitattributes @@ -0,0 +1,2 @@ +# Preserve original vendor PDFs without text diff or newline conversion. +*.pdf binary diff --git a/packages/modsim/.github/scripts/check-release-version.py b/packages/modsim/.github/scripts/check-release-version.py new file mode 100644 index 0000000..9ce549a --- /dev/null +++ b/packages/modsim/.github/scripts/check-release-version.py @@ -0,0 +1,43 @@ +"""Reject releases when the CLI version differs from the release tag.""" + +import ast +import sys +from pathlib import Path + +from check_release_version import package_version + + +def main(): + tag = sys.argv[1] + expected = tag[1:] if tag.startswith("v") else tag + package = package_version() + if package != expected: + print( + "Project version %s does not match release tag %s" % (package, tag), + file=sys.stderr, + ) + return 1 + module = ast.parse(Path("modsim/__init__.py").read_text(encoding="utf-8")) + versions = [ + node.value.value + for node in module.body + if isinstance(node, ast.Assign) + and any( + isinstance(target, ast.Name) and target.id == "__version__" + for target in node.targets + ) + and isinstance(node.value, ast.Constant) + and isinstance(node.value.value, str) + ] + if versions != [expected]: + print( + "modsim CLI version does not match release tag %s (found %s)" + % (tag, versions), + file=sys.stderr, + ) + return 1 + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/packages/modsim/.github/scripts/check_release_version.py b/packages/modsim/.github/scripts/check_release_version.py new file mode 100644 index 0000000..fc5cd31 --- /dev/null +++ b/packages/modsim/.github/scripts/check_release_version.py @@ -0,0 +1,34 @@ +"""Reject a release if its tag and checked-out package metadata differ.""" + +import sys +from pathlib import Path + +try: + import tomllib +except ModuleNotFoundError: + import tomli as tomllib + + +def package_version(): + metadata = tomllib.loads(Path("pyproject.toml").read_text(encoding="utf-8")) + try: + return metadata["project"]["version"] + except KeyError as exc: + raise ValueError("project version is missing from pyproject.toml") from exc + + +def main(): + tag = sys.argv[1] + expected = tag[1:] if tag.startswith("v") else tag + actual = package_version() + if actual != expected: + print( + "Project version %s does not match release tag %s" % (actual, tag), + file=sys.stderr, + ) + return 1 + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/packages/modsim/.github/scripts/preview-release.py b/packages/modsim/.github/scripts/preview-release.py new file mode 100644 index 0000000..8f5c9bc --- /dev/null +++ b/packages/modsim/.github/scripts/preview-release.py @@ -0,0 +1,189 @@ +"""Modsim preview guards and immutable registry verification (standard library).""" + +import hashlib +import json +import os +from pathlib import Path +import re +import subprocess +import sys +import time +import urllib.error +import urllib.request + + +def metadata(version): + url = f"https://pypi.org/pypi/modsim/{version}/json?release_check={time.time_ns()}" + try: + with urllib.request.urlopen(url, timeout=30) as response: + return json.load(response) + except urllib.error.HTTPError as exc: + if exc.code == 404: + return None + raise + + +def guard(tag): + if not re.fullmatch(r"v2\.\d+\.\d+(?:a|b|rc)\d+", tag): + raise ValueError("expected a unique v2 prerelease tag") + subprocess.run( + [sys.executable, ".github/scripts/check_release_version.py", tag], check=True + ) + actual = re.search( + r'__version__ = "([^"]+)"', Path("modsim/__init__.py").read_text() + ).group(1) + if actual != tag[1:]: + raise ValueError("module version differs from release tag") + sha = subprocess.check_output(["git", "rev-parse", "HEAD"], text=True).strip() + subprocess.run(["git", "merge-base", "--is-ancestor", sha, "origin/v2"], check=True) + repo = os.environ["GITHUB_REPOSITORY"] + # Workflows live at the repository root since TOOL-01; job names carry the package so + # they never share a check name with modpoll's. + require_ci( + repo, + sha, + "modsim.yml", + { + "modsim quality", + "modsim docs", + "modsim tox (3.10)", + "modsim tox (3.14)", + "modpoll snapshot replay", + }, + ) + require_ci( + repo, + sha, + "modsim-acceptance.yml", + {"catalog-interop"} + | { + f"single-device ({platform})" + for platform in ("ubuntu-latest", "macos-latest", "windows-latest") + }, + ) + print(f"Accepted {sha}: main and catalog/platform CI passed") + + +def require_ci(repo, sha, workflow, expected): + listing = json.loads( + subprocess.check_output( + [ + "gh", + "api", + f"repos/{repo}/actions/workflows/{workflow}/runs?head_sha={sha}&event=push&per_page=100", + ], + text=True, + ) + ) + runs = [run for run in listing["workflow_runs"] if run["head_branch"] == "v2"] + if ( + not runs + or runs[0]["status"] != "completed" + or runs[0]["conclusion"] != "success" + ): + raise ValueError(f"exact release SHA requires successful v2 CI: {workflow}") + jobs = json.loads( + subprocess.check_output( + [ + "gh", + "api", + f"repos/{repo}/actions/runs/{runs[0]['id']}/jobs?per_page=100", + ], + text=True, + ) + )["jobs"] + if {job["name"] for job in jobs} != expected or any( + job["conclusion"] != "success" for job in jobs + ): + raise ValueError(f"release requires all expected CI jobs: {workflow}") + + +def immutable(version): + data = metadata(version) + if data is None: + result = "false" + else: + published = { + item["filename"]: item["digests"]["sha256"] for item in data["urls"] + } + local = { + p.name: hashlib.sha256(p.read_bytes()).hexdigest() + for p in Path("dist").iterdir() + if p.is_file() and (p.name.endswith(".whl") or p.name.endswith(".tar.gz")) + } + if local != published: + raise ValueError( + "immutable PyPI version already exists with different bytes; recover original artifacts" + ) + result = "true" + with open(os.environ["GITHUB_OUTPUT"], "a") as output: + output.write(f"exists={result}\n") + + +def _wait_for_pypi(fetch, label, deadline): + """Wait for a newly published resource, without masking other failures.""" + attempts = 0 + while True: + attempts += 1 + try: + value = fetch() + except urllib.error.HTTPError as exc: + if exc.code != 404: + raise + value = None + if value is not None: + return value + remaining = deadline - time.monotonic() + if remaining <= 0: + raise TimeoutError( + f"PyPI {label} still unavailable after {attempts} attempts" + ) + delay = min(20, remaining) + print( + f"PyPI {label} not yet available (attempt {attempts}); retrying in {delay:.0f}s", + file=sys.stderr, + flush=True, + ) + time.sleep(delay) + + +def download(version, directory): + # Retry delayed metadata and wheel visibility after publication. + deadline = time.monotonic() + 600 + + def find_wheel(): + data = metadata(version) + if data is None: + return None + wheels = [item for item in data["urls"] if item["filename"].endswith(".whl")] + if len(wheels) > 1: + raise ValueError("expected exactly one published wheel") + return wheels[0] if wheels else None + + item = _wait_for_pypi(find_wheel, "wheel metadata", deadline) + + def fetch_wheel(): + separator = "&" if "?" in item["url"] else "?" + url = f"{item['url']}{separator}release_check={time.time_ns()}" + with urllib.request.urlopen(url, timeout=30) as response: + return response.read() + + payload = _wait_for_pypi(fetch_wheel, "wheel file", deadline) + if hashlib.sha256(payload).hexdigest() != item["digests"]["sha256"]: + raise ValueError("published wheel SHA256 mismatch") + destination = Path(directory) + destination.mkdir(parents=True, exist_ok=True) + (destination / item["filename"]).write_bytes(payload) + print(item["filename"], item["digests"]["sha256"]) + + +if __name__ == "__main__": + command, version = sys.argv[1:3] + if command == "guard": + guard(version) + elif command == "immutable": + immutable(version) + elif command == "download": + download(version, sys.argv[3]) + else: + raise ValueError("unknown command") diff --git a/packages/modsim/.github/scripts/release_image_tags.py b/packages/modsim/.github/scripts/release_image_tags.py new file mode 100644 index 0000000..bc847dc --- /dev/null +++ b/packages/modsim/.github/scripts/release_image_tags.py @@ -0,0 +1,82 @@ +"""Choose Docker tags without allowing an older release to replace newer aliases.""" + +import json +import os +import re +import sys +import urllib.request + +VERSION = re.compile(r"^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$") + + +def parse_version(tag): + match = VERSION.fullmatch(tag) + return tuple(map(int, match.groups())) if match else None + + +def select_tags(tag, releases): + version = parse_version(tag) + if version is None: + raise ValueError("release tag must be a stable semantic version") + versions = [] + for release in releases: + if release.get("draft") or release.get("prerelease"): + continue + candidate = parse_version(release.get("tag_name", "")) + if candidate is not None: + versions.append(candidate) + if version not in versions: + raise ValueError("release tag is not a published stable GitHub release") + tags = ["%d.%d.%d" % version] + if version == max(v for v in versions if v[0] == version[0]): + tags.append(str(version[0])) + if version == max(v for v in versions if v[:2] == version[:2]): + tags.append("%d.%d" % version[:2]) + is_latest = version == max(versions) + if is_latest: + tags.append("latest") + return tags, is_latest + + +def fetch_releases(): + api = os.environ["GITHUB_API_URL"].rstrip("/") + repo = os.environ["GITHUB_REPOSITORY"] + token = os.environ["GH_TOKEN"] + releases = [] + for page in range(1, 101): + req = urllib.request.Request( + "%s/repos/%s/releases?per_page=100&page=%d" % (api, repo, page), + headers={ + "Authorization": "Bearer " + token, + "Accept": "application/vnd.github+json", + }, + ) + with urllib.request.urlopen(req, timeout=30) as response: + batch = json.load(response) + if not isinstance(batch, list): + raise ValueError("GitHub releases response is not a list") + releases.extend(batch) + if len(batch) < 100: + return releases + raise ValueError("too many release pages to choose tags safely") + + +def main(): + tags, is_latest = select_tags(os.environ["TAG"], fetch_releases()) + image = "%s/%s/%s" % ( + os.environ["DOCKER_REGISTRY"], + os.environ["DOCKER_USERNAME"], + os.environ["IMAGE_NAME"], + ) + for tag in tags: + print("%s:%s" % (image, tag)) + with open(os.environ["GITHUB_OUTPUT"], "a", encoding="utf-8") as output: + output.write("latest=%s\n" % str(is_latest).lower()) + + +if __name__ == "__main__": + try: + main() + except Exception as exc: + print("Cannot select release image tags: %s" % exc, file=sys.stderr) + sys.exit(1) diff --git a/packages/modsim/.gitignore b/packages/modsim/.gitignore new file mode 100644 index 0000000..0d30124 --- /dev/null +++ b/packages/modsim/.gitignore @@ -0,0 +1,251 @@ +# Created by https://www.toptal.com/developers/gitignore/api/python,dotenv,linux,macos,windows +# Edit at https://www.toptal.com/developers/gitignore?templates=python,dotenv,linux,macos,windows + +### dotenv ### +.env + +# Generated TD exports +/output/ + +### Linux ### +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +### macOS ### +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### macOS Patch ### +# iCloud generated files +*.icloud + +### Python ### +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/#use-with-ide +.pdm.toml + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +#.idea/ + +### Python Patch ### +# ruff +.ruff_cache/ + +# LSP config files +pyrightconfig.json + +### Windows ### +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# End of https://www.toptal.com/developers/gitignore/api/python,dotenv,linux,macos,windows + +# Verified generated public example inputs +/examples/models/ + +# External CI consumer checkout +/.interop/ diff --git a/packages/modsim/.tool-versions b/packages/modsim/.tool-versions new file mode 100644 index 0000000..865d7b6 --- /dev/null +++ b/packages/modsim/.tool-versions @@ -0,0 +1,2 @@ +python 3.12.13 +uv 0.11.19 diff --git a/packages/modsim/CHANGELOG.md b/packages/modsim/CHANGELOG.md new file mode 100644 index 0000000..e6b2e49 --- /dev/null +++ b/packages/modsim/CHANGELOG.md @@ -0,0 +1,75 @@ +# Changelog + +## 2.0.0a1 (2026-10-29) + +- Add profile 0.2 TM/TD configuration from local files and HTTPS URLs. +- Run isolated Unit IDs on one TCP listener using local deployment files. +- Add deterministic scenarios, initialization and explicit local Python behaviors. +- Share complete property codecs across initialization, updates and protocol writes. +- Add community contributions with ADAM models and synthetic behavior examples. +- Preserve legacy unconfigured operation; publish v2 as an explicit preview. + +## [1.0.1](https://github.com/top-maker/modsim/compare/v1.0.0...v1.0.1) (2026-10-28) + + +### Bug Fixes + +* harden simulator transports and release safety ([#12](https://github.com/top-maker/modsim/issues/12)) ([0982f6a](https://github.com/top-maker/modsim/commit/0982f6aa10a8fcd83a7ad8c17cbbfec7a2bc4f9c)) + +## [1.0.0](https://github.com/top-maker/modsim/compare/v0.5.2...v1.0.0) (2026-10-27) + + +### ⚠ BREAKING CHANGES + +* deps ([#11](https://github.com/top-maker/modsim/issues/11)) + +### Features + +* prepare modsim 1.0.0 with graceful shutdown ([#9](https://github.com/top-maker/modsim/issues/9)) ([c2bcd5a](https://github.com/top-maker/modsim/commit/c2bcd5aa0a2788249931086d738b17e4ab29894c)) + + +### Bug Fixes + +* deps ([#11](https://github.com/top-maker/modsim/issues/11)) ([265d54d](https://github.com/top-maker/modsim/commit/265d54d392de65918ca4ba2e2f7fc797652ed8b3)) + +## [0.5.2](https://github.com/top-maker/modsim/compare/v0.5.1...v0.5.2) (2024-12-22) + + +### Bug Fixes + +* Example config issue ([6b47f09](https://github.com/top-maker/modsim/commit/6b47f092b23d4b3a23f1fbf11e15ad20b524e584)) + +## [0.5.1](https://github.com/top-maker/modsim/compare/0.5.0...v0.5.1) (2024-10-10) + + +### Bug Fixes + +* Broken version info ([f70294c](https://github.com/top-maker/modsim/commit/f70294c9250c56ba4da1418a22e89f76ee34cba5)) +* validation pipeline ([f9236bc](https://github.com/top-maker/modsim/commit/f9236bc90bfbbcb4664684979b7174ef8083ebd3)) + +## [0.5.0](https://github.com/top-maker/modsim/compare/v0.4.0...0.5.0) (2024-07-13) + + +### Features + +* add docker related commands in Makefile ([d0fdc7e](https://github.com/top-maker/modsim/commit/d0fdc7e037273398cafb22a470948e736ac7a366)) +* add docs ([0a0c8a5](https://github.com/top-maker/modsim/commit/0a0c8a5298060dd6057e7eef2087287b692b0069)) + + +### Bug Fixes + +* include master branch ([85d758e](https://github.com/top-maker/modsim/commit/85d758e25cc87ac3f0a840d36684d88d0812aef9)) +* remove old CHANGELOG.md ([341520d](https://github.com/top-maker/modsim/commit/341520d114a5390aae3bc8ff46c0a976a7d472ff)) + +## [0.4.0](https://github.com/top-maker/modsim/compare/v0.3.4...v0.4.0) (2024-07-07) + + +### Features + +* add docs ([0a0c8a5](https://github.com/top-maker/modsim/commit/0a0c8a5298060dd6057e7eef2087287b692b0069)) + + +### Bug Fixes + +* include master branch ([85d758e](https://github.com/top-maker/modsim/commit/85d758e25cc87ac3f0a840d36684d88d0812aef9)) +* remove old CHANGELOG.md ([341520d](https://github.com/top-maker/modsim/commit/341520d114a5390aae3bc8ff46c0a976a7d472ff)) diff --git a/packages/modsim/CONTRIBUTING.md b/packages/modsim/CONTRIBUTING.md new file mode 100644 index 0000000..293b626 --- /dev/null +++ b/packages/modsim/CONTRIBUTING.md @@ -0,0 +1,29 @@ +# Contributing to modsim + +Simulator code, runtime and simulation data changes target the affected tool +line (`v2` for model-driven development). Run relevant checks from the root: + +```sh +uv sync --all-groups +make check +make test +uv run python tools/generate-td.py --check +uv run --group docs mkdocs build -s +``` + +Device TMs, metadata, sources and product-specific simulation data belong in +[Open Modbus Catalog](https://github.com/top-maker/open-modbus-catalog), targeting +its `main` through a PR and required catalog CI. Do not add editable device copies +here. A new model submission needs an executable TM and source/permission/known +limits; maintainers can help complete metadata. +Never include private endpoints, credentials or customer data in public inputs. + +The model-source lock and downloader are consumers of immutable public data. +For a data update, pin the full catalog commit, review every file and hash, update examples/model-source.yaml through a PR, run the downloader, then +run affected simulator/client tests. The tests/fixtures tree is a frozen runtime +regression fixture, not a contribution catalog. Generated TD fixtures are +regenerated by tools/generate-td.py, never hand edited. + +CI covers Python 3.10 and 3.14. Local loopback checks do not certify hardware, +physical outputs or engineering-unit accuracy. See docs/release-process.md for +independent tool publishing; a data update does not require an app release. diff --git a/packages/modsim/Dockerfile b/packages/modsim/Dockerfile new file mode 100644 index 0000000..0e16e04 --- /dev/null +++ b/packages/modsim/Dockerfile @@ -0,0 +1,28 @@ +# syntax=docker/dockerfile:1 +# Build from the repository root: docker build -f packages/modsim/Dockerfile . + +FROM python:3.12-slim-bookworm + +COPY --from=ghcr.io/astral-sh/uv:0.11.19 /uv /uvx /bin/ + +# Copy dependency metadata first to cache the install layer. The workspace lock covers every +# member, so each member's metadata is copied for `--locked`; modsim itself runs from /app/modsim. +WORKDIR /app +ENV PATH="/app/.venv/bin:$PATH" +COPY pyproject.toml uv.lock /app/ +COPY packages/modpoll/pyproject.toml /app/packages/modpoll/ +COPY packages/modpoll-wot /app/packages/modpoll-wot +COPY packages/modsim/pyproject.toml packages/modsim/README.md /app/packages/modsim/ + +# Project initialization: +RUN uv sync --locked --no-dev --no-install-project --no-editable --package modsim + +# Copy Python app to the Docker image +COPY packages/modsim/modsim /app/modsim/ +COPY packages/modsim/examples /app/examples +COPY packages/modsim/tests/fixtures/io-module /app/tests/fixtures/io-module +COPY packages/modsim/examples/deployment.yaml /app/deployment.yaml +COPY packages/modsim/tools/fetch-models.py /app/tools/fetch-models.py +RUN .venv/bin/python tools/fetch-models.py + +CMD [ "python", "-m", "modsim" ] diff --git a/packages/modsim/LICENSE b/packages/modsim/LICENSE new file mode 100644 index 0000000..f1a3303 --- /dev/null +++ b/packages/modsim/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2021-2024, Ying Shaodong + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/modsim/Makefile b/packages/modsim/Makefile new file mode 100644 index 0000000..1e5daf4 --- /dev/null +++ b/packages/modsim/Makefile @@ -0,0 +1,71 @@ +PROJECT_NAME ?= modsim + +.PHONY: install +install: ## Install the uv environment and install the pre-commit hooks + @echo "🚀 Installing the project and pre-commit hooks" + @uv sync --all-groups + @cd ../.. && uv run --no-sync pre-commit install --allow-missing-config + +.PHONY: check +check: ## Run code quality tools. + @echo "🚀 Checking uv lock file consistency with 'pyproject.toml': Running uv lock --check" + @uv lock --check + @echo "🚀 Linting code: Running pre-commit" + @# One pre-commit configuration serves the workspace; check this package's files only. + @git ls-files -z . | xargs -0 uv run pre-commit run --config ../../.pre-commit-config.yaml --files + @echo "🚀 Static type checking: Running mypy" + @uv run mypy + @echo "🚀 Checking for obsolete dependencies: Running deptry" + @uv run deptry . + +.PHONY: test +test: ## Test the code with pytest + @echo "🚀 Testing code: Running pytest" + @uv run pytest --doctest-modules + +.PHONY: build +build: clean-build ## Build wheel file using uv + @echo "🚀 Creating wheel file" + @uv build + +.PHONY: clean-build +clean-build: ## clean build artifacts + @rm -rf dist + +.PHONY: publish +publish: ## Publish a release to PyPI. + @echo "🚀 Publishing: Dry run." + @if uv publish --dry-run --token ${PYPI_TOKEN}; then \ + echo "Dry run successful. Proceeding with publishing..."; \ + uv publish --token ${PYPI_TOKEN}; \ + else \ + echo "Dry run failed. Version might already exist or other error occurred."; \ + exit 1; \ + fi + +.PHONY: build-and-publish +build-and-publish: build publish ## Build and publish. + +.PHONY: docker-build-dev +docker-build-dev: ## Build docker for local dev + @echo "🚀 Creating docker image file" + @docker build -f Dockerfile -t ${PROJECT_NAME}:dev ../.. + +.PHONY: docker-run-dev +docker-run-dev: docker-build-dev ## Run docker for local dev + @echo "🚀 Docker run: ${PROJECT_NAME}:dev" + @docker run --rm ${PROJECT_NAME}:dev + +.PHONY: docs-test +docs-test: ## Test if documentation can be built without warnings or errors + @uv run --group docs mkdocs build -s + +.PHONY: docs +docs: ## Build and serve the documentation + @uv run --group docs mkdocs serve + +.PHONY: help +help: + @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' + +.DEFAULT_GOAL := help diff --git a/packages/modsim/README.md b/packages/modsim/README.md new file mode 100644 index 0000000..b06775f --- /dev/null +++ b/packages/modsim/README.md @@ -0,0 +1,271 @@ +# modsim + +modsim is a standalone Modbus simulator for device integration and testing. +The v2 development source reads WoT Thing Models (TM), instantiates device +descriptions (TD), and runs independent simulated devices on one Modbus TCP +listener. Models, simulation data, the simulator and the client remain separate. + +This README describes the **v2 development branch**. The published `2.0.0a1` +preview predates the managed deployment commands shown below; do not assume an +existing `latest` image or installed package contains the current source. +Stable and preview releases are independent. See [preview notes](docs/preview-notes.md) +and [release process](docs/release-process.md). + +## Install from source + +The v2 managed deployment commands are available in the development source; +they are not included in the published `2.0.0a1` release. Clone the `v2` +branch and install its dependencies with uv: + +```bash +git clone --branch v2 https://github.com/top-maker/modsim.git +cd modsim +uv sync --all-groups +``` + +## Run locally + +From the root directory, start the example deployment and check its status: + +```bash +uv run modsim up -d +uv run modsim ps +``` + +The commands use `examples/deployment.yaml` by default. The example starts two +virtual ADAM devices: Unit 1 exposes ADAM-5017UH raw inputs; Unit 2 exposes +ADAM-6024 raw I/O with synthetic AO→AI and DO→DI loopback. These are simulation +values, not verified physical measurements. The ADAM-5017UH model and simulation data +come from [Open Modbus Catalog](https://github.com/top-maker/open-modbus-catalog); +the ADAM-6024 model is a frozen regression fixture in `tests/fixtures/io-module/`. + +The deployment binds to all interfaces by default; set `server.bind` to +`127.0.0.1` in `examples/deployment.yaml` to restrict a direct local run. + +Useful commands for managing the deployment: + +```bash +uv run modsim logs -f +uv run modsim up --dry-run +uv run modsim reset --device adam-5017uh +uv run modsim export +uv run modsim down +``` + +Export writes all TDs to `output/` in the root directory by default; this +directory is ignored by Git. Use `-o FILE` for one TD or `--output-dir DIR` to +choose another directory. + +Use `-f FILE` to select another deployment. In `logs`, `-f` follows output; +use `--file FILE` to select the deployment. `up` runs in the foreground by +default; `-d` runs it in the background. Ctrl+C stops a service started by a +foreground `up`, but only detaches from an existing deployment or `logs -f`. +Background services do not restart after a machine reboot unless managed by a +process manager. Managed commands require POSIX (Linux/macOS/WSL); see +[managed deployments](docs/site/managed-deployments.md). + +`modsim export` reads the current deployment file and does not require a +running simulator. Use `--running` only when you need the last successfully +applied configuration instead of current file contents. That option connects to +the managed runtime in the same project environment; for Docker Compose, run it +inside the container. + +## Run with Docker Compose + +From the `examples/` directory, build and start the current source: + +```bash +docker compose up -d --build +docker compose logs -f +``` + +Compose publishes Modbus TCP only on host `127.0.0.1:5020` and restarts the +container unless stopped. Each restart resets simulation state. TDs advertise +`127.0.0.1` by default; configure the advertised host and port mapping when +clients connect from another machine. + +The deployment, model and simulation data files are mounted from the repository. +`docker compose up -d` starts the configured deployment; do not run `modsim up` +again just to start it. After editing the mounted deployment file, apply the +updated configuration to the running simulator with: + +```bash +docker compose exec modsim python -m modsim up -f /app/deployment.yaml -d +``` + +Use the mounted path Compose started (`/app/deployment.yaml`); the control +socket rejects any other path. An unchanged device keeps its state; a changed device is replaced. Listener +changes require a container restart. If you replace the deployment file itself, +run `docker compose up -d --force-recreate` to refresh its bind mount. Export +all running TDs directly into the host's `examples/td/` directory. The Compose +file maps the default output directory to that host directory. Run this from +the `examples/` directory: + +```bash +docker compose exec modsim python -m modsim export --running +``` + +This creates one `*.td.json` file per device in `examples/td/`. + +Stop the Compose deployment with `docker compose down`. + +## Example: test modpoll against modsim + +This example uses modpoll v2 (`modpoll==2.0.0a2`) and the local modsim source. +Export all TDs from the current deployment file. Run from the root directory; +modsim does not need to be running: + +```bash +uv run modsim export +``` + +In another terminal, from the root directory, read the exported TD: + +```bash +modpoll --once --interval 0 --tcp 127.0.0.1 --tcp-port 5020 \ + --config ./output/adam-6024.td.json --export ./adam-6024-snapshot.json +``` + +If you need the last applied configuration from a Docker Compose deployment, +use the Compose export command above and point modpoll to +`./examples/td/adam-6024.td.json` instead. + +The TD selects Unit ID 2. On a fresh deployment, `adam6024_raw` reports +`AO0_RAW: 100` and `AI0_RAW: 100`; values may differ if previously written. +The command reads the exported TD and connects to modsim on the host port. + +### Optional: write via MQTT + +Start a temporary local broker and a continuously running modpoll process: + +```bash +docker run --rm -d --name modpoll-demo-mqtt -p 127.0.0.1:1883:1883 \ + eclipse-mosquitto:2 mosquitto -c /mosquitto-no-auth.conf +modpoll --interval 0 --rate 1 --tcp 127.0.0.1 --tcp-port 5020 \ + --config ./adam-6024.td.json --mqtt-host 127.0.0.1 --mqtt-port 1883 +``` + +After modpoll connects, publish a non-retained write to the topic named for +the TD's `title` (`adam6024_raw`): + +```bash +docker exec modpoll-demo-mqtt mosquitto_pub -h 127.0.0.1 \ + -t modpoll/adam6024_raw/set \ + -m '{"object_type":"holding_register","address":10,"value":432}' +``` + +Run the one-shot modpoll command again. `AO0_RAW` and loopback `AI0_RAW` +should both read `432`. This synthetic raw value does not verify the physical +device's range or behavior. The example broker has no authentication and is +published only on host loopback; port 1883 must be available. + +Stop modpoll with Ctrl+C, stop the broker if used (`docker stop +modpoll-demo-mqtt`), then stop modsim with `uv run modsim down` or stop the +Compose deployment with `docker compose down`. + +## Models and simulation data + +A deployment has a stable ID per device, a TM path, instance parameters and +optional simulation data. TD IDs and Modbus Unit IDs must be unique. +[Simulation data](https://github.com/top-maker/modpoll-wot/blob/main/profile.md#simulation-data) +gives static initial values, seeded generators and bindings, and carries no +code; a local Python behavior is a separate `script` that requires +`--allow-scripts`. Neither duplicates the Thing Model's point mappings. See +[model configuration](docs/site/model-validation.md) for the supported profile, +codecs, constraints and behavior hooks. + +For a single device without a managed deployment: + +```bash +uv run python tools/fetch-models.py +uv run modsim --config examples/models/products/advantech/adam-5017uh/model.tm.json \ + --unit-id 1 --port 5020 \ + --data examples/models/products/advantech/adam-5017uh/model.sim.json +``` + +A modpoll `--export` snapshot is simulation data too, so a device read once can +be replayed locally. Snapshots hold readings of a real device; keep them on +your computer: + +```bash +modpoll --config device.tm.json --tcp 192.168.1.10 --once --export snapshot.json +uv run modsim --config device.tm.json --port 5020 --data snapshot.json +``` + +Without `--port`, modsim listens on 5020 so the first command needs no +administrator rights; read it with `modpoll --tcp 127.0.0.1 --tcp-port 5020`. +Linux, and macOS when binding to `127.0.0.1`, reserve ports below 1024 for +administrators: to listen on the standard port 502, run the command with sudo +(with uvx, `sudo "$(command -v uvx)" modsim --port 502 ...`). modsim prints the +same hint when a port is refused. Windows does not reserve these ports. + +### Modbus RTU + +`--serial pty` simulates a Modbus RTU device without hardware (Linux and macOS). +modsim creates a virtual serial cable, prints the port for the client and the +matching modpoll command, and removes it on exit: + +```bash +modsim --config device.tm.json --serial pty +# Virtual serial port for the client: /dev/pts/7 +# Read it with: modpoll --config device.tm.json --serial /dev/pts/7 --serial-baud 9600 +``` + +Virtual ports ignore baud rate and parity, so `--serial-baud` and `--serial-parity` +only shape the printed command. `--serial-link PATH` adds a fixed symbolic link to +the client port. Pass a port name instead of `pty` to listen on an existing serial +port with those settings. Windows has no pseudo-terminals: create a virtual serial +pair with a driver such as com0com, listen on one port with `--serial COM5` and +connect the client to the other. `--serial` and `--port` are mutually exclusive. + +The single-device model runtime currently supports TCP and Modbus RTU. The unconfigured demo +also supports TCP, UDP, TLS, RTU and ASCII; its datastore is shared by all Unit +IDs. TLS loads `certificates/pymodbus.crt` and `certificates/pymodbus.key` from +the working directory. See [transport details](docs/site/index.md#unconfigured-demo). + +The checked-in ADAM-6024 TD and its source hash can be checked with +`uv run python tools/generate-td.py --check`; omit `--check` to regenerate. + +### Models in your ModioHub Workspace + +`modsim login` signs in to ModioHub with your browser: it prints a code and an address (and opens the address +where a browser can open), you confirm the code there, and the 7-day tool session is kept in a file only you +can read (`~/.config/modiohub/credentials.json`, or `%APPDATA%\modiohub` on Windows). modpoll uses the same +file, so signing in with either tool signs in both. `MODIOHUB_TOKEN` replaces the file for scripts, +`MODIOHUB_URL` selects another server, and `login` and `logout` take `--server URL` for the same. `modsim logout` forgets the login on this computer. + +Then `--config modiohub:<id>@<version>` (the version is a number or `latest`) simulates one of your custom +Thing Models, or a shared one without signing in; the download is checked against the SHA-256 the server states. +Deployment manifests do not take `modiohub:` models, so a hosted deployment never carries your login. + +```sh +modsim --config modiohub:k3x9f2m7q4a8n5bd@latest --port 5020 +``` + +## Development + +See [CONTRIBUTING.md](CONTRIBUTING.md) for the v2 workflow and checks. The +repository keeps v1 and v2 release lines separate; no release is implied by a +source change. + +## Pinned public model inputs + +Device models and optional simulation data are maintained in +[Open Modbus Catalog](https://github.com/top-maker/open-modbus-catalog). +`examples/model-source.yaml` pins a full catalog commit and individual SHA-256 +hashes. Prepare examples with +`uv run python tools/fetch-models.py`; this downloads verified local inputs to +ignored `examples/models/`, never executes downloaded Python, and does not copy +an interpreter. Re-run after updating the lock through a reviewed PR. +The application keeps its independent modpoll-wot dependency. + +Single-device mode can read a fixed HTTPS TM URL and simulation data directly; +scripts stay local and require explicit `--allow-scripts`. Managed deployments +use Unix sockets and require POSIX; native Windows should use single-device +foreground mode or WSL. Independent-wheel CI verifies single-device remote-TM +startup, raw reads and process shutdown on Linux, macOS and native Windows. +It does not certify managed commands on Windows or every OS/Python combination. + +The pinned preparation also includes the scoped L2 product record and its data-owned +schema, so its input hashes and limits can be inspected alongside the local models. +These are verification metadata, not executable simulator instructions. diff --git a/packages/modsim/contrib/README.md b/packages/modsim/contrib/README.md new file mode 100644 index 0000000..a328dc9 --- /dev/null +++ b/packages/modsim/contrib/README.md @@ -0,0 +1,8 @@ +# Device data moved + +Device models are maintained in +[Open Modbus Catalog](https://github.com/top-maker/open-modbus-catalog). +Use its contribution guide and target main. This directory no longer accepts +model edits. Historical commits and published releases are unchanged. + +Prepare current examples using tools/fetch-models.py and examples/model-source.yaml. diff --git a/packages/modsim/docs/preview-notes.md b/packages/modsim/docs/preview-notes.md new file mode 100644 index 0000000..0e8284a --- /dev/null +++ b/packages/modsim/docs/preview-notes.md @@ -0,0 +1,137 @@ +# Modsim 2.0.0a12 preview + +Modsim 2.0.0a12 keeps modpoll-wot 0.6.0a2 and changes how a simulator is reached: + +- **Port 5020 by default.** Without `--port`, modsim now listens on 5020 for TCP, UDP and TLS, so the first + command needs no administrator rights on Linux and macOS. Read it with + `modpoll --tcp 127.0.0.1 --tcp-port 5020` (modpoll 2.0.0a10). `--port 502` still selects the standard port. +- **Modbus RTU without hardware.** `modsim --config device.tm.json --serial pty` creates a virtual serial + port on Linux and macOS, prints it together with the matching `modpoll --serial ...` command, and removes + it on exit. `--serial-link PATH` adds a fixed symbolic link; `--serial PORT` listens on an existing port + (on Windows, one port of a virtual pair made with a driver such as com0com). Virtual ports ignore baud + rate and parity. pyserial is now installed with modsim. + +## Modsim 2.0.0a11 preview + +Modsim 2.0.0a11 pins modpoll-wot 0.6.0a2 and resolves the ModioHub server from the only stored login. + +## Modsim 2.0.0a10 preview + +Modsim 2.0.0a10 keeps modpoll-wot 0.5.0a1. `modsim login` prints the sign-in link and opens a browser only +where one can be opened; the opener's output no longer fills the terminal, and Ctrl-C cancels with one line. +The login is shared with modpoll 2.0.0a8. + +## Modsim 2.0.0a9 preview + +Modsim 2.0.0a9 pins modpoll-wot 0.5.0a1 and connects to ModioHub: + +- `modsim login` signs in with your browser and `modsim logout` forgets the login. The 7-day tool session is + kept in `~/.config/modiohub/credentials.json` and is shared with modpoll 2.0.0a7. +- `--config modiohub:<id>@<version>` simulates a custom Thing Model from your ModioHub Workspace (a shared one + needs no login). Deployment manifests do not accept it. +- It also carries the SIM-06 fixes: only writable points are held after a client write, management requests + and device builds no longer block the event loop, and `script:` paths stay inside the deployment directory. + +## Modsim 2.0.0a8 preview + +Modsim 2.0.0a8 loads [simulation data](https://github.com/top-maker/modpoll-wot/blob/main/profile.md#simulation-data) +with `--data` and pins modpoll-wot 0.4.0a1. This preview breaks the previous +command line: + +- `--scenario` becomes `--data`; deployment devices use `data:` instead of + `scenario:`. +- `--initial-file` is removed: put the values in a data document's `initial`. +- Simulation data carries no code. Behavior scripts move out of the data file + to `--script` (with `--allow-scripts`) or a deployment device's `script:`, + and their values to the device's `scriptParameters:`. +- A modpoll `--export` snapshot is simulation data, so a device read once can + be replayed on this computer: + +```sh +uvx --prerelease allow modpoll==2.0.0a6 --config device.tm.json --tcp 192.168.1.10 --once --export snapshot.json +uvx --prerelease allow modsim==2.0.0a8 --config device.tm.json --data snapshot.json +``` + +Scaled values that modpoll exports, such as `230.10000000000002` for a raw +2301 with multiplier 0.1, are served again unchanged. Snapshot points modpoll +could not read keep their defaults and are listed at startup. Snapshots hold +readings of a real device: keep them on your computer. + +The `v2.0.0a7` tag points at the same changes but was never published: its +release guard did not yet expect the new snapshot replay CI job. + +### Previous preview + +#### Modsim 2.0.0a6 + +Modsim 2.0.0a6 pins modpoll-wot 0.3.0a3, the same interpreter as modpoll +2.0.0a5. Thing Models no longer carry a `modpoll:audit` plan: a TM that still +declares one is rejected as an unsupported root project extension, so modsim +and modpoll accept the same models. Delete the key to migrate. Simulation, +ports and remote loading are unchanged from 2.0.0a5: + +```sh +uvx --prerelease allow modsim==2.0.0a6 --config https://example.org/device.tm.json +``` + +#### Modsim 2.0.0a5 + +Without `--port`, modsim now listens on the standard Modbus port: 502 for TCP +and UDP, 802 for Modbus/TLS. A simulator started from a ModioHub Thing Model is +then read with `modpoll --tcp 127.0.0.1`, without `--tcp-port`: + +```sh +uvx --prerelease allow modsim==2.0.0a5 --config https://example.org/device.tm.json +``` + +Linux, and macOS when binding to `127.0.0.1`, reserve ports below 1024 for +administrators. modsim then exits before starting and explains how to rerun it +with sudo (`sudo "$(command -v uvx)" modsim ...`) or choose a port above 1023, +for example `--port 5020`. Managed deployments keep their explicit server port. +This preview still pins modpoll-wot 0.2.0a4. + +#### Modsim 2.0.0a4 + +Remote models and scenarios load directly from a site such as ModioHub: + +```sh +uvx --prerelease allow modsim==2.0.0a4 --config https://example.org/device.tm.json \ + --scenario https://example.org/device.sim.json --bind 127.0.0.1 --port 5020 +``` + +HTTPS requests identify themselves as `modsim/<version>`, because some CDNs reject +the default Python agent. `--scenario` accepts an HTTPS URL; a remote scenario +cannot name a behavior script. This preview still pins modpoll-wot 0.2.0a4. + + +#### Modsim 2.0.0a3 + + +This preview pins modpoll-wot 0.2.0a4. A local TCP simulator can load a full +profile 0.2 TM with an audit plan or its independently derived public audit TM. +Tests seed the same known values and verify the public model exposes only the +selected read spans. + +#### Modsim 2.0.0a2 + +This candidate uses published modpoll-wot 0.2.0a2 and immutable modbus-models-v1 +inputs. Device mappings and contribution workflows moved to a data repository, +now [Open Modbus Catalog](https://github.com/top-maker/open-modbus-catalog); +examples pin a full data commit and individual content hashes. Vendor originals +are not copied. The tool and data releases remain independent. + +Managed deployment version 2 supports local lifecycle and isolation on POSIX. +Single-device foreground mode supports fixed HTTPS TMs and local scenarios; +scripts require explicit --allow-scripts. Catalog acceptance compares raw Modbus +bytes, public modpoll 2.0.0a2 and node-wot 0.9.2 with asymmetric uint16 inputs, +and detects a deliberately wrong byte order. This is software evidence, not +hardware or engineering-unit certification. + +Release gates cover independent wheel single-device startup/read/stop on Linux, +macOS and Windows. Managed deployments remain POSIX-only; Windows uses foreground +mode or WSL. A candidate is not accepted until its exact CI and preview publish, +image, docs and source-independent acceptance jobs all pass. + +Expected install after publication: `uv tool install --prerelease allow modsim==2.0.0a2`. +The explicit preview image is `topmaker/modsim:2.0.0a2`; stable latest aliases stay +unchanged. Older 2.0.0a1 artifacts and historical contrib URLs remain immutable. diff --git a/packages/modsim/docs/release-process.md b/packages/modsim/docs/release-process.md new file mode 100644 index 0000000..9e07c02 --- /dev/null +++ b/packages/modsim/docs/release-process.md @@ -0,0 +1,45 @@ +# Preview release process + +Stable release-please stays on main. A v2 prerelease uses a unique PEP 440 version +and `v2.*` tag from v2, with matching pyproject and module versions. Push the +candidate first and wait for all four main CI jobs (quality, docs, Python 3.10 and 3.14). The preview guard requires successful CI on that exact SHA and v2 +ancestry before publishing. Catalog/platform acceptance must also pass on that +exact v2 SHA: independent installed-wheel Linux/macOS/Windows single-device +checks and the catalog-interop job. + +`preview.yml` checks out the tag, saves original wheel/sdist artifacts, verifies +installation and immutable registry hashes, publishes PyPI and a GitHub prerelease, +then the explicit version Docker image and documentation under `/v2/`. Stable +Docker and GitHub latest are not advanced. The preview Pages deployment preserves +the stable documentation; stable-line Pages maintenance should retain `/v2/`. + +Acceptance installs the published wheel with SHA verification, runs model/runtime +protocol tests without application source, and checks the published container's +two-device deployment. Do not mark a release accepted until all jobs pass. Record +SHA/tag, run URL, registry hashes and acceptance results in the project log. +Never replace tags or PyPI versions. If a later job fails, retry that failed job; +if publication itself needs recovery, reuse the original saved distributions. + +Registry acceptance waits up to ten minutes in total for version metadata and +the wheel, retrying HTTP 404 and missing wheel metadata with changing query +strings, which do not guarantee a cache bypass. Other HTTP errors and hash +mismatches fail immediately. If the wait times +out, keep the original artifacts for recovery; do not replace a tag or version. + +To repeat acceptance for an existing immutable tag after fixing validation tools, +run the preview workflow manually on v2 with its `tag` input. This skips all +publishing jobs, installs the existing PyPI wheel, uses fixtures from that exact +tag and runs the current acceptance tooling. It does not replace packages or +images. Record the separate validation run and tooling SHA. + +### Known-value checks + +Use the approved TM as the configuration for a local TCP simulator. Seed known +values with `--initial PROPERTY=JSON` or `--data` with an `initial` object, then read them with +a full modpoll read. Thing Models no longer carry a `modpoll:audit` plan; a +full read covers every property in `modpoll:acquisition`. + +Stop a foreground simulator with Ctrl-C. Restart with the same TM and initial +values to restore the original vector. A managed deployment can use +`modsim down -f deployment.yaml` and `modsim up -f deployment.yaml` on POSIX. +These checks verify software interoperability with the selected fixture. diff --git a/packages/modsim/docs/site/index.md b/packages/modsim/docs/site/index.md new file mode 100644 index 0000000..5954fe6 --- /dev/null +++ b/packages/modsim/docs/site/index.md @@ -0,0 +1,37 @@ +# modsim v2 development source + +modsim runs simulated Modbus devices for development and integration testing. +The current source supports profile 0.2 TM/TD input, simulation data and independent +devices on a single managed Modbus TCP listener. The published `2.0.0a1` +preview does not include all current managed commands; see +[preview notes](https://github.com/top-maker/modsim/blob/v2/docs/preview-notes.md). + +## Start a managed deployment + +From a source checkout, `docker compose up -d --build` runs the root +`examples/deployment.yaml`. Unit 1 is a virtual ADAM-5017UH input module and Unit 2 is a +virtual ADAM-6024 with synthetic I/O loopback. Compose publishes port 5020 on +host loopback. The ADAM mappings are manual-derived candidates; simulation is +not evidence of physical device behavior. + +To run locally with uv, use `uv run modsim up`. The default deployment +binds all host interfaces when run directly. See [managed deployments](managed-deployments.md) +for updates, logging, TD export, instance IDs and script permissions. + +## Unconfigured demo + +`modsim --comm tcp --port 5020` starts the legacy demonstration datastore; all +Unit IDs share its four Modbus tables. TCP and UDP use socket framing; UDP +listens on loopback. TLS uses `certificates/pymodbus.crt` and +`certificates/pymodbus.key` relative to the working directory. It does not +authenticate clients. Serial supports RTU and ASCII; physical serial hardware +has not been validated by the local regression suite. + +The CLI rejects non-default `--store` and the unsupported `--slaves` and +`--context` options. Run `modsim --help` for available options. + +## More information + +- [Model-driven simulation](model-validation.md): TM/TD, codecs and simulation data. +- [Managed deployments](managed-deployments.md): YAML, lifecycle and export. +- [Modules](modules.md): API reference. diff --git a/packages/modsim/docs/site/managed-deployments.md b/packages/modsim/docs/site/managed-deployments.md new file mode 100644 index 0000000..cab2b53 --- /dev/null +++ b/packages/modsim/docs/site/managed-deployments.md @@ -0,0 +1,169 @@ +# Managed deployments + +The 2.0.0a2 candidate adds two-level commands for a local, single-listener +deployment. These commands are not included in the published `2.0.0a1` preview. +Managed commands currently require POSIX (Linux, macOS or WSL); the existing +flag-based server entry point remains available on other platforms. + +## Start and reconcile + +```bash +modsim up -f examples/deployment.yaml -d +modsim ps -f examples/deployment.yaml +modsim up -f examples/deployment.yaml --dry-run +modsim up -f examples/deployment.yaml +modsim down -f examples/deployment.yaml +``` + +All commands default to `examples/deployment.yaml` in the current directory. `up` runs in +the foreground on first startup; `-d` starts a detached process. Later `up` +commands update that process and follow its logs; use `-d` to return immediately. +Interrupting the original foreground process stops its deployment. Interrupting +an attached `up` or `logs --follow` disconnects that viewer while the existing +deployment continues. `down` waits for cleanup; repeating it is harmless. + +Each deployment has a `name`, defaulting to the deployment directory name. Names +identify runtimes within the current OS user. A running name cannot be taken over +by another file. Keep the file path and name stable; run `down` before moving or +renaming the deployment. Commands operate on the selected deployment, rather than +discovering every deployment on the machine. + +## Deployment version 2 + +```yaml +version: 2 +name: lab-demo +server: + bind: 127.0.0.1 + port: 5020 +devices: + - id: adam-5017uh + model: examples/models/products/advantech/adam-5017uh/model.tm.json + parameters: + THING_ID: urn:modsim:example:adam-5017uh + UNIT_ID: 1 + data: examples/models/products/advantech/adam-5017uh/model.sim.json +``` + +`devices` may be empty. IDs and deployment names use lowercase letters, digits +and hyphens, starting with a letter or digit (maximum 64 characters). Device IDs, +instantiated TD IDs and Unit IDs must each be unique within the deployment. +Paths in the repository example resolve from the project root; for standalone +deployments, model, data and script paths resolve relative to the deployment file. +Models may also use bounded HTTPS URLs. Pin remote model revisions +for repeatable runs. + +Each device contains only `id`, `model`, and optional `parameters`, `data`, +`script` and `scriptParameters` (values a script reads as `device.parameters`). A model must be a profile 0.2 TM. Its instantiated TD must have a +stable URI `id`. Supply `THING_ID` when the TM declares that placeholder or has no `id`. +The deployment device ID selects management operations; the TD ID identifies the +Thing; Unit ID selects the device in Modbus requests. A device's TD ID cannot +change during an update: remove it in one successful `up`, then recreate it. + +`parameters` supplies typed TM bindings through the published shared interpreter: + +* `HOST`, `PORT` and `UNIT_ID` are reserved instance arguments, passed to the + interpreter's host, port and unit-id API. They can also satisfy its corresponding + reserved placeholders. `AUTHORITY` is derived; use `HOST` and `PORT` instead. +* `THING_ID` supplies an explicit TD identity when the TM has no `id`. +* Other keys must match TM placeholders. Missing or unused bindings are errors. +* HOST and PORT default to the concrete listener bind address and listener port. + A wildcard bind requires explicit HOST. An advertised endpoint can differ from + the listener for container port mappings or proxies; no connectivity test or + port forwarding is performed by export. The deployer must configure that route. +* UNIT_ID defaults to the model declaration, or the interpreter's fallback 1. + Declare it explicitly when creating multiple instances of an unbound TM. + +The deployment format is a Modsim contract, not a standard TD object. TD generation +uses `modpoll-wot==0.2.0a2` and its bundled TD/Modbus/profile validation. There is +no private TD parser or arbitrary TD patch mechanism. + +`data` names [simulation data](model-validation.md#simulation-data) or a modpoll +snapshot. Both JSON and YAML documents are accepted by managed deployments. +There is no duplicate initial-value field in deployment v2. Omitting data +produces valid static initial values from the model. Simulation data is not +exported as TD defaults. + +Deployment files must use the `.yaml` or `.yml` extension. YAML uses safe loading with a 1 MiB document limit, bounded nesting and JSON +compatible values; aliases, duplicate keys, implicit dates and non-finite numbers +are rejected. Use quoted strings where YAML scalar inference is inappropriate. + +## Update and reset behavior + +Before changing a runtime, `up` validates every model and data document and initializes +all new or changed candidates. An invalid candidate leaves the live device set +unchanged. This guarantee covers simulator state, not external side effects in +explicitly enabled Python scripts. + +* Unchanged devices retain register writes, elapsed simulation time, random state + and script state. Repeating `up` does not rerun their initialization hooks. +* New IDs create independent devices. Removed IDs stop their tasks. Removing the + last device leaves the listener available for a subsequent `up`. +* Changed model, parameters, data or behavior source replaces that device and + resets its state. Changes are detected by content, not just file paths. +* Listener changes require `down` followed by `up`. + +Supported protocol reads/writes and synchronous hooks do not suspend while using +device state. Registry replacement happens without yielding on the same event +loop, keeping an entire write and its echo on one device generation. Other Unit +IDs and established TCP connections remain available during updates. + +```bash +modsim reset --device adam-5017uh +modsim logs +``` + +`reset` rebuilds that device from the last successfully applied input snapshot, +including the original behavior source. It does not read pending file edits. +`logs` prints the last 1 MiB of the deployment log; `logs -f` or `logs --follow` keeps watching. +For `logs`, use `--file examples/deployment.yaml` to select a deployment; `-f` means follow. +`ps` reports device IDs, TD IDs, +Unit IDs, process ID and failure status as JSON. + +Local Python execution requires `up --allow-scripts` when starting the process. +Updates cannot grant script permission to a process started without it; restart +with the flag. `--dry-run` validates candidates and checks script syntax without +executing Python behavior. It reports additions, removals, replacements and kept +devices without changing the runtime. Initialization hooks are only exercised +during a real application of the update. + +In managed mode, a periodic behavior failure takes that device offline and marks +it failed in `ps`; other devices continue. Repeated unchanged `up` preserves that +failure status. Use `reset` to retry or change the data or script and run `up`. The legacy +flag-based startup retains its existing process-wide failure behavior. + +## TD export + +```bash +modsim export +modsim export --device adam-5017uh -o output/adam-5017uh.td.json +modsim export --running --device adam-5017uh -o output/applied.td.json +``` + +By default, `modsim export` writes every TD to `output/` in the project root. +The directory is ignored by Git. `--output-dir` changes the destination. + +Offline export reads the deployment, instantiates its TMs and validates the TDs; +it needs no running process or data files and never executes behavior scripts. `--running` +exports the last successfully applied TDs, so pending file edits cannot be +mistaken for the active configuration. TD export describes interfaces and +advertised endpoints, not current register values or a runtime snapshot. + +## Compatibility and scope + +`modsim --config ...` remains available for single-device operation. +Managed deployments require version `2`; version `"1"` and the former +`--deployment` entry point are no longer supported. +YAML support is an explicit +runtime dependency. + +Management uses private per-user Unix sockets and locks under the OS temporary +directory. It exposes no network management listener. Concurrent first starts +cannot acquire the same deployment lock; a losing start reports an error and can +be retried. SIGINT/SIGTERM and `down` close listeners, cancel device tasks and +remove the socket. The lock and log files remain for safe locking and inspection. +No remote API, multi-listener management, fault injection or state migration is +included in this change. + +Prepare pinned example inputs from the repository root with +`uv run python tools/fetch-models.py`; see `examples/model-source.yaml`. diff --git a/packages/modsim/docs/site/model-validation.md b/packages/modsim/docs/site/model-validation.md new file mode 100644 index 0000000..e8ed496 --- /dev/null +++ b/packages/modsim/docs/site/model-validation.md @@ -0,0 +1,149 @@ +# Model-driven simulation + +The v2 source uses the published, exact `modpoll-wot==0.2.0a2` dependency. +Install with `uv sync --all-groups`. Model parsing and TM instantiation belong to that +shared package; Modsim owns state and protocol execution. + +## One device + +```bash +uv run modsim --config examples/models/products/advantech/adam-5017uh/model.tm.json \ + --unit-id 1 --port 5020 \ + --data examples/models/products/advantech/adam-5017uh/model.sim.json +``` + +Without `--port`, the listener uses 5020; port 502 needs administrator rights on +Linux and on macOS for `127.0.0.1`; modsim then explains how to rerun with sudo +or choose a port above 1023. + +`--config` also accepts HTTPS model URLs. GitHub `blob` links are converted to +raw file URLs. Prefer a tag or commit SHA for repeatable runs; branch URLs change. +Downloads have a 15-second timeout and a 1 MiB limit, and use the shared bounded +JSON loader. Only models are downloaded; no script is fetched or executed from a +model. JSON-LD context URLs are vocabulary identifiers, not execution sources. + +The configured runtime supports profile 0.2 integer types (16/32/64-bit, +signed/unsigned), IEEE float16/32/64, fixed-capacity UTF-8 strings, register and +physical scalar booleans, physical boolean arrays, legacy register bool/bool8/ +bool16 arrays, register bit selectors and explicit legacy-MSB packed bit payloads. +Byte and word ordering follow the shared contract; legacy packed bit numeric +payloads ignore word ordering, and packed strings ignore both, matching Modpoll. + +Initialization, script updates, generators and Modbus writes use the same codec. +Integer-wire multipliers are inverted with exact rational arithmetic: values that +require fractional raw integers or overflow are rejected instead of truncated. +Negative factors are supported. A zero factor can only encode engineering zero, +using raw zero. IEEE values use their representable wire precision; startup +reports and `device.get` return the decoded value. Model constraints apply after +quantization too: an unrepresentable exact `const` is rejected. Numeric initial +values use bounded candidates and arithmetic, not enumeration of 32/64-bit ranges. +Complex constraints may require an explicit initial value/default/enum. + +Strings must fit their UTF-8 byte capacity, use zero padding and cannot end in +NUL (consumers strip trailing NULs). Physical bit arrays have their declared +length. Legacy register bool arrays retain the consumer's byte/LSB layout and +preserve unused padding. No engineering-unit conversion is guessed for raw ADAM +channels. Profile 0.2 is required; the unconfigured demonstration is unchanged. + +## Managed deployments + +For repeatable startup and runtime updates, use deployment version 2 and +`modsim up`. See [managed deployments](managed-deployments.md) for the YAML +contract, TM parameters, dynamic device lifecycle and TD export. +The ADAM lab example starts two independent devices on one listener: + +```bash +uv run modsim up -f examples/deployment.yaml +``` + +Paths in deployment files, including data and script paths, are relative to the +deployment directory. Unit IDs and TD identities must +be unique. Unknown addresses or Unit IDs never inherit another device's state. + +## Simulation data + +`--data` takes a local path or HTTPS URL of simulation data, defined by +[modpoll-wot](https://github.com/top-maker/modpoll-wot/blob/main/profile.md#simulation-data). +Version `"1"` fields: + +| Field | Meaning | +| --- | --- | +| `initial` | Property-name/value static values, the default | +| `tick` | Update interval in seconds, default 1, minimum 0.001 | +| `seed` | Per-instance random seed, default 0 | +| `generators` | Property-name to generator specification | +| `bindings` | Target property to source property for synthetic loopback | +| `writePolicy` | `hold` (default) or `overwrite` for generated properties | + +Simulation data carries no code. A modpoll `--export` snapshot is accepted as +well: the entry titled like the model, or the only entry, becomes `initial`; +points modpoll could not read (`null`) keep their defaults and are logged. +Scaled values are accepted when they are exact decimal multiples of the +multiplier or exactly the float modpoll exports, so a snapshot replays +unchanged. + +Generators: `constant` (`value`); `sine` (`center`, `amplitude`, positive `period`); +`ramp` (`start`, `rate`, `minimum`, `maximum`, clamped to bounds); +`noise` (`minimum`, `maximum`, uniform seeded noise). Integer-property noise +uses integer sampling to preserve the full 64-bit range. +Numeric generators round to the nearest integer for integer model properties. +Boolean channels can use constant values, bindings or scripts. All updates must +satisfy the model's schema and raw encoding bounds. Unknown properties are errors. +Binding chains and cycles are rejected; use a script for ordered dependencies. + +Initialization order: model defaults/type fallback → data `initial` → +CLI `--initial` → script `initialize` → first dynamic update at elapsed 0. +Single-device startup logs include the final initialized values; raw values are +synthetic unless the contribution explicitly documents their source. + +On each tick: generators → script `tick` → bindings. Modbus writes validate the +whole request, then run `on_write` and bindings before responding. Invalid write +requests or failed write hooks roll back register changes. Partial register +writes re-decode every overlapping property, including properties whose first +register was not touched. Batch updates and alias constraints are checked before +commit. Bit-field updates preserve neighboring bits. Protocol writes may not +change read-only/reserved bits; a writable bit sharing a register with read-only +bits can be changed while preserving those bits. Reads that would expose a +write-only field are rejected, while FC5/6 write echoes remain supported. +Model read-only measurements may be changed internally but cannot be written by clients. +`hold` stops a generator or binding for a property after a valid client write until +restart; `overwrite` permits the next tick to replace it. Scripts define their own write +response and may deliberately overwrite values. + +## Local Python behaviors + +```bash +uv run modsim --config examples/models/products/advantech/adam-5017uh/model.tm.json \ + --script behavior.py --allow-scripts +``` + +Optional synchronous hooks: + +```python +def initialize(device): + device.set("AI0_RAW", 100) + + +def tick(device, elapsed, dt): + device.set("AI0_RAW", 100 + int(elapsed) % 100) + + +def on_write(device, changes): + if "AO0_RAW" in changes: + device.set("AI0_RAW", changes["AO0_RAW"]) +``` + +Use `get(name)`, `set(name, value)` and `set_many({...})`. Batch updates validate +all values before changing cells. Hooks run on the server event loop and must not +block; async hooks are rejected. Python is ordinary local code, enabled explicitly +by `--allow-scripts`. Each device loads its own module instance. In single-device +`--config` mode, periodic behavior errors stop the server. In managed mode, an +error takes only that device offline and is reported by `ps`. SIGINT/SIGTERM +cancel updates and close the server. + +The sample loopback is an explicit synthetic assumption, not a claim that real +ADAM hardware automatically connects AO to AI or DO to DI. No fault injection, +recording/replay, multi-listener runtime or remote behavior execution is included. + +Prepare pinned example inputs from the repository root with +`uv run python tools/fetch-models.py`; see `examples/model-source.yaml`. diff --git a/packages/modsim/docs/site/modules.md b/packages/modsim/docs/site/modules.md new file mode 100644 index 0000000..6073f2f --- /dev/null +++ b/packages/modsim/docs/site/modules.md @@ -0,0 +1,7 @@ +# Modules + +::: modsim.main + +::: modsim.management + +::: modsim.manifest diff --git a/packages/modsim/examples/deployment.yaml b/packages/modsim/examples/deployment.yaml new file mode 100644 index 0000000..8c48d53 --- /dev/null +++ b/packages/modsim/examples/deployment.yaml @@ -0,0 +1,20 @@ +version: 2 +name: modsim-lab +server: + bind: 0.0.0.0 + port: 5020 +devices: +- id: adam-5017uh + model: examples/models/products/advantech/adam-5017uh/model.tm.json + parameters: + THING_ID: urn:modsim:device:advantech:adam-5017uh + UNIT_ID: 1 + HOST: 127.0.0.1 + data: examples/models/products/advantech/adam-5017uh/model.sim.json +- id: adam-6024 + model: tests/fixtures/io-module/adam-6024.tm.json + parameters: + THING_ID: urn:modsim:device:advantech:adam-6024 + UNIT_ID: 2 + HOST: 127.0.0.1 + data: tests/fixtures/io-module/simulation/adam-6024.data.json diff --git a/packages/modsim/examples/docker-compose.yaml b/packages/modsim/examples/docker-compose.yaml new file mode 100644 index 0000000..ca038b1 --- /dev/null +++ b/packages/modsim/examples/docker-compose.yaml @@ -0,0 +1,14 @@ +name: modsim-lab +services: + modsim: + build: + context: ../../.. + dockerfile: packages/modsim/Dockerfile + restart: unless-stopped + command: ["python", "-m", "modsim", "up", "-f", "/app/deployment.yaml"] + ports: + - "127.0.0.1:5020:5020" + volumes: + - ./deployment.yaml:/app/deployment.yaml:ro + - ./td:/app/output + - ./models:/app/examples/models:ro diff --git a/packages/modsim/examples/model-source.yaml b/packages/modsim/examples/model-source.yaml new file mode 100644 index 0000000..f3ec603 --- /dev/null +++ b/packages/modsim/examples/model-source.yaml @@ -0,0 +1,6 @@ +repository: top-maker/open-modbus-catalog +revision: fd90607ef0235c5af01dfd1c62b32ca853834bdb +files: + products/advantech/adam-5017uh/model.tm.json: 9e1d6e38dbb4e2db2f30f8dfd3d9df90a349b2e9aeb60a168ae4d60ee709ead7 + # Catalog schema 7 name for the simulation data; later catalog commits call it model.data.json. + products/advantech/adam-5017uh/model.sim.json: 246e0eaf9234aaec6c85c63497a27bbd89c132e436345636c9cdba8969fd3c9f diff --git a/packages/modsim/mkdocs-preview.yml b/packages/modsim/mkdocs-preview.yml new file mode 100644 index 0000000..4d510a5 --- /dev/null +++ b/packages/modsim/mkdocs-preview.yml @@ -0,0 +1,3 @@ +INHERIT: mkdocs.yml +site_url: https://top-maker.github.io/modsim/v2/ +edit_uri: edit/v2/docs/site/ diff --git a/packages/modsim/mkdocs.yml b/packages/modsim/mkdocs.yml new file mode 100644 index 0000000..9ad985f --- /dev/null +++ b/packages/modsim/mkdocs.yml @@ -0,0 +1,56 @@ +site_name: modsim +docs_dir: docs/site +repo_url: https://github.com/top-maker/modsim +site_url: https://top-maker.github.io/modsim +site_description: A Simple Modbus TCP Device Simulator used for modpoll tool +site_author: Ying Shaodong +edit_uri: edit/main/docs/site/ +repo_name: top-maker/modsim + +nav: + - Home: index.md + - Model validation: model-validation.md + - Managed deployments: managed-deployments.md + - Modules: modules.md +plugins: + - search + - mkdocstrings: + handlers: + python: + setup_commands: + - import sys + - sys.path.append('../') +theme: + name: material + feature: + tabs: true + palette: + - media: "(prefers-color-scheme: light)" + scheme: default + primary: white + accent: deep orange + toggle: + icon: material/brightness-7 + name: Switch to dark mode + - media: "(prefers-color-scheme: dark)" + scheme: slate + primary: black + accent: deep orange + toggle: + icon: material/brightness-4 + name: Switch to light mode + icon: + repo: fontawesome/brands/github + +extra: + social: + - icon: fontawesome/brands/github + link: https://github.com/top-maker/modsim + - icon: fontawesome/brands/python + link: https://pypi.org/project/modsim + +markdown_extensions: + - toc: + permalink: true + - pymdownx.arithmatex: + generic: true diff --git a/packages/modsim/modsim/__init__.py b/packages/modsim/modsim/__init__.py new file mode 100644 index 0000000..3a87841 --- /dev/null +++ b/packages/modsim/modsim/__init__.py @@ -0,0 +1 @@ +__version__ = "2.0.0a12" diff --git a/packages/modsim/modsim/__main__.py b/packages/modsim/modsim/__main__.py new file mode 100644 index 0000000..89f1142 --- /dev/null +++ b/packages/modsim/modsim/__main__.py @@ -0,0 +1,3 @@ +from .main import app + +app() diff --git a/packages/modsim/modsim/codec.py b/packages/modsim/modsim/codec.py new file mode 100644 index 0000000..527110f --- /dev/null +++ b/packages/modsim/modsim/codec.py @@ -0,0 +1,325 @@ +"""Encode/decode the shared profile's wire mappings without reparsing models.""" + +import math +import struct +from fractions import Fraction +from typing import Any + +from jsonschema import Draft7Validator # type: ignore[import-untyped] +from modpoll_wot import DataError, scaled_raw # type: ignore[import-untyped] + +FORMATS = { + "uint16": "H", + "int16": "h", + "uint32": "I", + "int32": "i", + "uint64": "Q", + "int64": "q", + "float16": "e", + "float32": "f", + "float64": "d", +} + + +class Codec: + """A property owns a span and masks within that span, not just its first cell.""" + + def __init__(self, group: Any, member: Any, schema: dict) -> None: + self.group, self.member, self.schema = group, member, schema + self.name, self.table = member.property, group.table + self.start = group.start + member.offset + self.bits = member.physical_bits + self.dtype = member.data_type + self.span = member.bit_count if self.bits else member.width + self.order = member.byte_order or group.byte_order + self.factor = ( + Fraction(str(member.multiplier)) + if member.multiplier is not None + else Fraction(1) + ) + self.validator = Draft7Validator(schema) + if ( + self.dtype not in FORMATS + and self.dtype not in ("bool", "bool8", "bool16") + and not self.dtype.startswith("string") + ): + raise ValueError(f"{self.name}: unsupported codec {self.dtype}") + + def validate(self, value: Any) -> None: + if not self.validator.is_valid(value): + raise ValueError( + f"{self.name}: value violates model constraints: {value!r}" + ) + if type(value) is float and not math.isfinite(value): + raise ValueError(f"{self.name}: non-finite value") + + def ordered(self, payload: bytes) -> bytes: + # This involution matches the profile 0.2 consumer semantics. Legacy + # packed bit payloads ignore word order; packed strings ignore both. + if self.bits and self.dtype.startswith("string"): + return payload + chunks = [payload[i : i + 2] for i in range(0, len(payload), 2)] + if self.order.startswith("LE_"): + chunks = [chunk[::-1] for chunk in chunks] + if not self.bits and self.order.endswith("_LE"): + chunks.reverse() + return b"".join(chunks) + + def payload(self, cells: Any) -> bytes: + values = [ + cells[self.table][i] for i in range(self.start, self.start + self.span) + ] + if self.bits: + return bytes( + sum(bool(bit) << (7 - j) for j, bit in enumerate(values[i : i + 8])) + for i in range(0, len(values), 8) + ) + return b"".join(int(value).to_bytes(2, "big") for value in values) + + def decode(self, cells: Any) -> Any: + member = self.member + if self.bits and self.dtype == "bool": + values = [ + bool(cells[self.table][i]) + for i in range(self.start, self.start + self.span) + ] + return values[0] if member.scalar else values + payload = self.payload(cells) + if member.bit is not None: + return bool( + (int.from_bytes(self.ordered(payload), "big") >> member.bit) & 1 + ) + if self.dtype in ("bool", "bool8", "bool16"): + count = 16 if self.dtype == "bool16" else 8 + return [bool(payload[i // 8] & (1 << (i % 8))) for i in range(count)] + payload = self.ordered(payload) + if self.dtype.startswith("string"): + return payload[: int(self.dtype[6:])].decode("utf-8").rstrip("\0") + raw = struct.unpack(">" + FORMATS[self.dtype], payload)[0] + if member.scalar: + return bool(raw) + if self.dtype.startswith("float"): + value = raw * float(self.factor) + if not math.isfinite(value): + raise ValueError(f"{self.name}: non-finite decoded value") + return value + value = raw * self.factor + return value.numerator if value.denominator == 1 else float(value) + + def encode(self, value: Any) -> list[tuple[int, int]]: + """Return (value, owned mask) for each wire cell, preserving other bits.""" + self.validate(value) + member = self.member + if self.bits and self.dtype == "bool": + values = [value] if member.scalar else value + if ( + not isinstance(values, list) + or len(values) != self.span + or any(type(v) is not bool for v in values) + ): + raise ValueError(f"{self.name}: expected {self.span} boolean bits") + return [(int(v), 1) for v in values] + length = self.span // 8 if self.bits else self.span * 2 + mask = b"\xff" * length + if member.bit is not None: + if type(value) is not bool: + raise ValueError(f"{self.name}: expected boolean") + mask = self.ordered((1 << member.bit).to_bytes(2, "big")) + payload = mask if value else b"\0\0" + elif self.dtype in ("bool", "bool8", "bool16"): + count = 16 if self.dtype == "bool16" else 8 + if ( + not isinstance(value, list) + or len(value) != count + or any(type(v) is not bool for v in value) + ): + raise ValueError(f"{self.name}: expected {count} boolean bits") + payload = bytes( + sum(int(v) << j for j, v in enumerate(value[i : i + 8])) + for i in range(0, count, 8) + ).ljust(length, b"\0") + mask = (b"\xff" * (count // 8)).ljust(length, b"\0") + elif self.dtype.startswith("string"): + capacity = int(self.dtype[6:]) + payload = value.encode("utf-8") + if len(payload) > capacity or value.endswith("\0"): + raise ValueError( + f"{self.name}: string is not losslessly encodable in {capacity} bytes" + ) + payload = self.ordered(payload.ljust(length, b"\0")) + else: + if member.scalar: + if type(value) is not bool: + raise ValueError(f"{self.name}: expected boolean") + raw: Any = int(value) + else: + if type(value) not in (int, float): + raise ValueError(f"{self.name}: expected a finite numeric value") + if self.dtype.startswith("float"): + if not self.factor: + if value != 0: + raise ValueError( + f"{self.name}: zero multiplier only represents zero" + ) + raw = 0.0 + else: + raw = float(Fraction(str(value)) / self.factor) + else: + # Exact decimals and the floats modpoll exports both map back. + try: + raw = scaled_raw( + value, + ( + 1 + if self.member.multiplier is None + else self.member.multiplier + ), + ) + except DataError as exc: + raise ValueError(f"{self.name}: {exc}") from exc + try: + payload = self.ordered(struct.pack(">" + FORMATS[self.dtype], raw)) + except (OverflowError, struct.error) as exc: + raise ValueError( + f"{self.name}: value cannot be encoded as {self.dtype}" + ) from exc + if self.bits: + return [ + (int(bool(payload[i // 8] & (1 << (7 - i % 8)))), 1) + for i in range(self.span) + ] + return [ + ( + int.from_bytes(payload[i : i + 2], "big"), + int.from_bytes(mask[i : i + 2], "big"), + ) + for i in range(0, length, 2) + ] + + def initial(self, supplied: Any, explicit: bool) -> Any: + if explicit: + candidates = [supplied] + elif "const" in self.schema: + candidates = [self.schema["const"]] + elif "default" in self.schema: + candidates = [self.schema["default"]] + elif "enum" in self.schema: + candidates = list(self.schema["enum"]) + else: + candidates = self.fallbacks() + for value in candidates: + try: + encoded = self.encode(value) + probe = { + self.table: { + self.start + i: raw for i, (raw, mask) in enumerate(encoded) + } + } + self.validate(self.decode(probe)) + return value + except (ValueError, TypeError, UnicodeError): + pass + raise ValueError( + f"{self.name}: no schema-valid encodable initial value; provide an explicit initial value" + ) + + def fallbacks(self) -> list: + schema = self.schema + if schema.get("type") == "boolean": + return [False, True] + if schema.get("type") == "array": + count = self.span if self.bits else (16 if self.dtype == "bool16" else 8) + item = schema.get("items", {}) + preferred = next( + (v for v in [False, True] if Draft7Validator(item).is_valid(v)), False + ) + return [[preferred] * count] + if self.dtype.startswith("string"): + length = schema.get("minLength", 0) + capacity = int(self.dtype[6:]) + return ["", "x" * length] if length <= capacity else [""] + if not self.factor: + return [0] + candidates: list = [0] + # Integer wire types use exact rational interval arithmetic and a raw + # quantum. This avoids enumeration and float loss at 64-bit boundaries. + if self.dtype.startswith(("int", "uint")): + width = int(self.dtype.lstrip("uint")) + signed = self.dtype.startswith("int") + low = -(1 << (width - 1)) if signed else 0 + high = (1 << (width - 1)) - 1 if signed else (1 << width) - 1 + for key, lower, exclusive in [ + ("minimum", True, False), + ("exclusiveMinimum", True, True), + ("maximum", False, False), + ("exclusiveMaximum", False, True), + ]: + if key not in schema: + continue + bound = Fraction(str(schema[key])) / self.factor + raw_lower = lower == (self.factor > 0) + if raw_lower: + low = max( + low, math.floor(bound) + 1 if exclusive else math.ceil(bound) + ) + else: + high = min( + high, math.ceil(bound) - 1 if exclusive else math.floor(bound) + ) + quantum = 1 + if "multipleOf" in schema: + quantum = abs( + (Fraction(str(schema["multipleOf"])) / self.factor).numerator + ) + for raw in ( + math.ceil(Fraction(low, quantum)) * quantum, + math.floor(Fraction(high, quantum)) * quantum, + ): + if low <= raw <= high: + result = raw * self.factor + candidates.append( + result.numerator if result.denominator == 1 else float(result) + ) + return candidates + for key in ("minimum", "exclusiveMinimum", "maximum", "exclusiveMaximum"): + if key in schema: + bound = schema[key] + candidates.append(bound) + float_raw = float(Fraction(str(bound)) / self.factor) + try: + packed = struct.pack(">" + FORMATS[self.dtype], float_raw) + number = int.from_bytes(packed, "big") + neighbors = [number - 1, number + 1] + if float_raw == 0: + neighbors.extend([1, (1 << (8 * len(packed) - 1)) | 1]) + for neighbor in neighbors: + if 0 <= neighbor < 1 << (8 * len(packed)): + adjusted = struct.unpack( + ">" + FORMATS[self.dtype], + neighbor.to_bytes(len(packed), "big"), + )[0] * float(self.factor) + if math.isfinite(adjusted): + candidates.append(adjusted) + except (OverflowError, struct.error): + pass + if "multipleOf" in schema: + step = Fraction(str(schema["multipleOf"])) + candidates.extend([float(step), -float(step)]) + for key in ("minimum", "exclusiveMinimum", "maximum", "exclusiveMaximum"): + if key not in schema: + continue + ratio = Fraction(str(schema[key])) / step + if key in ("minimum", "exclusiveMinimum"): + number = ( + math.floor(ratio) + 1 + if key == "exclusiveMinimum" + else math.ceil(ratio) + ) + else: + number = ( + math.ceil(ratio) - 1 + if key == "exclusiveMaximum" + else math.floor(ratio) + ) + candidates.append(float(number * step)) + return candidates diff --git a/packages/modsim/modsim/commands.py b/packages/modsim/modsim/commands.py new file mode 100644 index 0000000..6749bcd --- /dev/null +++ b/packages/modsim/modsim/commands.py @@ -0,0 +1,236 @@ +"""Two-level managed CLI; legacy flag-based server startup remains supported.""" + +import argparse +import asyncio +import json +import os +from pathlib import Path +import subprocess +import sys +import time + +from .management import RuntimeManager, paths, request, serve +from .manifest import load_deployment, read_yaml +from .utils import get_logger + +ACTIONS = {"up", "down", "ps", "logs", "export", "reset"} + + +def default_deployment() -> str: + """Select the example manifest from the repository root or examples directory.""" + if (Path.cwd() / "deployment.yaml").is_file(): + return "deployment.yaml" + return "examples/deployment.yaml" + + +def default_output_dir() -> Path: + """Use an ignored output directory at the project root.""" + return Path(__file__).resolve().parent.parent / "output" + + +def parser() -> argparse.ArgumentParser: + root = argparse.ArgumentParser(description="Manage a local Modsim deployment") + actions = root.add_subparsers(dest="action", required=True) + for action in sorted(ACTIONS): + command = actions.add_parser(action) + if action == "logs": + command.add_argument("--file", default=default_deployment()) + else: + command.add_argument("-f", "--file", default=default_deployment()) + if action == "up": + command.add_argument("-d", "--detach", action="store_true") + command.add_argument("--dry-run", action="store_true") + command.add_argument("--allow-scripts", action="store_true") + command.add_argument("--serve", action="store_true", help=argparse.SUPPRESS) + if action == "logs": + command.add_argument("-f", "--follow", action="store_true") + if action in ("export", "reset"): + command.add_argument("--device", required=action == "reset") + if action == "export": + output = command.add_mutually_exclusive_group() + output.add_argument("-o", "--output") + output.add_argument("--output-dir", default=str(default_output_dir())) + command.add_argument("--running", action="store_true") + return root + + +def identity(path: Path) -> str: + if path.suffix.lower() not in (".yaml", ".yml"): + raise ValueError("deployment file must use .yaml or .yml") + spec = read_yaml(path) + name = spec.get("name", path.parent.name) + if not isinstance(name, str) or not name: + raise ValueError("deployment name must be a nonempty string") + return name + + +def call(name: str, path: Path, action: str, **options: object) -> dict: + return asyncio.run( + request(name, {"action": action, "source": str(path), **options}) + ) + + +def online(name: str, path: Path) -> dict | None: + try: + return call(name, path, "ps") + except (FileNotFoundError, ConnectionError): + return None + + +def export_documents(tds: dict, args: argparse.Namespace) -> None: + if args.device: + if args.device not in tds: + raise ValueError(f"unknown device: {args.device}") + tds = {args.device: tds[args.device]} + output = Path(args.output) if args.output else None + output_is_directory = output is not None and ( + output.is_dir() or not output.suffix.lower() == ".json" + ) + if output_is_directory and output is not None: + output.mkdir(parents=True, exist_ok=True) + if args.output_dir and output is None: + Path(args.output_dir).mkdir(parents=True, exist_ok=True) + for key, td in tds.items(): + target = ( + output / f"{key}.td.json" + if output_is_directory and output is not None + else ( + output + if output is not None + else Path(args.output_dir) / f"{key}.td.json" + ) + ) + target.write_text( + json.dumps(td, ensure_ascii=False, indent=2) + "\n", encoding="utf-8" + ) + print(target) + + +def show_logs(name: str, path: Path, *, follow: bool = False) -> None: + """Print recent output and optionally follow until the deployment stops.""" + log_path = paths(name)[2] + if not log_path.exists(): + raise ValueError("no log for this deployment") + with log_path.open("rb") as stream: + stream.seek(max(0, log_path.stat().st_size - 1024 * 1024)) + while True: + data = stream.read() + if data: + print(data.decode("utf-8", errors="replace"), end="", flush=True) + if not follow or online(name, path) is None: + break + time.sleep(0.2) + + +def run(argv: list[str]) -> None: + args = parser().parse_args(argv) + get_logger() + path = Path(args.file).resolve() + try: + name = identity(path) + if args.action == "export": + if args.running: + try: + tds = call(name, path, "export")["tds"] + except FileNotFoundError as exc: + raise ValueError( + "no managed deployment found in this environment; " + "start it with `uv run modsim up -d`, or run export " + "inside the Docker Compose container" + ) from exc + else: + deployment = load_deployment(path, include_data=False) + tds = {key: item.td for key, item in deployment.instances.items()} + export_documents(tds, args) + return + if args.action == "logs": + # Verify the source if the deployment is currently running. + online(name, path) + show_logs(name, path, follow=args.follow) + return + if args.action != "up": + status = online(name, path) + if status is None: + if args.action == "reset": + raise ValueError("deployment is not running") + print(json.dumps({"running": False, "name": name})) + return + result = ( + status + if args.action == "ps" + else call(name, path, args.action, device=getattr(args, "device", None)) + ) + if args.action == "down": + deadline = time.monotonic() + 10 + while online(name, path) is not None: + if time.monotonic() >= deadline: + raise ValueError( + "deployment shutdown did not complete within 10 seconds" + ) + time.sleep(0.05) + print(json.dumps(result, ensure_ascii=False, indent=2)) + return + if args.serve: + asyncio.run(serve(path, args.allow_scripts, detached=True)) + elif online(name, path): + print( + json.dumps( + call( + name, + path, + "up", + dry_run=args.dry_run, + allow_scripts=args.allow_scripts, + ), + indent=2, + ) + ) + if not args.detach and not args.dry_run: + try: + show_logs(name, path, follow=True) + except KeyboardInterrupt: + # Detach from an existing deployment; its owner controls shutdown. + pass + elif args.dry_run: + + async def preview() -> dict: + manager = RuntimeManager(args.allow_scripts) + return await manager.apply(load_deployment(path), dry_run=True) + + print(json.dumps(asyncio.run(preview()), indent=2)) + elif not args.detach: + asyncio.run(serve(path, args.allow_scripts)) + else: + # Resolve/validate before launching; the worker validates again from its snapshot. + deployment = load_deployment(path) + log_path = paths(deployment.name)[2] + command = [sys.executable, "-m", "modsim", "up", "-f", str(path), "--serve"] + if args.allow_scripts: + command.append("--allow-scripts") + with log_path.open("ab") as output: + os.chmod(log_path, 0o600) + process = subprocess.Popen( + command, + stdin=subprocess.DEVNULL, + stdout=output, + stderr=output, + start_new_session=True, + ) + deadline = time.monotonic() + 30 + while process.poll() is None: + status = online(name, path) + if status: + print(json.dumps(status, ensure_ascii=False, indent=2)) + return + if time.monotonic() >= deadline: + process.terminate() + process.wait(timeout=10) + raise ValueError(f"startup timed out; inspect {log_path}") + time.sleep(0.05) + process.wait() + raise ValueError(f"startup failed; inspect {log_path}") + except KeyboardInterrupt: + return + except (ValueError, OSError, TypeError, TimeoutError) as exc: + print(f"modsim: {exc}", file=sys.stderr) + raise SystemExit(2) from exc diff --git a/packages/modsim/modsim/compat.py b/packages/modsim/modsim/compat.py new file mode 100644 index 0000000..907c501 --- /dev/null +++ b/packages/modsim/modsim/compat.py @@ -0,0 +1,131 @@ +"""Compatibility layer for PyModbus API changes. + +This module provides backward-compatible wrappers for APIs that changed +between PyModbus 3.6.9 and 3.16.1. +""" + +import struct +from typing import List + + +class Endian: + """Compatibility class for endianness constants removed in PyModbus 3.16.1.""" + + BIG = "big" + LITTLE = "little" + + +class BinaryPayloadBuilder: + """Compatibility wrapper for PyModbus BinaryPayloadBuilder. + + This class was removed in PyModbus 3.9.0+ but is needed for backward + compatibility with existing datastore initialization code. + """ + + def __init__(self, byteorder: str = "big", wordorder: str = "big") -> None: + """Initialize the builder. + + Args: + byteorder: Either "big" or "little" for byte order + wordorder: Either "big" or "little" for word order (register order) + """ + self.byteorder = byteorder + self.wordorder = wordorder + self._bits: List[bool] = [] + self._registers: List[int] = [] + + def add_bits(self, bits: List[bool]) -> "BinaryPayloadBuilder": + """Add a list of bits to the payload. + + Args: + bits: List of boolean values + + Returns: + Self for chaining + """ + self._bits.extend(bits) + return self + + def add_16bit_uint(self, value: int) -> "BinaryPayloadBuilder": + """Add a 16-bit unsigned integer.""" + self._registers.append(value & 0xFFFF) + return self + + def add_16bit_int(self, value: int) -> "BinaryPayloadBuilder": + """Add a 16-bit signed integer.""" + # Convert negative to unsigned representation (two's complement) + if value < 0: + value = (1 << 16) + value + self._registers.append(value & 0xFFFF) + return self + + def add_32bit_uint(self, value: int) -> "BinaryPayloadBuilder": + """Add a 32-bit unsigned integer (uses 2 registers).""" + if self.wordorder == "big": + self._registers.append((value >> 16) & 0xFFFF) + self._registers.append(value & 0xFFFF) + else: + self._registers.append(value & 0xFFFF) + self._registers.append((value >> 16) & 0xFFFF) + return self + + def add_32bit_int(self, value: int) -> "BinaryPayloadBuilder": + """Add a 32-bit signed integer (uses 2 registers).""" + # Convert to unsigned if negative + if value < 0: + value = (1 << 32) + value + return self.add_32bit_uint(value) + + def add_32bit_float(self, value: float) -> "BinaryPayloadBuilder": + """Add a 32-bit float (uses 2 registers).""" + fmt = ">f" # big-endian float + packed = struct.pack(fmt, value) + value_int = struct.unpack(">I", packed)[0] + return self.add_32bit_uint(value_int) + + def add_64bit_uint(self, value: int) -> "BinaryPayloadBuilder": + """Add a 64-bit unsigned integer (uses 4 registers).""" + if self.wordorder == "big": + self._registers.append((value >> 48) & 0xFFFF) + self._registers.append((value >> 32) & 0xFFFF) + self._registers.append((value >> 16) & 0xFFFF) + self._registers.append(value & 0xFFFF) + else: + self._registers.append(value & 0xFFFF) + self._registers.append((value >> 16) & 0xFFFF) + self._registers.append((value >> 32) & 0xFFFF) + self._registers.append((value >> 48) & 0xFFFF) + return self + + def add_64bit_int(self, value: int) -> "BinaryPayloadBuilder": + """Add a 64-bit signed integer (uses 4 registers).""" + # Convert to unsigned if negative + if value < 0: + value = (1 << 64) + value + return self.add_64bit_uint(value) + + def add_64bit_float(self, value: float) -> "BinaryPayloadBuilder": + """Add a 64-bit float (uses 4 registers).""" + packed = struct.pack(">d", value) + value_int = struct.unpack(">Q", packed)[0] + return self.add_64bit_uint(value_int) + + def add_string(self, value: str) -> "BinaryPayloadBuilder": + """Add a string (encoded as UTF-8).""" + encoded = value.encode("utf-8") + # Pad to even number of bytes + if len(encoded) % 2: + encoded += b"\x00" + # Convert bytes to registers (2 bytes per register) + for i in range(0, len(encoded), 2): + reg_value = (encoded[i] << 8) | encoded[i + 1] + self._registers.append(reg_value) + return self + + def to_coils(self) -> List[bool]: + """Return the bits as a list of booleans.""" + return self._bits + + def to_registers(self) -> List[int]: + """Return the registers as a list of integers.""" + return self._registers diff --git a/packages/modsim/modsim/deployment.py b/packages/modsim/modsim/deployment.py new file mode 100644 index 0000000..11dc89b --- /dev/null +++ b/packages/modsim/modsim/deployment.py @@ -0,0 +1,149 @@ +"""Simulation data and behavior for a single configured device.""" + +import logging +import math +from pathlib import Path +from typing import Any + +from modpoll_wot import load_simulation_data # type: ignore[import-untyped] +from modpoll_wot.loading import load_document # type: ignore[import-untyped] + +from .sources import is_remote, local_path, remote_document + +logger = logging.getLogger(__name__) + + +def obj(properties: dict, required: tuple = ()) -> dict: + return { + "type": "object", + "properties": properties, + "required": list(required), + "additionalProperties": False, + } + + +STRING = {"type": "string", "minLength": 1} + + +def data_document(source: str) -> dict: + """Load simulation data, or a modpoll --export snapshot, from a path or HTTPS URL.""" + if is_remote(source): + return remote_document(source) + return load_document(Path(local_path(Path.cwd(), source))) # type: ignore[no-any-return] + + +def resolve_data(document: dict, device: Any, title: str) -> dict: + """Check simulation data or a snapshot against the device's properties.""" + loaded = load_simulation_data( + document, title=title, properties=device.members.keys() + ) + if loaded.unread: + logger.warning( + "%s: snapshot points without a value keep their defaults: %s", + title, + ", ".join(loaded.unread), + ) + return loaded.data # type: ignore[no-any-return] + + +def apply_data(args: Any) -> None: + """Apply simulation data, CLI initial values and local behavior to a device.""" + device = args.runtime + title = args.model_initialization["title"] + spec = getattr(args, "data_spec", None) + if spec is None: + spec = ( + resolve_data(data_document(args.data), device, title) if args.data else {} + ) + device.tick_interval = spec.get("tick", 1.0) + if not math.isfinite(device.tick_interval) or device.tick_interval < 0.001: + raise ValueError("data tick must be finite and at least 0.001 seconds") + device.random.seed(spec.get("seed", 0)) + device.parameters = getattr(args, "script_parameters", None) or {} + device.generators = spec.get("generators", {}) + device.bindings = spec.get("bindings", {}) + device.write_policy = spec.get("writePolicy", "hold") + targets = device.generators.keys() | device.bindings.keys() + if ( + targets - device.members.keys() + or set(device.bindings.values()) - device.members.keys() + ): + raise ValueError( + f"{device.name}: simulation data references unknown properties" + ) + if device.generators.keys() & device.bindings.keys(): + raise ValueError("a property cannot have both a generator and a binding") + if device.bindings.keys() & set(device.bindings.values()): + raise ValueError("binding chains/cycles are unsupported; use a script") + for name, rule in device.generators.items(): + if rule["kind"] in ("ramp", "noise") and rule["minimum"] > rule["maximum"]: + raise ValueError(f"{name}: generator minimum exceeds maximum") + # Validate full declared generator envelopes before opening the listener. + import copy + + saved = copy.deepcopy(device.cells) + try: + for name, rule in device.generators.items(): + if rule["kind"] == "constant": + candidates = [rule["value"]] + elif rule["kind"] == "sine": + candidates = [ + rule["center"] - rule["amplitude"], + rule["center"] + rule["amplitude"], + ] + else: + candidates = [rule["minimum"], rule["maximum"]] + if ( + device.schemas[name].get("type") == "boolean" + and rule["kind"] != "constant" + ): + raise ValueError(f"{name}: boolean generators require constant values") + for value in candidates: + if ( + device.schemas[name].get("type") == "integer" + and type(value) is not bool + ): + value = round(value) + device.set(name, value) + finally: + device.cells = saved + initial = dict(spec.get("initial", {})) + # CLI initial values take precedence over simulation data. + from modpoll_wot import parse_parameters + + initial.update(parse_parameters(args.initial)) + device.set_many(initial) + script = args.script + if script: + if not args.allow_scripts: + raise ValueError("Python behavior scripts require --allow-scripts") + device.load_script( + local_path(Path.cwd(), script), getattr(args, "script_source", None) + ) + device.hook("initialize") + device.advance(0.0, 0.0) + origins = args.model_initialization["origins"] + for name in spec.get("initial", {}): + origins[name] = "data initial" + for name in parse_parameters(args.initial): + origins[name] = "instance initial" + if script: + for name in origins: + origins[name] = "local script/initialization" + for name in device.generators: + origins[name] = "data generator" + for name in device.bindings: + origins[name] = "data binding" + args.model_initialization["values"] = { + name: device.get(name) for name in device.members + } + + +def configure_devices(args: Any) -> list: + """Configure a single --config device.""" + from .wot import configure + + sim = configure(args) + apply_data(args) + args.runtimes = [args.runtime] + return [sim] diff --git a/packages/modsim/modsim/hub.py b/packages/modsim/modsim/hub.py new file mode 100644 index 0000000..076efba --- /dev/null +++ b/packages/modsim/modsim/hub.py @@ -0,0 +1,42 @@ +"""Bounded requests to ModioHub, with a tool session token when there is one.""" + +import json +from typing import Any +from urllib.error import HTTPError, URLError +from urllib.request import Request, urlopen + +from modpoll_wot.loading import MAX_BYTES # type: ignore[import-untyped] + +from . import __version__ + +TIMEOUT = 15 + + +def call( + url: str, *, method: str = "GET", body: Any = None, token: str | None = None +) -> tuple[int, bytes]: + """One request; returns the status and at most 1 MiB of the answer. An error status is a result.""" + headers = {"User-Agent": f"modsim/{__version__}", "Accept": "application/json"} + if token: + headers["Authorization"] = f"Bearer {token}" + data = None + if body is not None: + data = json.dumps(body).encode() + headers["Content-Type"] = "application/json" + request = Request(url, data=data, headers=headers, method=method) + try: + with urlopen(request, timeout=TIMEOUT) as response: + return response.status, response.read(MAX_BYTES + 1)[:MAX_BYTES] + except HTTPError as error: + return error.code, error.read(MAX_BYTES + 1)[:MAX_BYTES] + except (URLError, TimeoutError, OSError) as exc: + raise ValueError(f"Could not reach {url}: {exc}") from exc + + +def call_json(url: str, **options: Any) -> tuple[int, dict]: + status, payload = call(url, **options) + try: + document = json.loads(payload) + except ValueError: + document = {} + return status, document if isinstance(document, dict) else {} diff --git a/packages/modsim/modsim/login.py b/packages/modsim/modsim/login.py new file mode 100644 index 0000000..227cbb2 --- /dev/null +++ b/packages/modsim/modsim/login.py @@ -0,0 +1,168 @@ +"""Sign in to ModioHub with the browser authorization flow (OAuth device authorization grant, RFC 8628). + +``modsim login`` asks for a code, the user confirms it in the browser, and the tool session token that comes +back is kept in the credentials file shared with modpoll (see modpoll_wot.session). ``modsim logout`` removes it. +""" + +import os +import shutil +import subprocess +import sys +import time +import webbrowser +from typing import Any, Callable, Mapping, TextIO + +import modpoll_wot # type: ignore[import-untyped] + +from .hub import call_json + +CLIENT_ID = "modsim" +GRANT_TYPE = "urn:ietf:params:oauth:grant-type:device_code" + + +class LoginError(ValueError): + """The login did not complete; the message says why and what to do.""" + + +def open_in_browser( + url: str, + *, + environ: Mapping[str, str] | None = None, + platform: str | None = None, + run: Callable[..., Any] = subprocess.run, + which: Callable[[str], str | None] = shutil.which, +) -> bool: + """Try to open an address in a browser; False means the user has to open it from the printed link. + + Where there is no desktop (SSH, a minimal WSL) nothing is tried, and the opener's own complaints + never reach the terminal. + """ + environ = os.environ if environ is None else environ + platform = platform or sys.platform + if environ.get("BROWSER") or platform in ("darwin", "win32"): + return webbrowser.open(url) + if not (environ.get("DISPLAY") or environ.get("WAYLAND_DISPLAY")) or environ.get( + "SSH_CONNECTION" + ): + return False + opener = which("xdg-open") + if not opener: + return False + try: + return bool( + run( + [opener, url], + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL, + timeout=10, + ).returncode + == 0 + ) + except (OSError, subprocess.SubprocessError): + return False + + +def login( + server: str, + *, + sleep: Callable[[float], Any] | None = None, + monotonic: Callable[[], float] | None = None, + open_browser: Callable[[str], bool] | None = None, + out: TextIO | None = None, +) -> Any: + """Run the flow against a server; returns the saved Session.""" + sleep, monotonic = sleep or time.sleep, monotonic or time.monotonic + open_browser, out = open_browser or open_in_browser, out or sys.stdout + status, grant = call_json( + f"{server}/api/v1/tool-sessions/device-authorization", + method="POST", + body={"client_id": CLIENT_ID}, + ) + if status != 200: + raise LoginError(f"{server} refused the login ({status})") + print( + f"To sign in, confirm the code {grant['user_code']} at:\n {grant['verification_uri_complete']}", + file=out, + flush=True, + ) + # A browser opens only where one can; otherwise the address and code above are all there is. + if not open_browser(grant["verification_uri_complete"]): + print( + "Open the address above in a browser on any computer, then wait here.", + file=out, + flush=True, + ) + interval = grant["interval"] + deadline = monotonic() + grant["expires_in"] + while monotonic() < deadline: + sleep(interval) + status, body = call_json( + f"{server}/api/v1/tool-sessions/token", + method="POST", + body={ + "grant_type": GRANT_TYPE, + "device_code": grant["device_code"], + "client_id": CLIENT_ID, + }, + ) + if status == 200: + return _save(server, body) + error = body.get("error") + if error == "authorization_pending": + continue + if error == "slow_down": + interval += 5 + continue + if error == "access_denied": + raise LoginError("The login was denied in the browser.") + if error == "expired_token": + break + raise LoginError(f"The login failed ({error or status}).") + raise LoginError( + "The code expired before it was confirmed; run modsim login again." + ) + + +def _save(server: str, body: dict) -> Any: + token = body["access_token"] + status, me = call_json(f"{server}/api/v1/me", token=token) + modpoll_wot.save_session( + server, + token, + expires_in=body["expires_in"], + github_user=me.get("githubUser") if status == 200 else None, + ) + return modpoll_wot.load_session(server) + + +def command(arguments: list[str], *, out: TextIO | None = None) -> int: + """``login`` or ``logout`` with an optional ``--server``; returns the exit code.""" + out = out or sys.stdout + name, rest = arguments[0], arguments[1:] + try: + if rest[:1] == ["--server"] and len(rest) == 2: + server = modpoll_wot.server_url({"MODIOHUB_URL": rest[1]}) + elif not rest: + server = modpoll_wot.active_server() + else: + raise LoginError(f"usage: modsim {name} [--server URL]") + if name == "logout": + if modpoll_wot.forget_session(server): + print( + f"Signed out of {server} on this computer. The token stays valid on the server until it expires; revoke it in Settings to end it now.", + file=out, + ) + else: + print(f"No stored login for {server}.", file=out) + return 0 + try: + session = login(server, out=out) + except KeyboardInterrupt: + print("\nLogin cancelled.", file=sys.stderr) + return 130 + who = f" as @{session.github_user}" if session.github_user else "" + print(f"Signed in to {server}{who}. modpoll uses the same login.", file=out) + return 0 + except (LoginError, modpoll_wot.CredentialError) as exc: + print(str(exc), file=sys.stderr) + return 1 diff --git a/packages/modsim/modsim/main.py b/packages/modsim/modsim/main.py new file mode 100644 index 0000000..a972e99 --- /dev/null +++ b/packages/modsim/modsim/main.py @@ -0,0 +1,363 @@ +#!/usr/bin/env python3 +"""Modbus simulator server and process lifecycle.""" + +import sys +import json +import ssl +import asyncio +import socket +import signal +import logging +from contextlib import suppress +from typing import Any + +from pymodbus.pdu.device import ModbusDeviceIdentification +from pymodbus.server import ( + ModbusSerialServer, + ModbusTcpServer, + ModbusTlsServer, + ModbusUdpServer, + ServerAsyncStop, +) +from pymodbus.simulator import DataType, SimData, SimDevice + +from . import __version__ +from .compat import BinaryPayloadBuilder, Endian +from .utils import get_commandline, get_utc_time, get_logger +from .virtual_serial import VirtualSerialPair + +SERIAL_PARITY = {"none": "N", "even": "E", "odd": "O"} + +_logger = logging.getLogger(__name__) + + +def setup_server(args: Any) -> Any: + """Run server setup.""" + # The datastores only respond to the addresses that are initialized + # If you initialize a DataBlock to addresses of 0x00 to 0xFF, a request to + # 0x100 will respond with an invalid address exception. + # This is because many devices exhibit this kind of behavior (but not all) + if getattr(args, "config", None): + from .deployment import configure_devices + + args.context = configure_devices(args) + _logger.info( + "Model initialization: %s", + json.dumps(args.model_initialization, sort_keys=True), + ) + if not args.context: + _logger.info("Create datastore") + # build your payload + co_builder = BinaryPayloadBuilder(byteorder=Endian.BIG, wordorder=Endian.BIG) + # address=0, bytes=3 + for _ in range(3): + # The bits within each byte are big-endian + # The coils status (from the first position) = [1,0,1,0,0,0,0,1] + co_builder.add_bits([True, False, True, False, False, False, False, True]) + + hr_builder = BinaryPayloadBuilder(byteorder=Endian.BIG, wordorder=Endian.BIG) + # address=0, bytes=8 + hr_builder.add_16bit_uint(1) + hr_builder.add_16bit_uint(2) + hr_builder.add_16bit_uint(3) + hr_builder.add_16bit_uint(4) + # address=8, bytes=8 + hr_builder.add_16bit_int(-1) + hr_builder.add_16bit_int(-2) + hr_builder.add_16bit_int(-3) + hr_builder.add_16bit_int(-4) + # address=16, bytes=8 + hr_builder.add_32bit_uint(12345678) + hr_builder.add_32bit_uint(12345678) + # address=24, bytes=8 + hr_builder.add_32bit_int(-12345678) + hr_builder.add_32bit_int(-12345678) + # address=32, bytes=8 + hr_builder.add_32bit_float(12.34) + hr_builder.add_32bit_float(-12.34) + # address=40, bytes=8 + hr_builder.add_64bit_uint(12345678900) + # address=48, bytes=8 + hr_builder.add_64bit_int(-12345678900) + # address=56, bytes=16 + hr_builder.add_64bit_float(123.45) + hr_builder.add_64bit_float(-123.45) + # address=72, bytes=? + hr_builder.add_string("this is a string") + + # use that payload in the data store + co_values = co_builder.to_coils() + hr_values = hr_builder.to_registers() + args.context = SimDevice( + id=0, + simdata=( + [SimData(0, values=co_values, datatype=DataType.BITS)], + [SimData(10000, values=co_values, datatype=DataType.BITS)], + [SimData(40000, values=hr_values, datatype=DataType.REGISTERS)], + [SimData(30000, values=hr_values, datatype=DataType.REGISTERS)], + ), + ) + + # initialize the server information + # If you don't set this or any fields, they are defaulted to empty strings. + args.identity = ModbusDeviceIdentification( + info_name={ + "VendorName": "Pymodbus", + "ProductCode": "PM", + "VendorUrl": "https://github.com/riptideio/pymodbus/", + "ProductName": "Pymodbus Server", + "ModelName": "Pymodbus Server", + } + ) + return args + + +def privileged_port_hint(port: Any) -> str: + """Explain how to listen on a port the operating system reserves.""" + return ( + f"Port {port} needs administrator rights on this system. Run the same " + 'command with sudo; with uvx that is sudo "$(command -v uvx)" followed by ' + "the rest of the command. Or listen on a port above 1023, for example " + "--port 5020, and point the client at it (modpoll --tcp-port 5020)." + ) + + +def require_bindable(host: str, port: Any, kind: int = socket.SOCK_STREAM) -> None: + """Fail early with a clear message when binding needs elevated rights.""" + with socket.socket(socket.AF_INET, kind) as probe: + try: + probe.bind((host, int(port))) + except PermissionError as exc: + raise OSError(privileged_port_hint(port)) from exc + except OSError: + # Occupied ports and other failures are reported by the server itself. + return + + +def read_command(args: Any, port: str) -> str: + """The modpoll command that reads this simulator over its virtual serial port.""" + parts = ["modpoll"] + if getattr(args, "config", None): + parts += ["--config", args.config] + parts += ["--serial", port, "--serial-baud", str(args.serial_baud)] + if args.serial_parity != "none": + parts += ["--serial-parity", args.serial_parity] + if getattr(args, "unit_id", None) is not None: + parts += ["--unit-id", str(args.unit_id)] + return " ".join(parts) + + +async def serve_serial(args: Any) -> None: + pair = None + port = args.port + if port == "pty": + pair = VirtualSerialPair(getattr(args, "serial_link", None)) + pair.open(asyncio.get_running_loop()) + port = pair.server_port + _logger.info("Virtual serial port for the client: %s", pair.client_port) + if getattr(args, "serial_link", None): + _logger.info("Also linked as %s", args.serial_link) + _logger.info("Read it with: %s", read_command(args, pair.client_port)) + server: Any = ModbusSerialServer( + context=args.context, + identity=args.identity, + port=port, + framer=args.framer, + baudrate=args.serial_baud, + parity=SERIAL_PARITY[args.serial_parity], + ) + if hasattr(args, "runtimes"): + from .runtime import RuntimeContext + + server.context = RuntimeContext(args.runtimes) + tasks: list = [] + try: + if not await server.listen(): + raise OSError("Could not open serial port %s" % port) + tasks = [ + asyncio.create_task(device.run()) + for device in getattr(args, "runtimes", []) + ] + await asyncio.gather(server.serving, *tasks) + finally: + for task in tasks: + task.cancel() + await asyncio.gather(*tasks, return_exceptions=True) + await server.shutdown() + if pair is not None: + pair.close() + + +async def run_async_server(args: Any) -> Any: + """Run server.""" + txt = f"Start ASYNC server, listening on {args.port} - {args.comm}" + _logger.info(txt) + server: Any + if args.comm == "tcp": + address: tuple[str, int] = ( + getattr(args, "bind", None) + or ("127.0.0.1" if getattr(args, "runtimes", None) else ""), + args.port, + ) + require_bindable(address[0], args.port) + server = ModbusTcpServer( + context=args.context, + identity=args.identity, + address=address, + framer=args.framer, + ) + if hasattr(args, "runtimes"): + from .runtime import RuntimeContext + + server.context = RuntimeContext(args.runtimes) + tasks = [] + try: + if not await server.listen(): + raise OSError( + "Could not start Modbus TCP listener on port %s" % args.port + ) + tasks = [ + asyncio.create_task(device.run()) + for device in getattr(args, "runtimes", []) + ] + await asyncio.gather(server.serving, *tasks) + finally: + for task in tasks: + task.cancel() + await asyncio.gather(*tasks, return_exceptions=True) + await server.shutdown() + return server + elif args.comm == "udp": + address = ("127.0.0.1", args.port) + require_bindable(address[0], args.port, socket.SOCK_DGRAM) + server = ModbusUdpServer( + context=args.context, + identity=args.identity, + address=address, + framer=args.framer, + ) + try: + if not await server.listen(): + raise OSError( + "Could not start Modbus UDP listener on port %s" % args.port + ) + await server.serving + finally: + await server.shutdown() + return server + elif args.comm == "serial": + return await serve_serial(args) + elif args.comm == "tls": + address = ("", args.port) + require_bindable(address[0], args.port) + # Create SSL context from cert and key files + sslctx = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH) + try: + sslctx.load_cert_chain( + certfile="certificates/pymodbus.crt", + keyfile="certificates/pymodbus.key", + ) + except OSError as exc: + raise OSError( + "TLS needs certificates/pymodbus.crt and certificates/pymodbus.key " + f"in the working directory: {exc}" + ) from exc + + server = ModbusTlsServer( + context=args.context, + identity=args.identity, + address=address, + framer=args.framer, + sslctx=sslctx, + ) + try: + if not await server.listen(): + raise OSError( + "Could not start Modbus TLS listener on port %s" % args.port + ) + await server.serving + finally: + await server.shutdown() + return server + raise ValueError(f"Unknown communication type: {args.comm}") + + +def app() -> None: + from .commands import ACTIONS, run + from .login import command + + if sys.argv[1:2] in (["login"], ["logout"]): + raise SystemExit(command(sys.argv[1:])) + if len(sys.argv) > 1 and sys.argv[1] in ACTIONS: + run(sys.argv[1:]) + return + args = get_commandline() + global _logger + _logger = get_logger(args.log) + _logger.info( + f"Starting modsim v{__version__} at {get_utc_time().strftime('%Y-%m-%d %H:%M:%S')} UTC" + ) + + try: + run_args = setup_server(args) + except (ValueError, OSError) as exc: + _logger.error("Invalid model configuration: %s", exc) + raise SystemExit(2) from exc + try: + asyncio.run(_run_server_with_signals(run_args), debug=args.log == "debug") + except OSError as exc: + _logger.error("%s", exc) + raise SystemExit(2) from exc + + _logger.info("exiting.") + + +async def _run_server_with_signals(args: Any) -> None: + """Run the server and close its listener when the process is signaled.""" + loop = asyncio.get_running_loop() + server_task = asyncio.create_task(run_async_server(args)) + stop_requested = False + + async def stop_server() -> None: + for _ in range(100): + if server_task.done(): + return + try: + await ServerAsyncStop() + return + except (AttributeError, RuntimeError): + await asyncio.sleep(0.01) + + def request_stop() -> None: + nonlocal stop_requested + if not stop_requested: + stop_requested = True + if args.comm in ("tcp", "udp", "tls", "serial"): + server_task.cancel() + else: + loop.create_task(stop_server()) + + installed_signals = [] + for signum in (signal.SIGINT, signal.SIGTERM): + try: + loop.add_signal_handler(signum, request_stop) + installed_signals.append(signum) + except (NotImplementedError, RuntimeError): + pass + + try: + await server_task + except asyncio.CancelledError: + if not stop_requested: + raise + finally: + for signum in installed_signals: + loop.remove_signal_handler(signum) + if not server_task.done(): + server_task.cancel() + with suppress(asyncio.CancelledError): + await server_task + + +if __name__ == "__main__": + app() diff --git a/packages/modsim/modsim/management.py b/packages/modsim/modsim/management.py new file mode 100644 index 0000000..43f84a4 --- /dev/null +++ b/packages/modsim/modsim/management.py @@ -0,0 +1,311 @@ +"""Local deployment supervision and atomic device reconciliation (POSIX).""" + +import asyncio +from contextlib import suppress +import hashlib +import json +import logging +import os +from pathlib import Path +import signal +import stat +import tempfile +from typing import Any + +from pymodbus.simulator import DataType, SimData, SimDevice +from pymodbus.server import ModbusTcpServer + +from .manifest import Deployment, Instance, load_deployment +from .runtime import RuntimeContext + +LOG = logging.getLogger(__name__) +MAX_REQUEST = 8192 + + +def paths(name: str) -> tuple[Path, Path, Path]: + """Use a per-user private directory and a short, name-derived socket path.""" + if os.name != "posix": + raise ValueError("managed commands currently require POSIX (Linux/macOS/WSL)") + root = Path(tempfile.gettempdir()) / f"modsim-{os.getuid()}" + root.mkdir(mode=0o700, exist_ok=True) + info = root.lstat() + if not stat.S_ISDIR(info.st_mode) or info.st_uid != os.getuid(): + raise ValueError("unsafe runtime directory") + if stat.S_IMODE(info.st_mode) != 0o700: + raise ValueError("runtime directory must have permissions 0700") + key = hashlib.sha256(name.encode()).hexdigest()[:24] + return root / f"{key}.sock", root / f"{key}.lock", root / f"{key}.log" + + +class RuntimeManager: + """Own live devices and their tasks; commits never yield to protocol access.""" + + def __init__(self, allow_scripts: bool = False) -> None: + self.allow_scripts = allow_scripts + self.deployment: Deployment | None = None + self.context = RuntimeContext([]) + self.instances: dict[str, Instance] = {} + self.devices: dict[str, Any] = {} + self.tasks: dict[str, asyncio.Task] = {} + self.errors: dict[str, str] = {} + self.lock = asyncio.Lock() + + def plan(self, desired: Deployment) -> dict: + if self.deployment: + if desired.path != self.deployment.path: + raise ValueError("deployment name belongs to a different file") + if desired.name != self.deployment.name: + raise ValueError("deployment name cannot change") + if (desired.bind, desired.port) != ( + self.deployment.bind, + self.deployment.port, + ): + raise ValueError("listener changed; run down before up") + added, replaced, kept = [], [], [] + for key, item in desired.instances.items(): + old = self.instances.get(key) + if old is None: + added.append(key) + elif item.td["id"] != old.td["id"]: + raise ValueError( + f"{key}: TD id changed; remove the device before recreating" + ) + elif item.fingerprint != old.fingerprint: + replaced.append(key) + else: + kept.append(key) + return { + "added": added, + "replaced": replaced, + "removed": sorted(self.instances.keys() - desired.instances.keys()), + "kept": kept, + } + + async def apply(self, desired: Deployment, dry_run: bool = False) -> dict: + plan = self.plan(desired) + # Only changed candidates initialize; repeated up cannot rerun live hooks. + # Building validates schemas and executes behavior scripts; keep it off the + # event loop so Modbus clients of the running devices are still served. + candidates = { + key: await asyncio.to_thread( + desired.instances[key].build, self.allow_scripts, preview=dry_run + ) + for key in plan["added"] + plan["replaced"] + } + if dry_run: + return plan + retired = [self.tasks[key] for key in plan["removed"] + plan["replaced"]] + next_devices = { + key: candidates[key] if key in candidates else self.devices[key] + for key in desired.instances + } + next_tasks = {key: self.tasks[key] for key in plan["kept"]} + for key, device in candidates.items(): + next_tasks[key] = asyncio.create_task(self.run_device(key, device)) + # The supported datastore operations and hooks do not suspend. Swapping + # this registry in the same event loop is also atomic across write echoes. + self.context.devices = { + device.unit_id: device + for key, device in next_devices.items() + if key not in self.errors or key in candidates + } + for task in retired: + task.cancel() + self.instances = desired.instances + self.devices = next_devices + self.tasks = next_tasks + self.errors = { + key: self.errors[key] for key in plan["kept"] if key in self.errors + } + self.deployment = desired + await asyncio.gather(*retired, return_exceptions=True) + LOG.info("Deployment applied: %s", plan) + return plan + + async def run_device(self, key: str, device: Any) -> None: + try: + await device.run() + except Exception as exc: + self.errors[key] = str(exc) + # An invalid behavior must not keep serving apparently healthy data. + self.context.devices.pop(device.unit_id, None) + LOG.exception("Device %s failed; other devices remain online", key) + + async def reset(self, key: str) -> dict: + if key not in self.instances: + raise ValueError(f"unknown device: {key}") + candidate = self.instances[key].build(self.allow_scripts) + old = self.tasks[key] + self.context.devices[candidate.unit_id] = candidate + self.devices[key] = candidate + self.tasks[key] = asyncio.create_task(self.run_device(key, candidate)) + self.errors.pop(key, None) + old.cancel() + await asyncio.gather(old, return_exceptions=True) + return {"reset": key} + + def status(self) -> dict: + return { + "running": True, + "name": self.deployment.name if self.deployment else None, + "source": str(self.deployment.path) if self.deployment else None, + "pid": os.getpid(), + "devices": [ + { + "id": key, + "tdId": self.instances[key].td["id"], + "unitId": device.unit_id, + "state": "failed" if key in self.errors else "running", + "error": self.errors.get(key), + } + for key, device in self.devices.items() + ], + } + + async def close(self) -> None: + self.context.devices = {} + for task in self.tasks.values(): + task.cancel() + await asyncio.gather(*self.tasks.values(), return_exceptions=True) + + +async def request(name: str, message: dict) -> dict: + socket_path, _, _ = paths(name) + reader, writer = await asyncio.wait_for( + asyncio.open_unix_connection(str(socket_path), limit=2 * 254 * 1024 * 1024), 5 + ) + try: + writer.write(json.dumps(message).encode() + b"\n") + await writer.drain() + payload = await asyncio.wait_for(reader.readline(), 60) + if not payload: + raise ConnectionError("management connection closed") + response = json.loads(payload) + if "error" in response: + raise ValueError(response["error"]) + return response # type: ignore[no-any-return] + finally: + writer.close() + await writer.wait_closed() + + +async def serve( + path: Path, allow_scripts: bool = False, *, detached: bool = False +) -> None: + """Hold the deployment lock through listener and task shutdown.""" + import fcntl + + desired = await asyncio.to_thread(load_deployment, path) + socket_path, lock_path, log_path = paths(desired.name) + with lock_path.open("a") as lease: + try: + fcntl.flock(lease, fcntl.LOCK_EX | fcntl.LOCK_NB) + except BlockingIOError as exc: + raise ValueError( + "deployment is already starting or running; retry up" + ) from exc + manager = RuntimeManager(allow_scripts) + stop = asyncio.Event() + server: Any = ModbusTcpServer( + context=SimDevice( + id=0, + simdata=[SimData(0, datatype=DataType.INVALID)], + ), + address=(desired.bind, desired.port), + ) + server.context = manager.context + control = None + handlers: set[asyncio.Task] = set() + loop = asyncio.get_running_loop() + signals = [] + file_handler = None + if not detached: + file_handler = logging.FileHandler(log_path) + os.chmod(log_path, 0o600) + logging.getLogger().addHandler(file_handler) + + async def handle( + reader: asyncio.StreamReader, writer: asyncio.StreamWriter + ) -> None: + task = asyncio.current_task() + if task is not None: + handlers.add(task) + try: + # Read before locking so an idle connection cannot stall other commands. + payload = await asyncio.wait_for(reader.readline(), 5) + message = json.loads(payload) + if message.get("source") != str(desired.path): + raise ValueError("deployment name belongs to a different file") + action = message.get("action") + async with manager.lock: + if action == "up": + if message.get("allow_scripts") and not manager.allow_scripts: + raise ValueError( + "script permission requires down, then up --allow-scripts" + ) + candidate = await asyncio.to_thread( + load_deployment, desired.path + ) + result = await manager.apply( + candidate, bool(message.get("dry_run")) + ) + elif action == "ps": + result = manager.status() + elif action == "reset": + result = await manager.reset(message.get("device", "")) + elif action == "export": + result = { + "tds": { + key: item.td for key, item in manager.instances.items() + } + } + elif action == "down": + result = {"stopping": True} + stop.set() + else: + raise ValueError("unknown management action") + response = result + except Exception as exc: + response = {"error": str(exc)} + try: + writer.write(json.dumps(response).encode() + b"\n") + await writer.drain() + finally: + writer.close() + with suppress(ConnectionError): + await writer.wait_closed() + if task is not None: + handlers.discard(task) + + try: + await manager.apply(desired) + if not await server.listen(): + raise OSError(f"cannot listen on {desired.bind}:{desired.port}") + # The lease proves that a leftover socket cannot belong to a live owner. + socket_path.unlink(missing_ok=True) + control = await asyncio.start_unix_server( + handle, path=str(socket_path), limit=MAX_REQUEST + ) + os.chmod(socket_path, 0o600) + for signum in (signal.SIGINT, signal.SIGTERM): + loop.add_signal_handler(signum, stop.set) + signals.append(signum) + LOG.info( + "Deployment %s ready at %s:%s", desired.name, desired.bind, desired.port + ) + await stop.wait() + finally: + if control: + control.close() + await control.wait_closed() + for task in list(handlers): + task.cancel() + await asyncio.gather(*handlers, return_exceptions=True) + for signum in signals: + loop.remove_signal_handler(signum) + await manager.close() + await server.shutdown() + socket_path.unlink(missing_ok=True) + if file_handler: + logging.getLogger().removeHandler(file_handler) + file_handler.close() diff --git a/packages/modsim/modsim/manifest.py b/packages/modsim/modsim/manifest.py new file mode 100644 index 0000000..83f794e --- /dev/null +++ b/packages/modsim/modsim/manifest.py @@ -0,0 +1,296 @@ +"""Deployment v2: bounded YAML, TM instantiation and immutable input snapshots.""" + +from argparse import Namespace +from dataclasses import dataclass +import copy +import hashlib +import json +from pathlib import Path +from typing import Any + +import yaml # type: ignore[import-untyped] +from jsonschema import Draft7Validator # type: ignore[import-untyped] +from modpoll_wot import ( # type: ignore[import-untyped] + export_td, + load_simulation_data, + parse_model, +) +from modpoll_wot.loading import MAX_BYTES, load_document # type: ignore[import-untyped] + +from .deployment import STRING, obj +from .sources import local_path, model_document + + +class DeploymentLoader(yaml.SafeLoader): # type: ignore[no-any-unimported] + """Reject aliases and duplicate keys rather than expanding ambiguous YAML.""" + + def compose_node(self, parent: Any, index: Any) -> Any: + if self.check_event(yaml.AliasEvent): + raise ValueError("YAML aliases are unsupported") + depth = getattr(self, "deployment_depth", 0) + if depth >= 64: + raise ValueError("deployment nesting exceeds 64 containers") + self.deployment_depth = depth + 1 + try: + return super().compose_node(parent, index) + finally: + self.deployment_depth = depth + + def construct_mapping(self, node: Any, deep: bool = False) -> dict: + result = {} + for key_node, value_node in node.value: + key = self.construct_object(key_node, deep=deep) + if not isinstance(key, str): + raise ValueError("YAML object keys must be strings") + if key in result: + raise ValueError(f"duplicate YAML key: {key}") + result[key] = self.construct_object(value_node, deep=deep) + return result + + +IDENTIFIER = {"type": "string", "pattern": "^[a-z0-9][a-z0-9-]{0,63}$"} +MANIFEST = obj( + { + "version": {"const": 2}, + "name": IDENTIFIER, + "server": obj( + { + "bind": STRING, + "port": {"type": "integer", "minimum": 1, "maximum": 65535}, + } + ), + "devices": { + "type": "array", + "maxItems": 254, + "items": obj( + { + "id": IDENTIFIER, + "model": STRING, + "parameters": {"type": "object"}, + "data": STRING, + "script": STRING, + "scriptParameters": {"type": "object"}, + }, + ("id", "model"), + ), + }, + }, + ("version", "devices"), +) + + +def canonical(value: Any) -> bytes: + return json.dumps( + value, + sort_keys=True, + ensure_ascii=False, + allow_nan=False, + separators=(",", ":"), + ).encode("utf-8") + + +def read_yaml(path: Path) -> dict: + """Read JSON or safe YAML with bounded size, depth and JSON-compatible values.""" + if path.suffix.lower() == ".json": + value = load_document(path) + else: + with path.open("rb") as stream: + payload = stream.read(MAX_BYTES + 1) + if len(payload) > MAX_BYTES: + raise ValueError("deployment exceeds 1 MiB") + try: + value = yaml.load(payload, Loader=DeploymentLoader) + except yaml.YAMLError as exc: + raise ValueError(f"{path}: invalid YAML: {exc}") from exc + if not isinstance(value, dict): + raise ValueError(f"{path}: expected an object") + try: + canonical(value) + except (TypeError, ValueError, RecursionError) as exc: + raise ValueError(f"{path}: expected finite JSON-compatible values") from exc + return value + + +def validate(value: dict, schema: dict) -> None: + errors = sorted( + Draft7Validator(schema).iter_errors(value), key=lambda e: str(e.path) + ) + if errors: + error = errors[0] + raise ValueError(f"{'/'.join(map(str, error.path))}: {error.message}") + + +@dataclass +class Instance: + id: str + td: dict + model: Any + fingerprint: str + data: dict + script_path: str | None + script_source: bytes | None + script_parameters: dict + + def build(self, allow_scripts: bool = False, *, preview: bool = False) -> Any: + """Construct isolated state from this snapshot, without reopening inputs.""" + from .deployment import apply_data + from .wot import configure + + if self.script_source is not None: + if not allow_scripts: + raise ValueError("Python behavior scripts require --allow-scripts") + if preview: + compile(self.script_source, self.script_path or "<behavior>", "exec") + args = Namespace( + prepared_model=self.model, + initial=[], + data=None, + data_spec=copy.deepcopy(self.data), + script=None if preview else self.script_path, + script_source=self.script_source, + script_parameters=copy.deepcopy(self.script_parameters), + allow_scripts=allow_scripts, + ) + configure(args) + args.runtime.name = self.id + apply_data(args) + return args.runtime + + +@dataclass +class Deployment: + path: Path + name: str + bind: str + port: int + instances: dict[str, Instance] + + +def _is_modsim_project(directory: Path) -> bool: + try: + text = (directory / "pyproject.toml").read_text(encoding="utf-8") + except OSError: + return False + return '\nname = "modsim"\n' in text + + +def _is_git_root(directory: Path) -> bool: + marker = directory / ".git" + return marker.is_file() or (marker.is_dir() and any(marker.iterdir())) + + +def deployment_root(path: Path) -> Path: + """Use the repository root for checked-in examples, config directory otherwise. + + modsim's own examples resolve against the modsim project, which is the repository + root of a standalone checkout and packages/modsim inside the tools workspace. + """ + for parent in (path.parent, *path.parent.parents): + if _is_modsim_project(parent): + return parent + if _is_git_root(parent): + break + for parent in path.parent.parents: + marker = parent / ".git" + if marker.is_file() or (marker.is_dir() and any(marker.iterdir())): + return parent + marker = path.parent / ".git" + if marker.is_file() or (marker.is_dir() and any(marker.iterdir())): + return path.parent + return path.parent + + +def load_deployment(path: Path, *, include_data: bool = True) -> Deployment: + """Resolve and validate every instance before the runtime can be changed.""" + path = path.resolve() + if path.suffix.lower() not in (".yaml", ".yml"): + raise ValueError("deployment file must use .yaml or .yml") + spec = read_yaml(path) + validate(spec, MANIFEST) + name = spec.get("name", path.parent.name) + validate({"name": name}, obj({"name": IDENTIFIER}, ("name",))) + bind = spec.get("server", {}).get("bind", "127.0.0.1") + port = spec.get("server", {}).get("port", 5020) + root = deployment_root(path) + instances: dict[str, Instance] = {} + units: set[int] = set() + identities: set[str] = set() + for item in spec["devices"]: + key = item["id"] + if key in instances: + raise ValueError(f"duplicate device id: {key}") + source = item["model"] + if not source.startswith("https://"): + source = local_path(root, source) + document = model_document(source) + if not isinstance(document, dict): + raise ValueError(f"{key}: model must be an object") + types = document.get("@type", []) + if isinstance(types, str): + types = [types] + if "tm:ThingModel" not in types: + raise ValueError(f"{key}: deployment v2 requires a TM; use --config for TD") + parameters = dict(item.get("parameters", {})) + if "AUTHORITY" in parameters: + raise ValueError( + "use HOST and PORT; AUTHORITY is derived by the interpreter" + ) + # A TM need not declare a Thing ID. An explicit instance binding may + # provide it without changing the reusable model or inventing identity. + if "THING_ID" in parameters and "id" not in document: + document = copy.deepcopy(document) + document["id"] = "{{THING_ID}}" + host = parameters.pop("HOST", None) + if host is None: + if bind in ("0.0.0.0", "::", "*"): + raise ValueError(f"{key}: wildcard listener requires parameters.HOST") + host = bind + instance_port = parameters.pop("PORT", port) + unit = parameters.pop("UNIT_ID", None) + if not isinstance(host, str): + raise ValueError(f"{key}: HOST must be a string") + td = export_td( + document, host=host, port=instance_port, unit_id=unit, parameters=parameters + ) + if len(canonical(td)) > MAX_BYTES: + raise ValueError(f"{key}: generated TD exceeds 1 MiB") + model = parse_model(td) + identity = td.get("id") + if not isinstance(identity, str) or not identity: + raise ValueError(f"{key}: TM must instantiate a stable TD id") + if identity in identities or model.unit_id in units: + raise ValueError(f"{key}: duplicate TD id or Unit ID") + units.add(model.unit_id) + identities.add(identity) + data: dict = {} + script_path, script_source = None, None + if include_data and item.get("data"): + data = load_simulation_data( + read_yaml(Path(local_path(root, item["data"]))), + title=model.title, + properties=json.loads(model.properties_json).keys(), + ).data + if include_data and item.get("script"): + script_path = local_path(root, item["script"]) + # Scripts execute with the simulator's rights; keep them with the deployment. + if not Path(script_path).is_relative_to(root.resolve()): + raise ValueError(f"{key}: script must stay inside {root}") + with Path(script_path).open("rb") as stream: + script_source = stream.read(MAX_BYTES + 1) + if len(script_source) > MAX_BYTES: + raise ValueError("script exceeds 1 MiB") + script_parameters = dict(item.get("scriptParameters", {})) + fingerprint = hashlib.sha256( + canonical([item, document, td, data, script_path]) + (script_source or b"") + ).hexdigest() + instances[key] = Instance( + key, + td, + model, + fingerprint, + data, + script_path, + script_source, + script_parameters, + ) + return Deployment(path, name, bind, port, instances) diff --git a/packages/modsim/modsim/runtime.py b/packages/modsim/modsim/runtime.py new file mode 100644 index 0000000..dda5730 --- /dev/null +++ b/packages/modsim/modsim/runtime.py @@ -0,0 +1,267 @@ +"""Independent device state, local behavior hooks and atomic protocol access.""" + +import asyncio +import importlib.util +import inspect +import logging +import math +import random +from typing import AbstractSet, Any + +from pymodbus.constants import ExcCodes + +from .wot import FUNCTIONS +from .codec import Codec + +_LOG = logging.getLogger(__name__) + + +class Device: + """Property API for profile 0.2 wire mappings. + + Internal updates can change read-only measurements; Modbus writes cannot. + Hooks are synchronous and must not block. Each instance has its own module. + """ + + def __init__(self, model: Any, cells: Any, schemas: Any, access: Any) -> None: + self.unit_id = model.unit_id + self.name = model.title + self.cells = cells + self.access = access + self.schemas = schemas + self.members = { + member.property: (group, member) + for group in model.groups + for member in group.members + } + self.codecs = { + name: Codec(group, member, schemas[name]) + for name, (group, member) in self.members.items() + } + self.write_masks: dict[str, dict[int, int]] = {} + self.random = random.Random(0) + self.parameters: dict[str, Any] = {} + self.script: Any = None + self.tick_interval = 1.0 + self.generators: dict[str, Any] = {} + self.bindings: dict[str, str] = {} + self.write_policy = "hold" + self.held: set[str] = set() + # Previous raw values of cells changed by the write in progress, so a + # rejected write restores only what it touched. + self.journal: dict[tuple[str, int], Any] | None = None + + def get(self, name: str) -> Any: + """Read the current property value, including previous client writes.""" + return self.codecs[name].decode(self.cells) + + def set(self, name: str, value: Any) -> None: + """Update a measurement or output by property name.""" + self.set_many({name: value}) + + def affected(self, touched: AbstractSet[tuple[str, int]]) -> list[str]: + return [ + name + for name, codec in self.codecs.items() + if any( + (codec.table, i) in touched + for i in range(codec.start, codec.start + codec.span) + ) + ] + + def validate_cells(self, touched: AbstractSet[tuple[str, int]]) -> dict[str, Any]: + changes = {} + for name in self.affected(touched): + value = self.get(name) + self.codecs[name].validate(value) + changes[name] = value + return changes + + def set_many(self, values: dict[str, Any], *, initializing: bool = False) -> None: + """Validate spans and aliases before atomically committing raw cells.""" + updates: dict[tuple[str, int], tuple[int, int]] = {} + for name, value in values.items(): + if name not in self.codecs: + raise ValueError(f"{self.name}: unknown property {name}") + codec = self.codecs[name] + for offset, (raw, mask) in enumerate(codec.encode(value)): + key = (codec.table, codec.start + offset) + previous, owned = updates.get(key, (0, 0)) + if (previous ^ raw) & owned & mask: + raise ValueError(f"{name}: conflicting alias values") + updates[key] = ((previous & ~mask) | (raw & mask), owned | mask) + old = { + (table, address): self.cells[table][address] for table, address in updates + } + if self.journal is not None: + for key, raw in old.items(): + self.journal.setdefault(key, raw) + try: + for (table, address), (raw, mask) in updates.items(): + value = (int(self.cells[table][address]) & ~mask) | (raw & mask) + self.cells[table][address] = ( + bool(value) if table in ("coil", "discrete_input") else value + ) + if initializing: + for name in values: + self.codecs[name].validate(self.get(name)) + else: + self.validate_cells(set(updates)) + except Exception: + for (table, address), raw in old.items(): + self.cells[table][address] = raw + raise + + def hook(self, name: str, *args: Any) -> None: + callback = getattr(self.script, name, None) + if callback: + result = callback(self, *args) + if inspect.isawaitable(result): + if inspect.iscoroutine(result): + result.close() + raise ValueError(f"{name}: script hooks must be synchronous") + + def load_script(self, path: str, source: bytes | None = None) -> None: + spec = importlib.util.spec_from_file_location( + f"modsim_behavior_{self.unit_id}", path + ) + if spec is None or spec.loader is None: + raise ValueError(f"cannot load script: {path}") + self.script = importlib.util.module_from_spec(spec) + if source is None: + spec.loader.exec_module(self.script) + else: + exec(compile(source, path, "exec"), self.script.__dict__) + for name in ("initialize", "tick", "on_write"): + callback = getattr(self.script, name, None) + if callback is not None and ( + not callable(callback) or inspect.iscoroutinefunction(callback) + ): + raise ValueError(f"{path}: {name} must be a synchronous function") + + def advance(self, elapsed: float, dt: float) -> None: + values = {} + for name, rule in self.generators.items(): + if self.write_policy == "hold" and name in self.held: + continue + kind = rule["kind"] + if kind == "constant": + value = rule["value"] + elif kind == "sine": + value = rule["center"] + rule["amplitude"] * math.sin( + 2 * math.pi * elapsed / rule["period"] + ) + elif kind == "ramp": + value = rule["start"] + rule["rate"] * elapsed + value = min(rule["maximum"], max(rule["minimum"], value)) + elif kind == "noise": + value = ( + self.random.randint( + math.ceil(rule["minimum"]), math.floor(rule["maximum"]) + ) + if self.schemas[name].get("type") == "integer" + else self.random.uniform(rule["minimum"], rule["maximum"]) + ) + else: + raise ValueError(f"unknown generator: {kind}") + if self.schemas[name].get("type") == "integer" and type(value) is not bool: + value = round(value) + values[name] = value + self.set_many(values) + self.hook("tick", elapsed, dt) + self.apply_bindings() + + def apply_bindings(self) -> None: + """Copy sources to targets; under hold a client-written target stays put.""" + hold = self.write_policy == "hold" + self.set_many( + { + target: self.get(source) + for target, source in self.bindings.items() + if not (hold and target in self.held) + } + ) + + async def run(self) -> None: + loop = asyncio.get_running_loop() + start = previous = loop.time() + while True: + await asyncio.sleep(self.tick_interval) + now = loop.time() + try: + self.advance(now - start, now - previous) + except Exception: + _LOG.exception( + "Simulation failed for %s (Unit ID %s)", self.name, self.unit_id + ) + raise + previous = now + + +class RuntimeContext: + """Exact-address protocol boundary, isolated by Unit ID.""" + + def __init__(self, devices: list[Device]) -> None: + self.devices = {device.unit_id: device for device in devices} + + def device_ids(self) -> list[int]: + return list(self.devices) + + async def async_getValues( + self, device_id: int, func_code: int, address: int, count: int = 1 + ) -> Any: + device = self.devices.get(device_id) + if device is None: + return ExcCodes.GATEWAY_NO_RESPONSE + # PyModbus uses FC5/6 getValues internally to build the write echo; + # these are not protocol read operations and must support writeOnly. + if error := device.access(func_code, address, count, func_code in (5, 6)): + return error + table = FUNCTIONS[func_code] + return [device.cells[table][item] for item in range(address, address + count)] + + async def async_setValues( + self, + device_id: int, + func_code: int, + address: int, + values: list[int] | list[bool], + ) -> Any: + device = self.devices.get(device_id) + if device is None: + return ExcCodes.GATEWAY_NO_RESPONSE + if error := device.access(func_code, address, len(values), True): + return error + table = FUNCTIONS[func_code] + journal: dict[tuple[str, int], Any] = {} + device.journal = journal + held = device.held.copy() + try: + full_mask = 1 if table in ("coil", "discrete_input") else 65535 + for offset, value in enumerate(values): + current_address = address + offset + allowed = device.write_masks[table].get(current_address, 0) + current = int(device.cells[table][current_address]) + if (current ^ int(value)) & (full_mask ^ allowed): + raise ValueError("write changes read-only or unconfigured bits") + journal.setdefault( + (table, current_address), device.cells[table][current_address] + ) + device.cells[table][current_address] = value + touched = {(table, item) for item in range(address, address + len(values))} + changes = device.validate_cells(touched) + # Read-only aliases are re-decoded but not written, so their generators keep running. + device.held.update( + name for name in changes if device.codecs[name].member.writable + ) + device.hook("on_write", changes) + device.apply_bindings() + except Exception: + for (name, address), raw in journal.items(): + device.cells[name][address] = raw + device.held = held + _LOG.exception("Write rejected by device %s", device.name) + return ExcCodes.ILLEGAL_VALUE + finally: + device.journal = None + return None diff --git a/packages/modsim/modsim/sources.py b/packages/modsim/modsim/sources.py new file mode 100644 index 0000000..5bb5b92 --- /dev/null +++ b/packages/modsim/modsim/sources.py @@ -0,0 +1,103 @@ +"""Bounded local JSON and HTTPS model and simulation data loading.""" + +import hashlib +import tempfile +from pathlib import Path +from urllib.parse import urlparse +from urllib.request import Request, urlopen + +import modpoll_wot # type: ignore[import-untyped] +from modpoll_wot.loading import MAX_BYTES, load_document # type: ignore[import-untyped] + +from . import __version__ +from .hub import call, call_json + +# Some CDNs reject the default Python-urllib agent; identify the tool instead. +USER_AGENT = f"modsim/{__version__}" + + +def is_remote(value: str) -> bool: + return bool(urlparse(value).scheme) and not Path(value).is_absolute() + + +def local_path(base: Path, value: str) -> str: + if urlparse(value).scheme and not Path(value).is_absolute(): + raise ValueError(f"expected local path: {value}") + return str((base / value).resolve()) + + +def model_document(source: str) -> dict: + if source.startswith(modpoll_wot.REFERENCE_PREFIX): + return workspace_document(source) + if not is_remote(source): + return load_document(source) # type: ignore[no-any-return] + return remote_document(source) + + +def workspace_document(text: str) -> dict: + """A custom Thing Model version of the user's ModioHub Workspace: ``modiohub:<id>@<version>``. + + The login is used when there is one; a shared version can be read without it. The token only goes to the + server it was issued for, and the download is checked against the SHA-256 the server states. + """ + reference = modpoll_wot.parse_reference(text) + server = modpoll_wot.active_server() + session = modpoll_wot.load_session(server) + token = session.token if session else None + status, thing_model = call_json( + f"{server}/api/v1/thing-models/{reference.id}", token=token + ) + if status == 401: + raise ValueError("Your ModioHub login is no longer valid; run modsim login") + if status == 404: + raise ValueError( + f"No custom Thing Model {reference.id} is shared" + + (" or yours" if token else "; run modsim login if it is yours") + ) + if status != 200: + raise ValueError(f"{server} answered {status}") + versions = {str(item["version"]): item for item in thing_model["versions"]} + version = ( + thing_model["versions"][0] + if reference.version == "latest" + else versions.get(reference.version) + ) + if version is None: + raise ValueError(f"{text} has no version {reference.version}") + if not version["fileUrl"].startswith(server + "/"): + raise ValueError(f"{server} pointed to another address for {text}") + status, payload = call(version["fileUrl"], token=token) + if status != 200: + raise ValueError(f"{server} answered {status}") + if hashlib.sha256(payload).hexdigest() != version["sha256"]: + raise ValueError(f"{text} does not match the SHA-256 {server} reports for it") + return _bounded_document(payload) + + +def remote_document(source: str) -> dict: + """Load bounded JSON from an HTTPS URL with the shared loader's rules.""" + url = urlparse(source) + if url.scheme != "https": + raise ValueError("model and data URLs must use HTTPS") + if url.hostname == "github.com": + parts = url.path.strip("/").split("/") + if len(parts) >= 5 and parts[2] == "blob": + source = "https://raw.githubusercontent.com/" + "/".join( + parts[:2] + parts[3:] + ) + request = Request(source, headers={"User-Agent": USER_AGENT}) + with urlopen(request, timeout=15) as response: + if urlparse(response.geturl()).scheme != "https": + raise ValueError("redirect must use HTTPS") + payload = response.read(MAX_BYTES + 1) + if len(payload) > MAX_BYTES: + raise ValueError(f"document exceeds {MAX_BYTES} bytes") + return _bounded_document(payload) + + +def _bounded_document(payload: bytes) -> dict: + # Reuse all bounded JSON parsing rules from the public shared loader. + with tempfile.TemporaryDirectory(prefix="modsim-model-") as directory: + path = Path(directory) / "model.json" + path.write_bytes(payload) + return load_document(path) # type: ignore[no-any-return] diff --git a/packages/modsim/modsim/utils.py b/packages/modsim/modsim/utils.py new file mode 100644 index 0000000..5b95133 --- /dev/null +++ b/packages/modsim/modsim/utils.py @@ -0,0 +1,219 @@ +"""A collection of utility tools""" + +import argparse +import logging.config +from datetime import datetime, timezone +from typing import Any, Dict +from pymodbus.framer import ( + FramerType, +) + +from . import __version__, virtual_serial + +# Above 1023, so the first command needs no administrator rights. +DEFAULT_PORT = 5020 + +config: Dict[str, Any] = {} + + +def get_parser() -> argparse.ArgumentParser: + parser = argparse.ArgumentParser( + description=f"Modsim v{__version__} - A Simple Modbus TCP Device Simulator used for modpoll tool", + epilog="Managed commands: up, down, ps, logs, export, reset. Use modsim COMMAND --help. Sign in to ModioHub with modsim login.", + ) + parser.add_argument( + "-v", "--version", action="version", version=f"{__package__} v{__version__}" + ) + sources = parser.add_mutually_exclusive_group() + sources.add_argument( + "--config", + help="Profile 0.2 TM/TD local path, HTTPS URL, or modiohub:<id>@<version> for a custom Thing Model in your ModioHub Workspace", + ) + parser.add_argument( + "--data", + help=( + "Simulation data for --config: a local path or HTTPS URL of a data " + "document or a modpoll --export snapshot" + ), + ) + parser.add_argument("--script", help="Local Python behavior for --config") + parser.add_argument( + "--allow-scripts", + action="store_true", + help="Allow local Python behavior execution", + ) + parser.add_argument("--unit-id", type=int, help="Instance Unit ID for --config") + parser.add_argument( + "--bind", help="Listener address; configured TCP devices default to 127.0.0.1" + ) + parser.add_argument("--param", action="append", default=[], metavar="NAME=JSON") + parser.add_argument( + "--initial", action="append", default=[], metavar="PROPERTY=JSON" + ) + parser.add_argument( + "--comm", + choices=["tcp", "udp", "serial", "tls"], + help="set communication, default is tcp", + default=None, + type=str, + ) + parser.add_argument( + "--serial", + metavar="PORT", + help=( + "listen for Modbus RTU on a serial port; 'pty' creates a virtual serial " + "port (Linux, macOS) and prints the port for the client" + ), + ) + parser.add_argument( + "--serial-baud", type=int, help="serial baud rate, default is 9600" + ) + parser.add_argument( + "--serial-parity", + choices=["none", "even", "odd"], + help="serial parity, default is none", + ) + parser.add_argument( + "--serial-link", + metavar="PATH", + help="with --serial pty, also create this symbolic link to the client port", + ) + parser.add_argument( + "--framer", + choices=["ascii", "rtu", "socket", "tls"], + help="set framer, default depends on --comm", + type=str, + ) + parser.add_argument( + "--log", + choices=["critical", "error", "warning", "info", "debug"], + help="set log level, default is info", + default="info", + type=str, + ) + parser.add_argument( + "--port", + help="set port; defaults to 5020, which needs no administrator rights", + type=str, + ) + parser.add_argument( + "--store", + choices=["sequential", "sparse", "factory", "none"], + help="set type of datastore", + default="sequential", + type=str, + ) + parser.add_argument( + "--slaves", + help="set number of slaves, default is 0 (any)", + default=0, + type=int, + nargs="+", + ) + parser.add_argument( + "--context", + help="ADVANCED USAGE: set datastore context object", + default=None, + ) + return parser + + +def get_commandline() -> argparse.Namespace: + parser = get_parser() + args = parser.parse_args() + + if args.serial: + if args.comm not in (None, "serial"): + parser.error("--serial cannot be combined with --comm %s" % args.comm) + if args.port: + parser.error("--serial and --port are mutually exclusive") + args.comm = "serial" + args.port = args.serial + args.comm = args.comm or "tcp" + if args.comm != "serial" and ( + args.serial_baud or args.serial_parity or args.serial_link + ): + parser.error( + "--serial-baud, --serial-parity and --serial-link require --serial" + ) + if args.serial_link and args.serial != "pty": + parser.error("--serial-link requires --serial pty") + if args.serial == "pty" and not virtual_serial.available(): + parser.error( + "--serial pty is not available on Windows: create a virtual serial port " + "pair with a driver such as com0com and pass one of its ports to --serial" + ) + args.serial_baud = args.serial_baud or 9600 + args.serial_parity = args.serial_parity or "none" + if not args.config and ( + args.initial + or args.param + or args.unit_id is not None + or args.data + or args.script + ): + parser.error( + "--data, --initial, --param, --script and --unit-id require --config" + ) + if args.bind and args.comm != "tcp": + parser.error("--bind currently supports --comm tcp only") + if args.config and args.comm not in ("tcp", "serial"): + parser.error("model-driven simulation supports TCP and --serial") + if args.store != "sequential": + parser.error("only --store sequential is supported") + if args.slaves != 0: + parser.error( + "--slaves is not supported; the default datastore is shared by all unit IDs" + ) + if args.context is not None: + parser.error("--context is not supported from the command line") + allowed_framers = { + "tcp": {"socket"}, + "udp": {"socket"}, + "serial": {"rtu", "ascii"}, + "tls": {"tls"}, + } + if args.framer and args.framer not in allowed_framers[args.comm]: + parser.error("framer %s is not supported for %s" % (args.framer, args.comm)) + + # set defaults + comm_defaults: Dict[str, list] = { + "tcp": ["socket", DEFAULT_PORT], + "udp": ["socket", DEFAULT_PORT], + "serial": ["rtu", "/dev/ptyp0"], + "tls": ["tls", DEFAULT_PORT], + } + framers: Dict[str, Any] = { + "ascii": FramerType.ASCII, + "rtu": FramerType.RTU, + "socket": FramerType.SOCKET, + "tls": FramerType.TLS, + } + args.framer = framers[args.framer or comm_defaults[args.comm][0]] + args.port = args.port or comm_defaults[args.comm][1] + if args.comm != "serial" and args.port: + try: + args.port = int(args.port) + except ValueError: + parser.error("port must be an integer between 1 and 65535") + if not 1 <= args.port <= 65535: + parser.error("port must be an integer between 1 and 65535") + return args + + +def get_logger(level: str = "info") -> logging.Logger: + if config and config.get("logging"): + logging.config.dictConfig(config["logging"]) + else: + logging.basicConfig( + level=level.upper(), + format="%(asctime)s | %(levelname).1s | %(processName)s | %(name)s | %(message)s", + ) + logger = logging.getLogger(__name__) + return logger + + +def get_utc_time() -> datetime: + dt = datetime.now(timezone.utc) + utc_time = dt.replace(tzinfo=timezone.utc) + return utc_time diff --git a/packages/modsim/modsim/virtual_serial.py b/packages/modsim/modsim/virtual_serial.py new file mode 100644 index 0000000..2ea6f23 --- /dev/null +++ b/packages/modsim/modsim/virtual_serial.py @@ -0,0 +1,97 @@ +"""A virtual serial cable on pseudo-terminals (Linux and macOS). + +Two pseudo-terminal pairs are joined by a byte-forwarding bridge between their master +ends: the Modbus RTU server opens the slave of one pair and the client opens the slave +of the other. Pseudo-terminals ignore baud rate and parity, so nothing is simulated +beyond the bytes. Windows has no pseudo-terminals; use a virtual serial pair driver +and pass one of its ports to --serial instead. +""" + +import asyncio +import contextlib +import logging +import os +import sys +from pathlib import Path +from typing import Optional + +_logger = logging.getLogger(__name__) + + +def available() -> bool: + return sys.platform != "win32" + + +class VirtualSerialPair: + """Two joined ports: `server_port` for modsim and `client_port` for the Modbus client.""" + + def __init__(self, link: Optional[str] = None) -> None: + self.server_port = "" + self.client_port = "" + self._link = Path(link) if link else None + self._masters: list[int] = [] + self._slaves: list[int] = [] + self._loop: Optional[asyncio.AbstractEventLoop] = None + + def open(self, loop: asyncio.AbstractEventLoop) -> None: + if not available(): + raise OSError("virtual serial ports are not available on Windows") + import pty + import tty + + if self._link is not None and (self._link.exists() or self._link.is_symlink()): + if not self._link.is_symlink(): + raise ValueError(f"--serial-link {self._link} exists and is not a link") + self._link.unlink() + self._loop = loop + try: + names = [] + for _ in range(2): + master, slave = pty.openpty() + self._masters.append(master) + # Keep the slaves open for the life of the pair: a pseudo-terminal master + # reports a hangup once no slave is open, e.g. between two client runs. + self._slaves.append(slave) + tty.setraw(slave) + os.set_blocking(master, False) + names.append(os.ttyname(slave)) + self.server_port, self.client_port = names + if self._link is not None: + self._link.symlink_to(self.client_port) + first, second = self._masters + loop.add_reader(first, self._forward, first, second) + loop.add_reader(second, self._forward, second, first) + except BaseException: + self.close() + raise + + def _forward(self, source: int, target: int) -> None: + try: + data = os.read(source, 4096) + except (BlockingIOError, InterruptedError): + return + except OSError: + assert self._loop is not None + self._loop.remove_reader(source) + return + try: + written = os.write(target, data) + except BlockingIOError: + written = 0 + if written < len(data): + _logger.warning( + "Virtual serial bridge dropped %d bytes", len(data) - written + ) + + def close(self) -> None: + for master in self._masters: + if self._loop is not None: + with contextlib.suppress(Exception): + self._loop.remove_reader(master) + for descriptor in (*self._masters, *self._slaves): + with contextlib.suppress(OSError): + os.close(descriptor) + self._masters, self._slaves = [], [] + if self._link is not None and self._link.is_symlink(): + with contextlib.suppress(OSError): + self._link.unlink() diff --git a/packages/modsim/modsim/wot.py b/packages/modsim/modsim/wot.py new file mode 100644 index 0000000..eae2ac0 --- /dev/null +++ b/packages/modsim/modsim/wot.py @@ -0,0 +1,166 @@ +"""Compile shared profile 0.2 models into isolated simulator devices.""" + +import json +from typing import Any + +from modpoll_wot import parse_model, parse_parameters # type: ignore[import-untyped] +from pymodbus.constants import ExcCodes +from pymodbus.simulator import DataType, SimData, SimDevice + +from .sources import model_document + +TABLES = ("coil", "discrete_input", "holding_register", "input_register") +FUNCTIONS = { + 1: "coil", + 2: "discrete_input", + 3: "holding_register", + 4: "input_register", + 5: "coil", + 6: "holding_register", + 15: "coil", + 16: "holding_register", +} + + +def configure(args: Any) -> SimDevice: + """Compile a device; a TD endpoint never becomes the server bind address.""" + from .runtime import Device + + model = getattr(args, "prepared_model", None) + if model is None: + model = parse_model( + model_document(args.config), + unit_id=args.unit_id, + parameters=parse_parameters(args.param), + ) + if model.profile_version != "0.2" or model.properties_json is None: + raise ValueError("configured simulation requires profile 0.2") + schemas = json.loads(model.properties_json) + overrides: dict[str, Any] = parse_parameters(args.initial) + if overrides.keys() - schemas.keys(): + raise ValueError( + f"unknown initial properties: {sorted(overrides.keys() - schemas.keys())}" + ) + cells: dict[str, dict[int, int | bool]] = {table: {} for table in TABLES} + writable: dict[str, dict[int, int]] = {table: {} for table in TABLES} + protected: dict[str, dict[int, int]] = {table: {} for table in TABLES} + unreadable: dict[str, set[int]] = {table: set() for table in TABLES} + writable_cells: dict[str, set[int]] = {table: set() for table in TABLES} + ranges: dict[str, list[tuple[int, int]]] = {table: [] for table in TABLES} + for group in model.groups: + ranges[group.table].append((group.start, group.start + group.quantity)) + for address in range(group.start, group.start + group.quantity): + cells[group.table].setdefault( + address, False if group.table in TABLES[:2] else 0 + ) + + def access( + function_code: int, address: int, count: int, writing: bool + ) -> ExcCodes | None: + table = FUNCTIONS.get(function_code) + if table is None: + return ExcCodes.ILLEGAL_FUNCTION + if not any( + start <= address and address + count <= end for start, end in ranges[table] + ): + return ExcCodes.ILLEGAL_ADDRESS + if writing and any( + item not in writable_cells[table] + for item in range(address, address + count) + ): + return ExcCodes.ILLEGAL_ADDRESS + if not writing and any( + item in unreadable[table] for item in range(address, address + count) + ): + return ExcCodes.ILLEGAL_ADDRESS + return None + + device = Device(model, cells, schemas, access) + origins = {} + # Explicit defaults first, so an unconstrained alias can inherit existing + # register contents rather than inventing a conflicting zero. + ordered = sorted( + device.codecs, + key=lambda n: not ( + n in overrides or any(k in schemas[n] for k in ("const", "default", "enum")) + ), + ) + assigned: dict[tuple[str, int], tuple[int, int]] = {} + for name in ordered: + codec = device.codecs[name] + schema = schemas[name] + if name in overrides or any( + key in schema for key in ("const", "default", "enum") + ): + value = codec.initial(overrides.get(name), name in overrides) + else: + try: + value = codec.decode(device.cells) + codec.validate(value) + codec.encode(value) + except (ValueError, UnicodeError, TypeError): + value = codec.initial(None, False) + for offset, (raw, mask) in enumerate(codec.encode(value)): + key = (codec.table, codec.start + offset) + previous, owned = assigned.get(key, (0, 0)) + if (previous ^ raw) & owned & mask: + raise ValueError(f"{name}: conflicting alias initial values") + assigned[key] = ((previous & ~mask) | (raw & mask), owned | mask) + if codec.member.writable: + writable_cells[codec.table].add(key[1]) + permissions = writable if codec.member.writable else protected + permissions[codec.table][key[1]] = ( + permissions[codec.table].get(key[1], 0) | mask + ) + if not codec.member.readable: + unreadable[codec.table].add(key[1]) + device.set_many({name: value}, initializing=True) + origins[name] = ( + "override" + if name in overrides + else next( + (key for key in ("const", "default", "enum") if key in schema), + "synthetic type/constraint fallback", + ) + ) + device.validate_cells(set(assigned)) + for table in TABLES: + for address, mask in writable[table].items(): + writable[table][address] = mask & ~protected[table].get(address, 0) + device.write_masks = writable + args.runtime = device + args.model_initialization = { + "title": model.title, + "profile": model.profile_version, + "unit_id": model.unit_id, + "values": {name: device.get(name) for name in device.codecs}, + "origins": origins, + "groups": [ + {"table": g.table, "start": g.start, "quantity": g.quantity} + for g in model.groups + ], + } + blocks = [] + for table in TABLES: + bits = table in TABLES[:2] + blocks.append( + [ + SimData( + address, + values=[value], + datatype=DataType.BITS if bits else DataType.REGISTERS, + readonly=not writable[table].get(address, 0), + ) + for address, value in sorted(device.cells[table].items()) + ] + or [ + SimData( + 0, + values=[False] if bits else 0, + datatype=DataType.BITS if bits else DataType.INVALID, + ) + ] + ) + return SimDevice( + model.unit_id, simdata=(blocks[0], blocks[1], blocks[2], blocks[3]) + ) diff --git a/packages/modsim/pyproject.toml b/packages/modsim/pyproject.toml new file mode 100644 index 0000000..0369cf3 --- /dev/null +++ b/packages/modsim/pyproject.toml @@ -0,0 +1,69 @@ +[project] +name = "modsim" +version = "2.0.0a12" +description = "A Simple Modbus TCP Device Simulator used for modpoll tool" +authors = [{ name = "Ying Shaodong", email = "helloysd@gmail.com" }] +readme = "README.md" +requires-python = ">=3.10,<4.0" +dependencies = [ + "pymodbus~=3.16.1", + "pyserial>=3.5,<4.0", + "modpoll-wot==0.6.0a2", + "jsonschema>=4.21,<5", + "PyYAML>=6,<7", +] + +[dependency-groups] +dev = [ + "pre-commit>=3.5.0,<4.0.0", + "pytest>=8.2.2,<9.0.0", + "deptry>=0.16.1,<0.17.0", + "mypy>=1.10.1,<2.0.0", + "tox>=4.16.0,<5.0.0", + "tomli>=2,<3; python_version < '3.11'", +] +docs = [ + "mkdocs>=1.6.0,<2.0.0", + "mkdocs-material>=9.5.28,<10.0.0", + "mkdocstrings[python]>=0.25.1,<0.26.0", + "mkdocs-autorefs>=1.2,<1.4", + "markdown>=3.7,<3.8", + "pymdown-extensions>=10.11,<11", +] + +[build-system] +requires = ["uv_build>=0.11.19,<0.12.0"] +build-backend = "uv_build" + +[tool.uv.build-backend] +module-name = "modsim" +module-root = "" + +[tool.uv.sources] +# Inside the workspace modpoll-wot comes from packages/modpoll-wot; `uv build --no-sources` keeps the published pin. +modpoll-wot = { workspace = true } + +[project.urls] +Repository = "https://github.com/top-maker/modsim" +Documentation = "https://top-maker.github.io/modsim/" + +[tool.mypy] +files = ["modsim"] +disallow_untyped_defs = true +disallow_any_unimported = true +no_implicit_optional = true +check_untyped_defs = true +warn_return_any = true +warn_unused_ignores = true +show_error_codes = true + +[tool.pytest.ini_options] +testpaths = ["tests"] +markers = ["integration: local protocol integration test"] + +[project.scripts] +modsim = "modsim.main:app" + +[tool.deptry.per_rule_ignores] +# pymodbus imports pyserial for its serial transport; modsim never imports it itself. +DEP002 = ["pyserial"] diff --git a/packages/modsim/tests/fixtures/io-module/README.md b/packages/modsim/tests/fixtures/io-module/README.md new file mode 100644 index 0000000..d4124eb --- /dev/null +++ b/packages/modsim/tests/fixtures/io-module/README.md @@ -0,0 +1,6 @@ +# Runtime regression fixture + +Frozen MIT model/simulation data/TD used only for protocol and codec regression. +Not a device contribution or independently maintained product mapping. +It also serves as the ADAM-6024 device in examples/deployment.yaml. Generated +TDs are checked by tools/generate-td.py. Do not use this fixture as a model contribution target. diff --git a/packages/modsim/tests/fixtures/io-module/adam-6024.generated.td.json b/packages/modsim/tests/fixtures/io-module/adam-6024.generated.td.json new file mode 100644 index 0000000..c41325a --- /dev/null +++ b/packages/modsim/tests/fixtures/io-module/adam-6024.generated.td.json @@ -0,0 +1,287 @@ +{ + "@context": [ + "https://www.w3.org/2022/wot/td/v1.1", + { + "modpoll": "https://top-maker.github.io/modpoll/vocab/wot-modbus#", + "modv": "https://www.w3.org/2019/wot/modbus", + "xsd": "http://www.w3.org/2001/XMLSchema#" + } + ], + "title": "Advantech ADAM-6024 Ethernet Remote I/O Module", + "description": "Thing Model for the Advantech ADAM-6024 remote I/O module: six analog inputs, two analog outputs, two digital inputs and two digital outputs. Analog channels are exposed as raw 16-bit Modbus words; digital channels are booleans. Register addresses are manual-derived candidates and are not hardware-verified. Confirm address tables, firmware behavior, analog ranges and wire normalization before using with physical equipment.", + "modpoll:version": "0.2", + "properties": { + "AI0_RAW": { + "type": "integer", + "description": "Analog input channel 0 raw Modbus input-register word. No voltage/current scaling, signedness or engineering units are inferred.", + "unit": "count", + "minimum": 0, + "maximum": 65535, + "readOnly": true, + "forms": [ + { + "op": "readproperty", + "contentType": "application/octet-stream;length=2;signed=false;byteSeq=BIG_ENDIAN", + "modv:entity": "InputRegister", + "modv:address": 0, + "modv:quantity": 1, + "modv:type": "xsd:unsignedShort", + "href": "modbus+tcp://127.0.0.1:5020/1/0?quantity=1" + } + ] + }, + "AI1_RAW": { + "type": "integer", + "description": "Analog input channel 1 raw Modbus input-register word. No voltage/current scaling, signedness or engineering units are inferred.", + "unit": "count", + "minimum": 0, + "maximum": 65535, + "readOnly": true, + "forms": [ + { + "op": "readproperty", + "contentType": "application/octet-stream;length=2;signed=false;byteSeq=BIG_ENDIAN", + "modv:entity": "InputRegister", + "modv:address": 1, + "modv:quantity": 1, + "modv:type": "xsd:unsignedShort", + "href": "modbus+tcp://127.0.0.1:5020/1/1?quantity=1" + } + ] + }, + "AI2_RAW": { + "type": "integer", + "description": "Analog input channel 2 raw Modbus input-register word. No voltage/current scaling, signedness or engineering units are inferred.", + "unit": "count", + "minimum": 0, + "maximum": 65535, + "readOnly": true, + "forms": [ + { + "op": "readproperty", + "contentType": "application/octet-stream;length=2;signed=false;byteSeq=BIG_ENDIAN", + "modv:entity": "InputRegister", + "modv:address": 2, + "modv:quantity": 1, + "modv:type": "xsd:unsignedShort", + "href": "modbus+tcp://127.0.0.1:5020/1/2?quantity=1" + } + ] + }, + "AI3_RAW": { + "type": "integer", + "description": "Analog input channel 3 raw Modbus input-register word. No voltage/current scaling, signedness or engineering units are inferred.", + "unit": "count", + "minimum": 0, + "maximum": 65535, + "readOnly": true, + "forms": [ + { + "op": "readproperty", + "contentType": "application/octet-stream;length=2;signed=false;byteSeq=BIG_ENDIAN", + "modv:entity": "InputRegister", + "modv:address": 3, + "modv:quantity": 1, + "modv:type": "xsd:unsignedShort", + "href": "modbus+tcp://127.0.0.1:5020/1/3?quantity=1" + } + ] + }, + "AI4_RAW": { + "type": "integer", + "description": "Analog input channel 4 raw Modbus input-register word. No voltage/current scaling, signedness or engineering units are inferred.", + "unit": "count", + "minimum": 0, + "maximum": 65535, + "readOnly": true, + "forms": [ + { + "op": "readproperty", + "contentType": "application/octet-stream;length=2;signed=false;byteSeq=BIG_ENDIAN", + "modv:entity": "InputRegister", + "modv:address": 4, + "modv:quantity": 1, + "modv:type": "xsd:unsignedShort", + "href": "modbus+tcp://127.0.0.1:5020/1/4?quantity=1" + } + ] + }, + "AI5_RAW": { + "type": "integer", + "description": "Analog input channel 5 raw Modbus input-register word. No voltage/current scaling, signedness or engineering units are inferred.", + "unit": "count", + "minimum": 0, + "maximum": 65535, + "readOnly": true, + "forms": [ + { + "op": "readproperty", + "contentType": "application/octet-stream;length=2;signed=false;byteSeq=BIG_ENDIAN", + "modv:entity": "InputRegister", + "modv:address": 5, + "modv:quantity": 1, + "modv:type": "xsd:unsignedShort", + "href": "modbus+tcp://127.0.0.1:5020/1/5?quantity=1" + } + ] + }, + "AO0_RAW": { + "type": "integer", + "description": "Analog output channel 0 raw Modbus holding-register word. Writable through Modbus; permitted values and conversion to physical output depend on device range configuration and firmware and must be verified before hardware writes.", + "unit": "count", + "minimum": 0, + "maximum": 65535, + "forms": [ + { + "op": [ + "readproperty", + "writeproperty" + ], + "contentType": "application/octet-stream;length=2;signed=false;byteSeq=BIG_ENDIAN", + "modv:entity": "HoldingRegister", + "modv:address": 10, + "modv:quantity": 1, + "modv:type": "xsd:unsignedShort", + "href": "modbus+tcp://127.0.0.1:5020/1/10?quantity=1" + } + ] + }, + "AO1_RAW": { + "type": "integer", + "description": "Analog output channel 1 raw Modbus holding-register word. Writable through Modbus; permitted values and conversion to physical output depend on device range configuration and firmware and must be verified before hardware writes.", + "unit": "count", + "minimum": 0, + "maximum": 65535, + "forms": [ + { + "op": [ + "readproperty", + "writeproperty" + ], + "contentType": "application/octet-stream;length=2;signed=false;byteSeq=BIG_ENDIAN", + "modv:entity": "HoldingRegister", + "modv:address": 11, + "modv:quantity": 1, + "modv:type": "xsd:unsignedShort", + "href": "modbus+tcp://127.0.0.1:5020/1/11?quantity=1" + } + ] + }, + "DI0": { + "type": "boolean", + "description": "Digital input channel 0 state.", + "readOnly": true, + "forms": [ + { + "op": "readproperty", + "contentType": "application/octet-stream;length=1;signed=false;byteSeq=BIG_ENDIAN", + "modv:entity": "DiscreteInput", + "modv:address": 0, + "modv:quantity": 1, + "modv:type": "xsd:boolean", + "href": "modbus+tcp://127.0.0.1:5020/1/0?quantity=1" + } + ] + }, + "DI1": { + "type": "boolean", + "description": "Digital input channel 1 state.", + "readOnly": true, + "forms": [ + { + "op": "readproperty", + "contentType": "application/octet-stream;length=1;signed=false;byteSeq=BIG_ENDIAN", + "modv:entity": "DiscreteInput", + "modv:address": 1, + "modv:quantity": 1, + "modv:type": "xsd:boolean", + "href": "modbus+tcp://127.0.0.1:5020/1/1?quantity=1" + } + ] + }, + "DO0": { + "type": "boolean", + "description": "Digital output channel 0 state; writable through Modbus. Verify physical wiring and permitted operation before controlling hardware.", + "forms": [ + { + "op": [ + "readproperty", + "writeproperty" + ], + "contentType": "application/octet-stream;length=1;signed=false;byteSeq=BIG_ENDIAN", + "modv:entity": "Coil", + "modv:address": 16, + "modv:quantity": 1, + "modv:type": "xsd:boolean", + "href": "modbus+tcp://127.0.0.1:5020/1/16?quantity=1" + } + ] + }, + "DO1": { + "type": "boolean", + "description": "Digital output channel 1 state; writable through Modbus. Verify physical wiring and permitted operation before controlling hardware.", + "forms": [ + { + "op": [ + "readproperty", + "writeproperty" + ], + "contentType": "application/octet-stream;length=1;signed=false;byteSeq=BIG_ENDIAN", + "modv:entity": "Coil", + "modv:address": 17, + "modv:quantity": 1, + "modv:type": "xsd:boolean", + "href": "modbus+tcp://127.0.0.1:5020/1/17?quantity=1" + } + ] + } + }, + "modpoll:acquisition": [ + { + "modv:entity": "InputRegister", + "modv:address": 0, + "modv:quantity": 6, + "modpoll:members": [ + "AI0_RAW", + "AI1_RAW", + "AI2_RAW", + "AI3_RAW", + "AI4_RAW", + "AI5_RAW" + ] + }, + { + "modv:entity": "HoldingRegister", + "modv:address": 10, + "modv:quantity": 2, + "modpoll:members": [ + "AO0_RAW", + "AO1_RAW" + ] + }, + { + "modv:entity": "DiscreteInput", + "modv:address": 0, + "modv:quantity": 2, + "modpoll:members": [ + "DI0", + "DI1" + ] + }, + { + "modv:entity": "Coil", + "modv:address": 16, + "modv:quantity": 2, + "modpoll:members": [ + "DO0", + "DO1" + ] + } + ], + "securityDefinitions": { + "nosec_sc": { + "scheme": "nosec" + } + }, + "security": "nosec_sc" +} diff --git a/packages/modsim/tests/fixtures/io-module/adam-6024.tm.json b/packages/modsim/tests/fixtures/io-module/adam-6024.tm.json new file mode 100644 index 0000000..14307ca --- /dev/null +++ b/packages/modsim/tests/fixtures/io-module/adam-6024.tm.json @@ -0,0 +1,270 @@ +{ + "@context": [ + "https://www.w3.org/2022/wot/td/v1.1", + { + "modpoll": "https://top-maker.github.io/modpoll/vocab/wot-modbus#", + "modv": "https://www.w3.org/2019/wot/modbus", + "xsd": "http://www.w3.org/2001/XMLSchema#" + } + ], + "title": "Advantech ADAM-6024 Ethernet Remote I/O Module", + "description": "Thing Model for the Advantech ADAM-6024 remote I/O module: six analog inputs, two analog outputs, two digital inputs and two digital outputs. Analog channels are exposed as raw 16-bit Modbus words; digital channels are booleans. Register addresses are manual-derived candidates and are not hardware-verified. Confirm address tables, firmware behavior, analog ranges and wire normalization before using with physical equipment.", + "modpoll:version": "0.2", + "properties": { + "AI0_RAW": { + "type": "integer", + "description": "Analog input channel 0 raw Modbus input-register word. No voltage/current scaling, signedness or engineering units are inferred.", + "unit": "count", + "minimum": 0, + "maximum": 65535, + "readOnly": true, + "forms": [ + { + "op": "readproperty", + "contentType": "application/octet-stream;length=2;signed=false;byteSeq=BIG_ENDIAN", + "modv:entity": "InputRegister", + "modv:address": 0, + "modv:quantity": 1, + "modv:type": "xsd:unsignedShort" + } + ] + }, + "AI1_RAW": { + "type": "integer", + "description": "Analog input channel 1 raw Modbus input-register word. No voltage/current scaling, signedness or engineering units are inferred.", + "unit": "count", + "minimum": 0, + "maximum": 65535, + "readOnly": true, + "forms": [ + { + "op": "readproperty", + "contentType": "application/octet-stream;length=2;signed=false;byteSeq=BIG_ENDIAN", + "modv:entity": "InputRegister", + "modv:address": 1, + "modv:quantity": 1, + "modv:type": "xsd:unsignedShort" + } + ] + }, + "AI2_RAW": { + "type": "integer", + "description": "Analog input channel 2 raw Modbus input-register word. No voltage/current scaling, signedness or engineering units are inferred.", + "unit": "count", + "minimum": 0, + "maximum": 65535, + "readOnly": true, + "forms": [ + { + "op": "readproperty", + "contentType": "application/octet-stream;length=2;signed=false;byteSeq=BIG_ENDIAN", + "modv:entity": "InputRegister", + "modv:address": 2, + "modv:quantity": 1, + "modv:type": "xsd:unsignedShort" + } + ] + }, + "AI3_RAW": { + "type": "integer", + "description": "Analog input channel 3 raw Modbus input-register word. No voltage/current scaling, signedness or engineering units are inferred.", + "unit": "count", + "minimum": 0, + "maximum": 65535, + "readOnly": true, + "forms": [ + { + "op": "readproperty", + "contentType": "application/octet-stream;length=2;signed=false;byteSeq=BIG_ENDIAN", + "modv:entity": "InputRegister", + "modv:address": 3, + "modv:quantity": 1, + "modv:type": "xsd:unsignedShort" + } + ] + }, + "AI4_RAW": { + "type": "integer", + "description": "Analog input channel 4 raw Modbus input-register word. No voltage/current scaling, signedness or engineering units are inferred.", + "unit": "count", + "minimum": 0, + "maximum": 65535, + "readOnly": true, + "forms": [ + { + "op": "readproperty", + "contentType": "application/octet-stream;length=2;signed=false;byteSeq=BIG_ENDIAN", + "modv:entity": "InputRegister", + "modv:address": 4, + "modv:quantity": 1, + "modv:type": "xsd:unsignedShort" + } + ] + }, + "AI5_RAW": { + "type": "integer", + "description": "Analog input channel 5 raw Modbus input-register word. No voltage/current scaling, signedness or engineering units are inferred.", + "unit": "count", + "minimum": 0, + "maximum": 65535, + "readOnly": true, + "forms": [ + { + "op": "readproperty", + "contentType": "application/octet-stream;length=2;signed=false;byteSeq=BIG_ENDIAN", + "modv:entity": "InputRegister", + "modv:address": 5, + "modv:quantity": 1, + "modv:type": "xsd:unsignedShort" + } + ] + }, + "AO0_RAW": { + "type": "integer", + "description": "Analog output channel 0 raw Modbus holding-register word. Writable through Modbus; permitted values and conversion to physical output depend on device range configuration and firmware and must be verified before hardware writes.", + "unit": "count", + "minimum": 0, + "maximum": 65535, + "forms": [ + { + "op": [ + "readproperty", + "writeproperty" + ], + "contentType": "application/octet-stream;length=2;signed=false;byteSeq=BIG_ENDIAN", + "modv:entity": "HoldingRegister", + "modv:address": 10, + "modv:quantity": 1, + "modv:type": "xsd:unsignedShort" + } + ] + }, + "AO1_RAW": { + "type": "integer", + "description": "Analog output channel 1 raw Modbus holding-register word. Writable through Modbus; permitted values and conversion to physical output depend on device range configuration and firmware and must be verified before hardware writes.", + "unit": "count", + "minimum": 0, + "maximum": 65535, + "forms": [ + { + "op": [ + "readproperty", + "writeproperty" + ], + "contentType": "application/octet-stream;length=2;signed=false;byteSeq=BIG_ENDIAN", + "modv:entity": "HoldingRegister", + "modv:address": 11, + "modv:quantity": 1, + "modv:type": "xsd:unsignedShort" + } + ] + }, + "DI0": { + "type": "boolean", + "description": "Digital input channel 0 state.", + "readOnly": true, + "forms": [ + { + "op": "readproperty", + "contentType": "application/octet-stream;length=1;signed=false;byteSeq=BIG_ENDIAN", + "modv:entity": "DiscreteInput", + "modv:address": 0, + "modv:quantity": 1, + "modv:type": "xsd:boolean" + } + ] + }, + "DI1": { + "type": "boolean", + "description": "Digital input channel 1 state.", + "readOnly": true, + "forms": [ + { + "op": "readproperty", + "contentType": "application/octet-stream;length=1;signed=false;byteSeq=BIG_ENDIAN", + "modv:entity": "DiscreteInput", + "modv:address": 1, + "modv:quantity": 1, + "modv:type": "xsd:boolean" + } + ] + }, + "DO0": { + "type": "boolean", + "description": "Digital output channel 0 state; writable through Modbus. Verify physical wiring and permitted operation before controlling hardware.", + "forms": [ + { + "op": [ + "readproperty", + "writeproperty" + ], + "contentType": "application/octet-stream;length=1;signed=false;byteSeq=BIG_ENDIAN", + "modv:entity": "Coil", + "modv:address": 16, + "modv:quantity": 1, + "modv:type": "xsd:boolean" + } + ] + }, + "DO1": { + "type": "boolean", + "description": "Digital output channel 1 state; writable through Modbus. Verify physical wiring and permitted operation before controlling hardware.", + "forms": [ + { + "op": [ + "readproperty", + "writeproperty" + ], + "contentType": "application/octet-stream;length=1;signed=false;byteSeq=BIG_ENDIAN", + "modv:entity": "Coil", + "modv:address": 17, + "modv:quantity": 1, + "modv:type": "xsd:boolean" + } + ] + } + }, + "modpoll:acquisition": [ + { + "modv:entity": "InputRegister", + "modv:address": 0, + "modv:quantity": 6, + "modpoll:members": [ + "AI0_RAW", + "AI1_RAW", + "AI2_RAW", + "AI3_RAW", + "AI4_RAW", + "AI5_RAW" + ] + }, + { + "modv:entity": "HoldingRegister", + "modv:address": 10, + "modv:quantity": 2, + "modpoll:members": [ + "AO0_RAW", + "AO1_RAW" + ] + }, + { + "modv:entity": "DiscreteInput", + "modv:address": 0, + "modv:quantity": 2, + "modpoll:members": [ + "DI0", + "DI1" + ] + }, + { + "modv:entity": "Coil", + "modv:address": 16, + "modv:quantity": 2, + "modpoll:members": [ + "DO0", + "DO1" + ] + } + ], + "@type": "tm:ThingModel" +} diff --git a/packages/modsim/tests/fixtures/io-module/generated.json b/packages/modsim/tests/fixtures/io-module/generated.json new file mode 100644 index 0000000..a563320 --- /dev/null +++ b/packages/modsim/tests/fixtures/io-module/generated.json @@ -0,0 +1,19 @@ +{ + "source": "adam-6024.tm.json", + "source_sha256": "4c2aee3334faf6622f4ee34a23108fa0ec100a6b3110a78200eee79da8935596", + "generator": { + "package": "modpoll-wot", + "version": "0.6.0a2" + }, + "instance": { + "host": "127.0.0.1", + "port": 5020, + "unit_id": 1 + }, + "artifacts": { + "adam-6024.generated.td.json": { + "target": "project", + "sha256": "7362621b233d323f231c838c62f7a768f040a9b296edb513991ea044baebc458" + } + } +} diff --git a/packages/modsim/tests/fixtures/io-module/simulation/adam-6024.data.json b/packages/modsim/tests/fixtures/io-module/simulation/adam-6024.data.json new file mode 100644 index 0000000..01bcce7 --- /dev/null +++ b/packages/modsim/tests/fixtures/io-module/simulation/adam-6024.data.json @@ -0,0 +1,28 @@ +{ + "version": "1", + "tick": 0.1, + "initial": { + "AI0_RAW": 1000, + "AI1_RAW": 2000, + "AI2_RAW": 3000, + "AI3_RAW": 4000, + "AI4_RAW": 5000, + "AI5_RAW": 6000, + "AO0_RAW": 100, + "AO1_RAW": 200, + "DI0": false, + "DI1": true, + "DO0": false, + "DO1": true + }, + "bindings": { + "AI0_RAW": "AO0_RAW", + "AI1_RAW": "AO1_RAW", + "AI2_RAW": "AO0_RAW", + "AI3_RAW": "AO1_RAW", + "AI4_RAW": "AO0_RAW", + "AI5_RAW": "AO1_RAW", + "DI0": "DO0", + "DI1": "DO1" + } +} diff --git a/packages/modsim/tests/test_acceptance_fixtures.py b/packages/modsim/tests/test_acceptance_fixtures.py new file mode 100644 index 0000000..be1f00f --- /dev/null +++ b/packages/modsim/tests/test_acceptance_fixtures.py @@ -0,0 +1,49 @@ +"""Detached fixture preparation must preserve the original repository path base.""" + +from importlib.util import module_from_spec, spec_from_file_location +from pathlib import Path +from unittest.mock import Mock + +import yaml + +spec = spec_from_file_location( + "prepare_acceptance", + Path(__file__).resolve().parents[1] / "tools/prepare-acceptance.py", +) +prepare_acceptance = module_from_spec(spec) +spec.loader.exec_module(prepare_acceptance) + + +def test_relocated_manifest_preserves_model_and_data_base(tmp_path, monkeypatch): + directory = tmp_path / "examples" + directory.mkdir() + (directory / "model-source.yaml").write_text("revision: pinned\n") + manifest = directory / "deployment.yaml" + manifest.write_text( + yaml.safe_dump( + { + "devices": [ + { + "model": "examples/models/vendor/model.tm.json", + "data": "examples/models/vendor/model.data.json", + } + ] + } + ) + ) + fetch = Mock() + monkeypatch.setattr(prepare_acceptance.subprocess, "run", fetch) + prepare_acceptance.prepare(tmp_path) + args = fetch.call_args.args[0] + assert str(directory / "model-source.yaml") in args + assert str(directory / "models") in args + device = yaml.safe_load(manifest.read_text())["devices"][0] + assert device["model"] == str(directory / "models/vendor/model.tm.json") + assert device["data"] == str(directory / "models/vendor/model.data.json") + + +def test_historical_release_is_left_unchanged(tmp_path, monkeypatch): + fetch = Mock() + monkeypatch.setattr(prepare_acceptance.subprocess, "run", fetch) + prepare_acceptance.prepare(tmp_path) + fetch.assert_not_called() diff --git a/packages/modsim/tests/test_catalog_platform.py b/packages/modsim/tests/test_catalog_platform.py new file mode 100644 index 0000000..0b43122 --- /dev/null +++ b/packages/modsim/tests/test_catalog_platform.py @@ -0,0 +1,120 @@ +"""Opt-in installed CLI smoke against a pinned public TM on each supported OS.""" + +import json +import os +from pathlib import Path +import socket +import struct +import subprocess +import sys +import time + +import pytest +import yaml + +pytestmark = pytest.mark.skipif( + os.environ.get("MODSIM_CATALOG_PLATFORM") != "1", + reason="Opt-in public URL/platform acceptance; see .github/workflows/modsim-acceptance.yml", +) + + +def test_remote_model_single_device_read_and_stop(tmp_path): + lock = yaml.safe_load( + (Path(__file__).resolve().parents[1] / "examples/model-source.yaml").read_text() + ) + url = f"https://raw.githubusercontent.com/{lock['repository']}/{lock['revision']}/products/advantech/adam-5017uh/model.tm.json" + data = tmp_path / "initial.data.json" + values = [0x1234, 0x8001, 0xABCD, 0, 65535, 42, 0x0102, 0xFE01] + data.write_text( + json.dumps( + {"version": "1", "initial": {f"AI{i}_RAW": v for i, v in enumerate(values)}} + ) + ) + with socket.socket() as reservation: + reservation.bind(("127.0.0.1", 0)) + port = reservation.getsockname()[1] + env = dict(os.environ) + env.pop("PYTHONPATH", None) + with (tmp_path / "server.log").open("w+") as log: + process = subprocess.Popen( + [ + sys.executable, + "-m", + "modsim", + "--config", + url, + "--bind", + "127.0.0.1", + "--port", + str(port), + "--unit-id", + "1", + "--data", + str(data), + ], + cwd=tmp_path, + env=env, + stdout=log, + stderr=log, + ) + try: + deadline = time.monotonic() + 30 + while True: + if process.poll() is not None: + log.seek(0) + pytest.fail(log.read()) + try: + stream = socket.create_connection(("127.0.0.1", port), timeout=2) + break + except OSError: + if time.monotonic() >= deadline: + pytest.fail("Single-device startup timed out") + time.sleep(0.1) + with stream: + stream.sendall(struct.pack(">HHHBBHH", 7, 0, 6, 1, 4, 1, 8)) + response = b"" + while len(response) < 25: + part = stream.recv(25 - len(response)) + assert part + response += part + assert response == struct.pack(">HHHBBB8H", 7, 0, 19, 1, 4, 16, *values) + finally: + if os.name == "nt": + # A Windows venv executable can be a redirector with a child. + # Stop the owned tree so the test never leaves a listener behind. + subprocess.run( + ["taskkill", "/PID", str(process.pid), "/T", "/F"], + check=True, + capture_output=True, + ) + else: + process.terminate() + try: + process.wait(timeout=10) + except subprocess.TimeoutExpired: + process.kill() + process.wait() + # Stop means the foreground child is gone and its endpoint is closed. + assert process.poll() is not None + deadline = time.monotonic() + 5 + while True: + try: + with socket.create_connection(("127.0.0.1", port), timeout=0.2): + pass + except OSError: + break + assert ( + time.monotonic() < deadline + ), "Owned simulator listener remained after stop" + time.sleep(0.05) + + +def test_native_absolute_paths_are_files_not_url_schemes(tmp_path): + from modsim.sources import local_path, model_document + + path = tmp_path / "local-model.json" + path.write_text('{"fixture": true}') + assert local_path(tmp_path, str(path)) == str(path.resolve()) + assert model_document(str(path)) == {"fixture": True} + with pytest.raises(ValueError, match="expected local path"): + local_path(tmp_path, "https://example.invalid/scenario.json") diff --git a/packages/modsim/tests/test_codec.py b/packages/modsim/tests/test_codec.py new file mode 100644 index 0000000..8e2a001 --- /dev/null +++ b/packages/modsim/tests/test_codec.py @@ -0,0 +1,563 @@ +"""Independent wire vectors and atomic property/Modbus write semantics.""" + +import asyncio +import json +from pathlib import Path + +import pytest + +from pymodbus.constants import ExcCodes + +from modsim.runtime import RuntimeContext +from modsim.utils import get_parser +from modsim.wot import configure + +CONTEXT = [ + "https://www.w3.org/2022/wot/td/v1.1", + { + "modpoll": "https://top-maker.github.io/modpoll/vocab/wot-modbus#", + "modv": "https://www.w3.org/2019/wot/modbus", + "xsd": "http://www.w3.org/2001/XMLSchema#", + }, +] + + +def prop( + raw="unsignedInt", + quantity=2, + kind="integer", + address=0, + entity="HoldingRegister", + **extra, +): + value = { + "type": kind, + "forms": [ + { + "modv:entity": entity, + "modv:address": address, + "modv:quantity": quantity, + "modv:type": "xsd:" + raw, + } + ], + } + if kind == "array": + value["items"] = {"type": "boolean"} + if entity in ("InputRegister", "DiscreteInput"): + value["readOnly"] = True + value.update(extra) + return value + + +def configure_properties(tmp_path, properties, initial=None): + groups = {} + for name, value in properties.items(): + form = value["forms"][0] + key = form["modv:entity"] + groups.setdefault(key, []).append((name, form)) + acquisition = [] + for entity, forms in groups.items(): + start = min(form["modv:address"] for _, form in forms) + end = max(form["modv:address"] + form["modv:quantity"] for _, form in forms) + acquisition.append( + { + "modv:entity": entity, + "modv:address": start, + "modv:quantity": end - start, + "modpoll:members": [name for name, _ in forms], + } + ) + document = { + "@context": CONTEXT, + "@type": "tm:ThingModel", + "title": "codec-fixture", + "modpoll:version": "0.2", + "properties": properties, + "modpoll:acquisition": acquisition, + } + path = tmp_path / "codec.tm.json" + path.write_text(json.dumps(document)) + arguments = ["--config", str(path), "--unit-id", "1"] + for name, value in (initial or {}).items(): + arguments.extend(["--initial", name + "=" + json.dumps(value)]) + args = get_parser().parse_args(arguments) + configure(args) + return args.runtime + + +@pytest.mark.parametrize( + "order,words", + [ + ("BE_BE", [0x1234, 0x5678]), + ("LE_BE", [0x3412, 0x7856]), + ("BE_LE", [0x5678, 0x1234]), + ("LE_LE", [0x7856, 0x3412]), + ], +) +def test_four_orders_independent_uint32_vector(tmp_path, order, words): + mapping = prop() + mapping["forms"][0].update( + { + "modv:mostSignificantByte": order.startswith("BE"), + "modv:mostSignificantWord": order.endswith("BE"), + } + ) + instance = configure_properties(tmp_path, {"value": mapping}, {"value": 0x12345678}) + assert list(instance.cells["holding_register"].values()) == words + assert instance.get("value") == 0x12345678 + + +@pytest.mark.parametrize( + "raw,quantity,kind,value,words", + [ + ("short", 1, "integer", -12345, [0xCFC7]), + ("int", 2, "integer", -12345678, [0xFF43, 0x9EB2]), + ( + "unsignedLong", + 4, + "integer", + 0x0123456789ABCDEF, + [0x0123, 0x4567, 0x89AB, 0xCDEF], + ), + ("long", 4, "integer", -2, [0xFFFF, 0xFFFF, 0xFFFF, 0xFFFE]), + ("float", 2, "number", -12.5, [0xC148, 0]), + ("double", 4, "number", -12.5, [0xC029, 0, 0, 0]), + ("boolean", 1, "boolean", True, [1]), + ], +) +def test_numeric_wire_vectors(tmp_path, raw, quantity, kind, value, words): + instance = configure_properties( + tmp_path, {"value": prop(raw, quantity, kind)}, {"value": value} + ) + assert list(instance.cells["holding_register"].values()) == words + assert instance.get("value") == value + + +def test_float16_and_boolean_array_legacy_layout(tmp_path): + half = prop("hexBinary", 1, "number") + half["forms"][0]["modpoll:codec"] = "float16" + instance = configure_properties(tmp_path, {"value": half}, {"value": 1.5}) + assert instance.cells["holding_register"][0] == 0x3E00 + for codec, quantity, values, expected in [ + ("bool8", 1, [True] + [False] * 6 + [True], [0x8100]), + ("bool16", 2, [True] + [False] * 6 + [True, True] + [False] * 7, [0x8101, 0]), + ]: + mapping = prop("hexBinary", quantity, "array") + mapping["forms"][0]["modpoll:codec"] = codec + instance = configure_properties(tmp_path, {"value": mapping}, {"value": values}) + assert list(instance.cells["holding_register"].values()) == expected + assert instance.get("value") == values + + +@pytest.mark.parametrize( + "order,words", + [ + ("BE_BE", [0xE4B8, 0xAD00]), + ("LE_BE", [0xB8E4, 0x00AD]), + ("BE_LE", [0xAD00, 0xE4B8]), + ("LE_LE", [0x00AD, 0xB8E4]), + ], +) +def test_utf8_odd_byte_capacity_and_order(tmp_path, order, words): + mapping = prop("string", 2, "string") + mapping["forms"][0].update( + { + "modpoll:byteLength": 3, + "modv:mostSignificantByte": order.startswith("BE"), + "modv:mostSignificantWord": order.endswith("BE"), + } + ) + instance = configure_properties(tmp_path, {"value": mapping}, {"value": "中"}) + assert list(instance.cells["holding_register"].values()) == words + assert instance.get("value") == "中" + with pytest.raises(ValueError): + instance.set("value", "中文") + assert instance.get("value") == "中" + + +def test_boolean_physical_array_and_legacy_msb_numeric_packing(tmp_path): + array = prop("boolean", 5, "array", entity="Coil") + values = [True, False, True, True, False] + instance = configure_properties(tmp_path, {"value": array}, {"value": values}) + assert list(instance.cells["coil"].values()) == values + assert instance.get("value") == values + numeric = prop("unsignedShort", 16, "integer", entity="Coil") + numeric["forms"][0]["modpoll:bitPacking"] = "legacy-msb" + instance = configure_properties(tmp_path, {"value": numeric}, {"value": 0x1234}) + assert list(instance.cells["coil"].values()) == [ + bool(int(v)) for v in "0001001000110100" + ] + assert instance.get("value") == 0x1234 + + +def test_exact_inverse_multiplier_negative_and_zero(tmp_path): + mapping = prop("short", 1, "number") + mapping["forms"][0]["modpoll:multiplier"] = -0.1 + instance = configure_properties(tmp_path, {"value": mapping}, {"value": 12.3}) + assert instance.cells["holding_register"][0] == 0xFF85 + assert instance.get("value") == 12.3 + with pytest.raises(ValueError, match="integer multiple"): + instance.set("value", 12.35) + assert instance.get("value") == 12.3 + mapping["forms"][0]["modpoll:multiplier"] = 0 + instance = configure_properties(tmp_path, {"value": mapping}) + assert instance.get("value") == 0 + with pytest.raises(ValueError, match="zero multiplier"): + instance.set("value", 1) + + +def test_uint64_initial_constraints_without_enumeration_or_float_loss(tmp_path): + highest = (1 << 64) - 1 + mapping = prop( + "unsignedLong", 4, "integer", minimum=highest - 2, maximum=highest, multipleOf=3 + ) + instance = configure_properties(tmp_path, {"value": mapping}) + assert instance.get("value") == highest + assert list(instance.cells["holding_register"].values()) == [65535] * 4 + + +def test_masks_preserve_neighbors_and_detect_alias_conflicts(tmp_path): + flags = {} + for name, bit in [("a", 0), ("b", 1)]: + mapping = prop("unsignedShort", 1, "boolean") + mapping["forms"][0]["modpoll:bit"] = bit + flags[name] = mapping + flags["word"] = prop("unsignedShort", 1) + instance = configure_properties(tmp_path, flags, {"word": 0x8000}) + instance.set_many({"a": True, "b": True}) + assert instance.get("word") == 0x8003 + instance.set("a", False) + assert instance.get("word") == 0x8002 + with pytest.raises(ValueError, match="alias"): + instance.set_many({"word": 0, "b": True}) + assert instance.get("word") == 0x8002 + + +def test_readonly_bits_and_writeonly_property(tmp_path): + a = prop("unsignedShort", 1, "boolean", readOnly=True) + a["forms"][0]["modpoll:bit"] = 0 + b = prop("unsignedShort", 1, "boolean") + b["forms"][0]["modpoll:bit"] = 1 + instance = configure_properties(tmp_path, {"a": a, "b": b}) + context = RuntimeContext([instance]) + assert asyncio.run(context.async_setValues(1, 6, 0, [2])) is None + assert asyncio.run(context.async_setValues(1, 6, 0, [3])) == ExcCodes.ILLEGAL_VALUE + assert instance.get("a") is False + assert instance.get("b") is True + instance = configure_properties(tmp_path, {"value": prop(writeOnly=True)}) + context = RuntimeContext([instance]) + assert not isinstance(asyncio.run(context.async_getValues(1, 3, 0, 2)), list) + assert asyncio.run(context.async_setValues(1, 16, 0, [0x1234, 0x5678])) is None + assert instance.get("value") == 0x12345678 + + +def test_client_write_holds_only_writable_properties(tmp_path): + a = prop("unsignedShort", 1, "boolean", readOnly=True) + a["forms"][0]["modpoll:bit"] = 0 + b = prop("unsignedShort", 1, "boolean") + b["forms"][0]["modpoll:bit"] = 1 + instance = configure_properties(tmp_path, {"a": a, "b": b}) + instance.generators = {"a": {"kind": "constant", "value": True}} + context = RuntimeContext([instance]) + assert asyncio.run(context.async_setValues(1, 6, 0, [2])) is None + assert instance.held == {"b"} + instance.advance(0, 1) + assert instance.get("a") is True + assert instance.get("b") is True + + +def test_partial_float_write_validates_full_span_and_rolls_back(tmp_path): + instance = configure_properties( + tmp_path, {"value": prop("float", 2, "number", maximum=1.5)}, {"value": 1.5} + ) + context = RuntimeContext([instance]) + assert asyncio.run(context.async_setValues(1, 6, 1, [1])) == ExcCodes.ILLEGAL_VALUE + assert instance.get("value") == 1.5 + assert asyncio.run(context.async_setValues(1, 6, 0, [0x3F80])) is None + assert instance.get("value") == 1.0 + assert instance.held == {"value"} + assert ( + asyncio.run(context.async_setValues(1, 6, 0, [0x7F80])) + == ExcCodes.ILLEGAL_VALUE + ) + assert instance.get("value") == 1.0 + + +def test_internal_alias_constraints_and_failed_batch_rollback(tmp_path): + word = prop("unsignedShort", 1, maximum=1) + bit = prop("unsignedShort", 1, "boolean") + bit["forms"][0]["modpoll:bit"] = 1 + instance = configure_properties(tmp_path, {"word": word, "flag": bit}) + with pytest.raises(ValueError): + instance.set("flag", True) + assert instance.get("word") == 0 + + +def test_legacy_bool16_full_span_write_preserves_padding(tmp_path): + mapping = prop("hexBinary", 2, "array") + mapping["forms"][0]["modpoll:codec"] = "bool16" + instance = configure_properties(tmp_path, {"value": mapping}) + context = RuntimeContext([instance]) + assert asyncio.run(context.async_setValues(1, 16, 0, [0x8101, 0])) is None + assert instance.get("value") == [True] + [False] * 6 + [True, True] + [False] * 7 + assert ( + asyncio.run(context.async_setValues(1, 16, 0, [0, 1])) == ExcCodes.ILLEGAL_VALUE + ) + assert instance.cells["holding_register"] == {0: 0x8101, 1: 0} + + +@pytest.mark.integration +def test_tcp_wide_values_partial_writes_and_writeonly(tmp_path): + import os + import socket + import subprocess + import sys + import time + from pymodbus.client import ModbusTcpClient + + properties = { + "u32": prop(address=0), + "u64": prop("unsignedLong", 4, address=2), + "f32": prop("float", 2, "number", address=6, maximum=1.5), + "f64": prop("double", 4, "number", address=8), + "text": prop("string", 3, "string", address=12), + "secret": prop("unsignedShort", 1, address=15, writeOnly=True), + "flags": prop("boolean", 8, "array", entity="Coil"), + "hidden_flag": prop( + "boolean", 1, "boolean", entity="Coil", address=8, writeOnly=True + ), + } + initial = { + "u32": 0x12345678, + "u64": 0x0123456789ABCDEF, + "f32": 1.5, + "f64": -12.5, + "text": "abc", + "secret": 7, + "flags": [True, False] * 4, + } + configure_properties(tmp_path, properties, initial) + data_path = tmp_path / "initial.data.json" + data_path.write_text(json.dumps({"version": "1", "initial": initial})) + with socket.socket() as reservation: + reservation.bind(("127.0.0.1", 0)) + port = reservation.getsockname()[1] + root = Path(__file__).resolve().parents[1] + client = ModbusTcpClient("127.0.0.1", port=port, timeout=0.5, retries=0) + with (tmp_path / "server.log").open("w+") as log: + process = subprocess.Popen( + [ + sys.executable, + "-m", + "modsim", + "--config", + str(tmp_path / "codec.tm.json"), + "--data", + str(data_path), + "--port", + str(port), + "--unit-id", + "1", + ], + cwd=tmp_path, + env={**os.environ, "PYTHONPATH": str(root)}, + stdout=log, + stderr=log, + ) + try: + deadline = time.monotonic() + 8 + while not client.connect(): + if process.poll() is not None or time.monotonic() > deadline: + log.seek(0) + pytest.fail(log.read()) + time.sleep(0.05) + expected = [ + 0x1234, + 0x5678, + 0x0123, + 0x4567, + 0x89AB, + 0xCDEF, + 0x3FC0, + 0, + 0xC029, + 0, + 0, + 0, + 0x6162, + 0x6300, + 0, + ] + assert ( + client.read_holding_registers(0, count=15, device_id=1).registers + == expected + ) + assert client.read_holding_registers(15, device_id=1).isError() + assert not client.write_register(15, 9, device_id=1).isError() + assert not client.write_coil(8, True, device_id=1).isError() + assert client.read_coils(8, count=1, device_id=1).isError() + assert ( + client.read_coils(0, count=8, device_id=1).bits[:8] == initial["flags"] + ) + assert not client.write_coils(0, [False] * 8, device_id=1).isError() + assert client.read_coils(0, count=8, device_id=1).bits[:8] == [False] * 8 + assert client.write_register(7, 1, device_id=1).isError() + assert client.read_holding_registers(6, count=2, device_id=1).registers == [ + 0x3FC0, + 0, + ] + assert not client.write_register(6, 0x3F80, device_id=1).isError() + assert client.read_holding_registers(6, count=2, device_id=1).registers == [ + 0x3F80, + 0, + ] + assert not client.write_registers( + 2, [0xFEDC, 0xBA98, 0x7654, 0x3210], device_id=1 + ).isError() + assert client.read_holding_registers(2, count=4, device_id=1).registers == [ + 0xFEDC, + 0xBA98, + 0x7654, + 0x3210, + ] + assert client.write_registers(12, [0xFFFF, 0, 0], device_id=1).isError() + assert client.read_holding_registers( + 12, count=3, device_id=1 + ).registers == [0x6162, 0x6300, 0] + finally: + client.close() + process.terminate() + process.wait(timeout=5) + assert process.returncode == 0 + + +@pytest.mark.parametrize( + "constraints", [{"exclusiveMinimum": 0}, {"exclusiveMaximum": 0}] +) +def test_float_initial_respects_exclusive_zero_bounds(tmp_path, constraints): + instance = configure_properties( + tmp_path, {"value": prop("float", 2, "number", **constraints)} + ) + value = instance.get("value") + assert value > 0 if "exclusiveMinimum" in constraints else value < 0 + + +def test_float_rounding_reports_wire_value_and_rejects_unrepresentable_const(tmp_path): + instance = configure_properties( + tmp_path, {"value": prop("float", 2, "number")}, {"value": 0.1} + ) + assert instance.cells["holding_register"] == {0: 0x3DCC, 1: 0xCCCD} + assert instance.get("value") == 0.10000000149011612 + with pytest.raises(ValueError): + configure_properties(tmp_path, {"value": prop("float", 2, "number", const=0.1)}) + + +def test_impossible_string_length_is_rejected_without_large_allocation(tmp_path): + with pytest.raises(ValueError): + configure_properties( + tmp_path, {"value": prop("string", 2, "string", minLength=10**9)} + ) + + +@pytest.mark.parametrize("raw,quantity", [("float", 2), ("double", 4)]) +def test_float_initial_multipleof_intersects_declared_bounds(tmp_path, raw, quantity): + instance = configure_properties( + tmp_path, + { + "value": prop( + raw, quantity, "number", minimum=100, maximum=200, multipleOf=7 + ) + }, + ) + assert instance.get("value") == 105 + + +def test_bound_target_keeps_a_client_write_under_hold_and_follows_under_overwrite( + tmp_path, +): + source = prop("unsignedShort", 1, address=0) + target = prop("unsignedShort", 1, address=1) + for policy, expected in (("hold", 999), ("overwrite", 10)): + instance = configure_properties( + tmp_path, {"src": source, "tgt": target}, {"src": 10} + ) + instance.bindings = {"tgt": "src"} + instance.write_policy = policy + instance.apply_bindings() + context = RuntimeContext([instance]) + assert asyncio.run(context.async_setValues(1, 6, 1, [999])) is None + instance.advance(0, 1) + assert instance.get("src") == 10 + assert instance.get("tgt") == expected, policy + + +def test_rejected_write_restores_only_touched_cells_in_place(tmp_path): + flag = prop("unsignedShort", 1, address=0) + other = prop("unsignedShort", 1, address=1) + instance = configure_properties(tmp_path, {"a": flag, "b": other}, {"a": 1, "b": 2}) + cells = instance.cells + context = RuntimeContext([instance]) + + def fail(name, *args): + if name == "on_write": + instance.set("b", 77) + raise ValueError("script refused") + + instance.hook = fail + assert asyncio.run(context.async_setValues(1, 6, 0, [5])) == ExcCodes.ILLEGAL_VALUE + assert instance.get("a") == 1 and instance.get("b") == 2 + assert instance.cells is cells + assert instance.journal is None + + +def bit_prop(): + value = prop("unsignedShort", 1, "boolean") + value["forms"][0]["modpoll:bit"] = 0 + return value + + +@pytest.mark.parametrize( + "properties, name, value, match", + [ + ({"v": prop("unsignedShort", 1)}, "v", "text", "violates|expected"), + ({"v": prop("unsignedShort", 1)}, "v", True, "violates|expected"), + ({"v": prop("unsignedShort", 1)}, "v", 70000, "violates|cannot be encoded"), + ({"v": prop("float", 2, "number")}, "v", float("nan"), "violates|non-finite"), + ({"v": bit_prop()}, "v", 1, "violates"), + ({"v": bit_prop()}, "v", "yes", "violates"), + ], +) +def test_encoder_rejects_wrong_types_without_touching_the_register( + tmp_path, properties, name, value, match +): + instance = configure_properties(tmp_path, properties) + before = instance.get(name) + with pytest.raises(ValueError, match=match): + instance.set(name, value) + assert instance.get(name) == before + + +def test_script_hooks_must_be_synchronous(tmp_path): + from types import SimpleNamespace + + instance = configure_properties(tmp_path, {"v": prop("unsignedShort", 1)}) + + async def coroutine_hook(device, *args): + return None + + instance.script = SimpleNamespace(on_write=coroutine_hook) + with pytest.raises(ValueError, match="synchronous"): + instance.hook("on_write", {}) + instance.script = SimpleNamespace(on_write=lambda device, *args: asyncio.sleep(0)) + with pytest.raises(ValueError, match="synchronous"): + instance.hook("on_write", {}) + instance.script = SimpleNamespace(on_write=lambda device, *args: object()) + assert instance.hook("on_write", {}) is None + + +def test_async_hook_is_rejected_when_the_script_loads(tmp_path): + instance = configure_properties(tmp_path, {"v": prop("unsignedShort", 1)}) + script = tmp_path / "behavior.py" + script.write_text("async def tick(device, elapsed, dt):\n pass\n") + with pytest.raises(ValueError, match="must be a synchronous function"): + instance.load_script(str(script)) diff --git a/packages/modsim/tests/test_deployment.py b/packages/modsim/tests/test_deployment.py new file mode 100644 index 0000000..68b7ba2 --- /dev/null +++ b/packages/modsim/tests/test_deployment.py @@ -0,0 +1,399 @@ +"""Deployment isolation, scene updates, local hooks and bounded remote models.""" + +import asyncio +from io import BytesIO +import json +import os +from pathlib import Path +import socket +import subprocess +import sys +import time +from unittest.mock import patch + +import pytest +import yaml +from pymodbus.client import ModbusTcpClient + +from modsim.manifest import load_deployment +from argparse import Namespace +from modsim.runtime import RuntimeContext +from modsim.sources import model_document + +ROOT = Path(__file__).resolve().parents[1] +MODEL = ROOT / "tests/fixtures/io-module/adam-6024.tm.json" + + +def device(unit=1, **options): + return { + "id": options.pop("name", f"io-{unit}"), + "model": options.pop("model", str(MODEL)), + "parameters": {"THING_ID": f"urn:modsim:test:{unit}", "UNIT_ID": unit}, + **options, + } + + +def build(tmp_path, devices, **server): + # The fixture creates version 2 declarations; initial values belong to + # simulation data documents, not deployment device fields. + import copy + + devices = copy.deepcopy(devices) + for index, spec in enumerate(devices): + initial = spec.pop("initial", None) + if initial is not None: + data_path = tmp_path / f"fixture-data-{index}.json" + data_path.write_text(json.dumps({"version": "1", "initial": initial})) + spec["data"] = str(data_path) + path = tmp_path / "deployment.yaml" + path.write_text( + yaml.safe_dump( + {"version": 2, "name": "test-lab", "server": server, "devices": devices} + ) + ) + deployment = load_deployment(path) + runtimes = [ + item.build(allow_scripts=True) for item in deployment.instances.values() + ] + return Namespace(runtimes=runtimes, deployment=path) + + +def test_independent_units_and_atomic_invalid_writes(tmp_path): + args = build( + tmp_path, + [device(1, initial={"AO0_RAW": 12}), device(2, initial={"AO0_RAW": 34})], + ) + context = RuntimeContext(args.runtimes) + + async def check(): + assert await context.async_getValues(1, 3, 10) == [12] + assert await context.async_getValues(2, 3, 10) == [34] + assert await context.async_setValues(1, 16, 10, [56, 78]) is None + assert await context.async_getValues(1, 3, 10, 2) == [56, 78] + assert await context.async_getValues(2, 3, 10) == [34] + assert await context.async_setValues(1, 16, 11, [9, 9]) is not None + assert await context.async_getValues(1, 3, 10, 2) == [56, 78] + assert await context.async_setValues(1, 6, 0, [9]) is not None + assert await context.async_getValues(99, 3, 10) is not None + + asyncio.run(check()) + + +@pytest.mark.parametrize( + "devices", [[device(), device()], [device(), device(2, name="io-1")]] +) +def test_duplicate_instances_fail_before_listening(tmp_path, devices): + with pytest.raises(ValueError, match="duplicate"): + build(tmp_path, devices) + + +def test_relative_script_and_instance_state(tmp_path, monkeypatch): + (tmp_path / "models").mkdir() + (tmp_path / "models/io.tm.json").write_bytes(MODEL.read_bytes()) + (tmp_path / "scenes").mkdir() + (tmp_path / "scenes/behavior.py").write_text( + """counter = 0 + +def initialize(device): + device.set("AI0_RAW", 42) + +def tick(device, elapsed, dt): + global counter + counter += 1 + device.set("AI1_RAW", counter) + +def on_write(device, changes): + if "AO0_RAW" in changes: + device.set("AI0_RAW", changes["AO0_RAW"]) +""" + ) + specs = [ + device(unit, model="models/io.tm.json", script="scenes/behavior.py") + for unit in (1, 2) + ] + monkeypatch.chdir("/") + args = build(tmp_path, specs) + first, second = args.runtimes + assert first.get("AI0_RAW") == 42 + first.advance(1, 1) + assert first.get("AI1_RAW") == 2 + assert second.get("AI1_RAW") == 1 + asyncio.run(RuntimeContext(args.runtimes).async_setValues(1, 6, 10, [99])) + assert first.get("AI0_RAW") == 99 + assert second.get("AI0_RAW") == 42 + + +def test_script_requires_opt_in_and_unknown_fields_rejected(tmp_path): + (tmp_path / "script.py").write_text('raise AssertionError("must not execute")') + path = tmp_path / "denied.yaml" + path.write_text( + yaml.safe_dump( + {"version": 2, "name": "denied", "devices": [device(script="script.py")]} + ) + ) + with pytest.raises(ValueError, match="allow-scripts"): + next(iter(load_deployment(path).instances.values())).build() + with pytest.raises(ValueError, match="Additional properties"): + build(tmp_path, [device(typo=True)]) + + +def test_seeded_noise_and_client_write_policy(tmp_path): + data = { + "version": "1", + "seed": 73, + "generators": {"AO0_RAW": {"kind": "noise", "minimum": 1, "maximum": 100}}, + } + (tmp_path / "data.json").write_text(json.dumps(data)) + args = build(tmp_path, [device(1, data="data.json"), device(2, data="data.json")]) + first, second = args.runtimes + assert first.get("AO0_RAW") == second.get("AO0_RAW") + first.advance(1, 1) + second.advance(1, 1) + assert first.get("AO0_RAW") == second.get("AO0_RAW") + asyncio.run(RuntimeContext(args.runtimes).async_setValues(1, 6, 10, [777])) + first.advance(2, 1) + assert first.get("AO0_RAW") == 777 + first.write_policy = "overwrite" + first.advance(3, 1) + assert 1 <= first.get("AO0_RAW") <= 100 + + +def test_internal_measurement_updates_and_failed_batch_are_atomic(tmp_path): + instance = build(tmp_path, [device()]).runtimes[0] + instance.set("AI0_RAW", 123) + assert instance.get("AI0_RAW") == 123 + with pytest.raises(ValueError): + instance.set_many({"AI0_RAW": 456, "AI1_RAW": -1}) + assert instance.get("AI0_RAW") == 123 + + +def test_remote_model_uses_https_raw_and_shared_json_checks(): + class Response(BytesIO): + def geturl(self): + return "https://raw.githubusercontent.com/top-maker/modsim/v2/device.json" + + with patch( + "modsim.sources.urlopen", return_value=Response(MODEL.read_bytes()) + ) as request: + assert ( + model_document("https://github.com/top-maker/modsim/blob/v2/device.json")[ + "modpoll:version" + ] + == "0.2" + ) + assert ( + request.call_args.args[0].full_url + == "https://raw.githubusercontent.com/top-maker/modsim/v2/device.json" + ) + with patch("modsim.sources.urlopen", return_value=Response(b'{"a":1,"a":2}')): + with pytest.raises(ValueError, match="duplicate"): + model_document("https://example.com/model.json") + with patch("modsim.sources.urlopen", return_value=Response(b" " * 1048577)): + with pytest.raises(ValueError, match="exceeds"): + model_document("https://example.com/model.json") + with pytest.raises(ValueError, match="HTTPS"): + model_document("http://example.com/model.json") + + +@pytest.mark.integration +def test_multi_device_listener_loopback_and_shutdown(tmp_path): + with socket.socket() as reservation: + reservation.bind(("127.0.0.1", 0)) + port = reservation.getsockname()[1] + path = build( + tmp_path, + [ + device(1, initial={"AO0_RAW": 10}), + device( + 2, + data=str( + ROOT / "tests/fixtures/io-module/simulation/adam-6024.data.json" + ), + ), + ], + port=port, + ).deployment + client = ModbusTcpClient("127.0.0.1", port=port, timeout=0.5, retries=0) + with (tmp_path / "server.log").open("w+") as log: + process = subprocess.Popen( + [sys.executable, "-m", "modsim", "up", "-f", str(path)], + cwd=tmp_path, + env={**os.environ, "PYTHONPATH": str(ROOT)}, + stdout=log, + stderr=log, + ) + try: + deadline = time.monotonic() + 8 + while not client.connect(): + if process.poll() is not None or time.monotonic() >= deadline: + log.seek(0) + pytest.fail(log.read()) + time.sleep(0.05) + assert client.read_holding_registers(10, device_id=1).registers == [10] + assert not client.write_register(10, 432, device_id=2).isError() + assert client.read_input_registers(0, device_id=2).registers == [432] + assert client.read_holding_registers(10, device_id=1).registers == [10] + assert not client.write_coil(16, True, device_id=2).isError() + assert client.read_discrete_inputs(0, device_id=2).bits[0] is True + assert client.read_input_registers(0, device_id=3).isError() + assert client.read_coils(18, device_id=2).isError() + finally: + client.close() + process.terminate() + process.wait(timeout=5) + assert process.returncode == 0 + with socket.socket() as check: + # Match server reuse semantics: TIME_WAIT is not a live listener. + check.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) + check.bind(("127.0.0.1", port)) + + +def test_invalid_generator_envelope_and_binding_cycles_fail_at_startup(tmp_path): + scene = tmp_path / "invalid.json" + scene.write_text( + json.dumps( + { + "version": "1", + "generators": { + "AI0_RAW": { + "kind": "sine", + "center": 65530, + "amplitude": 10, + "period": 2, + } + }, + } + ) + ) + with pytest.raises(ValueError): + build(tmp_path, [device(data=scene.name)]) + scene.write_text( + json.dumps( + {"version": "1", "bindings": {"AO0_RAW": "AO1_RAW", "AO1_RAW": "AO0_RAW"}} + ) + ) + with pytest.raises(ValueError, match="chains/cycles"): + build(tmp_path, [device(data=scene.name)]) + + +def test_failed_write_hook_rolls_back_entire_device(tmp_path): + args = build(tmp_path, [device(initial={"AO0_RAW": 11, "AI0_RAW": 22})]) + instance = args.runtimes[0] + + class FailingScript: + @staticmethod + def on_write(device, changes): + device.set("AI0_RAW", 333) + raise ValueError("invalid device command") + + instance.script = FailingScript + assert ( + asyncio.run(RuntimeContext([instance]).async_setValues(1, 6, 10, [44])) + is not None + ) + assert instance.get("AO0_RAW") == 11 + assert instance.get("AI0_RAW") == 22 + assert not instance.held + + +def test_legacy_deployment_version_rejected(tmp_path): + path = tmp_path / "deployment.yaml" + path.write_text(json.dumps({"version": "1", "devices": []})) + with pytest.raises(ValueError, match="version"): + load_deployment(path) + + +def test_json_deployment_file_rejected(tmp_path): + path = tmp_path / "deployment.json" + path.write_text(json.dumps({"version": 2, "devices": []})) + with pytest.raises(ValueError, match="must use .yaml or .yml"): + load_deployment(path) + + +def test_explicit_thing_id_for_model_without_id(tmp_path): + instance = build(tmp_path, [device()]).runtimes[0] + deployment = load_deployment(tmp_path / "deployment.yaml") + assert deployment.instances["io-1"].td["id"] == "urn:modsim:test:1" + assert instance.unit_id == 1 + + +def test_root_adam_deployment(): + if not (ROOT / "examples/models").is_dir(): + pytest.skip("run tools/fetch-models.py to populate examples/models") + deployment = load_deployment(ROOT / "examples/deployment.yaml") + assert deployment.bind == "0.0.0.0" + assert [item.model.unit_id for item in deployment.instances.values()] == [1, 2] + assert all( + item.model.endpoint == ("127.0.0.1", 5020) + for item in deployment.instances.values() + ) + + +def test_removed_deployment_cli_option(tmp_path): + result = subprocess.run( + [sys.executable, "-m", "modsim", "--deployment", "old.json"], + cwd=tmp_path, + env={**os.environ, "PYTHONPATH": str(ROOT)}, + capture_output=True, + timeout=8, + ) + assert result.returncode != 0 + assert b"unrecognized arguments: --deployment" in result.stderr + + +def test_script_path_cannot_leave_the_deployment_directory(tmp_path): + project = tmp_path / "project" + project.mkdir() + (tmp_path / "evil.py").write_text('raise AssertionError("must not execute")') + (project / "link.py").symlink_to(tmp_path / "evil.py") + for script in ("../evil.py", str(tmp_path / "evil.py"), "link.py"): + with pytest.raises(ValueError, match="script must stay inside"): + build(project, [device(script=script)]) + + +def test_noise_sequences_follow_the_seed_and_differ_between_seeds(tmp_path): + for name, seed in (("a", 73), ("b", 74)): + (tmp_path / f"{name}.json").write_text( + json.dumps( + { + "version": "1", + "seed": seed, + "generators": { + "AO0_RAW": {"kind": "noise", "minimum": 1, "maximum": 100} + }, + } + ) + ) + args = build( + tmp_path, + [device(1, data="a.json"), device(2, data="a.json"), device(3, data="b.json")], + ) + sequences = [] + for runtime in args.runtimes: + values = [] + for tick in range(1, 9): + runtime.advance(tick, 1) + values.append(runtime.get("AO0_RAW")) + sequences.append(values) + assert sequences[0] == sequences[1] + assert sequences[0] != sequences[2] + + +def test_deployment_root_finds_the_modsim_project_inside_a_workspace(tmp_path): + from modsim.manifest import deployment_root + + (tmp_path / ".git").mkdir() + (tmp_path / ".git" / "HEAD").write_text("ref: refs/heads/v2\n") + package = tmp_path / "packages" / "modsim" + (package / "examples").mkdir(parents=True) + (package / "pyproject.toml").write_text('[project]\nname = "modsim"\n') + # modsim's own example resolves against the package, not the workspace repository. + assert deployment_root(package / "examples" / "deployment.yaml") == package + # Any other checked-in deployment keeps the repository root. + (tmp_path / "pyproject.toml").write_text('[project]\nname = "plant"\n') + (tmp_path / "lab").mkdir() + assert deployment_root(tmp_path / "lab" / "deployment.yaml") == tmp_path + # Outside Git, the configuration directory is the root. + alone = tmp_path.parent / (tmp_path.name + "-alone") + alone.mkdir() + assert deployment_root(alone / "deployment.yaml") == alone diff --git a/packages/modsim/tests/test_login.py b/packages/modsim/tests/test_login.py new file mode 100644 index 0000000..5934475 --- /dev/null +++ b/packages/modsim/tests/test_login.py @@ -0,0 +1,318 @@ +"""Sign in to ModioHub and read Workspace Thing Models (POLL-02b).""" + +import hashlib +import io +import json +import os +import stat +import sys +from unittest.mock import patch +from urllib.error import HTTPError + +import modpoll_wot +import pytest + +from modsim import hub, login, main, sources + +SERVER = "https://hub.test" +ID = "k3x9f2m7q4a8n5bd" + + +@pytest.fixture(autouse=True) +def isolated_login(monkeypatch, tmp_path): + monkeypatch.setenv("MODIOHUB_URL", SERVER) + monkeypatch.setenv("MODIOHUB_CREDENTIALS", str(tmp_path / "credentials.json")) + monkeypatch.delenv("MODIOHUB_TOKEN", raising=False) + return tmp_path / "credentials.json" + + +class Answer(io.BytesIO): + status = 200 + + def __enter__(self): + return self + + def __exit__(self, *exc): + return False + + +def reply(status, body): + payload = body if isinstance(body, bytes) else json.dumps(body).encode() + if status < 400: + answer = Answer(payload) + answer.status = status + return answer + return HTTPError("https://hub.test", status, "error", {}, io.BytesIO(payload)) + + +def fake_hub(routes, calls): + """Answer by URL suffix; a list is consumed in order. Records (method, url, token).""" + + def urlopen(request, timeout=None): + calls.append( + ( + request.get_method(), + request.full_url, + request.get_header("Authorization"), + ) + ) + for suffix, answer in routes.items(): + if request.full_url.endswith(suffix): + result = answer.pop(0) if isinstance(answer, list) else answer + if isinstance(result, HTTPError): + raise result + return result + raise AssertionError(f"unexpected request {request.full_url}") + + return patch.object(hub, "urlopen", urlopen) + + +def grant(): + return reply( + 200, + { + "device_code": "secret", + "user_code": "ABCD1234", + "interval": 5, + "expires_in": 900, + "verification_uri": f"{SERVER}/activate/", + "verification_uri_complete": f"{SERVER}/activate/?user_code=ABCD1234", + }, + ) + + +def test_login_waits_for_the_browser_and_shares_the_login_with_modpoll(isolated_login): + calls = [] + routes = { + "/device-authorization": [grant()], + "/token": [ + reply(400, {"error": "authorization_pending"}), + reply(400, {"error": "slow_down"}), + reply( + 200, + {"access_token": "tok", "token_type": "Bearer", "expires_in": 604800}, + ), + ], + "/api/v1/me": [reply(200, {"githubUser": "octo"})], + } + slept, out = [], io.StringIO() + with fake_hub(routes, calls): + session = login.login( + SERVER, sleep=slept.append, open_browser=lambda url: False, out=out + ) + assert slept == [5, 5, 10] + assert ( + "ABCD1234" in out.getvalue() + and "Open the address above in a browser" in out.getvalue() + ) + assert calls[0][:2] == ( + "POST", + f"{SERVER}/api/v1/tool-sessions/device-authorization", + ) + assert ("GET", f"{SERVER}/api/v1/me", "Bearer tok") in calls + assert (session.token, session.github_user) == ("tok", "octo") + assert modpoll_wot.load_session(SERVER).token == "tok" + if os.name == "posix": + assert stat.S_IMODE(isolated_login.stat().st_mode) == 0o600 + + +@pytest.mark.parametrize( + "error, message", + [ + ("access_denied", "denied"), + ("expired_token", "expired"), + ("invalid_grant", "failed"), + ], +) +def test_login_ends_with_a_reason(error, message): + routes = { + "/device-authorization": [grant()], + "/token": [reply(400, {"error": error})], + } + with fake_hub(routes, []), pytest.raises(login.LoginError, match=message): + login.login( + SERVER, + sleep=lambda seconds: None, + open_browser=lambda url: True, + out=io.StringIO(), + ) + assert modpoll_wot.load_session(SERVER) is None + + +def test_commands(capsys): + routes = { + "/device-authorization": [grant()], + "/token": [reply(200, {"access_token": "tok", "expires_in": 60})], + "/api/v1/me": [reply(200, {"githubUser": "octo"})], + } + with ( + fake_hub(routes, []), + patch.object(login, "open_in_browser", return_value=True), + patch.object(login.time, "sleep"), + ): + assert login.command(["login"]) == 0 + assert ( + "Signed in to https://hub.test as @octo. modpoll uses the same login." + in capsys.readouterr().out + ) + assert login.command(["logout"]) == 0 + assert "revoke it in Settings" in capsys.readouterr().out + assert login.command(["logout"]) == 0 + assert "No stored login" in capsys.readouterr().out + assert login.command(["login", "--server", "http://example.com"]) == 1 + assert login.command(["login", "--bogus"]) == 1 + + +def test_login_and_logout_run_before_the_normal_arguments(monkeypatch): + monkeypatch.setattr(sys, "argv", ["modsim", "logout"]) + with pytest.raises(SystemExit) as exit_info: + main.app() + assert exit_info.value.code == 0 + + +def model( + *, status=200, sha256=None, file_url=None, versions=None, body=b'{"title": "meter"}' +): + versions = versions or [ + { + "version": 2, + "sha256": sha256 or hashlib.sha256(body).hexdigest(), + "fileUrl": file_url or f"{SERVER}/api/v1/thing-models/{ID}/versions/2/file", + } + ] + return { + f"/thing-models/{ID}": reply(status, {"versions": versions}), + "/versions/2/file": reply(200, body), + } + + +def test_a_workspace_model_is_read_with_the_login_and_checked(): + modpoll_wot.save_session(SERVER, "tok", expires_in=3600) + calls = [] + with fake_hub(model(), calls): + assert sources.model_document(f"modiohub:{ID}@latest") == {"title": "meter"} + assert {token for _, _, token in calls} == {"Bearer tok"} + with fake_hub(model(), []), pytest.raises(ValueError, match="no version 5"): + sources.model_document(f"modiohub:{ID}@5") + + +def test_a_shared_model_needs_no_login_and_a_private_one_says_so(): + calls = [] + with fake_hub(model(), calls): + sources.model_document(f"modiohub:{ID}@2") + assert {token for _, _, token in calls} == {None} + with ( + fake_hub(model(status=404), []), + pytest.raises(ValueError, match="run modsim login if it is yours"), + ): + sources.model_document(f"modiohub:{ID}") + + +def test_a_download_that_does_not_match_or_leaves_the_server_is_refused(): + modpoll_wot.save_session(SERVER, "tok", expires_in=3600) + with ( + fake_hub(model(sha256="0" * 64), []), + pytest.raises(ValueError, match="SHA-256"), + ): + sources.model_document(f"modiohub:{ID}@2") + calls = [] + with ( + fake_hub(model(file_url="https://elsewhere.test/m.json"), calls), + pytest.raises(ValueError, match="another address"), + ): + sources.model_document(f"modiohub:{ID}@2") + assert all(url.startswith(SERVER) for _, url, _ in calls) + + +def test_a_bad_reference_and_a_deployment_manifest_do_not_use_the_login(): + with pytest.raises(ValueError, match="modiohub:<id>@<version>"): + sources.model_document("modiohub:nope") + + +class Finished: + def __init__(self, returncode): + self.returncode = returncode + + +@pytest.mark.parametrize( + "environ, platform, expected_calls", + [ + ({"DISPLAY": ":0"}, "linux", 1), + ({"WAYLAND_DISPLAY": "wayland-0"}, "linux", 1), + ({}, "linux", 0), # no desktop: SSH or a minimal WSL + ({"DISPLAY": ":0", "SSH_CONNECTION": "1 2 3 4"}, "linux", 0), + ], +) +def test_a_browser_is_tried_only_where_there_is_a_desktop( + environ, platform, expected_calls +): + calls = [] + opened = login.open_in_browser( + "https://hub.test/activate/?user_code=X", + environ=environ, + platform=platform, + run=lambda command, **options: calls.append((command, options)) or Finished(0), + which=lambda name: "/usr/bin/xdg-open", + ) + assert len(calls) == expected_calls and opened is bool(expected_calls) + if calls: + # The opener's complaints stay out of the terminal. + assert ( + calls[0][1]["stdout"] == login.subprocess.DEVNULL + and calls[0][1]["stderr"] == login.subprocess.DEVNULL + ) + + +def test_an_opener_that_finds_no_browser_or_is_missing_is_a_failure_not_noise(): + environ = {"DISPLAY": ":0"} + assert ( + login.open_in_browser( + "https://x.test", + environ=environ, + platform="linux", + run=lambda *a, **k: Finished(3), + which=lambda name: "/usr/bin/xdg-open", + ) + is False + ) + assert ( + login.open_in_browser( + "https://x.test", environ=environ, platform="linux", which=lambda name: None + ) + is False + ) + + def broken(*args, **kwargs): + raise OSError("gone") + + assert ( + login.open_in_browser( + "https://x.test", + environ=environ, + platform="linux", + run=broken, + which=lambda name: "/usr/bin/xdg-open", + ) + is False + ) + + +def test_the_browser_variable_and_other_platforms_use_the_standard_opener(monkeypatch): + seen = [] + monkeypatch.setattr(login.webbrowser, "open", lambda url: seen.append(url) or True) + assert ( + login.open_in_browser( + "https://a.test", environ={"BROWSER": "wslview"}, platform="linux" + ) + is True + ) + assert ( + login.open_in_browser("https://b.test", environ={}, platform="darwin") is True + ) + assert seen == ["https://a.test", "https://b.test"] + + +def test_ctrl_c_while_waiting_is_a_one_line_cancel(capsys): + with patch.object(login, "login", side_effect=KeyboardInterrupt): + assert login.command(["login"]) == 130 + assert "Login cancelled." in capsys.readouterr().err diff --git a/packages/modsim/tests/test_management.py b/packages/modsim/tests/test_management.py new file mode 100644 index 0000000..85a6895 --- /dev/null +++ b/packages/modsim/tests/test_management.py @@ -0,0 +1,479 @@ +"""Managed deployment acceptance using independent TCP clients and CLI processes.""" + +import asyncio +import json +import os +from pathlib import Path +import socket +import subprocess +import sys +import uuid + +import pytest +import yaml +from modpoll_wot import parse_model, validate_standard +from pymodbus.client import ModbusTcpClient + +from modsim.management import RuntimeManager +from modsim.manifest import load_deployment, read_yaml + +ROOT = Path(__file__).resolve().parents[1] +SOURCE = ROOT / "tests/fixtures/io-module/adam-6024.tm.json" + + +def fixture(tmp_path): + model = json.loads(SOURCE.read_text()) + model["id"] = "{{THING_ID}}" + model["title"] = "{{TITLE}}" + (tmp_path / "io.tm.json").write_text(json.dumps(model)) + (tmp_path / "data.json").write_text( + json.dumps({"version": "1", "initial": {"AO0_RAW": 12}}) + ) + with socket.socket() as reservation: + reservation.bind(("127.0.0.1", 0)) + port = reservation.getsockname()[1] + spec = { + "version": 2, + "name": "test-" + uuid.uuid4().hex[:16], + "server": {"bind": "127.0.0.1", "port": port}, + "devices": [device(1)], + } + path = tmp_path / "deployment.yaml" + write(path, spec) + return path, spec, port + + +def device(unit): + return { + "id": f"io-{unit}", + "model": "io.tm.json", + "parameters": { + "THING_ID": f"urn:modsim:test:io-{unit}", + "TITLE": f"I/O {unit}", + "UNIT_ID": unit, + }, + "data": "data.json", + } + + +def write(path, spec): + path.write_text(yaml.safe_dump(spec, allow_unicode=True, sort_keys=False)) + + +def cli(path, *args, check=True): + result = subprocess.run( + [sys.executable, "-m", "modsim", *args, "--file", str(path)], + cwd=path.parent, + env={**os.environ, "PYTHONPATH": str(ROOT), "PYTHONDONTWRITEBYTECODE": "1"}, + capture_output=True, + text=True, + timeout=45, + ) + if check: + assert result.returncode == 0, result.stderr + result.stdout + return result + + +def test_yaml_rejects_duplicates_aliases_nonfinite_and_deep_input(tmp_path): + path = tmp_path / "deployment.yaml" + for payload, error in [ + ("version: 2\nversion: 2", "duplicate"), + ("a: &a [1]\nb: *a", "aliases"), + ("a: .nan", "finite"), + ("a: " + "[" * 70 + "0" + "]" * 70, "nesting"), + ("a: 2026-10-29", "JSON-compatible"), + ]: + path.write_text(payload) + with pytest.raises(ValueError, match=error): + read_yaml(path) + + +def test_yaml_defaults_and_stable_standard_td(tmp_path): + path, spec, port = fixture(tmp_path) + path.write_text( + "version: 2\nname: lab\nserver:\n port: " + str(port) + "\ndevices:\n" + " - id: io-1\n model: io.tm.json\n parameters:\n" + " THING_ID: urn:modsim:test:io-1\n TITLE: 一号设备\n UNIT_ID: 7\n" + ) + desired = load_deployment(path) + instance = desired.instances["io-1"] + validate_standard(instance.td, kind="td") + assert parse_model(instance.td).unit_id == 7 + assert instance.td["title"] == "一号设备" + assert instance.model.endpoint == ("127.0.0.1", port) + assert instance.td == load_deployment(path).instances["io-1"].td + + +@pytest.mark.parametrize( + "change,match", + [ + ("duplicate-unit", "duplicate"), + ("duplicate-id", "duplicate"), + ("duplicate-td", "duplicate"), + ("unknown-parameter", "unused"), + ("missing-parameter", "unbound"), + ("wildcard", "requires parameters.HOST"), + ("missing-id", "stable TD id"), + ], +) +def test_invalid_instances_fail_before_start(tmp_path, change, match): + path, spec, _ = fixture(tmp_path) + other = device(2) + if change == "duplicate-unit": + other["parameters"]["UNIT_ID"] = 1 + elif change == "duplicate-id": + other["id"] = "io-1" + elif change == "duplicate-td": + other["parameters"]["THING_ID"] = "urn:modsim:test:io-1" + elif change == "unknown-parameter": + other["parameters"]["TYPO"] = 3 + elif change == "missing-parameter": + del other["parameters"]["TITLE"] + elif change == "wildcard": + spec["server"]["bind"] = "0.0.0.0" + elif change == "missing-id": + model = json.loads((tmp_path / "io.tm.json").read_text()) + del model["id"] + del other["parameters"]["THING_ID"] + del spec["devices"][0]["parameters"]["THING_ID"] + (tmp_path / "io.tm.json").write_text(json.dumps(model)) + spec["devices"].append(other) + write(path, spec) + with pytest.raises(ValueError, match=match): + load_deployment(path) + + +def test_snapshot_reset_reconcile_and_cleanup(tmp_path): + path, spec, _ = fixture(tmp_path) + + async def exercise(): + manager = RuntimeManager() + try: + await manager.apply(load_deployment(path)) + original = manager.devices["io-1"] + original.set("AO0_RAW", 99) + await manager.apply(load_deployment(path)) + assert manager.devices["io-1"] is original + assert original.get("AO0_RAW") == 99 + spec["devices"].append(device(2)) + write(path, spec) + await manager.apply(load_deployment(path)) + assert manager.devices["io-1"] is original + retired = manager.tasks["io-2"] + spec["devices"].pop() + write(path, spec) + await manager.apply(load_deployment(path)) + assert retired.done() + assert 2 not in manager.context.devices + (tmp_path / "data.json").write_text("invalid on disk") + await manager.reset("io-1") + assert manager.devices["io-1"].get("AO0_RAW") == 12 + finally: + await manager.close() + assert all(task.done() for task in manager.tasks.values()) + + asyncio.run(exercise()) + + +def test_dry_run_never_executes_scripts_and_failures_preserve_live_state(tmp_path): + path, spec, _ = fixture(tmp_path) + marker = tmp_path / "executed" + (tmp_path / "behavior.py").write_text( + f"from pathlib import Path\nPath({str(marker)!r}).touch()\n" + "def initialize(device):\n raise RuntimeError('candidate failed')\n" + ) + + async def exercise(): + manager = RuntimeManager(allow_scripts=True) + try: + await manager.apply(load_deployment(path)) + original = manager.devices["io-1"] + spec["devices"][0]["script"] = "behavior.py" + write(path, spec) + desired = load_deployment(path) + plan = await manager.apply(desired, dry_run=True) + assert plan["replaced"] == ["io-1"] + assert not marker.exists() + with pytest.raises(RuntimeError, match="candidate failed"): + await manager.apply(desired) + assert manager.devices["io-1"] is original + assert manager.context.devices[1] is original + finally: + await manager.close() + + asyncio.run(exercise()) + + +@pytest.mark.integration +def test_cli_live_add_remove_replace_export_reset_and_rollback(tmp_path): + path, spec, port = fixture(tmp_path) + client = ModbusTcpClient("127.0.0.1", port=port, timeout=1, retries=0) + try: + cli(path, "up", "-d") + first_pid = json.loads(cli(path, "ps").stdout)["pid"] + assert client.connect() + assert not client.write_register(10, 99, device_id=1).isError() + cli(path, "up", "-d") + assert client.read_holding_registers(10, device_id=1).registers == [99] + spec["devices"].append(device(2)) + write(path, spec) + cli(path, "up", "--dry-run") + assert client.read_holding_registers(10, device_id=2).isError() + cli(path, "up", "-d") + assert client.read_holding_registers(10, device_id=2).registers == [12] + assert client.read_holding_registers(10, device_id=1).registers == [99] + # Invalid update cannot retire either live instance. + spec["devices"][1]["parameters"]["UNIT_ID"] = 1 + write(path, spec) + assert cli(path, "up", "-d", check=False).returncode == 2 + assert client.read_holding_registers(10, device_id=2).registers == [12] + spec["devices"].pop() + write(path, spec) + cli(path, "up", "-d") + assert client.read_holding_registers(10, device_id=2).isError() + assert client.read_holding_registers(10, device_id=1).registers == [99] + cli(path, "reset", "--device", "io-1") + assert client.read_holding_registers(10, device_id=1).registers == [12] + # Export the applied version while on-disk parameters have drifted. + spec["devices"][0]["parameters"]["TITLE"] = "Changed offline" + write(path, spec) + live, offline = tmp_path / "live.json", tmp_path / "offline.json" + cli(path, "export", "--running", "--device", "io-1", "-o", str(live)) + cli(path, "export", "--device", "io-1", "-o", str(offline)) + assert json.loads(live.read_text())["title"] == "I/O 1" + assert json.loads(offline.read_text())["title"] == "Changed offline" + assert not client.write_register(10, 77, device_id=1).isError() + cli(path, "up", "-d") + assert client.read_holding_registers(10, device_id=1).registers == [12] + assert json.loads(cli(path, "ps").stdout)["pid"] == first_pid + # Listener changes explicitly require down/up. + spec["server"]["port"] = port + 1 if port < 65535 else port - 1 + write(path, spec) + assert "run down" in cli(path, "up", "-d", check=False).stderr + # Same-name deployments cannot take control from another file. + conflict = tmp_path / "other.yaml" + write(conflict, spec) + assert "different file" in cli(conflict, "up", "-d", check=False).stderr + spec["server"]["port"] = port + spec["devices"] = [] + write(path, spec) + cli(path, "up", "-d") + assert client.read_holding_registers(10, device_id=1).isError() + spec["devices"] = [device(1)] + write(path, spec) + cli(path, "up", "-d") + assert client.read_holding_registers(10, device_id=1).registers == [12] + assert cli(path, "logs").stdout + finally: + client.close() + cli(path, "down") + assert json.loads(cli(path, "ps").stdout)["running"] is False + cli(path, "down") + with socket.socket() as check: + # Match server reuse semantics: TIME_WAIT is not a live listener. + check.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) + check.bind(("127.0.0.1", port)) + + +def test_offline_export_requires_no_process_and_does_not_run_behavior(tmp_path): + path, spec, _ = fixture(tmp_path) + (tmp_path / "fail.py").write_text("raise RuntimeError('must not execute')") + spec["devices"][0]["script"] = "fail.py" + write(path, spec) + output = tmp_path / "tds" + cli(path, "export", "--output-dir", str(output)) + td = json.loads((output / "io-1.td.json").read_text()) + validate_standard(td, kind="td") + assert parse_model(td).unit_id == 1 + + +def test_reset_uses_pristine_script_parameters(tmp_path): + path, spec, _ = fixture(tmp_path) + (tmp_path / "behavior.py").write_text( + "def initialize(device):\n" + " device.parameters['counter'] += 1\n" + " device.set('AO0_RAW', device.parameters['counter'])\n" + ) + spec["devices"][0]["script"] = "behavior.py" + spec["devices"][0]["scriptParameters"] = {"counter": 0} + write(path, spec) + + async def exercise(): + manager = RuntimeManager(allow_scripts=True) + try: + await manager.apply(load_deployment(path)) + assert manager.devices["io-1"].get("AO0_RAW") == 1 + await manager.reset("io-1") + assert manager.devices["io-1"].get("AO0_RAW") == 1 + finally: + await manager.close() + + asyncio.run(exercise()) + + +def test_managed_behavior_failure_isolated_and_not_revived_by_unchanged_up(tmp_path): + path, spec, _ = fixture(tmp_path) + (tmp_path / "fail.py").write_text( + "def tick(device, elapsed, dt):\n" + " if elapsed > 0:\n" + " raise RuntimeError('failed device')\n" + ) + (tmp_path / "fail.json").write_text(json.dumps({"version": "1", "tick": 0.001})) + spec["devices"][0]["data"] = "fail.json" + spec["devices"][0]["script"] = "fail.py" + spec["devices"].append(device(2)) + write(path, spec) + + async def exercise(): + manager = RuntimeManager(allow_scripts=True) + try: + await manager.apply(load_deployment(path)) + await asyncio.wait_for(manager.tasks["io-1"], 2) + assert 1 not in manager.context.devices + assert 2 in manager.context.devices + assert manager.status()["devices"][0]["state"] == "failed" + original = manager.tasks["io-1"] + await manager.apply(load_deployment(path)) + assert 1 not in manager.context.devices + assert manager.tasks["io-1"] is original + await manager.reset("io-1") + assert manager.tasks["io-1"] is not original + finally: + await manager.close() + + asyncio.run(exercise()) + + +def test_export_does_not_require_data_files(tmp_path): + path, spec, _ = fixture(tmp_path) + (tmp_path / "data.json").unlink() + output = tmp_path / "instance.td.json" + cli(path, "export", "--device", "io-1", "-o", str(output)) + assert parse_model(json.loads(output.read_text())).unit_id == 1 + + +@pytest.mark.integration +def test_default_file_foreground_signal_cleanup(tmp_path): + import time + + path, spec, port = fixture(tmp_path) + with (tmp_path / "foreground.log").open("w+") as log: + process = subprocess.Popen( + [sys.executable, "-m", "modsim", "up"], + cwd=tmp_path, + env={**os.environ, "PYTHONPATH": str(ROOT)}, + stdout=log, + stderr=log, + ) + try: + deadline = time.monotonic() + 10 + while True: + if process.poll() is not None: + log.seek(0) + pytest.fail(log.read()) + status = json.loads(cli(path, "ps").stdout) + if status["running"]: + break + assert time.monotonic() < deadline + time.sleep(0.05) + finally: + process.terminate() + process.wait(timeout=10) + assert process.returncode == 0 + assert json.loads(cli(path, "ps").stdout)["running"] is False + with socket.socket() as check: + # Match server reuse semantics: TIME_WAIT is not a live listener. + check.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) + check.bind(("127.0.0.1", port)) + + +@pytest.mark.integration +def test_attached_up_and_follow_logs_detach_without_stopping(tmp_path): + import signal + import time + + path, _, _ = fixture(tmp_path) + cli(path, "up", "-d") + env = {**os.environ, "PYTHONPATH": str(ROOT)} + try: + for command in (["up"], ["logs", "-f"], ["logs", "--follow"]): + with (tmp_path / "output.log").open("w+") as output: + process = subprocess.Popen( + [sys.executable, "-m", "modsim", *command, "--file", str(path)], + cwd=tmp_path, + env=env, + stdout=output, + stderr=output, + ) + try: + deadline = time.monotonic() + 10 + while time.monotonic() < deadline: + output.flush() + if (tmp_path / "output.log").stat().st_size: + break + assert process.poll() is None + time.sleep(0.05) + else: + pytest.fail("attached command did not print logs") + assert process.poll() is None + finally: + process.send_signal(signal.SIGINT) + process.wait(timeout=5) + assert json.loads(cli(path, "ps").stdout)["running"] is True + finally: + cli(path, "down") + + +def test_apply_builds_devices_off_the_event_loop(tmp_path, monkeypatch): + import threading + + path, _, _ = fixture(tmp_path) + desired = load_deployment(path) + instance_type = type(desired.instances["io-1"]) + original = instance_type.build + threads = [] + + def build(self, *args, **kwargs): + threads.append(threading.current_thread()) + return original(self, *args, **kwargs) + + monkeypatch.setattr(instance_type, "build", build) + + async def exercise(): + manager = RuntimeManager() + try: + await manager.apply(desired) + finally: + await manager.close() + + asyncio.run(exercise()) + assert threads and all(t is not threading.main_thread() for t in threads) + + +def test_idle_management_connection_does_not_block_other_commands(tmp_path): + import time + + from modsim.management import paths + + path, spec, _ = fixture(tmp_path) + process = subprocess.Popen( + [sys.executable, "-m", "modsim", "up"], + cwd=tmp_path, + env={**os.environ, "PYTHONPATH": str(ROOT)}, + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL, + ) + try: + deadline = time.monotonic() + 10 + while not json.loads(cli(path, "ps").stdout)["running"]: + assert time.monotonic() < deadline and process.poll() is None + time.sleep(0.05) + with socket.socket(socket.AF_UNIX) as idle: + idle.connect(str(paths(spec["name"])[0])) + started = time.monotonic() + assert json.loads(cli(path, "ps").stdout)["running"] + # The server drops an idle client after 5 seconds. + assert time.monotonic() - started < 3 + finally: + process.terminate() + process.wait(timeout=10) diff --git a/packages/modsim/tests/test_model_source.py b/packages/modsim/tests/test_model_source.py new file mode 100644 index 0000000..5533123 --- /dev/null +++ b/packages/modsim/tests/test_model_source.py @@ -0,0 +1,79 @@ +"""Pinned consumer input integrity, containment and real runtime compilation.""" + +import hashlib +from importlib.util import module_from_spec, spec_from_file_location +from io import BytesIO +from pathlib import Path +from unittest.mock import patch + +import pytest +import yaml + +ROOT = Path(__file__).resolve().parents[1] +spec = spec_from_file_location("fetch_models", ROOT / "tools/fetch-models.py") +fetch_models = module_from_spec(spec) +spec.loader.exec_module(fetch_models) + + +class Response(BytesIO): + def geturl(self): + return "https://example.invalid/model" + + +def test_verified_inputs_and_no_partial_write_on_bad_hash(tmp_path): + payload = b"verified input" + lock = { + "repository": "example/models", + "revision": "1" * 40, + "files": {"vendor/model/model.tm.json": hashlib.sha256(payload).hexdigest()}, + } + path = tmp_path / "source.yaml" + path.write_text(yaml.safe_dump(lock)) + output = tmp_path / "out" + with patch.object( + fetch_models, "urlopen", return_value=Response(payload) + ) as remote: + fetch_models.fetch(path, output) + assert "/" + "1" * 40 + "/" in remote.call_args.args[0] + assert (output / "vendor/model/model.tm.json").read_bytes() == payload + lock["files"]["other.tm.json"] = "0" * 64 + path.write_text(yaml.safe_dump(lock)) + with patch.object( + fetch_models, "urlopen", side_effect=[Response(payload), Response(b"bad")] + ): + with pytest.raises(ValueError, match="hash mismatch"): + fetch_models.fetch(path, tmp_path / "bad") + assert not (tmp_path / "bad").exists() + + +@pytest.mark.parametrize( + "revision,name", + [("main", "model.tm.json"), ("1" * 40, "../escape"), ("1" * 40, "/absolute")], +) +def test_rejects_floating_revision_and_escaping_paths(tmp_path, revision, name): + path = tmp_path / "source.yaml" + path.write_text( + yaml.safe_dump( + { + "repository": "example/models", + "revision": revision, + "files": {name: "0" * 64}, + } + ) + ) + with patch.object(fetch_models, "urlopen") as remote: + with pytest.raises(ValueError): + fetch_models.fetch(path, tmp_path / "out") + remote.assert_not_called() + + +def test_pinned_catalog_deployment_compiles_when_prepared(): + from modsim.manifest import load_deployment + + if not (ROOT / "examples/models").exists(): + pytest.skip("Run tools/fetch-models.py to prepare pinned public inputs") + deployment = load_deployment(ROOT / "examples/deployment.yaml") + runtimes = [ + item.build(allow_scripts=False) for item in deployment.instances.values() + ] + assert len(runtimes) == 2 diff --git a/packages/modsim/tests/test_modsim.py b/packages/modsim/tests/test_modsim.py new file mode 100644 index 0000000..d9d9e76 --- /dev/null +++ b/packages/modsim/tests/test_modsim.py @@ -0,0 +1,525 @@ +import os +import socket +import signal +import subprocess +import sys +import time + +import modsim +import pytest +from pymodbus.client import ModbusTcpClient + + +@pytest.fixture +def local_tcp_client(): + reservation = socket.socket() + reservation.bind(("127.0.0.1", 0)) + port = reservation.getsockname()[1] + reservation.close() + + server = subprocess.Popen( + [sys.executable, "-m", "modsim", "--port", str(port), "--log", "error"], + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL, + ) + client = ModbusTcpClient("127.0.0.1", port=port, timeout=0.5) + try: + deadline = time.monotonic() + 10 + while time.monotonic() < deadline: + if server.poll() is not None: + pytest.fail(f"modsim server exited during startup: {server.returncode}") + if client.connect(): + break + time.sleep(0.05) + else: + pytest.fail("modsim server did not accept a local TCP connection") + + yield client + finally: + client.close() + server.terminate() + try: + server.wait(timeout=5) + except subprocess.TimeoutExpired: + server.kill() + server.wait(timeout=5) + + assert server.returncode == 0 + with socket.socket() as probe: + probe.bind(("127.0.0.1", port)) + + +def test_module_name(): + assert modsim.__name__ == "modsim" + + +@pytest.mark.integration +def test_local_tcp_server_reads_and_writes_default_holding_registers(local_tcp_client): + client = local_tcp_client + + result = client.read_holding_registers(40000, count=4, device_id=1) + assert not result.isError() + assert result.registers == [1, 2, 3, 4] + + result = client.write_registers(40000, [12, 13, 14, 15], device_id=1) + assert not result.isError() + result = client.read_holding_registers(40000, count=4, device_id=1) + assert not result.isError() + assert result.registers == [12, 13, 14, 15] + + +@pytest.mark.integration +def test_local_tcp_server_exercises_all_tables_and_boundaries(local_tcp_client): + client = local_tcp_client + + coils = client.read_coils(0, count=8, device_id=1) + assert not coils.isError() + assert coils.bits[:8] == [True, False, True, False, False, False, False, True] + + coil_write = client.write_coil(1, True, device_id=1) + assert not coil_write.isError() + coil_readback = client.read_coils(0, count=2, device_id=1) + assert not coil_readback.isError() + assert coil_readback.bits[:2] == [True, True] + + discrete = client.read_discrete_inputs(10000, count=8, device_id=1) + assert not discrete.isError() + assert discrete.bits[:8] == [ + True, + False, + True, + False, + False, + False, + False, + True, + ] + + readonly_coil_write = client.write_coil(10000, True, device_id=1) + assert readonly_coil_write.isError() + assert client.read_discrete_inputs(10000, count=1, device_id=1).bits[0] is True + + last_coil_before = client.read_coils(31, count=1, device_id=1) + assert not last_coil_before.isError() + assert client.write_coils(31, [True, True], device_id=1).isError() + last_coil_after = client.read_coils(31, count=1, device_id=1) + assert not last_coil_after.isError() + assert last_coil_after.bits[0] == last_coil_before.bits[0] + + input_registers = client.read_input_registers(30000, count=4, device_id=1) + assert not input_registers.isError() + assert input_registers.registers == [1, 2, 3, 4] + + readonly_write = client.write_register(30000, 99, device_id=1) + assert readonly_write.isError() + unchanged = client.read_input_registers(30000, count=1, device_id=1) + assert not unchanged.isError() + assert unchanged.registers == [1] + + out_of_range = client.read_holding_registers(40043, count=2, device_id=1) + assert out_of_range.isError() + last_before = client.read_holding_registers(40043, count=1, device_id=1) + assert not last_before.isError() + out_of_range_write = client.write_registers(40043, [11, 12], device_id=1) + assert out_of_range_write.isError() + last_after = client.read_holding_registers(40043, count=1, device_id=1) + assert not last_after.isError() + assert last_after.registers == last_before.registers + shared_unit = client.read_holding_registers(40000, count=1, device_id=42) + assert not shared_unit.isError() + assert shared_unit.registers == [1] + + +def test_import_does_not_parse_cli_arguments(): + result = subprocess.run( + [sys.executable, "-c", "import modsim.main", "--invalid-option"], + capture_output=True, + text=True, + ) + assert result.returncode == 0 + + +@pytest.mark.parametrize( + "arguments", + [ + ["--store", "sparse"], + ["--slaves", "1"], + ["--port", "bad"], + ["--port", "65536"], + ["--comm", "tcp", "--framer", "rtu"], + ], +) +def test_unsupported_cli_options_fail_cleanly(arguments): + result = subprocess.run( + [sys.executable, "-m", "modsim"] + arguments, + capture_output=True, + text=True, + ) + assert result.returncode == 2 + assert "error:" in result.stderr + assert "Traceback" not in result.stderr + + +@pytest.mark.integration +@pytest.mark.parametrize("sig", [signal.SIGINT, signal.SIGTERM]) +def test_signal_shutdown_releases_tcp_port(sig): + with socket.socket() as reservation: + reservation.bind(("127.0.0.1", 0)) + port = reservation.getsockname()[1] + process = subprocess.Popen( + [sys.executable, "-m", "modsim", "--port", str(port), "--log", "error"], + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL, + ) + try: + deadline = time.monotonic() + 10 + while time.monotonic() < deadline: + if process.poll() is not None: + pytest.fail("server exited during startup") + try: + with socket.create_connection(("127.0.0.1", port), timeout=0.2): + break + except OSError: + time.sleep(0.05) + else: + pytest.fail("server did not start") + process.send_signal(sig) + assert process.wait(timeout=5) == 0 + with socket.socket() as probe: + probe.bind(("127.0.0.1", port)) + finally: + if process.poll() is None: + process.kill() + process.wait(timeout=5) + + +@pytest.mark.integration +def test_occupied_tcp_port_fails_promptly(): + with socket.socket() as listener: + listener.bind(("0.0.0.0", 0)) + listener.listen() + port = listener.getsockname()[1] + result = subprocess.run( + [sys.executable, "-m", "modsim", "--port", str(port), "--log", "error"], + capture_output=True, + text=True, + timeout=5, + ) + assert result.returncode != 0 + assert "Could not start Modbus TCP listener" in result.stderr + + +def test_release_version_guard_accepts_matching_tag_and_rejects_mismatch(): + from pathlib import Path + + project = Path(__file__).resolve().parents[1] + guard = project / ".github/scripts/check-release-version.py" + for tag, expected in (("v" + modsim.__version__, 0), ("v9.9.9", 1)): + result = subprocess.run( + [sys.executable, str(guard), tag], + cwd=project, + capture_output=True, + text=True, + ) + assert result.returncode == expected + if expected: + assert "does not match" in result.stderr + + +@pytest.mark.integration +def test_local_udp_server_and_shutdown(): + from pymodbus.client import ModbusUdpClient + + with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as reservation: + reservation.bind(("127.0.0.1", 0)) + port = reservation.getsockname()[1] + process = subprocess.Popen( + [ + sys.executable, + "-m", + "modsim", + "--comm", + "udp", + "--port", + str(port), + "--log", + "error", + ], + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL, + ) + client = ModbusUdpClient("127.0.0.1", port=port, timeout=0.2, retries=0) + try: + deadline = time.monotonic() + 10 + result = None + while time.monotonic() < deadline: + if process.poll() is not None: + pytest.fail("UDP server exited during startup") + try: + result = client.read_holding_registers(40000, count=2, device_id=1) + if result and not result.isError(): + break + except Exception: + pass + time.sleep(0.05) + assert result and not result.isError() + assert result.registers == [1, 2] + process.terminate() + assert process.wait(timeout=5) == 0 + with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as probe: + probe.bind(("127.0.0.1", port)) + finally: + client.close() + if process.poll() is None: + process.kill() + process.wait(timeout=5) + + +@pytest.mark.integration +def test_occupied_udp_port_fails_promptly(): + with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as listener: + listener.bind(("127.0.0.1", 0)) + port = listener.getsockname()[1] + result = subprocess.run( + [ + sys.executable, + "-m", + "modsim", + "--comm", + "udp", + "--port", + str(port), + "--log", + "error", + ], + capture_output=True, + text=True, + timeout=5, + ) + assert result.returncode != 0 + assert "Could not start Modbus UDP listener" in result.stderr + + +@pytest.mark.integration +def test_local_tls_server_with_ephemeral_certificate(tmp_path): + import os + import shutil + import ssl + + openssl = shutil.which("openssl") + if not openssl: + pytest.skip("openssl is needed to generate a temporary certificate") + certdir = tmp_path / "certificates" + certdir.mkdir(parents=True) + cert = certdir / "pymodbus.crt" + key = certdir / "pymodbus.key" + subprocess.run( + [ + openssl, + "req", + "-x509", + "-newkey", + "rsa:2048", + "-nodes", + "-keyout", + str(key), + "-out", + str(cert), + "-days", + "1", + "-subj", + "/CN=localhost", + ], + check=True, + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL, + ) + with socket.socket() as reservation: + reservation.bind(("127.0.0.1", 0)) + port = reservation.getsockname()[1] + env = os.environ.copy() + env["PYTHONPATH"] = str(__import__("pathlib").Path(__file__).resolve().parents[1]) + process = subprocess.Popen( + [ + sys.executable, + "-m", + "modsim", + "--comm", + "tls", + "--port", + str(port), + "--log", + "error", + ], + cwd=tmp_path, + env=env, + stdout=subprocess.DEVNULL, + stderr=subprocess.PIPE, + text=True, + ) + context = ssl.create_default_context(cafile=str(cert)) + try: + deadline = time.monotonic() + 10 + while True: + if process.poll() is not None: + pytest.fail( + "TLS server exited during startup: " + process.stderr.read() + ) + try: + raw = socket.create_connection(("127.0.0.1", port), timeout=0.5) + break + except OSError: + if time.monotonic() >= deadline: + pytest.fail("TLS server did not start") + time.sleep(0.05) + with context.wrap_socket(raw, server_hostname="localhost") as client: + client.settimeout(2) + # Send Modbus TCP message with MBAP header + # MBAP: transaction_id (2) + protocol_id (2) + length (2) + unit_id (1) + # PDU: function_code (1) + starting_address (2) + quantity (2) + message = b"\x00\x01\x00\x00\x00\x06\x01\x03\x9c\x40\x00\x02" + client.sendall(message) + response = b"" + # Expect MBAP header (7 bytes) + PDU response (at least 1 byte) + while len(response) < 13: + part = client.recv(13 - len(response)) + assert part + response += part + # Verify MBAP header and response + assert response == b"\x00\x01\x00\x00\x00\x07\x01\x03\x04\x00\x01\x00\x02" + conflict = subprocess.run( + [ + sys.executable, + "-m", + "modsim", + "--comm", + "tls", + "--port", + str(port), + "--log", + "error", + ], + cwd=tmp_path, + env=env, + capture_output=True, + text=True, + timeout=5, + ) + assert conflict.returncode != 0 + assert "Could not start Modbus TLS listener" in conflict.stderr + process.terminate() + assert process.wait(timeout=5) == 0 + finally: + if process.poll() is None: + process.kill() + process.wait(timeout=5) + + +def test_privileged_port_reports_how_to_run(monkeypatch): + from modsim import main + + def refuse(self, address): + raise PermissionError(13, "Permission denied") + + monkeypatch.setattr(socket.socket, "bind", refuse) + with pytest.raises(OSError) as error: + main.require_bindable("127.0.0.1", 502) + message = str(error.value) + assert "Port 502 needs administrator rights" in message + assert 'sudo "$(command -v uvx)"' in message + assert "--port 5020" in message + + +@pytest.mark.parametrize("comm", ["tcp", "udp", "tls"]) +def test_default_port_is_5020(monkeypatch, comm): + from modsim.utils import get_commandline + + monkeypatch.setattr(sys, "argv", ["modsim", "--comm", comm]) + assert get_commandline().port == 5020 + + +def _unprivileged_low_ports(): + try: + with open("/proc/sys/net/ipv4/ip_unprivileged_port_start") as handle: + return int(handle.read()) <= 502 + except OSError: + return True + + +@pytest.mark.integration +@pytest.mark.skipif( + not sys.platform.startswith("linux") + or os.geteuid() == 0 + or _unprivileged_low_ports(), + reason="needs a non-root Linux user without access to port 502", +) +def test_privileged_port_without_rights_fails_with_hint(): + result = subprocess.run( + [sys.executable, "-m", "modsim", "--log", "error", "--port", "502"], + capture_output=True, + text=True, + timeout=5, + ) + assert result.returncode == 2 + assert "Port 502 needs administrator rights" in result.stderr + + +def test_tls_without_certificates_explains_what_is_missing(tmp_path): + with socket.socket() as reservation: + reservation.bind(("127.0.0.1", 0)) + port = reservation.getsockname()[1] + source = os.path.dirname(os.path.dirname(modsim.__file__)) + result = subprocess.run( + [sys.executable, "-m", "modsim", "--comm", "tls", "--port", str(port)], + cwd=tmp_path, + env={**os.environ, "PYTHONPATH": source}, + capture_output=True, + text=True, + timeout=30, + ) + assert result.returncode == 2 + assert "certificates/pymodbus.crt" in result.stderr + result.stdout + + +def test_serial_transport_passes_port_framer_and_datastore(monkeypatch): + import asyncio + + from modsim import main + from modsim.utils import get_commandline + + calls = {} + + class FakeSerialServer: + def __init__(self, **kwargs): + calls.update(kwargs) + self.serving = asyncio.get_event_loop().create_future() + self.serving.set_result(None) + + async def listen(self): + return True + + async def shutdown(self): + calls["shutdown"] = True + + monkeypatch.setattr(main, "ModbusSerialServer", FakeSerialServer) + monkeypatch.setattr( + sys, + "argv", + [ + "modsim", + "--serial", + "/dev/modsim-test", + "--serial-baud", + "19200", + "--serial-parity", + "even", + ], + ) + args = get_commandline() + main.setup_server(args) + assert asyncio.run(main.run_async_server(args)) is None + assert calls["port"] == "/dev/modsim-test" + assert calls["framer"] == args.framer + assert calls["context"] is args.context + assert (calls["baudrate"], calls["parity"]) == (19200, "E") + assert calls["shutdown"] diff --git a/packages/modsim/tests/test_preview_acceptance.py b/packages/modsim/tests/test_preview_acceptance.py new file mode 100644 index 0000000..52afaa5 --- /dev/null +++ b/packages/modsim/tests/test_preview_acceptance.py @@ -0,0 +1,37 @@ +"""Docker readiness must survive a socket proxy becoming ready first.""" + +import importlib.util +from pathlib import Path +from unittest.mock import Mock + + +spec = importlib.util.spec_from_file_location( + "acceptance", Path(__file__).resolve().parents[1] / "tools/preview-acceptance.py" +) +acceptance = importlib.util.module_from_spec(spec) +spec.loader.exec_module(acceptance) + + +def test_connection_reset_during_readiness_reconnects(monkeypatch): + client = Mock() + client.connect.return_value = True + ready = Mock(registers=[0] * 8) + ready.isError.return_value = False + input_value = Mock(registers=[432]) + input_value.isError.return_value = False + missing = Mock() + missing.isError.return_value = True + client.read_input_registers.side_effect = [ + ConnectionResetError(), + ready, + input_value, + missing, + ] + client.write_register.return_value.isError.return_value = False + client.write_coil.return_value.isError.return_value = False + client.read_discrete_inputs.return_value.bits = [True] + monkeypatch.setattr(acceptance, "ModbusTcpClient", lambda *args, **kwargs: client) + monkeypatch.setattr(acceptance.time, "sleep", lambda duration: None) + acceptance.main() + assert client.connect.call_count == 2 + assert client.close.call_count == 2 diff --git a/packages/modsim/tests/test_preview_guard.py b/packages/modsim/tests/test_preview_guard.py new file mode 100644 index 0000000..7851cde --- /dev/null +++ b/packages/modsim/tests/test_preview_guard.py @@ -0,0 +1,156 @@ +"""Preview release gates must enforce the current CI matrix.""" + +import importlib.util +import json +from pathlib import Path + +import pytest + +spec = importlib.util.spec_from_file_location( + "preview_guard", + Path(__file__).resolve().parents[1] / ".github/scripts/preview-release.py", +) +release = importlib.util.module_from_spec(spec) +spec.loader.exec_module(release) + + +def test_guard_requires_all_current_ci_jobs(monkeypatch): + monkeypatch.setenv("GITHUB_REPOSITORY", "example/modsim") + monkeypatch.setattr(release.subprocess, "run", lambda *a, **kw: None) + jobs = [ + {"name": name, "conclusion": "success"} + for name in ( + "modsim quality", + "modsim docs", + "modsim tox (3.10)", + "modsim tox (3.14)", + "modpoll snapshot replay", + ) + ] + + platform_jobs = [ + {"name": name, "conclusion": "success"} + for name in ( + "catalog-interop", + "single-device (ubuntu-latest)", + "single-device (macos-latest)", + "single-device (windows-latest)", + ) + ] + + def output(args, **kwargs): + if args[:3] == ["git", "rev-parse", "HEAD"]: + return "candidate\n" + if "runs?head_sha=" in " ".join(args): + return json.dumps( + { + "workflow_runs": [ + { + "head_branch": "v2", + "status": "completed", + "conclusion": "success", + "id": ( + 43 if "modsim-acceptance.yml" in " ".join(args) else 42 + ), + } + ] + } + ) + return json.dumps( + {"jobs": platform_jobs if "/runs/43/" in " ".join(args) else jobs} + ) + + monkeypatch.setattr(release.subprocess, "check_output", output) + release.guard("v" + __import__("modsim").__version__) + removed = jobs.pop() + with pytest.raises(ValueError, match="expected CI jobs"): + release.guard("v" + __import__("modsim").__version__) + jobs.append({**removed, "conclusion": "failure"}) + with pytest.raises(ValueError, match="expected CI jobs"): + release.guard("v" + __import__("modsim").__version__) + + jobs[-1]["conclusion"] = "success" + platform_jobs.pop() + with pytest.raises(ValueError, match="modsim-acceptance.yml"): + release.guard("v" + __import__("modsim").__version__) + + +def test_download_waits_for_pypi_and_checks_wheel_hash(monkeypatch, tmp_path, capsys): + import hashlib + import io + import urllib.error + + content = b"published wheel" + item = { + "filename": "package.whl", + "url": "https://files.pythonhosted.org/package.whl", + "digests": {"sha256": hashlib.sha256(content).hexdigest()}, + } + clock = [0] + metadata_calls = [] + urls = [] + monkeypatch.setattr(release.time, "monotonic", lambda: clock[0]) + monkeypatch.setattr( + release.time, "sleep", lambda seconds: clock.__setitem__(0, clock[0] + seconds) + ) + monkeypatch.setattr(release.time, "time_ns", lambda: clock[0]) + + def metadata(version): + metadata_calls.append(version) + if len(metadata_calls) <= 8: + return None + return {"urls": [] if len(metadata_calls) == 9 else [item]} + + def fetch(url, timeout): + urls.append(url) + if len(urls) == 1: + raise urllib.error.HTTPError(url, 404, "not ready", {}, None) + return io.BytesIO(content) + + monkeypatch.setattr(release, "metadata", metadata) + monkeypatch.setattr(release.urllib.request, "urlopen", fetch) + release.download("2.0.0a2", tmp_path) + assert (tmp_path / "package.whl").read_bytes() == content + assert len(metadata_calls) == 10 and len(urls) == 2 and urls[0] != urls[1] + assert clock[0] == 200 + assert "retrying" in capsys.readouterr().err + item["digests"]["sha256"] = "wrong" + with pytest.raises(ValueError, match="SHA256 mismatch"): + release.download("2.0.0a2", tmp_path) + + +def test_pypi_retry_times_out_and_does_not_hide_other_errors(monkeypatch): + import urllib.error + + clock = [0] + monkeypatch.setattr(release.time, "monotonic", lambda: clock[0]) + monkeypatch.setattr( + release.time, "sleep", lambda seconds: clock.__setitem__(0, clock[0] + seconds) + ) + with pytest.raises(TimeoutError, match="metadata still unavailable"): + release._wait_for_pypi(lambda: None, "metadata", 45) + assert clock[0] == 45 + + def forbidden(): + raise urllib.error.HTTPError("https://example.org", 403, "forbidden", {}, None) + + with pytest.raises(urllib.error.HTTPError, match="403"): + release._wait_for_pypi(forbidden, "metadata", 600) + assert clock[0] == 45 + + +def test_workflow_names_match_the_release_guard(): + import yaml + + # The workflows live at the repository root (packages/modsim/tests -> repository). + workflow = yaml.safe_load( + ( + Path(__file__).resolve().parents[3] / ".github/workflows/modsim.yml" + ).read_text() + ) + job = workflow["jobs"]["tox"] + assert job["name"] == "modsim tox (${{ matrix.python-version }})" + assert {row["python-version"] for row in job["strategy"]["matrix"]["include"]} == { + "3.10", + "3.14", + } diff --git a/packages/modsim/tests/test_release_image_tags.py b/packages/modsim/tests/test_release_image_tags.py new file mode 100644 index 0000000..27c7287 --- /dev/null +++ b/packages/modsim/tests/test_release_image_tags.py @@ -0,0 +1,122 @@ +import importlib.util +from pathlib import Path + +import pytest + +spec = importlib.util.spec_from_file_location( + "release_image_tags", + Path(__file__).resolve().parents[1] / ".github/scripts/release_image_tags.py", +) +tags = importlib.util.module_from_spec(spec) +spec.loader.exec_module(tags) + + +def releases(*versions): + return [ + {"tag_name": "v" + version, "draft": False, "prerelease": False} + for version in versions + ] + + +def test_latest_release_updates_all_matching_aliases(): + assert tags.select_tags("v2.1.0", releases("1.8.9", "2.0.0", "2.1.0")) == ( + ["2.1.0", "2", "2.1", "latest"], + True, + ) + + +def test_maintenance_release_does_not_replace_newer_major(): + assert tags.select_tags("v1.8.1", releases("1.7.9", "1.8.1", "2.0.0")) == ( + ["1.8.1", "1", "1.8"], + False, + ) + + +def test_old_patch_does_not_replace_major_or_minor_aliases(): + assert tags.select_tags("v1.8.0", releases("1.8.0", "1.8.1", "2.0.0")) == ( + ["1.8.0"], + False, + ) + + +def test_draft_prerelease_and_unknown_tag_cannot_publish_aliases(): + data = releases("1.0.0") + [ + {"tag_name": "v3.0.0", "draft": True}, + {"tag_name": "v4.0.0", "prerelease": True}, + ] + assert tags.select_tags("v1.0.0", data)[0][-1] == "latest" + for tag in ("v1.1.0", "v1.0.0-rc1", "bad"): + with pytest.raises(ValueError): + tags.select_tags(tag, data) + + +def test_older_minor_only_updates_its_own_minor_alias(): + assert tags.select_tags("v1.8.2", releases("1.8.2", "1.9.0", "2.0.0")) == ( + ["1.8.2", "1.8"], + False, + ) + + +def test_package_version_guard_accepts_matching_tag_and_rejects_mismatch(): + import subprocess + import sys + import re + + root = Path(__file__).resolve().parents[1] + guard = root / ".github/scripts/check_release_version.py" + source = (root / "pyproject.toml").read_text() + current = re.search(r'^version = "([^" ]+)"', source, re.MULTILINE).group(1) + for tag, expected in (("v" + current, 0), ("v9.9.9", 1)): + result = subprocess.run( + [sys.executable, str(guard), tag], cwd=root, capture_output=True, text=True + ) + assert result.returncode == expected + if expected: + assert "does not match" in result.stderr + + +def test_release_listing_fetches_all_pages(monkeypatch): + import io + import json + + monkeypatch.setenv("GITHUB_API_URL", "https://api.example.test") + monkeypatch.setenv("GITHUB_REPOSITORY", "owner/repo") + monkeypatch.setenv("GH_TOKEN", "test-token") + calls = [] + first_page = releases(*["1.0.%d" % i for i in range(100)]) + second_page = releases("2.0.0") + + def fake_open(request, timeout): + calls.append((request.full_url, timeout)) + return io.BytesIO( + json.dumps(first_page if len(calls) == 1 else second_page).encode() + ) + + monkeypatch.setattr(tags.urllib.request, "urlopen", fake_open) + result = tags.fetch_releases() + assert len(result) == 101 + assert calls[0][0].endswith("page=1") + assert calls[1][0].endswith("page=2") + assert tags.select_tags("v1.0.99", result) == (["1.0.99", "1", "1.0"], False) + + +def test_release_selection_emits_image_names_and_latest_flag( + monkeypatch, tmp_path, capsys +): + monkeypatch.setattr(tags, "fetch_releases", lambda: releases("1.2.0", "2.0.0")) + output = tmp_path / "github-output" + for key, value in { + "TAG": "v1.2.0", + "DOCKER_REGISTRY": "registry.example", + "DOCKER_USERNAME": "team", + "IMAGE_NAME": "modpoll", + "GITHUB_OUTPUT": str(output), + }.items(): + monkeypatch.setenv(key, value) + tags.main() + assert capsys.readouterr().out.splitlines() == [ + "registry.example/team/modpoll:1.2.0", + "registry.example/team/modpoll:1", + "registry.example/team/modpoll:1.2", + ] + assert output.read_text() == "latest=false\n" diff --git a/packages/modsim/tests/test_remote_sources.py b/packages/modsim/tests/test_remote_sources.py new file mode 100644 index 0000000..1014dcd --- /dev/null +++ b/packages/modsim/tests/test_remote_sources.py @@ -0,0 +1,44 @@ +"""HTTPS model and simulation data sources.""" + +from io import BytesIO +import json +from unittest.mock import patch + +import pytest + +from modpoll_wot import load_simulation_data + +from modsim import __version__, deployment, sources + + +class Response(BytesIO): + def __init__(self, payload, url="https://example.invalid/file.json"): + super().__init__(payload) + self.url = url + + def geturl(self): + return self.url + + +def test_remote_documents_identify_modsim(): + payload = json.dumps({"version": "1", "tick": 0.5}).encode() + with patch.object(sources, "urlopen", return_value=Response(payload)) as remote: + data = deployment.data_document("https://example.invalid/device.data.json") + assert data == {"version": "1", "tick": 0.5} + request = remote.call_args.args[0] + assert request.full_url == "https://example.invalid/device.data.json" + assert request.get_header("User-agent") == f"modsim/{__version__}" + + +def test_simulation_data_rejects_scripts_and_plain_http(): + payload = json.dumps({"version": "1", "script": "behavior.py"}).encode() + with patch.object(sources, "urlopen", return_value=Response(payload)): + document = deployment.data_document("https://example.invalid/s.json") + with pytest.raises(ValueError, match="script"): + load_simulation_data(document) + with pytest.raises(ValueError, match="must use HTTPS"): + deployment.data_document("http://example.invalid/s.json") + redirected = Response(b"{}", url="http://example.invalid/s.json") + with patch.object(sources, "urlopen", return_value=redirected): + with pytest.raises(ValueError, match="redirect must use HTTPS"): + sources.model_document("https://example.invalid/m.json") diff --git a/packages/modsim/tests/test_snapshot_replay.py b/packages/modsim/tests/test_snapshot_replay.py new file mode 100644 index 0000000..c0938c0 --- /dev/null +++ b/packages/modsim/tests/test_snapshot_replay.py @@ -0,0 +1,152 @@ +"""modpoll reads a simulated device, exports a snapshot, and modsim replays it. + +Runs when MODSIM_TEST_MODPOLL_PYTHON names a Python environment with modpoll +installed; modsim and modpoll stay independent installations. +""" + +import json +import os +from pathlib import Path +import socket +import subprocess +import sys +import time + +import pytest + +MODPOLL = os.environ.get("MODSIM_TEST_MODPOLL_PYTHON") +pytestmark = [ + pytest.mark.integration, + pytest.mark.skipif(not MODPOLL, reason="MODSIM_TEST_MODPOLL_PYTHON is not set"), +] +ROOT = Path(__file__).resolve().parents[1] + + +def register(raw, address, quantity=1, multiplier=None, kind="number"): + form = { + "op": "readproperty", + "modv:entity": "HoldingRegister", + "modv:address": address, + "modv:quantity": quantity, + "modv:type": "xsd:" + raw, + } + if multiplier is not None: + form["modpoll:multiplier"] = multiplier + return {"type": kind, "readOnly": True, "forms": [form]} + + +MODEL = { + "@context": [ + "https://www.w3.org/2022/wot/td/v1.1", + { + "modpoll": "https://top-maker.github.io/modpoll/vocab/wot-modbus#", + "modv": "https://www.w3.org/2019/wot/modbus", + "xsd": "http://www.w3.org/2001/XMLSchema#", + }, + ], + "@type": "tm:ThingModel", + "title": "replay-meter", + "modpoll:version": "0.2", + "properties": { + "VOLTAGE": register("unsignedShort", 0, multiplier="0.1"), + "CURRENT": register("short", 1, multiplier="0.001"), + "ENERGY": register("unsignedInt", 2, 2, multiplier="0.01"), + "FREQUENCY": register("float", 4, 2), + "STATUS": register("unsignedShort", 6, kind="integer"), + }, + "modpoll:acquisition": [ + { + "modv:entity": "HoldingRegister", + "modv:address": 0, + "modv:quantity": 7, + "modpoll:members": ["VOLTAGE", "CURRENT", "ENERGY", "FREQUENCY", "STATUS"], + } + ], +} +# 230.1 and 4.987 read back as 230.10000000000002 and 4.987 with float scaling; +# the replay must serve whatever modpoll exported. +INITIAL = { + "VOLTAGE": 230.1, + "CURRENT": -4.987, + "ENERGY": 123456.78, + "FREQUENCY": 50.0, + "STATUS": 4660, +} + + +def serve_and_read(tmp_path, model, data, name): + with socket.socket() as reservation: + reservation.bind(("127.0.0.1", 0)) + port = reservation.getsockname()[1] + env = {**os.environ, "PYTHONPATH": str(ROOT)} + with (tmp_path / f"{name}.log").open("w+") as log: + server = subprocess.Popen( + [ + sys.executable, + "-m", + "modsim", + "--config", + str(model), + "--data", + str(data), + "--bind", + "127.0.0.1", + "--port", + str(port), + ], + cwd=tmp_path, + env=env, + stdout=log, + stderr=log, + ) + try: + deadline = time.monotonic() + 30 + while True: + if server.poll() is not None: + log.seek(0) + raise AssertionError(log.read()) + try: + socket.create_connection(("127.0.0.1", port), timeout=0.2).close() + break + except OSError: + assert time.monotonic() < deadline, "modsim did not start" + time.sleep(0.1) + snapshot = tmp_path / f"{name}.snapshot.json" + subprocess.run( + [ + MODPOLL, + "-m", + "modpoll", + "--config", + str(model), + "--tcp", + "127.0.0.1", + "--tcp-port", + str(port), + "--once", + "--export", + str(snapshot), + ], + check=True, + capture_output=True, + timeout=60, + ) + return snapshot + finally: + server.terminate() + server.wait(timeout=10) + + +def test_exported_snapshot_replays_unchanged(tmp_path): + model = tmp_path / "replay.tm.json" + model.write_text(json.dumps(MODEL)) + data = tmp_path / "initial.data.json" + data.write_text(json.dumps({"version": "1", "initial": INITIAL})) + + first = serve_and_read(tmp_path, model, data, "first") + exported = json.loads(first.read_text())["replay-meter"] + assert exported["VOLTAGE"] == float(2301) * 0.1 != 230.1 + assert exported["STATUS"] == 4660 + + replayed = serve_and_read(tmp_path, model, first, "replay") + assert json.loads(replayed.read_text()) == json.loads(first.read_text()) diff --git a/packages/modsim/tests/test_virtual_serial.py b/packages/modsim/tests/test_virtual_serial.py new file mode 100644 index 0000000..721ed50 --- /dev/null +++ b/packages/modsim/tests/test_virtual_serial.py @@ -0,0 +1,112 @@ +"""RTU simulation over a virtual serial port (SIM-04).""" + +import json +import os +from pathlib import Path +import re +import subprocess +import sys +import time + +import pytest + +from modsim.main import read_command +from modsim.utils import get_parser + +MODEL = Path(__file__).parent / "fixtures/io-module/adam-6024.tm.json" +VALUES = [0x1234, 0x8001, 0xABCD, 0, 65535, 42] +posix_only = pytest.mark.skipif(os.name == "nt", reason="needs pseudo-terminals") + + +def _start(tmp_path, *extra): + data = tmp_path / "initial.data.json" + data.write_text( + json.dumps( + {"version": "1", "initial": {f"AI{i}_RAW": v for i, v in enumerate(VALUES)}} + ) + ) + log = (tmp_path / "server.log").open("w+") + process = subprocess.Popen( + [ + sys.executable, + "-m", + "modsim", + "--config", + str(MODEL), + "--unit-id", + "1", + "--data", + str(data), + "--serial", + "pty", + *extra, + ], + cwd=tmp_path, + stdout=log, + stderr=log, + ) + deadline = time.monotonic() + 30 + while time.monotonic() < deadline: + log.seek(0) + text = log.read() + found = re.search(r"Virtual serial port for the client: (\S+)", text) + if found: + return process, found.group(1) + if process.poll() is not None: + pytest.fail(text) + time.sleep(0.1) + process.kill() + pytest.fail("virtual serial startup timed out") + + +@posix_only +def test_model_is_read_over_the_virtual_port_and_cleaned_up(tmp_path): + from pymodbus.client import ModbusSerialClient + + link = tmp_path / "ttyV0" + process, port = _start(tmp_path, "--serial-link", str(link)) + try: + assert link.is_symlink() and os.readlink(link) == port + # The same server survives a client opening and closing the port twice. + for _ in range(2): + client = ModbusSerialClient(port, baudrate=9600, timeout=2) + assert client.connect() + try: + reply = client.read_input_registers(0, count=6, device_id=1) + assert not reply.isError() + assert reply.registers == VALUES + finally: + client.close() + finally: + process.terminate() + process.wait(timeout=10) + assert not link.is_symlink() + + +def test_read_command_names_the_virtual_port(): + args = get_parser().parse_args( + ["--config", "m.tm.json", "--serial", "pty", "--unit-id", "7"] + ) + args.serial_baud, args.serial_parity = 9600, "even" + assert read_command(args, "/dev/pts/9") == ( + "modpoll --config m.tm.json --serial /dev/pts/9 --serial-baud 9600" + " --serial-parity even --unit-id 7" + ) + + +@pytest.mark.parametrize( + "arguments", + [ + ["--serial", "pty", "--port", "5020"], + ["--serial", "pty", "--comm", "tcp"], + ["--serial-baud", "9600"], + ["--serial", "/dev/ttyUSB0", "--serial-link", "x"], + ], +) +def test_conflicting_serial_options_are_refused(monkeypatch, arguments): + from modsim.utils import get_commandline + + monkeypatch.setattr(sys, "argv", ["modsim", *arguments]) + with pytest.raises(SystemExit) as error: + get_commandline() + assert error.value.code == 2 diff --git a/packages/modsim/tests/test_wot.py b/packages/modsim/tests/test_wot.py new file mode 100644 index 0000000..cce54b0 --- /dev/null +++ b/packages/modsim/tests/test_wot.py @@ -0,0 +1,198 @@ +"""First raw-I/O model slice: native addressing, initialization and isolation.""" + +import json +import os +from pathlib import Path +import socket +import subprocess +import sys +import time + +import pytest +from pymodbus.client import ModbusTcpClient + +pytest.importorskip( + "modpoll_wot.profile", + reason="install candidate tool wheel for configured-device tests", +) +ROOT = Path(__file__).resolve().parents[1] + + +def model(entity="InputRegister", start=1, names=None): + names = names or [f"AI{i}_RAW" for i in range(8)] + bits = entity in ("Coil", "DiscreteInput") + ro = entity in ("InputRegister", "DiscreteInput") + properties = {} + for offset, name in enumerate(names): + prop = { + "type": "boolean" if bits else "integer", + "forms": [ + { + "modv:entity": entity, + "modv:address": start + offset, + "modv:quantity": 1, + "modv:type": "xsd:boolean" if bits else "xsd:unsignedShort", + } + ], + } + if ro: + prop["readOnly"] = True + if not bits: + prop.update({"minimum": 0, "maximum": 65535}) + properties[name] = prop + return { + "@context": [ + "https://www.w3.org/2022/wot/td/v1.1", + { + "modpoll": "https://top-maker.github.io/modpoll/vocab/wot-modbus#", + "modv": "https://www.w3.org/2019/wot/modbus", + "xsd": "http://www.w3.org/2001/XMLSchema#", + }, + ], + "@type": "tm:ThingModel", + "title": "raw-fixture", + "modpoll:version": "0.2", + "properties": properties, + "modpoll:acquisition": [ + { + "modv:entity": entity, + "modv:address": start, + "modv:quantity": len(names), + "modpoll:members": names, + } + ], + } + + +@pytest.fixture +def server(tmp_path): + running = [] + + def start(document, *arguments): + source = tmp_path / f"model-{len(running)}.json" + source.write_text(json.dumps(document)) + with socket.socket() as reservation: + reservation.bind(("127.0.0.1", 0)) + port = reservation.getsockname()[1] + env = dict( + os.environ, + PYTHONPATH=str(ROOT) + os.pathsep + os.environ.get("PYTHONPATH", ""), + ) + process = subprocess.Popen( + [ + sys.executable, + "-m", + "modsim", + "--config", + str(source), + "--bind", + "127.0.0.1", + "--port", + str(port), + "--unit-id", + "1", + "--log", + "error", + *arguments, + ], + cwd=ROOT, + env=env, + stdout=subprocess.DEVNULL, + stderr=subprocess.PIPE, + ) + client = ModbusTcpClient("127.0.0.1", port=port, timeout=0.5, retries=0) + running.append((process, client, port)) + deadline = time.monotonic() + 8 + while time.monotonic() < deadline: + if process.poll() is not None: + pytest.fail(process.stderr.read().decode()) + if client.connect(): + break + time.sleep(0.05) + else: + pytest.fail("configured device did not start") + return client + + yield start + for process, client, port in running: + client.close() + process.terminate() + process.wait(timeout=5) + process.stderr.close() + assert process.returncode == 0 + with socket.socket() as check: + # Match server reuse semantics: TIME_WAIT is not a live listener. + check.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) + check.bind(("127.0.0.1", port)) + + +@pytest.mark.integration +def test_input_model_reads_bounds_rejects_writes_and_does_not_share_units(server): + client = server(model(), "--initial", "AI0_RAW=1234", "--initial", "AI7_RAW=65535") + expected = [1234, 0, 0, 0, 0, 0, 0, 65535] + assert client.read_input_registers(1, count=8, device_id=1).registers == expected + assert client.read_input_registers(8, count=1, device_id=1).registers == [65535] + assert client.read_input_registers(0, count=1, device_id=1).isError() + assert client.read_input_registers(8, count=2, device_id=1).isError() + assert client.read_coils(0, count=1, device_id=1).isError() + assert client.write_coil(0, True, device_id=1).isError() + assert client.write_register(1, 42, device_id=1).isError() + assert client.write_registers(1, [42, 43], device_id=1).isError() + assert client.read_input_registers(1, count=8, device_id=2).isError() + assert client.read_input_registers(1, count=8, device_id=1).registers == expected + + +@pytest.mark.integration +def test_native_writable_registers_are_atomic_and_bits_do_not_leak_padding(server): + client = server(model("HoldingRegister", 10, ["AO0", "AO1"])) + assert not client.write_registers(10, [123, 456], device_id=1).isError() + assert client.read_holding_registers(10, count=2, device_id=1).registers == [ + 123, + 456, + ] + assert client.write_registers(11, [111, 222], device_id=1).isError() + assert client.read_holding_registers(10, count=2, device_id=1).registers == [ + 123, + 456, + ] + bits = server(model("Coil", 16, ["DO0", "DO1"])) + assert not bits.write_coils(16, [True, False], device_id=1).isError() + assert bits.read_coils(16, count=2, device_id=1).bits[:2] == [True, False] + assert bits.read_coils(15, count=1, device_id=1).isError() + assert bits.read_coils(18, count=1, device_id=1).isError() + assert bits.read_coils(17, count=2, device_id=1).isError() + assert bits.write_coils(17, [True, True], device_id=1).isError() + assert bits.read_coils(16, count=2, device_id=1).bits[:2] == [True, False] + + +@pytest.mark.parametrize( + "initial", ["AI0_RAW=-1", "AI0_RAW=65536", "AI0_RAW=true", "UNKNOWN=1"] +) +def test_invalid_initials_fail_before_binding(tmp_path, initial): + from modsim.wot import configure + from modsim.utils import get_parser + + path = tmp_path / "device.json" + path.write_text(json.dumps(model())) + args = get_parser().parse_args(["--config", str(path), "--initial", initial]) + with pytest.raises(ValueError): + configure(args) + + +def test_defaults_and_constraints_are_respected(tmp_path): + from modsim.wot import configure + from modsim.utils import get_parser + + d = model() + d["properties"]["AI0_RAW"].update({"minimum": 100, "maximum": 200, "multipleOf": 7}) + d["properties"]["AI1_RAW"]["default"] = 99 + path = tmp_path / "constrained.json" + path.write_text(json.dumps(d)) + args = get_parser().parse_args(["--config", str(path)]) + configure(args) + assert args.model_initialization["values"]["AI0_RAW"] == 105 + assert args.model_initialization["values"]["AI1_RAW"] == 99 + assert ( + args.model_initialization["origins"]["AI0_RAW"] + == "synthetic type/constraint fallback" + ) diff --git a/packages/modsim/tools/catalog-interop.py b/packages/modsim/tools/catalog-interop.py new file mode 100644 index 0000000..4172297 --- /dev/null +++ b/packages/modsim/tools/catalog-interop.py @@ -0,0 +1,251 @@ +"""Exercise immutable catalog inputs with independent released clients on loopback.""" + +import argparse +import copy +import hashlib +from importlib.metadata import version +from datetime import datetime, timezone +import json +import os +from pathlib import Path +import socket +import struct +import subprocess +import sys +from tempfile import TemporaryDirectory +import time +from urllib.request import urlopen + +from modpoll_wot import export_td +import yaml + +ROOT = Path(__file__).resolve().parents[1] +TM_PATH = "products/advantech/adam-5017uh/model.tm.json" +VALUES = [0x1234, 0x8001, 0xABCD, 0, 65535, 42, 0x0102, 0xFE01] +EXPECTED = {f"AI{i}_RAW": value for i, value in enumerate(VALUES)} + + +def receive(stream, count): + data = b"" + while len(data) < count: + part = stream.recv(count - len(data)) + if not part: + raise ValueError("Incomplete Modbus response") + data += part + return data + + +def node_values(reader, td): + result = subprocess.run( + ["node", str(reader), str(td)], + capture_output=True, + text=True, + timeout=30, + check=True, + ) + line = next( + line for line in result.stdout.splitlines() if line.startswith("RESULT=") + ) + return json.loads(line[7:]) + + +def run(args): + lock = yaml.safe_load(args.lock.read_text()) + revision = lock["revision"] + if len(revision) != 40 or any(c not in "0123456789abcdef" for c in revision): + raise ValueError("Full immutable data commit required") + url = f"https://raw.githubusercontent.com/{lock['repository']}/{revision}/{TM_PATH}" + with urlopen(url, timeout=20) as response: + payload = response.read(2 * 1024 * 1024 + 1) + digest = hashlib.sha256(payload).hexdigest() + if digest != lock["files"][TM_PATH]: + raise ValueError("Catalog TM hash mismatch") + reader = args.node_reader.resolve() + node_versions = { + name: json.loads( + ( + reader.parent / "node_modules/@node-wot" / name / "package.json" + ).read_text() + )["version"] + for name in ("core", "binding-modbus") + } + if set(node_versions.values()) != {"0.9.2"}: + raise ValueError("Expected pinned node-wot 0.9.2") + with socket.socket() as reserve: + reserve.bind(("127.0.0.1", 0)) + port = reserve.getsockname()[1] + with TemporaryDirectory(prefix="modsim-catalog-interop-") as temporary: + work = Path(temporary) + data = work / "initial.data.json" + data.write_text(json.dumps({"version": "1", "initial": EXPECTED})) + env = dict(os.environ) + env.pop("PYTHONPATH", None) + with (work / "simulator.log").open("w+") as log: + process = subprocess.Popen( + [ + sys.executable, + "-m", + "modsim", + "--config", + url, + "--bind", + "127.0.0.1", + "--port", + str(port), + "--unit-id", + "1", + "--data", + str(data), + ], + cwd=work, + env=env, + stdout=log, + stderr=log, + ) + try: + deadline = time.monotonic() + 30 + while True: + if process.poll() is not None: + log.seek(0) + raise ValueError(log.read()) + try: + stream = socket.create_connection( + ("127.0.0.1", port), timeout=1 + ) + break + except OSError: + if time.monotonic() >= deadline: + raise TimeoutError("Simulator did not become ready") + time.sleep(0.1) + with stream: + stream.sendall(struct.pack(">HHHBBHH", 7, 0, 6, 1, 4, 1, 8)) + raw_header = receive(stream, 7) + raw_body = receive(stream, 18) + assert raw_header == struct.pack(">HHHB", 7, 0, 19, 1) + assert raw_body == bytes([4, 16]) + struct.pack(">8H", *VALUES) + output = work / "modpoll.json" + subprocess.run( + [ + str(args.modpoll_python), + "-m", + "modpoll", + "--once", + "--tcp", + "127.0.0.1", + "--tcp-port", + str(port), + "--unit-id", + "1", + "--config", + url, + "--timeout", + "10", + "--interval", + "0", + "--export", + str(output), + ], + cwd=work, + env=env, + check=True, + capture_output=True, + text=True, + timeout=40, + ) + polled = json.loads(output.read_text()) + assert len(polled) == 1 and next(iter(polled.values())) == EXPECTED + td = export_td( + json.loads(payload), + host="127.0.0.1", + port=port, + unit_id=1, + target="node-wot-0.9.2", + ) + good = work / "correct.td.json" + good.write_text(json.dumps(td)) + td_digest = hashlib.sha256(good.read_bytes()).hexdigest() + node_actual = node_values(reader, good) + assert node_actual == EXPECTED + wrong = copy.deepcopy(td) + for prop in wrong["properties"].values(): + for form in prop["forms"]: + form["contentType"] = form["contentType"].replace( + "BIG_ENDIAN", "LITTLE_ENDIAN" + ) + bad = work / "wrong-byte-order.td.json" + bad.write_text(json.dumps(wrong)) + incorrect = node_values(reader, bad) + assert incorrect != EXPECTED and incorrect["AI0_RAW"] == 0x3412 + finally: + process.terminate() + try: + process.wait(timeout=10) + except subprocess.TimeoutExpired: + process.kill() + process.wait() + versions = json.loads( + subprocess.check_output( + [ + str(args.modpoll_python), + "-c", + "import json,importlib.metadata as m; print(json.dumps({p:m.version(p) for p in ['modpoll','modpoll-wot']}))", + ], + cwd=work, + env=env, + ) + ) + report = { + "executed-at": datetime.now(timezone.utc).isoformat().replace("+00:00", "Z"), + "data-revision": revision, + "td-sha256": td_digest, + "td-endpoint": { + "host": "127.0.0.1", + "port": port, + "unit-id": 1, + "target": "node-wot-0.9.2", + }, + "actual": { + "modpoll": next(iter(polled.values())), + "node-wot": node_actual, + "wrong-byte-order": incorrect, + "request-hex": struct.pack(">HHHBBHH", 7, 0, 6, 1, 4, 1, 8).hex(), + "response-hex": (raw_header + raw_body).hex(), + }, + "tm-sha256": digest, + "profile": "0.2", + "modsim": version("modsim"), + "simulator-interpreter": version("modpoll-wot"), + "clients": versions, + "node-wot": node_versions, + "reader-sha256": hashlib.sha256(reader.read_bytes()).hexdigest(), + "checks": { + "raw-fc4-start-1-count-8": "passed", + "modpoll": "passed", + "node-wot": "passed", + "wrong-byte-order-detected": "passed", + "shutdown": "passed", + }, + "expected": EXPECTED, + "scope": "Synthetic uint16 input subset only; no hardware, calibration, writes or general binding certification", + } + args.output.parent.mkdir(parents=True, exist_ok=True) + args.output.write_text(json.dumps(report, indent=2) + "\n") + print( + "Catalog interoperability passed: raw wire, published modpoll, node-wot, wrong-byte-order rejection, shutdown" + ) + + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument( + "--lock", type=Path, default=ROOT / "examples/model-source.yaml" + ) + parser.add_argument("--modpoll-python", type=Path, required=True) + parser.add_argument("--node-reader", type=Path, required=True) + parser.add_argument( + "--output", + type=Path, + required=True, + help="Temporary/CI report, outside maintained docs", + ) + run(parser.parse_args()) diff --git a/packages/modsim/tools/fetch-models.py b/packages/modsim/tools/fetch-models.py new file mode 100644 index 0000000..f3a1f89 --- /dev/null +++ b/packages/modsim/tools/fetch-models.py @@ -0,0 +1,62 @@ +"""Prepare bounded, hash-verified public example inputs; never execute them.""" + +import argparse +import hashlib +from pathlib import Path, PurePosixPath +import re +from urllib.parse import urlparse +from urllib.request import urlopen + +import yaml + +ROOT = Path(__file__).resolve().parents[1] +MAX_BYTES = 2 * 1024 * 1024 + + +def fetch(lock_path, destination): + lock = yaml.safe_load(Path(lock_path).read_text()) + if not re.fullmatch(r"[0-9a-f]{40}", lock["revision"]): + raise ValueError("Catalog revision must be a full commit SHA") + if not re.fullmatch(r"[\w-]+/[\w.-]+", lock["repository"]): + raise ValueError("Invalid public repository") + destination = Path(destination).resolve() + pending = [] + for name, digest in lock["files"].items(): + path = PurePosixPath(name) + if path.is_absolute() or ".." in path.parts or "\\" in name: + raise ValueError("Catalog path must remain relative") + if not re.fullmatch(r"[0-9a-f]{64}", digest): + raise ValueError("Invalid content hash") + target = destination / name + if not target.resolve().is_relative_to(destination): + raise ValueError("Catalog destination leaves output directory") + url = f"https://raw.githubusercontent.com/{lock['repository']}/{lock['revision']}/{name}" + with urlopen(url, timeout=20) as response: + if urlparse(response.geturl()).scheme != "https": + raise ValueError("Catalog redirects must use HTTPS") + payload = response.read(MAX_BYTES + 1) + if len(payload) > MAX_BYTES or hashlib.sha256(payload).hexdigest() != digest: + raise ValueError(f"Catalog content/hash mismatch: {name}") + pending.append((target, payload)) + if not pending: + raise ValueError("No locked input files") + # Verify every input before replacing any existing example file. + for target, payload in pending: + target.parent.mkdir(parents=True, exist_ok=True) + target.write_bytes(payload) + return [str(target) for target, _ in pending] + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument( + "--lock", type=Path, default=ROOT / "examples/model-source.yaml" + ) + parser.add_argument("--output", type=Path, default=ROOT / "examples/models") + args = parser.parse_args() + paths = fetch(args.lock, args.output) + print(f"Prepared {len(paths)} verified files; no scripts executed") + + +if __name__ == "__main__": + main() diff --git a/packages/modsim/tools/generate-td.py b/packages/modsim/tools/generate-td.py new file mode 100644 index 0000000..8311fba --- /dev/null +++ b/packages/modsim/tools/generate-td.py @@ -0,0 +1,71 @@ +"""Generate loopback TD examples from canonical TM sources; never edit TDs by hand.""" + +import argparse +import hashlib +from importlib.metadata import version +import json +from pathlib import Path +import sys + +ROOT = Path(__file__).resolve().parent +PRODUCTS = { + "adam-6024": "adam-6024", +} + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument( + "--check", action="store_true", help="Fail if generated examples are stale" + ) + args = parser.parse_args() + try: + from modpoll_wot import export_td + from modpoll_wot.loading import load_document + except ImportError: + parser.error("requires modpoll-wot==0.2.0a2; see README.md") + changed = [] + for product, stem in PRODUCTS.items(): + directory = ROOT.parent / "tests" / "fixtures" / "io-module" + source = directory / f"{stem}.tm.json" + model = load_document(source) + artifacts = {} + outputs = {} + document = export_td( + model, host="127.0.0.1", port=5020, unit_id=1, target="project" + ) + payload = (json.dumps(document, indent=2, ensure_ascii=False) + "\n").encode() + name = f"{stem}.generated.td.json" + outputs[directory / name] = payload + artifacts[name] = { + "target": "project", + "sha256": hashlib.sha256(payload).hexdigest(), + } + manifest = { + "source": source.name, + "source_sha256": hashlib.sha256(source.read_bytes()).hexdigest(), + "generator": {"package": "modpoll-wot", "version": version("modpoll-wot")}, + "instance": {"host": "127.0.0.1", "port": 5020, "unit_id": 1}, + "artifacts": artifacts, + } + outputs[directory / "generated.json"] = ( + json.dumps(manifest, indent=2) + "\n" + ).encode() + for path, payload in outputs.items(): + if not path.exists() or path.read_bytes() != payload: + changed.append(str(path.relative_to(ROOT.parent))) + if not args.check: + path.write_bytes(payload) + if args.check and changed: + print("Stale generated files: " + ", ".join(changed), file=sys.stderr) + return 1 + print( + "Generated examples are current." + if args.check + else "Generated: " + ", ".join(changed) + ) + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/packages/modsim/tools/prepare-acceptance.py b/packages/modsim/tools/prepare-acceptance.py new file mode 100644 index 0000000..4a0728a --- /dev/null +++ b/packages/modsim/tools/prepare-acceptance.py @@ -0,0 +1,40 @@ +"""Prepare immutable release fixtures outside Git without changing model bytes.""" + +from pathlib import Path +import subprocess +import sys + +import yaml + +TOOLS = Path(__file__).resolve().parent + + +def prepare(root): + root = Path(root).resolve() + lock = root / "examples/model-source.yaml" + if not lock.exists(): + return # Historical releases carry their own original contrib fixtures. + subprocess.run( + [ + sys.executable, + str(TOOLS / "fetch-models.py"), + "--lock", + str(lock), + "--output", + str(root / "examples/models"), + ], + check=True, + ) + manifest = root / "examples/deployment.yaml" + document = yaml.safe_load(manifest.read_text()) + # The source example uses repository-root paths. A detached acceptance tree + # has no Git root, so make that original base explicit in the staged copy. + for device in document["devices"]: + for key in ("model", "data", "script"): + if key in device and not device[key].startswith("https://"): + device[key] = str((root / device[key]).resolve()) + manifest.write_text(yaml.safe_dump(document, sort_keys=False)) + + +if __name__ == "__main__": + prepare(sys.argv[1]) diff --git a/packages/modsim/tools/preview-acceptance.py b/packages/modsim/tools/preview-acceptance.py new file mode 100644 index 0000000..a9f5421 --- /dev/null +++ b/packages/modsim/tools/preview-acceptance.py @@ -0,0 +1,38 @@ +"""Protocol readiness and two-device loopback check for the published container.""" + +import time + +from pymodbus.client import ModbusTcpClient +from pymodbus.exceptions import ModbusException + + +def main(): + client = ModbusTcpClient("127.0.0.1", port=5020, timeout=1, retries=0) + deadline = time.monotonic() + 30 + try: + while True: + try: + if client.connect(): + response = client.read_input_registers(1, count=8, device_id=1) + if not response.isError(): + break + except (OSError, ModbusException): + # Docker's proxy may accept a socket before the application is + # listening. Reconnect until an actual Modbus response arrives. + client.close() + if time.monotonic() >= deadline: + raise RuntimeError("published container failed protocol readiness") + time.sleep(0.1) + assert len(response.registers) == 8 + assert not client.write_register(10, 432, device_id=2).isError() + assert client.read_input_registers(0, device_id=2).registers == [432] + assert not client.write_coil(16, True, device_id=2).isError() + assert client.read_discrete_inputs(0, device_id=2).bits[0] + assert client.read_input_registers(0, device_id=3).isError() + print("Published image: two isolated Unit IDs and I/O loopback passed") + finally: + client.close() + + +if __name__ == "__main__": + main() diff --git a/packages/modsim/tox.ini b/packages/modsim/tox.ini new file mode 100644 index 0000000..619c51c --- /dev/null +++ b/packages/modsim/tox.ini @@ -0,0 +1,11 @@ +[tox] +skipsdist = true +envlist = py310, py314 + +[testenv] +allowlist_externals = uv +set_env = UV_PROJECT_ENVIRONMENT = {envdir} +commands_pre = uv sync --locked --all-groups +commands = + pytest + mypy diff --git a/pyproject.toml b/pyproject.toml index 6876436..23c5858 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,71 +1,8 @@ -[project] -name = "modpoll" -version = "2.0.0a10" -description = "A New Command-line Tool for Modbus and MQTT" -authors = [{ name = "Ying Shaodong", email = "helloysd@gmail.com" }] -readme = "README.md" -requires-python = ">=3.10,<4.0" -dependencies = [ - "pymodbus~=3.16.1", - "paho-mqtt>=2.1.0,<3.0.0", - "prettytable>=3.9.0,<4.0.0", - "requests>=2.32.5,<3.0.0", - "modpoll-wot==0.6.0a2", -] - -[project.optional-dependencies] -serial = ["pyserial>=3.5,<4.0"] - -[dependency-groups] -dev = [ - "pre-commit>=3.5.0,<4.0.0", - "pytest>=8.2.2,<9.0.0", - "deptry>=0.16.1,<0.17.0", - "tox>=4.16.0,<5.0.0", - "tomli>=2,<3; python_version < '3.11'", - "pytest-cov>=5,<8", -] -docs = [ - "sphinx>=6,<8", - "sphinx-argparse>=0.3.1,<0.4.0", - "sphinx-rtd-theme>=1.0.0,<2.0.0", - "sphinx-autobuild==2021.3.14", - "pandoc>=2.3,<3.0.0", -] - -[build-system] -requires = ["uv_build>=0.11.19,<0.12.0"] -build-backend = "uv_build" - -[tool.uv.build-backend] -module-name = "modpoll" -module-root = "" +# uv workspace for modpoll, modsim and modpoll-wot (TOOL-01). This root is not a package: each member keeps its own +# pyproject.toml, version and PyPI name, and is built and released on its own. +[tool.uv.workspace] +members = ["packages/modpoll", "packages/modsim", "packages/modpoll-wot"] [tool.uv] # Resolution covers Python 3.10 through 3.14; the CI matrix tests 3.10 and 3.14. environments = ["python_version < '3.15'"] - -[project.urls] -Repository = "https://github.com/top-maker/modpoll" -Documentation = "https://top-maker.github.io/modpoll" - -[tool.deptry] -package_module_name_map = { pyserial = "serial" } - -[tool.deptry.per_rule_ignores] -DEP002 = ["pyserial"] - -[tool.pytest.ini_options] -testpaths = ["tests"] -markers = ["integration: marks tests as integration tests"] - -[project.scripts] -modpoll = "modpoll.main:app" -modpoll-wot = "modpoll_wot.__main__:main" - -[tool.coverage.run] -source = ["modpoll"] - -[tool.coverage.report] -# Measured by the default offline suite (about 84%); raise it as coverage grows. -fail_under = 80 diff --git a/uv.lock b/uv.lock index 8a12351..7dea0e8 100644 --- a/uv.lock +++ b/uv.lock @@ -9,6 +9,13 @@ supported-markers = [ "python_full_version < '3.15'", ] +[manifest] +members = [ + "modpoll", + "modpoll-wot", + "modsim", +] + [[package]] name = "alabaster" version = "0.7.16" @@ -29,20 +36,54 @@ wheels = [ [[package]] name = "babel" -version = "2.17.0" +version = "2.18.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/7d/b2/51899539b6ceeeb420d40ed3cd4b7a40519404f9baf3d4ac99dc413a834b/babel-2.18.0.tar.gz", hash = "sha256:b80b99a14bd085fcacfa15c9165f651fbb3406e66cc603abf11c5750937c992d", size = 9959554, upload-time = "2026-02-01T12:30:56.078Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/77/f5/21d2de20e8b8b0408f0681956ca2c69f1320a3848ac50e6e7f39c6159675/babel-2.18.0-py3-none-any.whl", hash = "sha256:e2b422b277c2b9a9630c1d7903c2a00d0830c409c59ac8cae9081c92f1aeba35", size = 10196845, upload-time = "2026-02-01T12:30:53.445Z" }, +] + +[[package]] +name = "backrefs" +version = "8.1" +source = { registry = "https://pypi.org/simple" } +resolution-markers = [ + "python_full_version < '3.11'", +] +sdist = { url = "https://files.pythonhosted.org/packages/68/bc/c4b75b0279b2cf9e208c7dea5755a452d158a32abe1b7330824ff1127e86/backrefs-8.1.tar.gz", hash = "sha256:f86d9312df3ebae1241758af80809a319cafa1d8f32189edfb242c9aa55573b6", size = 6999089, upload-time = "2026-10-10T13:29:24.051Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/da/17/7be730f397b9239be5044a147f0cdfbd9605111b07af053c737b21d79d16/backrefs-8.1-py310-none-any.whl", hash = "sha256:438bd38dc7fa0cded52786a1351a2dad9efc2cda95d047284c41d916a22312a8", size = 380382, upload-time = "2026-10-10T13:29:12.764Z" }, + { url = "https://files.pythonhosted.org/packages/fd/d1/d25387b14119b7062fead6c9b2e87c2ab286beb346df79c6a649c095e979/backrefs-8.1-py311-none-any.whl", hash = "sha256:11f61846e446fa8637af2f5c073f1083aa58dbb7460b019fd51689f564e44f7e", size = 392180, upload-time = "2026-10-10T13:29:14.729Z" }, + { url = "https://files.pythonhosted.org/packages/7d/63/4c3078fcbb3956c55b24472d8375a1b7ad67203d4a1917512eee34d4fbee/backrefs-8.1-py312-none-any.whl", hash = "sha256:b472c76082769f86a97ffccfd1f2599b2b706610c6154955664fffe67e909035", size = 398092, upload-time = "2026-10-10T13:29:16.364Z" }, + { url = "https://files.pythonhosted.org/packages/df/22/60f30c9b8e497ca4bbac23991a726ebc267e23771a1b9d9c04b3a3c16dd6/backrefs-8.1-py313-none-any.whl", hash = "sha256:db577dbae1c61187534d35fc9bfbd0c01158fff6239a66fecf7590e5b17879a9", size = 400050, upload-time = "2026-10-10T13:29:18.09Z" }, + { url = "https://files.pythonhosted.org/packages/45/c7/80fa46ecb47717845ab9c07bce8651ef8f80aac5ec698e212d02ed2a9963/backrefs-8.1-py314-none-any.whl", hash = "sha256:1e857c32e91b8fe46ddb359ac21021a37b090fa4239566a61e9856123e334041", size = 411908, upload-time = "2026-10-10T13:29:19.876Z" }, + { url = "https://files.pythonhosted.org/packages/05/32/a57c5a5b7461b8c88266244014aa38052d76f64b064451b1d5342eb09bf4/backrefs-8.1-py315-none-any.whl", hash = "sha256:9c8fe3e2eaae4301a9ce787341d986e5ba25a887d89da6de0de5d58eca26a949", size = 417589, upload-time = "2026-10-10T13:29:21.821Z" }, +] + +[[package]] +name = "backrefs" +version = "8.3" source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/7d/6b/d52e42361e1aa00709585ecc30b3f9684b3ab62530771402248b1b1d6240/babel-2.17.0.tar.gz", hash = "sha256:0c54cffb19f690cdcc52a3b50bcbf71e07a808d1c80d549f2459b9d2cf0afb9d", size = 9951852, upload-time = "2025-02-01T15:17:41.026Z" } +resolution-markers = [ + "python_full_version >= '3.11' and python_full_version < '3.15'", +] +sdist = { url = "https://files.pythonhosted.org/packages/53/1d/01d5e03463cf724789518b935b1df079d3692e9565b7f41d5c289295b2a3/backrefs-8.3.tar.gz", hash = "sha256:bc87b4350f11cc6bf31a2f793dd2f9df577f5c91efaa943627bd261df26506aa", size = 5947408, upload-time = "2026-11-13T00:49:26.625Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/b7/b8/3fe70c75fe32afc4bb507f75563d39bc5642255d1d94f1f23604725780bf/babel-2.17.0-py3-none-any.whl", hash = "sha256:4d0b53093fdfb4b21c92b5213dba5a1b23885afa8383709427046b21c366e5f2", size = 10182537, upload-time = "2025-02-01T15:17:37.39Z" }, + { url = "https://files.pythonhosted.org/packages/b0/ed/960d7997ce9f41481ad50ce8b22ad3343c67510e15e687cfa0b47ece00a1/backrefs-8.3-py310-none-any.whl", hash = "sha256:bc7ab9f1f5444d23ce15795700f6a3e621f13d521e0cb87e21204ff1e12b8c5f", size = 386394, upload-time = "2026-11-13T00:49:16.959Z" }, + { url = "https://files.pythonhosted.org/packages/16/d7/4fcdb17835dc0f3519272d0d54114a4e63081732634c377491f8ba5b73a0/backrefs-8.3-py311-none-any.whl", hash = "sha256:2722cbb6884ecadce4cab992113fa50fc2c28733949104132fcf89dba0ac3290", size = 398389, upload-time = "2026-11-13T00:49:18.566Z" }, + { url = "https://files.pythonhosted.org/packages/ee/12/3f55cfffe037d84db1b37fee7a91b461ce02b6303417ae6ce4abf82d50c7/backrefs-8.3-py312-none-any.whl", hash = "sha256:f9e7cc5934a9dd89bf1d86a91853120fca7cd32d7861c829c7a449f30100ba99", size = 404182, upload-time = "2026-11-13T00:49:19.881Z" }, + { url = "https://files.pythonhosted.org/packages/26/ff/690caa4791e08622331c23b4728c80c2bffbf72a189fa1182860d5364f6c/backrefs-8.3-py313-none-any.whl", hash = "sha256:3f4b574b32f08b0c0dedc6ad15c3865ce93f1dca4fb31760e061bc4bac41ff2b", size = 406069, upload-time = "2026-11-13T00:49:21.463Z" }, + { url = "https://files.pythonhosted.org/packages/54/37/af7a66a70ec5ca0d535950c3807432b9840bf3ec9f98baf1268d08608925/backrefs-8.3-py314-none-any.whl", hash = "sha256:be0de6f9ead4d44839169774643f25e36f4f2b05f7f1850368f5b5147e279e82", size = 418239, upload-time = "2026-11-13T00:49:22.94Z" }, + { url = "https://files.pythonhosted.org/packages/ba/55/50bb5542709c09673e7d321dd3de828715780e138684ff84c65f04c88c02/backrefs-8.3-py315-none-any.whl", hash = "sha256:3930982530dc3e6c3b45094fdaa246edd59e4e91fd6b2dba61ee821efe1e3101", size = 423672, upload-time = "2026-11-13T00:49:24.871Z" }, ] [[package]] name = "cachetools" -version = "6.2.2" +version = "7.2.6" source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/fb/44/ca1675be2a83aeee1886ab745b28cda92093066590233cc501890eb8417a/cachetools-6.2.2.tar.gz", hash = "sha256:8e6d266b25e539df852251cfd6f990b4bc3a141db73b939058d809ebd2590fc6", size = 31571, upload-time = "2025-11-13T17:42:51.465Z" } +sdist = { url = "https://files.pythonhosted.org/packages/f2/0f/e02be8857e0fc519a12337568f0bf4b0aad4f3a95d7303e9e9d9fbcca8c2/cachetools-7.2.6.tar.gz", hash = "sha256:1096513bdeed468ba505df3d123e4578a5a22c955f4a9ba3912fd71f3f95363a", size = 46662, upload-time = "2026-10-26T21:46:43.818Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/e6/46/eb6eca305c77a4489affe1c5d8f4cae82f285d9addd8de4ec084a7184221/cachetools-6.2.2-py3-none-any.whl", hash = "sha256:6c09c98183bf58560c97b2abfcedcbaf6a896a490f534b031b661d3723b45ace", size = 11503, upload-time = "2025-11-13T17:42:50.232Z" }, + { url = "https://files.pythonhosted.org/packages/53/98/c8201d54b354857a3050a52751ca482eb143c404b387ab2c41a0f981b610/cachetools-7.2.6-py3-none-any.whl", hash = "sha256:8722e08fc36ae0838a9a0a2ab9935554720de3343a62dad7aae7c595854c8623", size = 19523, upload-time = "2026-10-26T21:46:42.277Z" }, ] [[package]] @@ -63,15 +104,6 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/db/3c/33bac158f8ab7f89b2e59426d5fe2e4f63f7ed25df84c036890172b412b5/cfgv-3.5.0-py2.py3-none-any.whl", hash = "sha256:a8dc6b26ad22ff227d2634a65cb388215ce6cc96bbcc5cfde7641ae87e8dacc0", size = 7445, upload-time = "2025-11-19T20:55:50.744Z" }, ] -[[package]] -name = "chardet" -version = "5.2.0" -source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/f3/0d/f7b6ab21ec75897ed80c17d79b15951a719226b9fababf1e40ea74d69079/chardet-5.2.0.tar.gz", hash = "sha256:1b3b6ff479a8c414bc3fa2c0852995695c4a026dcd6d0633b2dd092ca39c1cf7", size = 2069618, upload-time = "2023-08-01T19:23:02.662Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/38/6f/f5fbc992a329ee4e0f288c1fe0e2ad9485ed064cac731ed2fe47dcc38cbf/chardet-5.2.0-py3-none-any.whl", hash = "sha256:e1cf59446890a00105fe7b7912492ea04b6e6f06d4b742b2c788469e34c82970", size = 199385, upload-time = "2023-08-01T19:23:00.661Z" }, -] - [[package]] name = "charset-normalizer" version = "3.4.4" @@ -163,14 +195,11 @@ wheels = [ [[package]] name = "click" -version = "8.3.1" +version = "8.5.0" source = { registry = "https://pypi.org/simple" } -dependencies = [ - { name = "colorama", marker = "python_full_version < '3.15' and sys_platform == 'win32'" }, -] -sdist = { url = "https://files.pythonhosted.org/packages/3d/fa/656b739db8587d7b5dfa22e22ed02566950fbfbcdc20311993483657a5c0/click-8.3.1.tar.gz", hash = "sha256:12ff4785d337a1bb490bb7e9c2b1ee5da3112e94a8622f26a6c77f5d2fc6842a", size = 295065, upload-time = "2025-11-15T20:45:42.706Z" } +sdist = { url = "https://files.pythonhosted.org/packages/c7/0e/7fa0ef50764b67090eca4114772a2abf8b6148198475e54c660b97caeee6/click-8.5.0.tar.gz", hash = "sha256:ba0d2089de75ea0310e2dde03160e6ca10009947fb95a182f9b54021bb272e34", size = 382235, upload-time = "2026-08-26T13:33:14.56Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/98/78/01c019cdb5d6498122777c1a43056ebb3ebfeef2076d9d026bfe15583b2b/click-8.3.1-py3-none-any.whl", hash = "sha256:981153a64e25f12d547d3426c367a4857371575ee7ad18df2a6183ab0545b2a6", size = 108274, upload-time = "2025-11-15T20:45:41.139Z" }, + { url = "https://files.pythonhosted.org/packages/58/50/6c0d534c5f134586a8e1ba4e330569e32f057e33372ae556463212fb4cd3/click-8.5.0-py3-none-any.whl", hash = "sha256:255bc9599cf7748b4b1a446ccc735421bd08a2ae529a8b88597d3de5664ee360", size = 125251, upload-time = "2026-08-26T13:33:12.928Z" }, ] [[package]] @@ -472,11 +501,11 @@ wheels = [ [[package]] name = "distlib" -version = "0.4.0" +version = "0.4.4" source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/96/8e/709914eb2b5749865801041647dc7f4e6d00b549cfe88b65ca192995f07c/distlib-0.4.0.tar.gz", hash = "sha256:feec40075be03a04501a973d81f633735b4b69f98b05450592310c0f401a4e0d", size = 614605, upload-time = "2025-07-17T16:52:00.465Z" } +sdist = { url = "https://files.pythonhosted.org/packages/68/bc/d36966de7304047a1001a7559fbf266c464bb5d8cc85464536ef8c9bcc32/distlib-0.4.4.tar.gz", hash = "sha256:ca4175b4ac7f71223cc30ed7248c45d2b38c2439d8ee6e498ab67ed63cf3508d", size = 621304, upload-time = "2026-10-16T13:56:34.203Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/33/6b/e0547afaf41bf2c42e52430072fa5658766e3d65bd4b03a563d1b6336f57/distlib-0.4.0-py2.py3-none-any.whl", hash = "sha256:9659f7d87e46584a30b5780e43ac7a2143098441670ff0a49d5f9034c54a6c16", size = 469047, upload-time = "2025-07-17T16:51:58.613Z" }, + { url = "https://files.pythonhosted.org/packages/c1/2b/238f02a4927fa2e27aa995371d240a468b52e42eae44a678434aff736b38/distlib-0.4.4-py2.py3-none-any.whl", hash = "sha256:cf09d55b1e85a89576b036aeb71550bfd68320f3f21761ca329eadadad918638", size = 472099, upload-time = "2026-10-16T13:56:32.053Z" }, ] [[package]] @@ -502,20 +531,121 @@ wheels = [ [[package]] name = "filelock" -version = "3.20.0" +version = "4.1.0" source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/58/46/0028a82567109b5ef6e4d2a1f04a583fb513e6cf9527fcdd09afd817deeb/filelock-3.20.0.tar.gz", hash = "sha256:711e943b4ec6be42e1d4e6690b48dc175c822967466bb31c0c293f34334c13f4", size = 18922, upload-time = "2025-10-08T18:03:50.056Z" } +sdist = { url = "https://files.pythonhosted.org/packages/4c/58/6fd434bec86eff7c38a3168454cb132b762b2bea9b3ac094101a2f7bc32a/filelock-4.1.0.tar.gz", hash = "sha256:ad7f724afef953e731b1cc39bcd3a09166d72ed7fcdf29e6e88b1c3235c6715d", size = 561277, upload-time = "2026-10-09T19:57:20.34Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/76/91/7216b27286936c16f5b4d0c530087e4a54eead683e6b0b73dd0c64844af6/filelock-3.20.0-py3-none-any.whl", hash = "sha256:339b4732ffda5cd79b13f4e2711a31b0365ce445d95d243bb996273d072546a2", size = 16054, upload-time = "2025-10-08T18:03:48.35Z" }, + { url = "https://files.pythonhosted.org/packages/ee/86/032133892a5de43b5a98200b01aadcad68cc255e274a762f08b8a76d2912/filelock-4.1.0-py3-none-any.whl", hash = "sha256:2ce9818e3e2d8f284c1a964414447ef148d42a5fd5e2a477a7118e574b293ec1", size = 133003, upload-time = "2026-10-09T19:57:18.716Z" }, +] + +[[package]] +name = "ghp-import" +version = "2.1.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "python-dateutil", version = "3.0.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.11'" }, + { name = "python-dateutil", version = "4.0.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.11' and python_full_version < '3.15'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/d9/29/d40217cbe2f6b1359e00c6c307bb3fc876ba74068cbab3dde77f03ca0dc4/ghp-import-2.1.0.tar.gz", hash = "sha256:9c535c4c61193c2df8871222567d7fd7e5014d835f97dc7b7439069e2413d343", size = 10943, upload-time = "2022-05-02T15:47:16.11Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/f7/ec/67fbef5d497f86283db54c22eec6f6140243aae73265799baaaa19cd17fb/ghp_import-2.1.0-py3-none-any.whl", hash = "sha256:8337dd7b50877f163d4c0289bc1f1c7f127550241988d568c1db512c4324a619", size = 11034, upload-time = "2022-05-02T15:47:14.552Z" }, +] + +[[package]] +name = "griffe" +version = "2.3.0" +source = { registry = "https://pypi.org/simple" } +resolution-markers = [ + "python_full_version < '3.11'", +] +dependencies = [ + { name = "griffecli", version = "2.3.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.11'" }, + { name = "griffelib", version = "2.3.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.11'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/d5/03/75ca4d08a7eff164292d42cf72c7c510423b3414e66205f0ba5b35ad3034/griffe-2.3.0.tar.gz", hash = "sha256:aa5634c0d7802583ecd29a7fe335c02d462ffdf5ce8f51426a3d326f374e6d93", size = 247493, upload-time = "2026-09-04T15:08:15.364Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/61/f9/8bfacdb992aed404a3a53694689759841635bce93b86ddb621c1d7f2558c/griffe-2.3.0-py3-none-any.whl", hash = "sha256:92a41ff72eb1eb316cdcb7248a608f1313f9fbc6e35d5cffa5cf7c813b7db70b", size = 5072, upload-time = "2026-09-04T15:08:14.074Z" }, +] + +[[package]] +name = "griffe" +version = "2.4.1" +source = { registry = "https://pypi.org/simple" } +resolution-markers = [ + "python_full_version >= '3.11' and python_full_version < '3.15'", +] +dependencies = [ + { name = "griffecli", version = "2.4.1", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.11' and python_full_version < '3.15'" }, + { name = "griffelib", version = "2.4.1", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.11' and python_full_version < '3.15'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/33/a4/be055b9ced02e39ac0ab85960e0ed3d8c6017c03e90965e77ff276684418/griffe-2.4.1.tar.gz", hash = "sha256:766123e26ec35b2ead63202e9e43ec309d876085d571b7df288256cd6fe4a3ef", size = 450805, upload-time = "2026-10-22T11:20:02.532Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/29/93/67a1814b4b13e9a5cc02510dbfa1d3937603140192a701c96d861b272611/griffe-2.4.1-py3-none-any.whl", hash = "sha256:ca58ccdb1d8590ad062fad837a875dd704f94acf7a0104795a098a991ceaf728", size = 5100, upload-time = "2026-10-22T11:19:58.365Z" }, +] + +[[package]] +name = "griffecli" +version = "2.3.0" +source = { registry = "https://pypi.org/simple" } +resolution-markers = [ + "python_full_version < '3.11'", +] +dependencies = [ + { name = "colorama", marker = "python_full_version < '3.11'" }, + { name = "griffelib", version = "2.3.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.11'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/5c/15/f70539f7efb44f27d209b43e386b1a5397bd476879ff19a206b75454f58e/griffecli-2.3.0.tar.gz", hash = "sha256:916fdc851cf51d38e9b5ab82550305df45e5981d5dfe65d346544464abedb3ec", size = 59676, upload-time = "2026-09-04T15:08:16.426Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/06/8c/8ffa4272d6bf85a0abe8898ef74ef41d505317bb4103e14a11d45d799dce/griffecli-2.3.0-py3-none-any.whl", hash = "sha256:f94653edcb52ebcac21eaeb3b7121b065a636174eddf2bd558b5935e72a553e8", size = 11593, upload-time = "2026-09-04T15:08:11.739Z" }, +] + +[[package]] +name = "griffecli" +version = "2.4.1" +source = { registry = "https://pypi.org/simple" } +resolution-markers = [ + "python_full_version >= '3.11' and python_full_version < '3.15'", +] +dependencies = [ + { name = "colorama", marker = "python_full_version >= '3.11' and python_full_version < '3.15'" }, + { name = "griffelib", version = "2.4.1", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.11' and python_full_version < '3.15'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/c9/8e/d3130e17ae27c900f8f76c96ceb2f02edfe0c7db0366b49e033f81ff81d7/griffecli-2.4.1.tar.gz", hash = "sha256:6db9acad984990b08c833ab5ec73d5a604e317b2290074d04c91ca9e52d35a7b", size = 61762, upload-time = "2026-10-22T11:20:01.054Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/3f/dc/5cdbbbfd1a9e8c0e9b6b8b6e6d839e67f82cb138b77cf74856e5b80527de/griffecli-2.4.1-py3-none-any.whl", hash = "sha256:1678938e7b75a0aa34d3e408d550707a192f5297c3005aa0f92660648c30bc0a", size = 11774, upload-time = "2026-10-22T11:19:57.134Z" }, +] + +[[package]] +name = "griffelib" +version = "2.3.0" +source = { registry = "https://pypi.org/simple" } +resolution-markers = [ + "python_full_version < '3.11'", +] +sdist = { url = "https://files.pythonhosted.org/packages/27/af/018c10bc9edd42b6ef6db2e96b09542050d5253f9b195e74bc910b2d13ab/griffelib-2.3.0.tar.gz", hash = "sha256:7b0952caf5bca6afa4bb5ee8c6a2d183fe3f21b62efc5f6c7243cb2b26d2d115", size = 234534, upload-time = "2026-09-04T15:08:17.472Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/41/63/e876e789525063c840ccfa8857febdabd6523bcef9ce7eb979b9305ea895/griffelib-2.3.0-py3-none-any.whl", hash = "sha256:1b8f9cd525681c26b1d6d574faa1371651e8459ca51d209684f50b8096ae06e0", size = 169423, upload-time = "2026-09-04T15:08:12.956Z" }, +] + +[[package]] +name = "griffelib" +version = "2.4.1" +source = { registry = "https://pypi.org/simple" } +resolution-markers = [ + "python_full_version >= '3.11' and python_full_version < '3.15'", +] +sdist = { url = "https://files.pythonhosted.org/packages/36/e2/0f5d8ed08766bc6dcd3eebf5a6623d83cbca33a6e4c90aef57156ce745ad/griffelib-2.4.1.tar.gz", hash = "sha256:40c028dd2e623f464423f0e11e3c553158f1cf4f1368239a370534d73e1407ff", size = 245153, upload-time = "2026-10-22T11:20:03.705Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/de/02/1156d5f5307f573b901b14373848b84e69ca6cab09169b8cc97d16a181f9/griffelib-2.4.1-py3-none-any.whl", hash = "sha256:76bc562f936ad1ce198d2cf6d0731bd5c92a7d934b69ef828ef22ee0ffdb62ce", size = 172983, upload-time = "2026-10-22T11:19:59.843Z" }, ] [[package]] name = "identify" -version = "2.6.15" +version = "2.6.20" source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/ff/e7/685de97986c916a6d93b3876139e00eef26ad5bbbd61925d670ae8013449/identify-2.6.15.tar.gz", hash = "sha256:e4f4864b96c6557ef2a1e1c951771838f4edc9df3a72ec7118b338801b11c7bf", size = 99311, upload-time = "2025-10-02T17:43:40.631Z" } +sdist = { url = "https://files.pythonhosted.org/packages/53/35/d70c0006c7cee65999ea94a6273e60b2094f600a3d8b71b04318253fc643/identify-2.6.20.tar.gz", hash = "sha256:ad729860a923858d26917c2f4fb0a1d83d27a75b1e090c06440c573f048f3285", size = 99681, upload-time = "2026-09-26T20:29:07.187Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/0f/1c/e5fd8f973d4f375adb21565739498e2e9a1e54c858a97b9a8ccfdc81da9b/identify-2.6.15-py2.py3-none-any.whl", hash = "sha256:1181ef7608e00704db228516541eb83a88a9f94433a8c80bb9b5bd54b1d81757", size = 99183, upload-time = "2025-10-02T17:43:39.137Z" }, + { url = "https://files.pythonhosted.org/packages/fa/70/fffc9613501877c0a10a1ef73a165e6ded3e53f6e7502227fef56d973933/identify-2.6.20-py2.py3-none-any.whl", hash = "sha256:6a16b69b93187244e0548cbfd25b3e4a6f9a7a2ad784625c3bec2b8d27b81aaa", size = 99506, upload-time = "2026-09-26T20:29:06.054Z" }, ] [[package]] @@ -538,11 +668,11 @@ wheels = [ [[package]] name = "iniconfig" -version = "2.3.0" +version = "2.3.1" source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/72/34/14ca021ce8e5dfedc35312d08ba8bf51fdd999c576889fc2c24cb97f4f10/iniconfig-2.3.0.tar.gz", hash = "sha256:c76315c77db068650d49c5b56314774a7804df16fee4402c1f19d6d15d8c4730", size = 20503, upload-time = "2025-10-18T21:55:43.219Z" } +sdist = { url = "https://files.pythonhosted.org/packages/01/e1/2069291243c926a2ff1cd706c7f3eeb9b62144bf60f77c9fb9ff2fb26bd3/iniconfig-2.3.1.tar.gz", hash = "sha256:67f4b9c50da0dedf52af349e7749a80a9057a5031199791b906c3bb3ae878960", size = 21209, upload-time = "2026-10-06T22:48:38.076Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/cb/b1/3846dd7f199d53cb17f49cba7e651e9ce294d8497c8c150530ed11865bb8/iniconfig-2.3.0-py3-none-any.whl", hash = "sha256:f631c04d2c48c52b84d0d0549c99ff3859c98df65b3101406327ecc7d53fbf12", size = 7484, upload-time = "2025-10-18T21:55:41.639Z" }, + { url = "https://files.pythonhosted.org/packages/56/43/4ca9e49d27a1fcf6bece6f6aec0ea46bb9112489b93d4b688fb415457bdb/iniconfig-2.3.1-py3-none-any.whl", hash = "sha256:9121e2c1fdb355232495be3194c8dfe87ccc2d5dee45947b78e68f499790d7a7", size = 7552, upload-time = "2026-10-06T22:48:36.959Z" }, ] [[package]] @@ -584,6 +714,136 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/41/45/1a4ed80516f02155c51f51e8cedb3c1902296743db0bbc66608a0db2814f/jsonschema_specifications-2025.9.1-py3-none-any.whl", hash = "sha256:98802fee3a11ee76ecaca44429fda8a41bff98b00a0f2838151b113f210cc6fe", size = 18437, upload-time = "2025-09-08T01:34:57.871Z" }, ] +[[package]] +name = "librt" +version = "0.16.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/04/f5/9dc696772d241814bacac7880bac32f2930b5a6ebc1f85317b83161a011c/librt-0.16.0.tar.gz", hash = "sha256:ac38d6d8d66bf3d744148dbbc0b8e193e195a51e364ed55e224631f5721891fc", size = 219839, upload-time = "2026-09-29T00:55:32.891Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/ec/77/900294b3c9a81415323d81b3f3f271a7f5d7ed9d01e824fc38ffa49470b6/librt-0.16.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:96f576f2711f8519152ec76d0e599243555c1f07679fa73606ca8c8c868c0be6", size = 148668, upload-time = "2026-09-29T00:44:20.282Z" }, + { url = "https://files.pythonhosted.org/packages/55/3b/c301e8cc47758e4518b93e926a0111080155cc79fa03651d202ac2025065/librt-0.16.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:2bec3818c7da7c96ceae0ef5915a3d16c52dd08f3ea913bf1fe8568c447c7978", size = 153562, upload-time = "2026-09-29T00:44:21.672Z" }, + { url = "https://files.pythonhosted.org/packages/62/b1/4d5b98114a58bf17e3832cd33400e40f2582f68c2fb7ce25b4468cb1afd3/librt-0.16.0-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:64c79520414a3fdfc6aabd7593e6169afa14d5f8d9908d4b498db068868b08dd", size = 494337, upload-time = "2026-09-29T00:44:23.096Z" }, + { url = "https://files.pythonhosted.org/packages/88/36/14223c9b0dc38982eb4f399732c8cb27b19c7e027ae0faef5ca51d08d19f/librt-0.16.0-cp310-cp310-manylinux2014_i686.manylinux_2_17_i686.manylinux_2_28_i686.whl", hash = "sha256:f81b5b19ce748ef68d4746656b7929762eb2fe99269b266e4be07e2ee4de7144", size = 485440, upload-time = "2026-09-29T00:44:24.555Z" }, + { url = "https://files.pythonhosted.org/packages/ec/9e/d7155e6800d0c33e297e529b217649f7361d706491ebf9d2fc0fc627309e/librt-0.16.0-cp310-cp310-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:c71d1b76210a36729fedfc5115069b50a3d8619054745f8758fe5d6f19e86671", size = 498363, upload-time = "2026-09-29T00:44:26.03Z" }, + { url = "https://files.pythonhosted.org/packages/d3/ce/d5f1fb9f913ac0979d6fc5db9fb9c0bf28cc3470988528957922f15ed40c/librt-0.16.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:473eebc7866bb0a0c8849a292b5e7157c1aba5d14d0f0f610c52158d6d964262", size = 515453, upload-time = "2026-09-29T00:44:27.566Z" }, + { url = "https://files.pythonhosted.org/packages/b4/d4/ca0fca1a27c26080d1a25b2b31f271e532078a5719878c3daca0c3d4c539/librt-0.16.0-cp310-cp310-manylinux_2_34_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:4eb1313a19847089ee81e88742abedf285c60538816640b99742d8534b81d26a", size = 509537, upload-time = "2026-09-29T00:44:29.14Z" }, + { url = "https://files.pythonhosted.org/packages/ee/c0/26807bf2221a53a2c66f2e23a5c4d57f1c0eaa4afed7cb81d841cf3d1903/librt-0.16.0-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:ebefd60b42e2a82b32d136bb5f7c94eadfcd29f772b547df6f3291d1ed855a1c", size = 532541, upload-time = "2026-09-29T00:44:30.745Z" }, + { url = "https://files.pythonhosted.org/packages/0e/50/c329d509907e1bc061abeec3796f94d255d43ba25d28c3854d2138ed5ab2/librt-0.16.0-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:6c5da27e8056439f927ea896735da60e616c477a8293feaa3233d4e7781a6726", size = 537059, upload-time = "2026-09-29T00:44:32.102Z" }, + { url = "https://files.pythonhosted.org/packages/84/d6/4571b9c9e65d98e5503734166dce2fd3e216f526dc3c59a3773faa8a60e3/librt-0.16.0-cp310-cp310-musllinux_1_2_ppc64le.whl", hash = "sha256:67e718c7a43f8db325abbbf1404e2d535f12f8f7a1a82259568385cc5274b82a", size = 536614, upload-time = "2026-09-29T00:44:33.653Z" }, + { url = "https://files.pythonhosted.org/packages/c8/d3/a2ed8a292e4ab7889792a9c3f4ad5d1caf6557afce7f6b452e77f8ed20b7/librt-0.16.0-cp310-cp310-musllinux_1_2_riscv64.whl", hash = "sha256:314e703f0c19320dc8094e7a784b9cf29e1b67402515abf580069a6363c0b4f1", size = 517199, upload-time = "2026-09-29T00:44:35.115Z" }, + { url = "https://files.pythonhosted.org/packages/9e/24/276e5218b4b7adb6258a42b7403cb1b7cef25616238d0c2152288a9d2f53/librt-0.16.0-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:943c6bbecbdf7fa575a4f2952fcfd848c88ef95507c3fca411e89d4ac3ff8143", size = 558746, upload-time = "2026-09-29T00:44:36.656Z" }, + { url = "https://files.pythonhosted.org/packages/7c/5c/9156df81a1726e1efc9567379def2b8777a6d56f464d2f1b760bf951b8af/librt-0.16.0-cp310-cp310-win32.whl", hash = "sha256:7cc365f006891afb006b52d5ee5ee74c09306ffa20e2f8705a32a4450af2f3ba", size = 104424, upload-time = "2026-09-29T00:44:38.123Z" }, + { url = "https://files.pythonhosted.org/packages/0b/62/4fd172cb3f49ab2cf5ef17de519a93cfb935202c1270ba9d44c6a64178c3/librt-0.16.0-cp310-cp310-win_amd64.whl", hash = "sha256:0314058469f4d2fd279ce7c62ac274ac82c3918ef7db62ef0697c4c359370155", size = 124267, upload-time = "2026-09-29T00:44:39.455Z" }, + { url = "https://files.pythonhosted.org/packages/ba/0e/b04fd2d76b6a78a02286938251b2c119fb36ddece92c76cb4886ef7d44b8/librt-0.16.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:fe4372c52d4849096c6cc1cda2817d293ec51440c890474ed59ef38d46556f18", size = 148058, upload-time = "2026-09-29T00:44:40.903Z" }, + { url = "https://files.pythonhosted.org/packages/a3/fc/e1ed24aadb32d38603c0c07f579d739eb4d90e64e90d525b024e4a999b4d/librt-0.16.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:c72c5295a84bd249526da9bdca38f2e176d15c31c13bb0063c5053f4ca023421", size = 153073, upload-time = "2026-09-29T00:44:42.165Z" }, + { url = "https://files.pythonhosted.org/packages/be/38/133ab655409420e0c34a9a9836a7f4e5ae75fba758d7fe177099130d58ba/librt-0.16.0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:be56ba9c884143495b517f23fe794ae367d58cd89ea0fdd6d437e3c024a87f9f", size = 493052, upload-time = "2026-09-29T00:44:44.043Z" }, + { url = "https://files.pythonhosted.org/packages/94/42/aaa663bc9421f5bf7bbbe9d3316d7219749698ec7688ac3b519770a89c04/librt-0.16.0-cp311-cp311-manylinux2014_i686.manylinux_2_17_i686.manylinux_2_28_i686.whl", hash = "sha256:ef46c1a29ffb8c72e882e22618ec618778eacd0578fb22c6e7cf9c11d15f357b", size = 485506, upload-time = "2026-09-29T00:44:45.479Z" }, + { url = "https://files.pythonhosted.org/packages/7b/59/83a6eb5087ba8b45b083859e2085256963e06d4c2531944cdd962670bfb5/librt-0.16.0-cp311-cp311-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:d3c94211ee0c4f8d649ec06b7c115c0ec4eadb873a0e3154ca15cef3f814b071", size = 498708, upload-time = "2026-09-29T00:44:46.916Z" }, + { url = "https://files.pythonhosted.org/packages/a0/e4/15a8d62b2bc12935080ec7277e2e0b9b233047781eb784a51d3e25af669a/librt-0.16.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:94aed6a8308818b91677957d1bd03188869cd7aeb23c5dba7912a6c0402f7602", size = 515981, upload-time = "2026-09-29T00:44:48.316Z" }, + { url = "https://files.pythonhosted.org/packages/46/4f/287cc282ac5dd815204c0779e79401bb0a568c3a1335fb319bf0838fb566/librt-0.16.0-cp311-cp311-manylinux_2_34_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:349c0bcb87ebd07481b6ff781e25cdc699723dbe2212e57dabb27f7a13b7b87d", size = 508670, upload-time = "2026-09-29T00:44:49.726Z" }, + { url = "https://files.pythonhosted.org/packages/bf/5b/ab7292add898ade0d2b5b75d32a923aae315861671aa5c39f5491309f7ae/librt-0.16.0-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:001bfd59a7d45b17e3e75f2a8c6405280b35e7b84471792778e718c4f368950e", size = 530393, upload-time = "2026-09-29T00:44:51.356Z" }, + { url = "https://files.pythonhosted.org/packages/7a/9e/8e6bcf027d4bcbc16a4e864b3d158a1d3e5f55ffa53af0238020cad89271/librt-0.16.0-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:28e038895b998d7a0c7798922ce8a1dc157675df5cf1c9ef0aca809ed804b7a1", size = 534302, upload-time = "2026-09-29T00:44:52.893Z" }, + { url = "https://files.pythonhosted.org/packages/96/a4/8c5ab4f3b3a8e905ff8305d76976a2e666f52fe049edd398aed2402beb36/librt-0.16.0-cp311-cp311-musllinux_1_2_ppc64le.whl", hash = "sha256:0dbe4096a7ecc00fa835d24510ad8545a4efef738dac96e0e63516783ccde905", size = 536150, upload-time = "2026-09-29T00:44:54.421Z" }, + { url = "https://files.pythonhosted.org/packages/ea/5e/7c4bc267e3cd4b8bd288de9f62d61fff203829c9cc649ea2aa12e9218cf0/librt-0.16.0-cp311-cp311-musllinux_1_2_riscv64.whl", hash = "sha256:5cd5b092441053364af968ea12084692cb9d4a22f3ce9524e377880bf028761e", size = 514316, upload-time = "2026-09-29T00:44:55.998Z" }, + { url = "https://files.pythonhosted.org/packages/e0/75/c8bc6b50f43c73819334233f5a3259c81216742cef56d2140c3dd377c3f0/librt-0.16.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:3ddeb3c9dedb461bb457c6c7d9aa7fbf35329da313d1a7543d00c8d0f3473c96", size = 557731, upload-time = "2026-09-29T00:44:57.581Z" }, + { url = "https://files.pythonhosted.org/packages/93/fb/e241f91bc8de6c7ac1c6a20ea6dd381bc52312b44d711ffcd97140db1e57/librt-0.16.0-cp311-cp311-win32.whl", hash = "sha256:e05108e0849966f53a8d2d3112a7af881d0efaa479bc735bba91108f9f2350a7", size = 104922, upload-time = "2026-09-29T00:44:59.078Z" }, + { url = "https://files.pythonhosted.org/packages/d1/38/c892383d2bb1a6a80b2ec8ede84970a265a792c56614a06282bf3008517c/librt-0.16.0-cp311-cp311-win_amd64.whl", hash = "sha256:5f49cff01bd608ef7d97104cb035c75455e79c2d70bf4a506cf773338ac1860d", size = 125093, upload-time = "2026-09-29T00:49:01.621Z" }, + { url = "https://files.pythonhosted.org/packages/e4/56/8bbde1ed0b21480163617648f638fdaec9374cf5e9c846ebcee34ec02a42/librt-0.16.0-cp311-cp311-win_arm64.whl", hash = "sha256:1d28ae980ae2218f9c5b95d191e947296f918c9bf0b400d467a9430275bbe678", size = 115910, upload-time = "2026-09-29T00:52:40.131Z" }, + { url = "https://files.pythonhosted.org/packages/ad/76/bbdaeb87b7c47b5c7343e90222b9bfa4e4a8a83f647e02933ad0129225b1/librt-0.16.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:fe52bf4641069e7978a14253b036cb9002def1926317e710f2e249f8a8c47742", size = 151028, upload-time = "2026-09-29T00:52:41.508Z" }, + { url = "https://files.pythonhosted.org/packages/fd/0c/ab8ed3dab0085931aec4a792c7eaac8dc6c5ff4691fda3a5360d9d8a9cd2/librt-0.16.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:5bcc2c4726ced915b00de0c9856a4eeabfb3fddb93e10e0b8f735b7709358b6d", size = 155283, upload-time = "2026-09-29T00:52:42.873Z" }, + { url = "https://files.pythonhosted.org/packages/eb/36/494e79d460c80c1f030661e8287c9eca5e1ad652dc2b2180b6cd42abce0a/librt-0.16.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:ff7baa55f8e7c69851419e50a666015d02a74198716fd45c0125a2112e0a389f", size = 503185, upload-time = "2026-09-29T00:52:44.638Z" }, + { url = "https://files.pythonhosted.org/packages/9b/34/a8464038dd9db6e4381fa2b6eb73dc9a50888d77102c4c139304ac35cddc/librt-0.16.0-cp312-cp312-manylinux2014_i686.manylinux_2_17_i686.manylinux_2_28_i686.whl", hash = "sha256:b95d5d92ab83d39e760a52091bb1baba664f3a2351e39b1e16801e5747c2f0e9", size = 496738, upload-time = "2026-09-29T00:52:46.441Z" }, + { url = "https://files.pythonhosted.org/packages/6a/53/e0e5e334ef0c6ed27039d323819368b9ef6712be87d55ee2bf9799398afd/librt-0.16.0-cp312-cp312-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:b6d085d70bce51d43c5c7c36d63490770180d8779e71c49305c87b4213918de7", size = 513818, upload-time = "2026-09-29T00:52:48.068Z" }, + { url = "https://files.pythonhosted.org/packages/ad/f7/7ce72cbf19d0addd05090b339152fd0548a02562c2866a603e6e3b3da2df/librt-0.16.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:36e53948e99bbe3ffea257124cfcae1cfb01831555c9a9c903c9f9a72db7fd07", size = 531952, upload-time = "2026-09-29T00:52:49.816Z" }, + { url = "https://files.pythonhosted.org/packages/83/22/0b1bcb6a8e723c8b4fd60dfc8ae8ec6461c54073fbc8685efeb8d900d407/librt-0.16.0-cp312-cp312-manylinux_2_34_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:54d11f726aae9df5a6ffbbf0a03a52449bbac84a53ef03669cb41cdfd4ae41bf", size = 524465, upload-time = "2026-09-29T00:52:51.354Z" }, + { url = "https://files.pythonhosted.org/packages/64/2e/e9c23b8b9df1813da1be205deca9606beb7ddd033972246cd426d05374a0/librt-0.16.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:4323193ac0cd025f85af531df8ba91bf24d1973b401697347a6282e8fd3fcf5e", size = 543191, upload-time = "2026-09-29T00:52:53.284Z" }, + { url = "https://files.pythonhosted.org/packages/bc/e5/6a8b21b342c03ed7e230fa3afbfd2edc58e6e87ef1f0d11fa2b9a748c252/librt-0.16.0-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:e42f8e098b9c5396fefa05fb1cc7e33b0e08fc51da106b5de4a45fd22aac6743", size = 546979, upload-time = "2026-09-29T00:52:54.932Z" }, + { url = "https://files.pythonhosted.org/packages/84/9e/b5129023eced1be01e01c22757f53be551d463b1bb7264f787927404c1d6/librt-0.16.0-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:39ec1d5a14e37baf1450a6cabf03fe552340808bf1ad9d71824ab90117716459", size = 555317, upload-time = "2026-09-29T00:52:56.869Z" }, + { url = "https://files.pythonhosted.org/packages/71/89/28bba5938c725fe91f06bf93f7fa6c6b150229df53a87b454b0d5c2a796e/librt-0.16.0-cp312-cp312-musllinux_1_2_riscv64.whl", hash = "sha256:d1aabe3925cbb4a08d15b7b20ba4011b53019da0c4173a25155139b7b1baed65", size = 535846, upload-time = "2026-09-29T00:52:58.475Z" }, + { url = "https://files.pythonhosted.org/packages/22/92/63773026614f888c5d4e370e395ce42ca604b89f70b3acdfedbf94851b80/librt-0.16.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:300c3ffdc459f4a779a8411ecb188e3ac0b1ff3a3a7b099642555dedae06c69b", size = 573700, upload-time = "2026-09-29T00:53:00.127Z" }, + { url = "https://files.pythonhosted.org/packages/66/8f/347d4677eefb57cd9f8e01d95a1dcee9a91b4e44e664173c32ff6f3752e5/librt-0.16.0-cp312-cp312-win32.whl", hash = "sha256:c17194318e4c0c0348b36f36c2ec7534436fe0a4c15582403162a4f08c80797a", size = 106158, upload-time = "2026-09-29T00:53:02.031Z" }, + { url = "https://files.pythonhosted.org/packages/f0/2c/5193dc81127cd5ddfad031391b046bf32dda219b38463ab872407ca30646/librt-0.16.0-cp312-cp312-win_amd64.whl", hash = "sha256:25a58a19ea8d83b68209f04912df765e9260635ef77646542ed4b4abe6bc7940", size = 126176, upload-time = "2026-09-29T00:53:03.445Z" }, + { url = "https://files.pythonhosted.org/packages/ff/3d/9668a400c8dd81d162eba38b33fa49fa6205f1a64493570a13fbb815c3ee/librt-0.16.0-cp312-cp312-win_arm64.whl", hash = "sha256:f7be7cf555bc30ec12622e9447299cc4a9b8ff307548b634794353db0c2065dc", size = 116572, upload-time = "2026-09-29T00:53:04.815Z" }, + { url = "https://files.pythonhosted.org/packages/46/cd/ae5e0e9dba45d1399aa04a5395bcc0bead40d9fa06dc903634a7b4d7473d/librt-0.16.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:c5e6144e68b577f157519f2ba88ca20e3ed61c29b00e5cdfa76cd2d45acf059a", size = 151036, upload-time = "2026-09-29T00:53:06.284Z" }, + { url = "https://files.pythonhosted.org/packages/41/5a/48a16e323c5f9447a94cce7b59babf60fa04e62c3365ecf060c77ed8b320/librt-0.16.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:33f41443a1f4e1f099331b3d8120e409fbff84b9760bc1cc9ea496f37ddaa5cc", size = 155211, upload-time = "2026-09-29T00:53:07.72Z" }, + { url = "https://files.pythonhosted.org/packages/3f/29/0f59299eb4251a409b2e690ad4b7d9f8a676db829d7817ec961f32b44f7e/librt-0.16.0-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:7e510b7770bee609617a3374a96548eb114cae048023e3f049ee449e7ff2db32", size = 502587, upload-time = "2026-09-29T00:53:09.191Z" }, + { url = "https://files.pythonhosted.org/packages/de/ba/d6fb4ef8d1537c396079d72289f16be7cd35a366e5065c51253fea2760b6/librt-0.16.0-cp313-cp313-manylinux2014_i686.manylinux_2_17_i686.manylinux_2_28_i686.whl", hash = "sha256:efc49c462d4516b8a58b00b490078fa64689fd1fe66970cc190131d7afb8027e", size = 496146, upload-time = "2026-09-29T00:53:11.016Z" }, + { url = "https://files.pythonhosted.org/packages/52/fc/8c50dd4d7cc97c0ee8f252c8a3104980f234391cf1519b554e8b9de08b60/librt-0.16.0-cp313-cp313-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:92caf82ebef5e12d21c72242b70d1e92536f1711cf2a727a4c276de4b4469087", size = 513336, upload-time = "2026-09-29T00:53:12.655Z" }, + { url = "https://files.pythonhosted.org/packages/a9/59/16c409c56f708eda2db9a0553662845d45e3871c77d70a240dae3f3bdc56/librt-0.16.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:17bac7f7a16b328fff77e440287693eb017abde913595b5827ebccbc21ecd8a6", size = 531689, upload-time = "2026-09-29T00:53:14.39Z" }, + { url = "https://files.pythonhosted.org/packages/88/82/d34772a6c29d1446dcca6e64d74062efd508523ab351aa16625a4689d5cc/librt-0.16.0-cp313-cp313-manylinux_2_34_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:5b976054553670829985ed767feb78fb6bcede0175327c4844dd5c281c1be659", size = 524537, upload-time = "2026-09-29T00:53:16.064Z" }, + { url = "https://files.pythonhosted.org/packages/77/8f/24c5631313746131ccee53bc91fdc8374f9cf25e0082a1fee9c93bb98acc/librt-0.16.0-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:0058f9d68721094105917254c72ac0569117bb7b13b9769cf45d26d89f9d21cd", size = 543231, upload-time = "2026-09-29T00:53:17.939Z" }, + { url = "https://files.pythonhosted.org/packages/f2/cb/5f8e0d41dbd8b499c2265e939c31acc9ba59845565bf99539ad1c06aebcf/librt-0.16.0-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:30b7beaf3f4487b7d8adef1f158b49067cb4d5a19fa7a3bf31a4e7a820e435c5", size = 546499, upload-time = "2026-09-29T00:53:19.666Z" }, + { url = "https://files.pythonhosted.org/packages/be/61/063052de441d1385f59cea4223f184bf9e5d125de1ae3239b490aa1e486e/librt-0.16.0-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:468df902df016a06eb0e40b0747dc8d14e47d7a38b18b63b1fb167d85cb94d63", size = 555261, upload-time = "2026-09-29T00:53:21.292Z" }, + { url = "https://files.pythonhosted.org/packages/14/11/a2ada0529372268d6401afa9d457a095b68cd7753532b6f7f33049a19b43/librt-0.16.0-cp313-cp313-musllinux_1_2_riscv64.whl", hash = "sha256:aea7b1f2b125dad5de85f049136651bff256c883c65e6b9209b2da0a1ac3cdef", size = 536029, upload-time = "2026-09-29T00:53:23.07Z" }, + { url = "https://files.pythonhosted.org/packages/23/9d/5bb6d38853382986dca702fc7e06c8256d30f5fa0676d882773b744610dc/librt-0.16.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:a8afb6557920860b7a3a596eb804cf37e09e7cf8a803db2478c202acc72d8c2e", size = 573748, upload-time = "2026-09-29T00:53:24.696Z" }, + { url = "https://files.pythonhosted.org/packages/99/f6/0025cde35ff7f607684dc775a2b2d732cce2561cec050a6ee1fb2e1fc6fe/librt-0.16.0-cp313-cp313-pyemscripten_2025_0_wasm32.whl", hash = "sha256:77c7a2b4fe2c1369e0d5aa1cade26740a7b14be32fbc9a5535d617d20065c39d", size = 79861, upload-time = "2026-09-29T00:53:26.089Z" }, + { url = "https://files.pythonhosted.org/packages/93/93/303b8592909bd583f83f02818ffbea3f7647ca1e22b1cd5465d04b8145fe/librt-0.16.0-cp313-cp313-win32.whl", hash = "sha256:02d89c813d5ff74b17df72d3a34819d132cd168e56b81bf755b809bd9e46b8c4", size = 106236, upload-time = "2026-09-29T00:53:27.43Z" }, + { url = "https://files.pythonhosted.org/packages/cf/24/80bbb463c60ed18e29cb26aba386ddb76609580e4e7160710e550587018c/librt-0.16.0-cp313-cp313-win_amd64.whl", hash = "sha256:14ed6ebe3e4f85f326d7920011ad30ff49ed9334e62cf88caef9ba973d9e3a92", size = 126180, upload-time = "2026-09-29T00:53:28.7Z" }, + { url = "https://files.pythonhosted.org/packages/43/80/b1a6fbdd7da825cdd55c71aa81eb6cfa82c513c360774152eacb50b4a771/librt-0.16.0-cp313-cp313-win_arm64.whl", hash = "sha256:83d4041a3d9b2fd053a8a4e1f22878b3e5833e2712956382d5c048d791454e91", size = 116557, upload-time = "2026-09-29T00:53:30.012Z" }, + { url = "https://files.pythonhosted.org/packages/1e/93/9e0cf7da129a93c3dc7f45bc3cd4a660f2aaa995aa8a6f95c2583ef41239/librt-0.16.0-cp314-cp314-macosx_10_15_x86_64.whl", hash = "sha256:931a0bb0fcac88f263e269e46eb30ba8e21402cd3c62ca40cb97034c0693fab1", size = 149844, upload-time = "2026-09-29T00:53:31.391Z" }, + { url = "https://files.pythonhosted.org/packages/8f/26/8a90d2a8f2b2e471bb486b7aec117b8ae622715ed6c39853aec48ea20073/librt-0.16.0-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:1bc17e54e5305f8d40b7ca203671ff5a9e59c1d0f8ea0f625dcca53a3984de11", size = 154111, upload-time = "2026-09-29T00:53:32.718Z" }, + { url = "https://files.pythonhosted.org/packages/35/ce/67abb46258da4d3e42ff5b141db6f38c59357bef84c7979f183b22f924f1/librt-0.16.0-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:877698bf6bca5721d8be345f2fe09778e40ecadea8b58c73075f2b1a53666bf2", size = 494234, upload-time = "2026-09-29T00:53:34.466Z" }, + { url = "https://files.pythonhosted.org/packages/12/f9/ea7162414a16f8f1bbd3b493ad6d22b926c5471916e078350bdbca8c4e5f/librt-0.16.0-cp314-cp314-manylinux2014_i686.manylinux_2_17_i686.manylinux_2_28_i686.whl", hash = "sha256:5981c011b306781ce561e18e14230a14524a3d8109b97553666c942c18f31a96", size = 491173, upload-time = "2026-09-29T00:53:36.124Z" }, + { url = "https://files.pythonhosted.org/packages/b1/09/9b3e869060dd33f9989b80ba4fea306f6db8cecefcdfe6d7346ef0603f65/librt-0.16.0-cp314-cp314-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:afced3dfc17cd805ecf7a3d77996a71cf5f2c75aa66eb0c21a9930f4fc992f86", size = 505547, upload-time = "2026-09-29T00:53:37.686Z" }, + { url = "https://files.pythonhosted.org/packages/50/07/79007d2165f649ea93e08c0962d1d62c70af9cde77965255095bf9d96f9a/librt-0.16.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:ca8052401c55d7511dda6760719fda7618067e83535d7d0010096d216c34b667", size = 523057, upload-time = "2026-09-29T00:53:39.301Z" }, + { url = "https://files.pythonhosted.org/packages/61/0c/8fbaff66d0ba376d8864653f5acce1569bae27e89648671f26f7eca67ab8/librt-0.16.0-cp314-cp314-manylinux_2_34_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:1e511762a074005bb0aa569166779834e75e438370226930d0ce1866d4b6a33b", size = 515158, upload-time = "2026-09-29T00:53:41.012Z" }, + { url = "https://files.pythonhosted.org/packages/df/2e/23ff0dece76f07a4124413a57682efa0bbeb5765ac0122bc0955513f82ca/librt-0.16.0-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:f1e8591bd8a5a628cd7f07954c6a1592359a878bf032957a8e9057a41d644311", size = 534183, upload-time = "2026-09-29T00:53:42.451Z" }, + { url = "https://files.pythonhosted.org/packages/26/c4/e11dea21d9a29486eba78887380374189d472734fa32cc50cb37ca44d3d0/librt-0.16.0-cp314-cp314-musllinux_1_2_i686.whl", hash = "sha256:a4aaefb4ba6c07e1aeebb2795c8958148f1d6f9af3b555b53d23d766edb6d67a", size = 540663, upload-time = "2026-09-29T00:53:44.272Z" }, + { url = "https://files.pythonhosted.org/packages/44/75/e873ae158a8b7f5359be33e7fd6c1fbe02d9a78a3e89a77de6b0e837f476/librt-0.16.0-cp314-cp314-musllinux_1_2_ppc64le.whl", hash = "sha256:d92db7a0f6aee44f1baee94750457e8d2d1c6ccea41842de6268d34e8dc7eddd", size = 545908, upload-time = "2026-09-29T00:53:45.812Z" }, + { url = "https://files.pythonhosted.org/packages/ba/36/8939d3f6a93e11bd9592e6fe28d2b44f1c2dc4bed6e22e72359a91e18ffb/librt-0.16.0-cp314-cp314-musllinux_1_2_riscv64.whl", hash = "sha256:378dfaffb38e59c24a87cde5713cd865d51ff7383fa12947f3907f306ea1ca55", size = 523302, upload-time = "2026-09-29T00:53:47.596Z" }, + { url = "https://files.pythonhosted.org/packages/71/14/35309f44a077f0f42ade0e2e7cd88c0cea760c661af205c01ea90d3c0e1f/librt-0.16.0-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:3e0c39bdc85370422e8b637be76eb1fd07d30967551b03e62267dd156f553152", size = 565911, upload-time = "2026-09-29T00:53:49.278Z" }, + { url = "https://files.pythonhosted.org/packages/78/0c/df6255b94967f3159ebc46f08d8e783c12da6ee269ddb74b2efed63c640c/librt-0.16.0-cp314-cp314-pyemscripten_2026_0_wasm32.whl", hash = "sha256:1b384b90ab79a7bc30b566895809a636e0666f21f3cf12b54823d025b7e83839", size = 79119, upload-time = "2026-09-29T00:53:50.938Z" }, + { url = "https://files.pythonhosted.org/packages/6b/44/d30d5a5461378c9d33f36736c6791c3b4c4ba4b1ffe0da7350aedcb2c9a0/librt-0.16.0-cp314-cp314-win32.whl", hash = "sha256:52327da75a94012e7f932f913d20d3876bed3c102be00e6c3e8600ff7bdd58a7", size = 100140, upload-time = "2026-09-29T00:53:52.205Z" }, + { url = "https://files.pythonhosted.org/packages/c2/98/769712f356a1e897df3581bb0c3100375d054a000de26099360ea65b5111/librt-0.16.0-cp314-cp314-win_amd64.whl", hash = "sha256:3f0b8114c44b2ac06ff5dacd08e07e8e807ff4f46083f2a1602685122559be41", size = 120464, upload-time = "2026-09-29T00:53:53.495Z" }, + { url = "https://files.pythonhosted.org/packages/bf/d3/ae2abccc8bdc8b063c1613a77686e17b74e9d3d60cfe6f12c63fa2821b9f/librt-0.16.0-cp314-cp314-win_arm64.whl", hash = "sha256:8caf96a4ef8fb27d0ac0d1ad8337d26a240acd4a02fe4345d0a8f264753e8f99", size = 110889, upload-time = "2026-09-29T00:53:54.817Z" }, + { url = "https://files.pythonhosted.org/packages/e4/26/0737d4be058dd6376eade7dd8b380d4b869b6394cee929393a5a431c45bb/librt-0.16.0-cp314-cp314t-macosx_10_15_x86_64.whl", hash = "sha256:953107e2f68d0f3512c48f898b0dbf0ce5cc52bba0f318d847c985dc555ee4cc", size = 159838, upload-time = "2026-09-29T00:53:56.22Z" }, + { url = "https://files.pythonhosted.org/packages/01/96/9bc96531d7c620e9949af904470f02e3fa8f35129ab8e8f281c51eaa3788/librt-0.16.0-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:ad37d5b9abd49c9a655dcda7ea52a8a752884062ef1ee71ae17c2f2a0f81fe6a", size = 162018, upload-time = "2026-09-29T00:53:57.532Z" }, + { url = "https://files.pythonhosted.org/packages/0e/fa/b0289dcb186eb3f97221ba00da5f4bd3ba7fa5e99752d48aa8d336615334/librt-0.16.0-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:2c4aa329c17bd1aaea4f6e89335d8ccd494b3a5830b6654462273e50e11023f0", size = 703983, upload-time = "2026-09-29T00:53:59.024Z" }, + { url = "https://files.pythonhosted.org/packages/d9/ab/05ebbbde7530fc5eeb58fbd1581522a9f64f132fa703c4c595eed6e14760/librt-0.16.0-cp314-cp314t-manylinux2014_i686.manylinux_2_17_i686.manylinux_2_28_i686.whl", hash = "sha256:0ead24d2562a49473dddd9efef8581f020007eb0054389c3ee3ffad38b1ca4c9", size = 683847, upload-time = "2026-09-29T00:54:00.671Z" }, + { url = "https://files.pythonhosted.org/packages/a3/75/f52aeecd4dbadbddf80725ba7de126d8bd5d0eb66247eae17a81ed90dd4d/librt-0.16.0-cp314-cp314t-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:02118f56a9c36ddd07dfd9b919d9ecc117ba20a90987d56aa4c429fa34509188", size = 698045, upload-time = "2026-09-29T00:54:02.247Z" }, + { url = "https://files.pythonhosted.org/packages/e6/55/fa277a835cd6eb42380591ceb85f48c5b4d2b2d7e2cb9869e1e17d24d237/librt-0.16.0-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:4e29522c62e28595ff7e324c6834ade51127707f0e255b18d1c1cf03d39c1048", size = 724640, upload-time = "2026-09-29T00:54:04.078Z" }, + { url = "https://files.pythonhosted.org/packages/25/e4/2cf64354f3fde8ebd591b3b48f96510bee24ac5f7d1e567adbbe210abdbd/librt-0.16.0-cp314-cp314t-manylinux_2_34_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:3ff4b2367926b69c6215635902cccb04048e73094e9862900d27cb2c6bbff143", size = 731748, upload-time = "2026-09-29T00:54:05.741Z" }, + { url = "https://files.pythonhosted.org/packages/f8/c9/c180af3e94e01aa529fa93d7733fec2abc47f222345400cf21d5481d5f8a/librt-0.16.0-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:c6f1b27bf1632a7e016af9f145f82be95e1edd7721a646505c21059257cb5a04", size = 754960, upload-time = "2026-09-29T00:54:07.38Z" }, + { url = "https://files.pythonhosted.org/packages/95/d6/01073aa78c58f356b10d9c57b3fe9abb143df338142bcd316df417b89db0/librt-0.16.0-cp314-cp314t-musllinux_1_2_i686.whl", hash = "sha256:5696d7f52e7b37217cb3a8f92c744fe835942602fdd4c1a8bc4741d3bfdce15e", size = 747000, upload-time = "2026-09-29T00:54:09.06Z" }, + { url = "https://files.pythonhosted.org/packages/f7/d8/1de3783908658d697a8cfc00582f61299ffba7796d7260c112e4700b1109/librt-0.16.0-cp314-cp314t-musllinux_1_2_ppc64le.whl", hash = "sha256:6072e92dd876ff6ceeb6cf371e35e51f479349837391341f479b08df4564242b", size = 749569, upload-time = "2026-09-29T00:54:10.702Z" }, + { url = "https://files.pythonhosted.org/packages/b7/32/e817f66c96d6caa8bb8435ff93c4c220624d59efc506be59ab98fcd01d0c/librt-0.16.0-cp314-cp314t-musllinux_1_2_riscv64.whl", hash = "sha256:39ca4f2f2fe05de8e63493da592d84311adabe5bef52b193851981da9816b302", size = 729483, upload-time = "2026-09-29T00:54:12.25Z" }, + { url = "https://files.pythonhosted.org/packages/7c/c9/23992ccd2b9d22798fdd0f61353183a47414e651da782ad83eb680f50833/librt-0.16.0-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:f9807485a908f00355820f18e91e045ffdcdc5adb68aaec40a1e2b88c5f7bba1", size = 776584, upload-time = "2026-09-29T00:54:13.837Z" }, + { url = "https://files.pythonhosted.org/packages/67/3b/e8af957f08e6e2e8e566b099e43d2748418aa565df6ee1d9d3331209fdfe/librt-0.16.0-cp314-cp314t-win32.whl", hash = "sha256:94be5cb7bca4df6201f4183e9e4fa2086c655283d20b38cd84500a69057575a7", size = 104402, upload-time = "2026-09-29T00:54:15.568Z" }, + { url = "https://files.pythonhosted.org/packages/ca/1c/946e6443d7cd32347a086043395e421e52fd603c9163d2ec970ceab8eed6/librt-0.16.0-cp314-cp314t-win_amd64.whl", hash = "sha256:d46ca272b251d033dd4527b0dec5f261a28a52bd5fa0f99c117b0a1f8588cc2d", size = 126227, upload-time = "2026-09-29T00:54:17.165Z" }, + { url = "https://files.pythonhosted.org/packages/c2/a3/bc4f9959d3c62bcbf9e5fd3470a8bbd8bf33224ed4c25d7fba173201b8ac/librt-0.16.0-cp314-cp314t-win_arm64.whl", hash = "sha256:b9d6d4b14e92d876f8026b54c20c445f36425214c1081dc76f74e40db386b82b", size = 116493, upload-time = "2026-09-29T00:54:18.567Z" }, + { url = "https://files.pythonhosted.org/packages/b6/4b/10fdb42dfab4c1533e1570e686b18e86ff4328b406361b39fb3016667638/librt-0.16.0-cp315-cp315-macosx_10_15_x86_64.whl", hash = "sha256:6fe436af2eaf630474f491af5d032cbe45f93fcff5c3b9fe4ab194a7255b20ff", size = 149829, upload-time = "2026-09-29T00:54:19.933Z" }, + { url = "https://files.pythonhosted.org/packages/8e/30/a90ca13f1d3d91af1680000a4038536907018fbd51764767287a05d28b8b/librt-0.16.0-cp315-cp315-macosx_11_0_arm64.whl", hash = "sha256:8ff5d26c529336be9bd7ae04483235d77778ee7d6444a95353102b542601ce81", size = 154522, upload-time = "2026-09-29T00:54:21.306Z" }, + { url = "https://files.pythonhosted.org/packages/5c/dd/bcf364eacfa070bb1fc88d503111ae7177914197ba1fa717c748926e7930/librt-0.16.0-cp315-cp315-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:909d8e3c1faee44cb762b1c519ff8613dcc5ceae5c99987a00917b5a31fd1d6a", size = 497593, upload-time = "2026-09-29T00:54:22.798Z" }, + { url = "https://files.pythonhosted.org/packages/18/c1/2c4e81e347bdabfe8346bfc6dc37ae5e154d61c88e30848ec0606025a5e0/librt-0.16.0-cp315-cp315-manylinux2014_i686.manylinux_2_17_i686.manylinux_2_28_i686.whl", hash = "sha256:6d4a64283ee61824b5790de882bc68e2d9d7a5143537cb7a966f7354f71646d4", size = 480459, upload-time = "2026-09-29T00:54:24.364Z" }, + { url = "https://files.pythonhosted.org/packages/ab/d7/fef2a3cb8400701be496f6e459876f650b3451f407e30cb243de571ae615/librt-0.16.0-cp315-cp315-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:5810ba811297fdf37a1531a57667cb8ace0842013ca8606bf9eb7c24cf4be154", size = 507814, upload-time = "2026-09-29T00:54:25.997Z" }, + { url = "https://files.pythonhosted.org/packages/e1/6f/53762927a32e9dc9eb1d1c1f3528da281290c86d96929a8af652f671266e/librt-0.16.0-cp315-cp315-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:e56aaf8c167548dc8e5d6f3bd0f48dcdd299a23c73be3f744aab79d99e9c7f5d", size = 525114, upload-time = "2026-09-29T00:54:27.747Z" }, + { url = "https://files.pythonhosted.org/packages/6c/67/0b9d031f303c4e8c691a9a8ef9d272f13b530c11cc563b819df621b6a348/librt-0.16.0-cp315-cp315-manylinux_2_34_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:8f36c58e33b304b525c6c9c5076399c6ebf1109e17b9051a05a407b091b9215b", size = 520465, upload-time = "2026-09-29T00:54:29.331Z" }, + { url = "https://files.pythonhosted.org/packages/ae/d5/2056a3a85864e882eb17a203a10ddb26fa748bc9718ec67e79059ab46cae/librt-0.16.0-cp315-cp315-musllinux_1_2_aarch64.whl", hash = "sha256:242e00b3d4fa37c3d3c1ca5f5c9adb7d909ddb1eac9c41f2787320d00caa0af2", size = 537257, upload-time = "2026-09-29T00:54:30.915Z" }, + { url = "https://files.pythonhosted.org/packages/54/57/e0d79790c163cbc0909e209a6f62e30bb713b647f905a176cdc64848fd4d/librt-0.16.0-cp315-cp315-musllinux_1_2_i686.whl", hash = "sha256:0253721561787b8df8443eb347b7a6461015354e5bdd37ee38a41fef220d2bb0", size = 527442, upload-time = "2026-09-29T00:54:32.478Z" }, + { url = "https://files.pythonhosted.org/packages/aa/50/1c0c95aba7af51f4752ea34fbf2eb79b36e7cae3a72536248e8c735de735/librt-0.16.0-cp315-cp315-musllinux_1_2_ppc64le.whl", hash = "sha256:3e483a8d69ede8067db70c0e83007423b6925de6fd53afed01d66160f2e9398c", size = 548139, upload-time = "2026-09-29T00:54:34.183Z" }, + { url = "https://files.pythonhosted.org/packages/98/91/a8a43dd5138d4f55f88846b8f0c85454a4fad69952cebfcff9948f831290/librt-0.16.0-cp315-cp315-musllinux_1_2_riscv64.whl", hash = "sha256:69ba927445cfaaffb4081003ef5224c55a5c2ab67ef956f416ef744916e44121", size = 529708, upload-time = "2026-09-29T00:54:35.761Z" }, + { url = "https://files.pythonhosted.org/packages/2d/41/d5226881ab2b7c20d9d587b37bdd4a0ec8775a96d00ca87ac9f385587db4/librt-0.16.0-cp315-cp315-musllinux_1_2_x86_64.whl", hash = "sha256:d6a365f2ab45a984d0e00eee0dd17f599ceab8cadab6ea07b6111c8132fc0e42", size = 567781, upload-time = "2026-09-29T00:54:37.409Z" }, + { url = "https://files.pythonhosted.org/packages/bb/bf/2345ba57a626e8c78c4ddcc724636a8df5a593fe46c1ee76bbf477e32b0d/librt-0.16.0-cp315-cp315-pyemscripten_2026_5_wasm32.whl", hash = "sha256:f01f3805f2dae4781c0c34b440e31740d082950bdaf89a6f601ad589a28af57a", size = 79177, upload-time = "2026-09-29T00:54:38.792Z" }, + { url = "https://files.pythonhosted.org/packages/1e/40/99e77936cc9207f629b077bf7cbc5e2f0827cddd7c29792f04ef881bd2c3/librt-0.16.0-cp315-cp315-win32.whl", hash = "sha256:b0e3e721c75d2e79a76d4422c79d7ba705fe1bbafec907037fe7a657a480a0e3", size = 100127, upload-time = "2026-09-29T00:54:40.251Z" }, + { url = "https://files.pythonhosted.org/packages/56/1e/801fe26bc622061b9dfd010e166d94142cb774b733217e6d98d1c0cf2638/librt-0.16.0-cp315-cp315-win_amd64.whl", hash = "sha256:bc02954b1295de798bbdb0b4e2d8a28c2117de8b5c73dcbeb27dc32572dfb971", size = 120480, upload-time = "2026-09-29T00:54:41.722Z" }, + { url = "https://files.pythonhosted.org/packages/bb/a9/d533983055bd36e112627384c2c038845d1df882540b8bcefb566475640b/librt-0.16.0-cp315-cp315-win_arm64.whl", hash = "sha256:c5db585d43449a5f54303d4b2774e45e1babd975cfe1630a3d708c0b80c3e560", size = 110915, upload-time = "2026-09-29T00:54:43.052Z" }, + { url = "https://files.pythonhosted.org/packages/55/fe/d62238fa9c653b0e0613290349467cb65711b5800e8e474f45e942a0ad95/librt-0.16.0-cp315-cp315t-macosx_10_15_x86_64.whl", hash = "sha256:f06c689cb14afd9b612727553a5ec5a40febf113ca41c4413a2b0b334285884b", size = 159714, upload-time = "2026-09-29T00:54:44.497Z" }, + { url = "https://files.pythonhosted.org/packages/f3/ac/f31efe7818700be72ba4f9af8a80fa67c39808c8d26dacc55dc1f6f35172/librt-0.16.0-cp315-cp315t-macosx_11_0_arm64.whl", hash = "sha256:13b4e8aba90b0b1c82474e9844aa9ffe7ad3faa484350e1da64cb8188d903134", size = 162086, upload-time = "2026-09-29T00:54:45.968Z" }, + { url = "https://files.pythonhosted.org/packages/d9/16/4d7487bf86a9d7e8e18f37ba5538789233ea693637379b75701bd35ec9de/librt-0.16.0-cp315-cp315t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:5a269c46ae327d8e6f8c1f85f7516cb52c0fa48127565a1105a4f4a05ff2a0b4", size = 712727, upload-time = "2026-09-29T00:54:47.486Z" }, + { url = "https://files.pythonhosted.org/packages/77/74/50cd550ccc1a517b9ed62347625c01ddf8c4afad66490312677c011458f6/librt-0.16.0-cp315-cp315t-manylinux2014_i686.manylinux_2_17_i686.manylinux_2_28_i686.whl", hash = "sha256:a33e0dae1f8592146a4764d54ce842b278732d21a84e17c3bbe6b1bc158a2248", size = 681106, upload-time = "2026-09-29T00:54:49.126Z" }, + { url = "https://files.pythonhosted.org/packages/df/5d/7293f712975ee6fdd2251411fd9ef1c62bc99c7b83ecbe62dbc999b1fab7/librt-0.16.0-cp315-cp315t-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:47ada6ea32636492c61aa8ad27ae3b9404bfe7a97e3ba946d1984236cc741da0", size = 705921, upload-time = "2026-09-29T00:54:50.905Z" }, + { url = "https://files.pythonhosted.org/packages/67/f7/8aab946f11d59d1bece9ffc65d994b200c789a8ca5a95c17e17e609f912a/librt-0.16.0-cp315-cp315t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:c43bd6e642d8a248c114327f98dd25ac5a7cb5aa168ef02f0559b91874df16b8", size = 731786, upload-time = "2026-09-29T00:54:52.584Z" }, + { url = "https://files.pythonhosted.org/packages/43/76/1c42ab31e7cb8384ebf6d3af607213c495222474f4940443ae7639ab7685/librt-0.16.0-cp315-cp315t-manylinux_2_34_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:c3d1bb7841a816ace6449bb26d3f9560dbfa20e71c568d23f0f62bf1e68f50b1", size = 744964, upload-time = "2026-09-29T00:54:54.217Z" }, + { url = "https://files.pythonhosted.org/packages/6f/2e/4b19982d933d2dfced671e840b219e4c1cd3f507df6e6dabb51bbd4e3850/librt-0.16.0-cp315-cp315t-musllinux_1_2_aarch64.whl", hash = "sha256:3931f7a3db322e7f44e02a280e3949326ce9579ad388ee8d691dc7c76da9fb70", size = 765305, upload-time = "2026-09-29T00:54:55.815Z" }, + { url = "https://files.pythonhosted.org/packages/b8/1b/e872583de2dcb3ac7746e7a2321aeeb168274f3952a87dc66e05ddb29faf/librt-0.16.0-cp315-cp315t-musllinux_1_2_i686.whl", hash = "sha256:f4462528b6000afe8f16907b5c7c2553abf1df005ba5140e6eb394541c3624c3", size = 744959, upload-time = "2026-09-29T00:54:57.532Z" }, + { url = "https://files.pythonhosted.org/packages/10/de/a18c6bcfb297af2674233e90b3c3661c3a0af0f1434a0c966d2ef708a835/librt-0.16.0-cp315-cp315t-musllinux_1_2_ppc64le.whl", hash = "sha256:80039ba9b6a7d5f1a0175a4cca6bbefead87bd854c80abad1cb30afe47a830db", size = 758138, upload-time = "2026-09-29T00:54:59.484Z" }, + { url = "https://files.pythonhosted.org/packages/22/1c/0df1d732539c297bb1a093e1fe3204d2faf76a9022cf4e1d1c2fce059790/librt-0.16.0-cp315-cp315t-musllinux_1_2_riscv64.whl", hash = "sha256:7a1d272724b581bb6bc769dfdafed6da2ecc9886ba2450311de55a4ac2e1e9cd", size = 744268, upload-time = "2026-09-29T00:55:01.179Z" }, + { url = "https://files.pythonhosted.org/packages/a2/f7/ccaf31331f20c91a5bd9bd48ffc3f743f9c81bb5720cc7b2a720ca204f0a/librt-0.16.0-cp315-cp315t-musllinux_1_2_x86_64.whl", hash = "sha256:fbe4fb8c5445f7496d7f7f6bb0807875d09d47e6771ffa175fb2df2895fb86ba", size = 785783, upload-time = "2026-09-29T00:55:02.938Z" }, + { url = "https://files.pythonhosted.org/packages/c1/ea/7421d9e6db894cd6cd788b604b3394a163ded6b942052b6f96c23ccf08e1/librt-0.16.0-cp315-cp315t-win32.whl", hash = "sha256:375bfe6b572a8f6cfc398709356046173bf27e64c4c5edaf5f7062f051fb4bf9", size = 104355, upload-time = "2026-09-29T00:55:04.533Z" }, + { url = "https://files.pythonhosted.org/packages/85/6d/7c31a506eb847bc58aeb2402d58e17605e821f68ab5df5e66fe274a6df41/librt-0.16.0-cp315-cp315t-win_amd64.whl", hash = "sha256:bd3150023d3dc2bc70f3784e59ffa1140d56ddba3d8125b3d6f9f85221279bfc", size = 126134, upload-time = "2026-09-29T00:55:06.017Z" }, + { url = "https://files.pythonhosted.org/packages/36/69/7a5d10ac409c4da0355e054a14371871da9b5557fcc42772cd00181c6cce/librt-0.16.0-cp315-cp315t-win_arm64.whl", hash = "sha256:8ceafb70f2a4f0826f11031942e59c0728fd98da112dc346d4352bde1e486866", size = 116391, upload-time = "2026-09-29T00:55:07.484Z" }, +] + [[package]] name = "livereload" version = "2.7.1" @@ -596,95 +856,295 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/e4/3e/de54dc7f199e85e6ca37e2e5dae2ec3bce2151e9e28f8eb9076d71e83d56/livereload-2.7.1-py3-none-any.whl", hash = "sha256:5201740078c1b9433f4b2ba22cd2729a39b9d0ec0a2cc6b4d3df257df5ad0564", size = 22657, upload-time = "2024-12-18T13:41:56.35Z" }, ] +[[package]] +name = "markdown" +version = "3.7" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/54/28/3af612670f82f4c056911fbbbb42760255801b3068c48de792d354ff4472/markdown-3.7.tar.gz", hash = "sha256:2ae2471477cfd02dbbf038d5d9bc226d40def84b4fe2986e49b59b6b472bbed2", size = 357086, upload-time = "2024-08-16T15:55:17.812Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/3f/08/83871f3c50fc983b88547c196d11cf8c3340e37c32d2e9d6152abe2c61f7/Markdown-3.7-py3-none-any.whl", hash = "sha256:7eb6df5690b81a1d7942992c97fad2938e956e79df20cbc6186e9c3a77b1c803", size = 106349, upload-time = "2024-08-16T15:55:16.176Z" }, +] + [[package]] name = "markupsafe" -version = "3.0.3" -source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/7e/99/7690b6d4034fffd95959cbe0c02de8deb3098cc577c67bb6a24fe5d7caa7/markupsafe-3.0.3.tar.gz", hash = "sha256:722695808f4b6457b320fdc131280796bdceb04ab50fe1795cd540799ebe1698", size = 80313, upload-time = "2025-09-27T18:37:40.426Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/e8/4b/3541d44f3937ba468b75da9eebcae497dcf67adb65caa16760b0a6807ebb/markupsafe-3.0.3-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:2f981d352f04553a7171b8e44369f2af4055f888dfb147d55e42d29e29e74559", size = 11631, upload-time = "2025-09-27T18:36:05.558Z" }, - { url = "https://files.pythonhosted.org/packages/98/1b/fbd8eed11021cabd9226c37342fa6ca4e8a98d8188a8d9b66740494960e4/markupsafe-3.0.3-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:e1c1493fb6e50ab01d20a22826e57520f1284df32f2d8601fdd90b6304601419", size = 12057, upload-time = "2025-09-27T18:36:07.165Z" }, - { url = "https://files.pythonhosted.org/packages/40/01/e560d658dc0bb8ab762670ece35281dec7b6c1b33f5fbc09ebb57a185519/markupsafe-3.0.3-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:1ba88449deb3de88bd40044603fafffb7bc2b055d626a330323a9ed736661695", size = 22050, upload-time = "2025-09-27T18:36:08.005Z" }, - { url = "https://files.pythonhosted.org/packages/af/cd/ce6e848bbf2c32314c9b237839119c5a564a59725b53157c856e90937b7a/markupsafe-3.0.3-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:f42d0984e947b8adf7dd6dde396e720934d12c506ce84eea8476409563607591", size = 20681, upload-time = "2025-09-27T18:36:08.881Z" }, - { url = "https://files.pythonhosted.org/packages/c9/2a/b5c12c809f1c3045c4d580b035a743d12fcde53cf685dbc44660826308da/markupsafe-3.0.3-cp310-cp310-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:c0c0b3ade1c0b13b936d7970b1d37a57acde9199dc2aecc4c336773e1d86049c", size = 20705, upload-time = "2025-09-27T18:36:10.131Z" }, - { url = "https://files.pythonhosted.org/packages/cf/e3/9427a68c82728d0a88c50f890d0fc072a1484de2f3ac1ad0bfc1a7214fd5/markupsafe-3.0.3-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:0303439a41979d9e74d18ff5e2dd8c43ed6c6001fd40e5bf2e43f7bd9bbc523f", size = 21524, upload-time = "2025-09-27T18:36:11.324Z" }, - { url = "https://files.pythonhosted.org/packages/bc/36/23578f29e9e582a4d0278e009b38081dbe363c5e7165113fad546918a232/markupsafe-3.0.3-cp310-cp310-musllinux_1_2_riscv64.whl", hash = "sha256:d2ee202e79d8ed691ceebae8e0486bd9a2cd4794cec4824e1c99b6f5009502f6", size = 20282, upload-time = "2025-09-27T18:36:12.573Z" }, - { url = "https://files.pythonhosted.org/packages/56/21/dca11354e756ebd03e036bd8ad58d6d7168c80ce1fe5e75218e4945cbab7/markupsafe-3.0.3-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:177b5253b2834fe3678cb4a5f0059808258584c559193998be2601324fdeafb1", size = 20745, upload-time = "2025-09-27T18:36:13.504Z" }, - { url = "https://files.pythonhosted.org/packages/87/99/faba9369a7ad6e4d10b6a5fbf71fa2a188fe4a593b15f0963b73859a1bbd/markupsafe-3.0.3-cp310-cp310-win32.whl", hash = "sha256:2a15a08b17dd94c53a1da0438822d70ebcd13f8c3a95abe3a9ef9f11a94830aa", size = 14571, upload-time = "2025-09-27T18:36:14.779Z" }, - { url = "https://files.pythonhosted.org/packages/d6/25/55dc3ab959917602c96985cb1253efaa4ff42f71194bddeb61eb7278b8be/markupsafe-3.0.3-cp310-cp310-win_amd64.whl", hash = "sha256:c4ffb7ebf07cfe8931028e3e4c85f0357459a3f9f9490886198848f4fa002ec8", size = 15056, upload-time = "2025-09-27T18:36:16.125Z" }, - { url = "https://files.pythonhosted.org/packages/d0/9e/0a02226640c255d1da0b8d12e24ac2aa6734da68bff14c05dd53b94a0fc3/markupsafe-3.0.3-cp310-cp310-win_arm64.whl", hash = "sha256:e2103a929dfa2fcaf9bb4e7c091983a49c9ac3b19c9061b6d5427dd7d14d81a1", size = 13932, upload-time = "2025-09-27T18:36:17.311Z" }, - { url = "https://files.pythonhosted.org/packages/08/db/fefacb2136439fc8dd20e797950e749aa1f4997ed584c62cfb8ef7c2be0e/markupsafe-3.0.3-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:1cc7ea17a6824959616c525620e387f6dd30fec8cb44f649e31712db02123dad", size = 11631, upload-time = "2025-09-27T18:36:18.185Z" }, - { url = "https://files.pythonhosted.org/packages/e1/2e/5898933336b61975ce9dc04decbc0a7f2fee78c30353c5efba7f2d6ff27a/markupsafe-3.0.3-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:4bd4cd07944443f5a265608cc6aab442e4f74dff8088b0dfc8238647b8f6ae9a", size = 12058, upload-time = "2025-09-27T18:36:19.444Z" }, - { url = "https://files.pythonhosted.org/packages/1d/09/adf2df3699d87d1d8184038df46a9c80d78c0148492323f4693df54e17bb/markupsafe-3.0.3-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:6b5420a1d9450023228968e7e6a9ce57f65d148ab56d2313fcd589eee96a7a50", size = 24287, upload-time = "2025-09-27T18:36:20.768Z" }, - { url = "https://files.pythonhosted.org/packages/30/ac/0273f6fcb5f42e314c6d8cd99effae6a5354604d461b8d392b5ec9530a54/markupsafe-3.0.3-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:0bf2a864d67e76e5c9a34dc26ec616a66b9888e25e7b9460e1c76d3293bd9dbf", size = 22940, upload-time = "2025-09-27T18:36:22.249Z" }, - { url = "https://files.pythonhosted.org/packages/19/ae/31c1be199ef767124c042c6c3e904da327a2f7f0cd63a0337e1eca2967a8/markupsafe-3.0.3-cp311-cp311-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:bc51efed119bc9cfdf792cdeaa4d67e8f6fcccab66ed4bfdd6bde3e59bfcbb2f", size = 21887, upload-time = "2025-09-27T18:36:23.535Z" }, - { url = "https://files.pythonhosted.org/packages/b2/76/7edcab99d5349a4532a459e1fe64f0b0467a3365056ae550d3bcf3f79e1e/markupsafe-3.0.3-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:068f375c472b3e7acbe2d5318dea141359e6900156b5b2ba06a30b169086b91a", size = 23692, upload-time = "2025-09-27T18:36:24.823Z" }, - { url = "https://files.pythonhosted.org/packages/a4/28/6e74cdd26d7514849143d69f0bf2399f929c37dc2b31e6829fd2045b2765/markupsafe-3.0.3-cp311-cp311-musllinux_1_2_riscv64.whl", hash = "sha256:7be7b61bb172e1ed687f1754f8e7484f1c8019780f6f6b0786e76bb01c2ae115", size = 21471, upload-time = "2025-09-27T18:36:25.95Z" }, - { url = "https://files.pythonhosted.org/packages/62/7e/a145f36a5c2945673e590850a6f8014318d5577ed7e5920a4b3448e0865d/markupsafe-3.0.3-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:f9e130248f4462aaa8e2552d547f36ddadbeaa573879158d721bbd33dfe4743a", size = 22923, upload-time = "2025-09-27T18:36:27.109Z" }, - { url = "https://files.pythonhosted.org/packages/0f/62/d9c46a7f5c9adbeeeda52f5b8d802e1094e9717705a645efc71b0913a0a8/markupsafe-3.0.3-cp311-cp311-win32.whl", hash = "sha256:0db14f5dafddbb6d9208827849fad01f1a2609380add406671a26386cdf15a19", size = 14572, upload-time = "2025-09-27T18:36:28.045Z" }, - { url = "https://files.pythonhosted.org/packages/83/8a/4414c03d3f891739326e1783338e48fb49781cc915b2e0ee052aa490d586/markupsafe-3.0.3-cp311-cp311-win_amd64.whl", hash = "sha256:de8a88e63464af587c950061a5e6a67d3632e36df62b986892331d4620a35c01", size = 15077, upload-time = "2025-09-27T18:36:29.025Z" }, - { url = "https://files.pythonhosted.org/packages/35/73/893072b42e6862f319b5207adc9ae06070f095b358655f077f69a35601f0/markupsafe-3.0.3-cp311-cp311-win_arm64.whl", hash = "sha256:3b562dd9e9ea93f13d53989d23a7e775fdfd1066c33494ff43f5418bc8c58a5c", size = 13876, upload-time = "2025-09-27T18:36:29.954Z" }, - { url = "https://files.pythonhosted.org/packages/5a/72/147da192e38635ada20e0a2e1a51cf8823d2119ce8883f7053879c2199b5/markupsafe-3.0.3-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:d53197da72cc091b024dd97249dfc7794d6a56530370992a5e1a08983ad9230e", size = 11615, upload-time = "2025-09-27T18:36:30.854Z" }, - { url = "https://files.pythonhosted.org/packages/9a/81/7e4e08678a1f98521201c3079f77db69fb552acd56067661f8c2f534a718/markupsafe-3.0.3-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:1872df69a4de6aead3491198eaf13810b565bdbeec3ae2dc8780f14458ec73ce", size = 12020, upload-time = "2025-09-27T18:36:31.971Z" }, - { url = "https://files.pythonhosted.org/packages/1e/2c/799f4742efc39633a1b54a92eec4082e4f815314869865d876824c257c1e/markupsafe-3.0.3-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:3a7e8ae81ae39e62a41ec302f972ba6ae23a5c5396c8e60113e9066ef893da0d", size = 24332, upload-time = "2025-09-27T18:36:32.813Z" }, - { url = "https://files.pythonhosted.org/packages/3c/2e/8d0c2ab90a8c1d9a24f0399058ab8519a3279d1bd4289511d74e909f060e/markupsafe-3.0.3-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:d6dd0be5b5b189d31db7cda48b91d7e0a9795f31430b7f271219ab30f1d3ac9d", size = 22947, upload-time = "2025-09-27T18:36:33.86Z" }, - { url = "https://files.pythonhosted.org/packages/2c/54/887f3092a85238093a0b2154bd629c89444f395618842e8b0c41783898ea/markupsafe-3.0.3-cp312-cp312-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:94c6f0bb423f739146aec64595853541634bde58b2135f27f61c1ffd1cd4d16a", size = 21962, upload-time = "2025-09-27T18:36:35.099Z" }, - { url = "https://files.pythonhosted.org/packages/c9/2f/336b8c7b6f4a4d95e91119dc8521402461b74a485558d8f238a68312f11c/markupsafe-3.0.3-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:be8813b57049a7dc738189df53d69395eba14fb99345e0a5994914a3864c8a4b", size = 23760, upload-time = "2025-09-27T18:36:36.001Z" }, - { url = "https://files.pythonhosted.org/packages/32/43/67935f2b7e4982ffb50a4d169b724d74b62a3964bc1a9a527f5ac4f1ee2b/markupsafe-3.0.3-cp312-cp312-musllinux_1_2_riscv64.whl", hash = "sha256:83891d0e9fb81a825d9a6d61e3f07550ca70a076484292a70fde82c4b807286f", size = 21529, upload-time = "2025-09-27T18:36:36.906Z" }, - { url = "https://files.pythonhosted.org/packages/89/e0/4486f11e51bbba8b0c041098859e869e304d1c261e59244baa3d295d47b7/markupsafe-3.0.3-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:77f0643abe7495da77fb436f50f8dab76dbc6e5fd25d39589a0f1fe6548bfa2b", size = 23015, upload-time = "2025-09-27T18:36:37.868Z" }, - { url = "https://files.pythonhosted.org/packages/2f/e1/78ee7a023dac597a5825441ebd17170785a9dab23de95d2c7508ade94e0e/markupsafe-3.0.3-cp312-cp312-win32.whl", hash = "sha256:d88b440e37a16e651bda4c7c2b930eb586fd15ca7406cb39e211fcff3bf3017d", size = 14540, upload-time = "2025-09-27T18:36:38.761Z" }, - { url = "https://files.pythonhosted.org/packages/aa/5b/bec5aa9bbbb2c946ca2733ef9c4ca91c91b6a24580193e891b5f7dbe8e1e/markupsafe-3.0.3-cp312-cp312-win_amd64.whl", hash = "sha256:26a5784ded40c9e318cfc2bdb30fe164bdb8665ded9cd64d500a34fb42067b1c", size = 15105, upload-time = "2025-09-27T18:36:39.701Z" }, - { url = "https://files.pythonhosted.org/packages/e5/f1/216fc1bbfd74011693a4fd837e7026152e89c4bcf3e77b6692fba9923123/markupsafe-3.0.3-cp312-cp312-win_arm64.whl", hash = "sha256:35add3b638a5d900e807944a078b51922212fb3dedb01633a8defc4b01a3c85f", size = 13906, upload-time = "2025-09-27T18:36:40.689Z" }, - { url = "https://files.pythonhosted.org/packages/38/2f/907b9c7bbba283e68f20259574b13d005c121a0fa4c175f9bed27c4597ff/markupsafe-3.0.3-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:e1cf1972137e83c5d4c136c43ced9ac51d0e124706ee1c8aa8532c1287fa8795", size = 11622, upload-time = "2025-09-27T18:36:41.777Z" }, - { url = "https://files.pythonhosted.org/packages/9c/d9/5f7756922cdd676869eca1c4e3c0cd0df60ed30199ffd775e319089cb3ed/markupsafe-3.0.3-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:116bb52f642a37c115f517494ea5feb03889e04df47eeff5b130b1808ce7c219", size = 12029, upload-time = "2025-09-27T18:36:43.257Z" }, - { url = "https://files.pythonhosted.org/packages/00/07/575a68c754943058c78f30db02ee03a64b3c638586fba6a6dd56830b30a3/markupsafe-3.0.3-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:133a43e73a802c5562be9bbcd03d090aa5a1fe899db609c29e8c8d815c5f6de6", size = 24374, upload-time = "2025-09-27T18:36:44.508Z" }, - { url = "https://files.pythonhosted.org/packages/a9/21/9b05698b46f218fc0e118e1f8168395c65c8a2c750ae2bab54fc4bd4e0e8/markupsafe-3.0.3-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:ccfcd093f13f0f0b7fdd0f198b90053bf7b2f02a3927a30e63f3ccc9df56b676", size = 22980, upload-time = "2025-09-27T18:36:45.385Z" }, - { url = "https://files.pythonhosted.org/packages/7f/71/544260864f893f18b6827315b988c146b559391e6e7e8f7252839b1b846a/markupsafe-3.0.3-cp313-cp313-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:509fa21c6deb7a7a273d629cf5ec029bc209d1a51178615ddf718f5918992ab9", size = 21990, upload-time = "2025-09-27T18:36:46.916Z" }, - { url = "https://files.pythonhosted.org/packages/c2/28/b50fc2f74d1ad761af2f5dcce7492648b983d00a65b8c0e0cb457c82ebbe/markupsafe-3.0.3-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:a4afe79fb3de0b7097d81da19090f4df4f8d3a2b3adaa8764138aac2e44f3af1", size = 23784, upload-time = "2025-09-27T18:36:47.884Z" }, - { url = "https://files.pythonhosted.org/packages/ed/76/104b2aa106a208da8b17a2fb72e033a5a9d7073c68f7e508b94916ed47a9/markupsafe-3.0.3-cp313-cp313-musllinux_1_2_riscv64.whl", hash = "sha256:795e7751525cae078558e679d646ae45574b47ed6e7771863fcc079a6171a0fc", size = 21588, upload-time = "2025-09-27T18:36:48.82Z" }, - { url = "https://files.pythonhosted.org/packages/b5/99/16a5eb2d140087ebd97180d95249b00a03aa87e29cc224056274f2e45fd6/markupsafe-3.0.3-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:8485f406a96febb5140bfeca44a73e3ce5116b2501ac54fe953e488fb1d03b12", size = 23041, upload-time = "2025-09-27T18:36:49.797Z" }, - { url = "https://files.pythonhosted.org/packages/19/bc/e7140ed90c5d61d77cea142eed9f9c303f4c4806f60a1044c13e3f1471d0/markupsafe-3.0.3-cp313-cp313-win32.whl", hash = "sha256:bdd37121970bfd8be76c5fb069c7751683bdf373db1ed6c010162b2a130248ed", size = 14543, upload-time = "2025-09-27T18:36:51.584Z" }, - { url = "https://files.pythonhosted.org/packages/05/73/c4abe620b841b6b791f2edc248f556900667a5a1cf023a6646967ae98335/markupsafe-3.0.3-cp313-cp313-win_amd64.whl", hash = "sha256:9a1abfdc021a164803f4d485104931fb8f8c1efd55bc6b748d2f5774e78b62c5", size = 15113, upload-time = "2025-09-27T18:36:52.537Z" }, - { url = "https://files.pythonhosted.org/packages/f0/3a/fa34a0f7cfef23cf9500d68cb7c32dd64ffd58a12b09225fb03dd37d5b80/markupsafe-3.0.3-cp313-cp313-win_arm64.whl", hash = "sha256:7e68f88e5b8799aa49c85cd116c932a1ac15caaa3f5db09087854d218359e485", size = 13911, upload-time = "2025-09-27T18:36:53.513Z" }, - { url = "https://files.pythonhosted.org/packages/e4/d7/e05cd7efe43a88a17a37b3ae96e79a19e846f3f456fe79c57ca61356ef01/markupsafe-3.0.3-cp313-cp313t-macosx_10_13_x86_64.whl", hash = "sha256:218551f6df4868a8d527e3062d0fb968682fe92054e89978594c28e642c43a73", size = 11658, upload-time = "2025-09-27T18:36:54.819Z" }, - { url = "https://files.pythonhosted.org/packages/99/9e/e412117548182ce2148bdeacdda3bb494260c0b0184360fe0d56389b523b/markupsafe-3.0.3-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:3524b778fe5cfb3452a09d31e7b5adefeea8c5be1d43c4f810ba09f2ceb29d37", size = 12066, upload-time = "2025-09-27T18:36:55.714Z" }, - { url = "https://files.pythonhosted.org/packages/bc/e6/fa0ffcda717ef64a5108eaa7b4f5ed28d56122c9a6d70ab8b72f9f715c80/markupsafe-3.0.3-cp313-cp313t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:4e885a3d1efa2eadc93c894a21770e4bc67899e3543680313b09f139e149ab19", size = 25639, upload-time = "2025-09-27T18:36:56.908Z" }, - { url = "https://files.pythonhosted.org/packages/96/ec/2102e881fe9d25fc16cb4b25d5f5cde50970967ffa5dddafdb771237062d/markupsafe-3.0.3-cp313-cp313t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:8709b08f4a89aa7586de0aadc8da56180242ee0ada3999749b183aa23df95025", size = 23569, upload-time = "2025-09-27T18:36:57.913Z" }, - { url = "https://files.pythonhosted.org/packages/4b/30/6f2fce1f1f205fc9323255b216ca8a235b15860c34b6798f810f05828e32/markupsafe-3.0.3-cp313-cp313t-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:b8512a91625c9b3da6f127803b166b629725e68af71f8184ae7e7d54686a56d6", size = 23284, upload-time = "2025-09-27T18:36:58.833Z" }, - { url = "https://files.pythonhosted.org/packages/58/47/4a0ccea4ab9f5dcb6f79c0236d954acb382202721e704223a8aafa38b5c8/markupsafe-3.0.3-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:9b79b7a16f7fedff2495d684f2b59b0457c3b493778c9eed31111be64d58279f", size = 24801, upload-time = "2025-09-27T18:36:59.739Z" }, - { url = "https://files.pythonhosted.org/packages/6a/70/3780e9b72180b6fecb83a4814d84c3bf4b4ae4bf0b19c27196104149734c/markupsafe-3.0.3-cp313-cp313t-musllinux_1_2_riscv64.whl", hash = "sha256:12c63dfb4a98206f045aa9563db46507995f7ef6d83b2f68eda65c307c6829eb", size = 22769, upload-time = "2025-09-27T18:37:00.719Z" }, - { url = "https://files.pythonhosted.org/packages/98/c5/c03c7f4125180fc215220c035beac6b9cb684bc7a067c84fc69414d315f5/markupsafe-3.0.3-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:8f71bc33915be5186016f675cd83a1e08523649b0e33efdb898db577ef5bb009", size = 23642, upload-time = "2025-09-27T18:37:01.673Z" }, - { url = "https://files.pythonhosted.org/packages/80/d6/2d1b89f6ca4bff1036499b1e29a1d02d282259f3681540e16563f27ebc23/markupsafe-3.0.3-cp313-cp313t-win32.whl", hash = "sha256:69c0b73548bc525c8cb9a251cddf1931d1db4d2258e9599c28c07ef3580ef354", size = 14612, upload-time = "2025-09-27T18:37:02.639Z" }, - { url = "https://files.pythonhosted.org/packages/2b/98/e48a4bfba0a0ffcf9925fe2d69240bfaa19c6f7507b8cd09c70684a53c1e/markupsafe-3.0.3-cp313-cp313t-win_amd64.whl", hash = "sha256:1b4b79e8ebf6b55351f0d91fe80f893b4743f104bff22e90697db1590e47a218", size = 15200, upload-time = "2025-09-27T18:37:03.582Z" }, - { url = "https://files.pythonhosted.org/packages/0e/72/e3cc540f351f316e9ed0f092757459afbc595824ca724cbc5a5d4263713f/markupsafe-3.0.3-cp313-cp313t-win_arm64.whl", hash = "sha256:ad2cf8aa28b8c020ab2fc8287b0f823d0a7d8630784c31e9ee5edea20f406287", size = 13973, upload-time = "2025-09-27T18:37:04.929Z" }, - { url = "https://files.pythonhosted.org/packages/33/8a/8e42d4838cd89b7dde187011e97fe6c3af66d8c044997d2183fbd6d31352/markupsafe-3.0.3-cp314-cp314-macosx_10_13_x86_64.whl", hash = "sha256:eaa9599de571d72e2daf60164784109f19978b327a3910d3e9de8c97b5b70cfe", size = 11619, upload-time = "2025-09-27T18:37:06.342Z" }, - { url = "https://files.pythonhosted.org/packages/b5/64/7660f8a4a8e53c924d0fa05dc3a55c9cee10bbd82b11c5afb27d44b096ce/markupsafe-3.0.3-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:c47a551199eb8eb2121d4f0f15ae0f923d31350ab9280078d1e5f12b249e0026", size = 12029, upload-time = "2025-09-27T18:37:07.213Z" }, - { url = "https://files.pythonhosted.org/packages/da/ef/e648bfd021127bef5fa12e1720ffed0c6cbb8310c8d9bea7266337ff06de/markupsafe-3.0.3-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:f34c41761022dd093b4b6896d4810782ffbabe30f2d443ff5f083e0cbbb8c737", size = 24408, upload-time = "2025-09-27T18:37:09.572Z" }, - { url = "https://files.pythonhosted.org/packages/41/3c/a36c2450754618e62008bf7435ccb0f88053e07592e6028a34776213d877/markupsafe-3.0.3-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:457a69a9577064c05a97c41f4e65148652db078a3a509039e64d3467b9e7ef97", size = 23005, upload-time = "2025-09-27T18:37:10.58Z" }, - { url = "https://files.pythonhosted.org/packages/bc/20/b7fdf89a8456b099837cd1dc21974632a02a999ec9bf7ca3e490aacd98e7/markupsafe-3.0.3-cp314-cp314-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:e8afc3f2ccfa24215f8cb28dcf43f0113ac3c37c2f0f0806d8c70e4228c5cf4d", size = 22048, upload-time = "2025-09-27T18:37:11.547Z" }, - { url = "https://files.pythonhosted.org/packages/9a/a7/591f592afdc734f47db08a75793a55d7fbcc6902a723ae4cfbab61010cc5/markupsafe-3.0.3-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:ec15a59cf5af7be74194f7ab02d0f59a62bdcf1a537677ce67a2537c9b87fcda", size = 23821, upload-time = "2025-09-27T18:37:12.48Z" }, - { url = "https://files.pythonhosted.org/packages/7d/33/45b24e4f44195b26521bc6f1a82197118f74df348556594bd2262bda1038/markupsafe-3.0.3-cp314-cp314-musllinux_1_2_riscv64.whl", hash = "sha256:0eb9ff8191e8498cca014656ae6b8d61f39da5f95b488805da4bb029cccbfbaf", size = 21606, upload-time = "2025-09-27T18:37:13.485Z" }, - { url = "https://files.pythonhosted.org/packages/ff/0e/53dfaca23a69fbfbbf17a4b64072090e70717344c52eaaaa9c5ddff1e5f0/markupsafe-3.0.3-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:2713baf880df847f2bece4230d4d094280f4e67b1e813eec43b4c0e144a34ffe", size = 23043, upload-time = "2025-09-27T18:37:14.408Z" }, - { url = "https://files.pythonhosted.org/packages/46/11/f333a06fc16236d5238bfe74daccbca41459dcd8d1fa952e8fbd5dccfb70/markupsafe-3.0.3-cp314-cp314-win32.whl", hash = "sha256:729586769a26dbceff69f7a7dbbf59ab6572b99d94576a5592625d5b411576b9", size = 14747, upload-time = "2025-09-27T18:37:15.36Z" }, - { url = "https://files.pythonhosted.org/packages/28/52/182836104b33b444e400b14f797212f720cbc9ed6ba34c800639d154e821/markupsafe-3.0.3-cp314-cp314-win_amd64.whl", hash = "sha256:bdc919ead48f234740ad807933cdf545180bfbe9342c2bb451556db2ed958581", size = 15341, upload-time = "2025-09-27T18:37:16.496Z" }, - { url = "https://files.pythonhosted.org/packages/6f/18/acf23e91bd94fd7b3031558b1f013adfa21a8e407a3fdb32745538730382/markupsafe-3.0.3-cp314-cp314-win_arm64.whl", hash = "sha256:5a7d5dc5140555cf21a6fefbdbf8723f06fcd2f63ef108f2854de715e4422cb4", size = 14073, upload-time = "2025-09-27T18:37:17.476Z" }, - { url = "https://files.pythonhosted.org/packages/3c/f0/57689aa4076e1b43b15fdfa646b04653969d50cf30c32a102762be2485da/markupsafe-3.0.3-cp314-cp314t-macosx_10_13_x86_64.whl", hash = "sha256:1353ef0c1b138e1907ae78e2f6c63ff67501122006b0f9abad68fda5f4ffc6ab", size = 11661, upload-time = "2025-09-27T18:37:18.453Z" }, - { url = "https://files.pythonhosted.org/packages/89/c3/2e67a7ca217c6912985ec766c6393b636fb0c2344443ff9d91404dc4c79f/markupsafe-3.0.3-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:1085e7fbddd3be5f89cc898938f42c0b3c711fdcb37d75221de2666af647c175", size = 12069, upload-time = "2025-09-27T18:37:19.332Z" }, - { url = "https://files.pythonhosted.org/packages/f0/00/be561dce4e6ca66b15276e184ce4b8aec61fe83662cce2f7d72bd3249d28/markupsafe-3.0.3-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:1b52b4fb9df4eb9ae465f8d0c228a00624de2334f216f178a995ccdcf82c4634", size = 25670, upload-time = "2025-09-27T18:37:20.245Z" }, - { url = "https://files.pythonhosted.org/packages/50/09/c419f6f5a92e5fadde27efd190eca90f05e1261b10dbd8cbcb39cd8ea1dc/markupsafe-3.0.3-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:fed51ac40f757d41b7c48425901843666a6677e3e8eb0abcff09e4ba6e664f50", size = 23598, upload-time = "2025-09-27T18:37:21.177Z" }, - { url = "https://files.pythonhosted.org/packages/22/44/a0681611106e0b2921b3033fc19bc53323e0b50bc70cffdd19f7d679bb66/markupsafe-3.0.3-cp314-cp314t-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:f190daf01f13c72eac4efd5c430a8de82489d9cff23c364c3ea822545032993e", size = 23261, upload-time = "2025-09-27T18:37:22.167Z" }, - { url = "https://files.pythonhosted.org/packages/5f/57/1b0b3f100259dc9fffe780cfb60d4be71375510e435efec3d116b6436d43/markupsafe-3.0.3-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:e56b7d45a839a697b5eb268c82a71bd8c7f6c94d6fd50c3d577fa39a9f1409f5", size = 24835, upload-time = "2025-09-27T18:37:23.296Z" }, - { url = "https://files.pythonhosted.org/packages/26/6a/4bf6d0c97c4920f1597cc14dd720705eca0bf7c787aebc6bb4d1bead5388/markupsafe-3.0.3-cp314-cp314t-musllinux_1_2_riscv64.whl", hash = "sha256:f3e98bb3798ead92273dc0e5fd0f31ade220f59a266ffd8a4f6065e0a3ce0523", size = 22733, upload-time = "2025-09-27T18:37:24.237Z" }, - { url = "https://files.pythonhosted.org/packages/14/c7/ca723101509b518797fedc2fdf79ba57f886b4aca8a7d31857ba3ee8281f/markupsafe-3.0.3-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:5678211cb9333a6468fb8d8be0305520aa073f50d17f089b5b4b477ea6e67fdc", size = 23672, upload-time = "2025-09-27T18:37:25.271Z" }, - { url = "https://files.pythonhosted.org/packages/fb/df/5bd7a48c256faecd1d36edc13133e51397e41b73bb77e1a69deab746ebac/markupsafe-3.0.3-cp314-cp314t-win32.whl", hash = "sha256:915c04ba3851909ce68ccc2b8e2cd691618c4dc4c4232fb7982bca3f41fd8c3d", size = 14819, upload-time = "2025-09-27T18:37:26.285Z" }, - { url = "https://files.pythonhosted.org/packages/1a/8a/0402ba61a2f16038b48b39bccca271134be00c5c9f0f623208399333c448/markupsafe-3.0.3-cp314-cp314t-win_amd64.whl", hash = "sha256:4faffd047e07c38848ce017e8725090413cd80cbc23d86e55c587bf979e579c9", size = 15426, upload-time = "2025-09-27T18:37:27.316Z" }, - { url = "https://files.pythonhosted.org/packages/70/bc/6f1c2f612465f5fa89b95bead1f44dcb607670fd42891d8fdcd5d039f4f4/markupsafe-3.0.3-cp314-cp314t-win_arm64.whl", hash = "sha256:32001d6a8fc98c8cb5c947787c5d08b0a50663d139f1305bac5885d98d9b40fa", size = 14146, upload-time = "2025-09-27T18:37:28.327Z" }, +version = "3.0.4" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/38/9b/e422a865e1d5d57d0e509b4e0bf1c1a70a7f6382c29a5aa428df994c8bc8/markupsafe-3.0.4.tar.gz", hash = "sha256:2e9ad7dd851bf45fab9f75cbff4cb493fee9979e8d8c7c9c3ee119022518edd6", size = 153777, upload-time = "2026-10-02T23:07:22.29Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/41/aa/9a65962e364bf19745f6bec7bde398fb1f5ca53ad2e734258e6198cc32ba/markupsafe-3.0.4-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:dd8ea6ebee7aedbf7c749fa80521d9ccf1ba473e0d1e14805caafbaad281c889", size = 11521, upload-time = "2026-10-02T23:04:20.141Z" }, + { url = "https://files.pythonhosted.org/packages/14/36/927999a34b7d1def6957de89153d327fedc4030061940b5a468584e6c5a8/markupsafe-3.0.4-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:dff05cb7016dff1e9fd68f4122c127b65dfc59de5306cfb7ad92f956f230bee2", size = 12066, upload-time = "2026-10-02T23:04:21.275Z" }, + { url = "https://files.pythonhosted.org/packages/17/54/69e7b0db9bd687bfd83451eed5666384d67cfed3be062bfc59a06a15474e/markupsafe-3.0.4-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:cf63c214fe879a65e69a386f915e36104fc84254ab141240f8854602d8e0be2a", size = 22081, upload-time = "2026-10-02T23:04:22.221Z" }, + { url = "https://files.pythonhosted.org/packages/bd/14/f6f5c97903f7d2db76bbfaced31509a47d360a103b3aaf4849f6536591ec/markupsafe-3.0.4-cp310-cp310-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:2a6ef68ae94aed8721934072b27a3b654ea2100b97e4ab864cf1489c90926fbc", size = 26079, upload-time = "2026-10-02T23:04:23.346Z" }, + { url = "https://files.pythonhosted.org/packages/d0/04/c3cc9b75f94f8b54d7e503c44cebd4b4a115ec1d6f1b996b999807daba99/markupsafe-3.0.4-cp310-cp310-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:fd9f8797427910198f95bced71ddfed61130d7e349213bfb8466c9c99e2c46a8", size = 22611, upload-time = "2026-10-02T23:04:24.401Z" }, + { url = "https://files.pythonhosted.org/packages/00/26/c4708ed3b0f08e8e6d7cbce3314ac130cb5352d1f62951b6fef7878f2b1e/markupsafe-3.0.4-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:d1aca03ede943eb80ab3d63bb082c84b7aab85ea83bd0fd0c200260945fb49d9", size = 20712, upload-time = "2026-10-02T23:04:25.386Z" }, + { url = "https://files.pythonhosted.org/packages/d9/b9/f3894d6aae3d7a52c9363317f4baf2fcadc052163d6dbc871266e32639ed/markupsafe-3.0.4-cp310-cp310-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:0764a13d34cae40db7bbf3a09b7e9b491bf4603e20b263a7a9d6b8e324975d0a", size = 20742, upload-time = "2026-10-02T23:04:26.403Z" }, + { url = "https://files.pythonhosted.org/packages/59/7c/8e248ddbfe286ab6bddb462bdac0851cbb1510d2cbbb815a415fcb0511af/markupsafe-3.0.4-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:9388003072b95f2f1e3fd908604194d653ba21330d811961a78b7da1a77e9e36", size = 21560, upload-time = "2026-10-02T23:04:27.522Z" }, + { url = "https://files.pythonhosted.org/packages/df/26/2353fef7d4bcf2b18e16bad81979fcecff2915156ca6882447917205b8e2/markupsafe-3.0.4-cp310-cp310-musllinux_1_2_armv7l.whl", hash = "sha256:8698d70a8081ee8c090dbb394768b5789a1da8b131b5499f89d071dd3cfaf6be", size = 20973, upload-time = "2026-10-02T23:04:28.573Z" }, + { url = "https://files.pythonhosted.org/packages/67/6f/a9561d98d9a6ee3494b0b970a1c766e58bab128cc84841d56ec009456dbd/markupsafe-3.0.4-cp310-cp310-musllinux_1_2_ppc64le.whl", hash = "sha256:bf053da3c97a4bc5ecfbb218cdd2983febd91c617be8367d139882aa11e490aa", size = 22036, upload-time = "2026-10-02T23:04:29.568Z" }, + { url = "https://files.pythonhosted.org/packages/55/83/6217df9192eca95af3ff0cad955c9854a93fa43b288cf7411ae24713eb52/markupsafe-3.0.4-cp310-cp310-musllinux_1_2_riscv64.whl", hash = "sha256:9438a2648b2195980cb2dd8e53ed7b8df91319e2d0b70ae61a9e1d1bc8d3bec9", size = 20314, upload-time = "2026-10-02T23:04:30.881Z" }, + { url = "https://files.pythonhosted.org/packages/35/7c/9cd8081dae70e17fdab3558121fa618d459c7950c8abd8fc10fc024486d7/markupsafe-3.0.4-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:88d59b473bfb03259722600839af9bbd7fa13a2eb514beefeedb95997882f69a", size = 20780, upload-time = "2026-10-02T23:04:31.975Z" }, + { url = "https://files.pythonhosted.org/packages/44/37/c5f2f45f4d8f0c24e4af7b9dc711640c888044cbf5f7e2ba2c0bb74cbb55/markupsafe-3.0.4-cp310-cp310-win32.whl", hash = "sha256:4a540e2d3192792fc84eced57bef37851ccb2b41f73291bb17408eea77bcd278", size = 14096, upload-time = "2026-10-02T23:04:33.129Z" }, + { url = "https://files.pythonhosted.org/packages/50/50/394a1c61c9b9972cb4f76875c332af7109bd39bdad09d3a0ec5327a339dc/markupsafe-3.0.4-cp310-cp310-win_amd64.whl", hash = "sha256:5c22873ad1f0532ba40fa1727f3c0fc1bbbaab6d373d4cbe3f0dc74b2e2521c7", size = 14329, upload-time = "2026-10-02T23:04:34.168Z" }, + { url = "https://files.pythonhosted.org/packages/d1/9a/86d03d2f32ba41a57baa124a7bcb76d0a6d39b1622e9bd4d550074e8b61a/markupsafe-3.0.4-cp310-cp310-win_arm64.whl", hash = "sha256:3d23795802fc8bd72534836d64489bbf0f67c088959091bdb22e10735a5107bf", size = 14196, upload-time = "2026-10-02T23:04:35.201Z" }, + { url = "https://files.pythonhosted.org/packages/32/55/18dbb4778b30ada5ce071608503cc3edc9e14e13d868c17a6d178fc30f7a/markupsafe-3.0.4-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:9e25feb9e330b63edb0278a0acdf85e50d0cb0fbf49c3084abbe4e24ae195346", size = 11520, upload-time = "2026-10-02T23:04:36.299Z" }, + { url = "https://files.pythonhosted.org/packages/6c/14/0b05f79b4733e264a18d08fe08fa1df7347630ff32a6cb82180d9dccec55/markupsafe-3.0.4-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:7d3391b2188d18737cb2fa147028b1096236eaa7e156446c650a489fa2cadc91", size = 12063, upload-time = "2026-10-02T23:04:37.291Z" }, + { url = "https://files.pythonhosted.org/packages/ca/3a/63ba10b6c1463216b3e4df669a9f0e5a3b0c3071557d2e8229e3968c79fb/markupsafe-3.0.4-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:849dd2bb0e5e4ab2b71c7191726a4a8d5aa8a610daa584728cbee0b710ddc4ef", size = 24321, upload-time = "2026-10-02T23:04:38.262Z" }, + { url = "https://files.pythonhosted.org/packages/1a/2e/5f015261b76ad633d187ef6f388b413aedd64a8773c4df59e530a0be5525/markupsafe-3.0.4-cp311-cp311-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:befb4158af32106b9a93db8d6d1d1cbbd418c0d5aca0cabb7b1780abf0c89169", size = 28845, upload-time = "2026-10-02T23:04:39.295Z" }, + { url = "https://files.pythonhosted.org/packages/33/cf/26e594b26be40c2f1fec63ccf8a8b99d0335a5b2cbe84835c7d82a994375/markupsafe-3.0.4-cp311-cp311-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:71f88e749ea29f67f21f3b36433c1dc54c7729ed2a6d9e2da2e0d9e0d7b224eb", size = 24701, upload-time = "2026-10-02T23:04:40.348Z" }, + { url = "https://files.pythonhosted.org/packages/81/a5/a513b76c139a3915b43404324e55c0b7979ae4f0d39eb6f075b0282e90a8/markupsafe-3.0.4-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:6da83a088f8ef93b2d483a8232a4dbf4d69d3d8496b568a03c56becac43e1808", size = 22961, upload-time = "2026-10-02T23:04:41.372Z" }, + { url = "https://files.pythonhosted.org/packages/46/cf/4c66192c100b4542bcbe392ae06696b670f66927be3ac38a213234778ff9/markupsafe-3.0.4-cp311-cp311-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:8f0fac8b13d14bb06c68195f849371924ae53dd7b1c00fed24650f704383b692", size = 21920, upload-time = "2026-10-02T23:04:42.429Z" }, + { url = "https://files.pythonhosted.org/packages/cb/17/ac3662678bfbad649893117ada2ba44dc30bf56884e84f13154a792b10f1/markupsafe-3.0.4-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:4a7cdc2a420ca01058182da4253329764d4bfa055564d1eced90e6ba1e8b1d3d", size = 23726, upload-time = "2026-10-02T23:04:43.531Z" }, + { url = "https://files.pythonhosted.org/packages/f7/af/fe47cee339180a69ebca3c57fb3483d0f5cbd1e8337d1871fb1d9c1aebee/markupsafe-3.0.4-cp311-cp311-musllinux_1_2_armv7l.whl", hash = "sha256:83b3944fea42a8400edf92fd1770fb8d0d4f7de651353bd2d8525a92dba69a21", size = 22539, upload-time = "2026-10-02T23:04:44.618Z" }, + { url = "https://files.pythonhosted.org/packages/12/32/d55440ba140442800e02d799c9cb5ab597bf6ebdb1177b5ea39a11f797bd/markupsafe-3.0.4-cp311-cp311-musllinux_1_2_ppc64le.whl", hash = "sha256:8138eb83940ec7299024d92d4dee45f601b9e6c5ffde9d25f4e35e326203c707", size = 23963, upload-time = "2026-10-02T23:04:45.656Z" }, + { url = "https://files.pythonhosted.org/packages/50/9d/9c86042cb364c2ad4c971e6d1247929effd25f714cd7ee11b05e6316445b/markupsafe-3.0.4-cp311-cp311-musllinux_1_2_riscv64.whl", hash = "sha256:811d02d5122171c1941357efd8f9bf4ffe907b7f0a1a4e729a880e4be3f46e3e", size = 21506, upload-time = "2026-10-02T23:04:46.671Z" }, + { url = "https://files.pythonhosted.org/packages/75/ef/5b824f03ba40c3b3652b6272d083d2fc4fcdd440de519a3a39ba2c3e7262/markupsafe-3.0.4-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:50b5bedc9ed8a94fc8857a42ef4f84a81ea88f8d4f05dc8705fb23ee6d8dcca7", size = 22955, upload-time = "2026-10-02T23:04:47.698Z" }, + { url = "https://files.pythonhosted.org/packages/1e/e8/44cfcb5ea40e5e43cec7793ef90704ed0c475280839076c4345757eb8e59/markupsafe-3.0.4-cp311-cp311-win32.whl", hash = "sha256:2e5a7cd7fdd14fcb1ae5d7d8bf23d24fbd1daefd1fbca2580132e1ea75f098b5", size = 14094, upload-time = "2026-10-02T23:04:48.788Z" }, + { url = "https://files.pythonhosted.org/packages/91/89/f2b509f7bf79352e40117824c1070dbeafd4df67031d3fa98165a3134228/markupsafe-3.0.4-cp311-cp311-win_amd64.whl", hash = "sha256:fdb4ca07ab75ffadab4a8b135ad59cdbb3156b99310f3d565370da74a15d6bd3", size = 14328, upload-time = "2026-10-02T23:04:49.801Z" }, + { url = "https://files.pythonhosted.org/packages/2b/5a/ccf22672a0f64dc682306e288f0dabcb06c7a201f3bb6e6cbf86d9e8ad03/markupsafe-3.0.4-cp311-cp311-win_arm64.whl", hash = "sha256:569d65055d367e3dcdf30c3f41119467b73d9ee9faf332bdf40402644f5ac08e", size = 14188, upload-time = "2026-10-02T23:04:50.847Z" }, + { url = "https://files.pythonhosted.org/packages/81/09/4c59d56b8461ae8eb0d8ba34bb25b7e618547044679d58a82ef9b2479fc1/markupsafe-3.0.4-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:61631e08084be9e21a8967ec3139c7616ed7c5e9368e05c86d1b39562c8a57b6", size = 11658, upload-time = "2026-10-02T23:04:51.876Z" }, + { url = "https://files.pythonhosted.org/packages/a2/f0/d6613774d86fbf6d145751d43c59875e47a6f9f17daee0aef173bd36d90e/markupsafe-3.0.4-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:0930db9bdc62d22944e10b066448bb65dc9abe9112880c7cab8da54db4284d5f", size = 12050, upload-time = "2026-10-02T23:04:52.931Z" }, + { url = "https://files.pythonhosted.org/packages/0d/f2/8f18e0b806eb13c1f8d07d917a720831ead54253a6dec011fbc78098a6f8/markupsafe-3.0.4-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:6a45c3d514f2436064db00d7fc8778d888f0236ebfed649b53d13a59e69ad51b", size = 24363, upload-time = "2026-10-02T23:04:53.895Z" }, + { url = "https://files.pythonhosted.org/packages/60/ce/fa07dbe8a5675558fa36dea033e19995bc783de2dec5f540ccb9030b06aa/markupsafe-3.0.4-cp312-cp312-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:1e1451fab512d1bcc3dc26988ec1edb0b82c2db909132872cd9356070a6b63df", size = 28525, upload-time = "2026-10-02T23:04:54.905Z" }, + { url = "https://files.pythonhosted.org/packages/85/40/be87c01f3868ec217f8a2015089d71c22c8c5a75324822e5ed1cdd87210d/markupsafe-3.0.4-cp312-cp312-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:bd3ce56ae2cbae3ba82b683bc425cd7e48d2ed8b10f3e818186b6f5646d9271c", size = 24733, upload-time = "2026-10-02T23:04:56.229Z" }, + { url = "https://files.pythonhosted.org/packages/4f/a7/aeedb5140afa41fc74c225e9184ab96723a6e873b6ee1c9fede7283456d8/markupsafe-3.0.4-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:8e124f974786f831d6043728e38296969d3579db8896fe004682f5758e613581", size = 22985, upload-time = "2026-10-02T23:04:57.521Z" }, + { url = "https://files.pythonhosted.org/packages/c3/fc/e91352bb08c6a59da3ef0909d457bf95a5f5908fbf151b30a06d9dbcfbb4/markupsafe-3.0.4-cp312-cp312-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:c02e8f18bdedba082cef725942ac823b9b60656db07f7e265cb31618dfd00d77", size = 22001, upload-time = "2026-10-02T23:04:58.597Z" }, + { url = "https://files.pythonhosted.org/packages/5d/f8/bffee5e7d2a3deb59748a797650a48af7e672025cf641a79344a771ad106/markupsafe-3.0.4-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:9f098115c247e11d138ab83a28fa0323c77015007ea2df73ba5fd714dfefd67c", size = 23793, upload-time = "2026-10-02T23:04:59.686Z" }, + { url = "https://files.pythonhosted.org/packages/ed/59/b853d6628ecb4d658e1d637224846d5e9bb4adf4f8df97f3be9f29dce2ec/markupsafe-3.0.4-cp312-cp312-musllinux_1_2_armv7l.whl", hash = "sha256:d5f93ebbeb8032d47e349328ec8662d973d9b05a70b3c35df1f91fe419b84749", size = 22640, upload-time = "2026-10-02T23:05:00.768Z" }, + { url = "https://files.pythonhosted.org/packages/09/b2/1506df394f0f075797c418d0301498f49e43be194e3ffcb49e6fe6ccf022/markupsafe-3.0.4-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:64511c54db4e4987aef4c41923235927428729e8174c5dba488429be70a998ed", size = 24074, upload-time = "2026-10-02T23:05:01.813Z" }, + { url = "https://files.pythonhosted.org/packages/c7/81/5ed69cda630ac69ef60d06c09ba5a7f84ff66a2e28cf986fd5614ab3c6e6/markupsafe-3.0.4-cp312-cp312-musllinux_1_2_riscv64.whl", hash = "sha256:e1a622f13970d81f95d0c72f9dc090dce9085fccfa4c9f2174377ee32bd15786", size = 21563, upload-time = "2026-10-02T23:05:03.239Z" }, + { url = "https://files.pythonhosted.org/packages/0c/fe/fb1e79be0fea60aa32602ebefc9c35a82bb42b4df157285ab7dfec12341a/markupsafe-3.0.4-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:c9a7f43c0b202b334cc9184af09bb8f21d3a209e038efaf106936fb69e6b026e", size = 23048, upload-time = "2026-10-02T23:05:04.479Z" }, + { url = "https://files.pythonhosted.org/packages/c8/52/7632a53360671a9b750cdbabaf9cdd89f18b42248b8e4cb42c0b0296e459/markupsafe-3.0.4-cp312-cp312-win32.whl", hash = "sha256:f0ec3b750b59375eab5b0fb2b9254810c00a3375be6d789899f1055a1d556237", size = 14108, upload-time = "2026-10-02T23:05:05.513Z" }, + { url = "https://files.pythonhosted.org/packages/3f/bf/62495e180b7000aaf30000fff849e933f74264638057176cf46852500adc/markupsafe-3.0.4-cp312-cp312-win_amd64.whl", hash = "sha256:11935df9bf455ed0c04eb87bcd720f02b1fe5e02128a9430f23aed6f93336fc7", size = 14303, upload-time = "2026-10-02T23:05:06.538Z" }, + { url = "https://files.pythonhosted.org/packages/c5/8e/4c24208776a65878d656996945aacfbfe010d3720d1a98fc0eb8491fc03b/markupsafe-3.0.4-cp312-cp312-win_arm64.whl", hash = "sha256:a4bbd2d87dd233b9fc5812160c3d0ffbe42edc22a26ce0469f58479ede633fe9", size = 14174, upload-time = "2026-10-02T23:05:07.617Z" }, + { url = "https://files.pythonhosted.org/packages/6d/18/4bc5ba32499e87bb2b0ef5b3a9bb9c00a131fa961ddf0be548cb550f548b/markupsafe-3.0.4-cp313-cp313-android_24_arm64_v8a.whl", hash = "sha256:de8b364c423ef0a4bad9069657d617f9a5d2b2062457a89b1fa16ee199c399c1", size = 12786, upload-time = "2026-10-02T23:05:08.709Z" }, + { url = "https://files.pythonhosted.org/packages/4e/6f/17f0c099bf25f3e31e63cc19244d9f6af861a9a4ab778c203997903cfdd0/markupsafe-3.0.4-cp313-cp313-android_24_x86_64.whl", hash = "sha256:34bdde374c5932765d7dc685c4a1d191a3207852d67e8e0a9eb6ea85156181f1", size = 12510, upload-time = "2026-10-02T23:05:09.93Z" }, + { url = "https://files.pythonhosted.org/packages/11/af/1a141081b905036ee904ec4bd945e1f70b4e1b32d33c4e59e8cf1d58b247/markupsafe-3.0.4-cp313-cp313-ios_13_0_arm64_iphoneos.whl", hash = "sha256:6bd9e1788e15bfcf6a9082de42e30387e7b85d211ab21e57a939bb8cfaaf8d96", size = 11583, upload-time = "2026-10-02T23:05:10.884Z" }, + { url = "https://files.pythonhosted.org/packages/e7/0a/a89385ae590232622a03e091805cff12f24fabe6c11e0e8bae096cece81c/markupsafe-3.0.4-cp313-cp313-ios_13_0_arm64_iphonesimulator.whl", hash = "sha256:5066b244f576f91afc8ee3ba029a89f99d39c79b1853fe9d39bea9f0afbec148", size = 11801, upload-time = "2026-10-02T23:05:11.913Z" }, + { url = "https://files.pythonhosted.org/packages/ed/85/ea548dc013962eb73653124bc595635fbf9e0fa41d1f181a967ccb784dfb/markupsafe-3.0.4-cp313-cp313-ios_13_0_x86_64_iphonesimulator.whl", hash = "sha256:7a83aa6e4805df46fed18e989d3d16f86ef60cb50bbc8d9ce3a6be89165fbf6e", size = 11443, upload-time = "2026-10-02T23:05:12.887Z" }, + { url = "https://files.pythonhosted.org/packages/cc/72/15f2e5ec9cf2eb00d5cdfe968d94e4156a7bd7303832c3f3b2c403a36839/markupsafe-3.0.4-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:2d1b7d9308288661f56672b1b157d75fc536714d3638487bbea17b6318a78248", size = 11665, upload-time = "2026-10-02T23:05:13.829Z" }, + { url = "https://files.pythonhosted.org/packages/ca/e0/4030bea613677e333c8a2c901fd405055f657f9d06acba5b7357984b6ef7/markupsafe-3.0.4-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:73e77980c7207854f00fc4e71fb1626868d5740ab4012623d55c7a99ad122a72", size = 12061, upload-time = "2026-10-02T23:05:14.807Z" }, + { url = "https://files.pythonhosted.org/packages/f3/a5/28b76a7449eb702966b88bef599e2360b411fbb3afeee8fe560939be06ec/markupsafe-3.0.4-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:7018d4af1cd272e847aa5917983ab5e83e4f6579f9dbfecd4a79c0ca80b144c2", size = 24395, upload-time = "2026-10-02T23:05:15.909Z" }, + { url = "https://files.pythonhosted.org/packages/07/6c/21232811afc3a063b5e934b1ae2efda52f46154ec382f585149c020e61fe/markupsafe-3.0.4-cp313-cp313-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:c90d5b3d4e944e065a301d741b3c1d784f6bd1f503aa68b4967e32b2ba313d85", size = 27183, upload-time = "2026-10-02T23:05:16.976Z" }, + { url = "https://files.pythonhosted.org/packages/14/38/6ccdfa5b59049cb36fb80cbc80aee9cf1fc9bb77d1335ad435f2070b08cf/markupsafe-3.0.4-cp313-cp313-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:18a801868a884f216e784d7d14db2a4077143ce7610440aee2ce8f734e7cfcde", size = 24772, upload-time = "2026-10-02T23:05:18.209Z" }, + { url = "https://files.pythonhosted.org/packages/63/e0/cec6865dfe88cb48fedd4b20aed6af5158e41092adcbf3e028bcc6ec2108/markupsafe-3.0.4-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:434139499bb20b502ed3baa1f169e618f924a97e7a777fea1a49446d80106cf6", size = 23017, upload-time = "2026-10-02T23:05:19.286Z" }, + { url = "https://files.pythonhosted.org/packages/ee/76/6ed4940bb7648a9aac457c14f870cfdd5105f139a0fb1f29cd61fafa47d1/markupsafe-3.0.4-cp313-cp313-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:9e227f3dbe6bde7491cf0a9965d00b88c6b1a4a95d11480ddf88bb96d397c19f", size = 22036, upload-time = "2026-10-02T23:05:20.352Z" }, + { url = "https://files.pythonhosted.org/packages/a1/4f/ed476226d4fe46a09090a36025bf319296810028df55eb12f1253b540f3a/markupsafe-3.0.4-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:b8cd1f918b26fd7b1832ece557cc18f2d8747309ff8b3f0ef9d4250c5ad67a39", size = 23786, upload-time = "2026-10-02T23:05:21.576Z" }, + { url = "https://files.pythonhosted.org/packages/9a/35/66ff30450e35ef5fba9ebc930c9411747e537fd9447b65e44f5007e2b84d/markupsafe-3.0.4-cp313-cp313-musllinux_1_2_armv7l.whl", hash = "sha256:a5fcffb37e602b0b3c1638a97746b9b96125caa9bcf6fa41d337a9261de231ee", size = 22672, upload-time = "2026-10-02T23:05:22.922Z" }, + { url = "https://files.pythonhosted.org/packages/32/0b/72f45ce4b4efcbca4b80cf1b06703eff0be8d37e82abb78f66c85a7ead1e/markupsafe-3.0.4-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:5989cb26b2e1efc6a42216a9f6b5ee495ce5ace2e5b352a9af489976b32d1ee2", size = 24107, upload-time = "2026-10-02T23:05:24.175Z" }, + { url = "https://files.pythonhosted.org/packages/d2/03/71776e5fdcba04614b384cc102e8a4198208579d896fd1394cb7cb9aa900/markupsafe-3.0.4-cp313-cp313-musllinux_1_2_riscv64.whl", hash = "sha256:add96447a86d205ab616665d53b2950ee81083757f56e6ea833c8b2917646b46", size = 21615, upload-time = "2026-10-02T23:05:25.215Z" }, + { url = "https://files.pythonhosted.org/packages/ab/5f/801ce02a02e7aee0f784b1ec7843026178f6adeb9c93ac67eb1992a9a84d/markupsafe-3.0.4-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:2628d3a8cb648ecebb3c5d6b0a1052d400e4d8b7ac0fb786be8d285b50040d17", size = 23076, upload-time = "2026-10-02T23:05:26.423Z" }, + { url = "https://files.pythonhosted.org/packages/4a/85/c43776625428f3bb4a61e8633940400e3efe6409e3c6f5bff26de5e45618/markupsafe-3.0.4-cp313-cp313-win32.whl", hash = "sha256:672d207103e6b16ca098611b0f9efad6bc00afd47c03d6ef62186495ca677dc0", size = 14118, upload-time = "2026-10-02T23:05:27.716Z" }, + { url = "https://files.pythonhosted.org/packages/6f/36/163da64de88a13db79214ef75fa041be7fa13bdb42261cf5b7484de14bfb/markupsafe-3.0.4-cp313-cp313-win_amd64.whl", hash = "sha256:1f1f9477e174582b0a1b583d60b66e1f2cf5d3fe12cee985e4aedf44766600e5", size = 14313, upload-time = "2026-10-02T23:05:28.749Z" }, + { url = "https://files.pythonhosted.org/packages/9f/a8/9b662783ffaa1149221432a923cee562f78b9cbbb8baa3df9b3753e63e1e/markupsafe-3.0.4-cp313-cp313-win_arm64.whl", hash = "sha256:06de8ef6331f6e822c28d577dc8bf43fe398800477c49498f38fc38b67ff33fc", size = 14189, upload-time = "2026-10-02T23:05:29.917Z" }, + { url = "https://files.pythonhosted.org/packages/5c/c3/a944f3b0df22bd129e96915b9f4e98d2eeca6516687d7618304a966c3c74/markupsafe-3.0.4-cp314-cp314-android_24_arm64_v8a.whl", hash = "sha256:4ed644d75aa94a2baf7ec3a96eaa160ea58c742eb9d27c6506053c5c40fc84ed", size = 12787, upload-time = "2026-10-02T23:05:30.971Z" }, + { url = "https://files.pythonhosted.org/packages/d4/d6/a44863f69d88b6c7e27889108f70d47aed259edf89d5df3c5fca1eac87d6/markupsafe-3.0.4-cp314-cp314-android_24_x86_64.whl", hash = "sha256:6d2a9efe686f9de00d0d1ea32a4a5a86d558a2277501bd78d964214eab625e59", size = 12525, upload-time = "2026-10-02T23:05:32.263Z" }, + { url = "https://files.pythonhosted.org/packages/17/8f/168ba80e532dd6a93f96f8f706f1ad41d7990b6e1aeedc1cc0d211a33497/markupsafe-3.0.4-cp314-cp314-ios_13_0_arm64_iphoneos.whl", hash = "sha256:8781a792a070cf2bd1b86d3aa943894115faaba6e88122a7bf32d62072742453", size = 11589, upload-time = "2026-10-02T23:05:33.251Z" }, + { url = "https://files.pythonhosted.org/packages/32/b3/aa2c95a574d3af39403a469b295886eb9b6d448da568cbebb5a2cbfdc2e5/markupsafe-3.0.4-cp314-cp314-ios_13_0_arm64_iphonesimulator.whl", hash = "sha256:971a3bbb75d97ae4e2e8f7d4834236f86f85f0c85e04ab2e191db1123b04f80b", size = 11801, upload-time = "2026-10-02T23:05:34.315Z" }, + { url = "https://files.pythonhosted.org/packages/60/d0/34b810107d83840e768bf485de795893ebbae35b26ab061b487adfa0a692/markupsafe-3.0.4-cp314-cp314-ios_13_0_x86_64_iphonesimulator.whl", hash = "sha256:8909c2f1c6dd65e054ac4b573a91c8384d1492281e55d82d159d653f7a13adf6", size = 11447, upload-time = "2026-10-02T23:05:35.302Z" }, + { url = "https://files.pythonhosted.org/packages/6c/ab/2f8488f0f817a39fca068d2b17daf446bf5cdb3eae28c3720af534d873b4/markupsafe-3.0.4-cp314-cp314-macosx_10_15_x86_64.whl", hash = "sha256:4cf3468d5ec187ffffcaca8e61929a37448f215dafc1386a12c750a72fe53634", size = 11722, upload-time = "2026-10-02T23:05:36.363Z" }, + { url = "https://files.pythonhosted.org/packages/ad/40/e2d117b048d47282ade906fbfd92814cbee5647afc13fda88a3406039372/markupsafe-3.0.4-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:52704c5d36eb6dda8866493decd61111fff86244c9b1ad225ca01b9e91e5970f", size = 12061, upload-time = "2026-10-02T23:05:37.397Z" }, + { url = "https://files.pythonhosted.org/packages/9a/a8/73a81135e85ba66217f5af7facb03bbb386807e1a729ab64532e4c802652/markupsafe-3.0.4-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:1caa2fa5a6184fb233153b35f654e6687bd555476f6170f29d8ee9be1a8b0af9", size = 24434, upload-time = "2026-10-02T23:05:38.407Z" }, + { url = "https://files.pythonhosted.org/packages/ac/ca/fa9216dd01efee2dfdacafe7df32b4d0170fbac694b0c258a193d6e53999/markupsafe-3.0.4-cp314-cp314-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:387d8cd30e69b3f0a72877b9ae717033396404e19095b17fe89753a981fda44f", size = 27183, upload-time = "2026-10-02T23:05:39.581Z" }, + { url = "https://files.pythonhosted.org/packages/fa/4e/a469509e538d37af51103b17b073126973f2b1cbf197ff32c7ddf025cfe5/markupsafe-3.0.4-cp314-cp314-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:051417f74bcaaefa316276e0ff723f541616ca51043d070da00249d9bddd3e3c", size = 24813, upload-time = "2026-10-02T23:05:40.671Z" }, + { url = "https://files.pythonhosted.org/packages/8f/db/d7282caf7ab03af44d5d6fdbaa019b35c7d7f1c90588b839c07cba640d6a/markupsafe-3.0.4-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:a8e9f292fcda89b324f2f5c91d13f1424a153e40fc2756f38ee23b15835ff300", size = 23049, upload-time = "2026-10-02T23:05:41.864Z" }, + { url = "https://files.pythonhosted.org/packages/30/f3/b6a425206e6964efda6acee544d0eb01d1501784d0b8e2dcc74986f33b17/markupsafe-3.0.4-cp314-cp314-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:df1ae86ff54725a01fa1a0510b914ca53a161b7050be74f6204e24aded5971d0", size = 22088, upload-time = "2026-10-02T23:05:43.014Z" }, + { url = "https://files.pythonhosted.org/packages/ea/8a/84d3582fc1f0d5bd466cdf2eebf175e172158a6e70701aacec1de1b35430/markupsafe-3.0.4-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:8965520ac587c94a4ac48b729be3d8b8de00af39699b17585dfb599babe77977", size = 23846, upload-time = "2026-10-02T23:05:44.098Z" }, + { url = "https://files.pythonhosted.org/packages/1c/65/db101cce51b7ba4864ac491a9859d297dd1adf0e55b103fee9db9c47c527/markupsafe-3.0.4-cp314-cp314-musllinux_1_2_armv7l.whl", hash = "sha256:340cbb1957ba99929cbf19a75626d36ba1ae21d1730b287d1cf7f824a20c4fc7", size = 22674, upload-time = "2026-10-02T23:05:45.23Z" }, + { url = "https://files.pythonhosted.org/packages/e0/49/ddee9813d71db0c7a5c9d97c832125e6758a0c844777f1cf076569bb0e22/markupsafe-3.0.4-cp314-cp314-musllinux_1_2_ppc64le.whl", hash = "sha256:3a93d9616ddecfb393727a0041a562cf0b15a244e20f2bd25efc7949be4c4f17", size = 24104, upload-time = "2026-10-02T23:05:46.398Z" }, + { url = "https://files.pythonhosted.org/packages/aa/0e/7d8518d726726870a2399d69fd30d0fa36c5e57a2132c336b58d7c491073/markupsafe-3.0.4-cp314-cp314-musllinux_1_2_riscv64.whl", hash = "sha256:d2e56fd3b00222722abfb3f5f0759ddbae4b90811b5ad4343c64030ad1bde70c", size = 21637, upload-time = "2026-10-02T23:05:47.48Z" }, + { url = "https://files.pythonhosted.org/packages/b4/b0/b505e8a361ba557dbf3b3aa7331ea39b00d2022a26e925ff8463b9714bb3/markupsafe-3.0.4-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:0d9c47709875fdb321452056622e930c52afbc07a7d780762fbb8b4d91ce6fa4", size = 23081, upload-time = "2026-10-02T23:05:48.611Z" }, + { url = "https://files.pythonhosted.org/packages/1c/ea/9cc3cea873f980c75cbdb6f4277ce30ee955de38be0b3d02f14c108e0698/markupsafe-3.0.4-cp314-cp314-win32.whl", hash = "sha256:38fc55594dab834470b6733dead2ee9e3f657fb0608c769dcafa0ba5ab52f45c", size = 14272, upload-time = "2026-10-02T23:05:49.707Z" }, + { url = "https://files.pythonhosted.org/packages/80/f0/5792ff768a410f93ee3f84fc19345295ffc352d2c936b424cb37e514714c/markupsafe-3.0.4-cp314-cp314-win_amd64.whl", hash = "sha256:c1bc67752d5f21013cfe430df4062441714eab79f65a6a05e01505957e9c35fe", size = 14501, upload-time = "2026-10-02T23:05:50.788Z" }, + { url = "https://files.pythonhosted.org/packages/5f/cf/3d074a8edffcc6899355232ff2543ae8d929733239596423b7db79698bc9/markupsafe-3.0.4-cp314-cp314-win_arm64.whl", hash = "sha256:7e1636da3d8dfc220b6dd10264db5f2b165e4888c4518594898fbe381049af8a", size = 14364, upload-time = "2026-10-02T23:05:51.857Z" }, + { url = "https://files.pythonhosted.org/packages/d9/31/87ce42159aae2163cf3bbbd0c44bc87780510eecab1ea3859099aed95dcb/markupsafe-3.0.4-cp314-cp314t-macosx_10_15_x86_64.whl", hash = "sha256:805c8b84534fa10891890f0e4be39f3a99e94615d93e8836bf9fa1fdca2feeb2", size = 11759, upload-time = "2026-10-02T23:05:52.951Z" }, + { url = "https://files.pythonhosted.org/packages/5f/53/b047207eeb7752e960aca3eb1df5fb7eefa7dd4c62ac49bb156456c8a702/markupsafe-3.0.4-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:fa95848c929b6a75f6848d3c9793e59db365ee436776e57db835cdbfa79ba977", size = 12096, upload-time = "2026-10-02T23:05:54.066Z" }, + { url = "https://files.pythonhosted.org/packages/ee/51/4326c88a13c7b755657d44b4bb986f8c3d9843ecba7e22d98661d87f9a57/markupsafe-3.0.4-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:e916035e3e9930cbdfdd10abf48861340221857f45509565898e012263f7b289", size = 25699, upload-time = "2026-10-02T23:05:55.15Z" }, + { url = "https://files.pythonhosted.org/packages/f2/bb/990581b7474bfcf2cf34bed6ba5ea23bd87adb9d671213d68e88620e7a6b/markupsafe-3.0.4-cp314-cp314t-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:b4d12837e0203bbace818ff4a7461afdcd78bcd782351cea148139180d7bcffe", size = 27804, upload-time = "2026-10-02T23:05:56.29Z" }, + { url = "https://files.pythonhosted.org/packages/6b/89/89491878c28e8291f5aa2fffe2c2d57230d10ae366d55dd810b840513d78/markupsafe-3.0.4-cp314-cp314t-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:5086f9975abb1ab531ee6afca1761e4b59a19b446f3f6522ed776963228cfe5a", size = 25912, upload-time = "2026-10-02T23:05:57.416Z" }, + { url = "https://files.pythonhosted.org/packages/30/77/680998b54efdea06fc114565cd739b6d059f826a0279219b218dfa750d29/markupsafe-3.0.4-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:b4a635a0487774f841cb1fb62e907e7195cc95bc761e053184b8acc3ceb20733", size = 23623, upload-time = "2026-10-02T23:05:58.557Z" }, + { url = "https://files.pythonhosted.org/packages/ae/75/2709f5ac5de9467b40b10e2bb8f89cc63dfb74582e09aa734b1124a217de/markupsafe-3.0.4-cp314-cp314t-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:cb96e6e088d6cf71c1ea977510948320234824cf226e32f6f6e044f7a9c82b34", size = 23301, upload-time = "2026-10-02T23:05:59.94Z" }, + { url = "https://files.pythonhosted.org/packages/a0/c8/39eadc6c5b14c9c7679bfb98f4d4c6a97863b5beb91839aca4d2d6e16e55/markupsafe-3.0.4-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:8b5d563170ff8ba3181caa967c99a3c804d1dedb702c7cb93a6a7c32247da978", size = 24950, upload-time = "2026-10-02T23:06:01.289Z" }, + { url = "https://files.pythonhosted.org/packages/1a/5e/01037f8a43e8ccb0bffb4fbdc5212db05bf080fdd7286cd392332d58128a/markupsafe-3.0.4-cp314-cp314t-musllinux_1_2_armv7l.whl", hash = "sha256:396ec4e65cc889f69786b3b89478b471cee5a3bcf468b9d9bb03e1a30fb291fc", size = 23330, upload-time = "2026-10-02T23:06:02.441Z" }, + { url = "https://files.pythonhosted.org/packages/d4/f4/23e83ce0596bb0cbe670502d31df8f757bbd01a392aa486fa3b40d1ed399/markupsafe-3.0.4-cp314-cp314t-musllinux_1_2_ppc64le.whl", hash = "sha256:15ba9e28640feef770374b116a6f019c21f52404aeabe516aa7f800587b98cfc", size = 25239, upload-time = "2026-10-02T23:06:03.579Z" }, + { url = "https://files.pythonhosted.org/packages/88/5b/3708897368073cc683d524750474f41a77d2986152c380dcc55b20fdf340/markupsafe-3.0.4-cp314-cp314t-musllinux_1_2_riscv64.whl", hash = "sha256:d920abdfa61279ba1a2ef9484aab07bf03331f8c08a10120fa332353d06e6932", size = 22767, upload-time = "2026-10-02T23:06:04.699Z" }, + { url = "https://files.pythonhosted.org/packages/c6/61/ebda1307864b409e6b3115757a3d4a09cca46cfb6cc65191b5de226b424b/markupsafe-3.0.4-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:a9f54054101545a9a9cccefddf54316aa6e4491611fcbef9e91b3b6bebec04f6", size = 23668, upload-time = "2026-10-02T23:06:05.9Z" }, + { url = "https://files.pythonhosted.org/packages/09/15/98075cceac3b5ba0dbb8e4762a847be967d2befc349a2cf2d0ac77f62c9d/markupsafe-3.0.4-cp314-cp314t-win32.whl", hash = "sha256:12a606a492de952afcb43b59a14aaaaad120e708d3663dd0fdf2d738d427a691", size = 14301, upload-time = "2026-10-02T23:06:07.109Z" }, + { url = "https://files.pythonhosted.org/packages/0b/a3/768b560fcc4156685cb563d922b217810cfa7bc135773367f62f1f9d2078/markupsafe-3.0.4-cp314-cp314t-win_amd64.whl", hash = "sha256:a18f38cafc329bac5e3c2b96c765b4c96d3d103421ed22ab7988c1e3fce27464", size = 14526, upload-time = "2026-10-02T23:06:08.276Z" }, + { url = "https://files.pythonhosted.org/packages/93/63/da554b4c97a6b0ea3229ca7fe8cbfb620be81613d517f482e85958550537/markupsafe-3.0.4-cp314-cp314t-win_arm64.whl", hash = "sha256:eba154571c16e032112afac0dc2dfe9e63c2ceb7aedd07bb7eecf2ce26d4dd4c", size = 14421, upload-time = "2026-10-02T23:06:09.402Z" }, + { url = "https://files.pythonhosted.org/packages/a9/30/54d11c8ca027114898cab97421fb39e4ffd9ddf47cdbc44df2ec76722da9/markupsafe-3.0.4-cp315-cp315-android_24_arm64_v8a.whl", hash = "sha256:737c9c3981998eba27f11786f84fddcbabc74068b72a4a1f454ea02094b57b65", size = 12791, upload-time = "2026-10-02T23:06:10.485Z" }, + { url = "https://files.pythonhosted.org/packages/10/6d/97c913e253a14bd3cd0e15a5c56d13203b823fa7ee32498342896a072dc4/markupsafe-3.0.4-cp315-cp315-android_24_x86_64.whl", hash = "sha256:489505b03f692c3f376394e49194fa7a7f9e8558d6e293a7056a0032b0c38163", size = 12527, upload-time = "2026-10-02T23:06:11.834Z" }, + { url = "https://files.pythonhosted.org/packages/26/f9/b86d032042a4d597d9e1997f0e5f63a3eedaf11258e0a05760b0a0a826ea/markupsafe-3.0.4-cp315-cp315-ios_13_0_arm64_iphoneos.whl", hash = "sha256:077293e425f28ec737dbcad442a71752e28f8ae27cde3d68acd1fb212091cd92", size = 11602, upload-time = "2026-10-02T23:06:13.122Z" }, + { url = "https://files.pythonhosted.org/packages/f2/dc/73c14c1eedf0ac5fa3292ba43435e6c49d2c2050f33cebde541f8f4807f1/markupsafe-3.0.4-cp315-cp315-ios_13_0_arm64_iphonesimulator.whl", hash = "sha256:9348cbb300d224fe3b89793262cb093504d4ae927004468463f745188a193e4a", size = 11817, upload-time = "2026-10-02T23:06:14.227Z" }, + { url = "https://files.pythonhosted.org/packages/8f/69/2c2fcaa5fcee22d72c7819c0d536fd181c74a688e6143845419579cd2863/markupsafe-3.0.4-cp315-cp315-ios_13_0_x86_64_iphonesimulator.whl", hash = "sha256:b807e598953730f82e4eae3bd30f6a122cf6b31c398c6b504c0e04c13c170429", size = 11446, upload-time = "2026-10-02T23:06:15.574Z" }, + { url = "https://files.pythonhosted.org/packages/88/54/9e5ec76c62e6e2834d5a93623018c943e8b3bb41d663e3fd4c03303b9b85/markupsafe-3.0.4-cp315-cp315-macosx_10_15_x86_64.whl", hash = "sha256:799c39bdf5e2f1292fedd3009f7b3c9e760f10b2420cb9638d56920840ff6db8", size = 11719, upload-time = "2026-10-02T23:06:16.701Z" }, + { url = "https://files.pythonhosted.org/packages/96/24/3ec292b44064c16229e064d770b2625bd8ea941aa61f44905a9fa44942c0/markupsafe-3.0.4-cp315-cp315-macosx_11_0_arm64.whl", hash = "sha256:ae9dcb8fbe244cb82f8a6458b455b927a03685e383d9bacf1ea5ce180b96dc97", size = 12075, upload-time = "2026-10-02T23:06:17.855Z" }, + { url = "https://files.pythonhosted.org/packages/aa/85/b64fdb1f304848518742136983c24e96d967bfb59a0ea160e92736901ab0/markupsafe-3.0.4-cp315-cp315-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:4bced6e2a6dba6a28f7dd3c6ce14df1b2dd495923f16ea484cad03decd463b2b", size = 24656, upload-time = "2026-10-02T23:06:18.963Z" }, + { url = "https://files.pythonhosted.org/packages/9c/18/23997d4c65b355da6390d61cd56e0ab3befd6ba8dda25cb40c602bd0fa6b/markupsafe-3.0.4-cp315-cp315-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:3882fb412298575bae3b9c46868251f15cc69307359f87bb1b382e53d6e5a2c9", size = 27737, upload-time = "2026-10-02T23:06:20.117Z" }, + { url = "https://files.pythonhosted.org/packages/d4/36/35998dead3c6af88c38265a56e58100211f036234ab88eb2283fd4cbce44/markupsafe-3.0.4-cp315-cp315-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:04e7902ba80ee4bac1d50a549606527a1dcf0476cd81403db41099d3b60ec653", size = 25003, upload-time = "2026-10-02T23:06:21.284Z" }, + { url = "https://files.pythonhosted.org/packages/82/96/ef49135ce260db4ca4a12b119ed468449cd248db6b1468e2112b546d7a2e/markupsafe-3.0.4-cp315-cp315-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:925f929d6b59a8b3f8b8c6ac363cd0af7eecc81efb3071770b3c6717c450a369", size = 23111, upload-time = "2026-10-02T23:06:22.524Z" }, + { url = "https://files.pythonhosted.org/packages/50/7d/83126e338bd88c17a220668235368ad719fd4638e426739858cbb8508f77/markupsafe-3.0.4-cp315-cp315-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:f68edfc67aabac33708941f26f22a7b8e9f81429bc0cf249fcf7d66b23af8d19", size = 22403, upload-time = "2026-10-02T23:06:23.785Z" }, + { url = "https://files.pythonhosted.org/packages/83/dd/daf7e420de23c8206c365204e7b85e1251d8e19d34196a56336f316e5ed2/markupsafe-3.0.4-cp315-cp315-musllinux_1_2_aarch64.whl", hash = "sha256:e5c802729725bd07e2bc3ab7b76dc7e0bbfc53129d8f1eb1c002c24cf774717e", size = 24083, upload-time = "2026-10-02T23:06:25.037Z" }, + { url = "https://files.pythonhosted.org/packages/19/3c/11eecdc06bc44ad5570350085b572ebf049e8f9a38d1ece6d76640b739cd/markupsafe-3.0.4-cp315-cp315-musllinux_1_2_armv7l.whl", hash = "sha256:55ffd6ce583d97dc71dc92e930324c8c0d25aea7e3ade6ae54ef77cedb096811", size = 22931, upload-time = "2026-10-02T23:06:26.328Z" }, + { url = "https://files.pythonhosted.org/packages/0d/9e/ac0fd77f2a726e56ecc3ca0235d095feace1358d1b822406c2a2ef26a4dc/markupsafe-3.0.4-cp315-cp315-musllinux_1_2_ppc64le.whl", hash = "sha256:2cb3dd71fc6be918ad4264346a8ed69485f9b7ed7bf35495d8e22807cd6b8bea", size = 24299, upload-time = "2026-10-02T23:06:27.742Z" }, + { url = "https://files.pythonhosted.org/packages/d7/09/c6bd842ad58ff5b3bc76eeed7e9a42a6f11adc5d090ec697b72c9672731e/markupsafe-3.0.4-cp315-cp315-musllinux_1_2_riscv64.whl", hash = "sha256:94f5407f7bc64fa6463906b896f9904beeeb7dd8dc116ee8e9056c8714ff9916", size = 21948, upload-time = "2026-10-02T23:06:29.274Z" }, + { url = "https://files.pythonhosted.org/packages/a3/46/82f586711fed61e86faa1ee1bc317d68cd45a10c8bdbe3f7d1fdf9026ad8/markupsafe-3.0.4-cp315-cp315-musllinux_1_2_x86_64.whl", hash = "sha256:2dad610540cb2e6272855c178f08ae9a1c7ac258a7fb71660553a5f104b42741", size = 23150, upload-time = "2026-10-02T23:06:30.583Z" }, + { url = "https://files.pythonhosted.org/packages/19/2d/2dfdce99318abbfa26925195fbc17db188c46a1ec6457be121b6f9cfeb42/markupsafe-3.0.4-cp315-cp315-win32.whl", hash = "sha256:03470d1a8268e692ecf79ecd565593e59d44219377a7ead61f1f1b94c1f7ff6b", size = 14269, upload-time = "2026-10-02T23:06:31.949Z" }, + { url = "https://files.pythonhosted.org/packages/5b/ec/6000fd82e8791e58fcd0456ec20f098957e2b03d5ed02eb73241a577c0ba/markupsafe-3.0.4-cp315-cp315-win_amd64.whl", hash = "sha256:d882a373d8093c2941e01291b7ced96e9cbe4781da9a7751ca7e6c70385e5214", size = 14496, upload-time = "2026-10-02T23:06:33.258Z" }, + { url = "https://files.pythonhosted.org/packages/bc/66/e73bd5016421d5d6e2fb6de7dd609f9de020942ac8c626526bd8c6eeaf82/markupsafe-3.0.4-cp315-cp315-win_arm64.whl", hash = "sha256:353bd63081912ab8cfa6a0c7d185934cdf8426f04c618bba6bc4b394f2069b67", size = 14361, upload-time = "2026-10-02T23:06:34.539Z" }, + { url = "https://files.pythonhosted.org/packages/90/df/cb8c3dc98d313a951df2f8968f44e4cb5643df6d3cab749a530ce2f7d972/markupsafe-3.0.4-cp315-cp315t-macosx_10_15_x86_64.whl", hash = "sha256:c61750fadcd119d0825bcb7d7d675dd264dcc89cc05292aab5be68ebdbb374ad", size = 11760, upload-time = "2026-10-02T23:06:35.807Z" }, + { url = "https://files.pythonhosted.org/packages/d6/bb/4af9b3ca0753d654ac75f9531d5bd741bb77ca6e696f36807c475ffc099a/markupsafe-3.0.4-cp315-cp315t-macosx_11_0_arm64.whl", hash = "sha256:1c0df495a977d10460a94941799c72d5b5ab03d3858d949b55b5a66c8f371c99", size = 12108, upload-time = "2026-10-02T23:06:37.089Z" }, + { url = "https://files.pythonhosted.org/packages/3f/d4/b56429313aee5fd59b079c3df5615299959e25e7113eb6d8caadbdd7d38a/markupsafe-3.0.4-cp315-cp315t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:02fa4acbc6a3fc5c693c34d4dd8c1130b7fe99cc915181b0ddd6f72aeb296002", size = 25762, upload-time = "2026-10-02T23:06:38.419Z" }, + { url = "https://files.pythonhosted.org/packages/65/f5/34c181e891aa4f7d59c918584672e0c5eb7fffe76c1387d1246008bf4081/markupsafe-3.0.4-cp315-cp315t-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:05295589e619b9bed252a86b532b8e27350abc372d18ba89b59375325e91ec1e", size = 28400, upload-time = "2026-10-02T23:06:39.819Z" }, + { url = "https://files.pythonhosted.org/packages/ce/b5/ad14694fd0ac9a5ce30bc6498f2999378f418583dd1679cca5a1b512957e/markupsafe-3.0.4-cp315-cp315t-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:be6cb0c799abb0e2ba3e618e6d28ddddf7e485f6c2ce938dfa237daf3905072c", size = 25946, upload-time = "2026-10-02T23:06:41.381Z" }, + { url = "https://files.pythonhosted.org/packages/d6/a8/26b606445387d0ceb1eb1f21840094b84e4e3c3c3983d80d10b89823b490/markupsafe-3.0.4-cp315-cp315t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:26e9867520db70d37f7fb421a7f0d8adb40171011fb84ce869afa1a83370dfa8", size = 23634, upload-time = "2026-10-02T23:06:42.748Z" }, + { url = "https://files.pythonhosted.org/packages/39/a2/b8814de672f1f0094d498bf646f2fec9d6356b503d28ef500b71c5095377/markupsafe-3.0.4-cp315-cp315t-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:f03460ff076f70ab595bb45a0205ccea1971443575b6920c52e755dec2b3fbfe", size = 23488, upload-time = "2026-10-02T23:06:44.176Z" }, + { url = "https://files.pythonhosted.org/packages/db/c7/287223376fb73335a3cc5d6eb22c6ab01358cf33945a9c39c06b9dac3f4b/markupsafe-3.0.4-cp315-cp315t-musllinux_1_2_aarch64.whl", hash = "sha256:436e3ffc6310d3c41878c601db29098102fe5d8a467c49da4a4125254e0980f2", size = 25037, upload-time = "2026-10-02T23:06:45.646Z" }, + { url = "https://files.pythonhosted.org/packages/f9/29/4df8355e313426d19e62ba33e0253c009ca12a0894ee77d67fa67255361c/markupsafe-3.0.4-cp315-cp315t-musllinux_1_2_armv7l.whl", hash = "sha256:4e2c4809c14559aa7ef426f27fb35afbb38104c349a903bf8f3600456764bb38", size = 23543, upload-time = "2026-10-02T23:06:47.264Z" }, + { url = "https://files.pythonhosted.org/packages/71/e5/8377731e8495668dcc768f645e717df18318c841edaf023a99395f6da9b4/markupsafe-3.0.4-cp315-cp315t-musllinux_1_2_ppc64le.whl", hash = "sha256:da2af0d7aebfc2074080d72efa6ab8317c62481ef1f896f65d9999c1c01f4494", size = 25282, upload-time = "2026-10-02T23:06:48.795Z" }, + { url = "https://files.pythonhosted.org/packages/ed/5f/373456e37ceb1478d657d6fe769cbe0a39f0a8dfc1548eeb19c471eefdd9/markupsafe-3.0.4-cp315-cp315t-musllinux_1_2_riscv64.whl", hash = "sha256:aa2c838cc024642cc04c6854232f32b43e5e22833dd11119c1766c7873b8370d", size = 22993, upload-time = "2026-10-02T23:06:50.31Z" }, + { url = "https://files.pythonhosted.org/packages/d7/93/2cbd5628435afb6f541bbaced4bce0c2edac4b09a142e6e928b8b0da9858/markupsafe-3.0.4-cp315-cp315t-musllinux_1_2_x86_64.whl", hash = "sha256:b91cc9d336957239ff200f30097e6fea2dc6d6fb3c81e853eaa09eac904fd894", size = 23712, upload-time = "2026-10-02T23:06:51.759Z" }, + { url = "https://files.pythonhosted.org/packages/81/99/157e10966b033b363aeda5263e82596ee232a0b1d082fdbf90aa417ff083/markupsafe-3.0.4-cp315-cp315t-win32.whl", hash = "sha256:e49fb0d1ce92cfa0cb198cc5b1b11cdf9d0638658e2a2db2687e39db7c87fc78", size = 14300, upload-time = "2026-10-02T23:06:53.241Z" }, + { url = "https://files.pythonhosted.org/packages/33/05/55884815414c9706a23deca150b72c25a62109e65b0b6ce232077802c719/markupsafe-3.0.4-cp315-cp315t-win_amd64.whl", hash = "sha256:4f6e0852a0283b1b1fd776eeb7b766a5f440b3e2bd31ab51af3b400585f3965c", size = 14522, upload-time = "2026-10-02T23:06:54.729Z" }, + { url = "https://files.pythonhosted.org/packages/92/f9/ecbde7149e95b8a0f18e16d5d747f7dc06049d5da2e4f77f6f5e4a1f46a8/markupsafe-3.0.4-cp315-cp315t-win_arm64.whl", hash = "sha256:39dbacefc411633db5b4378b066a9aca70a3d7e2922c9e578d825f844026eeba", size = 14417, upload-time = "2026-10-02T23:06:56.246Z" }, +] + +[[package]] +name = "mergedeep" +version = "1.3.4" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/3a/41/580bb4006e3ed0361b8151a01d324fb03f420815446c7def45d02f74c270/mergedeep-1.3.4.tar.gz", hash = "sha256:0096d52e9dad9939c3d975a774666af186eda617e6ca84df4c94dec30004f2a8", size = 4661, upload-time = "2021-02-05T18:55:30.623Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/2c/19/04f9b178c2d8a15b076c8b5140708fa6ffc5601fb6f1e975537072df5b2a/mergedeep-1.3.4-py3-none-any.whl", hash = "sha256:70775750742b25c0d8f36c55aed03d24c3384d17c951b3175d898bd778ef0307", size = 6354, upload-time = "2021-02-05T18:55:29.583Z" }, +] + +[[package]] +name = "mkdocs" +version = "1.6.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "click", marker = "python_full_version < '3.15'" }, + { name = "colorama", marker = "python_full_version < '3.15' and sys_platform == 'win32'" }, + { name = "ghp-import", marker = "python_full_version < '3.15'" }, + { name = "jinja2", marker = "python_full_version < '3.15'" }, + { name = "markdown", marker = "python_full_version < '3.15'" }, + { name = "markupsafe", marker = "python_full_version < '3.15'" }, + { name = "mergedeep", marker = "python_full_version < '3.15'" }, + { name = "mkdocs-get-deps", marker = "python_full_version < '3.15'" }, + { name = "packaging", marker = "python_full_version < '3.15'" }, + { name = "pathspec", marker = "python_full_version < '3.15'" }, + { name = "pyyaml", marker = "python_full_version < '3.15'" }, + { name = "pyyaml-env-tag", marker = "python_full_version < '3.15'" }, + { name = "watchdog", version = "6.0.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.11'" }, + { name = "watchdog", version = "7.1.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.11' and python_full_version < '3.15'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/bc/c6/bbd4f061bd16b378247f12953ffcb04786a618ce5e904b8c5a01a0309061/mkdocs-1.6.1.tar.gz", hash = "sha256:7b432f01d928c084353ab39c57282f29f92136665bdd6abf7c1ec8d822ef86f2", size = 3889159, upload-time = "2024-08-30T12:24:06.899Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/22/5b/dbc6a8cddc9cfa9c4971d59fb12bb8d42e161b7e7f8cc89e49137c5b279c/mkdocs-1.6.1-py3-none-any.whl", hash = "sha256:db91759624d1647f3f34aa0c3f327dd2601beae39a366d6e064c03468d35c20e", size = 3864451, upload-time = "2024-08-30T12:24:05.054Z" }, +] + +[[package]] +name = "mkdocs-autorefs" +version = "1.3.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "markdown", marker = "python_full_version < '3.15'" }, + { name = "markupsafe", marker = "python_full_version < '3.15'" }, + { name = "mkdocs", marker = "python_full_version < '3.15'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/52/f4/77e3cf5e7ba54dca168bc718688127844721982ae88b08684669c5b5752d/mkdocs_autorefs-1.3.1.tar.gz", hash = "sha256:a6d30cbcccae336d622a66c2418a3c92a8196b69782774529ad441abb23c0902", size = 2056416, upload-time = "2025-02-11T15:33:29.316Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/db/19/f20edc082c1de2987dbaf30fcc514ed7a908d465a15aba7cba595c3b245a/mkdocs_autorefs-1.3.1-py3-none-any.whl", hash = "sha256:18c504ae4d3ee7f344369bb26cb31d4105569ee252aab7d75ec2734c2c8b0474", size = 2837887, upload-time = "2025-02-11T15:33:25.863Z" }, +] + +[[package]] +name = "mkdocs-get-deps" +version = "0.2.2" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "mergedeep", marker = "python_full_version < '3.15'" }, + { name = "platformdirs", marker = "python_full_version < '3.15'" }, + { name = "pyyaml", marker = "python_full_version < '3.15'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/ce/25/b3cccb187655b9393572bde9b09261d267c3bf2f2cdabe347673be5976a6/mkdocs_get_deps-0.2.2.tar.gz", hash = "sha256:8ee8d5f316cdbbb2834bc1df6e69c08fe769a83e040060de26d3c19fad3599a1", size = 11047, upload-time = "2026-03-10T02:46:33.632Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/88/29/744136411e785c4b0b744d5413e56555265939ab3a104c6a4b719dad33fd/mkdocs_get_deps-0.2.2-py3-none-any.whl", hash = "sha256:e7878cbeac04860b8b5e0ca31d3abad3df9411a75a32cde82f8e44b6c16ff650", size = 9555, upload-time = "2026-03-10T02:46:32.256Z" }, +] + +[[package]] +name = "mkdocs-material" +version = "9.7.7" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "babel", marker = "python_full_version < '3.15'" }, + { name = "backrefs", version = "8.1", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.11'" }, + { name = "backrefs", version = "8.3", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.11' and python_full_version < '3.15'" }, + { name = "colorama", marker = "python_full_version < '3.15'" }, + { name = "jinja2", marker = "python_full_version < '3.15'" }, + { name = "markdown", marker = "python_full_version < '3.15'" }, + { name = "mkdocs", marker = "python_full_version < '3.15'" }, + { name = "mkdocs-material-extensions", marker = "python_full_version < '3.15'" }, + { name = "paginate", marker = "python_full_version < '3.15'" }, + { name = "pygments", marker = "python_full_version < '3.15'" }, + { name = "pymdown-extensions", marker = "python_full_version < '3.15'" }, + { name = "requests", marker = "python_full_version < '3.15'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/f1/cd/c05d3a530ba7934f144fb45f7203cd236adc25c7bdcc34673d202f4b0278/mkdocs_material-9.7.7.tar.gz", hash = "sha256:c0649c065b1b0512d60aad8c10f947f8e455284475239b364b610f2deb4d0855", size = 4097923, upload-time = "2026-07-17T16:21:33.156Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/ad/21/17c1bc9e6f47c972ad66fb2ac2568f99f90f1207eeb6fc3b34d094dba7b5/mkdocs_material-9.7.7-py3-none-any.whl", hash = "sha256:8ea9bb1737a5b524a5f9dcf2e1b4ebda8274ae3008aa7845720a97083bef708f", size = 9305438, upload-time = "2026-07-17T16:21:30.017Z" }, +] + +[[package]] +name = "mkdocs-material-extensions" +version = "1.3.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/79/9b/9b4c96d6593b2a541e1cb8b34899a6d021d208bb357042823d4d2cabdbe7/mkdocs_material_extensions-1.3.1.tar.gz", hash = "sha256:10c9511cea88f568257f960358a467d12b970e1f7b2c0e5fb2bb48cab1928443", size = 11847, upload-time = "2023-11-22T19:09:45.208Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/5b/54/662a4743aa81d9582ee9339d4ffa3c8fd40a4965e033d77b9da9774d3960/mkdocs_material_extensions-1.3.1-py3-none-any.whl", hash = "sha256:adff8b62700b25cb77b53358dad940f3ef973dd6db797907c49e3c2ef3ab4e31", size = 8728, upload-time = "2023-11-22T19:09:43.465Z" }, +] + +[[package]] +name = "mkdocstrings" +version = "0.25.2" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "click", marker = "python_full_version < '3.15'" }, + { name = "jinja2", marker = "python_full_version < '3.15'" }, + { name = "markdown", marker = "python_full_version < '3.15'" }, + { name = "markupsafe", marker = "python_full_version < '3.15'" }, + { name = "mkdocs", marker = "python_full_version < '3.15'" }, + { name = "mkdocs-autorefs", marker = "python_full_version < '3.15'" }, + { name = "platformdirs", marker = "python_full_version < '3.15'" }, + { name = "pymdown-extensions", marker = "python_full_version < '3.15'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/24/a6/d544fae9749b19e23fb590f6344f9eae3a312323065070b4874236bb0e04/mkdocstrings-0.25.2.tar.gz", hash = "sha256:5cf57ad7f61e8be3111a2458b4e49c2029c9cb35525393b179f9c916ca8042dc", size = 91796, upload-time = "2024-07-25T14:55:49.895Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/2b/86/ee2aef075cc9a62a4f087c3c3f4e3e8a8318afe05a92f8f8415f1bf1af64/mkdocstrings-0.25.2-py3-none-any.whl", hash = "sha256:9e2cda5e2e12db8bb98d21e3410f3f27f8faab685a24b03b06ba7daa5b92abfc", size = 29289, upload-time = "2024-07-25T14:55:47.275Z" }, +] + +[package.optional-dependencies] +python = [ + { name = "mkdocstrings-python", marker = "python_full_version < '3.15'" }, +] + +[[package]] +name = "mkdocstrings-python" +version = "1.10.9" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "griffe", version = "2.3.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.11'" }, + { name = "griffe", version = "2.4.1", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.11' and python_full_version < '3.15'" }, + { name = "mkdocs-autorefs", marker = "python_full_version < '3.15'" }, + { name = "mkdocstrings", marker = "python_full_version < '3.15'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/d8/df/c0c09bf79f1329da2422b5d1d2d4d84070aee7cf7f99df98d7b78be066a9/mkdocstrings_python-1.10.9.tar.gz", hash = "sha256:f344aaa47e727d8a2dc911e063025e58e2b7fb31a41110ccc3902aa6be7ca196", size = 162070, upload-time = "2024-08-30T18:05:04.607Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/87/45/35c2ade06b6dfd383795008260405a47e10aba74e2c9594741a1a1f034b0/mkdocstrings_python-1.10.9-py3-none-any.whl", hash = "sha256:cbe98710a6757dfd4dff79bf36cb9731908fb4c69dd2736b15270ae7a488243d", size = 108360, upload-time = "2024-08-30T18:05:02.608Z" }, ] [[package]] name = "modpoll" version = "2.0.0a10" -source = { editable = "." } +source = { editable = "packages/modpoll" } dependencies = [ { name = "modpoll-wot", marker = "python_full_version < '3.15'" }, { name = "paho-mqtt", marker = "python_full_version < '3.15'" }, @@ -717,7 +1177,7 @@ docs = [ [package.metadata] requires-dist = [ - { name = "modpoll-wot", specifier = "==0.6.0a2" }, + { name = "modpoll-wot", editable = "packages/modpoll-wot" }, { name = "paho-mqtt", specifier = ">=2.1.0,<3.0.0" }, { name = "prettytable", specifier = ">=3.9.0,<4.0.0" }, { name = "pymodbus", specifier = "~=3.16.1" }, @@ -746,32 +1206,175 @@ docs = [ [[package]] name = "modpoll-wot" version = "0.6.0a2" -source = { registry = "https://pypi.org/simple" } +source = { editable = "packages/modpoll-wot" } dependencies = [ { name = "jsonschema", marker = "python_full_version < '3.15'" }, { name = "referencing", marker = "python_full_version < '3.15'" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/9a/c8/edebe6d6e0775d0f2cd97b24f835f03a0c2bca51313b912e5b385271ce10/modpoll_wot-0.6.0a2.tar.gz", hash = "sha256:38d078ae260d0666ba4ac83987da4db527c030900a62adf6de23986650e1ff5e", size = 60721, upload-time = "2026-11-13T07:20:06.794Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/80/8f/63352f818565184ee7961fedd0462ed36931fee58675477b604ce1cacf74/modpoll_wot-0.6.0a2-py3-none-any.whl", hash = "sha256:b6b4bf52dd2a195030c9bc8fc53bae9e7d027e94af33f01e512c708cbf888f7f", size = 52246, upload-time = "2026-11-13T07:20:07.947Z" }, + +[package.dev-dependencies] +dev = [ + { name = "pytest", marker = "python_full_version < '3.15'" }, +] + +[package.metadata] +requires-dist = [ + { name = "jsonschema", specifier = ">=4.18,<5" }, + { name = "referencing", specifier = ">=0.28.4,<1" }, +] + +[package.metadata.requires-dev] +dev = [{ name = "pytest", specifier = ">=8.2.2,<9" }] + +[[package]] +name = "modsim" +version = "2.0.0a12" +source = { editable = "packages/modsim" } +dependencies = [ + { name = "jsonschema", marker = "python_full_version < '3.15'" }, + { name = "modpoll-wot", marker = "python_full_version < '3.15'" }, + { name = "pymodbus", marker = "python_full_version < '3.15'" }, + { name = "pyserial", marker = "python_full_version < '3.15'" }, + { name = "pyyaml", marker = "python_full_version < '3.15'" }, +] + +[package.dev-dependencies] +dev = [ + { name = "deptry", marker = "python_full_version < '3.15'" }, + { name = "mypy", marker = "python_full_version < '3.15'" }, + { name = "pre-commit", marker = "python_full_version < '3.15'" }, + { name = "pytest", marker = "python_full_version < '3.15'" }, + { name = "tomli", marker = "python_full_version < '3.11'" }, + { name = "tox", marker = "python_full_version < '3.15'" }, +] +docs = [ + { name = "markdown", marker = "python_full_version < '3.15'" }, + { name = "mkdocs", marker = "python_full_version < '3.15'" }, + { name = "mkdocs-autorefs", marker = "python_full_version < '3.15'" }, + { name = "mkdocs-material", marker = "python_full_version < '3.15'" }, + { name = "mkdocstrings", extra = ["python"], marker = "python_full_version < '3.15'" }, + { name = "pymdown-extensions", marker = "python_full_version < '3.15'" }, +] + +[package.metadata] +requires-dist = [ + { name = "jsonschema", specifier = ">=4.21,<5" }, + { name = "modpoll-wot", editable = "packages/modpoll-wot" }, + { name = "pymodbus", specifier = "~=3.16.1" }, + { name = "pyserial", specifier = ">=3.5,<4.0" }, + { name = "pyyaml", specifier = ">=6,<7" }, +] + +[package.metadata.requires-dev] +dev = [ + { name = "deptry", specifier = ">=0.16.1,<0.17.0" }, + { name = "mypy", specifier = ">=1.10.1,<2.0.0" }, + { name = "pre-commit", specifier = ">=3.5.0,<4.0.0" }, + { name = "pytest", specifier = ">=8.2.2,<9.0.0" }, + { name = "tomli", marker = "python_full_version < '3.11'", specifier = ">=2,<3" }, + { name = "tox", specifier = ">=4.16.0,<5.0.0" }, +] +docs = [ + { name = "markdown", specifier = ">=3.7,<3.8" }, + { name = "mkdocs", specifier = ">=1.6.0,<2.0.0" }, + { name = "mkdocs-autorefs", specifier = ">=1.2,<1.4" }, + { name = "mkdocs-material", specifier = ">=9.5.28,<10.0.0" }, + { name = "mkdocstrings", extras = ["python"], specifier = ">=0.25.1,<0.26.0" }, + { name = "pymdown-extensions", specifier = ">=10.11,<11" }, +] + +[[package]] +name = "mypy" +version = "1.20.2" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "librt", marker = "python_full_version < '3.15' and platform_python_implementation != 'PyPy'" }, + { name = "mypy-extensions", marker = "python_full_version < '3.15'" }, + { name = "pathspec", marker = "python_full_version < '3.15'" }, + { name = "tomli", marker = "python_full_version < '3.11'" }, + { name = "typing-extensions", marker = "python_full_version < '3.15'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/04/af/e3d4b3e9ec91a0ff9aabfdb38692952acf49bbb899c2e4c29acb3a6da3ae/mypy-1.20.2.tar.gz", hash = "sha256:e8222c26daaafd9e8626dec58ae36029f82585890589576f769a650dd20fd665", size = 3817349, upload-time = "2026-04-21T17:12:28.473Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/76/97/ce2502df2cecf2ef997b6c6527c4a223b92feb9e7b790cdc8dcd683f3a8a/mypy-1.20.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:cf5a4db6dca263010e2c7bff081c89383c72d187ba2cf4c44759aac970e2f0c4", size = 14457059, upload-time = "2026-04-21T17:06:14.935Z" }, + { url = "https://files.pythonhosted.org/packages/c9/34/417ee60b822cc80c0f3dc9f495ad7fd8dbb8d8b2cf4baf22d4046d25d01d/mypy-1.20.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:7b0e817b518bff7facd7f85ea05b643ad8bdcce684cf29784987b0a7c8e1f997", size = 13346816, upload-time = "2026-04-21T17:10:41.433Z" }, + { url = "https://files.pythonhosted.org/packages/4a/85/e20951978702df58379d0bcc2e8f7ccdca4e78cd7dc66dd3ddbf9b29d517/mypy-1.20.2-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:97d7b9a485b40f8ca425460e89bf1da2814625b2da627c0dcc6aa46c92631d14", size = 13772593, upload-time = "2026-04-21T17:08:11.24Z" }, + { url = "https://files.pythonhosted.org/packages/63/a5/5441a13259ec516c56fd5de0fd96a69a9590ae6c5e5d3e5174aa84b97973/mypy-1.20.2-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:1e1c12f6d2db3d78b909b5f77513c11eb7f2dd2782b96a3ab6dffc7d44575c99", size = 14656635, upload-time = "2026-04-21T17:09:54.042Z" }, + { url = "https://files.pythonhosted.org/packages/3b/51/b89c69157c5e1f19fd125a65d991166a26906e7902f026f00feebbcfa2b9/mypy-1.20.2-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:89dce27e142d25ffbc154c1819383b69f2e9234dc4ed4766f42e0e8cb264ab5c", size = 14943278, upload-time = "2026-04-21T17:09:15.599Z" }, + { url = "https://files.pythonhosted.org/packages/e9/44/6b0eeecfe96d7cce1d71c66b8e03cb304aa70ec11f1955dc1d6b46aca3c3/mypy-1.20.2-cp310-cp310-win_amd64.whl", hash = "sha256:f376e37f9bf2a946872fc5fd1199c99310748e3c26c7a26683f13f8bdb756cbd", size = 10851915, upload-time = "2026-04-21T17:06:03.5Z" }, + { url = "https://files.pythonhosted.org/packages/3c/36/6593dc88545d75fb96416184be5392da5e2a8e8c2802a8597913e16ae25c/mypy-1.20.2-cp310-cp310-win_arm64.whl", hash = "sha256:6e2b469efd811707bc530fd1effef0f5d6eebcb7fe376affae69025da4b979a2", size = 9786676, upload-time = "2026-04-21T17:07:02.035Z" }, + { url = "https://files.pythonhosted.org/packages/1f/4d/9ebeae211caccbdaddde7ed5e31dfcf57faac66be9b11deb1dc6526c8078/mypy-1.20.2-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:4077797a273e56e8843d001e9dfe4ba10e33323d6ade647ff260e5cd97d9758c", size = 14371307, upload-time = "2026-04-21T17:08:56.442Z" }, + { url = "https://files.pythonhosted.org/packages/95/d7/93473d34b61f04fac1aecc01368485c89c5c4af7a4b9a0cab5d77d04b63f/mypy-1.20.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:cdecf62abcc4292500d7858aeae87a1f8f1150f4c4dd08fb0b336ee79b2a6df3", size = 13258917, upload-time = "2026-04-21T17:05:50.978Z" }, + { url = "https://files.pythonhosted.org/packages/e2/30/3dd903e8bafb7b5f7bf87fcd58f8382086dea2aa19f0a7b357f21f63071b/mypy-1.20.2-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:c566c3a88b6ece59b3d70f65bedef17304f48eb52ff040a6a18214e1917b3254", size = 13700516, upload-time = "2026-04-21T17:11:33.161Z" }, + { url = "https://files.pythonhosted.org/packages/07/05/c61a140aba4c729ac7bc99ae26fc627c78a6e08f5b9dd319244ea71a3d7e/mypy-1.20.2-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:0deb80d062b2479f2c87ae568f89845afc71d11bc41b04179e58165fd9f31e98", size = 14562889, upload-time = "2026-04-21T17:05:27.674Z" }, + { url = "https://files.pythonhosted.org/packages/fd/87/da78243742ffa8a36d98c3010f0d829f93d5da4e6786f1a1a6f2ad616502/mypy-1.20.2-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:bba9ad231e92a3e424b3e56b65aa17704993425bba97e302c832f9466bb85bac", size = 14803844, upload-time = "2026-04-21T17:10:06.2Z" }, + { url = "https://files.pythonhosted.org/packages/37/52/10a1ddf91b40f843943a3c6db51e2df59c9e237f29d355e95eaab427461f/mypy-1.20.2-cp311-cp311-win_amd64.whl", hash = "sha256:baf593f2765fa3a6b1ef95807dbaa3d25b594f6a52adcc506a6b9cb115e1be67", size = 10846300, upload-time = "2026-04-21T17:12:23.886Z" }, + { url = "https://files.pythonhosted.org/packages/20/02/f9a4415b664c53bd34d6709be59da303abcae986dc4ac847b402edb6fa1e/mypy-1.20.2-cp311-cp311-win_arm64.whl", hash = "sha256:20175a1c0f49863946ec20b7f63255768058ac4f07d2b9ded6a6b46cfb5a9100", size = 9779498, upload-time = "2026-04-21T17:09:23.695Z" }, + { url = "https://files.pythonhosted.org/packages/71/4e/7560e4528db9e9b147e4c0f22660466bf30a0a1fe3d63d1b9d3b0fd354ee/mypy-1.20.2-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:4dbfcf869f6b0517f70cf0030ba6ea1d6645e132337a7d5204a18d8d5636c02b", size = 14539393, upload-time = "2026-04-21T17:07:12.52Z" }, + { url = "https://files.pythonhosted.org/packages/32/d9/34a5efed8124f5a9234f55ac6a4ced4201e2c5b81e1109c49ad23190ec8c/mypy-1.20.2-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:4b6481b228d072315b053210b01ac320e1be243dc17f9e5887ef167f23f5fae4", size = 13361642, upload-time = "2026-04-21T17:06:53.742Z" }, + { url = "https://files.pythonhosted.org/packages/d1/14/eb377acf78c03c92d566a1510cda8137348215b5335085ef662ab82ecd3a/mypy-1.20.2-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:34397cdced6b90b836e38182076049fdb41424322e0b0728c946b0939ebdf9f6", size = 13740347, upload-time = "2026-04-21T17:12:04.73Z" }, + { url = "https://files.pythonhosted.org/packages/b9/94/7e4634a32b641aa1c112422eed1bbece61ee16205f674190e8b536f884de/mypy-1.20.2-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:a5da6976f20cae27059ea8d0c86e7cef3de720e04c4bb9ee18e3690fdb792066", size = 14734042, upload-time = "2026-04-21T17:07:43.16Z" }, + { url = "https://files.pythonhosted.org/packages/7a/f3/f7e62395cb7f434541b4491a01149a4439e28ace4c0c632bbf5431e92d1f/mypy-1.20.2-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:56908d7e08318d39f85b1f0c6cfd47b0cac1a130da677630dac0de3e0623e102", size = 14964958, upload-time = "2026-04-21T17:11:00.665Z" }, + { url = "https://files.pythonhosted.org/packages/3e/0d/47e3c3a0ec2a876e35aeac365df3cac7776c36bbd4ed18cc521e1b9d255b/mypy-1.20.2-cp312-cp312-win_amd64.whl", hash = "sha256:d52ad8d78522da1d308789df651ee5379088e77c76cb1994858d40a426b343b9", size = 10911340, upload-time = "2026-04-21T17:10:49.179Z" }, + { url = "https://files.pythonhosted.org/packages/d6/b2/6c852d72e0ea8b01f49da817fb52539993cde327e7d010e0103dc12d0dac/mypy-1.20.2-cp312-cp312-win_arm64.whl", hash = "sha256:785b08db19c9f214dc37d65f7c165d19a30fcecb48abfa30f31b01b5acaabb58", size = 9833947, upload-time = "2026-04-21T17:09:05.267Z" }, + { url = "https://files.pythonhosted.org/packages/5b/c4/b93812d3a192c9bcf5df405bd2f30277cd0e48106a14d1023c7f6ed6e39b/mypy-1.20.2-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:edfbfca868cdd6bd8d974a60f8a3682f5565d3f5c99b327640cedd24c4264026", size = 14524670, upload-time = "2026-04-21T17:10:30.737Z" }, + { url = "https://files.pythonhosted.org/packages/f3/47/42c122501bff18eaf1e8f457f5c017933452d8acdc52918a9f59f6812955/mypy-1.20.2-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:e2877a02380adfcdbc69071a0f74d6e9dbbf593c0dc9d174e1f223ffd5281943", size = 13336218, upload-time = "2026-04-21T17:08:44.069Z" }, + { url = "https://files.pythonhosted.org/packages/92/8f/75bbc92f41725fbd585fb17b440b1119b576105df1013622983e18640a93/mypy-1.20.2-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:7488448de6007cd5177c6cea0517ac33b4c0f5ee9b5e9f2be51ce75511a85517", size = 13724906, upload-time = "2026-04-21T17:08:01.02Z" }, + { url = "https://files.pythonhosted.org/packages/a1/32/4c49da27a606167391ff0c39aa955707a00edc500572e562f7c36c08a71f/mypy-1.20.2-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:bb9c2fa06887e21d6a3a868762acb82aec34e2c6fd0174064f27c93ede68ad15", size = 14726046, upload-time = "2026-04-21T17:11:22.354Z" }, + { url = "https://files.pythonhosted.org/packages/7f/fc/4e354a1bd70216359deb0c9c54847ee6b32ef78dfb09f5131ff99b494078/mypy-1.20.2-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:9d56a78b646f2e3daa865bc70cd5ec5a46c50045801ca8ff17a0c43abc97e3ee", size = 14955587, upload-time = "2026-04-21T17:12:16.033Z" }, + { url = "https://files.pythonhosted.org/packages/62/b2/c0f2056e9eb8f08c62cafd9715e4584b89132bdc832fcf85d27d07b5f3e5/mypy-1.20.2-cp313-cp313-win_amd64.whl", hash = "sha256:2a4102b03bb7481d9a91a6da8d174740c9c8c4401024684b9ca3b7cc5e49852f", size = 10922681, upload-time = "2026-04-21T17:06:35.842Z" }, + { url = "https://files.pythonhosted.org/packages/e5/14/065e333721f05de8ef683d0aa804c23026bcc287446b61cac657b902ccac/mypy-1.20.2-cp313-cp313-win_arm64.whl", hash = "sha256:a95a9248b0c6fd933a442c03c3b113c3b61320086b88e2c444676d3fd1ca3330", size = 9830560, upload-time = "2026-04-21T17:07:51.023Z" }, + { url = "https://files.pythonhosted.org/packages/ae/d1/b4ec96b0ecc620a4443570c6e95c867903428cfcde4206518eafdd5880c3/mypy-1.20.2-cp314-cp314-macosx_10_15_x86_64.whl", hash = "sha256:419413398fe250aae057fd2fe50166b61077083c9b82754c341cf4fd73038f30", size = 14524561, upload-time = "2026-04-21T17:06:27.325Z" }, + { url = "https://files.pythonhosted.org/packages/3a/63/d2c2ff4fa66bc49477d32dfa26e8a167ba803ea6a69c5efb416036909d30/mypy-1.20.2-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:e73c07f23009962885c197ccb9b41356a30cc0e5a1d0c2ea8fd8fb1362d7f924", size = 13363883, upload-time = "2026-04-21T17:11:11.239Z" }, + { url = "https://files.pythonhosted.org/packages/2a/56/983916806bf4eddeaaa2c9230903c3669c6718552a921154e1c5182c701f/mypy-1.20.2-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:0c64e5973df366b747646fc98da921f9d6eba9716d57d1db94a83c026a08e0fb", size = 13742945, upload-time = "2026-04-21T17:08:34.181Z" }, + { url = "https://files.pythonhosted.org/packages/19/65/0cd9285ab010ee8214c83d67c6b49417c40d86ce46f1aa109457b5a9b8d7/mypy-1.20.2-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:5a65aa591af023864fd08a97da9974e919452cfe19cb146c8a5dc692626445dc", size = 14706163, upload-time = "2026-04-21T17:05:15.51Z" }, + { url = "https://files.pythonhosted.org/packages/94/97/48ff3b297cafcc94d185243a9190836fb1b01c1b0918fff64e941e973cc9/mypy-1.20.2-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:4fef51b01e638974a6e69885687e9bd40c8d1e09a6cd291cca0619625cf1f558", size = 14938677, upload-time = "2026-04-21T17:05:39.562Z" }, + { url = "https://files.pythonhosted.org/packages/fd/a1/1b4233d255bdd0b38a1f284feeb1c143ca508c19184964e22f8d837ec851/mypy-1.20.2-cp314-cp314-win_amd64.whl", hash = "sha256:913485a03f1bcf5d279409a9d2b9ed565c151f61c09f29991e5faa14033da4c8", size = 11089322, upload-time = "2026-04-21T17:06:44.29Z" }, + { url = "https://files.pythonhosted.org/packages/78/c2/ce7ee2ba36aeb954ba50f18fa25d9c1188578654b97d02a66a15b6f09531/mypy-1.20.2-cp314-cp314-win_arm64.whl", hash = "sha256:c3bae4f855d965b5453784300c12ffc63a548304ac7f99e55d4dc7c898673aa3", size = 10017775, upload-time = "2026-04-21T17:07:20.732Z" }, + { url = "https://files.pythonhosted.org/packages/4e/a1/9d93a7d0b5859af0ead82b4888b46df6c8797e1bc5e1e262a08518c6d48e/mypy-1.20.2-cp314-cp314t-macosx_10_15_x86_64.whl", hash = "sha256:2de3dcea53babc1c3237a19002bc3d228ce1833278f093b8d619e06e7cc79609", size = 15549002, upload-time = "2026-04-21T17:08:23.107Z" }, + { url = "https://files.pythonhosted.org/packages/00/d2/09a6a10ee1bf0008f6c144d9676f2ca6a12512151b4e0ad0ff6c4fac5337/mypy-1.20.2-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:52b176444e2e5054dfcbcb8c75b0b719865c96247b37407184bbfca5c353f2c2", size = 14401942, upload-time = "2026-04-21T17:07:31.837Z" }, + { url = "https://files.pythonhosted.org/packages/57/da/9594b75c3c019e805250bed3583bdf4443ff9e6ef08f97e39ae308cb06f2/mypy-1.20.2-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:688c3312e5dadb573a2c69c82af3a298d43ecf9e6d264e0f95df960b5f6ac19c", size = 15041649, upload-time = "2026-04-21T17:09:34.653Z" }, + { url = "https://files.pythonhosted.org/packages/97/77/f75a65c278e6e8eba2071f7f5a90481891053ecc39878cc444634d892abe/mypy-1.20.2-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:29752dbbf8cc53f89f6ac096d363314333045c257c9c75cbd189ca2de0455744", size = 15864588, upload-time = "2026-04-21T17:11:44.936Z" }, + { url = "https://files.pythonhosted.org/packages/d7/46/1a4e1c66e96c1a3246ddf5403d122ac9b0a8d2b7e65730b9d6533ba7a6d3/mypy-1.20.2-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:803203d2b6ea644982c644895c2f78b28d0e208bba7b27d9b921e0ec5eb207c6", size = 16093956, upload-time = "2026-04-21T17:10:17.683Z" }, + { url = "https://files.pythonhosted.org/packages/5a/2c/78a8851264dec38cd736ca5b8bc9380674df0dd0be7792f538916157716c/mypy-1.20.2-cp314-cp314t-win_amd64.whl", hash = "sha256:9bcb8aa397ff0093c824182fd76a935a9ba7ad097fcbef80ae89bf6c1731d8ec", size = 12568661, upload-time = "2026-04-21T17:11:54.473Z" }, + { url = "https://files.pythonhosted.org/packages/83/01/cd7318aa03493322ce275a0e14f4f52b8896335e4e79d4fb8153a7ad2b77/mypy-1.20.2-cp314-cp314t-win_arm64.whl", hash = "sha256:e061b58443f1736f8a37c48978d7ab581636d6ab03e3d4f99e3fa90463bb9382", size = 10389240, upload-time = "2026-04-21T17:09:42.719Z" }, + { url = "https://files.pythonhosted.org/packages/28/9a/f23c163e25b11074188251b0b5a0342625fc1cdb6af604757174fa9acc9b/mypy-1.20.2-py3-none-any.whl", hash = "sha256:a94c5a76ab46c5e6257c7972b6c8cff0574201ca7dc05647e33e795d78680563", size = 2637314, upload-time = "2026-04-21T17:05:54.5Z" }, +] + +[[package]] +name = "mypy-extensions" +version = "1.2.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/d0/6f/43edf3be2748d0e40974a5ee046a8bb4c9961a4bdd3e7d5c6dcbf32d1af6/mypy_extensions-1.2.0.tar.gz", hash = "sha256:c6e275a07f1c2fc096b62940452d0eaa3f3af7de45d704787866240a7c6d5a51", size = 6566, upload-time = "2026-11-03T16:26:33.692Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/b5/99/7b1adac7e97ce7bbda34792dc6e9b2f5cc5cffd1875883f78a818b2a2687/mypy_extensions-1.2.0-py3-none-any.whl", hash = "sha256:993e7a20aa5671eb41a7132cf555af30062da99729601601b9a8382b11cae768", size = 5114, upload-time = "2026-11-03T16:26:32.731Z" }, ] [[package]] name = "nodeenv" -version = "1.9.1" +version = "1.11.0" source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/43/16/fc88b08840de0e0a72a2f9d8c6bae36be573e475a6326ae854bcc549fc45/nodeenv-1.9.1.tar.gz", hash = "sha256:6ec12890a2dab7946721edbfbcd91f3319c6ccc9aec47be7c7e6b7011ee6645f", size = 47437, upload-time = "2024-06-04T18:44:11.171Z" } +sdist = { url = "https://files.pythonhosted.org/packages/9a/8e/105de02c1322cfada6d9710d9146ef8026419d433c9d08359a2d35805811/nodeenv-1.11.0.tar.gz", hash = "sha256:3ce8fe5b71d16e8af7039ca65257354100bc772965d6bc549070649e53b1b146", size = 99301, upload-time = "2026-09-26T11:29:21.367Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/d2/1d/1b658dbd2b9fa9c4c9f32accbfc0205d532c8c6194dc0f2a4c0428e7128a/nodeenv-1.9.1-py2.py3-none-any.whl", hash = "sha256:ba11c9782d29c27c70ffbdda2d7415098754709be8a7056d79a737cd901155c9", size = 22314, upload-time = "2024-06-04T18:44:08.352Z" }, + { url = "https://files.pythonhosted.org/packages/54/c8/12811c9b48fde162bb72b6f2e78fada9a247a09d7bb5be2050a5d099c77b/nodeenv-1.11.0-py2.py3-none-any.whl", hash = "sha256:edaa16e6c14d7cf395d75d4bbd5a26390f4dc06501a33b4e76282b02cc688a25", size = 34277, upload-time = "2026-09-26T11:29:19.933Z" }, ] [[package]] name = "packaging" -version = "25.0" +version = "26.3" source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/a1/d4/1fc4078c65507b51b96ca8f8c3ba19e6a61c8253c72794544580a7b6c24d/packaging-25.0.tar.gz", hash = "sha256:d443872c98d677bf60f6a1f2f8c1cb748e8fe762d2bf9d3148b5599295b0fc4f", size = 165727, upload-time = "2025-04-19T11:48:59.673Z" } +sdist = { url = "https://files.pythonhosted.org/packages/7d/fa/3944b40b07da9ce895c0e6303a5ab7d53da063554f534556b134a54d6093/packaging-26.3.tar.gz", hash = "sha256:94edc256424af38762eb31306eed28beb9f0efc50a8837492c9d6fd6004aed79", size = 313412, upload-time = "2026-08-04T18:15:28.737Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/20/12/38679034af332785aac8774540895e234f4d07f7545804097de4b666afd8/packaging-25.0-py3-none-any.whl", hash = "sha256:29572ef2b1f17581046b3a2227d5c611fb25ec70ca1ba8554b24b0e69331a484", size = 66469, upload-time = "2025-04-19T11:48:57.875Z" }, + { url = "https://files.pythonhosted.org/packages/63/34/ba1c580383c9eada3711951fef0795c80b829a078d72188184bcab9dd527/packaging-26.3-py3-none-any.whl", hash = "sha256:d7193f7c8e4e93f444fde0262bf90af30e16fa0ad0ad44cb553c87339b23cd1c", size = 129956, upload-time = "2026-08-04T18:15:27.159Z" }, +] + +[[package]] +name = "paginate" +version = "0.5.7" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/ec/46/68dde5b6bc00c1296ec6466ab27dddede6aec9af1b99090e1107091b3b84/paginate-0.5.7.tar.gz", hash = "sha256:22bd083ab41e1a8b4f3690544afb2c60c25e5c9a63a30fa2f483f6c60c8e5945", size = 19252, upload-time = "2024-08-25T14:17:24.139Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/90/96/04b8e52da071d28f5e21a805b19cb9390aa17a47462ac87f5e2696b9566d/paginate-0.5.7-py2.py3-none-any.whl", hash = "sha256:b885e2af73abcf01d9559fd5216b57ef722f8c42affbb63942377668e35c7591", size = 13746, upload-time = "2024-08-25T14:17:22.55Z" }, ] [[package]] @@ -793,22 +1396,31 @@ dependencies = [ ] sdist = { url = "https://files.pythonhosted.org/packages/10/9a/e3186e760c57ee5f1c27ea5cea577a0ff9abfca51eefcb4d9a4cd39aff2e/pandoc-2.4.tar.gz", hash = "sha256:ecd1f8cbb7f4180c6b5db4a17a7c1a74df519995f5f186ef81ce72a9cbd0dd9a", size = 34635, upload-time = "2024-08-07T14:33:58.016Z" } +[[package]] +name = "pathspec" +version = "1.1.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/5a/82/42f767fc1c1143d6fd36efb827202a2d997a375e160a71eb2888a925aac1/pathspec-1.1.1.tar.gz", hash = "sha256:17db5ecd524104a120e173814c90367a96a98d07c45b2e10c2f3919fff91bf5a", size = 135180, upload-time = "2026-04-27T01:46:08.907Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/f1/d9/7fb5aa316bc299258e68c73ba3bddbc499654a07f151cba08f6153988714/pathspec-1.1.1-py3-none-any.whl", hash = "sha256:a00ce642f577bf7f473932318056212bc4f8bfdf53128c78bbd5af0b9b20b189", size = 57328, upload-time = "2026-04-27T01:46:07.06Z" }, +] + [[package]] name = "platformdirs" -version = "4.5.1" +version = "4.12.4" source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/cf/86/0248f086a84f01b37aaec0fa567b397df1a119f73c16f6c7a9aac73ea309/platformdirs-4.5.1.tar.gz", hash = "sha256:61d5cdcc6065745cdd94f0f878977f8de9437be93de97c1c12f853c9c0cdcbda", size = 21715, upload-time = "2025-12-05T13:52:58.638Z" } +sdist = { url = "https://files.pythonhosted.org/packages/90/a1/d5f9002a70298c64a789779077d8dd90c10aa1f47fe40c86802df874f2a6/platformdirs-4.12.4.tar.gz", hash = "sha256:63743c02414e755de4e31b8f68125c1407495b86c5a006e203c01ff8b9924250", size = 60010, upload-time = "2026-10-07T23:30:32.426Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/cb/28/3bfe2fa5a7b9c46fe7e13c97bda14c895fb10fa2ebf1d0abb90e0cea7ee1/platformdirs-4.5.1-py3-none-any.whl", hash = "sha256:d03afa3963c806a9bed9d5125c8f4cb2fdaf74a55ab60e5d59b3fde758104d31", size = 18731, upload-time = "2025-12-05T13:52:56.823Z" }, + { url = "https://files.pythonhosted.org/packages/f4/ba/223e00b885e960edd5d4b4d178c88acce019bd5b83786093681b8c393492/platformdirs-4.12.4-py3-none-any.whl", hash = "sha256:78bfb9db2a8471ed7eebe3c3c932da413911042994e699b384fbb4493fa872d7", size = 32596, upload-time = "2026-10-07T23:30:30.825Z" }, ] [[package]] name = "pluggy" -version = "1.6.0" +version = "1.7.0" source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/f9/e2/3e91f31a7d2b083fe6ef3fa267035b518369d9511ffab804f839851d2779/pluggy-1.6.0.tar.gz", hash = "sha256:7dcc130b76258d33b90f61b658791dede3486c3e6bfb003ee5c9bfb396dd22f3", size = 69412, upload-time = "2025-05-15T12:30:07.975Z" } +sdist = { url = "https://files.pythonhosted.org/packages/bf/db/7fc19e6f2dc92a966727031389fc2e08b558f0f25eb7403c1119ad4713cd/pluggy-1.7.0.tar.gz", hash = "sha256:d1eaa46ebb595891b860ab086b4d09c8588af65ebd4361b8e8f4bb8920b90ba8", size = 123304, upload-time = "2026-10-15T09:50:58.343Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/54/20/4d324d65cc6d9205fabedc306948156824eb9f0ee1633355a8f7ec5c66bf/pluggy-1.6.0-py3-none-any.whl", hash = "sha256:e920276dd6813095e9377c0bc5566d94c932c33b27a3e3945d8389c374dd4746", size = 20538, upload-time = "2025-05-15T12:30:06.134Z" }, + { url = "https://files.pythonhosted.org/packages/40/9e/2b38731e0fc536806f16490e1a12d7f0dc2a1235aa8cc07bcc75416a7daa/pluggy-1.7.0-py3-none-any.whl", hash = "sha256:7dd7b0d8832ba3cb632c306926ded123429211b83641b35dc5c41ad2d34f9bec", size = 27082, upload-time = "2026-10-15T09:50:56.808Z" }, ] [[package]] @@ -862,11 +1474,24 @@ wheels = [ [[package]] name = "pygments" -version = "2.19.2" +version = "2.21.0" source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/b0/77/a5b8c569bf593b0140bde72ea885a803b82086995367bf2037de0159d924/pygments-2.19.2.tar.gz", hash = "sha256:636cb2477cec7f8952536970bc533bc43743542f70392ae026374600add5b887", size = 4968631, upload-time = "2025-06-21T13:39:12.283Z" } +sdist = { url = "https://files.pythonhosted.org/packages/49/2e/ced460408999b33da6b31b0021b0f37d329e202d4169aeb164493778f25b/pygments-2.21.0.tar.gz", hash = "sha256:610ca751c9bc2492b38eb9a38a7fbc93edbbb2d7182edaf34e66ae493dee5c8c", size = 5005329, upload-time = "2026-08-17T08:02:48.824Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/c7/21/705964c7812476f378728bdf590ca4b771ec72385c533964653c68e86bdc/pygments-2.19.2-py3-none-any.whl", hash = "sha256:86540386c03d588bb81d44bc3928634ff26449851e99741617ecb9037ee5ec0b", size = 1225217, upload-time = "2025-06-21T13:39:07.939Z" }, + { url = "https://files.pythonhosted.org/packages/71/46/17f022dd3e953bf20a04a028a21ec746d942f8d2af30fa0f124fa0e6a684/pygments-2.21.0-py3-none-any.whl", hash = "sha256:2363c69b61c4a97c838da3b130dcd6468f4848992b21a82f2a63ec34377137d9", size = 1250147, upload-time = "2026-08-17T08:02:44.912Z" }, +] + +[[package]] +name = "pymdown-extensions" +version = "10.21.3" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "markdown", marker = "python_full_version < '3.15'" }, + { name = "pyyaml", marker = "python_full_version < '3.15'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/9e/26/d1015444da4d952a1ca487a236b522eb979766f0295a0bd0c5fc089989a9/pymdown_extensions-10.21.3.tar.gz", hash = "sha256:72cfcf55f07aea0d4af2c4f11dd4e52466ddfb1bb819673146398e0bd3a77354", size = 854140, upload-time = "2026-05-13T12:57:32.267Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/7e/85/545a951eecc270fcd688288c600017e2050a1aacb56c711d208586d3e470/pymdown_extensions-10.21.3-py3-none-any.whl", hash = "sha256:d7a5d08014fc571e80ca21dd6f854e31f94c489800350564d55d15b3c41e76b6", size = 269002, upload-time = "2026-05-13T12:57:30.296Z" }, ] [[package]] @@ -880,15 +1505,15 @@ wheels = [ [[package]] name = "pyproject-api" -version = "1.10.0" +version = "1.11.4" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "packaging", marker = "python_full_version < '3.15'" }, { name = "tomli", marker = "python_full_version < '3.11'" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/45/7b/c0e1333b61d41c69e59e5366e727b18c4992688caf0de1be10b3e5265f6b/pyproject_api-1.10.0.tar.gz", hash = "sha256:40c6f2d82eebdc4afee61c773ed208c04c19db4c4a60d97f8d7be3ebc0bbb330", size = 22785, upload-time = "2025-10-09T19:12:27.21Z" } +sdist = { url = "https://files.pythonhosted.org/packages/d1/82/9cec47d1613bd5cdd918b82a6ffe54924c5462f1e14c59c71ef238fbc9cf/pyproject_api-1.11.4.tar.gz", hash = "sha256:42332ebb8e5e510a3a9ea498cedb5723134ddd46ddfe2d07693917b2ebea22a7", size = 25169, upload-time = "2026-10-07T23:24:01.089Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/54/cc/cecf97be298bee2b2a37dd360618c819a2a7fd95251d8e480c1f0eb88f3b/pyproject_api-1.10.0-py3-none-any.whl", hash = "sha256:8757c41a79c0f4ab71b99abed52b97ecf66bd20b04fa59da43b5840bac105a09", size = 13218, upload-time = "2025-10-09T19:12:24.428Z" }, + { url = "https://files.pythonhosted.org/packages/d3/2f/ff5b8a99a33094a83e0e5c5b4cdf7b1fcc19dd009ff4acc1a749dcc18332/pyproject_api-1.11.4-py3-none-any.whl", hash = "sha256:30921dec1f85946dd47664536a003b2aea3a8be18e334c93ed12f6a8b1e60c76", size = 13563, upload-time = "2026-10-07T23:23:59.699Z" }, ] [[package]] @@ -933,6 +1558,49 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/9d/7a/d968e294073affff457b041c2be9868a40c1c71f4a35fcc1e45e5493067b/pytest_cov-7.1.0-py3-none-any.whl", hash = "sha256:a0461110b7865f9a271aa1b51e516c9a95de9d696734a2f71e3e78f46e1d4678", size = 22876, upload-time = "2026-03-21T20:11:14.438Z" }, ] +[[package]] +name = "python-dateutil" +version = "3.0.0" +source = { registry = "https://pypi.org/simple" } +resolution-markers = [ + "python_full_version < '3.11'", +] +dependencies = [ + { name = "six", marker = "python_full_version < '3.11'" }, + { name = "tzdata", marker = "python_full_version < '3.11'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/0e/df/f15f80383f152452d8985b36d95cb8751f901a3e0ff4cd27f7e118f168e2/python_dateutil-3.0.0.tar.gz", hash = "sha256:7ebcb3c29a92f3ceafe79a7a48a5c45677e9e004bbeec5742ac0bbb00560b7a2", size = 271066, upload-time = "2026-10-21T23:41:45.075Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/5a/17/cebee01d1c0c1441174cf0456ddc91b280d79acb65340c05e41d77866ee8/python_dateutil-3.0.0-py2.py3-none-any.whl", hash = "sha256:3c79630202e4152c6add678446984236efe4f57e84d8e892aab0637bab82e9fd", size = 94659, upload-time = "2026-10-21T23:41:43.431Z" }, +] + +[[package]] +name = "python-dateutil" +version = "4.0.0" +source = { registry = "https://pypi.org/simple" } +resolution-markers = [ + "python_full_version >= '3.11' and python_full_version < '3.15'", +] +dependencies = [ + { name = "tzdata", marker = "python_full_version >= '3.11' and python_full_version < '3.15'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/18/39/b3927f3616f6223832f9b760e4208e8a7c7e1dea2b4d9ad7d32a5d214c3a/python_dateutil-4.0.0.tar.gz", hash = "sha256:d7295ff14fdc0f92f662100bfb6c551d160ca090f2939f1ec5b9794265c03f06", size = 250419, upload-time = "2026-11-01T07:02:42.426Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/2f/a9/52b89563d154433d79b51ed1eb4842bf7334cb2696891a7fe135618853d7/python_dateutil-4.0.0-py3-none-any.whl", hash = "sha256:a5e246f79eb80475e691bf93862cead98decd8a498cf53ba0516fcdc0f50dc1c", size = 92853, upload-time = "2026-11-01T07:02:40.797Z" }, +] + +[[package]] +name = "python-discovery" +version = "1.9.5" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "filelock", marker = "python_full_version < '3.15'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/68/55/70b46fae646bc6f5cb5e82569949d925cff1c7b5ce20ec4a11e0d977f8c6/python_discovery-1.9.5.tar.gz", hash = "sha256:86279f5d2728bc067de28b7ddc571be2eacc2ae0e7048f8629d2481a0f8848a2", size = 141121, upload-time = "2026-11-06T15:32:11.331Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/ac/35/25bd092ca8a7e71192afdca67fbff4f797da74408e74ac3626e13b409ec0/python_discovery-1.9.5-py3-none-any.whl", hash = "sha256:a1fae8fca11e4bc61e38491c2aafff29e430b3c5e272d51ae52fb895bc4c0fac", size = 44377, upload-time = "2026-11-06T15:32:09.821Z" }, +] + [[package]] name = "pywin32" version = "311" @@ -1019,6 +1687,18 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/f1/12/de94a39c2ef588c7e6455cfbe7343d3b2dc9d6b6b2f40c4c6565744c873d/pyyaml-6.0.3-cp314-cp314t-win_arm64.whl", hash = "sha256:ebc55a14a21cb14062aa4162f906cd962b28e2e9ea38f9b4391244cd8de4ae0b", size = 149341, upload-time = "2025-09-25T21:32:56.828Z" }, ] +[[package]] +name = "pyyaml-env-tag" +version = "1.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "pyyaml", marker = "python_full_version < '3.15'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/eb/2e/79c822141bfd05a853236b504869ebc6b70159afc570e1d5a20641782eaa/pyyaml_env_tag-1.1.tar.gz", hash = "sha256:2eb38b75a2d21ee0475d6d97ec19c63287a7e140231e4214969d0eac923cd7ff", size = 5737, upload-time = "2025-05-13T15:24:01.64Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/04/11/432f32f8097b03e3cd5fe57e88efb685d964e2e5178a48ed61e841f7fdce/pyyaml_env_tag-1.1-py3-none-any.whl", hash = "sha256:17109e1a528561e32f026364712fee1264bc2ea6715120891174ed1b980d2e04", size = 4722, upload-time = "2025-05-13T15:23:59.629Z" }, +] + [[package]] name = "referencing" version = "0.37.0" @@ -1170,6 +1850,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/d1/b7/b95708304cd49b7b6f82fdd039f1748b66ec2b21d6a45180910802f1abf1/rpds_py-0.30.0-pp311-pypy311_pp73-musllinux_1_2_x86_64.whl", hash = "sha256:ac37f9f516c51e5753f27dfdef11a88330f04de2d564be3991384b2f3535d02e", size = 562191, upload-time = "2025-11-30T20:24:36.853Z" }, ] +[[package]] +name = "six" +version = "1.17.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/94/e7/b2c673351809dca68a0e064b6af791aa332cf192da575fd474ed7d6f16a2/six-1.17.0.tar.gz", hash = "sha256:ff70335d468e7eb6ec65b95b99d3a2836546063f63acc5171de367e834932a81", size = 34031, upload-time = "2024-12-04T17:35:28.174Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/b7/ce/149a00dd41f10bc29e5921b496af8b574d8413afcd5e30dfa0ed46c2cc5e/six-1.17.0-py2.py3-none-any.whl", hash = "sha256:4721f391ed90541fddacab5acf947aa0d3dc7d27b2e1e8eda2be8970586c3274", size = 11050, upload-time = "2024-12-04T17:35:26.475Z" }, +] + [[package]] name = "snowballstemmer" version = "3.0.1" @@ -1315,51 +2004,83 @@ wheels = [ [[package]] name = "tomli" -version = "2.3.0" -source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/52/ed/3f73f72945444548f33eba9a87fc7a6e969915e7b1acc8260b30e1f76a2f/tomli-2.3.0.tar.gz", hash = "sha256:64be704a875d2a59753d80ee8a533c3fe183e3f06807ff7dc2232938ccb01549", size = 17392, upload-time = "2025-10-08T22:01:47.119Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/b3/2e/299f62b401438d5fe1624119c723f5d877acc86a4c2492da405626665f12/tomli-2.3.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:88bd15eb972f3664f5ed4b57c1634a97153b4bac4479dcb6a495f41921eb7f45", size = 153236, upload-time = "2025-10-08T22:01:00.137Z" }, - { url = "https://files.pythonhosted.org/packages/86/7f/d8fffe6a7aefdb61bced88fcb5e280cfd71e08939da5894161bd71bea022/tomli-2.3.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:883b1c0d6398a6a9d29b508c331fa56adbcdff647f6ace4dfca0f50e90dfd0ba", size = 148084, upload-time = "2025-10-08T22:01:01.63Z" }, - { url = "https://files.pythonhosted.org/packages/47/5c/24935fb6a2ee63e86d80e4d3b58b222dafaf438c416752c8b58537c8b89a/tomli-2.3.0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:d1381caf13ab9f300e30dd8feadb3de072aeb86f1d34a8569453ff32a7dea4bf", size = 234832, upload-time = "2025-10-08T22:01:02.543Z" }, - { url = "https://files.pythonhosted.org/packages/89/da/75dfd804fc11e6612846758a23f13271b76d577e299592b4371a4ca4cd09/tomli-2.3.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:a0e285d2649b78c0d9027570d4da3425bdb49830a6156121360b3f8511ea3441", size = 242052, upload-time = "2025-10-08T22:01:03.836Z" }, - { url = "https://files.pythonhosted.org/packages/70/8c/f48ac899f7b3ca7eb13af73bacbc93aec37f9c954df3c08ad96991c8c373/tomli-2.3.0-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:0a154a9ae14bfcf5d8917a59b51ffd5a3ac1fd149b71b47a3a104ca4edcfa845", size = 239555, upload-time = "2025-10-08T22:01:04.834Z" }, - { url = "https://files.pythonhosted.org/packages/ba/28/72f8afd73f1d0e7829bfc093f4cb98ce0a40ffc0cc997009ee1ed94ba705/tomli-2.3.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:74bf8464ff93e413514fefd2be591c3b0b23231a77f901db1eb30d6f712fc42c", size = 245128, upload-time = "2025-10-08T22:01:05.84Z" }, - { url = "https://files.pythonhosted.org/packages/b6/eb/a7679c8ac85208706d27436e8d421dfa39d4c914dcf5fa8083a9305f58d9/tomli-2.3.0-cp311-cp311-win32.whl", hash = "sha256:00b5f5d95bbfc7d12f91ad8c593a1659b6387b43f054104cda404be6bda62456", size = 96445, upload-time = "2025-10-08T22:01:06.896Z" }, - { url = "https://files.pythonhosted.org/packages/0a/fe/3d3420c4cb1ad9cb462fb52967080575f15898da97e21cb6f1361d505383/tomli-2.3.0-cp311-cp311-win_amd64.whl", hash = "sha256:4dc4ce8483a5d429ab602f111a93a6ab1ed425eae3122032db7e9acf449451be", size = 107165, upload-time = "2025-10-08T22:01:08.107Z" }, - { url = "https://files.pythonhosted.org/packages/ff/b7/40f36368fcabc518bb11c8f06379a0fd631985046c038aca08c6d6a43c6e/tomli-2.3.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:d7d86942e56ded512a594786a5ba0a5e521d02529b3826e7761a05138341a2ac", size = 154891, upload-time = "2025-10-08T22:01:09.082Z" }, - { url = "https://files.pythonhosted.org/packages/f9/3f/d9dd692199e3b3aab2e4e4dd948abd0f790d9ded8cd10cbaae276a898434/tomli-2.3.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:73ee0b47d4dad1c5e996e3cd33b8a76a50167ae5f96a2607cbe8cc773506ab22", size = 148796, upload-time = "2025-10-08T22:01:10.266Z" }, - { url = "https://files.pythonhosted.org/packages/60/83/59bff4996c2cf9f9387a0f5a3394629c7efa5ef16142076a23a90f1955fa/tomli-2.3.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:792262b94d5d0a466afb5bc63c7daa9d75520110971ee269152083270998316f", size = 242121, upload-time = "2025-10-08T22:01:11.332Z" }, - { url = "https://files.pythonhosted.org/packages/45/e5/7c5119ff39de8693d6baab6c0b6dcb556d192c165596e9fc231ea1052041/tomli-2.3.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:4f195fe57ecceac95a66a75ac24d9d5fbc98ef0962e09b2eddec5d39375aae52", size = 250070, upload-time = "2025-10-08T22:01:12.498Z" }, - { url = "https://files.pythonhosted.org/packages/45/12/ad5126d3a278f27e6701abde51d342aa78d06e27ce2bb596a01f7709a5a2/tomli-2.3.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:e31d432427dcbf4d86958c184b9bfd1e96b5b71f8eb17e6d02531f434fd335b8", size = 245859, upload-time = "2025-10-08T22:01:13.551Z" }, - { url = "https://files.pythonhosted.org/packages/fb/a1/4d6865da6a71c603cfe6ad0e6556c73c76548557a8d658f9e3b142df245f/tomli-2.3.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:7b0882799624980785240ab732537fcfc372601015c00f7fc367c55308c186f6", size = 250296, upload-time = "2025-10-08T22:01:14.614Z" }, - { url = "https://files.pythonhosted.org/packages/a0/b7/a7a7042715d55c9ba6e8b196d65d2cb662578b4d8cd17d882d45322b0d78/tomli-2.3.0-cp312-cp312-win32.whl", hash = "sha256:ff72b71b5d10d22ecb084d345fc26f42b5143c5533db5e2eaba7d2d335358876", size = 97124, upload-time = "2025-10-08T22:01:15.629Z" }, - { url = "https://files.pythonhosted.org/packages/06/1e/f22f100db15a68b520664eb3328fb0ae4e90530887928558112c8d1f4515/tomli-2.3.0-cp312-cp312-win_amd64.whl", hash = "sha256:1cb4ed918939151a03f33d4242ccd0aa5f11b3547d0cf30f7c74a408a5b99878", size = 107698, upload-time = "2025-10-08T22:01:16.51Z" }, - { url = "https://files.pythonhosted.org/packages/89/48/06ee6eabe4fdd9ecd48bf488f4ac783844fd777f547b8d1b61c11939974e/tomli-2.3.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:5192f562738228945d7b13d4930baffda67b69425a7f0da96d360b0a3888136b", size = 154819, upload-time = "2025-10-08T22:01:17.964Z" }, - { url = "https://files.pythonhosted.org/packages/f1/01/88793757d54d8937015c75dcdfb673c65471945f6be98e6a0410fba167ed/tomli-2.3.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:be71c93a63d738597996be9528f4abe628d1adf5e6eb11607bc8fe1a510b5dae", size = 148766, upload-time = "2025-10-08T22:01:18.959Z" }, - { url = "https://files.pythonhosted.org/packages/42/17/5e2c956f0144b812e7e107f94f1cc54af734eb17b5191c0bbfb72de5e93e/tomli-2.3.0-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:c4665508bcbac83a31ff8ab08f424b665200c0e1e645d2bd9ab3d3e557b6185b", size = 240771, upload-time = "2025-10-08T22:01:20.106Z" }, - { url = "https://files.pythonhosted.org/packages/d5/f4/0fbd014909748706c01d16824eadb0307115f9562a15cbb012cd9b3512c5/tomli-2.3.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:4021923f97266babc6ccab9f5068642a0095faa0a51a246a6a02fccbb3514eaf", size = 248586, upload-time = "2025-10-08T22:01:21.164Z" }, - { url = "https://files.pythonhosted.org/packages/30/77/fed85e114bde5e81ecf9bc5da0cc69f2914b38f4708c80ae67d0c10180c5/tomli-2.3.0-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:a4ea38c40145a357d513bffad0ed869f13c1773716cf71ccaa83b0fa0cc4e42f", size = 244792, upload-time = "2025-10-08T22:01:22.417Z" }, - { url = "https://files.pythonhosted.org/packages/55/92/afed3d497f7c186dc71e6ee6d4fcb0acfa5f7d0a1a2878f8beae379ae0cc/tomli-2.3.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:ad805ea85eda330dbad64c7ea7a4556259665bdf9d2672f5dccc740eb9d3ca05", size = 248909, upload-time = "2025-10-08T22:01:23.859Z" }, - { url = "https://files.pythonhosted.org/packages/f8/84/ef50c51b5a9472e7265ce1ffc7f24cd4023d289e109f669bdb1553f6a7c2/tomli-2.3.0-cp313-cp313-win32.whl", hash = "sha256:97d5eec30149fd3294270e889b4234023f2c69747e555a27bd708828353ab606", size = 96946, upload-time = "2025-10-08T22:01:24.893Z" }, - { url = "https://files.pythonhosted.org/packages/b2/b7/718cd1da0884f281f95ccfa3a6cc572d30053cba64603f79d431d3c9b61b/tomli-2.3.0-cp313-cp313-win_amd64.whl", hash = "sha256:0c95ca56fbe89e065c6ead5b593ee64b84a26fca063b5d71a1122bf26e533999", size = 107705, upload-time = "2025-10-08T22:01:26.153Z" }, - { url = "https://files.pythonhosted.org/packages/19/94/aeafa14a52e16163008060506fcb6aa1949d13548d13752171a755c65611/tomli-2.3.0-cp314-cp314-macosx_10_13_x86_64.whl", hash = "sha256:cebc6fe843e0733ee827a282aca4999b596241195f43b4cc371d64fc6639da9e", size = 154244, upload-time = "2025-10-08T22:01:27.06Z" }, - { url = "https://files.pythonhosted.org/packages/db/e4/1e58409aa78eefa47ccd19779fc6f36787edbe7d4cd330eeeedb33a4515b/tomli-2.3.0-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:4c2ef0244c75aba9355561272009d934953817c49f47d768070c3c94355c2aa3", size = 148637, upload-time = "2025-10-08T22:01:28.059Z" }, - { url = "https://files.pythonhosted.org/packages/26/b6/d1eccb62f665e44359226811064596dd6a366ea1f985839c566cd61525ae/tomli-2.3.0-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:c22a8bf253bacc0cf11f35ad9808b6cb75ada2631c2d97c971122583b129afbc", size = 241925, upload-time = "2025-10-08T22:01:29.066Z" }, - { url = "https://files.pythonhosted.org/packages/70/91/7cdab9a03e6d3d2bb11beae108da5bdc1c34bdeb06e21163482544ddcc90/tomli-2.3.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:0eea8cc5c5e9f89c9b90c4896a8deefc74f518db5927d0e0e8d4a80953d774d0", size = 249045, upload-time = "2025-10-08T22:01:31.98Z" }, - { url = "https://files.pythonhosted.org/packages/15/1b/8c26874ed1f6e4f1fcfeb868db8a794cbe9f227299402db58cfcc858766c/tomli-2.3.0-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:b74a0e59ec5d15127acdabd75ea17726ac4c5178ae51b85bfe39c4f8a278e879", size = 245835, upload-time = "2025-10-08T22:01:32.989Z" }, - { url = "https://files.pythonhosted.org/packages/fd/42/8e3c6a9a4b1a1360c1a2a39f0b972cef2cc9ebd56025168c4137192a9321/tomli-2.3.0-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:b5870b50c9db823c595983571d1296a6ff3e1b88f734a4c8f6fc6188397de005", size = 253109, upload-time = "2025-10-08T22:01:34.052Z" }, - { url = "https://files.pythonhosted.org/packages/22/0c/b4da635000a71b5f80130937eeac12e686eefb376b8dee113b4a582bba42/tomli-2.3.0-cp314-cp314-win32.whl", hash = "sha256:feb0dacc61170ed7ab602d3d972a58f14ee3ee60494292d384649a3dc38ef463", size = 97930, upload-time = "2025-10-08T22:01:35.082Z" }, - { url = "https://files.pythonhosted.org/packages/b9/74/cb1abc870a418ae99cd5c9547d6bce30701a954e0e721821df483ef7223c/tomli-2.3.0-cp314-cp314-win_amd64.whl", hash = "sha256:b273fcbd7fc64dc3600c098e39136522650c49bca95df2d11cf3b626422392c8", size = 107964, upload-time = "2025-10-08T22:01:36.057Z" }, - { url = "https://files.pythonhosted.org/packages/54/78/5c46fff6432a712af9f792944f4fcd7067d8823157949f4e40c56b8b3c83/tomli-2.3.0-cp314-cp314t-macosx_10_13_x86_64.whl", hash = "sha256:940d56ee0410fa17ee1f12b817b37a4d4e4dc4d27340863cc67236c74f582e77", size = 163065, upload-time = "2025-10-08T22:01:37.27Z" }, - { url = "https://files.pythonhosted.org/packages/39/67/f85d9bd23182f45eca8939cd2bc7050e1f90c41f4a2ecbbd5963a1d1c486/tomli-2.3.0-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:f85209946d1fe94416debbb88d00eb92ce9cd5266775424ff81bc959e001acaf", size = 159088, upload-time = "2025-10-08T22:01:38.235Z" }, - { url = "https://files.pythonhosted.org/packages/26/5a/4b546a0405b9cc0659b399f12b6adb750757baf04250b148d3c5059fc4eb/tomli-2.3.0-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:a56212bdcce682e56b0aaf79e869ba5d15a6163f88d5451cbde388d48b13f530", size = 268193, upload-time = "2025-10-08T22:01:39.712Z" }, - { url = "https://files.pythonhosted.org/packages/42/4f/2c12a72ae22cf7b59a7fe75b3465b7aba40ea9145d026ba41cb382075b0e/tomli-2.3.0-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:c5f3ffd1e098dfc032d4d3af5c0ac64f6d286d98bc148698356847b80fa4de1b", size = 275488, upload-time = "2025-10-08T22:01:40.773Z" }, - { url = "https://files.pythonhosted.org/packages/92/04/a038d65dbe160c3aa5a624e93ad98111090f6804027d474ba9c37c8ae186/tomli-2.3.0-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:5e01decd096b1530d97d5d85cb4dff4af2d8347bd35686654a004f8dea20fc67", size = 272669, upload-time = "2025-10-08T22:01:41.824Z" }, - { url = "https://files.pythonhosted.org/packages/be/2f/8b7c60a9d1612a7cbc39ffcca4f21a73bf368a80fc25bccf8253e2563267/tomli-2.3.0-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:8a35dd0e643bb2610f156cca8db95d213a90015c11fee76c946aa62b7ae7e02f", size = 279709, upload-time = "2025-10-08T22:01:43.177Z" }, - { url = "https://files.pythonhosted.org/packages/7e/46/cc36c679f09f27ded940281c38607716c86cf8ba4a518d524e349c8b4874/tomli-2.3.0-cp314-cp314t-win32.whl", hash = "sha256:a1f7f282fe248311650081faafa5f4732bdbfef5d45fe3f2e702fbc6f2d496e0", size = 107563, upload-time = "2025-10-08T22:01:44.233Z" }, - { url = "https://files.pythonhosted.org/packages/84/ff/426ca8683cf7b753614480484f6437f568fd2fda2edbdf57a2d3d8b27a0b/tomli-2.3.0-cp314-cp314t-win_amd64.whl", hash = "sha256:70a251f8d4ba2d9ac2542eecf008b3c8a9fc5c3f9f02c56a9d7952612be2fdba", size = 119756, upload-time = "2025-10-08T22:01:45.234Z" }, - { url = "https://files.pythonhosted.org/packages/77/b8/0135fadc89e73be292b473cb820b4f5a08197779206b33191e801feeae40/tomli-2.3.0-py3-none-any.whl", hash = "sha256:e95b1af3c5b07d9e643909b5abbec77cd9f1217e6d0bca72b0234736b9fb1f1b", size = 14408, upload-time = "2025-10-08T22:01:46.04Z" }, +version = "2.5.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/b0/78/9ad63712633ed3ab5cc1a648d863d7e7da371e9425e209555a0fe711b695/tomli-2.5.0.tar.gz", hash = "sha256:264507556cd8b8c8e7c6ee037cdf443a463f03f4c958e57195e3d369711b8ff6", size = 17662, upload-time = "2026-10-07T12:23:37.892Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/22/a6/ab99b60ee52acd949684febabc3005d0045d0f66bebd9cdebd67372d26dd/tomli-2.5.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:c4dc1c1781f2f716de763d1e9a7b34c6a894e167e291c7c5d16c72f7a9538545", size = 163901, upload-time = "2026-10-07T12:22:15.601Z" }, + { url = "https://files.pythonhosted.org/packages/bc/00/ee01b7ed4579180fff07142d290257f25ba786f23f3ec6005f620933c2f5/tomli-2.5.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:eff8babca5a7999bc137acbc7482a8b7e17ffca5075ab41f5d770ab408c7bfef", size = 163756, upload-time = "2026-10-07T12:22:16.957Z" }, + { url = "https://files.pythonhosted.org/packages/72/c2/4efebf65372f6583185f79799312109dddb61102d47e5c33dcfd1a297aca/tomli-2.5.0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:86665cee9c4835b7a7f1e8ec2c719b5258d4dc782887aded5a8ae7352a96843b", size = 268038, upload-time = "2026-10-07T12:22:18.135Z" }, + { url = "https://files.pythonhosted.org/packages/53/07/5850468e925d898abb36038666f9c333a94d2a223e802a8ba5b6d319d23f/tomli-2.5.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:d7e369fd63331746182360977b1892bfc215476a30d61612d732425311639f56", size = 276422, upload-time = "2026-10-07T12:22:19.567Z" }, + { url = "https://files.pythonhosted.org/packages/b4/87/f293984cdcf83c054196d4fd3dad44fc68ae55b4b8c44bc76cef360c3150/tomli-2.5.0-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:7ad1ea345759240d6463efa0ed1c704402752e49aa21476620738d74d72d8aa1", size = 272616, upload-time = "2026-10-07T12:22:20.794Z" }, + { url = "https://files.pythonhosted.org/packages/ce/ce/db582886b3c1219d3fec93ebd669332482e5aee7a91e0f7838d84f2d1759/tomli-2.5.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:96243987194634bd411066ce40c952e108f86af04db533ecd8ac3ff2a85b1885", size = 276593, upload-time = "2026-10-07T12:22:22.12Z" }, + { url = "https://files.pythonhosted.org/packages/bf/72/7619b87dea4261fc27dd7b54c4461c129c1f7d9bb7ba3aec89c797a431b8/tomli-2.5.0-cp311-cp311-win32.whl", hash = "sha256:610b27d99f28ec5f191c7064a48f3ddb179a1fe6ca73d571483ae859f57b605e", size = 101830, upload-time = "2026-10-07T12:22:23.651Z" }, + { url = "https://files.pythonhosted.org/packages/1e/74/220106da34502304b6751a2a9b8a9fbca6c3fd47e737a2e2e3da7c61c9db/tomli-2.5.0-cp311-cp311-win_amd64.whl", hash = "sha256:c804ae44fe7b4bab5da295e4f980a1ff04670bca9d23fe0a4e887e08ebd741a8", size = 112742, upload-time = "2026-10-07T12:22:24.972Z" }, + { url = "https://files.pythonhosted.org/packages/27/99/7d9c8b41837a7773613e169504147375c157a290167aa59ad74a085f521f/tomli-2.5.0-cp311-cp311-win_arm64.whl", hash = "sha256:cfac177ebd6236003846ea339981f71457cb6eb748f23381eb257e45092e3980", size = 109332, upload-time = "2026-10-07T12:22:26.117Z" }, + { url = "https://files.pythonhosted.org/packages/52/ed/7baa86f87493646a594de388c7c1c40a39dd0461f7e9c0359cbeefc91fe8/tomli-2.5.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:1f4a40d03fb9f63424f0979855bdeaf44dd7696b8d59501822c10ed30ba532df", size = 164854, upload-time = "2026-10-07T12:22:27.444Z" }, + { url = "https://files.pythonhosted.org/packages/a5/b1/44c0341f2224397855723c7a8a39f718ea6fcbcc3dacc66e5aeca0f334e3/tomli-2.5.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:9ebf8d19b17bd0daeb7b7dec81a946a439b753942fd0210d6e96c532249eea6b", size = 164074, upload-time = "2026-10-07T12:22:28.679Z" }, + { url = "https://files.pythonhosted.org/packages/23/04/e2d5b7d3fba47adedb23de616c16d428ea076c79a3d8e1d95d649ffe197e/tomli-2.5.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:bf0b5e8e0f68ebb494356e577c06c139161efd8d3b9050f93b39b7c26cc54ff0", size = 274274, upload-time = "2026-10-07T12:22:29.804Z" }, + { url = "https://files.pythonhosted.org/packages/43/90/6090e706ff27a6f89f4a40578e3324b95c3cd8c4150868aabf33a8f414c3/tomli-2.5.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:6cf74416bdc94ae458b14e37286c1073081850ac8459a00d0c5efef5d44294c6", size = 286435, upload-time = "2026-10-07T12:22:31.297Z" }, + { url = "https://files.pythonhosted.org/packages/0a/9e/a2c40768df16c408f22430afb0a73e9d7e5f79c950884954649d1146b74d/tomli-2.5.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:61ea1ebe1e55a34ea8199cc8dbff398d35027b82271c8ac4802fd3a1fd5b1bcc", size = 278119, upload-time = "2026-10-07T12:22:32.601Z" }, + { url = "https://files.pythonhosted.org/packages/12/25/3c0cb485b98e9cfac495629b1c93c87ccf0b72fbe9d2689fd8fe62c6d5a3/tomli-2.5.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:ed53f7e89bb04f6d9e8e7799112360b0c4d5cbff067de0814c98c37c39b920f7", size = 286177, upload-time = "2026-10-07T12:22:33.745Z" }, + { url = "https://files.pythonhosted.org/packages/77/8b/0144c65f0e37e51c18d04ae15c21b19431c165002d0131fe9aa8b0b8b1e8/tomli-2.5.0-cp312-cp312-win32.whl", hash = "sha256:e7ad033e27a516a233bea839cdb77b80146facb3b4f40bf02cd0cac165cdd5c2", size = 102760, upload-time = "2026-10-07T12:22:34.887Z" }, + { url = "https://files.pythonhosted.org/packages/de/32/5d6d8f42fc9a05fce69354e00ff256484192f5f2fc9a2165718fa0de61ec/tomli-2.5.0-cp312-cp312-win_amd64.whl", hash = "sha256:bd05de8c1698f8413dd7d869492693a0bf2211543b787ac78cd5e7536af1a6d7", size = 112722, upload-time = "2026-10-07T12:22:36.162Z" }, + { url = "https://files.pythonhosted.org/packages/30/65/df18032218db0fb9b769fb23c8039a051f15c811993995ea04c350273a32/tomli-2.5.0-cp312-cp312-win_arm64.whl", hash = "sha256:069435bd5480429b98c5e5afb02ab21c219b6f0064680671c6dc0d46817346ea", size = 109534, upload-time = "2026-10-07T12:22:37.296Z" }, + { url = "https://files.pythonhosted.org/packages/42/e5/51736d70da209350969e15aca5c5ab6e2ce1ea87a0a892a6c13aec172a86/tomli-2.5.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:943276cf269e0071948d9ff697159c1735e623c1151d88abb09b74659ef0cbea", size = 163328, upload-time = "2026-10-07T12:22:38.373Z" }, + { url = "https://files.pythonhosted.org/packages/ec/55/086f80dab4ab497602644274e6dea7ec5dd0b4e262e443a8ad3bb7edee2d/tomli-2.5.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:463b16086865b97facd8d0b3fb4cb7c544e3f58d2a69dc3113d6db9653fdb043", size = 162246, upload-time = "2026-10-07T12:22:39.673Z" }, + { url = "https://files.pythonhosted.org/packages/aa/eb/3ecc94459f3635c92321f4e7bde571323fdb2267c50e19e3188a281eae3b/tomli-2.5.0-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:1245a6638fc4bb0a60af38a7d45413db34a13842027c77597c712c998c62fdf0", size = 272655, upload-time = "2026-10-07T12:22:41.08Z" }, + { url = "https://files.pythonhosted.org/packages/c0/d7/494fd1f0c37a621f1ad9975c2efadb523e8101f144ed6edb2e7fe64738f2/tomli-2.5.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:5d8bac3d603c97e6854424e5b2b5b741bdbde387e09f162fb0446812b4a8362b", size = 283595, upload-time = "2026-10-07T12:22:42.222Z" }, + { url = "https://files.pythonhosted.org/packages/70/51/bb8d62b1317e6640866f6949b2d5855e5300f2c99d46de1cd245570bba65/tomli-2.5.0-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:21e4cae4114aba25aa0d4f85cdf486d290fb35c0954d7bba536248da64d43066", size = 276253, upload-time = "2026-10-07T12:22:43.625Z" }, + { url = "https://files.pythonhosted.org/packages/66/f4/f46bd7f0763cd47de2db697dca9257c6a4adfd1a93b018cc75c8190ed5a8/tomli-2.5.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:bbaefc84548d754be821bba7c4141c4787dda182f9e77f2f87b71213529efa7b", size = 283582, upload-time = "2026-10-07T12:22:44.983Z" }, + { url = "https://files.pythonhosted.org/packages/ac/03/70f2bcb2923a6db37818d917e124270a7f4cfd38ea576f5aa753a91c0ef5/tomli-2.5.0-cp313-cp313-win32.whl", hash = "sha256:abdbf6313b8d9efe157edeb7ab6eae4de064b1300ad31abf73755154b30abe68", size = 102628, upload-time = "2026-10-07T12:22:46.508Z" }, + { url = "https://files.pythonhosted.org/packages/dc/98/d52024bb5b0ff68b4f0d276d867f634c84a67319a7e9f6b7708a37742333/tomli-2.5.0-cp313-cp313-win_amd64.whl", hash = "sha256:fd4dc129784e0c5335bd4e61dfcc4487499a013419e655cf2da1d091b7e0efdc", size = 113301, upload-time = "2026-10-07T12:22:47.647Z" }, + { url = "https://files.pythonhosted.org/packages/6f/f2/540db3a70572a8c23a28aba3e9c358ce0ffffbafc990905c1343aa265b31/tomli-2.5.0-cp313-cp313-win_arm64.whl", hash = "sha256:69491c143d2fe063046e0301e62a810bed338fa4d1ce0fd870c27dc1e09b0d84", size = 109744, upload-time = "2026-10-07T12:22:48.925Z" }, + { url = "https://files.pythonhosted.org/packages/e4/49/caf6b307766eb9567664a8707e9d6be5fcc0e8903f18781c6677a60d80c7/tomli-2.5.0-cp314-cp314-macosx_10_15_x86_64.whl", hash = "sha256:d3182ee2d887e507bd67319a0a61105d1dd33facc111329559a233b772c1a105", size = 162899, upload-time = "2026-10-07T12:22:50.088Z" }, + { url = "https://files.pythonhosted.org/packages/d3/c8/68cfce773a2733a49c74f99d627fb461bd990756860099eac25617889585/tomli-2.5.0-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:521345fd1f19d45b8df87657aaa38b6f2ca3800059fadf428e7ebf479a383646", size = 162080, upload-time = "2026-10-07T12:22:51.558Z" }, + { url = "https://files.pythonhosted.org/packages/7e/b2/e5bb8651fdad593f670501a7d718b1a7f73f064d44dea15e04c04dfef45d/tomli-2.5.0-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:6e95c7614e705bfe2b04b27aa124adec59752d15813df37e2156747cab3a006b", size = 273380, upload-time = "2026-10-07T12:22:52.918Z" }, + { url = "https://files.pythonhosted.org/packages/8d/d2/9e2d7f8b1dfe0e2b34c245986ebd55c4c553ea4ce6c47c443b332673253f/tomli-2.5.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:7ac2027d37c3afbdf4bdd377f2676f6f1d2122a5be1f1137b49dced590b37e75", size = 283228, upload-time = "2026-10-07T12:22:54.173Z" }, + { url = "https://files.pythonhosted.org/packages/ba/df/ec7b876b7b1a2718bd74a3743c076fff565b04029ba33e8f61fac262739f/tomli-2.5.0-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:c414be4ed9d3cac80c42e348fa5a956117d1a48227f48026e31f59cb4a7671eb", size = 277189, upload-time = "2026-10-07T12:22:55.342Z" }, + { url = "https://files.pythonhosted.org/packages/7d/7b/e192d9eed0b9cb80da799f4d77052297fb9a2c3cc9b19f571f56ea88add6/tomli-2.5.0-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:9b03d7dc168353b4132965bde20feceabaa470e570c6f59660dfae59b1f9eeb3", size = 283632, upload-time = "2026-10-07T12:22:56.735Z" }, + { url = "https://files.pythonhosted.org/packages/84/50/ff94454e75461d75623e47401ed323d65c10aab8fe9033242c20cd2fdf32/tomli-2.5.0-cp314-cp314-win32.whl", hash = "sha256:6f041843c4d3a37245c0c056fd955b186bf8b1fb85690cbe40b81230891dc34b", size = 103535, upload-time = "2026-10-07T12:22:58.084Z" }, + { url = "https://files.pythonhosted.org/packages/54/0b/bdacf05f963bd6026ebf6eeb0beda847d1d60e03e440725c64a4e08a0afd/tomli-2.5.0-cp314-cp314-win_amd64.whl", hash = "sha256:f4b653094e18f9031102d3a1da5c729c8f222d85225b18037dac621695e46e1a", size = 114621, upload-time = "2026-10-07T12:22:59.2Z" }, + { url = "https://files.pythonhosted.org/packages/61/99/53f438fa6ae4f9d4ed0ddde3e7242b3bdc34b48c8f9948b72b9e9b127676/tomli-2.5.0-cp314-cp314-win_arm64.whl", hash = "sha256:3f89d10c1ff6a38d992c27fc8a4816af71a909e08a40ec66934240b1e74347c3", size = 111572, upload-time = "2026-10-07T12:23:00.479Z" }, + { url = "https://files.pythonhosted.org/packages/b9/20/1f88f19427d380a40e90a770e087489eaafe4aeee070ae88ed2bbec00acd/tomli-2.5.0-cp314-cp314t-macosx_10_15_x86_64.whl", hash = "sha256:e9e15b4a6c7dd6b85b5fbab29488a73f1f70de516942308daa266bf0e0aeb0d4", size = 171814, upload-time = "2026-10-07T12:23:01.914Z" }, + { url = "https://files.pythonhosted.org/packages/d0/56/cbe5079c9f9a54b9b3e27fc82f08f3cb36edee75561679f53d2380c801d6/tomli-2.5.0-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:e12bbcd32897272fb05929110362ae9ff4c1b9bb26bd9e971e71dcd3275b4c3d", size = 171324, upload-time = "2026-10-07T12:23:03.18Z" }, + { url = "https://files.pythonhosted.org/packages/2b/30/1d53fd3b0f1cb3ba542e345ec32c26aefdddc4e829e4f3429af8a4f27782/tomli-2.5.0-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:20aa36de8f2cf87237143bc1fa1aae8d6612c09118f4da21c6a684db5dd1f6f9", size = 297441, upload-time = "2026-10-07T12:23:04.345Z" }, + { url = "https://files.pythonhosted.org/packages/66/d9/0800acb6a111686f764c1b91ef15cc42a20a66a46013bb42220f1d2c61c1/tomli-2.5.0-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:22185fad8a1e622f064e78008018a0dd3323550dcb479cb7a1d296888d74024f", size = 307476, upload-time = "2026-10-07T12:23:05.671Z" }, + { url = "https://files.pythonhosted.org/packages/e8/63/30a8f3cd51b5bec37f04744bad0b0dc6160df84aad4f27b0e9283d66f221/tomli-2.5.0-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:984012f71908165449a951de2050d52f276bfe3aa5d5f570f63ddad814370374", size = 296113, upload-time = "2026-10-07T12:23:07.202Z" }, + { url = "https://files.pythonhosted.org/packages/ab/18/0b9ffc597e69c5a1e20a7823cb60d54b39a9f54e91edcb8574f022186758/tomli-2.5.0-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:f79203b3965b4000e91808aaa7c040206093f2b8bf86f455982f2274c9ccf442", size = 307725, upload-time = "2026-10-07T12:23:08.508Z" }, + { url = "https://files.pythonhosted.org/packages/ab/c7/18f8baae0b5607a60e8e19b4a7fedee43a8ff6458e3896dcbbadeeac9c22/tomli-2.5.0-cp314-cp314t-win32.whl", hash = "sha256:91294a9fb94a75542f6e46e4a2ae709bd8d9b51134098cae5cf3bea5478b6d03", size = 108546, upload-time = "2026-10-07T12:23:09.956Z" }, + { url = "https://files.pythonhosted.org/packages/72/34/4cca9739254130627bde87500b3f2b512154fe2f278efa7e2a5e10ad4bcb/tomli-2.5.0-cp314-cp314t-win_amd64.whl", hash = "sha256:f15e3e0b835a6d68b10c86bf80a3149780498d6911c93c3ffd1861d19f9200f1", size = 117814, upload-time = "2026-10-07T12:23:11.486Z" }, + { url = "https://files.pythonhosted.org/packages/7d/fb/afa530d47dd80a78fce43beac6bc6e00f84558eafcffbc6f37b21e80d056/tomli-2.5.0-cp314-cp314t-win_arm64.whl", hash = "sha256:6664b7ae7af7294256c53960a6103077f4914cec8ff98479c352f622c6f6b2f0", size = 115188, upload-time = "2026-10-07T12:23:12.728Z" }, + { url = "https://files.pythonhosted.org/packages/66/98/316fdc00f8c0939e6fe50461dd343c162d3ad51d1286eb25b7db54361d50/tomli-2.5.0-cp315-cp315-macosx_10_15_x86_64.whl", hash = "sha256:a525685c2f97da40762b8695eb7aa0af4c8344ca1905c73e4e29cb04d34607dc", size = 162775, upload-time = "2026-10-07T12:23:13.941Z" }, + { url = "https://files.pythonhosted.org/packages/c5/22/7b10fa5bb01c9539f53f69b619361b19350acc73657772ea7ac70ba309a8/tomli-2.5.0-cp315-cp315-macosx_11_0_arm64.whl", hash = "sha256:9dbb18c1cfb2f6517942fc9314437f66aa06d94436ffb1f06102ef3572f35276", size = 161406, upload-time = "2026-10-07T12:23:15.215Z" }, + { url = "https://files.pythonhosted.org/packages/9c/e7/1a069d86dfd20f1f84f71c63faed9f83c1d890bc06c27d82dc7d888fb573/tomli-2.5.0-cp315-cp315-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:752e8b1aa6a4367ef8bf6a1a1e005540f7ed055ba36d7193796812ca5404eb52", size = 273855, upload-time = "2026-10-07T12:23:16.471Z" }, + { url = "https://files.pythonhosted.org/packages/ae/83/d1ef43d1687d092ab9c235455c76e6e709483b346b056f086095c7c263a5/tomli-2.5.0-cp315-cp315-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:c47300f9bf791808f77d82747691c4bb09cb14bdf3060cca99b42cdc4361d5a7", size = 284910, upload-time = "2026-10-07T12:23:18.166Z" }, + { url = "https://files.pythonhosted.org/packages/cc/05/f4d9cf7de61822ece0c3873f30d291e324911c71a378b8bfe5ced13fd9f5/tomli-2.5.0-cp315-cp315-musllinux_1_2_aarch64.whl", hash = "sha256:19b0dd8749f4ea2f112c5fcfb3c5248390c899d7e2e173f1d91abee1fa0ff391", size = 277723, upload-time = "2026-10-07T12:23:19.355Z" }, + { url = "https://files.pythonhosted.org/packages/42/28/78262493141fa543151cf005760c3cb01d09fc28a11f993c05109902cb8c/tomli-2.5.0-cp315-cp315-musllinux_1_2_x86_64.whl", hash = "sha256:57b1c3b01fab802e2899bc3d168dca320e14165e2fd9fd584760fb4ca5826859", size = 285115, upload-time = "2026-10-07T12:23:20.698Z" }, + { url = "https://files.pythonhosted.org/packages/1a/b9/e1dab9a30bcb677b5cc5cee810609cfd64f24306a3055767dd3fda00b1e0/tomli-2.5.0-cp315-cp315-win32.whl", hash = "sha256:667e521b37a6c5ccaa044202c235b530f90177ffe2cd4a64ecc213c7dd535feb", size = 103475, upload-time = "2026-10-07T12:23:21.941Z" }, + { url = "https://files.pythonhosted.org/packages/4c/bd/31a3790c11d6ea95fcf5e6022ac0f8d0543c9b61120b730fc481bd43d3b4/tomli-2.5.0-cp315-cp315-win_amd64.whl", hash = "sha256:d747252933c8a65ef6bd8da0fbb7ce28a90eb6119d8cd00772cd528aa07b68d5", size = 114589, upload-time = "2026-10-07T12:23:23.098Z" }, + { url = "https://files.pythonhosted.org/packages/47/a2/4f6310fa699364f0e3af7ee3af88dddd9af066d33e716a0265bbe2b3ea84/tomli-2.5.0-cp315-cp315-win_arm64.whl", hash = "sha256:75dbcde8751b0a960aa3de173aa5e894d590755c6d7758b7e774c06f1dc3cbdd", size = 111493, upload-time = "2026-10-07T12:23:24.233Z" }, + { url = "https://files.pythonhosted.org/packages/68/14/00853f0b396d8971107ae1921bb5b322fdee1650d2f16bf06c20adb532e5/tomli-2.5.0-cp315-cp315t-macosx_10_15_x86_64.whl", hash = "sha256:2419c2a189551987b59d80e63ec355671283336f41c6b9b89462df679c7d0c57", size = 171380, upload-time = "2026-10-07T12:23:25.512Z" }, + { url = "https://files.pythonhosted.org/packages/89/ad/fa6949321dadee46b27363974fb197b94c911c3b0f7a5fd26d7dc18fc2a0/tomli-2.5.0-cp315-cp315t-macosx_11_0_arm64.whl", hash = "sha256:0dc598040da8d42cf20f0be588ed7004f46db12a0ac6c32e03a59dccedaaadcd", size = 170553, upload-time = "2026-10-07T12:23:26.855Z" }, + { url = "https://files.pythonhosted.org/packages/53/aa/3056c919eb3e084df3752b2cf5f865dcc04af0b27dba2f66d7b28af4633a/tomli-2.5.0-cp315-cp315t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:49096930c8d886c9bbdab62d2d0d17ce823ddeea522309a190b36245d5b49e01", size = 294428, upload-time = "2026-10-07T12:23:28.132Z" }, + { url = "https://files.pythonhosted.org/packages/96/b2/faeeb5d8769ea3832021d73e892c8391eae7b4b4f8b55a789127bd8b18a9/tomli-2.5.0-cp315-cp315t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:b8ade5023067f99fe72b88accd30d0ea05a158e9e32a11f124e731ea9695313f", size = 304909, upload-time = "2026-10-07T12:23:29.381Z" }, + { url = "https://files.pythonhosted.org/packages/f6/52/f094c09e73fb654b621716d019acb5d29bdfd1be01df80c281d552bda48d/tomli-2.5.0-cp315-cp315t-musllinux_1_2_aarch64.whl", hash = "sha256:b69564772b5c8f22ea5f498dff08cfa825045b4d4c4400529000bdf818aa3b2a", size = 293220, upload-time = "2026-10-07T12:23:30.608Z" }, + { url = "https://files.pythonhosted.org/packages/86/f5/0c30541078ca4b505ce3bd76ed931facbfec524dd018535d691d1af0a6d2/tomli-2.5.0-cp315-cp315t-musllinux_1_2_x86_64.whl", hash = "sha256:8ff3a2ca028c7eee0c777f9a092038d0a594a9fa04e215f929a22c329e2cb142", size = 305705, upload-time = "2026-10-07T12:23:32.181Z" }, + { url = "https://files.pythonhosted.org/packages/05/74/590e7d19d6a118fc5cc5704ff358e21d95b8573f6b9443b1519f29ca8825/tomli-2.5.0-cp315-cp315t-win32.whl", hash = "sha256:62fc1bc8eb03e3a9cadfca713d65614ed8e09d974a283295ffe3a831976b4dc5", size = 108432, upload-time = "2026-10-07T12:23:33.496Z" }, + { url = "https://files.pythonhosted.org/packages/1c/b8/63a75cfb27a17c38550e44025d3a6e7be64516fd8608a3b75703bf37d81b/tomli-2.5.0-cp315-cp315t-win_amd64.whl", hash = "sha256:f3fcbc57b1791fa6cbe5d8434179d51de12be1a4811469529f47f6e7487a2571", size = 117281, upload-time = "2026-10-07T12:23:34.648Z" }, + { url = "https://files.pythonhosted.org/packages/72/01/e8c1debb2173973372934c68fc8e46170ab60ef23ed4592dff4dec6e8993/tomli-2.5.0-cp315-cp315t-win_arm64.whl", hash = "sha256:d2ba24db8a9376921b5e87b4762b9adb0f3f1deaea68f2b8b0bb2c11efb9c3e7", size = 115069, upload-time = "2026-10-07T12:23:35.77Z" }, + { url = "https://files.pythonhosted.org/packages/60/3f/3e3f8fd0919249b0200c80fbc4f9a1e70be19f9883da71dfb7f8b9ab8aca/tomli-2.5.0-py3-none-any.whl", hash = "sha256:32a7b79ac57a2e83670ce329ccf675798bc5a2094783a63676866b70503f2e2b", size = 14765, upload-time = "2026-10-07T12:23:36.875Z" }, +] + +[[package]] +name = "tomli-w" +version = "1.2.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/19/75/241269d1da26b624c0d5e110e8149093c759b7a286138f4efd61a60e75fe/tomli_w-1.2.0.tar.gz", hash = "sha256:2dd14fac5a47c27be9cd4c976af5a12d87fb1f0b4512f81d69cce3b35ae25021", size = 7184, upload-time = "2025-01-15T12:07:24.262Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/c7/18/c86eb8e0202e32dd3df50d43d7ff9854f8e0603945ff398974c1d91ac1ef/tomli_w-1.2.0-py3-none-any.whl", hash = "sha256:188306098d013b691fcadc011abd66727d3c414c571bb01b1a174ba8c983cf90", size = 6675, upload-time = "2025-01-15T12:07:22.074Z" }, ] [[package]] @@ -1383,33 +2104,43 @@ wheels = [ [[package]] name = "tox" -version = "4.32.0" +version = "4.65.0" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "cachetools", marker = "python_full_version < '3.15'" }, - { name = "chardet", marker = "python_full_version < '3.15'" }, { name = "colorama", marker = "python_full_version < '3.15'" }, { name = "filelock", marker = "python_full_version < '3.15'" }, { name = "packaging", marker = "python_full_version < '3.15'" }, { name = "platformdirs", marker = "python_full_version < '3.15'" }, { name = "pluggy", marker = "python_full_version < '3.15'" }, { name = "pyproject-api", marker = "python_full_version < '3.15'" }, + { name = "python-discovery", marker = "python_full_version < '3.15'" }, { name = "tomli", marker = "python_full_version < '3.11'" }, - { name = "typing-extensions", marker = "python_full_version < '3.11'" }, + { name = "tomli-w", marker = "python_full_version < '3.15'" }, + { name = "typing-extensions", marker = "python_full_version < '3.13'" }, { name = "virtualenv", marker = "python_full_version < '3.15'" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/59/bf/0e4dbd42724cbae25959f0e34c95d0c730df03ab03f54d52accd9abfc614/tox-4.32.0.tar.gz", hash = "sha256:1ad476b5f4d3679455b89a992849ffc3367560bbc7e9495ee8a3963542e7c8ff", size = 203330, upload-time = "2025-10-24T18:03:38.132Z" } +sdist = { url = "https://files.pythonhosted.org/packages/41/05/a79f2c293f5b5b2188978b4e8b60d12c64277662de1254184769f3e96571/tox-4.65.0.tar.gz", hash = "sha256:582c4adba07b8fbeca1454b528a512dfc66c19635154289c7032555dbc72d56c", size = 333143, upload-time = "2026-10-09T20:33:09.306Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/fc/cc/e09c0d663a004945f82beecd4f147053567910479314e8d01ba71e5d5dea/tox-4.32.0-py3-none-any.whl", hash = "sha256:451e81dc02ba8d1ed20efd52ee409641ae4b5d5830e008af10fe8823ef1bd551", size = 175905, upload-time = "2025-10-24T18:03:36.337Z" }, + { url = "https://files.pythonhosted.org/packages/e0/1a/3408ad74ac353c519f7a38fbe35fe107b5fbeaa55539f189c19d0726f14c/tox-4.65.0-py3-none-any.whl", hash = "sha256:823ea3df020d7ede8f5df6ba4f374585063b39aa86140c098fbb97833543844e", size = 238074, upload-time = "2026-10-09T20:33:07.366Z" }, ] [[package]] name = "typing-extensions" -version = "4.15.0" +version = "4.16.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/f6/cc/6253133b5bb138fc3306cebfbda2c520f545d36b5be2c7255cc528bb45d6/typing_extensions-4.16.0.tar.gz", hash = "sha256:dc983d19a509c94dba722ee6abd33940f7c05a89e243c47e907eb4db6f1a43e5", size = 113555, upload-time = "2026-07-02T08:40:05.92Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/49/d3/b8441a820a491ddfc024b0b0cf0393375b75ea13866d9c66727e54c2fc80/typing_extensions-4.16.0-py3-none-any.whl", hash = "sha256:481caa481374e813c1b176ada14e97f1f67a4539ce9cfeb3f350d78d6370c2e8", size = 45571, upload-time = "2026-07-02T08:40:04.659Z" }, +] + +[[package]] +name = "tzdata" +version = "2026.6" source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/72/94/1a15dd82efb362ac84269196e94cf00f187f7ed21c242792a923cdb1c61f/typing_extensions-4.15.0.tar.gz", hash = "sha256:0cea48d173cc12fa28ecabc3b837ea3cf6f38c6d1136f85cbaaf598984861466", size = 109391, upload-time = "2025-08-25T13:49:26.313Z" } +sdist = { url = "https://files.pythonhosted.org/packages/7a/29/6a1391d31cd00ff9e927215a224a880e1e84e826b64ba80a499e51c074d8/tzdata-2026.6.tar.gz", hash = "sha256:85d2cd9c09f81f0bb29db27759fc83af4f1e620efb814f8c5bf8b4cc4feece6d", size = 201017, upload-time = "2026-10-28T09:57:09.137Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/18/67/36e9267722cc04a6b9f15c7f3441c2363321a3ea07da7ae0c0707beb2a9c/typing_extensions-4.15.0-py3-none-any.whl", hash = "sha256:f0fa19c6845758ab08074a0cfa8b7aecb71c999ca73d62883bc25cc018c4e548", size = 44614, upload-time = "2025-08-25T13:49:24.86Z" }, + { url = "https://files.pythonhosted.org/packages/0a/66/9a06c2227fedfd4919f0eaaa8b94377d9730882a7e4f95823c9a331ab5e1/tzdata-2026.6-py2.py3-none-any.whl", hash = "sha256:0a10eec6e13ef16b627fabed9a5f2ba61a62b1c67f327305f4e7e412a70b4aec", size = 348210, upload-time = "2026-10-28T09:57:07.276Z" }, ] [[package]] @@ -1423,17 +2154,108 @@ wheels = [ [[package]] name = "virtualenv" -version = "20.35.4" +version = "21.15.1" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "distlib", marker = "python_full_version < '3.15'" }, { name = "filelock", marker = "python_full_version < '3.15'" }, + { name = "packaging", marker = "python_full_version < '3.15'" }, { name = "platformdirs", marker = "python_full_version < '3.15'" }, + { name = "python-discovery", marker = "python_full_version < '3.15'" }, { name = "typing-extensions", marker = "python_full_version < '3.11'" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/20/28/e6f1a6f655d620846bd9df527390ecc26b3805a0c5989048c210e22c5ca9/virtualenv-20.35.4.tar.gz", hash = "sha256:643d3914d73d3eeb0c552cbb12d7e82adf0e504dbf86a3182f8771a153a1971c", size = 6028799, upload-time = "2025-10-29T06:57:40.511Z" } +sdist = { url = "https://files.pythonhosted.org/packages/b2/24/20282bc8e69ff8dee680dc2b95e9dc81fa7e7894b14c1a8d06330e97fef7/virtualenv-21.15.1.tar.gz", hash = "sha256:e79c90b8f601701599c25905e02839924fede2c798d52325670d24fbdaab74ee", size = 5517048, upload-time = "2026-10-28T01:12:50.919Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/79/0c/c05523fa3181fdf0c9c52a6ba91a23fbf3246cc095f26f6516f9c60e6771/virtualenv-20.35.4-py3-none-any.whl", hash = "sha256:c21c9cede36c9753eeade68ba7d523529f228a403463376cf821eaae2b650f1b", size = 6005095, upload-time = "2025-10-29T06:57:37.598Z" }, + { url = "https://files.pythonhosted.org/packages/ce/23/cdab19d3a9da42ca0938081e163e25f81e610141800ead743ba1ee881f0e/virtualenv-21.15.1-py3-none-any.whl", hash = "sha256:0d14a991689c67600316880eadc0a37b7690cb632e3b4ac67e2bc05b2b2e24a4", size = 5558848, upload-time = "2026-10-28T01:12:48.605Z" }, +] + +[[package]] +name = "watchdog" +version = "6.0.0" +source = { registry = "https://pypi.org/simple" } +resolution-markers = [ + "python_full_version < '3.11'", +] +sdist = { url = "https://files.pythonhosted.org/packages/db/7d/7f3d619e951c88ed75c6037b246ddcf2d322812ee8ea189be89511721d54/watchdog-6.0.0.tar.gz", hash = "sha256:9ddf7c82fda3ae8e24decda1338ede66e1c99883db93711d8fb941eaa2d8c282", size = 131220, upload-time = "2024-11-01T14:07:13.037Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/0c/56/90994d789c61df619bfc5ce2ecdabd5eeff564e1eb47512bd01b5e019569/watchdog-6.0.0-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:d1cdb490583ebd691c012b3d6dae011000fe42edb7a82ece80965b42abd61f26", size = 96390, upload-time = "2024-11-01T14:06:24.793Z" }, + { url = "https://files.pythonhosted.org/packages/55/46/9a67ee697342ddf3c6daa97e3a587a56d6c4052f881ed926a849fcf7371c/watchdog-6.0.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:bc64ab3bdb6a04d69d4023b29422170b74681784ffb9463ed4870cf2f3e66112", size = 88389, upload-time = "2024-11-01T14:06:27.112Z" }, + { url = "https://files.pythonhosted.org/packages/44/65/91b0985747c52064d8701e1075eb96f8c40a79df889e59a399453adfb882/watchdog-6.0.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:c897ac1b55c5a1461e16dae288d22bb2e412ba9807df8397a635d88f671d36c3", size = 89020, upload-time = "2024-11-01T14:06:29.876Z" }, + { url = "https://files.pythonhosted.org/packages/e0/24/d9be5cd6642a6aa68352ded4b4b10fb0d7889cb7f45814fb92cecd35f101/watchdog-6.0.0-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:6eb11feb5a0d452ee41f824e271ca311a09e250441c262ca2fd7ebcf2461a06c", size = 96393, upload-time = "2024-11-01T14:06:31.756Z" }, + { url = "https://files.pythonhosted.org/packages/63/7a/6013b0d8dbc56adca7fdd4f0beed381c59f6752341b12fa0886fa7afc78b/watchdog-6.0.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:ef810fbf7b781a5a593894e4f439773830bdecb885e6880d957d5b9382a960d2", size = 88392, upload-time = "2024-11-01T14:06:32.99Z" }, + { url = "https://files.pythonhosted.org/packages/d1/40/b75381494851556de56281e053700e46bff5b37bf4c7267e858640af5a7f/watchdog-6.0.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:afd0fe1b2270917c5e23c2a65ce50c2a4abb63daafb0d419fde368e272a76b7c", size = 89019, upload-time = "2024-11-01T14:06:34.963Z" }, + { url = "https://files.pythonhosted.org/packages/39/ea/3930d07dafc9e286ed356a679aa02d777c06e9bfd1164fa7c19c288a5483/watchdog-6.0.0-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:bdd4e6f14b8b18c334febb9c4425a878a2ac20efd1e0b231978e7b150f92a948", size = 96471, upload-time = "2024-11-01T14:06:37.745Z" }, + { url = "https://files.pythonhosted.org/packages/12/87/48361531f70b1f87928b045df868a9fd4e253d9ae087fa4cf3f7113be363/watchdog-6.0.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:c7c15dda13c4eb00d6fb6fc508b3c0ed88b9d5d374056b239c4ad1611125c860", size = 88449, upload-time = "2024-11-01T14:06:39.748Z" }, + { url = "https://files.pythonhosted.org/packages/5b/7e/8f322f5e600812e6f9a31b75d242631068ca8f4ef0582dd3ae6e72daecc8/watchdog-6.0.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:6f10cb2d5902447c7d0da897e2c6768bca89174d0c6e1e30abec5421af97a5b0", size = 89054, upload-time = "2024-11-01T14:06:41.009Z" }, + { url = "https://files.pythonhosted.org/packages/68/98/b0345cabdce2041a01293ba483333582891a3bd5769b08eceb0d406056ef/watchdog-6.0.0-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:490ab2ef84f11129844c23fb14ecf30ef3d8a6abafd3754a6f75ca1e6654136c", size = 96480, upload-time = "2024-11-01T14:06:42.952Z" }, + { url = "https://files.pythonhosted.org/packages/85/83/cdf13902c626b28eedef7ec4f10745c52aad8a8fe7eb04ed7b1f111ca20e/watchdog-6.0.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:76aae96b00ae814b181bb25b1b98076d5fc84e8a53cd8885a318b42b6d3a5134", size = 88451, upload-time = "2024-11-01T14:06:45.084Z" }, + { url = "https://files.pythonhosted.org/packages/fe/c4/225c87bae08c8b9ec99030cd48ae9c4eca050a59bf5c2255853e18c87b50/watchdog-6.0.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:a175f755fc2279e0b7312c0035d52e27211a5bc39719dd529625b1930917345b", size = 89057, upload-time = "2024-11-01T14:06:47.324Z" }, + { url = "https://files.pythonhosted.org/packages/30/ad/d17b5d42e28a8b91f8ed01cb949da092827afb9995d4559fd448d0472763/watchdog-6.0.0-pp310-pypy310_pp73-macosx_10_15_x86_64.whl", hash = "sha256:c7ac31a19f4545dd92fc25d200694098f42c9a8e391bc00bdd362c5736dbf881", size = 87902, upload-time = "2024-11-01T14:06:53.119Z" }, + { url = "https://files.pythonhosted.org/packages/5c/ca/c3649991d140ff6ab67bfc85ab42b165ead119c9e12211e08089d763ece5/watchdog-6.0.0-pp310-pypy310_pp73-macosx_11_0_arm64.whl", hash = "sha256:9513f27a1a582d9808cf21a07dae516f0fab1cf2d7683a742c498b93eedabb11", size = 88380, upload-time = "2024-11-01T14:06:55.19Z" }, + { url = "https://files.pythonhosted.org/packages/a9/c7/ca4bf3e518cb57a686b2feb4f55a1892fd9a3dd13f470fca14e00f80ea36/watchdog-6.0.0-py3-none-manylinux2014_aarch64.whl", hash = "sha256:7607498efa04a3542ae3e05e64da8202e58159aa1fa4acddf7678d34a35d4f13", size = 79079, upload-time = "2024-11-01T14:06:59.472Z" }, + { url = "https://files.pythonhosted.org/packages/5c/51/d46dc9332f9a647593c947b4b88e2381c8dfc0942d15b8edc0310fa4abb1/watchdog-6.0.0-py3-none-manylinux2014_armv7l.whl", hash = "sha256:9041567ee8953024c83343288ccc458fd0a2d811d6a0fd68c4c22609e3490379", size = 79078, upload-time = "2024-11-01T14:07:01.431Z" }, + { url = "https://files.pythonhosted.org/packages/d4/57/04edbf5e169cd318d5f07b4766fee38e825d64b6913ca157ca32d1a42267/watchdog-6.0.0-py3-none-manylinux2014_i686.whl", hash = "sha256:82dc3e3143c7e38ec49d61af98d6558288c415eac98486a5c581726e0737c00e", size = 79076, upload-time = "2024-11-01T14:07:02.568Z" }, + { url = "https://files.pythonhosted.org/packages/ab/cc/da8422b300e13cb187d2203f20b9253e91058aaf7db65b74142013478e66/watchdog-6.0.0-py3-none-manylinux2014_ppc64.whl", hash = "sha256:212ac9b8bf1161dc91bd09c048048a95ca3a4c4f5e5d4a7d1b1a7d5752a7f96f", size = 79077, upload-time = "2024-11-01T14:07:03.893Z" }, + { url = "https://files.pythonhosted.org/packages/2c/3b/b8964e04ae1a025c44ba8e4291f86e97fac443bca31de8bd98d3263d2fcf/watchdog-6.0.0-py3-none-manylinux2014_ppc64le.whl", hash = "sha256:e3df4cbb9a450c6d49318f6d14f4bbc80d763fa587ba46ec86f99f9e6876bb26", size = 79078, upload-time = "2024-11-01T14:07:05.189Z" }, + { url = "https://files.pythonhosted.org/packages/62/ae/a696eb424bedff7407801c257d4b1afda455fe40821a2be430e173660e81/watchdog-6.0.0-py3-none-manylinux2014_s390x.whl", hash = "sha256:2cce7cfc2008eb51feb6aab51251fd79b85d9894e98ba847408f662b3395ca3c", size = 79077, upload-time = "2024-11-01T14:07:06.376Z" }, + { url = "https://files.pythonhosted.org/packages/b5/e8/dbf020b4d98251a9860752a094d09a65e1b436ad181faf929983f697048f/watchdog-6.0.0-py3-none-manylinux2014_x86_64.whl", hash = "sha256:20ffe5b202af80ab4266dcd3e91aae72bf2da48c0d33bdb15c66658e685e94e2", size = 79078, upload-time = "2024-11-01T14:07:07.547Z" }, + { url = "https://files.pythonhosted.org/packages/07/f6/d0e5b343768e8bcb4cda79f0f2f55051bf26177ecd5651f84c07567461cf/watchdog-6.0.0-py3-none-win32.whl", hash = "sha256:07df1fdd701c5d4c8e55ef6cf55b8f0120fe1aef7ef39a1c6fc6bc2e606d517a", size = 79065, upload-time = "2024-11-01T14:07:09.525Z" }, + { url = "https://files.pythonhosted.org/packages/db/d9/c495884c6e548fce18a8f40568ff120bc3a4b7b99813081c8ac0c936fa64/watchdog-6.0.0-py3-none-win_amd64.whl", hash = "sha256:cbafb470cf848d93b5d013e2ecb245d4aa1c8fd0504e863ccefa32445359d680", size = 79070, upload-time = "2024-11-01T14:07:10.686Z" }, + { url = "https://files.pythonhosted.org/packages/33/e8/e40370e6d74ddba47f002a32919d91310d6074130fe4e17dabcafc15cbf1/watchdog-6.0.0-py3-none-win_ia64.whl", hash = "sha256:a1914259fa9e1454315171103c6a30961236f508b9b623eae470268bbcc6a22f", size = 79067, upload-time = "2024-11-01T14:07:11.845Z" }, +] + +[[package]] +name = "watchdog" +version = "7.1.0" +source = { registry = "https://pypi.org/simple" } +resolution-markers = [ + "python_full_version >= '3.11' and python_full_version < '3.15'", +] +sdist = { url = "https://files.pythonhosted.org/packages/e2/55/087e45c2a3ed8223bc9f30d6b65f051de35513cfc30c989c2b1a14bf862e/watchdog-7.1.0.tar.gz", hash = "sha256:d3861e255416f49a1384474cb2efa097de165fb330d4c5432ce6708b509ed922", size = 218748, upload-time = "2026-11-05T09:33:21.28Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/dd/d7/e6d9c38630aa844ea4ad7f2d66924926fc1f73ed770ec7f3caa773f6b874/watchdog-7.1.0-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:be3f5f953b11bde13ee3c54ae740948f61b01b6b79442f92ff5b9d0c15e5b7e7", size = 120911, upload-time = "2026-11-05T09:32:28.095Z" }, + { url = "https://files.pythonhosted.org/packages/a1/78/87400e56145c88bf6b53474110009f3bc20edfea3b8e6bfcd20faada84d9/watchdog-7.1.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:a79b77db565ae3bc9ff490df2ce51a4bdd6b344a99732055e828e8dadaaf1c97", size = 112978, upload-time = "2026-11-05T09:32:29.511Z" }, + { url = "https://files.pythonhosted.org/packages/bf/3e/dd912eaf296c3c5e279b8e6824fb0cb103523a1dae209667c1221f205480/watchdog-7.1.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:bb9182d0b0b75a78137ea9ae8d74943e53ebc3fc5ea11178fdb3da32ced6ef18", size = 113552, upload-time = "2026-11-05T09:32:30.829Z" }, + { url = "https://files.pythonhosted.org/packages/59/14/40662f61f6e09f6a0371d95d916f6fc134825a7937b3ebff08cb6be433a8/watchdog-7.1.0-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:5047bc32663aa6c8a720940072a64cd648f4c6c6f34cd43592719bcc880b7465", size = 120967, upload-time = "2026-11-05T09:32:32.212Z" }, + { url = "https://files.pythonhosted.org/packages/83/dd/a36aed1934abf1b9a827f5d5b4fab23de395526eb1bc40da34aad9f2d589/watchdog-7.1.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:24bf3345278ed7861438cd1ff162888e955250124d1e3c122f9be1d5c2a142c3", size = 112992, upload-time = "2026-11-05T09:32:33.631Z" }, + { url = "https://files.pythonhosted.org/packages/a5/4d/a490bcebc20c0c2781b0e1b2674245354502c9a62b274cc41859f4b269cd/watchdog-7.1.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:84a196f6259d18ce53cc58f211f7d0184939dbbfaaebae6efc509cec333ba9ea", size = 113581, upload-time = "2026-11-05T09:32:34.752Z" }, + { url = "https://files.pythonhosted.org/packages/c3/1f/804e62a8895212f436944ea2f13cdb3e6a7e2570b14f3723d3fef2bc9db7/watchdog-7.1.0-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:33501d3ab5627e41b6230d5f92e651ea843b1d236cf2b135959dfda2d42d2f69", size = 120813, upload-time = "2026-11-05T09:32:35.831Z" }, + { url = "https://files.pythonhosted.org/packages/30/35/59365fa94ebc1cddf89a21752eb17afef037bd534d63ab1800721540e5f4/watchdog-7.1.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:531f1a21bf0d37ea82be9a717ab92c05ab6f2f32ec6c1f2e7a748f9cfd21c8b2", size = 112905, upload-time = "2026-11-05T09:32:37.371Z" }, + { url = "https://files.pythonhosted.org/packages/41/ac/d4d6fb1bd6f25b614fa7150629b8eb3e30f7ded82f63a19b4427b140475e/watchdog-7.1.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:fb84cdb12a3c4c273d71e4e5a4f76861fbf8f49bc9ca5be86f085ab6f57c683f", size = 113516, upload-time = "2026-11-05T09:32:38.48Z" }, + { url = "https://files.pythonhosted.org/packages/d4/8c/a25dac9642a4962d70cace9ffbb9ea4e575e6a61412ba5c80569460e0c81/watchdog-7.1.0-cp314-cp314-macosx_10_15_universal2.whl", hash = "sha256:a0fdb62a48b5073ea3bcca29b9910f1cbde1026ab8bffb87a69b112bf6d97d1c", size = 122360, upload-time = "2026-11-05T09:32:39.85Z" }, + { url = "https://files.pythonhosted.org/packages/c7/56/b262a7c5acb47cb7eebc0cb25ded697ac4fbfc2d65c3a505a210ecb2b2e3/watchdog-7.1.0-cp314-cp314-macosx_10_15_x86_64.whl", hash = "sha256:8b637a1525d7e23548419368485bf1de931aca4c9e132e89a41bad52ff435fca", size = 113003, upload-time = "2026-11-05T09:32:40.873Z" }, + { url = "https://files.pythonhosted.org/packages/e0/5f/5133b328bae8ec5fab02c329c4364445459d678194c42457c9721b6f64ea/watchdog-7.1.0-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:b1a669c90ae6dc734f2a5a417f15ba30d5ef41d890bc28aef161d51bb62b7882", size = 113518, upload-time = "2026-11-05T09:32:41.924Z" }, + { url = "https://files.pythonhosted.org/packages/13/e1/0de47b185b82317696f59c0f0b9bb105f6492d6d3423cb1535ce60f70c2f/watchdog-7.1.0-cp314-cp314t-macosx_10_15_universal2.whl", hash = "sha256:4332ae52b5e530d2c25a8525d765f1d34e595cfb07096c6b6368f9da10b5a8bf", size = 123108, upload-time = "2026-11-05T09:32:43.453Z" }, + { url = "https://files.pythonhosted.org/packages/56/f7/84b94e50c73479a291733027bd572336ba5b85dca27c18982186293bd8bd/watchdog-7.1.0-cp314-cp314t-macosx_10_15_x86_64.whl", hash = "sha256:701586db59c9c421389e2e007713a821d934c3d83d034f0cafa95516a422758d", size = 113369, upload-time = "2026-11-05T09:32:44.689Z" }, + { url = "https://files.pythonhosted.org/packages/12/71/a6e482e81cb7ebe9f2aea7955254dee2865ea99a580bfeceaf53c274875d/watchdog-7.1.0-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:d4c9804d3db8e18659cd7cd968e2dbb31a655d12fcc07ec54df5ae47ff929f50", size = 113900, upload-time = "2026-11-05T09:32:45.742Z" }, + { url = "https://files.pythonhosted.org/packages/46/8b/aeeacda90fcbcf2c8c3eeb761f9dcce798b0209c4413e9f89733d4bc8c8f/watchdog-7.1.0-cp315-cp315-macosx_10_15_universal2.whl", hash = "sha256:a78673ab08b15f42760ae036f9251d02ac4107390c074963ccad4fc91cf880ac", size = 122415, upload-time = "2026-11-05T09:32:46.9Z" }, + { url = "https://files.pythonhosted.org/packages/66/07/69e1962eeccd885cc6196fea3f45f610741ca259ce9f69f372aa42e35146/watchdog-7.1.0-cp315-cp315-macosx_10_15_x86_64.whl", hash = "sha256:b0747551092578b70a4e8c48260ab956a9aa7efd2e9f7614471a7f73ada91c44", size = 113001, upload-time = "2026-11-05T09:32:48.023Z" }, + { url = "https://files.pythonhosted.org/packages/d0/9a/3beeb0a20d9907468b48bdc63e2e0e5ff858b308c46051a823280164bbcf/watchdog-7.1.0-cp315-cp315-macosx_11_0_arm64.whl", hash = "sha256:3dcf1a72c8c83a945e99965746c818bca3f50c0835b66ef1deb388d89bae792a", size = 113576, upload-time = "2026-11-05T09:32:49.407Z" }, + { url = "https://files.pythonhosted.org/packages/f1/f6/d552bd549125010e7c7d78fbb8057ee4ec6f5d258ffdc8cd6c675f9a70ef/watchdog-7.1.0-cp315-cp315t-macosx_10_15_universal2.whl", hash = "sha256:22fb8c80a2e510ec7773e4f6b2c6db869c2aed80bfb09962feb0962eb54f3ac9", size = 123152, upload-time = "2026-11-05T09:32:50.724Z" }, + { url = "https://files.pythonhosted.org/packages/c6/7e/b951aeea6d6db7a917e3c1c5a341cbb3e5c8cc02ccb9201b2715547603c3/watchdog-7.1.0-cp315-cp315t-macosx_10_15_x86_64.whl", hash = "sha256:e226f1797764c3995ff9e91ce46f1b2ae65f59ab231785ef2f62243f06ba7956", size = 113366, upload-time = "2026-11-05T09:32:52.04Z" }, + { url = "https://files.pythonhosted.org/packages/b6/ce/9e944c1d21b9b767023fb63cc764affcff1c8f4853de8e0ad14005cadbba/watchdog-7.1.0-cp315-cp315t-macosx_11_0_arm64.whl", hash = "sha256:2dc548262230493c8740c50cb0016d5983143ef3e587284d55f8a9fac393340f", size = 113951, upload-time = "2026-11-05T09:32:53.341Z" }, + { url = "https://files.pythonhosted.org/packages/2a/ab/0c57f765c0b29534e12ca4aa69fc0b1cb8437ed307c4250887ecb400d8e8/watchdog-7.1.0-pp311-pypy311_pp80-macosx_10_15_x86_64.whl", hash = "sha256:cf55c6108cce5c590661ebf3345d5203b6c6455237d73122a64acb74acc6a920", size = 112010, upload-time = "2026-11-05T09:32:54.588Z" }, + { url = "https://files.pythonhosted.org/packages/67/f8/755e32b082b3b27c3f4730874dc09d11eed5c39ffbe512d30e2662e917b8/watchdog-7.1.0-pp311-pypy311_pp80-macosx_11_0_arm64.whl", hash = "sha256:b390a8a0b85a93882d2ad27cbcc222e1e93293a5410d2ceffb48c0fdb38e0b17", size = 112577, upload-time = "2026-11-05T09:32:55.7Z" }, + { url = "https://files.pythonhosted.org/packages/33/7d/1d661f910c1f3717603b3eea0e3bd5540c7a76221371ae24bb42e0e3b049/watchdog-7.1.0-pp312-pypy312_pp80-macosx_10_15_x86_64.whl", hash = "sha256:550ff9204139b6d759cd37210935bb88f6aac42542ad17516edaf17c9b35fd41", size = 112168, upload-time = "2026-11-05T09:32:57.02Z" }, + { url = "https://files.pythonhosted.org/packages/b6/29/f3b91fe0ef86c11f508de1c189054e2b4f00be8da6043e96130f841697d0/watchdog-7.1.0-pp312-pypy312_pp80-macosx_11_0_arm64.whl", hash = "sha256:22d8869d9cb822c735923eea39d9279f03d5fd23e6d325800ac9e402e34c0a28", size = 112671, upload-time = "2026-11-05T09:32:58.143Z" }, + { url = "https://files.pythonhosted.org/packages/b3/5b/1e62e5ab365634f84afe91f8fd78563c71226056d57e36d5fcba9d99b536/watchdog-7.1.0-py3-none-manylinux2014_aarch64.whl", hash = "sha256:dbd4e701a31b9bfa686bd831177b433695f5e4dabee6aa0bdf4efcf6f0fd5b9f", size = 103268, upload-time = "2026-11-05T09:32:59.401Z" }, + { url = "https://files.pythonhosted.org/packages/6e/0a/1da133041dfa1ca8d512e06485ce82dd2a9af7b6cc4fe9c277008380d10a/watchdog-7.1.0-py3-none-manylinux2014_armv7l.whl", hash = "sha256:d47f3067eb77a83d04de1cac214284da604f960eaee9816d7ebfd01a165b4175", size = 103269, upload-time = "2026-11-05T09:33:00.478Z" }, + { url = "https://files.pythonhosted.org/packages/e5/b4/3c9142add82c134fcbb748cc23e52603519679dddc4b5900d83e473d0648/watchdog-7.1.0-py3-none-manylinux2014_i686.whl", hash = "sha256:400788184d62c0e384da67de4d7fcb892bfeb064b2e59a7d1a1dccb9ff4b49bc", size = 103267, upload-time = "2026-11-05T09:33:01.522Z" }, + { url = "https://files.pythonhosted.org/packages/3f/d3/dbbc79e5ce139516cad0b88ec08df27fd00ef478547c0e584951f2c687b3/watchdog-7.1.0-py3-none-manylinux2014_ppc64.whl", hash = "sha256:b76e3ac088550b33046c4eabacdd7dd4cb9db9147c8749b202643a4b5c2433c8", size = 103266, upload-time = "2026-11-05T09:33:02.614Z" }, + { url = "https://files.pythonhosted.org/packages/7a/ad/721ff870f9ecf25532a07d58fb677764e17390a46b675486bf23ce278873/watchdog-7.1.0-py3-none-manylinux2014_ppc64le.whl", hash = "sha256:d94d0bcf30a9ea5ac5387df290b9e175c04747558c33443d2b0f763471699531", size = 103269, upload-time = "2026-11-05T09:33:03.694Z" }, + { url = "https://files.pythonhosted.org/packages/ab/4c/dfe0265c572027b2af9e824c6370a6ca39da33c819a99af48ddbc0cf1706/watchdog-7.1.0-py3-none-manylinux2014_s390x.whl", hash = "sha256:cbae4a087f712bac4086e653273a949f86e2f908d16f157fd3568217e0c07cbe", size = 103268, upload-time = "2026-11-05T09:33:04.738Z" }, + { url = "https://files.pythonhosted.org/packages/98/4d/60e1c38c27973d63f8748cfe8da70bdf698d1c1ab0e94fd18de15b3044fe/watchdog-7.1.0-py3-none-manylinux2014_x86_64.whl", hash = "sha256:77f06d709fe5d766ec51ec07b79773f5e29a0b3c4c3d195cfc7aa1e909fa566c", size = 103269, upload-time = "2026-11-05T09:33:05.95Z" }, + { url = "https://files.pythonhosted.org/packages/72/88/9190129165760c76191f4711b64a728d1bff02de74649c675797ae253f26/watchdog-7.1.0-py3-none-manylinux_2_17_aarch64.whl", hash = "sha256:48db8dd8f9f92359ca5d4bccbd82be814facc3f57feaa3c67be964cc86b1dc33", size = 103270, upload-time = "2026-11-05T09:33:07.48Z" }, + { url = "https://files.pythonhosted.org/packages/5e/6c/1c3a9066266b5c3f0db9146422f67e5d13781b2fb1b9e777ead5553fc1a7/watchdog-7.1.0-py3-none-manylinux_2_17_armv7l.whl", hash = "sha256:a47d6e1418d7ed80f69454fb7f000ded554363209f8b04b812bf46b6c9e3093f", size = 103268, upload-time = "2026-11-05T09:33:08.639Z" }, + { url = "https://files.pythonhosted.org/packages/40/6b/aa8fb28263d3965f91228ce9b251a786e36060a3571f4d724b2fab44a1c1/watchdog-7.1.0-py3-none-manylinux_2_17_i686.whl", hash = "sha256:71b0ebfd5b3ffe7cf53143f2ab63fa5038ca190fc10782ec23202765a859b057", size = 103268, upload-time = "2026-11-05T09:33:10.041Z" }, + { url = "https://files.pythonhosted.org/packages/63/bb/8757c54c6dcb0edcc514a47b0dc026f8751a266b6c320a0df8830d9f89a4/watchdog-7.1.0-py3-none-manylinux_2_17_ppc64.whl", hash = "sha256:c71bd120d57b16c2c49abd55d74d3c83f984e19024249ebe7ba4dc4903eb27ee", size = 103268, upload-time = "2026-11-05T09:33:11.147Z" }, + { url = "https://files.pythonhosted.org/packages/79/47/bdd6c0176695fb5b44fa9164ab5aa3edbefd322eea7dc584073fe7bfe67c/watchdog-7.1.0-py3-none-manylinux_2_17_ppc64le.whl", hash = "sha256:a17f37720ea088430754a7cc5869fad93915c69eaff8d5284adbac41f1befaaa", size = 103268, upload-time = "2026-11-05T09:33:12.264Z" }, + { url = "https://files.pythonhosted.org/packages/e6/99/13406d1424ed4a8796a800016d21ac6fba3ba9ac508cc860e97ce352f14e/watchdog-7.1.0-py3-none-manylinux_2_17_s390x.whl", hash = "sha256:89f78b2b1c153715463e27fc86f0f95fd4dd6cb07a2cdad932fe01840101fb5a", size = 103269, upload-time = "2026-11-05T09:33:13.414Z" }, + { url = "https://files.pythonhosted.org/packages/bb/28/96130c970c236e4278a188cb6b8dec2500ff395ddcebb74c6171f5fc6069/watchdog-7.1.0-py3-none-manylinux_2_17_x86_64.whl", hash = "sha256:ad6d0b473cb8cde0721692b22b30fcbea8b52102430528874b3593549888bd81", size = 103269, upload-time = "2026-11-05T09:33:14.916Z" }, + { url = "https://files.pythonhosted.org/packages/17/54/312036da06d83b4a21d25a0d83643d2a9b2188eb2e5031e52fe82eddbe0a/watchdog-7.1.0-py3-none-win32.whl", hash = "sha256:9c937139c8afdb26405639309956352ef72c453006e772e0cf5c0bbc0d1cba82", size = 103255, upload-time = "2026-11-05T09:33:16.394Z" }, + { url = "https://files.pythonhosted.org/packages/5a/bc/c04fbb2d6366afb0850e39c6d848f2d38066ff6dadccc886b3cb12c39e32/watchdog-7.1.0-py3-none-win_amd64.whl", hash = "sha256:16a5ba8694587cdbeae4ab8e6434cece994f9cce4e5bab03e61e6d1a0a93a643", size = 103260, upload-time = "2026-11-05T09:33:17.687Z" }, + { url = "https://files.pythonhosted.org/packages/92/9c/5a39ec8880c08e50f75d90f4e0e27b95dc91a04deb5e6e04871dd4b7e006/watchdog-7.1.0-py3-none-win_arm64.whl", hash = "sha256:5ed4b94365c53ffd51d88e47ca48d6afae02fb1bd849175a9a10927a2fbfb932", size = 103260, upload-time = "2026-11-05T09:33:18.987Z" }, + { url = "https://files.pythonhosted.org/packages/c0/aa/7a7210433e000f2491ddec7756d312009b0a47847e5c3457ccb03852cfdf/watchdog-7.1.0-py3-none-win_ia64.whl", hash = "sha256:0cfc5a6b3d4e76fc3e18fd371ee79d57945004da4105b589f71bb16966fd3e67", size = 103256, upload-time = "2026-11-05T09:33:20.159Z" }, ] [[package]]