pici

created pr with pici/rfc-001.1 on 2026-11-15T14:38:31Z · by c8ef7d19
cmds
checkout latest patchset:
ssh pr.pico.sh pull pici:rfc-001 | git am -3
checkout specific patchset revision:
ssh pr.pico.sh pull pici:rfc-001 [rev] | git am -3
add changes to patch request:
git format-patch main --stdout | ssh pr.pico.sh pici:rfc-001
add comment to patch request:
ssh pr.pico.sh comment pici:rfc-001 "lgtm!"

Patchset pici/rfc-001.1 on 2026-11-15T14:38:31Z · commit 3fea3bf

refactor: rfc_001_self_ci
Eric Bower 2026-11-15T14:38:11Z
Semantic diff summary
0 added, 0 modified, 0 signature changed, 0 removed across 0 analyzed files (1 file skipped: unsupported file type)
+20 -0 rfc_001_self_ci.gmi #
......@@ -0,0 +1,20 @@
1+# rfc 001 - self hosted ci
2+
3+Status: draft
4+
5+The current pici system has three main funcs: local runner, remote runner, and remote monitor. As we were experimenting with the ci system we realized that most of our use cases revolved around running it locally. We want to redesign pici to be local-first and then extend it to be used as a remote runner.
6+
7+The local run path becomes the reference implementation. pici runs the job in the foreground, streams output as it happens, and exits with the job's exit code. Detached execution stays available as a flag for scripts. The remote mode is the same core driven by an event instead of the local working tree.
8+
9+Originally the remote runner was designed to start the job through zmx and then quit immediately so the machine could immediately re-subscribe to the pipe event system. We want to redesign it so the runner waits for the job to complete before re-subscribing. That means one process owns the subscription, runs the job to completion, and does the post-job work (rendering the report, syncing artifacts, sending notifications) itself. The monitor daemon disappears for new installs and systemd becomes a single unit. For parallelism, the process holds a configurable number of concurrent slots, each running a job to completion, and holds any events that arrive while all slots are busy until a slot frees. We considered spawning multiple runner processes competing on the same pipe topic, but that requires the broker to deliver each message to exactly one subscriber plus some claim protocol, and in-process slots give us the same parallelism without that.
10+
11+We also want to change the way the remote runner works. Right now we have tightly coupled the system around git events (e.g. git.push and git.tag) which inadvertantly locked us into thinking about pici as a git appliance. We obviously want to continue to support git events but we want to do that as an extendable, plugin-based system. So instead of having pici set PICI_TAG and PICI_BRANCH and inject them into the pici.sh script we want to send a data payload so the end-user can define the fields they want to send their pici.sh script.
12+
13+Concretely, an event becomes a small envelope that the runner actually needs (type, name, workspace, and optionally a job id) plus a data object that is opaque to the runner and defined by whoever produced the event. The git post-receive hook becomes the git producer plugin, which is just a script that emits this envelope. Webhooks, cron, or a manual trigger are other producers emitting the same shape with their own data. The runner always injects the core fields into the environment, plus the full payload as JSON, and applies a user-defined mapping from data fields to flat env vars, so a git user gets PICI_BRANCH and PICI_COMMIT with a one line config and existing pici.sh scripts keep working unchanged.
14+
15+Further, we want to rewrite pici in zig so we can fully utilize libzmx which is a way to programmatically interface with zmx which is our job engine system built on terminal session persistence. This will also allow us to embed zmx into pici so we don't need to carry multiple binaries around to install pici. Today pici reaches zmx by exec'ing the cli and parsing its text output, and replacing that with the in-process library is what makes the wait-for-completion runner design natural. The go codebase stays as the behavioral reference and the rewrite ports subsystem by subsystem against the existing test suite.
16+
17+=> https://bower.sh/zmx-lib libzmx
18+
19+Finally I want to install a design paradigm that allows the user to farm pici.sh out to their own project's task runner (make, just, task, etc.). This is likely already possible with the one caveat that pici.sh is generally being run from the host machine without being inside of docker so they will need to install their own task runner in addition to the pici binary. The convention is that pici.sh becomes a thin shim that execs the project's ci target, and if a project has no pici.sh at all, pici detects a justfile, Makefile, or Taskfile and runs its default ci target directly so existing projects can adopt pici without writing a new file.
20+
Back to top