mirai-graph 1.0.0 → 1.1.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.
Files changed (30) hide show
  1. package/.github/workflows/ci.yml +19 -0
  2. package/CHANGELOG.md +30 -0
  3. package/CITATION.cff +2 -1
  4. package/README.md +21 -2
  5. package/ROADMAP.md +11 -16
  6. package/docs/adoption/cli.md +16 -1
  7. package/examples/project-technology-context-traversal/README.md +17 -0
  8. package/examples/project-technology-context-traversal/graph/objects.json +78 -0
  9. package/examples/project-technology-context-traversal/graph/relations.json +47 -0
  10. package/examples/project-technology-context-traversal/graph.json +30 -0
  11. package/examples/project-technology-context-traversal/selection.example.json +29 -0
  12. package/examples/project-technology-context-traversal/sources/announcement.md +3 -0
  13. package/examples/project-technology-context-traversal/sources/release-guide.md +3 -0
  14. package/examples/project-technology-context-traversal/sources/release-smoke.md +3 -0
  15. package/examples/project-technology-context-traversal/sources/rollback-policy.md +3 -0
  16. package/package.json +4 -3
  17. package/packages/cli/project-technology.js +43 -3
  18. package/packages/cli/validate-context-traversal.js +232 -0
  19. package/packages/cli/validate-mirai-graph.js +21 -2
  20. package/packages/project-technology/context-traversal.js +589 -0
  21. package/packages/project-technology/index.js +23 -40
  22. package/releases/1.1.0.md +36 -0
  23. package/releases/README.md +2 -0
  24. package/schemas/context-pack.schema.json +54 -1
  25. package/schemas/context-traversal-receipt.schema.json +64 -0
  26. package/standard/context-pack-generation.md +38 -1
  27. package/standard/object-model.md +11 -2
  28. package/standard/project-technology.md +37 -1
  29. package/standard/relation-model.md +11 -1
  30. package/standard/test-suite.md +5 -1
@@ -13,6 +13,7 @@ const {
13
13
  readJson,
14
14
  validateManifest,
15
15
  } = require("../cli/graph-manifest");
16
+ const traversal = require("./context-traversal");
16
17
 
17
18
  const CONTRACT_VERSION = "1.0.0";
18
19
  const EXTENSION_KEY = "mirai.project_technology";
@@ -412,48 +413,26 @@ function inventory(repo) {
412
413
  return payload;
413
414
  }
414
415
 
415
- function loadObjects(repo, manifest) {
416
- const objects = [];
417
- for (const file of specObjectFiles(repo, manifest)) {
418
- try {
419
- const item = readJson(file);
420
- const lifecycle = String(item.lifecycle || item.status || "").toLowerCase();
421
- if (!["archived", "superseded", "deprecated", "retired", "completed"].includes(lifecycle)) objects.push(item);
422
- } catch (_) { /* unavailable sources are omitted and reported through empty result */ }
423
- }
424
- return objects;
425
- }
426
-
427
416
  function context(repoArg, options = {}) {
428
- const repo = normalizeRepo(repoArg);
429
- const manifestState = readManifest(repo);
430
- const ext = extensionState(manifestState.manifest);
431
- const task = String(options.task || "").trim();
432
- const tokens = new Set(task.toLowerCase().split(/[^a-zа-я0-9_]+/i).filter((item) => item.length > 2));
433
- const ranked = loadObjects(repo, manifestState.manifest).map((object) => {
434
- const text = [object.id, object.kind, object.subtype, object.title, object.summary, ...(object.tags || [])].join(" ").toLowerCase();
435
- const objectTokens = new Set(text.split(/[^a-zа-я0-9_]+/i).filter((item) => item.length > 2));
436
- const overlap = [...tokens].filter((token) => objectTokens.has(token)).length;
437
- const baseline = ["skill_core", "skill_policy", "quality_gate"].includes(object.subtype) ? 0.15 : 0;
438
- return {
439
- object_id: object.id,
440
- score: Math.min(1, baseline + overlap * 0.18),
441
- title: object.title || null,
442
- summary: object.summary || null,
443
- source_refs: Array.isArray(object.source_refs) ? object.source_refs.filter((ref) => typeof ref === "string" && !path.isAbsolute(ref)) : [],
444
- };
445
- }).filter((item) => item.score > 0).sort((a, b) => b.score - a.score || String(a.object_id).localeCompare(String(b.object_id))).slice(0, Number(options.maxObjects || 12));
446
- const blockers = [...manifestState.blockers, ...ext.blockers];
447
- if (!ext.contract || ext.legacy || ext.contract.enabled !== true) blockers.push("project_technology_not_enabled");
448
- if (ranked.length === 0) blockers.push("no_verifiable_runtime_objects");
449
- return result("context", "read_only", blockers.length ? "blocked" : "success", {
450
- repository_id: manifestState.manifest?.id || path.basename(repo),
451
- task,
452
- included_objects: ranked,
417
+ if (options.phase === "expand") return traversal.expandContext(repoArg, options.traversalReceipt, options.selectedIds, options);
418
+ if (options.phase === "compile") return traversal.compileContext(repoArg, options.traversalReceipt, options.selection, options);
419
+ if (options.phase === "verify") return traversal.verifyContext(repoArg, options.contextPack, options.usageEvidence, options);
420
+ if (options.phase === "discover") return traversal.discoverContext(repoArg, options.task, options);
421
+ const discovered = traversal.discoverContext(repoArg, options.task, options);
422
+ const nodes = new Map((discovered.traversal_receipt?.nodes || []).map((node) => [node.id, node]));
423
+ return {
424
+ ...discovered,
425
+ operation_id: "mirai.project_technology.context",
426
+ task: discovered.traversal_receipt?.task?.text || "",
427
+ included_objects: (discovered.traversal_receipt?.candidates || []).map((candidate) => ({
428
+ object_id: candidate.id,
429
+ score: candidate.score,
430
+ title: nodes.get(candidate.id)?.title || null,
431
+ summary: nodes.get(candidate.id)?.summary || null,
432
+ source_refs: (nodes.get(candidate.id)?.source_refs || []).map((source) => source.ref),
433
+ })),
453
434
  runtime_contract: { graph_first_scope: "routing/capability/policy orientation", raw_source_authoritative: true, canonical_write_allowed: false },
454
- blockers: [...new Set(blockers)].sort(),
455
- next_action: blockers.length ? "repair graph coverage or load the declared raw source" : "load selected raw source references",
456
- });
435
+ };
457
436
  }
458
437
 
459
438
  function targetBindingStatus(repo) {
@@ -721,11 +700,14 @@ module.exports = {
721
700
  bindingValues,
722
701
  canonicalBytes,
723
702
  connect,
703
+ compileContext: traversal.compileContext,
724
704
  context,
705
+ discoverContext: traversal.discoverContext,
725
706
  disable,
726
707
  disconnect,
727
708
  enable,
728
709
  execute,
710
+ expandContext: traversal.expandContext,
729
711
  explain,
730
712
  extensionContract,
731
713
  inventory,
@@ -739,4 +721,5 @@ module.exports = {
739
721
  sync,
740
722
  targetBindingStatus,
741
723
  verify,
724
+ verifyContext: traversal.verifyContext,
742
725
  };
@@ -0,0 +1,36 @@
1
+ # Mirai Graph 1.1.0
2
+
3
+ Mirai Graph 1.1.0 adds universal, sequential context traversal to the existing
4
+ Project Technology mechanism.
5
+
6
+ ## What changed
7
+
8
+ - A caller can discover top-level candidates, expand selected branches to any
9
+ depth, compile the mandatory closure and verify actual use.
10
+ - The same protocol is available through the CLI and JavaScript API.
11
+ - Required processes, constraints and validators are included independently of
12
+ a model's selection.
13
+ - Context packs are deterministic, revision-bound and safe to transfer without
14
+ copying private source content.
15
+
16
+ ## What was validated
17
+
18
+ - Software, research, organization, platform, skill-like and
19
+ multi-repository fixtures.
20
+ - Sequential and batched expansion equivalence.
21
+ - Fail-closed behavior for incomplete, stale, blocked, deprecated, conflicting,
22
+ cyclic, tampered and over-budget context.
23
+ - Zero-write read-only behavior and compatibility with the existing Project
24
+ Technology provider/consumer contract.
25
+ - A dedicated traversal job on macOS, Linux and Windows.
26
+
27
+ ## Compatibility
28
+
29
+ `graph.json` remains schema `2.0.0`; the Project Technology activation contract
30
+ remains `1.0.0`; existing graphs do not require migration.
31
+
32
+ ## Claim boundary
33
+
34
+ The release proves deterministic contract behavior on the maintained fixtures.
35
+ It does not claim that automatic ranking alone understands every domain or that
36
+ a generated context pack authorizes changes.
@@ -15,6 +15,8 @@ Release notes must separate:
15
15
 
16
16
  ## Release Notes
17
17
 
18
+ - [v1.1.0](1.1.0.md) - universal sequential context traversal and usage
19
+ verification in Project Technology.
18
20
  - [v1.0.0](1.0.0.md) - stable Project Technology, CLI and public contract.
19
21
  - [v1.0.0-rc.6](1.0.0-rc.6.md) - anti-drift / quality-control release
20
22
  consolidation across Semantic Intent, Dynamic Episode, Goal Vector and
@@ -130,8 +130,61 @@
130
130
  "limitations": {
131
131
  "type": "array",
132
132
  "items": {
133
- "type": "string"
133
+ "type": ["string", "object"]
134
+ }
135
+ },
136
+ "task_digest": {
137
+ "type": "string",
138
+ "pattern": "^sha256:[0-9a-f]{64}$"
139
+ },
140
+ "graph_digest": {
141
+ "type": "string",
142
+ "pattern": "^sha256:[0-9a-f]{64}$"
143
+ },
144
+ "graph_revision": {
145
+ "type": ["string", "null"]
146
+ },
147
+ "selected_paths": {
148
+ "type": "array",
149
+ "items": { "type": "object" }
150
+ },
151
+ "rejected_paths": {
152
+ "type": "array",
153
+ "items": { "type": "object" }
154
+ },
155
+ "visited_nodes": {
156
+ "type": "array",
157
+ "items": { "type": "string" },
158
+ "uniqueItems": true
159
+ },
160
+ "stop_reasons": {
161
+ "type": "array",
162
+ "items": { "type": "object" }
163
+ },
164
+ "required_closure": {
165
+ "type": "object",
166
+ "required": ["object_ids", "relation_ids"],
167
+ "properties": {
168
+ "object_ids": { "type": "array", "items": { "type": "string" }, "uniqueItems": true },
169
+ "relation_ids": { "type": "array", "items": { "type": "string" }, "uniqueItems": true }
134
170
  }
171
+ },
172
+ "terminal_sources": {
173
+ "type": "array",
174
+ "items": { "type": "object" }
175
+ },
176
+ "completeness": {
177
+ "type": "object",
178
+ "required": ["status", "unresolved_required_ids", "unresolved_branch_ids"],
179
+ "properties": {
180
+ "status": { "enum": ["needs_more_discovery", "needs_decision", "blocked", "ready"] },
181
+ "unresolved_required_ids": { "type": "array", "items": { "type": "string" }, "uniqueItems": true },
182
+ "unresolved_branch_ids": { "type": "array", "items": { "type": "string" }, "uniqueItems": true }
183
+ }
184
+ },
185
+ "context_pack_digest": {
186
+ "type": "string",
187
+ "pattern": "^sha256:[0-9a-f]{64}$"
135
188
  }
136
189
  }
137
190
  }
@@ -0,0 +1,64 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://mirai-graph.dev/schemas/context-traversal-receipt.schema.json",
4
+ "title": "Mirai Graph Context Traversal Receipt",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": [
8
+ "contract",
9
+ "contract_version",
10
+ "repository_id",
11
+ "task",
12
+ "graph",
13
+ "visited_ids",
14
+ "expanded_ids",
15
+ "frontier_ids",
16
+ "candidates",
17
+ "nodes",
18
+ "relations",
19
+ "selection_history",
20
+ "blockers",
21
+ "warnings",
22
+ "traversal_digest"
23
+ ],
24
+ "properties": {
25
+ "contract": { "const": "context-traversal-receipt" },
26
+ "contract_version": { "const": "1.0.0" },
27
+ "repository_id": { "type": "string", "minLength": 1 },
28
+ "task": {
29
+ "type": "object",
30
+ "additionalProperties": false,
31
+ "required": ["text", "digest"],
32
+ "properties": {
33
+ "text": { "type": "string" },
34
+ "digest": { "type": "string", "pattern": "^sha256:[0-9a-f]{64}$" }
35
+ }
36
+ },
37
+ "graph": {
38
+ "type": "object",
39
+ "additionalProperties": false,
40
+ "required": ["revision", "digest"],
41
+ "properties": {
42
+ "revision": { "type": ["string", "null"] },
43
+ "digest": { "type": ["string", "null"], "pattern": "^sha256:[0-9a-f]{64}$" }
44
+ }
45
+ },
46
+ "visited_ids": { "$ref": "#/$defs/ids" },
47
+ "expanded_ids": { "$ref": "#/$defs/ids" },
48
+ "frontier_ids": { "$ref": "#/$defs/ids" },
49
+ "candidates": { "type": "array", "items": { "type": "object" } },
50
+ "nodes": { "type": "array", "items": { "type": "object" } },
51
+ "relations": { "type": "array", "items": { "type": "object" } },
52
+ "selection_history": { "type": "array", "items": { "type": "object" } },
53
+ "blockers": { "$ref": "#/$defs/ids" },
54
+ "warnings": { "$ref": "#/$defs/ids" },
55
+ "traversal_digest": { "type": "string", "pattern": "^sha256:[0-9a-f]{64}$" }
56
+ },
57
+ "$defs": {
58
+ "ids": {
59
+ "type": "array",
60
+ "items": { "type": "string", "minLength": 1 },
61
+ "uniqueItems": true
62
+ }
63
+ }
64
+ }
@@ -1,6 +1,6 @@
1
1
  # Mirai Graph Context-Pack Generation
2
2
 
3
- Status: 1.0 release-candidate standard section
3
+ Status: 1.1 stable standard section
4
4
 
5
5
  ## Purpose
6
6
 
@@ -56,6 +56,29 @@ task -> select relevant objects -> select relevant relations
56
56
  -> generate context pack -> review/use for task
57
57
  ```
58
58
 
59
+ Project Technology 1.1 implements this as a deterministic four-phase protocol:
60
+
61
+ ```text
62
+ discover -> expand -> compile -> verify
63
+ ```
64
+
65
+ The traversal receipt binds the task digest, graph digest and revision to the
66
+ visited nodes. The client records selected and rejected nodes, reasons,
67
+ confidence and selector type. Compilation then adds the mandatory dependency
68
+ closure and returns one of `needs_more_discovery`, `needs_decision`, `blocked`
69
+ or `ready`.
70
+
71
+ `ready` requires a result owner, terminal sources with exact revision and
72
+ SHA-256, all mandatory processes and validators, explicit reasons for omitted
73
+ branches, no required dependency cycle and no access or readiness conflict.
74
+ The context budget may remove optional material only; it must never remove the
75
+ mandatory closure.
76
+
77
+ The compiled pack adds selected and rejected paths, visited nodes, stop
78
+ reasons, mandatory closure, terminal sources, processes, constraints,
79
+ validators, completeness and `context_pack_digest`. These fields extend this
80
+ single context-pack contract; there is no parallel pack format.
81
+
59
82
  ## Selection Rules
60
83
 
61
84
  A context pack should include:
@@ -89,6 +112,20 @@ Relation explanations should include:
89
112
  Scores are implementation signals. They help review the generated context, but
90
113
  they do not prove semantic completeness.
91
114
 
115
+ ## Usage Evidence
116
+
117
+ Loading a source is not proof that it was used. For each significant rule,
118
+ usage evidence connects:
119
+
120
+ ```text
121
+ source -> applied rule -> decision -> changed or checked surface
122
+ -> validator -> outcome
123
+ ```
124
+
125
+ Verification fails when the evidence belongs to another context pack, skips a
126
+ mandatory source, process or validator, uses stale or tampered content, exposes
127
+ private material or treats generated context as write authorization.
128
+
92
129
  ## Validation
93
130
 
94
131
  Context-pack validation should check both shape and graph references:
@@ -1,6 +1,6 @@
1
1
  # Mirai Graph Object Model
2
2
 
3
- Status: 1.0 release-candidate standard section
3
+ Status: 1.1 stable standard section
4
4
 
5
5
  ## Purpose
6
6
 
@@ -106,7 +106,16 @@ Initial core kinds:
106
106
  - `evidence`;
107
107
  - `context_pack`;
108
108
  - `governance_gate`;
109
- - `profile`.
109
+ - `profile`;
110
+ - `owner`, `role`;
111
+ - `capability`, `process`;
112
+ - `resource`, `source`;
113
+ - `check`, `gate`, `constraint`;
114
+ - `access_requirement`.
115
+
116
+ The additional domain-neutral kinds support Project Technology traversal. A
117
+ consumer may display them using its own vocabulary without changing their
118
+ canonical meaning.
110
119
 
111
120
  ## Object Boundary Rules
112
121
 
@@ -1,6 +1,6 @@
1
1
  # Project Technology
2
2
 
3
- Status: 1.0 release-candidate extension contract
3
+ Status: 1.1 stable standard; activation contract remains 1.0.0
4
4
 
5
5
  Project Technology is the shared executable mechanism of Mirai Graph. It is
6
6
  not a profile, a second graph or a source of domain methodology.
@@ -19,6 +19,37 @@ Each graph keeps its own objects and relations. Project Technology only
19
19
  standardizes safe inventory, task context, accepted-target binding, freshness
20
20
  and verification.
21
21
 
22
+ ## Sequential Context Traversal
23
+
24
+ Project Technology exposes one model-independent navigation protocol:
25
+
26
+ ```text
27
+ discover -> expand -> compile -> verify
28
+ ```
29
+
30
+ - `discover` ranks a bounded set of top-level candidates for a task.
31
+ - `expand` reveals the accepted children of one or more selected nodes.
32
+ - `compile` validates the client's structured selection and adds the mandatory
33
+ closure over `requires`, `governed_by` and `validated_by`.
34
+ - `verify` checks that the resulting sources and rules were connected to a
35
+ decision, a surface, a validator and an outcome.
36
+
37
+ The caller may be a human, an AI model or a deterministic rule. Mirai Graph
38
+ does not select or invoke a model. Sequential and batched expansion of the same
39
+ nodes produces the same receipt digest.
40
+
41
+ The universal relation vocabulary for traversal is:
42
+
43
+ - structure: `contains`, `specializes`;
44
+ - mandatory closure: `requires`, `governed_by`, `validated_by`;
45
+ - sources: `documented_by`, `implemented_by`;
46
+ - interaction: `hands_off_to`, `conflicts_with`.
47
+
48
+ Consumer-specific names such as skills, companions or product commands are not
49
+ part of this protocol. Consumers map their own domain vocabulary to ordinary
50
+ owners, roles, capabilities, processes, resources, checks and access
51
+ requirements.
52
+
22
53
  ## Public Contract
23
54
 
24
55
  The only manifest extension key is `mirai.project_technology`:
@@ -73,3 +104,8 @@ source still answers "how should the domain work be done?".
73
104
  changed.
74
105
  - A blocked repository still supports narrow `explain`, `status`, `plan` and
75
106
  diagnostic `verify` calls.
107
+ - Context traversal is read-only in every phase and never grants write
108
+ authority.
109
+ - A context pack is not ready while a required branch, source, access boundary
110
+ or validator is missing, stale, blocked, deprecated, conflicting or
111
+ digest-mismatched.
@@ -1,6 +1,6 @@
1
1
  # Mirai Graph Relation Model
2
2
 
3
- Status: 1.0 release-candidate standard section
3
+ Status: 1.1 stable standard section
4
4
 
5
5
  ## Purpose
6
6
 
@@ -92,6 +92,16 @@ Initial core relation types:
92
92
  - `belongs_to`;
93
93
  - `related_to`.
94
94
 
95
+ Project Technology context traversal also standardizes:
96
+
97
+ - structure: `contains`, `specializes`;
98
+ - mandatory closure: `requires`, `governed_by`, `validated_by`;
99
+ - sources: `documented_by`, `implemented_by`;
100
+ - interaction: `hands_off_to`, `conflicts_with`.
101
+
102
+ These names are domain-neutral. A consumer may present them with its own user
103
+ vocabulary, but canonical traversal uses the shared relation types.
104
+
95
105
  ## Relation Boundary Rules
96
106
 
97
107
  A relation should be created when the connection changes how the system is
@@ -1,6 +1,6 @@
1
1
  # Mirai Graph Test Suite
2
2
 
3
- Status: 1.0 release-candidate standard section
3
+ Status: 1.1 stable standard section
4
4
 
5
5
  ## Purpose
6
6
 
@@ -32,6 +32,10 @@ Current checks:
32
32
  - score benchmark readiness;
33
33
  - run synthetic context-reduction calculation;
34
34
  - reject negative fixtures.
35
+ - verify deterministic Project Technology context traversal across project,
36
+ research, organization, platform, skill-like and multi-repository scopes;
37
+ - reject incomplete mandatory closure, stale nodes, conflicts, cycles,
38
+ tampered digests, secret-like evidence and context-budget shortcuts.
35
39
 
36
40
  ## Structural Validation
37
41