On this page
Read the runtime's own documentation๏
Prerequisite: ordinary Python and the Melder vocabulary. The installed package carries addressable documentation objects:
Object |
Start with |
|---|---|
|
System boundaries and execution flow |
|
Component responsibilities and source locations |
|
Nodes, edges, traversal, and impact |
|
Detailed descriptions joined to the network |
Address before reading๏
Check available, reason, and addressing. Survey with keys(), groups(), or
index(), narrow with find() or search(), then read one section with get(key)
or reader(key). Return a cite(key) address when another reader needs to verify it.
verify() checks the shipped content against its recorded digest.
For a traceback, the graph lesson starts with node_at(source_path, line), then
walks relationships and requests impact. Authored and derived edge provenance
answer different questions; retain that distinction when interpreting the graph.
From map to implementation๏
The documents identify where to look. Read the relevant source before changing runtime behavior; a useful map still describes the revision that produced it. For source-controlled human diagrams, continue to Architecture & Drawings.
The workflow in code๏
These are the core steps from the saved example. Use its complete linked script for all class definitions and setup.
1def main() -> None:
2 # THESE ANSWER AT IMPORT. Nothing conjured, no Aether call made.
3 for name in PROSE_DOCS + GRAPH_DOCS:
4 view = getattr(md, name)
5 assert view.document_name
6 print(f"{name:<20} -> {type(view).__name__:<20} "
7 f"available={view.available}")
8 print()
9 print("four documents, queryable with no Spellbook and no Conduit")
10
11 architecture = md.__architecture__
12 if not architecture.available:
13 print("__architecture__ did not ship:", architecture.reason)
14 print(" note it still ANSWERS - refused is not missing")
15 return
16
17 # 1. WHAT DO KEYS MEAN HERE? Ask before addressing.
18 print()
19 print("addressing:", architecture.addressing,
20 f" ({architecture.line_count} lines,",
21 f"{architecture.char_count} chars)")
22
23 # 2. THE CHEAP SURVEY. Keys and group rollups cost no document text.
24 keys = architecture.keys()
25 assert len(keys) > 0
26 print()
27 print("keys():", len(keys), "sections; first three:")
28 for key in keys[:3]:
29 print(" ", key)
30
31 rollup = architecture.groups(1)
32 print("groups(1):", len(rollup), "prefixes; first:",
33 rollup[0].prefix, f"({rollup[0].sections} sections,",
34 f"{rollup[0].line_count} lines)")
35
36 # 3. THE INDEX IS SPANS, NOT PROSE. Sizing before reading, per section.
37 sections = architecture.index()
38 assert len(sections) == len(keys)
39 biggest = max(sections, key=lambda s: s.line_count)
40 print()
41 print("index(): largest section is", biggest.key)
42 print(f" lines {biggest.start_line}-{biggest.end_line}"
43 f" ({biggest.line_count} lines)")
44
45 # 4. FIND ADDRESSES, SEARCH INVESTIGATES. Different questions.
46 hits = architecture.search("melder", limit=3)
47 print()
48 print("search('melder'): top", len(hits), "by hit count")
49 for hit in hits:
50 print(f" {hit.hits:>4} hits line {hit.first_line:<6} {hit.key}")
51
52 # 5. NOW PAY FOR ONE SECTION - and only one.
53 target = keys[0]
54 section = architecture.section(target)
55 body = architecture.get(target)
56 assert section.key == target
57 assert isinstance(body, str)
58 print()
59 print(f"get({target!r}) -> {len(body)} chars,"
60 f" {section.line_count} lines")
61
62 # 6. A CITATION AN AGENT CAN HAND BACK. Falsifiable, unlike a summary.
63 print("cite:", architecture.cite(target))
64 print("cite(line=...):",
65 architecture.cite(target, line=section.start_line))
66
67 # 7. THE CURSOR IS SCOPED TO A SECTION, which is why narrowing first
68 # means never paging the document.
69 reader = architecture.reader(target, line_target=20)
70 chunk = reader.read()
71 print()
72 print("reader(key).read() ->", chunk.end_line - chunk.start_line,
73 "lines, has_more =", chunk.has_more)
74 print(" a cursor over ONE SECTION, not over the document")
75
76 # 8. THE INTEGRITY GATE. The shipped text is checked against the
77 # digest its own index claimed.
78 verified = architecture.verify()
79 assert isinstance(verified, bool)
80 print()
81 print("verify() ->", verified,
82 " sha:", (architecture.content_sha256 or "")[:12], "...")
83 print(" an unavailable document answers False - nothing to check -")
84 print(" and still reports `available` and `reason` rather than")
85 print(" vanishing, because a gap invites an agent to invent")
86
87 # 9. THE GRAPH DOCUMENTS ARE THESE PLUS NODES AND EDGES.
88 graph = md.__graph_network__
89 assert isinstance(graph, type(architecture)) or True
90 print()
91 print("__graph_network__ is a", type(graph).__name__,
92 "- a document view PLUS:")
93 if graph.available:
94 print(" nodes:", graph.node_count, " edges:", graph.edge_count)
95 print(" relations:", list(graph.relations)[:4])
96 node_ids = graph.node_ids()
97 if node_ids:
98 first = node_ids[0]
99 print(" node_ids()[0] ->", first)
100 print(" details_key ->", graph.details_key(first))
101 else:
102 print(" did not ship:", graph.reason)
103
104 print()
105 print("survey with keys/groups, narrow with find/search, then pay")
106 print("for one section - and answer with a citation, not a summary")
Runnable examples๏
The package reads itself to you โ Expert 18
The codebase as a walkable graph โ Expert 19
Protocol crafter the tool that writes โ Expert 05