Skip to content

Instantly share code, notes, and snippets.

@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.

Poor man's literate programming

proc.py [--title TITLE] [--html] FILE [FILE ...]

proc.py turns Python source files into readable, navigable documentation. Input files can be a mix of Markdown and Python, processed in the order given.

When processing a Python file:

@wware
wware / 1_Formal_Definition.md
Last active June 3, 2026 17:51
Defining the typed graph in mathematical terms, and a schema for Sherlock Holmes stories

The Typed Graph: a 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