Skip to content

fix: make preview startup and task saves resilient - #85

Merged
nquyencubas523-cloud merged 3 commits into
mainfrom
codex/fix-save-or-update-atomic-20260803
Aug 4, 2026
Merged

fix: make preview startup and task saves resilient#85
nquyencubas523-cloud merged 3 commits into
mainfrom
codex/fix-save-or-update-atomic-20260803

Conversation

@nquyencubas523-cloud

Copy link
Copy Markdown
Contributor

Summary

  • forward valid small startup IDR packets instead of reopening the preview encoder and waiting indefinitely for a larger keyframe
  • route single and batch task saves through one service-layer SaveOrUpdateTask operation
  • validate schedules and resource admission before creating tasks or changing parameters, areas, schedules, or enable state
  • restore the previous parameters and areas when a parameter update fails
  • only apply resource admission to real disabled-to-enabled transitions

Root cause

Preview startup treated a valid keyframe as invalid based only on encoded packet size. The encoder was reopened repeatedly, so channel 1 algorithm overlay preview could fail until the device was restarted.

Task saving performed parameter, area, and strategy updates before SwitchTask(true) checked the resource score. When that final check returned ResourceLimit, the API reported failure after task state had already been persisted, with no transaction or compensation path. Batch apply used the same sequence.

Impact

Valid preview startup frames are now published normally. A failed task save is rejected before mutation when its schedule or start-resource admission is invalid, so callers no longer receive an error after partial state has been applied. Existing enabled tasks can still update parameters while the device is busy because no new start transition is required.

Validation

  • x86 build and full test suite passed: https://github.com/cosmo-wander-ai/cosmo-edge/actions/runs/30814785785
  • Sophon package and test binary build/upload passed: https://github.com/cosmo-wander-ai/cosmo-edge/actions/runs/30814785449
  • Sophon target tests passed directly on the test device:
    • [save-or-update]: 2 cases, 72 assertions
    • [video-task-handler]: 34 cases, 96 assertions
  • resource score 200 regression test returns ResourceLimit without creating or changing a task
  • controlled invalid-schedule save left taskList.json, param.json, and area.json byte-identical
  • successful save and restore round trip passed on 192.168.100.1
  • algorithm overlay preview returned FLV data with a valid header, about 164 ms first-frame latency, and zero preview failures
  • deployed Sophon binary remained healthy with no crashes or service restarts

The Sophon CI hardware-test job is still queued on the self-hosted runner; the same generated test binary has already passed the targeted suites directly on the target device.

@nquyencubas523-cloud
nquyencubas523-cloud marked this pull request as ready for review August 4, 2026 02:42
@nquyencubas523-cloud
nquyencubas523-cloud merged commit 2eaf5fd into main Aug 4, 2026
7 checks passed
@nquyencubas523-cloud
nquyencubas523-cloud deleted the codex/fix-save-or-update-atomic-20260803 branch August 4, 2026 02:42
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