@hippo-digital/hippocampus 2.8.1 → 2.9.1

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,56 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.9.1
4
+
5
+ - **Every route that can add a newer feature records the version it needs.**
6
+ In 2.9.0 only `draft promote` wrote `requiresPackage` into `_meta.json`, so
7
+ an expert review promoted with `promote research` left it out, and anyone
8
+ still on 2.8.1 got a schema error about an unknown method instead of being
9
+ told to upgrade. `promote research` and `import design-actions` now record
10
+ it too.
11
+ - **`validate` warns when the knowledge base needs more than `_meta.json`
12
+ says.** Records added by hand skip every command that records the level.
13
+ The warning names the features and the version, and fails `--strict`.
14
+ - **`migrate` records the level** even when the schema needs no migration, so
15
+ the warning has a one-command fix. Run `npx hippocampus validate` after
16
+ upgrading; if it warns, run `npx hippocampus migrate` and commit
17
+ `hippocampus/source/_meta.json`.
18
+
19
+ ## 2.9.0
20
+
21
+ Release 1 of the traceability work: the knowledge base can say who decided,
22
+ when, and on what, and any draft can be checked and promoted the same way.
23
+ Everything is additive within schemaVersion 1. A knowledge base that uses the
24
+ new link types or method records that it needs 2.9.0, so an older package
25
+ refuses it rather than reading it partially.
26
+
27
+ - **`draft check` and `draft promote`.** One route for drafts of any record
28
+ type, not just research rounds. `draft check` validates the draft against the
29
+ whole knowledge base without changing it, and writes what it found into the
30
+ draft's review note. `draft promote` needs a `--reviewer` who is not the
31
+ author, honours `after` (drafts that must go first), records each promotion
32
+ in `hippocampus/manifests/drafts.json`, and is safe to run twice. See
33
+ [Review a draft and promote it](docs/review-and-promote-a-draft.md#drafts-of-any-other-record).
34
+ - **Who and when on decisions.** Decisions take `decidedBy`, `decidedOn`
35
+ (`YYYY-MM-DD`) and `owner`; design actions take `owner`; insights take
36
+ `signedOffOn` beside `signedOffBy`. `import design-actions` now writes
37
+ Owner, Decided by and Date agreed into these fields instead of prose, reads
38
+ ISO, UK and Excel dates, and keeps a date it cannot read in the consequence
39
+ with a note.
40
+ - **Expert reviews are evaluation.** A new research method, `expert-review`,
41
+ for reviews such as a clinical safety review. A round can say whether it was
42
+ `formative` or `summative`. A participant can be a `reviewer`: reviewers are
43
+ listed separately on the research page and never counted as users the
44
+ research heard from.
45
+ - **Two new links.** `rests-on` (design action, decision or requirement to an
46
+ assumption) and `challenged-by` (assumption, decision or requirement to
47
+ evidence or an insight). Both show on record pages in each direction.
48
+ - **`_meta.json` records `requiresPackage`.** Written by `draft promote`, never
49
+ lowered, and checked on load with a message naming the version to upgrade to.
50
+ - **One list of collection files.** `lib/collections.js` is shared by loading,
51
+ validation and promotion, so `promote research` now sees ids in every record
52
+ type when it checks for clashes, and tolerates missing files.
53
+
3
54
  ## 2.8.1
4
55
 
5
56
  - **The viewer works with nhsuk-prototype-kit 8.5.2.** That kit renders through
@@ -31,6 +31,8 @@ const COMMANDS = {
31
31
  'import design-actions': 'import-design-actions.js',
32
32
  'promote research': 'promote-research-draft.js',
33
33
  'promote project-context': 'promote-project-context-draft.js',
34
+ 'draft check': 'check-draft.js',
35
+ 'draft promote': 'promote-draft.js',
34
36
  'link insight-needs': 'link-insights-to-needs.js',
35
37
  'source index': 'index-source-artefacts.js',
36
38
  'source audit': 'audit-provenance.js',
@@ -90,6 +90,25 @@ design action ID a decision points at exists, that statuses are in the permitted
90
90
  and that no action has two accepted options. It validates the whole knowledge base
91
91
  before writing anything, so a bad workbook cannot leave source data broken.
92
92
 
93
+ ### Who and when
94
+
95
+ The importer writes the workbook's people and dates as fields, not prose, so they
96
+ can be checked and shown:
97
+
98
+ | Workbook column | Record field |
99
+ | --- | --- |
100
+ | Design Actions `Owner` | design action `owner` |
101
+ | Decisions `Decided by` | decision `decidedBy` |
102
+ | Decisions `Date agreed` | decision `decidedOn` |
103
+
104
+ `Date agreed` may be an ISO date (`2026-11-11`), a UK date (`11/11/2026`) or an
105
+ Excel date cell. A date it cannot read is kept in the decision's `consequence` as
106
+ "Agreed ..." and the importer says so, rather than guessing. A design action's
107
+ `Dependency` stays in its rationale.
108
+
109
+ Where the knowledge base may be shared, put a role in `Owner` and `Decided by`
110
+ rather than a name.
111
+
93
112
  ## How this traces
94
113
 
95
114
  Relationships point from a dependent to what it relies on, because evidence impact
@@ -201,6 +201,83 @@ git checkout -- hippocampus/source hippocampus/manifests
201
201
  After you have committed, use `git revert` on that commit. Either way, the
202
202
  draft is still in `hippocampus/imports/research/` to correct and promote again.
203
203
 
204
+ ## Drafts of any other record
205
+
206
+ `promote research` handles one research round. For anything else - decisions
207
+ from a meeting, requirements, assumptions, a finding that challenges an earlier
208
+ call - write a draft in the general format and use `draft check` and
209
+ `draft promote`. They work the same way for every record type.
210
+
211
+ ### The draft format
212
+
213
+ ```json
214
+ {
215
+ "draft": {
216
+ "title": "Decisions from the 11 November playback",
217
+ "createdOn": "2026-11-12",
218
+ "summary": "Two options weighed for the medications drawer.",
219
+ "after": ["hippocampus/inbox/2026-11-11-playback-round.draft.json"],
220
+ "reviewNote": "2026-11-12-playback-decisions.review.md",
221
+ "draftedBy": "Interaction designer"
222
+ },
223
+ "records": {
224
+ "decisions": [ { "id": "meds-drawer-grouped", "title": "...", "status": "proposed", "decision": "...", "consequence": "..." } ],
225
+ "relationships": [ { "id": "meds-drawer-grouped-rests-on-gp-codes", "type": "rests-on", "from": "meds-drawer-grouped", "to": "gp-codes-are-consistent" } ]
226
+ }
227
+ }
228
+ ```
229
+
230
+ - `records` is keyed by collection name, the same names as the files in
231
+ `hippocampus/source/` (`decisions`, `requirements`, `assumptions`,
232
+ `insights`, `relationships` and so on). Each record is checked against the
233
+ same schema as the source file it will join.
234
+ - `after` lists drafts that must be promoted first, because this one links to
235
+ their records. A listed draft counts as promoted once it is in the promotion
236
+ manifest, or once every record in it is already in the knowledge base.
237
+ - `reviewNote` names the markdown file the reviewer works in. Without it, a
238
+ `.review.md` beside the draft is used if there is one.
239
+ - `draftedBy` is who wrote the draft, a person or a role.
240
+
241
+ ### Check it
242
+
243
+ ```bash
244
+ npx hippocampus draft check --draft hippocampus/inbox/<name>.draft.json
245
+ ```
246
+
247
+ It changes nothing in the knowledge base. It checks each record, looks for ids
248
+ already in use, checks `after`, and then validates the whole knowledge base as
249
+ it would be with the draft added. Only problems the draft would cause are
250
+ listed; any the knowledge base already had are mentioned once, separately.
251
+
252
+ It writes what it found into the review note, between
253
+ `<!-- hippocampus draft check: start -->` and
254
+ `<!-- hippocampus draft check: end -->`. Running it again replaces that block
255
+ and leaves the rest of the note alone. `--note <file>` writes to another file;
256
+ `--no-note` writes nothing. It exits with 1 if there are problems.
257
+
258
+ ### Promote it
259
+
260
+ ```bash
261
+ npx hippocampus draft promote --draft hippocampus/inbox/<name>.draft.json --reviewer "Clinical safety officer" --dry-run
262
+ npx hippocampus draft promote --draft hippocampus/inbox/<name>.draft.json --reviewer "Clinical safety officer"
263
+ ```
264
+
265
+ - It runs every check `draft check` does, and refuses if there is a problem.
266
+ - `--reviewer` is required, and must not be the draft's `draftedBy`: a draft is
267
+ not reviewed by the person who wrote it. Use a role where the knowledge base
268
+ may be shared.
269
+ - It adds the records to the source files and records the promotion in
270
+ `hippocampus/manifests/drafts.json`: the draft, its title, when, who reviewed
271
+ it, who drafted it, and how many of each record.
272
+ - If the draft uses something an older Hippocampus cannot read, such as a
273
+ `rests-on` link, it records the version needed in `_meta.json` and says so.
274
+ See [Source model](source-model.md#which-version-a-knowledge-base-needs).
275
+ - Promoting a draft whose records are all already there does nothing and says
276
+ "Already promoted", so running it twice is safe.
277
+
278
+ Then review the change with `git diff hippocampus/source hippocampus/manifests`
279
+ and commit it. To undo, use the same steps as for a research draft.
280
+
204
281
  ## Related skills
205
282
 
206
283
  - `review-research-import-draft`: an AI agent checks the draft against the
@@ -252,9 +252,11 @@ Do not invent evidence. If a claim is not evidenced, add an assumption instead.
252
252
 
253
253
  Files: `research-rounds.json`, `participants.json`, `insights.json`. Their import is described in [Research knowledge graph](research-knowledge-graph.md). Optional fields:
254
254
 
255
- - a round's `methods`: a list of `contextual-interview`, `interview`, `observation`, `focus-group`, `user-survey`, `usability-test`, `usability-inspection`, `card-sort`, `preference-test`, `desk-research`, `analytics`, `other`. The method decides which activity page lists the round.
255
+ - a round's `methods`: a list of `contextual-interview`, `interview`, `observation`, `focus-group`, `user-survey`, `usability-test`, `usability-inspection`, `expert-review`, `card-sort`, `preference-test`, `desk-research`, `analytics`, `other`. The method decides which activity page lists the round. `expert-review` is a review by a specialist against what they know, such as a clinical safety review of a screen; it counts as evaluation.
256
+ - a round's `evaluation`: `formative` (to find problems while the design can still change) or `summative` (to show the finished design is safe and usable). IEC 62366-1 asks for both.
257
+ - a participant's `kind`: `research-participant` (the default) or `reviewer`. A reviewer, such as a clinical safety officer, is listed under the round's reviewers and never counted as a user the research heard from.
256
258
  - a participant's `userId`: the user group they were recruited as
257
- - an insight's `polarity` (`problem`, `positive`, `observation`), `rating` (`positive`, `minor`, `major`, `critical`, `catastrophic`), `signedOffBy` (who agreed a catastrophic rating) and `qualityDimension`
259
+ - an insight's `polarity` (`problem`, `positive`, `observation`), `rating` (`positive`, `minor`, `major`, `critical`, `catastrophic`), `signedOffBy` (who agreed a catastrophic rating), `signedOffOn` (the date, `YYYY-MM-DD`) and `qualityDimension`
258
260
 
259
261
  ### Quality objectives
260
262
 
@@ -299,6 +301,16 @@ Allowed statuses:
299
301
  - `superseded`
300
302
  - `rejected`
301
303
 
304
+ Optional fields, so a decision says who made it and when:
305
+
306
+ | Field | Notes |
307
+ | --- | --- |
308
+ | `decidedBy` | The person or role who made the call. Prefer a role where the record may be shared. |
309
+ | `decidedOn` | The date it was made, `YYYY-MM-DD` |
310
+ | `owner` | Who carries it out |
311
+
312
+ A design action may also carry an `owner`. See [Design actions and decisions](design-actions-and-decisions.md).
313
+
302
314
  ### Assumptions
303
315
 
304
316
  File: `hippocampus/source/assumptions.json`
@@ -343,8 +355,16 @@ Typed links in `relationships.json` point from the record that depends to the re
343
355
  | `weighed-against` | decision | requirement | `meets`, `partly`, `fails`, `not-assessed` |
344
356
  | `applies-principle` | screen, requirement, decision or journey | principle | |
345
357
  | `observed-on` | insight | screen | |
358
+ | `rests-on` | design action, decision or requirement | assumption | |
359
+ | `challenged-by` | assumption, decision or requirement | evidence or insight | |
360
+
361
+ A relationship may carry a `note` saying why. Validation checks the From and To of these ten; a link written the wrong way round does not fail on its own, it just stops traversal, so validation catches it instead. The older types are listed in [Research knowledge graph](research-knowledge-graph.md).
362
+
363
+ `rests-on` makes an assumption's reach visible: when it turns out to be wrong, the work resting on it is listed on its page. `challenged-by` records the evidence or finding that calls a record into question, without deleting or overwriting it.
364
+
365
+ ### Which version a knowledge base needs
346
366
 
347
- A relationship may carry a `note` saying why. Validation checks the From and To of these eight; a link written the wrong way round does not fail on its own, it just stops traversal, so validation catches it instead. The older types are listed in [Research knowledge graph](research-knowledge-graph.md).
367
+ `hippocampus/source/_meta.json` holds the `schemaVersion` and, once a knowledge base uses something an older package cannot read, `requiresPackage`: the lowest version of Hippocampus that understands everything in it. `draft promote`, `promote research` and `import design-actions` write it when they add a newer link type or method, and never lower it. Records added by hand skip those commands, so `validate` warns when the knowledge base uses something `_meta.json` does not record, and `npx hippocampus migrate` records it. An older package refuses the knowledge base and says which version to upgrade to, rather than reading it partially. The `rests-on` and `challenged-by` links and the `expert-review` method need 2.9.0.
348
368
 
349
369
  Project context stays outside the graph: it is briefing material, and organisational requirements are where its rules become checkable.
350
370
 
@@ -0,0 +1,53 @@
1
+ const fs = require('fs')
2
+ const path = require('path')
3
+
4
+ // Every file a knowledge base is made of, keyed by the name the schema uses.
5
+ // One list, so that validate, the viewer and every promote command read the
6
+ // same set. `promote research` once kept its own shorter list and refused any
7
+ // draft that linked to a requirement, a goal or a principle, because it had
8
+ // never heard of them.
9
+ const COLLECTION_FILES = {
10
+ project: 'project.json',
11
+ projectContext: 'project-context.json',
12
+ users: 'users.json',
13
+ needs: 'needs.json',
14
+ scenarios: 'scenarios.json',
15
+ journeys: 'journeys.json',
16
+ screens: 'screens.json',
17
+ evidence: 'evidence.json',
18
+ decisions: 'decisions.json',
19
+ assumptions: 'assumptions.json',
20
+ researchRounds: 'research-rounds.json',
21
+ participants: 'participants.json',
22
+ insights: 'insights.json',
23
+ designActions: 'design-actions.json',
24
+ goals: 'goals.json',
25
+ qualityObjectives: 'quality-objectives.json',
26
+ requirements: 'requirements.json',
27
+ principles: 'principles.json',
28
+ relationships: 'relationships.json'
29
+ }
30
+
31
+ // The collections that are lists of records with ids, as opposed to the
32
+ // single project and project context objects.
33
+ const RECORD_COLLECTIONS = Object.keys(COLLECTION_FILES)
34
+ .filter((key) => key !== 'project' && key !== 'projectContext')
35
+
36
+ function readCollectionFile (knowledgeSourceDir, key) {
37
+ const filePath = path.join(knowledgeSourceDir, COLLECTION_FILES[key])
38
+ if (!fs.existsSync(filePath)) return []
39
+ return JSON.parse(fs.readFileSync(filePath, 'utf8'))
40
+ }
41
+
42
+ // Every record id in the knowledge base, whatever its type. A missing file is
43
+ // an empty collection: a freshly initialised project has almost none of them.
44
+ function readAllRecordIds (knowledgeSourceDir) {
45
+ const ids = new Set()
46
+ for (const key of RECORD_COLLECTIONS) {
47
+ if (key === 'relationships') continue
48
+ for (const item of readCollectionFile(knowledgeSourceDir, key)) ids.add(item.id)
49
+ }
50
+ return ids
51
+ }
52
+
53
+ module.exports = { COLLECTION_FILES, RECORD_COLLECTIONS, readCollectionFile, readAllRecordIds }
@@ -301,6 +301,8 @@ function checkConsequences (knowledge, scenarioId, { concerns = STANDING_CONCERN
301
301
  const distinctive = ownWords.filter((w) => !otherWords.has(w))
302
302
  const words = distinctive.length ? distinctive : ownWords
303
303
  const participants = (knowledge.participants || []).filter((p) => {
304
+ // A reviewer in an expert review is not research with that user group.
305
+ if (p.kind === 'reviewer') return false
304
306
  const role = roleWords(p.role)
305
307
  return words.some((w) => role.includes(w))
306
308
  })
@@ -215,6 +215,7 @@ function createHippocampusRouter ({ basePath, knowledgeStore, paths }) {
215
215
  { key: 'Finding', value: r.polarity },
216
216
  { key: 'Rating', value: r.rating },
217
217
  { key: 'Rating signed off by', value: r.signedOffBy },
218
+ { key: 'Signed off on', value: r.signedOffOn },
218
219
  { key: 'Quality', value: hcd.DIMENSION_LABELS[r.qualityDimension] },
219
220
  { key: 'Reference', value: r.reference },
220
221
  { key: 'Summary', value: r.summary }
@@ -256,6 +257,9 @@ function createHippocampusRouter ({ basePath, knowledgeStore, paths }) {
256
257
  { key: 'Status', value: r.status },
257
258
  { key: 'Decision', value: r.decision },
258
259
  { key: 'Consequence', value: r.consequence },
260
+ { key: 'Decided by', value: r.decidedBy },
261
+ { key: 'Decided on', value: r.decidedOn },
262
+ { key: 'Owner', value: r.owner },
259
263
  { key: 'Reference', value: r.reference }
260
264
  ],
261
265
  Screen: (r) => [
package/lib/hcd-views.js CHANGED
@@ -18,7 +18,9 @@ const CONTEXT_METHODS = new Set([
18
18
  'contextual-interview', 'interview', 'observation', 'focus-group',
19
19
  'user-survey', 'desk-research', 'analytics', 'card-sort'
20
20
  ])
21
- const EVALUATION_METHODS = new Set(['usability-test', 'usability-inspection', 'preference-test'])
21
+ // An expert review evaluates a design too - a clinician judging it rather than
22
+ // users being observed - so its rounds sit with the other evaluations.
23
+ const EVALUATION_METHODS = new Set(['usability-test', 'usability-inspection', 'preference-test', 'expert-review'])
22
24
 
23
25
  const METHOD_LABELS = {
24
26
  'contextual-interview': 'Contextual interview',
@@ -32,6 +34,7 @@ const METHOD_LABELS = {
32
34
  'preference-test': 'Preference test',
33
35
  'desk-research': 'Desk research',
34
36
  analytics: 'Analytics',
37
+ 'expert-review': 'Expert review',
35
38
  other: 'Other'
36
39
  }
37
40
 
@@ -180,7 +180,7 @@ function lintKnowledge (knowledge) {
180
180
  }
181
181
 
182
182
  const usabilityRounds = new Set((knowledge.researchRounds || [])
183
- .filter((round) => (round.methods || []).some((m) => m === 'usability-test' || m === 'usability-inspection'))
183
+ .filter((round) => (round.methods || []).some((m) => m === 'usability-test' || m === 'usability-inspection' || m === 'expert-review'))
184
184
  .map((round) => round.id))
185
185
  const unratedFindings = (knowledge.insights || []).filter((insight) => usabilityRounds.has(insight.roundId) && !insight.polarity && !insight.rating)
186
186
  if (unratedFindings.length) {