Study files

study/assemble.py

4.1 KB · View on GitHub →

import re, sys, pathlib
d = pathlib.Path(sys.argv[1]); out = pathlib.Path(sys.argv[2])
def sections(path):
    """split into (title, body) by any heading line"""
    secs=[]; cur=None; buf=[]
    for line in path.read_text().splitlines():
        m=re.match(r'^(#{1,4})\s+(.*)$', line)
        if m:
            if cur is not None or buf: secs.append((cur, buf))
            cur=m.group(2).strip(); buf=[]
        else: buf.append(line)
    secs.append((cur, buf)); return secs
def body(lines): return "\n".join(lines).strip()+"\n"
groups=[("1-programmable.md","1. Programmable capabilities"),("2-evidence-memory.md","2. Evidence and memory"),
        ("3-specialists.md","3. Specialist collaboration"),("4-execution-controls.md","4. Execution controls"),
        ("5-integration.md","5. Product integration"),("6-operations.md","6. Operations and verification")]
TAIL=("Evidence ledger","Verification log","Unresolved")
ledgers=[]; verlogs=[]; unres=[]
o=[(d/"../head.md").resolve().read_text().rstrip()+"\n"]
meta=sections(d/"0-metadata-companion-limits.md"); M={t:b for t,b in meta}
o.append("\n## Metadata\n\n"+body(M["(a) Metadata"]))
o.append("\n### Pinned external dependencies (capability-supplying)\n\n"+body(M["Pinned external dependencies (capability-supplying)"]))
o.append("\n## Runtime assessment (embedded-assistant use case)\n")
for fn,title in groups:
    secs=sections(d/fn); o.append(f"\n### {title}\n")
    for t,b in secs:
        if t is None: continue
        if t.startswith("Evidence ledger"): ledgers.append((title,body(b))); continue
        if t.startswith("Verification log"): verlogs.append((title,body(b))); continue
        if t.startswith("Unresolved"): unres.append((title,body(b))); continue
        if re.match(r'^\d\.', t):   # group heading itself
            o.append("\n"+body(b)); continue
        o.append(f"\n#### {title.split('. ',1)[1]}: {t}\n\n"+body(b))
g=(d/"../graded_intro.md").resolve(); gm=(d/"../grades/final.md").resolve()
if g.exists() and gm.exists(): o.append(g.read_text()+gm.read_text())
o.append("\n## Companion application comparison (ready-made application use case)\n\n")
o.append("This table is separate from the embedded-runtime assessment above. It describes the application surfaces around each runtime; items outside the audited component are marked as such and their features are not credited to the runtime.\n")
o.append("\n### Part A: platforms, clients, IDE, messaging\n\n"+body(M["Part A: platforms, clients, IDE, messaging"]))
o.append("\n### Part B: voice/media, onboarding/routing, fleet administration\n\n"+body(M["Part B: voice/media, onboarding/routing, fleet administration"]))
o.append("\n## Unresolved claims, conflicts and coverage limits\n\nVerified behavior is what the tables mark [S]. Design intent ([D]) and unperformed measurements are kept separate below.\n")
for key in ["Unresolved claims (not verified by the audits)","Source/doc conflicts","Material coverage limits (per runtime)","Proposed validation experiments (none performed)","Schema gaps (dimensions the 18 columns miss)"]:
    o.append(f"\n### {key}\n\n"+body(M[key]))
o.append("\n### Column-specific unresolved items\n")
for title,b in unres: o.append(f"\n#### {title}\n\n"+b)
if "Unresolved / conflicts (specific to these sections)" in M:
    o.append("\n#### Metadata and companion\n\n"+body(M["Unresolved / conflicts (specific to these sections)"]))
o.append("\n### Notes (metadata and companion)\n\n"+body(M["Notes"]))
o.append("\n## Evidence ledger\n\nAll links are pinned to the revisions in the reproducibility table. Prefixes: M metadata, A companion, P programmable, E evidence/memory, C specialists, X execution controls, I integration, O operations.\n")
o.append("\n### Metadata and companion (M, A)\n\n"+body(M["Evidence ledger"]))
for title,b in ledgers: o.append(f"\n### {title}\n\n"+b)
o.append("\n## Verification logs\n")
o.append((d/"../coordinator_checks.md").resolve().read_text())
o.append("\n### Metadata and companion\n\n"+body(M["Verification log"]))
for title,b in verlogs: o.append(f"\n### {title}\n\n"+b)
o.append((d/"../tail.md").resolve().read_text())
out.write_text("".join(o))