Abraham Hernández Castro

In production · 2 factories

Defabric

A multi-tenant ERP for flexible-packaging plants, with a Claude agent layer where every write waits for a person.

Role
Founder & Product Lead
Years
Jan 2026 – present
Status
In production at 2 factories
Stack
Claude API · React · Node · three.js / R3F · SSE
defabric · IA → Planta
Defabric's “Plant” view: an isometric 3D plant with departments, machines and agent markers, and an activity feed listing which agent delegated to which.
Real production UI (animated screenshot) · demo tenant “Ana Demo” · no customer or worker data
01 · Problem

A whole plant in one ERP, and agents that never write on their own.

An ERP for flexible packaging has to cover the whole plant: sales, production planning and lots, quality, warehouse, purchasing, HR, payroll and administration. The goal was to let people ask for work in plain language and let agents do the looking-up and the proposing, without a model ever writing to production data on its own.

That constraint shapes the architecture: agents read and propose; people confirm; the server re-checks.

02 · The system

A hierarchy of agents with a single way out: you.

FIG 1 · Agent layer architecture01 / 06
Defabric agent layerA person asks from the chat or a kiosk. The Director agent delegates to department leads, who delegate to work-center coordinators. Coordinators call read tools, or propose tools that only create a draft with an audit log. The person confirms the draft, which then runs with their own token against the ERP API. Tokens are metered per user and agent, and progress streams back over SSE.SURFACESAGENT LAYER · CLAUDETOOLS = TEAM ∩ USER PERMISSIONSperson · chat / kioskDirectorProductionQualityPurchasingHRExtrusionPrintingcoordinatorsread · pending_to_makepropose_* → draft + audit log✓ Confirm · your tokenERP APIsame endpoints as UIlive progress · SSEmetertokens · user · agent
Simplified diagram (4 of the departments, 2 of the coordinators). Tool names simplified.
  1. A person asks

    From the ERP chat or a shop-floor kiosk, in plain language. The request goes to the Director agent.

  2. The Director delegates

    It doesn't do everything itself: it hands off to the right department lead (Production, Quality, Purchasing, HR…).

  3. Leads delegate to coordinators

    Each work center (Extrusion, Printing…) has a coordinator with its own context and tools.

  4. Scoped tools

    An agent only sees its team's tools intersected with the user's permissions. Read tools run; propose_* tools don't write: they create a draft with an audit log.

  5. The person confirms

    Pressing Confirm runs the action with that person's own token, against the same endpoints and permissions as the screen. Single-use draft, expires in 15 min, re-verified on confirm.

  6. Everything is metered and visible

    Agent progress streams live over SSE, and token usage is recorded per user and per agent.

03 · How the agents work

One task, from question to Confirm.

trace · demo tenantillustrative
you       › "What's pending on Extrusion 1? Re-plan it if needed."director  → production.lead            delegateproduction→ extrusion.coord            delegateextrusion · pending_to_make(center: "Extrusion 1")          ✓ read · demo dataextrusion · propose_schedule(order: DEMO-1042, …)          → draft · no write · single-use · 15:00⏸ awaiting human approvalyou       ✓ Confirm · runs with your tokenapi       re-verify → unchanged → write ok · audit
tools/propose.tssketch · real excerpt pending
// Shape of a gated tool (simplified sketch, not production code)
export const proposeSchedule = defineTool({
  name: "propose_schedule",
  team: ["production"],             // ∩ user permissions
  requires: "production.schedule.write",
  async run(input, ctx) {
    // never writes: creates a draft the user must confirm
    return ctx.drafts.create({
      action: "schedule.update", input,
      singleUse: true, expiresIn: "15m",
      snapshot: await ctx.read.order(input.order),
    });
  },
});

The trace is an illustrative replay with demo data; the sketch shows the shape, not the real code (a sanitized excerpt from the repo is pending).

04 · Human gates & guardrails

Try it: confirm a draft.

Simulator · demo tenant
Draft · awaiting your Confirm15:00
Action
schedule.update
Order
DEMO-1042
Line
Extrusion 1
Proposed by
extrusion.coord

    What the agent cannot do without a person: any write. Schedules, time-clock fixes, loans and production orders all wait for explicit confirmation, with an audit log.

    And how the code enforces it: the agent has no write endpoints at all; only the Confirm button calls them, with the token of whoever presses it.

    Drafts, not writes

    The propose_* tools only create a draft and an audit entry.

    Your token, your permissions

    Confirm executes with the person's session, against the same endpoints as the screen.

    Single use, 15 minutes

    Each draft can be used once and expires after 15 minutes.

    Re-verified on confirm

    If the order changed since the draft, it is rejected.

    Scoped tools

    Agent's team ∩ user's permissions.

    Metered

    Token usage per user and per agent.

    Extra · plant in 3D

    Walk a stylized plant and watch the agents delegate.

    A low-poly recreation inspired by the real Plant view, with demo data. Loads only if you open it.

    Explore in 3D
    Abraham's 3D character in a safety vest on a flexible-packaging plant floor, holding a laptop that shows a dashboard
    AI-generated character
    05 · Results

    Only what has a source.

    WhatValueSource
    Factories in production2Self-reported · 2026
    ERP modules8Self-reported: sales, planning & lots, quality, warehouse, purchasing, HR, payroll, admin
    Agent writes without human confirmation0By design: agents have no write endpoints
    Time saved per requestNot measured yet—
    Draft acceptance rateNot measured yet—
    06 · Stack

    What it's built with.

    Claude API · tool useHierarchical subagentsReactNode.jsthree.js · React Three FiberServer-Sent EventsObject storageShop-floor kiosks
    Next case
    MNDA Studio

    Building agents for real operations? Let's talk.