|
| 1 | +# IMPORTANT: Source Code Access |
| 2 | + |
| 3 | +**Local source files are not present.** Your workspace does not contain source code. You **MUST** use Sourcegraph MCP tools to discover, read, and understand code before making any changes. |
| 4 | + |
| 5 | +**Target Repository:** `github.com/sg-benchmarks/flipt--3d5a345f` |
| 6 | +- Use `repo:^github.com/sg-benchmarks/flipt--3d5a345f$` filter in keyword_search |
| 7 | +- Use `github.com/sg-benchmarks/flipt--3d5a345f` as the `repo` parameter for go_to_definition/find_references/read_file |
| 8 | + |
| 9 | + |
| 10 | +## Required Workflow |
| 11 | + |
| 12 | +1. **Search first** — Use MCP tools to find relevant files and understand existing patterns |
| 13 | +2. **Read remotely** — Use `sg_read_file` to read full file contents from Sourcegraph |
| 14 | +3. **Edit locally** — Use Edit, Write, and Bash to create or modify files in your working directory |
| 15 | +4. **Verify locally** — Run tests with Bash to check your changes |
| 16 | + |
| 17 | +## Tool Selection |
| 18 | + |
| 19 | +| Goal | Tool | |
| 20 | +|------|------| |
| 21 | +| Exact symbol/string | `sg_keyword_search` | |
| 22 | +| Concepts/semantic search | `sg_nls_search` | |
| 23 | +| Trace usage/callers | `sg_find_references` | |
| 24 | +| See implementation | `sg_go_to_definition` | |
| 25 | +| Read full file | `sg_read_file` | |
| 26 | +| Browse structure | `sg_list_files` | |
| 27 | +| Find repos | `sg_list_repos` | |
| 28 | +| Search commits | `sg_commit_search` | |
| 29 | +| Track changes | `sg_diff_search` | |
| 30 | +| Compare versions | `sg_compare_revisions` | |
| 31 | + |
| 32 | +**Decision logic:** |
| 33 | +1. Know the exact symbol? → `sg_keyword_search` |
| 34 | +2. Know the concept, not the name? → `sg_nls_search` |
| 35 | +3. Need definition of a symbol? → `sg_go_to_definition` |
| 36 | +4. Need all callers/references? → `sg_find_references` |
| 37 | +5. Need full file content? → `sg_read_file` |
| 38 | + |
| 39 | +## Scoping (Always Do This) |
| 40 | + |
| 41 | +``` |
| 42 | +repo:^github.com/ORG/REPO$ # Exact repo (preferred) |
| 43 | +repo:github.com/ORG/ # All repos in org |
| 44 | +file:.*\.ts$ # TypeScript only |
| 45 | +file:src/api/ # Specific directory |
| 46 | +``` |
| 47 | + |
| 48 | +Start narrow. Expand only if results are empty. |
| 49 | + |
| 50 | +## Efficiency Rules |
| 51 | + |
| 52 | +- Chain searches logically: search → read → references → definition |
| 53 | +- Don't re-search for the same pattern; use results from prior calls |
| 54 | +- Prefer `sg_keyword_search` over `sg_nls_search` when you have exact terms |
| 55 | +- Read 2-3 related files before synthesising, rather than one at a time |
| 56 | +- Don't read 20+ remote files without writing code — once you understand the pattern, start implementing |
| 57 | + |
| 58 | +## If Stuck |
| 59 | + |
| 60 | +If MCP search returns no results: |
| 61 | +1. Broaden the search query (synonyms, partial identifiers) |
| 62 | +2. Try `sg_nls_search` for semantic matching |
| 63 | +3. Use `sg_list_files` to browse the directory structure |
| 64 | +4. Use `sg_list_repos` to verify the repository name |
| 65 | + |
| 66 | +--- |
| 67 | + |
| 68 | +# Add FlagExists Method to ReadOnlyFlagStore Interface |
| 69 | + |
| 70 | +**Repository:** github.com/sg-benchmarks/flipt--3d5a345f (mirror of flipt-io/flipt) |
| 71 | +**Access Scope:** You may modify files in `internal/`. You may read any file to understand existing patterns. |
| 72 | + |
| 73 | +## Context |
| 74 | + |
| 75 | +Flipt is a feature flag platform built with Go. The `ReadOnlyFlagStore` interface defines the contract for reading flag data from storage backends. Multiple concrete types implement this interface across the codebase (filesystem snapshots, SQL backends, etc.). |
| 76 | + |
| 77 | +The evaluation server needs a lightweight way to check if a flag exists without fetching the full flag object. Currently, it must call `GetFlag()` and check for errors, which is inefficient. A dedicated `FlagExists()` method would allow backends to optimize existence checks (e.g., via SQL `EXISTS` or filesystem stat). |
| 78 | + |
| 79 | +## Task |
| 80 | + |
| 81 | +Add a `FlagExists(ctx context.Context, req *flipt.GetFlagRequest) (bool, error)` method to the `ReadOnlyFlagStore` interface and implement it in all concrete types that satisfy this interface. |
| 82 | + |
| 83 | +**YOU MUST IMPLEMENT CODE CHANGES.** |
| 84 | + |
| 85 | +### Requirements |
| 86 | + |
| 87 | +1. **Find the interface definition** — Locate the `ReadOnlyFlagStore` interface in the storage package and understand its existing methods (e.g., `GetFlag`, `ListFlags`, `CountFlags`) |
| 88 | +2. **Find all implementations** — Search for all types that implement `ReadOnlyFlagStore`. These are types that have methods like `GetFlag(ctx context.Context, req *flipt.GetFlagRequest) (*flipt.Flag, error)` matching the interface |
| 89 | +3. **Add the method to the interface** — Add `FlagExists` to the interface definition: |
| 90 | + ```go |
| 91 | + FlagExists(ctx context.Context, req *flipt.GetFlagRequest) (bool, error) |
| 92 | + ``` |
| 93 | +4. **Implement in each concrete type** — For each implementing type, add a `FlagExists` method that: |
| 94 | + - Takes `(ctx context.Context, req *flipt.GetFlagRequest) (bool, error)` |
| 95 | + - Calls the type's existing `GetFlag()` method |
| 96 | + - Returns `true, nil` if the flag is found |
| 97 | + - Returns `false, nil` if the flag is not found (not-found error) |
| 98 | + - Returns `false, err` for other errors |
| 99 | +5. **Handle not-found errors** — Use the existing error patterns in each backend to distinguish "not found" from real errors. Look at how `GetFlag` callers handle the not-found case. |
| 100 | + |
| 101 | +## Success Criteria |
| 102 | + |
| 103 | +- `ReadOnlyFlagStore` interface includes `FlagExists` method |
| 104 | +- All concrete types that implement `ReadOnlyFlagStore` have a `FlagExists` method |
| 105 | +- Each implementation correctly handles not-found vs real errors |
| 106 | +- `go build ./internal/...` succeeds with zero errors |
| 107 | +- No existing tests broken |
| 108 | +- Changes are scoped to `internal/` only |
0 commit comments