Current Version: v26.04.24
- MANDATORY: All project documentation, specifications, manuals, test logs, and code comments MUST be written strictly in English.
- Enforcement: Any new documentation or updates to existing files must be reviewed for language consistency. This is to ensure global accessibility and alignment with international open-source standards.
- Rule: Every design change or new feature request begins with the Specification (
/SPEC.md) and the User Manual (/manual/). - Process:
- Update
SPEC.mdto reflect architectural changes. - Update relevant documentation in
/manual/*.mdsimultaneously. - Ensure all changes maintain the "Strict Bottom-Up" and "No-CRT" principles.
- Update
- Modern C: Strictly adhere to the C23 standard. Leverage C23 features (e.g.,
[[nodiscard]],stdckdint.h,_BitInt) while ensuring strict compatibility with freestanding environments. - Type System Integrity:
- Custom Types: Define and use custom types like
proven_u8,proven_i32,proven_size_tto isolate the core from the external environment and clarify intent. Avoid direct use of primitive types (int,long) and conduct rigorous reviews of range and signedness. - Index & Size: Strictly distinguish between
proven_size_tfor data size and indexing, andproven_ptrdiff_t(based onptrdiff_t) for pointer differences or offsets.
- Custom Types: Define and use custom types like
- Naming Conventions:
- Identifiers: Use lower snake case (
snake_case) for variable and function names. - Typedefs: All explicitly defined type names (including structs and enums) MUST end with the
_tsuffix (e.g.,proven_mem_t). Basic fixed-width integer types (e.g.,proven_u8) are exempt from the_tsuffix to maintain brevity and align with project style. - Macros: All macros MUST use upper snake case (
UPPER_SNAKE_CASE).
- Identifiers: Use lower snake case (
- Portability: Proactively address C standard portability issues. Avoid implementation-defined behavior unless explicitly wrapped in the platform abstraction layer.
- Safety & UB: Conduct rigorous reviews to eliminate Undefined Behavior (UB). Every memory access and arithmetic operation must be verified for safety.
- Strict Aliasing & Provenance: Always consider provenance rules and strict aliasing for optimized, bug-free code.
- Provenance-Aware Types: Use
proven_byte_tandproven_mem_tto ensure the compiler can optimize safely without violating memory rules. - Low-Level Optimization:
- Memory & Cache: Ensure proper memory alignment and data locality to maximize CPU cache hits.
- CPU Efficiency: Optimize for register utilization and minimize branch mispredictions by reducing complex conditional branching where possible.
- Zero-Overhead: Code must be as efficient as a manual implementation while remaining bug-free and safe.
- Value-Return (Result Pattern): Functions that can fail MUST return a
Resulttype structure (e.g.,proven_result_mem_mut_t) containing both the error code (proven_err_t) and the value, rather than using output pointers. - Explicit Control Flow: Do NOT use magic macros (like
PROVEN_TRY) to hide early returns. Error propagation MUST be explicit using standardif (res.err != PROVEN_OK)checks to maintain code visibility and debuggability. - No Partial Free: Memory allocations are managed strictly by the Arena. Never attempt to
freeor rollback memory on error. - Resource Cleanup: For non-memory system resources (files, sockets), use the standard C
goto cleanup_xxx;pattern to enforce a Single-Entry Single-Exit (SESE) strategy. Do NOT rely on non-standarddeferextensions.
- nob.h: The project strictly uses
nob.h(from tsoding) for its build system.MakefileorCMakeLists.txtare NOT allowed. - Build Script: The build script MUST be written in
nob.cat the root of the project. - Compilation: To build the project, first compile the build script (
cc nob.c -o nob), then run./nobto build the library and tests.
- Test-Driven Development: Implementation MUST follow the TDD cycle:
- Write failing unit tests first in the
/tests/directory as plain C source files. No external test frameworks are used; tests are compiled usingnob.cand run manually. - Implement the minimum code to pass the tests.
- Refactor while maintaining architectural integrity.
- Write failing unit tests first in the
- Validation: Use static analysis and runtime sanitizers to ensure UB-free implementation during the testing phase.
- Dependency Isolation (The Platform Layer): Any inevitable reliance on the standard library (libc) or OS APIs MUST be strictly isolated into the
/platform/abstraction layer (e.g.,proven_sys_mem.h). The core library (/src/proven/) is FORBIDDEN from directly including<stdlib.h>or OS headers. - Polymorphic VTable Allocator Constraint: All core systems and object creation pipelines in the project MUST fundamentally rely on the single polymorphic
proven_allocator_ttrait. They must NOT tightly couple to specific implementations like Arena or Heap internally. Existing specific allocators (e.g.,proven_heap_allocator()) must be implemented as vtable interface patterns that route strictly through the aforementioned/platform/layer. - License: The project is licensed under the MIT License.
- Compatibility: Any external code/library MUST be strictly compatible with the MIT License. GPL-style copyleft or restrictive commercial licenses are forbidden.
/SPEC.md: Root specification and design document./AGENTS.md: Core project working guidelines (this file)./manual/: User and developer manuals./include/: Public headers (.h)./src/: Library implementation files (.c)./tests/: TDD unit tests and test runners./platform/: Platform abstraction layer (isolation of external syscalls/libs).
- English Only: All project documentation, including specifications (
SPEC.md), test logs (TEST.md), architectural decisions, user manuals, and code comments, MUST be written strictly in English. This ensures global accessibility and consistency across the codebase. - No Emojis or Pictograms: When creating or updating documents, you MUST NOT include weird unicode emojis, pictograms, or symbol characters (e.g., 🚀, ⚡, ✅, etc.). Maintain a strictly professional text-based format.
- Rule: Whenever files are modified by AI through chat, the
include/proven/version.hfile MUST be updated with the current date (format: YY.MM.DD). - Process: Update
PROVEN_VERSION_STRING(e.g.,"proven_c_lib-v26.04.24") andPROVEN_VERSION_NUM(e.g.,260424) ininclude/proven/version.h. - Documentation: Synchronize the new version number (
v26.04.24) intoSPEC.md,AGENTS.md,index.html, and all Markdown manuals inside the/manual/folder.
- index.html Footer: The footer section at the bottom of the screen in
index.htmlMUST display the following information exactly:- Creator ID:
rubidus-api - Email:
rubidus@gmail.com - GitHub URL:
https://github.com/rubidus-api/proven_c_lib/ - License Information: MIT License
- Example format:
Creator: rubidus-api | Email: rubidus@gmail.com | GitHub: <a href="https://github.com/rubidus-api/proven_c_lib/">https://github.com/rubidus-api/proven_c_lib/</a> | License: MIT License
- Creator ID: