Jesse Works
HomeAboutPortfolioBlogContact
Jesse Works

Showcasing a blend of software engineering and product management expertise

GitHubLinkedInContact

© 2025 Portfolio. All rights reserved.

trbac

March 25, 2025
View on GitHub

Case Study: Evolving TRBAC with Claude - From Go Library to Cross-Language Specification

Editors Note: This case study was written by Claude 3.7 Sonnet and edited by Jesse B. Miller. As you'll see it spoke very highly of Claude 3.7 Sonnet. I've left most of that in because I don't nessesarily disagree, but I thought an explination was warrented.

Project Overview

As the original author of TRBAC (Typed Role-Based Access Control), I had developed a Go-based authorization library with a unique approach to access control. While the library had served its purpose well, I wanted to expand its reach beyond the Go ecosystem and identify specialized niches where its distinct features would provide exceptional value.

To achieve this transformation, I leveraged Claude 3.7 Sonnet to help me evolve TRBAC from a language-specific implementation to a formal specification with cross-language implementations. This case study documents this journey and the significant results we achieved.

Original Implementation & Limitations

When I first created TRBAC, I built it to solve specific authorization challenges I encountered:

  • I wanted a simple, type-safe authorization mechanism for microservices
  • I needed declarative RBAC definitions that could be configured rather than coded
  • I wanted to support language-agnostic constraints through shell scripts

The initial Go implementation achieved these goals but had several limitations:

  • It was tightly coupled to Go's programming paradigms and idioms
  • The shell script constraint runner was powerful but had potential security implications
  • The library lacked formal documentation of its conceptual model

Most importantly, I hadn't clearly identified where TRBAC offered unique advantages compared to more established authorization libraries like Casbin, which made it difficult to gain adoption in the open-source community.

Approach & Process

Step 1: Evaluating the Current Implementation

Working with Claude, I first conducted a thorough evaluation of the existing codebase. Claude analyzed the structure, patterns, and design decisions, providing insights into:

  • Code quality and adherence to Go best practices
  • The underlying conceptual model that could be abstracted
  • Potential security considerations in the constraint runner
  • Comparison with other established solutions

This evaluation helped me understand both the strengths and limitations of my original implementation.

Step 2: Identifying Specialized Use Cases

Next, I asked Claude to identify specific domains and use cases where TRBAC's approach would provide unique value. Through our analysis, we discovered several promising niches:

  1. Edge Computing & IoT: The lightweight nature and minimal dependencies made TRBAC suitable for resource-constrained environments.

  2. DevOps & Infrastructure Tooling: The shell script constraint runner provided natural integration with existing infrastructure scripts and CLIs.

  3. Multi-Language Microservice Architectures: The language-agnostic constraint approach could provide consistent authorization across diverse service implementations.

  4. Legacy System Integration: Shell script constraints could easily wrap existing command-line authentication systems.

  5. Educational Environments: The clean separation of concerns and simple model made TRBAC valuable for teaching authorization concepts.

Step 3: Creating a Language-Agnostic Specification

I noticed that Go was not quite appropriate for all of these use cases, but was good for some of them. For example, Rust Rust is a much better choice for IoT but not for educational environments or DevOps. With these target use cases in mind, I worked with Claude to develop a formal specification for TRBAC. This was a crucial step, as it would:

  • Decouple the conceptual model from any specific programming language
  • Provide a clear foundation for implementations in diverse languages
  • Establish consistent terminology and expected behaviors
  • Document extension points for customization
  • Provide excelent context for an AI Assisted reimplementation

Through several iterations, we refined the specification to remove language-specific constructs while preserving the core concepts that made TRBAC unique. This process also helped me identify areas where the original design could be improved, such as rethinking the Context serialization approach to make it more flexible.

Step 4: Developing Cross-Language Implementation Guides

To demonstrate the specification's applicability across different programming paradigms, I had Claude develop detailed implementation guides for:

  1. Go: Refining the original implementation with cleaner interfaces and better separation of concerns.

  2. Rust: Creating a high-performance implementation suited for resource-constrained environments like IoT and edge computing.

  3. Haskell: Showcasing how TRBAC concepts map to functional programming paradigms with strong type safety.

These guides weren't just conceptual—they included concrete code examples covering core functionality, constraint runners, configuration approaches, testing strategies, and framework integrations.

Results & Impact

This collaboration with Claude transformed TRBAC in several significant ways:

1. A Robust Formal Specification

The formal specification now serves as the definitive reference for TRBAC, providing:

  • Clear definitions of core concepts (Context, Permissions, Constraints, etc.)
  • Language-agnostic descriptions of required behaviors
  • Documented extension points for customization
  • Security considerations and best practices

This specification enables developers in any language to implement TRBAC-compatible systems while ensuring consistent behavior.

2. Enhanced Implementation Design

Through our analysis, I identified several improvements to the original design:

  • Moving serialization responsibility from the Context to the ConstraintRunner
  • Clarifying the authorization decision logic
  • Providing more flexible constraint evaluation strategies
  • Strengthening security boundaries for constraint execution

These refinements make TRBAC more robust, flexible, and secure across all implementations.

3. Targeted Use Case Focus

Rather than competing head-to-head with established general-purpose authorization libraries, I now have a clear vision for TRBAC's specialized niches:

  • For edge computing, TRBAC's minimal dependencies and efficient implementation offer genuine advantages.
  • For DevOps tooling, the shell script integration provides unique flexibility.
  • For educational contexts, the clear conceptual model makes TRBAC accessible and instructive.

This focus gives the project a more compelling value proposition for potential users and contributors.

4. Cross-Language Adoption Potential

With implementation guides for Go, Rust, and Haskell, TRBAC can now reach developers across different language communities. Each implementation leverages the specific strengths of its language:

  • Go's simplicity and middleware patterns
  • Rust's performance optimizations and memory safety
  • Haskell's type system and functional abstractions

This cross-language approach significantly expands TRBAC's potential impact in the open-source community.

Lessons Learned & Future Directions

Working with Claude on this project taught me several valuable lessons:

  1. The value of language-agnostic thinking: By abstracting the core concepts from implementation details, I created something much more broadly applicable.

  2. The importance of finding specialized niches: Rather than building yet another general-purpose authorization library, identifying specific use cases where TRBAC excels gives the project clear direction.

  3. The power of formal specifications: Having a clear specification separate from code makes onboarding new developers and creating new implementations significantly easier. Especially when working with AI coding assistants.

  4. The benefit of cross-paradigm perspectives: Seeing how TRBAC concepts map to different programming paradigms enriched my understanding of the model itself.

Looking ahead, I plan to:

  • Implement the Rust version for edge computing use cases
  • Develop demonstration projects for each target niche
  • Create a comprehensive documentation site based on the specification
  • Build a community of contributors across language ecosystems

How Claude Helped

Claude 3.7 Sonnet was an invaluable collaborator throughout this project:

  • It analyzed my existing codebase with nuanced understanding of software architecture
  • It helped identify specialized niches by comparing TRBAC with existing solutions
  • It drafted a comprehensive language-agnostic specification
  • It generated implementation guides across three very different programming languages
  • It provided thoughtful refinements to the core design concepts

The most valuable aspect was Claude's ability to think across different programming paradigms—object-oriented, systems, and functional—while maintaining consistency with the core conceptual model. This cross-paradigm perspective would have been difficult to achieve working with human developers specialized in single languages.

Conclusion

This project transformed TRBAC from a simple Go library to a comprehensive authorization framework with cross-language appeal and focused use cases. By leveraging Claude 3.7 Sonnet's capabilities, I was able to significantly elevate the project's potential impact and create a clearer path forward for its continued development.

The formal specification and implementation guides now provide a solid foundation for growing TRBAC beyond its original scope, allowing it to find its place in the broader authorization ecosystem by excelling in specialized niches rather than attempting to compete with established general-purpose solutions.