---
title: Context validity check
summary: Confirms whether an AppManagerBase instance holds enough valid state to proceed with a retrieve or write operation.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-07-30
library: SAIF.Application
reference_type: package
operation_id: OP-APP-03
trigger: Calling code reads the ValidContext property on an AppManagerBase instance
---

# Context validity check

`ValidContext` is the single, always-current boolean gate that consuming code checks before invoking a manager's `Retrieve()` or `Write()` methods. Unlike the security-role flags, it is fully delegated to the subclass — `AppManagerBase` supplies no default implementation at all.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-APP-03 |
| **Trigger** | Calling code reads the `ValidContext` read-only property |
| **Inputs** | Current manager instance state (subclass-defined) |
| **Outputs** | Boolean context-validity result |
| **Primary components** | `AppManagerBase.ValidContext`, `AppManagerBase.OnValidContext` (MustOverride) |
| **Entry point** | `Application\SAIF.Application\AppManagerBase.vb` |

## Steps

1. **Caller reads `ValidContext`.** Any code holding a reference to an `AppManagerBase`-derived instance can read the public read-only `ValidContext` property at any time; there is no precondition on when it can be called.
2. **Delegate to the subclass hook.** The property getter's entire implementation is `Return OnValidContext()` — it performs no computation of its own and simply forwards to the abstract `OnValidContext()` method.
3. **Subclass evaluates its own readiness.** The concrete application-manager subclass implements `OnValidContext()` to inspect whatever state it considers necessary — for example, whether a required identifier has been populated, whether `Retrieve()` has already succeeded, or whether `MarkContextSet()` has been called.*
   - Because this logic lives entirely in the consuming application, this library's documentation cannot enumerate the specific validity criteria; they are out of scope for `SAIF.Application` itself.
4. **Caller acts on the result.** Consuming code typically gates a subsequent `Retrieve()` or `Write()` call on `ValidContext` returning `True`, but `AppManagerBase` does not enforce this gating — it is a convention the caller must follow.
   - If the caller proceeds despite `ValidContext` returning `False`: behavior is entirely subclass-defined and unguarded at the `AppManagerBase` level.*

## Process flow

The following diagram visualizes the delegation from the base-class property to the subclass hook.

```mermaid
flowchart TD
	Start([Caller reads ValidContext]) --> Delegate[AppManagerBase.ValidContext<br>calls OnValidContext]
	Delegate --> SubclassCheck[Subclass OnValidContext<br>inspects its own state]
	SubclassCheck --> Result{Result}
	Result -->|True| Proceed([Caller proceeds with<br>Retrieve or Write])
	Result -->|False| Halt([Caller should not proceed;<br>not enforced by AppManagerBase])
```

## Failure and edge-case behavior

- `AppManagerBase` provides zero default validity logic; a subclass that fails to implement `OnValidContext()` meaningfully (for example, always returning `True`) defeats the check entirely with no warning from the base class.*
- Nothing ties `ValidContext` to the `ContextSet` flag tracked via `MarkContextSet()` / `MarkContextNotSet()` — see [Application context initialization](application-context-initialization.md) — so the two signals can disagree if the subclass does not keep them consistent.*
- Because the property has no side effects, repeated reads are safe and always reflect current subclass state at the time of the call — there is no caching of the result.

> **Note:** Statements marked with `*` were inferred from code structure, naming conventions, or
> contextual evidence where direct confirmation was not available in source artifacts.

## Related documentation

- [Operations and processes](../operations-processes.md)
- [Business rules](../business-rules.md)

## Sources

- `Application\SAIF.Application\AppManagerBase.vb`
