Mapper

Workflows that survive a crash, and agents that wait for a person

A directory of 30,858 Colombian companies; a hand review of 15 found 14 correct, against a minimum of 13. Two agents research a prospect or draft a proposal, then stop until a person approves.

Role
Sole engineer · automation, agents and operations
Status
Directory in production · agents in early runs
Built with
n8n, PostgreSQL, Supabase, JavaScript, Claude, Claude Code, MCP, Playwright

What I built and where it stands

I'm the only engineer at a firm that sells data analysis, automation and AI to small and mid-size companies in Colombia. Its slowest sales steps were finding companies worth talking to, preparing a first meeting and writing the proposal, so I built one tool for each.

The directory holds 30,858 companies and runs as n8n workflows over a PostgreSQL queue that retries without duplicating rows. Before its first production run I set a minimum of 13 correct out of 15 companies reviewed by hand. It got 14.

One agent researches a prospect after a person confirms it has the right company; the other drafts a proposal once the owner approves the offer. Nothing reaches a prospect unless a person sends it.

The directory is in production. The agents have had few runs and the first proposal hasn't been sent, so for them I report the design and its checks, not sales results.

How it flows

  1. Every company comes from the open data of Supersociedades, the companies regulator, and goes into a PostgreSQL queue on Supabase.
  2. n8n workflows take companies from the queue, find each one's website, read it while respecting robots.txt and store its contacts.
  3. The prospect agent looks the company up in the commercial registry and waits for a person to confirm it. Then it researches, saves a brief to a shared drive and, through MCP, opens one task per area in the team's task manager.
  4. Once the owner approves the offer, the proposal pipeline produces the PDF.

No step in the directory calls a model. It doesn't score leads, since a score would look precise without any data on which companies become clients. And it doesn't write messages that would speak for the firm before anyone read them.

The queue, and what broke in production

The workflows claim companies with FOR UPDATE SKIP LOCKED, so two runs never hold the same one. A claim lasts 20 minutes; if a process dies, its companies return to the queue when it expires, with at most 3 attempts each. Each company has a single row that gets updated, and contacts are written with ON CONFLICT on company, type and value, so a rerun duplicates nothing.

A three-minute DNS failure tested this. One batch did its work and couldn't save it, and most of it went back to the queue when the claims expired. Nine companies already on their third attempt were marked failed and stopped there, in plain view, instead of retrying forever.

The other incident: an online store with 687 forms on its home page. The parser cleaned the page again on every loop, and each match kept a reference to its own copy. One batch pushed the process to 2 GB of memory and killed it. Now the parser cleans each page once, and the same store takes 97 ms with 256 MB of heap.

The agents

The prospect agent checks identity first, because a brief about the wrong company is useless. A person confirms the match before any research runs, and the confirmed record then works as a filter: any later fact that doesn't match its tax ID, city, website or profiles is dropped.

Three helpers on a smaller model research the business, the decision maker and the competition in parallel, and they can only search and read the web. The main agent checks ad libraries in a browser, re-verifies the key facts and writes the brief.

Each fact carries its source, the date it was seen and whether it was seen or inferred. The agent never guesses a count, date or figure, and says so when a page can't be read.

Since the brief lives in a shared drive, Colombia's data protection law limits it to professional information. It leaves out family, home address, personal phone or email, ID numbers, health, politics, religion and photos. It has no prices and no verdict on whether the prospect is worth pursuing; that call belongs to whoever goes to the meeting.

A proposal draft goes through automatic checks: banned terms, leftovers from the previous client, long sentences, fonts not embedded, and a file too heavy for a phone. The internal version can't contain a single price. A panel of model reviewers can flag issues but can't block or approve; the owner decides.

Both agents run as Claude Code skills. A person starts and approves every run, so a hosted service would add something else to deploy and secure without adding control.

If a page carries hidden instructions

The prospect agent reads pages anyone can publish and writes to a shared drive and the task manager, so a page could carry instructions meant for it. I haven't built a defense aimed at that, and nothing filters what the agent reads. The damage is limited by controls that exist for other reasons:

  • research only starts on a company a person confirmed;
  • facts that don't match its record are dropped;
  • the helpers can only search and read the web;
  • no model contacts a prospect or fills in a form.

A page could still slant a brief, or get the agent to create or change tasks and files it has access to. I haven't tested the agents against a page written to mislead them.

How I checked it

The table covers the directory; so far the agents only have structural checks on every output.

Mapper chart: the minimum set before launch was 13 of 15 companies right; the hand review found 14, across 5 of Colombia's departments.
A hand review of 15 directory companies, against a minimum set before its first production run.
Measure Result
Minimum for the directory at least 13 of 15 companies correct, set before the run
Manual review 14 of 15 correct, across 5 Colombian departments
Failure found a domain-for-sale page taken as the company's site
After the fix re-check of 91 websites out of the 1,395 built from the company's legal name (part of the 10,380 found): 3 rejected (3.3%)
Companies with a website found 10,380 of 30,858 (33.6%)
Contact email other than the accounting mailbox 74% from the Supersociedades filings alone, 77.5% after reading the websites

Keeping it running

I'm the only engineer on these tools. The workflows' code lives in plain JavaScript modules outside n8n, and a script embeds it into the workflow definitions. The directory's schema isn't exposed through the public API and has Row Level Security. n8n gets its own limited role, and the schema only changes through migrations reviewed in a pull request.

The directory has no monthly cost, since it only uses free sources and free quotas. The team's task manager is separate: I self-host it on a VPS, with a daily copy of its database kept for 14 days and an hourly off-server backup kept for 90.

Limits and next

A single sample of 15 companies can catch a systematic error, but it can't measure a rate precisely. 14 of 15 fits anything from about 70% to 99% correct. And until the agents have an eval set, I can't say how often the brief gets things right.

That set is designed and is the next thing I'll run. It's built from the briefs the team has already used: for each fact, whether it was right and whether it mattered in the meeting. With it I can tell whether a prompt or model change makes the brief better or worse.