Let $X$ be a quasi-projective variety. Suppose that we (perhaps partially, if either enough is known) compactify to $\bar{X}$ with $\bar{X}\setminus X=D$ is a divisor. Say that we know the canonical bundle $K\_X$. Then $K\_{\bar{X}}=K\_X+nD$ for some $n$.


1. Is $n$ always negative? The examples I'm thinking of are for $X=\mathcal{M}\_g,\mathcal{A}\_g$
2. Is there a good method for computing this $n$?


In both cases, I'm particularly interested in finite covers of $\mathcal{M}\_g,\mathcal{A}\_g$ and other moduli spaces, if that helps to know how the variety is given.



Canonical bundle of compactifications
perhaps I am misunderstanding what you ask, but the answer is **no** to both questions. Take an arbitrary projective variety $\overline X$, actually for simplicity let $\overline X$ be normal. Then it has a canonical divisor, say $K\_{\overline X}$ and choose an actual representative, $K=\sum\_i a\_i K\_i$ where the $a\_i$ may be negative or positive. Now let $X=\overline X\setminus ({\rm Supp}\, K)$. Then $K\_X$ is trivial and there is no way you can tell the $a\_i$ just from knowing $K\_X$. Of course, if you know something else, that's a whole different question.


In any case, this at least shows that your $n$ is not always negative. If you know things like $X$ is covered by rational curves (or does not contain any) that could help, but as the above example shows, you need more information.


Some vaguely related thoughts on the canonical divisor are available at [this answer to another MO question](https://mathoverflow.net/questions/35736/the-canonical-line-bundle-of-a-normal-variety/46663#46663).


