armor-agent-plugin 6.0.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.

Potentially problematic release.


This version of armor-agent-plugin might be problematic. Click here for more details.

Files changed (50) hide show
  1. armor/__init__.py +9 -0
  2. armor/__main__.py +3 -0
  3. armor/cli.py +209 -0
  4. armor/data/ai_standards/_catalog/latest.json +7 -0
  5. armor/data/ai_standards/_catalog/versions/2026-05-14__b1ed6db3/guardrail_catalog.json +1517 -0
  6. armor/data/ai_standards/_catalog/versions/2026-05-14__b1ed6db3/guardrail_catalog.md +345 -0
  7. armor/data/ai_standards/_catalog/versions/2026-05-14__b1ed6db3/guardrail_matrix.csv +54 -0
  8. armor/data/ai_standards/_catalog/versions/2026-05-14__b1ed6db3/guardrail_matrix.json +1446 -0
  9. armor/data/ai_standards/_catalog/versions/2026-05-14__b1ed6db3/guardrail_matrix.md +57 -0
  10. armor/data/ai_standards/_catalog/versions/2026-05-14__b1ed6db3/manifest.json +29 -0
  11. armor/data/ai_standards/_catalog/versions/2026-05-14__b1ed6db3/source_coverage.json +360 -0
  12. armor/data/ai_standards/eu-ai-act/history.jsonl +1 -0
  13. armor/data/ai_standards/eu-ai-act/latest.json +7 -0
  14. armor/data/ai_standards/eu-ai-act/versions/2026-06-04__e1a1c700/manifest.json +5 -0
  15. armor/data/ai_standards/mitre-atlas/history.jsonl +1 -0
  16. armor/data/ai_standards/mitre-atlas/latest.json +7 -0
  17. armor/data/ai_standards/mitre-atlas/versions/2026-06-04__32346fb3/manifest.json +5 -0
  18. armor/data/ai_standards/nist-ai-rmf/history.jsonl +1 -0
  19. armor/data/ai_standards/nist-ai-rmf/latest.json +7 -0
  20. armor/data/ai_standards/nist-ai-rmf/versions/2026-06-04__b157a100/manifest.json +5 -0
  21. armor/data/ai_standards/owasp-llm-top10/history.jsonl +1 -0
  22. armor/data/ai_standards/owasp-llm-top10/latest.json +7 -0
  23. armor/data/ai_standards/owasp-llm-top10/versions/2026-06-04__0a592025/manifest.json +5 -0
  24. armor/file_lock.py +114 -0
  25. armor/pipeline/__init__.py +17 -0
  26. armor/pipeline/adversary.py +140 -0
  27. armor/pipeline/conform.py +259 -0
  28. armor/pipeline/conform_audit.py +192 -0
  29. armor/pipeline/load.py +94 -0
  30. armor/pipeline/report.py +357 -0
  31. armor/pipeline/schema.py +113 -0
  32. armor/pipeline/schemas/posture_report.schema.json +400 -0
  33. armor/pipeline/state.py +182 -0
  34. armor/pipeline/triage.py +225 -0
  35. armor/pipeline/triage_audit.py +153 -0
  36. armor_agent_plugin-6.0.0.dist-info/METADATA +574 -0
  37. armor_agent_plugin-6.0.0.dist-info/RECORD +50 -0
  38. armor_agent_plugin-6.0.0.dist-info/WHEEL +5 -0
  39. armor_agent_plugin-6.0.0.dist-info/entry_points.txt +2 -0
  40. armor_agent_plugin-6.0.0.dist-info/licenses/LICENSE +21 -0
  41. armor_agent_plugin-6.0.0.dist-info/top_level.txt +2 -0
  42. catalog/__init__.py +1 -0
  43. catalog/ai_standards_versioning.py +114 -0
  44. catalog/download_aiid_slim.py +90 -0
  45. catalog/download_eu_ai_act_cellar.py +86 -0
  46. catalog/download_mitre_atlas.py +78 -0
  47. catalog/download_nist_ai_rmf.py +77 -0
  48. catalog/download_owasp_llm_top10.py +71 -0
  49. catalog/generate_guardrail_catalog.py +990 -0
  50. catalog/refresh_catalog.py +77 -0
@@ -0,0 +1,400 @@
1
+ {
2
+ "$defs": {
3
+ "Coverage": {
4
+ "additionalProperties": false,
5
+ "properties": {
6
+ "applicable_only_pct": {
7
+ "maximum": 100.0,
8
+ "minimum": 0.0,
9
+ "title": "Applicable Only Pct",
10
+ "type": "number"
11
+ },
12
+ "by_family": {
13
+ "items": {
14
+ "$ref": "#/$defs/FamilyCoverage"
15
+ },
16
+ "title": "By Family",
17
+ "type": "array"
18
+ },
19
+ "by_verdict_in_scope": {
20
+ "additionalProperties": {
21
+ "type": "integer"
22
+ },
23
+ "title": "By Verdict In Scope",
24
+ "type": "object"
25
+ },
26
+ "earned_points": {
27
+ "minimum": 0.0,
28
+ "title": "Earned Points",
29
+ "type": "number"
30
+ },
31
+ "in_scope_count": {
32
+ "minimum": 0,
33
+ "title": "In Scope Count",
34
+ "type": "integer"
35
+ },
36
+ "max_possible_points": {
37
+ "minimum": 0.0,
38
+ "title": "Max Possible Points",
39
+ "type": "number"
40
+ },
41
+ "overall_pct": {
42
+ "maximum": 100.0,
43
+ "minimum": 0.0,
44
+ "title": "Overall Pct",
45
+ "type": "number"
46
+ }
47
+ },
48
+ "required": [
49
+ "overall_pct",
50
+ "applicable_only_pct",
51
+ "in_scope_count",
52
+ "max_possible_points",
53
+ "earned_points",
54
+ "by_verdict_in_scope",
55
+ "by_family"
56
+ ],
57
+ "title": "Coverage",
58
+ "type": "object"
59
+ },
60
+ "FamilyCoverage": {
61
+ "additionalProperties": false,
62
+ "properties": {
63
+ "earned": {
64
+ "minimum": 0.0,
65
+ "title": "Earned",
66
+ "type": "number"
67
+ },
68
+ "family": {
69
+ "title": "Family",
70
+ "type": "string"
71
+ },
72
+ "family_name": {
73
+ "title": "Family Name",
74
+ "type": "string"
75
+ },
76
+ "in_scope": {
77
+ "minimum": 0,
78
+ "title": "In Scope",
79
+ "type": "integer"
80
+ },
81
+ "max": {
82
+ "minimum": 0.0,
83
+ "title": "Max",
84
+ "type": "number"
85
+ },
86
+ "score_pct": {
87
+ "maximum": 100.0,
88
+ "minimum": 0.0,
89
+ "title": "Score Pct",
90
+ "type": "number"
91
+ }
92
+ },
93
+ "required": [
94
+ "family",
95
+ "family_name",
96
+ "in_scope",
97
+ "earned",
98
+ "max",
99
+ "score_pct"
100
+ ],
101
+ "title": "FamilyCoverage",
102
+ "type": "object"
103
+ },
104
+ "GuardrailRow": {
105
+ "additionalProperties": false,
106
+ "properties": {
107
+ "applicability": {
108
+ "enum": [
109
+ "applies",
110
+ "partial_scope",
111
+ "n_a",
112
+ "unknown"
113
+ ],
114
+ "title": "Applicability",
115
+ "type": "string"
116
+ },
117
+ "applicability_reason": {
118
+ "default": "",
119
+ "title": "Applicability Reason",
120
+ "type": "string"
121
+ },
122
+ "citations": {
123
+ "items": {
124
+ "type": "string"
125
+ },
126
+ "title": "Citations",
127
+ "type": "array"
128
+ },
129
+ "demoted_due_to_hallucination": {
130
+ "default": false,
131
+ "title": "Demoted Due To Hallucination",
132
+ "type": "boolean"
133
+ },
134
+ "description": {
135
+ "title": "Description",
136
+ "type": "string"
137
+ },
138
+ "family": {
139
+ "title": "Family",
140
+ "type": "string"
141
+ },
142
+ "family_name": {
143
+ "title": "Family Name",
144
+ "type": "string"
145
+ },
146
+ "gap_summary": {
147
+ "default": "",
148
+ "title": "Gap Summary",
149
+ "type": "string"
150
+ },
151
+ "reasoning": {
152
+ "default": "",
153
+ "title": "Reasoning",
154
+ "type": "string"
155
+ },
156
+ "remediation": {
157
+ "default": "",
158
+ "title": "Remediation",
159
+ "type": "string"
160
+ },
161
+ "sid": {
162
+ "title": "Sid",
163
+ "type": "string"
164
+ },
165
+ "verdict": {
166
+ "enum": [
167
+ "implemented",
168
+ "partial",
169
+ "weak",
170
+ "gap",
171
+ "inconclusive",
172
+ "n/a"
173
+ ],
174
+ "title": "Verdict",
175
+ "type": "string"
176
+ }
177
+ },
178
+ "required": [
179
+ "sid",
180
+ "family",
181
+ "family_name",
182
+ "description",
183
+ "applicability",
184
+ "verdict"
185
+ ],
186
+ "title": "GuardrailRow",
187
+ "type": "object"
188
+ },
189
+ "OpenQuestion": {
190
+ "additionalProperties": true,
191
+ "properties": {
192
+ "critique": {
193
+ "default": "",
194
+ "title": "Critique",
195
+ "type": "string"
196
+ },
197
+ "sid": {
198
+ "title": "Sid",
199
+ "type": "string"
200
+ }
201
+ },
202
+ "required": [
203
+ "sid"
204
+ ],
205
+ "title": "OpenQuestion",
206
+ "type": "object"
207
+ },
208
+ "Suggestion": {
209
+ "additionalProperties": false,
210
+ "properties": {
211
+ "action": {
212
+ "title": "Action",
213
+ "type": "string"
214
+ },
215
+ "current_verdict": {
216
+ "enum": [
217
+ "gap",
218
+ "inconclusive",
219
+ "weak",
220
+ "partial"
221
+ ],
222
+ "title": "Current Verdict",
223
+ "type": "string"
224
+ },
225
+ "family": {
226
+ "title": "Family",
227
+ "type": "string"
228
+ },
229
+ "family_name": {
230
+ "title": "Family Name",
231
+ "type": "string"
232
+ },
233
+ "family_score_pct": {
234
+ "maximum": 100.0,
235
+ "minimum": 0.0,
236
+ "title": "Family Score Pct",
237
+ "type": "number"
238
+ },
239
+ "gap_summary": {
240
+ "default": "",
241
+ "title": "Gap Summary",
242
+ "type": "string"
243
+ },
244
+ "points_unlocked": {
245
+ "maximum": 1.0,
246
+ "minimum": 0.0,
247
+ "title": "Points Unlocked",
248
+ "type": "number"
249
+ },
250
+ "reasoning": {
251
+ "default": "",
252
+ "title": "Reasoning",
253
+ "type": "string"
254
+ },
255
+ "remediation": {
256
+ "default": "",
257
+ "title": "Remediation",
258
+ "type": "string"
259
+ },
260
+ "sid": {
261
+ "title": "Sid",
262
+ "type": "string"
263
+ }
264
+ },
265
+ "required": [
266
+ "sid",
267
+ "family",
268
+ "family_name",
269
+ "current_verdict",
270
+ "points_unlocked",
271
+ "family_score_pct",
272
+ "action"
273
+ ],
274
+ "title": "Suggestion",
275
+ "type": "object"
276
+ },
277
+ "Totals": {
278
+ "additionalProperties": false,
279
+ "properties": {
280
+ "by_applicability": {
281
+ "additionalProperties": {
282
+ "type": "integer"
283
+ },
284
+ "title": "By Applicability",
285
+ "type": "object"
286
+ },
287
+ "by_verdict": {
288
+ "additionalProperties": {
289
+ "type": "integer"
290
+ },
291
+ "title": "By Verdict",
292
+ "type": "object"
293
+ },
294
+ "gaps": {
295
+ "minimum": 0,
296
+ "title": "Gaps",
297
+ "type": "integer"
298
+ },
299
+ "guardrails": {
300
+ "minimum": 0,
301
+ "title": "Guardrails",
302
+ "type": "integer"
303
+ },
304
+ "inconclusive": {
305
+ "minimum": 0,
306
+ "title": "Inconclusive",
307
+ "type": "integer"
308
+ },
309
+ "open_questions": {
310
+ "minimum": 0,
311
+ "title": "Open Questions",
312
+ "type": "integer"
313
+ },
314
+ "weak_or_partial": {
315
+ "minimum": 0,
316
+ "title": "Weak Or Partial",
317
+ "type": "integer"
318
+ }
319
+ },
320
+ "required": [
321
+ "guardrails",
322
+ "by_applicability",
323
+ "by_verdict",
324
+ "gaps",
325
+ "weak_or_partial",
326
+ "inconclusive",
327
+ "open_questions"
328
+ ],
329
+ "title": "Totals",
330
+ "type": "object"
331
+ }
332
+ },
333
+ "additionalProperties": false,
334
+ "properties": {
335
+ "coverage": {
336
+ "$ref": "#/$defs/Coverage"
337
+ },
338
+ "generated_at": {
339
+ "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}-\\d{2}-\\d{2}Z$",
340
+ "title": "Generated At",
341
+ "type": "string"
342
+ },
343
+ "open_questions": {
344
+ "items": {
345
+ "$ref": "#/$defs/OpenQuestion"
346
+ },
347
+ "title": "Open Questions",
348
+ "type": "array"
349
+ },
350
+ "phase": {
351
+ "const": "report",
352
+ "title": "Phase",
353
+ "type": "string"
354
+ },
355
+ "project": {
356
+ "title": "Project",
357
+ "type": "string"
358
+ },
359
+ "rows": {
360
+ "items": {
361
+ "$ref": "#/$defs/GuardrailRow"
362
+ },
363
+ "title": "Rows",
364
+ "type": "array"
365
+ },
366
+ "run_dir": {
367
+ "title": "Run Dir",
368
+ "type": "string"
369
+ },
370
+ "suggestions": {
371
+ "items": {
372
+ "$ref": "#/$defs/Suggestion"
373
+ },
374
+ "title": "Suggestions",
375
+ "type": "array"
376
+ },
377
+ "system_profile": {
378
+ "additionalProperties": true,
379
+ "title": "System Profile",
380
+ "type": "object"
381
+ },
382
+ "totals": {
383
+ "$ref": "#/$defs/Totals"
384
+ }
385
+ },
386
+ "required": [
387
+ "phase",
388
+ "generated_at",
389
+ "project",
390
+ "run_dir",
391
+ "system_profile",
392
+ "totals",
393
+ "coverage",
394
+ "suggestions",
395
+ "open_questions",
396
+ "rows"
397
+ ],
398
+ "title": "PostureReport",
399
+ "type": "object"
400
+ }
@@ -0,0 +1,182 @@
1
+ """Run directory management, phase state, project fingerprinting, and citation cross-verification."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from dataclasses import dataclass
6
+ from datetime import datetime, timezone
7
+ import hashlib
8
+ import json
9
+ import os
10
+ from pathlib import Path
11
+ import re
12
+ from typing import Any
13
+
14
+ PHASES = ("load", "triage", "triage-audit", "conform", "conform-audit", "report")
15
+
16
+ PHASE_ARTIFACT = {
17
+ "load": "01_guardrails.json",
18
+ "triage": "02_triage.json",
19
+ "triage-audit": "03_triage_audit.json",
20
+ "conform": "04_conformance.json",
21
+ "conform-audit": "05_conformance_audit.json",
22
+ "report": "06_report.json",
23
+ }
24
+
25
+ MAX_AUDIT_REVISIONS = 3
26
+
27
+ _CITATION_RE = re.compile(r"^([^:]+?)(?::(\d+))?(?:-(\d+))?$")
28
+
29
+ _SOURCE_EXTS = {".py", ".ts", ".tsx", ".js", ".java", ".go", ".rs", ".kt", ".cs", ".rb"}
30
+ _SKIP_DIRS = {".git", ".armor", "node_modules", ".venv", "venv", "__pycache__", "dist", "build", ".pytest_cache"}
31
+
32
+
33
+ @dataclass
34
+ class RunDir:
35
+ project: Path
36
+ root: Path
37
+
38
+ @property
39
+ def queue(self) -> Path:
40
+ q = self.root / "queue"
41
+ q.mkdir(parents=True, exist_ok=True)
42
+ return q
43
+
44
+ def artifact(self, phase: str) -> Path:
45
+ return self.root / PHASE_ARTIFACT[phase]
46
+
47
+ def request(self, phase: str) -> Path:
48
+ return self.queue / f"{phase}.request.json"
49
+
50
+ def response(self, phase: str) -> Path:
51
+ return self.queue / f"{phase}.response.json"
52
+
53
+ def status(self) -> dict[str, str]:
54
+ result: dict[str, str] = {}
55
+ q = self.root / "queue"
56
+ for phase in PHASES:
57
+ art = self.root / PHASE_ARTIFACT[phase]
58
+ resp = q / f"{phase}.response.json"
59
+ req = q / f"{phase}.request.json"
60
+ if art.exists():
61
+ result[phase] = "done"
62
+ elif resp.exists():
63
+ result[phase] = "response-ready (needs --finalize)"
64
+ elif req.exists():
65
+ result[phase] = "awaiting-llm"
66
+ else:
67
+ result[phase] = "pending"
68
+ return result
69
+
70
+
71
+ def _armor_dir(project: Path) -> Path:
72
+ d = project.resolve() / ".armor"
73
+ d.mkdir(parents=True, exist_ok=True)
74
+ return d
75
+
76
+
77
+ def _runs_dir(project: Path) -> Path:
78
+ d = _armor_dir(project) / "runs"
79
+ d.mkdir(parents=True, exist_ok=True)
80
+ return d
81
+
82
+
83
+ def new_run(project: Path) -> RunDir:
84
+ project_resolved = project.resolve()
85
+ runs = _runs_dir(project_resolved)
86
+ ts = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H-%M-%SZ")
87
+ root = runs / ts
88
+ suffix = 1
89
+ while root.exists():
90
+ root = runs / f"{ts}_{suffix}"
91
+ suffix += 1
92
+ root.mkdir(parents=True, exist_ok=True)
93
+ return RunDir(project=project_resolved, root=root)
94
+
95
+
96
+ def current_run(project: Path, create_if_missing: bool = True) -> RunDir:
97
+ project_resolved = project.resolve()
98
+ runs = _runs_dir(project_resolved)
99
+ entries = sorted([p for p in runs.iterdir() if p.is_dir()], key=lambda p: p.name)
100
+ if entries:
101
+ return RunDir(project=project_resolved, root=entries[-1])
102
+ if create_if_missing:
103
+ return new_run(project_resolved)
104
+ raise SystemExit(f"no run directory under {runs} \u2014 start with --phase load")
105
+
106
+
107
+ def require_phase_done(run: RunDir, phase: str) -> dict[str, Any]:
108
+ art = run.artifact(phase)
109
+ if not art.exists():
110
+ raise SystemExit(
111
+ f"phase '{phase}' has not completed in {run.root}; run: "
112
+ f"python skills/armor/scripts/armor_run.py pipeline {run.project} --phase {phase}"
113
+ )
114
+ return json.loads(art.read_text(encoding="utf-8"))
115
+
116
+
117
+ def project_fingerprint(project: Path, limit: int = 200) -> str:
118
+ project_resolved = project.resolve()
119
+ rows: list[str] = []
120
+ count = 0
121
+ for dirpath, dirnames, filenames in os.walk(project_resolved):
122
+ dirnames[:] = sorted([d for d in dirnames if d not in _SKIP_DIRS])
123
+ for fname in sorted(filenames):
124
+ if count >= limit:
125
+ break
126
+ p = Path(dirpath) / fname
127
+ if p.suffix in _SOURCE_EXTS:
128
+ try:
129
+ st = p.stat()
130
+ rel = p.relative_to(project_resolved).as_posix()
131
+ rows.append(f"{rel}|{st.st_mtime_ns}")
132
+ count += 1
133
+ except OSError:
134
+ continue
135
+ if count >= limit:
136
+ break
137
+ rows.sort()
138
+ return hashlib.sha256("\n".join(rows).encode("utf-8")).hexdigest()[:16]
139
+
140
+
141
+ def verify_citation(project: Path, citation: str) -> tuple[bool, str]:
142
+ if not isinstance(citation, str):
143
+ return (False, "unparseable citation")
144
+ s = citation.strip()
145
+ if not s:
146
+ return (False, "unparseable citation")
147
+ m = _CITATION_RE.match(s)
148
+ if not m:
149
+ return (False, "unparseable citation")
150
+ rel, start_s, end_s = m.group(1), m.group(2), m.group(3)
151
+ if end_s is not None and start_s is None:
152
+ return (False, "unparseable citation")
153
+
154
+ project_resolved = project.resolve()
155
+ try:
156
+ p = (project_resolved / rel).resolve()
157
+ p.relative_to(project_resolved)
158
+ except (ValueError, OSError):
159
+ return (False, "citation escapes project_root")
160
+
161
+ if not p.is_file():
162
+ return (False, "file not found")
163
+
164
+ if start_s is None:
165
+ return (True, "ok")
166
+
167
+ try:
168
+ text = p.read_text(encoding="utf-8", errors="replace")
169
+ total = len(text.splitlines())
170
+ except OSError:
171
+ return (False, "unreadable")
172
+
173
+ lo = int(start_s)
174
+ hi = int(end_s) if end_s is not None else lo
175
+ if lo < 1 or hi < lo or hi > total:
176
+ return (False, f"line out of bounds (file has {total} lines)")
177
+
178
+ return (True, "ok")
179
+
180
+
181
+ def hallucination_log(project: Path) -> Path:
182
+ return _armor_dir(project) / "hallucination_log.jsonl"