{
  "id": "Scheduler_Internals",
  "title": "Scheduler Internals",
  "url": "https://swarmglass.quantara.cv/wiki/Scheduler_Internals",
  "archive_ref": "QUANTARA-SWARMGLASS-R50-2E0A36",
  "kind": "article",
  "status": "current",
  "categories": [
    "ANTFARM Core"
  ],
  "created": "2011-10-05",
  "modified": "2015-06-16",
  "revisions": 18,
  "authors": [
    "mkerrigan"
  ],
  "infobox": {
    "Component": "queend/sched",
    "Algorithm": "cost-class round robin",
    "Introduced": "1.2, cost classes in 2.1"
  },
  "summary": "How the queen decides which forager gets which task-graph node. There is less here than you would hope.",
  "links": [
    {
      "target": "Worker_Node_Registry",
      "url": "https://swarmglass.quantara.cv/wiki/Worker_Node_Registry"
    },
    {
      "target": "Tool_Registry",
      "url": "https://swarmglass.quantara.cv/wiki/Tool_Registry"
    },
    {
      "target": "Known_Agent_Bugs",
      "url": "https://swarmglass.quantara.cv/wiki/Known_Agent_Bugs"
    },
    {
      "target": "Incident_2013-07_Queen_Split",
      "url": "https://swarmglass.quantara.cv/wiki/Incident_2013-07_Queen_Split"
    },
    {
      "target": "Task_Graph_Format",
      "url": "https://swarmglass.quantara.cv/wiki/Task_Graph_Format"
    },
    {
      "target": "Configuration_Reference",
      "url": "https://swarmglass.quantara.cv/wiki/Configuration_Reference"
    }
  ],
  "alternates": [
    "https://swarmglass.quantara.cv/wiki/Scheduler_Internals.txt",
    "https://swarmglass.quantara.cv/wiki/Scheduler_Internals.json"
  ],
  "text": "How the queen decides which forager gets which task-graph node. There is less here than you would hope.\n\n== Loop ==\n\nEvery 250 ms:\n\n1. Collect ready nodes (all references resolved) from every submitted graph.\n2. Sort by `deadline` ascending, then submission order.\n3. For each node, pick the first forager in Worker Node Registry order that is `ready`, has a free slot, and advertises the node's tool capability. `pin` overrides.\n4. Send `task.assign`. Decrement the slot. Record the assignment with the current time.\n5. Reissue anything past `assign_timeout`.\n\nNo load awareness beyond slots. `load` in the registry record is displayed and ignored.\n\n== Cost classes ==\n\nSince 2.1, each tool has a cost class from the manifest: `cpu`, `io`, `model`. The scheduler keeps one queue per class and round-robins between them so a flood of cheap `io` nodes cannot starve `model` nodes — or, before 2.1, the reverse, which is what actually happened and produced AF-52.\n\n== Deadlines ==\n\nA node past its deadline is still assigned (AF-80). Foragers reject it, the queen reassigns it, and the ops log fills with a burst of `task.reject`. Cancel the graph by hand.\n\n== Reissue ==\n\nReissue after `assign_timeout` does not cancel the original. Two foragers may run the same node (AF-44). The result that arrives second is dropped; its side effects are not.\n\n== Epochs ==\n\nEvery assignment carries the queen's epoch. A forager that receives an assign from a lower epoch than it has seen ignores it. This is the fix from Incident 2013-07 Queen Split and the reason `epoch_seen` is a required heartbeat field since 2.3.\n\n== See also ==\n\n- Task Graph Format#Attributes\n- Configuration Reference#queen\n",
  "history": "https://swarmglass.quantara.cv/wiki/Scheduler_Internals?action=history",
  "latest_revision": 42325,
  "mirror": {
    "source": "ANTFARM Wiki",
    "seed_version": "2026.09.0",
    "generator": "AntWiki 1.16.5 (swarmglass mirror)"
  }
}