Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions docs/GITHUB_RELEASE_WEBHOOK_PLAN.md
Original file line number Diff line number Diff line change
Expand Up @@ -347,10 +347,14 @@ independent. Reconciliation should:
6. persist a cursor or last-success marker;
7. log counts and classifications without response bodies.

Public unauthenticated GitHub API access is sufficient at the current
repository count. If its limit becomes operationally inadequate, use a
least-privileged GitHub App installation token; do not introduce a broad
personal token.
Public unauthenticated GitHub API access is the default. It can fail under
upstream limits or other access conditions; HTTP 403 alone does not identify
the cause. The optional [catalog-only GitHub App mode](../worker/README.md#github-release-ingestion-operators)
uses one selected repository per metadata-only token, fresh public repository
and organization checks, current expiry fences and no retry. It cannot reuse
engineering write credentials. Its public-release compatibility and deployed
CPU cost require qualification before separate host activation. Do not
introduce a broad personal token or widen contents permissions after a refusal.

## Operational visibility

Expand Down
2 changes: 1 addition & 1 deletion src/data/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ export const components: readonly PegmaComponent[] = [
'Being a hosted SaaS — hosts run it, own its data, and choose its providers',
'AI processing before the host documents what may leave its boundary',
],
now: 'The 0.1.0 package set is published on npm from the signed v0.1.0 release (2026-07-29); host deployments are the next step.',
now: 'The 0.2.12 package set is published on npm and composed by the Cloudflare reference host; optional AI routes remain host-controlled.',
plan: 'docs/PROJECT_PLAN.md',
},
{
Expand Down
61 changes: 61 additions & 0 deletions worker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,67 @@ remaining slots return without database or GitHub I/O. The 60-slot capacity is
checked in code. Fetches use stable numeric repository IDs, conditional ETags,
and bounded timeouts/bodies. Full-catalog backfill remains available explicitly.

Reconciliation defaults to anonymous public reads. The optional dedicated
catalog GitHub App mode is selected only by `GITHUB_RELEASE_AUTH_MODE=github_app`;
omission or `anonymous` preserves the default. An invalid or unavailable
configured App mode fails closed, without an anonymous retry. It never uses
the engineering App credentials or enables engineering/AI capabilities.

The separate `GITHUB_RELEASE_APP_CONFIGURATION` JSON has exactly `appId`,
Comment thread
FlyOverCoderKY marked this conversation as resolved.
Resolved
`installationId`, `version`, and UTC `validUntil` fields. The host supplies its
dedicated PKCS#8 PEM signing key as the secret
`GITHUB_RELEASE_APP_PRIVATE_KEY_PKCS8`, never a committed var. The existing
organization ID and exact 13-ID repository allowlist must be configured. No
App, installation, key or enabled mode is supplied by the default deployment.
The dedicated App installation must select only those 13 public repositories
and grant metadata-read only.
Both IDs are positive decimal **JSON strings**, not numbers. `version` is a
1–100 character string of letters, digits, dot, underscore or hyphen;
`validUntil` is a future UTC ISO timestamp ending in `Z` (optional millisecond
precision). The allowlist var is shared with webhook ingestion and public
release display. This App mode deliberately requires the complete 13-ID
deployment contract; narrowing it makes App mode unavailable. Do not widen an
ingestion allowlist merely to repair a configured authentication refusal.
The issuer signs a fresh RS256 App JWT and requests a selected installation
token for one scheduled immutable repository ID with **metadata-read only**.
It refuses any contents, issues or write permission in the returned grant.

Public latest-release access with this metadata-only token is an inference
from GitHub's public-resource access contract, not a deployed compatibility
claim. Before activation, verify that exact public read using the separately
approved App/installation; a refusal must not prompt broader permissions.
See GitHub's [latest-release access contract](https://docs.github.com/en/rest/releases/releases#get-the-latest-release),
[installation-token scope](https://docs.github.com/en/rest/apps/apps#create-an-installation-access-token-for-an-app)
and [App JWT requirements](https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/generating-a-json-web-token-jwt-for-a-github-app).
After each authenticated 200, 304 or 404, a fresh metadata read must confirm
the exact repository is public and belongs to the configured Pegma organization
before projection or progress advances. Inaccessible, private, transferred,
expired or changed authority holds the prior state. Authenticated requests
reject redirects. Minting, release access, metadata verification and projection
preparation share one ten-second admission deadline, with at most three GitHub
requests and no retry/cache. Authority is checked after awaited preparation
and synchronously at atomic transaction submission. Public Store transactions
cannot be canceled once submitted: the caller awaits their actual outcome,
including a late acknowledgement, rather than reporting a false timeout while
an abandoned write continues. A refusal or timeout before submission cannot
later resume into a write. Issuer and reconciliation must share one clock and
transport; the production root wires both explicitly.
Local tests do not prove deployed signing CPU cost or grant live access.

HTTP 403/429 summaries retain only bounded numeric `rateLimitRemaining` (up to
2,147,483,647) and `retryAfterSeconds` (decimal seconds up to 86,400), or null.
HTTP-date, malformed and out-of-bound Retry-After values are deliberately
discarded. Zero remaining or a retained numeric Retry-After is a throttle
signal; absent hints or nonzero remaining do not establish permission failure
or exclude secondary limiting. No error response body, raw headers, key, JWT
or token is logged. The [issuer and reconciliation tests](src/release-catalog-auth.test.ts)
exercise the optional contract with fictional responses.
Authentication failures use only the closed reason codes
`invalid_configuration`, `issuer_unavailable`, `invalid_grant` and
`authority_unavailable`. Metadata failures retain their own response status and
classification; they never combine a release body's byte count with a
different response.

Each successful scheduled shard records its scheduled timestamp durably in the
existing operations collection. Global reconciliation health advances only
when every currently allowlisted catalog repository has succeeded in that
Expand Down
7 changes: 7 additions & 0 deletions worker/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import {
type GitHubReleaseWebhookEnv,
} from './github-release-webhook';
import { loadReleaseHealthDetail } from './release-health';
import { releaseCatalogAuthenticationFor, type ReleaseCatalogAuthenticationEnv } from './release-catalog-auth';
import {
RELEASE_RECONCILIATION_CRON,
runReleaseReconciliation,
Expand Down Expand Up @@ -92,6 +93,7 @@ type AppEnv = Omit<Env, 'PEGMA_SUPPORT_RELEASE_FOLLOWUP_ENABLED' | 'PEGMA_SUPPOR
LoggerEnv &
IdentityRuntimeEnv &
GitHubReleaseWebhookEnv &
ReleaseCatalogAuthenticationEnv &
SupportRuntimeEnv &
CatalogFetchEnv & SupportAssistantProductionEnvironment & SupportLearningSourceEnvironment & SupportPaidEnvironment & SupportReleaseFollowupEnvironment & {
readonly PEGMA_SUPPORT_LEARNING_REVIEWS_ENABLED?: string;
Expand Down Expand Up @@ -1252,11 +1254,16 @@ return {
logger.log('error', 'release_reconciliation.not_configured', {});
return;
}
const releaseClock = systemClock;
const releaseFetch = fetch;
await runReleaseReconciliation({
store: createProductionStore(env),
logger,
config: releasesConfig,
scheduledTime: controller.scheduledTime,
authentication: releaseCatalogAuthenticationFor(() => env, { clock: releaseClock, fetch: releaseFetch }),
clock: releaseClock,
fetchImpl: releaseFetch,
followupTracking: () => followupTrackingFor(env),
});
} catch (error) {
Expand Down
Loading
Loading