You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Protobuf pattern set in SymbolExtractor.cs has four coverage problems on a real .proto corpus:
enum X is indexed as class kind, not enum kind. Protobuf has first-class enum declarations (e.g. enum Severity { ... }) but the extractor maps them to class. On googleapis (the canonical Protobuf corpus, 6,800 .proto files), symbols --kind enum --lang protobuf returns 0 rows despite 5,815 enum declarations in source.
package X.Y.Z is not captured at all. The package declaration is the canonical namespace concept in Protobuf (it determines the generated language's namespace/module path) and there is no regex for it. 6,932 package X.Y.Z lines on googleapis → 0 namespace symbols.
oneof X { ... } declarations inside messages are never captured.oneof is the union-type primitive in Protobuf (used heavily in google.protobuf.Value, polymorphic API designs, etc.). 2,572 chunk-hits on googleapis → 0 symbols.
extend X { ... } declarations are never captured. Used for proto2 message extensions and for FileOptions / FieldOptions / etc. in many Google APIs. 52 chunk-hits on googleapis → 0 symbols.
Same family as #155 / #165 / #166 / #167 / #168 / #169 / #171 — per-line regex list missing common language constructs.
Repro
curl -fsSL https://raw.githubusercontent.com/Widthdom/CodeIndex/main/install.sh | bash
CDIDX=/root/.local/bin/cdidx
mkdir -p /tmp/srcs &&cd /tmp/srcs
curl -fsSL -o googleapis.tar.gz https://codeload.github.com/googleapis/googleapis/tar.gz/refs/heads/master
tar xzf googleapis.tar.gz
"$CDIDX" /tmp/srcs/googleapis-master/google --db /tmp/proto.db
# → 6,800 .proto files, 90,382 symbols# Kinds:# class 54541# import 23138# function 12703# (no enum, no namespace)
1. enum mis-kinded as class
"$CDIDX" symbols --db /tmp/proto.db --lang protobuf --kind enum --limit 3
# → No symbols found.# Hint: no 'enum' symbols in the index. Indexed kinds: class, function, import"$CDIDX" symbols "Severity" --db /tmp/proto.db --lang protobuf --exact --limit 3
# class Severity api/expr/conformance/v1alpha1/conformance_service.proto:160-173# class Severity cloud/apihub/v1/common_fields.proto:64-79# class Severity cloud/bigquery/migration/v2/translation_suggestion.proto:32-45
Severity is a Protobuf enum — the indexer's vocabulary already has an enum kind (used for C / C++ / C# / Java / Rust / Swift / Kotlin / etc.) but the protobuf pattern hard-codes class.
2. package not captured
"$CDIDX" symbols --db /tmp/proto.db --lang protobuf --kind namespace --limit 3
# → No symbols found.# Hint: no 'namespace' symbols in the index.
Despite essentially every .proto file starting with a package line:
Source like package google.api; — the canonical namespace concept in Protobuf — never enters the symbol index.
3. oneof not captured
grep -RcE '^\s+oneof\s+\w+\s*\{' /tmp/srcs/googleapis-master/google | head -3
# 2,572 chunk-hits across the corpus"$CDIDX" symbols "kind" --db /tmp/proto.db --lang protobuf --exact --limit 3
# (returns no `oneof kind` rows; only message/enum/service rows that share the name)
oneof kind is a structural element of Value. AI consumers asking "what are the variants of Value?" get only the field references in the chunk text, not a structured oneof kind symbol.
Especially common in API metadata files (google/api/annotations.proto, google/api/client.proto, etc.) where the extension pattern attaches custom options to FieldOptions / MethodOptions.
Root cause
src/CodeIndex/Indexer/SymbolExtractor.cs:338-345:
["protobuf"]=[new("class",newRegex(@"^\s*message\s+(?<name>\w+)",RegexOptions.Compiled),BodyStyle.Brace),new("class",newRegex(@"^\s*enum\s+(?<name>\w+)",RegexOptions.Compiled),BodyStyle.Brace),// ← should be "enum"new("class",newRegex(@"^\s*service\s+(?<name>\w+)",RegexOptions.Compiled),BodyStyle.Brace),new("function",newRegex(@"^\s*rpc\s+(?<name>\w+)",RegexOptions.Compiled),BodyStyle.None),new("import",newRegex(@"^\s*import\s+""(?<name>[^""]+)"";",RegexOptions.Compiled),BodyStyle.None),],
Line 341 hard-codes class for enum. Should be enum.
No package regex.
No oneof regex.
No extend regex.
Optional polish: service X could be interface instead of class — services in Protobuf are RPC interface contracts, semantically closer to interface than class. Lower priority than the four primary fixes.
Why it matters
symbols --kind enum --lang protobuf is empty across every .proto corpus. AI consumers using kind-based exploration get an incorrect picture: it looks like Protobuf has no enums at all.
symbols --kind namespace --lang protobuf is empty. No package declarations means no way to query "show me the namespace structure of this proto API surface." map and inspect lose top-level structural signal.
oneof invisibility breaks polymorphic API understanding.google.protobuf.Value, google.protobuf.Any, google.api.HttpRule and many gRPC streaming types are designed around oneof. Missing them means an AI consumer can't see "what are the alternatives" for any union-typed message.
extend invisibility breaks API option / annotation exploration. Anyone exploring google.api.http, google.api.method_signature, google.api.client.default_host won't see the extend blocks that declare them.
Mis-kinded enum pollutes --kind class. 5,815 fake "classes" on googleapis dominate the class list, making it hard for AI consumers to find real message-kinded "classes."
Silent. No warning, no degraded-confidence signal.
Suggested direction
Four additive / reclassification fixes; all one-line:
Add oneof pattern. Kind choice: class (matches Protobuf's "structural unit" feel) or enum (it's a tagged union / variant, semantically closer to enum). I lean class to mirror message:
src/CodeIndex/Indexer/ReferenceExtractor.cs — verify whether the protobuf reference pass picks up cross-package / cross-file references; if it relies on the package symbol's existence, this fix should improve references / deps for protobuf.
tests/CodeIndex.Tests/SymbolExtractorTests.cs — fixtures for: (a) enum Severity { ... } captured as enum kind, (b) package google.api; captured as namespace, (c) nested oneof kind { ... } inside a message captured, (d) extend google.protobuf.FieldOptions { ... } captured, (e) service Greeter { rpc SayHello(...) returns (...); } continues to capture both the service and the rpc.
Same family: per-line regex list misses common language constructs and is silent about it. Protobuf's package / enum kind / oneof are unambiguous one-line fixes.
Summary
The Protobuf pattern set in
SymbolExtractor.cshas four coverage problems on a real.protocorpus:enum Xis indexed asclasskind, notenumkind. Protobuf has first-classenumdeclarations (e.g.enum Severity { ... }) but the extractor maps them toclass. On googleapis (the canonical Protobuf corpus, 6,800.protofiles),symbols --kind enum --lang protobufreturns 0 rows despite 5,815enumdeclarations in source.package X.Y.Zis not captured at all. The package declaration is the canonical namespace concept in Protobuf (it determines the generated language's namespace/module path) and there is no regex for it. 6,932package X.Y.Zlines on googleapis → 0 namespace symbols.oneof X { ... }declarations inside messages are never captured.oneofis the union-type primitive in Protobuf (used heavily in google.protobuf.Value, polymorphic API designs, etc.). 2,572 chunk-hits on googleapis → 0 symbols.extend X { ... }declarations are never captured. Used for proto2 message extensions and for FileOptions / FieldOptions / etc. in many Google APIs. 52 chunk-hits on googleapis → 0 symbols.Same family as #155 / #165 / #166 / #167 / #168 / #169 / #171 — per-line regex list missing common language constructs.
Repro
1.
enummis-kinded asclassSource at
conformance_service.proto:160:Severityis a Protobufenum— the indexer's vocabulary already has anenumkind (used for C / C++ / C# / Java / Rust / Swift / Kotlin / etc.) but the protobuf pattern hard-codesclass.2.
packagenot capturedDespite essentially every
.protofile starting with apackageline:Source like
package google.api;— the canonical namespace concept in Protobuf — never enters the symbol index.3.
oneofnot capturedSpot-check on
google/protobuf/struct.proto:oneof kindis a structural element ofValue. AI consumers asking "what are the variants of Value?" get only the field references in the chunk text, not a structuredoneof kindsymbol.4.
extendnot capturedEspecially common in API metadata files (
google/api/annotations.proto,google/api/client.proto, etc.) where the extension pattern attaches custom options to FieldOptions / MethodOptions.Root cause
src/CodeIndex/Indexer/SymbolExtractor.cs:338-345:classforenum. Should beenum.packageregex.oneofregex.extendregex.service Xcould beinterfaceinstead ofclass— services in Protobuf are RPC interface contracts, semantically closer tointerfacethanclass. Lower priority than the four primary fixes.Why it matters
symbols --kind enum --lang protobufis empty across every.protocorpus. AI consumers using kind-based exploration get an incorrect picture: it looks like Protobuf has no enums at all.symbols --kind namespace --lang protobufis empty. Nopackagedeclarations means no way to query "show me the namespace structure of this proto API surface."mapandinspectlose top-level structural signal.oneofinvisibility breaks polymorphic API understanding.google.protobuf.Value,google.protobuf.Any,google.api.HttpRuleand many gRPC streaming types are designed aroundoneof. Missing them means an AI consumer can't see "what are the alternatives" for any union-typed message.extendinvisibility breaks API option / annotation exploration. Anyone exploringgoogle.api.http,google.api.method_signature,google.api.client.default_hostwon't see theextendblocks that declare them.--kind class. 5,815 fake "classes" on googleapis dominate the class list, making it hard for AI consumers to find realmessage-kinded "classes."Suggested direction
Four additive / reclassification fixes; all one-line:
Re-kind
enumfromclasstoenum:Add
packagepattern asnamespace:Add
oneofpattern. Kind choice:class(matches Protobuf's "structural unit" feel) orenum(it's a tagged union / variant, semantically closer to enum). I leanclassto mirror message:Add
extendpattern:(Optional polish) Re-kind
servicefromclasstointerface:Mirrors how Java/C# extractors treat interface declarations.
Expected impact after fix
On
/tmp/srcs/googleapis-master/google:symbols --kind enum --lang protobuf --countrises from 0 to 5,815.symbols --kind namespace --lang protobuf --countrises from 0 to 6,932.symbols --kind class --lang protobuf --countdrops by ~5,815 (the re-kinded enums) and gains some fromoneof/extend(smaller).inspecton aoneof's containing message starts showing the oneof's structure.Scope
src/CodeIndex/Indexer/SymbolExtractor.cs— re-kind enum, add package / oneof / extend patterns, optionally re-kind service.src/CodeIndex/Indexer/ReferenceExtractor.cs— verify whether the protobuf reference pass picks up cross-package / cross-file references; if it relies on thepackagesymbol's existence, this fix should improvereferences/depsfor protobuf.tests/CodeIndex.Tests/SymbolExtractorTests.cs— fixtures for: (a)enum Severity { ... }captured as enum kind, (b)package google.api;captured as namespace, (c) nestedoneof kind { ... }inside a message captured, (d)extend google.protobuf.FieldOptions { ... }captured, (e)service Greeter { rpc SayHello(...) returns (...); }continues to capture both the service and the rpc.Related
if/for/while/switchblocks as function definitions #154 — JS/TS keyword false positives.import ( ... )blocks leak(as a symbol name, individual imports never captured, and single-line imports swallow trailing comments #155 — Go import block coverage collapse.use function X\Y\Zcaptures "function",require $variablecaptures the whole expression, group-use and aliases are lost #162 — PHP import extraction gaps.else if,case const Class()etc. asfunction if/function Class— negative lookahead missingelse/case/ more #163 — Dart else-if /case const Class()false positives.namespacedropped,module X.Y.Zmiscategorized asclass, andmember this.Foo = ...methods never captured #165 — F# namespace/module/member missing.Namespace Xnever captured, and all class/sub/function regexes require explicit visibility so unmodified declarations silently drop #166 — VB.NET namespace + visibility coverage.:=/::=variable assignments as targets (and ignores%-pattern rules entirely) #167 — Makefile:=variables and%patterns.@functiondeclarations never captured, compound/nested selectors miss everything after the first class,@forwardnot recognized as import #168 — SCSS@function/@forward/ compound selectors.impl Trait for Structcaptures the trait name as aclass(hundreds of fakeclass Future/class From/class Defaultrows on tokio), andunsafe impl ... for ...is dropped entirely #169 — Rustimpl Trait for Structmis-captures andunsafe impldropped..kts(Kotlin Script / Gradle Kotlin DSL) files are silently skipped —LangMaphas.ktbut no.kts, so everybuild.gradle.kts/settings.gradle.ktsis invisible #170 —.kts(Gradle Kotlin DSL) silently skipped.fragment X on Ynever captured (426 misses on graphql-platform),directive @Xnever captured,extendonly handlesextend type#171 — GraphQLfragment/directive/extendcoverage.Same family: per-line regex list misses common language constructs and is silent about it. Protobuf's
package/enum kind/oneofare unambiguous one-line fixes.Environment
install.sh).googleapis/googleapis@master— 6,800.protofiles, 5,815 enum declarations, 6,932 package declarations, 2,572oneofchunk-hits, 52extendchunk-hits.CLOUD_BOOTSTRAP_PROMPT.md.