Strucsta LogoStrucsta/Documentation

Chapter 4: Designing Pixel-Perfect PDFs

Testing with Step Replay

Target Audience: Users crafting the visual output.

When building automated workflows, testing is often the most painful part of the process. In a standard pipeline, if you want to see how a layout change affects your final document, you have to submit a new test form, wait for the AI to reason about the data, and then wait for the PDF to render. This loop is slow, non-deterministic, and burns through your AI API credits.

Strucsta solves this with Step Replay, a feature designed to give you a sub-second feedback loop while designing templates or correcting production data.

What is Step Replay?

Because Strucsta persists a strict audit trail of every Run, the engine has a permanent record of the exact data state at every node in your Directed Acyclic Graph (DAG).

Step Replay allows you to select a historical run, edit the intermediate JSON data if necessary, and re-execute only a specific step.

When you replay the Render (pdfmaker) step, the engine grabs the frozen, flattened state from the AI Reasoning step and injects it directly into your current JSONC template.


The Two Core Workflows

Step Replay supports two critical "Human-in-the-Loop" scenarios: the developer design phase, and production data correction.

1. Template Design (The Dev Loop)

When you are actively writing your JSONC layout, you need to see exactly how your font sizes, margins, and column widths look.

Instead of running the full pipeline:

  1. Trigger your workflow once with test data so the AI generates a valid JSON payload.
  2. Open your Render step's Templates & Assets editor.
  3. Make adjustments to your template.json file.
  4. Click Preview (which triggers a Step Replay in the background).

The engine bypasses the Ingest and Reason steps completely, merging your updated JSONC layout with the existing test data to generate a new PDF instantly.

2. Data Correction (The Prod Loop)

Even with strict schema enforcement, generative AI can occasionally choose a word that doesn't quite fit your brand tone, or a client might request a minor revision to a generated contract.

Instead of discarding the document and forcing the AI to generate a brand new one from scratch:

  1. Open the specific Run in your Strucsta dashboard.
  2. View the output JSON produced by the Reason step.
  3. Manually edit the specific string (e.g., changing "The service fee is non-refundable" to "The service fee is partially refundable").
  4. Replay the Render step.

You get a perfectly formatted, revised PDF without having to re-prompt the AI or restart the entire workflow.


Why Step Replay Matters

  • Zero AI Costs: Replaying a Render step does not trigger external LLM APIs. You can iterate on a visual layout 100 times without spending a single OpenAI credit.
  • Absolute Consistency: LLMs are inherently non-deterministic. If you re-run the entire pipeline just to test a margin change, the AI might generate slightly different text, making it harder to debug visual overflow issues. Step Replay locks the data state, ensuring you are testing against a stable baseline.
  • Rapid Prototyping: The sub-second generation time allows you to treat PDF design almost like writing CSS with a live preview.

By decoupling the data generation (Reasoning) from the visual presentation (Rendering), Step Replay gives you the flexibility of human-in-the-loop oversight combined with the speed of automated layout generation.