Skip to content

Python API reference

Your next step

In a terminal in your vault folder, type uv run python.

Before you start

  • A vault folder with a scat.toml file in it, for example a copy of the template. Getting started makes one.
  • A Python session started in that folder with uv run python, and import scat_tools typed in it. Every call below looks in the current folder unless you pass root=.
  • The same operations as commands are in the CLI reference. The two paths give the same messages.

How every call behaves

  • Every call returns a result. At the REPL, the result prints as the message the matching scat command prints, so you do not need print.
  • str(result) is that message. result.ok is False when the message holds an error or a refusal, and True otherwise. Warnings leave it True. On the CLI, ok is the exit code: True is 0, False is 1.
  • A call that cannot do what you asked does not raise. It returns a result that starts with refused and says what to do next. Nothing is written when a call refuses.
  • Every call takes the keyword root=, the vault folder (default: the current folder). On the CLI it is --root.
  • The outputs on this page are what a fresh copy of the template prints. The Python tab and the CLI tab use different new page names (reading-group and study-circle, desk-notes-one and desk-notes-two), so you can run both tabs in one vault, in page order, and each prints what is shown.
Python CLI What it does
scat_tools.check scat check Check the vault, a page, or a page and its neighbours. Writes nothing.
scat_tools.status scat status Show each page's status and the counts. Writes nothing.
scat_tools.index scat index Write the index page of each type that has none.
scat_tools.stub scat stub Create one stub page.
scat_tools.record_edge scat record-edge Record an edge: add its row to the narratives that tell it.
scat_tools.remove_edge scat remove-edge Remove an edge: delete its rows.
scat_tools.merge scat merge Make node page A into node page B of the same type, one node, moving no text; plan=True shows it and writes nothing.
scat_tools.rename scat rename Give a node page a new name and rewrite every link and row that names it; plan=True shows it and writes nothing.
scat_tools.link_page scat link-page Make the optional link page for one narrative's account of one node.
scat_tools.migrate_stakeholder scat migrate-stakeholder Move a vault that still has a group/ folder to the stakeholder layer, once; plan=True shows it and writes nothing.
scat_tools.where_used scat where-used Show every place a node page is used. Writes nothing.
scat_tools.stub_links scat stub-links Create the node pages that the ends of rows link and the vault lacks.
scat_tools.set_status scat set-status Set a page's status.
scat_tools.load none Read the vault into its knowledge graph. Writes nothing.
scat_tools.fingerprint scat fingerprint View: a narrative's nodes and edges (candidates when asked).
scat_tools.edge_table scat edges View: every edge of one type.
scat_tools.layered scat layered View: the union of fingerprints, in four layers.
scat_tools.trace scat trace View: what a node reaches, up or down the layers.
scat_tools.evidence scat evidence View: one node's narratives with the paragraph around each link, its edges and its adjacent nodes.
scat_tools.review scat review View: every pair of node pages of one type that shares a twin row or an adjacent node, the most shared first.
scat_tools.recurrence scat recurrence View: how many narratives and stakeholders reach each node and edge.
scat_tools.attribution scat attribution View: the narratives by contributor (where the vault's attribution mode allows it).
scat_tools.export_edges scat export-edges Write the edge tables as CSV and Markdown.
scat_tools.guide scat guide Show the guide of a lifecycle stage, or the index of the stages. Needs no vault.
scat_tools.draw.render, scat_tools.draw.fingerprint, scat_tools.draw.layered, scat_tools.draw.trace scat draw Draw a view, or a view's result, as an image (needs the extra draw).

Machine-readable output

result.to_dict() returns the data of the result as plain Python: the same document that the matching scat command prints with --json (see the CLI reference). --json prints exactly one JSON document and nothing else, and the exit code does not change. Print it with json.dumps(result.to_dict(), indent=2). The fields, and the rule for when schema_version changes (it is 3), are in the machine interface contract.

The examples below show to_dict() once for each call, with the output a fresh copy of the template gives at that point in the page. These JSON blocks are for reading: they are not run by the docs test.

scat_tools.check

check(page=None, *, neighborhood=False, root=".")

Checks the vault against the rules and returns a CheckResult (see Results). Writes nothing.

Parameter Meaning
page A page name (anonymity) or its path from the vault folder (concern/anonymity.md). Without it, the whole vault.
neighborhood True checks page and every page one link away, in either direction. It needs page.
root The vault folder.

It prints one block per problem, then a count line: <n> errors, <n> warnings. It starts with the vault's attribution mode (attribution mode: disallowed). With no problems it then prints no problems. Errors block, warnings do not. A rule id such as SCAT-END-NOPAGE names the rule; the Fix: line says what to do. Asking for neighborhood=True without a page, or for a page that is not there, returns a refusal.

The whole vault, and a page and every page one link away:

import scat_tools

scat_tools.check()
scat_tools.check("anonymity", neighborhood=True)
attribution mode: disallowed
no problems
attribution mode: disallowed
no problems
uv run scat check
uv run scat check anonymity --neighborhood
attribution mode: disallowed
no problems
attribution mode: disallowed
no problems

The check looks at structure only. It does not judge what the notes say: a forgotten edge is graded by no rule, and tensions, matches and gaps are for analysis, after the check passes and a coder has signed off the content.

One page, by name or by path:

scat_tools.check("anonymity")
scat_tools.check("concern/anonymity.md")
attribution mode: disallowed
no problems
attribution mode: disallowed
no problems
uv run scat check anonymity
uv run scat check concern/anonymity.md
attribution mode: disallowed
no problems
attribution mode: disallowed
no problems

As data, on the unchanged template (import json first):

>>> print(json.dumps(scat_tools.check().to_dict(), indent=2))
{
  "schema_version": 3,
  "kind": "check",
  "operation": "check",
  "ok": true,
  "mode": "disallowed",
  "problems": []
}

To see a problem with a fix a program can apply, change [[cap-setting]] to [[cap-settin]] in the second row of the table of narrative/groups-under-a-cap-pitch.md (line 22), a one-letter typo in a link. The fix has three options: a replace-text edit that writes the right name, a command that creates the missing page, and a delete-line edit.

>>> print(json.dumps(scat_tools.check().to_dict(), indent=2))
{
  "schema_version": 3,
  "kind": "check",
  "operation": "check",
  "ok": false,
  "mode": "disallowed",
  "problems": [
    {
      "rule": "SCAT-END-NOPAGE",
      "severity": "error",
      "file": "narrative/groups-under-a-cap-pitch.md",
      "line": 22,
      "column": 55,
      "field": null,
      "where": "row 2 cell `to`",
      "what": "[[cap-settin]] does not reach a page (no page is named cap-settin)",
      "repeat": 1,
      "fix": {
        "kind": "options",
        "options": [
          {
            "kind": "exact",
            "text": "replace `[[cap-settin]]` with `[[cap-setting]]`",
            "edits": [
              {
                "action": "replace-text",
                "file": "narrative/groups-under-a-cap-pitch.md",
                "line": 22,
                "column": 55,
                "find": "[[cap-settin]]",
                "replace": "[[cap-setting]]"
              }
            ]
          },
          {
            "kind": "exact",
            "text": "run `scat stub cap-settin --type technology` (REPL: `scat_tools.stub(\"cap-settin\", type=\"technology\")`) to create a technology page",
            "command": {
              "argv": [
                "stub",
                "cap-settin",
                "--type",
                "technology"
              ],
              "repl": "scat_tools.stub(\"cap-settin\", type=\"technology\")"
            }
          },
          {
            "kind": "exact",
            "text": "delete the row",
            "edits": [
              {
                "action": "delete-line",
                "file": "narrative/groups-under-a-cap-pitch.md",
                "line": 22,
                "find": "| [[groups-clustered-under-a-cap]] | is provided by | [[cap-settin]] | The cap setting is what fixes the number of stakeholders. The cap is a per-instance parameter; the example vault sets it to 6. |"
              }
            ]
          }
        ],
        "notes": []
      },
      "text": "error [SCAT-END-NOPAGE] narrative/groups-under-a-cap-pitch.md:22:55 row 2 cell `to`: [[cap-settin]] does not reach a page (no page is named cap-settin)\n  Fix (the coder chooses one):\n    1. replace `[[cap-settin]]` with `[[cap-setting]]`\n    2. run `scat stub cap-settin --type technology` (REPL: `scat_tools.stub(\"cap-settin\", type=\"technology\")`) to create a technology page\n    3. delete the row"
    }
  ]
}

Change the typo back ([[cap-settin]] to [[cap-setting]]) before you type the next commands, which assume the narrative as the template has it.

scat_tools.status

status(page=None, *, neighborhood=False, root=".")

Reads the status of each page and returns a StatusReport (see Results). Writes nothing.

Parameter Meaning
page A page name or path. Without it, the whole vault.
neighborhood True shows page and every page one link away, in either direction. It needs page.
root The vault folder.

It prints one line per page: the status (stub, draft, done, (missing) or something invalid as written), then the path. The last line counts the pages by status. For a neighborhood, the page comes first and the others follow in path order. A missing page, or neighborhood=True without a page, returns a refusal.

scat_tools.status("anonymity")
scat_tools.status("anonymity", neighborhood=True)
done         concern/anonymity.md
1 done
done         concern/anonymity.md
done         concern/attribution.md
done         narrative/groups-under-a-cap-pitch.md
done         narrative/notes-at-a-chatham-house-session.md
4 done
uv run scat status anonymity
uv run scat status anonymity --neighborhood
done         concern/anonymity.md
1 done
done         concern/anonymity.md
done         concern/attribution.md
done         narrative/groups-under-a-cap-pitch.md
done         narrative/notes-at-a-chatham-house-session.md
4 done

scat_tools.status() and scat status list every page in the vault, then the counts.

As data:

>>> print(json.dumps(scat_tools.status("anonymity").to_dict(), indent=2))
{
  "schema_version": 3,
  "kind": "status",
  "operation": "status",
  "ok": true,
  "scope": "page",
  "rows": [
    {
      "path": "concern/anonymity.md",
      "name": "anonymity",
      "type": "concern",
      "status": "done"
    }
  ],
  "counts": {
    "stub": 0,
    "draft": 0,
    "done": 1,
    "other": 0
  },
  "notes": []
}

scat_tools.which_stage

which_stage(*, root=".")

Returns the project's stage, kept in lifecycle.toml at the vault's root: its name, who set it, its work, its tools and each move out of it, with who decides and, for a move the tool can read from the vault, whether it holds now. It writes nothing. With no usable lifecycle.toml the stage is unknown, and the result lists the six stages. CLI twin: scat which-stage.

The functions of this page do not look at the stage: the REPL is a library. The scat command does, and so does the MCP server.

Parameter Meaning
root The vault folder (default: the current directory).

str(result) is the text scat which-stage prints. result.to_dict() is the document, of kind stage; its stage is plan, capture, code, synthesise, analyse, report or unknown.

scat_tools.which_stage().to_dict()["stage"]
uv run scat which-stage

scat_tools.set_stage

set_stage(to, by=None, *, root=".")

Moves the project to the stage to and writes it, signed with by, the name of the person who said so, to lifecycle.toml. Only a move the current stage lists is made. A stage that is not one of the six, the stage the project is already in, a move the model does not list, and a missing or blank by are each a refusal, with ok set to False and nothing written. A move the tool can read from the vault and that does not yet hold is reported in advisory and is still made. CLI twin: scat set-stage.

Parameter Meaning
to The stage to move to.
by The name of the person who said so. A signature, not proof of consent.
root The vault folder (default: the current directory).

str(result) is the text scat set-stage prints. The two tabs are two moves in turn: the project goes from plan to capture, then from capture to code.

scat_tools.set_stage("capture", "Ada Lovelace").ok
uv run scat set-stage --to code --by "Ada Lovelace"

scat_tools.index

index(*, root=".")

Writes the index page of each type that has none: index/<type>.base, an Obsidian Base that reads the vault itself and so cannot go stale. It never rewrites an existing file, so a column you add by hand stays.

Parameter Meaning
root The vault folder.

It prints one line per index page: created, or unchanged for one that exists. The template ships all five, so on it every line says unchanged. It refuses for an index page's name that another file already holds.

scat_tools.index()
unchanged index/stakeholder.base
unchanged index/concern.base
unchanged index/affordance.base
unchanged index/technology.base
unchanged index/narrative.base
uv run scat index
unchanged index/stakeholder.base
unchanged index/concern.base
unchanged index/affordance.base
unchanged index/technology.base
unchanged index/narrative.base

As data:

>>> print(json.dumps(scat_tools.index().to_dict(), indent=2))
{
  "schema_version": 3,
  "kind": "operation",
  "operation": "index",
  "ok": true,
  "created": [],
  "changed": [],
  "unchanged": [
    "index/stakeholder.base",
    "index/concern.base",
    "index/affordance.base",
    "index/technology.base",
    "index/narrative.base"
  ],
  "refused": [],
  "notes": []
}

scat_tools.stub

stub(name, type, *, root=".")

Creates one stub page: its type, status: stub, and a title made from the name. It never changes an existing file.

Parameter Meaning
name The new page's name: a-z, 0-9 and single hyphens, starting and ending with a letter or digit, at most 64 characters. These names are reserved and refuse: con, prn, aux, nul, com0 to com9, lpt0 to lpt9.
type The page type key: stakeholder, concern, affordance, technology or narrative.
root The vault folder.

It prints created <path>. It refuses when the name is not legal (a reserved name, or one over 64 characters; each ends with a Fix: line that offers a name that works), when a Markdown file already has the name (in any letter case), and when the type is not one of the five.

scat_tools.stub("reading-group", type="concern")
scat_tools.stub("desk-notes-one", type="narrative")
created concern/reading-group.md
created narrative/desk-notes-one.md
uv run scat stub study-circle --type concern
uv run scat stub desk-notes-two --type narrative
created concern/study-circle.md
created narrative/desk-notes-two.md

Running it again for the same name refuses, and the CLI exits with 1:

refused name `reading-group`: a Markdown file already has this name (concern/reading-group.md); names are compared without regard to case
  Fix: link to the existing page, or choose another name

As data:

>>> print(json.dumps(scat_tools.stub("reading-list", type="technology").to_dict(), indent=2))
{
  "schema_version": 3,
  "kind": "operation",
  "operation": "stub",
  "ok": true,
  "created": [
    "technology/reading-list.md"
  ],
  "changed": [],
  "unchanged": [],
  "refused": [],
  "notes": []
}

scat_tools.record_edge

record_edge(type, from_, to, told_by, note="", *, root=".")

Records an edge: adds its row to each narrative in told_by that has none. A node or a narrative that does not exist is made as a stub, the node of the type its layer fixes. It leaves every link as it is.

Parameter Meaning
type holds (stakeholder, then concern), addressed-by (concern, then affordance) or provided-by (affordance, then technology). The verb, such as "is addressed by", is accepted too.
from_, to The names of the two nodes, in the order the type lists.
told_by The name of a narrative, or a list of names.
note The row's note (default: none).
root The vault folder.

It prints created <path> for each page it made, changed <path> for each narrative it added a row to, and a note naming the row and its line. A narrative that already has the row prints unchanged <path>, so repeating a call writes nothing. It refuses, and writes nothing, when a narrative it would change is done (set it to draft first), when the type is unknown, when the two names are the same, or when a node exists with the wrong type for its layer. The result has edge (the type, the two names and every narrative that now tells it), rows_added and rows_removed.

scat_tools.record_edge("holds", "project-leads", "reading-group", ["desk-notes-one"], note="Said twice.")
changed narrative/desk-notes-one.md
note: added `| [[project-leads]] | holds | [[reading-group]] | Said twice. |` to narrative/desk-notes-one.md at line 12
uv run scat record-edge holds project-leads study-circle --told-by desk-notes-two --note "Said twice."
changed narrative/desk-notes-two.md
note: added `| [[project-leads]] | holds | [[study-circle]] | Said twice. |` to narrative/desk-notes-two.md at line 12

As data:

>>> print(json.dumps(scat_tools.record_edge("addressed-by", "reading-group", "reading-shelf", ["desk-notes-one"]).to_dict(), indent=2))
{
  "schema_version": 3,
  "kind": "operation",
  "operation": "record-edge",
  "ok": true,
  "created": [
    "affordance/reading-shelf.md"
  ],
  "changed": [
    "narrative/desk-notes-one.md"
  ],
  "unchanged": [],
  "refused": [],
  "notes": [
    "added `| [[reading-group]] | is addressed by | [[reading-shelf]] | |` to narrative/desk-notes-one.md at line 13"
  ],
  "edge": {
    "type": "addressed-by",
    "from": "reading-group",
    "to": "reading-shelf",
    "narratives": [
      "desk-notes-one"
    ]
  },
  "rows_added": [
    {
      "narrative": "desk-notes-one",
      "file": "narrative/desk-notes-one.md",
      "line": 13,
      "note": ""
    }
  ],
  "rows_removed": []
}

scat_tools.remove_edge

remove_edge(from_, to, told_by=None, *, root=".")

Removes an edge: deletes its rows, from the narratives named in told_by or, without it, from every narrative that tells it. The links stay.

Parameter Meaning
from_, to The names of the two nodes. The type follows from their layers.
told_by A narrative name, or a list of names; without it, every narrative that tells the edge.
root The vault folder.

It prints changed <path> for each narrative it deleted a row from, and a note that the links stay. When no narrative tells the edge it prints remove-edge: nothing to do. It refuses, and writes nothing, when a narrative it would change is done.

scat_tools.remove_edge("project-leads", "reading-group")
changed narrative/desk-notes-one.md
note: removed the row at line 12 of narrative/desk-notes-one.md
note: the links stay in the narratives; remove one by hand if the account no longer names it
uv run scat remove-edge project-leads study-circle
changed narrative/desk-notes-two.md
note: removed the row at line 12 of narrative/desk-notes-two.md
note: the links stay in the narratives; remove one by hand if the account no longer names it

As data:

>>> print(json.dumps(scat_tools.remove_edge("reading-group", "reading-shelf", ["desk-notes-one"]).to_dict(), indent=2))
{
  "schema_version": 3,
  "kind": "operation",
  "operation": "remove-edge",
  "ok": true,
  "created": [],
  "changed": [
    "narrative/desk-notes-one.md"
  ],
  "unchanged": [],
  "refused": [],
  "notes": [
    "removed the row at line 12 of narrative/desk-notes-one.md",
    "the links stay in the narratives; remove one by hand if the account no longer names it"
  ],
  "edge": {
    "type": "addressed-by",
    "from": "reading-group",
    "to": "reading-shelf",
    "narratives": []
  },
  "rows_added": [],
  "rows_removed": [
    {
      "narrative": "desk-notes-one",
      "file": "narrative/desk-notes-one.md",
      "line": 12,
      "note": ""
    }
  ]
}
stub_links(ref=None, *, root=".")

Creates the node pages that the ends of rows link and the vault lacks. Each new page has the type its layer fixes. It creates nothing for a link to an existing page, and nothing for a link outside a row, which has no layer: that is reported as a note, and you make the page with stub.

Parameter Meaning
ref A page name or path: look at that page's rows only. Without it, every page. (The CLI calls this PAGE.)
root The vault folder.

It prints created <path> for each page made, or stub-links: nothing to do.

scat_tools.stub_links()
stub-links: nothing to do
uv run scat stub-links
stub-links: nothing to do

As data:

>>> print(json.dumps(scat_tools.stub_links().to_dict(), indent=2))
{
  "schema_version": 3,
  "kind": "operation",
  "operation": "stub-links",
  "ok": true,
  "created": [],
  "changed": [],
  "unchanged": [],
  "refused": [],
  "notes": []
}

scat_tools.set_status

set_status(name, status, *, root=".")

Sets the status: line in a page's frontmatter and changes nothing else in the file. The lifecycle is stub, then draft, then done.

Parameter Meaning
name A page name or path. (The CLI calls this PAGE.)
status stub, draft or done.
root The vault folder.

It prints changed <path> and a note with the old status. When the page already has that status, it prints unchanged <path> and writes nothing. It refuses when status is not one of the three, when the page is not there, and when the frontmatter cannot be read. Setting done is judged as the page would stand at done, and refused while it would have an error (see below).

scat_tools.set_status("reading-group", "draft")
changed concern/reading-group.md
note: `status` set to draft (was stub)
uv run scat set-status study-circle draft
changed concern/study-circle.md
note: `status` set to draft (was stub)

A status that does not exist refuses, and the CLI exits with 1:

refused status `finished`: this is not a status
  Fix: use one of: stub, draft, done (stub: a name, perhaps some metadata; draft: content, not yet complete; done: complete, conformant and signed off by the coder)

Setting done on a page that would fail refuses with the rule SCAT-DONE-REFUSED. The page is not written, and the refusal lists each error with its fix, as check prints it at done. Here the narrative has no description:

refused [SCAT-DONE-REFUSED] narrative/desk-notes-one.md: 1 error(s) would stand at status done; status unchanged
  error [SCAT-FIELD] narrative/desk-notes-one.md field `description`: missing on a page with status: done
    Fix (the coder chooses one):
      1. add the line `description: "<one sentence you write>"` (author)
      2. run `scat set-status desk-notes-one draft` (REPL: `scat_tools.set_status("desk-notes-one", "draft")`) if the page is not finished
  Fix (the coder chooses one):
    1. fix the problems above, then run `scat set-status desk-notes-one done` again
    2. leave the page at `draft`: run `scat set-status desk-notes-one draft` (REPL: `scat_tools.set_status("desk-notes-one", "draft")`)

As data:

>>> print(json.dumps(scat_tools.set_status("reading-group", "draft").to_dict(), indent=2))
{
  "schema_version": 3,
  "kind": "operation",
  "operation": "set-status",
  "ok": true,
  "created": [],
  "changed": [],
  "unchanged": [
    "concern/reading-group.md"
  ],
  "refused": [],
  "notes": [
    "status is already draft"
  ]
}

A refusal has the same shape, with ok false and the reason in refused (the CLI exits with 1):

>>> print(json.dumps(scat_tools.set_status("reading-group", "finished").to_dict(), indent=2))
{
  "schema_version": 3,
  "kind": "operation",
  "operation": "set-status",
  "ok": false,
  "created": [],
  "changed": [],
  "unchanged": [],
  "refused": [
    {
      "subject": "status `finished`",
      "why": "this is not a status",
      "fix": {
        "kind": "manual",
        "options": [
          {
            "kind": "manual",
            "text": "use one of: stub, draft, done (stub: a name, perhaps some metadata; draft: content, not yet complete; done: complete, conformant and signed off by the coder)"
          }
        ],
        "notes": []
      }
    }
  ],
  "notes": []
}

scat_tools.merge

Merging, renaming and looking up where a node is used are the work of the synthesise stage, and the scat commands for them are refused in the others. The REPL calls are not. Move the project there before the command-line examples that follow:

uv run scat set-stage --to synthesise --by "Ada Lovelace"
merge(a, b, *, plan=False, root=".")

Makes node page a into node page b, two pages of one type, so that there is one node: every link to a in the narratives and node pages becomes a link to b, the node of each link page that names a names b, and a's page is removed. No text is moved: a's body is not copied (git keeps the history of its page), b's body and description are unchanged, and no link page is made. a's description is dropped (b keeps its own, with its status and other fields). It refuses a pair of different types, a page that is not a node page, and a contributor page that links a. Two rows of one narrative that would tell one edge become one row, their notes joined by ;; with plan=True it writes nothing.

Parameter Meaning
a The name of the node page that becomes b, and is removed.
b The name of the node page that stays.
plan True shows what the merge would do and writes nothing. The default applies it.
root The vault folder.

The whole result is built in a temporary copy of the vault first, and written only when the copy passes the check with no new error, holds no link to a, and gives the graph the vault had, with a called b. A narrative that is done stays done; done_narratives lists each one whose text changed. It refuses, and writes nothing, for a pair of different types, a page that is not a node page, a contributor page whose body links a (a merge never writes a contributor page), and an error in a page it reads. The CLI reference says how each kind of link is rewritten.

scat_tools.merge("project-leads", "workshop-participants", plan=True)
merge plan: `project-leads` becomes `workshop-participants`; nothing is written
  3 links to `project-leads` would be rewritten
would change narrative/false-start-and-clean-restart.md (2 links)
would change narrative/two-branches-and-tags-pitch.md (1 link)
would remove stakeholder/project-leads.md
would change 2 `done` narratives (they stay `done`): false-start-and-clean-restart, two-branches-and-tags-pitch
note: the body of `project-leads` is not copied: no text is moved, and git keeps the history of its page
note: the description of `project-leads` is dropped; `workshop-participants` keeps its own, and its body, its status (`done`) and other fields are unchanged
note: what only `project-leads` said stays in git; to carry any of it into `workshop-participants`, read the narratives (`scat evidence workshop-participants`) and write it in your own words
note: a `done` narrative whose text changes stays `done`: read it again before you rely on it
uv run scat merge --plan project-leads workshop-participants

The same text.

result.to_dict() is the document the command prints with --json; its plan, removed, done_narratives and links_rewritten fields are in the CLI reference. A refusal prints what to do next, and nothing is written:

scat_tools.merge("project-leads", "gated-approval", plan=True)
refused project-leads and gated-approval: `project-leads` is a stakeholder and `gated-approval` is an affordance: a merge needs two pages of one type
  Fix: name two node pages of one type (stakeholder, concern, affordance, technology): `scat merge A B` makes A into B

scat_tools.rename

rename(a, c, *, title=None, plan=False, root=".")

Gives node page a the new name c: the page moves to c, every link to a in the narratives and node pages and every from and to cell of an Edges told table becomes c, and the node of each link page that names a names c. It is the simplest move toward a more abstract word. It refuses a name that is taken (two pages that are one node are made one by merge), a name that is not legal, a page that is no node page, a contributor page that links a, and a page it reads that has an error in the check; with plan=True it writes nothing.

Parameter Meaning
a The name of the node page to rename.
c Its new name: a-z, 0-9 and single hyphens.
title The page's new title. The default keeps the title it has.
plan True shows what the rename would do and writes nothing. The default applies it.
root The vault folder.

The whole result is built in a temporary copy of the vault first, and written only when the copy passes the check with no new error, holds no link to a, and gives the graph the vault had, with a called c. It returns a RenameResult.

scat_tools.rename("gated-approval", "gated-merge", plan=True)
rename plan: `gated-approval` would be called `gated-merge`; nothing is written
  5 links to `gated-approval` would be rewritten
would move affordance/gated-approval.md to affordance/gated-merge.md
would change narrative/false-start-and-clean-restart.md (2 links)
would change narrative/two-branches-and-tags-pitch.md (3 links)
would change 2 `done` narratives (they stay `done`): false-start-and-clean-restart, two-branches-and-tags-pitch
note: the title of `gated-merge` is kept as it was: `scat rename gated-approval gated-merge --title "..."` sets it
note: a `done` narrative whose text changes stays `done`: read it again before you rely on it
uv run scat rename --plan gated-approval gated-merge

The same text.

result.to_dict() has plan, moved (from, to), done_narratives and links_rewritten; see the CLI reference.

link_page(narrative, node, *, root=".")

Makes the optional link page for one narrative's account of one node: a page in link/ with the two links in its frontmatter and an empty body, for you to write notes in. Nothing requires a link page, and no rule fires when one is absent. It refuses when the node is no end of a row of the narrative, or either name is no page of its kind; when a page for the pair exists, it writes nothing and says so.

Parameter Meaning
narrative The name of the narrative.
node The name of a stakeholder, concern, affordance or technology that is an end of a row of the narrative.
root The vault folder.
scat_tools.link_page("false-start-and-clean-restart", "intent-without-drift")
created link/false-start-and-clean-restart-intent-without-drift.md
uv run scat link-page two-branches-and-tags-pitch gated-approval

The same text.

The CLI tab makes a different page (two-branches-and-tags-pitch and gated-approval), so the two can run in one copy. See the CLI reference.

scat_tools.migrate_stakeholder

migrate_stakeholder(*, plan=False, root=".")

If your vault still has a group/ folder, call this once. It renames the folder group/ to stakeholder/, rewrites type: group to type: stakeholder in each page of the folder, replaces index/group.base with index/stakeholder.base, and moves stakeholder_group_cap in scat.toml into the stakeholder entry of a [caps] table. It changes no other text. CLI twin: scat migrate-stakeholder.

Parameter Meaning
plan True shows what the migration would do and writes nothing. The default applies it.
root The vault folder.

Called a second time, it prints unchanged for the folder, the index file and scat.toml. It refuses, and writes nothing, when group/ and stakeholder/ both exist. The output below is from a vault that still has a group/ folder. On a vault that is already in the new shape, every line says unchanged.

scat_tools.migrate_stakeholder(plan=True)
note: plan: nothing is written; the migration would rename the folder `group/` to `stakeholder/`; rewrite `type: group` to `type: stakeholder` in 3 page(s); replace `index/group.base` with `index/stakeholder.base`; move `stakeholder_group_cap` into the `stakeholder` entry of `[caps]` in `scat.toml`
uv run scat migrate-stakeholder --plan

The same text.

Without plan, the call prints one line for each file it changed (changed stakeholder/project-leads.md). result.to_dict() is the document the command prints with --json; see the CLI reference.

scat_tools.where_used

where_used(a, *, root=".")

Shows where node page a is used. It writes nothing. For each narrative (or node page) that links a it lists every link and every Edges told row that names a, and a note names the link pages of a. It is what you read to split a in two, assigning each narrative to a or to a new page and editing by hand, or to move detail out of a. A contributor page is never listed.

Parameter Meaning
a The name of the node page to look up.
root The vault folder.

The returned WhereUsed has node, node_type and pages (each with file, name, type, status, links and rows). It refuses a name that is no page, a page that is not a node page, and an error in a page it reads.

scat_tools.where_used("project-leads")
where used: `project-leads` (stakeholder) in 1 page: 2 links, 1 row; nothing is written
  narrative/false-start-and-clean-restart.md (narrative, done): links at line 13, 28
    row 1, line 28: | [[project-leads]] | holds | [[intent-without-drift]] | The project leads hold these as the concerns of the false-start story. |
note: you assign each narrative to `project-leads` or to a new page: make the new page with `scat stub <name> --type stakeholder`, then edit each link and row by hand
note: merge and rename keep done narratives done; to edit a done narrative by hand, set it to draft first: false-start-and-clean-restart
note: the vault's cap for stakeholder pages: cap 6, now 3
uv run scat where-used project-leads

The same text.

scat_tools.load

load(root=".")

Reads the vault into its knowledge graph and returns a Graph. It writes nothing and does not check: the views and the other calls check for themselves.

Parameter Meaning
root The vault folder.

A Graph holds nodes (by layer, in layer order), edges, narratives (the coded ones), excluded (the uncoded ones, left out), candidates and links. graph.summary() counts them. A vault folder that is not there does not raise: graph.ok is False and graph.refusal says what to do. It has no CLI twin: every scat command reads the same graph.

scat_tools.load().summary()
{'nodes': {'stakeholder': 3, 'concern': 5, 'affordance': 3, 'technology': 3}, 'narratives': 6, 'excluded': 0, 'edges': 8, 'edge_status': {'stub': 0, 'draft': 0, 'done': 8}, 'candidates': 7, 'links': 43}

Views

The command-line views belong to the analyse stage:

uv run scat set-stage --to analyse --by "Ada Lovelace"

A view is a purposeful picture or table made from a conformant vault, and the calls below make the views. Each returns a View, or a refusal. Each takes root=, writes nothing, and gives the same output for the same vault.

  • str(view) is a short text, one line per node or edge. At the REPL the view prints as that text.
  • view.ok is True. view.to_dict() is the document.
  • A view refuses, with the problems and their fixes, on a name that is not there or is ambiguous, an edge type or direction that does not exist, a vault folder that is missing, any error in the pages it draws, and a row of a narrative it draws that tells no edge (the file and the row are named; the edge table and the trace draw every narrative). Warnings do not refuse. A narrative that links no node page is excluded: left out of every view, listed under excluded (name, file and how to include it) by each view that draws every narrative, and refused when you name it. Relationship annotations appear in no view.

A narrative's marks, claim_type (actual, hypothetical, unclassified) and kind (scenario, architecture), are filters, and only when you ask. fingerprint, edge_table, layered, trace, evidence and recurrence take claim_type= and kind=, each a value or a list of values; the view then keeps the narratives with one of the values (and the edges they tell), says which filter it applied and names the narratives it left_out. A narrative without a claim_type is unclassified. A value outside the set refuses and names the values. Asked for no filter, a view gives the same document for two vaults that differ only in the marks.

The document has kind view and an operation of fingerprint, edges, layered, trace, evidence, review, recurrence or attribution. This is an excerpt of scat_tools.edge_table("holds").to_dict(); the full documents are in the CLI reference and the machine interface contract:

{
  "schema_version": 3,
  "kind": "view",
  "operation": "edges",
  "ok": true,
  "mode": "disallowed",
  "edge_type": "holds",
  "from_layer": "stakeholder",
  "to_layer": "concern",
  "rows": [
    {
      "type": "holds",
      "from": "facilitator-analysts",
      "to": "anonymity",
      "narratives": ["notes-at-a-chatham-house-session"],
      "status": "done"
    }
  ],
  "excluded": []
}

scat_tools.fingerprint

fingerprint(narrative=None, *, candidates=False, claim_type=None, kind=None, root=".")

Shows the fingerprint of a narrative: the nodes it links, the edges its rows tell, and, with candidates=True, its candidates (pairs of nodes that the account links, that an edge type fits, and that no row joins; without the option the view shows none). CLI twin: scat fingerprint.

Parameter Meaning
narrative A narrative name. Without it, every narrative, in path order.
candidates True to add the candidates. Default False. CLI: --candidates.
claim_type, kind A value or a list of values of a mark. Only narratives with one of the values are kept; the view says which filter it applied and lists the narratives it left out (filter, left_out). Without them nothing is filtered, and no mark changes the output. CLI: --claim-type, --kind, repeated for more than one value.
root The vault folder.

It refuses when the name is not a narrative, when two pages share it, and on an error in a page it draws.

scat_tools.fingerprint("groups-under-a-cap-pitch")
fingerprint groups-under-a-cap-pitch (done)
  concern
    anonymity [done]
  affordance
    groups-clustered-under-a-cap [done]
  technology
    cap-setting [done]
  edges
    addressed-by: anonymity -> groups-clustered-under-a-cap [done; told by groups-under-a-cap-pitch, notes-at-a-chatham-house-session]
    provided-by: groups-clustered-under-a-cap -> cap-setting [done; told by groups-under-a-cap-pitch]
uv run scat fingerprint groups-under-a-cap-pitch

The same text.

scat_tools.edge_table

edge_table(type, *, claim_type=None, kind=None, root=".")

Shows every edge of one type, in graph order, with the narratives that tell it and its status. CLI twin: scat edges.

Parameter Meaning
type holds, addressed-by or provided-by.
claim_type, kind A value or a list of values of a mark. Only narratives with one of the values are kept; the view says which filter it applied and lists the narratives it left out (filter, left_out). Without them nothing is filtered, and no mark changes the output. CLI: --claim-type, --kind, repeated for more than one value.
root The vault folder.

It refuses on any other type, and on an error in a page it draws.

scat_tools.edge_table("holds")
edges holds (stakeholder -> concern): 2
    holds: facilitator-analysts -> anonymity [done; told by notes-at-a-chatham-house-session]
    holds: project-leads -> intent-without-drift [done; told by false-start-and-clean-restart]
uv run scat edges holds

The same text.

scat_tools.layered

layered(narratives=None, *, candidates=False, claim_type=None, kind=None, root=".")

Shows the layered view: the union of the fingerprints of the narratives you name, as four layers. Without narratives, every narrative. CLI twin: scat layered, with one --narrative for each name.

Parameter Meaning
narratives A list of narrative names.
candidates True to add the candidates. Default False. CLI: --candidates.
claim_type, kind A value or a list of values of a mark. Only narratives with one of the values are kept; the view says which filter it applied and lists the narratives it left out (filter, left_out). Without them nothing is filtered, and no mark changes the output. CLI: --claim-type, --kind, repeated for more than one value.
root The vault folder.

The result also carries orphans when there are any: each node page that is an end of no edge anywhere in the vault (the whole vault, whichever narratives you name), with its name, type and status. With candidates=True it carries candidates, each {type, from, to, narrative} for the chosen narratives. The text form lists the candidates and the orphans.

It refuses on a name that is not a narrative, on a value that is not a list of names, on a candidates that is not True or False, and on an error in a page it draws.

scat_tools.layered(["groups-under-a-cap-pitch"])
layered view of groups-under-a-cap-pitch
  concern
    anonymity [done]
  affordance
    groups-clustered-under-a-cap [done]
  technology
    cap-setting [done]
  edges
    addressed-by: anonymity -> groups-clustered-under-a-cap [done; told by groups-under-a-cap-pitch, notes-at-a-chatham-house-session]
    provided-by: groups-clustered-under-a-cap -> cap-setting [done; told by groups-under-a-cap-pitch]
uv run scat layered --narrative groups-under-a-cap-pitch

The same text.

scat_tools.trace

trace(node, direction="both", *, claim_type=None, kind=None, root=".")

Follows edges from a node: up toward the stakeholders, down toward the technologies, or both. The node itself is left out. CLI twin: scat trace, with --direction.

Parameter Meaning
node The name of a stakeholder, concern, affordance or technology.
direction up, down or both.
claim_type, kind A value or a list of values of a mark. Only narratives with one of the values are kept; the view says which filter it applied and lists the narratives it left out (filter, left_out). Without them nothing is filtered, and no mark changes the output. CLI: --claim-type, --kind, repeated for more than one value.
root The vault folder.

It refuses when the name is not a node, when the direction is not one of the three, and on an error in a page it draws.

scat_tools.trace("anonymity", "up")
trace anonymity (up)
 up
  stakeholder
    facilitator-analysts [done]
  edges
    holds: facilitator-analysts -> anonymity [done; told by notes-at-a-chatham-house-session]
uv run scat trace anonymity --direction up

The same text.

A refusal prints what to do next, and nothing is written:

scat_tools.trace("anonymity", "sideways")
refused sideways: this is not a direction
  Fix: use one of: up, down, both

scat_tools.evidence

evidence(node, *, claim_type=None, kind=None, root=".")

Returns everything the vault says of one node page: the narratives that link it, each with the whole paragraph around every link and the sentence that holds the link marked (start and end are offsets in the paragraph); the narratives that link it and tell no edge for it, flagged (tells_edge is False); its edges, each with the narratives that tell it and the row's note; and its adjacent nodes by layer. CLI twin: scat evidence.

Parameter Meaning
node The name of a stakeholder, concern, affordance or technology.
claim_type, kind A value or a list of values of a mark. Only narratives with one of the values are kept; the view says which filter it applied and lists the narratives it left out (filter, left_out). Without them nothing is filtered, and no mark changes the output. CLI: --claim-type, --kind, repeated for more than one value.
root The vault folder.

str(view) begins with the vault's attribution mode and puts the marked sentence between >> and <<. A link inside the Edges told table is not a paragraph: it shows through the edges. The view reads no attributed_to field and lists no contributor page. It refuses when the name is not a node page (a narrative, a contributor page, or no page), when two pages carry the name, and on an error in a page it draws.

scat_tools.evidence("anonymity")
attribution mode: disallowed
evidence anonymity (concern, done): 2 narratives, 2 edges
  narratives (the sentence with the link is between >> and <<)
    groups-under-a-cap-pitch [done]
      line 12
        - [[groups-clustered-under-a-cap|The vault holds stakeholders]], and [[cap-setting|an instance setting]] caps their number.
        - The cap is set for each vault, in the vault's own configuration. The example vault sets it to 6.
        - A group is named by its role. No group stands for one identifiable person.
        - >>Reason given: the people in the data are stakeholders under the Chatham House rule, so [[anonymity|no individual is identifiable]].<<
    notes-at-a-chatham-house-session [done]
      line 12
        - [[workshop-participants|Workshop participants]] tell stories in conversations. The work is sized for manual note-taking in Obsidian.
        - [[facilitator-analysts|Facilitators]] take the field notes. >>The setting is Chatham House rule: the people in the data are stakeholders, so [[anonymity|no individual is identifiable]].<<
        - The vault holds stakeholders, and [[groups-clustered-under-a-cap|an instance setting caps their number]].
        - This vault runs in the disallowed attribution mode: the notes name stakeholders, never individuals, and no note links to a person. A project that needs names chooses another mode when it sets up.
        - >>[[attribution|Attribution]] and [[anonymity]] conflict as concerns, and the vault records that as a remark on one of them.<<
  edges
    holds: facilitator-analysts -> anonymity [done; told by notes-at-a-chatham-house-session]
        notes-at-a-chatham-house-session: They take the field notes under the Chatham House rule, so no individual is identifiable.
    addressed-by: anonymity -> groups-clustered-under-a-cap [done; told by groups-under-a-cap-pitch, notes-at-a-chatham-house-session]
        groups-under-a-cap-pitch: Participants appear only as stakeholders, so no stakeholder stands for one identifiable person.
        notes-at-a-chatham-house-session: The mission says the people in the data are stakeholders under the Chatham House rule, so no individual is identifiable.
  adjacent nodes
    stakeholder
      facilitator-analysts [done]
    affordance
      groups-clustered-under-a-cap [done]
excluded (no node page linked; link one node page to include it)
    desk-notes-one (narrative/desk-notes-one.md)
    desk-notes-two (narrative/desk-notes-two.md)
uv run scat evidence anonymity

The same text.

view.to_dict() is the document, the one scat evidence anonymity --json prints; see the CLI reference for all of it. A refusal prints what to do next, and nothing is written:

scat_tools.evidence("nobody")
refused nobody: no node has this name
  Fix: give the name of a page (the file name without `.md`) that is a stakeholder, concern, affordance or technology

scat_tools.review

review(*, root=".")

Returns the pairs of node pages of one type to read from, never findings. pairs holds every pair that shares a twin row (one narrative tells the same edge type between each of the pages and one other node) or an adjacent node (a node one edge away from both). There is no cut-off and no score: the pairs that share most adjacent nodes come first, and each pair shows its count (shared), its twin_rows, its shared_adjacent nodes and the link_texts coders gave each page. Names and descriptions are never compared.

Parameter Meaning
root The vault folder.

A narrative that links no node page is excluded: it is listed under excluded and not used. str(view) begins with the vault's attribution mode. The view reads no attributed_to field and lists no contributor page. It refuses where the other views do.

scat_tools.review()
attribution mode: disallowed
review: 1 page pair, each sharing a twin row or an adjacent node
    gated-approval ~ revert-with-history-kept (affordance; done, done): 1 shared adjacent node, 2 twin rows
        twin row: false-start-and-clean-restart (narrative/false-start-and-clean-restart.md lines 29 and 30) tells addressed-by with intent-without-drift
        twin row: two-branches-and-tags-pitch (narrative/two-branches-and-tags-pitch.md lines 22 and 23) tells addressed-by with intent-without-drift
        shared adjacent nodes: intent-without-drift
        link texts for gated-approval: "Approval is a merge into main", "a gated mission"
        link texts for revert-with-history-kept: "dev is reverted to the approved state. History is kept", "reverting without losing history"
uv run scat review

The same text.

view.to_dict() is the document, the one scat review --json prints; see the CLI reference for all of it.

scat_tools.recurrence

recurrence(*, claim_type=None, kind=None, root=".")

Returns how often each node and edge recurs. For every node page, narrative_count is the number of narratives that have a row ending at it and stakeholder_count the number of stakeholders that reach it by the layered edges (a stakeholder reaches itself); for every edge, the number of narratives that tell it and of stakeholders that reach its first end. A count of zero or one is a singleton, marked by narrative_singleton and stakeholder_singleton and by (singleton) in the text.

Parameter Meaning
claim_type, kind A value or a list of values of a mark. Only narratives with one of the values are kept; the view says which filter it applied and lists the narratives it left out (filter, left_out). Without them nothing is filtered, and no mark changes the output. CLI: --claim-type, --kind, repeated for more than one value.
root The vault folder.

A narrative that links no node page is excluded: it is listed under excluded and not used. The view reads no attributed_to field and lists no contributor page. The notebook in the vault template calls it.

scat_tools.recurrence()
recurrence: narratives and stakeholders that reach each node and edge
  stakeholder
    facilitator-analysts [done]: narratives 1 (singleton), stakeholders 1 (singleton)
    project-leads [done]: narratives 1 (singleton), stakeholders 1 (singleton)
    workshop-participants [done]: narratives 0 (singleton), stakeholders 1 (singleton)
  concern
    anonymity [done]: narratives 2, stakeholders 1 (singleton)
    attribution [done]: narratives 0 (singleton), stakeholders 0 (singleton)
    intent-without-drift [done]: narratives 2, stakeholders 1 (singleton)
  affordance
    gated-approval [done]: narratives 2, stakeholders 1 (singleton)
    groups-clustered-under-a-cap [done]: narratives 2, stakeholders 1 (singleton)
    revert-with-history-kept [done]: narratives 2, stakeholders 1 (singleton)
  technology
    archive-tags [done]: narratives 1 (singleton), stakeholders 1 (singleton)
    cap-setting [done]: narratives 1 (singleton), stakeholders 1 (singleton)
    main-and-dev-branches [done]: narratives 1 (singleton), stakeholders 1 (singleton)
  edges
    holds: facilitator-analysts -> anonymity [done]: narratives 1 (singleton), stakeholders 1 (singleton)
    holds: project-leads -> intent-without-drift [done]: narratives 1 (singleton), stakeholders 1 (singleton)
    addressed-by: anonymity -> groups-clustered-under-a-cap [done]: narratives 2, stakeholders 1 (singleton)
    addressed-by: intent-without-drift -> gated-approval [done]: narratives 2, stakeholders 1 (singleton)
    addressed-by: intent-without-drift -> revert-with-history-kept [done]: narratives 2, stakeholders 1 (singleton)
    provided-by: gated-approval -> main-and-dev-branches [done]: narratives 1 (singleton), stakeholders 1 (singleton)
    provided-by: groups-clustered-under-a-cap -> cap-setting [done]: narratives 1 (singleton), stakeholders 1 (singleton)
    provided-by: revert-with-history-kept -> archive-tags [done]: narratives 1 (singleton), stakeholders 1 (singleton)
uv run scat recurrence

The same text.

view.to_dict() is the document, the one scat recurrence --json prints; see the CLI reference.

scat_tools.attribution

attribution(*, root=".")

Shows each contributor page with the narratives whose attributed_to field names it, then the narratives that name none. A contributor page is in the knowledge graph but in no layered view, so no other view shows one. CLI twin: scat attribution.

Parameter Meaning
root The vault folder.

It refuses in a vault whose attribution mode is disallowed, where no narrative names a contributor and there is no contributor page to list. It refuses too on an error in a page it draws. The template's mode is disallowed, so on a fresh copy it refuses:

scat_tools.attribution()
refused scat.toml field `attribution`: this vault's attribution mode is `disallowed`, so it allows no attribution: no narrative names a contributor and there is no contributor page to list
  Fix: the coder who wants contributors named changes `attribution` in scat.toml for the whole vault
$ uv run scat attribution
refused scat.toml field `attribution`: this vault's attribution mode is `disallowed`, so it allows no attribution: no narrative names a contributor and there is no contributor page to list
  Fix: the coder who wants contributors named changes `attribution` in scat.toml for the whole vault

The command exits with 1, as every refusal does.

Take a copy of the template with attribution = "optional" in scat.toml, and the coding guide's saturday-at-the-tool-library narrative with attributed_to: ["[[ada-quill]]"], and ada-quill made with scat stub ada-quill --type contributor. The view prints, with the template's four narratives naming no one:

attribution: narratives by contributor
  ada-quill [stub]
    saturday-at-the-tool-library
  narratives that name no contributor
    false-start-and-clean-restart
    groups-under-a-cap-pitch
    notes-at-a-chatham-house-session
    two-branches-and-tags-pitch

scat_tools.export_edges

export_edges(out, *, root=".")

Writes each edge table to <out>/<type>.csv and <out>/<type>.md, and returns a Result. out is required. CLI twin: scat export-edges --out.

Parameter Meaning
out The folder to write in; made if it is not there.
root The vault folder.

The CSV has the columns from, to, narratives (joined by ;) and status. A file that is there is rewritten only when its content differs, so a second call prints unchanged. It refuses where edge_table would, and when out is a file; it then writes nothing.

scat_tools.export_edges("tables")
created tables/holds.csv
created tables/holds.md
created tables/addressed-by.csv
created tables/addressed-by.md
created tables/provided-by.csv
created tables/provided-by.md
uv run scat export-edges --out edge-tables

The same lines, with edge-tables/ in place of tables/.

scat_tools.guide

guide(stage=None)

Returns the guide of one stage of the project's lifecycle ("plan", "capture", "code", "synthesise", "analyse" or "report"). With no stage, or "index", it returns the index: the six stages and the moves between them. It needs no vault and has no root. A stage is where the project is; it is not a page's status. CLI twin: scat guide.

Parameter Meaning
stage The stage's name, or "index". Without it, the index.

str(result) is the text scat guide prints, and the result prints as that text. Besides ok (always True for a stage or the index), it holds stage, text, docs (the stage's docs page, or None for the index), tools (the stage's tools) and exits (the ids of its moves). A name that is not a stage returns a Result that is a refusal naming the six stages, with ok set to False.

scat_tools.guide("analyse")
scat_tools.guide("analyse").tools
scat_tools.guide("ideation").ok

The first line prints the guide. The other two give the stage's tools, and False for a name that is not a stage.

uv run scat guide analyse

The command prints the guide.

Drawings

A drawing shows a view as columns, one for each layer, in layer order, with the edges as lines between them. The columns are labelled stakeholder, concern, affordance and technology; the first holds the nodes of the stakeholder layer. SVG and PNG are the same drawing in two formats. It needs the extra draw: pip install "scat-tools[draw]". Without it, the call returns a refusal that says so. In the vault template it is already installed. Import the module with from scat_tools import draw. Where a view refuses, the drawing refuses with the same refusal.

A view's query returns a result: its document is the table of nodes and edges. A drawing and a table are two renderings of one result, and drawing never runs the query again. draw.render draws a result you already hold; draw.fingerprint, draw.layered and draw.trace run the query once and render it. To have the picture and the table from one query, run the view once and pass its result to draw.render. A drawing's .nodes() and .edges() always equal the table of the result it was drawn from, except that a trace's drawing includes the starting node, which the trace's table names (node) but lists in neither up nor down.

scat_tools.draw.render

draw.render(result, *, mark_narratives=False)

Draws a query result you already hold, without running any query: a fingerprint of one narrative, a layered view or a trace, as returned by scat_tools.fingerprint, scat_tools.layered or scat_tools.trace. With mark_narratives=True each edge of a layered view is marked by the narrative that tells it, as in draw.layered; it has no effect on a fingerprint or a trace. Returns a Drawing. A refusal passed in comes back unchanged. Any other result (an edge table, for example), or a fingerprint of more than one narrative, is refused with what to pass instead.

scat_tools.draw.fingerprint

draw.fingerprint(narrative, *, candidates=False, claim_type=None, kind=None, root=".")

Draws a narrative's fingerprint, in all four columns whatever the narrative's marks. With candidates=True its candidates are added as dashed lines. Returns a Drawing. narrative is required: one name. candidates is False unless you pass True (CLI: --candidates). CLI twin: scat draw fingerprint.

scat_tools.draw.layered

draw.layered(narratives=None, *, candidates=False, mark_narratives=False, claim_type=None, kind=None, root=".")

Draws the layered view of the named narratives, or of every narrative. It keeps all four columns, because it mixes narratives. With candidates=True the candidates are added as dashed lines. The footer also names the node pages no row tells, at most ten, then "and N more". Parts of the graph that share no node are drawn as separate bands, and nodes are ordered within each column to cut crossing lines. With mark_narratives=True each solid edge is drawn in the mark (colour and line style) of the narrative that tells it, black and thicker where more than one tells it, with a key under the figure; candidates stay grey and dashed. mark_narratives is False unless you pass True; the CLI and the server do not offer it. Returns a Drawing. candidates is False unless you pass True (CLI: --candidates). CLI twin: scat draw layered.

scat_tools.draw.trace

draw.trace(node, direction="both", *, claim_type=None, kind=None, root=".")

Draws what scat_tools.trace follows from a node: up toward the stakeholders, down toward the technologies, or both. The node itself is drawn too, in its own layer's column, and the title names it, its type and the direction (trace of concern water, up and down). It keeps all four columns. Returns a Drawing. node is required: the name of a stakeholder, concern, affordance or technology. direction is up, down or both (the default; CLI: --direction). CLI twin: scat draw trace.

Drawing

Member What it does
.png() The image, as bytes.
.svg() The image, as text.
.nodes() The nodes drawn, as (name, layer) pairs: column by column, each from the top down as drawn, bands included.
.edges() The edges drawn, as (from, to, dashed), the lines whose two ends are both drawn.
.save(path) Writes the image to path and returns a Result. It is the only call here that writes a drawing.

In Jupyter, a drawing shows itself. .save makes the folder if needed, rewrites a file only when its content differs, and refuses a name that does not end in .png or .svg, or that is a folder. The same view gives the same bytes.

from scat_tools import draw

draw.layered(["groups-under-a-cap-pitch"]).save("layered.png")
draw.fingerprint("groups-under-a-cap-pitch").save("fingerprint.svg")
draw.layered().save("layered.gif")
created layered.png
created fingerprint.svg
refused layered.gif: `.gif` is not an image type this draws
  Fix: end the file name with .png or .svg, for example `layered.png`
uv run scat draw layered --narrative groups-under-a-cap-pitch --out drawn.png
created drawn.png

Results

Each call returns one of these kinds of result. All print as their message.

Kind Returned by Holds
CheckResult check, when it ran problems, errors, warnings (tuples of problems), ok. A problem has rule, severity ("error" or "warning"), file, where, what, fix and line.
StatusReport status, when it ran scope ("page", "neighborhood" or "vault"), rows (each with path, name, type, status), counts (pages per status; other is a missing or invalid status), ok.
Result stub, stub_links, set_status, index, link_page, and any refusal created, changed, unchanged, notes (tuples of text), refused (each with subject, why, fix), ok.
EdgeResult record_edge, remove_edge everything a Result holds, and edge, rows_added, rows_removed.
Guide guide stage, text, docs, tools, exits, ok (always True).
MergeResult, RenameResult, WhereUsed merge, rename, where_used, when they ran everything a Result holds, and plan, removed, done_narratives, links_rewritten (merge); plan, moved, done_narratives, links_rewritten (rename); node, node_type, pages (where used).

The views return a View (see Views) and the drawings a Drawing (see Drawings).

A Result prints its lines in this order: created, changed, unchanged, refused, then note: lines. When it holds nothing, it prints <operation>: nothing to do.

result = scat_tools.check("anonymity", neighborhood=True)
result.ok
len(result.warnings)
result.problems
scat_tools.status("anonymity").counts
True
0
()
{'stub': 0, 'draft': 0, 'done': 1, 'other': 0}
uv run scat check anonymity --neighborhood

The command prints the message that str(result) holds. Its exit code is result.ok as 0 or 1: here 0, because there are no errors.

Where next

Keep the reference close: