@accounter/opcn1214-generator 0.0.0-bootstrap.0 → 0.0.0-stage

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 (477) hide show
  1. package/README.md +2 -336
  2. package/package.json +3 -74
  3. package/.bob/cjs/api/generate.d.ts +0 -44
  4. package/.bob/cjs/api/generate.js +0 -115
  5. package/.bob/cjs/api/parse.d.ts +0 -28
  6. package/.bob/cjs/api/parse.js +0 -38
  7. package/.bob/cjs/api/response.d.ts +0 -24
  8. package/.bob/cjs/api/response.js +0 -75
  9. package/.bob/cjs/api/validate.d.ts +0 -16
  10. package/.bob/cjs/api/validate.js +0 -15
  11. package/.bob/cjs/codec/boolean.d.ts +0 -7
  12. package/.bob/cjs/codec/boolean.js +0 -49
  13. package/.bob/cjs/codec/date.d.ts +0 -6
  14. package/.bob/cjs/codec/date.js +0 -68
  15. package/.bob/cjs/codec/enum.d.ts +0 -4
  16. package/.bob/cjs/codec/enum.js +0 -26
  17. package/.bob/cjs/codec/numeric.d.ts +0 -56
  18. package/.bob/cjs/codec/numeric.js +0 -186
  19. package/.bob/cjs/codec/padding.d.ts +0 -10
  20. package/.bob/cjs/codec/padding.js +0 -26
  21. package/.bob/cjs/codec/percent.d.ts +0 -6
  22. package/.bob/cjs/codec/percent.js +0 -33
  23. package/.bob/cjs/codec/phone.d.ts +0 -4
  24. package/.bob/cjs/codec/phone.js +0 -48
  25. package/.bob/cjs/codec/record.d.ts +0 -18
  26. package/.bob/cjs/codec/record.js +0 -176
  27. package/.bob/cjs/codec/registry.d.ts +0 -8
  28. package/.bob/cjs/codec/registry.js +0 -27
  29. package/.bob/cjs/codec/sections.d.ts +0 -41
  30. package/.bob/cjs/codec/sections.js +0 -177
  31. package/.bob/cjs/codec/text.d.ts +0 -5
  32. package/.bob/cjs/codec/text.js +0 -29
  33. package/.bob/cjs/codec/types.d.ts +0 -36
  34. package/.bob/cjs/codec/types.js +0 -16
  35. package/.bob/cjs/codec/windows1255.d.ts +0 -9
  36. package/.bob/cjs/codec/windows1255.js +0 -38
  37. package/.bob/cjs/errors.d.ts +0 -32
  38. package/.bob/cjs/errors.js +0 -103
  39. package/.bob/cjs/file/assemble.d.ts +0 -17
  40. package/.bob/cjs/file/assemble.js +0 -28
  41. package/.bob/cjs/file/control.d.ts +0 -13
  42. package/.bob/cjs/file/control.js +0 -45
  43. package/.bob/cjs/file/parse.d.ts +0 -18
  44. package/.bob/cjs/file/parse.js +0 -478
  45. package/.bob/cjs/file/split.d.ts +0 -17
  46. package/.bob/cjs/file/split.js +0 -71
  47. package/.bob/cjs/index.d.ts +0 -16
  48. package/.bob/cjs/index.js +0 -28
  49. package/.bob/cjs/layout/2024/layout.generated.d.ts +0 -6919
  50. package/.bob/cjs/layout/2024/layout.generated.js +0 -7224
  51. package/.bob/cjs/layout/2025/index.d.ts +0 -6
  52. package/.bob/cjs/layout/2025/index.js +0 -10
  53. package/.bob/cjs/layout/capital-gains.d.ts +0 -9
  54. package/.bob/cjs/layout/capital-gains.js +0 -15
  55. package/.bob/cjs/layout/countries.d.ts +0 -5
  56. package/.bob/cjs/layout/countries.js +0 -10
  57. package/.bob/cjs/layout/freeze.d.ts +0 -5
  58. package/.bob/cjs/layout/freeze.js +0 -16
  59. package/.bob/cjs/layout/registry.d.ts +0 -10
  60. package/.bob/cjs/layout/registry.js +0 -32
  61. package/.bob/cjs/layout/types.d.ts +0 -82
  62. package/.bob/cjs/layout/types.js +0 -35
  63. package/.bob/cjs/model/codes.generated.d.ts +0 -48
  64. package/.bob/cjs/model/codes.generated.js +0 -628
  65. package/.bob/cjs/model/index.d.ts +0 -3
  66. package/.bob/cjs/model/index.js +0 -5
  67. package/.bob/cjs/model/input.d.ts +0 -543
  68. package/.bob/cjs/model/input.js +0 -24
  69. package/.bob/cjs/model/normalized.d.ts +0 -43
  70. package/.bob/cjs/model/normalized.js +0 -0
  71. package/.bob/cjs/model/options.d.ts +0 -14
  72. package/.bob/cjs/model/options.js +0 -0
  73. package/.bob/cjs/model/schema.d.ts +0 -594
  74. package/.bob/cjs/model/schema.js +0 -339
  75. package/.bob/cjs/normalize/canonical.d.ts +0 -13
  76. package/.bob/cjs/normalize/canonical.js +0 -288
  77. package/.bob/cjs/normalize/capital-gains/assets.d.ts +0 -37
  78. package/.bob/cjs/normalize/capital-gains/assets.js +0 -94
  79. package/.bob/cjs/normalize/capital-gains/index.d.ts +0 -61
  80. package/.bob/cjs/normalize/capital-gains/index.js +0 -149
  81. package/.bob/cjs/normalize/capital-gains/no-withholding.d.ts +0 -18
  82. package/.bob/cjs/normalize/capital-gains/no-withholding.js +0 -36
  83. package/.bob/cjs/normalize/capital-gains/other.d.ts +0 -54
  84. package/.bob/cjs/normalize/capital-gains/other.js +0 -122
  85. package/.bob/cjs/normalize/capital-gains/section6.d.ts +0 -7
  86. package/.bob/cjs/normalize/capital-gains/section6.js +0 -13
  87. package/.bob/cjs/normalize/capital-gains/securities.d.ts +0 -26
  88. package/.bob/cjs/normalize/capital-gains/securities.js +0 -58
  89. package/.bob/cjs/normalize/denormalize.d.ts +0 -42
  90. package/.bob/cjs/normalize/denormalize.js +0 -359
  91. package/.bob/cjs/normalize/derive.d.ts +0 -57
  92. package/.bob/cjs/normalize/derive.js +0 -111
  93. package/.bob/cjs/normalize/enums.d.ts +0 -58
  94. package/.bob/cjs/normalize/enums.js +0 -69
  95. package/.bob/cjs/normalize/fields.d.ts +0 -28
  96. package/.bob/cjs/normalize/fields.js +0 -86
  97. package/.bob/cjs/normalize/foreign.d.ts +0 -22
  98. package/.bob/cjs/normalize/foreign.js +0 -85
  99. package/.bob/cjs/normalize/main.d.ts +0 -24
  100. package/.bob/cjs/normalize/main.js +0 -208
  101. package/.bob/cjs/normalize/paths.d.ts +0 -74
  102. package/.bob/cjs/normalize/paths.js +0 -169
  103. package/.bob/cjs/normalize/phone.d.ts +0 -12
  104. package/.bob/cjs/normalize/phone.js +0 -35
  105. package/.bob/cjs/normalize/rd-investments.d.ts +0 -10
  106. package/.bob/cjs/normalize/rd-investments.js +0 -25
  107. package/.bob/cjs/normalize/related-companies.d.ts +0 -10
  108. package/.bob/cjs/normalize/related-companies.js +0 -25
  109. package/.bob/cjs/normalize/report.d.ts +0 -9
  110. package/.bob/cjs/normalize/report.js +0 -53
  111. package/.bob/cjs/normalize/shareholders.d.ts +0 -10
  112. package/.bob/cjs/normalize/shareholders.js +0 -30
  113. package/.bob/cjs/normalize/text.d.ts +0 -11
  114. package/.bob/cjs/normalize/text.js +0 -41
  115. package/.bob/cjs/normalize/today.d.ts +0 -4
  116. package/.bob/cjs/normalize/today.js +0 -14
  117. package/.bob/cjs/pipeline.d.ts +0 -13
  118. package/.bob/cjs/pipeline.js +0 -37
  119. package/.bob/cjs/response/codes.d.ts +0 -2
  120. package/.bob/cjs/response/codes.js +0 -31
  121. package/.bob/cjs/validate/capital-gains-rules.d.ts +0 -6
  122. package/.bob/cjs/validate/capital-gains-rules.js +0 -162
  123. package/.bob/cjs/validate/check-digit.d.ts +0 -10
  124. package/.bob/cjs/validate/check-digit.js +0 -26
  125. package/.bob/cjs/validate/engine.d.ts +0 -5
  126. package/.bob/cjs/validate/engine.js +0 -35
  127. package/.bob/cjs/validate/field-rules.d.ts +0 -4
  128. package/.bob/cjs/validate/field-rules.js +0 -331
  129. package/.bob/cjs/validate/foreign-rules.d.ts +0 -6
  130. package/.bob/cjs/validate/foreign-rules.js +0 -171
  131. package/.bob/cjs/validate/issue.d.ts +0 -51
  132. package/.bob/cjs/validate/issue.js +0 -78
  133. package/.bob/cjs/validate/main-rules.d.ts +0 -24
  134. package/.bob/cjs/validate/main-rules.js +0 -425
  135. package/.bob/cjs/validate/parse-rules.d.ts +0 -31
  136. package/.bob/cjs/validate/parse-rules.js +0 -114
  137. package/.bob/cjs/validate/rules.d.ts +0 -746
  138. package/.bob/cjs/validate/rules.js +0 -680
  139. package/.bob/cjs/validate/shape.d.ts +0 -19
  140. package/.bob/cjs/validate/shape.js +0 -231
  141. package/.bob/cjs/validate/shareholder-rules.d.ts +0 -6
  142. package/.bob/cjs/validate/shareholder-rules.js +0 -83
  143. package/.bob/cjs/validate/structure-rules.d.ts +0 -26
  144. package/.bob/cjs/validate/structure-rules.js +0 -130
  145. package/.bob/esm/api/generate.d.ts +0 -44
  146. package/.bob/esm/api/generate.js +0 -111
  147. package/.bob/esm/api/parse.d.ts +0 -28
  148. package/.bob/esm/api/parse.js +0 -34
  149. package/.bob/esm/api/response.d.ts +0 -24
  150. package/.bob/esm/api/response.js +0 -72
  151. package/.bob/esm/api/validate.d.ts +0 -16
  152. package/.bob/esm/api/validate.js +0 -11
  153. package/.bob/esm/codec/boolean.d.ts +0 -7
  154. package/.bob/esm/codec/boolean.js +0 -46
  155. package/.bob/esm/codec/date.d.ts +0 -6
  156. package/.bob/esm/codec/date.js +0 -64
  157. package/.bob/esm/codec/enum.d.ts +0 -4
  158. package/.bob/esm/codec/enum.js +0 -23
  159. package/.bob/esm/codec/numeric.d.ts +0 -56
  160. package/.bob/esm/codec/numeric.js +0 -175
  161. package/.bob/esm/codec/padding.d.ts +0 -10
  162. package/.bob/esm/codec/padding.js +0 -21
  163. package/.bob/esm/codec/percent.d.ts +0 -6
  164. package/.bob/esm/codec/percent.js +0 -30
  165. package/.bob/esm/codec/phone.d.ts +0 -4
  166. package/.bob/esm/codec/phone.js +0 -45
  167. package/.bob/esm/codec/record.d.ts +0 -18
  168. package/.bob/esm/codec/record.js +0 -172
  169. package/.bob/esm/codec/registry.d.ts +0 -8
  170. package/.bob/esm/codec/registry.js +0 -23
  171. package/.bob/esm/codec/sections.d.ts +0 -41
  172. package/.bob/esm/codec/sections.js +0 -170
  173. package/.bob/esm/codec/text.d.ts +0 -5
  174. package/.bob/esm/codec/text.js +0 -26
  175. package/.bob/esm/codec/types.d.ts +0 -36
  176. package/.bob/esm/codec/types.js +0 -12
  177. package/.bob/esm/codec/windows1255.d.ts +0 -9
  178. package/.bob/esm/codec/windows1255.js +0 -32
  179. package/.bob/esm/errors.d.ts +0 -32
  180. package/.bob/esm/errors.js +0 -94
  181. package/.bob/esm/file/assemble.d.ts +0 -17
  182. package/.bob/esm/file/assemble.js +0 -25
  183. package/.bob/esm/file/control.d.ts +0 -13
  184. package/.bob/esm/file/control.js +0 -41
  185. package/.bob/esm/file/parse.d.ts +0 -18
  186. package/.bob/esm/file/parse.js +0 -474
  187. package/.bob/esm/file/split.d.ts +0 -17
  188. package/.bob/esm/file/split.js +0 -68
  189. package/.bob/esm/index.d.ts +0 -16
  190. package/.bob/esm/index.js +0 -11
  191. package/.bob/esm/layout/2024/layout.generated.d.ts +0 -6919
  192. package/.bob/esm/layout/2024/layout.generated.js +0 -7221
  193. package/.bob/esm/layout/2025/index.d.ts +0 -6
  194. package/.bob/esm/layout/2025/index.js +0 -7
  195. package/.bob/esm/layout/capital-gains.d.ts +0 -9
  196. package/.bob/esm/layout/capital-gains.js +0 -11
  197. package/.bob/esm/layout/countries.d.ts +0 -5
  198. package/.bob/esm/layout/countries.js +0 -7
  199. package/.bob/esm/layout/freeze.d.ts +0 -5
  200. package/.bob/esm/layout/freeze.js +0 -13
  201. package/.bob/esm/layout/registry.d.ts +0 -10
  202. package/.bob/esm/layout/registry.js +0 -27
  203. package/.bob/esm/layout/types.d.ts +0 -82
  204. package/.bob/esm/layout/types.js +0 -32
  205. package/.bob/esm/model/codes.generated.d.ts +0 -48
  206. package/.bob/esm/model/codes.generated.js +0 -625
  207. package/.bob/esm/model/index.d.ts +0 -3
  208. package/.bob/esm/model/index.js +0 -2
  209. package/.bob/esm/model/input.d.ts +0 -543
  210. package/.bob/esm/model/input.js +0 -21
  211. package/.bob/esm/model/normalized.d.ts +0 -43
  212. package/.bob/esm/model/normalized.js +0 -0
  213. package/.bob/esm/model/options.d.ts +0 -14
  214. package/.bob/esm/model/options.js +0 -0
  215. package/.bob/esm/model/schema.d.ts +0 -594
  216. package/.bob/esm/model/schema.js +0 -335
  217. package/.bob/esm/normalize/canonical.d.ts +0 -13
  218. package/.bob/esm/normalize/canonical.js +0 -285
  219. package/.bob/esm/normalize/capital-gains/assets.d.ts +0 -37
  220. package/.bob/esm/normalize/capital-gains/assets.js +0 -87
  221. package/.bob/esm/normalize/capital-gains/index.d.ts +0 -61
  222. package/.bob/esm/normalize/capital-gains/index.js +0 -142
  223. package/.bob/esm/normalize/capital-gains/no-withholding.d.ts +0 -18
  224. package/.bob/esm/normalize/capital-gains/no-withholding.js +0 -31
  225. package/.bob/esm/normalize/capital-gains/other.d.ts +0 -54
  226. package/.bob/esm/normalize/capital-gains/other.js +0 -112
  227. package/.bob/esm/normalize/capital-gains/section6.d.ts +0 -7
  228. package/.bob/esm/normalize/capital-gains/section6.js +0 -9
  229. package/.bob/esm/normalize/capital-gains/securities.d.ts +0 -26
  230. package/.bob/esm/normalize/capital-gains/securities.js +0 -52
  231. package/.bob/esm/normalize/denormalize.d.ts +0 -42
  232. package/.bob/esm/normalize/denormalize.js +0 -354
  233. package/.bob/esm/normalize/derive.d.ts +0 -57
  234. package/.bob/esm/normalize/derive.js +0 -99
  235. package/.bob/esm/normalize/enums.d.ts +0 -58
  236. package/.bob/esm/normalize/enums.js +0 -64
  237. package/.bob/esm/normalize/fields.d.ts +0 -28
  238. package/.bob/esm/normalize/fields.js +0 -81
  239. package/.bob/esm/normalize/foreign.d.ts +0 -22
  240. package/.bob/esm/normalize/foreign.js +0 -81
  241. package/.bob/esm/normalize/main.d.ts +0 -24
  242. package/.bob/esm/normalize/main.js +0 -204
  243. package/.bob/esm/normalize/paths.d.ts +0 -74
  244. package/.bob/esm/normalize/paths.js +0 -161
  245. package/.bob/esm/normalize/phone.d.ts +0 -12
  246. package/.bob/esm/normalize/phone.js +0 -32
  247. package/.bob/esm/normalize/rd-investments.d.ts +0 -10
  248. package/.bob/esm/normalize/rd-investments.js +0 -22
  249. package/.bob/esm/normalize/related-companies.d.ts +0 -10
  250. package/.bob/esm/normalize/related-companies.js +0 -22
  251. package/.bob/esm/normalize/report.d.ts +0 -9
  252. package/.bob/esm/normalize/report.js +0 -50
  253. package/.bob/esm/normalize/shareholders.d.ts +0 -10
  254. package/.bob/esm/normalize/shareholders.js +0 -27
  255. package/.bob/esm/normalize/text.d.ts +0 -11
  256. package/.bob/esm/normalize/text.js +0 -37
  257. package/.bob/esm/normalize/today.d.ts +0 -4
  258. package/.bob/esm/normalize/today.js +0 -11
  259. package/.bob/esm/pipeline.d.ts +0 -13
  260. package/.bob/esm/pipeline.js +0 -34
  261. package/.bob/esm/response/codes.d.ts +0 -2
  262. package/.bob/esm/response/codes.js +0 -28
  263. package/.bob/esm/validate/capital-gains-rules.d.ts +0 -6
  264. package/.bob/esm/validate/capital-gains-rules.js +0 -159
  265. package/.bob/esm/validate/check-digit.d.ts +0 -10
  266. package/.bob/esm/validate/check-digit.js +0 -23
  267. package/.bob/esm/validate/engine.d.ts +0 -5
  268. package/.bob/esm/validate/engine.js +0 -32
  269. package/.bob/esm/validate/field-rules.d.ts +0 -4
  270. package/.bob/esm/validate/field-rules.js +0 -328
  271. package/.bob/esm/validate/foreign-rules.d.ts +0 -6
  272. package/.bob/esm/validate/foreign-rules.js +0 -168
  273. package/.bob/esm/validate/issue.d.ts +0 -51
  274. package/.bob/esm/validate/issue.js +0 -72
  275. package/.bob/esm/validate/main-rules.d.ts +0 -24
  276. package/.bob/esm/validate/main-rules.js +0 -420
  277. package/.bob/esm/validate/parse-rules.d.ts +0 -31
  278. package/.bob/esm/validate/parse-rules.js +0 -110
  279. package/.bob/esm/validate/rules.d.ts +0 -746
  280. package/.bob/esm/validate/rules.js +0 -676
  281. package/.bob/esm/validate/shape.d.ts +0 -19
  282. package/.bob/esm/validate/shape.js +0 -227
  283. package/.bob/esm/validate/shareholder-rules.d.ts +0 -6
  284. package/.bob/esm/validate/shareholder-rules.js +0 -80
  285. package/.bob/esm/validate/structure-rules.d.ts +0 -26
  286. package/.bob/esm/validate/structure-rules.js +0 -122
  287. package/.bob/tsconfig.tsbuildinfo +0 -1
  288. package/.gitattributes +0 -1
  289. package/CLAUDE.md +0 -39
  290. package/dist/cjs/index.js +0 -28
  291. package/dist/esm/index.js +0 -11
  292. package/documentation/IMPLEMENTATION_PLAN.md +0 -2258
  293. package/documentation/SPEC.md +0 -1803
  294. package/documentation/layout/2024/codes.csv +0 -261
  295. package/documentation/layout/2024/countries.csv +0 -256
  296. package/documentation/layout/2024/fields.csv +0 -271
  297. package/documentation/layout/2024/records.csv +0 -18
  298. package/documentation/layout/README.md +0 -87
  299. package/documentation/specifications/1214-2024.pdf +0 -0
  300. package/documentation/tools/extract_layout.py +0 -191
  301. package/scripts/generate-layout.ts +0 -23
  302. package/scripts/layout/csv.ts +0 -111
  303. package/scripts/layout/derived-codes.ts +0 -12
  304. package/scripts/layout/render.ts +0 -364
  305. package/scripts/layout/sources.ts +0 -51
  306. package/scripts/layout/values.ts +0 -42
  307. package/scripts/render-rules-table.ts +0 -66
  308. package/src/api/generate.ts +0 -169
  309. package/src/api/parse.ts +0 -58
  310. package/src/api/response.ts +0 -110
  311. package/src/api/validate.ts +0 -26
  312. package/src/codec/boolean.ts +0 -62
  313. package/src/codec/date.ts +0 -75
  314. package/src/codec/enum.ts +0 -28
  315. package/src/codec/numeric.ts +0 -208
  316. package/src/codec/padding.ts +0 -33
  317. package/src/codec/percent.ts +0 -35
  318. package/src/codec/phone.ts +0 -54
  319. package/src/codec/record.ts +0 -206
  320. package/src/codec/registry.ts +0 -27
  321. package/src/codec/sections.ts +0 -208
  322. package/src/codec/text.ts +0 -31
  323. package/src/codec/types.ts +0 -47
  324. package/src/codec/windows1255.ts +0 -38
  325. package/src/errors.ts +0 -114
  326. package/src/file/assemble.ts +0 -42
  327. package/src/file/control.ts +0 -59
  328. package/src/file/parse.ts +0 -620
  329. package/src/file/split.ts +0 -86
  330. package/src/index.ts +0 -70
  331. package/src/layout/2024/layout.generated.ts +0 -7238
  332. package/src/layout/2025/index.ts +0 -9
  333. package/src/layout/capital-gains.ts +0 -20
  334. package/src/layout/countries.ts +0 -7
  335. package/src/layout/freeze.ts +0 -13
  336. package/src/layout/registry.ts +0 -33
  337. package/src/layout/types.ts +0 -134
  338. package/src/model/codes.generated.ts +0 -1190
  339. package/src/model/index.ts +0 -4
  340. package/src/model/input.ts +0 -594
  341. package/src/model/normalized.ts +0 -38
  342. package/src/model/options.ts +0 -17
  343. package/src/model/schema.ts +0 -381
  344. package/src/normalize/canonical.ts +0 -374
  345. package/src/normalize/capital-gains/assets.ts +0 -112
  346. package/src/normalize/capital-gains/index.ts +0 -212
  347. package/src/normalize/capital-gains/no-withholding.ts +0 -46
  348. package/src/normalize/capital-gains/other.ts +0 -153
  349. package/src/normalize/capital-gains/section6.ts +0 -14
  350. package/src/normalize/capital-gains/securities.ts +0 -73
  351. package/src/normalize/denormalize.ts +0 -426
  352. package/src/normalize/derive.ts +0 -136
  353. package/src/normalize/enums.ts +0 -87
  354. package/src/normalize/fields.ts +0 -110
  355. package/src/normalize/foreign.ts +0 -114
  356. package/src/normalize/main.ts +0 -284
  357. package/src/normalize/paths.ts +0 -184
  358. package/src/normalize/phone.ts +0 -45
  359. package/src/normalize/rd-investments.ts +0 -38
  360. package/src/normalize/related-companies.ts +0 -37
  361. package/src/normalize/report.ts +0 -59
  362. package/src/normalize/shareholders.ts +0 -42
  363. package/src/normalize/text.ts +0 -40
  364. package/src/normalize/today.ts +0 -15
  365. package/src/pipeline.ts +0 -42
  366. package/src/response/codes.ts +0 -30
  367. package/src/validate/capital-gains-rules.ts +0 -199
  368. package/src/validate/check-digit.ts +0 -25
  369. package/src/validate/engine.ts +0 -45
  370. package/src/validate/field-rules.ts +0 -383
  371. package/src/validate/foreign-rules.ts +0 -274
  372. package/src/validate/issue.ts +0 -121
  373. package/src/validate/main-rules.ts +0 -678
  374. package/src/validate/parse-rules.ts +0 -169
  375. package/src/validate/rules.ts +0 -747
  376. package/src/validate/shape.ts +0 -278
  377. package/src/validate/shareholder-rules.ts +0 -92
  378. package/src/validate/structure-rules.ts +0 -136
  379. package/tests/api/batch.test.ts +0 -227
  380. package/tests/api/exports.test.ts +0 -355
  381. package/tests/api/generate.test.ts +0 -409
  382. package/tests/api/parse.test.ts +0 -789
  383. package/tests/api/response.test.ts +0 -152
  384. package/tests/api/validate.test.ts +0 -86
  385. package/tests/codec/numeric.test.ts +0 -325
  386. package/tests/codec/record.test.ts +0 -318
  387. package/tests/codec/registry.test.ts +0 -17
  388. package/tests/codec/sections.test.ts +0 -333
  389. package/tests/codec/text.test.ts +0 -454
  390. package/tests/codec/windows1255.test.ts +0 -46
  391. package/tests/docs/readme.test.ts +0 -69
  392. package/tests/edge-cases.test.ts +0 -359
  393. package/tests/errors.test.ts +0 -138
  394. package/tests/file/assemble.test.ts +0 -188
  395. package/tests/file/split.test.ts +0 -61
  396. package/tests/fixtures/builders.ts +0 -512
  397. package/tests/fixtures/files.ts +0 -78
  398. package/tests/fixtures/golden/README.md +0 -37
  399. package/tests/fixtures/golden/VERIFICATION.md +0 -72
  400. package/tests/fixtures/golden/batch-50.input.ts +0 -92
  401. package/tests/fixtures/golden/batch-50.opcn +0 -150
  402. package/tests/fixtures/golden/capital-gains-max.input.ts +0 -177
  403. package/tests/fixtures/golden/capital-gains-max.opcn +0 -17
  404. package/tests/fixtures/golden/cg-27.input.ts +0 -63
  405. package/tests/fixtures/golden/cg-27.opcn +0 -4
  406. package/tests/fixtures/golden/cg-50.input.ts +0 -59
  407. package/tests/fixtures/golden/cg-50.opcn +0 -4
  408. package/tests/fixtures/golden/cg-51.input.ts +0 -60
  409. package/tests/fixtures/golden/cg-51.opcn +0 -4
  410. package/tests/fixtures/golden/cg-54.input.ts +0 -53
  411. package/tests/fixtures/golden/cg-54.opcn +0 -4
  412. package/tests/fixtures/golden/cg-60.input.ts +0 -77
  413. package/tests/fixtures/golden/cg-60.opcn +0 -4
  414. package/tests/fixtures/golden/cg-63.input.ts +0 -51
  415. package/tests/fixtures/golden/cg-63.opcn +0 -4
  416. package/tests/fixtures/golden/cg-64.input.ts +0 -62
  417. package/tests/fixtures/golden/cg-64.opcn +0 -4
  418. package/tests/fixtures/golden/cg-65.input.ts +0 -79
  419. package/tests/fixtures/golden/cg-65.opcn +0 -4
  420. package/tests/fixtures/golden/cg-66.input.ts +0 -53
  421. package/tests/fixtures/golden/cg-66.opcn +0 -4
  422. package/tests/fixtures/golden/cg-77.input.ts +0 -109
  423. package/tests/fixtures/golden/cg-77.opcn +0 -4
  424. package/tests/fixtures/golden/foreign.input.ts +0 -202
  425. package/tests/fixtures/golden/foreign.opcn +0 -27
  426. package/tests/fixtures/golden/hebrew-edge.input.ts +0 -90
  427. package/tests/fixtures/golden/hebrew-edge.opcn +0 -8
  428. package/tests/fixtures/golden/kibbutz.input.ts +0 -31
  429. package/tests/fixtures/golden/kibbutz.opcn +0 -2
  430. package/tests/fixtures/golden/main-full.input.ts +0 -780
  431. package/tests/fixtures/golden/main-full.opcn +0 -101
  432. package/tests/fixtures/golden/minimal.input.ts +0 -37
  433. package/tests/fixtures/golden/minimal.opcn +0 -3
  434. package/tests/fixtures/golden/related-and-rd.input.ts +0 -59
  435. package/tests/fixtures/golden/related-and-rd.opcn +0 -11
  436. package/tests/fixtures/random.ts +0 -843
  437. package/tests/golden/fixtures.test.ts +0 -627
  438. package/tests/golden/golden.test.ts +0 -95
  439. package/tests/helpers/coverage.ts +0 -18
  440. package/tests/helpers/sample-values.ts +0 -114
  441. package/tests/layout/codegen-sync.test.ts +0 -19
  442. package/tests/layout/integrity.test.ts +0 -232
  443. package/tests/layout/registry.test.ts +0 -98
  444. package/tests/model/code-unions.test.ts +0 -91
  445. package/tests/model/schema.test.ts +0 -1031
  446. package/tests/normalize/canonical.test.ts +0 -728
  447. package/tests/normalize/capital-gains.test.ts +0 -1850
  448. package/tests/normalize/coverage.test.ts +0 -88
  449. package/tests/normalize/denormalize.test.ts +0 -318
  450. package/tests/normalize/enums.test.ts +0 -118
  451. package/tests/normalize/foreign.test.ts +0 -273
  452. package/tests/normalize/main.test.ts +0 -839
  453. package/tests/normalize/paths.test.ts +0 -257
  454. package/tests/normalize/rd-investments.test.ts +0 -99
  455. package/tests/normalize/related-companies.test.ts +0 -106
  456. package/tests/normalize/shareholders.test.ts +0 -117
  457. package/tests/normalize/text.test.ts +0 -86
  458. package/tests/pipeline.test.ts +0 -96
  459. package/tests/roundtrip/determinism.test.ts +0 -207
  460. package/tests/roundtrip/property.test.ts +0 -126
  461. package/tests/roundtrip/roundtrip.test.ts +0 -573
  462. package/tests/rules/cases.ts +0 -873
  463. package/tests/rules/rules.test.ts +0 -69
  464. package/tests/rules/spec-sync.test.ts +0 -80
  465. package/tests/scripts/csv.test.ts +0 -78
  466. package/tests/scripts/values.test.ts +0 -80
  467. package/tests/validate/capital-gains-rules.test.ts +0 -307
  468. package/tests/validate/check-digit.test.ts +0 -42
  469. package/tests/validate/field-rules.test.ts +0 -867
  470. package/tests/validate/foreign-rules.test.ts +0 -255
  471. package/tests/validate/issue.test.ts +0 -96
  472. package/tests/validate/main-rules.test.ts +0 -761
  473. package/tests/validate/parse-rules.test.ts +0 -293
  474. package/tests/validate/shareholder-rules.test.ts +0 -143
  475. package/tsconfig.json +0 -10
  476. package/tsconfig.typecheck.json +0 -9
  477. package/vitest.config.ts +0 -11
@@ -1,2258 +0,0 @@
1
- # `@accounter/opcn1214-generator` — Implementation Plan
2
-
3
- Audience: the tech lead driving the build, and the coding agent(s) executing it. Companion to
4
- [`SPEC.md`](SPEC.md) (the _what_); this document is the _how_ and _in what order_.
5
-
6
- - **Part 1** — blueprint: the architecture as it will be built, the internal contracts every step
7
- relies on, and the deltas this plan makes to the spec.
8
- - **Part 2** — how the work was sliced (three rounds of breakdown) and the resulting step map.
9
- - **Part 3** — the prompts: one self-contained, test-driven instruction block per step, in order.
10
- Every block is fenced as `text` so it can be pasted into an agent unchanged.
11
-
12
- ---
13
-
14
- ## Part 1 — Blueprint
15
-
16
- ### 1.1 Shape of the system
17
-
18
- ```
19
- Report1214Input ─► shape (zod) ─► normalize ─► NormalizedReport ─► rule engine ─► (no errors) ─► assemble file ─► bytes
20
- ▲ │
21
- OPCN file ─► split lines ─► decode records ─────────┘ ◄──────────────── same codecs ─────────────────────┘
22
- │
23
- └─► denormalize ─► canonical Report1214Input
24
- ```
25
-
26
- Three ideas carry the whole design:
27
-
28
- 1. **The layout is data.** `documentation/layout/<year>/*.csv` → generated `as const` TypeScript.
29
- Field order, widths, kinds, allowed values and code tables are never hand-coded twice.
30
- 2. **Paired codecs.** Every field kind has one `Codec` with `encode` and `decode`. A generic record
31
- codec walks the layout. Generation and parsing therefore share one implementation, and the round
32
- trip is testable from the very first primitive.
33
- 3. **One internal model.** `NormalizedReport` sits between the public input and the bytes. The
34
- normalizer (input → model) and denormalizer (model → input) are the only code that knows the
35
- public input shape; codecs, rules and file assembly only see the model.
36
-
37
- ### 1.2 Internal contracts (fixed by early steps, relied on by all later ones)
38
-
39
- ```ts
40
- // src/codec/types.ts — created in B1
41
- export type Primitive = string | number | boolean | undefined
42
-
43
- export interface FieldShape {
44
- length: number
45
- type: 'numeric' | 'alphanumeric'
46
- kind: FieldKind | CodeKind
47
- values?: readonly EnumValue[]
48
- }
49
-
50
- export interface Codec {
51
- /** Returns exactly `shape.length` characters. Throws Opcn1214InternalError for a value that
52
- * validation should have rejected (encoders never repair data). */
53
- encode(value: Primitive, shape: FieldShape): string
54
- /** Inverse of encode. All-zero numeric text decodes to 0 and all-space text to undefined; the
55
- * record codec (B4) decides whether 0 means "absent" (it does for non-required header fields,
56
- * except amountX). Throws CodecDecodeError for raw text that cannot be decoded; the parser
57
- * converts it into a parse.* issue. */
58
- decode(raw: string, shape: FieldShape): Primitive
59
- }
60
-
61
- export class CodecDecodeError extends Error {
62
- readonly reason: 'numeric' | 'date' | 'format' | 'section' | 'length'
63
- readonly offset: number // 0-based offset within the decoded text (field, section or line)
64
- }
65
-
66
- // src/normalize/paths.ts — created in C1, shared by the normalizer and the parser (C7b)
67
- export function pathFor(recordType: RecordType, inputIndex: number, key: string): string
68
-
69
- // src/model/normalized.ts — created in C1
70
- export interface NormalizedRecord {
71
- recordType: RecordType
72
- index: number // 0-based among records of the same type
73
- inputIndex?: number // 30xx only: index in `capitalGains` (parser: index among all 30xx records)
74
- values: Record<string, Primitive> // FieldDef.key → value (derived keys included)
75
- codes: Map<string, number> // code-amount section, natural units
76
- countries: Array<{ country: string; income: number }> // 2200 only, otherwise []
77
- paths: Record<string, string> // key | `code:${code}` | `countries[${i}]` → input path
78
- }
79
-
80
- export interface NormalizedReport {
81
- taxYear: number
82
- layout: YearLayout
83
- records: NormalizedRecord[] // canonical order (SPEC §3.3), 9999 excluded
84
- notices: Issue[] // raised while normalizing (e.g. phone prefix dropped)
85
- omittedZeroCodes: Array<{ record: RecordType; recordIndex: number; code: string }>
86
- }
87
-
88
- // src/pipeline.ts — created in C3 (year stage included), extended in C5 (shape stage)
89
- export function runPipeline(
90
- input: unknown,
91
- options?: ValidateOptions
92
- ): { report?: NormalizedReport; issues: Issue[] } // issues sorted (SPEC §9.1)
93
- ```
94
-
95
- Value conventions inside `NormalizedRecord.values` (by kind):
96
-
97
- | Kind(s) | Value type in the model |
98
- | ------------------------------------------------------------------------------ | --------------------------------------------- |
99
- | `text`, `hebrewText` | normalized `string` (SPEC §4.3) |
100
- | `id9`, `shareholderId`, `digits` | digit `string` (kept as string) |
101
- | `num`, `year`, `count`, `serial`, `const`, `foreignCode`, `enum` | `number` (enums already mapped to their code) |
102
- | `amount`, `amountX`, `amountX100`, `rateX100`, `percentX100`, `percentLiteral` | `number` in natural units (ILS, percent) |
103
- | `date` | ISO `YYYY-MM-DD` `string` |
104
- | `flag`, `yesNo` | `boolean` |
105
- | `phonePrefix` | prefix `string` (`'052'`) |
106
- | `filler` | never stored |
107
- | any kind, absent | `undefined` |
108
-
109
- A value that failed a type conversion in the normalizer (e.g. `'12a'` for a numeric field) is kept
110
- **as the raw input** so the field rules report it; encoders are never reached with it because
111
- generation stops on errors.
112
-
113
- Facts that exist in the input but have no field of their own (a 6th reportable position, an explicit
114
- `hasCapitalGainsAppendix: false` while appendices exist, an invalid phone prefix that is dropped)
115
- are reported by the normalizer as `notices` with the rule ID that owns them; the engine merges
116
- notices with the other stages.
117
-
118
- ### 1.3 Spec changes made with this plan
119
-
120
- All rows below are **already applied** to `SPEC.md` (and D-13 to `layout/2024/fields.csv`) in the
121
- same commit as this plan; agents implement the spec as it now reads. The table is the change log.
122
-
123
- | # | Change | Why |
124
- | ---- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------- |
125
- | D-1 | `src/encode/` + `src/decode/` become `src/codec/` (paired codecs) and `src/file/` (assemble/split lines). `src/pipeline.ts` is added. | Shared implementation, round-trip tests per primitive |
126
- | D-2 | The parser ships in Part C (walking skeleton), not in a late phase; each later record slice adds encode **and** decode together. | No orphan code; round trip from the first report |
127
- | D-3 | Canonical form (SPEC §8.4) additions: digit-string inputs mapped to numeric fields are canonicalized to the field width with zero padding (`'12'` → `'012'` for a 3-digit branch); optional numeric header values equal to `0` are absent. | Makes `parse(generate(x)) = canonicalize(x)` exact |
128
- | D-4 | Header fillers are ignored on decode (only the 9–136 prefix is checked, `parse.prefixFiller`); generation always writes zeros/spaces. | Tolerant parser, strict generator |
129
- | D-5 | `main.kibbutz.code226` splits into `main.kibbutz.code226` (E: kibbutz without code 226) and `main.kibbutz.code226Other` (W: code 226 = 9 while kibbutz). `field.phonePrefix` is W only (the follow-up `field.required` is the error). | One severity per rule ID |
130
- | D-6 | `cg.code018` is removed; code 018 in 30xx records is covered by `field.enum` (allowed values 23, 50). | No duplicate rules |
131
- | D-7 | Tests are type-checked by a dedicated `tsconfig.typecheck.json` (`typecheck` script); package tests run with the package Vitest config (the root `unit` project needs Postgres). | Type-safe tests, fast local runs |
132
- | D-8 | Phase mapping: P0 = Part A, P1 = Parts B–D, P2 = Part E, P3 = Part F, P4 = Part G, P5 + P6 = Part H. | Plan/spec alignment |
133
- | D-9 | `field.taxYear` is removed: the shape stage only admits supported years and the parser selects the layout from 1000@146, so the rule can never fire. | Every rule must have a failing case |
134
- | D-10 | `struct.section.overflow` is removed: with every code of a record filled, each section still fits (1000: 1295 of 2048; 2000: 765 of 1024; largest 30xx: 273 of 1024). A layout integrity test asserts this per year, and the section encoder keeps its internal-error guard. | Every rule must have a failing case |
135
- | D-11 | `struct.foreignCountryRecords.max` is removed: one 2200 record per per-country code and only 23 such codes exist, so input can produce at most 23 (< 30); parsed files exceeding 30 are reported by `parse.occurrences`. | Every rule must have a failing case |
136
- | D-12 | Slot-aware `field.required`: a required field inside a repeated slot (`improvements[i].date`, …) is required only when another key of that slot has a value. `cg.improvements.date` is removed (covered). | Empty slots must not raise errors |
137
- | D-13 | New kind `digits` for identifier digit strings stored in numeric fields (phone numbers, withholder branch/account; 27 rows of fields.csv); `num` is numbers only. | `field.phoneNumber` and round trip need the string |
138
- | D-14 | `field.enum` applies to kinds `enum` and `rateX100` only (special values of `shareholderId`, and `values` of `yesNo`/`flag`/`const`/`phonePrefix`, are documentation, not exhaustive lists). `field.charset` owns the "no control characters" check; the windows-1255 helper checks code-page membership only. | Precise rule scope; CRLF is encodable |
139
- | D-15 | Parser: only maximum occurrences are enforced (`struct.shareholders.min` handles the minimum); an unsupported year in a file is `struct.taxYear.unsupported`. Goldens are committed PENDING with their sha256 in `VERIFICATION.md`, asserted by the golden test. RuleCase kinds `input`, `file`, `batch`. | Kibbutz files parse; goldens cannot change silently |
140
- | D-16 | The zod schema accepts any string for phone prefixes and country codes (rules check them); unknown/derived code keys are reported before zod and removed; `unrecognized_keys` becomes one `input.shape` issue per key; path segments that are not identifiers use `["…"]`. | Rules stay reachable; no double reports |
141
-
142
- ### 1.4 Plan review record
143
-
144
- An independent review (23 findings) was applied: blockers fixed — CRLF vs. the windows-1255 helper
145
- (B2), the `RuleId` circular type (C3), `struct.taxYear.unsupported` ordering (C3),
146
- schema-unreachable rules (C5, F2), empty improvement slots (D-12); majors — `digits` kind (D-13),
147
- decode/optional split (B1/B4), `field.enum` scope (D-14), zod issue mapping (C5/D3, D-16), file-case
148
- semantics and parse paths (C7b), notices for input-only facts (§1.2), `main-full` moved to D5,
149
- generated files ignored by lint and tests run last, file paths via `import.meta.url`, `typecheck` in
150
- CI, C7 split into C7a/C7b, golden sha256 guard, maxima-only parse occurrences; minors folded into
151
- the affected steps.
152
-
153
- ### 1.5 Test strategy at a glance
154
-
155
- - **Unit tests per codec** with round trip (`decode(encode(v)) === v`) and exact-string asserts.
156
- - **Generic layout tests** that run every record type of the year through the record codec with
157
- sample values (B4) — proves the engine for all 17 record types before any business code exists.
158
- - **Rule cases**: `tests/rules/cases.ts` is typed `{ [K in RuleId]: RuleCase }`, so adding a rule
159
- without a pass/fail case is a type error; `rules.test.ts` runs every case.
160
- - **Golden files** (`tests/fixtures/golden/*.opcn`, windows-1255 bytes) for byte-level stability,
161
- each verified once on SHAAM's structure checker by a human (checkpoints in Part 3); their sha256
162
- is recorded in `VERIFICATION.md` and asserted, so regenerating a golden is always a visible
163
- change.
164
- - **Round trip** generate → parse → `canonicalize` for every fixture; parse → generate byte equality
165
- for every golden file; seeded randomized inputs at the end (H3).
166
-
167
- ---
168
-
169
- ## Part 2 — Slicing the work
170
-
171
- ### 2.1 Round 1 — milestones
172
-
173
- | Milestone | Outcome |
174
- | --------- | ----------------------------------------------------------------------------- |
175
- | M1 | Layout available as typed data for any supported year |
176
- | M2 | Any record of the layout can be encoded and decoded |
177
- | M3 | A minimal, real 1214 file can be validated, generated and parsed (public API) |
178
- | M4 | Record 1000 complete with every rule |
179
- | M5 | Related companies and R&D investments |
180
- | M6 | Foreign appendix with country breakdown |
181
- | M7 | All ten capital-gains appendices |
182
- | M8 | Batch, response file, hardening, release |
183
-
184
- ### 2.2 Round 2 — chunks
185
-
186
- M3 was the riskiest milestone ("walking skeleton"), so it was split into model → assembly →
187
- validation framework → field rules → shape → API → parser. M4 was split by input group and by rule
188
- family. M7 was split by appendix family (the ten types share four shapes).
189
-
190
- ### 2.3 Round 3 — steps, and the sizing check
191
-
192
- Every candidate step was checked against these criteria; steps that failed were split or merged:
193
-
194
- - **One concept** a reviewer can hold in their head; roughly 150–500 lines of production code.
195
- - **Tests first** and able to fail for the right reason before the implementation exists.
196
- - **Ends integrated**: the new code is reachable from the previous layer's entry point by the end of
197
- the step (no module that only its own tests import, except the foundation layer in Parts A–B,
198
- whose consumer is the very next step).
199
- - **Green at the end**: typecheck, tests, lint, prettier and build pass; one commit per step.
200
- - **No forward references**: a step never needs a type or function introduced later.
201
-
202
- Adjustments made in this round: the code generator was split (fields vs. codes); codecs were split
203
- into numeric and text/date families; record-1000 work was split into three input groups and two rule
204
- groups; capital gains were split into one framework step plus four family steps; batch and
205
- response-file parsing were separated from parser hardening.
206
-
207
- ### 2.4 Step map
208
-
209
- | Step | Title | Adds rules | Golden / checkpoint |
210
- | ---- | ---------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------- |
211
- | A1 | Tooling baseline | — | |
212
- | A2 | Layout generator v1: records and header fields | — | |
213
- | A3 | Layout generator v2: codes, countries, code unions | — | |
214
- | A4 | Layout registry, integrity tests, first public exports | — | |
215
- | B1 | Codec contract and numeric codecs | — | |
216
- | B2 | Text normalization, windows-1255, text/date/boolean codecs | — | |
217
- | B3 | Code-amount and country-amount section codecs | — | |
218
- | B4 | Record codec and all-records round trip | — | |
219
- | C1 | Skeleton input model and normalizer (1000 core + 1020) | — | |
220
- | C2 | File assembly and the 9999 control record | — | |
221
- | C3 | Validation framework, year stage, first field rules | `struct.taxYear.unsupported` `field.required` `field.numeric` `field.length` `field.charset` | |
222
- | C4 | Remaining generic field rules | `field.integer` `field.decimals` `field.negative` `field.enum` `field.date` `field.percentRange` `field.hebrewFirstLetter` `field.phonePrefix` `field.phoneNumber` | |
223
- | C5 | Shape stage (zod) | `input.shape` | |
224
- | C6 | Public API v1: `validate1214`, `generate1214` | — | `minimal` · **CP-1** |
225
- | C7a | Parser v1: happy path and round trip | — | |
226
- | C7b | Parser v1: structural errors | `parse.empty` `parse.encoding` `parse.lineLength` `parse.formType` `parse.recordType` `parse.prefixFiller` `parse.order` `parse.control.missing` `parse.control.counts` `parse.numeric` `parse.date` `parse.codeSection` | |
227
- | D1 | Declarations and preparer | — | |
228
- | D2 | Other income, attachments, CG summary, qualifying company | — | |
229
- | D3 | Derived main codes and code-map guards | `input.derivedCode` `input.unknownCode` `struct.mainCodePairs.max` `main.bankAccount.format` | |
230
- | D4 | Record 1000 conditional requirements | `main.familyCompany.*` `main.houseCompany.code084` `main.investmentLaw.flag` `main.beneficiaryEnterprise.noticeDate` `main.specialYear.balanceSheetDate` `main.kibbutz.code226` `main.buildingIncome.code259` `main.cgReasons.otherText` `main.reportablePositions.required` `main.reportablePositions.max` | |
231
- | D5 | Record 1000 warnings and shareholder rules | `main.kibbutz.code226Other` `main.reportablePositions.unexpected` `main.cgUntransmitted.*` `main.bankAccount.withNoBank` `main.qualifyingCompany.*` `main.attachments.*` `shareholders.*` `struct.shareholders.min` `struct.shareholders.max` | `main-full` `kibbutz` · **CP-2** |
232
- | E1 | Related companies (1010) | `struct.relatedCompanies.max` | |
233
- | E2 | R&D investments (1030) | `struct.rdInvestments.max` `main.rd.records` `main.rd.total` | `related-and-rd` |
234
- | F1 | Foreign appendix (2000) | `foreign.otherIncome.description` `foreign.refund.amount` | |
235
- | F2 | Country breakdown (2200) | `foreign.breakdown.*` `parse.countrySection` | `foreign` · **CP-3** |
236
- | G1 | Capital-gains framework + 3063 | `struct.capitalGains.max` `main.capitalGains.flag` `main.appendixTotal.min` | `cg-63` |
237
- | G2 | Securities with withholders: 3060, 3064 | — | `cg-60` `cg-64` |
238
- | G3 | No-withholding appendices: 3065, 3066 | — | `cg-65` `cg-66` |
239
- | G4 | Asset appendices: 3027, 3050, 3054, 3051 | — | `cg-27` `cg-50` `cg-54` `cg-51` |
240
- | G5 | Other transactions: 3077 | `cg.improvements.max` `cg.improvements.code50Amount` `cg.virtualCurrency.wallet` | `cg-77` `capital-gains-max` · **CP-4** |
241
- | H1 | Parser hardening and batches | `parse.occurrences` `parse.multipleReports` `parse.derivedMismatch` `struct.batch.size` | `batch-50` |
242
- | H2 | Response file parser | — | |
243
- | H3 | Property, determinism and edge-case suite | — | `hebrew-edge` |
244
- | H4 | Release wiring | — | **CP-5** |
245
-
246
- `CP-n` are human checkpoints (Part 3, after the step that produces the files).
247
-
248
- ### 2.5 Branching and review
249
-
250
- One commit per step (conventional commit message given in each prompt). Recommended: one PR per Part
251
- (A–H), stacked on the spec PR, each reviewed before the next Part starts. A step may be split
252
- further by the agent if it grows beyond the sizing criteria; it must never be merged with the next.
253
-
254
- ---
255
-
256
- ## Part 3 — Prompts
257
-
258
- ### Standing instructions (prepend to every step, or point the agent at this section)
259
-
260
- ```text
261
- STANDING INSTRUCTIONS — read before every step of the 1214 generator plan
262
-
263
- Repository: accounter-fullstack (Yarn 4 monorepo). Package: packages/opcn1214-generator
264
- (@accounter/opcn1214-generator). Specification: packages/opcn1214-generator/documentation/SPEC.md.
265
- Plan: packages/opcn1214-generator/documentation/IMPLEMENTATION_PLAN.md (Part 1 holds the internal
266
- contracts you must respect). Layout data: documentation/layout/2024/*.csv.
267
-
268
- Working rules
269
- 1. Test-driven: write the tests listed in the step first, run them, see them fail for the expected
270
- reason, then implement until green. Do not weaken or skip a test to get green.
271
- 2. Do only this step. Do not implement anything listed as out of scope or belonging to a later
272
- step. Do not leave unused exports or dead code; everything you add must be reachable from the
273
- integration point named in the step's "Wiring" section.
274
- 3. TypeScript strict, ES modules only, import paths with the ".js" suffix, no default exports,
275
- no `any` (use `unknown` and narrow). Pure functions; no I/O in src/ (no fs, no network, no
276
- process.env); the only clock access is the injectable `today` option.
277
- 4. Use yarn only (never npm/npx/pnpm). Add dependencies with exact versions:
278
- yarn workspace @accounter/opcn1214-generator add --exact <pkg>@<version>
279
- 5. Tests live in packages/opcn1214-generator/tests/**, use Vitest globals, import from src/ (never
280
- dist/). Assert exact substrings of encoded lines at layout positions, e.g.
281
- line.slice(pos - 1, pos - 1 + len), in addition to any snapshot. Tests that read files (SPEC.md,
282
- CSVs, generated modules, goldens) resolve paths with new URL('…', import.meta.url): the root test
283
- runner uses the repository root as its working directory.
284
- 6. Never hand-edit generated files (src/layout/*/layout.generated.ts, src/model/codes.generated.ts)
285
- or golden files (tests/fixtures/golden/*.opcn). Regenerate them with their scripts.
286
- 7. If the spec is silent or ambiguous, choose the simplest behaviour consistent with SPEC §15,
287
- implement it, and record it in SPEC.md (§15 for ambiguities, otherwise the relevant section)
288
- in the same commit. If the spec is contradicted by real behaviour, stop and report.
289
- 8. Keep SPEC.md, RULES (src/validate/rules.ts) and tests/rules/cases.ts consistent: every rule ID
290
- added in a step exists in all three.
291
-
292
- Verify bundle (run at the end of every step, in this order; all must pass)
293
- yarn workspace @accounter/opcn1214-generator typecheck
294
- yarn workspace @accounter/opcn1214-generator build # runs `lint --fix` first, then bob
295
- yarn eslint packages/opcn1214-generator/src # root config, no --fix: the repo-wide lint CI
296
- yarn prettier --check packages/opcn1214-generator
297
- yarn workspace @accounter/opcn1214-generator test --run # last: catches anything lint --fix changed
298
- git status # lint --fix may have edited files: commit them
299
- (Do not use the root `yarn test`: its global setup requires Postgres.)
300
-
301
- Finish every step with one commit using the message given in the step, ending with the
302
- attribution lines your environment requires. Report: what changed, test counts, any spec edits,
303
- and anything you were unsure about.
304
- ```
305
-
306
- ---
307
-
308
- ### Part A — Foundation: layout as typed data
309
-
310
- #### A1 — Tooling baseline and spec deltas
311
-
312
- ```text
313
- STEP A1 — Tooling baseline and spec deltas
314
- Apply the standing instructions (IMPLEMENTATION_PLAN.md, Part 3).
315
-
316
- Context
317
- The package currently contains only documentation, a placeholder src/index.ts and a `test` script
318
- running `vitest --passWithNoTests`. Tests are not type-checked (tsconfig.json excludes tests/).
319
-
320
- Read first
321
- - IMPLEMENTATION_PLAN.md Part 1 (contracts; §1.3 lists spec changes that are already applied)
322
- - SPEC.md §5.2, §5.5, §13.9
323
- - package.json, tsconfig.json, vitest.config.ts of this package; the root tsconfig.json comment on
324
- `incremental` and CLAUDE.md "TypeScript Build Cache"
325
-
326
- Goal
327
- A test/typecheck harness ready for TDD, the runtime and dev dependencies the plan needs, and CI that
328
- runs the type check.
329
-
330
- Tests first
331
- 1. tests/smoke.test.ts — imports `SPEC_STATUS` from src/index.ts and asserts it equals
332
- 'specification' (proves the harness resolves src/ with .js-suffixed imports).
333
-
334
- Implementation
335
- - Dependencies: iconv-lite@0.7.3 (runtime); tsx@4.23.15 and prettier@3.10.1 (dev).
336
- - tsconfig.typecheck.json: extends ../../tsconfig.json; compilerOptions { noEmit: true,
337
- rootDir: ".", tsBuildInfoFile: "../../node_modules/.cache/tsbuildinfo/opcn1214-generator.tsbuildinfo" };
338
- include ["src", "tests", "scripts", "vitest.config.ts"].
339
- - package.json scripts: "typecheck": "tsc -p tsconfig.typecheck.json"; "test": "vitest"
340
- (remove --passWithNoTests); "generate:layout": "tsx scripts/generate-layout.ts" (the script is
341
- created in A2 — add the script entry in A2 instead if your tooling rejects a missing file).
342
- - .github/workflows/opcn1214-generator-test.yml: add a "Typecheck" step
343
- (yarn workspace @accounter/opcn1214-generator typecheck) between install and build.
344
-
345
- Wiring
346
- - The smoke test runs in `yarn workspace @accounter/opcn1214-generator test --run`.
347
- - `typecheck` covers src, tests and scripts.
348
-
349
- Out of scope
350
- Any src/ code beyond the existing placeholder.
351
-
352
- Verify
353
- Run the verify bundle. Also confirm `typecheck` fails if you temporarily add a type error to the
354
- smoke test (then remove it).
355
-
356
- Commit: "chore(opcn1214-generator): tooling baseline for implementation"
357
-
358
- Done when
359
- - The verify bundle passes with one test; the workflow runs typecheck, build and test.
360
- ```
361
-
362
- #### A2 — Layout generator v1: records and header fields
363
-
364
- ```text
365
- STEP A2 — Layout generator v1: records and header fields
366
- Apply the standing instructions (IMPLEMENTATION_PLAN.md, Part 3).
367
-
368
- Context
369
- documentation/layout/2024/records.csv and fields.csv describe every record and header field
370
- (SPEC §3.2, §3.4; column reference in documentation/layout/README.md). They are the source of
371
- truth; the runtime layout is generated TypeScript (SPEC §5.3).
372
-
373
- Read first
374
- - SPEC §3.2, §3.4, §4.2, §5.3, §5.4; documentation/layout/README.md; the two CSV files.
375
-
376
- Goal
377
- `yarn workspace @accounter/opcn1214-generator generate:layout` produces
378
- src/layout/2024/layout.generated.ts with all 17 records and their 270 header fields, and an
379
- internal `getLayout(2024)` returns it.
380
-
381
- Tests first
382
- 1. tests/scripts/csv.test.ts — RFC-4180 parsing: quoted fields with commas, doubled quotes,
383
- quoted newlines, CRLF and LF line endings, trailing newline, Hebrew text; header row mapped to
384
- objects; a row with the wrong number of columns throws with its line number.
385
- 2. tests/scripts/values.test.ts — the `values` grammar (`;`-separated items: `n`, `n..m`,
386
- `n=label`; split each item on the FIRST '=' only): '1=yes;2=no' →
387
- [{value:1,label:'yes'},{value:2,label:'no'}]; '1..12' → 12 items; '5;8;10;15;115;20';
388
- '999999964=…;999999998=…'; the 1000@834 value whose label contains '=' ("… (code 297=8)");
389
- '' → undefined; malformed input throws.
390
- 3. tests/layout/codegen-sync.test.ts — renders the module in memory from the CSVs with the same
391
- function the script uses (including prettier formatting with the repo config) and asserts it
392
- equals the committed layout.generated.ts.
393
- 4. tests/layout/integrity.test.ts (headers part) — for every record of getLayout(2024): fields sorted
394
- by position, first at 137, contiguous, last field ends at 136 + headerLength; headerLength plus
395
- sectionLength (if any) plus 136 equals length; keys unique per record; every kind is a FieldKind;
396
- derived fields are exactly the rows whose CSV key starts with "(derived) ".
397
-
398
- Implementation
399
- - src/layout/types.ts — RecordType, FieldKind (SPEC §4.2, including 'digits'), CodeKind
400
- ('amount'|'amountX100'|'rateX100'|'enum'|'num'), EnumValue, FieldDef (`derived: boolean`; `key`
401
- without the "(derived) " prefix),
402
- CodeDef, RecordDef, YearLayout (SPEC §5.4). CodeDef/countries are declared now but stay empty
403
- until A3 (records get `codes: []`, layout gets `countries: new Map()`).
404
- - scripts/layout/csv.ts — small RFC-4180 parser (no dependency).
405
- - scripts/layout/values.ts — values grammar parser.
406
- - scripts/layout/render.ts — `renderLayoutModule(year, { records, fields }): Promise<string>`
407
- producing an `as const` module, formatted with prettier.format() using
408
- prettier.resolveConfig() for the target path.
409
- - scripts/generate-layout.ts — for each documentation/layout/<year>/ directory, read the CSVs, write
410
- src/layout/<year>/layout.generated.ts. Header comment: "Generated by scripts/generate-layout.ts
411
- from documentation/layout/<year>/ — do not edit."
412
- - package.json "lint": add --ignore-pattern '**/*.generated.ts' so `lint --fix` (run by `build`)
413
- never rewrites generated files; the codegen-sync test is the guard.
414
- - src/layout/registry.ts — `getLayout(taxYear: number): YearLayout` for 2024 only for now
415
- (other years: throw a plain Error; A4 replaces it with the public error class).
416
-
417
- Wiring
418
- - registry.ts imports the generated module; integrity tests go through getLayout.
419
- - package.json "generate:layout" script points at scripts/generate-layout.ts.
420
-
421
- Out of scope
422
- Codes, countries, code unions (A3); 2025 and public exports (A4).
423
-
424
- Verify
425
- Run generate:layout twice — the second run produces no git diff. Run the verify bundle.
426
-
427
- Commit: "feat(opcn1214-generator): generate the record layout from CSV"
428
-
429
- Done when
430
- - All 17 records and 270 fields are in the generated module and pass the integrity tests.
431
- ```
432
-
433
- #### A3 — Layout generator v2: codes, countries and code unions
434
-
435
- ```text
436
- STEP A3 — Layout generator v2: codes, countries and code unions
437
- Apply the standing instructions (IMPLEMENTATION_PLAN.md, Part 3).
438
-
439
- Context
440
- A2 generates records and header fields; RecordDef.codes and YearLayout.countries are still empty.
441
- codes.csv holds 260 codes (1000: 102, 2000: 51, capital gains: 107) and countries.csv 255 country
442
- codes. The input model needs literal unions of codes (SPEC §5.3, §7.2).
443
-
444
- Read first
445
- - SPEC §3.5, §3.6, §4.5, §5.3, §7.4 (derived codes); codes.csv; countries.csv.
446
-
447
- Goal
448
- The generated layout contains every code and the country table; src/model/codes.generated.ts exports
449
- the code unions with the spec notes as JSDoc.
450
-
451
- Tests first
452
- 1. Extend tests/layout/integrity.test.ts: codes unique per record, 3 digits, length 1–12; total 260;
453
- 2000 has exactly 23 perCountryBreakdown codes; zeroAllowed codes are exactly
454
- 1000: 032 072 080 081 084 086 094 096 097 121 159, 2000: 442, 3054: 016; derived codes are
455
- exactly 1000: 008 028 273 277 278 280 297 and 3077: 501–505; countries: 255 unique entries,
456
- including '-88', all other codes zero-padded to 3 digits when looked up via a helper
457
- `countryKey(code)`; for every record with a code-amount section, the sum over ALL its codes of
458
- (3 + length) is <= the section length (D-10: a section can never overflow).
459
- 2. tests/model/code-unions.test.ts — type-level tests (expectTypeOf) that '010' is assignable to
460
- MainFormInputCode, '008' is not, '420' is assignable to CountryBreakdownCode, '401' is not, and
461
- CapitalGainsCode<77> includes '501'; runtime arrays (MAIN_FORM_CODES etc.) have the same members
462
- as the unions.
463
- 3. codegen-sync test covers both generated files.
464
-
465
- Implementation
466
- - Extend scripts/layout/render.ts and generate-layout.ts to read codes.csv and countries.csv:
467
- RecordDef.codes (sorted by code), CodeDef.derived from the fixed list above (put the list in
468
- scripts/layout/derived-codes.ts with a comment pointing to SPEC §7.4), YearLayout.countries as
469
- `ReadonlyMap<string, string>` keyed by 3-digit code ('-88' stays '-88').
470
- - src/model/codes.generated.ts (year-independent unions generated from the newest layout):
471
- MainFormCode, DerivedMainCode, MainFormInputCode, ForeignAppendixCode, CountryBreakdownCode,
472
- CapitalGainsSymbol (27|50|51|54|60|63|64|65|66|77), CapitalGainsCode<S>, CountryCode, plus
473
- `as const` arrays of each. JSDoc on each code literal: the Hebrew notesHe when present.
474
- - YearLayout.limits: { reportsPerFile: 50, capitalGainsAppendices: 14, mainCodePairs: 61,
475
- countriesPerRecord: 10 }.
476
- - RecordDef.section.maxEntries: 1000 → 61; 2200 → 10; every other record → its number of codes.
477
-
478
- Wiring
479
- - getLayout(2024) now returns codes and countries; codes.generated.ts is imported by nothing in
480
- src/ yet except a re-export from src/model/index.ts that C1 consumes. (Exception allowed: type
481
- modules of the foundation layer.)
482
-
483
- Out of scope
484
- 2025, public exports (A4).
485
-
486
- Verify
487
- Run generate:layout (no diff on second run) and the verify bundle.
488
-
489
- Commit: "feat(opcn1214-generator): generate code tables, country table and code unions"
490
-
491
- Done when
492
- - Integrity and union tests pass; the generated files are prettier-clean and in sync.
493
- ```
494
-
495
- #### A4 — Layout registry, integrity and first public exports
496
-
497
- ```text
498
- STEP A4 — Layout registry, integrity and first public exports
499
- Apply the standing instructions (IMPLEMENTATION_PLAN.md, Part 3).
500
-
501
- Context
502
- getLayout is internal and only knows 2024. SPEC §14 requires 2025 to reuse the 2024 layout until a
503
- 2025 spec exists, and SPEC §6.1/§6.3 define the public getLayout/supportedTaxYears and the error
504
- hierarchy.
505
-
506
- Read first
507
- - SPEC §6.1, §6.3, §6.4, §11.2, §14.
508
-
509
- Goal
510
- A public, typed layout registry for 2024 and 2025 and the error base classes; src/index.ts stops
511
- being a placeholder.
512
-
513
- Tests first
514
- 1. tests/layout/registry.test.ts — supportedTaxYears() deep-equals [2024, 2025]; getLayout(2025)
515
- deep-equals getLayout(2024) except taxYear; getLayout(2023) and getLayout(2026) throw
516
- Opcn1214UnsupportedYearError with taxYear set and an issue with ruleId
517
- 'struct.taxYear.unsupported'; the returned layout objects are frozen (Object.isFrozen at the
518
- record level).
519
- 2. tests/errors.test.ts — every error class sets `name`, extends the right parent, keeps `issues`,
520
- and Opcn1214Error's message summarizes up to five issues (SPEC §11.2).
521
- 3. tests/api/exports.test.ts — the public module exports exactly: getLayout, supportedTaxYears,
522
- Opcn1214Error, Opcn1214UnsupportedYearError, Opcn1214InternalError (runtime keys of
523
- `import * as api from '../../src/index.js'`). Update this list in every later step that adds
524
- public exports.
525
-
526
- Implementation
527
- - src/errors.ts — Opcn1214Error (issues), Opcn1214UnsupportedYearError (taxYear),
528
- Opcn1214InternalError. The Issue type needed by the errors: create src/validate/issue.ts with the
529
- `Issue` and `Severity` types from SPEC §9.1 (types only; the rule-ID union is a plain string for
530
- now and is narrowed in C3).
531
- - src/layout/2025/index.ts — `{ ...LAYOUT_2024, taxYear: 2025 }` (deep-frozen copy).
532
- - src/layout/registry.ts — map year → layout, `supportedTaxYears()`, deep-freeze at module load.
533
- - src/index.ts — export the functions, error classes and the public types (YearLayout, RecordDef,
534
- FieldDef, CodeDef, RecordType, FieldKind, Issue, Severity). Remove SPEC_STATUS and delete
535
- tests/smoke.test.ts.
536
-
537
- Wiring
538
- Public entry point now exposes the layout registry.
539
-
540
- Out of scope
541
- Validation, codecs.
542
-
543
- Verify
544
- Run the verify bundle; `build` must emit dist/typings/index.d.ts containing getLayout.
545
-
546
- Commit: "feat(opcn1214-generator): public layout registry for 2024 and 2025"
547
-
548
- Done when
549
- - Registry, error and export tests pass; no placeholder code remains.
550
- ```
551
-
552
- ---
553
-
554
- ### Part B — Codecs: any record to and from text
555
-
556
- #### B1 — Codec contract and numeric codecs
557
-
558
- ```text
559
- STEP B1 — Codec contract and numeric codecs
560
- Apply the standing instructions (IMPLEMENTATION_PLAN.md, Part 3).
561
-
562
- Context
563
- IMPLEMENTATION_PLAN.md §1.2 fixes the Codec contract and the value conventions per kind. SPEC §4.1,
564
- §4.2, §4.4 define encoding. This step covers the numeric family.
565
-
566
- Read first
567
- - IMPLEMENTATION_PLAN.md §1.2; SPEC §4.1, §4.2 (kinds table), §4.4, §15 A-1, A-21.
568
-
569
- Goal
570
- src/codec/ with the contract, padding helpers and codecs for: num, digits, id9, shareholderId, year,
571
- count, serial, const, foreignCode, amount, amountX, amountX100, rateX100, filler.
572
-
573
- Tests first (tests/codec/numeric.test.ts, table-driven)
574
- 1. padNumeric / padAlphanumeric — right-aligned; numeric pads '0' on the left; alphanumeric pads
575
- spaces on the side given by ALPHANUMERIC_PAD_SIDE ('left'); value longer than width throws
576
- Opcn1214InternalError.
577
- 2. For each kind: encode examples (e.g. amount 1234 width 12 → '000000001234'; id9 '12345' →
578
- '000012345'; amountX100 1234.56 → '000000123456'; amountX100 0.1 + 0.2 → '000000000030';
579
- rateX100 23 → '2300'; amountX 0 in an alphanumeric field of 12 → ' 0'; filler numeric →
580
- zeros, alphanumeric → spaces; undefined → zeros (numeric) or spaces (alphanumeric)).
581
- 3. Encoders throw Opcn1214InternalError for: negative, non-integer amount, NaN, more than 2 decimals
582
- for ×100 kinds, value wider than the field, non-digit id9.
583
- 4. Round trip: decode(encode(v)) equals v for representative values of each kind; all-zero numeric
584
- text decodes to 0 (deciding "absent" is the record codec's job, B4); id9/shareholderId/digits
585
- decode to the full-width digit string ('12' encoded in 3 → '012' → '012'); decode of non-digits
586
- throws CodecDecodeError with reason 'numeric' and the offset of the first bad character.
587
-
588
- Implementation
589
- - src/codec/types.ts — Primitive, FieldShape, Codec, CodecDecodeError (reason + offset, exactly as
590
- in IMPLEMENTATION_PLAN.md §1.2; internal, not exported from index).
591
- - src/codec/padding.ts — padNumeric, padAlphanumeric, ALPHANUMERIC_PAD_SIDE (SPEC §15 A-1).
592
- - src/codec/numeric.ts — the codecs above. ×100 scaling uses Math.round(v * 100) after checking
593
- Math.abs(v * 100 - Math.round(v * 100)) <= 1e-6 (SPEC §4.4).
594
- - src/codec/registry.ts — `CODECS: Partial<Record<FieldKind | CodeKind, Codec>>` and
595
- `codecFor(kind)` (throws Opcn1214InternalError for a missing kind).
596
-
597
- Wiring
598
- The registry is the single entry point B2–B4 use.
599
-
600
- Out of scope
601
- Text, date, boolean, enum, percent, phone codecs (B2); sections (B3).
602
-
603
- Verify
604
- Run the verify bundle.
605
-
606
- Commit: "feat(opcn1214-generator): codec contract and numeric codecs"
607
-
608
- Done when
609
- - Every numeric kind has a codec with encode/decode tests and round trips.
610
- ```
611
-
612
- #### B2 — Text normalization, windows-1255 and the remaining codecs
613
-
614
- ```text
615
- STEP B2 — Text normalization, windows-1255 and the remaining codecs
616
- Apply the standing instructions (IMPLEMENTATION_PLAN.md, Part 3).
617
-
618
- Context
619
- B1 created the codec registry as a Partial record. This step completes it, so CODECS becomes a total
620
- Record<FieldKind | CodeKind, Codec> (compile-time exhaustiveness).
621
-
622
- Read first
623
- - SPEC §4.2 (text, hebrewText, date, flag, yesNo, enum, phonePrefix, percentX100, percentLiteral),
624
- §4.3, §8.5, §15 A-2, A-3, A-19, A-20.
625
-
626
- Goal
627
- normalizeText, windows-1255 helpers and codecs for all remaining kinds.
628
-
629
- Tests first
630
- 1. tests/normalize/text.test.ts — each §4.3 rule: NFC, bidi controls removed, NBSP/tab → space,
631
- typographic quotes and dashes replaced, trim and collapse; Hebrew stays in logical order;
632
- geresh/gershayim and niqqud kept; control characters are NOT removed (validation reports them);
633
- isAllowedTextChar(ch) is false for U+0000–U+001F, U+007F and anything not in windows-1255.
634
- 2. tests/codec/windows1255.test.ts — encodeWindows1255('שלום abc\r\n') round-trips through
635
- decodeWindows1255; byte length equals string length; isWindows1255Representable is true for
636
- Hebrew, ASCII and CR/LF and false for emoji and CJK (iconv would emit '?' for them);
637
- encodeWindows1255 throws Opcn1214InternalError if any character is not in the code page (never
638
- emits '?'). The "no control characters in text" check is NOT here (D-14): it is
639
- isAllowedTextChar in src/normalize/text.ts, used by field.charset in C3.
640
- 3. tests/codec/text.test.ts — text/hebrewText alnum padding and round trip; value wider than field
641
- throws; date '2024-12-31' ↔ '31/12/2024', all spaces ↔ undefined, invalid raw date →
642
- CodecDecodeError('date'); flag true → '1', undefined → '0', '1' → true, '0' → undefined; yesNo
643
- true → '1', false → '2', undefined → '0'; enum 12 width 3 → '012' (value must be in shape.values,
644
- else InternalError); phonePrefix '02' in alphanumeric width 3 → ' 02' and in numeric width 3 →
645
- '002' (A-19), and both decode back to '02' (strip padding, keep the prefix's own leading zero:
646
- decode by stripping padding and leading zeros, then picking the allowed prefix with the same
647
- significant digits: '002' → '02', ' 02' → '02', '052' → '052'); percentX100 10.23 → ' 1023' (alnum, width 5); percentLiteral 100 → '00100',
648
- 10.23 → '10.23', 5.5 → '05.50', and decode back to numbers.
649
- 4. tests/codec/registry.test.ts — every FieldKind and CodeKind resolves through codecFor.
650
-
651
- Implementation
652
- - src/normalize/text.ts — normalizeText(value: string): string; isAllowedTextChar(ch: string).
653
- - src/codec/windows1255.ts — iconv-lite wrappers (encode, decode, isWindows1255Representable).
654
- - src/codec/text.ts, src/codec/date.ts, src/codec/boolean.ts, src/codec/enum.ts,
655
- src/codec/percent.ts, src/codec/phone.ts.
656
- - src/codec/registry.ts — make CODECS a total Record (remove Partial).
657
-
658
- Wiring
659
- All codecs registered; normalizeText is consumed by the normalizer in C1.
660
-
661
- Out of scope
662
- Sections, records.
663
-
664
- Verify
665
- Run the verify bundle.
666
-
667
- Commit: "feat(opcn1214-generator): text normalization, windows-1255 and remaining codecs"
668
-
669
- Done when
670
- - CODECS is total and type-checked; all codec tests pass.
671
- ```
672
-
673
- #### B3 — Code-amount and country-amount section codecs
674
-
675
- ```text
676
- STEP B3 — Code-amount and country-amount section codecs
677
- Apply the standing instructions (IMPLEMENTATION_PLAN.md, Part 3).
678
-
679
- Context
680
- Records 1000, 2000 and all 30xx end with a code-amount section; 2200 ends with a country-amount
681
- section (SPEC §3.5, §3.6). Values of each code are encoded with the codec of the code's kind.
682
-
683
- Read first
684
- - SPEC §3.5, §3.6, §4.5, §15 A-10, A-22.
685
-
686
- Goal
687
- encode/decode for both section kinds, driven by CodeDef lists from the layout.
688
-
689
- Tests first (tests/codec/sections.test.ts)
690
- 1. encodeCodeSection(new Map([['015', 3], ['010', 5000]]), codes1000, 2048) writes '010' + 12-digit
691
- 5000 then '015' + '03' (ascending order regardless of Map order), then zeros to 2048.
692
- 2. Capital-gains codes are written with 3 digits ('015' for code 15); amountX100 and rateX100 codes
693
- are scaled; enum codes validated against values (InternalError otherwise).
694
- 3. Section overflow (sum of entries > length) throws Opcn1214InternalError.
695
- 4. decodeCodeSection is the exact inverse; stops at the first position where the remainder is all
696
- zeros; throws CodecDecodeError('section') with the offset for: unknown code, truncated entry,
697
- duplicate code, non-zero data after an all-zero gap.
698
- 5. Edge: an entry for a zeroAllowed code with value 0 as the LAST entry survives the round trip.
699
- (The stop rule "remainder is all zeros" is exact because no code is '000': every entry starts
700
- with a non-zero digit somewhere in its 3-digit code. Assert this invariant over all layout
701
- codes in the test.)
702
- 6. Country section: entries (affiliation 1, country 3, income 12) × up to 10, zero-filled to 1024;
703
- '-88' encoded literally; country '40' written '040'; round trip; malformed entry →
704
- CodecDecodeError('section').
705
-
706
- Implementation
707
- - src/codec/sections.ts — encodeCodeSection, decodeCodeSection, encodeCountrySection,
708
- decodeCountrySection.
709
-
710
- Wiring
711
- Used by the record codec in B4.
712
-
713
- Out of scope
714
- Validation of which codes are allowed (rules, later); zero omission (normalizer, C1).
715
-
716
- Verify
717
- Run the verify bundle.
718
-
719
- Commit: "feat(opcn1214-generator): code-amount and country-amount section codecs"
720
-
721
- Done when
722
- - Both section codecs round-trip and reject malformed input with offsets.
723
- ```
724
-
725
- #### B4 — Record codec and the all-records round trip
726
-
727
- ```text
728
- STEP B4 — Record codec and the all-records round trip
729
- Apply the standing instructions (IMPLEMENTATION_PLAN.md, Part 3).
730
-
731
- Context
732
- With field and section codecs in place, a generic record codec can encode any record of any layout.
733
- The NormalizedRecord type (IMPLEMENTATION_PLAN.md §1.2) is introduced here.
734
-
735
- Read first
736
- - IMPLEMENTATION_PLAN.md §1.2; SPEC §3.2 (prefix), §3.4.
737
-
738
- Goal
739
- encodeRecord/decodeRecord for every record type, proven on all 17 record types of 2024 with
740
- generated sample values.
741
-
742
- Tests first
743
- 1. tests/helpers/sample-values.ts (test helper) — sampleRecord(def): NormalizedRecord with a valid,
744
- width-fitting, NON-ZERO value for every non-filler field (by kind) and, for code-amount records,
745
- up to three codes covering every code kind the record has (several records have only `amount`
746
- codes); for 2200 two countries.
747
- 2. tests/codec/record.test.ts — for every RecordDef of getLayout(2024):
748
- - encodeRecord(def, sampleRecord(def)) has length def.length, starts with '1214' + type +
749
- '0' × 128;
750
- - every field slice at its position equals codecFor(kind).encode(value) for that field;
751
- - decodeRecord(def, line, 0) deep-equals the sample (values, codes, countries).
752
- 3. encodeRecord throws Opcn1214InternalError when the produced length differs (simulate with a
753
- corrupted RecordDef in the test).
754
- 4. decodeRecord throws CodecDecodeError (reason 'length' or 'format', offset = column - 1) for a
755
- wrong length or a prefix mismatch.
756
- 5. Absent values: for header fields with required !== 'yes', decodeRecord maps a decoded 0 to
757
- undefined (exception: amountX, where 0 is meaningful) and an all-zero digit string (id9,
758
- shareholderId, digits) to undefined; required fields keep 0 (e.g. 9999 counts). Test with a
759
- sample record whose optional numeric fields are undefined: encode → decode gives undefined.
760
-
761
- Implementation
762
- - src/model/normalized.ts — NormalizedRecord, NormalizedReport (as in §1.2; NormalizedReport.notices
763
- uses the Issue type from src/validate/issue.ts).
764
- - src/codec/record.ts — encodeRecord, decodeRecord (fillers: write zeros/spaces, ignore on decode
765
- (SPEC §8.2 step 4); derived fields are encoded/decoded like any other field; the absent-value
766
- mapping of test 5).
767
-
768
- Wiring
769
- The record codec is the only way later code turns records into lines and back.
770
-
771
- Out of scope
772
- Normalization, file assembly.
773
-
774
- Verify
775
- Run the verify bundle.
776
-
777
- Commit: "feat(opcn1214-generator): generic record codec for every record type"
778
-
779
- Done when
780
- - The all-records round trip passes for all 17 record types.
781
- ```
782
-
783
- ---
784
-
785
- ### Part C — Walking skeleton: a minimal real report, end to end
786
-
787
- #### C1 — Skeleton input model and normalizer (1000 core + 1020)
788
-
789
- ```text
790
- STEP C1 — Skeleton input model and normalizer (1000 core + 1020)
791
- Apply the standing instructions (IMPLEMENTATION_PLAN.md, Part 3).
792
-
793
- Context
794
- The smallest fileable report has: record 1000 with company identity, the seven required
795
- declarations and main-form amounts; at least one 1020 shareholder; and 9999. This step introduces
796
- the public input types for exactly that subset and the normalizer that turns them into a
797
- NormalizedReport. Later steps extend the same interfaces (never a parallel type).
798
-
799
- Read first
800
- - SPEC §7.1, §7.2 (Report1214Input, CompanyDetails, Phone, Declarations — required members only,
801
- Shareholder), §7.3, §7.4 (rows for prefix, 150, 165, 832, 833, codes 008 and 273, 1020 serial),
802
- §4.3, §4.5; IMPLEMENTATION_PLAN.md §1.2 value conventions; fields.csv rows for 1000 and 1020.
803
-
804
- Goal
805
- normalizeReport(input, layout, options) → NormalizedReport for the skeleton subset.
806
-
807
- Tests first
808
- 1. tests/fixtures/builders.ts — `minimalInput(overrides?)`: a valid skeleton report (taxYear 2024,
809
- company with file number, registered name, two addresses, phone; the seven required declarations
810
- all `false`; amounts for the required codes with values valid for their allowed sets: 018 = 4,
811
- 072 = 0, 081 = 1000, 094 = 0, 263 = 1; one shareholder with a Hebrew name and dividend rights
812
- 100). Deep-merge overrides. Keep it valid against EVERY rule of SPEC §10 (later steps rely on it).
813
- 2. tests/normalize/main.test.ts —
814
- - every 1000 key produced from the skeleton input has the expected value and path
815
- (e.g. paths['company.phone.number'] === 'company.phone.number');
816
- - meta defaults: softwareName 'ACCOUNTER'; saveDate from options.today; default today is
817
- todayInJerusalem(now = new Date()) — test it with fixed Date values around midnight UTC;
818
- - text fields pass through normalizeText;
819
- - derived: 832 false, 833 false (no appendices exist yet), code 273 for all four combinations of
820
- 1029/1030, code 008 = 1 only when appliesAccountingStandards;
821
- - amounts: zero for a non-zeroAllowed code is omitted and listed in omittedZeroCodes; zero for a
822
- zeroAllowed code (072) is kept; codes' paths are `amounts["072"]`.
823
- 3. tests/normalize/shareholders.test.ts — one record per shareholder in input order, index and
824
- serialNumber (1-based), boolean/number mapping, paths `shareholders[i].<key>`.
825
- 4. A digit string that is not all digits (e.g. company.fileNumber '12a') is kept as-is in values
826
- (rules will reject it in C3). Phone numbers stay digit strings (kind `digits`).
827
-
828
- Implementation
829
- - src/model/input.ts — skeleton subset of SPEC §7.2. Mark with a TODO-free comment which SPEC
830
- section each interface implements; optional members not yet supported are simply absent.
831
- - src/model/index.ts — re-exports.
832
- - src/model/options.ts — ValidateOptions { rounding?: 'reject' | 'halfUp'; today?: () => IsoDate }
833
- and GenerateOptions = ValidateOptions (SPEC §6.2).
834
- - src/normalize/today.ts — todayInJerusalem(now = new Date()): IsoDate (Intl.DateTimeFormat with
835
- timeZone 'Asia/Jerusalem').
836
- - src/normalize/paths.ts — pathFor(recordType, inputIndex, key): the input path of a key (SPEC §7.3
837
- and §9.1 path grammar); every normalizer uses it, and the parser reuses it in C7b.
838
- - src/normalize/main.ts, src/normalize/shareholders.ts, src/normalize/report.ts (orchestrates,
839
- orders records per SPEC §3.3, fills omittedZeroCodes and notices: []).
840
- - src/normalize/derive.ts — code 273 and 008 derivations as small pure functions.
841
-
842
- Wiring
843
- normalizeReport uses getLayout, normalizeText and the layout's FieldDef keys; C2 consumes it.
844
-
845
- Out of scope
846
- Validation, encoding, optional declarations, preparer (D1+), other record types.
847
-
848
- Verify
849
- Run the verify bundle.
850
-
851
- Commit: "feat(opcn1214-generator): skeleton input model and normalizer"
852
-
853
- Done when
854
- - The minimal input normalizes into one 1000 and one 1020 record with every key, path and derived
855
- value asserted.
856
- ```
857
-
858
- #### C2 — File assembly and the 9999 control record
859
-
860
- ```text
861
- STEP C2 — File assembly and the 9999 control record
862
- Apply the standing instructions (IMPLEMENTATION_PLAN.md, Part 3).
863
-
864
- Context
865
- NormalizedReport (C1) + record codec (B4) are enough to produce the file text and bytes, once the
866
- 9999 record is derived and lines are joined.
867
-
868
- Read first
869
- - SPEC §3.1, §3.3, §3.8, §8.1 steps 6–7, §8.3.
870
-
871
- Goal
872
- renderReport(report) → { lines, text, bytes } with 9999 derived from the records.
873
-
874
- Tests first (tests/file/assemble.test.ts)
875
- 1. buildControlRecord(report) counts: reportCount 1; 1010, 1020, 2000 (0/1), capital-gains, 2200
876
- and 1030 counts from report.records (construct NormalizedReports by hand for counts > 0).
877
- 2. renderReport(normalizeReport(minimalInput())) — exactly 3 lines; lengths 4232, 1160, 150; text
878
- ends with '\r\n' and lines are joined with '\r\n'; bytes.length === text.length; selected slices:
879
- 1000@137 (file number), 1000@146 '2024', 1000@165 'DD/MM/YYYY' of the injected today, 1000@832
880
- '2', 1000 code section starts at 2185 with '018'; 1020@137 '01'; 9999@141 '01'.
881
- 3. Records are emitted in report.records order (assembly does not reorder; ordering is the
882
- normalizer's job) and 9999 is always last.
883
- 4. Determinism: two calls with the same input produce identical bytes.
884
-
885
- Implementation
886
- - src/file/control.ts — buildControlRecord(report): NormalizedRecord for 9999.
887
- - src/file/assemble.ts — renderReport(report): encodes each record with encodeRecord, appends 9999,
888
- joins with CRLF plus a final CRLF, encodes with encodeWindows1255. Asserts line lengths.
889
-
890
- Wiring
891
- renderReport(normalizeReport(...)) is the internal generation path; C6 puts validation in front of
892
- it.
893
-
894
- Out of scope
895
- Validation; public API.
896
-
897
- Verify
898
- Run the verify bundle.
899
-
900
- Commit: "feat(opcn1214-generator): file assembly and control record"
901
-
902
- Done when
903
- - The minimal input renders to a three-line windows-1255 file with all asserted slices.
904
- ```
905
-
906
- #### C3 — Validation framework and first field rules
907
-
908
- ```text
909
- STEP C3 — Validation framework and first field rules
910
- Apply the standing instructions (IMPLEMENTATION_PLAN.md, Part 3).
911
-
912
- Context
913
- Rules are data (RULES metadata, SPEC §9.1) plus implementations run by an engine over the
914
- NormalizedReport (SPEC §9.2 stages 3–5). Generic field rules are driven by FieldDef/CodeDef
915
- (SPEC §9.3). Every rule needs a pass and a fail case (SPEC §13.4).
916
-
917
- Read first
918
- - SPEC §9 (all), §10.2 (first four rules), §13.4; IMPLEMENTATION_PLAN.md §1.2 (runPipeline).
919
-
920
- Goal
921
- Issue sorting, the RULES catalogue with a narrowed RuleId union, the engine, the internal
922
- runPipeline with its year stage, and the rules struct.taxYear.unsupported, field.required,
923
- field.numeric, field.length, field.charset.
924
-
925
- Tests first
926
- 1. tests/validate/issue.test.ts — compareIssues orders by reportIndex, record order (SPEC §3.3),
927
- recordIndex, field position or code, ruleId.
928
- 2. tests/rules/cases.ts — `export const RULE_CASES: { [K in RuleId]: RuleCase }` where
929
- RuleCase = { kind: 'input'; fail(): unknown; pass(): unknown; path?: string } (a 'file' kind is
930
- added in C7). Fail cases are built from minimalInput() with one deliberate defect.
931
- 3. tests/rules/rules.test.ts — for every RULES entry: runPipeline(fail()) contains exactly one issue
932
- with that ruleId (at `path` when given, with the catalogued severity); runPipeline(pass()) has
933
- no issue with that ruleId. Also: pass() of every case has zero errors overall.
934
- 4. tests/rules/spec-sync.test.ts — every RULES id appears in SPEC.md §10 (read the file via
935
- import.meta.url; take the FIRST cell of each table row in §10.1–§10.7 and strip the backticks).
936
- (Equality is enforced in H4.)
937
- 5. Field rules details: required header field missing; required code missing (018); a required
938
- code that is not zeroAllowed given 0 counts as missing; '12a' in company.fileNumber →
939
- field.numeric; registered name of 51 characters → field.length; emoji / CR in a text field →
940
- field.charset (via isAllowedTextChar); issue carries `field` {position, length, nameHe} or
941
- `code`, and `specRef.page`.
942
- 6. Slot-aware required (SPEC §9.3, D-12): on a synthetic 3077 NormalizedRecord, an empty
943
- improvements[1] slot raises nothing; improvements[1].expense set without improvements[1].date
944
- raises field.required at that date key.
945
- 7. struct.taxYear.unsupported: runPipeline({ ...minimalInput(), taxYear: 2023 }) returns exactly
946
- that issue (path 'taxYear') and does not throw; nothing else runs after it.
947
-
948
- Implementation
949
- - src/validate/issue.ts — finish Issue (ruleId: RuleId), compareIssues, makeIssue helper.
950
- - src/validate/rules.ts — avoid a circular type: define RuleMetaInput (RuleMeta fields with
951
- `id: string`); `export const RULES = [...] as const satisfies readonly RuleMetaInput[]`;
952
- `export type RuleId = (typeof RULES)[number]['id']`;
953
- `export type RuleMeta = Omit<RuleMetaInput, 'id'> & { id: RuleId }`. Add the five rules
954
- (source/severity/scope/description/specRef from SPEC §10).
955
- - src/validate/field-rules.ts — one generic pass over every record's header fields and codes.
956
- - src/validate/engine.ts — runRules(report): Issue[] = report.notices + field stage + business
957
- stage + structure stage (the latter two are empty registries for now), sorted.
958
- - src/pipeline.ts — runPipeline(input: unknown, options): stage 1 checks input.taxYear against
959
- supportedTaxYears() (struct.taxYear.unsupported, stop); then getLayout → normalizeReport →
960
- runRules. Until C5 the rest of the input is assumed well-typed (cast after the year check).
961
- - A4's registry already builds an issue with ruleId 'struct.taxYear.unsupported'; it now type-checks
962
- against the narrowed RuleId.
963
-
964
- Wiring
965
- runPipeline is the single validation entry point (C6's validate1214 and generate1214 call it).
966
-
967
- Out of scope
968
- Other field rules (C4); zod (C5).
969
-
970
- Verify
971
- Run the verify bundle.
972
-
973
- Commit: "feat(opcn1214-generator): validation engine and first field rules"
974
-
975
- Done when
976
- - The five rules pass the case harness; adding a RULES entry without a case fails typecheck.
977
- ```
978
-
979
- #### C4 — Remaining generic field rules
980
-
981
- ```text
982
- STEP C4 — Remaining generic field rules
983
- Apply the standing instructions (IMPLEMENTATION_PLAN.md, Part 3).
984
-
985
- Context
986
- C3 built the engine and four field rules. SPEC §10.2 lists the rest. Two rules interact with the
987
- normalizer: an invalid phone prefix is dropped with a warning (it then triggers field.required for
988
- the required 1000@493), and the `rounding` option changes amount handling (SPEC §4.4).
989
-
990
- Read first
991
- - SPEC §4.4, §10.2; IMPLEMENTATION_PLAN.md §1.3 D-5.
992
-
993
- Goal
994
- field.integer, field.decimals, field.negative, field.enum, field.date, field.percentRange,
995
- field.hebrewFirstLetter, field.phonePrefix (W), field.phoneNumber — each with
996
- RULES entry, implementation and cases.
997
-
998
- Tests first
999
- 1. Add a RULE_CASES entry for each rule (typecheck forces it), using a defect the skeleton input
1000
- can express: 1.5 in an amount code (field.integer); -1 in an amount (field.negative); code 014 = 3
1001
- (field.enum — applies to kinds `enum` and `rateX100` only, SPEC §10.2); meta.saveDate
1002
- '2024-02-30' (field.date); shareholders[0].dividendRightsPercent
1003
- 100.01 (field.percentRange) and 10.123 (field.decimals); shareholder fullName '1abc'
1004
- (field.hebrewFirstLetter); phone prefix '01' (field.phonePrefix — build it with a cast; the
1005
- C5 schema accepts any string there so the rule stays reachable); phone number '123'
1006
- (field.phoneNumber, checked on the digit string: exactly 7 digits). Kinds the skeleton cannot express yet (amountX100, percentX100) get
1007
- unit tests on synthetic NormalizedReports in tests/validate/field-rules.test.ts.
1008
- 2. Rounding option: { rounding: 'halfUp' } turns 1.5 into 2 with no issue; default rejects.
1009
- 3. Phone prefix: invalid prefix for company.phone produces field.phonePrefix (warning, path
1010
- company.phone.prefix) AND field.required for 1000@493; for company.fax only the warning.
1011
-
1012
- Implementation
1013
- - Extend src/validate/field-rules.ts by kind; the hebrewFirstLetter check uses U+05D0–U+05EA.
1014
- - src/normalize/main.ts — drop invalid prefixes and push the warning into report.notices; apply
1015
- rounding when options.rounding === 'halfUp' (half away from zero).
1016
- - RULES entries.
1017
-
1018
- Wiring
1019
- All via runPipeline/runRules.
1020
-
1021
- Out of scope
1022
- zod (C5); business rules.
1023
-
1024
- Verify
1025
- Run the verify bundle.
1026
-
1027
- Commit: "feat(opcn1214-generator): remaining generic field rules"
1028
-
1029
- Done when
1030
- - Every rule of SPEC §10.2 is implemented and covered by RULE_CASES.
1031
- ```
1032
-
1033
- #### C5 — Shape stage (zod)
1034
-
1035
- ```text
1036
- STEP C5 — Shape stage (zod)
1037
- Apply the standing instructions (IMPLEMENTATION_PLAN.md, Part 3).
1038
-
1039
- Context
1040
- Public callers may pass anything (validate1214 takes `unknown`). Stages 1–2 of SPEC §9.2 check the
1041
- tax year and the JavaScript shape with strict zod schemas before normalization; failures stop the
1042
- pipeline.
1043
-
1044
- Read first
1045
- - SPEC §7.1 (strict objects, null rejected), §9.1 path grammar, §9.2 (incl. the zod notes), §10.1
1046
- input.shape.
1047
-
1048
- Goal
1049
- runPipeline(input: unknown) validates the shape after the year stage, then continues as before.
1050
-
1051
- Tests first
1052
- 1. tests/model/schema.test.ts —
1053
- - minimalInput() passes;
1054
- - unknown property at any depth → input.shape at that path (e.g. company.faxx). zod 4 reports
1055
- these as one `unrecognized_keys` issue at the parent with a `keys` array: emit one issue per
1056
- key with the key appended to the path;
1057
- - null for an optional property → input.shape;
1058
- - wrong type ('2024' for taxYear) → input.shape at 'taxYear';
1059
- - amounts with key '999' → input.shape at amounts["999"] (D3 refines this to input.unknownCode);
1060
- - amounts { '010': undefined } is accepted (optional values), and so is an object with
1061
- undefined optional members;
1062
- - company.phone.prefix '01' passes the shape stage (any string; field.phonePrefix reports it);
1063
- - path conversion: zod path ['shareholders', 2, 'fullName'] → 'shareholders[2].fullName' and
1064
- ['amounts', '018'] → 'amounts["018"]'.
1065
- 2. A compile-time test: Report1214Input is assignable to `z.input<typeof report1214InputSchema>`
1066
- (one direction only — the schema is deliberately looser for phone prefixes and country codes).
1067
- 3. RULE_CASES for input.shape.
1068
-
1069
- Implementation
1070
- - src/model/schema.ts — zod 4 strict schemas mirroring src/model/input.ts (z.strictObject;
1071
- z.partialRecord(z.enum(MAIN_FORM_INPUT_CODES), z.number().optional()) for amounts; IsoDate as a
1072
- regex-checked string; digit strings, phone prefixes and (later) country codes as plain
1073
- z.string() — semantic checks stay in rules). Export schemaFor(taxYear) even though both years
1074
- share one schema today.
1075
- - src/validate/shape.ts — zodIssuesToIssues(error): Issue[] with the path grammar.
1076
- - src/pipeline.ts — stage 2 (shape) after the year stage and before normalization; stop on its
1077
- issues.
1078
-
1079
- Wiring
1080
- runPipeline is now safe for untrusted input.
1081
-
1082
- Out of scope
1083
- Public API (C6).
1084
-
1085
- Verify
1086
- Run the verify bundle.
1087
-
1088
- Commit: "feat(opcn1214-generator): strict input shape validation"
1089
-
1090
- Done when
1091
- - Arbitrary input never makes runPipeline throw; shape problems are reported with exact paths.
1092
- ```
1093
-
1094
- #### C6 — Public API v1: validate1214 and generate1214
1095
-
1096
- ```text
1097
- STEP C6 — Public API v1: validate1214 and generate1214
1098
- Apply the standing instructions (IMPLEMENTATION_PLAN.md, Part 3).
1099
-
1100
- Context
1101
- runPipeline (validation) and renderReport (generation) exist. This step exposes them as the public
1102
- API of SPEC §6 and starts the golden-file suite.
1103
-
1104
- Read first
1105
- - SPEC §6.1, §6.2, §6.4, §6.5, §11, §13.5, §13.8.
1106
-
1107
- Goal
1108
- validate1214, generate1214, RULES and Opcn1214ValidationError are public; the `minimal` golden file
1109
- exists and is pending human verification.
1110
-
1111
- Tests first
1112
- 1. tests/api/validate.test.ts — valid input → { valid: true, errors: [], warnings: [] }; invalid →
1113
- valid false with sorted errors; never throws for any JSON value (null, [], 'x', 42, {}).
1114
- 2. tests/api/generate.test.ts — returns text, bytes, fileName '1214_<fileNumber>_2024.txt',
1115
- warnings, summary { reports: 1, records: {'1000':1,'1020':1,'9999':1}, mainCodePairs,
1116
- omittedZeroCodes }; throws Opcn1214ValidationError carrying all errors and warnings for invalid
1117
- input; options.today is honoured.
1118
- 3. tests/golden/golden.test.ts — for each tests/fixtures/golden/<name>.input.ts (exports a typed
1119
- input and options with a fixed today), generate1214 bytes equal the committed <name>.opcn bytes.
1120
- With UPDATE_GOLDEN=1 the test writes the files instead (document this in tests/fixtures/golden/
1121
- README.md: only for steps that intentionally add or change golden files). The test also asserts
1122
- that each golden's sha256 equals the value in VERIFICATION.md, so changing a golden always
1123
- requires editing that table (and resetting a VERIFIED row to PENDING).
1124
- 4. exports.test.ts updated with the new public names.
1125
-
1126
- Implementation
1127
- - src/errors.ts — Opcn1214ValidationError.
1128
- - src/api/validate.ts, src/api/generate.ts (calls runPipeline; throws on errors; then
1129
- renderReport; builds summary and fileName).
1130
- - src/index.ts — export validate1214, generate1214, RULES, Report1214Input and its sub-types,
1131
- IsoDate, PhonePrefix, the code unions of src/model/codes.generated.ts (MainFormCode,
1132
- MainFormInputCode, ForeignAppendixCode, CountryBreakdownCode, CapitalGainsSymbol,
1133
- CapitalGainsCode, CountryCode), ValidateOptions, GenerateOptions, ValidationResult,
1134
- GenerateResult, RuleMeta, RuleId.
1135
- - packages/opcn1214-generator/.gitattributes — `*.opcn binary`.
1136
- - tests/fixtures/golden/minimal.input.ts + minimal.opcn (generated with UPDATE_GOLDEN=1) and
1137
- VERIFICATION.md (table: fixture | sha256 | generated on | shopcn result | notes) with `minimal`
1138
- marked PENDING.
1139
-
1140
- Wiring
1141
- Public API complete for the skeleton subset.
1142
-
1143
- Out of scope
1144
- Parsing (C7).
1145
-
1146
- Verify
1147
- Run the verify bundle. Inspect minimal.opcn with `xxd | head` and confirm CRLF line ends and the
1148
- record lengths.
1149
-
1150
- Commit: "feat(opcn1214-generator): public validate and generate API"
1151
-
1152
- Done when
1153
- - A consumer can validate and generate a minimal 1214 file through the package's public API.
1154
- - VERIFICATION.md lists `minimal` as PENDING for checkpoint CP-1.
1155
- ```
1156
-
1157
- > **Human checkpoint CP-1 (after C6).** Upload `tests/fixtures/golden/minimal.opcn` unchanged to
1158
- > <https://secapp.taxes.gov.il/shopcn>. Record the result in `VERIFICATION.md`. If it is rejected,
1159
- > stop the plan and run a fix-up step (template at the end of Part 3) before C7a: the most likely
1160
- > causes are SPEC §15 A-1 (alphanumeric padding side), A-5 (line endings) and A-6 (encoding).
1161
-
1162
- **Outcome CP-1 (2026-11-17):** `minimal` passed on shopcn (A-1, A-5, A-6 verified).
1163
-
1164
- #### C7a — Parser v1: happy path and round trip
1165
-
1166
- ```text
1167
- STEP C7a — Parser v1: happy path and round trip
1168
- Apply the standing instructions (IMPLEMENTATION_PLAN.md, Part 3).
1169
-
1170
- Context
1171
- The record codec already decodes any record. This step turns a well-formed file back into the
1172
- public input: byte decoding, line splitting, decoding into a NormalizedReport, denormalizing and
1173
- canonicalizing. Structural error reporting is C7b. From now on, every step that adds input must
1174
- also extend denormalize/canonicalize and keep the round-trip tests green.
1175
-
1176
- Read first
1177
- - SPEC §6.1 (parse1214), §6.2 (ParseOptions, ParseResult), §8.2 steps 1, 2, 4, 5, 7, §8.4.
1178
-
1179
- Goal
1180
- Public parse1214 for the skeleton subset and both round-trip properties.
1181
-
1182
- Tests first
1183
- 1. tests/file/split.test.ts — windows-1255 bytes and strings; UTF-8 BOM stripped; CRLF and LF
1184
- accepted; one trailing empty line ignored.
1185
- 2. tests/normalize/canonical.test.ts — canonicalize(input, options) per SPEC §8.4: text normalized,
1186
- empty optionals removed, digit strings padded to width (company.fileNumber '12345' →
1187
- '000012345'), zero codes removed unless zeroAllowed, meta.saveDate from options.today.
1188
- 3. tests/roundtrip/roundtrip.test.ts — (a) parse1214(generate1214(x).bytes).report deep-equals
1189
- canonicalize(x) for minimalInput variants (with/without optional members, zero codes, digit
1190
- strings needing padding); (b) for every golden file, generate1214 of the parsed report (with the
1191
- parsed saveDate/softwareName in meta) gives the golden bytes.
1192
- 4. ParseResult.issues contains field/business issues of a structurally valid but invalid file
1193
- (e.g. the registered name at 1000@175 replaced by 50 spaces → field.required at
1194
- company.registeredName) and parse1214 does not throw for them.
1195
-
1196
- Implementation
1197
- - src/file/split.ts — decode bytes (options.encoding) + split lines.
1198
- - src/file/parse.ts — decode every line with decodeRecord (record type from positions 5–8), select
1199
- the layout from the 1000 record's tax year, build the NormalizedReport (paths via pathFor, using
1200
- the emission index as the input index).
1201
- - src/normalize/denormalize.ts — NormalizedReport → Report1214Input for the skeleton subset.
1202
- - src/normalize/canonical.ts — canonicalize(input, options).
1203
- - src/api/parse.ts — parse1214: split → parse → denormalize; ParseResult.issues = runRules on the
1204
- decoded report. For now a structural problem may surface as a thrown CodecDecodeError — C7b
1205
- turns those into Opcn1214ParseError.
1206
- - src/index.ts — export parse1214, ParseOptions, ParseResult.
1207
-
1208
- Wiring
1209
- generate1214 and parse1214 share the codecs, model and paths.
1210
-
1211
- Out of scope
1212
- Structural error collection and parse.* rules (C7b).
1213
-
1214
- Verify
1215
- Run the verify bundle.
1216
-
1217
- Commit: "feat(opcn1214-generator): parser and round-trip guarantees"
1218
-
1219
- Done when
1220
- - Both round-trip properties hold for the minimal fixtures and the `minimal` golden.
1221
- ```
1222
-
1223
- #### C7b — Parser v1: structural errors
1224
-
1225
- ```text
1226
- STEP C7b — Parser v1: structural errors
1227
- Apply the standing instructions (IMPLEMENTATION_PLAN.md, Part 3).
1228
-
1229
- Context
1230
- C7a parses well-formed files. Malformed files must produce Opcn1214ParseError with every structural
1231
- problem (not just the first), each with line and column, and the rule harness must accept file
1232
- cases.
1233
-
1234
- Read first
1235
- - SPEC §8.2 (all), §10.7, §13.4 (RuleCase kinds), §11.2.
1236
-
1237
- Goal
1238
- Structural detection and the rules parse.empty, parse.encoding, parse.lineLength, parse.formType,
1239
- parse.recordType, parse.prefixFiller, parse.order, parse.control.missing, parse.control.counts,
1240
- parse.numeric, parse.date, parse.codeSection; the 'file' RuleCase kind.
1241
-
1242
- Tests first
1243
- 1. tests/fixtures/files.ts (helper) — tamper(text, { line, position, value }), dropLine(text, line),
1244
- swapLines(text, a, b).
1245
- 2. Extend RuleCase with { kind: 'file'; fail(): string | Uint8Array; pass(): string | Uint8Array }.
1246
- The runner collects issues as
1247
- `try { return parse1214(content).issues } catch (e) { if (e instanceof Opcn1214ParseError) return e.issues; throw e }`
1248
- so the same kind serves structural rules (thrown) and business rules on parsed files (D4, G5).
1249
- 3. RULE_CASES for every parse.* rule of this step, built with the helpers from the `minimal`
1250
- golden; parse.encoding via options.encoding 'utf-8' and invalid UTF-8 bytes.
1251
- 4. tests/api/parse.test.ts — a file with three independent defects on different lines reports all
1252
- three, sorted by line; every issue has line and column; CodecDecodeError never escapes
1253
- parse1214.
1254
- 5. A tax year in 1000@146 outside supportedTaxYears() → struct.taxYear.unsupported (thrown).
1255
-
1256
- Implementation
1257
- - src/errors.ts — Opcn1214ParseError.
1258
- - src/file/parse.ts — per-line checks (length, form type, record type, prefix zeros), order check
1259
- against SPEC §3.3 for the record types known so far, control-record presence and counts; catch
1260
- CodecDecodeError per line and convert it (reason → rule: numeric → parse.numeric, date →
1261
- parse.date, section → parse.codeSection, length → parse.lineLength, format → parse.formType or
1262
- parse.recordType by offset); continue with the next line.
1263
- - src/validate/rules.ts — RULES entries (scope 'parse').
1264
-
1265
- Wiring
1266
- parse1214 throws Opcn1214ParseError for structural problems and returns business issues otherwise.
1267
-
1268
- Out of scope
1269
- parse.occurrences, parse.multipleReports, parse.derivedMismatch, batches (H1).
1270
-
1271
- Verify
1272
- Run the verify bundle.
1273
-
1274
- Commit: "feat(opcn1214-generator): structural parse errors"
1275
-
1276
- Done when
1277
- - Every listed parse.* rule passes its file case; malformed files never throw anything but
1278
- Opcn1214ParseError.
1279
- ```
1280
-
1281
- ---
1282
-
1283
- ### Part D — Record 1000 complete
1284
-
1285
- Every step in Parts D–G follows the same **vertical-slice recipe**; each prompt names only what is
1286
- specific to it:
1287
-
1288
- 1. Extend the public types in `src/model/input.ts` (SPEC §7.2) and the zod schema
1289
- (`src/model/schema.ts`); keep the type-equality test green.
1290
- 2. Extend the normalizer (keys and paths per SPEC §7.3, derivations per SPEC §7.4).
1291
- 3. Extend `denormalize` and `canonicalize`.
1292
- 4. Extend `tests/fixtures/builders.ts`.
1293
- 5. Add rules (RULES + implementation + RULE_CASES) if the step lists any.
1294
- 6. Extend the round-trip suite with fixtures exercising every new member.
1295
-
1296
- #### D1 — Declarations and preparer
1297
-
1298
- ```text
1299
- STEP D1 — Declarations and preparer
1300
- Apply the standing instructions and the Part D vertical-slice recipe (IMPLEMENTATION_PLAN.md).
1301
-
1302
- Context
1303
- Record 1000 still lacks the optional declarations and the preparer block. They are pure field
1304
- mappings (flags, yes/no, enums, dates); their cross-field rules arrive in D4/D5.
1305
-
1306
- Read first
1307
- - SPEC §7.2 PreparerDetails and Declarations (all optional members), §7.3 mapping table rows for
1308
- 836, 851, 863, 1034–1046 and 833, §7.4 (833); fields.csv 1000 rows 563–886 and 1029–1064.
1309
-
1310
- Goal
1311
- Every optional declaration and the preparer encode, decode and round-trip.
1312
-
1313
- Tests first
1314
- 1. tests/normalize/main.test.ts — for each new member: key, encoded value, path. Specifically:
1315
- form6111Obligation obliged/notObliged/notRelevant → 834 = 1/2/3; consolidatedReport three values
1316
- → 875 = 1/2/3; familyCompany object → 836 = 1 and 837 = representativeFileNumber;
1317
- beneficiaryEnterprise → 851 = 1, 852 = notice date; specialYear → 863 = 1, 864 = balance sheet
1318
- date; reportablePositions [12, 7] → 1034 = '012', 1037 = '007', 1040–1046 = '000';
1319
- requestsAdvancePayments/hasBuildingIncome/partOfMultinationalGroup are yes/no (1/2/0 when absent);
1320
- hasCapitalGainsAppendix true forces 833 = yes; preparer phone with valid prefix.
1321
- 2. Schema tests for the new members (strictness; reportablePositions is an array of integers with
1322
- no length limit in the schema — D4 reports more than 5 as a normalizer notice; the normalizer
1323
- writes the first five).
1324
- 3. Round trip: an input with every new member set (builder `fullDeclarationsInput()`).
1325
-
1326
- Implementation
1327
- Per the recipe. The enum literal ↔ code maps live next to the normalizer
1328
- (src/normalize/enums.ts) and are reused by denormalize.
1329
-
1330
- Wiring
1331
- All new keys flow through normalizeReport → renderReport and parse → denormalize.
1332
-
1333
- Out of scope
1334
- Rules about these fields (D4, D5); 297 and bank codes (D3).
1335
-
1336
- Verify
1337
- Run the verify bundle.
1338
-
1339
- Commit: "feat(opcn1214-generator): declarations and preparer in record 1000"
1340
-
1341
- Done when
1342
- - Every 1000 header key between positions 563 and 1064 is produced by the normalizer (assert with a
1343
- coverage helper that lists unmapped non-filler keys of record 1000 — only D2's groups remain).
1344
- ```
1345
-
1346
- #### D2 — Other income, attachments, capital-gains summary, qualifying company
1347
-
1348
- ```text
1349
- STEP D2 — Other income, attachments, capital-gains summary, qualifying company
1350
- Apply the standing instructions and the Part D vertical-slice recipe (IMPLEMENTATION_PLAN.md).
1351
-
1352
- Context
1353
- Four small groups complete the header of record 1000.
1354
-
1355
- Read first
1356
- - SPEC §7.2 (otherTaxableIncome, attachments, capitalGainsSummary, qualifyingCompany); fields.csv
1357
- 1000 rows 887–968 and 1065–1091; SPEC §4.2 percentX100 and amountX; §15 A-2, A-21.
1358
-
1359
- Goal
1360
- All non-filler header fields of record 1000 are mapped.
1361
-
1362
- Tests first
1363
- 1. Normalizer: otherTaxableIncome.source → 887 (hebrewText), amount → 937, ratePercent 10.23 → 949
1364
- ' 1023'; attachments counts → 954/957; capitalGainsSummary → 960/962/964–968;
1365
- qualifyingCompany purchased/amortizationClaimed yes/no → 1065/1090, amounts → 1066/1078,
1366
- amortizationAmount 0 → 1091 written as '0' (alphanumeric padding, A-21).
1367
- 2. Coverage helper from D1: record 1000 has no unmapped non-filler header keys.
1368
- 3. Round trip with every member set; canonicalize removes 0 for optional numeric header values
1369
- (D-3) except 1091 which is explicitly allowed to be 0 (document the exception in SPEC §8.4).
1370
-
1371
- Implementation
1372
- Per the recipe.
1373
-
1374
- Wiring
1375
- As in D1.
1376
-
1377
- Out of scope
1378
- Rules (D4, D5); code 028 (D3).
1379
-
1380
- Verify
1381
- Run the verify bundle.
1382
-
1383
- Commit: "feat(opcn1214-generator): remaining record 1000 header groups"
1384
-
1385
- Done when
1386
- - Record 1000's header is fully mapped and round-trips.
1387
- ```
1388
-
1389
- #### D3 — Derived main codes and code-map guards
1390
-
1391
- ```text
1392
- STEP D3 — Derived main codes and code-map guards
1393
- Apply the standing instructions and the Part D vertical-slice recipe (IMPLEMENTATION_PLAN.md).
1394
-
1395
- Context
1396
- Some main-form codes are derived from header data (SPEC §7.4) and must never come from the caller.
1397
- The amounts map needs dedicated rules instead of the generic input.shape.
1398
-
1399
- Read first
1400
- - SPEC §3.5, §7.2 bankAccount, §7.4 (codes 028, 277, 278, 280, 297), §10.1 (input.derivedCode,
1401
- input.unknownCode, struct.mainCodePairs.max), §10.3
1402
- main.bankAccount.format.
1403
-
1404
- Goal
1405
- Derived codes 028 (untransmitted part only; G1 adds transmitted appendices), 277/278/280, 297 and
1406
- the four rules.
1407
-
1408
- Tests first
1409
- 1. bankAccount { bank '12', branch '345', account '678' } → code 277 = 678, 278 = 12345 ('12' then
1410
- '345'), 280 = 1; form6111Obligation obliged → 297 = 8, notObliged → 297 = 9, notRelevant/absent →
1411
- no 297; capitalGainsSummary.untransmittedCount 3 → 028 = 3.
1412
- 2. RULE_CASES: amounts["273"] given → input.derivedCode (message names `declarations.directorsReceivedOpinion`
1413
- / `declarations.tookReportablePosition`); amounts["999"] → input.unknownCode (replaces the C5
1414
- input.shape behaviour for code-map keys; update that test); 62 pairs after derivations →
1415
- struct.mainCodePairs.max; bank '1' → main.bankAccount.format.
1416
- 3. Denormalize: 277/278/280 → bankAccount; 297 → form6111Obligation only when 834 is absent
1417
- (834 is the source of truth; 297 is checked for consistency in H1 parse.derivedMismatch).
1418
-
1419
- Implementation
1420
- Per the recipe; input.derivedCode/input.unknownCode are produced by the shape stage BEFORE zod: scan
1421
- the amounts map keys against the year's CodeDefs, report them, and remove those keys from the value
1422
- handed to zod so they are not reported again as input.shape (SPEC §9.2).
1423
-
1424
- Wiring
1425
- Derivations in normalizeReport; rules in the shape stage and the engine.
1426
-
1427
- Out of scope
1428
- Business rules (D4, D5).
1429
-
1430
- Verify
1431
- Run the verify bundle; the `minimal` golden must not change (if it does, stop and explain).
1432
-
1433
- Commit: "feat(opcn1214-generator): derived main-form codes and code-map rules"
1434
-
1435
- Done when
1436
- - Derived codes are produced and protected against caller input.
1437
- ```
1438
-
1439
- #### D4 — Record 1000 conditional requirements
1440
-
1441
- ```text
1442
- STEP D4 — Record 1000 conditional requirements
1443
- Apply the standing instructions (IMPLEMENTATION_PLAN.md, Part 3).
1444
-
1445
- Context
1446
- SPEC §10.3 lists conditional requirements of record 1000 that the generic field stage does not
1447
- evaluate (fields.csv `required = conditional`). They are business-stage rules over the
1448
- NormalizedReport, so they also run on parsed files.
1449
-
1450
- Read first
1451
- - SPEC §10.3 (error rows), §15 A-13; IMPLEMENTATION_PLAN.md §1.3 D-5.
1452
-
1453
- Goal
1454
- Rules: main.familyCompany.fileNumber, main.familyCompany.code080, main.houseCompany.code084,
1455
- main.investmentLaw.flag, main.beneficiaryEnterprise.noticeDate, main.specialYear.balanceSheetDate,
1456
- main.kibbutz.code226, main.buildingIncome.code259, main.cgReasons.otherText,
1457
- main.reportablePositions.required, main.reportablePositions.max.
1458
-
1459
- Tests first
1460
- 1. RULE_CASES for each. Rules that the input types make unreachable from input
1461
- (beneficiaryEnterprise.noticeDate, specialYear.balanceSheetDate, familyCompany.fileNumber when the
1462
- object exists) use 'file' cases built with tamper() on a generated file (C7b runner: business
1463
- issues come from parse1214(...).issues).
1464
- 2. Unit tests: code 080 = 0 satisfies main.familyCompany.code080 (zeroAllowed); the paths point at
1465
- the controlling input property (e.g. amounts["080"] for the missing code,
1466
- declarations.familyCompany for the flag).
1467
- 3. main.reportablePositions.max has no field of its own (only five positions exist): the normalizer
1468
- raises it as a notice (IMPLEMENTATION_PLAN.md §1.2) at declarations.reportablePositions[5] and
1469
- writes the first five positions.
1470
-
1471
- Implementation
1472
- - src/validate/main-rules.ts — one small function per rule, registered in the business stage.
1473
-
1474
- Wiring
1475
- Business-stage registry in src/validate/engine.ts.
1476
-
1477
- Out of scope
1478
- Warnings (D5).
1479
-
1480
- Verify
1481
- Run the verify bundle.
1482
-
1483
- Commit: "feat(opcn1214-generator): record 1000 conditional requirement rules"
1484
-
1485
- Done when
1486
- - All listed rules pass their cases on both input and file paths where applicable.
1487
- ```
1488
-
1489
- #### D5 — Record 1000 warnings and shareholder rules
1490
-
1491
- ```text
1492
- STEP D5 — Record 1000 warnings and shareholder rules
1493
- Apply the standing instructions (IMPLEMENTATION_PLAN.md, Part 3).
1494
-
1495
- Context
1496
- The remaining record 1000 rules are consistency warnings (source: derived) plus the shareholder
1497
- rules and counts. Kibbutz reports may have no shareholders.
1498
-
1499
- Read first
1500
- - SPEC §10.1 (struct.shareholders.min/max), §10.3 (warning rows except main.rd.*,
1501
- main.capitalGains.flag, main.appendixTotal.min — those need later records), §10.4, §15 A-15;
1502
- IMPLEMENTATION_PLAN.md §1.3 D-5.
1503
-
1504
- Goal
1505
- Goldens `main-full` and `kibbutz`, and the rules main.kibbutz.code226Other,
1506
- main.reportablePositions.unexpected, main.cgUntransmitted.reason,
1507
- main.cgUntransmitted.reasonWithoutCount, main.bankAccount.withNoBank,
1508
- main.qualifyingCompany.purchaseAmounts, main.qualifyingCompany.amortizationAmount,
1509
- main.attachments.code070, main.attachments.code010, shareholders.dividendRights.total,
1510
- shareholders.duplicateId, struct.shareholders.min, struct.shareholders.max.
1511
-
1512
- Tests first
1513
- 1. RULE_CASES for each rule; dividend rights total computed in hundredths (33.33 + 33.33 + 33.34
1514
- passes; 50 + 49.99 fails); total enforced only if at least one shareholder states it;
1515
- duplicate IDs ignore 999999964/999999998.
1516
- 2. Shape: shareholders becomes `Shareholder[]` that may be empty (the min rule, not the schema,
1517
- rejects empty lists for non-kibbutz companies).
1518
- 3. Golden `kibbutz`: isKibbutz, code 226, no shareholders; 9999 counts 00 shareholders.
1519
- 4. Golden `main-full`: every record-1000 header field set, 61 code pairs, bank account, 99
1520
- shareholders. It must be valid against EVERY rule of SPEC §10, including rules added in later
1521
- steps: no code 165 (main.rd.records in E2), dividend rights totalling exactly 100, not a
1522
- kibbutz, family/house-company codes present when flagged, no capital-gains or foreign flags
1523
- without the records. Assert validate1214(main-full).warnings is empty too.
1524
-
1525
- Implementation
1526
- - src/validate/main-rules.ts (warnings), src/validate/shareholder-rules.ts,
1527
- src/validate/structure-rules.ts (struct.* counts).
1528
-
1529
- Wiring
1530
- Business and structure stages.
1531
-
1532
- Out of scope
1533
- Rules depending on 1030, 2000/2200 or capital gains.
1534
-
1535
- Verify
1536
- Run the verify bundle.
1537
-
1538
- Commit: "feat(opcn1214-generator): record 1000 warnings and shareholder rules"
1539
-
1540
- Done when
1541
- - Every SPEC §10.3/§10.4 rule except main.rd.*, main.capitalGains.flag and main.appendixTotal.min
1542
- is implemented; `main-full` and `kibbutz` goldens are PENDING in VERIFICATION.md.
1543
- ```
1544
-
1545
- > **Human checkpoint CP-2 (after D5).** Verify `main-full` and `kibbutz` on shopcn; update
1546
- > `VERIFICATION.md`. Focus: percentage fields 949 and 1020@199–209 (SPEC §15 A-2, A-3), phone
1547
- > prefixes (A-19), bank code 278.
1548
-
1549
- **Outcome CP-2 (2026-11-17):** `main-full` and `kibbutz` rejected (identifier check digits, SPEC §15
1550
- A-25) → FIX-1.
1551
-
1552
- **Outcome CP-2 re-check (2026-11-18):** `kibbutz` passed; `main-full` rejected (withholding file
1553
- number not derived from the company file number, SPEC §15 A-28) → FIX-2.
1554
-
1555
- ---
1556
-
1557
- ### Part E — Related companies and R&D investments
1558
-
1559
- #### E1 — Related companies (1010)
1560
-
1561
- ```text
1562
- STEP E1 — Related companies (1010)
1563
- Apply the standing instructions and the Part D vertical-slice recipe (IMPLEMENTATION_PLAN.md).
1564
-
1565
- Context
1566
- Record 1010 (0–3 per report) lists related companies in Israel and abroad. It has no section.
1567
-
1568
- Read first
1569
- - SPEC §3.2, §3.3, §7.2 RelatedCompany, §7.4 (1010 serial), §10.1 struct.relatedCompanies.max;
1570
- fields.csv rows for 1010.
1571
-
1572
- Goal
1573
- relatedCompanies end to end (types, schema, normalizer, denormalizer, file order, 9999@139,
1574
- parser) and struct.relatedCompanies.max.
1575
-
1576
- Tests first
1577
- 1. Normalizer: relationType literals → 1..8 in the order of SPEC §7.2; serial numbers; paths
1578
- relatedCompanies[i].<key>; records placed after 1000 and before 1020.
1579
- 2. File: 9999@139 equals the count; parser accepts 1010 only between 1000 and 1020
1580
- (parse.order otherwise).
1581
- 3. RULE_CASES: four related companies → struct.relatedCompanies.max (the schema allows any array
1582
- length; the rule reports the limit).
1583
- 4. Round trip with 0, 1 and 3 related companies.
1584
-
1585
- Implementation
1586
- Per the recipe; src/normalize/related-companies.ts.
1587
-
1588
- Wiring
1589
- normalizeReport orchestrator; parser record-order table.
1590
-
1591
- Out of scope
1592
- R&D (E2).
1593
-
1594
- Verify
1595
- Run the verify bundle.
1596
-
1597
- Commit: "feat(opcn1214-generator): related companies (record 1010)"
1598
-
1599
- Done when
1600
- - Related companies generate, parse and round-trip; the limit rule passes its cases.
1601
- ```
1602
-
1603
- #### E2 — R&D investments (1030)
1604
-
1605
- ```text
1606
- STEP E2 — R&D investments (1030)
1607
- Apply the standing instructions and the Part D vertical-slice recipe (IMPLEMENTATION_PLAN.md).
1608
-
1609
- Context
1610
- Record 1030 (0–5 per report) lists investments in R&D companies; main-form code 165 is their total.
1611
-
1612
- Read first
1613
- - SPEC §3.2, §7.2 RdInvestment, §7.4 (1030 affiliation), §10.1 struct.rdInvestments.max, §10.3
1614
- main.rd.records and main.rd.total; fields.csv rows for 1030.
1615
-
1616
- Goal
1617
- rdInvestments end to end and three rules; golden `related-and-rd`.
1618
-
1619
- Tests first
1620
- 1. Normalizer: affiliation always 1; order after 1020; 9999@149 count.
1621
- 2. RULE_CASES: six investments → struct.rdInvestments.max; code 165 > 0 with no investments →
1622
- main.rd.records (E); total of investments ≠ code 165 → main.rd.total (W).
1623
- 3. Round trip with 0 and 5 investments. Golden `related-and-rd` (3 related companies,
1624
- 5 investments, code 165 equal to the total).
1625
-
1626
- Implementation
1627
- Per the recipe; src/normalize/rd-investments.ts; rules in src/validate/main-rules.ts.
1628
-
1629
- Wiring
1630
- As in E1.
1631
-
1632
- Out of scope
1633
- Foreign appendix.
1634
-
1635
- Verify
1636
- Run the verify bundle.
1637
-
1638
- Commit: "feat(opcn1214-generator): R&D investments (record 1030)"
1639
-
1640
- Done when
1641
- - `related-and-rd` is committed and PENDING in VERIFICATION.md; rules pass their cases.
1642
- ```
1643
-
1644
- ---
1645
-
1646
- ### Part F — Foreign appendix
1647
-
1648
- #### F1 — Foreign appendix (2000)
1649
-
1650
- ```text
1651
- STEP F1 — Foreign appendix (2000)
1652
- Apply the standing instructions and the Part D vertical-slice recipe (IMPLEMENTATION_PLAN.md).
1653
-
1654
- Context
1655
- Record 2000 (0–1) is the foreign appendix: a header and a code-amount section of 51 codes. Its
1656
- presence drives 1000@832 and 9999@143. Country breakdowns (2200) come in F2; until then, a filled
1657
- per-country code is allowed without a breakdown (F2 adds the rule).
1658
-
1659
- Read first
1660
- - SPEC §3.2, §3.5, §7.2 ForeignAppendix (without countryBreakdown), §7.4 (832), §10.5 first two
1661
- rows, §15 A-4, A-9, A-14; fields.csv and codes.csv rows for 2000.
1662
-
1663
- Goal
1664
- foreignAppendix end to end; 832 and 9999@143 derived; rules foreign.otherIncome.description and
1665
- foreign.refund.amount.
1666
-
1667
- Tests first
1668
- 1. Normalizer: header keys and paths (foreignAppendix.<key>); amounts → codes with paths
1669
- foreignAppendix.amounts["420"]; zero for code 442 kept (zeroAllowed), zero for others omitted;
1670
- 832 = yes when present; 9999@143 = '01'.
1671
- 2. Section starts at 1161 and amounts use 12 digits (A-4); the 2000 record is placed after 1030.
1672
- 3. RULE_CASES for the two rules; input.unknownCode and input.derivedCode also apply to
1673
- foreignAppendix.amounts (extend the shape-stage scan).
1674
- 4. Round trip with and without the appendix.
1675
-
1676
- Implementation
1677
- Per the recipe; src/normalize/foreign.ts; src/validate/foreign-rules.ts.
1678
-
1679
- Wiring
1680
- normalizeReport, parser order table, control record.
1681
-
1682
- Out of scope
1683
- countryBreakdown and 2200 (F2).
1684
-
1685
- Verify
1686
- Run the verify bundle.
1687
-
1688
- Commit: "feat(opcn1214-generator): foreign appendix (record 2000)"
1689
-
1690
- Done when
1691
- - The foreign appendix generates, parses and round-trips; 832 and 9999@143 follow its presence.
1692
- ```
1693
-
1694
- #### F2 — Country breakdown (2200)
1695
-
1696
- ```text
1697
- STEP F2 — Country breakdown (2200)
1698
- Apply the standing instructions and the Part D vertical-slice recipe (IMPLEMENTATION_PLAN.md).
1699
-
1700
- Context
1701
- Each filled per-country code of the foreign appendix (23 codes) needs exactly one 2200 record with
1702
- up to 10 countries. The country-amount section codec exists (B3); the country table is in the layout
1703
- (A3).
1704
-
1705
- Read first
1706
- - SPEC §3.6, §7.2 ForeignAppendix.countryBreakdown, §7.4 (2200 rows), §10.5 breakdown rows, §10.7 parse.countrySection, §15 A-16;
1707
- countries.csv.
1708
-
1709
- Goal
1710
- countryBreakdown end to end; rules foreign.breakdown.required, foreign.breakdown.orphan,
1711
- foreign.breakdown.countries.min, foreign.breakdown.countries.max,
1712
- foreign.breakdown.country.unknown, foreign.breakdown.country.unknownOnlyFor439,
1713
- foreign.breakdown.country.duplicate, parse.countrySection; golden `foreign`.
1714
-
1715
- Tests first
1716
- 1. Normalizer: one 2200 record per breakdown, sorted by code; header 137 = code, 140 = deductions;
1717
- countries with affiliation 1; paths foreignAppendix.countryBreakdown["420"].countries[i].country;
1718
- 9999@147 count; records placed right after 2000.
1719
- 2. RULE_CASES for every listed rule ('-88' on 420 → unknownOnlyFor439; '-88' on 439 passes;
1720
- 11 countries → countries.max; '001' → country.unknown (note: '999' is a real code, the UN);
1721
- the same country twice → duplicate). The schema accepts any string for country (SPEC §9.2).
1722
- 3. parse.countrySection for a malformed entry (affiliation 2) via tamper().
1723
- 4. Round trip; golden `foreign` (every per-country code, '-88' on 439, 10 countries on one code).
1724
-
1725
- Implementation
1726
- Per the recipe; extend src/normalize/foreign.ts and src/validate/foreign-rules.ts; the parser
1727
- groups 2200 records under the 2000 appendix during denormalization.
1728
-
1729
- Wiring
1730
- normalizeReport, parser, control record.
1731
-
1732
- Out of scope
1733
- Capital gains.
1734
-
1735
- Verify
1736
- Run the verify bundle.
1737
-
1738
- Commit: "feat(opcn1214-generator): foreign income by country (record 2200)"
1739
-
1740
- Done when
1741
- - `foreign` golden committed and PENDING; all breakdown rules pass their cases.
1742
- ```
1743
-
1744
- > **Human checkpoint CP-3 (after F2).** Verify `related-and-rd` and `foreign` on shopcn (A-4, A-9,
1745
- > A-14, A-16 in SPEC §15).
1746
-
1747
- **Outcome CP-3 (2026-11-17):** `foreign` passed (A-4, A-9, A-14, A-24 verified); `related-and-rd`
1748
- rejected (identifier check digits, SPEC §15 A-25) → FIX-1.
1749
-
1750
- **Outcome CP-3 re-check (2026-11-18):** `related-and-rd` rejected (Latin related-company name, SPEC
1751
- §15 A-29) → FIX-2.
1752
-
1753
- ---
1754
-
1755
- ### Part G — Capital-gains appendices
1756
-
1757
- The ten appendix types share four shapes. G1 builds the shared machinery with the simplest type;
1758
- G2–G5 add families. Every type gets its own golden file.
1759
-
1760
- #### G1 — Capital-gains framework and 3063
1761
-
1762
- ```text
1763
- STEP G1 — Capital-gains framework and 3063
1764
- Apply the standing instructions and the Part D vertical-slice recipe (IMPLEMENTATION_PLAN.md).
1765
-
1766
- Context
1767
- capitalGains is a discriminated union on `symbol` (record type = 3000 + symbol). Appendix numbers
1768
- count per symbol; the "מספר בתל"ם" sequence counts across all appendices; records are grouped by
1769
- type ascending, input order within a type (SPEC §3.3, §7.4, §15 A-7). 1000@833, code 028 and
1770
- 9999@145 depend on the appendices. 3063 (securities under section 6) is the simplest type: header
1771
- with foreign-asset flag and losses carried forward, 5 codes.
1772
-
1773
- Read first
1774
- - SPEC §3.7, §7.2 CapitalGainsAppendix and Section6SecuritiesAppendix, §7.4 (833, 028, 30xx rows),
1775
- §10.1 struct.capitalGains.max, §10.3 main.capitalGains.flag and main.appendixTotal.min,
1776
- §15 A-7, A-12; fields.csv/codes.csv rows for 3063.
1777
-
1778
- Goal
1779
- The capital-gains framework, record 3063 end to end, three rules, golden `cg-63`.
1780
-
1781
- Tests first
1782
- 1. Framework (tests/normalize/capital-gains.test.ts) using 3063 only: two 3063 appendices → appendix
1783
- numbers 1, 2; records emitted after 2000/2200; paths capitalGains[i].<key> keep the INPUT index
1784
- even when emission order differs; 833 = yes when any appendix exists; code 028 =
1785
- appendices + untransmittedCount; 9999@145 count.
1786
- 2. RULE_CASES: 15 appendices → struct.capitalGains.max; declarations.hasCapitalGainsAppendix false
1787
- with appendices → main.capitalGains.flag; capitalGainsSummary.totalAppendicesCount lower than
1788
- transmitted appendices (2000 + 30xx) + untransmittedCount → main.appendixTotal.min.
1789
- main.capitalGains.flag is raised by the normalizer as a notice (833 itself is derived as yes, so
1790
- the explicit `false` exists only in the input; IMPLEMENTATION_PLAN.md §1.2).
1791
- 3. Codes: amounts use 3-digit keys ('022', '056'); input.unknownCode/derivedCode apply.
1792
- 4. Round trip; golden `cg-63`.
1793
-
1794
- Implementation
1795
- - src/model/input.ts — CapitalGainsAppendix = Section6SecuritiesAppendix (the union grows in later
1796
- steps); schema as a z.discriminatedUnion on symbol.
1797
- - src/normalize/capital-gains/index.ts (ordering, numbering, sequence) and
1798
- src/normalize/capital-gains/section6.ts; denormalize counterpart; parser order table for 3063.
1799
- - Code 028 and 833 derivations updated in src/normalize/derive.ts.
1800
-
1801
- Wiring
1802
- normalizeReport, parser, control record, main-rules.
1803
-
1804
- Out of scope
1805
- Other appendix types.
1806
-
1807
- Verify
1808
- Run the verify bundle.
1809
-
1810
- Commit: "feat(opcn1214-generator): capital-gains framework and section 6 securities (3063)"
1811
-
1812
- Done when
1813
- - 3063 generates, parses and round-trips; numbering, 833, 028 and 9999@145 are correct.
1814
- ```
1815
-
1816
- #### G2 — Securities with withholders: 3060 and 3064
1817
-
1818
- ```text
1819
- STEP G2 — Securities with withholders: 3060 and 3064
1820
- Apply the standing instructions and the Part D vertical-slice recipe (IMPLEMENTATION_PLAN.md).
1821
-
1822
- Context
1823
- 3060 (securities) and 3064 (REIT) share a header: four yes/no flags, up to four withholding agents
1824
- (name, branch, account), losses carried forward; 21 and 6 codes.
1825
-
1826
- Read first
1827
- - SPEC §7.2 SecuritiesAppendix and ReitAppendix, §7.3 withholders rows, §15 A-8; fields.csv/
1828
- codes.csv rows for 3060 and 3064.
1829
-
1830
- Goal
1831
- Both types end to end with a shared normalizer helper; goldens `cg-60`, `cg-64`.
1832
-
1833
- Tests first
1834
- 1. withholders[0..3] → keys withholders[i].name/branch/account; withholder name must start with a
1835
- Hebrew letter (field.hebrewFirstLetter fires at capitalGains[i].withholders[j].name); branch '12'
1836
- canonicalizes to '012' (D-3); five withholders → input.shape.
1837
- 2. gainFromInvestmentFund is yes/no {1,2} for both types (A-8).
1838
- 3. Mixed appendices (63, 60, 64) are grouped by type ascending; appendix numbers per symbol; the
1839
- sequence is not written for these types (they have no "מספר בתל"ם" field).
1840
- 4. Round trip; goldens.
1841
-
1842
- Implementation
1843
- Per the recipe; src/normalize/capital-gains/securities.ts (shared by 3060/3064 and reused by 3065
1844
- in G3).
1845
-
1846
- Wiring
1847
- Union, schema, normalizer, denormalizer, parser order table.
1848
-
1849
- Out of scope
1850
- 3065/3066.
1851
-
1852
- Verify
1853
- Run the verify bundle.
1854
-
1855
- Commit: "feat(opcn1214-generator): securities and REIT appendices (3060, 3064)"
1856
-
1857
- Done when
1858
- - Both types round-trip and their goldens are PENDING in VERIFICATION.md.
1859
- ```
1860
-
1861
- #### G3 — No-withholding appendices: 3065 and 3066
1862
-
1863
- ```text
1864
- STEP G3 — No-withholding appendices: 3065 and 3066
1865
- Apply the standing instructions and the Part D vertical-slice recipe (IMPLEMENTATION_PLAN.md).
1866
-
1867
- Context
1868
- 3065 (form 1322) extends the securities header with a withholding status and the sequence number;
1869
- 3066 (form 1326) is a short variant. Their header positions differ from 3060 by one (147 vs 146
1870
- for the first withholder) — rely on the layout keys, never on offsets.
1871
-
1872
- Read first
1873
- - SPEC §7.2 NoWithholding1322Appendix and NoWithholding1326Appendix, §15 A-18; fields.csv/codes.csv
1874
- rows for 3065 and 3066.
1875
-
1876
- Goal
1877
- Both types end to end; goldens `cg-65`, `cg-66`.
1878
-
1879
- Tests first
1880
- 1. withholdingStatus notWithheldFirstHalf → 2, notWithheldSecondHalf → 3, absent → 0.
1881
- 2. The "מספר בתל"ם" sequence (3065@325, 3066@154) counts across all appendices in emission order:
1882
- with appendices [63, 65, 60, 66] the 65 gets the sequence of its emission position.
1883
- 3. Round trip; goldens.
1884
-
1885
- Implementation
1886
- Per the recipe; reuse the G2 securities helper for 3065.
1887
-
1888
- Wiring
1889
- As in G2.
1890
-
1891
- Out of scope
1892
- Asset types (G4), 3077 (G5).
1893
-
1894
- Verify
1895
- Run the verify bundle.
1896
-
1897
- Commit: "feat(opcn1214-generator): no-withholding appendices (3065, 3066)"
1898
-
1899
- Done when
1900
- - Both types round-trip; sequence numbering is asserted across mixed types.
1901
- ```
1902
-
1903
- #### G4 — Asset appendices: 3027, 3050, 3054, 3051
1904
-
1905
- ```text
1906
- STEP G4 — Asset appendices: 3027, 3050, 3054, 3051
1907
- Apply the standing instructions and the Part D vertical-slice recipe (IMPLEMENTATION_PLAN.md).
1908
-
1909
- Context
1910
- Four types describe a sold asset with dates. 3027 (shares) has three optional dates and ×100
1911
- codes; 3050 (betterment tax) and 3054 (oil partnership) require a purchase date and the code-15
1912
- date; 3051 (forced virtual-currency transaction) requires the code-15 date, codes 071 (= 1) and 016,
1913
- and may carry two wallet addresses. Code 018 is a rate (23 or 50) stored ×100.
1914
-
1915
- Read first
1916
- - SPEC §3.7 (p.38 guidance on symbol 51), §4.2 amountX100/rateX100, §7.2 SharesAppendix,
1917
- BettermentTaxAppendix, OilPartnershipAppendix, ForcedVirtualCurrencyAppendix; IMPLEMENTATION_PLAN
1918
- §1.3 D-6; fields.csv/codes.csv rows for 3027, 3050, 3051, 3054; extraction note for 3051.
1919
-
1920
- Goal
1921
- Four types end to end; goldens `cg-27`, `cg-50`, `cg-54`, `cg-51`.
1922
-
1923
- Tests first
1924
- 1. 3027: codes 020/053/027 accept agorot and are written ×100 (1234.56 → 123456); code 018 23 →
1925
- '2300', 30 → field.enum; dates → DD/MM/YYYY at 225/235/245; assetLocation abroad/israel → 1/2.
1926
- 2. 3050/3054: missing purchaseDate or dates.code15 → field.required at the right paths; 3050
1927
- code 014 ∈ {10, 20}.
1928
- 3. 3051: codes 071 and 016 required (field.required); walletAddresses (≤ 150 chars each, two at
1929
- most) at 236/386; buyerName must start with a Hebrew letter; sequence number at 234.
1930
- 4. Round trip for each; goldens.
1931
-
1932
- Implementation
1933
- Per the recipe; src/normalize/capital-gains/assets.ts.
1934
-
1935
- Wiring
1936
- As in G2.
1937
-
1938
- Out of scope
1939
- 3077 (G5).
1940
-
1941
- Verify
1942
- Run the verify bundle.
1943
-
1944
- Commit: "feat(opcn1214-generator): asset capital-gains appendices (3027, 3050, 3054, 3051)"
1945
-
1946
- Done when
1947
- - All four types round-trip; their goldens are PENDING in VERIFICATION.md.
1948
- ```
1949
-
1950
- #### G5 — Other transactions: 3077
1951
-
1952
- ```text
1953
- STEP G5 — Other transactions: 3077
1954
- Apply the standing instructions and the Part D vertical-slice recipe (IMPLEMENTATION_PLAN.md).
1955
-
1956
- Context
1957
- 3077 is the richest appendix: up to five improvements (expense, accumulated depreciation, date —
1958
- ×100 amounts in the header) whose code-50 amounts are written as derived codes 501–505, an
1959
- improvement count at 245, a replacement asset, wallet addresses, and code 071 for virtual currency.
1960
-
1961
- Read first
1962
- - SPEC §7.2 OtherTransactionsAppendix, §7.3 improvements rows, §7.4 (245, 501–505), §10.6, §15 A-11;
1963
- fields.csv/codes.csv rows for 3077.
1964
-
1965
- Goal
1966
- 3077 end to end; rules cg.improvements.max, cg.improvements.code50Amount, cg.virtualCurrency.wallet
1967
- (improvement dates are covered by the slot-aware field.required, SPEC §9.3); goldens `cg-77` and
1968
- `capital-gains-max` (14 appendices of mixed types).
1969
-
1970
- Tests first
1971
- 1. improvements[i] → keys improvements[i].expense/accumulatedDepreciation/date (×100 amounts) and
1972
- code 50(i+1) from code50Amount; 245 = improvements.length; passing 501 in amounts →
1973
- input.derivedCode.
1974
- 2. RULE_CASES for the three rules (six improvements → cg.improvements.max, raised as a normalizer
1975
- notice since only five slots exist; the wallet rule also via a 'file' case). Plus: a 3077 with
1976
- one improvement raises no field.required for the empty slots 2–5, and a parsed file with
1977
- improvement 2's expense but no date raises field.required at capitalGains[i].improvements[1].date.
1978
- 3. Code 092 accepts a single digit (A-11); dates.code15 and dates.code20 required.
1979
- 4. capital-gains-max: 14 appendices across all ten types; asserts grouping, appendix numbers,
1980
- sequence numbers, 9999@145 = 14, code 028.
1981
- 5. Round trip; goldens.
1982
-
1983
- Implementation
1984
- Per the recipe; src/normalize/capital-gains/other.ts; src/validate/capital-gains-rules.ts.
1985
-
1986
- Wiring
1987
- Completes the CapitalGainsAppendix union; parser order table complete for all record types.
1988
-
1989
- Out of scope
1990
- Batches, response file.
1991
-
1992
- Verify
1993
- Run the verify bundle.
1994
-
1995
- Commit: "feat(opcn1214-generator): other-transactions appendix (3077)"
1996
-
1997
- Done when
1998
- - All ten appendix types are supported; every SPEC §10.6 rule is implemented.
1999
- ```
2000
-
2001
- > **Human checkpoint CP-4 (after G5).** Verify every `cg-*` golden and `capital-gains-max` on shopcn
2002
- > (A-7, A-8, A-11 in SPEC §15).
2003
-
2004
- **Outcome CP-4 (2026-11-18):** `cg-27`, `cg-50`, `cg-51`, `cg-54`, `cg-63`, `cg-64`, `cg-66` and
2005
- `cg-77` passed; `cg-60` and `cg-65` rejected (more than 20 code-amount pairs in one appendix, SPEC
2006
- §15 A-30) and `capital-gains-max` rejected (3077 code 092 = 2, SPEC §15 A-31, superseding A-11) →
2007
- FIX-2.
2008
-
2009
- ---
2010
-
2011
- ### Part H — Completion
2012
-
2013
- #### H1 — Parser hardening and batches
2014
-
2015
- ```text
2016
- STEP H1 — Parser hardening and batches
2017
- Apply the standing instructions (IMPLEMENTATION_PLAN.md, Part 3).
2018
-
2019
- Context
2020
- All record types parse. Remaining: occurrence limits in files, multiple reports per file
2021
- (OPCN batches of up to 50), and consistency of derived values in parsed files.
2022
-
2023
- Read first
2024
- - SPEC §3.1, §6.1 (batch functions), §8.1 (batch), §8.2 step 3, §10.1 struct.batch.size, §10.7
2025
- (parse.occurrences, parse.multipleReports, parse.derivedMismatch).
2026
-
2027
- Goal
2028
- generate1214Batch, parse1214Batch, and rules parse.occurrences, parse.multipleReports,
2029
- parse.derivedMismatch, struct.batch.size; golden `batch-50`.
2030
-
2031
- Tests first
2032
- 1. generate1214Batch: concatenates reports in input order; issues carry reportIndex; 0 or 51
2033
- reports → struct.batch.size (thrown in Opcn1214ValidationError); fileName
2034
- '1214_batch_<n>.txt'; summary.reports = n.
2035
- 2. parse1214Batch: splits at each 9999; returns one ParseResult per report; a missing 9999 between
2036
- reports → parse.order or parse.control.missing at the right line.
2037
- 3. parse1214 given a batch → parse.multipleReports.
2038
- 4. parse.occurrences (MAXIMA only; minOccurs is never enforced by the parser — the `kibbutz`
2039
- golden has no 1020 records and must keep parsing): 4 records 1010, 6 records 1030, 2 records
2040
- 2000, 31 records 2200, 15 capital-gains records — each via a 'file' case.
2041
- 5. parse.derivedMismatch: tampered code 273 vs 1029/1030; 832 = yes without 2000; 833 = no with
2042
- appendices; wrong 1020 serial; wrong appendix number or sequence; code 297 inconsistent with 834;
2043
- code 028 inconsistent (each a tamper case; one rule ID, path/field identifies the value).
2044
- 6. Golden `batch-50` (50 minimal reports with distinct file numbers).
2045
- 7. Add RuleCase kind { kind: 'batch'; fail(): unknown[]; pass(): unknown[] } (runs
2046
- generate1214Batch and collects the thrown issues) for struct.batch.size.
2047
-
2048
- Implementation
2049
- - src/api/generate.ts (batch), src/api/parse.ts (batch), src/file/parse.ts (splitting, occurrence
2050
- limits from RecordDef.maxOccurs and layout.limits), src/validate/parse-rules.ts
2051
- (derivedMismatch, using the same derivation functions as the normalizer).
2052
- - src/index.ts exports the batch functions.
2053
-
2054
- Wiring
2055
- Public API complete except parseResponseFile.
2056
-
2057
- Out of scope
2058
- Response file (H2).
2059
-
2060
- Verify
2061
- Run the verify bundle.
2062
-
2063
- Commit: "feat(opcn1214-generator): batches and parser hardening"
2064
-
2065
- Done when
2066
- - Every SPEC §10.7 rule is implemented; batch goldens round-trip.
2067
- ```
2068
-
2069
- #### H2 — Response file parser
2070
-
2071
- ```text
2072
- STEP H2 — Response file parser
2073
- Apply the standing instructions (IMPLEMENTATION_PLAN.md, Part 3).
2074
-
2075
- Context
2076
- After transmission SHAAM returns shumot.shg: one line per report with file number (9), tax year (4),
2077
- response code (2) and, for codes 08/33, trailing field detail (SPEC §3.9).
2078
-
2079
- Read first
2080
- - SPEC §3.9, §6.1 parseResponseFile, §6.2 ResponseRecord.
2081
-
2082
- Goal
2083
- Public parseResponseFile.
2084
-
2085
- Tests first (tests/api/response.test.ts)
2086
- 1. A three-line file (codes 00, 05, 33 with detail) parses into three ResponseRecords with
2087
- meanings from SPEC §3.9 and accepted only for 00.
2088
- 2. Unknown code → meaning 'General error; notify SHAAM'.
2089
- 3. windows-1255 bytes with Hebrew detail text decode correctly; CRLF/LF; blank lines ignored.
2090
- 4. A malformed line (fewer than 15 characters or non-digit fields) throws Opcn1214ParseError with
2091
- the line number (rule parse.lineLength / parse.numeric reused).
2092
-
2093
- Implementation
2094
- - src/api/response.ts, src/response/codes.ts (code → English meaning table).
2095
- - src/index.ts exports parseResponseFile and ResponseRecord.
2096
-
2097
- Wiring
2098
- Public API complete.
2099
-
2100
- Out of scope
2101
- Matching responses to generated reports (callers do it by file number and year).
2102
-
2103
- Verify
2104
- Run the verify bundle.
2105
-
2106
- Commit: "feat(opcn1214-generator): SHAAM response file parser"
2107
-
2108
- Done when
2109
- - parseResponseFile is public and tested.
2110
- ```
2111
-
2112
- #### H3 — Property, determinism and edge-case suite
2113
-
2114
- ```text
2115
- STEP H3 — Property, determinism and edge-case suite
2116
- Apply the standing instructions (IMPLEMENTATION_PLAN.md, Part 3).
2117
-
2118
- Context
2119
- Every feature exists. This step adds the broad safety net of SPEC §13.6 and §13.7.
2120
-
2121
- Read first
2122
- - SPEC §8.3, §8.4, §13.6, §13.7.
2123
-
2124
- Goal
2125
- Seeded randomized round trips over all record types, determinism tests and the edge-case list;
2126
- golden `hebrew-edge`.
2127
-
2128
- Tests first
2129
- 1. tests/fixtures/random.ts — a seeded PRNG (mulberry32) and `randomValidInput(seed)` that composes
2130
- the builders: random subsets of optional members, 1–99 shareholders, 0–3 related companies,
2131
- 0–5 R&D investments, optional foreign appendix with breakdowns, 0–14 capital-gains appendices of
2132
- random types, valid values for every kind (within widths, valid dates, Hebrew names).
2133
- 2. tests/roundtrip/property.test.ts — 200 seeds: validate1214 is valid; generate → parse →
2134
- canonicalize deep-equals canonicalize(input); a failing seed is printed for reproduction.
2135
- 3. tests/roundtrip/determinism.test.ts — shuffled object keys, shuffled amounts order, undefined
2136
- members → identical bytes.
2137
- 4. tests/edge-cases.test.ts — every item of SPEC §13.7 as its own test.
2138
- 5. Golden `hebrew-edge`.
2139
-
2140
- Implementation
2141
- Tests only, plus any bug fixes they reveal (each fix gets its own focused unit test).
2142
-
2143
- Wiring
2144
- Runs in the package suite.
2145
-
2146
- Out of scope
2147
- New features.
2148
-
2149
- Verify
2150
- Run the verify bundle. Give the property test a generous per-test timeout (e.g. 60 s) instead of
2151
- asserting its duration (CI runs on three Node versions).
2152
-
2153
- Commit: "test(opcn1214-generator): property, determinism and edge-case suite"
2154
-
2155
- Done when
2156
- - 200 random seeds round-trip; every SPEC §13.7 case has a test.
2157
- ```
2158
-
2159
- #### H4 — Release wiring
2160
-
2161
- ```text
2162
- STEP H4 — Release wiring
2163
- Apply the standing instructions (IMPLEMENTATION_PLAN.md, Part 3).
2164
-
2165
- Context
2166
- The package is functionally complete. It must be wired into the monorepo like the sibling
2167
- generators and documented for consumers.
2168
-
2169
- Read first
2170
- - SPEC §6.4, §6.5, §12 P6, §13.4, §13.9; root package.json (build:tools), root tsconfig.json paths,
2171
- root vitest.config.ts aliases, .changeset/, packages/shaam6111-generator/README.md (style).
2172
-
2173
- Goal
2174
- Documented, releasable package.
2175
-
2176
- Tests first
2177
- 1. tests/rules/spec-sync.test.ts — now asserts equality: the set of RULES IDs equals the set of rule
2178
- IDs in SPEC.md §10 tables.
2179
- 2. tests/docs/readme.test.ts — every TypeScript code block in README.md preceded by `<!-- test -->` is executed
2180
- (write each example as a self-contained snippet using minimal fixtures) and the README rule table
2181
- equals the one rendered from RULES.
2182
- 3. tests/api/exports.test.ts — final public surface per SPEC §6.4.
2183
-
2184
- Implementation
2185
- - README.md — purpose, install, quick start (validate → generate), parsing, batches, response file,
2186
- error handling (SPEC §11.4 pattern), rule table (generated by scripts/render-rules-table.ts and
2187
- pasted between markers), versioning (SPEC §6.5), verification status (link VERIFICATION.md).
2188
- - Root wiring: add @accounter/opcn1214-generator to the root `build:tools` include list and to
2189
- root tsconfig.json `paths`; nothing in the server yet.
2190
- - Changeset: .changeset/<name>.md with a minor bump for @accounter/opcn1214-generator describing the
2191
- new package.
2192
- - Remove any leftover scaffolding (search for TODO, SPEC_STATUS, passWithNoTests).
2193
-
2194
- Wiring
2195
- Monorepo build includes the package.
2196
-
2197
- Out of scope
2198
- Server/client integration (SPEC Appendix B).
2199
-
2200
- Verify
2201
- Run the verify bundle and the root `yarn build:tools`.
2202
-
2203
- Commit: "chore(opcn1214-generator): release wiring and documentation"
2204
-
2205
- Done when
2206
- - The package builds as part of build:tools, README examples run, and the rule catalogue equals the
2207
- spec.
2208
- ```
2209
-
2210
- > **Human checkpoint CP-5 (after H4).** Every golden file in `VERIFICATION.md` is marked verified
2211
- > (or its rejection resolved). Then the package can be released and the server integration (SPEC
2212
- > Appendix B) planned.
2213
-
2214
- **Outcome CP-5 (2026-11-18):** `hebrew-edge` and `batch-50` passed; the five files rejected at the
2215
- CP-2 to CP-4 re-checks were regenerated in FIX-2 and are PENDING.
2216
-
2217
- **Outcome FIX-2 re-check (2026-11-18):** `cg-60`, `cg-65` and `related-and-rd` passed;
2218
- `capital-gains-max` rejected (an improvement without an expense, SPEC §15 A-32) → FIX-3; `main-full`
2219
- rejected (beneficiary-enterprise notice date before the tax year, 1000@852, SPEC §15 A-33) → FIX-3.
2220
-
2221
- **Outcome FIX-3 re-check (2026-11-18):** `main-full` and `capital-gains-max` passed. Every golden
2222
- file is verified on shopcn; CP-5 is closed.
2223
-
2224
- ---
2225
-
2226
- ### Fix-up step template (when a checkpoint fails)
2227
-
2228
- ```text
2229
- STEP FIX-<n> — <what shopcn rejected>
2230
- Apply the standing instructions (IMPLEMENTATION_PLAN.md, Part 3).
2231
-
2232
- Context
2233
- Checkpoint <CP-n> rejected <fixture>.opcn with: "<exact checker message>".
2234
- Suspected ambiguity: SPEC §15 <A-x>.
2235
-
2236
- Goal
2237
- Change the default for <A-x> to <new behaviour>, regenerate every affected golden file, and record
2238
- the outcome.
2239
-
2240
- Tests first
2241
- 1. Update the codec/encoder unit tests that encode the old behaviour to the new expected strings.
2242
- 2. Add a regression test naming the checkpoint.
2243
-
2244
- Implementation
2245
- - Change the single place that controls the behaviour (e.g. ALPHANUMERIC_PAD_SIDE).
2246
- - UPDATE_GOLDEN=1 for every golden; review the diff: only the bytes explained by the change may
2247
- differ.
2248
- - SPEC §15: mark <A-x> as verified with the new decision; VERIFICATION.md: reset affected fixtures
2249
- to PENDING.
2250
-
2251
- Verify
2252
- Run the verify bundle.
2253
-
2254
- Commit: "fix(opcn1214-generator): <short description> (verified on shopcn)"
2255
-
2256
- Done when
2257
- - All tests green; affected goldens PENDING for re-verification.
2258
- ```