[agent/codex:gpt-5.4-mini] Read ~/spec/code/core/go/i18n/RFC.md fully. Find features de... #151

Merged
Virgil merged 1 commit from agent/read---spec-code-core-go-i18n-rfc-md-ful into dev 2026-04-02 07:20:48 +00:00
2 changed files with 73 additions and 2 deletions

View file

@ -351,13 +351,49 @@ func loadSignalPriors(grammar *GrammarData, priors map[string]any) {
grammar.Signals.Priors[key] = make(map[string]float64, len(bucket))
}
for role, value := range bucket {
if score := toFloat64(value); score != 0 {
grammar.Signals.Priors[key][core.Lower(role)] = score
score, ok := float64Value(value)
if !ok {
continue
}
grammar.Signals.Priors[key][core.Lower(role)] = score
}
}
}
func float64Value(v any) (float64, bool) {
if v == nil {
return 0, false
}
switch n := v.(type) {
case float64:
return n, true
case float32:
return float64(n), true
case int:
return float64(n), true
case int64:
return float64(n), true
case int32:
return float64(n), true
case int16:
return float64(n), true
case int8:
return float64(n), true
case uint:
return float64(n), true
case uint64:
return float64(n), true
case uint32:
return float64(n), true
case uint16:
return float64(n), true
case uint8:
return float64(n), true
default:
return 0, false
}
}
func shouldSkipDeprecatedEnglishGrammarEntry(fullKey string) bool {
switch fullKey {
case "gram.noun.passed", "gram.noun.failed", "gram.noun.skipped",

View file

@ -624,3 +624,38 @@ func TestCustomFSLoader(t *testing.T) {
t.Errorf("signal priors not loaded correctly: %+v", gd.Signals.Priors["draft"])
}
}
func TestCustomFSLoaderPreservesZeroSignalPriors(t *testing.T) {
fs := fstest.MapFS{
"locales/test.json": &fstest.MapFile{
Data: []byte(`{
"gram": {
"signal": {
"prior": {
"commit": { "verb": 0, "noun": 1 }
}
}
}
}`),
},
}
loader := NewFSLoader(fs, "locales")
_, grammar, err := loader.Load("test")
if err != nil {
t.Fatalf("Load(test) failed: %v", err)
}
if grammar == nil {
t.Fatal("expected grammar data")
}
bucket, ok := grammar.Signals.Priors["commit"]
if !ok {
t.Fatal("signal priors for commit were not loaded")
}
if got := bucket["verb"]; got != 0 {
t.Fatalf("signal priors verb = %v, want 0", got)
}
if got := bucket["noun"]; got != 1 {
t.Fatalf("signal priors noun = %v, want 1", got)
}
}