Skip to content

fix(compile): honor author-declared mode: read on exec nodes (#165)#166

Merged
pawellisowski merged 2 commits into
mainfrom
fix/exec-mode-165
May 25, 2026
Merged

fix(compile): honor author-declared mode: read on exec nodes (#165)#166
pawellisowski merged 2 commits into
mainfrom
fix/exec-mode-165

Conversation

@pawellisowski
Copy link
Copy Markdown
Contributor

Summary

Fixes #165 — an author-declared node-level mode: read on a host exec node was silently overridden to mode: write at compile, with only a misleading "defaulting … for safety" note.

Root cause: Node (manifest/app.rs) had no mode field, so serde dropped the documented mode: declaration on parse. compile_node then hard-coded write for any command it couldn't resolve from the agent manifest (e.g. exec, whose read/write semantics are unknowable from the manifest alone).

This implements the issue's preferred option (1): honor it.

Changes

  • manifest/app.rs — add mode: Option<Mode> to Node so the author declaration survives deserialization.
  • app_lock.rs (compile_node) — when the command can't be inferred (command-not-found or agent-not-installed), honor node.mode before the write-mode default. The lock records the declared mode and the note states the declaration was honored (no misleading "defaulting" message). Absent any declaration, the prior safe write-mode default is unchanged.
  • runtime/orchestrator.rs (lookup_command_mode) — thread node.mode through so aware app run --dry-run / --simulate resolves the same mode as the lock, instead of short-circuiting a declared-read exec node as a would-write. (This second commit addresses a Codex review finding on the first.)

Test plan

  • compile_honors_author_declared_mode_on_unknown_command — lock records mode: read, no "defaulting" note.
  • compile_defaults_write_mode_on_unknown_command_without_declaration — regression guard: write-mode default still applies when no mode: is declared.
  • dry_run_honors_author_declared_read_mode_on_unknown_command — runtime treats a declared-read exec node as a read (no WouldWrite) under dry-run.
  • Full suite green (393 unit + all integration).
  • Codex review clean (no findings).

Node had no mode field so serde dropped node-level mode: read on parse.
compile_node then hard-coded write for any command not found in the
agent manifest (e.g. exec). Fix: add mode: Option<Mode> to Node and
check it before falling back to safe-default write-mode in both the
command-not-found and agent-not-installed branches. When the author
declares mode: read, the lock records read and notes the declaration
was honored; when no mode is declared, the prior safe default applies.
Two unit tests guard both sides. Also adds allow(dead_code) to the
pre-existing unused panel field in the same file.
Codex review on the compiler fix noted the lock recorded mode: read for
a declared exec node, but runtime::orchestrator::lookup_command_mode
still fell back to Mode::Write for the same unknown command — so under
aware app run --dry-run / --simulate the node was short-circuited as a
write, diverging from the lock it was compiled into.

Thread the node's declared mode into lookup_command_mode so it resolves
the otherwise-unknowable mode before the write-mode safety default,
mirroring compile_node exactly. Both dry-run/simulate call sites pass
node.mode. Adds a runtime test asserting a declared-read exec node is
NOT emitted as a would-write under dry-run.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Node-level mode: read on an exec node is silently overridden to write-mode at compile (no warning)

1 participant