pose-claim-audit 0.1.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.
- pose_claim_audit-0.1.0/LICENSE +21 -0
- pose_claim_audit-0.1.0/MANIFEST.in +3 -0
- pose_claim_audit-0.1.0/PKG-INFO +81 -0
- pose_claim_audit-0.1.0/README.md +71 -0
- pose_claim_audit-0.1.0/fixtures/bad/README.md +1 -0
- pose_claim_audit-0.1.0/fixtures/bad/app.py +1 -0
- pose_claim_audit-0.1.0/fixtures/good/README.md +1 -0
- pose_claim_audit-0.1.0/fixtures/good/app.py +2 -0
- pose_claim_audit-0.1.0/fixtures/no-claim/README.md +1 -0
- pose_claim_audit-0.1.0/fixtures/no-claim/app.py +1 -0
- pose_claim_audit-0.1.0/fixtures/no-pose/README.md +1 -0
- pose_claim_audit-0.1.0/fixtures/no-pose/app.py +2 -0
- pose_claim_audit-0.1.0/fixtures/testonly/README.md +1 -0
- pose_claim_audit-0.1.0/fixtures/testonly/tests/test_app.py +2 -0
- pose_claim_audit-0.1.0/pose_claim_audit/__init__.py +1 -0
- pose_claim_audit-0.1.0/pose_claim_audit/__main__.py +3 -0
- pose_claim_audit-0.1.0/pose_claim_audit/audit.py +198 -0
- pose_claim_audit-0.1.0/pose_claim_audit/phrases.py +104 -0
- pose_claim_audit-0.1.0/pose_claim_audit.egg-info/PKG-INFO +81 -0
- pose_claim_audit-0.1.0/pose_claim_audit.egg-info/SOURCES.txt +25 -0
- pose_claim_audit-0.1.0/pose_claim_audit.egg-info/dependency_links.txt +1 -0
- pose_claim_audit-0.1.0/pose_claim_audit.egg-info/entry_points.txt +2 -0
- pose_claim_audit-0.1.0/pose_claim_audit.egg-info/top_level.txt +1 -0
- pose_claim_audit-0.1.0/pyproject.toml +17 -0
- pose_claim_audit-0.1.0/setup.cfg +4 -0
- pose_claim_audit-0.1.0/tests/__init__.py +0 -0
- pose_claim_audit-0.1.0/tests/test_audit.py +152 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 pose-claim-audit contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pose-claim-audit
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Offline documentation and Python body-pose evidence auditor
|
|
5
|
+
License: MIT
|
|
6
|
+
Requires-Python: >=3.9
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Dynamic: license-file
|
|
10
|
+
|
|
11
|
+
# pose-claim-audit
|
|
12
|
+
|
|
13
|
+
An offline static auditor comparing body-pose promises in Markdown with
|
|
14
|
+
provider-resolved Python operations. Version 0.1.0; Python 3.9 or later;
|
|
15
|
+
MIT licensed; no runtime dependencies. Source is parsed, never executed.
|
|
16
|
+
|
|
17
|
+
Install and run:
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
pip install pose-claim-audit
|
|
21
|
+
pose-claim-audit ./project --json
|
|
22
|
+
python3 -m pose_claim_audit ./project --verbose
|
|
23
|
+
pose-claim-audit ./project --ignore 'vendor/*' --fail-on MEDIUM
|
|
24
|
+
pose-claim-audit --version
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
The documentation scope is root README.md and Markdown beneath any docs
|
|
28
|
+
path component. Blank lines separate paragraphs; fenced blocks are omitted,
|
|
29
|
+
inline code counts, and contractions, hyphens and whitespace are normalized.
|
|
30
|
+
Exact templates in phrases.py are matched longest first with word boundaries.
|
|
31
|
+
Negative spans are removed before positive matching. Example templates:
|
|
32
|
+
|
|
33
|
+
```text
|
|
34
|
+
supports pose estimation
|
|
35
|
+
does not estimate poses
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Evidence comes from mediapipe solutions pose.Pose construction or a bound
|
|
39
|
+
process call, and tasks vision.PoseLandmarker construction (including
|
|
40
|
+
create_from_options) or bound detect, detect_for_video and detect_async calls.
|
|
41
|
+
Import aliases and assignment, annotated assignment, attribute, with-target
|
|
42
|
+
and chained forms are recognized within each module. Local definitions shadow
|
|
43
|
+
imports. Construction alone counts; imports, image loading, camera capture,
|
|
44
|
+
landmark drawing, face/hand detection, generic YOLO objects, strings and
|
|
45
|
+
subprocess commands do not.
|
|
46
|
+
|
|
47
|
+
Symlinks are omitted. Production evidence excludes fixtures, docs, examples
|
|
48
|
+
and tests components and test_*.py or *_test.py names. Tests supply separate
|
|
49
|
+
fallback evidence; invalid Python supplies none. Repeatable --ignore patterns
|
|
50
|
+
use fnmatch against root-relative POSIX paths. files_scanned counts included
|
|
51
|
+
Markdown and Python files, including Python with invalid syntax.
|
|
52
|
+
|
|
53
|
+
Rules (at most one finding per family):
|
|
54
|
+
|
|
55
|
+
```text
|
|
56
|
+
documented-pose-claim-false: HIGH without production evidence; MEDIUM with test evidence only
|
|
57
|
+
documented-no-pose-claim-false: HIGH when production evidence contradicts a negative claim
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
JSON contains verdict, findings (rule, severity, message), and files_scanned.
|
|
61
|
+
Human output includes the verdict and findings; --verbose adds a file count.
|
|
62
|
+
Exit 0 means the selected threshold was not reached, including MEDIUM findings
|
|
63
|
+
at the default HIGH threshold. Exit 2 means failure; exit 1 means invalid or
|
|
64
|
+
unreadable input or a command-line usage error. --fail-on accepts HIGH or MEDIUM.
|
|
65
|
+
Without a documentation claim the result passes regardless of source.
|
|
66
|
+
|
|
67
|
+
This is a syntactic check, not proof of working inference or model quality.
|
|
68
|
+
Dynamic imports, intermodule bindings and arbitrary data flow are unsupported.
|
|
69
|
+
It does not load models, validate options, resolve runtime branches or check
|
|
70
|
+
that a constructed object receives real images. Module-wide binding resolution
|
|
71
|
+
is conservative about local name shadowing and does not model execution order.
|
|
72
|
+
|
|
73
|
+
Development:
|
|
74
|
+
|
|
75
|
+
```sh
|
|
76
|
+
python3 -m unittest discover
|
|
77
|
+
python3 -m build
|
|
78
|
+
python3 -m pose_claim_audit .
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
The source distribution includes the unittest suite and its fixtures.
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# pose-claim-audit
|
|
2
|
+
|
|
3
|
+
An offline static auditor comparing body-pose promises in Markdown with
|
|
4
|
+
provider-resolved Python operations. Version 0.1.0; Python 3.9 or later;
|
|
5
|
+
MIT licensed; no runtime dependencies. Source is parsed, never executed.
|
|
6
|
+
|
|
7
|
+
Install and run:
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
pip install pose-claim-audit
|
|
11
|
+
pose-claim-audit ./project --json
|
|
12
|
+
python3 -m pose_claim_audit ./project --verbose
|
|
13
|
+
pose-claim-audit ./project --ignore 'vendor/*' --fail-on MEDIUM
|
|
14
|
+
pose-claim-audit --version
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
The documentation scope is root README.md and Markdown beneath any docs
|
|
18
|
+
path component. Blank lines separate paragraphs; fenced blocks are omitted,
|
|
19
|
+
inline code counts, and contractions, hyphens and whitespace are normalized.
|
|
20
|
+
Exact templates in phrases.py are matched longest first with word boundaries.
|
|
21
|
+
Negative spans are removed before positive matching. Example templates:
|
|
22
|
+
|
|
23
|
+
```text
|
|
24
|
+
supports pose estimation
|
|
25
|
+
does not estimate poses
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Evidence comes from mediapipe solutions pose.Pose construction or a bound
|
|
29
|
+
process call, and tasks vision.PoseLandmarker construction (including
|
|
30
|
+
create_from_options) or bound detect, detect_for_video and detect_async calls.
|
|
31
|
+
Import aliases and assignment, annotated assignment, attribute, with-target
|
|
32
|
+
and chained forms are recognized within each module. Local definitions shadow
|
|
33
|
+
imports. Construction alone counts; imports, image loading, camera capture,
|
|
34
|
+
landmark drawing, face/hand detection, generic YOLO objects, strings and
|
|
35
|
+
subprocess commands do not.
|
|
36
|
+
|
|
37
|
+
Symlinks are omitted. Production evidence excludes fixtures, docs, examples
|
|
38
|
+
and tests components and test_*.py or *_test.py names. Tests supply separate
|
|
39
|
+
fallback evidence; invalid Python supplies none. Repeatable --ignore patterns
|
|
40
|
+
use fnmatch against root-relative POSIX paths. files_scanned counts included
|
|
41
|
+
Markdown and Python files, including Python with invalid syntax.
|
|
42
|
+
|
|
43
|
+
Rules (at most one finding per family):
|
|
44
|
+
|
|
45
|
+
```text
|
|
46
|
+
documented-pose-claim-false: HIGH without production evidence; MEDIUM with test evidence only
|
|
47
|
+
documented-no-pose-claim-false: HIGH when production evidence contradicts a negative claim
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
JSON contains verdict, findings (rule, severity, message), and files_scanned.
|
|
51
|
+
Human output includes the verdict and findings; --verbose adds a file count.
|
|
52
|
+
Exit 0 means the selected threshold was not reached, including MEDIUM findings
|
|
53
|
+
at the default HIGH threshold. Exit 2 means failure; exit 1 means invalid or
|
|
54
|
+
unreadable input or a command-line usage error. --fail-on accepts HIGH or MEDIUM.
|
|
55
|
+
Without a documentation claim the result passes regardless of source.
|
|
56
|
+
|
|
57
|
+
This is a syntactic check, not proof of working inference or model quality.
|
|
58
|
+
Dynamic imports, intermodule bindings and arbitrary data flow are unsupported.
|
|
59
|
+
It does not load models, validate options, resolve runtime branches or check
|
|
60
|
+
that a constructed object receives real images. Module-wide binding resolution
|
|
61
|
+
is conservative about local name shadowing and does not model execution order.
|
|
62
|
+
|
|
63
|
+
Development:
|
|
64
|
+
|
|
65
|
+
```sh
|
|
66
|
+
python3 -m unittest discover
|
|
67
|
+
python3 -m build
|
|
68
|
+
python3 -m pose_claim_audit .
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
The source distribution includes the unittest suite and its fixtures.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
supports pose estimation
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import mediapipe
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
supports pose estimation
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
A utility.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
x = 1
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
does not estimate poses
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
supports pose estimation
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.1.0"
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
"""Static documentation and provider evidence analysis."""
|
|
2
|
+
import argparse
|
|
3
|
+
import ast
|
|
4
|
+
import fnmatch
|
|
5
|
+
import json
|
|
6
|
+
import os
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
import re
|
|
9
|
+
import sys
|
|
10
|
+
|
|
11
|
+
from . import __version__
|
|
12
|
+
from .phrases import POSE, NOPOSE
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def matches(text, phrases):
|
|
16
|
+
spans = []
|
|
17
|
+
for phrase in sorted(phrases, key=len, reverse=True):
|
|
18
|
+
for match in re.finditer(r'\b' + re.escape(phrase) + r'\b', text):
|
|
19
|
+
if not any(match.start() < b and a < match.end() for a, b in spans):
|
|
20
|
+
spans.append(match.span())
|
|
21
|
+
return spans
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def claims(markdown):
|
|
25
|
+
lines = []
|
|
26
|
+
fence = None
|
|
27
|
+
for line in markdown.splitlines():
|
|
28
|
+
mark = re.match(r'^ {0,3}(`{3,}|~{3,})(.*)$', line)
|
|
29
|
+
if fence:
|
|
30
|
+
if mark and mark[1][0] == fence[0] and len(mark[1]) >= len(fence) and not mark[2].strip():
|
|
31
|
+
fence = None
|
|
32
|
+
continue
|
|
33
|
+
if mark:
|
|
34
|
+
fence = mark[1]
|
|
35
|
+
lines.append('')
|
|
36
|
+
else:
|
|
37
|
+
lines.append(line)
|
|
38
|
+
positive = negative = False
|
|
39
|
+
for paragraph in re.split(r'\n\s*\n', '\n'.join(lines)):
|
|
40
|
+
text = paragraph.lower().replace('’', "'").replace("n't", ' not').replace('-', ' ')
|
|
41
|
+
text = ' '.join(text.split())
|
|
42
|
+
spans = matches(text, NOPOSE)
|
|
43
|
+
negative |= bool(spans)
|
|
44
|
+
for a, b in sorted(spans, reverse=True):
|
|
45
|
+
text = text[:a] + ' ' * (b - a) + text[b:]
|
|
46
|
+
positive |= bool(matches(text, POSE))
|
|
47
|
+
return positive, negative
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def evidence(source):
|
|
51
|
+
try:
|
|
52
|
+
tree = ast.parse(source)
|
|
53
|
+
except (SyntaxError, ValueError):
|
|
54
|
+
return False
|
|
55
|
+
aliases = {}
|
|
56
|
+
shadowed = set()
|
|
57
|
+
for node in ast.walk(tree):
|
|
58
|
+
if isinstance(node, ast.Import):
|
|
59
|
+
for item in node.names:
|
|
60
|
+
aliases[item.asname or item.name.split('.')[0]] = item.name if item.asname else item.name.split('.')[0]
|
|
61
|
+
elif isinstance(node, ast.ImportFrom) and node.module:
|
|
62
|
+
for item in node.names:
|
|
63
|
+
aliases[item.asname or item.name] = node.module + '.' + item.name
|
|
64
|
+
elif isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef, ast.ClassDef)):
|
|
65
|
+
shadowed.add(node.name)
|
|
66
|
+
for name in shadowed:
|
|
67
|
+
aliases.pop(name, None)
|
|
68
|
+
|
|
69
|
+
def path(node):
|
|
70
|
+
if isinstance(node, ast.Name):
|
|
71
|
+
return aliases.get(node.id, '')
|
|
72
|
+
if isinstance(node, ast.Attribute):
|
|
73
|
+
parent = path(node.value)
|
|
74
|
+
return parent + '.' + node.attr if parent else ''
|
|
75
|
+
return ''
|
|
76
|
+
|
|
77
|
+
def construction(node):
|
|
78
|
+
if not isinstance(node, ast.Call):
|
|
79
|
+
return None
|
|
80
|
+
resolved = path(node.func)
|
|
81
|
+
if not resolved.startswith('mediapipe.'):
|
|
82
|
+
return None
|
|
83
|
+
if resolved.endswith('.pose.Pose'):
|
|
84
|
+
return 'pose'
|
|
85
|
+
if resolved.endswith('.PoseLandmarker') or resolved.endswith('.PoseLandmarker.create_from_options'):
|
|
86
|
+
return 'landmarker'
|
|
87
|
+
return None
|
|
88
|
+
|
|
89
|
+
bindings = {}
|
|
90
|
+
|
|
91
|
+
def key(node):
|
|
92
|
+
if isinstance(node, ast.Name):
|
|
93
|
+
return node.id
|
|
94
|
+
if isinstance(node, ast.Attribute):
|
|
95
|
+
base = key(node.value)
|
|
96
|
+
return base + '.' + node.attr if base else ''
|
|
97
|
+
return ''
|
|
98
|
+
|
|
99
|
+
for node in ast.walk(tree):
|
|
100
|
+
if construction(node):
|
|
101
|
+
return True
|
|
102
|
+
# Bindings also document the supported receiver shapes, independently
|
|
103
|
+
# of the fact that a construction itself already suffices.
|
|
104
|
+
targets, value = [], None
|
|
105
|
+
if isinstance(node, ast.Assign):
|
|
106
|
+
targets, value = node.targets, node.value
|
|
107
|
+
elif isinstance(node, ast.AnnAssign):
|
|
108
|
+
targets, value = [node.target], node.value
|
|
109
|
+
elif isinstance(node, ast.withitem):
|
|
110
|
+
targets, value = [node.optional_vars], node.context_expr
|
|
111
|
+
kind = construction(value)
|
|
112
|
+
if kind:
|
|
113
|
+
for target in targets:
|
|
114
|
+
bindings[key(target)] = kind
|
|
115
|
+
if isinstance(node, ast.Call) and isinstance(node.func, ast.Attribute):
|
|
116
|
+
kind = construction(node.func.value) or bindings.get(key(node.func.value))
|
|
117
|
+
if kind == 'pose' and node.func.attr == 'process':
|
|
118
|
+
return True
|
|
119
|
+
if kind == 'landmarker' and node.func.attr in ('detect', 'detect_for_video', 'detect_async'):
|
|
120
|
+
return True
|
|
121
|
+
return False
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def audit(root, ignores=()):
|
|
125
|
+
root = Path(root)
|
|
126
|
+
if not root.is_dir() or not os.access(root, os.R_OK | os.X_OK):
|
|
127
|
+
raise ValueError('root must be a readable directory')
|
|
128
|
+
positive = negative = production = test = False
|
|
129
|
+
count = 0
|
|
130
|
+
def ignored(rel):
|
|
131
|
+
return any(fnmatch.fnmatchcase(rel, pattern) for pattern in ignores)
|
|
132
|
+
def walk_error(error):
|
|
133
|
+
raise error
|
|
134
|
+
for directory, dirs, files in os.walk(root, onerror=walk_error, followlinks=False):
|
|
135
|
+
dirs[:] = sorted(d for d in dirs if not (Path(directory) / d).is_symlink()
|
|
136
|
+
and not ignored((Path(directory) / d).relative_to(root).as_posix()))
|
|
137
|
+
for name in sorted(files):
|
|
138
|
+
file = Path(directory) / name
|
|
139
|
+
rel = file.relative_to(root)
|
|
140
|
+
if file.is_symlink() or ignored(rel.as_posix()):
|
|
141
|
+
continue
|
|
142
|
+
doc = rel.as_posix() == 'README.md' or (file.suffix == '.md' and 'docs' in rel.parts[:-1])
|
|
143
|
+
if not doc and file.suffix != '.py':
|
|
144
|
+
continue
|
|
145
|
+
content = file.read_text(encoding='utf-8')
|
|
146
|
+
count += 1
|
|
147
|
+
if doc:
|
|
148
|
+
p, n = claims(content)
|
|
149
|
+
positive |= p
|
|
150
|
+
negative |= n
|
|
151
|
+
else:
|
|
152
|
+
if any(part in ('fixtures', 'docs', 'examples') for part in rel.parts[:-1]):
|
|
153
|
+
continue
|
|
154
|
+
is_test = 'tests' in rel.parts[:-1] or name.startswith('test_') or name.endswith('_test.py')
|
|
155
|
+
found = evidence(content)
|
|
156
|
+
if is_test:
|
|
157
|
+
test |= found
|
|
158
|
+
else:
|
|
159
|
+
production |= found
|
|
160
|
+
findings = []
|
|
161
|
+
if positive and not production:
|
|
162
|
+
findings.append(dict(rule='documented-pose-claim-false', severity='MEDIUM' if test else 'HIGH', message='Documentation promises body-pose functionality without production evidence.'))
|
|
163
|
+
if negative and production:
|
|
164
|
+
findings.append(dict(rule='documented-no-pose-claim-false', severity='HIGH', message='Documentation denies body-pose functionality but production evidence exists.'))
|
|
165
|
+
return dict(verdict='FAIL' if any(f['severity'] == 'HIGH' for f in findings) else 'PASS', findings=findings, files_scanned=count)
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
class Parser(argparse.ArgumentParser):
|
|
169
|
+
def error(self, message):
|
|
170
|
+
self.print_usage(sys.stderr)
|
|
171
|
+
self.exit(1, self.prog + ': error: ' + message + '\n')
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
def main(argv=None):
|
|
175
|
+
parser = Parser(prog='pose-claim-audit')
|
|
176
|
+
parser.add_argument('root')
|
|
177
|
+
parser.add_argument('--json', action='store_true')
|
|
178
|
+
parser.add_argument('--verbose', action='store_true')
|
|
179
|
+
parser.add_argument('--ignore', action='append', default=[])
|
|
180
|
+
parser.add_argument('--fail-on', choices=['HIGH', 'MEDIUM'], default='HIGH')
|
|
181
|
+
parser.add_argument('--version', action='version', version=__version__)
|
|
182
|
+
args = parser.parse_args(argv)
|
|
183
|
+
try:
|
|
184
|
+
result = audit(args.root, args.ignore)
|
|
185
|
+
except (OSError, ValueError, UnicodeError) as error:
|
|
186
|
+
print('Error: ' + str(error), file=sys.stderr)
|
|
187
|
+
return 1
|
|
188
|
+
failed = any(f['severity'] == 'HIGH' or args.fail_on == 'MEDIUM' for f in result['findings'])
|
|
189
|
+
result['verdict'] = 'FAIL' if failed else 'PASS'
|
|
190
|
+
if args.json:
|
|
191
|
+
print(json.dumps(result))
|
|
192
|
+
else:
|
|
193
|
+
print(result['verdict'])
|
|
194
|
+
for finding in result['findings']:
|
|
195
|
+
print('{severity} {rule}: {message}'.format(**finding))
|
|
196
|
+
if args.verbose:
|
|
197
|
+
print('Files scanned: ' + str(result['files_scanned']))
|
|
198
|
+
return 2 if failed else 0
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"""Exact documentation templates, ordered by descending length."""
|
|
2
|
+
|
|
3
|
+
POSE = (
|
|
4
|
+
'estimates body poses in images',
|
|
5
|
+
'supports body pose estimation',
|
|
6
|
+
'estimates body poses in video',
|
|
7
|
+
'estimate body poses in images',
|
|
8
|
+
'body pose estimation support',
|
|
9
|
+
'support body pose estimation',
|
|
10
|
+
'estimate body poses in video',
|
|
11
|
+
'detects body poses in images',
|
|
12
|
+
'detects body poses in video',
|
|
13
|
+
'detect body poses in images',
|
|
14
|
+
'detect body poses in video',
|
|
15
|
+
'tracks body poses in video',
|
|
16
|
+
'track body poses in video',
|
|
17
|
+
'estimates poses in images',
|
|
18
|
+
'supports pose estimation',
|
|
19
|
+
'estimates poses in video',
|
|
20
|
+
'estimate poses in images',
|
|
21
|
+
'support pose estimation',
|
|
22
|
+
'pose estimation support',
|
|
23
|
+
'supports pose detection',
|
|
24
|
+
'estimate poses in video',
|
|
25
|
+
'detects poses in images',
|
|
26
|
+
'detects skeleton joints',
|
|
27
|
+
'supports pose tracking',
|
|
28
|
+
'support pose detection',
|
|
29
|
+
'pose detection support',
|
|
30
|
+
'detects poses in video',
|
|
31
|
+
'detect poses in images',
|
|
32
|
+
'tracks poses in images',
|
|
33
|
+
'detect skeleton joints',
|
|
34
|
+
'tracks skeleton joints',
|
|
35
|
+
'recognizes body poses',
|
|
36
|
+
'recognises body poses',
|
|
37
|
+
'identifies body poses',
|
|
38
|
+
'pose tracking support',
|
|
39
|
+
'support pose tracking',
|
|
40
|
+
'estimates human poses',
|
|
41
|
+
'human pose estimation',
|
|
42
|
+
'detect poses in video',
|
|
43
|
+
'tracks poses in video',
|
|
44
|
+
'track poses in images',
|
|
45
|
+
'track skeleton joints',
|
|
46
|
+
'body pose estimation',
|
|
47
|
+
'recognize body poses',
|
|
48
|
+
'recognise body poses',
|
|
49
|
+
'estimates body poses',
|
|
50
|
+
'estimate human poses',
|
|
51
|
+
'track poses in video',
|
|
52
|
+
'identify body poses',
|
|
53
|
+
'estimate body poses',
|
|
54
|
+
'detects human poses',
|
|
55
|
+
'detects body poses',
|
|
56
|
+
'detect human poses',
|
|
57
|
+
'tracks human poses',
|
|
58
|
+
'detect body poses',
|
|
59
|
+
'tracks body poses',
|
|
60
|
+
'track human poses',
|
|
61
|
+
'track body poses',
|
|
62
|
+
'identifies poses',
|
|
63
|
+
'estimates poses',
|
|
64
|
+
'pose estimation',
|
|
65
|
+
'estimate poses',
|
|
66
|
+
'identify poses',
|
|
67
|
+
'pose detection',
|
|
68
|
+
'detects poses',
|
|
69
|
+
'pose tracking',
|
|
70
|
+
'detect poses',
|
|
71
|
+
'tracks poses',
|
|
72
|
+
'track poses',
|
|
73
|
+
'finds poses',
|
|
74
|
+
'find poses',
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
NOPOSE = (
|
|
78
|
+
'does not support body pose estimation',
|
|
79
|
+
'body pose estimation not supported',
|
|
80
|
+
'does not support pose estimation',
|
|
81
|
+
'does not support pose detection',
|
|
82
|
+
'does not support pose tracking',
|
|
83
|
+
'pose estimation not supported',
|
|
84
|
+
'does not estimate body poses',
|
|
85
|
+
'pose detection not supported',
|
|
86
|
+
'pose tracking not supported',
|
|
87
|
+
'does not detect body poses',
|
|
88
|
+
'never estimates body poses',
|
|
89
|
+
'does not track body poses',
|
|
90
|
+
'does not estimate poses',
|
|
91
|
+
'no body pose estimation',
|
|
92
|
+
'without pose estimation',
|
|
93
|
+
'without pose detection',
|
|
94
|
+
'does not detect poses',
|
|
95
|
+
'never estimates poses',
|
|
96
|
+
'without pose tracking',
|
|
97
|
+
'does not track poses',
|
|
98
|
+
'does not find poses',
|
|
99
|
+
'never detects poses',
|
|
100
|
+
'never tracks poses',
|
|
101
|
+
'no pose estimation',
|
|
102
|
+
'no pose detection',
|
|
103
|
+
'no pose tracking',
|
|
104
|
+
)
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pose-claim-audit
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Offline documentation and Python body-pose evidence auditor
|
|
5
|
+
License: MIT
|
|
6
|
+
Requires-Python: >=3.9
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Dynamic: license-file
|
|
10
|
+
|
|
11
|
+
# pose-claim-audit
|
|
12
|
+
|
|
13
|
+
An offline static auditor comparing body-pose promises in Markdown with
|
|
14
|
+
provider-resolved Python operations. Version 0.1.0; Python 3.9 or later;
|
|
15
|
+
MIT licensed; no runtime dependencies. Source is parsed, never executed.
|
|
16
|
+
|
|
17
|
+
Install and run:
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
pip install pose-claim-audit
|
|
21
|
+
pose-claim-audit ./project --json
|
|
22
|
+
python3 -m pose_claim_audit ./project --verbose
|
|
23
|
+
pose-claim-audit ./project --ignore 'vendor/*' --fail-on MEDIUM
|
|
24
|
+
pose-claim-audit --version
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
The documentation scope is root README.md and Markdown beneath any docs
|
|
28
|
+
path component. Blank lines separate paragraphs; fenced blocks are omitted,
|
|
29
|
+
inline code counts, and contractions, hyphens and whitespace are normalized.
|
|
30
|
+
Exact templates in phrases.py are matched longest first with word boundaries.
|
|
31
|
+
Negative spans are removed before positive matching. Example templates:
|
|
32
|
+
|
|
33
|
+
```text
|
|
34
|
+
supports pose estimation
|
|
35
|
+
does not estimate poses
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Evidence comes from mediapipe solutions pose.Pose construction or a bound
|
|
39
|
+
process call, and tasks vision.PoseLandmarker construction (including
|
|
40
|
+
create_from_options) or bound detect, detect_for_video and detect_async calls.
|
|
41
|
+
Import aliases and assignment, annotated assignment, attribute, with-target
|
|
42
|
+
and chained forms are recognized within each module. Local definitions shadow
|
|
43
|
+
imports. Construction alone counts; imports, image loading, camera capture,
|
|
44
|
+
landmark drawing, face/hand detection, generic YOLO objects, strings and
|
|
45
|
+
subprocess commands do not.
|
|
46
|
+
|
|
47
|
+
Symlinks are omitted. Production evidence excludes fixtures, docs, examples
|
|
48
|
+
and tests components and test_*.py or *_test.py names. Tests supply separate
|
|
49
|
+
fallback evidence; invalid Python supplies none. Repeatable --ignore patterns
|
|
50
|
+
use fnmatch against root-relative POSIX paths. files_scanned counts included
|
|
51
|
+
Markdown and Python files, including Python with invalid syntax.
|
|
52
|
+
|
|
53
|
+
Rules (at most one finding per family):
|
|
54
|
+
|
|
55
|
+
```text
|
|
56
|
+
documented-pose-claim-false: HIGH without production evidence; MEDIUM with test evidence only
|
|
57
|
+
documented-no-pose-claim-false: HIGH when production evidence contradicts a negative claim
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
JSON contains verdict, findings (rule, severity, message), and files_scanned.
|
|
61
|
+
Human output includes the verdict and findings; --verbose adds a file count.
|
|
62
|
+
Exit 0 means the selected threshold was not reached, including MEDIUM findings
|
|
63
|
+
at the default HIGH threshold. Exit 2 means failure; exit 1 means invalid or
|
|
64
|
+
unreadable input or a command-line usage error. --fail-on accepts HIGH or MEDIUM.
|
|
65
|
+
Without a documentation claim the result passes regardless of source.
|
|
66
|
+
|
|
67
|
+
This is a syntactic check, not proof of working inference or model quality.
|
|
68
|
+
Dynamic imports, intermodule bindings and arbitrary data flow are unsupported.
|
|
69
|
+
It does not load models, validate options, resolve runtime branches or check
|
|
70
|
+
that a constructed object receives real images. Module-wide binding resolution
|
|
71
|
+
is conservative about local name shadowing and does not model execution order.
|
|
72
|
+
|
|
73
|
+
Development:
|
|
74
|
+
|
|
75
|
+
```sh
|
|
76
|
+
python3 -m unittest discover
|
|
77
|
+
python3 -m build
|
|
78
|
+
python3 -m pose_claim_audit .
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
The source distribution includes the unittest suite and its fixtures.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
MANIFEST.in
|
|
3
|
+
README.md
|
|
4
|
+
pyproject.toml
|
|
5
|
+
fixtures/bad/README.md
|
|
6
|
+
fixtures/bad/app.py
|
|
7
|
+
fixtures/good/README.md
|
|
8
|
+
fixtures/good/app.py
|
|
9
|
+
fixtures/no-claim/README.md
|
|
10
|
+
fixtures/no-claim/app.py
|
|
11
|
+
fixtures/no-pose/README.md
|
|
12
|
+
fixtures/no-pose/app.py
|
|
13
|
+
fixtures/testonly/README.md
|
|
14
|
+
fixtures/testonly/tests/test_app.py
|
|
15
|
+
pose_claim_audit/__init__.py
|
|
16
|
+
pose_claim_audit/__main__.py
|
|
17
|
+
pose_claim_audit/audit.py
|
|
18
|
+
pose_claim_audit/phrases.py
|
|
19
|
+
pose_claim_audit.egg-info/PKG-INFO
|
|
20
|
+
pose_claim_audit.egg-info/SOURCES.txt
|
|
21
|
+
pose_claim_audit.egg-info/dependency_links.txt
|
|
22
|
+
pose_claim_audit.egg-info/entry_points.txt
|
|
23
|
+
pose_claim_audit.egg-info/top_level.txt
|
|
24
|
+
tests/__init__.py
|
|
25
|
+
tests/test_audit.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
pose_claim_audit
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "pose-claim-audit"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Offline documentation and Python body-pose evidence auditor"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = {text = "MIT"}
|
|
12
|
+
|
|
13
|
+
[project.scripts]
|
|
14
|
+
pose-claim-audit = "pose_claim_audit.audit:main"
|
|
15
|
+
|
|
16
|
+
[tool.setuptools.packages.find]
|
|
17
|
+
include = ["pose_claim_audit*"]
|
|
File without changes
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import ast
|
|
2
|
+
import json
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
import subprocess
|
|
5
|
+
import sys
|
|
6
|
+
import tempfile
|
|
7
|
+
import unittest
|
|
8
|
+
|
|
9
|
+
from pose_claim_audit.audit import audit, claims, evidence, matches
|
|
10
|
+
from pose_claim_audit.phrases import POSE, NOPOSE
|
|
11
|
+
|
|
12
|
+
ROOT = Path(__file__).resolve().parents[1]
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class ClaimsTests(unittest.TestCase):
|
|
16
|
+
def test_fences(self):
|
|
17
|
+
for fence in ('```', '~~~', ' ````'):
|
|
18
|
+
self.assertEqual(claims(fence+'\nsupports pose estimation\n'+fence), (False, False))
|
|
19
|
+
|
|
20
|
+
def test_inline(self):
|
|
21
|
+
self.assertEqual(claims('`supports pose estimation`'), (True, False))
|
|
22
|
+
|
|
23
|
+
def test_negative_removal(self):
|
|
24
|
+
for phrase in NOPOSE:
|
|
25
|
+
self.assertEqual(claims(phrase), (False, True), phrase)
|
|
26
|
+
|
|
27
|
+
def test_positive_templates(self):
|
|
28
|
+
for phrase in POSE:
|
|
29
|
+
self.assertEqual(claims(phrase), (True, False), phrase)
|
|
30
|
+
|
|
31
|
+
def test_hyphens(self):
|
|
32
|
+
self.assertEqual(claims('supports-pose-estimation'), (True, False))
|
|
33
|
+
|
|
34
|
+
def test_contractions(self):
|
|
35
|
+
self.assertEqual(claims("doesn't estimate poses"), (False, True))
|
|
36
|
+
|
|
37
|
+
def test_paragraph_join(self):
|
|
38
|
+
self.assertEqual(claims('supports pose\nestimation'), (True, False))
|
|
39
|
+
self.assertEqual(claims('supports pose\n\nestimation'), (False, False))
|
|
40
|
+
|
|
41
|
+
def test_longest(self):
|
|
42
|
+
self.assertEqual(matches('body pose estimation support', reversed(POSE)), [(0,28)])
|
|
43
|
+
|
|
44
|
+
def test_boundaries(self):
|
|
45
|
+
self.assertEqual(claims('redetect posesx'), (False, False))
|
|
46
|
+
|
|
47
|
+
def test_sorted_unique(self):
|
|
48
|
+
for phrases in (POSE, NOPOSE):
|
|
49
|
+
self.assertEqual(list(phrases), sorted(phrases, key=len, reverse=True))
|
|
50
|
+
self.assertEqual(len(phrases),len(set(phrases)))
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
class EvidenceTests(unittest.TestCase):
|
|
54
|
+
pass
|
|
55
|
+
|
|
56
|
+
POSITIVE = {
|
|
57
|
+
'direct': 'import mediapipe\nmediapipe.solutions.pose.Pose()',
|
|
58
|
+
'alias': 'import mediapipe as mp\nmp.solutions.pose.Pose()',
|
|
59
|
+
'from_import': 'from mediapipe.solutions.pose import Pose\nPose()',
|
|
60
|
+
'module_alias': 'from mediapipe.solutions import pose as p\np.Pose()',
|
|
61
|
+
'with': 'from mediapipe.solutions.pose import Pose\nwith Pose() as p:\n p.process(image)',
|
|
62
|
+
'attribute': 'from mediapipe.solutions.pose import Pose\nself.p = Pose()\nself.p.process(image)',
|
|
63
|
+
'chained': 'from mediapipe.solutions.pose import Pose\nPose().process(image)',
|
|
64
|
+
'bound_process': 'from mediapipe.solutions.pose import Pose\np=Pose()\np.process(image)',
|
|
65
|
+
'annotated': 'from mediapipe.solutions.pose import Pose\np: object = Pose()\np.process(image)',
|
|
66
|
+
'tasks_direct': 'import mediapipe as mp\nmp.tasks.vision.PoseLandmarker.create_from_options(options)',
|
|
67
|
+
'tasks_from': 'from mediapipe.tasks.vision import PoseLandmarker as P\nP.create_from_options(options)',
|
|
68
|
+
'tasks_construct': 'from mediapipe.tasks.vision import PoseLandmarker\nPoseLandmarker(options)',
|
|
69
|
+
}
|
|
70
|
+
for method in ('detect', 'detect_for_video', 'detect_async'):
|
|
71
|
+
POSITIVE['bound_'+method]='from mediapipe.tasks.vision import PoseLandmarker as P\np=P.create_from_options(options)\np.'+method+'(image)'
|
|
72
|
+
NEGATIVE = {
|
|
73
|
+
'bare_import':'import mediapipe',
|
|
74
|
+
'image_open':'import cv2\ncv2.imread("image")\nfrom PIL import Image\nImage.open("image")',
|
|
75
|
+
'camera':'import cv2\ncv2.VideoCapture(0).read()',
|
|
76
|
+
'drawing':'import mediapipe as mp\nmp.solutions.drawing_utils.draw_landmarks(image, landmarks)',
|
|
77
|
+
'face':'import mediapipe as mp\nmp.solutions.face_detection.FaceDetection()',
|
|
78
|
+
'hand':'import mediapipe as mp\nmp.solutions.hands.Hands()',
|
|
79
|
+
'yolo':'from ultralytics import YOLO\nYOLO("model")',
|
|
80
|
+
'local_class':'from mediapipe.solutions.pose import Pose\nclass Pose: pass\nPose()',
|
|
81
|
+
'local_function':'from mediapipe.tasks.vision import PoseLandmarker\ndef PoseLandmarker(): pass\nPoseLandmarker()',
|
|
82
|
+
'shadow_module':'import mediapipe as mp\ndef mp(): pass\nmp.solutions.pose.Pose()',
|
|
83
|
+
'unbound':'p.process(image)\np.detect(image)\np.detect_for_video(image)\np.detect_async(image)',
|
|
84
|
+
'string':'s="mediapipe.solutions.pose.Pose() skeleton pose"',
|
|
85
|
+
'subprocess':'import subprocess\nsubprocess.run(["pose", "detect"])',
|
|
86
|
+
'syntax':'import mediapipe\nmediapipe.solutions.pose.Pose((',
|
|
87
|
+
'other_provider':'import other\nother.pose.Pose()\nother.PoseLandmarker()',
|
|
88
|
+
}
|
|
89
|
+
def case(source, expected):
|
|
90
|
+
def test(self): self.assertEqual(evidence(source), expected)
|
|
91
|
+
return test
|
|
92
|
+
for name, source in POSITIVE.items(): setattr(EvidenceTests,'test_'+name,case(source, True))
|
|
93
|
+
for name, source in NEGATIVE.items(): setattr(EvidenceTests,'test_'+name,case(source, False))
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
class IntegrationTests(unittest.TestCase):
|
|
97
|
+
def cli(self, *args):
|
|
98
|
+
p=subprocess.run([sys.executable,'-m','pose_claim_audit',*map(str,args)],capture_output=True,text=True)
|
|
99
|
+
return p
|
|
100
|
+
|
|
101
|
+
def test_fixtures(self):
|
|
102
|
+
for fixture,code,rule,severity in [('good',0,None,None),('bad',2,'documented-pose-claim-false','HIGH'),('testonly',0,'documented-pose-claim-false','MEDIUM'),('no-pose',2,'documented-no-pose-claim-false','HIGH'),('no-claim',0,None,None)]:
|
|
103
|
+
p=self.cli(ROOT/'fixtures'/fixture,'--json'); self.assertEqual(p.returncode,code,p.stderr)
|
|
104
|
+
data=json.loads(p.stdout); self.assertEqual(set(data),{'verdict','findings','files_scanned'})
|
|
105
|
+
self.assertEqual(len(data['findings']),int(rule is not None))
|
|
106
|
+
if rule: self.assertEqual((data['findings'][0]['rule'],data['findings'][0]['severity']),(rule,severity))
|
|
107
|
+
self.assertEqual(self.cli(ROOT/'fixtures/testonly','--fail-on','MEDIUM').returncode,2)
|
|
108
|
+
|
|
109
|
+
def test_ignore(self):
|
|
110
|
+
self.assertEqual(audit(ROOT/'fixtures/bad',['README.*'])['findings'],[])
|
|
111
|
+
|
|
112
|
+
def test_verbose(self):
|
|
113
|
+
self.assertIn('Files scanned: 2',self.cli(ROOT/'fixtures/good','--verbose').stdout)
|
|
114
|
+
|
|
115
|
+
def test_version(self):
|
|
116
|
+
p=self.cli('--version'); self.assertEqual((p.returncode,p.stdout.strip()),(0,'0.1.0'))
|
|
117
|
+
|
|
118
|
+
def test_invalid_root(self):
|
|
119
|
+
self.assertEqual(self.cli(ROOT/'missing').returncode,1)
|
|
120
|
+
self.assertEqual(self.cli(ROOT/'README.md').returncode,1)
|
|
121
|
+
|
|
122
|
+
def test_usage(self):
|
|
123
|
+
for args in [(),('--unknown',),('.', '--fail-on','LOW')]:
|
|
124
|
+
self.assertEqual(self.cli(*args).returncode,1)
|
|
125
|
+
|
|
126
|
+
def test_self(self):
|
|
127
|
+
self.assertEqual(audit(ROOT)['findings'],[])
|
|
128
|
+
|
|
129
|
+
def test_exclusions_symlinks_docs(self):
|
|
130
|
+
with tempfile.TemporaryDirectory() as temp:
|
|
131
|
+
d=Path(temp); (d/'README.md').write_text('supports pose estimation')
|
|
132
|
+
for component in ('fixtures','examples','docs','tests'):
|
|
133
|
+
(d/component).mkdir(); (d/component/'source.py').write_text(POSITIVE['direct'])
|
|
134
|
+
(d/'linked.py').symlink_to(d/'tests/source.py')
|
|
135
|
+
(d/'linked_dir').symlink_to(d/'tests',target_is_directory=True)
|
|
136
|
+
result=audit(d); self.assertEqual(result['findings'][0]['severity'],'MEDIUM')
|
|
137
|
+
(d/'tests/source.py').unlink()
|
|
138
|
+
self.assertEqual(audit(d)['findings'][0]['severity'],'HIGH')
|
|
139
|
+
(d/'README.md').write_text('Utility')
|
|
140
|
+
(d/'docs/note.md').write_text('supports pose estimation')
|
|
141
|
+
self.assertEqual(len(audit(d)['findings']),1)
|
|
142
|
+
|
|
143
|
+
def test_test_filename(self):
|
|
144
|
+
with tempfile.TemporaryDirectory() as temp:
|
|
145
|
+
d=Path(temp); (d/'README.md').write_text('supports pose estimation')
|
|
146
|
+
for name in ('test_app.py','app_test.py'):
|
|
147
|
+
f=d/name; f.write_text(POSITIVE['direct'])
|
|
148
|
+
self.assertEqual(audit(d)['findings'][0]['severity'],'MEDIUM'); f.unlink()
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
if __name__ == '__main__':
|
|
152
|
+
unittest.main()
|