This file guides Codex and other coding agents working in this repository.
Latha DB is being ported from the deprecated Java implementation in deprecated/
into the new Gleam/Lustre application in app/.
Treat deprecated/ as the behavioral reference and migration source. Treat
app/ as the active implementation target.
The port should preserve the core Latha DB ideas:
- Lisp-style query language and script execution
- Table, record, type, and value semantics
- Persistence for
.lathaand.latha-bindata where practical - Transactions, undo behavior, and write safety
- Triggers, functions, vector operations, and graph utilities
- Client/server or HTTP behavior when it becomes part of the new app
You are expected to act as a senior software engineer who can work across languages and runtimes. The old project is Java; the new project is Gleam with Lustre. Understand the Java code first, then implement the equivalent behavior idiomatically in Gleam.
Do not blindly translate line by line. Port concepts, contracts, data formats, and externally visible behavior.
deprecated/: old Java implementation, fixtures, docs, Lisp scripts, sample databases, and architecture notes. Read-only reference unless explicitly asked otherwise.deprecated/src/main/java/com/lathadb/: old Java source tree.deprecated/ARCHITECTURE.md: high-level system design for the old engine.deprecated/CHEAT_SHEET.txt: useful query language and command examples.app/: new Gleam/Lustre project and the only normal destination for ported implementation work.app/src/: production Gleam source.app/test/: Gleam tests.app/build/: generated build output. Do not edit by hand.
- Before porting a feature, identify the old Java classes, tests, fixtures, and sample scripts that define its behavior.
- Add or update focused tests in
app/test/for each ported feature. - Keep public behavior compatible with existing
.latha,.latha-bin, and Lisp examples unless there is a deliberate migration decision. - Prefer small, reviewable feature slices over large rewrites.
- Keep generated files, build artifacts, and vendored package output out of manual edits.
- Document intentional behavior differences in the relevant code or docs.
- Preserve user data safety. Database writes, transaction behavior, and serialization changes need tests before they are considered done.
- Run commands from
app/unless a task explicitly targets the repository root. - Use
gleam testfor verification. - Use
gleam formatafter editing Gleam files. - Keep modules cohesive. Prefer domain modules such as engine, table, value,
parser, persistence, and server instead of growing all behavior in
app/src/app.gleam. - Prefer pure functions and explicit result types for parser, query execution, serialization, and storage behavior.
- Model failures with typed errors rather than stringly exceptions where possible.
The preferred migration order is:
- Core data model: values, records, tables, table sets, and types.
- Query parsing/tokenizing for the Lisp-style language.
- Query execution for basic create, insert, select, update, delete behavior.
- Persistence for text
.lathafiles and fixtures. - Transactions, undo, triggers, and function registry.
- Compression and
.latha-bincompatibility. - Vector, graph, network, REST, and UI features.
Adjust this order only when a user request requires it.
For each completed porting slice:
- The relevant old Java behavior has been inspected.
- New Gleam tests cover the intended behavior.
gleam formathas been run for modified Gleam files.gleam testpasses fromapp/.- Any known gap from the deprecated implementation is called out clearly.
- Do not edit
app/build/manually. - Do not delete deprecated fixtures or sample databases during migration.
- Do not rewrite unrelated app scaffolding while porting a feature.
- Do not change data formats casually.
- Do not treat the current starter Lustre counter UI as architecture.