Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
c26ef62
feat(encrypt): keep a dated plain copy of the old database
nodemode-ai Nov 27, 2026
be3a398
feat(snapshot): write a snapshot from the window through an owner-onl…
nodemode-ai Nov 27, 2026
9356cbf
feat(encrypt): make and keep a desktop key behind formledger_key_home
nodemode-ai Nov 27, 2026
43dde0a
fix(templates): pin the card name row so the meta line stops moving
nodemode-ai Nov 27, 2026
03e4295
feat(web): add the snapshot action that tells where the file went
nodemode-ai Nov 27, 2026
21e1999
fix(menubar): give cmd or ctrl p to search as form.md does
nodemode-ai Nov 27, 2026
fe0bc13
fix(palette): show print on its new key
nodemode-ai Nov 27, 2026
c222a7e
feat(templates): name each template line's account from the chart
nodemode-ai Nov 27, 2026
adf341d
feat(desktop): name the app data folder as the engine key home
nodemode-ai Nov 27, 2026
22c6d8b
feat(templates): show each card's accounts by number and chart name
nodemode-ai Nov 27, 2026
570a0e9
docs(encryption): describe the desktop key, the plain copy and key ba…
nodemode-ai Nov 27, 2026
64b1ffe
docs(encryption): say the shell wiring waits on one main.rs line
nodemode-ai Nov 27, 2026
bc83bd3
docs(hashout): log the desktop key, the plain copy and the shell seam
nodemode-ai Nov 27, 2026
147c5ff
docs(hashout): log the card shift fix and template account names
nodemode-ai Nov 27, 2026
2192ce1
fix(dashboards): match the form.md card radius
nodemode-ai Nov 27, 2026
0ffb658
fix(dashboards): larger tighter figures on the number cards
nodemode-ai Nov 27, 2026
0df36ec
fix(printout): keep formtxt's reason when it does not draw
nodemode-ai Nov 27, 2026
7f9ede4
fix(charts): compact value-axis labels like form.md
nodemode-ai Nov 27, 2026
d63b4c9
docs(hashout): log the dashboards comparison with form.md
nodemode-ai Nov 27, 2026
0c328aa
feat(printout): tell the person why formtxt did not draw
nodemode-ai Nov 27, 2026
88fe7d1
fix(printout): quote formtxt's refusal as its own sentence
nodemode-ai Nov 27, 2026
b75ede2
docs(print): record the formtxt print as verified and how to set it up
nodemode-ai Nov 27, 2026
ad100c1
fix(web): show the snapshot result in one toast with no interim message
nodemode-ai Nov 27, 2026
745d7de
fix(palette): keep group and key columns at fixed widths
nodemode-ai Nov 27, 2026
032d0db
docs(hashout): log the first formtxt drawn invoice
nodemode-ai Nov 27, 2026
fbd451d
fix(palette): line key hints up on the trailing edge
nodemode-ai Nov 27, 2026
766b61e
fix(desktop): hand the engine its key home from the shell
nodemode-ai Nov 27, 2026
1732e31
feat(templates): type the account name the server sends with a line
nodemode-ai Nov 27, 2026
4809022
docs(web): log the snapshot action and palette columns
nodemode-ai Nov 27, 2026
02829a5
docs(desktop): log the menubar read and the search key
nodemode-ai Nov 27, 2026
a7a8813
feat(window): write snapshot runs for real and the keys follow form.md
nodemode-ai Nov 27, 2026
1367206
docs(security): say when the server makes and keeps its own key
nodemode-ai Nov 27, 2026
b94b76c
docs(encryption): say the shell line is written and was not compiled
nodemode-ai Nov 27, 2026
ae06ab7
chore(release): 0.12.0
nodemode-ai Nov 27, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,37 @@
# Changelog

## 0.12.0

FormLedger writes a snapshot from the window, keeps its own key on the desktop, tells you when FormTxt did not draw a page, and names the accounts its templates post to.

### New
- **Write snapshot** in the menubar and the command palette writes the snapshot at once, into a `snapshots` folder inside the data folder, and says where it is and how many tables and rows it holds. Only the owner can write one.
- **A key of its own:** with `FORMLEDGER_KEY_HOME` set and no key file given, the server makes a key once, keeps it there and encrypts the ledger from then on, converting an existing plain ledger on first start. The desktop app is written to set this to its app data folder.
- **Template cards name their accounts,** for example "Posts to 4100 Sales · 4900 Other income", read from your chart of accounts.

### Improved
- **Printing through FormTxt:** when FormTxt does not draw the page, `cli print` says why under the "printed by" line, for example that FormTxt needs its window open and outside agents allowed, or that it has no such template. FormLedger waits 100 seconds for FormTxt, up from 45.
- **Dashboards** sit closer to form.md's: larger figures on the number cards, short labels on the value axis (2K, not 2000.00), and the same card corners.
- **The command palette** keeps its columns still while you type.

### Changed
- **Ctrl or Cmd+P opens Search,** as in form.md. Print is Ctrl or Cmd+Alt+P.
- **`formledger encrypt` keeps a plain copy** of the old database beside it, named `formledger-plain-copy-` and the date, and never overwrites an earlier copy. That copy is not encrypted: delete or move it once the encrypted ledger opens.

### Fixed
- The templates screen no longer moves a line on each card as the names arrive.
- A print that FormTxt refused used to fall back to the plain page without a word.

### Known issues
- Losing the key loses the books. Back the key file up; `docs/ENCRYPTION.md` says how. On the desktop the first-run warning is in the server's log, not in the window.
- FormLedger ships no FormTxt template. You make one in FormTxt and set `FORMLEDGER_FORMTXT_TEMPLATE_INVOICE` to its id (`docs/PRINT.md`).
- A document started from a template does not show the account each line posts to.
- The short axis labels on charts assume a currency with two decimal places.
- The top bar's title moves slightly as the dashboards screen loads.

### Under the hood
- Checked for this version: an invoice was drawn by FormTxt 0.38.0 and, with FormTxt stopped, by the plain renderer. Not run: the desktop app and its menubar were not compiled, and nothing ran on macOS or Windows.

## 0.11.0

FormLedger gets dashboards with charts, document templates, a short sidebar with a command palette and a full menubar, and encryption at rest.
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION := v0.11.0
VERSION := v0.12.0
GO_BUILD := CGO_ENABLED=0 go build -trimpath -ldflags "-s -w"

.PHONY: build web server check clean
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</p>

<p align="center">
<img alt="version v0.11.0" src="https://img.shields.io/badge/version-v0.11.0-eef0f4?style=flat-square">
<img alt="version v0.12.0" src="https://img.shields.io/badge/version-v0.12.0-eef0f4?style=flat-square">
<img alt="Go 1.26+" src="https://img.shields.io/badge/Go-1.26%2B-00ADD8?style=flat-square&logo=go&logoColor=white">
<img alt="TypeScript and Vite" src="https://img.shields.io/badge/TypeScript-Vite-3178c6?style=flat-square">
<img alt="License: Apache-2.0" src="https://img.shields.io/badge/license-Apache--2.0-3a3a3a?style=flat-square">
Expand Down Expand Up @@ -120,6 +120,7 @@ On Windows use `formledger_oc_install.bat` and `formledger.bat`.
| `FORMLEDGER_URL` | Server the command line talks to, default `http://127.0.0.1:8340` |
| `FORMLEDGER_TOKEN` | App token for the command line |
| `FORMLEDGER_KEY_FILE` | Key file that turns on encryption at rest; unset means the ledger is stored plain |
| `FORMLEDGER_KEY_HOME` | Folder where the server makes and keeps its own key (`formledger.key`) when no key file is given. The desktop app sets it to its app data folder. Losing that key loses the books: back it up (`docs/ENCRYPTION.md`) |

> [!IMPORTANT]
> **Status:** early. The ledger, selling, buying and stock work from the command line and over the server's routes. The window's screens for them are new and only partly checked in a browser, and the desktop app in `src-tauri/` has not been compiled.
Expand Down
5 changes: 4 additions & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ FormLedger, are ordinary bugs: please open an issue for those.
With a key (`FORMLEDGER_KEY_FILE`, or a systemd credential named `formledger.key`),
the ledger database, its WAL and its journal are encrypted with XTS-AES-256 through the
`formledger-crypt` SQLite VFS, ported from form.md. Without a key the ledger is plain,
and the server says so at start. A missing or wrong key stops the server before any
and the server says so at start. With `FORMLEDGER_KEY_HOME` set and no key given, the
server makes its own key once in that folder (owner-only) and uses it from then on; the
desktop app is written to set it to its app data folder, which is not the data directory.
A missing or wrong key stops the server before any
database is opened. The key is never stored in the data directory; if it is lost, the
ledger cannot be recovered by anyone. `formledger report snapshot` writes a plain copy
by design and must be treated as sensitive. See [`docs/ENCRYPTION.md`](docs/ENCRYPTION.md).
Expand Down
2 changes: 1 addition & 1 deletion cmd/HASHOUT_LOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Living log of all comment content, explainers, rationale, TODOs, & removed (hashed-out) code for the entry point, `embed.go`, `internal/server`, `internal/static` and `internal/startup`. Source files stay comment-free per dev-rules `sub-skills/hashout-log/SUB-SKILL.md`; everything they would have said lives here, indexed. Read it first, then edit code surgically.

Current build version: v0.11.0
Current build version: v0.12.0
Last updated: 2026-11-26 (US Eastern) · skeleton port from form.md

---
Expand Down
34 changes: 32 additions & 2 deletions cmd/formledger/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,19 @@ func encrypt() int {
return 2
}
defer release()
if err := store.Encrypt(context.Background(), cfg.DataDir, cfg.KeyFile); err != nil {
copyPath, err := store.Encrypt(context.Background(), cfg.DataDir, cfg.KeyFile)
if err != nil {
fmt.Fprintln(os.Stderr, "formledger encrypt:", err)
return 1
}
if copyPath == "" {
fmt.Println("the database was already encrypted with this key; nothing changed")
return 0
}
fmt.Println("encrypted the database; start FormLedger with the same FORMLEDGER_KEY_FILE")
fmt.Println("the old plain database was kept at:", copyPath)
fmt.Println(store.PlainCopyNote)
fmt.Println(crypt.LossWarning)
return 0
}

Expand Down Expand Up @@ -118,7 +126,29 @@ func serve() int {
if replaced > 0 {
log.Info("an engine left running by an earlier start was stopped", "pid", replaced)
}
key, err := crypt.Load(cfg.DataDir, crypt.KeyPath(cfg.KeyFile), store.HasData(cfg.DataDir))
keyPath := crypt.KeyPath(cfg.KeyFile)
if keyPath == "" && cfg.KeyHome != "" {
path, made, err := crypt.EnsureHome(cfg.KeyHome)
if err != nil {
log.Error("encryption", "err", fmt.Errorf("making the desktop key: %w", err))
return 2
}
keyPath = path
if made {
log.Warn("made this computer's FormLedger key", "key", path)
log.Warn(crypt.LossWarning)
}
if store.HasData(cfg.DataDir) && !crypt.Encrypted(cfg.DataDir) {
copyPath, err := store.Encrypt(ctx, cfg.DataDir, path)
if err != nil {
log.Error("encryption", "err", err)
return 1
}
log.Warn("encrypted the existing ledger; the old plain database was kept", "copy", copyPath)
log.Warn(store.PlainCopyNote)
}
}
key, err := crypt.Load(cfg.DataDir, keyPath, store.HasData(cfg.DataDir))
if err != nil {
log.Error("encryption", "err", err)
return 2
Expand Down
45 changes: 40 additions & 5 deletions docs/ENCRYPTION.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Encryption at rest

FormLedger can encrypt its data directory at rest with a 256-bit key that you hold outside the data directory. The wiring is ported from form.md (`internal/crypt/key.go`, `internal/cryptvfs/vfs.go`, `internal/store/store.go`, `internal/ops/encrypt.go`, `cmd/form-md/main.go`, `cmd/form-md/tool.go` and `.docs/wiki/Encryption.md`), changing only names. As in form.md, encryption is on when FormLedger is given a key and off when it is not.
FormLedger can encrypt its data directory at rest with a 256-bit key that you hold outside the data directory. The wiring is ported from form.md (`internal/crypt/key.go`, `internal/cryptvfs/vfs.go`, `internal/store/store.go`, `internal/ops/encrypt.go`, `cmd/form-md/main.go`, `cmd/form-md/tool.go` and `.docs/wiki/Encryption.md`), changing only names. On a server, as in form.md, encryption is on when FormLedger is given a key and off when it is not. The desktop app makes and keeps its own key, so a desktop ledger is always encrypted (below).

**There is no recovery without the key.** If the key is lost, the ledger cannot be read by anyone, including you. Back the key up before you put data in.
**Losing the key loses the books.** There is no recovery without the key: if it is lost, the ledger cannot be read by anyone, including you. Back the key up before you put data in (see "Backing up the key").

## What is encrypted, and with what

Expand All @@ -21,7 +21,7 @@ The database, WAL and journal keys and the key check are derived from the one ma
- The WAL file header and each WAL frame header, and the `-shm` file.
- Tampering is not detected as such: XTS carries no authentication tag, so a page changed on disk decrypts to noise, which SQLite reports as a damaged database.
- Anything outside the data directory: memory, network traffic (use TLS), and any snapshot you write (below).
- Copies made before encryption was turned on. `formledger encrypt` converts only the data directory.
- Copies made before encryption was turned on, and the `formledger-plain-copy-*.db` that `formledger encrypt` keeps.

## Where the key is

Expand All @@ -32,7 +32,23 @@ FormLedger looks for the key in this order:

With neither, the ledger is stored plain and the server says so at start: `at-rest encryption off`. The key file holds 32 bytes written as 64 hex characters or as base64.

**On a desktop**, as in form.md, nothing makes a key for you. Make one and keep it outside the data directory, readable only by you:
**In the desktop app**, the app keeps its own key. When it starts its server and no `FORMLEDGER_KEY_FILE` is set, it hands the server `FORMLEDGER_KEY_HOME`, the app's own data folder (not the `~/FormLedger` books folder). The server then:

1. makes `formledger.key` in that folder once, readable and writable by you only (mode 0600 on macOS and Linux; on Windows the folder is under your user profile, which only your account can read), and logs `made this computer's FormLedger key` with the path and the warning that losing the key loses the books;
2. uses that same key on every later start;
3. if the books folder still holds a plain ledger from an earlier version, encrypts it before opening, keeping the plain database beside it as described in "Turning it on for an existing ledger", and logs where the copy is.

A fresh desktop install is therefore encrypted from its first database. (In this build the server side was run and checked; the shell's line that passes the folder, `engine_start::key_home` in `src-tauri/src/main.rs`, is written but the desktop app was not compiled for this version.) Where the app data folder is:

| System | Folder |
|---|---|
| macOS | `~/Library/Application Support/[app identifier]/` |
| Linux | `~/.local/share/[app identifier]/` |
| Windows | `%APPDATA%\[app identifier]\` |

The app identifier is `identifier` in `src-tauri/tauri.conf.json`, today `ai.nodemode.formledger`. Set `FORMLEDGER_KEY_FILE` before starting the app to use a key of your own instead; the app then makes none.

**Running the server yourself on a desktop**, make a key and keep it outside the data directory, readable only by you:

```
formledger keygen > ~/formledger.key && chmod 600 ~/formledger.key
Expand All @@ -51,6 +67,14 @@ LoadCredential=formledger.key:/etc/formledger/formledger.key

Copy the key file to somewhere that is not the data directory and not the same disk: a password manager or an offline drive. A backup of the data directory without the key is useless; a key kept beside the data directory protects nothing.

The key is one line of 64 hex characters, so it can be kept as text:

- **Password manager:** open the key file in a text editor (on the desktop, the `formledger.key` in the app data folder above), copy the line into a secure note, and check that the note shows the same 64 characters.
- **Offline drive:** copy the file, for example `cp ~/.local/share/[app identifier]/formledger.key /media/usb/`, and keep the drive apart from the computer.
- **To restore:** put the file back where it was with mode 0600 (`chmod 600 formledger.key`), or point `FORMLEDGER_KEY_FILE` at it.

Back the key up again only if you replace it; it never changes on its own. Every backup of the books (`~/FormLedger`) needs that key to open.

## Turning it on for an existing ledger

A key given to a plain ledger is refused, so a plain ledger is never opened as if it were encrypted:
Expand All @@ -65,7 +89,18 @@ Stop FormLedger, then run:
FORMLEDGER_KEY_FILE=~/formledger.key formledger encrypt
```

It copies the database with `VACUUM INTO` to `formledger.db.encrypting` through the encrypting VFS, opens the copy and runs `PRAGMA integrity_check`, and only when that says `ok` renames the copy over `formledger.db` and writes `encryption.json`. If anything fails, the copy is removed and the plain database is left as it was. As in form.md, the plain database is not kept after a successful swap: take a copy of the data directory first if you want one, and delete it once you have checked the encrypted ledger.
It copies the database with `VACUUM INTO` to `formledger.db.encrypting` through the encrypting VFS, opens the copy and runs `PRAGMA integrity_check`, and only when that says `ok` renames the copy over `formledger.db` and writes `encryption.json`. If anything fails, the copy is removed and the plain database is left as it was.

Unlike form.md, the old plain database is kept. Before the swap, `formledger encrypt` writes it with `VACUUM INTO` beside the ledger as `formledger-plain-copy-YYYY-MM-DD.db` (mode 0600). It never overwrites a copy that is already there: a second copy on the same day is `formledger-plain-copy-YYYY-MM-DD-2.db`, and so on. It then prints:

```
encrypted the database; start FormLedger with the same FORMLEDGER_KEY_FILE
the old plain database was kept at: /path/to/data/formledger-plain-copy-2026-11-27.db
This copy is NOT encrypted: anyone who can read the file can read your books. Delete it or move it somewhere safe once you are sure the encrypted ledger opens.
Losing the key loses the books: without it nobody can read this ledger, not even you. Back the key file up now to a password manager or an offline drive.
```

Run on a ledger that is already encrypted with the same key, it changes nothing and says so. The plain copy is in the clear, like a snapshot: once the encrypted ledger opens with the key, delete the copy or move it somewhere as safe as the key.

## Missing or wrong key

Expand Down
Loading
Loading