@convesoft/mara 0.2.0 → 0.3.0-alpha.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 CHANGED
@@ -5,12 +5,13 @@ designs, decisions, and other durable facts stable identities, types, relations,
5
5
  validation, and deterministic retrieval. A CLI and stdio MCP server share the
6
6
  same operations, including discovery of narrative outside items.
7
7
 
8
- Mara 0.2.0 provides schema format 2 with flavour
9
- selection guidance, an engineering template, and unified `search`, `get`, and
10
- `related`. Start with the [0.2 migration guide](docs/migration-0.2.mara.md) for
11
- an existing project. The [0.1.0 documentation](https://github.com/convesoft/mara/tree/v0.1.0)
12
- describes the older released interface; use documentation and skill from the
13
- same revision as your executable.
8
+ This checkout adds typed inline relationships, metadata inverse aliases,
9
+ symmetric relationships, and occurrence inspection to the unified `search`,
10
+ `get`, and `related` workflow.
11
+ It requires schema format 3 and emits discovery format 2. Follow the
12
+ [relationship migration contract](docs/relations.mara.md) for existing projects.
13
+ Published 0.2.0 still uses schema format 2 and discovery format 1; use its
14
+ [documentation](https://github.com/convesoft/mara/tree/v0.2.0) and matching skill.
14
15
 
15
16
  ## Run Mara
16
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@convesoft/mara",
3
- "version": "0.2.0",
3
+ "version": "0.3.0-alpha.0",
4
4
  "description": "Structured project knowledge CLI and MCP server",
5
5
  "author": "Aliaksei Raketski",
6
6
  "license": "MIT OR Apache-2.0",
@@ -18,10 +18,10 @@
18
18
  "node": ">=18"
19
19
  },
20
20
  "optionalDependencies": {
21
- "@convesoft/mara-linux-x64-gnu": "0.2.0",
22
- "@convesoft/mara-linux-arm64-gnu": "0.2.0",
23
- "@convesoft/mara-darwin-x64": "0.2.0",
24
- "@convesoft/mara-darwin-arm64": "0.2.0"
21
+ "@convesoft/mara-linux-x64-gnu": "0.3.0-alpha.0",
22
+ "@convesoft/mara-linux-arm64-gnu": "0.3.0-alpha.0",
23
+ "@convesoft/mara-darwin-x64": "0.3.0-alpha.0",
24
+ "@convesoft/mara-darwin-arm64": "0.3.0-alpha.0"
25
25
  },
26
26
  "files": [
27
27
  "bin/mara.cjs",
package/plugin.json CHANGED
@@ -15,5 +15,5 @@
15
15
  "mcp",
16
16
  "agent-skill"
17
17
  ],
18
- "version": "0.2.0"
18
+ "version": "0.3.0-alpha.0"
19
19
  }
@@ -10,8 +10,11 @@ When MCP is unavailable, use an available Mara CLI invocation with `--format jso
10
10
  for structured results. The same operation selection, authoring, continuation,
11
11
  and validation rules apply to both surfaces.
12
12
 
13
- This skill targets the 0.2 interface: schema format 2 and unified `search`,
14
- `get`, and `related`. Use the skill shipped with the selected executable or
13
+ This skill targets the current 0.3 development interface: schema format 3,
14
+ discovery format 2, relationship format 1, validation format 1, and trace
15
+ format 1. Typed inline relationships, inverse aliases, symmetric edges,
16
+ external targets, graph policies, YAML current-state rules, and matrices are
17
+ implemented. Use the skill shipped with the selected executable or
15
18
  the same source revision. If an older installation exposes a different
16
19
  interface, report the mismatch and use its matching guidance; do not silently
17
20
  change the version pin or substitute removed commands.
@@ -71,12 +74,12 @@ Use the selected project's declarations, including custom flavours. Keep
71
74
  supporting narrative as Markdown when it does not need an independent identity;
72
75
  search/get/related can still discover, read, and navigate it.
73
76
 
74
- Schema format 2 requires all four guidance keys directly on every flavour:
77
+ Schema format 3 retains all four guidance keys directly on every flavour:
75
78
  a nonblank `description`, a nonempty list of nonblank `use_when` entries,
76
79
  an `avoid_when` list (`[]` is valid), and a `distinguish_from` mapping (`{}` is
77
80
  valid). Distinction targets must be other declared flavours with nonblank
78
81
  explanations. When asked to migrate format 1, edit the existing schema in place,
79
- set `format_version: 2`, and supply meaningful guidance. Preserve custom
82
+ set `format_version: 3`, and supply meaningful guidance. Preserve custom
80
83
  flavours, prefixes, fields, relations, document bytes, IDs, and MIDs; do not
81
84
  reinitialize or replace the schema with a template. Require `valid:true` from
82
85
  both `schema_validate` and `project_validate` (CLI `schema validate` and
@@ -107,9 +110,39 @@ inspect `<command> --help` for positional arguments and options.
107
110
  | Change title, custom fields, or body | `item_update` | `item update` |
108
111
  | Relocate an item; preserve ID and MID | `item_move` | `item move` |
109
112
  | Change human ID and supported references; preserve MID | `item_rename` | `item rename` |
113
+ | Inspect an edge and its source occurrences | `relation_get` | `relation get SOURCE RELATION TARGET` |
110
114
  | Add or remove an existing item's typed edge | `relation_add` or `relation_remove` | `relation add`, `relation remove` |
111
115
  | Delete an item; resolve reported relation/mention blockers | `item_delete` | `item delete` |
112
116
  | Check an item or whole-project integrity | `item_validate` or `project_validate` | `item validate`, `project validate` |
117
+ | Inspect coverage for selected roots | `trace_matrix` | `trace matrix` |
118
+
119
+ Validation (`project_validate`, `item_validate`, `schema_validate`) returns
120
+ `valid`, `evaluation_complete`, `summary`, `diagnostics`, and output
121
+ continuation. Match diagnostic `code` and `severity`, not message text.
122
+ Warnings do not invalidate a complete result; configuration/source failures
123
+ remain errors. Current-state rules load from explicit YAML files enabled by
124
+ project format 2 and `[rules]` with `format_version = 1` and `files = [...]`.
125
+ Run `schema_validate` to check definitions, then `project_validate` or
126
+ `item_validate` to evaluate policy. Status/owner fields are project-defined;
127
+ templates and existing projects gain no policies automatically. Schema relation
128
+ `cardinality` and `acyclic` declarations impose structural graph policies when
129
+ present. Policy failures do not block structured edits.
130
+ Invalid schemas now return the common envelope with `valid:false`, not an MCP
131
+ tool error. Counts are null when the schema cannot load. Diagnostic `path` and
132
+ `line` alias `location`; project-owned configuration paths are relative and
133
+ unavailable coordinates are omitted.
134
+
135
+ All three validation operations accept `limit` (1–100, default 20) and `cursor`;
136
+ CLI uses `--limit` and `--cursor`.
137
+ Continue unchanged inputs until `has_more:false`; summary
138
+ and validity cover the full target before pagination and reporting paths.
139
+ With configured rules, invalid corpus prerequisites skip policy evaluation,
140
+ including item-targeted checks. Fix the original diagnostics and run validation
141
+ again. `evaluation_unavailable` never means a policy pass. There is no logical
142
+ work counter; finite shape/path restrictions and output pagination remain.
143
+ Invalid arguments, stale cursors,
144
+ I/O preventing a result, and oversized indivisible output return
145
+ `{format_version:1,error:{code,message}}` with MCP `isError:true`.
113
146
 
114
147
  Use mutations only when the user has asked to change project knowledge. Choose
115
148
  the structured mutation for the semantic change. An invalid-argument error calls
@@ -136,11 +169,12 @@ accept `limit`.
136
169
 
137
170
  Call `related` with `{"reference":"<selected reference>"}` for direct schema
138
171
  relations, mentions, and containment. It returns `node` and
139
- `connections:[{relation,direction,neighbour,source}]`; pass a selected
172
+ `connections`; pass a selected
140
173
  `neighbour.reference` to `get` or another `related` call. Each call follows only
141
174
  direct connections; there is no automatic expansion or hops option.
142
175
 
143
- Use `direction:"incoming"` or `"outgoing"`; omission includes both. Related
176
+ Use `direction:"incoming"`, `"outgoing"`, or `"symmetric"`; omission includes all.
177
+ Direction is canonical even when a relation filter uses an inverse alias. Related
144
178
  `relations` accepts `schema:name` and `builtin:name`, with short names allowed
145
179
  only when unambiguous in the vocabulary. Related `flavours` selects item
146
180
  neighbours only. JSON represents containment as `contains` with direction;
@@ -161,8 +195,8 @@ Item MIDs retain durable identity. Search and related default to 20 entries
161
195
  and accept `limit` from 1 through 100; related counts connections, including
162
196
  different connections to the same neighbour. The byte budget may shorten pages.
163
197
 
164
- Unified discovery responses use `format_version: 1`, independently of schema
165
- format 2 and the application version. Inspect `node.kind` (item, section, block,
198
+ Unified discovery responses use `format_version: 2`, independently of schema
199
+ format 3 and the application version. Inspect `node.kind` (item, section, block,
166
200
  or document); only items have ID/MID/flavour. Item list retains its item-only
167
201
  response. On upgrade, discard old cursors and update parsers for the mixed
168
202
  `results`, consecutive `content`, and `connections` shapes above.
@@ -173,6 +207,86 @@ then `"${mara_cli[@]}" --project /absolute/project --format json get '<reference
173
207
  Use `related '<reference>'` for connections, `--relation builtin:mentions` to
174
208
  select explicit mentions, and `--cursor '<next_cursor>'` for continuation.
175
209
 
210
+ ## Inspect and change relationships
211
+
212
+ Schema lookup accepts inverse aliases and returns the canonical declaration,
213
+ `requested_name` and `inverse`. Lists show canonical names with aliases and
214
+ symmetry. Alias endpoint validation exchanges source and target first.
215
+
216
+ `related` returns each semantic schema edge once, with canonical `relation`,
217
+ endpoint-facing `label`, `direction`, `neighbour`, `edge` and `occurrence_count`.
218
+ Builtin connections retain `source`; use `relation_get` for schema locations.
219
+ Symmetric edges are excluded by incoming/outgoing filters. Directed self-edges
220
+ appear once as outgoing when direction is omitted. Different relation kinds
221
+ remain distinct. Item-list/search filters still select items with authored
222
+ metadata or inline assertions; canonical and alias filters select the same kind.
223
+
224
+ `relation_get {source,relation,target,limit?,cursor?}` returns the canonical
225
+ `edge`, total `occurrence_count` and a page of `occurrences`. Each occurrence
226
+ retains its author, spelling, source location and opaque `reference` selector.
227
+ Default limit is 20, maximum 100, with a 65,536-byte budget. Continue unchanged
228
+ until `has_more:false`; re-inspect after source/schema changes.
229
+
230
+ Add rejects an edge already asserted anywhere, including inverse, symmetric
231
+ and inline ID/MID equivalents. Direct source may intentionally repeat assertions.
232
+ `relation_remove {source,relation,target}` removes every occurrence across
233
+ included files. Supply `occurrence` from inspection to remove exactly one.
234
+ Stale or mismatched selectors fail without writes. Results report
235
+ `changed_occurrences`, `remaining_occurrences` and `edge_exists`. Inline removal
236
+ demotes internal `[[relation:target]]` to `[[target]]` and external assertions
237
+ to Markdown autolinks, preserving surrounding prose. The retained internal
238
+ mention still blocks deletion of its target.
239
+
240
+ Author `[[relation:ID]]`, `[[relation:MID]]`, or
241
+ `[[relation:external:https://host/path]]` in an item body using a canonical
242
+ schema name or inverse alias. External targets require `external: true` on the
243
+ relation declaration; Mara preserves their authored address and never fetches it.
244
+ No whitespace, labels or nested markup is allowed
245
+ inside the token. These assertions share metadata edge identity and produce no
246
+ builtin mention. Code, raw contexts and escaped openings remain literal; typed
247
+ tokens outside item bodies have no typed meaning. Unknown relations, malformed
248
+ tokens and invalid targets in supported contexts fail validation. Use body
249
+ creation/update to author inline assertions; relation add writes metadata.
250
+
251
+ For a format-1/2 or relation-vocabulary migration, follow
252
+ `docs/migration-0.3.mara.md` with the matching 0.3 executable. The supported
253
+ workflow is manual: save a Git checkpoint or project copy, review the complete
254
+ source diff, then require complete, valid schema and project validation. Mara
255
+ has no schema migration preview/apply command; `project_transaction_rollback`
256
+ does not undo manual edits. Preserve MIDs and unrelated declarations, fields,
257
+ prose and links. Existing relations remain directed with no alias unless the
258
+ schema explicitly changes. Review newly meaningful typed tokens, alias
259
+ collisions, all authored spellings and YAML rule paths before changing names.
260
+ When removing an inverse alias, inspect the canonical edge, reauthor it on its
261
+ canonical source if needed, remove inverse metadata, and demote inverse inline
262
+ tokens to bare mentions when preserving prose navigation. Never replace an
263
+ inverse name with the canonical name on the same item: that can reverse a
264
+ directed edge while validation still passes. Verify the canonical endpoints
265
+ after migration. Do not treat a direction, endpoint or meaning change as a
266
+ rename.
267
+
268
+ ## Inspect trace coverage
269
+
270
+ Use `trace_matrix` (CLI `trace matrix`) for a read-only view of selected roots.
271
+ Select roots with `ids`, `flavours`, `fields`, `paths`, or `all:true`; pass either
272
+ enabled rule IRIs in `rules` or a request-local `check:{files,shape}`. CLI uses
273
+ repeatable `--id`, `--flavour`, `--field KEY=VALUE`, `--path`, and either
274
+ `--rule` or `--check-file` with `--shape`. Do not mix the two evaluation modes.
275
+ The check files supply shapes for this request only; they do not enable policy
276
+ for project validation. A named rule uses its own applicability and selection
277
+ within the requested roots.
278
+
279
+ Read each result state (`passed`, `failed`, `not_applicable`, `unavailable`),
280
+ the check and edge records, source locations, and per-evaluation `summaries`.
281
+ An external endpoint is terminal; an edge outside root selection can still
282
+ contribute to a check. Known rule failures are matrix data, while
283
+ `evaluation_complete:false` means the view could not be fully evaluated.
284
+ Continue with unchanged inputs and `next_cursor` until `has_more:false`;
285
+ restart after source, schema, or rule changes. CLI defaults to Markdown for
286
+ this command; `--format json` returns trace format 1. MCP returns JSON and
287
+ accepts `render:"markdown"` for the matching Markdown page. The output is a
288
+ projection, not a saved source of project knowledge.
289
+
176
290
  ## Preserve authored references
177
291
 
178
292
  Use `[[ID]]`/`[[MID]]` in item bodies or narrative for item mentions, and
@@ -204,7 +318,7 @@ The shared `:key: value` source syntax does not make these interchangeable:
204
318
  - **Typed relations:** `justifies` and `satisfies` are relations, not custom
205
319
  fields. `fields:[{"key":"justifies","value":"REQ-EXAMPLE"}]` is invalid.
206
320
  Use creation `relations` or explicit relation operations; inspect allowed
207
- source/target flavours first. Incoming backlinks are derived, never authored.
321
+ source/target flavours first. Use canonical names or declared inverse aliases; reverse navigation is derived.
208
322
 
209
323
  CLI equivalents are `--title`, repeatable `--field KEY=VALUE`, update
210
324
  `--clear-field KEY`, and creation `--relation NAME=TARGET`. Never pass a relation