logwarden 0.3.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.
- logwarden-0.3.0/.gitignore +8 -0
- logwarden-0.3.0/CHANGELOG.md +9 -0
- logwarden-0.3.0/LICENSE +202 -0
- logwarden-0.3.0/PKG-INFO +114 -0
- logwarden-0.3.0/README.md +89 -0
- logwarden-0.3.0/docs/integration.md +97 -0
- logwarden-0.3.0/docs/releases/v0.1.0.md +25 -0
- logwarden-0.3.0/docs/releases/v0.2.0.md +43 -0
- logwarden-0.3.0/docs/releases/v0.3.0.md +71 -0
- logwarden-0.3.0/docs/roadmap.md +85 -0
- logwarden-0.3.0/docs/rules.md +118 -0
- logwarden-0.3.0/docs/standard.md +160 -0
- logwarden-0.3.0/examples/bad.jsonl +3 -0
- logwarden-0.3.0/examples/good.jsonl +2 -0
- logwarden-0.3.0/plugin/README.md +18 -0
- logwarden-0.3.0/pyproject.toml +59 -0
- logwarden-0.3.0/src/logwarden/__init__.py +7 -0
- logwarden-0.3.0/src/logwarden/__main__.py +5 -0
- logwarden-0.3.0/src/logwarden/_data/policies/logwarden.rego +101 -0
- logwarden-0.3.0/src/logwarden/_data/registry/logwarden.yaml +33 -0
- logwarden-0.3.0/src/logwarden/_data/registry/manifest.yaml +6 -0
- logwarden-0.3.0/src/logwarden/_data/rules.json +56 -0
- logwarden-0.3.0/src/logwarden/_data/templates/AGENTS.snippet.md +14 -0
- logwarden-0.3.0/src/logwarden/_data/templates/logwarden-fields.yaml +24 -0
- logwarden-0.3.0/src/logwarden/_data/weaver.toml +3 -0
- logwarden-0.3.0/src/logwarden/check.py +222 -0
- logwarden-0.3.0/src/logwarden/cli.py +187 -0
- logwarden-0.3.0/src/logwarden/config.py +56 -0
- logwarden-0.3.0/src/logwarden/data.py +30 -0
- logwarden-0.3.0/src/logwarden/mcp_server.py +95 -0
- logwarden-0.3.0/src/logwarden/output.py +37 -0
- logwarden-0.3.0/src/logwarden/pytest_plugin.py +48 -0
- logwarden-0.3.0/src/logwarden/weaver.py +123 -0
- logwarden-0.3.0/tests/conftest.py +27 -0
- logwarden-0.3.0/tests/data/mixed.jsonl +9 -0
- logwarden-0.3.0/tests/golden/bad.json +125 -0
- logwarden-0.3.0/tests/golden/bad.txt +40 -0
- logwarden-0.3.0/tests/golden/good.json +18 -0
- logwarden-0.3.0/tests/golden/good.txt +4 -0
- logwarden-0.3.0/tests/golden/mixed.json +188 -0
- logwarden-0.3.0/tests/golden/mixed.txt +49 -0
- logwarden-0.3.0/tests/test_cli.py +101 -0
- logwarden-0.3.0/tests/test_config.py +59 -0
- logwarden-0.3.0/tests/test_convert.py +29 -0
- logwarden-0.3.0/tests/test_init.py +25 -0
- logwarden-0.3.0/tests/test_mcp.py +57 -0
- logwarden-0.3.0/tests/test_parity.py +33 -0
- logwarden-0.3.0/tests/test_pytest_plugin.py +27 -0
- logwarden-0.3.0/tests/test_versions.py +14 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
Full release notes, each with a verification table, are in [docs/releases/](docs/releases/).
|
|
4
|
+
|
|
5
|
+
| Version | Status | Summary |
|
|
6
|
+
|---|---|---|
|
|
7
|
+
| [v0.3.0](docs/releases/v0.3.0.md) | Released 2026-11-18 | One PyPI package for every channel: Python CLI, pytest plugin, MCP, Claude Code plugin |
|
|
8
|
+
| [v0.2.0](docs/releases/v0.2.0.md) | Released 2026-11-17 | Project fields file, agent-friendly findings, pytest plugin, MCP server, docs and skill |
|
|
9
|
+
| [v0.1.0](docs/releases/v0.1.0.md) | Released 2026-11-17 | First check of JSON logs against the logging standard on OTel Weaver |
|
logwarden-0.3.0/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
logwarden-0.3.0/PKG-INFO
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: logwarden
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: Guardrail for structured logs: checks JSON logs against an OpenTelemetry-based logging standard
|
|
5
|
+
Project-URL: Homepage, https://github.com/Ingeniator/logwarden
|
|
6
|
+
Project-URL: Documentation, https://github.com/Ingeniator/logwarden/blob/main/docs/integration.md
|
|
7
|
+
Project-URL: Changelog, https://github.com/Ingeniator/logwarden/blob/main/CHANGELOG.md
|
|
8
|
+
Author: Ingeniator
|
|
9
|
+
License-Expression: Apache-2.0
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: ci,lint,logging,mcp,observability,opentelemetry,semconv,structlog
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: Framework :: Pytest
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
19
|
+
Classifier: Topic :: System :: Logging
|
|
20
|
+
Requires-Python: >=3.10
|
|
21
|
+
Requires-Dist: tomli>=2; python_version < '3.11'
|
|
22
|
+
Provides-Extra: mcp
|
|
23
|
+
Requires-Dist: mcp<3,>=2; extra == 'mcp'
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
|
|
26
|
+
# logwarden
|
|
27
|
+
|
|
28
|
+
A guardrail for logs. logwarden reads the JSON logs your service actually writes and flags
|
|
29
|
+
every line that would make debugging harder: ad-hoc field names, missing service info,
|
|
30
|
+
free-text events, and errors that don't say what failed. It exits with code 1 on
|
|
31
|
+
problems, so CI and AI agents can use it the way they use tests.
|
|
32
|
+
|
|
33
|
+
It checks output, not source code, so it works for any language. Field names follow
|
|
34
|
+
[OpenTelemetry semantic conventions](https://opentelemetry.io/docs/specs/semconv/registry/attributes/),
|
|
35
|
+
the names traces and metrics already use, so logs, traces and metrics can be queried together.
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
$ uvx logwarden check logs.jsonl
|
|
39
|
+
logwarden: 573 records, 2843 violations
|
|
40
|
+
|
|
41
|
+
539 adr_event_name - Event is a constant snake_case name
|
|
42
|
+
fix: Use a fixed name like import_completed and move variable data into fields
|
|
43
|
+
e.g. §4: event 'Loaded 3 models' must be a constant snake_case name
|
|
44
|
+
|
|
45
|
+
findings (first 20):
|
|
46
|
+
line 1 adr_event_name §4: event 'Loaded 3 models' must be a constant snake_case name
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## What it checks
|
|
50
|
+
|
|
51
|
+
| Rule | Fails on |
|
|
52
|
+
|---|---|
|
|
53
|
+
| `adr_banned_synonym` | `status=500` instead of `http.response.status_code=500` |
|
|
54
|
+
| `adr_semconv_prefix` | `http_route` instead of `http.route` |
|
|
55
|
+
| `missing_attribute` | a field that isn't semconv and isn't declared by the project |
|
|
56
|
+
| `deprecated` | a renamed semconv field (`gen_ai.system`) |
|
|
57
|
+
| `adr_missing_required` | no `service.name`, `service.version` or `deployment.environment.name` |
|
|
58
|
+
| `adr_environment_value` | `dev` instead of `development` |
|
|
59
|
+
| `adr_event_name` | `event="Loaded 3 models"` instead of `models_loaded` |
|
|
60
|
+
| `adr_failure_context` | an error line without `exception.type`, `error.type` or a status code |
|
|
61
|
+
|
|
62
|
+
The standard is in [docs/standard.md](https://github.com/Ingeniator/logwarden/blob/main/docs/standard.md), and each rule's fix is in
|
|
63
|
+
[docs/rules.md](https://github.com/Ingeniator/logwarden/blob/main/docs/rules.md).
|
|
64
|
+
|
|
65
|
+
## Use it in a project
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
uv add --dev logwarden # or: pipx install logwarden / uvx logwarden
|
|
69
|
+
logwarden init --agent # fields file + AGENTS.md section
|
|
70
|
+
LOGWARDEN_CAPTURE=logs.jsonl pytest # capture logs (pytest plugin, auto-registered)
|
|
71
|
+
logwarden check logs.jsonl # check them
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
```yaml
|
|
75
|
+
# CI
|
|
76
|
+
- uses: Ingeniator/logwarden@v0.3.0
|
|
77
|
+
with:
|
|
78
|
+
logs: logs.jsonl
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Project settings go in `[tool.logwarden]` in `pyproject.toml`, or in `logwarden.toml`.
|
|
82
|
+
See [docs/integration.md](https://github.com/Ingeniator/logwarden/blob/main/docs/integration.md) for capturing logs from any stack,
|
|
83
|
+
project-only fields and migrating a legacy service.
|
|
84
|
+
|
|
85
|
+
## For AI agents
|
|
86
|
+
|
|
87
|
+
- **Claude Code:** `/plugin marketplace add Ingeniator/logwarden`, then
|
|
88
|
+
`/plugin install logwarden@logwarden`. This gives a skill for writing good logs, the MCP
|
|
89
|
+
server and `/logwarden:check`.
|
|
90
|
+
- **Other agents:** `logwarden init --agent` adds a logwarden section to `AGENTS.md`. The MCP
|
|
91
|
+
server runs with `uvx --from 'logwarden[mcp]' logwarden mcp` and provides `check_logs`,
|
|
92
|
+
`explain_rule`, `list_rules` and `get_standard`.
|
|
93
|
+
- **Machine output:** `logwarden check --json` gives each finding's line number, rule and
|
|
94
|
+
fix hint.
|
|
95
|
+
- **Agents working on this repo:** read [AGENTS.md](https://github.com/Ingeniator/logwarden/blob/main/AGENTS.md).
|
|
96
|
+
|
|
97
|
+
## How it works
|
|
98
|
+
|
|
99
|
+
Each log line becomes a sample for [OTel Weaver](https://github.com/open-telemetry/weaver)
|
|
100
|
+
`registry live-check`. Weaver checks the sample's field names against the semconv
|
|
101
|
+
registry (plus logwarden's shared fields and the project's `logwarden-fields.yaml`) and
|
|
102
|
+
runs the rules in `src/logwarden/_data/policies/logwarden.rego`. Python 3.10+ on Linux,
|
|
103
|
+
macOS or Windows. Weaver is downloaded on first use and checked against its published
|
|
104
|
+
SHA-256.
|
|
105
|
+
|
|
106
|
+
## Not covered yet
|
|
107
|
+
|
|
108
|
+
See [docs/roadmap.md](https://github.com/Ingeniator/logwarden/blob/main/docs/roadmap.md). Next up: baseline mode for legacy services, a
|
|
109
|
+
sensitive-data rule, non-JSON lines, and a logging-setup library. Release notes are in
|
|
110
|
+
[CHANGELOG.md](https://github.com/Ingeniator/logwarden/blob/main/CHANGELOG.md).
|
|
111
|
+
|
|
112
|
+
## License
|
|
113
|
+
|
|
114
|
+
[Apache-2.0](https://github.com/Ingeniator/logwarden/blob/main/LICENSE)
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# logwarden
|
|
2
|
+
|
|
3
|
+
A guardrail for logs. logwarden reads the JSON logs your service actually writes and flags
|
|
4
|
+
every line that would make debugging harder: ad-hoc field names, missing service info,
|
|
5
|
+
free-text events, and errors that don't say what failed. It exits with code 1 on
|
|
6
|
+
problems, so CI and AI agents can use it the way they use tests.
|
|
7
|
+
|
|
8
|
+
It checks output, not source code, so it works for any language. Field names follow
|
|
9
|
+
[OpenTelemetry semantic conventions](https://opentelemetry.io/docs/specs/semconv/registry/attributes/),
|
|
10
|
+
the names traces and metrics already use, so logs, traces and metrics can be queried together.
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
$ uvx logwarden check logs.jsonl
|
|
14
|
+
logwarden: 573 records, 2843 violations
|
|
15
|
+
|
|
16
|
+
539 adr_event_name - Event is a constant snake_case name
|
|
17
|
+
fix: Use a fixed name like import_completed and move variable data into fields
|
|
18
|
+
e.g. §4: event 'Loaded 3 models' must be a constant snake_case name
|
|
19
|
+
|
|
20
|
+
findings (first 20):
|
|
21
|
+
line 1 adr_event_name §4: event 'Loaded 3 models' must be a constant snake_case name
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## What it checks
|
|
25
|
+
|
|
26
|
+
| Rule | Fails on |
|
|
27
|
+
|---|---|
|
|
28
|
+
| `adr_banned_synonym` | `status=500` instead of `http.response.status_code=500` |
|
|
29
|
+
| `adr_semconv_prefix` | `http_route` instead of `http.route` |
|
|
30
|
+
| `missing_attribute` | a field that isn't semconv and isn't declared by the project |
|
|
31
|
+
| `deprecated` | a renamed semconv field (`gen_ai.system`) |
|
|
32
|
+
| `adr_missing_required` | no `service.name`, `service.version` or `deployment.environment.name` |
|
|
33
|
+
| `adr_environment_value` | `dev` instead of `development` |
|
|
34
|
+
| `adr_event_name` | `event="Loaded 3 models"` instead of `models_loaded` |
|
|
35
|
+
| `adr_failure_context` | an error line without `exception.type`, `error.type` or a status code |
|
|
36
|
+
|
|
37
|
+
The standard is in [docs/standard.md](https://github.com/Ingeniator/logwarden/blob/main/docs/standard.md), and each rule's fix is in
|
|
38
|
+
[docs/rules.md](https://github.com/Ingeniator/logwarden/blob/main/docs/rules.md).
|
|
39
|
+
|
|
40
|
+
## Use it in a project
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
uv add --dev logwarden # or: pipx install logwarden / uvx logwarden
|
|
44
|
+
logwarden init --agent # fields file + AGENTS.md section
|
|
45
|
+
LOGWARDEN_CAPTURE=logs.jsonl pytest # capture logs (pytest plugin, auto-registered)
|
|
46
|
+
logwarden check logs.jsonl # check them
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
```yaml
|
|
50
|
+
# CI
|
|
51
|
+
- uses: Ingeniator/logwarden@v0.3.0
|
|
52
|
+
with:
|
|
53
|
+
logs: logs.jsonl
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Project settings go in `[tool.logwarden]` in `pyproject.toml`, or in `logwarden.toml`.
|
|
57
|
+
See [docs/integration.md](https://github.com/Ingeniator/logwarden/blob/main/docs/integration.md) for capturing logs from any stack,
|
|
58
|
+
project-only fields and migrating a legacy service.
|
|
59
|
+
|
|
60
|
+
## For AI agents
|
|
61
|
+
|
|
62
|
+
- **Claude Code:** `/plugin marketplace add Ingeniator/logwarden`, then
|
|
63
|
+
`/plugin install logwarden@logwarden`. This gives a skill for writing good logs, the MCP
|
|
64
|
+
server and `/logwarden:check`.
|
|
65
|
+
- **Other agents:** `logwarden init --agent` adds a logwarden section to `AGENTS.md`. The MCP
|
|
66
|
+
server runs with `uvx --from 'logwarden[mcp]' logwarden mcp` and provides `check_logs`,
|
|
67
|
+
`explain_rule`, `list_rules` and `get_standard`.
|
|
68
|
+
- **Machine output:** `logwarden check --json` gives each finding's line number, rule and
|
|
69
|
+
fix hint.
|
|
70
|
+
- **Agents working on this repo:** read [AGENTS.md](https://github.com/Ingeniator/logwarden/blob/main/AGENTS.md).
|
|
71
|
+
|
|
72
|
+
## How it works
|
|
73
|
+
|
|
74
|
+
Each log line becomes a sample for [OTel Weaver](https://github.com/open-telemetry/weaver)
|
|
75
|
+
`registry live-check`. Weaver checks the sample's field names against the semconv
|
|
76
|
+
registry (plus logwarden's shared fields and the project's `logwarden-fields.yaml`) and
|
|
77
|
+
runs the rules in `src/logwarden/_data/policies/logwarden.rego`. Python 3.10+ on Linux,
|
|
78
|
+
macOS or Windows. Weaver is downloaded on first use and checked against its published
|
|
79
|
+
SHA-256.
|
|
80
|
+
|
|
81
|
+
## Not covered yet
|
|
82
|
+
|
|
83
|
+
See [docs/roadmap.md](https://github.com/Ingeniator/logwarden/blob/main/docs/roadmap.md). Next up: baseline mode for legacy services, a
|
|
84
|
+
sensitive-data rule, non-JSON lines, and a logging-setup library. Release notes are in
|
|
85
|
+
[CHANGELOG.md](https://github.com/Ingeniator/logwarden/blob/main/CHANGELOG.md).
|
|
86
|
+
|
|
87
|
+
## License
|
|
88
|
+
|
|
89
|
+
[Apache-2.0](https://github.com/Ingeniator/logwarden/blob/main/LICENSE)
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# Connecting a project to logwarden
|
|
2
|
+
|
|
3
|
+
Four steps: install, capture logs, check in CI, set up agents. Each step is independent,
|
|
4
|
+
and most projects need about 10 lines of config.
|
|
5
|
+
|
|
6
|
+
## 1. Install
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
uv add --dev logwarden # Python projects: CLI + pytest capture plugin
|
|
10
|
+
pipx install logwarden # or a global CLI
|
|
11
|
+
uvx logwarden check logs.jsonl # or no install at all (needs uv)
|
|
12
|
+
|
|
13
|
+
logwarden init --agent # logwarden-fields.yaml + a logwarden section in AGENTS.md
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Weaver, which does the actual checking, is downloaded on first run into the user cache
|
|
17
|
+
directory. Set `WEAVER` to use your own binary.
|
|
18
|
+
|
|
19
|
+
## 2. Capture the logs your code produces
|
|
20
|
+
|
|
21
|
+
logwarden checks real output, so the project needs a run that produces logs: tests,
|
|
22
|
+
or a smoke run. Include failure cases (500s, timeouts). §10 of the standard is
|
|
23
|
+
about exactly those lines.
|
|
24
|
+
|
|
25
|
+
**Python / pytest.** With `logwarden` installed (as a dev dependency), the capture plugin is
|
|
26
|
+
registered automatically:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
LOGWARDEN_CAPTURE=logs.jsonl pytest
|
|
30
|
+
# without adding a dependency:
|
|
31
|
+
LOGWARDEN_CAPTURE=logs.jsonl uv run --with logwarden pytest
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
The plugin does nothing unless `LOGWARDEN_CAPTURE` is set. It writes each log line the
|
|
35
|
+
service formats to that file, at `INFO` and above (`LOGWARDEN_LEVEL` changes this). It
|
|
36
|
+
works with structlog routed through stdlib `logging`, which is the setup in the standard.
|
|
37
|
+
|
|
38
|
+
**Containers (any language):**
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
docker compose up -d myservice && ./smoke-test.sh
|
|
42
|
+
docker compose logs --no-log-prefix --no-color myservice > logs.jsonl
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
**Anything else:** save the service's stdout to a file, or pipe it in:
|
|
46
|
+
`./run-tests 2>&1 | logwarden check -`. Lines that aren't JSON are skipped and counted.
|
|
47
|
+
|
|
48
|
+
## 3. Check in CI
|
|
49
|
+
|
|
50
|
+
GitHub Actions:
|
|
51
|
+
|
|
52
|
+
```yaml
|
|
53
|
+
- run: LOGWARDEN_CAPTURE=logs.jsonl uv run pytest
|
|
54
|
+
- uses: Ingeniator/logwarden@v0.3.0
|
|
55
|
+
with:
|
|
56
|
+
logs: logs.jsonl
|
|
57
|
+
# fail: "false" # report only, while a legacy service is being migrated
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Other CI systems: `uvx logwarden==0.3.0 check logs.jsonl`. The exit code is 0 when the logs
|
|
61
|
+
are clean, 1 when there are violations, and 2 when setup failed.
|
|
62
|
+
|
|
63
|
+
**Migrating an existing service:** start with `fail: "false"`, fix the logging setup
|
|
64
|
+
first (it clears `adr_missing_required` on every line at once), then the call sites. Turn
|
|
65
|
+
`fail` back on when the count reaches zero.
|
|
66
|
+
|
|
67
|
+
## 4. Project config and project-only fields
|
|
68
|
+
|
|
69
|
+
```toml
|
|
70
|
+
# pyproject.toml (or the same keys at top level in logwarden.toml)
|
|
71
|
+
[tool.logwarden]
|
|
72
|
+
fields = "logwarden-fields.yaml"
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
`fields` lists fields only this service logs. When there's no config, `./logwarden-fields.yaml`
|
|
76
|
+
is used if it exists. The template that `logwarden init` creates explains the format and
|
|
77
|
+
when a field belongs there. Fields that several services share go into logwarden's
|
|
78
|
+
shared registry instead, through a PR to this repo.
|
|
79
|
+
|
|
80
|
+
The order of precedence is `--fields`, then `$LOGWARDEN_FIELDS`, then the config, then
|
|
81
|
+
`./logwarden-fields.yaml`. Unknown config keys produce a warning.
|
|
82
|
+
|
|
83
|
+
## 5. AI agents
|
|
84
|
+
|
|
85
|
+
Agents should check the logs of the code they write, the same way they run tests.
|
|
86
|
+
|
|
87
|
+
| Agent | Setup |
|
|
88
|
+
|---|---|
|
|
89
|
+
| Claude Code | `/plugin marketplace add Ingeniator/logwarden`, then `/plugin install logwarden@logwarden`. This gives the skill, the MCP server (via `uvx`, so uv must be installed) and `/logwarden:check` |
|
|
90
|
+
| Other agents (Codex, Cursor, …) | `logwarden init --agent` adds a logwarden section to `AGENTS.md`. For MCP: `uvx --from 'logwarden[mcp]' logwarden mcp` |
|
|
91
|
+
|
|
92
|
+
MCP tools: `check_logs(path | lines)`, `explain_rule(rule_id)`, `list_rules()`,
|
|
93
|
+
`get_standard()`. Agents with shell access can use `logwarden check --json` instead. Both
|
|
94
|
+
give the same result.
|
|
95
|
+
|
|
96
|
+
The skill tells the agent to fix findings in its own changes, never silence them,
|
|
97
|
+
and not to rewrite unrelated legacy logging unless asked.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# logwarden v0.1.0
|
|
2
|
+
|
|
3
|
+
**Status:** Released 2026-11-17 · commit `c0382c8`
|
|
4
|
+
|
|
5
|
+
First version: a command-line check of JSON logs against the ai-suite logging standard (ADR-0001).
|
|
6
|
+
|
|
7
|
+
## What's in it
|
|
8
|
+
|
|
9
|
+
- `bin/logwarden check <logs.jsonl>` converts each log line into a sample for OTel Weaver
|
|
10
|
+
`registry live-check` and prints the number of violations per rule. It exits with code 1
|
|
11
|
+
when it finds a violation.
|
|
12
|
+
- Rules (Rego): `adr_banned_synonym`, `adr_semconv_prefix`, `adr_missing_required`,
|
|
13
|
+
`adr_environment_value`, `adr_event_name`, `adr_failure_context`. Weaver adds
|
|
14
|
+
`missing_attribute` and `deprecated`.
|
|
15
|
+
- Registry: OTel semconv v1.45.0 plus shared fields (`logger`, `request_id`, `duration_ms`,
|
|
16
|
+
`upstream_request_id`, `upstream_error_message`).
|
|
17
|
+
- GitHub Action (`uses: Ingeniator/logwarden@v0.1.0`), and `make test` / `make check`.
|
|
18
|
+
|
|
19
|
+
## Verification
|
|
20
|
+
|
|
21
|
+
| Claim | How it was checked | Result |
|
|
22
|
+
|---|---|---|
|
|
23
|
+
| Good logs pass, bad logs fail each rule | `tests/smoke.sh` locally and in CI | ✅ CI run 44161866309 |
|
|
24
|
+
| Matches the earlier Weaver trial on yallmp | 570 lines → 1710 / 536 / 241 for the three main rules, same as the trial | ✅ |
|
|
25
|
+
| Overlay registries work, including from a git tag | Overlay with `group_id` as a local path and as `…@v0.1.0[registry]` | ✅ |
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# logwarden v0.2.0
|
|
2
|
+
|
|
3
|
+
**Status:** Released 2026-11-17 · commit `6740972`
|
|
4
|
+
|
|
5
|
+
This version makes logwarden usable by other projects and AI agents: findings point to
|
|
6
|
+
the exact line and say how to fix it, and logs can be captured from tests.
|
|
7
|
+
|
|
8
|
+
## What's new
|
|
9
|
+
|
|
10
|
+
- **Project fields file.** Projects list their own fields in `logwarden-fields.yaml`,
|
|
11
|
+
which is picked up automatically (or passed with `--fields`), and pin logwarden in only
|
|
12
|
+
one place.
|
|
13
|
+
- **Findings an agent can act on.** Each finding has the input line number, the rule, the
|
|
14
|
+
field and a fix hint. `--json` returns everything in machine-readable form. A field
|
|
15
|
+
flagged as a banned synonym is no longer also reported as unknown.
|
|
16
|
+
- **Messages that give the fix.** `status` → "use http.response.status_code", `http_route`
|
|
17
|
+
→ "probably 'http.route'".
|
|
18
|
+
- **Reads stdin.** `… | logwarden check -`. Lines that aren't JSON are counted as skipped.
|
|
19
|
+
- **New commands.** `logwarden rules [id]`, `logwarden init [--agent]`, `logwarden setup`.
|
|
20
|
+
Weaver downloads itself on first use.
|
|
21
|
+
- **pytest plugin** `logwarden-pytest`: `LOGWARDEN_CAPTURE=logs.jsonl pytest`.
|
|
22
|
+
- **MCP server** `mcp/server.py` with `check_logs`, `explain_rule`, `list_rules` and
|
|
23
|
+
`get_standard`.
|
|
24
|
+
- **Docs** `docs/standard.md`, `docs/rules.md`, `docs/integration.md`. `AGENTS.md`, a
|
|
25
|
+
skill, and an `AGENTS.md` snippet for other projects.
|
|
26
|
+
- **Action.** New `fields` and `fail` inputs, plus a job summary.
|
|
27
|
+
|
|
28
|
+
## Upgrading from v0.1.0
|
|
29
|
+
|
|
30
|
+
- Change `uses: Ingeniator/logwarden@v0.1.0` to `@v0.2.0`.
|
|
31
|
+
- Rule messages now start with `§N:` instead of `ADR-0001 §N:`. Rule ids are unchanged.
|
|
32
|
+
|
|
33
|
+
## Verification
|
|
34
|
+
|
|
35
|
+
| Claim | How it was checked | Result |
|
|
36
|
+
|---|---|---|
|
|
37
|
+
| Smoke test: every rule, line numbers, skipped count, no double report, `--fields`, stdin | 15 checks in `tests/smoke.sh` | ✅ |
|
|
38
|
+
| Works with macOS bash 3.2 | The local `bash` is 3.2.57 | ✅ |
|
|
39
|
+
| Action passes on good logs, fails on bad logs, `fail: "false"` only reports | CI job `action` | ✅ CI run 44168075637 |
|
|
40
|
+
| pytest plugin installs and captures | Clean venv locally, and CI job `pytest-plugin` | ✅ |
|
|
41
|
+
| Plugin works on a real service | yallmp: 433 tests pass, 573 JSON lines captured | ✅ |
|
|
42
|
+
| MCP tools work, including a pasted JSON line | stdio client against `mcp/server.py` with mcp 2.x | ✅ |
|
|
43
|
+
| `init --agent` can be run twice safely | Ran twice; `AGENTS.md` has one section | ✅ |
|