Skip to content

API: Introduced recording conditions that record only once the checked action happened - #10

Merged
whereareiam merged 2 commits into
devfrom
feature/recording-conditions
Nov 14, 2026
Merged

whereareiam merged 2 commits into
devfrom
feature/recording-conditions

Conversation

@whereareiam

Copy link
Copy Markdown
Owner

Some conditions depend on what happened before: a cooldown, a daily limit, something that may happen once. Such a condition must not count a use when it's only checked. Otherwise a cooldown is used up by a message that a later line refused, or that was never sent. This adds a shape for that: the host decides when the action happened.

public final class CooldownCondition implements ConditionType.Recording<Player, CooldownCondition.Settings> {
    public Outcome holds(Player player, Settings settings, Line line) { … }   // waiting?
    public void record(Player player, Settings settings, Line line) { … }      // start the clock
}

if (!(place.check(situation) instanceof Verdict.Passed passed)) return deny(...);
send(message);
passed.record();

What's in it

  • ConditionType.Recording<T, S>: a fourth shape, about one part, that answers at once, so every place takes it. holds and record both get the condition's Line.
  • model.Line: the condition's config path, such as chats.global.requires[1].cooldown, so two lines of one type keep their records apart.
  • Verdict.Passed(recordings):
    • It carries Verdict.Recordables (path, condition, action) for the recording conditions that decided the check.
    • passed.record() runs each once and in order. One that throws doesn't stop the others; the first failure is rethrown, with the later ones suppressed.
    • new Verdict.Passed() still exists and records nothing.
  • Which conditions record: only those that decided the check.
    • In an any, only the branch that was taken.
    • Never one inside a not, which held only by failing.
    • Nothing at all when a later line refuses, because there is no Passed then.
    • Both Place and DeferredPlace carry recordings.
  • Docs: "Recording what happened" in Condition types, and recording a passed verdict under Verdicts in Hosting.

API compatibility: Verdict.Passed gains a record component. Code that deconstructs it with the record pattern Verdict.Passed() has to write Verdict.Passed passed or Verdict.Passed(var recordings).

First user: Socialismus's cooldown condition, whose timers live in a replicated store (whereareiam/Socialismus#273).

Checks

  • ./gradlew build passes locally, Javadoc included.
  • New tests in DefaultConditionsTest:
    • holds until recorded, keyed by line;
    • nothing recorded when a later line refuses, or inside a not;
    • only the taken branch of an any records;
    • recording at a place that waits.

🤖 Generated with Claude Code

whereareiam and others added 2 commits November 14, 2026 11:54
ConditionType.Recording is a type about one part that holds by what it
recorded on its line before, such as a cooldown. Checking records nothing:
a Passed verdict carries the recordings of the conditions that decided it,
and the host calls passed.record() once the action the check allowed
happened. Only deciding conditions record: the taken branch of an any,
never one inside a not, and nothing when a later line refuses. Line names
the condition's config path, so two lines of one type keep apart.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@whereareiam whereareiam added the feature Something new for users or developers label Nov 14, 2026
@whereareiam
whereareiam merged commit 0b9b4f9 into dev Nov 14, 2026
5 of 6 checks passed
@whereareiam
whereareiam deleted the feature/recording-conditions branch November 14, 2026 11:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Something new for users or developers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant