interactive-claim-audit 0.1.0__py3-none-any.whl

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.
@@ -0,0 +1,2 @@
1
+ """Offline static audit of documented interactivity claims."""
2
+ __version__ = '0.1.0'
@@ -0,0 +1,47 @@
1
+ """Command line entry point."""
2
+ import argparse
3
+ import json
4
+ import sys
5
+ from . import __version__
6
+ from .audit import audit
7
+
8
+
9
+ class Parser(argparse.ArgumentParser):
10
+ def error(self, message):
11
+ self.print_usage(sys.stderr)
12
+ self.exit(1, self.prog + ': error: ' + message + '\n')
13
+
14
+
15
+ def main(argv=None):
16
+ parser = Parser(description='Offline static audit of documented interactivity claims.')
17
+ parser.add_argument('path', nargs='?', default='.')
18
+ parser.add_argument('--json', action='store_true', dest='as_json')
19
+ parser.add_argument('--verbose', action='store_true')
20
+ parser.add_argument('--ignore', action='append', default=[], metavar='GLOB')
21
+ parser.add_argument('--fail-on', choices=['MEDIUM', 'HIGH'], default='MEDIUM')
22
+ parser.add_argument('--version', action='version', version=__version__)
23
+ args = parser.parse_args(argv)
24
+ try:
25
+ result = audit(args.path, args.ignore)
26
+ except (OSError, ValueError) as exc:
27
+ parser.error(str(exc))
28
+ failed = any(f['severity'] == 'HIGH' or args.fail_on == 'MEDIUM' for f in result['findings'])
29
+ result['status'] = 'FAIL' if failed else 'PASS'
30
+ if args.as_json:
31
+ print(json.dumps(result, indent=2))
32
+ else:
33
+ print(result['status'])
34
+ for finding in result['findings']:
35
+ print(finding['severity'] + ' ' + finding['rule'])
36
+ for item in finding['evidence']:
37
+ print(' ' + item.get('path', '') + ':' + str(item.get('line', '')) + ' ' + item['kind'])
38
+ if args.verbose:
39
+ for claim in result['verified_claims']:
40
+ print('verified: ' + claim['family'])
41
+ for error in result['errors']:
42
+ print('parse warning: ' + error['path'] + ': ' + error['message'])
43
+ return 2 if failed else 0
44
+
45
+
46
+ if __name__ == '__main__':
47
+ sys.exit(main())
@@ -0,0 +1,158 @@
1
+ """Static documentation and prompt-call auditing; never imports audited code."""
2
+ import ast
3
+ import fnmatch
4
+ import os
5
+ from pathlib import Path
6
+ import re
7
+
8
+ NONINTERACTIVE = (
9
+ 'non-interactive', 'non interactive', 'not interactive', 'no prompts',
10
+ 'no user input', 'without user input', 'does not prompt', "doesn't prompt",
11
+ 'never prompts', 'without prompting', 'no interaction required',
12
+ 'no confirmation prompt', 'no manual intervention', 'does not ask',
13
+ 'never asks', 'runs unattended', 'unattended', 'CI-friendly', 'CI friendly',
14
+ 'suitable for CI', 'works in CI',
15
+ )
16
+ INTERACTIVE = (
17
+ 'interactive mode', 'interactive prompt', 'interactive use',
18
+ 'interactive confirmation', 'confirmation prompt', 'prompts for confirmation',
19
+ 'asks for confirmation', 'asks the user', 'prompts the user',
20
+ 'prompt for confirmation', 'ask the user',
21
+ )
22
+ NEGATION = re.compile(r"\b(?:no|not|never|without|doesn't|don't|isn't|does not)\b", re.I)
23
+
24
+
25
+ def phrase_pattern(phrases):
26
+ return re.compile(r'(?<!\w)(?:' + '|'.join(re.escape(p) for p in sorted(phrases, key=len, reverse=True)) + r')(?!\w)', re.I)
27
+
28
+
29
+ def extract_claims(text, path='README.md'):
30
+ """Return phrase occurrences with locations, excluding Markdown fences."""
31
+ lines = []
32
+ fence = None
33
+ for line in text.splitlines(keepends=True):
34
+ match = re.match(r'^\s{0,3}(`{3,}|~{3,})', line)
35
+ if fence:
36
+ lines.append('\n' if line.endswith('\n') else '')
37
+ if match and match[1][0] == fence[0] and len(match[1]) >= len(fence) and not line[match.end():].strip():
38
+ fence = None
39
+ elif match:
40
+ fence = match[1]
41
+ lines.append('\n' if line.endswith('\n') else '')
42
+ else:
43
+ lines.append(line)
44
+ prose = ''.join(lines)
45
+ result = []
46
+ for sentence in re.finditer(r'[^.!?]+(?:[.!?]|$)', prose):
47
+ value = sentence[0]
48
+ masked = list(value)
49
+ for match in phrase_pattern(NONINTERACTIVE).finditer(value):
50
+ result.append({'family': 'noninteractive', 'path': path,
51
+ 'line': prose.count('\n', 0, sentence.start() + match.start()) + 1,
52
+ 'phrase': match[0]})
53
+ masked[match.start():match.end()] = ' ' * len(match[0])
54
+ if not NEGATION.search(value):
55
+ for match in phrase_pattern(INTERACTIVE).finditer(''.join(masked)):
56
+ result.append({'family': 'interactive', 'path': path,
57
+ 'line': prose.count('\n', 0, sentence.start() + match.start()) + 1,
58
+ 'phrase': match[0]})
59
+ return result
60
+
61
+
62
+ def extract_evidence(source, path):
63
+ tree = ast.parse(source, filename=path)
64
+ getpass_names = set()
65
+ questionary_names = set()
66
+ questionary_functions = set()
67
+ toolkit_names = set()
68
+ toolkit_imported = False
69
+ for node in ast.walk(tree):
70
+ if isinstance(node, ast.Import):
71
+ for alias in node.names:
72
+ if alias.name == 'questionary':
73
+ questionary_names.add(alias.asname or alias.name)
74
+ if alias.name == 'prompt_toolkit' or alias.name.startswith('prompt_toolkit.'):
75
+ toolkit_names.add(alias.asname or alias.name.split('.')[0])
76
+ toolkit_imported = True
77
+ elif isinstance(node, ast.ImportFrom):
78
+ if node.module == 'getpass':
79
+ getpass_names.update(a.asname or a.name for a in node.names if a.name == 'getpass')
80
+ if node.module == 'questionary':
81
+ questionary_functions.update(a.asname or a.name for a in node.names)
82
+ if node.module and (node.module == 'prompt_toolkit' or node.module.startswith('prompt_toolkit.')):
83
+ toolkit_imported = True
84
+ toolkit_names.update(a.asname or a.name for a in node.names if a.name == 'shortcuts')
85
+ toolkit_names.update(a.asname or a.name for a in node.names if a.name == 'prompt')
86
+ result = {}
87
+ for node in ast.walk(tree):
88
+ if not isinstance(node, ast.Call):
89
+ continue
90
+ func = node.func
91
+ kind = None
92
+ if isinstance(func, ast.Name):
93
+ if func.id == 'input':
94
+ kind = 'input'
95
+ elif func.id in getpass_names:
96
+ kind = 'getpass'
97
+ elif func.id in questionary_functions:
98
+ kind = 'questionary'
99
+ elif toolkit_imported and (func.id == 'prompt' or func.id in toolkit_names and func.id != 'shortcuts'):
100
+ kind = 'prompt_toolkit'
101
+ elif isinstance(func, ast.Attribute):
102
+ if func.attr in ('prompt', 'confirm', 'getpass'):
103
+ kind = func.attr
104
+ elif func.attr == 'input' and isinstance(func.value, ast.Name) and func.value.id == 'builtins':
105
+ kind = 'input'
106
+ elif isinstance(func.value, ast.Name) and func.value.id in questionary_names:
107
+ kind = 'questionary'
108
+ if kind:
109
+ result[(path, node.lineno, kind)] = {'path': path, 'line': node.lineno, 'kind': kind}
110
+ return sorted(result.values(), key=lambda e: (e['path'], e['line'], e['kind']))
111
+
112
+
113
+ def audit(root, ignore=()):
114
+ root = Path(root)
115
+ if not root.is_dir():
116
+ raise ValueError('audit path must be a directory')
117
+ claims, production, testonly, errors = [], [], [], []
118
+ source_count = 0
119
+ for directory, dirs, files in os.walk(root, followlinks=False):
120
+ dirs[:] = sorted(d for d in dirs if not (Path(directory) / d).is_symlink() and not any(fnmatch.fnmatch((Path(directory) / d).relative_to(root).as_posix(), p) for p in ignore))
121
+ for name in sorted(files):
122
+ file = Path(directory) / name
123
+ relative = file.relative_to(root)
124
+ path = relative.as_posix()
125
+ if file.is_symlink() or name == '.env' or name.startswith('.env.') or any(fnmatch.fnmatch(path, p) for p in ignore):
126
+ continue
127
+ is_doc = path == 'README.md' or (relative.parts[0] == 'docs' and file.suffix == '.md')
128
+ if is_doc:
129
+ claims.extend(extract_claims(file.read_text(encoding='utf-8'), path))
130
+ if file.suffix != '.py' or any(p in ('docs', 'examples') for p in relative.parts[:-1]):
131
+ continue
132
+ test = any(p in ('tests', 'fixtures') for p in relative.parts[:-1]) or name.startswith('test_') or name.endswith('_test.py')
133
+ if not test:
134
+ source_count += 1
135
+ try:
136
+ evidence = extract_evidence(file.read_text(encoding='utf-8-sig'), path)
137
+ except (SyntaxError, UnicodeError) as exc:
138
+ errors.append({'path': path, 'message': str(exc)})
139
+ continue
140
+ (testonly if test else production).extend(evidence)
141
+ findings, verified = [], []
142
+ for family in ('noninteractive', 'interactive'):
143
+ family_claims = [c for c in claims if c['family'] == family]
144
+ if not family_claims:
145
+ continue
146
+ evidence = production
147
+ severity, suffix = 'HIGH', ''
148
+ if not source_count:
149
+ evidence = [{'kind': 'no-source'}]
150
+ elif not production and testonly:
151
+ severity, suffix, evidence = 'MEDIUM', '-test-only', testonly
152
+ elif (family == 'noninteractive' and not production) or (family == 'interactive' and production):
153
+ verified.append({'family': family, 'claims': family_claims, 'evidence': production})
154
+ continue
155
+ findings.append({'rule': 'documented-' + family + '-claim-false' + suffix,
156
+ 'severity': severity, 'claims': family_claims, 'evidence': evidence})
157
+ return {'findings': findings, 'verified_claims': verified, 'claims': claims,
158
+ 'production_evidence': production, 'test_only_evidence': testonly, 'errors': errors}
@@ -0,0 +1,141 @@
1
+ Metadata-Version: 2.4
2
+ Name: interactive-claim-audit
3
+ Version: 0.1.0
4
+ Summary: Offline static audit of documented interactivity claims.
5
+ License: MIT
6
+ Requires-Python: >=3.9
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ Dynamic: license-file
10
+
11
+ # interactive-claim-audit
12
+
13
+ Offline static audit of documented interactivity claims.
14
+
15
+ Version 0.1.0 · Python 3.9+ · MIT · standard library only at runtime.
16
+
17
+ Compare documentation promises about human interaction with named Python call sites. The auditor parses source without importing or executing the audited project, uses no network, skips symlinks, and skips `.env` and `.env.*` file contents.
18
+
19
+ ## Usage
20
+
21
+ Install from a local checkout:
22
+
23
+ ```sh
24
+ python3 -m pip install .
25
+ interactive-claim-audit /path/to/project
26
+ python3 -m interactive_claim_audit /path/to/project --json
27
+ interactive-claim-audit /path/to/project --verbose --ignore 'vendor/*'
28
+ interactive-claim-audit /path/to/project --fail-on HIGH
29
+ interactive-claim-audit --version
30
+ ```
31
+
32
+ The path defaults to the current directory. `--ignore GLOB` is repeatable and matches relative paths. `--verbose` adds verified families and parse warnings to text output. `--json` emits a JSON object containing `status`, `findings`, `verified_claims`, `claims`, `production_evidence`, `test_only_evidence`, and `errors`.
33
+
34
+ Exit codes are 0 for PASS, 2 for findings meeting the selected threshold, and 1 for usage errors. The default threshold is MEDIUM; `--fail-on HIGH` leaves MEDIUM findings visible but permits exit 0.
35
+
36
+ ## Rules
37
+
38
+ Documentation occurrences collapse into two families, `noninteractive` and `interactive`, evaluated independently. Each failing family produces one finding containing all applicable evidence items.
39
+
40
+ | Rule | Severity | Condition |
41
+ | --- | --- | --- |
42
+ | `documented-noninteractive-claim-false` | HIGH | The noninteractive family has production evidence. |
43
+ | `documented-noninteractive-claim-false-test-only` | MEDIUM | That family has evidence only in test or fixture sources. |
44
+ | `documented-interactive-claim-false` | HIGH | The interactive family lacks production evidence and has no test evidence. |
45
+ | `documented-interactive-claim-false-test-only` | MEDIUM | That family has evidence only in test or fixture sources. |
46
+
47
+ A claimed family with no production Python files produces one HIGH finding with `no-source` evidence, taking priority over the test-only rules. With production files present, the noninteractive family is verified when evidence is absent everywhere; the interactive family is verified when production evidence exists. Verified families appear in `verified_claims`. A tree with zero documentation claims passes regardless of its call sites.
48
+
49
+ ## Claim vocabulary
50
+
51
+ Only root `README.md` and `docs/**/*.md` supply claims. Fenced code blocks are excluded; inline code spans count as prose. Matching is case-insensitive and limited to the exact phrases below; hyphen and space spellings are accepted only where explicitly listed.
52
+
53
+ ```text
54
+ NONINTERACTIVE
55
+ non-interactive
56
+ non interactive
57
+ not interactive
58
+ no prompts
59
+ no user input
60
+ without user input
61
+ does not prompt
62
+ doesn't prompt
63
+ never prompts
64
+ without prompting
65
+ no interaction required
66
+ no confirmation prompt
67
+ no manual intervention
68
+ does not ask
69
+ never asks
70
+ runs unattended
71
+ unattended
72
+ CI-friendly
73
+ CI friendly
74
+ suitable for CI
75
+ works in CI
76
+
77
+ INTERACTIVE
78
+ interactive mode
79
+ interactive prompt
80
+ interactive use
81
+ interactive confirmation
82
+ confirmation prompt
83
+ prompts for confirmation
84
+ asks for confirmation
85
+ asks the user
86
+ prompts the user
87
+ prompt for confirmation
88
+ ask the user
89
+ ```
90
+
91
+ Negation is asymmetric: a sentence containing `no`, `not`, `never`, `without`, `doesn't`, `don't`, `isn't`, or `does not` suppresses the interactive family. Matches in the noninteractive family still count, including its negated phrases. Overlap masking finds the noninteractive family first, masks its matched spans, and searches the remaining text for the interactive family. This prevents a substring from generating an extra family match.
92
+
93
+ The bare words “interactive” and “prompt” are not claims. Paraphrases outside the vocabulary are not inferred. Contradictory documentation can supply both families; each receives its own evaluation.
94
+
95
+ ## Named evidence table
96
+
97
+ Evidence is collected from Python AST calls and deduplicated by relative file, line, and kind. Imports and aliases are tracked per file where indicated.
98
+
99
+ | Named call | Evidence treatment |
100
+ | --- | --- |
101
+ | `input(...)`, `builtins.input(...)` | Counts, including a locally shadowed `input`. |
102
+ | `.getpass(...)` | Counts on any receiver spelling. |
103
+ | Imported bare `getpass(...)` | Counts with `from getpass import getpass`, including aliases; a bare name without that import does not count. |
104
+ | `.prompt(...)` | Counts on any receiver, including Click, Questionary objects, and toolkit sessions. |
105
+ | `.confirm(...)` | Counts on any receiver. |
106
+ | `questionary.<name>(...)` or imported Questionary functions | Counts with tracked module or function imports and aliases. |
107
+ | Toolkit `prompt(...)` | Counts with a per-file `prompt_toolkit` import; imported `prompt` aliases and `shortcuts` imports are recognized. |
108
+
109
+ Production evidence excludes `tests/`, `fixtures/`, test filename patterns (`test_*.py`, `*_test.py`), `docs/`, and `examples/`. Test and fixture evidence is collected separately; docs and examples supply no source evidence. Symlinked files and directories are skipped. Parse and decoding failures are reported in `errors`; they are not proof that a file lacks relevant behavior.
110
+
111
+ ## Differentiation
112
+
113
+ | Neighbour | Its question | This tool's distinction |
114
+ | --- | --- | --- |
115
+ | auth-claim-audit | Are credentials required? | Examines dependence on a human, including filename and yes/no questions. `getpass` overlaps explicitly: login evidence there, human-input evidence here. |
116
+ | error-claim-audit | Which failures occur? | Examines waiting for a person. |
117
+ | concurrency-claim-audit | What execution model is used? | Examines human interaction. |
118
+ | timeout-claim-audit | What time bounds apply? | Examines human blocking rather than elapsed-time guarantees. |
119
+ | Bandit / Ruff | What code issues exist? | Compares documentation promises with source evidence. |
120
+ | Click / Questionary / prompt_toolkit documentation | How are input primitives used? | Checks documentation against a project's source instead of teaching those APIs. |
121
+
122
+ ## Honest limitations
123
+
124
+ This is a vocabulary-and-call-site check, not a behavioral proof. Exact-phrase claims miss paraphrases. Dead code counts: a call in an uncalled function is still evidence. Reachability, branches, flag defaults, runtime configuration, and whether a person actually sees a question are not inferred. A successful result does not prove every documented execution path behaves as intended.
125
+
126
+ Receiver types are not inferred: `.prompt`, `.confirm`, and `.getpass` calls on unrelated objects or test doubles can count. A locally defined `input` also counts. Import recognition is limited to the named evidence table; dynamic imports, indirect wrappers, and arbitrary alias assignments can escape detection.
127
+
128
+ Reading `sys.stdin.read`, `readline`, or `readlines`, including redirected or piped input, is not evidence. Printing and logging are not evidence. Argparse and Click option declarations are not evidence; in particular, `click.option(..., prompt=True)` is a documented gap because it is a declaration rather than a `.prompt(...)` call.
129
+
130
+ Curses, Urwid, and Textual interfaces are outside scope. Other libraries such as inquirer, PyInquirer, and bullet are outside scope unless their calls independently match a named pattern. Evidence found only in tests or fixtures receives MEDIUM under the rules above; it does not establish production behavior. Negation and overlap masking follow the lexical rules above rather than natural-language understanding.
131
+
132
+ ## Development and packaging
133
+
134
+ ```sh
135
+ PYTHONPATH=src python3 -m unittest discover -s tests -v
136
+ python3 -m build
137
+ # If isolated build dependencies are unavailable offline:
138
+ python3 -m build --no-isolation
139
+ ```
140
+
141
+ The build produces a wheel and source distribution in `dist/`. The source distribution includes the test fixtures through `MANIFEST.in`.
@@ -0,0 +1,9 @@
1
+ interactive_claim_audit/__init__.py,sha256=68Wu9BiGkv56193JM09CjVbDkooBhRKdbHna1AE1FDE,85
2
+ interactive_claim_audit/__main__.py,sha256=sZ2JnqFG6Pk8TPXLe6vVjhXvZTEg1p9H9paLp5ynk9o,1847
3
+ interactive_claim_audit/audit.py,sha256=3ua7AqPTSxxMWKRlkVlv8Pqz-xVoIKlU3_EQdBmsPlo,7838
4
+ interactive_claim_audit-0.1.0.dist-info/licenses/LICENSE,sha256=thQsacfdu4M-E9dSdndeSvRLT6qXnmnSSuwb59DaxUA,1093
5
+ interactive_claim_audit-0.1.0.dist-info/METADATA,sha256=LokRZBA49rHYnl8r_6zLam_aL4k-VRkR8IWUyqJqDOY,8195
6
+ interactive_claim_audit-0.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
7
+ interactive_claim_audit-0.1.0.dist-info/entry_points.txt,sha256=Vk4ZASCWTzKE6IOsIauhbvr7Kg4jzS8kgPtQFQ2Buug,82
8
+ interactive_claim_audit-0.1.0.dist-info/top_level.txt,sha256=oS7zsom5pGvCnOPzoPFKiV_Z6XeBHvgHFLqZdGMCh_M,24
9
+ interactive_claim_audit-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ interactive-claim-audit = interactive_claim_audit.__main__:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 interactive-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 @@
1
+ interactive_claim_audit