Class DerivationContradictions

java.lang.Object
org.ek9lang.compiler.phase9.DerivationContradictions
All Implemented Interfaces:
Function<Collection<IRConstruct>, List<String>>

public final class DerivationContradictions extends Object implements Function<Collection<IRConstruct>, List<String>>
THE per-program FUSE of the CONFINE stamp (N-V V1, review 2026-11-13 F4 (a); option A, acceptance-neutral): the two cross-checks of phase 5's derived RETAINS against the per-value escape record, computed in IR_ANALYSIS's single-threaded tail over the records EscapeFacts has just stamped and kept on the program (CompilableProgram.getDerivationContradictions()) for IR_OPTIMISATION to read - a program with ANY finding gets no CONFINE anywhere (ConfinedSites). The record's LOCAL verdict trusts the derived RETAINS at every call of a user callable; where the derivation MISSES a keep the verdict is unsound, and a wrong stamp is another thread's free against this thread's buffer (NV ยง2.4). The fuse turns such a slip into a leak the ledger counts, costs yield only where the derivation is wrong, and holds for a program no fixture ever exercised - which is what the ratchets over the test corpus cannot do. The escape census (ir/EscapeCensus) calls THIS for E1a and E1b; never a second copy of either.
  • E1a, DERIVED_RETAINS_CONTRADICTED (contradictions(Collection)): a parameter the IR PROVES kept - it reaches this, another parameter, the return, a static, a publish, a thread or a lock through holders the IR can see, never through an unresolved callee, a plumbing helper, an un-annotated extern result or an undeclared user constructor - while the derived RETAINS of the callable say it is kept nowhere and handed back never. Reads the PROVEN routes (reaches), never what a value may reach through a holder's other contents; a capture is the record's own fail-closed reading, not a proof - a closure that never leaves the operation keeps its capture only within the frame, and the closure's OWN routes already flow onto what it captured, so a closure that leaves (returned, stored into this, handed to a thread) proves the keep through the kinds above. ONE plumbing helper is a proven route (N-V V3 follow-up, 2026-11-13, finding (3) of the review): the async plumbing (StartsAndStopsRuntimeThreads.ASYNC_PLUMBING, Ek9Async) hands what it is given to the pipeline's workers - exactly the declared THREAD keep of TCP.accept, which the IR cannot see into either and E1a has always counted. A parameter's view captured into a dynamic function the operation hands to Ek9Async is therefore a keep the derivation must declare (it declares nothing: a capture of a parameter's view derives no rule), the fuse trips, and the caller's LOCAL list of stamped values that workers read is stamped no more. Every other plumbing helper (the sort, group, uniq, tail, split and stream-guard helpers) runs on the calling thread and stays an unseen route;
  • E1b, DERIVED_RETURN_CONTRADICTED (returnContradictions(Collection)): an operation whose returning slot's record the IR proves a view of the receiver (it reaches this) while the derived RETAINS of its callable say nothing of the result (return <- receiver-interior absent; unknown exempt; a childless result - an Integer handed back by a delegation - is no view anything can be kept into). The record then reads what is kept into that result at every call site as LOCAL (CE-3).
A constructor is judged by the front end through fateOf, never by derived RETAINS, so it is not compared; a function's _call is the function, its capture constructor takes the captures by rule. Hold one.
  • Constructor Details

    • DerivationContradictions

      public DerivationContradictions()
  • Method Details

    • apply

      public List<String> apply(Collection<IRConstruct> constructs)
      Every finding, E1a's then E1b's, each prefixed with its kind; empty when the derivation and the IR agree.
      Specified by:
      apply in interface Function<Collection<IRConstruct>, List<String>>
    • contradictions

      public List<String> contradictions(Collection<IRConstruct> constructs)
      E1a: the parameters whose IR-proven keep the derived RETAINS of their callable do not declare.
    • returnContradictions

      public List<String> returnContradictions(Collection<IRConstruct> constructs)
      E1b: the operations whose returned class the IR proves to be a view of the receiver while the derived RETAINS of the callable say nothing of the result.
    • overApproximations

      public int overApproximations(Collection<IRConstruct> constructs)
      The count of the conservative direction: parameters the RETAINS say are kept that the IR sees no keep of. Never a finding - only counted, by the census.