ADR-087: Configuration Is a Git Source — a CRAIG-Owned Fetcher Publishes a Verified Commit, Services Load It at Boot and Stamp Its SHA

Status

Accepted (2026-11-06) with plan config-git-source, #2947, epic &121. Amends: ADR-072 when that plan’s U5 lands (Tier 2 becomes config bundle data, boot-resolved and fail-closed, instead of compiled StateBundle data).

Erratum (2026-11-07): config repositories merge fast-forward only and never squash, so main’s head is always the author’s signed commit; GitLab-made merge, squash and rebase commits are unsigned and the fetcher refuses them (#2955).

Context

CRAIG’s repository holds its source and two deployments' configuration: rulesets/{federal,georgia,texas}, the compiled state crates' reference data, surface baselines and field ownership. Adopters do not consume CRAIG that way, and nothing makes a misplaced item fail. Rulesets decide policy, so a deployment’s configuration must be authenticated, and the exact revision behind every decision must be recorded. Today a decision reaches its ruleset revision in craig-rules' database, and the trail stops there.

The maintainer set the model (2026-11-06, #2947): a deployment points at a configuration source, a git repo in the Salt gitfs style, and tracks a branch head (branches as channels) or a tag; every decision is stamped with the resolved commit SHA, and the current SHA is on a version endpoint.

Decision

  1. Configuration is ordered git layers. CRAIG_CONFIG_SOURCE lists sources lowest precedence first: a federal base, a jurisdiction, optionally a deployment layer. Each is a git+https://, git+ssh:// or path: source tracking a branch or a tag. A file path resolves to the highest-precedence layer holding it; there is no content merge.

  2. CRAIG owns the fetcher (craig-config-fetch). resolve pins branches and tags to SHAs once per rollout so replicas move together; sync fetches, checks the commit out into a new worktree, verifies it, and publishes it by renaming a SHA-named directory into place and flipping current with rename(2).

  3. Verification gates publication. Modes head, tag and tag-and-head (after Flux): git verify-commit and/or git verify-tag, and the signer read from the raw status must be on the source’s trust root (an SSH allowed_signers file or an OpenPGP fingerprint list), which the deployment mounts and the config repo never carries. A refusal leaves current on the last good SHA, exits non-zero and writes a status file; a service with no good tree refuses to start.

  4. Services load at boot and stamp what they loaded. One immutable snapshot per process, built at boot and held in an Arc; a new configuration applies by rollout, never mid-decision. craig-rules records the layer SHAs on each ruleset snapshot, so evaluation → revision → commit. Every service answers GET /version with its build and the layer SHAs.

  5. Git is the only authority. In a config-managed deployment craig-rules reconciles its active rulesets from the loaded configuration at boot and refuses its write routes with 409 config-managed; rollback is moving the branch or tag.

  6. Credentials never ride in the URL. A source URL with userinfo is refused; private repos authenticate through the standard git credential environment (deploy token, deploy key).

Alternatives considered

Researched from primary sources on 2026-11-06, independently by craig and canopy (canopy #3254), converging.

  • Runtime pull in each service (each process clones and refreshes). Rejected: every service would carry git, the credentials and the verification, replicas would drift independently, and a pull mid-request invites a decision against a half-updated tree.

  • Bake at build time (config copied into images). Rejected: it couples the config cadence to image builds, multiplies images per jurisdiction, and keeps source and config in one artefact — today’s problem.

  • A GitOps operator (Flux, Argo CD). Rejected as primary: Kubernetes-only, while CRAIG runs in compose for the devstack and some installs. Flux’s verification modes are adopted as the model.

  • git-sync v4 with a verify hook. Rejected on evidence: v4.5.1, the latest release, has no pre-publish hook (the flag is README-only on master); its only hook runs after the flip, a failing hook only logs, unsigned and untrusted heads were published, and the image lacks ssh-keygen (canopy’s spike, canopy #3254).

  • OCI artifacts (ORAS) signed with cosign. Not chosen as primary — git gives history, review and branch channels for free — and kept as a future path for air-gapped installs.

  • A shared fetcher with canopy. Ruled out by the maintainer (2026-11-06): each project owns its implementation; the design and the must-pass refusal test are shared.

Consequences

  • rulesets/ and the state crates' data leave the source repository; testonia stays as the fixture layer. Source CI fetches pinned GA and TX config through config-sources.lock, so a misplaced item fails the battery.

  • A configuration change is a signed commit plus a rollout; there is no in-app hot fix and no hot reload in v1.

  • Decisions become traceable to a signed commit, and every service reports what it runs.

  • CRAIG maintains a small fetcher (fetch, worktree, verify, flip) and its refusal tests.

Verification

The must-pass test: an unsigned head and an untrusted-key head each leave current on the last good SHA, the fetch exits non-zero, and the status file says why; a good head flips. Plus the plan’s per-unit tests.

Amendment — #2956 (2026-11-15): a setting names who owns the rule sets

Decision 5 stands: in a config-managed deployment git is the only authority for craig-rules' rule sets. What changes is how a deployment says it is config-managed. Until this amendment craig-rules was config-managed when CRAIG_CONFIG_SOURCE was set, and ran with its write API open when it was not.

That switch cannot survive #2956. The jurisdiction is now named only by the configuration manifest, so craig-rules needs a configuration source whoever owns its rule sets, and the variable’s presence no longer says anything.

CRAIG_RULES__RULE_SET_AUTHORITY replaces it:

  • config (the default): the configuration layers own the rule sets. Boot reconciles the database to the layers' rule-set files, and the write routes answer 409 config-managed.

  • api: the write API owns them. Boot reconciles nothing and the write routes stay open; the configuration is read only for the jurisdiction.

Unset or blank is config, so a deployment that says nothing never has an open write API by omission; any other value refuses boot. The devstack sets api, because its seed and its tests write rule sets through the API.

This amendment also discharges the Amends line of § Status: ADR-072 carries the tier-2 change as its own § Amendment — #2956.

Edit this page · latest