: nply/foundationpkgs

commit 1808331741b8b964db4ff99edd5f7fd75df336ed
parent da3dbca45fdb5594ea0a20ea0f359def213b82e4
Author: Bharatvaj Hemanth <bharatvaj@yahoo.com>
Date: Fri, 11 Sep 2026 21:55:27 +0530

Document minci handoff Jobfile direction
3 files changed, 151 insertions(+), 2 deletions(-)
M
AGENTS.md
|
2
+-
M
CONTEXT.md
|
6
+++++-
A
docs/minci-handoff.md
|
145
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
diff --git a/AGENTS.md b/AGENTS.md
@@ -16,7 +16,7 @@ Read `CONTEXT.md` before changing package names, recipe layout, artifact paths, 
 - Plan or run repository CI: `scripts/fpkgs-ci.sh plan [REV]` and `scripts/fpkgs-ci.sh run [REV]`.
 - Gitolite integration uses `scripts/fpkgs-ci.sh post-receive`.
 
-See `docs/ci.md` for deployment/configuration details and `docs/ci-architecture.dot` for the CI graph.
+See `docs/ci.md` for the deployed bootstrap CI, `docs/minci-handoff.md` for the next provider-neutral Jobfile design, and `docs/ci-architecture.dot` for the CI graph.
 
 ## Development rules
 
diff --git a/CONTEXT.md b/CONTEXT.md
@@ -22,7 +22,11 @@
 
 **Gitolite trigger**: A gitolite hook that observes pushes, filters for `main`, and starts the detachable CI runner.
 
-**Detached CI runner**: `scripts/fpkgs-ci.sh`, the standalone integration script that can run from this repo or be copied into another APKBUILD repository.
+**Bootstrap CI runner**: `scripts/fpkgs-ci.sh`, the current foundationpkgs-specific integration script. It should be replaced by the provider-neutral `minci-handoff` shape.
+
+**minci-handoff**: The planned provider-neutral runner that accepts a generic handoff event, executes a Jobfile, publishes artifacts, and reports to minci.
+
+**Jobfile**: A POSIX shell, APKBUILD-like file containing CI metadata variables and job functions. The first implementation is server-level; later repos can provide `.config/minci/Jobfile` on an `integ` branch.
 
 **Native target**: The target returned by `guess_triplet` for the current build host. The initial deployed CI run builds this target.
 
diff --git a/docs/minci-handoff.md b/docs/minci-handoff.md
@@ -0,0 +1,145 @@
+# minci-handoff design
+
+`minci-handoff` is the next shape of the current `fpkgs-ci.sh` glue. It stays specific to minci as the report sink, but it is provider-neutral and project-neutral.
+
+## Replacement map
+
+Current foundationpkgs-specific pieces should move like this:
+
+| Current | Replace with | Why |
+| --- | --- | --- |
+| `scripts/fpkgs-ci.sh` | standalone `minci-handoff` executable | Current script knows APKBUILD buckets and foundationpkgs artifact layout. |
+| `FPKGS_*` env vars | server config + generic handoff event vars | The event format should be reusable across gitolite, webhooks, and manual runs. |
+| Built-in `list_apkbuilds()` planner | `Jobfile` job function | The repo/server Jobfile decides what to build. |
+| Built-in artifact path policy | `artifact_path` + `artifact_dir`/`artifact_url` vars | Keeps publishing generic. |
+| Built-in minci report per APKBUILD | minci reporter around each declared job | minci remains the reporting protocol, not the build planner. |
+| `scripts/build.sh` / `functions.sh` | job implementation for APKBUILD projects | These stay useful, but should not live in the runner core. |
+| `scripts/pacstall-install.sh` | optional job helper | Runtime APKBUILD → pacscript conversion stays project/tool-specific. |
+
+## Server-level Jobfile first
+
+Before requiring every repo to carry an `integ` branch, use one server-level Jobfile:
+
+```txt
+/etc/minci-handoff/Jobfile
+```
+
+This lets us work out runner semantics against `foundationpkgs` without forcing every repo to restructure.
+
+Later lookup order:
+
+1. server override: `/etc/minci-handoff/repos.d/<repo>.Jobfile`
+2. repo config branch: `refs/heads/integ:.config/minci/Jobfile`
+3. repo default branch: `.config/minci/Jobfile`
+4. common fallback: `/etc/minci-handoff/Jobfile`
+
+For now, use only the common fallback.
+
+## Handoff event format
+
+Adapters produce lowercase shell variables:
+
+```sh
+event=git-push
+repo_name=nply/foundationpkgs
+repo_url=ssh://git@nply.org/nply/foundationpkgs.git
+repo_path=/home/git/repositories/nply/foundationpkgs.git
+ref=refs/heads/main
+old_rev=0000000000000000000000000000000000000000
+new_rev=...
+actor=gitolite
+```
+
+A gitolite adapter is just a translator from `post-receive` stdin into this event format. GitHub/GitLab/webhook adapters can produce the same format later.
+
+## Jobfile format
+
+A Jobfile is POSIX shell, APKBUILD-like: variables plus functions.
+
+Required/expected variables:
+
+```sh
+project=foundationpkgs
+triggers="refs/heads/main"
+targets="native"
+jobs="packages"
+artifact_path="foundationpkgs"
+```
+
+Runner-provided variables while executing a job:
+
+```sh
+code_dir=/var/tmp/minci-handoff/checkouts/<rev>/code
+config_dir=/etc/minci-handoff
+work_dir=/var/tmp/minci-handoff/build/<job-key>
+artifact_dir=/var/tmp/minci-handoff/build/<job-key>/artifacts
+artifact_url=https://nply.org/dl/<artifact_path>/<target>/<job-key>/
+target=x86_64-unknown-linux-gnu
+ref=refs/heads/main
+old_rev=...
+new_rev=...
+repo_name=nply/foundationpkgs
+repo_url=...
+repo_path=...
+actor=...
+```
+
+Function contract:
+
+```sh
+prepare() { :; }        # optional, once per run
+<job>() { ...; }        # required for each name in jobs
+<job>_artifacts() {     # optional; default is find "$artifact_dir" -type f
+	find "$artifact_dir" -type f
+}
+cleanup() { :; }        # optional
+```
+
+## Common server Jobfile for foundationpkgs
+
+This is the first target Jobfile to install at `/etc/minci-handoff/Jobfile`:
+
+```sh
+# POSIX sh
+project=foundationpkgs
+triggers="refs/heads/main"
+targets="native"
+jobs="packages"
+artifact_path="foundationpkgs"
+
+packages() {
+	cd "$code_dir"
+	find Linux Unix noarch any -name APKBUILD -type f | sort | while IFS= read -r apk; do
+		pkg=$(awk -F= '$1 == "pkgname" { v = $2; gsub(/^"|"$/, "", v); print v; exit }' "$apk")
+		[ -n "$pkg" ] || pkg=$(dirname "$apk" | sed 's#.*/##')
+		out="$artifact_dir/$pkg"
+		mkdir -p "$out"
+		scripts/build.sh -o "$out" -t "$target" "$apk"
+	done
+}
+
+packages_artifacts() {
+	find "$artifact_dir" -type f
+}
+```
+
+## Build key rule
+
+`minci-handoff` should compute a job key from:
+
+- event data: `repo_name`, `ref`, `new_rev`, `target`
+- selected Jobfile content
+- job name
+- files declared by the Jobfile, if it provides `inputs_<job>()`
+- build environment: `MAKEFLAGS`, `CFLAGS`, `CPPFLAGS`, `LDFLAGS`, `PKG_CONFIG_PATH`, `CC`
+- tool versions visible to the runner
+
+For foundationpkgs, the server Jobfile can later add:
+
+```sh
+packages_inputs() {
+	find Linux Unix noarch any scripts -type f | sort
+}
+```
+
+That keeps rebuild criteria in config instead of runner internals.