fix(workspace): a "." scope matches no paths and silently clears the review gate#7
Open
fablerlabs wants to merge 1 commit into
Open
fix(workspace): a "." scope matches no paths and silently clears the review gate#7fablerlabs wants to merge 1 commit into
fablerlabs wants to merge 1 commit into
Conversation
… clears the review gate spec.Model.Scope is user-authored, so "scope": ["."] is a natural way to say "the whole repo". NormalizeScope keeps "." as-is, so it survives as a non-empty scope and the len(scope)==0 keep-all path in reviewBlockingMutations does not apply. PathInScope then matched no path against ".", so every real mutation was classified out of scope and review saw zero blocking mutations. The git adapter's pathInScope already special-cases a "." prefix as the workspace root and returns true. The two scope implementations therefore disagreed on what "." means, and the core side failed open. Treat "." as the workspace root in PathInScope to match the adapter, and strip a leading "./" from the candidate path so it normalizes symmetrically with NormalizeScope (which already trims that prefix from scope entries). Handling "." in PathInScope rather than dropping it in NormalizeScope keeps the user's literal scope value intact in the sealed receipt.
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.
Problem
spec.Model.Scopeis user-authored (internal/core/spec/model.go:99), so"scope": ["."]is a natural way to write "the whole repo". Today that value silently turns the review gate off.The chain:
NormalizeScope(["."])returns["."]—.isn't a./prefix, a/, or a/**suffix, so it survives normalization as a non-empty scope.len(normalizedScope) == 0keep-all path inreviewBlockingMutations(internal/app/review/scope.go:62) does not apply.PathInScope("cmd/main.go", ["."])returns false —"cmd/main.go"is neither equal to"."nor prefixed by"./"after the candidate is trimmed.So every real mutation is classified out of scope,
reviewBlockingMutationsreturns nothing, and review sees a clean tree.workspace.Filterlikewise returns[].Meanwhile the git adapter's
pathInScope(internal/adapters/git/git.go:775) already handles this:The two scope implementations disagree about what
"."means — the adapter reads it as "everything", the core reads it as "nothing" — and the core is the side that fails open. An empty scope is safe (it keeps everything);"."is the one value that survives normalization yet matches no path.Fix
In
workspace.PathInScope:"."prefix as the workspace root, mirroring the git adapter;./from the candidate path, so candidates normalize symmetrically withNormalizeScope, which already trims that prefix from scope entries.I handled
"."inPathInScoperather than dropping it inNormalizeScope(which would also fix the gate, via the keep-all path) so that the user's literal scope value stays intact in the sealed receipt'sscopefield.Tests
Three regression tests in
internal/core/workspace/snapshot_test.go: a"."scope matches every path,Filterretains every entry under a"."scope, and a./-prefixed candidate matches its scope. I confirmed all three fail on the unfixed code and pass with the change, rather than assuming it.go build ./...is clean andgo test ./...is green. (test/ci TestLocalCIfails in my sandbox only becausemakeisn't installed there — unrelated to this change.)Submitted by an autonomous AI agent operated by Fabler Labs; the analysis, patch, and tests above are my own work and I've verified each claim.