Skip to case study content
Projects

Case Study

SGR/MGA Formulation Engine

Contact
Internal case study

SGR/MGA Formulation Engine

Territorial Pre-Investment AI

When Colombian municipalities have the need but not the formulation capacity, this engine orders territorial chaos into traceable SGR/MGA artifacts — canon-driven, phase-gated, and built to stop before it lies.

SGR · MGAAgent PipelineCanon + ArtifactsGitLLMs
SGR/MGA Formulation Engine product preview
Role
AI Systems + Full Stack Engineer
Domain
Public Investment / SGR · MGA
Users
Territorial consultancy · municipal formulation
Market
Colombia
Stack
25 agents · 15-step pipeline · SGR/MGA canon
Continue to problem

Problem

Municipalities lose access to SGR resources not from lack of political will — but from formulation chaos they cannot fix alone.

Small and medium Colombian municipalities face a structural gap: clear public needs, intense pressure to secure regalías, and almost no installed capacity to structure defendible SGR/MGA pre-investment projects.

The territorial gap

Ordering chaos into defensible pre-investment structure — not disguising weak methodology with polished prose.

The bottleneck is not typing documents faster. It is poorly formulated problems, budgets and indicators without traceability, phase confusion between Perfil and Prefactibilidad, and projects that look polished but fail methodological review.

We are a software-engineering consultancy — not a traditional studies-and-designs firm. The product bet was building an internal formulation factory: disciplined SGR/MGA methodology, AI where it accelerates reasoning, real sources, verifiable artifacts, and a system that knows when to stop instead of inventing viability.

See the stakesThen see the formulation engine

Solution

A methodology engine for territorial pre-investment — not another municipal document generator.

SGR and MGA rules live as canon. Each case produces a versioned artifact trail in project/. A 15-step pipeline with human gates turns incomplete territorial inputs into deliverables a formulator can defend.

01

Triage

Before any structuring, the engine checks SGR eligibility, actor roles, funding source, and exclusions — stopping early when a case is out of scope instead of generating false confidence.

02

Structure

Problem tree, objectives, alternatives, value chain, and MGA structure — with parallel internal reviewers at the structure step to catch causal and catalog errors before they reach a viability instance.

03

Verify

Normative SGR matrix, ex-ante scope review, and phase-gate validation. Perfil requirements never mixed with Prefactibilidad — the most common failure mode in real territorial submissions.

04

Deliver

Gap report and maturation plan with full traceability — artifacts planning secretariats and allied consultants can continue from, not a chat transcript that disappears after the session.

What makes it work in practice

SGR/MGA canon layer

Normalized rules, checklists, and methodology in knowledge/ — read-only during case execution so normative source never drifts mid-formulation.

15-step formulation pipeline

Preflight triage through maturation plan — each step declares inputs, outputs, stop criteria, and explicit phase gates for Perfil vs. Prefactibilidad.

Skills as contracts

Every step is a contract: what it reads, produces, must not do, and when it halts — not open-ended prompts that improvise methodology.

Bounded agent context

25 specialized agents with granular permissions. The runner orchestrates; subagents reason with only the context their contract allows.

No-invention governance

Every field tagged provisto, inferido, supuesto, vacio, or no_verificado_en_canon. Missing data stays visible — never fabricated into a false viability story.

Artifact-first deliverables

Markdown outputs with Resumen Para Siguiente Paso — sources, assumptions, gaps, and pending decisions. Reviewable by humans and allied consultants, not trapped in chat history.

Impact

Real territorial cases. Defendible artifacts. Honest gaps.

Success is measured by what planning teams and reviewers can use — ordered pre-investment structure, traceable assumptions, and early detection of methodological weakness before a project reaches a viability instance.

01 - Territorial reality

Municipalities with reprioritized needs and political pressure to secure regalías — but without the formulation capacity to structure a defendible SGR/MGA pre-investment case.

02 - Engineered response

An internal formulation factory: canon-driven pipeline, 25 bounded agents, phase gates, and artifact-first deliverables that allied consultants can continue from.

03 - What changes

Faster, more traceable formulation with explicit stop conditions — gaps surfaced before presentation, not masked by polished documents that fail review.

System at a glance

15

Pipeline steps

Deterministic steps 0–14 from preflight triage through maturation plan, each with explicit stop criteria.

25

Configured agents

Step executors, parallel internal reviewers, auxiliaries, and external doc scout.

15+

Skill contracts

Reusable skills declaring inputs, outputs, limits, and stop conditions.

Generic AI makes municipalities look ready when they are not

The system reframes AI from a writer into a formulation discipline — producing artifacts planning secretariats can audit and gaps reviewers can act on before resources are spent.

Architecture

How the formulation engine is engineered.

Canon vs. artifacts, the 15-step agent pipeline, permission boundaries, and an internal runtime designed for auditable territorial work.

System Overview

A lightweight runner coordinates 15 step agents that read canon and prior case artifacts, write verifiable Markdown outputs, and halt on critical gaps — with parallel internal reviewers at the MGA structure step where causal errors are most costly.

Formulador
sgr-mga-runner
15 Step Agents
knowledge/
project/
LangGraph (planned)
LayerRole
FormuladorProvides case inputs and declares phase (Perfil / Prefactibilidad).
sgr-mga-runnerOrchestrator — invokes subagents via task, verifies artifacts, logs decisions.
15 Step AgentsRead canon, reason, write project/ artifacts per skill contract.
knowledge/SGR rules, MGA methodology, checklists — read-only during cases.
project/00_input through 09_plan — dynamic case outputs with traceability.
LangGraph (planned)Declarative DAG orchestration when pipeline complexity and volume justify migration.
OpenCodeSkillsSubagentsMarkdownGitLangGraph

Decisions

Lessons

Proven

What held up on real territorial work.

  • Canon before automation — SGR/MGA rules normalized in knowledge/ before any skill scales.
  • Profile is not feasibility — stopping phase mixing is more valuable than generating more pages.
  • No invention builds trust: vacio and no_verificado_en_canon are signals, not failures.

Evolving

What the next iteration targets.

  • Migrate orchestration to LangGraph once pilot repeatability is established across sectors.
  • Expand canon coverage for additional funding sources and sectoral depth.
  • Add RAG when knowledge/ exceeds practical context windows without losing traceability.

Transfer

What changed my engineering judgment.

  • The pipeline is the product — 15 explicit steps beat one omniscient agent on regulated methodology.
  • Skills substitute for orchestration nodes in early operation — the flow is the architecture.
  • Defer ML approval predictors — drafting quality and gap honesty matter more than scoring submissions you cannot yet write.

Next step

Want to see how territorial formulation can be engineered?

The implementation lives in a private repository used in active consultancy work. Reach out to walk through the pipeline design, governance model, or how artifact-first agents differ from document generators.