← Files Computable Systems EngineeringARCHIVED FILE
docs/workbench/composition-host-contract.md
9.52 KB · Dec 3, 2026 · 18:30 UTC
# Physical composition in Codex and ChatGPT This contract supports the active physical-composition capability. It does not admit another capability or replace the operation-level [parity ledger](parity.json). The existing [SVG and iconography requirements](composition-svg-fidelity.md) apply inside every host and export. A host adapter cannot substitute shapes, fonts, notation or selected engineering meaning to make its container work. ## Baseline and evidence boundary The qualified local implementation at `d37c51aad5f284a8f589dd7a70a2ab758bd50fdd` provides the native Git project, source-bound reader, role inspector and the admitted typed edits. The development protocol experiment delegates to that implementation; it adds neither a model nor an engineering verdict. The experiment uses MCP Apps 2.1.0 and MCP client/server/core/node 2.0.0 in a private build directory. It runs the official SDK bridge through a separate sandbox origin. This establishes a test environment, not actual Codex or ChatGPT behavior. The production SDK choice must account for the existing Python hosted server and retain upstream notices; the experiment does not require a second production engineering service. Read-only inspection of the preserved hosted implementation at `0e969d2f31e66ec31acc6fcc4b6e8137edad5262` identified a request workspace deleted at entry and exit, a shared compute coordinator and no persistent private composition project interface. Its existing deployment must remain intact. The new saved-project path cannot use that temporary workspace as authority. ## Shared operation and application boundary Use the existing native operation contracts for inspection, rename, finite multiplicity, checked layout, owned-definition creation, restoration and exact receipt lookup. Complete the remaining physical operations under their own ledger rows. Every interface must return the same independently computed native findings and publication outcome for the same input revision. The application provider needs four explicit responsibilities: | Responsibility | Required behavior | |---|---| | Request | Invoke the selected project's existing typed read, preview, apply and receipt paths; preserve native error codes and definitive-refusal information. | | Context | Publish project, view, UI session, commit, monotonic revision, bundle digest, selected UUID/occurrence, fixed draft target, pending exact request and unknown-save state. Retained review scope remains separately identified. | | Temporary state | Isolate each app instance's drafts and exact pending intent. A reopen/reload must either recover that intent or explicitly disclose that it cannot; another widget must never consume it. | | Artifact transfer | Deliver the exact requested source-bound artifact and manifest through a supported host route. Refusal, cancellation and unavailable transfer remain explicit. | The [shared application provider](composition-provider.md) now supplies this boundary around the existing controller, including an MCP client adapter. It retains the ordinary loopback provider and feature-detected Codex site adapter without intercepting global fetch/storage APIs. Complete the server, artifact-transfer and actual-host obligations against that same implementation; do not copy the controller or maintain a second model. Use focused MCP data tools, separate from the explicit open-view tool. A tool user without a rendered component must be able to obtain the project snapshot identity, read bounded source-bound occurrences, inspect complete retained review findings and submit the admitted edits. Pagination never reduces the required scope. Large SVG/font payloads belong in private UI metadata, not in model-visible summaries. Metadata is not authorization. This follows the [MCP tool guidance](https://developers.openai.com/plugins/build/mcp-server) and [MCP Apps UI contract](https://developers.openai.com/plugins/build/chatgpt-ui). The experiment's bounded state summary is insufficient as the final data-tool contract: complete findings and the bundle digest must remain available without opening the UI. Add those read operations before claiming MCP parity. ## Fidelity within a sandbox Serve a versioned static `ui://` resource; keep private project data in tool results. Bundle the application code while retaining original upstream notices. Continue rendering the native reader and original SVG masters, DejaVu Sans/Mono files, authored local key, exact swatches, textures and relationship treatments. Preserve readable-size scrolling and overview as separate navigation choices. Declare the resource, connection and nested-frame domains actually needed by the implementation. Test the host's enforced policy. The reference Chromium environment can render an internal `srcdoc` while refusing its embedded fonts; the presence of an iframe or SVG is therefore insufficient evidence. Keep the drawing hidden until the original fonts have loaded. On refusal, expose an explicit unsupported-view message and the applicable source-bound inspection; do not silently qualify a fallback drawing. Check candidate drawings and exports as well as the saved drawing. Source font coverage, successful font loads and actual glyph suppliers are distinct checks. Publish context after selection, form changes, preview, refusal, save, unacknowledged save, refresh and restoration. Serialize delivery and retain the latest unsent context after a bridge failure; only successful delivery advances the acknowledgement. Model context is advisory: native revision checks and the guarded UI operations remain decisive. ## Private saved-project persistence The first hosted acceptance is opening the same private composition in both applications and preserving it across compute termination. Implement only the support needed for that journey: 1. Validate the authenticated principal and project grant on every read, mutation, job, receipt and artifact request. Reject cross-project IDs before accessing sources. Keep storage paths, native session values and credentials out of browser/model results. Use the applicable [MCP OAuth contract](https://developers.openai.com/plugins/build/auth). 2. Reconstruct a compute cache from the published manifest and real Git objects. Verify exact source, registry, companion and artifact hashes before use. 3. Validate the typed operation against the supplied revision using the current Python/Java engine. Preserve unsupported syntax and original kit assets. 4. Upload immutable source/companion/Git objects and the candidate manifest. Atomically publish the project head and exact request receipt through the per-project coordinator only after those objects are durable. 5. Return committed only with that durable receipt. Unknown responses retain the original request ID and payload for lookup/retry. A stale command cannot overwrite a newer head. Restoration publishes a new monotonic revision. An interrupted upload must leave the old head readable. A crash after head publication but before response delivery must recover the original receipt without a second commit. A fresh compute process must reconstruct both cases from durable state, without relying on the previous container's disk. The existing 1.5-second local head poll implies 40 requests per minute per open widget, exceeding the preserved hosted worker's 30-request-per-minute limit before any edit. Qualify a capability-specific refresh/rate design with multiple widgets and both clients; do not carry this polling policy into deployment unchanged. Conditional reads or host subscriptions must preserve drafts and bind findings to the checked revision. Do not advertise subscriptions merely because an SDK offers them; the experiment uses JSON responses and polling. ## Required assembled acceptance Run these journeys against one assembled physical implementation. Record exact source revisions, dependency locks, project revisions, receipts, raw artifact hashes, rendered screenshots and inspected glyph suppliers. | Journey | Required independently expected outcome | |---|---| | Manual edit, then MCP edit | Both publish through the same native project; the saved diagram and complete retained findings match their source revision. | | Inherited role inspection | Native owner, selected parent and occurrence remain distinct; no ownership edge is invented. | | Lost save, reload, receipt and exact retry | Original target/request survives; the original receipt returns; revision advances once. | | Concurrent manual/agent edits | Stale publication refuses, draft remains recoverable and no newer source is overwritten. | | Preview/save/context delivery failure | Checked and unknown outcomes reach conversation context after recovery without silently retargeting a human draft. | | Strict host policy | Unsupported fonts/frame/transfer is explicit; an unqualified drawing or download never masquerades as success. | | Desktop and narrow view | Complete overview and readable navigation retain original text metrics, source-bound selection and formal notation. | | Export and restore | Exact source, registry, companions, used masters/fonts, Git history and manifest remain reconstructable; restoration is monotonic. | | Terminate compute, reopen elsewhere | Durable project and exact pending outcome survive in the other actual application, with correct account/project authorization. | The local SDK harness, synthetic site callbacks, actual Codex, actual ChatGPT browser/mobile and deployed storage/restart checks are separate evidence. Each operation remains open until its applicable cells pass. Complete the physical capability before substantive implementation of the next capability.
SHA-256: 5b3b04334743ef25d0161107e1217e0bfe60d843258f933d4823516088829506