gcfg: Report subsections through ReadWithOptions #19
All Vouch review confidence checks passed
Residual risk 0.20 = Change Risk (0.46) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.46 · 461 lines diff across 5 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.367
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #19"
general
weight: 0.35
pjbgf
ReadWithCallbackpasses""as the subsection for both[x]and[x ""], so a consumer cannot tell Git'sx.keyfromx..key(git config -lprintsx.aandx..afor the two headers). go-git foldsprotocol..allowontoprotocol.allowbecause of this, so a key Git never consults for the protocol policy takes effect asprotocol.allow(go-git/go-git#2403).Changes
ReadWithOptionstakesReadOptionvalues and reports each section header and option as anEvent.Event.HasSubsectionis true for[x ""]and for a legacy[x.y]header, false for[x]. It describes the header being read, so option lines carry it as well, and it resets at every header. A consumer rebuilds Git's key asx..keyorx.keyfrom it.Event.Positionis atoken.Position, the module's existing position type, with the 1-basedLineandColumnof the header's[or of the option key, so a consumer can report where it refused something.WithCallbacksets the callback. It is optional: without itReadWithOptionsonly parses the data, reports no events and returns the same errors as a callback that ignores them, which checks syntax.ReadWithCallbackkeeps its signature and wrapsReadWithOptions.ReadIntoand the otherRead*Intofunctions behave as before.ReadWithSubsectionCallback, which took six positional arguments, two of thembool, so a caller could swap them and still compile. The named fields ofEventfix that, and options leave room to add more without another signature change. That function was never released, so it is gone.ReadWithCallbacksays that[x ""]reports like[x]and points toReadWithOptions.ReadIntosays it keeps folding[sec ""]onto[sec], because a struct target cannot representsec..key, and that a caller applying a policy keyed on a subsection must useReadWithOptions.doc.gois updated to match.Behaviour changes
None for existing callers. This adds exported API, so it needs a minor release.
ReadIntostill folds[sec ""]onto[sec]. That is not new, and it is a conscious choice: refusing it would break v2 callers, and the fold is now documented.Dependencies
#18, which handles the legacy
[section.subsection]header, is merged. go-git/go-git#2558 (open) adds go-git's own use of it inplumbing/format/config/legacy.go, which is not on go-gitmainyet. go-git/go-git#2403 usesReadWithOptionsto refuse[protocol ""]and needs this released before it can drop a temporaryreplace.For go-git
go-git can refuse a header with
HasSubsection && Subsection == ""in its decoder, instead of the rewrite and fail-closed trick. ItsSectionandSubsectiontypes carry only a name, so that check stays in go-git's decoder.Testing
Table tests cover
[a.b],[a "b"],[a ""]and[a], the flag on option lines, the reset ([x "y"], then[z], then[x]; the test fails without the reset), the old callbacks being unchanged, and[x.]still being refused.TestReadWithOptionsPositioncovers a header and keys on several lines, indented ones, comments and blank lines, and a legacy header.TestReadWithOptionsWithoutCallbackcompares a read without options to one with a no-op callback on valid and invalid input. Output was checked againstgit config -l.go vetandgo test ./...pass.Release note
gcfg: add
ReadWithOptionsandWithCallback. The callback receives anEventthat reports, viaHasSubsection, whether a header had a subsection, so[x]and[x ""]can be told apart, and, viaPosition, where the header or option is.