using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; namespace StellaOps.Provcache.Api; public static partial class ProvcacheEndpointExtensions { /// /// GET /v1/provcache/proofs/{proofRoot}/manifest /// private static async Task GetProofManifestAsync( string proofRoot, [FromServices] IEvidenceChunkRepository chunkRepository, ILogger logger, CancellationToken cancellationToken) { logger.LogDebug("GET /v1/provcache/proofs/{ProofRoot}/manifest", proofRoot); try { var manifest = await chunkRepository.GetManifestAsync(proofRoot, cancellationToken); if (manifest is null) { return Results.NotFound(); } var chunkMetadata = manifest.Chunks .OrderBy(c => c.Index) .Select(c => new ChunkMetadataResponse { ChunkId = c.ChunkId, Index = c.Index, Hash = c.Hash, Size = c.Size, ContentType = c.ContentType }).ToList(); return Results.Ok(new ProofManifestResponse { ProofRoot = proofRoot, TotalChunks = manifest.TotalChunks, TotalSize = manifest.TotalSize, Chunks = chunkMetadata, GeneratedAt = manifest.GeneratedAt }); } catch (Exception ex) { logger.LogError(ex, "Error getting manifest for proof root {ProofRoot}", proofRoot); return InternalError("Manifest retrieval failed"); } } }