Engineering Principles & Architectural Contracts¶
Authoritative architectural baseline and engineering laws for
cordanaLLM/nucleus.
1. Authority Classes & Precedence¶
- Class 0 (Legal & Security): Zero-leak privacy invariant (no private RFC 1918 IPs, no workstation paths), licence compliance (
EUPL-1.2, with the per-path terms inREUSE.toml). - Class 1 (Declarative SSOT):
versions.jsonis the sole authority for kernel versions, release tags, kernel sources (URL or repository, the pinnedsha256or commit, and the accepted signers), and the supported architectures with theirARCH, base defconfig and toolchain prefix. - Class 2 (Code Contracts): NASA/JPL Power of 10 rules for shell scripts and automated build tooling.
- Class 3 (Documentation & ADRs): Architectural Decision Records under
docs/govern durable technical strategy.
2. NASA / JPL Power of 10 Adaptations¶
- Rule 1 (Simple Control Flow): Shell scripts must avoid recursion and unbounded loops.
- Rule 2 (Fixed Loop Bounds): All wait loops or retry loops must enforce an explicit maximum counter and timeout.
- Rule 4 (Short Functions): Shell functions must not exceed 60 lines of executable code.
- Rule 5 (Explicit Error Checking): Enforce
set -euo pipefail. Check exit codes of all external commands (wget,tar,patch,make). - Rule 7 (Restricted Scope): Keep shell variables localized (
local var=...). - Rule 9 (Static Analysis): All shell scripts must pass
shellcheckwith zero warnings before merging.
3. Kernel Packaging Contracts¶
- Native Debian Packaging: Builds generate standard
.debpackages via upstreammake bindeb-pkg: linux-image-<kernelrelease>_<debian_version>-lusoris<N>_<debian_arch>.deblinux-headers-<kernelrelease>_<debian_version>-lusoris<N>_<debian_arch>.deblinux-libc-dev_<debian_version>-lusoris<N>_<debian_arch>.deb- Package Versioning: Packages carry a reproducible localversion suffix, e.g.
-lusoris1. - Verified Sources: A kernel source is used only after
scripts/fetch-kernel-source.shhas proven it: a tarball matches its pinned SHA-256 and carries a good kernel.org signature, over the uncompressed tar, by a key the stream lists; a release-candidate tag passesgit verify-tagand points at its pinned commit. The public keys are inkeys/. Anything else is refused (ADR-0008). - Modular KConfig: Avoid monolith
.configfiles. Configuration is partitioned into composable fragments thatscripts/merge-config.shmerges in a fixed order:kconfig/security-hardened.config,kconfig/<arch>.config,kconfig/k8s-node.config, thenkconfig/streams/<stream>.configwhen the stream has one. The last line for a symbol wins,# CONFIG_X is not setincluded, and the output carries no timestamp. Against a verified tree (--source-tree), the fragments are applied with the kernel'sscripts/kconfig/merge_config.sh -mon top of the architecture's defconfig and resolved withmake olddefconfig; there is nokconfig/base.config. - Survival: A resolved configuration is used only when every value a fragment requests is in it unchanged,
# CONFIG_X is not setincluded (scripts/kconfig_survival.py). A fragment lineolddefconfigdropped configures nothing, so the check fails instead of the kernel silently lacking it. A symbol an architecture cannot have belongs in that architecture's fragment, never in a shared one, and the check is never relaxed to make a leg pass. - Claims are checked: Every option the documentation claims a stream builds is listed in
kconfig/required-config.json, and a resolved configuration in which one is off is refused (scripts/check_required_config.py). A claim the forge cannot build is removed from the documentation, never from the list alone.
4. Fuzzing¶
The requirement parser reads documents that other repositories publish, so it is fuzzed as well as tested. fuzz/fuzz_verify_kernel_requirement.py is an Atheris harness over parse_requirement, parse_config_text, release_components and at_least, starting from the seeds in fuzz/corpus/verify_kernel_requirement/.
- A crash is any exception other than
RequirementErrorfromparse_requirementorKconfigErrorfromparse_config_text, any exception from the release helpers, a release with a negative or surplus component, or a release that is not at least itself. make fuzzruns it forFUZZ_SECONDS(default 60) afterpip install --require-hashes -r requirements-fuzz.txt. Atheris ships wheels for x86_64 Linux and Python 3.12 to 3.14 only.- CI runs it for 60 seconds in the
lint-and-testjob, step "Fuzz the requirement parser"; a crash fails the job. tests/test_fuzz_harness.pyruns the seeds and hostile inputs through the harness without Atheris, and plants defects that the harness must report.