Katkat

Prevent Private Code Leakage in Coding Agents

MetaMachine Learning Engineer · Technical Screen

Last updated

This problem tests the ability to design an ML-driven safeguard system that prevents private codebase exposure during the training, fine-tuning, and inference phases of a coding agent.

Problem Statement

You are tasked with building a safety layer for a Large Language Model (LLM)-based coding agent used by Meta engineers. A critical risk is the model inadvertently leaking proprietary source code or internal secrets (e.g., API keys, internal endpoints) during chat completions or through its training data.

Design a system that ensures the coding agent does not output sensitive proprietary information.

Requirements

  1. Functional Requirements:
    • Detect sensitive patterns (PII, secrets, proprietary logic) in real-time before returning model output to the user.
    • Ensure the agent does not ingest private repositories into the general-purpose training pool without anonymization.
  2. Non-functional Requirements:
    • Latency: The safety check must add less than 100ms to the total inference latency.
    • Accuracy: Minimize false positives to maintain developer productivity; unauthorized redaction of standard code snippets must be avoided.

Deliverables

  • Describe the architecture of the safety pipeline (Inference time vs. Training time).
  • Define the mechanism for "Secret Detection" vs. "Proprietary Logic Leakage."
  • Explain how you would maintain a dataset of "known sensitive patterns" without creating a single point of failure.
  • Discuss the trade-offs between heuristic-based filters (e.g., regex/entropy) and ML-based classifiers.

Hints

Hint 1

Consider implementing a two-tiered check: a fast, local heuristic scanner for high-entropy strings followed by a lighter-weight Transformer model for context-aware classification.

Hint 2

Think about how to use Differential Privacy or PII-masking techniques during the fine-tuning stage to prevent the model from memorizing specific code blocks.

Hint 3

For system architecture, evaluate the use of an asynchronous sidecar process or a middleware proxy to perform sanitization without bottlenecking the main LLM inference thread.

Follow-up questions

  • How would you handle "context leakage," where the agent uses information from one private repository to solve a task in a different, restricted project?
  • If you detect a high probability of leakage, what is your strategy for logging, notifying the user, and providing feedback to the model's training pipeline?
  • How would you measure the effectiveness of this system (i.e., what metrics would you use to track leakage incidents versus developer friction)?