coaiajs 0.5.0 → 0.5.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.
@@ -0,0 +1,66 @@
1
+ # Reading the Store
2
+
3
+ `coaiajs` owns the writes. Anything that renders a chart store — a dashboard, a report, a
4
+ Twine promotion, another agent — needs the store's shape, and re-deriving that shape by
5
+ hand is where readers quietly go wrong.
6
+
7
+ It is not a style problem. When a hand-rolled reader drifts from the writer, it does not
8
+ break: it renders **less**. A chart holding real work looks identical to an empty one.
9
+
10
+ ## Use the contract
11
+
12
+ ```typescript
13
+ import { parseStore, getWork, getChartEntity } from 'coaiajs/narrative/contract';
14
+ import { readFile } from 'node:fs/promises';
15
+
16
+ const store = parseStore(await readFile('./memory.jsonl', 'utf8'));
17
+ const chart = getChartEntity(store, 'chart_1757200000000');
18
+ const work = getWork(store, 'chart_1757200000000');
19
+ ```
20
+
21
+ The contract keeps three rules:
22
+
23
+ 1. **Zero I/O.** No `fs`, no `process`, no network. The caller owns reading; this owns
24
+ shape.
25
+ 2. **Never imports the server.** The package root is safe to import, but the contract
26
+ lives behind its own subpath so a renderer pulls nothing it does not need.
27
+ 3. **Tolerant by construction, honest about what it skipped.** One unparseable line is
28
+ skipped and counted in `skipped`, where `parseJsonlMemory` — correctly, for a writer —
29
+ throws.
30
+
31
+ Classification is **not** defined in the contract. `jsonl-records.ts` holds the single
32
+ definition, and both the writer and the contract import it. The first draft of the
33
+ contract re-implemented classification by hand and a review measured it returning 73
34
+ entities where the writer returned 76: it dropped the legacy `type:"narrative_beat"`
35
+ dialect and reported the losses as corruption. Duplication relocated rather than removed.
36
+
37
+ ## What it gives you
38
+
39
+ | Export | Use |
40
+ |---|---|
41
+ | `parseStore(raw)` | `{ entities: Map, relations: [], skipped: number }` |
42
+ | `ENTITY_TYPES` | Every entity kind the writer writes |
43
+ | `MMOT_PHASES`, `CREATING_PHASES` | The vocabularies, including `full` |
44
+ | `chartEntityName`, `desiredOutcomeName`, `currentRealityName` | The naming scheme, once |
45
+ | `getChartEntity`, `getDesiredOutcome`, `getCurrentReality` | Chart parts by id |
46
+ | `getFlatActionSteps`, `getChildCharts`, `getWork` | The two shapes work takes, counted once |
47
+ | `getMmotBeats`, `getMmotEvaluations` | The MMOT trail |
48
+ | `storeRevision`, `revisionOf` | Cheap change detection between reads |
49
+
50
+ ## What `skipped` cannot tell you
51
+
52
+ Writes are temp-file-plus-rename, so a reader should never see a torn file and
53
+ `skipped > 0` genuinely suggests a foreign or damaged line.
54
+
55
+ But a store truncated by something *other* than this package can still be a syntactically
56
+ perfect prefix: every whole line parses, and the result is simply a smaller store with
57
+ `skipped === 0`. No reader can detect that from content alone. If it matters, compare
58
+ entity counts across reads.
59
+
60
+ ## Writing from outside
61
+
62
+ If you must write, go through `KnowledgeGraphManager` or
63
+ `readJsonlMemoryFile` / `writeJsonlMemoryFile`. They preserve fields this package does not
64
+ model — another consumer's metadata survives — and they write atomically. A bare
65
+ `writeFile` over the store truncates first, and a reader landing in that window gets a
66
+ valid partial store.
@@ -0,0 +1,71 @@
1
+ # Structural Tension Charting
2
+
3
+ A chart has three core parts:
4
+
5
+ 1. **Desired Outcome** — what the user wants to create.
6
+ 2. **Current Reality** — the honest present state in relation to that outcome.
7
+ 3. **Action Steps** — strategic secondary choices that support the primary choice.
8
+
9
+ Action steps are not independent checklist items. They must make sense together as an
10
+ overview strategy. Test them with: "If these steps were taken, would the desired outcome
11
+ likely be created?"
12
+
13
+ Each action step is a telescoped chart. Its title becomes the desired outcome of the child
14
+ chart, and it needs its own current reality. Never use "ready to begin" as that reality.
15
+
16
+ Good current reality examples:
17
+
18
+ - "No Django experience."
19
+ - "Package builds locally, publish dry-run not inspected."
20
+ - "Budget: $5000."
21
+ - "Completed models section, struggling with views."
22
+
23
+ Poor current reality examples:
24
+
25
+ - "Ready to begin."
26
+ - "Need to retrieve the notes."
27
+ - "Excited to start."
28
+ - "Prepared to tackle the action step."
29
+
30
+ ## How a chart is laid out in the store
31
+
32
+ For a chart with id `chart_1757200000000`:
33
+
34
+ | Entity | `entityType` |
35
+ |---|---|
36
+ | `chart_1757200000000_chart` | `structural_tension_chart` |
37
+ | `chart_1757200000000_desired_outcome` | `desired_outcome` |
38
+ | `chart_1757200000000_current_reality` | `current_reality` |
39
+ | `chart_1757200000000_action_1` … `_action_N` | `action_step` |
40
+
41
+ A telescoped child chart is a full chart of its own, carrying `metadata.parentChart` and,
42
+ when it grew out of a specific step, `metadata.parentActionStep`.
43
+
44
+ ## The two shapes work takes
45
+
46
+ This is the single most common source of a wrong reading. A chart holds its work in **two**
47
+ shapes:
48
+
49
+ 1. `action_step` entities that live on the chart itself.
50
+ 2. Telescoped child charts, which is what `add_action_step` produces.
51
+
52
+ Counting or rendering only one of them under-reports. A chart built entirely with
53
+ `add_action_step` used to report `0/0` progress while holding real work, and a chart
54
+ holding eight of its own steps used to render as "(No action steps yet)".
55
+
56
+ A child telescoped out of one of the chart's own steps is that same result seen closer up.
57
+ It counts **once**, through the step — not twice.
58
+
59
+ `getChartProgress`, `listActiveCharts`, `updateChartDueDate`, and
60
+ `coaiajs/narrative/contract`'s `getWork()` all apply that rule. Prefer them over walking
61
+ the graph by hand.
62
+
63
+ ## Moving a date
64
+
65
+ Use `update_chart_due_date`. It moves the chart and its desired outcome together, records
66
+ the move as an observation on the chart, and reports how many open steps still fall after
67
+ the new date. Pass `redistributeActionSteps: true` to spread those open steps evenly
68
+ between now and the new date.
69
+
70
+ Do not hand-edit the JSONL to change a date. Several MCP instances can point at one store
71
+ with no lock; a hand-edit races every one of them.
@@ -0,0 +1,72 @@
1
+ # Wampum Belts
2
+
3
+ A Wampum Belt is a non-linear mnemonic grid that runs in **parallel** with the linear
4
+ narrative beats. Beats are a sequence; a belt is a surface where position itself carries
5
+ meaning.
6
+
7
+ Reach for a belt when the order of things is not a line: when a reading depends on where
8
+ it sits relative to its neighbours, when several perspectives on one bead are all true,
9
+ or when a commitment needs a witness rather than a timestamp.
10
+
11
+ ## Shape
12
+
13
+ A belt has `rows` × `cols` positions. Each position holds at most one bead, written once.
14
+
15
+ A bead carries:
16
+
17
+ | Field | Meaning |
18
+ |---|---|
19
+ | `mnemonic` | Short anchor phrase |
20
+ | `color` | `white`, `purple`, `black`, or `mixed` |
21
+ | `position` | `{ row, col }`, zero-indexed, inside the grid |
22
+ | `reading` | The canonical meaning |
23
+ | `relationalReadings` | Optional per-perspective readings, keyed `left` / `center` / `right` / `row:N` / `col:N` |
24
+ | `ceremonyLink` | Optional tie to a chart or a beat |
25
+ | `observations` | Free notes |
26
+
27
+ `read_wampum_belt` with a `position` resolves the reading for that position: it prefers
28
+ `col:N`, then `row:N`, then the positional label (`left` / `center` / `right`), and falls
29
+ back to the canonical `reading`.
30
+
31
+ ## Ceremony links
32
+
33
+ `ceremonyLink.ceremonyType` is one of `commitment`, `accountability`, `witness`, or
34
+ `renewal`. With `chartId` it writes a `wampum_holds_accountable` edge to that chart; with
35
+ `beatName` it writes a `wampum_witnesses` edge to that beat.
36
+
37
+ **The edge is subject to the bead, not the belt.** A relation's identity in the store is
38
+ `(from, to, relationType)`. With the belt as subject, a second bead linking the same chart
39
+ under a different `ceremonyType` collided on that triple: the existence check matched, the
40
+ edge was skipped, and the bead kept a ceremony type the graph had no edge for. Silent
41
+ discard, with the bead's own record disagreeing with the graph and nothing saying so.
42
+
43
+ A bead id is `bead_<beltId>_<row>_<col>` and a position is written once, so
44
+ `(bead, target, relationType)` is unique by construction and every ceremony link survives
45
+ carrying its own type.
46
+
47
+ ## Tools
48
+
49
+ ```json
50
+ { "tool": "create_wampum_belt",
51
+ "arguments": { "title": "Release ceremony", "purpose": "Hold what each step promised", "rows": 2, "cols": 3 } }
52
+ ```
53
+
54
+ ```json
55
+ { "tool": "add_wampum_bead",
56
+ "arguments": {
57
+ "beltId": "belt_1757200000000",
58
+ "mnemonic": "witnessed",
59
+ "color": "purple",
60
+ "position": { "row": 0, "col": 1 },
61
+ "reading": "The publish was seen by someone other than its author",
62
+ "relationalReadings": { "center": "seen from the middle of the belt" },
63
+ "ceremonyLink": { "ceremonyType": "witness", "chartId": "chart_1757200000000" }
64
+ } }
65
+ ```
66
+
67
+ ```json
68
+ { "tool": "read_wampum_belt", "arguments": { "beltId": "belt_1757200000000" } }
69
+ ```
70
+
71
+ Out-of-bounds positions, occupied positions, and non-integer grids are refused with the
72
+ reason named.