Skip to content

Simplify repository configuration: schema cleanup, repo+local config layering, onboard skill, validator #3095

Open

Description

@jwbron

Problem

Onboarding a new repo to egg means manually editing ~/.config/egg/repositories.yaml — a single user-level file with a schema that has several subtle traps that don't show up until something silently breaks at runtime:

  • persist_dirs vs persist_system_dirs is the difference between "binary survives into the runtime sandbox" and "binary is silently discarded between Docker stages." Sandbox container missing uv: BRC tester can't run make test, falls back to incomplete pytest #2065 is exactly this: the local config installed uv via build_commands to /usr/local/bin but didn't persist that path, so the binary was discarded after Stage 1 and make test errored with uv is not installed inside the sandbox. A user reading config/repositories.yaml.example wouldn't catch this — only deep knowledge of sandbox/docker-setup.py + the multi-stage sandbox/Dockerfile reveals the trap.
  • watch_files must enumerate every dependency manifest the build_commands touch, otherwise Docker layer caching either thrashes (rebuilds on unrelated changes) or silently serves stale dep installs.
  • build_commands must be idempotent and run as root in a synthetic working directory under /tmp/repo-deps/ — a different shape than the developer's local install flow. Easy to write something that works locally but fails (or no-ops) during the image build.
  • checks must match the project's actual lint/test commands, but there's no validator that the named commands actually exist in the repo's Makefile.
  • The config lives only on the operator's machine. Every onboarder has to rediscover the right build_commands / persist_* / checks block from scratch, even though the answers are deterministic per-repo and could ship with the repo.

The example file at config/repositories.yaml.example documents the schema but doesn't catch any of these errors at write time. The result is config that looks correct, builds successfully, and then quietly degrades the agent's behavior weeks later when something hits the broken codepath.

Proposal

Three tightly related changes that together cut the onboarding error surface to near zero.

1. Simplify the per-repo schema

Reduce the surface area where users can write config that looks right but is silently wrong. Concretely:

  • Collapse persist_dirs + persist_system_dirs into a single persist: list. The loader classifies each entry as repo-relative vs absolute by the leading / and routes it into the right Docker stage internally. Callers stop having to know which list a path belongs in. (shared/egg_config/... and sandbox/docker-setup.py are the touch points.)
  • Make watch_files derivable, not required. If omitted, infer from a built-in manifest catalog (pyproject.toml, uv.lock, package.json, pnpm-lock.yaml, package-lock.json, yarn.lock, go.mod, go.sum, Cargo.toml, Cargo.lock, requirements*.txt, Gemfile.lock). Users override only when the heuristic is wrong. This eliminates the most common cache-thrash / stale-deps footgun.
  • Make checks derivable when conventional. If omitted, scan the repo's Makefile for lint / test targets (and package.json scripts for JS repos) and synthesize a default checks: block. Explicit checks: still wins.
  • Validate referenced Makefile targets at load time (not just runtime), so a typo in make tset is caught before the agent runs.

The intent is to keep the schema fully expressive but require only the irreducible bits per repo. Heuristics that guess wrong should be easy to override; heuristics that guess right should mean an empty/absent block is the common case.

2. Two config locations: repo defaults + local overrides

Today there's exactly one config file (~/.config/egg/repositories.yaml) and the operator must hand-author the per-repo block. Instead, support a layered model:

  • Repo-level defaults at .egg/repositories.yaml (or similar — see "Open questions") committed to the target repo. Contains only the per-repo block: build_commands, persist, watch_files, checks, auth_mode, etc. — i.e. the stuff that's a property of the repo, not of the operator.
  • User-level overrides at the existing ~/.config/egg/repositories.yaml. Continues to hold operator-scoped fields (github_username, bot_username, writable_repos, local_repos, default_reviewer, user_mode, github_sync, docker_setup extras) and may override or extend any per-repo field.

Merge semantics:

  • Operator-scoped top-level keys (identities, access lists, local mounts) come exclusively from the user file.
  • For each repo under repo_settings.<owner/repo>: deep-merge repo-defaults ← user-overrides, with the user file winning at the leaf level.
  • List-valued fields (checks, persist, watch_files): default behavior is replace, with an explicit extends: / + opt-in if/when we need additive merging. (Keep merge rules simple — surprising deep-merges of lists are a known footfgun.)
  • Lookup of repo defaults: when the operator runs egg against a checkout, look for .egg/repositories.yaml in that checkout. Skip silently if absent (current behavior preserved).

Why this is worth the complexity: the per-repo block is deterministic given the repo (its languages, its lockfiles, its Makefile). It belongs in version control alongside the repo. Operator identity, access matrices, and local paths are not deterministic and stay user-side. Splitting along that seam means a new operator onboarding an already-instrumented repo gets correct defaults for free.

3. Add an 'onboard repo' skill

A skill (/onboard-repo <path>) — or an egg onboard <repo-path> CLI command — that introspects a target repo and generates a correct per-repo block, written by default to <repo>/.egg/repositories.yaml (the new repo-defaults location) so it can be committed.

Detection logic:

  • Python (uv) — pyproject.toml + uv.lock → uv install + make deps (or uv sync); persist .venv + /usr/local/bin
  • Python (pip) — requirements.txt → pip install -r requirements.txt; persist .venv if a venv is created
  • Node — package.json + pnpm-lock.yaml / package-lock.json / yarn.lock → corepack/pnpm-or-npm install; persist node_modules
  • Go — go.mod → install Go to /usr/local/go, go mod download; persist /usr/local/go
  • Rust — Cargo.toml → install rustup, cargo fetch; persist ~/.cargo and target/
  • Mixed — combine the above (e.g. a large monorepo = Go + Node + Python)

Then parse the repo's Makefile (or package.json scripts, pyproject.toml [tool.poetry.scripts], etc.) for canonical lint/test command names and propose a checks: block.

Output: a YAML snippet that the skill writes to <repo>/.egg/repositories.yaml (or, if invoked without write permission to the repo, prints to stdout and offers to append to the user file as a fallback).

4. Validate existing config

Extend mcp__egg__validate_config (or add egg validate-config) to flag common misconfigurations across both layers:

  • build_commands install something to a system path (/usr/local/bin, /opt/...) but persist doesn't include the parent dir → the install will be discarded between stages
  • build_commands declare persist_dirs that the watch-files-only build context can't actually produce. The classic case (Sandbox agents in egg repo lack working .venv, silently fall back to system Python #2087): a uv/Python repo declares persist_dirs: [.venv] and runs uv sync, but the build context contains only Makefile + pyproject.toml + uv.lock — no source dirs, no README.md — so the hatchling build backend errors trying to package the local project. Validator should heuristically detect "uv sync" / "pip install -e ." / "npm install" / etc. paired with a project that needs source files the watch_files don't include, and suggest the no-install-project pattern (or list the missing watch_files). Note: as of Fix #2087: fail loudly when sandbox build_commands silently break #2090, docker-setup.py itself raises on this case at build time — but the validator should catch it at config-write time, before a wasted image rebuild.
  • checks.command references a Makefile target that doesn't exist in the repo's Makefile
  • watch_files lists a manifest the build_commands don't appear to use, or omits one they do (heuristic: install-tool keywords like pip install, npm ci, go mod)
  • local_repos.paths entry doesn't exist on disk
  • writable_repos entries that don't appear under repo_settings (probably fine, but worth flagging if they have non-default needs)
  • checkpoint_repo is well-formed owner/repo and (best-effort) accessible
  • Repo-defaults file at <repo>/.egg/repositories.yaml contains only per-repo-scoped keys (warn if it sets github_username, writable_repos, etc., which belong in the user file)

This is the safety net for users who hand-edit; the skill is the on-ramp for users who don't want to; the schema simplification raises the floor so even hand-authored configs are harder to get wrong.

Motivating examples

#2065 — root cause was a missing one-line persist_system_dirs: [/usr/local/bin] in the jwbron/egg block. The user had correctly identified that uv needed to be installed via build_commands; the schema's persistence model is what got them.

#2087 — same jwbron/egg block, different trap: persist_dirs: [.venv] paired with a make deps build command that ran uv sync on a watch-files-only context. The hatchling build backend tried to package the local egg project, errored out because README.md and the source dirs weren't in the build context, docker-setup.py warned-and-continued, and the image shipped with /opt/prebuilt-deps/ empty. Agents silently fell back to system Python for weeks. Fixed in #2090 by raising on the silent failure at build time and adding a make sandbox-deps target that does uv sync --no-install-project.

Both incidents share a shape: hand-authored config that looks correct, builds successfully, and produces an image that's quietly missing the deps the config promised. After the changes proposed here:

  • The schema simplification means there's just persist: [/usr/local/bin, .venv] — no decision to get wrong about which list a path belongs in.
  • The validator would catch both classes (missing system-dir persist; build-command-can't-produce-the-persist-target) at config-write time, before a wasted image rebuild.
  • The skill would never produce either misconfiguration in the first place.
  • The repo-defaults file means jwbron/egg ships its own correct block, and no future onboarder rediscovers the traps.

Open questions

  • Filename for repo defaults. .egg/repositories.yaml mirrors the user file naming. Alternatives: .egg.yaml (single-file), egg.yaml (visible at repo root). Mild preference for .egg/repositories.yaml since .egg/ gives us a place for future files (templates, per-repo cached state) without polluting the repo root.
  • Schema-versioning the repo file. A repo committing .egg/repositories.yaml is exposing itself to schema churn. A version: 1 field at the top, with the loader gracefully degrading on newer versions, is probably worth it from day one.
  • Whether extends: / template library belongs in this issue or a follow-up. The original issue listed it as out-of-scope; with repo-defaults landing here, deduplication via templates becomes more attractive but also more separable. Lean toward: ship without templates, revisit once we see how much per-repo config still duplicates across the fleet.

Out of scope (for follow-ups)

  • Repo template library (python-uv, node-pnpm, etc.) that users extends: from
  • A web UI / wizard — the CLI/skill is enough to start
  • Cross-repo dependency detection (e.g. a backend monorepo + its sibling frontend repo) — handle as a single combined block rather than auto-linking
  • Migrating existing users' configs automatically — provide a one-shot egg config migrate if needed, but don't block the change on it

Activity

  1. added
    p2
    sdlc-candidate
    on Jun 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    p2sdlc-candidate

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions