martha declare --from <file>: lazymartha's editor tab saves through Martha's one guard #368

Closed
opened 2026-12-02 12:20:02 +00:00 by hygiea · 4 comments
Member

Purpose (feature): a caller other than the editor itself can save a proposed declaration through Martha's one guard, so lazymartha's editor tab (martha-ai/lazymartha#14, package 4) saves by running martha declare --from <file> and never writes martha.json itself.

Ruling: Supervisor, on lazymartha#14 (relayed by Mars). Builder: Hygiea. Reviewer: Jupiter (it writes the declaration). Base: martha main 28b8909b (PR 366 landed).

The command

martha declare --from <file>

Exit codes:

  • 0 — the file was read, validated and written over .martha/martha.json.
  • 1 — refused: the reason on stderr, and .martha/martha.json untouched.
  • 2 — usage: declare any other way than --from <file>.

One guard, not a second copy

martha config's save loop (src/run_the_martha_command/configure_the_crew.ts) guards a save twice:

  • the reader, whyTheProposedIsRefused -> declareCrew(...) with the proposed text in place of the declaration;
  • the writer, writeAChangedDeclaration(root, {before, after}), which refuses when the declaration no longer holds the bytes the change was made from.

martha declare --from calls both, unchanged. whyTheProposedIsRefused becomes exported and is imported here; nothing of it is repeated. (The handshake in run_the_lazymartha_editor.ts only carries the editor's exit; the guard itself is in configure_the_crew.ts.)

Done when

  1. Accept: martha declare --from <file> with a declaration the reader accepts replaces .martha/martha.json with the file's bytes and exits 0, printing the one line the owner reads.
  2. Refuse unchanged: a file the reader refuses (not JSON, not a crew, an unknown member field) exits 1 with the reader's own reason on stderr, and .martha/martha.json holds the exact bytes it held before.
  3. Moved-declaration refusal: when .martha/martha.json is written between this command's read and its write, the save is refused, exits 1, names the declaration, and the declaration is left as the other writer left it.
  4. The same guard: the reader and the writer above are the ones used, each reached by a test that fails when its guard is removed.
  5. No crew declared under root: refused with the line martha config gives, exit 1.
  6. <file> missing or unreadable: refused, exit 1, naming the file.
  7. The whole npm test passes, and npm run typecheck.

Files

  • src/run_the_martha_command/run_the_martha_command.ts — USAGE, HELP, the declare parser (ACTS_OF_THEIR_OWN) and its dispatch (ACTS_IN_A_PROJECT)
  • src/run_the_martha_command/configure_the_crew.ts — export whyTheProposedIsRefused (no behaviour change)
  • src/save_a_declaration_the_owner_proposed/save_a_declaration_the_owner_proposed.ts — new slice: read the file, validate through the reader, write through the guarded write
  • src/save_a_declaration_the_owner_proposed/save_a_declaration_the_owner_proposed.node-test.ts — the tests
  • src/run_the_martha_command/run_the_martha_command.node-test.ts — the parser and dispatch cases

Harm each change could do

  • This is the command that writes the declaration, so a hole here writes the crew members start from. Both guards stand: nothing is written that declareCrew did not accept, and nothing is written over a declaration that moved.
  • --from reads a path the caller names. It writes nothing there and copies no files: the only path written is .martha/martha.json.

Refs martha-ai/lazymartha#14

Purpose (feature): a caller other than the editor itself can save a proposed declaration through Martha's one guard, so lazymartha's editor tab (martha-ai/lazymartha#14, package 4) saves by running `martha declare --from <file>` and never writes `martha.json` itself. Ruling: Supervisor, on lazymartha#14 (relayed by Mars). Builder: Hygiea. Reviewer: Jupiter (it writes the declaration). Base: martha main 28b8909b (PR 366 landed). ## The command ``` martha declare --from <file> ``` Exit codes: - `0` — the file was read, validated and written over `.martha/martha.json`. - `1` — refused: the reason on stderr, and `.martha/martha.json` untouched. - `2` — usage: `declare` any other way than `--from <file>`. ## One guard, not a second copy `martha config`'s save loop (`src/run_the_martha_command/configure_the_crew.ts`) guards a save twice: - the **reader**, `whyTheProposedIsRefused` -> `declareCrew(...)` with the proposed text in place of the declaration; - the **writer**, `writeAChangedDeclaration(root, {before, after})`, which refuses when the declaration no longer holds the bytes the change was made from. `martha declare --from` calls both, unchanged. `whyTheProposedIsRefused` becomes exported and is imported here; nothing of it is repeated. (The handshake in `run_the_lazymartha_editor.ts` only carries the editor's exit; the guard itself is in `configure_the_crew.ts`.) ## Done when 1. **Accept:** `martha declare --from <file>` with a declaration the reader accepts replaces `.martha/martha.json` with the file's bytes and exits 0, printing the one line the owner reads. 2. **Refuse unchanged:** a file the reader refuses (not JSON, not a crew, an unknown member field) exits 1 with the reader's own reason on stderr, and `.martha/martha.json` holds the exact bytes it held before. 3. **Moved-declaration refusal:** when `.martha/martha.json` is written between this command's read and its write, the save is refused, exits 1, names the declaration, and the declaration is left as the other writer left it. 4. **The same guard:** the reader and the writer above are the ones used, each reached by a test that fails when its guard is removed. 5. **No crew declared under root:** refused with the line `martha config` gives, exit 1. 6. **`<file>` missing or unreadable:** refused, exit 1, naming the file. 7. The whole `npm test` passes, and `npm run typecheck`. ## Files - `src/run_the_martha_command/run_the_martha_command.ts` — USAGE, HELP, the `declare` parser (`ACTS_OF_THEIR_OWN`) and its dispatch (`ACTS_IN_A_PROJECT`) - `src/run_the_martha_command/configure_the_crew.ts` — export `whyTheProposedIsRefused` (no behaviour change) - `src/save_a_declaration_the_owner_proposed/save_a_declaration_the_owner_proposed.ts` — new slice: read the file, validate through the reader, write through the guarded write - `src/save_a_declaration_the_owner_proposed/save_a_declaration_the_owner_proposed.node-test.ts` — the tests - `src/run_the_martha_command/run_the_martha_command.node-test.ts` — the parser and dispatch cases ## Harm each change could do - This is the command that writes the declaration, so a hole here writes the crew members start from. Both guards stand: nothing is written that `declareCrew` did not accept, and nothing is written over a declaration that moved. - `--from` reads a path the caller names. It writes nothing there and copies no files: the only path written is `.martha/martha.json`. Refs martha-ai/lazymartha#14
Author
Member

Built on 28b8909b. Two choices go past the words of the issue; both are named here for the reviewer:

  1. The mesh servers line. A save through declare --from writes .claude/settings.json's mesh servers line exactly as martha config does when the declaration declares a mesh and the file is not there yet (martha#191). Without it the same declaration, saved two ways, gives two crews — and the one saved by an editor tab has no mesh server to start. One line, calling the same function; say the word and it comes out.
  2. Words other than --from <file> say the usage (exit 2). They are read as no file at all, and the act answers usage: martha declare --from <file> on stderr. It is the act and not the parser on purpose: a parser refusal answers before the floor's line, which every act that parses at all is owed (every_act_is_held_to_the_floor.node-test.ts). Left to the usual fallback, martha declare alone would be read as start declare and answer "no member declare", which reads as a crew problem rather than a call problem.

Files, as built (the issue named a new slice directory; the two saves' glue belongs together instead):

  • src/run_the_martha_command/declare_the_crew_a_file_asks_for.ts — the save: read the file, whyTheProposedIsRefused, writeAChangedDeclaration, name the save.
  • src/run_the_martha_command/the_declaration_acts.ts — the two saves (config, declare) as the command table dispatches them, with their help lines and declareOf. run_the_martha_command.ts is at its 1105-line cap (eslint.config.mjs) and cannot take the entries; this is the extraction that fits them.
  • src/run_the_martha_command/configure_the_crew.ts — refusedHere, whyNotHere and whyTheProposedIsRefused exported, no behaviour change. One reader, one writer, no second copy.
  • src/run_the_martha_command/run_the_martha_command.ts — USAGE, and a spread in each of the three tables.
  • src/run_the_martha_command/declare_the_crew_a_file_asks_for.node-test.ts — six cases: accept, not-JSON refused unchanged, JSON-that-is-no-crew refused unchanged, moved-declaration refused, no crew declared, file unreadable.
  • src/run_the_martha_command/run_the_martha_command.node-test.ts — the parser, the exit codes end to end, and the help and usage lines.

Each guard is reached by a test that fails without it, run as a mutant:

  • reader guard removed (if (refused !== undefined && false)): the two "refused unchanged" cases fail, 4 pass.
  • moved-declaration comparison removed (if (false && textNow(...) !== change.before)): the moved case fails, 5 pass.

Two load-shaped reds on the first whole-suite run, both green alone afterwards and neither touching the declaration: a file stuck in a sync loop ends when its run is sent SIGTERM (10043 ms against a 10 000 ms bound) and a beat is written whole … (test 1) (60 s test timeout), on a 963 s run. The one real red on that run was mine — the floor's line skipped by a parser refusal — and is fixed above.

npm run typecheck, npm run lint and npm run verify are green on the tip, and the whole npm test on it is clean: 5991 tests, 5953 pass, 0 fail, 0 cancelled, 38 skipped, and the installer job's 170 steps pass.

Built on 28b8909b. Two choices go past the words of the issue; both are named here for the reviewer: 1. **The mesh servers line.** A save through `declare --from` writes `.claude/settings.json`'s mesh servers line exactly as `martha config` does when the declaration declares a mesh and the file is not there yet (martha#191). Without it the same declaration, saved two ways, gives two crews — and the one saved by an editor tab has no mesh server to start. One line, calling the same function; say the word and it comes out. 2. **Words other than `--from <file>` say the usage (exit 2).** They are read as no file at all, and the act answers `usage: martha declare --from <file>` on stderr. It is the act and not the parser on purpose: a parser refusal answers before the floor's line, which every act that parses at all is owed (`every_act_is_held_to_the_floor.node-test.ts`). Left to the usual fallback, `martha declare` alone would be read as `start declare` and answer "no member declare", which reads as a crew problem rather than a call problem. Files, as built (the issue named a new slice directory; the two saves' glue belongs together instead): - `src/run_the_martha_command/declare_the_crew_a_file_asks_for.ts` — the save: read the file, `whyTheProposedIsRefused`, `writeAChangedDeclaration`, name the save. - `src/run_the_martha_command/the_declaration_acts.ts` — the two saves (`config`, `declare`) as the command table dispatches them, with their help lines and `declareOf`. `run_the_martha_command.ts` is at its 1105-line cap (eslint.config.mjs) and cannot take the entries; this is the extraction that fits them. - `src/run_the_martha_command/configure_the_crew.ts` — `refusedHere`, `whyNotHere` and `whyTheProposedIsRefused` exported, no behaviour change. One reader, one writer, no second copy. - `src/run_the_martha_command/run_the_martha_command.ts` — USAGE, and a spread in each of the three tables. - `src/run_the_martha_command/declare_the_crew_a_file_asks_for.node-test.ts` — six cases: accept, not-JSON refused unchanged, JSON-that-is-no-crew refused unchanged, moved-declaration refused, no crew declared, file unreadable. - `src/run_the_martha_command/run_the_martha_command.node-test.ts` — the parser, the exit codes end to end, and the help and usage lines. Each guard is reached by a test that fails without it, run as a mutant: - reader guard removed (`if (refused !== undefined && false)`): the two "refused unchanged" cases fail, 4 pass. - moved-declaration comparison removed (`if (false && textNow(...) !== change.before)`): the moved case fails, 5 pass. Two load-shaped reds on the first whole-suite run, both green alone afterwards and neither touching the declaration: `a file stuck in a sync loop ends when its run is sent SIGTERM` (10043 ms against a 10 000 ms bound) and `a beat is written whole … (test 1)` (60 s test timeout), on a 963 s run. The one real red on that run was mine — the floor's line skipped by a parser refusal — and is fixed above. `npm run typecheck`, `npm run lint` and `npm run verify` are green on the tip, and the whole `npm test` on it is clean: 5991 tests, 5953 pass, 0 fail, 0 cancelled, 38 skipped, and the installer job's 170 steps pass.
Author
Member

PASS r=1 at a5785b60 (Jupiter, relayed by Mars). The tip does not change; Terra lands it in the land-PR round after batch 371.

Jupiter's four notes, none blocking, kept here so they outlive the package:

  1. No test feeds a declaration with an unknown member field. (The reader notes an unknown field rather than refusing it, so a case would pin that it is a note and not a refusal.)
  2. The mesh servers line (declare_the_crew_a_file_asks_for.ts:53) has no test in this slice — it is the one behaviour added past the issue, and it is tested only through config.
  3. <file> is read as given, not resolved against io.cwd as pin-key resolves its file, so a caller passing a relative path depends on its own working directory.
  4. A file whose name starts with - is read as the usage, and so cannot be saved.

Each wants a decision before it is code: 1 and 2 are tests, 3 is a call-shape choice that Titan's tab has to agree with, 4 bounds what <file> may be named.

PASS r=1 at a5785b60 (Jupiter, relayed by Mars). The tip does not change; Terra lands it in the land-PR round after batch 371. Jupiter's four notes, none blocking, kept here so they outlive the package: 1. No test feeds a declaration with an unknown member field. (The reader notes an unknown field rather than refusing it, so a case would pin that it is a note and not a refusal.) 2. The mesh servers line (`declare_the_crew_a_file_asks_for.ts:53`) has no test in this slice — it is the one behaviour added past the issue, and it is tested only through `config`. 3. `<file>` is read as given, not resolved against `io.cwd` as `pin-key` resolves its file, so a caller passing a relative path depends on its own working directory. 4. A file whose name starts with `-` is read as the usage, and so cannot be saved. Each wants a decision before it is code: 1 and 2 are tests, 3 is a call-shape choice that Titan's tab has to agree with, 4 bounds what `<file>` may be named.
Author
Member

r=2: main moved under the package, so hygiea/368-declare-from is merged with origin/main (dc3fa0e6) in a normal merge, tip c8eaed05. The package itself is unchanged from a5785b60; what a reviewer reads is the merge diff.

Main extracted HELP and USAGE into the_help_the_command_prints.ts (#369) — which is exactly where one conflict was. So declare's help line and its usage fragment now sit there beside config's, and the_declaration_acts.ts keeps only the parser and the acts (my earlier note above says it holds the help lines; that moved). The test file keeps both sides: the declare parser test, then #364's room tests.

run_the_martha_command.ts is 1087 lines, under its 1105 cap. On c8eaed05: typecheck, lint, verify and the whole npm test are clean (5998 tests, 5960 pass, 0 fail, 0 cancelled, 38 skipped; installer steps 170/170).

r=2: main moved under the package, so `hygiea/368-declare-from` is merged with origin/main (dc3fa0e6) in a normal merge, tip c8eaed05. The package itself is unchanged from a5785b60; what a reviewer reads is the merge diff. Main extracted HELP and USAGE into `the_help_the_command_prints.ts` (#369) — which is exactly where one conflict was. So `declare`'s help line and its usage fragment now sit there beside `config`'s, and `the_declaration_acts.ts` keeps only the parser and the acts (my earlier note above says it holds the help lines; that moved). The test file keeps both sides: the `declare` parser test, then #364's room tests. `run_the_martha_command.ts` is 1087 lines, under its 1105 cap. On c8eaed05: typecheck, lint, verify and the whole `npm test` are clean (5998 tests, 5960 pass, 0 fail, 0 cancelled, 38 skipped; installer steps 170/170).
Author
Member

LANDED: hygiea/368-declare-from c8eaed05 via land PR 373 onto main b2b1f961 (fast-forward). CI round 7005-7008 green. Verified before closing: main's tip is "Land martha-ai/martha#368 (PASS r=2)" and c8eaed05 is an ancestor of it.

martha declare --from <file> is now on main: a proposed declaration is saved through the same reader and writer martha config uses, refused with its reason on stderr and exit 1 leaving martha.json untouched, and the words for anything but --from <file> say the usage (exit 2).

Jupiter's four non-blocking notes (comment 8555) are not in this package: the unknown-member-field test, a test for the mesh servers line in this slice, resolving <file> against io.cwd, and the --leading name. They are the follow-up's to pick up.

LANDED: hygiea/368-declare-from c8eaed05 via land PR 373 onto main b2b1f961 (fast-forward). CI round 7005-7008 green. Verified before closing: main's tip is "Land martha-ai/martha#368 (PASS r=2)" and c8eaed05 is an ancestor of it. `martha declare --from <file>` is now on main: a proposed declaration is saved through the same reader and writer `martha config` uses, refused with its reason on stderr and exit 1 leaving martha.json untouched, and the words for anything but `--from <file>` say the usage (exit 2). Jupiter's four non-blocking notes (comment 8555) are not in this package: the unknown-member-field test, a test for the mesh servers line in this slice, resolving `<file>` against `io.cwd`, and the `-`-leading name. They are the follow-up's to pick up.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
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/martha#368
No description provided.