This document outlines the rules AI agents must follow when checking out branches, writing code, documenting features, and running the development environment. Follow these rules carefully:
- Commit Subject: Must follow the format
subsystem: component: short descriptionmatching the SOF project convention. Use the git history of the modified file(s) (git log --oneline -10 -- <file>) to determine the correct subsystem and component prefix. Examples:audio: chain_dma: add user-space scheduling supportipc4: handler: fix large config dispatchschedule: zephyr_domain: add user-space LL thread
- Commit Body: Should describe the changes in detail in the commit message body.
- Sign-off: All commits must be signed off by the developer (
Signed-off-by: Name <email>) using the identity from the local git config.
- Doxygen Comments: Any new C code or features must include Doxygen comments.
- Documentation Builds: Integration of new code must not introduce any new Doxygen errors or warnings. Code additions should be verified against a clean documentation build.
- Architectural Consistency: When adding or updating a file, any
architecture.mdorREADME.mdin the same directory must be reviewed. The agent is responsible for ensuring documentation stays in sync with code logic changes.
- Standard: Use
clangdinstead ofcheckpatchfor codestyle verification. - Rationale:
checkpatchis prone to confusion with assembly and non-standard C;clangdprovides better integration with IDEs and AI tools and is easier to maintain.
On PTL and other userspace configurations, audio application logic runs in Zephyr user-space
while the OS/HAL stays in the kernel. The authoritative model, directory taxonomy, syscall map,
memory-partition markers and Kconfig hierarchy are documented in
src/include/sof/userspace/README.md. When adding or
moving code, follow it:
- Place code in the right tier. OS/HAL/boot/inter-core → a kernel-only directory
(
arch/,drivers/,idc/,init/,platform/,probe/,logging/,trace/); audio application logic →audio/; reusable pure code → a shared-library directory (lib/,math/,module/) kept free of privileged operations. Each top-level directory'sREADME.mdstates its tier in a "Runs in:" banner — keep it accurate. - Cross the boundary only via a syscall. Add a
__syscalldeclaration, put thez_vrfy_validator in the boundary tier (preferablyzephyr/syscall/<subsystem>.c), validate every user-supplied argument, and add the call tosrc/include/sof/userspace/syscalls.h. - Mark shared globals. Any global a user thread reads or writes must carry a partition
marker (
APP_TASK_*,APP_SYSUSER_*, or aK_APP_*partition) at its declaration site, and kernel code must re-validate such data because it is user-writable.