@@ -305,19 +305,43 @@ Julia-specific wrappers are not yet written; `ccall` is the direct path.
305305A new Zig-edge repo is one that calls hyperpolymath services via
306306`libzig_api` or extends the Idris2 ABI with repo-specific types.
307307
308- . *Create from template.* Clone `hyperpolymath/rsr-template-repo`, run
308+ **Step 0 (preferred) — use the `zig-edge` Scaffoldia template.**
309+
310+ The template lives at
311+ `reposystem/scaffoldia/registry/zig/zig-edge.ncl`.
312+ It wires `build.zig`, `src/main.zig`, `src/abi/` (Types + Foreign + Layout),
313+ `<name>.ipkg`, `justfile`, `README.adoc`, `.gitignore`, and a minimal CI
314+ workflow in one shot. Invoke via Scaffoldia:
315+
316+ [source,bash]
317+ ----
318+ scaffoldia new zig-edge \
319+ --EDGE_NAME=my-gateway \
320+ --EDGE_PURPOSE="My service API gateway" \
321+ --DEFAULT_PORT=4001 \
322+ --HANDLER_PREFIX=myGateway
323+ ----
324+
325+ If Scaffoldia is not yet set up for your workstation, copy
326+ `reposystem/scaffoldia/registry/zig/zig-edge.ncl`, substitute the four
327+ `{{PLACEHOLDER}}` values manually, and render with `nickel export`.
328+
329+ Manual wiring (steps below) is the fallback when the template cannot be used.
330+
331+ . *Create from template (manual fallback).* Clone `hyperpolymath/rsr-template-repo`, run
309332 `just init`, and customise placeholders.
310- . *Add `libzig_api` to `build.zig`.* Reference the shared library output
311- from `developer-ecosystem/zig-api/ffi/zig/` or install it system-wide via
312- `just install` from the `zig-api` Justfile. A minimal skeleton:
333+ . *Add `libzig_api` to `build.zig`.* Use the pattern from the Scaffoldia
334+ template (`zig-edge.ncl` `build_zig` section) — `createModule` +
335+ `addAnonymousImport("zig_api", …)` + `addLibraryPath` + `addIncludePath` +
336+ `linkSystemLibrary("zig_api", …)`. Static linkage is required; dynamic
337+ linkage does not resolve all `proven_ffi` transitive symbols. A minimal
338+ skeleton (prefer the template over hand-writing this):
313339+
314340[source,zig]
315341----
316- const zig_api = b.addSharedLibraryFromPath(
317- .{ .name = "zig_api", .path = .{ .cwd_relative = PATH_TO_LIBZIG_API } },
318- );
319- exe.linkLibrary(zig_api);
320- exe.addIncludePath(.{ .cwd_relative = PATH_TO_GENERATED_ABI });
342+ edge_mod.addLibraryPath(.{ .cwd_relative = zig_api_lib_path });
343+ edge_mod.addIncludePath(.{ .cwd_relative = zig_api_include_path });
344+ edge_mod.linkSystemLibrary("zig_api", .{});
321345----
322346. *Use the canonical single-port + set_handler shape* (see §"Canonical
323347 single-port shape" above) for all HTTP-serving edge repos. **Do not** bind
@@ -449,6 +473,9 @@ The trigger was the estate-wide V-lang ban on 2026-04-10 (V-lang detected via
449473 source modules. `just check-header` runs in CI (`zig-api-ci.yml`) and fails
450474 the build on any drift.
451475
452- * *Template repo for new edges.* `rsr-template-repo` does not yet include a
453- `build.zig` skeleton that depends on `libzig_api`. A `just new-zig-edge`
454- subcommand in `scaffoldia` or a template overlay is the right long-term fix.
476+ * *Template repo for new edges.* **Resolved 2026-04-17.**
477+ `reposystem/scaffoldia/registry/zig/zig-edge.ncl` is the canonical
478+ Scaffoldia template for new Zig edge repos. It produces `build.zig`,
479+ `src/main.zig`, `src/abi/` (Types + Foreign + Layout), `<name>.ipkg`,
480+ `justfile`, `README.adoc`, `.gitignore`, and `.github/workflows/ci.yml`
481+ pre-wired to the unified stack. See §"Wiring a New Edge Repo" Step 0.
0 commit comments