Aarkam.Ahmodi.Abstractions 1.0.1

dotnet add package Aarkam.Ahmodi.Abstractions --version 1.0.1
                    
NuGet\Install-Package Aarkam.Ahmodi.Abstractions -Version 1.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Aarkam.Ahmodi.Abstractions" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Aarkam.Ahmodi.Abstractions" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="Aarkam.Ahmodi.Abstractions" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Aarkam.Ahmodi.Abstractions --version 1.0.1
                    
#r "nuget: Aarkam.Ahmodi.Abstractions, 1.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Aarkam.Ahmodi.Abstractions@1.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Aarkam.Ahmodi.Abstractions&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=Aarkam.Ahmodi.Abstractions&version=1.0.1
                    
Install as a Cake Tool

Aarkam.Ahmodi.Abstractions

Zero-Dependency Foundational Contracts, Domain Primitives, Layouts, and Memory Descriptors for .NET Erasure Coding

GitHub Repository NuGet Version NuGet Downloads License: Aarkam Sovereign .NET AOT & Trimming Zero Allocation

GitHub Repository | NuGet Package | Browse Source | Engine Package | License


Overview

Aarkam.Ahmodi.Abstractions is the zero-dependency contract layer and primitive specification for the Aarkam.Ahmodi Erasure Coding Framework. Engineered specifically for mission-critical software-defined storage (SDS), distributed object stores, cloud filesystems, and NVMe-oF storage appliances, it establishes a unified mathematical and memory foundation across all erasure coding implementations.

By maintaining strict zero external dependencies and multi-targeting down to .NET Standard 2.1, Aarkam.Ahmodi.Abstractions decouples storage engine orchestrators, network transport pipelines, and metadata coordinators from specific Galois Field arithmetic or SIMD hardware instruction sets. Every contract enforces a rigorous zero-managed-allocation discipline through modern C# Span<byte>, ReadOnlySpan<byte>, Memory<byte>, and lightweight readonly structures.


Architecture

The diagram below illustrates the relationship between functional contracts, layout definitions, memory buffers, and domain exceptions:

+-----------------------------------------------------------------------------------+
|                          1. FUNCTIONAL CODING CONTRACTS                           |
|                                                                                   |
|   +---------------------------------------------------------------------------+   |
|   |                               IErasureCodec                               |   |
|   |            (Unified Facade: AlgorithmId, Layout, Capabilities)            |   |
|   +---------------------+---------------------+-------------------------------+   |
|                         |                     |                                   |
|                         v                     v                                   |
|              +--------------------+ +--------------------+                        |
|              |   IErasureEncoder  | |   IErasureDecoder  |                        |
|              | Encode / Stripe    | | Decode to Span<T>  |                        |
|              +--------------------+ +--------------------+                        |
|                                     |                                             |
|                                     v                                             |
|                         +-----------------------+                                 |
|                         | IErasureReconstructor |                                 |
|                         | Reconstruct Survivors |                                 |
|                         +-----------------------+                                 |
+-----------------------------------------------------------------------------------+
                                         |
                                         v
+-----------------------------------------------------------------------------------+
|                       2. GEOMETRIC LAYOUT & MEMORY TIER                           |
|                                                                                   |
|  ErasureCodeLayout (readonly struct)      ShardBuffer (readonly struct)           |
|  - K: DataShards                          - Index: [0..TotalShards-1]             |
|  - M: ParityShards                        - Role: Data | Parity | LocalParity     |
|  - L: LocalParityShards                   - Memory / WritableMemory               |
|  - ShardSizeBytes                                                                 |
|  - TotalShards = K + M + L                ShardDescriptor (metadata + CRC32-C)    |
+-----------------------------------------------------------------------------------+
                                         |
                                         v
+-----------------------------------------------------------------------------------+
|                       3. EXTENSIBILITY & ERROR TAXONOMY                           |
|                                                                                   |
|  IErasureCodeProvider                     ErasureCodingException (Base)           |
|  - SupportsAlgorithm(id)                  |-- InsufficientShardsException         |
|  - CreateCodec(options)                   |-- SingularMatrixException             |
|                                           |-- CorruptedShardException (Bit-Rot)   |
|  IErasureCodeFactory                      |-- InvalidStripeLayoutException        |
|  - CreateCodec / RegisterProvider         `-- ShardValidationException            |
+-----------------------------------------------------------------------------------+

Key Features

  • Zero External Dependencies: Pure .NET Standard 2.1 / C# contract package with no third-party dependencies, making it ideal for low-level SDKs and shared storage primitives.
  • Zero Garbage Collection Overhead: All hot-path methods accept ReadOnlySpan<byte>, Span<byte>, ReadOnlySpan<ReadOnlyMemory<byte>>, and Span<Memory<byte>> for allocation-free execution.
  • Strict Geometric Layout Model: ErasureCodeLayout formally defines data shards (K), global parity shards (M), local parity shards (L), and shard byte lengths (S), enforcing mathematical consistency.
  • Orthogonal Interface Segregation: Clean separation between IErasureEncoder, IErasureDecoder, and IErasureReconstructor allows specialized hardware engines or pure regenerators to implement only the operations they support.
  • Immutable Metadata Descriptors: ShardDescriptor captures placement role, local repair group identity, and Castagnoli CRC32-C checksums for automated bit-rot tracking.
  • Pluggable Provider Architecture: IErasureCodeProvider and IErasureCodeFactory allow storage engines to dynamically register custom Galois Field implementations, GPU offload engines, or research algorithms.
  • Native AOT & Trimming Compliant: Fully annotated and tested for ahead-of-time (AOT) compilation without reflection or dynamic code generation.

Target Frameworks

Runtime Target Framework Compatibility Native AOT
.NET 10.0 net10.0 Full API & Preview C# Features Supported
.NET 8.0 (LTS) net8.0 Long-Term Support Engine Target Supported
.NET 6.0 (LTS) net6.0 Cross-Platform Compatibility Supported
.NET Standard 2.1 netstandard2.1 Broad Ecosystem & Legacy Host Interop Supported

Installation

.NET CLI

dotnet add package Aarkam.Ahmodi.Abstractions

Visual Studio Package Manager Console

Install-Package Aarkam.Ahmodi.Abstractions

PackageReference (MSBuild)

<PackageReference Include="Aarkam.Ahmodi.Abstractions" Version="1.0.1" />

Paket CLI

paket add Aarkam.Ahmodi.Abstractions

Primitives Catalog

Namespace Key Types Primary Responsibility
Aarkam.Ahmodi.Abstractions IErasureCodec, IErasureEncoder, IErasureDecoder, IErasureReconstructor Foundational contracts governing stripe encoding, payload decoding, and shard reconstruction.
Aarkam.Ahmodi.Abstractions ErasureCodeLayout Immutable readonly record struct defining stripe geometry (K, M, L, and S), capacity, and layout validation.
Aarkam.Ahmodi.Abstractions ErasureCodeCapabilities Bitwise flags describing algorithm properties (MDS status, local repair capabilities, hardware acceleration).
Aarkam.Ahmodi.Abstractions ErasureCodeOptions Strongly typed configuration container capturing algorithm identifiers, target layout, and execution preferences.
Aarkam.Ahmodi.Abstractions ShardBuffer, ShardRole, ShardDescriptor Value-type wrappers associating stripe indices and roles (Data, Parity, LocalParity) with memory slices and CRC32 checksums.
Aarkam.Ahmodi.Abstractions.Providers IErasureCodeProvider, IErasureCodeFactory Pluggable Service Provider Interface (SPI) for registering and instantiating custom erasure coding algorithms.
Aarkam.Ahmodi.Abstractions.Exceptions ErasureCodingException, InsufficientShardsException, SingularMatrixException, CorruptedShardException Strongly typed domain exception hierarchy for deterministic error handling and bit-rot isolation.

Code Examples

1. Working with ErasureCodeLayout and Geometric Properties

ErasureCodeLayout validates stripe geometry at creation time and provides precomputed capacity and storage-overhead metrics:

using Aarkam.Ahmodi.Abstractions;

// Define an 8+3 Cauchy Reed-Solomon layout with 64 KB shard payloads
var layout = new ErasureCodeLayout(
    dataShards: 8,
    parityShards: 3,
    shardSizeBytes: 64 * 1024);

Console.WriteLine($"Total Shards (K+M):       {layout.TotalShards}");         // 11
Console.WriteLine($"Stripe Data Capacity:     {layout.StripeDataSizeBytes} B"); // 524,288 B (512 KB)
Console.WriteLine($"Total Physical Footprint: {layout.TotalStripeSizeBytes} B"); // 720,896 B (704 KB)
Console.WriteLine($"Storage Efficiency:       {layout.StorageEfficiency:P2}");  // 72.73%
Console.WriteLine($"Storage Overhead:         {layout.StorageOverhead:P2}");    // 37.50%

// Query shard classification
ShardRole role = layout.GetShardRole(shardIndex: 9); // ShardRole.Parity

2. High-Performance Zero-Allocation Shard Decoding

Use IErasureDecoder with ShardBuffer to decode surviving shards directly into a caller-supplied memory destination:

using Aarkam.Ahmodi.Abstractions;

public void ProcessReadPipeline(IErasureDecoder decoder, IReadOnlyList<ShardBuffer> availableShards)
{
    var layout = decoder.Layout;
    
    // Allocate destination buffer on the stack, unmanaged memory, or leased array
    Span<byte> destination = stackalloc byte[(int)layout.StripeDataSizeBytes];

    // Decode directly into the destination buffer with zero heap allocations
    decoder.Decode(availableShards, destination);

    // Process reconstructed user payload
    ProcessUserPayload(destination);
}

3. Reconstructing Missing Shards with ShardBuffer

Use IErasureReconstructor to recover multiple erased shards simultaneously:

using Aarkam.Ahmodi.Abstractions;

public void PerformShardRepair(
    IErasureReconstructor reconstructor,
    IReadOnlyList<ShardBuffer> survivingShards,
    int missingIndexA,
    int missingIndexB)
{
    var layout = reconstructor.Layout;

    // Prepare target memory buffers for missing shards
    Memory<byte> targetMemoryA = new byte[layout.ShardSizeBytes];
    Memory<byte> targetMemoryB = new byte[layout.ShardSizeBytes];

    Span<ShardBuffer> missingTargets = stackalloc ShardBuffer[2]
    {
        new ShardBuffer(missingIndexA, targetMemoryA, layout.GetShardRole(missingIndexA)),
        new ShardBuffer(missingIndexB, targetMemoryB, layout.GetShardRole(missingIndexB))
    };

    // Reconstruct missing shards mathematically
    reconstructor.Reconstruct(survivingShards, missingTargets);

    // Persist newly reconstructed shards back to storage nodes
    WriteShardToDisk(missingIndexA, targetMemoryA);
    WriteShardToDisk(missingIndexB, targetMemoryB);
}

4. Robust Domain Error Handling & Bit-Rot Isolation

Handle structured domain exceptions to isolate silent corruption and insufficient survivors:

using Aarkam.Ahmodi.Abstractions;
using Aarkam.Ahmodi.Abstractions.Exceptions;

try
{
    reconstructor.Reconstruct(availableShards, missingTargets);
}
catch (CorruptedShardException ex)
{
    // Silent bit-rot detected via CRC32-C mismatch
    Console.Error.WriteLine($"[ALERT] Shard {ex.ShardIndex} suffered silent bit-rot!");
    Console.Error.WriteLine($"Expected CRC: 0x{ex.ExpectedChecksum:X8}, Got: 0x{ex.ActualChecksum:X8}");
    
    // Isolate the corrupted shard and trigger parity reconstruction
    QuarantineCorruptedShard(ex.ShardIndex);
}
catch (InsufficientShardsException ex)
{
    // Catastrophic data loss threshold: available shards < required shards
    Console.Error.WriteLine($"[FATAL] Stripe unrecoverable: only {ex.AvailableShards} available, need {ex.RequiredShards}.");
    NotifyDisasterRecovery(ex);
}
catch (SingularMatrixException ex)
{
    // Matrix inversion singularity (linear dependency in survivor subset)
    Console.Error.WriteLine($"[ERROR] Matrix inversion failed at pivot column {ex.SingularColumn}.");
}

5. Inspecting Algorithm Capabilities

Query ErasureCodeCapabilities at runtime to negotiate optimal repair paths:

using Aarkam.Ahmodi.Abstractions;

public void RouteRepairTask(IErasureCodec codec, int missingShardIndex)
{
    if (codec.Capabilities.HasFlag(ErasureCodeCapabilities.SupportsLocalRebuild))
    {
        // Locally Repairable Code (e.g. Azure LRC): recover using small local XOR group
        Console.WriteLine("Executing fast single-shard local group repair (sub-linear network I/O)...");
    }
    else if (codec.Capabilities.HasFlag(ErasureCodeCapabilities.IsMds))
    {
        // Full MDS Code (e.g. Cauchy Reed-Solomon): recover using global matrix inversion
        Console.WriteLine("Executing global MDS matrix reconstruction...");
    }
}

Extensibility

Implementing a Custom Erasure Codec

To integrate a proprietary coding algorithm, hardware accelerator (e.g. GPU / FPGA), or research code into the Aarkam ecosystem, implement IErasureCodec:

using Aarkam.Ahmodi.Abstractions;

public sealed class CustomHwAcceleratedCodec : IErasureCodec
{
    public string AlgorithmId => "custom-fpga-rs";
    public ErasureCodeLayout Layout { get; }
    public ErasureCodeCapabilities Capabilities =>
        ErasureCodeCapabilities.IsMds |
        ErasureCodeCapabilities.HardwareAccelerated;

    public CustomHwAcceleratedCodec(ErasureCodeLayout layout)
    {
        Layout = layout;
    }

    public void Encode(ReadOnlySpan<byte> data, Span<byte> parity)
    {
        // Delegate to hardware offload or custom vector routine
    }

    public void EncodeStripe(ReadOnlySpan<ReadOnlyMemory<byte>> dataShards, Span<Memory<byte>> parityShards)
    {
        // Scattered stripe encoding
    }

    public void Decode(IReadOnlyList<ShardBuffer> shards, Span<byte> destination)
    {
        // Reconstruct and output contiguous data
    }

    public void Reconstruct(IReadOnlyList<ShardBuffer> available, Span<ShardBuffer> missing)
    {
        // Custom mathematical reconstruction
    }

    public void Reconstruct(
        ReadOnlySpan<ReadOnlyMemory<byte>> survivingShards,
        ReadOnlySpan<int> survivingIndices,
        Span<Memory<byte>> targetShards,
        ReadOnlySpan<int> targetIndices)
    {
        // Zero-allocation span-based reconstruction
    }
}

Implementing IErasureCodeProvider

Expose your custom codec to the framework registry via IErasureCodeProvider:

using Aarkam.Ahmodi.Abstractions;
using Aarkam.Ahmodi.Abstractions.Providers;

public sealed class CustomCodecProvider : IErasureCodeProvider
{
    public bool SupportsAlgorithm(string algorithmId) =>
        string.Equals(algorithmId, "custom-fpga-rs", StringComparison.OrdinalIgnoreCase);

    public IErasureCodec CreateCodec(ErasureCodeOptions options)
    {
        return new CustomHwAcceleratedCodec(options.Layout);
    }
}

Performance & Design Philosophy

  1. Zero Heap Allocation on Hot Paths: High-throughput distributed storage engines cannot tolerate Garbage Collection pauses. All core APIs are strictly span-oriented and allow caller-managed memory buffers.
  2. Deterministic Layout Arithmetic: Every capacity, offset, and index operation within ErasureCodeLayout is verified for non-overflow and consistent alignment across all target runtimes.
  3. Structured Domain Exceptions: Avoids generic exceptions (InvalidOperationException, IndexOutOfRangeException) in favor of strongly typed domain exceptions that preserve diagnostic metadata (AvailableShards, SingularColumn, ExpectedChecksum).
  4. Native AOT & Trimming First: Designed for lightweight microservices and sovereign storage appliances with zero runtime reflection and trimmed compatibility.

Building from Source

git clone https://github.com/aarkamio/Aarkam.Ahmodi.git
cd Aarkam.Ahmodi

# Build Abstractions library across all target frameworks
dotnet build src/Aarkam.Ahmodi.Abstractions/Aarkam.Ahmodi.Abstractions.csproj --configuration Release

# Pack NuGet package
dotnet pack src/Aarkam.Ahmodi.Abstractions/Aarkam.Ahmodi.Abstractions.csproj --configuration Release

Contributing

Contributions, issues, and feature requests are welcome!

  1. Fork the repository on GitHub: https://github.com/aarkamio/Aarkam.Ahmodi
  2. Create your feature branch (git checkout -b feature/amazing-contract).
  3. Commit your changes (git commit -m 'feat: Add amazing contract').
  4. Push to the branch (git push origin feature/amazing-contract).
  5. Open a Pull Request on GitHub.

Authors & Maintainers


License

This software is governed by the Aarkam Sovereign Commercial Enterprise Software License Agreement (ASCEL-v1.0).

Copyright (c) 2026 Aarkam Inc. (https://aarkam.io/) & Mohamed Elhelbawi (https://github.com/melhelbawi).
All rights reserved.

See the full LICENSE file on GitHub for terms regarding commercial production deployment, cluster capacity ceilings, and sovereign evaluation. For commercial licensing inquiries, contact support@aarkam.io.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.1

    • No dependencies.
  • net10.0

    • No dependencies.
  • net6.0

    • No dependencies.
  • net8.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Aarkam.Ahmodi.Abstractions:

Package Downloads
Aarkam.Ahmodi

Ultra-high-performance, zero-allocation, hardware-accelerated .NET Erasure Coding Engine engineered for enterprise object stores, distributed filesystems, and NVMe-oF storage appliances. Supports 10 algorithm families (Cauchy & Vandermonde Reed-Solomon, Azure & Pyramid LRC, RAID-5/RDP/EVENODD/Liberation XOR array codes, and MSR/MBR Regenerating codes) with AVX-512BW, AVX2, SSSE3, ARM64 NEON, and Scalar backends, self-healing CRC32-C bit-rot scrubbing, throttled repair orchestration, and OpenTelemetry observability.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.1 122 11/11/2026