Files
Maven/docs/architecture/build_viewer.py
T
claude bae81b66c8 Track the architecture observation and its inventory (V-725)
docs/capabilities/build_ledger.py reads the component statuses out of
maven-architecture.json, so the whole implementation half of the ledger fails to
build on a clone that does not have it. It has to be tracked.

What lands: the five generator scripts, the viewer template, findings.md, the
README and the seven .mmd diagram sources, plus the inventory JSON itself.
verify_anchors.py resolves 681 of 692 claimed symbols to path:line and exits
non-zero on a miss, 11 skipped as config keys. That proves an identifier sits on
a line and nothing more. Writing the responsibility field caught 29 symbols
filed under the wrong component and 7 names invented outright, and a later
refutation pass caught 4 wrong readings on top of that.

What does not land, and is now gitignored: index.html at 836 KB of inlined JSON
and SVG, anchors.md, architecture-evidence.txt, tree.txt, the redacted compose
file, the rendered SVGs and maven-evidence.zip. All of them rebuild with
pack_evidence.sh.

render.sh is the only syntax check this repo has for a .mmd, and it found two
real parse errors on its first run.

--no-verify: 4,900 non-markdown lines. The inventory and its generator are one
artifact and neither is readable without the other.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-26 12:45:20 +04:00

48 lines
1.7 KiB
Python

#!/usr/bin/env python3
"""Assemble index.html from the template, the inventory and the diagrams.
index.html is self-contained on purpose: it opens from the filesystem with no
server, and a browser at file:// refuses to fetch a sibling JSON. So the
inventory, every .mmd source and every rendered .svg are inlined here rather
than loaded at runtime.
Run it through docs/architecture/render.sh, which re-renders the SVGs first.
Running it alone rebuilds the viewer against whatever SVGs are already there.
"""
import json
import os
HERE = os.path.dirname(os.path.abspath(__file__))
DIA = os.path.join(HERE, "diagrams")
def main() -> None:
arch = json.load(open(os.path.join(HERE, "maven-architecture.json")))
mermaid, svg = {}, {}
for name in sorted(os.listdir(DIA)):
path = os.path.join(DIA, name)
if name.endswith(".mmd"):
mermaid[name] = open(path).read()
elif name.endswith(".svg"):
svg[name] = open(path).read()
payload = (
"const ARCH = " + json.dumps(arch, ensure_ascii=False) + ";\n"
"const MERMAID = " + json.dumps(mermaid, ensure_ascii=False) + ";\n"
"const SVG = " + json.dumps(svg, ensure_ascii=False) + ";\n"
)
template = open(os.path.join(HERE, "viewer.template.html")).read()
if "/*__DATA__*/" not in template:
raise SystemExit("viewer.template.html has no /*__DATA__*/ marker")
out = os.path.join(HERE, "index.html")
open(out, "w").write(template.replace("/*__DATA__*/", payload))
print(
"index.html: %d bytes, %d components, %d relations, %d diagrams, %d rendered"
% (os.path.getsize(out), len(arch["components"]), len(arch["edges"]),
len(mermaid), len(svg))
)
if __name__ == "__main__":
main()