Repository navigation
Conversation
stemmerName(lang) gives the stemmer the text rules use for a language as 'natural:<class>' (the natural package's stemmer classes, from the same table stemmerFor reads), or 'none' for a language without one, so a stored word index can record which stemmer made its stems. Co-Authored-By: Claude <noreply@anthropic.com>
The terminology file states facts about its content; a reader now checks
them instead of accepting whatever it finds.
- meta is a closed list of keys (tx/sqlite-v2/meta.js): an unknown key, a
malformed value, or a required feature the reader does not know refuses
the file; provenance.* stays open. `requires` lists the features the
content uses; the one feature is identifier-text (identifier values are
TEXT and probed as text). A file without requires (built before this) is
accepted as before; readFileMeta is the one place that decides what such
a file may hold (no integrity facts, INTEGER identifier values, the
retired keys).
- meta integrity = {items, schema, catalog} (tx/sqlite-v2/integrity.js):
SHA-256 of sqlite_master and of the catalog tables rendered with quote().
The builder writes it when it finishes a file (finishFile, from finish()
and vacuumFile(); indexes.js <file> after a rebuild); the store checks a
file with requires at open: file length, both digests, concept and item
id ranges, the all and active set cardinalities.
- The word index records its scope (the names it holds) and the stemmer of
each language; the store uses it only when both are its own, else builds
the index in memory. The counts row is written and read little-endian.
- behaviour.* keeps only grammar. The presentation rules the other keys
carried (expansion order, lookup name, description, version algorithm,
designation uses, distinct designation texts, mixed links) are rules in
code by system (dialects.js; the grammar for mixed links), equal to the
values every existing file carries. A grammar the reader does not
implement (icd11) refuses the file.
- The builder checks the format's contracts before it finishes a file
(checkContracts) and runs the reader's meta check on what it writes.
- Unread columns removed: property.n_rows, property.target_kind,
code_system.release_date, hierarchy_meaning, case_sensitive (codes are
always matched exactly). ix.ix_key.normalForm.stats becomes
provenance.normalFormStats.
Co-Authored-By: Claude <noreply@anthropic.com>
Unknown required features and meta keys refused; retired keys refused in a file with requires and ignored in one without; each integrity check at open tripping on a changed copy; identifier probes on mixed and text-only files; the little-endian counts row; the in-memory word index on a stemmer or scope mismatch; the builder's contract checks; grammar icd11 refused. Co-Authored-By: Claude <noreply@anthropic.com>
…acts The format document states the strictness rule, requires and its known features, the meta key table, the integrity facts and the checks at open, the word-index facts, the contracts and which the builder checks, the remaining behaviour key with where each retired key's rule now lives, and the removed columns. Co-Authored-By: Claude <noreply@anthropic.com>
behaviour.grammar gains "cpt": codes may be written
<code>:<modifier>[:<modifier>...], the modifier rules being the grammar's.
This reader does not implement it and refuses such a file, as for icd11.
behaviour.filters is a format key again (no longer retired), in files with
and without requires: null, or the only filters the system understands as
FHIR CodeSystem.filter [{code, operator, values?}], where code is a catalog
property, inactive, or a filter the file's grammar defines. A malformed
value is refused. This reader does not apply such a list, and the generic
provider could otherwise serve a file that carries one, so it refuses the
file; the README says a reader that serves such a file must apply it.
Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The sqlite-v2 terminology file (
tx-terminology/1) states facts about terminology content. Untilnow it also carried hints about how a server should present a system (
behaviour.*keys), acceptedany unknown meta key silently, and had no way to tell a reader "you must understand X to read this
file", nor any way to notice a damaged or hand-edited file. This PR tightens the format without
changing its label (
tx-terminology/1,PRAGMA user_version = 1); every file built before it stillopens and answers exactly as before.
What changes in the format
format,requires,integrity,languages,displayContexts,moduleDependencies,edition,titles,derived-by-importer,ix.ix_word.format/.stemmers/.scope,ix.ix_order.walk.reached,behaviour.grammar,behaviour.filters) andrefuses a file with any other key, naming it.
provenance.*stays open (informational, neverread). A malformed value of a known key is refused, not ignored.
requires: a JSON list of the features beyond the base format that the file's content uses.A reader refuses a file that requires a feature it does not know. The one feature today is
identifier-text: everyidentifier.valueis TEXT, and readers probe identifiers with text.The builder writes
requires = ["identifier-text"]in every file.requires(every file built before this change) are accepted as before; for themonly, one function (
tx/sqlite-v2/meta.jsreadFileMeta) allows: no integrity facts, mixedINTEGER/TEXT identifier values with the old probe typing, the stored word index used as before,
and the retired keys (below) accepted and ignored.
meta integrity={items, schema, catalog}): the item count and SHA-256digests of
sqlite_masterand of the catalog tables (code_system,metawithout provenance,property,property_member,item_use,value_label, each row rendered with SQLite'squote()). Written by the step that finishes a file; a reader checks a file withrequiresatopen: file length =
page_count * page_size, the two digests, concept ids 1..N with the activeprefix, item ids N+1..N+M, and the cardinality of the stored all/active sets. The checks read the
catalog and a few index pages: measured at about 13 ms (50 ms cold) for the whole check on the
largest SNOMED CT edition, 1-6 ms on the others.
ix.ix_word.scope(which names the index holds:snomed,loinc,rxnorm) andix.ix_word.stemmers(the stemmer of each language, e.g.natural:PorterStemmer).A reader uses the stored index only when they match its own text search; otherwise it builds the
index in memory, as for a file without one (a stored stem from another stemmer would miss matches).
The per-concept counts row is now written and read little-endian explicitly (it was host order).
behaviour.*: two keys remain, both facts about the content.behaviour.grammar("snomed","icd11","cpt"or null) is the grammar of the codes;"cpt"means codes may be written<code>:<modifier>[:<modifier>...], with the modifier rules the reader's.behaviour.filters(null,or a list
{code, operator, values?}as FHIR CodeSystem.filter) lists the only filters the systemunderstands;
codeis a catalog property,inactive, or a filter the grammar defines. The others(
expansionOrder,lookupName,description,versionAlgorithm,designationUses,distinctDesignationTexts,lookupSkipsMixedLinks, and the alias/preferred keys) told a serverhow to present the system; those rules now live in code by system (
tx/sqlite-v2/dialects.js, andthe grammar for the SNOMED CT mixed-link rule). The values every installed file carries equal the
rules in code, so answers do not change. This server refuses, with a plain message, a file whose
grammar it does not implement (
icd11,cpt) and a file that carries a filter list (it does notapply one; a reader that serves such a file must).
property.n_rows,property.target_kind,code_system.release_date,.hierarchy_meaning,.case_sensitive(codes are always matchedexactly; the provider's
isCaseSensitive()returns true).ix.ix_key.normalForm.statsbecomesprovenance.normalFormStats.tx/sqlite-v2/README.mdand schema.sql, and thebuilder checks them before it finishes a file (
checkContracts: id ranges, one hierarchy, one listproperty, TEXT identifiers,
ix_setkey conventions and bitmap ranges, kind-4 sets without theiranchor,
ix_in/ix_by_subjectrow counts,ix_orderblock layout, the counts row length, theschema's indexes,
sqlite_stat1withoutsqlite_stat4), and runs the reader's meta check on whatit writes.
Compatibility, and what to look at
requires) open and answer as before; nothing needs rebuilding.know
requires, and probes integer-looking identifiers as INTEGER, which no longer match the TEXTvalues. There is no released reader to protect yet, which is why this is done now and under the
same format label.
key list (anything else must be
provenance.*), dropping the presentation keys in favour of rulesin code, and whether the open-time digests are wanted at all or should be a check a tool runs.
Code
tx/sqlite-v2/meta.js(new): the key list, value checks, known features, retired keys,readFileMeta.tx/sqlite-v2/integrity.js(new): the digests and the open checks, shared by the builder andthe reader.
tx/sqlite-v2/store.js: meta and integrity checks at open (unfinished: trueskips thefinished-file checks for the index builder's and importers' reads of a file mid-build);
identifier probes by
requires;wordIndexState; presentation rules fromdialects.js.tx/importers/sqlite-v2/builder.js:finishFile(contracts, integrity, meta check) at the end offinish()and invacuumFile(); text identifier values; removed columns.indexes.js: word-indexfacts, little-endian counts,
node indexes.js <file>finishes a file withrequiresagain after arebuild.
tx/library/text-match.js:stemmerName(lang), from the stemmer table.Tests
tests/tx/sqlite-v2-format-integrity.test.js(new, 25 tests): unknownrequiresand unknown keysrefused, retired keys refused with
requiresand accepted without, each of the six open checkstripping on a changed copy, identifier probes on mixed and text-only files, the little-endian counts
row, the in-memory fallback on a stemmer or scope mismatch, builder contract failures, grammars
icd11andcptrefused,behaviour.filtersaccepted (with a grammar-defined filter code) andchecked, a malformed one refused. Existing sqlite-v2 tests updated for the removed columns and text identifier values. All
tests/tx/sqlite-v2-*.test.jsandtests/tx/library-sqlite-v2.test.jspass.Rebuilding a file with the importers gives a file with
requiresand integrity facts; files builtbefore keep working unchanged.
🤖 Generated with Claude Code