/garden-search

Infrastructure L2+ Production low usage

/garden-search

Overview

/garden-search is a production command in the Infrastructure category of the Prismatic Platform that performs fast, full-text pattern search across all GARDEN (Growing Archive of Reusable Development and Engineering Nuggets) reference repositories. While /garden-explore provides structured navigation of the GARDEN ecosystem, /garden-search is optimized for targeted discovery -- finding specific patterns, function signatures, module names, or code constructs across 116 repositories containing 3,050+ files in a single operation.

The command operates under the L2+ authority level and is executed by the garden-explorer agent. It is part of the platform's 216-command slash command registry, built on the AIAD (Autonomous Intelligence Agent Design) standard. The garden-explorer agent leverages ripgrep-based indexing for sub-second search performance across the entire GARDEN corpus, making it practical to search the full 20+ year archive as part of routine development workflows.

The distinction between /garden-search and standard code search tools (like grep or IDE search) is scope and context. Standard search operates within the active repository. /garden-search extends the search boundary to encompass the entire GARDEN ecosystem -- 116 repositories that may contain solutions to problems that have already been solved in previous projects. This cross-repository search capability transforms the GARDEN from a passive archive into an active knowledge base that surfaces relevant precedent at the moment it is needed.

Search results are annotated with repository tier information (T1 through T5), file modification dates, and pattern classification metadata when available. This contextual enrichment enables operators to quickly assess the relevance and quality of each match without needing to manually inspect each file.

Architecture

The search system is built on a three-tier architecture optimized for speed and relevance.

Search Query --> Query Parser --> Search Engine --> Result Ranker --> Presenter
                     |                |                  |              |
                 Regex/Glob      ripgrep-based       Tier-weighted   Formatted
                 Expansion       Index Search        Relevance       Output
                                      |
                              GARDEN Index Cache
                              (ETS, ~80ms refresh)

Search Components

ComponentTechnologyResponsibility
Query ParserCustomParses search terms, regex patterns, and filter expressions
Search Engineripgrep + ETS indexFull-text search with regex support across all repositories
Index CacheETSPre-indexed file metadata for sub-second search on 3,050+ files
Result RankerCustomTier-weighted relevance scoring with recency boost
PresenterCustomFormats results with context lines, repository info, and tier badges

Search Index Structure

The search index is maintained as an ETS table with the following schema:

FieldTypePurpose
file_pathstringFull path within the GARDEN submodule
repo_namestringRepository name
repo_tieratomT1 through T5 classification
languageatomFile language (elixir, python, javascript, etc.)
last_modifiedDateTimeFile modification timestamp
pattern_tagslist(string)Extracted pattern tags from file content
content_hashbinarySHA-256 hash for change detection

Usage

Basic Usage

# Search for a term across all GARDEN repositories
/garden-search "GenServer"

# Search with regex pattern
/garden-search "def\s+handle_call"

# Search for a specific function name
/garden-search "fetch_results" --exact

# Search with file type filter
/garden-search "provider" --type elixir
# Search only in T1 production repositories
/garden-search "blackboard" --tier t1

# Search in a specific repository
/garden-search "websocket" --repo crisstal

# Search with language filter
/garden-search "async def" --lang python

# Search only in recently modified files
/garden-search "cache" --since 2025-01-01
# Search for module definitions matching a pattern
/garden-search "defmodule.*Provider" --type elixir

# Search for OTP behavior implementations
/garden-search "use GenServer" --type elixir --context 5

# Search for test patterns
/garden-search "describe.*integration" --type elixir --file-pattern "*_test.exs"

# Search with multiple terms (AND logic)
/garden-search "GenServer" --and "handle_info" --and "timeout"

Options & Parameters

OptionTypeDefaultDescription
QUERYstringrequiredSearch term or regex pattern
--exactbooleanfalseMatch exact string (disable regex)
--typestringallFile type filter: elixir, python, javascript, rust, go, markdown
--langstringallAlias for --type
--tierstringallRepository tier filter: t1, t2, t3, t4, t5
--repostringallSearch within a specific repository
--contextinteger2Number of context lines around each match
--sincedatenoneOnly search files modified after this date
--file-patternstringallGlob pattern to filter file names
--andstringnoneAdditional term that must also match (AND logic)
--max-resultsinteger50Maximum number of results to return
--formatstringrichOutput format: rich, plain, json, paths-only
--case-sensitivebooleanfalseEnable case-sensitive matching
--verify-integrationstringnoneVerify that a pattern has been integrated into the platform

Execution Flow

  1. Query Parsing: Parse the search query, expanding regex metacharacters and applying escape rules. If --exact is specified, the query is treated as a literal string.

  2. Scope Resolution: Determine the search scope based on filters (--tier, --repo, --type, --since). Build the list of files to search from the ETS index.

  3. Index Freshness Check: Verify the ETS index is current. If stale, trigger an incremental re-index of modified files. The index refresh typically completes in under 80ms.

  4. Search Execution: Execute the search using ripgrep against the resolved file list. ripgrep's SIMD-accelerated search ensures sub-second performance even for complex regex patterns across thousands of files.

  5. Result Collection: Collect matches with context lines, file metadata, and repository information.

  6. Relevance Ranking: Apply tier-weighted relevance scoring. T1 results receive a 5x boost, T2 receives 3x, T3 receives 2x, T4 receives 1x, and T5 receives 0.5x. Recent modifications receive an additional recency boost.

  7. Deduplication: Remove duplicate matches that appear in multiple branches or copies of the same file across repositories.

  8. Presentation: Format and display results with syntax highlighting, tier badges, and context lines.

Integration Points

ComponentIntegration TypeDescription
Prismatic AgentsExecutionInvoked by garden-explorer agent
GARDEN EcosystemData SourceSearches across all 116 GARDEN repositories
/garden-exploreComplementaryStructured exploration complements text search
/garden-extractWorkflowSearch results identify extraction targets
/garden-syncPrerequisiteSync ensures search index covers latest content
/gardenerParentGardener provides top-level GARDEN management
TelemetryMetricsSearch queries and result counts tracked
Git TreesPerformanceUses git-tree enumeration for file discovery

Best Practices

Use regex for pattern discovery, exact match for known targets. When searching for a specific function or module name, use --exact to avoid false matches from regex metacharacters. When exploring for patterns or conventions, regex provides the flexibility needed to discover variations.

Filter by tier for quality-focused searches. When seeking production-ready implementations to extract, filter to T1 and T2 repositories. When performing archaeological research into how a problem was previously approached, include T4 and T5.

Combine with context lines for understanding. Use --context 5 or higher to see surrounding code that provides implementation context. A bare match line often lacks the context needed to understand the pattern.

Use AND logic for precise multi-term searches. The --and option narrows results to files containing all specified terms, which is more effective than manually intersecting multiple search results.

Pipe results to extraction for automated workflows. Use --format paths-only to get a list of files that can be piped to other tools or used as input for /garden-extract.

Error Handling

ErrorCauseResolution
{:error, :invalid_regex}Search query contains invalid regex syntaxFix the regex pattern or use --exact for literal search
{:error, :no_results}No matches found for the queryBroaden the search by removing filters or using a less specific pattern
{:error, :index_stale}GARDEN index is outdatedRun /garden-sync to refresh the index
{:error, :repo_not_found}Specified --repo does not existCheck repository name spelling
{:error, :ripgrep_unavailable}ripgrep binary not foundInstall ripgrep: brew install ripgrep or cargo install ripgrep
{:error, :submodule_missing}One or more GARDEN submodules not initializedRun git submodule update --init --recursive garden/

Advanced Usage

Integration Verification

Verify that an extracted pattern is properly integrated into the platform:

# Check if the OSINT provider pattern from sig is integrated
/garden-search --verify-integration osint-provider

# Output shows:
# Source: garden/sig/lib/providers/base.ex
# Target: apps/prismatic_agents/lib/providers/base.ex
# Status: INTEGRATED (95% pattern match)
# Divergence: Target has additional error handling (expected evolution)

Cross-Repository Pattern Analysis

# Find all implementations of a specific pattern across repositories
/garden-search "defmodule.*Blackboard" --type elixir --format json | \
  jq 'group_by(.repo) | map({repo: .[0].repo, count: length})'

# Find technology migration examples (Python -> Elixir)
/garden-search "def fetch" --lang python --repo sig --format paths-only
/garden-search "def fetch" --lang elixir --repo sig --format paths-only

Search-Driven Development

Use GARDEN search as a starting point for new feature development:

# Research how rate limiting was implemented historically
/garden-search "rate_limit" --context 10 --tier t1,t2

# Find all event handling patterns
/garden-search "handle_event\|handle_info\|handle_cast" --type elixir --context 3

Doctrine Compliance

All commands operate under the NO MERCY, NO DOUBTS doctrine:

  • NO MERCY: Zero tolerance for incomplete execution or quality violations. Search results are always complete within the specified scope -- no partial results are returned due to timeouts or errors.
  • NO DOUBTS: Full investigation before action, evidence-based results. Search results include sufficient context (tier, language, modification date, context lines) to make evidence-based decisions about extraction and integration.

The command supports NABLA signal plurality by surfacing all matching implementations across the ecosystem, ensuring that decisions about pattern extraction are informed by the full range of available evidence rather than a single implementation.

  • /gardener - GARDEN legacy knowledge repository management across 116 repos
  • /garden-explore - Explore GARDEN repositories for patterns and knowledge
  • /garden-extract - Extract and integrate patterns from GARDEN repositories
  • /garden-sync - Synchronize GARDEN submodules to latest remote commits
  • /investigate - Launch comprehensive OSINT investigation across 121+ sources
  • /git-trees - Git tree-based codebase exploration at ~100x speed improvement

Connect & Contribute

Created by Tomáš Korcak (korczis) | Open Source under GHL