Skip to content

Instantly share code, notes, and snippets.

The saga of Graphwright

This work began as an exploration of Graph RAG for medical literature. It quickly became clear that the needs of researchers and clinicians marked this as a "high stakes" area of reasoning and retrieval, and that this would be an important consideration in every decision in the design of a suitable system. Specifically three principles emerged as significant requirements.

  1. The knowledge graph should use types and type-checking tools as a guard against meaningless contents. These aid in the ingestion of source documents, offering guidance in parsing ambiguous input.
  2. The medical field has accumulated a number of authoritative ontologies for diseases, drugs,
@wware
wware / Guardrails.md
Last active July 9, 2026 15:17
Guardrails for AI-generated code

Guardrails for AI-generated code

This is a topic that any post-2022 software engineer has to take seriously. So here is my take on things. First let's review what the dangers are that we are trying to avoid here.

  1. LLMs hallucinate, and frequently have a shallow (yet very confidently stated) understanding of the problem domain.
  2. LLMs become easily confused when navigating complex structures, such as deeply nested JSON structures.
  3. LLM-generated code is produced quickly and in large volume, and it becomes a coma-inducing wall of text. We need a way to stay in control, make sure it's doing what it's supposed to do, while allowing the LLM to play to its strengths.
@wware
wware / graph_lp_lang.md
Last active July 8, 2026 20:38
A literate-programming-friendly language for typed graphs

Datalog-with-types language (working name TBD)

Core motivation. Datalog with strict typing gets you ~90% of what the Graphwright typed-graph formalism (T, Φ, V, τ) already wants, and gives you a second, declarative language to embed in literate-programming markdown blocks — one where the code reads as the prose rather than fighting it.

Syntax sketch so far:

Type declarations, Haskell/OCaml-flavored, with an extends addition for hierarchy (not present in vanilla Haskell ADTs, needed because your $T_{ent}$ has real subtyping structure):

data Agent = Agent { name: String }

Multi-stage Docker images

Multi-stage builds work by separating build-time tools from runtime needs. You define multiple stages with separate FROM statements, build your application in early stages with all necessary compilers and dependencies, then copy only the final artifacts into a minimal runtime image. This eliminates the bulk of build tools from your final container.

Key principles:

  • Separate concerns: Early stages handle compilation, testing, and build processes. The final stage includes only what's needed to run the app.
  • Use COPY --from: Pull artifacts from earlier stages or external images into your final stage.
  • Pick lean base images for runtime: Use distroless images, Alpine, or scratch for the final stage to minimize size.
  • Language-specific patterns: Compiled languages (Go, Rust, C) benefit most—copy the binary alone. Interpreted languages (Python, Node, Ruby) can minify code in one stage and copy production files to another.

GQLib: Graph Traversal and Analysis Query Library

kgraph_api is a single typed Python library over GraphDbInterface. It exposes two tiers of operation against a typed graph:

  • Traversal — the four primitives an agent uses to orient itself and explore: describe_schema, search_instances, bfs_query, describe_instance.
  • Analysis — higher-level primitives that compute an answer instead of handing back a subgraph to be reasoned over: paths, intersection, ranking, comparison, conflict detection, clustering, summarization.
@wware
wware / llm_repl.md
Created June 6, 2026 20:45
Steps to write a little REPL loop for the Ollama server on my local network

To create an LLM-REPL (Read-Eval-Print Loop) in Python that can interact with your Ollama host on the local network and potentially access MCP servers, you'll need to follow a few steps. Here's a general guide to help you get started:

Step 1: Understand Your Environment

Before diving into coding, ensure you understand how your Ollama host works and what kind of communication protocols it uses (e.g., REST API, gRPC, etc.). You might also want to check if there are any official SDKs or libraries provided by the service.

Step 2: Set Up Your Python Environment

Make sure you have Python installed on your system. It's a good idea to use a virtual environment for your project:

Principles of Reliable Reasoning: Formal Definition

This defines the formal model precisely, establishes vocabulary, states hard rules, and lists explicit non-goals. When in doubt, check against this file before generating code, prose, or schema definitions.

The notation itself isn't the point — the benefits come from what the process of formalizing forces, and those benefits survive translation into plain prose.

It settles ambiguity permanently. Natural language descriptions of data structures

Docker Syslog Demo

A minimal two-container Docker Compose setup that demonstrates how to ship container logs over syslog to a custom log collector.

What it does

  • collector container — runs a small Python script (collector.py) that listens on UDP port 5514 and prints every syslog message it receives, timestamped, to stdout.
  • app container — an Alpine shell loop that emits hello from app every 2 seconds. Its Docker logging driver is configured to send output via syslog (UDP) to the collector instead of the normal Docker log buffer.

The result: app's stdout ends up in collector's stdout, routed through the syslog protocol, rather than being captured by Docker directly.