@polycode-projects/the-mechanical-code-talker 2.3.0 → 2.5.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/README.md +127 -28
- package/ROADMAP.md +3 -2
- package/bin/tmct.mjs +17 -90
- package/corpus/LICENSES.json +19 -4
- package/corpus/README.md +48 -0
- package/corpus/generated/README.md +24 -9
- package/corpus/generated/ace-surface-variants.jsonl +4 -1
- package/corpus/generated/manifest.json +4 -4
- package/corpus/prose/manifest.json +512 -0
- package/corpus/prose/sqlite/LICENSE-NOTICE +53 -0
- package/corpus/prose/sqlite/arch.txt +213 -0
- package/corpus/prose/sqlite/atomiccommit.txt +1117 -0
- package/corpus/prose/sqlite/faq.txt +473 -0
- package/corpus/prose/sqlite/fileformat.txt +1589 -0
- package/corpus/prose/sqlite/lang_createtable.txt +1339 -0
- package/corpus/prose/sqlite/lang_insert.txt +580 -0
- package/corpus/prose/sqlite/lang_select.txt +3293 -0
- package/corpus/prose/sqlite/optoverview.txt +908 -0
- package/corpus/prose/sqlite/queryplanner.txt +447 -0
- package/corpus/prose/sqlite/transactional.txt +41 -0
- package/corpus/prose/sqlite/wal.txt +567 -0
- package/corpus/prose/sqlite/whentouse.txt +300 -0
- package/corpus/prose/wikipedia/Apple.txt +4 -0
- package/corpus/prose/wikipedia/Attempto_Controlled_English.txt +169 -0
- package/corpus/prose/wikipedia/Automated_planning_and_scheduling.txt +67 -0
- package/corpus/prose/wikipedia/Bee.txt +7 -0
- package/corpus/prose/wikipedia/Bird.txt +8 -0
- package/corpus/prose/wikipedia/Bone.txt +4 -0
- package/corpus/prose/wikipedia/Book.txt +7 -0
- package/corpus/prose/wikipedia/Bread.txt +6 -0
- package/corpus/prose/wikipedia/Butterfly.txt +6 -0
- package/corpus/prose/wikipedia/Car.txt +1 -0
- package/corpus/prose/wikipedia/Cat.txt +1 -0
- package/corpus/prose/wikipedia/Child.txt +3 -0
- package/corpus/prose/wikipedia/City.txt +2 -0
- package/corpus/prose/wikipedia/Clock.txt +2 -0
- package/corpus/prose/wikipedia/Cooking.txt +1 -0
- package/corpus/prose/wikipedia/Description_logic.txt +660 -0
- package/corpus/prose/wikipedia/Doctor.txt +6 -0
- package/corpus/prose/wikipedia/Dog.txt +4 -0
- package/corpus/prose/wikipedia/Eagle.txt +4 -0
- package/corpus/prose/wikipedia/Emotion.txt +9 -0
- package/corpus/prose/wikipedia/Eye.txt +5 -0
- package/corpus/prose/wikipedia/Family.txt +3 -0
- package/corpus/prose/wikipedia/Farm.txt +4 -0
- package/corpus/prose/wikipedia/Fear.txt +4 -0
- package/corpus/prose/wikipedia/First-order_logic.txt +1518 -0
- package/corpus/prose/wikipedia/Fish.txt +10 -0
- package/corpus/prose/wikipedia/Flower.txt +3 -0
- package/corpus/prose/wikipedia/Food.txt +10 -0
- package/corpus/prose/wikipedia/Grass.txt +9 -0
- package/corpus/prose/wikipedia/Hand.txt +2 -0
- package/corpus/prose/wikipedia/Happiness.txt +3 -0
- package/corpus/prose/wikipedia/Heart.txt +4 -0
- package/corpus/prose/wikipedia/Horse.txt +4 -0
- package/corpus/prose/wikipedia/House.txt +6 -0
- package/corpus/prose/wikipedia/Human.txt +4 -0
- package/corpus/prose/wikipedia/Insect.txt +6 -0
- package/corpus/prose/wikipedia/Interactive_fiction.txt +112 -0
- package/corpus/prose/wikipedia/Knowledge.txt +5 -0
- package/corpus/prose/wikipedia/Knowledge_representation_and_reasoning.txt +87 -0
- package/corpus/prose/wikipedia/LICENSE-NOTICE +94 -0
- package/corpus/prose/wikipedia/Language.txt +10 -0
- package/corpus/prose/wikipedia/Learning.txt +4 -0
- package/corpus/prose/wikipedia/Mammal.txt +3 -0
- package/corpus/prose/wikipedia/Memory.txt +5 -0
- package/corpus/prose/wikipedia/Milk.txt +1 -0
- package/corpus/prose/wikipedia/Mountain.txt +1 -0
- package/corpus/prose/wikipedia/Natural_language_processing.txt +211 -0
- package/corpus/prose/wikipedia/Ostrich.txt +2 -0
- package/corpus/prose/wikipedia/Owl.txt +2 -0
- package/corpus/prose/wikipedia/Penguin.txt +2 -0
- package/corpus/prose/wikipedia/Plant.txt +5 -0
- package/corpus/prose/wikipedia/Rain.txt +1 -0
- package/corpus/prose/wikipedia/Resource_Description_Framework.txt +184 -0
- package/corpus/prose/wikipedia/River.txt +1 -0
- package/corpus/prose/wikipedia/School.txt +8 -0
- package/corpus/prose/wikipedia/Sea.txt +1 -0
- package/corpus/prose/wikipedia/Semantic_Web.txt +114 -0
- package/corpus/prose/wikipedia/Semantic_reasoner.txt +29 -0
- package/corpus/prose/wikipedia/Snow.txt +5 -0
- package/corpus/prose/wikipedia/Sun.txt +5 -0
- package/corpus/prose/wikipedia/Teacher.txt +4 -0
- package/corpus/prose/wikipedia/Team.txt +3 -0
- package/corpus/prose/wikipedia/Text-based_game.txt +17 -0
- package/corpus/prose/wikipedia/Tool.txt +4 -0
- package/corpus/prose/wikipedia/Tree.txt +7 -0
- package/corpus/prose/wikipedia/Weather.txt +4 -0
- package/corpus/prose/wikipedia/Web_Ontology_Language.txt +133 -0
- package/corpus/prose/wikipedia/Wind.txt +8 -0
- package/corpus/prose/wikipedia/Writing.txt +5 -0
- package/corpus/seon/README.md +1 -0
- package/corpus/tier2/generate.mjs +18 -18
- package/corpus/tier2/manifest.json +3 -3
- package/data/games/hanoi-3.txt +8 -2
- package/package.json +24 -5
- package/src/adapters/corpus-lanes.mjs +13 -0
- package/src/adapters/graph-build.mjs +5 -7
- package/src/adapters/import-closure.mjs +28 -0
- package/src/adapters/memory/blocks.mjs +5 -4
- package/src/adapters/memory/core.mjs +78 -5
- package/src/adapters/memory/shacl.mjs +12 -0
- package/src/adapters/providers/graph-service.mjs +12 -5
- package/src/adapters/tracked-files.mjs +17 -0
- package/src/domain/ask-vocab.mjs +2 -0
- package/src/domain/ask.mjs +225 -13
- package/src/domain/cli-verbs.mjs +201 -0
- package/src/domain/codegraph.mjs +142 -56
- package/src/domain/completions/graph-adapter.mjs +1 -1
- package/src/domain/completions/group.mjs +3 -17
- package/src/domain/completions/infer.mjs +4 -13
- package/src/domain/completions/rank.mjs +6 -19
- package/src/domain/grammar/lexicon-core.json +1 -1
- package/src/domain/hash.mjs +36 -13
- package/src/domain/interpret/fuzzy.mjs +7 -2
- package/src/domain/interpret/normalize.mjs +9 -0
- package/src/domain/interpret/strategies/keywords.mjs +19 -9
- package/src/domain/memory/capability.mjs +22 -3
- package/src/domain/memory/touched-facts.mjs +17 -0
- package/src/domain/module-paths.mjs +9 -0
- package/src/domain/persona/tiers.mjs +1 -1
- package/src/domain/planning.mjs +37 -0
- package/src/domain/prose.mjs +10 -2
- package/src/domain/relative-specifiers.mjs +12 -0
- package/src/domain/router/registry.mjs +3 -2
- package/src/domain/router/results.mjs +5 -18
- package/src/domain/seeded-random.mjs +33 -0
- package/src/domain/syllogise.mjs +10 -7
- package/src/domain/text-stats.mjs +31 -0
- package/src/services/chat.mjs +720 -182
- package/src/services/extract-facts.mjs +155 -0
- package/src/services/import-file.mjs +2 -2
- package/src/services/ledger-viz.mjs +6 -1
- package/src/services/sentences.mjs +26 -0
- package/src/surfaces/web/memory-ask-browser.bundle.js +11390 -360
- package/src/tools/graph-load.mjs +7 -1
- package/src/tools/readme-docs.mjs +113 -0
- package/src/tools/schema-docs.mjs +2 -2
- package/corpus/namenet/generate.mjs +0 -309
- package/corpus/wordnet/generate.mjs +0 -332
- package/src/adapters/prose-tokens.mjs +0 -98
- package/src/adapters/wordnet-source.mjs +0 -70
- package/src/domain/corpus-matrix.mjs +0 -87
- package/src/domain/inflect.mjs +0 -67
- package/src/domain/licences.mjs +0 -68
- package/src/domain/markdown-links.mjs +0 -55
- package/src/domain/persona/codegen.mjs +0 -123
- package/src/domain/publish-gate.mjs +0 -41
- package/src/domain/schemaorg/turtle.mjs +0 -25
- package/src/domain/semcor/parse.mjs +0 -87
- package/src/domain/version-stamp.mjs +0 -36
- package/src/domain/wordnet/yaml.mjs +0 -133
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
Architecture of SQLite
|
|
2
|
+
Small. Fast. Reliable.
|
|
3
|
+
Choose any three.
|
|
4
|
+
Home
|
|
5
|
+
Menu
|
|
6
|
+
About
|
|
7
|
+
Documentation
|
|
8
|
+
Download
|
|
9
|
+
License
|
|
10
|
+
Support
|
|
11
|
+
Purchase
|
|
12
|
+
Search
|
|
13
|
+
About
|
|
14
|
+
Documentation
|
|
15
|
+
Download
|
|
16
|
+
Support
|
|
17
|
+
Purchase
|
|
18
|
+
Search Documentation
|
|
19
|
+
Search Changelog
|
|
20
|
+
Architecture of SQLite
|
|
21
|
+
Introduction
|
|
22
|
+
This document describes the architecture of the SQLite library.
|
|
23
|
+
The information here is useful to those who want to understand or
|
|
24
|
+
modify the inner workings of SQLite.
|
|
25
|
+
Interface
|
|
26
|
+
SQL Command
|
|
27
|
+
Processor
|
|
28
|
+
Virtual Machine
|
|
29
|
+
B-Tree
|
|
30
|
+
Pager
|
|
31
|
+
OS Interface
|
|
32
|
+
Tokenizer
|
|
33
|
+
Parser
|
|
34
|
+
Code
|
|
35
|
+
Generator
|
|
36
|
+
Utilities
|
|
37
|
+
Test Code
|
|
38
|
+
Core
|
|
39
|
+
Backend
|
|
40
|
+
SQL Compiler
|
|
41
|
+
Accessories
|
|
42
|
+
A nearby diagram shows the main components of SQLite
|
|
43
|
+
and how they interoperate. The text below
|
|
44
|
+
explains the roles of the various components.
|
|
45
|
+
Overview
|
|
46
|
+
SQLite works by compiling SQL text into bytecode , then running
|
|
47
|
+
that bytecode using a virtual machine.
|
|
48
|
+
The sqlite3_prepare_v2() and related interfaces act as a compiler
|
|
49
|
+
for converting SQL text into bytecode. The sqlite3_stmt object is
|
|
50
|
+
a container for a single bytecode program that implements a single
|
|
51
|
+
SQL statement. The sqlite3_step() interface passes a bytecode program
|
|
52
|
+
into the virtual machine, and runs the program until it either completes,
|
|
53
|
+
or forms a row of result to be returned, or hits a fatal error, or is
|
|
54
|
+
interrupted .
|
|
55
|
+
Interface
|
|
56
|
+
Much of the C-language Interface is found in source
|
|
57
|
+
files main.c , legacy.c , and
|
|
58
|
+
vdbeapi.c
|
|
59
|
+
though some routines are
|
|
60
|
+
scattered about in other files where they can have access to data
|
|
61
|
+
structures with file scope.
|
|
62
|
+
The sqlite3_get_table() routine is implemented in table.c .
|
|
63
|
+
The sqlite3_mprintf() routine is found in printf.c .
|
|
64
|
+
The sqlite3_complete() interface is in complete.c .
|
|
65
|
+
The TCL Interface is implemented by tclsqlite.c .
|
|
66
|
+
To avoid name collisions, all external
|
|
67
|
+
symbols in the SQLite library begin with the prefix sqlite3 .
|
|
68
|
+
Those symbols that are intended for external use (in other words,
|
|
69
|
+
those symbols which form the API for SQLite) add an underscore, and
|
|
70
|
+
thus begin with sqlite3_ . Extension APIs sometimes add the
|
|
71
|
+
extension name prior to the underscore; for example:
|
|
72
|
+
sqlite3rbu_ or sqlite3session_ .
|
|
73
|
+
Tokenizer
|
|
74
|
+
When a string containing SQL statements is to be evaluated it is
|
|
75
|
+
first sent to the tokenizer.
|
|
76
|
+
The tokenizer breaks
|
|
77
|
+
the SQL text into tokens and hands those tokens
|
|
78
|
+
one by one to the parser. The tokenizer is hand-coded in
|
|
79
|
+
the file tokenize.c .
|
|
80
|
+
Note that in this design, the tokenizer calls the parser. People
|
|
81
|
+
who are familiar with YACC and BISON may be accustomed to doing things the
|
|
82
|
+
other way around — having the parser call the tokenizer. Having
|
|
83
|
+
the tokenizer call the parser is better, though, because it can be made
|
|
84
|
+
threadsafe and it runs faster.
|
|
85
|
+
Parser
|
|
86
|
+
The parser assigns meaning to tokens based on
|
|
87
|
+
their context. The parser for SQLite is generated using the
|
|
88
|
+
Lemon parser generator .
|
|
89
|
+
Lemon does the same job as YACC/BISON, but it uses
|
|
90
|
+
a different input syntax which is less error-prone.
|
|
91
|
+
Lemon also generates a parser which is reentrant and thread-safe.
|
|
92
|
+
And Lemon defines the concept of a non-terminal destructor so
|
|
93
|
+
that it does not leak memory when syntax errors are encountered.
|
|
94
|
+
The grammar file that drives Lemon and that defines the SQL language
|
|
95
|
+
that SQLite understands is found in parse.y .
|
|
96
|
+
Because
|
|
97
|
+
Lemon is a program not normally found on development machines, the
|
|
98
|
+
complete source code to Lemon (just one C file) is included in the
|
|
99
|
+
SQLite distribution in the "tool" subdirectory.
|
|
100
|
+
Code Generator
|
|
101
|
+
After the parser assembles tokens into a parse tree,
|
|
102
|
+
the code generator runs to analyze the parse tree and generate
|
|
103
|
+
bytecode that performs the work of the SQL statement.
|
|
104
|
+
The prepared statement object is a container for this bytecode.
|
|
105
|
+
There are many files in the code generator, including:
|
|
106
|
+
attach.c ,
|
|
107
|
+
auth.c ,
|
|
108
|
+
build.c ,
|
|
109
|
+
delete.c ,
|
|
110
|
+
expr.c ,
|
|
111
|
+
insert.c ,
|
|
112
|
+
pragma.c ,
|
|
113
|
+
select.c ,
|
|
114
|
+
trigger.c ,
|
|
115
|
+
update.c ,
|
|
116
|
+
vacuum.c ,
|
|
117
|
+
where.c ,
|
|
118
|
+
wherecode.c , and
|
|
119
|
+
whereexpr.c .
|
|
120
|
+
In these files is where most of the serious magic happens.
|
|
121
|
+
expr.c handles code generation for expressions.
|
|
122
|
+
where*.c handles code generation for WHERE clauses on
|
|
123
|
+
SELECT, UPDATE and DELETE statements. The files attach.c ,
|
|
124
|
+
delete.c , insert.c , select.c ,
|
|
125
|
+
trigger.c
|
|
126
|
+
update.c , and vacuum.c handle the code generation
|
|
127
|
+
for SQL statements with the same names. (Each of these files calls routines
|
|
128
|
+
in expr.c and where.c as necessary.) All other
|
|
129
|
+
SQL statements are coded out of build.c .
|
|
130
|
+
The auth.c file implements the functionality of
|
|
131
|
+
sqlite3_set_authorizer() .
|
|
132
|
+
The code generator, and especially the logic in where*.c
|
|
133
|
+
and in select.c , is sometimes called the
|
|
134
|
+
query planner . For any particular SQL statement, there might be
|
|
135
|
+
hundreds, thousands, or millions of different algorithms to compute
|
|
136
|
+
the answer. The query planner is an AI that strives to select the
|
|
137
|
+
best algorithm from these millions of choices.
|
|
138
|
+
Bytecode Engine
|
|
139
|
+
The bytecode program created by the code generator is run by
|
|
140
|
+
a virtual machine.
|
|
141
|
+
The virtual machine itself is entirely contained in a single
|
|
142
|
+
source file vdbe.c . The
|
|
143
|
+
vdbe.h header file defines an interface
|
|
144
|
+
between the virtual machine and the rest of the SQLite library and
|
|
145
|
+
vdbeInt.h which defines structures and interfaces that
|
|
146
|
+
are private to the virtual machine itself.
|
|
147
|
+
Various other vdbe*.c files are helpers to the virtual machine.
|
|
148
|
+
The vdbeaux.c file contains utilities used by the virtual
|
|
149
|
+
machine and interface modules used by the rest of the library to
|
|
150
|
+
construct VM programs. The vdbeapi.c file contains external
|
|
151
|
+
interfaces to the virtual machine such as the
|
|
152
|
+
sqlite3_bind_int() and sqlite3_step() . Individual values
|
|
153
|
+
(strings, integer, floating point numbers, and BLOBs) are stored
|
|
154
|
+
in an internal object named "Mem" which is implemented by
|
|
155
|
+
vdbemem.c .
|
|
156
|
+
SQLite implements SQL functions using callbacks to C-language routines.
|
|
157
|
+
Even the built-in SQL functions are implemented this way. Most of
|
|
158
|
+
the built-in SQL functions (ex: abs() , count() ,
|
|
159
|
+
substr() , and so forth) can be found in the func.c source
|
|
160
|
+
file.
|
|
161
|
+
Date and time conversion functions are found in date.c .
|
|
162
|
+
Some functions such as coalesce() and typeof() are implemented
|
|
163
|
+
as bytecode directly by the code generator.
|
|
164
|
+
B-Tree
|
|
165
|
+
An SQLite database is maintained on disk using a B-tree implementation
|
|
166
|
+
found in the btree.c source file. Separate B-trees are used for
|
|
167
|
+
each table and each index in the database. All B-trees are stored in the
|
|
168
|
+
same disk file. The file format details are stable and well-defined and
|
|
169
|
+
are guaranteed to be compatible moving forward.
|
|
170
|
+
The interface to the B-tree subsystem and the rest of the SQLite library
|
|
171
|
+
is defined by the header file btree.h .
|
|
172
|
+
Page Cache
|
|
173
|
+
The B-tree module requests information from the disk in fixed-size
|
|
174
|
+
pages. The default page_size is 4096 bytes but can be any power of
|
|
175
|
+
two between 512 and 65536 bytes.
|
|
176
|
+
The page cache is responsible for reading, writing, and
|
|
177
|
+
caching these pages.
|
|
178
|
+
The page cache also provides the rollback and atomic commit abstraction
|
|
179
|
+
and takes care of locking of the database file. The
|
|
180
|
+
B-tree driver requests particular pages from the page cache and notifies
|
|
181
|
+
the page cache when it wants to modify pages or commit or rollback
|
|
182
|
+
changes. The page cache handles all the messy details of making sure
|
|
183
|
+
the requests are handled quickly, safely, and efficiently.
|
|
184
|
+
The primary page cache implementation is in the
|
|
185
|
+
pager.c file. WAL mode logic is in the separate
|
|
186
|
+
wal.c file. In-memory caching is implemented by the
|
|
187
|
+
pcache.c and pcache1.c files.
|
|
188
|
+
The interface between the page cache subsystem
|
|
189
|
+
and the rest of SQLite is defined by the header file pager.h .
|
|
190
|
+
OS Interface
|
|
191
|
+
In order to provide portability across operating systems,
|
|
192
|
+
SQLite uses an abstract object called the VFS . Each VFS provides methods
|
|
193
|
+
for opening, reading, writing, and closing files on disk, and for other
|
|
194
|
+
OS-specific tasks such as finding the current time, or obtaining randomness
|
|
195
|
+
to initialize the built-in pseudo-random number generator.
|
|
196
|
+
SQLite currently provides VFSes for unix (in the os_unix.c
|
|
197
|
+
file) and Windows (in the os_win.c file).
|
|
198
|
+
Utilities
|
|
199
|
+
Memory allocation, caseless string comparison routines,
|
|
200
|
+
portable text-to-number conversion routines, and other utilities
|
|
201
|
+
are located in util.c .
|
|
202
|
+
Symbol tables used by the parser are maintained by hash tables found
|
|
203
|
+
in hash.c . The utf.c source file contains Unicode
|
|
204
|
+
conversion subroutines.
|
|
205
|
+
SQLite has its own private implementation of
|
|
206
|
+
printf() (with
|
|
207
|
+
some extensions) in printf.c and its own
|
|
208
|
+
pseudo-random number generator (PRNG) in random.c .
|
|
209
|
+
Test Code
|
|
210
|
+
Files in the "src/" folder of the source tree whose names begin with
|
|
211
|
+
test are for testing only and are not included in a standard
|
|
212
|
+
build of the library.
|
|
213
|
+
This page was last updated on 2025-05-31 13:08:22Z
|