We show that in a stable first-order theory, the failure of higher dimensional type amalgamation can always be witnessed by algebraic structures that we call n-ary polygroupoids. This generalizes a result of Hrushovski in  that failures of 4-amalgamation are witnessed by definable groupoids (which correspond to 2-ary polygroupoids in our terminology). The n-ary polygroupoids are definable in a mild expansion of the language (adding a predicate for a Morley sequence).
Bibliographical noteFunding Information:
The second author was supported by NRF of Korea grant 2011-0021916, and Sam-sung Science Technology Foundation under project number SSTF-BA1301-03. The third author was partially supported by NSF grant DMS-0901315. We thank the anonymous referee for pointing out some minor errors in the original draft and for many helpful suggestions concerning the notation and terminology.
All Science Journal Classification (ASJC) codes