meridian-plugin-usage 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- meridian_plugin_usage-1.0.0/.github/CODEOWNERS +2 -0
- meridian_plugin_usage-1.0.0/.github/dependabot.yml +14 -0
- meridian_plugin_usage-1.0.0/.github/pull_request_template.md +13 -0
- meridian_plugin_usage-1.0.0/.github/workflows/ci.yml +90 -0
- meridian_plugin_usage-1.0.0/.github/workflows/release.yml +119 -0
- meridian_plugin_usage-1.0.0/.gitignore +13 -0
- meridian_plugin_usage-1.0.0/CHANGELOG.md +12 -0
- meridian_plugin_usage-1.0.0/CODE_OF_CONDUCT.md +7 -0
- meridian_plugin_usage-1.0.0/CONTRIBUTING.md +16 -0
- meridian_plugin_usage-1.0.0/LICENSE +202 -0
- meridian_plugin_usage-1.0.0/NOTICE +5 -0
- meridian_plugin_usage-1.0.0/PKG-INFO +163 -0
- meridian_plugin_usage-1.0.0/README.md +121 -0
- meridian_plugin_usage-1.0.0/SECURITY.md +8 -0
- meridian_plugin_usage-1.0.0/contracts/conformance/golden/fingerprints.json +15 -0
- meridian_plugin_usage-1.0.0/contracts/conformance/plugin-contract.json +40 -0
- meridian_plugin_usage-1.0.0/contracts/usage-plugin.v1.json +95 -0
- meridian_plugin_usage-1.0.0/docs/aggregation.md +23 -0
- meridian_plugin_usage-1.0.0/docs/architecture.md +46 -0
- meridian_plugin_usage-1.0.0/docs/compatibility.md +30 -0
- meridian_plugin_usage-1.0.0/docs/configuration.md +23 -0
- meridian_plugin_usage-1.0.0/docs/conformance.md +33 -0
- meridian_plugin_usage-1.0.0/docs/recording.md +43 -0
- meridian_plugin_usage-1.0.0/pyproject.toml +128 -0
- meridian_plugin_usage-1.0.0/scripts/compare_artifacts.py +33 -0
- meridian_plugin_usage-1.0.0/scripts/verify_artifacts.py +151 -0
- meridian_plugin_usage-1.0.0/scripts/verify_contracts.py +224 -0
- meridian_plugin_usage-1.0.0/src/meridian_storage/plugins/usage/__init__.py +116 -0
- meridian_plugin_usage-1.0.0/src/meridian_storage/plugins/usage/_canonical.py +188 -0
- meridian_plugin_usage-1.0.0/src/meridian_storage/plugins/usage/_version.py +4 -0
- meridian_plugin_usage-1.0.0/src/meridian_storage/plugins/usage/aggregation.py +304 -0
- meridian_plugin_usage-1.0.0/src/meridian_storage/plugins/usage/compatibility.json +35 -0
- meridian_plugin_usage-1.0.0/src/meridian_storage/plugins/usage/correlation.py +106 -0
- meridian_plugin_usage-1.0.0/src/meridian_storage/plugins/usage/errors.py +167 -0
- meridian_plugin_usage-1.0.0/src/meridian_storage/plugins/usage/models.py +854 -0
- meridian_plugin_usage-1.0.0/src/meridian_storage/plugins/usage/plugin.py +93 -0
- meridian_plugin_usage-1.0.0/src/meridian_storage/plugins/usage/py.typed +1 -0
- meridian_plugin_usage-1.0.0/src/meridian_storage/plugins/usage/query.py +305 -0
- meridian_plugin_usage-1.0.0/src/meridian_storage/plugins/usage/repository.py +928 -0
- meridian_plugin_usage-1.0.0/src/meridian_storage/plugins/usage/retention.py +59 -0
- meridian_plugin_usage-1.0.0/src/meridian_storage/plugins/usage/schema.py +388 -0
- meridian_plugin_usage-1.0.0/tests/conftest.py +225 -0
- meridian_plugin_usage-1.0.0/tests/test_aggregation.py +176 -0
- meridian_plugin_usage-1.0.0/tests/test_conformance.py +86 -0
- meridian_plugin_usage-1.0.0/tests/test_models.py +225 -0
- meridian_plugin_usage-1.0.0/tests/test_packaging.py +46 -0
- meridian_plugin_usage-1.0.0/tests/test_released_integration.py +114 -0
- meridian_plugin_usage-1.0.0/tests/test_repository.py +366 -0
- meridian_plugin_usage-1.0.0/tests/test_schema_plugin.py +164 -0
- meridian_plugin_usage-1.0.0/tests/test_validation.py +311 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
version: 2
|
|
3
|
+
updates:
|
|
4
|
+
- package-ecosystem: pip
|
|
5
|
+
directory: /
|
|
6
|
+
schedule:
|
|
7
|
+
interval: weekly
|
|
8
|
+
groups:
|
|
9
|
+
development:
|
|
10
|
+
dependency-type: development
|
|
11
|
+
- package-ecosystem: github-actions
|
|
12
|
+
directory: /
|
|
13
|
+
schedule:
|
|
14
|
+
interval: weekly
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
## Summary
|
|
2
|
+
|
|
3
|
+
Describe the scoped Usage change.
|
|
4
|
+
|
|
5
|
+
## Verification
|
|
6
|
+
|
|
7
|
+
- [ ] Ruff formatting and lint pass
|
|
8
|
+
- [ ] Strict mypy passes
|
|
9
|
+
- [ ] Contract verifier passes
|
|
10
|
+
- [ ] Unit/integration/conformance tests pass
|
|
11
|
+
- [ ] Apache-2.0 headers and LICENSE/NOTICE remain correct
|
|
12
|
+
- [ ] No Adapter, Engine, credential, service, private database, native query, or pricing boundary is introduced
|
|
13
|
+
- [ ] Public behavior or architecture changes have approved design write-back
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
name: CI
|
|
3
|
+
|
|
4
|
+
on:
|
|
5
|
+
push:
|
|
6
|
+
branches: [main]
|
|
7
|
+
pull_request:
|
|
8
|
+
workflow_dispatch:
|
|
9
|
+
|
|
10
|
+
permissions:
|
|
11
|
+
contents: read
|
|
12
|
+
|
|
13
|
+
concurrency:
|
|
14
|
+
group: ci-${{ github.workflow }}-${{ github.ref }}
|
|
15
|
+
cancel-in-progress: true
|
|
16
|
+
|
|
17
|
+
jobs:
|
|
18
|
+
test:
|
|
19
|
+
name: Python ${{ matrix.python }}
|
|
20
|
+
runs-on: ubuntu-latest
|
|
21
|
+
strategy:
|
|
22
|
+
fail-fast: false
|
|
23
|
+
matrix:
|
|
24
|
+
python: ["3.12", "3.13", "3.14"]
|
|
25
|
+
steps:
|
|
26
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
27
|
+
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
|
|
28
|
+
with:
|
|
29
|
+
python-version: ${{ matrix.python }}
|
|
30
|
+
cache: pip
|
|
31
|
+
cache-dependency-path: pyproject.toml
|
|
32
|
+
- run: python -m pip install --disable-pip-version-check pip==26.2
|
|
33
|
+
- name: Install exact development dependencies
|
|
34
|
+
run: python -m pip install --disable-pip-version-check -e '.[test]'
|
|
35
|
+
- name: Verify source
|
|
36
|
+
run: |
|
|
37
|
+
ruff format --check .
|
|
38
|
+
ruff check .
|
|
39
|
+
mypy src
|
|
40
|
+
- name: Verify released contracts
|
|
41
|
+
run: python scripts/verify_contracts.py
|
|
42
|
+
- name: Run conformance tests
|
|
43
|
+
run: pytest
|
|
44
|
+
|
|
45
|
+
security:
|
|
46
|
+
name: Security
|
|
47
|
+
runs-on: ubuntu-latest
|
|
48
|
+
steps:
|
|
49
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
50
|
+
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
|
|
51
|
+
with:
|
|
52
|
+
python-version: "3.13"
|
|
53
|
+
cache: pip
|
|
54
|
+
cache-dependency-path: pyproject.toml
|
|
55
|
+
- run: python -m pip install --disable-pip-version-check pip==26.2
|
|
56
|
+
- run: python -m pip install --disable-pip-version-check -e '.[test]'
|
|
57
|
+
- run: bandit -r src -c pyproject.toml
|
|
58
|
+
- run: pip-audit --skip-editable
|
|
59
|
+
|
|
60
|
+
package:
|
|
61
|
+
name: Package
|
|
62
|
+
needs: [test, security]
|
|
63
|
+
runs-on: ubuntu-latest
|
|
64
|
+
env:
|
|
65
|
+
SOURCE_DATE_EPOCH: "1787702400"
|
|
66
|
+
steps:
|
|
67
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
68
|
+
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
|
|
69
|
+
with:
|
|
70
|
+
python-version: "3.13"
|
|
71
|
+
cache: pip
|
|
72
|
+
cache-dependency-path: pyproject.toml
|
|
73
|
+
- run: python -m pip install --disable-pip-version-check pip==26.2
|
|
74
|
+
- run: python -m pip install --disable-pip-version-check -e '.[test]'
|
|
75
|
+
- name: Build twice
|
|
76
|
+
run: |
|
|
77
|
+
python -m build --no-isolation --outdir dist-a
|
|
78
|
+
python -m build --no-isolation --outdir dist-b
|
|
79
|
+
- name: Verify distributions
|
|
80
|
+
run: |
|
|
81
|
+
twine check dist-a/*
|
|
82
|
+
python scripts/verify_artifacts.py dist-a
|
|
83
|
+
python scripts/compare_artifacts.py dist-a dist-b
|
|
84
|
+
cd dist-a && sha256sum meridian_plugin_usage-* > SHA256SUMS
|
|
85
|
+
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
|
86
|
+
with:
|
|
87
|
+
name: meridian-plugin-usage-1.0.0
|
|
88
|
+
path: dist-a/
|
|
89
|
+
if-no-files-found: error
|
|
90
|
+
retention-days: 30
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
name: Release
|
|
3
|
+
|
|
4
|
+
on:
|
|
5
|
+
push:
|
|
6
|
+
tags: ["v[0-9]+.[0-9]+.[0-9]+"]
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
inputs:
|
|
9
|
+
tag:
|
|
10
|
+
description: Existing immutable release tag to recover
|
|
11
|
+
required: true
|
|
12
|
+
type: string
|
|
13
|
+
|
|
14
|
+
permissions:
|
|
15
|
+
contents: read
|
|
16
|
+
|
|
17
|
+
env:
|
|
18
|
+
RELEASE_TAG: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref_name }}
|
|
19
|
+
|
|
20
|
+
jobs:
|
|
21
|
+
build:
|
|
22
|
+
name: Build release
|
|
23
|
+
runs-on: ubuntu-latest
|
|
24
|
+
env:
|
|
25
|
+
SOURCE_DATE_EPOCH: "1787702400"
|
|
26
|
+
steps:
|
|
27
|
+
- name: Validate release tag
|
|
28
|
+
shell: bash
|
|
29
|
+
run: |
|
|
30
|
+
if [[ ! "$RELEASE_TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
|
31
|
+
echo "Invalid tag" >&2
|
|
32
|
+
exit 1
|
|
33
|
+
fi
|
|
34
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
35
|
+
with:
|
|
36
|
+
ref: ${{ env.RELEASE_TAG }}
|
|
37
|
+
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
|
|
38
|
+
with:
|
|
39
|
+
python-version: "3.13"
|
|
40
|
+
cache: pip
|
|
41
|
+
cache-dependency-path: pyproject.toml
|
|
42
|
+
- run: python -m pip install --disable-pip-version-check pip==26.2
|
|
43
|
+
- run: python -m pip install --disable-pip-version-check -e '.[test]'
|
|
44
|
+
- run: |
|
|
45
|
+
ruff format --check .
|
|
46
|
+
ruff check .
|
|
47
|
+
mypy src
|
|
48
|
+
python scripts/verify_contracts.py
|
|
49
|
+
pytest
|
|
50
|
+
- run: |
|
|
51
|
+
python -m build --no-isolation --outdir dist
|
|
52
|
+
twine check dist/*
|
|
53
|
+
python scripts/verify_artifacts.py dist
|
|
54
|
+
cd dist && sha256sum meridian_plugin_usage-* > SHA256SUMS
|
|
55
|
+
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
|
56
|
+
with:
|
|
57
|
+
name: release-distributions
|
|
58
|
+
path: dist/
|
|
59
|
+
if-no-files-found: error
|
|
60
|
+
|
|
61
|
+
attest:
|
|
62
|
+
name: Attest release
|
|
63
|
+
needs: build
|
|
64
|
+
runs-on: ubuntu-latest
|
|
65
|
+
permissions:
|
|
66
|
+
id-token: write
|
|
67
|
+
contents: read
|
|
68
|
+
attestations: write
|
|
69
|
+
steps:
|
|
70
|
+
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
|
71
|
+
with:
|
|
72
|
+
name: release-distributions
|
|
73
|
+
path: dist
|
|
74
|
+
- uses: actions/attest@1e69f48acb82d1966a394da916b4c1698aa569d6 # v4.2.2
|
|
75
|
+
with:
|
|
76
|
+
subject-path: "dist/meridian_plugin_usage-*"
|
|
77
|
+
|
|
78
|
+
github-release:
|
|
79
|
+
name: Publish GitHub release
|
|
80
|
+
needs: [build, attest]
|
|
81
|
+
runs-on: ubuntu-latest
|
|
82
|
+
permissions:
|
|
83
|
+
contents: write
|
|
84
|
+
steps:
|
|
85
|
+
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
|
86
|
+
with:
|
|
87
|
+
name: release-distributions
|
|
88
|
+
path: dist
|
|
89
|
+
- name: Publish immutable tag artifacts
|
|
90
|
+
env:
|
|
91
|
+
GH_TOKEN: ${{ github.token }}
|
|
92
|
+
run: >-
|
|
93
|
+
gh release create "$RELEASE_TAG" dist/*
|
|
94
|
+
--repo "$GITHUB_REPOSITORY"
|
|
95
|
+
--verify-tag
|
|
96
|
+
--generate-notes
|
|
97
|
+
|
|
98
|
+
pypi:
|
|
99
|
+
name: Publish PyPI
|
|
100
|
+
if: github.event_name == 'push'
|
|
101
|
+
needs: [build, attest]
|
|
102
|
+
runs-on: ubuntu-latest
|
|
103
|
+
environment:
|
|
104
|
+
name: pypi
|
|
105
|
+
url: https://pypi.org/p/meridian-plugin-usage
|
|
106
|
+
permissions:
|
|
107
|
+
id-token: write
|
|
108
|
+
steps:
|
|
109
|
+
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
|
110
|
+
with:
|
|
111
|
+
name: release-distributions
|
|
112
|
+
path: dist
|
|
113
|
+
- name: Select distributions
|
|
114
|
+
run: |
|
|
115
|
+
mkdir -p publish
|
|
116
|
+
cp dist/*.whl dist/*.tar.gz publish/
|
|
117
|
+
- uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2
|
|
118
|
+
with:
|
|
119
|
+
packages-dir: publish/
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes follow Semantic Versioning.
|
|
4
|
+
|
|
5
|
+
## 1.0.0 - 2026-08-26
|
|
6
|
+
|
|
7
|
+
- Add immutable versioned meters, usage events, and aggregate records.
|
|
8
|
+
- Add exact Decimal unit normalization and correction-chain validation.
|
|
9
|
+
- Add bounded mapping-first record/query/batch APIs backed only by Meridian.
|
|
10
|
+
- Add deterministic aggregation with claims, watermark checkpoints, and late data revisions.
|
|
11
|
+
- Add OpenTelemetry and Evidence correlation, retention inputs, schema/plugin providers,
|
|
12
|
+
conformance evidence, CI, and reproducible distribution checks.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Code of Conduct
|
|
2
|
+
|
|
3
|
+
Contributors must keep project interactions respectful, constructive, and
|
|
4
|
+
welcoming. Harassment, discrimination, threats, and disclosure of private
|
|
5
|
+
information are not acceptable. Report conduct concerns privately through the
|
|
6
|
+
repository security contact.
|
|
7
|
+
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
Use Python 3.12 through 3.14. Create a virtual environment, install the exact
|
|
4
|
+
test extra, and run:
|
|
5
|
+
|
|
6
|
+
python -m pip install pip==26.2
|
|
7
|
+
python -m pip install -e '.[test]'
|
|
8
|
+
ruff format --check .
|
|
9
|
+
ruff check .
|
|
10
|
+
mypy src
|
|
11
|
+
python scripts/verify_contracts.py
|
|
12
|
+
pytest
|
|
13
|
+
|
|
14
|
+
Every source file must retain its Apache-2.0 SPDX header. Public behavior
|
|
15
|
+
changes require tests, compatibility evidence, and a design update when they
|
|
16
|
+
alter an approved Meridian interface or architecture boundary.
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Meridian contributors
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
202
|
+
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: meridian-plugin-usage
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Meridian V1 immutable usage recording, querying, and aggregation plugin
|
|
5
|
+
Project-URL: Documentation, https://github.com/zephytiju/meridian-plugin-usage#readme
|
|
6
|
+
Project-URL: Issues, https://github.com/zephytiju/meridian-plugin-usage/issues
|
|
7
|
+
Project-URL: Repository, https://github.com/zephytiju/meridian-plugin-usage
|
|
8
|
+
Author: Meridian contributors
|
|
9
|
+
License-Expression: Apache-2.0
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
License-File: NOTICE
|
|
12
|
+
Keywords: aggregation,meridian,metering,opentelemetry,usage
|
|
13
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
21
|
+
Classifier: Typing :: Typed
|
|
22
|
+
Requires-Python: <3.15,>=3.12
|
|
23
|
+
Requires-Dist: meridian-plugin-observability==1.0.0
|
|
24
|
+
Requires-Dist: meridian-storage-core==1.0.0
|
|
25
|
+
Requires-Dist: meridian-storage-evidence==1.0.0
|
|
26
|
+
Requires-Dist: meridian-storage-query==1.0.0
|
|
27
|
+
Requires-Dist: meridian-storage-semantics==1.0.0
|
|
28
|
+
Provides-Extra: test
|
|
29
|
+
Requires-Dist: bandit[toml]==1.8.6; extra == 'test'
|
|
30
|
+
Requires-Dist: build==1.3.0; extra == 'test'
|
|
31
|
+
Requires-Dist: hatchling==1.27.0; extra == 'test'
|
|
32
|
+
Requires-Dist: jsonschema==4.25.1; extra == 'test'
|
|
33
|
+
Requires-Dist: meridian-storage-clickhouse==1.0.0; extra == 'test'
|
|
34
|
+
Requires-Dist: mypy==1.17.1; extra == 'test'
|
|
35
|
+
Requires-Dist: packaging==26.3; extra == 'test'
|
|
36
|
+
Requires-Dist: pip-audit==2.9.0; extra == 'test'
|
|
37
|
+
Requires-Dist: pytest-cov==6.2.1; extra == 'test'
|
|
38
|
+
Requires-Dist: pytest==9.0.3; extra == 'test'
|
|
39
|
+
Requires-Dist: ruff==0.12.10; extra == 'test'
|
|
40
|
+
Requires-Dist: twine==6.1.0; extra == 'test'
|
|
41
|
+
Description-Content-Type: text/markdown
|
|
42
|
+
|
|
43
|
+
# meridian-plugin-usage
|
|
44
|
+
|
|
45
|
+
Meridian V1's open-source Usage plugin provides immutable metering events,
|
|
46
|
+
exact unit normalization, bounded queries, deterministic window aggregation,
|
|
47
|
+
retention inputs, and OpenTelemetry/Evidence correlation over logical Meridian
|
|
48
|
+
Resources.
|
|
49
|
+
|
|
50
|
+
This distribution is a Python library and Meridian plugin. It is not a service
|
|
51
|
+
or a Usage Catalog. It owns no database, provisions no engine, accepts no
|
|
52
|
+
engine credentials, calculates no prices, and uses only released mapping-first
|
|
53
|
+
Meridian Expressions.
|
|
54
|
+
|
|
55
|
+
## Install
|
|
56
|
+
|
|
57
|
+
```console
|
|
58
|
+
python -m pip install meridian-plugin-usage==1.0.0
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Python 3.12, 3.13, and 3.14 are supported. Runtime Meridian dependencies are
|
|
62
|
+
exactly pinned to their compatible 1.0.0 releases.
|
|
63
|
+
|
|
64
|
+
## Record immutable usage
|
|
65
|
+
|
|
66
|
+
Platform IaC renders the Meridian runtime, logical Resource placements,
|
|
67
|
+
identity/ACL, migrations, retention, and engine lifecycle. Application code
|
|
68
|
+
only creates the ready runtime and uses this library:
|
|
69
|
+
|
|
70
|
+
```python
|
|
71
|
+
from datetime import UTC, datetime
|
|
72
|
+
from decimal import Decimal
|
|
73
|
+
|
|
74
|
+
from meridian_storage.plugins.usage import (
|
|
75
|
+
DimensionSpec,
|
|
76
|
+
MeterV1,
|
|
77
|
+
UnitTransform,
|
|
78
|
+
Usage,
|
|
79
|
+
UsageEvent,
|
|
80
|
+
UsageScope,
|
|
81
|
+
UsageWindow,
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
usage = Usage(ready_meridian)
|
|
85
|
+
|
|
86
|
+
meter = MeterV1(
|
|
87
|
+
meter_id="api.requests",
|
|
88
|
+
version=1,
|
|
89
|
+
quantity="requests",
|
|
90
|
+
canonical_unit="request",
|
|
91
|
+
transforms={"kilorequest": UnitTransform(Decimal("1000"))},
|
|
92
|
+
dimensions=(DimensionSpec("region", required=True),),
|
|
93
|
+
scale=6,
|
|
94
|
+
active_from=datetime(2026, 1, 1, tzinfo=UTC),
|
|
95
|
+
)
|
|
96
|
+
usage.repository.register_meter(meter)
|
|
97
|
+
|
|
98
|
+
event = UsageEvent(
|
|
99
|
+
event_id="publisher-event-0001",
|
|
100
|
+
scope=UsageScope({"tenant": "acme", "environment": "prod"}),
|
|
101
|
+
subject_id="account-42",
|
|
102
|
+
meter_id=meter.meter_id,
|
|
103
|
+
meter_version=meter.version,
|
|
104
|
+
window=UsageWindow(
|
|
105
|
+
datetime(2026, 8, 26, 10, 0, tzinfo=UTC),
|
|
106
|
+
datetime(2026, 8, 26, 10, 1, tzinfo=UTC),
|
|
107
|
+
),
|
|
108
|
+
value=Decimal("2"),
|
|
109
|
+
unit="kilorequest",
|
|
110
|
+
dimensions={"region": "us-west"},
|
|
111
|
+
source="publisher",
|
|
112
|
+
)
|
|
113
|
+
receipt = usage.recorder.record(event)
|
|
114
|
+
assert receipt.event.value == Decimal("2000.000000")
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
An identical replay returns `RecordStatus.REPLAYED`. The same scoped
|
|
118
|
+
`event_id` with different normalized content raises the stable
|
|
119
|
+
`MERIDIAN_USAGE_IMMUTABLE_CONFLICT` error. Corrections are new signed
|
|
120
|
+
events referencing `correction_of`; existing events are never mutated.
|
|
121
|
+
|
|
122
|
+
## Query and aggregate
|
|
123
|
+
|
|
124
|
+
```python
|
|
125
|
+
page = usage.queries.events(
|
|
126
|
+
event.scope,
|
|
127
|
+
datetime(2026, 8, 26, 10, 0, tzinfo=UTC),
|
|
128
|
+
datetime(2026, 8, 26, 11, 0, tzinfo=UTC),
|
|
129
|
+
where={"meterId": meter.meter_id},
|
|
130
|
+
).page(limit=100).execute()
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Every query is scope-bound, time-bounded, cursor-paginated, and exposed both as
|
|
134
|
+
a mapping-first `Expression` and a serialized Query 1.0.0 logical plan.
|
|
135
|
+
Aggregation is a library worker with deterministic claims, immutable aggregate
|
|
136
|
+
versions, and compare-and-set watermark checkpoints. Retrying after a crash
|
|
137
|
+
replays identical outputs; late events create a new version that names the
|
|
138
|
+
version it supersedes.
|
|
139
|
+
|
|
140
|
+
## Batch profiles
|
|
141
|
+
|
|
142
|
+
- `partitioned` records deterministic per-event outcomes and is portable
|
|
143
|
+
to append-oriented placements such as ClickHouse.
|
|
144
|
+
- `atomic` opens one Meridian transaction on the events Resource and is
|
|
145
|
+
accepted only when the rendered placement advertises the transaction
|
|
146
|
+
capability.
|
|
147
|
+
|
|
148
|
+
Batch manifests and aggregation control records are logical structured
|
|
149
|
+
Resources. They are not a private database.
|
|
150
|
+
|
|
151
|
+
## Contracts and evidence
|
|
152
|
+
|
|
153
|
+
The package ships released Semantics schemas, plugin/schema-provider entry
|
|
154
|
+
points, JSON Schema compatibility evidence, deterministic golden
|
|
155
|
+
fingerprints, unit/integration/conformance tests, reproducible build checks,
|
|
156
|
+
and Apache-2.0 LICENSE/NOTICE material.
|
|
157
|
+
|
|
158
|
+
See [architecture](docs/architecture.md), [recording](docs/recording.md),
|
|
159
|
+
[aggregation](docs/aggregation.md), [configuration](docs/configuration.md),
|
|
160
|
+
[compatibility](docs/compatibility.md), and [conformance](docs/conformance.md).
|
|
161
|
+
|
|
162
|
+
Licensed under the Apache License, Version 2.0.
|
|
163
|
+
|