calkit-python 0.50.0__py3-none-any.whl → 0.50.2__py3-none-any.whl

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 (48) hide show
  1. calkit/agent_skills/build-paper-pipeline/SKILL.md +1 -1
  2. calkit/agent_skills/check-questions/SKILL.md +76 -20
  3. calkit/agent_skills/conventions/SKILL.md +18 -17
  4. calkit/cli/latex.py +400 -58
  5. calkit/cli/list.py +116 -130
  6. calkit/cli/show.py +515 -1
  7. calkit/cli/update.py +163 -0
  8. calkit/detect.py +67 -2
  9. calkit/docx.py +203 -28
  10. calkit/dvc/core.py +32 -0
  11. calkit/git.py +13 -0
  12. calkit/latex.py +461 -64
  13. calkit/models/core.py +60 -3
  14. calkit/pipeline.py +382 -1
  15. calkit/questions.py +717 -104
  16. calkit/resources/latex/calkit.sty +70 -17
  17. calkit/results.py +139 -0
  18. calkit/tables.py +260 -0
  19. calkit/tests/cli/test_check.py +22 -17
  20. calkit/tests/cli/test_latex.py +75 -0
  21. calkit/tests/cli/test_list.py +75 -84
  22. calkit/tests/cli/test_show.py +281 -0
  23. calkit/tests/cli/test_update.py +93 -0
  24. calkit/tests/test_detect.py +51 -0
  25. calkit/tests/test_docx.py +425 -1
  26. calkit/tests/test_latex.py +89 -3
  27. calkit/tests/test_pipeline.py +277 -3
  28. calkit/tests/test_questions.py +388 -2
  29. calkit/tests/test_results.py +121 -0
  30. calkit/tests/test_tables.py +169 -0
  31. {calkit_python-0.50.0.dist-info → calkit_python-0.50.2.dist-info}/METADATA +27 -13
  32. {calkit_python-0.50.0.dist-info → calkit_python-0.50.2.dist-info}/RECORD +48 -44
  33. {calkit_python-0.50.0.data → calkit_python-0.50.2.data}/data/etc/jupyter/jupyter_server_config.d/calkit.json +0 -0
  34. {calkit_python-0.50.0.data → calkit_python-0.50.2.data}/data/share/jupyter/labextensions/calkit/package.json +0 -0
  35. {calkit_python-0.50.0.data → calkit_python-0.50.2.data}/data/share/jupyter/labextensions/calkit/schemas/calkit/package.json.orig +0 -0
  36. {calkit_python-0.50.0.data → calkit_python-0.50.2.data}/data/share/jupyter/labextensions/calkit/schemas/calkit/plugin.json +0 -0
  37. {calkit_python-0.50.0.data → calkit_python-0.50.2.data}/data/share/jupyter/labextensions/calkit/static/506.c34b070098184e33.js +0 -0
  38. {calkit_python-0.50.0.data → calkit_python-0.50.2.data}/data/share/jupyter/labextensions/calkit/static/57d13a7399cec3c5.png +0 -0
  39. {calkit_python-0.50.0.data → calkit_python-0.50.2.data}/data/share/jupyter/labextensions/calkit/static/616.528427eb54a4a0c0.js +0 -0
  40. {calkit_python-0.50.0.data → calkit_python-0.50.2.data}/data/share/jupyter/labextensions/calkit/static/740.6bf87276e9e5788a.js +0 -0
  41. {calkit_python-0.50.0.data → calkit_python-0.50.2.data}/data/share/jupyter/labextensions/calkit/static/899.f9b9f9bf705a6493.js +0 -0
  42. {calkit_python-0.50.0.data → calkit_python-0.50.2.data}/data/share/jupyter/labextensions/calkit/static/935.46ecc6bf99aa593a.js +0 -0
  43. {calkit_python-0.50.0.data → calkit_python-0.50.2.data}/data/share/jupyter/labextensions/calkit/static/remoteEntry.109a3a8379365e59.js +0 -0
  44. {calkit_python-0.50.0.data → calkit_python-0.50.2.data}/data/share/jupyter/labextensions/calkit/static/style.js +0 -0
  45. {calkit_python-0.50.0.data → calkit_python-0.50.2.data}/data/share/jupyter/labextensions/calkit/static/third-party-licenses.json +0 -0
  46. {calkit_python-0.50.0.dist-info → calkit_python-0.50.2.dist-info}/WHEEL +0 -0
  47. {calkit_python-0.50.0.dist-info → calkit_python-0.50.2.dist-info}/entry_points.txt +0 -0
  48. {calkit_python-0.50.0.dist-info → calkit_python-0.50.2.dist-info}/licenses/LICENSE +0 -0
@@ -95,7 +95,7 @@ building a pipeline from scratch.
95
95
  number in it that is not traceable to a pipeline output. A finding there
96
96
  is a hole you closed by typing rather than by building, so go back to
97
97
  step 3 for it. Show the user the rendered sentences
98
- (`calkit list questions`) and the built document. Never commit a derived
98
+ (`calkit show question <n>`) and the built document. Never commit a derived
99
99
  output yourself, and never edit a results file by hand.
100
100
 
101
101
  ## Data a person has to collect
@@ -12,7 +12,21 @@ An answer in `calkit.yaml` is a claim about the evidence as it was when the
12
12
  answer was last edited. The pipeline keeps the evidence current; nothing
13
13
  keeps the prose current. Calkit's deterministic check catches evidence
14
14
  changing underneath an answer. This skill covers what a check cannot:
15
- whether the sentence still follows from the evidence.
15
+ whether the sentence still follows from the evidence, and whether the
16
+ question's `approach` describes what its pipeline stages actually do.
17
+
18
+ People sign off on a question in two ways, and the two are easy to mix up:
19
+
20
+ - **Verification**, under `verifications`: the stages behind the evidence
21
+ implement the `approach` correctly, i.e., the answer was worked out
22
+ right. It is about code against the approach sentence, not about whether
23
+ the answer is true.
24
+ - **Validation**, under `validations`: the approach suits the question and
25
+ the evidence justifies the answer, i.e., the right thing was worked out.
26
+ It is about whether the claim is logical and defensible, not about the
27
+ code.
28
+
29
+ A sign-off is theirs, not yours: you read and report, and they sign off.
16
30
 
17
31
  ## Division of labor
18
32
 
@@ -26,6 +40,15 @@ Deterministic, done by `calkit check questions` — never re-derive by hand:
26
40
  - every publication `label` still exists in the LaTeX source;
27
41
  - no evidence has changed (Git history for Git-tracked outputs, `dvc.lock`
28
42
  for DVC-tracked ones) since the commit that last edited the question;
43
+ - no verification is stale, i.e., neither the approach nor any of the
44
+ question's stages, their definitions or what `dvc.lock` lists as their
45
+ dependencies, has changed since the commit that added it;
46
+ - no validation is stale, i.e., neither the question, its hypothesis,
47
+ approach, or answer, nor its evidence has changed since the commit that
48
+ added it;
49
+ - which pipeline stages are behind each question's evidence, upstream
50
+ first, listed by `calkit check questions --verbose` and
51
+ `calkit show question <n>`;
29
52
  - each `value` entry reads a file a pipeline stage produces, or one
30
53
  declared with `imported_from`; anything else is an error, since a number
31
54
  nothing computes is a magic number;
@@ -37,7 +60,9 @@ Judgment, done here — the check reads paths and hashes, and cannot read a
37
60
  sentence:
38
61
 
39
62
  - **does the evidence actually support the answer**, which is the reason
40
- this skill exists;
63
+ this skill exists and what a validation vouches for;
64
+ - **does the `approach` describe what the stages implement**, which is what
65
+ a verification vouches for;
41
66
  - does the answer still follow from the evidence, given what changed;
42
67
  - are numbers retyped into the prose that should be `{name}` placeholders;
43
68
  - does a claim resting on a threshold use a conditional answer, with a
@@ -45,7 +70,7 @@ sentence:
45
70
  - is the answer concise, and does it point at the publication section that
46
71
  carries the argument rather than repeating it.
47
72
 
48
- ## Does the evidence support the answer?
73
+ ## Does the evidence support the answer? (validation)
49
74
 
50
75
  A question can pass every deterministic check and still be wrong: the
51
76
  paths resolve, the numbers render, nothing has changed since — and the
@@ -85,6 +110,29 @@ evidence does not support the sentence, propose the sentence it does
85
110
  support and let the user decide; never edit the answer to match the
86
111
  evidence without showing them both.
87
112
 
113
+ ## Does the approach match the implementation? (verification)
114
+
115
+ `approach` is one sentence on how the question is answered. The stages it
116
+ summarizes are derived from the evidence, so they can't drift, but the
117
+ sentence can. For each question with an `approach`:
118
+
119
+ 1. Get its stages from `calkit check questions --verbose --json` (the
120
+ `stages` list) and read each one's definition in `calkit.yaml`, then the
121
+ script, notebook, or command it runs.
122
+ 2. Check that the method the sentence names is the one the code runs,
123
+ e.g., a "discrete-event simulation" that is really a closed-form
124
+ calculation, or "a regression on all sites" that filters half of them.
125
+ 3. Check that anything the sentence states as fixed, e.g., a sample size,
126
+ a model, a dataset, a parameter, matches the code and its inputs.
127
+ 4. Check that no stage in the chain does something the sentence would lead
128
+ a reader to rule out, e.g., an exclusion step or a different estimator.
129
+
130
+ Report mismatches with the line of code and the words they contradict, and
131
+ propose a corrected sentence. A question with an answer and no `approach`
132
+ is worth one: draft it from the stages and let the user decide. Whether
133
+ the approach is the right one for the question belongs to validation, not
134
+ here.
135
+
88
136
  ## Procedure
89
137
 
90
138
  1. Run `calkit check questions --json` and read the report. Questions with
@@ -94,41 +142,49 @@ evidence without showing them both.
94
142
  review or the answer is one the paper leans on.
95
143
  2. For each **stale** question, the report names the evidence that changed
96
144
  and the commit the answer dates from. Read the rendered answer
97
- (`calkit list questions`) against the current evidence, and if it helps,
145
+ (`calkit show question <n>`) against the current evidence, and if it helps,
98
146
  the old evidence (`git show <commit>:<path>`). Decide:
99
- - **The claim still holds**: say so, and edit the question to record
100
- that you read it again. Any edit counts: the check anchors on the
101
- commit where the question last changed. Adding or refining `notes` is
102
- usually the honest edit to make, since it is where you say what you
103
- checked.
147
+ - **The claim still holds**: say so, with what you checked. Recording
148
+ that is the user's sign-off, not yours: suggest they run
149
+ `calkit update question <n> --validate "<what they checked>"`, or
150
+ `--verify` for the approach against the code, adding
151
+ `--with-ai "<your model>"` if your reading informed theirs. Never add
152
+ or refresh a sign-off yourself unless they ask you to, and then only
153
+ with their Git identity and that disclosure.
104
154
  - **The claim no longer holds**: draft a corrected answer, show the user
105
155
  the old and new text side by side with the values that changed, and
106
156
  only after they agree, edit `calkit.yaml`.
107
157
  - **The evidence changed because a stage is not reproducible** (same
108
158
  inputs, different output): that is a pipeline defect, not an answer
109
159
  defect. Report it as such and do not rewrite the answer to match noise.
110
- 3. For each **unattributed** evidence entry, ask where the file came
160
+ 3. For each **stale verification or validation**, the report names what
161
+ changed since the person signed off: for a verification, the approach,
162
+ a stage, or a dependency it ran; for a validation, evidence, with old
163
+ and new values, or the question's own text. Redo the matching reading
164
+ above against the version they signed off on
165
+ (`git show <commit>:calkit.yaml`), and tell the user who needs to look
166
+ again and at what.
167
+ 4. For each **unattributed** evidence entry, ask where the file came
111
168
  from. If a stage should produce it, that is a pipeline gap worth
112
169
  reporting. If it was imported or made by hand, declare it under
113
170
  `figures`, `datasets`, or `publications` with `imported_from` or
114
171
  `created_by` so the project says so. A `value` entry with no stage is
115
172
  reported as an error rather than `unattributed`: give it a stage.
116
- 4. For each **error**, fix the reference: a missing path means the pipeline
173
+ 5. For each **error**, fix the reference: a missing path means the pipeline
117
174
  has not been run or pulled; a bad key or placeholder means a results
118
175
  file was restructured; a missing label means the publication was
119
176
  reorganized. Do not delete evidence to make an error go away.
120
- 5. For every question you touched, move any number in the prose that the
177
+ 6. For every question you touched, move any number in the prose that the
121
178
  evidence carries into a `{name:...}` placeholder on a `value` entry, so
122
179
  it is read from the results file rather than retyped.
123
180
 
124
- 6. Run the evidence-supports-the-answer review above on every question in
125
- scope, `ok` ones included. A question the CLI passed is where an
181
+ 7. Run the validation and verification readings above on every question
182
+ in scope, `ok` ones included. A question the CLI passed is where an
126
183
  unsupported claim survives, because nothing else looks at it.
127
184
 
128
- Never edit a stale question just to clear the check. It is the act of
129
- reading the answer against the evidence that the edit is meant to record,
130
- and an edit made without doing that is a false statement about the
131
- project, not a tidy-up.
185
+ Never edit a question or add a sign-off just to clear the check. A
186
+ sign-off records a person having done the reading, and one added without
187
+ that is a false statement about the project, not a tidy-up.
132
188
 
133
189
  ## Writing answers
134
190
 
@@ -178,7 +234,7 @@ project, not a tidy-up.
178
234
 
179
235
  ## Reporting
180
236
 
181
- Relay a short table: question index, status, what changed, what you did or
182
- propose. Quote values, not adjectives. If the pipeline is stale
237
+ Relay a short table: question index, status, verification and validation
238
+ status, what changed, what you did or propose. Quote values, not adjectives. If the pipeline is stale
183
239
  (`calkit status`), say so first, since the evidence may be about to change
184
240
  again.
@@ -197,23 +197,24 @@ DVC handles:
197
197
 
198
198
  ## Key CLI commands
199
199
 
200
- | Command | What it does |
201
- | ------------------------------- | ---------------------------------------------------- |
202
- | `calkit run` | Run the pipeline (skips unchanged stages) |
203
- | `calkit run --force` | Force re-run all stages |
204
- | `calkit status` | Show which stages are stale |
205
- | `calkit xr <file>` | Auto-detect stage type, env, I/O, add to pipeline |
206
- | `calkit xenv -n <env> -- <cmd>` | Run a command in a named environment |
207
- | `calkit push` | Push Git commits and DVC-tracked files to remotes |
208
- | `calkit pull` | Pull latest code and data |
209
- | `calkit save` | Auto-add, commit, and push (Git + DVC) |
210
- | `calkit commit -m "msg"` | Commit all tracked changes (Git + DVC) |
211
- | `calkit add <file>` | Add a file to version control |
212
- | `calkit check env --name <env>` | Verify an environment matches its spec |
213
- | `calkit new` | Create new project objects (notebook, dataset, etc.) |
214
- | `calkit new question "<text>"` | Record a research question |
215
- | `calkit list questions` | Show questions with answers rendered from evidence |
216
- | `calkit check questions` | Check answers against current evidence |
200
+ | Command | What it does |
201
+ | ------------------------------- | ------------------------------------------------------ |
202
+ | `calkit run` | Run the pipeline (skips unchanged stages) |
203
+ | `calkit run --force` | Force re-run all stages |
204
+ | `calkit status` | Show which stages are stale |
205
+ | `calkit xr <file>` | Auto-detect stage type, env, I/O, add to pipeline |
206
+ | `calkit xenv -n <env> -- <cmd>` | Run a command in a named environment |
207
+ | `calkit push` | Push Git commits and DVC-tracked files to remotes |
208
+ | `calkit pull` | Pull latest code and data |
209
+ | `calkit save` | Auto-add, commit, and push (Git + DVC) |
210
+ | `calkit commit -m "msg"` | Commit all tracked changes (Git + DVC) |
211
+ | `calkit add <file>` | Add a file to version control |
212
+ | `calkit check env --name <env>` | Verify an environment matches its spec |
213
+ | `calkit new` | Create new project objects (notebook, dataset, etc.) |
214
+ | `calkit new question "<text>"` | Record a research question |
215
+ | `calkit list questions` | List questions with what each has and lacks |
216
+ | `calkit show question <n>` | Show a question with its answer rendered from evidence |
217
+ | `calkit check questions` | Check answers against current evidence |
217
218
 
218
219
  ## `calkit xr`: The fastest path to a reproducible stage
219
220