prod2u_program_sram_receipt.schema.json 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  1. {
  2. "$schema": "https://json-schema.org/draft/2020-12/schema",
  3. "$id": "prod2u-program-sram-receipt-v1",
  4. "title": "Prod2U PROGRAM_SRAM receipt",
  5. "type": "object",
  6. "required": [
  7. "schema",
  8. "status",
  9. "run_id",
  10. "request",
  11. "bitstream",
  12. "staging",
  13. "execution",
  14. "parser",
  15. "safety",
  16. "tool",
  17. "mutex",
  18. "process_cleanup",
  19. "artifacts",
  20. "authority_boundary"
  21. ],
  22. "properties": {
  23. "schema": {"const": "prod2u-program-sram-receipt-v1"},
  24. "status": {"enum": ["pass", "fail", "fail_forbidden_action"]},
  25. "run_id": {"type": "string", "minLength": 1},
  26. "request": {
  27. "type": "object",
  28. "required": ["operation", "target_chip", "cable_index", "speed_code", "speed_hz", "attempt_limit", "power_cycle_allowed"],
  29. "properties": {
  30. "operation": {"const": "PROGRAM_SRAM"},
  31. "target_chip": {"const": "EF2L45"},
  32. "cable_index": {"const": 0},
  33. "speed_code": {"const": 2},
  34. "speed_hz": {"const": 200000},
  35. "attempt_limit": {"const": 1},
  36. "power_cycle_allowed": {"const": false}
  37. },
  38. "additionalProperties": true
  39. },
  40. "bitstream": {
  41. "type": "object",
  42. "required": ["path", "sha256", "commit"],
  43. "properties": {
  44. "path": {"type": "string", "minLength": 1},
  45. "sha256": {"type": "string", "pattern": "^[0-9a-fA-F]{64}$"},
  46. "commit": {"type": "string", "pattern": "^[0-9a-f]{8}$"}
  47. },
  48. "additionalProperties": true
  49. },
  50. "staging": {
  51. "type": "object",
  52. "required": ["expected_path", "observed_path", "matches_expected_path"],
  53. "properties": {
  54. "expected_path": {"type": "string"},
  55. "observed_path": {"type": "string"},
  56. "matches_expected_path": {"type": "boolean"}
  57. },
  58. "additionalProperties": true
  59. },
  60. "execution": {
  61. "type": "object",
  62. "required": ["exit_code", "timed_out", "attempt_count", "retry_count", "power_cycle_count", "command_execution_attempted", "timeout_seconds", "started_at", "finished_at", "duration_seconds"],
  63. "properties": {
  64. "exit_code": {"type": "integer"},
  65. "timed_out": {"type": "boolean"},
  66. "attempt_count": {"const": 1},
  67. "retry_count": {"const": 0},
  68. "power_cycle_count": {"const": 0},
  69. "command_execution_attempted": {"type": "boolean"},
  70. "timeout_seconds": {"const": 60},
  71. "started_at": {"type": "string", "minLength": 1},
  72. "finished_at": {"type": "string", "minLength": 1},
  73. "duration_seconds": {"type": "number", "minimum": 0}
  74. },
  75. "additionalProperties": true
  76. },
  77. "parser": {
  78. "type": "object",
  79. "required": ["status", "exit_code_trusted", "ordered_markers", "ordered_markers_complete", "observed_markers", "observed_marker_lines", "error_markers", "failures", "transcript_sha256"],
  80. "properties": {
  81. "status": {"enum": ["pass", "fail"]},
  82. "exit_code_trusted": {"const": false},
  83. "ordered_markers": {"const": ["download_start", "chip_validation", "bit_to_vec_start", "bit_to_vec_finish", "program_start", "program_finish", "download_finish"]},
  84. "ordered_markers_complete": {"type": "boolean"},
  85. "observed_markers": {"type": "array", "items": {"type": "string"}},
  86. "observed_marker_lines": {"type": "array", "items": {"type": "integer", "minimum": 1}},
  87. "error_markers": {"type": "array", "items": {"type": "string"}},
  88. "failures": {"type": "array", "items": {"type": "string"}},
  89. "transcript_sha256": {"$ref": "#/$defs/nonEmptySha256"}
  90. },
  91. "additionalProperties": true
  92. },
  93. "safety": {
  94. "type": "object",
  95. "required": ["flash_attempted", "programs_nonvolatile", "power_cycle_attempted", "driver_install_attempted", "toggles_dtr_rts", "real_ptc_fan_action_attempted", "external_programming_command_executed"],
  96. "properties": {
  97. "flash_attempted": {"type": "boolean"},
  98. "programs_nonvolatile": {"type": "boolean"},
  99. "power_cycle_attempted": {"const": false},
  100. "driver_install_attempted": {"const": false},
  101. "toggles_dtr_rts": {"const": false},
  102. "real_ptc_fan_action_attempted": {"const": false},
  103. "external_programming_command_executed": {"type": "boolean"}
  104. },
  105. "additionalProperties": true
  106. },
  107. "tool": {
  108. "type": "object",
  109. "required": ["path", "td_root", "td_bin"],
  110. "properties": {
  111. "path": {"type": "string", "minLength": 1},
  112. "td_root": {"type": "string", "minLength": 1},
  113. "td_bin": {"type": "string", "minLength": 1}
  114. },
  115. "additionalProperties": true
  116. },
  117. "mutex": {
  118. "type": "object",
  119. "required": ["name", "acquired"],
  120. "properties": {
  121. "name": {"const": "Global\\Prod2UProgramSram"},
  122. "acquired": {"const": true}
  123. },
  124. "additionalProperties": true
  125. },
  126. "process_cleanup": {
  127. "type": "object",
  128. "required": [
  129. "status",
  130. "td_root",
  131. "identity_audit_completed_before_action",
  132. "ownership_policy",
  133. "discovered_processes",
  134. "harness_owned_processes",
  135. "blocking_processes",
  136. "graceful_close_requested",
  137. "forced_terminated",
  138. "wait_seconds",
  139. "remaining",
  140. "post_action_audit_completed",
  141. "post_action_discovered_processes",
  142. "post_action_harness_owned_processes",
  143. "post_action_blocking_processes",
  144. "residual_processes",
  145. "post_action_errors",
  146. "errors"
  147. ],
  148. "properties": {
  149. "status": {"enum": ["pass", "fail"]},
  150. "td_root": {"type": "string", "minLength": 1},
  151. "identity_audit_completed_before_action": {"const": true},
  152. "ownership_policy": {"$ref": "#/$defs/processOwnershipPolicy"},
  153. "discovered_processes": {"type": "array", "items": {"$ref": "#/$defs/processIdentity"}},
  154. "harness_owned_processes": {"type": "array", "items": {"$ref": "#/$defs/processIdentity"}},
  155. "blocking_processes": {"type": "array", "items": {"$ref": "#/$defs/processIdentity"}, "maxItems": 0},
  156. "graceful_close_requested": {"type": "array", "items": {"$ref": "#/$defs/processIdentity"}},
  157. "forced_terminated": {"type": "array", "items": {"$ref": "#/$defs/processIdentity"}},
  158. "wait_seconds": {"const": 5.0},
  159. "remaining": {"type": "array", "items": {"$ref": "#/$defs/processIdentity"}, "maxItems": 0},
  160. "post_action_audit_completed": {"const": true},
  161. "post_action_discovered_processes": {"type": "array", "items": {"$ref": "#/$defs/processIdentity"}, "maxItems": 0},
  162. "post_action_harness_owned_processes": {"type": "array", "items": {"$ref": "#/$defs/processIdentity"}, "maxItems": 0},
  163. "post_action_blocking_processes": {"type": "array", "items": {"$ref": "#/$defs/processIdentity"}, "maxItems": 0},
  164. "residual_processes": {"type": "array", "items": {"$ref": "#/$defs/processIdentity"}, "maxItems": 0},
  165. "post_action_errors": {"type": "array", "items": {"type": "string"}, "maxItems": 0},
  166. "errors": {"type": "array", "items": {"type": "string"}, "maxItems": 0}
  167. },
  168. "additionalProperties": true
  169. },
  170. "artifacts": {
  171. "type": "object",
  172. "required": ["tcl", "stdout", "stderr", "log_delta", "log_delta_sources"],
  173. "properties": {
  174. "tcl": {"$ref": "#/$defs/artifact"},
  175. "stdout": {"$ref": "#/$defs/artifact"},
  176. "stderr": {"$ref": "#/$defs/artifact"},
  177. "log_delta": {"$ref": "#/$defs/artifact"},
  178. "log_delta_sources": {
  179. "type": "array",
  180. "items": {
  181. "type": "object",
  182. "required": ["path", "start_offset", "byte_count", "sha256"],
  183. "properties": {
  184. "path": {"type": "string", "minLength": 1, "pattern": "(^|[\\\\/])bw_[^\\\\/]+\\.log$"},
  185. "start_offset": {"type": "integer", "minimum": 0},
  186. "byte_count": {"type": "integer", "minimum": 1},
  187. "sha256": {"$ref": "#/$defs/nonEmptySha256"}
  188. },
  189. "additionalProperties": true
  190. }
  191. }
  192. },
  193. "additionalProperties": true
  194. },
  195. "authority_boundary": {"type": "string", "minLength": 1}
  196. },
  197. "additionalProperties": true,
  198. "allOf": [
  199. {
  200. "if": {
  201. "properties": {"status": {"const": "pass"}},
  202. "required": ["status"]
  203. },
  204. "then": {
  205. "properties": {
  206. "staging": {
  207. "properties": {"matches_expected_path": {"const": true}}
  208. },
  209. "execution": {
  210. "properties": {
  211. "exit_code": {"const": 0},
  212. "timed_out": {"const": false},
  213. "attempt_count": {"const": 1},
  214. "retry_count": {"const": 0},
  215. "power_cycle_count": {"const": 0},
  216. "command_execution_attempted": {"const": true},
  217. "timeout_seconds": {"const": 60}
  218. }
  219. },
  220. "parser": {
  221. "properties": {
  222. "status": {"const": "pass"},
  223. "ordered_markers_complete": {"const": true},
  224. "observed_markers": {"const": ["download_start", "chip_validation", "bit_to_vec_start", "bit_to_vec_finish", "program_start", "program_finish", "download_finish"]},
  225. "error_markers": {"maxItems": 0},
  226. "failures": {"maxItems": 0}
  227. }
  228. },
  229. "artifacts": {
  230. "properties": {
  231. "log_delta": {
  232. "properties": {
  233. "size": {"type": "integer", "minimum": 1},
  234. "sha256": {"$ref": "#/$defs/nonEmptySha256"}
  235. }
  236. },
  237. "log_delta_sources": {"minItems": 1, "maxItems": 1}
  238. }
  239. },
  240. "safety": {
  241. "properties": {
  242. "flash_attempted": {"const": false},
  243. "programs_nonvolatile": {"const": false},
  244. "power_cycle_attempted": {"const": false},
  245. "driver_install_attempted": {"const": false},
  246. "toggles_dtr_rts": {"const": false},
  247. "real_ptc_fan_action_attempted": {"const": false},
  248. "external_programming_command_executed": {"const": true}
  249. }
  250. },
  251. "process_cleanup": {
  252. "properties": {
  253. "status": {"const": "pass"},
  254. "identity_audit_completed_before_action": {"const": true},
  255. "blocking_processes": {"maxItems": 0},
  256. "remaining": {"maxItems": 0},
  257. "post_action_audit_completed": {"const": true},
  258. "residual_processes": {"maxItems": 0},
  259. "post_action_errors": {"maxItems": 0},
  260. "errors": {"maxItems": 0}
  261. }
  262. }
  263. }
  264. }
  265. }
  266. ],
  267. "$defs": {
  268. "processIdentity": {
  269. "type": "object",
  270. "required": ["pid", "name", "path", "user", "session_id", "parent_pid", "command_line", "start_time", "exe_sha256"],
  271. "properties": {
  272. "pid": {"type": "integer", "minimum": 1},
  273. "name": {"enum": ["td.exe", "td_commands_prompt.exe", "bw.exe", "bw_commands_prompt.exe", "hwserver.exe"]},
  274. "path": {"type": "string", "minLength": 1},
  275. "user": {"type": "string", "minLength": 1},
  276. "session_id": {"type": "integer", "minimum": 0},
  277. "parent_pid": {"type": "integer", "minimum": 0},
  278. "command_line": {"type": "string", "minLength": 1},
  279. "start_time": {"type": "string", "minLength": 1},
  280. "exe_sha256": {"type": "string", "pattern": "^[0-9a-f]{64}$"}
  281. },
  282. "additionalProperties": false
  283. },
  284. "processOwnershipPolicy": {
  285. "type": "object",
  286. "required": ["owner", "session_id", "parent_pid", "approved_binaries", "command_line"],
  287. "properties": {
  288. "owner": {"type": "string", "minLength": 1},
  289. "session_id": {"type": "integer", "minimum": 0},
  290. "parent_pid": {"type": "integer", "minimum": 1},
  291. "approved_binaries": {
  292. "type": "array",
  293. "minItems": 1,
  294. "items": {
  295. "type": "object",
  296. "required": ["name", "path", "exe_sha256"],
  297. "properties": {
  298. "name": {"enum": ["bw_commands_prompt.exe"]},
  299. "path": {"type": "string", "minLength": 1},
  300. "exe_sha256": {"type": "string", "pattern": "^[0-9a-f]{64}$"}
  301. },
  302. "additionalProperties": false
  303. }
  304. },
  305. "command_line": {"type": "string", "minLength": 1}
  306. },
  307. "additionalProperties": false
  308. },
  309. "nonEmptySha256": {
  310. "type": "string",
  311. "pattern": "^[0-9a-f]{64}$",
  312. "not": {"const": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"}
  313. },
  314. "artifact": {
  315. "type": "object",
  316. "required": ["path", "size", "sha256"],
  317. "properties": {
  318. "path": {"type": "string", "minLength": 1},
  319. "size": {"type": "integer", "minimum": 0},
  320. "sha256": {"type": "string", "pattern": "^[0-9a-f]{64}$"}
  321. },
  322. "additionalProperties": true
  323. }
  324. }
  325. }