Skip to content

fix(linux): add structured control socket logging - #36

Merged
melonamin merged 2 commits into
melonamin:linux-portfrom
MemberIT:fix/linux-structured-control-logging
Sep 3, 2026
Merged

melonamin merged 2 commits into
melonamin:linux-portfrom
MemberIT:fix/linux-structured-control-logging

Conversation

@MemberIT

@MemberIT MemberIT commented Aug 29, 2026 •

Copy link
Copy Markdown

What

Give the Linux control-socket lifecycle the same queryable diagnostics that upstream macOS gained in umputun#442.

ControlServer now emits GLib structured notice records with a stable agterm journal identifier and ControlServer domain. On journal-connected desktops they are filterable with:

journalctl --user -t agterm GLIB_DOMAIN=ControlServer --since "30 minutes ago"

GLib keeps its standard-stream fallback when no journal is connected.

Cause

The Linux server wrote only its successful bind and two ownership messages directly to stderr. The path-length, socket(), bind(), and listen() failure guards returned silently, so the app correctly stayed open but left no reason for a missing control socket.

The ad-hoc stderr lines also had no structured category equivalent to upstream's os.Logger(subsystem:category:) filtering.

Minimal reproduction

  1. Launch the Linux app with an existing AGTERM_STATE_DIR whose resulting agterm.sock path exceeds sockaddr_un.sun_path.
  2. Observe that the app continues to run without a bound control socket.
  3. Before this change, stderr and the desktop journal contain no path-length diagnostic.

The same silent return existed for socket(), bind(), and listen() failures.

Expected: the app still launches, and the exact failure is available under the ControlServer log domain.

Change

Commit 539e917 (fix(linux): add structured control socket logging):

  • add a Linux-only LinuxStructuredLogger adapter over g_log_structured_array;
  • emit MESSAGE, PRIORITY=5, GLIB_DOMAIN=ControlServer, and SYSLOG_IDENTIFIER=agterm in one synchronous call;
  • log the path-length, socket, bind, listen, lock-open, duplicate-owner, and successful-bind paths;
  • copy errno text before cleanup syscalls, split bind/listen handling, and unlink the bound path after a listen failure;
  • add focused Swift Testing coverage for the structured record contract and exact UTF-8 message preservation;
  • document journal filtering and the non-journal stderr fallback in both troubleshooting sources.

No direct libsystemd dependency or custom journal writer is added.

Scope note

This is a Linux host-adapter change only. It does not change:

  • agtermCore;
  • the control protocol, dispatcher, or agtermctl;
  • macOS runtime code;
  • CLAUDE.md or CHANGELOG.md.

CLAUDE.md remains upstream-owned project guidance and is intentionally untouched.

Keep-in-sync

  • Control API coverage: not applicable; logging is internal transport diagnostics, not a user action or mutable capability.
  • Keymap/model/site command reference: unchanged.
  • Bundled skill: updated because it is the source of truth for troubleshooting commands.
  • README and changelog: unchanged; no feature/configuration or release-note surface changed.

Testing

All builds and tests ran inside swift:6.3.2-noble Docker containers; none ran on the host.

Full CI-shaped Docker validation:

  • installed the workflow GTK4/libadwaita/epoxy, AT-SPI/Xvfb, SwiftLint 0.65.0, and Zig 0.16.0 dependencies;
  • rebuilt libghostty from the pinned revision after rejecting a stale host cache;
  • scripts/check-linux-core-boundary.sh v0.24.0 — passed;
  • scripts/check-linux-cli-drift.sh — passed;
  • scripts/test-linux-architecture.sh — passed;
  • scripts/test-linux-resources.sh — passed;
  • scripts/verify-linux-vendor-cache.sh — passed;
  • cd agterm-linux && swift test — 334 tests in 48 suites passed;
  • cd agterm-linux && swift build — passed;
  • cd agterm-linux && swift build -c release — passed;
  • swiftlint lint --strict --quiet — passed;
  • both diff checks — passed;
  • scripts/stage-linux.sh — passed;
  • scripts/test-linux-ui.sh — full GTK AT-SPI smoke suite passed;
  • isolated long-socket runtime smoke — observed the exact path-length message with the ControlServer-Message stderr prefix.

After the final warning-only cleanup, a fresh Docker compile ran:

  • swift test --filter LinuxStructuredLoggerTests — 2 tests, including 9 message cases, passed;
  • swift build --product AgtermLinux — passed with no warning from the new logger.

Independent code review reported no findings.

GitHub Actions run 33247003684 is green: Detect changes, SwiftLint (Linux), Unit tests (Linux), and Build app (Linux GTK) passed; Cookbook checks were skipped by the path filter.

Related upstream

Files

  • agterm-linux/Sources/AgtermLinux/ControlServer.swift — modified
  • agterm-linux/Sources/AgtermLinux/LinuxStructuredLogger.swift — added
  • agterm-linux/Tests/AgtermLinuxTests/LinuxStructuredLoggerTests.swift — added
  • docs/troubleshooting.md — modified
  • plugins/agterm/skills/agterm/troubleshooting.md — modified

136 insertions, 14 deletions across 5 files.

@MemberIT
MemberIT requested a review from melonamin as a code owner August 29, 2026 10:05
@melonamin
melonamin force-pushed the fix/linux-structured-control-logging branch from 539e917 to de70918 Compare September 3, 2026 01:56
@melonamin
melonamin merged commit 014607b into melonamin:linux-port Sep 3, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants