bc38ea1ec7
Co-authored-by: nova28 <17953305+nova28@users.noreply.github.com> Co-authored-by: Carlos Florencio <carlosmflorencio@gmail.com>
4.4 KiB
4.4 KiB
id, title, status, wave, depends_on, plan, requirements, acceptance_criteria, system_design
| id | title | status | wave | depends_on | plan | requirements | acceptance_criteria | system_design | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 01-tick-and-gap | Tick, claim, and gap durability | done | 1 | plan.md |
|
|
|
Task 01: Tick, claim, and gap durability
Summary
Make a cron trigger due while the backend is down produce exactly one run on resume, whatever the gap size, and give that gap a durable, observable record.
In scope
apps/backend/internal/office/routines/service.go:computeCatchUp(replacescomputeRoutineMissed),buildGapSummary,processCronTrigger,reconcileStrandedTriggers,CreateRoutineTriggercron-satisfiability validation.apps/backend/internal/office/models/catchup.go:NormaliseCatchUpMaxclamp [1, 1000];RoutineRun.CatchUpMissedTicks/CatchUpFirstMissedAt/CatchUpTruncated.apps/backend/internal/office/repository/sqlite/{routines.go, catchup_migrations.go,catchup_migrations_postgres.go,wakeup_requests.go}: schema default, idempotentADD COLUMN, table-rebuild migration (SQLite) / dialect-gatedALTER TABLE ... SET DEFAULT(Postgres);GetDueTriggersordering;ListStrandedTriggers/ReconcileTriggerNextRun.apps/backend/internal/office/service/{prompt_builder.go, scheduler_integration.go}:appendMissedTicksSection,applyRoutineCatchUpContext.
Acceptance
- A cron trigger with any elapsed-tick count on resume dispatches exactly one
run;
catch_up_maxbounds only how many ticks are counted. - The gap (missed-tick count, first-missed timestamp, truncated flag) is
stored durably on the created
RoutineRun, written once at creation so a run later marked skipped, coalesced, or failed still carries it. - A cron trigger of kind "cron" is never persisted with a null
next_run_atat creation; a claim left unarmed by a process stopping mid-tick is reconciled by a later tick without dispatching a spurious run. - When the elapsed-tick computation fails,
next_run_atarms to the processing instant plus 24 hours with a warning naming the trigger and the underlying error; a syntactically valid but permanently unsatisfiable expression is instead left disarmed rather than retried forever.
Verification
cd apps/backend && go test ./internal/office/routines/... ./internal/office/repository/sqlite/... -count=1
cd apps/backend && go run ./cmd/sqlguard ./internal
cd apps/backend && KANDEV_TEST_POSTGRES_DSN=... go test ./internal/office/repository/sqlite/... -run Postgres -count=1
Files likely touched
apps/backend/internal/office/routines/service.goapps/backend/internal/office/models/catchup.goapps/backend/internal/office/repository/sqlite/routines.goapps/backend/internal/office/repository/sqlite/catchup_migrations.goapps/backend/internal/office/repository/sqlite/catchup_migrations_postgres.goapps/backend/internal/office/repository/sqlite/wakeup_requests.goapps/backend/internal/office/service/prompt_builder.goapps/backend/internal/office/service/scheduler_integration.go
Dependencies
None.
Parallelism
Sequential with task 02, which renames the policy this task's dispatch path reads.
Results
Implemented with TDD across the build history recorded in this task's Kandev
plan: the tick/claim/reconciliation path, the gap-summary funnel, the
SQLite/Postgres schema and migrations, and the prompt/wakeup payload fields.
Full internal/office suite green; a real PostgreSQL run proved the
dialect-gated default-policy migration.