Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions dotnet/EcencyApi/Handlers/PrivateApi.Misc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,25 @@ await Upstream.Pipe(
ApiClient.ApiRequest("ai-image-generate", HttpMethod.Post, null, data, null, 120000), ctx);
}

/// <summary>
/// Per-user AI image generation history (the upstream's last 20 successful
/// generations). The username comes ONLY from the validated code: prompts are
/// private to their author, so a body-supplied username would let any caller
/// read someone else's generation history.
/// </summary>
public static async Task AiImagesHistory(HttpContext ctx)
{
var body = await ctx.ReadBody();
var username = await ValidateCode(body);
if (username == null)
{
await ctx.SendText(401, "Unauthorized");
return;
}
await Upstream.Pipe(
ApiClient.ApiRequest($"users/{username}/ai-images", HttpMethod.Get), ctx);
Comment thread
qodo-code-review[bot] marked this conversation as resolved.
}

public static async Task AiAssistPrice(HttpContext ctx)
{
var body = await ctx.ReadBody();
Expand Down
1 change: 1 addition & 0 deletions dotnet/EcencyApi/Handlers/Routes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ public static void Map(WebApplication app)
app.MapPost("/private-api/boosted-post", PrivateApi.BoostedPost);
app.MapPost("/private-api/ai-generate-price", PrivateApi.AiGeneratePrice);
app.MapPost("/private-api/ai-generate-image", PrivateApi.AiGenerateImage);
app.MapPost("/private-api/ai-images", PrivateApi.AiImagesHistory);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remediation recommended

2. ai-images lacks parity artifacts 📘 Rule violation ▣ Testability

The PR adds the observable POST /private-api/ai-images endpoint without a corresponding
dotnet/parity/KNOWN_DIVERGENCES entry or an automated endpoint test. Both artifacts are required
for HTTP-visible route changes.
Agent Prompt
## Issue description
The new `POST /private-api/ai-images` route changes the public HTTP surface without the required parity divergence documentation or automated behavior coverage.

## Issue Context
Document how this endpoint differs from the reference image and add tests covering at least successful authenticated proxying and rejection of invalid signed codes.

## Fix Focus Areas
- dotnet/EcencyApi/Handlers/Routes.cs[158-158]
- dotnet/EcencyApi/Handlers/PrivateApi.Misc.cs[575-585]
- dotnet/parity/KNOWN_DIVERGENCES[1-1]
- dotnet/EcencyApi.Tests[1-1]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Parity artifacts added in 2f5a086: an AI_IMAGES_DIVERGENCE entry for the three generated probes, mirroring the dictation-route precedent for additive endpoints. On tests: the repo's convention unit-tests extractable request-construction logic (BuildTranscribeContent), while thin validate-and-pipe handlers like the sibling AI price routes have no endpoint harness; this handler has no extractable logic beyond the upstream URL, and the username-from-validated-code property is exercised by the parity badcode probe answering 401.

app.MapPost("/private-api/ai-assist-price", PrivateApi.AiAssistPrice);
app.MapPost("/private-api/ai-assist", PrivateApi.AiAssist);
app.MapPost("/private-api/ai-transcribe-price", PrivateApi.AiTranscribePrice);
Expand Down
16 changes: 16 additions & 0 deletions dotnet/parity/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,13 @@ def norm_body(text):
"::pop and ::badcode for every POST route, which is why all three appear here."
)

AI_IMAGES_DIVERGENCE = (
"Per-user AI image history route added after the port (ePoints users/<u>/ai-images). "
"The reference build has no such route and answers 404; this one validates the "
"signed code and answers 401 or proxies the history. Deterministic and additive -- "
"no behavior the reference ever had is changing."
)

# Cases where the C# port intentionally differs from Node (Node bugs the port fixes).
KNOWN_DIVERGENCES = {
"/auth-api/hs-token-refresh::min":
Expand Down Expand Up @@ -256,6 +263,15 @@ def norm_body(text):
AI_TRANSCRIBE_DIVERGENCE,
"/private-api/ai-transcribe::badcode":
AI_TRANSCRIBE_DIVERGENCE,
# Per-user AI image history, added after the port (ePoints users/<u>/ai-images).
# Same shape as the dictation entries: the reference build has no such route and
# answers 404 while this one validates the code and answers 401/proxies. Additive.
"/private-api/ai-images::min":
AI_IMAGES_DIVERGENCE,
"/private-api/ai-images::pop":
AI_IMAGES_DIVERGENCE,
"/private-api/ai-images::badcode":
AI_IMAGES_DIVERGENCE,
}

# Deliberately NOT listed above: /wallet-api/portfolio-v2::pop, whose HP action list
Expand Down
Loading