Repository navigation
Open
Labels
feature-requestRequest for new features or functionality
Description
Tracked in #568. This proposal stands on its own and doesn't depend on the others tracked there.
Summary
Event-trigger configuration is defined by the host, so only the host can fully validate it. Today the host validates only when a create or update action arrives, and it rejects with a single free-text reason.
This proposal adds a side-effect-free validateAutomation command. It returns the definition as the host would store it, plus field-level problems (errors and warnings), so editors can give inline feedback while the user is still typing.
Scenarios
- Inline errors for host-defined triggers. A trigger filter names a label that doesn't exist, or a branch pattern the host can't parse. The editor highlights the field before the user saves.
- Warnings that need host knowledge. "This event includes activity from bots, so this automation could trigger itself." "This repository receives about 400 events a day."
- Preview. Show the trigger titles and other values the host would fill in, and when the schedule will next fire, before saving.
- Check before approving. Validate a definition that someone else proposed before accepting it.
AHP today
listAutomationTriggerDefinitionsreturns event-trigger discovery data and aconfigSchema, so clients can check structure (types, enums, required properties) locally.- Clients can preview schedules locally with the portable cron rules.
- Anything else is validated only when
automation/createRequestedorautomation/updateRequestedarrives. A rejection carries one free-textActionEnvelope.rejectionReasonand no field information.
Proposal
- Command.
validateAutomationonahp-automations://takes a completedefinitionand, when the user is editing an existing automation, itsautomationURI. - Result.
definition: the definition as the host would store it, after the same normalization it applies on create or update.problems: field-level findings. Each has a JSON Pointerpathinto the definition, amessage, and aseverity(@nonexhaustive:errororwarning). Anerrormeans the host would reject the definition. Awarningmeans the host would accept it.nextOccurrences(optional): the next few times each schedule trigger would fire, as the host evaluates it. Clients can already compute previews with the portable rules; the host's answer is authoritative for its own evaluation, for example its time zone data.
- No side effects. Validation persists nothing, captures no customizations, and creates no runs. Hosts SHOULD run the same checks they run for create and update, so a definition with no errors is accepted unless something changes in between.
- Capability.
automations.validate. Clients use the command only when the host advertises it.
Sketch
Names and shapes are illustrative. The implementation PR settles them.
/** validateAutomation, on ahp-automations:// */
interface ValidateAutomationParams extends BaseParams {
channel: 'ahp-automations://';
definition: AutomationDefinition;
/** The existing automation being edited, if any. */
automation?: URI;
}
interface ValidateAutomationResult {
/** The definition as the host would store it. */
definition: AutomationDefinition;
/** Empty when the host would accept the definition without warnings. */
problems: AutomationProblem[];
/** Next few occurrences per schedule trigger, as ISO 8601 timestamps. */
nextOccurrences?: { triggerId: string; at: string[] }[];
}
interface AutomationProblem {
/** JSON Pointer into the definition, for example "/triggers/1/config/labels". */
path: string;
message: string;
severity: AutomationProblemSeverity;
}
/** @nonexhaustive */
const enum AutomationProblemSeverity {
Error = 'error',
Warning = 'warning',
}
interface AutomationCapabilities {
// ...existing fields
validate?: {};
}Why this shape
- AHP already resolves prospective state on the host.
resolveSessionConfiglets a client send a partial session configuration and get back what the host would do, before anything is created.listAutomationTriggerDefinitionsalready evaluates a prospective session template. Validating a prospective definition is the same pattern. - The authoritative path is unchanged. Create and update actions behave exactly as they do today. Validation is advisory, and the host stays the authority when the action arrives.
- JSON Pointer paths let any client map a problem to a field without understanding host-specific configuration.
Compatibility
- Additive and capability-gated. Clients that don't call the command see no change.
Out of scope
- Changing how create and update rejections are reported.
Open questions
- Should rejected create and update actions also carry structured problems?
rejectionReasonis free text everywhere in the protocol, so that would be a broader change. - Should the command also accept a patch for an existing automation, instead of a complete definition?
- Should hosts be able to signal that validation is expensive, so clients debounce more aggressively?
Related proposals (none required)
- Review-gated changes (Proposal: Review-gated automation definition changes #578): reviewers can validate a proposed definition before approving it.
Metadata
Metadata
Labels
feature-requestRequest for new features or functionality
Activity