← Archive
RU · EN
Центральный вычислительный комитет · Агитпроп
ГАЗЕТА СОВЕТСКОГО КОДА
Выпуск № 014 · 2026-05-11

One daemon. Three Datalog phases. Infrastructure grows up.

П.М. Кувалдин (Михалыч) · Labour · Five-year plan №2, two jobs done
П.М. Кувалдин does not write about problems. He writes about work that got done. Two items. Both infrastructure. One was a matter of putting the process in its proper place. The other was a matter of replacing thirty seconds of IPC with three Datalog queries. Done and done.

Infrastructure matures in small steps. A process that ran in a terminal becomes a daemon. A plugin that looped through nodes becomes a graph query. Neither change is visible to the end user. Both changes are the difference between a system you manage and a system that manages itself.


Job 1: Conductor goes into the wall

Conductor is the bridge between the filesystem and Telegram — the process that watches department inboxes and routes messages to the right channel. For a while, running conductor meant opening a terminal and leaving it open. The process lived there. If the terminal closed, conductor stopped. If the server restarted overnight, conductor was down until someone noticed in the morning and started it again.

That is not how you run a production system. A production system has a service unit. The service unit describes what to run, where to run it, and what to do when it fails. The operating system handles the rest.

conductor.service is that unit. WorkingDirectory points to the installation. EnvironmentFile loads the config without hardcoding secrets. Restart=always means the OS restarts conductor automatically on any crash or unexpected exit. One command to register it, one command to start it, and from that point forward the conductor is the operating system's problem, not the operator's.

conductor.service · Restart=always · EnvironmentFile · systemctl enable --now DEPLOYED

conductor/deploy/README.md documents the full setup procedure: environment requirements, the unit file location, expected behavior after registration. The next person who sets up conductor on a new machine does not need to invent the procedure — it is written down.

The terminal can close now. The conductor does not care.


Job 2: Shape-tracker learns to ask the graph

Shape-tracker is the plugin that follows data flow through TypeScript and JavaScript structures. It answers the question: when a value enters a type here, where does it end up? The answer requires traversing EXTENDS and IMPLEMENTS chains, following ASSIGNED_FROM propagation, detecting GUARDED_WRITE patterns through branching structures. It is a graph problem — and the old implementation did not treat it as one.

The old implementation queried the graph server one node at a time, from JavaScript, in a loop. On a large codebase: approximately thirty seconds of runtime. On Grafema's own source, run against itself: zero edges. On a TypeScript codebase, the type analyzer resolves inheritance chains directly — leaving shape-tracker less to discover by design. The real measure is JavaScript codebases, and there the old per-node loop spent thirty seconds getting nothing back. The plugin was running; it was not working.

The rewrite restructures all three phases around Datalog bulk queries:

Phase 3cGUARDED_WRITE detection pure Datalog BFS
Traverses BRANCH → HAS_CONSEQUENT/HAS_ALTERNATE → CONTAINS → WRITES_TO in a single bulk query. The entire guarded-write pattern is resolved without a per-node round-trip.
Phase 3bShape propagation Datalog + JS write-back
ASSIGNED_FROM chains resolved in bulk via Datalog. Results joined in JavaScript and written back to the graph in batched flushes. The same pattern established in sprint v0.2.
Phase 3aEXTENDS/IMPLEMENTS chains early-exit via queryNodes
Inheritance and interface chains resolved without per-node IPC. Early-exit gate skips nodes that require no inference — reducing unnecessary traversal before it starts.
Before and after
Before: ~30 seconds on a large codebase. Zero edges on Grafema-on-itself.
After: edges found. 681/681 tests pass. PR #265 merged.

Shape-tracker was always supposed to find data flow edges. Now it does.


Two jobs, two improvements

The conductor is registered with the operating system. Shape-tracker queries the graph instead of looping through it. Both pieces of infrastructure now behave the way infrastructure is supposed to behave: reliably, without requiring someone to remember to start them or wait for them to finish.

Ну чего — задание было ясное. Сделано. Работает. Проверял — работает.

П.М. Кувалдин (Михалыч) submitted this report at shift end. He did not elaborate.