Skip to content

Commit db45570

Browse files
hyperpolymathclaude
andcommitted
feat: convert lithoglyph from stale gitlink to tracked files + Phase A+B pipeline work
Convert lithoglyph/ from a stale gitlink (commit pointer with no .git) to fully tracked monorepo files. This was caused by the Feb 20 .git cleanup removing the nested .git without updating the parent index. Lithoglyph changes included: - FormBD → Lith rename complete (292+ files, zero remaining refs) - formdb-http/ → lith-http/ rename (IP: Google owns "FormDB") - Zig 0.15.2 HTTP API confirmed complete (77 call sites) - Bofig evidence collection schema (5 collections + 1 edge collection) - FQL test vectors for bofig_evidence, claims, entities, transactions - Cap'n Proto → Lithoglyph ingest bridge (bofig-ingest.sh + .exs) - Zig lith_adapter (StageResults → JSON with auto-PROMPT scoring) - Integration plan and Epstein test pathway documentation - STATE.scm updated to 75% completion - All FORMDB_* env vars → LITH_* across configs, docs, clients Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent c07bb73 commit db45570

853 files changed

Lines changed: 154695 additions & 1 deletion

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

lithoglyph

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
;; SPDX-License-Identifier: PMPL-1.0-or-later
2+
;; Bot Directives - Lithoglyph
3+
;;
4+
;; This directory contains directives for the gitbot-fleet automation system.
5+
;; Bots read these files to understand how to operate on this repository.
6+
7+
(bot-directives
8+
(version "1.0")
9+
(repo "lithoglyph")
10+
(fleet-members
11+
"rhodibot" ; Git operations
12+
"echidnabot" ; Code quality
13+
"sustainabot" ; Dependency updates
14+
"seambot" ; Integration checks
15+
"finishbot")) ; Task completion
16+
17+
;; Bot Responsibilities:
18+
;;
19+
;; rhodibot - Automated git operations (commits, tags, releases)
20+
;; echidnabot - Code quality enforcement (linting, tests, analysis)
21+
;; sustainabot - Dependency updates (Zig, Factor, Elixir packages)
22+
;; seambot - Integration verification (cross-language FFI checks)
23+
;; finishbot - Task completion tracking (TODOs, milestones)
24+
25+
;; Configuration Format:
26+
;; Each bot has its own .scm file defining its behavior for this repo.
27+
;; The format is S-expression based for easy parsing by Scheme/Elixir bots.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
;; SPDX-License-Identifier: PMPL-1.0-or-later
2+
;; Echidnabot Directives - Code Quality Automation
3+
;;
4+
;; Echidnabot enforces code quality standards, runs static analysis,
5+
;; and ensures industrial-grade code for Lithoglyph.
6+
7+
(echidnabot-config
8+
(repo-name "lithoglyph")
9+
10+
(quality-gates
11+
(block-on-failing-tests #t)
12+
(block-on-linter-errors #t)
13+
(block-on-security-issues #t)
14+
(require-test-coverage 80))
15+
16+
(zig-analysis
17+
(run-zig-test #t)
18+
(check-memory-leaks #t)
19+
(verify-abi-exports #t)
20+
(check-alignment #t)
21+
(verify-block-formats #t))
22+
23+
(factor-analysis
24+
(check-syntax #t)
25+
(verify-ffi-signatures #t)
26+
(check-for-stubs #t))
27+
28+
(forth-analysis
29+
(verify-stack-effects #t)
30+
(check-block-layout #t)
31+
(verify-crc-implementation #t))
32+
33+
(security-checks
34+
(scan-for-secrets #t)
35+
(check-for-unsafe-operations #t)
36+
(verify-input-validation #t)
37+
(check-buffer-bounds #t))
38+
39+
(automated-fixes
40+
(auto-format-code #f)
41+
(auto-fix-lints #f)
42+
(suggest-improvements #t))
43+
44+
(reporting
45+
(post-pr-comments #t)
46+
(generate-quality-report #t)
47+
(track-quality-trends #t)))
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
;; SPDX-License-Identifier: PMPL-1.0-or-later
2+
;; Rhodibot Directives - Git Operations Automation
3+
;;
4+
;; Rhodibot handles automated git operations, commit standardization,
5+
;; and repository health maintenance for Lithoglyph.
6+
7+
(rhodibot-config
8+
(repo-name "lithoglyph")
9+
(primary-language "zig")
10+
(additional-languages "factor" "forth" "elixir")
11+
12+
(commit-standards
13+
(format "conventional-commits")
14+
(scopes "core-zig" "core-factor" "core-forth" "api" "docs" "tests")
15+
(require-co-author #t)
16+
(co-author "Claude Sonnet 4.5 <noreply@anthropic.com>")
17+
(sign-commits #f))
18+
19+
(branch-protection
20+
(main-branch "main")
21+
(require-reviews 1)
22+
(require-tests-pass #t)
23+
(allow-force-push #f))
24+
25+
(automated-tasks
26+
(auto-rebase #f)
27+
(auto-merge-dependabot #f)
28+
(auto-tag-releases #t)
29+
(sync-forks #t))
30+
31+
(monitoring
32+
(check-for-drift #t)
33+
(verify-ci-status #t)
34+
(alert-on-failed-builds #t))
35+
36+
(cleanup-rules
37+
(delete-merged-branches #t)
38+
(squash-on-merge #f)
39+
(update-changelog #t)))

lithoglyph/.claude/CLAUDE.md

Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
# CLAUDE.md - AI Assistant Instructions for Lithoglyph
2+
3+
## Project Overview
4+
5+
Lithoglyph (formerly "Lith") is a narrative-first, reversible, audit-grade database core. Every mutation is a story event with full provenance. The tagline: "The database where the database is part of the story."
6+
7+
Multi-language stack in dependency order:
8+
1. **Forth** (core-forth/) — Block storage kernel, journaling, data model
9+
2. **Zig** (core-zig/) — C ABI bridge with WAL, 19 functions, block allocator
10+
3. **Zig** (ffi/zig/) — Delegation layer that forwards to core-zig
11+
4. **Idris2** (src/Lith/) — Dependent-type ABI proofs, memory layout verification
12+
5. **Factor** (core-factor/) — FQL runtime: parser, planner, executor
13+
6. **Lean 4** (normalizer/) — Normalization proofs, FD discovery (52 proofs)
14+
7. **Lean 4** (gql-dt/) — Dependently-typed Glyph Query Language
15+
8. **Zig + Rust** (beam/) — BEAM NIFs for Elixir/Erlang integration
16+
9. **Elixir** (lith-http/) — Phoenix HTTP API, control plane
17+
10. **Rust + Web** (studio/) — Tauri desktop GUI (mock data, early stage)
18+
11. **Zig** (api/) — REST + gRPC API (BROKEN — needs Zig 0.15.2 migration)
19+
20+
Subprojects with own `.machine_readable/`: gql-dt/, glyphbase/, lith-http/
21+
22+
## Architecture
23+
24+
```
25+
svalinn (TLS) → lith-http (Elixir :4000) → BEAM NIFs → core-zig (C ABI) → core-forth (blocks)
26+
27+
Idris2 ABI proofs (src/Lith/) verify bridge contracts
28+
Lean 4 normalizer verifies schema correctness
29+
GQL-DT (Lean 4) verifies query correctness
30+
Factor FQL plans and executes queries
31+
```
32+
33+
## Critical Invariants
34+
35+
1. **IP Rename PENDING**: Code uses `Lith`/`Form` internally. Must rename to `Litho`/`Lithoglyph` before any public release. Keep "form" only where it literally means HTML/data forms.
36+
2. **Zero `believe_me`** in Idris2 ABI (`src/Lith/`). This is a HARD invariant — no exceptions.
37+
3. **Zero `sorry`** in Lean 4 proofs (normalizer/, gql-dt/). All proofs must be constructive.
38+
4. **`core-zig/src/bridge.zig`** is the WORKING implementation. `ffi/zig/` only delegates to it. Never add new functionality to `ffi/zig/` directly.
39+
5. **Proven library** lives at `/var/mnt/eclipse/repos/proven/` (104+ modules) — never bundle a copy.
40+
6. All Zig `@ptrCast`/`@alignCast`/`@intToPtr` must have `// SAFETY:` comments.
41+
7. **SCM files** ONLY in `.machine_readable/` — never in root directories.
42+
8. **Container runtime**: Podman, never Docker. Files: `Containerfile`, never `Dockerfile`.
43+
9. **Base images**: `cgr.dev/chainguard/wolfi-base:latest` or `cgr.dev/chainguard/static:latest`.
44+
45+
## Machine-Readable Artefacts
46+
47+
`.machine_readable/` contains:
48+
- `STATE.scm` — Current project state, component status, completion percentages
49+
- `META.scm` — Architecture decisions, development practices, design rationale
50+
- `ECOSYSTEM.scm` — Position in ecosystem, related projects
51+
- `AGENTIC.scm` — AI agent interaction patterns, autonomous agent designs
52+
- `NEUROSYM.scm` — Neurosymbolic integration (symbolic proofs + planned neural layer)
53+
- `PLAYBOOK.scm` — Operational runbook, build procedures, incident response
54+
- `HANDOVER.scm` — Legacy handover artefact (historical)
55+
- `ROADMAP.scm` — Unified roadmap across all lithoglyph subprojects
56+
57+
## Language Policy
58+
59+
### ALLOWED
60+
- **Forth** — Storage kernel (gforth)
61+
- **Zig** — Bridge, BEAM NIF, API layer
62+
- **Idris2** — ABI proofs (dependent types)
63+
- **Lean 4** — Normalization proofs, GQL-DT
64+
- **Factor** — FQL runtime (concatenative)
65+
- **Elixir** — OTP control plane, HTTP API
66+
- **Rust** — BEAM NIF (Rustler), studio backend
67+
- **ReScript** — Client libraries (if needed)
68+
- **Nickel** — Configuration
69+
70+
### BANNED
71+
- TypeScript, Python, Go, Java, Node.js, npm
72+
73+
## Build Commands
74+
75+
### Core Components (dependency order)
76+
```bash
77+
# 1. Forth kernel (17 tests)
78+
cd core-forth && gforth test/lithoglyph-tests.fs
79+
80+
# 2. Zig bridge (primary — all tests)
81+
cd core-zig && zig build test
82+
83+
# 3. Zig FFI delegation (delegates to core-zig)
84+
cd ffi/zig && zig build test
85+
86+
# 4. Idris2 ABI type-check (3 files, must be clean)
87+
idris2 --source-dir src --check src/Lith/LithBridge.idr
88+
idris2 --source-dir src --check src/Lith/LithLayout.idr
89+
idris2 --source-dir src --check src/Lith/LithForeign.idr
90+
91+
# 5. Lean 4 normalizer (52 proofs)
92+
cd normalizer && lake build
93+
94+
# 6. Factor runtime
95+
cd core-factor && factor -run=listener # manual verification
96+
```
97+
98+
### Satellites
99+
```bash
100+
# BEAM NIF (Rust — 0 warnings required)
101+
cd beam/native_rust && cargo build
102+
103+
# BEAM NIF (Zig)
104+
cd beam/native && zig build
105+
106+
# Elixir HTTP (lith-http)
107+
cd lith-http && mix deps.get && mix compile && mix test
108+
109+
# GQL-DT (Lean 4)
110+
cd gql-dt && lake build
111+
112+
# Studio (Tauri — mostly mock data)
113+
cd studio && cargo build
114+
```
115+
116+
### Quick Verification
117+
```bash
118+
just test # core-zig + ffi/zig + core-forth
119+
just build-all # everything in dependency order
120+
```
121+
122+
## Component Status
123+
124+
| Component | Build | Tests | Notes |
125+
|-----------|-------|-------|-------|
126+
| core-forth | PASS | 17/17 | Block storage, journal, data model |
127+
| core-zig | PASS | PASS | 19 real functions, WAL commit |
128+
| ffi/zig | PASS | PASS | Delegates to core-zig |
129+
| Idris2 ABI | PASS | N/A | 3 files type-check clean, 0 believe_me |
130+
| Lean 4 normalizer | PASS | 52 PASS | FD discovery proofs |
131+
| core-factor | PASS | N/A | FQL parser/planner/executor |
132+
| BEAM NIF (Zig) | PASS | N/A | Real FFI calls |
133+
| BEAM NIF (Rust) | PASS | N/A | Rustler 0.35, 0 warnings |
134+
| lith-http | PASS | PASS | M15 complete |
135+
| gql-dt | PASS | claims 100% | Needs honest audit |
136+
| glyphbase | ? | ? | Needs honest audit |
137+
| api (Zig) | BROKEN | N/A | 83 old std.http.Server call sites |
138+
| studio | PASS | N/A | 11 commands return mock data |
139+
140+
## Patterns and Anti-Patterns
141+
142+
### Banned Patterns (CI enforced)
143+
- `believe_me` in Idris2 — use `%foreign prim__callbackToAnyPtr` pattern instead
144+
- `assert_total`, `assert_smaller`, `unsafePerformIO` in Idris2
145+
- `sorry` in Lean 4
146+
- `Admitted` in Coq (if any)
147+
- Zig unsafe casts without `// SAFETY:` annotation
148+
- SQL string concatenation — use parameterized query builders
149+
- Hardcoded secrets — use env vars with `${VAR:-}` defaults
150+
151+
### Key Design Patterns
152+
- **Bridge delegation**: `ffi/zig/``core-zig/` (never reverse)
153+
- **ABI-first**: Idris2 proofs define the interface contract, Zig implements it
154+
- **Proof-verified schemas**: Lean 4 normalizer proves schema correctness
155+
- **Narrative provenance**: Every mutation has a story — who, what, when, why
156+
- **WAL-first writes**: All mutations go through Write-Ahead Log before blocks
157+
158+
## Related Projects
159+
160+
- **verisimdb** — Octad database sibling (shares GQL patterns)
161+
- **quandledb** — Knot-theoretic database sibling
162+
- **nqc** — Normal-form Query Compiler
163+
- **proven** — Formally verified safety library (SafeString, SafeJson, etc.)
164+
- **hypatia** — Neurosymbolic CI/CD scanner
165+
- **gitbot-fleet** — Bot orchestration (rhodibot, echidnabot, sustainabot)
166+
167+
## Known Issues
168+
169+
- **API layer**: `api/src/rest.zig` and `api/src/grpc.zig` use old `std.http.Server` API — 83 call sites need Zig 0.15.2 migration
170+
- **Studio**: 11 Tauri commands return mock data, not real bridge calls
171+
- **IP rename**: `Lith`/`Form` namespace must be renamed before public release
172+
- **Idris2 Nat reduction**: Proof type signatures must use concrete literals, not function-defined constants (Idris2 0.8 limitation)
173+
- **gql-dt/glyphbase**: Claim 100% completion — need honest audit

lithoglyph/.editorconfig

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# SPDX-License-Identifier: PMPL-1.0-or-later
2+
# https://editorconfig.org
3+
4+
root = true
5+
6+
[*]
7+
charset = utf-8
8+
end_of_line = lf
9+
indent_size = 2
10+
indent_style = space
11+
insert_final_newline = true
12+
trim_trailing_whitespace = true
13+
14+
[*.md]
15+
trim_trailing_whitespace = false
16+
17+
[*.adoc]
18+
trim_trailing_whitespace = false
19+
20+
[*.rs]
21+
indent_size = 4
22+
23+
[*.zig]
24+
indent_size = 4
25+
26+
[*.ada]
27+
indent_size = 3
28+
29+
[*.adb]
30+
indent_size = 3
31+
32+
[*.ads]
33+
indent_size = 3
34+
35+
[*.ex]
36+
indent_size = 2
37+
38+
[*.exs]
39+
indent_size = 2
40+
41+
[*.hs]
42+
indent_size = 2
43+
44+
[*.res]
45+
indent_size = 2
46+
47+
[*.resi]
48+
indent_size = 2
49+
50+
[*.ncl]
51+
indent_size = 2
52+
53+
[*.scm]
54+
indent_size = 2
55+
56+
[*.nix]
57+
indent_size = 2
58+
59+
[Justfile]
60+
indent_style = space
61+
indent_size = 4
62+
63+
[justfile]
64+
indent_style = space
65+
indent_size = 4
66+
67+
[Makefile]
68+
indent_style = tab

0 commit comments

Comments
 (0)