Distributed System Flow Tracer #784
farukzahra
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Distributed System Flow Tracer
Purpose
Trace an application entry point through a distributed system and reconstruct the complete downstream interaction graph.
Given an API endpoint, function, command, event, or other entry point, investigate the code and infrastructure to discover:
The final result should be a Mermaid graph representing the discovered flow.
The skill must be technology-agnostic.
Do not assume a specific:
Examples of technologies that may be encountered include Java, TypeScript, Python, Go, C#, Kafka, Google Pub/Sub, RabbitMQ, AWS SQS/SNS, Azure Service Bus, NATS, HTTP, gRPC, webhooks, and others.
Core Principle
Start from an entry point and recursively follow the system.
Do not attempt to document the entire architecture upfront.
The investigation should be entry-point driven.
For example:
The goal is to discover this flow automatically.
Input
The user should provide an entry point such as:
or:
or:
or:
If the user provides an API endpoint, use it as the root of the investigation.
Investigation Algorithm
Step 1 — Identify the Entry Point
Locate the implementation of the requested entry point.
Determine:
Do not rely only on filenames or documentation.
Prefer evidence from source code and configuration.
Record the discovered node.
Example:
Step 2 — Inspect the Execution Flow
Follow the implementation far enough to identify meaningful downstream interactions.
Look for:
Do not assume that every function call represents a distributed-system edge.
Focus on interactions that cross application, process, infrastructure, or system boundaries.
Step 3 — Normalize Interactions
Regardless of the underlying technology, normalize discovered interactions into generic concepts.
Use concepts such as:
And relationships such as:
The internal representation should not depend on Kafka, Pub/Sub, RabbitMQ, Java, Spring, etc.
For example:
may all represent a messaging relationship:
Preserve the actual technology as metadata when it is known.
Example:
Step 4 — Follow Synchronous Dependencies
When the current component calls another service synchronously:
identify the target service and continue investigating that service.
Determine:
Continue recursively.
Step 5 — Follow Asynchronous Dependencies
When the current component publishes a message or event:
identify the messaging destination.
Determine, using the available environment and tools:
For each discovered consumer:
open or locate the consumer's implementation and inspect what it does.
Then continue recursively.
Step 6 — Continue Recursively
Every discovered service becomes a new investigation point.
For example:
Continue until no new meaningful downstream interactions are discovered.
The traversal must work across mixed technologies.
Example:
Do not stop because the technology changes.
Step 7 — Avoid Cycles
Distributed systems may contain cycles.
Maintain a set of already investigated nodes and relationships.
For example:
Do not recursively investigate the same node forever.
When a previously discovered node is encountered:
record the relationship but do not traverse it again.
Evidence and Confidence
Prefer direct evidence over assumptions.
Evidence may come from:
When possible, preserve the evidence supporting each relationship.
Example:
If a relationship is inferred rather than directly verified, mark it as inferred.
Do not fabricate architecture.
If the relationship cannot be verified, state that clearly.
Technology-Agnostic Investigation
Never hard-code assumptions such as:
as the only discovery mechanism.
Instead reason about the behavior:
Likewise, do not assume:
is the only way a message is produced.
Look for the actual implementation patterns used by the project.
The agent may use:
Choose the appropriate tool based on the environment.
Mermaid Output
The primary output must be a Mermaid graph.
Prefer a clear top-down graph:
graph TD API["POST /orders"] ORDER["Order Service"] EVENT1["order.created"] BILLING["Billing Service"] EVENT2["invoice.created"] NOTIFICATION["Notification Service"] API --> ORDER ORDER -->|publishes| EVENT1 EVENT1 -->|consumed by| BILLING BILLING -->|publishes| EVENT2 EVENT2 -->|consumed by| NOTIFICATIONKeep the graph readable.
Do not create a separate node for every function call.
Only include implementation details when they help explain a distributed interaction.
Output Requirements
The final response should contain:
1. Mermaid Graph
The complete discovered flow.
2. Short Summary
Briefly describe:
3. Unverified Relationships
List relationships that could not be confirmed.
Example:
Do not hide uncertainty.
Investigation Rules
Example
User:
The agent discovers:
The final output should be:
graph TD API["POST /orders"] ORDER["order-service"] ORDER_EVENT["order.created"] INVENTORY["inventory-service"] INVENTORY_EVENT["inventory.reserved"] BILLING["billing-service"] INVOICE_EVENT["invoice.created"] NOTIFICATION["notification-service"] API --> ORDER ORDER -->|publishes| ORDER_EVENT ORDER_EVENT -->|consumed by| INVENTORY ORDER_EVENT -->|consumed by| BILLING INVENTORY -->|publishes| INVENTORY_EVENT BILLING -->|publishes| INVOICE_EVENT INVOICE_EVENT -->|consumed by| NOTIFICATIONThe technology used to implement this flow is secondary.
The objective is to answer one question:
All reactions