On this page

0293. Application Actions API v1.1 (app.actions/v1.1): Compact Catalogs, Batching, Dry-Run, Undo & derive Actions

Context

ADR-0292 established the pure-plugin app.actions/v1 control plane (state_delta, app_actions_trace, app_actions, app_actions_mcp, app_actions_tui) and deferred ergonomics codegen and specialized action-model work behind a Phase-3 Go/No-Go gate.

Measurements across three real applications (examples/tui/todo, todo-actions, and coding-harness-2) and the frozen 12-scenario benchmark (bench/app-actions/RESULTS.md) confirmed:

Decision

Extend app_actions and app_actions_mcp (remaining strictly pure with capabilities = [] and C/interp parity) with app.actions/v1.1 additions while preserving compatibility with existing app.actions/v1 callers:

  1. Fluent Pure Schema Builder (app_actions.schema) & Typed Argument Reader (app_actions.args):

    • schema_obj() returns an immutable ObjSchema builder (req_str, opt_str, req_i64, opt_i64, req_bool, opt_bool, req_enum, opt_enum, req_str_arr, opt_str_arr, to_json) guaranteed to emit "additionalProperties": false and pass mcp.wire.schema_supported(..., 0).
    • parse_args(args_json) returns a typed ArgsView wrapper around mcp.wire.object with req_str, opt_str, req_i64, opt_i64, req_bool, opt_bool, req_str_list, and opt_str_list.
  2. Compact Action Naming & Catalog Grammar (app_actions(format="compact")):

    • Recommend short 1–2 token dot-namespaced action names (<ns>.<verb>, e.g., t.new, t.split, t.run, td.add) and concise arg keys (id, dir, cmd, txt, q).
    • Add app_actions.contract.format_compact_catalog(specs, include_disabled) -> str emitting one deterministic line per action: name(arg1:str,arg2?:low|normal|high) [R|W|D|D!] — short desc with [OFF: reason] appended for disabled actions when include_disabled == true.
    • app_actions_mcp accepts optional "format": "full" | "compact" (default "full").
  3. Pure Immutability Superpowers in ActionSession<A> (app_actions.session):

    • Persisted revision start: new_session_at(app, initial_rev, cfg) starts a session at any initial_rev >= 1 (clamping values < 1 to 1) so restarts preserve monotonic state_rev.
    • Pure dry_run preview: execute_dry_run(s, call, presented_approval_id) validates expected_rev, action existence/enablement, mcp.wire arguments, and harness_policy (PolicyDenied fails closed), then runs pure app.apply, secret redaction, and state_delta.choose_wire_update without mutating s.app, s.rev, history, or metrics. For approval-gated actions (requires_approval or Effect.Ask), execute_dry_run computes the redacted delta preview with requires_approval: true so ADR-0225 approval dialogs can render exact diffs before human confirmation.
    • Immutable undo ring & monotonic rollback: ActionSession<A> retains a bounded ring rev_apps: vec<RevApp<A>> (capped at min(history_cap, 32)). undo(s) and rollback_to_rev(s, target_rev) restore the exact prior immutable app value A, compute the transition WireUpdate, and increment s.rev monotonically (never reusing prior revision numbers).
    • Transactional execute_batch: Executes 1..=16 calls sequentially against evolving immutable cur_app, checking expected_rev once up front and failing closed on empty or > 16-step batches. Returns a single coalesced WireUpdate from pre-batch to post-batch state and advances s.rev by 1 on commit:
      • On ApprovalRequired: returns BatchStatus.PausedForApproval(completed_count, pending_index, err) — committing prior safe steps when atomic == false (with a coalesced delta and updated current_rev), or rolling back cleanly when atomic == true.
      • On UnknownAction, DisabledAction, InvalidArgs, PolicyDenied, or ExecutionFailed: rolls back cleanly (rev and app unchanged, rolled_back: true) when atomic == true, or commits earlier completed steps when atomic == false, returning BatchStatus.Failed(completed_count, failed_index, err).
  4. Flat-Token 3-Tool MCP Extension (app_actions_mcp):

    • Retain the exact 3-tool surface (app_state, app_actions, app_act) and strict <= 900 combined schema token budget.
    • Extend app_actions with optional format ("full" | "compact").
    • Extend app_act with optional dry_run: boolean, batch: [{ name, args? }, ...], and atomic: boolean (default true), while preserving single-call name + args. Dry-run calls never mutate session state or emit executable host ActionEffects (McpServeReply.effects = [], state_changed = false).
  5. derive Actions Generator Boundary (Task C02):

    • Authorize a GEN_ABI 2 generator plugin (plugins/app_actions_gen) to generate mcp.wire-validated input_schema_json, typed decoders, base ActionSpecs, and compact catalogs from a single annotated enum.
    • Preserve ADR-0292 D1 and D4 by keeping curated project_state projections/windows and live state-dependent enabled/disabled_reason predicates as explicit pure .tn functions rather than raw struct reflection.

Alternatives Considered

Consequences