Repository navigation
Complete V1.Dev exact-JSON SDK APIs #1412
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Gudge (MGudgin)
wants to merge
1
commit into
main
Choose a base branch
from
user/gudge/json_dev_apis
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| # .NET V1.Dev exact-JSON API | ||
|
|
||
| Public namespace: `Microsoft.Mxc.Sdk.V1.Dev`. All methods accept one complete | ||
| caller-authored exact-version JSON string; they do not stamp a version, parse | ||
| through typed V1, or take a duplicate container ID. Native exact parsing | ||
| rejects unregistered versions and unknown fields. Phase-specific methods | ||
| check the JSON phase before calling native code. | ||
|
|
||
| `JsonOptions.Experimental` authorizes an experimental backend independently | ||
| of the JSON version. `PtyJsonOptions` is a separate option type for PTY | ||
| operations with its own `Experimental` and optional `MxcPtySize? Size` | ||
| (24 rows by 80 columns by default). Non-PTY operations accept only | ||
| `JsonOptions`. Return types are the existing V1 execution and process types; | ||
| lifecycle and validation results are complete native response JSON strings, | ||
| without narrowing through typed V1 metadata. When importing both typed and | ||
| dev namespaces, qualify the dev facade (for example, | ||
| `using Dev = Microsoft.Mxc.Sdk.V1.Dev;`). | ||
|
|
||
| ```csharp | ||
| // Microsoft.Mxc.Sdk.V1.Dev.MxcContainer | ||
| ExecutionResult RunJson(string json, JsonOptions? options = null); | ||
| Task<ExecutionResult> RunJsonAsync(string json, JsonOptions? options = null, | ||
| CancellationToken cancellationToken = default); | ||
| MxcProcess SpawnJson(string json, JsonOptions? options = null); | ||
| Task<MxcProcess> SpawnJsonAsync(string json, JsonOptions? options = null, | ||
| CancellationToken cancellationToken = default); | ||
| MxcPtyProcess SpawnWithPtyJson(string json, PtyJsonOptions? options = null); | ||
|
|
||
| // Microsoft.Mxc.Sdk.V1.Dev.MxcLifecycle | ||
| ExecutionResult RunInContainerJson(string json, JsonOptions? options = null); | ||
| Task<ExecutionResult> RunInContainerJsonAsync(string json, JsonOptions? options = null, | ||
| CancellationToken cancellationToken = default); | ||
| MxcProcess SpawnInContainerJson(string json, JsonOptions? options = null); | ||
| Task<MxcProcess> SpawnInContainerJsonAsync(string json, JsonOptions? options = null, | ||
| CancellationToken cancellationToken = default); | ||
| MxcPtyProcess SpawnInContainerWithPtyJson(string json, PtyJsonOptions? options = null); | ||
|
|
||
| string ProvisionContainerJson(string json, JsonOptions? options = null); | ||
| Task<string> ProvisionContainerJsonAsync(string json, JsonOptions? options = null); | ||
| string StartContainerJson(string json, JsonOptions? options = null); | ||
| Task<string> StartContainerJsonAsync(string json, JsonOptions? options = null); | ||
| string StopContainerJson(string json, JsonOptions? options = null); | ||
| Task<string> StopContainerJsonAsync(string json, JsonOptions? options = null); | ||
| string DeprovisionContainerJson(string json, JsonOptions? options = null); | ||
| Task<string> DeprovisionContainerJsonAsync(string json, JsonOptions? options = null); | ||
|
|
||
| string ValidateProvisionJson(string json, JsonOptions? options = null); | ||
| Task<string> ValidateProvisionJsonAsync(string json, JsonOptions? options = null); | ||
| string ValidateStartJson(string json, JsonOptions? options = null); | ||
| Task<string> ValidateStartJsonAsync(string json, JsonOptions? options = null); | ||
| string ValidateStopJson(string json, JsonOptions? options = null); | ||
| Task<string> ValidateStopJsonAsync(string json, JsonOptions? options = null); | ||
| string ValidateDeprovisionJson(string json, JsonOptions? options = null); | ||
| Task<string> ValidateDeprovisionJsonAsync(string json, JsonOptions? options = null); | ||
| string ValidateProcessJson(string json, JsonOptions? options = null); | ||
| Task<string> ValidateProcessJsonAsync(string json, JsonOptions? options = null); | ||
| ``` | ||
|
|
||
| PTY entry points are synchronous only. Only the four async run/spawn methods | ||
| take cancellation tokens, matching their existing typed V1 counterparts. | ||
| One-shot `RunJsonAsync` cancellation stops awaiting, not native execution; | ||
| `RunInContainerJsonAsync` disposes its owned process on cancellation. Async | ||
| lifecycle operations run off the caller's thread but have no cancellation | ||
| token. Captured output is returned as lossy UTF-8 text; live handles retain | ||
| the existing V1 stream and disposal contract. | ||
| Timed-out in-container capture closes its readers and returns partial text | ||
| without deprovisioning the caller-owned container. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| # Node V1.Dev exact-JSON API | ||
|
|
||
| Public subpath: `@microsoft/mxc-sdk/v1/dev`. All operations accept one | ||
| complete caller-authored exact-version JSON string and return Promises. | ||
| The SDK never stamps a version or reserializes the document through the V1 | ||
| stable mapper. Native exact parsing remains authoritative for unknown fields, | ||
| unsupported versions, policy, and backend availability. There is no | ||
| package-root alias. | ||
|
|
||
| `JsonOptions` contains optional `experimental?: boolean` authorization, | ||
| independent of the authored JSON version. `PtyJsonOptions` additionally | ||
| contains optional `size?: MxcPtySize` (24 rows by 80 columns by default). | ||
| Execution returns the existing V1 result or process types. Lifecycle and | ||
| validation return the complete native response JSON string. Phase-specific | ||
| methods reject a different phase before native dispatch. | ||
|
|
||
| ```typescript | ||
| export function runJson(json: string, options?: JsonOptions): Promise<ExecutionResult>; | ||
| export function spawnJson(json: string, options?: JsonOptions): Promise<MxcProcess>; | ||
| export function spawnWithPtyJson(json: string, options?: PtyJsonOptions): Promise<MxcPtyProcess>; | ||
|
|
||
| export function runInContainerJson(json: string, options?: JsonOptions): Promise<ExecutionResult>; | ||
| export function spawnInContainerJson(json: string, options?: JsonOptions): Promise<MxcProcess>; | ||
| export function spawnInContainerWithPtyJson( | ||
| json: string, options?: PtyJsonOptions | ||
| ): Promise<MxcPtyProcess>; | ||
|
|
||
| export function provisionContainerJson(json: string, options?: JsonOptions): Promise<string>; | ||
| export function startContainerJson(json: string, options?: JsonOptions): Promise<string>; | ||
| export function stopContainerJson(json: string, options?: JsonOptions): Promise<string>; | ||
| export function deprovisionContainerJson(json: string, options?: JsonOptions): Promise<string>; | ||
| export function validateProvisionJson(json: string, options?: JsonOptions): Promise<string>; | ||
| export function validateStartJson(json: string, options?: JsonOptions): Promise<string>; | ||
| export function validateStopJson(json: string, options?: JsonOptions): Promise<string>; | ||
| export function validateDeprovisionJson(json: string, options?: JsonOptions): Promise<string>; | ||
| export function validateProcessJson(json: string, options?: JsonOptions): Promise<string>; | ||
| ``` | ||
|
|
||
| Captured stdout and stderr are returned as lossy UTF-8 text. Pipe and PTY | ||
| operations resolve with owning V1 handles after startup. Existing-container | ||
| execution does not deprovision its caller-owned container. On timeout, | ||
| in-container capture closes its output streams and returns the text collected | ||
| so far. If capture fails, disposal cannot replace the | ||
| original read or wait error; read failures reject without waiting for the | ||
| workload to exit. The Node ProcessContainer one-shot PTY route | ||
| passes the original UTF-8 JSON through `wxc-exec --config-base64`, including | ||
|
Comment on lines
+45
to
+46
|
||
| the historical `0.9.0-alpha` `appcontainer` alias, rather than the stable | ||
| typed mapper. Its Promise resolves when the executor starts, before the executor | ||
| finishes policy validation; subsequent failures appear in combined terminal | ||
| output and its exit code. This route cannot expose structured native warnings | ||
| or output metadata through its current terminal channel. It forwards | ||
| `process.timeout` to `wxc-exec`, but `wait().timedOut` remains `false` on an | ||
| executor exit even if the executor enforced that timeout; the terminal | ||
| channel supplies no distinct timeout outcome. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| # Rust V1.Dev exact-JSON API | ||
|
|
||
| Public entrypoint: `mxc_sdk::v1::dev`. All methods accept one complete, | ||
| caller-authored exact-version JSON document and execute through the | ||
| in-process engine. No method stamps a version, reserializes the request, or | ||
| takes a second container ID. Invalid versions, unknown fields, and malformed | ||
| JSON are rejected by the exact contract parser. | ||
|
Comment on lines
+6
to
+7
|
||
|
|
||
| `JsonOptions { experimental: bool }` authorizes an experimental backend | ||
| independently of the authored version. `PtyJsonOptions` also carries | ||
| `size: MxcPtySize` (24 rows by 80 columns by default). The full request, | ||
| including its version, phase, and any container ID, is a single JSON string. | ||
| Result and process types are the existing `mxc_sdk::v1` types. | ||
|
|
||
| `run_json` and `run_in_container_json` return byte-preserving | ||
| `ExecutionResult` values; a nonzero workload exit or timeout is an outcome, | ||
| not an API error. Pipe and PTY spawns return owned `MxcProcess` and | ||
| `MxcPtyProcess` handles. Existing-container execution does not deprovision | ||
| the caller-owned container. The phase-specific lifecycle and validation | ||
| methods require the matching `phase` in the JSON before dispatch; validation | ||
| uses native dry-run behavior. They return the complete native response | ||
| envelope as a `String`, including backend-specific metadata. | ||
|
|
||
| ```rust | ||
| pub fn run_json(json: &str, options: JsonOptions) -> Result<ExecutionResult, Error>; | ||
| pub fn spawn_json(json: &str, options: JsonOptions) -> Result<MxcProcess, Error>; | ||
| pub fn spawn_with_pty_json(json: &str, options: PtyJsonOptions) | ||
| -> Result<MxcPtyProcess, Error>; | ||
|
|
||
| pub fn run_in_container_json(json: &str, options: JsonOptions) | ||
| -> Result<ExecutionResult, Error>; | ||
| pub fn spawn_in_container_json(json: &str, options: JsonOptions) -> Result<MxcProcess, Error>; | ||
| pub fn spawn_in_container_with_pty_json(json: &str, options: PtyJsonOptions) | ||
| -> Result<MxcPtyProcess, Error>; | ||
|
|
||
| pub fn provision_container_json(json: &str, options: JsonOptions) -> Result<String, Error>; | ||
| pub fn start_container_json(json: &str, options: JsonOptions) -> Result<String, Error>; | ||
| pub fn stop_container_json(json: &str, options: JsonOptions) -> Result<String, Error>; | ||
| pub fn deprovision_container_json(json: &str, options: JsonOptions) -> Result<String, Error>; | ||
| pub fn validate_provision_json(json: &str, options: JsonOptions) -> Result<String, Error>; | ||
| pub fn validate_start_json(json: &str, options: JsonOptions) -> Result<String, Error>; | ||
| pub fn validate_stop_json(json: &str, options: JsonOptions) -> Result<String, Error>; | ||
| pub fn validate_deprovision_json(json: &str, options: JsonOptions) -> Result<String, Error>; | ||
| pub fn validate_process_json(json: &str, options: JsonOptions) -> Result<String, Error>; | ||
| ``` | ||
|
|
||
| Capture uses pipe-backed execution: a backend without piped execution | ||
| rejects this mode with `UnsupportedContainment` even when experimental | ||
| access is authorized. PTY and state-aware support also depend on the | ||
|
|
||
| selected backend and host. Unsupported modes fail rather than switching to | ||
| another I/O mode. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm trying to reason over the overall design.
Is it a normal SDK pattern to have a complete a ::dev:: namespace that duplicates the API surface for active development?
Could it be something like,
ContainerRequestDevthat just holds the json string)SpawnAPI to accept an interface,IContainerRequest?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that way there's only one
Spawnfunction and it's easier for consumer to migrate code from "dev" to stableThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for raising the migration ergonomics. The separate V1.Dev surface is intentional: typed V1 Spawn(ContainerRequest) emits the SDK-owned published contract with no experimental opt-in, while SpawnJson preserves the caller-authored exact version and takes backend authorization separately. An IContainerRequest overload would mix those contracts in the stable facade, and it would not address lifecycle calls whose JSON owns the phase/id and whose response can contain evolving metadata. The one-shot result and process-handle types are already shared. Moving a promoted feature to typed V1 still requires converting the request fields; sharing the Spawn name would not remove that step. I would keep explicit *Json operations in this PR and consider a cross-SDK convenience surface separately if migration friction warrants it.