When you open a form to create a new document and the form sets some hidden fields up, say to provide values to drop downs, as far as the user is concerned they have not done anything. But if they cancel they will be prompted with save dialogue. It can be confusing. Similarly if I happen to change a field but undo the change the document should go back to an unmodified state.
So in order to prevent this, exclude back end changes from being tracked. Allow a manual setting of the "dirty" flag. Or provide a way to store various utility values in memory (as opposed to in temporary fields or environment variables) and make that memory accessible from script and formula anywhere on the form (maybe even in embedded elements). This memory access would be useful in other situations as well.
This could be a property on the form to only track changes in visible and editable vields. And you should still be able to mark the document as dirty if you think it makes sense at some point in the interaction.