KatInterview

Design a Safe, Automated Code-Change Pipeline

System DesignModel answer
MediumModel answerSystem Designsystem-designai-agentsdeveloper-tooling

Last updated

Design an end-to-end pipeline that takes an engineering ticket, uses an LLM agent to propose code changes, and produces a verified pull request safely.

Background

Your team wants to build an automated pipeline that accelerates routine engineering tasks — patching a bug from a stack trace, generating missing unit tests, or bumping a library to its latest patch version. A language model will write the code, but the organization has non-negotiable requirements: no production secrets may be touched, every change must be reproducible and auditable, and a human always approves before anything merges.

You are asked to design this pipeline end-to-end.

What to Cover

1. Scope Definition and Context Assembly How does the system decide what a given ticket is allowed to touch? How is relevant code context gathered without flooding the model's context window?

2. Agent Skills and Prompting What tools does the agent have access to, and how are they defined? What goes in the system prompt, and what must be enforced outside it?

3. Host-Side Guardrails What hard limits does the host environment enforce regardless of what the agent says? Think about secrets, destructive commands, infinite loops, and token/time budgets.

4. Verification and the Feedback Loop How does the system validate the agent's proposed diff? What stages run, in what order, and how are failures fed back to the agent for correction?

5. Review and Merge How does a human reviewer inspect the result, and what metadata helps them trust (or reject) it?

Deliverables

  • A component-level architecture walkthrough (prose or a simple ASCII diagram is fine)
  • An example tool invocation schema showing both a success and a policy-denial response
  • A discussion of at least three failure modes and how the design handles them

Hints

Hint 1

Start by treating the LLM as an untrusted, non-deterministic component — the host controls what it can see and do, and the model only proposes. Ask yourself: what would happen if the model tried to delete a test file to make tests pass?

Hint 2

Think about where enforcement actually lives. A system prompt says 'don't touch CI config'; a path ACL enforces it. List the hard limits that must be deterministic code, then separately list the soft guidance that belongs in the prompt.

Hint 3

For the verification stage, consider what a false-positive test pass looks like — tests that were deleted, assertions that were skipped, or a bug 'fix' that just swallows the error. How do your integrity checks catch each of those?