Imported from 0202alcc/luvatrix (
AGENTS.md). Install upstream withnpx skills add 0202alcc/luvatrix. Copyright stays with the author.
AGENTS
Repository-level operating rules and quick-start context for human and AI contributors.
Read First
- Inspect the code before planning or editing. Use
rg,rg --files, targetedsed, and existing tests to understand current patterns. - Check
git status --short --branchbefore changing files. The worktree may contain user or agent changes; do not revert unrelated work. - Prefer small, task-focused changes with matching tests. A task is complete only after relevant verification passes or the blocker is documented.
Current Codebase Shape
luvatrix/is the public app-developer API package. Useluvatrix.appfor stable app-facing imports such asAppContext, manifest helpers, platform constants, and install validation.luvatrix_core/contains runtime internals:core/: app protocol, manifest parsing, lifecycle/runtime loops, HDI, sensors, scene graph, window matrix, debug/audit support.targets/: render target abstractions and adapters such as Metal, Vulkan, CPU scene, and web targets.platform/: platform-specific integrations. Imports fromplatform.macos,platform.ios, andplatform.webshould stay lazy unless the selected render path needs them.
luvatrix_ui/contains first-party UI contracts, controls, text rendering, planes protocol/runtime, and planning/table helpers.luvatrix_plot/contains plotting APIs, raster drawing, adapters, scales, and app-protocol compile helpers.main.pyis the CLI entrypoint.luvatrix validate-app ...validates app manifests and optional render dependencies;luvatrix run-app ...launches an app protocol folder.
Packaging and Optional Runtime Policy
luvatrixis one Python distribution with optional extras, not split distributions.- Keep base dependencies usable for manifest loading, public API imports, and headless app validation/runs.
- Platform-heavy dependencies must stay in extras:
macos: PyObjC/AppKit/Quartz/Metal runtime support.vulkan: Python Vulkan binding only; native Vulkan SDK/MoltenVK is still installed outside pip.web: websocket runtime support.ios: reserved for Python-installable iOS helpers; native Xcode packaging remains outside pip.trading: Coinbase/trading-dashboard dependencies.
- Do not add eager top-level imports of macOS, iOS, Vulkan, or web modules from public API or CLI import paths. Missing extras should fail only when the matching renderer is selected, with an actionable install hint.
App Protocol Conventions
- App folders use
app.tomlplus a Python entrypoint such asapp_main:create. app.tomlis the source of truth for app support declarations:- Use
platform_support = ["macos", "ios"]for a shared Apple-platform app. - Use
[[variants]]only when a platform or architecture needs a differentmodule_rootorentrypoint.
- Use
- Keep app lifecycle objects compatible with
init(ctx),loop(ctx, dt), andstop(ctx). - Validate platform support and optional dependency availability through
luvatrix.app.check_app_installorluvatrix.app.validate_app_install. - Scroll-heavy scene apps should build stable content-space primitives with
App.frame(..., retained=True, content_offset=(x, y)). After the retained scene exists, useApp.set_scene_content_offset(x, y)for transform-only revisions that do not rebuild nodes. On native Metal this preserves geometry buffers and applies scrolling as a GPU transform; do not pre-translate every primitive unless its content actually changed. - Apps without continuous animation may call
set_continuous_render(False)and useinvalidate()after data or state changes. Input consumed throughInputManager.snapshot()invalidates automatically. - Use
luvatrix.app.ScrollbarControllerfor custom scene scrollbars. It supplies track clicking, thumb-anchor dragging, pointer capture outside the track, release handling, and horizontal/vertical parity; keep painted scrollbar geometry separate from a comfortably sized interaction target.
Python Tooling Policy
- Use
uvfor Python workflows:uv syncuv run pytest ...uv run python ...
- Do not use bare
pythonorpipunless blocked by environment constraints. If blocked, document the reason and fallback. - For tests, prefer focused coverage first, then broaden only when the touched surface warrants it.
Test-First Development Policy
- For every behavior change or bug fix, write or update the test that defines the expected behavior before implementing the production change.
- Confirm the new or changed test fails for the expected reason before implementation, then make the smallest change that makes it pass.
- Tests must describe externally meaningful behavior and include relevant error or boundary cases; do not couple assertions to implementation details merely to raise coverage.
- Keep tests and implementation on the same feature branch. Separate test and implementation commits are encouraged when practical, but commit shape is not a merge requirement.
- Behavior-changing pull requests must complete the test-first evidence in the pull request template and pass the
required-testscheck before merging intodev. - Documentation, metadata, generated artifacts, and provably behavior-neutral mechanical refactors may use the documented exception, with the reason recorded in the pull request.
- See
CONTRIBUTING.mdfor the complete workflow and reviewer expectations.
Security Gate Policy
- Pull requests into
dev,staging, andmainmust pass the aggregatesecurity-reviewcheck described inSECURITY.md. - Do not weaken or suppress dependency, secret, Python SAST, or GitHub Actions findings merely to make CI green. Document narrow false-positive or accepted-risk exceptions.
- The agent-review files under
.github/security/are a provider-neutral contract only. Do not add credentials or enable model execution without an explicit security review of the workflow trust boundary.
Git and Branch Policy
- Use one descriptive feature branch per feature, such as
feature/platform-scoped-packageorfix/lazy-platform-imports. - Use the promotion ladder
feature/* -> dev -> staging -> main. - Every promotion happens through a pull request: feature branches target
dev,devtargetsstaging, andstagingtargetsmain. - Treat
mainas production andstagingas the pre-production soak branch for catching integration issues before release. - Local git inspection, staging, commits, and branch-local checks are allowed without extra permission.
- Merge, rebase, pull request, or push activity involving
mainrequires explicit human permission. - Stage only files that belong to the current task. If unrelated changes exist, leave them untouched and mention them in the handoff.
- Never use destructive git commands such as
git reset --hardor broad restore/checkout commands unless the human explicitly asks.
Pull Request Format
- Use a concise title that names the behavior changed.
- Include:
- what changed,
- why it changed,
- tests or commands run,
- any known limitations or follow-up work.
- For behavior changes, include the expected behavior, the test-first failure observed, and the passing verification. Do not mark both test-first checklist alternatives.
Useful Verification Commands
- Public API and optional install validation:
uv run pytest tests/test_luvatrix_public_app_api.py
- App manifest and variant routing:
uv run pytest tests/test_app_runtime.py -k "manifest or variant or platform_support"
- Headless CLI smoke:
uv run python main.py validate-app examples/full_suite_interactive --render headlessuv run python main.py run-app examples/hello_world --render headless --ticks 1 --energy-safety off
- Broader runtime checks should be chosen based on touched modules, for example macOS renderer tests for
luvatrix_core/platform/macos/*changes or planes tests forluvatrix_ui/planes_*changes. - Retained scene-scroll throughput:
uv run python tools/perf/macos_scene_scroll_harness.py.