feat: add DB inline content cache for app asset draft files

Introduce app_asset_contents table as a read-through cache over S3 for
text-like asset files (e.g. .md skill documents). This eliminates N
individual S3 fetches during SkillBuilder builds — bulk_load pulls all
content in a single SQL query with S3 fallback on miss.

Key components:
- CachedContentAccessor: DB-first read / dual-write / S3 fallback
- AssetContentService: static DB operations (get, get_many, upsert, delete)
- should_mirror(): single source of truth for extension-based policy
- Alembic migration for app_asset_contents table

Modified callers:
- SkillBuilder uses accessor.bulk_load() instead of per-node S3 reads
- AppAssetService.get/update_file_content route through accessor
- delete_node cleans both DB cache and S3
- draft_app_assets_initializer uses should_mirror() instead of hardcoded .md
This commit is contained in:
Harry
2026-03-09 14:44:21 +08:00
parent 53f76a20c2
commit a8074f4f4a
11 changed files with 391 additions and 52 deletions

View File

@ -9,7 +9,7 @@ from .account import (
TenantStatus,
)
from .api_based_extension import APIBasedExtension, APIBasedExtensionPoint
from .app_asset import AppAssets
from .app_asset import AppAssetContent, AppAssets
from .comment import (
WorkflowComment,
WorkflowCommentMention,
@ -136,6 +136,7 @@ __all__ = [
"App",
"AppAnnotationHitHistory",
"AppAnnotationSetting",
"AppAssetContent",
"AppAssets",
"AppDatasetJoin",
"AppMCPServer",