Skip to content

systemd units (.service/.timer) are in no extension set, so a repo's whole scheduled-job topology is invisible — and the graph answers confidently rather than emptying #2848

Open

Description

@nathanschram

Summary

.service and .timer appear in none of CODE_EXTENSIONS / DOC_EXTENSIONS / PAPER_EXTENSIONS /
IMAGE_EXTENSIONS, so classify_file() returns None and systemd units are never collected at any cost
tier. For a repo that keeps its units under version control, that means the entire OS-level scheduled-job
topology is absent from the graph
.

Verified on graphifyy==0.9.42:

from graphify.detect import CODE_EXTENSIONS, DOC_EXTENSIONS, PAPER_EXTENSIONS, IMAGE_EXTENSIONS
watched = CODE_EXTENSIONS | DOC_EXTENSIONS | PAPER_EXTENSIONS | IMAGE_EXTENSIONS
".service" in watched   # False
".timer"   in watched   # False

Same class as #2434 (.toml/.ini/.cfg). Worth flagging: #2434 is closed as completed, but on
0.9.42 ".toml" in watched is still False — so either the fix is merged-but-unreleased, or the class is
still open in practice. Not a complaint, just a data point for whoever triages this one.

Why this is worse than a missing extractor

The failure is silent and confident, not empty. In our repo (11 tracked units — a daily audit, a Slack
digest, a watchdog, a backup, a knowledge-graph refresh):

$ graphify query "what scheduled jobs run on sl" --budget 400
Traversal: BFS depth=2 | Start: ['run()', 'runScheduledIndexing()'] | 59 nodes found

59 nodes, all from the application's in-process scheduler, zero timers. Nothing signals that the units
were skipped — the answer looks complete. The related unclassified count is computed by detect(), but
the print at cli.py:3181-3187 lives in the elif cmd == "extract": branch, so graphify update never
emits it and there is no log line to notice either.

Why units are worth extracting (unlike most config)

They are genuinely graph-shaped, and every edge lands on nodes an AST pass has already created:

Relation From → To Source key
activates *.timer → *.service [Timer] Unit=, else the filename convention
runs *.service → a script node ExecStart=, after stripping /usr/bin/env bash …
documented_by unit → a doc node Documentation=file://…
after/wants/requires unit → unit [Unit] ordering keys

No tree-sitter grammar is needed — units are INI. extractors/sln.py (92 lines, pure re) looks like the
right template.

What we did meanwhile, in case it is useful

Rather than patch site-packages (reverted by uv tool upgrade), we wrote a ~500-line deterministic pass in
our own tooling that runs after graphify update and merges the units into graph.json. It yields
11 nodes + 18 edges and turns the query above into a real answer:

$ graphify path config_systemd_sl_graphify_refresh_timer scripts_graphify_refresh
Shortest path (2 hops):
  sl-graphify-refresh.timer --activates [EXTRACTED]--> sl-graphify-refresh.service
                            --calls/runs [EXTRACTED]--> graphify-refresh.sh

Happy to port the parser semantics into graphify/extractors/systemd.py as a PR if that is wanted — but
given the current PR backlog we would rather ask first than add to it. The issue stands on its own.

Two things that would bite an implementation

  1. Do not add the extensions without the _DISPATCH entry (extract.py:4769) — R (.r/.R) listed in CODE_EXTENSIONS but has no AST extractor — silently drops all R files with zero warning #1689 documents that
    exact combination silently dropping every matching file with no warning.
  2. Node ids collide. _file_stem drops the extension, so foo.service and foo.timer — which is the
    normal systemd naming convention, not an edge case — collapse into one node. This is Node IDs collide for files sharing a basename (e.g. layout.py vs layout.ts) #1829 with a
    guaranteed-to-occur trigger rather than an incidental basename clash; we had to keep the extension in the
    id (config_systemd_foo_service / …_timer) to avoid it. Commented there separately.

Environment

  • graphifyy==0.9.42, Python 3.12, Ubuntu 24.04
  • Repo: ~900 tracked files, 5,282 nodes; 11 config/systemd/*.{service,timer}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions