Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

FormaSL — Dependency, Invalidation & Recovery Contract (RAC-02)

Status: STABLE Authority: NORMATIVE ARCHITECTURAL DECISION CONTRACT — dependency/invalidation/recovery for reactive activation Ratification: owner dispatch 2026-09-30 — “vamos fechar todos os documentos; nada de micro tarefas” (single-pass closure of the RAC documentation front) Parent: REACTIVE-ACTIVATION-CONTRACT.md (RAC-01) Depends on: REACTIVE-ACTIVATION-CONTRACT.md (laws RAC-L01..L11), ../foundations/SEMANTIC-INVARIANTS.md (INV-TIME-01..03), EFFECT-OBSERVATION-CLAIM.md, EXECUTABLE-SEMANTIC-INTERFACE-CONTRACT.md (§13), P5AR-C-REPRESENTATION-IMPLEMENTATION-CONTRACTS.md (§CHG), SITUATED-RESULT-CONTRACT.md Role: bind the RAC-01 coordinate model to concrete coordinate kinds, define the operational Affected(E, Δ) relation, dependency registration/invalidation mechanics, staleness and coalescing eligibility, and the two declared recovery regimes — together (dependency and recovery are born together, per owner amendment). Closes the RAC documentation front; implementation (RAC-03..08 wiring, scheduler/host) is out of scope here.


1. Position relative to RAC-01

RAC-01 froze the reactive boundary (what reactive activation is and is not). This contract specifies the machinery RAC-01 named but did not define:

RAC-01 §6  three coordinate classes      -> §2  closed coordinate vocabulary
RAC-01 §6  Affected(E, Δ)                -> §4-§5  operational definition
RAC-01 §2  Dependency Index              -> §6  registration & invalidation
RAC-01 §5  RAC-L08 coalescing            -> §7  eligibility + mechanics
RAC-01 §7  recovery coordinates          -> §8  the two recovery regimes
           (named but unspecified)       -> §9  failure-mode obligations

Every law of RAC-01 (RAC-L01..L11) is inherited unchanged. This contract adds no new standing, no new syntax, no public surface, and reopens nothing in the RAC-01 non-openings list (FO-L5-12/CHG-1 and FO-P3-14/CHG-2 remain closed).

2. Coordinate vocabulary (closed set)

Coordinates are the only addresses over which invalidation operates. The vocabulary is closed: only the kinds below may enter the Dependency Index. A coordinate of unknown kind is rejected fail-closed.

C1  Input / basis coordinates
    C1.claim     ClaimLifecycleCoordinate   { claim_ref, standing_class }
                 — emitted by claim lifecycle transitions
                 (assert / adopt / retract / supersede; lifecycle HistoryChain)
    C1.obs       ObservationCoordinate      { observation_record_ref }
                 — emitted by post-bridge observation admission only (OBG-5)
    C1.occ       EstablishedOccurrenceCoordinate { occurrence_id }
                 — emitted by carrier minting (ActionJournal):
                 AdapterReceipt, ExecutionRecord, EffectRecord (with
                 CausalBasisRef), ExecutionRequest/Attempt/Receipt
    C1.src       SourceRevisionCoordinate   { source_ref, revision }
                 — emitted by source publication
    C1.policy    PolicyModelRevisionCoordinate { policy_ref, revision }
                 — emitted by contract/policy/model revision (basis changes)

C2  Result coordinates
    C2.result    ResultCoordinate { application, result_channel,
                                    result_identity }
                 — emitted ONLY by a completed evaluation publishing its
                 exported result through its declared result/data-dependence
                 interface (compose DataDependence.channel); the index MUST
                 NOT synthesize C2 coordinates from anything else (RAC-L11)

C3  Dynamic concrete dependencies
    C3.state     StateKeyCoordinate { key, version, basis, presence }
                 — emitted by application-state commits; mirrors the
                 StateReadSet entry shape (contract §26; versions prevent ABA)
    C3.rev       RevisionCoordinate { contract_revision_ref }

Binding rules:

R2-OB-01  Closed vocabulary. Only declared coordinate kinds enter the
          index; unknown kinds fail closed.
R2-OB-02  Declared emitters only. A coordinate is admissible only from its
          declared emitter class. No coordinate is synthesized from
          internal fixpoint state, intermediate derivations, or unparsed
          payloads (RAC-L11).
R2-OB-03  C2 exists only where declared. A ResultCoordinate is admissible
          only if a DataDependence {producer_step, consumer_step, channel}
          (or equivalent declared result channel) names it.
R2-OB-04  Projection is declared, never inferred. A storage key projects to
          semantic coordinates only through the source's declared projection
          interface. An undeclared key remains C3-only and can never affect
          statically registered C1/C2 dependencies.
R2-OB-05  One change, both vocabularies. A single admitted change may emit
          coordinates in more than one class (e.g. an application-state
          commit emits C3 keys and, if a projection is declared, the
          corresponding C1/C2 coordinates). Emission is per declared
          interface, not per heuristic.

3. Change notification shape

A ChangeNotification carries (RAC-01 §7, now bound):

source identity            which declared emitter class / source instance
basis/revision             the revision the change was admitted under
                           (amendment A2: mandatory whenever the source
                           has an admitted revision — in particular the
                           C2/CompletedResult emission MUST carry the
                           sealed evaluation's basis; policy-only
                           triggers legitimately carry none, since no
                           admitted revision changed)
changed coordinates        Δ ⊆ coordinate vocabulary (§2), possibly empty
recovery coordinates       per the source's declared RecoveryRegime (§8):
                           occurrence identity, source position/cursor,
                           sequence/watermark — only when required
R2-OB-06  Empty Δ is legal. A policy-only trigger (timer, declared
          periodic reevaluation) produces a notification with Δ = ∅.
          It creates no coordinate, no invalidation, and no standing
          (RAC-L07); it can only become an activation candidate through
          a declared policy at the gate.
R2-OB-07  Notification idempotency. When a source provides a monotonic
          position (ordinal/cursor/watermark), applying Δ is idempotent by
          max-position per coordinate WITHIN THAT SOURCE (position
          streams are per-source — amendment A4): a notification older
          than the last applied one for the same coordinate from the
          same source is discarded (out-of-order tolerance). Sources
          without monotonic position rely on coordinate
          equality dedup; they MUST then declare a recovery regime that
          does not depend on ordering (§8).

4. Dependencies(E)

For a sealed evaluation E (or registered application):

Dependencies(E) = StaticSemanticDeps(E) ∪ DynamicConcreteDeps(E)
R2-OB-08  Static extraction. StaticSemanticDeps(E) is extracted at plan
          admission / evaluation sealing from the plan/compose graph:
          consumer steps depend on producer steps through declared channels
          (DataDependence), mapped onto C1/C2 coordinates per the declared
          interfaces. No static dependency is inferred from source text
          order or runtime schedule (compose distinction preserved).
R2-OB-09  Dynamic registration. DynamicConcreteDeps(E) is accumulated from
          E's StateReadSet at evaluation completion: {key, version, basis,
          presence} per entry. Dynamic dependencies register retroactively
          after the run that read them; they never require pre-declaration.
R2-OB-10  Absence is a dependency. A read that validated absence
          (presence = false at version v) registers a dependency on that
          key being absent at ≥ v; any later appearance/change of the key
          invalidates E. Absence is not the absence of a dependency.

5. Affected(E, Δ) — operational definition

Affected(E, Δ)  iff  ∃ d ∈ Dependencies(E), c ∈ Δ : match(d, c)

Match semantics per class:

C3.state   exact key; affected only if changed version > recorded version
           (same-or-older version ⇒ stale notification, discarded per
           R2-OB-07; this is the ABA guard of contract §26); basis recorded
           for audit, not for matching (state keys are basis-scoped by the
           storage plane's scope discipline)
C1.claim   SUBJECT-level on claim_ref: any lifecycle transition on the
           claim (assert / adopt / retract / supersede) affects every
           consumer depending on that claim, whatever standing the
           dependency recorded; standing_class is PAYLOAD of the
           transition, never part of the matching identity
           (amendment A1, audit RAC-IMPL-AUDIT-807e530a)
C1.src     SUBJECT-level on source_ref: a new published revision
           invalidates dependencies recorded at older revisions
           (amendment A1)
C1.policy  SUBJECT-level on policy_ref: a new admitted revision
           invalidates dependencies recorded at older revisions —
           this is what makes R2-OB-12 deliverable (amendment A1)
C1.obs     exact coordinate identity
C3.rev     exact coordinate identity
C2.result  exact (application, result_channel) match; result_identity
           participates for occurrence-of-result sensitivity where declared
subsumption  only through declared projection interfaces (R2-OB-04).
           No prefix, glob, or structural inference. Fail closed.

Amendment A1 (audit RAC-IMPL-AUDIT-807e530a, owner repair dispatch 2026-09-30). The original §5 text (“C1.* exact coordinate identity; standing_class participates for C1.claim”) was internally inconsistent: exact identity cannot deliver the claim-lifecycle parenthetical (a retraction carries a different standing than the recorded dependency) nor R2-OB-12 (a policy delta arrives at a NEW revision than the recorded basis dependency). Matching for C1.claim / C1.src / C1.policy is therefore SUBJECT-level; revision and standing class are transition payload. Verified empirically by probes P1–P3 in the audit and killed by regression tests after repair.

R2-OB-11  Affected is monotone under coordinate set union and is computed
          without executing anything: invalidation is pure operational
          bookkeeping (Phase 1 of RAC-01 §2).
R2-OB-12  Basis staleness is a coordinate. If E's sealed basis was
          superseded by a policy/contract revision, the emitted
          C1.policy coordinate matches E's basis dependency and E becomes
          affected independently of any data change.

6. Registration & invalidation mechanics

R2-OB-13  Index shape. The Dependency Index maps coordinate → set of
          affected identities (EvaluationInstanceId / application
          identity). Static deps register at admission/seal; dynamic deps
          register at completion (R2-OB-09).
R2-OB-14  The index is a cache (RAC-L10). It is reconstructible from:
          (a) durable registration records (which applications exist, which
          recovery regime, which reevaluation policies — §8), (b) static
          re-extraction from admitted plans, (c) dynamic deps recomputed at
          the next evaluation. Recovery MUST NOT depend on index survival.
          Durable truth of change lives only in the substrate feeds:
          storage watch streams (occurrence/delivery/acknowledgement as
          distinct identities), FormaFS change feed with monotonic ordinal
          (FormaFsCursor), and the append-only lifecycle HistoryChain
          (in-place rewrite forbidden, INV-TIME-03/FP-25).
R2-OB-15  Durable registrations. The set of registered applications with
          their declared recovery regimes and reevaluation policies is the
          recovery input and MUST be durable/reconstructible. Losing it
          loses the system's reactive identity; losing the index does not.

7. Coalescing eligibility and mechanics (RAC-L08 operationalized)

The consumption profile is derived, not declared as a public enum:

R2-OB-16  Profile derivation. An application is OCCURRENCE-SENSITIVE iff
          its Dependencies(E) contain at least one C1.occ (or C2.result
          with per-occurrence sensitivity declared). Otherwise it is
          LEVEL-SENSITIVE. The derivation is internal machinery; no public
          surface enumeration is introduced at this stage.
R2-OB-17  Level-sensitive coalescing. Pending notifications coalesce on
          key (application identity, material subject/basis scope);
          execution evaluates against the LATEST current basis/state, never
          against the queued notification snapshot. "Payment 123 changed"
          three times ⇒ one reevaluation.
R2-OB-18  Occurrence-sensitive processing. No coalescing across distinct
          occurrence identities. Each occurrence is processed idempotently:
          duplicate delivery never duplicates the occurrence (watch-stream
          discipline) and per-occurrence effects remain keyed
          (EffectKey {case_key, external_occurrence}; StorageIdempotencyKey
          where durable idempotency is required). "Trade T1, T2, T3" stays
          three processings.

8. Recovery regimes (RAC-L10 operationalized)

RestartSafety requires RecoverableActivationBasis. The regime is declared per application (durable registration, R2-OB-15) and is honored by the source’s recovery coordinates (RAC-01 §7).

R2-OB-19  LEVEL-SENSITIVE recovery = resync. On restart (or lost
          notification): discard index and queues; re-read CURRENT
          basis/state; reconcile (re-evaluate per declared policy or defer
          to the next trigger). Missed notifications are NOT enumerated;
          none of events 5..9 need to be replayed to learn desired=10,
          observed=9.
R2-OB-20  OCCURRENCE-SENSITIVE recovery = durable occurrence recovery.
          Requires per (source, consumer): a durable replayable position
          and an ack/progress watermark. Delivery is at-least-once;
          unacked occurrences are redelivered after restart; per-occurrence
          processing is idempotent (R2-OB-18). Reading "current state" is
          NOT a substitute: lost T2 cannot be reconstructed from state.
R2-OB-21  Ordinal gaps fail closed. In an occurrence feed, a detected gap
          in source positions means a lost wakeup: request resync from the
          source; never silently skip an ordinal.
R2-OB-22  Hybrid is declared, not universal. A source/application may
          declare cursor replay + periodic authoritative resync. A cursor
          alone is never authority over world state; the periodic resync
          bounds the damage of any cursor divergence.
R2-OB-23  Cross-source order is not assumed. Occurrences from different
          sources are concurrent by default (INV-TIME-02); only declared
          dependency (CausalBasisRef) creates order. Within one source,
          processing follows source ordinal order.

9. Failure-mode obligations

R2-OB-24  Restart            → §8 per regime; index rebuilt, not restored.
R2-OB-25  Lost notification  → level: next resync/resnapshot catches up
                               (R2-OB-19); occurrence: gap detection ⇒
                               resync (R2-OB-21); hybrid: periodic resync
                               bounds divergence (R2-OB-22).
R2-OB-26  Duplicate          → level: coalescing (R2-OB-17); occurrence:
                               occurrence-identity idempotency (R2-OB-18).
R2-OB-27  Out-of-order       → max-position idempotency where positions
                               exist (R2-OB-07); buffering-until-contiguous
                               or gap-resync for occurrence feeds; never
                               silent skip.
R2-OB-28  Stale candidate    → the ActivationGate re-validates exact
                               versions/basis at activation time (pull
                               check on the read-set discipline of
                               contract §26) and evaluates against latest;
                               a notification's snapshot is never the
                               evaluation's premise.

10. Non-openings (inherited, restated for closure)

FO-L5-12 (CHG-1) and FO-P3-14 (CHG-2) remain closed and absence-checked. No concrete syntax, no on/trigger/subscribe, no Stream<Result> / IncrementalResult, no universal event store / durable queue / cursor protocol / workflow engine. The profile derivation (R2-OB-16) is internal; no public ActivationMode enum is introduced at this stage. Ordinary composition cycles remain governed by OrdinaryCompositionCycle requires ExplicitIterationOrRecursionContract.

11. Relationship to verified artifacts

All cited precursors were inspected in code, not assumed:

crates/compose/src/compose.rs            DataDependence {producer_step,
                                         consumer_step, channel} — "Exact
                                         declared channel text for this
                                         carrier"; the four-way order
                                         distinction in the module header
crates/application-state/src/read_set.rs StateDependency {key, version,
                                         basis}; StateReadResult {..,
                                         present}; "read set carries
                                         versions to prevent ABA;
                                         dependency validation checks exact
                                         versions and basis" (§26)
crates/application-state/src/projector.rs
                                         StateTransitionOccurrence
                                         {reference, affected_keys};
                                         StateTransitionOrdinal(u64)
crates/storage/src/watch_stream.rs       occurrence / delivery /
                                         acknowledgement distinct;
                                         "duplicate delivery never
                                         duplicates the occurrence";
                                         conflicting payload re-recording
                                         rejected
crates/storage/src/commit.rs             StorageJournalAppend;
                                         StorageIdempotencyKey;
                                         ExpectedCondition::GlobalAtRevision
crates/formafs-core/src/change.rs        FormaFsCursor(u64) — "a monotonic
                                         change ordinal"; FormaFsChange feed
crates/lifecycle/src/history.rs          HistoryChain append-only;
                                         in-place rewrite forbidden
                                         (INV-TIME-03/FP-25);
                                         replay_occurrence takes occurrence
                                         identity as input (FO-L4-07,
                                         replay non-creation)
crates/runtime/src/runtime.rs            EvaluationInstance sealing;
                                         rebind ⇒ NEW instance (P3-O-20)
crates/time (formasl-time)               ClockReading/domain; guards;
                                         TemporalStanding; reading is never
                                         standing (RAC-L07)
crates/mrs-terminal                      EffectKey {case_key,
                                         external_occurrence};
                                         DecodeEvidenceBridge;
                                         ExternalStateReadback

12. What this contract does not specify

The RAC documentation front is closed with RAC-01 + RAC-02. What remains is implementation, not documents, and follows the RAC-01 §11 ordering:

RAC-03  dependency extraction wiring (R2-OB-08/09 into admission/seal paths)
RAC-04  invalidation engine (index, match, R2-OB-11..15)
RAC-05  activation gate + propagation (gate pull-check R2-OB-28; C2 emission)
RAC-06  external ingress binding (adapters / observation / watches →
        ChangeNotification with regime-correct recovery coordinates)
RAC-07  external effect feedback (request/effectuation/observation loop,
        epistemic boundary untouched)
RAC-08  reliability (R2-OB-24..28 protocols, bounded queues, backpressure)
then    scheduler / continuous host design — a design task that only makes
        sense after the above exist; deliberately not written now.

RAC-02 introduces no code obligations of its own; the CHG-1/CHG-2 absence checks continue to hold unchanged.

13. Amendment record

A1 (audit RAC-IMPL-AUDIT-807e530a, owner repair dispatch 2026-09-30)
    §5 matching for C1.claim / C1.src / C1.policy changed from exact
    coordinate identity to SUBJECT-level (claim_ref / source_ref /
    policy_ref); revision and standing class are transition payload.
    Original rule was internally inconsistent: it could not deliver the
    claim-lifecycle parenthetical nor R2-OB-12. Empirically confirmed
    by audit probes P1–P3; regression tests added after repair.

A2 (same dispatch)  §3 basis/revision obligation clarified: mandatory
    whenever the source has an admitted revision (C2/CompletedResult
    MUST carry the sealed evaluation's basis; enforced by the
    ChangeNotification constructor since the repair); policy-only
    triggers carry none.

A3 (same dispatch)  §6 index lifecycle: evaluations must be retired by
    the host (engine.retire_evaluation) — the index is a cache (R2-OB-14)
    and evaluation consumers accumulate otherwise.

A4 (audit RAC-IMPL-AUDIT-ROUND2-4e8b5dc8, campaign
    CAMPAIGN-REACTIVE-INGRESS-v0.1 RI-01, owner dispatch 2026-10-07)
    Two scoping laws from the round-2 findings, both effective at the
    machinery since this campaign's RI-01:

    (a) R2-OB-07 POSITION STREAMS ARE PER-SOURCE. Max-position
        idempotency keys the last applied position by
        (notification.source, coordinate identity), not by identity
        alone: state keys are opaque per-scope bytes (§26), so the same
        key text in two sources is two independent position streams.
        Identity-only tracking silently STALE-DROPPED a fresh delta from
        one source against another source's higher position — the
        under-invalidation direction (audit probe Q1/Q2). Positionless
        dedup is unchanged: coordinate-CONTENT equality is
        source-independent by construction, since content-identical
        coordinates invalidate identically.

    (b) §3 COMPLETION BASIS IS VERIFIED, NEVER TRUSTED. The engine
        records the ActivationOrder basis at begin_evaluation and
        complete_evaluation fails closed (BasisMismatch) when the
        completion basis differs (audit probe Q4). A2's mandatory-basis
        rule bound what the C2 emission must CARRY; A4 binds what the
        engine will ACCEPT.

    INDEX SCOPING NOTE (same findings, disposition = document): the §5
    index matches C3.state dependencies by key only across state
    spaces, so a delta on the same key text from an unrelated scope can
    invalidate a consumer that never read that scope. This is the
    OVER-invalidation direction (safe; a spurious candidate is gated,
    not executed) and is accepted at v0.1. Per-scope matching keys
    would require carrying the source/space identity in the dependency
    coordinate — a successor decision, not a defect.