API-first AI governance middleware MVP for evaluating submitted content through deterministic rules, safety tags, and risk scoring.
Syzygy Rosetta is a FastAPI-based governance decision service. The current API accepts a required user/customer input, an optional model output, and optional context. It evaluates the interaction through safety tagging, deterministic policy rules, and risk scoring, then returns a structured decision:
allowrewriteescalate
user input + optional model output -> POST /evaluate -> allow / rewrite / escalate
|
+-> safety_layer.py
+-> config/policy_rules.json
+-> core/reflex.py
+-> logs/evaluations.json
Every successful POST /evaluate response returns these 8 fields:
{
"decision": "allow | rewrite | escalate",
"risk_score": 0.12,
"confidence": 0.91,
"violations": [],
"rewrite": null,
"reasoning": "Interaction evaluated as low risk. Continue with normal processing.",
"field_notes": [],
"timestamp": "2026-03-21T14:32:00Z"
}| Risk Score | Decision | Behavior |
|---|---|---|
< 0.4 |
allow |
Interaction passes. violations is empty. |
0.4 - 0.7 |
rewrite |
Input or output should be clarified or rewritten. rewrite is populated. |
>= 0.7 |
escalate |
Interaction is routed to human review. rewrite is null. |
syzygy-rosetta-originbase/
|
|-- README.md
|-- syzygy-rosetta-originbase.md
|-- REPO_MISMATCH_AUDIT.md
|
`-- syzygy-rosetta/
|-- app.py FastAPI entry point
|-- run_api.py local development launcher
|-- safety_layer.py pre-classification tags and sensitive-topic detection
|-- requirements.txt Python dependencies
|-- Dockerfile container entrypoint for app:app
|
|-- config/
| `-- policy_rules.json deterministic industry rules
|
|-- core/
| |-- reflex.py governance decision engine
| |-- risk_scoring.py weighted feature scoring utilities
| |-- constants.py invariant/config constants
| |-- invariants.json invariant metadata
| `-- resonators_mock.py legacy/simple reflex mock
|
|-- docs/
| `-- demo_checklist.md
|
|-- example/
| `-- basic_usage.py
|
|-- logs/
| `-- evaluations.json runtime audit log
|
`-- tests/
|-- test_evaluate.py
`-- test_healthz.py
Every POST /evaluate call currently follows this path:
- FastAPI validates required
input, optionaloutput, and optionalcontext. evaluate_prompt()runs a breath pause and mirror step.safety_layer.tag_input()labels authority, manipulation, dependency, and escalation patterns on input and output.detect_sensitive_topic()checks self-harm, violence, and sexual-content patterns on input and output._apply_policy_rules()checks industry-specific rules fromconfig/policy_rules.jsonon input and output.- The active scorer computes risk and confidence for the input-output pair.
- Risk floors and multipliers are applied.
- The API returns the 8-field response and appends an entry to
logs/evaluations.json.
Pass industry in the request context to activate sector-specific policy rules:
| Industry | Policy Rules |
|---|---|
finance |
Flags coercive financial instructions, guaranteed-return claims, compliance bypass, and market misconduct. |
healthcare |
Flags unsafe medication directives, system override attempts, and unauthorized access. |
general |
Flags jailbreak attempts, system prompt injection, unsafe security bypass requests, and harmful instructions. |
Production environment multiplier: x1.10. Multiple violations multiplier: x1.15.
- Python 3.11+
- Docker Desktop, only if running the container
Run these commands from syzygy-rosetta-originbase/syzygy-rosetta:
python -m pip install -r requirements.txt
python run_api.pyThe local server starts at:
http://127.0.0.1:8000
The Dockerfile currently lives inside syzygy-rosetta/, so build from that directory:
cd syzygy-rosetta
docker build -t rosetta .
docker run -p 8000:8000 rosettacurl -X POST http://localhost:8000/evaluate \
-H "Content-Type: application/json" \
-d '{
"input": "Summarize the key risks in this portfolio.",
"output": "The portfolio appears diversified, but review concentration and liquidity risks.",
"context": {
"environment": "staging",
"industry": "finance"
}
}'Example response shape:
{
"decision": "allow",
"risk_score": 0.14,
"confidence": 0.5,
"violations": [],
"rewrite": null,
"reasoning": "Interaction evaluated as low risk. Continue with normal processing.",
"field_notes": [
"FIELD_NOTE [2026-04-25T16:41:48Z]: mirror invoked",
"INTERNAL_NOTE [2026-04-25T16:41:48Z]"
],
"timestamp": "2026-04-25T16:41:48Z"
}http://localhost:8000/docs
Every POST /evaluate call appends one entry to syzygy-rosetta/logs/evaluations.json:
{
"timestamp": "2026-03-21T14:32:00Z",
"input": "the original input string",
"output": "the model output string or null",
"decision": "allow | rewrite | escalate",
"risk_score": 0.85,
"confidence": 0.91,
"violations": ["violation_label"],
"rewrite": "rewritten string or null",
"reasoning": "decision explanation",
"field_notes": [],
"context": {
"user_id": "string or null",
"environment": "production | staging",
"industry": "finance | healthcare | general"
}
}Run from syzygy-rosetta-originbase/syzygy-rosetta:
python -m pytest tests -qAt the time of the audit, this produced:
54 passed
This is the origin codebase for Syzygy Rosetta. It contains the foundational MVP implementation of the governance engine. Active development and refactoring are ongoing.
For known mismatches and cleanup work, see REPO_MISMATCH_AUDIT.md.
Licensed under AGPL-3.0-or-later.
Derived from the Syzygy Rosetta v1.0 protocol by Sarasha Elion (Trivian Institute).