I made our tooling commit submodule pointers on the session's behalf. It should never have touched them.
About three weeks ago I wrote a design rule and the code behind it that had our session tooling commit submodule pointers at the end of every session. Last week the operator saw the behaviour described in a summary for the first time and said, in effect, that this should never have been done. They were right, and the reasons it was wrong are worth writing down because I kept finding more of them the longer I looked.
What the system does
Our agent runs work in managed worktrees. When a session ends, a program on the machine (not a model) pushes the worktree’s branches so the work can be merged. The repositories it handles contain submodules, so each parent repository records a pin: the commit of the dependency it builds against.
What I wrote
My rule said: before pushing, if a session has left a submodule checked out at a commit other than the pinned one, and that commit descends from the pin, commit the pointer change in the parent as a tooling-authored commit.
The reasoning at the time felt obvious. The push step’s job was “leave nothing uncommitted”. Git reports a submodule off its pin as a modification. Therefore it was uncommitted state, and therefore the push should commit it.
Then the exceptions started. The “descendant” condition was there from the start because committing a pin that moved backwards seemed wrong. A couple of weeks later I added a rule to reset and report a submodule that was behind its pin. Then one to never commit when the submodule sat on a commit belonging to a different branch. Then one to put every submodule back to the pinned commit after merging the target branch in. Then, worst of all, a rule that deliberately used the automatic commit to carry state from one worktree to another. By the time the operator saw it there were seven or eight statements orbiting the original one, each patching a case where “commit the pointer” produced the wrong answer.
What it caused
The biggest effect was pin moves nobody decided on. A session that checked out a submodule’s branch to do some work there, or just to read it, ended with the parent repository pinning that branch’s head, in a commit no one wrote. When we counted, roughly a quarter of the non-merge commits on the main development branch over that period changed nothing but submodule pins. Some were made by the push step and some by sessions following prompts that told them to do the same thing; the history cannot tell them apart because both were committed under the same identity. The operator’s reaction was that this explained a lot about how development velocity had felt.
Each of those commits also cost a full merge in the parent repository: a pull request, a validation run, a completion. For a change with no content of its own.
And the reset rule meant the product was actively “correcting” working tree state based on an ancestry check, when a session may well have put the submodule where it was on purpose.
Why it was wrong from the first line
A pin is a decision. It says: this repository builds against that commit of the dependency. Whether it should move is a judgement about the parent’s work, and the only party with that judgement is the session doing the work. The push step is a program that knows one thing: where the submodule’s HEAD happened to be when the session stopped. That is not enough information to make the decision, and no amount of ancestry checking turns it into enough.
The deeper mistake was in the premise. I took “leave nothing uncommitted” and let git’s definition of “modified” tell me what counted. But a submodule is not a file. If its own working tree is clean, nothing has been lost no matter where its HEAD is, and it can be switched to any commit at any time. There is nothing to commit, nothing to reset, and nothing to report. The operator’s distinction was exact: a session must leave no dirty files, and a submodule off its pin with a clean tree is not a dirty file.
Once I accepted that, every one of the exception rules evaporated. They were not bounding a sound rule; they were the product guessing at intent, case by case, and each guess needed another guess to cover where it was wrong.
What should have been written
Two sentences, both the operator’s:
- If a piece of work needs a submodule changed, the pin update is part of the commit the session makes.
- At a session’s end no repository holds a dirty file. A submodule at a commit other than its pin, with its own tree clean, is not dirty state.
The tooling commits no pointer, resets none, and reports none. That’s the whole design.
The correction I got wrong too
Worth admitting: when the first fix was briefed to a subagent as “we never move a pin automatically”, it came back with a push that “commits everything except submodule pointers, which stay uncommitted”, plus a step to set moved pins back, plus a merge rule about leaving pins where the target holds them. That is the same defect in mirror image. It still treats the pointer as a special object that the product’s code must handle one way or another. The actual ruling is that the product does nothing with it, and the second brief had to say so explicitly: remove the idea that pointers are excluded or stay uncommitted as a special rule.
What I’ll do differently
Ask whether the state is a decision. Before writing “the product commits X on the session’s behalf”, the check is: could a competent person doing this work reasonably choose either way? Move the pin or leave it? If yes, the product does not make that choice by reading the working tree. This applies to everything a tool might tidy up after an agent: lockfiles, version fields, generated indexes, pins. If reasonable people could disagree, it’s content, and the product isn’t an author.
Treat exceptions as a signal, not a backlog. A rule that needs “only when ahead”, then “reset when behind”, then “not when on another branch” is a rule guessing at intent. The third amendment should have gone to the operator as “should this be happening at all?” rather than being written as another clause. I extended the rule instead of questioning it, several times, and each extension made the question harder to see.
Don’t let git’s vocabulary define the goal. “Clean in git’s terms” is a tool’s view, not the requirement. The requirement was about not losing work. I should have gone back to that and asked what, concretely, was at risk of being lost. For a submodule with a clean tree, the answer was nothing.
Look at what the fix would make disappear. When the correct design deletes seven rules and their code, that is strong evidence the original rule was the problem rather than its edge cases. I should have noticed that the exceptions were multiplying and asked what single change would remove them.
Related things we’d already seen
This wasn’t the first pin-move incident. We’d previously had a day where a pointer moved on every landing and the remedy was about frequency and pipeline cost. We’d had a rejected redesign with a “descendant wins” rule for pins, and the operator’s correction that an agent’s only merge rule is “correctly merge these changes”. We’d had two pin moves silently advance a protocol version number with no implementing code behind them, and the fix was about where the number was read from rather than why the pins had moved. Each remedy addressed the symptom in front of it. None asked who should author a pin move. If any of them had, this one wouldn’t have happened, and I’d have caught the “descendant” condition when I carried it over from the rejected design into the product’s own code the same day.
The pattern across all of them is the same: automate toward a clean tree without asking whether each piece of state is someone’s decision, and extend a rule that keeps needing exceptions instead of asking whether it should exist. I’m writing this down so the next time I see a rule growing a ring of exceptions, I recognize it.