Sector F Logo

Sector F Labs


exp-013-service-pipe

1. Title:

Service Pipe Architecture Evaluation: Composing Services with Unix-Style Pipes with messages formated in JSONL

2. Experiment Number & Status:

3. Abstract / Summary:

This experiment proposes to evaluate the effectiveness of composing independent services using Unix-style pipes. It focuses on a lightweight, stream-based protocol leveraging JSON Lines (JSONL) with structured message tagging ("type" and "correlationId") to enable highly composable, modular, and reconfigurable architectures. Key areas of exploration include efficient message processing, scaling patterns (batch parallelism with gnu parallel, multi-client distribution with a load-balancer utility), and integrating arbitrary commands via jsonl-wrap. The primary demonstration system for this experiment will be a Telegram bot backend pipeline, showcasing end-to-end user request processing.

4. Motivation:

As systems grow in complexity, the need for highly modular, reconfigurable, and language-agnostic components becomes critical. This experiment is motivated by the desire to explore a simple yet powerful paradigm—Unix pipes—as a robust foundation for inter-service communication. By standardizing on JSONL streaming and specific message protocol rules, we aim to reduce coupling, simplify deployment, and enhance the ability to dynamically chain and adapt services, mirroring the composability found in traditional shell scripting but for complex application logic.

5. Goal / Hypothesis:

We hypothesize that a stream-based, JSONL-centric pipe protocol, combined with clear message typing and correlation, will allow independent services to be seamlessly composed and reconfigured through simple command-line operations. This approach is expected to yield highly composable, modular, efficient, and language-agnostic system architectures capable of handling both batch and continuous data streams, as well as enabling various scaling patterns.

6. Methodology:

This experiment involves developing and testing a pipeline where services are chained using Unix pipes, with communication strictly adhering to a defined JSONL streaming protocol.

All findings, unexpected outcomes, performance observations, and debugging insights will be documented in a logs/ directory with entries dated in ISO format (e.g., logs/2025-05-31-pipeline-performance.md, logs/2025-06-02-load-balancer-behavior.md). This documentation will capture both successful patterns and failure modes to inform future iterations and architectural decisions.

Primary Demonstration System:

The core of this experiment will be proven by implementing and observing the following Telegram bot backend pipeline:

telegram-in \
| auth-service \
| capability-dispatcher --capabilities 'canned-responder;llm-responder' \
| load-balancer --workers 4 \
| parallel --jobs 4 --pipe --line-buffer 'llm-proxy | response-formatter' \
| telegram-out

Let's break down how each service in this specific pipeline adheres to the proposed pipe protocol and contributes to the overall goals:

Environment Variables for Telegram Adapters

The Kafka connection details are provided through the following variables:

An example message is provided at telegram-out/example.jsonl. Run cat telegram-out/example.jsonl | telegram-out to quickly test the adapter.

General Pipe Protocol Adherence:

Beyond this specific pipeline, the experiment will generally ensure:

Additional Utilities and Patterns Demonstrated:

7. Success Criteria:

The experiment will be deemed successful if:

8. Potential Challenges / Considerations:

9. Expected Outcome / Learnings:

We expect to validate the significant advantages of this Unix-pipe, JSONL-based approach:

10. Conclusion / Next Steps (Post-Experiment):

The primary outcome of this experiment will be a set of learnings and insights to inform the development of the utility commands and supporting tools necessary to make this architectural pattern feasible for production use. Rather than integrating into an existing system, the focus will be on identifying and building the essential utilities and protocols required for robust, composable, and maintainable pipe-based service architectures. Next steps may include:

11. References / Related Work: