Files
archie/internal/infrastructure/cronstore/kind.go
T
sam 7b13751783 feat(cronstore): add job kind discriminator and bump schema to 2
Jobs need a discriminator for the delivery router to dispatch on, and
JobSpec had none. Add a top-level Kind field with values "chat" (default
when empty) and "workflow".

The empty value is load-bearing: every job written before this field
existed carries no kind and must keep delivering as a chat message, so an
empty Kind resolves to "chat" rather than being rejected.

DisallowUnknownFields means this additive change must bump schemaVersion,
so it goes 1 -> 2. A version-1 file still loads — Kind reads back empty —
which a test pins, because the alternative is that every existing cron job
stops firing on upgrade.

The store does not interpret the value: an unrecognised kind is persisted
verbatim and refused by the router, which owns the kind-to-runner mapping.
2026-09-14 09:54:41 +00:00

25 lines
1.1 KiB
Go

package cronstore
// Kind values for JobSpec.Kind: the discriminator that decides which delivery
// runner handles a job.
//
// They live here, beside the field that carries them, because they are part of
// the on-disk vocabulary — an operator writes one in jobs.json, the strict
// decoder reads it back, and a file written by a build that never heard of it
// must fail loudly rather than deliver the wrong way. Which runner serves a
// kind is not the store's business: the router in
// internal/infrastructure/crondelivery owns that mapping, which is why an
// unrecognised kind is left on disk rather than refused at Create.
const (
// KindChat delivers the job's Payload.Text as a chat message through the
// deployment's channel. It is the default: an empty Kind means KindChat,
// so every job written before this field existed (schema version 1)
// keeps delivering the way it did when it was created.
KindChat = "chat"
// KindWorkflow submits the job as a unit of work through the work-intake
// path, so the existing task lifecycle owns scheduling, retries, gates
// and PR opening.
KindWorkflow = "workflow"
)