Skip to content

detect: an absence is raised when its deadline passes, and after a restart - #5

Merged
cpoder merged 1 commit into
masterfrom
absence-close
Sep 24, 2026
Merged

cpoder merged 1 commit into
masterfrom
absence-close

Conversation

@cpoder

@cpoder cpoder commented Sep 24, 2026

Copy link
Copy Markdown
Owner

What was wrong

The alert waited for the next event. A detect unit with an absence (Order as o -> NOT Ack where id == o.id within 4h) raised it only when the next event reached the pattern. On subjects that go quiet after the order, that event never comes, so the alert never did.

A restart lost the pending absences. Take an absence the unit was waiting out when it was killed. The snapshot kept the open sequence, but not what its negated step waited for. After the restart the acknowledgement no longer cancelled it, and the deadline dropped it without an alert.

The fix

The engine is pinned at varpulis 21f3ba4 (varpulis/varpulis#287).

  • An absence completes on the event time of the types feeding the pattern, which moves forward on its own once they go quiet (VEJAS_IDLE_CLOSE_SECS, v0.3.3).
  • A restore rebuilds each run's negated step.

No change to the runtime itself.

Proof on NATS: e2e/detect

  • D8: two orders at 20:00:00; o-2 is acknowledged at 20:00:01, o-1 is not. Nothing else is ever published on either subject.
    • This build: o-1 is raised about the 5 s window plus the 1 s grace later, and only o-1.
    • The v0.3.3 runtime (VEJAS_BIN=...): nothing.
  • D9: order o-3, a snapshot that holds it, then kill -9 with o-3 still open (asserted: it had not been raised before the crash). Then restart, and silence.
    • This build: o-3 is raised once after the restart.
    • v0.3.3: never.
  • The D4 topology check now expects five units.

Run locally: every invariant passes on this build (D1–D9). On v0.3.3, D8 and D9 fail and the rest pass.

Docs

concepts/detects.md: an absence is raised when its deadline passes, and a restart does not lose it.

🤖 Generated with Claude Code

https://claude.ai/code/session_01N3K1TGnWTvwYzt9rKuJXES

…start (varpulis #287)

"An order not acknowledged within 4h" waited for the next event that
reached the pattern: on subjects that went quiet after the order, it was
never raised. And an absence the unit was waiting out when it stopped
lost what its negated step waited for in the snapshot, so after the
restart the deadline dropped it without an alert. Engine pinned at
varpulis 21f3ba4 (#287). e2e/detect D8 (silent subjects) and D9 (kill -9
with the order in the snapshot) fail on v0.3.3 and pass now.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01N3K1TGnWTvwYzt9rKuJXES
@cpoder
cpoder merged commit 4921ac4 into master Sep 24, 2026
3 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.

1 participant