touchstone-dqi 0.0.1__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.
- touchstone_dqi-0.0.1/.env.example +3 -0
- touchstone_dqi-0.0.1/.githooks/commit-msg +2 -0
- touchstone_dqi-0.0.1/.github/workflows/README.md +8 -0
- touchstone_dqi-0.0.1/.github/workflows/ci.yml +57 -0
- touchstone_dqi-0.0.1/.github/workflows/publish.yml +43 -0
- touchstone_dqi-0.0.1/.gitignore +41 -0
- touchstone_dqi-0.0.1/CONTRIBUTING.md +153 -0
- touchstone_dqi-0.0.1/LICENSE +202 -0
- touchstone_dqi-0.0.1/PKG-INFO +153 -0
- touchstone_dqi-0.0.1/README.md +129 -0
- touchstone_dqi-0.0.1/docs/packs.md +71 -0
- touchstone_dqi-0.0.1/docs/releasing.md +60 -0
- touchstone_dqi-0.0.1/packaging/dqi/README.md +14 -0
- touchstone_dqi-0.0.1/packaging/dqi/dqi/__init__.py +8 -0
- touchstone_dqi-0.0.1/packaging/dqi/pyproject.toml +23 -0
- touchstone_dqi-0.0.1/packs/example_pack/manifest.yaml +21 -0
- touchstone_dqi-0.0.1/pyproject.toml +50 -0
- touchstone_dqi-0.0.1/scripts/check_commit_msg.py +115 -0
- touchstone_dqi-0.0.1/src/touchstone/__init__.py +1 -0
- touchstone_dqi-0.0.1/src/touchstone/backends/__init__.py +3 -0
- touchstone_dqi-0.0.1/src/touchstone/backends/base.py +109 -0
- touchstone_dqi-0.0.1/src/touchstone/bundle.py +106 -0
- touchstone_dqi-0.0.1/src/touchstone/cli.py +110 -0
- touchstone_dqi-0.0.1/src/touchstone/contracts/__init__.py +14 -0
- touchstone_dqi-0.0.1/src/touchstone/contracts/bundle.py +44 -0
- touchstone_dqi-0.0.1/src/touchstone/contracts/item.py +35 -0
- touchstone_dqi-0.0.1/src/touchstone/contracts/manifest.py +45 -0
- touchstone_dqi-0.0.1/src/touchstone/contracts/plan.py +28 -0
- touchstone_dqi-0.0.1/src/touchstone/errors.py +15 -0
- touchstone_dqi-0.0.1/src/touchstone/plan_check.py +58 -0
- touchstone_dqi-0.0.1/tests/test_backends.py +150 -0
- touchstone_dqi-0.0.1/tests/test_bundle.py +99 -0
- touchstone_dqi-0.0.1/tests/test_cli_matches_readme.py +24 -0
- touchstone_dqi-0.0.1/tests/test_commit_msg.py +45 -0
- touchstone_dqi-0.0.1/tests/test_no_locale_in_src.py +25 -0
- touchstone_dqi-0.0.1/tests/test_plan_check.py +55 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
`ci.yml` runs three jobs.
|
|
2
|
+
|
|
3
|
+
- `test`: lint, format check, unit tests.
|
|
4
|
+
- `commit-messages`: every commit in a pull request is checked against
|
|
5
|
+
`scripts/check_commit_msg.py`. See CONTRIBUTING.md.
|
|
6
|
+
- `offline-install`: builds a wheel, vendors its dependencies, then installs and runs
|
|
7
|
+
with no package index. Touchstone has to work in an environment with no egress, so
|
|
8
|
+
that claim is tested on every push rather than asserted in the README.
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
name: ci
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
test:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
steps:
|
|
12
|
+
- uses: actions/checkout@v5
|
|
13
|
+
- uses: astral-sh/setup-uv@v7
|
|
14
|
+
with:
|
|
15
|
+
python-version: "3.12"
|
|
16
|
+
- run: uv sync --all-extras --dev
|
|
17
|
+
- run: uv run ruff check .
|
|
18
|
+
- run: uv run ruff format --check .
|
|
19
|
+
- run: uv run pytest -q
|
|
20
|
+
|
|
21
|
+
commit-messages:
|
|
22
|
+
runs-on: ubuntu-latest
|
|
23
|
+
if: github.event_name == 'pull_request'
|
|
24
|
+
steps:
|
|
25
|
+
- uses: actions/checkout@v5
|
|
26
|
+
with:
|
|
27
|
+
fetch-depth: 0
|
|
28
|
+
- name: check every commit message in the pull request
|
|
29
|
+
run: |
|
|
30
|
+
set -e
|
|
31
|
+
base="${{ github.event.pull_request.base.sha }}"
|
|
32
|
+
head="${{ github.event.pull_request.head.sha }}"
|
|
33
|
+
status=0
|
|
34
|
+
for sha in $(git rev-list "$base".."$head"); do
|
|
35
|
+
git log -1 --format=%B "$sha" > /tmp/msg
|
|
36
|
+
echo "--- $(git log -1 --format=%h\ %s "$sha")"
|
|
37
|
+
python3 scripts/check_commit_msg.py /tmp/msg || status=1
|
|
38
|
+
done
|
|
39
|
+
exit $status
|
|
40
|
+
|
|
41
|
+
offline-install:
|
|
42
|
+
runs-on: ubuntu-latest
|
|
43
|
+
steps:
|
|
44
|
+
- uses: actions/checkout@v5
|
|
45
|
+
- uses: actions/setup-python@v6
|
|
46
|
+
with:
|
|
47
|
+
python-version: "3.12"
|
|
48
|
+
- name: build a wheel and vendor its dependencies
|
|
49
|
+
run: |
|
|
50
|
+
pip install build
|
|
51
|
+
python -m build --wheel --outdir dist
|
|
52
|
+
pip download -d vendor dist/*.whl
|
|
53
|
+
- name: install and run with networking disabled
|
|
54
|
+
run: |
|
|
55
|
+
python -m venv .airgap
|
|
56
|
+
.airgap/bin/pip install --no-index --find-links vendor touchstone-dqi
|
|
57
|
+
.airgap/bin/touchstone version
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
name: publish
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
inputs:
|
|
8
|
+
package:
|
|
9
|
+
description: "Which package to publish"
|
|
10
|
+
required: true
|
|
11
|
+
type: choice
|
|
12
|
+
options: [touchstone-dqi, dqi]
|
|
13
|
+
|
|
14
|
+
jobs:
|
|
15
|
+
touchstone:
|
|
16
|
+
if: github.event_name == 'release' || inputs.package == 'touchstone-dqi'
|
|
17
|
+
runs-on: ubuntu-latest
|
|
18
|
+
environment: pypi
|
|
19
|
+
permissions:
|
|
20
|
+
id-token: write
|
|
21
|
+
steps:
|
|
22
|
+
- uses: actions/checkout@v5
|
|
23
|
+
- uses: actions/setup-python@v6
|
|
24
|
+
with:
|
|
25
|
+
python-version: "3.12"
|
|
26
|
+
- run: pip install build
|
|
27
|
+
- run: python -m build
|
|
28
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
29
|
+
|
|
30
|
+
dqi:
|
|
31
|
+
if: inputs.package == 'dqi'
|
|
32
|
+
runs-on: ubuntu-latest
|
|
33
|
+
environment: pypi
|
|
34
|
+
permissions:
|
|
35
|
+
id-token: write
|
|
36
|
+
steps:
|
|
37
|
+
- uses: actions/checkout@v5
|
|
38
|
+
- uses: actions/setup-python@v6
|
|
39
|
+
with:
|
|
40
|
+
python-version: "3.12"
|
|
41
|
+
- run: pip install build
|
|
42
|
+
- run: python -m build packaging/dqi --outdir dist
|
|
43
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Internal planning documents. Never commit these.
|
|
2
|
+
# They live outside this repo, in products/touchstone/. This is a second line of defence.
|
|
3
|
+
*-NIGERIA-FIRST.md
|
|
4
|
+
*-ASQI-TEARDOWN.md
|
|
5
|
+
*-DESIGN.md
|
|
6
|
+
*-BUILD-PLAN.md
|
|
7
|
+
*-NAMING.md
|
|
8
|
+
PLAN-*.md
|
|
9
|
+
CONTEXT.md
|
|
10
|
+
HANDBOOK.md
|
|
11
|
+
productPlan.md
|
|
12
|
+
DECISIONS.md
|
|
13
|
+
RUNLOG.md
|
|
14
|
+
notes/
|
|
15
|
+
internal/
|
|
16
|
+
|
|
17
|
+
# Python
|
|
18
|
+
__pycache__/
|
|
19
|
+
*.py[cod]
|
|
20
|
+
.venv/
|
|
21
|
+
venv/
|
|
22
|
+
*.egg-info/
|
|
23
|
+
dist/
|
|
24
|
+
build/
|
|
25
|
+
.pytest_cache/
|
|
26
|
+
.ruff_cache/
|
|
27
|
+
.coverage
|
|
28
|
+
htmlcov/
|
|
29
|
+
|
|
30
|
+
# Environment
|
|
31
|
+
.env
|
|
32
|
+
.env.*
|
|
33
|
+
!.env.example
|
|
34
|
+
|
|
35
|
+
# Runtime output
|
|
36
|
+
runs/
|
|
37
|
+
bundles/
|
|
38
|
+
logs/
|
|
39
|
+
|
|
40
|
+
# OS
|
|
41
|
+
.DS_Store
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
Read this before your first commit. The rules here are enforced by CI, not by review.
|
|
4
|
+
|
|
5
|
+
## Commit messages
|
|
6
|
+
|
|
7
|
+
Write like an engineer with work to do. Short, factual, imperative.
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
add wilson interval to rate estimator
|
|
11
|
+
fix digest resolution for multi-arch images
|
|
12
|
+
drop unused seed parameter from plan loader
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
**Rules, all enforced by `scripts/check_commit_msg.py`:**
|
|
16
|
+
|
|
17
|
+
1. Subject is 50 characters or fewer. Hard limit 72.
|
|
18
|
+
2. Imperative mood. `add`, not `added` or `adds`.
|
|
19
|
+
3. Lowercase first word. No trailing full stop.
|
|
20
|
+
4. Body optional. Add one only to explain *why*, never to restate the diff.
|
|
21
|
+
Wrap at 72. Blank line between subject and body.
|
|
22
|
+
5. **No em dashes or en dashes.** Anywhere. Use a comma or a full stop.
|
|
23
|
+
6. No marketing adjectives. The linter rejects: comprehensive, robust, seamless,
|
|
24
|
+
powerful, cutting-edge, state-of-the-art, elegant, blazing, leverage, delve,
|
|
25
|
+
utilise, holistic, streamline, unlock, empower.
|
|
26
|
+
7. No AI attribution. No `Co-Authored-By` for a tool, no `Generated with`, no emoji.
|
|
27
|
+
8. No issue-tracker noise in the subject. Put refs in the body.
|
|
28
|
+
|
|
29
|
+
**Why 50 characters.** `git log --oneline` is how the history gets read. A subject
|
|
30
|
+
that wraps is a subject nobody reads.
|
|
31
|
+
|
|
32
|
+
**Why the adjective list.** Those words carry no information about the change. If a
|
|
33
|
+
commit needs to say the work is good, the work is not good enough.
|
|
34
|
+
|
|
35
|
+
### Bad, and why
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
feat: Implement comprehensive and robust validation logic for the plan
|
|
39
|
+
loader module - this seamlessly handles all edge cases
|
|
40
|
+
|
|
41
|
+
Generated with Claude Code
|
|
42
|
+
Co-Authored-By: Claude <noreply@anthropic.com>
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Too long. Past tense marketing. Em dash. Claims coverage it cannot prove.
|
|
46
|
+
Attribution nobody needs.
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
validate plan against pack manifests
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
That is the same commit.
|
|
53
|
+
|
|
54
|
+
## Code
|
|
55
|
+
|
|
56
|
+
Same principle. Clarity first, volume last.
|
|
57
|
+
|
|
58
|
+
1. **No comment that restates the code.** `# increment counter` above `i += 1` gets
|
|
59
|
+
deleted in review.
|
|
60
|
+
2. **Comment only what the code cannot say**: a why, a constraint, a reference to a
|
|
61
|
+
spec or a paper, a known sharp edge.
|
|
62
|
+
3. **Docstrings on public functions only**, one line, saying what it returns. Skip the
|
|
63
|
+
Args and Returns blocks unless the types are genuinely unclear.
|
|
64
|
+
4. **No defensive noise.** Do not catch an exception you cannot handle. Do not check
|
|
65
|
+
for a condition the type system already rules out.
|
|
66
|
+
5. **Functions do one thing.** If you need a section comment inside a function, that
|
|
67
|
+
section is a function.
|
|
68
|
+
6. **No abbreviations that need a glossary.** `manifest`, not `mfst`.
|
|
69
|
+
7. **Fail closed.** A missing file, an unresolvable digest or a stale hash is an error
|
|
70
|
+
with a non-zero exit. Never a warning, never a silent default. This tool produces
|
|
71
|
+
evidence, and evidence that degraded quietly is worse than no evidence.
|
|
72
|
+
8. **No country, language or regulator logic in `src/`.** All of it belongs in packs
|
|
73
|
+
and in `mappings/`. CI fails the build on a two-letter country code in `src/`.
|
|
74
|
+
|
|
75
|
+
### Bad
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
def process_items(items: list[dict]) -> dict:
|
|
79
|
+
"""
|
|
80
|
+
Process the items.
|
|
81
|
+
|
|
82
|
+
Args:
|
|
83
|
+
items: A list of items to process.
|
|
84
|
+
|
|
85
|
+
Returns:
|
|
86
|
+
A dictionary containing the processed results.
|
|
87
|
+
"""
|
|
88
|
+
# Initialise the results dictionary
|
|
89
|
+
results = {}
|
|
90
|
+
# Loop over each item in the list
|
|
91
|
+
for item in items:
|
|
92
|
+
# Check if the item is valid
|
|
93
|
+
if item is not None:
|
|
94
|
+
results[item["id"]] = item
|
|
95
|
+
return results
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Good
|
|
99
|
+
|
|
100
|
+
```python
|
|
101
|
+
def index_by_id(items: list[ItemRecord]) -> dict[str, ItemRecord]:
|
|
102
|
+
"""Index records by item_id. Raises on a duplicate."""
|
|
103
|
+
out = {}
|
|
104
|
+
for item in items:
|
|
105
|
+
if item.item_id in out:
|
|
106
|
+
raise DuplicateItemError(item.item_id)
|
|
107
|
+
out[item.item_id] = item
|
|
108
|
+
return out
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Shorter, typed, named for what it does, and it fails closed on the case the first
|
|
112
|
+
version silently swallowed.
|
|
113
|
+
|
|
114
|
+
## Documentation
|
|
115
|
+
|
|
116
|
+
The README is the only document most people read. Optimise it for someone who has
|
|
117
|
+
five minutes and a system they want to test.
|
|
118
|
+
|
|
119
|
+
1. What it is, in two sentences.
|
|
120
|
+
2. What it needs to run.
|
|
121
|
+
3. A command that produces output.
|
|
122
|
+
4. Everything else in `docs/`.
|
|
123
|
+
|
|
124
|
+
No badges beyond build and licence. No feature list written as marketing. No emoji.
|
|
125
|
+
|
|
126
|
+
## Naming
|
|
127
|
+
|
|
128
|
+
The instrument is **Touchstone**. The index it computes is **DQI**.
|
|
129
|
+
|
|
130
|
+
- Tool versions: `Touchstone 1.0`.
|
|
131
|
+
- Specification versions: `DQI Specification v1.0`.
|
|
132
|
+
- Never `DQI 1.0` on its own. It is ambiguous and the ambiguity is permanent.
|
|
133
|
+
|
|
134
|
+
## Before you push
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
uv run ruff check . && uv run ruff format --check .
|
|
138
|
+
uv run pytest
|
|
139
|
+
uv run python scripts/check_commit_msg.py .git/COMMIT_EDITMSG
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Install the hooks once and the last one runs itself:
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
git config core.hooksPath .githooks
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## Pull requests
|
|
149
|
+
|
|
150
|
+
- One change per pull request.
|
|
151
|
+
- The description says what changed and why. Not how, the diff says how.
|
|
152
|
+
- A pull request that changes a contract in `src/touchstone/contracts/` is a major
|
|
153
|
+
version and needs a note saying what breaks.
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: touchstone-dqi
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Seal evaluation output into an evidence bundle anyone can re-check offline.
|
|
5
|
+
Project-URL: Homepage, https://github.com/Quantile-Labs/touchstone
|
|
6
|
+
Project-URL: Source, https://github.com/Quantile-Labs/touchstone
|
|
7
|
+
Author: Quantile Labs
|
|
8
|
+
Maintainer: Quantile Labs
|
|
9
|
+
License-Expression: Apache-2.0
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: ai-assurance,audit,evaluation,reproducibility
|
|
12
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
18
|
+
Classifier: Topic :: Software Development :: Testing
|
|
19
|
+
Requires-Python: >=3.12
|
|
20
|
+
Requires-Dist: pydantic>=2.11
|
|
21
|
+
Requires-Dist: pyyaml>=6.0
|
|
22
|
+
Requires-Dist: typer>=0.16
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
|
|
25
|
+
# Touchstone
|
|
26
|
+
|
|
27
|
+
Touchstone seals evaluation output into an evidence bundle: the plan, the per-item
|
|
28
|
+
observations, and a SHA-256 over every file. Anyone can re-check that bundle offline,
|
|
29
|
+
without this tool and without trusting whoever produced it.
|
|
30
|
+
|
|
31
|
+
## Status
|
|
32
|
+
|
|
33
|
+
Early. Three of the seven pipeline commands work. The rest are stubs that exit 2, and
|
|
34
|
+
nothing is published to PyPI yet.
|
|
35
|
+
|
|
36
|
+
## Requirements
|
|
37
|
+
|
|
38
|
+
Python 3.12 or later. `run` will need Docker once it exists; nothing today does.
|
|
39
|
+
|
|
40
|
+
## Install
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
git clone https://github.com/Quantile-Labs/touchstone
|
|
44
|
+
cd touchstone
|
|
45
|
+
python3 -m venv .venv
|
|
46
|
+
.venv/bin/pip install -e .
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Check a plan
|
|
50
|
+
|
|
51
|
+
A plan names the packs to run and the systems to run them against. `validate` reads it
|
|
52
|
+
against each pack's `manifest.yaml` and reports what does not line up:
|
|
53
|
+
|
|
54
|
+
```console
|
|
55
|
+
$ touchstone validate plan.yaml
|
|
56
|
+
plan.yaml: ok, 1 pack(s)
|
|
57
|
+
|
|
58
|
+
$ touchstone validate broken.yaml
|
|
59
|
+
broken.yaml: 1 problem(s)
|
|
60
|
+
example_pack: pack does not accept parameter 'max_itemz'
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
It resolves packs from `./packs`. Pass `--manifests` to point somewhere else. No
|
|
64
|
+
container runs, and it exits 1 if anything is wrong.
|
|
65
|
+
|
|
66
|
+
## Seal and verify a bundle
|
|
67
|
+
|
|
68
|
+
`bundle` hashes every file under a directory and writes `MANIFEST.json`:
|
|
69
|
+
|
|
70
|
+
```console
|
|
71
|
+
$ touchstone bundle run-004
|
|
72
|
+
run-004: sealed 3 file(s)
|
|
73
|
+
sha256 f57c02f1af4a277d404c29af41cb8953a513a1b0ca38884fcacaf0cbf3359d19
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
The printed hash covers the file list, so identical content seals to the same value on
|
|
77
|
+
any machine. Sealing a directory that already has a manifest is an error.
|
|
78
|
+
|
|
79
|
+
`verify` re-checks the bundle and names what moved:
|
|
80
|
+
|
|
81
|
+
```console
|
|
82
|
+
$ touchstone verify run-004
|
|
83
|
+
run-004: verified
|
|
84
|
+
|
|
85
|
+
$ touchstone verify tampered
|
|
86
|
+
tampered: 1 failure(s)
|
|
87
|
+
hash mismatch: items.jsonl
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Exit 0 means every file matches its recorded hash and no unrecorded file is present.
|
|
91
|
+
Exit 1 means it does not. There is no network call, no database and no config file.
|
|
92
|
+
|
|
93
|
+
## Verify without Touchstone
|
|
94
|
+
|
|
95
|
+
The bundle outlives the tool, so nothing in it needs the tool to read. Check any single
|
|
96
|
+
file against its recorded hash:
|
|
97
|
+
|
|
98
|
+
```console
|
|
99
|
+
$ shasum -a 256 run-004/items.jsonl
|
|
100
|
+
63a6e0f7ba35198b686265cab8c8b389599c8bb6c3fcff06234d5b68cda0d82f run-004/items.jsonl
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Recompute the bundle hash from the manifest alone:
|
|
104
|
+
|
|
105
|
+
```console
|
|
106
|
+
$ jq -cS '.files' run-004/MANIFEST.json | tr -d '\n' | shasum -a 256
|
|
107
|
+
f57c02f1af4a277d404c29af41cb8953a513a1b0ca38884fcacaf0cbf3359d19 -
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
That hash detects a file edited after sealing. It does not detect a forger who reseals
|
|
111
|
+
the whole bundle, which is what external anchoring is for. Anchoring is not built yet.
|
|
112
|
+
|
|
113
|
+
## The pipeline
|
|
114
|
+
|
|
115
|
+
```
|
|
116
|
+
validate -> freeze -> run -> estimate -> grade -> bundle -> verify
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
| Command | Does | State |
|
|
120
|
+
|---|---|---|
|
|
121
|
+
| `validate` | check a plan against the manifests of the packs it names | works |
|
|
122
|
+
| `freeze` | pin image digests, hash the plan, fix seeds and thresholds | exits 2 |
|
|
123
|
+
| `run` | execute packs, write per-item observations | exits 2 |
|
|
124
|
+
| `estimate` | compute rates and intervals, by stratum | exits 2 |
|
|
125
|
+
| `grade` | apply a score card, produce DQI indicators | exits 2 |
|
|
126
|
+
| `bundle` | hash every file in a directory, write `MANIFEST.json` | works |
|
|
127
|
+
| `verify` | re-check a bundle against its manifest, offline | works |
|
|
128
|
+
|
|
129
|
+
Only `run` needs a container. Everything after it is a function over files.
|
|
130
|
+
|
|
131
|
+
## Design
|
|
132
|
+
|
|
133
|
+
Three choices shape the rest:
|
|
134
|
+
|
|
135
|
+
- Packs emit one observation per item, not a summary. Touchstone computes the rates and
|
|
136
|
+
intervals, so a reader can recompute them from the sample in the bundle.
|
|
137
|
+
- Runs are pinned before they start. `freeze` resolves image tags to digests and hashes
|
|
138
|
+
the plan; `run` refuses a plan that has changed since.
|
|
139
|
+
- A missing file, an unresolvable digest or a stale hash is an error with a non-zero
|
|
140
|
+
exit, never a warning.
|
|
141
|
+
|
|
142
|
+
To write a pack, see [docs/packs.md](docs/packs.md).
|
|
143
|
+
|
|
144
|
+
## Licence
|
|
145
|
+
|
|
146
|
+
Apache 2.0. See [LICENSE](LICENSE).
|
|
147
|
+
|
|
148
|
+
## Contributing
|
|
149
|
+
|
|
150
|
+
Read [CONTRIBUTING.md](CONTRIBUTING.md) first. The commit message and code style rules
|
|
151
|
+
are enforced by CI.
|
|
152
|
+
|
|
153
|
+
Maintained by [Quantile Labs](https://quantilelabs.com).
|