Loading Lion artifact…
Inspect Lion Program Source (JSON)
[
  "begin",
  [
    "relation",
    "entity",
    [
      "id",
      "label",
      "kind",
      "owner",
      "status"
    ],
    {
      "certified": true,
      "description": "Operational knowledge graph nodes governed as code",
      "key": [
        "id"
      ]
    }
  ],
  [
    "relation",
    "link",
    [
      "from",
      "to",
      "rel"
    ],
    {
      "certified": true,
      "description": "Directed typed edges between operational graph entities",
      "references": {
        "from": [
          "entity",
          "id"
        ],
        "to": [
          "entity",
          "id"
        ]
      }
    }
  ],
  [
    "relation",
    "ui_state",
    [
      "k",
      "v"
    ],
    {
      "key": [
        "k"
      ]
    }
  ],
  [
    "fact",
    [
      "entity",
      "planner",
      "Planner Agent",
      "agent",
      "ops-team",
      "ok"
    ],
    [
      "entity",
      "verifier",
      "Verifier Agent",
      "agent",
      "safety-team",
      "ok"
    ],
    [
      "entity",
      "ledger",
      "Escrow Ledger",
      "service",
      "core-eng",
      "accent"
    ],
    [
      "entity",
      "policy",
      "Cedar & SMT Gate",
      "policy",
      "security",
      "ok"
    ],
    [
      "entity",
      "snapshot",
      "Prolly Branch #42",
      "branch",
      "core-eng",
      "accent"
    ],
    [
      "link",
      "planner",
      "snapshot",
      "proposes"
    ],
    [
      "link",
      "snapshot",
      "verifier",
      "reviewed_by"
    ],
    [
      "link",
      "verifier",
      "policy",
      "proves_with"
    ],
    [
      "link",
      "policy",
      "ledger",
      "guards"
    ],
    [
      "ui_state",
      "selected",
      "snapshot"
    ],
    [
      "ui_state",
      "tab",
      "graph"
    ],
    [
      "ui_state",
      "simulate_branch",
      false
    ]
  ],
  [
    "relation",
    "reaches",
    [
      "src",
      "dst"
    ]
  ],
  [
    "rule",
    [
      "reaches",
      "?a",
      "?b"
    ],
    [
      "link",
      "?a",
      "?b",
      "?_"
    ]
  ],
  [
    "rule",
    [
      "reaches",
      "?a",
      "?c"
    ],
    [
      "link",
      "?a",
      "?b",
      "?_"
    ],
    [
      "reaches",
      "?b",
      "?c"
    ]
  ],
  [
    "define",
    "smt_guard",
    [
      "proof/smt",
      [
        "quote",
        [
          "and",
          [
            "forall",
            [
              "x"
            ],
            [
              "implies",
              [
                ">=",
                "x",
                0
              ],
              [
                ">=",
                [
                  "bal",
                  "x"
                ],
                0
              ]
            ]
          ],
          [
            ">=",
            "acct",
            0
          ],
          [
            "=",
            "b",
            [
              "store",
              "a",
              "acct",
              [
                "bal",
                "acct"
              ]
            ]
          ],
          [
            "<=",
            "acct",
            "target"
          ],
          [
            "<=",
            "target",
            "acct"
          ],
          [
            "<",
            [
              "select",
              "b",
              "target"
            ],
            0
          ]
        ]
      ]
    ],
    {
      "persist": true
    }
  ],
  [
    "define",
    "pdr_inv",
    [
      "proof/invariant",
      {
        "init": [
          "lambda",
          [
            "s"
          ],
          [
            "and",
            [
              "=",
              [
                "object/get",
                "s",
                "x"
              ],
              0
            ],
            [
              "=",
              [
                "object/get",
                "s",
                "y"
              ],
              0
            ]
          ]
        ],
        "invariant": [
          "lambda",
          [
            "s"
          ],
          [
            "number/greaterThanOrEqualTo",
            [
              "object/get",
              "s",
              "y"
            ],
            0
          ]
        ],
        "next": [
          "lambda",
          [
            "s",
            "s2"
          ],
          [
            "and",
            [
              "=",
              [
                "object/get",
                "s2",
                "x"
              ],
              [
                "number/add",
                [
                  "object/get",
                  "s",
                  "x"
                ],
                1
              ]
            ],
            [
              "=",
              [
                "object/get",
                "s2",
                "y"
              ],
              [
                "number/add",
                [
                  "object/get",
                  "s",
                  "y"
                ],
                [
                  "object/get",
                  "s",
                  "x"
                ]
              ]
            ]
          ]
        ],
        "strengthen": true,
        "vars": {
          "x": "value/integer?",
          "y": "value/integer?"
        }
      }
    ],
    {
      "persist": true
    }
  ],
  [
    "define",
    "view",
    [
      "lambda",
      [],
      [
        "begin",
        [
          "define",
          "sel",
          [
            "array/head",
            [
              "find",
              "?v",
              [
                "ui_state",
                "selected",
                "?v"
              ]
            ]
          ]
        ],
        [
          "define",
          "active_tab",
          [
            "array/head",
            [
              "find",
              "?v",
              [
                "ui_state",
                "tab",
                "?v"
              ]
            ]
          ]
        ],
        [
          "define",
          "sim",
          [
            "array/head",
            [
              "find",
              "?v",
              [
                "ui_state",
                "simulate_branch",
                "?v"
              ]
            ]
          ]
        ],
        [
          "define",
          "nodes",
          [
            "find",
            {
              "group": "?kind",
              "id": "?id",
              "label": "?label",
              "subtitle": "?kind",
              "tone": "?status"
            },
            [
              "entity",
              "?id",
              "?label",
              "?kind",
              "?_owner",
              "?status"
            ]
          ]
        ],
        [
          "define",
          "edges",
          [
            "cond",
            [
              "sim",
              [
                "assuming",
                [
                  "fact",
                  [
                    "link",
                    "planner",
                    "ledger",
                    "direct_write (UNREVIEWED)"
                  ]
                ],
                [
                  "find",
                  {
                    "from": "?a",
                    "label": "?r",
                    "to": "?b",
                    "tone": [
                      "cond",
                      [
                        [
                          "=",
                          "?r",
                          "direct_write (UNREVIEWED)"
                        ],
                        "warn"
                      ],
                      [
                        "else",
                        "ok"
                      ]
                    ]
                  },
                  [
                    "link",
                    "?a",
                    "?b",
                    "?r"
                  ]
                ]
              ]
            ],
            [
              "else",
              [
                "find",
                {
                  "from": "?a",
                  "label": "?r",
                  "to": "?b",
                  "tone": "ok"
                },
                [
                  "link",
                  "?a",
                  "?b",
                  "?r"
                ]
              ]
            ]
          ]
        ],
        [
          "define",
          "sel_row",
          [
            "array/head",
            [
              "find",
              {
                "id": "sel",
                "kind": "?k",
                "label": "?l",
                "owner": "?o",
                "status": "?s"
              },
              [
                "entity",
                "sel",
                "?l",
                "?k",
                "?o",
                "?s"
              ]
            ]
          ]
        ],
        [
          "define",
          "downstream",
          [
            "find",
            "?d",
            [
              "reaches",
              "sel",
              "?d"
            ]
          ]
        ],
        [
          "define",
          "why_ledger",
          [
            "why",
            [
              "reaches",
              "planner",
              "ledger"
            ]
          ]
        ],
        [
          "ui/stack",
          {
            "gap": "lg"
          },
          [
            "ui/hero",
            {
              "badges": [
                "quote",
                [
                  {
                    "label": "Schema as Code",
                    "tone": "accent"
                  },
                  {
                    "label": "Branches & assuming",
                    "tone": "ok"
                  },
                  {
                    "label": "SMT + PDR Verified",
                    "tone": "ok"
                  },
                  {
                    "label": "100% Lion UI",
                    "tone": "accent"
                  }
                ]
              ],
              "eyebrow": "Lion Graph-as-Code Public Artifact",
              "subtitle": "Inspired by Omnigraph & Graph-as-Code: operational agent memory, schema governance, counterfactual branch simulation, formal proofs, and interactive UI declared in one JSON program.",
              "title": "Agent Operational Knowledge Graph"
            }
          ],
          [
            "ui/grid",
            {
              "cols": 4,
              "gap": "md"
            },
            [
              "ui/metric",
              {
                "caption": "Governed agents, branches & policies",
                "label": "Graph Entities",
                "value": [
                  "array/length",
                  "nodes"
                ]
              }
            ],
            [
              "ui/metric",
              {
                "caption": [
                  "cond",
                  [
                    "sim",
                    "Includes 1 unreviewed bypass edge"
                  ],
                  [
                    "else",
                    "All edges pass policy review"
                  ]
                ],
                "label": "Active Edges",
                "tone": [
                  "cond",
                  [
                    "sim",
                    "warn"
                  ],
                  [
                    "else",
                    "ok"
                  ]
                ],
                "value": [
                  "array/length",
                  "edges"
                ]
              }
            ],
            [
              "ui/metric",
              {
                "caption": "forall E-matching + arrays + Nelson-Oppen",
                "label": "SMT Guard",
                "tone": "ok",
                "value": [
                  "cond",
                  [
                    [
                      "proof/valid?",
                      [
                        "object/get",
                        "smt_guard",
                        "proof"
                      ]
                    ],
                    "Verified"
                  ],
                  [
                    "else",
                    "Failed"
                  ]
                ]
              }
            ],
            [
              "ui/metric",
              {
                "caption": "Auto-synthesized via PDR strengthening",
                "label": "PDR Auto-Lemma",
                "tone": "ok",
                "value": [
                  "array/head",
                  [
                    "object/get",
                    "pdr_inv",
                    "strengthened"
                  ]
                ]
              }
            ]
          ],
          [
            "ui/tabs",
            {
              "active": "active_tab",
              "onChange": [
                "quote",
                [
                  "fact",
                  [
                    "ui_state",
                    "tab",
                    "value"
                  ]
                ]
              ],
              "tabs": [
                "array/make",
                {
                  "badge": [
                    "array/length",
                    "nodes"
                  ],
                  "id": "graph",
                  "label": "Knowledge Graph"
                },
                {
                  "badge": 2,
                  "id": "proofs",
                  "label": "Formal Proofs & Policies"
                },
                {
                  "id": "provenance",
                  "label": "Why Provenance"
                }
              ]
            },
            [
              "cond",
              [
                [
                  "=",
                  "active_tab",
                  "graph"
                ],
                [
                  "ui/stack",
                  {
                    "gap": "md"
                  },
                  [
                    "ui/card",
                    [
                      "ui/row",
                      {
                        "align": "center",
                        "gap": "md"
                      },
                      [
                        "ui/toggle",
                        {
                          "checked": "sim",
                          "label": "Simulate counterfactual branch: Planner bypasses Verifier (assuming)",
                          "onChange": [
                            "quote",
                            [
                              "fact",
                              [
                                "ui_state",
                                "simulate_branch",
                                "value"
                              ]
                            ]
                          ]
                        }
                      ]
                    ]
                  ],
                  [
                    "cond",
                    [
                      "sim",
                      [
                        "ui/alert",
                        {
                          "title": "Branch Policy Alert (Counterfactual assuming)",
                          "tone": "warn"
                        },
                        "Simulated branch introduces an unreviewed edge planner -> ledger. In production, Lion invariants block direct writes that bypass verifier + policy."
                      ]
                    ]
                  ],
                  [
                    "ui/graph",
                    {
                      "edges": "edges",
                      "height": 220,
                      "layout": "layered",
                      "nodes": "nodes",
                      "onSelect": [
                        "quote",
                        [
                          "fact",
                          [
                            "ui_state",
                            "selected",
                            "value"
                          ]
                        ]
                      ],
                      "selected": "sel",
                      "title": "Click any entity node to inspect"
                    }
                  ],
                  [
                    "ui/card",
                    {
                      "title": "Selected Entity Inspector"
                    },
                    [
                      "ui/kv",
                      {
                        "columns": 5,
                        "items": [
                          "array/make",
                          {
                            "label": "Entity ID",
                            "mono": true,
                            "value": "sel"
                          },
                          {
                            "label": "Label",
                            "value": [
                              "object/get",
                              "sel_row",
                              "label"
                            ]
                          },
                          {
                            "label": "Type",
                            "value": [
                              "object/get",
                              "sel_row",
                              "kind"
                            ]
                          },
                          {
                            "label": "Owner",
                            "value": [
                              "object/get",
                              "sel_row",
                              "owner"
                            ]
                          },
                          {
                            "label": "Reachable Downstream",
                            "value": [
                              "array/length",
                              "downstream"
                            ]
                          }
                        ]
                      }
                    ]
                  ],
                  [
                    "cond",
                    [
                      "sim",
                      [
                        "ui/diff",
                        {
                          "added": [
                            "quote",
                            [
                              "[\"link\", \"planner\", \"ledger\", \"direct_write (UNREVIEWED)\"]"
                            ]
                          ],
                          "removed": [
                            "quote",
                            []
                          ],
                          "title": "Counterfactual Branch Diff (main vs proposed)"
                        }
                      ]
                    ]
                  ]
                ]
              ],
              [
                [
                  "=",
                  "active_tab",
                  "proofs"
                ],
                [
                  "ui/grid",
                  {
                    "cols": 2,
                    "gap": "md"
                  },
                  [
                    "ui/proof",
                    {
                      "summary": "Combines forall E-matching, McCarthy array read-over-write (select/store), Nelson-Oppen LIA+EUF, and RUP refutation.",
                      "title": "Escrow Array + Quantified Balance Guard (proof/smt)",
                      "valid": [
                        "proof/valid?",
                        [
                          "object/get",
                          "smt_guard",
                          "proof"
                        ]
                      ]
                    },
                    "smt_guard"
                  ],
                  [
                    "ui/proof",
                    {
                      "summary": "Automatically synthesized auxiliary lemma x >= 0 via CTI-guided PDR-lite strengthening and verified initiation + consecution + safety.",
                      "title": "Accumulator Non-Negativity (proof/invariant strengthen)",
                      "valid": [
                        "proof/valid?",
                        [
                          "object/get",
                          "pdr_inv",
                          "proof"
                        ]
                      ]
                    },
                    "pdr_inv"
                  ]
                ]
              ],
              [
                "else",
                [
                  "ui/card",
                  {
                    "title": "Kernel-Checked Derivation: planner reaches ledger"
                  },
                  [
                    "ui/why",
                    {
                      "title": "why(reaches(planner, ledger))"
                    },
                    "why_ledger"
                  ]
                ]
              ]
            ]
          ]
        ]
      ]
    ],
    {
      "persist": true
    }
  ],
  [
    "view"
  ]
]