Dry run 3880 showed that since #124 Renovate proposed no bump at all: - pip-compile: the manager refused the lock's header ("Option --newline=LF not supported (yet)"), extracted nothing and only logged a WARN, so the Python tools were never bumped. Drop --newline from scripts/lock-requirements.sh and the lock header (the 81 entries and hashes are unchanged); the manager now reads 81 dependencies. The lock is an image input: ci 0.2.19 -> 0.2.20. - pre-commit: every hook was skipped (skipReason github-token-required, no GitHub token exists), and with the warning off the GitHub GraphQL lookup is refused at once (403 rate limit). Look the hooks up with git ls-remote (packageRule overrideDatasource git-tags, which needs RENOVATE_GITHUB_TOKEN_WARN=false because the token check runs before package rules apply). Renovate dereferences annotated tags, so the new rev is the commit (checked against git ls-remote for conventional-pre-commit v4.5.0). git-tags has no release timestamps, so hook bumps are not automerged. Tested with [email protected].0 --platform=local against this checkout. Not tested: the real job (renovate.json is read from main), the lock replay by Renovate's pip-compile artifact step, and the ci 0.2.20 image build. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_014uGZTRacjtXvmKxHr5TM5G
12 KiB
CLAUDE.md
Guidance for Claude Code (claude.ai/code) in this repository.
What this is
mortis.kamino: an Ansible Collection (GPL-3.0-or-later, REUSE-compliant), extracted role by
role from the author's homelab environment repository. The design contract is ADR 0004 (in the
maintainer's environment repository). Roles arrive here wave by wave; docker is in 1.0.0, fail2ban in 1.1.0, network_interfaces and systemd_hardening in 1.2.0, system_baseline in 1.3.0, ufw in 1.4.0.
Fork pull requests from untrusted users are not accepted for now: a fork controls its own
workflow file, so the if: guards are a convenience, not a boundary (see the header of
molecule.yml). Do not change visibility, repository settings, branch or tag protection,
or create tags: those are the operator's.
Working here
- Set up once per clone:
scripts/dev-setup.sh(a virtualenv with the pinned tools and git hooks that find them). Thelanguage: systemhooks runreuse,ansible-lintandantsibull-changelogby name, so a hook run without that virtualenv onPATHfails. - Agent skills come from holocron through apm:
apm install(theapmCLI is not one of the pinned tools, anddev-setup.shdoes not run it) deploys them to.claude/skillsand.claude/agents, both gitignored likeapm_modules/.apm.ymlandapm.lock.yamlare the only tracked files. The entries are unpinned on purpose (see the comment inapm.yml);apm install --updatemoves them. They are tooling, sogalaxy.ymlbuild_ignorekeeps them out of the Collection. - Commit with git in a clone, never through the Gitea API. The hooks (REUSE, yamllint,
actionlint, ansible-lint, gitleaks, changelog lint, Conventional Commits) only run in
git commit; an API commit skips them and CI finds the problem after the push. The first hook run builds the Go hook environments and takes minutes: run commits in the background.git pushalso runsansible-test sanityon HEAD (scripts/ansible-test-sanity.sh, the Build job's check, which ruff and the other hooks do not cover); its first run builds virtualenvs and takes minutes. - Feature branch and pull request;
mainandv*tags are protected. Never push tomain. Releases are the operator's: annotatedvX.Y.Ztags equal togalaxy.yml's version. - Conventional Commits. A PR says what was verified and what was not.
- There is no local molecule and no container runtime on the control host: do not install one.
Molecule runs in CI, on the repository's own runner (label
kamino-molecule). - Changes that can affect a consumer need a changelog fragment (
changelogs/fragments/). New files are covered byREUSE.toml; third-party-derived content needs its own annotation.
Agent skills
Issue tracker
Issues live in Gitea Issues on mortis/kamino, used through the gitea-issues skill and the Gitea MCP tools. See docs/agents/issue-tracker.md.
Triage labels
The five triage roles map onto the repo's scoped Status/ and Reviewed/ labels. See docs/agents/triage-labels.md.
Domain docs
Single-context: GLOSSARY.md and docs/adr/ at the root, both created lazily. See docs/agents/domain.md.
Workflows (.gitea/workflows/)
- Never
pull_request_target. A forkpull_requestrun gets no secrets and a read-only job token; a same-repo pull request does get the org Actions secrets, so nothing butimage.ymlmay reference them. Pass ref, repo and name values to scripts throughenv:, never interpolate${{ github.* }}into arun:block. - Runner labels are
kamino-dockerandkamino-moleculeonly (.gitea/actionlint.yaml). Use thegithub.*contexts, which Gitea aliases; actionlint does not knowgitea.*. - Lint and Build run in the
ciimage. After the checkout they compare the pin files with the checksums baked into the image: a PR that changesrequirements-dev.txt,requirements-dev.lock,requirements.ymlor.pre-commit-config.yamltakes the slower path that installs the pinned tools and collections. - Molecule runs on every same-repo pull request, Renovate's included (a new image is tested by its own pin
pull request), with no workflow path filter, so that it can be a required check. Fork pull requests are skipped.
What a pull request runs is chosen by
scripts/select_molecule_scenarios.py, run from the base branch's copy (a pull request cannot edit its own rules): only the scenarios of the roles it changes, none for a diff of only its IGNORED paths, a failure for a changed role with no scenario, and every scenario for any other file, for every push tomain, for manual dispatch and for the nightly run (04:43 UTC, after Renovate's). A new file outsideroles/<role>/runs everything until it is added to IGNORED, which is right only when no scenario reads it. A new commit cancels the pull request's running Molecule run, and the step first removes containers a cancelled run left; two runs never overlap because the runner has a single slot, so raising its capacity needs a lock or a shared concurrency group. - Every scenario sets
scenario.test_sequenceto molecule's default minus the leadingdestroy(the workflow clears stale containers first, and the molecule state lives in the job's ownANSIBLE_HOME, so a killed run leaves none behind); copy it into a new scenario. - Molecule discovers
extensions/molecule/*/androles/*/molecule/*/. Theimage-smokeandimage-smoke-2604scenarios test the molecule images themselves (24.04 and 26.04); a role scenario that must pass on both takesimage: ${MOLECULE_IMAGE}or${MOLECULE_IMAGE_2604}per platform.
Images (images/)
ci,molecule-ubuntu2404andmolecule-ubuntu2604, built byimage.ymlwith kaniko on push tomain(never on pull requests) and pushed togit.rkdr.net/mortis/<name>.- The molecule images are one Ubuntu release each, by name: the hosts run 24.04 today and 26.04 is the
target, so roles are tested on both. A new release is a new image added by hand (Renovate's major
ubuntuupdates are disabled everywhere); retire an image when no host runs its release. A new image's first consumer pin is a hand-made PR with the digest its first build printed; Renovate follows it after. - Each has a semver
version:in the workflow's build matrix. A published version tag is never moved and never rebuilt (the job looks it up in the registry first and ends without building): bump the version in the PR that changes the image. A new version is pushed as<version>andlatest; there is nosha-*tag, so one digest belongs to exactly one version. ansible-test sanityignores live intests/sanity/ignore-common.txt; the Build job copies it to the file name of the installed core version in its throwaway worktree (a committedignore-<MAJOR.MINOR>.txtis appended for findings of one version only).- Consumers pin
image:<version>@sha256:<digest>(lint.yml,build.yml,molecule.yml). A build prints the new digest; moving a pin is a reviewed edit, and every build has a new digest. - kaniko runs inside the job container and unpacks the image it builds over it, so each matrix entry names its
job container (
job_image: ubuntu:<release>@sha256:...) and its release must equal theFROM ubuntu:release of the image's Dockerfile (check_image_versions.py pinsfails otherwise). Moving an image to a new release is one edit: the DockerfileFROM, thejob_imagetag and digest, and the version bump. Digest drift within a release is tolerated. Ajob_image-only bump is not an image input: no version bump, nothing rebuilt; the post-merge Images run only reaches the prepare step for published versions, so that is its only exercise. - Image metadata: Gitea's package page shows the description as plain text (no markdown), lists every label,
and links source, documentation and licence; it renders no README. So each Dockerfile carries the same
label block (
org.opencontainers.image.*plusnet.rkdr.mortis.purpose/contents/usage), the build addsversion,revisionandcreated, and the readme-style text lives indocs/images/<name>.md, which thedocumentationlabel links to.check_image_versions.py pinsfails when a label or that file is missing. The docs sit outside the image directories on purpose: editing them is not an image input, so it needs no new version. Editing a label in a Dockerfile is an input and does. - Each pushed layer must stay below 100 MB: Cloudflare rejects larger request bodies with
HTTP 413. That is why the
ciimage deletes the Go toolchains from the hook cache. image.ymlis the only workflow that may reference the org Actions secrets (the registry push credential). Never print or use them anywhere else.
Dependency automation (Renovate)
renovate.json is run by .gitea/workflows/renovate.yml (daily cron and workflow_dispatch) on the
kamino-docker runner, as a Kamino-only bot user, so code from this repository never runs in the
maintainer's production environment. Never reuse another Renovate credential here.
- Policy: minor and patch bumps automerge, majors are manual; the Lint and Build checks are the gate.
A new Ubuntu release is a deliberate edit, never a bump. The
job_imageof each matrix entry inimage.ymlnever automerges: that job holds the registry push credential. kaniko is pinned by layer digests inimage.ymland updated by hand. - Two-PR loop for an image input (
requirements-dev.txt,requirements-dev.lock,requirements.yml,.pre-commit-config.yaml,images/**): PR 1 carries the input change plus the PATCH bump of the imageversion:inimage.yml(scripts/bump_image_versions.py [<base-ref>];check_image_versions.py bumpthen passes; Renovate runs it as a post-upgrade task). The merge builds the image onmain. PR 2 moves the consumers' pins to the new digest (Renovate's pin-follow rule for themortis/*images; a major version stays manual). - Python tool pins and their lock:
requirements-dev.txtholds the direct pins,requirements-dev.lockis their hashed lock (installed withpip install --require-hashes -r requirements-dev.lock -r requirements-dev.txt; pip refuses an unhashed package and any disagreement between the two). Renovate'spip-compilemanager bumps a pin and regenerates the lock by replaying the lock's header command; a weekly lock-file-maintenance PR moves transitive packages and is never automerged. By hand:scripts/lock-requirements.sh [--upgrade]. The header must hold only options Renovate knows: it refuses--newline=LF("not supported (yet)"), extracts nothing, and proposes no bump, with only a WARN in an otherwise green run. Hook repositories in.pre-commit-config.yamlare pinned by commit SHA with a# frozen: vX.Y.Zcomment. Renovate looks them up withgit ls-remote(packageRuleoverrideDatasource: git-tagsplusRENOVATE_GITHUB_TOKEN_WARN=falseinrenovate.yml), because there is no GitHub token and the defaultgithub-tagslookup is skipped or rate limited. A hook bump is never automerged:git-tagshas no release timestamps, sominimumReleaseAgecannot delay it. After a Renovate config change, test it locally before the merge:renovate --platform=local(same version asrenovate.yml) reads this checkout; a dry run in Actions readsrenovate.jsonfrommain. - Bot-diff gate:
scripts/check_bot_pr_diff.pyruns in the lint workflow, fromorigin/main's copy so a pull request cannot weaken it. Arenovate/head ref may only change version lines (tool pins and their lock entries and hashes, hookrev:lines, Dockerfile FROM tags and digests, matrixversion:lines,job_image:pins, consumer image pins); anything else fails,renovate.jsonincluded. The branch name is attacker-controlled, so this only constrains the bot's own pull requests. - No Collection release from tooling bumps: tooling files are in
galaxy.ymlbuild_ignore. A role-visible change needs a changelog fragment and a newgalaxy.ymlversion; only the operator tags. - No production images:
check_image_versions.py pinsfails when anything under.gitea/workflowsmentions the maintainer's production image namespace. - Hand edits on a bot branch: a commit pushed by hand to a
renovate/branch makes Renovate stop rebasing it, so merge that pull request by hand. - The runner has a single slot: the Renovate job (up to 30 minutes) delays Lint, Build and Molecule.
- Open item: do not enable automerge for bot PRs until a live run has shown that they get Lint and Build.