search and ai stabilization work, localization stablized.
This commit is contained in:
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using static StellaOps.Localization.T;
|
||||
|
||||
namespace StellaOps.Provcache;
|
||||
|
||||
@@ -21,7 +22,7 @@ public sealed partial class EvidenceChunker
|
||||
|
||||
if (orderedChunks.Count == 0)
|
||||
{
|
||||
throw new ArgumentException("No chunks provided.", nameof(chunks));
|
||||
throw new ArgumentException(_t("common.provcache.no_chunks_provided"), nameof(chunks));
|
||||
}
|
||||
|
||||
// Verify Merkle root.
|
||||
@@ -31,7 +32,7 @@ public sealed partial class EvidenceChunker
|
||||
if (!string.Equals(computedRoot, expectedProofRoot, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
$"Merkle root mismatch. Expected: {expectedProofRoot}, Computed: {computedRoot}");
|
||||
_t("common.provcache.merkle_root_mismatch", expectedProofRoot, computedRoot));
|
||||
}
|
||||
|
||||
// Verify each chunk.
|
||||
@@ -42,7 +43,7 @@ public sealed partial class EvidenceChunker
|
||||
if (!VerifyChunk(chunk))
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
$"Chunk {chunk.ChunkIndex} verification failed. Expected hash: {chunk.ChunkHash}");
|
||||
_t("common.provcache.chunk_verification_failed", chunk.ChunkIndex, chunk.ChunkHash));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using static StellaOps.Localization.T;
|
||||
|
||||
namespace StellaOps.Provcache;
|
||||
|
||||
@@ -25,7 +26,7 @@ public sealed partial class MinimalProofExporter
|
||||
var cacheResult = await _provcacheService.GetAsync(veriKey, bypassCache: false, cancellationToken);
|
||||
if (cacheResult.Entry is null)
|
||||
{
|
||||
throw new InvalidOperationException($"Cache entry not found for VeriKey: {veriKey}");
|
||||
throw new InvalidOperationException(_t("common.provcache.cache_entry_not_found", veriKey));
|
||||
}
|
||||
|
||||
var entry = cacheResult.Entry;
|
||||
@@ -34,7 +35,7 @@ public sealed partial class MinimalProofExporter
|
||||
|
||||
// Get the chunk manifest.
|
||||
var manifest = await _chunkRepository.GetManifestAsync(proofRoot, cancellationToken)
|
||||
?? throw new InvalidOperationException($"Chunk manifest not found for proof root: {proofRoot}");
|
||||
?? throw new InvalidOperationException(_t("common.provcache.chunk_manifest_not_found", proofRoot));
|
||||
|
||||
// Build chunks based on density.
|
||||
var bundleChunks = await GetChunksForDensityAsync(
|
||||
@@ -61,7 +62,7 @@ public sealed partial class MinimalProofExporter
|
||||
{
|
||||
if (_signer is null)
|
||||
{
|
||||
throw new InvalidOperationException("Signing requested but no signer is configured.");
|
||||
throw new InvalidOperationException(_t("common.provcache.signing_requested_no_signer"));
|
||||
}
|
||||
|
||||
bundle = await SignBundleAsync(bundle, options.SigningKeyId, cancellationToken);
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.IO;
|
||||
using System.Text.Json;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using static StellaOps.Localization.T;
|
||||
|
||||
namespace StellaOps.Provcache;
|
||||
|
||||
@@ -16,7 +17,7 @@ public sealed partial class MinimalProofExporter
|
||||
ArgumentNullException.ThrowIfNull(jsonBytes);
|
||||
|
||||
var bundle = JsonSerializer.Deserialize<MinimalProofBundle>(jsonBytes, s_jsonOptions)
|
||||
?? throw new InvalidOperationException("Failed to deserialize bundle.");
|
||||
?? throw new InvalidOperationException(_t("common.provcache.bundle_deserialize_failed"));
|
||||
|
||||
return await ImportAsync(bundle, cancellationToken);
|
||||
}
|
||||
@@ -32,7 +33,7 @@ public sealed partial class MinimalProofExporter
|
||||
inputStream,
|
||||
s_jsonOptions,
|
||||
cancellationToken)
|
||||
?? throw new InvalidOperationException("Failed to deserialize bundle.");
|
||||
?? throw new InvalidOperationException(_t("common.provcache.bundle_deserialize_failed"));
|
||||
|
||||
return await ImportAsync(bundle, cancellationToken);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ using StellaOps.Provenance.Attestation;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using static StellaOps.Localization.T;
|
||||
|
||||
namespace StellaOps.Provcache;
|
||||
|
||||
@@ -17,7 +18,7 @@ public sealed partial class MinimalProofExporter
|
||||
{
|
||||
if (_signer is null)
|
||||
{
|
||||
throw new InvalidOperationException("Signer is not configured.");
|
||||
throw new InvalidOperationException(_t("common.provcache.signer_not_configured"));
|
||||
}
|
||||
|
||||
// Serialize bundle without signature for signing.
|
||||
|
||||
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using static StellaOps.Localization.T;
|
||||
|
||||
namespace StellaOps.Provcache;
|
||||
|
||||
@@ -22,7 +23,7 @@ public sealed partial class HttpChunkFetcher
|
||||
var timeout = _options.Timeout;
|
||||
if (timeout <= TimeSpan.Zero || timeout == Timeout.InfiniteTimeSpan)
|
||||
{
|
||||
throw new InvalidOperationException("Lazy fetch HTTP timeout must be a positive, non-infinite duration.");
|
||||
throw new InvalidOperationException(_t("common.provcache.http_timeout_invalid"));
|
||||
}
|
||||
|
||||
if (_httpClient.Timeout == Timeout.InfiniteTimeSpan || _httpClient.Timeout > timeout)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using static StellaOps.Localization.T;
|
||||
|
||||
namespace StellaOps.Provcache;
|
||||
|
||||
@@ -8,27 +9,27 @@ public sealed partial class HttpChunkFetcher
|
||||
{
|
||||
if (!baseAddress.IsAbsoluteUri)
|
||||
{
|
||||
throw new InvalidOperationException("Lazy fetch base URL must be absolute.");
|
||||
throw new InvalidOperationException(_t("common.provcache.fetch_url_absolute"));
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(baseAddress.UserInfo))
|
||||
{
|
||||
throw new InvalidOperationException("Lazy fetch base URL must not include user info.");
|
||||
throw new InvalidOperationException(_t("common.provcache.fetch_url_no_userinfo"));
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(baseAddress.Host))
|
||||
{
|
||||
throw new InvalidOperationException("Lazy fetch base URL must include a host.");
|
||||
throw new InvalidOperationException(_t("common.provcache.fetch_url_host_required"));
|
||||
}
|
||||
|
||||
if (!_allowedSchemes.Contains(baseAddress.Scheme))
|
||||
{
|
||||
throw new InvalidOperationException($"Lazy fetch base URL scheme '{baseAddress.Scheme}' is not allowed.");
|
||||
throw new InvalidOperationException(_t("common.provcache.fetch_url_scheme_invalid", baseAddress.Scheme));
|
||||
}
|
||||
|
||||
if (!_allowAllHosts && !IsHostAllowed(baseAddress.Host, _allowedHosts))
|
||||
{
|
||||
throw new InvalidOperationException($"Lazy fetch base URL host '{baseAddress.Host}' is not allowlisted.");
|
||||
throw new InvalidOperationException(_t("common.provcache.fetch_url_host_invalid", baseAddress.Host));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Http;
|
||||
using System.Text.Json;
|
||||
using static StellaOps.Localization.T;
|
||||
|
||||
namespace StellaOps.Provcache;
|
||||
|
||||
@@ -71,7 +72,7 @@ public sealed partial class HttpChunkFetcher : ILazyEvidenceFetcher, IDisposable
|
||||
};
|
||||
|
||||
var baseAddress = _httpClient.BaseAddress
|
||||
?? throw new InvalidOperationException("HttpChunkFetcher requires a BaseAddress on the HTTP client.");
|
||||
?? throw new InvalidOperationException(_t("common.provcache.http_base_address_required"));
|
||||
|
||||
_allowedSchemes = NormalizeSchemes(_options.AllowedSchemes);
|
||||
_allowedHosts = NormalizeHosts(_options.AllowedHosts, baseAddress.Host, out _allowAllHosts);
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
// ----------------------------------------------------------------------------
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using static StellaOps.Localization.T;
|
||||
|
||||
namespace StellaOps.Provcache.Oci;
|
||||
|
||||
@@ -13,22 +14,22 @@ public sealed partial class ProvcacheOciAttestationBuilder
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(request.ArtifactReference))
|
||||
{
|
||||
throw new ArgumentException("Artifact reference is required.", nameof(request));
|
||||
throw new ArgumentException(_t("common.provcache.artifact_reference_required"), nameof(request));
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(request.ArtifactDigest))
|
||||
{
|
||||
throw new ArgumentException("Artifact digest is required.", nameof(request));
|
||||
throw new ArgumentException(_t("common.provcache.artifact_digest_required"), nameof(request));
|
||||
}
|
||||
|
||||
if (request.DecisionDigest is null)
|
||||
{
|
||||
throw new ArgumentException("DecisionDigest is required.", nameof(request));
|
||||
throw new ArgumentException(_t("common.provcache.decision_digest_required"), nameof(request));
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(request.DecisionDigest.VeriKey))
|
||||
{
|
||||
throw new ArgumentException("DecisionDigest.VeriKey is required.", nameof(request));
|
||||
throw new ArgumentException(_t("common.provcache.decision_digest_verikey_required"), nameof(request));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +55,7 @@ public sealed partial class ProvcacheOciAttestationBuilder
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(digest))
|
||||
{
|
||||
throw new ArgumentException("Digest cannot be empty.", nameof(digest));
|
||||
throw new ArgumentException(_t("common.provcache.digest_empty"), nameof(digest));
|
||||
}
|
||||
|
||||
// Handle "sha256:abc123..." format.
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
<ProjectReference Include="../StellaOps.Determinism.Abstractions/StellaOps.Determinism.Abstractions.csproj" />
|
||||
<ProjectReference Include="../../Router/__Libraries/StellaOps.Messaging/StellaOps.Messaging.csproj" />
|
||||
<ProjectReference Include="../../Provenance/StellaOps.Provenance.Attestation/StellaOps.Provenance.Attestation.csproj" />
|
||||
<ProjectReference Include="../StellaOps.Localization/StellaOps.Localization.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using static StellaOps.Localization.T;
|
||||
|
||||
namespace StellaOps.Provcache;
|
||||
|
||||
@@ -12,7 +13,7 @@ public sealed partial class VeriKeyBuilder
|
||||
public VeriKeyBuilder WithMergePolicyHash(string policyHash)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(policyHash))
|
||||
throw new ArgumentException("Policy hash cannot be null or empty.", nameof(policyHash));
|
||||
throw new ArgumentException(_t("common.provcache.policy_hash_required"), nameof(policyHash));
|
||||
|
||||
_mergePolicyHash = NormalizeHash(policyHash);
|
||||
return this;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using static StellaOps.Localization.T;
|
||||
|
||||
namespace StellaOps.Provcache;
|
||||
|
||||
@@ -13,7 +14,7 @@ public sealed partial class VeriKeyBuilder
|
||||
public VeriKeyBuilder WithSbomHash(string sbomHash)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(sbomHash))
|
||||
throw new ArgumentException("SBOM hash cannot be null or empty.", nameof(sbomHash));
|
||||
throw new ArgumentException(_t("common.provcache.sbom_hash_required"), nameof(sbomHash));
|
||||
|
||||
_sbomHash = NormalizeHash(sbomHash);
|
||||
return this;
|
||||
|
||||
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using static StellaOps.Localization.T;
|
||||
|
||||
namespace StellaOps.Provcache;
|
||||
|
||||
@@ -15,7 +16,7 @@ public sealed partial class VeriKeyBuilder
|
||||
public VeriKeyBuilder WithSignerSetHash(string signerSetHash)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(signerSetHash))
|
||||
throw new ArgumentException("Signer set hash cannot be null or empty.", nameof(signerSetHash));
|
||||
throw new ArgumentException(_t("common.provcache.signer_set_hash_required"), nameof(signerSetHash));
|
||||
|
||||
_signerSetHash = NormalizeHash(signerSetHash);
|
||||
return this;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using static StellaOps.Localization.T;
|
||||
|
||||
namespace StellaOps.Provcache;
|
||||
|
||||
@@ -13,7 +14,7 @@ public sealed partial class VeriKeyBuilder
|
||||
public VeriKeyBuilder WithSourceHash(string sourceHash)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(sourceHash))
|
||||
throw new ArgumentException("Source hash cannot be null or empty.", nameof(sourceHash));
|
||||
throw new ArgumentException(_t("common.provcache.source_hash_required"), nameof(sourceHash));
|
||||
|
||||
_sourceHash = NormalizeHash(sourceHash);
|
||||
return this;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using static StellaOps.Localization.T;
|
||||
|
||||
namespace StellaOps.Provcache;
|
||||
|
||||
@@ -12,7 +13,7 @@ public sealed partial class VeriKeyBuilder
|
||||
public VeriKeyBuilder WithTimeWindow(string timeWindow)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(timeWindow))
|
||||
throw new ArgumentException("Time window cannot be null or empty.", nameof(timeWindow));
|
||||
throw new ArgumentException(_t("common.provcache.time_window_required"), nameof(timeWindow));
|
||||
|
||||
_timeWindow = timeWindow;
|
||||
return this;
|
||||
|
||||
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using static StellaOps.Localization.T;
|
||||
|
||||
namespace StellaOps.Provcache;
|
||||
|
||||
@@ -15,7 +16,7 @@ public sealed partial class VeriKeyBuilder
|
||||
public VeriKeyBuilder WithVexHashSet(string vexHashSetHash)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(vexHashSetHash))
|
||||
throw new ArgumentException("VEX hash set hash cannot be null or empty.", nameof(vexHashSetHash));
|
||||
throw new ArgumentException(_t("common.provcache.vex_hash_required"), nameof(vexHashSetHash));
|
||||
|
||||
_vexHashSetHash = NormalizeHash(vexHashSetHash);
|
||||
return this;
|
||||
|
||||
Reference in New Issue
Block a user