Prototype loop

From danielraffel/pulp · View interactive version

Prototype loop is an AI agent skill from the GitHub repository danielraffel/pulp. Leveraged-prototype dev loop (`pulp loop`) — focus marker plus normal watch/rebuild loop, with AOT analyzer guidance and deferred ar-swap/PR-monitor playbook. Use when porting an existing UI/bundle to Pulp, doing visual/behavioral parity work, or batching upstream framework gap fixes.

How to use this skill

Skill file

Prototype Loop Skill

Codifies the leveraged-prototype dev loop for closing framework gaps during

high-feedback UI parity work.

When to use this skill

Trigger this skill when the user is doing any of:

Do not trigger for: bugfixes, cross-platform refactors, or final-landing flows. Those want the cross-platform default.

When NOT to use this skill

The loop in one breath

analyze → file → prototype (ar-swap) → monitor → bump → ship

Each step has tooling. The CLI loop is available now; deeper archive-splice, issue-monitoring, and analyzer-lift work should land separately.

Current surface

| Surface | Status |

|---------|--------|

| pulp loop CLI + skill + slash command + docs | available |

| pulp-ar-swap.sh ABI-checked archive splice | deferred |

| pulp loop --watch-issues PR-monitor | deferred |

| Lift @pulp/css-adapt, pulp-css-analyze, extract-html-bundle | deferred |

Step 0 — Start a new worktree warm, not cold

A fresh worktree's first build is a full configure plus every compile and

link, even when the worktree you branched from built the same tree minutes

ago. On macOS/APFS, pulp build --seed-build (or PULP_SEED_BUILD=1 in the

environment so every first build does it) runs

tools/scripts/seed_build_dir.py before the first configure. It clonefiles

the warm Ninja build dir of the sibling worktree closest to HEAD (shared

blocks, no data copied) and retargets it: text files that name the donor

path are rewritten, .ninja_deps is re-emitted, .ninja_log command hashes

are recomputed, binaries that embed the donor path are dropped, and unchanged

clean sources get the donor's mtimes. The first build is then only what

differs from the donor. Receipt: build/.pulp-seed-receipt.json (edges left

to build, path-tainted binaries dropped, timings).

What to know before trusting it:

date is rebuilt, and it reads the donor without writing it (the suite

audits the donor's inodes and mtimes).

PULP_BUILD_EXAMPLES, same APFS volume, and not mid-build. Anything else

is refused with exit 3 and nothing left behind, and pulp build configures

from scratch as usual. Cross-volume never silently copies.

everything; a Debug donor (-g) embeds the path in every object and gains

only the configure. Targets whose -D defines carry the source dir

recompile regardless.

copy of build.ninja. A plain ninja -n stops at CMake's always-dirty

glob check and reports 2, and counting its status lines undercounts,

because a dry run skips the status line of edges that finish together.

When cmake_rerun_pending is non-empty (a CMakeLists.txt differs from

the donor's, e.g. a VERSION bump) CMake re-runs first and the count is a

lower bound.

selector widens to all; on a seeded dir that is exactly the leftover

edges, not a full build.

Never start the worktree under /tmp or $TMPDIR. Configure and

governed-build.sh refuse it (exit 3), because a temporary tree misses the

shared ccache and starts every build cold; create it under

$PULP_WORKTREES_ROOT or beside the primary checkout. A second pulp build

into a tree that is still building exits 75 and names the running build:

attach to that one instead of relaunching. pulp loop takes the same lock for

each rebuild, so a loop and a manual pulp build in one tree cannot race; a

rebuild that finds another build holding the tree reports 75 and the loop keeps

watching.

Step 1 — AOT analyze the consumer's bundle

Run pulp-css-analyze over the consumer's pre-built React bundle. The output is a coverage report listing unmapped CSS props with occurrence counts.

Reference output shape:

Unmapped CSS props (8 total):
  fontFamily            14×   examples: src/Label.tsx:23, src/Header.tsx:8, ...
  textAlign             6×    examples: src/Caption.tsx:12, ...
  ...

The occurrence counts are how you prioritize — file the 14× issue first.

Step 2 — File framework issues with the right shape

Each gap deserves its own issue. Use this shape:

Filing 6 well-shaped issues with concrete signatures cuts upstream ramp-up dramatically. If you're going to file an umbrella + sub-issues, link the sub-issues from the umbrella's body so the dashboard view is coherent.

Step 3 — Enter focus mode (`pulp loop`)

pulp loop                       # auto-detect host platform
pulp loop --platform=macos      # explicit override
pulp loop --status              # report current state
pulp loop --off                 # restore cross-platform mode

The CLI persists [loop] focus_platform = "..." in ~/.pulp/config.toml. Subsequent invocations stay pinned until explicitly cleared.

The watch loop is also focused on the working diff by default: before every

rebuild it re-runs the affected-target selector (pulp affected, script

tools/scripts/affected_targets.py) and passes cmake --build --target only

the targets that own the diff plus their companion test programs

(test_<stem>*.cpp), following add_dependencies and CTest fixture edges. With

--test it runs only those tests via ctest --tests-from-file. A one-line

.cpp edit in core/view rebuilds pulp-view-core + pulp-test-widgets in

seconds instead of relinking ~1,400 programs. The banner it prints is the

contract:

FOCUSED: building 3/1708 targets affected by your diff - run 'pulp build --all' before opening a PR

build; --target and --test-filter always win; PULP_BUILD_FOCUS=0

disables focus for a shell.

build-system change, an unmapped C/C++ file, or a selection above ~40% of the

target graph. Header edits focus only when a dependency database exists

(ninja -t deps or Makefile .o.d files).

record the CMake file-API codemodel it selects from.

all; run pulp build --all && pulp test --all before shipyard pr.

A fresh source-checkout configure leaves the example projects off (-DPULP_BUILD_EXAMPLES=OFF) and pins Ninja + Release, like pulp build. When the prototype lives under examples/, pass pulp loop --examples so the first configure (or a reconfigure of a tree that has examples off) includes it. An existing tree an older CLI left on Makefiles, Debug, or examples ON is migrated on the first pulp loop: its cache moves to build/.pulp-pre-migration/, one Reconfiguring … (was: …) line prints, and the tree configures fresh (a one-time full rebuild). A prototype under examples/ must therefore pass --examples on every run, or the migration turns examples back off; PULP_KEEP_BUILD_CONFIG=1 keeps a tree as it is.

In an SDK project on macOS, pulp loop (like pulp dev) links plug-ins against

the development-only shared Pulp runtime (PULP_DEV_SHARED_UI=ON): each VST3,

CLAP, AU or Standalone module is about a megabyte, so a one-file edit relinks in

a fraction of the static time. Those bundles load only from this build tree and

pulp ship refuses them, so run pulp build (it switches the dir back to static

links, a relink only) before handing a build to anyone. --no-dev-shared keeps

static links for a session, for example in a sandboxed host that will not load

code from outside the bundle. The source checkout keeps static links.

--no-watch flips state and exits without entering the watch loop — this is what tests use, and it's also useful when you want the marker but plan to drive builds yourself.

Step 4 — Local prototype via ar-swap

Pick the simplest gap from your filed issues. Build the framework patch in another worktree:

git worktree add ../pulp-fix-issue-X feat/fix-issue-X
cd ../pulp-fix-issue-X
cmake --build build --target pulp-view

The planned pulp loop --ar-swap-from ../pulp-fix-issue-X helper will splice the changed .o files into the pinned SDK's static archive after validating header/library ABI. The validator refuses on vtable mismatch — the failure mode where a consumer compiles against stale layout assumptions such as Label::font_family_.

Until that helper lands, do the ar-swap by hand:

  1. Build the patched object file in the other worktree.
  2. nm -gU the object — make sure exported symbols match what your consumer's compile expects.
  3. ar -r <pinned-sdk>/lib/libpulp-view.a <patched.o> — splice.
  4. Visually validate via pulp-screenshot or another explicit capture path.
  5. DELETE the local archive after validation. Otherwise you'll forget it's spliced and ship a binary that doesn't match the upstream pin.

Step 5 — Monitor upstream PR state flips

When automatic upstream monitoring is available:

pulp loop --watch-issues 924,927,931,932

will poll gh pr list for state flips on PRs referencing the named issues. It fires a notification when each PR transitions to MERGED.

Until then, run this in a side terminal:

watch -n 60 'gh pr list --state merged --search "924 OR 927 OR 931 OR 932" --json number,title,mergedAt'

Step 6 — Bump SDK pin and validate cross-platform

After the upstream batch merges and auto-releases:

  1. Bump the consumer's SDK pin in one shot (e.g. 0.52.0 → 0.56.0 if v0.53/v0.54/v0.55/v0.56 each came from one of the merged PRs). Update pulp.toml / find_package(Pulp …).
  2. Run pulp loop --off — restore cross-platform mode.
  3. Run shipyard pr (or pulp pr) — full cross-platform validation gates the merge. This is the contract: focus mode for iterating, cross-platform for landing.

Filing follow-up issues

When you discover a new framework gap while in focus mode, file it the same way as Step 2. Don't fix it locally and forget — the loop's discipline is upstream-first.

If you fixed something locally to keep iteration moving and the upstream issue isn't merged yet, leave a // TODO(issue-NNN) marker and a planning doc note in the consumer. The skill is "file framework issues immediately", not "fix and forget".

Switching modes

The mode is advisory at the build layer today. The marker is read by tooling that wants to know "is the developer iterating or landing?", but it does not silently hide cross-platform breakage. Keep the marker semantically clean: "I am iterating, please don't surprise me with cross-platform configure cost."

Common pitfalls

Slash command

The Claude Code slash command lives at CODE0. It asks the user to confirm the focus platform, then orchestrates the loop.

Reference

Transactional graph-file development reload

The C++ dev/loop delegate accepts --graph-file with an existing enrolled

--graph-instance, consent --graph-grant and --graph-generation. Reuse

SignalGraphControlAuthority, the product catalog, strict shared parser and

prepared-edit publication; no extension-only watcher or direct executor bypass.

The serialized control request stays bounded at 512 KiB. See

docs/guides/graph-file-reload.md for limitations and numeric installed proof.

The public transaction admits at most 1 MiB for either format; the broker's

512 KiB serialized bound also counts JSON escaping. Building can outlast a control

lease: renew only through the caller's existing grant, and refuse expired/revoked

authority instead of silently acquiring a new grant or lease.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.