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: 19.3.0 | Status: DDD-Compliant Architecture
The Chirality Framework is a meta-ontological, system-agnostic methodology for mapping the solution space to a problem statement in the context of knowledge work. It creates structured semantic relationships that serve as "semantic anchors" to guide LLMs through problem-solving stages across a "semantic valley."
The framework employs two distinct phases with fundamentally different prompting strategies:
- Phase 1 (Matrices A-E): Uses conversational prompting to build semantic understanding
- Phase 2 (Tensors M-N): Uses Phase 1 implementation as system prompt for modular cell-by-cell construction
Core Architecture: Two‑Phase Semantic Computation
Phase 1: Conversational Semantic Pipeline (Matrices A-E)
Phase 1 uses a conversational dialogue history as the system prompt to create semantic understanding. The dialogue builds the concept of semantic multiplication through examples, develops key concepts organically, and establishes modal ontologies through iterative refinement. This creates a "semantic state" in the LLM that enables proper interpretation.
Semantic‑first transcript with out‑of‑band normalization:
- Stage A — Mechanical/Interpreted (Markdown): Prompts produce human‑readable, markdown‑formatted matrices; the transcript stays clean and creative.
- Stage B — Normalization (Strict JSON): A reusable normalizer prompt converts Stage‑A text into schema‑accurate JSON. Local validation + one diff‑driven retry ensures strict compliance. A small deterministic parser skips the LLM when markdown tables match canonical shapes.
Phase 2: Modular Tensor Construction (Tensors M-N)
Phase 2 uses the complete Phase 1 implementation (through Matrix E) as the system prompt, then constructs tensors cell-by-cell WITHOUT rolling context. The modular design of the tensors facilitates this approach, with each cell computed independently using semantic cross products to create hierarchical structures.
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] = [G] · [T] |
Alethic |
7. Assessment | [M] = [R] × [E] |
Epistemic |
8. Implementation | [W] = [M] × [X] |
Alethic |
9. Reflection | [U] = [W] × [P] |
Alethic |
10. Resolution | [N] = [U] × [H] |
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 recommended way to use the framework is to compute the entire Phase 1 pipeline and view the results.
Prerequisites
- Python 3.9+
- An OpenAI API key set as the
OPENAI_API_KEYenvironment variable in a.envfile in the project root.
Step 1: Install and Set Up
# Install with all dependencies
pip install -e ".[dev,openai]"
# Ensure the lens catalog is generated (only needs to be done once)
python3 -m chirality.interfaces.cli lenses ensure
Step 2: Run Phase‑1 (semantic‑first) and extract structured JSON
Recommended end‑to‑end (semantic transcript + strict JSON):
# Use a stronger model if desired
export CHIRALITY_MODEL=gpt-5
export CHIRALITY_TEMPERATURE=1.0
# Run Phase‑1 in relaxed (markdown) mode and extract strict JSON
python -m chirality.interfaces.cli \
phase1-dialogue-run \
--lens-mode auto \
--relaxed-json \
--extract-structured \
--reasoning-effort low \
--out runs/latest_run
# Artifacts
# - runs/latest_run/phase1_dialogue.jsonl (clean transcript)
# - runs/latest_run/phase1_relaxed_output.json (Stage‑A content)
# - runs/latest_run/phase1_structured.json (JSON + validation report)
# - runs/latest_run/phase1_structured_matrices.json (matrices‑only for DB ingest)
Stage‑A only through Matrix C (quick test):
python -m chirality.interfaces.cli \
phase1-dialogue-run \
--lens-mode auto \
--relaxed-json \
--stop-at C_interpreted \
--extract-structured \
--out runs/c_stageA
Run extraction later (CI/CD):
python -m chirality.interfaces.cli \
phase1-extract \
--from runs/latest_run/phase1_relaxed_output.json \
--out runs/latest_run/phase1_structured.json \
--matrices-only # optional: write only matrices
Print matrices (quick view):
python - <<'PY'
import json, pathlib
p = pathlib.Path('runs/latest_run/phase1_structured_matrices.json')
data = json.loads(p.read_text())
for m in ['C','F','D','K','X','Z','G','T','E']:
if m in data['matrices']:
print(f'== Matrix {m} ==')
for k,v in data['matrices'][m].items():
if isinstance(v, dict) and 'elements' in v:
print(f'[{k}]')
for row in v['elements']:
print(' | '.join(map(str,row)))
print()
PY
Development
To set up the development environment and run tests, please refer to the instructions in CONTRIBUTING.md.
Key Development Notes:
- DDD Architecture: Clean separation of domain/application/infrastructure/interfaces layers
- Prompt Assets: Located in
chirality/infrastructure/prompts/assets/following DDD principles - Single CLI Entry Point: Use
chiralitycommand (viachirality.interfaces.cli:main) - Output Channels: Logs go to stderr, data goes to stdout (for CI/CD integration)
- Guard Scripts: Run before commits to prevent legacy code drift
- Structured outputs & transport: Adapter uses typed input parts; Stage‑B enforces JSON via
json_objectand validates locally (plus one retry). For reasoning models (e.g., GPT‑5), unsupported sampling params (liketop_p) are omitted automatically.
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. 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-19.4.0.tar.gz.
File metadata
- Download URL: chirality_framework-19.4.0.tar.gz
- Upload date:
- Size: 221.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f82b1abf281fcedd325a2b6143357bee32013c80265c0688e1e16fd24139cfb2
|
|
| MD5 |
3ef4c4ea1e841b65428e2e081aed901a
|
|
| BLAKE2b-256 |
97c9ab09372ca58ec1720550082669f006b9163b87fd80533657a7d2cdb6b118
|
Provenance
The following attestation bundles were made for chirality_framework-19.4.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-19.4.0.tar.gz -
Subject digest:
f82b1abf281fcedd325a2b6143357bee32013c80265c0688e1e16fd24139cfb2 - Sigstore transparency entry: 497203647
- Sigstore integration time:
-
Permalink:
sgttomas/chirality-framework@c08a65abc952cd91a6307048b71728497e796bb1 -
Branch / Tag:
refs/tags/v19.4.0 - Owner: https://github.com/sgttomas
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@c08a65abc952cd91a6307048b71728497e796bb1 -
Trigger Event:
release
-
Statement type:
File details
Details for the file chirality_framework-19.4.0-py3-none-any.whl.
File metadata
- Download URL: chirality_framework-19.4.0-py3-none-any.whl
- Upload date:
- Size: 160.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 |
6ea1e43b9d2f8a384b4b15b8042b01aadc3a4da4c75a6386a52119be3b341f1a
|
|
| MD5 |
0c137b2431681a1602a8d18d06a0943d
|
|
| BLAKE2b-256 |
535b83e781b56865880beac33085b8fb90b91cb2872311107923a90612043e9c
|
Provenance
The following attestation bundles were made for chirality_framework-19.4.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-19.4.0-py3-none-any.whl -
Subject digest:
6ea1e43b9d2f8a384b4b15b8042b01aadc3a4da4c75a6386a52119be3b341f1a - Sigstore transparency entry: 497203671
- Sigstore integration time:
-
Permalink:
sgttomas/chirality-framework@c08a65abc952cd91a6307048b71728497e796bb1 -
Branch / Tag:
refs/tags/v19.4.0 - Owner: https://github.com/sgttomas
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@c08a65abc952cd91a6307048b71728497e796bb1 -
Trigger Event:
release
-
Statement type: