Skip to content

#567 Opt-in strict tick-abort policy — cancel the rest of the tick on a fatal system exception - #601

Merged
nockawa merged 1 commit into
mainfrom
feature/567-strict-tick-abort
Jul 30, 2026
Merged

nockawa merged 1 commit into
mainfrom
feature/567-strict-tick-abort

Conversation

@nockawa

@nockawa nockawa commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

Closes #567.

RuntimeOptions.SystemExceptionPolicy = AbortTickAndStop makes the first unhandled system exception cancel the remainder of the tick. Default stays Isolate — today's fault isolation, unchanged.

The objective is cancellation, not durability suppression. The issue asked for WriteTickFence and UoW.Flush() to be skipped so a failed tick would not become a durability boundary. That was rejected: SingleVersion components are written in place and receive their WAL record at the fence, so skipping it leaves the page mutated, dirty and un-logged for the checkpoint thread to persist later — a durable mutation with no log record behind it, which is exactly AP-01's [fatal][silent] failure mode. Skipping the fence would have created an illegal durability boundary rather than avoiding one. Fence and flush now run on every tick, aborted or not, and that is recorded as new rule TP-01a.

What the abort actually does: nothing that hasn't started runs, running systems finish normally, the output phase is suppressed so a failed tick is never published, and the runtime goes terminal.

How cancellation works

Typhon cancels by dispatch-and-drain, never by halting dispatch — a tick terminates when _systemsRemaining reaches zero, so a system that is never dispatched hangs the tick. _systemFailed propagation was already a cancellation protocol with per-system scope; this adds a tick-scoped latch read at the three gates that already read it.

Two design corrections found during implementation, both folded back into the design doc:

  • C1 — the doc put the third gate in FindReadySystem. That reintroduces the very hang it exists to prevent. It must be after the claim succeeds. Verified by negative control: with the gate disabled, AbortTickAndStop_ReadyButUnclaimedRoot_DoesNotRun fails with victimCount == 1.
  • C2 — DrainFailedSystemChunks is used, for systems that have not started. What rule D1 forbids is draining a system that already has.

Deviation from the design

The design called for an OnCriticalOverload-style internal callback bridge for the abort event. Not done, deliberately: that would fire host code on a worker thread mid-tick. OnTickAborted is raised from OnTickEndInternal instead — TickDriver, after the tick drains, so ordering is trivial and "exactly once" falls out for free.

Prerequisite fixes (independent of the feature)

  • Four silent catch { flag; return; } sites fixed — OnShouldRun/OnPrepare on both the single-threaded and multi-worker successor paths. All four swallowed the exception with no log, no capture, no SkipReason.
  • CaptureSystemException no longer lazy-allocates; the ??= raced across concurrent workers and silently dropped every capture but one.
  • RecordSystemFailure now funnels log → capture → maybe-latch, replacing 12 hand-rolled call pairs.

Public surface

SystemExceptionPolicy, TickOutcome / TickOutcomeReason, SkipReason.TickAborted, TyphonRuntime.LastTickOutcome, TyphonRuntime.OnTickAborted, TyphonRuntime.FatalStop().

Performance

Free when off. Six checks, the hottest being one per successor edge; the two chunk-loop gates sit inside a pre-existing if (chunk == 0) branch, so the per-chunk inner loop pays nothing. The latch is a padded, write-once int — shared-clean in every core's L1, no coherence traffic, and _systemIsEngine[] short-circuits so it is never loaded unless an abort fired.

Testing

15 new tests across two fixtures (~2 s). Full suite 4076 passed / 0 failed.

Two ACs are not covered by tests and are flagged as inspection-only in the design doc rather than quietly ticked:

  • output-phase suppression — needs a live subscription server, too heavy/flaky for a unit test;
  • Fence-DAG-throw routing — no fault-injection hook exists on the Fence systems.

Design doc: claude/design/Runtime/08-strict-tick-abort.md (Status: Implemented) in typhon-claude, same branch name.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Gcg4vW8vJ4QjNyj6NQabHs

@nockawa
nockawa merged commit 93bca60 into main Jul 30, 2026
15 checks passed
@nockawa
nockawa deleted the feature/567-strict-tick-abort branch July 30, 2026 12:15
nockawa added a commit that referenced this pull request Jul 31, 2026
… doc/ [no-ut] [no-doc] (#610)

PR #601 added RuntimeOptions.SystemExceptionPolicy but nothing in doc/ moved, leaving four feature-set pages and the runtime overview asserting fault-isolation semantics as unconditional — "one failure doesn't abort the tick", "other DAG branches continue", "it does not abort sibling members".

Each fix qualifies the existing statement as the Isolate default rather than replacing it, then states what AbortTickAndStop does instead. All five also carry the two exemptions none of the filed issues mention: engine tracks never observe the abort flag (D3 — the fence runs no matter what), and abort granularity is the system rather than the chunk (D1), so a system already running drains all of it.

10-runtime.md additionally gains OnTickAborted / LastTickOutcome / FatalStop in the §9 hooks list and SystemExceptionPolicy in the RuntimeOptions knobs table, none of which existed in the docs despite being public API since #601.
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.

[Feature]: opt-in strict tick-abort policy for fatal system exceptions

1 participant