Table of Contents

Class IntegrityScanner

Namespace
Typhon.Engine
Assembly
Typhon.Engine.dll

Answers three questions about a database without changing a byte of it: is it sound, what exactly is wrong, and what would a repair cost.

public static class IntegrityScanner
Inheritance
IntegrityScanner
Inherited Members

Examples

using var source = new OfflineBundlePageSource("game.typhon");
var report = IntegrityScanner.Scan(source, IntegrityOptions.Deep);
Console.WriteLine(IntegrityReportText.Render(report));
return report.ExitCode;

Remarks

The scan is provably read-only — it reaches pages through an IPageSource, which is contractually side-effect free — so it is always safe to run: on a production database, on a corrupt one, on one that will not open. That last case is the point. The engine already repairs on the crash path, but it does so silently, only at open, only when it feels like it, and reports into log lines. A database can therefore be silently repaired with the operator learning nothing, or refuse to open with the operator learning nothing useful.

The scanner is also a test oracle. Because it needs no model of what the database should contain, it can be asserted after any crash-injection cell — including ones whose correct final state the harness cannot compute.

Methods

Scan(IPageSource, IntegrityOptions)

Scans a page source and produces a report.

public static IntegrityReport Scan(IPageSource source, IntegrityOptions options = null)

Parameters

source IPageSource

The source to read through. Not disposed by this method.

options IntegrityOptions

Depth, filters and budgets. Defaults to Standard.

Returns

IntegrityReport

Exceptions

ArgumentNullException

source is null.

VerifySpine(IPageSource)

The always-on open-time tier: page-0 pair selection, the bootstrap stream, and that every segment pointer resolves to a real segment root. Bounded by the number of segments rather than the size of the database — kilobytes read, sub-millisecond — which is what makes it affordable on every open.

public static IntegrityReport VerifySpine(IPageSource source)

Parameters

source IPageSource

The source to verify.

Returns

IntegrityReport

Remarks

The clean-shutdown flag records that the last process closed properly. It does not record that the bytes are still correct. Damage that happens while a database is closed — bit rot, a truncated copy, a restore from the wrong place, a file-level backup tool writing through — is invisible to a clean open, which then proceeds to serve it. This tier is the cheapest thing that catches the whole structurally-broken class, which is exactly the damage where opening anyway does the most harm.