Repository navigation
feat(commit): fail on reference trailers citing unresolvable Lore-ids - #79
Merged
Merged
Conversation
lore commit now resolves every Supersedes / Depends-on / Related id against the repository's shared all-refs Lore-id index before creating the commit. A dangling id fails the commit (exit 1, nothing committed) with one batched validation error that merges format and resolution issues, so one retry fixes everything. Format errors gain actionable hints: a pasted git-hash shape (pure hex, length 7 or 9-64) and a case-only mistake (8-hex failing on case) each get a targeted sentence; resolution errors suggest near matches (Hamming distance <= 2, capped at 3). A --no-verify-refs flag is the explicit escape hatch for the rare legitimate case (an atom existing only on an unfetched branch); it skips only this check, not hooks. The gate is best-effort: a transient index-build failure (GitError) skips validation with a fixed warning, so "could not check" stays distinguishable from "check failed". Resolution semantics match lore trace exactly (all refs, HEAD-preferred), and the commit-msg validator's warning-severity reference-exists rule is unchanged. Rationale: the existing checking surfaces report after the fact at warning severity and demonstrably did not prevent 16 broken references in a production corpus; prevention belongs at the moment of creation. CHANGELOG.md is untouched (maintainer surface). Lore-id: 2d88edb7 Constraint: --no-verify-refs joins NON_INPUT_KEYS so --amend --no-edit never trips input-conflict detection Constraint: Best-effort catch is GitError-only; other failures propagate Constraint: CHANGELOG.md stays out of the PR; the maintainer authors changelog entries Tested: Command and service seams plus a real-git integration suite (hermetic temp-dir repo): a dangling id fails creating nothing (asserted via direct git rev-list --count), then the corrected id and the escape hatch each succeed Tested: Full gate on Windows: 36 files / 558 tests (baseline 512 at main), +46 tests Confidence: high Scope-risk: narrow
TommyC81
force-pushed
the
feat/commit-ref-validation
branch
from
November 7, 2026 13:52
5cc5fff to
3ed6294
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
lore commitnow resolves everySupersedes/Depends-on/Relatedid against the repository's shared Lore-id index before creating the commit. A dangling id fails the commit (exit 1, nothing committed) with one batched validation error; format errors and resolution errors merge into a single failure so one retry fixes everything. A--no-verify-refsflag is the explicit escape hatch. The gate is best-effort: a transient index-build failure skips validation with a warning rather than blocking the commit.Resolves #78.
Implementation
One commit, whose message carries the full design story. It was built and gated in four slices before squashing: (1) reference gate - resolution lives as methods on the atom repository (the index owner); the commit command receives the repository in its dependency bag exactly as the trace command does; unresolvable ids throw before the build, so nothing is committed. (2)
--no-verify-refs- commander-negated always-defined boolean; joinsNON_INPUT_KEYSso--amend --no-editnever trips input-conflict detection. (3) Merged batching + hints - format and reference issues merge into one error; two pinned hint sentences (git-hash shape: pure hex length 7 or 9-64; case-only mistake: 8-hex failing on case); near-match candidates (Hamming <= 2, index-order ties, cap 3);(trailer, id)dedup. (4) Best-effort + end-to-end proof -GitError-only catch emitting the fixed warning; interactive, unborn-HEAD, and unborn-HEAD-escape coverage; a real-git integration test drives the whole story on Windows.Design notes (pre-empting review questions)
--jsonunknown-key rejection): silent data loss is worse than a blocked commit. Scripts passing bad ids today are producing broken references;--no-verify-refsis their migration path.git's--no-verify. That flag skips hooks; this flag skips only the reference check. The project ships hooks, so the near-collision is worth this sentence.reference-existsrule stays warning-severity in this PR (unchanged); aligning checking-surface vocabulary is a separate doctor-side change we'd like to discuss (see the companion issue's downstream notes).rulefield in JSON errors. main.ts's JSON error mapping drops the rule name today (pre-existing, shared by all validation errors). A follow-up idea for scriptability; deliberately not touched here.tests/, so the non-optional options key cannot fail the main typecheck - the PR uses a scoped tsc as proof. An observation, not a fix; happy to discuss adding a tests tsconfig separately.Testing
36 files / 558 tests green on Windows (baseline 512 at main): +46 tests across the command seam, the repository service seam, and a new real-git integration suite (hermetic temp-dir git env: dangling id fails creating nothing - asserted via direct
git rev-list --count- then the corrected id and the escape hatch each succeed). Behavior pins are mutation-verified (replay-on-error, catch-type, ignored-flag, and gate-neutering mutants all turn the suite red).Changelog (maintainer surface)
This PR deliberately does not touch CHANGELOG.md; changelog entries are the maintainer's surface. Suggested line if wanted:
lore commitreference validation -Supersedes/Depends-on/RelatedLore-ids are now resolved against repository history before committing; a dangling id fails the commit with near-match suggestions instead of committing a broken link,--no-verify-refsskips the check, and a transient index build failure degrades to a fixed warning so "could not check" stays distinguishable from "check failed".