Architecture|~6 min read

2. The 5-Layer Multi-Agent AI Pipeline

In-depth breakdown of the 5-layer manufacturing process, prompt engineering v2.1.0, and 6Cs automated quality auditing.

01

Asynchronous Pipeline Lifecycle

How background jobs are scheduled, executed, checkpointed, and streamed to the client without timing out.

Requirements generation is an intensive process requiring 60–180 seconds of multi-agent reasoning. SRA orchestrates this using an asynchronous event-driven model:

  1. Job Dispatch: queueService.js computes an MD5 hash of the input for idempotency, creates an Analysis record with status PENDING, and publishes the job to Upstash QStash.
  2. Worker Ingestion: QStash delivers the webhook to POST /api/worker/process. workerController.js atomically transitions the record to IN_PROGRESS via updateMany to guarantee that duplicate webhook deliveries are safely ignored.
  3. Live SSE Streaming: The client connects to GET /api/analyze/:id/stream. Progress events (stage transitions, agent thoughts, section completions) are published to Redis Pub/Sub and pushed to the browser via Server-Sent Events (SSE).
  4. Serverless Budget Checkpointing (`pipelineBudget.js`): On serverless environments (e.g. Vercel 300s limit), the pipeline checks execution budgets before heavy stages. If time runs low, it checkpoints intermediate state to PostgreSQL and re-enqueues itself to continue seamlessly without data loss.

The 5 Sequential Layers

LayerNamePrimary ResponsibilityAgent / Service
Layer 1Intake MappingTranslates unstructured vision into canonical JSON draft schemaProductOwnerAgent
Layer 2Multi-Agent SystemParallel business value modeling, architecture design, and document synthesisProductOwner, Architect, Developer
Layer 3Objective ReviewAutomated 6Cs quality audit and RAG faithfulness scoringReviewerAgent, CriticAgent, evalService
Layer 4Refinement HubHuman-in-the-loop chat iterations, version branching, and self-healing diagramsChatAgent, DiagramRepair
Layer 5Knowledge IndexingSemantic shredding and vector embedding into pgvector for reuseragService, embeddingService
02

Layer 2: Multi-Agent System (MAS v2.1.0)

Coordinated role separation between Product Owner, Systems Architect, and Developer Agents using the v2.1.0 Gold Standard prompt registry.

Role-Based Agent Choreography

Rather than asking a single LLM to write an entire specification, SRA utilizes specialized agents with distinct domain responsibilities:

1. Product Owner Agent

  • Decomposes business goals, identifies primary/secondary user classes, defines operating environments, and establishes boundary constraints.
  • Formulates feature candidate lists and stimulus/response sequences.

2. Systems Architect Agent

  • Determines external interface requirements (User Interfaces, Hardware Interfaces, Software APIs, and Communication Protocols).
  • Generates Mermaid architecture diagrams (Sequence Diagrams, Flowcharts, Entity-Relationship Models).
  • Injects relevant historical design patterns retrieved from the vector knowledge base.

3. Developer Agent

  • Synthesizes the formal normative requirement statements ("The system shall...").
  • Formats each section according to the target standard's exact schema descriptor with intentional rate-limit cooldown throttles.
03

Layer 3: Objective Review & 6Cs Quality Audit

Algorithmic grading against the 6Cs quality standard and LLM-as-a-judge faithfulness scoring.

The 6Cs Quality Standard

Every generated specification is audited by the CriticAgent against six core software engineering metrics:

  1. Clarity: Unambiguous phrasing free of vague qualifiers ("fast", "user-friendly", "robust").
  2. Completeness: Compulsory coverage of all required sections, external interfaces, and non-functional constraints.
  3. Conciseness: High information density without fluff or duplicate requirement definitions.
  4. Consistency: Zero internal contradictions between functional rules, database entities, and user roles.
  5. Correctness: Valid Mermaid diagram syntax, proper RFC 2119 normative verbs ("SHALL", "SHOULD"), and accurate schema types.
  6. Context: Alignment with user-provided domain knowledge and historical organizational standards.

Reflection & Surgical Repair Loop:

  • If the aggregate quality score falls below 85/100, the ReviewerAgent flags specific deficient sections.
  • The pipeline enters a reflection pass (maximum 2 passes) where the Developer Agent performs surgical refinement only on the flagged sections, preserving the rest of the document intact.
Was this page helpful?

Help us improve the SRA enterprise documentation.