Skip to content
#Data Engineering#Security#TypeScript#Data Privacy

Zero-PII Data Engineering: Sanitizing Git History and Synthetic Pipelines

A technical case study in remediating legacy credential exposure in git history, eliminating learner personal data, and establishing deterministic synthetic data generation.

Henish Patel4 min read

Building early-stage software often creates technical debt that directly impacts data governance. In rapid iterations, development practices can lead to exposed test secrets, build configurations that suppress type errors, and unverified data retention.

During my work as Software Engineer (Data and AI) on FrancoBuddy (a French-learning application built part-time alongside university studies between February 2025 and March 2026), establishing rigorous data hygiene and security controls became a primary engineering mandate.

This case study reviews three technical interventions:

  1. Purging exposed credentials across the full git commit graph using git-filter-repo.
  2. Eliminating build-error bypasses to resolve 124 latent TypeScript compilation errors.
  3. Replacing user records with a zero-PII synthetic learner data generation pipeline.

1. Git History Sanitization: Surgical Credential Purging

During an automated security audit with Gitleaks, two active API keys were identified in early repository commits. Even though the current HEAD commit did not reference these variables, git maintains an immutable history of every committed tree object. Anyone with read access could checkout previous revisions and retrieve the credentials.

Simply pushing a new commit that deletes the secrets is insufficient. The commit history itself must be rewritten.

The Remediation Workflow

We utilized git-filter-repo to scrub the repository history without destroying branch topology:

# 1. Generate an isolated clone for history modification
git clone --mirror git@github.com:henish73/franco-buddy.git repo-sanitization
cd repo-sanitization

# 2. Define expressions to scrub and replace with sanitized placeholders
git-filter-repo --replace-text <(cat << 'EOF'
regex:AI_SERVICE_API_KEY=[A-Za-z0-9_\-]{32,}==>AI_SERVICE_API_KEY=PLACEHOLDER_ROTATED
regex:STORAGE_SERVICE_KEY=[A-Za-z0-9_\-]{32,}==>STORAGE_SERVICE_KEY=PLACEHOLDER_ROTATED
EOF
)

# 3. Verify clean state across all historical refs
gitleaks detect --source . --verbose

Following the history rewrite, the upstream API keys were rotated immediately in the respective vendor dashboards. Every contributor verified that local caches were wiped and fresh clones were initialized.

2. Resolving the Build Bypass: 124 Hidden TypeScript Errors

In the legacy next.config.js file, rapid feature experiments had introduced a standard anti-pattern:

// Legacy build configuration bypass
module.exports = {
  typescript: {
    ignoreBuildErrors: true, // Dangerous bypass suppressing compilation failures
  },
};

This bypass allowed production bundles to compile despite severe type incompatibilities. When ignoreBuildErrors was toggled to false, the compiler failed immediately, uncovering 124 unresolved type errors across the codebase.

The errors fell into three major categories:

  • Mismatched Event Payloads: Learner practice sessions emitted progress events with missing schema properties (sessionDurationMs vs duration).
  • Implicit Any Types: Database query handlers in Firebase functions lacked explicit return signatures, leading to runtime undefined property access.
  • Null Reference Assumptions: Nullable learner state was accessed directly without optional chaining or validation guards.
// Refactored strongly-typed learner event contract
export interface LearnerExerciseEvent {
  readonly eventId: string;
  readonly learnerId: string;
  readonly exerciseType: "vocabulary" | "conjugation" | "pronunciation";
  readonly score: number; // Normalized 0.0 - 1.0
  readonly durationMs: number;
  readonly timestamp: string; // ISO 8601 UTC
}

We refactored each handler to enforce strict typing with Zod schemas. Once the 124 type errors were systematically resolved, we expanded the automated test suite to 136 passing unit and integration tests, ensuring zero type regressions in the build pipeline.

3. Zero-PII Synthetic Learner Generation

To analyze student retention and learning trajectories without retaining real user personal data, we designed a zero-PII synthetic data pipeline.

Personal Identifiable Information (names, student email addresses, geographic coordinates) was completely removed. Instead, the analytics warehouse was populated using a parameterized stochastic learner model calibrated against the Common European Framework of Reference for Languages (CEFR: levels A1 through C2).

   +------------------------------------------------------+
   |        CEFR Proficiency Transition Matrix            |
   |              (A1 -> A2 -> B1 -> B2)                  |
   +------------------------------------------------------+
                             |
                             v
   +------------------------------------------------------+
   |      Deterministic Synthetic Event Generator         |
   |     - Exercise completion frequency (Poisson)        |
   |     - Error decay curves (Ebbinghaus retention)      |
   |     - Session length distributions (Log-normal)      |
   +------------------------------------------------------+
                             |
                             v
   +------------------------------------------------------+
   |          Zero-PII Analytics Warehouse                |
   |     (100% Synthetic, Statistically Faithful)         |
   +------------------------------------------------------+

Event Generation Mechanics

The synthetic model simulated realistic learner behavior while guaranteeing zero privacy exposure:

  1. Proficiency Curve Decay: Retention decay followed a modified Ebbinghaus forgetting curve, determining how review intervals affected exercise scores.
  2. Session Cadence: User return frequencies were modeled via a Poisson process with weekly seasonality peaks on weekends and weekday evenings.
  3. Synthetic IDs: Identifiers were generated using salted cryptographic hashes that cannot be reverse-mapped to any real individual.
import numpy as np

def generate_synthetic_session(learner_level: str, day_index: int):
    # Simulated proficiency score based on difficulty and level
    base_accuracy = {"A1": 0.85, "A2": 0.72, "B1": 0.60, "B2": 0.48}[learner_level]
    noise = np.random.normal(0, 0.05)
    score = np.clip(base_accuracy + noise, 0.0, 1.0)
    
    return {
        "learner_hash": f"synth_{hash((learner_level, day_index)) & 0xFFFFFF:06x}",
        "proficiency_level": learner_level,
        "score": round(score, 3),
        "session_duration_sec": int(np.random.lognormal(mean=5.5, sigma=0.4))
    }

Takeaways

  1. Git history is permanent unless actively rewritten: Never assume deleting an API key in a later commit secures the secret. Automate repository scanning and rewrite history when leaks occur.
  2. Build bypasses compound technical debt: Suppressing compilation errors hides critical data contract mismatches that eventually break downstream analytics pipelines.
  3. Prioritize synthetic data for product analytics: Calibrated synthetic models allow engineering teams to develop dashboards, test schema migrations, and evaluate machine learning models without storing or exposing sensitive user data.

Henish Patel

B.Sc. Computer Science student at Algoma University (graduating December 2026). Focusing on data pipelines, machine learning engineering, and production systems.