Skip to content

[ISSUE] Document Repository Engineering Patterns & Best Practices with External References #249

Done

Description

@marcobuschini

Goal

Identify, catalog, and document the core C++20 systems programming, architectural, testing, and tooling patterns used across milo in one or more dedicated Markdown documents under docs/ (following existing docs/01-*.md–08-*.md conventions and SPDX GPL-3.0-only headers), with concrete repo file references and authoritative web citations justifying each practice.

Proposed Documentation Scope

Create docs/09-design-patterns-and-best-practices.md (and link it from README.md / docs/reference.md if appropriate), covering:

  1. Freestanding C++20 Without Exceptions, RTTI, or atexit
    • Value-based error handling (Result<T, E>, Kernel::DDK::Status), placement new over static storage (drivers/dummy/DummyDriver.cpp), and -fno-use-cxa-atexit singleton discipline (kernel/ddk/KernelPlatformServices.cpp).
    • References: C++ Core Guidelines (Error handling / Freestanding), ARM/Itanium C++ ABI freestanding notes.
  2. RAII & Rule of Five for Deterministic Resource Ownership
    • Move-only, non-copyable handles (DDK::MmioRegion, DmaBuffer, IrqHandle, IrqLock, EventHandle), Sync::IrqGuard, Kernel::Log::ScopedLevel, and TestSession.
    • References: C++ Core Guidelines (R.1, C.21, E.6).
  3. Hardware Isolation, HAL, and Compiler-Enforced DDK Boundaries
    • Separating arch-agnostic kernel/ from arch/aarch64-linux-gnu/ and kernel/hal/targets/qemu_virt/.
    • Capability injection via Kernel::DDK::PlatformServices and compiler-enforced -I$(MILO_DDK_DIR)/include isolation (drivers/ddk.mk, make export-ddk).
    • References: Dependency Inversion Principle, Linux/WDF/Fuchsia driver-framework isolation patterns.
  4. Dual-Target Testing & Zero-Leak Invariants
    • Host-side snitch unit tests with ASan/UBSan + gcovr coverage (tests/host/mocks/host_hal.cpp) alongside QEMU kernel shell (test all) and EL0 userspace (user/test_milo.c) verification.
    • pfa_free_pages_count() baseline conservation checks and Page refcounting (page_get/page_put) for CoW/demand-zero paging.
    • References: Dual-target embedded TDD, AddressSanitizer/UBSan docs, Linux struct page refcounting model.
  5. Observability: Structured Forensic Logging Decoupled from Console UX
    • Separating console verbosity (Kernel::Log::set_level) from IrqGuard-protected ring-buffer capture (logs --json, /dev/kmsg) using JSON Lines (NDJSON).
    • References: JSON Lines specification (jsonlines.org), structured logging best practices.
  6. Automated Quality Gates & Repository Hygiene
    • make quality (clang-format, clang-tidy via compile_commands.json, SPDX GPL-3.0-only header checks, test-host), .githooks/pre_commit, and Conventional Commits.
    • References: SPDX (spdx.dev), Conventional Commits (conventionalcommits.org), Clang-Tidy C++ Core Guidelines checks.

Acceptance Criteria

  • New documentation added under docs/ (with SPDX GPL-3.0-only header) and cross-linked from README.md / docs/reference.md.
  • Every documented pattern cites concrete files/symbols in the repository and includes valid, authoritative web reference links.
  • make license-check passes cleanly.

Activity

  1. self-assigned this
    on Dec 3, 2026
  2. changed the title [-]dev patterns docs[/-] [+][ISSUE] Document Repository Engineering Patterns & Best Practices with External References[/+] on Dec 3, 2026
  3. moved this from Backlog to Todo in kernelite/miloon Dec 3, 2026
  4. moved this from Todo to In progress in kernelite/miloon Dec 3, 2026
  5. moved this from In progress to In review in kernelite/miloon Dec 3, 2026
  6. moved this from In review to Done in kernelite/miloon Dec 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions