Skip to content

feat(runtime): add document lifecycle commands and exact-byte persistence path - #2

Merged
m-mdy-m merged 14 commits into
mainfrom
feature/document-lifecycle-commands-host-1.0.0-rc.1
Nov 5, 2026
Merged

m-mdy-m merged 14 commits into
mainfrom
feature/document-lifecycle-commands-host-1.0.0-rc.1

Conversation

@m-mdy-m

@m-mdy-m m-mdy-m commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

Summary

Add the Runtime-owned document lifecycle needed by a live Frontend session while keeping all command/keymap policy in Runtime and all file I/O in the optional Backend Host service.

Changes

  • Add document.new, document.open and document.close commands.
  • Add Runtime default keymaps for create/save/undo/redo/close (Ctrl+N/S/Z/Shift+Z/W).
  • Keep Frontend input raw: physical keys and text are interpreted only by Runtime.
  • Open files through optional host.fs.read_file; absence fails closed with UNSUPPORTED.
  • Defer lifecycle UI publication to command dispatch so each lifecycle action emits one semantic snapshot rather than duplicate same-revision flushes.
  • Apply command-returned view_id focus centrally before UI publication for both explicit commands and keymap dispatch.
  • Preserve Backend IO_ERROR identity in Runtime's structured error vocabulary.
  • Add a standalone integration scenario for byte-preserving open/edit/paste/undo/redo/save/close/reopen, including BOM, NUL, invalid UTF-8, LF/CRLF/mixed terminators, missing/unsupported files, size limits, interrupted writes and failed commit cleanup.
  • Extend FakeHost filesystem behavior only for tests.

Baseline

This branch starts from the exact Runtime revision previously pinned by CDIN deps.lock (762aba7d5674149cae3a8f736d93159360fff730) rather than importing unrelated current-main changes.

Verification

  • CI run 42070467074: PASS on Linux Lua 5.5, macOS Lua 5.4 and Windows Lua 5.4.
  • Unit, integration, boundary and documentation/workflow checks all passed.
  • The dedicated integration scenario verifies exact-byte edits and failure cleanup with FakeHost.

CDIN now pins this tested Runtime head together with the merged Frontend TUI package and Backend 1.0.2. The headless CDIN document workflow is implemented and passed Linux pinned-stack E2E plus Linux ASan/UBSan/leak detection in CI run 42073127614; current-head macOS/Windows verification is still pending. This CDIN smoke does not replace FE-019 TUI readiness or rendering tests.

@m-mdy-m
m-mdy-m marked this pull request as ready for review November 5, 2026 17:07
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-05T17:13:27.999565Z 84379cb Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 84379cb7f8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

if not document then
return false, "no active document"
end
return runtime:_close_document(document.id, false)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Check dirty state before closing a document

When a document has unsaved edits, invoking this new command (including the newly bound Ctrl+W) unconditionally closes its Kernel handle and removes its views; no dirty-state check or confirmation runs, so the only canonical copy of those edits is discarded without a save/cancel choice. Guard dirty closes with a confirmation or explicit discard path rather than closing immediately.

AGENTS.md reference: AGENTS.md:L8-L9

Useful? React with 👍 / 👎.

-- FE-016 / PROTO-041: default editing shortcuts are Runtime policy. The
-- Frontend emits raw key events and never duplicates or interprets bindings.
runtime.keymap:bind("ctrl+n", "document.new", { owner = "core" })
runtime.keymap:bind("ctrl+s", "document.save", { owner = "core" })

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Surface a missing save capability on Ctrl+S

For a path-backed document on a Host without begin_atomic_write, document.save is filtered out by its available predicate before Saver:save can raise UNSUPPORTED, so this new Ctrl+S binding returns unhandled instead of the documented unsupported-capability error. Keep the command executable when the writer is absent so it can return UNSUPPORTED, or surface that typed result from the binding.

Useful? React with 👍 / 👎.

@m-mdy-m
m-mdy-m merged commit dddebe0 into main Nov 5, 2026
5 checks passed
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.

1 participant