qa-twice.sh: round 1 fail 2 (test files failed to load: hls.js was installed only in the worker's worktree, not in the main checkout; npm ci fixed it). Round 2: 347 tests, pass 347 · flaky 0 · fail 0
2 of 3
Fix
blocker fixed with conditional markHlsReady / markHlsError (e61f747e); OUTPUT_MISSING made conditional (64d66721); FE advisories (1e436475)
—
Land: full gates
mvn verify: 1788 tests, 0 failures, 2 skipped, line coverage 96.37% (threshold 90%). npm run test: 610/610. npm run lint: 0 errors, 3 old warnings. npm run build: hls.js in its own chunk
—
Gate 2 (owner)
push (b89acfba..4bb3836c)
—
CI + smoke
CI green (Funny App Build and Deploy, Deploy Frontend, Publish Docs). mock-test.sh 22/22. Read-only prod check: 53 feed videos all carry hlsUrl: null (flag absent/OFF); playlist for an unknown id → 404, for ..%2Fx → 404 (rejected before the controller)
Schema:video_sources.hls_status (NONE default, CHECK) + hls_error, partial queue index (202610240001-video-source-hls.sql).
Transcoding:
HlsStorage validates names and keeps every path inside video-cache/hls/{fileId}/. It also rejects symlinks and publishes by renaming the tmp directory.
FfmpegHlsClient runs ffprobe (H.264 + AAC/MP3 only) and ffmpeg -c copy -f hls, with argument lists and a timeout kill.
HlsTranscodeWorker runs one job at a time. It peeks the queue, takes the file lock, then claims by id. It runs the disk guard, then publishes under conditional markHlsReady, so it never overwrites NONE/PENDING. Startup recovery and an orphan sweep run at boot.
Admin:
SUPER_ADMIN-only PUT/DELETE /admin/videos/{id}/hls with @AuditLog.
AdminVideoDto.hlsStatus/hlsError.
Video delete always removes the rendition.
A re-download resets READY/ERROR to PENDING.
Playback:
Public GET /video-stream/hls/{fileId}/playlist.m3u8 (READY + PUBLISHED + not hidden) and /{segment} (immutable cache, no DB).
VideoDto.hlsUrl is set only when the Harness flag hls_streaming_enabled is on and the video is READY. The flag is read once per request.
Frontend:
hls.js@1.7.3, loaded lazily.
useHlsSource uses native HLS or hls.js and falls back to Range at the same position.
The swiper skips Range preload for HLS videos.
The admin HLS column has a SUPER_ADMIN toggle and polls every 5 s while in progress.
Applied: 3 from plan review, 3 from FE review, 4 from BE round 1, and 1 from BE round 2 (OUTPUT_MISSING). Left open:
BE r1, segments served without a DB/visibility check. This is spec-conformant (BR-13), and the plan Risks row records it.
BE r1, hardcoded https://canh-labs.com in Converter. This is the same debt as embedLink. Follow-up: move it to AppProperties.
BE r2, symlink check is lexical and not atomic with the open (CWE-367). The risk is low, because only the app writes video-cache/hls/.
BE r2, published dir briefly visible while the status is still PROCESSING. It is harmless, because the playlist endpoint requires READY.
Bundle. The main chunk grew about 1.9 kB gzip (+5.2 kB raw) over the whole run. The plan's "< 1 KB" AC was for HL-6 alone, where it was +0.99 kB gzip. The rest is HL-7 admin UI code and i18n. hls.js itself is a separate 186 kB gzip chunk.
Create the Harness flag hls_streaming_enabled, OFF, before or right after the deploy. With no flag, the default false already keeps everyone on Range.
Turn HLS on for one H.264 video in the admin table. It should reach READY in under 30 s. Then open /api/v1/funny-app/video-stream/hls/{fileId}/playlist.m3u8 in Safari: it plays.
Turn HLS on for an iPhone HEVC video. It should end ERROR "unsupported codec".
Turn the flag ON and reload the feed. Network shows .m3u8/.ts for the READY video and /stream/ for the others. Check resume and watch history.
Delete one segment on the VM during playback. Playback continues through Range.
Turn HLS off for the video: the directory is gone. Turn the flag OFF: the feed is back to Range.
Run ./api/mock-test.sh after the deploy.
Rollback note: turn the flag OFF first, then revert HL-7..HL-1, then remove video-cache/hls/ on the VM.