@maadb/core 0.14.0 → 0.15.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/README.md +14 -8
- package/dist/architect.d.ts.map +1 -1
- package/dist/architect.js +6 -0
- package/dist/architect.js.map +1 -1
- package/dist/instructions/manifest.d.ts.map +1 -1
- package/dist/instructions/manifest.js +4 -0
- package/dist/instructions/manifest.js.map +1 -1
- package/dist/maad-md.d.ts.map +1 -1
- package/dist/maad-md.js +2 -0
- package/dist/maad-md.js.map +1 -1
- package/dist/skill-files.d.ts.map +1 -1
- package/dist/skill-files.js +8 -0
- package/dist/skill-files.js.map +1 -1
- package/dist/skills/corpus-explorer.d.ts +2 -0
- package/dist/skills/corpus-explorer.d.ts.map +1 -0
- package/dist/skills/corpus-explorer.js +220 -0
- package/dist/skills/corpus-explorer.js.map +1 -0
- package/dist/skills/graph-ontology.d.ts +2 -0
- package/dist/skills/graph-ontology.d.ts.map +1 -0
- package/dist/skills/graph-ontology.js +252 -0
- package/dist/skills/graph-ontology.js.map +1 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
[](LICENSE)
|
|
4
4
|
[](package.json)
|
|
5
5
|
[](tsconfig.json)
|
|
6
|
-
[](https://github.com/maadb/maadb/actions/workflows/ci.yml)
|
|
7
7
|
[](https://www.npmjs.com/package/@maadb/core)
|
|
8
|
-
[](https://github.com/maadb/maadb/releases/latest)
|
|
9
9
|
|
|
10
10
|
> **Markdown is the database. The engine makes it queryable.**
|
|
11
11
|
|
|
@@ -15,7 +15,7 @@ MAADb stores records as markdown files with YAML frontmatter for structured fiel
|
|
|
15
15
|
|
|
16
16
|
- **Markdown is canonical.** Open any record in any text editor — your data is exactly what's on screen, no translation layer.
|
|
17
17
|
- **History policy is explicit.** Choose per-write audit commits, a Git-free feed, zero-write reads, batched commits, or annotated snapshots per project. `maad_history` shows available Git history.
|
|
18
|
-
- **LLM-native.** Ships with
|
|
18
|
+
- **LLM-native.** Ships with 46 MCP tools for discovery, read, write, maintenance, and auth. Designed for agent workflows from the start.
|
|
19
19
|
- **Optional schemas.** Add YAML schemas when you want structure, skip them when you don't. Validation runs on writes, never on old records.
|
|
20
20
|
- **The index is a speed layer.** SQLite stores pointers into your markdown files. Delete it and `maad reindex` rebuilds it from the markdown — your data never depends on the index surviving.
|
|
21
21
|
- **Safe under concurrent writes.** Clean shutdown, lock recovery, rate limiting, retry-safe operations all built in.
|
|
@@ -279,7 +279,7 @@ Generate a token from the CLI (plaintext printed ONCE; server stores only the SH
|
|
|
279
279
|
|
|
280
280
|
```bash
|
|
281
281
|
node dist/cli.js --instance /path/to/instance.yaml auth issue-token \
|
|
282
|
-
--role=admin --name='primary-gateway' --projects='*' --agent=
|
|
282
|
+
--role=admin --name='primary-gateway' --projects='*' --agent=gateway-agent
|
|
283
283
|
# → maad_pat_<32hex> on stdout
|
|
284
284
|
```
|
|
285
285
|
|
|
@@ -320,7 +320,7 @@ rotating a token, discard the old session and initialize a fresh one with the ne
|
|
|
320
320
|
bearer. A client that previously reused one session across several tokens must now
|
|
321
321
|
open one session per token.
|
|
322
322
|
|
|
323
|
-
> **Known gap (
|
|
323
|
+
> **Known gap (still present in v0.14.0):** `maad_instance_reload` does not reload `tokens.yaml`.
|
|
324
324
|
> On a deployment where SIGHUP is unavailable, a revocation written to
|
|
325
325
|
> `tokens.yaml` by another process is not observed by the running server until it
|
|
326
326
|
> restarts, and sessions bound to the revoked token stay live until then. Prefer
|
|
@@ -369,7 +369,7 @@ my-project/
|
|
|
369
369
|
_backend/ # SQLite index — gitignored, rebuildable
|
|
370
370
|
maad.db
|
|
371
371
|
_import/ # Drop zone for raw markdown imports
|
|
372
|
-
_skills/ # Agent skill files (architect, import, etc.) — engine-managed
|
|
372
|
+
_skills/ # Agent skill files (architect, import, graph, corpus, etc.) — engine-managed
|
|
373
373
|
MAAD.md # Managed: canonical agent operating instructions (static, stamped)
|
|
374
374
|
CLAUDE.md / AGENTS.md # Created once at init: thin pointers to MAAD.md, user-owned after
|
|
375
375
|
<type-dirs>/ # Record files — one directory per type
|
|
@@ -429,9 +429,15 @@ The vector store is `sqlite-vec` (in the same SQLite file); the lexical leg is F
|
|
|
429
429
|
|
|
430
430
|
## Current state
|
|
431
431
|
|
|
432
|
-
**Current:** v0.
|
|
432
|
+
**Current:** v0.15.0 — managed graph-ontology and corpus-explorer skills teach agents typed-graph densification and unfamiliar-project mapping using existing MCP primitives (`maad_related`, `maad_relationship_paths`, `maad_join`, …).
|
|
433
|
+
|
|
434
|
+
See the [v0.15.0 release notes](docs/releases/v0.15.0.md) for highlights, verification, and migration notes.
|
|
433
435
|
|
|
434
436
|
Recent shipped scope:
|
|
437
|
+
- **0.15.0** — Managed `_skills/graph-ontology.md` and `_skills/corpus-explorer.md` (MANAGED_ARTIFACTS 4 → 6)
|
|
438
|
+
- **0.14.0** — Per-project `audit`, `feed`, `read`, `batch`, and `snapshot` history modes; explicit flush; crash recovery; history health telemetry
|
|
439
|
+
- **0.13.0** — Evidence-backed relationship paths with deterministic bounded traversal and canonical edge evidence
|
|
440
|
+
- **0.12.4** — HTTP sessions bound to the authenticated principal that opened them; revoke, rotate, reload, and expiry tear down affected sessions
|
|
435
441
|
- **0.12.3** — Token-store `reload` serialized against in-flight mutations, so a SIGHUP during issue/revoke/rotate cannot drop a just-written token from the in-memory index
|
|
436
442
|
- **0.12.2** — Canonical path containment for `maad_scan`; serialized token-store issue/revoke/rotate
|
|
437
443
|
- **0.12.1** — Escape newlines and carriage returns in double-quoted YAML frontmatter scalars
|
|
@@ -450,7 +456,7 @@ See [Version.md](Version.md) for the full release history and forward plan.
|
|
|
450
456
|
|
|
451
457
|
- TypeScript strict, Node.js 24+ (current Active LTS)
|
|
452
458
|
- 6 production dependencies: `better-sqlite3`, `gray-matter`, `js-yaml`, `simple-git`, `@modelcontextprotocol/sdk`, `pino`. Plus one **optional** dependency `sqlite-vec` (semantic retrieval) — lazily loaded only when `MAAD_SEMANTIC_ENABLE` is on; absent or failed to load ⇒ semantic disabled, engine unaffected
|
|
453
|
-
-
|
|
459
|
+
- 1,274 tests at v0.15.0, Vitest — run on every push/PR across Ubuntu and Windows
|
|
454
460
|
- MIT license, pre-1.0, actively developed
|
|
455
461
|
|
|
456
462
|
## License
|
package/dist/architect.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"architect.d.ts","sourceRoot":"","sources":["../src/architect.ts"],"names":[],"mappings":"AAMA,wBAAgB,sBAAsB,IAAI,MAAM,
|
|
1
|
+
{"version":3,"file":"architect.d.ts","sourceRoot":"","sources":["../src/architect.ts"],"names":[],"mappings":"AAMA,wBAAgB,sBAAsB,IAAI,MAAM,CA8N/C"}
|
package/dist/architect.js
CHANGED
|
@@ -118,6 +118,12 @@ For each entity, determine: master or transaction. Use the design checkpoint fro
|
|
|
118
118
|
|
|
119
119
|
### 2. Map relationships
|
|
120
120
|
Draw the refs: what points to what. A job refs a customer and a technician. A note appends to a job.
|
|
121
|
+
Name \`ref\` fields as relations (\`parent_case\`, \`assigned_attorney\`), not
|
|
122
|
+
generics (\`link\`, \`related\`) — the field name is the only edge label the
|
|
123
|
+
graph exposes. When an existing corpus has prose links that should become
|
|
124
|
+
queryable structure, that is densification: add an optional \`ref\` field
|
|
125
|
+
(additive evolution), then set it on records — see \`_skills/graph-ontology.md\`
|
|
126
|
+
Recipe 4. Do not invent Cypher-style edges or UI graph views in the engine.
|
|
121
127
|
|
|
122
128
|
### 3. Define fields
|
|
123
129
|
For each type: name, type, required, indexed, enum values, ref targets. Use domain knowledge for sensible defaults.
|
package/dist/architect.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"architect.js","sourceRoot":"","sources":["../src/architect.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,2CAA2C;AAC3C,6EAA6E;AAC7E,2DAA2D;AAC3D,+EAA+E;AAE/E,MAAM,UAAU,sBAAsB;IACpC,OAAO
|
|
1
|
+
{"version":3,"file":"architect.js","sourceRoot":"","sources":["../src/architect.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,2CAA2C;AAC3C,6EAA6E;AAC7E,2DAA2D;AAC3D,+EAA+E;AAE/E,MAAM,UAAU,sBAAsB;IACpC,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4NR,CAAC;AACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../src/instructions/manifest.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../src/instructions/manifest.ts"],"names":[],"mappings":"AAiCA,iFAAiF;AACjF,wBAAgB,aAAa,IAAI,MAAM,CAOtC;AAED,MAAM,WAAW,eAAe;IAC9B,iDAAiD;IACjD,IAAI,EAAE,MAAM,CAAC;IACb,2DAA2D;IAC3D,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,MAAM,CAAC;CACxB;AAED;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,EAAE,SAAS,eAAe,EAOvD,CAAC;AAIF,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAI7C;AAED,qDAAqD;AACrD,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,MAAwB,GAAG,MAAM,CAElG;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,yCAAyC;IACzC,IAAI,EAAE,MAAM,CAAC;CACd;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAI9D;AAED,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,UAAU,GAAG,UAAU,GAAG,WAAW,GAAG,SAAS,CAAC;AAE7F,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,gBAAgB,CAAC;IACxB,kEAAkE;IAClE,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,EAAE,eAAe,GAAG,iBAAiB,CAUnG;AAWD,+DAA+D;AAC/D,wBAAgB,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,iBAAiB,EAAE,CAGrE;AAED,MAAM,WAAW,WAAW;IAC1B,gFAAgF;IAChF,OAAO,EAAE,iBAAiB,EAAE,CAAC;IAC7B,2DAA2D;IAC3D,eAAe,EAAE,iBAAiB,EAAE,CAAC;IACrC,qEAAqE;IACrE,gBAAgB,EAAE,iBAAiB,EAAE,CAAC;IACtC,mCAAmC;IACnC,OAAO,EAAE,iBAAiB,EAAE,CAAC;CAC9B;AAED,wBAAgB,WAAW,CAAC,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE;IAAE,KAAK,EAAE,OAAO,CAAA;CAAE,GAAG,WAAW,CActF;AAED,4EAA4E;AAC5E,wBAAgB,YAAY,CAAC,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,GAAG,MAAM,EAAE,CAW7E"}
|
|
@@ -25,6 +25,8 @@ import { createRequire } from 'node:module';
|
|
|
25
25
|
import { generateMaadMd } from '../maad-md.js';
|
|
26
26
|
import { generateSchemaGuide, generateImportGuide } from '../skill-files.js';
|
|
27
27
|
import { generateArchitectSkill } from '../architect.js';
|
|
28
|
+
import { generateGraphOntologySkill } from '../skills/graph-ontology.js';
|
|
29
|
+
import { generateCorpusExplorerSkill } from '../skills/corpus-explorer.js';
|
|
28
30
|
const require = createRequire(import.meta.url);
|
|
29
31
|
/** Engine version = template version. Resolved from the shipped package.json. */
|
|
30
32
|
export function engineVersion() {
|
|
@@ -46,6 +48,8 @@ export const MANAGED_ARTIFACTS = [
|
|
|
46
48
|
{ name: 'architect-core', relPath: '_skills/architect-core.md', generate: generateArchitectSkill },
|
|
47
49
|
{ name: 'schema-guide', relPath: '_skills/schema-guide.md', generate: generateSchemaGuide },
|
|
48
50
|
{ name: 'import-guide', relPath: '_skills/import-guide.md', generate: generateImportGuide },
|
|
51
|
+
{ name: 'graph-ontology', relPath: '_skills/graph-ontology.md', generate: generateGraphOntologySkill },
|
|
52
|
+
{ name: 'corpus-explorer', relPath: '_skills/corpus-explorer.md', generate: generateCorpusExplorerSkill },
|
|
49
53
|
];
|
|
50
54
|
const STAMP_RE = /^<!-- maadb:managed name=([A-Za-z0-9_-]+) engine=([^\s]+) hash=sha256:([0-9a-f]{64}) -->\r?\n?/;
|
|
51
55
|
export function hashBody(body) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest.js","sourceRoot":"","sources":["../../src/instructions/manifest.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,qEAAqE;AACrE,mEAAmE;AACnE,EAAE;AACF,0CAA0C;AAC1C,2CAA2C;AAC3C,+EAA+E;AAC/E,2EAA2E;AAC3E,+BAA+B;AAC/B,8EAA8E;AAC9E,+EAA+E;AAC/E,+EAA+E;AAC/E,gFAAgF;AAChF,8EAA8E;AAC9E,0EAA0E;AAC1E,2EAA2E;AAC3E,uEAAuE;AACvE,kCAAkC;AAClC,yEAAyE;AACzE,+EAA+E;AAE/E,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,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d.ts","sourceRoot":"","sources":["../src/maad-md.ts"],"names":[],"mappings":"AAUA,wBAAgB,cAAc,IAAI,MAAM,
|
|
1
|
+
{"version":3,"file":"maad-md.d.ts","sourceRoot":"","sources":["../src/maad-md.ts"],"names":[],"mappings":"AAUA,wBAAgB,cAAc,IAAI,MAAM,CAoHvC"}
|
package/dist/maad-md.js
CHANGED
|
@@ -120,6 +120,8 @@ of secrets and personal data you would not hand to every project member.
|
|
|
120
120
|
- \`_skills/architect-core.md\` — design and deploy schemas (Architect mode)
|
|
121
121
|
- \`_skills/schema-guide.md\` — schema DSL reference and evolution
|
|
122
122
|
- \`_skills/import-guide.md\` — importing existing data
|
|
123
|
+
- \`_skills/graph-ontology.md\` — typed graph traversal and densification
|
|
124
|
+
- \`_skills/corpus-explorer.md\` — map an unfamiliar project to a typed corpus map
|
|
123
125
|
`;
|
|
124
126
|
}
|
|
125
127
|
//# sourceMappingURL=maad-md.js.map
|
package/dist/maad-md.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"maad-md.js","sourceRoot":"","sources":["../src/maad-md.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,2EAA2E;AAC3E,EAAE;AACF,0EAA0E;AAC1E,sEAAsE;AACtE,6EAA6E;AAC7E,wEAAwE;AACxE,oEAAoE;AACpE,+EAA+E;AAE/E,MAAM,UAAU,cAAc;IAC5B,OAAO
|
|
1
|
+
{"version":3,"file":"maad-md.js","sourceRoot":"","sources":["../src/maad-md.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,2EAA2E;AAC3E,EAAE;AACF,0EAA0E;AAC1E,sEAAsE;AACtE,6EAA6E;AAC7E,wEAAwE;AACxE,oEAAoE;AACpE,+EAA+E;AAE/E,MAAM,UAAU,cAAc;IAC5B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkHR,CAAC;AACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skill-files.d.ts","sourceRoot":"","sources":["../src/skill-files.ts"],"names":[],"mappings":"AAKA,wBAAgB,mBAAmB,IAAI,MAAM,
|
|
1
|
+
{"version":3,"file":"skill-files.d.ts","sourceRoot":"","sources":["../src/skill-files.ts"],"names":[],"mappings":"AAKA,wBAAgB,mBAAmB,IAAI,MAAM,CAwP5C;AAED,wBAAgB,mBAAmB,IAAI,MAAM,CAmK5C"}
|
package/dist/skill-files.js
CHANGED
|
@@ -212,6 +212,14 @@ client:
|
|
|
212
212
|
target: client # points to records of type "client"
|
|
213
213
|
\`\`\`
|
|
214
214
|
|
|
215
|
+
**Densification (additive refs):** when agents discover structural links that
|
|
216
|
+
only exist in prose or \`mention\` annotations, prefer adding a new *optional*
|
|
217
|
+
\`ref\` (or \`list\` of \`ref\`) field to the current schema version, \`maad_reload\`,
|
|
218
|
+
then set the field on records. That is an additive change — no \`vN+1\` bump.
|
|
219
|
+
Name the field as a relation, set \`index: true\` if you will filter or join on
|
|
220
|
+
it, and verify with \`maad_find_orphans\`. Full recipe:
|
|
221
|
+
\`_skills/graph-ontology.md\`.
|
|
222
|
+
|
|
215
223
|
## Template headings (optional)
|
|
216
224
|
|
|
217
225
|
Add heading structure that \`maad_create\` will generate for new records:
|
package/dist/skill-files.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skill-files.js","sourceRoot":"","sources":["../src/skill-files.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,2DAA2D;AAC3D,oDAAoD;AACpD,+EAA+E;AAE/E,MAAM,UAAU,mBAAmB;IACjC,OAAO
|
|
1
|
+
{"version":3,"file":"skill-files.js","sourceRoot":"","sources":["../src/skill-files.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,2DAA2D;AAC3D,oDAAoD;AACpD,+EAA+E;AAE/E,MAAM,UAAU,mBAAmB;IACjC,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsPR,CAAC;AACF,CAAC;AAED,MAAM,UAAU,mBAAmB;IACjC,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiKR,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"corpus-explorer.d.ts","sourceRoot":"","sources":["../../src/skills/corpus-explorer.ts"],"names":[],"mappings":"AAIA,wBAAgB,2BAA2B,IAAI,MAAM,CAuNpD"}
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// Corpus Explorer skill — managed instruction generator (fully static).
|
|
3
|
+
// ============================================================================
|
|
4
|
+
export function generateCorpusExplorerSkill() {
|
|
5
|
+
return `# Mapping an Unfamiliar Project
|
|
6
|
+
|
|
7
|
+
> Managed by the MAADb engine — do not edit (changes block future refreshes).
|
|
8
|
+
> Project-specific corpus maps belong in \`_skills/local/corpus-map.md\`.
|
|
9
|
+
> Never append session notes to this skill file.
|
|
10
|
+
|
|
11
|
+
## Purpose
|
|
12
|
+
|
|
13
|
+
You are an agent landing in a MAADB project you did not build and do not
|
|
14
|
+
know. This skill is a staged exploration protocol that takes you from zero
|
|
15
|
+
to a **written, typed map of the corpus** — what the record types are, how
|
|
16
|
+
they connect, how dense the graph is, where it is broken — using cheap,
|
|
17
|
+
bounded reads. The protocol front-loads index-backed tools and defers
|
|
18
|
+
full-body reads to the end, so orientation cost stays flat even on large
|
|
19
|
+
corpora.
|
|
20
|
+
|
|
21
|
+
Audience: any agent with reader access. The final stage writes one overlay
|
|
22
|
+
file, which needs writer access (skippable — report the map in chat instead).
|
|
23
|
+
|
|
24
|
+
## When to load this skill
|
|
25
|
+
|
|
26
|
+
- First session in a project whose \`maad_summary\` you have never seen.
|
|
27
|
+
- You've been handed a task referencing types or records you can't place.
|
|
28
|
+
- Before proposing schema or convention changes to an inherited corpus —
|
|
29
|
+
map first, judge second.
|
|
30
|
+
- Periodically on long-lived projects, to refresh a stale corpus map.
|
|
31
|
+
|
|
32
|
+
If \`maad_summary\` shows an **empty** project, stop — this skill maps
|
|
33
|
+
existing data. Enter Architect mode instead (\`_skills/architect-core.md\`).
|
|
34
|
+
|
|
35
|
+
## Ground rules
|
|
36
|
+
|
|
37
|
+
- **Never** map a corpus by listing or reading files directly — all reads go
|
|
38
|
+
through MCP tools, and the index is faster than you.
|
|
39
|
+
- Match read shape to need (\`hot\` → fields, \`warm\` → one section, \`cold\` →
|
|
40
|
+
full body). In this protocol, \`cold\` appears only in Stage 3, on a
|
|
41
|
+
handful of records.
|
|
42
|
+
- Everything you write into the map must be grounded in a tool result from
|
|
43
|
+
**this** session; counts you intend to publish go through
|
|
44
|
+
\`maad_verify mode=count\` first.
|
|
45
|
+
- Watch \`_meta.warnings[]\` on every response — orientation is exactly when
|
|
46
|
+
you want to notice degraded subsystems or drift signals early.
|
|
47
|
+
|
|
48
|
+
## The protocol
|
|
49
|
+
|
|
50
|
+
Six stages. Each produces a section of the final map; you can stop early
|
|
51
|
+
and still hold a partial map (that's a feature — Stage 6 records what was
|
|
52
|
+
*not* explored, and a truncated map that says so is still trustworthy).
|
|
53
|
+
|
|
54
|
+
### Stage 0 — Bind and capabilities
|
|
55
|
+
|
|
56
|
+
On multi-project servers: \`maad_projects\`, then \`maad_use_project\` (bindings
|
|
57
|
+
are fixed per session). Then \`maad_describe\`: project overview, stats, and
|
|
58
|
+
\`capabilities\` — notably whether relationship paths and semantic search are
|
|
59
|
+
available in this deployment, which decides your Stage 4 toolkit.
|
|
60
|
+
|
|
61
|
+
### Stage 1 — Summary: the shape
|
|
62
|
+
|
|
63
|
+
\`maad_summary\` once. Extract into notes:
|
|
64
|
+
|
|
65
|
+
- Type inventory with counts — your candidate class list.
|
|
66
|
+
- Sample doc IDs per type — seeds for Stages 3–4.
|
|
67
|
+
- Warnings: broken refs and validation errors reported here are your first
|
|
68
|
+
hygiene signal; carry them to Stage 5, don't chase them yet.
|
|
69
|
+
|
|
70
|
+
Skim \`MAAD.md\` and list \`_skills/\` — an existing \`_skills/local/\` overlay
|
|
71
|
+
(prior conventions, an earlier corpus map) changes your job from *mapping*
|
|
72
|
+
to *verifying and updating a map*.
|
|
73
|
+
|
|
74
|
+
### Stage 2 — Schema: the intended graph
|
|
75
|
+
|
|
76
|
+
For each type from Stage 1: \`maad_schema <type>\`. Build two tables as you
|
|
77
|
+
go:
|
|
78
|
+
|
|
79
|
+
1. **Type table** — required fields, enums (the project's controlled
|
|
80
|
+
vocabularies), indexed fields (what the project's builders expected to
|
|
81
|
+
query — intent fossilized in config).
|
|
82
|
+
2. **Edge table** — every \`ref\` / \`list[ref]\` field: source type, field
|
|
83
|
+
name, target type. This is the **intended** graph, before you've looked
|
|
84
|
+
at a single record.
|
|
85
|
+
|
|
86
|
+
Note the file-strategy signal: types whose records are few but block-heavy
|
|
87
|
+
are transaction-pattern (entries appended under parents — see
|
|
88
|
+
\`_skills/schema-guide.md\`); their real "record count" is blocks, not files,
|
|
89
|
+
and their parent ref is usually the corpus's highest-volume edge.
|
|
90
|
+
|
|
91
|
+
### Stage 3 — Samples: the actual records
|
|
92
|
+
|
|
93
|
+
Per type, cheapest first:
|
|
94
|
+
|
|
95
|
+
- \`maad_get <sample-id> hot\` on 1–2 samples — do real records fill the
|
|
96
|
+
schema's fields? Sparse optional fields here foreshadow a sparse graph.
|
|
97
|
+
- \`maad_query\` with a projection of 3–4 key fields, small limit — the
|
|
98
|
+
spread, not just the sample (status distributions, date ranges).
|
|
99
|
+
- \`maad_get <id> cold\` on **one or two** records total, for narrative
|
|
100
|
+
texture: are bodies annotated (\`[[type:value|label]]\`)? Do they name
|
|
101
|
+
other records in prose?
|
|
102
|
+
- \`maad_search primitive=entity limit=20\` (then other primitives that the
|
|
103
|
+
domain suggests) — is the annotation layer in active use, and with which
|
|
104
|
+
subtypes? Remember frontmatter string fields index as \`primitive=entity,
|
|
105
|
+
subtype=<field-name>\`, so search results mix field values and body
|
|
106
|
+
annotations; the subtype tells you which.
|
|
107
|
+
- Where \`maad_describe\` said semantic search is enabled,
|
|
108
|
+
\`maad_semantic_search\` with 2–3 domain phrases is a cheap probe for
|
|
109
|
+
themes the schema doesn't capture. Degraded responses say so — fall back
|
|
110
|
+
without guessing.
|
|
111
|
+
|
|
112
|
+
### Stage 4 — Related and paths: the realized graph
|
|
113
|
+
|
|
114
|
+
Now compare the intended graph (Stage 2) with reality.
|
|
115
|
+
|
|
116
|
+
1. **Measure edge usage with aggregates, not iteration.** For each edge in
|
|
117
|
+
the Stage 2 table: \`maad_aggregate docType=<source> groupBy=<ref-field>\`.
|
|
118
|
+
Group count ≈ how many distinct targets are actually referenced; a
|
|
119
|
+
near-empty result means a declared-but-unused edge. This also hands you
|
|
120
|
+
the **hubs** — target IDs with the largest groups.
|
|
121
|
+
2. **Walk the hubs.** For the top 2–3 hubs: \`maad_related direction=both\`,
|
|
122
|
+
then
|
|
123
|
+
|
|
124
|
+
\`\`\`
|
|
125
|
+
maad_relationship_paths
|
|
126
|
+
startDocId: <hub>
|
|
127
|
+
direction: both
|
|
128
|
+
maxDepth: 2
|
|
129
|
+
\`\`\`
|
|
130
|
+
|
|
131
|
+
Organize by \`nodes[].distance\`. Check \`truncation.truncated\` /
|
|
132
|
+
\`limitsReached\` before concluding anything about reach — a truncated
|
|
133
|
+
traversal is a lower bound.
|
|
134
|
+
3. **Probe the observed-vs-intended gap.** Re-run one hub's paths with
|
|
135
|
+
\`extractionKinds: ["ref", "mention"]\`. Many \`mention\` edges beyond the
|
|
136
|
+
\`ref\` edges = structure living in prose = densification opportunity
|
|
137
|
+
(that's the graph/ontology skill's Recipe 4 — record it, don't fix it
|
|
138
|
+
mid-mapping). Few mentions *and* few refs on a corpus whose bodies
|
|
139
|
+
clearly name other records (Stage 3) = links invisible to tooling
|
|
140
|
+
entirely; note that too.
|
|
141
|
+
4. Cross-type detail questions that surface here ("which open cases belong
|
|
142
|
+
to which client industry?") are \`maad_join\` / ref-chain
|
|
143
|
+
\`maad_aggregate\` one-liners — use them to spot-check, resist per-record
|
|
144
|
+
loops.
|
|
145
|
+
|
|
146
|
+
### Stage 5 — Integrity: where the graph is broken
|
|
147
|
+
|
|
148
|
+
- \`maad_find_orphans\` — per-record broken-ref inventory (which ref fields
|
|
149
|
+
point at nonexistent targets).
|
|
150
|
+
- \`maad_verify mode=integrity\` — the wider sweep (index/document drift,
|
|
151
|
+
schema drift) — cheap insurance that what you just mapped is what's
|
|
152
|
+
actually on disk, especially if the project sees external edits.
|
|
153
|
+
|
|
154
|
+
Findings go **in the map**, not into ad-hoc repair: repair tools follow
|
|
155
|
+
dry-run-then-confirm contracts and deserve a deliberate pass, and on
|
|
156
|
+
read-only deployments mutation isn't yours to do (\`READ_ONLY\` — report,
|
|
157
|
+
don't retry).
|
|
158
|
+
|
|
159
|
+
### Stage 6 — Write the typed map
|
|
160
|
+
|
|
161
|
+
Deliverable: \`_skills/local/corpus-map.md\` — a project-owned overlay file
|
|
162
|
+
(engine refresh never touches it). Create or update; if one existed
|
|
163
|
+
(Stage 1), preserve its history notes and update the snapshot. Suggested
|
|
164
|
+
shape:
|
|
165
|
+
|
|
166
|
+
\`\`\`markdown
|
|
167
|
+
# Corpus Map — <project> (as of <date>)
|
|
168
|
+
|
|
169
|
+
## Types
|
|
170
|
+
| type | count* | pattern | purpose (one line) | key fields |
|
|
171
|
+
|
|
172
|
+
## Edges (intended vs realized)
|
|
173
|
+
| ref field | source → target | declared | usage (aggregate) | mention overflow? |
|
|
174
|
+
|
|
175
|
+
## Annotation practice
|
|
176
|
+
Primitives/subtypes in active use; whether doc-ID mentions are annotated.
|
|
177
|
+
|
|
178
|
+
## Hubs
|
|
179
|
+
Top hub records and what clusters around them (path-walk findings).
|
|
180
|
+
|
|
181
|
+
## Hygiene
|
|
182
|
+
Broken refs / orphans / drift found in Stage 5. Unfixed — inventory only.
|
|
183
|
+
|
|
184
|
+
## Not explored
|
|
185
|
+
Types sampled shallowly, truncated traversals, stages skipped.
|
|
186
|
+
|
|
187
|
+
## Open questions
|
|
188
|
+
Anything the corpus couldn't answer about itself.
|
|
189
|
+
|
|
190
|
+
*counts verified via maad_verify mode=count on <date>
|
|
191
|
+
\`\`\`
|
|
192
|
+
|
|
193
|
+
The map is a **snapshot of project truth, owned by the project** — exactly
|
|
194
|
+
what \`_skills/local/\` is for. It is not engine documentation; never put
|
|
195
|
+
engine-version facts in it (they rot — \`MAAD.md\` owns those).
|
|
196
|
+
|
|
197
|
+
If you lack writer access, deliver the same content as your session report.
|
|
198
|
+
|
|
199
|
+
## After the map — handoffs
|
|
200
|
+
|
|
201
|
+
- Sparse realized graph, rich mention/prose links → load the
|
|
202
|
+
graph/ontology skill (\`_skills/graph-ontology.md\`) and run its
|
|
203
|
+
densification recipe against the map's "mention overflow" column.
|
|
204
|
+
- Schema gaps or evolution needs → Architect mode
|
|
205
|
+
(\`_skills/architect-core.md\` + \`_skills/schema-guide.md\`).
|
|
206
|
+
- Broken refs / drift → a deliberate hygiene pass with the repair tools'
|
|
207
|
+
dry-run contracts; the map's Hygiene section is its worklist.
|
|
208
|
+
|
|
209
|
+
## Non-goals / hand off to the host
|
|
210
|
+
|
|
211
|
+
- No visualization: the map is markdown tables. Rendering it as an
|
|
212
|
+
interactive graph or dashboard is host-side work — never engine core.
|
|
213
|
+
- No repair during mapping — inventory only (Stage 5).
|
|
214
|
+
- No schema edits during mapping — the map may *recommend*; Architect
|
|
215
|
+
executes.
|
|
216
|
+
- No file-system spelunking — if a question can't be answered through the
|
|
217
|
+
tool surface, that inability is itself a finding for the map.
|
|
218
|
+
`;
|
|
219
|
+
}
|
|
220
|
+
//# sourceMappingURL=corpus-explorer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"corpus-explorer.js","sourceRoot":"","sources":["../../src/skills/corpus-explorer.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,wEAAwE;AACxE,+EAA+E;AAE/E,MAAM,UAAU,2BAA2B;IACzC,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqNR,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph-ontology.d.ts","sourceRoot":"","sources":["../../src/skills/graph-ontology.ts"],"names":[],"mappings":"AAIA,wBAAgB,0BAA0B,IAAI,MAAM,CAuPnD"}
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// Graph / Ontology skill — managed instruction generator (fully static).
|
|
3
|
+
// ============================================================================
|
|
4
|
+
export function generateGraphOntologySkill() {
|
|
5
|
+
return `# Working the Project as a Typed Graph
|
|
6
|
+
|
|
7
|
+
> Managed by the MAADb engine — do not edit (changes block future refreshes).
|
|
8
|
+
> Project-specific ontology conventions belong in \`_skills/local/ontology.md\`.
|
|
9
|
+
> Findings and densification notes go there too — never append them to this file.
|
|
10
|
+
|
|
11
|
+
## Purpose
|
|
12
|
+
|
|
13
|
+
You are an agent operating on a MAADB project. This skill teaches you to
|
|
14
|
+
treat the project as a **typed information graph**: to read structure that
|
|
15
|
+
already exists, to choose the right traversal tool for each question, and to
|
|
16
|
+
**densify** the graph — promoting links that live only in prose into typed,
|
|
17
|
+
queryable structure. The engine gives you bounded graph primitives; you are
|
|
18
|
+
the query planner and the ontologist.
|
|
19
|
+
|
|
20
|
+
Audience: any agent with at least reader access. Densification recipes
|
|
21
|
+
(Recipes 4–5) additionally need writer access and — for schema changes — the
|
|
22
|
+
Architect channel described in \`_skills/architect-core.md\`.
|
|
23
|
+
|
|
24
|
+
## When to load this skill
|
|
25
|
+
|
|
26
|
+
- You need to answer connection questions: "how is X related to Y?",
|
|
27
|
+
"what depends on this record?", "walk the chain from case to industry."
|
|
28
|
+
- You are building a report or view that spans record types.
|
|
29
|
+
- You notice the project is **link-poor**: records reference each other in
|
|
30
|
+
body text but \`maad_related\` returns little — structure exists in prose
|
|
31
|
+
but not in the graph.
|
|
32
|
+
- You are establishing or extending naming/linking conventions for a project
|
|
33
|
+
(light ontology work).
|
|
34
|
+
|
|
35
|
+
For first-contact orientation in a project you don't know at all, load
|
|
36
|
+
\`_skills/corpus-explorer.md\` first — it ends where this skill begins.
|
|
37
|
+
|
|
38
|
+
## The graph model — what an edge is
|
|
39
|
+
|
|
40
|
+
The engine derives edges from markdown; SQLite rows are derived data and
|
|
41
|
+
reindex rebuilds them. There are exactly two edge kinds:
|
|
42
|
+
|
|
43
|
+
1. **\`ref\` edges** — frontmatter fields of type \`ref\` (or \`list\` with
|
|
44
|
+
\`item_type: ref\`). Typed by the **field name** (\`client\`, \`parent_case\`,
|
|
45
|
+
\`assigned_attorney\`). This is the *intentional* graph: schema-declared,
|
|
46
|
+
validated, queryable, joinable. Evidence origin is the field; source
|
|
47
|
+
line/block evidence is null.
|
|
48
|
+
2. **\`mention\` edges** — inline annotations \`[[type:value|label]]\` whose
|
|
49
|
+
value is a doc ID with a registered prefix (e.g.
|
|
50
|
+
\`[[identifier:cli-001|the client]]\`). This is the *observed* graph:
|
|
51
|
+
extracted from prose, carrying line and block evidence, but not schema-
|
|
52
|
+
validated. Plain prose that names a record without an annotation creates
|
|
53
|
+
**no edge at all**.
|
|
54
|
+
|
|
55
|
+
The density gradient — prose → annotated mention → typed ref — is the core
|
|
56
|
+
of this skill. Each promotion step makes a link more queryable and more
|
|
57
|
+
verifiable.
|
|
58
|
+
|
|
59
|
+
## Choosing the traversal tool
|
|
60
|
+
|
|
61
|
+
| Question shape | Tool | Why |
|
|
62
|
+
|---|---|---|
|
|
63
|
+
| "What touches this one record?" (1 hop) | \`maad_related\` | Cheapest neighborhood read; direction \`outgoing\` / \`incoming\` / \`both\` (default \`both\`) |
|
|
64
|
+
| "How does A connect to B?" / "what's within N hops?" / "show me the evidence" | \`maad_relationship_paths\` | Bounded multi-hop BFS, deterministic, cycle-safe, returns per-edge evidence and per-node distance |
|
|
65
|
+
| "Give me these fields from many records *and* their ref targets" | \`maad_join\` | One call instead of query → get → get (N+1) chains |
|
|
66
|
+
| "Roll up a metric across a ref hop" ("cases per client industry") | \`maad_aggregate\` with a ref-chain \`groupBy\` (\`"client->industry"\`) | Group-by resolves refs at query time; never iterate records to count |
|
|
67
|
+
| "Where is this record *mentioned* in prose?" | \`maad_search\` (scoped \`value=<docId>\`) or \`maad_relationship_paths\` with \`extractionKinds: ["ref","mention"]\` | Mentions are opt-in on path traversal; search finds the raw extracted objects |
|
|
68
|
+
|
|
69
|
+
Two defaults that will bite you if unexamined:
|
|
70
|
+
|
|
71
|
+
- \`maad_related\` defaults to direction \`both\`; \`maad_relationship_paths\`
|
|
72
|
+
defaults to \`outgoing\`. When a path result looks mysteriously empty, check
|
|
73
|
+
direction first — dependency questions ("what refs this?") need
|
|
74
|
+
\`incoming\` or \`both\`.
|
|
75
|
+
- \`maad_relationship_paths\` traverses **\`ref\` edges only by default**.
|
|
76
|
+
Mentions are opt-in via \`extractionKinds: ["ref", "mention"]\`. If you are
|
|
77
|
+
probing the *observed* graph, you must opt in.
|
|
78
|
+
|
|
79
|
+
Bounds (validated, over-cap values are rejected, not clamped): \`maxDepth\`
|
|
80
|
+
default 2, cap 4 · \`maxNodes\` 50/100 · \`maxEdges\` 100/200 · \`maxPaths\`
|
|
81
|
+
25/50. If a response trips the byte-size guard, narrow with \`fieldLabels\`
|
|
82
|
+
or \`extractionKinds\`, or lower the limits — don't retry as-is.
|
|
83
|
+
|
|
84
|
+
## Recipes
|
|
85
|
+
|
|
86
|
+
### Recipe 1 — Typed neighborhood of one record
|
|
87
|
+
|
|
88
|
+
Goal: everything structurally connected to \`cas-012\`, with meaning.
|
|
89
|
+
|
|
90
|
+
1. \`maad_get cas-012 hot\` — its own typed fields.
|
|
91
|
+
2. \`maad_related docId=cas-012 direction=both\` — 1-hop adjacency; note the
|
|
92
|
+
**field names** on each edge (they are your edge types).
|
|
93
|
+
3. Where you need target detail for several neighbors of the same type,
|
|
94
|
+
don't loop \`maad_get\` — use \`maad_join\` on the source type with
|
|
95
|
+
\`refFields\` (Recipe 6).
|
|
96
|
+
4. Only escalate to \`maad_relationship_paths\` if 1 hop is insufficient.
|
|
97
|
+
|
|
98
|
+
### Recipe 2 — Connection between two specific records
|
|
99
|
+
|
|
100
|
+
Goal: does \`cas-012\` connect to \`con-007\`, and through what?
|
|
101
|
+
|
|
102
|
+
\`\`\`
|
|
103
|
+
maad_relationship_paths
|
|
104
|
+
startDocId: cas-012
|
|
105
|
+
targetDocId: con-007
|
|
106
|
+
direction: both
|
|
107
|
+
maxDepth: 3
|
|
108
|
+
\`\`\`
|
|
109
|
+
|
|
110
|
+
Read the result as claims with proof: each edge carries \`fieldLabel\`,
|
|
111
|
+
extraction kind, and canonical evidence (source line + block for mentions;
|
|
112
|
+
field origin for refs). When you report the connection, cite the doc IDs on
|
|
113
|
+
the path — and for mention-backed hops, treat the link as *observed, not
|
|
114
|
+
validated* and say so.
|
|
115
|
+
|
|
116
|
+
A \`state: missing\` node on a path is a **broken ref** — the edge exists but
|
|
117
|
+
the target doesn't. Report it (and see Recipe 7); missing targets are
|
|
118
|
+
terminal, so real connectivity may be wider than what a broken hop shows.
|
|
119
|
+
|
|
120
|
+
### Recipe 3 — Bounded exploration outward from a hub
|
|
121
|
+
|
|
122
|
+
Goal: the working set within 2 hops of a central record.
|
|
123
|
+
|
|
124
|
+
\`\`\`
|
|
125
|
+
maad_relationship_paths
|
|
126
|
+
startDocId: cli-001
|
|
127
|
+
direction: both
|
|
128
|
+
maxDepth: 2
|
|
129
|
+
fieldLabels: [client, parent_case] # optional: only these edge types
|
|
130
|
+
\`\`\`
|
|
131
|
+
|
|
132
|
+
Use \`nodes[].distance\` to organize the result into rings. Check
|
|
133
|
+
\`truncation.truncated\` and \`limitsReached\` **before** summarizing — a
|
|
134
|
+
truncated traversal is a lower bound, not a census, and your summary must
|
|
135
|
+
say which limit was hit if one was.
|
|
136
|
+
|
|
137
|
+
### Recipe 4 — Promote prose links to typed structure (densification)
|
|
138
|
+
|
|
139
|
+
Goal: links that exist only in narrative become schema-typed refs.
|
|
140
|
+
|
|
141
|
+
1. **Find candidates.** Probe the observed graph:
|
|
142
|
+
\`maad_relationship_paths\` from key records with
|
|
143
|
+
\`extractionKinds: ["ref","mention"]\`, \`maxDepth: 1\` — every \`mention\`
|
|
144
|
+
edge is a candidate. Corpus-wide, \`maad_search\` with \`value=<docId>\`
|
|
145
|
+
scoped per hub record inventories where it's mentioned. (Prose links with
|
|
146
|
+
no annotation at all are invisible to tools — surfacing those is judgment
|
|
147
|
+
work while reading \`cold\` bodies.)
|
|
148
|
+
2. **Decide if the link is structural.** Promote when the relationship is:
|
|
149
|
+
queried or filtered on; needed in joins/aggregates; integrity-relevant
|
|
150
|
+
(should break loudly if the target vanishes); or cardinality-stable
|
|
151
|
+
(every case has a client). Leave as mention/prose when it's incidental
|
|
152
|
+
commentary.
|
|
153
|
+
3. **Type it.** If a suitable \`ref\` field exists in the schema, done. If
|
|
154
|
+
not, this is a schema change — an **additive** new \`ref\` field (with
|
|
155
|
+
\`target\` and \`index: true\`) via the Architect channel
|
|
156
|
+
(\`_skills/architect-core.md\`): registry/schema edits go through the
|
|
157
|
+
deployment's approved channel, then \`maad_reload\`. Never write schema
|
|
158
|
+
files through record tools.
|
|
159
|
+
4. **Set the field.** \`maad_update\` per record (sequential; pass
|
|
160
|
+
\`expectedVersion\` when you hold a read), or \`maad_bulk_update\` for a
|
|
161
|
+
genuine batch. Keep the prose mention — you are adding structure, not
|
|
162
|
+
rewriting narrative.
|
|
163
|
+
5. **Verify.** \`maad_related\` on a sample now shows the edge with the new
|
|
164
|
+
field label; \`maad_find_orphans docType=<type>\` catches typo'd targets
|
|
165
|
+
immediately.
|
|
166
|
+
6. **Record the convention** in \`_skills/local/ontology.md\` (Recipe 5) so
|
|
167
|
+
the next agent types new records the same way.
|
|
168
|
+
|
|
169
|
+
### Recipe 5 — Light ontology, MAADB-style
|
|
170
|
+
|
|
171
|
+
An ontology here is **conventions, not a reasoner**:
|
|
172
|
+
|
|
173
|
+
- **Classes** = registered doc types.
|
|
174
|
+
- **Typed predicates** = \`ref\` field names. Name them as relations
|
|
175
|
+
(\`parent_case\`, \`assigned_attorney\`), not generically (\`link1\`, \`related\`).
|
|
176
|
+
The field name is the only edge label the graph has — spend it well.
|
|
177
|
+
- **Controlled vocabularies** = \`enum\` fields.
|
|
178
|
+
- **Annotation vocabulary** = the 11 fixed primitives plus registry
|
|
179
|
+
\`extraction.subtypes\` (e.g. \`attorney: entity\`). Subtypes make
|
|
180
|
+
\`maad_search\` domain-aware without engine changes.
|
|
181
|
+
|
|
182
|
+
The ontology's *documentation* lives in \`_skills/local/ontology.md\` — a
|
|
183
|
+
project-owned overlay file you create and maintain (it survives engine
|
|
184
|
+
refreshes). Keep it short and normative: one table of types, one table of
|
|
185
|
+
ref fields with their meaning and cardinality, the subtype vocabulary, and
|
|
186
|
+
the annotation policy ("always annotate doc-ID mentions in prose as
|
|
187
|
+
\`[[identifier:<docId>|label]]\`" is the single highest-leverage rule, because
|
|
188
|
+
it feeds Recipe 4's candidate pipeline).
|
|
189
|
+
|
|
190
|
+
Schema *changes* implied by ontology work are Architect work — hand off to
|
|
191
|
+
\`_skills/architect-core.md\`; do not duplicate its channel rules here.
|
|
192
|
+
|
|
193
|
+
### Recipe 6 — Cross-type reports and views
|
|
194
|
+
|
|
195
|
+
Row-level view ("open cases with client name and industry"):
|
|
196
|
+
|
|
197
|
+
\`\`\`
|
|
198
|
+
maad_join
|
|
199
|
+
docType: case
|
|
200
|
+
filters: { status: open }
|
|
201
|
+
refs: [client]
|
|
202
|
+
fields: [title, status, opened_at]
|
|
203
|
+
refFields: { client: [name, industry] }
|
|
204
|
+
\`\`\`
|
|
205
|
+
|
|
206
|
+
Rollup ("case count by client industry"):
|
|
207
|
+
|
|
208
|
+
\`\`\`
|
|
209
|
+
maad_aggregate
|
|
210
|
+
docType: case
|
|
211
|
+
groupBy: "client->industry"
|
|
212
|
+
filters: { status: open }
|
|
213
|
+
\`\`\`
|
|
214
|
+
|
|
215
|
+
Compose the two into a markdown report (summary table from \`aggregate\`,
|
|
216
|
+
detail table from \`join\`) and — if the report should persist — write it as a
|
|
217
|
+
record via \`maad_create\` in a report-ish doc type if the project has one.
|
|
218
|
+
Ground every number you state: \`maad_verify mode=count\` (or \`mode=field\`)
|
|
219
|
+
before presenting totals as fact. Rendering to anything richer than
|
|
220
|
+
markdown, and publishing anywhere, is host work (see Non-goals).
|
|
221
|
+
|
|
222
|
+
### Recipe 7 — Graph hygiene
|
|
223
|
+
|
|
224
|
+
Run before *and* after densification passes:
|
|
225
|
+
|
|
226
|
+
- \`maad_find_orphans\` — records whose ref fields point at nonexistent
|
|
227
|
+
targets (broken refs, per-record detail).
|
|
228
|
+
- \`maad_verify mode=integrity\` — the broader sweep (index drift, schema
|
|
229
|
+
drift, broken refs) after pulls or external edits.
|
|
230
|
+
- \`maad_validate\` after any schema evolution — see \`_skills/schema-guide.md\`
|
|
231
|
+
§ versioning for the migrate-or-grandfather discipline.
|
|
232
|
+
|
|
233
|
+
A densification pass that introduces broken refs has made the graph *worse*
|
|
234
|
+
— typed-but-wrong beats untyped only if you catch it, which is why Recipe 4
|
|
235
|
+
ends in \`maad_find_orphans\`.
|
|
236
|
+
|
|
237
|
+
## Non-goals / hand off to the host
|
|
238
|
+
|
|
239
|
+
- **No visualization here.** Emitting a small inline Mermaid/DOT sketch in
|
|
240
|
+
chat from path output is fine as ordinary agent output; anything
|
|
241
|
+
interactive, rendered, served, or saved as an artifact belongs to
|
|
242
|
+
host-side skills — never to \`@maadb/core\`.
|
|
243
|
+
- **No query language.** You compose bounded primitives; there is no Cypher
|
|
244
|
+
and none is coming.
|
|
245
|
+
- **No inference engine.** Do not invent transitive/derived edges and
|
|
246
|
+
present them as data — a multi-hop path is evidence of connection, not a
|
|
247
|
+
new fact. If a derived relationship matters, promote it explicitly
|
|
248
|
+
(Recipe 4) so it becomes a real, validated edge.
|
|
249
|
+
- **No schema writes through record tools** — Architect channel only.
|
|
250
|
+
`;
|
|
251
|
+
}
|
|
252
|
+
//# sourceMappingURL=graph-ontology.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph-ontology.js","sourceRoot":"","sources":["../../src/skills/graph-ontology.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,yEAAyE;AACzE,+EAA+E;AAE/E,MAAM,UAAU,0BAA0B;IACxC,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqPR,CAAC;AACF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maadb/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"description": "Markdown As A Database — treats markdown as the canonical data store, builds a queryable index, and gives LLMs deterministic read/write access.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -48,10 +48,10 @@
|
|
|
48
48
|
"node": ">=24.0.0"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@modelcontextprotocol/sdk": "1.
|
|
51
|
+
"@modelcontextprotocol/sdk": "1.30.0",
|
|
52
52
|
"better-sqlite3": "12.11.1",
|
|
53
53
|
"gray-matter": "~4.0.3",
|
|
54
|
-
"js-yaml": "~4.3.
|
|
54
|
+
"js-yaml": "~4.3.1",
|
|
55
55
|
"pino": "10.3.1",
|
|
56
56
|
"simple-git": "3.36.0"
|
|
57
57
|
},
|