ProveCode

Verify real code ownership via 90-second AST mutation challenges, using Flagsmith multivariate experiments to measure whether failing edge-case hints boost verified developer completions.


Inspiration

With AI coding assistants capable of passing standard online coding assessments in seconds, passing hidden test cases no longer proves that a developer actually understands the code they submitted. Traditional online judges check static input/output correctness, leaving educators, recruiters, and engineering teams unable to distinguish genuine problem-solving mastery from copy-pasted AI output.

We built ProveCode to verify true code ownership—and integrated Flagsmith Experimentation to scientifically test how much failure context helps genuine authors prove their understanding without giving away the answer.


What It Does

ProveCode turns every passing coding submission into a live, 90-second code-ownership verification challenge:

  1. Standard Execution Gate: Users write and submit their solution in a Monaco-style code editor while passive telemetry tracks copy-paste ratios, keystroke cadence, and tab-blur events. Once all hidden test cases pass, ProveCode intercepts the standard "Accepted" verdict.
  2. Surgical AST Mutation (SilentSplice Engine): A Tree-sitter Concrete Syntax Tree (CST) mutation engine parses the user's own passing code and introduces a subtle, realistic edge-case bug (such as shifting <= to < in binary search, flipping === to !==, or swapping -Infinity to 0), filtering mutants against hidden test suites so basic smoke tests pass while edge cases fail.
  3. 90-Second "Save It" Lockdown: The editor locks into readOnly mode with a 90-second countdown timer. To prove authorship, the user must click the exact mutated line number and write a plain-English explanation of what changed and why it breaks the edge case.
  4. Hybrid AI Rubric Verdict: A deterministic line-match gate and local pre-filter pair with a structured LLM rubric (preferring on-device Gemini Nano inference via Firebase AI Logic with cloud Gemini fallback) to evaluate the explanation against the ground-truth AST diff—awarding a PROVEN or NOT YET verdict.
  5. AI Usage & Mastery Analytics Dashboard: Tracks self-written PROVEN solves versus AI-flagged submissions across monthly and yearly views, alongside an audit log of AST rules, Flagsmith experiment buckets, and behavioral telemetry signals.

Flagsmith Experimentation

To move beyond UX guesswork in high-pressure developer workflows, we wired Flagsmith Experimentation directly into the 90-second lockdown challenge:

  • Multivariate Flag: save_it_challenge_mode (50% control / 50% hint_assisted)
    • Control (control): Standard 90-second lockdown—the user sees only the mutated code and must locate the broken line and explain the bug from their own mental model.
    • Variant (hint_assisted): Displays the exact failing edge-case clue (input, expected, and mutated actual output) inside the lockdown panel.
  • Persistent User Identity: Every user is assigned a persistent Firebase Authentication UID (flagsmith.init({ environmentID, identity: uid })), guaranteeing users remain locked into the same experiment bucket across page reloads.
  • Conversion Event: flagsmith.trackEvent("challenge_proven") fires whenever a user passes the 90-second AST verification (VERDICT: PROVEN), allowing us to measure real conversion lift, Bayesian win probability, and credible intervals in Flagsmith.
  • Resilience & Live Updates: Configured with a 15-second polling interval and safe defaultFlags fallbacks so the application remains responsive even if network conditions fluctuate.

Architecture & Tech Stack

6-Step Pipeline

  1. Client Editor & Passive Telemetry: Captures pasteRatio, tabSwitches, and hint usage during authoring.
  2. Execution Gate: Validates solutions against public and hidden test suites before triggering mutation.
  3. Tree-sitter CST Mutation Engine: Uses UTF-8 byte offsets (startIndex to endIndex) to splice single-token mutations while preserving indentation, variable names, and comments.
  4. Non-Equivalent Mutant Filter: Runs candidate mutants in parallel and selects edge-case bugs passing 30%–85% of hidden tests, storing the secret ground truth (targetLine, originalToken, mutatedToken, expiresAt) in Firebase Firestore.
  5. 90-Second Lockdown UI: Renders the mutated code read-only, captures line-number clicks, and conditionally renders the Flagsmith hint_assisted edge-case clue.
  6. Hybrid AI Grader & Mastery Analytics: Evaluates explanations via Firebase AI Logic (on-device Gemini Nano + cloud Gemini fallback), fires Flagsmith conversion events, and logs verified proofs to Firestore.

Stack Breakdown

Layer Technologies
Frontend Next.js, React, TypeScript, Tailwind CSS, Monaco Editor (@monaco-editor/react)
Feature Flags & A/B Testing Flagsmith SDK (Multivariate flags, identify, trackEvent, live polling)
Primary Backend & Database Firebase Authentication, Cloud Firestore, Node.js
AST Engine tree-sitter, tree-sitter-javascript, tree-sitter-python
AI Verification Firebase AI Logic (On-device Gemini Nano + Cloud Gemini fallback)

Challenges We Ran Into

  • Filtering Non-Equivalent Mutants: Naive token swaps frequently produced syntax errors or broke every test case immediately. Running candidate mutants against our hidden test suite and filtering for 30%–85% pass rates ensured injected bugs specifically target algorithmic edge cases.
  • Preventing Answer Leaks & Bucket Drift: Exposing ground-truth line numbers on the client risked DevTools inspection, while anonymous reloads risked shifting users between A/B variants. Storing secret diffs in Firestore and binding Flagsmith identities directly to persistent Firebase UIDs solved both cleanly.
  • Balancing Hint Helpfulness vs. False Positives: Surfacing the failing edge case in Variant B needed to aid genuine authors without enabling blind guessing, requiring strict rubric prompts that verify both line-change identification and logical consequence.

Accomplishments That We're Proud Of

  • Built a lossless Tree-sitter byte-slice mutation engine that generates realistic, edge-case-specific bugs from a developer's own passing code in milliseconds.
  • Embedded a real Flagsmith multivariate A/B test at the core of the verification workflow to measure how edge-case feedback impacts verified completion rates.
  • Delivered both an interactive Active Verification Arena and an AI Usage & Mastery Analytics Dashboard backed by Firebase and Flagsmith.

What We Learned

  • Start With Multivariate Flags: Initializing a multivariate flag from day one with persistent user IDs avoids fragmented analytics and makes Flagsmith's Bayesian experimentation metrics immediately actionable.
  • AST Byte Offsets Beat Regex: Operating on Tree-sitter CST byte ranges guarantees surgical code mutations without breaking formatting or comments.
  • Data-Driven Developer UX: Even subtle UI changes under time pressure—like showing a single failing edge case during a 90-second timer—measurably affect completion behavior when instrumented with conversion events.

What's Next for ProveCode

  • Expanded Language & Multi-Hunk Support: Adding C++, Java, and Go grammars to the Tree-sitter mutator along with multi-line invariant mutations.
  • Automated Progressive Rollout: Using Flagsmith's Bayesian confidence thresholds and user segments (pasteRatio tiers) to dynamically tune hint visibility.
  • Shareable Cryptographic Proof Badges: Generating verifiable public proof URLs backed by Firestore records for developer portfolios and technical hiring.

Built With

Share this project:

Updates

Submission history