@hippo-digital/hippocampus 2.7.2 → 2.8.0
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 +53 -0
- package/README.md +5 -4
- package/agents/knowledge-builder.md +2 -0
- package/agents/workflow-orchestrator.md +2 -0
- package/assets/dist/hippocampus.css +1 -1
- package/assets/hippocampus.scss +124 -0
- package/bin/hippocampus.js +1 -0
- package/docs/add-project-context.md +8 -2
- package/docs/ask-whats-already-known.md +6 -2
- package/docs/check-for-unintended-consequences.md +7 -2
- package/docs/data-and-governance.md +6 -2
- package/docs/describe-the-context-of-use.md +134 -0
- package/docs/design-actions-and-decisions.md +8 -3
- package/docs/hippocampus-for-designers-and-researchers.md +98 -220
- package/docs/hippocampus-technical.md +16 -0
- package/docs/human-centred-design.md +165 -0
- package/docs/import-a-research-round.md +9 -2
- package/docs/link-insights-to-needs.md +6 -2
- package/docs/record-a-usability-test.md +118 -0
- package/docs/record-design-principles.md +76 -0
- package/docs/research-knowledge-graph.md +25 -6
- package/docs/review-and-promote-a-draft.md +7 -2
- package/docs/set-quality-objectives.md +87 -0
- package/docs/source-model.md +104 -23
- package/docs/start-here.md +52 -34
- package/docs/turn-personas-into-users-and-needs.md +9 -2
- package/docs/weigh-options-against-requirements.md +96 -0
- package/docs/write-requirements.md +161 -0
- package/lib/breadcrumb.js +67 -14
- package/lib/create-router.js +90 -2
- package/lib/docs.js +28 -4
- package/lib/flow-map.js +15 -4
- package/lib/hcd-views.js +362 -0
- package/lib/known.js +5 -2
- package/lib/lint-knowledge.js +170 -1
- package/lib/load-knowledge.js +128 -5
- package/lib/record-links.js +11 -2
- package/lib/schema.js +190 -4
- package/lib/tidy-principles.js +112 -0
- package/package.json +1 -1
- package/scripts/init.js +19 -0
- package/scripts/migrate-knowledge.js +9 -1
- package/scripts/smoke-routes.js +12 -1
- package/scripts/tidy-principles.js +68 -0
- package/skills/COVERAGE-MATRIX.md +2 -0
- package/skills/README.md +5 -0
- package/skills/add-scenario/SKILL.md +4 -0
- package/skills/add-user-needs/SKILL.md +11 -1
- package/skills/create-journey-from-scenario/SKILL.md +4 -1
- package/skills/ingest-research-round/SKILL.md +3 -3
- package/skills/ingest-user-personas/SKILL.md +24 -7
- package/skills/map-research-to-graph/SKILL.md +7 -5
- package/skills/record-design-decision/SKILL.md +1 -0
- package/skills/review-research-import-draft/SKILL.md +7 -1
- package/skills/skills.json +54 -1
- package/skills/structure-research-draft/SKILL.md +12 -2
- package/skills/weigh-options-against-requirements/SKILL.md +60 -0
- package/skills/write-requirements/SKILL.md +69 -0
- package/views/hippocampus/_layout.html +15 -12
- package/views/hippocampus/components/_activity.njk +36 -0
- package/views/hippocampus/components/_journey-step.njk +30 -0
- package/views/hippocampus/context.html +197 -0
- package/views/hippocampus/design.html +128 -0
- package/views/hippocampus/evaluation.html +119 -0
- package/views/hippocampus/index.html +57 -11
- package/views/hippocampus/journey.html +25 -1
- package/views/hippocampus/journeys.html +3 -0
- package/views/hippocampus/plan.html +64 -0
- package/views/hippocampus/requirements.html +94 -0
- package/views/hippocampus/research.html +20 -1
- package/views/hippocampus/scenarios.html +3 -0
- package/views/hippocampus/user.html +43 -3
package/lib/lint-knowledge.js
CHANGED
|
@@ -2,6 +2,34 @@ const { recordSchemas, UNRESEARCHED } = require('./schema')
|
|
|
2
2
|
|
|
3
3
|
const LIST_GLYPH = /^[\s\u00a0]*[\u2022\u25cf\u25aa\u25e6\u2043\u2219\u00b7\u25cb]/
|
|
4
4
|
|
|
5
|
+
// CPUX-F: a user need is independent of any solution. It must not name the
|
|
6
|
+
// system, and the moment it names an interface element it has stopped saying
|
|
7
|
+
// what the user needs and started saying what the team would build.
|
|
8
|
+
//
|
|
9
|
+
// Tuned on 146 NCRS needs, where this flagged 32 and a read of each found 30
|
|
10
|
+
// fair. "Route" is left out on purpose: in clinical research it means a
|
|
11
|
+
// referral pathway or a way of searching, not a URL. Quoted text is ignored,
|
|
12
|
+
// because "not shown" inside a quote is the user's words, not the design.
|
|
13
|
+
const NAMES_SYSTEM = /\b(the (system|service|app|website|tool|prototype)|prototype screens?)\b/i
|
|
14
|
+
const NAMES_INTERFACE = /\b(highlight(ed|ing)?|display(ed)?|shown|screens?|pages?|buttons?|tabs?|layout|split[- ]screen|drop-?down|search box|(?<!visual )fields?|banners?|pop-?ups?|scroll(ing)?|click(ing)?|filters?|prominent|stand out|at a glance)\b/i
|
|
15
|
+
const HAS_GOAL = /\b(so that|in order to)\b/i
|
|
16
|
+
const QUOTED = /["\u201c][^"\u201d]*["\u201d]/g
|
|
17
|
+
|
|
18
|
+
// The service's own short name counts as naming the system: `shortName` if
|
|
19
|
+
// the project sets one, and any all-capitals word in its name ("NCRS patient
|
|
20
|
+
// search" gives NCRS).
|
|
21
|
+
function serviceNamesOf (project) {
|
|
22
|
+
return [project && project.shortName]
|
|
23
|
+
.concat(((project && project.name) || '').split(/\s+/).filter((word) => /^[A-Z]{2,}$/.test(word)))
|
|
24
|
+
.filter(Boolean)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function solutionWording (statement, serviceNames) {
|
|
28
|
+
const text = String(statement || '').replace(QUOTED, ' ')
|
|
29
|
+
const named = serviceNames.find((name) => new RegExp(`\\b${name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\b`, 'i').test(text))
|
|
30
|
+
return named || (text.match(NAMES_SYSTEM) || [])[0] || (text.match(NAMES_INTERFACE) || [])[0] || null
|
|
31
|
+
}
|
|
32
|
+
|
|
5
33
|
// Parsing answers "is this loadable?". Linting answers the question a team
|
|
6
34
|
// actually has: "what is thin, and what is missing?" Keeping them apart is what
|
|
7
35
|
// lets a freshly initialised project boot with nothing in it while still being
|
|
@@ -95,6 +123,147 @@ function lintKnowledge (knowledge) {
|
|
|
95
123
|
})
|
|
96
124
|
}
|
|
97
125
|
|
|
126
|
+
// ── The human-centred design layer ────────────────────────────────────
|
|
127
|
+
//
|
|
128
|
+
// All info rather than warning: every one of these is a gap a team fills
|
|
129
|
+
// over time, and a knowledge base written before the layer existed should
|
|
130
|
+
// not light up with warnings the day it upgrades.
|
|
131
|
+
|
|
132
|
+
const serviceNames = serviceNamesOf(knowledge.project)
|
|
133
|
+
const solutionNeeds = (knowledge.needs || [])
|
|
134
|
+
.map((need) => ({ need, term: solutionWording(need.statement, serviceNames) }))
|
|
135
|
+
.filter(({ term }) => term)
|
|
136
|
+
if (solutionNeeds.length) {
|
|
137
|
+
infos.push({
|
|
138
|
+
rule: 'need-names-solution',
|
|
139
|
+
count: solutionNeeds.length,
|
|
140
|
+
ids: solutionNeeds.map(({ need }) => need.id),
|
|
141
|
+
terms: Object.fromEntries(solutionNeeds.map(({ need, term }) => [need.id, term])),
|
|
142
|
+
message:
|
|
143
|
+
`${solutionNeeds.length} of ${knowledge.needs.length} needs name the service or an interface element ` +
|
|
144
|
+
'("highlighted", "the screen", "filters") - a need says what is necessary, and the design decides how'
|
|
145
|
+
})
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const goalless = (knowledge.needs || []).filter((need) => !need.goalId && !HAS_GOAL.test(need.statement || ''))
|
|
149
|
+
if (goalless.length) {
|
|
150
|
+
infos.push({
|
|
151
|
+
rule: 'need-without-goal',
|
|
152
|
+
count: goalless.length,
|
|
153
|
+
ids: goalless.map((need) => need.id),
|
|
154
|
+
message: `${goalless.length} of ${knowledge.needs.length} needs say what but not why - no "so that" and no goal`
|
|
155
|
+
})
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const untyped = (knowledge.users || []).filter((user) => !user.userType)
|
|
159
|
+
if (untyped.length && (knowledge.users || []).length) {
|
|
160
|
+
infos.push({
|
|
161
|
+
rule: 'user-without-type',
|
|
162
|
+
count: untyped.length,
|
|
163
|
+
ids: untyped.map((user) => user.id),
|
|
164
|
+
message:
|
|
165
|
+
`${untyped.length} of ${knowledge.users.length} users are not marked primary, secondary or indirect - ` +
|
|
166
|
+
'so the people who never touch the service but live with its output cannot be told apart'
|
|
167
|
+
})
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const noMethod = (knowledge.researchRounds || []).filter((round) => !(round.methods || []).length)
|
|
171
|
+
if (noMethod.length) {
|
|
172
|
+
infos.push({
|
|
173
|
+
rule: 'round-without-method',
|
|
174
|
+
count: noMethod.length,
|
|
175
|
+
ids: noMethod.map((round) => round.id),
|
|
176
|
+
message:
|
|
177
|
+
`${noMethod.length} of ${knowledge.researchRounds.length} research rounds do not say how they were run - ` +
|
|
178
|
+
'the method decides whether a finding can speak to usability'
|
|
179
|
+
})
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
const usabilityRounds = new Set((knowledge.researchRounds || [])
|
|
183
|
+
.filter((round) => (round.methods || []).some((m) => m === 'usability-test' || m === 'usability-inspection'))
|
|
184
|
+
.map((round) => round.id))
|
|
185
|
+
const unratedFindings = (knowledge.insights || []).filter((insight) => usabilityRounds.has(insight.roundId) && !insight.polarity && !insight.rating)
|
|
186
|
+
if (unratedFindings.length) {
|
|
187
|
+
infos.push({
|
|
188
|
+
rule: 'finding-without-polarity',
|
|
189
|
+
count: unratedFindings.length,
|
|
190
|
+
ids: unratedFindings.map((insight) => insight.id),
|
|
191
|
+
message:
|
|
192
|
+
`${unratedFindings.length} findings from usability rounds are not marked as a problem or a positive finding - ` +
|
|
193
|
+
'what works is what a later change breaks by accident'
|
|
194
|
+
})
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
for (const insight of knowledge.insights || []) {
|
|
198
|
+
if (insight.rating === 'catastrophic' && !insight.signedOffBy) {
|
|
199
|
+
warnings.push({
|
|
200
|
+
rule: 'catastrophic-unsigned',
|
|
201
|
+
collection: 'insights',
|
|
202
|
+
id: insight.id,
|
|
203
|
+
message:
|
|
204
|
+
`insights ${insight.id}: rated catastrophic with nobody recorded as signing it off (signedOffBy). ` +
|
|
205
|
+
'A risk of major harm is the clinical safety officer\'s call, not the research team\'s alone.'
|
|
206
|
+
})
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
const principlesAsEvidence = (knowledge.evidence || []).filter((item) => /principle/i.test(item.sourceType || ''))
|
|
211
|
+
if (principlesAsEvidence.length) {
|
|
212
|
+
warnings.push({
|
|
213
|
+
rule: 'principle-in-evidence',
|
|
214
|
+
ids: principlesAsEvidence.map((item) => item.id),
|
|
215
|
+
message:
|
|
216
|
+
`${principlesAsEvidence.length} evidence records are principles (${principlesAsEvidence.map((item) => item.id).join(', ')}). ` +
|
|
217
|
+
'Counted as evidence they inflate the research behind every step that cites them - ' +
|
|
218
|
+
'`npx hippocampus tidy principles` moves them, or names what rests on them alone.'
|
|
219
|
+
})
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
const requirements = knowledge.requirements || []
|
|
223
|
+
if (!requirements.length && (knowledge.needs || []).length) {
|
|
224
|
+
infos.push({
|
|
225
|
+
rule: 'no-requirements',
|
|
226
|
+
message:
|
|
227
|
+
'No requirements yet. A need says what is necessary; a requirement says what the user must be able to ' +
|
|
228
|
+
'recognise, select or input, precisely enough to check a design against.'
|
|
229
|
+
})
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
const placeholders = requirements.filter((req) => req.measure && req.measure.valuesStatus !== 'agreed')
|
|
233
|
+
if (placeholders.length) {
|
|
234
|
+
infos.push({
|
|
235
|
+
rule: 'requirement-placeholder-measure',
|
|
236
|
+
count: placeholders.length,
|
|
237
|
+
ids: placeholders.map((req) => req.id),
|
|
238
|
+
message: `${placeholders.length} quantitative requirements still have placeholder numbers - set them with the team and check them with users`
|
|
239
|
+
})
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
if (requirements.length) {
|
|
243
|
+
const derived = new Set(requirements.flatMap((req) => req.needIds || []))
|
|
244
|
+
for (const rel of knowledge.relationships || []) if (rel.type === 'derives-from') derived.add(rel.to)
|
|
245
|
+
const uncovered = (knowledge.needs || []).filter((need) => !derived.has(need.id))
|
|
246
|
+
if (uncovered.length) {
|
|
247
|
+
infos.push({
|
|
248
|
+
rule: 'need-without-requirement',
|
|
249
|
+
count: uncovered.length,
|
|
250
|
+
ids: uncovered.map((need) => need.id),
|
|
251
|
+
message: `${uncovered.length} of ${knowledge.needs.length} needs have no requirement yet, so no design can be checked against them`
|
|
252
|
+
})
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
const verified = new Set((knowledge.relationships || []).filter((rel) => rel.type === 'verified-by').map((rel) => rel.from))
|
|
256
|
+
const unverified = requirements.filter((req) => req.kind.startsWith('user-') && !verified.has(req.id))
|
|
257
|
+
if (unverified.length) {
|
|
258
|
+
infos.push({
|
|
259
|
+
rule: 'requirement-not-evaluated',
|
|
260
|
+
count: unverified.length,
|
|
261
|
+
ids: unverified.map((req) => req.id),
|
|
262
|
+
message: `${unverified.length} user requirements have not been evaluated - no finding says whether a design meets them`
|
|
263
|
+
})
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
98
267
|
const needsWithoutEvidence = (knowledge.needs || []).filter((need) => !(need.evidenceIds || []).length)
|
|
99
268
|
if (needsWithoutEvidence.length) {
|
|
100
269
|
infos.push({
|
|
@@ -182,4 +351,4 @@ function lintKnowledge (knowledge) {
|
|
|
182
351
|
return { warnings, infos }
|
|
183
352
|
}
|
|
184
353
|
|
|
185
|
-
module.exports = { lintKnowledge }
|
|
354
|
+
module.exports = { lintKnowledge, solutionWording, serviceNamesOf }
|
package/lib/load-knowledge.js
CHANGED
|
@@ -19,6 +19,10 @@ const files = {
|
|
|
19
19
|
participants: 'participants.json',
|
|
20
20
|
insights: 'insights.json',
|
|
21
21
|
designActions: 'design-actions.json',
|
|
22
|
+
goals: 'goals.json',
|
|
23
|
+
qualityObjectives: 'quality-objectives.json',
|
|
24
|
+
requirements: 'requirements.json',
|
|
25
|
+
principles: 'principles.json',
|
|
22
26
|
relationships: 'relationships.json'
|
|
23
27
|
}
|
|
24
28
|
|
|
@@ -136,6 +140,12 @@ function getRecordDetail (id) {
|
|
|
136
140
|
for (const screenId of record.screenIds || []) add('Screens', screenId)
|
|
137
141
|
for (const decisionId of record.decisionIds || []) add('Decisions', decisionId)
|
|
138
142
|
for (const participantId of record.participantIds || []) add('Participants', participantId)
|
|
143
|
+
for (const insightId of record.insightIds || []) add('Insights', insightId)
|
|
144
|
+
for (const requirementId of record.requirementIds || []) add('Requirements', requirementId)
|
|
145
|
+
for (const principleId of record.principleIds || []) add('Principles', principleId)
|
|
146
|
+
if (record.goalId) add('Goal', record.goalId)
|
|
147
|
+
if (record.userGroupId) add('User group', record.userGroupId)
|
|
148
|
+
if (record.measure && record.measure.userId) add('Measured with', record.measure.userId)
|
|
139
149
|
if (record.userId) add('User', record.userId)
|
|
140
150
|
if (record.scenarioId) add('Scenario', record.scenarioId)
|
|
141
151
|
if (record.roundId) add('Research round', record.roundId)
|
|
@@ -146,7 +156,8 @@ function getRecordDetail (id) {
|
|
|
146
156
|
for (const journey of knowledge.journeys || []) {
|
|
147
157
|
for (const step of journey.steps || []) {
|
|
148
158
|
const mentions = [...(step.needIds || []), ...(step.screenIds || []),
|
|
149
|
-
...(step.evidenceIds || []), ...(step.decisionIds || [])
|
|
159
|
+
...(step.evidenceIds || []), ...(step.decisionIds || []),
|
|
160
|
+
...(step.requirementIds || []), ...(step.principleIds || [])]
|
|
150
161
|
if (mentions.includes(id)) add('Journeys', journey.id)
|
|
151
162
|
}
|
|
152
163
|
}
|
|
@@ -181,7 +192,15 @@ const OUTWARD = {
|
|
|
181
192
|
'uses-evidence': 'Evidence used',
|
|
182
193
|
'renders-screen': 'Screens rendered',
|
|
183
194
|
'drives-journey': 'Journeys driven',
|
|
184
|
-
'records-decision': 'Decisions recorded'
|
|
195
|
+
'records-decision': 'Decisions recorded',
|
|
196
|
+
'derives-from': 'Derived from needs',
|
|
197
|
+
'based-on-insight': 'Based on insights',
|
|
198
|
+
'constrained-by': 'Constrained by',
|
|
199
|
+
'refines-objective': 'Quality objectives this makes measurable',
|
|
200
|
+
'verified-by': 'Evaluated by',
|
|
201
|
+
'weighed-against': 'Requirements this was weighed against',
|
|
202
|
+
'applies-principle': 'Principles applied',
|
|
203
|
+
'observed-on': 'Seen on screens'
|
|
185
204
|
}
|
|
186
205
|
|
|
187
206
|
const INWARD = {
|
|
@@ -198,7 +217,15 @@ const INWARD = {
|
|
|
198
217
|
'uses-evidence': 'Used by',
|
|
199
218
|
'renders-screen': 'Rendered by',
|
|
200
219
|
'drives-journey': 'Driven by',
|
|
201
|
-
'records-decision': 'Recorded by'
|
|
220
|
+
'records-decision': 'Recorded by',
|
|
221
|
+
'derives-from': 'Requirements derived from this',
|
|
222
|
+
'based-on-insight': 'Requirements based on this',
|
|
223
|
+
'constrained-by': 'Requirements this constrains',
|
|
224
|
+
'refines-objective': 'Measured by',
|
|
225
|
+
'verified-by': 'Requirements this evaluated',
|
|
226
|
+
'weighed-against': 'Options weighed against this',
|
|
227
|
+
'applies-principle': 'Applied by',
|
|
228
|
+
'observed-on': 'Findings seen here'
|
|
202
229
|
}
|
|
203
230
|
|
|
204
231
|
function outwardLabel (type) { return OUTWARD[type] || type }
|
|
@@ -207,7 +234,8 @@ function inwardLabel (type) { return INWARD[type] || type }
|
|
|
207
234
|
function findRecord (knowledge, id) {
|
|
208
235
|
for (const collection of ['needs', 'insights', 'screens', 'users', 'scenarios',
|
|
209
236
|
'journeys', 'evidence', 'decisions', 'assumptions', 'researchRounds',
|
|
210
|
-
'participants', 'designActions'
|
|
237
|
+
'participants', 'designActions', 'goals', 'qualityObjectives',
|
|
238
|
+
'requirements', 'principles']) {
|
|
211
239
|
const found = (knowledge[collection] || []).find((item) => item.id === id)
|
|
212
240
|
if (found) return found
|
|
213
241
|
}
|
|
@@ -228,6 +256,10 @@ function buildIndex (knowledge) {
|
|
|
228
256
|
participants: byId(knowledge.participants),
|
|
229
257
|
insights: byId(knowledge.insights),
|
|
230
258
|
designActions: byId(knowledge.designActions),
|
|
259
|
+
goals: byId(knowledge.goals || []),
|
|
260
|
+
qualityObjectives: byId(knowledge.qualityObjectives || []),
|
|
261
|
+
requirements: byId(knowledge.requirements || []),
|
|
262
|
+
principles: byId(knowledge.principles || []),
|
|
231
263
|
relationships: byId(knowledge.relationships)
|
|
232
264
|
}
|
|
233
265
|
index.entities = buildEntityIndex(knowledge)
|
|
@@ -251,7 +283,11 @@ function buildEntityIndex (knowledge) {
|
|
|
251
283
|
researchRounds: { type: 'Research round', labelKey: 'title' },
|
|
252
284
|
participants: { type: 'Participant', labelKey: 'label' },
|
|
253
285
|
insights: { type: 'Insight', labelKey: 'title' },
|
|
254
|
-
designActions: { type: 'Design action', labelKey: 'title' }
|
|
286
|
+
designActions: { type: 'Design action', labelKey: 'title' },
|
|
287
|
+
goals: { type: 'Goal', labelKey: 'statement' },
|
|
288
|
+
qualityObjectives: { type: 'Quality objective', labelKey: 'statement' },
|
|
289
|
+
requirements: { type: 'Requirement', labelKey: 'statement' },
|
|
290
|
+
principles: { type: 'Principle', labelKey: 'title' }
|
|
255
291
|
}
|
|
256
292
|
|
|
257
293
|
const entities = {}
|
|
@@ -875,14 +911,101 @@ function validateKnowledge () {
|
|
|
875
911
|
for (const insightId of action.insightIds || []) requireRef(errors, 'design action', action.id, 'insightIds', insightId, index.insights)
|
|
876
912
|
}
|
|
877
913
|
|
|
914
|
+
for (const user of knowledge.users) {
|
|
915
|
+
if (user.userGroupId) requireRef(errors, 'user', user.id, 'userGroupId', user.userGroupId, index.users)
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
for (const goal of knowledge.goals) {
|
|
919
|
+
requireRef(errors, 'goal', goal.id, 'userId', goal.userId, index.users)
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
for (const need of knowledge.needs) {
|
|
923
|
+
if (need.goalId) requireRef(errors, 'need', need.id, 'goalId', need.goalId, index.goals)
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
for (const scenario of knowledge.scenarios) {
|
|
927
|
+
if (scenario.goalId) requireRef(errors, 'scenario', scenario.id, 'goalId', scenario.goalId, index.goals)
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
for (const journey of knowledge.journeys) {
|
|
931
|
+
for (const step of journey.steps || []) {
|
|
932
|
+
for (const requirementId of step.requirementIds || []) requireRef(errors, 'journey step', step.id, 'requirementIds', requirementId, index.requirements)
|
|
933
|
+
for (const principleId of step.principleIds || []) requireRef(errors, 'journey step', step.id, 'principleIds', principleId, index.principles)
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
for (const participant of knowledge.participants) {
|
|
938
|
+
if (participant.userId) requireRef(errors, 'participant', participant.id, 'userId', participant.userId, index.users)
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
for (const requirement of knowledge.requirements) {
|
|
942
|
+
for (const needId of requirement.needIds || []) requireRef(errors, 'requirement', requirement.id, 'needIds', needId, index.needs)
|
|
943
|
+
for (const insightId of requirement.insightIds || []) requireRef(errors, 'requirement', requirement.id, 'insightIds', insightId, index.insights)
|
|
944
|
+
if (requirement.measure && requirement.measure.userId) {
|
|
945
|
+
requireRef(errors, 'requirement', requirement.id, 'measure.userId', requirement.measure.userId, index.users)
|
|
946
|
+
}
|
|
947
|
+
errors.push(...requirementKindErrors(requirement))
|
|
948
|
+
}
|
|
949
|
+
|
|
878
950
|
for (const relationship of knowledge.relationships) {
|
|
879
951
|
requireRef(errors, 'relationship', relationship.id, 'from', relationship.from, index.entities)
|
|
880
952
|
requireRef(errors, 'relationship', relationship.id, 'to', relationship.to, index.entities)
|
|
953
|
+
const rule = RELATIONSHIP_ENDS[relationship.type]
|
|
954
|
+
const from = index.entities[relationship.from]
|
|
955
|
+
const to = index.entities[relationship.to]
|
|
956
|
+
if (rule && from && to && (!rule.from.includes(from.collection) || !rule.to.includes(to.collection))) {
|
|
957
|
+
errors.push(
|
|
958
|
+
`relationship ${relationship.id}: ${relationship.type} runs from ${rule.from.join(' or ')} ` +
|
|
959
|
+
`to ${rule.to.join(' or ')}, but this one runs from ${from.collection} to ${to.collection}`
|
|
960
|
+
)
|
|
961
|
+
}
|
|
881
962
|
}
|
|
882
963
|
|
|
883
964
|
return { valid: errors.length === 0, errors, sourcesUpdatedAt: sourcesUpdatedAt() }
|
|
884
965
|
}
|
|
885
966
|
|
|
967
|
+
// Where each of the requirements-layer links may start and end. The older link
|
|
968
|
+
// types predate this and are not checked; these are, because a link written
|
|
969
|
+
// the wrong way round does not fail - impact walks silently stop at it.
|
|
970
|
+
const RELATIONSHIP_ENDS = {
|
|
971
|
+
'derives-from': { from: ['requirements'], to: ['needs'] },
|
|
972
|
+
'based-on-insight': { from: ['requirements'], to: ['insights'] },
|
|
973
|
+
'constrained-by': { from: ['requirements'], to: ['requirements'] },
|
|
974
|
+
'refines-objective': { from: ['requirements'], to: ['qualityObjectives'] },
|
|
975
|
+
'verified-by': { from: ['requirements'], to: ['insights'] },
|
|
976
|
+
'weighed-against': { from: ['decisions'], to: ['requirements'] },
|
|
977
|
+
'applies-principle': { from: ['screens', 'requirements', 'decisions', 'journeys'], to: ['principles'] },
|
|
978
|
+
'observed-on': { from: ['insights'], to: ['screens'] }
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
/**
|
|
982
|
+
* The rules that tie a requirement's fields to its kind.
|
|
983
|
+
*
|
|
984
|
+
* A user requirement exists to meet a user need, so it names one. An
|
|
985
|
+
* organisational requirement comes from a rule rather than from users, so it
|
|
986
|
+
* names where the rule comes from instead. A qualitative requirement says what
|
|
987
|
+
* the user must recognise, select or input; a quantitative one says how it is
|
|
988
|
+
* measured. These are checked here rather than in the schema so the message
|
|
989
|
+
* can name the record.
|
|
990
|
+
*/
|
|
991
|
+
function requirementKindErrors (requirement) {
|
|
992
|
+
const errors = []
|
|
993
|
+
const at = `requirement ${requirement.id}`
|
|
994
|
+
if (requirement.kind.startsWith('user-') && !(requirement.needIds || []).length) {
|
|
995
|
+
errors.push(`${at}: a user requirement names the user need it meets (needIds)`)
|
|
996
|
+
}
|
|
997
|
+
if ((requirement.kind === 'organisational' || requirement.kind === 'market') && !requirement.source) {
|
|
998
|
+
errors.push(`${at}: an ${requirement.kind} requirement says where the rule comes from (source)`)
|
|
999
|
+
}
|
|
1000
|
+
if (requirement.kind === 'user-qualitative' && !requirement.verb) {
|
|
1001
|
+
errors.push(`${at}: a qualitative requirement says whether the user must recognise, select or input (verb)`)
|
|
1002
|
+
}
|
|
1003
|
+
if (requirement.kind === 'user-quantitative' && !requirement.measure) {
|
|
1004
|
+
errors.push(`${at}: a quantitative requirement says how it is measured (measure)`)
|
|
1005
|
+
}
|
|
1006
|
+
return errors
|
|
1007
|
+
}
|
|
1008
|
+
|
|
886
1009
|
function requireRef (errors, type, id, field, value, lookup) {
|
|
887
1010
|
if (!lookup[value]) errors.push(`${type} ${id}: ${field} references missing id ${value}`)
|
|
888
1011
|
}
|
package/lib/record-links.js
CHANGED
|
@@ -16,8 +16,12 @@ const ROUTES = {
|
|
|
16
16
|
Screen: (id) => `/screens/${id}`,
|
|
17
17
|
Journey: (id) => `/journeys/${id}`,
|
|
18
18
|
Evidence: (id) => `/evidence/${id}/impact`,
|
|
19
|
+
Goal: (id) => `/goals/${id}`,
|
|
20
|
+
Requirement: (id) => `/requirements/${id}`,
|
|
21
|
+
Principle: (id) => `/principles/${id}`,
|
|
22
|
+
'Quality objective': (id) => `/objectives/${id}`,
|
|
23
|
+
Decision: (id) => `/decisions/${id}`,
|
|
19
24
|
Scenario: null,
|
|
20
|
-
Decision: null,
|
|
21
25
|
Assumption: null,
|
|
22
26
|
'Research round': null,
|
|
23
27
|
Participant: null,
|
|
@@ -34,7 +38,12 @@ const LIST_ROUTES = {
|
|
|
34
38
|
Screen: '/screens',
|
|
35
39
|
Journey: '/journeys',
|
|
36
40
|
Insight: '/research',
|
|
37
|
-
'Research round': '/research'
|
|
41
|
+
'Research round': '/research',
|
|
42
|
+
Goal: '/context',
|
|
43
|
+
Requirement: '/requirements',
|
|
44
|
+
Principle: '/design',
|
|
45
|
+
Decision: '/design',
|
|
46
|
+
'Quality objective': '/plan'
|
|
38
47
|
}
|
|
39
48
|
|
|
40
49
|
function listHrefFor (type, basePath = '') {
|