- Add tools/validate.py: validates packages, and with --correction runs proposed corrections through the gate against a package without writing anything (spec/11 §11.4). The gate now refuses a proposal that fails the correction schema, rule correction.schema. - tools/load.py validates every package before loading, and with --bundle --built-from builds a scienting-bundle/1 with the FTS5 search index and bundle_meta (spec/13 §13.5). Search rows are defined per unit (sentence, cell, equation outside a sentence, figure-text) with the parent kind as context. - Roster keys carry a role, and a key with the role owner may revoke any receipt (spec/08 §8.7, spec/20); roster schema, store table and the fixture roster updated. The checker signs a trial revocation to prove the rule both ways. - A qa: receipt raises the nodes it sampled except those in its errors (spec/08 §8.2); the example paper's fidelity counts become 27 F3, 13 F2, 4 F1 and 1 F0. - The destination chooses the keyed scheme, not the text policy: hmac-team between the team's machines, hkdf-pages outside the team (spec/05 §5.8, spec/12 §12.5). - A TextQuoteSelector must repeat the anchor's plain quote and is absent for hashed or keyed anchors (spec/18 §18.3). - Add fixtures/records/suspect.json, a scienting-suspect/1 record. - Oracle: hashes are kept incrementally and checked after every correction against a full recomputation; load and write refuse unsafe manifest paths; Ed25519, HKDF and schema validation come from the cryptography and jsonschema packages; canonical JSON uses the built-in encoder with an exact RFC 8785 fallback. - The tools need Python 3.14 with cryptography and jsonschema; the py310 CI environment is dropped and the workflow runs the default only. - Resolve every [CHECK] note in the docs, READMEs and context; add CONTRIBUTING.md; every tool answers --help and refuses unknown options. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
155 lines
4.3 KiB
SQL
155 lines
4.3 KiB
SQL
-- The team store: everything a team adds to its documents.
|
|
-- Normative: spec/13-database.md. Load sql/doc.sql first.
|
|
-- Portable to SQLite 3.37+, Dolt and PostgreSQL 12+, under the same rules as sql/doc.sql.
|
|
-- License: CC0-1.0.
|
|
|
|
CREATE TABLE roster_keys (
|
|
store VARCHAR(128) NOT NULL,
|
|
id VARCHAR(128) NOT NULL,
|
|
person TEXT NOT NULL,
|
|
role VARCHAR(16) NOT NULL CHECK (role IN ('owner', 'editor', 'reader', 'guest')),
|
|
scheme VARCHAR(16) NOT NULL CHECK (scheme IN ('ed25519', 'ssh', 'gpg', 'sigstore')),
|
|
public_key TEXT NOT NULL,
|
|
purposes TEXT NOT NULL,
|
|
registered_at VARCHAR(20) NOT NULL,
|
|
revoked_at VARCHAR(20),
|
|
PRIMARY KEY (store, id)
|
|
);
|
|
|
|
CREATE TABLE projects (
|
|
project_key VARCHAR(128) NOT NULL,
|
|
store VARCHAR(128),
|
|
name TEXT NOT NULL,
|
|
description TEXT,
|
|
claims TEXT,
|
|
settings TEXT,
|
|
record TEXT NOT NULL,
|
|
PRIMARY KEY (project_key)
|
|
);
|
|
|
|
CREATE TABLE members (
|
|
project_key VARCHAR(128) NOT NULL,
|
|
person VARCHAR(256) NOT NULL,
|
|
role VARCHAR(8) NOT NULL CHECK (role IN ('owner', 'editor', 'reader', 'guest')),
|
|
signing_keys TEXT NOT NULL,
|
|
PRIMARY KEY (project_key, person)
|
|
);
|
|
|
|
CREATE TABLE project_documents (
|
|
project_key VARCHAR(128) NOT NULL,
|
|
doc_key VARCHAR(257) NOT NULL,
|
|
reason TEXT NOT NULL,
|
|
tags TEXT,
|
|
reading_status TEXT,
|
|
PRIMARY KEY (project_key, doc_key)
|
|
);
|
|
|
|
CREATE TABLE reading_paths (
|
|
project_key VARCHAR(128) NOT NULL,
|
|
id VARCHAR(128) NOT NULL,
|
|
title TEXT NOT NULL,
|
|
steps TEXT NOT NULL,
|
|
PRIMARY KEY (project_key, id)
|
|
);
|
|
|
|
CREATE TABLE layers (
|
|
id VARCHAR(256) NOT NULL,
|
|
project_key VARCHAR(128),
|
|
label TEXT NOT NULL,
|
|
purpose TEXT NOT NULL,
|
|
audience VARCHAR(8) CHECK (audience IN ('novice', 'student', 'expert', 'mixed')),
|
|
visibility VARCHAR(8) NOT NULL CHECK (visibility IN ('private', 'team', 'public')),
|
|
license TEXT NOT NULL,
|
|
record TEXT NOT NULL,
|
|
PRIMARY KEY (id)
|
|
);
|
|
|
|
CREATE TABLE annotations (
|
|
id VARCHAR(256) NOT NULL,
|
|
layer VARCHAR(256) NOT NULL,
|
|
body_kind VARCHAR(24) NOT NULL CHECK (body_kind IN ('gloss', 'claim-link', 'symbol', 'comment', 'caveat', 'question', 'exercise', 'citation-context', 'prerequisite', 'crosslink', 'translation', 'generated')),
|
|
status VARCHAR(10) NOT NULL CHECK (status IN ('proposed', 'confirmed', 'rejected', 'withdrawn')),
|
|
receipt VARCHAR(32),
|
|
creator VARCHAR(256) NOT NULL,
|
|
created VARCHAR(20) NOT NULL,
|
|
record TEXT NOT NULL,
|
|
PRIMARY KEY (id)
|
|
);
|
|
CREATE INDEX annotations_layer ON annotations (layer);
|
|
|
|
-- Derived from annotation targets, so a reader finds the annotations on a node.
|
|
CREATE TABLE annotation_targets (
|
|
annotation VARCHAR(256) NOT NULL,
|
|
ord INTEGER NOT NULL,
|
|
doc_key VARCHAR(257),
|
|
node VARCHAR(128),
|
|
target_annotation VARCHAR(256),
|
|
PRIMARY KEY (annotation, ord)
|
|
);
|
|
CREATE INDEX annotation_targets_node ON annotation_targets (doc_key, node);
|
|
|
|
CREATE TABLE datasets (
|
|
id VARCHAR(128) NOT NULL,
|
|
doc_key VARCHAR(257),
|
|
content_hash VARCHAR(64) NOT NULL,
|
|
descriptor TEXT NOT NULL,
|
|
PRIMARY KEY (id)
|
|
);
|
|
|
|
CREATE TABLE dataset_values (
|
|
dataset VARCHAR(128) NOT NULL,
|
|
resource VARCHAR(128) NOT NULL,
|
|
row_key VARCHAR(128) NOT NULL,
|
|
field VARCHAR(128) NOT NULL,
|
|
printed VARCHAR(64),
|
|
origin_kind VARCHAR(10) NOT NULL CHECK (origin_kind IN ('reported', 'digitized', 'computed', 'measured')),
|
|
anchor TEXT,
|
|
PRIMARY KEY (dataset, resource, row_key, field)
|
|
);
|
|
|
|
CREATE TABLE digitizations (
|
|
id VARCHAR(32) NOT NULL,
|
|
doc_key VARCHAR(257) NOT NULL,
|
|
panel VARCHAR(16) NOT NULL,
|
|
page_fp VARCHAR(64),
|
|
method VARCHAR(8) NOT NULL CHECK (method IN ('manual', 'traced', 'proposed')),
|
|
confirmation VARCHAR(32),
|
|
dataset VARCHAR(128),
|
|
record TEXT NOT NULL,
|
|
PRIMARY KEY (id)
|
|
);
|
|
|
|
CREATE TABLE views (
|
|
id VARCHAR(128) NOT NULL,
|
|
project_key VARCHAR(128),
|
|
spec TEXT NOT NULL,
|
|
PRIMARY KEY (id)
|
|
);
|
|
|
|
CREATE TABLE policies (
|
|
id VARCHAR(32) NOT NULL,
|
|
project_key VARCHAR(128),
|
|
signer VARCHAR(128) NOT NULL,
|
|
made_at VARCHAR(20) NOT NULL,
|
|
valid_until VARCHAR(20),
|
|
record TEXT NOT NULL,
|
|
PRIMARY KEY (id)
|
|
);
|
|
|
|
CREATE TABLE submissions (
|
|
id VARCHAR(32) NOT NULL,
|
|
exercise VARCHAR(256) NOT NULL,
|
|
student VARCHAR(64) NOT NULL,
|
|
submitted_at VARCHAR(20) NOT NULL,
|
|
record TEXT NOT NULL,
|
|
PRIMARY KEY (id)
|
|
);
|
|
|
|
CREATE TABLE grades (
|
|
submission VARCHAR(32) NOT NULL,
|
|
score VARCHAR(32) NOT NULL,
|
|
max_score VARCHAR(32) NOT NULL,
|
|
record TEXT NOT NULL,
|
|
PRIMARY KEY (submission)
|
|
);
|