generator: warn when the manifest indexes files git does not track

Regenerating the function manifest indexes what is on disk, which is
correct. The hazard is committing the result: an entry for a file git does
not have installs an autoload stub on every other clone, and the first call
to it unsets the stub, fails to source a file that is not there, and dies
with "command not found".

Easy to cause without noticing, and easy to cause repeatedly when more than
one person is working in the same tree — somebody else's in-progress file
is sitting under scripts/ whenever you happen to regenerate. It has already
happened twice today: once picking up a vendored dev helper, once picking
up an uncommitted validator.

Warn rather than skip. The scan is right to index them, and mid-work is a
normal state for a tree to be in; what is not fine is committing it. The
warning names the files, so the choice is obvious either way — commit them
alongside, or drop their entries first.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
librelad 2026-08-19 00:18:32 +01:00
parent f747083115
commit e73f47ad46

View File

@ -305,6 +305,27 @@ isSuccessful "Wrote $(realpath --relative-to="$SCRIPTS_DIR" "$OUTPUT")"
isNotice "Scanned $total_files files, indexed $total_fns function definitions"
isNotice "${#eager_files[@]} files flagged eager (will always source)"
# Untracked sources: warn before the manifest goes anywhere.
#
# The scan indexes what is on disk, which is correct. The hazard is committing
# the result: an entry for a file git does not have installs a stub on every
# other clone, and the first call to it unsets the stub, fails to source a file
# that is not there, and dies with "command not found". Easy to cause without
# noticing — several people working in one tree means someone else's in-progress
# file is sitting in scripts/ whenever you happen to regenerate.
#
# Just a warning: the scan is right to index them, and mid-work is a perfectly
# normal state for the tree to be in. What is not fine is committing it.
if command -v git >/dev/null 2>&1 && git -C "$SCRIPTS_DIR" rev-parse --git-dir >/dev/null 2>&1; then
_untracked=$(git -C "$SCRIPTS_DIR" ls-files --others --exclude-standard -- '*.sh' 2>/dev/null)
if [[ -n "$_untracked" ]]; then
isNotice "Indexed files git does not track yet:"
printf ' %s\n' $_untracked
isNotice " Commit them with this manifest, or drop their entries before committing —"
isNotice " an entry for a file others do not have breaks on first call."
fi
fi
# Collisions: report so they can be audited. The manifest reflects last-write-
# wins, which matches the existing eager-load semantics, so behaviour is
# identical — the warnings are about *avoidable* fragility, not bugs.