You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 80ea606
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: AGENTS.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -101,7 +101,7 @@ Desktop tool for Minecraft modpack developers (Origin Realms Beyond) to sync mod
101
101
## mrpack export invariant (Pass 3)
102
102
- Every exported/stored file entry carries lowercase hex `sha1` (40) AND `sha512` (128) plus `fileSize` and an allowed HTTPS download, OR goes to `overrides/`, OR the export fails. Never emit a pack without passing the validator.
103
103
- Never write hashes by guessing. Hashing goes through the single streaming utility `src/main/export/hash.ts` (`hashFile`).
104
-
- Manifest schema version for the hash cache is `HASH_CACHE_SCHEMA_VERSION` (currently 2); legacy entries are migrated lazily in memory during export via `migrateManifestEntries`.
104
+
- Manifest schema version for the hash cache is `HASH_CACHE_SCHEMA_VERSION` (currently 3); legacy entries are migrated lazily in memory during export via `migrateManifestEntries` and resolved through local bytes -> stored hash (`/version_files`) -> strict CDN URL (`/version/{id}`), then cross-verified against Modrinth. `source`/`verified` are internal and never written to the pack.
105
105
- Atomic export: write to a temp file, validate, then rename. Never leave a partial `.mrpack`.
- Local file bytes available: hashes computed from bytes are ground truth. Modrinth API disagreement => `FILE_HASH_MISMATCH`.
14
-
- Stored manifest only: use stored `sha1`/`sha512`; never guess.
15
-
- Legacy entries (missing one hash): migrate lazily (local file -> hash; else Modrinth API via available hash; else fail `MISSING_FILE_HASH`).
12
+
## Source of truth and resolution chain
13
+
`migrateManifestEntries` (`src/main/export/migrate.ts`) resolves legacy/partial entries in this order:
14
+
1. Both `sha1` + `sha512` already present: use them and cross-verify below.
15
+
2. Local file bytes: exact `root/<path>`, then the filename from each download URL under `root/mods`, then the entry `filename`, then a case-insensitive exact match. Only the profile root is read; the versions-repo tree is never used for local bytes.
16
+
3. Available hash: batch `POST https://api.modrinth.com/v2/version_files` with `algorithm` matching the stored hash type (`sha1` or `sha512`). The response is an object keyed by the submitted hash.
17
+
4. Download URL: parse the strict Modrinth CDN URL (`https://cdn.modrinth.com/data/<project>/versions/<version>/<filename>`), then `GET /version/{versionId}` with `GET /project/{projectId}/version` as fallback, selecting the file whose `url` matches exactly.
18
+
5. Otherwise fail with `MISSING_FILE_HASH`, including `causes` and `pathsTried` for diagnostics.
19
+
20
+
Local bytes are ground truth. If a stored hash disagrees with local bytes the export fails with `FILE_HASH_MISMATCH` (`local-hash-mismatch`); hashes are never guessed.
21
+
22
+
## Verification
23
+
Every real Modrinth CDN URL is cross-checked:
24
+
25
+
-`sha512` batch `POST /version_files` (chunks of 25), requiring exact URL, `sha1`, `sha512`, and `fileSize` equality.
26
+
- URL not served or hash unknown: `FILE_HASH_MISMATCH` with `url-not-served-by-modrinth`.
27
+
- Size disagreement: `FILE_HASH_MISMATCH` with `size-mismatch`.
28
+
- Network failure or rate limiting: non-network-only entries are exported with `verified: false` plus a warning; network-only entries fail with `MISSING_FILE_HASH` (`modrinth-unreachable` / `modrinth-rate-limited`).
29
+
30
+
Requests send an identifying `User-Agent: ORB-Modpack-Exporter/<version>`, retry transient failures with backoff, honour `Retry-After` on 429, and abort after 30s.
31
+
32
+
`source` and `verified` are internal fields; both are stripped from `modrinth.index.json` and release snapshots.
33
+
34
+
## Hash cache
35
+
Path: `<versionsRepo>/.mrpack_hash_cache.json` (gitignored). `HASH_CACHE_SCHEMA_VERSION` is `3`; other schemas are ignored. Entries may carry `files` and `expiresAt`. A persisted `null` is treated as a miss (never a permanent negative cache). The cache is only rewritten when an entry actually changed.
16
36
17
37
## Validator
18
38
`src/main/export/validator.ts` exports `validateMrpackIndex` and `validateZipEntryNames`.
0 commit comments