Repository navigation
feat(automation): complete the trigger and action vocabulary - #77
Merged
Merged
Conversation
Adds the three remaining triggers and three remaining actions the automation policy engine was specified to carry. Triggers: an unresponsive-instance gauge read of the newest retained monitoring sample, a generic status-plus-duration trigger measured from the evaluator's own timestamped observation, and system disk used-percent as a metric on the existing sustained-metric trigger rather than a fourth union member. Every one of them treats an unmeasured reading as absence of evidence and stays quiet: a null silence, a sample that measured no disk, and a history that no longer covers the present are all non-firing, which is the safe direction for triggers that restart and stop instances. Actions: maintenance-state and restart-suppression write one in-memory, instance-scoped hold with the same lifetime ceiling as the existing cooldown and backoff guards, and explicit-audit records a caller-authored line. Holds are enforced across policies in action execution, not only against the policy that wrote them: a maintenance hold refuses automated restarts and stops, a restart hold refuses only restarts so an instance can still be brought down and left down, and every refusal is audited with its own outcome code instead of being dropped silently. Active holds are exposed read-only through mcsl.automation.get, and the dry run reports them without writing any state. The get result carries the hold list as an init-only property rather than a second constructor parameter: the JSON schema exporter enumerates parameter defaults, and a defaulted ImmutableArray is a default instance that throws there.
The union converters ignored any property they did not recognise, so a misspelled instance_id read as absent — and absent means every instance on the wildcard-capable kinds, quietly widening a single-instance policy into a fleet-wide one. Both converters now reject a property outside the kind's own field set, uniformly across every kind rather than only the new ones, matching the strictness JsonUnmappedMemberHandling.Disallow gives every source-generated DTO. The per-kind field table doubles as the known-discriminator list so the two cannot drift. Explicit null on a scalar is rejected for the same reason a malformed value is: it asserts a value the field cannot hold, and substituting the default silently loses it. Null on instance_id stays meaningful, since that is how the wildcard is written. Instances removed from the catalog left their observations and holds behind. A removed instance's status can never change again, so a surviving status entry satisfied a duration trigger forever; both maps are now pruned against the tick's catalog snapshot. The audit record written by audit.record put the operator's message in Target, which is matched exactly by audit queries — so the records the action exists to surface were the ones a target-filtered query could never return. Target is now the instance id, Permission is the bare action type, and the authored text rides in the detail field the other branches use for their outcome code. The dry run judged a hold from the first target of a firing only. It now asks per target and per action through the same predicate execution uses, so a firing that covers several instances reports exactly the ones whose actions would be refused. Adds the converter negatives, validator negatives and multi-target coverage the review asked for, including a percentage threshold above 100 — a rule that could never fire — and a confirmed-intent restart meeting an active hold.
MCServerLauncher.Common gained public contract surface with the automation vocabulary, so its preview.5 fingerprint stopped describing the tree and the baseline moves rather than being re-cut in place, which the NU1403 rule forbids. Common is the only payload that differs: the Daemon.API and SDK payloads, the packed generator, NuGet.Versioning and every buildTransitive asset are byte-identical to their preview.5 entries, so the version bump itself is shown not to touch a payload. The record carries one caveat. The SDK payload is an almost empty facade, but its deterministic module id is not independent of what it compiles against: an intermediate state of Common during this work moved the SDK hash with no SDK source change, and the final state moved it back. A future Common-only edit that shifts that hash is therefore not by itself a sign of breakage. The scope table moves the three triggers and three actions to delivered. Diagnostics stays deferred as its own issue.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #65 — completes the planned automation vocabulary. The three missing triggers land as
instance.unresponsive,instance.status_duration, and asystem_disk_percentmetric on the existingmetric.sustainedtrigger; three of the four missing actions land asinstance.maintenance,instance.restart_suppression, andaudit.record. The fourth, diagnostics, is split to #75 by decision (2026-08-01) — it is the only planned kind whose content and destination were never defined, so it gets a design pass first per the #64/#65/#66 precedent. The two deliberate deviations from the issue's acceptance-criteria wording are recorded in an issue comment.Design decisions (approved 2026-08-01)
metric.sustainedas a new metric value instead of a dedicated DTO: it is shape-identical to the existing windowed metrics, so it inherits the sustained-evidence rule for free — any gap/null sample in the window means no evidence, and no evidence never fires.instance.unresponsiveis a gauge, not a window: it fires when the latest sample'sSilentSecondsmeets the threshold;null(not measured / not running) is no evidence and stays quiet.instance_id: nullis the wildcard, with multi-target firing like the crash-loop repair.instance.status_duration{instance_id?, status, duration_seconds}: continuously in the configured status for ≥ N seconds, measured from the evaluator's own timestamped observation (first-observation baseline is the documented ceiling). The policy-level cooldown guards refire, same posture asmetric.sustained.{scope: all|restarts, until, reason}backs both new mutation actions:instance.maintenancewritesall,instance.restart_suppressionwritesrestarts. A restart is refused by either scope; a stop only by a full maintenance hold (a restart hold exists precisely to let an instance be brought down and left down); notifications, audit records, confirmation plans, and the hold-writing actions are never refused. Every refusal is audited (automation.suppressed), active holds are readable viamcsl.automation.get, expiry is lazy, and the store lives and dies with the daemon — same ceiling as the rest of the evaluator's runtime state. NoInstanceStatus,InstanceReport, WPF, or persistence changes.audit.record{message, severity}writes a caller-authored audit event through the existing sink; the message is length-capped at validation.Adversarial review
A 4-dimension multi-agent review (contracts/serialization, evaluator semantics, packaging/pin, test adequacy) produced 14 confirmed findings; all are closed in the
fix(automation)commit. The ones worth knowing about:instance_iddeserialized the new wildcard-capable triggers to fleet-wide scope. Both converters now reject any property outside the kind's field set — uniformly across every kind — and the per-kind field table doubles as the discriminator list so the two cannot drift. Explicitnullon a scalar is rejected the same way. (The event-rule converters share the original gap; tracked separately as event-rules: union converters silently drop unknown property names #74.)RefusingHoldpredicate per target and per action, somcsl.automation.testcannot drift from what a tick actually does.audit.recordwrote the operator message into the auditTargetfield, which is exactly matched by target-filtered queries — the records the action exists to surface were the ones such a query could never return. Target is now the instance id; the message rides in the detail field.Packaging
MCServerLauncher.Common's surface changed, so the internal baseline moves2.0.0-preview.5→2.0.0-preview.6per the established pin discipline: fingerprints re-recorded after all source changes, machine-checked byPinnedPayloadHashesMatchTheAcceptanceRecord, spec §12.1 version table advanced per its own amendment protocol. No release, no publication (standing instruction).Verification (independent supervisor run on the final branch)
ProtocolTests 1392/1392 · Daemon.ApiTests 116/116 (pin check included) · ProtocolDocs
--checkgreen · V1 deletion gate green · WPF build 0 warnings ·git diff --checkclean.