Repository navigation
[Epic] Repository Search and Read MCP Tools Implementation - #2832
Conversation
… suite (22 tests) passes, as does the existing `planningUtils` test that covers the relevance engine I touched. `tsc --noEmit` and eslint come back clean for the core package. Nothing in the app calls the service yet, so it hasn't been exercised against a real clone or database outside the tests. `searchRepositoryFiles` (`packages/core/src/services/repositoryRetrievalService.ts`) - Semantic mode (default): it reads `indexing_status`, `last_indexed_at` and `last_indexed_hash` from `repositories` for the branch (`'HEAD'` if none is given). It then calls `findRelevantFiles` with summary scoring and the default agent from the agent registry. - Fallback: if the repo isn't indexed, indexing is in progress or failed, or no default agent is configured, it uses keyword, path and git-history scoring only. `freshness.caveat` says why. - Older index: if the index was built from an older commit than the one being searched, it still uses the summaries but sets `stale: true` with a caveat. - Semantic results: each file has a score and its match reasons (`semantic`, `path-match`, `git-history`), filtered by path prefix and paginated with `offset`, `limit`, `nextOffset` and `totalMatches`. - Literal mode: it runs `git grep -n -I -z -F` against the exact commit the ref points to. It's case-insensitive unless `caseSensitive` is set, and returns per-file match counts plus the first few matching lines (5 by default). No matches gives an empty result, not an error. - Literal search, not regex: I added the `-F` flag, so a query like `validateToken()` matches that text exactly. `readRepositoryFileContent` - It rejects paths containing `..`, a leading `/`, backslashes or null bytes. Binary files and directories get a 400, and missing files a 404. - Content comes from `git show <commit>:<path>`, so it doesn't depend on what's checked out in the shared clone. - It returns the requested line range, capped at `maxLines` (800) and `maxBytes` (120,000). `truncated` and `nextStartLine` tell the caller where to continue. Where the repo comes from: both functions accept a `repoPath` to use an existing clone. Otherwise they use the standard clone path, and only call `ensureRepoCloned` when there's no local clone or the ref isn't found locally. Additions beyond the spec: - Error type: errors are thrown as `RepositoryRetrievalError` with an HTTP-style `status`, so an API or MCP layer can map them directly. - Ref restrictions: refs that start with `-` or contain `..`, `~`, `^`, `:` or similar are rejected. Plain branch names and commit SHAs work, but forms like `HEAD~1` don't. - Hard caps: there are hard caps of 5,000 lines and 1 MB per read, and files over 20 MB are refused before being loaded. - Small change to the shared relevance engine: `findRelevantFiles` results now include an optional `signals` list, because its single `reason: 'combined'` value hid which signals contributed. Existing callers are unaffected. To keep files under the lint size limit, the types and input checks live in `repositoryRetrievalTypes.ts` and `repositoryRetrievalValidation.ts`. Everything is exported from `packages/core/src/index.ts`. Tests: `packages/core/test/repositoryRetrievalService.test.ts` runs grep and file reads against a real temporary git repo. The database, agent registry and relevance engine are mocked for the semantic cases. To run the tests I installed dependencies with `npm ci` and built `packages/shared` locally. This is backend-only, so there are no visual previews.
…wait for that.
* The watcher I started will notify me when the test finishes, so I'll wait for that.
* feat(ai): I fixed F1. The test now runs the executor with the real policy, and its final traversal call produces the standard `INVALID_PATH` envelope. The test passes.
I fixed F1. The test now runs the executor with the real policy, and its final traversal call produces the standard `INVALID_PATH` envelope. The test passes.
**What changed** (only `packages/api/test/mcpRepositoryRetrieval.test.ts`):
- **Policy dependency:** the stub that only had `repository` is gone. The test now uses `Object.create(McpPolicy.prototype)`, so the executor calls the real `requireScope`, `requirePermission` and `repository` methods. It skips the constructor, which only sets up OAuth/JWKS state these methods don't use.
- **A second error in the same assertion:** with the policy fixed, the last call still failed. `executeTool` doesn't return an error envelope; it throws. The envelope is built one layer up, in `packages/api/mcp/server.ts:65`, via `toToolErrorResult(classifyError(error, …))`. The test now runs a rejected `executeTool` call through that same conversion. It checks that a traversal path gives `{ code: 'INVALID_PATH', status: 400 }`.
- **New regression checks:**
- A caller without the `read` scope gets an `INSUFFICIENT_SCOPE` envelope from the executor. This proves the scope check really runs.
- Neither executor call reaches the file-read service.
**Checking for the same mistake elsewhere:** the other MCP tests that fake a policy already provide `requireScope`. This was the only executor test in the PR with an incomplete policy.
**Verification:** `NODE_ENV=test npx tsx --experimental-test-module-mocks --test --test-force-exit packages/api/test/mcpRepositoryRetrieval.test.ts` passes (1/1). With the old stub, the final call would fail with a `TypeError` instead of `INVALID_PATH`.
**Separate findings, not changed:**
- Run without `--test-force-exit`, the test file passed nothing and was killed after 300s by my timeout. Something seems to keep the process open, probably the SQLite connection it opens. I didn't check whether this happens on the code before my change. This file also isn't in the `test:mcp` script list.
- The run prints `[mcp] Access log write failed: db is not a function` because `deps.db` is an empty stub. The executor catches and logs this, so the test still passes.
- ESLint ignores `packages/api/test`, and the api `tsconfig.json` doesn't include test files, so neither lint nor `tsc` covered this file. It does run cleanly under `tsx`.
PR: #2833
Comment by: @propr-ultrafix (ID: 0)
Model: Claude Opus 5.5
* feat(ai): I fixed the shard 3 timeout. `packages/api/test/mcpRepositoryRetrieval.test.ts` passed but never exited. Using the executor opened the core SQLite connection, and nothing closed it, so the process stayed alive until CI's 180s limit killed it.
I fixed the shard 3 timeout. `packages/api/test/mcpRepositoryRetrieval.test.ts` passed but never exited. Using the executor opened the core SQLite connection, and nothing closed it, so the process stayed alive until CI's 180s limit killed it.
**The fix:** the test now imports `closeConnection` from `@propr/core` and calls it in `after(async () => closeConnection())`. The neighbouring MCP tests, like `mcpRepositoryConsent.test.ts` and `mcpAccessLogDispatch.test.ts`, close the connection the same way. No other file changed.
**Checked locally**, without `--test-force-exit`, which is closer to how CI runs it:
- **Before:** a copy of the previous version still hadn't exited at a 40s timeout (exit code 124).
- **After:** the test passes 1/1, logs "SQLite database connection closed", and the process exits in about 3.5s.
I only ran this one file, not the full shard. The shard also warned that `test/taskIntentWithdrawal.test.ts` passed but used 85% of its time limit (152.9s of 180s). This PR doesn't touch it.
There is no visual change, so no previews were made.
PR: #2833
Comment by: @github-actions[bot] (ID: 6019780816)
Model: Claude Opus 5.5
---------
Co-authored-by: propr-dev[bot] <1316198+propr-dev[bot]@users.noreply.github.com>
…es` and `read_repository_file`. The full `npm run test:mcp` suite passes (325 tests, 0 failures), including the 16 new tests. I didn't make preview images because nothing in the app's UI changed. Tests (`packages/api/test/mcpRepositoryRetrieval.test.ts`). The branch already had a version of this file, but it replaced the retrieval service with a fake. I rewrote it so the tools now run against real code: - Setup: a real git repository is cloned into the folder the service reads clones from, and index state and file summaries live in the SQLite test database. - What runs for real: the tool catalog, the executor with the real access policy, and the retrieval service. - What's faked: only the list of configured repositories, and the model that ranks files by their summaries. The fake model still receives the real summaries from the database. The new tests cover: - Semantic search, indexed: ranked paths with their reasons and freshness details. There is also a test for an index built from an older commit, which is marked stale. - Semantic search, unindexed: still returns results from path and history matching, with a caveat that the repository isn't indexed. - Literal search: match counts and matching lines, case sensitivity on and off, no matches returning an empty list with `totalMatches: 0`, paging with `offset`/`limit`/`nextOffset`, and the path filter. - Reading files: whole file, a line range, and the `maxLines`/`maxBytes` caps setting `truncated` and `nextStartLine`. - Errors: missing file (`FILE_NOT_FOUND`), binary file (`BINARY_FILE`), and `../` or absolute paths (`INVALID_PATH`). - Access: both tools return `REPOSITORY_FORBIDDEN` for a repository that isn't in the grant, isn't configured on the instance, or isn't accessible on GitHub. A caller without the read scope gets `INSUFFICIENT_SCOPE`. - End to end: a real MCP client over HTTP lists the tools, runs a search, then reads the matching line. Other changes: - I added the file to the `test:mcp` script in `package.json`; it wasn't listed there before. - I also had to edit `packages/api/test/mcpObservableSurface.test.ts`. That test checks every backticked lowercase word in `docs/mcp.md` against a list of known tool and field names. The new guide text uses words like `ref`, `commit`, `freshness` and `semantic`, so I added them to that list. Docs: - `docs/mcp-coverage.md`: a new row next to `get_repository_context` describing both tools, their parameters, freshness behaviour and error codes, plus an entry in the verification checklist for the new tests. - `docs/mcp.md`: a new section, "Searching and reading repository files". It has parameter tables, example results for both search modes and for a read, and the freshness caveats. It also has a four-step search-then-read example that reuses the returned `commit` as `ref` so every step reads the same snapshot. The new error codes are added to the errors table. - `docs/docs/features/mcp.md`: a row in the "Common operator workflows" table and a short operator note on freshness, output limits and errors. The test run logs warnings about Redis and model pricing. They come from the code that records usage metrics for summary ranking; there's no Redis in the test environment, and the code continues past the failure, so tests still pass and the process exits normally.
|
/merge |
|
🔀 Resolved merge conflicts from Conflicting Files
Resolution SummaryI resolved the conflict in What the conflict was about
How I resolved it Why Verification
🤖 Resolution Details
System-triggered merge conflict resolution |
Automatically resolved merge conflicts after merging target branch into PR branch. Resolved conflicts in: - test/sharedRepoPreparation.test.ts PR: #2832 Model: Claude Opus 5.5
|
/review astra fable |
|
✅ AI Code Review Complete requested by @integry Posted 2 reviews: |
🔍 AI Code Review — astraOverall EvaluationThe PR adds reusable repository retrieval services, MCP tools, integration tests, and operator documentation. It needs changes before merge: the MCP output pipeline can alter file contents, and accepted read sizes can exceed the transport’s response limit. ✅ Commit-scoped retrieval — Literal search, file reads, and relevance filtering use a resolved commit rather than working-tree contents. ✅ Authorization coverage — Both tools enforce repository access, with integration tests covering grant, configuration, GitHub-access, and scope denials. ✅ Continuation handling — Bounded reads preserve whole lines and provide a continuation cursor instead of silently dropping oversized line fragments. The supplied current-head status reports 17 passed checks, no failures, and no pending checks. This review uses static tracing only; no commands were run. Merge blockersEvery finding below was introduced by this PR and must be resolved before merging. F1: 🔴 Preserve source text through MCP redaction
F2: 🔴 Align read bounds with the response envelope
SuggestionsThese are optional follow-ups and are not sent to S1: 🟢 Explain managed-clone freshness
S2: 🟢 Stream literal search output
ScoreThe implementation has substantial coverage and passing current-head checks, but two concrete MCP integration defects prevent merge readiness. Both can be corrected locally without redesigning the retrieval service. Score: 6/10 🤖 Review Details
Copy and edit to choose records from this review: 🤖 Review by ProPR |
🔍 AI Code Review — fableOverall EvaluationThis PR adds a repository retrieval layer to The PR is not merge-ready. Two defects sit at the boundary the PR introduces: (1) the default branch resolution reads the shared clone's stale local branch, so the most common call silently returns old code; (2) the MCP result pipeline the tools were plugged into re-parses and reshapes any ✅ Robust ✅ Commit-scoped relevance is genuinely commit-scoped — ✅ Shallow-clone ref fetching is correct and well-tested — Merge blockersEvery finding below was introduced by this PR and must be resolved before merging. F3: 🔴 Default branch resolution returns the stale local branch of the shared clone
F4: 🔴
|
|
/fix all |
|
✅ Applied the requested follow-up changes in commit 61388ee
Summary of ChangesAll 14 selected records (F1–F5, S1–S9) are done. The full Findings
Suggestions
To keep Two side effects of S3
Found separately, not fixed (outside this scope)
The Gmail, Google Calendar and Google Drive connectors need authorizing in your claude.ai connector settings before they can be used; this task didn't need them. 🤖 Implementation Details
Undo Changes • View Task Execution 💡 ProPR Slash Commands
🤖 Generated by ProPR |
…npm run test:mcp` run had 330 of 331 tests passing. The one failure was a docs check in `mcpObservableSurface.test.ts`: my new docs mention `content`, so I added it to that test's list of allowed field names. That test passes now, but I haven't re-run the whole suite since. The core retrieval tests pass (44/44), as does the existing `relevanceServiceCommit` test. Both packages typecheck and lint clean. Nothing in the UI changed, so there are no previews. All 14 selected records (F1–F5, S1–S9) are done. The full `npm run test:mcp` run had 330 of 331 tests passing. The one failure was a docs check in `mcpObservableSurface.test.ts`: my new docs mention `content`, so I added it to that test's list of allowed field names. That test passes now, but I haven't re-run the whole suite since. The core retrieval tests pass (44/44), as does the existing `relevanceServiceCommit` test. Both packages typecheck and lint clean. Nothing in the UI changed, so there are no previews. **Findings** - **F1 / F4 – source text came back altered.** The result redactor no longer parses or rewrites file content, line previews, paths or the echoed query as JSON for the two new tools (`toolExecution.ts`). Those fields still have tokens and `Bearer …` values masked, through a new `redactText` helper in `adapter.ts`. `returnedBytes` is recalculated from the content actually returned. New tests read a pretty-printed `config.json` (keys like `password`, a 201-item array, a fake token) and check it comes back exactly as committed apart from the masked token. Another checks that a `[1, 2, 3]` match preview equals the line `read_repository_file` returns. - **F2 / F5 – sizes the tool accepted but the response cap rejected.** - The `maxBytes` maximum is now 200000 in the schema and both docs. - The core reader takes two new options. One caps the content's size after JSON escaping, so a read stops early and returns `nextStartLine`. The other is the largest `maxBytes` the caller accepts, so error hints never suggest a value the tool would reject. - A line that can't fit in any response now gets `FILE_TOO_LARGE`, saying no `maxBytes` will work. - There's also a final size check in the tool. - New tests read a 300 KB file with `maxBytes: 200000` and continue from `nextStartLine`, check that 300000 is rejected up front, and read a line of 150,000 quote characters. - **F3 – reads used the clone's stale local branch.** Every branch, `origin/<x>`, `refs/heads/<x>`, tag or `HEAD` request now fetches that ref from GitHub first. It then resolves from the fetched copy, so an old local `refs/heads/main` can't win. `HEAD` now means GitHub's default branch, kept in a private ref (`refs/propr/retrieval/origin-head`). A branch that has been deleted on GitHub now returns `REF_NOT_FOUND` instead of its leftover copy. I added the proposed regression in core and an MCP-level version of it. **Suggestions** - **S1:** `docs/mcp.md` now explains how fresh results are and how the shared clone's cache behaves. - **S2 / S5:** `git grep` output is now streamed, keeping full counts but only a few preview lines per file. The scan stops after 10,000 matching files or 64 MiB of output and reports `scanTruncated` (new file `repositoryLiteralGrep.ts`). - **S3:** "this name isn't a tag" is remembered for 60 seconds, and identical fetches running at the same time share one request. If GitHub can't be reached but the ref is cached, the result answers from the cache and adds a `refCaveat`. - **S4:** I removed the duplicate repository authorization check in both handlers; the executor already does it. - **S6:** `INVALID_REF` and `REPOSITORY_RETRIEVAL_FAILED` are now documented. - **S7:** a literal search page that would exceed 256 KiB now ends early, and `nextOffset` picks up at the first file left out (covered by a test with 100 wide matches). - **S8:** retrieval only clones when no clone exists yet. It never calls `ensureRepoCloned` on an existing clone, so it no longer changes what's checked out. Tests check the checkout stays on the worker's branch. - **S9:** relevance-engine failures now become `REPOSITORY_RETRIEVAL_FAILED` with status 500 (not retryable). Fetch failures stay 502 and retryable. To keep `repositoryRetrievalService.ts` within lint limits, I moved the line-selection code into `repositoryFileLines.ts`. **Two side effects of S3** - Because "not a tag" is remembered for 60 seconds, a tag created on GitHub with the same name as a branch can be missed for up to a minute. - `HEAD` with nothing cached now fails with 502 when GitHub is unreachable, where before it answered from the local checkout. **Found separately, not fixed (outside this scope)** - `presentResultText` copies the full result into the plain-text fallback. That text isn't covered by the 256 KiB check, so a large file read is sent roughly twice. - If a tag is deleted on GitHub while a local copy remains, the cached "not a tag" entry lets that local tag keep answering until the 60 seconds run out. This is a rare edge case. The Gmail, Google Calendar and Google Drive connectors need authorizing in your claude.ai connector settings before they can be used; this task didn't need them. PR: #2832 Comment by: @integry (ID: 6025149105) Model: Claude Opus 5.5
|
/review fable astra |
|
✅ AI Code Review Complete requested by @integry Posted 2 reviews: |
🔍 AI Code Review — fableOverall EvaluationThis PR adds a repository retrieval service to One contract gap remains: the documented error mapping for clone failures is not implemented, because errors from ✅ Byte-exact source text through the redactor — ✅ Origin-first ref resolution that leaves the shared clone alone — ✅ Streamed grep with chunk-boundary safety — Merge blockersEvery finding below was introduced by this PR and must be resolved before merging. F6: 🔴 Clone and raw git failures bypass the documented error mapping
SuggestionsThese are optional follow-ups and are not sent to S10: 🟢
|
🔍 AI Code Review — astraOverall EvaluationThe PR adds composable repository search and bounded reads with substantial integration coverage. It needs changes before merge: cached tags can override successfully refreshed branches, and credential masking can corrupt returned line structure. ✅ Authorization before retrieval — Both tools use the executor’s scope and repository checks before accessing git. ✅ Commit-scoped retrieval — Searches and reads use resolved commits, and semantic candidates are restricted to the requested commit’s tree. ✅ Response bounds and coverage — The implementation handles encoded response limits and tests pagination, authorization, freshness, and an MCP search-then-read loop. The supplied current-head checks report 17 passed, none failed or pending. This review used static analysis only; no commands were run. Merge blockersEvery finding below was introduced by this PR and must be resolved before merging. F7: 🔴 Deleted cached tags shadow refreshed branches
F8: 🔴 Credential masking removes repository newlines
SuggestionsThese are optional follow-ups and are not sent to S16: 🟢 Bound missing-tag cache retentionThe new ScoreThe implementation has strong authorization, bounded-response handling, and test coverage, with passing current-head checks. Two demonstrated correctness defects require localized fixes before merge. Score: 6/10 🤖 Review Details
Copy and edit to choose records from this review: 🤖 Review by ProPR |
|
/fix all |
|
✅ Applied the requested follow-up changes in commit 194a412
Summary of ChangesAll ten selected records are fixed (F6–F8 and S10–S16), each with a regression test. The full Findings
Suggestions
I updated 🤖 Implementation Details
Undo Changes • View Task Execution 💡 ProPR Slash Commands
🤖 Generated by ProPR |
…h with a regression test. The full `npm run test:mcp` run passes 391 of 391, which now includes the two core test files. Core and API both typecheck and lint clean. I checked that every new core regression fails against the old code. The F8 test I didn't run against the old code, but it follows directly from the old regex. Nothing visible in the UI changed, so there are no previews. All ten selected records are fixed (F6–F8 and S10–S16), each with a regression test. The full `npm run test:mcp` run passes 391 of 391, which now includes the two core test files. Core and API both typecheck and lint clean. I checked that every new core regression fails against the old code. The F8 test I didn't run against the old code, but it follows directly from the old regex. Nothing visible in the UI changed, so there are no previews. **Findings** - **F6 – clone and local git failures:** - A failed clone now returns `REPOSITORY_RETRIEVAL_FAILED` 502, retryable, with credentials removed from the URL in the message. This covers read, literal search and semantic search. - In `readBlob`, a git failure on a file that exists now returns 500. While testing this I found a worse case: when `git show` hits a corrupt object it can exit with an error without printing to stderr. simple-git then treats it as success and returns an empty string, so the file looked empty. The read now fetches the raw bytes and checks the length against `cat-file -s`. - Both changes have core regressions. I couldn't do an end-to-end MCP test with no clone, because the real clone would reach out to github.com. The step that maps a 502 to the retryable envelope is unchanged and already covered. - **F7 – deleted tag hiding a branch:** the fetch now returns the exact local ref it stored, and resolution uses only that. When GitHub is unreachable, the cached fallback also skips tags GitHub recently reported missing. One related change: if fetching the tag fails for a reason other than "not found", the fetch stops there instead of falling through to the branch. You then get the cached answer with a `refCaveat`, rather than a silent switch from tag to branch. The regression caches a tag, deletes it on the remote, and checks that reads, searches and the offline fallback all land on the surviving branch. - **F8 – masking removed newlines:** the `Bearer` pattern in `redactText` now matches only spaces and tabs, never a line break. That fixes both the tool's masking and the executor's second pass. The MCP regression checks that reading the whole file and reading it one line at a time give the same text with the same line numbers. **Suggestions** - **S10:** a path is rejected only when one of its segments is exactly `..`, so names like `CHANGELOG..md` now work. - **S11:** a hex-only name now resolves only as a commit ID (via `rev-parse --disambiguate`). A local branch with the same name can no longer answer. - **S12:** `assertSafeRef` now applies the same rules as `git check-ref-format` (`.lock`, `//`, a bare `@`, parts starting with `.`, control characters, and so on). Bad names return `INVALID_REF` before any fetch or clone. - **S13:** `repositoryRetrievalService.test.ts` and `relevanceServiceCommit.test.ts` are now part of `test:mcp`. - **S14:** reading a symlink returns `INVALID_PATH` with a message naming the link's target, instead of returning the target path as file content. The blob reader moved into its own module, `repositoryBlobReader.ts`. - **S15:** - The relevance engine now lists the commit's files once and shares that list between path scoring and the commit filter. - Relevance results are cached for 60 seconds, up to 50 entries, in the new `repositoryRelevanceCache.ts`. The cache key includes the commit, query, model and index build. Failed runs, and runs where summary scoring didn't contribute, aren't cached. Paging through results no longer repeats the LLM ranking pass. - Nothing tests the shared file listing directly; the existing commit-scoped relevance tests still pass. - **S16:** the missing-tag cache now holds at most 1,000 entries and clears out expired ones whenever a new one is added. There's a test for the expiry sweep but not for the 1,000 limit, because reaching it would need over a thousand real fetches. I updated `docs/mcp.md` and `docs/mcp-coverage.md` to describe the new path, ref, symlink, masking and caching behaviour. PR: #2832 Comment by: @integry (ID: 6025848769) Model: Claude Opus 5.5
|
/review fable astra |
|
✅ AI Code Review Complete requested by @integry Posted 2 reviews: |
🔍 AI Code Review — fableOverall EvaluationThis PR adds a repository retrieval service to I traced the changed control paths (authorization → ✅ Opaque-text handling through the redactor is correct and tested — ✅ Ref resolution refuses to answer from stale local state — ✅ Response-size accounting is conservative and consistent — Verdict: ready to merge within scope, conditional on the Merge blockersNo merge blockers. SuggestionsThese are optional follow-ups and are not sent to S17: 🟢 Canonicalize repository casing before cloning and index lookup
S18: 🟢 Measure response size after masking
|
🔍 AI Code Review — astraOverall EvaluationThe PR adds composable repository search and bounded reading with substantial integration coverage. It needs localized correctness fixes before merge. ✅ Snapshot consistency — Retrieval resolves a commit and uses it for literal search, blob reads, and semantic tree/history scoring. ✅ Authorization enforcement — Both tools pass through repository policy and read-scope checks before retrieval. ✅ Response bounds — Reads preserve whole-line continuation, and oversized search pages return a continuation offset. This review is based on static analysis of the supplied code. No commands were run; no current-head check runs were reported. Merge blockersEvery finding below was introduced by this PR and must be resolved before merging. F9: 🔴 Truncated scans report incomplete counts as complete
F10: 🔴 Missing index revision is reported as fresh
SuggestionsThese are optional follow-ups and are not sent to S24: 🟢 Align stale-index documentation
ScoreThe implementation has strong authorization, snapshot handling, and targeted tests. Two localized result-contract defects remain, so it is not yet merge-ready. Score: 6/10 🤖 Review Details
Copy and edit to choose records from this review: 🤖 Review by ProPR |
|
/merge |
|
🔀 Resolved merge conflicts from Conflicting Files
Resolution SummaryThe merge conflict is resolved. What the conflict was: Both branches changed the same line, the
How I resolved it: I started from the PR's version of the line and inserted Why: The two sides only added things and didn't overlap, so keeping both is safe. Dropping either side would leave tests out of Checks:
🤖 Resolution Details
System-triggered merge conflict resolution |
Automatically resolved merge conflicts after merging target branch into PR branch. Resolved conflicts in: - package.json PR: #2832 Model: Claude Opus 5.5
|
/fix all |
|
/ultrafix |
|
🔄 Ultrafix loop started (goal: 8/10, max cycles: 10) First action:
|
|
⏳ Ultrafix is waiting for CI before the next These blocking checks on
Checks matching this repository's non-blocking checks never gate Ultrafix. The loop continues automatically once the blocking checks pass; if they have not settled within 2 hours, Ultrafix stops. |
|
✅ AI Code Review Complete requested by @propr-ultrafix Posted 1 review: |
🔍 AI Code Review — codex:gpt-6-astraOverall EvaluationThe PR implements repository search and bounded reading with substantial integration coverage. It needs a localized correction before merge because credential masking can exceed the caller’s requested byte limit. ✅ Authorization before retrieval — Both tools use the executor’s scope and repository checks before accessing git. ✅ Commit-scoped retrieval — Search and reads resolve a commit, and semantic candidates are restricted to its tree. ✅ Protocol coverage — Added tests exercise catalog dispatch, authorization failures, pagination, and an MCP search-then-read loop. Current checks report 17 passed, none failed or pending. Merge blockersEvery finding below was introduced by this PR and must be resolved before merging. F11: 🔴 Preserve maxBytes after credential masking
SuggestionsThese are optional follow-ups and are not sent to S25: 🟢 Exercise real cold-clone preparationThe cold-clone tests mock ScoreThe implementation has strong authorization, snapshot handling, documentation, and tests, with passing current checks. One demonstrated output-bound violation remains and requires a localized fix. Score: 6/10 🤖 Review Details
Copy and edit to choose records from this review: 🤖 Review by ProPR |
|
✅ Applied the requested follow-up changes in commit 459e06f
Summary of ChangesI fixed F11: Cause: Fix (
New tests (
Similar code: No visual preview was created, since this change has no visible UI. 🤖 Implementation Details
💡 ProPR Slash Commands
🤖 Generated by ProPR |
…bytes than the requested `maxBytes` after credentials are masked. The repository-retrieval MCP tests pass (29 of 29), and the typecheck shows no errors in the changed files. I fixed F11: `read_repository_file` no longer returns more bytes than the requested `maxBytes` after credentials are masked. The repository-retrieval MCP tests pass (29 of 29), and the typecheck shows no errors in the changed files. **Cause:** `fitReadResult` masked each line (for example, `ghp_a` becomes `[redacted]`) after the service had already applied `maxBytes`. It then only checked the overall 256 KiB response limit, so a 5-byte request could return `returnedBytes: 10`. **Fix** (`packages/api/mcp/toolsContext.ts`): - `fitReadResult` now takes the requested `maxBytes`, and `read_repository_file` passes it in. - Lines are now kept only while they fit both the requested byte limit and the response limit, counting whole lines after masking. - When later lines are dropped, the result still reports where to continue: `endLine`, `returnedBytes`, `truncated: true` and `nextStartLine` all match the content actually returned. - If the first masked line is larger than `maxBytes`, the tool returns a 413 `FILE_TOO_LARGE` error. Like the service's existing error, it says how large `maxBytes` needs to be. The older 413 for a line that can never fit in a response is unchanged. **New tests** (`packages/api/test/mcpRepositoryRetrievalResults.test.ts`): - Direct `fitReadResult` tests: - Masking pushes the second line over `maxBytes`, so it is dropped and `nextStartLine` points to it. - A page the service already truncated keeps its `nextStartLine` when the masked content still fits. - Reading `ghp_a` with `maxBytes: 5` returns a 413 that asks for at least 10 bytes. - An end-to-end `read_repository_file` test confirms the requested `maxBytes` reaches the masking step. The file's mock can now return a successful result as well as an error. **Similar code:** `fitSearchResult` also masks before measuring, but `search_repository_files` has no `maxBytes` setting, so the same problem can't happen there. Nothing else calls `fitReadResult`. No visual preview was created, since this change has no visible UI. PR: #2832 Comment by: @propr-ultrafix (ID: 0) Model: Claude Opus 5.5
|
⏳ Ultrafix is waiting for CI before the next These blocking checks on
Checks matching this repository's non-blocking checks never gate Ultrafix. The loop continues automatically once the blocking checks pass; if they have not settled within 2 hours, Ultrafix stops. |
|
✅ AI Code Review Complete requested by @propr-ultrafix Posted 1 review: |
🔍 AI Code Review — codex:gpt-6-astraOverall EvaluationThe PR implements shared repository retrieval, authorized MCP tools, and extensive integration coverage. It needs a localized correctness fix before merge. ✅ Authorization before retrieval — The executor checks scope, repository grants, configuration, and current GitHub access before invoking either tool. ✅ Bounded responses — Reads preserve whole-line continuation, and search pages account for JSON encoding and credential masking. ✅ Commit-scoped retrieval — Search and reading use resolved commits rather than the shared checkout. This review used static analysis only, as requested. Current checks report 15 passed, none failed, and one pending. Merge blockersEvery finding below was introduced by this PR and must be resolved before merging. F12: 🔴 Normalize paths before detecting symlinks
SuggestionsThese are optional follow-ups and are not sent to S26: 🟢 Clarify trailing newline behaviorThe documentation describes content as “exactly as committed,” but ScoreThe implementation has strong authorization, response bounds, and test coverage, but the symlink rejection bypass needs correction. The pending check alone does not lower the score. Score: 6/10 🤖 Review Details
Copy and edit to choose records from this review: 🤖 Review by ProPR |
|
✅ Applied the requested follow-up changes in commit 8eb2e4d
Summary of ChangesI fixed F12. A symlink is now rejected as Fix
Regression tests (
Test results
Separate issue, not fixed: This change has nothing visible, so I made no previews. 🤖 Implementation Details
💡 ProPR Slash Commands
🤖 Generated by ProPR |
…wever its path is spelled, so `././util-link.ts` no longer returns the contents of `src/util.ts`. I fixed F12. A symlink is now rejected as `INVALID_PATH` however its path is spelled, so `././util-link.ts` no longer returns the contents of `src/util.ts`. **Fix** - I added `canonicalRepositoryPath` in `packages/core/src/services/repositoryRetrievalValidation.ts`. It runs the existing safety checks, then drops empty and `.` segments, so `./a`, `././a`, `a//b` and `a/./b` all become one path. A path that ends up empty, such as `.`, `./` or `././`, is rejected as `invalid_path`. - `readRepositoryFileContent` uses it in place of stripping a single leading `./` (`packages/core/src/services/repositoryRetrievalService.ts:482`). The Git lookup and the symlink check in `readBlob` now get the same path the tree uses, so the comparison in `repositoryBlobReader.ts:57` matches. The `path` field in the result is also the canonical form now. - `readBlob` has only this one caller, so nothing else needed the change. **Regression tests** (`packages/core/test/repositoryRetrievalService.test.ts`) - A symlink read as `util-link.ts`, `./util-link.ts`, `././util-link.ts` and `.//util-link.ts` gives the same 400 `invalid_path` "symbolic link" error each time. - An ordinary file read as `././src/util.ts`, `src//util.ts` and `src/./util.ts` returns `path: 'src/util.ts'`, and the empty paths are rejected. - With the old single-prefix stripping put back, both new tests fail. With the fix, they pass. **Test results** - The core retrieval suite passes: 61 of 61. - The MCP retrieval suites (`mcpRepositoryRetrieval`, `mcpRepositoryRetrievalResults`) pass: 29 of 29. - The typecheck shows no errors in the changed files, and ESLint reports no errors on them. ESLint skipped the test file because no lint configuration covers it. - I didn't add a symlink to the MCP-level test fixture, because that fixture is shared and a new file could change other tests' search results. The MCP layer turns `invalid_path` into `INVALID_PATH`, so the core tests cover this path. **Separate issue, not fixed:** `normalizePathPrefix`, used by `search_repository_files`, still strips only one leading `./`, so a prefix like `././src` won't match anything. It doesn't let a symlink through, so it's outside F12 and I left it alone. This change has nothing visible, so I made no previews. PR: #2832 Comment by: @propr-ultrafix (ID: 0) Model: Claude Opus 5.5
|
⏳ Ultrafix is waiting for CI before the next These blocking checks on
Checks matching this repository's non-blocking checks never gate Ultrafix. The loop continues automatically once the blocking checks pass; if they have not settled within 2 hours, Ultrafix stops. |
|
✅ AI Code Review Complete requested by @propr-ultrafix Posted 1 review: |
🔍 AI Code Review — codex:gpt-6-astraOverall EvaluationThe PR implements the shared retrieval service, authorized MCP search/read tools, integration coverage, and documentation. The supplied code supports merge readiness within scope, conditional on the remaining JavaScript/TypeScript analysis check completing successfully. ✅ Commit-scoped retrieval — Reads and literal searches use resolved commits; semantic ranking restricts candidates to the requested commit’s tree. ✅ Authorization before retrieval — Both tools pass through the executor’s scope and repository policy checks before accessing git. ✅ Bounded, resumable results — Whole-line reads and fitted search pages preserve continuation cursors, with explicit truncation and freshness metadata. This was a static review of the supplied diff and context; no commands or tests were run. The authoritative check summary reports no failures, 15 passes, and one pending check. Merge blockersNo merge blockers. SuggestionsThese are optional follow-ups and are not sent to S27: 🟢 Clarify terminal newline handling
ScoreThe implementation addresses the stated objective with substantial coverage of authorization, ref resolution, response bounds, and failure handling. No merge-blocking defect was verified; the remaining check is pending. Score: 9/10 🤖 Review Details
Copy and edit to choose records from this review: 🤖 Review by ProPR |
Full Test Suite ResultsValidation failed during: Test shard (shard 2).
View shard 2/4 outputDetails truncated; see the uploaded artifacts for complete failure rows and logs. |
|
✅ Applied the requested follow-up changes in commit 2417683 Summary of ChangesI fixed the shard 2 failure in Cause: The CI log shows test 32 ( Fix: I added a Verification:
There's no visual change, so I didn't create any previews. 🤖 Implementation Details
Undo Changes • View Task Execution 💡 ProPR Slash Commands
🤖 Generated by ProPR |
…ryWorkflow.test.ts`. It was an intermittent timing bug in the validation wrapper, not a problem with this PR's repository search/read changes. I fixed the shard 2 failure in `packages/core/test/repositoryWorkflow.test.ts`. It was an intermittent timing bug in the validation wrapper, not a problem with this PR's repository search/read changes. **Cause:** The CI log shows test 32 (`validation distinguishes a timeout from a command killed or exiting 124 before its limit`) failing because `exit 124` was reported as "Timed out" instead of "Failed (exit 124)". The wrapper in `packages/core/src/workflow/workflowExecution.ts` decides whether a 124/137 exit was a real timeout by checking elapsed time with bash's `$SECONDS`, which only counts whole seconds. The test uses a 1-second limit, so an `exit 124` that returns instantly but happens to cross a second boundary looks like it ran for a full second. **Fix:** I added a `clock_ms` helper that reads bash 5's microsecond clock (`EPOCHREALTIME`), and the check now compares elapsed milliseconds against the limit in milliseconds. On bash older than 5 it falls back to the old `$SECONDS` behaviour, so the flake could still happen there. A real timeout is still always detected, because `timeout(1)` starts after the start time is recorded. **Verification:** - **The bug itself:** in 300 back-to-back immediate `exit 124` runs, the old seconds check called one a timeout and the new check called none. - **The failing suite:** `repositoryWorkflow.test.ts` passed 35/35 three times in a row through `scripts/run-test-suite.mjs`. It also passed before the change, so the local runs don't reproduce the flake; the stress loop is the evidence for the fix. - **Related suites:** `workflowContainerSmoke`, `repositoryWorkflowAdmission` and `prPublicationJob` pass. - **Typecheck and lint:** `tsc` for `packages/core` reports no errors. ESLint skipped the file because no lint config covers it, so lint wasn't actually checked. There's no visual change, so I didn't create any previews. PR: #2832 Comment by: @github-actions[bot] (ID: 6035114858) Model: Claude Opus 5.5
Full Test Suite ResultsValidation failed during: Test shard (shard 1), Test shard (shard 2).
View shard 1/4 outputView shard 2/4 outputDetails truncated; see the uploaded artifacts for complete failure rows and logs. |
|
✅ Applied the requested follow-up changes in commit 1957e28 Summary of ChangesI fixed both failing test files. Each crashed before any test ran, and neither failure came from this PR's repository search/read changes. Cause: CI tests this branch merged with the current
The CI logs confirm this. Both runs stopped with Fix: I added the two missing functions to the test stand-ins:
Verification:
Only the two test files changed. There's nothing visual here, so I didn't make previews. 🤖 Implementation Details
Undo Changes • View Task Execution 💡 ProPR Slash Commands
🤖 Generated by ProPR |
…st ran, and neither failure came from this PR's repository search/read changes. I fixed both failing test files. Each crashed before any test ran, and neither failure came from this PR's repository search/read changes. **Cause:** CI tests this branch merged with the current `main`. On `main`, two source files now import functions from `@propr/core` that the tests' stand-in version of `@propr/core` doesn't provide. In Node, a missing import like that is a hard error when the file loads: - `src/jobs/prCommentPostExecution.ts` now imports `describeAgentTermination`, which `test/prPublicationRecoveryJob.test.ts` was missing. - `src/jobs/ultrafixCiWait.ts` now imports `recoverCiFailureFollowups`, which `test/ultrafixContinuationEntryPoint.test.ts` was missing. The CI logs confirm this. Both runs stopped with `SyntaxError: The requested module '@propr/core' does not provide an export named …`. The tests have the same gap on `main`, so `main` will probably hit the same failure. **Fix:** I added the two missing functions to the test stand-ins: - `test/prPublicationRecoveryJob.test.ts`: `describeAgentTermination: () => 'Agent execution timed out.'` - `test/ultrafixContinuationEntryPoint.test.ts`: `recoverCiFailureFollowups: async () => undefined` **Verification:** - With `main`'s versions of the two source files swapped in temporarily (to imitate the CI merge), both files pass: 39/39 and 8/8. I put this branch's versions back afterwards. - On the branch as it is, both files also pass. Only the two test files changed. There's nothing visual here, so I didn't make previews. PR: #2832 Comment by: @github-actions[bot] (ID: 6035381972) Model: Claude Opus 5.5
…ith `mcpEpicDispatch.test.ts` and all 5 passed. All four failing test files pass now. I ran them together with `mcpEpicDispatch.test.ts` and all 5 passed. **The one failure this PR caused: `test/planIssueHandlers.followup.test.ts`.** The test file crashed on load with `SyntaxError: The requested module '@propr/core' does not provide an export named 'getEpicExecutionQueue'`. This branch added `getEpicExecutionQueue` and `summarizeEpicQueue` to the imports from `@propr/core` in `packages/api/routes/planIssueHandlers.ts`, for the new execution-queue endpoints. The test replaces `@propr/core` with a stand-in that didn't have them. I added both, returning `null`, to the test's stand-in in `test/planIssueHandlers.followup.test.ts`. **The other three failures were already fixed on `main`.** CI runs this branch merged with the current `main`, but the branch didn't have `main`'s fixes yet (from PR #2832). I copied each file from `main` as it is, so the next merge from `main` should have no conflicts in them: - **`test/prPublicationRecoveryJob.test.ts`**: adds the missing `describeAgentTermination` stand-in. - **`test/ultrafixContinuationEntryPoint.test.ts`**: adds the missing `recoverCiFailureFollowups` stand-in. - **`packages/core/src/workflow/workflowExecution.ts`** (for `packages/core/test/repositoryWorkflow.test.ts`): fixes an intermittent failure where a command that quickly exits with code 124 was sometimes reported as a timeout. Nothing in the UI changed, so there are no previews. PR: #2828 Comment by: @github-actions[bot] (ID: 6036104280) Model: Claude Opus 5.5
… (S11–S27). Typecheck and lint are clean with no warnings, all 2162 UI unit tests pass, and all 22 Playwright tests in the two planner specs pass, 7 of them new. I also ran the core epic-queue tests: all 26 pass, 3 of them new. I've applied all 8 findings (F6–F13) and all 17 suggestions (S11–S27). Typecheck and lint are clean with no warnings, all 2162 UI unit tests pass, and all 22 Playwright tests in the two planner specs pass, 7 of them new. I also ran the core epic-queue tests: all 26 pass, 3 of them new. **Findings** - **F6 – Queue Remaining ignored the demo and saving guards:** the button is now disabled in demo mode and while a setting is saving, with a "Demo mode is read-only" tooltip. The click handler also refuses both cases, including the "queue behind running work" path. - **F7 – A closed earlier issue blocked the epic:** the batch now starts with the earliest pending issue in creation order, the same rule the server uses. So a closed earlier issue no longer blocks the rest. - **F8 / S11 – Edited Max Loops lost on dismiss:** closing the popover (outside click, Escape, resize) now commits the field you're typing in before it disappears. Tested both in jsdom and in the browser; the unit test fails if the fix is removed. - **F9 – Issue links on the wrong tasks after reconnecting:** each received issue now records which task created it. The server creates issues one task at a time, so that's `createdCount + failedCount − 1` from the event. Issues created before you connected stay blank (`#…`) instead of taking a neighbour's link, and this also works when an earlier task failed. - **F10 / F12 – Header overlap at tablet widths:** I removed the 320px title minimum, gave the title a 12rem floor, and let the header wrap, so the actions move to a second line when there isn't room. My first attempt passed its test but the 1024px screenshot showed the phase switcher clipped, because the sidebar narrows the content. The wrapping version fixes that. New tests at 768, 1024 and 1280px check that every action and the phase switcher are fully on screen and nothing overlaps. The header is still a single row at 1440px. - **F11 – Default couldn't clear an explicit model:** choosing Default now compares against the saved model, so it clears an override even when the override is the default model. - **F13 / S19 – Stray upload file:** I deleted `packages/api/temp_uploads/dd9afce3-…` and added `temp_uploads/` to `.gitignore`. `git rm` failed because the git index is read-only here, so the file is deleted from disk only. The commit needs to include that deletion. **Suggestions** - **S12:** the plans list decides whether to show repository owners from the full repository list, not just the current page. - **S13:** checked; both use the 768px breakpoint. New tests confirm the phase switcher shows on the Review step at 768 and 1024px. - **S14:** with neither Epic nor auto-merge on, the disabled button is replaced by one line of text: "Enable auto-merge or Epic PR to queue the remaining tasks." - **S15:** popovers now ignore scrolling in containers that don't hold their trigger. When the trigger's container scrolls, the popover follows it and only closes once the trigger is off screen. - **S16:** a single-issue epic shows "Implement Epic" again. - **S17:** no change needed; only the planner uses `STATUS_CONFIG`. - **S18 / S20:** the config and agent popovers take focus when they open and hand it back on Escape. The "…" menu now supports Escape, arrow keys and Home/End, and returns focus to its button. - **S21:** new core tests cover a queue behind two running issues: the second isn't started again, either can finish first, and recovery doesn't treat a running issue as a lost start. - **S22:** discovery telemetry is labelled as an estimate until the run reports real numbers, and files taken from the last preview read "Expected" instead of "Scanned". The scan-time hints have a "typical, not measured" tooltip. - **S23:** no change needed. `workflowExecution.ts` is identical to `main` (it was copied over from #2832), so it disappears from the diff on the next merge from `main`. The new timeout check is also more precise than the old one. - **S24:** the task list switches layout at 768px, the same as the editor. - **S25:** no change needed; the only callers are the two planner headers, and both already show the branch. - **S26:** the model selector skips the catalog request when the plan already has a default model. - **S27:** a default with no agent named no longer hides any agent's version of that model. One related issue I didn't fix: in the issue-creation list, the "Created / Creating / Queued" badges still assume no task has failed. Links now land on the right task, but after a failure the badges can be off by one row. Previews show the Execution header at 768, 1024, 1280 and 1440px, plus the labelled discovery telemetry. PR: #2828 Comment by: @integry (ID: 6041581324) Model: Claude Opus 5.5
Repository Search and Read MCP Tools Implementation
This Epic PR aggregates all changes for the plan: Repository Search and Read MCP Tools Implementation
Issues in this Epic
Auto-close
When this PR is merged, the following issues will be automatically closed:
Fixes #2797
Fixes #2798
Fixes #2799
Created automatically by ProPR