agentobs 1.0.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.
Files changed (188) hide show
  1. agentobs-1.0.0/.gitattributes +2 -0
  2. agentobs-1.0.0/.github/workflows/ci.yml +147 -0
  3. agentobs-1.0.0/.gitignore +181 -0
  4. agentobs-1.0.0/.pre-commit-config.yaml +62 -0
  5. agentobs-1.0.0/.readthedocs.yaml +18 -0
  6. agentobs-1.0.0/CNAME +1 -0
  7. agentobs-1.0.0/CODE_AUDIT_REPORT_2026-03-01.md +251 -0
  8. agentobs-1.0.0/CODE_AUDIT_REPORT_2026-03-04_EXTERNAL_REVIEW.md +147 -0
  9. agentobs-1.0.0/LICENSE +21 -0
  10. agentobs-1.0.0/LLM_TOOLKIT_SCHEMA_SOURCE_OF_TRUTH.md +1098 -0
  11. agentobs-1.0.0/PKG-INFO +636 -0
  12. agentobs-1.0.0/README.md +557 -0
  13. agentobs-1.0.0/RELEASE.md +89 -0
  14. agentobs-1.0.0/RFC-0001-AGENTOBS.md +1928 -0
  15. agentobs-1.0.0/SDK-SPEC-0001.md +570 -0
  16. agentobs-1.0.0/TRACIUM-IMPL-PLAN.md +749 -0
  17. agentobs-1.0.0/docs/Makefile +16 -0
  18. agentobs-1.0.0/docs/_static/.gitkeep +2 -0
  19. agentobs-1.0.0/docs/api/compliance.md +173 -0
  20. agentobs-1.0.0/docs/api/consumer.md +212 -0
  21. agentobs-1.0.0/docs/api/deprecations.md +190 -0
  22. agentobs-1.0.0/docs/api/event.md +243 -0
  23. agentobs-1.0.0/docs/api/exceptions.md +209 -0
  24. agentobs-1.0.0/docs/api/export.md +596 -0
  25. agentobs-1.0.0/docs/api/governance.md +159 -0
  26. agentobs-1.0.0/docs/api/index.md +44 -0
  27. agentobs-1.0.0/docs/api/integrations.md +176 -0
  28. agentobs-1.0.0/docs/api/migrate.md +216 -0
  29. agentobs-1.0.0/docs/api/models.md +137 -0
  30. agentobs-1.0.0/docs/api/redact.md +214 -0
  31. agentobs-1.0.0/docs/api/signing.md +227 -0
  32. agentobs-1.0.0/docs/api/stream.md +256 -0
  33. agentobs-1.0.0/docs/api/types.md +220 -0
  34. agentobs-1.0.0/docs/api/ulid.md +111 -0
  35. agentobs-1.0.0/docs/api/validate.md +82 -0
  36. agentobs-1.0.0/docs/changelog.md +344 -0
  37. agentobs-1.0.0/docs/cli.md +384 -0
  38. agentobs-1.0.0/docs/conf.py +128 -0
  39. agentobs-1.0.0/docs/contributing.md +130 -0
  40. agentobs-1.0.0/docs/index.md +90 -0
  41. agentobs-1.0.0/docs/installation.md +65 -0
  42. agentobs-1.0.0/docs/make.bat +35 -0
  43. agentobs-1.0.0/docs/namespaces/audit.md +133 -0
  44. agentobs-1.0.0/docs/namespaces/cache.md +88 -0
  45. agentobs-1.0.0/docs/namespaces/cost.md +56 -0
  46. agentobs-1.0.0/docs/namespaces/diff.md +56 -0
  47. agentobs-1.0.0/docs/namespaces/eval.md +58 -0
  48. agentobs-1.0.0/docs/namespaces/fence.md +52 -0
  49. agentobs-1.0.0/docs/namespaces/guard.md +27 -0
  50. agentobs-1.0.0/docs/namespaces/index.md +60 -0
  51. agentobs-1.0.0/docs/namespaces/prompt.md +60 -0
  52. agentobs-1.0.0/docs/namespaces/redact_ns.md +56 -0
  53. agentobs-1.0.0/docs/namespaces/template.md +63 -0
  54. agentobs-1.0.0/docs/namespaces/trace.md +72 -0
  55. agentobs-1.0.0/docs/quickstart.md +171 -0
  56. agentobs-1.0.0/docs/schema/README.md +300 -0
  57. agentobs-1.0.0/docs/schema/envelope.schema.json +182 -0
  58. agentobs-1.0.0/docs/schema/payloads/agent-run.schema.json +145 -0
  59. agentobs-1.0.0/docs/schema/payloads/agent-step.schema.json +198 -0
  60. agentobs-1.0.0/docs/schema/payloads/audit.schema.json +171 -0
  61. agentobs-1.0.0/docs/schema/payloads/cache.schema.json +193 -0
  62. agentobs-1.0.0/docs/schema/payloads/cost.schema.json +138 -0
  63. agentobs-1.0.0/docs/schema/payloads/diff.schema.json +150 -0
  64. agentobs-1.0.0/docs/schema/payloads/eval.schema.json +251 -0
  65. agentobs-1.0.0/docs/schema/payloads/fence.schema.json +181 -0
  66. agentobs-1.0.0/docs/schema/payloads/guard.schema.json +125 -0
  67. agentobs-1.0.0/docs/schema/payloads/prompt.schema.json +181 -0
  68. agentobs-1.0.0/docs/schema/payloads/redact.schema.json +189 -0
  69. agentobs-1.0.0/docs/schema/payloads/span.schema.json +195 -0
  70. agentobs-1.0.0/docs/schema/payloads/template.schema.json +192 -0
  71. agentobs-1.0.0/docs/schema/types/common.schema.json +512 -0
  72. agentobs-1.0.0/docs/user_guide/compliance.md +119 -0
  73. agentobs-1.0.0/docs/user_guide/events.md +121 -0
  74. agentobs-1.0.0/docs/user_guide/export.md +283 -0
  75. agentobs-1.0.0/docs/user_guide/governance.md +227 -0
  76. agentobs-1.0.0/docs/user_guide/index.md +15 -0
  77. agentobs-1.0.0/docs/user_guide/migration.md +192 -0
  78. agentobs-1.0.0/docs/user_guide/redaction.md +120 -0
  79. agentobs-1.0.0/docs/user_guide/signing.md +146 -0
  80. agentobs-1.0.0/examples/agent_workflow.py +55 -0
  81. agentobs-1.0.0/examples/langchain_chain.py +46 -0
  82. agentobs-1.0.0/examples/openai_chat.py +48 -0
  83. agentobs-1.0.0/examples/secure_pipeline.py +54 -0
  84. agentobs-1.0.0/implementationplan.md +525 -0
  85. agentobs-1.0.0/llm-schema_Enterprise_Product_Spec.docx +0 -0
  86. agentobs-1.0.0/pyproject.toml +202 -0
  87. agentobs-1.0.0/schemas/v1.0/schema.json +117 -0
  88. agentobs-1.0.0/test_agent.jsonl +2 -0
  89. agentobs-1.0.0/test_events.jsonl +1 -0
  90. agentobs-1.0.0/tests/__init__.py +1 -0
  91. agentobs-1.0.0/tests/conftest.py +97 -0
  92. agentobs-1.0.0/tests/test_actor.py +155 -0
  93. agentobs-1.0.0/tests/test_benchmarks.py +135 -0
  94. agentobs-1.0.0/tests/test_cli.py +342 -0
  95. agentobs-1.0.0/tests/test_compliance.py +494 -0
  96. agentobs-1.0.0/tests/test_consumer.py +242 -0
  97. agentobs-1.0.0/tests/test_deprecations.py +213 -0
  98. agentobs-1.0.0/tests/test_event.py +833 -0
  99. agentobs-1.0.0/tests/test_exceptions.py +134 -0
  100. agentobs-1.0.0/tests/test_export_datadog.py +392 -0
  101. agentobs-1.0.0/tests/test_export_grafana.py +285 -0
  102. agentobs-1.0.0/tests/test_export_jsonl.py +380 -0
  103. agentobs-1.0.0/tests/test_export_otel_bridge.py +403 -0
  104. agentobs-1.0.0/tests/test_export_otlp.py +1080 -0
  105. agentobs-1.0.0/tests/test_export_webhook.py +458 -0
  106. agentobs-1.0.0/tests/test_governance.py +212 -0
  107. agentobs-1.0.0/tests/test_integration.py +132 -0
  108. agentobs-1.0.0/tests/test_integrations.py +500 -0
  109. agentobs-1.0.0/tests/test_migrate.py +160 -0
  110. agentobs-1.0.0/tests/test_models.py +481 -0
  111. agentobs-1.0.0/tests/test_namespaces.py +951 -0
  112. agentobs-1.0.0/tests/test_phase11_security.py +257 -0
  113. agentobs-1.0.0/tests/test_phase5_coverage.py +859 -0
  114. agentobs-1.0.0/tests/test_policy_and_streaming.py +723 -0
  115. agentobs-1.0.0/tests/test_redact.py +637 -0
  116. agentobs-1.0.0/tests/test_sdk_config.py +266 -0
  117. agentobs-1.0.0/tests/test_sdk_coverage_boost.py +1032 -0
  118. agentobs-1.0.0/tests/test_sdk_exporters.py +465 -0
  119. agentobs-1.0.0/tests/test_sdk_final_coverage.py +847 -0
  120. agentobs-1.0.0/tests/test_sdk_gap_filler.py +367 -0
  121. agentobs-1.0.0/tests/test_sdk_openai_integration.py +753 -0
  122. agentobs-1.0.0/tests/test_sdk_phase7_integrations.py +1019 -0
  123. agentobs-1.0.0/tests/test_sdk_precision_coverage.py +182 -0
  124. agentobs-1.0.0/tests/test_sdk_span.py +472 -0
  125. agentobs-1.0.0/tests/test_sdk_stream.py +307 -0
  126. agentobs-1.0.0/tests/test_sdk_tracer.py +216 -0
  127. agentobs-1.0.0/tests/test_sdk_validation_coverage.py +930 -0
  128. agentobs-1.0.0/tests/test_signing.py +843 -0
  129. agentobs-1.0.0/tests/test_stream.py +576 -0
  130. agentobs-1.0.0/tests/test_types.py +332 -0
  131. agentobs-1.0.0/tests/test_ulid.py +370 -0
  132. agentobs-1.0.0/tests/test_validate.py +408 -0
  133. agentobs-1.0.0/tracium/__init__.py +449 -0
  134. agentobs-1.0.0/tracium/_cli.py +481 -0
  135. agentobs-1.0.0/tracium/_span.py +649 -0
  136. agentobs-1.0.0/tracium/_stream.py +282 -0
  137. agentobs-1.0.0/tracium/_tracer.py +164 -0
  138. agentobs-1.0.0/tracium/actor.py +141 -0
  139. agentobs-1.0.0/tracium/compliance/__init__.py +53 -0
  140. agentobs-1.0.0/tracium/compliance/_compat.py +209 -0
  141. agentobs-1.0.0/tracium/compliance/test_chain.py +221 -0
  142. agentobs-1.0.0/tracium/compliance/test_isolation.py +265 -0
  143. agentobs-1.0.0/tracium/config.py +171 -0
  144. agentobs-1.0.0/tracium/consumer.py +379 -0
  145. agentobs-1.0.0/tracium/deprecations.py +314 -0
  146. agentobs-1.0.0/tracium/event.py +892 -0
  147. agentobs-1.0.0/tracium/exceptions.py +214 -0
  148. agentobs-1.0.0/tracium/export/__init__.py +35 -0
  149. agentobs-1.0.0/tracium/export/datadog.py +484 -0
  150. agentobs-1.0.0/tracium/export/grafana.py +333 -0
  151. agentobs-1.0.0/tracium/export/jsonl.py +198 -0
  152. agentobs-1.0.0/tracium/export/otel_bridge.py +292 -0
  153. agentobs-1.0.0/tracium/export/otlp.py +766 -0
  154. agentobs-1.0.0/tracium/export/webhook.py +278 -0
  155. agentobs-1.0.0/tracium/exporters/__init__.py +29 -0
  156. agentobs-1.0.0/tracium/exporters/console.py +270 -0
  157. agentobs-1.0.0/tracium/exporters/jsonl.py +144 -0
  158. agentobs-1.0.0/tracium/governance.py +287 -0
  159. agentobs-1.0.0/tracium/integrations/__init__.py +33 -0
  160. agentobs-1.0.0/tracium/integrations/_pricing.py +212 -0
  161. agentobs-1.0.0/tracium/integrations/anthropic.py +388 -0
  162. agentobs-1.0.0/tracium/integrations/groq.py +444 -0
  163. agentobs-1.0.0/tracium/integrations/langchain.py +315 -0
  164. agentobs-1.0.0/tracium/integrations/llamaindex.py +329 -0
  165. agentobs-1.0.0/tracium/integrations/ollama.py +286 -0
  166. agentobs-1.0.0/tracium/integrations/openai.py +366 -0
  167. agentobs-1.0.0/tracium/integrations/together.py +485 -0
  168. agentobs-1.0.0/tracium/migrate.py +296 -0
  169. agentobs-1.0.0/tracium/models.py +407 -0
  170. agentobs-1.0.0/tracium/namespaces/__init__.py +167 -0
  171. agentobs-1.0.0/tracium/namespaces/audit.py +181 -0
  172. agentobs-1.0.0/tracium/namespaces/cache.py +209 -0
  173. agentobs-1.0.0/tracium/namespaces/cost.py +175 -0
  174. agentobs-1.0.0/tracium/namespaces/diff.py +146 -0
  175. agentobs-1.0.0/tracium/namespaces/eval_.py +232 -0
  176. agentobs-1.0.0/tracium/namespaces/fence.py +180 -0
  177. agentobs-1.0.0/tracium/namespaces/guard.py +104 -0
  178. agentobs-1.0.0/tracium/namespaces/prompt.py +185 -0
  179. agentobs-1.0.0/tracium/namespaces/redact.py +172 -0
  180. agentobs-1.0.0/tracium/namespaces/template.py +197 -0
  181. agentobs-1.0.0/tracium/namespaces/trace.py +872 -0
  182. agentobs-1.0.0/tracium/py.typed +0 -0
  183. agentobs-1.0.0/tracium/redact.py +529 -0
  184. agentobs-1.0.0/tracium/signing.py +580 -0
  185. agentobs-1.0.0/tracium/stream.py +548 -0
  186. agentobs-1.0.0/tracium/types.py +419 -0
  187. agentobs-1.0.0/tracium/ulid.py +294 -0
  188. agentobs-1.0.0/tracium/validate.py +292 -0
@@ -0,0 +1,2 @@
1
+ # Auto detect text files and perform LF normalization
2
+ * text=auto
@@ -0,0 +1,147 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: ["main", "develop"]
6
+ pull_request:
7
+ branches: ["main", "develop"]
8
+ workflow_dispatch:
9
+
10
+ concurrency:
11
+ group: ${{ github.workflow }}-${{ github.ref }}
12
+ cancel-in-progress: true
13
+
14
+ env:
15
+ PYTHONUNBUFFERED: "1"
16
+ FORCE_COLOR: "1"
17
+ PIP_DISABLE_PIP_VERSION_CHECK: "1"
18
+
19
+ jobs:
20
+ # ──────────────────────────────────────────────────────────────────────────
21
+ # Lint & type-check (fast gate — runs on one Python version only)
22
+ # ──────────────────────────────────────────────────────────────────────────
23
+ lint:
24
+ name: Lint & type-check
25
+ runs-on: ubuntu-latest
26
+ steps:
27
+ - uses: actions/checkout@v4
28
+
29
+ - name: Set up Python 3.12
30
+ uses: actions/setup-python@v5
31
+ with:
32
+ python-version: "3.12"
33
+ cache: pip
34
+
35
+ - name: Install dev dependencies
36
+ run: pip install -e ".[dev]"
37
+
38
+ - name: Run ruff (lint)
39
+ run: ruff check --output-format=github .
40
+
41
+ - name: Run ruff (format check)
42
+ run: ruff format --check .
43
+
44
+ - name: Run mypy (strict)
45
+ run: mypy llm_toolkit_schema tests
46
+
47
+ # ──────────────────────────────────────────────────────────────────────────
48
+ # Test matrix (3.9 → 3.12)
49
+ # ──────────────────────────────────────────────────────────────────────────
50
+ test:
51
+ name: "Python ${{ matrix.python-version }} / ${{ matrix.os }}"
52
+ needs: lint
53
+ runs-on: ${{ matrix.os }}
54
+ strategy:
55
+ fail-fast: false
56
+ matrix:
57
+ os: [ubuntu-latest, windows-latest]
58
+ python-version: ["3.9", "3.10", "3.11", "3.12"]
59
+ exclude:
60
+ # Reduce Windows CI load — only test oldest and newest
61
+ - os: windows-latest
62
+ python-version: "3.10"
63
+ - os: windows-latest
64
+ python-version: "3.11"
65
+
66
+ steps:
67
+ - uses: actions/checkout@v4
68
+
69
+ - name: Set up Python ${{ matrix.python-version }}
70
+ uses: actions/setup-python@v5
71
+ with:
72
+ python-version: ${{ matrix.python-version }}
73
+ cache: pip
74
+
75
+ - name: Install package + dev extras
76
+ run: pip install -e ".[dev]"
77
+
78
+ - name: Run unit & integration tests with coverage
79
+ run: >
80
+ pytest
81
+ --tb=short
82
+ --strict-markers
83
+ -v
84
+ --cov=llm_toolkit_schema
85
+ --cov-report=term-missing
86
+ --cov-report=xml:coverage.xml
87
+ --cov-fail-under=100
88
+ -m "not perf"
89
+
90
+ - name: Upload coverage to Codecov
91
+ if: matrix.python-version == '3.12' && matrix.os == 'ubuntu-latest'
92
+ uses: codecov/codecov-action@v4
93
+ with:
94
+ files: coverage.xml
95
+ fail_ci_if_error: false
96
+
97
+ # ──────────────────────────────────────────────────────────────────────────
98
+ # Performance benchmarks (single run on Python 3.12 / ubuntu)
99
+ # ──────────────────────────────────────────────────────────────────────────
100
+ perf:
101
+ name: Performance benchmarks
102
+ needs: test
103
+ runs-on: ubuntu-latest
104
+ steps:
105
+ - uses: actions/checkout@v4
106
+
107
+ - name: Set up Python 3.12
108
+ uses: actions/setup-python@v5
109
+ with:
110
+ python-version: "3.12"
111
+ cache: pip
112
+
113
+ - name: Install package + dev extras
114
+ run: pip install -e ".[dev]"
115
+
116
+ - name: Run performance tests
117
+ run: >
118
+ pytest
119
+ -m "perf"
120
+ --tb=short
121
+ -v
122
+
123
+ # ──────────────────────────────────────────────────────────────────────────
124
+ # Security scan via pip-audit
125
+ # ──────────────────────────────────────────────────────────────────────────
126
+ security:
127
+ name: pip-audit
128
+ runs-on: ubuntu-latest
129
+ steps:
130
+ - uses: actions/checkout@v4
131
+
132
+ - name: Set up Python 3.12
133
+ uses: actions/setup-python@v5
134
+ with:
135
+ python-version: "3.12"
136
+ cache: pip
137
+
138
+ - name: Install pip-audit
139
+ run: pip install pip-audit
140
+
141
+ - name: Audit dependencies
142
+ run: pip-audit --require-hashes -r <(pip install -e ".[dev]" --dry-run --report json | python -c "
143
+ import json, sys
144
+ data = json.load(sys.stdin)
145
+ for item in data.get('install', []):
146
+ print(item['metadata']['name'] + '==' + item['metadata']['version'])
147
+ " || echo "skipped") 2>/dev/null || pip-audit
@@ -0,0 +1,181 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py,cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ #uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ #poetry.lock
109
+
110
+ # pdm
111
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
112
+ #pdm.lock
113
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
114
+ # in version control.
115
+ # https://pdm.fming.dev/latest/usage/project/#working-with-version-control
116
+ .pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
121
+ __pypackages__/
122
+
123
+ # Celery stuff
124
+ celerybeat-schedule
125
+ celerybeat.pid
126
+
127
+ # SageMath parsed files
128
+ *.sage.py
129
+
130
+ # Environments
131
+ .env
132
+ .venv
133
+ env/
134
+ venv/
135
+ ENV/
136
+ env.bak/
137
+ venv.bak/
138
+
139
+ # Spyder project settings
140
+ .spyderproject
141
+ .spyproject
142
+
143
+ # Rope project settings
144
+ .ropeproject
145
+
146
+ # mkdocs documentation
147
+ /site
148
+
149
+ # mypy
150
+ .mypy_cache/
151
+ .dmypy.json
152
+ dmypy.json
153
+
154
+ # Pyre type checker
155
+ .pyre/
156
+
157
+ # pytype static type analyzer
158
+ .pytype/
159
+
160
+ # Cython debug symbols
161
+ cython_debug/
162
+
163
+ # PyCharm
164
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
165
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
166
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
167
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
168
+ #.idea/
169
+
170
+ # Ruff stuff:
171
+ .ruff_cache/
172
+
173
+ # PyPI configuration file
174
+ .pypirc
175
+
176
+ # Cursor
177
+ # Cursor is an AI-powered code editor.`.cursorignore` specifies files/directories to
178
+ # exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
179
+ # refer to https://docs.cursor.com/context/ignore-files
180
+ .cursorignore
181
+ .cursorindexingignore
@@ -0,0 +1,62 @@
1
+ repos:
2
+ # ── Core file hygiene ─────────────────────────────────────────────────────
3
+ - repo: https://github.com/pre-commit/pre-commit-hooks
4
+ rev: v4.6.0
5
+ hooks:
6
+ - id: trailing-whitespace
7
+ - id: end-of-file-fixer
8
+ - id: check-yaml
9
+ - id: check-toml
10
+ - id: check-json
11
+ - id: check-added-large-files
12
+ args: [--maxkb=500]
13
+ - id: check-merge-conflict
14
+ - id: debug-statements
15
+ - id: detect-private-key
16
+ - id: mixed-line-ending
17
+ args: [--fix=lf]
18
+ - id: no-commit-to-branch
19
+ args: [--branch, main]
20
+
21
+ # ── Ruff (lint + format) ──────────────────────────────────────────────────
22
+ - repo: https://github.com/astral-sh/ruff-pre-commit
23
+ rev: v0.4.10
24
+ hooks:
25
+ - id: ruff
26
+ args: [--fix, --exit-non-zero-on-fix]
27
+ - id: ruff-format
28
+
29
+ # ── mypy ─────────────────────────────────────────────────────────────────
30
+ - repo: https://github.com/pre-commit/mirrors-mypy
31
+ rev: v1.10.1
32
+ hooks:
33
+ - id: mypy
34
+ additional_dependencies:
35
+ - pytest>=8.0
36
+ args: [--strict]
37
+ pass_filenames: false
38
+ entry: mypy llm_toolkit_schema tests
39
+
40
+ # ── Validate pyproject.toml structure ─────────────────────────────────────
41
+ - repo: https://github.com/abravalheri/validate-pyproject
42
+ rev: v0.18
43
+ hooks:
44
+ - id: validate-pyproject
45
+
46
+ # ── Commit message linting (Conventional Commits) ─────────────────────────
47
+ - repo: https://github.com/compilerla/conventional-pre-commit
48
+ rev: v3.2.0
49
+ hooks:
50
+ - id: conventional-pre-commit
51
+ stages: [commit-msg]
52
+ args: [feat, fix, docs, style, refactor, perf, test, chore, ci, build, revert]
53
+
54
+ default_install_hook_types:
55
+ - pre-commit
56
+ - commit-msg
57
+
58
+ ci:
59
+ autofix_prs: true
60
+ autoupdate_schedule: monthly
61
+ skip:
62
+ - mypy # mypy requires the package installed; only run in CI matrix
@@ -0,0 +1,18 @@
1
+ # Read the Docs configuration file — https://docs.readthedocs.io/en/stable/config-file/v2.html
2
+ version: 2
3
+
4
+ build:
5
+ os: ubuntu-24.04
6
+ tools:
7
+ python: "3.13"
8
+
9
+ sphinx:
10
+ configuration: docs/conf.py
11
+ fail_on_warning: false
12
+
13
+ python:
14
+ install:
15
+ - method: pip
16
+ path: .
17
+ extra_requirements:
18
+ - docs
agentobs-1.0.0/CNAME ADDED
@@ -0,0 +1 @@
1
+ llmtoolkitschema.getspanforege.com
@@ -0,0 +1,251 @@
1
+ # Code Audit Report
2
+
3
+ Date: 2026-03-01
4
+ Repository: `llm-toolkit-schema`
5
+ Scope: Coding standards, performance, security, hallucination controls, and observability
6
+
7
+ ## Executive Summary
8
+
9
+ - The codebase is generally high quality with strong typing, clear module boundaries, and extensive tests.
10
+ - Functional tests pass (`1214 passed`), but CI currently fails due to strict coverage gate (`97.71%` vs required `100%`).
11
+ - Highest-impact issues are: mutable event payload despite immutability claims, validation/signature format drift, partially implemented governance behavior, and exporter hardening/performance gaps.
12
+
13
+ ## Verification Performed
14
+
15
+ - Static inspection of core modules:
16
+ - `llm_toolkit_schema/event.py`
17
+ - `llm_toolkit_schema/validate.py`
18
+ - `llm_toolkit_schema/signing.py`
19
+ - `llm_toolkit_schema/governance.py`
20
+ - `llm_toolkit_schema/stream.py`
21
+ - `llm_toolkit_schema/export/*.py`
22
+ - `llm_toolkit_schema/namespaces/*.py`
23
+ - `llm_toolkit_schema/_cli.py`
24
+ - Grep-based scans for broad exception handling and risky patterns.
25
+ - Test run: `python -m pytest -q` in project venv.
26
+
27
+ ## Findings by Category
28
+
29
+ ### 1) Coding Standards & Correctness
30
+
31
+ #### 1.1 Event immutability contract is violated (High)
32
+
33
+ **Observation**
34
+ - The documentation promises immutability after creation, but `Event.payload` returns the internal mutable dict directly.
35
+
36
+ **Risk**
37
+ - Consumers can mutate payloads post-validation/signing, leading to data integrity bugs and confusing behavior.
38
+
39
+ **Evidence**
40
+ - `llm_toolkit_schema/event.py` (`payload` property returns `_payload` directly).
41
+
42
+ **Recommended Fix**
43
+ - Return a defensive copy or read-only mapping (`MappingProxyType`) in `payload` property.
44
+ - Optionally deep-freeze nested structures at construction if strict immutability is required.
45
+ - Add tests that verify mutation attempts do not alter internal event state.
46
+
47
+ #### 1.2 Governance `strict_unknown` field is unused (Medium)
48
+
49
+ **Observation**
50
+ - `strict_unknown` exists in `EventGovernancePolicy`, but no logic uses it in `check_event`.
51
+
52
+ **Risk**
53
+ - Misleading API: users assume strict unknown handling exists when it does not.
54
+
55
+ **Evidence**
56
+ - `llm_toolkit_schema/governance.py` (field present, no behavior branch).
57
+
58
+ **Recommended Fix**
59
+ - Implement strict behavior: block/warn unknown event types when `strict_unknown=True`.
60
+ - Or remove the field/docs until behavior is fully implemented.
61
+
62
+ #### 1.3 Broad exception handling in user-facing ingestion paths (Medium)
63
+
64
+ **Observation**
65
+ - Broad `except Exception` blocks are used in CLI and stream parsing paths.
66
+
67
+ **Risk**
68
+ - Can mask root causes and leak low-level/internal exception text into user output.
69
+
70
+ **Evidence**
71
+ - `llm_toolkit_schema/_cli.py`
72
+ - `llm_toolkit_schema/stream.py`
73
+
74
+ **Recommended Fix**
75
+ - Catch typed exceptions (`JSONDecodeError`, `DeserializationError`, etc.).
76
+ - Preserve structured diagnostics internally while providing sanitized user messages.
77
+
78
+ ### 2) Security
79
+
80
+ #### 2.1 Validation/signature format mismatch (High)
81
+
82
+ **Observation**
83
+ - Signing code emits prefixed values:
84
+ - checksum: `sha256:<hex>`
85
+ - signature: `hmac-sha256:<hex>`
86
+ - Stdlib fallback validator currently validates both fields as bare 64-hex.
87
+
88
+ **Risk**
89
+ - Signed valid events may fail schema validation in fallback path.
90
+ - Security/validation logic drift can cause reject/accept inconsistencies.
91
+
92
+ **Evidence**
93
+ - `llm_toolkit_schema/signing.py`
94
+ - `llm_toolkit_schema/validate.py`
95
+
96
+ **Recommended Fix**
97
+ - Use dedicated patterns:
98
+ - checksum: `^sha256:[0-9a-f]{64}$`
99
+ - signature: `^hmac-sha256:[0-9a-f]{64}$`
100
+ - Align with published JSON schema and model validators.
101
+
102
+ #### 2.2 Exporter endpoint hardening gaps (Medium)
103
+
104
+ **Observation**
105
+ - Webhook/OTLP/Grafana URLs and Datadog site are accepted with minimal validation.
106
+
107
+ **Risk**
108
+ - SSRF-like misconfiguration, accidental local-network targeting, or malformed host injection in operational setups.
109
+
110
+ **Evidence**
111
+ - `llm_toolkit_schema/export/webhook.py`
112
+ - `llm_toolkit_schema/export/otlp.py`
113
+ - `llm_toolkit_schema/export/grafana.py`
114
+ - `llm_toolkit_schema/export/datadog.py`
115
+
116
+ **Recommended Fix**
117
+ - Parse and validate URLs at construction:
118
+ - Enforce allowed schemes (`https` by default; configurable `http` for local dev).
119
+ - Optional denylist for localhost/private CIDRs unless explicitly enabled.
120
+ - Strict hostname validation for `dd_site`.
121
+
122
+ #### 2.3 Datadog fallback IDs are not deterministic across runs (Medium)
123
+
124
+ **Observation**
125
+ - Uses `hash()` fallback for trace/span IDs.
126
+
127
+ **Risk**
128
+ - Python hash randomization yields unstable IDs across processes; trace correlation can break.
129
+
130
+ **Evidence**
131
+ - `llm_toolkit_schema/export/datadog.py`
132
+
133
+ **Recommended Fix**
134
+ - Replace fallback with stable derivation (e.g., SHA-256 truncation).
135
+
136
+ ### 3) Performance & Scalability
137
+
138
+ #### 3.1 OTLP `batch_size` is configured but not enforced (Medium)
139
+
140
+ **Observation**
141
+ - `batch_size` is stored and documented, but `export_batch` does not chunk by it.
142
+
143
+ **Risk**
144
+ - Large batches may cause oversized payloads, memory spikes, and network backpressure issues.
145
+
146
+ **Evidence**
147
+ - `llm_toolkit_schema/export/otlp.py`
148
+
149
+ **Recommended Fix**
150
+ - Implement chunking in `export_batch` using `self._batch_size` and send per chunk.
151
+
152
+ #### 3.2 In-memory accumulation for ingestion constructors (Medium)
153
+
154
+ **Observation**
155
+ - `from_file`, `from_queue`, `from_async_queue`, `from_async_iter`, and `from_kafka` collect all events into lists.
156
+
157
+ **Risk**
158
+ - High memory use for long streams or large files.
159
+
160
+ **Evidence**
161
+ - `llm_toolkit_schema/stream.py`
162
+
163
+ **Recommended Fix**
164
+ - Provide iterator/async-iterator streaming alternatives and bounded/limit options.
165
+
166
+ #### 3.3 Datadog exporter uses current wall clock instead of event timestamp (Low-Medium)
167
+
168
+ **Observation**
169
+ - Span start time/metric timestamps are based on `time.time()` rather than event timestamp.
170
+
171
+ **Risk**
172
+ - Distorted observability timelines and inaccurate replay analysis.
173
+
174
+ **Evidence**
175
+ - `llm_toolkit_schema/export/datadog.py`
176
+
177
+ **Recommended Fix**
178
+ - Parse and use `event.timestamp` for temporal fidelity.
179
+
180
+ ### 4) Hallucination & Agentic Safety Controls
181
+
182
+ #### 4.1 Guard/fence modules are schema-only, not enforcement (Medium)
183
+
184
+ **Observation**
185
+ - Namespaces provide payload data classes for guard/fence events, but no runtime policy engine exists here.
186
+
187
+ **Risk**
188
+ - Teams may assume these modules enforce anti-hallucination behavior by default.
189
+
190
+ **Evidence**
191
+ - `llm_toolkit_schema/namespaces/guard.py`
192
+ - `llm_toolkit_schema/namespaces/fence.py`
193
+ - `llm_toolkit_schema/namespaces/template.py`
194
+
195
+ **Recommended Fix**
196
+ - Add explicit runtime policy hooks (or a companion enforcement module):
197
+ - pre-generation input guard checks
198
+ - post-generation output validation and retry policy
199
+ - citation/grounding validation hooks
200
+ - configurable fail-open/fail-closed behavior
201
+
202
+ ## Observability Posture
203
+
204
+ ### Strengths
205
+
206
+ - Strong event envelope model with trace/org/team/session metadata.
207
+ - Dedicated exporters for OTLP, Datadog, Grafana, webhook, and JSONL.
208
+ - Signing/audit-chain support for tamper evidence.
209
+ - Comprehensive tests and high effective coverage.
210
+
211
+ ### Gaps
212
+
213
+ - Timestamp normalization inconsistency across exporters.
214
+ - Some documented behavior not fully implemented (`strict_unknown`, `batch_size`).
215
+ - Hardening guards for egress endpoints should be stronger for production use.
216
+
217
+ ## Prioritized Remediation Plan
218
+
219
+ ### P0 (Immediate)
220
+
221
+ 1. Fix validator/signature format alignment in `validate.py`.
222
+ 2. Enforce event payload immutability contract in `event.py`.
223
+
224
+ ### P1 (Next)
225
+
226
+ 3. Implement `strict_unknown` governance behavior (or remove option).
227
+ 4. Enforce OTLP exporter chunking by configured `batch_size`.
228
+ 5. Replace Datadog `hash()` fallback IDs with deterministic cryptographic derivation.
229
+
230
+ ### P2 (Hardening)
231
+
232
+ 6. Add URL/site validation and safe egress options in exporters.
233
+ 7. Add streaming ingestion APIs to avoid full-memory accumulation.
234
+ 8. Introduce explicit runtime guardrail/fence enforcement hooks and docs.
235
+
236
+ ## Suggested Acceptance Criteria for Fixes
237
+
238
+ - New unit tests for each fix path and regression scenario.
239
+ - No behavioral drift in existing passing tests.
240
+ - Compatibility docs updated where behavior changes are user-visible.
241
+ - Security-sensitive changes reviewed with threat-model checklist.
242
+
243
+ ## Test Status (at time of audit)
244
+
245
+ - Command: `python -m pytest -q`
246
+ - Result: Functional tests passed (`1214 passed`), process exited non-zero due to coverage gate.
247
+ - Coverage gate failure: total coverage below required threshold (`97.71%` vs `100%`).
248
+
249
+ ---
250
+
251
+ If needed, I can generate a follow-up implementation patch set that addresses P0 + P1 items with tests.