<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Reference on factgraph</title><link>http://factgraph.docs.symbolic-intelligence.de/docs/reference/</link><description>Recent content in Reference on factgraph</description><generator>Hugo</generator><language>en-us</language><copyright>[© CC BY 4.0](https://creativecommons.org/licenses/by/4.0/legalcode)</copyright><atom:link href="http://factgraph.docs.symbolic-intelligence.de/docs/reference/index.xml" rel="self" type="application/rss+xml"/><item><title>factgraph (entry point)</title><link>http://factgraph.docs.symbolic-intelligence.de/docs/reference/factgraph/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>http://factgraph.docs.symbolic-intelligence.de/docs/reference/factgraph/</guid><description>&lt;h1 id="factgraph-entry-point-and-namespace-map"&gt;FactGraph (entry point and namespace map)&lt;a class="anchor" href="#factgraph-entry-point-and-namespace-map"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;The &lt;code&gt;FactGraph&lt;/code&gt; class is the SDK entry point: it owns the compiled schema and the append-only ledger, and exposes every user-facing operation through a set of &lt;code&gt;fg.*&lt;/code&gt; namespaces. &lt;code&gt;FactGraph&lt;/code&gt; is a literal alias of &lt;code&gt;SDKStore&lt;/code&gt; (&lt;code&gt;FactGraph = SDKStore&lt;/code&gt;); both names refer to the same class and are exported from &lt;code&gt;factgraph.sdk&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id="factgraph"&gt;&lt;code&gt;FactGraph&lt;/code&gt;&lt;a class="anchor" href="#factgraph"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The main SDK graph object. It holds the compiled schema (&lt;code&gt;schema_ir&lt;/code&gt;), an append-only &lt;code&gt;Ledger&lt;/code&gt;, an optional workspace path, and the namespace managers reachable as properties. Instances are normally built with the classmethod constructors below rather than by calling the class directly.&lt;/p&gt;</description></item><item><title>Schema</title><link>http://factgraph.docs.symbolic-intelligence.de/docs/reference/schema/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>http://factgraph.docs.symbolic-intelligence.de/docs/reference/schema/</guid><description>&lt;h1 id="schema-entity-identity-field"&gt;Schema: Entity, Identity, Field&lt;a class="anchor" href="#schema-entity-identity-field"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;Reference for declaring a factgraph schema with Python classes: the &lt;code&gt;Entity&lt;/code&gt; base class, the &lt;code&gt;Identity&lt;/code&gt; and &lt;code&gt;Field&lt;/code&gt; descriptors, the compile helpers, and the &lt;code&gt;fg.schema&lt;/code&gt; register/extend/apply namespace.&lt;/p&gt;
&lt;p&gt;All symbols on this page are importable from &lt;code&gt;factgraph.sdk&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#e2e4e5;background-color:#282a36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-python" data-lang="python"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#ff6ac1"&gt;from&lt;/span&gt; factgraph.sdk &lt;span style="color:#ff6ac1"&gt;import&lt;/span&gt; Entity, Field, Identity
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#ff6ac1"&gt;from&lt;/span&gt; factgraph.sdk &lt;span style="color:#ff6ac1"&gt;import&lt;/span&gt; (
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; compile_schema_from_classes,
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; schema_preflight_from_classes,
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; build_authoring_schema_from_classes,
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;A schema is declared by subclassing &lt;code&gt;Entity&lt;/code&gt; and assigning annotated &lt;code&gt;Identity&lt;/code&gt; and &lt;code&gt;Field&lt;/code&gt; descriptors. The &lt;code&gt;EntityMeta&lt;/code&gt; metaclass reads the annotations at class-definition time and compiles them into a per-class &lt;code&gt;__sdk_entity_spec__&lt;/code&gt;. &lt;code&gt;FactGraph.create(schema_classes=[...])&lt;/code&gt; consumes those specs to build the graph schema.&lt;/p&gt;</description></item><item><title>Three-layer API</title><link>http://factgraph.docs.symbolic-intelligence.de/docs/reference/three-layer-api/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>http://factgraph.docs.symbolic-intelligence.de/docs/reference/three-layer-api/</guid><description>&lt;h1 id="three-layer-api-entities-fields-assertions"&gt;Three-layer API: entities, fields, assertions&lt;a class="anchor" href="#three-layer-api-entities-fields-assertions"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;The write and read surface of a &lt;code&gt;FactGraph&lt;/code&gt; (alias of &lt;code&gt;SDKStore&lt;/code&gt;) is divided into three navigation layers, each exposed as a read-only namespace on the graph instance &lt;code&gt;fg&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Each namespace is selected by a fixed navigation key. Passing the wrong kind of key raises &lt;code&gt;SDKStoreError&lt;/code&gt; with a message that names the correct layer (citing ADR-API §4.1.1). The layers are:&lt;/p&gt;
&lt;table&gt;
 &lt;thead&gt;
 &lt;tr&gt;
 &lt;th&gt;Namespace&lt;/th&gt;
 &lt;th&gt;Layer&lt;/th&gt;
 &lt;th&gt;Navigation key&lt;/th&gt;
 &lt;th&gt;Property&lt;/th&gt;
 &lt;/tr&gt;
 &lt;/thead&gt;
 &lt;tbody&gt;
 &lt;tr&gt;
 &lt;td&gt;&lt;code&gt;fg.entities&lt;/code&gt;&lt;/td&gt;
 &lt;td&gt;1&lt;/td&gt;
 &lt;td&gt;&lt;code&gt;EntityClass&lt;/code&gt; + identity kwargs, or a managed &lt;code&gt;e_ref&lt;/code&gt;&lt;/td&gt;
 &lt;td&gt;&lt;code&gt;entities&lt;/code&gt;&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;&lt;code&gt;fg.fields&lt;/code&gt;&lt;/td&gt;
 &lt;td&gt;2&lt;/td&gt;
 &lt;td&gt;&lt;code&gt;Field&lt;/code&gt; descriptor + &lt;code&gt;e_ref&lt;/code&gt; (+ optional value)&lt;/td&gt;
 &lt;td&gt;&lt;code&gt;fields&lt;/code&gt;&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;&lt;code&gt;fg.assertions&lt;/code&gt;&lt;/td&gt;
 &lt;td&gt;3&lt;/td&gt;
 &lt;td&gt;&lt;code&gt;asrt_id&lt;/code&gt; string&lt;/td&gt;
 &lt;td&gt;&lt;code&gt;assertions&lt;/code&gt;&lt;/td&gt;
 &lt;/tr&gt;
 &lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;All three namespaces reject attribute assignment: &lt;code&gt;fg.entities.x = ...&lt;/code&gt;, &lt;code&gt;fg.fields.x = ...&lt;/code&gt;, and &lt;code&gt;fg.assertions.x = ...&lt;/code&gt; each raise &lt;code&gt;FrozenSnapshotError&lt;/code&gt;.&lt;/p&gt;</description></item><item><title>Rules</title><link>http://factgraph.docs.symbolic-intelligence.de/docs/reference/rules/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>http://factgraph.docs.symbolic-intelligence.de/docs/reference/rules/</guid><description>&lt;h1 id="rules"&gt;Rules&lt;a class="anchor" href="#rules"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;Reference for the rule-authoring surface: &lt;code&gt;build_application_rule&lt;/code&gt;, the Entity-DSL atom forms, &lt;code&gt;vars&lt;/code&gt;, &lt;code&gt;Not&lt;/code&gt;, the application &lt;code&gt;Rule&lt;/code&gt; value, &lt;code&gt;RuleExpr&lt;/code&gt; composition, and &lt;code&gt;fg.rules.inspect&lt;/code&gt; with its &lt;code&gt;RuleExprInspect&lt;/code&gt; result. Most of these symbols are importable from &lt;code&gt;factgraph.sdk&lt;/code&gt;. The supporting types &lt;code&gt;RuleValidationError&lt;/code&gt;, &lt;code&gt;RuleOccurrence&lt;/code&gt;, and &lt;code&gt;RulePortRef&lt;/code&gt; are not exported from &lt;code&gt;factgraph.sdk&lt;/code&gt;; import them from &lt;code&gt;factgraph.application.protocol&lt;/code&gt; (their defining module is &lt;code&gt;factgraph.application.protocol.rule&lt;/code&gt;). &lt;code&gt;PortType&lt;/code&gt; is importable only from &lt;code&gt;factgraph.application.protocol.rule&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;A &lt;code&gt;Rule&lt;/code&gt; is an AND-only conjunction of conditions over existing facts, with named output &lt;code&gt;ports&lt;/code&gt;. Rules are values: they compose with &lt;code&gt;&amp;amp;&lt;/code&gt; and &lt;code&gt;|&lt;/code&gt; into a &lt;code&gt;RuleExpr&lt;/code&gt;, and are inspected with &lt;code&gt;fg.rules.inspect&lt;/code&gt;.&lt;/p&gt;</description></item><item><title>Evaluation and explanation</title><link>http://factgraph.docs.symbolic-intelligence.de/docs/reference/evaluation/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>http://factgraph.docs.symbolic-intelligence.de/docs/reference/evaluation/</guid><description>&lt;h1 id="evaluation-and-explanation"&gt;Evaluation and explanation&lt;a class="anchor" href="#evaluation-and-explanation"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;The &lt;code&gt;fg.eval&lt;/code&gt; namespace, its result envelope (&lt;code&gt;EvaluateResult&lt;/code&gt; / &lt;code&gt;EvaluateRow&lt;/code&gt;), and the explanation surface (&lt;code&gt;Explanation&lt;/code&gt; and the &lt;code&gt;EvidenceGraph&lt;/code&gt; it carries).&lt;/p&gt;
&lt;p&gt;&lt;code&gt;fg.eval&lt;/code&gt; is a read-only namespace on a &lt;code&gt;FactGraph&lt;/code&gt; / &lt;code&gt;SDKStore&lt;/code&gt; instance. Assigning to it raises &lt;code&gt;FrozenSnapshotError&lt;/code&gt;. It never writes to the ledger.&lt;/p&gt;
&lt;h2 id="fgevalevaluaterule_or_expr--head-enginenone-confignone---evaluateresult"&gt;&lt;code&gt;fg.eval.evaluate(rule_or_expr, *, head, engine=None, config=None) -&amp;gt; EvaluateResult&lt;/code&gt;&lt;a class="anchor" href="#fgevalevaluaterule_or_expr--head-enginenone-confignone---evaluateresult"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Evaluates an application &lt;code&gt;Rule&lt;/code&gt; or a &lt;code&gt;RuleExpr&lt;/code&gt; against the current visible view and returns an &lt;code&gt;EvaluateResult&lt;/code&gt; envelope. (The same method also accepts an &lt;code&gt;Inference&lt;/code&gt; object or a structured derivation dict; those legacy derivation inputs are not covered here.)&lt;/p&gt;</description></item><item><title>Engines and semantics</title><link>http://factgraph.docs.symbolic-intelligence.de/docs/reference/engines-and-semantics/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>http://factgraph.docs.symbolic-intelligence.de/docs/reference/engines-and-semantics/</guid><description>&lt;h1 id="engines-and-semantics"&gt;Engines and semantics&lt;a class="anchor" href="#engines-and-semantics"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;The &lt;code&gt;engine=&lt;/code&gt; and &lt;code&gt;config=&lt;/code&gt; options of &lt;code&gt;fg.eval.evaluate(...)&lt;/code&gt; and &lt;code&gt;fg.eval.explain(...)&lt;/code&gt;, the supported engine names, the public semantics wrappers &lt;code&gt;ProbLogConfig&lt;/code&gt; and &lt;code&gt;PyReasonConfig&lt;/code&gt;, the canonical &lt;code&gt;SemanticsProfile&lt;/code&gt;, and how certainty is represented per engine.&lt;/p&gt;
&lt;h2 id="engine-option"&gt;&lt;code&gt;engine=&lt;/code&gt; option&lt;a class="anchor" href="#engine-option"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Selects the runtime adapter that executes a rule, RuleExpr, or inference. Passed as a keyword to &lt;code&gt;fg.eval.evaluate(...)&lt;/code&gt;, &lt;code&gt;fg.eval.evaluate_candidates(...)&lt;/code&gt;, and &lt;code&gt;fg.eval.explain(...)&lt;/code&gt;.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Type:&lt;/strong&gt; string or &lt;code&gt;None&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Default:&lt;/strong&gt; &lt;code&gt;None&lt;/code&gt;, which resolves to &lt;code&gt;&amp;quot;native&amp;quot;&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Accepted values:&lt;/strong&gt; &lt;code&gt;&amp;quot;native&amp;quot;&lt;/code&gt;, &lt;code&gt;&amp;quot;souffle&amp;quot;&lt;/code&gt;, &lt;code&gt;&amp;quot;problog&amp;quot;&lt;/code&gt;, &lt;code&gt;&amp;quot;pyreason&amp;quot;&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The accepted set is fixed by &lt;code&gt;SUPPORTED_ENGINES&lt;/code&gt; in &lt;code&gt;factgraph.core.semantics&lt;/code&gt;:&lt;/p&gt;</description></item><item><title>Audit and capabilities</title><link>http://factgraph.docs.symbolic-intelligence.de/docs/reference/audit/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>http://factgraph.docs.symbolic-intelligence.de/docs/reference/audit/</guid><description>&lt;h1 id="audit-and-capabilities"&gt;Audit and capabilities&lt;a class="anchor" href="#audit-and-capabilities"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;Reference for the &lt;code&gt;fg.audit&lt;/code&gt; namespace (&lt;code&gt;explain&lt;/code&gt;, &lt;code&gt;conflicts&lt;/code&gt;, &lt;code&gt;diff_proof_frames&lt;/code&gt;) and the &lt;code&gt;fg.meta&lt;/code&gt; namespace (&lt;code&gt;capabilities&lt;/code&gt;). Both namespaces are read-only: assigning an attribute on either raises &lt;code&gt;FrozenSnapshotError&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id="fgaudit"&gt;&lt;code&gt;fg.audit&lt;/code&gt;&lt;a class="anchor" href="#fgaudit"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The &lt;code&gt;fg.audit&lt;/code&gt; namespace exposes post-hoc audit queries over the ledger and over recorded round events. The attribute &lt;code&gt;fg.audit&lt;/code&gt; returns the audit namespace manager.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#e2e4e5;background-color:#282a36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-python" data-lang="python"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;fg&lt;span style="color:#ff6ac1"&gt;.&lt;/span&gt;audit &lt;span style="color:#78787e"&gt;# read-only namespace; fg.audit.x = ... raises FrozenSnapshotError&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="fgauditexplaintarget"&gt;&lt;code&gt;fg.audit.explain(target)&lt;/code&gt;&lt;a class="anchor" href="#fgauditexplaintarget"&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Explain chosen-policy state for the predicate/entity cell of one assertion.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Parameters:&lt;/strong&gt;&lt;/p&gt;</description></item><item><title>Persistence</title><link>http://factgraph.docs.symbolic-intelligence.de/docs/reference/persistence/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>http://factgraph.docs.symbolic-intelligence.de/docs/reference/persistence/</guid><description>&lt;h1 id="persistence-workspaces-and-attach"&gt;Persistence: workspaces and attach&lt;a class="anchor" href="#persistence-workspaces-and-attach"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;The public surface for persisting a &lt;code&gt;FactGraph&lt;/code&gt; to disk and reloading it: the workspace &lt;code&gt;create&lt;/code&gt; / &lt;code&gt;save_workspace&lt;/code&gt; / &lt;code&gt;load_workspace&lt;/code&gt; lifecycle, the &lt;code&gt;FactGraph.attach(db, ...)&lt;/code&gt; Database lifecycle, and the &lt;code&gt;Database&lt;/code&gt;, &lt;code&gt;CommitResult&lt;/code&gt;, &lt;code&gt;AssertionInput&lt;/code&gt;, and &lt;code&gt;MetaEntry&lt;/code&gt; types exported from &lt;code&gt;factgraph.sdk&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;FactGraph&lt;/code&gt; is a literal alias of &lt;code&gt;SDKStore&lt;/code&gt; (&lt;code&gt;FactGraph = SDKStore&lt;/code&gt;). The names are interchangeable; this page uses &lt;code&gt;FactGraph&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id="factgraphcreateschema_classes--ledgernone-ledger_pathnone-pathnone-artifact_store_rootnone-registry_rootnone-registrynone-default_row_formatnone---sdkstore"&gt;&lt;code&gt;FactGraph.create(schema_classes, *, ledger=None, ledger_path=None, path=None, artifact_store_root=None, registry_root=None, registry=None, default_row_format=None) -&amp;gt; SDKStore&lt;/code&gt;&lt;a class="anchor" href="#factgraphcreateschema_classes--ledgernone-ledger_pathnone-pathnone-artifact_store_rootnone-registry_rootnone-registrynone-default_row_formatnone---sdkstore"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Classmethod. Creates a &lt;code&gt;FactGraph&lt;/code&gt; from Python &lt;code&gt;Entity&lt;/code&gt; classes and optionally binds it to a durable workspace directory. This is the constructor that produces a workspace-capable graph.&lt;/p&gt;</description></item><item><title>Errors</title><link>http://factgraph.docs.symbolic-intelligence.de/docs/reference/errors/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>http://factgraph.docs.symbolic-intelligence.de/docs/reference/errors/</guid><description>&lt;h1 id="errors-and-error-codes"&gt;Errors and error codes&lt;a class="anchor" href="#errors-and-error-codes"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;The public exception hierarchy raised by the factgraph SDK, the attributes carried on each error, and the exported error-code string constants.&lt;/p&gt;
&lt;p&gt;Most public error classes and all code constants are re-exported from the top-level &lt;code&gt;factgraph.sdk&lt;/code&gt; package (see &lt;a href="http://factgraph.docs.symbolic-intelligence.de/docs/reference/factgraph/"&gt;&lt;code&gt;reference/factgraph.md&lt;/code&gt;&lt;/a&gt;). The base class &lt;code&gt;SDKError&lt;/code&gt; is not re-exported from &lt;code&gt;factgraph.sdk&lt;/code&gt;; import it from &lt;code&gt;factgraph.sdk.errors&lt;/code&gt;. &lt;code&gt;RuleValidationError&lt;/code&gt; and &lt;code&gt;DetachedRowError&lt;/code&gt; live outside the SDK package; &lt;code&gt;DetachedRowError&lt;/code&gt; is re-exported from &lt;code&gt;factgraph.sdk&lt;/code&gt;, while &lt;code&gt;RuleValidationError&lt;/code&gt; is not.&lt;/p&gt;</description></item></channel></rss>