Interlude: A Lesson in Principle — Romo Lampkin and the Contract Playbook

Sometimes, progress doesn’t come in the straight line you expect. Today was one of those days.

I stepped away from redlining contracts and diving deep into tracked changes. Instead, I took a detour — a diversion courtesy of Google AI Studio, or as the universe would have it, Syrio Forel. Brilliant UI/UX generator, but sometimes unpredictable, slightly dodgy logic, and no match for the Mervyn Trants of the world when it come into hardcore coding (Antigravity and Cursor). The target? Contract Playbooks, built in Superdoc.

Forel, ever the genius with a flair for chaos, had already wired up a working MVP. Playbooks were being generated, LLM rules structured, clause analysis hooked up. But… embeddings? They existed only in the ephemeral ether. The JSON playbook persisted, but the vector fingerprints — the fingerprints! — had nowhere to live. Storage would have to be handled manually.

While watching this unfold, I had a sharp reminder of legal principle — and human sanity — thanks to Romo Lampkin. Lampkin, the man of quiet authority, reminded me that “free in AGPLv3 does not mean free of charge.” A simple truth, but one easily ignored in the rush to integrate a library or call an API. That lesson crystallized today’s work: intellectual clarity matters as much as technical correctness.


Project Highlights from the Playbook Diversion

1. Superdoc Editor Integration

  • Successfully embedded Superdoc via CDN (unpkg.com/superdoc/dist/superdoc.umd.js) in a React/TypeScript/Tailwind environment.
  • Encapsulated all library-specific logic in SuperdocEditor.tsx to protect the main app from AGPLv3 quirks.
  • Fixed initialization race conditions using cleanup timers and stable prop references.
  • Added resilient polling for global object detection (window.SuperDocLibrary).

2. Blank Editor Fixes

  • Null document in configuration was breaking initialization; omitted the property entirely for blank states.
  • CSS adjustments to ensure text visibility and stable layout.
  • Flexbox layout with min-height ensured proper canvas rendering on all devices.

3. UI/UX Improvements

  • Added "Debug Mode" for editor isolation.
  • Implemented placeholder Settings modal.
  • Built RiskCard and DetailView for review sidebar workflow.

4. Backend / AI Logic

  • DocxParser using JSZip preserves XML numbering for accurate clause references.
  • Playbook generation: chunk → Gemini LLM → JSON structure.
  • "Review" mode analyses contracts against the playbook and surfaces risk findings.

5. Dead Ends & Lessons Learned

  • Dynamic imports failed; switched to standard <script> CDN injection.
  • Superdoc’s namespace quirks required detection logic for UMD library exposure.
  • Layout and CSS quirks resolved with Flexbox + explicit dimensions.
  • Console logging of circular references fixed with sanitized objects.

6. Next Objectives

  • Implement Tracked Changes inside Superdoc: programmatic insertion, user attribution ("Contract AI"), UI hooks for Accept/Reject.
  • Refine party detection regex/LLM prompts.
  • Polish the detail view for responsive layouts on small screens.

Forel’s side mission reminded me of a fundamental truth: the MVP succeeds because humans inspect every line of the foundational blocks. He could generate clauses and structure a playbook automatically, but without careful architecture and debugging, critical details — like embeddings — vanish.

Lampkin’s principle echoes in my mind: even when the code is “free,” the cost of misunderstanding or misusing it is real. Today’s detour into Superdoc and Gemini wasn’t just a technical exercise — it was a lesson in discipline, persistence, and respecting the rules of the game, both legal and technical.

Google AI Studio is really fun to play with and you can even vibe code from your phone. Gorgeous UI/UX too (meaning it gives your apps beautiful UI). Perhaps I will see this through, another Superdoc proof of concept before hacking MS Word again .