Skip to content

Commit 1f8ca50

Browse files
committed
added checks for pkl generation
1 parent 2cccba3 commit 1f8ca50

6 files changed

Lines changed: 59 additions & 5 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Pkl generated parity
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
generated-parity:
12+
name: Generated files match Pkl
13+
runs-on: ubuntu-latest
14+
timeout-minutes: 15
15+
steps:
16+
- name: Check out repository
17+
uses: actions/checkout@v6
18+
19+
- name: Install Nix
20+
uses: cachix/install-nix-action@v31
21+
22+
- name: Run dev-shell generated parity check
23+
run: nix develop -c ./config/pkl/check-generated.sh

config/pkl/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,16 @@ git status --short config/.opencode config/.claude
6161

6262
If regeneration is deterministic and current, there should be no diff after a clean re-run.
6363

64-
5. Run stale-output detection (fails if generated files drift from committed outputs):
64+
5. Run Nix dev-shell integration stale-output test (fails if generated files drift from committed outputs):
6565

6666
```bash
6767
nix develop -c ./config/pkl/check-generated.sh
6868
```
6969

70+
This test intentionally exits non-zero when run outside `nix develop`.
71+
72+
GitHub CI also runs this same command in `.github/workflows/pkl-generated-parity.yml` on `push` and `pull_request`.
73+
7074
## Troubleshooting
7175

7276
- `pkl: command not found`: run commands via `nix develop -c ...` exactly as shown.

config/pkl/check-generated.sh

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,28 @@ set -euo pipefail
44
repo_root="$(git rev-parse --show-toplevel)"
55
cd "$repo_root"
66

7+
if [[ -z "${IN_NIX_SHELL:-}" ]]; then
8+
cat <<'EOF'
9+
This integration check must run in the Nix dev shell.
10+
11+
Run with:
12+
nix develop -c ./config/pkl/check-generated.sh
13+
EOF
14+
exit 1
15+
fi
16+
17+
if ! command -v pkl >/dev/null 2>&1; then
18+
printf 'pkl is not available in PATH. Enter the dev shell with: nix develop\n' >&2
19+
exit 1
20+
fi
21+
722
tmp_dir="$(mktemp -d)"
823
cleanup() {
924
rm -rf "$tmp_dir"
1025
}
1126
trap cleanup EXIT
1227

13-
nix develop -c pkl eval -m "$tmp_dir" config/pkl/generate.pkl >/dev/null
28+
pkl eval -m "$tmp_dir" config/pkl/generate.pkl >/dev/null
1429

1530
paths=(
1631
"config/.opencode/agent"

context/architecture.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ Current target renderer helper modules:
2222
- `config/pkl/renderers/claude-metadata.pkl`
2323
- `config/pkl/renderers/metadata-coverage-check.pkl`
2424
- `config/pkl/generate.pkl` (single multi-file generation entrypoint)
25-
- `config/pkl/check-generated.sh` (stale-output detection against committed generated files)
25+
- `config/pkl/check-generated.sh` (dev-shell integration stale-output detection against committed generated files)
26+
- `.github/workflows/pkl-generated-parity.yml` (CI wrapper that runs the parity check on `push` and `pull_request`)
2627

2728
The scaffold provides stable canonical content-unit identifiers and reusable target-agnostic text primitives for all planned authored generated classes (agents, commands, skills, shared library file).
2829

@@ -36,6 +37,7 @@ Renderer modules apply target-specific metadata/frontmatter rules while reusing
3637
- Both renderers expose per-class rendered document objects (`agents`, `commands`, `skills`) consumed by `config/pkl/generate.pkl`.
3738
- `config/pkl/generate.pkl` emits deterministic `output.files` mappings for all authored generated targets: OpenCode/Claude agents, commands, skills, and `lib/drift-collectors.js` in both trees.
3839
- Generated-file safety markers are part of emitted artifacts: Markdown outputs include an HTML warning comment after frontmatter, and the shared library output carries a leading JS generated warning header.
40+
- `config/pkl/check-generated.sh` is intentionally dev-shell scoped (`nix develop -c ...`): it requires `IN_NIX_SHELL`, runs `pkl eval -m <tmp> config/pkl/generate.pkl`, and fails when generated-owned paths drift.
3941

4042
Generated authored classes:
4143

context/patterns.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
- Use `config/pkl/generate.pkl` as the single generation module for authored config outputs.
3030
- Use `config/pkl/README.md` as the contributor-facing runbook for prerequisites, ownership boundaries, regeneration steps, and troubleshooting.
3131
- Run multi-file generation with `nix develop -c pkl eval -m . config/pkl/generate.pkl` to emit to repository-root mapped paths.
32-
- Run stale-output detection with `nix develop -c ./config/pkl/check-generated.sh`; it regenerates into a temporary directory and fails if generated-owned paths differ from committed outputs.
32+
- Run stale-output detection with `nix develop -c ./config/pkl/check-generated.sh`; the script is a dev-shell integration test, exits non-zero outside `nix develop`, regenerates into a temporary directory, and fails if generated-owned paths differ from committed outputs.
33+
- Keep CI parity enforcement aligned with local workflow by running the same command in `.github/workflows/pkl-generated-parity.yml` on both `push` and `pull_request`.
3334
- For non-destructive verification during development, run `nix develop -c pkl eval -m context/tmp/t04-generated config/pkl/generate.pkl` and inspect emitted paths under `context/tmp/`.
3435
- Keep `output.files` limited to generated-owned paths only (`config/{opencode_root}/{agent,command,skills,lib}` and `config/{claude_root}/{agents,commands,skills,lib}` where roots map to `.opencode` and `.claude`).
3536
- Keep the shared drift library generated warning marker in `config/.opencode/lib/drift-collectors.js` (the canonical copied source) so both target library outputs inherit a stable, non-duplicating safety header.

context/plans/pkl-config-generation.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ Create a deterministic Pkl-based generation workflow that produces both configur
132132
- Regenerated all generated-owned outputs with `nix develop -c pkl eval -m . config/pkl/generate.pkl` and verified clean-state determinism via `nix develop -c ./config/pkl/check-generated.sh`.
133133
- Ran task-level checks and light build gate: `nix develop -c pkl eval config/pkl/renderers/metadata-coverage-check.pkl`, `nix develop -c pkl eval config/pkl/generate.pkl`, and `nix flake check --no-build`.
134134

135-
- [ ] T08: Validation and cleanup (status:todo)
135+
- [x] T08: Validation and cleanup (status:done)
136136
- Task ID: T08
137137
- Goal: Run final end-to-end validation, ensure docs and generated outputs are aligned, and clean temporary artifacts.
138138
- Boundaries (in/out of scope):
@@ -144,6 +144,15 @@ Create a deterministic Pkl-based generation workflow that produces both configur
144144
- Temporary planning/execution artifacts are cleaned.
145145
- Verification notes (commands or checks):
146146
- Run full planned validation checks and capture evidence in the plan update.
147+
- Evidence:
148+
- Added Nix dev-shell integration parity behavior to `config/pkl/check-generated.sh`: the check now requires `IN_NIX_SHELL`, evaluates `config/pkl/generate.pkl` with `pkl` directly inside the shell, and diffs generated-owned paths against committed outputs.
149+
- Updated `config/pkl/README.md` command guidance to describe `nix develop -c ./config/pkl/check-generated.sh` as the Nix dev-shell integration stale-output test and documented the outside-shell non-zero expectation.
150+
- Captured clean-state parity evidence with `nix develop -c ./config/pkl/check-generated.sh` (pass: "Generated outputs are up to date.").
151+
- Re-ran generator and metadata validations: `nix develop -c pkl eval config/pkl/generate.pkl` and `nix develop -c pkl eval config/pkl/renderers/metadata-coverage-check.pkl`.
152+
- Validation report (commands, exit codes, key outputs): `nix develop -c ./config/pkl/check-generated.sh` (exit 0; output includes `Generated outputs are up to date.`), `nix develop -c pkl eval config/pkl/generate.pkl` (exit 0), `nix develop -c pkl eval config/pkl/renderers/metadata-coverage-check.pkl` (exit 0), `nix flake check --no-build` (exit 0), and `nix flake check` (exit 0).
153+
- Lint/format validation note: this repository currently defines no separate global lint/format gate beyond the Nix-based checks above for this scope.
154+
- Confirmed temporary artifact cleanliness for this task: `context/tmp/` contains only `.gitignore`.
155+
- Residual risk: full multi-platform flake validation remains host-scoped; Nix reported incompatible systems omitted (`aarch64-darwin`, `aarch64-linux`, `x86_64-darwin`).
147156

148157
## 5) Open questions
149158
- None. Scope choice confirmed: shared canonical source with authored-file generation only.

0 commit comments

Comments
 (0)