@trac3er/oh-my-god 2.0.3 → 2.0.5

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 (259) hide show
  1. package/.agents/skills/omg/AGENTS.fragment.md +5 -0
  2. package/.agents/skills/omg/algorithms/SKILL.md +11 -0
  3. package/.agents/skills/omg/algorithms/openai.yaml +11 -0
  4. package/.agents/skills/omg/api-twin/SKILL.md +11 -0
  5. package/.agents/skills/omg/api-twin/openai.yaml +12 -0
  6. package/.agents/skills/omg/codex-mcp.toml +4 -0
  7. package/.agents/skills/omg/control-plane/SKILL.md +11 -0
  8. package/.agents/skills/omg/control-plane/openai.yaml +14 -0
  9. package/.agents/skills/omg/data-lineage/SKILL.md +11 -0
  10. package/.agents/skills/omg/data-lineage/openai.yaml +12 -0
  11. package/.agents/skills/omg/delta-classifier/SKILL.md +11 -0
  12. package/.agents/skills/omg/delta-classifier/openai.yaml +12 -0
  13. package/.agents/skills/omg/eval-gate/SKILL.md +11 -0
  14. package/.agents/skills/omg/eval-gate/openai.yaml +12 -0
  15. package/.agents/skills/omg/health/SKILL.md +11 -0
  16. package/.agents/skills/omg/health/openai.yaml +11 -0
  17. package/.agents/skills/omg/hook-governor/SKILL.md +11 -0
  18. package/.agents/skills/omg/hook-governor/openai.yaml +11 -0
  19. package/.agents/skills/omg/incident-replay/SKILL.md +11 -0
  20. package/.agents/skills/omg/incident-replay/openai.yaml +12 -0
  21. package/.agents/skills/omg/lsp-pack/SKILL.md +11 -0
  22. package/.agents/skills/omg/lsp-pack/openai.yaml +11 -0
  23. package/.agents/skills/omg/mcp-fabric/SKILL.md +11 -0
  24. package/.agents/skills/omg/mcp-fabric/openai.yaml +13 -0
  25. package/.agents/skills/omg/preflight/SKILL.md +11 -0
  26. package/.agents/skills/omg/preflight/openai.yaml +12 -0
  27. package/.agents/skills/omg/remote-supervisor/SKILL.md +11 -0
  28. package/.agents/skills/omg/remote-supervisor/openai.yaml +12 -0
  29. package/.agents/skills/omg/robotics/SKILL.md +11 -0
  30. package/.agents/skills/omg/robotics/openai.yaml +11 -0
  31. package/.agents/skills/omg/secure-worktree-pipeline/SKILL.md +11 -0
  32. package/.agents/skills/omg/secure-worktree-pipeline/openai.yaml +12 -0
  33. package/.agents/skills/omg/security-check/SKILL.md +11 -0
  34. package/.agents/skills/omg/security-check/openai.yaml +13 -0
  35. package/.agents/skills/omg/tracebank/SKILL.md +11 -0
  36. package/.agents/skills/omg/tracebank/openai.yaml +12 -0
  37. package/.agents/skills/omg/vision/SKILL.md +11 -0
  38. package/.agents/skills/omg/vision/openai.yaml +11 -0
  39. package/.claude-plugin/marketplace.json +3 -3
  40. package/.claude-plugin/plugin.json +1 -1
  41. package/.claude-plugin/scripts/uninstall.sh +2 -2
  42. package/.mcp.json +20 -4
  43. package/CHANGELOG.md +10 -0
  44. package/OMG-setup.sh +9 -3
  45. package/OMG_COMPAT_CONTRACT.md +92 -0
  46. package/README.md +24 -4
  47. package/SECURITY.md +6 -0
  48. package/commands/OMG:api-twin.md +22 -0
  49. package/commands/OMG:preflight.md +26 -0
  50. package/commands/OMG:security-check.md +28 -0
  51. package/commands/__init__.py +1 -0
  52. package/control_plane/__init__.py +2 -0
  53. package/control_plane/openapi.yaml +228 -0
  54. package/control_plane/server.py +123 -0
  55. package/control_plane/service.py +185 -0
  56. package/dist/enterprise/bundle/.agents/skills/omg/AGENTS.fragment.md +5 -0
  57. package/dist/enterprise/bundle/.agents/skills/omg/algorithms/SKILL.md +11 -0
  58. package/dist/enterprise/bundle/.agents/skills/omg/algorithms/openai.yaml +11 -0
  59. package/dist/enterprise/bundle/.agents/skills/omg/api-twin/SKILL.md +11 -0
  60. package/dist/enterprise/bundle/.agents/skills/omg/api-twin/openai.yaml +12 -0
  61. package/dist/enterprise/bundle/.agents/skills/omg/codex-mcp.toml +4 -0
  62. package/dist/enterprise/bundle/.agents/skills/omg/control-plane/SKILL.md +11 -0
  63. package/dist/enterprise/bundle/.agents/skills/omg/control-plane/openai.yaml +14 -0
  64. package/dist/enterprise/bundle/.agents/skills/omg/data-lineage/SKILL.md +11 -0
  65. package/dist/enterprise/bundle/.agents/skills/omg/data-lineage/openai.yaml +12 -0
  66. package/dist/enterprise/bundle/.agents/skills/omg/delta-classifier/SKILL.md +11 -0
  67. package/dist/enterprise/bundle/.agents/skills/omg/delta-classifier/openai.yaml +12 -0
  68. package/dist/enterprise/bundle/.agents/skills/omg/eval-gate/SKILL.md +11 -0
  69. package/dist/enterprise/bundle/.agents/skills/omg/eval-gate/openai.yaml +12 -0
  70. package/dist/enterprise/bundle/.agents/skills/omg/health/SKILL.md +11 -0
  71. package/dist/enterprise/bundle/.agents/skills/omg/health/openai.yaml +11 -0
  72. package/dist/enterprise/bundle/.agents/skills/omg/hook-governor/SKILL.md +11 -0
  73. package/dist/enterprise/bundle/.agents/skills/omg/hook-governor/openai.yaml +11 -0
  74. package/dist/enterprise/bundle/.agents/skills/omg/incident-replay/SKILL.md +11 -0
  75. package/dist/enterprise/bundle/.agents/skills/omg/incident-replay/openai.yaml +12 -0
  76. package/dist/enterprise/bundle/.agents/skills/omg/lsp-pack/SKILL.md +11 -0
  77. package/dist/enterprise/bundle/.agents/skills/omg/lsp-pack/openai.yaml +11 -0
  78. package/dist/enterprise/bundle/.agents/skills/omg/mcp-fabric/SKILL.md +11 -0
  79. package/dist/enterprise/bundle/.agents/skills/omg/mcp-fabric/openai.yaml +13 -0
  80. package/dist/enterprise/bundle/.agents/skills/omg/preflight/SKILL.md +11 -0
  81. package/dist/enterprise/bundle/.agents/skills/omg/preflight/openai.yaml +12 -0
  82. package/dist/enterprise/bundle/.agents/skills/omg/remote-supervisor/SKILL.md +11 -0
  83. package/dist/enterprise/bundle/.agents/skills/omg/remote-supervisor/openai.yaml +12 -0
  84. package/dist/enterprise/bundle/.agents/skills/omg/robotics/SKILL.md +11 -0
  85. package/dist/enterprise/bundle/.agents/skills/omg/robotics/openai.yaml +11 -0
  86. package/dist/enterprise/bundle/.agents/skills/omg/secure-worktree-pipeline/SKILL.md +11 -0
  87. package/dist/enterprise/bundle/.agents/skills/omg/secure-worktree-pipeline/openai.yaml +12 -0
  88. package/dist/enterprise/bundle/.agents/skills/omg/security-check/SKILL.md +11 -0
  89. package/dist/enterprise/bundle/.agents/skills/omg/security-check/openai.yaml +13 -0
  90. package/dist/enterprise/bundle/.agents/skills/omg/tracebank/SKILL.md +11 -0
  91. package/dist/enterprise/bundle/.agents/skills/omg/tracebank/openai.yaml +12 -0
  92. package/dist/enterprise/bundle/.agents/skills/omg/vision/SKILL.md +11 -0
  93. package/dist/enterprise/bundle/.agents/skills/omg/vision/openai.yaml +11 -0
  94. package/dist/enterprise/bundle/.claude-plugin/marketplace.json +36 -0
  95. package/dist/enterprise/bundle/.claude-plugin/plugin.json +23 -0
  96. package/dist/enterprise/bundle/.mcp.json +40 -0
  97. package/dist/enterprise/bundle/OMG_COMPAT_CONTRACT.md +92 -0
  98. package/dist/enterprise/bundle/registry/bundles/algorithms.yaml +45 -0
  99. package/dist/enterprise/bundle/registry/bundles/api-twin.yaml +48 -0
  100. package/dist/enterprise/bundle/registry/bundles/control-plane.yaml +61 -0
  101. package/dist/enterprise/bundle/registry/bundles/data-lineage.yaml +47 -0
  102. package/dist/enterprise/bundle/registry/bundles/delta-classifier.yaml +47 -0
  103. package/dist/enterprise/bundle/registry/bundles/eval-gate.yaml +47 -0
  104. package/dist/enterprise/bundle/registry/bundles/health.yaml +45 -0
  105. package/dist/enterprise/bundle/registry/bundles/hook-governor.yaml +97 -0
  106. package/dist/enterprise/bundle/registry/bundles/incident-replay.yaml +47 -0
  107. package/dist/enterprise/bundle/registry/bundles/lsp-pack.yaml +48 -0
  108. package/dist/enterprise/bundle/registry/bundles/mcp-fabric.yaml +53 -0
  109. package/dist/enterprise/bundle/registry/bundles/preflight.yaml +48 -0
  110. package/dist/enterprise/bundle/registry/bundles/remote-supervisor.yaml +49 -0
  111. package/dist/enterprise/bundle/registry/bundles/robotics.yaml +45 -0
  112. package/dist/enterprise/bundle/registry/bundles/secure-worktree-pipeline.yaml +54 -0
  113. package/dist/enterprise/bundle/registry/bundles/security-check.yaml +50 -0
  114. package/dist/enterprise/bundle/registry/bundles/tracebank.yaml +47 -0
  115. package/dist/enterprise/bundle/registry/bundles/vision.yaml +45 -0
  116. package/dist/enterprise/bundle/registry/omg-capability.schema.json +80 -0
  117. package/dist/enterprise/bundle/settings.json +381 -0
  118. package/dist/enterprise/manifest.json +255 -0
  119. package/dist/public/bundle/.agents/skills/omg/AGENTS.fragment.md +5 -0
  120. package/dist/public/bundle/.agents/skills/omg/algorithms/SKILL.md +11 -0
  121. package/dist/public/bundle/.agents/skills/omg/algorithms/openai.yaml +11 -0
  122. package/dist/public/bundle/.agents/skills/omg/api-twin/SKILL.md +11 -0
  123. package/dist/public/bundle/.agents/skills/omg/api-twin/openai.yaml +12 -0
  124. package/dist/public/bundle/.agents/skills/omg/codex-mcp.toml +4 -0
  125. package/dist/public/bundle/.agents/skills/omg/control-plane/SKILL.md +11 -0
  126. package/dist/public/bundle/.agents/skills/omg/control-plane/openai.yaml +14 -0
  127. package/dist/public/bundle/.agents/skills/omg/data-lineage/SKILL.md +11 -0
  128. package/dist/public/bundle/.agents/skills/omg/data-lineage/openai.yaml +12 -0
  129. package/dist/public/bundle/.agents/skills/omg/delta-classifier/SKILL.md +11 -0
  130. package/dist/public/bundle/.agents/skills/omg/delta-classifier/openai.yaml +12 -0
  131. package/dist/public/bundle/.agents/skills/omg/eval-gate/SKILL.md +11 -0
  132. package/dist/public/bundle/.agents/skills/omg/eval-gate/openai.yaml +12 -0
  133. package/dist/public/bundle/.agents/skills/omg/health/SKILL.md +11 -0
  134. package/dist/public/bundle/.agents/skills/omg/health/openai.yaml +11 -0
  135. package/dist/public/bundle/.agents/skills/omg/hook-governor/SKILL.md +11 -0
  136. package/dist/public/bundle/.agents/skills/omg/hook-governor/openai.yaml +11 -0
  137. package/dist/public/bundle/.agents/skills/omg/incident-replay/SKILL.md +11 -0
  138. package/dist/public/bundle/.agents/skills/omg/incident-replay/openai.yaml +12 -0
  139. package/dist/public/bundle/.agents/skills/omg/lsp-pack/SKILL.md +11 -0
  140. package/dist/public/bundle/.agents/skills/omg/lsp-pack/openai.yaml +11 -0
  141. package/dist/public/bundle/.agents/skills/omg/mcp-fabric/SKILL.md +11 -0
  142. package/dist/public/bundle/.agents/skills/omg/mcp-fabric/openai.yaml +13 -0
  143. package/dist/public/bundle/.agents/skills/omg/preflight/SKILL.md +11 -0
  144. package/dist/public/bundle/.agents/skills/omg/preflight/openai.yaml +12 -0
  145. package/dist/public/bundle/.agents/skills/omg/remote-supervisor/SKILL.md +11 -0
  146. package/dist/public/bundle/.agents/skills/omg/remote-supervisor/openai.yaml +12 -0
  147. package/dist/public/bundle/.agents/skills/omg/robotics/SKILL.md +11 -0
  148. package/dist/public/bundle/.agents/skills/omg/robotics/openai.yaml +11 -0
  149. package/dist/public/bundle/.agents/skills/omg/secure-worktree-pipeline/SKILL.md +11 -0
  150. package/dist/public/bundle/.agents/skills/omg/secure-worktree-pipeline/openai.yaml +12 -0
  151. package/dist/public/bundle/.agents/skills/omg/security-check/SKILL.md +11 -0
  152. package/dist/public/bundle/.agents/skills/omg/security-check/openai.yaml +13 -0
  153. package/dist/public/bundle/.agents/skills/omg/tracebank/SKILL.md +11 -0
  154. package/dist/public/bundle/.agents/skills/omg/tracebank/openai.yaml +12 -0
  155. package/dist/public/bundle/.agents/skills/omg/vision/SKILL.md +11 -0
  156. package/dist/public/bundle/.agents/skills/omg/vision/openai.yaml +11 -0
  157. package/dist/public/bundle/.claude-plugin/marketplace.json +36 -0
  158. package/dist/public/bundle/.claude-plugin/plugin.json +23 -0
  159. package/dist/public/bundle/.mcp.json +40 -0
  160. package/dist/public/bundle/OMG_COMPAT_CONTRACT.md +92 -0
  161. package/dist/public/bundle/registry/bundles/algorithms.yaml +45 -0
  162. package/dist/public/bundle/registry/bundles/api-twin.yaml +48 -0
  163. package/dist/public/bundle/registry/bundles/control-plane.yaml +61 -0
  164. package/dist/public/bundle/registry/bundles/data-lineage.yaml +47 -0
  165. package/dist/public/bundle/registry/bundles/delta-classifier.yaml +47 -0
  166. package/dist/public/bundle/registry/bundles/eval-gate.yaml +47 -0
  167. package/dist/public/bundle/registry/bundles/health.yaml +45 -0
  168. package/dist/public/bundle/registry/bundles/hook-governor.yaml +97 -0
  169. package/dist/public/bundle/registry/bundles/incident-replay.yaml +47 -0
  170. package/dist/public/bundle/registry/bundles/lsp-pack.yaml +48 -0
  171. package/dist/public/bundle/registry/bundles/mcp-fabric.yaml +53 -0
  172. package/dist/public/bundle/registry/bundles/preflight.yaml +48 -0
  173. package/dist/public/bundle/registry/bundles/remote-supervisor.yaml +49 -0
  174. package/dist/public/bundle/registry/bundles/robotics.yaml +45 -0
  175. package/dist/public/bundle/registry/bundles/secure-worktree-pipeline.yaml +54 -0
  176. package/dist/public/bundle/registry/bundles/security-check.yaml +50 -0
  177. package/dist/public/bundle/registry/bundles/tracebank.yaml +47 -0
  178. package/dist/public/bundle/registry/bundles/vision.yaml +45 -0
  179. package/dist/public/bundle/registry/omg-capability.schema.json +80 -0
  180. package/dist/public/bundle/settings.json +379 -0
  181. package/dist/public/manifest.json +255 -0
  182. package/docs/assets/omg-hud.svg +32 -0
  183. package/docs/install/claude-code.md +31 -0
  184. package/docs/install/codex.md +29 -0
  185. package/docs/migration/native-adoption.md +57 -0
  186. package/docs/proof.md +55 -0
  187. package/docs/release-checklist.md +38 -0
  188. package/docs/transcripts/crazy.md +17 -0
  189. package/docs/transcripts/setup.md +25 -0
  190. package/hooks/policy_engine.py +38 -7
  191. package/hooks/post-write.py +1 -1
  192. package/hooks/prompt-enhancer.py +1 -1
  193. package/hooks/security_validators.py +75 -0
  194. package/hooks/setup_wizard.py +43 -8
  195. package/hooks/shadow_manager.py +28 -2
  196. package/package.json +1 -1
  197. package/plugins/README.md +3 -1
  198. package/plugins/__init__.py +1 -0
  199. package/plugins/advanced/commands/OMG:deep-plan.md +1 -1
  200. package/plugins/advanced/commands/OMG:security-review.md +10 -113
  201. package/plugins/advanced/commands/OMG:ship.md +1 -1
  202. package/plugins/advanced/plugin.json +1 -10
  203. package/plugins/core/plugin.json +25 -2
  204. package/pyproject.toml +38 -2
  205. package/registry/__init__.py +1 -0
  206. package/registry/bundles/algorithms.yaml +45 -0
  207. package/registry/bundles/api-twin.yaml +48 -0
  208. package/registry/bundles/control-plane.yaml +61 -0
  209. package/registry/bundles/data-lineage.yaml +47 -0
  210. package/registry/bundles/delta-classifier.yaml +47 -0
  211. package/registry/bundles/eval-gate.yaml +47 -0
  212. package/registry/bundles/health.yaml +45 -0
  213. package/registry/bundles/hook-governor.yaml +97 -0
  214. package/registry/bundles/incident-replay.yaml +47 -0
  215. package/registry/bundles/lsp-pack.yaml +48 -0
  216. package/registry/bundles/mcp-fabric.yaml +53 -0
  217. package/registry/bundles/preflight.yaml +48 -0
  218. package/registry/bundles/remote-supervisor.yaml +49 -0
  219. package/registry/bundles/robotics.yaml +45 -0
  220. package/registry/bundles/secure-worktree-pipeline.yaml +54 -0
  221. package/registry/bundles/security-check.yaml +50 -0
  222. package/registry/bundles/tracebank.yaml +47 -0
  223. package/registry/bundles/vision.yaml +45 -0
  224. package/registry/omg-capability.schema.json +80 -0
  225. package/registry/verify_artifact.py +90 -0
  226. package/runtime/adapters/claude.py +3 -0
  227. package/runtime/adapters/gpt.py +3 -0
  228. package/runtime/adapters/local.py +3 -0
  229. package/runtime/adoption.py +1 -1
  230. package/runtime/api_twin.py +179 -0
  231. package/runtime/asset_loader.py +62 -0
  232. package/runtime/compat.py +24 -3
  233. package/runtime/contract_compiler.py +847 -0
  234. package/runtime/data_lineage.py +73 -0
  235. package/runtime/delta_classifier.py +81 -0
  236. package/runtime/domain_packs.py +46 -0
  237. package/runtime/ecosystem.py +1 -1
  238. package/runtime/eval_gate.py +50 -0
  239. package/runtime/guide_assert.py +45 -0
  240. package/runtime/incident_replay.py +47 -0
  241. package/runtime/mcp_config_writers.py +147 -30
  242. package/runtime/mcp_memory_server.py +1 -1
  243. package/runtime/omg_compat_contract_snapshot.json +9 -8
  244. package/runtime/omg_contract_snapshot.json +9 -8
  245. package/runtime/omg_mcp_server.py +207 -0
  246. package/runtime/preflight.py +73 -0
  247. package/runtime/providers/codex_provider.py +2 -12
  248. package/runtime/providers/gemini_provider.py +2 -21
  249. package/runtime/providers/kimi_provider.py +2 -21
  250. package/runtime/remote_supervisor.py +64 -0
  251. package/runtime/runtime_profile.py +61 -0
  252. package/runtime/security_check.py +464 -0
  253. package/runtime/subagent_dispatcher.py +117 -10
  254. package/runtime/team_router.py +3 -1
  255. package/runtime/tracebank.py +53 -0
  256. package/runtime/untrusted_content.py +102 -0
  257. package/scripts/omg.py +360 -2
  258. package/settings.json +81 -18
  259. package/tools/python_repl.py +33 -3
@@ -0,0 +1,53 @@
1
+ """Structured trace capture for OMG routes and release evidence."""
2
+ from __future__ import annotations
3
+
4
+ from datetime import datetime, timezone
5
+ import json
6
+ from pathlib import Path
7
+ from typing import Any
8
+ from uuid import uuid4
9
+
10
+
11
+ TRACEBANK_REL_PATH = Path(".omg") / "tracebank" / "events.jsonl"
12
+
13
+
14
+ def _now() -> str:
15
+ return datetime.now(timezone.utc).isoformat()
16
+
17
+
18
+ def record_trace(
19
+ project_dir: str,
20
+ *,
21
+ trace_type: str,
22
+ route: str,
23
+ status: str,
24
+ plan: dict[str, Any] | None = None,
25
+ patch: dict[str, Any] | None = None,
26
+ verify: dict[str, Any] | None = None,
27
+ failures: list[dict[str, Any]] | None = None,
28
+ rejections: list[dict[str, Any]] | None = None,
29
+ metadata: dict[str, Any] | None = None,
30
+ ) -> dict[str, Any]:
31
+ trace_id = f"trace-{uuid4().hex}"
32
+ record = {
33
+ "schema": "TracebankRecord",
34
+ "trace_id": trace_id,
35
+ "recorded_at": _now(),
36
+ "trace_type": trace_type,
37
+ "route": route,
38
+ "status": status,
39
+ "plan": plan or {},
40
+ "patch": patch or {},
41
+ "verify": verify or {},
42
+ "failures": failures or [],
43
+ "rejections": rejections or [],
44
+ "metadata": metadata or {},
45
+ }
46
+
47
+ path = Path(project_dir) / TRACEBANK_REL_PATH
48
+ path.parent.mkdir(parents=True, exist_ok=True)
49
+ with path.open("a", encoding="utf-8") as handle:
50
+ handle.write(json.dumps(record, ensure_ascii=True) + "\n")
51
+
52
+ record["path"] = TRACEBANK_REL_PATH.as_posix()
53
+ return record
@@ -0,0 +1,102 @@
1
+ """State and provenance tracking for untrusted external content."""
2
+ from __future__ import annotations
3
+
4
+ import json
5
+ from pathlib import Path
6
+ import re
7
+ from typing import Any
8
+
9
+
10
+ STATE_REL_PATH = Path(".omg") / "state" / "untrusted-content.json"
11
+ _INSTRUCTION_PATTERNS: tuple[re.Pattern[str], ...] = (
12
+ re.compile(r"ignore\s+previous\s+instructions", re.IGNORECASE),
13
+ re.compile(r"\b(system|assistant|developer)\s*:", re.IGNORECASE),
14
+ re.compile(r"\b(run|execute|commit|push|apply_patch|edit)\b", re.IGNORECASE),
15
+ )
16
+
17
+
18
+ def mark_untrusted_content(
19
+ project_dir: str,
20
+ *,
21
+ source_type: str,
22
+ content: str,
23
+ source_ref: str = "",
24
+ ) -> dict[str, Any]:
25
+ state_path = _state_path(project_dir)
26
+ state = get_untrusted_content_state(project_dir)
27
+ sanitized, quarantined = quarantine_instruction_like_text(content)
28
+ entry = {
29
+ "source_type": source_type,
30
+ "source_ref": source_ref,
31
+ "quarantined_fragments": quarantined,
32
+ "trust_score": 0.0,
33
+ }
34
+ provenance = list(state.get("provenance", []))
35
+ provenance.append(entry)
36
+ next_state = {
37
+ "active": True,
38
+ "last_source_type": source_type,
39
+ "last_source_ref": source_ref,
40
+ "sanitized_content": sanitized,
41
+ "quarantined_fragments": quarantined,
42
+ "provenance": provenance[-20:],
43
+ "trust_scores": {"external_content": 0.0},
44
+ }
45
+ _write_state(state_path, next_state)
46
+ return next_state
47
+
48
+
49
+ def clear_untrusted_content(project_dir: str, *, reason: str) -> dict[str, Any]:
50
+ state_path = _state_path(project_dir)
51
+ existing = get_untrusted_content_state(project_dir)
52
+ next_state = {
53
+ **existing,
54
+ "active": False,
55
+ "cleared_reason": reason,
56
+ }
57
+ _write_state(state_path, next_state)
58
+ return next_state
59
+
60
+
61
+ def get_untrusted_content_state(project_dir: str) -> dict[str, Any]:
62
+ state_path = _state_path(project_dir)
63
+ if not state_path.exists():
64
+ return {
65
+ "active": False,
66
+ "provenance": [],
67
+ "trust_scores": {},
68
+ }
69
+ try:
70
+ payload = json.loads(state_path.read_text(encoding="utf-8"))
71
+ except (OSError, json.JSONDecodeError):
72
+ return {
73
+ "active": False,
74
+ "provenance": [],
75
+ "trust_scores": {},
76
+ }
77
+ return payload if isinstance(payload, dict) else {"active": False, "provenance": [], "trust_scores": {}}
78
+
79
+
80
+ def is_untrusted_content_mode_active(project_dir: str) -> bool:
81
+ return bool(get_untrusted_content_state(project_dir).get("active", False))
82
+
83
+
84
+ def quarantine_instruction_like_text(content: str) -> tuple[str, list[str]]:
85
+ sanitized_lines: list[str] = []
86
+ quarantined: list[str] = []
87
+ for raw_line in content.splitlines():
88
+ line = raw_line.strip()
89
+ if any(pattern.search(line) for pattern in _INSTRUCTION_PATTERNS):
90
+ quarantined.append(raw_line)
91
+ continue
92
+ sanitized_lines.append(raw_line)
93
+ return "\n".join(sanitized_lines).strip(), quarantined
94
+
95
+
96
+ def _state_path(project_dir: str) -> Path:
97
+ return Path(project_dir) / STATE_REL_PATH
98
+
99
+
100
+ def _write_state(path: Path, payload: dict[str, Any]) -> None:
101
+ path.parent.mkdir(parents=True, exist_ok=True)
102
+ path.write_text(json.dumps(payload, indent=2, ensure_ascii=True) + "\n", encoding="utf-8")
package/scripts/omg.py CHANGED
@@ -1,10 +1,11 @@
1
1
  #!/usr/bin/env python3
2
- """OMG 2.0.3 CLI entrypoint.
2
+ """OMG 2.0.5 CLI entrypoint.
3
3
 
4
4
  Implements practical command-line flows for:
5
5
  - omg ship
6
6
  - omg fix --issue
7
7
  - omg secure
8
+ - omg security check
8
9
  - omg maintainer
9
10
  - omg trust review
10
11
  - omg runtime dispatch
@@ -31,6 +32,20 @@ from hooks.shadow_manager import create_evidence_pack
31
32
  from hooks.trust_review import review_config_change, write_trust_manifest
32
33
  from lab.pipeline import publish_artifact, run_pipeline
33
34
  from runtime.dispatcher import dispatch_runtime
35
+ from runtime.api_twin import ingest_contract, record_fixture, serve_fixture, verify_fixture
36
+ from runtime.data_lineage import build_lineage_manifest
37
+ from runtime.eval_gate import evaluate_trace
38
+ from runtime.incident_replay import build_incident_pack
39
+ from runtime.domain_packs import get_domain_pack_contract
40
+ from runtime.preflight import run_preflight
41
+ from runtime.remote_supervisor import issue_local_supervisor_session, verify_local_supervisor_token
42
+ from runtime.security_check import run_security_check
43
+ from runtime.contract_compiler import (
44
+ build_release_readiness,
45
+ compile_contract_outputs,
46
+ validate_contract_registry,
47
+ )
48
+ from runtime.tracebank import record_trace
34
49
  from runtime.compat import (
35
50
  DEFAULT_CONTRACT_SNAPSHOT_PATH,
36
51
  DEFAULT_GAP_REPORT_PATH,
@@ -120,14 +135,55 @@ def cmd_ship(args: argparse.Namespace) -> int:
120
135
  run_id = args.run_id or _now_run_id()
121
136
  verification = dispatched.get("verification", {})
122
137
  checks = verification.get("checks", []) if isinstance(verification, dict) else []
138
+ preflight = run_preflight(project_dir, goal=str(idea.get("goal", "")))
139
+ security_result = run_security_check(project_dir=project_dir, scope=".")
140
+ trace = record_trace(
141
+ project_dir,
142
+ trace_type="ship",
143
+ route=preflight["route"],
144
+ status="ok",
145
+ plan=dispatched.get("plan", {}),
146
+ verify=verification if isinstance(verification, dict) else {},
147
+ metadata={"runtime": runtime, "run_id": run_id},
148
+ )
149
+ eval_result = evaluate_trace(
150
+ project_dir,
151
+ trace_id=trace["trace_id"],
152
+ suites=["planning", "security"],
153
+ metrics={
154
+ "planning": 1.0 if dispatched.get("status") == "ok" else 0.0,
155
+ "security": max(float(security_result["trust_scores"].get("overall", 0.0)), 0.0),
156
+ },
157
+ )
158
+ lineage = build_lineage_manifest(
159
+ project_dir,
160
+ artifact_type="evidence-pack",
161
+ sources=[{"kind": "repo", "path": ".", "license": "MIT"}],
162
+ privacy="internal",
163
+ license="MIT",
164
+ derivation={"trace_id": trace["trace_id"], "route": preflight["route"], "eval_path": eval_result["path"]},
165
+ trace_id=trace["trace_id"],
166
+ )
123
167
  evidence_path = create_evidence_pack(
124
168
  project_dir,
125
169
  run_id,
126
170
  tests=checks if isinstance(checks, list) else [],
127
- security_scans=[],
171
+ security_scans=[
172
+ {
173
+ "tool": "security-check",
174
+ "finding_count": security_result["summary"]["finding_count"],
175
+ "path": security_result["evidence"]["path"],
176
+ }
177
+ ],
128
178
  diff_summary={"runtime": runtime, "goal": idea.get("goal", "")},
129
179
  reproducibility={"command": f"omg ship --runtime {runtime} --idea {idea_path}"},
130
180
  unresolved_risks=[],
181
+ provenance=security_result["provenance"],
182
+ trust_scores=security_result["trust_scores"],
183
+ api_twin={"recommended_route": preflight["route"] if preflight["route"] == "api-twin" else ""},
184
+ route_metadata=preflight,
185
+ trace_ids=[trace["trace_id"]],
186
+ lineage=lineage,
131
187
  )
132
188
 
133
189
  out = {
@@ -137,6 +193,8 @@ def cmd_ship(args: argparse.Namespace) -> int:
137
193
  "run_id": run_id,
138
194
  "goal": idea.get("goal", ""),
139
195
  "evidence_path": os.path.relpath(evidence_path, project_dir),
196
+ "trace_id": trace["trace_id"],
197
+ "eval_path": eval_result["path"],
140
198
  }
141
199
  print(json.dumps(out, indent=2))
142
200
  return 0
@@ -155,6 +213,151 @@ def cmd_secure(args: argparse.Namespace) -> int:
155
213
  return 0 if decision.action != "deny" else 3
156
214
 
157
215
 
216
+ def cmd_security_check(args: argparse.Namespace) -> int:
217
+ result = run_security_check(
218
+ project_dir=_ensure_project_dir(),
219
+ scope=args.scope,
220
+ include_live_enrichment=bool(args.live_enrichment),
221
+ )
222
+ print(json.dumps(result, indent=2))
223
+ return 0
224
+
225
+
226
+ def cmd_api_twin_ingest(args: argparse.Namespace) -> int:
227
+ result = ingest_contract(_ensure_project_dir(), name=args.name, source_path=args.source)
228
+ print(json.dumps(result, indent=2))
229
+ return 0
230
+
231
+
232
+ def cmd_api_twin_record(args: argparse.Namespace) -> int:
233
+ result = record_fixture(
234
+ _ensure_project_dir(),
235
+ name=args.name,
236
+ endpoint=args.endpoint,
237
+ cassette_version=args.cassette_version,
238
+ request=json.loads(args.request_json),
239
+ response=json.loads(args.response_json),
240
+ validated=bool(args.validated),
241
+ redactions=json.loads(args.redactions_json) if args.redactions_json else None,
242
+ )
243
+ print(json.dumps(result, indent=2))
244
+ return 0
245
+
246
+
247
+ def cmd_api_twin_serve(args: argparse.Namespace) -> int:
248
+ result = serve_fixture(
249
+ _ensure_project_dir(),
250
+ name=args.name,
251
+ endpoint=args.endpoint,
252
+ cassette_version=args.cassette_version,
253
+ latency_ms=int(args.latency_ms),
254
+ failure_mode=args.failure_mode,
255
+ schema_drift=bool(args.schema_drift),
256
+ )
257
+ print(json.dumps(result, indent=2))
258
+ return 0
259
+
260
+
261
+ def cmd_api_twin_verify(args: argparse.Namespace) -> int:
262
+ result = verify_fixture(
263
+ _ensure_project_dir(),
264
+ name=args.name,
265
+ endpoint=args.endpoint,
266
+ cassette_version=args.cassette_version,
267
+ live_response=json.loads(args.live_response_json),
268
+ )
269
+ print(json.dumps(result, indent=2))
270
+ return 0
271
+
272
+
273
+ def cmd_preflight(args: argparse.Namespace) -> int:
274
+ result = run_preflight(_ensure_project_dir(), goal=args.goal)
275
+ print(json.dumps(result, indent=2))
276
+ return 0
277
+
278
+
279
+ def cmd_domain_pack(args: argparse.Namespace) -> int:
280
+ result = get_domain_pack_contract(args.name)
281
+ print(json.dumps(result, indent=2))
282
+ return 0
283
+
284
+
285
+ def cmd_trace_record(args: argparse.Namespace) -> int:
286
+ result = record_trace(
287
+ _ensure_project_dir(),
288
+ trace_type=args.trace_type,
289
+ route=args.route,
290
+ status=args.status,
291
+ plan=json.loads(args.plan_json) if args.plan_json else {},
292
+ verify=json.loads(args.verify_json) if args.verify_json else {},
293
+ )
294
+ print(json.dumps(result, indent=2))
295
+ return 0
296
+
297
+
298
+ def cmd_eval_gate(args: argparse.Namespace) -> int:
299
+ result = evaluate_trace(
300
+ _ensure_project_dir(),
301
+ trace_id=args.trace_id,
302
+ suites=args.suites.split(","),
303
+ metrics=json.loads(args.metrics_json),
304
+ )
305
+ print(json.dumps(result, indent=2))
306
+ return 0 if result["status"] == "ok" else 2
307
+
308
+
309
+ def cmd_delta_classify(args: argparse.Namespace) -> int:
310
+ from runtime.delta_classifier import classify_project_changes
311
+
312
+ touched_files = [item for item in args.files.split(",") if item]
313
+ result = classify_project_changes(_ensure_project_dir(), touched_files=touched_files or None, goal=args.goal)
314
+ print(json.dumps(result, indent=2))
315
+ return 0
316
+
317
+
318
+ def cmd_incident_replay(args: argparse.Namespace) -> int:
319
+ result = build_incident_pack(
320
+ _ensure_project_dir(),
321
+ title=args.title,
322
+ failing_tests=[item for item in args.failing_tests.split(",") if item],
323
+ logs=[item for item in args.logs.split("|") if item],
324
+ diff_summary=json.loads(args.diff_summary_json),
325
+ trace_id=args.trace_id or None,
326
+ )
327
+ print(json.dumps(result, indent=2))
328
+ return 0
329
+
330
+
331
+ def cmd_lineage(args: argparse.Namespace) -> int:
332
+ result = build_lineage_manifest(
333
+ _ensure_project_dir(),
334
+ artifact_type=args.artifact_type,
335
+ sources=json.loads(args.sources_json),
336
+ privacy=args.privacy,
337
+ license=args.license_name,
338
+ derivation=json.loads(args.derivation_json),
339
+ trace_id=args.trace_id or None,
340
+ )
341
+ print(json.dumps(result, indent=2))
342
+ return 0 if result["status"] == "ok" else 2
343
+
344
+
345
+ def cmd_supervisor_issue(args: argparse.Namespace) -> int:
346
+ result = issue_local_supervisor_session(
347
+ _ensure_project_dir(),
348
+ worker_id=args.worker_id,
349
+ shared_secret=args.shared_secret,
350
+ )
351
+ print(json.dumps(result, indent=2))
352
+ return 0
353
+
354
+
355
+ def cmd_supervisor_verify(args: argparse.Namespace) -> int:
356
+ result = verify_local_supervisor_token(args.token, shared_secret=args.shared_secret)
357
+ print(json.dumps(result, indent=2))
358
+ return 0 if result["status"] == "ok" else 2
359
+
360
+
158
361
  def cmd_maintainer(args: argparse.Namespace) -> int:
159
362
  project_dir = _ensure_project_dir()
160
363
  out_dir = Path(project_dir) / ".omg" / "evidence"
@@ -357,6 +560,34 @@ def cmd_ecosystem_sync(args: argparse.Namespace) -> int:
357
560
  return 0 if not errors else 2
358
561
 
359
562
 
563
+ def cmd_contract_validate(args: argparse.Namespace) -> int:
564
+ result = validate_contract_registry(ROOT_DIR)
565
+ print(json.dumps(result, indent=2))
566
+ return 0 if result.get("status") == "ok" else 2
567
+
568
+
569
+ def cmd_contract_compile(args: argparse.Namespace) -> int:
570
+ hosts = args.hosts or []
571
+ result = compile_contract_outputs(
572
+ root_dir=ROOT_DIR,
573
+ output_root=args.output_root,
574
+ hosts=hosts,
575
+ channel=args.channel,
576
+ )
577
+ print(json.dumps(result, indent=2))
578
+ return 0 if result.get("status") == "ok" else 2
579
+
580
+
581
+ def cmd_release_readiness(args: argparse.Namespace) -> int:
582
+ result = build_release_readiness(
583
+ root_dir=ROOT_DIR,
584
+ output_root=args.output_root,
585
+ channel=args.channel,
586
+ )
587
+ print(json.dumps(result, indent=2))
588
+ return 0 if result.get("status") == "ok" else 2
589
+
590
+
360
591
  def _add_compat_subcommands(parent: argparse.ArgumentParser, *, dest: str) -> None:
361
592
  compat_sub = parent.add_subparsers(dest=dest, required=True)
362
593
  compat_list = compat_sub.add_parser("list", help="List supported legacy skill names")
@@ -399,6 +630,35 @@ def _add_ecosystem_subcommands(parent: argparse.ArgumentParser, *, dest: str) ->
399
630
  ecosystem_sync.set_defaults(func=cmd_ecosystem_sync)
400
631
 
401
632
 
633
+ def _add_contract_subcommands(parent: argparse.ArgumentParser, *, dest: str) -> None:
634
+ contract_sub = parent.add_subparsers(dest=dest, required=True)
635
+
636
+ contract_validate = contract_sub.add_parser("validate", help="Validate contract doc, schema, and bundle registry")
637
+ contract_validate.set_defaults(func=cmd_contract_validate)
638
+
639
+ contract_compile = contract_sub.add_parser("compile", help="Compile Claude/Codex artifacts from the canonical contract")
640
+ contract_compile.add_argument(
641
+ "--host",
642
+ dest="hosts",
643
+ action="append",
644
+ choices=["claude", "codex"],
645
+ required=True,
646
+ help="Host to compile (repeat for multiple hosts)",
647
+ )
648
+ contract_compile.add_argument("--channel", default="public", choices=["public", "enterprise"])
649
+ contract_compile.add_argument("--output-root", default="", help="Write outputs to this root instead of the repo root")
650
+ contract_compile.set_defaults(func=cmd_contract_compile)
651
+
652
+
653
+ def _add_release_subcommands(parent: argparse.ArgumentParser, *, dest: str) -> None:
654
+ release_sub = parent.add_subparsers(dest=dest, required=True)
655
+
656
+ release_readiness = release_sub.add_parser("readiness", help="Check production release readiness for compiled artifacts")
657
+ release_readiness.add_argument("--channel", default="dual", choices=["public", "enterprise", "dual"])
658
+ release_readiness.add_argument("--output-root", default="", help="Check compiled outputs from this root instead of the repo root")
659
+ release_readiness.set_defaults(func=cmd_release_readiness)
660
+
661
+
402
662
  def build_parser() -> argparse.ArgumentParser:
403
663
  parser = argparse.ArgumentParser(prog="omg", description=f"OMG {CANONICAL_VERSION} CLI")
404
664
  sub = parser.add_subparsers(dest="command", required=True)
@@ -418,6 +678,98 @@ def build_parser() -> argparse.ArgumentParser:
418
678
  secure.add_argument("--command", required=True)
419
679
  secure.set_defaults(func=cmd_secure)
420
680
 
681
+ security = sub.add_parser("security", help="Canonical OMG security workflows")
682
+ security_sub = security.add_subparsers(dest="security_command", required=True)
683
+ security_check = security_sub.add_parser("check", help="Run canonical OMG security check")
684
+ security_check.add_argument("--scope", default=".")
685
+ security_check.add_argument("--live-enrichment", action="store_true")
686
+ security_check.set_defaults(func=cmd_security_check)
687
+
688
+ api_twin = sub.add_parser("api-twin", help="Contract replay and fixture-based API simulation")
689
+ api_twin_sub = api_twin.add_subparsers(dest="api_twin_command", required=True)
690
+ api_twin_ingest = api_twin_sub.add_parser("ingest", help="Ingest OpenAPI/Postman/example contract input")
691
+ api_twin_ingest.add_argument("--name", required=True)
692
+ api_twin_ingest.add_argument("--source", required=True)
693
+ api_twin_ingest.set_defaults(func=cmd_api_twin_ingest)
694
+ api_twin_record = api_twin_sub.add_parser("record", help="Record approved fixture response")
695
+ api_twin_record.add_argument("--name", required=True)
696
+ api_twin_record.add_argument("--endpoint", default="default")
697
+ api_twin_record.add_argument("--cassette-version", default="v1")
698
+ api_twin_record.add_argument("--request-json", required=True)
699
+ api_twin_record.add_argument("--response-json", required=True)
700
+ api_twin_record.add_argument("--validated", action="store_true")
701
+ api_twin_record.add_argument("--redactions-json", default="")
702
+ api_twin_record.set_defaults(func=cmd_api_twin_record)
703
+ api_twin_serve = api_twin_sub.add_parser("serve", help="Replay a fixture with optional drift/failure injection")
704
+ api_twin_serve.add_argument("--name", required=True)
705
+ api_twin_serve.add_argument("--endpoint", default="default")
706
+ api_twin_serve.add_argument("--cassette-version", default="v1")
707
+ api_twin_serve.add_argument("--latency-ms", type=int, default=0)
708
+ api_twin_serve.add_argument("--failure-mode", default="")
709
+ api_twin_serve.add_argument("--schema-drift", action="store_true")
710
+ api_twin_serve.set_defaults(func=cmd_api_twin_serve)
711
+ api_twin_verify = api_twin_sub.add_parser("verify", help="Validate a fixture against a live response")
712
+ api_twin_verify.add_argument("--name", required=True)
713
+ api_twin_verify.add_argument("--endpoint", default="default")
714
+ api_twin_verify.add_argument("--cassette-version", default="v1")
715
+ api_twin_verify.add_argument("--live-response-json", required=True)
716
+ api_twin_verify.set_defaults(func=cmd_api_twin_verify)
717
+
718
+ preflight = sub.add_parser("preflight", help="Structured OMG preflight routing")
719
+ preflight.add_argument("--goal", required=True)
720
+ preflight.set_defaults(func=cmd_preflight)
721
+
722
+ domain_pack = sub.add_parser("domain-pack", help="Inspect optional domain pack contracts")
723
+ domain_pack.add_argument("--name", required=True, choices=["robotics", "vision", "algorithms", "health"])
724
+ domain_pack.set_defaults(func=cmd_domain_pack)
725
+
726
+ tracebank = sub.add_parser("tracebank", help="Record structured route traces")
727
+ tracebank.add_argument("--trace-type", required=True)
728
+ tracebank.add_argument("--route", required=True)
729
+ tracebank.add_argument("--status", default="ok")
730
+ tracebank.add_argument("--plan-json", default="")
731
+ tracebank.add_argument("--verify-json", default="")
732
+ tracebank.set_defaults(func=cmd_trace_record)
733
+
734
+ eval_gate = sub.add_parser("eval-gate", help="Evaluate a trace for release gating")
735
+ eval_gate.add_argument("--trace-id", required=True)
736
+ eval_gate.add_argument("--suites", required=True, help="Comma-separated suite names")
737
+ eval_gate.add_argument("--metrics-json", required=True)
738
+ eval_gate.set_defaults(func=cmd_eval_gate)
739
+
740
+ delta = sub.add_parser("delta-classifier", help="Classify repo changes for routing and policy")
741
+ delta.add_argument("--goal", default="")
742
+ delta.add_argument("--files", default="")
743
+ delta.set_defaults(func=cmd_delta_classify)
744
+
745
+ incident = sub.add_parser("incident-replay", help="Build an incident replay pack")
746
+ incident.add_argument("--title", required=True)
747
+ incident.add_argument("--failing-tests", default="")
748
+ incident.add_argument("--logs", default="")
749
+ incident.add_argument("--diff-summary-json", required=True)
750
+ incident.add_argument("--trace-id", default="")
751
+ incident.set_defaults(func=cmd_incident_replay)
752
+
753
+ lineage = sub.add_parser("data-lineage", help="Build lineage metadata for generated artifacts")
754
+ lineage.add_argument("--artifact-type", required=True)
755
+ lineage.add_argument("--sources-json", required=True)
756
+ lineage.add_argument("--privacy", required=True)
757
+ lineage.add_argument("--license-name", required=True)
758
+ lineage.add_argument("--derivation-json", required=True)
759
+ lineage.add_argument("--trace-id", default="")
760
+ lineage.set_defaults(func=cmd_lineage)
761
+
762
+ supervisor = sub.add_parser("remote-supervisor", help="Local-only authenticated supervisor session helpers")
763
+ supervisor_sub = supervisor.add_subparsers(dest="remote_supervisor_command", required=True)
764
+ supervisor_issue = supervisor_sub.add_parser("issue", help="Issue a local supervisor session")
765
+ supervisor_issue.add_argument("--worker-id", required=True)
766
+ supervisor_issue.add_argument("--shared-secret", required=True)
767
+ supervisor_issue.set_defaults(func=cmd_supervisor_issue)
768
+ supervisor_verify = supervisor_sub.add_parser("verify", help="Verify a supervisor session token")
769
+ supervisor_verify.add_argument("--token", required=True)
770
+ supervisor_verify.add_argument("--shared-secret", required=True)
771
+ supervisor_verify.set_defaults(func=cmd_supervisor_verify)
772
+
421
773
  maintainer = sub.add_parser("maintainer", help="OSS maintainer evidence helper")
422
774
  maintainer.add_argument("--mode", default="impact", choices=["triage", "release", "review", "impact"])
423
775
  maintainer.set_defaults(func=cmd_maintainer)
@@ -479,6 +831,12 @@ def build_parser() -> argparse.ArgumentParser:
479
831
  ecosystem = sub.add_parser("ecosystem", help="Upstream ecosystem sync and status")
480
832
  _add_ecosystem_subcommands(ecosystem, dest="ecosystem_command")
481
833
 
834
+ contract = sub.add_parser("contract", help="Canonical OMG contract validation and compilation")
835
+ _add_contract_subcommands(contract, dest="contract_command")
836
+
837
+ release = sub.add_parser("release", help="OMG release-readiness checks")
838
+ _add_release_subcommands(release, dest="release_command")
839
+
482
840
  return parser
483
841
 
484
842