@lalalic/markcut 3.2.39 → 3.2.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lalalic/markcut",
3
- "version": "3.2.39",
3
+ "version": "3.2.40",
4
4
  "description": "Markdown-to-video engine. Describe scenes in markdown, get a rendered video.",
5
5
  "bin": {
6
6
  "markcut": "bin/markcut"
@@ -0,0 +1,156 @@
1
+ # Feature Specification: Preview Review Delivery (Text / Event)
2
+
3
+ **Library:** Markcut (`markcut.preview` and Neo Mobile review clients)
4
+ **Created:** 2026-11-05
5
+ **Status:** Proposed — specification only; not implemented
6
+ **Decision:** Use exactly two delivery modes, `text` and `event`. No callback registry, callback dispatcher, or Markcut-owned Relay workflow.
7
+
8
+ ## Goal and boundaries
9
+
10
+ Let the same Markcut Preview player collect human review decisions, scene/timestamp comments, and immutable video revision identity, then deliver that result through the caller's selected transport. Markcut owns preview/review interaction, not the decision about how to revise a video, resume an Agent, or advance a Relay Job.
11
+
12
+ - `text` (default): send the Review Result to the opening Agent conversation using the existing MCP App `ui/message` route.
13
+ - `event`: the caller supplies an event template to the Markcut Provider. On Submit, the Preview UI fills the review-only fields and publishes it through the existing authorized Events MCP tool. The event consumer (Relay or another application) decides what to do next.
14
+ - Neo Mobile supports the same two modes and the same Review Result. It uses its already authenticated Neo MCP connection for event delivery and its existing Agent-turn route for text delivery.
15
+ - Do not add `callback`, a callback dispatcher, a Markcut review inbox, or direct Relay SQLite/Graph access inside Markcut.
16
+
17
+ ## User stories and acceptance scenarios
18
+
19
+ ### US-1: Review a video in a direct Agent conversation (P1)
20
+
21
+ 1. Given `markcut.preview({path})` without delivery options, when the viewer submits `approved` or `changes_requested`, then one structured Review Result is sent with `ui/message` to the opening conversation.
22
+ 2. Given unsaved scene/timestamp comments, when the viewer requests changes, then submission requires explicit actionable feedback and includes the selected scene/time context.
23
+ 3. Given a superseded revision, when a viewer tries to submit, then the UI refuses and displays the historical/read-only state; an old approval never approves newer content.
24
+
25
+ ### US-2: Publish human review as a caller-owned Event (P1)
26
+
27
+ 1. Given a Preview created with `delivery: "event"` and a valid provider-bound `eventTemplate`, when the viewer submits, then the UI fills only the reserved review payload fields and calls the authorized Events MCP publish tool.
28
+ 2. Given a successful publish acknowledgement, when the UI reports completion, then it says the feedback was **submitted**, not that Relay processed it or that an Agent fixed the video.
29
+ 3. Given a temporary publish error or lost acknowledgement, when submission is retried, then the same stable idempotency key is reused; the downstream consumer must deduplicate equivalent review decisions.
30
+ 4. Given missing event-tool access, invalid authorization/template, or a stale revision, when the viewer submits, then the UI reports a failure and does not silently fall back to `text` or claim success.
31
+
32
+ ### US-3: Submit the same review from Neo Mobile (P1)
33
+
34
+ 1. Given a mobile review request carrying `delivery` and the frozen event template, when the user taps Approve or Request Changes, then Neo Mobile sends the same schema as the web Preview via its authenticated `events publish` tool.
35
+ 2. Given `text`, when the user submits, then Neo Mobile uses the owning Agent's supported New Turn route without requiring Relay.
36
+ 3. Given intermittent connectivity, when a queued review is retried after reconnect or relaunch, then the original request ID, video identity and idempotency key are preserved.
37
+ 4. Given a new published video revision, when the user views history, then approval of an older revision remains scoped to that older `contentHash` and `revisionId`.
38
+
39
+ ## Public contract (proposed)
40
+
41
+ ### Preview request
42
+
43
+ ```js
44
+ // Default: text mode; backward compatible.
45
+ markcut.preview({ path: "/absolute/video.md" });
46
+
47
+ // Event mode: caller supplies the template; Provider binds it to this preview.
48
+ markcut.preview({
49
+ path: "/absolute/video.md",
50
+ review: {
51
+ delivery: "event",
52
+ eventTemplate: {
53
+ type: "markcut.review.submitted",
54
+ source: "job/<job-id>/task/<task-id>/execution/<execution-id>",
55
+ data: { correlation: { /* caller-owned opaque values */ } }
56
+ }
57
+ }
58
+ });
59
+ ```
60
+
61
+ The event `source` above illustrates a caller-provided Relay execution identity, **not** a value invented by Markcut or the UI. The caller is responsible for establishing this identity and its permission to emit the review event. For standalone callers, use the authorized source scheme supported by the selected event service. The template is a delivery envelope, not executable code.
62
+
63
+ ### Provider → UI / mobile
64
+
65
+ The Provider freezes the delivery choice, event template (if any), and preview identifiers with the published immutable revision. Both clients receive the identical logical configuration. Delivery changes require a new authorized preview request; the UI must not choose its own event destination, event type, source, or correlation fields.
66
+
67
+ ### Normalized Review Result
68
+
69
+ ```json
70
+ {
71
+ "requestId": "review-request-id",
72
+ "previewId": "preview-id",
73
+ "revisionId": "immutable-revision-id",
74
+ "contentHash": "64-character-sha256-hex",
75
+ "decision": "changes_requested",
76
+ "comments": [
77
+ { "sceneId": "opening", "timeSeconds": 3.2, "text": "Shorten the opening by two seconds" }
78
+ ],
79
+ "idempotencyKey": "stable-per-submission-key"
80
+ }
81
+ ```
82
+
83
+ `decision` is either `approved` or `changes_requested`. Approved reviews do not include unsent draft comments. Keep existing overall-comment and playback-context fields where applicable; this example shows the minimum scene-specific data, not a replacement for richer existing comment structures. Review Result schema must be identical in `text` and `event` modes.
84
+
85
+ ### Event publish envelope
86
+
87
+ The Provider's event template owns `type`, `source` and any fixed `data` fields. On Submit, the client attaches the normalized Review Result under `data.review` **without overwriting template-owned fields**, then publishes through the existing Events MCP interface:
88
+
89
+ ```json
90
+ {
91
+ "command": "publish",
92
+ "args": {
93
+ "type": "markcut.review.submitted",
94
+ "source": "<trusted-caller-source>",
95
+ "data": {
96
+ "correlation": { "...": "caller-owned" },
97
+ "review": { "decision": "changes_requested", "revisionId": "...", "contentHash": "...", "comments": [], "idempotencyKey": "..." }
98
+ }
99
+ }
100
+ }
101
+ ```
102
+
103
+ The Neo MCP command façade accepts `events` with `command: "publish"` and `args: {type,source,data}`; the standalone Events MCP provider exposes `publish({type,source,data})`. The UI must call the actually available, authorized MCP interface. Browser MCP App availability of the Events tool must be verified before promising Event mode; no arbitrary HTTP URL or shell command may be specified as an event target.
104
+
105
+ ## Functional requirements
106
+
107
+ - **FR-001**: Preserve `text` as the default and existing `ui/message` behavior for old `markcut.preview` callers.
108
+ - **FR-002**: Support explicit `review.delivery` values `text` and `event` only; reject unknown values and Event mode without a valid event template.
109
+ - **FR-003**: On Approve or Request Changes Submit (not on every comment edit), collect and normalize the review once and deliver via the selected transport.
110
+ - **FR-004**: Bind `previewId`, `revisionId`, `contentHash`, `delivery` and event template to the review request; prevent client mutation of protected event fields and reject obsolete revisions.
111
+ - **FR-005**: In Event mode, publish the provider-bound template with review fields via existing authenticated Events MCP capability. No Markcut-to-Relay internal dependency or callback registration.
112
+ - **FR-006**: Return a truthful receipt for *transport acceptance only*. Processing or Task/Agent completion remains the consumer's responsibility.
113
+ - **FR-007**: Persist a stable idempotency key with pending mobile feedback and reuse it on retries. Event consumers must deduplicate by request + revision + submission key; publishing multiple times must not cause repeated revisions.
114
+ - **FR-008**: Preserve current Neo Mobile inbox/grouping, video playback, queue and retry UX. Add `delivery` and `eventTemplate` to review request metadata, and route delivery using the selected mode.
115
+ - **FR-009**: Validate template source/type permissions server-side or at the authenticated event gateway; never trust a browser-provided Relay execution identity. Review events must not be accepted as `task.completed`, `task.failed`, or Final Reviewer approval events.
116
+ - **FR-010**: Preserve review and approval scope per exact immutable revision. A new video revision requires fresh human approval; an Agent review cannot substitute for it.
117
+ - **FR-011**: Make submission failures visible and retryable, with no success banner until an actual accepted receipt. Do not change delivery modes automatically on failure.
118
+ - **FR-012**: Preserve compatibility for existing Neo Mobile requests carrying legacy `ownerCallbackTool` / `ownerThreadID` while migrating new requests to the explicit two-mode contract; do not introduce a third public mode.
119
+
120
+ ## Ownership and downstream behavior
121
+
122
+ - **Markcut Provider**: compiles/publishes immutable media, binds review delivery metadata, validates preview revision state, provides review template to clients.
123
+ - **Markcut Preview UI**: gathers comments and decision, fills review fields, dispatches either text or event, displays honest receipt/failure state.
124
+ - **Neo Mobile**: displays the same review/revision, submits through its authenticated Neo MCP connection, retains offline retry state.
125
+ - **Caller/Event consumer**: owns authorization, durable business processing, any Relay Event → original Producer Agent continuation, rereview, workflow transitions, and video delivery. `markcut.review.submitted` is domain input, **not** Relay task-completion authority.
126
+
127
+ ## Edge cases and compatibility
128
+
129
+ - Published revision superseded while the video is open; duplicated taps, replayed queued submissions, lost ACK, and device offline/relaunch.
130
+ - Absent or unauthorized Events MCP tool in an embedded ChatGPT iframe; show an explicit unsupported-delivery error rather than covertly changing modes.
131
+ - Invalid/forged template, conflicting reserved payload keys, insufficient execution identity, cancelled/superseded Relay Job, and denied publish permissions.
132
+ - Review feedback submitted in ChatGPT but separately approved on mobile; downstream caller resolves competing decisions using version binding and its own policy.
133
+ - Failed preview compilation must not cancel previously published immutable preview resources or falsely authorize human approval.
134
+
135
+ ## Verification and success criteria
136
+
137
+ 1. **Web**: default text, explicit text, event request and actual authorized Events MCP publish each deliver one verifiable review result. No Event publish occurs before Submit.
138
+ 2. **Mobile**: both modes pass device-level submission and offline retry tests. An Event-mode review reaches a test consumer with unchanged template-owned fields and correct scene/timestamp comments.
139
+ 3. **Safety**: stale hashes, forged source/types, missing event capability and cancelled consumer contexts cannot be misreported as accepted or approved.
140
+ 4. **Idempotency**: duplicate submits and repeated transport delivery produce at most one consumer-side business decision per key.
141
+ 5. **Backward compatibility**: existing text-only ChatGPT preview and existing Neo Mobile feedback requests continue to work; no callback dispatcher is required.
142
+ 6. **End-to-end evidence**: actual hosted Preview and iPhone submissions are tested separately. Published/queued receipts alone do not prove downstream Relay execution, a fixed video, or final delivery.
143
+
144
+ ## Non-goals
145
+
146
+ - Implementing an Event Bus, callback dispatcher, polling review inbox, or a Markcut-specific review database.
147
+ - Allowing the browser to execute shell commands, arbitrary URLs, or unrestricted events.
148
+ - Making Markcut decide how Relay revises, reruns, approves, or merges Tasks.
149
+ - Treating human Preview approval as Relay Final Reviewer approval.
150
+
151
+ ## Implementation notes to validate before coding
152
+
153
+ - Today's Markcut Provider accepts `path` and optional `relay` metadata; it does **not yet** accept the proposed `review` option.
154
+ - Today the hosted player delivers through `ui/message`; today Neo Mobile uses an `ownerCallbackTool` / Agent-turn fallback. Both need migration to the two-mode configuration.
155
+ - The Neo Events Bus has a `publish` MCP tool, with a separate `events` command façade. Verify that the hosted MCP App is permitted to invoke the authorized event tool through its actual Host before implementing a direct UI publish route. If not supported, treat that as an integration constraint to resolve without creating a generic callback framework by default.
156
+ - Current Events Bus assigns transport `event_id` internally; place caller-side idempotency in `data.review.idempotencyKey` and enforce deduplication at the consumer.