@oddstate/core 0.0.0-stage → 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Oddstate contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/NOTICE.md ADDED
@@ -0,0 +1,18 @@
1
+ # Oddstate licenses
2
+
3
+ - [MIT](LICENSE) covers original source code, reproducers, code examples,
4
+ development documentation and skill instructions and scripts.
5
+ - [CC BY 4.0](licenses/CC-BY-4.0.txt) covers original educational prose in corpus
6
+ cases, their descriptive metadata and guides. Attribute this material to
7
+ Oddstate contributors and link to the [project](https://github.com/IshitRaj/oddstate).
8
+ - [CC0 1.0](licenses/CC0-1.0.txt) applies to original reusable corpus fixtures.
9
+
10
+ Core and the agent skill include corpus material alongside MIT-licensed code.
11
+ The CLI package contains MIT-licensed code and obtains corpus material from
12
+ core. Citations identify external sources. Upstream material remains subject to its
13
+ own terms.
14
+
15
+ Geist and Geist Mono retain their upstream SIL Open Font License 1.1 notices in
16
+ the website's `apps/web/src/fonts` directory. Oddstate's names and marks,
17
+ website artwork, and third-party dependencies and assets are outside the
18
+ project license grants above. Dependencies retain their own license terms.
package/README.md CHANGED
@@ -1,3 +1,103 @@
1
- # Temporary Holding Version
1
+ # Oddstate core
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ `@oddstate/core` is an ESM library that provides synchronous access to a snapshot
4
+ of the Oddstate corpus. It requires Node.js 24 or newer for Node consumers.
5
+ Build it from the repository root with `pnpm --filter @oddstate/core build`.
6
+
7
+ ```ts
8
+ import { getCase, getFixture, searchCases } from "@oddstate/core";
9
+
10
+ const results = searchCases("date UTC", { category: "dates-and-times" });
11
+ const edgeCase = getCase("date-only-utc");
12
+ const evidence = edgeCase?.verification.evidence;
13
+ const fixture = getFixture("date-only-utc", "date-inputs");
14
+ ```
15
+
16
+ ## API
17
+
18
+ | Function | Result |
19
+ | ------------------------------- | --------------------------------------------------------------- |
20
+ | `getCase(id)` | Full case metadata and `markdown`, or `undefined`. |
21
+ | `listCategories()` | Categories in registry order. |
22
+ | `listCases(filters?)` | Case summaries ordered by ID. |
23
+ | `searchCases(query, filters?)` | Case summaries in relevance order. |
24
+ | `getRelatedCases(id)` | Directly related case summaries in the declared order, or `[]`. |
25
+ | `getFixture(caseId, fixtureId)` | A fixture descriptor with its `content`, or `undefined`. |
26
+
27
+ Summaries include `id`, `title`, `summary` and `category`. Use the full case for
28
+ references, fixture descriptors, compatibility prerequisites and recorded
29
+ verification evidence. Case and fixture IDs are exact and case-sensitive. A
30
+ fixture's `file` is its original filename. JSON and text fixture contents are
31
+ strings with the original whitespace. Binary fixtures return `Uint8Array`.
32
+ Results can be modified independently of subsequent calls.
33
+
34
+ `listCases` and `searchCases` accept `category` and `nodeMajor` filters and apply
35
+ both when supplied. `nodeMajor` selects cases whose supported verification
36
+ floor is at or below the supplied major. `verification.evidence` identifies
37
+ the Node version and environment of the recorded run. A `nodeMajor` outside
38
+ the positive safe integer range throws `RangeError`. An unknown category yields
39
+ an empty list.
40
+
41
+ ## Search
42
+
43
+ Use the browser-focused entry point when you only need search.
44
+
45
+ ```ts
46
+ import { searchCases } from "@oddstate/core/search";
47
+
48
+ const results = searchCases("date UTC", { category: "dates-and-times" });
49
+ ```
50
+
51
+ This entry loads case summaries, the Node major filter and generated search
52
+ terms. Whole case records, Markdown source, verification evidence and fixture
53
+ payloads stay in the full core entry. The full entry builds its search index on
54
+ the first search.
55
+
56
+ Search first looks for every distinct query word across the case ID, title,
57
+ summary, Markdown and fixture IDs. It compares lowercase, NFC-normalised
58
+ whole words. Punctuation separates words, with code points such as `U+FFFD`
59
+ kept together. The strongest field for each word contributes 3 points for the
60
+ case ID or title, 2 for the summary, and 1 for Markdown or a fixture ID.
61
+
62
+ When no case matches exactly within the selected filters, search drops common
63
+ question and connecting words and folds simple plurals and common spellings
64
+ such as `normalization` and `normalisation`. A partial result may miss one
65
+ word if at least two words match and one appears in a case ID, title or
66
+ summary. Results are ordered by the number of matched words, then field
67
+ score, then ascending case ID. A query without searchable words or matches
68
+ returns `[]`. Search does not use fuzzy spelling correction or semantic
69
+ matching.
70
+
71
+ ## Build and package boundaries
72
+
73
+ The build uses the repository's existing loader and verifier to check every
74
+ case in the current environment before generating the JavaScript snapshots in
75
+ `dist`. The snapshots carry forward the evidence stored in case metadata.
76
+ Full core embeds Markdown, original JSON and text, and base64-encoded binary
77
+ bytes. Runtime imports stay inside the built package and work independently of
78
+ the application's directory and framework.
79
+ The library targets ES2022 and uses the standard `structuredClone` and `atob`
80
+ APIs. The package includes its own TypeScript declarations for both entry
81
+ points and has no runtime dependencies.
82
+
83
+ `pnpm --filter @oddstate/core test` builds the package, type-checks consumers
84
+ against its exported declarations, and exercises the distribution through its
85
+ package entry point. The workspace release smoke test installs the actual
86
+ tarballs in a fresh npm project and checks strict TypeScript consumers.
87
+
88
+ ## Browser bundle measurement
89
+
90
+ Build core, then run `node scripts/measure-search-bundle.mts` from the workspace
91
+ root. The script compares the full and browser entries on two seeded synthetic
92
+ corpora using the installed Webpack and SWC versions. It runs both generated
93
+ bundles without Node globals and compares their search results. To measure a
94
+ previous implementation, pass `--before-dist <path>` with its built core
95
+ directory.
96
+
97
+ | Cases | Binary bytes per case | Previous gzip bytes | Browser entry gzip bytes |
98
+ | ----: | --------------------: | ------------------: | -----------------------: |
99
+ | 3,000 | 1,024 | 3,281,129 | 91,862 |
100
+ | 1,000 | 16,384 | 17,381,848 | 33,442 |
101
+
102
+ Measurements used the pre-hardening core, Webpack 5.98.0 and Next's bundled SWC
103
+ on Node 24.22.3. They measure bundle size and result equivalence in a JS context.
@@ -0,0 +1,17 @@
1
+ import type { CaseMetadata, Category } from "./types.js";
2
+
3
+ export interface CaseSnapshot {
4
+ metadata: CaseMetadata;
5
+ markdown: string;
6
+ // Binary fixture entries contain base64. JSON and text entries contain source text.
7
+ fixtureContents: Record<string, string>;
8
+ }
9
+
10
+ export interface CorpusSnapshot {
11
+ categories: Category[];
12
+ // The loader produces global ID order, regardless of category directory order.
13
+ cases: CaseSnapshot[];
14
+ }
15
+
16
+ // The repository build script writes the JavaScript module into dist.
17
+ export const corpus: CorpusSnapshot;