Skip to content

Workflow HDSL — HarnessDSL & Canonical Topology

In AGBoss (Agent Graph Builder Open Source System), a workflow is written in HarnessDSL (HDSL) — the declarative graph grammar and verification specification built into AGBoss (analogous to JSX in React or PSL in Prisma). While AGBoss is the framework, static compiler (agboss check), and production runtime on LangGraph (npm i @agboss/core), HarnessDSL is the grammar used inside *.workflow.ts and contract decorators to specify flow chains, narrow @Dto contracts, Path Scope, in-degree = 1 vs in-degree >= 2 canonical topology, { about } staleness tracking, quorums, and compensateWith / committedBy sagas. In a @Workflow class, flow is a list of paths. Each path reads like a sentence starting at a source (start(StartClass), agent(AgentClass), router(RouterClass), action(ActionClass), workflow(ChildWorkflow)), with strictly one chained call per line (@stylistic/newline-per-chained-call), and every value produced on an edge declared explicitly via .returns(...).

Canonical Topology Isomorphism (in-degree = 1 vs in-degree >= 2)

Section titled “Canonical Topology Isomorphism (in-degree = 1 vs in-degree >= 2)”

When AI coding agents edit unconstrained graph definitions, they can format the exact same topology in ten different ways — creating deep nesting pyramids and unreviewable Git diffs. AGBoss enforces a 1-to-1 structural isomorphism (Principle 3) verified by agboss check:

  1. Single incoming edge (in-degree = 1): A node reached from only one predecessor must be chained inline (.toAgent(NextStep)).
  2. Convergence node (in-degree >= 2): A node reached from two or more edges (for example, MainRouter reached both from start(IntakeWorkflowStart) and from the caseOf(ProfileDto) loop-back) must be extracted as a top-level entry (router(MainRouter), agent(ReviewerAgent), action(MergeAction)) in the flow: [...] array ([flow.shared-node-inline]).
  3. One chained call per line: Every builder method call occupies its own line, and inline branch nesting is capped at depth 4 ([flow.path-too-deep]).

How HDSL paths, .chooseOne(route()), and .switch(caseOf()) work

Section titled “How HDSL paths, .chooseOne(route()), and .switch(caseOf()) work”

Components declare their typed input fields and output DTO (or oneOf(DtoA, DtoB) union), while the @Workflow({ flow: [...] }) array holds the entire control-flow topology and data flow:

How review loops use { about } and historyOf

Section titled “How review loops use { about } and historyOf”

When a reviewer evaluates an artifact (such as OfferDraftDto), attach { about: OfferDraftDto } (or { about: [DtoA, DtoB] }) on a single output .returns(CritiqueDto, { about: PlanDto }) or on a specific union branch caseOf(ChangesRequestedDto, { about: OfferDraftDto }) (never on .returns(oneOf(...)) and never as a positional helper):

  • Automatic outdating of stale reviews: When the editor produces a fresh OfferDraftDto, any earlier ChangesRequestedDto or DraftApprovedDto that was { about: OfferDraftDto } is automatically marked outdated in Path Scope so downstream nodes can never consume a stale v1 decision paired with a v2 draft ([input.outdated-on-path], [launch.branch-outdates-sibling]).
  • Bounded iteration history (historyOf(Dto, { limit })): Steps that need to inspect prior drafts or critique rounds declare historyOf(OfferDraftDto, { limit: 3 }) in their input contract to receive { current, previous: [...] } instead of manual state arrays or legacy string tags.

How parallel launches, quorums, and recursion work

Section titled “How parallel launches, quorums, and recursion work”

For concurrent execution and hierarchical composition, HarnessDSL (HDSL) provides four additional primitives:

  1. Parallel launches (.toParallelAgents() / .toParallelWorkflows()): Run multiple distinct agents (SecurityAgent, LegalAgent, { maxConcurrency: 3 }) or fan out across a listOf(ItemDto) ({ maxItems: 20, maxConcurrency: 4 }), followed by .join() and .onJoinError(...).
  2. Consensus quorums (.joinQuorum() / .joinQuorumGroups()): Continue as soon as { min, max, deadline: seconds(30) } answers are accepted by @Arbiter rules attached via .acceptedBy(ArbiterClass) or .acceptedBy(anyOf(A, B)), cancelling surplus branches immediately.
  3. Workflow as a step (.toWorkflow(ChildWorkflow) / .toParallelWorkflows()): Run a child @Workflow as an isolated execution with its own maxSteps and Path Scope, branching on its finishes via .returns(oneOf(...)).switch(caseOf(...)...).
  4. Bounded self-recursion (ThisWorkflow): Pass ThisWorkflow to .toWorkflow(ThisWorkflow), route(ThisWorkflow), or .toParallelWorkflows(ThisWorkflow, { maxItems }) with @Workflow({ maxDepth: 3, maxConcurrentExecutions: 6 }). At depth === maxDepth (soft stop), the runtime automatically strips the recursive oneOf variant or router target from the model’s schema so the run converges cleanly (warming two prefix cache entries: depth < maxDepth and depth === maxDepth).