[{"data":1,"prerenderedAt":1981},["ShallowReactive",2],{"docs-\u002Fdocs\u002Fv2\u002Fcognets\u002Fbuilding\u002Fzero":3},{"id":4,"title":5,"body":6,"description":1974,"extension":1975,"meta":1976,"navigation":205,"path":1977,"seo":1978,"stem":1979,"__hash__":1980},"docs\u002Fdocs\u002Fv2\u002Fcognets\u002Fbuilding\u002Fzero.md","Anatomy of zero",{"type":7,"value":8,"toc":1959},"minimark",[9,13,21,46,49,54,57,60,142,146,258,265,269,501,504,523,527,531,603,606,621,633,636,739,750,753,756,1339,1342,1354,1368,1374,1380,1394,1397,1476,1479,1494,1497,1534,1537,1549,1553,1836,1845,1851,1855,1858,1868,1874,1880,1888,1892,1895,1952,1955],[10,11,5],"h1",{"id":12},"anatomy-of-zero",[14,15,16,20],"p",{},[17,18,19],"code",{},"@axon\u002Fzero"," is the default cognet — the brain every agent runs unless it selects another.\nIt is about 120 lines, and it is the thing you clone when you want to build your own.",[22,23,28],"pre",{"className":24,"code":25,"language":26,"meta":27,"style":27},"language-bash shiki shiki-themes dark-plus","axon clone @axon\u002Fzero\n","bash","",[17,29,30],{"__ignoreMap":27},[31,32,35,39,43],"span",{"class":33,"line":34},"line",1,[31,36,38],{"class":37},"sCudf","axon",[31,40,42],{"class":41},"sKc5r"," clone",[31,44,45],{"class":41}," @axon\u002Fzero\n",[14,47,48],{},"This page reads all of it.",[50,51,53],"h2",{"id":52},"what-it-is","What it is",[14,55,56],{},"A conversational agent loop: fold the log, render context, call one engine, decide per\nblock what becomes real, repeat until the model says it's done and nothing is pending.",[14,58,59],{},"Three files.",[22,61,63],{"className":24,"code":62,"language":26,"meta":27,"style":27},"zero\u002F\n├── src\u002F\n│   ├── main.ts       # the loop\n│   └── state.ts      # the resident model\n├── plugins\u002F\n│   └── setup.ts      # boot hydration, shutdown checkpoint\n└── cognet.config.ts  # identity\n",[17,64,65,70,79,95,109,117,130],{"__ignoreMap":27},[31,66,67],{"class":33,"line":34},[31,68,69],{"class":37},"zero\u002F\n",[31,71,73,76],{"class":33,"line":72},2,[31,74,75],{"class":37},"├──",[31,77,78],{"class":41}," src\u002F\n",[31,80,82,85,88,91],{"class":33,"line":81},3,[31,83,84],{"class":37},"│",[31,86,87],{"class":41},"   ├──",[31,89,90],{"class":41}," main.ts",[31,92,94],{"class":93},"sOLPB","       # the loop\n",[31,96,98,100,103,106],{"class":33,"line":97},4,[31,99,84],{"class":37},[31,101,102],{"class":41},"   └──",[31,104,105],{"class":41}," state.ts",[31,107,108],{"class":93},"      # the resident model\n",[31,110,112,114],{"class":33,"line":111},5,[31,113,75],{"class":37},[31,115,116],{"class":41}," plugins\u002F\n",[31,118,120,122,124,127],{"class":33,"line":119},6,[31,121,84],{"class":37},[31,123,102],{"class":41},[31,125,126],{"class":41}," setup.ts",[31,128,129],{"class":93},"      # boot hydration, shutdown checkpoint\n",[31,131,133,136,139],{"class":33,"line":132},7,[31,134,135],{"class":37},"└──",[31,137,138],{"class":41}," cognet.config.ts",[31,140,141],{"class":93},"  # identity\n",[50,143,145],{"id":144},"identity","Identity",[22,147,151],{"className":148,"code":149,"language":150,"meta":27,"style":27},"language-ts shiki shiki-themes dark-plus","export default defineCognet({\n    name: \"zero\",\n    version: \"0.1.0\",\n    abi: \"9\",\n\n    mode: { kind: \"invocation\" },\n\n    \u002F\u002F runaway guard: a wake that hasn't converged in this many\n    \u002F\u002F render→infer→act ticks is a loop bug or a stuck model, not progress\n    maxTicksPerWake: 32,\n})\n","ts",[17,152,153,169,181,191,201,207,224,228,234,240,252],{"__ignoreMap":27},[31,154,155,159,162,165],{"class":33,"line":34},[31,156,158],{"class":157},"sYbnZ","export",[31,160,161],{"class":157}," default",[31,163,164],{"class":37}," defineCognet",[31,166,168],{"class":167},"sTNBD","({\n",[31,170,171,175,178],{"class":33,"line":72},[31,172,174],{"class":173},"s3F5K","    name:",[31,176,177],{"class":41}," \"zero\"",[31,179,180],{"class":167},",\n",[31,182,183,186,189],{"class":33,"line":81},[31,184,185],{"class":173},"    version:",[31,187,188],{"class":41}," \"0.1.0\"",[31,190,180],{"class":167},[31,192,193,196,199],{"class":33,"line":97},[31,194,195],{"class":173},"    abi:",[31,197,198],{"class":41}," \"9\"",[31,200,180],{"class":167},[31,202,203],{"class":33,"line":111},[31,204,206],{"emptyLinePlaceholder":205},true,"\n",[31,208,209,212,215,218,221],{"class":33,"line":119},[31,210,211],{"class":173},"    mode:",[31,213,214],{"class":167}," { ",[31,216,217],{"class":173},"kind:",[31,219,220],{"class":41}," \"invocation\"",[31,222,223],{"class":167}," },\n",[31,225,226],{"class":33,"line":132},[31,227,206],{"emptyLinePlaceholder":205},[31,229,231],{"class":33,"line":230},8,[31,232,233],{"class":93},"    \u002F\u002F runaway guard: a wake that hasn't converged in this many\n",[31,235,237],{"class":33,"line":236},9,[31,238,239],{"class":93},"    \u002F\u002F render→infer→act ticks is a loop bug or a stuck model, not progress\n",[31,241,243,246,250],{"class":33,"line":242},10,[31,244,245],{"class":173},"    maxTicksPerWake:",[31,247,249],{"class":248},"sDGX8"," 32",[31,251,180],{"class":167},[31,253,255],{"class":33,"line":254},11,[31,256,257],{"class":167},"})\n",[14,259,260,261,264],{},"Invocation mode: it sleeps until a stimulus arrives. ",[17,262,263],{},"maxTicksPerWake: 32"," is a safety\nnet — in practice zero converges in two or three.",[50,266,268],{"id":267},"the-resident-model","The resident model",[22,270,272],{"className":148,"code":271,"language":150,"meta":27,"style":27},"export type ZeroState = {\n    entries: AxonEntry[]\n    seq: number\n}\n\nexport const state: ZeroState = {\n    entries: [],\n    seq: -1,\n}\n\nexport function sync(): void {\n    for (const entry of kernel.store.session.get({ after: state.seq })) {\n        state.entries.push(entry)\n        state.seq = entry.time.seq\n    }\n}\n",[17,273,274,289,303,313,318,322,340,348,361,365,369,388,441,466,490,496],{"__ignoreMap":27},[31,275,276,278,282,286],{"class":33,"line":34},[31,277,158],{"class":157},[31,279,281],{"class":280},"scz_3"," type",[31,283,285],{"class":284},"sNl3T"," ZeroState",[31,287,288],{"class":167}," = {\n",[31,290,291,294,297,300],{"class":33,"line":72},[31,292,293],{"class":173},"    entries",[31,295,296],{"class":167},": ",[31,298,299],{"class":284},"AxonEntry",[31,301,302],{"class":167},"[]\n",[31,304,305,308,310],{"class":33,"line":81},[31,306,307],{"class":173},"    seq",[31,309,296],{"class":167},[31,311,312],{"class":284},"number\n",[31,314,315],{"class":33,"line":97},[31,316,317],{"class":167},"}\n",[31,319,320],{"class":33,"line":111},[31,321,206],{"emptyLinePlaceholder":205},[31,323,324,326,329,333,335,338],{"class":33,"line":119},[31,325,158],{"class":157},[31,327,328],{"class":280}," const",[31,330,332],{"class":331},"s9McN"," state",[31,334,296],{"class":167},[31,336,337],{"class":284},"ZeroState",[31,339,288],{"class":167},[31,341,342,345],{"class":33,"line":132},[31,343,344],{"class":173},"    entries:",[31,346,347],{"class":167}," [],\n",[31,349,350,353,356,359],{"class":33,"line":230},[31,351,352],{"class":173},"    seq:",[31,354,355],{"class":167}," -",[31,357,358],{"class":248},"1",[31,360,180],{"class":167},[31,362,363],{"class":33,"line":236},[31,364,317],{"class":167},[31,366,367],{"class":33,"line":242},[31,368,206],{"emptyLinePlaceholder":205},[31,370,371,373,376,379,382,385],{"class":33,"line":254},[31,372,158],{"class":157},[31,374,375],{"class":280}," function",[31,377,378],{"class":37}," sync",[31,380,381],{"class":167},"(): ",[31,383,384],{"class":284},"void",[31,386,387],{"class":167}," {\n",[31,389,391,394,397,400,403,406,409,412,415,417,420,422,425,428,431,433,435,438],{"class":33,"line":390},12,[31,392,393],{"class":157},"    for",[31,395,396],{"class":167}," (",[31,398,399],{"class":280},"const",[31,401,402],{"class":331}," entry",[31,404,405],{"class":280}," of",[31,407,408],{"class":173}," kernel",[31,410,411],{"class":167},".",[31,413,414],{"class":173},"store",[31,416,411],{"class":167},[31,418,419],{"class":173},"session",[31,421,411],{"class":167},[31,423,424],{"class":37},"get",[31,426,427],{"class":167},"({ ",[31,429,430],{"class":173},"after:",[31,432,332],{"class":173},[31,434,411],{"class":167},[31,436,437],{"class":173},"seq",[31,439,440],{"class":167}," })) {\n",[31,442,444,447,449,452,454,457,460,463],{"class":33,"line":443},13,[31,445,446],{"class":173},"        state",[31,448,411],{"class":167},[31,450,451],{"class":173},"entries",[31,453,411],{"class":167},[31,455,456],{"class":37},"push",[31,458,459],{"class":167},"(",[31,461,462],{"class":173},"entry",[31,464,465],{"class":167},")\n",[31,467,469,471,473,475,478,480,482,485,487],{"class":33,"line":468},14,[31,470,446],{"class":173},[31,472,411],{"class":167},[31,474,437],{"class":173},[31,476,477],{"class":167}," = ",[31,479,462],{"class":173},[31,481,411],{"class":167},[31,483,484],{"class":173},"time",[31,486,411],{"class":167},[31,488,489],{"class":173},"seq\n",[31,491,493],{"class":33,"line":492},15,[31,494,495],{"class":167},"    }\n",[31,497,499],{"class":33,"line":498},16,[31,500,317],{"class":167},[14,502,503],{},"The model is the log, folded into memory, and nothing else.",[14,505,506,507,510,511,514,515,517,518,411],{},"That's the decision the rest of the cognet rests on. Cold boot is ",[17,508,509],{},"sync()"," with the cursor\nat ",[17,512,513],{},"-1","; a steady-state tick is ",[17,516,509],{}," with the cursor at the high-water mark. Same\ncall, different cursor — so there is no separate hydration path that could drift from the\nlive one. See ",[519,520,522],"a",{"href":521},"\u002Fdocs\u002Fv2\u002Fcognets\u002Fengine\u002Fmemory","Memory",[50,524,526],{"id":525},"the-loop","The loop",[528,529,530],"h3",{"id":530},"sense",[22,532,534],{"className":148,"code":533,"language":150,"meta":27,"style":27},"loop(async ({ signal, stop }) => {\n    await phase(\"sync\", async () => {\n        sync()\n    })\n",[17,535,536,566,590,598],{"__ignoreMap":27},[31,537,538,541,543,546,549,552,555,558,561,564],{"class":33,"line":34},[31,539,540],{"class":37},"loop",[31,542,459],{"class":167},[31,544,545],{"class":280},"async",[31,547,548],{"class":167}," ({ ",[31,550,551],{"class":173},"signal",[31,553,554],{"class":167},", ",[31,556,557],{"class":173},"stop",[31,559,560],{"class":167}," }) ",[31,562,563],{"class":280},"=>",[31,565,387],{"class":167},[31,567,568,571,574,576,579,581,583,586,588],{"class":33,"line":72},[31,569,570],{"class":157},"    await",[31,572,573],{"class":37}," phase",[31,575,459],{"class":167},[31,577,578],{"class":41},"\"sync\"",[31,580,554],{"class":167},[31,582,545],{"class":280},[31,584,585],{"class":167}," () ",[31,587,563],{"class":280},[31,589,387],{"class":167},[31,591,592,595],{"class":33,"line":81},[31,593,594],{"class":37},"        sync",[31,596,597],{"class":167},"()\n",[31,599,600],{"class":33,"line":97},[31,601,602],{"class":167},"    })\n",[14,604,605],{},"One fold, at the top of every tick.",[14,607,608,609,612,613,616,617,620],{},"On the first tick of a wake this pulls the triggering stimuli. On later ticks it pulls the\n",[17,610,611],{},"cognet:action:typescript"," and ",[17,614,615],{},"cognet:action:result"," entries the kernel committed for\nlast tick's ",[17,618,619],{},"run()"," — which is how tool results re-enter the model.",[14,622,623,624,628,629,632],{},"Note what the loop body signature ",[625,626,627],"em",{},"doesn't"," use: ",[17,630,631],{},"stimuli",". For a log-derived mind the log\ntail is the diff, so stimuli, the cognet's own outputs, and action results all arrive\nthrough this one door in one ordering.",[528,634,635],{"id":635},"render",[22,637,639],{"className":148,"code":638,"language":150,"meta":27,"style":27},"    const messages = await phase(\"render\", async () => {\n        return air.render({\n            base: await kernel.base(),\n            scope: kernel.scope(),\n            history: state.entries,\n        })\n    })\n",[17,640,641,671,685,703,717,730,735],{"__ignoreMap":27},[31,642,643,646,649,651,654,656,658,661,663,665,667,669],{"class":33,"line":34},[31,644,645],{"class":280},"    const",[31,647,648],{"class":331}," messages",[31,650,477],{"class":167},[31,652,653],{"class":157},"await",[31,655,573],{"class":37},[31,657,459],{"class":167},[31,659,660],{"class":41},"\"render\"",[31,662,554],{"class":167},[31,664,545],{"class":280},[31,666,585],{"class":167},[31,668,563],{"class":280},[31,670,387],{"class":167},[31,672,673,676,679,681,683],{"class":33,"line":72},[31,674,675],{"class":157},"        return",[31,677,678],{"class":173}," air",[31,680,411],{"class":167},[31,682,635],{"class":37},[31,684,168],{"class":167},[31,686,687,690,693,695,697,700],{"class":33,"line":81},[31,688,689],{"class":173},"            base:",[31,691,692],{"class":157}," await",[31,694,408],{"class":173},[31,696,411],{"class":167},[31,698,699],{"class":37},"base",[31,701,702],{"class":167},"(),\n",[31,704,705,708,710,712,715],{"class":33,"line":97},[31,706,707],{"class":173},"            scope:",[31,709,408],{"class":173},[31,711,411],{"class":167},[31,713,714],{"class":37},"scope",[31,716,702],{"class":167},[31,718,719,722,724,726,728],{"class":33,"line":111},[31,720,721],{"class":173},"            history:",[31,723,332],{"class":173},[31,725,411],{"class":167},[31,727,451],{"class":173},[31,729,180],{"class":167},[31,731,732],{"class":33,"line":119},[31,733,734],{"class":167},"        })\n",[31,736,737],{"class":33,"line":132},[31,738,602],{"class":167},[14,740,741,742,745,746,749],{},"Context is assembled from three things: the agent's identity (",[17,743,744],{},"base()","), the executable\ntool surface (",[17,747,748],{},"scope()","), and zero's own resident history.",[14,751,752],{},"The kernel supplies the first two as raw material and has no opinion about where they land\nin the rendered context. That placement is zero's decision, and a different cognet would\nmake it differently — or use a different format entirely. The AIR grammar zero uses is\nzero's choice, not the platform's.",[528,754,755],{"id":755},"invoke",[22,757,759],{"className":148,"code":758,"language":150,"meta":27,"style":27},"    const { blocks, done } = await phase(\"invoke\", async () => {\n        const collected: string[] = []\n        let stopped = false\n        let speaking: string | null = null\n\n        for await (const event of kernel.stream({ messages, signal })) {\n            switch (event.type) {\n                case \"engine:text:delta\":\n                    if (!speaking) speaking = crypto.randomUUID()\n                    await kernel.output(\"cognet:output:text\", {\n                        content: event.content,\n                        chunk: { of: speaking },\n                    })\n                    break\n\n                case \"engine:text\":\n                    if (speaking) {\n                        await kernel.output(\"cognet:output:text\", {\n                            content: \"\",\n                            chunk: { of: speaking, final: true },\n                        })\n                        speaking = null\n                    } else {\n                        await kernel.output(\"cognet:output:text\", { content: event.content })\n                    }\n                    break\n\n                case \"engine:typescript\":\n                    collected.push(event.content)\n                    break\n\n                case \"engine:output:error\":\n                    await kernel.output(\"cognet:output:text\", {\n                        content: `[format] ${event.code}: ${event.message}`,\n                    })\n                    break\n\n                case \"engine:stop\":\n                    stopped = true\n                    break\n            }\n        }\n\n        return { blocks: collected, done: stopped }\n    })\n",[17,760,761,797,813,826,848,852,886,904,915,943,963,977,991,996,1001,1005,1014,1025,1043,1054,1076,1082,1092,1103,1133,1139,1144,1149,1159,1179,1184,1189,1199,1216,1254,1259,1264,1269,1279,1290,1295,1301,1307,1312,1334],{"__ignoreMap":27},[31,762,763,765,767,770,772,775,778,780,782,784,787,789,791,793,795],{"class":33,"line":34},[31,764,645],{"class":280},[31,766,214],{"class":167},[31,768,769],{"class":331},"blocks",[31,771,554],{"class":167},[31,773,774],{"class":331},"done",[31,776,777],{"class":167}," } = ",[31,779,653],{"class":157},[31,781,573],{"class":37},[31,783,459],{"class":167},[31,785,786],{"class":41},"\"invoke\"",[31,788,554],{"class":167},[31,790,545],{"class":280},[31,792,585],{"class":167},[31,794,563],{"class":280},[31,796,387],{"class":167},[31,798,799,802,805,807,810],{"class":33,"line":72},[31,800,801],{"class":280},"        const",[31,803,804],{"class":331}," collected",[31,806,296],{"class":167},[31,808,809],{"class":284},"string",[31,811,812],{"class":167},"[] = []\n",[31,814,815,818,821,823],{"class":33,"line":81},[31,816,817],{"class":280},"        let",[31,819,820],{"class":173}," stopped",[31,822,477],{"class":167},[31,824,825],{"class":280},"false\n",[31,827,828,830,833,835,837,840,843,845],{"class":33,"line":97},[31,829,817],{"class":280},[31,831,832],{"class":173}," speaking",[31,834,296],{"class":167},[31,836,809],{"class":284},[31,838,839],{"class":167}," | ",[31,841,842],{"class":284},"null",[31,844,477],{"class":167},[31,846,847],{"class":280},"null\n",[31,849,850],{"class":33,"line":111},[31,851,206],{"emptyLinePlaceholder":205},[31,853,854,857,859,861,863,866,868,870,872,875,877,880,882,884],{"class":33,"line":119},[31,855,856],{"class":157},"        for",[31,858,692],{"class":157},[31,860,396],{"class":167},[31,862,399],{"class":280},[31,864,865],{"class":331}," event",[31,867,405],{"class":280},[31,869,408],{"class":173},[31,871,411],{"class":167},[31,873,874],{"class":37},"stream",[31,876,427],{"class":167},[31,878,879],{"class":173},"messages",[31,881,554],{"class":167},[31,883,551],{"class":173},[31,885,440],{"class":167},[31,887,888,891,893,896,898,901],{"class":33,"line":132},[31,889,890],{"class":157},"            switch",[31,892,396],{"class":167},[31,894,895],{"class":173},"event",[31,897,411],{"class":167},[31,899,900],{"class":173},"type",[31,902,903],{"class":167},") {\n",[31,905,906,909,912],{"class":33,"line":230},[31,907,908],{"class":157},"                case",[31,910,911],{"class":41}," \"engine:text:delta\"",[31,913,914],{"class":167},":\n",[31,916,917,920,923,926,929,931,933,936,938,941],{"class":33,"line":236},[31,918,919],{"class":157},"                    if",[31,921,922],{"class":167}," (!",[31,924,925],{"class":173},"speaking",[31,927,928],{"class":167},") ",[31,930,925],{"class":173},[31,932,477],{"class":167},[31,934,935],{"class":173},"crypto",[31,937,411],{"class":167},[31,939,940],{"class":37},"randomUUID",[31,942,597],{"class":167},[31,944,945,948,950,952,955,957,960],{"class":33,"line":242},[31,946,947],{"class":157},"                    await",[31,949,408],{"class":173},[31,951,411],{"class":167},[31,953,954],{"class":37},"output",[31,956,459],{"class":167},[31,958,959],{"class":41},"\"cognet:output:text\"",[31,961,962],{"class":167},", {\n",[31,964,965,968,970,972,975],{"class":33,"line":254},[31,966,967],{"class":173},"                        content:",[31,969,865],{"class":173},[31,971,411],{"class":167},[31,973,974],{"class":173},"content",[31,976,180],{"class":167},[31,978,979,982,984,987,989],{"class":33,"line":390},[31,980,981],{"class":173},"                        chunk:",[31,983,214],{"class":167},[31,985,986],{"class":173},"of:",[31,988,832],{"class":173},[31,990,223],{"class":167},[31,992,993],{"class":33,"line":443},[31,994,995],{"class":167},"                    })\n",[31,997,998],{"class":33,"line":468},[31,999,1000],{"class":157},"                    break\n",[31,1002,1003],{"class":33,"line":492},[31,1004,206],{"emptyLinePlaceholder":205},[31,1006,1007,1009,1012],{"class":33,"line":498},[31,1008,908],{"class":157},[31,1010,1011],{"class":41}," \"engine:text\"",[31,1013,914],{"class":167},[31,1015,1017,1019,1021,1023],{"class":33,"line":1016},17,[31,1018,919],{"class":157},[31,1020,396],{"class":167},[31,1022,925],{"class":173},[31,1024,903],{"class":167},[31,1026,1028,1031,1033,1035,1037,1039,1041],{"class":33,"line":1027},18,[31,1029,1030],{"class":157},"                        await",[31,1032,408],{"class":173},[31,1034,411],{"class":167},[31,1036,954],{"class":37},[31,1038,459],{"class":167},[31,1040,959],{"class":41},[31,1042,962],{"class":167},[31,1044,1046,1049,1052],{"class":33,"line":1045},19,[31,1047,1048],{"class":173},"                            content:",[31,1050,1051],{"class":41}," \"\"",[31,1053,180],{"class":167},[31,1055,1057,1060,1062,1064,1066,1068,1071,1074],{"class":33,"line":1056},20,[31,1058,1059],{"class":173},"                            chunk:",[31,1061,214],{"class":167},[31,1063,986],{"class":173},[31,1065,832],{"class":173},[31,1067,554],{"class":167},[31,1069,1070],{"class":173},"final:",[31,1072,1073],{"class":280}," true",[31,1075,223],{"class":167},[31,1077,1079],{"class":33,"line":1078},21,[31,1080,1081],{"class":167},"                        })\n",[31,1083,1085,1088,1090],{"class":33,"line":1084},22,[31,1086,1087],{"class":173},"                        speaking",[31,1089,477],{"class":167},[31,1091,847],{"class":280},[31,1093,1095,1098,1101],{"class":33,"line":1094},23,[31,1096,1097],{"class":167},"                    } ",[31,1099,1100],{"class":157},"else",[31,1102,387],{"class":167},[31,1104,1106,1108,1110,1112,1114,1116,1118,1121,1124,1126,1128,1130],{"class":33,"line":1105},24,[31,1107,1030],{"class":157},[31,1109,408],{"class":173},[31,1111,411],{"class":167},[31,1113,954],{"class":37},[31,1115,459],{"class":167},[31,1117,959],{"class":41},[31,1119,1120],{"class":167},", { ",[31,1122,1123],{"class":173},"content:",[31,1125,865],{"class":173},[31,1127,411],{"class":167},[31,1129,974],{"class":173},[31,1131,1132],{"class":167}," })\n",[31,1134,1136],{"class":33,"line":1135},25,[31,1137,1138],{"class":167},"                    }\n",[31,1140,1142],{"class":33,"line":1141},26,[31,1143,1000],{"class":157},[31,1145,1147],{"class":33,"line":1146},27,[31,1148,206],{"emptyLinePlaceholder":205},[31,1150,1152,1154,1157],{"class":33,"line":1151},28,[31,1153,908],{"class":157},[31,1155,1156],{"class":41}," \"engine:typescript\"",[31,1158,914],{"class":167},[31,1160,1162,1165,1167,1169,1171,1173,1175,1177],{"class":33,"line":1161},29,[31,1163,1164],{"class":173},"                    collected",[31,1166,411],{"class":167},[31,1168,456],{"class":37},[31,1170,459],{"class":167},[31,1172,895],{"class":173},[31,1174,411],{"class":167},[31,1176,974],{"class":173},[31,1178,465],{"class":167},[31,1180,1182],{"class":33,"line":1181},30,[31,1183,1000],{"class":157},[31,1185,1187],{"class":33,"line":1186},31,[31,1188,206],{"emptyLinePlaceholder":205},[31,1190,1192,1194,1197],{"class":33,"line":1191},32,[31,1193,908],{"class":157},[31,1195,1196],{"class":41}," \"engine:output:error\"",[31,1198,914],{"class":167},[31,1200,1202,1204,1206,1208,1210,1212,1214],{"class":33,"line":1201},33,[31,1203,947],{"class":157},[31,1205,408],{"class":173},[31,1207,411],{"class":167},[31,1209,954],{"class":37},[31,1211,459],{"class":167},[31,1213,959],{"class":41},[31,1215,962],{"class":167},[31,1217,1219,1221,1224,1227,1229,1231,1233,1236,1238,1240,1242,1244,1247,1249,1252],{"class":33,"line":1218},34,[31,1220,967],{"class":173},[31,1222,1223],{"class":41}," `[format] ",[31,1225,1226],{"class":280},"${",[31,1228,895],{"class":173},[31,1230,411],{"class":167},[31,1232,17],{"class":173},[31,1234,1235],{"class":280},"}",[31,1237,296],{"class":41},[31,1239,1226],{"class":280},[31,1241,895],{"class":173},[31,1243,411],{"class":167},[31,1245,1246],{"class":173},"message",[31,1248,1235],{"class":280},[31,1250,1251],{"class":41},"`",[31,1253,180],{"class":167},[31,1255,1257],{"class":33,"line":1256},35,[31,1258,995],{"class":167},[31,1260,1262],{"class":33,"line":1261},36,[31,1263,1000],{"class":157},[31,1265,1267],{"class":33,"line":1266},37,[31,1268,206],{"emptyLinePlaceholder":205},[31,1270,1272,1274,1277],{"class":33,"line":1271},38,[31,1273,908],{"class":157},[31,1275,1276],{"class":41}," \"engine:stop\"",[31,1278,914],{"class":167},[31,1280,1282,1285,1287],{"class":33,"line":1281},39,[31,1283,1284],{"class":173},"                    stopped",[31,1286,477],{"class":167},[31,1288,1289],{"class":280},"true\n",[31,1291,1293],{"class":33,"line":1292},40,[31,1294,1000],{"class":157},[31,1296,1298],{"class":33,"line":1297},41,[31,1299,1300],{"class":167},"            }\n",[31,1302,1304],{"class":33,"line":1303},42,[31,1305,1306],{"class":167},"        }\n",[31,1308,1310],{"class":33,"line":1309},43,[31,1311,206],{"emptyLinePlaceholder":205},[31,1313,1315,1317,1319,1322,1324,1326,1329,1331],{"class":33,"line":1314},44,[31,1316,675],{"class":157},[31,1318,214],{"class":167},[31,1320,1321],{"class":173},"blocks:",[31,1323,804],{"class":173},[31,1325,554],{"class":167},[31,1327,1328],{"class":173},"done:",[31,1330,820],{"class":173},[31,1332,1333],{"class":167}," }\n",[31,1335,1337],{"class":33,"line":1336},45,[31,1338,602],{"class":167},[14,1340,1341],{},"This is the part worth reading closely, because it's where the ABI's design shows.",[14,1343,1344,1345,1349,1350,1353],{},"The kernel yields ",[1346,1347,1348],"strong",{},"raw engine events",". It does not pre-label them as the cognet's\noutput. When a text block arrives, zero decides to emit it. When a typescript block\narrives, zero decides to collect it. That decision belongs to the cognet alone, and a\ncognet that wanted to critique its own code before running it would simply not push to\n",[17,1351,1352],{},"collected"," here.",[14,1355,1356,1359,1360,1363,1364,1367],{},[1346,1357,1358],{},"Streaming is chunked emission."," Deltas emit as chunks of one correlation group; the\nclosing ",[17,1361,1362],{},"engine:text"," closes it with ",[17,1365,1366],{},"final: true",". There is no separate push channel —\nchunks are ordinary committed entries, so they reach every observer through the same\npipeline as any other fact.",[14,1369,1370,1373],{},[1346,1371,1372],{},"Code is collected, not run mid-stream."," Blocks accumulate until the model has finished\nthe whole message, so they run concurrently and an abort can't leave half a message acted\non.",[14,1375,1376,1379],{},[1346,1377,1378],{},"A format violation becomes an ordinary fact."," When the model breaks the AIR contract,\nzero emits the error as text rather than throwing. Next tick's render shows the model its\nown violation and it self-corrects.",[14,1381,1382,1385,1386,1389,1390,1393],{},[1346,1383,1384],{},"Stopping is causal, never inferred."," ",[17,1387,1388],{},"engine:stop"," is the model's explicit ",[17,1391,1392],{},"\u003Cdone\u002F>",".\nZero never guesses that a response looked final.",[528,1395,1396],{"id":1396},"act",[22,1398,1400],{"className":148,"code":1399,"language":150,"meta":27,"style":27},"    if (blocks.length > 0) {\n        await phase(\"act\", async () => {\n            await kernel.run(blocks, { signal })\n        })\n    }\n",[17,1401,1402,1424,1446,1468,1472],{"__ignoreMap":27},[31,1403,1404,1407,1409,1411,1413,1416,1419,1422],{"class":33,"line":34},[31,1405,1406],{"class":157},"    if",[31,1408,396],{"class":167},[31,1410,769],{"class":173},[31,1412,411],{"class":167},[31,1414,1415],{"class":173},"length",[31,1417,1418],{"class":167}," > ",[31,1420,1421],{"class":248},"0",[31,1423,903],{"class":167},[31,1425,1426,1429,1431,1433,1436,1438,1440,1442,1444],{"class":33,"line":72},[31,1427,1428],{"class":157},"        await",[31,1430,573],{"class":37},[31,1432,459],{"class":167},[31,1434,1435],{"class":41},"\"act\"",[31,1437,554],{"class":167},[31,1439,545],{"class":280},[31,1441,585],{"class":167},[31,1443,563],{"class":280},[31,1445,387],{"class":167},[31,1447,1448,1451,1453,1455,1458,1460,1462,1464,1466],{"class":33,"line":81},[31,1449,1450],{"class":157},"            await",[31,1452,408],{"class":173},[31,1454,411],{"class":167},[31,1456,1457],{"class":37},"run",[31,1459,459],{"class":167},[31,1461,769],{"class":173},[31,1463,1120],{"class":167},[31,1465,551],{"class":173},[31,1467,1132],{"class":167},[31,1469,1470],{"class":33,"line":97},[31,1471,734],{"class":167},[31,1473,1474],{"class":33,"line":111},[31,1475,495],{"class":167},[14,1477,1478],{},"An array runs every block concurrently and returns results in order.",[14,1480,1481,1482,1485,1486,612,1488,1490,1491,1493],{},"Zero doesn't inspect those results. It doesn't need to: ",[17,1483,1484],{},"kernel.run()"," commits\n",[17,1487,611],{},[17,1489,615],{}," itself, so success and failure both\nflow back through the log identically and arrive in the model at next tick's ",[17,1492,509],{},".\nThat tick's render shows the model its own stdout.",[528,1495,1496],{"id":1496},"yield",[22,1498,1500],{"className":148,"code":1499,"language":150,"meta":27,"style":27},"    if (done && blocks.length === 0) stop()\n})\n",[17,1501,1502,1530],{"__ignoreMap":27},[31,1503,1504,1506,1508,1510,1513,1515,1517,1519,1522,1524,1526,1528],{"class":33,"line":34},[31,1505,1406],{"class":157},[31,1507,396],{"class":167},[31,1509,774],{"class":173},[31,1511,1512],{"class":167}," && ",[31,1514,769],{"class":173},[31,1516,411],{"class":167},[31,1518,1415],{"class":173},[31,1520,1521],{"class":167}," === ",[31,1523,1421],{"class":248},[31,1525,928],{"class":167},[31,1527,557],{"class":37},[31,1529,597],{"class":167},[31,1531,1532],{"class":33,"line":72},[31,1533,257],{"class":167},[14,1535,1536],{},"Four lines that carry the cognet's judgment about its own completion.",[14,1538,1539,1541,1542,1545,1546,1548],{},[17,1540,774],{}," alone isn't enough. If the model emitted code this tick, there will be another\ntick regardless of what it said — because the model must ",[625,1543,1544],{},"witness its own results"," before\nthe wake can honestly end. A cognet that stopped on ",[17,1547,1392],{}," while a tool call was still\nunwitnessed would strand the result in the log, unseen.",[50,1550,1552],{"id":1551},"lifecycle","Lifecycle",[22,1554,1556],{"className":148,"code":1555,"language":150,"meta":27,"style":27},"export default definePlugin(({ hooks }) => {\n    hooks.on(\"boot\", async () => {\n        sync()\n\n        const checkpoint = await kernel.store.get(\"checkpoint\")\n        kernel.emit(\"cognet:log:info\", {\n            value: checkpoint\n                ? `zero: hydrated ${state.entries.length} entries (checkpoint seq ${checkpoint.seq}, live seq ${state.seq})`\n                : `zero: cold boot, hydrated ${state.entries.length} entries`,\n        })\n    })\n\n    hooks.on(\"shutdown\", async () => {\n        await kernel.store.set(\"checkpoint\", { seq: state.seq, savedAt: Date.now() })\n    })\n})\n",[17,1557,1558,1579,1604,1610,1614,1642,1659,1667,1720,1747,1751,1755,1759,1782,1828,1832],{"__ignoreMap":27},[31,1559,1560,1562,1564,1567,1570,1573,1575,1577],{"class":33,"line":34},[31,1561,158],{"class":157},[31,1563,161],{"class":157},[31,1565,1566],{"class":37}," definePlugin",[31,1568,1569],{"class":167},"(({ ",[31,1571,1572],{"class":173},"hooks",[31,1574,560],{"class":167},[31,1576,563],{"class":280},[31,1578,387],{"class":167},[31,1580,1581,1584,1586,1589,1591,1594,1596,1598,1600,1602],{"class":33,"line":72},[31,1582,1583],{"class":173},"    hooks",[31,1585,411],{"class":167},[31,1587,1588],{"class":37},"on",[31,1590,459],{"class":167},[31,1592,1593],{"class":41},"\"boot\"",[31,1595,554],{"class":167},[31,1597,545],{"class":280},[31,1599,585],{"class":167},[31,1601,563],{"class":280},[31,1603,387],{"class":167},[31,1605,1606,1608],{"class":33,"line":81},[31,1607,594],{"class":37},[31,1609,597],{"class":167},[31,1611,1612],{"class":33,"line":97},[31,1613,206],{"emptyLinePlaceholder":205},[31,1615,1616,1618,1621,1623,1625,1627,1629,1631,1633,1635,1637,1640],{"class":33,"line":111},[31,1617,801],{"class":280},[31,1619,1620],{"class":331}," checkpoint",[31,1622,477],{"class":167},[31,1624,653],{"class":157},[31,1626,408],{"class":173},[31,1628,411],{"class":167},[31,1630,414],{"class":173},[31,1632,411],{"class":167},[31,1634,424],{"class":37},[31,1636,459],{"class":167},[31,1638,1639],{"class":41},"\"checkpoint\"",[31,1641,465],{"class":167},[31,1643,1644,1647,1649,1652,1654,1657],{"class":33,"line":119},[31,1645,1646],{"class":173},"        kernel",[31,1648,411],{"class":167},[31,1650,1651],{"class":37},"emit",[31,1653,459],{"class":167},[31,1655,1656],{"class":41},"\"cognet:log:info\"",[31,1658,962],{"class":167},[31,1660,1661,1664],{"class":33,"line":132},[31,1662,1663],{"class":173},"            value:",[31,1665,1666],{"class":173}," checkpoint\n",[31,1668,1669,1672,1675,1677,1680,1682,1684,1686,1688,1690,1693,1695,1698,1700,1702,1704,1707,1709,1711,1713,1715,1717],{"class":33,"line":230},[31,1670,1671],{"class":167},"                ? ",[31,1673,1674],{"class":41},"`zero: hydrated ",[31,1676,1226],{"class":280},[31,1678,1679],{"class":173},"state",[31,1681,411],{"class":167},[31,1683,451],{"class":173},[31,1685,411],{"class":167},[31,1687,1415],{"class":173},[31,1689,1235],{"class":280},[31,1691,1692],{"class":41}," entries (checkpoint seq ",[31,1694,1226],{"class":280},[31,1696,1697],{"class":173},"checkpoint",[31,1699,411],{"class":167},[31,1701,437],{"class":173},[31,1703,1235],{"class":280},[31,1705,1706],{"class":41},", live seq ",[31,1708,1226],{"class":280},[31,1710,1679],{"class":173},[31,1712,411],{"class":167},[31,1714,437],{"class":173},[31,1716,1235],{"class":280},[31,1718,1719],{"class":41},")`\n",[31,1721,1722,1725,1728,1730,1732,1734,1736,1738,1740,1742,1745],{"class":33,"line":236},[31,1723,1724],{"class":167},"                : ",[31,1726,1727],{"class":41},"`zero: cold boot, hydrated ",[31,1729,1226],{"class":280},[31,1731,1679],{"class":173},[31,1733,411],{"class":167},[31,1735,451],{"class":173},[31,1737,411],{"class":167},[31,1739,1415],{"class":173},[31,1741,1235],{"class":280},[31,1743,1744],{"class":41}," entries`",[31,1746,180],{"class":167},[31,1748,1749],{"class":33,"line":242},[31,1750,734],{"class":167},[31,1752,1753],{"class":33,"line":254},[31,1754,602],{"class":167},[31,1756,1757],{"class":33,"line":390},[31,1758,206],{"emptyLinePlaceholder":205},[31,1760,1761,1763,1765,1767,1769,1772,1774,1776,1778,1780],{"class":33,"line":443},[31,1762,1583],{"class":173},[31,1764,411],{"class":167},[31,1766,1588],{"class":37},[31,1768,459],{"class":167},[31,1770,1771],{"class":41},"\"shutdown\"",[31,1773,554],{"class":167},[31,1775,545],{"class":280},[31,1777,585],{"class":167},[31,1779,563],{"class":280},[31,1781,387],{"class":167},[31,1783,1784,1786,1788,1790,1792,1794,1797,1799,1801,1803,1806,1808,1810,1812,1814,1817,1820,1822,1825],{"class":33,"line":468},[31,1785,1428],{"class":157},[31,1787,408],{"class":173},[31,1789,411],{"class":167},[31,1791,414],{"class":173},[31,1793,411],{"class":167},[31,1795,1796],{"class":37},"set",[31,1798,459],{"class":167},[31,1800,1639],{"class":41},[31,1802,1120],{"class":167},[31,1804,1805],{"class":173},"seq:",[31,1807,332],{"class":173},[31,1809,411],{"class":167},[31,1811,437],{"class":173},[31,1813,554],{"class":167},[31,1815,1816],{"class":173},"savedAt:",[31,1818,1819],{"class":173}," Date",[31,1821,411],{"class":167},[31,1823,1824],{"class":37},"now",[31,1826,1827],{"class":167},"() })\n",[31,1829,1830],{"class":33,"line":492},[31,1831,602],{"class":167},[31,1833,1834],{"class":33,"line":498},[31,1835,257],{"class":167},[14,1837,1838,1841,1842,1844],{},[17,1839,1840],{},"boot"," calls the same ",[17,1843,509],{}," the loop calls. Rehydration isn't a special path.",[14,1846,1847,1850],{},[17,1848,1849],{},"shutdown"," persists a cursor and nothing else. Durable episodic writes already happened\nthrough the kernel at the moment they mattered, so the only thing in RAM worth saving is\nthe high-water mark — and even that is an optimization. Delete the checkpoint and zero\ncold-boots with one full re-fold, losing nothing.",[50,1852,1854],{"id":1853},"what-zero-doesnt-do","What zero doesn't do",[14,1856,1857],{},"Reading a reference implementation for its absences is often more useful than reading it\nfor its features.",[14,1859,1860,1863,1864,1867],{},[1346,1861,1862],{},"It holds no entities."," The ECS world is constructed for every wake, and zero uses it\npurely for ",[17,1865,1866],{},"phase()"," timing. Its model is the folded log. That's a legitimate way to use\nthe engine — the world is available, not mandatory.",[14,1869,1870,1873],{},[1346,1871,1872],{},"It never inspects run results."," Success and failure take the same path back into the\nmodel.",[14,1875,1876,1879],{},[1346,1877,1878],{},"It has no retry logic, no summarization, no compression."," Not because those are wrong,\nbut because zero is the reference, and every one of them is a strategy decision that\nbelongs to whoever needs it.",[14,1881,1882,1887],{},[1346,1883,1884,1885,411],{},"It ignores ",[17,1886,631],{}," The log tail is the diff.",[50,1889,1891],{"id":1890},"where-to-change-it","Where to change it",[14,1893,1894],{},"The four phases are the natural seams:",[1896,1897,1898,1911],"table",{},[1899,1900,1901],"thead",{},[1902,1903,1904,1908],"tr",{},[1905,1906,1907],"th",{},"Phase",[1905,1909,1910],{},"Change it to",[1912,1913,1914,1925,1934,1943],"tbody",{},[1902,1915,1916,1922],{},[1917,1918,1919],"td",{},[17,1920,1921],{},"sync",[1917,1923,1924],{},"hold a derived model — a summary, an index, a spatial map",[1902,1926,1927,1931],{},[1917,1928,1929],{},[17,1930,635],{},[1917,1932,1933],{},"use a different grammar, a different context budget, a different format entirely",[1902,1935,1936,1940],{},[1917,1937,1938],{},[17,1939,755],{},[1917,1941,1942],{},"call several engines, critique before running, route by block type",[1902,1944,1945,1949],{},[1917,1946,1947],{},[17,1948,1396],{},[1917,1950,1951],{},"gate execution, ask for confirmation, transform blocks first",[14,1953,1954],{},"None of that touches the kernel. The contract stays exactly seven verbs, whichever of\nthese you rewrite.",[1956,1957,1958],"style",{},"html pre.shiki code .sCudf, html code.shiki .sCudf{--shiki-default:#DCDCAA}html pre.shiki code .sKc5r, html code.shiki .sKc5r{--shiki-default:#CE9178}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html pre.shiki code .sOLPB, html code.shiki .sOLPB{--shiki-default:#6A9955}html pre.shiki code .sYbnZ, html code.shiki .sYbnZ{--shiki-default:#C586C0}html pre.shiki code .sTNBD, html code.shiki .sTNBD{--shiki-default:#D4D4D4}html pre.shiki code .s3F5K, html code.shiki .s3F5K{--shiki-default:#9CDCFE}html pre.shiki code .sDGX8, html code.shiki .sDGX8{--shiki-default:#B5CEA8}html pre.shiki code .scz_3, html code.shiki .scz_3{--shiki-default:#569CD6}html pre.shiki code .sNl3T, html code.shiki .sNl3T{--shiki-default:#4EC9B0}html pre.shiki code .s9McN, html code.shiki .s9McN{--shiki-default:#4FC1FF}",{"title":27,"searchDepth":72,"depth":72,"links":1960},[1961,1962,1963,1964,1971,1972,1973],{"id":52,"depth":72,"text":53},{"id":144,"depth":72,"text":145},{"id":267,"depth":72,"text":268},{"id":525,"depth":72,"text":526,"children":1965},[1966,1967,1968,1969,1970],{"id":530,"depth":81,"text":530},{"id":635,"depth":81,"text":635},{"id":755,"depth":81,"text":755},{"id":1396,"depth":81,"text":1396},{"id":1496,"depth":81,"text":1496},{"id":1551,"depth":72,"text":1552},{"id":1853,"depth":72,"text":1854},{"id":1890,"depth":72,"text":1891},"The reference cognet, read in full.","md",{},"\u002Fdocs\u002Fv2\u002Fcognets\u002Fbuilding\u002Fzero",{"title":5,"description":1974},"docs\u002Fv2\u002Fcognets\u002Fbuilding\u002Fzero","LD881pZnuf8d1HsRNiRNVhBvx3nfIVvm1oXojH5a3S4",1785156432046]