Rules
Rules it can’t break.
A learned score ranks the options. A written mask decides which options exist.
before
action = model.predict(incident)
if action == "restart" and peak_hours:
action = model.second_choice(incident) # also allowed? check again…
if action == "rollback" and deploy_age > 60:
action = ... # patch, retrain, hope
with TensorCode · click a rule to switch it off
allowed = {
"restart": not peak_hours, # never at peak
"rollback": minutes_since_deploy < 60, # recent deploys only
"scale": budget_left > 0, # it costs money
"page": True, # a person, always
}
mask = torch.tensor([allowed[a] for a in ACTIONS])
options = CandidateSet(encode(incident),
Latent(actions.tensor, space, mask=mask), ACTIONS)
choice = decide(score(options)).identity # never a masked action
rules.py · trained on 8 postmortems
Incident
Bars: the learned score. Struck through: masked by a rule. Changing a rule changes the choice at once, with no retraining.