DecidrHolon Design Kit

Technologies and APIs

Task types JSON

Schema, startup validation checks, and deterministic variant selection for task-types.json.

JSON
{
  "status": "draft",
  "note": "Placeholder prices in whole cents, set over the measured raw cost per call (24 Nov live). The real prices are set by a person. Each task type has one product (the holon's service for it) and one or more variants; a step's variant is chosen in code from the run's path.",
  "task_types": [
    {
      "id": "receive_message",
      "name": "Receive a message",
      "kind": "code",
      "steps": ["message.receive"],
      "product": { "id": "receive_message.service", "name": "Receive a message", "variants": [
        { "id": "code_only", "name": "Code only", "price_cents": 0, "unit": "message" }
      ] }
    },
    {
      "id": "screen_message",
      "name": "Screen a message",
      "kind": "code",
      "steps": ["message.screen"],
      "product": { "id": "screen_message.service", "name": "Screen a message", "variants": [
        { "id": "code_only", "name": "Code only", "price_cents": 0, "unit": "message" }
      ] }
    },
    {
      "id": "classify_message",
      "name": "Classify a message",
      "kind": "model",
      "steps": ["message.checks"],
      "product": { "id": "classify_message.service", "name": "Classify a message", "variants": [
        { "id": "standard", "name": "Standard", "price_cents": 1, "unit": "message" }
      ] }
    },
    {
      "id": "apply_rules",
      "name": "Apply the rules",
      "kind": "code",
      "steps": ["message.rules"],
      "product": { "id": "apply_rules.service", "name": "Apply the rules", "variants": [
        { "id": "code_only", "name": "Code only", "price_cents": 0, "unit": "message" }
      ] }
    },
    {
      "id": "prepare_reply",
      "name": "Prepare a reply",
      "kind": "model",
      "steps": ["message.reply"],
      "product": { "id": "prepare_reply.service", "name": "Prepare a reply", "variants": [
        { "id": "reviewed", "name": "Reviewed", "price_cents": 5, "unit": "reply" },
        { "id": "live", "name": "Live", "price_cents": 6, "unit": "reply" },
        { "id": "fixed", "name": "Fixed", "price_cents": 0, "unit": "reply" }
      ] }
    },
    {
      "id": "check_reply",
      "name": "Check a reply",
      "kind": "model",
      "steps": ["message.review"],
      "product": { "id": "check_reply.service", "name": "Check a reply", "variants": [
        { "id": "standard", "name": "Standard", "price_cents": 1, "unit": "reply" },
        { "id": "code_only", "name": "Code only", "price_cents": 0, "unit": "reply" }
      ] }
    },
    {
      "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" }
      ] }
    },
    {
      "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" }
      ] }
    },
    {
      "id": "explore_type",
      "name": "Explore a new type",
      "kind": "model",
      "steps": ["explore.explore"],
      "product": { "id": "explore_type.service", "name": "Explore a new type", "variants": [
        { "id": "standard", "name": "Standard", "price_cents": 250, "unit": "type" }
      ] }
    },
    {
      "id": "hold_for_review",
      "name": "Hold for a person to review",
      "kind": "code",
      "steps": ["explore.review"],
      "product": { "id": "hold_for_review.service", "name": "Hold for a person to review", "variants": [
        { "id": "code_only", "name": "Code only", "price_cents": 0, "unit": "type" }
      ] }
    }
  ]
}

Overview

task-types.json defines the step-level service task types that a holon's flows are billed as, kept in data rather than scattered through code. Reference: task-types.mjs Reference: task-types.json Each task type carries one product and one or more variants, each with a whole-cent price_cents and a unit. Screens always show Product · Variant · $X.XX / unit, never a bare Product or unlabelled price. Ruling 52 Wireframe review B12

flow.mjs calls loadTaskTypes() at module import time, so any missing or invalid file prevents the server from starting. Reference: flow.mjs Reference: task-types.mjs These step-level service types are distinct from the per-question decision task types in battery.mjs. Reference: task-types.mjs

All figures in task-types.json are placeholder draft prices set over measured raw model costs (status: "draft"). A typical reviewed message bills $0.07 ($0.01 classify + $0.05 reply + $0.01 check). Real commercial prices are set by a person, never by a model. Reference: task-types.json House note: three-service holon

Inputs

Top-level fields

FieldTypeRequiredPurpose
statusstringYesLifecycle marker ("draft" in the reference file)
notestringNoHuman-readable provenance and pricing note
task_typesarrayYesList of service task-type definitions

Task-type and variant fields

FieldTypeRequiredPurpose
idstringYesUnique snake-case task-type key (for example classify_message)
namestringYesDisplay name for the task type
kindstringYesExecution kind ("code" or "model")
stepsstring[]YesOne or more <flow>.<step> pairs mapped to this task type
product.idstringYesUnique product key across the file (for example classify_message.service)
product.namestringNo (recommended)Product display name
product.variantsarrayYesNon-empty list of purchasable variants
variants[].idstringYesUnique variant key within the product (code_only, standard, reviewed, live, fixed)
variants[].namestringYesHuman-readable variant label shown beside the product
variants[].price_centsintegerYesNon-negative whole number of cents (0 for code-only or fixed-line steps)
variants[].unitstringYesUnit billed (message, reply, run, organisation, type)

Outputs

validateTaskTypes(data) returns a frozen catalogue object with four properties: Reference: task-types.mjs

  • status: the top-level status string.
  • taskTypes: the validated list of task-type objects.
  • price(flow, step, variant): resolves ${flow}.${step} and returns { task_type, variant, price_cents }. Throws immediately if the (flow, step) pair is unmapped or if variant is not permitted for that pair in FLOW_STEPS.
  • public(): returns { [id]: { name, variants: { [variantId]: { name, price_cents } } } } for GET /api/state, stripping steps and unit. Reference: task-types.mjs Reference: flow.mjs

In flow.mjs, every emitted step carries { task_type, variant, price_cents, raw_cost_micro }. A step whose status is 'failed' sets price_cents: 0 while keeping its raw_cost_micro, and endRun excludes any step still in 'running' status when totalling run.price_cents and metrics.billedCents. Reference: flow.mjs

Topics

Allowed flow steps (FLOW_STEPS)

task-types.mjs declares the exact closed map of (flow, step) pairs that the console emits and the variants code may select for each: 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'],
});

Validation rules (validateTaskTypes)

validateTaskTypes collects every failure and throws a single combined error listing all problems: Reference: task-types.mjs

  1. The parsed root value must be a non-null object.
  2. status must be a non-empty trimmed string.
  3. task_types must be an array.
  4. Every task type must have a non-empty string id, unique across task_types.
  5. Every task type must have a non-empty string name and a non-empty string kind.
  6. Every task type must have a non-null product object with a non-empty string id, unique across all products.
  7. product.variants must be a non-empty array.
  8. Every variant must have a non-empty string id, unique within its product.
  9. Every variant must have a non-empty string name and a non-empty string unit.
  10. Every variant's price_cents must satisfy Number.isInteger(v.price_cents) && v.price_cents >= 0.
  11. Every task type's steps must be an array; each step pair must be an own property of FLOW_STEPS and cannot already be mapped to another task type.
  12. Every (flow, step) pair in FLOW_STEPS must map to a task type, and every variant listed for that pair in FLOW_STEPS must exist on that task type's product.variants. Reference: task-types.mjs

Deterministic variant selection

Code inside flow.mjs selects each step's variant solely from the run's execution path, never via model output: Reference: task-types.mjs Reference: flow.mjs

Flow stepVariant chosenExact condition in flow.mjs
message.replyfixed ($0.00)A blocking rule (redirect or abuse) fired, returning a fixed line without calling the reply model
message.replylive ($0.06)streamMode === 'live' AND no strict rule (adviser, privacy) fired
message.replyreviewed ($0.05)Default path: reply is held until code checks and the reply battery pass
message.reviewcode_only ($0.00)finish() caught a prompt 'leak' (short-circuiting the reply battery) OR reply reviewing is disabled
message.reviewstandard ($0.01)Code checks passed and the reply battery ran
All other FLOW_STEPSSingle listed variant'code_only' ($0.00) for code steps; 'standard' for message.checks ($0.01), profile.checks ($0.02), and explore.explore ($2.50)

See also