@sifr-dev/loom 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/CHANGELOG.md +112 -0
  2. package/LICENSE +21 -0
  3. package/README.ar.md +253 -0
  4. package/README.md +262 -2
  5. package/dist/browser.js +2717 -0
  6. package/dist/cli.js +15 -0
  7. package/dist/index.js +4854 -0
  8. package/dist/types/args.d.ts +14 -0
  9. package/dist/types/base64.d.ts +9 -0
  10. package/dist/types/browser.d.ts +57 -0
  11. package/dist/types/canonical.d.ts +20 -0
  12. package/dist/types/cli.d.ts +12 -0
  13. package/dist/types/commands/context.d.ts +30 -0
  14. package/dist/types/commands/diff.d.ts +18 -0
  15. package/dist/types/commands/doctor.d.ts +19 -0
  16. package/dist/types/commands/export.d.ts +30 -0
  17. package/dist/types/commands/migrate.d.ts +9 -0
  18. package/dist/types/commands/serve.d.ts +18 -0
  19. package/dist/types/commands/snapshot.d.ts +15 -0
  20. package/dist/types/commands/sync.d.ts +17 -0
  21. package/dist/types/commands/verify.d.ts +9 -0
  22. package/dist/types/commands/watch.d.ts +25 -0
  23. package/dist/types/compute.d.ts +49 -0
  24. package/dist/types/concurrency.d.ts +31 -0
  25. package/dist/types/config.d.ts +132 -0
  26. package/dist/types/diff.d.ts +57 -0
  27. package/dist/types/digest.d.ts +11 -0
  28. package/dist/types/entities.d.ts +27 -0
  29. package/dist/types/errors.d.ts +37 -0
  30. package/dist/types/fs.d.ts +23 -0
  31. package/dist/types/github/cache.d.ts +44 -0
  32. package/dist/types/github/client.d.ts +91 -0
  33. package/dist/types/github/collect.d.ts +36 -0
  34. package/dist/types/github/discovery.d.ts +39 -0
  35. package/dist/types/github/fixture.d.ts +26 -0
  36. package/dist/types/github/guard.d.ts +14 -0
  37. package/dist/types/github/memory-cache.d.ts +34 -0
  38. package/dist/types/index.d.ts +44 -0
  39. package/dist/types/log.d.ts +16 -0
  40. package/dist/types/metrics.d.ts +21 -0
  41. package/dist/types/migrate.d.ts +24 -0
  42. package/dist/types/pipeline.d.ts +73 -0
  43. package/dist/types/queue.d.ts +33 -0
  44. package/dist/types/sdk.d.ts +165 -0
  45. package/dist/types/secrets.d.ts +28 -0
  46. package/dist/types/serve-handler.d.ts +46 -0
  47. package/dist/types/sha256.d.ts +13 -0
  48. package/dist/types/site-module.d.ts +23 -0
  49. package/dist/types/site.d.ts +135 -0
  50. package/dist/types/snapshot.d.ts +16 -0
  51. package/dist/types/store.d.ts +119 -0
  52. package/dist/types/triggers.d.ts +67 -0
  53. package/dist/types/types.d.ts +176 -0
  54. package/dist/types/version.d.ts +7 -0
  55. package/dist/types/webhook/delivery.d.ts +45 -0
  56. package/dist/types/webhook/receiver.d.ts +46 -0
  57. package/dist/types/webhook/signature.d.ts +43 -0
  58. package/docs/CONFIGURATION.md +213 -0
  59. package/docs/DEPLOYMENT.md +316 -0
  60. package/docs/SDK.md +351 -0
  61. package/docs/SITE_CONTRACT.md +318 -0
  62. package/docs/VERIFICATION.md +130 -0
  63. package/package.json +83 -4
  64. package/schema/site@1.json +188 -0
@@ -0,0 +1,176 @@
1
+ export declare const SNAPSHOT_SCHEMA = "loom/snapshot@1";
2
+ export type ReleaseSnapshot = {
3
+ id: number | string;
4
+ tag: string;
5
+ name: string | null;
6
+ publishedAt: string | null;
7
+ prerelease: boolean;
8
+ draft: boolean;
9
+ url: string | null;
10
+ };
11
+ export type HeadSnapshot = {
12
+ sha: string;
13
+ message: string;
14
+ author: string | null;
15
+ committedAt: string | null;
16
+ url: string;
17
+ };
18
+ /** README state: identity plus a bounded plain-text excerpt, never the full blob. */
19
+ export type ReadmeSnapshot = {
20
+ path: string;
21
+ sha: string;
22
+ size: number;
23
+ /** Original encoding advertised by GitHub (usually "base64"). */
24
+ encoding: string | null;
25
+ htmlUrl: string | null;
26
+ downloadUrl: string | null;
27
+ /** First `collect.readmeExcerptChars` characters of the decoded text. */
28
+ excerpt: string | null;
29
+ };
30
+ export type BranchSnapshot = {
31
+ name: string;
32
+ sha: string;
33
+ protected: boolean;
34
+ /** True for the repository's default branch. */
35
+ default: boolean;
36
+ };
37
+ export type CommitCommentSnapshot = {
38
+ id: number | string;
39
+ body: string;
40
+ author: string | null;
41
+ createdAt: string | null;
42
+ url: string | null;
43
+ commitSha: string | null;
44
+ };
45
+ export type IssueCommentSnapshot = {
46
+ id: number | string;
47
+ body: string;
48
+ author: string | null;
49
+ createdAt: string | null;
50
+ url: string | null;
51
+ issueNumber: number | null;
52
+ };
53
+ export type WorkflowSnapshot = {
54
+ id: number | string;
55
+ name: string;
56
+ path: string;
57
+ state: string;
58
+ };
59
+ export type CiSnapshot = {
60
+ workflow: string | null;
61
+ runId: number | string;
62
+ status: string | null;
63
+ conclusion: string | null;
64
+ branch: string | null;
65
+ sha: string | null;
66
+ url: string | null;
67
+ updatedAt: string | null;
68
+ };
69
+ export type RepoSnapshot = {
70
+ /** Canonical, case-insensitive id: `owner/name` lowercased. */
71
+ id: string;
72
+ /** Display name exactly as GitHub reports it. */
73
+ fullName: string;
74
+ description: string | null;
75
+ homepage: string | null;
76
+ topics: string[];
77
+ language: string | null;
78
+ languages: Record<string, number>;
79
+ license: string | null;
80
+ stars: number;
81
+ forks: number;
82
+ watchers: number;
83
+ openIssues: number;
84
+ archived: boolean;
85
+ fork: boolean;
86
+ defaultBranch: string;
87
+ createdAt: string | null;
88
+ updatedAt: string | null;
89
+ pushedAt: string | null;
90
+ htmlUrl: string;
91
+ visibility: "public";
92
+ releases: ReleaseSnapshot[];
93
+ head: HeadSnapshot | null;
94
+ /** Present only when `collect.readme` is enabled. */
95
+ readme?: ReadmeSnapshot | null;
96
+ /** Present only when `collect.branches` is enabled. */
97
+ branches?: BranchSnapshot[];
98
+ /** Present only when `collect.commitComments` is enabled. */
99
+ commitComments?: CommitCommentSnapshot[];
100
+ /** Present only when `collect.issueComments` is enabled. */
101
+ issueComments?: IssueCommentSnapshot[];
102
+ /** Present only when `collect.workflows` is enabled. */
103
+ workflows?: WorkflowSnapshot[];
104
+ /** Latest CI run on the default branch, when `collect.workflows` is enabled. */
105
+ ci?: CiSnapshot | null;
106
+ };
107
+ export type SnapshotError = {
108
+ repo: string;
109
+ code: string;
110
+ message: string;
111
+ /** True when the previous good copy of this repository was kept instead of deletion. */
112
+ retained?: boolean;
113
+ };
114
+ export type SnapshotSourceCollect = {
115
+ readme: boolean;
116
+ branches: boolean;
117
+ extraBranches: string[];
118
+ branchLimit: number;
119
+ commitComments: boolean;
120
+ commitCommentLimit: number;
121
+ issueComments: boolean;
122
+ issueCommentLimit: number;
123
+ workflows: boolean;
124
+ workflowLimit: number;
125
+ ciRuns: number;
126
+ };
127
+ export type SnapshotSource = {
128
+ kind: "github";
129
+ api: string;
130
+ repos: string[];
131
+ releases: number;
132
+ includeLatestCommit: boolean;
133
+ /** Present when at least one opt-in `collect` source was enabled. */
134
+ collect?: SnapshotSourceCollect;
135
+ /** Old owner login -> current login used to canonicalise this snapshot. */
136
+ ownerAliases?: {
137
+ from: string;
138
+ to: string;
139
+ }[];
140
+ /** Authenticated login when `discovery.owners` contained `me`. */
141
+ identity?: string | null;
142
+ /** Present when owner discovery contributed to `repos`. */
143
+ discovery?: {
144
+ owners: string[];
145
+ include: string[];
146
+ exclude: string[];
147
+ includeArchived: boolean;
148
+ includeForks: boolean;
149
+ /** Number of repositories selected by discovery (excluding explicit `repos`). */
150
+ selected: number;
151
+ };
152
+ };
153
+ export type SnapshotPayload = {
154
+ schema: typeof SNAPSHOT_SCHEMA;
155
+ source: SnapshotSource;
156
+ repos: RepoSnapshot[];
157
+ errors: SnapshotError[];
158
+ };
159
+ export type Snapshot = {
160
+ payload: SnapshotPayload;
161
+ /** Content address of the payload, `sha256:<hex>`. */
162
+ id: string;
163
+ };
164
+ export type SnapshotStats = {
165
+ repos: number;
166
+ releases: number;
167
+ languages: number;
168
+ errors: number;
169
+ readmes: number;
170
+ branches: number;
171
+ commitComments: number;
172
+ issueComments: number;
173
+ workflows: number;
174
+ };
175
+ /** Everything a repo entity owns, excluding the entities modelled separately. */
176
+ export declare function snapshotStats(payload: SnapshotPayload): SnapshotStats;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * One source of truth for the version string. `package.json` is the release
3
+ * artifact; this constant is what `loom --version` prints. A test keeps them
4
+ * equal so a release cannot ship a lying binary.
5
+ */
6
+ export declare const VERSION = "1.0.0";
7
+ export declare const USER_AGENT = "loom-sync/1.0.0 (+https://github.com/Sifr-Dev/Loom)";
@@ -0,0 +1,45 @@
1
+ export declare const WEBHOOK_STATE_SCHEMA = "loom/webhook-state@1";
2
+ export type DeliveryRecord = {
3
+ id: string;
4
+ at: string;
5
+ event: string;
6
+ repo: string | null;
7
+ };
8
+ export type PayloadRecord = {
9
+ hash: string;
10
+ at: string;
11
+ };
12
+ export type DeliveryLogFile = {
13
+ schema: typeof WEBHOOK_STATE_SCHEMA;
14
+ deliveries: DeliveryRecord[];
15
+ payloads: PayloadRecord[];
16
+ };
17
+ export type DeliveryOpenResult = {
18
+ log: DeliveryLog;
19
+ recovered: boolean;
20
+ quarantined: string | null;
21
+ };
22
+ /**
23
+ * Durable record of verified webhook deliveries.
24
+ *
25
+ * GitHub retries a delivery with the same `X-GitHub-Delivery` id; remembering
26
+ * which ids were processed is what makes a retry idempotent and a replay inert.
27
+ */
28
+ export declare class DeliveryLog {
29
+ #private;
30
+ private constructor();
31
+ static open(path: string): Promise<DeliveryLog>;
32
+ /**
33
+ * Open the durable delivery log. Corruption is treated as "we cannot prove
34
+ * anything was processed": the file is quarantined and an empty log starts,
35
+ * so GitHub retries are accepted rather than rejected as replays.
36
+ */
37
+ static openWithRecovery(path: string): Promise<DeliveryOpenResult>;
38
+ get size(): number;
39
+ has(id: string): boolean;
40
+ hasPayload(hash: string, windowMs: number, nowMs?: number): boolean;
41
+ /** Record a verified delivery and persist immediately. Returns false if it was already seen. */
42
+ record(record: DeliveryRecord, payloadHash?: string | null): Promise<boolean>;
43
+ save(): Promise<void>;
44
+ toJSON(): DeliveryLogFile;
45
+ }
@@ -0,0 +1,46 @@
1
+ import { type SignatureMode } from "./signature.js";
2
+ import type { DeliveryLog } from "./delivery.js";
3
+ export type WebhookInput = {
4
+ headers: Headers;
5
+ body: Uint8Array;
6
+ };
7
+ export type WebhookKind = "accepted" | "ignored" | "duplicate" | "unauthorized" | "invalid";
8
+ export type WebhookDecision = {
9
+ kind: WebhookKind;
10
+ /** GitHub event name, or the empty string when it could not be read. */
11
+ event: string;
12
+ delivery: string;
13
+ action: "sync" | "none";
14
+ repo: string | null;
15
+ ref: string | null;
16
+ payloadHash: string;
17
+ reason: string;
18
+ };
19
+ export type WebhookReceiverOptions = {
20
+ /** Current secret first; extra entries allow rotation without downtime. */
21
+ secrets: string | readonly string[];
22
+ deliveries: DeliveryLog;
23
+ branches?: readonly string[];
24
+ /** Treat a push to the repository's own default branch as watched. */
25
+ branchDiscovery?: boolean;
26
+ mode?: SignatureMode;
27
+ toleranceSeconds?: number;
28
+ maxBodyBytes?: number;
29
+ now?: () => number;
30
+ /** Only these repositories may trigger a rebuild. Defaults to every public repo. */
31
+ repoAllowed?: (repo: string) => boolean;
32
+ logger?: (message: string, detail?: Record<string, unknown>) => void;
33
+ };
34
+ export declare class WebhookReceiver {
35
+ #private;
36
+ constructor(options: WebhookReceiverOptions);
37
+ handle(input: WebhookInput): Promise<WebhookDecision>;
38
+ /**
39
+ * Persist a delivery after its work succeeded. Callers record only after the
40
+ * rebuild finishes so a failed sync can still be retried by GitHub; once it
41
+ * succeeds, a replay with the same delivery id is inert.
42
+ */
43
+ markDelivered(decision: WebhookDecision): Promise<void>;
44
+ /** True when this delivery id was already processed. */
45
+ seen(delivery: string): boolean;
46
+ }
@@ -0,0 +1,43 @@
1
+ export declare const SIGNATURE_HEADER = "x-hub-signature-256";
2
+ export declare const DELIVERY_HEADER = "x-github-delivery";
3
+ export declare const EVENT_HEADER = "x-github-event";
4
+ export declare const TIMESTAMP_HEADER = "x-loom-timestamp";
5
+ export declare const HOOK_ID_HEADER = "x-github-hook-id";
6
+ export type SignatureMode = "github" | "signed-timestamp";
7
+ export type VerifyOptions = {
8
+ secret: string;
9
+ body: Uint8Array;
10
+ /** Value of `X-Hub-Signature-256`, e.g. `sha256=ab12…`. */
11
+ signature: string | null;
12
+ mode?: SignatureMode;
13
+ /** Required in `signed-timestamp` mode. */
14
+ timestamp?: string | null;
15
+ toleranceSeconds?: number;
16
+ nowMs?: number;
17
+ };
18
+ export type VerifyResult = {
19
+ valid: true;
20
+ timestamp: number | null;
21
+ } | {
22
+ valid: false;
23
+ reason: string;
24
+ };
25
+ /** HMAC-SHA256 in lowercase hex. */
26
+ export declare function hmacSha256Hex(secret: string, payload: Uint8Array | string): string;
27
+ /** The header value GitHub sends: `sha256=<hex>`. */
28
+ export declare function signBody(secret: string, payload: Uint8Array | string): string;
29
+ /**
30
+ * Constant-time comparison of two hex digests. Length differences are still
31
+ * compared against a same-length buffer so the comparison does not short-circuit
32
+ * on length alone before doing the work.
33
+ */
34
+ export declare function timingSafeHexEqual(left: string, right: string): boolean;
35
+ /**
36
+ * Verify a GitHub-style HMAC body signature, or the stricter signed-timestamp
37
+ * variant used for Loom's own internal hook.
38
+ *
39
+ * In `signed-timestamp` mode the signed message is `<unix-seconds>.<body>` and
40
+ * a request outside the tolerance window is rejected even with a valid MAC, so
41
+ * a captured request cannot be replayed later.
42
+ */
43
+ export declare function verifySignature(options: VerifyOptions): VerifyResult;
@@ -0,0 +1,213 @@
1
+ # Configuration
2
+
3
+ **English** | [العربية](ar/CONFIGURATION.md)
4
+
5
+ Loom reads `loom.config.json` from the working directory. Secrets never live in
6
+ this file: each secret is named by the environment variable that holds it. The
7
+ schema is `loom/config@1`. A missing file yields the defaults, which read no
8
+ repository until `repos` or `discovery.owners` is set.
9
+
10
+ A complete file:
11
+
12
+ ```json
13
+ {
14
+ "schema": "loom/config@1",
15
+ "repos": ["Sifr-Dev/Stele", "Sifr-Dev/Loom"],
16
+ "branches": ["main"],
17
+ "releases": 3,
18
+ "includeLatestCommit": true,
19
+ "aliases": { "Sifr-Dev/OldName": "Sifr-Dev/NewName" },
20
+ "ownerAliases": { "OldLogin": "NewLogin" },
21
+ "discovery": {
22
+ "owners": ["Sifr-Dev"],
23
+ "include": [],
24
+ "exclude": ["acme/legacy-site", "acme/archive"],
25
+ "includeArchived": false,
26
+ "includeForks": false
27
+ },
28
+ "collect": {
29
+ "readme": true,
30
+ "readmeExcerptChars": 600,
31
+ "branches": true,
32
+ "branchLimit": 10,
33
+ "extraBranches": [],
34
+ "commitComments": true,
35
+ "commitCommentLimit": 20,
36
+ "issueComments": true,
37
+ "issueCommentLimit": 20,
38
+ "workflows": true,
39
+ "workflowLimit": 10,
40
+ "ciRuns": 5
41
+ },
42
+ "store": ".loom",
43
+ "githubBaseUrl": "https://api.github.com",
44
+ "triggers": [
45
+ { "kind": "vercel", "urlEnv": "VERCEL_DEPLOY_HOOK_URL" },
46
+ {
47
+ "kind": "github-dispatch",
48
+ "repo": "Sifr-Dev/site",
49
+ "eventType": "loom-sync",
50
+ "tokenEnv": "SITE_DISPATCH_TOKEN"
51
+ },
52
+ { "kind": "webhook", "urlEnv": "SINK_URL", "secretEnv": "SINK_SECRET" }
53
+ ],
54
+ "webhook": {
55
+ "path": "/webhook",
56
+ "secretEnv": "LOOM_WEBHOOK_SECRET",
57
+ "toleranceSeconds": 300,
58
+ "maxBodyBytes": 1048576
59
+ },
60
+ "watch": { "intervalSeconds": 60 },
61
+ "serve": {
62
+ "pollIntervalSeconds": 300,
63
+ "queueDepth": 32,
64
+ "shutdownTimeoutSeconds": 30,
65
+ "syncTimeoutSeconds": 120
66
+ }
67
+ }
68
+ ```
69
+
70
+ ## Top-level keys
71
+
72
+ | Key | Type | Default | Meaning |
73
+ | --- | --- | --- | --- |
74
+ | `schema` | string | `loom/config@1` | Rejected when it is another value. |
75
+ | `repos` | string[] | `[]` | Explicit public repositories as `owner/name`. |
76
+ | `branches` | string[] | `["main"]` | Branches whose pushes are deploy-relevant for webhooks. |
77
+ | `releases` | integer 0 to 100 | `5` | Maximum releases exported per repository, newest first. |
78
+ | `includeLatestCommit` | boolean | `true` | Read the head commit of the default branch. |
79
+ | `aliases` | object | `{}` | Old repository id to current id, for renames. |
80
+ | `ownerAliases` | object | `{}` | Old owner login to current login, for account renames. |
81
+ | `discovery` | object | see below | Public-owner discovery. |
82
+ | `collect` | object | see below | Opt-in, bounded enrichment. |
83
+ | `store` | string | `.loom` | Store directory, relative to the project. |
84
+ | `githubBaseUrl` | string | `https://api.github.com` | API base for tests, proxies, or GitHub Enterprise. |
85
+ | `triggers` | array | `[]` | Deploy targets notified after a committed change. |
86
+ | `webhook` | object | see below | Inbound GitHub webhook settings. |
87
+ | `watch` | object | `{ "intervalSeconds": 60 }` | Poll interval for `loom watch`. |
88
+ | `serve` | object | see below | Webhook server queue and lifecycle. |
89
+
90
+ ## Repositories and validation
91
+
92
+ `repos` entries must be `owner/name`. Names longer than 140 characters, names
93
+ containing `..` or `//`, and names with a control character are rejected. A
94
+ duplicate entry is dropped case-insensitively, keeping the first spelling.
95
+
96
+ `store` must be a relative path inside the project. An absolute path or a path
97
+ containing `..` is rejected.
98
+
99
+ `branches` must be a non-empty array. Entries may not start with `refs/` and may
100
+ not contain `..`. The head of each repository is always read from the branch
101
+ GitHub reports as default, so a repository whose default branch is `master` is
102
+ not missed. `branches` is an additional allow-list for webhook pushes.
103
+
104
+ Aliases are case-insensitive and chains are followed with cycle protection.
105
+ `loom doctor` reports an alias cycle instead of following it forever.
106
+
107
+ ## Discovery
108
+
109
+ `discovery.owners` makes new public repositories appear with no config or site
110
+ edit. The owner listing is paginated and filtered in this order:
111
+
112
+ 1. reject `private: true` or any non-`public` visibility;
113
+ 2. reject a full name whose owner is not the configured owner;
114
+ 3. reject archived repositories unless `includeArchived` is true;
115
+ 4. reject forks unless `includeForks` is true;
116
+ 5. reject any `exclude` glob match;
117
+ 6. when `include` is non-empty, require at least one match.
118
+
119
+ `include` and `exclude` accept `owner/name` globs with `*` and `?`, for example
120
+ `Sifr-Dev/*` or `Sifr-Dev/Ob?erse`. A match in `exclude` always wins. Explicit
121
+ `repos` entries are added after discovery and are not subject to this policy.
122
+
123
+ A discovery failure aborts the sync before any commit, so a partial page can
124
+ never look like a set of deletions.
125
+
126
+ ## Account renames
127
+
128
+ `ownerAliases` keeps an account rename canonical: the old login is rewritten to
129
+ the current login before every request, so repository ids, diffs, and site data
130
+ use the new login and an old owner does not appear in project data.
131
+
132
+ Use `discovery.owners: ["me"]` to track the authenticated account through
133
+ `GET /user`. A redirect from the old login is detected automatically. A hard
134
+ `404` needs an explicit alias. Loom cannot rename the GitHub account or rewrite
135
+ arbitrary source files.
136
+
137
+ ## Privacy boundary
138
+
139
+ Discovery reads the public owner and repository endpoints, filters any
140
+ `private: true` or non-`public` visibility entry before it is fetched, and the
141
+ public guard runs again on every repository response. A token only raises the
142
+ rate limit; it never widens what Loom stores. The site record is a public
143
+ surface record, not an account dump.
144
+
145
+ ## Required data versus curated enrichment
146
+
147
+ Loom emits every required generic project field: identity, description, topics,
148
+ languages, counts, branch, URLs, timestamps, newest release, and head. Site-only
149
+ enrichment (tagline, category, maturity, flagship, narrative, capabilities,
150
+ benchmarks) is never invented or required by Loom. The site overlays it by
151
+ `project.id` and renders a generic card when no enrichment exists. The contract
152
+ is in [SITE_CONTRACT.md](SITE_CONTRACT.md#required-data-versus-curated-enrichment).
153
+
154
+ ## Collection limits
155
+
156
+ `collect` is opt-in and bounded. Each source has an explicit limit, so a
157
+ high-activity repository cannot make the snapshot or the website module grow
158
+ without bound. With every flag false, the snapshot keeps metadata, languages,
159
+ releases, and the latest commit only.
160
+
161
+ | Key | Type | Default | Meaning |
162
+ | --- | --- | --- | --- |
163
+ | `readme` | boolean | `false` | Read README state and a plain-text excerpt. |
164
+ | `readmeExcerptChars` | integer 0 to 20000 | `600` | Maximum excerpt length. |
165
+ | `branches` | boolean | `false` | Read branch heads. |
166
+ | `branchLimit` | integer 1 to 100 | `10` | Maximum branches kept. |
167
+ | `extraBranches` | string[] | `[]` | Branches to track in addition to the default branch. |
168
+ | `commitComments` | boolean | `false` | Read commit comments. |
169
+ | `commitCommentLimit` | integer 1 to 100 | `20` | Maximum commit comments kept. |
170
+ | `issueComments` | boolean | `false` | Read issue and pull request comments. |
171
+ | `issueCommentLimit` | integer 1 to 100 | `20` | Maximum issue comments kept. |
172
+ | `workflows` | boolean | `false` | Read workflow definitions and the latest CI run. |
173
+ | `workflowLimit` | integer 1 to 100 | `10` | Maximum workflows kept. |
174
+ | `ciRuns` | integer 1 to 100 | `5` | CI runs considered when selecting the latest. |
175
+
176
+ ## Triggers
177
+
178
+ | Kind | Required keys | Behaviour |
179
+ | --- | --- | --- |
180
+ | `vercel` | `urlEnv` | `POST` the deploy hook URL with the snapshot id as `X-Loom-Delivery`. |
181
+ | `github-dispatch` | `repo`, `eventType`, `tokenEnv` | `POST /repos/{repo}/dispatches` with a `client_payload.delivery`. |
182
+ | `webhook` | `urlEnv`, optional `secretEnv` | Signed JSON body; the HMAC goes in `X-Loom-Signature`. |
183
+
184
+ A trigger whose environment variable is missing is recorded as `skipped` and
185
+ keeps the outbox pending. It is never reported as a successful deploy.
186
+
187
+ ## Webhook settings
188
+
189
+ | Key | Default | Meaning |
190
+ | --- | --- | --- |
191
+ | `path` | `/webhook` | HTTP path served by `loom serve`. |
192
+ | `secretEnv` | `LOOM_WEBHOOK_SECRET` | Environment variable holding the HMAC secret. The secret must be at least 16 characters. |
193
+ | `toleranceSeconds` | `300` | Accepted clock skew in signed-timestamp mode. |
194
+ | `maxBodyBytes` | `1048576` | Requests above this size are rejected before verification. |
195
+
196
+ ## Server settings
197
+
198
+ | Key | Default | Meaning |
199
+ | --- | --- | --- |
200
+ | `watch.intervalSeconds` | `60` | Seconds between polls in `loom watch`. |
201
+ | `serve.pollIntervalSeconds` | `0` | Reconciliation poll interval; `0` disables polling. |
202
+ | `serve.queueDepth` | `32` | Webhook syncs allowed to wait behind the active one. |
203
+ | `serve.shutdownTimeoutSeconds` | `30` | Graceful drain deadline on `SIGTERM` and `SIGINT`. |
204
+ | `serve.syncTimeoutSeconds` | `120` | Hard deadline for one queued sync. |
205
+
206
+ ## Authentication
207
+
208
+ Public reads work anonymously at 60 requests per hour. Live sync should use a
209
+ PAT or a GitHub App token in `GITHUB_TOKEN`, overridden with `--token-env`.
210
+ Loom reads the token by name and never writes it to config, snapshots, or logs.
211
+ Fine-grained read access to public repositories is enough; private and internal
212
+ repositories are rejected by policy. The PAT scopes are listed in
213
+ [SDK.md](SDK.md#authentication-and-pat-scopes).