@tibia.sh/tibiawiki-data 3.0.0 → 3.0.1

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 +158 -12
  2. package/index.db +0 -0
  3. package/package.json +3 -3
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
 
@@ -99,7 +101,9 @@ pnpm build-index
99
101
 
100
102
  That builds `dist/`, then `scripts/build.ts` runs the devDependency's
101
103
  `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.
104
+ writes exactly the file this package ships and exports. Every build resolves the
105
+ generator's PyPI dependencies after a 7-day cooldown, matching the one pnpm applies to npm
106
+ packages, and setting `UV_EXCLUDE_NEWER` overrides it.
103
107
 
104
108
  `build-index` needs [`uv`](https://docs.astral.sh/uv/) and network access to
105
109
  TibiaWiki. It validates the new index before replacing `index.db`, so a build that
@@ -109,21 +113,53 @@ its journal beside that. `.gitignore` excludes both, and must never exclude
109
113
  `index.db`. The `3.0.0` build took just under six minutes, most of it the generator's
110
114
  crawl.
111
115
 
116
+ `pnpm test` pins the generator too. It fails for an index whose `database_info` `version`
117
+ is anything but `9.0.0`. The major version covers only the server's enrichment tables,
118
+ and no version covers the tables tibiawiki-sql writes yet, so a rebuild with another
119
+ generator waits until that is decided.
120
+
121
+ ### Drift
122
+
123
+ `.github/workflows/drift.yml` rebuilds the index every Monday at 06:17 UTC, and when you
124
+ run it by hand from the Actions tab. It digests the committed `index.db` with the
125
+ devDependency's `tibiawiki-mcp index-digest`, runs `pnpm build-index`, digests the
126
+ rebuilt index, and runs `pnpm test` against it. The digest covers what the server reads,
127
+ and leaves out stamps that change on every run, such as `generate_time`. The run's log
128
+ shows both digests.
129
+
130
+ When the digests match, the run ends green and opens nothing. When they differ, the
131
+ content changed. The run pushes the rebuilt `index.db` to the `drift/index` branch, with
132
+ `version` set to the next patch npm does not have. It opens a pull request carrying both
133
+ digests, or updates the one already open. Merging that pull request publishes the new
134
+ patch.
135
+
136
+ - The pull request is opened with `GITHUB_TOKEN`, so its CI waits for you. Click
137
+ "Approve workflows to run" on it, then review the pull request before you merge it.
138
+ - The workflow never merges and never turns on auto-merge, so a bad day on the wiki can at
139
+ most open a pull request.
140
+ - A red run is a signal. A tripped gate, a failing test, an unreadable registry, or a
141
+ `version` on `main` that npm does not list yet each end the run red, and nothing is
142
+ pushed or opened. Find out why before the next run.
143
+ - Each run that finds a change replaces `drift/index`, so an open pull request always
144
+ carries the newest rebuild.
145
+ - GitHub turns off a schedule after 60 days without activity in a public repository, and
146
+ that stops the job without a red run. Turn it back on from the Actions tab.
147
+
112
148
  ## The devDependency on the server
113
149
 
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.
150
+ `@tibia.sh/tibiawiki-mcp` is a devDependency for three jobs: its `build-index` produces
151
+ the index, its `index-digest` tells the drift job whether a rebuild changed it, and its
152
+ `serve` validates it, in `pnpm test` here and in `pnpm smoke` against an installed copy.
117
153
 
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.
154
+ **When to bump it.** On a `0.x` version, `^0.3.0` means `>=0.3.0 <0.4.0`. Left alone,
155
+ it pins every rebuild to the 0.3 generator and its gates while the server moves on.
120
156
  Bump it whenever the server's indexer changes: `build-index`, its enrichment, its
121
157
  gates, or the schema. Write the new range by hand. This repository saves exact
122
158
  versions, so `pnpm add` records a pin instead.
123
159
 
124
160
  **The dependency cycle is intentional.** The server depends on this package, and this
125
161
  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
162
+ dev-only and never resolved at runtime. Do not "fix" it. Because the server depends on
127
163
  this package, `node_modules` here also holds a published copy of this package,
128
164
  installed as the server's dependency. The server's default index resolution could
129
165
  find that copy instead of `index.db`. So the test always passes `TIBIAWIKI_MCP_DB`
@@ -145,8 +181,16 @@ pnpm test
145
181
  2. It typechecks `src/`, `test/` and `scripts/`, the JavaScript in `scripts/`
146
182
  included. This must come after the build: the test imports this package by its own
147
183
  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.
184
+ 3. It runs every `test/*.test.ts`. `test/data.test.ts` spawns the server from the
185
+ devDependency against `index.db`, and makes a real query. The other files check the
186
+ release and drift workflows, the smoke check and the test floor, with no network.
187
+
188
+ The run fails when fewer than `MIN_TESTS` tests pass. `node --test` still exits 0 for a
189
+ file that declares no tests, for a skipped test, and for a `--test-name-pattern` that
190
+ filters tests away, one inherited through `NODE_OPTIONS` included. Without the floor, an
191
+ emptied test file would pass the gate every publish runs. Adding a test needs no change. When
192
+ you remove or skip one on purpose, lower `MIN_TESTS` in `test/min-tests.ts` in the same
193
+ commit.
150
194
 
151
195
  `prepublishOnly` runs `pnpm test` too, so publishing from the directory always builds
152
196
  `dist/` first.
@@ -173,6 +217,108 @@ installed package and it spawns the installed server, so it checks the artefact
173
217
  than this checkout. That is why the test file imports only node builtins and packages
174
218
  by name.
175
219
 
220
+ ## Releases
221
+
222
+ Merging a commit to `main` publishes its `package.json` `version` if npm does not have
223
+ that version yet. On every push to `main`, `.github/workflows/release.yml` asks npm
224
+ whether it lists that exact version. If it does, the run publishes nothing and ends
225
+ green. Every merge that leaves `version` alone ends this way. If it does not, the run
226
+ installs from the lockfile, runs `pnpm test`, and runs `npm publish`.
227
+
228
+ - The check is for existence, never a comparison with `latest`. A revert leaves
229
+ `version` below `latest`, and `npm publish` moves `latest` itself.
230
+ - A registry the check cannot read fails the run. It is never taken for a missing
231
+ version.
232
+ - The run packs the committed `index.db` and never rebuilds it, so the file published is
233
+ the file reviewed in the pull request.
234
+ - It publishes through npm trusted publishing, so no npm token exists to leak, and npm
235
+ attaches a provenance attestation for the merged commit. The trusted publisher is
236
+ registered for the file name `release.yml`, and renaming the file breaks publishing
237
+ with no warning.
238
+ - Every pull request runs the same `pnpm test`, in `.github/workflows/ci.yml`.
239
+
240
+ Nothing is tagged, so a failed publish leaves nothing stranded. When a release run fails,
241
+ follow [docs/RELEASING.md](docs/RELEASING.md).
242
+
243
+ ### Bumping the schema version
244
+
245
+ **Not yet exercised.** No schema bump has gone through this procedure.
246
+
247
+ A bump from N-1 to N cannot pass the automated gates. This package's `N.0.0` runs
248
+ `pnpm test` against its devDependency server, which has to read schema N, so it needs a
249
+ schema-N server on the registry. That server's CI needs this package's `N.0.0` on the
250
+ registry: its `^N` dependency has to install, and its `test/data-package.test.ts` and
251
+ regression sweep read the installed index. So one side is published outside its
252
+ pipeline. It is this package, because no published server installs `N.0.0`. Server
253
+ `0.1.0` does not use this package, and every later server depends on a major below N.
254
+
255
+ 1. On the server's schema-N branch, run `pnpm build`, then `npm pack`. Build this
256
+ repository's index with that tarball's `build-index`. The published server stamps the
257
+ index N-1, which this repository's tests reject. Then cross-validate: install each
258
+ repository's counterpart from the other's local tarball, and run both full test
259
+ suites. Neither repository builds `dist/` when it packs, so build before every
260
+ `npm pack`, or the tarball carries a stale `dist/` or none.
261
+ 2. The maintainer publishes this package's `N.0.0` by hand, from the validated tarball.
262
+ `npm publish` runs no lifecycle scripts for a tarball, so step 1 is the only gate it
263
+ gets. The release carries no provenance and no trusted publisher.
264
+ 3. The server's pull request sets `MCP_SCHEMA_VERSION` to N and its dependency range to
265
+ `^N`. It also adds `trustPolicyExclude` for exactly `@tibia.sh/tibiawiki-data@N.0.0`
266
+ to the server's `pnpm-workspace.yaml`, with the reason in a comment:
267
+
268
+ ```yaml
269
+ # @tibia.sh/tibiawiki-data N.0.0 was published by hand, so it has no trusted publisher.
270
+ trustPolicyExclude:
271
+ - '@tibia.sh/tibiawiki-data@N.0.0'
272
+ ```
273
+
274
+ Its CI passes against the registry, and its release PR publishes it through the
275
+ server's pipeline.
276
+ 4. This repository's pull request commits that exact `index.db`, with `SCHEMA_VERSION` N,
277
+ `version` `N.0.0`, and the devDependency moved to the new server. The new server
278
+ depends on `^N`, so the install here resolves the hand-published `N.0.0` too, and the
279
+ pull request adds the same exclude to this repository's `pnpm-workspace.yaml`. Its CI
280
+ passes, and merging it publishes nothing, because npm already has `N.0.0`.
281
+
282
+ Do not merge a data refresh here between steps 2 and 4. `main` is still on N-1 then, and
283
+ npm refuses to publish a version below `N.0.0` without a dist-tag, so its release run
284
+ fails.
285
+
286
+ Both repositories set `trustPolicy: no-downgrade`, which makes pnpm refuse a version with
287
+ weaker trust evidence than any version published before it. The release workflow publishes
288
+ with a trusted publisher, and a publish by hand has none. So once npm has a release of this
289
+ package from the release workflow, an install that resolves `N.0.0` without the exclude
290
+ fails with `ERR_PNPM_TRUST_DOWNGRADE`. pnpm reads only the first `trustPolicyExclude` entry
291
+ that names a package, so keep one entry for it.
292
+
293
+ Once npm has `N.0.1` or later from the release workflow, remove both excludes. In each
294
+ repository, remove it in the pull request that moves the lockfile off `N.0.0` with
295
+ `pnpm update @tibia.sh/tibiawiki-data --no-save`. Without `--no-save`, pnpm also raises the
296
+ server's `^N` to the new version, such as `^N.0.1`, and the server's
297
+ `test/data-package.test.ts` rejects that. Without the exclude, a lockfile still on `N.0.0`
298
+ fails the next `pnpm dedupe`.
299
+
300
+ **Verify the deadlock before relying on this.** On a scratch branch, set the server's
301
+ `MCP_SCHEMA_VERSION` to N: its `test/data-package.test.ts` and regression sweep must
302
+ fail. Here, set `SCHEMA_VERSION` and `version` to N against the schema-(N-1)
303
+ devDependency: the suite must fail before anything is published. If either suite passes,
304
+ it is not checking what this procedure assumes, so stop and find out why. Once npm has a
305
+ release of this package from the release workflow, the server's install of the
306
+ hand-published `N.0.0` fails with `ERR_PNPM_TRUST_DOWNGRADE` without the exclude from
307
+ step 3. Do not try to reproduce that against the real registry, because it takes a real
308
+ publish by hand.
309
+
310
+ This repository's half was checked on 2026-09-13 for N = 4, on a clone. `pnpm test`
311
+ fails at `the shipped index carries SCHEMA_VERSION`. With the index's
312
+ `mcp_schema_version` row set to 4 as well, it fails at the server test instead, because
313
+ the schema-3 server refuses a schema-4 index. Either way `npm publish` stops in
314
+ `prepublishOnly` and packs nothing.
315
+
316
+ The trust failure was checked on 2026-09-13 with pnpm 10.33.0, against a local stand-in
317
+ for the registry and never the real one. With `3.0.1` from a trusted publisher and `4.0.0`
318
+ published by hand after it, the server's install of `^4` and this repository's install of
319
+ a server that depends on `^4` both fail with `ERR_PNPM_TRUST_DOWNGRADE`. An exclude for
320
+ exactly `@tibia.sh/tibiawiki-data@4.0.0` lets both through.
321
+
176
322
  ## Licence
177
323
 
178
324
  `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.1",
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)",
@@ -31,14 +31,14 @@
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
37
  "prepublishOnly": "pnpm test"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@modelcontextprotocol/client": "2.0.0",
41
- "@tibia.sh/tibiawiki-mcp": "^0.1.0",
41
+ "@tibia.sh/tibiawiki-mcp": "^0.3.0",
42
42
  "@types/node": "24.13.3",
43
43
  "typescript": "7.0.2"
44
44
  }