How trivian-technologies/syzygy-rosetta-originbase works
1. Overall shape
- This repo is a small Python 3.11 FastAPI service that acts as an AI governance middleware.
- Its core job is to take an input plus optional context, run it through a deterministic policy/risk pipeline, and return a decision: allow, rewrite, or escalate.
2. Primary runtime boundary
- The main deployment unit is the API process started from app.py or run_api.py.
- The service is containerized with a Dockerfile, exposed on port 8000, and intended to be called by upstream AI systems rather than by end users directly.
3. Request/response flow
- The central ingress is POST /evaluate.
- That request is parsed, normalized, scored, and then converted into a fixed response shape with fields like decision, risk_score, confidence, violations, rewrite, reasoning, field_notes, and timestamp.
- A successful evaluation also appends an audit entry to logs/evaluations.json.
4. Governance engine
- core/reflex.py appears to be the orchestration layer for the evaluation pipeline.
- It combines multiple stages: input parsing, structural analysis, safety tagging, policy matching, composite risk scoring, thresholding, and response assembly.
- This is the main architectural center of the repo.
5. Safety and policy subsystems
- safety_layer.py performs pre-classification and tags patterns such as authority, manipulation, dependency, and escalation.
- config/policy_rules.json provides deterministic, industry-specific policy rules for sectors like finance, healthcare, and general use.
- These rules act as hard or semi-hard risk floors before final decisioning.
6. Risk scoring subsystem
- core/risk_scoring.py contains the composite scorer logic.
- The README describes three scoring contributors: keyword-based scoring, feature-based scoring, and an optional LLM-based scorer.
- core/resonators_mock.py suggests the project includes mock or placeholder components for some of these scoring/resonance behaviors.
7. Domain constants and invariants
- core/constants.py and core/invariants.json define shared thresholds, fixed labels, or governance assumptions used by the evaluation engine.
- These files likely keep policy logic and response semantics consistent across the service and tests.
8. Audit and persistence
- The only persistent runtime artifact visible in the repo is logs/evaluations.json.
- This file is append-only from the app’s perspective and functions as the audit trail for every evaluation request.
- There is no evidence of a database or queue; persistence appears intentionally lightweight and file-based.
9. External dependency boundary
- The repo is provider-agnostic by default, but the README mentions an optional Anthropic-backed LLM scorer activated through ANTHROPIC_API_KEY.
- That means the architecture has a clean local-first path, with an optional external inference dependency that increases scorer sophistication without changing the API contract.
10. Testing boundary
- tests/test_evaluate.py and tests/test_healthz.py cover the public API behavior, decision paths, schema validation, and health endpoint behavior.
- This suggests the externally observable contract is tightly tested, while internal scoring/policy details remain implementation concerns.
11. Developer and example surface
- example/basic_usage.py provides a minimal client-side integration example.
- docs/demo_checklist.md and the PDF documentation indicate the repo is meant to be demoed as a governance product, not just run as a library.
12. How to draw the architecture
- The key diagram should show an inbound AI output/request entering the FastAPI service, flowing through policy rules, safety tagging, and composite risk scoring, then exiting as a decision response.
- A side path should show audit logging to logs/evaluations.json.
- A dashed optional path should show the external LLM scorer, and a separate config boundary should show policy_rules.json and invariants/constants feeding the engine.
Main entry points: reflex.py Reflex · app.py App · risk_scoring.py Risk scoring · safety_layer.py Safety
Components 17
Runtime
API process and startup entrypoints
- App · Defines the API service and request handling surface
syzygy-rosetta/app.py - Run API · Process entrypoint for running the service
syzygy-rosetta/run_api.py - Dockerfile · Container image definition for the API service
syzygy-rosetta/Dockerfile
Core engine
Governance orchestration, safety, and scoring
- Reflex · Coordinates parse, analyze, score, decide, and assemble
syzygy-rosetta/core/reflex.py - Safety · Pre-classifies risky patterns and safety signals
syzygy-rosetta/safety_layer.py - Risk scoring · Combines keyword, feature, and optional LLM scoring
syzygy-rosetta/core/risk_scoring.py - Mock resonators · Placeholder or mock scoring/resonance behavior
syzygy-rosetta/core/resonators_mock.py
Policy config
Deterministic rules and shared invariants
- Constants · Fixed thresholds and governance labels
syzygy-rosetta/core/constants.py - Invariants · Static assumptions and response semantics
syzygy-rosetta/core/invariants.json - Policy rules · Industry-specific rule set for evaluation floors
syzygy-rosetta/config/policy_rules.json
Audit trail
Append-only evaluation logs
- Eval log · Append-only evaluation audit trail
syzygy-rosetta/logs/evaluations.json
External integration
Optional provider-backed scoring
- Anthropic API · External scorer used when enabled by API key
Verification
Public API tests
- Eval tests · Validates decisions, schema, and response behavior
syzygy-rosetta/tests/test_evaluate.py - Health tests · Validates health endpoint behavior
syzygy-rosetta/tests/test_healthz.py
Docs and examples
Usage and demo surface
- Usage example · Minimal integration example for upstream callers
syzygy-rosetta/example/basic_usage.py - Demo guide · Checklist for presenting the governance workflow
syzygy-rosetta/docs/demo_checklist.md - README · Repository overview and operating instructions
syzygy-rosetta/README.md
Connections 19
- Run API → App: starts · Launches the API process
- App → Reflex: POST /evaluate · Sends incoming requests into the governance pipeline
- Reflex → Safety: tag · Derives safety signals before scoring
- Reflex → Policy rules: match · Applies deterministic policy floors and sector rules
- Reflex → Risk scoring: score · Computes composite risk and confidence
- Risk scoring → Mock resonators: fallback · Uses mock resonance behavior where applicable
- Risk scoring → Anthropic API: optional LLM · Delegates to external scorer when configured
- Reflex → Constants: thresholds · Reads shared decision thresholds and labels
- Reflex → Invariants: semantics · Uses governance invariants for response assembly
- Safety → Policy rules: seed · Feeds tagged risk patterns into rule evaluation
- Risk scoring → Constants: calibrate · Uses shared scoring constants and cutoffs
- Risk scoring → Invariants: constrain · Conforms to fixed scoring semantics
- Reflex → Eval log: append · Writes audit entry after evaluation
- App → Eval log: audit · Exposes the persisted evaluation trail indirectly through the pipeline
- App → Dockerfile: package · Runs inside the containerized deployment unit
- Eval tests → App: covers · Exercises the evaluation API contract
- Health tests → App: covers · Exercises the health endpoint contract
- Usage example → App: calls · Demonstrates client-side integration
- Demo guide → README: supports · Guides demo and walkthrough usage