DecidrHolon Design Kit

Tutorials

Add a task type

Define a priced task type from canonical action types, validate it in task-types.json, display its variant price and record its run as events.

Time: 30 minutes · You need: Node, a copy of the reference console folder, and a working local holon from Build your first holon.

A task type is Decidr's atomic wholesale unit of work: one goal, bounded ordered context, one output cell, one evaluation criterion, a repeating frequency, and a Product -> Variant price in dollars and cents. Doctrine §5 Doctrine §10 Wireframe spec B Ruling 52 In this tutorial you will walk through the worked Profile an organisation task type (profile_organisation) from the specification and task-types.json, register its flow step, pass startup validation, render its price correctly, record its run as immutable events, and check it against the review guidelines. Wireframe spec B Reference: task-types.json Reference: task-types.mjs

Section 1: Choose the action chain and the one output

Follow the engineer's loop: start from the flow rather than a table, decompose until the task type is atomic, and declare the context shape generically so the same task type runs for any organisation supplying that shape. Doctrine §6 Doctrine §10

Every task type chains canonical verb-tense action types across three deterministic slots: intake (read, watch, listen, or observe), deliberation (consider), and commitment (select, enter, upload, or count). Wireframe spec A1 Wireframe spec B Human approvals use confirm and stop at hold_for_review because holons never approve. Constitution 1.7 Wireframe review B17 Wireframe review C2

  1. Map the action chain for Profile an organisation (profile_organisation), assigned to the Organisation holon for EFS in Greenwich NSW. Intake pulls only the minimum required context under the Tail-Light Rule; deliberation evaluates the closed question bank with zero public confidence scores; commitment records controlled linked values rather than naked strings. Wireframe spec B Ruling 17 Ruling 18 Schema rules §3.1
JSON
{
  "task_type": "profile_organisation",
  "name": "Profile an organisation",
  "context_shape": {
    "entity_type": "org",
    "inputs": ["public website snapshot", "ABN record"]
  },
  "action_chain": [
    { "slot": "intake", "action": "read", "event": "read" },
    { "slot": "deliberation", "action": "consider", "event": "considered" },
    { "slot": "commitment", "action": "select", "event": "selected" }
  ],
  "output": "Controlled organisation profile attributes (sector, customers, offer clarity, and verified predicates); missing required fields logged as unknown for a person"
}
  1. Check the closed evaluation questions that back the consider and select slots. In battery.mjs, ORG_SEED declares 13 atomic checks (10 predicates, 2 controlled choices sector and customers, and 1 four-level score offer_clarity). Each question checks one observable fact from evidence, and any missing required attribute becomes unknown rather than a guess. Reference: battery.mjs Constitution, article 2
JavaScript
// Excerpt from battery.mjs (ORG_SEED):
t('org', 'standard', {
  type: 'choice',
  name: 'sector',
  instructions: 'Which sector does the organisation mainly work in?',
  choices: [
    { value: 'financial_services', description: 'Advice, lending, insurance, banking, superannuation.' },
    { value: 'professional_services', description: 'Accounting, legal, consulting, engineering, design.' },
    { value: 'other', description: 'None of these.' },
  ],
}),
t('org', 'standard', {
  type: 'score',
  name: 'offer_clarity',
  instructions: 'How clearly does the evidence say what a customer gets and on what terms?',
  levels: [
    { label: 'Not stated', description: 'No offer is described.' },
    { label: 'Vague', description: 'Offerings are named but not what they include.' },
    { label: 'Clear', description: 'What each offering includes is described.' },
    { label: 'Clear with terms', description: 'What each includes is described, with price or how it is charged.' },
  ],
})
  1. Choose the execution kind and check how work splits between code, model, and people. Pure rule and storage steps run as code_only at $0.00 (zero model tokens); model-backed classification or profiling steps run as a priced variant whose draft price clears measured raw model costs; steps needing human sign-off hand off to a person with a companion text reasoning box beside logical-reasoning answers. Ruling 4 Ruling 27 Wireframe review C2
Text
Task kind mapping (from function-holon specification):
- Rule step:                         Read -> Consider (rule) -> Select / Send         ($0.00 code_only)
- AI Specialist step:                Read -> Consider (checks) -> Select              (priced variant, e.g. $0.02)
- AI Specialist, person confirms:    Read -> Consider -> Select -> hold_for_review    (holon draft + person confirm)
- Person step (including approvals): Read / Watch / Listen -> Consider -> Confirm     (human only, never holon)

Section 2: Add the entry to task-types.json

Task types and their prices live in console/task-types.json as data, not code. Each task type has one product (the holon's service for that work) and one or more variants, each carrying a non-negative integer price_cents and a unit. Reference: task-types.json Reference: task-types.mjs

  1. Add (or inspect) the profile_organisation entry in console/task-types.json. Notice how steps links the task type to the exact flow.step pair profile.checks, and how the Standard variant sets price_cents: 2 ($0.02) with unit: "organisation". Reference: task-types.json Wireframe spec B
JSON
{
  "id": "profile_organisation",
  "name": "Profile an organisation",
  "kind": "model",
  "steps": ["profile.checks"],
  "product": {
    "id": "profile_organisation.service",
    "name": "Profile an organisation",
    "variants": [
      {
        "id": "standard",
        "name": "Standard",
        "price_cents": 2,
        "unit": "organisation"
      }
    ]
  }
}
  1. Map the deterministic storage step (profile.stored) to store_record at price_cents: 0 (code_only). Deterministic lookups, counts, rules and storage steps always bill $0.00 and consume zero model tokens. Reference: task-types.json Ruling 4
JSON
{
  "id": "store_record",
  "name": "Store the record",
  "kind": "code",
  "steps": ["message.stored", "profile.stored"],
  "product": {
    "id": "store_record.service",
    "name": "Store the record",
    "variants": [
      {
        "id": "code_only",
        "name": "Code only",
        "price_cents": 0,
        "unit": "run"
      }
    ]
  }
}
  1. Check every name, product.name and variant name against Decidr's canonical vocabulary before saving. Use plain Australian English, avoid retired or banned verbs, and never include internal IDs or vendor names. Ruling 40 Ruling 41 Ruling 42 Wireframe review C2
JSON
{
  "status": "draft",
  "note": "Whole-cent draft prices set above measured raw model costs. A person approves production prices.",
  "task_types": [
    {
      "id": "profile_organisation",
      "name": "Profile an organisation",
      "kind": "model",
      "steps": ["profile.checks"],
      "product": {
        "id": "profile_organisation.service",
        "name": "Profile an organisation",
        "variants": [
          { "id": "standard", "name": "Standard", "price_cents": 2, "unit": "organisation" }
        ]
      }
    }
  ]
}

Section 3: Register the step and pass validateTaskTypes

flow.mjs calls loadTaskTypes() at module import time, which runs validateTaskTypes(data) against FLOW_STEPS in task-types.mjs. Any missing mapping, duplicate ID or invalid price stops the server at startup before a single request is served. Reference: task-types.mjs Reference: flow.mjs

  1. Confirm every (flow.step) pair your task type handles is declared in FLOW_STEPS in console/task-types.mjs alongside the exact variant IDs that deterministic code may choose for it. Reference: task-types.mjs
JavaScript
export const FLOW_STEPS = Object.freeze({
  'message.receive': ['code_only'],
  'message.screen': ['code_only'],
  'message.checks': ['standard'],
  'message.rules': ['code_only'],
  'message.reply': ['reviewed', 'live', 'fixed'],
  'message.review': ['standard', 'code_only'],
  'message.stored': ['code_only'],
  'profile.checks': ['standard'],
  'profile.stored': ['code_only'],
  'explore.explore': ['standard'],
  'explore.review': ['code_only'],
});
  1. Verify your entry satisfies every check enforced by validateTaskTypes() in task-types.mjs:
    • The file parses as an object with a non-empty status string and a task_types array.
    • Each task type has a non-empty, unique id, a non-empty name, and a non-empty kind.
    • Each task type has a product object with a non-empty, unique product.id and a non-empty variants list.
    • Each variant has a non-empty id (unique within its product), a non-empty name, a non-empty unit, and a price_cents value that is a non-negative integer (0 or higher, whole cents only).
    • steps is a list where every entry exists in FLOW_STEPS, and no step pair is claimed by two task types.
    • Every (flow.step) pair in FLOW_STEPS maps to one task type, and every allowed variant listed for that pair exists on that task type's product. Reference: task-types.mjs
Shell
node -e "import('./console/task-types.mjs').then(m => { const c = m.loadTaskTypes(); console.log(c.status, c.price('profile', 'checks', 'standard')); })"
# -> draft { task_type: 'profile_organisation', variant: 'standard', price_cents: 2 }
  1. Check endpoint coverage before adding a brand-new flow beyond profile. In the current reference server.mjs, POST /api/profile-checks is live for profile_organisation. The general per-step runner endpoints specified for function holons (POST /api/task-step for intake, consider and select, and POST /api/task-confirm for human confirmation with reasoning) are not yet built in server.mjs; see Console endpoints for what is live versus specified. Reference: server.mjs Wireframe review C3
JavaScript
// Live in server.mjs today for profile_organisation:
if (p === '/api/profile-checks') {
  if (paused()) return send(res, 200, { ok: false, paused: true });
  if (publicMode && (!limiter.hit(`profile:s:${sid}`, limits.sessionProfile) || !limiter.hit('profile:day', limits.dayProfile))) {
    return send(res, 429, { ok: false, limited: 'profile' });
  }
  return await admitAndRun(s, req, res, addr, () => s.flows.profileChecks());
}

Section 4: Show the price on screen

Customer and operator interfaces never display a bare parent Product and never display an unlabelled bare price. Always format every priced task type as Product · Variant · $X.XX / unit, using whole cents rendered to dollars and cents. Ruling 52 Wireframe review B12 Reference: money.js

  1. Format price_cents with formatCents() from console/ui/money.js so $0.02 always renders with two decimal places (0 renders as $0.00). Note that task-types.mjs's public() summary currently returns name and price_cents without unit; to show the full unit label on screen, read unit from the task-type definition or include unit in your catalogue serializer. Reference: money.js Reference: task-types.mjs
JavaScript
import { formatCents } from './console/ui/money.js';

function formatVariantPrice(productName, variant) {
  return `${productName} · ${variant.name} · ${formatCents(variant.price_cents)} / ${variant.unit}`;
}

// formatVariantPrice('Profile an organisation', { name: 'Standard', price_cents: 2, unit: 'organisation' })
// -> "Profile an organisation · Standard · $0.02 / organisation"
  1. Render the task type card cleanly on a single light surface with its level glyph, action chain, and formatted Product · Variant · $X.XX / unit line. Keep raw model cost (raw_cost_micro) off public edge ports; raw cost telemetry belongs strictly on the internal loopback port. Holon rules §1.3 Wireframe review C6 Wireframe review B12
Organisation holon Profile an organisation
Model
1. Read · 2. Consider · 3. Select
Entity EFS (Greenwich NSW)
Profile an organisation · Standard · $0.02 / organisation
HTML
<div class="hx-card hx-stack">
  <div class="hx-spread">
    <div class="hx-row">
      <img class="hx-glyph" src="assets/glyphs/organisation.svg" alt="Organisation holon">
      <span class="hx-title">Profile an organisation</span>
    </div>
    <span class="hx-chip">Model</span>
  </div>
  <div class="hx-steps hx-small hx-muted">1. Read · 2. Consider · 3. Select</div>
  <div class="hx-field">
    <span class="hx-small hx-muted">Entity</span>
    <span>EFS (Greenwich NSW)</span>
  </div>
  <div class="hx-price">Profile an organisation · Standard · $0.02 / organisation</div>
</div>

Section 5: Record the run as events

The append-only event log is the source of truth; projections and UI summaries are rebuilt from events. Ruling 15 Doctrine §10 In flow.mjs, deterministic code selects the step's variant from the run's path (never by a model), computes its whole-cent price via taskTypes.price(), bills $0.00 if a step fails (while retaining internal raw cost), and appends an immutable event to the local decision store. Reference: flow.mjs Reference: decision-store.mjs

  1. Inspect step() and profileChecks() in console/flow.mjs. When profile.checks completes, flow.mjs calls store?.addRun() (recording the run and each individual decision row) and store?.addEvent() (recording each finished step payload into holon_flow_events), then sums finished step prices in endRun(). Reference: flow.mjs Reference: decision-store.mjs
JavaScript
// From flow.mjs: variant pricing and append-only event emission
function step(run, name, data, flow, variant = 'code_only', rawMicro = 0) {
  const tt = taskTypes.price(flow, name, variant);
  const s = {
    name,
    ...data,
    task_type: tt.task_type,
    variant: tt.variant,
    price_cents: data.status === 'failed' ? 0 : tt.price_cents,
    raw_cost_micro: Math.max(0, Math.round(Number(rawMicro) || 0)),
  };
  const i = run.steps.findIndex(x => x.name === name);
  if (i >= 0) run.steps[i] = s; else run.steps.push(s);
  emit({ type: 'run.step', runId: run.id, step: s });
  if (s.status === 'done' || s.status === 'failed' || s.status === 'stopped') {
    store?.addEvent({ runId: run.id, holon: holonName, flow, step: name, payload: s });
  }
}
  1. Trigger POST /api/profile-checks against your local console on 127.0.0.1:4981 and watch the streamed events. Reference: server.mjs Reference: flow.mjs
Shell
curl -N -X POST http://127.0.0.1:4981/api/profile-checks \
  -H 'content-type: application/json' \
  -H 'accept: text/event-stream' \
  -d '{}'
  1. Inspect the recorded run.done and step events. profile.checks bills 2 cents ($0.02) on success (0 cents on failure), profile.stored bills 0 cents ($0.00), and every step lands in holon_flow_events keyed by run_id so the entire run is replayable. Reference: flow.mjs Reference: decision-store.mjs
JSON
{
  "type": "run.done",
  "runId": "00000000-0000-4000-8000-000000000001",
  "run": {
    "status": "done",
    "ms": 1420,
    "price_cents": 2
  }
}

Section 6: Check it against the review guidelines

Before your task type ships, verify both its flow contract (section 2) and its commerce and operations contract (section 8) in the Review guidelines.

  1. Run an automated catalogue check in Node confirming validateTaskTypes() succeeds, every variant has a positive or zero whole-cent price and non-empty unit, and every formatted price line matches Product · Variant · $X.XX / unit. Reference: task-types.mjs Reference: money.js Wireframe review B12
Shell
node -e "
import('./console/task-types.mjs').then(async ({ loadTaskTypes }) => {
  const { formatCents } = await import('./console/ui/money.js');
  const cat = loadTaskTypes();
  for (const t of cat.taskTypes) {
    for (const v of t.product.variants) {
      console.log(\`\${t.product.name} · \${v.name} · \${formatCents(v.price_cents)} / \${v.unit}\`);
    }
  }
});
"
  1. Walk every applicable rule in Review guidelines before sign-off:
Text
Task-type sign-off summary:
- Action chain declared (intake -> consider -> commitment)
- Single output cell, linked entity IDs for reference values
- Validated by loadTaskTypes() at startup
- Displayed as Product · Variant · $X.XX / unit (no discounts, flat legal fees)
- Failed steps bill $0.00; completed steps append immutable events

Check your understanding

  1. Who chooses which variant applies when a flow step runs: the model or deterministic code?

    Answer: Deterministic code in flow.mjs always selects the variant from the run's path (such as standard, reviewed, fixed, or code_only) and validates it through taskTypes.price(flow, step, variant). A model never picks a variant or a price. Reference: task-types.mjs Reference: flow.mjs

  2. What happens if profile.checks fails because the decisions service is unavailable?

    Answer: flow.mjs records the step as failed, sets price_cents to 0 so the failed step bills $0.00, retains any internal raw_cost_micro, and still emits the step event to the append-only store. Reference: flow.mjs

  3. Why is displaying $0.02 alone on a task-type card rejected in review?

    Answer: Every priced surface must identify the Product, the Variant, and the unit price in dollars and cents (Profile an organisation · Standard · $0.02 / organisation). Showing a bare price or a bare parent Product violates the commerce guidelines. Ruling 52 Wireframe review B12

Next

Read the full file schema in task-types.json reference and the action-type composition rules in Task types. When you are ready to wire new routes, check Console endpoints and the Review guidelines.