{"id":51271411,"url":"https://github.com/d-plaindoux/zigma","last_synced_at":"2026-06-29T18:05:56.544Z","repository":{"id":364987667,"uuid":"1270007784","full_name":"d-plaindoux/zigma","owner":"d-plaindoux","description":"Zig signature implementation framework","archived":false,"fork":false,"pushed_at":"2026-06-24T06:11:46.000Z","size":35,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-24T08:12:59.609Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Zig","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/d-plaindoux.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-06-15T09:45:09.000Z","updated_at":"2026-06-24T06:11:50.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/d-plaindoux/zigma","commit_stats":null,"previous_names":["d-plaindoux/zigma"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/d-plaindoux/zigma","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d-plaindoux%2Fzigma","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d-plaindoux%2Fzigma/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d-plaindoux%2Fzigma/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d-plaindoux%2Fzigma/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/d-plaindoux","download_url":"https://codeload.github.com/d-plaindoux/zigma/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d-plaindoux%2Fzigma/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34937453,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-29T02:00:05.398Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-06-29T18:05:55.781Z","updated_at":"2026-06-29T18:05:56.538Z","avatar_url":"https://github.com/d-plaindoux.png","language":"Zig","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Zigma\n\n**Algebraic Abstractions, Formal Invariants, and Zero-Cost Contracts for Zig.**\n\nZigma is a lightweight, zero-cost framework that brings the power of modularity—inspired by OCaml functors, and Rust traits—to systems programming in Zig. By leveraging pure `comptime` reflection, Zigma allows you to define strict **specifications** bundled with mathematical **invariants**, guaranteeing that your implementations are correct by construction with absolutely zero runtime overhead.\n\n---\n\n## The Problem\nIn systems programming, interfaces are often implicit (duck typing) or polymorphic at runtime (VTables). \n* **Implicit interfaces** lead to cryptic compiler errors deep within your generics when an implementation breaks a contract.\n* **Runtime interfaces** (like `std.mem.Allocator`) introduce pointer indirections and prevent compiler optimizations.\n* More importantly, traditional interfaces only check *types*, not *logic*. They cannot guarantee that your data structures respect the necessary semantic laws (invariants) during development.\n\n## The Zigma Solution\nZigma allows you to treat algebraic specifications as first-class citizens. By combining compile-time introspection with an ergonomic, Rust-inspired DSL, Zigma:\n1. **Validates Signatures:** Ensures your structures strictly adhere to the required contract before running any code.\n2. **Embeds Semantic Invariants:** Bundles mathematical assertions (e.g., Stack LIFO behavior) directly within the specification.\n3. **Guarantees Maximum Performance:** Uses compile-time evaluation and forced inlining to completely erase the abstraction barrier in the final machine code.\n\n---\n\n## Sketch\n\n\u003e NOTE: Work in progress for the design and the implementation\n\n### 1. Define the Specification and Invariants\nDeclare your interface layout and embed its mathematical laws directly within the struct namespace. Notice we can also use of `callconv(.@\"inline\")` to enforce performance constraints.\n\n```zig\nconst std = @import(\"std\");\nconst Pair = ...;\n\nfn Stack(comptime T: fn (type) type, comptime A: type) type {\n    return struct {\n        \n        create: fn () callconv(.@\"inline\") T(A),\n        push: fn (std.mem.Allocator, A, T(A)) anyerror!T(A),\n        peek: fn (T(A)) ?A,\n        pop: fn (std.mem.Allocator, T(A)) Pair(?A, T(A)),\n\n        //\n        // Invariants\n        // \n        \n        fn @\"S.peek(S.create()) = null\"(Impl: @This()) !void {\n            const stack = Impl.create();\n            try std.testing.expectEqual(null, Impl.peek(stack));\n        }\n        \n        fn @\"S.peek(S.push(a, S.create())) = a\"(\n            Impl: @This(),\n            allocator: std.mem.Allocator,\n            a: A,\n        ) !void {\n            const stack = try Impl.push(allocator, a, Impl.create());\n            defer @TypeOf(stack).deinit(allocator, stack);\n\n            try std.testing.expectEqual(a, Impl.peek(stack));\n        }\n        \n        // ...\n        \n        pub fn checkInvariants(Impl: @This(), allocator: std.mem.Allocator, a: A) !void {\n            try Impl.@\"S.peek(S.create()) = null\"();\n            try Impl.@\"S.peek(S.push(a, S.create())) = a\"(allocator, a);\n        }\n    };\n}\n```\n\n### 2. Implement a Pure Incarnation\n\nYour implementation remains a clean, decoupled, and highly cohesive struct. It does not need to know about the specification or metadata; it just provides the functions.\n\n```zig\nfn StackList(comptime A: type) type {\n    return struct {\n        inline fn create() List(A) { \n            return .nil(); \n        }\n        \n        fn push(allocator: std.mem.Allocator, a: A, l: List(A)) anyerror!List(A) {\n            return try .cons(allocator, a, l);\n        }\n        \n        fn peek(l: List(A)) ?A { \n            // ... \n        }\n        \n        fn pop(allocator: std.mem.Allocator, l: List(A)) Pair(?A, List(A)) { \n            // ... \n        }\n    };\n}\n\n```\n\n### 3. Bind and Verify via the DSL\n\nUse Zigma's `impl` DSL to safely instantiate and test your implementation against the specification.\n\n```zig\ntest \"should check Stack invariants for StackList incarnation\" {\n    const allocator = std.testing.allocator;\n\n    // Bind the incarnation to the specification (Rust-like syntax)\n    const checker = impl(Stack(List, u32)).with(StackList(u32));\n\n    // Run the embedded algebraic tests\n    try checker.checkInvariants(allocator, 42);\n}\n\n```\n\n---\n\n## Key Features\n\n### Compile-Time Contract Enforcement\n\nNo more runtime crashes due to mismatched interfaces. If your implementation misses a method or alters a signature, Zigma halts the compilation immediately with clean, tailored, and descriptive error messages pointing out exactly what is wrong.\n\n### Guaranteed Inlining (`callconv(.@\"inline\")`)\n\nUnlike traditional interface patterns that rely on function pointers or VTables, Zigma allows you to enforce inlining constraints directly at the signature level. By applying `callconv(.@\"inline\")` to the specification's function types, the compiler **forces** the incarnation's code directly into the call site. This eliminates function call overhead entirely (no register saving, no stack manipulation) and unlocks powerful compiler optimization passes across your abstraction boundaries.\n\n### Property-Based Design\n\nDecouple your architecture from your validation logic. Write your invariant test suites once inside the specification struct, and automatically execute them against *any* present or future implementation of that interface.\n\n---\n\n## Core Architecture\n\nZigma operates on a highly clean 2-tier abstraction structure, all resolved during compilation:\n\n* **The Engine (`Validator`):** Handles static introspection and structural mapping.\n* **The DSL (`implement`):** Exposes an ergonomic `implement(Spec).with(Impl)` syntax.\n\n---\n\n## Why Use Zigma?\n\n* **For Library Authors:** Expose bulletproof abstractions. When users implement your traits, they are instantly warned by the compiler if they break either your structural layout or your behavioral invariants.\n* **For Systems Engineers:** Safely encapsulate critical, low-level components (allocators, database engines, network protocols) without sacrificing raw performance.\n* **For Functional Programmers:** Bring the mathematical rigor of Algebraic Data Types and Module Functors directly into a low-level language.\n\n## License\n\n```\nMIT License\n\nCopyright (c) 2026 Didier Plaindoux\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fd-plaindoux%2Fzigma","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fd-plaindoux%2Fzigma","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fd-plaindoux%2Fzigma/lists"}