Skip to content

fix(logs): remove the itsup logs reader and run on the current logger - #150

Open
Morriz wants to merge 8 commits into
mainfrom
fix/hold-logger-below-0.7
Open

Morriz wants to merge 8 commits into
mainfrom
fix/hold-logger-below-0.7

Conversation

@Morriz

@Morriz Morriz commented Nov 24, 2026 •

Copy link
Copy Markdown
Owner

Why

One logger, one instruction: itsUP uses the organisation's logger (instruktai-python-logger) so that every project reads its own logs the same way, with instrukt-ai-logs <app>. itsUP owns no reader.

itsup logs <target> went against that. It was an itsUP-owned log reader that borrowed reader helpers from the logger package. The logger dropped its reader side on purpose in 0.7.0 (the Python package is the writer SDK only; the reader is the Rust tool instrukt-ai-logs), and because itsup/cli.py imported commands.logs at import time, every itsup command failed to start on the new logger. Boot bringup, the nightly apply and the daemon starts all go through that CLI.

An earlier head of this branch answered that by copying the helpers into itsUP. That kept a second reader alive under itsUP's ownership. This head removes the reader instead.

Net change against main

Removed

  • commands/logs.py, its registration in itsup/cli.py and its entry in the host-only set.
  • lib/paths.py:logs_dir() and access_log_file(), which nothing else used.
  • docs/third-party/instrukt-ai-logging/log-reading-primitives.md, the note about the reader primitives the logger no longer ships.
  • lib/log_reading.py was added and removed again within this branch, so it does not appear in the net diff.

Dependency

  • instruktai-python-logger>=0.10 with no upper bound (was >=0.6.6,<0.11); the lock moves from 0.10.2 to 0.10.3, the latest release.
  • .github/dependabot.yml has no net change.
  • itsUP now imports two names from the logger, both public writer API: configure_logging and get_logger.

Documentation: where each log is read

  • Logger-written diagnostics: instrukt-ai-logs itsup. The docs now say it is the logger project's standalone tool, that make install does not provide it, and how to install it (README carries the command; the design snippet points at the logger project).
  • Supervised units, including the API server and the security monitor: the supervisor journal, journalctl -u <unit>.
  • Traefik access log: Traefik's own file, read with ordinary tools.
  • docs/project/spec/cli.md loses the logs section; the host-only lists in the CLI spec, the repository conventions (and the generated AGENTS.md), and the itsup domain's host-boundary policy lose logs.
  • docs/project/design/logging.md drops the router as a consumer and the two router-only passages (the --grep/--since selection rule and the timestamp failure mode).
  • The two systemd third-party notes no longer name the removed router as their consumer; they name the callers that remain.
  • Separate commit: the logging design said the default log source is avoided because processes must not share a file, while the CLI and the two CLI-family one-shots share it. The sentence now states what the code does.
  • Separate commit: the README and the itsup domain's CLI surface pointed monitor diagnostics at instrukt-ai-logs itsup --include monitor. The monitor has logged to the journal since it became a supervised daemon, so they now name the journal.

No feature spec or use case was bound to itsup logs, so nothing was retired there.

CI guard

  • make smoke starts the CLI from the installed environment (one delegation line, .venv/bin/itsup --help), and the Test workflow runs it after lint. Until now CI only formatted and linted api and lib, so a dependency update that stops the CLI from importing merged green.

Verified

Off the container host, on macOS, in this branch's environment:

  • uv sync --frozen succeeds; uv lock --upgrade-package instruktai-python-logger --dry-run reports no change, so the lock holds the latest release.
  • .venv/bin/itsup --help starts and lists no logs command.
  • All 22 modules that import instrukt_ai_logging import cleanly on 0.10.3.
  • bin/format.sh then bin/lint.sh pass (pylint 10.00, mypy clean).
  • instrukt docs validate and instrukt docs render --check pass.
  • The guard catches the failure it is for: with main's itsup/cli.py and commands/logs.py put back on the locked logger, make smoke fails with ModuleNotFoundError: No module named 'instrukt_ai_logging.cli'; on this head it passes. Without an environment the recipe also exits non-zero.
  • The reader options named in the docs (--since, --include, --grep, --follow) were checked against instrukt-ai-logs 0.10.3 built from its tag.

Not verified

  • Nothing was run on the container host. The journalctl instructions and the unit names come from the unit files and the existing runtime-operations spec.
  • The Test workflow run for this head on GitHub; see the checks on this PR.
  • Whether instrukt-ai-logs is installed on the container host. Before 0.7 the Python package shipped a script of that name; from 0.7 on, a machine needs the standalone tool.
  • The daemon entry points (api/main.py, bin/monitor.py, bin/backup.py, bin/alert.py) are not started in CI either. They import cleanly here; the guard covers the CLI only.

Follow-up

#151 builds on this head. It records why the daemons stay on the journal for now: a root-run process and the itsUP user cannot share the logger's directory without breaking the user's instrukt-ai-logs itsup, which already applies to the root-run backup job.

Host state

Carried over from the earlier description of this PR and not observed in this change: the container host was put on logger 0.6.7 by hand to recover, and its next self-update from main installs whatever the lock holds. Until this merges that is 0.10.2 with a CLI that does not start.

… the bound

itsup imports instrukt_ai_logging.cli, which the logger stopped shipping in
0.7.0. The bound set for that was rewritten to <0.11 by the next grouped
Dependabot bump, because a 0.x minor is not a semver-major and the existing
ignore rule let it through. The lock moved to 0.10.2 and the container host
installed it on its next self-update, after which every itsup command failed
on import: boot bringup, the nightly apply, the API and the monitor start.

Restore the bound, relock to 0.6.7, and tell Dependabot to ignore logger
releases from 0.7 so the bound is not rewritten again.

Session: t3:5128ca34-972f-4682-ada6-678a5e45024e
Human-Involved: true
The logs command took both from the logger's reader side, which the logger
removed in 0.7.0 when its Python package became the writer SDK only. The CLI
imports the logs command at start, so that one import kept every itsup command
from starting on a current logger.

itsUP now carries the two helpers in lib/log_reading.py. The follower keeps the
behaviour the access log needs: it follows an existing file from its end and
keeps going across truncation in place (copytruncate), replacement at the same
path, and a file that is not there yet.

Three things differ from the code it replaces. A line is held until its newline
arrives, so --grep and --since see whole records, and a file that appears after
the follow started is read from its beginning instead of from its end; the
logger project's current follower does both. The file is read as bytes, so
truncation is judged against a true byte offset and line endings pass through
unchanged, as they already do when the file is read without --follow.

The third-party note that documented the removed reader primitives as something
itsUP reuses goes with the imports.

Session: t3:5128ca34-972f-4682-ada6-678a5e45024e
Human-Involved: true
Nothing in itsUP imports the logger's removed reader side any more, so the
upper bound has no reason left. The requirement becomes a floor at the 0.10
line, the lock moves to 0.10.3, and the Dependabot rule that kept updates from
lifting the bound is removed so the logger follows the same update path as
every other dependency. The writer API itsUP calls, configure_logging and
get_logger, has the same signatures on that release.

The logging design follows: the diagnostic viewer is a standalone tool that the
Python package no longer installs, the handler is no longer named after a class
the logger replaced, and the read path of itsup logs is stated as itsUP's own.

Session: t3:5128ca34-972f-4682-ada6-678a5e45024e
Human-Involved: true
@Morriz Morriz changed the title fix(deps): hold the logger below 0.7 and keep Dependabot from lifting the bound fix(deps): run on the current logger by owning the log-reading helpers Nov 24, 2026
itsUP uses the organisation's one logger so that every project carries the
same instruction for reading its own logs, `instrukt-ai-logs <app>`. An
itsUP-owned reader stands against that: it is a second place to read logs,
and because the CLI imported it at start, the reader helpers it borrowed
from the logger package took every itsup command down when the logger
dropped its reader side. Copying those helpers into itsUP kept the second
reader alive under itsUP's ownership instead of removing it.

The command, its helpers, its host-gate entry and the path helpers nothing
else uses are gone. The CLI spec, the logging design, the host-boundary
rules and the README state where each log is read with the tool that owns
it: logger-written diagnostics with instrukt-ai-logs (the logger project's
standalone tool, with its install step), the supervised units in the
supervisor journal, and the Traefik access log as Traefik's own file.

Session: t3:thread:delegated-task:command%3Amcp%3A90097403-c516-484c-8d66-e31ba569c0c1%3Adelegate-task%3A07981b9a-bc91-45b2-a78c-d360166c6c63
Human-Involved: true
The README and the itsup domain's CLI surface still sent readers to
`instrukt-ai-logs itsup --include monitor`. The monitor has logged to its
supervised unit's stdout since it became a supervised daemon and writes no
file in the logger's directory, so that instruction shows none of its
current records. They now name the journal, where the records are.

Session: t3:thread:delegated-task:command%3Amcp%3A90097403-c516-484c-8d66-e31ba569c0c1%3Adelegate-task%3A07981b9a-bc91-45b2-a78c-d360166c6c63
Human-Involved: true
The Test workflow formats and lints `api` and `lib` and never starts
`itsup`, so a dependency update that stops the CLI from importing merges
green and fails first on the host, where boot bringup, the nightly apply
and the daemon starts all go through that CLI. `make smoke` starts it from
the synced environment and the workflow runs it after lint, so an import
that no longer resolves fails the check before merge.

Session: t3:thread:delegated-task:command%3Amcp%3A90097403-c516-484c-8d66-e31ba569c0c1%3Adelegate-task%3A07981b9a-bc91-45b2-a78c-d360166c6c63
Human-Involved: true
@Morriz Morriz changed the title fix(deps): run on the current logger by owning the log-reading helpers fix(logs): remove the itsup logs reader and run on the current logger Nov 24, 2026
The recipe carried a guard for a missing environment: a conditional with
its own error handling inside the Makefile, where no linter or reviewer
of scripts sees it. The recipe now only names the CLI. A missing
environment or an import that no longer resolves both end the recipe
non-zero, so the Test workflow still fails before merge.

Session: t3:thread:delegated-task:command%3Amcp%3A90097403-c516-484c-8d66-e31ba569c0c1%3Adelegate-task%3A07981b9a-bc91-45b2-a78c-d360166c6c63
Human-Involved: true
The design said the default source is avoided because independent
processes must not share one log file. The CLI and the two CLI-family
one-shots do share the default file, and the logger writes each line whole
so that they can. The sentence now states what the code does: a producer
with its own trigger declares a source, the CLI family shares the default.

Session: t3:thread:delegated-task:command%3Amcp%3A90097403-c516-484c-8d66-e31ba569c0c1%3Adelegate-task%3A07981b9a-bc91-45b2-a78c-d360166c6c63
Human-Involved: true
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.

1 participant