vigiles API reference
    Preparing search index...

    Interface StateFact

    A recorded fact as a hook reads it — the typed replacement for "cat the stamp file and clamp whatever comes back".

    interface StateFact {
        ageSeconds: number;
        at: string;
        recorded: boolean;
        value: string;
        fresherThan(
            within: `${number}s` | `${number}m` | `${number}h` | `${number}d`,
        ): boolean;
        olderThan(
            within: `${number}s` | `${number}m` | `${number}h` | `${number}d`,
        ): boolean;
    }
    Index

    Properties

    ageSeconds: number

    Seconds since the recording — Infinity when never recorded, never null.

    🔴 THE TYPE IS THE SAFETY PROPERTY. With number | null, the test every author writes first (age < 3600) reads a never-recorded fact as FRESH, because null < 3600 is true in JavaScript. A hook that has never run would therefore never run. With Infinity every comparison lands on the side that speaks, and there is no null case to forget.

    at: string

    ISO-8601 instant of the recording; "" when never recorded.

    recorded: boolean

    Has this key ever been recorded? The only way to distinguish "never" from "long ago".

    value: string

    The recorded string; "" when never recorded.

    Methods

    • True iff recorded within within. Never-recorded → false (so the hook speaks).

      Parameters

      • within: `${number}s` | `${number}m` | `${number}h` | `${number}d`

      Returns boolean

    • True iff not recorded within within. Never-recorded → true (so the hook speaks).

      Parameters

      • within: `${number}s` | `${number}m` | `${number}h` | `${number}d`

      Returns boolean