Skip to content

Commit 240d8ca

Browse files
hyperpolymathclaude
andcommitted
docs(quandledb): add CHANGELOG + docstrings for QuandleSemantic public API
CHANGELOG captures the absorb-into-monorepo transition and recent doc additions. Docstrings added to 4 public symbols in QuandleSemantic module: - QuandleRelation (struct): field semantics + positive/negative crossing meaning - QuandlePresentation (struct): iso-via-canonical-blob contract - canonicalize_presentation: relabelling rule + isomorphism relationship - canonical_presentation_blob: serialisation format spec + SHA-256 feed Raises quandledb's maintainability aspect from 0 docstrings → 4 public-API docstrings. extract_presentation and quandle_descriptor already had docstrings. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent d83e81e commit 240d8ca

2 files changed

Lines changed: 91 additions & 0 deletions

File tree

quandledb/CHANGELOG.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<!-- SPDX-License-Identifier: PMPL-1.0-or-later -->
2+
<!-- Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk> -->
3+
4+
# Changelog — QuandleDB
5+
6+
All notable changes to this project will be documented in this file.
7+
8+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
9+
10+
## [Unreleased]
11+
12+
### Added
13+
- EXPLAINME.adoc: honest scope, invariants, boundaries, polyglot stack map
14+
- TEST-NEEDS.md: 21 assertions today, gaps documented per test category
15+
- PROOF-NEEDS.md: 4 mathematical obligations (quandle axioms, Reidemeister
16+
invariance, canonicalisation idempotence, colouring well-definedness)
17+
+ 3 systems obligations (cross-platform determinism, ABI-FFI layout,
18+
NIF safety)
19+
- CRG v2 READINESS.md (grade D)
20+
21+
### Changed
22+
- Absorbed into `nextgen-databases/` monorepo (removed nested .git dir)
23+
- KQL → renamed reference to align with KRL stack naming
24+
25+
## [Absorbed into monorepo] 2026-04-05
26+
27+
Previously lived as a nested git repo under nextgen-databases/. Flattened
28+
into the parent monorepo per the "no .git dirs in monorepo subdirs" rule.
29+
History preserved in the absorption commit message.
30+
31+
### Included in absorption
32+
- `server/serve.jl`: HTTP server with quandle_semantic_index SQLite sidecar
33+
- `server/quandle_semantic.jl`: QuandleSemantic module — presentation
34+
extraction, canonicalisation, descriptor hashing (SHA-256)
35+
- `src/abi/Types.idr`: Idris2 ABI type layer
36+
- `src/ffi/semantic_ffi.zig`: Zig FFI layer
37+
- `src/api/*.v`: V-lang API triples
38+
- `beam/`: Elixir BEAM client with NIFs
39+
40+
### Prior history (pre-absorption)
41+
- fix: replace Obj.magic with typed Fetch API bindings in Api.res
42+
- chore: batch RSR compliance
43+
- docs: KQL safety model — two-tier architecture with TypeLL levels
44+
- feat: KQL query language design — SQL compat + dependent type variants

quandledb/server/quandle_semantic.jl

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,39 @@ export QuandleRelation, QuandlePresentation
99
export extract_presentation, canonicalize_presentation, canonical_presentation_blob
1010
export quandle_descriptor
1111

12+
"""
13+
QuandleRelation
14+
15+
A single crossing relation in the fundamental quandle. At a positive crossing,
16+
the right quandle action gives `lhs ▷ rhs = out`; at a negative crossing,
17+
this is inverted (`is_inverse = true`).
18+
19+
# Fields
20+
- `lhs::Int`: left-hand-side generator index (the arc being acted on)
21+
- `rhs::Int`: acting generator index (the over-strand arc)
22+
- `out::Int`: result generator index (the arc after the crossing)
23+
- `is_inverse::Bool`: `true` for negative crossings (inverse action)
24+
"""
1225
struct QuandleRelation
1326
lhs::Int
1427
rhs::Int
1528
out::Int
1629
is_inverse::Bool
1730
end
1831

32+
"""
33+
QuandlePresentation
34+
35+
Fundamental-quandle presentation of a knot diagram: `generator_count` generators
36+
(one per arc) plus a list of relations (one per crossing).
37+
38+
# Fields
39+
- `generator_count::Int`: number of generators (equals number of distinct arcs
40+
after union-find collapsing at each crossing)
41+
- `relations::Vector{QuandleRelation}`: one relation per crossing
42+
43+
Two presentations with equal `canonical_presentation_blob` are isomorphic quandles.
44+
"""
1945
struct QuandlePresentation
2046
generator_count::Int
2147
relations::Vector{QuandleRelation}
@@ -104,6 +130,16 @@ function extract_presentation(pd::KnotTheory.PlanarDiagram)::QuandlePresentation
104130
QuandlePresentation(generator_count, relations)
105131
end
106132

133+
"""
134+
canonicalize_presentation(p::QuandlePresentation) -> QuandlePresentation
135+
136+
Relabel generators in `p` to canonical form: generators receive fresh ids
137+
`1, 2, 3, ...` in the order they first appear in sorted relations.
138+
139+
Two presentations produce the same canonical form iff they represent the
140+
same presentation up to generator renaming. This is the basis for
141+
`canonical_presentation_blob`'s fingerprint.
142+
"""
107143
function canonicalize_presentation(p::QuandlePresentation)::QuandlePresentation
108144
sorted_rel = sort(p.relations, by = r -> (r.lhs, r.rhs, r.out, r.is_inverse ? 1 : 0))
109145

@@ -134,6 +170,17 @@ function canonicalize_presentation(p::QuandlePresentation)::QuandlePresentation
134170
QuandlePresentation(p.generator_count, canon_rel)
135171
end
136172

173+
"""
174+
canonical_presentation_blob(p::QuandlePresentation) -> String
175+
176+
Serialise `p` to a canonical text blob after applying `canonicalize_presentation`.
177+
Format: `qpres-v1|g=<generator_count>|r=<rel>;<rel>;...` where each `<rel>` is
178+
`lhs,rhs,out,sign` with `sign ∈ {-1, 1}`.
179+
180+
Two presentations with the same blob are isomorphic as quandles (up to
181+
generator renaming). This blob is the input to SHA-256 fingerprinting in
182+
`quandle_descriptor`.
183+
"""
137184
function canonical_presentation_blob(p::QuandlePresentation)::String
138185
c = canonicalize_presentation(p)
139186
rel_tokens = String[]

0 commit comments

Comments
 (0)