gatelineAPI reference
interface RunSource {
    displayName?: string;
    fetchIntervalSeconds?: number;
    formerIds?: readonly string[];
    id: string;
    localOnly?: boolean;
    mode?: "decide" | "view" | "dispatch";
    templates: ContractTemplates;
    aheadOfOrigin(ref: RunRef): Promise<null | number>;
    behindOrigin(ref: RunRef): Promise<null | number>;
    branchTip(branch: string): Promise<null | string>;
    engineHealth(): Promise<null | EngineHealth>;
    identity(): Promise<null | Identity>;
    lastTouched(ref: RunRef, paths: string[]): Promise<null | CommitInfo>;
    lastTouchedExcept(
        ref: RunRef,
        excludePaths: string[],
    ): Promise<null | CommitInfo>;
    listArtifacts(ref: RunRef): Promise<string[]>;
    listRuns(): Promise<RunRef[]>;
    originUrl(): Promise<null | string>;
    readArtifact(ref: RunRef, path: string): Promise<null | string>;
    readDiff(ref: RunRef): Promise<string>;
    readState(ref: RunRef): Promise<StateParseResult & { raw: null | string }>;
    runHistory(ref: RunRef): Promise<CommitInfo[]>;
    stageRun(scaffold: RunScaffold, who: Identity): Promise<StageOutcome>;
    stateHistory(ref: RunRef): Promise<StateCommit[]>;
    syncFromRemote(): Promise<void>;
    viewRefs(): Promise<ViewRefs>;
    watchRefs(
        onChange: () => void,
        options?: { debounceMs?: number; onTouch?: () => void },
    ): Promise<() => void>;
    workingDirectory(): string;
    writeState(
        ref: RunRef,
        mutate: StateDocMutation,
        message: string,
        options?: { expectedTip?: string },
    ): Promise<WriteResult>;
}

Implemented by

Properties

displayName?: string

The short name an interface shows. Presentation only: never in a URL, a cache key or a commit. Optional so a driver or a test double need not say; read it through displayNameOf, which falls back to the id's last segment.

fetchIntervalSeconds?: number

Seconds between fetches from origin, when the operator configured this repository to poll (fetch_interval). Absent means it does not poll.

formerIds?: readonly string[]

Names this repository was reached by before its current id, so a link made under one still resolves (§6.3, §6.4): the config's former_ids:, and the ids a deployment used before #494 — the config name, the directory's basename, and either with a -2 suffix. Absent means none.

id: string

The repository's id (docs/MULTI-REPO.md §6): <host>/<owner>/<name> from its origin, or local/<name> when it has none. What URLs, cache keys and logs carry. Two ids that differ only in case name the same repository; compare them with sameRepositoryId.

localOnly?: boolean

True when this repository is served local-only: nothing is fetched from or pushed to origin.

mode?: "decide" | "view" | "dispatch"

What this deployment may do here (§7.3), as resolved for this process: a config entry's mode, except that a dispatch entry reads as decide where no engine runs (ui, the CLI); a repository given by --repo or the working directory is dispatch under up and decide otherwise. Optional so a driver or a test double need not say, and absent means no restriction — how the engine's own source is built. A view source refuses every write (writeState, stageRun), which is where the rule is enforced so that no caller can forget it.

Contract templates of this repo, for R3 validation.

Methods

  • Commits on the run branch that origin does not yet have — unpushed writes (#149): the lineage Gatehouse renders and the lineage origin consumers see have silently diverged. Absent method or null result means "not knowable" (no origin tracking, remote-kind run) — display nothing, never zero.

    Parameters

    Returns Promise<null | number>

  • Commits origin has that the local run branch does not (#99). Non-zero together with aheadOfOrigin means the branch has genuinely diverged — local-wins observation is then a deliberate choice that must be visible, never silent. Absent method or null means "not knowable".

    Parameters

    Returns Promise<null | number>

  • The commit a branch points at now, or null when it names none. What the remote runner's intents are pinned to (runner-api.ts). Absent means the driver cannot resolve names.

    Parameters

    • branch: string

    Returns Promise<null | string>

  • The heartbeat of an engine running on this machine beside the server (#100), or null when none has ever written one here. Absent means this driver cannot see a local engine, and the caller reports none.

    Returns Promise<null | EngineHealth>

  • Most recent commit touching anything in the run directory except the given run-relative paths — the delta guard (#188): state.yaml alone moving (bookkeeping, a resolution note) is not "something landed".

    Parameters

    • ref: RunRef
    • excludePaths: string[]

    Returns Promise<null | CommitInfo>

  • This source's origin URL as git resolves it (git remote get-url origin, which applies insteadOf rewrites — the same string the id is derived from), for deriving a link out to the git host (#267 — view-model/host-link.ts decides what it means). Null means there is nothing to link to and the caller keeps its local view: no remote configured, or a local-only source, which has no origin by definition (FRONTEND.md §4.1 — degrade to the local view, never to a dead end). Absent method means the same.

    Returns Promise<null | string>

  • Every commit on the run branch touching the run's own directory, newest first — the branch's own order, which is what "after" means when the clocks that stamped the facts disagree (#346, branch-order.ts). One log, no per-commit reads: stateHistory is the expensive walk, this is the cheap index that places its commits alongside the artifact landings.

    Optional, like the origin-divergence counts: a driver with no history to offer omits it, and its callers fall back to timestamps.

    Parameters

    Returns Promise<CommitInfo[]>

  • The only branch-minting path (plan ADR-3, R1): builds a genesis commit from scaffold.files against the default branch's tip and lands it via create-only CAS. Always authored as who — never a bot-pinned source identity — because a staged run must be attributable to the human who staged it, whoever is holding the write path.

    Parameters

    Returns Promise<StageOutcome>

  • Bring what origin has into this repository's view of it, so runs pushed elsewhere show up. Absent means the driver reads origin directly and has nothing to bring in.

    Returns Promise<void>

  • The refs this source's views read, as comparable strings (#461): what a cache validates an entry against, and what decides whether a change is worth announcing. Optional: a driver that cannot say omits it, and its views are refreshed on a timer instead.

    Returns Promise<ViewRefs>

  • Watch where this repository's refs are stored. onTouch fires at once on every write there, onChange once the writes have settled. Neither means a ref moved (an index refresh writes there too); both mean the refs are worth reading again. Resolves to a function that stops watching. Absent means there is nothing local to watch, and the caller relies on its timer.

    Parameters

    • onChange: () => void
    • Optionaloptions: { debounceMs?: number; onTouch?: () => void }

    Returns Promise<() => void>

  • The top directory of this repository's local clone: where a tool that works inside a clone runs (gh, for a draft PR or a review sync; an engine under gateline up). Absent on a source with no local clone, and a caller that needs one says so rather than guessing a path.

    Returns string

  • The single write path (rule R2): apply a mutation to state.yaml and commit it to the run branch, compare-and-swap semantics. expectedTip extends the CAS window back to the caller's read: when given and the branch no longer points there, the write refuses with ref-moved — the machine co-writer's derive-then-write guard (ORCHESTRATOR.md §4.4). Human surfaces omit it: their reads happen inside this call.

    Parameters

    Returns Promise<WriteResult>