Skip to content

feat(log): add log viewing provider#335

Merged
retr0h merged 19 commits into
mainfrom
feat/log-management-provider
Apr 1, 2026
Merged

feat(log): add log viewing provider#335
retr0h merged 19 commits into
mainfrom
feat/log-management-provider

Conversation

@retr0h

@retr0h retr0h commented Apr 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add read-only log viewing provider that queries systemd journal entries via journalctl --output=json
  • Two endpoints: GET /node/{hostname}/log (query all) and GET /node/{hostname}/log/unit/{name} (query by unit)
  • Optional query params: lines (default 100), since (time filter), priority (0-7 or name)
  • Full cross-layer implementation: provider, agent processor, API handlers, SDK service, CLI commands
  • log:read permission added to all built-in roles (admin, write, read)
  • Container-aware: returns ErrUnsupported in containers (journalctl requires systemd)
  • Broadcast support for all operations

Test plan

  • Unit tests pass (just go::unit)
  • Lint clean (just go::vet)
  • Integration test covers query and unit endpoints
  • Verify on Debian host: osapi client node log query --target _any
  • Verify on Debian host: osapi client node log unit --target _any --name sshd.service
  • Verify broadcast: osapi client node log query --target _all
  • Verify --json output for both commands
  • Verify skipped status on Darwin/container

🤖 Generated with Claude Code

retr0h and others added 13 commits March 31, 2026 17:55
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
…ntation

Add the log provider package at internal/provider/node/log/ with a
Provider interface for querying systemd journal entries, Darwin and
Linux stubs returning ErrUnsupported, and a Debian implementation
using journalctl --output=json with full JSON parsing and filtering.

🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Add OpLogQuery and OpLogQueryUnit operation constants to the SDK,
OperationLog* aliases in the job types, PermLogRead permission across
all roles, processLogOperation processor dispatching query/queryUnit
sub-ops, and createLogProvider factory wired into NewNodeProcessor and
the agent registry.

🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Add OpenAPI spec for log management domain with two endpoints:
GET /node/{hostname}/log and GET /node/{hostname}/log/unit/{name}.
Regenerate combined spec and SDK client with new log types.

🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.ai/code)
Add LogService with Query and QueryUnit methods wrapping the generated
OpenAPI client. Includes result types, gen→SDK conversions, export
bridges, and full httptest.Server test coverage for all HTTP paths.

🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Add feature page, CLI subcommand docs, SDK doc page, and SDK example
for the log management provider. Update cross-references in features
table, authentication, configuration, architecture, API guidelines,
Docusaurus navbar, and SDK client overview to include log:read.

🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
retr0h and others added 2 commits March 31, 2026 20:12
…oding

The Query/QueryBroadcast methods accept `any` and call json.Marshal
internally. Pre-marshalling to []byte caused double-encoding — the
agent received a JSON string instead of the expected object.

Co-Authored-By: Claude <noreply@anthropic.com>
Add ListSources operation across all layers — runs
`journalctl --field=SYSLOG_IDENTIFIER` to discover available
log sources. New endpoint: GET /node/{hostname}/log/source.

Also add missing test coverage for query params and timestamp
edge cases to bring all new code to 100% statement coverage.

Co-Authored-By: Claude <noreply@anthropic.com>
@codecov

codecov Bot commented Apr 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #335      +/-   ##
==========================================
+ Coverage   99.82%   99.89%   +0.07%     
==========================================
  Files         383      396      +13     
  Lines       17648    18200     +552     
==========================================
+ Hits        17617    18181     +564     
+ Misses         19       11       -8     
+ Partials       12        8       -4     
Files with missing lines Coverage Δ
internal/agent/processor.go 100.00% <100.00%> (ø)
internal/agent/processor_log.go 100.00% <100.00%> (ø)
internal/authtoken/permissions.go 100.00% <ø> (ø)
internal/controller/api/node/log/handler.go 100.00% <100.00%> (ø)
internal/controller/api/node/log/log.go 100.00% <100.00%> (ø)
internal/controller/api/node/log/log_query_get.go 100.00% <100.00%> (ø)
internal/controller/api/node/log/log_source_get.go 100.00% <100.00%> (ø)
internal/controller/api/node/log/log_unit_get.go 100.00% <100.00%> (ø)
internal/controller/api/node/log/validate.go 100.00% <100.00%> (ø)
internal/provider/node/log/darwin.go 100.00% <100.00%> (ø)
... and 6 more

... and 2 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1f2d33b...3a275cd. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

retr0h and others added 4 commits March 31, 2026 21:02
- Add TestProcessLogSources and query unmarshal error test
- Add size field to package handler test data to cover Size > 0 branch

Co-Authored-By: Claude <noreply@anthropic.com>
Follow project convention: one suite method per function, all
scenarios as rows in one table.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
…eferences

The ListSources operation was added to code but docs were not updated:
- Add CLI doc for source subcommand
- Add /log/source to api-guidelines endpoint table
- Add Sources to feature page operations table and CLI examples
- Add Sources method and LogSourceResult to SDK doc
- Add Sources demo to SDK example
- Update features landing page description

Co-Authored-By: Claude <noreply@anthropic.com>
@retr0h retr0h merged commit 5d9a550 into main Apr 1, 2026
11 checks passed
@retr0h retr0h deleted the feat/log-management-provider branch April 1, 2026 04:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant