Skip to content

@usine/github/polling

An issue number and update time reported by repository change detection.

  • Schema.Class

new ChangedIssue(…args): ChangedIssue

Parameter Type
…args [props: object, options?: MakeOptions]

ChangedIssue

readonly number: number

readonly updatedAt: Utc


A pull request number and update time reported by repository change detection.

  • Schema.Class

new ChangedPullRequest(…args): ChangedPullRequest

Parameter Type
…args [props: object, options?: MakeOptions]

ChangedPullRequest

readonly number: number

readonly updatedAt: Utc


Finds changed GitHub Items and fetches the snapshots used to select work for Loops.

  • Context.ServiceClass

readonly Service: object

The service’s operations: what yield* GitHubPolling returns.

readonly changes: (repository, cursor) => Effect.Effect<ChangeDetection, GitHubAppError>

Finds issue and PR updates since the saved cursor; persist the returned cursor after processing the detected Items.

Parameter Type
repository RepositoryName
cursor PollCursor

Effect.Effect<ChangeDetection, GitHubAppError>

readonly labels: (repository, entityTag) => Effect.Effect<RepositoryLabelCatalog | RepositoryLabelsNotModified, GitHubAppError>

Reads the repository’s label catalog, or confirms the catalog named by entityTag is unchanged.

Parameter Type
repository RepositoryName
entityTag Option.Option<EntityTag>

Effect.Effect<RepositoryLabelCatalog | RepositoryLabelsNotModified, GitHubAppError>

readonly snapshot: (repository, item) => Effect.Effect<PayloadSnapshot, GitHubAppError>

Fetches an Item’s selection and prompt payload together with its timestamp-independent content hash.

Parameter Type
repository RepositoryName
item ChangedItem

Effect.Effect<PayloadSnapshot, GitHubAppError>

readonly static layer: Layer<GitHubPolling, never, Crypto | HttpClient | GitHubApp>


An issue’s observed payload and the content identity used to decide whether it represents new work.

  • Schema.Class

new IssueSnapshot(…args): IssueSnapshot

Parameter Type
…args [props: object, options?: MakeOptions]

IssueSnapshot

readonly contentHash: string & Brand<"GitHubContentHash">

readonly payload: object

readonly assignees: object

readonly nodes: readonly object[]

readonly totalCount: number

readonly author: { login: string; } | null

readonly body: string

readonly closedAt: string | null

readonly closedByPullRequestsReferences: object

readonly nodes: readonly object[]

readonly totalCount: number

readonly comments: object

readonly nodes: readonly object[]

readonly totalCount: number

readonly createdAt: string

readonly issueType: { name: string; } | null

readonly labels: object

readonly nodes: readonly object[]

readonly totalCount: number

readonly milestone: { title: string; } | null

readonly number: number

readonly state: string

readonly stateReason: string | null

readonly title: string

readonly updatedAt: string

readonly url: string


REST cursor for efficiency only. Losing it is safe because Event dedup is permanent (ADR 0007).

  • Schema.Class

new PollCursor(…args): PollCursor

Parameter Type
…args [props: object, options?: MakeOptions]

PollCursor

readonly entityTag: Option<string & Brand<"GitHubEntityTag">>

readonly watermark: Option<Utc>

readonly static empty: PollCursor


A pull request’s observed payload and the content identity used to decide whether it represents new work.

  • Schema.Class

new PullRequestSnapshot(…args): PullRequestSnapshot

Parameter Type
…args [props: object, options?: MakeOptions]

PullRequestSnapshot

readonly contentHash: string & Brand<"GitHubContentHash">

readonly payload: object

readonly additions: number

readonly author: { login: string; } | null

readonly baseRefName: string

readonly body: string

readonly changedFiles: number

readonly closingIssuesReferences: object

readonly nodes: readonly object[]

readonly totalCount: number

readonly comments: object

readonly nodes: readonly object[]

readonly totalCount: number

readonly createdAt: string

readonly deletions: number

readonly headRefName: string

readonly headRefOid: string

readonly isDraft: boolean

readonly labels: object

readonly nodes: readonly object[]

readonly totalCount: number

readonly mergeable: string

readonly merged: boolean

readonly mergedAt: string | null

readonly mergeStateStatus: string

readonly number: number

readonly reviewDecision: string | null

readonly reviewRequests: object

readonly nodes: readonly object[]

readonly totalCount: number

readonly reviews: object

readonly nodes: readonly object[]

readonly totalCount: number

readonly reviewThreads: object

readonly nodes: readonly object[]

readonly totalCount: number

readonly state: string

readonly statusCheckRollup: { state: string; } | null

readonly title: string

readonly updatedAt: string

readonly url: string


Changed Items, the next cursor, and whether the page cap left more Items to fetch.

  • Schema.Class

new RepositoryChanges(…args): RepositoryChanges

Parameter Type
…args [props: object, options?: MakeOptions]

RepositoryChanges

readonly backlog: boolean

True when the page cap ended the walk early. The rest arrives next cycle.

readonly backoffUntil: Option<Utc>

Request backoff from rate pressure or Retry-After; excludes the normal polling interval.

readonly cursor: PollCursor

readonly items: readonly (ChangedIssue | ChangedPullRequest)[]

readonly nextPollAt: Option<Utc>


One repository label as GitHub defines it. The name routes lanes, and color and description are presentation only.

  • Schema.Class

new RepositoryLabel(…args): RepositoryLabel

Parameter Type
…args [props: object, options?: MakeOptions]

RepositoryLabel

readonly color: string & Brand<"GitHubRepositoryLabelColor">

readonly description: Option<string>

readonly name: string & Brand<"GitHubRepositoryLabelName">


A complete label catalog with the ETag of its canonical REST URL.

  • Schema.Class

new RepositoryLabelCatalog(…args): RepositoryLabelCatalog

Parameter Type
…args [props: object, options?: MakeOptions]

RepositoryLabelCatalog

readonly entityTag: Option<string & Brand<"GitHubEntityTag">>

readonly labels: readonly RepositoryLabel[]


GitHub confirmed the catalog named by its ETag has not changed.

  • Schema.Class

new RepositoryLabelsNotModified(…args): RepositoryLabelsNotModified

Parameter Type
…args [props?: object, options?: MakeOptions]

RepositoryLabelsNotModified


GitHub confirmed that the repository cursor still describes its current state.

  • Schema.Class

new RepositoryNotModified(…args): RepositoryNotModified

Parameter Type
…args [props: object, options?: MakeOptions]

RepositoryNotModified

readonly backoffUntil: Option<Utc>

Request backoff from rate pressure or Retry-After; excludes the normal polling interval.

readonly cursor: PollCursor

readonly nextPollAt: Option<Utc>

ChangeDetection = typeof ChangeDetection.Type

The result of checking repository changes, including the earliest next poll time.


ChangedItem = typeof ChangedItem.Type

An issue or pull request whose payload needs to be fetched after change detection.


ContentHash = typeof ContentHash.Type

Identifies an Item’s payload content for Event deduplication; timestamp-only changes keep the same hash.


EntityTag = typeof EntityTag.Type

GitHub’s opaque HTTP validator for a conditional repository or label-catalog request.


IssuePayload = typeof IssuePayload.Type

The issue payload slice that if: expressions and prompt interpolation range over.


PayloadSnapshot = typeof PayloadSnapshot.Type

The fetched Item state shared by selection, prompt rendering, and Event deduplication.


PullRequestPayload = typeof PullRequestPayload.Type

The pull-request payload slice that if: expressions and prompt interpolation range over.


RepositoryLabelColor = typeof RepositoryLabelColor.Type

GitHub stores label colors as six hex digits without the leading hash.


RepositoryLabelDetection = typeof RepositoryLabelDetection.Type

A complete label catalog or confirmation that the cached catalog is unchanged.


RepositoryLabelName = typeof RepositoryLabelName.Type

A repository label name as returned by GitHub, preserved without case conversion.

const ChangeDetection: Schema.Union<readonly [typeof RepositoryNotModified, typeof RepositoryChanges]>

The result of checking repository changes, including the earliest next poll time.


const ChangedItem: Schema.Union<readonly [typeof ChangedIssue, typeof ChangedPullRequest]>

An issue or pull request whose payload needs to be fetched after change detection.


const ContentHash: Schema.brand<Schema.String, "GitHubContentHash">

Identifies an Item’s payload content for Event deduplication; timestamp-only changes keep the same hash.


const EntityTag: Schema.brand<Schema.NonEmptyString, "GitHubEntityTag">

GitHub’s opaque HTTP validator for a conditional repository or label-catalog request.


const IssuePayload: Schema.Struct<{ assignees: Schema.Struct<{ nodes: Schema.$Array<Schema.Struct<{ login: Schema.NonEmptyString; }>>; totalCount: Schema.Int; }>; author: Schema.NullOr<Schema.Struct<{ login: Schema.NonEmptyString; }>>; body: Schema.String; closedAt: Schema.NullOr<Schema.String>; closedByPullRequestsReferences: Schema.decodeTo<Schema.Codec<{ nodes: readonly object[]; totalCount: number; }, { nodes: readonly object[]; totalCount: number; }, never, never>, Schema.NullOr<Schema.Codec<{ nodes: readonly object[]; totalCount: number; }, { nodes: readonly object[]; totalCount: number; }, never, never>>, never, never>; comments: Schema.Struct<{ nodes: Schema.$Array<Schema.Struct<{ author: Schema.NullOr<Schema.Struct<{ login: Schema.NonEmptyString; }>>; body: Schema.String; createdAt: Schema.String; }>>; totalCount: Schema.Int; }>; createdAt: Schema.String; issueType: Schema.NullOr<Schema.Struct<{ name: Schema.String; }>>; labels: Schema.decodeTo<Schema.Codec<{ nodes: readonly object[]; totalCount: number; }, { nodes: readonly object[]; totalCount: number; }, never, never>, Schema.NullOr<Schema.Codec<{ nodes: readonly object[]; totalCount: number; }, { nodes: readonly object[]; totalCount: number; }, never, never>>, never, never>; milestone: Schema.NullOr<Schema.Struct<{ title: Schema.String; }>>; number: Schema.Int; state: Schema.String; stateReason: Schema.NullOr<Schema.String>; title: Schema.String; updatedAt: Schema.String; url: Schema.NonEmptyString; }>

The issue payload slice that if: expressions and prompt interpolation range over.


const PayloadSnapshot: Schema.Union<readonly [typeof IssueSnapshot, typeof PullRequestSnapshot]>

The fetched Item state shared by selection, prompt rendering, and Event deduplication.


const PullRequestPayload: Schema.Struct<{ additions: Schema.Int; author: Schema.NullOr<Schema.Struct<{ login: Schema.NonEmptyString; }>>; baseRefName: Schema.String; body: Schema.String; changedFiles: Schema.Int; closingIssuesReferences: Schema.decodeTo<Schema.Codec<{ nodes: readonly object[]; totalCount: number; }, { nodes: readonly object[]; totalCount: number; }, never, never>, Schema.NullOr<Schema.Codec<{ nodes: readonly object[]; totalCount: number; }, { nodes: readonly object[]; totalCount: number; }, never, never>>, never, never>; comments: Schema.Struct<{ nodes: Schema.$Array<Schema.Struct<{ author: Schema.NullOr<Schema.Struct<{ login: Schema.NonEmptyString; }>>; body: Schema.String; createdAt: Schema.String; }>>; totalCount: Schema.Int; }>; createdAt: Schema.String; deletions: Schema.Int; headRefName: Schema.String; headRefOid: Schema.NonEmptyString; isDraft: Schema.Boolean; labels: Schema.decodeTo<Schema.Codec<{ nodes: readonly object[]; totalCount: number; }, { nodes: readonly object[]; totalCount: number; }, never, never>, Schema.NullOr<Schema.Codec<{ nodes: readonly object[]; totalCount: number; }, { nodes: readonly object[]; totalCount: number; }, never, never>>, never, never>; mergeable: Schema.withDecodingDefaultKey<Schema.String, never>; merged: Schema.Boolean; mergedAt: Schema.NullOr<Schema.String>; mergeStateStatus: Schema.withDecodingDefaultKey<Schema.String, never>; number: Schema.Int; reviewDecision: Schema.NullOr<Schema.String>; reviewRequests: Schema.decodeTo<Schema.Codec<{ nodes: readonly object[]; totalCount: number; }, { nodes: readonly object[]; totalCount: number; }, never, never>, Schema.NullOr<Schema.Codec<{ nodes: readonly object[]; totalCount: number; }, { nodes: readonly object[]; totalCount: number; }, never, never>>, never, never>; reviews: Schema.decodeTo<Schema.Codec<{ nodes: readonly object[]; totalCount: number; }, { nodes: readonly object[]; totalCount: number; }, never, never>, Schema.NullOr<Schema.Codec<{ nodes: readonly object[]; totalCount: number; }, { nodes: readonly object[]; totalCount: number; }, never, never>>, never, never>; reviewThreads: Schema.Struct<{ nodes: Schema.$Array<Schema.Struct<{ comments: Schema.Struct<{ nodes: Schema.$Array<Schema.Struct<…>>; totalCount: Schema.Int; }>; isOutdated: Schema.Boolean; isResolved: Schema.Boolean; path: Schema.String; }>>; totalCount: Schema.Int; }>; state: Schema.String; statusCheckRollup: Schema.NullOr<Schema.Struct<{ state: Schema.String; }>>; title: Schema.String; updatedAt: Schema.String; url: Schema.NonEmptyString; }>

The pull-request payload slice that if: expressions and prompt interpolation range over.


const RepositoryLabelColor: Schema.brand<Schema.String, "GitHubRepositoryLabelColor">

GitHub stores label colors as six hex digits without the leading hash.


const RepositoryLabelDetection: Schema.Union<readonly [typeof RepositoryLabelCatalog, typeof RepositoryLabelsNotModified]>

A complete label catalog or confirmation that the cached catalog is unchanged.


const RepositoryLabelName: Schema.brand<Schema.NonEmptyString, "GitHubRepositoryLabelName">

A repository label name as returned by GitHub, preserved without case conversion.