@tibia.sh/tibiawiki-data 3.0.0 → 3.0.2

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 (3) hide show
  1. package/README.md +183 -13
  2. package/index.db +0 -0
  3. package/package.json +5 -4
package/README.md CHANGED
@@ -28,9 +28,11 @@ major are data refreshes of the same schema.
28
28
 
29
29
  `SCHEMA_VERSION` is a literal in `src/index.ts`, and `pnpm test` asserts that it
30
30
  equals both the `package.json` major and the index's `mcp_schema_version` row.
31
- Change all three together. The literal is deliberate. Derived from `package.json`,
32
- that assertion would compare a value with itself and could never fail, and it is the
33
- only thing that stops a release from shipping under the wrong major.
31
+ Change all three together, following
32
+ [Bumping the schema version](#bumping-the-schema-version). The literal is deliberate.
33
+ Derived from `package.json`, that assertion would compare a value with itself and could
34
+ never fail, and it is the only thing that stops a release from shipping under the wrong
35
+ major.
34
36
 
35
37
  ## Why the index is committed
36
38
 
@@ -76,6 +78,7 @@ What each release was built from:
76
78
  | Release | Generator `version` | `generate_time` |
77
79
  |---|---|---|
78
80
  | `3.0.0` | `9.0.0` | `2026-09-12T19:53:53.020856+00:00` |
81
+ | `3.0.1` | `9.0.0` | `2026-09-13T07:02:58.860376+00:00` |
79
82
 
80
83
  To read them from any index:
81
84
 
@@ -99,7 +102,12 @@ pnpm build-index
99
102
 
100
103
  That builds `dist/`, then `scripts/build.ts` runs the devDependency's
101
104
  `tibiawiki-mcp build-index` with `TIBIAWIKI_MCP_DB` set to `DB_PATH`, so the build
102
- writes exactly the file this package ships and exports.
105
+ writes exactly the file this package ships and exports. From `0.3.1`, the server installs
106
+ the generator from its own requirements file, where every Python dependency is pinned and
107
+ hashed, so every build runs the same packages. Builds still set a 7-day PyPI cooldown,
108
+ matching the one pnpm applies to npm packages. It is a backstop for a server older than
109
+ `0.3.1`, which resolves those dependencies fresh on every build. You can override it with
110
+ `UV_EXCLUDE_NEWER`.
103
111
 
104
112
  `build-index` needs [`uv`](https://docs.astral.sh/uv/) and network access to
105
113
  TibiaWiki. It validates the new index before replacing `index.db`, so a build that
@@ -109,21 +117,63 @@ its journal beside that. `.gitignore` excludes both, and must never exclude
109
117
  `index.db`. The `3.0.0` build took just under six minutes, most of it the generator's
110
118
  crawl.
111
119
 
120
+ `pnpm test` pins the generator too. It fails for an index whose `database_info` `version`
121
+ is anything but `9.0.0`. The major version covers only the server's enrichment tables,
122
+ and no version covers the tables tibiawiki-sql writes.
123
+
124
+ A generator upgrade does not bump the major. A user who installed the oldest published server
125
+ that depends on `^N` gets every new `N.x` of this package, so before every publish, and in CI,
126
+ the `oldest-consumer` job installs that server package from npm together with the packed
127
+ candidate, and pages every item through its `tibia_find_items`. The gate passes only when no
128
+ page is an error, every page carries the candidate index's `generate_time`, and every item in
129
+ the index comes back exactly once. `pnpm oldest-consumer` runs the same gate, and needs network
130
+ access to npm.
131
+
132
+ The sweep covers items only, not creatures, NPCs, quests or spells. So the `9.0.0` pin in
133
+ `test/data.test.ts` stays as the explicit decision point for a generator upgrade.
134
+
135
+ ### Drift
136
+
137
+ `.github/workflows/drift.yml` rebuilds the index every Monday at 06:17 UTC, and when you
138
+ run it by hand from the Actions tab. It digests the committed `index.db` with the
139
+ devDependency's `tibiawiki-mcp index-digest`, runs `pnpm build-index`, digests the
140
+ rebuilt index, and runs `pnpm test` against it. The digest covers what the server reads,
141
+ and leaves out stamps that change on every run, such as `generate_time`. The run's log
142
+ shows both digests.
143
+
144
+ When the digests match, the run ends green and opens nothing. When they differ, the
145
+ content changed. The run pushes the rebuilt `index.db` to the `drift/index` branch, with
146
+ `version` set to the next patch npm does not have. It opens a pull request carrying both
147
+ digests, or updates the one already open. Merging that pull request publishes the new
148
+ patch.
149
+
150
+ - The pull request is opened with `GITHUB_TOKEN`, so its CI waits for you. Click
151
+ "Approve workflows to run" on it, then review the pull request before you merge it.
152
+ - The workflow never merges and never turns on auto-merge, so a bad day on the wiki can at
153
+ most open a pull request.
154
+ - A red run is a signal. A tripped gate, a failing test, an unreadable registry, or a
155
+ `version` on `main` that npm does not list yet each end the run red, and nothing is
156
+ pushed or opened. Find out why before the next run.
157
+ - Each run that finds a change replaces `drift/index`, so an open pull request always
158
+ carries the newest rebuild.
159
+ - GitHub turns off a schedule after 60 days without activity in a public repository, and
160
+ that stops the job without a red run. Turn it back on from the Actions tab.
161
+
112
162
  ## The devDependency on the server
113
163
 
114
- `@tibia.sh/tibiawiki-mcp` is a devDependency for two jobs: its `build-index` produces
115
- the index, and its `serve` validates it, in `pnpm test` here and in `pnpm smoke`
116
- against an installed copy.
164
+ `@tibia.sh/tibiawiki-mcp` is a devDependency for three jobs: its `build-index` produces
165
+ the index, its `index-digest` tells the drift job whether a rebuild changed it, and its
166
+ `serve` validates it, in `pnpm test` here and in `pnpm smoke` against an installed copy.
117
167
 
118
- **When to bump it.** On a `0.x` version, `^0.1.0` means `>=0.1.0 <0.2.0`. Left alone,
119
- it pins every rebuild to the 0.1 generator and its gates while the server moves on.
168
+ **When to bump it.** On a `0.x` version, `^0.3.0` means `>=0.3.0 <0.4.0`. Left alone,
169
+ it pins every rebuild to the 0.3 generator and its gates while the server moves on.
120
170
  Bump it whenever the server's indexer changes: `build-index`, its enrichment, its
121
171
  gates, or the schema. Write the new range by hand. This repository saves exact
122
172
  versions, so `pnpm add` records a pin instead.
123
173
 
124
174
  **The dependency cycle is intentional.** The server depends on this package, and this
125
175
  package devDepends on the server. npm and pnpm allow it because this side is
126
- dev-only and never resolved at runtime. Do not "fix" it. Once the server depends on
176
+ dev-only and never resolved at runtime. Do not "fix" it. Because the server depends on
127
177
  this package, `node_modules` here also holds a published copy of this package,
128
178
  installed as the server's dependency. The server's default index resolution could
129
179
  find that copy instead of `index.db`. So the test always passes `TIBIAWIKI_MCP_DB`
@@ -132,7 +182,7 @@ explicitly, and checks that the answer's `indexGeneratedAt` matches `index.db`.
132
182
  ## Development
133
183
 
134
184
  Requires Node 22.18 or later, because the tests run TypeScript directly, and pnpm
135
- 10.33.0, pinned in `packageManager`.
185
+ 12.4.1, pinned in `packageManager`.
136
186
 
137
187
  ```bash
138
188
  pnpm install --frozen-lockfile
@@ -145,8 +195,17 @@ pnpm test
145
195
  2. It typechecks `src/`, `test/` and `scripts/`, the JavaScript in `scripts/`
146
196
  included. This must come after the build: the test imports this package by its own
147
197
  name, so it typechecks against the built declarations, as a consumer does.
148
- 3. It runs `test/data.test.ts`. That test spawns the server from the devDependency
149
- against `index.db`, and makes a real query.
198
+ 3. It runs every `test/*.test.ts`. `test/data.test.ts` spawns the server from the
199
+ devDependency against `index.db`, and makes a real query. The other files check the
200
+ workflows, the smoke check, the oldest-consumer gate's decisions and the test floor, with
201
+ no network.
202
+
203
+ The run fails when fewer than `MIN_TESTS` tests pass. `node --test` still exits 0 for a
204
+ file that declares no tests, for a skipped test, and for a `--test-name-pattern` that
205
+ filters tests away, one inherited through `NODE_OPTIONS` included. Without the floor, an
206
+ emptied test file would pass the gate every publish runs. Adding a test needs no change. When
207
+ you remove or skip one on purpose, lower `MIN_TESTS` in `test/min-tests.ts` in the same
208
+ commit.
150
209
 
151
210
  `prepublishOnly` runs `pnpm test` too, so publishing from the directory always builds
152
211
  `dist/` first.
@@ -173,6 +232,117 @@ installed package and it spawns the installed server, so it checks the artefact
173
232
  than this checkout. That is why the test file imports only node builtins and packages
174
233
  by name.
175
234
 
235
+ ## Releases
236
+
237
+ Merging a commit to `main` publishes its `package.json` `version` if npm does not have
238
+ that version yet. On every push to `main`, `.github/workflows/release.yml` runs the
239
+ `oldest-consumer` gate from [How the index is built](#how-the-index-is-built), and its release
240
+ job waits for that gate. The release job then asks npm whether it lists that exact version. If
241
+ it does, the run publishes nothing and ends green. Every merge that leaves `version` alone,
242
+ and passes the gate, ends this way. If it does not, the run installs from the lockfile, runs
243
+ `pnpm test`, and runs `npm publish`.
244
+
245
+ - The gate runs on every push, whether the run publishes or not, so an index that breaks the
246
+ oldest published server turns the run red even when nothing is published.
247
+ - The check is for existence, never a comparison with `latest`. A revert leaves
248
+ `version` below `latest`, and `npm publish` moves `latest` itself.
249
+ - A registry the check cannot read fails the run. It is never taken for a missing
250
+ version.
251
+ - The run packs the committed `index.db` and never rebuilds it, so the file published is
252
+ the file reviewed in the pull request.
253
+ - It publishes through npm trusted publishing, so no npm token exists to leak, and npm
254
+ attaches a provenance attestation for the merged commit. The trusted publisher is
255
+ registered for the file name `release.yml`, and renaming the file breaks publishing
256
+ with no warning.
257
+ - Every pull request runs the same `pnpm test` and the same gate, in `.github/workflows/ci.yml`.
258
+
259
+ Nothing is tagged, so a failed publish leaves nothing stranded. When a release run fails,
260
+ follow [docs/RELEASING.md](docs/RELEASING.md).
261
+
262
+ ### Bumping the schema version
263
+
264
+ **Not yet exercised.** No schema bump has gone through this procedure.
265
+
266
+ A bump from N-1 to N cannot pass the automated gates. This package's `N.0.0` runs
267
+ `pnpm test` against its devDependency server, which has to read schema N, so it needs a
268
+ schema-N server on the registry. That server's CI needs this package's `N.0.0` on the
269
+ registry: its `^N` dependency has to install, and its `test/data-package.test.ts` and
270
+ regression sweep read the installed index. So one side is published outside its
271
+ pipeline. It is this package, because no published server installs `N.0.0`. Server
272
+ `0.1.0` does not use this package, and every later server depends on a major below N.
273
+
274
+ 1. On the server's schema-N branch, run `pnpm build`, then `npm pack`. Build this
275
+ repository's index with that tarball's `build-index`. The published server stamps the
276
+ index N-1, which this repository's tests reject. Then cross-validate: install each
277
+ repository's counterpart from the other's local tarball, and run both full test
278
+ suites. Neither repository builds `dist/` when it packs, so build before every
279
+ `npm pack`, or the tarball carries a stale `dist/` or none.
280
+ 2. The maintainer publishes this package's `N.0.0` by hand, from the validated tarball.
281
+ `npm publish` runs no lifecycle scripts for a tarball, so step 1 is the only gate it
282
+ gets. The release carries no provenance and no trusted publisher.
283
+ 3. The server's pull request sets `MCP_SCHEMA_VERSION` to N and its dependency range to
284
+ `^N`. It also adds `trustPolicyExclude` for exactly `@tibia.sh/tibiawiki-data@N.0.0`
285
+ to the server's `pnpm-workspace.yaml`, with the reason in a comment:
286
+
287
+ ```yaml
288
+ # @tibia.sh/tibiawiki-data N.0.0 was published by hand, so it has no trusted publisher.
289
+ trustPolicyExclude:
290
+ - '@tibia.sh/tibiawiki-data@N.0.0'
291
+ ```
292
+
293
+ Its CI passes against the registry, and its release PR publishes it through the
294
+ server's pipeline.
295
+ 4. This repository's pull request commits that exact `index.db`, with `SCHEMA_VERSION` N,
296
+ `version` `N.0.0`, and the devDependency moved to the new server. The new server
297
+ depends on `^N`, so the install here resolves the hand-published `N.0.0` too, and the
298
+ pull request adds the same exclude to this repository's `pnpm-workspace.yaml`. Its CI
299
+ passes, and merging it publishes nothing, because npm already has `N.0.0`.
300
+
301
+ Do not merge a data refresh here between steps 2 and 4. `main` is still on N-1 then, and
302
+ npm refuses to publish a version below `N.0.0` without a dist-tag, so its release run
303
+ fails.
304
+
305
+ Both repositories set `trustPolicy: no-downgrade`, which makes pnpm refuse a version with
306
+ weaker trust evidence than any version published before it. The release workflow publishes
307
+ with a trusted publisher, and a publish by hand has none. So once npm has a release of this
308
+ package from the release workflow, an install that resolves `N.0.0` without the exclude
309
+ fails with `ERR_PNPM_TRUST_DOWNGRADE`. pnpm reads only the first `trustPolicyExclude` entry
310
+ that names a package, so keep one entry for it.
311
+
312
+ Once npm has `N.0.1` or later from the release workflow, remove both excludes. In each
313
+ repository, remove it in the pull request that moves the lockfile off `N.0.0` with
314
+ `pnpm update @tibia.sh/tibiawiki-data --no-save`. Without `--no-save`, pnpm also raises the
315
+ server's `^N` to the new version, such as `^N.0.1`, and the server's
316
+ `test/data-package.test.ts` rejects that. Without the exclude, a lockfile still on `N.0.0`
317
+ fails the next `pnpm dedupe`. pnpm 12.4.1 fails `update --no-save` with
318
+ `ERR_PNPM_STRICT_MIN_RELEASE_AGE_REQUIRES_SAVE` whenever `minimumReleaseAge` is set
319
+ ([pnpm#14835](https://github.com/pnpm/pnpm/issues/14835)). Until `packageManager` names a
320
+ pnpm with the fix, run `pnpm update @tibia.sh/tibiawiki-data` without `--no-save`, restore
321
+ `^N` in the server's `package.json`, then run `pnpm install`. The lockfile moves and the range
322
+ stays.
323
+
324
+ **Verify the deadlock before relying on this.** On a scratch branch, set the server's
325
+ `MCP_SCHEMA_VERSION` to N: its `test/data-package.test.ts` and regression sweep must
326
+ fail. Here, set `SCHEMA_VERSION` and `version` to N against the schema-(N-1)
327
+ devDependency: the suite must fail before anything is published. If either suite passes,
328
+ it is not checking what this procedure assumes, so stop and find out why. Once npm has a
329
+ release of this package from the release workflow, the server's install of the
330
+ hand-published `N.0.0` fails with `ERR_PNPM_TRUST_DOWNGRADE` without the exclude from
331
+ step 3. Do not try to reproduce that against the real registry, because it takes a real
332
+ publish by hand.
333
+
334
+ This repository's half was checked on 2026-09-13 for N = 4, on a clone. `pnpm test`
335
+ fails at `the shipped index carries SCHEMA_VERSION`. With the index's
336
+ `mcp_schema_version` row set to 4 as well, it fails at the server test instead, because
337
+ the schema-3 server refuses a schema-4 index. Either way `npm publish` stops in
338
+ `prepublishOnly` and packs nothing.
339
+
340
+ The trust failure was checked on 2026-09-13 with pnpm 10.33.0, against a local stand-in
341
+ for the registry and never the real one. With `3.0.1` from a trusted publisher and `4.0.0`
342
+ published by hand after it, the server's install of `^4` and this repository's install of
343
+ a server that depends on `^4` both fail with `ERR_PNPM_TRUST_DOWNGRADE`. An exclude for
344
+ exactly `@tibia.sh/tibiawiki-data@4.0.0` lets both through.
345
+
176
346
  ## Licence
177
347
 
178
348
  `index.db` is adapted from TibiaWiki (https://tibia.fandom.com), whose text is
package/index.db CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tibia.sh/tibiawiki-data",
3
- "version": "3.0.0",
3
+ "version": "3.0.2",
4
4
  "description": "The prebuilt TibiaWiki index served by @tibia.sh/tibiawiki-mcp. Its major version is the index schema version.",
5
5
  "type": "module",
6
6
  "license": "(CC-BY-SA-3.0 AND MIT)",
@@ -12,7 +12,7 @@
12
12
  "bugs": {
13
13
  "url": "https://github.com/tibia-sh/tibiawiki-data/issues"
14
14
  },
15
- "packageManager": "pnpm@10.33.0",
15
+ "packageManager": "pnpm@12.4.1",
16
16
  "exports": {
17
17
  ".": {
18
18
  "types": "./dist/index.d.ts",
@@ -31,14 +31,15 @@
31
31
  "scripts": {
32
32
  "typecheck": "tsc --noEmit",
33
33
  "build": "tsc -p tsconfig.build.json",
34
- "test": "pnpm build && pnpm typecheck && node --test test/*.test.ts",
34
+ "test": "pnpm build && pnpm typecheck && node --test --test-reporter=spec --test-reporter-destination=stdout --test-reporter=./test/min-tests.ts --test-reporter-destination=stderr test/*.test.ts",
35
35
  "build-index": "pnpm build && node scripts/build.ts",
36
36
  "smoke": "node scripts/smoke.mjs",
37
+ "oldest-consumer": "pnpm build && node scripts/oldest-consumer.ts",
37
38
  "prepublishOnly": "pnpm test"
38
39
  },
39
40
  "devDependencies": {
40
41
  "@modelcontextprotocol/client": "2.0.0",
41
- "@tibia.sh/tibiawiki-mcp": "^0.1.0",
42
+ "@tibia.sh/tibiawiki-mcp": "^0.3.0",
42
43
  "@types/node": "24.13.3",
43
44
  "typescript": "7.0.2"
44
45
  }