cngx 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cngx-0.1.0/.dockerignore +31 -0
- cngx-0.1.0/.env.example +20 -0
- cngx-0.1.0/.gitignore +46 -0
- cngx-0.1.0/CHANGELOG.md +78 -0
- cngx-0.1.0/CODE_OF_CONDUCT.md +130 -0
- cngx-0.1.0/CONTRIBUTING.md +165 -0
- cngx-0.1.0/Dockerfile +44 -0
- cngx-0.1.0/LICENSE +21 -0
- cngx-0.1.0/Makefile +70 -0
- cngx-0.1.0/PKG-INFO +332 -0
- cngx-0.1.0/README.md +236 -0
- cngx-0.1.0/ROADMAP.md +85 -0
- cngx-0.1.0/SECURITY.md +48 -0
- cngx-0.1.0/action.yml +114 -0
- cngx-0.1.0/cngx/__init__.py +54 -0
- cngx-0.1.0/cngx/__main__.py +6 -0
- cngx-0.1.0/cngx/calibration/__init__.py +32 -0
- cngx-0.1.0/cngx/calibration/confidence.py +251 -0
- cngx-0.1.0/cngx/calibration/profiles.py +625 -0
- cngx-0.1.0/cngx/capture/__init__.py +26 -0
- cngx-0.1.0/cngx/capture/adapters/__init__.py +31 -0
- cngx-0.1.0/cngx/capture/adapters/base.py +131 -0
- cngx-0.1.0/cngx/capture/adapters/claude.py +522 -0
- cngx-0.1.0/cngx/capture/adapters/gemini.py +698 -0
- cngx-0.1.0/cngx/capture/adapters/mock.py +421 -0
- cngx-0.1.0/cngx/capture/adapters/openai.py +535 -0
- cngx-0.1.0/cngx/capture/tracer.py +340 -0
- cngx-0.1.0/cngx/cli/__init__.py +5 -0
- cngx-0.1.0/cngx/cli/capture.py +162 -0
- cngx-0.1.0/cngx/cli/check_cmd.py +134 -0
- cngx-0.1.0/cngx/cli/demo.py +427 -0
- cngx-0.1.0/cngx/cli/diff.py +167 -0
- cngx-0.1.0/cngx/cli/drift.py +182 -0
- cngx-0.1.0/cngx/cli/enforce.py +297 -0
- cngx-0.1.0/cngx/cli/gate.py +305 -0
- cngx-0.1.0/cngx/cli/history.py +236 -0
- cngx-0.1.0/cngx/cli/main.py +326 -0
- cngx-0.1.0/cngx/cli/pin.py +172 -0
- cngx-0.1.0/cngx/cli/quickstart_cmd.py +120 -0
- cngx-0.1.0/cngx/cli/regression_cmd.py +102 -0
- cngx-0.1.0/cngx/cli/report_cmd.py +189 -0
- cngx-0.1.0/cngx/cli/submit_cmd.py +351 -0
- cngx-0.1.0/cngx/cli/watch.py +90 -0
- cngx-0.1.0/cngx/cli/wrap.py +178 -0
- cngx-0.1.0/cngx/contracts/__init__.py +50 -0
- cngx-0.1.0/cngx/contracts/schema.py +418 -0
- cngx-0.1.0/cngx/contracts/validator.py +607 -0
- cngx-0.1.0/cngx/core/__init__.py +36 -0
- cngx-0.1.0/cngx/core/config.py +139 -0
- cngx-0.1.0/cngx/core/exceptions.py +127 -0
- cngx-0.1.0/cngx/core/models.py +331 -0
- cngx-0.1.0/cngx/diff/__init__.py +6 -0
- cngx-0.1.0/cngx/diff/engine.py +531 -0
- cngx-0.1.0/cngx/diff/formatter.py +225 -0
- cngx-0.1.0/cngx/drift/__init__.py +7 -0
- cngx-0.1.0/cngx/drift/batch.py +268 -0
- cngx-0.1.0/cngx/drift/detector.py +473 -0
- cngx-0.1.0/cngx/drift/legacy.py +125 -0
- cngx-0.1.0/cngx/drift/legacy_streaming.py +129 -0
- cngx-0.1.0/cngx/drift/paired.py +203 -0
- cngx-0.1.0/cngx/drift/scoring.py +185 -0
- cngx-0.1.0/cngx/drift/semantic.py +183 -0
- cngx-0.1.0/cngx/drift/session.py +66 -0
- cngx-0.1.0/cngx/drift/streaming.py +251 -0
- cngx-0.1.0/cngx/drift/trajectory.py +175 -0
- cngx-0.1.0/cngx/enforcement/__init__.py +11 -0
- cngx-0.1.0/cngx/enforcement/gate.py +392 -0
- cngx-0.1.0/cngx/enforcement/github_action.py +173 -0
- cngx-0.1.0/cngx/fingerprint/__init__.py +11 -0
- cngx-0.1.0/cngx/fingerprint/extractor.py +184 -0
- cngx-0.1.0/cngx/fingerprint/metrics.py +361 -0
- cngx-0.1.0/cngx/fingerprint/normalizer.py +172 -0
- cngx-0.1.0/cngx/observability/__init__.py +18 -0
- cngx-0.1.0/cngx/observability/logging.py +225 -0
- cngx-0.1.0/cngx/observability/metrics.py +242 -0
- cngx-0.1.0/cngx/observability/otel.py +124 -0
- cngx-0.1.0/cngx/providers/__init__.py +14 -0
- cngx-0.1.0/cngx/providers/base.py +143 -0
- cngx-0.1.0/cngx/providers/rate_limiter.py +160 -0
- cngx-0.1.0/cngx/providers/retry.py +263 -0
- cngx-0.1.0/cngx/proxy/__init__.py +14 -0
- cngx-0.1.0/cngx/proxy/analysis.py +330 -0
- cngx-0.1.0/cngx/proxy/app.py +174 -0
- cngx-0.1.0/cngx/proxy/config.py +37 -0
- cngx-0.1.0/cngx/proxy/events.py +73 -0
- cngx-0.1.0/cngx/proxy/server.py +18 -0
- cngx-0.1.0/cngx/py.typed +0 -0
- cngx-0.1.0/cngx/security/__init__.py +5 -0
- cngx-0.1.0/cngx/security/regex_sandbox.py +200 -0
- cngx-0.1.0/cngx/server/__init__.py +5 -0
- cngx-0.1.0/cngx/server/app.py +549 -0
- cngx-0.1.0/cngx/storage/__init__.py +5 -0
- cngx-0.1.0/cngx/storage/backend.py +732 -0
- cngx-0.1.0/cngx/storage/database.py +896 -0
- cngx-0.1.0/cngx/system_demo/__init__.py +40 -0
- cngx-0.1.0/cngx/system_demo/pipeline.py +579 -0
- cngx-0.1.0/cngx/system_demo/runner.py +337 -0
- cngx-0.1.0/cngx/system_demo/scenarios.py +424 -0
- cngx-0.1.0/cngx/tui/__init__.py +5 -0
- cngx-0.1.0/cngx/tui/alerts.py +61 -0
- cngx-0.1.0/cngx/tui/dashboard.py +165 -0
- cngx-0.1.0/cngx/versioning/__init__.py +7 -0
- cngx-0.1.0/cngx/versioning/baseline.py +132 -0
- cngx-0.1.0/cngx/versioning/pinning.py +61 -0
- cngx-0.1.0/cngx/versioning/store.py +116 -0
- cngx-0.1.0/contracts/code_correctness.yaml +99 -0
- cngx-0.1.0/contracts/math_correctness.yaml +102 -0
- cngx-0.1.0/contracts/research_reasoning.yaml +102 -0
- cngx-0.1.0/demo_contract.yaml +22 -0
- cngx-0.1.0/examples/basic_usage.py +106 -0
- cngx-0.1.0/examples/complete_demo.py +281 -0
- cngx-0.1.0/examples/contracts/basic_reasoning.yaml +28 -0
- cngx-0.1.0/examples/contracts/math_reasoning.yaml +55 -0
- cngx-0.1.0/examples/contracts/strict_verification.yaml +34 -0
- cngx-0.1.0/examples/demo_contracts.py +169 -0
- cngx-0.1.0/examples/drift_detection.py +77 -0
- cngx-0.1.0/examples/killer_demo.py +232 -0
- cngx-0.1.0/examples/regression_suite_real.yaml +23 -0
- cngx-0.1.0/examples/regression_testing.py +67 -0
- cngx-0.1.0/examples/streaming_capture.py +114 -0
- cngx-0.1.0/examples/system_demo.py +436 -0
- cngx-0.1.0/mkdocs.yml +76 -0
- cngx-0.1.0/packaging/pyinstaller/README.md +29 -0
- cngx-0.1.0/packaging/pyinstaller/cngx.spec +83 -0
- cngx-0.1.0/pyproject.toml +180 -0
- cngx-0.1.0/scripts/demo/README.md +103 -0
- cngx-0.1.0/scripts/demo/install_ttyd_msvc.ps1 +25 -0
- cngx-0.1.0/scripts/demo/quickstart.tape +27 -0
- cngx-0.1.0/scripts/demo/record_quickstart.ps1 +22 -0
- cngx-0.1.0/scripts/demo/record_quickstart.sh +7 -0
- cngx-0.1.0/scripts/demo/record_tracker.py +315 -0
- cngx-0.1.0/scripts/real_world_validation/.gitignore +2 -0
- cngx-0.1.0/scripts/real_world_validation/run_all.py +525 -0
- cngx-0.1.0/scripts/record_quickstart_demo.py +42 -0
- cngx-0.1.0/scripts/test_github_action_local.py +90 -0
cngx-0.1.0/.dockerignore
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*.egg-info/
|
|
5
|
+
dist/
|
|
6
|
+
build/
|
|
7
|
+
.eggs/
|
|
8
|
+
|
|
9
|
+
# Environments
|
|
10
|
+
.env
|
|
11
|
+
.venv/
|
|
12
|
+
venv/
|
|
13
|
+
|
|
14
|
+
# IDE
|
|
15
|
+
.vscode/
|
|
16
|
+
.idea/
|
|
17
|
+
|
|
18
|
+
# Data (don't ship databases)
|
|
19
|
+
*.db
|
|
20
|
+
*.duckdb
|
|
21
|
+
/data/
|
|
22
|
+
|
|
23
|
+
# OS
|
|
24
|
+
.DS_Store
|
|
25
|
+
Thumbs.db
|
|
26
|
+
|
|
27
|
+
# Test / CI
|
|
28
|
+
.pytest_cache/
|
|
29
|
+
htmlcov/
|
|
30
|
+
.coverage
|
|
31
|
+
.cngx/
|
cngx-0.1.0/.env.example
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# ─────────────────────────────────────────────
|
|
2
|
+
# cngx Environment Variables
|
|
3
|
+
# Copy this file to .env and fill in your values
|
|
4
|
+
# ─────────────────────────────────────────────
|
|
5
|
+
|
|
6
|
+
# ── LLM Provider API Keys ──
|
|
7
|
+
# At least one is required for live testing.
|
|
8
|
+
# Mock adapter works without any keys.
|
|
9
|
+
GOOGLE_API_KEY=
|
|
10
|
+
OPENAI_API_KEY=
|
|
11
|
+
ANTHROPIC_API_KEY=
|
|
12
|
+
|
|
13
|
+
# ── Server (optional self-hosted UI) ──
|
|
14
|
+
CNGX_HOST=0.0.0.0
|
|
15
|
+
CNGX_PORT=8642
|
|
16
|
+
CNGX_SECRET_KEY=change-me-to-a-random-secret
|
|
17
|
+
|
|
18
|
+
# ── Optional ──
|
|
19
|
+
CNGX_LOG_LEVEL=INFO
|
|
20
|
+
CNGX_STORAGE_DIR=.cngx
|
cngx-0.1.0/.gitignore
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Python bytecode and caches
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
*.egg-info/
|
|
6
|
+
.eggs/
|
|
7
|
+
dist/
|
|
8
|
+
build/
|
|
9
|
+
*.egg
|
|
10
|
+
|
|
11
|
+
# Virtual environments
|
|
12
|
+
.venv/
|
|
13
|
+
venv/
|
|
14
|
+
.venv-pyinstaller/
|
|
15
|
+
env/
|
|
16
|
+
|
|
17
|
+
# Test and type checker caches
|
|
18
|
+
.pytest_cache/
|
|
19
|
+
.mypy_cache/
|
|
20
|
+
.ruff_cache/
|
|
21
|
+
.coverage
|
|
22
|
+
htmlcov/
|
|
23
|
+
|
|
24
|
+
# Secrets and local runtime data
|
|
25
|
+
.env
|
|
26
|
+
.cngx/
|
|
27
|
+
.cogscope/
|
|
28
|
+
|
|
29
|
+
# Generated documentation and tracker site
|
|
30
|
+
site/
|
|
31
|
+
tracker/site/index.html
|
|
32
|
+
tracker/site/data.js
|
|
33
|
+
tracker/site/site.css
|
|
34
|
+
tracker/site/app.js
|
|
35
|
+
tracker/site/docs.js
|
|
36
|
+
tracker/site/docs/
|
|
37
|
+
tracker/screenshots/
|
|
38
|
+
|
|
39
|
+
# VHS tooling (MSVC ttyd binaries, not committed)
|
|
40
|
+
.vhs-tools/
|
|
41
|
+
|
|
42
|
+
# IDE and OS
|
|
43
|
+
.vscode/
|
|
44
|
+
.idea/
|
|
45
|
+
.DS_Store
|
|
46
|
+
Thumbs.db
|
cngx-0.1.0/CHANGELOG.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to cngx will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [0.1.0] - 2026-07-06
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
- **Fresh public relaunch** under the name **cngx** (renamed from the private `rvc` package).
|
|
12
|
+
- Prior GitHub and PyPI name was **cogscope**; releases now ship as **cngx**.
|
|
13
|
+
- **Version reset to 0.1.0**, new version scheme for the open-source developer tool; supersedes the prior 1.0.0/2.0.0 mismatch in the private tree.
|
|
14
|
+
- Enterprise/SaaS surfaces (`platform/`, `cloud/`, `sdk/`, `rvc-demo/`, `rvc-prod/`) moved to `_archive_pre_oss/`.
|
|
15
|
+
- Phase-2 modules (correctness, robustness, governance, benchmarks, etc.) archived for future releases.
|
|
16
|
+
|
|
17
|
+
### Removed
|
|
18
|
+
- Cloud platform CLI commands, enterprise SDK tests, and multi-service `docker-compose.yml` from the public tree.
|
|
19
|
+
|
|
20
|
+
## [1.0.0] - 2026-02-11
|
|
21
|
+
|
|
22
|
+
### Added
|
|
23
|
+
- **Claude/Anthropic adapter**, full support for Claude Opus, Sonnet, Haiku (3, 3.5, 4) with extended thinking extraction
|
|
24
|
+
- **RBAC role system**, admin, member, viewer roles with scope-based enforcement
|
|
25
|
+
- **Webhook notifications**, real-time alerts on gate blocks, drift detection, contract violations
|
|
26
|
+
- **Batch enforcement API**, validate multiple prompts/fingerprints in a single API call
|
|
27
|
+
- **Structured JSON logging**, production-grade log output with correlation IDs, compatible with ELK/Datadog
|
|
28
|
+
- **Prometheus metrics**, `/metrics` endpoint with enforcement counters, latency histograms, active org gauges
|
|
29
|
+
- **PostgreSQL support**, cloud database can use PostgreSQL for horizontal scaling via `CNGX_DATABASE_URL`
|
|
30
|
+
- **Streaming capture**, capture reasoning traces from streaming LLM responses
|
|
31
|
+
- **GitHub Actions CI/CD**, automated testing, linting, and PyPI publishing on release
|
|
32
|
+
- **MkDocs documentation site**, comprehensive docs with tutorials, API reference, contract authoring guide
|
|
33
|
+
- **LICENSE file** (MIT)
|
|
34
|
+
- **CHANGELOG.md**
|
|
35
|
+
- **CONTRIBUTING.md**
|
|
36
|
+
|
|
37
|
+
### Changed
|
|
38
|
+
- **Version bumped to 1.0.0**, production-ready release
|
|
39
|
+
- **Cloud auth hardened**, API keys removed from query strings, secure cookie-based web UI auth
|
|
40
|
+
- **Rate limiter**, configurable per org plan tier (free: 100/min, team: 500/min, enterprise: 2000/min)
|
|
41
|
+
- **pyproject.toml**, updated with all new optional dependencies, proper classifiers
|
|
42
|
+
- **CLI error handling**, all commands wrapped with structured error reporting
|
|
43
|
+
|
|
44
|
+
### Fixed
|
|
45
|
+
- API key revoke now uses correct `AuditAction.API_KEY_REVOKE` instead of reusing `API_KEY_CREATE`
|
|
46
|
+
- Cloud login page now uses Jinja2 template instead of inline HTML
|
|
47
|
+
- Adapters `__init__.py` exports all adapters (was missing GeminiAdapter)
|
|
48
|
+
- Circuit breaker in SDK client is now class-level (shared across instances)
|
|
49
|
+
|
|
50
|
+
### Security
|
|
51
|
+
- ReDoS regex sandbox hardened with additional pattern detection
|
|
52
|
+
- API keys never appear in server logs or query strings
|
|
53
|
+
- Web UI auth uses HttpOnly secure cookies instead of URL parameters
|
|
54
|
+
- TLS enforcement flag added to cloud server config
|
|
55
|
+
|
|
56
|
+
## [0.2.0] - 2025-12-01
|
|
57
|
+
|
|
58
|
+
### Added
|
|
59
|
+
- Cloud platform (multi-tenant SaaS)
|
|
60
|
+
- Contract enforcement engine
|
|
61
|
+
- Behavioral fingerprinting (30+ metrics)
|
|
62
|
+
- DuckDB storage
|
|
63
|
+
- OpenAI and Gemini adapters
|
|
64
|
+
- CLI with gate, capture, diff, drift, eval, pin commands
|
|
65
|
+
- System demo module
|
|
66
|
+
- Cross-model validation
|
|
67
|
+
- Calibration profiles for 12 model families
|
|
68
|
+
- Explainability engine
|
|
69
|
+
- Remediation engine
|
|
70
|
+
|
|
71
|
+
## [0.1.0] - 2025-09-01
|
|
72
|
+
|
|
73
|
+
### Added
|
|
74
|
+
- Initial release
|
|
75
|
+
- Core reasoning trace capture
|
|
76
|
+
- Basic fingerprinting
|
|
77
|
+
- Diff engine
|
|
78
|
+
- CLI scaffolding
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our
|
|
6
|
+
community a harassment-free experience for everyone, regardless of age, body
|
|
7
|
+
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
|
8
|
+
identity and expression, level of experience, education, socio-economic status,
|
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity
|
|
10
|
+
and orientation.
|
|
11
|
+
|
|
12
|
+
We pledge to act and interact in ways that contribute to an open, welcoming,
|
|
13
|
+
diverse, inclusive, and healthy community.
|
|
14
|
+
|
|
15
|
+
## Our Standards
|
|
16
|
+
|
|
17
|
+
Examples of behavior that contributes to a positive environment for our
|
|
18
|
+
community include:
|
|
19
|
+
|
|
20
|
+
* Demonstrating empathy and kindness toward other people
|
|
21
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
|
22
|
+
* Giving and gracefully accepting constructive feedback
|
|
23
|
+
* Accepting responsibility and apologizing to those affected by our mistakes,
|
|
24
|
+
and learning from the experience
|
|
25
|
+
* Focusing on what is best not just for us as individuals, but for the
|
|
26
|
+
overall community
|
|
27
|
+
|
|
28
|
+
Examples of unacceptable behavior include:
|
|
29
|
+
|
|
30
|
+
* The use of sexualized language or imagery, and sexual attention or
|
|
31
|
+
advances of any kind
|
|
32
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
|
33
|
+
* Public or private harassment
|
|
34
|
+
* Publishing others' private information, such as a physical or email
|
|
35
|
+
address, without their explicit permission
|
|
36
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
37
|
+
professional setting
|
|
38
|
+
|
|
39
|
+
## Enforcement Responsibilities
|
|
40
|
+
|
|
41
|
+
Community leaders are responsible for clarifying and enforcing our standards of
|
|
42
|
+
acceptable behavior and will take appropriate and fair corrective action in
|
|
43
|
+
response to any behavior that they deem inappropriate, threatening, offensive,
|
|
44
|
+
or harmful.
|
|
45
|
+
|
|
46
|
+
Community leaders have the right and responsibility to remove, edit, or reject
|
|
47
|
+
comments, commits, code, wiki edits, issues, and other contributions that are
|
|
48
|
+
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
|
49
|
+
decisions when appropriate.
|
|
50
|
+
|
|
51
|
+
## Scope
|
|
52
|
+
|
|
53
|
+
This Code of Conduct applies within all community spaces, and also applies when
|
|
54
|
+
an individual is officially representing the community in public spaces.
|
|
55
|
+
Examples of representing our community include using an official e-mail address,
|
|
56
|
+
posting via an official social media account, or acting as an appointed
|
|
57
|
+
representative at an online or offline event.
|
|
58
|
+
|
|
59
|
+
## Enforcement
|
|
60
|
+
|
|
61
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
62
|
+
reported to the community leaders responsible for enforcement by opening a
|
|
63
|
+
private GitHub Security Advisory on this repository, or by contacting
|
|
64
|
+
[@aadi-joshi](https://github.com/aadi-joshi) directly via GitHub.
|
|
65
|
+
|
|
66
|
+
All complaints will be reviewed and investigated promptly and fairly.
|
|
67
|
+
|
|
68
|
+
All community leaders are obligated to respect the privacy and security of the
|
|
69
|
+
reporter of any incident.
|
|
70
|
+
|
|
71
|
+
## Enforcement Guidelines
|
|
72
|
+
|
|
73
|
+
Community leaders will follow these Community Impact Guidelines in determining
|
|
74
|
+
the consequences for any action they deem in violation of this Code of Conduct:
|
|
75
|
+
|
|
76
|
+
### 1. Correction
|
|
77
|
+
|
|
78
|
+
**Community Impact:** Use of inappropriate language or other behavior deemed
|
|
79
|
+
unprofessional or unwelcome in the community.
|
|
80
|
+
|
|
81
|
+
**Consequence:** A private, written warning from community leaders, providing
|
|
82
|
+
clarity around the nature of the violation and an explanation of why the
|
|
83
|
+
behavior was inappropriate. A public apology may be requested.
|
|
84
|
+
|
|
85
|
+
### 2. Warning
|
|
86
|
+
|
|
87
|
+
**Community Impact:** A violation through a single incident or series
|
|
88
|
+
of actions.
|
|
89
|
+
|
|
90
|
+
**Consequence:** A warning with consequences for continued behavior. No
|
|
91
|
+
interaction with the people involved, including unsolicited interaction with
|
|
92
|
+
those enforcing the Code of Conduct, for a specified period of time. This
|
|
93
|
+
includes avoiding interactions in community spaces as well as external channels
|
|
94
|
+
like social media. Violating these terms may lead to a temporary or
|
|
95
|
+
permanent ban.
|
|
96
|
+
|
|
97
|
+
### 3. Temporary Ban
|
|
98
|
+
|
|
99
|
+
**Community Impact:** A serious violation of community standards, including
|
|
100
|
+
sustained inappropriate behavior.
|
|
101
|
+
|
|
102
|
+
**Consequence:** A temporary ban from any sort of interaction or public
|
|
103
|
+
communication with the community for a specified period of time. No public or
|
|
104
|
+
private interaction with the people involved, including unsolicited interaction
|
|
105
|
+
with those enforcing the Code of Conduct, is allowed during this period.
|
|
106
|
+
Violating these terms may lead to a permanent ban.
|
|
107
|
+
|
|
108
|
+
### 4. Permanent Ban
|
|
109
|
+
|
|
110
|
+
**Community Impact:** Demonstrating a pattern of violation of community
|
|
111
|
+
standards, including sustained inappropriate behavior, harassment of an
|
|
112
|
+
individual, or aggression toward or disparagement of classes of individuals.
|
|
113
|
+
|
|
114
|
+
**Consequence:** A permanent ban from any sort of public interaction within
|
|
115
|
+
the community.
|
|
116
|
+
|
|
117
|
+
## Attribution
|
|
118
|
+
|
|
119
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
|
120
|
+
version 2.0, available at
|
|
121
|
+
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
|
122
|
+
|
|
123
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct
|
|
124
|
+
enforcement ladder](https://github.com/mozilla/diversity).
|
|
125
|
+
|
|
126
|
+
[homepage]: https://www.contributor-covenant.org
|
|
127
|
+
|
|
128
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
|
129
|
+
https://www.contributor-covenant.org/faq. Translations are available at
|
|
130
|
+
https://www.contributor-covenant.org/translations.
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# Contributing to cngx
|
|
2
|
+
|
|
3
|
+
Thank you for helping improve cngx. This guide covers local development, code style, and how to extend the project.
|
|
4
|
+
|
|
5
|
+
## Development setup
|
|
6
|
+
|
|
7
|
+
### Prerequisites
|
|
8
|
+
|
|
9
|
+
- Python 3.10+
|
|
10
|
+
- Git
|
|
11
|
+
|
|
12
|
+
### Local install
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
git clone https://github.com/aadi-joshi/cngx.git
|
|
16
|
+
cd cngx
|
|
17
|
+
|
|
18
|
+
python -m venv .venv
|
|
19
|
+
# Windows: .venv\Scripts\activate
|
|
20
|
+
# macOS/Linux: source .venv/bin/activate
|
|
21
|
+
|
|
22
|
+
pip install -e ".[dev]"
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Optional provider extras (only if you are working on or testing that adapter):
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pip install -e ".[dev,gemini]" # Google Gemini
|
|
29
|
+
pip install -e ".[dev,claude]" # Anthropic Claude
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Run tests
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
pytest # full suite
|
|
36
|
+
pytest tests/unit/ -q # unit tests only
|
|
37
|
+
pytest tests/unit/test_drift_alerting.py -v # statistical alerting tests
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Lint and format
|
|
41
|
+
|
|
42
|
+
The repo uses **Ruff** (lint + isort), **Black** (format), and **mypy** (types). Config lives in `pyproject.toml`.
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
ruff check .
|
|
46
|
+
black --check .
|
|
47
|
+
mypy cngx/
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Auto-format before committing:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
ruff check --fix .
|
|
54
|
+
black .
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Optional: `pre-commit install` if you use pre-commit hooks locally.
|
|
58
|
+
|
|
59
|
+
## Project layout (active OSS tree)
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
cngx/
|
|
63
|
+
├── capture/ # Tracing and LLM adapters
|
|
64
|
+
├── proxy/ # Local ASGI reverse proxy
|
|
65
|
+
├── tui/ # Live terminal dashboard
|
|
66
|
+
├── fingerprint/ # Metric extraction (see metrics.py)
|
|
67
|
+
├── diff/ # Trace/fingerprint comparison
|
|
68
|
+
├── drift/ # Baseline-relative drift detection
|
|
69
|
+
├── calibration/ # Model profiles and adaptive thresholds
|
|
70
|
+
├── contracts/ # Behavior policies (YAML) and validation
|
|
71
|
+
├── versioning/ # Baseline pinning
|
|
72
|
+
├── storage/ # Local DuckDB
|
|
73
|
+
├── cli/ # Typer CLI entry points
|
|
74
|
+
└── system_demo/ # Reference pipeline scenarios
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Hosted SaaS and marketing-site code from earlier development is **not** in this repository and is out of scope for new contributions.
|
|
78
|
+
|
|
79
|
+
## Proposing a new behavioral metric
|
|
80
|
+
|
|
81
|
+
1. Read `cngx/fingerprint/metrics.py`, `MetricsCalculator` holds regex patterns and counting logic for each signal.
|
|
82
|
+
2. Add your metric computation there (keep it fast and deterministic; prefer explicit patterns over NLP).
|
|
83
|
+
3. Wire the new field through `cngx/fingerprint/extractor.py` into `BehavioralFingerprint` in `cngx/core/models.py` if it is a new top-level metric.
|
|
84
|
+
4. If the metric should influence drift alerting, update `cngx/calibration/profiles.py` (`QUALITY_METRICS` / `LENGTH_METRICS`) and review `cngx/drift/detector.py`.
|
|
85
|
+
5. Add unit tests in `tests/unit/test_metrics.py` or `tests/unit/test_fingerprint.py` with a minimal synthetic trace.
|
|
86
|
+
|
|
87
|
+
Design note: metrics are heuristics. Document what each pattern captures and what it will miss.
|
|
88
|
+
|
|
89
|
+
## Adding a new LLM provider adapter
|
|
90
|
+
|
|
91
|
+
1. Create `cngx/capture/adapters/your_provider.py`.
|
|
92
|
+
2. Subclass `BaseAdapter` in `cngx/capture/adapters/base.py` and implement:
|
|
93
|
+
- `async def call(...)`, primary async entry point
|
|
94
|
+
- `def call_sync(...)`, synchronous wrapper (often `asyncio.run` or shared core)
|
|
95
|
+
- Streaming via `StreamChunk` if the provider supports it
|
|
96
|
+
3. Register the adapter in `cngx/capture/adapters/__init__.py` and in `CngxTracer`’s adapter map (`cngx/capture/tracer.py`).
|
|
97
|
+
4. Add routing in `cngx/proxy/app.py` if the proxy should forward that provider’s API shape.
|
|
98
|
+
5. Add a model profile stub in `cngx/calibration/profiles.py` if the family has distinct baseline behavior.
|
|
99
|
+
6. Add optional dependency in `pyproject.toml` under `[project.optional-dependencies]`.
|
|
100
|
+
7. Add tests in `tests/unit/` with mocked HTTP or the `mock` adapter pattern; skip live tests when API keys are absent.
|
|
101
|
+
|
|
102
|
+
Never log or persist API keys. Read them from environment variables only.
|
|
103
|
+
|
|
104
|
+
## Pull requests
|
|
105
|
+
|
|
106
|
+
1. Open an issue or discussion for large changes before investing heavily.
|
|
107
|
+
2. Fork, branch from `main` (or the active launch branch), keep PRs focused.
|
|
108
|
+
3. Include tests for behavior changes.
|
|
109
|
+
4. Run `pytest`, `ruff check .`, `black --check .`, and `mypy cngx/` before opening the PR.
|
|
110
|
+
5. Use clear commit messages (`feat:`, `fix:`, `docs:`, etc.).
|
|
111
|
+
6. Fill out the PR template; link related issues.
|
|
112
|
+
|
|
113
|
+
Maintainers review for correctness, test coverage, user-facing clarity (plain language in CLI/docs), and whether new metrics respect the statistical alerting design (no single-metric or length-only false alarms).
|
|
114
|
+
|
|
115
|
+
## Reporting bugs and suggesting features
|
|
116
|
+
|
|
117
|
+
- **Bugs:** use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md).
|
|
118
|
+
- **Features:** use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md).
|
|
119
|
+
|
|
120
|
+
## CI integration and README badge
|
|
121
|
+
|
|
122
|
+
**GitHub Action:** add `uses: aadi-joshi/cngx@v0.1.0` to your workflow. See [docs/guides/github-action.md](docs/guides/github-action.md).
|
|
123
|
+
|
|
124
|
+
**README badge** (shields.io):
|
|
125
|
+
|
|
126
|
+
```markdown
|
|
127
|
+
[](https://github.com/aadi-joshi/cngx)
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
More options: [docs/guides/badge.md](docs/guides/badge.md).
|
|
131
|
+
|
|
132
|
+
Local smoke test for the action logic:
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
python scripts/test_github_action_local.py
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## Demo assets (dev tooling only)
|
|
139
|
+
|
|
140
|
+
Regenerate README/docs media with scripts under `scripts/demo/`. See `scripts/demo/README.md`.
|
|
141
|
+
|
|
142
|
+
Terminal quickstart GIF:
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
vhs scripts/demo/quickstart.tape
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
Tracker site recording:
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
pip install -e ".[dev]"
|
|
152
|
+
playwright install chromium
|
|
153
|
+
python scripts/demo/record_tracker.py
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Playwright is listed under `[project.optional-dependencies] dev` only, not in runtime dependencies.
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
## Code of conduct
|
|
160
|
+
|
|
161
|
+
This project follows the [Contributor Covenant](CODE_OF_CONDUCT.md). Be respectful and constructive.
|
|
162
|
+
|
|
163
|
+
## License
|
|
164
|
+
|
|
165
|
+
By contributing, you agree your contributions are licensed under the MIT License.
|
cngx-0.1.0/Dockerfile
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# cngx local proxy, optional container for home server / VPS
|
|
2
|
+
#
|
|
3
|
+
# Runs the ASGI reverse proxy only (not a multi-service SaaS stack).
|
|
4
|
+
# Forwards LLM traffic, fingerprints on the side. API keys via env at runtime.
|
|
5
|
+
#
|
|
6
|
+
# Build: docker build -t cngx-proxy .
|
|
7
|
+
# Run: docker run -p 8642:8642 -e OPENAI_API_KEY=sk-... cngx-proxy
|
|
8
|
+
#
|
|
9
|
+
# See README.md and SECURITY.md for key handling (memory only, never logged).
|
|
10
|
+
|
|
11
|
+
FROM python:3.11-slim AS builder
|
|
12
|
+
|
|
13
|
+
WORKDIR /build
|
|
14
|
+
RUN pip install --no-cache-dir hatchling
|
|
15
|
+
COPY pyproject.toml README.md LICENSE ./
|
|
16
|
+
COPY cngx/ cngx/
|
|
17
|
+
RUN pip wheel --no-deps --wheel-dir /wheels .
|
|
18
|
+
|
|
19
|
+
FROM python:3.11-slim
|
|
20
|
+
|
|
21
|
+
LABEL maintainer="cngx Contributors"
|
|
22
|
+
LABEL description="cngx local LLM proxy with behavioral fingerprinting"
|
|
23
|
+
LABEL version="0.1.0"
|
|
24
|
+
|
|
25
|
+
RUN groupadd -r cngx && useradd -r -g cngx -d /app -s /sbin/nologin cngx
|
|
26
|
+
|
|
27
|
+
WORKDIR /app
|
|
28
|
+
COPY --from=builder /wheels /wheels
|
|
29
|
+
RUN pip install --no-cache-dir /wheels/*.whl && rm -rf /wheels
|
|
30
|
+
|
|
31
|
+
RUN mkdir -p /data/.cngx && chown -R cngx:cngx /data
|
|
32
|
+
USER cngx
|
|
33
|
+
|
|
34
|
+
ENV CNGX_STORAGE_DIR=/data/.cngx
|
|
35
|
+
ENV CNGX_PROXY_HOST=0.0.0.0
|
|
36
|
+
ENV CNGX_PROXY_PORT=8642
|
|
37
|
+
ENV PYTHONUNBUFFERED=1
|
|
38
|
+
|
|
39
|
+
EXPOSE 8642
|
|
40
|
+
|
|
41
|
+
HEALTHCHECK --interval=30s --timeout=5s --retries=3 \
|
|
42
|
+
CMD python -c "import httpx; httpx.get('http://127.0.0.1:8642/health').raise_for_status()" || exit 1
|
|
43
|
+
|
|
44
|
+
CMD ["uvicorn", "cngx.proxy.app:app", "--host", "0.0.0.0", "--port", "8642"]
|
cngx-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 aadi-joshi
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
cngx-0.1.0/Makefile
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
.PHONY: help install dev test lint format build publish clean docker docs demo
|
|
2
|
+
|
|
3
|
+
help: ## Show this help
|
|
4
|
+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | \
|
|
5
|
+
awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
|
|
6
|
+
|
|
7
|
+
install: ## Install cngx (core only)
|
|
8
|
+
pip install -e .
|
|
9
|
+
|
|
10
|
+
dev: ## Install cngx with all dev dependencies
|
|
11
|
+
pip install -e ".[all,dev,docs]"
|
|
12
|
+
|
|
13
|
+
test: ## Run all tests (no API keys needed)
|
|
14
|
+
python -m pytest tests/ -v --noconftest -x
|
|
15
|
+
|
|
16
|
+
test-unit: ## Run unit tests only
|
|
17
|
+
python -m pytest tests/unit/ -v --noconftest
|
|
18
|
+
|
|
19
|
+
test-integration: ## Run integration tests
|
|
20
|
+
python tests/integration/test_e2e_pipeline.py
|
|
21
|
+
|
|
22
|
+
test-coverage: ## Run tests with coverage report
|
|
23
|
+
python -m pytest tests/ --noconftest --cov=cngx --cov-report=html --cov-report=term
|
|
24
|
+
|
|
25
|
+
lint: ## Run linters (ruff)
|
|
26
|
+
ruff check cngx/ tests/
|
|
27
|
+
ruff format --check cngx/ tests/
|
|
28
|
+
|
|
29
|
+
format: ## Auto-format code
|
|
30
|
+
ruff format cngx/ tests/
|
|
31
|
+
ruff check --fix cngx/ tests/
|
|
32
|
+
|
|
33
|
+
typecheck: ## Run type checker
|
|
34
|
+
mypy cngx/ --ignore-missing-imports
|
|
35
|
+
|
|
36
|
+
build: ## Build package
|
|
37
|
+
python -m build
|
|
38
|
+
|
|
39
|
+
publish: ## Publish to PyPI (requires credentials)
|
|
40
|
+
python -m build
|
|
41
|
+
twine upload dist/*
|
|
42
|
+
|
|
43
|
+
clean: ## Remove build artifacts
|
|
44
|
+
rm -rf build/ dist/ *.egg-info .cngx/ htmlcov/ .coverage
|
|
45
|
+
find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
|
|
46
|
+
find . -type f -name "*.pyc" -delete 2>/dev/null || true
|
|
47
|
+
|
|
48
|
+
docker: ## Build Docker image
|
|
49
|
+
docker build -t cngx:latest .
|
|
50
|
+
|
|
51
|
+
docs: ## Build documentation site
|
|
52
|
+
mkdocs build
|
|
53
|
+
|
|
54
|
+
docs-serve: ## Serve docs locally
|
|
55
|
+
mkdocs serve
|
|
56
|
+
|
|
57
|
+
demo: ## Run the full system demo (no API keys needed)
|
|
58
|
+
python examples/basic_usage.py
|
|
59
|
+
|
|
60
|
+
demo-e2e: ## Run integration pipeline tests
|
|
61
|
+
python -m pytest tests/integration/test_full_pipeline.py -v
|
|
62
|
+
|
|
63
|
+
gate-mock: ## Run a sample gate check with mock adapter
|
|
64
|
+
cngx gate check "Solve x^2 + 5x + 6 = 0" \
|
|
65
|
+
--contract contracts/math_correctness.yaml \
|
|
66
|
+
--adapter mock \
|
|
67
|
+
--model mock-model
|
|
68
|
+
|
|
69
|
+
version: ## Show cngx version
|
|
70
|
+
cngx version
|