* Implement log retention policy
- Added Append method to io.Medium interface and implementations.
- Defined RotationOptions and updated log.Options to support log rotation.
- Implemented RotatingWriter in pkg/log/rotation.go with size and age-based retention.
- Updated Logger to use RotatingWriter when configured.
- Added comprehensive tests for log rotation and retention.
- Documented the log retention policy in docs/pkg/log.md and docs/configuration.md.
- Fixed MockMedium to return current time for Stat to avoid premature cleanup in tests.
* Fix formatting issues in pkg/io/local/client.go
The CI failed due to formatting issues. This commit fixes them and ensures all modified files are properly formatted.
* Fix auto-merge workflow CI failure
Inlined the auto-merge logic and added actions/checkout and --repo flag to gh command to provide the necessary git context. This resolves the 'fatal: not a git repository' error in CI.
* Address feedback on log retention policy
- Made cleanup synchronous in RotatingWriter for better reliability.
- Improved rotation error handling with recovery logic.
- Fixed size tracking to only increment on successful writes.
- Updated MockMedium to support and preserve ModTimes for age-based testing.
- Added TestRotatingWriter_AgeRetention and TestLogger_RotationIntegration.
- Implemented negative MaxAge to disable age-based retention.
- Updated documentation for clarity on Output priority and MaxAge behavior.
- Fixed typo in test comments.
- Fixed CI failure in auto-merge workflow.
---------
Co-authored-by: Claude <developers@lethean.io>
* feat(log): log all errors at handling point with context
This change ensures all errors are logged at the point where they are
handled, including contextual information such as operations and
logical stack traces.
Key changes:
- Added `StackTrace` and `FormatStackTrace` to `pkg/log/errors.go`.
- Enhanced `Logger.log` in `pkg/log/log.go` to automatically extract
and log `op` and `stack` keys when an error is passed in keyvals.
- Updated CLI logging and output helpers to support structured logging.
- Updated CLI fatal error handlers to log errors before exiting.
- Audited and updated error logging in MCP service (tool handlers and
TCP transport), CLI background services (signal and health), and
Agentic task handlers.
* feat(log): log all errors at handling point with context
This change ensures all errors are logged at the point where they are
handled, including contextual information such as operations and
logical stack traces.
Key changes:
- Added `StackTrace` and `FormatStackTrace` to `pkg/log/errors.go`.
- Enhanced `Logger.log` in `pkg/log/log.go` to automatically extract
and log `op` and `stack` keys when an error is passed in keyvals.
- Updated CLI logging and output helpers to support structured logging.
- Updated CLI fatal error handlers to log errors before exiting.
- Audited and updated error logging in MCP service (tool handlers and
TCP transport), CLI background services (signal and health), and
Agentic task handlers.
- Fixed formatting in `pkg/mcp/mcp.go` and `pkg/io/local/client.go`.
- Removed unused `fmt` import in `pkg/cli/runtime.go`.
* feat(log): log all errors at handling point with context
This change ensures all errors are logged at the point where they are
handled, including contextual information such as operations and
logical stack traces.
Key changes:
- Added `StackTrace` and `FormatStackTrace` to `pkg/log/errors.go`.
- Enhanced `Logger.log` in `pkg/log/log.go` to automatically extract
and log `op` and `stack` keys when an error is passed in keyvals.
- Updated CLI logging and output helpers to support structured logging.
- Updated CLI fatal error handlers to log errors before exiting.
- Audited and updated error logging in MCP service (tool handlers and
TCP transport), CLI background services (signal and health), and
Agentic task handlers.
- Fixed formatting in `pkg/mcp/mcp.go` and `pkg/io/local/client.go`.
- Removed unused `fmt` import in `pkg/cli/runtime.go`.
- Fixed CI failure in `auto-merge` workflow by providing explicit
repository context to the GitHub CLI.
* feat(log): address PR feedback and improve error context extraction
Addressed feedback from PR review:
- Improved `Fatalf` and other fatal functions in `pkg/cli/errors.go` to
use structured logging for the formatted message.
- Added direct unit tests for `StackTrace` and `FormatStackTrace` in
`pkg/log/errors_test.go`, covering edge cases like plain errors,
nil errors, and mixed error chains.
- Optimized the automatic context extraction loop in `pkg/log/log.go`
by capturing the original length of keyvals.
- Fixed a bug in `StackTrace` where operations were duplicated when
the error chain included non-`*log.Err` errors.
- Fixed formatting and unused imports from previous commits.
* fix: address code review comments
- Simplify Fatalf logging by removing redundant format parameter
(the formatted message is already logged as "msg")
- Tests for StackTrace/FormatStackTrace edge cases already exist
- Loop optimization in pkg/log/log.go already implemented
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude <developers@lethean.io>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Extract logging to pkg/log for use outside CLI:
- Logger with Debug/Info/Warn/Error levels
- Key-value pairs for structured logging
- Customisable styling and output
- Optional Core framework integration via Service
Enhance pkg/errors with:
- Wrap() and WrapCode() helpers
- Code() for error codes
- Op(), ErrCode(), Message(), Root() extractors
- Standard library wrappers (Is, As, New, Join)
Update pkg/cli/log.go to use pkg/log with CLI styling.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>