Repository navigation
Description
Description
assets/init-workspace.sh has two code paths for placeholder substitution
({{SHORT_NAME}}, {{ORG_NAME}}, {{GITHUB_REPOSITORY}}):
- The manifest fast path:
flake.nix(around line 1476) greps the
template at image build time and bakes the file list into
/root/assets/.placeholder-manifest.txt; the script then runs one
sed -iper manifest entry (~117 forks).test_image.py:: test_placeholder_manifest_bakedpins that the file exists. - The fallback (manifest absent): since [CHORE] BATS runtime: parallelize the suite, batch the init-workspace.sh fork loops, collapse redundant scaffolds #1687 one batched
grep -rl --null --exclude-dir=.git … | xargs -0 -r sed -i ….
The fast path exists only inside the image (its path translation hardcodes
/root/assets/workspace), consumers reach it through install.sh → the
container, and BATS never exercises it (host-side runs hit the fallback).
Measured in #1687: 117 per-file sed -i ≈ 2.6s vs ≈ 0.15s for the batched
form — the "fast" path is 15-20x slower than the fallback it was meant
to beat, and it is the one code path the suite does not cover.
Retiring it leaves one substitution routine that is faster than both,
covered by 300 BATS tests, and identical on host and in the image. Deleted
with it: the flake build step, the manifest test, and the host/image
divergence.
Acceptance Criteria
-
init-workspace.shhas one substitution path (the batched
grep -rl | xargs sed -iform); theMANIFEST_FILEbranch, the
MANIFEST_FILEvariable and the "Using build-time manifest" /
"Manifest not found" messages are gone - The
.placeholder-manifest.txtbuild step is removed fromflake.nix
and the image no longer ships the file (test_placeholder_manifest_baked
inverted or replaced by a negative pin) - A scaffold rendered in the container (
install.sh/test_integration)
is byte-identical to one rendered by the previous image, permissions
included — the [CHORE] BATS runtime: parallelize the suite, batch the init-workspace.sh fork loops, collapse redundant scaffolds #1687 WP2 proof method (diff -r+find -printf '%m %y %p') applied across the old/new image, not just host-side -
init-workspace.bats300/300,install.bats95/95,test_image.py
andtest_integration.pygreen in CI - CHANGELOG
Changedentry (consumer-visible: the image changes and the
substitution log lines change)
Implementation Notes
- The batched form's selection semantics (regular files,
.git/excluded,
symlinks inside the tree not followed, binaries matched) are documented
inline at the fallback since [CHORE] BATS runtime: parallelize the suite, batch the init-workspace.sh fork loops, collapse redundant scaffolds #1687 — keep that comment as the routine's
contract. grep -rwalks the whole workspace, not just the template tree; in the
image that is the consumer's repo. The manifest path only touched files the
template shipped. Confirm the batched walk cannot rewrite a consumer file
that happens to contain a{{…}}token — the old fallback had the same
reach and no report ever came, but a scoped walk ($TEMPLATE_DIR-derived
paths, likesweep_scaffold_writabledoes) would be the conservative
choice and is also cheaper. Decide and record it.- Check
docs/and the#718/#802history for prose that describes the
manifest so it does not go stale.
Related Issues
- Follows [CHORE] BATS runtime: parallelize the suite, batch the init-workspace.sh fork loops, collapse redundant scaffolds #1687 (WP2 notes flagged this as the follow-up); PR chore(ci): cut the BATS suite runtime #1690
- Introduced by perf: bake the build-time placeholder manifest into the Nix image #718 / perf(image): bake the build-time placeholder manifest into the Nix image #802
Priority
Low
Changelog Category
Changed
Activity
test(init): pin consumer-owned placeholder tokens against the substit…
fix(init): scope placeholder substitution to the files devkit ships
build(image): stop baking the placeholder manifest
docs(changelog): record the scoped placeholder substitution
test(init): pin the substitution pass against a trailing TEMPLATE_DIR…
fix(init): normalize a trailing slash off the candidate walk's source…
test(init): pin the candidate walk's .git/.venv pruning to rsync's se…
fix(init): prune .git and .venv by name at any depth in the candidate…
c-vigo commentedon Sep 25, 2026
Correcting the premise before the fix lands, because the numbers in the issue do
not survive measurement.
The manifest has 13 entries, not ~117.
assets/workspace/is 117 files, butonly 13 of them carry a substitution token, and the manifest is grepped from that
tree — so the "~117 forks" figure counted the template, not the manifest.
Speed is noise. Timed on a clean tree: manifest path 31 ms, batched
fallback 16 ms. Both are irrelevant against a ~270 ms scaffold. The
"15-20x slower" framing came from applying #1687's 117-file
sed -imeasurementto a list that is 13 entries long. The fast path is not the disaster the issue
describes, and "it is slower than the fallback" is not a reason to retire it.
The real defect is scope, and it is in the survivor. The batched fallback
greps
$WORKSPACE_DIR. In the image that is the consumer's mounted repo,.venvandnode_modulesincluded. Any consumer-owned file carrying a literal{{SHORT_NAME}},{{ORG_NAME}}or{{GITHUB_REPOSITORY}}is rewritten inplace — on the first scaffold, and again on every upgrade. Reproduced with
seeded files: a
docs/*.tmplholding all three tokens comes back asname: testproj / org: test / repo: test/repo. The manifest path never had thatreach, so retiring it and keeping the fallback as-is would have made the
consumer-facing behaviour strictly worse, not better.
So the change is not "delete the fast path" but one routine, scoped to the
files devkit ships, derived exactly as
sweep_scaffold_writablederives itschmodset (template tree → workspace destinations), plus the smoke overlaywhen one was applied. That answers the implementation note's open question:
the scoped walk is the conservative choice and the cheaper one — on a
7.4k-file consumer tree, 405 ms → 38 ms.
Acceptance criteria are otherwise unchanged and all met, except criterion 3
(old-image vs new-image
diff -r+%m %y %p), which needs the PR's imagebuilt; the host-side equivalent is clean across all four modes,
--smoke-test,and a Node scaffold with
DEVKIT_LICENSE=proprietary, and the image-level runfollows on the CI artifact.
One scope note for the record:
docs/carries no prose about the manifest. Theonly mentions are in
docs/issues/issue-718.md,docs/issues/issue-1687.md,docs/pull-requests/pr-802.mdandpr-813.md— historical records of thosechanges — and the released
CHANGELOGentry for #718. None are rewritten.fix(init): scope placeholder substitution to the paths devkit ships (#…
c-vigo commentedon Sep 25, 2026
Shipped to
devin #1707 with the old/new image byte-identity proof in the PR comments. Follow-ups: #1700 (the chmod sweep walks the baked .venv), #1703 (trailing-slash walks).fix(init): walk the template through one pruned candidate emitter (#1715
chore: release 1.17.0 (#1734)