benchside 0.4.2__tar.gz → 0.4.4__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 (191) hide show
  1. {benchside-0.4.2 → benchside-0.4.4}/PKG-INFO +15 -3
  2. benchside-0.4.4/README.md +85 -0
  3. {benchside-0.4.2 → benchside-0.4.4}/SETUP.md +20 -2
  4. benchside-0.4.4/benchside/__init__.py +1 -0
  5. {benchside-0.4.2 → benchside-0.4.4}/benchside/application/app.py +33 -2
  6. {benchside-0.4.2 → benchside-0.4.4}/benchside/application/native.py +79 -36
  7. benchside-0.4.4/benchside/application/notebook.py +95 -0
  8. {benchside-0.4.2 → benchside-0.4.4}/benchside/application/sharing.py +214 -43
  9. {benchside-0.4.2 → benchside-0.4.4}/benchside/cli/hooks.py +1 -1
  10. {benchside-0.4.2 → benchside-0.4.4}/benchside/cli/journal.py +2 -2
  11. {benchside-0.4.2 → benchside-0.4.4}/benchside/cli/main.py +28 -3
  12. {benchside-0.4.2 → benchside-0.4.4}/benchside/cli/sharing.py +9 -1
  13. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/consultation/event/decision_recorded.py +1 -1
  14. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/consultation/event/gap_observed.py +13 -1
  15. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/consultation/event/question.py +2 -2
  16. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/consultation/event/research_recorded.py +1 -1
  17. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/consultation/service/consultation.py +2 -0
  18. benchside-0.4.4/benchside/domain/export/event/consent_granted.py +21 -0
  19. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/export/model/value.py +3 -2
  20. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/export/model/wire.py +18 -4
  21. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/export/service/consent.py +3 -3
  22. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/export/service/export.py +48 -23
  23. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/export/service/reporting.py +14 -4
  24. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/shared/model/capture.py +1 -1
  25. benchside-0.4.4/benchside/domain/shared/model/gap.py +138 -0
  26. {benchside-0.4.2 → benchside-0.4.4}/benchside/infrastructure/journal/projection.py +2 -0
  27. {benchside-0.4.2 → benchside-0.4.4}/benchside/infrastructure/readable_records.py +3 -1
  28. {benchside-0.4.2 → benchside-0.4.4}/benchside/reporting.py +12 -1
  29. {benchside-0.4.2 → benchside-0.4.4}/content/app/SKILL.md +38 -5
  30. {benchside-0.4.2 → benchside-0.4.4}/content/app/references/app-api.md +65 -6
  31. benchside-0.4.4/content/app/references/claude-file-memory.md +174 -0
  32. benchside-0.4.4/content/app/references/discovery.md +56 -0
  33. {benchside-0.4.2 → benchside-0.4.4}/content/app/references/generic-agents.md +3 -0
  34. benchside-0.4.4/content/app/references/introduction.md +15 -0
  35. {benchside-0.4.2 → benchside-0.4.4}/content/app/references/metascience.md +23 -6
  36. {benchside-0.4.2 → benchside-0.4.4}/content/app/references/native-memory.md +64 -61
  37. {benchside-0.4.2 → benchside-0.4.4}/content/app/references/onboarding.md +75 -13
  38. {benchside-0.4.2 → benchside-0.4.4}/content/app/references/sharing.md +116 -9
  39. {benchside-0.4.2 → benchside-0.4.4}/content/claude/bench-init/SKILL.md +7 -3
  40. {benchside-0.4.2 → benchside-0.4.4}/content/claude/bench-share/SKILL.md +27 -1
  41. {benchside-0.4.2 → benchside-0.4.4}/content/personas/journal-club.yaml +1 -0
  42. {benchside-0.4.2 → benchside-0.4.4}/content/personas/methods-clinic.yaml +1 -0
  43. {benchside-0.4.2 → benchside-0.4.4}/content/personas/peer-review.yaml +1 -0
  44. {benchside-0.4.2 → benchside-0.4.4}/content/personas/pi-hypothesis.yaml +1 -0
  45. {benchside-0.4.2 → benchside-0.4.4}/content/personas/pi.yaml +1 -0
  46. {benchside-0.4.2 → benchside-0.4.4}/content/personas/repro-check.yaml +1 -0
  47. {benchside-0.4.2 → benchside-0.4.4}/content/personas/results-meeting.yaml +1 -0
  48. {benchside-0.4.2 → benchside-0.4.4}/content/personas/study-design.yaml +1 -0
  49. {benchside-0.4.2 → benchside-0.4.4}/content/templates/app-role.md.tmpl +2 -0
  50. {benchside-0.4.2 → benchside-0.4.4}/content/templates/blocks/capture-contract.md +6 -2
  51. benchside-0.4.4/content/templates/blocks/workflow-support.md +16 -0
  52. {benchside-0.4.2 → benchside-0.4.4}/content/templates/skill.md.tmpl +2 -0
  53. {benchside-0.4.2 → benchside-0.4.4}/docs/package-description.md +14 -2
  54. {benchside-0.4.2 → benchside-0.4.4}/pyproject.toml +1 -1
  55. {benchside-0.4.2 → benchside-0.4.4}/uv.lock +1 -1
  56. benchside-0.4.2/README.md +0 -310
  57. benchside-0.4.2/benchside/__init__.py +0 -1
  58. benchside-0.4.2/benchside/domain/export/event/consent_granted.py +0 -9
  59. benchside-0.4.2/benchside/domain/shared/model/gap.py +0 -89
  60. {benchside-0.4.2 → benchside-0.4.4}/.gitignore +0 -0
  61. {benchside-0.4.2 → benchside-0.4.4}/LICENSE +0 -0
  62. {benchside-0.4.2 → benchside-0.4.4}/benchside/application/__init__.py +0 -0
  63. {benchside-0.4.2 → benchside-0.4.4}/benchside/application/bridge.py +0 -0
  64. {benchside-0.4.2 → benchside-0.4.4}/benchside/application/contributions.py +0 -0
  65. {benchside-0.4.2 → benchside-0.4.4}/benchside/application/di.py +0 -0
  66. {benchside-0.4.2 → benchside-0.4.4}/benchside/application/metascience.py +0 -0
  67. {benchside-0.4.2 → benchside-0.4.4}/benchside/application/packaging.py +0 -0
  68. {benchside-0.4.2 → benchside-0.4.4}/benchside/application/submission_failures.py +0 -0
  69. {benchside-0.4.2 → benchside-0.4.4}/benchside/cli/__init__.py +0 -0
  70. {benchside-0.4.2 → benchside-0.4.4}/benchside/cli/install.py +0 -0
  71. {benchside-0.4.2 → benchside-0.4.4}/benchside/cli/runtime.py +0 -0
  72. {benchside-0.4.2 → benchside-0.4.4}/benchside/cli/ui/__init__.py +0 -0
  73. {benchside-0.4.2 → benchside-0.4.4}/benchside/cli/ui/_glyphs.py +0 -0
  74. {benchside-0.4.2 → benchside-0.4.4}/benchside/cli/ui/_model.py +0 -0
  75. {benchside-0.4.2 → benchside-0.4.4}/benchside/cli/ui/_renderer.py +0 -0
  76. {benchside-0.4.2 → benchside-0.4.4}/benchside/cli/ui/_rich.py +0 -0
  77. {benchside-0.4.2 → benchside-0.4.4}/benchside/config.py +0 -0
  78. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/__init__.py +0 -0
  79. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/authoring/__init__.py +0 -0
  80. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/authoring/command/__init__.py +0 -0
  81. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/authoring/command/compile.py +0 -0
  82. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/authoring/model/__init__.py +0 -0
  83. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/authoring/model/flow.py +0 -0
  84. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/authoring/model/persona.py +0 -0
  85. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/authoring/model/skill.py +0 -0
  86. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/authoring/model/value.py +0 -0
  87. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/authoring/port/__init__.py +0 -0
  88. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/authoring/port/renderer.py +0 -0
  89. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/authoring/port/repository.py +0 -0
  90. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/authoring/port/skill_writer.py +0 -0
  91. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/authoring/query/__init__.py +0 -0
  92. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/authoring/query/get_persona.py +0 -0
  93. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/authoring/query/list_personas.py +0 -0
  94. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/authoring/service/__init__.py +0 -0
  95. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/authoring/service/authoring.py +0 -0
  96. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/authoring/util/__init__.py +0 -0
  97. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/authoring/util/di/__init__.py +0 -0
  98. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/authoring/util/di/provider.py +0 -0
  99. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/consultation/__init__.py +0 -0
  100. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/consultation/command/__init__.py +0 -0
  101. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/consultation/command/capture_gap.py +0 -0
  102. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/consultation/command/close.py +0 -0
  103. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/consultation/command/open.py +0 -0
  104. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/consultation/command/raise_critique.py +0 -0
  105. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/consultation/command/record_decision.py +0 -0
  106. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/consultation/command/resolve_critique.py +0 -0
  107. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/consultation/command/state_hypothesis.py +0 -0
  108. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/consultation/event/__init__.py +0 -0
  109. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/consultation/event/closed.py +0 -0
  110. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/consultation/event/critique_raised.py +0 -0
  111. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/consultation/event/critique_resolved.py +0 -0
  112. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/consultation/event/hypothesis_stated.py +0 -0
  113. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/consultation/event/opened.py +0 -0
  114. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/consultation/model/__init__.py +0 -0
  115. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/consultation/model/consultation.py +0 -0
  116. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/consultation/model/project.py +0 -0
  117. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/consultation/model/value.py +0 -0
  118. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/consultation/port/__init__.py +0 -0
  119. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/consultation/port/repository.py +0 -0
  120. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/consultation/query/__init__.py +0 -0
  121. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/consultation/query/get_consultation.py +0 -0
  122. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/consultation/query/recall_project.py +0 -0
  123. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/consultation/service/__init__.py +0 -0
  124. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/consultation/util/__init__.py +0 -0
  125. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/consultation/util/di/__init__.py +0 -0
  126. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/consultation/util/di/provider.py +0 -0
  127. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/export/__init__.py +0 -0
  128. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/export/command/__init__.py +0 -0
  129. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/export/command/export_observations.py +0 -0
  130. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/export/command/grant_consent.py +0 -0
  131. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/export/command/revoke_consent.py +0 -0
  132. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/export/event/__init__.py +0 -0
  133. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/export/event/consent_revoked.py +0 -0
  134. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/export/event/observations_exported.py +0 -0
  135. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/export/event/reporting.py +0 -0
  136. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/export/model/__init__.py +0 -0
  137. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/export/model/ledger.py +0 -0
  138. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/export/model/metascience.py +0 -0
  139. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/export/model/reporting.py +0 -0
  140. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/export/port/__init__.py +0 -0
  141. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/export/port/redactor.py +0 -0
  142. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/export/port/repository.py +0 -0
  143. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/export/port/sink.py +0 -0
  144. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/export/query/__init__.py +0 -0
  145. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/export/query/consent_status.py +0 -0
  146. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/export/query/preview_export.py +0 -0
  147. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/export/service/__init__.py +0 -0
  148. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/export/util/__init__.py +0 -0
  149. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/export/util/di/__init__.py +0 -0
  150. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/export/util/di/provider.py +0 -0
  151. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/shared/__init__.py +0 -0
  152. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/shared/command.py +0 -0
  153. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/shared/error.py +0 -0
  154. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/shared/event.py +0 -0
  155. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/shared/model/__init__.py +0 -0
  156. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/shared/model/aggregate.py +0 -0
  157. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/shared/model/entity.py +0 -0
  158. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/shared/model/ids.py +0 -0
  159. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/shared/model/provenance.py +0 -0
  160. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/shared/model/value.py +0 -0
  161. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/shared/port/__init__.py +0 -0
  162. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/shared/port/base.py +0 -0
  163. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/shared/port/journal.py +0 -0
  164. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/shared/query.py +0 -0
  165. {benchside-0.4.2 → benchside-0.4.4}/benchside/domain/shared/service.py +0 -0
  166. {benchside-0.4.2 → benchside-0.4.4}/benchside/infrastructure/__init__.py +0 -0
  167. {benchside-0.4.2 → benchside-0.4.4}/benchside/infrastructure/content/__init__.py +0 -0
  168. {benchside-0.4.2 → benchside-0.4.4}/benchside/infrastructure/content/loader.py +0 -0
  169. {benchside-0.4.2 → benchside-0.4.4}/benchside/infrastructure/content/renderer.py +0 -0
  170. {benchside-0.4.2 → benchside-0.4.4}/benchside/infrastructure/content/writer.py +0 -0
  171. {benchside-0.4.2 → benchside-0.4.4}/benchside/infrastructure/files.py +0 -0
  172. {benchside-0.4.2 → benchside-0.4.4}/benchside/infrastructure/http_sink.py +0 -0
  173. {benchside-0.4.2 → benchside-0.4.4}/benchside/infrastructure/journal/__init__.py +0 -0
  174. {benchside-0.4.2 → benchside-0.4.4}/benchside/infrastructure/journal/di.py +0 -0
  175. {benchside-0.4.2 → benchside-0.4.4}/benchside/infrastructure/journal/registry.py +0 -0
  176. {benchside-0.4.2 → benchside-0.4.4}/benchside/infrastructure/journal/store.py +0 -0
  177. {benchside-0.4.2 → benchside-0.4.4}/benchside/infrastructure/placeholders.py +0 -0
  178. {benchside-0.4.2 → benchside-0.4.4}/benchside/infrastructure/readable_refresh.py +0 -0
  179. {benchside-0.4.2 → benchside-0.4.4}/benchside/infrastructure/redaction.py +0 -0
  180. {benchside-0.4.2 → benchside-0.4.4}/benchside/infrastructure/session_context.py +0 -0
  181. {benchside-0.4.2 → benchside-0.4.4}/benchside/infrastructure/storage_layout.py +0 -0
  182. {benchside-0.4.2 → benchside-0.4.4}/benchside/infrastructure/survey_links.py +0 -0
  183. {benchside-0.4.2 → benchside-0.4.4}/benchside/util/__init__.py +0 -0
  184. {benchside-0.4.2 → benchside-0.4.4}/benchside/util/di/__init__.py +0 -0
  185. {benchside-0.4.2 → benchside-0.4.4}/benchside/util/di/base.py +0 -0
  186. {benchside-0.4.2 → benchside-0.4.4}/benchside/util/di/scope.py +0 -0
  187. {benchside-0.4.2 → benchside-0.4.4}/content/app/scripts/benchside_app.py +0 -0
  188. {benchside-0.4.2 → benchside-0.4.4}/content/app-requirements.txt +0 -0
  189. {benchside-0.4.2 → benchside-0.4.4}/content/fixtures/.gitkeep +0 -0
  190. {benchside-0.4.2 → benchside-0.4.4}/content/legacy-skill-digests.json +0 -0
  191. {benchside-0.4.2 → benchside-0.4.4}/content/templates/blocks/sovereignty.md +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: benchside
3
- Version: 0.4.2
3
+ Version: 0.4.4
4
4
  Summary: Research colleagues with private project memory and optional workflow reporting.
5
5
  Project-URL: Homepage, https://github.com/science-works/benchside
6
6
  Project-URL: Documentation, https://github.com/science-works/benchside/blob/main/SETUP.md
@@ -67,8 +67,10 @@ synthetic record. Installing the Python package alone does not complete that set
67
67
  The package is named **benchside**; its command is **bench**. Upgrade with
68
68
  `uv tool upgrade benchside` or `python -m pip install --upgrade benchside`, then
69
69
  rerun the same `bench setup` command to refresh the installed skill. Keep private
70
- records in their existing location. Every app sharing a notebook upgraded by
71
- 0.4.1 must use **0.4.1 or newer**, including apps previously running 0.4.0.
70
+ records in their existing location. **Update every app sharing a Benchside store
71
+ to 0.4.3 or newer together**, including apps using the same local directory. Older cloud
72
+ clients refuse the new notebook format; older local clients can omit new record
73
+ types from their views. Reopen the existing project and verify recall after updating.
72
74
 
73
75
  ## Research roles and records
74
76
 
@@ -77,12 +79,22 @@ records in their existing location. Every app sharing a notebook upgraded by
77
79
  - Results discussant and reproducibility auditor
78
80
  - Journal-club discussant and scientific peer reviewer
79
81
 
82
+ Benchside can also offer to save a decision, evidence or an open question during
83
+ ordinary research chat without starting a role. All roles share the selected
84
+ project's records and can explore practical workflow delays involving materials,
85
+ equipment, coordination, methods, software or data.
86
+
80
87
  The agent selects a suitable role with the researcher. Decisions and research
81
88
  records remain in the chosen private store, with ODT/Markdown reading copies
82
89
  for local storage. Optional sharing is disabled initially; scientific findings
83
90
  are excluded from metascience submissions. Workflow problems require review and
84
91
  approval. Survey participation is agreed before answering.
85
92
 
93
+ Setup offers **Enable all five**, **Choose specific categories**, **Decide later**,
94
+ then **Decline all**, with none recommended or preselected. The all-five shortcut
95
+ saves participation preferences together; individual report approval, conversation
96
+ source selection and each survey's study agreement remain separate.
97
+
86
98
  ## ChatGPT and Claude websites
87
99
 
88
100
  This Python package does **not** install a web-app plugin or grant storage/network
@@ -0,0 +1,85 @@
1
+ <div align="center">
2
+ <picture>
3
+ <source media="(prefers-color-scheme: dark)" srcset="docs/assets/logo-dark.svg">
4
+ <img src="docs/assets/logo-light.svg" alt="" width="84">
5
+ </picture>
6
+ <h1>Benchside</h1>
7
+ <p><strong>A research partner and a private project notebook for your AI assistant.</strong></p>
8
+ <p><a href="docs/getting-started.md">Getting started</a> · <a href="https://github.com/science-works/benchside/releases/latest">Latest release</a> · <a href="CONTRIBUTING.md">Contribute a role</a></p>
9
+ </div>
10
+
11
+ Bring a half-formed question, a puzzling result or a paper you want to discuss. Benchside gives your assistant eight scientific roles and keeps a record of what **you** decided, what evidence you used and what’s still open. In a new chat, you can pick up the same project.
12
+
13
+ Benchside is built by **Science Works, a nonprofit research and policy studio** studying how researchers use AI and what tools would make their work easier.
14
+
15
+ ## Try it
16
+
17
+ Paste this into your agent:
18
+
19
+ > Set up Benchside for me in this app: https://github.com/science-works/benchside
20
+
21
+ For a first try, use **Claude Code** with a local folder or **Claude web** with a private notebook. ChatGPT, Codex and other agents such as OpenCode have [setup routes](docs/host-support.md) too, including for locally hosted models.
22
+
23
+ Your agent follows [the setup guide](SETUP.md), helps you choose where to save your work and checks it can reopen a test record. Benchside needs no separate account or API key. A web app may ask you to upload the plugin.
24
+
25
+ **A first session might sound like this:**
26
+
27
+ > **You:** Be my research supervisor. I have several images from each of six donors. What counts as an independent observation here?
28
+ >
29
+ > **Later:** Record my decision to check the donor labels before analysis. Leave open how to handle the repeated images.
30
+ >
31
+ > **Next chat:** Reopen my imaging project. What did I decide, and what was still open?
32
+
33
+ ## Which role would help?
34
+
35
+ Ask in your own words. You don’t need to know a command or have a hypothesis to start.
36
+
37
+ | When you’re asking… | Try the… |
38
+ | --- | --- |
39
+ | What’s the next useful step for this project? | Research supervisor (PI) |
40
+ | What result would challenge my hypothesis? | Hypothesis reviewer |
41
+ | Which comparison or control am I missing? | Study-design consultant |
42
+ | Why did the same protocol give different results? | Methods troubleshooter |
43
+ | How far does this result support my claim? | Results discussant |
44
+ | Could another lab reproduce this analysis? | Reproducibility auditor |
45
+ | Does this paper’s evidence support its conclusion? | Journal-club discussant |
46
+ | What would a reviewer ask me to revise? | Scientific peer reviewer |
47
+
48
+ ## Where does my notebook live?
49
+
50
+ You choose during setup. **Science Works does not receive your notebook.** Your decisions, findings and open questions stay in the project record you control.
51
+
52
+ - **On your computer:** choose a folder and read the journal as an ODT document, Markdown or both.
53
+ - **In your AI app:** use a private Claude file artifact or ChatGPT Page after Benchside verifies saving and reopening. Existing Claude Docs stay intact; see [Claude memory](content/app/references/claude-file-memory.md) if your account cannot restore one.
54
+ - **In a connected service:** use a document store such as Google Docs if your agent has a connector that can safely update it. Benchside checks this before relying on it.
55
+
56
+ To continue in another app, point it at the same folder or notebook. Both apps need access; their accounts don’t sync automatically. Saving locally doesn’t change how your AI provider processes the chat. [More about your records →](docs/readable-records.md)
57
+
58
+ ## Share workarounds and support metascience
59
+
60
+ Researchers in different labs often lose time solving the same problem. We want a workaround that helps one lab to be easy for the next lab to find. When people keep getting stuck, and there’s no good workaround, that helps Science Works decide what software should be built. Building this shared, searchable collection of problems and workarounds is part of our [community plans](docs/community.md). We’d love you to help shape it!
61
+
62
+ **Sharing is optional and off by default.** If you choose to contribute a workflow problem, you see the exact report and can edit it, skip it or send it to Science Works. Reports use a random contributor ID so we can connect contributions from the same notebook or folder. Your full chats and scientific findings are never part of the report. An optional short workflow excerpt can preserve your wording with confidential and research-specific details replaced by `[redacted]`; you review everything in the report before sending.
63
+
64
+ For example: *“My spreadsheet kept turning sample IDs into dates. Importing that column as text fixed it.”* Someone else can use that tip without seeing any proprietary data.
65
+
66
+ With permission, we study these reports to understand where scientific workflows break down. You can separately opt into usage counts, feedback, surveys or analysis of selected conversations to help us understand **where language models help researchers and where they fall short**. Setup lets you enable all five options together, choose specific categories, decide later or decline all; none is recommended or preselected. You can change your choices later. [How participation works →](docs/getting-started.md#optional-sharing)
67
+
68
+ ## Get involved
69
+
70
+ Have an idea for a scientific role? [Propose it or open a PR](CONTRIBUTING.md). If you use Benchside in published work, please cite [the release you used](https://github.com/science-works/benchside/releases).
71
+
72
+ [Live demo guide](docs/demo-start-here.md) · [How Benchside works](ARCHITECTURE.md) · [Developer guide](docs/getting-started.md#developer-packaging) · [Apache 2.0 licence](LICENSE)
73
+
74
+ <details>
75
+ <summary>Setting up Benchside on someone’s behalf? Instructions for agents</summary>
76
+
77
+ ### Agent setup essentials
78
+
79
+ Follow [SETUP.md](SETUP.md), including the [short introduction](content/app/references/introduction.md) before first setup. If you can only read this page:
80
+
81
+ - Reuse a working installation. On a local agent, install the [Python package](https://pypi.org/project/benchside/) with `uv tool install benchside` or pip in a persistent virtual environment. Run `bench setup --agent claude` for Claude Code, `bench setup --agent codex` for Codex, or `bench setup --agent generic --skills-dir <actual host skill directory>` for another agent.
82
+ - In ChatGPT, discover **Plugin Creator** and use the unchanged `benchside-plugin-<version>.zip` from the [latest release](https://github.com/science-works/benchside/releases/latest). For Claude’s plugin installer, use `benchside-claude-plugin-<version>.zip`. If only manual upload is available, guide that step. No MCP server is needed.
83
+ - Run the installed skill’s version check. After the researcher chooses durable storage, save and read back an isolated synthetic record; check recall in a new chat if possible. Explain any missing capability. Do not send data during setup.
84
+
85
+ </details>
@@ -26,6 +26,10 @@ in web readers. The repository README contains the essential installation checks
26
26
  Do not repeatedly ask the researcher to upload instructions, especially when the
27
27
  actual blocker is lack of an installation tool.
28
28
 
29
+ Before first setup, use the [short introduction](content/app/references/introduction.md).
30
+ If the researcher is only exploring, wait for agreement before installing. An
31
+ explicit request to install already authorises the supported setup steps.
32
+
29
33
  ## 1. Check the app and any existing installation
30
34
 
31
35
  Use the app already specified by the researcher; ask only if the destination is
@@ -163,11 +167,15 @@ inventing a second setup process. Ask only what is not already known:
163
167
  - **Which project?** List existing projects in that store and continue the
164
168
  selected one, or create a separate new project. Never merge projects by title.
165
169
  - **Optional metascience participation?** Explain the independent choices and
166
- preserve existing preferences. Declining or deciding later never blocks use.
170
+ preserve existing preferences. Offer **Enable all five**, **Choose specific
171
+ categories**, **Decide later**, then **Decline all**, with no recommended or
172
+ preselected answer. Explain all five before accepting the all-five shortcut;
173
+ no five-question reconfirmation is needed. Declining or deciding later never
174
+ blocks use. Follow onboarding for the separate source and submission approvals.
167
175
 
168
176
  Offer the optional discipline/career-stage question as described in onboarding;
169
177
  it is not required. Then ask what the researcher wants help with and choose a
170
- suitable role. They do not need to learn slash commands or choose a permanent role.
178
+ suitable role or notebook-only action. They do not need to learn slash commands or choose a permanent role.
171
179
 
172
180
  Private records and optional submissions are separate. Do not upload notebooks
173
181
  or research documents to Science Works. Setup consent does not approve a gap,
@@ -175,6 +183,10 @@ feedback, usage or activity submission; those need an exact preview and approval
175
183
  Surveys use the agreement shown before their questions. No sharing or network
176
184
  test should submit data as part of installation.
177
185
 
186
+ For implicit suggestions in OpenCode, ChatGPT/Codex, Claude Code and other hosts,
187
+ follow [skill discovery](content/app/references/discovery.md). Verify the scope
188
+ and actual fresh-chat behaviour instead of assuming installation guarantees it.
189
+
178
190
  ## 4. Verify and explain the result
179
191
 
180
192
  First invoke the installed `scripts/benchside_app.py` with
@@ -220,3 +232,9 @@ use 0.4.1 or newer**, including apps previously using 0.4.0. Preserve
220
232
  custom files; do not unzip a package over a source installation, whose saved
221
233
  runtime pointer could keep launching the older version. See the
222
234
  [full update guidance](content/app/references/onboarding.md).
235
+
236
+ For the upcoming workflow/notebook beta, update **every app and agent sharing
237
+ the same local folder as well as a cloud notebook**. Older 0.4.2 apps can omit
238
+ the new notebook-only records from their views without deleting them. Restart
239
+ Claude Code desktop and other long-running hosts after updating so they load the
240
+ new plugin/runtime, then verify recall in each app before continuing.
@@ -0,0 +1 @@
1
+ __version__ = "0.4.4"
@@ -40,6 +40,7 @@ READ_ACTIONS = {
40
40
  "participation.status",
41
41
  "sharing.status",
42
42
  "sharing.history",
43
+ "sharing.drafts",
43
44
  "storage.check",
44
45
  "metascience.status",
45
46
  "metascience.history",
@@ -143,6 +144,18 @@ class App:
143
144
  if any((directory / ".git").exists() for directory in (home, *home.parents)):
144
145
  raise InvalidStateError("Benchside's journal must be stored outside Git")
145
146
 
147
+ @staticmethod
148
+ def _sharing_scope(request):
149
+ project = request.get("project_id")
150
+ all_projects = request.get("all_projects", False)
151
+ if type(all_projects) is not bool or (all_projects and project is not None):
152
+ raise ValidationError("Choose a Benchside project or an explicit all-project review")
153
+ if not all_projects and (not isinstance(project, str) or not project):
154
+ raise ValidationError(
155
+ "Provide the current Benchside project_id. Use all_projects:true only "
156
+ "when the researcher explicitly requests a review across projects."
157
+ )
158
+
146
159
  def _dispatch(self, action, request):
147
160
  if action in {"records.preferences", "records.configure"}:
148
161
  from benchside.infrastructure.readable_records import configure, preferences
@@ -205,16 +218,24 @@ class App:
205
218
  match action:
206
219
  case "sharing.status":
207
220
  return flow.status()
221
+ case "sharing.drafts":
222
+ if request.get("channel") in {None, "gaps"}:
223
+ self._sharing_scope(request)
224
+ return flow.drafts(channel=request.get("channel"), project_id=request.get("project_id"))
208
225
  case "sharing.consent":
209
226
  if type(request.get("enabled")) is not bool:
210
227
  raise ValidationError("Consent enabled must be true or false")
211
228
  flow.set_consent(
212
- request["channel"], request["enabled"], kinds=request.get("kinds")
229
+ request["channel"], request["enabled"], kinds=request.get("kinds"), scope=request.get("scope", "kinds")
213
230
  )
214
231
  return flow.status()
232
+ case "sharing.check_in":
233
+ return flow.check_in(request["project_id"], request["session_id"])
215
234
  case "sharing.feedback":
216
235
  return flow.feedback(**request["feedback"]).model_dump(mode="json")
217
236
  case "sharing.preview":
237
+ if request["channel"] == "gaps":
238
+ self._sharing_scope(request)
218
239
  return [
219
240
  d.model_dump(mode="json")
220
241
  for d in flow.prepare(
@@ -224,6 +245,8 @@ class App:
224
245
  feedback_id=request.get("feedback_id"),
225
246
  comment=request.get("comment"),
226
247
  week=request.get("week"),
248
+ replace_draft_ids=request.get("replace_draft_ids"),
249
+ project_id=request.get("project_id"),
227
250
  )
228
251
  ]
229
252
  case "sharing.send":
@@ -340,6 +363,11 @@ class App:
340
363
  surface=config["surface"],
341
364
  ),
342
365
  ):
366
+ if action.startswith("notebook."):
367
+ from benchside.application.notebook import record_checkpoint
368
+
369
+ identifier = record_checkpoint(self, project_id, action, request)
370
+ return {"recorded": identifier, "recall": recalled()}
343
371
  if action == "start":
344
372
  persona = self.personas.get(PersonaId(request["role"]))
345
373
  if persona is None:
@@ -428,12 +456,14 @@ class App:
428
456
  resolution=Resolution(request["resolution"]),
429
457
  )
430
458
  case "decide":
459
+ from benchside.application.notebook import decision_rationale
460
+
431
461
  identifier = f"d-{identifier}"
432
462
  self.service.record_decision(
433
463
  **common,
434
464
  decision_id=identifier,
435
465
  decision=request["decision"],
436
- rationale=request["rationale"],
466
+ rationale=decision_rationale(request),
437
467
  supersedes=request.get("supersedes"),
438
468
  )
439
469
  case "gap":
@@ -442,6 +472,7 @@ class App:
442
472
  **common,
443
473
  observation_id=identifier,
444
474
  gap=TypeAdapter(Gap).validate_python(request["gap"]),
475
+ basis=request.get("basis", "unknown"),
445
476
  )
446
477
  case "close":
447
478
  if type(request.get("converged")) is not bool:
@@ -9,6 +9,7 @@ Compression is for document size, not encryption or anonymisation.
9
9
  import base64
10
10
  import copy
11
11
  import hashlib
12
+ import html
12
13
  import json
13
14
  import re
14
15
  import tempfile
@@ -30,7 +31,9 @@ SCHEMA = "benchside.native.v1"
30
31
  CHECKPOINT_SCHEMA = "benchside.native.v2"
31
32
  CONTEXT_SCHEMA = "benchside.native.v3"
32
33
  RESEARCH_SCHEMA = "benchside.native.v4"
33
- SCHEMA_ORDER = (SCHEMA, CHECKPOINT_SCHEMA, CONTEXT_SCHEMA, RESEARCH_SCHEMA)
34
+ WORKFLOW_SCHEMA = "benchside.native.v5"
35
+ OFFER_SCHEMA = "benchside.native.v6"
36
+ SCHEMA_ORDER = (SCHEMA, CHECKPOINT_SCHEMA, CONTEXT_SCHEMA, RESEARCH_SCHEMA, WORKFLOW_SCHEMA, OFFER_SCHEMA)
34
37
  MAX_DOCUMENT_BYTES = 190_000 # Fits one native Pages edit with room for transport metadata.
35
38
  MAX_METASCIENCE_DOCUMENT_BYTES = 48 * 1024
36
39
  MAX_STATE_BYTES = 8 * 1024 * 1024
@@ -147,7 +150,7 @@ def _check_files(files):
147
150
  if set(data) != {"id"} or not HEX.fullmatch(data["id"]):
148
151
  _fail("Invalid native installation identity")
149
152
  elif (
150
- (set(data) - ({"title"} if name.startswith("app-projects/") else set()))
153
+ (set(data) - ({"title", "sharing_offer"} if name.startswith("app-projects/") else set()))
151
154
  != (
152
155
  {"host", "app_version", "surface", "project_id"}
153
156
  if name.startswith("app-sessions/")
@@ -158,6 +161,22 @@ def _check_files(files):
158
161
  or not isinstance(data["app_version"], str)
159
162
  ):
160
163
  _fail("Invalid native project configuration")
164
+ if "sharing_offer" in data:
165
+ offer = data["sharing_offer"]
166
+ if (not isinstance(offer, dict)
167
+ or set(offer) not in ({"fingerprint", "session_id"}, {"observation_ids", "session_id"})
168
+ or not isinstance(offer.get("session_id"), str)
169
+ or not HEX.fullmatch(offer["session_id"])):
170
+ _fail("Invalid native sharing offer")
171
+ if "fingerprint" in offer:
172
+ if not isinstance(offer["fingerprint"], str) or not re.fullmatch(r"[a-f0-9]{64}", offer["fingerprint"]):
173
+ _fail("Invalid native sharing offer")
174
+ else:
175
+ ids = offer["observation_ids"]
176
+ if (not isinstance(ids, list)
177
+ or any(not isinstance(i, str) or not i or len(i) > 128 for i in ids)
178
+ or len(ids) != len(set(ids))):
179
+ _fail("Invalid native sharing offer identifiers")
161
180
  if "title" in data and (
162
181
  not isinstance(data["title"], str)
163
182
  or not 1 <= len(data["title"]) <= 160
@@ -231,29 +250,32 @@ def _validate_project(project):
231
250
  _fail("Invalid native project document ID or title")
232
251
 
233
252
 
234
- def _has_gap_context(value):
235
- """Include JSONL journals, frozen draft JSON and operation results in the gate.
236
-
237
- Older packages must refuse a context-bearing notebook instead of silently
238
- discarding nested fields when replaying their older event models.
239
- """
253
+ def _contains_feature(value, predicate, markers):
254
+ """Walk nested values and encoded JSON/JSONL consistently for schema gates."""
240
255
  if isinstance(value, dict):
241
- if value.get("schema") == "benchside.gaps.v3" or ("kind" in value and "context" in value):
242
- return True
243
- return any(_has_gap_context(item) for item in value.values())
256
+ return predicate(value) or any(
257
+ _contains_feature(item, predicate, markers) for item in value.values()
258
+ )
244
259
  if isinstance(value, list):
245
- return any(_has_gap_context(item) for item in value)
246
- if isinstance(value, str) and ("context" in value or "benchside.gaps.v3" in value):
260
+ return any(_contains_feature(item, predicate, markers) for item in value)
261
+ if isinstance(value, str) and any(marker in value for marker in markers):
247
262
  for line in [value, *value.splitlines()]:
248
263
  try:
249
264
  decoded = json.loads(line)
250
265
  except (ValueError, TypeError):
251
266
  continue
252
- if not isinstance(decoded, str) and _has_gap_context(decoded):
267
+ if not isinstance(decoded, str) and _contains_feature(decoded, predicate, markers):
253
268
  return True
254
269
  return False
255
270
 
256
271
 
272
+ def _has_gap_context(value):
273
+ return _contains_feature(
274
+ value, lambda v: v.get("schema") == "benchside.gaps.v3"
275
+ or ("kind" in v and "context" in v), ("context", "benchside.gaps.v3"),
276
+ )
277
+
278
+
257
279
  def _document_limit(request):
258
280
  # A host store may hold less than one Pages edit: Claude Docs caps a code block
259
281
  # at 65,536 characters. Omitted means the original limit for every other host.
@@ -266,27 +288,36 @@ def _document_limit(request):
266
288
 
267
289
 
268
290
  def _has_extended_research(value):
269
- """Gate 0.4 values in files, frozen payloads and cached results for older clients."""
270
- if isinstance(value, dict):
271
- if isinstance(value.get("discipline"), list) or any(
272
- value.get(key) == "pi-hypothesis" for key in ("role", "benchside_role", "persona_id")
273
- ):
274
- return True
275
- return any(_has_extended_research(item) for item in value.values())
276
- if isinstance(value, list):
277
- return any(_has_extended_research(item) for item in value)
278
- if isinstance(value, str) and ("discipline" in value or "pi-hypothesis" in value):
279
- for line in [value, *value.splitlines()]:
280
- try:
281
- decoded = json.loads(line)
282
- except (ValueError, TypeError):
283
- continue
284
- if not isinstance(decoded, str) and _has_extended_research(decoded):
285
- return True
286
- return False
291
+ return _contains_feature(
292
+ value, lambda v: isinstance(v.get("discipline"), list) or any(
293
+ v.get(key) == "pi-hypothesis" for key in ("role", "benchside_role", "persona_id")
294
+ ), ("discipline", "pi-hypothesis"),
295
+ )
296
+
297
+
298
+ def _has_workflow_features(value):
299
+ return _contains_feature(
300
+ value, lambda v: (
301
+ v.get("schema") == "benchside.gaps.v4" or v.get("kind") == "workflow_problem"
302
+ or v.get("scope") == "all_workflow" or "sharing_offer" in v
303
+ or ("consultation_id" in v and "gap" in v and v.get("basis", "unknown") != "unknown")
304
+ or ("consultation_id" in v and v["consultation_id"] is None)
305
+ ), ("workflow_problem", "all_workflow", "consultation_id", "benchside.gaps.v4", "sharing_offer"),
306
+ )
307
+
308
+
309
+ def _has_item_offers(value):
310
+ return _contains_feature(
311
+ value, lambda v: isinstance(v.get("sharing_offer"), dict)
312
+ and "observation_ids" in v["sharing_offer"], ("sharing_offer",),
313
+ )
287
314
 
288
315
 
289
316
  def _minimum_schema(body):
317
+ if _has_item_offers(body):
318
+ return OFFER_SCHEMA
319
+ if _has_workflow_features(body):
320
+ return WORKFLOW_SCHEMA
290
321
  if _has_extended_research(body):
291
322
  return RESEARCH_SCHEMA
292
323
  if _has_gap_context(body):
@@ -361,7 +392,7 @@ def unpack(document, expected_workspace_id=None):
361
392
  _validate_body(body)
362
393
  # 0.4.0 already saved extended research values under v1-v3. Validate
363
394
  # them with current models and upgrade on pack; never strand those stores.
364
- required = CONTEXT_SCHEMA if _has_gap_context(body) else (
395
+ required = OFFER_SCHEMA if _has_item_offers(body) else WORKFLOW_SCHEMA if _has_workflow_features(body) else CONTEXT_SCHEMA if _has_gap_context(body) else (
365
396
  CHECKPOINT_SCHEMA if "replay" in body else SCHEMA
366
397
  )
367
398
  if SCHEMA_ORDER.index(snapshot["schema"]) < SCHEMA_ORDER.index(required):
@@ -709,7 +740,12 @@ def _quote(text):
709
740
 
710
741
  def journal_view(app, project_id, projects, revision, history="recent"):
711
742
  recall = app.run({"action": "recall", "project_id": project_id, "history": history})
743
+ title = projects.get(project_id, {}).get("title") or recall.get("title") or project_id
744
+ # A project title is user text, not Markdown links/images or HTML.
745
+ title = re.sub(r"([\\`*_\[\]{}()!#])", r"\\\1", html.escape(title, quote=False))
712
746
  lines = [
747
+ "# Benchside project journal",
748
+ _quote(title),
713
749
  f"Snapshot revision: {revision}.",
714
750
  (
715
751
  "This page is a readable view of that snapshot, not a live save status. "
@@ -731,7 +767,8 @@ def journal_view(app, project_id, projects, revision, history="recent"):
731
767
  label = "All" if history == "all" else "Recent"
732
768
  lines.append(f"## {label} decisions")
733
769
  for decision in recall["recent_decisions"]:
734
- lines.extend([_quote(decision["decision"]), _quote(decision["rationale"])])
770
+ lines.extend([_quote(decision["decision"]),
771
+ _quote(decision["rationale"] or "Rationale not stated")])
735
772
  lines.extend(["", f"## {label} research questions and answers"])
736
773
  for question in recall["recent_questions"]:
737
774
  lines.extend([_quote(question["question"]), _quote(question["answer"] or "Unresolved")])
@@ -756,6 +793,7 @@ def journal_view(app, project_id, projects, revision, history="recent"):
756
793
 
757
794
 
758
795
  BATCH_ACTIONS = {
796
+ "notebook.decide", "notebook.record", "notebook.question", "notebook.answer", "notebook.gap",
759
797
  "setup",
760
798
  "roles",
761
799
  "projects",
@@ -775,6 +813,8 @@ BATCH_ACTIONS = {
775
813
  "participation.status",
776
814
  "participation.set",
777
815
  "sharing.status",
816
+ "sharing.drafts",
817
+ "sharing.history",
778
818
  "sharing.consent",
779
819
  "metascience.status",
780
820
  "metascience.consent",
@@ -857,9 +897,12 @@ def _execute_batch(app, body, steps):
857
897
  _fail("Invalid native batch step")
858
898
  identifier = step.get("id")
859
899
  if not isinstance(identifier, str) or not re.fullmatch(r"[a-z][a-z0-9_]{0,31}", identifier):
860
- _fail("Use a short unique batch step ID")
900
+ _fail(
901
+ "Batch step IDs must be 1–32 characters: start with a lowercase letter, "
902
+ "then use lowercase letters, digits or underscores (for example, review_a)"
903
+ )
861
904
  if identifier in identifiers:
862
- _fail("Use a short unique batch step ID")
905
+ _fail("Each batch step ID must be unique; rename the repeated ID and its $ref references")
863
906
  identifiers.add(identifier)
864
907
  command = step.get("request")
865
908
  if (
@@ -0,0 +1,95 @@
1
+ """Private checkpoints without opening or counting a role consultation.
2
+
3
+ The app validates the selected project/session and holds the transaction lock.
4
+ Reuse the journal events so role and notebook recall see the same history.
5
+ """
6
+
7
+ from uuid import uuid4
8
+
9
+ from pydantic import TypeAdapter
10
+
11
+ from benchside.domain.consultation.event.decision_recorded import DecisionRecorded
12
+ from benchside.domain.consultation.event.gap_observed import GapObserved
13
+ from benchside.domain.consultation.event.question import QuestionAnswered, QuestionRecorded
14
+ from benchside.domain.consultation.event.research_recorded import ResearchRecorded
15
+ from benchside.domain.consultation.model.project import Project
16
+ from benchside.domain.consultation.model.value import Decision, ResearchQuestion, ResearchRecord
17
+ from benchside.domain.shared.error import ValidationError
18
+ from benchside.domain.shared.event import new_event_id
19
+ from benchside.domain.shared.model.gap import Gap
20
+
21
+
22
+ def decision_rationale(request):
23
+ rationale = request.get("rationale")
24
+ if rationale is None:
25
+ return ""
26
+ if not isinstance(rationale, str):
27
+ raise ValidationError("A decision rationale must be text or omitted")
28
+ return rationale if rationale.strip() else ""
29
+
30
+
31
+ def record_checkpoint(app, project_id, action, request):
32
+ if request.get("sitting_id"):
33
+ raise ValidationError("Notebook actions do not take a sitting; use the role action instead")
34
+ project = app.service.projects.get(project_id)
35
+ common = {"id": new_event_id(), "project_id": project_id, "consultation_id": None}
36
+ identifier = uuid4().hex
37
+ match action:
38
+ case "notebook.decide":
39
+ if not isinstance(request.get("decision"), str) or not request["decision"].strip():
40
+ raise ValidationError("A notebook decision needs decision")
41
+ rationale = decision_rationale(request)
42
+ supersedes = request.get("supersedes")
43
+ identifier = f"d-{identifier}"
44
+ event = DecisionRecorded(
45
+ **common,
46
+ decision_id=identifier,
47
+ decision=request["decision"],
48
+ rationale=rationale if rationale.strip() else "",
49
+ supersedes=supersedes,
50
+ )
51
+ # Setup registers a project before its first scientific journal event.
52
+ project = project or Project(id=project_id, title=project_id.root)
53
+ project.record_decision(Decision(
54
+ id=identifier, decision=event.decision, rationale=event.rationale,
55
+ decided_at=event.recorded_at, supersedes=supersedes,
56
+ ))
57
+ case "notebook.record":
58
+ identifier = f"r-{identifier}"
59
+ record = ResearchRecord(id=identifier, **request["record"])
60
+ if record.kind not in {"note", "evidence"}:
61
+ raise ValidationError(
62
+ "Notebook records use note or evidence; role records use their role action"
63
+ )
64
+ if record.kind == "evidence" and not record.sources:
65
+ raise ValidationError(
66
+ "Evidence needs an actual inspected source or explicit researcher report"
67
+ )
68
+ event = ResearchRecorded(**common, record=record)
69
+ case "notebook.question":
70
+ identifier = f"q-{identifier}"
71
+ event = QuestionRecorded(
72
+ **common, question=ResearchQuestion(id=identifier, question=request["question"])
73
+ )
74
+ case "notebook.answer":
75
+ identifier = request["question_id"]
76
+ question = (
77
+ next((q for q in project.questions if q.id == identifier), None)
78
+ if project
79
+ else None
80
+ )
81
+ if question is None or question.answer is not None:
82
+ raise ValidationError("Question not found in this project or already answered")
83
+ event = QuestionAnswered(**common, question_id=identifier, answer=request["answer"])
84
+ case "notebook.gap":
85
+ identifier = f"o-{identifier}"
86
+ event = GapObserved(
87
+ **common,
88
+ observation_id=identifier,
89
+ gap=TypeAdapter(Gap).validate_python(request["gap"]),
90
+ basis=request.get("basis", "unknown"),
91
+ )
92
+ case _:
93
+ raise ValidationError("Unknown notebook action")
94
+ app.journal.append(project_id, event)
95
+ return identifier