feat(core,engine): 부트스트랩 리소스 정적 게시(bake) 및 폴백 체계 도입

공개 제보 https://github.com/gnuboard/g7/issues/122 대응 — 초기 부트스트랩
리소스(다국어 병합·컴포넌트 정의·라우트·확장 번들·템플릿 dist)를 캐시 버전
디렉토리(public/build/ext/{v}/)에 실파일로 게시해 웹서버가 rewrite 전에 직접
서빙한다. 부트 임계 경로의 PHP 왕복을 제거하고(실측 TTFB 131~144ms → 1~7ms),
미게시·부분게시·GC 직후에는 fetch·태그·번들 3계층이 종전 API 로 즉시 폴백한다.

- 게시: 원자적 tmp→rename→manifest(존재=완료), 캐시 락 단일 실행, 인라인 GC
 (현재+직전 1개), incrementExtensionCacheVersion 단일 지점 terminating 트리거
 + blade 자가 치유 + 설치기 태스크(best_effort) + 일일 cleanup 스케줄,
 sudo 업데이트 대비 소유권 정상화(normalizeOwnership)·prune/백업 제외
- 프론트(engine-v1.61.0): blade 주입 cache_version 1급 시드(이중 부트 로드 제거),
 fetchStaticFirst 즉시 폴백, ComponentRegistry 버전 키드 매니페스트,
 ModuleAssetLoader 번들 정적→레거시 폴백, asset-url-recovery staticToLegacy 역변환
- 폴백 API 품질: lang/components/routes ETag+304 + 환경 분기 Cache-Control,
 열화 라우트 스냅샷 공개 캐시 금지(서버측 캐시 회피와 대칭), 게시 .htaccess
 mod_deflate + nginx gzip 스니펫(압축 전송량 회귀 방지)
- SEO 정합: 봇 HTML 은 GC 대상 정적 URL 미사용(allowStatic:false), props $switch
 봇측 해석 구현(engine-v1.56.0 패리티), 패리티 룰 expression-dialect 그룹 신설,
 상주 allow 헤더 제거로 잠금 복원, _comment* 접두 주석 키 분류
- 검증: 전 수정 red→green 4단계, Playwright 라이브 21건, Chrome MCP 24축+M1~M3,
 봇 curl 3축, 캐시 저장소(file/redis/database) 축 판정, 히스토리·공개이슈·커밋
 이력 전수 재조사 반영
- 코어 7.0.10, engine-v1.61.0. kill-switch: G7_STATIC_CACHE=false
This commit is contained in:
HeuJung committed 2026-08-25 17:02:53 +09:00
1 parent 56836a2b66
commit 5ba7a83597
73 files changed
+4219 -98

No files matched your search

+32 -2
View File
@@ -8,7 +8,7 @@
import { createLogger } from '../utils/Logger';
import { loadScriptWithRetry } from '../template-engine/networkResilience';
import { convertToCurrentMode } from '../support/assetUrl';
import { convertToCurrentMode, staticToLegacy } from '../support/assetUrl';
const logger = createLogger('ModuleAssetLoader');
@@ -204,6 +204,18 @@ export class ModuleAssetLoader {
};
link.onerror = () => {
// 정적 게시(bake) URL 미스 → 종전 API URL 로 1회 전환 (#122).
// 게시 디렉토리는 GC(현재+직전 1개 보존) 대상이라, 캐시된 HTML 의 구버전
// 정적 URL 이 404 가 될 수 있다 — fetchStaticFirst 와 동일한 즉시 폴백.
const legacy = staticToLegacy(link.getAttribute('href') ?? url);
if (legacy !== null && link.dataset.g7StaticFallback !== '1') {
link.dataset.g7StaticFallback = '1';
logger.warn(`Bundle CSS static miss, falling back to API: ${key} (${url} -> ${legacy})`);
link.href = convertToCurrentMode(legacy);
return;
}
logger.warn(`Failed to load bundle CSS: ${key} (${url})`);
resolve();
};
@@ -240,7 +252,25 @@ export class ModuleAssetLoader {
return existingPromise;
}
const loadPromise = loadScriptWithRetry(url, { id: elementId }, { label: `bundle JS: ${key}` })
// 정적 게시(bake) URL 이면 1회만 시도하고, 미스 시 종전 API URL 로 전환해 기존
// 재시도 예산을 이어간다 (#122 — fetchStaticFirst 와 동형: 정적 1 + 레거시 재시도).
// 게시 디렉토리는 GC(현재+직전 1개 보존) 대상이라 캐시된 HTML 의 구버전 정적
// URL 이 404 가 될 수 있고, 같은 정적 URL 재시도는 그 상태를 복구하지 못한다.
const legacyUrl = staticToLegacy(url);
const attempt = legacyUrl !== null
? loadScriptWithRetry(url, { id: elementId }, { label: `bundle JS: ${key}`, retries: 0 })
.catch(() => {
logger.warn(`Bundle JS static miss, falling back to API: ${key} (${url} -> ${legacyUrl})`);
return loadScriptWithRetry(
convertToCurrentMode(legacyUrl),
{ id: elementId },
{ label: `bundle JS: ${key}` }
);
})
: loadScriptWithRetry(url, { id: elementId }, { label: `bundle JS: ${key}` });
const loadPromise = attempt
.then(() => {
logger.log(`Bundle JS loaded: ${key}`);
const script = document.getElementById(elementId);