From 1b4fa61ba458ab596d40338b6084f2496228eebb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Sun, 15 Feb 2026 17:46:24 +0000 Subject: [PATCH] update skills --- stage0/.claude/skills/port-astgen/SKILL.md | 97 ++++++++++++++----- .../skills/port-astgen/worker-prompt.md | 27 ++++-- 2 files changed, 93 insertions(+), 31 deletions(-) diff --git a/stage0/.claude/skills/port-astgen/SKILL.md b/stage0/.claude/skills/port-astgen/SKILL.md index 091945e94d..e8cacd7672 100644 --- a/stage0/.claude/skills/port-astgen/SKILL.md +++ b/stage0/.claude/skills/port-astgen/SKILL.md @@ -7,31 +7,60 @@ disable-model-invocation: true # Port AstGen — Orchestrator -You manage the iterative porting loop. For each iteration you enable a -skipped test, dispatch a worker agent, then verify and commit. +You manage the iterative porting loop. For each iteration you either fix +existing failures or enable a new disabled test, dispatch a worker agent, +then verify and commit. **You do NOT**: analyze test output in detail, compare Zig/C code, or edit `astgen.c`. The worker handles all of that. -## Loop +## Phase 0: Check for leftovers -Repeat until no `SkipZigTest` lines remain in `astgen_test.zig`. +Before enabling anything new, run the existing tests: -### Step 1: Find the first skipped test +```sh +zig build test-zig0 2>&1 | head -20 +``` -Search `stage0/astgen_test.zig` for lines matching: +If tests **FAIL**: dispatch a worker (Step 4 below) with context +describing the failure — no test was "enabled", just paste the first +~20 lines of output and tell the worker existing tests are failing. +After the worker returns, follow Steps 5–7 as normal. Re-run Phase 0 +until existing tests pass before proceeding to the main loop. + +If tests **PASS**: proceed to the main loop. + +## Main Loop + +Repeat until no `SkipZigTest` lines AND no commented corpus entries +remain in `astgen_test.zig`. + +### Step 1: Find the next disabled test + +Search `stage0/astgen_test.zig` in priority order: + +**Priority A — SkipZigTest lines:** +Search for lines matching: ``` if (true) return error.SkipZigTest ``` -Pick the first one. If none found, all corpus tests pass — stop. +Pick the first one. Note the test name (the `test "..."` header above +the skip line) and the line number. -Note the test name (the `test "..."` header above the skip line) and -the line number. +**Priority B — Commented corpus entries:** +If no SkipZigTest lines exist, search for lines matching `//.{ "` inside +the `corpus_files` tuple (between `const corpus_files = .{` and `};`). +Pick the first one. Note the file name and line number. -### Step 2: Comment it out +If neither is found, all tests are enabled — go to the final check. -Comment out the `if (true) return error.SkipZigTest;` line to enable -the test. +### Step 2: Enable the test + +**For SkipZigTest:** Comment out the `if (true) return error.SkipZigTest;` +line to enable the test. + +**For commented corpus entry:** Uncomment the line (remove the leading +`//`). ### Step 3: Quick smoke test @@ -46,7 +75,9 @@ without bloating your context. The worker will run the full test itself. 1. Read the file `.claude/skills/port-astgen/worker-prompt.md`. 2. Replace the placeholder `{{TEST_CONTEXT}}` with the actual context: - - Test name and line number from Step 1 + - What was enabled: test name + line number (SkipZigTest) or + corpus file name + line number (corpus entry) + - Whether this is a SkipZigTest or a corpus entry - The first ~10 lines of test output from Step 3 3. Launch via the Task tool: ``` @@ -60,7 +91,9 @@ The worker returns a structured result. Extract: - `STATUS`: one of `pass`, `progress`, or `no-progress` - `COMMIT_MSG`: a descriptive commit message -### Step 6: Verify build +### Step 6: Handle by status + +**If STATUS is `pass` or `progress`:** Launch a sub-agent to run: @@ -72,10 +105,10 @@ This must exit 0 with no unexpected output. The agent must investigate: 1. Any valgrind errors. 2. Any debug output (should comment out printf statements). 3. Any formatting or staticcheck issues. -3. Any failing tests -- should not happen as agent verifies before returning, - but if it does, the sub-agent should fix them. +4. Any failing tests — should not happen as the worker verifies before + returning, but if it does, the sub-agent should fix them. -### Step 7: Commit +Then commit: ```sh git add stage0/astgen.c stage0/astgen_test.zig @@ -84,13 +117,33 @@ git commit -m " Co-Authored-By: " ``` -### Step 8: Repeat +**If STATUS is `no-progress`:** -Go back to Step 1. **Never stop early** — continue until all `SkipZigTest` -lines are gone, all tests are un-commented and all tests pass. +Do NOT commit. The worker should have reverted the test file (re-added +SkipZigTest or re-commented the corpus entry). Verify with: -If you decide that "it's done", do a final sanity check: +```sh +git diff stage0/astgen_test.zig +``` + +If there are leftover changes (the entry is still enabled), re-comment +the corpus entry or re-add the SkipZigTest yourself. Then: + +```sh +git checkout -- stage0/astgen.c stage0/astgen_test.zig +``` + +Log that this test was skipped due to no progress and continue. + +### Step 7: Repeat + +Go back to Step 1. **Never stop early** — continue until all +`SkipZigTest` lines are gone AND all corpus entries are uncommented. + +## Final Check + +When no disabled tests remain, run: zig build all-zig0 -Dvalgrind -If that fails, go back to 1. +If that fails, go back to Phase 0 (treat it as a leftover). diff --git a/stage0/.claude/skills/port-astgen/worker-prompt.md b/stage0/.claude/skills/port-astgen/worker-prompt.md index bfcbfd0f74..6f319eef56 100644 --- a/stage0/.claude/skills/port-astgen/worker-prompt.md +++ b/stage0/.claude/skills/port-astgen/worker-prompt.md @@ -4,8 +4,10 @@ You are a worker agent porting `AstGen.zig` to `astgen.c`. This is a **mechanical translation** — no creativity, no invention. When the C code differs from Zig, copy the Zig structure into C. -The orchestrator has already enabled a corpus test for you. Your job: -diagnose the failure, port the fix, clean up, and return a result. +The orchestrator has enabled a test for you (either by uncommenting a +corpus entry in `corpus_files` or by commenting out a `SkipZigTest` +line). Your job: diagnose any failure, port the fix, clean up, and +return a result. ## Context from orchestrator @@ -67,8 +69,9 @@ Apply the minimal mechanical change to `astgen.c` to match the upstream. Run - `string_bytes_len` diff decreased - First tag mismatch position moved later -You should mark progress marker (whatever it is from the above) *in/near the -comment of the skipped test*. +You should mark progress marker (whatever it is from the above) *in/near +the disabled test entry* (as a TODO comment on the SkipZigTest line or +above the commented corpus entry). Once there is *any* progress, you MUST clean up and commit per sections below. Do not try to fix everything at once -- clean up & commit early & often. @@ -77,8 +80,11 @@ Do not try to fix everything at once -- clean up & commit early & often. 1. Remove ALL `fprintf`/`printf` debug statements from `astgen.c`. 2. Remove `#include ` if it was added for debugging. -3. If the test still fails: re-add the `if (true) return error.SkipZigTest;` - line with a TODO comment describing the remaining diff. +3. If the test still fails: + - **For a SkipZigTest test:** re-add the `if (true) return error.SkipZigTest;` + line with a TODO comment describing the remaining diff. + - **For a corpus entry:** re-comment the line in `corpus_files` (add `//` + prefix back) and add a TODO comment above it describing the remaining diff. 4. Test if other compilers or valgrind did not regress, fix if it did: zig build fmt-zig0 && zig build all-zig0 -Dvalgrind |& grep -v Warning @@ -92,9 +98,12 @@ STATUS: pass | progress | no-progress COMMIT_MSG: ``` -- `pass` — the enabled test now passes (SkipZigTest was NOT re-added) -- `progress` — partial progress was made (SkipZigTest was re-added with TODO) -- `no-progress` — no measurable improvement (SkipZigTest was re-added) +- `pass` — the enabled test now passes (SkipZigTest was NOT re-added / + corpus entry remains uncommented) +- `progress` — partial progress was made (SkipZigTest was re-added with + TODO / corpus entry was re-commented with TODO above it) +- `no-progress` — no measurable improvement (SkipZigTest was re-added / + corpus entry was re-commented) ## Rules