MemberJunction / MemberJunction/MJ
CodeGen drift gate: the new diff diagnostics print nothing when the drift is an untracked file
- Dominant language
- TSQL
- Stars
- 29
- Forks
- 6
- Avg merge
- 2d 1h
- Merged PRs (30d)
- 323
Description
## What happens
Both CodeGen drift gates detect drift with `git status --porcelain`, but explain it with `git diff`. Those two commands disagree about untracked files, so a whole class of drift fails the gate while printing no explanation at all.
Detection ([`integration.yml:715`](https://github.com/MemberJunction/MJ/blob/next/.github/workflows/integration.yml#L715), and again at `:859`):
```sh
git status --porcelain -- packages/ metadata/ migrations/ > /tmp/drift.txt
```
`git status --porcelain` lists untracked files as `?? path`. Explanation (added in #4372):
```sh
git diff --stat -- packages/ metadata/ migrations/ > /tmp/drift-stat.txt || true
git diff -- packages/ metadata/ migrations/ | head -c 100000 > /tmp/drift-diff.txt || true
```
`git diff` ignores untracked files entirely. So when the drift is a newly emitted file, the log reads:
```
::error::CodeGen output DIFFERS from committed artifacts (drift). Files:
?? packages/.../some-new-file.ts
--- change shape ---
--- first 100KB of diff ---
```
Two empty headings. That reads like the diagnostic is broken rather than like an explanation of the failure, which is the opposite of what #4372's second commit set out to achieve.
## Why this case is real, not hypothetical
The gate already knows CodeGen leaves untracked files behind — four lines above the detection there is a dedicated sweep for exactly that:
```sh
git ls-files --others --exclude-standard -- migrations/ \
| grep -E '/CodeGen_Run_[^/]*\.sql$' | xargs -r rm -f || true
```
That sweep removes only `CodeGen_Run_*.sql`. Any other untracked artifact — a generated subclass for a new entity, a new metadata file — survives to `drift.txt` and lands in this gap.
## Fix
One line before the diffs. `-N` records intent-to-add, so untracked files show up in `git diff` as additions without staging their content:
```sh
git add -A -N -- packages/ metadata/ migrations/ || true
```
Needs to go in both copies: the daily gate (~`:723`) and the weekly AI gate (~`:867`).
## Origin
Found reviewing #4372. Diagnostics only — no effect on whether the gate passes or fails.
Contributor guide
Research direction
Read the two CodeGen drift-gate blocks in .github/workflows/integration.yml around lines 715–723 and 859–867. Check how the existing git status and git diff diagnostics handle an untracked generated artifact, then make both copies report its change shape and content without changing the gate result. Done means an untracked file produces non-empty diagnostic output in both gates.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- git, github-actions, shell
- Domain
- ci-cd, devops
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 90/100