feat(engine): harden mailbox CLIs for v0.2.0

- Atomic delivery: create the temp file inside the destination dir
  (dot-prefixed, invisible to the inbox glob) so the final rename never
  crosses filesystems and readers never see a half-written message.
- Reject . and .. explicitly in the --reply-to and coord-done name
  guards instead of relying on downstream failure.
- Add -h/--help to coord-inbox.sh (uniform across the three CLIs).
- Close selftest gaps: default mailbox path via HOME fallback, malformed
  frontmatter on the read path, read-only destination dir. 48 -> 64
  checks, all green.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018fduZz8otpU3W3rhfoPD6t
This commit is contained in:
Kjell Tore Guttormsen 2026-07-24 19:57:40 +02:00
commit 0a79e786fc
9 changed files with 80 additions and 26 deletions

View file

@ -9,7 +9,7 @@ marketplace plugin. Three components, one boundary:
grammar, frontmatter, delivery, archiving, the seen set. `coord-send.sh`
writes, `coord-inbox.sh` reads (formatted for context injection),
`coord-done.sh` archives. Everything is pinned by `coord-selftest.sh`
(48 checks, throwaway mailbox via `CLAUDE_COORD_DIR`).
(64 checks, throwaway mailbox via `CLAUDE_COORD_DIR`).
- **Hook (`hooks/scripts/session-start.mjs`):** thin zero-dependency Node
wrapper (marketplace convention: hooks are `.mjs`) that calls
`coord-inbox.sh` and emits the `hookSpecificOutput.additionalContext`
@ -30,7 +30,7 @@ and frames it; the send side sanitizes line-oriented fields.
- Zero dependencies everywhere: bash + coreutils in the engine, `node:`
builtins only in hook and tests.
- TDD: no behavior change without a failing selftest check first.
`bash scripts/coord-selftest.sh` must exit 0 (48/48).
`bash scripts/coord-selftest.sh` must exit 0 (64/64).
- English for all code, docs, and commit messages (public repo). Norwegian
trigger aliases in the skill description are deliberate.
- Conventional Commits: `type(scope): description`.
@ -49,11 +49,8 @@ README version badge, `skills/coord-send/SKILL.md` frontmatter, git tag
the catalog's `scripts/release-plugin.mjs coord` (tag + ref bump together);
verify with `scripts/check-versions.mjs`. Never hand-edit a ref.
## Hardening roadmap (queued, post-v0.1.0)
## Hardening roadmap
- Atomic delivery: `mktemp` inside the destination dir so rename never
crosses filesystems.
- Explicit `.`/`..` rejection in `--reply-to`/`coord-done` guards.
- Selftest gaps: default mailbox path (unset `CLAUDE_COORD_DIR`), malformed
frontmatter on the read path.
- Uniform `-h` across the three CLIs (`coord-inbox.sh` lacks it).
Empty — the post-v0.1.0 queue (atomic delivery, `.`/`..` rejection,
selftest gaps, uniform `-h`) shipped in v0.2.0. `coord-inbox.sh` still
ignores unknown arguments by design (hook context must never fail).