Skip to content

feat(automation): complete the trigger and action vocabulary - #77

Merged
AresConnor merged 3 commits into
masterfrom
feat/automation-vocabulary
Aug 1, 2026
Merged

AresConnor merged 3 commits into
masterfrom
feat/automation-vocabulary

Conversation

@AresConnor

Copy link
Copy Markdown
Contributor

Summary

Closes #65 — completes the planned automation vocabulary. The three missing triggers land as instance.unresponsive, instance.status_duration, and a system_disk_percent metric on the existing metric.sustained trigger; three of the four missing actions land as instance.maintenance, instance.restart_suppression, and audit.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)

  • disk rides metric.sustained as 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.unresponsive is a gauge, not a window: it fires when the latest sample's SilentSeconds meets the threshold; null (not measured / not running) is no evidence and stays quiet. instance_id: null is 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 as metric.sustained.
  • One in-memory instance-scoped suppression store {scope: all|restarts, until, reason} backs both new mutation actions: instance.maintenance writes all, instance.restart_suppression writes restarts. 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 via mcsl.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. No InstanceStatus, 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:

  • The union converters silently dropped unknown property names, so a typo'd instance_id deserialized 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. Explicit null on 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.)
  • A confirmed automation intent executing its deferred restart bypassed the suppression store; execution and the dry run now consult the same RefusingHold predicate per target and per action, so mcsl.automation.test cannot drift from what a tick actually does.
  • Status observations and holds are pruned against each tick's catalog snapshot — a deleted instance no longer satisfies a duration trigger forever or leaves a hold behind for whatever reuses the id.
  • audit.record wrote the operator message into the audit Target field, 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 moves 2.0.0-preview.5 → 2.0.0-preview.6 per the established pin discipline: fingerprints re-recorded after all source changes, machine-checked by PinnedPayloadHashesMatchTheAcceptanceRecord, 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 --check green · V1 deletion gate green · WPF build 0 warnings · git diff --check clean.

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.
@AresConnor
AresConnor merged commit d1df7d3 into master Aug 1, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

automation: complete the planned trigger and action vocabulary

1 participant