[{"data":1,"prerenderedAt":1136},["ShallowReactive",2],{"i-mdi:magnify":3,"i-simple-icons:visualstudiocode":8,"i-mdi:github":11,"i-mdi:discord":13,"i-mdi:youtube":15,"i-mdi:flask-outline":17,"i-vscode-icons:default-folder-opened":19,"i-vscode-icons:default-folder":22,"i-vscode-icons:folder-type-plugin":24,"i-vscode-icons:folder-type-src":26,"i-vscode-icons:file-type-typescript":28,"i-vscode-icons:file-type-json":30,"docs-\u002Fdocs\u002Fv2\u002Fcognets\u002Fapi\u002Floop":32},{"left":4,"top":4,"width":5,"height":5,"rotate":4,"vFlip":6,"hFlip":6,"body":7},0,24,false,"\u003Cpath fill=\"currentColor\" d=\"M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5l-1.5 1.5l-5-5v-.79l-.27-.27A6.52 6.52 0 0 1 9.5 16A6.5 6.5 0 0 1 3 9.5A6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14S14 12 14 9.5S12 5 9.5 5\"\u002F>",{"left":4,"top":4,"width":5,"height":5,"rotate":4,"vFlip":6,"hFlip":6,"body":9,"hidden":10},"\u003Cpath fill=\"currentColor\" d=\"M23.15 2.587L18.21.21a1.49 1.49 0 0 0-1.705.29l-9.46 8.63l-4.12-3.128a1 1 0 0 0-1.276.057L.327 7.261A1 1 0 0 0 .326 8.74L3.899 12L.326 15.26a1 1 0 0 0 .001 1.479L1.65 17.94a1 1 0 0 0 1.276.057l4.12-3.128l9.46 8.63a1.49 1.49 0 0 0 1.704.29l4.942-2.377A1.5 1.5 0 0 0 24 20.06V3.939a1.5 1.5 0 0 0-.85-1.352m-5.146 14.861L10.826 12l7.178-5.448z\"\u002F>",true,{"left":4,"top":4,"width":5,"height":5,"rotate":4,"vFlip":6,"hFlip":6,"body":12},"\u003Cpath fill=\"currentColor\" d=\"M12 2A10 10 0 0 0 2 12c0 4.42 2.87 8.17 6.84 9.5c.5.08.66-.23.66-.5v-1.69c-2.77.6-3.36-1.34-3.36-1.34c-.46-1.16-1.11-1.47-1.11-1.47c-.91-.62.07-.6.07-.6c1 .07 1.53 1.03 1.53 1.03c.87 1.52 2.34 1.07 2.91.83c.09-.65.35-1.09.63-1.34c-2.22-.25-4.55-1.11-4.55-4.92c0-1.11.38-2 1.03-2.71c-.1-.25-.45-1.29.1-2.64c0 0 .84-.27 2.75 1.02c.79-.22 1.65-.33 2.5-.33s1.71.11 2.5.33c1.91-1.29 2.75-1.02 2.75-1.02c.55 1.35.2 2.39.1 2.64c.65.71 1.03 1.6 1.03 2.71c0 3.82-2.34 4.66-4.57 4.91c.36.31.69.92.69 1.85V21c0 .27.16.59.67.5C19.14 20.16 22 16.42 22 12A10 10 0 0 0 12 2\"\u002F>",{"left":4,"top":4,"width":5,"height":5,"rotate":4,"vFlip":6,"hFlip":6,"body":14,"hidden":10},"\u003Cpath fill=\"currentColor\" d=\"m22 24l-5.25-5l.63 2H4.5A2.5 2.5 0 0 1 2 18.5v-15A2.5 2.5 0 0 1 4.5 1h15A2.5 2.5 0 0 1 22 3.5V24M12 6.8c-2.68 0-4.56 1.15-4.56 1.15c1.03-.92 2.83-1.45 2.83-1.45l-.17-.17c-1.69.03-3.22 1.2-3.22 1.2c-1.72 3.59-1.61 6.69-1.61 6.69c1.4 1.81 3.48 1.68 3.48 1.68l.71-.9c-1.25-.27-2.04-1.38-2.04-1.38S9.3 14.9 12 14.9s4.58-1.28 4.58-1.28s-.79 1.11-2.04 1.38l.71.9s2.08.13 3.48-1.68c0 0 .11-3.1-1.61-6.69c0 0-1.53-1.17-3.22-1.2l-.17.17s1.8.53 2.83 1.45c0 0-1.88-1.15-4.56-1.15m-2.07 3.79c.65 0 1.18.57 1.17 1.27c0 .69-.52 1.27-1.17 1.27c-.64 0-1.16-.58-1.16-1.27c0-.7.51-1.27 1.16-1.27m4.17 0c.65 0 1.17.57 1.17 1.27c0 .69-.52 1.27-1.17 1.27c-.64 0-1.16-.58-1.16-1.27c0-.7.51-1.27 1.16-1.27Z\"\u002F>",{"left":4,"top":4,"width":5,"height":5,"rotate":4,"vFlip":6,"hFlip":6,"body":16},"\u003Cpath fill=\"currentColor\" d=\"m10 15l5.19-3L10 9zm11.56-7.83c.13.47.22 1.1.28 1.9c.07.8.1 1.49.1 2.09L22 12c0 2.19-.16 3.8-.44 4.83c-.25.9-.83 1.48-1.73 1.73c-.47.13-1.33.22-2.65.28c-1.3.07-2.49.1-3.59.1L12 19c-4.19 0-6.8-.16-7.83-.44c-.9-.25-1.48-.83-1.73-1.73c-.13-.47-.22-1.1-.28-1.9c-.07-.8-.1-1.49-.1-2.09L2 12c0-2.19.16-3.8.44-4.83c.25-.9.83-1.48 1.73-1.73c.47-.13 1.33-.22 2.65-.28c1.3-.07 2.49-.1 3.59-.1L12 5c4.19 0 6.8.16 7.83.44c.9.25 1.48.83 1.73 1.73\"\u002F>",{"left":4,"top":4,"width":5,"height":5,"rotate":4,"vFlip":6,"hFlip":6,"body":18},"\u003Cpath fill=\"currentColor\" d=\"M5 19a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1c0-.21-.07-.41-.18-.57L13 8.35V4h-2v4.35L5.18 18.43c-.11.16-.18.36-.18.57m1 3a3 3 0 0 1-3-3c0-.6.18-1.16.5-1.63L9 7.81V6a1 1 0 0 1-1-1V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v1a1 1 0 0 1-1 1v1.81l5.5 9.56c.32.47.5 1.03.5 1.63a3 3 0 0 1-3 3zm7-6l1.34-1.34L16.27 18H7.73l2.66-4.61zm-.5-4a.5.5 0 0 1 .5.5a.5.5 0 0 1-.5.5a.5.5 0 0 1-.5-.5a.5.5 0 0 1 .5-.5\"\u002F>",{"left":4,"top":4,"width":20,"height":20,"rotate":4,"vFlip":6,"hFlip":6,"body":21},32,"\u003Cpath fill=\"#dcb67a\" d=\"M27.4 5.5h-9.2l-2.1 4.2H4.3v16.8h25.2v-21Zm0 18.7H6.6V11.8h20.8Zm0-14.5h-8.2l1-2.1h7.1v2.1Z\"\u002F>\u003Cpath fill=\"#dcb67a\" d=\"M25.7 13.7H.5l3.8 12.8h25.2z\"\u002F>",{"left":4,"top":4,"width":20,"height":20,"rotate":4,"vFlip":6,"hFlip":6,"body":23},"\u003Cpath fill=\"#c09553\" d=\"M27.5 5.5h-9.3l-2.1 4.2H4.4v16.8h25.2v-21Zm0 4.2h-8.2l1.1-2.1h7.1Z\"\u002F>",{"left":4,"top":4,"width":20,"height":20,"rotate":4,"vFlip":6,"hFlip":6,"body":25},"\u003Cpath fill=\"#ffba58\" d=\"M27.5 5.5h-9.3l-2.1 4.2H4.4v16.8h25.2v-21Zm0 4.2h-8.2l1.1-2.1h7.1Z\"\u002F>\u003Cpath fill=\"#e76a00\" d=\"M20 12.5V14h-4a2.006 2.006 0 0 0-2 2v4h-1.5a2.5 2.5 0 0 0 0 5H14v4a2.006 2.006 0 0 0 2 2h3.8v-1.5a2.7 2.7 0 0 1 5.4 0V31H29a2.006 2.006 0 0 0 2-2v-3.8h-1.5a2.7 2.7 0 0 1 0-5.4H31V16a2.006 2.006 0 0 0-2-2h-4v-1.5a2.5 2.5 0 0 0-5 0\"\u002F>",{"left":4,"top":4,"width":20,"height":20,"rotate":4,"vFlip":6,"hFlip":6,"body":27},"\u003Cpath fill=\"#14622a\" d=\"M27.5 5.5h-9.3l-2.1 4.2H4.4v16.8h25.2v-21Zm0 4.2h-8.2l1.1-2.1h7.1Z\"\u002F>\u003Cpath fill=\"#06cc14\" d=\"M19.146 30.989a1 1 0 0 1-.207-.025a1.04 1.04 0 0 1-.726-1.213l2.709-14.431a1.04 1.04 0 0 1 .444-.683a.9.9 0 0 1 .7-.122a1.043 1.043 0 0 1 .727 1.213L20.077 30.16a1.03 1.03 0 0 1-.442.681a.9.9 0 0 1-.489.148m5.432-2.045h-.068a.93.93 0 0 1-.668-.377a1.1 1.1 0 0 1 .1-1.419l4.658-4.553l-4.638-4.239a1.1 1.1 0 0 1-.141-1.416a.94.94 0 0 1 .661-.4a.9.9 0 0 1 .709.237l5.47 5a1.1 1.1 0 0 1 .144 1.416a1 1 0 0 1-.142.163l-5.447 5.324a.92.92 0 0 1-.638.264m-8.155.003a.9.9 0 0 1-.639-.267l-5.452-5.327a1 1 0 0 1-.132-.153a1.094 1.094 0 0 1 .141-1.414l5.471-5a.88.88 0 0 1 .7-.238a.94.94 0 0 1 .665.4a1.1 1.1 0 0 1-.14 1.417L12.4 22.6l4.659 4.551a1.09 1.09 0 0 1 .1 1.419a.93.93 0 0 1-.669.377Z\"\u002F>",{"left":4,"top":4,"width":20,"height":20,"rotate":4,"vFlip":6,"hFlip":6,"body":29},"\u003Cpath fill=\"#007acc\" d=\"M23.827 8.243a4.4 4.4 0 0 1 2.223 1.281a6 6 0 0 1 .852 1.143c.011.045-1.534 1.083-2.471 1.662c-.034.023-.169-.124-.322-.35a2.01 2.01 0 0 0-1.67-1c-1.077-.074-1.771.49-1.766 1.433a1.3 1.3 0 0 0 .153.666c.237.49.677.784 2.059 1.383c2.544 1.095 3.636 1.817 4.31 2.843a5.16 5.16 0 0 1 .416 4.333a4.76 4.76 0 0 1-3.932 2.815a11 11 0 0 1-2.708-.028a6.53 6.53 0 0 1-3.616-1.884a6.3 6.3 0 0 1-.926-1.371a3 3 0 0 1 .327-.208c.158-.09.756-.434 1.32-.761l1.024-.6l.214.312a4.8 4.8 0 0 0 1.35 1.292a3.3 3.3 0 0 0 3.458-.175a1.545 1.545 0 0 0 .2-1.974c-.276-.395-.84-.727-2.443-1.422a8.8 8.8 0 0 1-3.349-2.055a4.7 4.7 0 0 1-.976-1.777a7.1 7.1 0 0 1-.062-2.268a4.33 4.33 0 0 1 3.644-3.374a9 9 0 0 1 2.691.084m-8.343 1.483l.011 1.454h-4.63v13.148H7.6V11.183H2.97V9.755a14 14 0 0 1 .04-1.466c.017-.023 2.832-.034 6.245-.028l6.211.017Z\"\u002F>",{"left":4,"top":4,"width":20,"height":20,"rotate":4,"vFlip":6,"hFlip":6,"body":31},"\u003Cpath fill=\"#f5de19\" d=\"M4.014 14.976a2.5 2.5 0 0 0 1.567-.518a2.38 2.38 0 0 0 .805-1.358a15.3 15.3 0 0 0 .214-2.944q.012-2.085.075-2.747a5.2 5.2 0 0 1 .418-1.686a3 3 0 0 1 .755-1.018A3.05 3.05 0 0 1 9 4.125A6.8 6.8 0 0 1 10.544 4h.7v1.96h-.387a2.34 2.34 0 0 0-1.723.468a3.4 3.4 0 0 0-.425 2.092a36 36 0 0 1-.137 4.133a4.7 4.7 0 0 1-.768 2.06A4.6 4.6 0 0 1 6.1 16a3.8 3.8 0 0 1 1.992 1.754a8.9 8.9 0 0 1 .618 3.865q0 2.435.05 2.9a1.76 1.76 0 0 0 .504 1.181a2.64 2.64 0 0 0 1.592.337h.387V28h-.7a5.7 5.7 0 0 1-1.773-.2a2.97 2.97 0 0 1-1.324-.93a3.35 3.35 0 0 1-.681-1.63a24 24 0 0 1-.165-3.234a16.5 16.5 0 0 0-.214-3.106a2.4 2.4 0 0 0-.805-1.361a2.5 2.5 0 0 0-1.567-.524Zm23.972 2.035a2.5 2.5 0 0 0-1.567.524a2.4 2.4 0 0 0-.805 1.361a16.5 16.5 0 0 0-.212 3.109a24 24 0 0 1-.169 3.234a3.35 3.35 0 0 1-.681 1.63a2.97 2.97 0 0 1-1.324.93a5.7 5.7 0 0 1-1.773.2h-.7V26.04h.387a2.64 2.64 0 0 0 1.592-.337a1.76 1.76 0 0 0 .506-1.186q.05-.462.05-2.9a8.9 8.9 0 0 1 .618-3.865A3.8 3.8 0 0 1 25.9 16a4.6 4.6 0 0 1-1.7-1.286a4.7 4.7 0 0 1-.768-2.06a36 36 0 0 1-.137-4.133a3.4 3.4 0 0 0-.425-2.092a2.34 2.34 0 0 0-1.723-.468h-.387V4h.7a6.8 6.8 0 0 1 1.54.125a3.05 3.05 0 0 1 1.149.581a3 3 0 0 1 .755 1.018a5.2 5.2 0 0 1 .418 1.686q.062.662.075 2.747a15.3 15.3 0 0 0 .212 2.947a2.38 2.38 0 0 0 .805 1.355a2.5 2.5 0 0 0 1.567.518Z\"\u002F>",{"id":33,"title":34,"body":35,"description":1129,"extension":1130,"meta":1131,"navigation":10,"path":1132,"seo":1133,"stem":1134,"__hash__":1135},"docs\u002Fdocs\u002Fv2\u002Fcognets\u002Fapi\u002Floop.md","loop",{"type":36,"value":37,"toc":1115},"minimark",[38,41,45,189,200,208,357,373,382,386,401,443,448,455,506,509,513,537,548,561,565,657,664,680,683,687,729,790,797,817,824,860,863,870,903,909,916,923,927,1023,1085,1091,1097,1101,1108,1111],[39,40,34],"h1",{"id":34},[42,43,44],"p",{},"The brain's entry point. A cognet declares exactly one, and it is the only thing the kernel\ncalls.",[46,47,52],"pre",{"className":48,"code":49,"language":50,"meta":51,"style":51},"language-ts shiki shiki-themes dark-plus","loop(async ({ stimuli, signal, stop }) => { \u002F* one tick *\u002F })\n\ntype LoopCtx = {\n    \u002F** Stimuli committed since the last wake, in seq order. *\u002F\n    stimuli: readonly AxonStimulusEntry[]\n    \u002F** The wake's abort leash — for the cognet's OWN work. *\u002F\n    signal: AbortSignal\n    \u002F** End the wake after this tick completes. The brain stays warm. *\u002F\n    stop(): void\n}\n","ts","",[53,54,55,105,111,124,130,148,154,165,171,183],"code",{"__ignoreMap":51},[56,57,60,63,67,71,74,78,81,84,86,89,92,95,98,102],"span",{"class":58,"line":59},"line",1,[56,61,34],{"class":62},"sCudf",[56,64,66],{"class":65},"sTNBD","(",[56,68,70],{"class":69},"scz_3","async",[56,72,73],{"class":65}," ({ ",[56,75,77],{"class":76},"s3F5K","stimuli",[56,79,80],{"class":65},", ",[56,82,83],{"class":76},"signal",[56,85,80],{"class":65},[56,87,88],{"class":76},"stop",[56,90,91],{"class":65}," }) ",[56,93,94],{"class":69},"=>",[56,96,97],{"class":65}," { ",[56,99,101],{"class":100},"sOLPB","\u002F* one tick *\u002F",[56,103,104],{"class":65}," })\n",[56,106,108],{"class":58,"line":107},2,[56,109,110],{"emptyLinePlaceholder":10},"\n",[56,112,114,117,121],{"class":58,"line":113},3,[56,115,116],{"class":69},"type",[56,118,120],{"class":119},"sNl3T"," LoopCtx",[56,122,123],{"class":65}," = {\n",[56,125,127],{"class":58,"line":126},4,[56,128,129],{"class":100},"    \u002F** Stimuli committed since the last wake, in seq order. *\u002F\n",[56,131,133,136,139,142,145],{"class":58,"line":132},5,[56,134,135],{"class":76},"    stimuli",[56,137,138],{"class":65},": ",[56,140,141],{"class":69},"readonly",[56,143,144],{"class":119}," AxonStimulusEntry",[56,146,147],{"class":65},"[]\n",[56,149,151],{"class":58,"line":150},6,[56,152,153],{"class":100},"    \u002F** The wake's abort leash — for the cognet's OWN work. *\u002F\n",[56,155,157,160,162],{"class":58,"line":156},7,[56,158,159],{"class":76},"    signal",[56,161,138],{"class":65},[56,163,164],{"class":119},"AbortSignal\n",[56,166,168],{"class":58,"line":167},8,[56,169,170],{"class":100},"    \u002F** End the wake after this tick completes. The brain stays warm. *\u002F\n",[56,172,174,177,180],{"class":58,"line":173},9,[56,175,176],{"class":62},"    stop",[56,178,179],{"class":65},"(): ",[56,181,182],{"class":119},"void\n",[56,184,186],{"class":58,"line":185},10,[56,187,188],{"class":65},"}\n",[42,190,191,192,195,196,199],{},"Declaring two loops throws ",[53,193,194],{},"COGNET_LOOP_ALREADY_DECLARED",". Declaring none throws\n",[53,197,198],{},"COGNET_NO_LOOP",".",[201,202,204,207],"h2",{"id":203},"maints-is-a-raw-script",[53,205,206],{},"main.ts"," is a raw script",[46,209,211],{"className":48,"code":210,"language":50,"meta":51,"style":51},"\u002F\u002F src\u002Fmain.ts\nimport { Air } from \"@arcforge\u002Fair\"\nimport { state, sync } from \".\u002Fstate\"\n\nconst air = Air({ protocol: \"classic\" })   \u002F\u002F resident for the process\n\nloop(async ({ stop }) => {\n    await phase(\"render\", async () => { \u002F* ... *\u002F })\n    stop()\n})\n",[53,212,213,218,239,260,264,293,297,316,345,352],{"__ignoreMap":51},[56,214,215],{"class":58,"line":59},[56,216,217],{"class":100},"\u002F\u002F src\u002Fmain.ts\n",[56,219,220,224,226,229,232,235],{"class":58,"line":107},[56,221,223],{"class":222},"sYbnZ","import",[56,225,97],{"class":65},[56,227,228],{"class":76},"Air",[56,230,231],{"class":65}," } ",[56,233,234],{"class":222},"from",[56,236,238],{"class":237},"sKc5r"," \"@arcforge\u002Fair\"\n",[56,240,241,243,245,248,250,253,255,257],{"class":58,"line":113},[56,242,223],{"class":222},[56,244,97],{"class":65},[56,246,247],{"class":76},"state",[56,249,80],{"class":65},[56,251,252],{"class":76},"sync",[56,254,231],{"class":65},[56,256,234],{"class":222},[56,258,259],{"class":237}," \".\u002Fstate\"\n",[56,261,262],{"class":58,"line":126},[56,263,110],{"emptyLinePlaceholder":10},[56,265,266,269,273,276,278,281,284,287,290],{"class":58,"line":132},[56,267,268],{"class":69},"const",[56,270,272],{"class":271},"s9McN"," air",[56,274,275],{"class":65}," = ",[56,277,228],{"class":62},[56,279,280],{"class":65},"({ ",[56,282,283],{"class":76},"protocol:",[56,285,286],{"class":237}," \"classic\"",[56,288,289],{"class":65}," })   ",[56,291,292],{"class":100},"\u002F\u002F resident for the process\n",[56,294,295],{"class":58,"line":150},[56,296,110],{"emptyLinePlaceholder":10},[56,298,299,301,303,305,307,309,311,313],{"class":58,"line":156},[56,300,34],{"class":62},[56,302,66],{"class":65},[56,304,70],{"class":69},[56,306,73],{"class":65},[56,308,88],{"class":76},[56,310,91],{"class":65},[56,312,94],{"class":69},[56,314,315],{"class":65}," {\n",[56,317,318,321,324,326,329,331,333,336,338,340,343],{"class":58,"line":167},[56,319,320],{"class":222},"    await",[56,322,323],{"class":62}," phase",[56,325,66],{"class":65},[56,327,328],{"class":237},"\"render\"",[56,330,80],{"class":65},[56,332,70],{"class":69},[56,334,335],{"class":65}," () ",[56,337,94],{"class":69},[56,339,97],{"class":65},[56,341,342],{"class":100},"\u002F* ... *\u002F",[56,344,104],{"class":65},[56,346,347,349],{"class":58,"line":173},[56,348,176],{"class":62},[56,350,351],{"class":65},"()\n",[56,353,354],{"class":58,"line":185},[56,355,356],{"class":65},"})\n",[42,358,359,360,364,365,368,369,372],{},"Not a module with exports. It runs ",[361,362,363],"strong",{},"once"," at ",[53,366,367],{},"load()",", with the ambient globals live and\nthe kernel already bound, and its job is to declare ",[53,370,371],{},"loop()",". Everything it holds in module\nor closure scope is the brain's resident memory for the life of the process.",[42,374,375,376,378,379,199],{},"Imports are ordinary. Doing work at the top level is not — the kernel binds at ",[53,377,367],{},",\nand touching a syscall before that throws ",[53,380,381],{},"COGNET_ACCESSED_BEFORE_LOAD",[201,383,385],{"id":384},"wake-tick-stop","Wake, tick, stop",[42,387,388,389,392,393,396,397,400],{},"A ",[361,390,391],{},"wake"," is one invocation of the brain. A ",[361,394,395],{},"tick"," is one iteration of the loop body\ninside that wake. The body runs repeatedly until it calls ",[53,398,399],{},"stop()"," or the wake aborts.",[46,402,404],{"className":48,"code":403,"language":50,"meta":51,"style":51},"loop(async ({ stop }) => {\n    \u002F\u002F ... this runs again, and again, until:\n    stop()   \u002F\u002F end the wake AFTER this tick completes\n})\n",[53,405,406,424,429,439],{"__ignoreMap":51},[56,407,408,410,412,414,416,418,420,422],{"class":58,"line":59},[56,409,34],{"class":62},[56,411,66],{"class":65},[56,413,70],{"class":69},[56,415,73],{"class":65},[56,417,88],{"class":76},[56,419,91],{"class":65},[56,421,94],{"class":69},[56,423,315],{"class":65},[56,425,426],{"class":58,"line":107},[56,427,428],{"class":100},"    \u002F\u002F ... this runs again, and again, until:\n",[56,430,431,433,436],{"class":58,"line":113},[56,432,176],{"class":62},[56,434,435],{"class":65},"()   ",[56,437,438],{"class":100},"\u002F\u002F end the wake AFTER this tick completes\n",[56,440,441],{"class":58,"line":126},[56,442,356],{"class":65},[42,444,445,447],{},[53,446,399],{}," is a declaration that the wake is finished, not an immediate exit — the current\ntick runs to completion. Afterward the brain stays warm: module scope survives, and the\nnext wake starts with everything still resident.",[42,449,450,451,454],{},"This is where a cognet expresses ",[361,452,453],{},"judgment about its own completion",":",[46,456,458],{"className":48,"code":457,"language":50,"meta":51,"style":51},"\u002F\u002F Code this tick means another tick regardless of what the model said —\n\u002F\u002F the model must see its own results before the wake can honestly end.\nif (done && blocks.length === 0) stop()\n",[53,459,460,465,470],{"__ignoreMap":51},[56,461,462],{"class":58,"line":59},[56,463,464],{"class":100},"\u002F\u002F Code this tick means another tick regardless of what the model said —\n",[56,466,467],{"class":58,"line":107},[56,468,469],{"class":100},"\u002F\u002F the model must see its own results before the wake can honestly end.\n",[56,471,472,475,478,481,484,487,489,492,495,499,502,504],{"class":58,"line":113},[56,473,474],{"class":222},"if",[56,476,477],{"class":65}," (",[56,479,480],{"class":76},"done",[56,482,483],{"class":65}," && ",[56,485,486],{"class":76},"blocks",[56,488,199],{"class":65},[56,490,491],{"class":76},"length",[56,493,494],{"class":65}," === ",[56,496,498],{"class":497},"sDGX8","0",[56,500,501],{"class":65},") ",[56,503,88],{"class":62},[56,505,351],{"class":65},[42,507,508],{},"That policy belongs to the cognet. The kernel has no opinion about when thinking is\nfinished.",[201,510,511],{"id":77},[53,512,77],{},[42,514,515,516,519,520,80,523,80,526,80,529,532,533,536],{},"Narrowly typed to ",[53,517,518],{},"cognet:stimulus:*"," — ",[53,521,522],{},"text",[53,524,525],{},"audio",[53,527,528],{},"visual",[53,530,531],{},"vector",". The cognet's\nwhole input contract, mirroring ",[53,534,535],{},"output()"," being its whole unmediated write contract. It\nnever has to switch over every entry family that exists, only what it can actually receive.",[42,538,539,542,543,547],{},[361,540,541],{},"An empty diff is ordinary, not an edge case."," For a continuous cognet it is the steady\nstate. For an invocation cognet the diff may hold ",[544,545,546],"em",{},"more"," than one stimulus, when several\narrived while the previous wake was running.",[42,549,550,551,553,554,199],{},"Only the first tick of a wake sees new arrivals — ",[53,552,77],{}," is the wake's diff, not a live\nfeed. A cognet that wants history reads\n",[555,556,558],"a",{"href":557},"\u002Fdocs\u002Fv2\u002Fcognets\u002Fapi\u002Fstore",[53,559,560],{},"kernel.store.session",[201,562,563],{"id":83},[53,564,83],{},[46,566,568],{"className":48,"code":567,"language":50,"meta":51,"style":51},"loop(async ({ signal, stop }) => {\n    for (const item of work) {\n        if (signal.aborted) return\n        await fold(item)\n    }\n})\n",[53,569,570,592,613,632,648,653],{"__ignoreMap":51},[56,571,572,574,576,578,580,582,584,586,588,590],{"class":58,"line":59},[56,573,34],{"class":62},[56,575,66],{"class":65},[56,577,70],{"class":69},[56,579,73],{"class":65},[56,581,83],{"class":76},[56,583,80],{"class":65},[56,585,88],{"class":76},[56,587,91],{"class":65},[56,589,94],{"class":69},[56,591,315],{"class":65},[56,593,594,597,599,601,604,607,610],{"class":58,"line":107},[56,595,596],{"class":222},"    for",[56,598,477],{"class":65},[56,600,268],{"class":69},[56,602,603],{"class":271}," item",[56,605,606],{"class":69}," of",[56,608,609],{"class":76}," work",[56,611,612],{"class":65},") {\n",[56,614,615,618,620,622,624,627,629],{"class":58,"line":113},[56,616,617],{"class":222},"        if",[56,619,477],{"class":65},[56,621,83],{"class":76},[56,623,199],{"class":65},[56,625,626],{"class":76},"aborted",[56,628,501],{"class":65},[56,630,631],{"class":222},"return\n",[56,633,634,637,640,642,645],{"class":58,"line":126},[56,635,636],{"class":222},"        await",[56,638,639],{"class":62}," fold",[56,641,66],{"class":65},[56,643,644],{"class":76},"item",[56,646,647],{"class":65},")\n",[56,649,650],{"class":58,"line":132},[56,651,652],{"class":65},"    }\n",[56,654,655],{"class":58,"line":150},[56,656,356],{"class":65},[42,658,659,660,663],{},"The wake's abort leash, for the cognet's ",[361,661,662],{},"own"," work only.",[42,665,666,667,80,670,80,673,676,677],{},"Everything the kernel mediates — ",[53,668,669],{},"run()",[53,671,672],{},"stream()",[53,674,675],{},"transform()"," — is cancelled by the\nkernel itself, unconditionally. A wake's cancellation is not something a cognet opts into,\nand threading a signal by hand meant one missing argument made an operation unkillable.\n",[361,678,679],{},"Those verbs take no signal at all.",[42,681,682],{},"What remains is the loop's own units of work between those calls: folding state, evaluating\na stop condition, anything running in cognet code. A JS function cannot be preempted, so\nhonouring this is cooperative and always will be. Check it between units and return.",[201,684,686],{"id":685},"invocation-and-continuous","Invocation and continuous",[46,688,690],{"className":48,"code":689,"language":50,"meta":51,"style":51},"export default defineCognet({\n    mode: { kind: \"invocation\" },   \u002F\u002F or { kind: \"continuous\" }\n})\n",[53,691,692,706,725],{"__ignoreMap":51},[56,693,694,697,700,703],{"class":58,"line":59},[56,695,696],{"class":222},"export",[56,698,699],{"class":222}," default",[56,701,702],{"class":62}," defineCognet",[56,704,705],{"class":65},"({\n",[56,707,708,711,713,716,719,722],{"class":58,"line":107},[56,709,710],{"class":76},"    mode:",[56,712,97],{"class":65},[56,714,715],{"class":76},"kind:",[56,717,718],{"class":237}," \"invocation\"",[56,720,721],{"class":65}," },   ",[56,723,724],{"class":100},"\u002F\u002F or { kind: \"continuous\" }\n",[56,726,727],{"class":58,"line":113},[56,728,356],{"class":65},[730,731,732,750],"table",{},[733,734,735],"thead",{},[736,737,738,742,745],"tr",{},[739,740,741],"th",{},"Mode",[739,743,744],{},"Woken by",[739,746,747,748],{},"Empty ",[53,749,77],{},[751,752,753,767],"tbody",{},[736,754,755,761,764],{},[756,757,758],"td",{},[53,759,760],{},"invocation",[756,762,763],{},"A stimulus arriving",[756,765,766],{},"Does not happen",[736,768,769,774,787],{},[756,770,771],{},[53,772,773],{},"continuous",[756,775,776,777,780,781],{},"A clock the ",[361,778,779],{},"body"," owns, via ",[555,782,784],{"href":783},"\u002Fdocs\u002Fv2\u002Fcognets\u002Fapi\u002Fkernel",[53,785,786],{},"kernel.wake()",[756,788,789],{},"The ordinary steady state",[42,791,792,793,796],{},"Part of the cognet's own declared identity, never blueprint-overridable — same trust\ndirection as ",[53,794,795],{},"abi",". A cognet built for invocation-based wakes was never written to tolerate\nan empty-stimuli tick, so an agent author cannot flip this from outside.",[42,798,799,802,803,806,807,810,811,814,815,199],{},[361,800,801],{},"Continuous carries no rate."," It declares the ",[544,804,805],{},"shape"," of the cognet — \"tick me, don't\nhand me a chat prompt\" — and nothing more. A ",[53,808,809],{},"tickMs"," lived here once and was wrong in the\nsame way a ",[53,812,813],{},"salience"," field on a stimulus is wrong: it had the brain asserting how fast its\nworld turns, which it cannot know. The rate lives with whatever drives ",[53,816,786],{},[201,818,820,823],{"id":819},"wakeon-which-entries-wake-you",[53,821,822],{},"wakeOn"," — which entries wake you",[46,825,827],{"className":48,"code":826,"language":50,"meta":51,"style":51},"export default defineCognet({\n    wakeOn: [\"cognet:stimulus:text\"],   \u002F\u002F absent = wake on everything\n})\n",[53,828,829,839,856],{"__ignoreMap":51},[56,830,831,833,835,837],{"class":58,"line":59},[56,832,696],{"class":222},[56,834,699],{"class":222},[56,836,702],{"class":62},[56,838,705],{"class":65},[56,840,841,844,847,850,853],{"class":58,"line":107},[56,842,843],{"class":76},"    wakeOn:",[56,845,846],{"class":65}," [",[56,848,849],{"class":237},"\"cognet:stimulus:text\"",[56,851,852],{"class":65},"],   ",[56,854,855],{"class":100},"\u002F\u002F absent = wake on everything\n",[56,857,858],{"class":58,"line":113},[56,859,356],{"class":65},[42,861,862],{},"A conversational cognet declares nothing and hears all of it. One attached to a firehose\nsensor names the few kinds worth a thought. Overridable by the blueprint.",[201,864,866,869],{"id":865},"maxticksperwake-the-runaway-guard",[53,867,868],{},"maxTicksPerWake"," — the runaway guard",[46,871,873],{"className":48,"code":872,"language":50,"meta":51,"style":51},"export default defineCognet({\n    maxTicksPerWake: 32,   \u002F\u002F omitted = UNBOUNDED, and that is the right default\n})\n",[53,874,875,885,899],{"__ignoreMap":51},[56,876,877,879,881,883],{"class":58,"line":59},[56,878,696],{"class":222},[56,880,699],{"class":222},[56,882,702],{"class":62},[56,884,705],{"class":65},[56,886,887,890,893,896],{"class":58,"line":107},[56,888,889],{"class":76},"    maxTicksPerWake:",[56,891,892],{"class":497}," 32",[56,894,895],{"class":65},",   ",[56,897,898],{"class":100},"\u002F\u002F omitted = UNBOUNDED, and that is the right default\n",[56,900,901],{"class":58,"line":113},[56,902,356],{"class":65},[42,904,905,906,199],{},"Exceeding it throws ",[53,907,908],{},"COGNET_MAX_TICKS",[42,910,911,912,915],{},"Omitted means unbounded, which is correct for most cognets. A ceiling cannot distinguish a\nrunaway loop from a long job — the only difference is whether the ticks accomplish\nanything, which a count cannot see. ",[53,913,914],{},"zero"," capped this at 32 once and killed a run\nmid-verification after forty clean turns of real work.",[42,917,918,919,922],{},"Set it only where a wake is genuinely expected to converge in a known number of steps — a\nclassifier, a fixed pipeline — so exceeding it really is a bug. For open-ended work, what\nbounds a wake is ",[53,920,921],{},"\u003Cdone\u002F>",", the user's interrupt, and the engine failing loudly.",[201,924,926],{"id":925},"plugins","Plugins",[46,928,930],{"className":48,"code":929,"language":50,"meta":51,"style":51},"\u002F\u002F plugins\u002Fclock.ts\nexport default definePlugin(({ hooks }) => {\n    hooks.on(\"boot\", () => {\n        setInterval(() => void kernel.wake(), 1000 \u002F 30)\n    })\n})\n",[53,931,932,937,958,980,1014,1019],{"__ignoreMap":51},[56,933,934],{"class":58,"line":59},[56,935,936],{"class":100},"\u002F\u002F plugins\u002Fclock.ts\n",[56,938,939,941,943,946,949,952,954,956],{"class":58,"line":107},[56,940,696],{"class":222},[56,942,699],{"class":222},[56,944,945],{"class":62}," definePlugin",[56,947,948],{"class":65},"(({ ",[56,950,951],{"class":76},"hooks",[56,953,91],{"class":65},[56,955,94],{"class":69},[56,957,315],{"class":65},[56,959,960,963,965,968,970,973,976,978],{"class":58,"line":113},[56,961,962],{"class":76},"    hooks",[56,964,199],{"class":65},[56,966,967],{"class":62},"on",[56,969,66],{"class":65},[56,971,972],{"class":237},"\"boot\"",[56,974,975],{"class":65},", () ",[56,977,94],{"class":69},[56,979,315],{"class":65},[56,981,982,985,988,990,993,996,998,1000,1003,1006,1009,1012],{"class":58,"line":126},[56,983,984],{"class":62},"        setInterval",[56,986,987],{"class":65},"(() ",[56,989,94],{"class":69},[56,991,992],{"class":69}," void",[56,994,995],{"class":76}," kernel",[56,997,199],{"class":65},[56,999,391],{"class":62},[56,1001,1002],{"class":65},"(), ",[56,1004,1005],{"class":497},"1000",[56,1007,1008],{"class":65}," \u002F ",[56,1010,1011],{"class":497},"30",[56,1013,647],{"class":65},[56,1015,1016],{"class":58,"line":132},[56,1017,1018],{"class":65},"    })\n",[56,1020,1021],{"class":58,"line":150},[56,1022,356],{"class":65},[730,1024,1025,1035],{},[733,1026,1027],{},[736,1028,1029,1032],{},[739,1030,1031],{},"Hook",[739,1033,1034],{},"Fires",[751,1036,1037,1051,1060,1072],{},[736,1038,1039,1044],{},[756,1040,1041],{},[53,1042,1043],{},"boot",[756,1045,1046,1047,1050],{},"Once, after ",[53,1048,1049],{},"main()"," declared the loop",[736,1052,1053,1057],{},[756,1054,1055],{},[53,1056,391],{},[756,1058,1059],{},"Before the first tick of each wake, with the wake",[736,1061,1062,1066],{},[756,1063,1064],{},[53,1065,395],{},[756,1067,1068,1069],{},"Before each tick body, with ",[53,1070,1071],{},"{ tick }",[736,1073,1074,1079],{},[756,1075,1076],{},[53,1077,1078],{},"shutdown",[756,1080,1081,1082],{},"Once, at ",[53,1083,1084],{},"unload()",[42,1086,1087,1088,1090],{},"Registered at import time, awaited to completion in order. ",[53,1089,395],{}," is on the hot path —\nplugins there must stay cheap.",[42,1092,1093,1096],{},[53,1094,1095],{},"definePlugin"," is global-only and side-effecting: calling it registers the hooks.",[201,1098,1100],{"id":1099},"overlap","Overlap",[42,1102,1103,1104,1107],{},"Two wakes of a continuous cognet routinely overlap — the clock fires whether or not the\nprevious wake finished. Each gets its own tick counter and its own ambient scope, bound\nacross every await, so a ",[53,1105,1106],{},"phase()"," in one never times against the other's clock.",[42,1109,1110],{},"Module scope is shared. That is the brain's resident memory, and treating it as\nsingle-writer is the cognet's problem to solve.",[1112,1113,1114],"style",{},"html pre.shiki code .sCudf, html code.shiki .sCudf{--shiki-default:#DCDCAA}html pre.shiki code .sTNBD, html code.shiki .sTNBD{--shiki-default:#D4D4D4}html pre.shiki code .scz_3, html code.shiki .scz_3{--shiki-default:#569CD6}html pre.shiki code .s3F5K, html code.shiki .s3F5K{--shiki-default:#9CDCFE}html pre.shiki code .sOLPB, html code.shiki .sOLPB{--shiki-default:#6A9955}html pre.shiki code .sNl3T, html code.shiki .sNl3T{--shiki-default:#4EC9B0}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 .sYbnZ, html code.shiki .sYbnZ{--shiki-default:#C586C0}html pre.shiki code .sKc5r, html code.shiki .sKc5r{--shiki-default:#CE9178}html pre.shiki code .s9McN, html code.shiki .s9McN{--shiki-default:#4FC1FF}html pre.shiki code .sDGX8, html code.shiki .sDGX8{--shiki-default:#B5CEA8}",{"title":51,"searchDepth":107,"depth":107,"links":1116},[1117,1119,1120,1121,1122,1123,1125,1127,1128],{"id":203,"depth":107,"text":1118},"main.ts is a raw script",{"id":384,"depth":107,"text":385},{"id":77,"depth":107,"text":77},{"id":83,"depth":107,"text":83},{"id":685,"depth":107,"text":686},{"id":819,"depth":107,"text":1124},"wakeOn — which entries wake you",{"id":865,"depth":107,"text":1126},"maxTicksPerWake — the runaway guard",{"id":925,"depth":107,"text":926},{"id":1099,"depth":107,"text":1100},"loop() is a cognet's entry point and the only thing the kernel calls. A cognet declares exactly one.","md",{},"\u002Fdocs\u002Fv2\u002Fcognets\u002Fapi\u002Floop",{"title":34,"description":1129},"docs\u002Fv2\u002Fcognets\u002Fapi\u002Floop","dEePUMiZwX39bKz-HnZu7Gh-xjQEl7i1AuvSdYxASkU",1788121883897]