Contributing
KDAL is one of three components of the HAVEN Master’s thesis. Contributions must preserve API clarity, QEMU-first reproducibility, and Linux kernel coding discipline.
Where to work. The kernel module (src/, include/, tests/,
scripts/ci/) and the kdality runtime CLI (tools/) are maintained. The
language, the compiler and the editor plugins (lang/, compiler/,
editor/) are frozen since 2026-11-01: still built and checked by CI,
but they take no new work unless the thesis needs them (KDAL’s README,
Repository Layout).
Development Setup
Section titled “Development Setup”# Install build tools./scripts/env/dependencies.sh
# Build everything (compiler, library, tool)./scripts/dev/build.sh --variant debug all
# Prepare the QEMU workspace when you need guest-side validation./scripts/env/prepare.sh./scripts/env/kernel.sh
# Run CI suite./scripts/ci/test.sh
# Install the git hooks (once per clone), then run the quality gatescripts/gate installscripts/gate pre-pushQuality Gate
Section titled “Quality Gate”KDAL uses the quality gate shared by the HAVEN ecosystem
(design).
scripts/gate fetches the gate’s engine from haven at the commit pinned in
quality/gate.json (once, into ~/.cache/haven-gate/) and runs it with
KDAL’s profile:
| Stage | When | Checks |
|---|---|---|
pre-commit |
git commit (hook) |
secrets, personal names and home paths in the staged files |
pre-push |
git push (hook) |
checkpatch.pl (Linux v6.18) on the kernel module, cppcheck, clang-tidy on compiler/ and tools/kdality/, lizard, jscpd, shellcheck, ruff on the files changed against main |
ci |
every pull request, required | the same on the whole tree, plus gitleaks |
Findings are rated BLOCKER, CRITICAL, MAJOR, MINOR or INFO. A BLOCKER always
stops the change; a CRITICAL or MAJOR finding stops it when it is not in
quality/baseline.json. The baseline holds the findings that existed when
the gate started: fix them when you can, and after fixing run
scripts/gate baseline and commit the smaller baseline. Never add new
findings to the baseline to get a change through. scripts/gate doctor
lists the tools found; tools/gate/ci-setup.sh in the engine’s directory
(scripts/gate engine-dir) installs the pinned versions. A newer engine is
taken by changing engine.commit in a pull request of its own.
Code Style
Section titled “Code Style”- Kernel code: Linux kernel coding style (
checkpatch.plclean)- Tabs for indentation, 80-column soft limit
/* C89 comments */kdal_prefix for global symbols- Proper
gotoerror unwinding
- Userspace code: C99 with
-Wall -Wextra -pedantic - Scripts: Bash with
set -euo pipefail
Commit Messages
Section titled “Commit Messages”Use Conventional Commits:
feat(driver): add GPIO driver classfix(chardev): handle partial write correctlytest(kunit): add registry overflow testdocs(api): document new ioctl commandci: add kernel build matrixRules:
- Separate refactors from behavior changes
- One logical change per commit
- Explain why, not just what
- Call out ABI or API impact explicitly
Pull Request Process
Section titled “Pull Request Process”- Fork and create a feature branch
- Implement changes with tests
- Run
./scripts/ci/test.shlocally - Push with the hooks installed (
scripts/gate install), so the gate checks your changes - Submit PR with description of changes and testing done
Architecture Rules
Section titled “Architecture Rules”- No backend-specific types in public headers (
include/kdal/) - No direct hardware access in core or drivers - always through backend ops
- No new ioctl without version bump - see
scripts/release/bump_version.sh - No
printkspam - usepr_debug()for development,pr_info()for lifecycle - No sleeping in registry iteration - callbacks must be non-blocking
Adding a New Driver
Section titled “Adding a New Driver”- Create
src/drivers/example/<name>driver.c - Implement
struct kdal_driver_ops(at minimum:probe,remove,read,write) - Add
init()/exit()functions - Wire into
src/core/kdal.cinit cascade - Add to
Makefile(kdal-y += ...) - Add KUnit tests in
tests/kunit/ - Update
tools/kdality/kdalctl.cdevice class name mapping
Adding a New Backend
Section titled “Adding a New Backend”See the Porting Guide.
Adding a .kdh Standard Library Device
Section titled “Adding a .kdh Standard Library Device”The standard library is part of the frozen lang/; for reference:
- Create
lang/stdlib/<device>.kdh - Define a
device classwithregisters,signals,capabilities,powerandconfigblocks - Follow existing patterns - see
lang/stdlib/uart.kdhas reference - Create a matching example
.kdcfile inexamples/ - Add a test case in
tests/userspace/or extendtest.sh
Modifying the Compiler
Section titled “Modifying the Compiler”The compiler is frozen (above): a change to it needs the thesis to need it,
decided first. For reference, it lives in compiler/ and produces
libkdalc.a + kdalc:
compiler/├── source.c # Reading the source file├── lexer.c # Hand-written tokenizer (about 100 token types)├── parser.c # Recursive descent → arena-allocated AST├── sema.c # Symbol resolution, register validation├── codegen.c # C code generation + Kbuild emitter├── main.c # Standalone kdalc entry point├── fuzz/ # libFuzzer target for the lexer and parser├── CMakeLists.txt # Builds libkdalc.a and kdalc└── include/ # token.h, ast.h, codegen.hRules:
- All public API uses
kdal_prefix (e.g.kdal_lex(),kdal_parse()) - AST nodes are arena-allocated - never free individual nodes
- Codegen must emit kernel-style C - tabs, 80-col, C89 comments
- New token types → update
token.henum + lexer keyword table - New AST nodes → update
ast.hunion + parser + sema + codegen
Testing Requirements
Section titled “Testing Requirements”- All new kernel code must have KUnit tests
- All new ioctl paths must have userspace test coverage
- Integration tests for multi-device interactions
- Benchmark measurements for performance-sensitive changes
License
Section titled “License”Contributions are licensed under GPL-2.0-only (KDAL’s CONTRIBUTING.md,
since 2026-12-03; see Upstreaming). New C
files start with // SPDX-License-Identifier: GPL-2.0-only (.c) or
/* SPDX-License-Identifier: GPL-2.0-only */ (.h).