Skip to content

Make as optional for <Git.Commit> #751

Description

@taras

Story

As someone committing staged changes from an executable document, I want to omit as when I do not need the new commit's object ID, so the common commit form does not require an otherwise unused binding.

Example

This ordinary run creates a commit whose message comes from the component's content:

xmd run -e '<Git.Commit>Adding AGENTS.md</Git.Commit>'

It succeeds without rendering or binding the commit ID.

An author who needs that ID can still capture it:

<Git.Commit as="commitId">Adding AGENTS.md</Git.Commit>

Current gap

<Git.Commit> returns the new commit's full object ID, and the general value-component rule currently requires every returned value to be captured with as. As a result, the first example is refused before the commit runs:

<Git.Commit /> declares `returns`, so it renders nothing and must be invoked with `as`: <Git.Commit as="binding" />.

Creating the commit is the component's primary outcome. Its object ID is an optional receipt for documents that need to refer to it later, so requiring every caller to invent and retain a binding makes the less common form mandatory. The syntax catalog already describes <Git.Commit>'s as as optional, but validation and execution do not honor that contract.

Contract

as is optional for <Git.Commit> in ordinary and workflow runs, for both its self-closing and paired forms.

Without as, <Git.Commit> performs the same commit operation and renders nothing. The new commit's object ID is validated at the component boundary and then discarded by the caller.

With as, the existing behavior remains: the binding receives the new commit's full object ID and the component renders nothing.

The component's message rules do not change. A message may come from the message prop, rendered content, or both, and paired content finishes expanding before the commit begins.

Optional capture is an explicit part of a component's contract, not a relaxation for every component that declares returns. Value-only components whose result is their primary outcome, such as <Glob>, continue to require as. Static document validation, runtime expansion, and xmd syntax read the same capture requirement.

Git staging, identity, signing, hooks, transaction, replay, journaling, and failure behavior do not change. In particular, a workflow run retains the successful Git effect whether or not the document binds its returned object ID.

Acceptance

  • <Git.Commit>Adding AGENTS.md</Git.Commit> creates the commit without an as diagnostic, renders nothing, and uses Adding AGENTS.md as the commit message.
  • <Git.Commit message="Adding AGENTS.md" /> creates the same commit without requiring a binding.
  • <Git.Commit as="commitId">Adding AGENTS.md</Git.Commit> continues to bind the resulting full object ID.
  • Ordinary runs and workflow runs accept the unbound forms and retain their existing Git behavior.
  • xmd validate accepts an otherwise valid unbound <Git.Commit> invocation.
  • A value-only component such as <Glob> is still refused without as.
  • xmd syntax Git.Commit describes as as optional, matching validation and execution.
  • architecture.md, specs/workflow-workspace-spec.md, and the value-component contract in specs/executable-mdx-spec.md describe optional result capture without weakening components that still require it.

Evidence

Run the focused component, validation, ordinary-run, workflow, and syntax suites:

deno task test packages/core/tests/document-validation.test.ts packages/workflow/tests/git-commit.test.ts packages/workflow/tests/run-composition-ambient.test.ts packages/cli/tests/inline-cli.test.ts packages/cli/tests/syntax-cli.test.ts

The regression evidence includes paired and self-closing commits without as, capture when requested, an unbound value-only negative control, and agreement between validation, execution, and syntax inspection.

Related

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    UXUser-facing usability and interaction improvements

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions