Skip to content

perf(build): skip AI-author phase on deploy builds (#2761) - #2783

Merged
jung-thomas merged 1 commit into
DEVfrom
worktree-issue-2761-skip-ai-author
Oct 14, 2026
Merged

jung-thomas merged 1 commit into
DEVfrom
worktree-issue-2761-skip-ai-author

Conversation

@jung-thomas

Copy link
Copy Markdown
Contributor

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:

  1. SKIP_AI_AUTHOR flag (default off). build:deploy sets it via cross-env (existing repo pattern, cf. seed-ai-quizzes), skipping the AI phase on deploy builds. rebuild-content.yml leaves it unset, so HANA-served bodies — the ones that actually keep their quizzes — are unaffected.
  2. Fail-open on missing AI Hub binding. The gate resolves the binding once per build; a missing deploymentId skips the whole phase with a single warning instead of 200 per-step throws.

How

  • New pure, unit-tested module 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.ts resolves 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 null deploymentId; env-var read.
  • Full unit suite: the 26 failing files are pre-existing missing-build-artifact / native-dep failures (missing core.bundle.mjs / parsers.bundle.mjs, mediapipe selfie, Vue islands needing npm run setup) — verified to fail identically on clean origin/DEV with fetch-tutorials.ts reverted. None import this change.

Not done here (follow-ups on #2761)

mtar size (#3), 502 upload resilience (#4), deploy-entry-point consolidation (#5).

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.
@jung-thomas
jung-thomas merged commit f50765a into DEV Oct 14, 2026
5 of 6 checks passed
@jung-thomas
jung-thomas deleted the worktree-issue-2761-skip-ai-author branch October 14, 2026 21:55
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.

1 participant