Skip to content

fix: instantiate the RSR template for contractiles - #21

Merged
hyperpolymath merged 1 commit into
mainfrom
fix/instantiate-template
Jul 27, 2026
Merged

fix: instantiate the RSR template for contractiles#21
hyperpolymath merged 1 commit into
mainfrom
fix/instantiate-template

Conversation

@hyperpolymath

Copy link
Copy Markdown
Owner

Summary

Contractiles was scaffolded from the RSR template but never instantiated: {{PLACEHOLDER}} tokens (and the literal string rsr-template-repo) survived across ~100 files, including the Zig FFI source, which genuinely failed to parse (export fn {{project}}_init()).

  • Substituted identity placeholders with this repo's real values, derived from its own SPDX headers, GitHub metadata, and what "contractiles" (the normative half of the contractile/descriptile pattern in the A2ML/K9 ecosystem) actually is.
  • De-clobbered CODE_OF_CONDUCT.md, which an unrelated estate-wide sweep had stamped with a different project's identity ("Squisher Corpus").
  • Fixed real Zig bugs beyond substitution: Handle was an opaque type with fields (invalid — opaque types can't have fields), callconv(.C) isn't valid under Zig 0.16 (.c is), and std.heap.c_allocator needs libc, which build.zig never linked. Rewrote build.zig to produce a real static-library artifact and wire zig build test to both the inline unit tests and a genuine integration_test.zig (was a fully-commented placeholder).
  • Replaced Justfile fake-gate stubs (build/test/e2e/aspect/bench/lint/deps/install — all unconditional echo) with real idris2/zig invocations; deleted recipes with nothing real to do.
  • Removed template-only machinery: scripts/validate-template.sh, tests/e2e/template_instantiation_test.sh, .machine_readable/ai/PLACEHOLDERS.adoc, and the corresponding sections of benches/template_bench.sh.
  • Rewrote README.adoc, SECURITY.md, CODE_OF_CONDUCT.md, security.txt, and docs/status/TEST-NEEDS.adoc to describe this repo truthfully; dropped fabricated-risk fields (PGP fingerprint/key URL, hiring line) rather than invent them.

Verification (literal exit codes)

zig fmt --check .          → 0
zig build (in ffi dir)     → 0
zig build test             → 0  (11/11 tests passing)
just --list                → 0  (Justfile parses)
just build / just test     → 0

Known residue (left deliberately)

container/*, machine-readable-design/canonical-directory-structure/*, and .machine_readable/configs/{selur-compose,stapeln}.toml still carry {{SERVICE_NAME}}/{{PORT}}/etc. — these are a legitimate recurring template substituted by just container-init, not one-time instantiation artifacts (documented in container/README.adoc). docs/governance/*-AUDIT-TEMPLATE.adoc, .machine_readable/contractiles/Justfile (a stale duplicate of the root Justfile), and build/just/init.just (the now-vestigial bootstrap wizard) were not touched.

Test plan

  • zig fmt --check . exits 0
  • zig build exits 0 in src/interface/ffi
  • zig build test exits 0, 11/11 tests pass
  • just --list parses the Justfile
  • bash tests/e2e.sh and bash tests/aspect_tests.sh run for real (aspect currently reports one known false-positive, documented in docs/status/TEST-NEEDS.adoc)

🤖 Generated with Claude Code

Contractiles was scaffolded from the RSR template but never instantiated:
{{PLACEHOLDER}} tokens (and, separately, the literal string
"rsr-template-repo") survived across ~100 files, including the Zig FFI
source, which genuinely failed to parse (export fn {{project}}_init()).

- Substitute identity placeholders (AUTHOR, OWNER, REPO, PROJECT[_NAME],
  FORGE, CURRENT_YEAR/DATE, LICENSE, etc.) with this repo's real values,
  derived from its own SPDX headers, GitHub metadata, and the A2ML/K9
  ecosystem memory of what "contractiles" (the normative half of the
  contractile/descriptile pattern) actually is.
- De-clobber CODE_OF_CONDUCT.md, which an unrelated estate-wide sweep had
  stamped with a different project's identity ("Squisher Corpus").
- Fix real Zig bugs beyond substitution: `Handle` was an `opaque` type with
  fields (invalid Zig — opaque types cannot have fields), `callconv(.C)` is
  not valid under Zig 0.16 (`.c` is), and `std.heap.c_allocator` requires
  libc, which build.zig never linked. Rewrote build.zig to produce a real
  static-library artifact and wire `zig build test` to both the inline
  unit tests and a genuine integration_test.zig (was a fully-commented
  placeholder). Verified: `zig fmt --check .` exit 0, `zig build` exit 0,
  `zig build test` exit 0 (11/11 tests passing).
- Replace Justfile fake-gate stubs (build/test/e2e/aspect/bench/lint/deps/
  install, all `echo "..."` regardless of outcome) with real invocations
  of `idris2` and `zig`; delete recipes with nothing real to do
  (build-watch's language list, run/run-verbose for a library with no
  executable). tests/e2e.sh gets a real build-the-ABI/build-the-FFI
  pipeline in place of its fully-commented example sections.
- Remove template-only machinery that has no purpose once a repo is
  instantiated: scripts/validate-template.sh,
  tests/e2e/template_instantiation_test.sh,
  .machine_readable/ai/PLACEHOLDERS.adoc, and the corresponding sections
  of benches/template_bench.sh.
- Rewrite README.adoc, SECURITY.md, CODE_OF_CONDUCT.md, security.txt,
  and docs/status/TEST-NEEDS.adoc to describe this repo truthfully;
  drop fabricated-risk fields (PGP fingerprint/key URL, hiring line)
  rather than invent them.

Known residue (left deliberately): container/*, machine-readable-design/
canonical-directory-structure/*, and .machine_readable/configs/{selur-
compose,stapeln}.toml still carry {{SERVICE_NAME}}/{{PORT}}/etc. — these
are legitimate recurring templates substituted by `just container-init`,
not one-time instantiation artifacts (documented in container/README.adoc).
docs/governance/*-AUDIT-TEMPLATE.adoc, .machine_readable/contractiles/
Justfile (a stale duplicate of the root Justfile), and build/just/init.just
(the now-vestigial bootstrap wizard) were not touched.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@hyperpolymath
hyperpolymath marked this pull request as ready for review July 27, 2026 18:17
@hyperpolymath
hyperpolymath merged commit b9b98d7 into main Jul 27, 2026
40 of 43 checks passed
@hyperpolymath
hyperpolymath deleted the fix/instantiate-template branch July 27, 2026 18:17
hyperpolymath added a commit to hyperpolymath/scaffoldia that referenced this pull request Jul 27, 2026
## Summary

scaffoldia (sibling of `contractiles`) was scaffolded from
`rsr-template-repo` but never fully instantiated. Companion cure to
hyperpolymath/contractiles#21, adapted to
scaffoldia's actual (different) disease shape — scaffoldia had already
been partially cured in earlier PRs (#16/#17), so this closes the
*remaining* gaps rather than repeating contractiles' fix verbatim.

* **~420 `{{TOKEN}}` identity placeholders** resolved across ~65 files,
derived from the repo's own SPDX headers, LICENSE file, and GitHub's own
description (`gh repo view hyperpolymath/scaffoldia --json
description`). Deliberately left `container/*`,
`machine-readable-design/{canonical-directory-structure,harvested-registry}/`,
`docs-template/`, and drift-detector files whose job is to literally
match `{{PLACEHOLDER}}` as a pattern.
* **Literal `rsr-template-repo` self-identity string** fixed in ~15
files — most notably `.machine_readable/contractiles/*` (a stale,
never-updated copy of an earlier root `Justfile`) and three onboarding
docs that described a nonexistent installable app with fabricated `just
run`/`just heal`/`just setup` commands. Genuine references to the real
upstream (pipeline mentions, clone-to-start-new-project examples,
provenance notes) were left alone.
* **Two real (non-template) doc bugs** found and fixed:
`docs/attribution/CITATIONS.adoc` linked to
`github.com/hyperpolymath/Scaffoldia` (capitalised, wrong) in all five
citation formats; `docs/developer/ABI-FFI-README.adoc`'s Idris2 example
imported a nonexistent `SCAFFOLDIA.ABI.Foreign` module (real path is
`Abi.Foreign`).
* **Removed a fabricated PGP fingerprint/key** from
`.github/SECURITY.md` and `.well-known/security.txt` — confirmed via
`curl https://github.com/hyperpolymath.gpg` and `gh api
users/hyperpolymath/gpg_keys` that no key has ever been uploaded, rather
than inventing one.

## Zig — the hard requirement

`src/interface/ffi/src/main.zig` had the same three real Zig 0.16
compile bugs as contractiles, beyond placeholder text:
1. `Handle` was `opaque { allocator: ..., initialized: ... }` — opaque
types cannot have fields; changed to a plain `struct`.
2. `callconv(.C)` is not a valid `CallingConvention` member under Zig
0.16 — changed to `.c`.
3. `std.heap.c_allocator` requires libc; `build.zig` never linked it.

`build.zig` was a no-op stub — rewritten into a real build (static
library, `.link_libc = true`, test steps for both the main module and
the integration-test module). `test/integration_test.zig` was a
fully-commented-out placeholder — replaced with 10 real tests exercising
every exported `scaffoldia_*` function.

**Verified:**
- `zig fmt --check .` → exit 0
- `zig build` → exit 0
- `zig build test --summary all` → exit 0, **13/13 tests pass** (3 unit
+ 10 integration)
- `idris2 --build abi.ipkg` → exit 0
- `just --list` → exit 0
- All workflow YAML still parses

## Justfile

Fake-gate recipes (`build`, `build-release`, `test`, `test-verbose`,
`test-smoke`, `e2e`, `aspect`, `bench`, `fmt`, `fmt-check`, `lint`,
`deps`, `install`) replaced with real invocations. `run`/`run-verbose`
deleted (library, no executable). `readiness` deleted (duplicated
`crg-grade`/`crg-badge` with no distinct real check). `clean` fixed — it
previously did `rm -rf ... build/ ...`, which would have deleted the
repo's own tracked `build/` orchestration directory; now targets only
`build/ttc/`, `.zig-cache/`, `zig-out/`.

`tests/e2e.sh` (previously fully commented out) now runs real preflight
+ Idris2 build + Zig build/test. `benches/template_bench.sh` dropped its
two benchmark sections that called the now-deleted scripts and kept the
real ones.

## Deleted template-only machinery

`scripts/validate-template.sh`,
`tests/e2e/template_instantiation_test.sh`,
`.machine_readable/ai/PLACEHOLDERS.adoc`. No workflow referenced them.

`docs/status/TEST-NEEDS.adoc` rewritten — it previously narrated the
deleted `validate-template.sh`'s "8-phase validation" as the repo's own
feature; now describes the real test suite honestly.

## Test plan

- [x] `zig fmt --check .` exits 0
- [x] `zig build` exits 0 (from `src/interface/ffi`)
- [x] `zig build test --summary all` exits 0, 13/13 tests pass
- [x] `idris2 --build abi.ipkg` exits 0
- [x] `just --list` exits 0
- [x] All `.github/workflows/*.yml` still parse as valid YAML
- [x] `git diff --cached --stat` confirms `.editorconfig`,
`.gitattributes`, `.gitignore`, `flake.nix`, `.tool-versions` untouched
- [x] `tests/aspect_tests.sh` passes except the pre-existing,
out-of-scope false positive on proof-doc prose mentioning
"Admitted"/"sorry"

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant