@things-factory/figure-service 10.1.205 → 10.1.207

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 (105) hide show
  1. package/dist-server/service/figure/event-subscriber.js +5 -0
  2. package/dist-server/service/figure/event-subscriber.js.map +1 -1
  3. package/dist-server/service/figure/figure-context.js +0 -2
  4. package/dist-server/service/figure/figure-context.js.map +1 -1
  5. package/dist-server/service/figure/figure-format.d.ts +9 -2
  6. package/dist-server/service/figure/figure-format.js +36 -69
  7. package/dist-server/service/figure/figure-format.js.map +1 -1
  8. package/dist-server/service/figure/figure-mutation.js +2 -0
  9. package/dist-server/service/figure/figure-mutation.js.map +1 -1
  10. package/dist-server/service/figure/figure-propose-steps.d.ts +1 -1
  11. package/dist-server/service/figure/figure-propose-steps.js +3 -5
  12. package/dist-server/service/figure/figure-propose-steps.js.map +1 -1
  13. package/dist-server/service/figure/figure-query.js +3 -5
  14. package/dist-server/service/figure/figure-query.js.map +1 -1
  15. package/dist-server/service/figure/figure-revert.js +1 -1
  16. package/dist-server/service/figure/figure-revert.js.map +1 -1
  17. package/dist-server/service/figure/figure-type.js +1 -1
  18. package/dist-server/service/figure/figure-type.js.map +1 -1
  19. package/dist-server/tsconfig.tsbuildinfo +1 -1
  20. package/package.json +8 -8
  21. package/recipes/base-frame/recipe.json +4 -8
  22. package/recipes/belt-surface/recipe.json +2 -4
  23. package/recipes/bin-row/recipe.json +1 -2
  24. package/recipes/bollard-row/recipe.json +1 -2
  25. package/recipes/cabinet-doors/recipe.json +5 -10
  26. package/recipes/cable-tray/recipe.json +3 -6
  27. package/recipes/canopy/recipe.json +2 -4
  28. package/recipes/cart-handle/recipe.json +1 -2
  29. package/recipes/ceiling-rail-carriage/recipe.json +1 -2
  30. package/recipes/chain-rails/recipe.json +2 -4
  31. package/recipes/column-row/recipe.json +1 -2
  32. package/recipes/conveyor-skirts/recipe.json +4 -8
  33. package/recipes/double-hinged-door/recipe.json +6 -12
  34. package/recipes/drawer-stack/recipe.json +13 -26
  35. package/recipes/drip-tray/recipe.json +2 -4
  36. package/recipes/end-covers/recipe.json +4 -8
  37. package/recipes/ffu-row/recipe.json +1 -2
  38. package/recipes/floor-zone/recipe.json +4 -8
  39. package/recipes/folding-door/recipe.json +3 -6
  40. package/recipes/gantry-frame/recipe.json +1 -2
  41. package/recipes/guard-cover/recipe.json +2 -4
  42. package/recipes/handrail/recipe.json +2 -4
  43. package/recipes/hatch/recipe.json +4 -8
  44. package/recipes/hinged-door/recipe.json +4 -8
  45. package/recipes/hopper/recipe.json +1 -2
  46. package/recipes/ladder/recipe.json +3 -6
  47. package/recipes/lift-updown/recipe.json +2 -4
  48. package/recipes/linear-guide/recipe.json +1 -2
  49. package/recipes/locker-row/recipe.json +1 -2
  50. package/recipes/observation-window/recipe.json +4 -8
  51. package/recipes/operator-panel/recipe.json +4 -8
  52. package/recipes/partition-wall/recipe.json +3 -6
  53. package/recipes/peg-board/facts.md +1 -1
  54. package/recipes/peg-board/recipe.json +1 -2
  55. package/recipes/pipe-run/recipe.json +1 -2
  56. package/recipes/platform/recipe.json +2 -4
  57. package/recipes/pull-cord/recipe.json +1 -2
  58. package/recipes/roll-up-shutter/recipe.json +3 -6
  59. package/recipes/roller-row/recipe.json +2 -4
  60. package/recipes/room-shell/recipe.json +6 -12
  61. package/recipes/safety-fence/recipe.json +2 -4
  62. package/recipes/safety-mat/recipe.json +1 -2
  63. package/recipes/shelf-tiers/recipe.json +5 -10
  64. package/recipes/side-guides/recipe.json +2 -4
  65. package/recipes/sign-board/recipe.json +1 -2
  66. package/recipes/sliding-door/recipe.json +7 -14
  67. package/recipes/stairs/recipe.json +1 -2
  68. package/recipes/stopper/recipe.json +1 -2
  69. package/recipes/suction-pads/recipe.json +1 -2
  70. package/recipes/tank/recipe.json +2 -4
  71. package/recipes/toe-board/recipe.json +1 -2
  72. package/recipes/traffic-cones/recipe.json +1 -2
  73. package/recipes/transfer-belts/recipe.json +2 -4
  74. package/recipes/trough/recipe.json +1 -2
  75. package/recipes/turntable/recipe.json +1 -2
  76. package/recipes/workbench-top/recipe.json +2 -4
  77. package/scripts/templates.test.mts +2 -3
  78. package/server/service/figure/event-subscriber.ts +4 -0
  79. package/server/service/figure/figure-blueprint-query.test.ts +3 -0
  80. package/server/service/figure/figure-category-db.test.ts +2 -2
  81. package/server/service/figure/figure-context.test.ts +2 -2
  82. package/server/service/figure/figure-context.ts +0 -2
  83. package/server/service/figure/figure-deprecation-db.test.ts +2 -2
  84. package/server/service/figure/figure-format.test.ts +25 -105
  85. package/server/service/figure/figure-format.ts +40 -73
  86. package/server/service/figure/figure-inspect-db.test.ts +6 -5
  87. package/server/service/figure/figure-llm-smoke.test.ts +1 -1
  88. package/server/service/figure/figure-mutation.ts +2 -0
  89. package/server/service/figure/figure-namespace-db.test.ts +2 -2
  90. package/server/service/figure/figure-propose-steps.test.ts +15 -20
  91. package/server/service/figure/figure-propose-steps.ts +3 -5
  92. package/server/service/figure/figure-public-db.test.ts +2 -2
  93. package/server/service/figure/figure-query.ts +3 -6
  94. package/server/service/figure/figure-release-check.test.ts +2 -2
  95. package/server/service/figure/figure-release-record-db.test.ts +7 -6
  96. package/server/service/figure/figure-release-size-db.test.ts +156 -0
  97. package/server/service/figure/figure-revert.ts +2 -2
  98. package/server/service/figure/figure-tools.test.ts +2 -2
  99. package/server/service/figure/figure-type.ts +1 -1
  100. package/translations/en.json +4 -16
  101. package/translations/es.json +4 -16
  102. package/translations/ja.json +4 -16
  103. package/translations/ko.json +4 -16
  104. package/translations/ms.json +4 -16
  105. package/translations/zh.json +4 -16
@@ -13,6 +13,8 @@ const figure_history_js_1 = require("./figure-history.js");
13
13
  * 그 전부를 남기면 판본 목록이 「내가 오늘 몇 번 눌렀나」가 된다. 사람이 판이라고 부르는 것은
14
14
  * **발행한 것**이므로 그때만 베낀다. board 가 같은 규칙으로 돈다(`board-service` 의 같은 이름 파일).
15
15
  *
16
+ * 발행판의 정본(`__releaseSource`)은 크기 범위를 적은 발행판 사본이다 — Figure 행에는 작성자가 좁힌 끝만 남는다.
17
+ *
16
18
  * 발행 메모는 Figure 의 칸이 아니다. `releaseFigure` 가 저장할 엔티티에 `__releaseComment` 로 얹어
17
19
  * 두면 여기서 판본의 `comment` 로 옮긴다 — 메모는 그 판의 것이지 도형의 것이 아니다. 정본 형식
18
20
  * (`__releaseFormat`), 잰 커널의 판(`__releaseKernel`, ADR-0109 C1), 직전 판에 견준 변경(`__releaseChanges`), 발행 때 잰 값(`__releaseMetrics`)과
@@ -21,6 +23,9 @@ const figure_history_js_1 = require("./figure-history.js");
21
23
  /** What `releaseFigure` laid on the entity for this release, moved onto the history row. */
22
24
  function releaseRecordOnto(history, entity) {
23
25
  const e = entity;
26
+ /* What a board reads of this release: its own copy, with the size range written down (ADR-0087 decision 6). */
27
+ if (e.__releaseSource)
28
+ history.source = e.__releaseSource;
24
29
  history.comment = e.__releaseComment ?? null;
25
30
  history.assetFormat = e.__releaseFormat ?? null;
26
31
  history.kernelVersion = e.__releaseKernel ?? null;
@@ -1 +1 @@
1
- {"version":3,"file":"event-subscriber.js","sourceRoot":"","sources":["../../../server/service/figure/event-subscriber.ts"],"names":[],"mappings":";;;;AAAA,qCAAyC;AAEzC,8DAAkE;AAElE,2CAAoC;AACpC,2DAAmD;AAEnD;;;;;;;;;;;GAWG;AACH,4FAA4F;AAC5F,SAAS,iBAAiB,CAAC,OAAsB,EAAE,MAAc;IAC/D,MAAM,CAAC,GAAG,MAAa,CACtB;IAAC,OAAe,CAAC,OAAO,GAAG,CAAC,CAAC,gBAAgB,IAAI,IAAI,CAAA;IACtD,OAAO,CAAC,WAAW,GAAG,CAAC,CAAC,eAAe,IAAI,IAAI,CAAA;IAC/C,OAAO,CAAC,aAAa,GAAG,CAAC,CAAC,eAAe,IAAI,IAAI,CAAA;IACjD,sEAAsE;IACtE,OAAO,CAAC,OAAO,GAAG,CAAC,CAAC,gBAAgB,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CA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yBAAe,GAAE;GACL,6BAA6B,CA4BzC","sourcesContent":["import { EventSubscriber } from 'typeorm'\n\nimport { HistoryEntitySubscriber } from '@operato/typeorm-history'\n\nimport { Figure } from './figure.js'\nimport { FigureHistory } from './figure-history.js'\n\n/**\n * 판본을 남긴다 — **발행된 저장에만.**\n *\n * `@operato/typeorm-history` 는 원래 모든 저장을 베낀다. 그런데 도형은 저작 중에 수십 번 저장되고,\n * 그 전부를 남기면 판본 목록이 「내가 오늘 몇 번 눌렀나」가 된다. 사람이 판이라고 부르는 것은\n * **발행한 것**이므로 그때만 베낀다. board 가 같은 규칙으로 돈다(`board-service` 의 같은 이름 파일).\n *\n * 발행 메모는 Figure 의 칸이 아니다. `releaseFigure` 가 저장할 엔티티에 `__releaseComment` 로 얹어\n * 두면 여기서 판본의 `comment` 로 옮긴다 — 메모는 그 판의 것이지 도형의 것이 아니다. 정본 형식\n * (`__releaseFormat`), 잰 커널의 판(`__releaseKernel`, ADR-0109 C1), 직전 판에 견준 변경(`__releaseChanges`), 발행 때 잰 값(`__releaseMetrics`)과\n * 윗모습(`__releaseTopView`)도 같은 길로 옮긴다(ADR-0104).\n */\n/** What `releaseFigure` laid on the entity for this release, moved onto the history row. */\nfunction releaseRecordOnto(history: FigureHistory, entity: Figure): FigureHistory {\n const e = entity as any\n ;(history as any).comment = e.__releaseComment ?? null\n history.assetFormat = e.__releaseFormat ?? null\n history.kernelVersion = e.__releaseKernel ?? null\n /* [] stays \"[]\" (nothing changed); null stays null (not compared). */\n history.changes = e.__releaseChanges == null ? null : JSON.stringify(e.__releaseChanges)\n history.metrics = e.__releaseMetrics == null ? null : JSON.stringify(e.__releaseMetrics)\n history.topView = e.__releaseTopView == null ? null : JSON.stringify(e.__releaseTopView)\n return history\n}\n\n@EventSubscriber()\nexport class FigureHistoryEntitySubscriber extends HistoryEntitySubscriber<Figure, FigureHistory> {\n public get entity() {\n return Figure\n }\n\n public get historyEntity() {\n return FigureHistory\n }\n\n public beforeInsertHistory(history: FigureHistory, entity: Figure): FigureHistory {\n return releaseRecordOnto(history, entity)\n }\n\n public beforeUpdateHistory(history: FigureHistory, entity: Figure): FigureHistory {\n return releaseRecordOnto(history, entity)\n }\n\n public async afterInsert(event: any): Promise<void> {\n if (event.entity?.state == 'released') {\n await super.afterInsert(event)\n }\n }\n\n public async afterUpdate(event: any): Promise<void> {\n if (event.entity?.state == 'released') {\n await super.afterUpdate(event)\n }\n }\n}\n"]}
1
+ {"version":3,"file":"event-subscriber.js","sourceRoot":"","sources":["../../../server/service/figure/event-subscriber.ts"],"names":[],"mappings":";;;;AAAA,qCAAyC;AAEzC,8DAAkE;AAElE,2CAAoC;AACpC,2DAAmD;AAEnD;;;;;;;;;;;;;GAaG;AACH,4FAA4F;AAC5F,SAAS,iBAAiB,CAAC,OAAsB,EAAE,MAAc;IAC/D,MAAM,CAAC,GAAG,MAAa,CAAA;IACvB,+GAA+G;IAC/G,IAAI,CAAC,CAAC,eAAe;QAAE,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,eAAe,CACxD;IAAC,OAAe,CAAC,OAAO,GAAG,CAAC,CAAC,gBAAgB,IAAI,IAAI,CAAA;IACtD,OAAO,CAAC,WAAW,GAAG,CAAC,CAAC,eAAe,IAAI,IAAI,CAAA;IAC/C,OAAO,CAAC,aAAa,GAAG,CAAC,CAAC,eAAe,IAAI,IAAI,CAAA;IACjD,sEAAsE;IACtE,OAAO,CAAC,OAAO,GAAG,CAAC,CAAC,gBAAgB,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAA;IACxF,OAAO,CAAC,OAAO,GAAG,CAAC,CAAC,gBAAgB,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAA;IACxF,OAAO,CAAC,OAAO,GAAG,CAAC,CAAC,gBAAgB,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAA;IACxF,OAAO,OAAO,CAAA;AAChB,CAAC;AAGM,IAAM,6BAA6B,GAAnC,MAAM,6BAA8B,SAAQ,yCAA8C;IAC/F,IAAW,MAAM;QACf,OAAO,kBAAM,CAAA;IACf,CAAC;IAED,IAAW,aAAa;QACtB,OAAO,iCAAa,CAAA;IACtB,CAAC;IAEM,mBAAmB,CAAC,OAAsB,EAAE,MAAc;QAC/D,OAAO,iBAAiB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;IAC3C,CAAC;IAEM,mBAAmB,CAAC,OAAsB,EAAE,MAAc;QAC/D,OAAO,iBAAiB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;IAC3C,CAAC;IAEM,KAAK,CAAC,WAAW,CAAC,KAAU;QACjC,IAAI,KAAK,CAAC,MAAM,EAAE,KAAK,IAAI,UAAU,EAAE,CAAC;YACtC,MAAM,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,CAAA;QAChC,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,WAAW,CAAC,KAAU;QACjC,IAAI,KAAK,CAAC,MAAM,EAAE,KAAK,IAAI,UAAU,EAAE,CAAC;YACtC,MAAM,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,CAAA;QAChC,CAAC;IACH,CAAC;CACF,CAAA;AA5BY,sEAA6B;wCAA7B,6BAA6B;IADzC,IAAA,yBAAe,GAAE;GACL,6BAA6B,CA4BzC","sourcesContent":["import { EventSubscriber } from 'typeorm'\n\nimport { HistoryEntitySubscriber } from '@operato/typeorm-history'\n\nimport { Figure } from './figure.js'\nimport { FigureHistory } from './figure-history.js'\n\n/**\n * 판본을 남긴다 — **발행된 저장에만.**\n *\n * `@operato/typeorm-history` 는 원래 모든 저장을 베낀다. 그런데 도형은 저작 중에 수십 번 저장되고,\n * 그 전부를 남기면 판본 목록이 「내가 오늘 몇 번 눌렀나」가 된다. 사람이 판이라고 부르는 것은\n * **발행한 것**이므로 그때만 베낀다. board 가 같은 규칙으로 돈다(`board-service` 의 같은 이름 파일).\n *\n * 발행판의 정본(`__releaseSource`)은 크기 범위를 적은 발행판 사본이다 — Figure 행에는 작성자가 좁힌 끝만 남는다.\n *\n * 발행 메모는 Figure 의 칸이 아니다. `releaseFigure` 가 저장할 엔티티에 `__releaseComment` 로 얹어\n * 두면 여기서 판본의 `comment` 로 옮긴다 — 메모는 그 판의 것이지 도형의 것이 아니다. 정본 형식\n * (`__releaseFormat`), 잰 커널의 판(`__releaseKernel`, ADR-0109 C1), 직전 판에 견준 변경(`__releaseChanges`), 발행 때 잰 값(`__releaseMetrics`)과\n * 윗모습(`__releaseTopView`)도 같은 길로 옮긴다(ADR-0104).\n */\n/** What `releaseFigure` laid on the entity for this release, moved onto the history row. */\nfunction releaseRecordOnto(history: FigureHistory, entity: Figure): FigureHistory {\n const e = entity as any\n /* What a board reads of this release: its own copy, with the size range written down (ADR-0087 decision 6). */\n if (e.__releaseSource) history.source = e.__releaseSource\n ;(history as any).comment = e.__releaseComment ?? null\n history.assetFormat = e.__releaseFormat ?? null\n history.kernelVersion = e.__releaseKernel ?? null\n /* [] stays \"[]\" (nothing changed); null stays null (not compared). */\n history.changes = e.__releaseChanges == null ? null : JSON.stringify(e.__releaseChanges)\n history.metrics = e.__releaseMetrics == null ? null : JSON.stringify(e.__releaseMetrics)\n history.topView = e.__releaseTopView == null ? null : JSON.stringify(e.__releaseTopView)\n return history\n}\n\n@EventSubscriber()\nexport class FigureHistoryEntitySubscriber extends HistoryEntitySubscriber<Figure, FigureHistory> {\n public get entity() {\n return Figure\n }\n\n public get historyEntity() {\n return FigureHistory\n }\n\n public beforeInsertHistory(history: FigureHistory, entity: Figure): FigureHistory {\n return releaseRecordOnto(history, entity)\n }\n\n public beforeUpdateHistory(history: FigureHistory, entity: Figure): FigureHistory {\n return releaseRecordOnto(history, entity)\n }\n\n public async afterInsert(event: any): Promise<void> {\n if (event.entity?.state == 'released') {\n await super.afterInsert(event)\n }\n }\n\n public async afterUpdate(event: any): Promise<void> {\n if (event.entity?.state == 'released') {\n await super.afterUpdate(event)\n }\n }\n}\n"]}
@@ -240,7 +240,6 @@ function figureViewOf(asset, request = {}) {
240
240
  */
241
241
  const SUBJECT = {
242
242
  'add-part': () => undefined,
243
- 'fit-room': () => undefined,
244
243
  'set-section-corner': step => step.part,
245
244
  'set-cavity': step => step.part,
246
245
  'set-section': step => step.part,
@@ -267,7 +266,6 @@ const SUBJECT = {
267
266
  'duplicate-part': step => step.target,
268
267
  'move-part': step => step.target,
269
268
  'set-placement': () => undefined,
270
- 'declare-occupancy': () => undefined,
271
269
  'declare-instance-size': () => undefined,
272
270
  'clear-mounting-face': () => undefined,
273
271
  'scale-uniformly': () => undefined,
@@ -1 +1 @@
1
- {"version":3,"file":"figure-context.js","sourceRoot":"","sources":["../../../server/service/figure/figure-context.ts"],"names":[],"mappings":";;;AAyHA,4CAWC;AAwED,0CAuCC;AAQD,oCA2DC;AA8ED,0CAiBC;AAoBD,gDA4BC;AAtbD,oHAAoH;AACvG,QAAA,qBAAqB,GAAG,OAAO,CAAA;AAE5C,kHAAkH;AAClH,MAAM,aAAa,GAAG,6BAAqB,GAAG,CAAC,CAAA;AAE/C,qGAAqG;AACrG,MAAM,aAAa,GAAG,EAAE,CAAA;AAiExB,MAAM,MAAM,GAAG,CAAC,KAAc,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,MAAM,IAAI,CAAC,CAAA;AACrE,MAAM,KAAK,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,CAAC,EAAW,EAAE,EAAE,CAAC,EAAE,KAAK,IAAI,IAAI,CAAC,OAAO,EAAE,KAAK,QAAQ,IAAI,EAAE,CAAC,UAAU,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,CAAA;AAErH,4FAA4F;AAE5F,MAAM,WAAW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CAAE,CAAA;QACzC,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,KAAK,CAAC,CAAA;IACnF,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC","sourcesContent":["/**\n * What of a figure the model is shown (ADR-0061 2026-10-16 decision 4).\n *\n * The kernel keeps a figure up to 1 MiB (`FIGURE_JSON_MAX_BYTES`); that is whether the figure is valid. How much of it the\n * model reads at once is another question with its own number. A figure that fits is shown whole. One that does not is\n * shown as an outline -- its sections, and every part by name, shape and what it is fastened to -- and in full only the\n * parts and sections asked for, while they fit. A section too large for the outline is left out, named by its JSON\n * Pointer with the entries inside it, and read by pointer. The full source stays on the server: a proposal is applied\n * and judged on it, on the version the request was made on.\n *\n * A proposal on a figure shown in part changes only what it was shown: no part not read in full, and nothing inside a\n * section left out and not read. Read is what the server put before the writer, never what a model says it read.\n */\nimport type { FigureAsset, FigureProposalStep } from '@hatiolab/figure-model'\n\n/** The most of a figure, serialized, the model is shown in one read. Not a validity limit: that is the kernel's. */\nexport const FIGURE_CONTEXT_BUDGET = 100_000\n\n/** Of the budget, what the outline's sections may take; the rest is for the parts and sections read beside it. */\nconst OUTLINE_SHARE = FIGURE_CONTEXT_BUDGET / 2\n\n/** How many entries of a section left out, or pointers in a reason, are named: the largest first. */\nconst ENTRIES_NAMED = 20\n\ntype Dynamic = any\n\nexport interface FigureOutlinePart {\n id: string\n /** The operation that makes its shape (`box@1`, `extrude@1`, ...). */\n shape?: string\n /** What it is fastened to: `<part>.<face>`, `mounting-plane`, or nothing when unfastened. */\n on?: string\n joint?: { id: string; type: string }\n material?: string\n /** How long its part read is: what reading it costs. */\n chars: number\n}\n\nexport interface FigureOmittedSection {\n /** The JSON Pointer of the section left out. */\n section: string\n chars: number\n /** Its largest entries, by pointer: what to read when the whole does not fit. */\n entries?: { section: string; chars: number }[]\n}\n\nexport interface FigureOutline {\n /** The whole source's length, and the budget it does not fit. */\n chars: number\n budget: number\n parts: FigureOutlinePart[]\n /** Parts the outline had no room to list, past the ones listed. */\n partsNotListed?: number\n /** Sections left out because they would crowd the outline. */\n omitted?: FigureOmittedSection[]\n [section: string]: unknown\n}\n\nexport interface FigurePartRead {\n appearance: Dynamic\n /** The fastenings that name it: its own (body1) and its children's (body0). */\n joints: Dynamic[]\n /** The graph nodes and constants under its name: `<part>` and `<part>.*` (a part id has no dot). */\n nodes: Dynamic[]\n constants: Dynamic[]\n}\n\nexport interface FigureReadRequest {\n parts?: readonly string[]\n /** JSON Pointers (RFC 6901) into the source, such as `/document/capabilities/bindings/0`. */\n sections?: readonly string[]\n}\n\nexport interface FigureView {\n whole: boolean\n /** Whole: the source as it is. */\n source?: FigureAsset\n outline?: FigureOutline\n /** The parts shown in full, by id, in the order asked. */\n parts?: Record<string, FigurePartRead>\n shown?: string[]\n /** The sections read, by pointer. */\n sections?: Record<string, unknown>\n /** What was asked for and not shown, with why and what to read instead. */\n notRead?: ({ part: string; reason: string } | { section: string; reason: string })[]\n}\n\nconst length = (value: unknown) => JSON.stringify(value)?.length ?? 0\nconst under = (part: string) => (id: unknown) => id === part || (typeof id === 'string' && id.startsWith(`${part}.`))\n\n/* ── JSON Pointer (RFC 6901) ─────────────────────────────────────────────────────────── */\n\nconst escapeToken = (token: string) => token.replace(/~/g, '~0').replace(/\\//g, '~1')\nconst pointerOf = (tokens: readonly (string | number)[]) => tokens.map(t => `/${escapeToken(String(t))}`).join('')\nfunction tokensOf(pointer: string): string[] | undefined {\n if (typeof pointer !== 'string' || !pointer.startsWith('/')) return undefined\n return pointer.slice(1).split('/').map(t => t.replace(/~1/g, '/').replace(/~0/g, '~'))\n}\nfunction valueAt(root: unknown, tokens: readonly string[]): { found: boolean; value?: unknown } {\n let at: Dynamic = root\n for (const token of tokens) {\n if (at === null || typeof at !== 'object' || !Object.prototype.hasOwnProperty.call(at, token)) return { found: false }\n at = at[token]\n }\n return { found: true, value: at }\n}\n/** `inner` is `outer` or inside it. */\nconst within = (inner: string, outer: string) => inner === outer || inner.startsWith(`${outer}/`)\n\n/** A value's entries by pointer, largest first, the first ENTRIES_NAMED of them. */\nfunction entriesOf(pointer: string, value: unknown): { section: string; chars: number }[] {\n if (value === null || typeof value !== 'object') return []\n const tokens = tokensOf(pointer)!\n return Object.entries(value as object)\n .map(([key, entry]) => ({ section: pointerOf([...tokens, key]), chars: length(entry) }))\n .sort((a, b) => b.chars - a.chars)\n .slice(0, ENTRIES_NAMED)\n}\n\n/* ── Parts ───────────────────────────────────────────────────────────────────────────── */\n\nexport function figurePartReadOf(asset: FigureAsset, part: string): FigurePartRead | undefined {\n const appearance = asset.appearance.find(a => a.target === part)\n if (!appearance) return undefined\n const model = asset.document.model as Dynamic\n const own = under(part)\n return {\n appearance,\n joints: ((asset as Dynamic).joints ?? []).filter((j: Dynamic) => j?.body1?.part === part || j?.body0?.part === part),\n nodes: model.nodes.filter((n: Dynamic) => own(n.id)),\n constants: model.constants.filter((c: Dynamic) => own(c.id))\n }\n}\n\n/** Where a part's records are, by pointer: for a part too large to read as one. */\nfunction partPointers(asset: FigureAsset, part: string): string[] {\n const model = asset.document.model as Dynamic\n const own = under(part)\n return [\n ...asset.appearance.flatMap((a, i) => (a.target === part ? [pointerOf(['appearance', i])] : [])),\n ...((asset as Dynamic).joints ?? []).flatMap((j: Dynamic, i: number) => (j?.body1?.part === part || j?.body0?.part === part ? [pointerOf(['joints', i])] : [])),\n ...model.nodes.flatMap((n: Dynamic, i: number) => (own(n.id) ? [pointerOf(['document', 'model', 'nodes', i])] : [])),\n ...model.constants.flatMap((c: Dynamic, i: number) => (own(c.id) ? [pointerOf(['document', 'model', 'constants', i])] : []))\n ]\n}\n\n/* ── The outline ─────────────────────────────────────────────────────────────────────── */\n\n/*\n The sections of an outline: every top-level field but the parts' records, the document's fields but its model, and the\n model's fields but its graph. Each may be left out by its pointer.\n*/\nconst PART_RECORDS = ['/document', '/appearance', '/joints', '/document/model', '/document/model/nodes', '/document/model/constants']\nfunction sectionsOf(asset: FigureAsset): string[] {\n const out: string[] = []\n const walk = (tokens: string[]) => {\n const { value } = valueAt(asset, tokens)\n for (const key of Object.keys(value as object)) {\n const pointer = pointerOf([...tokens, key])\n if (pointer === '/document' || pointer === '/document/model') walk([...tokens, key])\n else if (!PART_RECORDS.includes(pointer)) out.push(pointer)\n }\n }\n walk([])\n return out\n}\n\nfunction outlinePartsOf(asset: FigureAsset): FigureOutlinePart[] {\n const nodes = (asset.document.model as Dynamic).nodes\n const joints = (asset as Dynamic).joints ?? []\n return asset.appearance.map((look: Dynamic) => {\n const id = look.target\n const joint = joints.find((j: Dynamic) => j?.body1?.part === id)\n const body0 = joint?.body0\n const on = !joint ? undefined : body0?.part ? `${body0.part}.${body0.face}` : (body0?.plane ?? 'mounting-plane')\n const shape = nodes.find((n: Dynamic) => n.id === `${id}.shape`)?.op\n return {\n id,\n ...(shape ? { shape } : {}),\n ...(on ? { on } : {}),\n ...(joint ? { joint: { id: joint.id, type: joint.type } } : {}),\n ...(look.material?.token ? { material: look.material.token } : {}),\n chars: length(figurePartReadOf(asset, id))\n }\n })\n}\n\n/** Writes a section into the outline at its pointer, making the objects on the way. */\nfunction place(outline: Dynamic, tokens: readonly string[], value: unknown) {\n let at = outline\n tokens.slice(0, -1).forEach(token => (at = at[token] ??= {}))\n at[tokens[tokens.length - 1]!] = value\n}\n\n/**\n * What the view wraps the outline in, read or not: an outline that took the whole budget left the view over it by these\n * (53 characters, a figure of 3000 long-named parts, 2026-10-19).\n */\nconst VIEW_ENVELOPE = () => length({ whole: false, outline: {}, parts: {}, shown: [], sections: {}, notRead: [] }) - length({})\n\n/**\n * The outline: within OUTLINE_SHARE for its sections, the largest left out first; and, every field counted, within the\n * budget less what the view wraps it in -- a figure of very many parts lists them by id only, then as many as fit.\n */\nexport function figureOutlineOf(asset: FigureAsset, chars = length(asset)): FigureOutline {\n const limit = FIGURE_CONTEXT_BUDGET - VIEW_ENVELOPE()\n const model = asset.document.model as Dynamic\n const sections = sectionsOf(asset).map(pointer => ({ pointer, value: valueAt(asset, tokensOf(pointer)!).value }))\n const sized = sections.map(s => ({ ...s, chars: length(s.value) })).sort((a, b) => b.chars - a.chars)\n\n let total = sized.reduce((sum, s) => sum + s.chars, 0)\n const omitted: FigureOmittedSection[] = []\n const kept = new Set(sized.map(s => s.pointer))\n for (const s of sized) {\n if (total <= OUTLINE_SHARE) break\n kept.delete(s.pointer)\n total -= s.chars\n const entries = entriesOf(s.pointer, s.value)\n omitted.push({ section: s.pointer, chars: s.chars, ...(entries.length ? { entries } : {}) })\n }\n\n const outline: Dynamic = { chars, budget: FIGURE_CONTEXT_BUDGET }\n place(outline, ['document', 'model', 'nodes'], model.nodes.length)\n place(outline, ['document', 'model', 'constants'], model.constants.length)\n for (const s of sections) if (kept.has(s.pointer)) place(outline, tokensOf(s.pointer)!, s.value)\n if (omitted.length) outline.omitted = omitted\n\n let parts: Dynamic[] = outlinePartsOf(asset)\n outline.parts = parts\n if (length(outline) > limit) outline.parts = parts = parts.map(p => ({ id: p.id }))\n if (length(outline) > limit) {\n /* As many as fit, in part order, with how many more there are. */\n let room = limit - length({ ...outline, parts: [], partsNotListed: parts.length })\n const listed: Dynamic[] = []\n for (const p of parts) {\n room -= length(p) + 1\n if (room < 0) break\n listed.push(p)\n }\n outline.parts = listed\n outline.partsNotListed = parts.length - listed.length\n }\n return outline as FigureOutline\n}\n\n/* ── The view ────────────────────────────────────────────────────────────────────────── */\n\n/**\n * The view of a figure the model is shown: whole when it fits, else the outline and what was asked for -- parts, then\n * sections, each in the order asked -- while it fits beside it. Every field counted, the view is within the budget.\n */\nexport function figureViewOf(asset: FigureAsset, request: FigureReadRequest = {}): FigureView {\n const chars = length(asset)\n if (chars <= FIGURE_CONTEXT_BUDGET) return { whole: true, source: asset }\n\n const outline = figureOutlineOf(asset, chars)\n const view: FigureView = { whole: false, outline, parts: {}, shown: [], sections: {}, notRead: [] }\n const room = () => FIGURE_CONTEXT_BUDGET - length(view)\n const refuse = (one: { part: string; reason: string } | { section: string; reason: string }) => {\n if (length(one) + 1 <= room()) view.notRead!.push(one)\n }\n\n for (const part of [...new Set(request.parts ?? [])]) {\n const one = figurePartReadOf(asset, part)\n if (!one) {\n refuse({ part, reason: `${part} is not a part of this figure; the outline lists its parts` })\n continue\n }\n const cost = length(one) + length(part) + length(part) + 3\n view.parts![part] = one\n view.shown!.push(part)\n if (room() >= 0) continue\n delete view.parts![part]\n view.shown!.pop()\n if (cost <= FIGURE_CONTEXT_BUDGET - length(outline)) {\n refuse({ part, reason: `${part} (${cost} characters) does not fit beside what is already read; read it in another call with fewer parts or sections` })\n } else {\n const pointers = partPointers(asset, part)\n refuse({\n part,\n reason:\n `${part} (${cost} characters) is too large to show beside the outline; read its records as sections: ` +\n `${pointers.slice(0, ENTRIES_NAMED).join(', ')}${pointers.length > ENTRIES_NAMED ? ` and ${pointers.length - ENTRIES_NAMED} more` : ''}. ` +\n 'Parts read as sections are not counted as read in full: they cannot be changed'\n })\n }\n }\n\n for (const section of [...new Set(request.sections ?? [])]) {\n const tokens = tokensOf(section)\n const at = tokens && tokens.length ? valueAt(asset, tokens) : { found: false }\n if (!at.found) {\n refuse({ section, reason: `there is no section ${section}; a section is a JSON Pointer such as /document/capabilities/bindings/0` })\n continue\n }\n const cost = length(at.value) + length(section) + 2\n view.sections![section] = at.value\n if (room() >= 0) continue\n delete view.sections![section]\n const entries = entriesOf(section, at.value)\n refuse({\n section,\n reason: entries.length\n ? `${section} (${cost} characters) is too large to show at once here; read its entries: ${entries.map(e => `${e.section} (${e.chars})`).join(', ')}`\n : `${section} is one value of ${length(at.value)} characters, larger than can be shown here; it cannot be read or changed by a proposal`\n })\n }\n\n if (!view.notRead!.length) delete view.notRead\n return view\n}\n\n/* ── What a proposal may change ──────────────────────────────────────────────────────── */\n\ntype StepOf<K extends FigureProposalStep['kind']> = Extract<FigureProposalStep, { kind: K }>\ntype Subject = string | undefined\n\n/**\n * The part each kind of step changes, read from the field the kernel reads for that kind (audit D4-R1: a `part` beside a\n * `set-material`'s `target` is not read by the kernel, so it may not stand in for it). Every kind of the kernel's step\n * type is here, or this does not compile. A step that changes no one part says so with undefined: what it does to the\n * figure's sections is held by `unreadSectionEdits`.\n */\nconst SUBJECT: { [K in FigureProposalStep['kind']]: (step: StepOf<K>, base: FigureAsset) => Subject } = {\n 'add-part': () => undefined,\n 'fit-room': () => undefined,\n 'set-section-corner': step => step.part,\n 'set-cavity': step => step.part,\n 'set-section': step => step.part,\n attach: step => step.part,\n 'link-dimension': step => step.part,\n 'follow-size': step => step.part,\n 'unlink-dimension': step => step.part,\n 'scale-position': step => step.part,\n 'fix-position': step => step.part,\n 'nudge-part': step => step.part,\n detach: step => step.part,\n 'make-repeat': step => step.part,\n 'set-repeat': step => step.part,\n 'remove-repeat': step => step.part,\n 'set-mounting-face': step => step.part,\n 'add-binding': step => step.part,\n 'set-joint': step => step.joint?.body1?.part,\n 'remove-joint': (step, base) => ((base as Dynamic).joints ?? []).find((j: Dynamic) => j?.id === step.id)?.body1?.part,\n 'set-material': step => step.target,\n 'set-segments': step => step.target,\n 'rename-part': step => step.target,\n 'set-visibility': step => step.target,\n 'remove-part': step => step.target,\n 'duplicate-part': step => step.target,\n 'move-part': step => step.target,\n 'set-placement': () => undefined,\n 'declare-occupancy': () => undefined,\n 'declare-instance-size': () => undefined,\n 'clear-mounting-face': () => undefined,\n 'scale-uniformly': () => undefined,\n 'follow-size-in-proportion': () => undefined,\n 'set-detail-level': () => undefined,\n 'add-design-input': () => undefined,\n 'set-input-range': () => undefined,\n 'publish-input': () => undefined,\n 'unpublish-input': () => undefined,\n 'remove-binding': () => undefined,\n 'set-slot-layout': () => undefined,\n 'remove-slot-layout': () => undefined,\n 'set-extension': () => undefined,\n rename: () => undefined,\n 'set-capabilities': () => undefined,\n 'set-state-input': () => undefined,\n 'set-state-defaults': () => undefined,\n 'set-driver': () => undefined,\n 'remove-driver': () => undefined,\n 'set-clip': () => undefined,\n 'set-motion-group': () => undefined,\n 'remove-motion-group': () => undefined,\n 'set-data-schema': () => undefined,\n 'rename-data-field': () => undefined,\n 'set-data-binding': () => undefined,\n 'remove-data-binding': () => undefined,\n 'set-status-port': () => undefined,\n 'remove-status-port': () => undefined\n}\n\n/**\n * The steps that change a part of the base not shown in full, as reasons said back to the writer. A part may still be\n * named to fasten to or to follow -- the kernel works from it, nothing about it is guessed -- and a new part is the\n * steps' own. A kind this table does not know is refused: it is not let through unjudged.\n */\nexport function unreadPartEdits(base: FigureAsset, steps: readonly FigureProposalStep[], view: FigureView): string[] {\n const existing = new Set(base.appearance.map(a => a.target))\n const shown = new Set(view.shown ?? [])\n const allowed = [...shown].join(', ') || 'none'\n return steps.flatMap((step, i) => {\n const kind = (step as Dynamic)?.kind\n if (typeof kind !== 'string') return []\n const judge = (SUBJECT as Record<string, (step: Dynamic, base: FigureAsset) => Subject>)[kind]\n if (!Object.prototype.hasOwnProperty.call(SUBJECT, kind) || !judge)\n return [`UNKNOWN_STEP: steps[${i}] has the kind \"${kind}\", which is not one of the commands; use only the commands taught.`]\n const part = judge(step, base)\n if (typeof part !== 'string' || !existing.has(part) || shown.has(part)) return []\n return [\n `UNREAD_PART: steps[${i}] (${kind}) changes \"${part}\", which was not shown in full, so its source is not known here. ` +\n `Change only the parts shown in full (${allowed}) or parts the steps add. To change ${part}, read it with getFigureSource parts and pass it in parts to proposeFigureCandidate.`\n ]\n })\n}\n\n/** Entries of a value, keyed by `id` when every entry of a list has a distinct one, else by place. */\nfunction keyedEntries(value: unknown): Map<string, { token: string; value: unknown }> {\n const out = new Map<string, { token: string; value: unknown }>()\n if (Array.isArray(value)) {\n const ids = value.map(v => (v && typeof v === 'object' && typeof (v as Dynamic).id === 'string' ? (v as Dynamic).id : undefined))\n const byId = ids.every(Boolean) && new Set(ids).size === ids.length\n value.forEach((v, i) => out.set(byId ? `id:${ids[i]}` : `at:${i}`, { token: String(i), value: v }))\n } else if (value && typeof value === 'object') {\n for (const [key, v] of Object.entries(value)) out.set(`key:${key}`, { token: key, value: v })\n }\n return out\n}\n\n/**\n * What of the sections left out of the outline and not read the steps changed, as reasons said back to the writer. Judged\n * on what the steps made, not on what they say: nothing that was there may be changed or taken away. A new entry -- a\n * record in a list, a key in a map -- is the steps' own.\n */\nexport function unreadSectionEdits(base: FigureAsset, after: FigureAsset, view: FigureView): string[] {\n const read = Object.keys(view.sections ?? {})\n const reasons: string[] = []\n const say = (pointer: string, what: string) =>\n reasons.push(\n `UNREAD_SECTION: the steps ${what} ${pointer}, which was left out of the outline and not read, so it is not known here. ` +\n `Leave it as it is; to change it, read it with getFigureSource sections and pass it in sections to proposeFigureCandidate.`\n )\n const check = (pointer: string, before: unknown, now: unknown) => {\n if (reasons.length >= ENTRIES_NAMED || read.some(r => within(pointer, r))) return\n const records = (v: unknown) => v !== null && typeof v === 'object'\n if (!records(before) || !records(now) || Array.isArray(before) !== Array.isArray(now)) {\n if (JSON.stringify(before) !== JSON.stringify(now)) say(pointer, 'change')\n return\n }\n const later = keyedEntries(now)\n for (const [key, entry] of keyedEntries(before)) {\n const child = `${pointer}/${escapeToken(entry.token)}`\n const kept = later.get(key)\n if (kept) check(child, entry.value, kept.value)\n else if (!read.some(r => within(child, r))) say(child, 'remove')\n }\n }\n for (const omitted of view.outline?.omitted ?? []) {\n const tokens = tokensOf(omitted.section)!\n check(omitted.section, valueAt(base, tokens).value, valueAt(after, tokens).value)\n }\n return reasons\n}\n"]}
1
+ {"version":3,"file":"figure-context.js","sourceRoot":"","sources":["../../../server/service/figure/figure-context.ts"],"names":[],"mappings":";;;AAyHA,4CAWC;AAwED,0CAuCC;AAQD,oCA2DC;AA4ED,0CAiBC;AAoBD,gDA4BC;AApbD,oHAAoH;AACvG,QAAA,qBAAqB,GAAG,OAAO,CAAA;AAE5C,kHAAkH;AAClH,MAAM,aAAa,GAAG,6BAAqB,GAAG,CAAC,CAAA;AAE/C,qGAAqG;AACrG,MAAM,aAAa,GAAG,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CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;gBAAE,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAA;QAClE,CAAC;IACH,CAAC,CAAA;IACD,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,OAAO,EAAE,OAAO,IAAI,EAAE,EAAE,CAAC;QAClD,MAAM,MAAM,GAAG,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAE,CAAA;QACzC,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,KAAK,CAAC,CAAA;IACnF,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC","sourcesContent":["/**\n * What of a figure the model is shown (ADR-0061 2026-10-16 decision 4).\n *\n * The kernel keeps a figure up to 1 MiB (`FIGURE_JSON_MAX_BYTES`); that is whether the figure is valid. How much of it the\n * model reads at once is another question with its own number. A figure that fits is shown whole. One that does not is\n * shown as an outline -- its sections, and every part by name, shape and what it is fastened to -- and in full only the\n * parts and sections asked for, while they fit. A section too large for the outline is left out, named by its JSON\n * Pointer with the entries inside it, and read by pointer. The full source stays on the server: a proposal is applied\n * and judged on it, on the version the request was made on.\n *\n * A proposal on a figure shown in part changes only what it was shown: no part not read in full, and nothing inside a\n * section left out and not read. Read is what the server put before the writer, never what a model says it read.\n */\nimport type { FigureAsset, FigureProposalStep } from '@hatiolab/figure-model'\n\n/** The most of a figure, serialized, the model is shown in one read. Not a validity limit: that is the kernel's. */\nexport const FIGURE_CONTEXT_BUDGET = 100_000\n\n/** Of the budget, what the outline's sections may take; the rest is for the parts and sections read beside it. */\nconst OUTLINE_SHARE = FIGURE_CONTEXT_BUDGET / 2\n\n/** How many entries of a section left out, or pointers in a reason, are named: the largest first. */\nconst ENTRIES_NAMED = 20\n\ntype Dynamic = any\n\nexport interface FigureOutlinePart {\n id: string\n /** The operation that makes its shape (`box@1`, `extrude@1`, ...). */\n shape?: string\n /** What it is fastened to: `<part>.<face>`, `mounting-plane`, or nothing when unfastened. */\n on?: string\n joint?: { id: string; type: string }\n material?: string\n /** How long its part read is: what reading it costs. */\n chars: number\n}\n\nexport interface FigureOmittedSection {\n /** The JSON Pointer of the section left out. */\n section: string\n chars: number\n /** Its largest entries, by pointer: what to read when the whole does not fit. */\n entries?: { section: string; chars: number }[]\n}\n\nexport interface FigureOutline {\n /** The whole source's length, and the budget it does not fit. */\n chars: number\n budget: number\n parts: FigureOutlinePart[]\n /** Parts the outline had no room to list, past the ones listed. */\n partsNotListed?: number\n /** Sections left out because they would crowd the outline. */\n omitted?: FigureOmittedSection[]\n [section: string]: unknown\n}\n\nexport interface FigurePartRead {\n appearance: Dynamic\n /** The fastenings that name it: its own (body1) and its children's (body0). */\n joints: Dynamic[]\n /** The graph nodes and constants under its name: `<part>` and `<part>.*` (a part id has no dot). */\n nodes: Dynamic[]\n constants: Dynamic[]\n}\n\nexport interface FigureReadRequest {\n parts?: readonly string[]\n /** JSON Pointers (RFC 6901) into the source, such as `/document/capabilities/bindings/0`. */\n sections?: readonly string[]\n}\n\nexport interface FigureView {\n whole: boolean\n /** Whole: the source as it is. */\n source?: FigureAsset\n outline?: FigureOutline\n /** The parts shown in full, by id, in the order asked. */\n parts?: Record<string, FigurePartRead>\n shown?: string[]\n /** The sections read, by pointer. */\n sections?: Record<string, unknown>\n /** What was asked for and not shown, with why and what to read instead. */\n notRead?: ({ part: string; reason: string } | { section: string; reason: string })[]\n}\n\nconst length = (value: unknown) => JSON.stringify(value)?.length ?? 0\nconst under = (part: string) => (id: unknown) => id === part || (typeof id === 'string' && id.startsWith(`${part}.`))\n\n/* ── JSON Pointer (RFC 6901) ─────────────────────────────────────────────────────────── */\n\nconst escapeToken = (token: string) => token.replace(/~/g, '~0').replace(/\\//g, '~1')\nconst pointerOf = (tokens: readonly (string | number)[]) => tokens.map(t => `/${escapeToken(String(t))}`).join('')\nfunction tokensOf(pointer: string): string[] | undefined {\n if (typeof pointer !== 'string' || !pointer.startsWith('/')) return undefined\n return pointer.slice(1).split('/').map(t => t.replace(/~1/g, '/').replace(/~0/g, '~'))\n}\nfunction valueAt(root: unknown, tokens: readonly string[]): { found: boolean; value?: unknown } {\n let at: Dynamic = root\n for (const token of tokens) {\n if (at === null || typeof at !== 'object' || !Object.prototype.hasOwnProperty.call(at, token)) return { found: false }\n at = at[token]\n }\n return { found: true, value: at }\n}\n/** `inner` is `outer` or inside it. */\nconst within = (inner: string, outer: string) => inner === outer || inner.startsWith(`${outer}/`)\n\n/** A value's entries by pointer, largest first, the first ENTRIES_NAMED of them. */\nfunction entriesOf(pointer: string, value: unknown): { section: string; chars: number }[] {\n if (value === null || typeof value !== 'object') return []\n const tokens = tokensOf(pointer)!\n return Object.entries(value as object)\n .map(([key, entry]) => ({ section: pointerOf([...tokens, key]), chars: length(entry) }))\n .sort((a, b) => b.chars - a.chars)\n .slice(0, ENTRIES_NAMED)\n}\n\n/* ── Parts ───────────────────────────────────────────────────────────────────────────── */\n\nexport function figurePartReadOf(asset: FigureAsset, part: string): FigurePartRead | undefined {\n const appearance = asset.appearance.find(a => a.target === part)\n if (!appearance) return undefined\n const model = asset.document.model as Dynamic\n const own = under(part)\n return {\n appearance,\n joints: ((asset as Dynamic).joints ?? []).filter((j: Dynamic) => j?.body1?.part === part || j?.body0?.part === part),\n nodes: model.nodes.filter((n: Dynamic) => own(n.id)),\n constants: model.constants.filter((c: Dynamic) => own(c.id))\n }\n}\n\n/** Where a part's records are, by pointer: for a part too large to read as one. */\nfunction partPointers(asset: FigureAsset, part: string): string[] {\n const model = asset.document.model as Dynamic\n const own = under(part)\n return [\n ...asset.appearance.flatMap((a, i) => (a.target === part ? [pointerOf(['appearance', i])] : [])),\n ...((asset as Dynamic).joints ?? []).flatMap((j: Dynamic, i: number) => (j?.body1?.part === part || j?.body0?.part === part ? [pointerOf(['joints', i])] : [])),\n ...model.nodes.flatMap((n: Dynamic, i: number) => (own(n.id) ? [pointerOf(['document', 'model', 'nodes', i])] : [])),\n ...model.constants.flatMap((c: Dynamic, i: number) => (own(c.id) ? [pointerOf(['document', 'model', 'constants', i])] : []))\n ]\n}\n\n/* ── The outline ─────────────────────────────────────────────────────────────────────── */\n\n/*\n The sections of an outline: every top-level field but the parts' records, the document's fields but its model, and the\n model's fields but its graph. Each may be left out by its pointer.\n*/\nconst PART_RECORDS = ['/document', '/appearance', '/joints', '/document/model', '/document/model/nodes', '/document/model/constants']\nfunction sectionsOf(asset: FigureAsset): string[] {\n const out: string[] = []\n const walk = (tokens: string[]) => {\n const { value } = valueAt(asset, tokens)\n for (const key of Object.keys(value as object)) {\n const pointer = pointerOf([...tokens, key])\n if (pointer === '/document' || pointer === '/document/model') walk([...tokens, key])\n else if (!PART_RECORDS.includes(pointer)) out.push(pointer)\n }\n }\n walk([])\n return out\n}\n\nfunction outlinePartsOf(asset: FigureAsset): FigureOutlinePart[] {\n const nodes = (asset.document.model as Dynamic).nodes\n const joints = (asset as Dynamic).joints ?? []\n return asset.appearance.map((look: Dynamic) => {\n const id = look.target\n const joint = joints.find((j: Dynamic) => j?.body1?.part === id)\n const body0 = joint?.body0\n const on = !joint ? undefined : body0?.part ? `${body0.part}.${body0.face}` : (body0?.plane ?? 'mounting-plane')\n const shape = nodes.find((n: Dynamic) => n.id === `${id}.shape`)?.op\n return {\n id,\n ...(shape ? { shape } : {}),\n ...(on ? { on } : {}),\n ...(joint ? { joint: { id: joint.id, type: joint.type } } : {}),\n ...(look.material?.token ? { material: look.material.token } : {}),\n chars: length(figurePartReadOf(asset, id))\n }\n })\n}\n\n/** Writes a section into the outline at its pointer, making the objects on the way. */\nfunction place(outline: Dynamic, tokens: readonly string[], value: unknown) {\n let at = outline\n tokens.slice(0, -1).forEach(token => (at = at[token] ??= {}))\n at[tokens[tokens.length - 1]!] = value\n}\n\n/**\n * What the view wraps the outline in, read or not: an outline that took the whole budget left the view over it by these\n * (53 characters, a figure of 3000 long-named parts, 2026-10-19).\n */\nconst VIEW_ENVELOPE = () => length({ whole: false, outline: {}, parts: {}, shown: [], sections: {}, notRead: [] }) - length({})\n\n/**\n * The outline: within OUTLINE_SHARE for its sections, the largest left out first; and, every field counted, within the\n * budget less what the view wraps it in -- a figure of very many parts lists them by id only, then as many as fit.\n */\nexport function figureOutlineOf(asset: FigureAsset, chars = length(asset)): FigureOutline {\n const limit = FIGURE_CONTEXT_BUDGET - VIEW_ENVELOPE()\n const model = asset.document.model as Dynamic\n const sections = sectionsOf(asset).map(pointer => ({ pointer, value: valueAt(asset, tokensOf(pointer)!).value }))\n const sized = sections.map(s => ({ ...s, chars: length(s.value) })).sort((a, b) => b.chars - a.chars)\n\n let total = sized.reduce((sum, s) => sum + s.chars, 0)\n const omitted: FigureOmittedSection[] = []\n const kept = new Set(sized.map(s => s.pointer))\n for (const s of sized) {\n if (total <= OUTLINE_SHARE) break\n kept.delete(s.pointer)\n total -= s.chars\n const entries = entriesOf(s.pointer, s.value)\n omitted.push({ section: s.pointer, chars: s.chars, ...(entries.length ? { entries } : {}) })\n }\n\n const outline: Dynamic = { chars, budget: FIGURE_CONTEXT_BUDGET }\n place(outline, ['document', 'model', 'nodes'], model.nodes.length)\n place(outline, ['document', 'model', 'constants'], model.constants.length)\n for (const s of sections) if (kept.has(s.pointer)) place(outline, tokensOf(s.pointer)!, s.value)\n if (omitted.length) outline.omitted = omitted\n\n let parts: Dynamic[] = outlinePartsOf(asset)\n outline.parts = parts\n if (length(outline) > limit) outline.parts = parts = parts.map(p => ({ id: p.id }))\n if (length(outline) > limit) {\n /* As many as fit, in part order, with how many more there are. */\n let room = limit - length({ ...outline, parts: [], partsNotListed: parts.length })\n const listed: Dynamic[] = []\n for (const p of parts) {\n room -= length(p) + 1\n if (room < 0) break\n listed.push(p)\n }\n outline.parts = listed\n outline.partsNotListed = parts.length - listed.length\n }\n return outline as FigureOutline\n}\n\n/* ── The view ────────────────────────────────────────────────────────────────────────── */\n\n/**\n * The view of a figure the model is shown: whole when it fits, else the outline and what was asked for -- parts, then\n * sections, each in the order asked -- while it fits beside it. Every field counted, the view is within the budget.\n */\nexport function figureViewOf(asset: FigureAsset, request: FigureReadRequest = {}): FigureView {\n const chars = length(asset)\n if (chars <= FIGURE_CONTEXT_BUDGET) return { whole: true, source: asset }\n\n const outline = figureOutlineOf(asset, chars)\n const view: FigureView = { whole: false, outline, parts: {}, shown: [], sections: {}, notRead: [] }\n const room = () => FIGURE_CONTEXT_BUDGET - length(view)\n const refuse = (one: { part: string; reason: string } | { section: string; reason: string }) => {\n if (length(one) + 1 <= room()) view.notRead!.push(one)\n }\n\n for (const part of [...new Set(request.parts ?? [])]) {\n const one = figurePartReadOf(asset, part)\n if (!one) {\n refuse({ part, reason: `${part} is not a part of this figure; the outline lists its parts` })\n continue\n }\n const cost = length(one) + length(part) + length(part) + 3\n view.parts![part] = one\n view.shown!.push(part)\n if (room() >= 0) continue\n delete view.parts![part]\n view.shown!.pop()\n if (cost <= FIGURE_CONTEXT_BUDGET - length(outline)) {\n refuse({ part, reason: `${part} (${cost} characters) does not fit beside what is already read; read it in another call with fewer parts or sections` })\n } else {\n const pointers = partPointers(asset, part)\n refuse({\n part,\n reason:\n `${part} (${cost} characters) is too large to show beside the outline; read its records as sections: ` +\n `${pointers.slice(0, ENTRIES_NAMED).join(', ')}${pointers.length > ENTRIES_NAMED ? ` and ${pointers.length - ENTRIES_NAMED} more` : ''}. ` +\n 'Parts read as sections are not counted as read in full: they cannot be changed'\n })\n }\n }\n\n for (const section of [...new Set(request.sections ?? [])]) {\n const tokens = tokensOf(section)\n const at = tokens && tokens.length ? valueAt(asset, tokens) : { found: false }\n if (!at.found) {\n refuse({ section, reason: `there is no section ${section}; a section is a JSON Pointer such as /document/capabilities/bindings/0` })\n continue\n }\n const cost = length(at.value) + length(section) + 2\n view.sections![section] = at.value\n if (room() >= 0) continue\n delete view.sections![section]\n const entries = entriesOf(section, at.value)\n refuse({\n section,\n reason: entries.length\n ? `${section} (${cost} characters) is too large to show at once here; read its entries: ${entries.map(e => `${e.section} (${e.chars})`).join(', ')}`\n : `${section} is one value of ${length(at.value)} characters, larger than can be shown here; it cannot be read or changed by a proposal`\n })\n }\n\n if (!view.notRead!.length) delete view.notRead\n return view\n}\n\n/* ── What a proposal may change ──────────────────────────────────────────────────────── */\n\ntype StepOf<K extends FigureProposalStep['kind']> = Extract<FigureProposalStep, { kind: K }>\ntype Subject = string | undefined\n\n/**\n * The part each kind of step changes, read from the field the kernel reads for that kind (audit D4-R1: a `part` beside a\n * `set-material`'s `target` is not read by the kernel, so it may not stand in for it). Every kind of the kernel's step\n * type is here, or this does not compile. A step that changes no one part says so with undefined: what it does to the\n * figure's sections is held by `unreadSectionEdits`.\n */\nconst SUBJECT: { [K in FigureProposalStep['kind']]: (step: StepOf<K>, base: FigureAsset) => Subject } = {\n 'add-part': () => undefined,\n 'set-section-corner': step => step.part,\n 'set-cavity': step => step.part,\n 'set-section': step => step.part,\n attach: step => step.part,\n 'link-dimension': step => step.part,\n 'follow-size': step => step.part,\n 'unlink-dimension': step => step.part,\n 'scale-position': step => step.part,\n 'fix-position': step => step.part,\n 'nudge-part': step => step.part,\n detach: step => step.part,\n 'make-repeat': step => step.part,\n 'set-repeat': step => step.part,\n 'remove-repeat': step => step.part,\n 'set-mounting-face': step => step.part,\n 'add-binding': step => step.part,\n 'set-joint': step => step.joint?.body1?.part,\n 'remove-joint': (step, base) => ((base as Dynamic).joints ?? []).find((j: Dynamic) => j?.id === step.id)?.body1?.part,\n 'set-material': step => step.target,\n 'set-segments': step => step.target,\n 'rename-part': step => step.target,\n 'set-visibility': step => step.target,\n 'remove-part': step => step.target,\n 'duplicate-part': step => step.target,\n 'move-part': step => step.target,\n 'set-placement': () => undefined,\n 'declare-instance-size': () => undefined,\n 'clear-mounting-face': () => undefined,\n 'scale-uniformly': () => undefined,\n 'follow-size-in-proportion': () => undefined,\n 'set-detail-level': () => undefined,\n 'add-design-input': () => undefined,\n 'set-input-range': () => undefined,\n 'publish-input': () => undefined,\n 'unpublish-input': () => undefined,\n 'remove-binding': () => undefined,\n 'set-slot-layout': () => undefined,\n 'remove-slot-layout': () => undefined,\n 'set-extension': () => undefined,\n rename: () => undefined,\n 'set-capabilities': () => undefined,\n 'set-state-input': () => undefined,\n 'set-state-defaults': () => undefined,\n 'set-driver': () => undefined,\n 'remove-driver': () => undefined,\n 'set-clip': () => undefined,\n 'set-motion-group': () => undefined,\n 'remove-motion-group': () => undefined,\n 'set-data-schema': () => undefined,\n 'rename-data-field': () => undefined,\n 'set-data-binding': () => undefined,\n 'remove-data-binding': () => undefined,\n 'set-status-port': () => undefined,\n 'remove-status-port': () => undefined\n}\n\n/**\n * The steps that change a part of the base not shown in full, as reasons said back to the writer. A part may still be\n * named to fasten to or to follow -- the kernel works from it, nothing about it is guessed -- and a new part is the\n * steps' own. A kind this table does not know is refused: it is not let through unjudged.\n */\nexport function unreadPartEdits(base: FigureAsset, steps: readonly FigureProposalStep[], view: FigureView): string[] {\n const existing = new Set(base.appearance.map(a => a.target))\n const shown = new Set(view.shown ?? [])\n const allowed = [...shown].join(', ') || 'none'\n return steps.flatMap((step, i) => {\n const kind = (step as Dynamic)?.kind\n if (typeof kind !== 'string') return []\n const judge = (SUBJECT as Record<string, (step: Dynamic, base: FigureAsset) => Subject>)[kind]\n if (!Object.prototype.hasOwnProperty.call(SUBJECT, kind) || !judge)\n return [`UNKNOWN_STEP: steps[${i}] has the kind \"${kind}\", which is not one of the commands; use only the commands taught.`]\n const part = judge(step, base)\n if (typeof part !== 'string' || !existing.has(part) || shown.has(part)) return []\n return [\n `UNREAD_PART: steps[${i}] (${kind}) changes \"${part}\", which was not shown in full, so its source is not known here. ` +\n `Change only the parts shown in full (${allowed}) or parts the steps add. To change ${part}, read it with getFigureSource parts and pass it in parts to proposeFigureCandidate.`\n ]\n })\n}\n\n/** Entries of a value, keyed by `id` when every entry of a list has a distinct one, else by place. */\nfunction keyedEntries(value: unknown): Map<string, { token: string; value: unknown }> {\n const out = new Map<string, { token: string; value: unknown }>()\n if (Array.isArray(value)) {\n const ids = value.map(v => (v && typeof v === 'object' && typeof (v as Dynamic).id === 'string' ? (v as Dynamic).id : undefined))\n const byId = ids.every(Boolean) && new Set(ids).size === ids.length\n value.forEach((v, i) => out.set(byId ? `id:${ids[i]}` : `at:${i}`, { token: String(i), value: v }))\n } else if (value && typeof value === 'object') {\n for (const [key, v] of Object.entries(value)) out.set(`key:${key}`, { token: key, value: v })\n }\n return out\n}\n\n/**\n * What of the sections left out of the outline and not read the steps changed, as reasons said back to the writer. Judged\n * on what the steps made, not on what they say: nothing that was there may be changed or taken away. A new entry -- a\n * record in a list, a key in a map -- is the steps' own.\n */\nexport function unreadSectionEdits(base: FigureAsset, after: FigureAsset, view: FigureView): string[] {\n const read = Object.keys(view.sections ?? {})\n const reasons: string[] = []\n const say = (pointer: string, what: string) =>\n reasons.push(\n `UNREAD_SECTION: the steps ${what} ${pointer}, which was left out of the outline and not read, so it is not known here. ` +\n `Leave it as it is; to change it, read it with getFigureSource sections and pass it in sections to proposeFigureCandidate.`\n )\n const check = (pointer: string, before: unknown, now: unknown) => {\n if (reasons.length >= ENTRIES_NAMED || read.some(r => within(pointer, r))) return\n const records = (v: unknown) => v !== null && typeof v === 'object'\n if (!records(before) || !records(now) || Array.isArray(before) !== Array.isArray(now)) {\n if (JSON.stringify(before) !== JSON.stringify(now)) say(pointer, 'change')\n return\n }\n const later = keyedEntries(now)\n for (const [key, entry] of keyedEntries(before)) {\n const child = `${pointer}/${escapeToken(entry.token)}`\n const kept = later.get(key)\n if (kept) check(child, entry.value, kept.value)\n else if (!read.some(r => within(child, r))) say(child, 'remove')\n }\n }\n for (const omitted of view.outline?.omitted ?? []) {\n const tokens = tokensOf(omitted.section)!\n check(omitted.section, valueAt(base, tokens).value, valueAt(after, tokens).value)\n }\n return reasons\n}\n"]}
@@ -46,8 +46,8 @@ export interface FigureReleaseCheckInput {
46
46
  }
47
47
  /**
48
48
  * A check an app adds to releasing (LV figure-server design G10): findings in the gate's own shape, blocking or said.
49
- * The LV figure-server refuses an origin off the middle of the room, which operato-figure only says (ADR-0104
50
- * decision 4: refusing is the receiving side's), and says its carrier and budget advice.
49
+ * The LV figure-server refuses an origin off the middle of the floor, a receiving side's check (ADR-0104 decision 4),
50
+ * and says its carrier and budget advice.
51
51
  */
52
52
  export type FigureReleaseCheck = (input: FigureReleaseCheckInput) => GateFinding[];
53
53
  /** Adds a check to every release verdict (`inspectFigure`, `releaseFigure`). Returns the way to take it off again. */
@@ -82,12 +82,19 @@ rowCategory?: string | null): Inspection;
82
82
  * read, which is a different fact from "nothing changed".
83
83
  */
84
84
  export declare function releaseRecordOf(sourceJson: string, releasedJson?: string | null): {
85
+ source: string;
85
86
  format: string;
86
87
  kernel: string;
87
88
  changes: FigureContractChange[] | null;
88
89
  metrics: FigureReleaseMetrics;
89
90
  topView: FigureTopView;
90
91
  };
92
+ /**
93
+ * A release's source made a draft's again (a revert): the size ends its release wrote down, as far as the parts allow,
94
+ * are opened, and the author's own are kept (ADR-0087 decision 6). An author's end that equals the computed one is
95
+ * opened with them.
96
+ */
97
+ export declare function draftSourceOfRelease(releasedJson: string): string;
91
98
  /**
92
99
  * What a consumer is handed for a released figure: the asset itself, because what draws it -- `registerFigure` in
93
100
  * things-scene -- takes the asset and compiles it with the kernel.
@@ -5,10 +5,12 @@ exports.registerFigureReleaseCheck = registerFigureReleaseCheck;
5
5
  exports.parseSource = parseSource;
6
6
  exports.inspectSource = inspectSource;
7
7
  exports.releaseRecordOf = releaseRecordOf;
8
+ exports.draftSourceOfRelease = draftSourceOfRelease;
8
9
  exports.consumablePayloadOf = consumablePayloadOf;
9
10
  /*
10
- * The doors a stored source goes through: saving (`parseSource`), publishing (`inspectSource`) and handing it to a
11
- * board (`consumablePayloadOf`). The format is `figure-asset-1`, and the asset says so in its `version`; a source
11
+ * The doors a stored source goes through: saving (`parseSource`), publishing (`inspectSource`, and the release's own
12
+ * copy in `releaseRecordOf`), bringing a release back as a draft (`draftSourceOfRelease`) and handing it to a board
13
+ * (`consumablePayloadOf`). The format is `figure-asset-1`, and the asset says so in its `version`; a source
12
14
  * that does not is refused by name, because a source the server cannot identify is one it must not save.
13
15
  */
14
16
  const figure_model_1 = require("@hatiolab/figure-model");
@@ -106,38 +108,13 @@ function parseSource(sourceJson) {
106
108
  * The words are the modeller's (ADR-0097 §9 Q2 A): 「차지하는 공간」 for the volume a figure takes up, 「부품에 맞추기」 for
107
109
  * setting it from the parts, and 「장착면」 for the face it stands on (`figure.text.mounting-face-explained`). A fact, then the way out.
108
110
  */
109
- function figureWording(violation, say, hasParts) {
111
+ function figureWording(violation, say) {
110
112
  const part = violation.part ?? '';
111
113
  const axis = (violation.axis ?? '').toUpperCase();
112
114
  const mm = violation.mm ?? 0;
113
115
  const degrees = violation.degrees ?? 0;
114
116
  const key = (field) => `figure.gate.${violation.code.toLowerCase().replace(/_/g, '-')}.${field}`;
115
117
  switch (violation.code) {
116
- case 'PART_OUTSIDE_OCCUPANCY':
117
- return {
118
- message: say(key('message'), { part, axis, mm }, `'${part}' goes ${mm} mm past the space the figure takes on ${axis}.`),
119
- why: say(key('why'), {}, 'The space the figure takes sets the scale it is placed at. What lies past it is left out of that scale, so on a board this part lands outside the place given to the figure.'),
120
- how: say(key('how'), { part, axis, mm }, `Use "fit to parts" to fit the space the figure takes to the parts again, or move '${part}' ${mm} mm inward on ${axis}.`)
121
- };
122
- case 'OCCUPANCY_UNDECLARED':
123
- return violation.axis
124
- ? {
125
- message: say(`figure.gate.occupancy-empty-axis.message`, { axis }, `The space the figure takes is empty on ${axis}.`),
126
- why: say(key('why'), {}, 'The space a figure takes sets the scale it is placed at on a board.'),
127
- how: say(key('how'), {}, 'Use "fit to parts" to set the space the figure takes from the parts as they are now.')
128
- }
129
- : {
130
- message: say(key('message'), {}, 'The space this figure takes is not set yet.'),
131
- why: say(key('why'), {}, 'The space a figure takes sets the scale it is placed at on a board.'),
132
- /*
133
- A new figure is refused this way before it has a part, and 「fit to parts」 has nothing to measure then —
134
- the screen does not offer it. Telling the author to press it sent them looking for a button that was not
135
- there (:3300, 2026-09-24).
136
- */
137
- how: hasParts
138
- ? say(key('how'), {}, 'Use "fit to parts" to set the space the figure takes from the parts as they are now.')
139
- : say(key('how-no-parts'), {}, 'Add a shape first, then use "fit to parts" to set the space the figure takes from it.')
140
- };
141
118
  case 'PARTS_OFF_PLACEMENT_FACE':
142
119
  return {
143
120
  message: say(key('message'), { part, mm }, `The mounting face of '${part}' is ${mm} mm off the plane the figure stands on.`),
@@ -204,12 +181,9 @@ rowCategory) {
204
181
  }
205
182
  let inspection;
206
183
  let asset;
207
- let hasParts = true;
208
184
  try {
209
185
  asset = (0, figure_model_1.parseFigureAsset)(sourceJson);
210
186
  inspection = (0, figure_model_1.inspectFigureAsset)(asset);
211
- const cost = (0, figure_model_1.figureCostOf)(asset);
212
- hasParts = cost.groups + cost.hidden > 0;
213
187
  }
214
188
  catch (e) {
215
189
  const error = e;
@@ -221,7 +195,7 @@ rowCategory) {
221
195
  const say = sayerOf(t);
222
196
  const findings = inspection.violations.map(violation => ({
223
197
  code: violation.code.toLowerCase().replace(/_/g, '-'),
224
- ...figureWording(violation, say, hasParts),
198
+ ...figureWording(violation, say),
225
199
  at: violation.part,
226
200
  blocking: true
227
201
  }));
@@ -239,38 +213,6 @@ rowCategory) {
239
213
  blocking: true
240
214
  });
241
215
  }
242
- if (inspection.coverage.method === 'sampled') {
243
- const states = inspection.coverage.states;
244
- findings.push({
245
- code: 'state-range-sampled',
246
- /* Sizes as well as motion: the instance size range is swept for every figure (figure-model, designer 2026-09-27). */
247
- message: say('figure.gate.state-range-sampled.message', { states }, `The whole range of sizes and motion could not be proven, so ${states} combinations of size and pose were checked.`),
248
- why: say('figure.gate.state-range-sampled.why', {}, 'Between the combinations that were checked, a part may still go past the space the figure takes.'),
249
- how: say('figure.gate.state-range-sampled.how', {}, 'To cover the whole range, re-author what could not be proven.'),
250
- /*
251
- Which motions stopped the proof, by the name a person gave them: the kernel reports each operation it could
252
- not prove (`j2-shoulder.chain: compose@1 turns …`), and the screen showed that English list as it was. The
253
- name before the first dot is the joint or part; the operations stay in the logs.
254
- */
255
- at: [...new Set((inspection.coverage.unprovable ?? []).map(entry => entry.split(':')[0].split('.')[0].trim()).filter(Boolean))].join(' · ') || undefined,
256
- blocking: false
257
- });
258
- }
259
- /*
260
- Said, never refused (ADR-0104 decision 4): the origin is where the figure is fastened, and a door fastened at its
261
- hinge is a right model. A drawing that places figures by the middle of their room reads this before it pins one.
262
- */
263
- const origin = (0, figure_model_1.figureOriginCentredOf)(asset);
264
- if (origin && !origin.centred) {
265
- const off = origin.off.map(o => `${o.axis.toUpperCase()} ${o.mm} mm`).join(', ');
266
- findings.push({
267
- code: 'origin-off-centre',
268
- message: say('figure.gate.origin-off-centre.message', { off }, `The origin is off the middle of the declared room: ${off}.`),
269
- why: say('figure.gate.origin-off-centre.why', {}, 'A drawing that places figures by the middle of their room puts this one that far from where it is drawn.'),
270
- how: say('figure.gate.origin-off-centre.how', {}, 'Keep it when the figure is fastened there, as a door at its hinge. Move the origin to the middle to place it by its room.'),
271
- blocking: false
272
- });
273
- }
274
216
  findings.push(...planeGapFindings(asset, say));
275
217
  if (releasedJson)
276
218
  findings.push(...figureContractFindings(asset, releasedJson, say));
@@ -301,7 +243,7 @@ const PLANE_ENGLISH = {
301
243
  }
302
244
  };
303
245
  function planeGapFindings(asset, say) {
304
- if (asset.occupancy?.contact)
246
+ if (asset.mountingFace)
305
247
  return [];
306
248
  const gap = (0, figure_model_1.figurePlaneGapOf)(asset);
307
249
  if (!gap || gap.touches)
@@ -477,10 +419,15 @@ function figureContractWording(change, say) {
477
419
  why: say(key('why'), {}, 'It adds what the figure can do. Placed instances stand as they are.')
478
420
  };
479
421
  /* Said, never refused (ADR-0104): a consumer that pins a release reads these before it moves to this one. */
480
- case 'occupancy-changed':
422
+ case 'size-changed':
481
423
  return {
482
- message: say(key('message'), v, `The room the figure takes changed from ${v.before || 'none'} to ${v.after || 'none'}.`),
483
- why: say(key('why'), {}, 'A consumer places the figure by this room. One that moves to this release sees it take the new room.')
424
+ message: say(key('message'), v, `The figure's size changed from ${v.before || 'none'} to ${v.after || 'none'}.`),
425
+ why: say(key('why'), {}, 'A board gives the figure a box of this size. One that moves to this release sees its box change.')
426
+ };
427
+ case 'motion-range-changed':
428
+ return {
429
+ message: say(key('message'), v, `The room the figure sweeps as it moves changed from ${v.before || 'none'} to ${v.after || 'none'}.`),
430
+ why: say(key('why'), {}, 'It is what the figure reaches when it moves. One that moves to this release sees it reach differently.')
484
431
  };
485
432
  case 'contact-face-changed':
486
433
  return {
@@ -637,7 +584,18 @@ function figureContractWording(change, say) {
637
584
  */
638
585
  function releaseRecordOf(sourceJson, releasedJson) {
639
586
  const asset = (0, figure_model_1.parseFigureAsset)(sourceJson);
640
- const measured = { format: asset.version, kernel: figure_model_1.FIGURE_KERNEL_VERSION, metrics: (0, figure_model_1.figureReleaseMetricsOf)(asset), topView: (0, figure_model_1.figureTopViewOf)(asset, null) };
587
+ /*
588
+ The release's own copy carries its size range as it is now: the author's ends, and the rest as far as the parts
589
+ allow (ADR-0087 decision 6). A board reads the ends from it and does not measure; the figure's row keeps only what
590
+ the author narrowed.
591
+ */
592
+ const measured = {
593
+ source: (0, figure_model_1.serializeFigureAsset)((0, figure_model_1.recordFigureInstanceSize)(asset)),
594
+ format: asset.version,
595
+ kernel: figure_model_1.FIGURE_KERNEL_VERSION,
596
+ metrics: (0, figure_model_1.figureReleaseMetricsOf)(asset),
597
+ topView: (0, figure_model_1.figureTopViewOf)(asset, null)
598
+ };
641
599
  if (!releasedJson)
642
600
  return { ...measured, changes: [] };
643
601
  let before;
@@ -649,6 +607,15 @@ function releaseRecordOf(sourceJson, releasedJson) {
649
607
  }
650
608
  return { ...measured, changes: (0, figure_model_1.figureContractChanges)(before, asset) };
651
609
  }
610
+ /**
611
+ * A release's source made a draft's again (a revert): the size ends its release wrote down, as far as the parts allow,
612
+ * are opened, and the author's own are kept (ADR-0087 decision 6). An author's end that equals the computed one is
613
+ * opened with them.
614
+ */
615
+ function draftSourceOfRelease(releasedJson) {
616
+ assertFormat(releasedJson);
617
+ return (0, figure_model_1.serializeFigureAsset)((0, figure_model_1.forgetRecordedInstanceSize)((0, figure_model_1.parseFigureAsset)(releasedJson)));
618
+ }
652
619
  /**
653
620
  * What a consumer is handed for a released figure: the asset itself, because what draws it -- `registerFigure` in
654
621
  * things-scene -- takes the asset and compiles it with the kernel.