MCPcopy Create free account
hub / github.com/Graphify-Labs/graphify / monolith_roundtrip

Function monolith_roundtrip

tools/skillgen/gen.py:903–942  ·  view source on GitHub ↗

Assert a monolith renders diff-clean vs its v8 blob modulo allowed changes. The monolith bodies are hand-maintained single files frozen against a pinned pristine v8 blob (``roundtrip_ref``); this is the guard that stops an arbitrary edit (even a blessed one) from drifting them. Sanction

(platform: Platform)

Source from the content-addressed store, hash-verified

901
902
903def monolith_roundtrip(platform: Platform) -> list[str]:
904 """Assert a monolith renders diff-clean vs its v8 blob modulo allowed changes.
905
906 The monolith bodies are hand-maintained single files frozen against a pinned
907 pristine v8 blob (``roundtrip_ref``); this is the guard that stops an
908 arbitrary edit (even a blessed one) from drifting them. Sanctioned changes are
909 enumerated as predicates in ``_SANCTIONED_MONOLITH_DIFFS``: the file_type enum
910 unification, the unified frontmatter description, the chunk-cleanup rewrite
911 (#1172), and the four #1392 runbook fixes (directed propagation, content-only
912 semantic scope, stale-cache unlink, and the zero-node/shrink-guard ordering).
913
914 The comparison is a multiset diff, not a positional zip: a line whose text is
915 unchanged but merely *moved* (the report-write line shifted below ``to_json``
916 in the ordering fix) cancels out and is not flagged. Only lines whose content
917 is genuinely added or removed are checked, and each must be sanctioned.
918 """
919 if platform.bucket != "monolith":
920 return []
921 if platform.roundtrip_ref is None:
922 return [f"[{platform.key}] monolith is missing roundtrip_ref"]
923
924 rendered_lines = render(platform)[0].content.splitlines()
925 # Strip trigger lines from the original — they are non-spec and their removal
926 # (#1180) is a permitted diff.
927 original_lines = [
928 l for l in _normalise(_git_show(platform.roundtrip_ref)).splitlines()
929 if not _is_trigger_line(l)
930 ]
931
932 added = Counter(rendered_lines) - Counter(original_lines)
933 removed = Counter(original_lines) - Counter(rendered_lines)
934
935 problems: list[str] = []
936 for line in list(added.elements()) + list(removed.elements()):
937 if _is_sanctioned_monolith_diff(line):
938 continue
939 problems.append(
940 f"[{platform.key}] unsanctioned monolith change vs pristine v8: {line!r}"
941 )
942 return problems
943
944
945def _always_on_constants(ref: str) -> dict[str, str]:

Callers 1

mainFunction · 0.85

Calls 5

renderFunction · 0.85
_normaliseFunction · 0.85
_git_showFunction · 0.85
_is_trigger_lineFunction · 0.85

Tested by

no test coverage detected