Repository navigation
watch service: pin the install environment into the unit, verify the systemd path live - #21
Conversation
…ystemd A scheduler starts a job with a bare environment, so a timer installed from a shell that sets XDG_DATA_HOME or WALLAPOP_CONFIG went on to check a different, empty state database: no events, no error, nothing to see. The unit now carries the variables that decide where the CLI reads and writes, and which backend it talks to, as they stood at install time. The session token is deliberately left out of a world-readable file. Alongside that, three correctness fixes the live run and a close reading turned up: ExecStart quotes the executable so a path with a space does not produce a unit that fails on every trigger; the launchd plist escapes every value, since a plist that does not parse is an agent that silently never runs; and linger is read from the passwd database rather than $USER, which a scheduled process may not have. Unit rendering moves into three pure functions so the launchd and Windows cases are testable on Linux: the plist is parsed and its keys checked, the schtasks line is pinned exactly. Verified live on systemd 249 at a 30s interval against the fake Wallapop: install, repeated firing, events reaching the log and the sinks, status and doctor reporting active, log rotation at the cap by a scheduled run, and an uninstall that leaves nothing. Reboot, launchd and schtasks are not exercised; docs/cli-spec.md says exactly what was and was not.
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Advanced Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@coderabbitai review |
|
…rrides Three findings from review, all real. systemd expands % specifiers inside unit values, so a percent-encoded URL or a path with a % in it either made systemd drop the assignment or substituted something else. Every rendered value now doubles its %. HOME is what the default paths derive from when the XDG variables are unset, which is the common case, so a unit that did not carry it could still land on another home. It is pinned with the rest. A relative WALLAPOP_CONFIG or XDG override was recorded as given, and a scheduler runs the job from its own working directory, so it would have pointed somewhere else. Path overrides are made absolute before they go into the unit. Re-verified live: systemd accepts the unit, resolves the environment exactly as written, runs it, and uninstall leaves nothing.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1983deccfe
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
A relative HOME makes every derived path relative, so the unit would carry a StandardOutput= systemd ignores and the unit files would land outside the directory systemd reads. Install now says so and stops instead of writing a schedule that quietly does nothing. Relative XDG_* overrides do not reach this: adrg/xdg drops them and falls back to the HOME defaults, checked against the built binary.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4a58438636
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
A relative XDG value is invalid per the spec and adrg/xdg drops it, so the install ran on the HOME defaults. Making it absolute and writing it into the unit handed the timer an override the install never used, which is the same empty-database failure from the other direction. XDG values are now pinned only when they are already absolute. WALLAPOP_CONFIG keeps the absolute conversion: it is read raw rather than through xdg, so a relative one does take effect and the scheduler starts from its own working directory. HOME goes in as it is, since a relative one is refused before this point.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 340225ae05
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
|
Codex Review: Didn't find any major issues. Delightful! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
issue #5 was mostly about proving the scheduled checks actually survive the terminal closing, not about writing new features. so i went and ran it for real on this box, and the running of it turned up one bug that mattered plus a few that would have bitten on the platforms i cannot run.
the bug the live run found
a scheduler starts a job with a bare environment. the unit pinned the log path (absolute) but nothing else, so the CLI inside the timer re-resolved its own paths from whatever environment systemd happened to hand it. anyone who sets
XDG_DATA_HOME,XDG_STATE_HOMEorWALLAPOP_CONFIGin their shell got a timer reading a different, empty state database: no watches, no events, no error, an empty log. silent no-op.the unit now writes those variables in as they stood at install time, plus the three base-URL overrides.
WALLAPOP_SESSION_TOKENis deliberately not written, a unit file is world-readable.three more, from reading rather than running
ExecStartis word-split by systemd, so a binary path with a space produced a unit that failed on every single trigger. the executable is quoted now.&and the plist stops parsing, and a launchd agent that does not parse just never runs, quietly. every value is XML-escaped now.lingerEnabledread$USER, which a scheduled or su'd process may not have. empty name,loginctlfails, and every status line claims linger is off. it reads the passwd database now.unit rendering moved into three pure functions (
systemdUnits,launchdPlist,schtasksCreate) so the macOS and windows shapes are testable from linux. new tests parse the plist and check the keys launchd needs, and pin the schtasks line exactly.what was verified live
linux, systemd 249, against
internal/fakewallapop, 30s interval, real units in~/.config/systemd/user:installwrites both units,daemon-reloads,enable --nows.systemctl --user is-enabledsaysenabled,is-activesaysactive, and the timer appears inlist-timers.last_run.watch events) and the Watch's Sinks (anexecsink that appended every event it was handed, 3 deliveries from scheduled runs, on top of the one fromsink test).statusreportedactivewithlast_runmatching the journal,doctorreportedschedule: active..log.1and the run after that started a fresh.log. two files, bounded.uninstallprintedremoved, and afterwards: no unit files, no timer inlist-timers, nothing inlist-unit-files, no log, no.log.1.statusanddoctorboth saynot installed. box left clean.what was not verified, and why
enabled(sotimers.targetpulls it in) and linger is on (so the user manager starts at boot without a login). those two together are what makes a user timer survive logout and come back after a reboot. i did not reboot, so i am not ticking that box.loginctl enable-lingerbranch. this box already had linger on, so install's call had nothing to do. i did not turn linger off to test it, since five unrelated user timers run on this box and i am not gambling with them.Label,ProgramArguments,StartIntervalin whole seconds,RunAtLoad,StandardOutPath/StandardErrorPath, and an agent in~/Library/LaunchAgentsis loaded at login, which is the macOS answer to "after a reboot". a test parses the generated plist and checks those keys are present and the values intact. it has never been handed to launchd./SC MINUTE /MO n, minutes rounded up, never 0,\"around the executable so aC:\Program Files\...path stays one argument). never run on windows.after review
four more, all from codex, all real, all fixed on this branch:
%specifiers inside unit values, so a percent-encoded URL or a path with a%in it either got dropped or silently rewritten. every rendered value doubles its%now.HOMEwas missing from the pinned set, and it is where every default path comes from when the XDG variables are unset. pinned.WALLAPOP_CONFIGwas recorded as given, and the scheduler starts from its own directory. made absolute.filepath.Abson a relative XDG value handed the timer an overrideadrg/xdghad ignored at install time, which is this PR's own bug from the other side. XDG values are pinned only when already absolute.a relative
HOMEmakes every derived path relative, so install refuses instead of writing a unit systemd would ignore. the deeper fix, normalisingHOMEwhere paths are resolved, is ininternal/configand is left alone.re-verified live on systemd after each round: the unit installs,
systemctl --user show -p Environmentreads the pinned values back unchanged, the run exits 0, uninstall leaves nothing.outside my lane
wallapop config setcannot set an array, so anexecsink'scommandcannot be configured from the CLI at all:config set sinks.x.command /pathfails withcannot decode TOML string into []string. i hand-edited config.toml for the live test. that lives ininternal/cli/misc.go, which i do not own on this branch, so it is untouched and reported here instead.Closes #5