Skip to content

fix(create-blocks-app): install one copy of @aws-cdk-blocks/core in a new app - #1661

Merged
pranavosu merged 5 commits into
mainfrom
fix/rc-single-core-and-readme-imports
Nov 20, 2026
Merged

pranavosu merged 5 commits into
mainfrom
fix/rc-single-core-and-readme-imports

Conversation

@pranavosu

@pranavosu pranavosu commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

A new app scaffolded by create-blocks-app installs one copy of @aws-cdk-blocks/core under every block (21 to 25 copies) and none at the top level. core keeps module-level registries, so the copies don't share state:

  • getSdkIdentifiers() returns {} for every block, locally and in Lambda.
  • An error thrown by a block fails instanceof ApiError on the server.
  • @aws-cdk-blocks/core can't be imported from app code (TS2307, ERR_MODULE_NOT_FOUND).

The cause is the templates' @types/node ^20.19.43. core's optional peer chain (unctx → unplugin → vitest) ends in @types/node ^22.0.0 || >=24.0.0. npm takes optional peers into account when placing packages, so it can't put core at the top of the app. Published 0.9.0 has the same problem today.

Separately, the KVStore and Database README examples import from @aws-cdk-blocks/core, bb-auth, bb-kv-store and bb-database, which a scaffolded app doesn't declare, so a copied example doesn't compile. The KVStore README also points to transaction() in two packages that don't exist.

Issue #, if available: none

Changes

  • All 13 templates and the backend and Amplify setups in create-blocks-app declare @types/node ^22.12.0. That is the lowest version that satisfies both vite (^20.19.0 || >=22.12.0) and vitest (^22.0.0 || >=24.0.0), and it matches the templates' Node >=22 engine.
  • scripts/canary/run-canary.ts:
    • The canary now fails if a scaffolded app installs more than one copy of @aws-cdk-blocks/core.
    • It now also sets the lowercase npm_config_userconfig. npm run canary exports npm_config_userconfig=~/.npmrc, and the scaffold's own npm install read that instead of the canary's .npmrc, so the app installed @aws-cdk-blocks/* from the public registry rather than from the local build. CI may be affected the same way: the canary passes daily while testing already-published packages.
  • bb-kv-store and bb-database READMEs import their examples from aws-cdk-blocks; the /kysely and /testing entry points still come from @aws-cdk-blocks/bb-database. The KVStore README links to Database transactions.
  • bb-kv-store/scripts/generate-readme-test.mjs compiles the README snippets against the package's own types. It now resolves each name imported from aws-cdk-blocks to the module the umbrella re-exports it from: this package's mock entry, the Auth stand-in, or @aws-cdk-blocks/core. The umbrella depends on this package, so importing it directly from the generated test made the build fail with TS5055.

Validation

  • I ran the canary locally against npm run publish:local and the local registry:

    Template @types/node Copies of core Result
    sql ^20.19.43 21 the new check fails (red)
    sql ^22.12.0 1 build, local e2e (3/3) and cdk synth pass
    api-only ^22.12.0 1 build, local e2e (11/11) and cdk synth pass
    react ^22.12.0 1 build, local e2e (16/16) and cdk synth pass

    After the userconfig fix, every @aws-cdk-blocks/* entry in the scaffolded app's lockfile resolves from the local registry (24 of 24, previously 0 of 30).

  • Rebased on main after the package rename (chore: rename packages to @aws-cdk-blocks, umbrella to unscoped aws-cdk-blocks #1627): names are @aws-cdk-blocks/* and the aws-cdk-blocks umbrella. npm run build and npm run lint pass. Tests pass for bb-kv-store (321, including the README snippet test), bb-database (372) and blocks (634 + 52), and the sql canary passes again from the local registry with one core.

  • npm run lint passes. packages/blocks tests pass. packages/create-blocks-app tests pass, except "refuses to scaffold into an npm workspace that does not list the app's cdk-blocks/ folder", which also fails locally on unmodified main.

  • The README import changes were exercised in a scaffolded sql app against the canary-rc-1-0 build: the Database Quick start compiles and runs with the aws-cdk-blocks imports.

Checklist

  • PR description included
  • Tests are changed or added
  • Relevant documentation is changed or added (and PR referenced)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@pranavosu
pranavosu requested a review from a team as a code owner November 19, 2026 08:57
@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor
📖 Glossary & notes — scoring, indicators, per-metric thresholds (click to expand)
  • N = 1 — one rep per cell, so a small delta may be model variance, not a real change; re-run for certainty.
  • Indicators (change vs baseline, per metric): ✨ noticeably improved · ✅ OK / no significant change (within noise band) · ⚠️ slight regression (beyond 1× threshold) · ❌ serious regression (beyond 2× threshold) · 🆕 new — no baseline value yet (current value shown, tagged (new)) · — nothing to show this run · 🗑️ cell gone since the baseline. Each cell shows <indicator> <value> (<Δ vs main>) inline.
  • Columns: Tests (pass/denom) · Judge (overall 0-10 score with signed delta; per-dimension breakdown lives in the judge artifact JSON) · Cost · Turns (agent cycles) · Score · Stop reason.
  • Threshold definitions (per metric, DELTA_THRESHOLDS in overview.mjs):
    • composite/score: ±5 points — a change ≤5 pts is ✅; >5 improving is ✨; >5 worsening is ⚠️; >10 worsening is ❌.
    • judge (overall): ±0.3 — a shift ≤0.3 is ✅; >0.3 improving is ✨; >0.3 worsening is ⚠️; >0.6 worsening is ❌.
    • tests: ±1 pass — a ≤1 pass change is ✅; >1 improving is ✨; >1 worsening is ⚠️; >2 worsening is ❌.
    • cost: ±10% of baseline (floor $0.02) — within 10% is ✅; >10% cheaper is ✨; >10% more expensive is ⚠️; >20% more expensive is ❌.
    • turns: ±3 cycles — a ≤3 turn change is ✅; >3 fewer is ✨; >3 more is ⚠️; >6 more is ❌.
  • Directions: higher is better for tests, judge, and score; lower is better for cost and turns.
  • Composite (0-100) = round(60·test_rate + 4·judge·min(1, 4·test_rate), 1) — 60% objective pass-rate + 40% judge, the judge term gated below a 25% pass-rate.
  • Cost = builder token spend at Bedrock Claude Opus 4.8 rates ($5 in / $25 out per 1M tokens; BUILDER_PRICING in scoring.mjs).
  • SCORE = composite ÷ cost — composite points per dollar (higher = better). Cost, not raw token volume, is the denominator, so tokens can't dominate; a broken (composite 0) cell scores 0 no matter how cheap. Flip SCORE_PER_DOLLAR in scoring.mjs for cost-per-point (lower = better).
  • Baseline = the most recent main-branch bench (bench/runs/latest-main.json), NOT the PR base commit — the PR always diffs against the current state of main.
  • Excluded from the mean: harness_error cells (infra failures) and gradeable cells that ran no tests. agent_fail (agent produced no app in budget) and dead_server (built app never served / crashed) are BOTH included, as composite 0.
  • Run artifacts — per-cell source + full agent traces · 🕒 Last run: 2026-11-20T00:15:55Z · run #44642056232

Results — PR vs main baseline

Each metric shows its current value colored by the change vs the latest main baseline 6ae587a. ✨ improved · ✅ within noise · ⚠️ slight regression · ❌ serious regression · 🆕 no baseline yet (value shown, tagged (new)).

  • Mean composite 96.5/100 across 3 scored cell(s) — ✨ +9.9 vs main · judge mean 9.13/10.
  • Verdicts: 3 pass · 0 partial · 0 fail · 5 harness_error.
  • Totals: cost $85.55 · tokens 16.6M in / 106.6K out · 248 turns.
  • Biggest gains: collab-presence-board/default (+1.6).
  • Biggest drops: async-word-counter/bare (-1.6), file-gallery/bare (-0.8).
  • Config: baseline 6ae587a.
  • ✅ Composite band 🟢 across 3 scored cell(s). Threshold 65 — pass.
Task Template Tests Judge Cost Turns Score Stop reason
async-word-counter bare ✅ 13/13 (0) ⚠️ 9.2 (-0.4) ❌ $9.21 (+$4.7) ❌ 37 (+15) ❌ 10.5 (-11.3) endTurn
auth-notes demo — — ❌ $32.28 (+$7.4) ❌ 79 (+14) — in_progress
cognito-profile auth — — ✨ $18.73 (-$10.38) ✨ 52 (-22) — in_progress
collab-presence-board default ✅ 11/11 (0) ✨ 9.2 (+0.4) ⚠️ $3.79 (+$0.58) ✅ 17 (0) ✅ 25.5 (-4.2) endTurn
email-digest demo 🗑️ removed (was 12/12) — — — — —
file-gallery bare ✅ 12/12 (0) ✅ 9 (-0.2) ✨ $1.84 (-$0.89) ✅ 12 (-1) ✨ 52.1 (+16.7) endTurn
kb-chat-agent demo 🗑️ removed (was 9/9) — — — — —
observability-api backend — — ❌ $15.94 (+$12.01) ❌ 36 (+11) — in_progress
oidc-dsql-notes react — — — — — —
sql-kb-catalog nextjs — — ✨ $3.76 (-$4.76) ✨ 15 (-14) — in_progress

Merge verdict

✅ This bench run does not block the PR.

  • ✅ Absolute floor — mean composite 96.5 >= floor 65.
  • ✅ Regression vs main — mean composite delta +9.9 pts vs main is within the 10-pt limit.

The Δ vs base ball above is a fixed ±5-pt display band; the regression gate uses BENCH_MAX_REGRESSION. The ball is cosmetic — the gate threshold is what blocks.

Caveats & exclusions

  • 🧰 Excluded (harness_error, not scored) — 5: 4× cancelled, 1× preflight_failed. Cells: auth-notes/demo, cognito-profile/auth, observability-api/backend, oidc-dsql-notes/react, sql-kb-catalog/nextjs

harsh62
harsh62 previously approved these changes Nov 19, 2026
… new app

Templates declared @types/node ^20.19.43. The optional peer chain of
@aws-cdk-blocks/core (unctx -> unplugin -> vitest) ends in @types/node
^22.0.0 || >=24.0.0, so npm nested a copy of core under every block and
none at the root. Templates and the backend/Amplify setups now declare
^22.12.0, matching their Node >=22 engine.

The canary now fails when a scaffold installs more than one core, and
sets the lowercase npm_config_userconfig as well, so the scaffold's own
npm install reads the canary registry instead of ~/.npmrc.
@pranavosu
pranavosu force-pushed the fix/rc-single-core-and-readme-imports branch from 151341c to 3613866 Compare November 19, 2026 17:28
@pranavosu pranavosu changed the title fix(create-blocks-app): install one copy of @aws-blocks/core in a new app fix(create-blocks-app): install one copy of @aws-cdk-blocks/core in a new app Nov 19, 2026

This branch was previously deployed

2 inactive deployments
e2e — effe8ea2 Deployed Nov 20, 2026 by pranavosu via E2E Teardown Verify #7523
agent-bench — effe8ea2 Deployed Nov 20, 2026 by pranavosu via bench / summary #6553
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.

3 participants