Repository navigation
perf(build): skip AI-author phase on deploy builds (#2761) - #2783
Merged
Merged
Conversation
A deploy build renders ~1400 tutorial bodies that the approuter discards (tutorial HTML is served from HANA BLOBs, not static files), so the expensive AI-author pass on that render is pure waste. Two quick wins from the 2026-10-13 release retro: 1. SKIP_AI_AUTHOR flag — build:deploy sets it via cross-env, skipping the AI-quiz expansion and json-render challenge-spec loop. The content rebuild (rebuild-content.yml) leaves it unset, so HANA-served bodies still get quizzes. 2. Fail-open on missing AI Hub binding — the gate resolves the binding once per build; a missing deploymentId skips the whole phase with one warning instead of up to 200 per-step throw-and-log cycles that burn the AI_AUTHOR_BUILD_CAP. Both share a single decision point (scripts/lib/ai-author-gate.ts). When disabled, unmaterialized [AUTOAUTHOR_*] placeholders are dropped so no placeholder leaks into the page; hand-authored [VALIDATE_N] questions are untouched.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2761 (quick wins #1 and #2 from the release retro; the mtar-size, 502-resilience, and deploy-entry-point consolidation items remain for separate PRs).
What
A deploy build renders ~1400 tutorial bodies that the approuter discards (tutorial HTML is served from HANA BLOBs, not static files — see CLAUDE.md). The expensive AI-author pass (AI-quiz expansion + json-render challenge specs) on that throwaway render is pure wall-clock waste, and when there's no AI Hub binding it burns up to
AI_AUTHOR_BUILD_CAP(200) per-step throw-and-log cycles.Two quick wins, behind one decision point:
SKIP_AI_AUTHORflag (default off).build:deploysets it viacross-env(existing repo pattern, cf.seed-ai-quizzes), skipping the AI phase on deploy builds.rebuild-content.ymlleaves it unset, so HANA-served bodies — the ones that actually keep their quizzes — are unaffected.deploymentIdskips the whole phase with a single warning instead of 200 per-step throws.How
scripts/lib/ai-author-gate.ts→resolveAiAuthorGate()returns{ enabled, reason }. Resolver is injected, so the decision is testable without a real binding.scripts/fetch-tutorials.tsresolves the gate once, logs[ai-author] ENABLED/DISABLED — <reason>, and gates both AI call sites. When disabled, unmaterialized[AUTOAUTHOR_*]placeholders are dropped so none leak into the page; hand-authored[VALIDATE_N]questions flow through untouched.package.json:build:deploy→cross-env SKIP_AI_AUTHOR=1 npm run build:all.Testing
test/lib/ai-author-gate.test.ts— 5 tests, all green: skip short-circuits before probing; enabled when binding resolves (probed exactly once); fail-open on throw and on nulldeploymentId; env-var read.core.bundle.mjs/parsers.bundle.mjs, mediapipe selfie, Vue islands needingnpm run setup) — verified to fail identically on cleanorigin/DEVwithfetch-tutorials.tsreverted. None import this change.Not done here (follow-ups on #2761)
mtar size (#3), 502 upload resilience (#4), deploy-entry-point consolidation (#5).