@synopackageland/cli 0.4.0 → 0.4.1

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 (438) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +37 -0
  3. package/dist/build-spk/generator.js +3 -0
  4. package/dist/build-spk/notices.d.ts +5 -0
  5. package/dist/build-spk/notices.js +60 -0
  6. package/dist/cli.js +9 -2
  7. package/dist/error-registry.js +20 -0
  8. package/dist/init.d.ts +4 -0
  9. package/dist/init.js +20 -12
  10. package/dist/standalone/build.js +3 -1
  11. package/dist/standalone/daemon.d.ts +23 -0
  12. package/dist/standalone/daemon.js +114 -0
  13. package/dist/standalone/dsm-window.d.ts +1 -1
  14. package/dist/standalone/dsm-window.js +50 -10
  15. package/dist/standalone/helper-inventory.d.ts +16 -0
  16. package/dist/standalone/helper-inventory.js +2 -0
  17. package/dist/standalone/helper.d.ts +2 -12
  18. package/dist/standalone/helper.js +8 -7
  19. package/dist/standalone/host-adapter.d.ts +5 -0
  20. package/dist/standalone/host-adapter.js +148 -0
  21. package/dist/standalone/host-platform.d.ts +13 -0
  22. package/dist/standalone/host-platform.js +42 -0
  23. package/dist/standalone/host-types.d.ts +49 -0
  24. package/dist/standalone/host-types.js +1 -0
  25. package/dist/standalone/inspect-helper.d.ts +6 -0
  26. package/dist/standalone/inspect-helper.js +88 -0
  27. package/dist/standalone/inspect-spk.d.ts +2 -0
  28. package/dist/standalone/inspect-spk.js +49 -0
  29. package/dist/standalone/lifecycle-helper.d.ts +2 -0
  30. package/dist/standalone/lifecycle-helper.js +12 -0
  31. package/dist/standalone/lifecycle.d.ts +3 -0
  32. package/dist/standalone/lifecycle.js +53 -0
  33. package/dist/standalone/manifest.d.ts +2 -0
  34. package/dist/standalone/manifest.js +4 -1
  35. package/dist/standalone/reopen-events.d.ts +2 -0
  36. package/dist/standalone/reopen-events.js +28 -0
  37. package/dist/standalone/root-messages.js +9 -0
  38. package/dist/standalone/root-window.d.ts +4 -3
  39. package/dist/standalone/root-window.js +17 -5
  40. package/dist/standalone/spk.d.ts +4 -3
  41. package/dist/standalone/spk.js +20 -33
  42. package/dist/template-paths.d.ts +2 -0
  43. package/dist/template-paths.js +9 -0
  44. package/dist/templates/_daemon/fixture_linux_test.go +15 -0
  45. package/dist/templates/_daemon/fixture_other_test.go +7 -0
  46. package/dist/templates/_daemon/go.mod +3 -0
  47. package/dist/templates/_daemon/main.go +608 -0
  48. package/dist/templates/_daemon/main_test.go +242 -0
  49. package/dist/templates/_daemon/process_linux.go +55 -0
  50. package/dist/templates/_daemon/process_linux_test.go +161 -0
  51. package/dist/templates/_daemon/process_other.go +14 -0
  52. package/dist/templates/_daemon/testdata/child.go +41 -0
  53. package/dist/templates/_shared/GO-LICENSE +27 -0
  54. package/dist/templates/_shared/GO-PATENTS +22 -0
  55. package/dist/templates/_shared/LICENSES/TEMPLATE.txt +21 -0
  56. package/dist/templates/_shared/notice-overrides/index.json +14 -0
  57. package/dist/templates/_shared/notice-overrides/utils-0.4.2-LICENSE +21 -0
  58. package/dist/templates/_shared/notice-overrides/utils-0.5.0-LICENSE +21 -0
  59. package/dist/templates/_shared/third-party-notices.mjs +51 -0
  60. package/dist/templates/native-go/README.md +57 -1
  61. package/dist/templates/native-go/backend/THIRD_PARTY_NOTICES.txt +59 -0
  62. package/dist/templates/native-go/backend/cmd/dsm-readonly-probe/main_linux.go +46 -0
  63. package/dist/templates/native-go/backend/go.mod +4 -0
  64. package/dist/templates/native-go/backend/go.sum +4 -0
  65. package/dist/templates/native-go/backend/internal/api/binary.go +154 -0
  66. package/dist/templates/native-go/backend/internal/api/binary_test.go +165 -0
  67. package/dist/templates/native-go/backend/internal/api/registry.go +14 -4
  68. package/dist/templates/native-go/backend/internal/api/server.go +4 -0
  69. package/dist/templates/native-go/backend/internal/app/nas_cgi_artifact_test.go +121 -0
  70. package/dist/templates/native-go/backend/internal/app/nas_refusal_test.go +46 -0
  71. package/dist/templates/native-go/backend/internal/app/routes.go +11 -0
  72. package/dist/templates/native-go/backend/internal/app/routes_test.go +10 -5
  73. package/dist/templates/native-go/backend/internal/dsmprobe/collector_linux.go +335 -0
  74. package/dist/templates/native-go/backend/internal/dsmprobe/collector_linux_test.go +41 -0
  75. package/dist/templates/native-go/backend/internal/dsmprobe/protocol.go +179 -0
  76. package/dist/templates/native-go/backend/internal/dsmprobe/protocol_test.go +29 -0
  77. package/dist/templates/native-go/backend/internal/helper/cohort.go +393 -0
  78. package/dist/templates/native-go/backend/internal/helper/cohort_publication.go +18 -0
  79. package/dist/templates/native-go/backend/internal/helper/cohort_publication_test.go +105 -0
  80. package/dist/templates/native-go/backend/internal/helper/cohort_test.go +372 -0
  81. package/dist/templates/native-go/backend/internal/helper/control.go +226 -21
  82. package/dist/templates/native-go/backend/internal/helper/control_test.go +10 -2
  83. package/dist/templates/native-go/backend/internal/helper/data_contract.go +242 -0
  84. package/dist/templates/native-go/backend/internal/helper/data_contract_test.go +51 -0
  85. package/dist/templates/native-go/backend/internal/helper/data_decode.go +184 -0
  86. package/dist/templates/native-go/backend/internal/helper/data_decode_pointer_test.go +30 -0
  87. package/dist/templates/native-go/backend/internal/helper/data_protocol.go +416 -0
  88. package/dist/templates/native-go/backend/internal/helper/data_protocol_test.go +449 -0
  89. package/dist/templates/native-go/backend/internal/helper/dsm_acl_linux.go +139 -0
  90. package/dist/templates/native-go/backend/internal/helper/dsm_acl_linux_test.go +121 -0
  91. package/dist/templates/native-go/backend/internal/helper/dsm_acl_syscall_linux.go +95 -0
  92. package/dist/templates/native-go/backend/internal/helper/dsm_acl_syscall_linux_test.go +56 -0
  93. package/dist/templates/native-go/backend/internal/helper/dsm_bridge_linux.go +144 -0
  94. package/dist/templates/native-go/backend/internal/helper/dsm_bridge_linux_test.go +89 -0
  95. package/dist/templates/native-go/backend/internal/helper/dsm_home_linux.go +107 -0
  96. package/dist/templates/native-go/backend/internal/helper/dsm_home_linux_test.go +82 -0
  97. package/dist/templates/native-go/backend/internal/helper/dsm_probe_transport_linux.go +151 -0
  98. package/dist/templates/native-go/backend/internal/helper/dsm_probe_transport_linux_test.go +66 -0
  99. package/dist/templates/native-go/backend/internal/helper/grant_authority.go +516 -0
  100. package/dist/templates/native-go/backend/internal/helper/grant_authority_contract.go +88 -0
  101. package/dist/templates/native-go/backend/internal/helper/grant_authority_test.go +510 -0
  102. package/dist/templates/native-go/backend/internal/helper/grant_cohort.go +389 -0
  103. package/dist/templates/native-go/backend/internal/helper/grant_cohort_test.go +239 -0
  104. package/dist/templates/native-go/backend/internal/helper/grant_delivery.go +49 -0
  105. package/dist/templates/native-go/backend/internal/helper/grant_delivery_methods.go +273 -0
  106. package/dist/templates/native-go/backend/internal/helper/grant_delivery_test.go +322 -0
  107. package/dist/templates/native-go/backend/internal/helper/grant_operation_contract.go +47 -0
  108. package/dist/templates/native-go/backend/internal/helper/grant_readonly_test.go +180 -0
  109. package/dist/templates/native-go/backend/internal/helper/grant_repository_linux.go +415 -0
  110. package/dist/templates/native-go/backend/internal/helper/grant_repository_linux_test.go +468 -0
  111. package/dist/templates/native-go/backend/internal/helper/grant_rpc.go +147 -0
  112. package/dist/templates/native-go/backend/internal/helper/grant_rpc_test.go +51 -0
  113. package/dist/templates/native-go/backend/internal/helper/grant_snapshot.go +75 -0
  114. package/dist/templates/native-go/backend/internal/helper/grant_supervisor_linux.go +134 -0
  115. package/dist/templates/native-go/backend/internal/helper/grant_supervisor_linux_test.go +254 -0
  116. package/dist/templates/native-go/backend/internal/helper/lease.go +112 -0
  117. package/dist/templates/native-go/backend/internal/helper/lease_linux.go +44 -0
  118. package/dist/templates/native-go/backend/internal/helper/lease_other.go +8 -0
  119. package/dist/templates/native-go/backend/internal/helper/lifecycle.go +234 -0
  120. package/dist/templates/native-go/backend/internal/helper/lifecycle_test.go +473 -0
  121. package/dist/templates/native-go/backend/internal/helper/managed_pilot.go +284 -0
  122. package/dist/templates/native-go/backend/internal/helper/managed_pilot_repository_linux.go +74 -0
  123. package/dist/templates/native-go/backend/internal/helper/managed_pilot_repository_linux_test.go +40 -0
  124. package/dist/templates/native-go/backend/internal/helper/managed_pilot_test.go +210 -0
  125. package/dist/templates/native-go/backend/internal/helper/nas_shipped_refusal_linux_test.go +97 -0
  126. package/dist/templates/native-go/backend/internal/helper/native_discovery.go +79 -0
  127. package/dist/templates/native-go/backend/internal/helper/native_identity.go +89 -0
  128. package/dist/templates/native-go/backend/internal/helper/native_provider.go +159 -0
  129. package/dist/templates/native-go/backend/internal/helper/native_provider_test.go +421 -0
  130. package/dist/templates/native-go/backend/internal/helper/observation.go +204 -0
  131. package/dist/templates/native-go/backend/internal/helper/observation_health_test.go +115 -0
  132. package/dist/templates/native-go/backend/internal/helper/observation_reload_budget_test.go +117 -0
  133. package/dist/templates/native-go/backend/internal/helper/observation_test.go +196 -0
  134. package/dist/templates/native-go/backend/internal/helper/observer_diagnostic.go +109 -0
  135. package/dist/templates/native-go/backend/internal/helper/observer_diagnostic_linux.go +76 -0
  136. package/dist/templates/native-go/backend/internal/helper/observer_diagnostic_linux_test.go +124 -0
  137. package/dist/templates/native-go/backend/internal/helper/observer_diagnostic_test.go +98 -0
  138. package/dist/templates/native-go/backend/internal/helper/operation_bootstrap_linux.go +193 -0
  139. package/dist/templates/native-go/backend/internal/helper/operation_credentials_linux.go +56 -0
  140. package/dist/templates/native-go/backend/internal/helper/operation_linux.go +480 -0
  141. package/dist/templates/native-go/backend/internal/helper/operation_linux_test.go +528 -0
  142. package/dist/templates/native-go/backend/internal/helper/process_linux.go +11 -1
  143. package/dist/templates/native-go/backend/internal/helper/publication_test.go +178 -0
  144. package/dist/templates/native-go/backend/internal/helper/read_stream_cohort_linux_test.go +156 -0
  145. package/dist/templates/native-go/backend/internal/helper/read_transfer.go +40 -0
  146. package/dist/templates/native-go/backend/internal/helper/read_transfer_linux.go +109 -0
  147. package/dist/templates/native-go/backend/internal/helper/read_transfer_linux_test.go +118 -0
  148. package/dist/templates/native-go/backend/internal/helper/read_transfer_test.go +177 -0
  149. package/dist/templates/native-go/backend/internal/helper/readonly.go +105 -0
  150. package/dist/templates/native-go/backend/internal/helper/readonly_admission.go +85 -0
  151. package/dist/templates/native-go/backend/internal/helper/readonly_cohort_linux_test.go +253 -0
  152. package/dist/templates/native-go/backend/internal/helper/readonly_linux_test.go +378 -0
  153. package/dist/templates/native-go/backend/internal/helper/readonly_mount_linux.go +65 -0
  154. package/dist/templates/native-go/backend/internal/helper/readonly_mount_proxy_linux.go +113 -0
  155. package/dist/templates/native-go/backend/internal/helper/readonly_operations_linux.go +168 -0
  156. package/dist/templates/native-go/backend/internal/helper/readonly_resolver_linux.go +241 -0
  157. package/dist/templates/native-go/backend/internal/helper/readonly_test.go +40 -0
  158. package/dist/templates/native-go/backend/internal/helper/relaxed_identity.go +252 -0
  159. package/dist/templates/native-go/backend/internal/helper/relaxed_identity_contract.go +105 -0
  160. package/dist/templates/native-go/backend/internal/helper/relaxed_identity_test.go +406 -0
  161. package/dist/templates/native-go/backend/internal/helper/relaxed_invalidation.go +200 -0
  162. package/dist/templates/native-go/backend/internal/helper/repair.go +132 -0
  163. package/dist/templates/native-go/backend/internal/helper/repair_test.go +271 -0
  164. package/dist/templates/native-go/backend/internal/helper/s1r_actor_acl_linux_test.go +303 -0
  165. package/dist/templates/native-go/backend/internal/helper/s1r_actor_fixture_linux_test.go +184 -0
  166. package/dist/templates/native-go/backend/internal/helper/s1r_actor_races_linux_test.go +231 -0
  167. package/dist/templates/native-go/backend/internal/helper/s1r_fixture_contract_linux_test.go +18 -0
  168. package/dist/templates/native-go/backend/internal/helper/server_linux.go +44 -3
  169. package/dist/templates/native-go/backend/internal/helper/status.go +74 -11
  170. package/dist/templates/native-go/backend/internal/helper/status_test.go +83 -0
  171. package/dist/templates/native-go/backend/internal/helper/supervision.go +28 -5
  172. package/dist/templates/native-go/backend/internal/helper/supervisor_frame.go +76 -0
  173. package/dist/templates/native-go/backend/internal/helper/supervisor_frame_linux_test.go +69 -0
  174. package/dist/templates/native-go/backend/internal/helper/supervisor_frame_test.go +107 -0
  175. package/dist/templates/native-go/backend/internal/helper/supervisor_linux.go +187 -16
  176. package/dist/templates/native-go/backend/internal/helper/supervisor_linux_test.go +618 -7
  177. package/dist/templates/native-go/backend/internal/helper/supervisor_socket_eof_test.go +74 -0
  178. package/dist/templates/native-go/backend/internal/helper/supervisor_socket_test.go +45 -0
  179. package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/create.json +23 -0
  180. package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/frames.json +67 -0
  181. package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/grant-store.json +52 -0
  182. package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/intent.json +20 -0
  183. package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/list.json +20 -0
  184. package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/publish.json +20 -0
  185. package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/read.json +22 -0
  186. package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/stat.json +22 -0
  187. package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/write-stream.json +22 -0
  188. package/dist/templates/native-go/backend/internal/helper/unit_connection.go +75 -0
  189. package/dist/templates/native-go/backend/internal/helper/unit_connection_linux_test.go +135 -0
  190. package/dist/templates/native-go/backend/internal/helper/unit_connection_test.go +133 -0
  191. package/dist/templates/native-go/backend/internal/helper/unit_frame_test.go +32 -0
  192. package/dist/templates/native-go/backend/internal/helper/unit_linux.go +364 -0
  193. package/dist/templates/native-go/backend/internal/helper/unit_linux_test.go +46 -0
  194. package/dist/templates/native-go/backend/internal/helper/unit_mechanisms_linux_test.go +217 -0
  195. package/dist/templates/native-go/backend/internal/helper/unit_padding_linux_test.go +178 -0
  196. package/dist/templates/native-go/backend/internal/helper/unit_query_linux.go +111 -0
  197. package/dist/templates/native-go/backend/internal/helper/unit_reload_linux_test.go +372 -0
  198. package/dist/templates/native-go/backend/internal/helper/unit_reload_sequence_linux_test.go +232 -0
  199. package/dist/templates/native-go/backend/internal/helper/write.go +77 -0
  200. package/dist/templates/native-go/backend/internal/helper/write_admission.go +260 -0
  201. package/dist/templates/native-go/backend/internal/helper/write_admission_test.go +135 -0
  202. package/dist/templates/native-go/backend/internal/helper/write_cohort_linux_test.go +218 -0
  203. package/dist/templates/native-go/backend/internal/helper/write_files_linux.go +202 -0
  204. package/dist/templates/native-go/backend/internal/helper/write_files_linux_test.go +199 -0
  205. package/dist/templates/native-go/backend/internal/helper/write_intent_linux.go +116 -0
  206. package/dist/templates/native-go/backend/internal/helper/write_intent_linux_test.go +74 -0
  207. package/dist/templates/native-go/backend/internal/helper/write_operation_linux.go +245 -0
  208. package/dist/templates/native-go/backend/internal/helper/write_test.go +53 -0
  209. package/dist/templates/native-go/ui/app.js +8 -1
  210. package/dist/templates/native-go-better-auth/node/build.mjs +2 -0
  211. package/dist/templates/native-go-vue/README.md +115 -1
  212. package/dist/templates/native-go-vue/frontend/DESIGN.md +1 -1
  213. package/dist/templates/native-go-vue/frontend/package-lock.json +132 -229
  214. package/dist/templates/native-go-vue/frontend/package.json +1 -1
  215. package/dist/templates/native-go-vue/frontend/src/App.vue +33 -6
  216. package/dist/templates/native-go-vue/frontend/src/context.ts +41 -2
  217. package/dist/templates/native-go-vue/frontend/src/main.ts +4 -1
  218. package/dist/templates/native-go-vue/frontend/src/nas/NasGrantSettings.vue +74 -0
  219. package/dist/templates/native-go-vue/frontend/src/nas/NasPathPicker.vue +106 -0
  220. package/dist/templates/native-go-vue/frontend/src/nas/NasUnavailable.vue +20 -0
  221. package/dist/templates/native-go-vue/frontend/src/nas/i18n/de.json +74 -0
  222. package/dist/templates/native-go-vue/frontend/src/nas/i18n/en.json +74 -0
  223. package/dist/templates/native-go-vue/frontend/src/nas/i18n/es.json +74 -0
  224. package/dist/templates/native-go-vue/frontend/src/nas/i18n/fr.json +74 -0
  225. package/dist/templates/native-go-vue/frontend/src/nas/i18n/it.json +74 -0
  226. package/dist/templates/native-go-vue/frontend/src/nas/i18n/ja.json +74 -0
  227. package/dist/templates/native-go-vue/frontend/src/nas/i18n/ko.json +74 -0
  228. package/dist/templates/native-go-vue/frontend/src/nas/i18n/zh-CN.json +74 -0
  229. package/dist/templates/native-go-vue/frontend/src/nas/i18n/zh-TW.json +74 -0
  230. package/dist/templates/native-go-vue/frontend/src/nas/i18n.ts +38 -0
  231. package/dist/templates/native-go-vue/frontend/src/nas/mock-provider.ts +119 -0
  232. package/dist/templates/native-go-vue/frontend/src/nas/provider.ts +59 -0
  233. package/dist/templates/native-go-vue/frontend/src/nas/use-request.ts +27 -0
  234. package/dist/templates/native-go-vue/frontend/src/style.css +17 -0
  235. package/dist/templates/native-go-vue/frontend/test/apps.test.ts +44 -2
  236. package/dist/templates/native-go-vue/frontend/test/nas-provider.test.ts +81 -0
  237. package/dist/templates/native-go-vue/frontend/test/nas-request.test.ts +21 -0
  238. package/dist/templates/native-go-vue/frontend/test/nas-ui.test.ts +261 -0
  239. package/dist/templates/native-go-vue/frontend/tsconfig.json +1 -1
  240. package/dist/templates/native-go-vue/frontend/vite.config.ts +6 -4
  241. package/package.json +3 -2
  242. package/templates/_daemon/fixture_linux_test.go +15 -0
  243. package/templates/_daemon/fixture_other_test.go +7 -0
  244. package/templates/_daemon/go.mod +3 -0
  245. package/templates/_daemon/main.go +608 -0
  246. package/templates/_daemon/main_test.go +242 -0
  247. package/templates/_daemon/process_linux.go +55 -0
  248. package/templates/_daemon/process_linux_test.go +161 -0
  249. package/templates/_daemon/process_other.go +14 -0
  250. package/templates/_daemon/testdata/child.go +41 -0
  251. package/templates/_shared/GO-LICENSE +27 -0
  252. package/templates/_shared/GO-PATENTS +22 -0
  253. package/templates/_shared/LICENSES/TEMPLATE.txt +21 -0
  254. package/templates/_shared/notice-overrides/index.json +14 -0
  255. package/templates/_shared/notice-overrides/utils-0.4.2-LICENSE +21 -0
  256. package/templates/_shared/notice-overrides/utils-0.5.0-LICENSE +21 -0
  257. package/templates/_shared/third-party-notices.mjs +51 -0
  258. package/templates/native-go/README.md +57 -1
  259. package/templates/native-go/backend/THIRD_PARTY_NOTICES.txt +59 -0
  260. package/templates/native-go/backend/cmd/dsm-readonly-probe/main_linux.go +46 -0
  261. package/templates/native-go/backend/go.mod +4 -0
  262. package/templates/native-go/backend/go.sum +4 -0
  263. package/templates/native-go/backend/internal/api/binary.go +154 -0
  264. package/templates/native-go/backend/internal/api/binary_test.go +165 -0
  265. package/templates/native-go/backend/internal/api/registry.go +14 -4
  266. package/templates/native-go/backend/internal/api/server.go +4 -0
  267. package/templates/native-go/backend/internal/app/nas_cgi_artifact_test.go +121 -0
  268. package/templates/native-go/backend/internal/app/nas_refusal_test.go +46 -0
  269. package/templates/native-go/backend/internal/app/routes.go +11 -0
  270. package/templates/native-go/backend/internal/app/routes_test.go +10 -5
  271. package/templates/native-go/backend/internal/dsmprobe/collector_linux.go +335 -0
  272. package/templates/native-go/backend/internal/dsmprobe/collector_linux_test.go +41 -0
  273. package/templates/native-go/backend/internal/dsmprobe/protocol.go +179 -0
  274. package/templates/native-go/backend/internal/dsmprobe/protocol_test.go +29 -0
  275. package/templates/native-go/backend/internal/helper/cohort.go +393 -0
  276. package/templates/native-go/backend/internal/helper/cohort_publication.go +18 -0
  277. package/templates/native-go/backend/internal/helper/cohort_publication_test.go +105 -0
  278. package/templates/native-go/backend/internal/helper/cohort_test.go +372 -0
  279. package/templates/native-go/backend/internal/helper/control.go +226 -21
  280. package/templates/native-go/backend/internal/helper/control_test.go +10 -2
  281. package/templates/native-go/backend/internal/helper/data_contract.go +242 -0
  282. package/templates/native-go/backend/internal/helper/data_contract_test.go +51 -0
  283. package/templates/native-go/backend/internal/helper/data_decode.go +184 -0
  284. package/templates/native-go/backend/internal/helper/data_decode_pointer_test.go +30 -0
  285. package/templates/native-go/backend/internal/helper/data_protocol.go +416 -0
  286. package/templates/native-go/backend/internal/helper/data_protocol_test.go +449 -0
  287. package/templates/native-go/backend/internal/helper/dsm_acl_linux.go +139 -0
  288. package/templates/native-go/backend/internal/helper/dsm_acl_linux_test.go +121 -0
  289. package/templates/native-go/backend/internal/helper/dsm_acl_syscall_linux.go +95 -0
  290. package/templates/native-go/backend/internal/helper/dsm_acl_syscall_linux_test.go +56 -0
  291. package/templates/native-go/backend/internal/helper/dsm_bridge_linux.go +144 -0
  292. package/templates/native-go/backend/internal/helper/dsm_bridge_linux_test.go +89 -0
  293. package/templates/native-go/backend/internal/helper/dsm_home_linux.go +107 -0
  294. package/templates/native-go/backend/internal/helper/dsm_home_linux_test.go +82 -0
  295. package/templates/native-go/backend/internal/helper/dsm_probe_transport_linux.go +151 -0
  296. package/templates/native-go/backend/internal/helper/dsm_probe_transport_linux_test.go +66 -0
  297. package/templates/native-go/backend/internal/helper/grant_authority.go +516 -0
  298. package/templates/native-go/backend/internal/helper/grant_authority_contract.go +88 -0
  299. package/templates/native-go/backend/internal/helper/grant_authority_test.go +510 -0
  300. package/templates/native-go/backend/internal/helper/grant_cohort.go +389 -0
  301. package/templates/native-go/backend/internal/helper/grant_cohort_test.go +239 -0
  302. package/templates/native-go/backend/internal/helper/grant_delivery.go +49 -0
  303. package/templates/native-go/backend/internal/helper/grant_delivery_methods.go +273 -0
  304. package/templates/native-go/backend/internal/helper/grant_delivery_test.go +322 -0
  305. package/templates/native-go/backend/internal/helper/grant_operation_contract.go +47 -0
  306. package/templates/native-go/backend/internal/helper/grant_readonly_test.go +180 -0
  307. package/templates/native-go/backend/internal/helper/grant_repository_linux.go +415 -0
  308. package/templates/native-go/backend/internal/helper/grant_repository_linux_test.go +468 -0
  309. package/templates/native-go/backend/internal/helper/grant_rpc.go +147 -0
  310. package/templates/native-go/backend/internal/helper/grant_rpc_test.go +51 -0
  311. package/templates/native-go/backend/internal/helper/grant_snapshot.go +75 -0
  312. package/templates/native-go/backend/internal/helper/grant_supervisor_linux.go +134 -0
  313. package/templates/native-go/backend/internal/helper/grant_supervisor_linux_test.go +254 -0
  314. package/templates/native-go/backend/internal/helper/lease.go +112 -0
  315. package/templates/native-go/backend/internal/helper/lease_linux.go +44 -0
  316. package/templates/native-go/backend/internal/helper/lease_other.go +8 -0
  317. package/templates/native-go/backend/internal/helper/lifecycle.go +234 -0
  318. package/templates/native-go/backend/internal/helper/lifecycle_test.go +473 -0
  319. package/templates/native-go/backend/internal/helper/managed_pilot.go +284 -0
  320. package/templates/native-go/backend/internal/helper/managed_pilot_repository_linux.go +74 -0
  321. package/templates/native-go/backend/internal/helper/managed_pilot_repository_linux_test.go +40 -0
  322. package/templates/native-go/backend/internal/helper/managed_pilot_test.go +210 -0
  323. package/templates/native-go/backend/internal/helper/nas_shipped_refusal_linux_test.go +97 -0
  324. package/templates/native-go/backend/internal/helper/native_discovery.go +79 -0
  325. package/templates/native-go/backend/internal/helper/native_identity.go +89 -0
  326. package/templates/native-go/backend/internal/helper/native_provider.go +159 -0
  327. package/templates/native-go/backend/internal/helper/native_provider_test.go +421 -0
  328. package/templates/native-go/backend/internal/helper/observation.go +204 -0
  329. package/templates/native-go/backend/internal/helper/observation_health_test.go +115 -0
  330. package/templates/native-go/backend/internal/helper/observation_reload_budget_test.go +117 -0
  331. package/templates/native-go/backend/internal/helper/observation_test.go +196 -0
  332. package/templates/native-go/backend/internal/helper/observer_diagnostic.go +109 -0
  333. package/templates/native-go/backend/internal/helper/observer_diagnostic_linux.go +76 -0
  334. package/templates/native-go/backend/internal/helper/observer_diagnostic_linux_test.go +124 -0
  335. package/templates/native-go/backend/internal/helper/observer_diagnostic_test.go +98 -0
  336. package/templates/native-go/backend/internal/helper/operation_bootstrap_linux.go +193 -0
  337. package/templates/native-go/backend/internal/helper/operation_credentials_linux.go +56 -0
  338. package/templates/native-go/backend/internal/helper/operation_linux.go +480 -0
  339. package/templates/native-go/backend/internal/helper/operation_linux_test.go +528 -0
  340. package/templates/native-go/backend/internal/helper/process_linux.go +11 -1
  341. package/templates/native-go/backend/internal/helper/publication_test.go +178 -0
  342. package/templates/native-go/backend/internal/helper/read_stream_cohort_linux_test.go +156 -0
  343. package/templates/native-go/backend/internal/helper/read_transfer.go +40 -0
  344. package/templates/native-go/backend/internal/helper/read_transfer_linux.go +109 -0
  345. package/templates/native-go/backend/internal/helper/read_transfer_linux_test.go +118 -0
  346. package/templates/native-go/backend/internal/helper/read_transfer_test.go +177 -0
  347. package/templates/native-go/backend/internal/helper/readonly.go +105 -0
  348. package/templates/native-go/backend/internal/helper/readonly_admission.go +85 -0
  349. package/templates/native-go/backend/internal/helper/readonly_cohort_linux_test.go +253 -0
  350. package/templates/native-go/backend/internal/helper/readonly_linux_test.go +378 -0
  351. package/templates/native-go/backend/internal/helper/readonly_mount_linux.go +65 -0
  352. package/templates/native-go/backend/internal/helper/readonly_mount_proxy_linux.go +113 -0
  353. package/templates/native-go/backend/internal/helper/readonly_operations_linux.go +168 -0
  354. package/templates/native-go/backend/internal/helper/readonly_resolver_linux.go +241 -0
  355. package/templates/native-go/backend/internal/helper/readonly_test.go +40 -0
  356. package/templates/native-go/backend/internal/helper/relaxed_identity.go +252 -0
  357. package/templates/native-go/backend/internal/helper/relaxed_identity_contract.go +105 -0
  358. package/templates/native-go/backend/internal/helper/relaxed_identity_test.go +406 -0
  359. package/templates/native-go/backend/internal/helper/relaxed_invalidation.go +200 -0
  360. package/templates/native-go/backend/internal/helper/repair.go +132 -0
  361. package/templates/native-go/backend/internal/helper/repair_test.go +271 -0
  362. package/templates/native-go/backend/internal/helper/s1r_actor_acl_linux_test.go +303 -0
  363. package/templates/native-go/backend/internal/helper/s1r_actor_fixture_linux_test.go +184 -0
  364. package/templates/native-go/backend/internal/helper/s1r_actor_races_linux_test.go +231 -0
  365. package/templates/native-go/backend/internal/helper/s1r_fixture_contract_linux_test.go +18 -0
  366. package/templates/native-go/backend/internal/helper/server_linux.go +44 -3
  367. package/templates/native-go/backend/internal/helper/status.go +74 -11
  368. package/templates/native-go/backend/internal/helper/status_test.go +83 -0
  369. package/templates/native-go/backend/internal/helper/supervision.go +28 -5
  370. package/templates/native-go/backend/internal/helper/supervisor_frame.go +76 -0
  371. package/templates/native-go/backend/internal/helper/supervisor_frame_linux_test.go +69 -0
  372. package/templates/native-go/backend/internal/helper/supervisor_frame_test.go +107 -0
  373. package/templates/native-go/backend/internal/helper/supervisor_linux.go +187 -16
  374. package/templates/native-go/backend/internal/helper/supervisor_linux_test.go +618 -7
  375. package/templates/native-go/backend/internal/helper/supervisor_socket_eof_test.go +74 -0
  376. package/templates/native-go/backend/internal/helper/supervisor_socket_test.go +45 -0
  377. package/templates/native-go/backend/internal/helper/testdata/protocol2/create.json +23 -0
  378. package/templates/native-go/backend/internal/helper/testdata/protocol2/frames.json +67 -0
  379. package/templates/native-go/backend/internal/helper/testdata/protocol2/grant-store.json +52 -0
  380. package/templates/native-go/backend/internal/helper/testdata/protocol2/intent.json +20 -0
  381. package/templates/native-go/backend/internal/helper/testdata/protocol2/list.json +20 -0
  382. package/templates/native-go/backend/internal/helper/testdata/protocol2/publish.json +20 -0
  383. package/templates/native-go/backend/internal/helper/testdata/protocol2/read.json +22 -0
  384. package/templates/native-go/backend/internal/helper/testdata/protocol2/stat.json +22 -0
  385. package/templates/native-go/backend/internal/helper/testdata/protocol2/write-stream.json +22 -0
  386. package/templates/native-go/backend/internal/helper/unit_connection.go +75 -0
  387. package/templates/native-go/backend/internal/helper/unit_connection_linux_test.go +135 -0
  388. package/templates/native-go/backend/internal/helper/unit_connection_test.go +133 -0
  389. package/templates/native-go/backend/internal/helper/unit_frame_test.go +32 -0
  390. package/templates/native-go/backend/internal/helper/unit_linux.go +364 -0
  391. package/templates/native-go/backend/internal/helper/unit_linux_test.go +46 -0
  392. package/templates/native-go/backend/internal/helper/unit_mechanisms_linux_test.go +217 -0
  393. package/templates/native-go/backend/internal/helper/unit_padding_linux_test.go +178 -0
  394. package/templates/native-go/backend/internal/helper/unit_query_linux.go +111 -0
  395. package/templates/native-go/backend/internal/helper/unit_reload_linux_test.go +372 -0
  396. package/templates/native-go/backend/internal/helper/unit_reload_sequence_linux_test.go +232 -0
  397. package/templates/native-go/backend/internal/helper/write.go +77 -0
  398. package/templates/native-go/backend/internal/helper/write_admission.go +260 -0
  399. package/templates/native-go/backend/internal/helper/write_admission_test.go +135 -0
  400. package/templates/native-go/backend/internal/helper/write_cohort_linux_test.go +218 -0
  401. package/templates/native-go/backend/internal/helper/write_files_linux.go +202 -0
  402. package/templates/native-go/backend/internal/helper/write_files_linux_test.go +199 -0
  403. package/templates/native-go/backend/internal/helper/write_intent_linux.go +116 -0
  404. package/templates/native-go/backend/internal/helper/write_intent_linux_test.go +74 -0
  405. package/templates/native-go/backend/internal/helper/write_operation_linux.go +245 -0
  406. package/templates/native-go/backend/internal/helper/write_test.go +53 -0
  407. package/templates/native-go/ui/app.js +8 -1
  408. package/templates/native-go-better-auth/node/build.mjs +2 -0
  409. package/templates/native-go-vue/README.md +115 -1
  410. package/templates/native-go-vue/frontend/DESIGN.md +1 -1
  411. package/templates/native-go-vue/frontend/package-lock.json +132 -229
  412. package/templates/native-go-vue/frontend/package.json +1 -1
  413. package/templates/native-go-vue/frontend/src/App.vue +33 -6
  414. package/templates/native-go-vue/frontend/src/context.ts +41 -2
  415. package/templates/native-go-vue/frontend/src/main.ts +4 -1
  416. package/templates/native-go-vue/frontend/src/nas/NasGrantSettings.vue +74 -0
  417. package/templates/native-go-vue/frontend/src/nas/NasPathPicker.vue +106 -0
  418. package/templates/native-go-vue/frontend/src/nas/NasUnavailable.vue +20 -0
  419. package/templates/native-go-vue/frontend/src/nas/i18n/de.json +74 -0
  420. package/templates/native-go-vue/frontend/src/nas/i18n/en.json +74 -0
  421. package/templates/native-go-vue/frontend/src/nas/i18n/es.json +74 -0
  422. package/templates/native-go-vue/frontend/src/nas/i18n/fr.json +74 -0
  423. package/templates/native-go-vue/frontend/src/nas/i18n/it.json +74 -0
  424. package/templates/native-go-vue/frontend/src/nas/i18n/ja.json +74 -0
  425. package/templates/native-go-vue/frontend/src/nas/i18n/ko.json +74 -0
  426. package/templates/native-go-vue/frontend/src/nas/i18n/zh-CN.json +74 -0
  427. package/templates/native-go-vue/frontend/src/nas/i18n/zh-TW.json +74 -0
  428. package/templates/native-go-vue/frontend/src/nas/i18n.ts +38 -0
  429. package/templates/native-go-vue/frontend/src/nas/mock-provider.ts +119 -0
  430. package/templates/native-go-vue/frontend/src/nas/provider.ts +59 -0
  431. package/templates/native-go-vue/frontend/src/nas/use-request.ts +27 -0
  432. package/templates/native-go-vue/frontend/src/style.css +17 -0
  433. package/templates/native-go-vue/frontend/test/apps.test.ts +44 -2
  434. package/templates/native-go-vue/frontend/test/nas-provider.test.ts +81 -0
  435. package/templates/native-go-vue/frontend/test/nas-request.test.ts +21 -0
  436. package/templates/native-go-vue/frontend/test/nas-ui.test.ts +261 -0
  437. package/templates/native-go-vue/frontend/tsconfig.json +1 -1
  438. package/templates/native-go-vue/frontend/vite.config.ts +6 -4
@@ -0,0 +1,231 @@
1
+ package helper
2
+
3
+ import (
4
+ "context"
5
+ "os"
6
+ "strings"
7
+ "testing"
8
+ )
9
+
10
+ func s1rActorRaces(t *testing.T, spec s1rActorSpec, kind string) {
11
+ root := spec.Root + "/race"
12
+ pin, code := pinReadOnlyRoot(root)
13
+ if code != "" {
14
+ t.Fatal(code)
15
+ }
16
+ defer pin.Close()
17
+ ctx := context.Background()
18
+ switch kind {
19
+ case "symlink":
20
+ for _, link := range []struct{ name, target string }{{"inside-link", "file"}, {"outside-link", "../bob/file"}, {"dir-link", "../bob"}} {
21
+ s1rMust(t, os.Symlink(link.target, root+"/"+link.name))
22
+ }
23
+ for _, action := range []Action{ActionStat, ActionRead, ActionList, ActionReadStream} {
24
+ segments := []string{"outside-link"}
25
+ if action == ActionList {
26
+ segments = []string{"dir-link"}
27
+ }
28
+ work := readWork(pin, segments...)
29
+ work.Action = action
30
+ if action == ActionList {
31
+ work.MaxBytes = 0
32
+ work.Limit = 20
33
+ }
34
+ if action == ActionStat {
35
+ work.MaxBytes = 0
36
+ }
37
+ if action == ActionReadStream {
38
+ x, r := openActorReadTransfer(ctx, pin, work, fixtureReadOnlyACL{})
39
+ if x != nil {
40
+ x.Close()
41
+ }
42
+ if r.Code != ErrDenied || r.Bytes != 0 {
43
+ t.Fatal("symlink stream", r)
44
+ }
45
+ } else {
46
+ r, b := executeReadOnly(ctx, pin, work, fixtureReadOnlyACL{})
47
+ if r.Code != ErrDenied || len(b) > 0 || r.Entry != nil || r.List != nil {
48
+ t.Fatal("symlink metadata/read", action, r)
49
+ }
50
+ }
51
+ }
52
+ r, b := executeReadOnly(ctx, pin, readWork(pin, "inside-link"), fixtureReadOnlyACL{})
53
+ if r.Code != ErrDenied || len(b) > 0 {
54
+ t.Fatal("internal symlink followed", r)
55
+ }
56
+ r, _ = executeReadOnly(ctx, pin, readOnlyWork{RootPath: root, Action: ActionList, Segments: []string{}, Limit: 20}, fixtureReadOnlyACL{})
57
+ if r.Code != "" || r.List == nil || len(r.List.Entries) != 1 || r.List.Entries[0].Name != "file" {
58
+ t.Fatal("symlink names leaked by list", r)
59
+ }
60
+ for _, segments := range [][]string{{"outside-link"}, {"dir-link", "new"}} {
61
+ x, c := openActorWriteTransfer(ctx, pin, writeWork{RootPath: root, Action: ActionCreate, Segments: segments, MaxBytes: 3}, fixtureReadOnlyACL{})
62
+ if x != nil {
63
+ x.Close()
64
+ }
65
+ if c != ErrDenied {
66
+ t.Fatal("symlink create", c)
67
+ }
68
+ }
69
+ t.Log("stat/list/read/stream/create reject symlinks; list filters symlink names")
70
+ case "stat-rename", "list-rename", "read-rename":
71
+ s1rMust(t, os.Mkdir(root+"/sub", 0700))
72
+ s1rMust(t, os.WriteFile(root+"/sub/file", []byte("original"), 0600))
73
+ mutated := false
74
+ acl := fixtureReadOnlyACL{hook: func() {
75
+ if mutated {
76
+ return
77
+ }
78
+ mutated = true
79
+ s1rMust(t, os.Rename(root+"/sub", root+"/moved"))
80
+ s1rMust(t, os.Mkdir(root+"/sub", 0700))
81
+ s1rMust(t, os.WriteFile(root+"/sub/file", []byte("foreign"), 0600))
82
+ }}
83
+ work := readWork(pin, "sub", "file")
84
+ if kind == "stat-rename" {
85
+ work.Action = ActionStat
86
+ work.MaxBytes = 0
87
+ }
88
+ if kind == "list-rename" {
89
+ work.Action = ActionList
90
+ work.MaxBytes = 0
91
+ work.Segments = []string{"sub"}
92
+ work.Limit = 20
93
+ }
94
+ r, b := executeReadOnly(ctx, pin, work, acl)
95
+ if r.Code != ErrStale || len(b) != 0 || r.Entry != nil || r.List != nil {
96
+ t.Fatal("renamed ancestry released bytes", r, string(b))
97
+ }
98
+ t.Log(kind + ": replacement after resolver open refuses bytes and metadata with stale")
99
+ case "stream-rename":
100
+ work := readWork(pin, "file")
101
+ work.Action = ActionReadStream
102
+ x, r := openActorReadTransfer(ctx, pin, work, fixtureReadOnlyACL{})
103
+ if r.Code != "" {
104
+ t.Fatal(r)
105
+ }
106
+ defer x.Close()
107
+ b, c := x.ReadChunk(ctx, 3)
108
+ if c != "" || string(b) != "can" {
109
+ t.Fatal(c, string(b))
110
+ }
111
+ s1rMust(t, os.Rename(root+"/file", root+"/old"))
112
+ s1rMust(t, os.Symlink("../bob/file", root+"/file"))
113
+ b, c = x.ReadChunk(ctx, 3)
114
+ if c != ErrDenied || len(b) != 0 {
115
+ t.Fatal("stream followed replacement", c, string(b))
116
+ }
117
+ t.Log("first fixed-FD stream chunk succeeds; symlink replacement refuses next chunk")
118
+ case "create-rename", "publish-rename", "publish-symlink":
119
+ s1rMust(t, os.Mkdir(root+"/sub", 0700))
120
+ staged := kind != "create-rename"
121
+ work := writeWork{RootPath: root, Action: ActionCreate, Segments: []string{"sub", "result"}, MaxBytes: 6}
122
+ if staged {
123
+ work.Action = ActionWriteStream
124
+ work.Staged = true
125
+ }
126
+ x, c := openActorWriteTransfer(ctx, pin, work, fixtureReadOnlyACL{})
127
+ if c != "" {
128
+ t.Fatal(c)
129
+ }
130
+ defer x.Close()
131
+ receipt, c := x.WriteChunk(ctx, []byte("abc"))
132
+ if c != "" || receipt.BytesWritten != 3 {
133
+ t.Fatal(receipt, c)
134
+ }
135
+ if kind == "publish-symlink" {
136
+ s1rMust(t, os.Symlink("../file", root+"/sub/result"))
137
+ receipt, c = x.Commit(ctx)
138
+ if c != ErrDenied || receipt.Published || receipt.Committed {
139
+ t.Fatal("publish replaced symlink", receipt, c)
140
+ }
141
+ target, e := os.Readlink(root + "/sub/result")
142
+ s1rMust(t, e)
143
+ if target != "../file" {
144
+ t.Fatal(target)
145
+ }
146
+ } else {
147
+ s1rMust(t, os.Rename(root+"/sub", root+"/moved"))
148
+ s1rMust(t, os.Mkdir(root+"/sub", 0700))
149
+ s1rMust(t, os.WriteFile(root+"/sub/result", []byte("foreign"), 0600))
150
+ if staged {
151
+ receipt, c = x.Commit(ctx)
152
+ if c != ErrStale || receipt.Published {
153
+ t.Fatal("publish after rename", receipt, c)
154
+ }
155
+ } else {
156
+ receipt, c = x.WriteChunk(ctx, []byte("def"))
157
+ if c != ErrPartial || receipt.BytesWritten != 3 {
158
+ t.Fatal("write after rename", receipt, c)
159
+ }
160
+ }
161
+ b, e := os.ReadFile(root + "/sub/result")
162
+ s1rMust(t, e)
163
+ if string(b) != "foreign" {
164
+ t.Fatal("foreign destination overwritten", string(b))
165
+ }
166
+ if staged {
167
+ if _, e := os.Stat(root + "/moved/result"); !os.IsNotExist(e) {
168
+ t.Fatal("anonymous stage became visible", e)
169
+ }
170
+ } else {
171
+ b, e = os.ReadFile(root + "/moved/result")
172
+ s1rMust(t, e)
173
+ if string(b) != "abc" {
174
+ t.Fatal("partial bytes changed", string(b))
175
+ }
176
+ }
177
+ }
178
+ t.Logf("%s: refusal=%s receipt=%+v; foreign destination preserved", kind, c, receipt)
179
+ case "publish-permission-loss":
180
+ work := writeWork{RootPath: root, Action: ActionWriteStream, Segments: []string{"result"}, MaxBytes: 3, Staged: true}
181
+ x, c := openActorWriteTransfer(ctx, pin, work, fixtureReadOnlyACL{})
182
+ if c != "" {
183
+ t.Fatal(c)
184
+ }
185
+ defer x.Close()
186
+ _, c = x.WriteChunk(ctx, []byte("abc"))
187
+ if c != "" {
188
+ t.Fatal(c)
189
+ }
190
+ s1rMust(t, os.Chmod(root, 0500))
191
+ defer os.Chmod(root, 0700)
192
+ r, c := x.Commit(ctx)
193
+ // Current S7 maps linkat EACCES to unsupported; require the exact behavior,
194
+ // report it, and preserve the fail-closed publish gate.
195
+ if c != ErrUnsupported || r.Published || r.Committed || r.BytesWritten != 3 {
196
+ t.Fatal("publish after parent chmod", r, c)
197
+ }
198
+ if _, e := os.Stat(root + "/result"); !os.IsNotExist(e) {
199
+ t.Fatal("publish wrote forbidden directory", e)
200
+ }
201
+ t.Log("parent write permission removed: kernel denies linkat; receipt retains staged bytes, published=false")
202
+ case "open-fd-write-permission-loss":
203
+ work := writeWork{RootPath: root, Action: ActionCreate, Segments: []string{"result"}, MaxBytes: 6}
204
+ x, c := openActorWriteTransfer(ctx, pin, work, fixtureReadOnlyACL{})
205
+ if c != "" {
206
+ t.Fatal(c)
207
+ }
208
+ defer x.Close()
209
+ r, c := x.WriteChunk(ctx, []byte("abc"))
210
+ if c != "" {
211
+ t.Fatal(c)
212
+ }
213
+ s1rMust(t, x.file.Chmod(0000))
214
+ defer x.file.Chmod(0600)
215
+ r, c = x.WriteChunk(ctx, []byte("def"))
216
+ if c != "" || r.BytesWritten != 6 {
217
+ t.Fatal("Linux open-FD semantics", r, c)
218
+ }
219
+ r, c = x.Commit(ctx)
220
+ if c != "" || !r.Committed {
221
+ t.Fatal(r, c)
222
+ }
223
+ b, e := os.ReadFile(root + "/result")
224
+ if !os.IsPermission(e) || len(b) != 0 {
225
+ t.Fatal("new open bypassed chmod", e, string(b))
226
+ }
227
+ t.Log("chmod 000 denies a new open; previously opened writer FD still writes/commits under Linux semantics")
228
+ default:
229
+ t.Fatal("unknown race", strings.TrimSpace(kind))
230
+ }
231
+ }
@@ -0,0 +1,18 @@
1
+ package helper
2
+
3
+ import (
4
+ "os"
5
+ "testing"
6
+ )
7
+
8
+ func TestS1RFixtureContract(t *testing.T) {
9
+ if os.Geteuid() != 0 {
10
+ t.Skip("disposable root VM only")
11
+ }
12
+ root := s1rFixture(t)
13
+ for _, name := range []string{"alice", "bob", "supplementary", "acl-allow", "acl-mask", "acl-file-mask", "inherit", "readonly", "race"} {
14
+ if _, err := os.Stat(root + "/" + name + "/file"); err != nil {
15
+ t.Fatal(name, err)
16
+ }
17
+ }
18
+ }
@@ -1,6 +1,8 @@
1
1
  package helper
2
2
 
3
3
  import (
4
+ "crypto/rand"
5
+ "encoding/hex"
4
6
  "encoding/json"
5
7
  "io"
6
8
  "net"
@@ -13,7 +15,7 @@ import (
13
15
 
14
16
  func serveLinux(c Client) error {
15
17
  r, err := readRecord(c.StateDir, 0)
16
- if err != nil || !r.Enabled || r.Inventory != c.Expected {
18
+ if err != nil || !r.Enabled || r.Inventory != c.Expected || r.Lifecycle == nil || r.Lifecycle.Phase != "running" {
17
19
  return errTrust
18
20
  }
19
21
  // Only the supervisor writes process.json.
@@ -76,8 +78,47 @@ func serveLinux(c Client) error {
76
78
  return
77
79
  }
78
80
  r, err := readRecord(c.StateDir, 0)
79
- disabled := err != nil || !r.Enabled || r.Inventory != c.Expected
80
- json.NewEncoder(conn).Encode(Respond(c.Expected, disabled, req))
81
+ readiness := "fenced"
82
+ if err == nil && r.Enabled && r.Inventory == c.Expected && r.Lifecycle != nil && r.Lifecycle.Phase == "running" {
83
+ readiness = parentReadiness(c)
84
+ }
85
+ res := Respond(c.Expected, readiness != "ready", req)
86
+ if readiness != "ready" {
87
+ res.Error = readiness
88
+ }
89
+ json.NewEncoder(conn).Encode(res)
81
90
  }()
82
91
  }
83
92
  }
93
+
94
+ // No lifecycle mutations: only the exact owned child can request admission.
95
+ func parentReadiness(c Client) string {
96
+ p, err := readProcess(c.RunDir, 0)
97
+ if err != nil || p.PID != os.Getppid() {
98
+ return "fenced"
99
+ }
100
+ actual, err := inspectSupervisor(p.PID, c.Expected)
101
+ if err != nil || actual != p {
102
+ return "fenced"
103
+ }
104
+ conn, err := net.DialTimeout("unix", filepath.Join(c.RunDir, "supervisor.sock"), 100*time.Millisecond)
105
+ if err != nil {
106
+ return "fenced"
107
+ }
108
+ defer conn.Close()
109
+ peer, err := peerCredentials(conn.(*net.UnixConn))
110
+ if err != nil || peer.Uid != 0 || int(peer.Pid) != p.PID {
111
+ return "fenced"
112
+ }
113
+ conn.SetDeadline(time.Now().Add(200 * time.Millisecond))
114
+ var nonce [32]byte
115
+ if _, err := rand.Read(nonce[:]); err != nil {
116
+ return "fenced"
117
+ }
118
+ req := supervisorRequest{Process: p, Op: "admit", Nonce: hex.EncodeToString(nonce[:])}
119
+ if json.NewEncoder(conn).Encode(req) != nil {
120
+ return "fenced"
121
+ }
122
+ res, err := decodeSupervisorReply(conn, c.Expected, req.Nonce)
123
+ return supervisorReadiness(res, err)
124
+ }
@@ -25,6 +25,7 @@ type Inventory struct {
25
25
  Protocol int `json:"protocol"`
26
26
  PayloadDigest string `json:"payloadDigest"`
27
27
  RegistryDigest string `json:"registryDigest"`
28
+ DataAccess string `json:"dataAccess,omitempty"`
28
29
  }
29
30
 
30
31
  var digestPattern = regexp.MustCompile(`^[a-f0-9]{64}$`)
@@ -32,13 +33,16 @@ var packagePattern = regexp.MustCompile(`^[A-Za-z][A-Za-z0-9]{1,63}$`)
32
33
  var versionPattern = regexp.MustCompile(`^\d+(\.\d+){0,3}-\d{4}$`)
33
34
 
34
35
  func (i Inventory) Valid() bool {
35
- return packagePattern.MatchString(i.Package) && versionPattern.MatchString(i.Version) && i.Protocol > 0 && digestPattern.MatchString(i.PayloadDigest) && digestPattern.MatchString(i.RegistryDigest)
36
+ mode := i.DataAccess == "" || i.Protocol == DataProtocol && (i.DataAccess == "unavailable" || i.DataAccess == "relaxed")
37
+ return mode && packagePattern.MatchString(i.Package) && versionPattern.MatchString(i.Version) && (i.Protocol == 1 || i.Protocol == DataProtocol) && digestPattern.MatchString(i.PayloadDigest) && digestPattern.MatchString(i.RegistryDigest)
36
38
  }
37
39
 
38
40
  type Record struct {
39
- Inventory Inventory `json:"inventory"`
40
- Enabled bool `json:"enabled"`
41
- Residual bool `json:"residual,omitempty"`
41
+ Schema int `json:"schema,omitempty"`
42
+ Lifecycle *Lifecycle `json:"lifecycle,omitempty"`
43
+ Inventory Inventory `json:"inventory"`
44
+ Enabled bool `json:"enabled"`
45
+ Residual bool `json:"residual,omitempty"`
42
46
  }
43
47
  type Request struct {
44
48
  Inventory Inventory `json:"inventory"`
@@ -161,14 +165,16 @@ func readRecord(dir string, owner uint32) (Record, error) {
161
165
  d := json.NewDecoder(io.LimitReader(f, 4097))
162
166
  d.DisallowUnknownFields()
163
167
  var decoded struct {
164
- Inventory Inventory `json:"inventory"`
165
- Enabled *bool `json:"enabled"`
166
- Residual bool `json:"residual,omitempty"`
168
+ Schema int `json:"schema,omitempty"`
169
+ Lifecycle *Lifecycle `json:"lifecycle,omitempty"`
170
+ Inventory Inventory `json:"inventory"`
171
+ Enabled *bool `json:"enabled"`
172
+ Residual bool `json:"residual,omitempty"`
167
173
  }
168
- if d.Decode(&decoded) != nil || d.Decode(new(any)) != io.EOF || !decoded.Inventory.Valid() || decoded.Enabled == nil {
174
+ if d.Decode(&decoded) != nil || d.Decode(new(any)) != io.EOF || !decoded.Inventory.Valid() || decoded.Enabled == nil || !decoded.Lifecycle.valid() || (decoded.Schema != 0 && decoded.Schema != 2) {
169
175
  return r, errTrust
170
176
  }
171
- r = Record{Inventory: decoded.Inventory, Enabled: *decoded.Enabled, Residual: decoded.Residual}
177
+ r = Record{Schema: decoded.Schema, Inventory: decoded.Inventory, Enabled: *decoded.Enabled, Residual: decoded.Residual, Lifecycle: decoded.Lifecycle}
172
178
  return r, nil
173
179
  }
174
180
 
@@ -201,6 +207,36 @@ func (c Client) Status(ctx context.Context) State {
201
207
  s.Cleanup = "required"
202
208
  return s
203
209
  }
210
+ if err == nil && r.Lifecycle != nil && r.Lifecycle.Phase != "running" {
211
+ if e := protected(c.RunDir, c.Owner, true); e != nil && !errors.Is(e, fs.ErrNotExist) {
212
+ return result("incompatible", "untrusted-runtime")
213
+ }
214
+ if r.Lifecycle.Completion != "" {
215
+ path := filepath.Join(c.StateDir, "completion-"+r.Lifecycle.Epoch+".json")
216
+ st, e := os.Lstat(path)
217
+ ok := e == nil && st.Mode().IsRegular() && st.Mode().Perm() == 0600
218
+ if ok {
219
+ s, valid := st.Sys().(*syscall.Stat_t)
220
+ ok = valid && s.Uid == c.Owner
221
+ }
222
+ if ok && uint32(os.Geteuid()) == c.Owner {
223
+ _, e = completionRecord(c, r)
224
+ ok = e == nil
225
+ }
226
+ if !ok {
227
+ s := result("failed", "invalid-completion")
228
+ s.Cleanup = "required"
229
+ return s
230
+ }
231
+ }
232
+
233
+ if !runtimeAbsent(c) {
234
+ s := result("failed", "incomplete-transition")
235
+ s.Cleanup = "required"
236
+ return s
237
+ }
238
+ return result("stopped", "admin-recover-required")
239
+ }
204
240
  // Conflict has precedence over missing approval. Even an unapproved leftover
205
241
  // socket is probed before claiming that authorization alone can fix it.
206
242
  if e := protected(c.RunDir, c.Owner, true); e != nil && !errors.Is(e, fs.ErrNotExist) {
@@ -215,7 +251,24 @@ func (c Client) Status(ctx context.Context) State {
215
251
  }
216
252
  state, reason := c.probe(ctx, socket)
217
253
  if state != "ready" {
218
- return result(state, reason)
254
+ s := result(state, reason)
255
+ if state == "pending" {
256
+ if err == nil && r.Lifecycle != nil && r.Lifecycle.Phase == "running" {
257
+ s.PackageRunning = "running"
258
+ return s
259
+ }
260
+ s.State, s.Reason = "failed", "health-refused"
261
+ }
262
+ if r.Lifecycle != nil {
263
+ if _, err := readProcess(c.RunDir, c.Owner); err == nil {
264
+ s.State = "failed"
265
+ s.Cleanup = "required"
266
+ }
267
+ }
268
+ if reason == "lifecycle-fenced" {
269
+ s.Cleanup = "required"
270
+ }
271
+ return s
219
272
  }
220
273
  } else if !errors.Is(e, fs.ErrNotExist) {
221
274
  return result("failed", "runtime-unreadable")
@@ -226,7 +279,11 @@ func (c Client) Status(ctx context.Context) State {
226
279
  if e != nil {
227
280
  return result("stopped", "runtime-missing")
228
281
  }
229
- return result("ready", "live-handshake")
282
+ s := result("ready", "live-handshake")
283
+ if r.Lifecycle != nil {
284
+ s.PackageRunning = "running"
285
+ }
286
+ return s
230
287
  }
231
288
 
232
289
  func (c Client) probe(ctx context.Context, socket string) (string, string) {
@@ -264,6 +321,12 @@ func (c Client) probe(ctx context.Context, socket string) (string, string) {
264
321
  if res.Nonce != req.Nonce || res.Inventory != c.Expected || res.Error == "incompatible" {
265
322
  return "incompatible", "handshake-mismatch"
266
323
  }
324
+ if !res.OK && res.Error == "reload-revalidating" {
325
+ return "pending", "reload-revalidating"
326
+ }
327
+ if !res.OK && res.Error == "fenced" {
328
+ return "failed", "lifecycle-fenced"
329
+ }
267
330
  if !res.OK || res.Error != "" {
268
331
  return "failed", "health-refused"
269
332
  }
@@ -203,3 +203,86 @@ func TestProcessRecordIsNotReadableByOrdinaryOSUsers(t *testing.T) {
203
203
  t.Fatalf("process record permissions: %v %v", s, err)
204
204
  }
205
205
  }
206
+
207
+ func TestS8InventoryHealthRejectsUnknownProtocol(t *testing.T) {
208
+ c := fixture(t)
209
+ for _, protocol := range []int{1, 2} {
210
+ i := c.Expected
211
+ i.Protocol = protocol
212
+ if !i.Valid() || !Respond(i, false, Request{Inventory: i, Op: "health", Nonce: strings.Repeat("c", 64)}).OK {
213
+ t.Fatal("supported protocol", protocol)
214
+ }
215
+ }
216
+ for _, protocol := range []int{0, 3, 99} {
217
+ i := c.Expected
218
+ i.Protocol = protocol
219
+ res := Respond(i, false, Request{Inventory: i, Op: "health", Nonce: strings.Repeat("c", 64)})
220
+ if i.Valid() || res.OK || res.Error != "incompatible" {
221
+ t.Fatal("unknown protocol accepted", protocol, res)
222
+ }
223
+ }
224
+ }
225
+
226
+ func TestPendingHealthRequiresTrustedRunningApproval(t *testing.T) {
227
+ for _, kind := range []string{"running", "missing", "legacy", "disabled", "residual", "fenced", "nonce", "inventory", "contradictory"} {
228
+ t.Run(kind, func(t *testing.T) {
229
+ c := fixture(t)
230
+ r := Record{Inventory: c.Expected, Enabled: true, Lifecycle: testLifecycle("running")}
231
+ switch kind {
232
+ case "legacy":
233
+ r.Lifecycle = nil
234
+ case "disabled":
235
+ r.Enabled = false
236
+ case "residual":
237
+ r.Residual = true
238
+ case "fenced":
239
+ r.Lifecycle.Phase = "fenced"
240
+ }
241
+ if kind != "missing" {
242
+ record(t, c, r)
243
+ }
244
+ live(t, c, c.Expected, func(req Request) Response {
245
+ res := Response{Inventory: c.Expected, Nonce: req.Nonce, Error: "reload-revalidating"}
246
+ switch kind {
247
+ case "nonce":
248
+ res.Nonce = "replay"
249
+ case "inventory":
250
+ res.Inventory.Protocol++
251
+ case "contradictory":
252
+ res.OK = true
253
+ }
254
+ return res
255
+ })
256
+ got := c.Status(context.Background())
257
+ if kind == "running" {
258
+ if got.State != "pending" || got.Reason != "reload-revalidating" || got.Cleanup != "" || got.PackageRunning != "running" {
259
+ t.Fatalf("%+v", got)
260
+ }
261
+ if c.CheckStopped(context.Background()) == nil {
262
+ t.Fatal("pending accepted as stopped")
263
+ }
264
+ } else if got.State == "pending" || got.State == "ready" {
265
+ t.Fatalf("untrusted pending: %+v", got)
266
+ }
267
+ })
268
+ }
269
+ }
270
+
271
+ func TestS1RInventoryModeIsProtocolTwoOnly(t *testing.T) {
272
+ i := Inventory{Package: "Fixture", Version: "1.0.0-0001", Protocol: 2, PayloadDigest: strings.Repeat("a", 64), RegistryDigest: strings.Repeat("b", 64)}
273
+ for _, mode := range []string{"", "unavailable", "relaxed"} {
274
+ i.DataAccess = mode
275
+ if !i.Valid() {
276
+ t.Fatal("known mode refused", mode)
277
+ }
278
+ }
279
+ i.DataAccess = "active"
280
+ if i.Valid() {
281
+ t.Fatal("unknown mode accepted")
282
+ }
283
+ i.DataAccess = "relaxed"
284
+ i.Protocol = 1
285
+ if i.Valid() {
286
+ t.Fatal("protocol 1 accepted relaxed")
287
+ }
288
+ }
@@ -70,15 +70,38 @@ func stopChild(ctx context.Context, child supervisedChild, grace time.Duration)
70
70
  // Read to actual connection EOF. A LimitReader's synthetic EOF at the size
71
71
  // cap can never certify supervisor exit, so reaching that cap is a refusal.
72
72
  func readSupervisorReply(reader io.Reader, want Inventory, nonce string) error {
73
- b, err := io.ReadAll(io.LimitReader(reader, 4097))
74
- if err != nil || len(b) > 4096 {
73
+ res, err := decodeSupervisorReply(reader, want, nonce)
74
+ if err != nil || !res.OK || res.Error != "" {
75
75
  return errTrust
76
76
  }
77
+ return nil
78
+ }
79
+
80
+ // Parsing authenticates the entire bounded reply; readiness and stop ACKs
81
+ // retain separate acceptance rules. No refusal can certify supervisor exit.
82
+ func decodeSupervisorReply(reader io.Reader, want Inventory, nonce string) (Response, error) {
77
83
  var res Response
84
+ b, err := io.ReadAll(io.LimitReader(reader, 4097))
85
+ if err != nil || len(b) > 4096 {
86
+ return res, errTrust
87
+ }
78
88
  d := json.NewDecoder(bytes.NewReader(b))
79
89
  d.DisallowUnknownFields()
80
- if d.Decode(&res) != nil || d.Decode(new(any)) != io.EOF || !res.OK || res.Error != "" || res.Inventory != want || res.Nonce != nonce {
81
- return errTrust
90
+ if d.Decode(&res) != nil || d.Decode(new(any)) != io.EOF || res.Inventory != want || res.Nonce != nonce {
91
+ return Response{}, errTrust
82
92
  }
83
- return nil
93
+ return res, nil
94
+ }
95
+
96
+ // A pending health refusal cannot be used as a successful admission or stop ACK.
97
+ func supervisorReadiness(res Response, err error) string {
98
+ if err == nil {
99
+ if res.OK && res.Error == "" {
100
+ return "ready"
101
+ }
102
+ if !res.OK && res.Error == "reload-revalidating" {
103
+ return res.Error
104
+ }
105
+ }
106
+ return "fenced"
84
107
  }
@@ -0,0 +1,76 @@
1
+ package helper
2
+
3
+ import (
4
+ "bufio"
5
+ "bytes"
6
+ "encoding/json"
7
+ "io"
8
+ "net"
9
+ "time"
10
+ )
11
+
12
+ type supervisorRequest struct {
13
+ Process Process `json:"process"`
14
+ Op string `json:"op"`
15
+ Nonce string `json:"nonce"`
16
+ Data json.RawMessage `json:"data,omitempty"`
17
+ }
18
+
19
+ // Legacy M1 requests do not half-close; grant controls MUST half-close. Count
20
+ // the entire v2 frame (including whitespace), reject duplicates and trailing
21
+ // frames, and bound both time and memory. The outer process binds this socket.
22
+ func decodeSupervisorRequest(reader io.Reader) (supervisorRequest, Code) {
23
+ var req supervisorRequest
24
+ limited := &io.LimitedReader{R: reader, N: MaxControlBytes + 1}
25
+ d := json.NewDecoder(limited)
26
+ var raw json.RawMessage
27
+ if d.Decode(&raw) != nil {
28
+ return req, ErrInvalid
29
+ }
30
+ if code := decodeDataObject(bytes.NewReader(raw), &req, MaxControlBytes); code != "" {
31
+ return req, code
32
+ }
33
+ if req.Op == "grants" {
34
+ rest, err := io.ReadAll(io.MultiReader(d.Buffered(), limited))
35
+ if err != nil {
36
+ return req, ErrInvalid
37
+ }
38
+ if limited.N <= 0 {
39
+ return req, ErrLimit
40
+ }
41
+ if len(bytes.TrimSpace(rest)) != 0 {
42
+ return req, ErrInvalid
43
+ }
44
+ } else if d.InputOffset() > 4096 || len(req.Data) > 0 {
45
+ return req, ErrInvalid
46
+ }
47
+ if !allReferences(req.Nonce) || (req.Op != "admit" && req.Op != "stop" && req.Op != "grants") {
48
+ return req, ErrInvalid
49
+ }
50
+ return req, ""
51
+ }
52
+
53
+ const supervisorAttestationWait = time.Second
54
+ const supervisorFrameBudget = 100 * time.Millisecond
55
+
56
+ // The caller sends no frame bytes until its full post-connect hash succeeds.
57
+ // Separate the bounded wait for that computation from the fixed frame budget.
58
+ func receiveSupervisorRequest(conn net.Conn) (supervisorRequest, Code) {
59
+ firstDeadline := time.Now().Add(supervisorAttestationWait)
60
+ if err := conn.SetReadDeadline(firstDeadline); err != nil {
61
+ return supervisorRequest{}, ErrInvalid
62
+ }
63
+ reader := bufio.NewReader(conn)
64
+ if _, err := reader.Peek(1); err != nil || !time.Now().Before(firstDeadline) {
65
+ return supervisorRequest{}, ErrInvalid
66
+ }
67
+ frameDeadline := time.Now().Add(supervisorFrameBudget)
68
+ if err := conn.SetDeadline(frameDeadline); err != nil {
69
+ return supervisorRequest{}, ErrInvalid
70
+ }
71
+ req, code := decodeSupervisorRequest(reader)
72
+ if !time.Now().Before(frameDeadline) {
73
+ return supervisorRequest{}, ErrInvalid
74
+ }
75
+ return req, code
76
+ }