A semantic calculator for executing a canonical, multi-stage pipeline for structured problem-solving and knowledge generation.
Project description
Chirality Framework: A Semantic Calculator
Version: 16.3.0 | Status: Active Development
The Chirality Framework is a "semantic calculator" designed to execute a fixed, canonical algorithm for structured problem-solving. It transforms a set of base matrices through a multi-stage semantic pipeline, producing a series of derived matrices that represent a complete traversal of a "semantic valley" from problem to evaluation.
The value of this project is in the unique, insightful output of the calculation and the observability of the process, not in the flexibility of the code.
Core Concept: The Canonical Pipeline
The framework computes a sequence of matrices, each representing a station in the semantic valley. The primary operations involve:
- Semantic Dot Product: A two-stage LLM process involving: a. Semantic Resolution: Raw terms are resolved into a concise conceptual summary. b. Combined Ontological Lensing: The conceptual summary is interpreted through a unified lens of the cell's row, column, and station context in a single, powerful LLM call.
- Station Shifting: An LLM-driven transformation of a matrix from one context (e.g., Verification) to another (e.g., Validation), also performed using the Combined Lensing pipeline.
- Structural Operations: Standard matrix operations like transposing and slicing, which do not involve an LLM.
For a complete technical description, see the Canonical Algorithm Documentation.
The Ontological Modality Path
The sequence of stations in the semantic valley is not arbitrary; it follows a deep, underlying pattern of cognitive modalities. This path describes the type of work being done at each stage, revealing a structured cycle of systematic processing, epistemic (knowledge-based) evaluation, and alethic (truth-based) assessment.
| Modality | Station | Operation |
|---|---|---|
Problem |
1. Problem Statement | [A], [B] |
Systematic |
2. Requirements | [C] = [A] * [B] |
Process |
3. Objectives | [D] = [A] + [F] |
Epistemic |
4. Verification | [K] = [D]^T, [X] = [K] * [J] |
Epistemic |
5. Validation | [Z] = shift([X]) |
Process |
6. Evaluation | [G], [P], [T], [E] |
Alethic |
7. Assessment | [M] = [R] x [E] |
Epistemic |
8. Implementation | [W] = [M] x [X] |
Alethic |
9. Integration | [U] = [W] x [P] |
Alethic |
10. Reflection | [N] = [U] x [H] |
Resolution |
11. Resolution | Final = synth([N]) |
Clarifications:
- X/Z Modality: Both Verification (S4) and Validation (S5) are
Epistemic. S4 strictly precedes S5. - E Modality: Evaluation (S6) is a
Processmodality, not Epistemic.
For a detailed explanation of this conceptual architecture, see the Project Philosophy Documentation.
Quick Start: The End-to-End Workflow
The recommended way to use the framework is to compute the entire pipeline and view the results in the generated HTML viewer.
Prerequisites
- Python 3.9+
- An OpenAI API key set as the
OPENAI_API_KEYenvironment variable.
Step 1: Compute the Full Pipeline
This command runs the entire semantic pipeline (Matrices C through E), generates snapshots of every matrix (including the base matrices A, B, and J), and creates detailed trace files for debugging.
# Install with OpenAI support
pip install 'chirality-framework[openai]'
# Set your API key (add to your shell profile for persistence)
export OPENAI_API_KEY="sk-..."
# Run the full pipeline with the OpenAI resolver
python3 -m chirality.cli compute-pipeline --resolver openai --snapshot-jsonl --include-base
This will create two directories, snapshots/<run_id>/ and traces/<run_id>/, containing the output files.
Step 2: Render and View the Results
This command reads the generated snapshots and creates a self-contained HTML file to display all the matrices in an elegant, readable format.
# Render the latest run and open it in your browser
python3 -m chirality.cli render-viewer --latest --open
This will create a viewer-output/ directory containing the index.html and style.css files and automatically open the page for you. You can change the output location with --output-dir.
Advanced Usage
App Integration Mode (Producer Contract)
For automation by external apps (e.g., chirality-app), use app mode to write a manifest and contract snapshots with a single JSON result to stdout.
python3 -m chirality.cli compute-pipeline \
--resolver echo \
--out runs/my-run-1 \
--problem-file problem.json \
--max-seconds 900
- Writes per-cell JSONL snapshots for
C,D,X,Eunderruns/<run_id>/snapshots/with formatcells-jsonl-v1. - Writes
runs/<run_id>/index.jsonlast and atomically with checksums, sizes, and record counts. - Prints exactly one JSON line to stdout on success:
{ "run_id": "...", "manifest": "runs/<run_id>/index.json" }. - Exit codes:
0success;2invalid args;3timeout;4I/O;5resolver;1general. - Backward compatibility: also dual-writes legacy snapshots for all computed matrices to
snapshots/<run_id>/for the built-in viewer.
App Mode (Chirality App Integration)
-
Generate a run:
python3 -m chirality.cli compute-pipeline --resolver <echo|openai> --out runs/<run_id> --problem-file problem.json --max-seconds 900 -
Output:
runs/<run_id>/index.jsonruns/<run_id>/snapshots/{C,D,X,E}.jsonl
-
Stdout (last line):
{"run_id":"<run_id>","manifest":"runs/<run_id>/index.json"} -
Contract:
- Manifest
framework_schema_version = "1.0.0" - Each matrix entry includes
path,format:"cells-jsonl-v1",records,sha256,bytes - JSONL rows include
id, matrix, row, col, row_label, col_label, station, text, citations, refs, meta.order
- Manifest
Using Framework Artifacts (chirality-app)
- Set
CHIRALITY_RUNS_DIR=/absolute/path/to/chirality-framework/runsin chirality-app.env.local - Ingest:
POST /api/agent/runwith body{"framework_run_id":"<run_id>"}(optionally include"enable_rag": true) - Export:
GET /api/agent/export/<run_id>with headerX-Role: approver
Computing Individual Matrices
The compute-matrix command allows you to compute and snapshot any single matrix, automatically handling its prerequisites.
# Compute just the final Evaluation matrix (E)
python3 -m chirality.cli compute-matrix E --resolver openai --snapshot-jsonl
# Snapshot a base matrix for reference
python3 -m chirality.cli compute-matrix A --snapshot-jsonl
Inspecting a Single Cell
For detailed debugging, the compute-cell command lets you observe the new canonical pipeline for any single cell in a matrix.
# Observe the computation of cell C[0,0] with verbose output
python3 -m chirality.cli compute-cell C --i 0 --j 0 --resolver openai --verbose --trace
Viewing Options
The render-viewer command has several options for customizing the output:
# Render a specific run with a custom title
python3 -m chirality.cli render-viewer --run-id "<run_id>" --title "My Analysis"
# Render with the "Elements" style for a more code-like view
python3 -m chirality.cli render-viewer --latest --style elements
# Disable the default value sanitization to see raw output
python3 -m chirality.cli render-viewer --latest --style elements --no-sanitize-values
Common CLI Commands
- Compute full pipeline (dev):
python3 -m chirality.cli compute-pipeline --resolver echo --snapshot-jsonl --include-base -v - App-mode run (artifacts):
python3 -m chirality.cli compute-pipeline --resolver echo --out runs/my-run-1 --problem-file problem.json --max-seconds 900 - Render latest viewer:
python3 -m chirality.cli render-viewer --latest --open - Inspect a cell:
python3 -m chirality.cli compute-cell C --i 0 --j 0 -v
See full CLI Quick Reference in docs/API_REFERENCE.md#cli-reference.
Development
To set up the development environment and run tests, please refer to the instructions in CONTRIBUTING.md.
Additional docs:
docs/INTERFACE.md: Producer mirror of the chirality-app contract (app mode).GEMINI.md: Guidance for using Gemini/AI assistants with this repo.CLAUDE.md: Guidance for using Claude Code with this repo.AGENTS.md: Notes for agentic coding assistants working on this project.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file chirality_framework-17.0.0.tar.gz.
File metadata
- Download URL: chirality_framework-17.0.0.tar.gz
- Upload date:
- Size: 78.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d13b84b63b6ab844b8a3f53d546ef99081b348ee151b50e5e00f4b72fea083d1
|
|
| MD5 |
964e329a2246633c28ca251f2f03e381
|
|
| BLAKE2b-256 |
31acc0a48e95837839a40c7012608cdfa4052740c75ebd6ab4a62ebb1c64e94e
|
Provenance
The following attestation bundles were made for chirality_framework-17.0.0.tar.gz:
Publisher:
python-publish.yml on sgttomas/chirality-framework
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
chirality_framework-17.0.0.tar.gz -
Subject digest:
d13b84b63b6ab844b8a3f53d546ef99081b348ee151b50e5e00f4b72fea083d1 - Sigstore transparency entry: 477813927
- Sigstore integration time:
-
Permalink:
sgttomas/chirality-framework@318f86316c2536a2970ac4cb3ce2af5fb6784bd6 -
Branch / Tag:
refs/tags/v17.0.0 - Owner: https://github.com/sgttomas
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@318f86316c2536a2970ac4cb3ce2af5fb6784bd6 -
Trigger Event:
release
-
Statement type:
File details
Details for the file chirality_framework-17.0.0-py3-none-any.whl.
File metadata
- Download URL: chirality_framework-17.0.0-py3-none-any.whl
- Upload date:
- Size: 78.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
df6ff95cf688789835d8d540ae36c2a1a5aade36978571abaf8ba9baac772982
|
|
| MD5 |
0201199f3f41010c0aa8b9778097ccb0
|
|
| BLAKE2b-256 |
6a46374b0b2e218fcf115e02fb41fa84c425bfce3c76d6b6c626c846b6569f3f
|
Provenance
The following attestation bundles were made for chirality_framework-17.0.0-py3-none-any.whl:
Publisher:
python-publish.yml on sgttomas/chirality-framework
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
chirality_framework-17.0.0-py3-none-any.whl -
Subject digest:
df6ff95cf688789835d8d540ae36c2a1a5aade36978571abaf8ba9baac772982 - Sigstore transparency entry: 477813940
- Sigstore integration time:
-
Permalink:
sgttomas/chirality-framework@318f86316c2536a2970ac4cb3ce2af5fb6784bd6 -
Branch / Tag:
refs/tags/v17.0.0 - Owner: https://github.com/sgttomas
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@318f86316c2536a2970ac4cb3ce2af5fb6784bd6 -
Trigger Event:
release
-
Statement type: