Skip to content

feat: add POST /agent/refresh so an agent can make a new repository visible - #202

Merged
davidnmbond merged 1 commit into
mainfrom
feat/agent-api-refresh
Nov 13, 2026
Merged

davidnmbond merged 1 commit into
mainfrom
feat/agent-api-refresh

Conversation

@davidnmbond

Copy link
Copy Markdown
Contributor

A repository created after the app started only becomes visible through a refresh, and only the dashboard button could queue one. The agent API now has POST /agent/refresh.

  • Queues the same RefreshAll work with the same dedup key (refresh:*) as the button, so a pending refresh folds the request; a running one does not, so asking again earns a fresh pass behind it.
  • Recorded in the ledger as coming from agent-api.
  • Spends the same GitHub API budget as the button; there is no confirmation step, so callers should not poll it.
  • 4 new tests on the queuing rules. The HTTP route itself is a thin wrapper and has not been exercised against a running app.
  • Full suite: 2408 of 2409 pass. The one failure, AiFixIntegrationTests.ItFixesTheMissingPackageProjectUrl, fails identically on a clean origin/main (da54648), so it is not caused by this change.

…isible

A repository created after the app started only appears after a refresh, which only the dashboard button could queue. The endpoint queues the same RefreshAll work under the same dedup key, so it folds with a pending button press, and records the queue origin as agent-api. A refresh already running does not fold the request, because it may have listed the organisation before the repository existed.
@codacy-production

codacy-production Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 11 complexity · 0 duplication

Metric Results
Complexity 11
Duplication 0

View in Codacy

🟢 Coverage 31.58% diff coverage · -0.03% coverage variation

Metric Results
Coverage variation ✅ -0.03% coverage variation (-1.00%)
Diff coverage ✅ 31.58% diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (15455f7) 22624 14382 63.57%
Head commit (051487d) 22643 (+19) 14388 (+6) 63.54% (-0.03%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#202) 19 6 31.58%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

AI Reviewer: first review requested successfully. AI can make mistakes. Always validate suggestions.

Run reviewer

TIP This summary will be updated as you push new changes.

@codacy-production codacy-production Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

✅ No blocking issues noticed

No blocking security or logic findings were identified. The endpoint implementation remains insufficiently covered: the complex production service has low overall coverage, and route-level HTTP behavior and queue attribution are not exercised. One required endpoint test scenario is missing.

Test suggestions

  • First refresh request queues RefreshAll with the expected descriptor and deduplication key.
  • Second request while a refresh is pending is deduplicated.
  • Request while a refresh is running queues a distinct follow-up refresh.
  • HTTP endpoint attributes queued work to agent-api and returns the expected response.
  • Verify the endpoint response for both newly queued and deduplicated requests.
Prompt proposal for missing tests
Consider implementing these tests if applicable:
1. HTTP endpoint attributes queued work to agent-api and returns the expected response.
2. Verify the endpoint response for both newly queued and deduplicated requests.

TIP Add a Jira or Linear ticket key to the branch or title so the reviewer can check the PR against it. Using another tracker? Tell us.
TIP How was this review? Give us feedback

Comment on lines +485 to +497
group.MapPost("/refresh", (WorkLaneService lanes) =>
{
using var origin = Governance.QueueOrigin.Use("agent-api");

var item = EnqueueRefresh(lanes);

return Results.Json(new
{
queued = item is null ? 0 : 1,
id = item?.Id,
note = item is null ? "A refresh is already waiting its turn and will pick up what exists now." : null
});
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 MEDIUM RISK

Suggestion: Add an endpoint-level test for POST /agent/refresh covering a first request that returns a queued work ID, a deduplicated pending request that returns the explanatory note, and verification that the queued work is attributed to agent-api.

See Coverage in Codacy

TIP React 👍 if this review is right, or reply with what's wrong and how it could be better to help improve the reviewer.

@davidnmbond
davidnmbond merged commit cdb0663 into main Nov 13, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant