Add mesh-knowledge, the knowledge base's first slice (hq issue 425, ADR 0290)
mesh/merge-gate pass: builds new: modules/mesh-knowledge, sent nowhere; no bus step; every machine composes with the change as it did without (4 of 4 compo…
mesh/repo-check pass: its merge-check.sh passed, each part in its toolchain: merge-check.sh (go), merge-check-typescript.sh (typescript)
mesh/delivery superseded: a newer head of the same pull request
mesh/merge-gate pass: builds new: modules/mesh-knowledge, sent nowhere; no bus step; every machine composes with the change as it did without (4 of 4 compo…
mesh/repo-check pass: its merge-check.sh passed, each part in its toolchain: merge-check.sh (go), merge-check-typescript.sh (typescript)
mesh/delivery superseded: a newer head of the same pull request
An agent learns what a decision says only by reading whole records. This module holds every decision record and research effort whole in a database in the store, with clauses that carry their own status and source, typed links read from both ends, and every version. It answers ask, get and holds within a stated bound, and takes a record through reserve, propose (refused on any of the 29 per-record rules), review by someone other than the author, and acceptance, on the operator's proven warrant when the record needs it. The 4 whole-set rules make the module unhealthy when they fail. The import reads hq at a commit through the records module, never overwrites, and changes nothing when run again. Prose decisions get drafted clauses that a second judgement must confirm before they are served.
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
-- The consolidated schema of the knowledge base: what a fresh database is given at once, and what every
|
||||
-- migration in migrations/ applied in order comes to (the test TestTheConsolidatedSchemaIsTheMigrationsApplied
|
||||
-- holds the two equal). Consolidated through migration 0001.
|
||||
|
||||
create table record (
|
||||
kind text not null check (kind in ('decision', 'research')),
|
||||
number integer not null check (number > 0),
|
||||
status text not null,
|
||||
topic text not null default '',
|
||||
current_version integer not null,
|
||||
pending_version integer,
|
||||
revision bigint not null default 1,
|
||||
search tsvector not null default ''::tsvector,
|
||||
primary key (kind, number)
|
||||
);
|
||||
|
||||
create index record_search on record using gin (search);
|
||||
create index record_topic on record (topic);
|
||||
|
||||
create table version (
|
||||
kind text not null,
|
||||
number integer not null,
|
||||
n integer not null check (n > 0),
|
||||
by text not null,
|
||||
at timestamptz not null,
|
||||
why text not null,
|
||||
insight boolean not null default false,
|
||||
body jsonb not null,
|
||||
primary key (kind, number, n),
|
||||
foreign key (kind, number) references record (kind, number)
|
||||
);
|
||||
|
||||
create table clause (
|
||||
kind text not null,
|
||||
number integer not null,
|
||||
n integer not null check (n > 0),
|
||||
text text not null,
|
||||
status text not null,
|
||||
source text not null,
|
||||
search tsvector not null,
|
||||
primary key (kind, number, n),
|
||||
foreign key (kind, number) references record (kind, number)
|
||||
);
|
||||
|
||||
create index clause_search on clause using gin (search);
|
||||
|
||||
create table link (
|
||||
from_kind text not null,
|
||||
from_number integer not null,
|
||||
from_clause integer not null default 0,
|
||||
kind text not null,
|
||||
to_kind text not null,
|
||||
to_number integer not null default 0,
|
||||
to_clause integer not null default 0,
|
||||
to_path text not null default '',
|
||||
body jsonb not null,
|
||||
foreign key (from_kind, from_number) references record (kind, number)
|
||||
);
|
||||
|
||||
create index link_from on link (from_kind, from_number);
|
||||
create index link_to on link (to_kind, to_number);
|
||||
|
||||
create table finding (
|
||||
rule text not null,
|
||||
records text[] not null,
|
||||
says text not null,
|
||||
at timestamptz not null
|
||||
);
|
||||
|
||||
create table told (
|
||||
topic text primary key,
|
||||
at timestamptz not null default now()
|
||||
);
|
||||
Reference in New Issue
Block a user