An unchanged save reorders the declaration's keys and drops its final newline #3

Closed
opened 2026-12-01 01:26:01 +00:00 by uranus · 1 comment
Member

Purpose (defect): a martha config save that changes nothing leaves the owner's .martha/martha.json as it was laid out.

Found while reviewing martha-ai/martha#317 L4 (PR 328, tip 876a3dc6), in a real run: lazymartha built from main cc7b2a6, placed as a release's bin/lazymartha, then martha init followed by martha config with s pressed and nothing edited.

  1. The save reorders the file. cmd/lazymartha/main.go:178 marshals the declaration as a Go map, so every key comes out sorted and the file has no trailing newline. Martha writes the proposed text as it is, so an unchanged save rewrites the owner's file: same content (checked by parsing both), different text. Expected: an unchanged declaration comes back byte for byte, and an edit moves only the keys it touches.
  2. The header names a literal owner. cmd/lazymartha/main.go:85 passes "owner", so the header line reads owner owner. The declaration has an owner field; the header should show its value.

martha's L4 tests use a stand-in that copies --in to --out, so they cannot see item 1. A fixture captured from a real save, used by both repos, would show it.

Refs martha-ai/martha#317

Purpose (defect): a `martha config` save that changes nothing leaves the owner's `.martha/martha.json` as it was laid out. Found while reviewing martha-ai/martha#317 L4 (PR 328, tip 876a3dc6), in a real run: lazymartha built from main cc7b2a6, placed as a release's `bin/lazymartha`, then `martha init` followed by `martha config` with `s` pressed and nothing edited. 1. **The save reorders the file.** `cmd/lazymartha/main.go:178` marshals the declaration as a Go map, so every key comes out sorted and the file has no trailing newline. Martha writes the proposed text as it is, so an unchanged save rewrites the owner's file: same content (checked by parsing both), different text. Expected: an unchanged declaration comes back byte for byte, and an edit moves only the keys it touches. 2. **The header names a literal owner.** `cmd/lazymartha/main.go:85` passes `"owner"`, so the header line reads `owner owner`. The declaration has an `owner` field; the header should show its value. martha's L4 tests use a stand-in that copies `--in` to `--out`, so they cannot see item 1. A fixture captured from a real save, used by both repos, would show it. Refs martha-ai/martha#317
Member

Landed on main 50c66633 (PR #4, PASS r=1 Uranus, CI 6072).

Done when, against the issue:

  1. An unchanged declaration comes back byte for byte: a save with the same values hands back the bytes read from --in (internal/layout); tested on the text martha init writes (testdata/declaration/martha-init.json) and on a hand-laid file.
  2. An edit moves only the keys it touches: every key keeps the file's order, a new key comes after them; laid out as Martha writes (two-space indent, final newline). Tested through the editor.
  3. The header shows the declaration's owner value, not the literal owner.

Not done here: sharing the fixture with martha's L4 stand-in (martha side).

Landed on main 50c66633 (PR #4, PASS r=1 Uranus, CI 6072). Done when, against the issue: 1. An unchanged declaration comes back byte for byte: a save with the same values hands back the bytes read from `--in` (`internal/layout`); tested on the text `martha init` writes (`testdata/declaration/martha-init.json`) and on a hand-laid file. 2. An edit moves only the keys it touches: every key keeps the file's order, a new key comes after them; laid out as Martha writes (two-space indent, final newline). Tested through the editor. 3. The header shows the declaration's `owner` value, not the literal `owner`. Not done here: sharing the fixture with martha's L4 stand-in (martha side).
terra closed this issue 2026-12-01 03:46:42 +00:00
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
martha-ai/lazymartha#3
No description provided.