We study 2d N = (0, 2) supersymmetric quiver gauge theories that describe the low-energy dynamics of D1-branes at Calabi-Yau fourfold (CY 4 ) singularities. On general grounds, the holomorphic sector of these theories-matter content and (classical) superpotential interactions-should be fully captured by the topological B-model on the CY 4 . By studying a number of examples, we confirm this expectation and flesh out the dictionary between B-brane category and supersymmetric quiver: the matter content of the supersymmetric quiver is encoded in morphisms between B-branes (that is, Ext groups of coherent sheaves), while the superpotential interactions are encoded in the A ∞ algebra satisfied by the morphisms. This provides us with a derivation of the supersymmetric quiver directly from the CY 4 geometry. We also suggest a relation between triality of N = (0, 2) gauge theories and certain mutations of exceptional collections of sheaves. 0d N = 1 supersymmetric quivers, corresponding to D-instantons probing CY 5 singularities, can be discussed similarly. Contents 1. Introduction 2 2. D1-brane quivers and 2d N = (0, 2) theories 7 2.1 N = (0, 2) quiver gauge theory from B-branes at a CY 4 singularity 8 2.2 D1-brane on C 4 15 2.3 Orbifolds C 4 /Γ 20 2.4 Fractional branes on a local P 3 24 2.5 Fractional branes on a local P 1 × P 1 38 3. Triality and mutations of exceptional collections 44 3.1 Triality acting on N = (0, 2) supersymmetric quivers 45 3.2 Triality and the C 4 /Z 4 quiver 47 3.3 Triality from mutation-a conjecture 51 4. D-instanton quivers and gauged matrix models 55 4.1 N = 1 gauged matrix model from B-branes at a CY 5 singularity 56 4.2 D(−1)-brane on C 5 58 4.3 Orbifolds C 5 /Γ 60 A. Dimensional reductions 63 B. Fractional D3-branes on a local P 2 65 B.1 Fractional branes and supersymmetric quivers 65 B.2 Seiberg duality as mutation 69 C. A ∞ structure and N = (0, 2) quiver 70 C.1 An algebraic preliminary 70 C.2 Ext algebra and N = (0, 2) quiver 71 C.3 General procedure to compute the higher products 73 D. Higher products on a local P 1 × P 1 74-1 -1 That is, fields X IJ in the fundamental of U (N I ) and in the antifundamental of U (N J ). 2 Very recently, these 2d and 0d quivers were also related to cluster algebras [22].10 This expression is only formal. The N = (0, 2) superpotential that appears in the gauge theory Lagrangian is the usual Tr Λ I J I (X)), since superspace treats Λ andΛ asymmetrically. This formal W first appeared in [22]. It elegantly encodes the algebraic structure of the N = (0, 2) quiver relations. This point is further discussed in Appendix C.11 That is, a family of maps satisfying certain consistency conditions [59].The J-terms of the remaining 8 fields are given explicitly by:One can check that:Tr(E Γ (s) J Γ (s) ) = Tr C i M jk A k D ij , (2.81)