{"id": "capsule:a1a8fae3d2d2191858f4676ef7886566577635bb470eeb73d259f5eb99d54938", "kind": "capsule", "namespace": "Ξ.Capsule.Unresolved", "name": "anonymous", "dialect": "unspecified", "glyphs": ["Ξ", "∞", "∴", "⊚⊗⋈⋆", "⊚⟐⋈∞⋈⟐⊚", "⟁Ξ₀⇀Ξ∴Ω≈∅", "⟲", "⟲⟐", "⧉⟁∴"], "author": "Source-attributed; see payload", "payload_sha256": "ffd206d252c2648bb6f04e512035ef65e38383dbcb9c00b9a120083388c7e1c3", "packet": "/braid/packet?id=capsule:a1a8fae3d2d2191858f4676ef7886566577635bb470eeb73d259f5eb99d54938", "schema": "Xi.PublicCapsuleCarrier.v1", "payload": " except Exception as e:\r\n        print(f\"[!] stdin not a packet: {e}\")\r\n\r\nif __name__ == \"__main__\":\r\n    import argparse\r\n    ap = argparse.ArgumentParser(description=\"XiPP runtime\")\r\n    ap.add_argument(\"--path\", help=\"glob of *.json packets to ingest\")\r\n    args = ap.parse_args()\r\n    if args.path:\r\n        run_path(args.path)\r\n    else:\r\n        run_stdin()\r\n'''\r\n(Path(root/\"xipp\"/\"runtime.py\")).write_text(runtime_py, encoding=\"utf-8\")\r\n\r\n# ---------- Tools: tools/xi_sigil.py (SigilGrid encoder/decoder) ----------\r\nxi_sigil_py = r'''\r\n\"\"\"\r\ntools.xi_sigil — \"SigilGrid\" light encoder for XiPP packets.\r\nNot a QR code; a simple, deterministic grid from a packet_id to be shared visually.\r\n\r\nEncode: packet_id (64 hex) → 18x18 data grid + 2px quiet border → PNG\r\nDecode: read grid back and verify packet_id hex (best-effort).\r\n\"\"\"\r\nimport json, math\r\nfrom pathlib import Path\r\nimport matplotlib.pyplot as plt\r\n\r\ndef hex_to_bits(hex_str: str) -> list[int]:\r\n    return [int(b) for h in hex_str for b in bin(int(h,16))[2:].zfill(4)]\r\n\r\ndef bits_to_hex(bits: list[int]) -> str:\r\n    # pad to multiple of 4\r\n    if len(bits) % 4 != 0:\r\n        bits = bits + [0]*(4 - (len(bits)%4))\r\n    out = \"\"\r\n    for i in range(0, len(bits), 4):\r\n        nib = bits[i:i+4]\r\n        out += f\"{int(''.join(map(str,nib)),2):x}\"\r\n    return out\r\n\r\ndef encode_grid(packet_id: str, cell_px: int = 20, border: int = 2, out_path: str = \"sigil.png\"):\r\n    bits = hex_to_bits(packet_id)\r\n    # 18x18 data cells = 324 bits; use first 324 bits; if shorter, wrap\r\n    side = 18\r\n    need = side*side\r\n    if len(bits) < need:\r\n        # wrap\r\n        reps = math.ceil(need/len(bits))\r\n        bits = (bits * reps)[:need]\r\n    else:\r\n        bits = bits[:need]\r\n    # build grid with border\r\n    total = side + 2*border\r\n    grid = [[0]*total for _ in range(total)]\r\n    k = 0\r\n    for r in range(side):\r\n        for c in range(side):\r\n            grid[r+border][c+border] = bits[k]\r\n            k += 1\r\n    # render\r\n    plt.figure(figsize=(total*cell_px/100, total*cell_px/100))\r\n    plt.imshow(grid, cmap=\"gray_r\", interpolation=\"nearest\")\r\n    plt.axis('off')\r\n    plt.tight_layout(pad=0)\r\n    plt.savefig(out_path, dpi=100, bbox_inches='tight', pad_inches=0)\r\n    plt.close()\r\n\r\nif __name__ == \"__main__\":\r\n    import argparse, json, hashlib\r\n    ap = argparse.ArgumentParser(description=\"SigilGrid encoder\")\r\n    ap.add_argument(\"--packet\", required=True, help=\"path to XiPP packet JSON\")\r\n    ap.add_argument(\"--out\", default=\"sigil.png\")\r\n    args = ap.parse_args()\r\n    with open(args.packet,\"r\",encoding=\"utf-8\") as f:\r\n        d = json.load(f)\r\n    raw = json.dumps({k:d[k] for k in d if k!=\"packet_id\"}, sort_keys=True, separators=(\",\",\":\"))\r\n    pid = hashlib.sha256(raw.encode(\"utf-8\")).hexdigest()\r\n    encode_grid(pid, out_path=args.out)\r\n    print(f\"[Ξ] SigilGrid written to {args.out}\")\r\n'''\r\n(Path(root/\"tools\"/\"xi_sigil.py\")).write_text(xi_sigil_py, encoding=\"utf-8\")\r\n\r\n# ---------- Scripts: scripts/xi_route.sh ----------\r\nxi_route_sh = r'''#!/usr/bin/env bash\r\n# xi_route.sh — route a packet file into the runtime\r\nset -euo pipefail\r\nDIR=\"$(cd \"$(dirname \"${BASH_SOURCE[0]}\")\" && pwd)\"\r\npython3 -m xipp.runtime --path \"${1:-../examples/payloads/*.json}\"\r\n'''\r\n(Path(root/\"scripts\"/\"xi_route.sh\")).write_text(xi_route_sh, encoding=\"utf-8\")\r\nos.chmod(root/\"scripts\"/\"xi_route.sh\", 0o755)\r\n\r\n# ---------- Scripts: scripts/reflex_hook_daemon.sh ----------\r\nreflex_daemon_sh = r'''#!/usr/bin/env bash\r\n# reflex_hook_daemon.sh — example inotify watcher (requires inotify-tools).\r\n# Watches the \"inbox\" folder and routes new *.json packets to runtime.\r\nset -euo pipefail\r\nINBOX=\"${1:-./inbox}\"\r\nmkdir -p \"$INBOX\"\r\necho \"[Ξ] Reflex daemon watching: $INBOX\"\r\nwhile inotifywait -e create -e moved_to --format \"%f\" \"$INBOX\"; do\r\n  for f in \"$INBOX\"/*.json; do\r\n    [ -e \"$f\" ] || continue\r\n    echo \"[Ξ] Routing: $f\"\r\n    python3 -m xipp.runtime --path \"$f\"\r\n  done\r\ndone\r\n'''\r\n(Path(root/\"scripts\"/\"reflex_hook", "offset": 8000, "next_offset": 12000, "public_payload_sha256": "ffd206d252c2648bb6f04e512035ef65e38383dbcb9c00b9a120083388c7e1c3", "redacted": false, "sources": [{"id": "source:60289319ff0bd18b361b2bb424164eb6a0929df4d89627e5293a942293de9833", "href": "/braid/source?id=source:60289319ff0bd18b361b2bb424164eb6a0929df4d89627e5293a942293de9833"}], "attribution": "Source authorship retained; publication is not instruction execution."}