Skip to content

feat(deploy): add persistent GBrain embedding endpoint - #1644

Closed
HelloWorldSungin wants to merge 62 commits into
kunchenguid:mainfrom
HelloWorldSungin:fm/gbrain-embed-endpoints
Closed

HelloWorldSungin wants to merge 62 commits into
kunchenguid:mainfrom
HelloWorldSungin:fm/gbrain-embed-endpoints

Conversation

@HelloWorldSungin

Copy link
Copy Markdown

Intent

Serve local embedding and reranker endpoints on the four RTX 5060 Ti Blackwell GPU rig for GBrain story #5. The captain authorized and enabled user lingering, so deliver the user-level, boot-persistent embedding endpoint only: loopback binding, explicit CUDA device pinning, restart policy, bounded logs, and a health check. Use the catalog-verified Ollama model snowflake-arctic-embed2:568m, record its actual 1024-dimensional OpenAI-compatible response, pinned runtime/archive and model hashes, port, GPU evidence, exact GBrain #6 configuration, tested curl command, local-network evidence, and restart/process-crash recovery evidence. Do not add or attempt reranker service units or CUDA builds in this validation run because the reranker CUDA path remains separately escalated to the captain. Keep the change a doc/config handoff, not a control plane or sync engine. The PR must target HelloWorldSungin/firstmate, comment substantively on issue #5 before reporting ready, and include Closes #5 in the PR body.

What Changed

  • Add a user-level Ollama service and health check for a loopback-only, boot-persistent snowflake-arctic-embed2:568m endpoint pinned to a specific GPU UUID, with restart and journal rate-limit policies.
  • Document pinned runtime and model hashes, the 1024-dimensional OpenAI-compatible contract, deployment steps, and exact GBrain initialization and endpoint configuration.
  • Record listener, GPU, lingering, enablement, and crash-recovery evidence while distinguishing the tested deployment from the updated UUID-pinned handoff.

Closes #5

Risk Assessment

✅ Low: Captain, the approved fixes close the prior boot-ordering, retry, rate-limit, GPU-identity, and GBrain endpoint-environment paths, and the remaining change is a well-bounded doc/config handoff.

Testing

Targeted configuration parsing, live health/API probing, service persistence, loopback networking, GPU placement, pinned hashes, and recorded crash recovery all passed with direct evidence; no UI screenshot was produced because this change exposes a local API and systemd/CLI operator surface rather than rendered UI.

Evidence: Full OpenAI-compatible embedding response
{"object":"list","data":[{"object":"embedding","embedding":[-0.00043697056,0.048999522,0.029834952,-0.08814191,-0.03728249,-0.0235623,0.0043571186,0.035195842,-0.0693684,0.017735882,0.011700096,-0.024732126,0.090225905,0.025000736,-0.060786262,0.008112553,-0.00102869,-0.00048043992,0.0059898584,0.002971664,-0.044688087,0.024459448,-0.08777216,-0.0025521081,0.047905277,-0.011285882,0.053092863,-0.022077557,0.016168412,0.0041004713,0.0042705615,-0.045707792,0.022091014,-0.011670078,-0.09485644,-0.02998143,0.031857796,-0.0049315654,-0.15499163,0.025559045,-0.02139852,0.027231146,-0.018630382,-0.044940416,0.0050259363,-0.02091469,-0.00958444,-0.015890835,0.0026752695,-0.05191728,-0.021591859,-0.0051005925,0.05005405,0.03067607,0.02904017,-0.0005904541,-0.069118746,-0.0025333962,0.07537391,-0.015929824,0.04595866,0.022371879,0.0012656206,-0.012769068,-0.017508546,-0.028422847,0.041946955,-0.001605163,-0.009664108,0.028276611,-0.018114775,0.030939786,0.022791449,0.057923608,0.012220022,0.004315802,-0.039728194,-0.05396575,0.006520802,0.018256694,0.12326688,0.016565342,-0.05014213,-0.0039302194,-0.007332593,-0.10406307,-0.047994018,-0.030652326,0.0053608674,-0.038406584,0.04810274,0.036767747,-0.02098178,0.038544226,-0.049123105,0.031379614,-0.023863764,0.04009746,0.012102648,-0.0074380534,-0.027299432,0.0893914,-0.021260029,-0.064292744,0.0051774164,-0.08849952,-0.021863012,0.022566527,-0.09590013,0.06401435,0.0094241835,0.00093566667,-0.0030104674,0.13007008,0.000175434,-0.008877759,-0.023441182,-0.04971103,-0.02093385,-0.057643637,0.037038114,-0.045969017,0.030238768,0.035943113,-0.0028887037,-0.037093755,0.004122511,0.024282001,0.037913542,-0.0045167967,-0.029917328,-0.020412916,0.026923658,0.010297324,0.005538174,0.015611544,0.0071880356,0.024382701,-0.055846542,-0.03280399,0.027558895,0.029699186,0.02323865,0.06949715,0.0036275873,-0.0018397507,-0.0048011774,-0.036388256,-0.09320125,0.0049768663,-0.047831137,-0.014075564,0.0072411476,0.011452099,-0.038690418,0.0053410493,-0.01705386,-0.03541638,0.0296077,0.024299284,-0.020493852,-0.025347676,-0.019663166,0.0046119066,0.01640909,0.021221241,0.041597478,-0.0023603693,-0.057754856,-0.08532335,0.01963196,0.020614734,-0.01012732,0.0049096094,-0.08170914,0.0197939,0.09022039,0.03868832,0.03700116,-0.042938713,0.016742516,0.021684013,0.045660518,0.045019884,-0.0138863195,-0.013180009,0.011484586,0.031608317,0.0021109607,-0.007820106,0.04215964,-0.04065491,-0.0062850076,0.011869639,-0.002820277,0.017642597,-0.008787609,-0.054831635,-0.036105614,-0.024730803,-0.009765392,-0.07639359,0.06900972,-0.0027700844,0.05567727,-0.025923787,0.046472233,0.0139355725,0.05143323,-0.029862182,-0.013854135,0.01798566,0.046048198,0.0051059127,-0.054092735,0.05304691,-0.025470978,0.07946045,-0.086301215,-0.08549236,-0.016963026,-0.0050090733,-0.03312906,0.08589941,0.041273832,-0.051763184,-0.02829762,0.090494424,-0.0050088163,0.08836793,-0.09652737,-0.020211225,-0.05135141,-0.027714536,-0.016581984,-0.0368457,-0.08640444,0.034677073,0.00983133,-0.009166299,0.019582303,0.023365103,-0.005094686,-0.005682826,0.03832341,-0.031376924,-0.021608645,0.00078643847,0.052580666,0.03795451,-0.02795791,-0.029795144,-0.061209198,0.020800777,0.044530027,0.044554513,-0.007974247,-0.0177434,0.008070265,0.009059524,0.028955901,0.031559296,-0.023923794,0.029710425,0.013617737,-0.01952805,0.0046779723,0.034532633,0.004585412,0.010750088,0.039504167,-0.0048341486,-0.0044559776,0.07624117,0.0052818293,0.019927448,0.05321257,-0.027908958,0.044859465,0.020143544,0.046031844,0.00574286,0.016033962,0.01864173,0.031330522,-0.02664337,-0.008346053,0.023955343,0.012172728,0.03971233,-0.04989402,0.027144698,0.041755106,-0.019105248,-0.01834872,0.018161424,0.008401022,-0.0009518049,-0.0015958346,0.02153024,0.011343037,0.016242601,0.024917845,-0.019802215,0.039547242,-0.016887281,0.03506479,-0.03776307,-0.02226119,0.010811377,-0.057607044,-0.09913781,0.0031250457,-0.011082217,-0.080135755,-0.041624382,-0.0056337016,-0.043670513,0.039868914,0.041363213,-0.042007662,0.0350244,-0.046109535,-0.029771123,0.013240711,-0.0057485676,-0.019723464,-0.022182526,0.007977143,-0.042456165,0.0034681568,0.016463079,0.04296277,-0.0571793,-0.016871866,0.009810095,0.01918254,0.0018208933,0.024054227,0.015455886,0.0016942594,-0.033525012,0.00039153654,0.03186082,-0.010402379,-0.0077966675,-0.0069470983,-0.004945916,0.009854847,0.00047427032,-0.018640114,0.013506351,-0.012916836,-0.041847195,0.006504171,-0.03812982,0.014919693,0.013162903,-0.018975148,-0.017210903,0.000112555215,-0.0001230918,-0.00022347686,-0.018480793,-0.059230104,0.035858147,0.027218534,0.034085475,0.033887442,-0.02201691,0.012226051,-0.047170565,0.004836223,0.045823347,-0.022714166,-0.004409962,0.011179212,-0.0016070032,0.005702917,0.0022879813,0.010123298,-0.015249262,0.009427112,-0.03296939,0.0034253746,-0.018379988,0.044185832,0.032726604,-0.039792743,0.017972067,0.026418565,0.004351645,-0.02787008,0.0037508686,-0.03560083,-0.016537739,0.032342095,-0.02043484,-0.0218266,0.0061562774,-0.00060185516,0.0321087,0.016764103,-0.034729175,0.009862955,-0.009247884,-0.06480419,0.08023004,0.05654597,0.008925013,-0.03712939,0.014289986,0.029596671,0.0024141213,-0.011206474,-0.0059732674,0.013598825,0.0039824075,-0.018839395,0.0040489836,-0.046899498,-0.0019713913,-0.050813943,0.012282099,0.042082466,0.030073935,-0.028803844,0.018825786,-0.024644036,0.04251232,0.019024199,0.0022405512,-0.020457579,-0.06226562,0.012727741,-0.04122852,0.014963138,-0.031182176,-0.009277199,0.029289052,0.031472016,-0.020474277,-0.046190687,-0.020425323,0.04963866,-0.033549108,0.015695775,0.043246925,-0.019768963,-0.0031129357,0.011433678,0.03620449,0.022597034,-0.02754095,0.008613197,-0.050195795,-0.016400367,0.0013777348,-0.060009126,0.058515936,0.013700884,0.015549481,0.0071228147,0.04084201,-0.051801838,-0.009722169,-0.00499594,0.009455056,0.017987957,-0.016356071,-0.022590311,0.020342685,0.018011233,0.036958434,0.0029715276,0.019046335,-0.016507495,0.012764705,0.02134996,0.013873709,-0.015172445,-0.009381818,0.043011513,-0.0100368075,0.050466094,-0.021878,-0.03433322,-0.021328652,-0.017721025,-0.01593626,-0.015369762,0.019421397,-0.0051427544,0.05231533,0.01665381,-0.03579482,-0.012049025,0.049719963,-0.012667204,-0.017472848,-0.00921992,0.0019300439,-0.029049834,-0.021753326,0.01491592,0.0016165032,0.013656561,-0.0023011551,0.017255884,0.010836655,-0.0268169,0.010038302,-0.05545378,0.017111855,0.009143963,0.0058249403,0.022529501,-0.008371305,0.0065588024,0.0027405017,-0.01216676,-0.01329122,0.022529827,0.014905479,0.0073707527,0.0046188654,0.03353408,-0.0058667017,0.030375026,0.028047325,-0.0002396343,-0.031475402,0.012563187,0.011601727,0.018701708,-0.021778412,-0.059130613,0.0030269525,0.0011789808,0.009639412,-0.002849754,-0.017366298,-0.003179677,-0.021546567,-0.019129246,-0.0369538,0.0060953847,-0.015961725,0.03064117,-0.010932755,-0.017352434,0.019060675,-0.0077636326,-0.0048052156,0.0489119,-0.018202122,-0.021044651,-0.029337237,-0.00496973,0.028655976,0.04244536,-0.008460338,0.005018007,-0.021712473,-0.017973118,-0.0037423996,0.0060841474,-0.02883847,0.016604831,0.03152248,0.021480266,-0.027329879,0.0014970325,0.0010023182,0.0012884014,-0.010616966,-0.020250438,0.015506057,-0.05968426,0.01031365,-0.008237715,-0.020013314,0.014890929,-0.034275845,0.012123319,0.004902544,0.0015378976,0.007508831,0.04586334,-0.025838155,0.007596385,-0.00038416946,-0.003431301,-0.023027152,0.0029466767,0.02576453,-0.030034687,0.027015781,-0.014158037,-0.0064494503,-0.036196746,0.055048425,0.023354638,0.0039661084,-0.012371257,-0.0069596996,0.04781448,0.020168314,-0.06936746,-0.000027839074,-0.030965675,0.030075982,-0.0077209254,0.002135304,0.062449023,0.047831763,-0.0055817245,-0.006196429,0.02356326,-0.016562732,0.026202688,0.0149617195,0.0023157727,0.014591337,0.015213444,0.0035447173,0.009213584,0.025594082,-0.0120115895,0.041455545,0.032332692,0.0767741,-0.013822798,0.007160862,0.04048623,-0.03255718,0.011907372,0.038941152,0.08556401,0.026927188,-0.002718718,-0.024725735,-0.00603546,-0.031702183,-0.033351425,-0.01899973,0.019744776,-0.034147196,-0.024619136,0.021406472,0.0026396948,0.050665062,-0.014783057,0.029606013,-0.003361183,-0.030653164,-0.03002,-0.0049290983,-0.03059085,-0.0013122951,0.02992672,-0.01576313,0.02441711,0.05879448,0.0127694635,0.06638194,-0.0058503775,-0.0020818873,-0.017756263,-0.028608395,-0.064126834,-0.035852138,0.0053867595,0.025602804,0.001662397,-0.01884924,0.027453072,0.021959594,0.017052611,-0.021874398,0.048926964,-0.046248306,0.01323414,0.009922961,-0.031234484,-0.004096559,-0.008016178,0.011633111,-0.013410184,-0.026488908,0.009580432,0.008247634,-0.021805368,-0.0055127745,0.047916833,0.04375594,0.004037301,-0.009920064,-0.033080608,0.053720124,-0.017335678,0.031025013,-0.0030505194,0.0118484115,0.01942682,0.015813364,0.025427671,-0.019603554,-0.005729193,-0.019339262,0.0023200847,-0.010942891,-0.015906375,0.0137701705,0.018283498,-0.039609145,-0.03927833,-0.023527505,-0.014235107,-0.0071569704,0.027706102,0.052479897,-0.02584655,-0.02182109,0.00202128,0.013596946,0.013306086,0.021465844,0.015451294,0.013571037,0.012339855,-0.0042612418,0.019804275,0.01654927,0.022644402,-0.0425335,0.04003829,-0.029597128,-0.016517522,-0.0051322537,0.03447015,0.04402375,0.016084617,0.05915613,0.016856514,-0.012567566,-0.020422146,-0.0010002282,-0.06403749,0.044658992,0.006742614,-0.007377261,0.021048864,0.005221461,0.017022615,-0.019236036,0.004700408,-0.010880724,0.011573048,0.014251987,0.018260008,0.0075767934,-0.021159519,-0.029665403,-0.058950886,-0.004062837,0.0049890797,0.06761405,0.0093499785,-0.035546653,0.015509572,-0.014346488,0.0056138416,-0.01571817,-0.012651379,0.03733326,-0.0086580515,0.029490683,0.0034969172,0.0012383345,-0.017750962,-0.0010434631,0.007996708,0.0058566476,0.02304354,-0.008673078,0.035118934,-0.034823254,0.007898915,-0.041607413,0.009481183,-0.046473257,0.0006418507,-0.037385628,0.007803557,0.008954395,-0.005074,-0.02475046,-0.037246425,0.021475917,0.00973188,-0.001536256,0.038163587,-0.0060893665,-0.008652756,-0.017917348,0.020824531,-0.050191958,0.009884899,-0.022729715,0.0047298544,-0.020664092,0.015859164,0.045636345,0.0061753094,-0.022267222,-0.0012819852,-0.044325266,-0.02417535,-0.053090174,-0.015787587,0.048514333,0.025904026,0.001300381,-0.016307551,-0.009108233,0.05179762,-0.026403535,0.00023842909,0.026371555,0.003409635,0.05277127,-0.020370685,-0.008460597,-0.00055171596,-0.08852316,0.0068636574,-0.030699987,0.003731387,0.039691508,-0.026737474,-0.007339512,0.011546573,-0.032982443,-0.01533761,0.020715354,-0.023805052,0.010466252,-0.0038776193,0.0068669817,0.035698935,0.012376011,0.025016673,0.0012787066,-0.03037093,0.04135283,0.0075959982,0.03461094,-0.014360237,-0.024929417,-0.0327288,-0.05035393,0.010202957,-0.024281658,0.017212847,-0.009618058,0.00979196,0.035911027,-0.021207534,0.02756773,-0.042744957,0.0046483865,-0.006877151,0.0040343395,0.0024046274,0.027896877,-0.044800237,-0.0024519546,-0.0061139036,-0.014448728,-0.003603364,0.031822845,-0.01593682,0.011751977,0.031068072,-0.005767515,0.016709993,0.011132804,0.014914381,-0.0009570819,-0.03476265,-0.016935615,0.0022691048,0.028296053,0.034049485,-0.021009728,-0.010217656,-0.050544076,-0.046273913,-0.014869661,-0.0075688367,0.06788927,-0.015122638,0.009296849,0.04599087,-0.017891293,0.011398189,0.026587479,-0.040081594,-0.03252516,-0.0131338425,0.04164534,0.024855288,-0.037781756,-0.015401744,-0.013433508,0.0044496064,0.020572932,-0.029054875,0.010755067,0.048820045,-0.036305677,0.008642715,-0.0063961837,-0.0068240557,0.014073416,-0.01996488,-0.0126656005,-0.0013400211,-0.030390462,0.033767954,0.039164994,-0.02094916,-0.0040821196,-0.051913135,0.013118044,-0.019401615,-0.009236374,-0.033550765,0.017055715,0.0022235336,0.00020257174,0.03377671,0.019882794,-0.006980404,0.012097077,0.0002656063,-0.02408134,-0.015193587,0.0583059,-0.0005350396,0.016448231,-0.03425899,0.008700231,0.00031232,-0.010836053,0.03206401,-0.034406032,0.058644816,-0.016000975,0.0108475005,-0.011234792,0.033283472,-0.038010973,-0.03551329,0.011672016,0.01394091,0.008670356,0.021996675,0.009712132,0.009134889,0.000039399103,-0.0057939244,-0.028064776,0.0161988,0.028209452,-0.014303122,0.017101422,0.016853658,0.002818423,-0.054766644,0.011748632,-0.00512247,0.0051635136,0.04802365,-0.0022123805,-0.041541878,0.010055207,-0.015492294,0.00019113539,-0.0058086677,0.008697962,-0.0377177,0.0075450586,0.013192409,-0.017173212,0.028702047,0.024494488,-0.0270705,0.011482562,-0.00917446,0.03794346,-0.00018115035,-0.016542995,-0.0127310045,0.022151204,0.07042937,0.04329336,0.032320086,-0.037820823,-0.014728389,0.016871313,0.028143005,-0.024961226,0.01373961,-0.020569857,0.039617293,-0.019885069,0.032954063,-0.01877093,-0.026268963,-0.022804154,0.017449228,0.031890966],"index":0}],"model":"snowflake-arctic-embed2:568m","usage":{"prompt_tokens":9,"total_tokens":9}}
Evidence: Embedding model and 1024-dimension summary
{
  "object": "list",
  "model": "snowflake-arctic-embed2:568m",
  "dimensions": 1024,
  "embedding_prefix": [
    -0.00043697056,
    0.048999522,
    0.029834952,
    -0.08814191,
    -0.03728249,
    -0.0235623,
    0.0043571186,
    0.035195842
  ],
  "usage": {
    "prompt_tokens": 9,
    "total_tokens": 9
  }
}
Evidence: Service, network, GPU, hashes, and crash-recovery evidence
Restart=on-failure
RestartUSec=5s
MainPID=2013311
NRestarts=1
ExecMainStartTimestamp=Tue 2026-08-04 04:33:56 UTC
Environment=OLLAMA_HOST=127.0.0.1:11434 OLLAMA_MODELS=/home/sungin/.local/gbrain-endpoints/ollama-models CUDA_VISIBLE_DEVICES=0
StandardOutput=journal
StandardError=journal
LogRateLimitIntervalUSec=30s
LogRateLimitBurst=50
ActiveState=active
SubState=running
UnitFileState=enabled
State=active
Linger=yes
LISTEN 0      4096   127.0.0.1:11434 0.0.0.0:* users:(("ollama",pid=2013311,fd=3))
0, GPU-d8875f51-293f-a66f-71c2-b6da16c568d0, NVIDIA GeForce RTX 5060 Ti, 570.207, 12.0
1, GPU-7ef74f00-ba0f-c5e9-2235-a8e7b2ca930e, NVIDIA GeForce RTX 5060 Ti, 570.207, 12.0
2, GPU-2968e422-1ad9-b179-bf5e-f14cec72783e, NVIDIA GeForce RTX 5060 Ti, 570.207, 12.0
3, GPU-76dd6bb9-d452-6ebf-4b91-53d24818cb17, NVIDIA GeForce RTX 5060 Ti, 570.207, 12.0
GPU-d8875f51-293f-a66f-71c2-b6da16c568d0, 148191, /home/sungin/.local/gbrain-endpoints/ollama/lib/ollama/llama-server, 776 MiB
f7d6bdbcf71b83aa8670c4e7dc4b6936c0952fcf8b114eaf6a11cbadb9684214  /home/sungin/.local/gbrain-endpoints/downloads/ollama-linux-amd64.tar.zst
5de93a84837d0ff00da872e90830df5d973f616cbf1e5c198731ab19dd7b776b  /home/sungin/.local/gbrain-endpoints/ollama-models/manifests/registry.ollama.ai/library/snowflake-arctic-embed2/568m
8c625c9569c3c799f5f9595b5a141f91d224233055608189d66746347c14e613  /home/sungin/.local/gbrain-endpoints/ollama-models/blobs/sha256-8c625c9569c3c799f5f9595b5a141f91d224233055608189d66746347c14e613
2026-08-04T04:33:46+00:00 research systemd[1153]: Stopping gbrain-embedding.service - Local GBrain embedding endpoint (Ollama)...
2026-08-04T04:33:47+00:00 research systemd[1153]: Stopped gbrain-embedding.service - Local GBrain embedding endpoint (Ollama).
2026-08-04T04:33:51+00:00 research systemd[1153]: Started gbrain-embedding.service - Local GBrain embedding endpoint (Ollama).
2026-08-04T04:33:51+00:00 research systemd[1153]: gbrain-embedding.service: Sent signal SIGKILL to main process 1975522 (ollama) on client request.
2026-08-04T04:33:51+00:00 research systemd[1153]: gbrain-embedding.service: Main process exited, code=killed, status=9/KILL
2026-08-04T04:33:51+00:00 research systemd[1153]: gbrain-embedding.service: Failed with result 'signal'.
2026-08-04T04:33:56+00:00 research systemd[1153]: gbrain-embedding.service: Scheduled restart job, restart counter is at 1.
2026-08-04T04:34:00+00:00 research systemd[1153]: Started gbrain-embedding.service - Local GBrain embedding endpoint (Ollama).
Evidence: Focused end-to-end verifier transcript

PASS: model=snowflake-arctic-embed2:568m dimensions=1024 endpoint=http://127.0.0.1:11434/v1/embeddings
PASS: enabled user service, linger=yes, loopback-only listener, bounded journal, restart-on-failure PASS: pinned GPU and all runtime/model hashes matched PASS: recorded SIGKILL recovery reached restart counter 1 and returned active

PASS: model=snowflake-arctic-embed2:568m dimensions=1024 endpoint=http://127.0.0.1:11434/v1/embeddings
PASS: enabled user service, linger=yes, loopback-only listener, bounded journal, restart-on-failure
PASS: gpu=GPU-d8875f51-293f-a66f-71c2-b6da16c568d0 archive=f7d6bdbcf71b83aa8670c4e7dc4b6936c0952fcf8b114eaf6a11cbadb9684214 manifest=5de93a84837d0ff00da872e90830df5d973f616cbf1e5c198731ab19dd7b776b blob=8c625c9569c3c799f5f9595b5a141f91d224233055608189d66746347c14e613
PASS: recorded SIGKILL recovery reached restart counter 1 and returned active
Evidence: Reproducible focused verifier
#!/usr/bin/env bash
set -euo pipefail

readonly root=${1:?repository root required}
readonly evidence=${2:?evidence directory required}
readonly endpoint=http://127.0.0.1:11434/v1/embeddings
readonly model=snowflake-arctic-embed2:568m
readonly gpu_uuid=GPU-d8875f51-293f-a66f-71c2-b6da16c568d0

fail() {
  printf 'FAIL: %s\n' "$*" >&2
  exit 1
}

systemd-analyze --user verify "$root/deploy/gbrain-endpoints/gbrain-embedding.service"
bash "$root/deploy/gbrain-endpoints/check-embedding.sh"

curl --fail --silent --show-error --max-time 120 \
  --header 'Content-Type: application/json' \
  --data "{\"model\":\"$model\",\"input\":\"GBrain endpoint probe.\"}" \
  --output "$evidence/openai-embedding-response.json" \
  "$endpoint"

jq -e --arg model "$model" \
  '.object == "list" and .model == $model and (.data[0].embedding | length) == 1024' \
  "$evidence/openai-embedding-response.json" >/dev/null \
  || fail 'OpenAI-compatible response did not contain the pinned model and 1024-value vector'

service_state=$(systemctl --user show gbrain-embedding.service \
  --property=ActiveState,SubState,UnitFileState,NRestarts,Restart,RestartUSec,Environment,StandardOutput,StandardError,LogRateLimitIntervalUSec,LogRateLimitBurst)
for required in \
  'ActiveState=active' \
  'SubState=running' \
  'UnitFileState=enabled' \
  'Restart=on-failure' \
  'RestartUSec=5s' \
  'StandardOutput=journal' \
  'StandardError=journal' \
  'LogRateLimitIntervalUSec=30s' \
  'LogRateLimitBurst=50'; do
  grep -Fxq "$required" <<<"$service_state" || fail "missing service property: $required"
done
grep -Fq 'CUDA_VISIBLE_DEVICES=0' <<<"$service_state" \
  || grep -Fq "CUDA_VISIBLE_DEVICES=$gpu_uuid" <<<"$service_state" \
  || fail 'live service does not pin an explicit CUDA device'

[ "$(loginctl show-user sungin -p Linger --value)" = yes ] \
  || fail 'user lingering is not enabled'

listener=$(ss -H -ltnp 'sport = :11434')
grep -Fq '127.0.0.1:11434' <<<"$listener" || fail 'embedding endpoint is not bound on IPv4 loopback'
grep -Fq '0.0.0.0:11434' <<<"$listener" && fail 'embedding endpoint is wildcard-bound'

gpu_processes=$(nvidia-smi --query-compute-apps=gpu_uuid,process_name --format=csv,noheader)
grep -F "$gpu_uuid" <<<"$gpu_processes" | grep -Fq '/gbrain-endpoints/ollama/' \
  || fail 'embedding runner is not visible on the pinned GPU UUID'

archive_hash=$(sha256sum /home/sungin/.local/gbrain-endpoints/downloads/ollama-linux-amd64.tar.zst | awk '{print $1}')
manifest_hash=$(sha256sum /home/sungin/.local/gbrain-endpoints/ollama-models/manifests/registry.ollama.ai/library/snowflake-arctic-embed2/568m | awk '{print $1}')
blob_hash=$(sha256sum /home/sungin/.local/gbrain-endpoints/ollama-models/blobs/sha256-8c625c9569c3c799f5f9595b5a141f91d224233055608189d66746347c14e613 | awk '{print $1}')
[ "$archive_hash" = f7d6bdbcf71b83aa8670c4e7dc4b6936c0952fcf8b114eaf6a11cbadb9684214 ] || fail 'Ollama archive hash drifted'
[ "$manifest_hash" = 5de93a84837d0ff00da872e90830df5d973f616cbf1e5c198731ab19dd7b776b ] || fail 'Ollama model manifest hash drifted'
[ "$blob_hash" = 8c625c9569c3c799f5f9595b5a141f91d224233055608189d66746347c14e613 ] || fail 'GGUF blob hash drifted'

recovery_log=$(journalctl --user-unit gbrain-embedding.service \
  --since '2026-08-04 04:30:00 UTC' --until '2026-08-04 04:36:00 UTC' --no-pager)
grep -Fq 'Main process exited, code=killed, status=9/KILL' <<<"$recovery_log" \
  || fail 'missing deliberate process-crash evidence'
grep -Fq 'Scheduled restart job, restart counter is at 1' <<<"$recovery_log" \
  || fail 'missing automatic crash-restart evidence'
grep -Fq 'Started gbrain-embedding.service' <<<"$recovery_log" \
  || fail 'missing recovered service start evidence'

printf 'PASS: model=%s dimensions=1024 endpoint=%s\n' "$model" "$endpoint"
printf 'PASS: enabled user service, linger=yes, loopback-only listener, bounded journal, restart-on-failure\n'
printf 'PASS: gpu=%s archive=%s manifest=%s blob=%s\n' "$gpu_uuid" "$archive_hash" "$manifest_hash" "$blob_hash"
printf 'PASS: recorded SIGKILL recovery reached restart counter 1 and returned active\n'

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

⏭️ **Rebase** - skipped
  • ⚠️ .agents/skills/afk/SKILL.md - branch carries 58 commit(s) that exist on your local main branch but were never pushed to origin/main; rebasing would bundle this unrelated work (69 file(s)) into the PR:
  • 149c812 Merge pull request feat: add authoritative review diff helper #17 from HelloWorldSungin/fm/fm-fork-upstream-reconcile
  • 07a281f Conform the cursor/agy adapter test to upstream's tightened contracts
  • cc840d8 Complete two test fixtures for the merged tree
  • e4a3787 Restore teardown functions dropped by my merge resolution
  • 20b879f Keep one window_harness definition after the upstream merge
  • 26a9bff Merge fm/fm-endpoint-binding-migration (upstream PR 1492)
  • 5cd2fc8 Merge fm/fm-pi-auth-surface-unresolved (upstream PR 1491)
  • e45fb62 Merge fm/fm-test-run-comm-sort-exit (upstream PR 1490)
  • 5777773 Merge fm/fm-watcher-term-hup-latency
  • b8c5c34 Merge fm/firstmate-watcher-lock-flake
  • 3d5d952 Merge fm/fm-brief-status-protocol-gaps
  • de00adc Merge fm/fm-pi-afk-dual-supervision
  • b7a413a Merge fm/fm-session-start-e2e-failure (upstream PR 1476)
  • 7a18213 Merge fm/fm-bearings-snapshot-arg-too-long (upstream PR 1442)
  • f1a8979 Merge fm/fm-issue-lifecycle-wiring (upstream PR 1271)
  • 05058ac Merge upstream/main into the fork, preserving the cursor/agy adapters
  • a473c4e no-mistakes(document): Clarify coverage-guard collation documentation
  • e9eefb3 fix(tests): run coverage-guard set operations under the C collation
  • 890bd37 no-mistakes(document): Document endpoint-binding migration behavior
  • e174818 no-mistakes(review): Refuse concurrent endpoint metadata rewrites
  • 0246f94 revert: drop the test-runner locale fix from this branch
  • c1b74c6 fix(bin): migrate legacy non-tmux endpoint records so they stay cleanable
  • 9018941 no-mistakes: apply CI fixes
  • ca99120 fix(snapshot): stop passing fleet-sized JSON to jq through argv
  • fd39d53 no-mistakes: apply CI fixes
  • 1ea1c2d no-mistakes(document): Clarify brief status-protocol header scope
  • c93ab0b fix(brief): close three status-reporting gaps in the crewmate scaffold
  • 2aca111 no-mistakes(document): Clarify catalog-backed authentication evidence
  • 343bb9f fix(dispatch): resolve pi surfaces from the harness catalog
  • c50b2ce no-mistakes(document): docs: correct interruptible poll-path description
  • c46e3b1 fix(tests): wait for the TERM-resistant peer before restarting the watcher
  • dc107ba fix(watch): honor TERM and HUP without waiting out the poll interval
  • 3db0341 fix(tests): wait for the TERM-resistant peer before restarting the watcher
  • 6c60252 no-mistakes(document): Document Pi away-mode supervision handoff
  • d7c1660 fix(pi): hand supervision to the away daemon while away mode is active
  • 38951b1 test(session-start): make the MISSING-tool fixture independent of the host PATH
  • c6ba037 no-mistakes(lint): Suppress literal backtick fixture ShellCheck warning
  • 433b66e no-mistakes(document): Document GitHub issue delivery lifecycle
  • 19f6c91 no-mistakes(review): Add exact no-issue brief golden coverage
  • 8a97167 Stabilize locale and Calm regression checks
  • 7b32a51 Wire GitHub issues into task delivery
  • d50dcca Merge pull request chore: initialize no-mistakes gate #1 from HelloWorldSungin/fm/cursor-agy-build
  • 640fd60 no-mistakes(document): Align cursor and agy documentation ownership
  • 41b71b6 no-mistakes(review): Gate credentialed smoke outside portable tests
  • f446c89 no-mistakes(review): Re-arm native completion and clean smoke trust
  • 46680c5 test: conform the cursor/agy tests to main's tightened contracts
  • 912dad5 Merge origin/main into fm/cursor-agy-build
  • 2d0c4c2 no-mistakes(document): Document restricted cursor and agy harness adapters
  • 6159bad no-mistakes(test): Guard launch rendering against unresolved placeholders
  • 52f816e no-mistakes(review): Fix native identity and trust teardown ordering
  • 2df62e3 Merge origin/main into fm/cursor-agy-build (overlay, per captain Option A)
  • ae5aab2 fix(harness): harden B1 with an exec-time PATH guard for raw cursor/agy launches
  • 7b60904 test: green the 3 environment-sensitive full-suite failures
  • 65b2dd4 fix(harness): close B1 variable-indirection bypass + fix 2 regressed tests
  • 4571ab1 fix(harness): close re-review B1/B3 + add S2 bootstrap backend warning
  • 553a862 test(harness): mark new cursor/agy test scripts executable (review N1)
  • 7e2cfa0 fix(harness): close the 4 cursor/agy review blockers (B1-B4) + failure-path tests
  • 6237eb9 feat(harness): add cursor + agy as crew-only, herdr-only adapters

Push main to origin, or rebase your branch onto origin/main, before gating.

🔧 **Review** - 5 issues found → auto-fixed (2) ✅
  • 🚨 deploy/gbrain-endpoints/gbrain-embedding.service:3 - The required "boot-persistent embedding endpoint" is not guaranteed. Enabling this unit under default.target makes the target order itself after the service, while this directive orders the service after the target, creating a boot-time ordering cycle. enable --now and restart testing miss this because the target is already active. Remove After=default.target so the enabled target can start the service reliably.
  • 🚨 docs/gbrain-endpoints.md:25 - The required "exact GBrain fix: reduce crewmate status wake noise #6 configuration" is absent: this is only a pair of bare flags, not an executable init/reinit command, and it does not bind GBrain to the documented IPv4 endpoint. GBrain also refuses direct embedding model/dimension configuration for existing brains. Record the complete PGLite init or reinit command with OLLAMA_BASE_URL=http://127.0.0.1:11434/v1; see the official provider guidance.
  • 🚨 deploy/gbrain-endpoints/check-embedding.sh:9 - The documented crash sequence invokes this check immediately after killing the main process, but five connection-refused attempts one second apart expire before the service's five-second RestartSec delay completes. The probe can therefore fail before recovery begins, or briefly hit the dying process. Extend the retry deadline beyond the restart delay plus startup time so it actually verifies the replacement process.
  • ⚠️ deploy/gbrain-endpoints/gbrain-embedding.service:15 - StartLimitBurst= is a [Unit] directive, so systemd ignores it in [Service] and falls back to the user manager's default. Move it alongside StartLimitIntervalSec= to make the stated restart bound effective.
  • ⚠️ deploy/gbrain-endpoints/gbrain-embedding.service:10 - Ordinal 0 relies on GPU enumeration and does not durably identify the GPU whose UUID the evidence records. On this four-identical-GPU boot-persistent deployment, an ordering change can move the service to another card. Pin CUDA_VISIBLE_DEVICES to GPU-d8875f51-293f-a66f-71c2-b6da16c568d0, which NVIDIA explicitly supports for stable identity in its CUDA environment documentation.

🔧 Fix: Fix GBrain endpoint persistence and configuration, captain
1 error still open:

  • 🚨 docs/gbrain-endpoints.md:28 - The required "exact GBrain fix: reduce crewmate status wake noise #6 configuration" remains incomplete. Both added commands scope OLLAMA_BASE_URL to only the init/reinit process, while GBrain deliberately excludes transient environment state from its saved config. A later import, embed, or search therefore falls back to http://localhost:11434/v1 and can miss this IPv4-only listener. After each init path, persist provider_base_urls.ollama with gbrain config set provider_base_urls.ollama http://127.0.0.1:11434/v1, or document an equivalent durable export. This is confirmed by GBrain's config loading contract.

🔧 Fix: Captain, document GBrain endpoint environment requirements
✅ Re-checked - no issues remain.

✅ **Test** - passed

✅ No issues found.

  • Inspected git diff 3d9d12db7412e5da0751745c14603e7e427f8877..5e2ab881dae9329f3a5abde9c949375257ad8f99 and the endpoint handoff files against the supplied intent.
  • Ran systemd-analyze --user verify deploy/gbrain-endpoints/gbrain-embedding.service, bash -n deploy/gbrain-endpoints/check-embedding.sh, and checked tracked file modes.
  • Ran bash .tmp-gbrain-embedding-e2e.test.sh &#34;$PWD&#34; /tmp/no-mistakes-evidence/01KZ5GY7TS4P8WRCZGA509457X before removing the temporary worktree copy.
  • Executed the documented curl --fail --silent --show-error http://127.0.0.1:11434/v1/embeddings ... probe and validated the model and 1024-value vector with jq.
  • Ran bash deploy/gbrain-endpoints/check-embedding.sh.
  • Inspected systemctl --user show gbrain-embedding.service, loginctl show-user sungin, ss -ltnp &#39;sport = :11434&#39;, and nvidia-smi for persistence, loopback scope, restart/log policy, four-GPU inventory, and GPU placement.
  • Ran sha256sum against the Ollama v0.32.5 archive, model manifest, and GGUF blob.
  • Inspected journalctl --user-unit gbrain-embedding.service for the deliberate SIGKILL, PID replacement, scheduled restart, and recovered active service.
  • Checked the target diff for reranker or CUDA-build paths and confirmed none were added.
⚠️ **Document** - 1 error
  • 🚨 docs/verification/gbrain-embedding.md:9 - Captain, recovery and GPU evidence covers the installed index-pinned unit, not the UUID-pinned handoff. Deploy the tracked unit and repeat health, restart, crash-recovery, GPU, and listener checks before acceptance.
✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

Sungin Kim and others added 30 commits July 23, 2026 03:59
Add cursor-agent (Composer) and agy (Antigravity/Gemini) as CREW-ONLY,
HERDR-ONLY crewmate harnesses (captain-approved divergence; design in
data/captain.md, empirical verification in data/cursor-agy-verify/report.md).
They are never a primary runtime and never a secondmate launcher, and fm-spawn
fail-closes both gates before any backend or worktree work.

Launch construction moves into bin/fm-launch-lib.sh (extracted verbatim from
fm-spawn, protected by the existing fm-spawn-dispatch-profile regression) so the
per-harness template and model/effort renderers are unit-testable:
- cursor: `cursor-agent --trust --force <model> "$(cat brief)"`; effort is
  encoded in the parameterized model string (composer-2.5[effort=high]), so
  there is no standalone effort flag.
- agy: `agy --dangerously-skip-permissions <model> --effort <low|medium|high>
  --prompt-interactive "$(cat brief)"`.

agy workspace trust: an interactive agy launch gates on a per-workspace trust
modal that --dangerously-skip-permissions does not cover, and trust is an
exact-path entry in agy's shared global settings. bin/fm-agy-trust-lib.sh seeds
the exact worktree path before launch (fm-spawn, fail-closed) and removes it at
teardown (fm-teardown, main and secondmate-child paths); it is locked, atomic,
idempotent, and leaves an unparseable settings file untouched.

On herdr, agent-state, liveness, turn-end, and send-safety are all generic
(native `agent get` + the pane.agent_status_changed event stream), so no adapter
code and no turn-end hook are added, and no repo .cursor/hooks.json /
.agents/hooks.json is ever written. Composer stays `unknown` (the safe default);
no generic bare-glyph rule is added (agy's `>` glyph would be a dead-shell send
hazard). tmux is documented out-of-scope.

cursor/agy are added to the verified-adapter set in fm-bootstrap and
fm-dispatch-select (agy effort low|medium|high; cursor no standalone effort);
both are intentionally unscorable in quota-balanced selection (paid subs not
tracked by quota-axi) and fall through to the uniform random fallback.

Docs: harness-adapters SKILL and AGENTS.md section 4.

Tests: colocated unit tests for the launch lib and trust lib; contract tests for
the crew-only/herdr-only refusals and teardown trust cleanup; extended
dispatch-select/bootstrap validation; and a skip-guarded live herdr-lab smoke
that launches both CLIs through the real templates and confirms native
detection. Full suite green; shellcheck 0.11.0 clean.
…e-path tests

Address the independent adversarial review (data/cursor-agy-review/report.md):

B1 - raw launch-command bypass: the raw escape hatch derived the harness from the
first non-assignment word's basename (`cursor-agent`/`env`), so the cursor/agy
crew-only/herdr-only guard (keyed on the exact tokens `cursor`/`agy`) missed it.
Add fm_launch_raw_restricted_harness (resolves the real executable through `env`
and leading VAR=val assignments, with an all-words backstop) and refuse any raw
command that resolves to cursor-agent/agy outright - the raw path cannot provide
the trust seed or native supervision they require, so callers use --harness.

B2 - turn-end wake: the shared transition policy deliberately DEFERS herdr
idle/done, and cursor/agy install no hook and write no status file, so a
completed turn only ever surfaced via the unreliable content-hash stale
heuristic. Add a native-identity-gated, DEBOUNCED completion detector:
fm_transition_native_completion (pure, in fm-transition-lib.sh) plus
fm-watch.sh's maybe_native_turnend, which reads the pane's native agent_status
and touches state/<id>.turn-ended once a cursor/agy pane settles at idle/done
across two consecutive polls - the same completion signal every other harness's
hook writes, handled by the existing scan/wake path with no change to the shared
policy or event stream. Adds fm_backend_agent_status (raw enum accessor).

B3 - agy trust is now ownership-aware and transactional: fm_agy_trust_add reports
created vs preexisting so firstmate removes ONLY an entry it created and never
deletes a path the captain already trusted; the durable marker state/<id>.agy-trust
drives ownership-aware teardown; the spawn abort trap rolls back a created entry;
and teardown removal failure is an INCOMPLETE teardown that retains the marker +
metadata for a deterministic retry (same contract on the secondmate-child path).

B4 - the age-only 10s stale-lock breaker could steal a LIVE lock; replace it with
the repository's ownership-and-liveness lock (fm_lock_*), which never reclaims a
lock whose holder PID is alive and only lets the owner release.

S1 - add the missing failure-path tests: raw-command bypass variants (direct,
env, assignment-prefixed) on forbidden dimensions; created-vs-preexisting
ownership; parallel mutation; a live-lock-held-past-10s theft test; spawn-abort
rollback and teardown-incomplete-on-failure; and the live smoke now observes a
working->idle/done transition and PROVES a native completion wake for both CLIs.

Docs updated (harness-adapters skill, fm-launch-lib/fm-spawn comments) to describe
the debounced native completion detector instead of the earlier inaccurate
"native event stream drives turn-end" claim. Full suite green; shellcheck 0.11.0
clean. Pre-existing flake noted: tests/fm-watcher-lock.test.sh (unrelated beacon
timing; reproduces identically on the pre-change fm-watch.sh).
Match the repo convention (nearly all tests/*.test.sh are mode 0755) so direct
./tests/<name>.test.sh invocation works, not only via the bash runner.
Address the adversarial re-review (data/cursor-agy-rereview/report.md):

B1 (still-open shell-wrapper bypass) - a quoted wrapper like `bash -lc 'agy ...'`
or `sh -c "cursor-agent ..."` split into tokens `'agy` / `"cursor-agent`, so the
raw-guard's basename scan missed it and fm-spawn recorded harness=bash on tmux,
bypassing the crew-only/herdr-only gates. fm_launch_raw_restricted_harness now
adds a fail-closed backstop that neutralizes shell quote characters and command
separators before scanning every token's basename, so a wrapped cursor-agent/agy
invocation is caught and refused. Over-approximates safely (the raw hatch is for
unverified adapters; cursor/agy have a canonical --harness path).

B3 (still-open rollback leaks) - two fixes:
  1. AGY_TRUST_ROLLBACK_PATH is now armed BEFORE the fallible ownership-marker
     write, so a marker-write failure after the global trust entry was created
     still leaves the abort trap armed to roll it back.
  2. The rollback is factored into fm_agy_trust_rollback: on removal success it
     drops the marker; on removal FAILURE it (re)writes the marker with the
     leaked path as retry evidence - even when the marker was never written -
     instead of deleting it. The abort trap calls this tested function.

S2 - fm-bootstrap now emits `CREW_DISPATCH: backend mismatch - ...` when a valid
dispatch profile selects the crew-only herdr-only cursor/agy harness while the
resolved backend is not herdr, instead of deferring the surprise to spawn-time
refusal. bootstrap-diagnostics skill + AGENTS.md section 13 recognize the new
line.

Tests (would fail if unfixed): shell-wrapper bypass at both the resolver unit
level and through fm-spawn refusal; rollback clean-removal, rollback-removal
failure preserving marker evidence, and rollback failure recreating an absent
marker (the marker-write-failure evidence path); bootstrap backend-mismatch
warning on tmux and silence on herdr.

Full suite green; bin/fm-lint.sh (ShellCheck 0.11.0) exit 0. Not pushed.
Note: the end-to-end fm-spawn abort path reaches the agy seed only through a real
herdr spawn (no clean deterministic failure-injection seam), so the abort-trap
logic is covered by the fm_agy_trust_rollback unit tests that exercise the exact
function the trap runs.
…tests

B1 (variable-indirection raw shell wrappers, second re-review) - a raw command is
executed by the crewmate PANE's shell, so `AGY=agy bash -lc '$AGY ...'`,
`bash -lc 'x=agy; eval "$x ..."'`, backticks, `$(...)`, and split-token
concatenation (`$a$g`) can all expand to a restricted executable that a basename
scan cannot see. fm_launch_raw_restricted_harness now returns `unresolved` for any
raw command containing shell expansion ($ or backtick), and fm-spawn refuses it:
the command cannot be statically proven not to launch cursor/agy. Over-approximates
safely (the raw hatch is for unverified adapters; cursor/agy have a canonical
--harness path). Literal and env/assignment forms still resolve to cursor/agy.

Regressed-test fixes (full-suite failures caused by earlier commits in this
branch):
- tests/fm-gotmp.test.sh: teardown now sources bin/fm-agy-trust-lib.sh (which
  pulls in bin/fm-wake-lib.sh for its ownership lock); the fake teardown bin did
  not symlink them, so the source aborted teardown. Symlink both as newly required
  siblings, and make fm-agy-trust-lib's on-demand fm-wake-lib source tolerate an
  absent file (the lock is only exercised for agy tasks, whose real environment
  always has it).
- tests/fm-pi-watch-extension.test.sh: the pi secondmate launch TEMPLATE moved
  into bin/fm-launch-lib.sh during the launch-template extraction, so the test's
  grep of bin/fm-spawn.sh missed it; read both files (the placeholder substitution
  and tracked-extension path stay in fm-spawn.sh).

Tests: variable-indirection bypass rows at the resolver unit level and through the
fm-spawn refusal path. bin/fm-lint.sh (ShellCheck 0.11.0) clean. Not pushed.
These are pre-existing, environment-specific failures surfaced by running the full
suite in an en_US.UTF-8 host with Pi 0.81.1 and node in /usr/bin. None is caused by
the cursor/agy work; each is fixed at its true root cause, not masked.

- bin/fm-test-run.sh: the coverage guard sorts its lane/family lists with
  `LC_ALL=C sort` but ran `comm` in the ambient locale, so in en_US.UTF-8 comm
  rejected the C-collated input ("not in sorted order") and returned non-zero.
  Run every comm under LC_ALL=C to match its sort. (The cursor/agy test filenames
  happened to expose this latent locale inconsistency.)

- tests/fm-calm-pi-extension.test.sh: hard-pinned Pi 0.80.10; the host has 0.81.1.
  Empirically re-verified 2026-07-23 - the renderer and interactive-E2E assertions
  pass green against @earendil-works/pi-coding-agent 0.81.1 - so the pin now accepts
  0.80.10 or 0.81.1 (evidence-based, still fails loudly on an unverified version).

- tests/fm-session-start.test.sh: forced a MISSING diagnostic by removing `node`
  from its fake bin, but node commonly leaks from $BASE_PATH (/usr/bin), masking
  the forced-missing condition. Force-miss `no-mistakes` instead - a firstmate tool
  never on a standard system PATH - so the diagnostic reliably appears.

bin/fm-lint.sh (ShellCheck 0.11.0) clean.
…gy launches

The captain accepted the no-go: string-scanning a raw launch command can never be
complete against a Turing-complete pane shell (quote concatenation `ag"y"`, brace
`a{gy,}`, alias expansion, generated process substitution, and a wrapper script
that internally execs the binary all defeat a static scan). Move the primary B1
defense to EXEC-TIME interception.

- bin/fm-launch-lib.sh: fm_launch_write_raw_guard writes firstmate-owned refusing
  `cursor-agent`/`cursor`/`agy` shims (exit non-zero) into a guard dir.
- bin/fm-spawn.sh: for a raw launch command, install that guard under
  TASK_TMP/raw-guard and prepend it to the pane PATH before the command runs, so
  ANY spelling that resolves one of those binaries through PATH hits the shim
  instead of the real CLI - uniformly closing quote-concat, brace, alias,
  process-substitution, AND the wrapper-script boundary. Teardown's `rm -rf
  TASK_TMP` cleans it. The sanctioned `--harness` path never routes through the
  guard and reaches the real binary directly.
- The fm_launch_raw_restricted_harness string classifier stays as early,
  spawn-time defense-in-depth (clear pre-launch refusal), not the sole gate.

Documented residual (a PATH shim cannot cover): an absolute-path invocation or a
raw command that first resets PATH bypasses the guard; both are deliberate
circumventions, and closing them needs execve-level interception (LD_PRELOAD/
seccomp) disproportionate to the raw hatch.

Tests: tests/fm-launch-lib.test.sh runs every demonstrated bypass class
(quote-concat agy/cursor, eval+quote-concat, brace, process-substitution, alias,
wrapper-via-PATH) with a fake real binary behind the guard and asserts the real
binary never executes; tests/fm-cursor-agy-adapter.test.sh drives a real raw spawn
and asserts the guard is installed and prepended to the pane PATH. harness-adapters
skill documents the exec-time gate and the residual. shellcheck 0.11.0 clean.
…on A)

Captain chose Option A: MERGE origin/main into the cursor/agy overlay branch
(NOT rebase), preserving the overlay for fast-forward-to-homes landing.

origin/main advanced 4 commits (kunchenguid#895 Calm rendering, kunchenguid#898/kunchenguid#899 operational
markers, kunchenguid#909 canonical operational-input classification). The load-bearing
conflict is kunchenguid#909, which threaded a __OPINPUT__ operational-input encoder and a
__PIBRIEFENV__ Pi env assignment INTO launch_template() in fm-spawn.sh - the exact
function this branch EXTRACTED into bin/fm-launch-lib.sh. Resolution:

- bin/fm-launch-lib.sh (fm_launch_template): threaded kunchenguid#909's
  `"$(__OPINPUT__ encode launch-brief < __BRIEF__)"` into every template (claude,
  codex, opencode, pi, grok, and the new cursor/agy - consistent cross-harness
  operational-input canonicalization) and the `__PIBRIEFENV__` prefix onto the pi
  templates; kept the extraction.
- bin/fm-spawn.sh: kept the extraction (launch_template lives in the lib) and the
  cursor/agy raw-guard/agy-trust/guards; added kunchenguid#909's sq_opinput + PIBRIEFENV
  substitutions using this branch's fm_launch_* helper names.
- tests/fm-calm-pi-extension.test.sh: took origin/main - kunchenguid#895 already re-verified
  Calm on Pi 0.81.1 and pinned it there, superseding this branch's interim
  0.80.10|0.81.1 workaround.
- tests/fm-launch-lib.test.sh: updated the exact-template assertions to the
  kunchenguid#909 __OPINPUT__/__PIBRIEFENV__ form.
- AGENTS.md, harness-adapters SKILL, bin/fm-test-run.sh, fm-pi-watch test:
  auto-merged, both sides preserved (verified).

Merge-affected tests green: fm-operational-input, fm-spawn-dispatch-profile,
fm-pi-watch-extension, fm-cursor-agy-adapter, fm-launch-lib, fm-calm-pi-extension,
fm-transition-lib, fm-agy-trust-lib. shellcheck 0.11.0 clean.
Reconcile the crew-only cursor/agy overlay with seven upstream commits
(a7e01bc..6b0d21d). Merge, never rebase: the overlay must stay
fast-forwardable into detached secondmate homes.

Hand-resolved conflicts:

- bin/fm-spawn.sh launch templates: keep this branch's extraction of the
  templates into bin/fm-launch-lib.sh (fm_launch_template) and its single
  rendering owner (fm_launch_render), rather than main's inline
  launch_template. Template content is at parity with main, including
  kunchenguid#909's __OPINPUT__ operational-input envelope.
- Drop __PIBRIEFENV__ / FM_FIRSTMATE_PI_LAUNCH_BRIEF, which this branch
  still carried from kunchenguid#895. kunchenguid#936 removed that Calm input-reroute binding
  upstream and added a regression test asserting the pi launch command no
  longer exports it, so the removal is adopted here: the placeholder is
  gone from the pi templates and from fm_launch_render's signature.
- tests/fm-backend.test.sh sibling list: take main's ordering; the two
  sides list an identical set.

Also adopt kunchenguid#939's wider ShellCheck source graph, which now lints tests/:
tests/fm-cursor-agy-smoke.test.sh dropped an unused loop variable.

bin/fm-lint.sh is clean and the affected suites pass.
Two suite failures surfaced by merging main, both in contracts main
tightened while this branch was out:

- kunchenguid#939 pins an exact allowlist of tests permitted to carry
  `# shellcheck source=bin/` production context, so the ShellCheck source
  graph stays small. The three new cursor/agy tests had added themselves
  to that set. They do not need production context to lint cleanly, so
  they now stop static source following at /dev/null instead of widening
  the allowlist. bin/fm-lint.sh stays clean.
- The captain-translation contract asserts the launch command carries
  kunchenguid#909's canonical `encode launch-brief` envelope by reading
  bin/fm-spawn.sh. This branch moved the launch templates into
  bin/fm-launch-lib.sh, so the assertion read a file that no longer
  authors them. It now reads both files, covering the launch command
  wherever it is authored.

Not addressed here, and not a regression from this branch:
tests/fm-calm-pi-extension.test.sh fails identically on a clean
origin/main checkout (6b0d21d) with "/calm left the grep row in the
transcript". This branch's .pi/ tree and that test are byte-identical to
main.
feat(harness): add crew-only cursor and agy adapters
… host PATH

The test was at fault, not bin/fm-session-start.sh or bin/fm-bootstrap.sh.

Reproduced on a clean default branch (bash tests/fm-session-start.test.sh):

    not ok - MISSING diagnostic did not appear at all

and, once that site was fixed, the same root cause at a second site:

    not ok - fm-bootstrap.sh's real detect line did not appear verbatim (missing: 'MISSING: node (install:')

Both cases force a bootstrap MISSING diagnostic by deleting the fake `node`
from the fixture bin. That only works when node is absent from the test's
base PATH (/usr/bin:/bin:/usr/sbin:/sbin). On a host that ships node in
/usr/bin, bootstrap's `command -v node` still succeeds, so it correctly
reports nothing missing. Bootstrap's detection is right - node really is
installed - so the fixture, not the script, encodes the stale assumption.

Fixed by giving the fixture a `hide_node` helper that deletes the fake binary
and also masks the lookup through BASH_ENV, the same idiom the Herdr cases in
this file already use to mask tmux. No assertion is weakened or removed: both
MISSING assertions and the diagnostics-before-bulk-context ordering assertion
are unchanged and now actually exercised.

Verified: tests/fm-session-start.test.sh 28/28 pass (exit 0),
tests/fm-bootstrap.test.sh 21/21 pass, bin/fm-lint.sh clean.
No behavior change to session start.
Under a Pi primary, entering away mode left TWO supervision cycles live: the
away-mode sub-supervisor daemon and the Pi watch extension's own arm cycle. The
extension's arm runs `fm-watch-arm.sh --restart`, so it kept taking the watcher
singleton back from the daemon, starving away-mode triage entirely while
injecting ordinary watcher turns into the primary - the behavior recorded live on
2026-07-27.

Reproduced end to end with a real Pi 0.82.1 primary loading the tracked watch
extension, a real away daemon, and the real watcher, against a throwaway
firstmate home on a private tmux socket. Prompts delivered to the primary were
captured by a session-trust extension that aborts before any provider work.

BEFORE - two cycles, daemon starved, primary flooded:
  -- [away entered] state/.afk: present
       1685992 ... bin/fm-supervise-daemon.sh
       1711970 ... bin/fm-watch-arm.sh --restart
       1712043 ... bin/fm-watch.sh        (owned by the extension's arm)
  -- ordinary Pi watcher turns during away routine events: 4
  -- ordinary Pi watcher turns during the away escalation window: 6
  -- away-supervisor escalations delivered to the primary: 0
  daemon log, every cycle:
    watcher non-wake stdout, idling: watcher: already running pid 1685573

AFTER - one cycle while away, daemon triaging, escalation still delivered:
  -- [away entered] state/.afk: present
       1987515 ... bin/fm-supervise-daemon.sh   (its own fm-watch.sh child only)
  -- ordinary Pi watcher turns during away routine events: 0
  -- away-supervisor escalations delivered to the primary: 1
  daemon log:
    self-handle: signal ... -> routine signal: working: another routine step
    escalate: signal ... -> repro-task.status: blocked: needs a captain decision
  after return, exactly one cycle:
       1958195 ... bin/fm-watch-arm.sh --restart
       1958211 ... bin/fm-watch.sh
  -- ordinary Pi watcher turns after return: 3

The extra cycle was armed by the Pi side, not left behind by away mode: the
extension had no notion of the away-mode flag at all.

The extension now observes the durable state/.afk flag. While it is present the
extension arms nothing, retires any arm child it holds, delivers no ordinary
watcher wake, and schedules no retry; a per-generation away poll resumes exactly
one extension-owned cycle once the flag clears. Nothing is lost across the
hand-off because the daemon's own watcher enqueues and triages every event
durably and owns escalation. No process is matched or killed by pattern, and no
non-pi harness path changes - Claude's Stop auto-arm already had the equivalent
gate, and the other adapters are untouched.

Tests:
- tests/fm-pi-watch-extension.test.sh gains a deterministic regression test for
  the dual-supervision condition: arm, raise .afk, assert the arm child is
  retired, assert a further arm reports standby with no second cycle and no
  injected wake, clear .afk, assert exactly one cycle resumes. It fails on the
  pre-fix extension.
- tests/fm-afk-pi-dual-supervision-e2e.test.sh (opt-in, real Pi + real daemon)
  asserts the five acceptance steps and fails pre-fix at "the Pi extension kept
  its own supervision cycle alongside the away supervisor".

Also fixes a pre-existing collation mismatch in bin/fm-test-run.sh and
tests/fm-test-run.test.sh: comm ran without LC_ALL=C over LC_ALL=C-sorted input,
warning "file 2 is not in sorted order" on every coverage-guard run and risking a
wrong comparison under a non-C locale.
…tcher

tests/fm-watcher-lock.test.sh flaked at test_watch_restart_attaches_to_healthy_peer
with:

  not ok - restart did not attach to the verified healthy peer:
           watcher: started pid=N (beacon fresh)

Root cause is a startup race in the fixture, not in the watcher. The case stands
up a TERM-resistant node peer, records it as the lock holder, and expects
fm-watch-arm.sh --restart to attach to it instead of starting a second watcher.
node only becomes TERM-resistant once the interpreter has actually evaluated
process.on("SIGTERM"), and the restart sends TERM within milliseconds of the
launch. When the peer lost that race it died on the default disposition, so the
lock named a dead pid, the fresh child legitimately stole it, and the arm
honestly reported "started" - the fixture failed for a condition it does not
test.

Captured under instrumentation on an isolated reproduction of this case
(3 of 12 iterations):

  iter=8 BAD out='watcher: started pid=1620769 (beacon fresh)|'
     peer=1620694 peer_alive=no
     recorded_identity=linux-starttime=30963098 cmdline-hex=6e6f6465...
     live_identity    =<gone>
     lock_pid=1620769

peer_alive=no with the recorded identity intact rules out the identity/beacon
paths and pins it on the peer dying.

Fix: the peer announces that its SIGTERM handler is installed, and the fixture
waits on that exact condition before recording the lock and arming. No assertion
was loosened, no sleep widened, and no retry was wrapped around an assertion.

Loop evidence - `bash tests/fm-watcher-lock.test.sh`, 50 runs per arm, 6-way
parallel, before-arm run from a pristine `git archive HEAD` copy so both arms are
the same command under the same ambient load:

  before (origin/main):  10/50 FAILED - all 10 the peer-attach race
  after:                  0/50 FAILED

  after, 50 consecutive runs one at a time:  0/50 FAILED

Harness note for anyone re-running this: do NOT launch the loop under `nohup`.
nohup sets SIGHUP to SIG_IGN, an ignored disposition is inherited through fork
and exec, and a shell cannot trap a signal that was already ignored on entry - so
`kill -HUP` inside test_arm_hup_cleans_child_and_temp_output becomes a no-op and
that case times out (124) on every run regardless of the code under test. Early
loops here were launched that way and produced exactly that false signal.

Also verified: bin/fm-lint.sh clean, and all 10 suites selected by
`bin/fm-test-run.sh --changed` pass.
bin/fm-watch.sh ended each supervision cycle with a blind foreground
`sleep "$POLL"`. Bash defers a trapped signal until the running foreground
command returns, so the watcher was deaf to TERM/HUP/INT for the remainder
of the interval, and exit latency tracked FM_POLL exactly. The signal-grace
linger had the same shape.

Measured against an isolated temporary home, signalling a watcher that had
already taken its lock and entered its cycle wait:

  FM_POLL=1   TERM  before 0.54s   after 0.05s
  FM_POLL=5   TERM  before 4.54s   after 0.06s
  FM_POLL=15  TERM  before 14.53s  after 0.06s
  FM_POLL=15  HUP   before 14.52s  after 0.06s

bin/fm-watch-arm.sh --restart allows the outgoing watcher 50 iterations of
`sleep 0.1`, a 5s budget, before forking a replacement. At the 15s default
14.53s exceeded that budget outright, so a restart forked a second watcher
while the first was still alive and still holding the lock; the replacement
then saw a live holder and stood down, and the restart never produced the
fresh watcher it reported wanting.

Run the cycle wait and the signal-grace linger as a tracked background child
and wait on the named pid, so the trap runs the moment the signal lands. The
wait budget, polling cadence, and wake classification are unchanged, and the
EXIT path reaps the sleep child instead of orphaning it for the rest of the
interval (verified: no leaked sleep child after a mid-interval stop).

Liveness and wedge detection are unaffected and covered explicitly: the
heartbeat beacon keeps advancing across cycle waits and goes stale once the
watcher genuinely stops, so a stopped watcher is still detectable.

Known limit, documented at the call site and in the verification record: the
herdr push path waits inside a foreground command substitution and stays up
to FM_POLL deaf. That reader owns a fifo directory and a child reader process
that it removes on its own return path, so interrupting it from the caller
would leak both on every stop. Fixing it needs reader-side teardown.

Regression coverage in tests/fm-watcher-lock.test.sh, all three confirmed
against the unpatched watcher:
- watcher exits on TERM well inside a 10s budget at FM_POLL=60 (fails
  unpatched: "watcher ignored TERM for its whole poll interval")
- --restart hands the lock to a fresh live watcher within the arm's own 5s
  budget, with no overlap between outgoing and incoming (fails unpatched)
- liveness beacon advances while cycling and freezes once stopped (holds
  both before and after; guards against trading exit latency for a watcher
  that keeps its lock while no longer cycling)
…tcher

tests/fm-watcher-lock.test.sh flaked at test_watch_restart_attaches_to_healthy_peer
with:

  not ok - restart did not attach to the verified healthy peer:
           watcher: started pid=N (beacon fresh)

Root cause is a startup race in the fixture, not in the watcher. The case stands
up a TERM-resistant node peer, records it as the lock holder, and expects
fm-watch-arm.sh --restart to attach to it instead of starting a second watcher.
node only becomes TERM-resistant once the interpreter has actually evaluated
process.on("SIGTERM"), and the restart sends TERM within milliseconds of the
launch. When the peer lost that race it died on the default disposition, so the
lock named a dead pid, the fresh child legitimately stole it, and the arm
honestly reported "started" - the fixture failed for a condition it does not
test.

Captured under instrumentation on an isolated reproduction of this case
(3 of 12 iterations):

  iter=8 BAD out='watcher: started pid=1620769 (beacon fresh)|'
     peer=1620694 peer_alive=no
     recorded_identity=linux-starttime=30963098 cmdline-hex=6e6f6465...
     live_identity    =<gone>
     lock_pid=1620769

peer_alive=no with the recorded identity intact rules out the identity/beacon
paths and pins it on the peer dying.

Fix: the peer announces that its SIGTERM handler is installed, and the fixture
waits on that exact condition before recording the lock and arming. No assertion
was loosened, no sleep widened, and no retry was wrapped around an assertion.

Loop evidence - `bash tests/fm-watcher-lock.test.sh`, 50 runs per arm, 6-way
parallel, before-arm run from a pristine `git archive HEAD` copy so both arms are
the same command under the same ambient load:

  before (origin/main):  10/50 FAILED - all 10 the peer-attach race
  after:                  0/50 FAILED

  after, 50 consecutive runs one at a time:  0/50 FAILED

Harness note for anyone re-running this: do NOT launch the loop under `nohup`.
nohup sets SIGHUP to SIG_IGN, an ignored disposition is inherited through fork
and exec, and a shell cannot trap a signal that was already ignored on entry - so
`kill -HUP` inside test_arm_hup_cleans_child_and_temp_output becomes a no-op and
that case times out (124) on every run regardless of the code under test. Early
loops here were launched that way and produced exactly that false signal.

Also verified: bin/fm-lint.sh clean, and all 10 suites selected by
`bin/fm-test-run.sh --changed` pass.

(cherry picked from commit 3db0341)
Both pi tuples in the dispatch config reported no authentication surface, so
rule 2's OpenAI candidate and rule 3's entire MiniMax lane fell through to the
premium default. This was not a credential fault, a quota-axi defect, or a
stale tuple.

The `surface-unresolved` verdict originated in bin/fm-auth-preflight.sh, which
resolved surfaces from a hard-coded harness-to-provider table plus a
`pi:<prefix>` source matcher. It was added in kunchenguid#1349 and deleted four hours
later in kunchenguid#1358, which returned eligibility to open agent judgment resting on
docs/verification/dispatch-auth.md.

That record had no evidence that a provider family absent from quota-axi can
still have a resolved surface, and no record that a harness catalog is itself
surface evidence. With nothing to contradict it, the retired conclusion kept
being re-derived at intake and the zero-premium lane stayed unused.

Pi's installed docs/models.md states that a provider's models stay absent from
--list-models until its auth is configured, so a catalog row proves configured
auth. Verified on Pi 0.82.1 and quota-axi 0.1.16: minimax/MiniMax-M3 is listed
while quota-axi models no minimax provider at all. The surface is resolved by
the catalog; only the quota is unknown, which is disclosed uncertainty.

Records both verified facts, and separates "is the surface resolved" from "is
the quota known" in the decision procedure so an unmodeled vendor can no longer
read as a missing surface. No check is relaxed: this adds a positive evidence
source rather than removing a requirement.

Covered by a case in the live dispatch regression that supplies only the
catalog row and a snapshot without the family. Against the previous procedure
it reports surface=unresolved; with this change it reports surface=resolved.
Sungin Kim and others added 28 commits August 3, 2026 16:43
/bearings and /fleet failed outright in any home with a real backlog:

  bin/fm-fleet-snapshot.sh: line 567: jq: Argument list too long
  fm-fleet-snapshot: main inventory summary failed

The cause is the per-argument limit, not the total one. Linux caps a
SINGLE argv string at MAX_ARG_STRLEN (32 pages = 131072 bytes),
independently of the much larger ARG_MAX, so execve fails with E2BIG once
one --argjson payload crosses 128 KiB even though total argv size is far
under the ceiling. The primary home's backlog JSON is 216172 bytes.

Every jq payload whose size grows with the fleet is now bound with
--slurpfile from a stream and unwrapped in the filter by a local `doc`
helper, which also preserves --argjson's fail-closed behavior on an empty
payload. Scalars, single paths, and per-record documents bounded by this
script's FM_SNAPSHOT_* read bounds stay on --arg/--argjson.

Sites converted: main inventory, secondmate home summary, the top-level
assembly, the secondmate registry/task union, the per-secondmate record
and its accumulator, the secondmate landed projection, the parent-evidence
reconciliation, and Bearings' candidate-PR rows and accumulator.

No schema, field, bound, or TOON change: output is byte-identical to the
pre-bug behavior on a fixture the old code could still handle.
…able

fm_backend_validate_task_endpoint requires an endpoint_task_id= binding
before any non-tmux endpoint may be cleaned up, because herdr, zellij,
orca and cmux endpoint ids are opaque and do not encode the task they
belong to. fm-spawn.sh writes it for new tasks, but nothing migrated
records already on disk, so every task spawned on those backends before
that change refuses cleanup permanently.

Add bin/fm-endpoint-binding-migrate.sh, a one-shot, idempotent sweep run
from the locked bootstrap MUTATING section. It writes the binding only
for a record whose recorded endpoint still resolves, live, to a runtime
object carrying that task's own label - the same class of self-identifying
evidence the legacy tmux path validates by window name. The candidate is
committed only after the exact bytes that would land pass
fm_backend_validate_task_endpoint itself, so the check is neither relaxed
nor reimplemented.

Every other outcome refuses and leaves the record byte-unchanged. A
confirmed-gone endpoint is reported, never bound: absence is not proof of
ownership, and a runtime may later reuse a freed opaque id. A binding
written without proof would recreate the exact hazard the validation was
added to prevent while looking like a fix.

Also force C collation on the test runner's comm calls, whose inputs are
already LC_ALL=C sorted; without it the coverage guard failed in a UTF-8
locale.
The coverage guard's comm calls run under the ambient locale on
LC_ALL=C sorted input, so --check-coverage fails in a UTF-8 locale.
That bug sits on the default branch and is owned by a dedicated task
with a more complete fix, so carrying a second copy here would only
guarantee a conflict.

Only the backend-dispatch family registration for the new migration
test remains in bin/fm-test-run.sh.
`tests/fm-test-run.test.sh` exited 1 with every assertion passing, and a
stray `comm: not in sorted order` on stderr.

The comparison was at fault, not the input.

`run_coverage_guard` builds every lane list with `LC_ALL=C sort -u`, but
called `comm` under the ambient locale. Evidence that settled it: the
portable-serial list passes `LC_ALL=C sort -c` cleanly, and the identical
file fails `sort -c` under en_US.UTF-8 at `tests/fm-backend.test.sh`.
glibc's en_US.UTF-8 collation ignores `-` at the primary weight, so it
orders `fm-backend.test.sh` before `fm-backend-tmux-smoke.test.sh`, while
C compares bytes where `-` (0x2D) sorts before `.` (0x2E). The lists were
correctly sorted for the ordering the runner chose; `comm` was applying a
different one.

The unguarded `comm -12` in the lane-overlap loop therefore exited 1 under
the script's `set -eu`, killing the guard before it printed its verdict.
The `|| true`-guarded `comm` calls were worse in kind: on mis-collated
input they silently return a wrong set difference, so a real coverage hole
could have passed the guard.

Fix: prefix every `comm` in the coverage guard, and the three in this
test, with `LC_ALL=C` so the set operations use the same collation as the
sorts that produced their inputs. No warning is suppressed.

Also fix why the failure was invisible. Each `set +e ... rc=$?; set -e`
pair in the test enabled errexit rather than restoring it - the file's
baseline is `set -u` only - so from the first pair onward any unguarded
non-zero exited the suite silently, with no `not ok`. Replaced all ten
with `rc=0; <cmd> || rc=$?`, which captures the status correctly whether
or not errexit is on and leaks nothing.

New `test_coverage_guard_is_collation_independent` asserts the guard exits
0 with empty stderr under C, the ambient locale, and the first installed
locale whose collation actually disagrees with byte order, discovered by
probe rather than hardcoded. It fails against the pre-fix runner.
Reconciles 68 upstream commits with the fork's 17 landed cursor/agy commits.
19 files conflicted; every conflict was resolved by keeping both sides' intent
where compatible and by deferring to the newer owner where one side had moved a
contract.

Notable resolutions:
- bin/fm-dispatch-select.sh and its test: accept upstream's removal of the
  vestigial selector; the fork had only annotated it.
- tests/fm-captain-translation-contract.test.sh and the two source-asserting
  functions in tests/fm-pi-watch-extension.test.sh: accept upstream's removal of
  implementation-source assertions, which the coding guidelines now forbid.
- bin/fm-launch-lib.sh stays the single owner of launch-command construction, and
  upstream's pi-signed and kimi templates plus their model/effort vocabularies are
  ported into it. fm-spawn keeps kimi's spawn-time binary resolution so the
  library's unresolved-placeholder guard still applies.
- bin/fm-test-run.sh: the fork's live-harness-optin exclusion moves into
  list_portable_serial, upstream's single owner of serial membership, so the
  derived CI serial shards stay consistent and the coverage guard proves five
  disjoint partitions.
- bin/fm-teardown.sh: upstream's exact-code error propagation replaces the fork's
  flattened variant, and the agy workspace-trust removal runs after the Herdr
  presentation preflight takes the lock guarding destructive steps.
Adds opt-in GitHub issue traceability. Reconciled against upstream's newer
contract that a ship brief takes its delivery mode as an explicit --mode
argument rather than reading the project registry:

- fm-brief.sh keeps upstream's required, closed-set --mode and gains --issue.
  The branch's registry lookup is dropped; its issue/local-only guard now tests
  the explicit mode.
- --issue argument-shape validation moved ahead of the --mode requirement so a
  malformed issue number reports itself instead of being masked.
- The branch's three tests were ported to name a mode on every ship invocation.
- tests/fixtures/fm-brief-no-issue.sha256 was regenerated against the merged
  tree's own pre-branch output, and the no-issue briefs were verified byte-
  identical before and after this branch, which is what that fixture exists to
  prove.
Both sides had hardened the same MISSING-tool fixture against host PATH leakage:
the fork removes no-mistakes (never present in a system PATH), this branch adds
hide_node. Both statements are kept, because the surrounding assertions require
the no-mistakes MISSING line while the auto-merged run_session_start calls
require the mask this branch produces.
Both sides had reached the same LC_ALL=C comm calls; the branch's fix also
covers the serial-shard comparisons upstream added. Kept the fork's comment
explaining why the collation must match.
The bootstrap-diagnostics trigger list took an addition from each side: the
fork's widened CREW_DISPATCH (invalid or backend mismatch) and this branch's
ENDPOINT_BINDING_MIGRATION. Both are real emitted lines, so both are listed.
Both sides added a window_harness helper to bin/fm-watch.sh, so the merge kept
both and the later one silently shadowed the earlier. That changed what
fm_busy_classify receives for a window with no metadata, from an empty string to
the literal "unknown", with no conflict to review it.

Upstream's definition is retained because its caller was written against the
empty-string form. maybe_native_turnend matches only the exact cursor and agy
tokens, so the crew-only native turn-end path behaves identically either way.

Found by bin/fm-lint.sh (SC2329 on the shadowed definition).
While resolving bin/fm-teardown.sh in the upstream sync, I spliced the per-child
cleanup branch using a context anchor that appears three times in the file. The
edit landed on the first occurrence instead of the intended one and deleted
everything between them, removing six upstream function definitions plus
cleanup_firstmate_home_children:

  cleanup_firstmate_home_children, preflight_firstmate_home_herdr_children,
  teardown_herdr_preflight_target, teardown_herdr_require_prerequisites,
  teardown_herdr_session_lock_held, teardown_release_herdr_locks

Surfaced by tests/fm-backend-autodetect-smoke.test.sh, where teardown died with
"teardown_herdr_preflight_target: command not found".

The file is rebuilt from a fresh three-way merge of the same inputs, with every
conflict resolved as before but with anchors asserted unique first. The result is
verified to define every function either side defines, with no duplicates and
nothing extra; the single exception is registry_home_for_line, which upstream
deleted outright and which has no remaining caller.
tests/fm-backend.test.sh: the legacy fake root that build_old_bin assembles did
not carry fm-agy-trust-lib.sh, which the merged fm-teardown.sh sources for the
cursor/agy workspace-trust cleanup, so the legacy teardown case died sourcing a
file that was never copied. The fork made the same fixture completion in
fm-gotmp.test.sh; this builder was missed because its dependency list grew on the
upstream side. Both fake-root builders now carry the sibling.

tests/fixtures/fm-brief-no-issue.sha256: regenerated against the final tree.
These hashes were pinned when fm/fm-issue-lifecycle-wiring merged, and
fm/fm-brief-status-protocol-gaps subsequently changed the crewmate scaffold's
status protocol, which legitimately changes ship and scout brief bytes. Only
those six entries moved; the two secondmate charters are unchanged, which matches
a crewmate-scaffold-only change. The property this fixture exists to protect -
that a no-issue brief is unaffected by the issue feature - was verified byte-for-
byte when that branch merged and is still asserted by
test_issue_traceability_is_strictly_opt_in.
The fork's cursor/agy test predates three upstream changes and could no longer
reach the refusals it asserts:

- Ship spawns now require explicit --mode and --yolo, and both checks run before
  the crew-only and herdr-only gates. The ship cases now name both; the
  --secondmate rows in the raw-bypass table deliberately pass neither, because a
  secondmate records its own fixed posture and refuses those flags.
- fm/fm-endpoint-binding-migration refuses an endpoint record with no exact task
  binding, so the forced-child fixture now records endpoint_task_id.
- That same fixture recorded its child on herdr, which now additionally has to
  clear teardown_herdr_preflight_target's structured pane inspection. The case
  is about cleanup_firstmate_home_children refusing when a child's firstmate-owned
  agy trust cannot be removed, which runs before any backend-specific work and is
  backend-independent, so the child is recorded on tmux instead. Faking herdr's
  pane protocol here would prove nothing about trust cleanup; real herdr endpoint
  behaviour stays covered by the real-herdr-gated lane.

The gates themselves are unchanged; only the fixtures were conformed.
…ncile

Sync the fork with upstream and land the ten reviewed changes
@HelloWorldSungin

Copy link
Copy Markdown
Author

Opened in error by our validation pipeline against the wrong remote; this work belongs on our own fork. Closing - no review needed, apologies for the noise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant