@outerlayer/cli 0.34.0-next.20261028164329 → 0.34.0-next.20261029014930

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (185) hide show
  1. package/README.md +7 -0
  2. package/dist/agent-setup-J2WZHYN5.js +32 -0
  3. package/dist/{artifact-link-cmd-CSVFEM5O.js → artifact-link-cmd-6LFCTDBD.js} +5 -5
  4. package/dist/{build-SEJJWGTO.js → build-2JBISOVR.js} +8 -8
  5. package/dist/{build-disk-EYRR3PBT.js → build-disk-ECEVCK35.js} +6 -6
  6. package/dist/build-info.json +1 -1
  7. package/dist/{builder-T7B46P7T.js → builder-OMDEUDO3.js} +5 -5
  8. package/dist/caller-P5ZHKVD5.js +18 -0
  9. package/dist/{check-SPMUN5C4.js → check-6ZGMF7VF.js} +84 -66
  10. package/dist/{chunk-ANPNT6PM.js → chunk-2AM6Z5BP.js} +1 -1
  11. package/dist/{chunk-UE2C4STC.js → chunk-2B6EKUBD.js} +88 -6
  12. package/dist/{chunk-GG5OE6MY.js → chunk-2RTGZ6AE.js} +1 -1
  13. package/dist/{chunk-QGEGLZSY.js → chunk-32QKEHC7.js} +46 -6
  14. package/dist/{chunk-VNVZDWO3.js → chunk-352DHUTP.js} +4 -1
  15. package/dist/{chunk-IPWKT5J7.js → chunk-3MKCUCG7.js} +225 -121
  16. package/dist/{chunk-ZJSNLVCE.js → chunk-545P7JY7.js} +1 -1
  17. package/dist/{chunk-2EEW6FJN.js → chunk-5FWBAM6O.js} +1 -1
  18. package/dist/{chunk-MCPCOKHN.js → chunk-5VGVYEFT.js} +9 -9
  19. package/dist/{chunk-T2Q7ISPE.js → chunk-5WYT3PPE.js} +1 -1
  20. package/dist/{chunk-ARL6X6Y4.js → chunk-62TMOXQN.js} +2 -2
  21. package/dist/{chunk-RRXS4CWE.js → chunk-6JDEP42Z.js} +9 -7
  22. package/dist/{chunk-YIK5SGEN.js → chunk-6OAOOAJO.js} +69 -27
  23. package/dist/{chunk-FUOKDHRB.js → chunk-76VJKVM5.js} +8 -7
  24. package/dist/{chunk-4YD7N6V3.js → chunk-7B6CKPNZ.js} +3 -3
  25. package/dist/{chunk-I2MFIT6X.js → chunk-7T5MUKW6.js} +28 -27
  26. package/dist/{chunk-2EHDLYSL.js → chunk-7TIFAOUG.js} +30 -22
  27. package/dist/{chunk-G2JWZDFA.js → chunk-A2LHHKTT.js} +3 -3
  28. package/dist/{chunk-ESVW4MJY.js → chunk-AAGU5FJF.js} +1 -1
  29. package/dist/{chunk-WA3HIJVK.js → chunk-B7ZC2HKE.js} +3 -3
  30. package/dist/{chunk-YF7W7B7Y.js → chunk-BWJRNMZZ.js} +37 -10
  31. package/dist/{chunk-TUSYOL2O.js → chunk-CJPTUU2E.js} +1 -1
  32. package/dist/{chunk-MEIDQLXQ.js → chunk-D7BEGG7T.js} +1 -1
  33. package/dist/{chunk-V2S2WRGD.js → chunk-DG25T7AY.js} +11 -11
  34. package/dist/chunk-DUV33KMD.js +31 -0
  35. package/dist/{chunk-NCOL5RYI.js → chunk-E4R3M6XJ.js} +1 -1
  36. package/dist/{chunk-DCBFUUDL.js → chunk-EFZM7UOP.js} +7 -7
  37. package/dist/{chunk-KH4774QT.js → chunk-F57NE5AO.js} +1 -1
  38. package/dist/{chunk-MH6QLXUO.js → chunk-FJ7KTNMD.js} +1 -1
  39. package/dist/{chunk-3KGXXTMN.js → chunk-FNS2RJ5T.js} +5 -5
  40. package/dist/{chunk-2O5KA67H.js → chunk-FUJUFLDC.js} +2 -2
  41. package/dist/{chunk-CRB3POP4.js → chunk-FZKNTIOJ.js} +1 -1
  42. package/dist/{chunk-KPEMNHVF.js → chunk-G7OVITGQ.js} +2 -2
  43. package/dist/{chunk-7JSWRF5O.js → chunk-GD4AXYK3.js} +10 -10
  44. package/dist/{chunk-SAAVZ2BX.js → chunk-GOSOKVBF.js} +1 -1
  45. package/dist/{chunk-ZTOJIRJH.js → chunk-HFHRTVXN.js} +8 -8
  46. package/dist/{chunk-S6UM3N4R.js → chunk-HSE2LOWO.js} +36 -11
  47. package/dist/{chunk-XDAMLX2L.js → chunk-HUS3GYCX.js} +9 -9
  48. package/dist/{chunk-PJDQPF5N.js → chunk-HWVMRETT.js} +1 -1
  49. package/dist/{chunk-WH3FPBPO.js → chunk-I35CNSPC.js} +60 -29
  50. package/dist/{chunk-ZCA34T7R.js → chunk-JEOBBOZY.js} +8 -8
  51. package/dist/{chunk-RQ3GCCHH.js → chunk-JXXMOAJG.js} +2 -2
  52. package/dist/{chunk-EA2PQRCU.js → chunk-K6LLZONM.js} +6 -6
  53. package/dist/{chunk-QI7JB2GU.js → chunk-KWFJF4CX.js} +646 -210
  54. package/dist/{chunk-URIZRCRY.js → chunk-KYDEBGJG.js} +1 -1
  55. package/dist/{chunk-P2PNBDUT.js → chunk-LLQGVGFO.js} +3 -3
  56. package/dist/{chunk-HFOZTCTN.js → chunk-N2OG4RN6.js} +7 -7
  57. package/dist/{chunk-KT4CN6OU.js → chunk-OHQMGLJP.js} +3 -3
  58. package/dist/{chunk-5BHIBJDA.js → chunk-OLM2TIOW.js} +1 -1
  59. package/dist/{chunk-VEVNGDTP.js → chunk-PDK35AR4.js} +2 -2
  60. package/dist/{chunk-UZEIBWTP.js → chunk-PGJY7XTY.js} +7 -7
  61. package/dist/{chunk-TDCHUEKY.js → chunk-PNAVR5OD.js} +5 -5
  62. package/dist/{chunk-RPST2GNG.js → chunk-PQ5YDDDE.js} +3 -3
  63. package/dist/{chunk-OKJXZXYH.js → chunk-PUSCE544.js} +6 -6
  64. package/dist/{chunk-ZEFNJCN3.js → chunk-QM3HMXMU.js} +2 -2
  65. package/dist/{chunk-CUAB7FAZ.js → chunk-QNISFH47.js} +8 -8
  66. package/dist/{chunk-5TXQFZHY.js → chunk-QOVUDIUI.js} +1 -1
  67. package/dist/{chunk-OYQVLQP3.js → chunk-QTNWAV23.js} +14 -12
  68. package/dist/{chunk-ZCZY3Q55.js → chunk-RZ22SWMA.js} +1 -1
  69. package/dist/{chunk-KQDK4Q6A.js → chunk-SMYOFJHK.js} +10 -10
  70. package/dist/{chunk-GH2HEEOH.js → chunk-TV2OQUWE.js} +1 -1
  71. package/dist/{chunk-HH3BQG65.js → chunk-UPRZREBO.js} +1 -1
  72. package/dist/{chunk-W7E6IMEW.js → chunk-UTIRCHI5.js} +22 -21
  73. package/dist/{chunk-H7MGR2GN.js → chunk-UZDWCSLS.js} +6 -6
  74. package/dist/{chunk-IAVT7R6O.js → chunk-WJTIU2A5.js} +6 -6
  75. package/dist/{chunk-QGDGGLSD.js → chunk-X4PYXWBY.js} +3 -3
  76. package/dist/{chunk-54LIUIZL.js → chunk-XGSJNXH2.js} +4 -4
  77. package/dist/chunk-XKV6HXKD.js +39 -0
  78. package/dist/{chunk-I7RZHMXW.js → chunk-YBAVN6WS.js} +3 -3
  79. package/dist/{chunk-IXRUVR25.js → chunk-YTTESG7K.js} +46 -7
  80. package/dist/{chunk-MRLJK4GZ.js → chunk-YZSE7EYM.js} +6 -6
  81. package/dist/{chunk-CKDSPW35.js → chunk-ZI2E4YMY.js} +6 -6
  82. package/dist/{chunk-UXC3RQLF.js → chunk-ZQQNWDPE.js} +1 -1
  83. package/dist/{claude-launcher-7IC6QWR5.js → claude-launcher-GACOES7Z.js} +6 -6
  84. package/dist/{cli-GKROH23V.js → cli-A3IUMZHY.js} +162 -152
  85. package/dist/{cli-update-notice-4DLZ3655.js → cli-update-notice-T3CXRWNB.js} +3 -3
  86. package/dist/{command-XA6DOFL4.js → command-XPDD3473.js} +39 -38
  87. package/dist/{config-RSOCVUKC.js → config-7DT7UVUI.js} +8 -8
  88. package/dist/connect-cmd-TWSO7YKC.js +27 -0
  89. package/dist/{container-start-ZDSVXSAL.js → container-start-2AQWC275.js} +53 -52
  90. package/dist/{context-cleanup-CEZSKNVL.js → context-cleanup-PASDUBGW.js} +5 -5
  91. package/dist/{context-show-cmd-XWLTP6R4.js → context-show-cmd-6MEUB3HU.js} +18 -18
  92. package/dist/{control-plane-launch-3MBWPYWZ.js → control-plane-launch-6NN5ZSP3.js} +15 -15
  93. package/dist/{demo-record-cmd-SIKNTSGI.js → demo-record-cmd-2FY7VCIL.js} +3 -3
  94. package/dist/{demo-voice-cmd-SAB3QU4F.js → demo-voice-cmd-GJNJNEAI.js} +29 -29
  95. package/dist/{dist-VPXROEZO.js → dist-Z6WP743R.js} +2 -2
  96. package/dist/{docker-YMRPMDOW.js → docker-DLJTPUC5.js} +5 -5
  97. package/dist/{doctor-NVHAE4LS.js → doctor-HYDAFWR2.js} +49 -38
  98. package/dist/emit-artifact-cmd-TTLDSPP3.js +43 -0
  99. package/dist/emit-cmd-UOPHEUW5.js +16 -0
  100. package/dist/emit-criteria-cmd-MZSFNXTL.js +33 -0
  101. package/dist/emit-demo-cmd-CPC6OR6A.js +47 -0
  102. package/dist/emit-finding-cmd-6ABNXD5P.js +34 -0
  103. package/dist/{emit-result-cmd-VCKNZ4RZ.js → emit-result-cmd-7STD6BH3.js} +27 -27
  104. package/dist/emit-step-cmd-A35LWNWB.js +33 -0
  105. package/dist/find-unit-ZMUTRE46.js +19 -0
  106. package/dist/{findings-cmd-PLHBAQW4.js → findings-cmd-JNLW5T2Q.js} +22 -22
  107. package/dist/fleet-readiness-7WASGVPR.js +28 -0
  108. package/dist/governing-source-SQE47DKU.js +38 -0
  109. package/dist/{guest-init-MI4SEME4.js → guest-init-73ZCYECM.js} +2 -2
  110. package/dist/{hook-fast-GOH4T6SN.js → hook-fast-AELCXUNA.js} +6 -6
  111. package/dist/{hook-wrap-fast-7VYYAAH4.js → hook-wrap-fast-545QJSBJ.js} +3 -3
  112. package/dist/host-checks-EM7CVCO6.js +78 -0
  113. package/dist/{host-key-OMLDWLNG.js → host-key-ZRXO2BXZ.js} +2 -2
  114. package/dist/{image-tag-YJJONB64.js → image-tag-6KN2SKDZ.js} +2 -2
  115. package/dist/index.js +6 -6
  116. package/dist/init-4U2IAN5U.js +57 -0
  117. package/dist/{init-W3ATJYLX.js → init-NEOWYRSR.js} +35 -34
  118. package/dist/{init-cmd-XJOEU2PB.js → init-cmd-WRNXDUM7.js} +32 -32
  119. package/dist/{init-update-KX3FFQ5H.js → init-update-ATXYAAAD.js} +29 -29
  120. package/dist/{install-cmd-QTIIMO6B.js → install-cmd-WF2N2SKL.js} +4 -4
  121. package/dist/{layout-7UOBWNYO.js → layout-ZE6F2Z7W.js} +4 -4
  122. package/dist/login-browser-YB7AMKHR.js +13 -0
  123. package/dist/{logout-cmd-5WE2N5B5.js → logout-cmd-Z2PYV5LF.js} +5 -5
  124. package/dist/{logs-YVXVAYTD.js → logs-WEJHWBLM.js} +22 -2
  125. package/dist/loop-IHQ4UMRY.js +89 -0
  126. package/dist/machine-VNDSSHQA.js +57 -0
  127. package/dist/{machine-skills-KYN7XJEJ.js → machine-skills-DMHU7OLO.js} +5 -5
  128. package/dist/{mcp-install-cmd-LD7KYAOP.js → mcp-install-cmd-23ZY4IBK.js} +5 -5
  129. package/dist/{mcp-serve-cmd-ECTAPDB3.js → mcp-serve-cmd-YT63QC7W.js} +8 -8
  130. package/dist/{paths-M66LPPUF.js → paths-IGFAJFPN.js} +1 -1
  131. package/dist/{pending-7LC6XDRO.js → pending-GBIXDPY7.js} +2 -2
  132. package/dist/{pidfile-DSQOOAZV.js → pidfile-BDQMJPLA.js} +2 -2
  133. package/dist/{record-3KKIJ3XL.js → record-KLNLIQVR.js} +2 -2
  134. package/dist/{runner-env-EX7YUIUH.js → runner-env-PBTT2CNL.js} +10 -10
  135. package/dist/{runner-identity-LJWBXNM5.js → runner-identity-JVG53E73.js} +5 -5
  136. package/dist/{runner-key-CAUO4RKG.js → runner-key-YKHIRBO4.js} +34 -33
  137. package/dist/session-sender-SNBEWETV.js +43 -0
  138. package/dist/{settings-3DBYKYQD.js → settings-XB2HYBKO.js} +2 -2
  139. package/dist/{spec-cmd-SAWQYHKM.js → spec-cmd-VPP66GMQ.js} +22 -22
  140. package/dist/{starter-pack-KB3YH4KX.js → starter-pack-WUNNS6G7.js} +9 -9
  141. package/dist/state-VIWYAWVB.js +9 -0
  142. package/dist/{status-IPIMYTG5.js → status-HY5FJPJV.js} +74 -52
  143. package/dist/{statusline-fast-YVHG6ZLX.js → statusline-fast-E7RWVREA.js} +4 -4
  144. package/dist/sync-cmd-7BG47GNA.js +42 -0
  145. package/dist/update-steps-NI25AAQM.js +79 -0
  146. package/dist/{watch-6NRBX6VE.js → watch-QMKKCF2B.js} +27 -27
  147. package/dist/{work-claim-cmd-SLVX2N4L.js → work-claim-cmd-UUMDPIZG.js} +25 -25
  148. package/dist/work-cmd-5QGKKDFY.js +31 -0
  149. package/dist/work-comment-cmd-YJ3JTQ5B.js +32 -0
  150. package/dist/{work-demo-cmd-SZJIKB5J.js → work-demo-cmd-AQ4JVDCK.js} +19 -19
  151. package/dist/{work-launch-LEQ2MPM3.js → work-launch-TTGSHLY4.js} +3 -3
  152. package/dist/{work-logs-cmd-MRFSBMJM.js → work-logs-cmd-TQTA7KQK.js} +19 -19
  153. package/dist/{work-open-pr-cmd-N7GK7FUQ.js → work-open-pr-cmd-2NFF3RYJ.js} +21 -21
  154. package/dist/work-pr-cmd-R5VRWQJD.js +32 -0
  155. package/dist/work-proofs-cmd-UYGYDIYY.js +35 -0
  156. package/dist/{work-proofs-record-CJAFFWXG.js → work-proofs-record-U3KQOM5Z.js} +33 -33
  157. package/dist/{work-stop-cmd-M6RIGF7S.js → work-stop-cmd-SIAX4XAA.js} +19 -19
  158. package/package.json +1 -1
  159. package/skill-pack/maintained/outerlayer-build/SKILL.md +2 -1
  160. package/skill-pack/maintained/outerlayer-build/references/evidence.md +2 -1
  161. package/skill-pack/maintained/outerlayer-build/scripts/criterion-citations.mjs +65 -8
  162. package/dist/agent-setup-IVXRBFVV.js +0 -32
  163. package/dist/connect-cmd-JFGDHFLA.js +0 -27
  164. package/dist/emit-artifact-cmd-TZTVQCFT.js +0 -43
  165. package/dist/emit-cmd-4G3443OJ.js +0 -16
  166. package/dist/emit-criteria-cmd-WH7JB4RQ.js +0 -33
  167. package/dist/emit-demo-cmd-DNUVG5N7.js +0 -47
  168. package/dist/emit-finding-cmd-X5CBH4ZA.js +0 -34
  169. package/dist/emit-step-cmd-IUXZZYKO.js +0 -33
  170. package/dist/find-unit-QYD2FMCP.js +0 -19
  171. package/dist/fleet-readiness-F65CKZY5.js +0 -28
  172. package/dist/governing-source-JFCTQXYK.js +0 -38
  173. package/dist/host-checks-LEVAIIN4.js +0 -77
  174. package/dist/init-JVKJTJNM.js +0 -56
  175. package/dist/login-browser-Q25ZNSQ3.js +0 -13
  176. package/dist/loop-NNJN2XOW.js +0 -87
  177. package/dist/machine-OQOHEMJB.js +0 -56
  178. package/dist/session-sender-U2CTD7EX.js +0 -43
  179. package/dist/sync-cmd-EBJQ5LMH.js +0 -42
  180. package/dist/update-steps-E2PP5DPR.js +0 -78
  181. package/dist/work-cmd-VSHZCXHQ.js +0 -31
  182. package/dist/work-comment-cmd-3DCL7VHN.js +0 -32
  183. package/dist/work-pr-cmd-HD5OIHUU.js +0 -32
  184. package/dist/work-proofs-cmd-H2GGE5HK.js +0 -35
  185. package/dist/{chunk-POND2SMT.js → chunk-RC2WZQK6.js} +1 -1
@@ -1,36 +1,37 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from 'node:module';
3
- import { itemsSentence, criteriaOf, hostItemsOf, loadCitationFinder, MAX_TEST_FILE_BYTES, MAX_TEST_FILES, testFileMatcher, criterionInputs, planCriteria, parseJudgeAnswer, inCriteriaOrder, oneLineReason, judgedItems } from './chunk-UE2C4STC.js';
3
+ import { itemsSentence, criteriaOf, hostItemsOf, loadCitationFinder, testFileMatcher, MAX_TEST_FILE_BYTES, MAX_TEST_FILES, criterionInputs, uncitedIds, planCriteria, parseJudgeAnswer, inCriteriaOrder, oneLineReason, judgedItems, IdScan, firstInPathOrder, isSearchCandidate } from './chunk-2B6EKUBD.js';
4
4
  import { readsJobState, READ_JOB_STATE_FORMATS, jobStateFormatOf } from './chunk-ZVB57WI6.js';
5
- import { HELPER_PATH, DOCKERD_LOG, HELPER_RECORD } from './chunk-POND2SMT.js';
6
- import { zodProblem } from './chunk-I3LTIAOR.js';
7
- import { senderPidfile } from './chunk-TDCHUEKY.js';
8
- import { installScrubContext } from './chunk-I2MFIT6X.js';
5
+ import { HELPER_PATH, DOCKERD_LOG, HELPER_RECORD } from './chunk-RC2WZQK6.js';
9
6
  import { writeDockerClientConfig } from './chunk-BBJ6BM5U.js';
10
- import { upgradedStarterText } from './chunk-IAVT7R6O.js';
11
- import { ADDED_USER, shellQuote, GH_CONFIG_YML, ghHostsYml, firstLine, provisionWithFreshFallback, hasClaudeCredential, AssetError, obtainImage, taggedLog, planSavedState, clockOf, savedStateBase, savedStatesDir, ensureRootfs, makeBuildsDirPrivate, gitRemoteFor, startServicesFor, createLeaseChannel, createBuildDisk, machineConfig, startJailedInto, resolveAgentUser, AgentUserError, agentUidOf, userIdChangedReason, runBuildSteps, setupInputFor, runtimeStepInput, settleFailedSteps, keepRuntimeStep, keepMissingSetupScripts, createContainerRuntime, containerSenderCommand, hostCommandEnvironment, execArgv, signalInContainer, startHostServices, LEASE_SECONDS, managedBuildSettingsFor, stopContainer, cleanupContainer, recordProofsInContainer, PROOFS_LOG, outOfMemoryReason, closeHostBuild, dropManagedClaudeKey, dropManagedBuildSettings, startCheckContainer, ranRuntimeStep, provisionRuntimes, lifecycleSteps, lifecycleFailureReason, writeEvalInput, DeliveryFailure, EVAL_INPUT_NAME, syncInContainer, copyTranscriptsFromContainer, senderAliveScript, discardUnusableState, MANAGED_UNJAILED_REASON, uidFromProbe, saveAndPrune, managedMachineLimits, withFactoryHosts, helperFirecrackerNote, said, managedClaudeKeyValues, managedBuildSettingValues, stopJailed, deleteBuildDisk, RECORD_PROOFS_ARGV, managedClaudeKeyFor, ROOT_DISK_ID_PREFIX, copyTranscripts, writeRecord, containerJudgeEnvironment, deleteRecord, senderSignalScript, copyJudgeTree } from './chunk-WH3FPBPO.js';
12
- import { fetchCommit, readBranchHead, diffBetween } from './chunk-OYQVLQP3.js';
7
+ import { zodProblem } from './chunk-I3LTIAOR.js';
8
+ import { senderPidfile } from './chunk-PNAVR5OD.js';
9
+ import { installScrubContext } from './chunk-7T5MUKW6.js';
10
+ import { upgradedStarterText } from './chunk-WJTIU2A5.js';
11
+ import { ADDED_USER, shellQuote, GH_CONFIG_YML, ghHostsYml, firstLine, provisionWithFreshFallback, itemTag, hasClaudeCredential, AssetError, obtainImage, taggedLog, planSavedState, clockOf, savedStateBase, savedStatesDir, ensureRootfs, makeBuildsDirPrivate, gitRemoteFor, startServicesFor, createLeaseChannel, createBuildDisk, machineConfig, startJailedInto, resolveAgentUser, AgentUserError, agentUidOf, userIdChangedReason, runBuildSteps, setupInputFor, runtimeStepInput, settleFailedSteps, keepRuntimeStep, keepMissingSetupScripts, createContainerRuntime, containerSenderCommand, hostCommandEnvironment, execArgv, signalInContainer, startHostServices, LEASE_SECONDS, itemScope, managedBuildSettingsFor, stopContainer, cleanupContainer, recordProofsInContainer, PROOFS_LOG, outOfMemoryReason, closeHostBuild, dropManagedClaudeKey, dropManagedBuildSettings, startCheckContainer, ranRuntimeStep, provisionRuntimes, lifecycleSteps, lifecycleFailureReason, runSetupScripts, writeEvalInput, DeliveryFailure, EVAL_INPUT_NAME, syncInContainer, copyTranscriptsFromContainer, senderAliveScript, discardUnusableState, MANAGED_UNJAILED_REASON, uidFromProbe, saveAndPrune, managedMachineLimits, withFactoryHosts, helperFirecrackerNote, said, managedClaudeKeyValuesFor, managedBuildSettingValuesFor, managedClaudeKeyValues, managedBuildSettingValues, stopJailed, deleteBuildDisk, RECORD_PROOFS_ARGV, managedClaudeKeyFor, ROOT_DISK_ID_PREFIX, copyTranscripts, writeRecord, containerJudgeEnvironment, deleteRecord, senderSignalScript, copyJudgeTree } from './chunk-I35CNSPC.js';
12
+ import { fetchCommit, readBranchHead, diffBetween } from './chunk-QTNWAV23.js';
13
+ import { isSameProcess, startTimeOf } from './chunk-JBJTC3UU.js';
13
14
  import { waitForAgent, vmExecArgs } from './chunk-5W2YSWIW.js';
14
15
  import { socketPathProblem, vsockLinks, LEASE_LINK, linkVsockSockets } from './chunk-ROQPDCRU.js';
15
- import { describeCallFailure, resolveGoverningSource, prefetchGovernedContext, refusalCode, removeStagedContext, stageGovernedContext, pinnedSourceOf, commandWithShim, logStamp, createRunnerLog, formatDuration, removeKeptContext, retrySend, formatClock, keptContextTree, WORKFLOW_PERMISSION_REASON } from './chunk-DCBFUUDL.js';
16
- import { imageBuildOf, isBuiltinContainer, isBuiltinProcess, isBuiltinVm, egressSummary, DEFAULT_CHECK_TIME_LIMIT_MINUTES, optionalEgress } from './chunk-YF7W7B7Y.js';
17
- import { formatBytes, DEFAULT_CACHE_DISK, allocatedBytes } from './chunk-RRXS4CWE.js';
18
- import { HASH_ARGV, parseProgramHash, JUDGE_PROGRAM, writeJobFile, readJobFile, parseSize, identityScript, identityArgs, parseIdentity, mountableHome, homeCopyScript, homeCopyArgs, childEnvironment, withAnswerProtocol, judgeCommand, MAX_REPORT_BYTES, JUDGE_MAX_TURNS, JUDGE_DIR, COMMAND_DIR, MAX_ITEMS_BYTES } from './chunk-P2PNBDUT.js';
16
+ import { describeCallFailure, resolveGoverningSource, prefetchGovernedContext, refusalCode, removeStagedContext, stageGovernedContext, pinnedSourceOf, commandWithShim, logStamp, createRunnerLog, formatDuration, removeKeptContext, retrySend, formatClock, keptContextTree, WORKFLOW_PERMISSION_REASON } from './chunk-EFZM7UOP.js';
17
+ import { claimCalls, spoolHomeFor, itemCalls, claimItem, leftByRunnerKey } from './chunk-XKV6HXKD.js';
18
+ import { imageBuildOf, isBuiltinContainer, isBuiltinProcess, isBuiltinVm, egressSummary, DEFAULT_CHECK_TIME_LIMIT_MINUTES, DEFAULT_SETUP_MINUTES, optionalEgress } from './chunk-BWJRNMZZ.js';
19
+ import { formatBytes, DEFAULT_CACHE_DISK, allocatedBytes } from './chunk-6JDEP42Z.js';
20
+ import { HASH_ARGV, parseProgramHash, JUDGE_PROGRAM, writeJobFile, readJobFile, parseSize, identityScript, identityArgs, parseIdentity, mountableHome, homeCopyScript, homeCopyArgs, childEnvironment, withAnswerProtocol, judgeCommand, MAX_REPORT_BYTES, JUDGE_MAX_TURNS, JUDGE_DIR, COMMAND_DIR, MAX_ITEMS_BYTES } from './chunk-LLQGVGFO.js';
19
21
  import { CLAUDE_CODE_VERSION, FIRECRACKER_VERSION } from './chunk-D3CT6XQ4.js';
20
- import { isSameProcess, startTimeOf } from './chunk-JBJTC3UU.js';
21
- import { WorkCommandError, postJson, isSignatureRefusal, getJson } from './chunk-XDAMLX2L.js';
22
- import { planArtifactUpload } from './chunk-VEVNGDTP.js';
23
- import { readCloudConfig } from './chunk-PJDQPF5N.js';
24
- import { signerFor } from './chunk-5TXQFZHY.js';
25
- import { AGENTS_SKILLS_BASE, OUTERLAYER_SKILLS_BASE, resolvePackRoot } from './chunk-HH3BQG65.js';
26
- import { scrubText } from './chunk-GH2HEEOH.js';
22
+ import { WorkCommandError, postJson, isSignatureRefusal, getJson } from './chunk-HUS3GYCX.js';
23
+ import { planArtifactUpload } from './chunk-PDK35AR4.js';
24
+ import { readCloudConfig } from './chunk-HWVMRETT.js';
25
+ import { signerFor } from './chunk-QOVUDIUI.js';
26
+ import { AGENTS_SKILLS_BASE, OUTERLAYER_SKILLS_BASE, resolvePackRoot } from './chunk-UPRZREBO.js';
27
+ import { scrubText } from './chunk-TV2OQUWE.js';
27
28
  import { MAINTAINED_SKILLS } from './chunk-CDDED64E.js';
28
29
  import { resolveVersion } from './chunk-RA3O54FC.js';
29
- import { parsePolicy } from './chunk-2EEW6FJN.js';
30
- import { CheckItemsSchema } from './chunk-IXRUVR25.js';
31
- import { homeFromEnv } from './chunk-VNVZDWO3.js';
32
- import { RUNNER_FILE_MODE, runnerDir, buildDir, vsockPath, jobConsolePath } from './chunk-S6UM3N4R.js';
33
- import { JOB_MOUNT, repositoriesOf, primaryOf, buildEnvironment, CHECKOUT_DIR, claudeCredential, AGENT_CREDENTIAL_MISSING, sharedUserEnvironment, headerVariables, authorEnvironment, withTunnelRecord, commitIdentityRecord, RELAY_PORT, repositoryPath, lifecycleWorkdir, CHECK_ITEMS_FILE, fdName, BUILD_HOME, CLAUDE_CREDENTIAL_VARIABLES, currentClaudeCredential, removedClaudeCredentialValues, managedClaudeCredential, checkEnvironment, withMiseVariables, EVAL_INPUT_DIR } from './chunk-YLPJOUVF.js';
30
+ import { parsePolicy } from './chunk-5FWBAM6O.js';
31
+ import { CheckItemsSchema } from './chunk-YTTESG7K.js';
32
+ import { homeFromEnv } from './chunk-352DHUTP.js';
33
+ import { RUNNER_FILE_MODE, runnerDir, buildDir, orgStoreIn, vsockPath, jobConsolePath, orgHomeDir } from './chunk-HSE2LOWO.js';
34
+ import { JOB_MOUNT, repositoriesOf, primaryOf, buildEnvironment, CHECKOUT_DIR, claudeCredential, AGENT_CREDENTIAL_MISSING, sharedUserEnvironment, headerVariables, authorEnvironment, withTunnelRecord, commitIdentityRecord, RELAY_PORT, repositoryPath, lifecycleWorkdir, CHECK_ITEMS_FILE, fdName, BUILD_HOME, CLAUDE_CREDENTIAL_VARIABLES, currentClaudeCredential, removedClaudeCredentialValues, managedClaudeCredential, checkEnvironment, EVAL_INPUT_DIR, withMiseVariables } from './chunk-YLPJOUVF.js';
34
35
  import { RUNNER_WORDED_REASONS, UNKNOWN_TRACKING_REASON } from './chunk-MESOOLF4.js';
35
36
  import { randomBytes, createHash } from 'crypto';
36
37
  import { rmSync, existsSync, statSync, appendFileSync, mkdirSync, chmodSync, writeFileSync, openSync, closeSync, readFileSync, readdirSync, createReadStream, lstatSync, realpathSync, writeSync, renameSync, fstatSync, readSync } from 'fs';
@@ -311,14 +312,18 @@ function guestPortFor(runtime, state) {
311
312
  stream: (argv, io) => runtime.vm.execStream(state.vsockPath, { argv, user: "root", cwd: "/", env: { PATH: ROOT_PATH } }, io)
312
313
  };
313
314
  }
314
- function stepExecFor(input) {
315
+ function guestExecFor(input) {
315
316
  return async (argv, workdir, opts) => {
316
317
  const signal = opts?.timeoutMs === void 0 ? void 0 : AbortSignal.timeout(opts.timeoutMs);
317
318
  const ran = await input.vm.exec(input.vsockPath, input.request(argv, workdir, opts?.variables), signal === void 0 ? void 0 : { signal });
318
- if (opts?.quiet !== true) appendFileSync(input.logPath, ran.stdout + ran.stderr);
319
+ if (opts?.logPath !== void 0) appendFileSync(opts.logPath, ran.stdout + ran.stderr);
319
320
  return signal?.aborted === true ? { ...ran, timedOut: true } : ran;
320
321
  };
321
322
  }
323
+ function stepExecFor(input) {
324
+ const exec = guestExecFor(input);
325
+ return (argv, workdir, opts) => exec(argv, workdir, { ...opts?.quiet === true ? {} : { logPath: input.logPath }, timeoutMs: opts?.timeoutMs, variables: opts?.variables });
326
+ }
322
327
  function asRoot(runtime, state, argv, stdin) {
323
328
  return runtime.vm.exec(state.vsockPath, { argv, user: "root", cwd: "/", env: { PATH: ROOT_PATH } }, stdin === void 0 ? void 0 : { stdin });
324
329
  }
@@ -428,7 +433,7 @@ async function provisionMicroVm(input) {
428
433
  async function provisionMicroVmOnce(input, allowRestore) {
429
434
  const { config, runtime, item, itemKey, jobDir, log, tokens } = input;
430
435
  const { vm } = runtime;
431
- const tag = `#${item.number}`;
436
+ const tag = itemTag({ item: item.number, organizationId: input.organizationId, claimId: input.claimId });
432
437
  const logPath = join(jobDir, "provision.log");
433
438
  const fail = (reason) => ({ ok: false, reason });
434
439
  if (!hasClaudeCredential(config, runtime.hostEnv, jobDir)) return fail(AGENT_CREDENTIAL_MISSING);
@@ -452,6 +457,7 @@ async function provisionMicroVmOnce(input, allowRestore) {
452
457
  if (governingSource.kind === "governed") {
453
458
  const unfetched = await prefetchGovernedContext({
454
459
  configPath: config.configPath,
460
+ ...input.organizationId === void 0 ? {} : { organizationId: input.organizationId },
455
461
  repository,
456
462
  source: governingSource,
457
463
  controlPlaneUrl,
@@ -476,6 +482,7 @@ async function provisionMicroVmOnce(input, allowRestore) {
476
482
  repository: governingSource.kind === "governed" ? governingSource.repository : repository,
477
483
  pinned: governingSource.kind === "governed" ? { commit: governingSource.sha, ref: governingSource.ref } : void 0,
478
484
  governedRepository: repository,
485
+ ...input.organizationId === void 0 ? {} : { organizationId: input.organizationId },
479
486
  tag,
480
487
  log,
481
488
  aborted: input.aborted,
@@ -564,7 +571,7 @@ async function provisionMicroVmOnce(input, allowRestore) {
564
571
  imageConfig = { env: madeInBuilder.env, user: madeInBuilder.user };
565
572
  } else {
566
573
  try {
567
- state.rootfs = await ensureRootfs({ host: vm.rootfs, runnerDir: runnerDirPath, imageId: report.imageId, memoryBytes: limits.memoryBytes });
574
+ state.rootfs = await ensureRootfs({ host: vm.rootfs, runnerDir: orgStoreIn(runnerDirPath, input.organizationId), imageId: report.imageId, memoryBytes: limits.memoryBytes });
568
575
  imageConfig = await vm.rootfs.imageConfig(report.imageId);
569
576
  } catch (err) {
570
577
  return bail(`the image could not be converted to a root disk: ${describeCallFailure(err)}`);
@@ -580,7 +587,7 @@ async function provisionMicroVmOnce(input, allowRestore) {
580
587
  makeBuildsDirPrivate(buildDir2);
581
588
  let services;
582
589
  try {
583
- const gitRemote = gitRemoteFor(runtime, { repositories, tokens, buildDir: buildDir2, log: (line) => log.line(`${tag} ${line}`) });
590
+ const gitRemote = gitRemoteFor(runtime, { repositories, tokens, buildDir: buildDir2, organizationId: input.organizationId, log: (line) => log.line(`${tag} ${line}`) });
584
591
  services = await startServicesFor(runtime, config, buildDir2, jobDir, itemKey, true, gitRemote, "socket", void 0, void 0, (line) => log.line(`${tag} ${line}`));
585
592
  runtime.tunnels.set(buildId, services);
586
593
  } catch (err) {
@@ -759,6 +766,7 @@ async function provisionMicroVmOnce(input, allowRestore) {
759
766
  aborted: input.aborted,
760
767
  stageContext: () => stageGovernedContext({
761
768
  config,
769
+ ...input.organizationId === void 0 ? {} : { organizationId: input.organizationId },
762
770
  repository,
763
771
  source: pinnedSourceOf(governingSource),
764
772
  buildId,
@@ -825,7 +833,7 @@ function agentVersionOf(toolsJson) {
825
833
  function vmExecFor(input, argv) {
826
834
  const state = input.job.microvm;
827
835
  const env = buildEnvironment({
828
- config: input.config,
836
+ config: claimCalls(input.config, input.job),
829
837
  item: input.job.item,
830
838
  itemKey: input.job.itemKey,
831
839
  branch: input.job.branch,
@@ -857,7 +865,7 @@ function microVmCommandLine(input) {
857
865
  async function startMicroVmCommand(input) {
858
866
  const state = input.job.microvm;
859
867
  const env = buildEnvironment({
860
- config: input.config,
868
+ config: claimCalls(input.config, input.job),
861
869
  item: input.job.item,
862
870
  itemKey: input.job.itemKey,
863
871
  branch: input.job.branch,
@@ -908,7 +916,7 @@ async function runCliInMicroVm(input, argv, logName, goneReason) {
908
916
  if (!isRunning(runtime, state)) return { ok: false, reason: goneReason };
909
917
  try {
910
918
  const env = buildEnvironment({
911
- config: input.config,
919
+ config: claimCalls(input.config, job),
912
920
  item: job.item,
913
921
  itemKey: job.itemKey,
914
922
  branch: job.branch,
@@ -1044,7 +1052,7 @@ function microVmJudgeEnvironment(input) {
1044
1052
  async function startCheckMicroVm(input) {
1045
1053
  const { config, runtime, job, jobDir, tokens, log } = input;
1046
1054
  const { vm } = runtime;
1047
- const tag = `#${job.item}`;
1055
+ const tag = `${itemTag(job)}`;
1048
1056
  const limits = machineLimits(config, jobDir);
1049
1057
  const built = job.microvm;
1050
1058
  const repository = built?.repository ?? job.repository;
@@ -1096,7 +1104,7 @@ async function startCheckMicroVm(input) {
1096
1104
  state.rootfs = built.rootfs;
1097
1105
  } else {
1098
1106
  try {
1099
- state.rootfs = await ensureRootfs({ host: vm.rootfs, runnerDir: runnerDirPath, imageId: built.imageId, memoryBytes: limits.memoryBytes });
1107
+ state.rootfs = await ensureRootfs({ host: vm.rootfs, runnerDir: orgStoreIn(runnerDirPath, job.organizationId), imageId: built.imageId, memoryBytes: limits.memoryBytes });
1100
1108
  } catch (err) {
1101
1109
  return fail(`the image could not be converted to a root disk: ${describeCallFailure(err)}`);
1102
1110
  }
@@ -1111,6 +1119,7 @@ async function startCheckMicroVm(input) {
1111
1119
  repositories: repositoriesOf({ repositories: job.repositories, repository, branch }),
1112
1120
  tokens,
1113
1121
  buildDir: buildDir2,
1122
+ organizationId: job.organizationId,
1114
1123
  log: (line) => log.line(`${tag} ${line}`),
1115
1124
  readOnly: true
1116
1125
  });
@@ -1204,11 +1213,11 @@ async function startCheckMicroVm(input) {
1204
1213
  environment: {
1205
1214
  state,
1206
1215
  evalInput: { dir: evalInput.dir, deliver: deliverEvalInput },
1207
- exec: async (argv, workdir, opts) => {
1208
- const ran = await vm.exec(state.vsockPath, { argv, user: agentUser, cwd: workdir, env: execEnvironment(state.imageEnv, withMiseVariables(env, opts?.variables)) });
1209
- if (opts?.logPath !== void 0) appendFileSync(opts.logPath, ran.stdout + ran.stderr);
1210
- return ran;
1211
- },
1216
+ exec: guestExecFor({
1217
+ vm,
1218
+ vsockPath: state.vsockPath,
1219
+ request: (argv, workdir, variables) => ({ argv, user: agentUser, cwd: workdir, env: execEnvironment(state.imageEnv, withMiseVariables(env, variables)) })
1220
+ }),
1212
1221
  restart: async () => {
1213
1222
  try {
1214
1223
  if (state.jailed !== void 0) await stopJailed(vm.helper, state);
@@ -1360,6 +1369,14 @@ async function readWorkItem(config, item, fetchImpl) {
1360
1369
  const { data } = await getJson(config.url, `/v1/work-items/${item}`, config.apiKey, config.appId, fetchImpl, await signerFor(config.configPath));
1361
1370
  return data;
1362
1371
  }
1372
+ function declaredPullRequest(workItem, repository) {
1373
+ const declared = fields(workItem).pullRequests;
1374
+ if (!Array.isArray(declared)) return void 0;
1375
+ const wanted = repository.toLowerCase();
1376
+ const matching = declared.map((entry) => fields(entry)).filter((entry) => typeof entry.repository === "string" && entry.repository.toLowerCase() === wanted && typeof entry.prNumber === "number" && Number.isInteger(entry.prNumber) && entry.prNumber > 0);
1377
+ const chosen = matching.find((entry) => entry.state === "open") ?? matching[0];
1378
+ return chosen === void 0 ? void 0 : chosen.prNumber;
1379
+ }
1363
1380
  async function readItemEvaluation(config, item, fetchImpl) {
1364
1381
  try {
1365
1382
  const body = fields(await readWorkItem(config, item, fetchImpl));
@@ -1502,7 +1519,7 @@ var exitsLogged = /* @__PURE__ */ new Map();
1502
1519
  var BUILD_HOME2 = "/build/home";
1503
1520
  async function startSender(input) {
1504
1521
  const { config, job, jobDir, deps } = input;
1505
- const tag = `#${job.item}`;
1522
+ const tag = `${itemTag(job)}`;
1506
1523
  if (job.itemKey === void 0) return void 0;
1507
1524
  const spawnFn = deps.spawnFn ?? spawn;
1508
1525
  try {
@@ -1545,7 +1562,7 @@ function launchFor(config, job, jobDir, deps) {
1545
1562
  if (job.container !== void 0) {
1546
1563
  return { ...containerSenderCommand({ job, runtime: deps.runtime ?? createContainerRuntime(), config }), cwd: jobDir };
1547
1564
  }
1548
- const env = jobEnv(config, job.item, job.itemKey, jobDir, process.env, job.branch, job.commitIdentity?.author);
1565
+ const env = jobEnv(claimCalls(config, job), job.item, job.itemKey, jobDir, process.env, job.branch, job.commitIdentity?.author, spoolHomeFor(config, job));
1549
1566
  const build = job.build;
1550
1567
  const hostEnv = build === void 0 ? env : hostCommandEnvironment(env, build, config, job.commitIdentity?.hooksPath);
1551
1568
  if (build?.exec !== void 0) {
@@ -1569,11 +1586,11 @@ async function restartSender(input) {
1569
1586
  const deadline = (deps.waitMs ?? STOP_WAIT_MS) / POLL_MS;
1570
1587
  for (let waited = 0; await running() && waited < deadline; waited += 1) await sleep(POLL_MS);
1571
1588
  if (await running()) {
1572
- deps.log.error(`#${job.item} the session sender an earlier runner left did not stop in time \xB7 killing it`);
1589
+ deps.log.error(`${itemTag(job)} the session sender an earlier runner left did not stop in time \xB7 killing it`);
1573
1590
  await signalInContainer(runtime, state, pidfile, "KILL");
1574
1591
  }
1575
1592
  } catch (err) {
1576
- deps.log.error(`#${job.item} stopping the session sender an earlier runner left failed: ${describeCallFailure(err)} \xB7 continuing`);
1593
+ deps.log.error(`${itemTag(job)} stopping the session sender an earlier runner left failed: ${describeCallFailure(err)} \xB7 continuing`);
1577
1594
  }
1578
1595
  }
1579
1596
  return startSender(input);
@@ -1622,7 +1639,7 @@ async function stopSender(input) {
1622
1639
  const { job, deps } = input;
1623
1640
  const sender = job.sender;
1624
1641
  if (sender === void 0) return;
1625
- const tag = `#${job.item}`;
1642
+ const tag = `${itemTag(job)}`;
1626
1643
  const sleep = deps.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
1627
1644
  const inContainer = job.container === void 0 ? void 0 : { state: job.container, runtime: deps.runtime ?? createContainerRuntime(), pidfile: senderPidfile(BUILD_HOME2, Number(job.item)) };
1628
1645
  const inGuest = job.microvm === void 0 ? void 0 : { state: job.microvm, runtime: deps.runtime ?? createContainerRuntime(), pidfile: senderPidfile(BUILD_HOME2, Number(job.item)) };
@@ -1658,23 +1675,26 @@ function isTailedStage(stage) {
1658
1675
  }
1659
1676
  var PROVISION_PROBLEM = /\b(warn(ing)?|error|fail(ed|ure)?|refused)\b/i;
1660
1677
  var READ_LIMIT_BYTES = 1048576;
1661
- var ITEM_LINE = /^#(\d+)\b/;
1678
+ var ITEM_LINE = /^#(\d+(?:@[A-Za-z0-9_-]+)?)(?![A-Za-z0-9_@-])/;
1679
+ function keyOf(item, scope) {
1680
+ return scope === void 0 ? String(Number(item)) : `${Number(item)}@${scope}`;
1681
+ }
1662
1682
  var AttemptLogBook = class {
1663
1683
  constructor(now = () => /* @__PURE__ */ new Date()) {
1664
1684
  this.now = now;
1665
1685
  this.dirs = /* @__PURE__ */ new Map();
1666
1686
  this.lastByKey = /* @__PURE__ */ new Map();
1667
1687
  }
1668
- /** Starts keeping lines for `item` in `jobDirPath`. Idempotent. */
1669
- open(item, jobDirPath) {
1670
- this.dirs.set(Number(item), jobDirPath);
1688
+ /** Starts keeping lines for `item` in `jobDirPath`. Idempotent. A fleet build passes the `scope` of its organization. */
1689
+ open(item, jobDirPath, scope) {
1690
+ this.dirs.set(keyOf(item, scope), jobDirPath);
1671
1691
  }
1672
1692
  /** Stops keeping lines for `item`; its file stays on disk until housekeeping removes the job directory. */
1673
- close(item) {
1674
- const number = Number(item);
1675
- this.dirs.delete(number);
1676
- for (const key of [...this.lastByKey.keys()]) {
1677
- if (key.startsWith(`${number}:`)) this.lastByKey.delete(key);
1693
+ close(item, scope) {
1694
+ const key = keyOf(item, scope);
1695
+ this.dirs.delete(key);
1696
+ for (const slot of [...this.lastByKey.keys()]) {
1697
+ if (slot.startsWith(`${key}:`)) this.lastByKey.delete(slot);
1678
1698
  }
1679
1699
  }
1680
1700
  /** The log with every line it writes for an open item also kept in that item's file. */
@@ -1691,20 +1711,21 @@ var AttemptLogBook = class {
1691
1711
  };
1692
1712
  }
1693
1713
  /** One line for `item` that does not itself start with its number. */
1694
- note(item, text2) {
1695
- this.append(Number(item), text2);
1714
+ note(item, text2, scope) {
1715
+ this.append(keyOf(item, scope), text2);
1696
1716
  }
1697
1717
  /** One line, written only when `text` differs from the last one written under `key` for the item. */
1698
- noteChanged(item, key, text2) {
1699
- const number = Number(item);
1700
- const slot = `${number}:${key}`;
1718
+ noteChanged(item, key, text2, scope) {
1719
+ const slot = `${keyOf(item, scope)}:${key}`;
1701
1720
  if (this.lastByKey.get(slot) === text2) return;
1702
1721
  this.lastByKey.set(slot, text2);
1703
- this.append(number, text2);
1722
+ this.append(keyOf(item, scope), text2);
1704
1723
  }
1705
1724
  keepItemLine(text2) {
1706
1725
  const match = ITEM_LINE.exec(text2);
1707
- if (match !== null) this.append(Number(match[1]), text2);
1726
+ if (match === null) return;
1727
+ const [number = "", scope] = match[1].split("@");
1728
+ this.append(keyOf(number, scope), text2);
1708
1729
  }
1709
1730
  append(item, text2) {
1710
1731
  const dir = this.dirs.get(item);
@@ -1912,6 +1933,32 @@ function testFilesIn(root, isTest, limits = { files: MAX_TEST_FILES, bytes: MAX_
1912
1933
  walk(root, "");
1913
1934
  return files;
1914
1935
  }
1936
+ function findIdsOutsideTestsIn(root, input, limits = { files: MAX_TEST_FILES, bytes: MAX_TEST_FILE_BYTES }) {
1937
+ const candidates = [];
1938
+ const walk = (dir, prefix) => {
1939
+ for (const name of readdirSync(dir)) {
1940
+ if (prefix === "" && name === ".git") continue;
1941
+ const path = join(dir, name);
1942
+ const rel = prefix === "" ? name : `${prefix}/${name}`;
1943
+ const stat = lstatSync(path);
1944
+ if (stat.isDirectory()) walk(path, rel);
1945
+ else if (stat.isFile() && isSearchCandidate({ path: rel, size: stat.size }, input, limits.bytes)) candidates.push({ path: rel, size: stat.size });
1946
+ }
1947
+ };
1948
+ walk(root, "");
1949
+ const scan = new IdScan(input.finder, input.ids);
1950
+ for (const { path } of firstInPathOrder(candidates, limits.files)) {
1951
+ if (scan.complete) break;
1952
+ let contents;
1953
+ try {
1954
+ contents = readFileSync(join(root, path), "utf8");
1955
+ } catch {
1956
+ continue;
1957
+ }
1958
+ scan.offer(path, contents);
1959
+ }
1960
+ return scan.result();
1961
+ }
1915
1962
  function proofsFileIn(root) {
1916
1963
  const path = join(root, ".outerlayer-proofs.yaml");
1917
1964
  try {
@@ -1941,18 +1988,23 @@ async function hostPassedNames(config, item, fetchImpl) {
1941
1988
  function environmentFor(input) {
1942
1989
  const { config, job, jobDir, deps } = input;
1943
1990
  if (deps.judgeEnvironment !== void 0) return deps.judgeEnvironment;
1944
- if (job.container !== void 0) return containerJudgeEnvironment({ runtime: deps.runtime, config, job, jobDir, log: (line) => deps.log.line(`#${job.item} ${line}`) });
1991
+ if (job.container !== void 0) return containerJudgeEnvironment({ runtime: deps.runtime, config, job, jobDir, log: (line) => deps.log.line(`${itemTag(job)} ${line}`) });
1945
1992
  if (job.microvm !== void 0) return microVmJudgeEnvironment({ runtime: deps.runtime, job, jobDir });
1946
1993
  return void 0;
1947
1994
  }
1948
1995
  async function runJudge(input) {
1949
1996
  const { config, job, jobDir, deps } = input;
1950
1997
  const { runtime, log } = deps;
1951
- const tag = `#${job.item}`;
1998
+ const tag = `${itemTag(job)}`;
1952
1999
  const now = deps.now ?? (() => /* @__PURE__ */ new Date());
1953
2000
  const repository = job.repository ?? job.container?.repository;
1954
2001
  if (repository === void 0) return;
1955
2002
  const repo = repository;
2003
+ let itemRead;
2004
+ const readItem = () => itemRead ??= readWorkItem(itemCalls(config, job), job.item, deps.fetchImpl).catch((err) => {
2005
+ itemRead = void 0;
2006
+ throw err;
2007
+ });
1956
2008
  const tokens = runtime.credentials.get(jobDir);
1957
2009
  let readToken;
1958
2010
  try {
@@ -1976,12 +2028,12 @@ async function runJudge(input) {
1976
2028
  rmSync(scratch, { recursive: true, force: true });
1977
2029
  log.line(`${tag} judge not run: the definitions could not be read: ${definitions.reason}`);
1978
2030
  job.judgeNotRun = `the definitions could not be read: ${definitions.reason}`;
1979
- const passed = await retrySend(() => hostPassedNames(config, job.item, deps.fetchImpl), { now: deps.now });
2031
+ const passed = await retrySend(() => hostPassedNames(itemCalls(config, job), job.item, deps.fetchImpl), { now: deps.now });
1980
2032
  if (!passed.ok) {
1981
2033
  log.error(`${tag} the item's host results could not be read, so none was failed: ${passed.reason}`);
1982
2034
  return;
1983
2035
  }
1984
- const record2 = makeRecorder({ config, job, deps });
2036
+ const record2 = makeRecorder({ config, job, jobDir, deps });
1985
2037
  for (const name of passed.value) await record2(name, "fail", `the definitions could not be read: ${definitions.reason}`, { idTag: "judge-unread" });
1986
2038
  return;
1987
2039
  }
@@ -1995,7 +2047,7 @@ async function runJudge(input) {
1995
2047
  }
1996
2048
  log.line(`${tag} judge started (${checks.map((check) => check.name).join(", ")})`);
1997
2049
  const startedMs = now().getTime();
1998
- const record = makeRecorder({ config, job, deps });
2050
+ const record = makeRecorder({ config, job, jobDir, deps });
1999
2051
  const fail = (check, reason) => {
2000
2052
  log.error(`${tag} judge failed: ${reason}`);
2001
2053
  return record(check.name, "fail", reason);
@@ -2042,7 +2094,7 @@ async function runJudge(input) {
2042
2094
  if (check.judge.subjects === "criteria") {
2043
2095
  let workItem;
2044
2096
  try {
2045
- workItem = await readWorkItem(config, job.item, deps.fetchImpl);
2097
+ workItem = await readItem();
2046
2098
  } catch (err) {
2047
2099
  return await fail(check, `the item's criteria could not be read: ${describeCallFailure(err)}`);
2048
2100
  }
@@ -2055,11 +2107,21 @@ async function runJudge(input) {
2055
2107
  if (!fetched.ok) return await fail(check, `the build's tests could not be fetched: ${fetched.reason}`);
2056
2108
  const finder = await loadCitationFinder();
2057
2109
  const list = criteria ?? [];
2058
- const testFiles = testFilesIn(branchDir, testFileMatcher(finder, proofsFileIn(branchDir)));
2110
+ const isTest = testFileMatcher(finder, proofsFileIn(branchDir));
2111
+ const testFiles = testFilesIn(branchDir, isTest);
2059
2112
  const citations = finder.buildCitations({ ids: list.map((criterion) => criterion.id), files: testFiles, repository: repo, sha: head });
2060
2113
  const testFileText = new Map(testFiles.map((file) => [file.path, file.contents]));
2061
2114
  const inputs = new Map(list.map((criterion) => [criterion.id, criterionInputs({ brief, criterion, citations, testFiles: testFileText })]));
2062
- const plan = planCriteria({ criteria: list, citations, inputs, previous, noTestFiles: testFiles.length === 0 });
2115
+ const uncited = uncitedIds(list, citations);
2116
+ let foundIn;
2117
+ if (uncited.length > 0) {
2118
+ try {
2119
+ foundIn = (deps.findIdsOutside ?? findIdsOutsideTestsIn)(branchDir, { isTest, isSearchable: finder.isSearchableFile, finder, ids: uncited });
2120
+ } catch (err) {
2121
+ log.error(`${tag} the search for the ids of the criteria that no test cites failed: ${describeCallFailure(err)}`);
2122
+ }
2123
+ }
2124
+ const plan = planCriteria({ criteria: list, citations, inputs, previous, noTestFiles: testFiles.length === 0, foundIn });
2063
2125
  if (plan.toJudge.length < list.length) {
2064
2126
  log.line(`${tag} judge: ${plan.toJudge.length} of ${list.length} criteria to judge, ${list.length - plan.toJudge.length} settled without the judge`);
2065
2127
  }
@@ -2197,6 +2259,15 @@ async function runJudge(input) {
2197
2259
  return void 0;
2198
2260
  }
2199
2261
  const clientArtifactId = `host-judge-${createHash("sha256").update(`${job.claimId}:${job.startedAt}:${check.name}`).digest("hex").slice(0, 40)}`;
2262
+ const calls = itemCalls(config, job);
2263
+ let prNumber;
2264
+ if (config.fleet === true) {
2265
+ try {
2266
+ prNumber = declaredPullRequest(await readItem(), repo);
2267
+ } catch (err) {
2268
+ log.error(`${tag} the item's pull requests could not be read for the judge's report: ${describeCallFailure(err)}`);
2269
+ }
2270
+ }
2200
2271
  const request = {
2201
2272
  schemaVersion: 1,
2202
2273
  artifact: {
@@ -2211,12 +2282,13 @@ async function runJudge(input) {
2211
2282
  repository: repo,
2212
2283
  gitRepo: repo,
2213
2284
  gitBranch: at.branch,
2214
- commitSha: at.head
2285
+ commitSha: at.head,
2286
+ ...prNumber === void 0 ? {} : { prNumber }
2215
2287
  },
2216
2288
  blob: { data: bytes.toString("base64") }
2217
2289
  };
2218
2290
  const signer = await signerFor(config.configPath);
2219
- const sent = await retrySend(() => postJson(config.url, "/v1/artifacts", config.apiKey, config.appId, request, deps.fetchImpl, void 0, signer), { now: deps.now });
2291
+ const sent = await retrySend(() => postJson(calls.url, "/v1/artifacts", calls.apiKey, calls.appId, request, deps.fetchImpl, void 0, signer), { now: deps.now });
2220
2292
  if (!sent.ok) {
2221
2293
  log.error(`${tag} the judge's report could not be uploaded: ${sent.reason}`);
2222
2294
  return void 0;
@@ -2229,7 +2301,7 @@ async function runJudge(input) {
2229
2301
  // src/runner/job.ts
2230
2302
  var RENEW_INTERVAL_SECONDS = 300;
2231
2303
  var IDLE_CPU_USEC_PER_MINUTE_FLOOR = 2e6;
2232
- function jobEnv(config, item, itemKey, jobDirPath, baseEnv = process.env, branch, author) {
2304
+ function jobEnv(config, item, itemKey, jobDirPath, baseEnv = process.env, branch, author, spoolHome) {
2233
2305
  const secrets = new Set(headerVariables(config.build?.destinations));
2234
2306
  const passthrough = {};
2235
2307
  for (const [key, value] of Object.entries(baseEnv)) {
@@ -2250,6 +2322,8 @@ function jobEnv(config, item, itemKey, jobDirPath, baseEnv = process.env, branch
2250
2322
  // The branch the claim named. A hook that makes its own checkout puts it
2251
2323
  // on this branch, and the build's commands push to it.
2252
2324
  ...branch === void 0 ? {} : { OUTERLAYER_BRANCH: branch },
2325
+ // A fleet build's artifacts are spooled under its organization's folder, not the user's home.
2326
+ ...spoolHome === void 0 ? {} : { OUTERLAYER_SPOOL_HOME: spoolHome },
2253
2327
  // Git prefers these to any configuration, so a host's own git identity never authors a commit of the build.
2254
2328
  ...authorEnvironment(author)
2255
2329
  };
@@ -2414,14 +2488,15 @@ function mergeScrubConfig(a, b) {
2414
2488
  patterns: [...scrubList(a?.patterns), ...scrubList(b?.patterns)]
2415
2489
  };
2416
2490
  }
2417
- function releaseScrub(config, home) {
2491
+ function releaseScrub(config, home, jobDir) {
2418
2492
  const merged = mergeScrubConfig(config.scrub, readCloudConfig(home).scrub);
2419
2493
  const secrets = [...headerVariables(config.build?.destinations), ...CLAUDE_CREDENTIAL_VARIABLES].map((name) => process.env[name] ?? "");
2420
- const held = [currentClaudeCredential(process.env)?.value, ...removedClaudeCredentialValues(), ...managedClaudeKeyValues(), ...managedBuildSettingValues()].filter((value) => value !== void 0);
2494
+ const managed = config.fleet === true ? jobDir === void 0 ? [] : [...managedClaudeKeyValuesFor(jobDir), ...managedBuildSettingValuesFor(jobDir)] : [...managedClaudeKeyValues(), ...managedBuildSettingValues()];
2495
+ const held = [currentClaudeCredential(process.env)?.value, ...removedClaudeCredentialValues(), ...managed].filter((value) => value !== void 0);
2421
2496
  return { literals: [...scrubList(merged?.literals), ...secrets, ...held], patterns: scrubList(merged?.patterns) };
2422
2497
  }
2423
- function transcriptScrub(config, secrets) {
2424
- const base = releaseScrub(config, homeFromEnv());
2498
+ function transcriptScrub(config, secrets, jobDir) {
2499
+ const base = releaseScrub(config, homeFromEnv(), jobDir);
2425
2500
  return { literals: [...scrubList(base.literals), ...secrets.filter((secret) => secret !== void 0 && secret !== "")], patterns: scrubList(base.patterns) };
2426
2501
  }
2427
2502
  function stripUnsendableReasonChars(text2) {
@@ -2432,7 +2507,7 @@ function stripTerminalControls(text2) {
2432
2507
  }
2433
2508
  function releaseLogFor(jobDirPath, job, config) {
2434
2509
  const home = homeFromEnv();
2435
- installScrubContext(home, transcriptScrub(config, [job.itemKey, config.apiKey]));
2510
+ installScrubContext(home, transcriptScrub(config, [job.itemKey, config.apiKey], jobDirPath));
2436
2511
  return buildReleaseLog(jobDirPath, job.endStage, (text2) => scrubText(stripTerminalControls(stripUnsendableReasonChars(text2))));
2437
2512
  }
2438
2513
  function readReasonLine(jobDirPath, config, home = homeFromEnv()) {
@@ -2442,18 +2517,18 @@ function readReasonLine(jobDirPath, config, home = homeFromEnv()) {
2442
2517
  } catch {
2443
2518
  return void 0;
2444
2519
  }
2445
- return scrubReason(raw.split(/\r\n|\r|\n/)[0] ?? "", config, home);
2520
+ return scrubReason(raw.split(/\r\n|\r|\n/)[0] ?? "", config, home, jobDirPath);
2446
2521
  }
2447
- function scrubReason(line, config, home = homeFromEnv()) {
2448
- installScrubContext(home, releaseScrub(config, home));
2522
+ function scrubReason(line, config, home = homeFromEnv(), jobDir) {
2523
+ installScrubContext(home, releaseScrub(config, home, jobDir));
2449
2524
  const oneLine = scrubText(stripUnsendableReasonChars(line)).replace(/[\r\n]+/g, " ");
2450
2525
  const trimmed = cutReasonLine(oneLine).trim();
2451
2526
  return trimmed.length > 0 ? trimmed : void 0;
2452
2527
  }
2453
- function scrubTunnelRecord(record, config) {
2528
+ function scrubTunnelRecord(record, config, jobDir) {
2454
2529
  if (record === void 0) return void 0;
2455
2530
  const home = homeFromEnv();
2456
- installScrubContext(home, releaseScrub(config, home));
2531
+ installScrubContext(home, releaseScrub(config, home, jobDir));
2457
2532
  return {
2458
2533
  hosts: record.hosts.map((host) => scrubText(host)),
2459
2534
  hostsMore: record.hostsMore,
@@ -2628,9 +2703,9 @@ function wasAlreadyReleased(result, sentOutcome, sentAtMs) {
2628
2703
  const releasedAtMs = Date.parse(result.releasedAt);
2629
2704
  return Number.isFinite(releasedAtMs) && releasedAtMs < sentAtMs - RELEASE_SKEW_MS;
2630
2705
  }
2631
- function runSync(config, item, itemKey, workdir, jobDirPath, spawnFn = spawn, branch, author) {
2706
+ function runSync(config, item, itemKey, workdir, jobDirPath, spawnFn = spawn, branch, author, spoolHome) {
2632
2707
  return new Promise((resolve) => {
2633
- const env = jobEnv(config, item, itemKey, jobDirPath, process.env, branch, author);
2708
+ const env = jobEnv(config, item, itemKey, jobDirPath, process.env, branch, author, spoolHome);
2634
2709
  let child;
2635
2710
  try {
2636
2711
  child = spawnFn(process.execPath, [process.argv[1] ?? "outerlayer", "sync"], {
@@ -2652,7 +2727,7 @@ function runSync(config, item, itemKey, workdir, jobDirPath, spawnFn = spawn, br
2652
2727
  }
2653
2728
  async function runSyncViaExec(config, job, jobDirPath, spawnFn = spawn) {
2654
2729
  const build = job.build;
2655
- const env = hostCommandEnvironment(jobEnv(config, job.item, job.itemKey, jobDirPath, process.env, job.branch, job.commitIdentity?.author), build, config, job.commitIdentity?.hooksPath);
2730
+ const env = hostCommandEnvironment(jobEnv(claimCalls(config, job), job.item, job.itemKey, jobDirPath, process.env, job.branch, job.commitIdentity?.author, spoolHomeFor(config, job)), build, config, job.commitIdentity?.hooksPath);
2656
2731
  try {
2657
2732
  const result = await runHook(
2658
2733
  build.exec,
@@ -2670,7 +2745,7 @@ async function runSyncViaExec(config, job, jobDirPath, spawnFn = spawn) {
2670
2745
  }
2671
2746
  function runRecordProofs(config, job, jobDirPath, spawnFn = spawn) {
2672
2747
  return new Promise((resolve) => {
2673
- const env = jobEnv(config, job.item, job.itemKey, jobDirPath, process.env, job.branch, job.commitIdentity?.author);
2748
+ const env = jobEnv(claimCalls(config, job), job.item, job.itemKey, jobDirPath, process.env, job.branch, job.commitIdentity?.author, spoolHomeFor(config, job));
2674
2749
  let fd;
2675
2750
  let child;
2676
2751
  try {
@@ -2698,7 +2773,7 @@ function runRecordProofs(config, job, jobDirPath, spawnFn = spawn) {
2698
2773
  }
2699
2774
  async function runRecordProofsViaExec(config, job, jobDirPath, spawnFn = spawn) {
2700
2775
  const build = job.build;
2701
- const env = hostCommandEnvironment(jobEnv(config, job.item, job.itemKey, jobDirPath, process.env, job.branch, job.commitIdentity?.author), build, config, job.commitIdentity?.hooksPath);
2776
+ const env = hostCommandEnvironment(jobEnv(claimCalls(config, job), job.item, job.itemKey, jobDirPath, process.env, job.branch, job.commitIdentity?.author, spoolHomeFor(config, job)), build, config, job.commitIdentity?.hooksPath);
2702
2777
  try {
2703
2778
  const result = await runHook(build.exec, env, jobDirPath, join(jobDirPath, PROOFS_LOG), spawnFn, void 0, execArgv(job.workdir, [...RECORD_PROOFS_ARGV]));
2704
2779
  return result.code === 0 ? { ok: true } : { ok: false, reason: `exit ${result.code}` };
@@ -2756,8 +2831,8 @@ async function finishJob(job, jobDirPath, outcome, config, deps, ending) {
2756
2831
  const log = deps.log ?? createRunnerLog(now);
2757
2832
  const jobFilePath = join(jobDirPath, "job.json");
2758
2833
  const logPath = join(jobDirPath, "command.log");
2759
- const tag = `#${job.item}`;
2760
- deps.attemptLogs?.open(job.item, jobDirPath);
2834
+ const tag = `${itemTag(job)}`;
2835
+ deps.attemptLogs?.open(job.item, jobDirPath, itemScope(job));
2761
2836
  const valuesNotHeld = (job.managedVariables?.length ?? 0) > 0 && managedBuildSettingsFor(jobDirPath) === void 0;
2762
2837
  if (job.sender !== void 0) {
2763
2838
  await stopSender({ job, deps: { spawnFn, runtime: deps.container, log } });
@@ -2798,7 +2873,7 @@ async function finishJob(job, jobDirPath, outcome, config, deps, ending) {
2798
2873
  writeJobFile(jobFilePath, job);
2799
2874
  }
2800
2875
  if (outcome !== void 0 && ending?.reason !== void 0) {
2801
- job.reason = RUNNER_WORDED_REASONS.has(ending.reason) ? ending.reason : scrubReason(ending.reason, config);
2876
+ job.reason = RUNNER_WORDED_REASONS.has(ending.reason) ? ending.reason : scrubReason(ending.reason, config, void 0, jobDirPath);
2802
2877
  writeJobFile(jobFilePath, job);
2803
2878
  }
2804
2879
  const uploadSessions = async (workdir) => {
@@ -2813,11 +2888,11 @@ async function finishJob(job, jobDirPath, outcome, config, deps, ending) {
2813
2888
  } else {
2814
2889
  log.line(`${tag} sync started`);
2815
2890
  const startedMs = now().getTime();
2816
- const sync = build !== void 0 ? await syncInContainer({ config, runtime: build.runtime, job, jobDir: jobDirPath, log: (line) => log.line(`${tag} ${line}`) }) : vmBuild !== void 0 ? await syncInMicroVm({ config, runtime: vmBuild.runtime, job, jobDir: jobDirPath }) : job.build?.exec !== void 0 ? await runSyncViaExec(config, job, jobDirPath, spawnFn) : await runSync(config, job.item, job.itemKey, workdir, jobDirPath, spawnFn, job.branch, job.commitIdentity?.author);
2891
+ const sync = build !== void 0 ? await syncInContainer({ config, runtime: build.runtime, job, jobDir: jobDirPath, log: (line) => log.line(`${tag} ${line}`) }) : vmBuild !== void 0 ? await syncInMicroVm({ config, runtime: vmBuild.runtime, job, jobDir: jobDirPath }) : job.build?.exec !== void 0 ? await runSyncViaExec(config, job, jobDirPath, spawnFn) : await runSync(claimCalls(config, job), job.item, job.itemKey, workdir, jobDirPath, spawnFn, job.branch, job.commitIdentity?.author, spoolHomeFor(config, job));
2817
2892
  const took = formatDuration(now().getTime() - startedMs);
2818
2893
  if (sync.ok) log.line(`${tag} sync ok (${took})`);
2819
2894
  else log.error(`${tag} sync failed: ${sync.reason ?? "no reason given"} \xB7 continuing`);
2820
- const left = spooledArtifactIds(deps.home ?? homeFromEnv());
2895
+ const left = spooledArtifactIds(deps.home ?? (job.organizationId === void 0 ? homeFromEnv() : orgHomeDir(config.configPath, job.organizationId)));
2821
2896
  if (left.length > 0) {
2822
2897
  job.spooledArtifacts = left.slice(0, MAX_NAMED_SPOOLED);
2823
2898
  const named = job.spooledArtifacts.join(", ");
@@ -2864,7 +2939,7 @@ async function finishJob(job, jobDirPath, outcome, config, deps, ending) {
2864
2939
  log.error(`${tag} removing an earlier attempt's check environment failed: ${describeCallFailure(err)} \xB7 continuing`);
2865
2940
  }
2866
2941
  }
2867
- if (outcome === "ok" && !job.cleanupRan && job.proofsRan !== true && !valuesNotHeld && job.workdir !== void 0 && job.itemKey !== void 0 && await declaresRecordedProof(config, job.item, deps.fetchImpl)) {
2942
+ if (outcome === "ok" && !job.cleanupRan && job.proofsRan !== true && !valuesNotHeld && job.workdir !== void 0 && job.itemKey !== void 0 && await declaresRecordedProof(itemCalls(config, job), job.item, deps.fetchImpl)) {
2868
2943
  setStage(job, jobDirPath, "proofs");
2869
2944
  job.proofsRan = true;
2870
2945
  writeJobFile(jobFilePath, job);
@@ -2921,7 +2996,7 @@ async function finishJob(job, jobDirPath, outcome, config, deps, ending) {
2921
2996
  log.error(`${tag} could not read the build's memory events: ${describeCallFailure(err)} \xB7 continuing`);
2922
2997
  }
2923
2998
  if (outOfMemory !== void 0) {
2924
- job.reason = scrubReason(outOfMemory, config);
2999
+ job.reason = scrubReason(outOfMemory, config, void 0, jobDirPath);
2925
3000
  writeJobFile(jobFilePath, job);
2926
3001
  }
2927
3002
  }
@@ -2990,7 +3065,7 @@ async function finishJob(job, jobDirPath, outcome, config, deps, ending) {
2990
3065
  } else {
2991
3066
  if (!isBuiltinContainer(config.hooks.cleanup) && !isBuiltinProcess(config.hooks.cleanup) && !isBuiltinVm(config.hooks.cleanup)) {
2992
3067
  const cleanupEnv = {
2993
- ...jobEnv(config, job.item, job.itemKey, jobDirPath, process.env, job.branch, job.commitIdentity?.author),
3068
+ ...jobEnv(claimCalls(config, job), job.item, job.itemKey, jobDirPath, process.env, job.branch, job.commitIdentity?.author, spoolHomeFor(config, job)),
2994
3069
  ...job.build === void 0 ? {} : { OUTERLAYER_BUILD_DIR: job.build.buildDir },
2995
3070
  OUTERLAYER_OUTCOME: outcome ?? "",
2996
3071
  OUTERLAYER_LOG: logPath
@@ -3031,13 +3106,13 @@ async function finishJob(job, jobDirPath, outcome, config, deps, ending) {
3031
3106
  let verdictReason;
3032
3107
  if (outcome === "ok") {
3033
3108
  const decision = await settleVerdict({
3034
- read: () => readItemEvaluation(config, job.item, deps.fetchImpl),
3109
+ read: () => readItemEvaluation(itemCalls(config, job), job.item, deps.fetchImpl),
3035
3110
  now,
3036
3111
  sleep: deps.sleep ?? waitMs
3037
3112
  });
3038
3113
  if (decision.outcome === "incomplete") {
3039
3114
  const release2 = unfinishedRelease(
3040
- scrubReason(incompleteReason(decision.reason, job.judgeNotRun), config),
3115
+ scrubReason(incompleteReason(decision.reason, job.judgeNotRun), config, void 0, jobDirPath),
3041
3116
  deps.container?.credentials.get(jobDirPath)?.reason
3042
3117
  );
3043
3118
  outcome = release2.outcome;
@@ -3050,7 +3125,7 @@ async function finishJob(job, jobDirPath, outcome, config, deps, ending) {
3050
3125
  log.line(`${tag} report started \xB7 phase end`);
3051
3126
  const reportStartedMs = now().getTime();
3052
3127
  const reportEnv = {
3053
- ...jobEnv(config, job.item, job.itemKey, jobDirPath, process.env, job.branch, job.commitIdentity?.author),
3128
+ ...jobEnv(claimCalls(config, job), job.item, job.itemKey, jobDirPath, process.env, job.branch, job.commitIdentity?.author, spoolHomeFor(config, job)),
3054
3129
  OUTERLAYER_PHASE: "end",
3055
3130
  OUTERLAYER_OUTCOME: outcome ?? "",
3056
3131
  OUTERLAYER_LOG: logPath
@@ -3087,18 +3162,18 @@ async function finishJob(job, jobDirPath, outcome, config, deps, ending) {
3087
3162
  if (verdictReason !== void 0) {
3088
3163
  job.reason = verdictReason;
3089
3164
  } else if (outOfMemory !== void 0) {
3090
- job.reason = scrubReason(outOfMemory, config);
3165
+ job.reason = scrubReason(outOfMemory, config, void 0, jobDirPath);
3091
3166
  } else if (ending?.reason === void 0) {
3092
3167
  job.reason = (outcome === "ok" ? void 0 : held?.reason) ?? (isolated ? fromHook ?? job.reason : fromHook);
3093
3168
  }
3094
3169
  if (outcome === "failed" && job.reason === void 0 && job.commandEndReason !== void 0) {
3095
- job.reason = scrubReason(job.commandEndReason, config);
3170
+ job.reason = scrubReason(job.commandEndReason, config, void 0, jobDirPath);
3096
3171
  }
3097
3172
  const cliVersion = deps.cliVersion ?? resolveVersion();
3098
3173
  const base = job.environment ?? (job.microvm !== void 0 ? { isolation: "vm", cliVersion } : job.container === void 0 ? sharedUserEnvironment(cliVersion) : { isolation: "container", cliVersion });
3099
3174
  if (isolated || job.build !== void 0) {
3100
3175
  tunnelRecord ??= readTunnelRecord(join(jobDirPath, "tunnel.json"));
3101
- job.environment = withTunnelRecord(base, scrubTunnelRecord(tunnelRecord, config), !isolated);
3176
+ job.environment = withTunnelRecord(base, scrubTunnelRecord(tunnelRecord, config, jobDirPath), !isolated);
3102
3177
  } else {
3103
3178
  job.environment = base;
3104
3179
  }
@@ -3112,7 +3187,7 @@ async function finishJob(job, jobDirPath, outcome, config, deps, ending) {
3112
3187
  const runnerLog = valuesNotHeld ? `The runner sends no log for this attempt: ${VALUES_NOT_HELD}.
3113
3188
  ` : releaseLogFor(jobDirPath, job, config);
3114
3189
  const detail = outcome === void 0 ? { log: runnerLog } : { stage: job.endStage, exitCode: job.endExitCode, reason: job.reason, environment: job.environment, log: runnerLog };
3115
- const release = await retrySend(() => releaseLease(config, job.item, outcome, detail, deps.fetchImpl), {
3190
+ const release = await retrySend(() => releaseLease(claimCalls(config, job), claimItem(config, job), outcome, detail, deps.fetchImpl), {
3116
3191
  now: deps.now,
3117
3192
  sleep: deps.sleep
3118
3193
  });
@@ -3126,7 +3201,7 @@ async function finishJob(job, jobDirPath, outcome, config, deps, ending) {
3126
3201
  job.endedAt = endedAt.toISOString();
3127
3202
  job.releaseFailed = release.ok ? alreadyReleased ? ALREADY_RELEASED : void 0 : release.reason;
3128
3203
  writeJobFile(jobFilePath, job);
3129
- deps.attemptLogs?.close(job.item);
3204
+ deps.attemptLogs?.close(job.item, itemScope(job));
3130
3205
  const total = formatDuration(endedAt.getTime() - new Date(job.startedAt).getTime());
3131
3206
  if (alreadyReleased) {
3132
3207
  log.line(
@@ -3137,9 +3212,8 @@ async function finishJob(job, jobDirPath, outcome, config, deps, ending) {
3137
3212
  outcome === void 0 ? `${tag} released \xB7 not attempted (provision exit 75) \xB7 ${total}` : `${tag} released \xB7 outcome ${outcome} \xB7 ${total}${egressText(tunnelRecord)}`
3138
3213
  );
3139
3214
  } else {
3140
- log.error(
3141
- `${tag} release failed after ${release.attempts} attempt(s): ${release.reason}; the lease expires at ${formatClock(leaseExpiry(job, endedAt), endedAt)}${egressText(tunnelRecord)}`
3142
- );
3215
+ const lapse = release.code === "machine_revoked" ? "the gateway ended the lease when the machine was revoked" : `the lease expires at ${formatClock(leaseExpiry(job, endedAt), endedAt)}`;
3216
+ log.error(`${tag} release failed after ${release.attempts} attempt(s): ${release.reason}; ${lapse}${egressText(tunnelRecord)}`);
3143
3217
  }
3144
3218
  return job;
3145
3219
  }
@@ -3176,9 +3250,15 @@ async function retryFailedReleases(jobsDirPath, config, deps) {
3176
3250
  if (!job || job.releaseFailed === void 0 || job.releaseFailed === ALREADY_RELEASED || isUnfinished(job)) {
3177
3251
  continue;
3178
3252
  }
3253
+ if (leftByRunnerKey(config, job)) {
3254
+ rmSync(join(dirPath, SCRUBBED_RELEASE_LOG), { force: true });
3255
+ job.releaseFailed = void 0;
3256
+ writeJobFile(jobFilePath, job);
3257
+ continue;
3258
+ }
3179
3259
  const runnerLog = readScrubbedReleaseLog(dirPath) ?? releaseLogFor(dirPath, job, config);
3180
3260
  const detail = job.outcome === void 0 ? { log: runnerLog } : { stage: job.endStage, exitCode: job.endExitCode, reason: job.reason, environment: job.environment, log: runnerLog };
3181
- const release = await retrySend(() => releaseLease(config, job.item, job.outcome, detail, deps.fetchImpl), {
3261
+ const release = await retrySend(() => releaseLease(claimCalls(config, job), claimItem(config, job), job.outcome, detail, deps.fetchImpl), {
3182
3262
  now: deps.now,
3183
3263
  sleep: deps.sleep
3184
3264
  });
@@ -3244,6 +3324,17 @@ async function recoverLostJobs(jobsDirPath, config, deps) {
3244
3324
  const recovered = [];
3245
3325
  for (const { dirPath, job } of unfinishedJobs(jobsDirPath)) {
3246
3326
  if (!isReadable(job)) continue;
3327
+ if (leftByRunnerKey(config, job)) {
3328
+ (deps.log ?? createRunnerLog(deps.now ?? (() => /* @__PURE__ */ new Date()))).error(
3329
+ `${itemTag(job)} left by a runner key: a fleet runner cannot release its lease, which lapses by itself \xB7 closing its job file`
3330
+ );
3331
+ job.outcome = "interrupted";
3332
+ job.endedAt = (deps.now ?? (() => /* @__PURE__ */ new Date()))().toISOString();
3333
+ job.reason = "an unfinished build from a runner key; a fleet runner cannot release its lease";
3334
+ writeJobFile(join(dirPath, "job.json"), job);
3335
+ recovered.push(job);
3336
+ continue;
3337
+ }
3247
3338
  const tracking = trackingOf(job);
3248
3339
  if (tracking !== void 0 && tracking !== "container" && tracking !== "microvm") {
3249
3340
  recovered.push(await finishJob(job, dirPath, "interrupted", config, deps, { reason: UNKNOWN_TRACKING_REASON }));
@@ -3354,14 +3445,15 @@ function checksIn(root, log, tag) {
3354
3445
  }
3355
3446
  async function readDefinitions(input, repository, scratch, token, tokens) {
3356
3447
  const { config, job, deps } = input;
3357
- const tag = `#${job.item}`;
3448
+ const tag = `${itemTag(job)}`;
3358
3449
  const stage = deps.stage ?? stageGovernedContext;
3359
3450
  const controlPlaneUrl = (controlPlane) => deps.runtime.remoteFor?.(controlPlane) ?? `${deps.runtime.github.gitUrl}/${controlPlane}.git`;
3360
3451
  const governing = (job.container ?? job.microvm)?.governing;
3361
3452
  const kept = keptContextTree(input.jobDir, governing);
3362
3453
  if (kept !== void 0) return { ok: true, ...checksIn(kept, deps.log, tag) };
3363
3454
  const staged = await stage({
3364
- config,
3455
+ config: claimCalls(config, job),
3456
+ ...job.organizationId === void 0 ? {} : { organizationId: job.organizationId },
3365
3457
  repository,
3366
3458
  ...governing === void 0 ? {} : { source: { repository: governing.repository, ref: governing.ref, sha: governing.commit } },
3367
3459
  buildId: `checks-${randomBytes(4).toString("hex")}`,
@@ -3404,21 +3496,22 @@ function noCleanEnvironment(job) {
3404
3496
  return `the host has no clean environment for checks: this build ran under ${ran}, and checks run only in a new container or microVM from a build's image`;
3405
3497
  }
3406
3498
  function makeRecorder(input) {
3407
- const { config, job, deps } = input;
3408
- const tag = `#${job.item}`;
3499
+ const { config, job, deps, jobDir } = input;
3500
+ const tag = `${itemTag(job)}`;
3409
3501
  const now = deps.now ?? (() => /* @__PURE__ */ new Date());
3502
+ const calls = itemCalls(config, job);
3410
3503
  let signer;
3411
3504
  return async (name, result, sentence, opts = {}) => {
3412
3505
  signer ??= await signerFor(config.configPath);
3413
3506
  const keyTail = opts.keyTail ?? "";
3414
- const body = sentence === void 0 ? void 0 : cutReasonLine(`${scrubReason(sentence, config) ?? "check failed"}${keyTail}`);
3507
+ const body = sentence === void 0 ? void 0 : cutReasonLine(`${scrubReason(sentence, config, void 0, jobDir) ?? "check failed"}${keyTail}`);
3415
3508
  const clientEmitId = `host-${createHash("sha256").update(`${job.claimId}:${job.startedAt}:${name}${opts.idTag === void 0 ? "" : `:${opts.idTag}`}`).digest("hex").slice(0, 40)}`;
3416
3509
  const sent = await retrySend(
3417
3510
  () => postJson(
3418
- config.url,
3511
+ calls.url,
3419
3512
  "/v1/emitted-results",
3420
- config.apiKey,
3421
- config.appId,
3513
+ calls.apiKey,
3514
+ calls.appId,
3422
3515
  {
3423
3516
  schemaVersion: 1,
3424
3517
  // A field left undefined is not sent: the request is JSON.
@@ -3437,7 +3530,7 @@ function makeRecorder(input) {
3437
3530
  async function runHostChecks(input) {
3438
3531
  const { config, job, jobDir, deps } = input;
3439
3532
  const { runtime, log } = deps;
3440
- const tag = `#${job.item}`;
3533
+ const tag = `${itemTag(job)}`;
3441
3534
  const now = deps.now ?? (() => /* @__PURE__ */ new Date());
3442
3535
  const repository = job.repository ?? job.container?.repository;
3443
3536
  if (repository === void 0) return;
@@ -3472,7 +3565,7 @@ async function runHostChecks(input) {
3472
3565
  }
3473
3566
  log.line(`${tag} checks started (${checks.map((check) => check.name).join(", ")})`);
3474
3567
  const startedMs = now().getTime();
3475
- const recorder = makeRecorder({ config, job, deps });
3568
+ const recorder = makeRecorder({ config, job, jobDir, deps });
3476
3569
  const record = (check, result, sentence, keyTail = "", items) => recorder(check.name, result, sentence, { keyTail, items });
3477
3570
  const failAll = async (reason, keyTail = "") => {
3478
3571
  log.error(`${tag} checks failed: ${reason}${keyTail}`);
@@ -3534,7 +3627,7 @@ async function runHostChecks(input) {
3534
3627
  let variables;
3535
3628
  const setup = async () => {
3536
3629
  const started = job.microvm !== void 0 ? await startCheckMicroVm({
3537
- config,
3630
+ config: claimCalls(config, job),
3538
3631
  runtime,
3539
3632
  job,
3540
3633
  jobDir,
@@ -3626,6 +3719,17 @@ async function runHostChecks(input) {
3626
3719
  }
3627
3720
  if (typeof settled === "string") return await failAll(settled);
3628
3721
  const ready = settled;
3722
+ const setupMinutes = config.build?.setupMinutes ?? DEFAULT_SETUP_MINUTES;
3723
+ const prepared = await runSetupScripts({
3724
+ repositories: [...repositoriesToCheckOut.filter((entry) => entry.primary), ...repositoriesToCheckOut.filter((entry) => !entry.primary)],
3725
+ exec: (argv, workdir, opts) => ready.exec(argv, workdir, { logPath: opts?.quiet === true ? void 0 : environmentLog, timeoutMs: opts?.timeoutMs, variables }),
3726
+ log,
3727
+ tag: `${tag} checks`,
3728
+ timeoutMs: setupMinutes * 6e4,
3729
+ limitMinutes: setupMinutes,
3730
+ aborted: () => false
3731
+ });
3732
+ if (!prepared.ok) return await failAll(`the check environment could not be prepared: ${prepared.reason}`);
3629
3733
  try {
3630
3734
  await writeEvalInput({
3631
3735
  job,
@@ -3635,8 +3739,8 @@ async function runHostChecks(input) {
3635
3739
  readToken,
3636
3740
  branchHead: primaryHead ?? (job.container ?? job.microvm)?.startCommit ?? "",
3637
3741
  transcripts,
3638
- scrub: transcriptScrub(config, [config.apiKey, job.itemKey, readToken]),
3639
- readWorkItem: () => readWorkItem(config, job.item, deps.fetchImpl),
3742
+ scrub: transcriptScrub(config, [config.apiKey, job.itemKey, readToken], jobDir),
3743
+ readWorkItem: () => readWorkItem(itemCalls(config, job), job.item, deps.fetchImpl),
3640
3744
  fetchDiff: deps.fetchDiff ?? ((input2) => diffBetween(input2)),
3641
3745
  log
3642
3746
  });
@@ -3678,7 +3782,7 @@ async function runHostChecks(input) {
3678
3782
  continue;
3679
3783
  }
3680
3784
  const read = await ready.exec(["head", "-c", String(MAX_CHECK_ITEMS_BYTES + 1), CHECK_ITEMS_FILE], CHECKOUT_DIR);
3681
- const items = commandItems(read, (text2) => scrubReason(text2, config) ?? text2);
3785
+ const items = commandItems(read, (text2) => scrubReason(text2, config, void 0, jobDir) ?? text2);
3682
3786
  if (!items.ok) {
3683
3787
  await record(check, "fail", items.reason);
3684
3788
  continue;
@@ -3694,7 +3798,7 @@ async function runHostChecks(input) {
3694
3798
  continue;
3695
3799
  }
3696
3800
  const last = lastLine(outcome.stderr) ?? lastLine(outcome.stdout);
3697
- const scrubbed = last === void 0 ? void 0 : scrubReason(last, config);
3801
+ const scrubbed = last === void 0 ? void 0 : scrubReason(last, config, void 0, jobDir);
3698
3802
  await record(check, "fail", `exited ${outcome.status}${scrubbed === void 0 ? " with no output" : `: ${cutReasonLine(scrubbed, 140)}`}`, "", items.items);
3699
3803
  }
3700
3804
  } catch (err) {