@hippo-digital/hippocampus 2.0.1 → 2.2.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 +97 -0
- package/README.md +2 -0
- package/agents/knowledge-builder.md +2 -0
- package/agents/workflow-orchestrator.md +2 -0
- package/bin/hippocampus.js +2 -0
- package/lib/consequences.js +348 -0
- package/lib/known.js +258 -0
- package/package.json +1 -1
- package/scripts/audit-provenance.js +1 -1
- package/scripts/consequences.js +147 -0
- package/scripts/known.js +118 -0
- package/skills/find-unintended-consequences/SKILL.md +124 -0
- package/skills/skills.json +59 -0
- package/skills/whats-known-about/SKILL.md +113 -0
package/lib/known.js
ADDED
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
// "What do we already know about this?" answered from the knowledge base, so
|
|
2
|
+
// that nobody finds something out for a second time.
|
|
3
|
+
//
|
|
4
|
+
// Three things make an answer like this trustworthy, and each one is easy to
|
|
5
|
+
// lose in a summary:
|
|
6
|
+
//
|
|
7
|
+
// - Every claim keeps its own date, confidence and research round. Two rounds
|
|
8
|
+
// agreeing is a stronger finding than one sentence that hides both, and an
|
|
9
|
+
// old low-confidence insight is not the same fact as a recent strong one.
|
|
10
|
+
// - Assumptions are kept apart from findings. An assumption is a belief the
|
|
11
|
+
// design rests on; reporting one as research is the failure this knowledge
|
|
12
|
+
// base exists to stop.
|
|
13
|
+
// - Finding nothing is an answer. Which rounds exist, which of them produced
|
|
14
|
+
// nothing in the knowledge base, and which held files were never ingested
|
|
15
|
+
// all decide whether "nothing found" means "nobody asked".
|
|
16
|
+
|
|
17
|
+
// Evidence whose source type says it is an assertion rather than a finding.
|
|
18
|
+
// Shared with `source audit`, which classes unsourced evidence the same way.
|
|
19
|
+
const ASSERTION_TYPES = /assumption|principle|decision|local repo reference/i
|
|
20
|
+
|
|
21
|
+
// The fields a topic is usually named in. Titles alone miss most of it: the
|
|
22
|
+
// topic is normally in the body of a record, not its heading.
|
|
23
|
+
const SEARCH_FIELDS = {
|
|
24
|
+
evidence: ['title', 'summary', 'quotes'],
|
|
25
|
+
insights: ['title', 'summary'],
|
|
26
|
+
needs: ['statement'],
|
|
27
|
+
assumptions: ['statement'],
|
|
28
|
+
scenarios: ['title', 'trigger', 'context', 'happyPath', 'edgeCases'],
|
|
29
|
+
designActions: ['title', 'action', 'rationale'],
|
|
30
|
+
decisions: ['title', 'decision', 'consequence'],
|
|
31
|
+
screens: ['title', 'purpose'],
|
|
32
|
+
journeys: ['title', 'description']
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// The kinds of record that are design work - things someone would build twice
|
|
36
|
+
// if they did not know they existed.
|
|
37
|
+
const BUILT_TYPES = new Set(['screens', 'journeys', 'designActions', 'decisions'])
|
|
38
|
+
const FINDING_TYPES = new Set(['insights', 'evidence'])
|
|
39
|
+
|
|
40
|
+
function escapeRegex (text) {
|
|
41
|
+
return text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Match at the start of a word, so "postcode" finds "postcodes" but "age" does
|
|
45
|
+
// not find "page".
|
|
46
|
+
function matcher (terms) {
|
|
47
|
+
const patterns = terms.map((term) => ({ term, re: new RegExp(`\\b${escapeRegex(term)}`, 'i') }))
|
|
48
|
+
return (text) => patterns.filter(({ re }) => re.test(text)).map(({ term }) => term)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function textOf (record, fields) {
|
|
52
|
+
return fields.map((field) => {
|
|
53
|
+
const value = record[field]
|
|
54
|
+
return Array.isArray(value) ? value.join(' ') : (value == null ? '' : String(value))
|
|
55
|
+
}).join(' ')
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Edges pointing from a record to what was built on it. The schema's
|
|
59
|
+
// relationship rows point dependents at what they rely on for some types and
|
|
60
|
+
// the other way round for others, and some links live only in id-list fields,
|
|
61
|
+
// so this spells out each one rather than walking rows blindly. Provenance
|
|
62
|
+
// (who said it, which round) is deliberately absent: a round is not relevant
|
|
63
|
+
// because something drawn from it was.
|
|
64
|
+
function buildForwardEdges (knowledge) {
|
|
65
|
+
const forward = new Map()
|
|
66
|
+
const add = (from, to) => {
|
|
67
|
+
if (!from || !to || from === to) return
|
|
68
|
+
if (!forward.has(from)) forward.set(from, new Set())
|
|
69
|
+
forward.get(from).add(to)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
for (const rel of knowledge.relationships || []) {
|
|
73
|
+
switch (rel.type) {
|
|
74
|
+
case 'supported-by': // need/insight supported by evidence
|
|
75
|
+
case 'uses-evidence':
|
|
76
|
+
case 'supports-insight':
|
|
77
|
+
case 'responds-to-insight': // design action responds to insight
|
|
78
|
+
case 'resolves-action': // decision resolves design action
|
|
79
|
+
case 'addresses-need': // screen addresses need
|
|
80
|
+
case 'renders-screen':
|
|
81
|
+
case 'records-decision':
|
|
82
|
+
add(rel.to, rel.from)
|
|
83
|
+
break
|
|
84
|
+
case 'tests-need': // insight or scenario tests a need
|
|
85
|
+
case 'leads-to-action':
|
|
86
|
+
case 'drives-journey':
|
|
87
|
+
add(rel.from, rel.to)
|
|
88
|
+
break
|
|
89
|
+
default:
|
|
90
|
+
break
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
for (const need of knowledge.needs || []) for (const id of need.evidenceIds || []) add(id, need.id)
|
|
95
|
+
for (const insight of knowledge.insights || []) for (const id of insight.evidenceIds || []) add(id, insight.id)
|
|
96
|
+
for (const scenario of knowledge.scenarios || []) for (const id of scenario.needIds || []) add(scenario.id, id)
|
|
97
|
+
for (const screen of knowledge.screens || []) for (const id of screen.needIds || []) add(id, screen.id)
|
|
98
|
+
for (const action of knowledge.designActions || []) for (const id of action.insightIds || []) add(id, action.id)
|
|
99
|
+
for (const journey of knowledge.journeys || []) {
|
|
100
|
+
for (const step of journey.steps || []) {
|
|
101
|
+
for (const id of [...(step.needIds || []), ...(step.screenIds || []), ...(step.evidenceIds || []), ...(step.decisionIds || [])]) {
|
|
102
|
+
add(id, journey.id)
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return forward
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function collectionIndex (knowledge) {
|
|
110
|
+
const where = new Map()
|
|
111
|
+
for (const collection of Object.keys(SEARCH_FIELDS).concat(['researchRounds', 'participants', 'users'])) {
|
|
112
|
+
for (const record of knowledge[collection] || []) where.set(record.id, { collection, record })
|
|
113
|
+
}
|
|
114
|
+
return where
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function roundOf (knowledge, roundId) {
|
|
118
|
+
const round = (knowledge.researchRounds || []).find((r) => r.id === roundId)
|
|
119
|
+
return round ? { id: round.id, title: round.title, date: round.date } : null
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function labelOf (collection, record) {
|
|
123
|
+
return record.title || record.statement || record.label || record.id
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* @param {object} knowledge from store.getKnowledge()
|
|
128
|
+
* @param {string[]} terms words or phrases; a record matches on any of them
|
|
129
|
+
* @param {object} [options]
|
|
130
|
+
* @param {Array} [options.sourceArtefacts] entries from manifests/source-index.json
|
|
131
|
+
* @param {number} [options.hops=3] how far to follow what was built
|
|
132
|
+
*/
|
|
133
|
+
function whatsKnown (knowledge, terms, { sourceArtefacts = [], hops = 3 } = {}) {
|
|
134
|
+
const cleaned = terms.map((t) => t.trim()).filter(Boolean)
|
|
135
|
+
if (!cleaned.length) throw new Error('Give at least one word or phrase to look for.')
|
|
136
|
+
const match = matcher(cleaned)
|
|
137
|
+
const where = collectionIndex(knowledge)
|
|
138
|
+
|
|
139
|
+
const matched = new Map()
|
|
140
|
+
for (const [collection, fields] of Object.entries(SEARCH_FIELDS)) {
|
|
141
|
+
for (const record of knowledge[collection] || []) {
|
|
142
|
+
const hits = match(textOf(record, fields))
|
|
143
|
+
if (hits.length) matched.set(record.id, { collection, record, terms: hits })
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const findings = []
|
|
148
|
+
const assumptions = []
|
|
149
|
+
const needs = []
|
|
150
|
+
const scenarios = []
|
|
151
|
+
const design = []
|
|
152
|
+
|
|
153
|
+
for (const { collection, record, terms: hits } of matched.values()) {
|
|
154
|
+
const base = { id: record.id, label: labelOf(collection, record), terms: hits }
|
|
155
|
+
if (collection === 'insights') {
|
|
156
|
+
findings.push({
|
|
157
|
+
...base,
|
|
158
|
+
kind: 'insight',
|
|
159
|
+
confidence: record.confidence,
|
|
160
|
+
round: roundOf(knowledge, record.roundId),
|
|
161
|
+
participants: (record.participantIds || []).length
|
|
162
|
+
})
|
|
163
|
+
} else if (collection === 'evidence') {
|
|
164
|
+
const entry = { ...base, kind: 'evidence', sourceType: record.sourceType, confidence: record.confidence, sourcePath: record.sourcePath || null }
|
|
165
|
+
if (ASSERTION_TYPES.test(record.sourceType || '')) assumptions.push({ ...entry, kind: 'evidence recorded as an assertion' })
|
|
166
|
+
else findings.push(entry)
|
|
167
|
+
} else if (collection === 'assumptions') {
|
|
168
|
+
assumptions.push({ ...base, kind: 'assumption', risk: record.risk })
|
|
169
|
+
} else if (collection === 'needs') {
|
|
170
|
+
needs.push({ ...base, priority: record.priority })
|
|
171
|
+
} else if (collection === 'scenarios') {
|
|
172
|
+
scenarios.push({ ...base, riskLevel: record.riskLevel || null })
|
|
173
|
+
} else {
|
|
174
|
+
design.push({ ...base, kind: collection, status: record.status || null })
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// Oldest round first, then by strength, so agreement across rounds reads as
|
|
179
|
+
// a sequence rather than being folded into one line.
|
|
180
|
+
const confidenceRank = { high: 0, medium: 1, low: 2 }
|
|
181
|
+
findings.sort((a, b) =>
|
|
182
|
+
`${a.round?.date || '9999'}`.localeCompare(`${b.round?.date || '9999'}`) ||
|
|
183
|
+
(confidenceRank[a.confidence] ?? 3) - (confidenceRank[b.confidence] ?? 3) ||
|
|
184
|
+
a.id.localeCompare(b.id))
|
|
185
|
+
|
|
186
|
+
// What already exists because of these records, found by following each
|
|
187
|
+
// one forward a bounded number of steps. Needs reached on the way are
|
|
188
|
+
// reported too: they are what the findings were turned into.
|
|
189
|
+
const forward = buildForwardEdges(knowledge)
|
|
190
|
+
const reached = new Map()
|
|
191
|
+
let frontier = [...matched.keys()]
|
|
192
|
+
const seen = new Set(frontier)
|
|
193
|
+
for (let step = 1; step <= hops && frontier.length; step++) {
|
|
194
|
+
const next = []
|
|
195
|
+
for (const from of frontier) {
|
|
196
|
+
for (const to of forward.get(from) || []) {
|
|
197
|
+
if (seen.has(to)) continue
|
|
198
|
+
seen.add(to)
|
|
199
|
+
next.push(to)
|
|
200
|
+
const found = where.get(to)
|
|
201
|
+
if (!found) continue
|
|
202
|
+
const origin = matched.has(from) ? from : reached.get(from)?.via
|
|
203
|
+
const originCollection = matched.has(from) ? matched.get(from).collection : reached.get(from)?.originCollection
|
|
204
|
+
reached.set(to, { ...found, via: origin, originCollection, step })
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
frontier = next
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
const builtOn = []
|
|
211
|
+
const needsReached = []
|
|
212
|
+
for (const [id, { collection, record, via, originCollection, step }] of reached) {
|
|
213
|
+
const entry = { id, label: labelOf(collection, record), via, steps: step }
|
|
214
|
+
if (BUILT_TYPES.has(collection)) builtOn.push({ ...entry, kind: collection, status: record.status || null })
|
|
215
|
+
// Only needs a finding leads to. A scenario that names the topic usually
|
|
216
|
+
// tests a dozen needs about other things, and listing them all buries the
|
|
217
|
+
// few the research actually supports.
|
|
218
|
+
else if (collection === 'needs' && FINDING_TYPES.has(originCollection)) needsReached.push({ ...entry, priority: record.priority })
|
|
219
|
+
}
|
|
220
|
+
const byKind = (a, b) => `${a.kind || ''}:${a.id}`.localeCompare(`${b.kind || ''}:${b.id}`)
|
|
221
|
+
builtOn.sort(byKind)
|
|
222
|
+
needsReached.sort(byKind)
|
|
223
|
+
|
|
224
|
+
// Coverage: whether "nothing found" can be read as "nobody asked".
|
|
225
|
+
const insightCount = new Map()
|
|
226
|
+
for (const insight of knowledge.insights || []) insightCount.set(insight.roundId, (insightCount.get(insight.roundId) || 0) + 1)
|
|
227
|
+
const roundsWithFindings = new Set(findings.filter((f) => f.round).map((f) => f.round.id))
|
|
228
|
+
const rounds = (knowledge.researchRounds || []).map((round) => ({
|
|
229
|
+
id: round.id,
|
|
230
|
+
title: round.title,
|
|
231
|
+
date: round.date,
|
|
232
|
+
insights: insightCount.get(round.id) || 0,
|
|
233
|
+
matchedFindings: findings.filter((f) => f.round?.id === round.id).length,
|
|
234
|
+
namesTopic: match(textOf(round, ['title', 'summary', 'focus'])).length > 0
|
|
235
|
+
})).sort((a, b) => `${a.date}`.localeCompare(`${b.date}`))
|
|
236
|
+
|
|
237
|
+
const nearestRounds = rounds.filter((r) => r.namesTopic && !roundsWithFindings.has(r.id))
|
|
238
|
+
const emptyRounds = rounds.filter((r) => r.insights === 0)
|
|
239
|
+
const unIngested = sourceArtefacts
|
|
240
|
+
.filter((a) => !a.ingestedAs && !(a.citedBy || []).length)
|
|
241
|
+
.filter((a) => match(`${a.path || ''} ${a.fileName || ''}`.replace(/[-_./]/g, ' ')).length)
|
|
242
|
+
.map((a) => ({ path: a.path, roundId: a.roundId || null }))
|
|
243
|
+
|
|
244
|
+
return {
|
|
245
|
+
terms: cleaned,
|
|
246
|
+
findings,
|
|
247
|
+
assumptions,
|
|
248
|
+
needs,
|
|
249
|
+
needsReached,
|
|
250
|
+
scenarios,
|
|
251
|
+
design,
|
|
252
|
+
builtOn,
|
|
253
|
+
coverage: { rounds, roundsWithFindings: [...roundsWithFindings], nearestRounds, emptyRounds, unIngested },
|
|
254
|
+
nothingFound: matched.size === 0
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
module.exports = { whatsKnown, ASSERTION_TYPES, SEARCH_FIELDS }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hippo-digital/hippocampus",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "A design-knowledge base for NHS Prototype Kit projects: research, insights, needs, journeys and screens, traceable end to end.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "index.js",
|
|
@@ -22,7 +22,7 @@ const ctx = createContextOrExit({ argv })
|
|
|
22
22
|
// gestures at a folder. `Round 4 - ...` is the shape that fails: it looks like a
|
|
23
23
|
// citation and identifies nothing.
|
|
24
24
|
const VAGUE = [/\.\.\./, /^\s*$/, /\*/]
|
|
25
|
-
const ASSERTION_TYPES = /
|
|
25
|
+
const { ASSERTION_TYPES } = require('../lib/known')
|
|
26
26
|
|
|
27
27
|
function main () {
|
|
28
28
|
const project = ctx.requireProjects()[0]
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const { createContextOrExit } = require('../lib/context')
|
|
3
|
+
const { checkConsequences } = require('../lib/consequences')
|
|
4
|
+
|
|
5
|
+
// hippocampus consequences <scenario-id> [--json] [--all]
|
|
6
|
+
//
|
|
7
|
+
// Run a new or changed journey against the users the knowledge base already
|
|
8
|
+
// knows: who stands on the same ground, which decisions were already taken
|
|
9
|
+
// there, which parts of the ground are weak, and which questions every new kind
|
|
10
|
+
// of user raises that nobody may have asked. Lists candidates, not verdicts -
|
|
11
|
+
// see the find-unintended-consequences skill for the judgement. Always exits 0
|
|
12
|
+
// when the knowledge base loads and the scenario exists.
|
|
13
|
+
|
|
14
|
+
const argv = process.argv.slice(2)
|
|
15
|
+
const ctx = createContextOrExit({ argv })
|
|
16
|
+
|
|
17
|
+
const flags = { json: false, all: false }
|
|
18
|
+
const args = []
|
|
19
|
+
for (let i = 0; i < argv.length; i++) {
|
|
20
|
+
const arg = argv[i]
|
|
21
|
+
if (arg === '--root') { i++; continue }
|
|
22
|
+
if (arg.startsWith('--root=')) continue
|
|
23
|
+
if (arg === '--json') flags.json = true
|
|
24
|
+
else if (arg === '--all') flags.all = true
|
|
25
|
+
else if (arg.startsWith('--')) { console.error(`Unknown option: ${arg}`); process.exit(1) }
|
|
26
|
+
else args.push(arg)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const project = ctx.requireProjects()[0]
|
|
30
|
+
const knowledge = project.store.getKnowledge()
|
|
31
|
+
|
|
32
|
+
if (args.length !== 1) {
|
|
33
|
+
console.error('Usage: hippocampus consequences <scenario-id> [--json] [--all]')
|
|
34
|
+
const scenarios = knowledge.scenarios || []
|
|
35
|
+
if (scenarios.length) {
|
|
36
|
+
console.error('\nScenarios in this knowledge base:')
|
|
37
|
+
for (const s of scenarios) console.error(` ${s.id} (${s.userId})`)
|
|
38
|
+
}
|
|
39
|
+
process.exit(1)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
let result
|
|
43
|
+
try {
|
|
44
|
+
result = checkConsequences(knowledge, args[0])
|
|
45
|
+
} catch (error) {
|
|
46
|
+
console.error(error.message)
|
|
47
|
+
process.exit(1)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (flags.json) {
|
|
51
|
+
console.log(JSON.stringify(result, null, 2))
|
|
52
|
+
process.exit(0)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const LIMIT = flags.all ? Infinity : 25
|
|
56
|
+
const clip = (text, n = 108) => (text && text.length > n ? `${text.slice(0, n - 1)}…` : text || '')
|
|
57
|
+
const roundLabel = (round) => (round ? `${round.title}, ${round.date}` : 'no research round')
|
|
58
|
+
let clipped = false
|
|
59
|
+
|
|
60
|
+
function section (title, items, render, note) {
|
|
61
|
+
if (!items.length) return
|
|
62
|
+
console.log(`\n${title} (${items.length})${note ? ` - ${note}` : ''}`)
|
|
63
|
+
for (const item of items.slice(0, LIMIT)) console.log(render(item))
|
|
64
|
+
if (items.length > LIMIT) {
|
|
65
|
+
clipped = true
|
|
66
|
+
console.log(` ... and ${items.length - LIMIT} more`)
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const { scenario, persona } = result
|
|
71
|
+
console.log('Checking a journey against the users we already know')
|
|
72
|
+
console.log(` ${scenario.title}`)
|
|
73
|
+
console.log(` ${scenario.id} · ${scenario.userLabel} (${scenario.userId})`)
|
|
74
|
+
console.log(` (${ctx.root}, ${result.researchRounds} research rounds)`)
|
|
75
|
+
|
|
76
|
+
console.log('\nThis user in the research')
|
|
77
|
+
if (persona.participants.length) {
|
|
78
|
+
console.log(` ${persona.participants.length} participant(s) whose role matches "${persona.matchedOn.join('", "')}", in ${persona.rounds.length} round(s): ` +
|
|
79
|
+
persona.rounds.map((r) => `${r.title} (${r.date})`).join('; '))
|
|
80
|
+
} else {
|
|
81
|
+
console.log(` No participant's role matches "${persona.matchedOn.join('", "')}". No round has included this kind of user,`)
|
|
82
|
+
console.log(' so every need below rests on evidence gathered from other roles. Matched on role names.')
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const standsOn = [
|
|
86
|
+
...result.ground.map((g) => ({ ...g, kind: 'evidence' })),
|
|
87
|
+
...result.groundInsights.map((i) => ({ ...i, kind: 'insight' }))
|
|
88
|
+
]
|
|
89
|
+
section('What this journey stands on', standsOn, (g) => g.kind === 'insight'
|
|
90
|
+
? ` insight ${g.id} [${g.confidence}, ${roundLabel(g.round)}]\n tests ${g.testsNeeds.join(', ')}`
|
|
91
|
+
: g.assertion
|
|
92
|
+
? ` evidence ${g.id} [${g.sourceType} - an assertion, not a finding]\n cited by ${g.citedBy.join(', ')}`
|
|
93
|
+
: ` evidence ${g.id} [${g.confidence}, ${g.sourceType}]\n cited by ${g.citedBy.join(', ')}`,
|
|
94
|
+
'the evidence under this journey\'s own needs, and the insights that test them')
|
|
95
|
+
|
|
96
|
+
const needCount = result.reaches.reduce((n, u) => n + u.needs.length, 0)
|
|
97
|
+
if (result.reaches.length) {
|
|
98
|
+
console.log(`\nUsers we already know who stand on the same ground (${result.reaches.length} roles, ${needCount} needs)`)
|
|
99
|
+
for (const user of result.reaches) {
|
|
100
|
+
console.log(` ${user.label} (${user.userId})`)
|
|
101
|
+
for (const need of user.needs.slice(0, LIMIT)) {
|
|
102
|
+
console.log(` ${need.id} [${need.priority}]\n ${clip(need.label, 100)}\n via ${need.via.join(', ')}`)
|
|
103
|
+
}
|
|
104
|
+
if (user.needs.length > LIMIT) { clipped = true; console.log(` ... and ${user.needs.length - LIMIT} more`) }
|
|
105
|
+
}
|
|
106
|
+
} else {
|
|
107
|
+
console.log('\nNo other user\'s needs stand on this ground.')
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
section('Design actions already responding to this ground', result.designActions,
|
|
111
|
+
(a) => ` [${(a.status || 'no status').padEnd(11)}] ${a.id}\n ${clip(a.label, 100)}\n via ${a.via.join(', ')}`)
|
|
112
|
+
|
|
113
|
+
section('Decisions already taken on this ground', result.decisions,
|
|
114
|
+
(d) => ` [${(d.status || 'no status').padEnd(8)}] ${d.id}\n ${clip(d.label, 100)}\n via ${d.via.join(', ')}`,
|
|
115
|
+
'check the journey against each one')
|
|
116
|
+
|
|
117
|
+
section('Weak ground', [
|
|
118
|
+
...result.weakGround.assumptions.map((a) => ({ ...a, kind: 'assumption' })),
|
|
119
|
+
...result.weakGround.evidence.map((e) => ({ ...e, kind: 'evidence' })),
|
|
120
|
+
...result.weakGround.insights.map((i) => ({ ...i, kind: 'insight' }))
|
|
121
|
+
],
|
|
122
|
+
(w) => w.kind === 'assumption'
|
|
123
|
+
? ` assumption ${w.id} [${w.risk} risk]\n ${clip(w.label)}`
|
|
124
|
+
: w.kind === 'evidence'
|
|
125
|
+
? ` evidence ${w.id} [${w.confidence}${w.assertion ? `, ${w.sourceType}` : ''}]\n ${clip(w.label)}`
|
|
126
|
+
: ` insight ${w.id} [${w.confidence}, ${roundLabel(w.round)}]\n ${clip(w.label)}`,
|
|
127
|
+
'assumptions, and findings not held at high confidence')
|
|
128
|
+
|
|
129
|
+
section('Screens already built on this ground', result.screens,
|
|
130
|
+
(s) => ` ${s.id}${s.route ? ` ${s.route}` : ''}\n ${clip(s.label)}`,
|
|
131
|
+
'where this journey is likely to land')
|
|
132
|
+
|
|
133
|
+
console.log('\nQuestions every new kind of user raises')
|
|
134
|
+
for (const c of result.concerns) {
|
|
135
|
+
console.log(` ${c.id.padEnd(12)} ${c.question}`)
|
|
136
|
+
if (c.nobodyAsked) {
|
|
137
|
+
console.log(` Nobody has asked. No record in ${result.researchRounds} rounds names it. That is the finding.`)
|
|
138
|
+
} else {
|
|
139
|
+
if (c.findings) console.log(` ${c.findings} finding(s), in ${c.roundsWithFindings} round(s)`)
|
|
140
|
+
for (const n of c.namedBy.slice(0, 6)) console.log(` named by ${n.id}${n.status ? ` [${n.status}]` : ''}`)
|
|
141
|
+
if (c.namedBy.length > 6) console.log(` ... and ${c.namedBy.length - 6} more`)
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
console.log('\nThese are candidates, not verdicts. Whether each decision is a collision, whether a finding is')
|
|
146
|
+
console.log('already handled, and which gaps need research are judgements - see the find-unintended-consequences skill.')
|
|
147
|
+
if (clipped) console.log('\nSome lists were cut at 25. Run with --all for everything, or --json for the full result.')
|
package/scripts/known.js
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const fs = require('fs')
|
|
3
|
+
const path = require('path')
|
|
4
|
+
const { createContextOrExit } = require('../lib/context')
|
|
5
|
+
const { whatsKnown } = require('../lib/known')
|
|
6
|
+
|
|
7
|
+
// hippocampus known <word or phrase> [more...] [--json] [--all] [--hops N]
|
|
8
|
+
//
|
|
9
|
+
// What the knowledge base already holds on a topic: the findings with their
|
|
10
|
+
// round, date and confidence; the assumptions, kept apart; the needs and
|
|
11
|
+
// design work built on them; and whether "nothing found" can be read as
|
|
12
|
+
// "nobody asked". Always exits 0 when the knowledge base loads - finding
|
|
13
|
+
// nothing is an answer, not a failure.
|
|
14
|
+
|
|
15
|
+
const argv = process.argv.slice(2)
|
|
16
|
+
const ctx = createContextOrExit({ argv })
|
|
17
|
+
|
|
18
|
+
const flags = { json: false, all: false, hops: 3 }
|
|
19
|
+
const terms = []
|
|
20
|
+
for (let i = 0; i < argv.length; i++) {
|
|
21
|
+
const arg = argv[i]
|
|
22
|
+
if (arg === '--root') { i++; continue }
|
|
23
|
+
if (arg.startsWith('--root=')) continue
|
|
24
|
+
if (arg === '--json') flags.json = true
|
|
25
|
+
else if (arg === '--all') flags.all = true
|
|
26
|
+
else if (arg === '--hops') flags.hops = Number(argv[++i])
|
|
27
|
+
else if (arg.startsWith('--')) { console.error(`Unknown option: ${arg}`); process.exit(1) }
|
|
28
|
+
else terms.push(arg)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (!terms.length) {
|
|
32
|
+
console.error('Usage: hippocampus known <word or phrase> [more words...] [--json] [--all] [--hops N]')
|
|
33
|
+
console.error('Each argument is searched separately; quote a phrase to keep it together.')
|
|
34
|
+
process.exit(1)
|
|
35
|
+
}
|
|
36
|
+
if (!Number.isInteger(flags.hops) || flags.hops < 0) {
|
|
37
|
+
console.error('--hops needs a whole number, 0 or more.')
|
|
38
|
+
process.exit(1)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function readSourceArtefacts () {
|
|
42
|
+
const indexPath = path.join(ctx.paths.manifestsDir, 'source-index.json')
|
|
43
|
+
if (!fs.existsSync(indexPath)) return []
|
|
44
|
+
return JSON.parse(fs.readFileSync(indexPath, 'utf8')).artefacts || []
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const project = ctx.requireProjects()[0]
|
|
48
|
+
const knowledge = project.store.getKnowledge()
|
|
49
|
+
const result = whatsKnown(knowledge, terms, { sourceArtefacts: readSourceArtefacts(), hops: flags.hops })
|
|
50
|
+
|
|
51
|
+
if (flags.json) {
|
|
52
|
+
console.log(JSON.stringify(result, null, 2))
|
|
53
|
+
process.exit(0)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const LIMIT = flags.all ? Infinity : 25
|
|
57
|
+
const clip = (text, n = 110) => (text.length > n ? `${text.slice(0, n - 1)}…` : text)
|
|
58
|
+
const roundLabel = (round) => (round ? `${round.title}, ${round.date}` : 'no research round')
|
|
59
|
+
let clipped = false
|
|
60
|
+
|
|
61
|
+
function section (title, items, render, note) {
|
|
62
|
+
if (!items.length) return
|
|
63
|
+
console.log(`\n${title} (${items.length})${note ? ` - ${note}` : ''}`)
|
|
64
|
+
for (const item of items.slice(0, LIMIT)) console.log(render(item))
|
|
65
|
+
if (items.length > LIMIT) {
|
|
66
|
+
clipped = true
|
|
67
|
+
console.log(` ... and ${items.length - LIMIT} more`)
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
console.log(`What the knowledge base holds on: ${result.terms.join(', ')}`)
|
|
72
|
+
console.log(`(${ctx.root}, ${result.coverage.rounds.length} research rounds)`)
|
|
73
|
+
|
|
74
|
+
if (result.nothingFound) {
|
|
75
|
+
console.log('\nNo record names this.')
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
section('Findings', result.findings, (f) => f.kind === 'insight'
|
|
79
|
+
? ` insight ${f.id} [${f.confidence}, ${f.participants} participants, ${roundLabel(f.round)}]\n ${clip(f.label)}`
|
|
80
|
+
: ` evidence ${f.id} [${f.confidence}, ${f.sourceType}]\n ${clip(f.label)}`,
|
|
81
|
+
'oldest round first; each is a separate claim')
|
|
82
|
+
|
|
83
|
+
section('Assumptions', result.assumptions, (a) => a.kind === 'assumption'
|
|
84
|
+
? ` assumption ${a.id} [${a.risk} risk]\n ${clip(a.label)}`
|
|
85
|
+
: ` evidence ${a.id} [${a.sourceType} - an assertion, not a finding]\n ${clip(a.label)}`,
|
|
86
|
+
'beliefs the design rests on, not research')
|
|
87
|
+
|
|
88
|
+
section('Needs that name it', result.needs, (n) => ` ${n.id} [${n.priority}]\n ${clip(n.label)}`)
|
|
89
|
+
section('Needs these findings support', result.needsReached, (n) => ` ${n.id} [${n.priority}, via ${n.via}]\n ${clip(n.label)}`)
|
|
90
|
+
section('Scenarios that name it', result.scenarios, (s) => ` ${s.id}${s.riskLevel ? ` [${s.riskLevel} risk]` : ''}\n ${clip(s.label)}`)
|
|
91
|
+
section('Design work that names it', result.design, (d) => ` ${d.kind.padEnd(13)} ${d.id}${d.status ? ` [${d.status}]` : ''}\n ${clip(d.label)}`)
|
|
92
|
+
section('Already built on these', result.builtOn, (d) => ` ${d.kind.padEnd(13)} ${d.id}${d.status ? ` [${d.status}]` : ''} via ${d.via}\n ${clip(d.label)}`,
|
|
93
|
+
'check these before building it again')
|
|
94
|
+
|
|
95
|
+
const { rounds, roundsWithFindings, nearestRounds, emptyRounds, unIngested } = result.coverage
|
|
96
|
+
console.log('\nCoverage')
|
|
97
|
+
const withFindings = rounds.filter((r) => roundsWithFindings.includes(r.id))
|
|
98
|
+
console.log(` Rounds with a finding on this: ${withFindings.length} of ${rounds.length}` +
|
|
99
|
+
(withFindings.length ? ` - ${withFindings.map((r) => `${r.title} (${r.date})`).join('; ')}` : ''))
|
|
100
|
+
if (nearestRounds.length) {
|
|
101
|
+
console.log(` Rounds whose title or summary names it, with no matching finding: ${nearestRounds.map((r) => `${r.title} (${r.date})`).join('; ')}`)
|
|
102
|
+
}
|
|
103
|
+
if (emptyRounds.length) {
|
|
104
|
+
console.log(` Rounds that produced no insights here (${emptyRounds.length}): ${emptyRounds.map((r) => `${r.title} (${r.date})`).join('; ')}`)
|
|
105
|
+
console.log(' The topic may be in their source material without having been ingested.')
|
|
106
|
+
}
|
|
107
|
+
if (unIngested.length) {
|
|
108
|
+
console.log(` Held files never ingested whose names match (${unIngested.length}):`)
|
|
109
|
+
for (const a of unIngested.slice(0, LIMIT)) console.log(` ${a.path}`)
|
|
110
|
+
}
|
|
111
|
+
if (!rounds.length) {
|
|
112
|
+
console.log(' This knowledge base has no research rounds yet, so nothing here can say whether anyone asked.')
|
|
113
|
+
} else if (result.nothingFound && !nearestRounds.length && !unIngested.length) {
|
|
114
|
+
console.log(emptyRounds.length
|
|
115
|
+
? ' No ingested record or round names this. Before calling it unresearched, check the rounds above that produced nothing here.'
|
|
116
|
+
: ' No round covered this. That is the finding.')
|
|
117
|
+
}
|
|
118
|
+
if (clipped) console.log('\nSome lists were cut at 25. Run with --all for everything, or --json for the full result.')
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: find-unintended-consequences
|
|
3
|
+
description: "Runs a new or changed journey against the users the knowledge base already knows and reports where it could cause them problems, with the record behind each finding. Use when a new persona arrives, before designing a new journey, or before changing one that other roles rely on."
|
|
4
|
+
id: find-unintended-consequences
|
|
5
|
+
title: Find unintended consequences of a journey
|
|
6
|
+
purpose: Before a new or changed journey is designed, find which users we already know it could hurt, which decisions it runs into, and which questions nobody has asked - so the consequences are found in the knowledge base instead of in production.
|
|
7
|
+
owners:
|
|
8
|
+
- knowledge-builder
|
|
9
|
+
- workflow-orchestrator
|
|
10
|
+
composes:
|
|
11
|
+
- whats-known-about
|
|
12
|
+
- record-design-decision
|
|
13
|
+
reads:
|
|
14
|
+
- hippocampus/source/scenarios.json
|
|
15
|
+
- hippocampus/source/users.json
|
|
16
|
+
- hippocampus/source/needs.json
|
|
17
|
+
- hippocampus/source/evidence.json
|
|
18
|
+
- hippocampus/source/insights.json
|
|
19
|
+
- hippocampus/source/decisions.json
|
|
20
|
+
- hippocampus/source/design-actions.json
|
|
21
|
+
- hippocampus/source/assumptions.json
|
|
22
|
+
- hippocampus/source/participants.json
|
|
23
|
+
- hippocampus/source/relationships.json
|
|
24
|
+
edits:
|
|
25
|
+
- artefacts/consequence-reviews/
|
|
26
|
+
runs:
|
|
27
|
+
- npx hippocampus consequences <scenario-id>
|
|
28
|
+
- npx hippocampus known "<topic>"
|
|
29
|
+
- npx hippocampus validate
|
|
30
|
+
outputs:
|
|
31
|
+
- A review sorting every candidate into collides with a decision, rests on weak ground, already handled, or nobody asked
|
|
32
|
+
- For each finding, the existing user and need it affects and the record behind it
|
|
33
|
+
- A plain statement of whether this kind of user has ever been in a research round
|
|
34
|
+
- Proposed fixes, naming the existing decision each one reuses or saying that a new decision is needed
|
|
35
|
+
- A dated review under `artefacts/consequence-reviews/`
|
|
36
|
+
guardrails:
|
|
37
|
+
- The command lists candidates, not verdicts. Classify every one; never paste its output as the answer.
|
|
38
|
+
- Walk the shared ground, never the screen. Do not add users who are reached only because they use a screen this journey might land on - a shared page reaches everyone and hides the few whose needs actually stand on this ground.
|
|
39
|
+
- Report what is already handled. A review that flags everything gets ignored, and the findings that matter go with it.
|
|
40
|
+
- Never invent evidence for a new persona. If no round has included this kind of user, say so first, and record the gap as an assumption - never as a finding.
|
|
41
|
+
- A decision's status is part of the finding. `proposed` is not settled; `rejected` means the journey may be asking for something the team already refused. Surface it; do not overturn it quietly.
|
|
42
|
+
- Do not answer a "nobody asked" by guessing. It is a research question, or a decision somebody has to own.
|
|
43
|
+
- Every finding names the existing user, their need and the record id behind it.
|
|
44
|
+
acceptance:
|
|
45
|
+
- Every candidate is classified into one of the four kinds, naming the existing user, the need and the record id behind it.
|
|
46
|
+
- The review says whether this kind of user has ever been in a research round.
|
|
47
|
+
- Every standing concern is reported, including any that nobody has asked.
|
|
48
|
+
- Each proposed fix names the existing decision it reuses, or says a new decision is needed.
|
|
49
|
+
- Nothing is asserted that cannot be pointed at in `hippocampus/source/`.
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
# Find unintended consequences of a journey
|
|
53
|
+
|
|
54
|
+
## Use when
|
|
55
|
+
|
|
56
|
+
A new kind of user is arriving and their journeys are about to be designed.
|
|
57
|
+
Also before changing a journey other roles rely on, or whenever someone asks
|
|
58
|
+
"what could this break for the people we already serve?"
|
|
59
|
+
|
|
60
|
+
## Workflow
|
|
61
|
+
|
|
62
|
+
1. **Get the journey into the knowledge base as a scenario.** A new persona
|
|
63
|
+
goes in through `add-user-needs` and `add-scenario`, or through the ingestion
|
|
64
|
+
skills if there is real research. Cite the evidence the needs genuinely rest
|
|
65
|
+
on. Where there is none, add an assumption rather than borrowing evidence and
|
|
66
|
+
calling it support. The check reads a scenario id.
|
|
67
|
+
|
|
68
|
+
2. **Run the check.**
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
npx hippocampus consequences scenario-the-new-journey
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Run it with no argument to list the scenario ids.
|
|
75
|
+
|
|
76
|
+
3. **Read `This user in the research` first.** If no round has included this
|
|
77
|
+
kind of user, every need rests on evidence gathered from other roles. Put
|
|
78
|
+
that at the top of the review - it qualifies everything after it.
|
|
79
|
+
|
|
80
|
+
4. **Classify every decision on the ground.** Decisions arrive two ways: taken
|
|
81
|
+
in a journey built on the same evidence, or resolving a design action that
|
|
82
|
+
responds to one of the journey's insights. Each one says which. Read the
|
|
83
|
+
decision text, not only its title, and treat a design action with no decision
|
|
84
|
+
yet as work in progress on the same ground.
|
|
85
|
+
- **Collides** - the journey needs something the decision deferred or refused.
|
|
86
|
+
- **Already handled** - the decision answers a question the journey raises.
|
|
87
|
+
- Otherwise it is on the ground but not in the way; say so in one line.
|
|
88
|
+
|
|
89
|
+
5. **Go through the users it reaches, high-priority needs first.** For each,
|
|
90
|
+
ask whether the new journey changes what they see, what they can trust, or
|
|
91
|
+
what gets written to the record they rely on. Name the need and the evidence.
|
|
92
|
+
|
|
93
|
+
6. **Name the weak ground the journey adds weight to.** An assumption that
|
|
94
|
+
carried four needs and now carries eight is more dangerous than it was, even
|
|
95
|
+
though nothing about it changed.
|
|
96
|
+
|
|
97
|
+
7. **Report the standing concerns.** `Nobody has asked` is a finding, not a
|
|
98
|
+
pass. Use `npx hippocampus known "<topic>"` for anything the journey raises
|
|
99
|
+
that the standing concerns do not cover.
|
|
100
|
+
|
|
101
|
+
8. **Propose fixes.** Prefer an existing decision applied to the new role over a
|
|
102
|
+
new one. A genuinely new decision goes through `record-design-decision`. An
|
|
103
|
+
open question is raised as `[DECISION NEEDED]` with the person who has to
|
|
104
|
+
answer it.
|
|
105
|
+
|
|
106
|
+
9. **Write the review** to `artefacts/consequence-reviews/` with today's date
|
|
107
|
+
and the scenario id, in four sections: collides with a decision, rests on
|
|
108
|
+
weak ground, already handled, nobody asked.
|
|
109
|
+
|
|
110
|
+
## Guardrails
|
|
111
|
+
|
|
112
|
+
- Candidates are not verdicts. Every one gets classified.
|
|
113
|
+
- Users reached only through a shared screen are not reached.
|
|
114
|
+
- Already-handled findings are reported, not dropped.
|
|
115
|
+
- No invented evidence for a new persona; the gap is an assumption.
|
|
116
|
+
- A rejected decision the journey needs is surfaced, never quietly reversed.
|
|
117
|
+
- A "nobody asked" is research or a decision to own, never a guess.
|
|
118
|
+
|
|
119
|
+
## Finish
|
|
120
|
+
|
|
121
|
+
End with the fixes that reuse existing decisions, then the open questions and
|
|
122
|
+
who has to answer each one. The review is what lets the build start from the
|
|
123
|
+
consequences instead of discovering them - so it has to be readable by someone
|
|
124
|
+
who never ran the command.
|