specify-core 0.1.18__tar.gz → 0.2.0__tar.gz

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 (85) hide show
  1. {specify_core-0.1.18 → specify_core-0.2.0}/CHANGELOG.md +187 -0
  2. {specify_core-0.1.18 → specify_core-0.2.0}/Cargo.lock +3 -3
  3. {specify_core-0.1.18 → specify_core-0.2.0}/Cargo.toml +1 -1
  4. {specify_core-0.1.18 → specify_core-0.2.0}/PKG-INFO +6 -5
  5. {specify_core-0.1.18 → specify_core-0.2.0}/README.md +46 -19
  6. {specify_core-0.1.18 → specify_core-0.2.0}/crates/specify-core-py/Cargo.toml +2 -2
  7. {specify_core-0.1.18 → specify_core-0.2.0}/crates/specify-core-py/README.md +5 -4
  8. {specify_core-0.1.18 → specify_core-0.2.0}/crates/specify-core-py/src/lib.rs +19 -4
  9. {specify_core-0.1.18 → specify_core-0.2.0}/pyproject.toml +1 -1
  10. {specify_core-0.1.18 → specify_core-0.2.0}/python/specify_core/api.py +11 -5
  11. {specify_core-0.1.18 → specify_core-0.2.0}/python/specify_core/rules.py +6 -0
  12. {specify_core-0.1.18 → specify_core-0.2.0}/src/answer_file.rs +8 -0
  13. {specify_core-0.1.18 → specify_core-0.2.0}/src/api.rs +290 -19
  14. {specify_core-0.1.18 → specify_core-0.2.0}/src/bom.rs +3 -0
  15. {specify_core-0.1.18 → specify_core-0.2.0}/src/characteristics.rs +20 -0
  16. {specify_core-0.1.18 → specify_core-0.2.0}/src/cli.rs +222 -122
  17. {specify_core-0.1.18 → specify_core-0.2.0}/src/existing.rs +70 -8
  18. {specify_core-0.1.18 → specify_core-0.2.0}/src/lib.rs +3 -0
  19. {specify_core-0.1.18 → specify_core-0.2.0}/src/mcp.rs +812 -190
  20. specify_core-0.2.0/src/open.rs +1180 -0
  21. {specify_core-0.1.18 → specify_core-0.2.0}/src/pmi_scene.rs +39 -1
  22. {specify_core-0.1.18 → specify_core-0.2.0}/src/problems.rs +2 -0
  23. {specify_core-0.1.18 → specify_core-0.2.0}/src/process.rs +6 -2
  24. {specify_core-0.1.18 → specify_core-0.2.0}/src/provenance.rs +162 -15
  25. specify_core-0.2.0/src/resume/truth.rs +884 -0
  26. {specify_core-0.1.18 → specify_core-0.2.0}/src/resume.rs +25 -1
  27. {specify_core-0.1.18 → specify_core-0.2.0}/src/revision/assembly.rs +25 -2
  28. {specify_core-0.1.18 → specify_core-0.2.0}/src/revision/pmi.rs +567 -62
  29. {specify_core-0.1.18 → specify_core-0.2.0}/src/revision/tests.rs +7 -0
  30. {specify_core-0.1.18 → specify_core-0.2.0}/src/revision.rs +488 -37
  31. specify_core-0.2.0/src/rule_sources.rs +252 -0
  32. {specify_core-0.1.18 → specify_core-0.2.0}/src/rules/datums.rs +16 -6
  33. {specify_core-0.1.18 → specify_core-0.2.0}/src/rules/holes.rs +39 -0
  34. {specify_core-0.1.18 → specify_core-0.2.0}/src/rules/mod.rs +138 -13
  35. {specify_core-0.1.18 → specify_core-0.2.0}/src/rules/turned.rs +5 -0
  36. {specify_core-0.1.18 → specify_core-0.2.0}/src/serve.rs +41 -6
  37. specify_core-0.2.0/src/session.rs +1071 -0
  38. {specify_core-0.1.18 → specify_core-0.2.0}/src/writer.rs +156 -10
  39. specify_core-0.1.18/src/open.rs +0 -449
  40. {specify_core-0.1.18 → specify_core-0.2.0}/LICENSE +0 -0
  41. {specify_core-0.1.18 → specify_core-0.2.0}/NOTICE +0 -0
  42. {specify_core-0.1.18 → specify_core-0.2.0}/crates/specify-core-py/LICENSE +0 -0
  43. {specify_core-0.1.18 → specify_core-0.2.0}/crates/specify-core-py/NOTICE +0 -0
  44. {specify_core-0.1.18 → specify_core-0.2.0}/python/specify_core/__init__.py +0 -0
  45. {specify_core-0.1.18 → specify_core-0.2.0}/python/specify_core/__main__.py +0 -0
  46. {specify_core-0.1.18 → specify_core-0.2.0}/python/specify_core/choices.py +0 -0
  47. {specify_core-0.1.18 → specify_core-0.2.0}/python/specify_core/cli.py +0 -0
  48. {specify_core-0.1.18 → specify_core-0.2.0}/python/specify_core/existing.py +0 -0
  49. {specify_core-0.1.18 → specify_core-0.2.0}/python/specify_core/load.py +0 -0
  50. {specify_core-0.1.18 → specify_core-0.2.0}/python/specify_core/problems.py +0 -0
  51. {specify_core-0.1.18 → specify_core-0.2.0}/python/specify_core/schema/haecceity.pmi-1.json +0 -0
  52. {specify_core-0.1.18 → specify_core-0.2.0}/python/specify_core/schema/haecceity.presentation-1.json +0 -0
  53. {specify_core-0.1.18 → specify_core-0.2.0}/python/specify_core/serve.py +0 -0
  54. {specify_core-0.1.18 → specify_core-0.2.0}/python/specify_core/writer.py +0 -0
  55. {specify_core-0.1.18 → specify_core-0.2.0}/src/anchors.rs +0 -0
  56. {specify_core-0.1.18 → specify_core-0.2.0}/src/carried.rs +0 -0
  57. {specify_core-0.1.18 → specify_core-0.2.0}/src/characteristics/inspection.rs +0 -0
  58. {specify_core-0.1.18 → specify_core-0.2.0}/src/characteristics/keys.rs +0 -0
  59. {specify_core-0.1.18 → specify_core-0.2.0}/src/choices.rs +0 -0
  60. {specify_core-0.1.18 → specify_core-0.2.0}/src/dimensioning.rs +0 -0
  61. {specify_core-0.1.18 → specify_core-0.2.0}/src/extras.rs +0 -0
  62. {specify_core-0.1.18 → specify_core-0.2.0}/src/features.rs +0 -0
  63. {specify_core-0.1.18 → specify_core-0.2.0}/src/general.rs +0 -0
  64. {specify_core-0.1.18 → specify_core-0.2.0}/src/input.rs +0 -0
  65. {specify_core-0.1.18 → specify_core-0.2.0}/src/locations.rs +0 -0
  66. {specify_core-0.1.18 → specify_core-0.2.0}/src/main.rs +0 -0
  67. {specify_core-0.1.18 → specify_core-0.2.0}/src/materials.rs +0 -0
  68. {specify_core-0.1.18 → specify_core-0.2.0}/src/mates.rs +0 -0
  69. {specify_core-0.1.18 → specify_core-0.2.0}/src/mesh.rs +0 -0
  70. {specify_core-0.1.18 → specify_core-0.2.0}/src/part.rs +0 -0
  71. {specify_core-0.1.18 → specify_core-0.2.0}/src/pmi_origin.rs +0 -0
  72. {specify_core-0.1.18 → specify_core-0.2.0}/src/pmi_scene/notes.rs +0 -0
  73. {specify_core-0.1.18 → specify_core-0.2.0}/src/pyfmt.rs +0 -0
  74. {specify_core-0.1.18 → specify_core-0.2.0}/src/pyjson.rs +0 -0
  75. {specify_core-0.1.18 → specify_core-0.2.0}/src/resume/names.rs +0 -0
  76. {specify_core-0.1.18 → specify_core-0.2.0}/src/revision/pmi_picture.rs +0 -0
  77. {specify_core-0.1.18 → specify_core-0.2.0}/src/revision/treatments.rs +0 -0
  78. {specify_core-0.1.18 → specify_core-0.2.0}/src/rules/mates.rs +0 -0
  79. {specify_core-0.1.18 → specify_core-0.2.0}/src/rules/py.rs +0 -0
  80. {specify_core-0.1.18 → specify_core-0.2.0}/src/rules/records.rs +0 -0
  81. {specify_core-0.1.18 → specify_core-0.2.0}/src/sightlines.rs +0 -0
  82. {specify_core-0.1.18 → specify_core-0.2.0}/src/standards.rs +0 -0
  83. {specify_core-0.1.18 → specify_core-0.2.0}/src/tolerancing.rs +0 -0
  84. {specify_core-0.1.18 → specify_core-0.2.0}/src/triangulate.rs +0 -0
  85. {specify_core-0.1.18 → specify_core-0.2.0}/src/writer/tests.rs +0 -0
@@ -4,6 +4,193 @@ All notable changes to specify-core-rust. The format follows
4
4
  [Keep a Changelog](https://keepachangelog.com/en/1.1.0/); versions follow
5
5
  [Semantic Versioning](https://semver.org/).
6
6
 
7
+ ## Unreleased
8
+
9
+ ## 0.2.0 (2026-11-19)
10
+
11
+ Read first:
12
+
13
+ - **Fixed: rewriting a file Specify wrote no longer drops PMI** (ADR P9; details under Fixed).
14
+ Before, a rewrite from the editor, `write` or a session dropped PMI another tool had added,
15
+ and defaults written but never stored as answers. Two cases are still dropped, as before: a
16
+ default whose faces another tool moved, and Specify-marked PMI written from a raw intent where
17
+ no default exists.
18
+ - **Preview:** the Specify page (`specify-core open`, `open --diff`) and MCP `show` need the
19
+ built app until it is bundled: `--app DIR` or `SPECIFY_APP_DIR` (and `--wasm DIR` or
20
+ `SPECIFY_WASM_DIR` when the engine is not in the app's `wasm/`). For MCP `show`, only the
21
+ environment variables.
22
+ - **Conflicts with another tool's PMI:** when a requirement another tool wrote contradicts a
23
+ stored answer, Specify offers only to keep the file's requirement; it never replaces it. A
24
+ "use my answer" choice comes in the next release.
25
+ - **Asked again on reopening:** defaults taken that write no PMI (no coating, a general hole,
26
+ no flatness on a datum) leave nothing in the file to read back, so a reopened file asks them
27
+ again. Answers given and stored are resumed.
28
+ - **Exports take only approved defaults** (`questions --resolve-defaults`, serve, Python, WASM
29
+ `exportAnswers`): pass the approvals to keep an export complete. The editor's Answers (JSON)
30
+ export is unchanged until the editor sends approvals.
31
+ - **Upgrading from 0.1.18** (details below): `specify-core open` no longer takes `--site` or
32
+ `--editor` and no longer hands the file to draftwright.io; MCP `write_pmi` refuses a boolean
33
+ `accept_defaults` (pass the approved defaults with their values); Rust `api::export_answers`
34
+ takes approvals and returns `Exported {answers, missing}`; `analyse`'s `resume` gains
35
+ conflicts and `present`, and a reopened file's `existing` and `part` are no longer empty; the
36
+ page's Save sends `{rev, acceptDefaults}`, not the STEP's bytes.
37
+
38
+ ### Added
39
+
40
+ - docs/rule-sources.md: where each of Specify's defaults and tables comes from (standard,
41
+ edition where recorded, convention, vendor figure or assumption) and where it is in the code,
42
+ with the review still open (for #196).
43
+ - Every default carries a structured `source` beside its `basis`: `{rule, kind, refs}`, the
44
+ rule's stable id, `standard`/`convention`/`vendor`/`assumption`, and the standards it cites
45
+ (edition and clause where recorded). In `api::review` and WASM `review`, the MCP `questions`
46
+ tool, Python `Question.source`, and CLI `questions --sources` / serve `questions` with
47
+ `"sources": true` (without them the Python-compatible document is unchanged); `review` and MCP
48
+ `characteristics` give `sources` beside the preview intent, and answer exports `_specify.sources`.
49
+ Additive: `Question::to_dict`, intents written and the STEP are unchanged. Rule ids are
50
+ listed in docs/rule-sources.md (for #196).
51
+ - Agent-first Specify sessions (docs/session.md): `specify-core mcp` holds each opened file's
52
+ answers as a session with a `rev` and its last 256 changes, and its new `show` tool serves the
53
+ Specify page (docs/open.md) for that session on 127.0.0.1 and opens the browser, so the agent
54
+ and the person edit one set of answers. New MCP tools `changes` (what changed since a `rev`),
55
+ `show` and `save` (the specified STEP written beside the file, or over it when opened
56
+ `in_place`; `accept_defaults` required, the defaults the person approved with the values they saw). `open` takes `old`, `old_answers` and `in_place`,
57
+ and with `old` compares the revisions as `diff` does and starts from the carried answers;
58
+ every tool that reads the answers returns `rev`. `answer` takes `partial: true` (every valid
59
+ answer applied in one rev, each id's outcome or refusal given) and `questions` `compact: true`
60
+ (the open questions as `{id, prompt, choices or hint, suggested?, rule?}`); the server's
61
+ instructions give the two agent patterns (intent known: answer in one call, ask the gaps;
62
+ no context: `show`) and ADR P9 (never a default as intent). Set up with
63
+ `claude mcp add specify -- specify-core mcp`.
64
+ - `specify-core open --diff OLD NEW [--answers FILE]`: the page shows what changed (`GET diff`,
65
+ what WASM `diff()` returns, `{report, markdown, view}` or for an assembly
66
+ `{report, markdown, parts}`, built by the same code, now `revision::part_diff` and
67
+ `revision::assembly_diff`; `GET file?rev=old`) and starts from the answers `specify-core diff`
68
+ carries to NEW; Save writes NEW.
69
+ - The page server holds the session: `GET`/`PUT answers` (a stale `rev` is refused with the
70
+ current answers) and `GET events` (server-sent events: the state, then every change and save,
71
+ at most 4 streams); `config` gains `mode`, `path`, `part`, `oldName` and `oldPath`.
72
+
73
+ ### Changed
74
+
75
+ - Answer exports no longer take every default (ADR P9: a default becomes intent only when the
76
+ person approves it). `api::export_answers`, CLI `questions --resolve-defaults`, serve
77
+ `export_answers`, WASM `exportAnswers` and Python `api.export_answers` export the answers given
78
+ plus exactly the defaults approved by part, `{"<part>": {"<id>": value}}` with the value the
79
+ person saw (CLI `--accept-defaults FILE`, serve and Python `accept_defaults`, WASM's second
80
+ argument); without approvals, no defaults. An approval that is not an open question's
81
+ default, or whose default has changed, is refused naming the part and question (serve adds
82
+ `expected` and `current`). Another part's approvals do not apply. Open questions and carry
83
+ blocks no longer refuse an export: it is written incomplete, blocks kept in
84
+ `_specify.unresolved`; serve's result adds `complete` and `missing`, and the CLI lists the
85
+ open questions on stderr. `api::export_answers` now returns `Exported {answers, missing}`;
86
+ `api::with_approved` is the one approval check, shared with the page's Save and MCP.
87
+ `exportAnswers` now needs approvals for defaults; the editor's Answers (JSON) export, which
88
+ uses `acceptDefaults`, still includes every default until the editor moves to
89
+ `exportAnswers` with approvals.
90
+ - On reopening a file Specify wrote, the PMI is the truth (ADR P9 §3): `analyse` reads the
91
+ file's PMI and part settings first and compares them item by item with what the stored
92
+ answers would write (the revision diff's PMI item matching, every face its own). Answers
93
+ the file agrees with resume (`resume.answers`) and their items are not repeated; defaults
94
+ the file states as written but never stored as answers are `resume.present` (answered by
95
+ the file, still answerable); Specify's PMI no stored answer states, stated otherwise than
96
+ its default, answers its question (`resume.file`, kept on writing, not a conflict); the
97
+ file's other PMI is `existing` and `part` (before, a resumed file gave `existing: []` and
98
+ `part: {}`). A stored answer the file
99
+ changed or removed is a conflict, `resume.conflicts: [{id, stored, file}]` with an analysis
100
+ warning each: the file's items stay in `existing` tagged `question`, the answer is not
101
+ resumed and its question is not asked until decided, by answering it (restore; the file's
102
+ items give way on writing) or listing it in `_specify.keep` (keep the file's). `review`,
103
+ WASM `review` and MCP `open`/`questions` present undecided conflicts as `conflicts`
104
+ (`kind: "conflict"`, choices keep/restore); MCP `answer` takes `keep: [id]`, and the tool
105
+ descriptions tell an agent to put conflicts to the person, never decide them. Rewriting a
106
+ reopened part keeps PMI another tool added and undecided conflicts' items: a
107
+ replace-written part with unmarked PMI is rewritten as a scoped Add, replacing only
108
+ Specify's marked requirements (before, a rewrite dropped the added PMI, and the editor's
109
+ preview write dropped defaults written but not stored). Files from before #22, with no
110
+ marked requirements, open and rewrite as before. See docs/answers.md.
111
+ - `specify-core open STEP` serves the Specify app itself on 127.0.0.1 instead of handing the
112
+ file to draftwright.io: the app, the engine, the file and its settings are served under a
113
+ random one-off path, and Specify's Save writes the specified STEP next to the input
114
+ (`<name>.specified.step`, then `-2`, `-3`, …; never overwriting), or over it with
115
+ `--in-place` (the original kept once per run as `.bak`; a link's target is replaced and the
116
+ link kept). Saves go beside the path as given, even when it is a link. `--read-only` refuses
117
+ saves, `--port N` picks the port. Nothing depends on draftwright.io and Chrome no longer asks
118
+ about local-network access. An open page sends a heartbeat (`GET config`) every 30 s; the
119
+ command stops 90 s after the last page is closed, or after 30 minutes without a request.
120
+ Until the app is bundled, `--app DIR` (or `SPECIFY_APP_DIR`) names the built app and
121
+ `--wasm DIR` (or `SPECIFY_WASM_DIR`) the engine's wasm-pack `pkg/`. The contract for the
122
+ app's authors is docs/open.md.
123
+ - Save from the page sends `{rev, acceptDefaults}` (JSON; `acceptDefaults` required, by part
124
+ `{"<part>": {"<id>": <value>}}`, exactly the defaults the person approved with the values
125
+ they saw, checked against the current defaults and applied together on that part only, ADR P9), not the STEP bytes. A save writes only parts with answers, and a part
126
+ joining the session is a change (`joined`): the command writes the session's answers with `specify-core write`'s writer, so a
127
+ save from the page and one from the agent write the same file. An incomplete save is written
128
+ (what is answered, the answers stored so reopening resumes them) and answers `complete` and
129
+ `missing`; an in-place save always writes from the file as opened, and refuses (409) a file
130
+ changed on disk by another program. `--read-only` also refuses answer changes.
131
+ - MCP `write_pmi` and `export_answers` no longer take every default (ADR P9): they write or
132
+ export what is answered plus exactly the `accept_defaults` given (`{"<id>": <value>}`, the
133
+ values the person saw, checked against the current defaults), incomplete allowed, with
134
+ `complete` and `missing`; `write_pmi`'s boolean `accept_defaults` is refused.
135
+ - `specify-core diff`, MCP's `diff` and the sessions compare through one function
136
+ (`revision::compare`).
137
+
138
+ ### Removed
139
+
140
+ - `specify-core open`'s `--site` and `--editor`, and its handoff to
141
+ draftwright.io/specify?open=….
142
+
143
+ ### Fixed
144
+
145
+ - Reopening and writing again a file Specify wrote no longer drops PMI (ADR P9): requirements
146
+ another tool added (unmarked), defaults written but never stored as answers, a stored answer
147
+ the file contradicts (until the person decides), and a conflict kept are all kept, through
148
+ the CLI's `write`, WASM `writePmi`, a session save and MCP; another tool's requirement in
149
+ conflict stands against any answer, saved answers included. Known limits, both also lost
150
+ before this change: a default whose faces another tool moved, and Specify-marked PMI
151
+ written from a raw intent where no default exists, are still dropped on rewrite.
152
+ - `diff` on a symmetric part, where the old part fits the new one turned (180° say) as well as
153
+ it lies, broke the tie by the file's frame without saying so. It still matches in the file's
154
+ frame, now a stated rule in docs/diff.md, and says so: report.md's "Matched in the file's
155
+ frame; a 180° turn about Z fits equally." and report.json's `frame_tie`. The verdict and
156
+ carried answers are unchanged.
157
+ - `diff`'s PMI change list paired a removed hole's requirement with the one on the hole that
158
+ took its face numbers ("80 → 30") through their shared face-numbered id. A same-id pair now
159
+ must agree with the face correspondence, so the removed hole's requirements are removed and
160
+ the surviving holes' unchanged. A removal is `retired` only from a carried number history:
161
+ with fresh numbers it is `removed`, so a number is no longer listed as retired and given to
162
+ another item. Carried answers and written PMI are unchanged.
163
+ - `diff` reported a body or a hole pattern as moved when a hole was cut into it or its holes
164
+ were resized ("thin wall body: moved X −0.1", "1 hole pattern moved"): its centroid moved,
165
+ its faces did not. A feature now moves only when its faces do. A pocket or slot moved on a
166
+ part too sparse to align (only face lines before) is now reported moved.
167
+ - `diff` named a thin wall body a "thin wall bodie"; families ending in `-ies` now read `-y`.
168
+ - `diff`'s requirements to check repeated a feature's change for each of its requirements and
169
+ named a position tolerance by its planned locations ("70; 50; 50; 35; ⌖ ⌀0.2Ⓜ A B C"). One
170
+ line now names the change once, with each requirement as the PMI list names it.
171
+ - `diff` counted a requirement that was only numbered differently as a change to the PMI. It is
172
+ counted apart in the summary ("N characteristic numbers changed (requirements unchanged)"),
173
+ and Markdown lists it after the changes as unchanged.
174
+ - The release's npm job failed for 0.1.18: `npm pack` read the relative `release/pkg` as a
175
+ GitHub repository. `tools/npm_package.py` passes an absolute path; a test packs a relative
176
+ directory with npm.
177
+
178
+ ### WASM API
179
+
180
+ - `engine.exportAnswers(answersJson, approvalsJson?)`: exports the answers given plus exactly the
181
+ defaults in `approvalsJson` (`{"<part>": {"<id>": value}}`; none when absent), never every
182
+ default (ADR P9). Open questions and carry blocks no longer throw; an approval whose default
183
+ has changed does.
184
+ - WASM `writePmi`'s report says whether the answers were complete: `complete` and `missing` (the
185
+ required questions still open). An incomplete set is still written, as before.
186
+ - `diff()`'s PMI items gain an optional `detail`: the explanation that used to be appended to a
187
+ retired item's `reason`, which is now always the plain code.
188
+ - `engine.review` / `review` add `conflicts` (only when there are some): a reopened file's
189
+ stored answers its PMI contradicts, `{id, kind: "conflict", text, stored, file, choices}`;
190
+ `snapshot().analysis.resume` adds `conflicts` and `present`, and `existing`/`part`
191
+ now hold the file's PMI its answers do not explain (ADR P9). Answers accept `_specify.keep: [id]`. The
192
+ generated declarations are unchanged.
193
+
7
194
  ## 0.1.18 (2026-11-17)
8
195
 
9
196
  ### Added
@@ -753,7 +753,7 @@ dependencies = [
753
753
 
754
754
  [[package]]
755
755
  name = "specify-core"
756
- version = "0.1.18"
756
+ version = "0.2.0"
757
757
  dependencies = [
758
758
  "base64",
759
759
  "clap",
@@ -773,7 +773,7 @@ dependencies = [
773
773
 
774
774
  [[package]]
775
775
  name = "specify-core-py"
776
- version = "0.1.18"
776
+ version = "0.2.0"
777
777
  dependencies = [
778
778
  "pyo3",
779
779
  "serde_json",
@@ -782,7 +782,7 @@ dependencies = [
782
782
 
783
783
  [[package]]
784
784
  name = "specify-core-wasm"
785
- version = "0.1.18"
785
+ version = "0.2.0"
786
786
  dependencies = [
787
787
  "console_error_panic_hook",
788
788
  "haecceity",
@@ -4,7 +4,7 @@ resolver = "3"
4
4
 
5
5
  [package]
6
6
  name = "specify-core"
7
- version = "0.1.18"
7
+ version = "0.2.0"
8
8
  edition = "2024"
9
9
  license = "Apache-2.0"
10
10
  description = "Interview-driven AP242 PMI authoring for STEP parts (Rust port of specify-core)"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: specify-core
3
- Version: 0.1.18
3
+ Version: 0.2.0
4
4
  Classifier: Development Status :: 3 - Alpha
5
5
  Classifier: Intended Audience :: Developers
6
6
  Classifier: Intended Audience :: Manufacturing
@@ -153,8 +153,9 @@ file is read back and checked before it is kept.
153
153
  Status: early (0.x). The JSON formats may change between minor versions; changes are listed in
154
154
  the changelog. Draftwright® is a registered trade mark of Betwixt Ltd.
155
155
 
156
- Complete answer sidecars (defaults explicit, with geometry evidence) can be exported
157
- before writing: `api.export_answers(step, analysis, answers)` returns a dict.
158
- Incomplete sets and unresolved carries are refused. See
159
- [answer files](../../docs/answers.md#export-a-complete-sidecar).
156
+ Answer sidecars (with geometry evidence) can be exported before writing:
157
+ `api.export_answers(step, analysis, answers, accept_defaults=None)` returns a dict of the
158
+ answers given plus exactly the defaults approved (`{"<part>": {"<id>": value}}`).
159
+ Open questions and carry blocks do not refuse it (`write` still needs a complete set). See
160
+ [answer files](../../docs/answers.md#export-a-sidecar).
160
161
 
@@ -53,7 +53,7 @@ One engine, one set of answers and files, whichever way you call it:
53
53
  | **In the browser** | nothing: [draftwright.io/specify](https://draftwright.io/specify) and [draftwright.io/diff](https://draftwright.io/diff) | |
54
54
  | **Command line** | `uv tool install specify-core` (or `pipx install specify-core`), a [release](https://github.com/pzfreo/specify-core/releases) binary, `cargo install specify-core`, or `cargo build --release` | [install](#install-the-command-line), [use](#command-line) |
55
55
  | **Python** | `pip install specify-core` (CPython 3.11+, no dependencies) | [below](#python), [package README](crates/specify-core-py/README.md) |
56
- | **Rust** | `specify-core = "0.1.18"` (crates.io) | [below](#rust), [docs/library.md](docs/library.md) |
56
+ | **Rust** | `specify-core = "0.2.0"` (crates.io) | [below](#rust), [docs/library.md](docs/library.md) |
57
57
  | **Browser** (WebAssembly) | `@draftwright/specify-core-wasm` (npm), or `specify-core-wasm-<version>.tgz` on each release | [docs/wasm.md](docs/wasm.md) |
58
58
  | **Host process** (JSON lines) | `specify-core serve` | [below](#host-process) |
59
59
  | **LLM client** (MCP: Claude Code, Claude Desktop) | `specify-core mcp` (stdio) or `specify-core mcp --http` | [docs/mcp.md](docs/mcp.md) |
@@ -78,13 +78,20 @@ The flow is the same everywhere:
78
78
  specify-core analyse plate.step -o plate.analysis.json # features, faces, existing PMI
79
79
  specify-core questions plate.analysis.json --open # what is still unanswered
80
80
  echo '{"part.material": "6082-T6", "hole.function:holes:9": "fit:H7"}' > answers.json
81
- # Export defaults explicitly, with face evidence, before writing:
81
+ # The defaults the person approved, by part, each with the value they saw (here every
82
+ # default offered for the open questions, once the person has seen the list and agreed):
83
+ specify-core questions plate.analysis.json --answers answers.json --open \
84
+ | jq '{"0": (map(select(.default != null) | {(.id): .default}) | add // {})}' > approved.json
85
+ # Export the answers plus those defaults, with face evidence; stderr lists what is still open:
82
86
  specify-core questions plate.analysis.json --answers answers.json \
83
- --resolve-defaults --step plate.step > plate.complete.answers.json
84
- specify-core write plate.step plate.analysis.json plate.complete.answers.json -o plate-pmi.step
87
+ --resolve-defaults --step plate.step --accept-defaults approved.json > plate.answers.json
88
+ specify-core write plate.step plate.analysis.json plate.answers.json -o plate-pmi.step
85
89
  ```
86
90
 
87
- `write` refuses until every question has an answer, or `--accept-defaults` supplies the rest.
91
+ An export takes no default the person did not approve (ADR P9), so without `--accept-defaults`
92
+ it is usually incomplete. `write` still needs a complete set: answer the open questions, or
93
+ approve their defaults in the approvals file, and export again. `write` refuses until every
94
+ question has an answer, or its own `--accept-defaults` supplies the rest.
88
95
  It prints a JSON report with `output`, `written`, `not_written` and `warnings`. `not_written`
89
96
  gives each reason, including an answer whose question is not asked given the other answers
90
97
  ([answers](docs/answers.md#answers-to-questions-not-asked)).
@@ -103,15 +110,33 @@ are named `max_deviation_mm`. See [mesh tolerance](docs/mesh-tolerance.md).
103
110
  `-o -` writes `analyse`'s or `mesh`'s JSON to stdout (the summary goes to stderr), for a pipe:
104
111
  `specify-core analyse plate.step -o - | jq '.features[].family'`.
105
112
 
106
- `specify-core open plate.step` opens the file in [draftwright.io/specify](https://draftwright.io/specify)
107
- in your browser, with nothing to click and nothing uploaded: it serves the file once on
108
- 127.0.0.1, to the editor's origin only, and exits once the page has fetched it (or after 10
109
- minutes). `--editor` opens the full editor instead, `--site ORIGIN` another deployment, and
110
- `--no-browser` only prints the address. The first time, Chrome asks whether
111
- "draftwright.io wants to access other apps and services on this device": Allow lets the page
112
- fetch the file from 127.0.0.1, and is remembered. If the file did not open while that prompt
113
- was up, stop the command (Ctrl-C) and run it again. If you chose Block, allow it again in
114
- draftwright.io's site settings.
113
+ `specify-core open plate.step` opens the file in Specify in your browser, served by the
114
+ command itself on 127.0.0.1: nothing is uploaded and nothing depends on a website. The command
115
+ holds the answers given in the page; Specify's Save writes them (what is answered, even with
116
+ questions still open; the defaults only when you choose "with defaults") into
117
+ `plate.specified.step` next to the input (then `plate.specified-2.step`, …; nothing is
118
+ overwritten); `--in-place` saves over the input (through a link, over its target) and keeps the
119
+ original once as `plate.step.bak`, and `--read-only` refuses answer changes and saves.
120
+ `specify-core open --diff old.step new.step` shows what changed and starts from the answers
121
+ `specify-core diff` carries to the new revision (`--answers FILE` for the old answers); Save
122
+ writes the new one. `--port N` picks the port and `--no-browser` only prints the address. The
123
+ command stops 90 seconds after the last page is closed, or after 30 minutes without a request.
124
+ **Preview:** the app is not bundled yet. Pass `--app DIR` (or set `SPECIFY_APP_DIR`) to the built Specify app
125
+ and `--wasm DIR` (or `SPECIFY_WASM_DIR`) to the engine's wasm-pack `pkg/` directory. See
126
+ [docs/open.md](docs/open.md).
127
+
128
+ **With an AI agent.** Add Specify to your agent once, as a stdio MCP server:
129
+
130
+ ```sh
131
+ claude mcp add specify -- specify-core mcp
132
+ ```
133
+
134
+ The agent opens the part, answers what you tell it, and calls `show` to open the same Specify
135
+ page on the same answers: your edits in the page are what the agent reads next, and its answers
136
+ appear in the page as it makes them. Either side saves. `show` is a **preview** until the app is
137
+ bundled: it needs `SPECIFY_APP_DIR` set for the MCP server (and `SPECIFY_WASM_DIR` when the
138
+ engine is not in the app's `wasm/`). See
139
+ [docs/session.md](docs/session.md) and [docs/mcp.md](docs/mcp.md).
115
140
 
116
141
  **Shell completion.** `specify-core completions SHELL` prints a completion script for `bash`,
117
142
  `zsh`, `fish`, `powershell` or `elvish`:
@@ -250,7 +275,7 @@ Each [release](https://github.com/pzfreo/specify-core/releases) has the command
250
275
  (x86_64), macOS (Apple silicon) and Windows (x86_64), each with a SHA-256 checksum:
251
276
 
252
277
  ```bash
253
- v=v0.1.18; t=aarch64-apple-darwin # or x86_64-unknown-linux-gnu
278
+ v=v0.2.0; t=aarch64-apple-darwin # or x86_64-unknown-linux-gnu
254
279
  gh release download $v -R pzfreo/specify-core -p "specify-core-$v-$t.tar.gz*"
255
280
  shasum -a 256 -c specify-core-$v-$t.tar.gz.sha256 && tar -xzf specify-core-$v-$t.tar.gz
256
281
  ./specify-core-$v-$t/specify-core --help
@@ -270,9 +295,10 @@ echo '{"id": 1, "op": "analyse", "step": "part.step"}' | specify-core serve
270
295
  ```
271
296
 
272
297
  - **Ops:** `parts`, `analyse`, `questions`, `preview`, `interpret`, `export_answers` and `write`.
273
- `export_answers` takes `step`, `analysis` and `answers`, and returns `result.answers`: a
274
- complete map with explicit defaults and geometry evidence; it refuses incomplete sets.
275
- See [answer files](docs/answers.md#export-a-complete-sidecar).
298
+ `export_answers` takes `step`, `analysis`, `answers` and optional `accept_defaults` (the
299
+ defaults approved, `{"<part>": {"<id>": value}}`), and returns `result.answers` (what is
300
+ answered plus those defaults, with geometry evidence), `complete` and `missing`.
301
+ See [answer files](docs/answers.md#export-a-sidecar).
276
302
  - `analyse` accepts optional `max_deviation_mm` for the returned mesh (for example `0.05`).
277
303
  It must be a finite number of at least 0.001 mm; invalid or unmet bounds return `invalid`.
278
304
  Omission or `null` preserves the default mesh. See [mesh tolerance](docs/mesh-tolerance.md).
@@ -295,7 +321,7 @@ Every file is read back and checked before it is kept.
295
321
 
296
322
  ## Status
297
323
 
298
- **0.1.18** (2026-11-17). Until 1.0:
324
+ **0.2.0** (2026-11-19). Until 1.0:
299
325
  - a minor release (0.2, 0.3) may change the command line, the JSON formats or answer ids, and its
300
326
  [CHANGELOG](CHANGELOG.md) entry says how to upgrade;
301
327
  - a patch release doesn't.
@@ -321,6 +347,7 @@ that implementation wrote. The `specify-core` Python package is now this engine;
321
347
  | [step-diff/README.md](step-diff/README.md) | the pull request action |
322
348
  | [docs/part-notes.md](docs/part-notes.md) | part notes in the STEP file |
323
349
  | [docs/process.md](docs/process.md) | how a part is made (`part.process`) and its defaults |
350
+ | [docs/rule-sources.md](docs/rule-sources.md) | where each default comes from: standard, convention, vendor figure or assumption |
324
351
  | [docs/python.md](docs/python.md) | building the Python package; compatibility with the Python implementation |
325
352
  | [docs/design.md](docs/design.md) | design and status |
326
353
  | [docs/questions.md](docs/questions.md) | decisions taken and open |
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "specify-core-py"
3
- version = "0.1.18"
3
+ version = "0.2.0"
4
4
  edition = "2024"
5
5
  license = "Apache-2.0"
6
6
  description = "Python bindings for specify-core: the Python package's API on the Rust engine"
@@ -16,7 +16,7 @@ test = false
16
16
  doctest = false
17
17
 
18
18
  [dependencies]
19
- specify-core = { path = "../..", version = "=0.1.18" }
19
+ specify-core = { path = "../..", version = "=0.2.0" }
20
20
  # abi3-py311: one wheel per platform for every CPython from 3.11 (#183).
21
21
  # No `extension-module` feature: maturin sets PYO3_BUILD_EXTENSION_MODULE, and without it
22
22
  # `cargo test --workspace` still links.
@@ -126,7 +126,8 @@ file is read back and checked before it is kept.
126
126
  Status: early (0.x). The JSON formats may change between minor versions; changes are listed in
127
127
  the changelog. Draftwright® is a registered trade mark of Betwixt Ltd.
128
128
 
129
- Complete answer sidecars (defaults explicit, with geometry evidence) can be exported
130
- before writing: `api.export_answers(step, analysis, answers)` returns a dict.
131
- Incomplete sets and unresolved carries are refused. See
132
- [answer files](../../docs/answers.md#export-a-complete-sidecar).
129
+ Answer sidecars (with geometry evidence) can be exported before writing:
130
+ `api.export_answers(step, analysis, answers, accept_defaults=None)` returns a dict of the
131
+ answers given plus exactly the defaults approved (`{"<part>": {"<id>": value}}`).
132
+ Open questions and carry blocks do not refuse it (`write` still needs a complete set). See
133
+ [answer files](../../docs/answers.md#export-a-sidecar).
@@ -43,7 +43,8 @@ fn raised(error: Error) -> PyErr {
43
43
  match error {
44
44
  Error::Load(_)
45
45
  | Error::Rules(rules::Error::Invalid(_))
46
- | Error::Write(WriteError::Invalid(_)) => PyValueError::new_err(error.to_string()),
46
+ | Error::Write(WriteError::Invalid(_))
47
+ | Error::Unapproved(_) => PyValueError::new_err(error.to_string()),
47
48
  _ => PyRuntimeError::new_err(error.to_string()),
48
49
  }
49
50
  }
@@ -304,16 +305,26 @@ fn pmi_scene(
304
305
  .map_err(PyValueError::new_err)
305
306
  }
306
307
 
307
- /// Complete answer file, with defaults explicit and evidence checked against the part.
308
+ /// Answer file of the answers given and exactly the defaults in `accept_defaults` (JSON,
309
+ /// `{"<part>": {"<id>": value}}`; none when absent; ADR P9), with evidence checked against
310
+ /// the part. Open questions stay open.
308
311
  #[pyfunction]
312
+ #[pyo3(signature = (step, analysis, answers, accept_defaults=None))]
309
313
  fn export_answers(
310
314
  py: Python<'_>,
311
315
  step: &Bound<'_, PyAny>,
312
316
  analysis: &str,
313
317
  answers: &str,
318
+ accept_defaults: Option<&str>,
314
319
  ) -> PyResult<String> {
315
320
  let analysis = parse("analysis", analysis)?;
316
321
  let answers = answers_of(answers)?;
322
+ let approved = match accept_defaults {
323
+ Some(text) => api::approvals(&parse("accept_defaults", text)?).ok_or_else(|| {
324
+ PyValueError::new_err(format!("accept_defaults: {}", api::APPROVALS_FORM))
325
+ })?,
326
+ None => api::Approved::new(),
327
+ };
317
328
  let index = analysis["binding"]["part"].as_u64().unwrap_or(0) as usize;
318
329
  let owned;
319
330
  let handle = match loaded(step, None)? {
@@ -323,8 +334,8 @@ fn export_answers(
323
334
  &owned
324
335
  }
325
336
  };
326
- py.detach(|| api::export_answers(&handle.loaded, &analysis, &answers))
327
- .map(|answers| Value::Object(answers).to_string())
337
+ py.detach(|| api::export_answers(&handle.loaded, &analysis, &answers, &approved))
338
+ .map(|exported| Value::Object(exported.answers).to_string())
328
339
  .map_err(raised)
329
340
  }
330
341
 
@@ -708,6 +719,10 @@ fn record(question: &Question) -> Value {
708
719
  out.insert("diameter".into(), json!(question.diameter));
709
720
  out.insert("depth".into(), json!(question.depth));
710
721
  out.insert("basis".into(), json!(question.basis));
722
+ out.insert(
723
+ "source".into(),
724
+ question.source_json().unwrap_or(Value::Null),
725
+ );
711
726
  out.insert("mate".into(), json!(question.mate));
712
727
  Value::Object(out)
713
728
  }
@@ -4,7 +4,7 @@ build-backend = "maturin"
4
4
 
5
5
  [project]
6
6
  name = "specify-core"
7
- version = "0.1.18"
7
+ version = "0.2.0"
8
8
  description = "Add manufacturing intent (GD&T, fits, threads, finish) to STEP parts and write it as AP242 semantic PMI"
9
9
  readme = "README.md"
10
10
  license = "Apache-2.0"
@@ -84,16 +84,22 @@ def apply(
84
84
 
85
85
 
86
86
  def export_answers(
87
- step: str | Path | LoadedPart, analysis: dict[str, Any], answers: dict[str, Any]
87
+ step: str | Path | LoadedPart,
88
+ analysis: dict[str, Any],
89
+ answers: dict[str, Any],
90
+ accept_defaults: dict[str, dict[str, Any]] | None = None,
88
91
  ) -> dict[str, Any]:
89
- """Complete answer map with defaults explicit and ``_specify.evidence`` for this part.
92
+ """Answer map with ``_specify.evidence`` for this part: the answers given, plus exactly the
93
+ defaults in ``accept_defaults`` (``{"<part>": {"<id>": value}}``, each with the value the
94
+ person saw; none when omitted). Never every default (ADR P9); open questions stay open.
90
95
 
91
- Does not write STEP. Raises IncompleteError for unanswered required questions
92
- or carry blocks, and ValueError for stale evidence or a mismatched analysis.
96
+ Does not write STEP. Raises ValueError for stale evidence, a mismatched analysis, or an
97
+ approved default that is not an open question's default as it now stands.
93
98
  Serialize with ``json.dumps(result, indent=2) + "\\n"`` for a stable sidecar.
94
99
  """
100
+ approved = None if accept_defaults is None else json.dumps(accept_defaults)
95
101
  return json.loads(_native.export_answers(
96
- _step(step), json.dumps(analysis), json.dumps(answers)
102
+ _step(step), json.dumps(analysis), json.dumps(answers), approved
97
103
  ))
98
104
 
99
105
 
@@ -59,6 +59,9 @@ class Question:
59
59
  #: Why the default is what it is, in a sentence: shown as a choice made for
60
60
  #: the person, to keep or change.
61
61
  basis: str = ""
62
+ #: Which rule proposed the default and what it rests on: ``{"rule", "kind", "refs"}``
63
+ #: (see the engine's ``docs/rule-sources.md``); None where there is no default.
64
+ source: dict[str, Any] | None = None
62
65
  #: When the default comes from how the part fits another in its assembly: why.
63
66
  mate: str = ""
64
67
  optional: bool = False
@@ -91,6 +94,8 @@ class Question:
91
94
  out["choices"] = list(self.choices)
92
95
  if self.basis:
93
96
  out["basis"] = self.basis
97
+ if self.source:
98
+ out["source"] = self.source
94
99
  return out
95
100
 
96
101
  @classmethod
@@ -116,6 +121,7 @@ class Question:
116
121
  diameter=record["diameter"],
117
122
  depth=record["depth"],
118
123
  basis=record["basis"],
124
+ source=record.get("source"),
119
125
  mate=record["mate"],
120
126
  optional=record.get("optional", False),
121
127
  )
@@ -23,6 +23,14 @@ pub fn validate(answers: &Map<String, Value>) -> Result<(), String> {
23
23
  {
24
24
  return Err("_specify.unresolved must map question IDs to reasons".into());
25
25
  }
26
+ if let Some(keep) = meta.get(crate::resume::truth::KEEP)
27
+ && !keep.as_array().is_some_and(|ids| {
28
+ ids.iter()
29
+ .all(|id| id.as_str().is_some_and(|s| !s.is_empty()))
30
+ })
31
+ {
32
+ return Err("_specify.keep must list question IDs".into());
33
+ }
26
34
  Ok(())
27
35
  }
28
36