logwarden v0.4.0¶
Status: Released 2026-11-18 · tag v0.4.0.
Safe to adopt on an existing service: record what's there today, fail only on new problems, and switch off a rule with a written reason. Three new rules cover secrets and personal data, lines that aren't JSON, and malformed trace context.
What's new¶
- Baseline.
logwarden baseline logs.jsonlwrites.logwarden-baseline.jsonwith the current findings. When a baseline is configured (baseline = ".logwarden-baseline.json"),checkfails only on findings that aren't in it. Findings are matched by rule, field, logger and event name with numbers and ids masked, not by line number, so they survive code moving around.check --baseline FILEand--no-baselineoverride the config. The result reports how many findings the baseline hid and how many baseline entries no longer occur (fixed), so the baseline can be shrunk. - Disable a rule, with a reason.
disable = { adr_event_name = "legacy events, see JIRA-123" }. An empty reason, an unknown rule id or the list formdisable = ["..."]is an error (exit 2). Disabled rules and their reasons are listed in every result, so they stay visible. - New rule
adr_sensitive_data(§8). Fails on: - field names such as
password,secret,api_key,authorization,cookie,*_token(also inside nested objects), unless the value is redacted (***,[REDACTED], …); - values that look like a JWT, a
Bearertoken, a known API-key format (OpenAI/Anthropicsk-, GitHub, GitLab, AWSAKIA, Slack, GoogleAIza), a private-key block, credentials in a URL (scheme://user:pass@), an email address, or a card number (checked with the Luhn checksum).
The message names the field and the kind of data, never the value itself, so findings
are safe to print in CI.
- New rule adr_non_json_line (§1). A line that isn't a JSON object (a plain-text
banner, a traceback printed by a library, a JSON array) is a violation. Blank lines are
still ignored. Before, such lines were only counted in skipped_lines.
- New rule adr_trace_context (§3, §7). trace_id must be 32 lowercase hex characters
and span_id 16, not all zeros (the W3C format), and span_id needs a trace_id.
- Source linters in the agent instructions. The skill and the AGENTS.md snippet tell
agents to run Ruff LOG/G/TRY400 (Python) or sloglint (Go) when the project uses them,
and never to silence findings by adding them to the baseline or disable unless asked.
Fixes¶
- A line whose
event,trace_idorspan_idis not a string (a number, an object, …) made Weaver reject the whole input, socheckfailed with exit 2 for every line. Such values are now converted to strings and reported by the rules (adr_event_name,adr_trace_context). adr_failure_contextcited §12, the section number in the old ai-suite ADR. It now cites §10 of the canonical standard. The rule id is unchanged.
Breaking changes¶
- Lines that aren't JSON objects now fail the check (
adr_non_json_line) instead of only being counted. If the input mixes in output that isn't the service's logs, capture only the service's output, or setdisable = { adr_non_json_line = "<reason>" }. - Logs that contain the patterns above now fail
adr_sensitive_data. --jsongains keys (baselined,baseline,baseline_fixed,disabled); existing keys keep their meaning. When a baseline ordisableapplies,violations,by_ruleandfindingscount only the findings that still fail.
Upgrading from v0.3.0¶
uv add --dev logwarden@0.4.0 # CI: uses: Ingeniator/logwarden@v0.4.0
logwarden check logs.jsonl # new rules may report findings
# To adopt gradually on an existing service:
logwarden baseline logs.jsonl # writes .logwarden-baseline.json; commit it
# pyproject.toml
# [tool.logwarden]
# baseline = ".logwarden-baseline.json"
Claude Code: /plugin update logwarden@logwarden.
Verification¶
CI run 44250655963 (commit 39f0df6):
86 tests passed on each of ubuntu py3.10, ubuntu py3.13, macos py3.13 and windows py3.13;
action, package and plugin jobs passed.
| # | Claim | How it was checked | Result |
|---|---|---|---|
| 1 | Existing results unchanged apart from the listed changes | v0.3.0 from PyPI (uvx logwarden==0.3.0) vs v0.4.0 with the three new rules disabled: --json identical (apart from version, the new keys and §12 → §10) on good (0 violations), bad (7), the edge-case file (16) and yallmp's 573 lines (2843). The goldens were then regenerated and the diff reviewed: only the new rules' findings, §10 and the header wording (blank or non-JSON lines) changed |
✅ |
| 2 | Baseline: only new findings fail; matching survives line moves and changed numbers | test_baseline.py: re-check passes with baselined 3; reordered lines with Loaded 7 models vs Loaded 3 models still match while one new finding fails; fixed entries counted in baseline_fixed and shown in text; --baseline, --no-baseline, config path, --output; missing or malformed baseline → exit 2; the non-JSON entry stores a hash, not the line |
✅ |
| 3 | Baseline works on a real service | yallmp (433 tests, 573 lines): logwarden baseline wrote 417 entries covering 2843 findings, and check passed with 2843 known. A new test in the scratchpad with one new log call, structlog.get_logger("app.feature.export").info("Exported 12 rows", path=...) (434 tests, 574 lines): check exited 1 with exactly that line's 5 findings (event name, path synonym, 3 required fields). yallmp's working tree untouched |
✅ |
| 4 | disable needs a reason and stays visible |
test_config.py: disabled rules don't fail and are listed with reason and count in JSON and text; list form, empty reason, non-string reason and unknown rule → exit 2 with the message |
✅ |
| 5 | adr_sensitive_data catches each listed pattern, without false positives on normal fields, and never prints the value |
test_new_rules.py: 18 positive cases (each key name family, nested keys, JWT, Bearer, sk-, ghp_, AKIA, xoxb-, AIza, PEM, two URL forms, email, card as text and as int) and 6 negative groups (redacted values, nested redacted, token counts, booleans, Luhn-invalid id, ns timestamp, UUID, date, URL without credentials, hex sha, task-…); no secret appears anywhere in the JSON result. yallmp: 0 findings; reviewed by hand: its test traffic has no credentials (headers are host/accept/user-agent) |
✅ |
| 6 | adr_non_json_line flags non-JSON and non-object lines, not blank ones |
test_new_rules.py: plain text, array, number, string, null flagged with their kind; blank and whitespace lines ignored; the line text is not in the result |
✅ |
| 7 | adr_trace_context checks W3C format |
test_new_rules.py: valid pair and trace-only pass; uppercase, wrong length, all zeros, non-hex, a number and span-only fail |
✅ |
| 8 | A non-string event/trace_id/span_id no longer breaks the run |
test_new_rules.py with numbers, floats, objects, lists and booleans: exit 1, all 3 lines checked, adr_event_name ("not a JSON boolean", …) and adr_trace_context reported. On v0.3.0 the same input exits 2 |
✅ |
| 9 | Every rule is documented and wired | test_rules_wired.py: every rule has a rules.json entry, a docs/rules.md section and a link from docs/standard.md; rules.json has no extra rules; examples/bad.jsonl triggers every logwarden rule |
✅ |
| 10 | MCP check_logs applies the project's baseline and disable |
test_mcp.py (stdio, all OSes): a configured but missing baseline returns an error; after logwarden baseline, check_logs returns ok, baselined > 0 and the disabled rule with its reason |
✅ |
| 11 | Plugin and snippet carry the new agent guidance | claude plugin validate --strict passes for the marketplace and the plugin (also in CI). The skill and the AGENTS snippet mention Ruff/sloglint and forbid running logwarden baseline or disable unless asked |
✅ |
| 12 | CI green on Linux, macOS, Windows; release publishes | CI above. Dry run: release run 44251039651 published 0.4.0.dev3 to TestPyPI; uvx logwarden==0.4.0.dev3 check examples/bad.jsonl from a clean environment with an empty Weaver cache exits 1 with all 10 rules. Real publish: tag v0.4.0 → release run 44251550832 published 0.4.0 to PyPI and created the GitHub release. From PyPI in a clean environment with an empty Weaver cache: uvx logwarden==0.4.0 check examples/bad.jsonl exits 1 with 10 rules, good.jsonl passes, and uvx --from 'logwarden[mcp]==0.4.0' logwarden mcp serves all 4 tools |
✅ |