@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.
- package/CHANGELOG.md +112 -0
- package/LICENSE +21 -0
- package/README.ar.md +253 -0
- package/README.md +262 -2
- package/dist/browser.js +2717 -0
- package/dist/cli.js +15 -0
- package/dist/index.js +4854 -0
- package/dist/types/args.d.ts +14 -0
- package/dist/types/base64.d.ts +9 -0
- package/dist/types/browser.d.ts +57 -0
- package/dist/types/canonical.d.ts +20 -0
- package/dist/types/cli.d.ts +12 -0
- package/dist/types/commands/context.d.ts +30 -0
- package/dist/types/commands/diff.d.ts +18 -0
- package/dist/types/commands/doctor.d.ts +19 -0
- package/dist/types/commands/export.d.ts +30 -0
- package/dist/types/commands/migrate.d.ts +9 -0
- package/dist/types/commands/serve.d.ts +18 -0
- package/dist/types/commands/snapshot.d.ts +15 -0
- package/dist/types/commands/sync.d.ts +17 -0
- package/dist/types/commands/verify.d.ts +9 -0
- package/dist/types/commands/watch.d.ts +25 -0
- package/dist/types/compute.d.ts +49 -0
- package/dist/types/concurrency.d.ts +31 -0
- package/dist/types/config.d.ts +132 -0
- package/dist/types/diff.d.ts +57 -0
- package/dist/types/digest.d.ts +11 -0
- package/dist/types/entities.d.ts +27 -0
- package/dist/types/errors.d.ts +37 -0
- package/dist/types/fs.d.ts +23 -0
- package/dist/types/github/cache.d.ts +44 -0
- package/dist/types/github/client.d.ts +91 -0
- package/dist/types/github/collect.d.ts +36 -0
- package/dist/types/github/discovery.d.ts +39 -0
- package/dist/types/github/fixture.d.ts +26 -0
- package/dist/types/github/guard.d.ts +14 -0
- package/dist/types/github/memory-cache.d.ts +34 -0
- package/dist/types/index.d.ts +44 -0
- package/dist/types/log.d.ts +16 -0
- package/dist/types/metrics.d.ts +21 -0
- package/dist/types/migrate.d.ts +24 -0
- package/dist/types/pipeline.d.ts +73 -0
- package/dist/types/queue.d.ts +33 -0
- package/dist/types/sdk.d.ts +165 -0
- package/dist/types/secrets.d.ts +28 -0
- package/dist/types/serve-handler.d.ts +46 -0
- package/dist/types/sha256.d.ts +13 -0
- package/dist/types/site-module.d.ts +23 -0
- package/dist/types/site.d.ts +135 -0
- package/dist/types/snapshot.d.ts +16 -0
- package/dist/types/store.d.ts +119 -0
- package/dist/types/triggers.d.ts +67 -0
- package/dist/types/types.d.ts +176 -0
- package/dist/types/version.d.ts +7 -0
- package/dist/types/webhook/delivery.d.ts +45 -0
- package/dist/types/webhook/receiver.d.ts +46 -0
- package/dist/types/webhook/signature.d.ts +43 -0
- package/docs/CONFIGURATION.md +213 -0
- package/docs/DEPLOYMENT.md +316 -0
- package/docs/SDK.md +351 -0
- package/docs/SITE_CONTRACT.md +318 -0
- package/docs/VERIFICATION.md +130 -0
- package/package.json +83 -4
- package/schema/site@1.json +188 -0
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
# Site consumer contract (`loom/site@1`)
|
|
2
|
+
|
|
3
|
+
**English** | [العربية](ar/SITE_CONTRACT.md)
|
|
4
|
+
|
|
5
|
+
Loom is the sole source of project data for a portfolio site. The site does not
|
|
6
|
+
call GitHub, does not own a project list, and does not need a hand-authored
|
|
7
|
+
dossier when a repository is added, renamed, archived, or released. It reads one
|
|
8
|
+
canonical JSON document and renders it in the order it arrives.
|
|
9
|
+
|
|
10
|
+
The stable artifact is produced by:
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
loom export --out site.json # from the committed snapshot
|
|
14
|
+
loom export --source remote --out site.json # recompute without committing
|
|
15
|
+
loom export --check --out site.json # exit 7 when a redeploy is due
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
`loom export` is deterministic: the same snapshot produces the same bytes on
|
|
19
|
+
every machine. It contains no build timestamp, no run id, and no random id.
|
|
20
|
+
`siteDigest(record)` is `sha256:<hex>` over the canonical JSON and is a safe
|
|
21
|
+
cache key or deploy de-duplication token.
|
|
22
|
+
|
|
23
|
+
## Schema
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
type SiteRecord = {
|
|
27
|
+
schema: "loom/site@1";
|
|
28
|
+
/** Content address of the snapshot this record was derived from. */
|
|
29
|
+
snapshot: string; // "sha256:<64 hex>"
|
|
30
|
+
/** False when a configured repository had no data and no previous copy. */
|
|
31
|
+
complete: boolean;
|
|
32
|
+
projects: SiteProject[]; // sorted by id
|
|
33
|
+
/** Old repository id to current id, resolved through alias chains. */
|
|
34
|
+
aliases: { from: string; to: string }[];
|
|
35
|
+
/** Old owner login to current login, applied before repository aliases. */
|
|
36
|
+
ownerAliases: { from: string; to: string }[];
|
|
37
|
+
errors: SnapshotError[]; // metadata only; never rendered as projects
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
type SiteProject = {
|
|
41
|
+
id: string; // "owner/name" lowercased, the stable key
|
|
42
|
+
slug: string; // URL-safe leaf name from GitHub
|
|
43
|
+
owner: string;
|
|
44
|
+
name: string;
|
|
45
|
+
fullName: string; // display casing from GitHub
|
|
46
|
+
description: string | null;
|
|
47
|
+
homepage: string | null;
|
|
48
|
+
topics: string[]; // sorted
|
|
49
|
+
language: string | null; // GitHub's primary language
|
|
50
|
+
languages: { name: string; bytes: number }[]; // bytes desc, then name
|
|
51
|
+
license: string | null; // SPDX id
|
|
52
|
+
stars: number;
|
|
53
|
+
forks: number;
|
|
54
|
+
watchers: number;
|
|
55
|
+
openIssues: number;
|
|
56
|
+
archived: boolean;
|
|
57
|
+
fork: boolean;
|
|
58
|
+
defaultBranch: string; // "main", "master", or whatever GitHub says
|
|
59
|
+
htmlUrl: string;
|
|
60
|
+
createdAt: string | null;
|
|
61
|
+
updatedAt: string | null;
|
|
62
|
+
pushedAt: string | null;
|
|
63
|
+
release: SiteRelease | null; // newest non-draft release
|
|
64
|
+
releases: SiteRelease[]; // newest first, non-draft only
|
|
65
|
+
head: SiteHead | null; // latest commit on defaultBranch
|
|
66
|
+
|
|
67
|
+
// Optional, present only when the snapshot enabled the matching collect flag:
|
|
68
|
+
readme?: SiteReadme | null; // path, sha, size, htmlUrl, bounded excerpt
|
|
69
|
+
branches?: SiteBranch[]; // default branch first, then by name
|
|
70
|
+
commitComments?: SiteComment[];// newest first, bounded
|
|
71
|
+
issueComments?: SiteComment[]; // newest first, bounded
|
|
72
|
+
workflows?: SiteWorkflow[]; // id, name, path, state
|
|
73
|
+
ci?: SiteCi | null; // latest run on the default branch
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
type SiteRelease = {
|
|
77
|
+
tag: string;
|
|
78
|
+
name: string | null;
|
|
79
|
+
publishedAt: string | null;
|
|
80
|
+
prerelease: boolean;
|
|
81
|
+
url: string | null;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
type SiteHead = {
|
|
85
|
+
sha: string;
|
|
86
|
+
shortSha: string; // first 12 characters
|
|
87
|
+
message: string;
|
|
88
|
+
author: string | null;
|
|
89
|
+
committedAt: string | null;
|
|
90
|
+
url: string;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
type SiteReadme = {
|
|
94
|
+
path: string;
|
|
95
|
+
sha: string;
|
|
96
|
+
size: number;
|
|
97
|
+
htmlUrl: string | null;
|
|
98
|
+
downloadUrl: string | null;
|
|
99
|
+
excerpt: string | null;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
type SiteBranch = {
|
|
103
|
+
name: string;
|
|
104
|
+
sha: string;
|
|
105
|
+
shortSha: string;
|
|
106
|
+
protected: boolean;
|
|
107
|
+
default: boolean;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
type SiteComment = {
|
|
111
|
+
id: number | string;
|
|
112
|
+
body: string;
|
|
113
|
+
author: string | null;
|
|
114
|
+
createdAt: string | null;
|
|
115
|
+
url: string | null;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
type SiteWorkflow = {
|
|
119
|
+
id: number | string;
|
|
120
|
+
name: string;
|
|
121
|
+
path: string;
|
|
122
|
+
state: string;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
type SiteCi = {
|
|
126
|
+
workflow: string | null;
|
|
127
|
+
runId: number | string;
|
|
128
|
+
status: string | null;
|
|
129
|
+
conclusion: string | null;
|
|
130
|
+
branch: string | null;
|
|
131
|
+
sha: string | null;
|
|
132
|
+
shortSha: string | null;
|
|
133
|
+
url: string | null;
|
|
134
|
+
updatedAt: string | null;
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
type SnapshotError = {
|
|
138
|
+
repo: string; // lowercased owner/name
|
|
139
|
+
code: string;
|
|
140
|
+
message: string;
|
|
141
|
+
retained?: true; // previous good copy kept; not a deletion
|
|
142
|
+
};
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
The shipped JSON Schema is [`../schema/site@1.json`](../schema/site@1.json).
|
|
146
|
+
The suite validates real `loom export` output against it.
|
|
147
|
+
|
|
148
|
+
## Guarantees
|
|
149
|
+
|
|
150
|
+
1. **Public state only.** A private or internal response is rejected before any
|
|
151
|
+
record is produced. Visibility is always `"public"`. Owner discovery filters
|
|
152
|
+
private and internal listings before fetching; the guard runs again on each
|
|
153
|
+
repository response.
|
|
154
|
+
2. **Adding a repository is a data change.** If its owner is in
|
|
155
|
+
`discovery.owners`, the next sync emits a new snapshot, a `repo:` addition
|
|
156
|
+
event, and a project entry with no Loom config or site source edit. Explicit
|
|
157
|
+
`repos` entries remain supported for pinning.
|
|
158
|
+
3. **A rename is an update, not a new project.** Once the repository is in the
|
|
159
|
+
alias table, the project keeps its releases and head under the new `id`. The
|
|
160
|
+
diff carries `previousId`, and `aliases` maps the old id to the new one so a
|
|
161
|
+
consumer can keep its identity.
|
|
162
|
+
4. **An account rename canonicalises every repository.** `ownerAliases` maps an
|
|
163
|
+
old owner login to the current one before any request. Entities (repo, head,
|
|
164
|
+
releases, branches, comments, workflows, CI) move to the new owner id in one
|
|
165
|
+
`updated` event with `previousId`. The record lists `ownerAliases`, and
|
|
166
|
+
`owner`, `fullName`, `htmlUrl`, and every emitted link use the canonical
|
|
167
|
+
login. Old owner strings do not appear in project data. A redirect from the
|
|
168
|
+
old login is detected automatically; a hard `404` requires an explicit
|
|
169
|
+
`ownerAliases` entry, and `loom doctor` reports cycles.
|
|
170
|
+
5. **A fetch failure is not a deletion.** With error tolerance and a previous
|
|
171
|
+
snapshot, Loom retains the last good project and sets `retained: true` on the
|
|
172
|
+
error. The record stays complete and no deploy is triggered by the error.
|
|
173
|
+
Without a previous copy the sync is fail-closed: it does not commit or
|
|
174
|
+
dispatch, keeps the previous head, and exits `6` (`partial`). A remote
|
|
175
|
+
candidate record for that state has `complete: false`; do not deploy it.
|
|
176
|
+
6. **Deploy only on change.** `loom sync` commits only when the diff is not
|
|
177
|
+
empty. `site.json` is byte-identical for an unchanged poll, and a site
|
|
178
|
+
workflow dispatches only when `status == "created"`.
|
|
179
|
+
7. **One trigger per committed change.** Each trigger adapter runs once per
|
|
180
|
+
change. Trigger requests carry `X-Loom-Delivery: <snapshot>` (or
|
|
181
|
+
`client_payload.delivery`), so a receiver can make a retry idempotent. A
|
|
182
|
+
crash after commit is repaired by the durable outbox on the next run, not by
|
|
183
|
+
a second deploy for the same snapshot.
|
|
184
|
+
8. **Fail closed.** A trigger failure leaves the snapshot committed but the
|
|
185
|
+
outbox pending. The next run retries with exponential backoff. A failed
|
|
186
|
+
deploy is never reported as success.
|
|
187
|
+
|
|
188
|
+
## Required data versus curated enrichment
|
|
189
|
+
|
|
190
|
+
Loom owns the required generic record for every selected repository. These
|
|
191
|
+
fields are always emitted, with `null` or an empty array as the explicit
|
|
192
|
+
absence value:
|
|
193
|
+
|
|
194
|
+
- identity: `id`, `slug`, `owner`, `name`, `fullName`, `htmlUrl`;
|
|
195
|
+
- presentation-safe public metadata: `description`, `homepage`, `topics`,
|
|
196
|
+
`language`, `languages`, `license`;
|
|
197
|
+
- state: `stars`, `forks`, `watchers`, `openIssues`, `archived`, `fork`,
|
|
198
|
+
`defaultBranch`, timestamps;
|
|
199
|
+
- activity: `release`, `releases`, `head`.
|
|
200
|
+
|
|
201
|
+
The site owns curated enrichment: tagline, category, maturity, flagship status,
|
|
202
|
+
morphology, narrative, capabilities, benchmarks, related projects, and any
|
|
203
|
+
hand-written claims. Loom never emits these fields and never requires them. The
|
|
204
|
+
site overlays enrichment by `project.id` (or stable `slug`) and falls back to a
|
|
205
|
+
generic card when a newly discovered project has no dossier.
|
|
206
|
+
|
|
207
|
+
This is what makes a new public repository a data event only: no Loom config, no
|
|
208
|
+
site source edit, and no fabricated dossier fields.
|
|
209
|
+
|
|
210
|
+
## Discovery policy
|
|
211
|
+
|
|
212
|
+
`discovery.owners` is the default source for a site. For each owner Loom
|
|
213
|
+
resolves the account type, pages the public repository listing, and applies this
|
|
214
|
+
deterministic order:
|
|
215
|
+
|
|
216
|
+
1. reject `private: true` or non-`public` visibility;
|
|
217
|
+
2. reject a full name whose owner is not the configured owner;
|
|
218
|
+
3. reject archived repositories unless `includeArchived` is true;
|
|
219
|
+
4. reject forks unless `includeForks` is true;
|
|
220
|
+
5. reject any `exclude` glob match;
|
|
221
|
+
6. if `include` is non-empty, require at least one match.
|
|
222
|
+
|
|
223
|
+
`discovery.owners` may contain `me`: Loom resolves it through `GET /user` with
|
|
224
|
+
the configured PAT, then lists that login. A configured old login is resolved
|
|
225
|
+
through `ownerAliases` before any request; if `/users/{old}` instead redirects
|
|
226
|
+
to the current login, Loom records the old to new owner alias automatically. A
|
|
227
|
+
hard `404` with no alias is fail-closed and asks the operator to add one.
|
|
228
|
+
Required PAT scope: public repository read plus `GET /user` (any valid token);
|
|
229
|
+
`me` cannot be resolved anonymously.
|
|
230
|
+
|
|
231
|
+
Explicit `repos` entries are added after discovery and are not subject to the
|
|
232
|
+
policy. Results are de-duplicated case-insensitively and sorted, so the same
|
|
233
|
+
GitHub state produces the same record. A discovery or API failure aborts the
|
|
234
|
+
sync before commit; a partial page is never interpreted as a deletion.
|
|
235
|
+
|
|
236
|
+
## Site consumption
|
|
237
|
+
|
|
238
|
+
The reference deployment writes the record and the typed module, then tells the
|
|
239
|
+
site to redeploy. The site must:
|
|
240
|
+
|
|
241
|
+
1. validate `schema === "loom/site@1"` and `complete === true`;
|
|
242
|
+
2. use `snapshot` or the record digest as its cache and deploy key;
|
|
243
|
+
3. sort nothing itself, because `projects` and `releases` are already ordered;
|
|
244
|
+
4. treat an unknown `@2` schema as "upgrade the site", never as a best-effort
|
|
245
|
+
parse of `@1`.
|
|
246
|
+
|
|
247
|
+
A minimal consumer:
|
|
248
|
+
|
|
249
|
+
```ts
|
|
250
|
+
const response = await fetch(process.env.LOOM_SITE_RECORD_URL!);
|
|
251
|
+
const record = (await response.json()) as import("@sifr-dev/loom/browser").SiteRecord;
|
|
252
|
+
|
|
253
|
+
if (record.schema !== "loom/site@1") throw new Error(`unsupported ${record.schema}`);
|
|
254
|
+
if (!record.complete) throw new Error("refusing to deploy an incomplete record");
|
|
255
|
+
|
|
256
|
+
const projects = record.projects.filter((project) => !project.archived);
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
When the site builds the record itself, `@sifr-dev/loom/browser` runs the same
|
|
260
|
+
read in a page, a worker, or an edge function, without a filesystem or a Node
|
|
261
|
+
builtin:
|
|
262
|
+
|
|
263
|
+
```ts
|
|
264
|
+
import { collectSite } from "@sifr-dev/loom/browser";
|
|
265
|
+
|
|
266
|
+
const record = await collectSite({ repos: ["Sifr-Dev/Loom"], releases: 3 });
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
## Typed website module
|
|
270
|
+
|
|
271
|
+
For a TypeScript site, export the same data as a typed module instead of JSON:
|
|
272
|
+
|
|
273
|
+
```bash
|
|
274
|
+
loom export --format ts --out src/generated/projects.ts
|
|
275
|
+
loom export --format ts --out src/generated/projects.ts --check # exit 7 when stale
|
|
276
|
+
|
|
277
|
+
# A deployed site can use the self-contained mode and skip the SDK install:
|
|
278
|
+
loom export --format ts --package none --out src/generated/projects.ts
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
`--package none` emits `SiteProject` and `SiteRecord` (and their nested types)
|
|
282
|
+
inside the generated file instead of importing `@sifr-dev/loom`, so the site can
|
|
283
|
+
consume the artifact without the SDK in its dependency tree. The default mode
|
|
284
|
+
imports the package types for SDK consumers. Both modes are deterministic and
|
|
285
|
+
supported by `--check`.
|
|
286
|
+
|
|
287
|
+
The module is deterministic and self-describing:
|
|
288
|
+
|
|
289
|
+
```ts
|
|
290
|
+
export const SNAPSHOT = "sha256:...";
|
|
291
|
+
export const COMPLETE = true;
|
|
292
|
+
export type ProjectId = "sifr-dev/loom" | "sifr-dev/stele";
|
|
293
|
+
export const PROJECTS: readonly SiteProject[] = []; // generic, sorted by id
|
|
294
|
+
export const CURATED: Partial<Record<ProjectId, CuratedProject>> = {};
|
|
295
|
+
export function enrich(curated = CURATED): EnrichedProject[];
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
`PROJECTS` carries only generic discovered data. `CURATED` is optional
|
|
299
|
+
enrichment keyed by the canonical lowercase project id; pass
|
|
300
|
+
`--curated curated.json` to bake a site-owned enrichment file into the module.
|
|
301
|
+
A newly discovered repository appears in `PROJECTS` on the next export with no
|
|
302
|
+
site source edit. The site overlays enrichment by id and falls back to a generic
|
|
303
|
+
card.
|
|
304
|
+
|
|
305
|
+
`loom export --check` returns exit `7` when either the JSON record or the typed
|
|
306
|
+
module differs from disk, so CI can gate the redeploy on the generated artifact.
|
|
307
|
+
|
|
308
|
+
## Versioning policy
|
|
309
|
+
|
|
310
|
+
- Additive optional fields are allowed within `@1`.
|
|
311
|
+
- Renaming, removing, or changing the meaning of a field requires `@2`.
|
|
312
|
+
- `loom migrate` upgrades the on-disk store; it never guesses a future schema.
|
|
313
|
+
- The record is content-addressed, so a consumer can compare byte for byte
|
|
314
|
+
before deploying.
|
|
315
|
+
- The 1.0.0 release freezes the exported names and the `loom/site@1` shape.
|
|
316
|
+
|
|
317
|
+
The deployment path that publishes the record and dispatches the site is
|
|
318
|
+
described in [DEPLOYMENT.md](DEPLOYMENT.md).
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# Verification
|
|
2
|
+
|
|
3
|
+
**English** | [العربية](ar/VERIFICATION.md)
|
|
4
|
+
|
|
5
|
+
Run these from a checkout after `bun install`. They need no token and no
|
|
6
|
+
network: every GitHub response is a recorded fixture.
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
bun run typecheck # tsc --noEmit, strict and noUncheckedIndexedAccess
|
|
10
|
+
bun test # 244 tests, 27 files
|
|
11
|
+
bun run build # dist/index.js, dist/browser.js, dist/cli.js, dist/types
|
|
12
|
+
bun run demo:determinism
|
|
13
|
+
bun run bench # conditional-request and deploy measurements
|
|
14
|
+
bun run verify # typecheck, test, build, fixture sync, determinism
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Test suite
|
|
18
|
+
|
|
19
|
+
```console
|
|
20
|
+
$ bun test
|
|
21
|
+
bun test v1.4.5 (a7733435c)
|
|
22
|
+
|
|
23
|
+
244 pass
|
|
24
|
+
0 fail
|
|
25
|
+
Ran 244 tests across 27 files. [2.78s]
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
The suite covers:
|
|
29
|
+
|
|
30
|
+
- canonical JSON and digest stability across key order and process restarts;
|
|
31
|
+
- ETag replay, pagination, page-loop refusal, `5xx` retry with jitter, `429`
|
|
32
|
+
`Retry-After` as seconds and as an HTTP date, proactive rate-limit budget, an
|
|
33
|
+
exhausted primary limit, transport retries, and cancellation;
|
|
34
|
+
- the public-repository guard, paginated owner discovery, the
|
|
35
|
+
private/archived/fork/include/exclude policy, a new repository appearing, and
|
|
36
|
+
a repository disappearing;
|
|
37
|
+
- content-addressed dedupe, atomic writes, tamper detection, a missing object,
|
|
38
|
+
secret refusal, and deterministic repeat syncs;
|
|
39
|
+
- diff add, update, remove, and rename aliasing, including releases and alias
|
|
40
|
+
chains;
|
|
41
|
+
- webhook signatures (valid, invalid, sha1, malformed), signed timestamps,
|
|
42
|
+
replay, delivery dedupe across restarts, and trigger redaction;
|
|
43
|
+
- queue ordering, dedupe, backpressure, outbox crash recovery, cache and outbox
|
|
44
|
+
quarantine, lock contention, migration, doctor, and export determinism;
|
|
45
|
+
- real exports against `schema/site@1.json`, a browser build of the data entry,
|
|
46
|
+
a scan of its module graph for environment-specific APIs, a 25-seed order
|
|
47
|
+
fuzz, a 50-cycle soak, and the CLI exit codes.
|
|
48
|
+
|
|
49
|
+
## Offline sync and store check
|
|
50
|
+
|
|
51
|
+
```console
|
|
52
|
+
$ bun src/cli.ts sync --config fixtures/demo.config.json --fixture fixtures/github --store .loom-doc
|
|
53
|
+
loom sync: created sha256:8aa70586ead8f545f40b88c1c50edfcda4684ba37cc2080da672a1fad0fd74ad (2 repos, 4 releases, 0 not-modified, 23ms)
|
|
54
|
+
added head:sifr-dev/loom
|
|
55
|
+
added head:sifr-dev/stele
|
|
56
|
+
added release:sifr-dev/loom@v0.1.0
|
|
57
|
+
added release:sifr-dev/stele@v0.1.0
|
|
58
|
+
added release:sifr-dev/stele@v0.2.0
|
|
59
|
+
added release:sifr-dev/stele@v0.3.0-rc.1
|
|
60
|
+
added repo:sifr-dev/loom
|
|
61
|
+
added repo:sifr-dev/stele
|
|
62
|
+
|
|
63
|
+
$ bun src/cli.ts sync --config fixtures/demo.config.json --fixture fixtures/github --store .loom-doc
|
|
64
|
+
loom sync: unchanged sha256:8aa70586ead8f545f40b88c1c50edfcda4684ba37cc2080da672a1fad0fd74ad (2 repos, 4 releases, 8 not-modified, 13ms)
|
|
65
|
+
|
|
66
|
+
$ bun src/cli.ts export --store .loom-doc --out site.json
|
|
67
|
+
loom export: wrote site.json from sha256:8aa70586ead8f545f40b88c1c50edfcda4684ba37cc2080da672a1fad0fd74ad (sha256:f28846551d82d7357cae43572328b2d82c6681910a44c252b5ba5a033f36fee2)
|
|
68
|
+
|
|
69
|
+
$ bun src/cli.ts verify --store .loom-doc
|
|
70
|
+
loom verify: ok (1 objects, 20 checks)
|
|
71
|
+
ok manifest-present - found
|
|
72
|
+
ok manifest-schema - schema=loom/manifest@1
|
|
73
|
+
ok manifest-snapshot-id - sha256:8aa70586ead8f545f40b88c1c50edfcda4684ba37cc2080da672a1fad0fd74ad
|
|
74
|
+
ok snapshot-present - found
|
|
75
|
+
ok snapshot-bytes - bytes hash to their name
|
|
76
|
+
ok snapshot-json - parses
|
|
77
|
+
ok snapshot-canonical - byte-identical to canonical form
|
|
78
|
+
ok snapshot-schema - schema=loom/snapshot@1
|
|
79
|
+
ok snapshot-id - sha256:8aa70586ead8f545f40b88c1c50edfcda4684ba37cc2080da672a1fad0fd74ad
|
|
80
|
+
ok manifest-stats - expected {"repos":2,"releases":4,"languages":2,"errors":0,"readmes":0,"branches":0,"commitComments":0,"issueComments":0,"workflows":0}
|
|
81
|
+
ok snapshot-order - repositories sorted by id
|
|
82
|
+
ok snapshot-releases - releases are non-draft and newest first
|
|
83
|
+
ok no-secrets - no credential patterns
|
|
84
|
+
ok objects-addressed - 1 objects verified
|
|
85
|
+
ok objects-secret-free - clean
|
|
86
|
+
ok store-version - store v1
|
|
87
|
+
ok outbox-valid - absent
|
|
88
|
+
ok outbox-target - absent
|
|
89
|
+
ok site-record - absent
|
|
90
|
+
ok site-record-snapshot - absent
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
The second sync reports `8 not-modified`: every conditional request returned
|
|
94
|
+
`304` and the snapshot id did not change.
|
|
95
|
+
|
|
96
|
+
## Determinism
|
|
97
|
+
|
|
98
|
+
```console
|
|
99
|
+
$ bun run demo:determinism
|
|
100
|
+
loom determinism: ok sha256:8aa70586ead8f545f40b88c1c50edfcda4684ba37cc2080da672a1fad0fd74ad (2 repos, 4 releases)
|
|
101
|
+
store A: created, then unchanged (8 conditional 304s)
|
|
102
|
+
store B: created independently, 1 identical objects in 1 prefix dir(s)
|
|
103
|
+
verify: A 20 checks ok, B 20 checks ok
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Store A and store B are independent directories. Both read the same fixture and
|
|
107
|
+
produce one object with the same name and the same bytes.
|
|
108
|
+
|
|
109
|
+
## Measured sync cost
|
|
110
|
+
|
|
111
|
+
```console
|
|
112
|
+
$ bun run bench
|
|
113
|
+
{"schema":"loom/bench@1","cycles":100,"cold":{"ms":28.69,"status":"created","requests":8,"notModified":0},"warm":{"totalMs":94.87,"perPollMs":0.95,"requests":800,"notModified":800,"commits":0,"triggerCalls":1,"conditionalHitRate":1},"maxRssKb":76640}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
The warm phase is 100 polls of unchanged state: 800 conditional requests, 800
|
|
117
|
+
`304`s, zero commits, and one trigger call for the single change that opened the
|
|
118
|
+
phase. The per-poll cost is the first request plus the cached replay, not a full
|
|
119
|
+
fetch.
|
|
120
|
+
|
|
121
|
+
## What the checks do not prove
|
|
122
|
+
|
|
123
|
+
- The fixtures model GitHub. They cannot reproduce every edge case in the live
|
|
124
|
+
API.
|
|
125
|
+
- A snapshot is content-addressed, not signed. `loom verify` detects corruption,
|
|
126
|
+
not a malicious writer with access to the store.
|
|
127
|
+
- Secret scanning is pattern-based. It catches the shapes listed in the SDK
|
|
128
|
+
guide, not every possible secret.
|
|
129
|
+
- The store lock is local to one host. Two hosts writing the same directory are
|
|
130
|
+
outside the guarantee.
|
package/package.json
CHANGED
|
@@ -1,6 +1,85 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sifr-dev/loom",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "TypeScript SDK that turns public GitHub repositories into deterministic snapshots and typed portfolio-site data.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "Mohamed Salahy <264395179+mohamedsalahi@users.noreply.github.com>",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/Sifr-Dev/Loom.git"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/Sifr-Dev/Loom",
|
|
13
|
+
"keywords": [
|
|
14
|
+
"github",
|
|
15
|
+
"portfolio",
|
|
16
|
+
"sdk",
|
|
17
|
+
"snapshot",
|
|
18
|
+
"webhook",
|
|
19
|
+
"etag",
|
|
20
|
+
"typescript",
|
|
21
|
+
"bun",
|
|
22
|
+
"browser"
|
|
23
|
+
],
|
|
24
|
+
"main": "./dist/index.js",
|
|
25
|
+
"module": "./dist/index.js",
|
|
26
|
+
"types": "./dist/types/index.d.ts",
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"types": "./dist/types/index.d.ts",
|
|
30
|
+
"import": "./dist/index.js",
|
|
31
|
+
"default": "./dist/index.js"
|
|
32
|
+
},
|
|
33
|
+
"./browser": {
|
|
34
|
+
"types": "./dist/types/browser.d.ts",
|
|
35
|
+
"import": "./dist/browser.js",
|
|
36
|
+
"default": "./dist/browser.js"
|
|
37
|
+
},
|
|
38
|
+
"./schema/site@1.json": "./schema/site@1.json",
|
|
39
|
+
"./package.json": "./package.json"
|
|
40
|
+
},
|
|
41
|
+
"bin": {
|
|
42
|
+
"loom": "./dist/cli.js"
|
|
43
|
+
},
|
|
44
|
+
"files": [
|
|
45
|
+
"dist",
|
|
46
|
+
"schema",
|
|
47
|
+
"docs/SDK.md",
|
|
48
|
+
"docs/SITE_CONTRACT.md",
|
|
49
|
+
"docs/CONFIGURATION.md",
|
|
50
|
+
"docs/VERIFICATION.md",
|
|
51
|
+
"docs/DEPLOYMENT.md",
|
|
52
|
+
"README.md",
|
|
53
|
+
"README.ar.md",
|
|
54
|
+
"LICENSE",
|
|
55
|
+
"CHANGELOG.md"
|
|
56
|
+
],
|
|
57
|
+
"publishConfig": {
|
|
58
|
+
"access": "public"
|
|
59
|
+
},
|
|
60
|
+
"engines": {
|
|
61
|
+
"bun": ">=1.1",
|
|
62
|
+
"node": ">=20"
|
|
63
|
+
},
|
|
64
|
+
"scripts": {
|
|
65
|
+
"loom": "bun src/cli.ts",
|
|
66
|
+
"typecheck": "tsc --noEmit",
|
|
67
|
+
"test": "bun test",
|
|
68
|
+
"build": "bun run build:types && bun build src/index.ts --target bun --outdir dist --format esm && bun build src/browser.ts --target browser --outdir dist --format esm && bun build src/cli.ts --target bun --outdir dist --minify",
|
|
69
|
+
"build:types": "tsc -p tsconfig.build.json && bun scripts/rewrite-declarations.ts",
|
|
70
|
+
"bench": "bun scripts/benchmark.ts",
|
|
71
|
+
"verify": "bun run typecheck && bun run test && bun run build && bun run demo:sync && bun run demo:determinism",
|
|
72
|
+
"prepack": "bun run typecheck && bun test && bun run build",
|
|
73
|
+
"demo:sync": "bun src/cli.ts sync --config fixtures/demo.config.json --fixture fixtures/github --store .loom-demo --json",
|
|
74
|
+
"demo:determinism": "bun scripts/determinism.ts",
|
|
75
|
+
"demo:serve": "bun src/cli.ts serve --config fixtures/demo.config.json --fixture fixtures/github --store .loom-demo --port 8787 --secret-env LOOM_WEBHOOK_SECRET"
|
|
76
|
+
},
|
|
77
|
+
"devDependencies": {
|
|
78
|
+
"@types/bun": "^1.4.5",
|
|
79
|
+
"typescript": "^7.0.2"
|
|
80
|
+
},
|
|
81
|
+
"bugs": {
|
|
82
|
+
"url": "https://github.com/Sifr-Dev/Loom/issues"
|
|
83
|
+
},
|
|
84
|
+
"sideEffects": false
|
|
85
|
+
}
|