Documentation
¶
Overview ¶
Package workflow holds the JumpCloud Workflows wire contract and DSL validator shared by the CLI (internal/cmd) and the MCP server (internal/mcp), so the two surfaces cannot drift on the endpoints, the three different list envelopes, or the DSL rules.
The OpenAPI spec declares a workflow's DSL as a bare `dsl: object` — no schema, no field list. The real specification is JumpCloud's public "Workflows Public API & DSL Guide", vendored at docs/reference/workflows-dsl.md; every validation rule in validate.go cites a documented statement from it. What follows is what live probing against org 5ec71e8e96bfda0611fc6c5b on 2026-08-27 established beyond, or against, both documents:
- Three list envelopes in one area: /workflows and /workflows/runs answer {totalCount, results}, but /workflows/templates answers {templates:[…]}.
- Runs OUTLIVE their workflow. A run for a workflow deleted weeks earlier still lists, carrying workflowDeletedAt. Runs are an audit trail, not a child collection — neither document mentions this.
- trigger_type (jc_events | external | scheduler) is response-only; it is derived server-side from the DSL's trigger block and is not accepted on create.
- The guide's jc_operation `with` field list omits `version`, but all 33 jc_operation steps across the 12 shipped templates carry it, and its value tracks the operation's API version exactly (v1 path → 1, v2 path → 2) with zero mismatches. It is real and fully derivable, so this package emits it and validates it rather than ignoring it.
- A completed run carries executionDetails.nodes: a per-step trace with each step's input, output, and the HTTP method, URL and status the step actually called. Undocumented in both the spec and the guide, and the only way to see why a run failed.
- Placeholders in shipped templates are REPLACE_WITH_* and may carry a numeric suffix (REPLACE_WITH_GROUP_ID_1).
- Half the shipped catalog has side effects: 6 of 12 templates send email and 2 call external connectors. Initialising from a template routinely produces a DSL that needs --allow-side-effects.
Index ¶
- Constants
- Variables
- func AnnotateAllLastRan(rows []json.RawMessage, lastRan map[string]string) []json.RawMessage
- func AnnotateLastRan(row json.RawMessage, lastRan map[string]string) json.RawMessage
- func ComparePathParams(op Operation, with map[string]any) (missing, unexpected []string, ok bool)
- func CorrectedTemplateRow(ct CorrectedTemplate) map[string]any
- func CreateBody(w Workflow) map[string]any
- func EffectiveSince(w Workflow, since time.Time) time.Time
- func EventFields(eventType string) []string
- func EventTypeCount() int
- func EventTypes(service, search string) map[string]EventType
- func IsCorrectedID(identifier string) bool
- func JumpTargets(top []Task) map[string]bool
- func JumpsAway(t Task) bool
- func KnownEventField(eventType, field string) bool
- func LastRanByWorkflow(runs []Run) map[string]string
- func LintWorkflow(w Workflow) (LintSubject, DSL, bool)
- func NewestEventTime(events []json.RawMessage) (time.Time, error)
- func NormalizeMarker(name string) string
- func ObservedEventTypes(items []json.RawMessage) (map[string]int, error)
- func OperationCount() int
- func OperationIDs() []string
- func ParseList(raw json.RawMessage) ([]json.RawMessage, error)
- func ResolveID(rows []json.RawMessage, identifier string) (string, error)
- func RunEndpoint(runID string) string
- func RunsWithin(runs []Run, workflowID string, since time.Time) int
- func ScaffoldDSL() json.RawMessage
- func ServedTemplateRow(id, name, category, description string) map[string]any
- func SortComparison(tasks []TaskComparison)
- func SortHealth(reports []HealthReport)
- func SuggestEventType(name string, limit int) []string
- func SuggestOperation(id string, limit int) []string
- func TemplateEndpoint(id string) string
- func TriggerBody(data map[string]any) map[string]any
- func TriggerEndpoint(id string) string
- func UnreachableTasks(tasks []Task) map[string]bool
- func UpdateBody(w Workflow) map[string]any
- func WorkflowEndpoint(id string) string
- type CatalogAudit
- type CatalogGap
- type Comparison
- type CorrectedTemplate
- type DSL
- func (d DSL) Expressions() []Expression
- func (d DSL) Fill(values map[string]string) (json.RawMessage, error)
- func (d DSL) PlaceholderKinds() map[string]PlaceholderKind
- func (d DSL) PlaceholderMarkers() []string
- func (d DSL) Placeholders() []Placeholder
- func (d DSL) SideEffects() []SideEffect
- func (d DSL) Tasks() []Task
- func (d DSL) Trigger() (TriggerStyle, error)
- type EventRecency
- type EventType
- type ExecutionDetails
- type ExprKind
- type Expression
- type Finding
- type HealthReport
- type HealthVerdict
- type IfCondition
- type LintSubject
- type LintSummary
- type NodeOutput
- type Operation
- type Placeholder
- type PlaceholderKind
- type Result
- type Run
- type RunNode
- type RunState
- type ScopeGap
- type Severity
- type SideEffect
- type SimResult
- type SimStatus
- type SimStep
- type Task
- type TaskComparison
- type Template
- type TraceStatus
- type TriggerStyle
- type Verdict
- type Workflow
Constants ¶
const ( NodeTypeOperation = "jc_operation" NodeTypeConnector = "connector_operation" NodeTypeSwitch = "switch" NodeTypeTrigger = "trigger" // NodeTypeEmail covers sendEmailsToAddresses — the engine reports the // call type as plain "email". sendEmailsToChannel presumably shares it, // but that has not been observed. NodeTypeEmail = "email" // NodeTypeFor is a for.each loop. It appears as ONE node carrying an // iteration count and a summary; individual iterations are not // represented in the trace at all. NodeTypeFor = "for" )
Node types seen in real traces.
const ( // SourceJumpCloud marks a template served by JumpCloud. SourceJumpCloud = "jumpcloud" // SourceJC marks one of jc's own corrected copies. SourceJC = "jc" )
Source values, shared by every surface that reports where a template came from. One vocabulary, defined once.
const ( // CallJCOperation invokes a JumpCloud API operation by operationId. CallJCOperation = "jc_operation" // CallEmailAddresses sends real email to explicit addresses. CallEmailAddresses = "sendEmailsToAddresses" // CallEmailChannel sends real email to notification channels. CallEmailChannel = "sendEmailsToChannel" // CallConnector performs an arbitrary HTTP request against a configured // third-party connector. CallConnector = "connector_operation" )
Call types a task may invoke. Three of the four have side effects that reach outside JumpCloud, which is why they are named here rather than treated as opaque strings.
const ( KindCommand = "command" KindUserGroup = "user-group" KindDeviceGroup = "device-group" KindPolicy = "policy" KindAppleMDM = "apple-mdm" KindWorkflow = "workflow" KindFreeText = "free-text" )
Placeholder kinds. A kind names WHAT a marker wants, not how to find it: this package deliberately does not import internal/resolve, so each surface maps a kind onto its own resolver (the CLI and MCP to a ResourceConfig, the TUI to a registry entry it can open as a picker).
const ( TriggerEvents = "jc_events" TriggerExternal = "external" TriggerScheduler = "scheduler" )
Trigger types, as reported by the API on reads. Derived server-side from the DSL; never sent on create.
const ( StatusActive = "active" StatusInactive = "inactive" )
Statuses accepted on create and update.
const CorrectedIDPrefix = "jc:"
CorrectedIDPrefix marks a template as jc's rather than JumpCloud's. The prefix matters: a corrected copy shares its NAME with the original, so without it the two could not be told apart when resolving.
const Endpoint = "/workflows"
Endpoint is the workflow definitions collection.
const LastRanKey = "last_ran"
LastRanKey is the field name, matching what the documentation promised before the field was removed for not existing.
const RanPredicateDoc = "CRITICAL when reading a trace: is_executed, success and message are NOT evidence " +
"that a step did its work. A step a branch routed around reports is_executed=true, success=true and " +
"\"Task completed.\" — byte-identical to one that ran — and differs ONLY in that node_output is null. " +
"The single trustworthy predicate is node_output != null: a step with node_output null made no call, " +
"whatever the other fields say, and a step WITH node_output ran even if success is false (that is a " +
"failed call, not a skipped one). Verified against ground truth: a task skipped this way would have " +
"created a user group, and afterwards the group did not exist."
const RunsEndpoint = "/workflows/runs"
RunsEndpoint lists every workflow run in the organization. Runs outlive the workflow they came from, so this is not scoped under a workflow.
const TemplatesEndpoint = "/workflows/templates"
TemplatesEndpoint is the server-served template catalog.
const TraceSkipPrefix = "Skipping"
TraceSkipPrefix is how the engine reports a guard that excluded a task. A branch skip carries no such marker, which is why State does not rely on it alone.
const TriggerGrace = 60 * time.Second
TriggerGrace is how long after an event a workflow is given to run before its silence is called a fault.
Directory Insights and the workflow engine lag INDEPENDENTLY, and either can be ahead. A previous fix covered DI being behind — a run with no indexed event. This covers the engine being behind: an indexed event with no run yet.
Trigger latency is not characteristic. Two observations of the same event type, same DSL shape, same tenant:
2026-08-28 ~0.5s from event to run start 2026-08-31 ~19s
A 40x spread with no apparent cause, so any inference from "no run yet" has to be sized for the slow case — and 19s is only the slowest OBSERVED, not a known bound. 60s covers it with margin.
This costs nothing for the verdict's real use case: a workflow broken for days has events far older than any grace window.
const TruncatedNodeDoc = "TRUNCATED NODES: when is_output_truncated is true, node_output is not a trimmed " +
"version of the normal shape — it is a DIFFERENT object, {_preview, _truncated, pageCount, totalItems}, " +
"with no body, status, method or url. So node_output is present while status is absent. This is why the " +
"predicate is node_output != null and not anything involving status: keying on status would read a " +
"truncated step as skipped when it ran. Truncation applies to a step's extract output, not to raw response " +
"bodies — one run truncated a 7-item extracted list while leaving a substantially larger raw device body intact."
RanPredicateDoc is the one canonical statement of how to tell whether a trace step ran. It is reused verbatim wherever that rule is described, so two phrasings cannot drift apart — a wrong-but-plausible rule about exactly these fields cost two build cycles once already. TruncatedNodeDoc describes the one node shape where the predicate's two halves come apart. Reused wherever the trace is described, alongside RanPredicateDoc.
Variables ¶
ControlTargets are the reserved `then` targets that are not task names.
var KnownCalls = map[string]bool{ CallJCOperation: true, CallEmailAddresses: true, CallEmailChannel: true, CallConnector: true, }
KnownCalls is every call type the DSL defines.
var ListDefaultFields = []string{"id", "name", "status", "trigger_type", "last_ran"}
ListDefaultFields is the default field subset shown for workflows. ListDefaultFields trims the list view. The API returns the full DSL on every row, which dominates the payload and is not a list-view concern.
last_ran is back, but COMPUTED rather than passed through: the API sends no last-run timestamp, so jc derives it from the runs list on every read. See lastran.go for why that override was worth making.
var RunDefaultFields = []string{"id", "name", "workflowId", "status", "startedAt", "completedAt"}
RunDefaultFields is the default field subset shown for runs.
var ScheduleFrequencies = map[string]bool{ "once": true, "hourly": true, "daily": true, "weekly": true, "monthly": true, }
ScheduleFrequencies are the time-based trigger frequencies. The DSL takes a structured schedule; there are no cron strings.
var SideEffectCalls = map[string]string{ CallEmailAddresses: "sends email to explicit addresses", CallEmailChannel: "sends email to notification channels", CallConnector: "calls an external connector endpoint", }
SideEffectCalls are the call types that reach outside JumpCloud: they mail people or call external endpoints. Creating a workflow containing one is gated behind an explicit opt-in.
var TemplateDefaultFields = []string{"id", "name", "category", "description"}
TemplateDefaultFields is the default field subset shown for templates.
Functions ¶
func AnnotateAllLastRan ¶
func AnnotateAllLastRan(rows []json.RawMessage, lastRan map[string]string) []json.RawMessage
AnnotateAllLastRan applies AnnotateLastRan across a list.
func AnnotateLastRan ¶
func AnnotateLastRan(row json.RawMessage, lastRan map[string]string) json.RawMessage
AnnotateLastRan injects last_ran into a workflow object, and is a no-op when the workflow has never run — an absent field says "never" more honestly than an empty string, and matches what the documentation described.
func ComparePathParams ¶
ComparePathParams reports how a task's pathParams object differs from the placeholders the operation's path actually requires.
Shared by validate and simulate on purpose. A live run wrote pathParams {"userid": ...} against /api/v2/users/{user_id}/memberof and BOTH accepted it — simulate even printed the correct path beside the wrong name without remarking on it — so the two agreeing is the point, not an incidental tidiness.
ok is false when pathParams is present but not an object.
func CorrectedTemplateRow ¶
func CorrectedTemplateRow(ct CorrectedTemplate) map[string]any
CorrectedTemplateRow summarises one of jc's corrected copies.
func CreateBody ¶
CreateBody builds the POST /workflows body. trigger_type is deliberately absent: the API derives it from the DSL and rejects nothing, but sending it would imply the caller controls it.
func EffectiveSince ¶
EffectiveSince returns the point from which a workflow can fairly be judged: the later of the requested window start and the workflow's own creation.
Without this clamp the check accuses every new workflow. A workflow created an hour ago cannot have responded to an event from five days ago, but the raw comparison sees "47 events, 0 runs" and calls it broken. That single false positive would be enough to make the whole report untrustworthy, because the newest workflows are exactly the ones an operator is checking.
An unparseable or absent created_at falls back to the requested window: a missing timestamp should not silently narrow the comparison to nothing.
func EventFields ¶
EventFields returns the payload fields a jc_events trigger of this type is known to expose, sorted. Unknown event types still get the common envelope, since it was present on every payload observed.
func EventTypeCount ¶
func EventTypeCount() int
EventTypeCount reports how many event types the catalog holds.
func EventTypes ¶
EventTypes returns the catalog, optionally filtered by service and by a substring matched against the name or its description.
func IsCorrectedID ¶
IsCorrectedID reports whether an identifier addresses the corrected catalog.
func JumpTargets ¶
JumpTargets returns every task named by a `then`, at the top level, whether from a task or from a switch case.
func JumpsAway ¶
JumpsAway reports whether a task always transfers control elsewhere, so the task after it is never reached by fall-through.
func KnownEventField ¶
KnownEventField reports whether a top-level input field is known for an event type.
func LastRanByWorkflow ¶
LastRanByWorkflow returns the most recent run start per workflow id.
Runs outlive their workflow, so this may name workflows that no longer exist; callers join on the ids they hold rather than iterating this.
func LintWorkflow ¶
func LintWorkflow(w Workflow) (LintSubject, DSL, bool)
LintWorkflow validates one workflow. Scope checking needs a role lookup, so it stays with the caller; ApplyRole folds the result back in.
func NewestEventTime ¶
func NewestEventTime(events []json.RawMessage) (time.Time, error)
NewestEventTime returns the newest timestamp across matching events.
Callers use this to decide whether a workflow that has never run SHOULD have run. Silently skipping an event that will not decode makes the newest event look older than it is, or absent entirely — and this subsystem has already shipped that bug twice, once returning the oldest event as the newest and once letting missing recency read as never-fired. On error the caller must record recency as UNKNOWN rather than substitute a zero time, which the verdict logic already handles as its own case.
func NormalizeMarker ¶
NormalizeMarker returns the full REPLACE_WITH_* form of a marker name, so --set COMMAND_ID and --set REPLACE_WITH_COMMAND_ID mean the same thing.
func ObservedEventTypes ¶
func ObservedEventTypes(items []json.RawMessage) (map[string]int, error)
ObservedEventTypes builds the emitted-type histogram the catalog audit diffs against.
This one matters most. AuditCatalog reports GAPS — types the tenant emitted that the catalog does not list — so a skipped record shrinks the observed set and the audit reports fewer gaps. The whole point of the tool is catching a catalog that omits things; a decode failure would make the omission detector report no omissions.
An empty key stays a legitimate skip: that is a bucket with no type, not a record jc could not read.
func OperationCount ¶
func OperationCount() int
OperationCount reports how many operations the index holds.
func OperationIDs ¶
func OperationIDs() []string
OperationIDs returns every known operationId, sorted.
func ParseList ¶
func ParseList(raw json.RawMessage) ([]json.RawMessage, error)
ParseList unwraps the {totalCount, results:[…]} envelope used by /workflows and /workflows/runs.
func ResolveID ¶
func ResolveID(rows []json.RawMessage, identifier string) (string, error)
ResolveID turns a workflow name or ID into an ID.
A record that will not decode is an error, not a skip. Skipping one turns "I could not read this workflow" into "workflow not found", and the caller goes looking for something that is sitting in the list.
Ambiguity was already handled correctly here and is preserved: names are not unique, so several matches report every ID rather than picking one.
func RunsWithin ¶
RunsWithin counts runs of a workflow that started within the window.
func ScaffoldDSL ¶
func ScaffoldDSL() json.RawMessage
ScaffoldDSL returns a minimal workflow to author from when starting without a template.
It is deliberately not an empty document. The DSL has no published schema, so a blank start is where people get it wrong; a scaffold that already validates shows the required shape — exactly one trigger, a non-empty `do`, a jc_operation carrying operationId and the matching version — and can be created as-is, then edited.
The trigger is external because that is the one style a person can start by hand (jc workflows trigger), and the single step is a read-only list, so an unedited scaffold cannot change anything.
func ServedTemplateRow ¶
ServedTemplateRow summarises a JumpCloud template for a list view, without its DSL — a full catalog is ~40KB of nested documents. Where jc ships a corrected copy, the row names it, because this list is where a caller decides what to copy.
func SortComparison ¶
func SortComparison(tasks []TaskComparison)
SortComparison puts divergences first, agreement last.
func SortHealth ¶
func SortHealth(reports []HealthReport)
SortHealth orders reports so the actionable ones come first.
func SuggestEventType ¶
SuggestEventType returns the closest catalog entries to an unrecognised type. The realistic failure is a typo rather than an invention — user_suspend for user_suspended — so edit distance is the right measure, and naming the near miss is what makes the warning actionable.
func SuggestOperation ¶
SuggestOperation returns the closest known operationIds to an unknown one, so a typo produces a usable message instead of a bare rejection.
Two different failures need two different scores. A camelCase typo is a near-miss and edit distance finds it. A legacy snake_case id is not a typo at all — it is a different naming scheme for the same operation, so its words are matched against candidates instead ("systemusers_list" shares "systemusers" with "getApiSystemusers", which edit distance would never rank highly).
func TemplateEndpoint ¶
TemplateEndpoint is a single template by ID.
func TriggerBody ¶
TriggerBody wraps the caller's input as the {data} envelope /runs expects.
func TriggerEndpoint ¶
TriggerEndpoint starts a manual run. It is only meaningful for workflows whose trigger source is "external"; the API accepts the call for others but nothing happens.
func UnreachableTasks ¶
UnreachableTasks returns the names of top-level tasks that no branch targets and that follow a task which jumps away — tasks the engine silently never runs.
func UpdateBody ¶
UpdateBody builds the PUT /workflows/{id} body. V2 PUTs in this API are full-replace, so callers must read the current workflow and pass a complete object rather than only what changed.
func WorkflowEndpoint ¶
WorkflowEndpoint is a single workflow by ID.
Types ¶
type CatalogAudit ¶
type CatalogAudit struct {
// Window describes the period audited, for the report to be meaningful.
Window string `json:"window"`
// Emitted is how many distinct types the tenant produced.
Emitted int `json:"emitted_types"`
// Known is the catalog size at the time of the audit.
Known int `json:"catalog_size"`
// Gaps are emitted types absent from the catalog, worst first by volume.
Gaps []CatalogGap `json:"gaps"`
// Covered is how many emitted types the catalog already knew.
Covered int `json:"covered"`
// Note states what the result does and does not prove.
Note string `json:"note"`
}
CatalogAudit is the comparison of a live tenant against the catalog.
func AuditCatalog ¶
func AuditCatalog(observed map[string]int, window string) CatalogAudit
AuditCatalog diffs observed event types against the catalog.
observed maps event type to occurrence count, as `insights distinct` returns it. A quiet tenant emits few types, so an empty gap list is weak evidence of a complete catalog and the note says so.
type CatalogGap ¶
type CatalogGap struct {
EventType string `json:"event_type"`
// Count is how many were seen in the audited window.
Count int `json:"count"`
// Suggestions are near-miss catalog entries. A gap with a close neighbour
// is more likely a documentation omission than a new event family — and
// on the trigger side, more likely to be someone's typo.
Suggestions []string `json:"closest_known,omitempty"`
}
CatalogGap is one event type a tenant emits that the catalog does not know.
type Comparison ¶
type Comparison struct {
RunID string `json:"run_id"`
Tasks []TaskComparison `json:"tasks"`
Agree int `json:"agree"`
Diverge int `json:"diverge"`
// Unresolved is counted apart from Diverge. The plan declared it could
// not evaluate these, so holding them against it inflates the
// disagreement and trains the reader to ignore the number.
Unresolved int `json:"unresolved"`
// CannotCompare counts steps whose trace shape cannot establish whether
// they ran. Unlike Unresolved this is NOT a clean bill of health: it
// means the comparison has a hole, and it is reported as one.
CannotCompare int `json:"cannot_compare"`
// RunHalted records that the run stopped early, which explains any
// not-in-run verdicts after the failing step rather than leaving them
// looking like planner bugs.
RunHalted bool `json:"run_halted"`
HaltedAt string `json:"halted_at,omitempty"`
Caveat string `json:"caveat"`
Interpreted string `json:"how_to_read,omitempty"`
}
Comparison is a whole plan measured against a whole run.
func CompareRun ¶
func CompareRun(sim SimResult, run Run) Comparison
CompareRun measures a dry run against a real one.
Task names are the join key. A name in one and not the other is reported rather than quietly dropped, because a systematic naming mismatch — nested tasks, for instance — would otherwise look like perfect agreement on an empty set.
type CorrectedTemplate ¶
type CorrectedTemplate struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
Category string `json:"category,omitempty"`
// Corrects names the JumpCloud template this replaces.
Corrects string `json:"corrects"`
CorrectsID string `json:"corrects_id,omitempty"`
// Changes says what was altered and why, in one sentence.
Changes string `json:"changes"`
DSL json.RawMessage `json:"dsl"`
}
CorrectedTemplate is one repaired template, carrying what it corrects and what changed, so the difference is auditable rather than asserted.
func CorrectedTemplates ¶
func CorrectedTemplates() []CorrectedTemplate
CorrectedTemplates returns the repaired catalog.
func CorrectionFor ¶
func CorrectionFor(templateName string) (CorrectedTemplate, bool)
CorrectionFor returns the corrected replacement for a JumpCloud template name, so a defect report can point straight at the fix.
func FindCorrected ¶
func FindCorrected(identifier string) (CorrectedTemplate, bool)
FindCorrected resolves a corrected template by ID or name. The "jc:" prefix is optional, so both "jc:wipe-device-and-reset-asset-status" and the original template's name work.
func (CorrectedTemplate) Describe ¶
func (t CorrectedTemplate) Describe() string
Describe renders one line naming what a corrected template replaces.
type DSL ¶
type DSL struct {
Input map[string]any `json:"input,omitempty"`
Schedule map[string]any `json:"schedule"`
Do []map[string]any `json:"do"`
}
DSL is a workflow definition document.
func ParseDSL ¶
func ParseDSL(raw json.RawMessage) (DSL, error)
ParseDSL decodes a DSL document, rejecting unknown top-level keys so a misplaced field is reported rather than silently ignored by the server.
func (DSL) Expressions ¶
func (d DSL) Expressions() []Expression
Expressions collects every Expr source in the document with its position and the result type that position requires.
func (DSL) Fill ¶
Fill substitutes marker values throughout the document.
Substitution is textual because markers appear anywhere a string can — task parameters, schedule conditions, email bodies, connector paths — and a typed walk would have to know every one of those positions.
It is all-or-nothing: an unknown key, or a marker left unfilled, is an error and nothing is returned. A half-filled workflow is worse than none, because it would fail at run time rather than here.
func (DSL) PlaceholderKinds ¶
func (d DSL) PlaceholderKinds() map[string]PlaceholderKind
PlaceholderKinds returns every distinct marker in the document with what it expects, in sorted order so output and prompts are stable.
func (DSL) PlaceholderMarkers ¶
PlaceholderMarkers returns the distinct markers, sorted.
func (DSL) Placeholders ¶
func (d DSL) Placeholders() []Placeholder
Placeholders walks the whole document, since markers appear in task parameters, schedule conditions, and email bodies alike.
func (DSL) SideEffects ¶
func (d DSL) SideEffects() []SideEffect
SideEffects lists every step that sends email or calls an external connector, with its concrete targets.
func (DSL) Tasks ¶
Tasks flattens the `do` list into tasks in document order, descending one level into for-loop bodies. Nested loops are not supported by the engine, so depth never exceeds 1 in a valid document; a deeper nesting is still reported here so Validate can name it.
func (DSL) Trigger ¶
func (d DSL) Trigger() (TriggerStyle, error)
Trigger reads the trigger style out of the schedule block. It reports an error only for a schedule that names no recognisable style at all; deeper checks belong to Validate.
type EventRecency ¶
type EventRecency struct {
// Known is false when the lookup could not be performed. A verdict must
// never be inferred from an absence it could not measure.
Known bool
// WithinGrace is how many matching events fell inside the window.
WithinGrace int
// Newest is the newest matching event, set only when one was inside the
// window. Outside it, the API cannot tell us which was newest.
Newest time.Time
}
EventRecency answers the only question the grace window needs: was there a matching event too recently for silence to mean anything?
It is deliberately NOT "the newest event's timestamp". Directory Insights ignores the sort parameter — verified by issuing the same query with "-timestamp", "timestamp" and no sort at all, and receiving byte-identical ascending results all three times. So there is no way to ask the API for the newest event, and taking the first row of a limited query returns the OLDEST, which is what made the first version of this guard inert: fed the oldest event, "is it within 60s?" is almost always false for any workflow with history, so never-fired fired immediately — exactly what the window existed to prevent.
Asking instead for events inside the grace window sidesteps the ordering problem entirely: if that query returns anything, an event is recent; if it returns nothing, every matching event is older than the window and silence is meaningful. The set is small enough to scan for a real newest timestamp.
type EventType ¶
type EventType struct {
// Describe is JumpCloud's own one-line description.
Describe string `json:"d"`
// Service is the Directory Insights service it belongs to, matching
// api.ValidInsightsServices. Empty where the docs do not group it.
Service string `json:"s,omitempty"`
}
EventType is one documented Directory Insights event.
func LookupEventType ¶
LookupEventType returns the catalog entry for an event type.
type ExecutionDetails ¶
type ExecutionDetails struct {
Nodes []RunNode `json:"nodes,omitempty"`
}
ExecutionDetails is the per-step trace a completed run carries. Neither the OpenAPI spec nor the DSL guide mentions it, but it is the only place the outcome of an individual step is visible — including the HTTP status and URL each jc_operation actually called. It is what makes a failed run diagnosable.
type Expression ¶
type Expression struct {
// Source is the expression text, unwrapped from ${ }.
Source string
// Path is where it sits, for error messages.
Path string
// Kind constrains what the expression must evaluate to.
Kind ExprKind
// Interpolated marks an expression embedded in a larger string, which
// may legitimately be any type.
Interpolated bool
}
Expression is one Expr source found in the document.
type Finding ¶
type Finding struct {
Severity Severity `json:"severity"`
Path string `json:"path"`
Message string `json:"message"`
// Hint is the concrete fix, when there is one.
Hint string `json:"hint,omitempty"`
}
Finding is one validation result.
type HealthReport ¶
type HealthReport struct {
WorkflowID string `json:"workflow_id"`
Name string `json:"name"`
Status string `json:"status"`
Trigger string `json:"trigger_type"`
EventType string `json:"event_type,omitempty"`
Events int `json:"events_in_window"`
Runs int `json:"runs_in_window"`
Verdict HealthVerdict `json:"verdict"`
Detail string `json:"detail"`
// Conditioned notes that the trigger filters events, so a run count
// below the event count is expected rather than suspicious.
Conditioned bool `json:"trigger_has_condition,omitempty"`
// UnknownEventType flags a type absent from the catalog, which makes a
// never-fired verdict far more likely to be a typo.
UnknownEventType bool `json:"unknown_event_type,omitempty"`
// NewestEvent is the newest matching event INSIDE the grace window, when
// there was one. Outside the window it is empty, because Directory
// Insights offers no way to ask which event was newest — see EventRecency.
NewestEvent string `json:"newest_event,omitempty"`
// GraceSeconds is the window a workflow is given to respond to an event
// before its silence counts against it.
//
// Reported on EVERY row the guard applies to, whether or not it changed
// the verdict, so a field-set assertion does not pass or fail depending on
// which code path ran. A row shape that varies by path is the same defect
// as a list whose records carry different keys.
GraceSeconds int `json:"grace_window_seconds,omitempty"`
// RecentEvents is how many matching events fell inside the grace window.
RecentEvents int `json:"recent_events_in_grace_window"`
// WindowStart is where the comparison actually began. It is the later of
// the requested window and the workflow's creation time — see
// EffectiveSince for why that clamp is not optional.
WindowStart string `json:"window_start,omitempty"`
}
HealthReport is one workflow's assessment.
func AssessHealth ¶
func AssessHealth(w Workflow, events, runs int, windowStart time.Time, recency EventRecency) HealthReport
AssessHealth builds the verdict for one workflow from its counts.
events is how many times the trigger's event type occurred in the window; runs is how many times this workflow ran in the same window. Both counts must be taken over the SAME window, and that window must start no earlier than EffectiveSince — otherwise a workflow younger than the window reads as never-fired.
type HealthVerdict ¶
type HealthVerdict string
HealthVerdict classifies one workflow.
const ( // HealthFiring means the event occurred and the workflow ran. HealthFiring HealthVerdict = "firing" // HealthNeverFired means the event occurred and the workflow never ran. // This is the failure the product cannot surface. HealthNeverFired HealthVerdict = "never-fired" // HealthUnverifiable means the event did not occur in the window, so // nothing can be concluded. HealthUnverifiable HealthVerdict = "unverifiable" // HealthNotApplicable covers workflows with no jc_events trigger, and // inactive ones, which are not expected to run. HealthNotApplicable HealthVerdict = "n/a" )
type IfCondition ¶
IfCondition is a task guard as the engine evaluated it.
type LintSubject ¶
type LintSubject struct {
// Kind is "workflow" or "template" — WHAT the subject is.
Kind string `json:"kind"`
// Source is "jumpcloud" or "jc" — WHO wrote it. It uses the same
// vocabulary as workflows_templates_list deliberately: encoding one
// distinction two ways (there: source, here: a "(jc corrected)" suffix on
// kind) made a caller consuming both tools learn two vocabularies for the
// same fact. Presentation may still render it prettily; the DATA says it
// once.
Source string `json:"source,omitempty"`
ID string `json:"id"`
Name string `json:"name"`
// Status and Role are set for workflows; a template has neither.
Status string `json:"status,omitempty"`
// ExecutionRoleID and Role are BOTH emitted, using the same field names
// workflows_get and workflows_list use for the same facts.
//
// lint previously reported only `execution_role` as a NAME while get and
// list reported only `execution_role_id` as an ID — a different field name
// AND a different representation for one fact, so correlating a linted
// workflow to its role needed a separate lookup. Same class as the
// source/kind divergence fixed for templates; it was invisible until the
// tenant had a workflow to compare.
//
// The id is the durable half: ids are stable, names are not, so it is the
// join key between the two tools.
//
// The reverse — a resolved role NAME on workflows_get/list — is
// deliberately NOT added. Those return the API object, and composing a
// field into a passthrough is the same mistake as normalising `admin`
// would have been: it trades a visible gap for an invisible jc-only
// value. A lint subject is jc's own object and may carry both.
ExecutionRoleID string `json:"execution_role_id,omitempty"`
Role string `json:"execution_role,omitempty"`
// Skipped explains why nothing could be checked, when that happened —
// a DSL that will not parse cannot be validated, and reporting that as
// "clean" would be worse than saying nothing.
Skipped string `json:"skipped,omitempty"`
// CorrectedBy names jc's repaired copy, when this subject has findings
// and a correction exists. Reporting a defect without naming the fix
// leaves the operator exactly where they started.
CorrectedBy string `json:"corrected_by,omitempty"`
// LastRan is the most recent run start, absent when the workflow has never
// run. Emitted here as well as on workflows_get/list so the two objects
// answer "when did this last run" the same way.
LastRan string `json:"last_ran,omitempty"`
// TriggerType is lifted to the top level to sit where workflows_get and
// workflows_list put it. It was reachable only as result.trigger_type,
// so the same name lived at two depths and any top-level field-set diff
// flagged it.
TriggerType string `json:"trigger_type,omitempty"`
// Corrects is set on jc's own corrected copies, naming what they replace.
Corrects string `json:"corrects,omitempty"`
Result Result `json:"result"`
}
LintSubject is one thing that was linted.
func LintCorrected ¶
func LintCorrected() []LintSubject
LintCorrected validates jc's own corrected copies.
They are linted in the SAME sweep that reports the defects they correct, so the output proves the corrections rather than merely asserting them — and so a corrected copy that ever drifted would be caught by the tool it exists to answer.
func LintTemplate ¶
func LintTemplate(id, name string, dsl json.RawMessage) LintSubject
LintTemplate validates one template from the served catalog.
Placeholders are NOT counted against it: a template is supposed to have them, and counting them reported 10 of 12 as failing while burying the real defects. Where jc ships a corrected copy of a template that has findings, the subject names it — reporting a defect without naming the fix leaves the reader where they started, and this sweep is where they were choosing what to copy.
func (LintSubject) Errors ¶
func (s LintSubject) Errors() int
Errors and Warnings count this subject's findings by severity.
func (LintSubject) Warnings ¶
func (s LintSubject) Warnings() int
type LintSummary ¶
type LintSummary struct {
Subjects []LintSubject `json:"subjects"`
// Totals over every subject.
Checked int `json:"checked"`
Clean int `json:"clean"`
Errors int `json:"with_errors"`
Warnings int `json:"with_warnings"`
Skipped int `json:"skipped"`
// CheckedBySource breaks the total down, because a bare "16 checked" over
// a 12-template catalog reads as though the catalog grew. Four of those
// are jc's corrected duplicates of four of the twelve.
CheckedBySource map[string]int `json:"checked_by_source,omitempty"`
}
LintSummary is the whole sweep.
func Summarize ¶
func Summarize(subjects []LintSubject) LintSummary
Summarize computes the totals and orders subjects worst-first, so the output's first line is the one worth acting on.
type NodeOutput ¶
type NodeOutput struct {
Method string `json:"method,omitempty"`
// Status is an HTTP status for a jc_operation and a word for an email
// node, so it cannot be typed as an int — see TraceStatus.
Status TraceStatus `json:"status,omitempty"`
URL string `json:"url,omitempty"`
Body any `json:"body,omitempty"`
// NotificationType appears on email nodes.
NotificationType string `json:"notification_type,omitempty"`
}
NodeOutput is what a step produced. Its shape depends on the node type: a jc_operation reports method/url/status/body, while an email node reports notification_type and a STRING status ("success").
type Operation ¶
type Operation struct {
Method string `json:"m"`
Path string `json:"p"`
Summary string `json:"s"`
// Scopes are the API scopes that permit this operation, from the spec's
// x-scopes extension. Holding ANY one of them is sufficient.
//
// Treat this as a lower bound, not the whole truth: the live API rejected
// postApiRuncommand under a role lacking these and named a fourth scope
// ("systems") that the spec does not list. So a role holding one of these
// definitely works, while a role holding none of them may still work.
// That asymmetry is why the scope check warns rather than blocks.
Scopes []string `json:"sc,omitempty"`
}
Operation is one JumpCloud API operation a jc_operation step can call.
func LookupOperation ¶
LookupOperation returns the operation for an operationId.
func (Operation) APIVersion ¶
APIVersion returns the JumpCloud API version the operation lives under. jc_operation steps carry a `version` field alongside operationId, and across all 33 steps in the 12 shipped templates its value matches this exactly.
func (Operation) PathParams ¶
PathParams returns the placeholder names an operation's path requires, in the order they appear. 602 of the 894 catalogued operations take at least one, and the names are not uniform — id, user_id, group_id, UUID, provider_id — which is exactly why supplying the wrong one is easy.
type Placeholder ¶
Placeholders returns every unfilled REPLACE_WITH_* marker in the document, each with the JSON path where it sits, in document order.
type PlaceholderKind ¶
type PlaceholderKind struct {
// Kind is one of the Kind* constants.
Kind string `json:"kind"`
// Describe is a one-phrase explanation for help text and prompts.
Describe string `json:"describe"`
// Resolvable reports whether a name can be looked up for this kind. Free
// text is not resolvable and is taken literally.
Resolvable bool `json:"resolvable"`
}
PlaceholderKind describes what a REPLACE_WITH_* marker expects.
func ClassifyPlaceholder ¶
func ClassifyPlaceholder(marker string) PlaceholderKind
ClassifyPlaceholder reports what a marker expects. It accepts either the full marker or the bare name, so a caller can pass what a user typed.
type Result ¶
type Result struct {
Findings []Finding `json:"findings"`
TriggerType string `json:"trigger_type,omitempty"`
SideEffects []SideEffect `json:"side_effects,omitempty"`
}
Result is the outcome of validating one DSL document.
func ValidateRaw ¶
func ValidateRaw(raw json.RawMessage) Result
Validate checks a DSL document against the rules JumpCloud's Workflows DSL guide documents, plus the operationId index.
It is deliberately local, but not because the API is permissive -- that was the original premise and probing it proved otherwise. POST /workflows rejects an unknown operationId, a missing required path parameter, an Expr expression that will not compile (with line and column), and a workflow whose execution role lacks a needed scope. Being local buys three things instead: an answer before the round trip and without creating anything on the tenant, a "did you mean" the API does not offer, and the checks the API genuinely skips -- event types are accepted unvalidated, so a typo there yields a trigger that silently never fires.
func ValidateWithRole ¶
ValidateWithRole runs Validate and adds a scope finding per step the role does not obviously permit. roleName is used only in the message.
func WithoutPlaceholderFindings ¶
WithoutPlaceholderFindings drops the findings that exist only because REPLACE_WITH_* markers are still in place.
A template is SUPPOSED to have placeholders, so reporting them as errors makes every template look broken and buries the findings that matter — the template's own defects, which anyone copying it inherits. Linting the catalog raw reports 10 of 12 as failing when the real number of defective ones is far smaller.
This is only correct for templates. On a real workflow an unfilled marker is a genuine error: it means someone shipped a template without finishing it.
type Run ¶
type Run struct {
ID string `json:"id"`
WorkflowID string `json:"workflowId"`
Name string `json:"name,omitempty"`
Status string `json:"status"`
StartedAt string `json:"startedAt,omitempty"`
CompletedAt string `json:"completedAt,omitempty"`
Error string `json:"error,omitempty"`
WorkflowDeletedAt string `json:"workflowDeletedAt,omitempty"`
Input map[string]any `json:"input,omitempty"`
ExecutionDetails ExecutionDetails `json:"executionDetails,omitempty"`
}
Run is one execution of a workflow. WorkflowDeletedAt is set when the workflow it came from has since been deleted; the run itself survives.
func ParseRuns ¶
func ParseRuns(raw json.RawMessage) ([]Run, error)
ParseRuns decodes the runs list into typed runs.
func (Run) Done ¶
Done reports whether the run has reached a terminal state, so a caller polling after a manual trigger knows when to stop.
func (Run) FailedNode ¶
FailedNode returns the first step that ran and did not succeed, which is where a failed run went wrong.
type RunNode ¶
type RunNode struct {
Name string `json:"name"`
Type string `json:"type"`
Success bool `json:"success"`
IsExecuted bool `json:"is_executed"`
Message string `json:"message,omitempty"`
TriggerType string `json:"trigger_type,omitempty"`
Truncated bool `json:"is_output_truncated,omitempty"`
NodeInput any `json:"node_input,omitempty"`
NodeOutput *NodeOutput `json:"node_output,omitempty"`
// IfCondition is present on a node whose task-level `if` was evaluated,
// carrying the expression and its result. It is a stronger skip signal
// than the message, being structured rather than English prose.
IfCondition *IfCondition `json:"if_condition,omitempty"`
// IterationCount is how many times a `for` node's body ran. It is the
// only signal that distinguishes a loop that completed from one that was
// never entered, because a `for` node carries NO node_output on success —
// see RunNode.State.
IterationCount *int `json:"iteration_count,omitempty"`
}
RunNode is one executed step. The first node is always the synthetic "__trigger" node carrying the run's input.
func (RunNode) Ran ¶
Ran reports whether this step made its call — REGARDLESS of the outcome.
A failed step ran. "The workflow never touched this" and "the workflow touched this and got a 404" are opposite facts for anyone auditing a run, and collapsing them is the same conflation as reading is_executed, one axis over: success is the OUTCOME, never the evidence of execution.
func (RunNode) State ¶
State classifies what this node did, and why.
For a call node the rule is node_output: a step that reached the API always has one, and a step that did not never does. Everything else is either not a call (trigger, switch) or a shape this package has not observed, and is reported as unknown rather than assumed.
type RunState ¶
type RunState string
RunState is what a trace node actually did.
The trace's own fields cannot answer this. A step a branch routed around reports is_executed=true, success=true and "Task completed." — identical in every field to one that ran, except that node_output is null.
EVIDENCE. This predicate is derived from a small number of real runs against org 5ec71e8e96bfda0611fc6c5b on 2026-08-28. It is recorded here in full so the next person can falsify it in one read rather than re-deriving it — this repo got the rule wrong twice, and both times the finding travelled as a conclusion with its evidence left behind.
run 0c5c7e6e-3b9f-4807-80a0-0c77ff63b7f4 — the decisive one. A switch
jumped past an untargeted jc_operation that would have CREATED A USER
GROUP; afterwards the group did not exist, while the jump target's did.
Ground truth from outside the trace, because the trace was in question.
__trigger type=trigger node_output=null "Workflow invoked."
router type=switch node_output=null "Switch evaluated."
orphanStep type=jc_operation node_output=null "Task completed." <- did NOT run
jumpTarget type=jc_operation node_output=201 "Task completed." <- ran
run 49770a2e-1cdc-44e5-80f2-5afcd10ed6d6 — guard skips report
"Skipping — if condition did not match."; references to a skipped task
evaluate false without erroring.
run c5d40e74-00b3-4269-a26c-ec2c6a4e4cef — a create returned 201, and a
task guarded on `status == 200` was skipped while `>= 200 && < 300` ran.
run 71db73cc-0221-4fef-8eaa-24f4dc1e788f — email. The engine reports the
call type as "email", not "sendEmailsToAddresses". A send carries
node_output {"notification_type":"workflows_common","status":"success"}
— so the envelope rule holds for email too — and a guarded-off send
carries a null node_output plus if_condition {expression, result:false}.
Note the STRING status: typing it as an int made the trace view fail
outright on any run containing an email step.
SCOPE, stated honestly. Observed: jc_operation, switch, trigger, and email (sendEmailsToAddresses). NOT observed in any state: connector_operation, and sendEmailsToChannel — which presumably shares the "email" node type, though that is an assumption, not an observation. Unobserved types return RunStateUnknown; see the note at the fallthrough, which is not merely "nobody has looked yet".
State table as observed:
state is_executed success node_output message ran true true populated "Task completed." skipped, branch not taken true true null "Task completed." skipped, guard false true true null "Skipping — …" skipped, prior task failed false true null "Not executed — …" failed true false populated descriptive
const ( // RunStateRan means the step did its work. RunStateRan RunState = "ran" // RunStateSkipped means the step was visited but did nothing. RunStateSkipped RunState = "skipped" // RunStateFailed means the step ran and failed, which halts the run. RunStateFailed RunState = "failed" // RunStateUnknown is for node types whose trace shape has not been // observed. Guessing here would repeat the mistake this type exists to // prevent. RunStateUnknown RunState = "unknown" )
type ScopeGap ¶
type ScopeGap struct {
// Task is the step's name.
Task string `json:"task"`
// OperationID is what it calls.
OperationID string `json:"operation_id"`
// Describe renders the operation as METHOD /path.
Describe string `json:"describe"`
// Needs are the scopes that would permit it; any one suffices.
Needs []string `json:"needs"`
}
ScopeGap is one step whose operation no held scope permits.
func CheckScopes ¶
CheckScopes reports the steps a role's scopes do not obviously permit.
The execution role is the only thing between an unattended workflow and the API — validation otherwise checks that an operation EXISTS, not that the workflow may call it, so deleteApiSystemusersById passes silently. Comparing the DSL's operations against a named role's scopes moves that from a run-time surprise to an author-time finding.
A gap is advisory, not disqualifying. The spec's x-scopes is a lower bound: the live API accepted a scope for postApiRuncommand that the spec omits, so a role holding none of the declared scopes may still be permitted. Reporting a gap as an error would block workflows that actually work.
type SideEffect ¶
type SideEffect struct {
// Task is the task's name.
Task string
// Call is the call type.
Call string
// What describes the effect in one phrase.
What string
// Targets are the concrete recipients or endpoints, so a reviewer sees
// who gets mailed and what gets called rather than only that it happens.
Targets []string
}
SideEffect is one step that reaches outside JumpCloud.
type SimResult ¶
type SimResult struct {
Steps []SimStep `json:"steps"`
// Caveat is carried in the payload deliberately: a caller reading only
// the result must still see what this cannot tell them.
Caveat string `json:"caveat"`
}
SimResult is a dry run.
func Simulate ¶
Simulate plans what a DSL would do for a given trigger input.
It never performs a request. Reads are reported as would-call with their resolved parameters so the caller can decide whether to run them; writes, emails and connector calls are reported as stubbed.
func SimulateRaw ¶
SimulateRaw is Simulate over a raw DSL document.
type SimStatus ¶
type SimStatus string
SimStatus is what happened to one step in a dry run.
const ( // SimWouldCall is a read that the caller may execute for real. SimWouldCall SimStatus = "would-call" // SimStubbed is a write, email or connector call: never executed. SimStubbed SimStatus = "stubbed" // SimSkipped is a step a guard or branch excluded. SimSkipped SimStatus = "skipped" // SimSwitched is a switch node, which evaluates its cases and routes. It // is a form of running, not of being skipped. SimSwitched SimStatus = "switched" // SimUnresolved is a step whose parameters could not be resolved, // usually because they reference a prior step's response body that a dry // run does not have. SimUnresolved SimStatus = "unresolved" )
type SimStep ¶
type SimStep struct {
Task string `json:"task"`
Status SimStatus `json:"status"`
// Call is the DSL call type.
Call string `json:"call,omitempty"`
// Operation renders the JumpCloud operation as METHOD /path.
Operation string `json:"operation,omitempty"`
// Method is the HTTP method, which is what decides read versus write.
Method string `json:"method,omitempty"`
// Params are the resolved path, query and body parameters.
Params map[string]any `json:"params,omitempty"`
// Why explains a skip, a stub, or a failure to resolve.
Why string `json:"why,omitempty"`
}
SimStep is one planned step.
type Task ¶
type Task struct {
// Name is the task's key, which is how other tasks reference it in
// `then` targets and ${ actions.<name> } expressions.
Name string
// Path is the JSON path to the task, for error messages.
Path string
// Body is the task object.
Body map[string]any
// Depth is 0 for top-level tasks and 1 inside a for-loop body.
Depth int
// Parent is the enclosing loop task's name, empty at the top level.
Parent string
}
Task is one entry of a `do` list, flattened out of its single-key wrapper.
func (Task) Describe ¶
Describe renders the task as one line: a jc_operation resolved to the real endpoint it calls, and the other call types named for what they do. Shared so the CLI's `explain` and the TUI's review cannot describe a step differently.
func (Task) OperationID ¶
OperationID returns the jc_operation operationId, if this is one.
type TaskComparison ¶
type TaskComparison struct {
Task string `json:"task"`
Verdict Verdict `json:"verdict"`
// Planned is the simulate status, empty when the plan never saw it.
Planned SimStatus `json:"planned,omitempty"`
// Ran is what the trace shows: whether the step made its call, whatever
// the outcome.
Ran bool `json:"ran"`
// Failed records that the call ran and failed. It is reported alongside
// the verdict rather than folded into it: the plan predicting a call that
// then 404s got the execution right, and calling that a divergence would
// blame the planner for the tenant's state.
Failed bool `json:"failed,omitempty"`
// Status is what the step really reported: an HTTP status for an API
// call, or a word like "success" for an email send.
Status string `json:"status,omitempty"`
// Detail explains the verdict in a sentence.
Detail string `json:"detail,omitempty"`
}
TaskComparison is one task, as planned and as run.
type Template ¶
type Template struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
Category string `json:"category,omitempty"`
DSL json.RawMessage `json:"dsl"`
}
Template is one entry in the server-served catalog.
func ParseTemplates ¶
func ParseTemplates(raw json.RawMessage) ([]Template, error)
ParseTemplates unwraps the {templates:[…]} envelope. The catalog uses a different envelope from every other list in this area.
type TraceStatus ¶
type TraceStatus struct {
// Code is the HTTP status when the engine reported a number, else 0.
Code int
// Text is the word the engine reported, else empty.
Text string
}
TraceStatus is a step's status, which the engine reports as a NUMBER for an API call and as a STRING for an email send.
Typing this as an int made `jc workflows runs get --trace` fail outright on any run containing an email step — the trace view, which is the only place a failed run's cause is visible, was unusable for exactly the workflows that send notifications. Observed as {"notification_type":"workflows_common", "status":"success"}.
func (TraceStatus) MarshalJSON ¶
func (s TraceStatus) MarshalJSON() ([]byte, error)
MarshalJSON round-trips whichever form was received.
func (TraceStatus) OK ¶
func (s TraceStatus) OK() bool
OK reports whether the status indicates success, in either form.
func (TraceStatus) String ¶
func (s TraceStatus) String() string
String renders the status for a human.
func (*TraceStatus) UnmarshalJSON ¶
func (s *TraceStatus) UnmarshalJSON(b []byte) error
UnmarshalJSON accepts either form rather than failing on the unexpected one.
type TriggerStyle ¶
type TriggerStyle struct {
// Source is "jc_events" or "external" for event and manual triggers, and
// empty for a time-based schedule.
Source string
// Frequency is set for a time-based schedule.
Frequency string
// Condition is the trigger's gating expression, when present.
Condition string
// EventType is the Directory Insights event a jc_events trigger listens
// for.
EventType string
}
TriggerStyle describes which of the three mutually exclusive trigger styles a DSL uses.
func (TriggerStyle) TriggerType ¶
func (t TriggerStyle) TriggerType() string
TriggerType maps the style onto the trigger_type the API reports back.
type Verdict ¶
type Verdict string
Verdict classifies one task's agreement between plan and run.
const ( // VerdictAgree means the plan and the run did the same thing. VerdictAgree Verdict = "agree" // VerdictRanButPlannedSkip means the workflow did something the plan said // it would not. This is the direction that matters: the plan understated // what the workflow touches. VerdictRanButPlannedSkip Verdict = "ran-but-planned-skip" // VerdictSkippedButPlannedRun means the plan overstated. VerdictSkippedButPlannedRun Verdict = "skipped-but-planned-run" // VerdictNotInRun means the plan named a task the run never reached, // which a halt earlier in the run explains. VerdictNotInRun Verdict = "not-in-run" // VerdictNotInPlan means the run has a task the plan never mentioned. VerdictNotInPlan Verdict = "not-in-plan" // VerdictUnresolved means the plan could not resolve the step's // parameters, so there is nothing to compare. VerdictUnresolved Verdict = "unresolved-in-plan" // VerdictCannotCompare means the TRACE cannot say whether the step ran, // because its node type has no established shape. This is ranked with the // divergences, not with agreement: treating it as "no disagreement" would // make the tool quietest exactly where its evidence is weakest, which is // the failure mode that produced the bug this comparison exists to catch. VerdictCannotCompare Verdict = "cannot-compare" )
type Workflow ¶
type Workflow struct {
ID string `json:"id,omitempty"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
DSL json.RawMessage `json:"dsl"`
Status string `json:"status,omitempty"`
TriggerType string `json:"trigger_type,omitempty"`
ExecutionRoleID string `json:"execution_role_id,omitempty"`
CreatedBy string `json:"created_by,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
UpdatedAt string `json:"updated_at,omitempty"`
}
Workflow is a saved workflow definition.
func ParseWorkflow ¶
func ParseWorkflow(raw json.RawMessage) (Workflow, error)
ParseWorkflow decodes a single workflow.