voight-kampff-forensics 0.1.0.dev0__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.
Files changed (26) hide show
  1. voight_kampff_forensics-0.1.0.dev0/LICENSE +202 -0
  2. voight_kampff_forensics-0.1.0.dev0/PKG-INFO +41 -0
  3. voight_kampff_forensics-0.1.0.dev0/README.md +13 -0
  4. voight_kampff_forensics-0.1.0.dev0/pyproject.toml +113 -0
  5. voight_kampff_forensics-0.1.0.dev0/pyproject.toml.orig +102 -0
  6. voight_kampff_forensics-0.1.0.dev0/src/voight_kampff/__init__.py +15 -0
  7. voight_kampff_forensics-0.1.0.dev0/src/voight_kampff/__main__.py +7 -0
  8. voight_kampff_forensics-0.1.0.dev0/src/voight_kampff/_orchestration/__init__.py +5 -0
  9. voight_kampff_forensics-0.1.0.dev0/src/voight_kampff/_orchestration/manifestes.py +123 -0
  10. voight_kampff_forensics-0.1.0.dev0/src/voight_kampff/_orchestration/travail.py +448 -0
  11. voight_kampff_forensics-0.1.0.dev0/src/voight_kampff/_protocole.py +78 -0
  12. voight_kampff_forensics-0.1.0.dev0/src/voight_kampff/_travail/__init__.py +6 -0
  13. voight_kampff_forensics-0.1.0.dev0/src/voight_kampff/_travail/__main__.py +7 -0
  14. voight_kampff_forensics-0.1.0.dev0/src/voight_kampff/_travail/contexte.py +179 -0
  15. voight_kampff_forensics-0.1.0.dev0/src/voight_kampff/_travail/fichier.py +64 -0
  16. voight_kampff_forensics-0.1.0.dev0/src/voight_kampff/_travail/garde.py +28 -0
  17. voight_kampff_forensics-0.1.0.dev0/src/voight_kampff/_travail/principal.py +218 -0
  18. voight_kampff_forensics-0.1.0.dev0/src/voight_kampff/cli.py +48 -0
  19. voight_kampff_forensics-0.1.0.dev0/src/voight_kampff/modules/__init__.py +31 -0
  20. voight_kampff_forensics-0.1.0.dev0/src/voight_kampff/py.typed +0 -0
  21. voight_kampff_forensics-0.1.0.dev0/src/voight_kampff/rapport/__init__.py +1 -0
  22. voight_kampff_forensics-0.1.0.dev0/src/voight_kampff/rapport/modele.py +958 -0
  23. voight_kampff_forensics-0.1.0.dev0/src/voight_kampff/schemas/__init__.py +60 -0
  24. voight_kampff_forensics-0.1.0.dev0/src/voight_kampff/schemas/manifeste.schema.json +63 -0
  25. voight_kampff_forensics-0.1.0.dev0/src/voight_kampff/schemas/messages.schema.json +85 -0
  26. voight_kampff_forensics-0.1.0.dev0/src/voight_kampff/schemas/rapport.schema.json +371 -0
@@ -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,41 @@
1
+ Metadata-Version: 2.4
2
+ Name: voight-kampff-forensics
3
+ Version: 0.1.0.dev0
4
+ Summary: Analyse de provenance et d'intégrité de fichiers, sans modèle d'IA embarqué.
5
+ Keywords: forensics,provenance,c2pa,métadonnées,vérification
6
+ Author: TheDarkMac
7
+ License-Expression: Apache-2.0
8
+ License-File: LICENSE
9
+ Classifier: Development Status :: 2 - Pre-Alpha
10
+ Classifier: Environment :: Console
11
+ Classifier: Intended Audience :: End Users/Desktop
12
+ Classifier: Natural Language :: French
13
+ Classifier: Operating System :: MacOS
14
+ Classifier: Operating System :: Microsoft :: Windows
15
+ Classifier: Operating System :: POSIX :: Linux
16
+ Classifier: Programming Language :: Python :: 3 :: Only
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: 3.14
20
+ Classifier: Topic :: Multimedia
21
+ Classifier: Topic :: Security
22
+ Classifier: Typing :: Typed
23
+ Requires-Dist: jsonschema>=4.26
24
+ Requires-Python: >=3.12
25
+ Project-URL: Repository, https://github.com/TheDarkMac/AI-detector
26
+ Project-URL: Documentation, https://github.com/TheDarkMac/AI-detector/tree/detector/docs
27
+ Description-Content-Type: text/markdown
28
+
29
+ # Voight-Kampff
30
+
31
+ Outil d'analyse de fichiers qui relève les preuves et les indices de génération ou de retouche par IA, **sans embarquer aucun modèle d'IA**.
32
+
33
+ L'outil ne délivre pas de verdict certain : il distingue ce qui se vérifie (signature, métadonnée, filigrane documenté) de ce qui se mesure seulement (anomalies du signal), et explique chaque constat.
34
+
35
+ Le projet est en cours de construction : aucune analyse n'est encore disponible, et aucune version n'est publiée. Le paquet s'appellera `voight-kampff-forensics` sur PyPI, et installera les commandes `voight-kampff` et `vk`.
36
+
37
+ Le développement se fait sur la branche `detector`. Voir `CONTRIBUTING.md` et `docs/` sur cette branche.
38
+
39
+ ## Licence
40
+
41
+ Le dépôt, code et documentation compris, est publié sous licence [Apache-2.0](LICENSE).
@@ -0,0 +1,13 @@
1
+ # Voight-Kampff
2
+
3
+ Outil d'analyse de fichiers qui relève les preuves et les indices de génération ou de retouche par IA, **sans embarquer aucun modèle d'IA**.
4
+
5
+ L'outil ne délivre pas de verdict certain : il distingue ce qui se vérifie (signature, métadonnée, filigrane documenté) de ce qui se mesure seulement (anomalies du signal), et explique chaque constat.
6
+
7
+ Le projet est en cours de construction : aucune analyse n'est encore disponible, et aucune version n'est publiée. Le paquet s'appellera `voight-kampff-forensics` sur PyPI, et installera les commandes `voight-kampff` et `vk`.
8
+
9
+ Le développement se fait sur la branche `detector`. Voir `CONTRIBUTING.md` et `docs/` sur cette branche.
10
+
11
+ ## Licence
12
+
13
+ Le dépôt, code et documentation compris, est publié sous licence [Apache-2.0](LICENSE).
@@ -0,0 +1,113 @@
1
+ [project]
2
+ name = "voight-kampff-forensics"
3
+ version = "0.1.0.dev0"
4
+ description = "Analyse de provenance et d'intégrité de fichiers, sans modèle d'IA embarqué."
5
+ readme = "README.md"
6
+ requires-python = ">=3.12"
7
+ license = "Apache-2.0"
8
+ license-files = ["LICENSE"]
9
+ keywords = [
10
+ "forensics",
11
+ "provenance",
12
+ "c2pa",
13
+ "métadonnées",
14
+ "vérification",
15
+ ]
16
+ classifiers = [
17
+ "Development Status :: 2 - Pre-Alpha",
18
+ "Environment :: Console",
19
+ "Intended Audience :: End Users/Desktop",
20
+ "Natural Language :: French",
21
+ "Operating System :: MacOS",
22
+ "Operating System :: Microsoft :: Windows",
23
+ "Operating System :: POSIX :: Linux",
24
+ "Programming Language :: Python :: 3 :: Only",
25
+ "Programming Language :: Python :: 3.12",
26
+ "Programming Language :: Python :: 3.13",
27
+ "Programming Language :: Python :: 3.14",
28
+ "Topic :: Multimedia",
29
+ "Topic :: Security",
30
+ "Typing :: Typed",
31
+ ]
32
+ dependencies = ["jsonschema>=4.26"]
33
+
34
+ [[project.authors]]
35
+ name = "TheDarkMac"
36
+
37
+ [project.scripts]
38
+ voight-kampff = "voight_kampff.cli:main"
39
+ vk = "voight_kampff.cli:main"
40
+
41
+ [project.urls]
42
+ Repository = "https://github.com/TheDarkMac/AI-detector"
43
+ Documentation = "https://github.com/TheDarkMac/AI-detector/tree/detector/docs"
44
+
45
+ [dependency-groups]
46
+ dev = [
47
+ "coverage>=7.10",
48
+ "mypy>=1.18",
49
+ "pip-audit>=2.9",
50
+ "pytest>=8.4",
51
+ "ruff>=0.14",
52
+ "types-jsonschema>=4.26",
53
+ ]
54
+
55
+ [build-system]
56
+ requires = ["uv_build>=0.13.5,<0.14"]
57
+ build-backend = "uv_build"
58
+
59
+ [tool.uv.build-backend]
60
+ module-name = "voight_kampff"
61
+
62
+ [tool.ruff]
63
+ target-version = "py312"
64
+ line-length = 100
65
+ extend-exclude = ["docs/00-cahier-des-charges"]
66
+
67
+ [tool.ruff.lint]
68
+ select = [
69
+ "E",
70
+ "W",
71
+ "F",
72
+ "I",
73
+ "B",
74
+ "UP",
75
+ "S",
76
+ "SIM",
77
+ "C4",
78
+ "PT",
79
+ "RUF",
80
+ ]
81
+
82
+ [tool.ruff.lint.per-file-ignores]
83
+ "tests/**" = [
84
+ "S101",
85
+ "S603",
86
+ ]
87
+
88
+ [tool.mypy]
89
+ python_version = "3.12"
90
+ strict = true
91
+ files = [
92
+ "src",
93
+ "tests",
94
+ ]
95
+
96
+ [tool.pytest.ini_options]
97
+ testpaths = ["tests"]
98
+ addopts = [
99
+ "-ra",
100
+ "--strict-markers",
101
+ "--strict-config",
102
+ "--import-mode=importlib",
103
+ ]
104
+ xfail_strict = true
105
+
106
+ [tool.coverage.run]
107
+ branch = true
108
+ source = ["voight_kampff"]
109
+ patch = ["subprocess"]
110
+
111
+ [tool.coverage.report]
112
+ show_missing = true
113
+ skip_covered = false
@@ -0,0 +1,102 @@
1
+ # Configuration du paquet et de l'outillage — voir docs/decisions/ADR-0047 à ADR-0050
2
+
3
+ [project]
4
+ name = "voight-kampff-forensics"
5
+ version = "0.1.0.dev0"
6
+ description = "Analyse de provenance et d'intégrité de fichiers, sans modèle d'IA embarqué."
7
+ readme = "README.md"
8
+ requires-python = ">=3.12"
9
+ # Expression SPDX et fichier de licence (PEP 639) ; pas de classificateur de licence, que PEP 639 permet de refuser à côté (ADR-0067).
10
+ license = "Apache-2.0"
11
+ license-files = ["LICENSE"]
12
+ authors = [{ name = "TheDarkMac" }]
13
+ keywords = ["forensics", "provenance", "c2pa", "métadonnées", "vérification"]
14
+ classifiers = [
15
+ "Development Status :: 2 - Pre-Alpha",
16
+ "Environment :: Console",
17
+ "Intended Audience :: End Users/Desktop",
18
+ "Natural Language :: French",
19
+ "Operating System :: MacOS",
20
+ "Operating System :: Microsoft :: Windows",
21
+ "Operating System :: POSIX :: Linux",
22
+ "Programming Language :: Python :: 3 :: Only",
23
+ "Programming Language :: Python :: 3.12",
24
+ "Programming Language :: Python :: 3.13",
25
+ "Programming Language :: Python :: 3.14",
26
+ "Topic :: Multimedia",
27
+ "Topic :: Security",
28
+ "Typing :: Typed",
29
+ ]
30
+ # Chaque bibliothèque est ajoutée par la tâche qui l'utilise (ADR-0043) : jsonschema en T11 (ADR-0054).
31
+ dependencies = [
32
+ "jsonschema>=4.26",
33
+ ]
34
+
35
+ [project.scripts]
36
+ voight-kampff = "voight_kampff.cli:main"
37
+ vk = "voight_kampff.cli:main"
38
+
39
+ [project.urls]
40
+ Repository = "https://github.com/TheDarkMac/AI-detector"
41
+ Documentation = "https://github.com/TheDarkMac/AI-detector/tree/detector/docs"
42
+
43
+ [dependency-groups]
44
+ dev = [
45
+ "coverage>=7.10",
46
+ "mypy>=1.18",
47
+ "pip-audit>=2.9",
48
+ "pytest>=8.4",
49
+ "ruff>=0.14",
50
+ "types-jsonschema>=4.26",
51
+ ]
52
+
53
+ [build-system]
54
+ requires = ["uv_build>=0.13.5,<0.14"]
55
+ build-backend = "uv_build"
56
+
57
+ [tool.uv.build-backend]
58
+ module-name = "voight_kampff"
59
+
60
+ [tool.ruff]
61
+ target-version = "py312"
62
+ line-length = 100
63
+ # Cahier des charges reçu : document source, jamais modifié (y compris ses blocs de code).
64
+ extend-exclude = ["docs/00-cahier-des-charges"]
65
+
66
+ [tool.ruff.lint]
67
+ select = [
68
+ "E", "W", # pycodestyle
69
+ "F", # pyflakes
70
+ "I", # tri des imports
71
+ "B", # bugbear
72
+ "UP", # syntaxe moderne
73
+ "S", # sécurité (règles Bandit)
74
+ "SIM", # simplifications
75
+ "C4", # compréhensions
76
+ "PT", # style pytest
77
+ "RUF", # règles propres à Ruff
78
+ ]
79
+
80
+ [tool.ruff.lint.per-file-ignores]
81
+ # assert est l'outil des tests ; les tests lancent l'interpréteur courant, sans entrée externe.
82
+ "tests/**" = ["S101", "S603"]
83
+
84
+ [tool.mypy]
85
+ python_version = "3.12"
86
+ strict = true
87
+ files = ["src", "tests"]
88
+
89
+ [tool.pytest.ini_options]
90
+ testpaths = ["tests"]
91
+ addopts = ["-ra", "--strict-markers", "--strict-config", "--import-mode=importlib"]
92
+ xfail_strict = true
93
+
94
+ [tool.coverage.run]
95
+ branch = true
96
+ source = ["voight_kampff"]
97
+ # Mesure aussi les interpréteurs lancés par les tests (python -m voight_kampff).
98
+ patch = ["subprocess"]
99
+
100
+ [tool.coverage.report]
101
+ show_missing = true
102
+ skip_covered = false
@@ -0,0 +1,15 @@
1
+ """Voight-Kampff : analyse de provenance et d'intégrité de fichiers.
2
+
3
+ L'outil relève les preuves et les indices de génération ou de retouche, sans
4
+ modèle d'IA embarqué, et ne délivre aucun verdict certain (ADR-0008, ADR-0018).
5
+
6
+ L'interface publique de la bibliothèque n'exposera que l'analyse par un
7
+ processus de travail isolé (ADR-0036, ES-17) ; elle est construite à partir de
8
+ T11 et T12.
9
+ """
10
+
11
+ from importlib.metadata import version
12
+
13
+ __all__ = ["__version__"]
14
+
15
+ __version__: str = version("voight-kampff-forensics")
@@ -0,0 +1,7 @@
1
+ """Permet ``python -m voight_kampff``."""
2
+
3
+ import sys
4
+
5
+ from voight_kampff.cli import main
6
+
7
+ sys.exit(main())
@@ -0,0 +1,5 @@
1
+ """Processus principal : manifestes des modules, lancement du processus de travail, réception.
2
+
3
+ Rien ici n'interprète le contenu du fichier analysé : seul le processus de travail le lit
4
+ (ADR-0028, ADR-0036, ES-01).
5
+ """
@@ -0,0 +1,123 @@
1
+ """Manifestes des modules : lecture, validation, ordre, désactivation (ADR-0042, ADR-0064).
2
+
3
+ Les manifestes sont lus et validés sans importer le code des modules. Ils sont livrés avec
4
+ l'outil : un manifeste invalide est un défaut de l'outil, qui arrête l'analyse avec un message
5
+ explicite, comme un catalogue invalide (ADR-0029).
6
+ """
7
+
8
+ import tomllib
9
+ from collections.abc import Collection, Iterable
10
+ from dataclasses import dataclass
11
+ from importlib.resources.abc import Traversable
12
+
13
+ from voight_kampff import schemas
14
+ from voight_kampff.modules import MANIFESTE, dossiers
15
+ from voight_kampff.rapport.modele import Direction
16
+
17
+ __all__ = ["Manifeste", "ManifesteInvalide", "ModuleInconnu", "decouvrir", "lire", "selectionner"]
18
+
19
+
20
+ class ManifesteInvalide(ValueError):
21
+ """Manifeste d'un module livré illisible, non conforme ou incohérent avec les autres."""
22
+
23
+
24
+ class ModuleInconnu(ValueError):
25
+ """Module à désactiver absent de cette version de l'outil."""
26
+
27
+
28
+ @dataclass(frozen=True, slots=True)
29
+ class Manifeste:
30
+ """Ce que le processus principal sait d'un module sans importer son code."""
31
+
32
+ identifiant: str
33
+ """Nom du dossier du module, donc nom d'import."""
34
+ version: str
35
+ formats: tuple[str, ...]
36
+ """Formats réels traités ; le module n'est appliqué qu'à ceux-là (T13)."""
37
+ exigences: tuple[str, ...]
38
+ regles: tuple[str, ...]
39
+ """Règles du catalogue employées ; leur existence est vérifiée avec le catalogue (T15)."""
40
+ fiche: str
41
+ """Fiche technique ``docs/techniques/<fiche>.md`` (NF-09)."""
42
+ directions: tuple[Direction, ...]
43
+ """Directions permises par la fiche technique (ADR-0022)."""
44
+ requiert: tuple[str, ...] = ()
45
+ """Modules exécutés avant celui-ci, dans le même processus de travail."""
46
+
47
+
48
+ def lire(dossier: Traversable) -> Manifeste:
49
+ """Lit et valide le manifeste d'un dossier de module."""
50
+ nom = dossier.name
51
+ try:
52
+ document = tomllib.loads((dossier / MANIFESTE).read_text(encoding="utf-8"))
53
+ except (UnicodeDecodeError, tomllib.TOMLDecodeError):
54
+ raise ManifesteInvalide(f"module {nom} : manifeste illisible") from None
55
+ try:
56
+ schemas.valider("manifeste", document)
57
+ except schemas.DocumentInvalide as erreur:
58
+ raise ManifesteInvalide(f"module {nom} : {erreur}") from None
59
+ if document["identifiant"] != nom:
60
+ raise ManifesteInvalide(f"module {nom} : l'identifiant doit être le nom du dossier")
61
+ return Manifeste(
62
+ identifiant=document["identifiant"],
63
+ version=document["version"],
64
+ formats=tuple(document["formats"]),
65
+ exigences=tuple(document["exigences"]),
66
+ regles=tuple(document["regles"]),
67
+ fiche=document["fiche"],
68
+ directions=tuple(Direction(direction) for direction in document["directions"]),
69
+ requiert=tuple(document["requiert"]),
70
+ )
71
+
72
+
73
+ def decouvrir(racine: Traversable | None = None) -> tuple[Manifeste, ...]:
74
+ """Manifestes des modules livrés, dans l'ordre d'exécution.
75
+
76
+ Un module vient après ceux qu'il requiert ; à rang égal, l'ordre est celui des
77
+ identifiants, pour que deux analyses exécutent les modules dans le même ordre (NF-06).
78
+ """
79
+ manifestes = {manifeste.identifiant: manifeste for manifeste in map(lire, dossiers(racine))}
80
+ for manifeste in manifestes.values():
81
+ for requis in manifeste.requiert:
82
+ if requis == manifeste.identifiant or requis not in manifestes:
83
+ raise ManifesteInvalide(
84
+ f"module {manifeste.identifiant} : module requis absent ou lui-même"
85
+ )
86
+ return _ordonner(manifestes)
87
+
88
+
89
+ def _ordonner(manifestes: dict[str, Manifeste]) -> tuple[Manifeste, ...]:
90
+ restants = {identifiant: set(m.requiert) for identifiant, m in manifestes.items()}
91
+ ordre: list[Manifeste] = []
92
+ while restants:
93
+ prets = sorted(identifiant for identifiant, requis in restants.items() if not requis)
94
+ if not prets:
95
+ cycle = ", ".join(sorted(restants))
96
+ raise ManifesteInvalide(f"modules {cycle} : dépendance circulaire")
97
+ for identifiant in prets:
98
+ ordre.append(manifestes[identifiant])
99
+ del restants[identifiant]
100
+ for requis in restants.values():
101
+ requis.difference_update(prets)
102
+ return tuple(ordre)
103
+
104
+
105
+ def selectionner(
106
+ manifestes: Iterable[Manifeste], desactives: Collection[str]
107
+ ) -> tuple[tuple[Manifeste, ...], tuple[Manifeste, ...]]:
108
+ """Sépare les modules actifs des modules désactivés par l'utilisateur, ordre conservé.
109
+
110
+ Un module qui en requiert un désactivé est désactivé lui aussi : il ne pourrait pas
111
+ s'exécuter. ``manifestes`` doit être dans l'ordre d'exécution (:func:`decouvrir`).
112
+ """
113
+ manifestes = tuple(manifestes)
114
+ connus = {manifeste.identifiant for manifeste in manifestes}
115
+ inconnus = sorted(set(desactives) - connus)
116
+ if inconnus:
117
+ raise ModuleInconnu(f"module inconnu : {', '.join(inconnus)}")
118
+ eteints = set(desactives)
119
+ for manifeste in manifestes:
120
+ if eteints.intersection(manifeste.requiert):
121
+ eteints.add(manifeste.identifiant)
122
+ actifs = tuple(m for m in manifestes if m.identifiant not in eteints)
123
+ return actifs, tuple(m for m in manifestes if m.identifiant in eteints)